diff --git a/.gitignore b/.gitignore index d34c3dd7..35b5507a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ installs sources +plugins shims diff --git a/README.md b/README.md index 1a2a5898..6d45cb60 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,11 @@ ### _extendable version manager_ > I've built plugins to support the following languages: -> * [Ruby](#TODO) +> * [Ruby](https://github.com/HashNuke/asdf-ruby) > * [Erlang](https://github.com/HashNuke/asdf-erlang) > * [Elixir](https://github.com/HashNuke/asdf-elixir) > -> There is a [super-simple API](https://github.com/HashNuke/asdf/blob/master/docs/creating-package-sources.md) for supporting more languages. +> There is a [super-simple API](https://github.com/HashNuke/asdf/blob/master/docs/creating-plugins.md) for supporting more languages. --- @@ -36,40 +36,40 @@ echo 'source $HOME/.asdf/asdf.sh' >> ~/.bash_profile ## USAGE -### Manage sources +### Manage plugins -Sources are how asdf understands how to handle packages. +Plugins are how asdf understands how to handle different packages. -##### Add a package source +##### Add a plugin ```bash -asdf source-add -# asdf add-source erlang https://github.com/HashNuke/asdf-erlang.git +asdf plugin-add +# asdf plugin-add erlang https://github.com/HashNuke/asdf-erlang.git ``` -##### Remove a source +##### Remove a plugin ```bash -asdf source-remove -# asdf remove-source erlang +asdf plugin-remove +# asdf plugin-remove erlang ``` -##### Update sources +##### Update plugins ```bash -asdf source-update --all +asdf plugin-update --all ``` If you want to update a specific package, just say so. ```bash -asdf source-update -# asdf update-source erlang +asdf plugin-update +# asdf plugin-update erlang ``` -### Manage packages +### Manage versions ```bash asdf install diff --git a/bin/asdf b/bin/asdf index 3fe4e347..d3d55c8d 100755 --- a/bin/asdf +++ b/bin/asdf @@ -8,9 +8,9 @@ source $(dirname $(dirname $0))/lib/commands/uninstall.sh source $(dirname $(dirname $0))/lib/commands/list.sh source $(dirname $(dirname $0))/lib/commands/list-all.sh source $(dirname $(dirname $0))/lib/commands/reshim.sh -source $(dirname $(dirname $0))/lib/commands/source-add.sh -source $(dirname $(dirname $0))/lib/commands/source-update.sh -source $(dirname $(dirname $0))/lib/commands/source-remove.sh +source $(dirname $(dirname $0))/lib/commands/plugin-add.sh +source $(dirname $(dirname $0))/lib/commands/plugin-update.sh +source $(dirname $(dirname $0))/lib/commands/plugin-remove.sh callback_args="${@:2}" @@ -38,14 +38,14 @@ case $1 in "reshim") reshim_command $callback_args;; -"source-add") - source_add_command $callback_args;; +"plugin-add") + plugin_add_command $callback_args;; -"source-update") - source_update_command $callback_args;; +"plugin-update") + plugin_update_command $callback_args;; -"source-remove") - source_remove_command $callback_args;; +"plugin-remove") + plugin_remove_command $callback_args;; *) help_command diff --git a/bin/private/asdf-exec b/bin/private/asdf-exec index b022fa5f..8c51a4c1 100755 --- a/bin/private/asdf-exec +++ b/bin/private/asdf-exec @@ -6,7 +6,7 @@ package=$1 executable_path=$2 source_path=$(get_source_path $package) -check_if_source_exists $source_path +check_if_plugin_exists $plugin_path full_version=$(get_preset_version_for $package) diff --git a/help.txt b/help.txt index 6fca99c9..5b6bad7c 100644 --- a/help.txt +++ b/help.txt @@ -1,16 +1,16 @@ -MANAGE PACKAGE SOURCES +MANAGE PLUGINS - asdf source-add - Add git repo as source for a package + asdf plugin-add + Add git repo as plugin - asdf source-remove - Remove package source and versions + asdf plugin-remove + Remove plugin and versions - asdf source-update - Update package source + asdf plugin-update + Update plugin - asdf source-updatee --all - Update sources for all packages + asdf plugin-updatee --all + Update all plugins MANAGE PACKAGES diff --git a/lib/commands/install.sh b/lib/commands/install.sh index 1c4b5d69..80122080 100644 --- a/lib/commands/install.sh +++ b/lib/commands/install.sh @@ -1,8 +1,8 @@ install_command() { local package_name=$1 local full_version=$2 - local source_path=$(get_source_path $package_name) - check_if_source_exists $source_path + local plugin_path=$(get_plugin_path $package_name) + check_if_plugin_exists $plugin_path IFS=':' read -a version_info <<< "$full_version" if [ "${version_info[0]}" = "tag" ] || [ "${version_info[0]}" = "commit" ]; then @@ -14,6 +14,6 @@ install_command() { fi local install_path=$(get_install_path $package_name $install_type $version) - ${source_path}/bin/install $install_type $version $install_path + ${plugin_path}/bin/install $install_type $version $install_path reshim_command $package_name $full_version } diff --git a/lib/commands/list-all.sh b/lib/commands/list-all.sh index abe34077..76f597c8 100644 --- a/lib/commands/list-all.sh +++ b/lib/commands/list-all.sh @@ -1,8 +1,8 @@ list_all_command() { local package_name=$1 - local source_path=$(get_source_path $package_name) - check_if_source_exists $source_path - local versions=$( ${source_path}/bin/list-all ) + local plugin_path=$(get_plugin_path $package_name) + check_if_plugin_exists $plugin_path + local versions=$( ${plugin_path}/bin/list-all ) IFS=' ' read -a versions_list <<< "$versions" diff --git a/lib/commands/list.sh b/lib/commands/list.sh index ce80cc05..8f8cdc50 100644 --- a/lib/commands/list.sh +++ b/lib/commands/list.sh @@ -1,7 +1,7 @@ list_command() { local package_name=$1 - local source_path=$(get_source_path $package_name) - check_if_source_exists $source_path + local plugin_path=$(get_plugin_path $package_name) + check_if_plugin_exists $plugin_path local package_installs_path=$(asdf_dir)/installs/${package_name} diff --git a/lib/commands/plugin-add.sh b/lib/commands/plugin-add.sh new file mode 100644 index 00000000..0fcd41ad --- /dev/null +++ b/lib/commands/plugin-add.sh @@ -0,0 +1,11 @@ +plugin_add_command() { + local package_name=$1 + local source_url=$2 + local plugin_path=$(get_plugin_path $package_name) + + mkdir -p $(asdf_dir)/sources + git clone $source_url $plugin_path + if [ $? -eq 0 ]; then + chmod +x $plugin_path/bin/* + fi +} diff --git a/lib/commands/plugin-remove.sh b/lib/commands/plugin-remove.sh new file mode 100644 index 00000000..bdf6bdb4 --- /dev/null +++ b/lib/commands/plugin-remove.sh @@ -0,0 +1,7 @@ +plugin_remove_command() { + local package_name=$1 + local plugin_path=$(get_plugin_path $package_name) + + rm -rf $plugin_path + rm -rf $(asdf_dir)/installs/${package_name} +} diff --git a/lib/commands/source-update.sh b/lib/commands/plugin-update.sh similarity index 50% rename from lib/commands/source-update.sh rename to lib/commands/plugin-update.sh index 1df0611e..c617e74a 100644 --- a/lib/commands/source-update.sh +++ b/lib/commands/plugin-update.sh @@ -1,12 +1,12 @@ -source_update_command() { +plugin_update_command() { local package_name=$1 if [ "$package_name" = "--all" ]; then for dir in $(asdf_dir)/sources/*; do (cd "$dir" && git pull) done else - local source_path=$(get_source_path $package_name) - check_if_source_exists $source_path - (cd $source_path; git pull) + local plugin_path=$(get_plugin_path $package_name) + check_if_plugin_exists $plugin_path + (cd $plugin_path; git pull) fi } diff --git a/lib/commands/reshim.sh b/lib/commands/reshim.sh index bc409452..b1bffb3f 100644 --- a/lib/commands/reshim.sh +++ b/lib/commands/reshim.sh @@ -2,8 +2,8 @@ reshim_command() { local package_name=$1 local full_version=$2 local executable_path=$3 - local source_path=$(get_source_path $package_name) - check_if_source_exists $source_path + local plugin_path=$(get_plugin_path $package_name) + check_if_plugin_exists $plugin_path ensure_shims_dir # If full version is empty then generate shims for all versions in the package @@ -52,9 +52,9 @@ generate_shim_for_executable() { local package_name=$1 local full_version=$2 local executable=$3 - local source_path=$(get_source_path $package_name) + local plugin_path=$(get_plugin_path $package_name) - check_if_source_exists $source_path + check_if_plugin_exists $plugin_path IFS=':' read -a version_info <<< "$full_version" if [ "${version_info[0]}" = "tag" ] || [ "${version_info[0]}" = "commit" ]; then @@ -72,8 +72,8 @@ generate_shim_for_executable() { generate_shims_for_version() { local package_name=$1 local full_version=$2 - local source_path=$(get_source_path $package_name) - check_if_source_exists $source_path + local plugin_path=$(get_plugin_path $package_name) + check_if_plugin_exists $plugin_path IFS=':' read -a version_info <<< "$full_version" if [ "${version_info[0]}" = "tag" ] || [ "${version_info[0]}" = "commit" ]; then @@ -86,8 +86,8 @@ generate_shims_for_version() { local install_path=$(get_install_path $package_name $install_type $version) - if [ -f ${source_path}/bin/list-bin-paths ]; then - local space_seperated_list_of_bin_paths=$(sh ${source_path}/bin/list-bin-paths $package_name $install_type $version "${@:2}") + if [ -f ${plugin_path}/bin/list-bin-paths ]; then + local space_seperated_list_of_bin_paths=$(sh ${plugin_path}/bin/list-bin-paths $package_name $install_type $version "${@:2}") else local space_seperated_list_of_bin_paths="bin" fi diff --git a/lib/commands/source-add.sh b/lib/commands/source-add.sh deleted file mode 100644 index 169134e7..00000000 --- a/lib/commands/source-add.sh +++ /dev/null @@ -1,11 +0,0 @@ -source_add_command() { - local package_name=$1 - local source_url=$2 - local source_path=$(get_source_path $package_name) - - mkdir -p $(asdf_dir)/sources - git clone $source_url $source_path - if [ $? -eq 0 ]; then - chmod +x $source_path/bin/* - fi -} diff --git a/lib/commands/source-remove.sh b/lib/commands/source-remove.sh deleted file mode 100644 index fd1d8ffd..00000000 --- a/lib/commands/source-remove.sh +++ /dev/null @@ -1,7 +0,0 @@ -source_remove_command() { - local package_name=$1 - local source_path=$(get_source_path $package_name) - - rm -rf $source_path - rm -rf $(asdf_dir)/installs/${package_name} -} diff --git a/lib/commands/uninstall.sh b/lib/commands/uninstall.sh index d1c7063f..82b60a24 100644 --- a/lib/commands/uninstall.sh +++ b/lib/commands/uninstall.sh @@ -1,9 +1,9 @@ uninstall_command() { local package_name=$1 local full_version=$2 - local source_path=$(get_source_path $package_name) + local plugin_path=$(get_plugin_path $package_name) - check_if_source_exists $source_path + check_if_plugin_exists $plugin_path IFS=':' read -a version_info <<< "$full_version" if [ "${version_info[0]}" = "tag" ] || [ "${version_info[0]}" = "commit" ]; then @@ -21,8 +21,8 @@ uninstall_command() { exit 1 fi - if [ -f ${source_path}/bin/uninstall ]; then - ${source_path}/bin/uninstall $install_type $version $install_path "${@:3}" + if [ -f ${plugin_path}/bin/uninstall ]; then + ${plugin_path}/bin/uninstall $install_type $version $install_path "${@:3}" else rm -rf $install_path fi diff --git a/lib/utils.sh b/lib/utils.sh index 5f12e7bc..ab1aa6c2 100644 --- a/lib/utils.sh +++ b/lib/utils.sh @@ -28,10 +28,10 @@ get_install_path() { } -check_if_source_exists() { +check_if_plugin_exists() { if [ ! -d $1 ] then - display_error "No such package" + display_error "No such plugin" exit 1 fi } @@ -43,8 +43,8 @@ get_version_part() { } -get_source_path() { - echo $(asdf_dir)/sources/$1 +get_plugin_path() { + echo $(asdf_dir)/plugins/$1 }