Commit Graph

35 Commits

Author SHA1 Message Date
Zoltan Kochan
23eb4a6141 refactor(env): unify node version specifier parsing into parseNodeSpecifier in node.resolver (#10668)
* refactor(env): unify node version specifier parsing into parseNodeSpecifier in node.resolver

Move parseNodeSpecifier from @pnpm/plugin-commands-env to @pnpm/node.resolver and
replace the simpler parseEnvSpecifier with an enhanced version that supports all
Node.js version specifier formats: standalone release channels (nightly, rc, test,
v8-canary, release), well-known aliases (lts, latest), LTS codenames (argon, iron),
semver ranges (18, ^18), and channel/version combos (rc/18, nightly/latest).

* fix(env): address parseNodeSpecifier review feedback

- Remove overly strict release/X.Y.Z-only validation; release/latest,
  release/lts, and release/<range> are now accepted
- Validate unknown release channels (e.g. foo/18) with a clear error
  instead of letting them fall through to a confusing network failure
- Add test cases for release/latest, release/lts, and release/18
2026-02-22 14:34:02 +01:00
Zoltan Kochan
50fbecae7d refactor(env): pnpm env use now delegates to pnpm add --global (#10666)
This PR overhauls `pnpm env` use to route through pnpm's own install machinery instead of maintaining a parallel code path with manual symlink/shim/hardlink logic.

```
pnpm env use -g <version>
```

now runs:

```
pnpm add --global node@runtime:<version>
```

via `@pnpm/exec.pnpm-cli-runner`. All manual symlink, hardlink, and cmd-shim code in `envUse.ts` is gone (~1000 lines removed across the package).

### Changes

**npm and npx shims on all platforms**

Added `getNodeBinsForCurrentOS(platform)` to `@pnpm/constants`, returning a `Record<string, string>` with the correct relative paths for `node`, `npm`, and `npx` inside a Node.js distribution. `BinaryResolution.bin` is widened from `string` to `string | Record<string, string>` in `@pnpm/resolver-base` and `@pnpm/lockfile.types`, so the node resolver can set all three entries and pnpm's bin-linker creates shims for each automatically.

**Windows npm/npx fix**

`addFilesFromDir` was skipping root-level `node_modules/` (to avoid storing a package's own dependencies), which stripped the bundled `npm` from Node.js Windows zip archives. Added an `includeNodeModules` option and enabled it from the binary fetcher so Windows distributions keep their full contents.

**Removed subcommands**

`pnpm env add` and `pnpm env remove` are removed. `pnpm env use` handles both installing and activating a version. `pnpm env list` now always lists remote versions (the `--remote` flag is no longer required, though it is kept for backwards compatibility).

**musl support**

On Alpine Linux and other musl-based systems, the musl variant of Node.js is automatically downloaded from [unofficial-builds.nodejs.org](https://unofficial-builds.nodejs.org).
2026-02-22 12:06:34 +01:00
Zoltan Kochan
9065f491f0 feat: add musl support to node runtime (#10664)
The lockfile now includes musl Linux builds (sourced from
unofficial-builds.nodejs.org) alongside the standard glibc variants,
so that `node@runtime:` works out of the box on Alpine Linux and other
musl-based distributions.

`env use` can download node.js artifacts for systems that use musl.
2026-02-21 21:29:05 +01:00
Brandon Cheng
1a5b5beea2 build: replace ts-jest with simple transformer (#10579)
* test: use `import type` in more places

Several tests are failing because a module isn't being mocked. This is
due to the mocked module being imported before the mock being set up.

Switching to `import type` should elide the import fully.

* build: replace ts-jest with simple transformer

* chore: remove `ts-jest`

* chore: remove babel dependencies from root project

* ci: use Node.js 22.13.0 (instead of 22.12.0)

Node.js 22.13.0 introduces the `stripTypeScriptTypes` function

* fix: copilot feedback
2026-02-09 11:35:22 +01:00
Zoltan Kochan
66d93e81d9 fix: update tar-stream to v3 2026-01-18 20:18:55 +01:00
Zoltan Kochan
71de2b3f2b feat!: remove use-node-version CLI option and pnpm.executionEnv.nodeVersion manifest field (#10373) 2025-12-27 22:41:53 +01:00
Zoltan Kochan
491a84fb26 feat: use ESM instead of commonjs (#9870) 2025-08-25 10:02:00 +02:00
Zoltan Kochan
51bc234712 Merge branch 'main' into v11 2025-08-19 15:29:18 +02:00
Zoltan Kochan
facd7656e8 refactor: always use extensions in relative imports (#9878) 2025-08-19 15:25:11 +02:00
Zoltan Kochan
f2f3979e5a Merge branch 'main' into v11 2025-08-19 00:17:44 +02:00
Zoltan Kochan
c89c93d59b test: use @jest/globals (#9877) 2025-08-19 00:16:25 +02:00
Zoltan Kochan
3d65c12243 Merge branch 'main' into v11 2025-08-18 15:23:01 +02:00
Zoltan Kochan
14c78e81d4 test: use jest.mocked (#9874) 2025-08-18 15:22:37 +02:00
Zoltan Kochan
f176285cac test: update Jest to v30 (#9866) 2025-08-15 15:28:41 +02:00
Zoltan Kochan
1a07b8fc7c feat: install Node.js runtime as a dependency (#9755) 2025-07-19 15:11:40 +02:00
Zoltan Kochan
1ba2e15f2c feat: verify the integrity of Node.js artifacts (#9750) 2025-07-12 18:04:09 +02:00
btea
b61ade33d8 fix: compatible with more node pre-release versions (#9292)
* fix: compatible with more node pre-release versions

* fix: match prerelease regex

* docs: remove changeset

---------

Co-authored-by: Zoltan Kochan <z@kochan.io>
2025-03-17 01:53:24 +01:00
chlorine
6248d4064b fix: invalid Node.js version in use-node-version should not break (#9285)
close #9276
2025-03-16 11:32:30 +01:00
Ardeshir Izadi
ad4f9a1658 test(plugin-commands-env): unskip tests requiring mock tar files (#8674) 2024-10-21 03:01:03 +02:00
Ardeshir Izadi
d04f7f2320 fix: don't download node, when wanted node version is running (#8673)
close #8391

---------

Co-authored-by: Zoltan Kochan <z@kochan.io>
2024-10-21 02:53:47 +02:00
Khải
9b4f73caaf chore(scripts): typecheck-only (#8395)
* chore(scripts): typecheck-only

* feat: change all configuration

* feat: include pnpm/ and pnpm/test/

* chore(deps): remove unused dependency

* refactor(typescript-only): use find-packages

* refactor(typescript-only): refactor paths

* fix: typescript-only

* fix: update compile-only

* fix: compile pnpm

* fix: windows

* fix: windows

* chore: meta-updater

* refactor(tsconfig): remove explicit composite

* fix: path in windows

* feat: don't depend on cwd

---------

Co-authored-by: Zoltan Kochan <z@kochan.io>
2024-08-11 08:26:01 +02:00
Khải
0ef168b77d feat: per-package node version (#8277)
close #6720
2024-07-13 14:08:57 +02:00
Brandon Cheng
c7e1b6fae8 chore: configure TypeScript project references for tests (#8128)
* refactor: store link values before converting to references

* fix: use .sort() without localeCompare

https://github.com/pnpm/pnpm/pull/8128#discussion_r1614031566

> Nit, but you probably just want to call sort without a comparison
> function; these are already strings and locale compare is not a good
> comparison for anything but human readable strings since it will
> differ on different people's machines based on their language setting.
> I've hit this too many times before for code gen.

* feat: configure meta-updater to write test/tsconfig.json files

* fix: relative imports for __typings__

* chore: `pnpm run meta-updater`

* fix: explicitly use test/tsconfig.json for ts-jest
2024-05-31 12:48:13 +02:00
Hyunbin
4d2923858a fix(env): --global related error messages (#7456) 2023-12-26 12:59:34 +01:00
Hyunbin
b9c7fb91f3 fix(env): unify Node.js related expressions (#7356) 2023-12-03 18:34:39 +01:00
Eric Kwoka
2e6915727d feat(env): allow installing and removing multiple NodeJS versions at once (#7155)
---------

Co-authored-by: Zoltan Kochan <z@kochan.io>
2023-10-05 03:13:46 +03:00
Zoltan Kochan
4c959b7122 test: do not finish the workers after each test run 2023-08-25 18:13:41 +03:00
Zoltan Kochan
58cc58f14f fix: use the new tarball fetcher for fetching node.js (#6938)
ref #6850
2023-08-14 16:27:01 +03:00
Khải
66423df837 feat: clear error on invalid node version (#6916)
related to #6909
2023-08-10 01:38:06 +03:00
Zoltan Kochan
34724dd0f2 fix: env use should work on Windows (#6884)
close #6587
2023-07-31 11:39:50 +03:00
Zoltan Kochan
4b97f1f07a perf: don't use await inside loops (#6617) 2023-06-05 12:12:47 +03:00
GreyXor
36ffbfcd4b fix: typo standalone (#6244) 2023-03-19 21:02:40 +02:00
Zoltan Kochan
e570adc101 fix(env): fail with a meaningful error when no pnpm home dir is found (#6134)
close #6095
close #3865
2023-02-26 05:39:44 +02:00
Minoru Takeuchi
a49788f9f8 test(plugin-commands-env): fix a test that falling in arm64 (#5673) 2022-11-23 23:11:07 +02:00
Zoltan Kochan
4ca53b0b50 refactor: group projects in different subdirectories (#5659) 2022-11-20 01:35:22 +02:00