Skip to content

Commit 769170e

Browse files
adapt to biome specific parameters
1 parent 3dc3d95 commit 769170e

File tree

5 files changed

+40
-36
lines changed

5 files changed

+40
-36
lines changed

README.md

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<div align="center">
22

3-
# asdf-biome [![Build](https://github.com/stathis-alexander/asdf-biome/actions/workflows/build.yml/badge.svg)](https://github.com/stathis-alexander/asdf-biome/actions/workflows/build.yml) [![Lint](https://github.com/stathis-alexander/asdf-biome/actions/workflows/lint.yml/badge.svg)](https://github.com/stathis-alexander/asdf-biome/actions/workflows/lint.yml)
3+
# asdf-biome [![Build](https://github.com/angellist/asdf-biome/actions/workflows/build.yml/badge.svg)](https://github.com/angellist/asdf-biome/actions/workflows/build.yml) [![Lint](https://github.com/angellist/asdf-biome/actions/workflows/lint.yml/badge.svg)](https://github.com/angellist/asdf-biome/actions/workflows/lint.yml)
44

5-
[biome](https://github.com/angellist/asdf-biome) plugin for the [asdf version manager](https://asdf-vm.com).
5+
[biome](https://github.com/biomejs/biome) plugin for the [asdf version manager](https://asdf-vm.com).
66

77
</div>
88

@@ -15,10 +15,7 @@
1515

1616
# Dependencies
1717

18-
**TODO: adapt this section**
19-
20-
- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html).
21-
- `SOME_ENV_VAR`: set this environment variable in your shell config to load the correct version of tool x.
18+
- `bash`, `curl`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html).
2219

2320
# Install
2421

@@ -27,7 +24,7 @@ Plugin:
2724
```shell
2825
asdf plugin add biome
2926
# or
30-
asdf plugin add biome https://github.com/stathis-alexander/asdf-biome.git
27+
asdf plugin add biome https://github.com/angellist/asdf-biome.git
3128
```
3229

3330
biome:
@@ -53,7 +50,7 @@ install & manage versions.
5350

5451
Contributions of any kind welcome! See the [contributing guide](contributing.md).
5552

56-
[Thanks goes to these contributors](https://github.com/stathis-alexander/asdf-biome/graphs/contributors)!
53+
[Thanks goes to these contributors](https://github.com/angellist/asdf-biome/graphs/contributors)!
5754

5855
# License
5956

bin/download

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,5 @@ source "${plugin_dir}/lib/utils.bash"
1010

1111
mkdir -p "$ASDF_DOWNLOAD_PATH"
1212

13-
# TODO: Adapt this to proper extension and adapt extracting strategy.
14-
release_file="$ASDF_DOWNLOAD_PATH/$TOOL_NAME-$ASDF_INSTALL_VERSION.tar.gz"
15-
1613
# Download tar.gz file to the download directory
17-
download_release "$ASDF_INSTALL_VERSION" "$release_file"
18-
19-
# Extract contents of tar.gz file into the download directory
20-
tar -xzf "$release_file" -C "$ASDF_DOWNLOAD_PATH" --strip-components=1 || fail "Could not extract $release_file"
21-
22-
# Remove the tar.gz file since we don't need to keep it
23-
rm "$release_file"
14+
download_release "$ASDF_INSTALL_VERSION" $(release_file $ASDF_DOWNLOAD_PATH)

bin/latest-stable

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ printf "redirect url: %s\n" "$redirect_url" >&2
2323
if [[ "$redirect_url" == "$GH_REPO/releases" ]]; then
2424
version="$(list_all_versions | sort_versions | tail -n1 | xargs echo)"
2525
else
26-
version="$(printf "%s\n" "$redirect_url" | sed 's|.*/tag/v\{0,1\}||')"
26+
version="$(printf "%s\n" "$redirect_url" | sed 's|.*/tag/v\{0,1\}||' | sed $CLEAN_RELEASE_REGEX)"
2727
fi
2828

2929
printf "%s\n" "$version"

contributing.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@
33
Testing Locally:
44

55
```shell
6-
asdf plugin test <plugin-name> <plugin-url> [--asdf-tool-version <version>] [--asdf-plugin-gitref <git-ref>] [test-command*]
7-
8-
# TODO: adapt this
9-
asdf plugin test biome https://github.com/stathis-alexander/asdf-biome.git "biome --version"
6+
asdf plugin test biome https://github.com/angellist/asdf-biome.git "biome --version"
107
```
118

129
Tests are automatically run in GitHub Actions on push and PR.

lib/utils.bash

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
set -euo pipefail
44

5-
# TODO: Ensure this is the correct GitHub homepage where releases can be downloaded for biome.
6-
GH_REPO="https://github.com/angellist/asdf-biome"
5+
GH_REPO="https://github.com/biomejs/biome"
76
TOOL_NAME="biome"
87
TOOL_TEST="biome --version"
8+
CLEAN_RELEASE_REGEX='s/^cli\/v//'
99

1010
fail() {
1111
echo -e "asdf-$TOOL_NAME: $*"
@@ -27,22 +27,44 @@ sort_versions() {
2727
list_github_tags() {
2828
git ls-remote --tags --refs "$GH_REPO" |
2929
grep -o 'refs/tags/.*' | cut -d/ -f3- |
30-
sed 's/^v//' # NOTE: You might want to adapt this sed to remove non-version strings from tags
30+
grep -o "cli/v[0-9]\+\.[0-9]\+\.[0-9]\+$" | # Match semantic versioning tags
31+
sed $CLEAN_RELEASE_REGEX
3132
}
3233

3334
list_all_versions() {
34-
# TODO: Adapt this. By default we simply list the tag names from GitHub releases.
35-
# Change this function if biome has other means of determining installable versions.
3635
list_github_tags
3736
}
3837

38+
binary_suffix() {
39+
local suffix
40+
41+
if [[ "$OSTYPE" == "darwin"* ]]; then
42+
suffix="-darwin-arm64"
43+
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
44+
suffix="-linux-x64"
45+
else
46+
fail "Unsupported OS: $OSTYPE"
47+
fi
48+
49+
echo "$suffix"
50+
}
51+
52+
release_file() {
53+
local download_path="$1"
54+
55+
echo "$download_path/$TOOL_NAME$(binary_suffix)"
56+
}
57+
3958
download_release() {
4059
local version filename url
4160
version="$1"
4261
filename="$2"
4362

44-
# TODO: Adapt the release URL convention for biome
45-
url="$GH_REPO/archive/v${version}.tar.gz"
63+
if [[ "$version" =~ "cli/v[0-9]\+\.[0-9]\+\.[0-9]\+$" ]]; then
64+
version="$(echo "$version" | sed 's/^cli\/v//')"
65+
fi
66+
67+
url="$GH_REPO/releases/download/cli/v${version}/biome$(binary_suffix)"
4668

4769
echo "* Downloading $TOOL_NAME release $version..."
4870
curl "${curl_opts[@]}" -o "$filename" -C - "$url" || fail "Could not download $url"
@@ -53,15 +75,12 @@ install_version() {
5375
local version="$2"
5476
local install_path="${3%/bin}/bin"
5577

56-
if [ "$install_type" != "version" ]; then
57-
fail "asdf-$TOOL_NAME supports release installs only"
58-
fi
59-
6078
(
6179
mkdir -p "$install_path"
62-
cp -r "$ASDF_DOWNLOAD_PATH"/* "$install_path"
80+
mv $(release_file $ASDF_DOWNLOAD_PATH) "$install_path/$TOOL_NAME"
81+
chmod +x "$install_path/$TOOL_NAME"
6382

64-
# TODO: Assert biome executable exists.
83+
# Assert biome executable exists.
6584
local tool_cmd
6685
tool_cmd="$(echo "$TOOL_TEST" | cut -d' ' -f1)"
6786
test -x "$install_path/$tool_cmd" || fail "Expected $install_path/$tool_cmd to be executable."

0 commit comments

Comments
 (0)