@pnpm/exec.commands 1100.3.0 → 1100.3.2

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/dlx.js CHANGED
@@ -8,10 +8,11 @@ import { OUTPUT_OPTIONS } from '@pnpm/cli.common-cli-options-help';
8
8
  import { docsUrl, readProjectManifestOnly } from '@pnpm/cli.utils';
9
9
  import { types } from '@pnpm/config.reader';
10
10
  import { getPublishedByPolicy } from '@pnpm/config.version-policy';
11
- import { createHexHash } from '@pnpm/crypto.hash';
11
+ import { createShortHash } from '@pnpm/crypto.hash';
12
12
  import { PnpmError } from '@pnpm/error';
13
13
  import { createResolver, makeResolutionStrict } from '@pnpm/installing.client';
14
14
  import { add } from '@pnpm/installing.commands';
15
+ import { logger } from '@pnpm/logger';
15
16
  import { readPackageJsonFromDir } from '@pnpm/pkg-manifest.reader';
16
17
  import { parseWantedDependency } from '@pnpm/resolving.parse-wanted-dependency';
17
18
  import { lexCompare } from '@pnpm/util.lex-comparator';
@@ -186,8 +187,23 @@ export async function handler(opts, [command, ...args], commands) {
186
187
  }
187
188
  else {
188
189
  // Drop the partially-populated cache so a subsequent dlx run starts
189
- // clean instead of reusing a broken install.
190
- await fs.promises.rm(cachedDir, { recursive: true, force: true });
190
+ // clean instead of reusing a broken install. This is best-effort: on
191
+ // Windows the just-run install scripts (or antivirus) can briefly hold
192
+ // handles on freshly written files, so retry with backoff. A cleanup
193
+ // failure must never mask the original install error, which is the one
194
+ // worth surfacing — log it and rethrow err. A leftover prepare dir is
195
+ // harmless: it has a unique name and findCache only trusts the `pkg`
196
+ // symlink.
197
+ try {
198
+ await fs.promises.rm(cachedDir, { recursive: true, force: true, maxRetries: 10, retryDelay: 100 });
199
+ }
200
+ catch (cleanupErr) {
201
+ logger.warn({
202
+ error: cleanupErr,
203
+ message: `Failed to clean up the dlx cache directory at "${cachedDir}"`,
204
+ prefix: cachedDir,
205
+ });
206
+ }
191
207
  throw err;
192
208
  }
193
209
  }
@@ -353,7 +369,12 @@ export function createCacheKey(opts) {
353
369
  }
354
370
  }
355
371
  const hashStr = JSON.stringify(args);
356
- return createHexHash(hashStr);
372
+ // A short (truncated) hash keeps the dlx cache path short. The full
373
+ // virtual-store path below it (`<key>/<prepare>/node_modules/.pnpm/<pkgId>/
374
+ // node_modules/<pkg>`) can otherwise blow past Windows' MAX_PATH (260) and
375
+ // make lifecycle scripts fail with a `spawn cmd.exe ENOENT` (the cwd no
376
+ // longer resolves). 128 bits is ample collision resistance for a cache key.
377
+ return createShortHash(hashStr);
357
378
  }
358
379
  function getValidCacheDir(cacheLink, dlxCacheMaxAge) {
359
380
  let stats;
@@ -379,7 +400,10 @@ function getValidCacheDir(cacheLink, dlxCacheMaxAge) {
379
400
  return isValid ? target : undefined;
380
401
  }
381
402
  function getPrepareDir(cachePath) {
382
- const name = `${new Date().getTime().toString(16)}-${process.pid.toString(16)}`;
403
+ // base36 (vs hex) keeps this segment short — see createCacheKey for why dlx
404
+ // path length matters on Windows. time+pid stays unique across concurrent
405
+ // dlx processes and across a process's own retries of a failed install.
406
+ const name = `${Date.now().toString(36)}-${process.pid.toString(36)}`;
383
407
  return path.join(cachePath, name);
384
408
  }
385
409
  function resolveCatalogProtocol(catalogResolver, alias, bareSpecifier) {
package/lib/exec.d.ts CHANGED
@@ -28,7 +28,7 @@ export type ExecOpts = Required<Pick<ConfigContext, 'selectedProjectsGraph'>> &
28
28
  resumeFrom?: string;
29
29
  reportSummary?: boolean;
30
30
  implicitlyFellbackFromRun?: boolean;
31
- } & Pick<Config, 'bin' | 'dir' | 'extraBinPaths' | 'extraEnv' | 'lockfileDir' | 'modulesDir' | 'nodeOptions' | 'nodeExperimentalPackageMap' | 'pnpmHomeDir' | 'recursive' | 'reporter' | 'reporterHidePrefix' | 'userAgent' | 'verifyDepsBeforeRun' | 'workspaceDir'> & Pick<ConfigContext, 'cliOptions'> & CheckDepsStatusOptions;
31
+ } & Pick<Config, 'bin' | 'dir' | 'extraBinPaths' | 'extraEnv' | 'lockfileDir' | 'modulesDir' | 'nodeOptions' | 'nodeExperimentalPackageMap' | 'pnpmHomeDir' | 'recursive' | 'reporter' | 'reporterHidePrefix' | 'userAgent' | 'verifyDepsBeforeRun' | 'workspaceDir'> & Pick<ConfigContext, 'cliOptions' | 'allProjectsGraph' | 'prodAllProjectsGraph' | 'prodOnlySelectedProjectDirs'> & CheckDepsStatusOptions;
32
32
  export declare function handler(opts: ExecOpts, params: string[]): Promise<{
33
33
  exitCode: number;
34
34
  }>;
package/lib/exec.js CHANGED
@@ -8,7 +8,7 @@ import { makeNodePackageMapOption, makeNodeRequireOption } from '@pnpm/exec.life
8
8
  import { logger } from '@pnpm/logger';
9
9
  import { prependDirsToPath } from '@pnpm/shell.path';
10
10
  import { tryReadProjectManifest } from '@pnpm/workspace.project-manifest-reader';
11
- import { sortProjects } from '@pnpm/workspace.projects-sorter';
11
+ import { sortFilteredProjects } from '@pnpm/workspace.projects-sorter';
12
12
  import { safeExeca as execa } from 'execa';
13
13
  import pLimit from 'p-limit';
14
14
  import { pick } from 'ramda';
@@ -123,7 +123,7 @@ export async function handler(opts, params) {
123
123
  let chunks;
124
124
  if (opts.recursive) {
125
125
  chunks = opts.sort
126
- ? sortProjects(opts.selectedProjectsGraph)
126
+ ? sortFilteredProjects(opts)
127
127
  : [Object.keys(opts.selectedProjectsGraph).sort()];
128
128
  if (opts.reverse) {
129
129
  chunks = chunks.reverse();
@@ -1,6 +1,6 @@
1
1
  import { type Config, type ConfigContext } from '@pnpm/config.reader';
2
2
  import type { PackageScripts } from '@pnpm/types';
3
- export type RecursiveRunOpts = Pick<Config, 'bin' | 'enablePrePostScripts' | 'unsafePerm' | 'pnpmHomeDir' | 'requiredScripts' | 'userAgent' | 'scriptsPrependNodePath' | 'scriptShell' | 'shellEmulator' | 'stream' | 'syncInjectedDepsAfterScripts' | 'workspaceDir' | 'nodeExperimentalPackageMap' | 'modulesDir'> & Pick<ConfigContext, 'rootProjectManifest'> & Required<Pick<ConfigContext, 'allProjects' | 'selectedProjectsGraph'> & Pick<Config, 'workspaceDir' | 'dir'>> & Partial<Pick<Config, 'extraBinPaths' | 'extraEnv' | 'bail' | 'reporter' | 'reverse' | 'sort' | 'workspaceConcurrency'>> & {
3
+ export type RecursiveRunOpts = Pick<Config, 'bin' | 'enablePrePostScripts' | 'unsafePerm' | 'pnpmHomeDir' | 'requiredScripts' | 'userAgent' | 'scriptsPrependNodePath' | 'scriptShell' | 'shellEmulator' | 'stream' | 'syncInjectedDepsAfterScripts' | 'workspaceDir' | 'nodeExperimentalPackageMap' | 'modulesDir'> & Pick<ConfigContext, 'rootProjectManifest' | 'allProjectsGraph' | 'prodAllProjectsGraph' | 'prodOnlySelectedProjectDirs'> & Required<Pick<ConfigContext, 'allProjects' | 'selectedProjectsGraph'> & Pick<Config, 'workspaceDir' | 'dir'>> & Partial<Pick<Config, 'extraBinPaths' | 'extraEnv' | 'bail' | 'reporter' | 'reverse' | 'sort' | 'workspaceConcurrency'>> & {
4
4
  ifPresent?: boolean;
5
5
  resumeFrom?: string;
6
6
  reportSummary?: boolean;
@@ -6,7 +6,7 @@ import { getWorkspaceConcurrency } from '@pnpm/config.reader';
6
6
  import { PnpmError } from '@pnpm/error';
7
7
  import { makeNodePackageMapOption, makeNodeRequireOption, } from '@pnpm/exec.lifecycle';
8
8
  import { groupStart } from '@pnpm/log.group';
9
- import { sortProjects } from '@pnpm/workspace.projects-sorter';
9
+ import { sortFilteredProjects } from '@pnpm/workspace.projects-sorter';
10
10
  import pLimit from 'p-limit';
11
11
  import { realpathMissing } from 'realpath-missing';
12
12
  import { createEmptyRecursiveSummary, getExecutionDuration, getResumedPackageChunks, writeRecursiveSummary } from './exec.js';
@@ -21,7 +21,7 @@ export async function runRecursive(params, opts) {
21
21
  }
22
22
  let hasCommand = 0;
23
23
  const sortedPackageChunks = opts.sort
24
- ? sortProjects(opts.selectedProjectsGraph)
24
+ ? sortFilteredProjects(opts)
25
25
  : [Object.keys(opts.selectedProjectsGraph).sort()];
26
26
  let packageChunks = opts.reverse ? sortedPackageChunks.reverse() : sortedPackageChunks;
27
27
  if (opts.resumeFrom) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pnpm/exec.commands",
3
- "version": "1100.3.0",
3
+ "version": "1100.3.2",
4
4
  "description": "Commands for running scripts",
5
5
  "keywords": [
6
6
  "pnpm",
@@ -11,9 +11,9 @@
11
11
  "funding": "https://opencollective.com/pnpm",
12
12
  "repository": {
13
13
  "type": "git",
14
- "url": "https://github.com/pnpm/pnpm/tree/main/exec/commands"
14
+ "url": "https://github.com/pnpm/pnpm/tree/main/pnpm11/exec/commands"
15
15
  },
16
- "homepage": "https://github.com/pnpm/pnpm/tree/main/exec/commands#readme",
16
+ "homepage": "https://github.com/pnpm/pnpm/tree/main/pnpm11/exec/commands#readme",
17
17
  "bugs": {
18
18
  "url": "https://github.com/pnpm/pnpm/issues"
19
19
  },
@@ -41,31 +41,31 @@
41
41
  "symlink-dir": "^10.0.1",
42
42
  "which": "npm:@pnpm/which@^3.0.1",
43
43
  "write-json-file": "^7.0.0",
44
- "@pnpm/building.commands": "1100.1.6",
45
- "@pnpm/catalogs.resolver": "1100.0.0",
46
44
  "@pnpm/bins.resolver": "1100.0.8",
45
+ "@pnpm/building.commands": "1100.1.8",
46
+ "@pnpm/catalogs.resolver": "1100.0.0",
47
47
  "@pnpm/cli.command": "1100.0.1",
48
48
  "@pnpm/cli.common-cli-options-help": "1100.0.2",
49
- "@pnpm/config.version-policy": "1100.1.5",
50
- "@pnpm/cli.utils": "1101.0.12",
51
- "@pnpm/config.reader": "1101.10.0",
49
+ "@pnpm/cli.utils": "1101.0.13",
50
+ "@pnpm/config.reader": "1101.11.0",
51
+ "@pnpm/config.version-policy": "1100.1.6",
52
52
  "@pnpm/core-loggers": "1100.2.1",
53
- "@pnpm/error": "1100.0.0",
54
53
  "@pnpm/crypto.hash": "1100.0.1",
54
+ "@pnpm/deps.status": "1100.1.4",
55
+ "@pnpm/engine.runtime.commands": "1100.1.8",
56
+ "@pnpm/error": "1100.0.1",
57
+ "@pnpm/exec.lifecycle": "1100.1.2",
55
58
  "@pnpm/exec.pnpm-cli-runner": "1100.0.1",
56
- "@pnpm/installing.client": "1100.2.9",
57
- "@pnpm/exec.lifecycle": "1100.1.0",
58
- "@pnpm/installing.commands": "1100.10.0",
59
- "@pnpm/pkg-manifest.reader": "1100.0.8",
60
- "@pnpm/shell.path": "1100.0.1",
59
+ "@pnpm/installing.client": "1100.2.11",
60
+ "@pnpm/installing.commands": "1100.10.2",
61
+ "@pnpm/pkg-manifest.reader": "1100.0.9",
61
62
  "@pnpm/resolving.parse-wanted-dependency": "1100.0.1",
62
- "@pnpm/workspace.injected-deps-syncer": "1100.0.20",
63
+ "@pnpm/shell.path": "1100.0.1",
64
+ "@pnpm/store.path": "1100.0.2",
63
65
  "@pnpm/types": "1101.3.2",
64
- "@pnpm/store.path": "1100.0.1",
65
- "@pnpm/deps.status": "1100.1.2",
66
- "@pnpm/workspace.project-manifest-reader": "1100.0.13",
67
- "@pnpm/workspace.projects-sorter": "1100.0.7",
68
- "@pnpm/engine.runtime.commands": "1100.1.6"
66
+ "@pnpm/workspace.injected-deps-syncer": "1100.0.22",
67
+ "@pnpm/workspace.project-manifest-reader": "1100.0.14",
68
+ "@pnpm/workspace.projects-sorter": "1100.0.8"
69
69
  },
70
70
  "peerDependencies": {
71
71
  "@pnpm/logger": "^1100.0.0"
@@ -77,13 +77,13 @@
77
77
  "@types/which": "^3.0.4",
78
78
  "is-windows": "^1.0.2",
79
79
  "write-yaml-file": "^6.0.0",
80
- "@pnpm/exec.commands": "1100.3.0",
81
- "@pnpm/logger": "1100.0.0",
82
- "@pnpm/prepare": "1100.0.16",
83
80
  "@pnpm/engine.runtime.system-version": "1100.0.3",
84
- "@pnpm/workspace.projects-filter": "1100.0.22",
81
+ "@pnpm/exec.commands": "1100.3.2",
82
+ "@pnpm/logger": "1100.0.0",
83
+ "@pnpm/prepare": "1100.0.18",
85
84
  "@pnpm/test-ipc-server": "1100.0.0",
86
- "@pnpm/testing.command-defaults": "1100.0.6"
85
+ "@pnpm/testing.command-defaults": "1100.0.8",
86
+ "@pnpm/workspace.projects-filter": "1100.0.24"
87
87
  },
88
88
  "engines": {
89
89
  "node": ">=22.13"