22
33set -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"
76TOOL_NAME=" biome"
87TOOL_TEST=" biome --version"
8+ CLEAN_RELEASE_REGEX=' s/^cli\/v//'
99
1010fail () {
1111 echo -e " asdf-$TOOL_NAME : $* "
@@ -27,41 +27,55 @@ sort_versions() {
2727list_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
3334list_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+
3954download_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
5169install_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