Skip to content

Commit

Permalink
Minor adaptations after the setup
Browse files Browse the repository at this point in the history
  • Loading branch information
ehsash committed Jan 29, 2025
1 parent c695e93 commit b708632
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 20 deletions.
1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
shellcheck 0.9.0
shfmt 3.6.0
java temurin-23.0.2+7
4 changes: 1 addition & 3 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
TODO: INSERT YOUR NAME COPYRIGHT YEAR (if applicable to your license)

MIT License

Copyright (c) [year] [fullname]
Copyright (c) 2025 Ehsash Tehel

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
4 changes: 1 addition & 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`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html).
- `SOME_ENV_VAR`: set this environment variable in your shell config to load the correct version of tool x.
- `java`: requires Java Runtime Environment (JRE), installed system-wide, or via asdf

# Install

Expand Down
2 changes: 1 addition & 1 deletion bin/download
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ source "${plugin_dir}/lib/utils.bash"

mkdir -p "$ASDF_DOWNLOAD_PATH"

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

# Download tar.gz file to the download directory
Expand Down
3 changes: 0 additions & 3 deletions contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,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 signal-cli https://github.com/ehsash/asdf-signal-cli.git "signal-cli --version"
```

Expand Down
15 changes: 5 additions & 10 deletions lib/utils.bash
100644 → 100755
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 signal-cli.
GH_REPO="https://github.com/AsamK/signal-cli"
TOOL_NAME="signal-cli"
TOOL_TEST="signal-cli --version"
Expand All @@ -14,7 +13,6 @@ fail() {

curl_opts=(-fsSL)

# NOTE: You might want to remove this if signal-cli is not hosted on GitHub releases.
if [ -n "${GITHUB_API_TOKEN:-}" ]; then
curl_opts=("${curl_opts[@]}" -H "Authorization: token $GITHUB_API_TOKEN")
fi
Expand All @@ -27,12 +25,10 @@ sort_versions() {
list_github_tags() {
git ls-remote --tags --refs "$GH_REPO" |
grep -o 'refs/tags/.*' | cut -d/ -f3- |
sed 's/^v//' # NOTE: You might want to adapt this sed to remove non-version strings from tags
sed 's/^v//'
}

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

Expand All @@ -41,8 +37,7 @@ download_release() {
version="$1"
filename="$2"

# TODO: Adapt the release URL convention for signal-cli
url="$GH_REPO/archive/v${version}.tar.gz"
url="${GH_REPO}/releases/download/v${version}/${TOOL_NAME}-${version}.tar.gz"

echo "* Downloading $TOOL_NAME release $version..."
curl "${curl_opts[@]}" -o "$filename" -C - "$url" || fail "Could not download $url"
Expand All @@ -51,20 +46,20 @@ download_release() {
install_version() {
local install_type="$1"
local version="$2"
local install_path="${3%/bin}/bin"
local install_path="${3%/bin}"

if [ "$install_type" != "version" ]; then
fail "asdf-$TOOL_NAME supports release installs only"
fi

(
mkdir -p "$install_path"

cp -r "$ASDF_DOWNLOAD_PATH"/* "$install_path"

# TODO: Assert signal-cli 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."
test -x "$install_path/bin/$tool_cmd" || fail "Expected $install_path/bin/$tool_cmd to be executable."

echo "$TOOL_NAME $version installation was successful!"
) || (
Expand Down

0 comments on commit b708632

Please sign in to comment.