Use ASDF version manager

At first, we did Ruby work, so we needed a ruby version manager.
Then we needed Node, so some of us added a node version manager.
Some of work with varying versions of Python, Elixir, Elm, etc.
ASDF lets us stop searching out solutions to the same problem in
each of these languges by supporting [plugins][1].

[1]: https://github.com/asdf-vm/asdf-plugins/tree/master/plugins
trunk
Derek Prior 7 years ago committed by Derek Prior
parent cfda02a041
commit 2210951f07
No known key found for this signature in database
GPG Key ID: 60D9C7F1019704B4

@ -115,10 +115,9 @@ Testing tools:
Programming languages, package managers, and configuration:
* [ASDF] for managing programming language versions
* [Bundler] for managing Ruby libraries
* [Node.js] and [NPM], for running apps and installing JavaScript packages
* [Rbenv] for managing versions of Ruby
* [Ruby Build] for installing Rubies
* [Ruby] stable for writing general-purpose code
* [Yarn] for managing JavaScript packages
@ -126,8 +125,7 @@ Programming languages, package managers, and configuration:
[ImageMagick]: http://www.imagemagick.org/
[Node.js]: http://nodejs.org/
[NPM]: https://www.npmjs.org/
[Rbenv]: https://github.com/sstephenson/rbenv
[Ruby Build]: https://github.com/sstephenson/ruby-build
[ASDF]: https://github.com/asdf-vm/asdf
[Ruby]: https://www.ruby-lang.org/en/
[Yarn]: https://yarnpkg.com/en/

56
mac

@ -86,7 +86,6 @@ gem_install_or_update() {
gem update "$@"
else
gem install "$@"
rbenv rehash
fi
}
@ -114,6 +113,7 @@ brew bundle --file=- <<EOF
tap "thoughtbot/formulae"
tap "homebrew/services"
tap "universal-ctags/universal-ctags"
tap "caskroom/cask"
# Unix
brew "universal-ctags", args: ["HEAD"]
@ -140,12 +140,11 @@ brew "imagemagick"
# Testing
brew "qt@5.5" if MacOS::Xcode.installed?
# Programming languages and package managers
# Programming language prerequisites and package managers
brew "libyaml" # should come after openssl
brew "node"
brew "rbenv"
brew "ruby-build"
brew "coreutils"
brew "yarn"
cask "gpgtools"
# Databases
brew "postgres", restart_service: :changed
@ -162,27 +161,48 @@ fancy_echo "Update heroku binary..."
brew unlink heroku
brew link --force heroku
fancy_echo "Configuring Ruby ..."
find_latest_ruby() {
rbenv install -l | grep -v - | tail -1 | sed -e 's/^ *//'
fancy_echo "Configuring asdf version manager..."
if [ ! -d "$HOME/.asdf" ]; then
git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.3.0
append_to_zshrc "source $HOME/.asdf/asdf.sh" 1
fi
install_asdf_plugin() {
local name="$1"
local url="$2"
if ! asdf plugin-list | grep -Fq "$name"; then
asdf plugin-add "$name" "$url"
fi
}
ruby_version="$(find_latest_ruby)"
# shellcheck disable=SC2016
append_to_zshrc 'eval "$(rbenv init - --no-rehash)"' 1
eval "$(rbenv init -)"
# shellcheck disable=SC1090
source "$HOME/.asdf/asdf.sh"
install_asdf_plugin "ruby" "https://github.com/asdf-vm/asdf-ruby.git"
install_asdf_plugin "nodejs" "https://github.com/asdf-vm/asdf-nodejs.git"
if ! rbenv versions | grep -Fq "$ruby_version"; then
RUBY_CONFIGURE_OPTS=--with-openssl-dir=/usr/local/opt/openssl rbenv install -s "$ruby_version"
fi
install_asdf_language() {
local language="$1"
local version
version="$(asdf list-all "$language" | tail -1)"
rbenv global "$ruby_version"
rbenv shell "$ruby_version"
if ! asdf list "$language" | grep -Fq "$version"; then
asdf install "$language" "$version"
asdf global "$language" "$version"
fi
}
fancy_echo "Installing latest Ruby..."
install_asdf_language "ruby"
gem update --system
gem_install_or_update 'bundler'
gem_install_or_update "bundler"
number_of_cores=$(sysctl -n hw.ncpu)
bundle config --global jobs $((number_of_cores - 1))
fancy_echo "Installing latest Node..."
bash "$HOME/.asdf/plugins/nodejs/bin/import-release-team-keyring"
install_asdf_language "nodejs"
if [ -f "$HOME/.laptop.local" ]; then
fancy_echo "Running your customizations from ~/.laptop.local ..."
# shellcheck disable=SC1090

Loading…
Cancel
Save