diff --git a/.changeset/small-numbers-joke.md b/.changeset/small-numbers-joke.md new file mode 100644 index 0000000000..3730a05577 --- /dev/null +++ b/.changeset/small-numbers-joke.md @@ -0,0 +1,16 @@ +--- +"@pnpm/plugin-commands-installation": major +"@pnpm/plugin-commands-publishing": major +"@pnpm/plugin-commands-script-runners": major +"@pnpm/plugin-commands-deploy": major +"@pnpm/plugin-commands-env": major +"@pnpm/workspace.find-packages": major +"@pnpm/constants": major +"@pnpm/core": major +"@pnpm/lifecycle": major +"@pnpm/types": major +"@pnpm/config": major +"pnpm": major +--- + +Removed support for the `useNodeVersion` and `executionEnv.nodeVersion` fields. `devEngines.runtime` and `engines.runtime` should be used instead [#10373](https://github.com/pnpm/pnpm/pull/10373). diff --git a/config/config/src/Config.ts b/config/config/src/Config.ts index c385f00789..8fb7a7e6ec 100644 --- a/config/config/src/Config.ts +++ b/config/config/src/Config.ts @@ -98,7 +98,6 @@ export interface Config extends OptionsFromRootManifest { ignoreCurrentSpecifiers?: boolean recursive?: boolean enablePrePostScripts?: boolean - useNodeVersion?: string useStderr?: boolean nodeLinker?: 'hoisted' | 'isolated' | 'pnp' preferSymlinkedExecutables?: boolean diff --git a/config/config/src/getOptionsFromRootManifest.ts b/config/config/src/getOptionsFromRootManifest.ts index 19dc597a86..08a34a6bee 100644 --- a/config/config/src/getOptionsFromRootManifest.ts +++ b/config/config/src/getOptionsFromRootManifest.ts @@ -27,7 +27,7 @@ export type OptionsFromRootManifest = { peerDependencyRules?: PeerDependencyRules supportedArchitectures?: SupportedArchitectures allowBuilds?: Record -} & Pick +} & Pick export function getOptionsFromRootManifest (manifestDir: string, manifest: ProjectManifest): OptionsFromRootManifest { const settings: OptionsFromRootManifest = getOptionsFromPnpmSettings(manifestDir, { @@ -40,8 +40,6 @@ export function getOptionsFromRootManifest (manifestDir: string, manifest: Proje 'auditConfig', 'auditConfig', 'configDependencies', - 'executionEnv', - 'executionEnv', 'ignorePatchFailures', 'ignoredBuiltDependencies', 'ignoredOptionalDependencies', diff --git a/config/config/test/index.ts b/config/config/test/index.ts index 581cf776c8..65f7a33262 100644 --- a/config/config/test/index.ts +++ b/config/config/test/index.ts @@ -1332,7 +1332,6 @@ test('loads setting from environment variable pnpm_config_*', async () => { }) expect(config.fetchRetries).toBe(100) expect(config.hoistPattern).toStrictEqual(['react', 'react-dom']) - expect(config.useNodeVersion).toBe('22.0.0') expect(config.onlyBuiltDependencies).toStrictEqual(['is-number', 'is-positive', 'is-negative']) expect(config.registry).toBe('https://registry.example.com/') expect(config.registries.default).toBe('https://registry.example.com/') @@ -1342,10 +1341,10 @@ test('environment variable pnpm_config_* should override pnpm-workspace.yaml', a prepareEmpty() writeYamlFile('pnpm-workspace.yaml', { - useNodeVersion: '20.0.0', + fetchRetries: 5, }) - async function getConfigValue (env: NodeJS.ProcessEnv): Promise { + async function getConfigValue (env: NodeJS.ProcessEnv): Promise { const { config } = await getConfig({ cliOptions: {}, env, @@ -1355,23 +1354,23 @@ test('environment variable pnpm_config_* should override pnpm-workspace.yaml', a }, workspaceDir: process.cwd(), }) - return config.useNodeVersion + return config.fetchRetries } - expect(await getConfigValue({})).toBe('20.0.0') + expect(await getConfigValue({})).toBe(5) expect(await getConfigValue({ - pnpm_config_use_node_version: '22.0.0', - })).toBe('22.0.0') + pnpm_config_fetch_retries: '10', + })).toBe(10) }) test('CLI should override environment variable pnpm_config_*', async () => { prepareEmpty() - async function getConfigValue (cliOptions: Record): Promise { + async function getConfigValue (cliOptions: Record): Promise { const { config } = await getConfig({ cliOptions, env: { - pnpm_config_use_node_version: '18.0.0', + pnpm_config_fetch_retries: '5', }, packageManager: { name: 'pnpm', @@ -1379,16 +1378,16 @@ test('CLI should override environment variable pnpm_config_*', async () => { }, workspaceDir: process.cwd(), }) - return config.useNodeVersion + return config.fetchRetries } - expect(await getConfigValue({})).toBe('18.0.0') + expect(await getConfigValue({})).toBe(5) expect(await getConfigValue({ - useNodeVersion: '22.0.0', - })).toBe('22.0.0') + fetchRetries: 10, + })).toBe(10) expect(await getConfigValue({ - 'use-node-version': '22.0.0', - })).toBe('22.0.0') + 'fetch-retries': 10, + })).toBe(10) }) describe('global config.yaml', () => { diff --git a/env/plugin-commands-env/src/index.ts b/env/plugin-commands-env/src/index.ts index 15f766b4ea..807a718d11 100644 --- a/env/plugin-commands-env/src/index.ts +++ b/env/plugin-commands-env/src/index.ts @@ -1,4 +1,3 @@ import * as env from './env.js' -import { prepareExecutionEnv } from './node.js' -export { env, prepareExecutionEnv } +export { env } diff --git a/env/plugin-commands-env/src/node.ts b/env/plugin-commands-env/src/node.ts index 6dcf321d08..2c77697861 100644 --- a/env/plugin-commands-env/src/node.ts +++ b/env/plugin-commands-env/src/node.ts @@ -2,13 +2,11 @@ import fs from 'fs' import path from 'path' import util from 'util' import { type Config } from '@pnpm/config' -import { getSystemNodeVersion } from '@pnpm/env.system-node-version' import { createFetchFromRegistry, type FetchFromRegistry } from '@pnpm/fetch' import { globalInfo, globalWarn } from '@pnpm/logger' import { fetchNode } from '@pnpm/node.fetcher' import { getNodeMirror } from '@pnpm/node.resolver' import { getStorePath } from '@pnpm/store-path' -import { type PrepareExecutionEnvOptions, type PrepareExecutionEnvResult } from '@pnpm/types' import { loadJsonFile } from 'load-json-file' import { writeJsonFile } from 'write-json-file' import { isValidVersion, parseNodeSpecifier } from './parseNodeSpecifier.js' @@ -32,31 +30,10 @@ export type NvmNodeCommandOptions = Pick & Partial> & { remote?: boolean -} - -const nodeFetchPromises: Record> = {} - -export async function prepareExecutionEnv (config: NvmNodeCommandOptions, { extraBinPaths, executionEnv }: PrepareExecutionEnvOptions): Promise { - if (!executionEnv?.nodeVersion || `v${executionEnv.nodeVersion}` === getSystemNodeVersion()) { - return { extraBinPaths: extraBinPaths ?? [] } - } - - let nodePathPromise = nodeFetchPromises[executionEnv.nodeVersion] - if (!nodePathPromise) { - nodePathPromise = getNodeBinDir({ - ...config, - useNodeVersion: executionEnv.nodeVersion, - }) - nodeFetchPromises[executionEnv.nodeVersion] = nodePathPromise - } - - return { - extraBinPaths: [await nodePathPromise, ...extraBinPaths ?? []], - } + useNodeVersion?: string } export async function getNodeBinDir (opts: NvmNodeCommandOptions): Promise { diff --git a/env/plugin-commands-env/test/node.test.ts b/env/plugin-commands-env/test/node.test.ts index dbbd272a80..efdc102ea6 100644 --- a/env/plugin-commands-env/test/node.test.ts +++ b/env/plugin-commands-env/test/node.test.ts @@ -60,7 +60,6 @@ const { getNodeDir, getNodeBinDir, getNodeVersionsBaseDir, - prepareExecutionEnv, } = await import('../lib/node.js') beforeEach(() => { @@ -145,19 +144,3 @@ test('specified an invalid Node.js via use-node-version should not cause pnpm it const calls = jest.mocked(globalWarn).mock.calls expect(calls[calls.length - 1][0]).toContain('"22.14" is not a valid Node.js version.') }) - -describe('prepareExecutionEnv', () => { - test('should not proceed to fetch Node.js if the process is already running in wanted node version', async () => { - fetchMock.mockImplementationOnce(() => { - throw new Error('prepareExecutionEnv should not proceed to fetch Node.js when wanted version is running') - }) - - await prepareExecutionEnv({ - bin: '', - pnpmHomeDir: process.cwd(), - rawConfig: {}, - }, { - executionEnv: { nodeVersion: process.versions.node }, - }) - }) -}) diff --git a/exec/lifecycle/src/runLifecycleHook.ts b/exec/lifecycle/src/runLifecycleHook.ts index f925cfdea0..a14f697607 100644 --- a/exec/lifecycle/src/runLifecycleHook.ts +++ b/exec/lifecycle/src/runLifecycleHook.ts @@ -2,7 +2,7 @@ import path from 'path' import { lifecycleLogger } from '@pnpm/core-loggers' import { globalWarn } from '@pnpm/logger' import lifecycle from '@pnpm/npm-lifecycle' -import { type DependencyManifest, type ProjectManifest, type PrepareExecutionEnv, type PackageScripts } from '@pnpm/types' +import { type DependencyManifest, type ProjectManifest, type PackageScripts } from '@pnpm/types' import { PnpmError } from '@pnpm/error' import { existsSync } from 'fs' import isWindows from 'is-windows' @@ -26,7 +26,6 @@ export interface RunLifecycleHookOptions { shellEmulator?: boolean stdio?: string unsafePerm: boolean - prepareExecutionEnv?: PrepareExecutionEnv } export async function runLifecycleHook ( @@ -109,17 +108,13 @@ Please unset the scriptShell option, or configure it to a .exe instead. const logLevel = (opts.stdio !== 'inherit' || opts.silent) ? 'silent' : undefined - const extraBinPaths = (await opts.prepareExecutionEnv?.({ - extraBinPaths: opts.extraBinPaths, - executionEnv: (manifest as ProjectManifest).pnpm?.executionEnv, - }))?.extraBinPaths ?? opts.extraBinPaths await lifecycle(m, stage, opts.pkgRoot, { config: { ...opts.rawConfig, 'frozen-lockfile': false, }, dir: opts.rootModulesDir, - extraBinPaths, + extraBinPaths: opts.extraBinPaths, extraEnv: { ...opts.extraEnv, INIT_CWD: opts.initCwd ?? process.cwd(), diff --git a/exec/plugin-commands-script-runners/src/dlx.ts b/exec/plugin-commands-script-runners/src/dlx.ts index adc055b874..698d9a4c10 100644 --- a/exec/plugin-commands-script-runners/src/dlx.ts +++ b/exec/plugin-commands-script-runners/src/dlx.ts @@ -33,7 +33,6 @@ export function rcOptionsTypes (): Record { 'cpu', 'libc', 'os', - 'use-node-version', ], types), 'shell-mode': Boolean, } @@ -78,7 +77,7 @@ export type DlxCommandOptions = { package?: string[] shellMode?: boolean allowBuild?: string[] -} & Pick & Omit & PnpmSettings +} & Pick & Omit & PnpmSettings export async function handler ( opts: DlxCommandOptions, diff --git a/exec/plugin-commands-script-runners/src/exec.ts b/exec/plugin-commands-script-runners/src/exec.ts index 890adf5578..20df4608ca 100644 --- a/exec/plugin-commands-script-runners/src/exec.ts +++ b/exec/plugin-commands-script-runners/src/exec.ts @@ -7,7 +7,6 @@ import { type CheckDepsStatusOptions } from '@pnpm/deps.status' import { makeNodeRequireOption } from '@pnpm/lifecycle' import { logger } from '@pnpm/logger' import { tryReadProjectManifest } from '@pnpm/read-project-manifest' -import { prepareExecutionEnv } from '@pnpm/plugin-commands-env' import { sortPackages } from '@pnpm/sort-packages' import { type Project, type ProjectsGraph, type ProjectRootDir, type ProjectRootDirRealPath } from '@pnpm/types' import execa from 'execa' @@ -41,7 +40,6 @@ export function rcOptionsTypes (): Record { ...pick([ 'bail', 'sort', - 'use-node-version', 'unsafe-perm', 'workspace-concurrency', 'reporter-hide-prefix', @@ -222,23 +220,15 @@ export async function handler ( const workspacePnpPath = opts.workspaceDir && existsPnp(opts.workspaceDir) let exitCode = 0 - const mapPrefixToPrependPaths: Record = {} - await Promise.all(chunks.flat().map(async prefix => { - const executionEnv = await prepareExecutionEnv(opts, { - extraBinPaths: opts.extraBinPaths, - executionEnv: opts.selectedProjectsGraph[prefix]?.package.manifest.pnpm?.executionEnv, - }) - mapPrefixToPrependPaths[prefix] = [ - './node_modules/.bin', - ...executionEnv.extraBinPaths, - ] - })) + const prependPaths = [ + './node_modules/.bin', + ...(opts.extraBinPaths ?? []), + ] const reporterShowPrefix = opts.recursive && opts.reporterHidePrefix === false for (const chunk of chunks) { // eslint-disable-next-line no-await-in-loop await Promise.all(chunk.map(async (prefix) => limitRun(async () => { - const prependPaths = mapPrefixToPrependPaths[prefix] result[prefix].status = 'running' const startTime = process.hrtime() try { diff --git a/exec/plugin-commands-script-runners/src/run.ts b/exec/plugin-commands-script-runners/src/run.ts index 603a8156e0..5838254437 100644 --- a/exec/plugin-commands-script-runners/src/run.ts +++ b/exec/plugin-commands-script-runners/src/run.ts @@ -6,7 +6,6 @@ import { tryReadProjectManifest, } from '@pnpm/cli-utils' import { type CompletionFunc } from '@pnpm/command' -import { prepareExecutionEnv } from '@pnpm/plugin-commands-env' import { FILTERING, UNIVERSAL_OPTIONS } from '@pnpm/common-cli-options-help' import { type Config, types as allTypes, getWorkspaceConcurrency } from '@pnpm/config' import { PnpmError } from '@pnpm/error' @@ -86,7 +85,6 @@ export function rcOptionsTypes (): Record { return { ...pick([ 'npm-path', - 'use-node-version', ], allTypes), } } @@ -97,7 +95,6 @@ export function cliOptionsTypes (): Record { 'bail', 'sort', 'unsafe-perm', - 'use-node-version', 'workspace-concurrency', 'scripts-prepend-node-path', ], allTypes), @@ -165,7 +162,6 @@ export type RunOpts = | 'dir' | 'enablePrePostScripts' | 'engineStrict' - | 'executionEnv' | 'extraBinPaths' | 'extraEnv' | 'nodeOptions' @@ -280,9 +276,6 @@ so you may run "pnpm -w run ${scriptName}"`, stdio: (specifiedScripts.length > 1 && concurrency > 1) ? 'pipe' : 'inherit', unsafePerm: true, // when running scripts explicitly, assume that they're trusted. } - if (opts.executionEnv != null) { - lifecycleOpts.extraBinPaths = (await prepareExecutionEnv(opts, { executionEnv: opts.executionEnv })).extraBinPaths - } const existsPnp = existsInDir.bind(null, '.pnp.cjs') const pnpPath = (opts.workspaceDir && existsPnp(opts.workspaceDir)) ?? existsPnp(dir) if (pnpPath) { diff --git a/exec/plugin-commands-script-runners/src/runRecursive.ts b/exec/plugin-commands-script-runners/src/runRecursive.ts index 1cc824b740..9fdc043899 100644 --- a/exec/plugin-commands-script-runners/src/runRecursive.ts +++ b/exec/plugin-commands-script-runners/src/runRecursive.ts @@ -3,7 +3,6 @@ import path from 'path' import util from 'util' import { throwOnCommandFail } from '@pnpm/cli-utils' import { type Config, getWorkspaceConcurrency } from '@pnpm/config' -import { prepareExecutionEnv } from '@pnpm/plugin-commands-env' import { PnpmError } from '@pnpm/error' import { makeNodeRequireOption, @@ -127,10 +126,6 @@ export async function runRecursive ( stdio, unsafePerm: true, // when running scripts explicitly, assume that they're trusted. } - const { executionEnv } = pkg.package.manifest.pnpm ?? {} - if (executionEnv != null) { - lifecycleOpts.extraBinPaths = (await prepareExecutionEnv(opts, { executionEnv })).extraBinPaths - } const pnpPath = workspacePnpPath ?? existsPnp(prefix) if (pnpPath) { lifecycleOpts.extraEnv = { diff --git a/exec/plugin-commands-script-runners/test/index.ts b/exec/plugin-commands-script-runners/test/index.ts index 8232029bbe..1413d33246 100644 --- a/exec/plugin-commands-script-runners/test/index.ts +++ b/exec/plugin-commands-script-runners/test/index.ts @@ -756,25 +756,3 @@ test('pnpm run without node version', async () => { workspaceConcurrency: 1, }, ['assert-node-version']) }) - -test('pnpm run with node version', async () => { - prepare({ - scripts: { - 'assert-node-version': 'node -e "assert.equal(process.version, \'v20.0.0\')"', - }, - }) - - await run.handler({ - ...DEFAULT_OPTS, - bin: 'node_modules/.bin', - dir: process.cwd(), - extraBinPaths: [], - extraEnv: {}, - pnpmHomeDir: process.cwd(), - rawConfig: {}, - workspaceConcurrency: 1, - executionEnv: { - nodeVersion: '20.0.0', - }, - }, ['assert-node-version']) -}) diff --git a/packages/constants/src/index.ts b/packages/constants/src/index.ts index 6c15205add..14deae85d0 100644 --- a/packages/constants/src/index.ts +++ b/packages/constants/src/index.ts @@ -18,8 +18,6 @@ export const ABBREVIATED_META_DIR = 'metadata-v1.3' export const FULL_META_DIR = 'metadata-full-v1.3' // This is currently not used at all export const FULL_FILTERED_META_DIR = 'metadata-ff-v1.3' -export const USEFUL_NON_ROOT_PNPM_FIELDS = ['executionEnv'] as const - export function getNodeBinLocationForCurrentOS (platform: string = process.platform): string { return platform === 'win32' ? 'node.exe' : 'bin/node' } diff --git a/packages/types/src/env.ts b/packages/types/src/env.ts deleted file mode 100644 index a90d3c3f37..0000000000 --- a/packages/types/src/env.ts +++ /dev/null @@ -1,14 +0,0 @@ -export interface PrepareExecutionEnvOptions { - extraBinPaths?: string[] - executionEnv: ExecutionEnv | undefined -} - -export interface PrepareExecutionEnvResult { - extraBinPaths: string[] -} - -export type PrepareExecutionEnv = (options: PrepareExecutionEnvOptions) => Promise - -export interface ExecutionEnv { - nodeVersion?: string -} diff --git a/packages/types/src/index.ts b/packages/types/src/index.ts index 59c4ca1eeb..86f5e46146 100644 --- a/packages/types/src/index.ts +++ b/packages/types/src/index.ts @@ -1,5 +1,4 @@ export * from './config.js' -export * from './env.js' export * from './misc.js' export * from './options.js' export * from './package.js' diff --git a/packages/types/src/package.ts b/packages/types/src/package.ts index 3980dd5468..8d9efa9a33 100644 --- a/packages/types/src/package.ts +++ b/packages/types/src/package.ts @@ -1,5 +1,3 @@ -import { type ExecutionEnv } from './env.js' - export type Dependencies = Record export type PackageBin = string | { [commandName: string]: string } @@ -173,7 +171,6 @@ export interface PnpmSettings { auditConfig?: AuditConfig requiredScripts?: string[] supportedArchitectures?: SupportedArchitectures - executionEnv?: ExecutionEnv } export interface ProjectManifest extends BaseManifest { diff --git a/pkg-manager/core/src/install/extendInstallOptions.ts b/pkg-manager/core/src/install/extendInstallOptions.ts index 4f27e67829..3688b678b6 100644 --- a/pkg-manager/core/src/install/extendInstallOptions.ts +++ b/pkg-manager/core/src/install/extendInstallOptions.ts @@ -17,7 +17,6 @@ import { type PeerDependencyRules, type ReadPackageHook, type Registries, - type PrepareExecutionEnv, type TrustPolicy, } from '@pnpm/types' import { type CustomResolver, type CustomFetcher, type PreResolutionHookContext } from '@pnpm/hooks.types' @@ -165,7 +164,6 @@ export interface StrictInstallOptions { hoistWorkspacePackages?: boolean virtualStoreDirMaxLength: number peersSuffixMaxLength: number - prepareExecutionEnv?: PrepareExecutionEnv returnListOfDepsRequiringBuild?: boolean injectWorkspacePackages?: boolean ci?: boolean diff --git a/pkg-manager/core/src/install/index.ts b/pkg-manager/core/src/install/index.ts index 9bf580740d..4d800d3713 100644 --- a/pkg-manager/core/src/install/index.ts +++ b/pkg-manager/core/src/install/index.ts @@ -410,7 +410,6 @@ export async function mutateModules ( stdio: opts.ownLifecycleHooksStdio, storeController: opts.storeController, unsafePerm: opts.unsafePerm || false, - prepareExecutionEnv: opts.prepareExecutionEnv, } if (!opts.ignoreScripts && !opts.ignorePackageManifest && rootProjectManifest?.scripts?.[DEV_PREINSTALL]) { diff --git a/pkg-manager/plugin-commands-installation/package.json b/pkg-manager/plugin-commands-installation/package.json index b21020309a..1f6036d82c 100644 --- a/pkg-manager/plugin-commands-installation/package.json +++ b/pkg-manager/plugin-commands-installation/package.json @@ -56,7 +56,6 @@ "@pnpm/package-store": "workspace:*", "@pnpm/parse-wanted-dependency": "workspace:*", "@pnpm/pick-registry-for-package": "workspace:*", - "@pnpm/plugin-commands-env": "workspace:*", "@pnpm/plugin-commands-rebuild": "workspace:*", "@pnpm/pnpmfile": "workspace:*", "@pnpm/read-modules-dir": "workspace:*", diff --git a/pkg-manager/plugin-commands-installation/src/add.ts b/pkg-manager/plugin-commands-installation/src/add.ts index e65595be73..f484871a8c 100644 --- a/pkg-manager/plugin-commands-installation/src/add.ts +++ b/pkg-manager/plugin-commands-installation/src/add.ts @@ -3,7 +3,6 @@ import { FILTERING, OPTIONS, UNIVERSAL_OPTIONS } from '@pnpm/common-cli-options- import { types as allTypes } from '@pnpm/config' import { resolveConfigDeps } from '@pnpm/config.deps-installer' import { PnpmError } from '@pnpm/error' -import { prepareExecutionEnv } from '@pnpm/plugin-commands-env' import { createOrConnectStoreController } from '@pnpm/store-connection-manager' import { pick } from 'ramda' import renderHelp from 'render-help' @@ -291,6 +290,5 @@ export async function handler ( fetchFullMetadata: getFetchFullMetadata(opts), include, includeDirect: include, - prepareExecutionEnv: prepareExecutionEnv.bind(null, opts), }, params) } diff --git a/pkg-manager/plugin-commands-installation/src/dedupe.ts b/pkg-manager/plugin-commands-installation/src/dedupe.ts index 4aa0807ae5..0560503b4d 100644 --- a/pkg-manager/plugin-commands-installation/src/dedupe.ts +++ b/pkg-manager/plugin-commands-installation/src/dedupe.ts @@ -1,7 +1,6 @@ import { docsUrl } from '@pnpm/cli-utils' import { OPTIONS, UNIVERSAL_OPTIONS } from '@pnpm/common-cli-options-help' import { dedupeDiffCheck } from '@pnpm/dedupe.check' -import { prepareExecutionEnv } from '@pnpm/plugin-commands-env' import renderHelp from 'render-help' import { type InstallCommandOptions, rcOptionsTypes as installCommandRcOptionsTypes } from './install.js' import { installDeps } from './installDeps.js' @@ -64,6 +63,5 @@ export async function handler (opts: DedupeCommandOptions): Promise { include, includeDirect: include, lockfileCheck: opts.check ? dedupeDiffCheck : undefined, - prepareExecutionEnv: prepareExecutionEnv.bind(null, opts), }, []) } diff --git a/pkg-manager/plugin-commands-installation/src/install.ts b/pkg-manager/plugin-commands-installation/src/install.ts index 25a3d2ea2e..777e446ad8 100644 --- a/pkg-manager/plugin-commands-installation/src/install.ts +++ b/pkg-manager/plugin-commands-installation/src/install.ts @@ -2,7 +2,6 @@ import { docsUrl } from '@pnpm/cli-utils' import { FILTERING, OPTIONS, OUTPUT_OPTIONS, UNIVERSAL_OPTIONS } from '@pnpm/common-cli-options-help' import { type Config, types as allTypes } from '@pnpm/config' import { WANTED_LOCKFILE } from '@pnpm/constants' -import { prepareExecutionEnv } from '@pnpm/plugin-commands-env' import { type CreateStoreControllerOptions } from '@pnpm/store-connection-manager' import { pick } from 'ramda' import renderHelp from 'render-help' @@ -367,7 +366,6 @@ export async function handler (opts: InstallCommandOptions): Promise { ), include, includeDirect: include, - prepareExecutionEnv: prepareExecutionEnv.bind(null, opts), fetchFullMetadata: getFetchFullMetadata(opts), } if (opts.resolutionOnly) { diff --git a/pkg-manager/plugin-commands-installation/src/installDeps.ts b/pkg-manager/plugin-commands-installation/src/installDeps.ts index 70a5782f9b..314ad56515 100644 --- a/pkg-manager/plugin-commands-installation/src/installDeps.ts +++ b/pkg-manager/plugin-commands-installation/src/installDeps.ts @@ -13,7 +13,7 @@ import { findWorkspacePackages } from '@pnpm/workspace.find-packages' import { type LockfileObject } from '@pnpm/lockfile.types' import { rebuildProjects } from '@pnpm/plugin-commands-rebuild' import { createOrConnectStoreController, type CreateStoreControllerOptions } from '@pnpm/store-connection-manager' -import { type IncludedDependencies, type Project, type ProjectsGraph, type ProjectRootDir, type PrepareExecutionEnv } from '@pnpm/types' +import { type IncludedDependencies, type Project, type ProjectsGraph, type ProjectRootDir } from '@pnpm/types' import { IgnoredBuildsError, install, @@ -134,7 +134,6 @@ export type InstallDepsOptions = Pick { const filterResults = await filterPackagesFromDir(wsDir, filters, { engineStrict: config.engineStrict, - nodeVersion: config.nodeVersion ?? config.useNodeVersion, + nodeVersion: config.nodeVersion, patterns: config.workspacePackagePatterns, linkWorkspacePackages: !!config.linkWorkspacePackages, prefix: process.cwd(), @@ -291,22 +290,6 @@ export async function main (inputArgv: string[]): Promise { ), ...(workspaceDir ? { workspacePrefix: workspaceDir } : {}), }) - - if (config.useNodeVersion != null) { - if ('webcontainer' in process.versions) { - globalWarn('Automatic installation of different Node.js versions is not supported in WebContainer') - } else { - config.extraBinPaths = ( - await prepareExecutionEnv(config, { - extraBinPaths: config.extraBinPaths, - executionEnv: { - nodeVersion: config.useNodeVersion, - }, - }) - ).extraBinPaths - config.nodeVersion = config.useNodeVersion - } - } let result = pnpmCmds[cmd ?? 'help']( // TypeScript doesn't currently infer that the type of config // is `Omit` after the `delete config.reporter` statement diff --git a/pnpm/test/cli.ts b/pnpm/test/cli.ts index 59d79b09b7..1b0f09a4b7 100644 --- a/pnpm/test/cli.ts +++ b/pnpm/test/cli.ts @@ -6,7 +6,6 @@ import { fixtures } from '@pnpm/test-fixtures' import { sync as rimraf } from '@zkochan/rimraf' import execa from 'execa' import isWindows from 'is-windows' -import { sync as writeYamlFile } from 'write-yaml-file' import { execPnpm, execPnpmSync, @@ -142,23 +141,6 @@ test('exit code from plugin is used to end the process', () => { expect(result.stdout.toString()).toMatch(/is-positive/) }) -test('use the specified Node.js version for running scripts', async () => { - prepare({ - scripts: { - test: "node -e \"require('fs').writeFileSync('version',process.version,'utf8')\"", - }, - }) - writeYamlFile('pnpm-workspace.yaml', { - useNodeVersion: '14.0.0', - }) - await execPnpm(['run', 'test'], { - env: { - PNPM_HOME: path.resolve('pnpm_home'), - }, - }) - expect(fs.readFileSync('version', 'utf8')).toBe('v14.0.0') -}) - test('if an unknown command is executed, run it', async () => { prepare({}) await execPnpm(['node', '-e', "require('fs').writeFileSync('foo','','utf8')"]) diff --git a/pnpm/test/dlx.ts b/pnpm/test/dlx.ts index 70a9501345..b693210a04 100644 --- a/pnpm/test/dlx.ts +++ b/pnpm/test/dlx.ts @@ -261,17 +261,18 @@ test('dlx read registry from .npmrc in the current directory', async () => { expect(execResult.stdout.toString().trim()).toBe('hello from @pnpm.e2e/needs-auth') }) -test('dlx uses the node version specified by --use-node-version', async () => { +test('dlx uses the node version specified by --package=node@runtime:', async () => { prepareEmpty() const pnpmHome = path.resolve('home') const execResult = execPnpmSync([ - '--use-node-version=20.0.0', + '--package=node@runtime:20.0.0', + '--package=@pnpm.e2e/print-node-info', `--config.store-dir=${path.resolve('store')}`, `--config.cache-dir=${path.resolve('cache')}`, 'dlx', - '@pnpm.e2e/print-node-info', + 'print-node-info', ], { env: { PNPM_HOME: pnpmHome, @@ -289,14 +290,8 @@ test('dlx uses the node version specified by --use-node-version', async () => { throw err } - expect(nodeInfo).toMatchObject({ - versions: { - node: '20.0.0', - }, - execPath: process.platform === 'win32' - ? path.join(pnpmHome, 'nodejs', '20.0.0', 'node.exe') - : path.join(pnpmHome, 'nodejs', '20.0.0', 'bin', 'node'), - }) + expect(nodeInfo.versions.node).toBe('20.0.0') + expect(nodeInfo.execPath).toContain(path.normalize('links/@/node/20.0.0')) }) describeOnLinuxOnly('dlx with supportedArchitectures CLI options', () => { diff --git a/pnpm/test/exec.ts b/pnpm/test/exec.ts deleted file mode 100644 index 580b6b6d00..0000000000 --- a/pnpm/test/exec.ts +++ /dev/null @@ -1,73 +0,0 @@ -import { prepare, preparePackages } from '@pnpm/prepare' -import { execPnpmSync } from './utils/index.js' - -test('exec with executionEnv', async () => { - prepare({ - name: 'test', - version: '0.0.0', - pnpm: { - executionEnv: { - nodeVersion: '18.0.0', - }, - }, - }) - - const output = execPnpmSync(['exec', 'node', '--version']).stdout.toString().trim() - expect(output).toBe('v18.0.0') -}) - -test('recursive exec when some packages define different executionEnv', async () => { - preparePackages([ - { - name: 'node-version-unset', - version: '0.0.0', - }, - { - name: 'node-version-18', - version: '0.0.0', - pnpm: { - executionEnv: { - nodeVersion: '18.0.0', - }, - }, - }, - { - name: 'node-version-20', - version: '0.0.0', - pnpm: { - executionEnv: { - nodeVersion: '20.0.0', - }, - }, - }, - ]) - - const execNodePrintVersion = (extraOptions: string[]) => - execPnpmSync([ - ...extraOptions, - '--recursive', - '--reporter-hide-prefix', - 'exec', - 'node', - '--print', - '">>> " + require("./package.json").name + ": " + process.version', - ]) - .stdout - .toString() - .trim() - .split('\n') - .filter(x => x.startsWith('>>> ')) - .sort() - - expect(execNodePrintVersion([])).toStrictEqual([ - '>>> node-version-18: v18.0.0', - '>>> node-version-20: v20.0.0', - `>>> node-version-unset: ${process.version}`, - ]) - - expect(execNodePrintVersion(['--use-node-version=19.0.0'])).toStrictEqual([ - '>>> node-version-18: v18.0.0', - '>>> node-version-20: v20.0.0', - '>>> node-version-unset: v19.0.0', - ]) -}) diff --git a/pnpm/test/install/lifecycleScripts.ts b/pnpm/test/install/lifecycleScripts.ts index 5dc4a1b9b4..877d3b29a9 100644 --- a/pnpm/test/install/lifecycleScripts.ts +++ b/pnpm/test/install/lifecycleScripts.ts @@ -1,12 +1,12 @@ import fs from 'fs' import path from 'path' -import { prepare, preparePackages } from '@pnpm/prepare' +import { prepare } from '@pnpm/prepare' import { type PackageManifest, type ProjectManifest } from '@pnpm/types' import { sync as rimraf } from '@zkochan/rimraf' import PATH from 'path-name' import { loadJsonFileSync } from 'load-json-file' import writeYamlFile from 'write-yaml-file' -import { execPnpm, execPnpmSync, pnpmBinLocation } from '../utils/index.js' +import { execPnpmSync, pnpmBinLocation } from '../utils/index.js' import { getIntegrity } from '@pnpm/registry-mock' import { readWorkspaceManifest } from '@pnpm/workspace.read-manifest' @@ -218,96 +218,6 @@ test('selectively allow scripts in some dependencies by --allow-build flag overl expect(result.stdout.toString()).toContain('The following dependencies are ignored by the root project, but are allowed to be built by the current command: @pnpm.e2e/install-script-example') }) -test('use node versions specified by pnpm.executionEnv.nodeVersion in workspace packages', async () => { - const projects = preparePackages([ - { - location: '.', - package: { - name: 'root', - version: '1.0.0', - private: true, - }, - }, - { - name: 'node-version-unset', - version: '1.0.0', - scripts: { - test: 'node -v > node-version.txt', - }, - }, - { - name: 'node-version-18', - version: '1.0.0', - scripts: { - test: 'node -v > node-version.txt', - }, - pnpm: { - executionEnv: { - nodeVersion: '18.0.0', - }, - }, - }, - { - name: 'node-version-20', - version: '1.0.0', - scripts: { - test: 'node -v > node-version.txt', - }, - pnpm: { - executionEnv: { - nodeVersion: '20.0.0', - }, - }, - }, - ]) - - await writeYamlFile(path.resolve('pnpm-workspace.yaml'), { - packages: ['*'], - }) - - execPnpmSync(['-r', 'test']) - expect( - ['node-version-unset', 'node-version-18', 'node-version-20'].map(name => { - const filePath = path.join(projects[name].dir(), 'node-version.txt') - return fs.readFileSync(filePath, 'utf-8').trim() - }) - ).toStrictEqual([process.version, 'v18.0.0', 'v20.0.0']) - - execPnpmSync(['--config.use-node-version=19.0.0', '-r', 'test']) - expect( - ['node-version-unset', 'node-version-18', 'node-version-20'].map(name => { - const filePath = path.join(projects[name].dir(), 'node-version.txt') - return fs.readFileSync(filePath, 'utf-8').trim() - }) - ).toStrictEqual(['v19.0.0', 'v18.0.0', 'v20.0.0']) -}) - -test('ignores pnpm.executionEnv specified by dependencies', async () => { - prepare({ - name: 'ignores-pnpm-use-node-version-from-dependencies', - version: '1.0.0', - dependencies: { - // this package's package.json has pnpm.executionEnv.nodeVersion = '20.0.0' - '@pnpm.e2e/has-execution-env': '1.0.0', - }, - pnpm: { - neverBuiltDependencies: [], - }, - }) - - await execPnpm(['install']) - - const nodeInfoFile = path.resolve('node_modules', '@pnpm.e2e', 'has-execution-env', 'node-info.json') - const nodeInfoJson = fs.readFileSync(nodeInfoFile, 'utf-8') - const nodeInfo = JSON.parse(nodeInfoJson) - - // pnpm should still use system's Node.js to execute the install script despite pnpm.executionEnv.nodeVersion specified by the dependency - expect(nodeInfo).toMatchObject({ - execPath: process.execPath, - versions: process.versions, - }) -}) - test('preinstall script does not trigger verify-deps-before-run (#8954)', async () => { const pnpm = `${process.execPath} ${pnpmBinLocation}` // this would fail if either paths happen to contain spaces diff --git a/pnpm/test/run.ts b/pnpm/test/run.ts index d961001d24..2c6be9ff34 100644 --- a/pnpm/test/run.ts +++ b/pnpm/test/run.ts @@ -231,61 +231,3 @@ test('--reporter-hide-prefix should hide workspace prefix', async () => { expect(output).toContain('2') expect(output).not.toContain('script2: 2') }) - -test('recursive run when some packages define different node versions', async () => { - preparePackages([ - { - name: 'node-version-unset', - scripts: { - 'print-node-version': 'node -v', - }, - }, - { - name: 'node-version-18', - scripts: { - 'print-node-version': 'node -v', - }, - pnpm: { - executionEnv: { - nodeVersion: '18.0.0', - }, - }, - }, - { - name: 'node-version-20', - scripts: { - 'print-node-version': 'node -v', - }, - pnpm: { - executionEnv: { - nodeVersion: '20.0.0', - }, - }, - }, - ]) - - const runPrintNodeVersion = (args: string[]) => - execPnpmSync(args) - .stdout - .toString() - .trim() - .split('\n') - .filter(x => /print-node-version.*v\d+\.\d+\.\d+/.test(x)) - .sort() - - expect( - runPrintNodeVersion(['run', '-r', 'print-node-version']) - ).toStrictEqual([ - 'node-version-18 print-node-version: v18.0.0', - 'node-version-20 print-node-version: v20.0.0', - `node-version-unset print-node-version: ${process.version}`, - ]) - - expect( - runPrintNodeVersion(['run', '-r', '--use-node-version=19.0.0', 'print-node-version']) - ).toStrictEqual([ - 'node-version-18 print-node-version: v18.0.0', - 'node-version-20 print-node-version: v20.0.0', - 'node-version-unset print-node-version: v19.0.0', - ]) -}) diff --git a/releasing/plugin-commands-deploy/src/createDeployFiles.ts b/releasing/plugin-commands-deploy/src/createDeployFiles.ts index 135e91ce95..4ff0c2b023 100644 --- a/releasing/plugin-commands-deploy/src/createDeployFiles.ts +++ b/releasing/plugin-commands-deploy/src/createDeployFiles.ts @@ -1,8 +1,6 @@ import path from 'path' import url from 'url' import normalizePath from 'normalize-path' -import { pick } from 'ramda' -import { USEFUL_NON_ROOT_PNPM_FIELDS } from '@pnpm/constants' import * as dp from '@pnpm/dependency-path' import { type DirectoryResolution, @@ -139,7 +137,6 @@ export function createDeployFiles ({ optionalDependencies: targetSnapshot.optionalDependencies, pnpm: { ...rootProjectManifest?.pnpm, - ...pick(USEFUL_NON_ROOT_PNPM_FIELDS, selectedProjectManifest.pnpm ?? {}), overrides: undefined, // the effects of the overrides should already be part of the package snapshots patchedDependencies: undefined, packageExtensions: undefined, // the effects of the package extensions should already be part of the package snapshots diff --git a/releasing/plugin-commands-deploy/test/shared-lockfile.test.ts b/releasing/plugin-commands-deploy/test/shared-lockfile.test.ts index 760cc6dcfc..9b406c0ba0 100644 --- a/releasing/plugin-commands-deploy/test/shared-lockfile.test.ts +++ b/releasing/plugin-commands-deploy/test/shared-lockfile.test.ts @@ -282,9 +282,6 @@ test('the deploy manifest should inherit some fields from the pnpm object from t overrides: { 'is-positive': '2.0.0', }, - executionEnv: { - nodeVersion: '20.0.0', - }, }, }, 'project-0': { @@ -299,9 +296,6 @@ test('the deploy manifest should inherit some fields from the pnpm object from t overrides: { 'is-positive': '=1.0.0', }, - executionEnv: { - nodeVersion: '18.0.0', - }, }, }, } @@ -351,7 +345,6 @@ test('the deploy manifest should inherit some fields from the pnpm object from t const manifest = readPackageJson('deploy') as ProjectManifest expect(manifest.pnpm).toStrictEqual({ onlyBuiltDependencies: preparedManifests.root.pnpm!.onlyBuiltDependencies, - executionEnv: preparedManifests['project-0'].pnpm!.executionEnv, } as ProjectManifest['pnpm']) expect(readPackageJson('deploy/node_modules/is-positive/')).toHaveProperty(['version'], preparedManifests.root.pnpm!.overrides!['is-positive']) diff --git a/releasing/plugin-commands-publishing/src/publish.ts b/releasing/plugin-commands-publishing/src/publish.ts index 62e240d4aa..5c1e1e47ce 100644 --- a/releasing/plugin-commands-publishing/src/publish.ts +++ b/releasing/plugin-commands-publishing/src/publish.ts @@ -9,7 +9,6 @@ import { runNpm } from '@pnpm/run-npm' import { type ProjectManifest } from '@pnpm/types' import { getCurrentBranch, isGitRepo, isRemoteHistoryClean, isWorkingTreeClean } from '@pnpm/git-utils' import { loadToken } from '@pnpm/network.auth-header' -import { prepareExecutionEnv } from '@pnpm/plugin-commands-env' import enquirer from 'enquirer' import rimraf from '@zkochan/rimraf' import { pick } from 'ramda' @@ -252,7 +251,6 @@ Do you want to continue?`, rootModulesDir: await realpathMissing(path.join(dir, 'node_modules')), stdio: 'inherit', unsafePerm: true, // when running scripts explicitly, assume that they're trusted. - prepareExecutionEnv: prepareExecutionEnv.bind(null, opts), }) const { manifest } = await readProjectManifest(dir, opts) // Unfortunately, we cannot support postpack at the moment diff --git a/releasing/plugin-commands-publishing/test/recursivePublish.ts b/releasing/plugin-commands-publishing/test/recursivePublish.ts index a0480ce201..2f253bc6fa 100644 --- a/releasing/plugin-commands-publishing/test/recursivePublish.ts +++ b/releasing/plugin-commands-publishing/test/recursivePublish.ts @@ -305,57 +305,3 @@ test('when publish some package throws an error, exit code should be non-zero', expect(result?.exitCode).toBe(1) }) - -test('recursive publish runs script with Node.js version specified by pnpm.executionEnv.nodeVersion', async () => { - preparePackages([ - { - name: 'test-publish-node-version-unset', - version: '1.0.0', - scripts: { - prepublishOnly: 'node -v > node-version.txt', - }, - }, - { - name: 'test-publish-node-version-18', - version: '1.0.0', - scripts: { - prepublishOnly: 'node -v > node-version.txt', - }, - pnpm: { - executionEnv: { - nodeVersion: '18.0.0', - }, - }, - }, - { - name: 'test-publish-node-version-20', - version: '1.0.0', - scripts: { - prepublishOnly: 'node -v > node-version.txt', - }, - pnpm: { - executionEnv: { - nodeVersion: '20.0.0', - }, - }, - }, - ]) - - fs.writeFileSync('.npmrc', CREDENTIALS, 'utf8') - - await publish.handler({ - ...DEFAULT_OPTS, - ...await filterPackagesFromDir(process.cwd(), []), - dir: process.cwd(), - dryRun: true, - pnpmHomeDir: process.cwd(), - recursive: true, - }, []) - - expect( - ['unset', '18', '20'] - .map(suffix => `test-publish-node-version-${suffix}`) - .map(name => path.resolve(name, 'node-version.txt')) - .map(nodeVersionFile => fs.readFileSync(nodeVersionFile, 'utf-8').trim()) - ).toStrictEqual([process.version, 'v18.0.0', 'v20.0.0']) -}) diff --git a/workspace/find-packages/src/index.ts b/workspace/find-packages/src/index.ts index 5b04e74f64..bf14d5225f 100644 --- a/workspace/find-packages/src/index.ts +++ b/workspace/find-packages/src/index.ts @@ -1,5 +1,4 @@ import { packageIsInstallable } from '@pnpm/cli-utils' -import { USEFUL_NON_ROOT_PNPM_FIELDS } from '@pnpm/constants' import { type ProjectManifest, type Project, type SupportedArchitectures } from '@pnpm/types' import { lexCompare } from '@pnpm/util.lex-comparator' import { findPackages } from '@pnpm/fs.find-packages' @@ -64,9 +63,6 @@ export async function findWorkspacePackagesNoCheck (workspaceRoot: string, opts? const uselessNonRootManifestFields: Array = ['resolutions'] -type ProjectManifestPnpm = Required['pnpm'] -const usefulNonRootPnpmFields: ReadonlyArray = USEFUL_NON_ROOT_PNPM_FIELDS - function checkNonRootProjectManifest ({ manifest, rootDir }: Project): void { const warn = printNonRootFieldWarning.bind(null, rootDir) for (const field of uselessNonRootManifestFields) { @@ -75,9 +71,7 @@ function checkNonRootProjectManifest ({ manifest, rootDir }: Project): void { } } for (const field in manifest.pnpm) { - if (!usefulNonRootPnpmFields.includes(field as keyof ProjectManifestPnpm)) { - warn(`pnpm.${field}`) - } + warn(`pnpm.${field}`) } } diff --git a/workspace/find-packages/test/__fixtures__/warning-for-non-root-project/packages/bar/package.json b/workspace/find-packages/test/__fixtures__/warning-for-non-root-project/packages/bar/package.json index 049c715695..d7d66ab2f5 100644 --- a/workspace/find-packages/test/__fixtures__/warning-for-non-root-project/packages/bar/package.json +++ b/workspace/find-packages/test/__fixtures__/warning-for-non-root-project/packages/bar/package.json @@ -2,8 +2,7 @@ "name": "bar", "version": "1.0.0", "pnpm": { - "overrides": {}, - "executionEnv": {} + "overrides": {} }, "resolutions": {} } diff --git a/workspace/find-packages/test/__fixtures__/warning-for-non-root-project/packages/foo/package.json b/workspace/find-packages/test/__fixtures__/warning-for-non-root-project/packages/foo/package.json index 16deac19f7..e749a1b2b4 100644 --- a/workspace/find-packages/test/__fixtures__/warning-for-non-root-project/packages/foo/package.json +++ b/workspace/find-packages/test/__fixtures__/warning-for-non-root-project/packages/foo/package.json @@ -2,7 +2,6 @@ "name": "foo", "version": "1.0.0", "pnpm": { - "overrides": {}, - "executionEnv": {} + "overrides": {} } }