Skip to content

Commit

Permalink
feat: asdf-fluttergen
Browse files Browse the repository at this point in the history
  • Loading branch information
ronnnnn committed Aug 21, 2024
1 parent 4cfcbf2 commit 44b83f7
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 18 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @ronnnnn
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- name: asdf_plugin_test
uses: asdf-vm/actions/plugin-test@v2
uses: asdf-vm/actions/plugin-test@v3
with:
command: fluttergen -v
6 changes: 3 additions & 3 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: asdf-vm/actions/install@v2
- uses: actions/checkout@v4
- uses: asdf-vm/actions/install@v3
- run: scripts/lint.bash

actionlint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Check workflow files
uses: docker://rhysd/actionlint:1.6.23
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ jobs:
release-please:
runs-on: ubuntu-latest
steps:
- uses: GoogleCloudPlatform/release-please-action@v3
- uses: GoogleCloudPlatform/release-please-action@v4
with:
release-type: simple
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# 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)

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

</div>

Expand All @@ -15,8 +15,6 @@

# 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.

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

mkdir -p "$ASDF_DOWNLOAD_PATH"

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

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

# Extract contents of tar.gz file into the download directory
tar -xzf "$release_file" -C "$ASDF_DOWNLOAD_PATH" --strip-components=1 || fail "Could not extract $release_file"
tar -xzf "$release_file" -C "$ASDF_DOWNLOAD_PATH" || fail "Could not extract $release_file"

# Remove the tar.gz file since we don't need to keep it
rm "$release_file"
3 changes: 1 addition & 2 deletions contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ 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 fluttergen https://github.com/FlutterGen/asdf-fluttergen.git "fluttergen -v"
asdf plugin test fluttergen git@github.com:FlutterGen/asdf-fluttergen.git "fluttergen -v"
```

Tests are automatically run in GitHub Actions on push and PR.
21 changes: 15 additions & 6 deletions lib/utils.bash
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 fluttergen.
GH_REPO="https://github.com/FlutterGen/flutter_gen"
TOOL_NAME="fluttergen"
TOOL_TEST="fluttergen -v"
Expand Down Expand Up @@ -31,18 +30,29 @@ list_github_tags() {
}

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

extract_os() {
local os_name
os_name=""

case "$(uname -s)" in
Linux*) os_name="linux" ;;
Darwin*) os_name="macos" ;;
*) fail "Unsupported OS: $(uname -s)" ;;
esac

echo "$os_name"
}

download_release() {
local version filename url
version="$1"
filename="$2"

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

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

# TODO: Assert fluttergen 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."
Expand Down

0 comments on commit 44b83f7

Please sign in to comment.