From aac4e4c6a13e42527ccd6d6a68382e8b3d217a9a Mon Sep 17 00:00:00 2001 From: Luis Mayta Date: Sun, 10 Nov 2024 18:39:16 -0300 Subject: [PATCH] feat(core): implement function for install rvm (#57) --- config/base.zsh | 4 +- internal/base.zsh | 93 +++++++++++++++++++++++++---------------------- 2 files changed, 51 insertions(+), 46 deletions(-) diff --git a/config/base.zsh b/config/base.zsh index 659d416..73ac5a1 100644 --- a/config/base.zsh +++ b/config/base.zsh @@ -1,7 +1,7 @@ #!/usr/bin/env ksh # -*- coding: utf-8 -*- -export RVM_MESSAGE_BREW="Please install brew or use antibody bundle luismayta/zsh-brew branch:develop" +export RVM_MESSAGE_BREW="Please install brew or use antibody bundle hadenlabs/zsh-brew" export RVM_PACKAGE_NAME=rvm export RVM_ROOT="${HOME}"/.rvm export RVM_CACHE_DIR="${HOME}/.cache/rvm" @@ -15,4 +15,4 @@ export RVM_PACKAGES=( terminal-notifier solargraph bundler -) +) \ No newline at end of file diff --git a/internal/base.zsh b/internal/base.zsh index 95da65d..d665320 100644 --- a/internal/base.zsh +++ b/internal/base.zsh @@ -2,68 +2,73 @@ # -*- coding: utf-8 -*- function rvm::internal::rvm::install { - message_info "Installing ${RVM_PACKAGE_NAME}" - rvm::internal::install::gpg + message_info "Installing ${RVM_PACKAGE_NAME}" + rvm::internal::install::gpg - curl -sSL https://get.rvm.io | bash -s stable - rvm get stable - rvm::internal::rvm::load - message_success "Installed ${RVM_PACKAGE_NAME}" + curl -sSL https://get.rvm.io | bash -s stable + rvm get stable + rvm::internal::rvm::load + message_success "Installed ${RVM_PACKAGE_NAME}" } function rvm::internal::install::gpg { - if core::exists gpg; then - gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 - fi + if core::exists gpg; then + gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 + fi - if core::exists gpg2; then - gpg2 --keyserver hkp://pool.sks-keyservers.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB - fi + if core::exists gpg2; then + gpg2 --keyserver hkp://pool.sks-keyservers.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB + fi - command curl -sSL https://rvm.io/mpapis.asc | gpg --import - - command curl -sSL https://rvm.io/pkuczynski.asc | gpg --import - + command curl -sSL https://rvm.io/mpapis.asc | gpg --import - + command curl -sSL https://rvm.io/pkuczynski.asc | gpg --import - } function rvm::internal::rvm::load { - # Add RVM to PATH for scripting - [ -e "${RVM_ROOT}/bin" ] && export PATH="${PATH}:${RVM_ROOT}/bin" - [ -e "/usr/local/rvm/bin" ] && export PATH="${PATH}:/usr/local/rvm/bin" + # Add RVM to PATH for scripting + [ -e "${RVM_ROOT}/bin" ] && export PATH="${PATH}:${RVM_ROOT}/bin" + [[ -s "${RVM_ROOT}/scripts/rvm" ]] && . "${RVM_ROOT}/scripts/rvm" } function rvm::internal::packages::install { - if ! core::exists gem; then - message_warning "it's neccesary have gem" - return - fi + if ! core::exists gem; then + message_warning "it's neccesary have gem" + return + fi - message_info "Installing required gem packages" - gem install "${RVM_PACKAGES[@]}" - message_success "Installed required gem packages" + message_info "Installing required gem packages" + gem install "${RVM_PACKAGES[@]}" + message_success "Installed required gem packages" +} + +function rvm::internal::version::install { + local version=${1} + rvm install ${version} } function rvm::internal::version::all::install { - if ! core::exists rvm; then - message_warning "not found rvm" - return - fi + if ! core::exists rvm; then + message_warning "not found rvm" + return + fi - for version in "${RVM_VERSIONS[@]}"; do - message_info "Install version of rvm ${version}" - rvm install "${version}" - message_success "Installed version of rvm ${version}" - done - rvm use "${RVM_VERSION_GLOBAL}" --default - message_success "Installed versions of rvm" + for version in "${RVM_VERSIONS[@]}"; do + message_info "Install version of rvm ${version}" + rvm::internal::version::install "${version}" + message_success "Installed version of rvm ${version}" + done + rvm use "${RVM_VERSION_GLOBAL}" --default + message_success "Installed versions of rvm" } function rvm::internal::version::global::install { - if ! core::exists rvm; then - message_warning "not found rvm" - return - fi - message_info "Installing version global of rvm ${RVM_VERSION_GLOBAL}" - rvm install "${RVM_VERSION_GLOBAL}" - rvm use "${RVM_VERSION_GLOBAL}" --default - message_success "Installed version global of rvm ${RVM_VERSION_GLOBAL}" -} + if ! core::exists rvm; then + message_warning "not found rvm" + return + fi + message_info "Installing version global of rvm ${RVM_VERSION_GLOBAL}" + rvm::internal::version::install "${RVM_VERSION_GLOBAL}" + rvm use "${RVM_VERSION_GLOBAL}" --default + message_success "Installed version global of rvm ${RVM_VERSION_GLOBAL}" +} \ No newline at end of file