Skip to content

Commit 845dace

Browse files
adapt to biome specific parameters
1 parent 3dc3d95 commit 845dace

File tree

5 files changed

+37
-38
lines changed

5 files changed

+37
-38
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: 0 additions & 9 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
1714
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"

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: 30 additions & 16 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,41 +27,55 @@ 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="$ASDF_DOWNLOAD_PATH/$TOOL_NAME$(binary_suffix)"
53+
3954
download_release() {
40-
local version filename url
55+
local version url
4156
version="$1"
42-
filename="$2"
4357

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

4764
echo "* Downloading $TOOL_NAME release $version..."
48-
curl "${curl_opts[@]}" -o "$filename" -C - "$url" || fail "Could not download $url"
65+
curl "${curl_opts[@]}" -o "$RELEASE_FILE" -C - "$url" || fail "Could not download $url"
66+
chmod +x "$RELEASE_FILE"
4967
}
5068

5169
install_version() {
5270
local install_type="$1"
5371
local version="$2"
5472
local install_path="${3%/bin}/bin"
5573

56-
if [ "$install_type" != "version" ]; then
57-
fail "asdf-$TOOL_NAME supports release installs only"
58-
fi
59-
6074
(
6175
mkdir -p "$install_path"
62-
cp -r "$ASDF_DOWNLOAD_PATH"/* "$install_path"
76+
mv "$RELEASE_FILE" "$install_path"
6377

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

0 commit comments

Comments
 (0)