Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for 'asdf' sdk manager #240

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions scripts/package/dump
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ source "$DOTLY_PATH/scripts/package/src/dump.sh"
##? * Python
##? * Volta.sh or NPM
##? * Winget
##? * asdf
##?
##? Usage:
##? dump
Expand All @@ -34,4 +35,6 @@ fi

platform::command_exists winget.exe && package::winget_dump && output::answer "Windows apps dumped on $WINGET_DUMP_FILE_PATH"

platform::command_exists asdf && package::asdf_dump && output::answer "asdf SDKs dumped on $ASDF_DUMP_FILE_PATH"

output::write 'All packages dumped'
2 changes: 2 additions & 0 deletions scripts/package/import
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,6 @@ fi

platform::command_exists winget.exe && output::header "Importing Winget apps from $WINGET_DUMP_FILE_PATH" && package::winget_import

platform::command_exists asdf && output::header "Importing Asdf apps from $ASDF_DUMP_FILE_PATH" && package::asdf_import

output::solution 'All packages imported'
35 changes: 35 additions & 0 deletions scripts/package/src/dump.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ PYTHON_DUMP_FILE_PATH="$DOTFILES_PATH/langs/python/requirements.txt"
SNAP_DUMP_FILE_PATH="$DOTFILES_PATH/os/linux/snap/packages.txt"
VOLTA_DUMP_FILE_PATH="$DOTFILES_PATH/langs/js/volta_dependencies.txt"
WINGET_DUMP_FILE_PATH="$DOTFILES_PATH/os/windows/winget.output"
ASDF_DUMP_FILE_PATH="$DOTFILES_PATH/langs/sdk/asdf.txt"

package::brew_dump() {
if platform::is_macos; then
Expand Down Expand Up @@ -124,3 +125,37 @@ package::pacman_import() {
yay -s "$(cat $PACMAN_DUMP_FILE_PATH)"
fi
}

package::asdf_dump() {
mkdir -p "$DOTFILES_PATH/langs/sdk"
echo -n >$ASDF_DUMP_FILE_PATH

for plug in $(asdf plugin-list); do
for ver in $(asdf list $plug | awk '{print $1; }'); do
if [ -z "$ver" ]; then
echo "No versions installed for $plug"
else
echo "$plug $ver" >>$ASDF_DUMP_FILE_PATH
fi
done
done
}

package::asdf_import() {
if [ -f "$ASDF_DUMP_FILE_PATH" ]; then
for plug in $(cat $ASDF_DUMP_FILE_PATH | awk '{ print $1 }' | uniq); do
echo "asdf plugin-add $plug"
done
while read -r line; do
plug=$(echo $line | awk '{print $1; }')
ver=$(echo $line | awk '{print $2; }')
if [[ $ver == \** ]]; then
ver=${ver:1}
echo "asdf install $plug $ver"
echo "asdf global $plug $ver"
else
echo "asdf install $plug $ver"
fi
done <$ASDF_DUMP_FILE_PATH
fi
}