Skip to content

Fix plugin for v0.16 of asdf and lts resolution #417

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

Merged
merged 5 commits into from
Feb 25, 2025
Merged
Show file tree
Hide file tree
Changes from 4 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
21 changes: 12 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ You can specify a non-default location of this file by setting a `ASDF_NPM_DEFAU
We provide a command for running the installed `node-build` command:

```bash
asdf nodejs nodebuild --version
asdf cmd nodejs nodebuild --version
```

### node-build advanced variations
Expand All @@ -122,7 +122,7 @@ Some of them will work out of the box, and some will need a bit of investigation
To list all the available variations run:

```bash
asdf nodejs nodebuild --definitions
asdf cmd nodejs nodebuild --definitions
```

_Note that this command only lists the current `node-build` definitions. You might want to [update the local `node-build` repository](#updating-node-build-definitions) before listing them._
Expand All @@ -132,7 +132,7 @@ _Note that this command only lists the current `node-build` definitions. You mig
Every new node version needs to have a definition file in the `node-build` repository. `asdf-nodejs` already tries to update `node-build` on every new version installation, but if you want to update `node-build` manually for some reason we provide a command just for that:

```bash
asdf nodejs update-nodebuild
asdf cmd nodejs update-nodebuild
```

### Integrity/signature check
Expand All @@ -141,21 +141,24 @@ In the past `asdf-nodejs` checked for signatures and integrity by querying live

### Resolving latest available LTS version in a script

This plugin adds a custom subcommand `asdf nodejs resolve lts`. If you want to know what is the latest available LTS major version number you can do this:
This plugin adds a custom subcommand `asdf cmd nodejs resolve lts`. If you want to know what is the latest available LTS major version number you can do this:

```sh
# Before checking for aliases, update nodebuild to check for newly releasead versions
asdf nodejs update-nodebuild
asdf cmd nodejs update-nodebuild

asdf nodejs resolve lts
# outputs: 22.11.0
asdf cmd nodejs resolve lts
# outputs: 22.13.1
```

You also have the option of forcing a resolution strategy by using the flags `--latest-installed` and `--latest-available`

```bash
# Outputs the latest version installed locally which is a LTS
asdf nodejs resolve lts --latest-installed
asdf cmd nodejs resolve lts --latest-installed

# Outputs the latest version available for download which is a LTS
asdf nodejs resolve lts --latest-available
asdf cmd nodejs resolve lts --latest-available
```

## Corepack
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /usr/bin/env bash
#!/usr/bin/env bash

set -eu -o pipefail

Expand Down
2 changes: 1 addition & 1 deletion lib/commands/command-resolve.bash → lib/commands/command-resolve
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /usr/bin/env bash
#!/usr/bin/env bash

set -eu -o pipefail

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /usr/bin/env bash
#!/usr/bin/env bash

set -eu -o pipefail

Expand Down
7 changes: 5 additions & 2 deletions lib/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ colored() {
export RED=31 GREEN=32 YELLOW=33 BLUE=34 MAGENTA=35 CYAN=36

nodebuild_wrapped() {
"$ASDF_NODEJS_PLUGIN_DIR/lib/commands/command-nodebuild.bash" "$@"
"$ASDF_NODEJS_PLUGIN_DIR/lib/commands/command-nodebuild" "$@"
}

try_to_update_nodebuild() {
Expand All @@ -51,7 +51,7 @@ try_to_update_nodebuild() {

local exit_code=0

"$ASDF_NODEJS_PLUGIN_DIR/lib/commands/command-update-nodebuild.bash" 2>/dev/null || exit_code=$?
"$ASDF_NODEJS_PLUGIN_DIR/lib/commands/command-update-nodebuild" 2>/dev/null || exit_code=$?

if [ "$exit_code" != 0 ]; then
printf "
Expand Down Expand Up @@ -152,6 +152,9 @@ resolve_version() {

if [ "$query" = lts ] || [ "$query" = "lts/*" ]; then
query="${nodejs_codenames[${#nodejs_codenames[@]} - 1]#*:}"
local all_versions
all_versions=$("$ASDF_NODEJS_PLUGIN_DIR/bin/list-all" 2>/dev/null | tr ' ' '\n')
query=$(echo "$all_versions" | grep "^$query\." | tail -n1)
fi

if [ "${ASDF_NODEJS_LEGACY_FILE_DYNAMIC_STRATEGY-}" ]; then
Expand Down