@pnpm/engine.runtime.commands 1000.0.0-0

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/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015-2016 Rico Sta. Cruz and other contributors
4
+ Copyright (c) 2016-2026 Zoltan Kochan and other contributors
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
@@ -0,0 +1,9 @@
1
+ import type { NvmNodeCommandOptions } from './node.js';
2
+ export declare const skipPackageManagerCheck = true;
3
+ export declare function rcOptionsTypes(): Record<string, unknown>;
4
+ export declare function cliOptionsTypes(): Record<string, unknown>;
5
+ export declare const commandNames: string[];
6
+ export declare function help(): string;
7
+ export declare function handler(opts: NvmNodeCommandOptions, params: string[]): Promise<string | {
8
+ exitCode: number;
9
+ } | void>;
package/lib/env/env.js ADDED
@@ -0,0 +1,87 @@
1
+ import { docsUrl } from '@pnpm/cli.utils';
2
+ import { PnpmError } from '@pnpm/error';
3
+ import { renderHelp } from 'render-help';
4
+ import { envList } from './envList.js';
5
+ import { envUse } from './envUse.js';
6
+ export const skipPackageManagerCheck = true;
7
+ export function rcOptionsTypes() {
8
+ return {};
9
+ }
10
+ export function cliOptionsTypes() {
11
+ return {
12
+ global: Boolean,
13
+ remote: Boolean,
14
+ };
15
+ }
16
+ export const commandNames = ['env'];
17
+ export function help() {
18
+ return renderHelp({
19
+ description: 'Manage Node.js versions.',
20
+ descriptionLists: [
21
+ {
22
+ title: 'Commands',
23
+ list: [
24
+ {
25
+ description: 'Installs the specified version of Node.js. The npm CLI bundled with the given Node.js version gets installed as well. This sets this version of Node.js as the current version.',
26
+ name: 'use',
27
+ },
28
+ {
29
+ description: 'List remote Node.js versions available to install.',
30
+ name: 'list',
31
+ shortAlias: 'ls',
32
+ },
33
+ ],
34
+ },
35
+ {
36
+ title: 'Options',
37
+ list: [
38
+ {
39
+ description: 'Manages Node.js versions globally',
40
+ name: '--global',
41
+ shortAlias: '-g',
42
+ },
43
+ ],
44
+ },
45
+ ],
46
+ url: docsUrl('env'),
47
+ usages: [
48
+ 'pnpm env use --global 18',
49
+ 'pnpm env use --global lts',
50
+ 'pnpm env use --global argon',
51
+ 'pnpm env use --global latest',
52
+ 'pnpm env use --global rc/18',
53
+ 'pnpm env list',
54
+ 'pnpm env list 18',
55
+ 'pnpm env list lts',
56
+ 'pnpm env list argon',
57
+ 'pnpm env list latest',
58
+ 'pnpm env list rc/18',
59
+ ],
60
+ });
61
+ }
62
+ export async function handler(opts, params) {
63
+ if (params.length === 0) {
64
+ throw new PnpmError('ENV_NO_SUBCOMMAND', 'Please specify the subcommand', {
65
+ hint: help(),
66
+ });
67
+ }
68
+ if (opts.global && !opts.bin) {
69
+ throw new PnpmError('CANNOT_MANAGE_NODE', 'Unable to manage Node.js because pnpm was not installed using the standalone installation script', {
70
+ hint: 'If you want to manage Node.js with pnpm, you need to remove any Node.js that was installed by other tools, then install pnpm using one of the standalone scripts that are provided on the installation page: https://pnpm.io/installation',
71
+ });
72
+ }
73
+ switch (params[0]) {
74
+ case 'use': {
75
+ await envUse(opts, params.slice(1));
76
+ return;
77
+ }
78
+ case 'list':
79
+ case 'ls': {
80
+ return envList(opts, params.slice(1));
81
+ }
82
+ default: {
83
+ throw new PnpmError('ENV_UNKNOWN_SUBCOMMAND', 'This subcommand is not known');
84
+ }
85
+ }
86
+ }
87
+ //# sourceMappingURL=env.js.map
@@ -0,0 +1,2 @@
1
+ import type { NvmNodeCommandOptions } from './node.js';
2
+ export declare function envList(opts: NvmNodeCommandOptions, params: string[]): Promise<string>;
@@ -0,0 +1,14 @@
1
+ import { getNodeMirror, parseNodeSpecifier, resolveNodeVersions } from '@pnpm/engine.runtime.node-resolver';
2
+ import { createFetchFromRegistry } from '@pnpm/network.fetch';
3
+ export async function envList(opts, params) {
4
+ const nodeVersionList = await listRemoteVersions(opts, params[0]);
5
+ // Make the newest version located at the end of the output
6
+ return nodeVersionList.reverse().join('\n');
7
+ }
8
+ async function listRemoteVersions(opts, versionSpec) {
9
+ const fetch = createFetchFromRegistry(opts);
10
+ const { releaseChannel, versionSpecifier } = versionSpec ? parseNodeSpecifier(versionSpec) : { releaseChannel: 'release', versionSpecifier: '' };
11
+ const nodeMirrorBaseUrl = getNodeMirror(opts.rawConfig, releaseChannel);
12
+ return resolveNodeVersions(fetch, versionSpecifier, nodeMirrorBaseUrl);
13
+ }
14
+ //# sourceMappingURL=envList.js.map
@@ -0,0 +1,2 @@
1
+ import type { NvmNodeCommandOptions } from './node.js';
2
+ export declare function envUse(opts: NvmNodeCommandOptions, params: string[]): Promise<void>;
@@ -0,0 +1,22 @@
1
+ import { PnpmError } from '@pnpm/error';
2
+ import { runPnpmCli } from '@pnpm/exec.pnpm-cli-runner';
3
+ import { globalWarn } from '@pnpm/logger';
4
+ export async function envUse(opts, params) {
5
+ globalWarn('"pnpm env use" is deprecated. Use "pnpm runtime set node <version> -g" instead.');
6
+ if (!opts.global) {
7
+ throw new PnpmError('NOT_IMPLEMENTED_YET', '"pnpm env use <version>" can only be used with the "--global" option currently');
8
+ }
9
+ const version = params[0]?.trim();
10
+ if (!version) {
11
+ throw new PnpmError('MISSING_NODE_VERSION', '"pnpm env use --global <version>" requires a Node.js version to be specified');
12
+ }
13
+ const args = ['add', '--global', `node@runtime:${version}`];
14
+ if (opts.bin)
15
+ args.push('--global-bin-dir', opts.bin);
16
+ if (opts.storeDir)
17
+ args.push('--store-dir', opts.storeDir);
18
+ if (opts.cacheDir)
19
+ args.push('--cache-dir', opts.cacheDir);
20
+ runPnpmCli(args, { cwd: opts.pnpmHomeDir });
21
+ }
22
+ //# sourceMappingURL=envUse.js.map
@@ -0,0 +1,2 @@
1
+ import * as env from './env.js';
2
+ export { env };
@@ -0,0 +1,3 @@
1
+ import * as env from './env.js';
2
+ export { env };
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,4 @@
1
+ import type { Config } from '@pnpm/config.reader';
2
+ export type NvmNodeCommandOptions = Pick<Config, 'bin' | 'global' | 'fetchRetries' | 'fetchRetryFactor' | 'fetchRetryMaxtimeout' | 'fetchRetryMintimeout' | 'fetchTimeout' | 'userAgent' | 'ca' | 'cert' | 'httpProxy' | 'httpsProxy' | 'key' | 'localAddress' | 'noProxy' | 'rawConfig' | 'strictSsl' | 'storeDir' | 'pnpmHomeDir'> & Partial<Pick<Config, 'cacheDir' | 'configDir' | 'cliOptions' | 'sslConfigs' | 'registries' | 'rawLocalConfig' | 'lockfileDir' | 'nodeLinker' | 'modulesDir' | 'symlink' | 'frozenLockfile' | 'preferFrozenLockfile' | 'sideEffectsCache' | 'sideEffectsCacheReadonly' | 'supportedArchitectures'>> & {
3
+ remote?: boolean;
4
+ };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=node.js.map
@@ -0,0 +1,2 @@
1
+ export declare function getNodeExecPathInBinDir(pnpmHomeDir: string): string;
2
+ export declare function getNodeExecPathInNodeDir(nodeDir: string): string;
@@ -0,0 +1,8 @@
1
+ import path from 'node:path';
2
+ export function getNodeExecPathInBinDir(pnpmHomeDir) {
3
+ return path.resolve(pnpmHomeDir, process.platform === 'win32' ? 'node.exe' : 'node');
4
+ }
5
+ export function getNodeExecPathInNodeDir(nodeDir) {
6
+ return path.join(nodeDir, process.platform === 'win32' ? 'node.exe' : 'bin/node');
7
+ }
8
+ //# sourceMappingURL=utils.js.map
package/lib/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export { env } from './env/index.js';
2
+ export { runtime } from './runtime/index.js';
package/lib/index.js ADDED
@@ -0,0 +1,3 @@
1
+ export { env } from './env/index.js';
2
+ export { runtime } from './runtime/index.js';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,2 @@
1
+ import * as runtime from './runtime.js';
2
+ export { runtime };
@@ -0,0 +1,3 @@
1
+ import * as runtime from './runtime.js';
2
+ export { runtime };
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,8 @@
1
+ import type { Config } from '@pnpm/config.reader';
2
+ export type RuntimeCommandOptions = Pick<Config, 'bin' | 'dir' | 'global' | 'pnpmHomeDir'> & Partial<Pick<Config, 'storeDir' | 'cacheDir'>>;
3
+ export declare const skipPackageManagerCheck = true;
4
+ export declare function rcOptionsTypes(): Record<string, unknown>;
5
+ export declare function cliOptionsTypes(): Record<string, unknown>;
6
+ export declare const commandNames: string[];
7
+ export declare function help(): string;
8
+ export declare function handler(opts: RuntimeCommandOptions, params: string[]): Promise<void>;
@@ -0,0 +1,85 @@
1
+ import { docsUrl } from '@pnpm/cli.utils';
2
+ import { PnpmError } from '@pnpm/error';
3
+ import { runPnpmCli } from '@pnpm/exec.pnpm-cli-runner';
4
+ import { renderHelp } from 'render-help';
5
+ export const skipPackageManagerCheck = true;
6
+ export function rcOptionsTypes() {
7
+ return {};
8
+ }
9
+ export function cliOptionsTypes() {
10
+ return {
11
+ global: Boolean,
12
+ };
13
+ }
14
+ export const commandNames = ['runtime', 'rt'];
15
+ export function help() {
16
+ return renderHelp({
17
+ description: 'Manage runtimes.',
18
+ descriptionLists: [
19
+ {
20
+ title: 'Commands',
21
+ list: [
22
+ {
23
+ description: 'Installs the specified version of a runtime (e.g. node, deno, bun).',
24
+ name: 'set',
25
+ },
26
+ ],
27
+ },
28
+ {
29
+ title: 'Options',
30
+ list: [
31
+ {
32
+ description: 'Installs the runtime globally',
33
+ name: '--global',
34
+ shortAlias: '-g',
35
+ },
36
+ ],
37
+ },
38
+ ],
39
+ url: docsUrl('runtime'),
40
+ usages: [
41
+ 'pnpm runtime set node 22 -g',
42
+ 'pnpm runtime set node lts -g',
43
+ 'pnpm runtime set node rc/22 -g',
44
+ 'pnpm runtime set deno 2 -g',
45
+ 'pnpm runtime set bun latest -g',
46
+ ],
47
+ });
48
+ }
49
+ export async function handler(opts, params) {
50
+ if (params.length === 0) {
51
+ throw new PnpmError('RUNTIME_NO_SUBCOMMAND', 'Please specify the subcommand', {
52
+ hint: help(),
53
+ });
54
+ }
55
+ switch (params[0]) {
56
+ case 'set': {
57
+ runtimeSet(opts, params.slice(1));
58
+ return;
59
+ }
60
+ default: {
61
+ throw new PnpmError('RUNTIME_UNKNOWN_SUBCOMMAND', `Unknown subcommand: ${params[0]}`, {
62
+ hint: help(),
63
+ });
64
+ }
65
+ }
66
+ }
67
+ function runtimeSet(opts, params) {
68
+ const runtimeName = params[0]?.trim();
69
+ if (!runtimeName) {
70
+ throw new PnpmError('MISSING_RUNTIME_NAME', '"pnpm runtime set <name> <version>" requires a runtime name (e.g. node, deno, bun)');
71
+ }
72
+ const versionSpec = params[1]?.trim();
73
+ const args = ['add', `${runtimeName}@runtime:${versionSpec ?? ''}`];
74
+ if (opts.global) {
75
+ args.push('--global');
76
+ if (opts.bin)
77
+ args.push('--global-bin-dir', opts.bin);
78
+ }
79
+ if (opts.storeDir)
80
+ args.push('--store-dir', opts.storeDir);
81
+ if (opts.cacheDir)
82
+ args.push('--cache-dir', opts.cacheDir);
83
+ runPnpmCli(args, { cwd: opts.global ? opts.pnpmHomeDir : opts.dir });
84
+ }
85
+ //# sourceMappingURL=runtime.js.map
package/package.json ADDED
@@ -0,0 +1,57 @@
1
+ {
2
+ "name": "@pnpm/engine.runtime.commands",
3
+ "version": "1000.0.0-0",
4
+ "description": "pnpm commands for managing runtimes",
5
+ "keywords": [
6
+ "pnpm",
7
+ "pnpm11",
8
+ "runtime"
9
+ ],
10
+ "license": "MIT",
11
+ "funding": "https://opencollective.com/pnpm",
12
+ "repository": "https://github.com/pnpm/pnpm/tree/main/engine/runtime/commands",
13
+ "homepage": "https://github.com/pnpm/pnpm/tree/main/engine/runtime/commands#readme",
14
+ "bugs": {
15
+ "url": "https://github.com/pnpm/pnpm/issues"
16
+ },
17
+ "type": "module",
18
+ "main": "lib/index.js",
19
+ "types": "lib/index.d.ts",
20
+ "exports": {
21
+ ".": "./lib/index.js"
22
+ },
23
+ "files": [
24
+ "lib",
25
+ "!*.map"
26
+ ],
27
+ "dependencies": {
28
+ "render-help": "^2.0.0",
29
+ "@pnpm/cli.utils": "1001.2.8",
30
+ "@pnpm/error": "1000.0.5",
31
+ "@pnpm/network.fetch": "1000.2.6",
32
+ "@pnpm/exec.pnpm-cli-runner": "1000.0.1",
33
+ "@pnpm/config.reader": "1004.4.2",
34
+ "@pnpm/engine.runtime.node-resolver": "1001.0.5"
35
+ },
36
+ "peerDependencies": {
37
+ "@pnpm/logger": ">=1001.0.0 <1002.0.0"
38
+ },
39
+ "devDependencies": {
40
+ "@jest/globals": "30.0.5",
41
+ "cross-env": "^10.1.0",
42
+ "@pnpm/engine.runtime.commands": "1000.0.0-0",
43
+ "@pnpm/logger": "1001.0.1"
44
+ },
45
+ "engines": {
46
+ "node": ">=22.13"
47
+ },
48
+ "jest": {
49
+ "preset": "@pnpm/jest-config"
50
+ },
51
+ "scripts": {
52
+ "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"",
53
+ "_test": "cross-env NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules --disable-warning=ExperimentalWarning --disable-warning=DEP0169\" jest",
54
+ "compile": "tsgo --build && pnpm run lint --fix",
55
+ "test": "pnpm run compile && pnpm run _test"
56
+ }
57
+ }