Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jrrom committed Nov 5, 2023
1 parent 42d76ad commit 4e29714
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 12 deletions.
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@

# Dependencies

**TODO: adapt this section**

- `bash`, `curl`, `tar`: generic POSIX utilities.
- `SOME_ENV_VAR`: set this environment variable in your shell config to load the correct version of tool x.
- `node` and `purs`

# Install

Expand Down Expand Up @@ -55,6 +53,12 @@ Contributions of any kind welcome! See the [contributing guide](contributing.md)

[Thanks goes to these contributors](https://github.com/jrrom/asdf-spago/graphs/contributors)!

# Thanks

Special thanks to [asdf](https://github.com/asdf-vm/asdf)

[nsaunders](https://github.com/nsaunders/asdf-spago) (Now archived)

# License

See [LICENSE](LICENSE) © [jrrom](https://github.com/jrrom/)
1 change: 0 additions & 1 deletion bin/download
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ source "${plugin_dir}/lib/utils.bash"

mkdir -p "$ASDF_DOWNLOAD_PATH"

# TODO: Adapt this to proper extension and adapt extracting strategy.
release_file="$ASDF_DOWNLOAD_PATH/$TOOL_NAME-$ASDF_INSTALL_VERSION.tar.gz"

# Download tar.gz file to the download directory
Expand Down
1 change: 0 additions & 1 deletion contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ Testing Locally:
```shell
asdf plugin test <plugin-name> <plugin-url> [--asdf-tool-version <version>] [--asdf-plugin-gitref <git-ref>] [test-command*]

# TODO: adapt this
asdf plugin test spago https://github.com/jrrom/asdf-spago.git "spago --help"
```

Expand Down
36 changes: 29 additions & 7 deletions lib/utils.bash
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

set -euo pipefail

# TODO: Ensure this is the correct GitHub homepage where releases can be downloaded for spago.
GH_REPO="https://github.com/purescript/spago"
TOOL_NAME="spago"
TOOL_TEST="spago --help"
Expand Down Expand Up @@ -31,18 +30,42 @@ list_github_tags() {
}

list_all_versions() {
# TODO: Adapt this. By default we simply list the tag names from GitHub releases.
# Change this function if spago has other means of determining installable versions.
list_github_tags
}

download_release() {
local version filename url
local version filename bin url
version="$1"
filename="$2"

# TODO: Adapt the release URL convention for spago
url="$GH_REPO/archive/v${version}.tar.gz"

if [[ "$OSTYPE" == "linux-gnu"* ]]; then
bin="linux"
elif [[ "$OSTYPE" == "darwin"* ]]; then
# spago release artifacts have changed names over time for macOS.
#
# - "osx.tar.gz" up to and including 0.17.0 (other than a few exceptions)
# - "macOS-latest.tar.gz" for 0.18.0
# - "macOS.tar.gz" for 0.18.1 onwards (up to 0.19.0 as of this writing)
#
# There are a few other outlier versions which might not be handled here, and the very
# early versions don't seem to contain an executable named "spago" so those don't work either.
#
# See https://github.com/purescript/spago/releases for release artifact filenames
major_version=$(echo $version | cut -d'.' -f1)
minor_version=$(echo $version | cut -d'.' -f2)
if [[ "$version" == "0.18.0" ]]; then
bin="macOS-latest"
elif (($major_version == 0 && $minor_version < 18)); then
bin="osx"
else
bin="macOS"
fi
else
fail "unrecognized operating system $OSTYPE"
fi

url="$GH_REPO/releases/download/${version}/${bin}.tar.gz"

echo "* Downloading $TOOL_NAME release $version..."
curl "${curl_opts[@]}" -o "$filename" -C - "$url" || fail "Could not download $url"
Expand All @@ -61,7 +84,6 @@ install_version() {
mkdir -p "$install_path"
cp -r "$ASDF_DOWNLOAD_PATH"/* "$install_path"

# TODO: Assert spago executable exists.
local tool_cmd
tool_cmd="$(echo "$TOOL_TEST" | cut -d' ' -f1)"
test -x "$install_path/$tool_cmd" || fail "Expected $install_path/$tool_cmd to be executable."
Expand Down

0 comments on commit 4e29714

Please sign in to comment.