From a22ededbdb4af78dd6a837180e5bda2ddc474af6 Mon Sep 17 00:00:00 2001 From: Qiheng He Date: Wed, 4 Nov 2026 10:17:52 +0800 Subject: [PATCH 1/2] docs: list the 0.5.4 changes under the release and drop the "Unreleased" remarks Release 0.5.4 is published, so the pages stop marking its behavior as newer than the last release. This is the procedure of "Releasing" in docs/development.md, in English and Chinese: - changes.md: "Unreleased" becomes "0.5.4 (2026-11-04)", every entry gets its pull request (#43, #45, #44), the sentence about the newest release "at the time of writing" goes, and the User-Agent is `vfox/1.0.13 vfox-nodejs/0.5.4`. - README, README_CN: the paragraph that explains "Unreleased" goes, and the `.nvmrc` paragraph describes one behavior. - lts, nvmrc, scenarios, versions, mirror: the "Unreleased: release 0.5.3 ..." remarks go. The tables that set 0.5.3 against "Unreleased" (nvmrc.md, and two in scenarios.md) keep the one column that is 0.5.4. - troubleshooting, mirror, nvmrc: where a reader of an older plugin looks up a message or a symptom, a short "Before 0.5.4" / "Since 0.5.4" sentence stays (`version not found ... 27.0.0-alpha.0.0.0`, `checksum error` through Huawei Cloud, TUNA, USTC and BFSU, `.nvmrc` not applied after a `cd`). mirror.md no longer names the mirrors that worked before 0.5.4, only the four that failed, which is what was checked. - scenarios.md: the outputs are from "the code that became release 0.5.4" (hooks/ and lib/ of the PR branch equal the release), and the sentence that gave the fresh shell per directory of the Windows e2e suite as a result of the `cd` limit now says only what the suite covers. - source-build.md: the example URL of a released zip is 0.5.4. Checked with vfox 1.0.13 in an isolated HOME, using the published zip (sha256 0e2cbadc...): `vfox info` says 0.5.4. Against the live nodejs.org, `vfox search` lists 877 releases and no pre-release although the index starts with 27.0.0-alpha.0.0.0, and `.lts-cache` holds the 12 lines up to lithium. Against a local mirror whose index starts with a pre-release, `install nodejs@latest` takes the newest release, and the index, SHASUMS256.txt and the download all carry `User-Agent: vfox/1.0.13 vfox-nodejs/0.5.4`; with small stand-in tarballs, the 8-row table of nvmrc.md and the 7-row table of scenarios.md come out as written, and the three .nvmrc encodings select 22.23.4. The links and anchors of all pages resolve. --- README.md | 16 ++---- README_CN.md | 4 +- docs/changes.md | 28 +++++---- docs/lts.md | 14 ++--- docs/mirror.md | 15 +++-- docs/nvmrc.md | 80 +++++++++++--------------- docs/scenarios.md | 105 ++++++++++++++++------------------ docs/source-build.md | 2 +- docs/troubleshooting.md | 20 +++---- docs/versions.md | 8 +-- docs/zh-CN/changes.md | 16 +++--- docs/zh-CN/lts.md | 8 +-- docs/zh-CN/mirror.md | 2 +- docs/zh-CN/nvmrc.md | 38 ++++++------ docs/zh-CN/scenarios.md | 52 ++++++++--------- docs/zh-CN/source-build.md | 2 +- docs/zh-CN/troubleshooting.md | 6 +- docs/zh-CN/versions.md | 4 +- 18 files changed, 189 insertions(+), 231 deletions(-) diff --git a/README.md b/README.md index c57455c..519dddd 100644 --- a/README.md +++ b/README.md @@ -45,10 +45,6 @@ node -v `vfox search nodejs` lists every release, with the npm that comes with it and a mark on the ones of an LTS line. In an interactive terminal it lets you pick one. -Behavior that only exists on `main` and not in the latest release is marked -"Unreleased" in the pages below. [docs/changes.md](docs/changes.md) lists it, and -[docs/source-build.md](docs/source-build.md) gets you `main`. - ### Example: Ubuntu 26.04 ```bash @@ -123,13 +119,11 @@ details and for mirrors that were checked. vfox reads these files at every prompt in a directory that has one, and selects the release they name if it is installed, so a `cd` into the directory switches. -Unreleased: release 0.5.3 reads them when a shell starts in the directory, not -after a `cd` from a running shell. Neither switches back when you `cd` into a -directory with no config at all; a `.vfox.toml`, which `vfox use --project` -writes, does. What a file can say depends on vfox's -`legacyVersionFile.strategy`: with the default, `specified`, only a full release -number selects something. A file in UTF-16 or with a byte order mark, which -Windows PowerShell 5.1 writes, is read too (Unreleased). See +It does not switch back when you `cd` into a directory with no config at all; a +`.vfox.toml`, which `vfox use --project` writes, does. What a file can say +depends on vfox's `legacyVersionFile.strategy`: with the default, `specified`, +only a full release number selects something. A file in UTF-16 or with a byte +order mark, which Windows PowerShell 5.1 writes, is read too. See [docs/nvmrc.md](docs/nvmrc.md) for details. ## LTS diff --git a/README_CN.md b/README_CN.md index aa56271..58f101d 100644 --- a/README_CN.md +++ b/README_CN.md @@ -34,8 +34,6 @@ node -v `vfox search nodejs` 会列出每个版本及其自带的 npm,属于 LTS 版本线的版本带有标记。在交互式终端里可以从中选一个。 -只存在于 `main`、还没进入最新发布版的行为,在下面各页里标有“未发布”。[docs/zh-CN/changes.md](docs/zh-CN/changes.md) 里列出了这些行为,想直接用上 `main`,见 [docs/zh-CN/source-build.md](docs/zh-CN/source-build.md)。 - ### 示例:Ubuntu 26.04 ```bash @@ -80,7 +78,7 @@ Node.js 为 Linux(x64、arm64、ppc64le、s390x)、macOS(x64 和 arm64) ## `.nvmrc` 和 `.node-version` -每个提示符出现在带有这些文件的目录里时,vfox 都会读取它们,并选中其中指定的版本(前提是已经安装),所以 `cd` 进这个目录就会切换。未发布:0.5.3 在 Shell 于该目录里启动时读取,已经在运行的 Shell 里 `cd` 进来则不读取。两者在 `cd` 到完全没有配置的目录时都不会切换回来;`vfox use --project` 写出的 `.vfox.toml` 则会。文件里能写什么取决于 vfox 的 `legacyVersionFile.strategy`:默认值 `specified` 下,只有完整的版本号才能选中某个版本。UTF-16 的文件或带字节顺序标记的文件(Windows PowerShell 5.1 会写出这样的文件)也能读取(未发布)。详见 [docs/zh-CN/nvmrc.md](docs/zh-CN/nvmrc.md)。 +每个提示符出现在带有这些文件的目录里时,vfox 都会读取它们,并选中其中指定的版本(前提是已经安装),所以 `cd` 进这个目录就会切换。`cd` 到完全没有配置的目录时不会切换回来;`vfox use --project` 写出的 `.vfox.toml` 则会。文件里能写什么取决于 vfox 的 `legacyVersionFile.strategy`:默认值 `specified` 下,只有完整的版本号才能选中某个版本。UTF-16 的文件或带字节顺序标记的文件(Windows PowerShell 5.1 会写出这样的文件)也能读取。详见 [docs/zh-CN/nvmrc.md](docs/zh-CN/nvmrc.md)。 ## LTS diff --git a/docs/changes.md b/docs/changes.md index 89eb397..68c8fdf 100644 --- a/docs/changes.md +++ b/docs/changes.md @@ -4,11 +4,9 @@ What changed in each release, as a user notices it. GitHub's [release pages](https://github.com/version-fox/vfox-nodejs/releases) list the -pull requests. The newest release at the time of writing is 0.5.3, and `main` is -ahead of it by everything under "Unreleased". -[source-build.md](source-build.md) gets you those changes now. +pull requests. -## Unreleased +## 0.5.4 (2026-11-04) - `vfox install nodejs@latest` installs the newest release again, and `vfox search nodejs` no longer lists pre-releases. Since 2026-10-29 the index @@ -16,15 +14,17 @@ ahead of it by everything under "Unreleased". lists it first, so `latest` resolves to it and the install ends with `version not found for provided version 27.0.0-alpha.0.0.0`. `nodejs@26` and the other numbers work. Only releases of three numbers are listed now. See - [versions.md](versions.md#installing). + [versions.md](versions.md#installing) + ([#43](https://github.com/version-fox/vfox-nodejs/pull/43)). - Huawei Cloud, TUNA, USTC and BFSU work as mirrors. Release 0.5.3 leaves the download of the package to vfox, which asks with the `User-Agent` of Go's HTTP client, and these four answer that with an error page, or with nothing, in place of the file (HTTP 418, 403, 204 and 403): the install ends in `checksum error`. The plugin now has vfox download with the `User-Agent` of its own - requests, `vfox/1.0.13 vfox-nodejs/0.5.3` under vfox 1.0.13, and all of the + requests, `vfox/1.0.13 vfox-nodejs/0.5.4` under vfox 1.0.13, and all of the mirrors of [mirror.md](mirror.md#mirrors-that-work) install 24.21.0. China - Telecom Cloud, `https://mirrors.ctyun.cn/nodejs-release`, is in that list now. + Telecom Cloud, `https://mirrors.ctyun.cn/nodejs-release`, is in that list now + ([#45](https://github.com/version-fox/vfox-nodejs/pull/45)). - The plugin learns the LTS lines from the version index, so a line that Node.js promotes later needs no release of the plugin. It keeps what it learned in `.lts-cache` next to the plugin. It writes the file when @@ -36,12 +36,14 @@ ahead of it by everything under "Unreleased". ends at Lithium (26): Node.js 26 entered long-term support on 2026-10-28. Release 0.5.3 has the table only, and it ends at Krypton (24), so there `lts/lithium` selects nothing under `latest_installed`, and `lts` and `lts/*` - select a 24.x. See [lts.md](lts.md#what-this-plugin-understands). + select a 24.x. See [lts.md](lts.md#what-this-plugin-understands) + ([#44](https://github.com/version-fox/vfox-nodejs/pull/44)). - A `.nvmrc` or `.node-version` in UTF-16, or in UTF-8 with a byte order mark, is read. Windows PowerShell 5.1 writes the first with `>` and `Out-File`, and the second with `-Encoding UTF8`. Release 0.5.3 reads the bytes as they are, so no release matches the text and vfox says nothing. See - [nvmrc.md](nvmrc.md#what-the-file-may-hold). + [nvmrc.md](nvmrc.md#what-the-file-may-hold) + ([#44](https://github.com/version-fox/vfox-nodejs/pull/44)). - `.nvmrc` and `.node-version` are read at every prompt in their directory, so a `cd` into it switches, and a change of the file takes effect at the next prompt. Release 0.5.3 reads them when a shell starts in the directory and not @@ -49,14 +51,16 @@ ahead of it by everything under "Unreleased". shell and does not track version files. The plugin now removes that result whenever vfox asks it to read such a file. A `cd` out of the directory into one with no config at all does not switch back yet, and a `.vfox.toml` always - did. See [nvmrc.md](nvmrc.md#when-the-file-is-read). The cache is vfox's, and - vfox has been asked to fix it + did. See [nvmrc.md](nvmrc.md#when-the-file-is-read) + ([#44](https://github.com/version-fox/vfox-nodejs/pull/44)). The cache is + vfox's, and vfox has been asked to fix it ([version-fox/vfox#745](https://github.com/version-fox/vfox/issues/745), tracked here as [#46](https://github.com/version-fox/vfox-nodejs/issues/46)). - The documentation has a page of scenarios: the nvm-sh/nvm commands next to vfox's, Windows PowerShell 5.1 from scratch, one Node.js for a whole team, several projects in one shell, `vfox exec`, mirrors and editors. See - [scenarios.md](scenarios.md). + [scenarios.md](scenarios.md) + ([#44](https://github.com/version-fox/vfox-nodejs/pull/44)). ## 0.5.3 (2026-10-20) diff --git a/docs/lts.md b/docs/lts.md index 1a2dcdc..14d7104 100644 --- a/docs/lts.md +++ b/docs/lts.md @@ -49,7 +49,8 @@ maintainer has to keep up: answer for a while, so not every search does), and when it installs a release and the file is missing or a day old. It keeps what it learned in `.lts-cache` next to the plugin, where vfox keeps its `.available.cache`. Delete the file - to make it forget, and it learns again at the next install. + to make it forget, and it learns again at the next install. How it works is in + [development.md](development.md#what-the-plugin-learns-about-lts-lines). - Before it has learned anything, or where it cannot write the file, it uses the table below. The table is a start: a line that is missing from it is learned as soon as the plugin has had the index in hand. @@ -81,7 +82,7 @@ practice: - Under `latest_available` the plugin finds the new codename in the index the day it appears. `lts` and `lts/*` then name the newest release of the new - line, and `lts/lithium` worked there at once, with release 0.5.3 as well. + line, and `lts/lithium` worked there at once. - Under `specified` and `latest_installed` the plugin knows the line from the first time it has the index in hand after the promotion: the `vfox search` or the install that brings you the new line. `latest_installed` selects nothing @@ -90,13 +91,6 @@ practice: line that the plugin knows. - `(LTS)` in `vfox search` follows the index, so it changes at once. -Unreleased: release 0.5.3 has the table only, and no file. The table was -published before Lithium and ends at Krypton, so with 22.23.4, 24.22.2 and -26.13.0 installed on 2026-11-03 it selected 24.22.2 for `lts/*` and nothing for -`lts/lithium` under `latest_installed`, and only a release of the plugin adds a -line there. How the plugin learns is in -[development.md](development.md#what-the-plugin-learns-about-lts-lines). - ## Examples Given an `.nvmrc` (the same applies to `.node-version`) and @@ -115,7 +109,7 @@ v22.23.4 ```sh # 2. Bare `lts` (or `lts/*`) means "the newest LTS line that the plugin knows", -# 26 at the time of writing (Unreleased: 24 in release 0.5.3). +# 26 at the time of writing. $ printf 'lts\n' > .nvmrc $ cd && eval "$(vfox activate bash)" && eval "$(vfox env -s bash)" && node --version v26.13.0 diff --git a/docs/mirror.md b/docs/mirror.md index cd9ba76..930b666 100644 --- a/docs/mirror.md +++ b/docs/mirror.md @@ -89,15 +89,14 @@ A mirror can change or go away without the plugin knowing. On 2026-11-03 each of them was also used to install 24.21.0 with vfox 1.0.13 (`VFOX_NODEJS_MIRROR= vfox install nodejs@24.21.0`), and every one -installed it and ran. Unreleased: release 0.5.3 only installs from npmmirror, -Alibaba Cloud, Tencent Cloud and Nanjing University. It leaves the download to -vfox, which asks with the `User-Agent` of Go's HTTP client, -`Go-http-client/1.1`, and Huawei Cloud (HTTP 418), TUNA and BFSU (403) and USTC -(204 with no content) answer that with an error page, or with nothing, in place -of the package: vfox saves the answer and the install ends in `checksum error`. +installed it and ran. Before 0.5.4 the install through Huawei Cloud, TUNA, USTC +and BFSU ended in `checksum error`: vfox downloads the package itself, asking +with the `User-Agent` of Go's HTTP client, `Go-http-client/1.1`, and Huawei +Cloud (HTTP 418), TUNA and BFSU (403) and USTC (204 with no content) answer that +with an error page, or with nothing, in place of the package, which vfox saves. The plugin asks for `index.json` and `SHASUMS256.txt` with the `User-Agent` -that vfox builds for it, `vfox/1.0.13 vfox-nodejs/0.5.3`, which all of them -serve, and it now has the download send the same one. +that vfox builds for it, `vfox/1.0.13 vfox-nodejs/0.5.4`, which all of them +serve, and it has the download send the same one. Addresses that only redirect are not listed: on 2026-11-03 `mirror.sjtu.edu.cn/nodejs-release` sent the requests to nodejs.org, and diff --git a/docs/nvmrc.md b/docs/nvmrc.md index efc76b4..5c42913 100644 --- a/docs/nvmrc.md +++ b/docs/nvmrc.md @@ -24,10 +24,7 @@ node -v # v22.23.3 vfox's shell hook reads the file at every prompt in the directory and selects the release it names, so a `cd` into the directory switches, and so does a -change of the file. `vfox use` is not needed. Unreleased: release 0.5.3 reads -the file when a shell starts in the directory, not after a `cd` from a running -shell, where the example prints the global release. See -[below](#when-the-file-is-read). The hook is vfox's own, see its +change of the file. `vfox use` is not needed. The hook is vfox's own, see its [quick start](https://vfox.dev/guides/quick-start.html) for zsh, fish, PowerShell and the others. @@ -59,15 +56,14 @@ when the `.vfox.toml` of the current directory is another one than before, when 1.0.13, and `main` of vfox on 2026-11-03), so vfox does not notice that the shell is in a directory that has one. -Unreleased: the plugin makes up for that. vfox runs the plugin's -`ParseLegacyFile` before it looks at the kept result, and the plugin removes -`env-state.json` there (`util.forget_env_state`), so vfox works the environment -out again at every prompt in a directory with such a file. A `cd` into the -directory switches, a `cd` from one such directory to another does, and a -change of the file does at the next prompt. The extra calculation took about a -millisecond per prompt with one SDK installed, and `--debug` shows it as -`Config changed: true`. It is a workaround for vfox, to drop when vfox tracks -these files. +The plugin makes up for that. vfox runs the plugin's `ParseLegacyFile` before it +looks at the kept result, and the plugin removes `env-state.json` there +(`util.forget_env_state`), so vfox works the environment out again at every +prompt in a directory with such a file. A `cd` into the directory switches, a +`cd` from one such directory to another does, and a change of the file does at +the next prompt. The extra calculation took about a millisecond per prompt with +one SDK installed, and `--debug` shows it as `Config changed: true`. It is a +workaround for vfox, to drop when vfox tracks these files. It does nothing for a `cd` out of the directory into one that has no config at all. The plugin is not called there, so vfox goes on with the result it made for @@ -75,27 +71,23 @@ the directory you left (`Using cached output`), and the shell keeps that release. A directory with a `.vfox.toml` or with a version file of its own does switch, and so does a new shell. -Release 0.5.3 does not remove the file. It reads a `.nvmrc` when the shell -starts in the directory, and again after a `vfox use`, and not after a `cd`, -in either direction. This is what `node -v` printed in one shell, step by step, -with vfox 1.0.13 and 26.13.0 as the global release (bash 5.3, and PowerShell -7.6.9 agrees): - -| Step | Release 0.5.3 | Unreleased | -| --- | --- | --- | -| A shell that starts in a directory with a `.nvmrc` that names 18.20.8 | v18.20.8 | v18.20.8 | -| A shell that starts in a directory with no config at all | v26.13.0 | v26.13.0 | -| `cd` into the directory with the `.nvmrc` for 18.20.8 | v26.13.0 | v18.20.8 | -| `cd` into a directory with a `.node-version` that names 24.22.2 | v26.13.0 | v24.22.2 | -| Edit that `.node-version` to name 22.23.4 | v26.13.0 | v22.23.4 | -| `cd` into a directory with no config at all | v26.13.0 | v22.23.4 | -| `cd` into a directory with a `.vfox.toml` that names 18.20.8 | v18.20.8 | v18.20.8 | -| `cd` into a directory with no config at all | v26.13.0 | v26.13.0 | +This is what `node -v` printed in one shell, step by step, with vfox 1.0.13 and +26.13.0 as the global release (bash 5.3, and PowerShell 7.6.9 agrees): + +| Step | `node -v` | +| --- | --- | +| A shell that starts in a directory with a `.nvmrc` that names 18.20.8 | v18.20.8 | +| A shell that starts in a directory with no config at all | v26.13.0 | +| `cd` into the directory with the `.nvmrc` for 18.20.8 | v18.20.8 | +| `cd` into a directory with a `.node-version` that names 24.22.2 | v24.22.2 | +| Edit that `.node-version` to name 22.23.4 | v22.23.4 | +| `cd` into a directory with no config at all | v22.23.4 | +| `cd` into a directory with a `.vfox.toml` that names 18.20.8 | v18.20.8 | +| `cd` into a directory with no config at all | v26.13.0 | The first row is a shell of its own, the other seven follow one another in a -second shell. `vfox --debug env -s bash` shows both sides of the unreleased -column. In a directory with a `.nvmrc`, the plugin parses the file and vfox -calculates: +second shell. `vfox --debug env -s bash` shows both cases. In a directory with a +`.nvmrc`, the plugin parses the file and vfox calculates: ```text Parsing legacy file /home/me/projects/legacy-api/.nvmrc @@ -113,10 +105,9 @@ Config changed: false, configPaths: map[global:/home/me/.vfox/.vfox.toml] Using cached output ``` -Release 0.5.3 prints the second block in the directory with the `.nvmrc` as -well, after `Found nodejs@18.20.8`. A `.vfox.toml` is tracked in both, so -`vfox use --project nodejs@18.20.8` is the way to get the switching in a -release. See [scenarios.md](scenarios.md#several-projects-in-one-shell). +A `.vfox.toml` is tracked by vfox itself, so it switches in both directions: +`vfox use --project nodejs@18.20.8` writes one. See +[scenarios.md](scenarios.md#several-projects-in-one-shell). The cache is vfox's, and so is the fix. It is reported as [version-fox/vfox#745](https://github.com/version-fox/vfox/issues/745), and @@ -158,9 +149,6 @@ Decoding means that a file in UTF-16, or in UTF-8 with a byte order mark, reads like plain text. Windows PowerShell 5.1 writes such files with `>`, `Out-File` and `-Encoding UTF8`, see [scenarios.md](scenarios.md#writing-the-file-from-windows-powershell-51). -Unreleased: release 0.5.3 reads the bytes as they are, so the mark or the zero -bytes of UTF-16 become part of the text, no release matches it, and vfox says -nothing. The results on 2026-11-03 with 20.20.2, 22.23.4, 24.21.0, 25.9.0 and 26.13.0 installed, when 24.22.2 is the newest 24.x and 22.23.4 the newest 22.x: @@ -184,10 +172,7 @@ index names a newer release than the one you have, nothing is selected. Use `latest_installed` that is the newest line that the plugin knows (26 at the time of writing), under `latest_available` the newest release that carries any codename in the index. See [lts.md](lts.md) for how the plugin knows lines and -what happens when Node.js promotes a new one. Unreleased: release 0.5.3 knows -only a table that ends at Krypton (24), because it was published before Node.js -26 became an LTS line. There `lts/lithium` selects nothing under -`latest_installed`, and `lts/*` and `lts` select 24.21.0 in the table above. +what happens when Node.js promotes a new one. ## Not understood @@ -224,10 +209,9 @@ If the release does not switch: - The shell hook is not active. `eval "$(vfox activate bash)"` has to run in the shell, not only once somewhere else. -- Release 0.5.3 only: the shell was already running when you `cd`'d into the - directory, see [When the file is read](#when-the-file-is-read). Open a new - terminal there, or install the plugin of `main` - ([source-build.md](source-build.md)). +- Before 0.5.4 only: the shell was already running when you `cd`'d into the + directory, and vfox went on with the release it had worked out for the shell. + Open a new terminal there, or update the plugin with `vfox update nodejs`. - The shell came from a directory with a version file and went into one with no config at all, and it keeps the release of the directory it left. Open a new terminal. @@ -238,7 +222,7 @@ If the release does not switch: - A `.vfox.toml` or `.tool-versions` is in the way, or `legacyVersionFile.enable` is `false`. - The text is on the list above, or has a comment in it, or the file is in an - encoding the plugin does not read (release 0.5.3: anything but plain ASCII + encoding the plugin does not read (before 0.5.4: anything but plain ASCII text). `vfox --debug env -s bash` prints what the plugin returned and what vfox did diff --git a/docs/scenarios.md b/docs/scenarios.md index e11d8e2..72e01a1 100644 --- a/docs/scenarios.md +++ b/docs/scenarios.md @@ -12,10 +12,10 @@ hook for each shell, so the same work runs in Windows PowerShell 5.1, which ships with Windows 10 and 11, as well as in PowerShell 7, bash, zsh and fish. Each case below says what you want, what to type and what you see. The outputs -are from 2026-11-03 on Linux x64, with vfox 1.0.13 and this plugin as on `main`, -and the home directory is shown as `/home/me`. The PowerShell lines were run in -PowerShell 7.6.9 on Linux, except those that exist only on Windows: -`Set-ExecutionPolicy` and the user-level +are from 2026-11-03 on Linux x64, with vfox 1.0.13 and the code that became +release 0.5.4, and the home directory is shown as `/home/me`. The PowerShell +lines were run in PowerShell 7.6.9 on Linux, except those that exist only on +Windows: `Set-ExecutionPolicy` and the user-level `[Environment]::SetEnvironmentVariable`. Windows PowerShell 5.1 itself is not part of the test suite ([platforms.md](platforms.md#what-ci-covers)), so a case marks what rests on the documentation of PowerShell or on vfox's source, not on @@ -26,7 +26,7 @@ a run there. | nvm-sh/nvm | vfox | Notes | | --- | --- | --- | | `nvm install 22` | `vfox install nodejs@22` | The newest 22.x, checked against its SHA-256 sum. See [versions.md](versions.md) | -| `nvm install node` | `vfox install nodejs@latest` | Unreleased: release 0.5.3 fails while the index lists a pre-release, as it has since 2026-10-29. `nodejs@26` works everywhere | +| `nvm install node` | `vfox install nodejs@latest` | The newest release of any line, LTS or not. See [versions.md](versions.md#installing) | | `nvm install --lts`, `nvm install 'lts/*'` | `vfox install nodejs@26` | There is no `lts` name, name the line. 26 is the newest LTS line on 2026-11-03, and `vfox search nodejs \| grep -m1 '(LTS)'` shows the newest LTS release. See [lts.md](lts.md) | | `nvm use 22` | `vfox use nodejs@22` | This shell only. `22` is the newest installed 22.x | | `nvm alias default 22` | `vfox use --global nodejs@22` | Every new shell | @@ -131,9 +131,8 @@ What is different on Windows: from winget or Scoop, or from another version manager can sit in front of vfox's. `vfox use` then prints a note that names it and says that it comes before vfox in `PATH`, see [pnpm.md](pnpm.md). Uninstall the other one. -- A `.nvmrc` that Windows PowerShell 5.1 writes with `>` is UTF-16. - Unreleased: release 0.5.3 does not read it, see - [below](#writing-the-file-from-windows-powershell-51). +- A `.nvmrc` that Windows PowerShell 5.1 writes with `>` is UTF-16, which the + plugin reads, see [below](#writing-the-file-from-windows-powershell-51). ## The same Node.js for the whole team @@ -189,16 +188,14 @@ newest 22.x. `lts/*` and the other `.nvmrc` names do not: the install ends with `version not found for provided version lts/*`. The `.nvmrc` is applied at every prompt in the project directory, so a `cd` into -it switches. Unreleased: release 0.5.3 applies it when a shell starts there, for -instance in the terminal that your editor opens in the folder, and not after a -`cd` from a running shell. Leaving the directory for one with no config at all -does not switch back in either, see +it switches. Leaving the directory for one with no config at all does not +switch back, see [Several projects in one shell](#several-projects-in-one-shell). If the repository should not get a vfox file, `vfox use --project` still gives you a -`.vfox.toml` for yourself, which switches in every release and in both -directions. Put `.vfox.toml` and `.vfox/` in `.git/info/exclude`, and run `vfox -config gitignore.enable false` (for all projects) so that vfox does not add -`.vfox/` to the `.gitignore` that the repository tracks. +`.vfox.toml` for yourself, which switches in both directions. Put `.vfox.toml` +and `.vfox/` in `.git/info/exclude`, and run `vfox config gitignore.enable +false` (for all projects) so that vfox does not add `.vfox/` to the +`.gitignore` that the repository tracks. ### Writing the file from Windows PowerShell 5.1 @@ -206,22 +203,19 @@ Windows PowerShell 5.1 writes UTF-16 for `>`, `>>` and `Out-File`, UTF-8 with a byte order mark for `-Encoding UTF8`, and the ANSI code page for `Set-Content` without `-Encoding`, which is plain text for a release number ([about_Character_Encoding](https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_character_encoding)). -The plugin decodes UTF-16 and drops the mark before it reads the text. -Unreleased: release 0.5.3 reads the bytes as they are, so the mark or the zero -bytes of UTF-16 become part of the text, no release matches it, and vfox says -nothing about it. The table gives the first bytes of each file and what a -directory holding it selected, with 22.23.4 installed and the default strategy: - -| The file starts with | Written by Windows PowerShell 5.1 with | Release 0.5.3 | Unreleased | -| --- | --- | --- | --- | -| `32 32 2e 32 33 2e 34 0d 0a` | `Set-Content .nvmrc 22.23.4 -Encoding ascii`, or `Set-Content .nvmrc 22.23.4` | 22.23.4 | 22.23.4 | -| `ef bb bf 32 32 2e ...` | `Set-Content .nvmrc 22.23.4 -Encoding UTF8` | nothing | 22.23.4 | -| `ff fe 32 00 32 00 2e 00 ...` | `'22.23.4' > .nvmrc`, `'22.23.4' \| Out-File .nvmrc` | nothing | 22.23.4 | - -The bytes were written on Linux and tried there, with both versions of the -plugin. What Windows PowerShell writes is from Microsoft's documentation. -PowerShell 7 writes UTF-8 without a mark for all of these, which every release -reads. This one works everywhere: +The plugin decodes UTF-16 and drops the mark before it reads the text. The table +gives the first bytes of each file and what a directory holding it selected, +with 22.23.4 installed and the default strategy: + +| The file starts with | Written by Windows PowerShell 5.1 with | Selected | +| --- | --- | --- | +| `32 32 2e 32 33 2e 34 0d 0a` | `Set-Content .nvmrc 22.23.4 -Encoding ascii`, or `Set-Content .nvmrc 22.23.4` | 22.23.4 | +| `ef bb bf 32 32 2e ...` | `Set-Content .nvmrc 22.23.4 -Encoding UTF8` | 22.23.4 | +| `ff fe 32 00 32 00 2e 00 ...` | `'22.23.4' > .nvmrc`, `'22.23.4' \| Out-File .nvmrc` | 22.23.4 | + +The bytes were written on Linux and tried there. What Windows PowerShell writes +is from Microsoft's documentation. PowerShell 7 writes UTF-8 without a mark for +all of these, which the plugin reads as plain text. This one works everywhere: ```powershell Set-Content -Path .nvmrc -Value '22.23.4' -Encoding ascii @@ -234,30 +228,27 @@ global 26. In a hooked shell, `cd` between them. This is what `node -v` printed at each step of one shell, with 18.20.8, 24.22.2 and 26.13.0 installed and 26.13.0 as the global release (bash 5.3, and PowerShell 7.6.9 agrees): -| Step | Release 0.5.3 | Unreleased | -| --- | --- | --- | -| The shell starts in a directory with no config at all | v26.13.0 | v26.13.0 | -| `cd` into a directory with a `.nvmrc` that names 18.20.8 | v26.13.0 | v18.20.8 | -| `cd` into a directory with a `.node-version` that names 24.22.2 | v26.13.0 | v24.22.2 | -| `cd` into a directory with no config at all | v26.13.0 | v24.22.2 | -| `cd` into a directory with a `.vfox.toml` that names 18.20.8 | v18.20.8 | v18.20.8 | -| `cd` into a directory with a `.vfox.toml` that names 24.22.2 | v24.22.2 | v24.22.2 | -| `cd` into a directory with no config at all | v26.13.0 | v26.13.0 | +| Step | `node -v` | +| --- | --- | +| The shell starts in a directory with no config at all | v26.13.0 | +| `cd` into a directory with a `.nvmrc` that names 18.20.8 | v18.20.8 | +| `cd` into a directory with a `.node-version` that names 24.22.2 | v24.22.2 | +| `cd` into a directory with no config at all | v24.22.2 | +| `cd` into a directory with a `.vfox.toml` that names 18.20.8 | v18.20.8 | +| `cd` into a directory with a `.vfox.toml` that names 24.22.2 | v24.22.2 | +| `cd` into a directory with no config at all | v26.13.0 | - **`.vfox.toml`** switches on every `cd`, and back to the global release when - you leave for a directory with no config. It does in every release. -- **`.nvmrc` and `.node-version`** are read at every prompt in their directory - (Unreleased). A `cd` from one such directory into another switches, and - editing the file takes effect at the next prompt. Release 0.5.3 reads them - only when the shell starts in the directory, so none of the `cd` steps above - switched. + you leave for a directory with no config. +- **`.nvmrc` and `.node-version`** are read at every prompt in their directory. + A `cd` from one such directory into another switches, and editing the file + takes effect at the next prompt. - **Leaving** a directory with such a file for one with no config at all does - not switch back, in either: the shell keeps the release it had, as the fourth - step shows. The plugin is not called in a directory with nothing to read, and - vfox goes on with the result it kept. A new terminal, or a directory with a - `.vfox.toml` or a version file of its own, switches. That is a limit of vfox's - cache, reported as - [version-fox/vfox#745](https://github.com/version-fox/vfox/issues/745) and + not switch back: the shell keeps the release it had, as the fourth step shows. + The plugin is not called in a directory with nothing to read, and vfox goes on + with the result it kept. A new terminal, or a directory with a `.vfox.toml` or + a version file of its own, switches. That is a limit of vfox's cache, reported + as [version-fox/vfox#745](https://github.com/version-fox/vfox/issues/745) and tracked here as [#46](https://github.com/version-fox/vfox-nodejs/issues/46). Why is in [nvmrc.md](nvmrc.md#when-the-file-is-read): vfox keeps the result of @@ -265,11 +256,11 @@ its first calculation for the shell and does not track version files (vfox 1.0.13), and the plugin makes vfox calculate again whenever it reads one. So: - For projects that you move between in one shell, `.vfox.toml` is the one that - works in every release and in both directions: `vfox use --project - nodejs@18.20.8` in each of them. + works in both directions: `vfox use --project nodejs@18.20.8` in each of them. - A `.nvmrc` is enough where a shell starts in the directory: the terminal of - your editor, a new tab in the same folder, a script. This is also why the - Windows e2e suite of this repository starts a new shell for each directory. + your editor, a new tab in the same folder, a script. The Windows e2e suite of + this repository starts a new shell for each directory, so a `cd` in a running + Windows shell is not part of it. ## Another release in this window only diff --git a/docs/source-build.md b/docs/source-build.md index ddac550..4531108 100644 --- a/docs/source-build.md +++ b/docs/source-build.md @@ -15,7 +15,7 @@ and `lib/` at its top level; that is the plugin package contract (see the [shared workflow documentation](https://github.com/version-fox/plugin-manifest-action)). A released plugin zip URL also works as `--source`, e.g. -`vfox add --source https://github.com/version-fox/vfox-nodejs/releases/download/v0.5.3/vfox-nodejs-0.5.3.zip`. +`vfox add --source https://github.com/version-fox/vfox-nodejs/releases/download/v0.5.4/vfox-nodejs-0.5.4.zip`. Prerequisites on all systems: [vfox](https://github.com/version-fox/vfox) itself plus `git`. diff --git a/docs/troubleshooting.md b/docs/troubleshooting.md index 532c5a5..4917091 100644 --- a/docs/troubleshooting.md +++ b/docs/troubleshooting.md @@ -17,10 +17,9 @@ knows `latest`, `24.21.0`, `24.21` and `24`, see [versions.md](versions.md). and `22.99`, which are well formed but start no release. For an LTS line, install the line by number, see [lts.md](lts.md#installing-an-lts-line). -Unreleased: release 0.5.3 ends here for `latest` as well, with `version not -found for provided version 27.0.0-alpha.0.0.0`, because the index of -nodejs.org has listed that pre-release as its newest entry since 2026-10-29. -`nodejs@26` is not affected. +Before 0.5.4 `latest` ended here as well, with `version not found for provided +version 27.0.0-alpha.0.0.0`, because the index of nodejs.org has listed that +pre-release as its newest entry since 2026-10-29. `nodejs@26` was not affected. ### `get checksum failed: HTTP 404 from https://nodejs.org/dist/v24.99.0/SHASUMS256.txt` @@ -92,11 +91,12 @@ stops when they differ. It names the file it dropped: `Checksum error, file: cut-off download and a mirror whose files differ from its `SHASUMS256.txt`. Nothing is installed. Run it again, or try another [mirror](mirror.md). -Unreleased: release 0.5.3 also ends here through Huawei Cloud, TUNA, USTC and -BFSU. vfox downloads with the `User-Agent` of Go's HTTP client, which they +Before 0.5.4 it also ended here through Huawei Cloud, TUNA, USTC and BFSU: vfox +asked for the package with the `User-Agent` of Go's HTTP client, which they answer with an error page, or with nothing, in place of the package, and vfox -checks that answer against the sum. The plugin now has the download send the -`User-Agent` of its own requests, see [mirror.md](mirror.md#mirrors-that-work). +checked that answer against the sum. Since 0.5.4 the plugin has the download +send the `User-Agent` of its own requests, see +[mirror.md](mirror.md#mirrors-that-work). ### `nodejs@24.99 is not installed` @@ -213,8 +213,8 @@ after `get checksum failed:`: [npm.md](npm.md#yarn-pnpm-and-corepack). - **`.nvmrc` selects nothing.** Check the strategy and what the file holds, and that the shell did not come from a directory with a version file into one with - none (it keeps the release it had). Release 0.5.3 also does not read the file - after a `cd` from a running shell. See [nvmrc.md](nvmrc.md#not-finding-it). + none (it keeps the release it had). Before 0.5.4 the file was not read after a + `cd` from a running shell either. See [nvmrc.md](nvmrc.md#not-finding-it). - **`git status` lists `.vfox/`.** vfox links the release into the project as `.vfox/sdks/nodejs`. Ignore `.vfox/` in `.gitignore`, and keep `.vfox.toml`. - **The installed name has no `v`.** Releases are named `24.21.0`, and a `v` in diff --git a/docs/versions.md b/docs/versions.md index b746ce6..cacd47b 100644 --- a/docs/versions.md +++ b/docs/versions.md @@ -37,11 +37,7 @@ checks it and unpacks it. These are the answers on 2026-10-21: prints `nodejs@24.22.0 is already installed` once you have the newest. - The plugin lists releases with three numbers, and nothing else: no `-rc` builds, alphas, nightlies or four-part numbers. Those end in `version not - found for provided version ...`. Unreleased: release 0.5.3 lists whatever - the index holds. Since 2026-10-29 that includes the pre-release - `27.0.0-alpha.0.0.0`, the newest entry, so `latest` ends in `version not - found for provided version 27.0.0-alpha.0.0.0`, while `nodejs@26` installs - the newest 26.x. + found for provided version ...`. - A release number that does not exist (`24.99.0`) ends in `get checksum failed: HTTP 404 from ...`, as nodejs.org has no directory for it. A release that exists but has no package for your platform ends in `Node.js package ... @@ -146,7 +142,7 @@ Available versions: - The list is the `index.json` of nodejs.org, or of your [mirror](mirror.md), without a pre-release if it holds one: 872 releases from 0.1.14 to 26.12.0 on 2026-10-21. npm is listed from 0.6.3 on and empty before - that. Unreleased: release 0.5.3 lists pre-releases too. + that. - `(LTS)` is the `lts` field of the index, which Node.js sets from the day a line enters long-term support. 24.11.0 is the first release of Krypton with it, 24.10.0 and the releases before have none. See [lts.md](lts.md). diff --git a/docs/zh-CN/changes.md b/docs/zh-CN/changes.md index 2c12c9d..67e9ea6 100644 --- a/docs/zh-CN/changes.md +++ b/docs/zh-CN/changes.md @@ -2,16 +2,16 @@ [中文](changes.md) | [English](../changes.md) -按发布版本列出用户能感受到的变化。GitHub 的 [Release 页面](https://github.com/version-fox/vfox-nodejs/releases)列出了对应的 PR。写这篇文档时最新的发布版是 0.5.3,`main` 比它多出“未发布”下面的所有内容。想现在就用上这些变化,见 [source-build.md](source-build.md)。 +按发布版本列出用户能感受到的变化。GitHub 的 [Release 页面](https://github.com/version-fox/vfox-nodejs/releases)列出了对应的 PR。 -## 未发布 +## 0.5.4(2026-11-04) -- `vfox install nodejs@latest` 重新安装最新的版本,`vfox search nodejs` 也不再列出预发布版本。2026-10-29 起,nodejs.org 的索引里最新的一条是 `27.0.0-alpha.0.0.0`。0.5.3 把它排在最前面,所以 `latest` 解析成它,安装以 `version not found for provided version 27.0.0-alpha.0.0.0` 告终。`nodejs@26` 等按编号安装的写法不受影响。现在只列出由三段数字组成的版本。见 [versions.md](versions.md#安装)。 -- 华为云、TUNA、USTC 和北外现在可以用作镜像。0.5.3 把安装包的下载交给 vfox,而 vfox 请求时使用 Go HTTP 客户端的 `User-Agent`,这四个镜像对它返回的是错误页面或者空内容,而不是文件(依次是 HTTP 418、403、204 和 403),安装以 `checksum error` 结束。插件现在让 vfox 下载时使用它自己请求时的 `User-Agent`(vfox 1.0.13 下是 `vfox/1.0.13 vfox-nodejs/0.5.3`),[mirror.md](mirror.md#可用的镜像) 里的所有镜像都能安装 24.21.0。天翼云 `https://mirrors.ctyun.cn/nodejs-release` 也加进了这份列表。 -- 插件从版本索引里学到 LTS 版本线,所以 Node.js 以后再升的版本线,不需要为插件发布新版本。它把学到的内容放在插件旁边的 `.lts-cache` 里。`vfox search`,或者安装 `latest` 或某个大版本时读到索引,以及安装某个确切版本、而这个文件不存在或者已有一天时,它会写这个文件;在 `specified` 和 `latest_installed` 下,`lts/`、`lts` 和 `lts/*` 读这个文件,不发任何请求。在学到任何内容之前,或者文件无法写入的地方,它使用一张代号表,这张表现在到 Lithium(26)为止:Node.js 26 在 2026-10-28 进入长期支持。0.5.3 只有这张表,而且到 Krypton(24)为止,所以在那里 `latest_installed` 下 `lts/lithium` 什么也选不中,`lts` 和 `lts/*` 选中某个 24.x。见 [lts.md](lts.md#插件认识哪些代号)。 -- UTF-16 的 `.nvmrc` 或 `.node-version`,以及带字节顺序标记的 UTF-8 文件,现在可以读取了。Windows PowerShell 5.1 用 `>` 和 `Out-File` 写出前者,用 `-Encoding UTF8` 写出后者。0.5.3 按原样读取字节,所以没有任何版本能匹配这段文本,而 vfox 不会有任何提示。见 [nvmrc.md](nvmrc.md#文件里可以写什么)。 -- `.nvmrc` 和 `.node-version` 在每个提示符出现在它们所在的目录里时都会读取,所以 `cd` 进去就会切换,改动文件则在下一个提示符生效。0.5.3 在 Shell 于该目录里启动时读取,`cd` 之后不读取,因为 vfox 1.0.13 会保留它为 Shell 第一次算出的结果,并且不跟踪版本文件。现在,每当 vfox 请插件读取这样的文件时,插件就会删除那个结果。从这个目录 `cd` 到完全没有配置的目录时还不会切换回来,而 `.vfox.toml` 一直都会。见 [nvmrc.md](nvmrc.md#什么时候读取这个文件)。这个缓存是 vfox 的,已经请 vfox 修复([version-fox/vfox#745](https://github.com/version-fox/vfox/issues/745),这里用 [#46](https://github.com/version-fox/vfox-nodejs/issues/46) 跟踪)。 -- 文档新增了一页使用场景:nvm-sh/nvm 与 vfox 的命令对照、从零开始使用 Windows PowerShell 5.1、全团队使用同一个 Node.js、一个 Shell 里的多个项目、`vfox exec`、镜像和编辑器。见 [scenarios.md](scenarios.md)。 +- `vfox install nodejs@latest` 重新安装最新的版本,`vfox search nodejs` 也不再列出预发布版本。2026-10-29 起,nodejs.org 的索引里最新的一条是 `27.0.0-alpha.0.0.0`。0.5.3 把它排在最前面,所以 `latest` 解析成它,安装以 `version not found for provided version 27.0.0-alpha.0.0.0` 告终。`nodejs@26` 等按编号安装的写法不受影响。现在只列出由三段数字组成的版本。见 [versions.md](versions.md#安装)([#43](https://github.com/version-fox/vfox-nodejs/pull/43))。 +- 华为云、TUNA、USTC 和北外现在可以用作镜像。0.5.3 把安装包的下载交给 vfox,而 vfox 请求时使用 Go HTTP 客户端的 `User-Agent`,这四个镜像对它返回的是错误页面或者空内容,而不是文件(依次是 HTTP 418、403、204 和 403),安装以 `checksum error` 结束。插件现在让 vfox 下载时使用它自己请求时的 `User-Agent`(vfox 1.0.13 下是 `vfox/1.0.13 vfox-nodejs/0.5.4`),[mirror.md](mirror.md#可用的镜像) 里的所有镜像都能安装 24.21.0。天翼云 `https://mirrors.ctyun.cn/nodejs-release` 也加进了这份列表([#45](https://github.com/version-fox/vfox-nodejs/pull/45))。 +- 插件从版本索引里学到 LTS 版本线,所以 Node.js 以后再升的版本线,不需要为插件发布新版本。它把学到的内容放在插件旁边的 `.lts-cache` 里。`vfox search`,或者安装 `latest` 或某个大版本时读到索引,以及安装某个确切版本、而这个文件不存在或者已有一天时,它会写这个文件;在 `specified` 和 `latest_installed` 下,`lts/`、`lts` 和 `lts/*` 读这个文件,不发任何请求。在学到任何内容之前,或者文件无法写入的地方,它使用一张代号表,这张表现在到 Lithium(26)为止:Node.js 26 在 2026-10-28 进入长期支持。0.5.3 只有这张表,而且到 Krypton(24)为止,所以在那里 `latest_installed` 下 `lts/lithium` 什么也选不中,`lts` 和 `lts/*` 选中某个 24.x。见 [lts.md](lts.md#插件认识哪些代号)([#44](https://github.com/version-fox/vfox-nodejs/pull/44))。 +- UTF-16 的 `.nvmrc` 或 `.node-version`,以及带字节顺序标记的 UTF-8 文件,现在可以读取了。Windows PowerShell 5.1 用 `>` 和 `Out-File` 写出前者,用 `-Encoding UTF8` 写出后者。0.5.3 按原样读取字节,所以没有任何版本能匹配这段文本,而 vfox 不会有任何提示。见 [nvmrc.md](nvmrc.md#文件里可以写什么)([#44](https://github.com/version-fox/vfox-nodejs/pull/44))。 +- `.nvmrc` 和 `.node-version` 在每个提示符出现在它们所在的目录里时都会读取,所以 `cd` 进去就会切换,改动文件则在下一个提示符生效。0.5.3 在 Shell 于该目录里启动时读取,`cd` 之后不读取,因为 vfox 1.0.13 会保留它为 Shell 第一次算出的结果,并且不跟踪版本文件。现在,每当 vfox 请插件读取这样的文件时,插件就会删除那个结果。从这个目录 `cd` 到完全没有配置的目录时还不会切换回来,而 `.vfox.toml` 一直都会。见 [nvmrc.md](nvmrc.md#什么时候读取这个文件)([#44](https://github.com/version-fox/vfox-nodejs/pull/44))。这个缓存是 vfox 的,已经请 vfox 修复([version-fox/vfox#745](https://github.com/version-fox/vfox/issues/745),这里用 [#46](https://github.com/version-fox/vfox-nodejs/issues/46) 跟踪)。 +- 文档新增了一页使用场景:nvm-sh/nvm 与 vfox 的命令对照、从零开始使用 Windows PowerShell 5.1、全团队使用同一个 Node.js、一个 Shell 里的多个项目、`vfox exec`、镜像和编辑器。见 [scenarios.md](scenarios.md)([#44](https://github.com/version-fox/vfox-nodejs/pull/44))。 ## 0.5.3(2026-10-20) diff --git a/docs/zh-CN/lts.md b/docs/zh-CN/lts.md index f3c4d0b..960ba85 100644 --- a/docs/zh-CN/lts.md +++ b/docs/zh-CN/lts.md @@ -26,7 +26,7 @@ $ vfox search nodejs | grep -m1 '(LTS)' `index.json` 在每个版本的 `lts` 字段里写明了 LTS 版本线的代号(`"lts": "Lithium"`,不在长期支持内的版本是 `false`)。插件从那里读取代号,而不是靠维护者手工维护的一份清单: - 在 `latest_available` 策略下,插件读取文件时向索引查询,也就是带有这个文件的目录里每个提示符都查一次,所以插件发布之后才出现的代号,当天就能用。 -- 在 `specified` 和 `latest_installed` 下,插件同样在每个提示符运行,不能每次都去取索引。它使用上一次拿到索引时学到的内容:`vfox search`,或者安装 `latest` 或某个大版本(比如 `nodejs@26`),向它要版本列表时(vfox 会把答案保留一段时间,所以不是每次搜索都会这样),以及安装某个版本、而这个文件不存在或者已有一天的时候。它把学到的内容放在插件旁边的 `.lts-cache` 里,vfox 自己的 `.available.cache` 也在那里。删掉这个文件就等于让它忘掉,下一次安装时会重新学到。 +- 在 `specified` 和 `latest_installed` 下,插件同样在每个提示符运行,不能每次都去取索引。它使用上一次拿到索引时学到的内容:`vfox search`,或者安装 `latest` 或某个大版本(比如 `nodejs@26`),向它要版本列表时(vfox 会把答案保留一段时间,所以不是每次搜索都会这样),以及安装某个版本、而这个文件不存在或者已有一天的时候。它把学到的内容放在插件旁边的 `.lts-cache` 里,vfox 自己的 `.available.cache` 也在那里。删掉这个文件就等于让它忘掉,下一次安装时会重新学到。插件如何学到这些,见 [development.md](development.md#插件如何学到-lts-版本线)。 - 在学到任何内容之前,或者文件无法写入的地方,它使用下面的表。这张表只是个起点:表里没有的版本线,插件一拿到索引就会学到。 “首个 LTS 版本”和“最后一个版本”取自 2026-11-03 的索引,Jod、Krypton 和 Lithium 仍在发布新版本: @@ -50,12 +50,10 @@ $ vfox search nodejs | grep -m1 '(LTS)' 编号为偶数的版本线每年十月进入长期支持,并在那时得到代号。Node.js 26 在 2026-10-28 就是这样,代号是 Lithium:26.13.0 是索引里第一个带 `lts` 标记的版本。升级版本线在实践中是这样的: -- 在 `latest_available` 下,新代号一出现在索引里,插件当天就能找到。这时 `lts` 和 `lts/*` 指的是新版本线的最新版本,`lts/lithium` 在那里当天就能用,0.5.3 也一样。 +- 在 `latest_available` 下,新代号一出现在索引里,插件当天就能找到。这时 `lts` 和 `lts/*` 指的是新版本线的最新版本,`lts/lithium` 在那里当天就能用。 - 在 `specified` 和 `latest_installed` 下,插件从升级之后第一次拿到索引起就认识这条版本线:也就是把新版本线带给你的那次 `vfox search` 或者安装。`latest_installed` 在没有安装这条版本线的任何版本之前什么也选不中,所以这已经够早了。在那之前,`lts/` 什么都选不中,`lts` 和 `lts/*` 指的是插件认识的最新的版本线。 - `vfox search` 里的 `(LTS)` 跟随索引,所以会立刻变化。 -未发布:0.5.3 只有那张表,没有这个文件。这张表发布时 Lithium 还没有出现,到 Krypton 为止,所以 2026-11-03,已安装 22.23.4、24.22.2 和 26.13.0 时,它在 `latest_installed` 下 `lts/*` 选中 24.22.2,`lts/lithium` 什么也选不中,要让它认识一条版本线,只有发布插件的新版本。插件如何学到这些,见 [development.md](development.md#插件如何学到-lts-版本线)。 - ## 示例 假设有一个 `.nvmrc`(`.node-version` 同理),并且已安装 `22.23.4`、`24.21.0` 和 `26.13.0`,情形是 2026-11-03 的。示例 1 到 4 都在 `latest_installed` 策略下运行,这个策略由示例 1 设置,各个策略见 [nvmrc.md](nvmrc.md#由策略决定): @@ -71,7 +69,7 @@ v22.23.4 ```sh # 2. 单独的 `lts`(或 `lts/*`)表示“插件认识的最新的 LTS 版本线”, -# 撰写本文时为 26(未发布:0.5.3 里是 24)。 +# 撰写本文时为 26。 $ printf 'lts\n' > .nvmrc $ cd && eval "$(vfox activate bash)" && eval "$(vfox env -s bash)" && node --version v26.13.0 diff --git a/docs/zh-CN/mirror.md b/docs/zh-CN/mirror.md index 64e0b1d..de93914 100644 --- a/docs/zh-CN/mirror.md +++ b/docs/zh-CN/mirror.md @@ -67,7 +67,7 @@ $env:VFOX_NODEJS_MIRROR = "https://npmmirror.com/mirrors/node" | 北京外国语大学 | `https://mirrors.bfsu.edu.cn/nodejs-release`(会重定向到 TUNA) | | 天翼云 | `https://mirrors.ctyun.cn/nodejs-release` | -2026-11-03,又用 vfox 1.0.13 通过它们各安装了一次 24.21.0(`VFOX_NODEJS_MIRROR= vfox install nodejs@24.21.0`),每一个都安装成功并且能运行。未发布:0.5.3 只能从 npmmirror、阿里云、腾讯云和南京大学安装。它把下载交给 vfox,而 vfox 请求时使用的是 Go HTTP 客户端的 `User-Agent`,即 `Go-http-client/1.1`,华为云(HTTP 418)、TUNA 和北外(403)以及 USTC(204,没有内容)对它返回的是错误页面或者空内容,而不是安装包:vfox 把这个回应存成文件,安装以 `checksum error` 结束。插件请求 `index.json` 和 `SHASUMS256.txt` 时用的是 vfox 为它生成的 `User-Agent`,即 `vfox/1.0.13 vfox-nodejs/0.5.3`,这些镜像都正常响应,现在下载时也改用同一个。 +2026-11-03,又用 vfox 1.0.13 通过它们各安装了一次 24.21.0(`VFOX_NODEJS_MIRROR= vfox install nodejs@24.21.0`),每一个都安装成功并且能运行。0.5.4 之前,通过华为云、TUNA、USTC 和北外安装会以 `checksum error` 结束:下载由 vfox 自己完成,它请求时使用的是 Go HTTP 客户端的 `User-Agent`,即 `Go-http-client/1.1`,华为云(HTTP 418)、TUNA 和北外(403)以及 USTC(204,没有内容)对它返回的是错误页面或者空内容,而不是安装包,vfox 把这个回应存成了文件。插件请求 `index.json` 和 `SHASUMS256.txt` 时用的是 vfox 为它生成的 `User-Agent`,即 `vfox/1.0.13 vfox-nodejs/0.5.4`,这些镜像都正常响应,下载时也改用同一个。 只做重定向的地址没有列出:2026-11-03,`mirror.sjtu.edu.cn/nodejs-release` 把请求转到了 nodejs.org,`mirrors.cernet.edu.cn/nodejs-release` 则转到了中科大的一台服务器。 diff --git a/docs/zh-CN/nvmrc.md b/docs/zh-CN/nvmrc.md index 9914fe9..9fd9474 100644 --- a/docs/zh-CN/nvmrc.md +++ b/docs/zh-CN/nvmrc.md @@ -19,7 +19,7 @@ cd my-project # 里面有上面那个 .nvmrc node -v # v22.23.3 ``` -vfox 挂载到 Shell 之后,每个提示符出现在这个目录里时都会读取这个文件,并选中其中指定的版本,所以 `cd` 进这个目录就会切换,改动文件也一样。不需要 `vfox use`。未发布:0.5.3 在 Shell 于这个目录里启动时读取,在已经运行的 Shell 里 `cd` 进来则不读取,上面的示例打印的是全局版本,见[下文](#什么时候读取这个文件)。挂载由 vfox 自己完成,zsh、fish、PowerShell 等其他 Shell 的挂载方式见它的[快速入门](https://vfox.dev/zh-hans/guides/quick-start.html)。 +vfox 挂载到 Shell 之后,每个提示符出现在这个目录里时都会读取这个文件,并选中其中指定的版本,所以 `cd` 进这个目录就会切换,改动文件也一样。不需要 `vfox use`。挂载由 vfox 自己完成,zsh、fish、PowerShell 等其他 Shell 的挂载方式见它的[快速入门](https://vfox.dev/zh-hans/guides/quick-start.html)。 - 只读取当前目录下的文件。进入项目的子目录就找不到它了,所以 `cd packages/app` 之后会回到全局版本。 - 同一目录里两个文件都有时,`.node-version` 优先。 @@ -33,24 +33,24 @@ vfox 挂载到 Shell 之后,每个提示符出现在这个目录里时都会 vfox 在 Shell 出现第一个提示符时算出它的环境,并把结果保存在会话目录的 `env-state.json` 里。只有当前目录的 `.vfox.toml` 与上次不是同一个、`PATH` 与上次不同,或者 vfox 的某个配置文件更新了(`vfox use` 就会造成这一点),它才会重新计算。`.nvmrc` 或 `.node-version` 不在其中(vfox 1.0.13,以及 2026-11-03 的 vfox `main`),所以 vfox 注意不到 Shell 进入了带有这类文件的目录。 -未发布:插件弥补了这一点。vfox 在查看保存的结果之前,会先运行插件的 `ParseLegacyFile`,插件就在这里删掉 `env-state.json`(`util.forget_env_state`),于是在带有这类文件的目录里,vfox 在每个提示符都会重新算一遍。`cd` 进这个目录会切换,从一个这样的目录 `cd` 到另一个也会,改动文件则在下一个提示符生效。多算这一次,在只装了一个 SDK 时每个提示符大约多花一毫秒,`--debug` 里显示为 `Config changed: true`。这是针对 vfox 的权宜之计,等 vfox 跟踪这些文件之后就该去掉。 +插件弥补了这一点。vfox 在查看保存的结果之前,会先运行插件的 `ParseLegacyFile`,插件就在这里删掉 `env-state.json`(`util.forget_env_state`),于是在带有这类文件的目录里,vfox 在每个提示符都会重新算一遍。`cd` 进这个目录会切换,从一个这样的目录 `cd` 到另一个也会,改动文件则在下一个提示符生效。多算这一次,在只装了一个 SDK 时每个提示符大约多花一毫秒,`--debug` 里显示为 `Config changed: true`。这是针对 vfox 的权宜之计,等 vfox 跟踪这些文件之后就该去掉。 从这个目录 `cd` 到完全没有配置的目录时,它帮不上忙。插件在那里不会被调用,所以 vfox 沿用它为你离开的那个目录算出的结果(`Using cached output`),Shell 也就停在那个版本上。带有 `.vfox.toml` 的目录,或者带有它自己的版本文件的目录,会切换,新开的 Shell 也一样。 -0.5.3 不会删除这个文件。它在 Shell 于该目录里启动时读取 `.nvmrc`,执行 `vfox use` 之后会再读一次,而 `cd` 之后不读,进出都一样。下面是在 vfox 1.0.13 里,同一个 Shell 一步一步执行时 `node -v` 打印的结果,全局版本是 26.13.0(bash 5.3,PowerShell 7.6.9 的结果一致): +下面是在 vfox 1.0.13 里,同一个 Shell 一步一步执行时 `node -v` 打印的结果,全局版本是 26.13.0(bash 5.3,PowerShell 7.6.9 的结果一致): -| 步骤 | 0.5.3 | 未发布 | -| --- | --- | --- | -| 在 `.nvmrc` 写着 18.20.8 的目录里启动一个 Shell | v18.20.8 | v18.20.8 | -| 在完全没有配置的目录里启动一个 Shell | v26.13.0 | v26.13.0 | -| `cd` 进有 18.20.8 那个 `.nvmrc` 的目录 | v26.13.0 | v18.20.8 | -| `cd` 进 `.node-version` 写着 24.22.2 的目录 | v26.13.0 | v24.22.2 | -| 把那个 `.node-version` 改成 22.23.4 | v26.13.0 | v22.23.4 | -| `cd` 进完全没有配置的目录 | v26.13.0 | v22.23.4 | -| `cd` 进 `.vfox.toml` 写着 18.20.8 的目录 | v18.20.8 | v18.20.8 | -| `cd` 进完全没有配置的目录 | v26.13.0 | v26.13.0 | +| 步骤 | `node -v` | +| --- | --- | +| 在 `.nvmrc` 写着 18.20.8 的目录里启动一个 Shell | v18.20.8 | +| 在完全没有配置的目录里启动一个 Shell | v26.13.0 | +| `cd` 进有 18.20.8 那个 `.nvmrc` 的目录 | v18.20.8 | +| `cd` 进 `.node-version` 写着 24.22.2 的目录 | v24.22.2 | +| 把那个 `.node-version` 改成 22.23.4 | v22.23.4 | +| `cd` 进完全没有配置的目录 | v22.23.4 | +| `cd` 进 `.vfox.toml` 写着 18.20.8 的目录 | v18.20.8 | +| `cd` 进完全没有配置的目录 | v26.13.0 | -第一行是单独的一个 Shell,其余七行是在第二个 Shell 里依次执行的。`vfox --debug env -s bash` 能看到“未发布”这一列的两种情形。在带有 `.nvmrc` 的目录里,插件解析了这个文件,vfox 重新计算: +第一行是单独的一个 Shell,其余七行是在第二个 Shell 里依次执行的。`vfox --debug env -s bash` 能看到这两种情形。在带有 `.nvmrc` 的目录里,插件解析了这个文件,vfox 重新计算: ```text Parsing legacy file /home/me/projects/legacy-api/.nvmrc @@ -67,7 +67,7 @@ Config changed: false, configPaths: map[global:/home/me/.vfox/.vfox.toml] Using cached output ``` -0.5.3 在带有 `.nvmrc` 的目录里,在 `Found nodejs@18.20.8` 之后打印的也是第二段。`.vfox.toml` 在两边都是被跟踪的,所以在发布版里想要 `cd` 时自动切换,用 `vfox use --project nodejs@18.20.8`。见 [scenarios.md](scenarios.md#一个-shell-里的多个项目)。 +`.vfox.toml` 是 vfox 自己跟踪的,所以它在两个方向上都会切换:`vfox use --project nodejs@18.20.8` 会写出一个。见 [scenarios.md](scenarios.md#一个-shell-里的多个项目)。 这个缓存是 vfox 的,修复也要由 vfox 来做。它已经作为 [version-fox/vfox#745](https://github.com/version-fox/vfox/issues/745) 报告,在有发布版带上修复之前,这里用 [#46](https://github.com/version-fox/vfox-nodejs/issues/46) 跟踪。等 vfox 自己能注意到版本文件之后,这个应对办法就可以去掉。 @@ -91,7 +91,7 @@ vfox config legacyVersionFile.strategy latest_installed 插件在处理文本之前,会先对它解码,去掉所有空白,去掉开头的 `v`,把其余部分转成小写,并把 `lts-jod` 改成 `lts/jod`。所以 `v22.23.3`、CRLF 换行的文件,以及版本前后的空白,都没有问题。`lts/jod` 这样的名字,会变成它所在版本线的大版本(22),这是插件从索引里知道的,见 [lts.md](lts.md);`latest_available` 除外,它会向索引查询带有这个代号的最新版本。版本号末尾可以用 `x`、`X` 或 `*` 代替不作限定的部分:`22.x`、`22.x.x` 和 `22.*` 都表示 22。 -解码的意思是,UTF-16 的文件,或者带字节顺序标记的 UTF-8 文件,读起来和纯文本一样。Windows PowerShell 5.1 的 `>`、`Out-File` 和 `-Encoding UTF8` 写出的就是这样的文件,见 [scenarios.md](scenarios.md#在-windows-powershell-51-里写这个文件)。未发布:0.5.3 按原样读取字节,所以标记或者 UTF-16 的零字节会成为文本的一部分,没有任何版本能匹配它,而 vfox 不会有任何提示。 +解码的意思是,UTF-16 的文件,或者带字节顺序标记的 UTF-8 文件,读起来和纯文本一样。Windows PowerShell 5.1 的 `>`、`Out-File` 和 `-Encoding UTF8` 写出的就是这样的文件,见 [scenarios.md](scenarios.md#在-windows-powershell-51-里写这个文件)。 下面是 2026-11-03 在已安装 20.20.2、22.23.4、24.21.0、25.9.0 和 26.13.0 的情况下得到的结果,此时 24.22.2 是最新的 24.x,22.23.4 是最新的 22.x: @@ -108,7 +108,7 @@ vfox config legacyVersionFile.strategy latest_installed `latest_available` 不会回退到较旧的已安装版本。索引里列出的版本比你已安装的更新时,什么都不会选中。想选中已安装的最新版本,请用 `latest_installed`。 -`lts` 和 `lts/*` 指最新的 LTS 版本线。在 `specified` 和 `latest_installed` 下,指的是插件认识的最新的版本线(撰写本文时为 26);在 `latest_available` 下,指的是索引里带有任意代号的最新版本。插件如何认识版本线,以及 Node.js 把一条新版本线升为 LTS 时会发生什么,见 [lts.md](lts.md)。未发布:0.5.3 只认识一张到 Krypton(24)为止的表,因为它发布时 Node.js 26 还不是 LTS 版本线。在那里,`latest_installed` 下 `lts/lithium` 什么也选不中,`lts` 和 `lts/*` 在上面的表里选中 24.21.0。 +`lts` 和 `lts/*` 指最新的 LTS 版本线。在 `specified` 和 `latest_installed` 下,指的是插件认识的最新的版本线(撰写本文时为 26);在 `latest_available` 下,指的是索引里带有任意代号的最新版本。插件如何认识版本线,以及 Node.js 把一条新版本线升为 LTS 时会发生什么,见 [lts.md](lts.md)。 ## 不认识的写法 @@ -133,14 +133,14 @@ vfox config legacyVersionFile.strategy latest_installed 版本没有切换时: - vfox 没有挂载到当前的 Shell。`eval "$(vfox activate bash)"` 要在当前 Shell 里执行过,只在别处执行过不算。 -- 仅限 0.5.3:你 `cd` 进这个目录时,Shell 已经在运行,见[什么时候读取这个文件](#什么时候读取这个文件)。请在那里打开一个新终端,或者安装 `main` 的插件([source-build.md](source-build.md))。 +- 仅限 0.5.4 之前:你 `cd` 进这个目录时,Shell 已经在运行,而 vfox 沿用了它为这个 Shell 算出的版本。请在那里打开一个新终端,或者用 `vfox update nodejs` 更新插件。 - Shell 从带有版本文件的目录进入了完全没有配置的目录,它会保持离开的那个目录的版本。请打开一个新终端。 - 当前目录是文件所在目录的子目录。 - 版本没有安装,用 `vfox install nodejs@22.23.3` 安装。 - 策略是 `specified`,而文件里写的是 `22` 或 `lts/jod`。 - 在 `latest_available` 下,已经发布了比已安装版本更新的版本。 - 被 `.vfox.toml` 或 `.tool-versions` 挡住了,或者 `legacyVersionFile.enable` 是 `false`。 -- 文本属于上面列出的不认识的写法,或者里面带有注释,或者文件的编码是插件读不了的(0.5.3:只能读纯 ASCII 文本)。 +- 文本属于上面列出的不认识的写法,或者里面带有注释,或者文件的编码是插件读不了的(0.5.4 之前:只能读纯 ASCII 文本)。 `vfox --debug env -s bash` 会打印插件返回了什么,以及 vfox 怎样处理它: diff --git a/docs/zh-CN/scenarios.md b/docs/zh-CN/scenarios.md index d3a9f2b..65e26bb 100644 --- a/docs/zh-CN/scenarios.md +++ b/docs/zh-CN/scenarios.md @@ -4,14 +4,14 @@ 这个插件给 vfox 提供的,正是 [nvm-sh/nvm](https://github.com/nvm-sh/nvm) 给 POSIX Shell 提供的东西:多个 Node.js 版本并存,可以为一个 Shell、一个项目选定其中一个,或者设为默认,并且能读取 `.nvmrc` 文件。nvm-sh/nvm 是一组 Shell 函数。它的 README 列出的是 Unix、macOS 和 WSL 上的 sh、dash、ksh、zsh 和 bash,另外在某些情况下也可以用于 Git Bash 和 Cygwin,其他 Windows 用户则被指向别的工具。PowerShell 不在这个列表里。vfox 是一个程序,为每种 Shell 都提供挂载脚本,所以同样的事情既可以在 Windows 10 和 11 自带的 Windows PowerShell 5.1 里做,也可以在 PowerShell 7、bash、zsh 和 fish 里做。 -下面每个场景都写明你想做什么、要输入什么、会看到什么。输出取自 2026-11-03 的 Linux x64,使用 vfox 1.0.13 和 `main` 上的本插件,主目录一律写成 `/home/me`。PowerShell 的命令在 Linux 上的 PowerShell 7.6.9 里运行过,只有 Windows 独有的除外:`Set-ExecutionPolicy`,以及写入用户级环境变量的 `[Environment]::SetEnvironmentVariable`。Windows PowerShell 5.1 本身不在测试套件里(见 [platforms.md](platforms.md#ci-覆盖什么)),所以凡是依据 PowerShell 的文档或 vfox 的源码、而没有在那里实际运行过的内容,场景里都会注明。 +下面每个场景都写明你想做什么、要输入什么、会看到什么。输出取自 2026-11-03 的 Linux x64,使用 vfox 1.0.13 和后来成为 0.5.4 的代码,主目录一律写成 `/home/me`。PowerShell 的命令在 Linux 上的 PowerShell 7.6.9 里运行过,只有 Windows 独有的除外:`Set-ExecutionPolicy`,以及写入用户级环境变量的 `[Environment]::SetEnvironmentVariable`。Windows PowerShell 5.1 本身不在测试套件里(见 [platforms.md](platforms.md#ci-覆盖什么)),所以凡是依据 PowerShell 的文档或 vfox 的源码、而没有在那里实际运行过的内容,场景里都会注明。 ## 从 nvm 迁移 | nvm-sh/nvm | vfox | 说明 | | --- | --- | --- | | `nvm install 22` | `vfox install nodejs@22` | 最新的 22.x,并对照 SHA-256 校验和检查。见 [versions.md](versions.md) | -| `nvm install node` | `vfox install nodejs@latest` | 未发布:0.5.3 在索引里有预发布版本时会失败,2026-10-29 起就是这样。`nodejs@26` 在哪里都能用 | +| `nvm install node` | `vfox install nodejs@latest` | 所有版本线中最新的版本,不论是否属于 LTS。见 [versions.md](versions.md#安装) | | `nvm install --lts`、`nvm install 'lts/*'` | `vfox install nodejs@26` | 没有 `lts` 这个名字,请写明版本线。2026-11-03 时 26 是最新的 LTS 版本线,`vfox search nodejs \| grep -m1 '(LTS)'` 会显示最新的 LTS 版本。见 [lts.md](lts.md) | | `nvm use 22` | `vfox use nodejs@22` | 只对当前 Shell 有效。`22` 是已安装的最新的 22.x | | `nvm alias default 22` | `vfox use --global nodejs@22` | 之后的每个新 Shell | @@ -75,7 +75,7 @@ 如果 `vfox use --session` 打印了这一行,说明配置文件没有运行:要么是第 1 步的执行策略,要么是挂载那一行写在了另一个 PowerShell 的配置文件里。 - 只有 `PATH` 里的第一个 `node` 会运行。nodejs.org 的安装程序、winget 或 Scoop 装的,或者另一个版本管理器的,都可能排在 vfox 前面。这时 `vfox use` 会打印一条提示,指出是哪一个,并说明它排在 vfox 前面,见 [pnpm.md](pnpm.md)。请卸载另一个。 -- Windows PowerShell 5.1 用 `>` 写出的 `.nvmrc` 是 UTF-16。未发布:0.5.3 读不了它,见[下文](#在-windows-powershell-51-里写这个文件)。 +- Windows PowerShell 5.1 用 `>` 写出的 `.nvmrc` 是 UTF-16,插件能读它,见[下文](#在-windows-powershell-51-里写这个文件)。 ## 全团队使用同一个 Node.js @@ -118,19 +118,19 @@ vfox install "nodejs@$((Get-Content .nvmrc -TotalCount 1).Trim())" `v22.23.4` 可以,因为 vfox 会去掉 `v`;`22` 也可以,它会安装最新的 22.x。`lts/*` 和 `.nvmrc` 里的其他名字则不行:安装会以 `version not found for provided version lts/*` 结束。 -每个提示符出现在项目目录里时都会应用 `.nvmrc`,所以 `cd` 进去就会切换。未发布:0.5.3 在 Shell 于该目录里启动时应用它,比如编辑器在这个文件夹里打开的终端;从已经运行的 Shell 里 `cd` 进来则不应用。离开这个目录进入完全没有配置的目录时,两边都不会切换回来,见[一个 Shell 里的多个项目](#一个-shell-里的多个项目)。如果仓库里不该出现 vfox 的文件,`vfox use --project` 仍然可以让你自己得到一个 `.vfox.toml`,它在每个版本里、两个方向上都会切换。把 `.vfox.toml` 和 `.vfox/` 写进 `.git/info/exclude`,再执行 `vfox config gitignore.enable false`(对所有项目生效),这样 vfox 就不会把 `.vfox/` 加进仓库所跟踪的 `.gitignore`。 +每个提示符出现在项目目录里时都会应用 `.nvmrc`,所以 `cd` 进去就会切换。离开这个目录进入完全没有配置的目录时不会切换回来,见[一个 Shell 里的多个项目](#一个-shell-里的多个项目)。如果仓库里不该出现 vfox 的文件,`vfox use --project` 仍然可以让你自己得到一个 `.vfox.toml`,它在两个方向上都会切换。把 `.vfox.toml` 和 `.vfox/` 写进 `.git/info/exclude`,再执行 `vfox config gitignore.enable false`(对所有项目生效),这样 vfox 就不会把 `.vfox/` 加进仓库所跟踪的 `.gitignore`。 ### 在 Windows PowerShell 5.1 里写这个文件 -Windows PowerShell 5.1 的 `>`、`>>` 和 `Out-File` 写出 UTF-16,`-Encoding UTF8` 写出带字节顺序标记的 UTF-8,不带 `-Encoding` 的 `Set-Content` 写的是 ANSI 代码页,对版本号来说就是纯文本([about_Character_Encoding](https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_character_encoding))。插件在读取文本之前,会先对 UTF-16 解码并去掉标记。未发布:0.5.3 按原样读取字节,所以标记或者 UTF-16 的零字节会成为文本的一部分,没有任何版本能匹配它,而 vfox 对此不会有任何提示。下表给出每种文件开头的字节,以及已安装 22.23.4、使用默认策略时,带有该文件的目录选中了什么: +Windows PowerShell 5.1 的 `>`、`>>` 和 `Out-File` 写出 UTF-16,`-Encoding UTF8` 写出带字节顺序标记的 UTF-8,不带 `-Encoding` 的 `Set-Content` 写的是 ANSI 代码页,对版本号来说就是纯文本([about_Character_Encoding](https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_character_encoding))。插件在读取文本之前,会先对 UTF-16 解码并去掉标记。下表给出每种文件开头的字节,以及已安装 22.23.4、使用默认策略时,带有该文件的目录选中了什么: -| 文件开头的字节 | Windows PowerShell 5.1 用什么写出 | 0.5.3 | 未发布 | -| --- | --- | --- | --- | -| `32 32 2e 32 33 2e 34 0d 0a` | `Set-Content .nvmrc 22.23.4 -Encoding ascii`,或者 `Set-Content .nvmrc 22.23.4` | 22.23.4 | 22.23.4 | -| `ef bb bf 32 32 2e ...` | `Set-Content .nvmrc 22.23.4 -Encoding UTF8` | 无 | 22.23.4 | -| `ff fe 32 00 32 00 2e 00 ...` | `'22.23.4' > .nvmrc`、`'22.23.4' \| Out-File .nvmrc` | 无 | 22.23.4 | +| 文件开头的字节 | Windows PowerShell 5.1 用什么写出 | 选中 | +| --- | --- | --- | +| `32 32 2e 32 33 2e 34 0d 0a` | `Set-Content .nvmrc 22.23.4 -Encoding ascii`,或者 `Set-Content .nvmrc 22.23.4` | 22.23.4 | +| `ef bb bf 32 32 2e ...` | `Set-Content .nvmrc 22.23.4 -Encoding UTF8` | 22.23.4 | +| `ff fe 32 00 32 00 2e 00 ...` | `'22.23.4' > .nvmrc`、`'22.23.4' \| Out-File .nvmrc` | 22.23.4 | -这些字节是在 Linux 上写出的,两个版本的插件都在那里试过。Windows PowerShell 写出什么,依据的是微软的文档。PowerShell 7 对上面这些写法都写出不带标记的 UTF-8,每个版本都能读。下面这样写在哪里都可以: +这些字节是在 Linux 上写出的,也是在那里试的。Windows PowerShell 写出什么,依据的是微软的文档。PowerShell 7 对上面这些写法都写出不带标记的 UTF-8,插件把它当作纯文本读取。下面这样写在哪里都可以: ```powershell Set-Content -Path .nvmrc -Value '22.23.4' -Encoding ascii @@ -140,24 +140,24 @@ Set-Content -Path .nvmrc -Value '22.23.4' -Encoding ascii 一个用 Node.js 18 的旧 API,一个用 24 的 Web 应用,其余的都用全局的 26。在挂载了 vfox 的 Shell 里,在它们之间 `cd`。下面是同一个 Shell 里每一步 `node -v` 的输出,已安装 18.20.8、24.22.2 和 26.13.0,全局版本是 26.13.0(bash 5.3,PowerShell 7.6.9 的结果一致): -| 步骤 | 0.5.3 | 未发布 | -| --- | --- | --- | -| Shell 在完全没有配置的目录里启动 | v26.13.0 | v26.13.0 | -| `cd` 进 `.nvmrc` 写着 18.20.8 的目录 | v26.13.0 | v18.20.8 | -| `cd` 进 `.node-version` 写着 24.22.2 的目录 | v26.13.0 | v24.22.2 | -| `cd` 进完全没有配置的目录 | v26.13.0 | v24.22.2 | -| `cd` 进 `.vfox.toml` 写着 18.20.8 的目录 | v18.20.8 | v18.20.8 | -| `cd` 进 `.vfox.toml` 写着 24.22.2 的目录 | v24.22.2 | v24.22.2 | -| `cd` 进完全没有配置的目录 | v26.13.0 | v26.13.0 | - -- **`.vfox.toml`** 在每次 `cd` 时都会切换,离开去没有配置的目录时也会切回全局版本。每个版本都是这样。 -- **`.nvmrc` 和 `.node-version`** 在每个提示符出现在它所在的目录里时都会读取(未发布)。从一个这样的目录 `cd` 到另一个会切换,改动文件则在下一个提示符生效。0.5.3 只在 Shell 于该目录里启动时读取,所以上面的 `cd` 步骤一个都没有切换。 -- **离开**带有这类文件的目录、进入完全没有配置的目录时,两边都不会切换回来:Shell 保持它原有的版本,第四步就是这样。在没有东西可读的目录里不会调用插件,vfox 沿用它保存的结果。新开的终端,或者带有 `.vfox.toml` 或它自己的版本文件的目录,会切换。这是 vfox 缓存的限制,已作为 [version-fox/vfox#745](https://github.com/version-fox/vfox/issues/745) 报告,这里用 [#46](https://github.com/version-fox/vfox-nodejs/issues/46) 跟踪。 +| 步骤 | `node -v` | +| --- | --- | +| Shell 在完全没有配置的目录里启动 | v26.13.0 | +| `cd` 进 `.nvmrc` 写着 18.20.8 的目录 | v18.20.8 | +| `cd` 进 `.node-version` 写着 24.22.2 的目录 | v24.22.2 | +| `cd` 进完全没有配置的目录 | v24.22.2 | +| `cd` 进 `.vfox.toml` 写着 18.20.8 的目录 | v18.20.8 | +| `cd` 进 `.vfox.toml` 写着 24.22.2 的目录 | v24.22.2 | +| `cd` 进完全没有配置的目录 | v26.13.0 | + +- **`.vfox.toml`** 在每次 `cd` 时都会切换,离开去没有配置的目录时也会切回全局版本。 +- **`.nvmrc` 和 `.node-version`** 在每个提示符出现在它所在的目录里时都会读取。从一个这样的目录 `cd` 到另一个会切换,改动文件则在下一个提示符生效。 +- **离开**带有这类文件的目录、进入完全没有配置的目录时不会切换回来:Shell 保持它原有的版本,第四步就是这样。在没有东西可读的目录里不会调用插件,vfox 沿用它保存的结果。新开的终端,或者带有 `.vfox.toml` 或它自己的版本文件的目录,会切换。这是 vfox 缓存的限制,已作为 [version-fox/vfox#745](https://github.com/version-fox/vfox/issues/745) 报告,这里用 [#46](https://github.com/version-fox/vfox-nodejs/issues/46) 跟踪。 原因在 [nvmrc.md](nvmrc.md#什么时候读取这个文件):vfox 把 Shell 第一次计算的结果保存下来,并不跟踪版本文件(vfox 1.0.13),而插件在每次读取版本文件时都会让 vfox 重新计算。所以: -- 对需要在同一个 Shell 里来回切换的项目,`.vfox.toml` 在每个版本里、两个方向上都管用:在每个项目里执行 `vfox use --project nodejs@18.20.8` 这样的命令。 -- 在该目录里启动的东西,`.nvmrc` 就够了:编辑器里的终端、同一文件夹里新开的标签页、脚本。这也是本仓库的 Windows E2E 套件为每个目录都新启动一个 Shell 的原因。 +- 对需要在同一个 Shell 里来回切换的项目,`.vfox.toml` 在两个方向上都管用:在每个项目里执行 `vfox use --project nodejs@18.20.8` 这样的命令。 +- 在该目录里启动的东西,`.nvmrc` 就够了:编辑器里的终端、同一文件夹里新开的标签页、脚本。本仓库的 Windows E2E 套件为每个目录都新启动一个 Shell,所以在已经运行的 Windows Shell 里 `cd` 的情形不在其中。 ## 只在这个窗口里换一个版本 diff --git a/docs/zh-CN/source-build.md b/docs/zh-CN/source-build.md index 906c2af..a5b6e99 100644 --- a/docs/zh-CN/source-build.md +++ b/docs/zh-CN/source-build.md @@ -10,7 +10,7 @@ vfox add nodejs 需要尚未发布的内容(`main` 分支,或者检出的某个 PR)时,就从源码安装:把检出的代码打包成 zip,交给 `vfox add --source`。zip 的顶层必须有 `metadata.lua`、`hooks/` 和 `lib/`,这是插件包的约定(见[共享工作流文档](https://github.com/version-fox/plugin-manifest-action))。 -已发布的插件 zip 的 URL 也可以用作 `--source`,例如 `vfox add --source https://github.com/version-fox/vfox-nodejs/releases/download/v0.5.3/vfox-nodejs-0.5.3.zip`。 +已发布的插件 zip 的 URL 也可以用作 `--source`,例如 `vfox add --source https://github.com/version-fox/vfox-nodejs/releases/download/v0.5.4/vfox-nodejs-0.5.4.zip`。 所有系统都需要事先装好 [vfox](https://github.com/version-fox/vfox) 本身和 `git`。 diff --git a/docs/zh-CN/troubleshooting.md b/docs/zh-CN/troubleshooting.md index f7f890f..6243a03 100644 --- a/docs/zh-CN/troubleshooting.md +++ b/docs/zh-CN/troubleshooting.md @@ -10,7 +10,7 @@ `nodejs@` 后面既不是版本号,也不是某个版本号的开头。插件认识 `latest`、`24.21.0`、`24.21` 和 `24`,见 [versions.md](versions.md)。`lts`、`lts/iron`、`stable`、`24.21.0.1` 和 `24.0.0-rc.1` 都会报这个错,`99` 和 `22.99` 也一样:它们的格式没有问题,但没有任何版本以它们开头。要安装某条 LTS 版本线,请按编号安装,见 [lts.md](lts.md#安装一条-lts-版本线)。 -未发布:0.5.3 对 `latest` 也会报这个错,即 `version not found for provided version 27.0.0-alpha.0.0.0`,因为 nodejs.org 的索引从 2026-10-29 起把这个预发布版本列为最新的一条。`nodejs@26` 不受影响。 +0.5.4 之前,`latest` 也会报这个错,即 `version not found for provided version 27.0.0-alpha.0.0.0`,因为 nodejs.org 的索引从 2026-10-29 起把这个预发布版本列为最新的一条。`nodejs@26` 不受影响。 ### `get checksum failed: HTTP 404 from https://nodejs.org/dist/v24.99.0/SHASUMS256.txt` @@ -46,7 +46,7 @@ vfox 没有告诉插件当前运行在哪种 CPU 上。这是不应该出现的 vfox 会打印 `Verifying checksum ...`,拿下载的文件和这个校验和比对,不一致就停下来,并指出它丢弃的文件:`Checksum error, file: ~/.vfox/cache/nodejs/node-v24.21.0-linux-x64.tar.gz`。常见的原因是下载被截断,或者镜像上的文件与它自己的 `SHASUMS256.txt` 对不上。不会安装任何东西。请重试,或者换一个[镜像](mirror.md)。 -未发布:0.5.3 通过华为云、TUNA、USTC 和北外安装时也会停在这里。vfox 下载时使用 Go HTTP 客户端的 `User-Agent`,这几个镜像对它返回的是错误页面或者空内容,而不是安装包,vfox 再拿这个回应去比对校验和。插件现在让下载使用它自己请求时的 `User-Agent`,见 [mirror.md](mirror.md#可用的镜像)。 +0.5.4 之前,通过华为云、TUNA、USTC 和北外安装时也会停在这里:vfox 下载时使用 Go HTTP 客户端的 `User-Agent`,这几个镜像对它返回的是错误页面或者空内容,而不是安装包,vfox 再拿这个回应去比对校验和。从 0.5.4 起,插件让下载使用它自己请求时的 `User-Agent`,见 [mirror.md](mirror.md#可用的镜像)。 ### `nodejs@24.99 is not installed` @@ -123,7 +123,7 @@ vfox config proxy.url http://127.0.0.1:7890 - **`vfox current nodejs` 和 `node -v` 的结果不一致。** 原因同上。前者给出的是会话或作用域里的选择,后者是 `PATH` 实际找到的。 - **`vfox use` 之后,全局安装的 npm 包不见了。** 全局包属于某个版本,见 [npm.md](npm.md#全局包属于某个版本)。 - **找不到 `corepack`。** Node.js 25 及以后的版本不自带它,见 [npm.md](npm.md#yarnpnpm-与-corepack)。 -- **`.nvmrc` 什么也没选中。** 请检查策略和文件里的内容,以及 Shell 是不是从带有版本文件的目录进入了完全没有配置的目录(它会保持原有的版本)。0.5.3 在已经运行的 Shell 里 `cd` 之后也不会读取这个文件。见 [nvmrc.md](nvmrc.md#没有生效)。 +- **`.nvmrc` 什么也没选中。** 请检查策略和文件里的内容,以及 Shell 是不是从带有版本文件的目录进入了完全没有配置的目录(它会保持原有的版本)。0.5.4 之前,在已经运行的 Shell 里 `cd` 之后也不会读取这个文件。见 [nvmrc.md](nvmrc.md#没有生效)。 - **`git status` 列出了 `.vfox/`。** vfox 会把这个版本以 `.vfox/sdks/nodejs` 的形式链接到项目里。请在 `.gitignore` 里忽略 `.vfox/`,并保留 `.vfox.toml`。 - **安装后的版本名里没有 `v`。** 版本的名字形如 `24.21.0`,你输入时带的 `v` 会被去掉。 diff --git a/docs/zh-CN/versions.md b/docs/zh-CN/versions.md index 7c5d47f..96ae88c 100644 --- a/docs/zh-CN/versions.md +++ b/docs/zh-CN/versions.md @@ -27,7 +27,7 @@ vfox install nodejs@latest # 所有版本线中最新的版本 - “最新”指索引里列出的所有版本中数字最大的那个,不论是否属于 LTS。尚未进入长期支持的版本线(比如现在的 26)可以比最新的 LTS 版本线更新,所以 `latest` 并不等于 LTS 版本。 - `24` 和 `24.21` 是在索引里查找的,不是在已安装的版本里查找。`vfox install nodejs@24` 会装上比你已有的更新的 24.x;已经是最新版本时,则打印 `nodejs@24.22.0 is already installed`。 -- 插件只列出由三段数字组成的版本,别的一概没有:没有 `-rc` 构建、alpha 版本、每日构建,也没有四段数字的版本号。这些写法最终都会报 `version not found for provided version ...`。未发布:0.5.3 会列出索引里的所有条目。2026-10-29 起,其中包括最新的一条预发布版本 `27.0.0-alpha.0.0.0`,所以 `latest` 最终会报 `version not found for provided version 27.0.0-alpha.0.0.0`,而 `nodejs@26` 会安装最新的 26.x。 +- 插件只列出由三段数字组成的版本,别的一概没有:没有 `-rc` 构建、alpha 版本、每日构建,也没有四段数字的版本号。这些写法最终都会报 `version not found for provided version ...`。 - 不存在的版本号(`24.99.0`)最终会报 `get checksum failed: HTTP 404 from ...`,因为 nodejs.org 上没有对应的目录。版本存在但没有你所在平台的包时,最终会报 `Node.js package ... is not listed in ...`。见 [troubleshooting.md](troubleshooting.md#插件给出的提示) 和 [platforms.md](platforms.md)。 - 每次下载都会对照该版本 `SHASUMS256.txt` 里的 SHA-256 校验和进行检查。vfox 会打印 `Verifying checksum ...`,校验和不一致时会报 `checksum error` 并停止,什么也不会安装。 - 安装时如果发现同名的版本已经存在,就不会下载任何东西。 @@ -106,7 +106,7 @@ Available versions: - 0.6.2 [npm ] ``` -- 列表就是 nodejs.org(或你的[镜像](mirror.md))的 `index.json`,其中有预发布版本时除外:2026-10-21 共有 872 个版本,从 0.1.14 到 26.12.0。npm 从 0.6.3 起才有,更早的版本是空的。未发布:0.5.3 也会列出预发布版本。 +- 列表就是 nodejs.org(或你的[镜像](mirror.md))的 `index.json`,其中有预发布版本时除外:2026-10-21 共有 872 个版本,从 0.1.14 到 26.12.0。npm 从 0.6.3 起才有,更早的版本是空的。 - `(LTS)` 对应索引里的 `lts` 字段,Node.js 从一条版本线进入长期支持的那天起才会设置它。Krypton 版本线里第一个带有该字段的版本是 24.11.0,24.10.0 及更早的版本没有。见 [lts.md](lts.md)。 - 插件会忽略参数:`vfox search nodejs 24` 打印的仍是同一份完整的列表。要过滤的话,用管道,比如 `vfox search nodejs | grep '^ - 24\.'`。在管道里,vfox 只打印输出。 - 在交互式终端里,vfox 改为显示一个选择列表(`Please select a version of nodejs to install [type to search]`):方向键移动,输入内容过滤,回车确认。 From 4df47168f21d97a4c080ea428028836468bd6177 Mon Sep 17 00:00:00 2001 From: Qiheng He Date: Wed, 4 Nov 2026 10:18:19 +0800 Subject: [PATCH 2/2] docs(versions): Node.js 26 is an LTS line since 2026-10-28 "A line that is not in long-term support yet, such as 26 today" stopped being true when 26.13.0 (Lithium) came out on 2026-10-28; the index of nodejs.org shows it with `lts: Lithium`, and it is the newest release, so `latest` is an LTS release now. The sentence is about why `latest` is not "the LTS", and the table above it is from 2026-10-21, when 26 was still the line that was not in long-term support. It says so now, in English and Chinese. This is not caused by release 0.5.4. It is a separate commit so that it can be dropped alone. --- docs/versions.md | 4 ++-- docs/zh-CN/versions.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/versions.md b/docs/versions.md index cacd47b..5c1fe7e 100644 --- a/docs/versions.md +++ b/docs/versions.md @@ -30,8 +30,8 @@ checks it and unpacks it. These are the answers on 2026-10-21: | `latest` | `26.12.0`, the newest release in the index. vfox prints `Using latest version: 26.12.0` first | - "Newest" is the highest number among the releases that the index lists, LTS - or not. A line that is not in long-term support yet, such as 26 today, can be - newer than the newest LTS line, so `latest` is not "the LTS". + or not. A line that is not in long-term support yet can be newer than the + newest LTS line, as 26 was until 2026-10-28, so `latest` is not "the LTS". - `24` and `24.21` are looked up in the index, not among what is installed. `vfox install nodejs@24` installs a newer 24.x than the one you have, and prints `nodejs@24.22.0 is already installed` once you have the newest. diff --git a/docs/zh-CN/versions.md b/docs/zh-CN/versions.md index 96ae88c..9378e96 100644 --- a/docs/zh-CN/versions.md +++ b/docs/zh-CN/versions.md @@ -25,7 +25,7 @@ vfox install nodejs@latest # 所有版本线中最新的版本 | `24` | `24.22.0`,即最新的 24.x | | `latest` | `26.12.0`,即索引里最新的版本。vfox 会先打印 `Using latest version: 26.12.0` | -- “最新”指索引里列出的所有版本中数字最大的那个,不论是否属于 LTS。尚未进入长期支持的版本线(比如现在的 26)可以比最新的 LTS 版本线更新,所以 `latest` 并不等于 LTS 版本。 +- “最新”指索引里列出的所有版本中数字最大的那个,不论是否属于 LTS。尚未进入长期支持的版本线可以比最新的 LTS 版本线更新(26 在 2026-10-28 之前就是这样),所以 `latest` 并不等于 LTS 版本。 - `24` 和 `24.21` 是在索引里查找的,不是在已安装的版本里查找。`vfox install nodejs@24` 会装上比你已有的更新的 24.x;已经是最新版本时,则打印 `nodejs@24.22.0 is already installed`。 - 插件只列出由三段数字组成的版本,别的一概没有:没有 `-rc` 构建、alpha 版本、每日构建,也没有四段数字的版本号。这些写法最终都会报 `version not found for provided version ...`。 - 不存在的版本号(`24.99.0`)最终会报 `get checksum failed: HTTP 404 from ...`,因为 nodejs.org 上没有对应的目录。版本存在但没有你所在平台的包时,最终会报 `Node.js package ... is not listed in ...`。见 [troubleshooting.md](troubleshooting.md#插件给出的提示) 和 [platforms.md](platforms.md)。