@pnpm/installing.deps-restorer 1101.1.11 → 1102.1.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/lib/index.d.ts +9 -0
- package/lib/index.js +51 -3
- package/lib/lockfileToHoistedDepGraph.js +2 -1
- package/package.json +39 -39
package/lib/index.d.ts
CHANGED
|
@@ -90,12 +90,21 @@ export interface HeadlessOptions {
|
|
|
90
90
|
skipRuntimes?: boolean;
|
|
91
91
|
enableModulesDir?: boolean;
|
|
92
92
|
virtualStoreOnly?: boolean;
|
|
93
|
+
nodeExperimentalPackageMap?: boolean;
|
|
94
|
+
nodePackageMapType?: 'standard' | 'loose';
|
|
93
95
|
nodeLinker?: 'isolated' | 'hoisted' | 'pnp';
|
|
94
96
|
useGitBranchLockfile?: boolean;
|
|
95
97
|
useLockfile?: boolean;
|
|
96
98
|
supportedArchitectures?: SupportedArchitectures;
|
|
97
99
|
hoistWorkspacePackages?: boolean;
|
|
98
100
|
modulesFile?: Modules | null;
|
|
101
|
+
/**
|
|
102
|
+
* Awaited right before dependency lifecycle scripts run. Lets the caller
|
|
103
|
+
* overlap lockfile verification with fetching and linking while still
|
|
104
|
+
* guaranteeing no dependency script executes on an unverified lockfile:
|
|
105
|
+
* the returned promise rejects when verification failed.
|
|
106
|
+
*/
|
|
107
|
+
verifyLockfile?: () => Promise<void>;
|
|
99
108
|
}
|
|
100
109
|
export interface InstallationResultStats {
|
|
101
110
|
added: number;
|
package/lib/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import { lockfileToDepGraph, } from '@pnpm/deps.graph-builder';
|
|
|
9
9
|
import { calcDepState, findRuntimeNodeVersion } from '@pnpm/deps.graph-hasher';
|
|
10
10
|
import * as dp from '@pnpm/deps.path';
|
|
11
11
|
import { PnpmError } from '@pnpm/error';
|
|
12
|
-
import { makeNodeRequireOption, runLifecycleHooksConcurrently, } from '@pnpm/exec.lifecycle';
|
|
12
|
+
import { makeNodePackageMapOption, makeNodeRequireOption, runLifecycleHooksConcurrently, } from '@pnpm/exec.lifecycle';
|
|
13
13
|
import { symlinkDependency } from '@pnpm/fs.symlink-dependency';
|
|
14
14
|
import { linkDirectDeps } from '@pnpm/installing.linking.direct-dep-linker';
|
|
15
15
|
import { hoist } from '@pnpm/installing.linking.hoist';
|
|
@@ -17,7 +17,7 @@ import { prune } from '@pnpm/installing.linking.modules-cleaner';
|
|
|
17
17
|
import { writeModulesManifest, } from '@pnpm/installing.modules-yaml';
|
|
18
18
|
import { filterLockfileByEngine, filterLockfileByImportersAndEngine, } from '@pnpm/lockfile.filtering';
|
|
19
19
|
import { getLockfileImporterId, readCurrentLockfile, readWantedLockfile, writeCurrentLockfile, writeLockfiles, } from '@pnpm/lockfile.fs';
|
|
20
|
-
import { writePnpFile } from '@pnpm/lockfile.to-pnp';
|
|
20
|
+
import { PACKAGE_MAP_FILENAME, writePackageMap, writePackageMapFromDependenciesGraph, writePnpFile } from '@pnpm/lockfile.to-pnp';
|
|
21
21
|
import { nameVerFromPkgSnapshot, } from '@pnpm/lockfile.utils';
|
|
22
22
|
import { logger, streamParser, } from '@pnpm/logger';
|
|
23
23
|
import { readPackageJsonFromDir } from '@pnpm/pkg-manifest.reader';
|
|
@@ -322,6 +322,36 @@ export async function headlessInstall(opts) {
|
|
|
322
322
|
});
|
|
323
323
|
}
|
|
324
324
|
}
|
|
325
|
+
const shouldWritePackageMap = opts.enableModulesDir !== false && opts.nodeLinker !== 'pnp' && !opts.virtualStoreOnly;
|
|
326
|
+
if (shouldWritePackageMap) {
|
|
327
|
+
// Omit the importer self-mapping when a project has no name: the map keys
|
|
328
|
+
// dependencies by package name, so falling back to the importer id (`.` or
|
|
329
|
+
// a path) would emit a non-package-name key. Matches pacquet.
|
|
330
|
+
const importerNames = Object.fromEntries(selectedProjects.map(({ manifest, id }) => [id, manifest.name]));
|
|
331
|
+
if (opts.nodeLinker === 'hoisted') {
|
|
332
|
+
await writePackageMapFromDependenciesGraph({
|
|
333
|
+
directDependenciesByImporterId,
|
|
334
|
+
graph,
|
|
335
|
+
importerNames,
|
|
336
|
+
lockfile: filteredLockfile,
|
|
337
|
+
lockfileDir,
|
|
338
|
+
packageMapType: opts.nodePackageMapType,
|
|
339
|
+
packageIdStrategy: 'path',
|
|
340
|
+
rootModulesDir,
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
else {
|
|
344
|
+
await writePackageMap(filteredLockfile, {
|
|
345
|
+
importerNames,
|
|
346
|
+
lockfileDir,
|
|
347
|
+
locationByDepPath: Object.fromEntries(Object.values(graph).map((node) => [node.depPath, node.dir])),
|
|
348
|
+
packageMapType: opts.nodePackageMapType,
|
|
349
|
+
rootModulesDir,
|
|
350
|
+
virtualStoreDir,
|
|
351
|
+
virtualStoreDirMaxLength: opts.virtualStoreDirMaxLength,
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
}
|
|
325
355
|
if (opts.ignoreScripts) {
|
|
326
356
|
for (const { id, manifest } of selectedProjects) {
|
|
327
357
|
if (opts.ignoreScripts && ((manifest?.scripts) != null) &&
|
|
@@ -358,9 +388,17 @@ export async function headlessInstall(opts) {
|
|
|
358
388
|
if (opts.enablePnp) {
|
|
359
389
|
extraEnv = {
|
|
360
390
|
...extraEnv,
|
|
361
|
-
...makeNodeRequireOption(path.join(opts.lockfileDir, '.pnp.cjs')),
|
|
391
|
+
...makeNodeRequireOption(path.join(opts.lockfileDir, '.pnp.cjs'), extraEnv),
|
|
392
|
+
};
|
|
393
|
+
}
|
|
394
|
+
if (opts.nodeExperimentalPackageMap && shouldWritePackageMap) {
|
|
395
|
+
extraEnv = {
|
|
396
|
+
...extraEnv,
|
|
397
|
+
...makeNodePackageMapOption(path.join(rootModulesDir, PACKAGE_MAP_FILENAME), extraEnv),
|
|
362
398
|
};
|
|
363
399
|
}
|
|
400
|
+
// Dependency lifecycle scripts must not run on an unverified lockfile.
|
|
401
|
+
await opts.verifyLockfile?.();
|
|
364
402
|
ignoredBuilds = (await buildModules(graph, Array.from(directNodes), {
|
|
365
403
|
allowBuild,
|
|
366
404
|
childConcurrency: opts.childConcurrency,
|
|
@@ -485,6 +523,16 @@ export async function headlessInstall(opts) {
|
|
|
485
523
|
}));
|
|
486
524
|
summaryLogger.debug({ prefix: lockfileDir });
|
|
487
525
|
if (!opts.ignoreScripts && !opts.ignorePackageManifest && !skipPostImportLinking) {
|
|
526
|
+
if (opts.nodeExperimentalPackageMap && shouldWritePackageMap) {
|
|
527
|
+
scriptsOpts.extraEnv = {
|
|
528
|
+
...scriptsOpts.extraEnv,
|
|
529
|
+
...makeNodePackageMapOption(path.join(rootModulesDir, PACKAGE_MAP_FILENAME), scriptsOpts.extraEnv),
|
|
530
|
+
};
|
|
531
|
+
}
|
|
532
|
+
// The projects' own lifecycle scripts import dependency code linked from
|
|
533
|
+
// the lockfile, so they are held to the same gate as dependency builds —
|
|
534
|
+
// also on the `enableModulesDir: false` path that skips buildModules.
|
|
535
|
+
await opts.verifyLockfile?.();
|
|
488
536
|
await runLifecycleHooksConcurrently(['preinstall', 'install', 'postinstall', 'preprepare', 'prepare', 'postprepare'], projectsToBeBuilt, opts.childConcurrency ?? 5, scriptsOpts);
|
|
489
537
|
}
|
|
490
538
|
if ((reporter != null) && typeof reporter === 'function') {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
2
|
import { packageIsInstallable } from '@pnpm/config.package-is-installable';
|
|
3
3
|
import * as dp from '@pnpm/deps.path';
|
|
4
|
+
import { safeJoinModulesDir } from '@pnpm/fs.symlink-dependency';
|
|
4
5
|
import { hoist } from '@pnpm/installing.linking.real-hoist';
|
|
5
6
|
import { nameVerFromPkgSnapshot, packageIdFromSnapshot, pkgSnapshotToResolution, } from '@pnpm/lockfile.utils';
|
|
6
7
|
import { logger } from '@pnpm/logger';
|
|
@@ -134,7 +135,7 @@ async function fetchDeps(opts, modules, deps) {
|
|
|
134
135
|
});
|
|
135
136
|
return;
|
|
136
137
|
}
|
|
137
|
-
const dir =
|
|
138
|
+
const dir = safeJoinModulesDir(modules, dep.name);
|
|
138
139
|
const depLocation = path.relative(opts.lockfileDir, dir);
|
|
139
140
|
const resolution = pkgSnapshotToResolution(depPath, pkgSnapshot, opts.registries);
|
|
140
141
|
let fetchResponse;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pnpm/installing.deps-restorer",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1102.1.0",
|
|
4
4
|
"description": "Fast installation using only pnpm-lock.yaml",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pnpm",
|
|
@@ -38,60 +38,60 @@
|
|
|
38
38
|
"path-exists": "^5.0.0",
|
|
39
39
|
"ramda": "npm:@pnpm/ramda@0.28.1",
|
|
40
40
|
"realpath-missing": "^2.0.0",
|
|
41
|
-
"@pnpm/
|
|
42
|
-
"@pnpm/building.policy": "1100.0.
|
|
43
|
-
"@pnpm/building.during-install": "1101.0.18",
|
|
44
|
-
"@pnpm/config.package-is-installable": "1100.0.10",
|
|
41
|
+
"@pnpm/building.during-install": "1102.0.1",
|
|
42
|
+
"@pnpm/building.policy": "1100.0.10",
|
|
45
43
|
"@pnpm/constants": "1100.0.0",
|
|
46
|
-
"@pnpm/
|
|
47
|
-
"@pnpm/deps.
|
|
48
|
-
"@pnpm/
|
|
44
|
+
"@pnpm/config.package-is-installable": "1100.0.11",
|
|
45
|
+
"@pnpm/deps.graph-hasher": "1100.2.5",
|
|
46
|
+
"@pnpm/core-loggers": "1100.2.1",
|
|
47
|
+
"@pnpm/deps.graph-builder": "1100.0.17",
|
|
48
|
+
"@pnpm/deps.path": "1100.0.8",
|
|
49
49
|
"@pnpm/error": "1100.0.0",
|
|
50
|
-
"@pnpm/exec.lifecycle": "1100.0
|
|
51
|
-
"@pnpm/fs.symlink-dependency": "1100.0.
|
|
52
|
-
"@pnpm/installing.linking.direct-dep-linker": "1100.0.
|
|
53
|
-
"@pnpm/installing.linking.hoist": "1100.0.
|
|
54
|
-
"@pnpm/installing.linking.
|
|
55
|
-
"@pnpm/installing.
|
|
56
|
-
"@pnpm/
|
|
57
|
-
"@pnpm/lockfile.
|
|
58
|
-
"@pnpm/
|
|
59
|
-
"@pnpm/lockfile.utils": "1100.0.
|
|
60
|
-
"@pnpm/
|
|
61
|
-
"@pnpm/
|
|
62
|
-
"@pnpm/
|
|
63
|
-
"@pnpm/
|
|
64
|
-
"@pnpm/
|
|
65
|
-
"@pnpm/
|
|
66
|
-
"@pnpm/
|
|
67
|
-
"@pnpm/
|
|
50
|
+
"@pnpm/exec.lifecycle": "1100.1.0",
|
|
51
|
+
"@pnpm/fs.symlink-dependency": "1100.0.10",
|
|
52
|
+
"@pnpm/installing.linking.direct-dep-linker": "1100.0.10",
|
|
53
|
+
"@pnpm/installing.linking.hoist": "1100.0.15",
|
|
54
|
+
"@pnpm/installing.linking.modules-cleaner": "1100.1.8",
|
|
55
|
+
"@pnpm/installing.linking.real-hoist": "1100.1.3",
|
|
56
|
+
"@pnpm/installing.package-requester": "1102.0.0",
|
|
57
|
+
"@pnpm/lockfile.filtering": "1100.1.7",
|
|
58
|
+
"@pnpm/installing.modules-yaml": "1100.0.9",
|
|
59
|
+
"@pnpm/lockfile.utils": "1100.0.13",
|
|
60
|
+
"@pnpm/lockfile.to-pnp": "1100.1.0",
|
|
61
|
+
"@pnpm/patching.config": "1100.0.8",
|
|
62
|
+
"@pnpm/store.controller-types": "1100.1.5",
|
|
63
|
+
"@pnpm/pkg-manifest.reader": "1100.0.8",
|
|
64
|
+
"@pnpm/lockfile.fs": "1100.1.6",
|
|
65
|
+
"@pnpm/types": "1101.3.2",
|
|
66
|
+
"@pnpm/workspace.project-manifest-reader": "1100.0.13",
|
|
67
|
+
"@pnpm/bins.linker": "1100.0.15"
|
|
68
68
|
},
|
|
69
69
|
"peerDependencies": {
|
|
70
|
-
"@pnpm/logger": "^
|
|
71
|
-
"@pnpm/worker": "^1100.1
|
|
70
|
+
"@pnpm/logger": "^1100.0.0",
|
|
71
|
+
"@pnpm/worker": "^1100.2.1"
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
|
-
"@jest/globals": "30.
|
|
74
|
+
"@jest/globals": "30.4.1",
|
|
75
75
|
"@types/fs-extra": "^11.0.4",
|
|
76
76
|
"@types/ramda": "0.31.1",
|
|
77
|
-
"concurrently": "
|
|
77
|
+
"concurrently": "10.0.3",
|
|
78
78
|
"isexe": "4.0.0",
|
|
79
79
|
"load-json-file": "^7.0.1",
|
|
80
80
|
"tempy": "3.0.0",
|
|
81
81
|
"write-json-file": "^7.0.0",
|
|
82
|
-
"@pnpm/assert-project": "1100.0.15",
|
|
83
|
-
"@pnpm/installing.deps-restorer": "1101.1.11",
|
|
84
82
|
"@pnpm/crypto.object-hasher": "1100.0.0",
|
|
85
|
-
"@pnpm/installing.read-projects-context": "1100.0.
|
|
83
|
+
"@pnpm/installing.read-projects-context": "1100.0.16",
|
|
84
|
+
"@pnpm/assert-project": "1100.0.16",
|
|
86
85
|
"@pnpm/logger": "1100.0.0",
|
|
87
|
-
"@pnpm/
|
|
88
|
-
"@pnpm/
|
|
89
|
-
"@pnpm/store.index": "1100.
|
|
90
|
-
"@pnpm/test-ipc-server": "1100.0.0",
|
|
86
|
+
"@pnpm/store.cafs": "1100.1.10",
|
|
87
|
+
"@pnpm/prepare": "1100.0.16",
|
|
88
|
+
"@pnpm/store.index": "1100.2.0",
|
|
91
89
|
"@pnpm/store.path": "1100.0.1",
|
|
92
|
-
"@pnpm/testing.registry-mock": "1100.0.5",
|
|
93
90
|
"@pnpm/test-fixtures": "1100.0.0",
|
|
94
|
-
"@pnpm/
|
|
91
|
+
"@pnpm/test-ipc-server": "1100.0.0",
|
|
92
|
+
"@pnpm/installing.deps-restorer": "1102.1.0",
|
|
93
|
+
"@pnpm/testing.temp-store": "1100.1.10",
|
|
94
|
+
"@pnpm/testing.registry-mock": "1100.0.6"
|
|
95
95
|
},
|
|
96
96
|
"engines": {
|
|
97
97
|
"node": ">=22.13"
|