@vltpkg/graph 1.0.0-rc.1 → 1.0.0-rc.10
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/dist/esm/actual/load.d.ts.map +1 -1
- package/dist/esm/actual/load.js +35 -14
- package/dist/esm/actual/load.js.map +1 -1
- package/dist/esm/browser.d.ts +1 -1
- package/dist/esm/diff.d.ts +2 -0
- package/dist/esm/diff.d.ts.map +1 -1
- package/dist/esm/edge.d.ts +1 -0
- package/dist/esm/edge.d.ts.map +1 -1
- package/dist/esm/edge.js +4 -0
- package/dist/esm/edge.js.map +1 -1
- package/dist/esm/fixup-added-names.d.ts +16 -0
- package/dist/esm/fixup-added-names.d.ts.map +1 -0
- package/dist/esm/fixup-added-names.js +31 -0
- package/dist/esm/fixup-added-names.js.map +1 -0
- package/dist/esm/graph.d.ts +18 -4
- package/dist/esm/graph.d.ts.map +1 -1
- package/dist/esm/graph.js +63 -40
- package/dist/esm/graph.js.map +1 -1
- package/dist/esm/ideal/append-nodes.d.ts +2 -1
- package/dist/esm/ideal/append-nodes.d.ts.map +1 -1
- package/dist/esm/ideal/append-nodes.js +183 -78
- package/dist/esm/ideal/append-nodes.js.map +1 -1
- package/dist/esm/ideal/build-ideal-from-starting-graph.d.ts +4 -4
- package/dist/esm/ideal/build-ideal-from-starting-graph.d.ts.map +1 -1
- package/dist/esm/ideal/build-ideal-from-starting-graph.js +34 -19
- package/dist/esm/ideal/build-ideal-from-starting-graph.js.map +1 -1
- package/dist/esm/ideal/build.d.ts.map +1 -1
- package/dist/esm/ideal/build.js +29 -2
- package/dist/esm/ideal/build.js.map +1 -1
- package/dist/esm/ideal/get-importer-specs.d.ts +9 -2
- package/dist/esm/ideal/get-importer-specs.d.ts.map +1 -1
- package/dist/esm/ideal/get-importer-specs.js +80 -5
- package/dist/esm/ideal/get-importer-specs.js.map +1 -1
- package/dist/esm/ideal/get-ordered-dependencies.d.ts +10 -0
- package/dist/esm/ideal/get-ordered-dependencies.d.ts.map +1 -0
- package/dist/esm/ideal/get-ordered-dependencies.js +42 -0
- package/dist/esm/ideal/get-ordered-dependencies.js.map +1 -0
- package/dist/esm/ideal/peers.d.ts +71 -0
- package/dist/esm/ideal/peers.d.ts.map +1 -0
- package/dist/esm/ideal/peers.js +318 -0
- package/dist/esm/ideal/peers.js.map +1 -0
- package/dist/esm/ideal/refresh-ideal-graph.d.ts +48 -0
- package/dist/esm/ideal/refresh-ideal-graph.d.ts.map +1 -0
- package/dist/esm/ideal/refresh-ideal-graph.js +79 -0
- package/dist/esm/ideal/refresh-ideal-graph.js.map +1 -0
- package/dist/esm/ideal/types.d.ts +78 -1
- package/dist/esm/ideal/types.d.ts.map +1 -1
- package/dist/esm/ideal/types.js.map +1 -1
- package/dist/esm/index.d.ts +2 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/install.d.ts +3 -2
- package/dist/esm/install.d.ts.map +1 -1
- package/dist/esm/install.js +30 -6
- package/dist/esm/install.js.map +1 -1
- package/dist/esm/lockfile/load-edges.d.ts.map +1 -1
- package/dist/esm/lockfile/load-edges.js +4 -3
- package/dist/esm/lockfile/load-edges.js.map +1 -1
- package/dist/esm/lockfile/load-nodes.d.ts +1 -1
- package/dist/esm/lockfile/load-nodes.d.ts.map +1 -1
- package/dist/esm/lockfile/load-nodes.js +16 -4
- package/dist/esm/lockfile/load-nodes.js.map +1 -1
- package/dist/esm/lockfile/load.d.ts +2 -2
- package/dist/esm/lockfile/load.d.ts.map +1 -1
- package/dist/esm/lockfile/load.js +6 -29
- package/dist/esm/lockfile/load.js.map +1 -1
- package/dist/esm/lockfile/save.d.ts +5 -1
- package/dist/esm/lockfile/save.d.ts.map +1 -1
- package/dist/esm/lockfile/save.js +23 -9
- package/dist/esm/lockfile/save.js.map +1 -1
- package/dist/esm/node.d.ts +14 -0
- package/dist/esm/node.d.ts.map +1 -1
- package/dist/esm/node.js +21 -0
- package/dist/esm/node.js.map +1 -1
- package/dist/esm/reify/add-edges.d.ts +1 -1
- package/dist/esm/reify/add-edges.d.ts.map +1 -1
- package/dist/esm/reify/add-edges.js +2 -1
- package/dist/esm/reify/add-edges.js.map +1 -1
- package/dist/esm/reify/extract-node.d.ts.map +1 -1
- package/dist/esm/reify/extract-node.js +10 -2
- package/dist/esm/reify/extract-node.js.map +1 -1
- package/dist/esm/reify/index.js +1 -1
- package/dist/esm/reify/index.js.map +1 -1
- package/dist/esm/reify/update-importers-package-json.d.ts +1 -1
- package/dist/esm/reify/update-importers-package-json.d.ts.map +1 -1
- package/dist/esm/reify/update-importers-package-json.js +19 -16
- package/dist/esm/reify/update-importers-package-json.js.map +1 -1
- package/dist/esm/stringify-node.d.ts.map +1 -1
- package/dist/esm/stringify-node.js +10 -1
- package/dist/esm/stringify-node.js.map +1 -1
- package/dist/esm/uninstall.d.ts.map +1 -1
- package/dist/esm/uninstall.js +10 -0
- package/dist/esm/uninstall.js.map +1 -1
- package/dist/esm/update.d.ts.map +1 -1
- package/dist/esm/update.js +10 -0
- package/dist/esm/update.js.map +1 -1
- package/dist/esm/visualization/human-readable-output.d.ts.map +1 -1
- package/dist/esm/visualization/human-readable-output.js +7 -2
- package/dist/esm/visualization/human-readable-output.js.map +1 -1
- package/dist/esm/visualization/json-output.d.ts +2 -1
- package/dist/esm/visualization/json-output.d.ts.map +1 -1
- package/dist/esm/visualization/json-output.js +2 -2
- package/dist/esm/visualization/json-output.js.map +1 -1
- package/dist/esm/visualization/mermaid-output.d.ts.map +1 -1
- package/dist/esm/visualization/mermaid-output.js +57 -16
- package/dist/esm/visualization/mermaid-output.js.map +1 -1
- package/package.json +31 -31
- package/dist/esm/ideal/add-nodes.d.ts +0 -34
- package/dist/esm/ideal/add-nodes.d.ts.map +0 -1
- package/dist/esm/ideal/add-nodes.js +0 -39
- package/dist/esm/ideal/add-nodes.js.map +0 -1
- package/dist/esm/ideal/remove-nodes.d.ts +0 -7
- package/dist/esm/ideal/remove-nodes.d.ts.map +0 -1
- package/dist/esm/ideal/remove-nodes.js +0 -19
- package/dist/esm/ideal/remove-nodes.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load.d.ts","sourceRoot":"","sources":["../../../src/actual/load.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"load.d.ts","sourceRoot":"","sources":["../../../src/actual/load.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAQnC,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAGnC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAC3C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AACvD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAA;AACvD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAEnD,OAAO,KAAK,EACV,aAAa,EAEd,MAAM,iBAAiB,CAAA;AAGxB,MAAM,MAAM,WAAW,GAAG,WAAW,GAAG;IACtC;;OAEG;IACH,WAAW,EAAE,MAAM,CAAA;IACnB;;OAEG;IACH,YAAY,CAAC,EAAE,kBAAkB,CAAA;IACjC;;OAEG;IACH,SAAS,CAAC,EAAE,aAAa,CAAA;IACzB;;OAEG;IACH,QAAQ,CAAC,EAAE,QAAQ,CAAA;IACnB;;OAEG;IACH,WAAW,EAAE,WAAW,CAAA;IACxB;;OAEG;IACH,MAAM,EAAE,UAAU,CAAA;IAClB;;;;;;;OAOG;IACH,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB;;;OAGG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B;;OAEG;IACH,iCAAiC,CAAC,EAAE,OAAO,CAAA;IAE3C;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAA;CACvB,CAAA;AAED,MAAM,MAAM,SAAS,GAAG;IACtB,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,IAAI,CAAA;CACf,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAAA;CAC9C,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,mBAAmB,QACzB,OAAO,KACX,GAAG,IAAI,iBAGe,CAAA;AAEzB;;;GAGG;AACH,eAAO,MAAM,mBAAmB,QACzB,OAAO,KACX,iBAKF,CAAA;AAUD;;;GAGG;AACH,eAAO,MAAM,cAAc,SACnB,IAAI,QACJ,IAAI,KACT,KAAK,GAAG,SAGQ,CAAA;AA2SnB;;;;GAIG;AACH,eAAO,MAAM,IAAI,YAAa,WAAW,KAAG,KAsG3C,CAAA"}
|
package/dist/esm/actual/load.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { asDepID, hydrate, joinDepIDTuple } from '@vltpkg/dep-id';
|
|
1
|
+
import { asDepID, hydrate, joinDepIDTuple, joinExtra, splitDepID, splitExtra, } from '@vltpkg/dep-id';
|
|
2
2
|
import { Spec } from '@vltpkg/spec';
|
|
3
3
|
import { graphStep } from '@vltpkg/output';
|
|
4
4
|
import { isObject } from '@vltpkg/types';
|
|
5
5
|
import { shorten, getRawDependencies, getDependencies, } from "../dependencies.js";
|
|
6
6
|
import { Graph } from "../graph.js";
|
|
7
7
|
import { loadHidden } from "../lockfile/load.js";
|
|
8
|
+
import { saveHidden } from "../lockfile/save.js";
|
|
8
9
|
import { readFileSync } from 'node:fs';
|
|
9
10
|
/**
|
|
10
11
|
* Checks if a given object is a {@link StoreConfigObject}.
|
|
@@ -135,12 +136,14 @@ const parseDir = (options, scurry, packageJson, depsFound, graph, fromNode, curr
|
|
|
135
136
|
if (!loadManifests) {
|
|
136
137
|
const depId = findDepID(realpath);
|
|
137
138
|
if (depId) {
|
|
138
|
-
let h = hydrate(depId, alias,
|
|
139
|
-
...options,
|
|
140
|
-
});
|
|
139
|
+
let h = hydrate(depId, alias, options);
|
|
141
140
|
// if the parsed registry value is using the default value, then
|
|
142
141
|
// the node should inherit the registry value from its parent node
|
|
143
|
-
h.
|
|
142
|
+
if (h.type === 'registry' &&
|
|
143
|
+
h.registry === h.options.registry &&
|
|
144
|
+
fromNode.registry) {
|
|
145
|
+
h.registry = fromNode.registry;
|
|
146
|
+
}
|
|
144
147
|
// Check for active modifiers and replace spec even when not loading manifests
|
|
145
148
|
const { spec: modifiedSpec, queryModifier } = maybeApplyModifierToSpec(h, alias, modifierRefs);
|
|
146
149
|
h = modifiedSpec;
|
|
@@ -151,7 +154,7 @@ const parseDir = (options, scurry, packageJson, depsFound, graph, fromNode, curr
|
|
|
151
154
|
h, // uses spec from hydrated id
|
|
152
155
|
{
|
|
153
156
|
name,
|
|
154
|
-
}, depId, queryModifier);
|
|
157
|
+
}, depId, joinExtra({ modifier: queryModifier }));
|
|
155
158
|
// Update active entry after placing package
|
|
156
159
|
const activeModifier = modifierRefs?.get(alias);
|
|
157
160
|
if (activeModifier && node) {
|
|
@@ -176,15 +179,28 @@ const parseDir = (options, scurry, packageJson, depsFound, graph, fromNode, curr
|
|
|
176
179
|
const depType = shorten(type, alias, fromNode.manifest);
|
|
177
180
|
let spec = Spec.parse(alias, bareSpec, {
|
|
178
181
|
...options,
|
|
182
|
+
registry: fromNode.registry,
|
|
179
183
|
});
|
|
180
|
-
// if the parsed registry value is using the default value, then
|
|
181
|
-
// the node should inherit the registry value from its parent node
|
|
182
|
-
spec.inheritedRegistry = fromNode.registry;
|
|
183
184
|
// Check for active modifiers and replace spec if a modifier is complete
|
|
184
185
|
const { spec: modifiedSpec, queryModifier } = maybeApplyModifierToSpec(spec, alias, modifierRefs);
|
|
185
186
|
spec = modifiedSpec;
|
|
186
187
|
const maybeId = getPathBasedId(spec, realpath);
|
|
187
|
-
|
|
188
|
+
let peerSetHash;
|
|
189
|
+
if (maybeId) {
|
|
190
|
+
// parses extra info from depID to retrieve peerSetHash
|
|
191
|
+
try {
|
|
192
|
+
const tuple = splitDepID(maybeId);
|
|
193
|
+
const type = tuple[0];
|
|
194
|
+
const extra = type === 'registry' || type === 'git' ?
|
|
195
|
+
tuple[3]
|
|
196
|
+
: tuple[2];
|
|
197
|
+
peerSetHash =
|
|
198
|
+
extra ? splitExtra(extra).peerSetHash : undefined;
|
|
199
|
+
/* c8 ignore next - impossible: getPathBasedId asserts valid dep id */
|
|
200
|
+
}
|
|
201
|
+
catch { }
|
|
202
|
+
}
|
|
203
|
+
node = graph.placePackage(fromNode, depType, spec, mani, maybeId, joinExtra({ modifier: queryModifier, peerSetHash }));
|
|
188
204
|
// Update active entry after placing package
|
|
189
205
|
const activeModifier = modifierRefs?.get(alias);
|
|
190
206
|
if (activeModifier && node) {
|
|
@@ -222,14 +238,12 @@ const parseDir = (options, scurry, packageJson, depsFound, graph, fromNode, curr
|
|
|
222
238
|
const depType = shorten(type, name, fromNode.manifest);
|
|
223
239
|
let spec = Spec.parse(name, bareSpec, {
|
|
224
240
|
...options,
|
|
241
|
+
registry: fromNode.registry,
|
|
225
242
|
});
|
|
226
|
-
// if the parsed registry value is using the default value, then
|
|
227
|
-
// the node should inherit the registry value from its parent node
|
|
228
|
-
spec.inheritedRegistry = fromNode.registry;
|
|
229
243
|
// Check for active modifiers and replace spec for missing dependencies
|
|
230
244
|
const { spec: modifiedSpec, queryModifier } = maybeApplyModifierToSpec(spec, name, modifierRefs);
|
|
231
245
|
spec = modifiedSpec;
|
|
232
|
-
graph.placePackage(fromNode, depType, spec, undefined, undefined, queryModifier);
|
|
246
|
+
graph.placePackage(fromNode, depType, spec, undefined, undefined, joinExtra({ modifier: queryModifier }));
|
|
233
247
|
}
|
|
234
248
|
}
|
|
235
249
|
};
|
|
@@ -291,6 +305,13 @@ export const load = (options) => {
|
|
|
291
305
|
}
|
|
292
306
|
// Clean up any pending modifier entries that were never completed
|
|
293
307
|
modifiers?.rollbackActiveEntries();
|
|
308
|
+
// caches the load result to the hidden lockfile when enabled
|
|
309
|
+
if (scurry.cwd.resolve('node_modules').lstatSync()?.isDirectory()) {
|
|
310
|
+
saveHidden({
|
|
311
|
+
...options,
|
|
312
|
+
graph,
|
|
313
|
+
});
|
|
314
|
+
}
|
|
294
315
|
}
|
|
295
316
|
done();
|
|
296
317
|
return graph;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load.js","sourceRoot":"","sources":["../../../src/actual/load.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AACjE,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACnC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EACL,OAAO,EACP,kBAAkB,EAClB,eAAe,GAChB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAYhD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AA4EtC;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CACjC,GAAY,EACc,EAAE,CAC5B,QAAQ,CAAC,GAAG,CAAC;IACb,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,EAAE,WAAW,CAAC;IACtD,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,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IAAI,EAAE,CAAA;IAEN,OAAO,KAAK,CAAA;AACd,CAAC,CAAA","sourcesContent":["import { asDepID, hydrate, joinDepIDTuple } from '@vltpkg/dep-id'\nimport { Spec } from '@vltpkg/spec'\nimport { graphStep } from '@vltpkg/output'\nimport { isObject } from '@vltpkg/types'\nimport {\n shorten,\n getRawDependencies,\n getDependencies,\n} from '../dependencies.ts'\nimport { Graph } from '../graph.ts'\nimport { loadHidden } from '../lockfile/load.ts'\nimport type { DepID } from '@vltpkg/dep-id'\nimport type { PackageJson } from '@vltpkg/package-json'\nimport type { SpecOptions } from '@vltpkg/spec'\nimport type { NormalizedManifest } from '@vltpkg/types'\nimport type { Monorepo } from '@vltpkg/workspaces'\nimport type { Path, PathScurry } from 'path-scurry'\nimport type { Node } from '../node.ts'\nimport type {\n GraphModifier,\n ModifierActiveEntry,\n} from '../modifiers.ts'\nimport { readFileSync } from 'node:fs'\n\nexport type LoadOptions = SpecOptions & {\n /**\n * The project root dirname.\n */\n projectRoot: string\n /**\n * The project root manifest.\n */\n mainManifest?: NormalizedManifest\n /**\n * The graph modifiers helper object.\n */\n modifiers?: GraphModifier\n /**\n * A {@link Monorepo} object, for managing workspaces\n */\n monorepo?: Monorepo\n /**\n * A {@link PackageJson} object, for sharing manifest caches\n */\n packageJson: PackageJson\n /**\n * A {@link PathScurry} object, for use in globs\n */\n scurry: PathScurry\n /**\n * If set to `false`, `actual.load` will not load any `package.json`\n * files while traversing the file system.\n *\n * The resulting {@link Graph} from loading with `loadManifests=false`\n * has no information on dependency types or the specs defined and\n * no information on missing and extraneous dependencies.\n */\n loadManifests?: boolean\n /**\n * If set to `true`, then do not shortcut the process by reading the\n * hidden lockfile at `node_modules/.vlt-lock.json`\n */\n skipHiddenLockfile?: boolean\n /**\n * Load only importers into the graph if the modifiers have changed.\n */\n skipLoadingNodesOnModifiersChange?: boolean\n // TODO: move the lockfile-related options to a separate type file\n /**\n * If set to `true`, fail if lockfile is missing or out of date.\n * Used by ci command to enforce lockfile integrity.\n */\n expectLockfile?: boolean\n /**\n * If set to `true`, fail if lockfile is missing or out of sync with package.json.\n * Prevents any lockfile modifications and is stricter than expectLockfile.\n */\n frozenLockfile?: boolean\n /**\n * If set to `true`, only update the lockfile without performing any node_modules\n * operations. Skips package extraction, filesystem operations, and hidden lockfile saves.\n */\n lockfileOnly?: boolean\n}\n\nexport type ReadEntry = {\n alias: string\n name: string\n realpath: Path\n}\n\n/**\n * The configuration object type as it is saved in the `.vlt/vlt.json`\n */\nexport type StoreConfigObject = {\n modifiers: Record<string, string> | undefined\n}\n\n/**\n * Checks if a given object is a {@link StoreConfigObject}.\n */\nexport const isStoreConfigObject = (\n obj: unknown,\n): obj is StoreConfigObject =>\n isObject(obj) &&\n Object.prototype.hasOwnProperty.call(obj, 'modifiers') &&\n isObject(obj.modifiers)\n\n/**\n * Returns a {@link StoreConfigObject} from a given object.\n * Throws a TypeError if the object can't be converted.\n */\nexport const asStoreConfigObject = (\n obj: unknown,\n): StoreConfigObject => {\n if (!isStoreConfigObject(obj)) {\n throw new TypeError(`Expected a store config object, got ${obj}`)\n }\n return obj\n}\n\n// path-based refer to the types of dependencies that are directly linked to\n// their real location in the file system and thus will not have an entry\n// in the `node_modules/.vlt` store\nconst pathBasedType = new Set(['file', 'workspace'])\nconst isPathBasedType = (\n type: string,\n): type is 'file' | 'workspace' => pathBasedType.has(type)\n\n/**\n * Returns a {@link DepID} for a given spec and path, if the spec is\n * path-based or a registry spec, otherwise returns `undefined`.\n */\nexport const getPathBasedId = (\n spec: Spec,\n path: Path,\n): DepID | undefined =>\n isPathBasedType(spec.type) ?\n joinDepIDTuple([spec.type, path.relativePosix()])\n : findDepID(path)\n\n/**\n * Retrieve the {@link DepID} for a given package from its location.\n */\nconst findDepID = ({ parent, name }: Path): DepID | undefined =>\n parent?.name === '.vlt' ? asDepID(name)\n : parent?.isCWD === false ? findDepID(parent)\n : undefined\n\n/**\n * Retrieves the closest `node_modules` parent {@link Path} found.\n */\nconst findNodeModules = ({\n parent,\n name,\n isCWD,\n}: Path): Path | undefined =>\n parent?.name === 'node_modules' ? parent\n : parent && name !== '.vlt' && !isCWD ? findNodeModules(parent)\n : undefined\n\n/**\n * Retrieves the scoped-normalized package name from its {@link Path}.\n */\nconst findName = ({ parent, name }: Path): string =>\n parent?.name.startsWith('@') ? `${parent.name}/${name}` : name\n\n/**\n * Helper function that gets a modified {@link Spec} when finding a modifier\n * that applies to a given dependency. Otherwise returns the original spec\n * value and no queryModifier.\n */\nconst maybeApplyModifierToSpec = (\n spec: Spec,\n depName: string,\n modifierRefs?: Map<string, ModifierActiveEntry>,\n): { spec: Spec; queryModifier?: string } => {\n const activeModifier = modifierRefs?.get(depName)\n const queryModifier = activeModifier?.modifier.query\n const completeModifier =\n activeModifier &&\n activeModifier.interactiveBreadcrumb.current ===\n activeModifier.modifier.breadcrumb.last\n\n if (\n queryModifier &&\n completeModifier &&\n 'spec' in activeModifier.modifier\n ) {\n const modifiedSpec = activeModifier.modifier.spec\n modifiedSpec.overridden = true\n return { spec: modifiedSpec, queryModifier }\n }\n\n return { spec, queryModifier }\n}\n\n/**\n * Reads the current directory defined at `currDir` and looks for folder\n * names and their realpath resolution, normalizing scoped package names\n * and removing any invalid symlinks from the list of items that should\n * be parsed through in order to build the graph.\n */\nconst readDir = (\n scurry: PathScurry,\n currDir: Path,\n fromNodeName?: string,\n) => {\n const res = new Set<ReadEntry>()\n for (const entry of scurry.readdirSync(currDir)) {\n // ignore any hidden files / folders\n if (entry.name.startsWith('.')) continue\n\n // scope folder found, it will need to be read and iterated over\n // in order to find any scoped packages inside\n if (entry.name.startsWith('@')) {\n const scopedItems = readDir(scurry, entry, fromNodeName)\n for (const scopedItem of scopedItems) {\n res.add(scopedItem)\n }\n continue\n }\n\n // skip anything that isn't a symlink, it's not an edge\n if (!entry.isSymbolicLink()) continue\n\n // we'll need to learn what is the real path for this entry in order\n // to retrieve the `location` and `id` properties for the node, if a\n // realpath is not found just move on to the next element\n const realpath = entry.realpathSync()\n if (!realpath) {\n continue\n }\n\n // infer both the alias and proper package names, including scopes\n const alias = findName(entry)\n const name = findName(realpath)\n res.add({\n alias,\n name,\n realpath,\n })\n }\n return res\n}\n\n/**\n * Parses the files located at `currDir` and place packages found inside\n * as dependencies of `fromNode`, building the instantiated `graph`.\n */\nconst parseDir = (\n options: LoadOptions,\n scurry: PathScurry,\n packageJson: PackageJson,\n depsFound: Map<Node, Path>,\n graph: Graph,\n fromNode: Node,\n currDir: Path,\n) => {\n const { loadManifests, modifiers } = options\n const dependencies = getRawDependencies(fromNode)\n const seenDeps = new Set<string>()\n const readItems: Set<ReadEntry> = readDir(\n scurry,\n currDir,\n fromNode.name,\n )\n\n // Get modifier references for this node's dependencies\n const modifierRefs = modifiers?.tryDependencies(fromNode, [\n ...getDependencies(fromNode, options).values(),\n ])\n\n for (const { alias, name, realpath } of readItems) {\n let node\n\n // tracks what dependencies have been seen\n // so that we can mark missing dependencies\n seenDeps.add(alias)\n\n // places the package in the graph reading\n // its manifest only if necessary\n if (!loadManifests) {\n const depId = findDepID(realpath)\n\n if (depId) {\n let h = hydrate(depId, alias, {\n ...options,\n })\n // if the parsed registry value is using the default value, then\n // the node should inherit the registry value from its parent node\n h.inheritedRegistry = fromNode.registry\n\n // Check for active modifiers and replace spec even when not loading manifests\n const { spec: modifiedSpec, queryModifier } =\n maybeApplyModifierToSpec(h, alias, modifierRefs)\n h = modifiedSpec\n\n // graphs build with no manifest have no notion of\n // dependency types and or spec definitions since those\n // would have to be parsed from a manifest\n node = graph.placePackage(\n fromNode,\n 'prod', // defaults to prod deps\n h, // uses spec from hydrated id\n {\n name,\n },\n depId,\n queryModifier,\n )\n\n // Update active entry after placing package\n const activeModifier = modifierRefs?.get(alias)\n if (activeModifier && node) {\n modifiers?.updateActiveEntry(node, activeModifier)\n }\n }\n }\n\n // retrieve references to the current folder name found in `fromNode`\n // manifest listed dependencies, removing it from the map will leave\n // a list of missing dependencies at the end of the iteration\n const deps = dependencies.get(alias)\n\n // in case this graph is skipping manifests, this next block might\n // still need to execute, thus actually loading a manifest file, for\n // edge-cases such as loading a linked node that is not going to have\n // DepID info available in its realpath or extraneous nodes\n if (!node) {\n const mani = packageJson.read(realpath.fullpath())\n // declares fallback default values for both depType and bareSpec\n // in order to support loadManifests=false fallback for link nodes\n const type = deps?.type || 'dependencies'\n const bareSpec = deps?.bareSpec || '*'\n\n const depType = shorten(type, alias, fromNode.manifest)\n let spec = Spec.parse(alias, bareSpec, {\n ...options,\n })\n // if the parsed registry value is using the default value, then\n // the node should inherit the registry value from its parent node\n spec.inheritedRegistry = fromNode.registry\n\n // Check for active modifiers and replace spec if a modifier is complete\n const { spec: modifiedSpec, queryModifier } =\n maybeApplyModifierToSpec(spec, alias, modifierRefs)\n spec = modifiedSpec\n\n const maybeId = getPathBasedId(spec, realpath)\n node = graph.placePackage(\n fromNode,\n depType,\n spec,\n mani,\n maybeId,\n queryModifier,\n )\n\n // Update active entry after placing package\n const activeModifier = modifierRefs?.get(alias)\n if (activeModifier && node) {\n modifiers?.updateActiveEntry(node, activeModifier)\n }\n }\n\n if (node) {\n // If a found dependency is not declared in any of the original\n // node dependencies, then add an edge to the graph pointing to it\n // and mark it as extraneous.\n //\n // This only makes sense if full manifests are being loaded\n // so that we have reference to dependencies info.\n if (loadManifests && !deps) {\n const [edge] = node.edgesIn\n if (edge) {\n graph.extraneousDependencies.add(edge)\n }\n }\n\n // for a succesfully created node, add its location\n // property and queue up to read its dependencies\n node.location = `./${realpath.relativePosix()}`\n const node_modules = findNodeModules(realpath)\n\n // queue items up to continue parsing dirs in case a node was succesfully\n // placed in the graph and its node_modules folder was correctly found\n if (node_modules) {\n depsFound.set(node, node_modules)\n }\n }\n }\n\n // any remaining dependencies that have not been found\n // when reading the directory should be marked as missing\n for (const { name, type, bareSpec } of dependencies.values()) {\n if (!seenDeps.has(name)) {\n const depType = shorten(type, name, fromNode.manifest)\n let spec = Spec.parse(name, bareSpec, {\n ...options,\n })\n // if the parsed registry value is using the default value, then\n // the node should inherit the registry value from its parent node\n spec.inheritedRegistry = fromNode.registry\n\n // Check for active modifiers and replace spec for missing dependencies\n const { spec: modifiedSpec, queryModifier } =\n maybeApplyModifierToSpec(spec, name, modifierRefs)\n spec = modifiedSpec\n\n graph.placePackage(\n fromNode,\n depType,\n spec,\n undefined,\n undefined,\n queryModifier,\n )\n }\n }\n}\n\n/**\n * Read the file system looking for `node_modules` folders and\n * returns a new {@link Graph} that represents the relationship\n * between the dependencies found.\n */\nexport const load = (options: LoadOptions): Graph => {\n const done = graphStep('actual')\n const {\n modifiers,\n monorepo,\n projectRoot,\n packageJson,\n scurry,\n skipHiddenLockfile = false,\n skipLoadingNodesOnModifiersChange = false,\n } = options\n const mainManifest =\n options.mainManifest ?? packageJson.read(projectRoot)\n\n if (!skipHiddenLockfile) {\n try {\n // if we reach here, the hidden lockfile is valid\n const graph = loadHidden({\n ...options,\n projectRoot,\n mainManifest,\n packageJson,\n monorepo,\n scurry,\n })\n done()\n return graph\n } catch {\n // if validation fails or any other error occurs,\n // fall back to filesystem traversal\n }\n }\n\n const graph = new Graph({ ...options, mainManifest })\n\n // retrieve the configuration object from the store\n let storeConfig: StoreConfigObject = { modifiers: undefined }\n try {\n storeConfig = asStoreConfigObject(\n JSON.parse(\n readFileSync(\n scurry.resolve('node_modules/.vlt/vlt.json'),\n 'utf8',\n ),\n ),\n )\n } catch {}\n const storeModifiers = JSON.stringify(storeConfig.modifiers ?? {})\n const optionsModifiers = JSON.stringify(modifiers?.config)\n const modifiersChanged = storeModifiers !== optionsModifiers\n const shouldLoadDependencies = !(\n skipLoadingNodesOnModifiersChange && modifiersChanged\n )\n\n // will only skip loading dependencies if the\n // skipLoadingNodesOnModifiersChange option is set to true\n // and the current modifiers have not changed when compared\n // to the modifiers stored in the `node_modules/.vlt/vlt.json` store config\n if (shouldLoadDependencies) {\n const depsFound = new Map<Node, Path>()\n\n // starts the list of initial folders to parse using the importer nodes\n for (const importer of graph.importers) {\n modifiers?.tryImporter(importer)\n depsFound.set(\n importer,\n scurry.cwd.resolve(`${importer.location}/node_modules`),\n )\n }\n\n // breadth-first traversal of the file system tree reading deps found\n // starting from the node_modules folder of every importer in order to\n // find the actual installed dependencies at each location\n for (const [node, path] of depsFound.entries()) {\n parseDir(\n options,\n scurry,\n packageJson,\n depsFound,\n graph,\n node,\n path,\n )\n }\n\n // Clean up any pending modifier entries that were never completed\n modifiers?.rollbackActiveEntries()\n }\n\n done()\n\n return graph\n}\n"]}
|
|
1
|
+
{"version":3,"file":"load.js","sourceRoot":"","sources":["../../../src/actual/load.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,OAAO,EACP,cAAc,EACd,SAAS,EACT,UAAU,EACV,UAAU,GACX,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACnC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EACL,OAAO,EACP,kBAAkB,EAClB,eAAe,GAChB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAYhD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AA4EtC;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CACjC,GAAY,EACc,EAAE,CAC5B,QAAQ,CAAC,GAAG,CAAC;IACb,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,EAAE,WAAW,CAAC;IACtD,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,CAAA;AAEzB;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CACjC,GAAY,EACO,EAAE;IACrB,IAAI,CAAC,mBAAmB,CAA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SAAS,GAAG,IAAI,GAAG,EAAc,CAAA;QAEvC,uEAAuE;QACvE,KAAK,MAAM,QAAQ,IAAI,KAAK,CAAC,SAAS,EAAE,CAAC;YACvC,SAAS,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAA;YAChC,SAAS,CAAC,GAAG,CACX,QAAQ,EACR,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,QAAQ,CAAC,QAAQ,eAAe,CAAC,CACxD,CAAA;QACH,CAAC;QAED,qEAAqE;QACrE,sEAAsE;QACtE,0DAA0D;QAC1D,KAAK,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,SAAS,CAAC,OAAO,EAAE,EAAE,CAAC;YAC/C,QAAQ,CACN,OAAO,EACP,MAAM,EACN,WAAW,EACX,SAAS,EACT,KAAK,EACL,IAAI,EACJ,IAAI,CACL,CAAA;QACH,CAAC;QAED,kEAAkE;QAClE,SAAS,EAAE,qBAAqB,EAAE,CAAA;QAElC,6DAA6D;QAC7D,IACE,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,SAAS,EAAE,EAAE,WAAW,EAAE,EAC7D,CAAC;YACD,UAAU,CAAC;gBACT,GAAG,OAAO;gBACV,KAAK;aACN,CAAC,CAAA;QACJ,CAAC;IACH,CAAC;IAED,IAAI,EAAE,CAAA;IAEN,OAAO,KAAK,CAAA;AACd,CAAC,CAAA","sourcesContent":["import {\n asDepID,\n hydrate,\n joinDepIDTuple,\n joinExtra,\n splitDepID,\n splitExtra,\n} from '@vltpkg/dep-id'\nimport { Spec } from '@vltpkg/spec'\nimport { graphStep } from '@vltpkg/output'\nimport { isObject } from '@vltpkg/types'\nimport {\n shorten,\n getRawDependencies,\n getDependencies,\n} from '../dependencies.ts'\nimport { Graph } from '../graph.ts'\nimport { loadHidden } from '../lockfile/load.ts'\nimport { saveHidden } from '../lockfile/save.ts'\nimport type { DepID } from '@vltpkg/dep-id'\nimport type { PackageJson } from '@vltpkg/package-json'\nimport type { SpecOptions } from '@vltpkg/spec'\nimport type { NormalizedManifest } from '@vltpkg/types'\nimport type { Monorepo } from '@vltpkg/workspaces'\nimport type { Path, PathScurry } from 'path-scurry'\nimport type { Node } from '../node.ts'\nimport type {\n GraphModifier,\n ModifierActiveEntry,\n} from '../modifiers.ts'\nimport { readFileSync } from 'node:fs'\n\nexport type LoadOptions = SpecOptions & {\n /**\n * The project root dirname.\n */\n projectRoot: string\n /**\n * The project root manifest.\n */\n mainManifest?: NormalizedManifest\n /**\n * The graph modifiers helper object.\n */\n modifiers?: GraphModifier\n /**\n * A {@link Monorepo} object, for managing workspaces\n */\n monorepo?: Monorepo\n /**\n * A {@link PackageJson} object, for sharing manifest caches\n */\n packageJson: PackageJson\n /**\n * A {@link PathScurry} object, for use in globs\n */\n scurry: PathScurry\n /**\n * If set to `false`, `actual.load` will not load any `package.json`\n * files while traversing the file system.\n *\n * The resulting {@link Graph} from loading with `loadManifests=false`\n * has no information on dependency types or the specs defined and\n * no information on missing and extraneous dependencies.\n */\n loadManifests?: boolean\n /**\n * If set to `true`, then do not shortcut the process by reading the\n * hidden lockfile at `node_modules/.vlt-lock.json`\n */\n skipHiddenLockfile?: boolean\n /**\n * Load only importers into the graph if the modifiers have changed.\n */\n skipLoadingNodesOnModifiersChange?: boolean\n // TODO: move the lockfile-related options to a separate type file\n /**\n * If set to `true`, fail if lockfile is missing or out of date.\n * Used by ci command to enforce lockfile integrity.\n */\n expectLockfile?: boolean\n /**\n * If set to `true`, fail if lockfile is missing or out of sync with package.json.\n * Prevents any lockfile modifications and is stricter than expectLockfile.\n */\n frozenLockfile?: boolean\n /**\n * If set to `true`, only update the lockfile without performing any node_modules\n * operations. Skips package extraction, filesystem operations, and hidden lockfile saves.\n */\n lockfileOnly?: boolean\n}\n\nexport type ReadEntry = {\n alias: string\n name: string\n realpath: Path\n}\n\n/**\n * The configuration object type as it is saved in the `.vlt/vlt.json`\n */\nexport type StoreConfigObject = {\n modifiers: Record<string, string> | undefined\n}\n\n/**\n * Checks if a given object is a {@link StoreConfigObject}.\n */\nexport const isStoreConfigObject = (\n obj: unknown,\n): obj is StoreConfigObject =>\n isObject(obj) &&\n Object.prototype.hasOwnProperty.call(obj, 'modifiers') &&\n isObject(obj.modifiers)\n\n/**\n * Returns a {@link StoreConfigObject} from a given object.\n * Throws a TypeError if the object can't be converted.\n */\nexport const asStoreConfigObject = (\n obj: unknown,\n): StoreConfigObject => {\n if (!isStoreConfigObject(obj)) {\n throw new TypeError(`Expected a store config object, got ${obj}`)\n }\n return obj\n}\n\n// path-based refer to the types of dependencies that are directly linked to\n// their real location in the file system and thus will not have an entry\n// in the `node_modules/.vlt` store\nconst pathBasedType = new Set(['file', 'workspace'])\nconst isPathBasedType = (\n type: string,\n): type is 'file' | 'workspace' => pathBasedType.has(type)\n\n/**\n * Returns a {@link DepID} for a given spec and path, if the spec is\n * path-based or a registry spec, otherwise returns `undefined`.\n */\nexport const getPathBasedId = (\n spec: Spec,\n path: Path,\n): DepID | undefined =>\n isPathBasedType(spec.type) ?\n joinDepIDTuple([spec.type, path.relativePosix()])\n : findDepID(path)\n\n/**\n * Retrieve the {@link DepID} for a given package from its location.\n */\nconst findDepID = ({ parent, name }: Path): DepID | undefined =>\n parent?.name === '.vlt' ? asDepID(name)\n : parent?.isCWD === false ? findDepID(parent)\n : undefined\n\n/**\n * Retrieves the closest `node_modules` parent {@link Path} found.\n */\nconst findNodeModules = ({\n parent,\n name,\n isCWD,\n}: Path): Path | undefined =>\n parent?.name === 'node_modules' ? parent\n : parent && name !== '.vlt' && !isCWD ? findNodeModules(parent)\n : undefined\n\n/**\n * Retrieves the scoped-normalized package name from its {@link Path}.\n */\nconst findName = ({ parent, name }: Path): string =>\n parent?.name.startsWith('@') ? `${parent.name}/${name}` : name\n\n/**\n * Helper function that gets a modified {@link Spec} when finding a modifier\n * that applies to a given dependency. Otherwise returns the original spec\n * value and no queryModifier.\n */\nconst maybeApplyModifierToSpec = (\n spec: Spec,\n depName: string,\n modifierRefs?: Map<string, ModifierActiveEntry>,\n): { spec: Spec; queryModifier?: string } => {\n const activeModifier = modifierRefs?.get(depName)\n const queryModifier = activeModifier?.modifier.query\n const completeModifier =\n activeModifier &&\n activeModifier.interactiveBreadcrumb.current ===\n activeModifier.modifier.breadcrumb.last\n\n if (\n queryModifier &&\n completeModifier &&\n 'spec' in activeModifier.modifier\n ) {\n const modifiedSpec = activeModifier.modifier.spec\n modifiedSpec.overridden = true\n return { spec: modifiedSpec, queryModifier }\n }\n\n return { spec, queryModifier }\n}\n\n/**\n * Reads the current directory defined at `currDir` and looks for folder\n * names and their realpath resolution, normalizing scoped package names\n * and removing any invalid symlinks from the list of items that should\n * be parsed through in order to build the graph.\n */\nconst readDir = (\n scurry: PathScurry,\n currDir: Path,\n fromNodeName?: string,\n) => {\n const res = new Set<ReadEntry>()\n for (const entry of scurry.readdirSync(currDir)) {\n // ignore any hidden files / folders\n if (entry.name.startsWith('.')) continue\n\n // scope folder found, it will need to be read and iterated over\n // in order to find any scoped packages inside\n if (entry.name.startsWith('@')) {\n const scopedItems = readDir(scurry, entry, fromNodeName)\n for (const scopedItem of scopedItems) {\n res.add(scopedItem)\n }\n continue\n }\n\n // skip anything that isn't a symlink, it's not an edge\n if (!entry.isSymbolicLink()) continue\n\n // we'll need to learn what is the real path for this entry in order\n // to retrieve the `location` and `id` properties for the node, if a\n // realpath is not found just move on to the next element\n const realpath = entry.realpathSync()\n if (!realpath) {\n continue\n }\n\n // infer both the alias and proper package names, including scopes\n const alias = findName(entry)\n const name = findName(realpath)\n res.add({\n alias,\n name,\n realpath,\n })\n }\n return res\n}\n\n/**\n * Parses the files located at `currDir` and place packages found inside\n * as dependencies of `fromNode`, building the instantiated `graph`.\n */\nconst parseDir = (\n options: LoadOptions,\n scurry: PathScurry,\n packageJson: PackageJson,\n depsFound: Map<Node, Path>,\n graph: Graph,\n fromNode: Node,\n currDir: Path,\n) => {\n const { loadManifests, modifiers } = options\n const dependencies = getRawDependencies(fromNode)\n const seenDeps = new Set<string>()\n const readItems: Set<ReadEntry> = readDir(\n scurry,\n currDir,\n fromNode.name,\n )\n\n // Get modifier references for this node's dependencies\n const modifierRefs = modifiers?.tryDependencies(fromNode, [\n ...getDependencies(fromNode, options).values(),\n ])\n\n for (const { alias, name, realpath } of readItems) {\n let node\n\n // tracks what dependencies have been seen\n // so that we can mark missing dependencies\n seenDeps.add(alias)\n\n // places the package in the graph reading\n // its manifest only if necessary\n if (!loadManifests) {\n const depId = findDepID(realpath)\n\n if (depId) {\n let h = hydrate(depId, alias, options)\n // if the parsed registry value is using the default value, then\n // the node should inherit the registry value from its parent node\n if (\n h.type === 'registry' &&\n h.registry === h.options.registry &&\n fromNode.registry\n ) {\n h.registry = fromNode.registry\n }\n\n // Check for active modifiers and replace spec even when not loading manifests\n const { spec: modifiedSpec, queryModifier } =\n maybeApplyModifierToSpec(h, alias, modifierRefs)\n h = modifiedSpec\n\n // graphs build with no manifest have no notion of\n // dependency types and or spec definitions since those\n // would have to be parsed from a manifest\n node = graph.placePackage(\n fromNode,\n 'prod', // defaults to prod deps\n h, // uses spec from hydrated id\n {\n name,\n },\n depId,\n joinExtra({ modifier: queryModifier }),\n )\n\n // Update active entry after placing package\n const activeModifier = modifierRefs?.get(alias)\n if (activeModifier && node) {\n modifiers?.updateActiveEntry(node, activeModifier)\n }\n }\n }\n\n // retrieve references to the current folder name found in `fromNode`\n // manifest listed dependencies, removing it from the map will leave\n // a list of missing dependencies at the end of the iteration\n const deps = dependencies.get(alias)\n\n // in case this graph is skipping manifests, this next block might\n // still need to execute, thus actually loading a manifest file, for\n // edge-cases such as loading a linked node that is not going to have\n // DepID info available in its realpath or extraneous nodes\n if (!node) {\n const mani = packageJson.read(realpath.fullpath())\n // declares fallback default values for both depType and bareSpec\n // in order to support loadManifests=false fallback for link nodes\n const type = deps?.type || 'dependencies'\n const bareSpec = deps?.bareSpec || '*'\n\n const depType = shorten(type, alias, fromNode.manifest)\n let spec = Spec.parse(alias, bareSpec, {\n ...options,\n registry: fromNode.registry,\n })\n\n // Check for active modifiers and replace spec if a modifier is complete\n const { spec: modifiedSpec, queryModifier } =\n maybeApplyModifierToSpec(spec, alias, modifierRefs)\n spec = modifiedSpec\n\n const maybeId = getPathBasedId(spec, realpath)\n let peerSetHash: string | undefined\n if (maybeId) {\n // parses extra info from depID to retrieve peerSetHash\n try {\n const tuple = splitDepID(maybeId)\n const type = tuple[0]\n const extra =\n type === 'registry' || type === 'git' ?\n tuple[3]\n : tuple[2]\n\n peerSetHash =\n extra ? splitExtra(extra).peerSetHash : undefined\n /* c8 ignore next - impossible: getPathBasedId asserts valid dep id */\n } catch {}\n }\n node = graph.placePackage(\n fromNode,\n depType,\n spec,\n mani,\n maybeId,\n joinExtra({ modifier: queryModifier, peerSetHash }),\n )\n\n // Update active entry after placing package\n const activeModifier = modifierRefs?.get(alias)\n if (activeModifier && node) {\n modifiers?.updateActiveEntry(node, activeModifier)\n }\n }\n\n if (node) {\n // If a found dependency is not declared in any of the original\n // node dependencies, then add an edge to the graph pointing to it\n // and mark it as extraneous.\n //\n // This only makes sense if full manifests are being loaded\n // so that we have reference to dependencies info.\n if (loadManifests && !deps) {\n const [edge] = node.edgesIn\n if (edge) {\n graph.extraneousDependencies.add(edge)\n }\n }\n\n // for a succesfully created node, add its location\n // property and queue up to read its dependencies\n node.location = `./${realpath.relativePosix()}`\n const node_modules = findNodeModules(realpath)\n\n // queue items up to continue parsing dirs in case a node was succesfully\n // placed in the graph and its node_modules folder was correctly found\n if (node_modules) {\n depsFound.set(node, node_modules)\n }\n }\n }\n\n // any remaining dependencies that have not been found\n // when reading the directory should be marked as missing\n for (const { name, type, bareSpec } of dependencies.values()) {\n if (!seenDeps.has(name)) {\n const depType = shorten(type, name, fromNode.manifest)\n let spec = Spec.parse(name, bareSpec, {\n ...options,\n registry: fromNode.registry,\n })\n\n // Check for active modifiers and replace spec for missing dependencies\n const { spec: modifiedSpec, queryModifier } =\n maybeApplyModifierToSpec(spec, name, modifierRefs)\n spec = modifiedSpec\n\n graph.placePackage(\n fromNode,\n depType,\n spec,\n undefined,\n undefined,\n joinExtra({ modifier: queryModifier }),\n )\n }\n }\n}\n\n/**\n * Read the file system looking for `node_modules` folders and\n * returns a new {@link Graph} that represents the relationship\n * between the dependencies found.\n */\nexport const load = (options: LoadOptions): Graph => {\n const done = graphStep('actual')\n const {\n modifiers,\n monorepo,\n projectRoot,\n packageJson,\n scurry,\n skipHiddenLockfile = false,\n skipLoadingNodesOnModifiersChange = false,\n } = options\n const mainManifest =\n options.mainManifest ?? packageJson.read(projectRoot)\n\n if (!skipHiddenLockfile) {\n try {\n // if we reach here, the hidden lockfile is valid\n const graph = loadHidden({\n ...options,\n projectRoot,\n mainManifest,\n packageJson,\n monorepo,\n scurry,\n })\n done()\n return graph\n } catch {\n // if validation fails or any other error occurs,\n // fall back to filesystem traversal\n }\n }\n\n const graph = new Graph({ ...options, mainManifest })\n\n // retrieve the configuration object from the store\n let storeConfig: StoreConfigObject = { modifiers: undefined }\n try {\n storeConfig = asStoreConfigObject(\n JSON.parse(\n readFileSync(\n scurry.resolve('node_modules/.vlt/vlt.json'),\n 'utf8',\n ),\n ),\n )\n } catch {}\n const storeModifiers = JSON.stringify(storeConfig.modifiers ?? {})\n const optionsModifiers = JSON.stringify(modifiers?.config)\n const modifiersChanged = storeModifiers !== optionsModifiers\n const shouldLoadDependencies = !(\n skipLoadingNodesOnModifiersChange && modifiersChanged\n )\n\n // will only skip loading dependencies if the\n // skipLoadingNodesOnModifiersChange option is set to true\n // and the current modifiers have not changed when compared\n // to the modifiers stored in the `node_modules/.vlt/vlt.json` store config\n if (shouldLoadDependencies) {\n const depsFound = new Map<Node, Path>()\n\n // starts the list of initial folders to parse using the importer nodes\n for (const importer of graph.importers) {\n modifiers?.tryImporter(importer)\n depsFound.set(\n importer,\n scurry.cwd.resolve(`${importer.location}/node_modules`),\n )\n }\n\n // breadth-first traversal of the file system tree reading deps found\n // starting from the node_modules folder of every importer in order to\n // find the actual installed dependencies at each location\n for (const [node, path] of depsFound.entries()) {\n parseDir(\n options,\n scurry,\n packageJson,\n depsFound,\n graph,\n node,\n path,\n )\n }\n\n // Clean up any pending modifier entries that were never completed\n modifiers?.rollbackActiveEntries()\n\n // caches the load result to the hidden lockfile when enabled\n if (\n scurry.cwd.resolve('node_modules').lstatSync()?.isDirectory()\n ) {\n saveHidden({\n ...options,\n graph,\n })\n }\n }\n\n done()\n\n return graph\n}\n"]}
|
package/dist/esm/browser.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export type { LoadResult, TransferData, } from './transfer-data/load.ts';
|
|
|
6
6
|
export * from './virtual-root.ts';
|
|
7
7
|
declare const lockfile: {
|
|
8
8
|
loadEdges: (graph: import("@vltpkg/types").GraphLike, edges: import("./lockfile/types.ts").LockfileData["edges"], options: import("@vltpkg/spec").SpecOptions) => void;
|
|
9
|
-
loadNodes: (graph: import("@vltpkg/types").GraphLike, nodes: import("./lockfile/types.ts").LockfileData["nodes"], options: import("@vltpkg/spec").SpecOptions, actual?: import("@vltpkg/types").GraphLike) => void;
|
|
9
|
+
loadNodes: (graph: import("@vltpkg/types").GraphLike, nodes: import("./lockfile/types.ts").LockfileData["nodes"], options: import("@vltpkg/spec").SpecOptions, actual?: import("@vltpkg/types").GraphLike, throwOnMissingManifest?: boolean) => void;
|
|
10
10
|
};
|
|
11
11
|
declare const transfer: {
|
|
12
12
|
load: (transfered: import("./transfer-data/load.ts").TransferData) => import("./transfer-data/load.ts").LoadResult;
|
package/dist/esm/diff.d.ts
CHANGED
|
@@ -53,6 +53,7 @@ export declare class Diff {
|
|
|
53
53
|
nodes: {
|
|
54
54
|
add: {
|
|
55
55
|
rawManifest?: import("@vltpkg/types").Override<import("@vltpkg/types").Manifest, import("@vltpkg/types").NormalizedFields> | undefined;
|
|
56
|
+
peerSetHash?: string | undefined;
|
|
56
57
|
id: import("@vltpkg/dep-id").DepID;
|
|
57
58
|
name: string;
|
|
58
59
|
version: string | undefined;
|
|
@@ -75,6 +76,7 @@ export declare class Diff {
|
|
|
75
76
|
}[];
|
|
76
77
|
delete: {
|
|
77
78
|
rawManifest?: import("@vltpkg/types").Override<import("@vltpkg/types").Manifest, import("@vltpkg/types").NormalizedFields> | undefined;
|
|
79
|
+
peerSetHash?: string | undefined;
|
|
78
80
|
id: import("@vltpkg/dep-id").DepID;
|
|
79
81
|
name: string;
|
|
80
82
|
version: string | undefined;
|
package/dist/esm/diff.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diff.d.ts","sourceRoot":"","sources":["../../src/diff.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAC/C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AACrC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AACvC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAOrC,QAAA,MAAM,cAAc,eAA2C,CAAA;AAE/D;;;;;;;;;;GAUG;AACH,qBAAa,IAAI;IACf,IAAI,EAAE,KAAK,CAAA;IACX,EAAE,EAAE,KAAK,CAAA;IAET,WAAW,EAAE,MAAM,CAAA;IAEnB;;;OAGG;IACH,mBAAmB,UAAQ;IAE3B;;OAEG;IACH,KAAK;QACH,+DAA+D;;QAE/D,+DAA+D;;MAEhE;IAED;;OAEG;IACH,KAAK;QACH,qEAAqE;;QAErE,qEAAqE;;MAEtE;IAED;;OAEG;IACH,YAAY,UAAO;IAEnB,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,WAEvB;gBAEW,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK;IA4ClC,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,MAAM;IAwC7D,UAAU,IAAI,OAAO;IASrB,MAAM
|
|
1
|
+
{"version":3,"file":"diff.d.ts","sourceRoot":"","sources":["../../src/diff.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAC/C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AACrC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AACvC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAOrC,QAAA,MAAM,cAAc,eAA2C,CAAA;AAE/D;;;;;;;;;;GAUG;AACH,qBAAa,IAAI;IACf,IAAI,EAAE,KAAK,CAAA;IACX,EAAE,EAAE,KAAK,CAAA;IAET,WAAW,EAAE,MAAM,CAAA;IAEnB;;;OAGG;IACH,mBAAmB,UAAQ;IAE3B;;OAEG;IACH,KAAK;QACH,+DAA+D;;QAE/D,+DAA+D;;MAEhE;IAED;;OAEG;IACH,KAAK;QACH,qEAAqE;;QAErE,qEAAqE;;MAEtE;IAED;;OAEG;IACH,YAAY,UAAO;IAEnB,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,WAEvB;gBAEW,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK;IA4ClC,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,MAAM;IAwC7D,UAAU,IAAI,OAAO;IASrB,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAYP"}
|
package/dist/esm/edge.d.ts
CHANGED
package/dist/esm/edge.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"edge.d.ts","sourceRoot":"","sources":["../../src/edge.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAExC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAC/C,OAAO,KAAK,EAAE,mBAAmB,EAAE,QAAQ,EAAE,MAAM,eAA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,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc;IAanD;;OAEG;IACH,IAAI,EAAE,IAAI,CAAA;IAEV;;OAEG;IACH,EAAE,CAAC,EAAE,IAAI,CAAA;IAET;;OAEG;IACH,IAAI,EAAE,mBAAmB,CAAA;IAEzB;;OAEG;IACH,IAAI,EAAE,IAAI,CAAA;gBAGR,IAAI,EAAE,mBAAmB,EACzB,IAAI,EAAE,IAAI,EACV,IAAI,EAAE,IAAI,EACV,EAAE,CAAC,EAAE,IAAI;IAQX;;OAEG;IACH,IAAI,IAAI,WAEP;IAED;;OAEG;IACH,IAAI,GAAG,IAAI,OAAO,CAEjB;IAED,IAAI,QAAQ,IAAI,OAAO,CAEtB;IAED,IAAI,IAAI,IAAI,OAAO,CAElB;IAED,IAAI,YAAY,IAAI,OAAO,CAE1B;IAED,KAAK,IAAI,OAAO;IAWhB,MAAM;;;;;;IASN,QAAQ;CAIT"}
|
package/dist/esm/edge.js
CHANGED
package/dist/esm/edge.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"edge.js","sourceRoot":"","sources":["../../src/edge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAE7C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAKnC,MAAM,cAAc,GAAG,MAAM,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAA;AAE/D,MAAM,OAAO,IAAI;IACf,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC;QACtB,OAAO,oBAAoB,CAAA;IAC7B,CAAC;IAED,CAAC,cAAc,CAAC,CAAC,CAAS,EAAE,OAAuB;QACjD,MAAM,GAAG,GAAG,OAAO,CACjB;YACE,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,EAAE;YAClB,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC;YACvB,EAAE,EAAE,IAA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IAED,MAAM;QACJ,OAAO;YACL,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,EAAE;YAClB,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,EAAE;YACf,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC;SACxB,CAAA;IACH,CAAC;CACF","sourcesContent":["import { satisfies } from '@vltpkg/satisfies'\nimport type { Spec } from '@vltpkg/spec'\nimport { inspect } from 'node:util'\nimport type { InspectOptions } from 'node:util'\nimport type { DependencyTypeShort, EdgeLike } from '@vltpkg/types'\nimport type { Node } from './node.ts'\n\nconst kCustomInspect = Symbol.for('nodejs.util.inspect.custom')\n\nexport class Edge implements EdgeLike {\n get [Symbol.toStringTag]() {\n return '@vltpkg/graph.Edge'\n }\n\n [kCustomInspect](_: number, options: InspectOptions) {\n const str = inspect(\n {\n from: this.from.id,\n type: this.type,\n spec: String(this.spec),\n to: this.to?.id,\n },\n options,\n )\n return `${this[Symbol.toStringTag]} ${str}`\n }\n\n /**\n * The Node this Edge is connecting from, this is usually the dependent.\n */\n from: Node\n\n /**\n * The node this Edge is connecting to, this is usually a direct dependency.\n */\n to?: Node\n\n /**\n * What type of dependency relationship `from` and `to` nodes have.\n */\n type: DependencyTypeShort\n\n /**\n * The defined spec value for `to` as parsed from the dependent metadata.\n */\n spec: Spec\n\n constructor(\n type: DependencyTypeShort,\n spec: Spec,\n from: Node,\n to?: Node,\n ) {\n this.from = from\n this.to = to\n this.type = type\n this.spec = spec\n }\n\n /**\n * The name of the dependency `to` as defined in the dependent metadata.\n */\n get name() {\n return this.spec.name\n }\n\n /**\n * This edge was defined as part of a `devDependencies` in `package.json`\n */\n get dev(): boolean {\n return this.type === 'dev'\n }\n\n get optional(): boolean {\n return this.type === 'peerOptional' || this.type === 'optional'\n }\n\n get peer(): boolean {\n return this.type === 'peer' || this.type === 'peerOptional'\n }\n\n get peerOptional(): boolean {\n return this.type === 'peerOptional'\n }\n\n valid(): boolean {\n return !this.to ?\n this.optional\n : satisfies(\n this.to.id,\n this.spec,\n this.from.location,\n this.from.projectRoot,\n )\n }\n\n toJSON() {\n return {\n from: this.from.id,\n to: this.to?.id,\n type: this.type,\n spec: String(this.spec),\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"edge.js","sourceRoot":"","sources":["../../src/edge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAE7C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAKnC,MAAM,cAAc,GAAG,MAAM,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAA;AAE/D,MAAM,OAAO,IAAI;IACf,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC;QACtB,OAAO,oBAAoB,CAAA;IAC7B,CAAC;IAED,CAAC,cAAc,CAAC,CAAC,CAAS,EAAE,OAAuB;QACjD,MAAM,GAAG,GAAG,OAAO,CACjB;YACE,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,EAAE;YAClB,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC;YACvB,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,EAAE;SAChB,EACD,OAAO,CACR,CAAA;QACD,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,GAAG,EAAE,CAAA;IAC7C,CAAC;IAED;;OAEG;IACH,IAAI,CAAM;IAEV;;OAEG;IACH,EAAE,CAAO;IAET;;OAEG;IACH,IAAI,CAAqB;IAEzB;;OAEG;IACH,IAAI,CAAM;IAEV,YACE,IAAyB,EACzB,IAAU,EACV,IAAU,EACV,EAAS;QAET,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,EAAE,GAAG,EAAE,CAAA;QACZ,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,IAAI,G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A;IAC/D,CAAC;CACF","sourcesContent":["import { satisfies } from '@vltpkg/satisfies'\nimport type { Spec } from '@vltpkg/spec'\nimport { inspect } from 'node:util'\nimport type { InspectOptions } from 'node:util'\nimport type { DependencyTypeShort, EdgeLike } from '@vltpkg/types'\nimport type { Node } from './node.ts'\n\nconst kCustomInspect = Symbol.for('nodejs.util.inspect.custom')\n\nexport class Edge implements EdgeLike {\n get [Symbol.toStringTag]() {\n return '@vltpkg/graph.Edge'\n }\n\n [kCustomInspect](_: number, options: InspectOptions) {\n const str = inspect(\n {\n from: this.from.id,\n type: this.type,\n spec: String(this.spec),\n to: this.to?.id,\n },\n options,\n )\n return `${this[Symbol.toStringTag]} ${str}`\n }\n\n /**\n * The Node this Edge is connecting from, this is usually the dependent.\n */\n from: Node\n\n /**\n * The node this Edge is connecting to, this is usually a direct dependency.\n */\n to?: Node\n\n /**\n * What type of dependency relationship `from` and `to` nodes have.\n */\n type: DependencyTypeShort\n\n /**\n * The defined spec value for `to` as parsed from the dependent metadata.\n */\n spec: Spec\n\n constructor(\n type: DependencyTypeShort,\n spec: Spec,\n from: Node,\n to?: Node,\n ) {\n this.from = from\n this.to = to\n this.type = type\n this.spec = spec\n }\n\n /**\n * The name of the dependency `to` as defined in the dependent metadata.\n */\n get name() {\n return this.spec.name\n }\n\n /**\n * This edge was defined as part of a `devDependencies` in `package.json`\n */\n get dev(): boolean {\n return this.type === 'dev'\n }\n\n get optional(): boolean {\n return this.type === 'peerOptional' || this.type === 'optional'\n }\n\n get peer(): boolean {\n return this.type === 'peer' || this.type === 'peerOptional'\n }\n\n get peerOptional(): boolean {\n return this.type === 'peerOptional'\n }\n\n valid(): boolean {\n return !this.to ?\n this.optional\n : satisfies(\n this.to.id,\n this.spec,\n this.from.location,\n this.from.projectRoot,\n )\n }\n\n toJSON() {\n return {\n from: this.from.id,\n to: this.to?.id,\n type: this.type,\n spec: String(this.spec),\n }\n }\n\n toString() {\n const to = `${this.name}${this.to ? '' : ' (missing)'}`\n return `Edge from: ${this.from.id} --|${this.type}|--> ${to}`\n }\n}\n"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Spec } from '@vltpkg/spec';
|
|
2
|
+
import type { Dependency } from './dependencies.ts';
|
|
3
|
+
import type { Manifest } from '@vltpkg/types';
|
|
4
|
+
import type { SpecOptions } from '@vltpkg/spec';
|
|
5
|
+
/**
|
|
6
|
+
* When adding new dependencies, it's very common to not have a dependency
|
|
7
|
+
* name directly available to reference, e.g: `file:local/folder` or
|
|
8
|
+
* `remote:tarball-url.tgz`. In these cases, a placeholder `(unknown)` name
|
|
9
|
+
* is used in the `Spec` object and the `add` Map structure that holds
|
|
10
|
+
* references to added dependencies will use the stringified spec as a key.
|
|
11
|
+
*
|
|
12
|
+
* This helper function fixes unknown names in the `add` map by replacing
|
|
13
|
+
* placeholder specs with the correct names from the provided manifest.
|
|
14
|
+
*/
|
|
15
|
+
export declare const fixupAddedNames: (add: Map<string, Dependency> | undefined, manifest: Pick<Manifest, "name"> | undefined, options: SpecOptions, spec: Spec) => Spec;
|
|
16
|
+
//# sourceMappingURL=fixup-added-names.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fixup-added-names.d.ts","sourceRoot":"","sources":["../../src/fixup-added-names.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACnC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAC7C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAE/C;;;;;;;;;GASG;AACH,eAAO,MAAM,eAAe,QACrB,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,GAAG,SAAS,YAC9B,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,GAAG,SAAS,WACnC,WAAW,QACd,IAAI,KACT,IAkBF,CAAA"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Spec } from '@vltpkg/spec';
|
|
2
|
+
/**
|
|
3
|
+
* When adding new dependencies, it's very common to not have a dependency
|
|
4
|
+
* name directly available to reference, e.g: `file:local/folder` or
|
|
5
|
+
* `remote:tarball-url.tgz`. In these cases, a placeholder `(unknown)` name
|
|
6
|
+
* is used in the `Spec` object and the `add` Map structure that holds
|
|
7
|
+
* references to added dependencies will use the stringified spec as a key.
|
|
8
|
+
*
|
|
9
|
+
* This helper function fixes unknown names in the `add` map by replacing
|
|
10
|
+
* placeholder specs with the correct names from the provided manifest.
|
|
11
|
+
*/
|
|
12
|
+
export const fixupAddedNames = (add, manifest, options, spec) => {
|
|
13
|
+
// Handle nameless dependencies
|
|
14
|
+
if (add && manifest?.name && spec.name === '(unknown)') {
|
|
15
|
+
const s = add.get(String(spec));
|
|
16
|
+
if (s) {
|
|
17
|
+
// removes the previous, placeholder entry key
|
|
18
|
+
add.delete(String(spec));
|
|
19
|
+
// replaces spec with a version with the correct name
|
|
20
|
+
spec = Spec.parse(manifest.name, spec.bareSpec, options);
|
|
21
|
+
// updates the add map with the fixed up spec
|
|
22
|
+
const n = {
|
|
23
|
+
type: s.type,
|
|
24
|
+
spec,
|
|
25
|
+
};
|
|
26
|
+
add.set(manifest.name, n);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return spec;
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=fixup-added-names.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fixup-added-names.js","sourceRoot":"","sources":["../../src/fixup-added-names.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAKnC;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAC7B,GAAwC,EACxC,QAA4C,EAC5C,OAAoB,EACpB,IAAU,EACJ,EAAE;IACR,+BAA+B;IAC/B,IAAI,GAAG,IAAI,QAAQ,EAAE,IAAI,IAAI,IAAI,CAAC,IAAI,KAAK,WAAW,EAAE,CAAC;QACvD,MAAM,CAAC,GAA2B,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAA;QACvD,IAAI,CAAC,EAAE,CAAC;YACN,8CAA8C;YAC9C,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAA;YACxB,qDAAqD;YACrD,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;YACxD,6CAA6C;YAC7C,MAAM,CAAC,GAAG;gBACR,IAAI,EAAE,CAAC,CAAC,IAAI;gBACZ,IAAI;aACL,CAAA;YACD,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC,CAAA;QAC3B,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC,CAAA","sourcesContent":["import { Spec } from '@vltpkg/spec'\nimport type { Dependency } from './dependencies.ts'\nimport type { Manifest } from '@vltpkg/types'\nimport type { SpecOptions } from '@vltpkg/spec'\n\n/**\n * When adding new dependencies, it's very common to not have a dependency\n * name directly available to reference, e.g: `file:local/folder` or\n * `remote:tarball-url.tgz`. In these cases, a placeholder `(unknown)` name\n * is used in the `Spec` object and the `add` Map structure that holds\n * references to added dependencies will use the stringified spec as a key.\n *\n * This helper function fixes unknown names in the `add` map by replacing\n * placeholder specs with the correct names from the provided manifest.\n */\nexport const fixupAddedNames = (\n add: Map<string, Dependency> | undefined,\n manifest: Pick<Manifest, 'name'> | undefined,\n options: SpecOptions,\n spec: Spec,\n): Spec => {\n // Handle nameless dependencies\n if (add && manifest?.name && spec.name === '(unknown)') {\n const s: Dependency | undefined = add.get(String(spec))\n if (s) {\n // removes the previous, placeholder entry key\n add.delete(String(spec))\n // replaces spec with a version with the correct name\n spec = Spec.parse(manifest.name, spec.bareSpec, options)\n // updates the add map with the fixed up spec\n const n = {\n type: s.type,\n spec,\n }\n add.set(manifest.name, n)\n }\n }\n return spec\n}\n"]}
|
package/dist/esm/graph.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ import type { Monorepo } from '@vltpkg/workspaces';
|
|
|
6
6
|
import type { InspectOptions } from 'node:util';
|
|
7
7
|
import { Edge } from './edge.ts';
|
|
8
8
|
import { Node } from './node.ts';
|
|
9
|
+
import type { PeerContext } from './ideal/types.ts';
|
|
9
10
|
declare const kCustomInspect: unique symbol;
|
|
10
11
|
export type ManifestInventory = Map<DepID, NormalizedManifest>;
|
|
11
12
|
export type GraphOptions = SpecOptions & {
|
|
@@ -73,7 +74,19 @@ export declare class Graph implements GraphLike {
|
|
|
73
74
|
* The root of the project this graph represents
|
|
74
75
|
*/
|
|
75
76
|
projectRoot: string;
|
|
77
|
+
/**
|
|
78
|
+
* The peer context sets used to resolve peer dependencies within this graph.
|
|
79
|
+
*/
|
|
80
|
+
peerContexts: PeerContext[];
|
|
81
|
+
/**
|
|
82
|
+
* Tracks the current peer context index.
|
|
83
|
+
*/
|
|
84
|
+
currentPeerContextIndex: number;
|
|
76
85
|
constructor(options: GraphOptions);
|
|
86
|
+
/**
|
|
87
|
+
* Get the next peer context index.
|
|
88
|
+
*/
|
|
89
|
+
nextPeerContextIndex(): number;
|
|
77
90
|
/**
|
|
78
91
|
* Delete all nodes and edges that are unreachable from the importers.
|
|
79
92
|
* The collection of deleted nodes is returned.
|
|
@@ -93,7 +106,7 @@ export declare class Graph implements GraphLike {
|
|
|
93
106
|
/**
|
|
94
107
|
* Find an existing node to satisfy a dependency
|
|
95
108
|
*/
|
|
96
|
-
findResolution(spec: Spec, fromNode: Node,
|
|
109
|
+
findResolution(spec: Spec, fromNode: Node, extra?: string): Node | undefined;
|
|
97
110
|
/**
|
|
98
111
|
* Create a new node in the graph.
|
|
99
112
|
*/
|
|
@@ -121,11 +134,12 @@ export declare class Graph implements GraphLike {
|
|
|
121
134
|
/**
|
|
122
135
|
* Removes the resolved node of a given edge.
|
|
123
136
|
*/
|
|
124
|
-
removeEdgeResolution(edge: Edge,
|
|
137
|
+
removeEdgeResolution(edge: Edge, extra?: string): void;
|
|
125
138
|
/**
|
|
126
|
-
*
|
|
139
|
+
* Remove all edges from the graph while preserving nodes and resolution caches.
|
|
140
|
+
* This allows the graph to be reconstructed efficiently using the existing nodes.
|
|
127
141
|
*/
|
|
128
|
-
|
|
142
|
+
resetEdges(): void;
|
|
129
143
|
toJSON(): import("./index.ts").LockfileData;
|
|
130
144
|
[kCustomInspect](_: number, options: InspectOptions): string;
|
|
131
145
|
}
|
package/dist/esm/graph.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graph.d.ts","sourceRoot":"","sources":["../../src/graph.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAG3C,OAAO,
|
|
1
|
+
{"version":3,"file":"graph.d.ts","sourceRoot":"","sources":["../../src/graph.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAG3C,OAAO,EAAc,IAAI,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,KAAK,EACV,SAAS,EACT,QAAQ,EACR,kBAAkB,EAClB,kBAAkB,EACnB,MAAM,eAAe,CAAA;AACtB,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAElD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAE/C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAGhC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAEnD,QAAA,MAAM,cAAc,eAA2C,CAAA;AAQ/D,MAAM,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