Skip to content

Commit 44b83f7

Browse files
committed
feat: asdf-fluttergen
1 parent 4cfcbf2 commit 44b83f7

File tree

8 files changed

+24
-18
lines changed

8 files changed

+24
-18
lines changed

.github/CODEOWNERS

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @ronnnnn

.github/workflows/build.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ jobs:
1717
runs-on: ${{ matrix.os }}
1818
steps:
1919
- name: asdf_plugin_test
20-
uses: asdf-vm/actions/plugin-test@v2
20+
uses: asdf-vm/actions/plugin-test@v3
2121
with:
2222
command: fluttergen -v

.github/workflows/lint.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ jobs:
1010
lint:
1111
runs-on: ubuntu-latest
1212
steps:
13-
- uses: actions/checkout@v3
14-
- uses: asdf-vm/actions/install@v2
13+
- uses: actions/checkout@v4
14+
- uses: asdf-vm/actions/install@v3
1515
- run: scripts/lint.bash
1616

1717
actionlint:
1818
runs-on: ubuntu-latest
1919
steps:
20-
- uses: actions/checkout@v3
20+
- uses: actions/checkout@v4
2121
- name: Check workflow files
2222
uses: docker://rhysd/actionlint:1.6.23
2323
with:

.github/workflows/release.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ jobs:
1313
release-please:
1414
runs-on: ubuntu-latest
1515
steps:
16-
- uses: GoogleCloudPlatform/release-please-action@v3
16+
- uses: GoogleCloudPlatform/release-please-action@v4
1717
with:
1818
release-type: simple

README.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# asdf-fluttergen [![Build](https://github.com/FlutterGen/asdf-fluttergen/actions/workflows/build.yml/badge.svg)](https://github.com/FlutterGen/asdf-fluttergen/actions/workflows/build.yml) [![Lint](https://github.com/FlutterGen/asdf-fluttergen/actions/workflows/lint.yml/badge.svg)](https://github.com/FlutterGen/asdf-fluttergen/actions/workflows/lint.yml)
44

5-
[fluttergen](https://github.com/FlutterGen/flutter_gen) plugin for the [asdf version manager](https://asdf-vm.com).
5+
[FlutterGen](https://github.com/FlutterGen/flutter_gen) plugin for the [asdf version manager](https://asdf-vm.com).
66

77
</div>
88

@@ -15,8 +15,6 @@
1515

1616
# Dependencies
1717

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

bin/download

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,13 @@ 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.
1413
release_file="$ASDF_DOWNLOAD_PATH/$TOOL_NAME-$ASDF_INSTALL_VERSION.tar.gz"
1514

1615
# Download tar.gz file to the download directory
1716
download_release "$ASDF_INSTALL_VERSION" "$release_file"
1817

1918
# 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"
19+
tar -xzf "$release_file" -C "$ASDF_DOWNLOAD_PATH" || fail "Could not extract $release_file"
2120

2221
# Remove the tar.gz file since we don't need to keep it
2322
rm "$release_file"

contributing.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ Testing Locally:
55
```shell
66
asdf plugin test <plugin-name> <plugin-url> [--asdf-tool-version <version>] [--asdf-plugin-gitref <git-ref>] [test-command*]
77

8-
# TODO: adapt this
9-
asdf plugin test fluttergen https://github.com/FlutterGen/asdf-fluttergen.git "fluttergen -v"
8+
asdf plugin test fluttergen [email protected]:FlutterGen/asdf-fluttergen.git "fluttergen -v"
109
```
1110

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

lib/utils.bash

+15-6
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
set -euo pipefail
44

5-
# TODO: Ensure this is the correct GitHub homepage where releases can be downloaded for fluttergen.
65
GH_REPO="https://github.com/FlutterGen/flutter_gen"
76
TOOL_NAME="fluttergen"
87
TOOL_TEST="fluttergen -v"
@@ -31,18 +30,29 @@ list_github_tags() {
3130
}
3231

3332
list_all_versions() {
34-
# TODO: Adapt this. By default we simply list the tag names from GitHub releases.
35-
# Change this function if fluttergen has other means of determining installable versions.
3633
list_github_tags
3734
}
3835

36+
extract_os() {
37+
local os_name
38+
os_name=""
39+
40+
case "$(uname -s)" in
41+
Linux*) os_name="linux" ;;
42+
Darwin*) os_name="macos" ;;
43+
*) fail "Unsupported OS: $(uname -s)" ;;
44+
esac
45+
46+
echo "$os_name"
47+
}
48+
3949
download_release() {
4050
local version filename url
4151
version="$1"
4252
filename="$2"
4353

44-
# TODO: Adapt the release URL convention for fluttergen
45-
url="$GH_REPO/archive/v${version}.tar.gz"
54+
os_name=$(extract_os)
55+
url="$GH_REPO/releases/download/v${version}/fluttergen-${os_name}.tar.gz"
4656

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

64-
# TODO: Assert fluttergen executable exists.
6574
local tool_cmd
6675
tool_cmd="$(echo "$TOOL_TEST" | cut -d' ' -f1)"
6776
test -x "$install_path/$tool_cmd" || fail "Expected $install_path/$tool_cmd to be executable."

0 commit comments

Comments
 (0)