Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update to v0.2.0 #5

Merged
merged 5 commits into from
Apr 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
shellcheck 0.9.0
shfmt 3.6.0
shellcheck 0.10.0 # sync-constraints="~> v0.9, !pre"
shfmt 3.8.0 # sync-constraints="~> v3.6, !pre"
27 changes: 15 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,20 @@ asdf plugin add sync https://github.com/robzr/asdf-sync.git
sync:

```shell
# asdf-sync has hooks to run via asdf
# asdf sync runs as an asdf extension command
asdf sync help
```

# Usage

asdf-sync extends the functionality of [asdf](https://github.com/asdf-vm/asdf),
using the standard syntax [.tool-versions asdf config file](https://asdf-vm.com/manage/configuration.html#tool-versions),
with optional additional configuration embedeed in specially formatted comments
to provides the following functionality:
- automatically installs and updates any plugins by interpreting .tool-versions syntax
- can read standard format version constraints embeded in .tool-verisons comments
- can auto-update .tool-versions file, effectively using it as a version lockfile
- can read and use custom plugin URLs embedded in .tool-version comments
using the standard syntax [.tool-versions asdf config file](https://asdf-vm.com/manage/configuration.html#tool-versions)
along with optional configuration tokens embedded in comments to provides the
following functionality:
- automatically installs any plugins specified
- interprets version constraints embedded in .tool-verisons comments
- updates .tool-versions file with latest version(s) matching constraints
- uses custom plugin URLs embedded in .tool-version comments

## Configuration

Expand All @@ -61,20 +61,23 @@ Now, running `asdf sync` will ensure these plugins are installed.
## Version Constraint Interpretation

asdf is great, but there is no native format for intelligent version constraints.
Version constraints can be a power mechanism to enable automatic updates while
Version constraints can be a powerful mechanism to enable automatic updates while
preventing breaking changes. If a program is versioned in accordance with
[Semantic Versioning](https://semver.org), it should be safe to simply follow
updates within the same major version, as SemVer specifies that breaking changes
necessitate a major version increase.
require a major version increment.
```
sver 1.2.0 # sync-constraint="~> v1.2, !pre"
terraform 1.5.7 # sync-constraint="~> v1.5, !pre"
terragrunt 0.51.5 # sync-constraint="~> v0.51.5, !pre"
```
Using a `sync-constraint="<constraint>"` token in .tool-versions will assign a
version constraint to a given package. Upon running `asdf sync`, the latest
versions matching the constraint will be determined, the .tool-versions file
will be updated accordingly, and the packages will automatically be installed.
versions matching the constraint will be determined, and the .tool-versions file
will be updated accordingly.

Typically after this, you will also want to run `asdf install` to install the new
versions.

## asdf Plugin URLs

Expand Down
7 changes: 4 additions & 3 deletions asdf-sync
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# asdf-sync by Rob Zwissler (@robzr) 4/5/2024 https://github.com/robzr/asdf-sync

VERSION=v0.1.0
VERSION=v0.2.0

SVER_RUN=false
#### BEGIN SVER
Expand Down Expand Up @@ -890,20 +890,21 @@ process_tool_versions() {

print_help() {
cat <<-_EOF_ 1>&2
asdf sync version: ${VERSION}

ASDF SYNC
asdf sync Sync .tool-versions plugins (install,
optionally update using constraints)
asdf sync -f Forces installation (suppress error on
missing config, overrides conflicts)
asdf sync -h Displays usage instructions
asdf sync -q Quiet output
asdf sync -v Verbose output
asdf sync <name> [<name> ...] Manually specify package name(s)
asdf sync help Displays usage instructions
asdf sync version Displays plugin version

ASDF SYNC CONFIG
Using the same .tool-versions files as asdf (the filename cna be overridden
Using the same .tool-versions files as asdf (the filename can be overridden
with the TOOL_VERSIONS_FILE environment variable, just like asdf), with
optional additional tokens embedded in comments. Available tokens:

Expand Down
20 changes: 1 addition & 19 deletions bin/download
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,4 @@

set -euo pipefail

current_script_path=${BASH_SOURCE[0]}
plugin_dir=$(dirname "$(dirname "$current_script_path")")

# shellcheck source=./lib/utils.bash
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"

# Remove the tar.gz file since we don't need to keep it
rm "$release_file"
true
10 changes: 5 additions & 5 deletions bin/install
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

set -euo pipefail

current_script_path=${BASH_SOURCE[0]}
plugin_dir=$(dirname "$(dirname "$current_script_path")")
cat<<'_EOF_'

# shellcheck source=./lib/utils.bash
source "${plugin_dir}/lib/utils.bash"
asdf sync runs as an asdf extension, there is no additional tool to install
or run. To update, run "asdf plugin update sync".

install_version "$ASDF_INSTALL_TYPE" "$ASDF_INSTALL_VERSION" "$ASDF_INSTALL_PATH"
For help, run "asdf sync help".
_EOF_
Loading