@pnpm/engine.pm.commands 1100.0.1 → 1101.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export { selfUpdate } from './self-updater/index.js';
2
- export { installPnpm, installPnpmToStore, linkExePlatformBinary } from './self-updater/installPnpm.js';
2
+ export { exePlatformPkgDirName, installPnpm, installPnpmToStore, linkExePlatformBinary } from './self-updater/installPnpm.js';
3
3
  export { setup } from './setup/index.js';
4
+ export { withCmd } from './with/index.js';
package/lib/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  export { selfUpdate } from './self-updater/index.js';
2
- export { installPnpm, installPnpmToStore, linkExePlatformBinary } from './self-updater/installPnpm.js';
2
+ export { exePlatformPkgDirName, installPnpm, installPnpmToStore, linkExePlatformBinary } from './self-updater/installPnpm.js';
3
3
  export { setup } from './setup/index.js';
4
+ export { withCmd } from './with/index.js';
4
5
  //# sourceMappingURL=index.js.map
@@ -39,4 +39,11 @@ export declare function installPnpmToStore(pnpmVersion: string, opts: {
39
39
  }): Promise<{
40
40
  binDir: string;
41
41
  }>;
42
+ /**
43
+ * Computes the scope-local directory name of the `@pnpm/exe` platform
44
+ * package for a given host: `exe.<platform>-<arch>[-musl]`. Pure so that the
45
+ * musl branch is unit-testable without mocking detect-libc or patching
46
+ * process.platform.
47
+ */
48
+ export declare function exePlatformPkgDirName(platform: NodeJS.Platform, arch: string, libcFamily: string | null): string;
42
49
  export declare function linkExePlatformBinary(installDir: string): void;
@@ -9,6 +9,7 @@ import { installGlobalPackages } from '@pnpm/global.commands';
9
9
  import { cleanOrphanedInstallDirs, createGlobalCacheKey, createInstallDir, findGlobalPackage, getHashLink, } from '@pnpm/global.packages';
10
10
  import { headlessInstall } from '@pnpm/installing.deps-restorer';
11
11
  import { registerProject } from '@pnpm/store.controller';
12
+ import { familySync } from 'detect-libc';
12
13
  import { symlinkDir } from 'symlink-dir';
13
14
  // @pnpm/exe has platform-specific binaries, so its GVS hash must
14
15
  // include ENGINE_NAME for correct per-platform resolution.
@@ -227,17 +228,25 @@ async function installFromResolution(installDir, opts, params) {
227
228
  allowBuilds: {},
228
229
  }, params);
229
230
  }
230
- // @pnpm/exe bundles Node.js via optional platform-specific packages (e.g. @pnpm/macos-arm64).
231
+ /**
232
+ * Computes the scope-local directory name of the `@pnpm/exe` platform
233
+ * package for a given host: `exe.<platform>-<arch>[-musl]`. Pure so that the
234
+ * musl branch is unit-testable without mocking detect-libc or patching
235
+ * process.platform.
236
+ */
237
+ export function exePlatformPkgDirName(platform, arch, libcFamily) {
238
+ const normalizedArch = platform === 'win32' && arch === 'ia32' ? 'x86' : arch;
239
+ const libcSuffix = platform === 'linux' && libcFamily === 'musl' ? '-musl' : '';
240
+ return `exe.${platform}-${normalizedArch}${libcSuffix}`;
241
+ }
242
+ // @pnpm/exe bundles Node.js via optional platform-specific packages
243
+ // (e.g. @pnpm/exe.darwin-arm64, @pnpm/exe.linux-x64-musl).
231
244
  // Its postinstall script links the correct binary into the @pnpm/exe package dir.
232
245
  // Since scripts are disabled during install (to support systems without Node.js),
233
246
  // we replicate that linking here.
234
247
  export function linkExePlatformBinary(installDir) {
235
- const platform = process.platform === 'win32'
236
- ? 'win'
237
- : process.platform === 'darwin'
238
- ? 'macos'
239
- : process.platform;
240
- const arch = platform === 'win' && process.arch === 'ia32' ? 'x86' : process.arch;
248
+ const platform = process.platform;
249
+ const pkgDirName = exePlatformPkgDirName(platform, process.arch, familySync());
241
250
  const exePkgDir = path.join(installDir, 'node_modules', '@pnpm', 'exe');
242
251
  if (!fs.existsSync(exePkgDir))
243
252
  return;
@@ -245,14 +254,14 @@ export function linkExePlatformBinary(installDir) {
245
254
  // to the top-level node_modules. It's a dependency of @pnpm/exe and lives as a
246
255
  // sibling in the virtual store. Resolve through the @pnpm/exe symlink to find it.
247
256
  const exeRealDir = fs.realpathSync(exePkgDir);
248
- const platformPkgDir = path.join(path.dirname(exeRealDir), `${platform}-${arch}`);
249
- const executable = platform === 'win' ? 'pnpm.exe' : 'pnpm';
257
+ const platformPkgDir = path.join(path.dirname(exeRealDir), pkgDirName);
258
+ const executable = platform === 'win32' ? 'pnpm.exe' : 'pnpm';
250
259
  const src = path.join(platformPkgDir, executable);
251
260
  if (!fs.existsSync(src))
252
261
  return;
253
262
  const dest = path.join(exePkgDir, executable);
254
263
  forceLink(src, dest);
255
- if (platform === 'win') {
264
+ if (platform === 'win32') {
256
265
  const exePkgJsonPath = path.join(exePkgDir, 'package.json');
257
266
  const exePkg = JSON.parse(fs.readFileSync(exePkgJsonPath, 'utf8'));
258
267
  exePkg.bin.pnpm = 'pnpm.exe';
@@ -5,5 +5,5 @@ export declare function cliOptionsTypes(): Record<string, unknown>;
5
5
  export declare const commandNames: string[];
6
6
  export declare const skipPackageManagerCheck = true;
7
7
  export declare function help(): string;
8
- export type SelfUpdateCommandOptions = CreateStoreControllerOptions & Pick<Config, 'globalPkgDir' | 'lockfileDir' | 'managePackageManagerVersions' | 'modulesDir' | 'pnpmHomeDir'> & Pick<ConfigContext, 'rootProjectManifestDir' | 'wantedPackageManager'>;
8
+ export type SelfUpdateCommandOptions = CreateStoreControllerOptions & Pick<Config, 'globalPkgDir' | 'lockfileDir' | 'modulesDir' | 'pnpmHomeDir'> & Pick<ConfigContext, 'rootProjectManifestDir' | 'wantedPackageManager'>;
9
9
  export declare function handler(opts: SelfUpdateCommandOptions, params: string[]): Promise<undefined | string>;
@@ -0,0 +1,2 @@
1
+ import * as withCmd from './with.js';
2
+ export { withCmd };
@@ -0,0 +1,3 @@
1
+ import * as withCmd from './with.js';
2
+ export { withCmd };
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,11 @@
1
+ import { type Config, type ConfigContext } from '@pnpm/config.reader';
2
+ import { type CreateStoreControllerOptions } from '@pnpm/store.connection-manager';
3
+ export declare const commandNames: string[];
4
+ export declare const skipPackageManagerCheck = true;
5
+ export declare const rcOptionsTypes: typeof cliOptionsTypes;
6
+ export declare function cliOptionsTypes(): Record<string, unknown>;
7
+ export declare function help(): string;
8
+ export type WithCommandOptions = CreateStoreControllerOptions & Pick<Config, 'dir' | 'lockfileDir' | 'pnpmHomeDir' | 'virtualStoreDirMaxLength'> & Pick<ConfigContext, 'rootProjectManifestDir'>;
9
+ export declare function handler(opts: WithCommandOptions, params: string[]): Promise<{
10
+ exitCode: number;
11
+ }>;
@@ -0,0 +1,101 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ import { isExecutedByCorepack, packageManager } from '@pnpm/cli.meta';
4
+ import { docsUrl } from '@pnpm/cli.utils';
5
+ import { types as allTypes } from '@pnpm/config.reader';
6
+ import { PnpmError } from '@pnpm/error';
7
+ import { resolvePackageManagerIntegrities } from '@pnpm/installing.env-installer';
8
+ import { prependDirsToPath } from '@pnpm/shell.path';
9
+ import { createStoreController } from '@pnpm/store.connection-manager';
10
+ import crossSpawn from 'cross-spawn';
11
+ import { pick } from 'ramda';
12
+ import { renderHelp } from 'render-help';
13
+ import { installPnpmToStore } from '../self-updater/installPnpm.js';
14
+ export const commandNames = ['with'];
15
+ export const skipPackageManagerCheck = true;
16
+ export const rcOptionsTypes = cliOptionsTypes;
17
+ export function cliOptionsTypes() {
18
+ return pick([], allTypes);
19
+ }
20
+ export function help() {
21
+ return renderHelp({
22
+ description: 'Run pnpm with a specific version (or the currently running one), ignoring the "packageManager" and "devEngines.packageManager" fields of the project manifest.',
23
+ descriptionLists: [],
24
+ url: docsUrl('with'),
25
+ usages: [
26
+ 'pnpm with current <pnpm args>',
27
+ 'pnpm with <version> <pnpm args>',
28
+ 'pnpm with next install',
29
+ 'pnpm with 10 install',
30
+ ],
31
+ });
32
+ }
33
+ export async function handler(opts, params) {
34
+ if (params.length === 0) {
35
+ throw new PnpmError('MISSING_WITH_SPEC', 'Missing version argument. Usage: pnpm with <version|current> <args...>');
36
+ }
37
+ if (isExecutedByCorepack()) {
38
+ throw new PnpmError('CANT_USE_WITH_IN_COREPACK', 'The "pnpm with" command does not work under corepack');
39
+ }
40
+ // `with current` is handled earlier in parseCliArgs.ts, which re-parses it
41
+ // for in-process execution, so this handler only ever sees version/dist-tag specs.
42
+ const [spec, ...args] = params;
43
+ fs.mkdirSync(opts.pnpmHomeDir, { recursive: true });
44
+ const store = await createStoreController(opts);
45
+ let binDir;
46
+ try {
47
+ // resolvePackageManagerIntegrities resolves ranges/dist-tags via the
48
+ // registry and writes the resolved exact version to the envLockfile.
49
+ const envLockfile = await resolvePackageManagerIntegrities(spec, {
50
+ rootDir: opts.pnpmHomeDir,
51
+ registries: opts.registries,
52
+ storeController: store.ctrl,
53
+ storeDir: store.dir,
54
+ });
55
+ const resolvedVersion = envLockfile.importers['.'].packageManagerDependencies?.['pnpm']?.version;
56
+ if (!resolvedVersion) {
57
+ throw new PnpmError('CANNOT_RESOLVE_PNPM', `Cannot resolve pnpm version for "${spec}"`);
58
+ }
59
+ ;
60
+ ({ binDir } = await installPnpmToStore(resolvedVersion, {
61
+ envLockfile,
62
+ storeController: store.ctrl,
63
+ storeDir: store.dir,
64
+ registries: opts.registries,
65
+ virtualStoreDirMaxLength: opts.virtualStoreDirMaxLength,
66
+ packageManager: { name: packageManager.name, version: packageManager.version },
67
+ }));
68
+ }
69
+ finally {
70
+ await store.ctrl.close();
71
+ }
72
+ // The child pnpm must skip the packageManager/devEngines check so the requested
73
+ // version stays active. Two keys are set for backward compatibility:
74
+ // - `COREPACK_ROOT` is honored by every pnpm release that supports corepack
75
+ // (older versions skip the pm check whenever this is set).
76
+ // - `pnpm_config_pm_on_fail=ignore` is the principled override recognized
77
+ // by pnpm releases that ship the `pmOnFail` setting.
78
+ const pnpmEnv = prependDirsToPath([binDir]);
79
+ const spawnEnv = {
80
+ ...process.env,
81
+ [pnpmEnv.name]: pnpmEnv.value,
82
+ COREPACK_ROOT: process.env.COREPACK_ROOT ?? 'pnpm-with',
83
+ pnpm_config_pm_on_fail: 'ignore',
84
+ };
85
+ const pnpmBinPath = path.join(binDir, 'pnpm');
86
+ const { status, signal, error } = crossSpawn.sync(pnpmBinPath, args, {
87
+ stdio: 'inherit',
88
+ env: spawnEnv,
89
+ });
90
+ if (error)
91
+ throw error;
92
+ if (signal) {
93
+ // Best-effort: try to terminate with the same signal the child received.
94
+ // If the signal is handled or ignored, fall back to a non-zero exit code
95
+ // so the caller doesn't mistake an interrupted run for a successful one.
96
+ process.kill(process.pid, signal);
97
+ return { exitCode: 1 };
98
+ }
99
+ return { exitCode: status ?? 0 };
100
+ }
101
+ //# sourceMappingURL=with.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pnpm/engine.pm.commands",
3
- "version": "1100.0.1",
3
+ "version": "1101.0.1",
4
4
  "description": "pnpm commands for self-updating and setting up pnpm",
5
5
  "keywords": [
6
6
  "pnpm",
@@ -25,29 +25,32 @@
25
25
  ],
26
26
  "dependencies": {
27
27
  "@pnpm/os.env.path-extender": "^3.0.0",
28
+ "cross-spawn": "^7.0.6",
29
+ "detect-libc": "^2.0.3",
28
30
  "path-name": "^1.0.0",
29
31
  "ramda": "npm:@pnpm/ramda@0.28.1",
30
32
  "render-help": "^2.0.0",
31
33
  "semver": "^7.7.2",
32
34
  "symlink-dir": "^10.0.1",
33
- "@pnpm/bins.linker": "1100.0.1",
34
35
  "@pnpm/building.policy": "1100.0.1",
35
- "@pnpm/config.reader": "1100.0.1",
36
+ "@pnpm/cli.utils": "1101.0.0",
37
+ "@pnpm/bins.linker": "1100.0.2",
36
38
  "@pnpm/cli.meta": "1100.0.1",
37
- "@pnpm/cli.utils": "1100.0.1",
38
39
  "@pnpm/error": "1100.0.0",
39
- "@pnpm/deps.graph-hasher": "1100.0.1",
40
- "@pnpm/global.commands": "1100.0.1",
40
+ "@pnpm/deps.graph-hasher": "1100.1.0",
41
+ "@pnpm/global.commands": "1100.0.3",
41
42
  "@pnpm/global.packages": "1100.0.1",
42
- "@pnpm/installing.client": "1100.0.1",
43
- "@pnpm/installing.env-installer": "1100.0.1",
44
- "@pnpm/installing.deps-restorer": "1100.0.1",
45
- "@pnpm/lockfile.types": "1100.0.1",
46
- "@pnpm/store.connection-manager": "1100.0.1",
47
- "@pnpm/resolving.npm-resolver": "1100.0.1",
43
+ "@pnpm/config.reader": "1101.1.0",
44
+ "@pnpm/installing.client": "1100.0.3",
45
+ "@pnpm/installing.deps-restorer": "1100.0.3",
46
+ "@pnpm/lockfile.types": "1100.0.2",
47
+ "@pnpm/installing.env-installer": "1100.1.1",
48
+ "@pnpm/shell.path": "1100.0.0",
48
49
  "@pnpm/types": "1101.0.0",
49
- "@pnpm/store.controller": "1100.0.1",
50
- "@pnpm/workspace.project-manifest-reader": "1100.0.1"
50
+ "@pnpm/resolving.npm-resolver": "1100.1.0",
51
+ "@pnpm/workspace.project-manifest-reader": "1100.0.2",
52
+ "@pnpm/store.controller": "1100.0.2",
53
+ "@pnpm/store.connection-manager": "1100.0.3"
51
54
  },
52
55
  "peerDependencies": {
53
56
  "@pnpm/logger": ">=1001.0.0 <1002.0.0"
@@ -57,14 +60,12 @@
57
60
  "@types/cross-spawn": "^6.0.6",
58
61
  "@types/ramda": "0.31.1",
59
62
  "@types/semver": "7.7.1",
60
- "cross-spawn": "^7.0.6",
61
- "@pnpm/constants": "1100.0.0",
62
- "@pnpm/error": "1100.0.0",
63
63
  "@pnpm/logger": "1100.0.0",
64
- "@pnpm/prepare": "1100.0.1",
65
- "@pnpm/engine.pm.commands": "1100.0.1",
66
- "@pnpm/shell.path": "1100.0.0",
67
- "@pnpm/testing.mock-agent": "1100.0.1"
64
+ "@pnpm/error": "1100.0.0",
65
+ "@pnpm/constants": "1100.0.0",
66
+ "@pnpm/prepare": "1100.0.2",
67
+ "@pnpm/testing.mock-agent": "1100.0.1",
68
+ "@pnpm/engine.pm.commands": "1101.0.1"
68
69
  },
69
70
  "engines": {
70
71
  "node": ">=22.13"