From 97dc93ef6241ed2864bc1d250f4bec1a1dc23d88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C4=83t=C4=83lin=20Mari=C8=99?= Date: Mon, 4 Sep 2023 22:48:41 -0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=A5=20Switch=20from=20using=20nvm=20to?= =?UTF-8?q?=20using=20Volta?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ref: https://volta.sh/ --- src/os/installs/macos/main.sh | 2 +- src/os/installs/macos/misc_tools.sh | 5 +- src/os/installs/nvm.sh | 87 ---------------------------- src/os/installs/ubuntu/main.sh | 2 +- src/os/installs/ubuntu/misc_tools.sh | 21 +++---- src/os/installs/volta.sh | 64 ++++++++++++++++++++ 6 files changed, 76 insertions(+), 105 deletions(-) delete mode 100755 src/os/installs/nvm.sh create mode 100755 src/os/installs/volta.sh diff --git a/src/os/installs/macos/main.sh b/src/os/installs/macos/main.sh index 78ea84858..da02b6c2e 100755 --- a/src/os/installs/macos/main.sh +++ b/src/os/installs/macos/main.sh @@ -11,7 +11,7 @@ cd "$(dirname "${BASH_SOURCE[0]}")" \ ./bash.sh ./git.sh -./../nvm.sh +./../volta.sh ./browsers.sh ./compression_tools.sh ./gpg.sh diff --git a/src/os/installs/macos/misc_tools.sh b/src/os/installs/macos/misc_tools.sh index 6eb262ebe..6eda06d99 100755 --- a/src/os/installs/macos/misc_tools.sh +++ b/src/os/installs/macos/misc_tools.sh @@ -9,7 +9,4 @@ cd "$(dirname "${BASH_SOURCE[0]}")" \ print_in_purple "\n Miscellaneous Tools\n\n" brew_install "ShellCheck" "shellcheck" - -if [ -d "$HOME/.nvm" ]; then - brew_install "Yarn" "yarn" -fi +brew_install "Yarn" "yarn" diff --git a/src/os/installs/nvm.sh b/src/os/installs/nvm.sh deleted file mode 100755 index 58ccefe04..000000000 --- a/src/os/installs/nvm.sh +++ /dev/null @@ -1,87 +0,0 @@ -#!/bin/bash - -cd "$(dirname "${BASH_SOURCE[0]}")" \ - && . "../utils.sh" - -declare -r LOCAL_SHELL_CONFIG_FILE="$HOME/.bash.local" -declare -r NVM_DIRECTORY="$HOME/.nvm" -declare -r NVM_GIT_REPO_URL="https://github.com/nvm-sh/nvm.git" - -# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -add_nvm_configs() { - - declare -r CONFIGS=" -# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# Node Version Manager - -export NVM_DIR=\"$NVM_DIRECTORY\" - -[ -f \"\$NVM_DIR/nvm.sh\" ] \\ - && . \"\$NVM_DIR/nvm.sh\" - -[ -f \"\$NVM_DIR/bash_completion\" ] \\ - && . \"\$NVM_DIR/bash_completion\" -" - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - execute \ - "printf '%s' '$CONFIGS' >> $LOCAL_SHELL_CONFIG_FILE \ - && . $LOCAL_SHELL_CONFIG_FILE" \ - "Update $LOCAL_SHELL_CONFIG_FILE" - -} - -install_latest_stable_node() { - - # Install the latest stable version of Node - # (this will also set it as the default). - - execute \ - ". $LOCAL_SHELL_CONFIG_FILE \ - && nvm install --lts" \ - "Install Node LTS" -} - -install_nvm() { - - # Install `nvm` and add the necessary - # configs in the local shell config file. - - execute \ - "git clone --quiet $NVM_GIT_REPO_URL $NVM_DIRECTORY" \ - "Install" \ - && add_nvm_configs - -} - -update_nvm() { - - execute \ - "cd $NVM_DIRECTORY \ - && git fetch --quiet origin \ - && git checkout --quiet \$(git describe --abbrev=0 --tags) \ - && . $NVM_DIRECTORY/nvm.sh" \ - "Upgrade" - -} - -# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -main() { - - print_in_purple "\n nvm\n\n" - - if [ ! -d "$NVM_DIRECTORY" ]; then - install_nvm - else - update_nvm - fi - - install_latest_stable_node - -} - -main diff --git a/src/os/installs/ubuntu/main.sh b/src/os/installs/ubuntu/main.sh index 01a73e686..6a21fe72b 100755 --- a/src/os/installs/ubuntu/main.sh +++ b/src/os/installs/ubuntu/main.sh @@ -12,12 +12,12 @@ upgrade ./build-essentials.sh ./git.sh -./../nvm.sh ./browsers.sh ./compression_tools.sh ./image_tools.sh ./misc.sh ./misc_tools.sh +./../volta.sh ./../npm.sh ./tmux.sh ./../vim.sh diff --git a/src/os/installs/ubuntu/misc_tools.sh b/src/os/installs/ubuntu/misc_tools.sh index 669ad2737..c9e4abe10 100755 --- a/src/os/installs/ubuntu/misc_tools.sh +++ b/src/os/installs/ubuntu/misc_tools.sh @@ -12,20 +12,17 @@ install_package "cURL" "curl" install_package "ShellCheck" "shellcheck" install_package "xclip" "xclip" -if [ -d "$HOME/.nvm" ]; then +if ! package_is_installed "yarn"; then - if ! package_is_installed "yarn"; then + add_key "https://dl.yarnpkg.com/debian/pubkey.gpg" \ + || print_error "Yarn (add key)" - add_key "https://dl.yarnpkg.com/debian/pubkey.gpg" \ - || print_error "Yarn (add key)" + add_to_source_list "https://dl.yarnpkg.com/debian/ stable main" "yarn.list" \ + || print_error "Yarn (add to package resource list)" - add_to_source_list "https://dl.yarnpkg.com/debian/ stable main" "yarn.list" \ - || print_error "Yarn (add to package resource list)" + update &> /dev/null \ + || print_error "Yarn (resync package index files)" - update &> /dev/null \ - || print_error "Yarn (resync package index files)" - - fi - - install_package "Yarn" "yarn" "--no-install-recommends" fi + +install_package "Yarn" "yarn" "--no-install-recommends" diff --git a/src/os/installs/volta.sh b/src/os/installs/volta.sh new file mode 100755 index 000000000..5b78744b8 --- /dev/null +++ b/src/os/installs/volta.sh @@ -0,0 +1,64 @@ +#!/bin/bash + +cd "$(dirname "${BASH_SOURCE[0]}")" \ + && . "../utils.sh" + +declare -r LOCAL_SHELL_CONFIG_FILE="$HOME/.bash.local" + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +add_configs() { + + # Check if the configs need to be added. + + . "$LOCAL_SHELL_CONFIG_FILE" + + if command -v volta &> /dev/null; then + return + fi + + declare -r CONFIGS=" +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +# Volta + +export PATH=\"\$HOME/.volta/bin:\$PATH\" +" + + execute \ + "printf '%s' '$CONFIGS' >> $LOCAL_SHELL_CONFIG_FILE" \ + "Update $LOCAL_SHELL_CONFIG_FILE" + +} + +install() { + execute \ + "curl https://get.volta.sh | bash -s -- --skip-setup" \ + "Install" +} + +install_node() { + + # Install Node.js LTS. + # Note: This will also set it as the default. + + execute \ + ". $LOCAL_SHELL_CONFIG_FILE && \ + volta install node" \ + "Install Node.js LTS" + +} + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +main() { + + print_in_purple "\n Volta\n\n" + + install + add_configs + install_node + +} + +main