@pnpm/deps.graph-builder 1002.0.4 → 1002.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/iteratePkgsForVirtualStore.d.ts +16 -0
- package/lib/iteratePkgsForVirtualStore.js +81 -0
- package/lib/iteratePkgsForVirtualStore.js.map +1 -0
- package/lib/lockfileToDepGraph.d.ts +3 -1
- package/lib/lockfileToDepGraph.js +77 -90
- package/lib/lockfileToDepGraph.js.map +1 -1
- package/package.json +8 -7
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type PkgMeta } from '@pnpm/calc-dep-state';
|
|
2
|
+
import { type LockfileObject, type PackageSnapshot } from '@pnpm/lockfile.fs';
|
|
3
|
+
import { type PkgIdWithPatchHash } from '@pnpm/types';
|
|
4
|
+
interface PkgSnapshotWithLocation {
|
|
5
|
+
pkgMeta: PkgMetaAndSnapshot;
|
|
6
|
+
dirNameInVirtualStore: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function iteratePkgsForVirtualStore(lockfile: LockfileObject, opts: {
|
|
9
|
+
enableGlobalVirtualStore?: boolean;
|
|
10
|
+
virtualStoreDirMaxLength: number;
|
|
11
|
+
}): IterableIterator<PkgSnapshotWithLocation>;
|
|
12
|
+
interface PkgMetaAndSnapshot extends PkgMeta {
|
|
13
|
+
pkgSnapshot: PackageSnapshot;
|
|
14
|
+
pkgIdWithPatchHash: PkgIdWithPatchHash;
|
|
15
|
+
}
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.iteratePkgsForVirtualStore = iteratePkgsForVirtualStore;
|
|
27
|
+
const calc_dep_state_1 = require("@pnpm/calc-dep-state");
|
|
28
|
+
const lockfile_utils_1 = require("@pnpm/lockfile.utils");
|
|
29
|
+
const dp = __importStar(require("@pnpm/dependency-path"));
|
|
30
|
+
function* iteratePkgsForVirtualStore(lockfile, opts) {
|
|
31
|
+
if (opts.enableGlobalVirtualStore) {
|
|
32
|
+
for (const { hash, pkgMeta } of hashDependencyPaths(lockfile)) {
|
|
33
|
+
yield {
|
|
34
|
+
dirNameInVirtualStore: hash,
|
|
35
|
+
pkgMeta,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
else if (lockfile.packages) {
|
|
40
|
+
for (const depPath in lockfile.packages) {
|
|
41
|
+
if (Object.prototype.hasOwnProperty.call(lockfile.packages, depPath)) {
|
|
42
|
+
const pkgSnapshot = lockfile.packages[depPath];
|
|
43
|
+
const { name, version } = (0, lockfile_utils_1.nameVerFromPkgSnapshot)(depPath, pkgSnapshot);
|
|
44
|
+
yield {
|
|
45
|
+
pkgMeta: {
|
|
46
|
+
depPath: depPath,
|
|
47
|
+
pkgIdWithPatchHash: dp.getPkgIdWithPatchHash(depPath),
|
|
48
|
+
name,
|
|
49
|
+
version,
|
|
50
|
+
pkgSnapshot,
|
|
51
|
+
},
|
|
52
|
+
dirNameInVirtualStore: dp.depPathToFilename(depPath, opts.virtualStoreDirMaxLength),
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
function hashDependencyPaths(lockfile) {
|
|
59
|
+
const graph = (0, calc_dep_state_1.lockfileToDepGraph)(lockfile);
|
|
60
|
+
return (0, calc_dep_state_1.iterateHashedGraphNodes)(graph, iteratePkgMeta(lockfile, graph));
|
|
61
|
+
}
|
|
62
|
+
function* iteratePkgMeta(lockfile, graph) {
|
|
63
|
+
if (lockfile.packages == null) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
for (const depPath in lockfile.packages) {
|
|
67
|
+
if (!Object.prototype.hasOwnProperty.call(lockfile.packages, depPath)) {
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
const pkgSnapshot = lockfile.packages[depPath];
|
|
71
|
+
const { name, version } = (0, lockfile_utils_1.nameVerFromPkgSnapshot)(depPath, pkgSnapshot);
|
|
72
|
+
yield {
|
|
73
|
+
name,
|
|
74
|
+
version,
|
|
75
|
+
depPath: depPath,
|
|
76
|
+
pkgIdWithPatchHash: graph[depPath].pkgIdWithPatchHash ?? dp.getPkgIdWithPatchHash(depPath),
|
|
77
|
+
pkgSnapshot,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=iteratePkgsForVirtualStore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"iteratePkgsForVirtualStore.js","sourceRoot":"","sources":["../src/iteratePkgsForVirtualStore.ts"],"names":[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,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAA;AACxE,CAAC;AAED,QAAS,CAAC,CAAC,cAAc,CAAE,QAAwB,EAAE,KAAyB;IAC5E,IAAI,QAAQ,CAAC,QAAQ,IAAI,IAAI,EAAE,CAAC;QAC9B,OAAM;IACR,CAAC;IACD,KAAK,MAAM,OAAO,IAAI,QAAQ,CAAC,QAAQ,EAAE,CAAC;QACxC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,EAAE,CAAC;YACtE,SAAQ;QACV,CAAC;QACD,MAAM,WAAW,GAAG,QAAQ,CAAC,QAAQ,CAAC,OAAkB,CAAC,CAAA;QACzD,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,IAAA,uCAAsB,EAAC,OAAO,EAAE,WAAW,CAAC,CAAA;QACtE,MAAM;YACJ,IAAI;YACJ,OAAO;YACP,OAAO,EAAE,OAAkB;YAC3B,kBAAkB,EAAE,KAAK,CAAC,OAAkB,CAAC,CAAC,kBAAkB,IAAI,EAAE,CAAC,qBAAqB,CAAC,OAAkB,CAAC;YAChH,WAAW;SACZ,CAAA;IACH,CAAC;AACH,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type LockfileObject } from '@pnpm/lockfile.fs';
|
|
1
|
+
import { type LockfileResolution, type LockfileObject } from '@pnpm/lockfile.fs';
|
|
2
2
|
import { type IncludedDependencies } from '@pnpm/modules-yaml';
|
|
3
3
|
import { type PatchGroupRecord } from '@pnpm/patching.config';
|
|
4
4
|
import { type PatchInfo } from '@pnpm/patching.types';
|
|
@@ -21,12 +21,14 @@ export interface DependenciesGraphNode {
|
|
|
21
21
|
hasBin: boolean;
|
|
22
22
|
filesIndexFile?: string;
|
|
23
23
|
patch?: PatchInfo;
|
|
24
|
+
resolution: LockfileResolution;
|
|
24
25
|
}
|
|
25
26
|
export interface DependenciesGraph {
|
|
26
27
|
[depPath: string]: DependenciesGraphNode;
|
|
27
28
|
}
|
|
28
29
|
export interface LockfileToDepGraphOptions {
|
|
29
30
|
autoInstallPeers: boolean;
|
|
31
|
+
enableGlobalVirtualStore?: boolean;
|
|
30
32
|
engineStrict: boolean;
|
|
31
33
|
force: boolean;
|
|
32
34
|
importerIds: ProjectId[];
|
|
@@ -38,22 +38,56 @@ const dp = __importStar(require("@pnpm/dependency-path"));
|
|
|
38
38
|
const path_exists_1 = __importDefault(require("path-exists"));
|
|
39
39
|
const equals_1 = __importDefault(require("ramda/src/equals"));
|
|
40
40
|
const isEmpty_1 = __importDefault(require("ramda/src/isEmpty"));
|
|
41
|
+
const iteratePkgsForVirtualStore_1 = require("./iteratePkgsForVirtualStore");
|
|
41
42
|
const brokenModulesLogger = (0, logger_1.logger)('_broken_node_modules');
|
|
42
43
|
async function lockfileToDepGraph(lockfile, currentLockfile, opts) {
|
|
44
|
+
const { graph, locationByDepPath, } = await buildGraphFromPackages(lockfile, currentLockfile, opts);
|
|
45
|
+
const _getChildrenPaths = getChildrenPaths.bind(null, {
|
|
46
|
+
force: opts.force,
|
|
47
|
+
graph,
|
|
48
|
+
lockfileDir: opts.lockfileDir,
|
|
49
|
+
registries: opts.registries,
|
|
50
|
+
sideEffectsCacheRead: opts.sideEffectsCacheRead,
|
|
51
|
+
skipped: opts.skipped,
|
|
52
|
+
storeController: opts.storeController,
|
|
53
|
+
storeDir: opts.storeDir,
|
|
54
|
+
virtualStoreDir: opts.virtualStoreDir,
|
|
55
|
+
virtualStoreDirMaxLength: opts.virtualStoreDirMaxLength,
|
|
56
|
+
locationByDepPath,
|
|
57
|
+
});
|
|
58
|
+
for (const node of Object.values(graph)) {
|
|
59
|
+
const pkgSnapshot = lockfile.packages[node.depPath];
|
|
60
|
+
const allDeps = {
|
|
61
|
+
...pkgSnapshot.dependencies,
|
|
62
|
+
...(opts.include.optionalDependencies ? pkgSnapshot.optionalDependencies : {}),
|
|
63
|
+
};
|
|
64
|
+
const peerDeps = pkgSnapshot.peerDependencies ? new Set(Object.keys(pkgSnapshot.peerDependencies)) : null;
|
|
65
|
+
node.children = _getChildrenPaths(allDeps, peerDeps, '.');
|
|
66
|
+
}
|
|
67
|
+
const directDependenciesByImporterId = {};
|
|
68
|
+
for (const importerId of opts.importerIds) {
|
|
69
|
+
const projectSnapshot = lockfile.importers[importerId];
|
|
70
|
+
const rootDeps = {
|
|
71
|
+
...(opts.include.devDependencies ? projectSnapshot.devDependencies : {}),
|
|
72
|
+
...(opts.include.dependencies ? projectSnapshot.dependencies : {}),
|
|
73
|
+
...(opts.include.optionalDependencies ? projectSnapshot.optionalDependencies : {}),
|
|
74
|
+
};
|
|
75
|
+
directDependenciesByImporterId[importerId] = _getChildrenPaths(rootDeps, null, importerId);
|
|
76
|
+
}
|
|
77
|
+
return { graph, directDependenciesByImporterId };
|
|
78
|
+
}
|
|
79
|
+
async function buildGraphFromPackages(lockfile, currentLockfile, opts) {
|
|
43
80
|
const currentPackages = currentLockfile?.packages ?? {};
|
|
44
81
|
const graph = {};
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
82
|
+
const locationByDepPath = {};
|
|
83
|
+
const _getPatchInfo = patching_config_1.getPatchInfo.bind(null, opts.patchedDependencies);
|
|
84
|
+
const promises = [];
|
|
85
|
+
const pkgSnapshotsWithLocations = (0, iteratePkgsForVirtualStore_1.iteratePkgsForVirtualStore)(lockfile, opts);
|
|
86
|
+
for (const { dirNameInVirtualStore, pkgMeta } of pkgSnapshotsWithLocations) {
|
|
87
|
+
promises.push((async () => {
|
|
88
|
+
const { pkgIdWithPatchHash, name: pkgName, version: pkgVersion, depPath, pkgSnapshot } = pkgMeta;
|
|
50
89
|
if (opts.skipped.has(depPath))
|
|
51
90
|
return;
|
|
52
|
-
// TODO: optimize. This info can be already returned by pkgSnapshotToResolution()
|
|
53
|
-
const { name: pkgName, version: pkgVersion } = (0, lockfile_utils_1.nameVerFromPkgSnapshot)(depPath, pkgSnapshot);
|
|
54
|
-
const modules = path_1.default.join(opts.virtualStoreDir, dp.depPathToFilename(depPath, opts.virtualStoreDirMaxLength), 'node_modules');
|
|
55
|
-
const packageId = (0, lockfile_utils_1.packageIdFromSnapshot)(depPath, pkgSnapshot);
|
|
56
|
-
const pkgIdWithPatchHash = dp.getPkgIdWithPatchHash(depPath);
|
|
57
91
|
const pkg = {
|
|
58
92
|
name: pkgName,
|
|
59
93
|
version: pkgVersion,
|
|
@@ -62,65 +96,52 @@ async function lockfileToDepGraph(lockfile, currentLockfile, opts) {
|
|
|
62
96
|
os: pkgSnapshot.os,
|
|
63
97
|
libc: pkgSnapshot.libc,
|
|
64
98
|
};
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
99
|
+
const packageId = (0, lockfile_utils_1.packageIdFromSnapshot)(depPath, pkgSnapshot);
|
|
100
|
+
if (!opts.force && (0, package_is_installable_1.packageIsInstallable)(packageId, pkg, {
|
|
101
|
+
engineStrict: opts.engineStrict,
|
|
102
|
+
lockfileDir: opts.lockfileDir,
|
|
103
|
+
nodeVersion: opts.nodeVersion,
|
|
104
|
+
optional: pkgSnapshot.optional === true,
|
|
105
|
+
supportedArchitectures: opts.supportedArchitectures,
|
|
106
|
+
}) === false) {
|
|
73
107
|
opts.skipped.add(depPath);
|
|
74
108
|
return;
|
|
75
109
|
}
|
|
76
|
-
const dir = path_1.default.join(modules, pkgName);
|
|
77
110
|
const depIsPresent = !('directory' in pkgSnapshot.resolution && pkgSnapshot.resolution.directory != null) &&
|
|
78
|
-
currentPackages[depPath] &&
|
|
111
|
+
currentPackages[depPath] &&
|
|
112
|
+
(0, equals_1.default)(currentPackages[depPath].dependencies, pkgSnapshot.dependencies);
|
|
113
|
+
const modules = path_1.default.join(opts.virtualStoreDir, dirNameInVirtualStore, 'node_modules');
|
|
114
|
+
const dir = path_1.default.join(modules, pkgName);
|
|
115
|
+
locationByDepPath[depPath] = dir;
|
|
79
116
|
let dirExists;
|
|
80
|
-
if (depIsPresent &&
|
|
81
|
-
(0, isEmpty_1.default)(
|
|
117
|
+
if (depIsPresent &&
|
|
118
|
+
(0, isEmpty_1.default)(currentPackages[depPath].optionalDependencies ?? {}) &&
|
|
119
|
+
(0, isEmpty_1.default)(pkgSnapshot.optionalDependencies ?? {})) {
|
|
82
120
|
dirExists = await (0, path_exists_1.default)(dir);
|
|
83
|
-
if (dirExists)
|
|
121
|
+
if (dirExists)
|
|
84
122
|
return;
|
|
85
|
-
}
|
|
86
|
-
brokenModulesLogger.debug({
|
|
87
|
-
missing: dir,
|
|
88
|
-
});
|
|
123
|
+
brokenModulesLogger.debug({ missing: dir });
|
|
89
124
|
}
|
|
90
125
|
let fetchResponse;
|
|
91
|
-
if (depIsPresent && (0, equals_1.default)(currentPackages[depPath].optionalDependencies,
|
|
126
|
+
if (depIsPresent && (0, equals_1.default)(currentPackages[depPath].optionalDependencies, pkgSnapshot.optionalDependencies)) {
|
|
92
127
|
if (dirExists ?? await (0, path_exists_1.default)(dir)) {
|
|
93
128
|
fetchResponse = {};
|
|
94
129
|
}
|
|
95
130
|
else {
|
|
96
|
-
brokenModulesLogger.debug({
|
|
97
|
-
missing: dir,
|
|
98
|
-
});
|
|
131
|
+
brokenModulesLogger.debug({ missing: dir });
|
|
99
132
|
}
|
|
100
133
|
}
|
|
101
134
|
if (!fetchResponse) {
|
|
102
135
|
const resolution = (0, lockfile_utils_1.pkgSnapshotToResolution)(depPath, pkgSnapshot, opts.registries);
|
|
103
|
-
core_loggers_1.progressLogger.debug({
|
|
104
|
-
packageId,
|
|
105
|
-
requester: opts.lockfileDir,
|
|
106
|
-
status: 'resolved',
|
|
107
|
-
});
|
|
136
|
+
core_loggers_1.progressLogger.debug({ packageId, requester: opts.lockfileDir, status: 'resolved' });
|
|
108
137
|
try {
|
|
109
|
-
fetchResponse = opts.storeController.fetchPackage({
|
|
138
|
+
fetchResponse = await opts.storeController.fetchPackage({
|
|
110
139
|
force: false,
|
|
111
140
|
lockfileDir: opts.lockfileDir,
|
|
112
141
|
ignoreScripts: opts.ignoreScripts,
|
|
113
|
-
pkg: {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
},
|
|
117
|
-
expectedPkg: {
|
|
118
|
-
name: pkgName,
|
|
119
|
-
version: pkgVersion,
|
|
120
|
-
},
|
|
121
|
-
}); // eslint-disable-line
|
|
122
|
-
if (fetchResponse instanceof Promise)
|
|
123
|
-
fetchResponse = await fetchResponse;
|
|
142
|
+
pkg: { id: packageId, resolution },
|
|
143
|
+
expectedPkg: { name: pkgName, version: pkgVersion },
|
|
144
|
+
});
|
|
124
145
|
}
|
|
125
146
|
catch (err) {
|
|
126
147
|
if (pkgSnapshot.optional)
|
|
@@ -131,6 +152,7 @@ async function lockfileToDepGraph(lockfile, currentLockfile, opts) {
|
|
|
131
152
|
graph[dir] = {
|
|
132
153
|
children: {},
|
|
133
154
|
pkgIdWithPatchHash,
|
|
155
|
+
resolution: pkgSnapshot.resolution,
|
|
134
156
|
depPath,
|
|
135
157
|
dir,
|
|
136
158
|
fetching: fetchResponse.fetching,
|
|
@@ -143,41 +165,10 @@ async function lockfileToDepGraph(lockfile, currentLockfile, opts) {
|
|
|
143
165
|
optionalDependencies: new Set(Object.keys(pkgSnapshot.optionalDependencies ?? {})),
|
|
144
166
|
patch: _getPatchInfo(pkgName, pkgVersion),
|
|
145
167
|
};
|
|
146
|
-
|
|
147
|
-
}));
|
|
148
|
-
const ctx = {
|
|
149
|
-
force: opts.force,
|
|
150
|
-
graph,
|
|
151
|
-
lockfileDir: opts.lockfileDir,
|
|
152
|
-
pkgSnapshotsByDepPaths: lockfile.packages,
|
|
153
|
-
registries: opts.registries,
|
|
154
|
-
sideEffectsCacheRead: opts.sideEffectsCacheRead,
|
|
155
|
-
skipped: opts.skipped,
|
|
156
|
-
storeController: opts.storeController,
|
|
157
|
-
storeDir: opts.storeDir,
|
|
158
|
-
virtualStoreDir: opts.virtualStoreDir,
|
|
159
|
-
virtualStoreDirMaxLength: opts.virtualStoreDirMaxLength,
|
|
160
|
-
};
|
|
161
|
-
for (const [dir, node] of Object.entries(graph)) {
|
|
162
|
-
const pkgSnapshot = pkgSnapshotByLocation[dir];
|
|
163
|
-
const allDeps = {
|
|
164
|
-
...pkgSnapshot.dependencies,
|
|
165
|
-
...(opts.include.optionalDependencies ? pkgSnapshot.optionalDependencies : {}),
|
|
166
|
-
};
|
|
167
|
-
const peerDeps = pkgSnapshot.peerDependencies ? new Set(Object.keys(pkgSnapshot.peerDependencies)) : null;
|
|
168
|
-
node.children = getChildrenPaths(ctx, allDeps, peerDeps, '.');
|
|
169
|
-
}
|
|
170
|
-
for (const importerId of opts.importerIds) {
|
|
171
|
-
const projectSnapshot = lockfile.importers[importerId];
|
|
172
|
-
const rootDeps = {
|
|
173
|
-
...(opts.include.devDependencies ? projectSnapshot.devDependencies : {}),
|
|
174
|
-
...(opts.include.dependencies ? projectSnapshot.dependencies : {}),
|
|
175
|
-
...(opts.include.optionalDependencies ? projectSnapshot.optionalDependencies : {}),
|
|
176
|
-
};
|
|
177
|
-
directDependenciesByImporterId[importerId] = getChildrenPaths(ctx, rootDeps, null, importerId);
|
|
178
|
-
}
|
|
168
|
+
})());
|
|
179
169
|
}
|
|
180
|
-
|
|
170
|
+
await Promise.all(promises);
|
|
171
|
+
return { graph, locationByDepPath };
|
|
181
172
|
}
|
|
182
173
|
function getChildrenPaths(ctx, allDeps, peerDeps, importerId) {
|
|
183
174
|
const children = {};
|
|
@@ -188,15 +179,11 @@ function getChildrenPaths(ctx, allDeps, peerDeps, importerId) {
|
|
|
188
179
|
continue;
|
|
189
180
|
}
|
|
190
181
|
const childRelDepPath = dp.refToRelative(ref, alias);
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
children[alias] = ctx.graph[childRelDepPath].dir;
|
|
182
|
+
if (ctx.locationByDepPath[childRelDepPath]) {
|
|
183
|
+
children[alias] = ctx.locationByDepPath[childRelDepPath];
|
|
194
184
|
}
|
|
195
|
-
else if (
|
|
196
|
-
|
|
197
|
-
continue;
|
|
198
|
-
const pkgName = (0, lockfile_utils_1.nameVerFromPkgSnapshot)(childRelDepPath, childPkgSnapshot).name;
|
|
199
|
-
children[alias] = path_1.default.join(ctx.virtualStoreDir, dp.depPathToFilename(childRelDepPath, ctx.virtualStoreDirMaxLength), 'node_modules', pkgName);
|
|
185
|
+
else if (ctx.graph[childRelDepPath]) {
|
|
186
|
+
children[alias] = ctx.graph[childRelDepPath].dir;
|
|
200
187
|
}
|
|
201
188
|
else if (ref.indexOf('file:') === 0) {
|
|
202
189
|
children[alias] = path_1.default.resolve(ctx.lockfileDir, ref.slice(5));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lockfileToDepGraph.js","sourceRoot":"","sources":["../src/lockfileToDepGraph.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"lockfileToDepGraph.js","sourceRoot":"","sources":["../src/lockfileToDepGraph.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6FA,gDA8CC;AA3ID,gDAAuB;AACvB,+CAAiD;AACjD,qDAE2B;AAE3B,yDAG6B;AAC7B,yCAAqC;AAErC,yEAAmE;AACnE,2DAA2E;AAQ3E,0DAA2C;AAC3C,8DAAoC;AACpC,8DAAqC;AACrC,gEAAuC;AACvC,6EAAyE;AAEzE,MAAM,mBAAmB,GAAG,IAAA,eAAM,EAAC,sBAAsB,CAAC,CAAA;AAkEnD,KAAK,UAAU,kBAAkB,CACtC,QAAwB,EACxB,eAAsC,EACtC,IAA+B;IAE/B,MAAM,EACJ,KAAK,EACL,iBAAiB,GAClB,GAAG,MAAM,sBAAsB,CAAC,QAAQ,EAAE,eAAe,EAAE,IAAI,CAAC,CAAA;IAEjE,MAAM,iBAAiB,GAAG,gBAAgB,CAAC,IAAI,CAAC,IAAI,EAAE;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 -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pnpm/deps.graph-builder",
|
|
3
|
-
"version": "1002.0
|
|
3
|
+
"version": "1002.1.0",
|
|
4
4
|
"description": "A package for building a dependency graph from a lockfile",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pnpm",
|
|
@@ -26,23 +26,24 @@
|
|
|
26
26
|
"path-exists": "^4.0.0",
|
|
27
27
|
"ramda": "npm:@pnpm/ramda@0.28.1",
|
|
28
28
|
"@pnpm/constants": "1001.1.0",
|
|
29
|
-
"@pnpm/dependency-path": "1000.0.9",
|
|
30
|
-
"@pnpm/lockfile.utils": "1001.0.11",
|
|
31
29
|
"@pnpm/core-loggers": "1001.0.1",
|
|
32
|
-
"@pnpm/
|
|
30
|
+
"@pnpm/calc-dep-state": "1002.0.0",
|
|
31
|
+
"@pnpm/dependency-path": "1000.0.9",
|
|
32
|
+
"@pnpm/lockfile.fs": "1001.1.13",
|
|
33
|
+
"@pnpm/lockfile.utils": "1001.0.12",
|
|
33
34
|
"@pnpm/modules-yaml": "1000.3.3",
|
|
34
35
|
"@pnpm/package-is-installable": "1000.0.10",
|
|
35
36
|
"@pnpm/patching.config": "1001.0.3",
|
|
36
37
|
"@pnpm/patching.types": "1000.1.0",
|
|
37
|
-
"@pnpm/types": "
|
|
38
|
-
"@pnpm/
|
|
38
|
+
"@pnpm/store-controller-types": "1003.0.3",
|
|
39
|
+
"@pnpm/types": "1000.6.0"
|
|
39
40
|
},
|
|
40
41
|
"peerDependencies": {
|
|
41
42
|
"@pnpm/logger": ">=1001.0.0 <1002.0.0"
|
|
42
43
|
},
|
|
43
44
|
"devDependencies": {
|
|
44
45
|
"@types/ramda": "0.29.12",
|
|
45
|
-
"@pnpm/deps.graph-builder": "1002.0
|
|
46
|
+
"@pnpm/deps.graph-builder": "1002.1.0",
|
|
46
47
|
"@pnpm/logger": "1001.0.0"
|
|
47
48
|
},
|
|
48
49
|
"engines": {
|