------------------------------------------------------------
commit 76213105b7879cf8dad72cf15b01f9146a88560f
Author: John Gee <[email protected]>
Date: Sat Nov 9 12:15:23 2024 +1300
10.1.0
diff --git a/package-lock.json b/package-lock.json
index bb15caa..ef1d9d8 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,6 +1,6 @@
{
"name": "n",
- "version": "10.0.1-0",
+ "version": "10.1.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
diff --git a/package.json b/package.json
index d0f8cb0..bf3744f 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
{
"name": "n",
"description": "Interactively Manage All Your Node Versions",
- "version": "10.0.1-0",
+ "version": "10.1.0",
"author": "TJ Holowaychuk <[email protected]>",
"homepage": "https://github.com/tj/n",
"bugs": "https://github.com/tj/n/issues",
------------------------------------------------------------
commit c66dc02048d72923cd1e919504a2ce8f4e84c006
Author: John Gee <[email protected]>
Date: Sat Nov 9 12:08:54 2024 +1300
Update CHANGELOG for 10.1.0
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1b2729e..511b424 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -9,12 +9,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased] (date goes here)
-## [10.1.0] (2024-10-20)
+## [10.1.0] (2024-11-09)
### Added
-- `--cleanup` removes cached version after install ([#818])
+- `--cleanup` option to delete cached version after install for a one-shot install ([#818])
+- `download` command to download Node.js version into cache ([#821])
- document using `--download` with run/exec/which in README
+- support trailing comments in `.nvmrc` file ([#820])
+- mask password in download URL when displayed ([#815])
### Changed
@@ -528,8 +531,11 @@ Only minor functional changes, but technically could break scripts relying on sp
[#785]: https://github.com/tj/n/pull/785
[#810]: https://github.com/tj/n/pull/810
[#813]: https://github.com/tj/n/pull/813
+[#815]: https://github.com/tj/n/pull/815
[#817]: https://github.com/tj/n/pull/817
[#818]: https://github.com/tj/n/pull/818
+[#820]: https://github.com/tj/n/pull/820
+[#821]: https://github.com/tj/n/pull/821
<!-- reference links for releases -->
------------------------------------------------------------
commit 058fd9a52ea9c9cde2413bc16686dd9fd50aa17d
Author: John Gee <[email protected]>
Date: Sat Nov 9 11:57:34 2024 +1300
Add unofficial builds as example mirror (#823)
diff --git a/README.md b/README.md
index 9d09198..5dd92b4 100644
--- a/README.md
+++ b/README.md
@@ -20,7 +20,7 @@ Node.js version management: no subshells, no profile setup, no convoluted API, j
- [Using Downloaded Node.js Versions Without Reinstalling](#using-downloaded-nodejs-versions-without-reinstalling)
- [Preserving npm](#preserving-npm)
- [Miscellaneous](#miscellaneous)
- - [Custom Source](#custom-source)
+ - [Custom Mirror](#custom-mirror)
- [Custom Architecture](#custom-architecture)
- [Optional Environment Variables](#optional-environment-variables)
- [How It Works](#how-it-works)
@@ -254,13 +254,24 @@ Display diagnostics to help resolve problems:
n doctor
-## Custom Source
+## Custom Mirror
If you would like to use a different Node.js mirror which has the same layout as the default <https://nodejs.org/dist/>, you can define `N_NODE_MIRROR`.
-The most common example is from users in China who can define:
+
+One example is for users in China who can define:
export N_NODE_MIRROR=https://npmmirror.com/mirrors/node
+Another example is the Node.js [unofficial-builds project](https://github.com/nodejs/unofficial-builds/) which has downloads for some platforms not made available officially, such as armv6l (Raspberry Pi) and 32-bit x86.
+
+ export N_NODE_MIRROR=https://unofficial-builds.nodejs.org/download/release
+
+You may need to specify the architecture explicitly if not autodetected by `n`, such as using `musl` `libc` on Alpine:
+
+ export N_NODE_MIRROR=https://unofficial-builds.nodejs.org/download/release
+ apk add bash curl libstdc++
+ n --arch x64-musl install lts
+
If the custom mirror requires authentication you can add the [url-encoded](https://urlencode.org) username and password into the URL. e.g.
export N_NODE_MIRROR=https://encoded-username:encoded-password@host:port/path
------------------------------------------------------------
commit fe3c3da5affc3c988ace292583bc5dfbd1226516
Author: John Gee <[email protected]>
Date: Sat Nov 9 11:43:28 2024 +1300
Add manual install instructions and remove probably rarely used make instruction (#822)
diff --git a/README.md b/README.md
index 858cb6a..9d09198 100644
--- a/README.md
+++ b/README.md
@@ -64,11 +64,11 @@ If `npm` is not yet available, one way to bootstrap an install is to download an
# If you want n installed, you can use npm now.
npm install -g n
-Alternatively, you can clone this repo and
+If you don't need support for updates to `n` itself you can just save the download:
- make install
-
-which defaults to `/usr/local/bin/n`. To install `n` in a custom location such as `$CUSTOM_LOCATION/bin/n`, run `PREFIX=$CUSTOM_LOCATION make install`.
+ curl -fsSL -o /usr/local/bin/n https://raw.githubusercontent.com/tj/n/master/bin/n
+ chmod 0755 /usr/local/bin/n
+ n install lts
### Third Party Installers
------------------------------------------------------------
commit cbde6e2b0142a0ba577c2ee51aeb5325f1c6d4d7
Author: John Gee <[email protected]>
Date: Sat Nov 9 11:42:51 2024 +1300
Add download command (#821)
diff --git a/README.md b/README.md
index fb879d3..858cb6a 100644
--- a/README.md
+++ b/README.md
@@ -234,6 +234,10 @@ List downloaded versions in cache:
n ls
+Download version into cache:
+
+ n download 22
+
Use `n` to access cached versions (already downloaded) without internet available.
n --offline 12
diff --git a/bin/n b/bin/n
index cd31052..ac2c961 100755
--- a/bin/n
+++ b/bin/n
@@ -390,6 +390,7 @@ Commands:
n ls Output downloaded versions
n ls-remote [version] Output matching versions available for download
n uninstall Remove the installed Node.js
+ n download <version> Download Node.js <version> into cache
Options:
@@ -794,6 +795,8 @@ install() {
if [[ ! -e "$dir/n.lock" ]] ; then
if [[ "$DOWNLOAD" == "false" ]] ; then
activate "${g_mirror_folder_name}/${version}"
+ else
+ log downloaded "${g_mirror_folder_name}/${version} already in cache"
fi
exit
fi
@@ -802,7 +805,11 @@ install() {
abort "version unavailable offline"
fi
- log installing "${g_mirror_folder_name}-v$version"
+ if [[ "$DOWNLOAD" == "false" ]]; then
+ log installing "${g_mirror_folder_name}-v$version"
+ else
+ log download "${g_mirror_folder_name}-v$version"
+ fi
local url="$(tarball_url "$version")"
is_ok "${url}" || abort "download preflight failed for '$version' ($(display_masked_url "${url}"))"
@@ -1733,6 +1740,7 @@ else
lsr|ls-remote|list-remote) shift; display_remote_versions "$1"; exit ;;
uninstall) uninstall_installed; exit ;;
i|install) shift; install "$1"; exit ;;
+ download) shift; DOWNLOAD="true"; install "$1"; exit ;;
N_TEST_DISPLAY_LATEST_RESOLVED_VERSION) shift; get_latest_resolved_version "$1" > /dev/null || exit 2; echo "${g_target_node}"; exit ;;
*) install "$1"; exit ;;
esac
diff --git a/test/tests/install-options.bats b/test/tests/install-options.bats
index f30da48..74e5c37 100644
--- a/test/tests/install-options.bats
+++ b/test/tests/install-options.bats
@@ -17,9 +17,22 @@ function teardown() {
@test "n --download 4.9.1" {
+ # deprecated use of --download, replaced by download command
n --download 4.9.1
[ -d "${N_PREFIX}/n/versions/node/4.9.1" ]
- # Remember, we installed a dummy node so do have a bin/node
+ [ ! -f "${N_PREFIX}/bin/node" ]
+ [ ! -f "${N_PREFIX}/bin/npm" ]
+ [ ! -d "${N_PREFIX}/include" ]
+ [ ! -d "${N_PREFIX}/lib" ]
+ [ ! -d "${N_PREFIX}/shared" ]
+}
+
+
+@test "n download 4.9.1" {
+ # not an option, but keep with --download so stays in sync
+ n download 4.9.1
+ [ -d "${N_PREFIX}/n/versions/node/4.9.1" ]
+ [ ! -f "${N_PREFIX}/bin/node" ]
[ ! -f "${N_PREFIX}/bin/npm" ]
[ ! -d "${N_PREFIX}/include" ]
[ ! -d "${N_PREFIX}/lib" ]
@@ -35,6 +48,14 @@ function teardown() {
}
+@test "n --cleanup 4.9.1" {
+ n install --cleanup 4.9.1
+ output="$(node --version)"
+ assert_equal "${output}" "v4.9.1"
+ [ ! -d "${N_PREFIX}/n/versions/node/4.9.1" ]
+}
+
+
# mostly --preserve, but also variations with i/install and lts/numeric
@test "--preserve variations # (4 installs)" {
local ARGON_VERSION="v4.9.1"
diff --git a/test/tests/offline.bats b/test/tests/offline.bats
index 64aa844..06c62e4 100644
--- a/test/tests/offline.bats
+++ b/test/tests/offline.bats
@@ -8,7 +8,7 @@ function setup_file() {
unset_n_env
setup_tmp_prefix
# Note, NOT latest version of 16.
- n --download 16.19.0
+ n download 16.19.0
export N_NODE_MIRROR="https://no.internet.available"
}
diff --git a/test/tests/run-which.bats b/test/tests/run-which.bats
index 99bb6fe..be8d6d7 100644
--- a/test/tests/run-which.bats
+++ b/test/tests/run-which.bats
@@ -9,8 +9,8 @@ function setup_file() {
# fixed directory so can reuse the two installs
tmpdir="${TMPDIR:-/tmp}"
export N_PREFIX="${tmpdir}/n/test/run-which"
- n --download 4.9.1
- n --download lts
+ n download 4.9.1
+ n download lts
# using "latest" for download tests with run and exec
}
------------------------------------------------------------
commit eea2a555331a1c5c488f5af392b01a87a9641e65
Author: John Gee <[email protected]>
Date: Mon Oct 28 14:58:34 2024 +1300
Add support for trailing comment in .nvmrc (#820)
diff --git a/bin/n b/bin/n
index 675b88c..cd31052 100755
--- a/bin/n
+++ b/bin/n
@@ -1147,6 +1147,8 @@ function get_nvmrc_version() {
verbose_log "found" "${filepath}"
local version
<"${filepath}" read -r version
+ # remove trailing comment, after #
+ version="$(echo "${version}" | sed 's/[[:space:]]*#.*//')"
verbose_log "read" "${version}"
# Translate from nvm aliases
case "${version}" in
diff --git a/test/tests/version-resolve-auto-nvmrc.bats b/test/tests/version-resolve-auto-nvmrc.bats
index a99c7fa..fbe72b7 100644
--- a/test/tests/version-resolve-auto-nvmrc.bats
+++ b/test/tests/version-resolve-auto-nvmrc.bats
@@ -68,3 +68,11 @@ function setup() {
output="$(n N_TEST_DISPLAY_LATEST_RESOLVED_VERSION auto)"
assert_equal "${output}" "8.11.1"
}
+
+@test "auto .nvmrc, trailing comment" {
+ local TARGET_VERSION="8.10.0"
+ cd "${MY_DIR}"
+ printf "${TARGET_VERSION} # comment" > .nvmrc
+ output="$(n N_TEST_DISPLAY_LATEST_RESOLVED_VERSION auto)"
+ assert_equal "${output}" "${TARGET_VERSION}"
+}
------------------------------------------------------------
commit 1a1b61967b0c5f010c77722456568a195f48794b
Author: John Gee <[email protected]>
Date: Mon Oct 28 14:54:27 2024 +1300
Minor reword
diff --git a/README.md b/README.md
index 0ed9486..fb879d3 100644
--- a/README.md
+++ b/README.md
@@ -242,7 +242,7 @@ Remove the cache version after installing using `--cleanup`. This is particularl
curl -fsSL https://raw.githubusercontent.com/tj/n/master/bin/n | bash -s install --cleanup lts
-Normally `n run`, `n exec`, and `n which` will fail if the target version is not already in the cache. You can add `--download` to use the cache if available or download first if required:
+Normally `n run`, `n exec`, and `n which` will fail if the target version is not already in the cache. You can add `--download` to use the cache if available or download if required:
n --download run 18.3 my-script.js
------------------------------------------------------------
commit 7128e837f3e1eb6e1051eae7921ee4d2edda72f9
Author: John Gee <[email protected]>
Date: Mon Oct 28 14:12:13 2024 +1300
Add more codenames, out to 2026
diff --git a/bin/n b/bin/n
index fb686f4..675b88c 100755
--- a/bin/n
+++ b/bin/n
@@ -262,7 +262,7 @@ function update_arch_settings_for_version() {
function is_lts_codename() {
# https://github.com/nodejs/Release/blob/master/CODENAMES.md
# e.g. argon, Boron
- [[ "$1" =~ ^([Aa]rgon|[Bb]oron|[Cc]arbon|[Dd]ubnium|[Ee]rbium|[Ff]ermium|[Gg]allium|[Hh]ydrogen|[Ii]ron|[Jj]od)$ ]]
+ [[ "$1" =~ ^([Aa]rgon|[Bb]oron|[Cc]arbon|[Dd]ubnium|[Ee]rbium|[Ff]ermium|[Gg]allium|[Hh]ydrogen|[Ii]ron|[Jj]od|[Kk]rypton|[Ll]ithium)$ ]]
}
#
diff --git a/test/tests/install-options.bats b/test/tests/install-options.bats
index 2dcdc95..f30da48 100644
--- a/test/tests/install-options.bats
+++ b/test/tests/install-options.bats
@@ -19,7 +19,7 @@ function teardown() {
@test "n --download 4.9.1" {
n --download 4.9.1
[ -d "${N_PREFIX}/n/versions/node/4.9.1" ]
- # Remember, we installed a dumy node so do have a bin/node
+ # Remember, we installed a dummy node so do have a bin/node
[ ! -f "${N_PREFIX}/bin/npm" ]
[ ! -d "${N_PREFIX}/include" ]
[ ! -d "${N_PREFIX}/lib" ]
------------------------------------------------------------
commit 9d9e58a1df289fda18a4aa20d43e5fffe2ca57e1
Author: John Gee <[email protected]>
Date: Mon Oct 28 10:05:44 2024 +1300
Documentation updates
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 87d1f8e..1b2729e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -14,7 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- `--cleanup` removes cached version after install ([#818])
-- mention of `--download` in README
+- document using `--download` with run/exec/which in README
### Changed
diff --git a/README.md b/README.md
index 60670d6..0ed9486 100644
--- a/README.md
+++ b/README.md
@@ -93,6 +93,7 @@ As a result, both `n` itself and all Node.js versions it manages are hosted insi
Changing from a previous Node.js installed to a different location may involve a few extra steps. See docs for [changing node location](./docs/changing-node-location.md) for a walk-through example of switching from using Homebrew to using `n` to manage Node.js.
You have a problem with multiple versions if after installing node you see the "installed" and "active" locations are different:
+
```console
% n lts
copying : node/20.12.2
@@ -241,11 +242,7 @@ Remove the cache version after installing using `--cleanup`. This is particularl
curl -fsSL https://raw.githubusercontent.com/tj/n/master/bin/n | bash -s install --cleanup lts
-The `--download` option can be used in two ways, to download a version into cache but not make active:
-
- n --download lts
-
-or to download a possibly missing version for `n run`, `n exec`, and `n which`:
+Normally `n run`, `n exec`, and `n which` will fail if the target version is not already in the cache. You can add `--download` to use the cache if available or download first if required:
n --download run 18.3 my-script.js
@@ -290,8 +287,8 @@ To change the location to say `$HOME/.n`, add lines like the following to your s
export N_PREFIX=$HOME/.n
export PATH=$N_PREFIX/bin:$PATH
-If you want to store the downloads under a different location, use `N_CACHE_PREFIX`. This does *not* affect the currently active
-node version.
+If you want to store the downloads under a different location, use `N_CACHE_PREFIX`. This does _not_ affect where the active
+node version is installed.
`n` defaults to using xz compressed Node.js tarballs for the download if it is likely tar on the system supports xz decompression.
You can override the automatic choice by setting an environment variable to zero or non-zero:
diff --git a/bin/n b/bin/n
index 3b59076..fb686f4 100755
--- a/bin/n
+++ b/bin/n
@@ -397,7 +397,7 @@ Options:
-h, --help Display help information
-p, --preserve Preserve npm and npx during install of Node.js
-q, --quiet Disable curl output. Disable log messages processing "auto" and "engine" labels.
- -d, --download Download if necessary, and don't make active
+ -d, --download Download if necessary. Used with run/exec/which.
--cleanup Remove cached version after install
-a, --arch Override system architecture
--offline Resolve target version against cached downloads instead of internet lookup
------------------------------------------------------------
commit 2914fe3ed51c039a854c91cffdd3c5c6f934b93d
Merge: 859efc6 e5c51e8
Author: John Gee <[email protected]>
Date: Sun Oct 20 11:12:02 2024 +1300
Merge branch 'develop' of github.com:tj/n into develop