@vltpkg/graph 1.0.0-rc.13 → 1.0.0-rc.15
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/README.md +97 -22
- package/dist/actual/load.d.ts.map +1 -1
- package/dist/actual/load.js +3 -2
- package/dist/actual/load.js.map +1 -1
- package/dist/diff.d.ts +2 -0
- package/dist/diff.d.ts.map +1 -1
- package/dist/diff.js +5 -1
- package/dist/diff.js.map +1 -1
- package/dist/fixup-added-names.d.ts +4 -1
- package/dist/fixup-added-names.d.ts.map +1 -1
- package/dist/fixup-added-names.js +16 -0
- package/dist/fixup-added-names.js.map +1 -1
- package/dist/graph.d.ts +7 -0
- package/dist/graph.d.ts.map +1 -1
- package/dist/graph.js +17 -2
- package/dist/graph.js.map +1 -1
- package/dist/ideal/append-nodes.d.ts +14 -2
- package/dist/ideal/append-nodes.d.ts.map +1 -1
- package/dist/ideal/append-nodes.js +188 -57
- package/dist/ideal/append-nodes.js.map +1 -1
- package/dist/ideal/build.d.ts.map +1 -1
- package/dist/ideal/build.js +11 -1
- package/dist/ideal/build.js.map +1 -1
- package/dist/ideal/peers.d.ts +90 -6
- package/dist/ideal/peers.d.ts.map +1 -1
- package/dist/ideal/peers.js +387 -131
- package/dist/ideal/peers.js.map +1 -1
- package/dist/ideal/refresh-ideal-graph.d.ts +0 -4
- package/dist/ideal/refresh-ideal-graph.d.ts.map +1 -1
- package/dist/ideal/refresh-ideal-graph.js +8 -24
- package/dist/ideal/refresh-ideal-graph.js.map +1 -1
- package/dist/ideal/sorting.d.ts +46 -0
- package/dist/ideal/sorting.d.ts.map +1 -0
- package/dist/ideal/sorting.js +71 -0
- package/dist/ideal/sorting.js.map +1 -0
- package/dist/ideal/types.d.ts +2 -6
- package/dist/ideal/types.d.ts.map +1 -1
- package/dist/ideal/types.js.map +1 -1
- package/dist/install.d.ts.map +1 -1
- package/dist/install.js +12 -0
- package/dist/install.js.map +1 -1
- package/dist/lockfile/load.d.ts.map +1 -1
- package/dist/lockfile/load.js +21 -0
- package/dist/lockfile/load.js.map +1 -1
- package/dist/lockfile/save.d.ts.map +1 -1
- package/dist/lockfile/save.js +2 -2
- package/dist/lockfile/save.js.map +1 -1
- package/dist/lockfile/types.d.ts +7 -0
- package/dist/lockfile/types.d.ts.map +1 -1
- package/dist/lockfile/types.js +6 -0
- package/dist/lockfile/types.js.map +1 -1
- package/dist/node.d.ts +2 -0
- package/dist/node.d.ts.map +1 -1
- package/dist/node.js.map +1 -1
- package/dist/reify/extract-node.d.ts.map +1 -1
- package/dist/reify/extract-node.js.map +1 -1
- package/dist/reify/index.d.ts +1 -0
- package/dist/reify/index.d.ts.map +1 -1
- package/dist/reify/index.js +2 -1
- package/dist/reify/index.js.map +1 -1
- package/dist/update.d.ts.map +1 -1
- package/dist/update.js +1 -0
- package/dist/update.js.map +1 -1
- package/dist/visualization/mermaid-output.d.ts +2 -1
- package/dist/visualization/mermaid-output.d.ts.map +1 -1
- package/dist/visualization/mermaid-output.js +28 -16
- package/dist/visualization/mermaid-output.js.map +1 -1
- package/package.json +22 -22
- package/dist/ideal/get-ordered-dependencies.d.ts +0 -10
- package/dist/ideal/get-ordered-dependencies.d.ts.map +0 -1
- package/dist/ideal/get-ordered-dependencies.js +0 -42
- package/dist/ideal/get-ordered-dependencies.js.map +0 -1
package/README.md
CHANGED
|
@@ -41,57 +41,87 @@ At a glance:
|
|
|
41
41
|
`node_modules/.vlt-lock.json` mirroring the current on-disk state to
|
|
42
42
|
accelerate subsequent loads of the Actual graph.
|
|
43
43
|
- Modifiers: Configuration for selectively altering dependency
|
|
44
|
-
resolution
|
|
45
|
-
|
|
44
|
+
resolution via DSS queries in `vlt.json`.
|
|
45
|
+
- Peer Contexts: Isolation mechanism for peer dependencies that allows
|
|
46
|
+
multiple versions of the same package when peer requirements differ.
|
|
46
47
|
|
|
47
48
|
## API
|
|
48
49
|
|
|
49
|
-
### `actual.load(
|
|
50
|
+
### `actual.load(options): Graph`
|
|
50
51
|
|
|
51
52
|
Recursively loads the `node_modules` folder found at `projectRoot` in
|
|
52
53
|
order to create a graph representation of the current installed
|
|
53
54
|
packages.
|
|
54
55
|
|
|
55
|
-
### `
|
|
56
|
+
### `ideal.build(options): Promise<Graph>`
|
|
56
57
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
local file system.
|
|
58
|
+
Builds the ideal dependency graph by loading from lockfile (preferred)
|
|
59
|
+
or actual graph, then expanding dependencies by fetching manifests.
|
|
60
|
+
Requires `packageInfo` and `remover` in addition to standard options.
|
|
61
61
|
|
|
62
|
-
### `lockfile.load(
|
|
62
|
+
### `lockfile.load(options): Graph`
|
|
63
63
|
|
|
64
64
|
Loads the lockfile file found at `projectRoot` and returns the graph.
|
|
65
65
|
|
|
66
|
-
### `
|
|
66
|
+
### `lockfile.save(options): void`
|
|
67
|
+
|
|
68
|
+
Saves the graph to `vlt-lock.json`.
|
|
69
|
+
|
|
70
|
+
### `reify(options): Promise<ReifyResult>`
|
|
67
71
|
|
|
68
72
|
Computes a `Diff` between the Actual and Ideal graphs and applies the
|
|
69
73
|
minimal filesystem changes (creating/deleting links, writing
|
|
70
74
|
lockfiles, hoisting, lifecycle scripts) to make the on-disk install
|
|
71
|
-
match the Ideal graph.
|
|
75
|
+
match the Ideal graph. Returns `{ diff, buildQueue }`.
|
|
76
|
+
|
|
77
|
+
### `install(options, add?): Promise<{ graph, diff, buildQueue }>`
|
|
78
|
+
|
|
79
|
+
High-level install orchestration that handles graph building, reify,
|
|
80
|
+
and lockfile management. Supports `--frozen-lockfile`,
|
|
81
|
+
`--clean-install`, and `--lockfile-only` modes.
|
|
82
|
+
|
|
83
|
+
### `mermaidOutput(graph): string`
|
|
84
|
+
|
|
85
|
+
Generates Mermaid flowchart syntax from graph data.
|
|
86
|
+
|
|
87
|
+
### `humanReadableOutput(graph, options): string`
|
|
88
|
+
|
|
89
|
+
Generates ASCII tree output with optional colors. Used in `vlt ls`.
|
|
90
|
+
|
|
91
|
+
### `jsonOutput(graph): JSONOutputItem[]`
|
|
92
|
+
|
|
93
|
+
Returns array of `{name, fromID, spec, type, to, overridden}` items.
|
|
72
94
|
|
|
73
95
|
## Usage
|
|
74
96
|
|
|
75
|
-
|
|
76
|
-
method to build a graph representation of the install defined at the
|
|
77
|
-
`projectRoot` directory.
|
|
97
|
+
### High-Level Install
|
|
78
98
|
|
|
79
|
-
```
|
|
80
|
-
import {
|
|
99
|
+
```ts
|
|
100
|
+
import { install } from '@vltpkg/graph'
|
|
81
101
|
|
|
82
|
-
const graph = await
|
|
102
|
+
const { graph, diff, buildQueue } = await install({
|
|
103
|
+
projectRoot: process.cwd(),
|
|
104
|
+
packageInfo,
|
|
105
|
+
packageJson,
|
|
106
|
+
scurry,
|
|
107
|
+
allowScripts: '*',
|
|
108
|
+
})
|
|
83
109
|
```
|
|
84
110
|
|
|
85
111
|
### Load Actual Graph and Reify
|
|
86
112
|
|
|
87
113
|
```ts
|
|
88
114
|
import { actual, ideal, reify } from '@vltpkg/graph'
|
|
115
|
+
import { RollbackRemove } from '@vltpkg/rollback-remove'
|
|
116
|
+
|
|
117
|
+
const remover = new RollbackRemove()
|
|
89
118
|
|
|
90
119
|
// Load current on-disk state
|
|
91
120
|
const from = actual.load({
|
|
92
121
|
projectRoot: process.cwd(),
|
|
93
122
|
packageJson,
|
|
94
123
|
scurry,
|
|
124
|
+
loadManifests: true,
|
|
95
125
|
})
|
|
96
126
|
|
|
97
127
|
// Build intended end state (may start from lockfile or actual)
|
|
@@ -100,15 +130,18 @@ const to = await ideal.build({
|
|
|
100
130
|
packageInfo,
|
|
101
131
|
packageJson,
|
|
102
132
|
scurry,
|
|
133
|
+
remover,
|
|
103
134
|
})
|
|
104
135
|
|
|
105
136
|
// Apply minimal changes to match Ideal
|
|
106
|
-
await reify({
|
|
137
|
+
const { diff, buildQueue } = await reify({
|
|
107
138
|
graph: to,
|
|
108
139
|
actual: from,
|
|
109
140
|
packageInfo,
|
|
110
141
|
packageJson,
|
|
111
142
|
scurry,
|
|
143
|
+
remover,
|
|
144
|
+
allowScripts: '*',
|
|
112
145
|
})
|
|
113
146
|
```
|
|
114
147
|
|
|
@@ -118,15 +151,48 @@ await reify({
|
|
|
118
151
|
import { lockfile } from '@vltpkg/graph'
|
|
119
152
|
|
|
120
153
|
// Load virtual graph from vlt-lock.json
|
|
121
|
-
const
|
|
154
|
+
const graph = lockfile.load({
|
|
122
155
|
projectRoot,
|
|
123
156
|
mainManifest,
|
|
124
157
|
packageJson,
|
|
125
|
-
scurry,
|
|
126
158
|
})
|
|
127
159
|
|
|
128
|
-
// Save
|
|
129
|
-
lockfile.save({ graph
|
|
160
|
+
// Save to vlt-lock.json
|
|
161
|
+
lockfile.save({ graph })
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### Graph Visualization
|
|
165
|
+
|
|
166
|
+
```ts
|
|
167
|
+
import {
|
|
168
|
+
mermaidOutput,
|
|
169
|
+
humanReadableOutput,
|
|
170
|
+
jsonOutput,
|
|
171
|
+
} from '@vltpkg/graph'
|
|
172
|
+
|
|
173
|
+
// Mermaid flowchart (for docs, dashboards)
|
|
174
|
+
const mermaid = mermaidOutput({
|
|
175
|
+
edges: [...graph.edges],
|
|
176
|
+
nodes: [...graph.nodes.values()],
|
|
177
|
+
importers: graph.importers,
|
|
178
|
+
})
|
|
179
|
+
|
|
180
|
+
// ASCII tree with colors (used in `vlt ls`)
|
|
181
|
+
const tree = humanReadableOutput(
|
|
182
|
+
{
|
|
183
|
+
edges: [...graph.edges],
|
|
184
|
+
nodes: [...graph.nodes.values()],
|
|
185
|
+
importers: graph.importers,
|
|
186
|
+
},
|
|
187
|
+
{ colors: true },
|
|
188
|
+
)
|
|
189
|
+
|
|
190
|
+
// JSON array of dependency items
|
|
191
|
+
const json = jsonOutput({
|
|
192
|
+
edges: [...graph.edges],
|
|
193
|
+
nodes: [...graph.nodes.values()],
|
|
194
|
+
importers: graph.importers,
|
|
195
|
+
})
|
|
130
196
|
```
|
|
131
197
|
|
|
132
198
|
## Architecture
|
|
@@ -137,6 +203,7 @@ Graph construction modes supported by the library:
|
|
|
137
203
|
- Load and save via `src/lockfile/load.ts` and
|
|
138
204
|
`src/lockfile/save.ts`
|
|
139
205
|
- Hidden lockfile: `node_modules/.vlt-lock.json` for faster loads
|
|
206
|
+
- 📖 [Lockfile README](./src/lockfile/README.md)
|
|
140
207
|
|
|
141
208
|
- Actual Graphs (filesystem-based)
|
|
142
209
|
- Loaded by traversing `node_modules` via `src/actual/load.ts`
|
|
@@ -150,20 +217,28 @@ Graph construction modes supported by the library:
|
|
|
150
217
|
`src/ideal/get-importer-specs.ts`
|
|
151
218
|
- Fetches and expands manifests using `@vltpkg/package-info`, reuses
|
|
152
219
|
existing nodes that satisfy specs
|
|
220
|
+
- 📖 [Ideal README](./src/ideal/README.md)
|
|
153
221
|
|
|
154
222
|
Finally, `src/diff.ts` computes changes and `src/reify/` applies them
|
|
155
223
|
to the filesystem.
|
|
156
224
|
|
|
225
|
+
- 📖 [Reify README](./src/reify/README.md)
|
|
226
|
+
- 📖 [Architecture Guide](./ARCHITECTURE.md)
|
|
227
|
+
|
|
157
228
|
## Related Workspaces
|
|
158
229
|
|
|
159
230
|
- `@vltpkg/dep-id`: Unique IDs for packages, ensuring `Node` identity
|
|
160
231
|
- `@vltpkg/spec`: Parse/normalize dependency specifiers and registry
|
|
161
232
|
semantics
|
|
162
233
|
- `@vltpkg/semver`: Semantic version parsing/comparison
|
|
234
|
+
- `@vltpkg/satisfies`: Check if a DepID satisfies a Spec
|
|
163
235
|
- `@vltpkg/package-info`: Fetch remote manifests and artifacts
|
|
164
236
|
(registry, git, tarball)
|
|
165
237
|
- `@vltpkg/package-json`: Read and cache local `package.json` files
|
|
166
238
|
- `@vltpkg/workspaces`: Monorepo workspace discovery and grouping
|
|
239
|
+
- `@vltpkg/rollback-remove`: Safe file removal with rollback
|
|
240
|
+
capability
|
|
241
|
+
- `@vltpkg/vlt-json`: Load `vlt.json` configuration (modifiers, et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(options) => {
|
|
|
271
271
|
return graph;
|
|
272
272
|
}
|
|
273
273
|
catch {
|
|
274
|
-
//
|
|
275
|
-
// fall back to filesystem traversal
|
|
274
|
+
// Hidden lockfile is cache-only, safe to regenerate on any error
|
|
275
|
+
// as it will fall back to filesystem traversal
|
|
276
|
+
// TODO: Warn version mismatch to @vltpkg/output for debugging
|
|
276
277
|
}
|
|
277
278
|
}
|
|
278
279
|
const graph = new Graph({ ...options, mainManifest });
|
package/dist/actual/load.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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,E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IAAI,sBAAsB,EAAE,CAAC;QAC3B,MAAM,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"]}
|
|
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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,IAAI,sBAAsB,EAAE,CAAC;QAC3B,MAAM,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 // Hidden lockfile is cache-only, safe to regenerate on any error\n // as it will fall back to filesystem traversal\n // TODO: Warn version mismatch to @vltpkg/output for debugging\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/diff.d.ts
CHANGED
|
@@ -71,6 +71,7 @@ export declare class Diff {
|
|
|
71
71
|
engines?: Record<string, string>;
|
|
72
72
|
os?: string[] | string;
|
|
73
73
|
cpu?: string[] | string;
|
|
74
|
+
libc?: string[] | string;
|
|
74
75
|
} | undefined;
|
|
75
76
|
buildState: "none" | "needed" | "built" | "failed";
|
|
76
77
|
}[];
|
|
@@ -94,6 +95,7 @@ export declare class Diff {
|
|
|
94
95
|
engines?: Record<string, string>;
|
|
95
96
|
os?: string[] | string;
|
|
96
97
|
cpu?: string[] | string;
|
|
98
|
+
libc?: string[] | string;
|
|
97
99
|
} | undefined;
|
|
98
100
|
buildState: "none" | "needed" | "built" | "failed";
|
|
99
101
|
}[];
|
package/dist/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,q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C7D,UAAU,IAAI,OAAO;IASrB,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAYP"}
|
package/dist/diff.js
CHANGED
|
@@ -80,8 +80,12 @@ export class Diff {
|
|
|
80
80
|
continue;
|
|
81
81
|
if (fromEdge?.to)
|
|
82
82
|
this.edges.delete.add(fromEdge);
|
|
83
|
-
if (edge.to)
|
|
83
|
+
if (edge.to) {
|
|
84
84
|
this.edges.add.add(edge);
|
|
85
|
+
if (!edge.optional) {
|
|
86
|
+
this.optionalOnly = false;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
85
89
|
}
|
|
86
90
|
for (const edge of this.from.edges) {
|
|
87
91
|
// the node with this dep, in the to graph
|
package/dist/diff.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diff.js","sourceRoot":"","sources":["../src/diff.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAM3C,uDAAuD;AACvD,6EAA6E;AAC7E,4BAA4B;AAC5B,wBAAwB;AAExB,MAAM,cAAc,GAAG,MAAM,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAA;AAE/D;;;;;;;;;;GAUG;AACH,MAAM,OAAO,IAAI;IACf,IAAI,CAAO;IACX,EAAE,CAAO;IAET,WAAW,CAAQ;IAEnB;;;OAGG;IACH,mBAAmB,GAAG,KAAK,CAAA;IAE3B;;OAEG;IACH,KAAK,GAAG;QACN,+DAA+D;QAC/D,GAAG,EAAE,IAAI,GAAG,EAAQ;QACpB,+DAA+D;QAC/D,MAAM,EAAE,IAAI,GAAG,EAAQ;KACxB,CAAA;IAED;;OAEG;IACH,KAAK,GAAG;QACN,qEAAqE;QACrE,GAAG,EAAE,IAAI,GAAG,EAAQ;QACpB,qEAAqE;QACrE,MAAM,EAAE,IAAI,GAAG,EAAQ;KACxB,CAAA;IAED;;OAEG;IACH,YAAY,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,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;gBACnD,MAAM,EAAE,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;aAC1D;YACD,KAAK,EAAE;gBACL,GAAG,EAAE,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;gBACnD,MAAM,EAAE,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;aAC1D;SACF,CAAA;IACH,CAAC;CACF","sourcesContent":["import { error } from '@vltpkg/error-cause'\nimport type { InspectOptions } from 'node:util'\nimport type { Edge } from './edge.ts'\nimport type { Graph } from './graph.ts'\nimport type { Node } from './node.ts'\n\n// XXX should file deps *always* be considered changed?\n// unless the thing containing it wasn't possibly changed because it's inside\n// a dep that didn't change?\n// Same with remote deps\n\nconst kCustomInspect = Symbol.for('nodejs.util.inspect.custom')\n\n/**\n * A Diff object is a representation of a set of changes from one\n * graph to another, typically from the actual graph as it is reified\n * on disk, to an intended ideal graph.\n *\n * The naming convention can get a bit confusing here, because it's a\n * set of directed changes from one set of directed objects to another.\n *\n * Within the context the Diff object, `from` is the Graph we're coming from,\n * and `to` is the Graph we're trying to create.\n */\nexport class Diff {\n from: Graph\n to: Graph\n\n projectRoot: string\n\n /**\n * If changes need to be made later for failures of optional nodes,\n * set this flag so that we know to call graph.gc() at the appropriate time.\n */\n hadOptionalFailures = false\n\n /**\n * Collection of nodes to add and delete\n */\n nodes = {\n /** Nodes in the `to` graph that are not in the `from` graph */\n add: new Set<Node>(),\n /** Nodes in the `from` graph that are not in the `to` graph */\n delete: new Set<Node>(),\n }\n\n /**\n * Collection of nodes to add and delete\n */\n edges = {\n /** Edges in the `to` graph that are not found in the `from` graph */\n add: new Set<Edge>(),\n /** Edges in the `from` graph that are not found in the `to` graph */\n delete: new Set<Edge>(),\n }\n\n /**\n * True if the diff only contains optional nodes (computed during construction)\n */\n optionalOnly = true\n\n get [Symbol.toStringTag]() {\n return '@vltpkg/graph.Diff'\n }\n\n constructor(from: Graph, to: Graph) {\n this.from = from\n this.to = to\n this.projectRoot = from.projectRoot\n if (to.projectRoot !== from.projectRoot) {\n throw error('projectRoot mismatch in Graph diff', {\n wanted: from.projectRoot,\n found: to.projectRoot,\n })\n }\n\n for (const [id, node] of this.from.nodes) {\n if (!this.to.nodes.get(id)?.equals(node)) {\n this.nodes.delete.add(node)\n }\n }\n\n for (const [id, node] of this.to.nodes) {\n if (!this.from.nodes.get(id)?.equals(node)) {\n this.nodes.add.add(node)\n if (!node.optional) {\n this.optionalOnly = false\n }\n }\n }\n\n for (const edge of this.to.edges) {\n // the node with this dep, in the from graph\n const fromNode = this.from.nodes.get(edge.from.id)\n const fromEdge = fromNode?.edgesOut.get(edge.spec.name)\n if (fromEdge?.to?.id === edge.to?.id) continue\n if (fromEdge?.to) this.edges.delete.add(fromEdge)\n if (edge.to) this.edges.add.add(edge)\n }\n for (const edge of this.from.edges) {\n // the node with this dep, in the to graph\n const toNode = this.to.nodes.get(edge.from.id)\n const toEdge = toNode?.edgesOut.get(edge.spec.name)\n if (toEdge?.to?.id === edge.to?.id) continue\n if (edge.to) this.edges.delete.add(edge)\n if (toEdge?.to) this.edges.add.add(toEdge)\n }\n }\n\n [kCustomInspect](_: number, options?: InspectOptions): string {\n const red: [string, string] =\n options?.colors ? ['\\x1b[31m', '\\x1b[m'] : ['', '']\n const green: [string, string] =\n options?.colors ? ['\\x1b[32m', '\\x1b[m'] : ['', '']\n const lines: string[] = []\n for (const node of this.nodes.add) {\n lines.push(`+ ${node.id}`)\n }\n for (const node of this.nodes.delete) {\n lines.push(`- ${node.id}`)\n }\n for (const edge of this.edges.add) {\n /* c8 ignore next */\n const to = edge.to?.id ?? ''\n lines.push(\n `+ ${edge.from.id} ${edge.type} ${edge.spec} ${to}`.trim(),\n )\n }\n for (const edge of this.edges.delete) {\n /* c8 ignore next */\n const to = edge.to?.id ?? ''\n lines.push(\n `- ${edge.from.id} ${edge.type} ${edge.spec} ${to}`.trim(),\n )\n }\n const wrap = (s: string, c: [string, string]) => c.join(s)\n const color =\n options?.colors ?\n (s: string) => wrap(s, s.startsWith('+') ? green : red)\n : (s: string) => s\n\n return `${this[Symbol.toStringTag]} {\n${lines\n .sort((a, b) => a.substring(1).localeCompare(b.substring(1), 'en'))\n .map(s => ' ' + color(s))\n .join('\\n')}\n}`\n }\n\n hasChanges(): boolean {\n return (\n this.nodes.add.size > 0 ||\n this.nodes.delete.size > 0 ||\n this.edges.add.size > 0 ||\n this.edges.delete.size > 0\n )\n }\n\n toJSON() {\n return {\n nodes: {\n add: [...this.nodes.add].map(node => node.toJSON()),\n delete: [...this.nodes.delete].map(node => node.toJSON()),\n },\n edges: {\n add: [...this.edges.add].map(edge => edge.toJSON()),\n delete: [...this.edges.delete].map(edge => edge.toJSON()),\n },\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"diff.js","sourceRoot":"","sources":["../src/diff.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAM3C,uDAAuD;AACvD,6EAA6E;AAC7E,4BAA4B;AAC5B,wBAAwB;AAExB,MAAM,cAAc,GAAG,MAAM,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAA;AAE/D;;;;;;;;;;GAUG;AACH,MAAM,OAAO,IAAI;IACf,IAAI,CAAO;IACX,EAAE,CAAO;IAET,WAAW,CAAQ;IAEnB;;;OAGG;IACH,mBAAmB,GAAG,KAAK,CAAA;IAE3B;;OAEG;IACH,KAAK,GAAG;QACN,+DAA+D;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AAC,IAAI,CAAC;EACX,CAAA;IACA,CAAC;IAED,UAAU;QACR,OAAO,CACL,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC;YACvB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,GAAG,CAAC;YAC1B,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC;YACvB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,GAAG,CAAC,CAC3B,CAAA;IACH,CAAC;IAED,MAAM;QACJ,OAAO;YACL,KAAK,EAAE;gBACL,GAAG,EAAE,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;gBACnD,MAAM,EAAE,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;aAC1D;YACD,KAAK,EAAE;gBACL,GAAG,EAAE,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;gBACnD,MAAM,EAAE,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;aAC1D;SACF,CAAA;IACH,CAAC;CACF","sourcesContent":["import { error } from '@vltpkg/error-cause'\nimport type { InspectOptions } from 'node:util'\nimport type { Edge } from './edge.ts'\nimport type { Graph } from './graph.ts'\nimport type { Node } from './node.ts'\n\n// XXX should file deps *always* be considered changed?\n// unless the thing containing it wasn't possibly changed because it's inside\n// a dep that didn't change?\n// Same with remote deps\n\nconst kCustomInspect = Symbol.for('nodejs.util.inspect.custom')\n\n/**\n * A Diff object is a representation of a set of changes from one\n * graph to another, typically from the actual graph as it is reified\n * on disk, to an intended ideal graph.\n *\n * The naming convention can get a bit confusing here, because it's a\n * set of directed changes from one set of directed objects to another.\n *\n * Within the context the Diff object, `from` is the Graph we're coming from,\n * and `to` is the Graph we're trying to create.\n */\nexport class Diff {\n from: Graph\n to: Graph\n\n projectRoot: string\n\n /**\n * If changes need to be made later for failures of optional nodes,\n * set this flag so that we know to call graph.gc() at the appropriate time.\n */\n hadOptionalFailures = false\n\n /**\n * Collection of nodes to add and delete\n */\n nodes = {\n /** Nodes in the `to` graph that are not in the `from` graph */\n add: new Set<Node>(),\n /** Nodes in the `from` graph that are not in the `to` graph */\n delete: new Set<Node>(),\n }\n\n /**\n * Collection of nodes to add and delete\n */\n edges = {\n /** Edges in the `to` graph that are not found in the `from` graph */\n add: new Set<Edge>(),\n /** Edges in the `from` graph that are not found in the `to` graph */\n delete: new Set<Edge>(),\n }\n\n /**\n * True if the diff only contains optional nodes (computed during construction)\n */\n optionalOnly = true\n\n get [Symbol.toStringTag]() {\n return '@vltpkg/graph.Diff'\n }\n\n constructor(from: Graph, to: Graph) {\n this.from = from\n this.to = to\n this.projectRoot = from.projectRoot\n if (to.projectRoot !== from.projectRoot) {\n throw error('projectRoot mismatch in Graph diff', {\n wanted: from.projectRoot,\n found: to.projectRoot,\n })\n }\n\n for (const [id, node] of this.from.nodes) {\n if (!this.to.nodes.get(id)?.equals(node)) {\n this.nodes.delete.add(node)\n }\n }\n\n for (const [id, node] of this.to.nodes) {\n if (!this.from.nodes.get(id)?.equals(node)) {\n this.nodes.add.add(node)\n if (!node.optional) {\n this.optionalOnly = false\n }\n }\n }\n\n for (const edge of this.to.edges) {\n // the node with this dep, in the from graph\n const fromNode = this.from.nodes.get(edge.from.id)\n const fromEdge = fromNode?.edgesOut.get(edge.spec.name)\n if (fromEdge?.to?.id === edge.to?.id) continue\n if (fromEdge?.to) this.edges.delete.add(fromEdge)\n if (edge.to) {\n this.edges.add.add(edge)\n if (!edge.optional) {\n this.optionalOnly = false\n }\n }\n }\n for (const edge of this.from.edges) {\n // the node with this dep, in the to graph\n const toNode = this.to.nodes.get(edge.from.id)\n const toEdge = toNode?.edgesOut.get(edge.spec.name)\n if (toEdge?.to?.id === edge.to?.id) continue\n if (edge.to) this.edges.delete.add(edge)\n if (toEdge?.to) this.edges.add.add(toEdge)\n }\n }\n\n [kCustomInspect](_: number, options?: InspectOptions): string {\n const red: [string, string] =\n options?.colors ? ['\\x1b[31m', '\\x1b[m'] : ['', '']\n const green: [string, string] =\n options?.colors ? ['\\x1b[32m', '\\x1b[m'] : ['', '']\n const lines: string[] = []\n for (const node of this.nodes.add) {\n lines.push(`+ ${node.id}`)\n }\n for (const node of this.nodes.delete) {\n lines.push(`- ${node.id}`)\n }\n for (const edge of this.edges.add) {\n /* c8 ignore next */\n const to = edge.to?.id ?? ''\n lines.push(\n `+ ${edge.from.id} ${edge.type} ${edge.spec} ${to}`.trim(),\n )\n }\n for (const edge of this.edges.delete) {\n /* c8 ignore next */\n const to = edge.to?.id ?? ''\n lines.push(\n `- ${edge.from.id} ${edge.type} ${edge.spec} ${to}`.trim(),\n )\n }\n const wrap = (s: string, c: [string, string]) => c.join(s)\n const color =\n options?.colors ?\n (s: string) => wrap(s, s.startsWith('+') ? green : red)\n : (s: string) => s\n\n return `${this[Symbol.toStringTag]} {\n${lines\n .sort((a, b) => a.substring(1).localeCompare(b.substring(1), 'en'))\n .map(s => ' ' + color(s))\n .join('\\n')}\n}`\n }\n\n hasChanges(): boolean {\n return (\n this.nodes.add.size > 0 ||\n this.nodes.delete.size > 0 ||\n this.edges.add.size > 0 ||\n this.edges.delete.size > 0\n )\n }\n\n toJSON() {\n return {\n nodes: {\n add: [...this.nodes.add].map(node => node.toJSON()),\n delete: [...this.nodes.delete].map(node => node.toJSON()),\n },\n edges: {\n add: [...this.edges.add].map(edge => edge.toJSON()),\n delete: [...this.edges.delete].map(edge => edge.toJSON()),\n },\n }\n }\n}\n"]}
|
|
@@ -11,6 +11,9 @@ import type { SpecOptions } from '@vltpkg/spec';
|
|
|
11
11
|
*
|
|
12
12
|
* This helper function fixes unknown names in the `add` map by replacing
|
|
13
13
|
* placeholder specs with the correct names from the provided manifest.
|
|
14
|
+
*
|
|
15
|
+
* It also fixes empty bareSpec values (from CLI args like `vlt install foo`)
|
|
16
|
+
* by calculating the proper semver range from the resolved manifest version.
|
|
14
17
|
*/
|
|
15
|
-
export declare const fixupAddedNames: (add: Map<string, Dependency> | undefined, manifest: Pick<Manifest, "name"> | undefined, options: SpecOptions, spec: Spec) => Spec;
|
|
18
|
+
export declare const fixupAddedNames: (add: Map<string, Dependency> | undefined, manifest: Pick<Manifest, "name" | "version"> | undefined, options: SpecOptions, spec: Spec) => Spec;
|
|
16
19
|
//# sourceMappingURL=fixup-added-names.d.ts.map
|
|
@@ -1 +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;
|
|
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;AAG/C;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,eAAe,QACrB,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,GAAG,SAAS,YAC9B,IAAI,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC,GAAG,SAAS,WAC/C,WAAW,QACd,IAAI,KACT,IAqCF,CAAA"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Spec } from '@vltpkg/spec';
|
|
2
|
+
import { calculateSaveValue } from "./reify/calculate-save-value.js";
|
|
2
3
|
/**
|
|
3
4
|
* When adding new dependencies, it's very common to not have a dependency
|
|
4
5
|
* name directly available to reference, e.g: `file:local/folder` or
|
|
@@ -8,6 +9,9 @@ import { Spec } from '@vltpkg/spec';
|
|
|
8
9
|
*
|
|
9
10
|
* This helper function fixes unknown names in the `add` map by replacing
|
|
10
11
|
* placeholder specs with the correct names from the provided manifest.
|
|
12
|
+
*
|
|
13
|
+
* It also fixes empty bareSpec values (from CLI args like `vlt install foo`)
|
|
14
|
+
* by calculating the proper semver range from the resolved manifest version.
|
|
11
15
|
*/
|
|
12
16
|
export const fixupAddedNames = (add, manifest, options, spec) => {
|
|
13
17
|
// Handle nameless dependencies
|
|
@@ -26,6 +30,18 @@ export const fixupAddedNames = (add, manifest, options, spec) => {
|
|
|
26
30
|
add.set(manifest.name, n);
|
|
27
31
|
}
|
|
28
32
|
}
|
|
33
|
+
// Fix empty bareSpec (usually from CLI args like `vlt install foo`)
|
|
34
|
+
// by calculating the proper semver range from the resolved manifest version
|
|
35
|
+
if (add && manifest?.version && !spec.bareSpec) {
|
|
36
|
+
const addEntry = add.get(spec.name);
|
|
37
|
+
if (addEntry) {
|
|
38
|
+
const saveValue = calculateSaveValue(spec.final.type, spec, undefined, manifest.version);
|
|
39
|
+
if (saveValue && saveValue !== spec.bareSpec) {
|
|
40
|
+
spec = Spec.parse(spec.name, saveValue, options);
|
|
41
|
+
addEntry.spec = spec;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
29
45
|
return spec;
|
|
30
46
|
};
|
|
31
47
|
//# sourceMappingURL=fixup-added-names.js.map
|
|
@@ -1 +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;
|
|
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;AAInC,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAA;AAEpE;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAC7B,GAAwC,EACxC,QAAwD,EACxD,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;IAED,oEAAoE;IACpE,4EAA4E;IAC5E,IAAI,GAAG,IAAI,QAAQ,EAAE,OAAO,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;QAC/C,MAAM,QAAQ,GAAG,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QACnC,IAAI,QAAQ,EAAE,CAAC;YACb,MAAM,SAAS,GAAG,kBAAkB,CAClC,IAAI,CAAC,KAAK,CAAC,IAAI,EACf,IAAI,EACJ,SAAS,EACT,QAAQ,CAAC,OAAO,CACjB,CAAA;YACD,IAAI,SAAS,IAAI,SAAS,KAAK,IAAI,CAAC,QAAQ,EAAE,CAAC;gBAC7C,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC,CAAA;gBAChD,QAAQ,CAAC,IAAI,GAAG,IAAI,CAAA;YACtB,CAAC;QACH,CAAC;IACH,CAAC;IAED,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'\nimport { calculateSaveValue } from './reify/calculate-save-value.ts'\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 *\n * It also fixes empty bareSpec values (from CLI args like `vlt install foo`)\n * by calculating the proper semver range from the resolved manifest version.\n */\nexport const fixupAddedNames = (\n add: Map<string, Dependency> | undefined,\n manifest: Pick<Manifest, 'name' | 'version'> | 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\n // Fix empty bareSpec (usually from CLI args like `vlt install foo`)\n // by calculating the proper semver range from the resolved manifest version\n if (add && manifest?.version && !spec.bareSpec) {\n const addEntry = add.get(spec.name)\n if (addEntry) {\n const saveValue = calculateSaveValue(\n spec.final.type,\n spec,\n undefined,\n manifest.version,\n )\n if (saveValue && saveValue !== spec.bareSpec) {\n spec = Spec.parse(spec.name, saveValue, options)\n addEntry.spec = spec\n }\n }\n }\n\n return spec\n}\n"]}
|
package/dist/graph.d.ts
CHANGED
|
@@ -78,6 +78,13 @@ export declare class Graph implements GraphLike {
|
|
|
78
78
|
* The peer context sets used to resolve peer dependencies within this graph.
|
|
79
79
|
*/
|
|
80
80
|
peerContexts: PeerContext[];
|
|
81
|
+
/**
|
|
82
|
+
* Cache of forked peer contexts so identical fork operations can reuse
|
|
83
|
+
* previously created contexts instead of duplicating them.
|
|
84
|
+
*
|
|
85
|
+
* Key format is internal and constructed in `ideal/peers.ts`.
|
|
86
|
+
*/
|
|
87
|
+
peerContextForkCache: Map<string, PeerContext>;
|
|
81
88
|
/**
|
|
82
89
|
* Tracks the current peer context index.
|
|
83
90
|
*/
|
package/dist/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,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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M,EAAE,OAAO,EAAE,cAAc;CAIpD"}
|
package/dist/graph.js
CHANGED
|
@@ -86,6 +86,13 @@ export class Graph {
|
|
|
86
86
|
* The peer context sets used to resolve peer dependencies within this graph.
|
|
87
87
|
*/
|
|
88
88
|
peerContexts;
|
|
89
|
+
/**
|
|
90
|
+
* Cache of forked peer contexts so identical fork operations can reuse
|
|
91
|
+
* previously created contexts instead of duplicating them.
|
|
92
|
+
*
|
|
93
|
+
* Key format is internal and constructed in `ideal/peers.ts`.
|
|
94
|
+
*/
|
|
95
|
+
peerContextForkCache = new Map();
|
|
89
96
|
/**
|
|
90
97
|
* Tracks the current peer context index.
|
|
91
98
|
*/
|
|
@@ -130,6 +137,12 @@ export class Graph {
|
|
|
130
137
|
wsNode.setImporterLocation(`./${ws.path}`);
|
|
131
138
|
if (wsNode.manifest) {
|
|
132
139
|
this.manifests.set(wsNode.id, wsNode.manifest);
|
|
140
|
+
// set bins for workspace nodes so they can be linked
|
|
141
|
+
// when another importer depends on this workspace
|
|
142
|
+
/* c8 ignore next 3 - tested by integration tests */
|
|
143
|
+
if (wsNode.manifest.bin) {
|
|
144
|
+
wsNode.bins = wsNode.manifest.bin;
|
|
145
|
+
}
|
|
133
146
|
}
|
|
134
147
|
this.importers.add(wsNode);
|
|
135
148
|
// creates a virtual edge to connect the workspaces to the root node
|
|
@@ -312,9 +325,9 @@ export class Graph {
|
|
|
312
325
|
}
|
|
313
326
|
// add extra manifest info if available
|
|
314
327
|
if (manifest) {
|
|
315
|
-
const { bin, engines, os, cpu } = manifest;
|
|
328
|
+
const { bin, engines, os, cpu, libc } = manifest;
|
|
316
329
|
// add platform info if available
|
|
317
|
-
if (engines || os || cpu) {
|
|
330
|
+
if (engines || os || cpu || libc) {
|
|
318
331
|
const platform = {};
|
|
319
332
|
if (engines)
|
|
320
333
|
platform.engines = engines;
|
|
@@ -322,6 +335,8 @@ export class Graph {
|
|
|
322
335
|
platform.os = os;
|
|
323
336
|
if (cpu)
|
|
324
337
|
platform.cpu = cpu;
|
|
338
|
+
if (libc)
|
|
339
|
+
platform.libc = libc;
|
|
325
340
|
toNode.platform = platform;
|
|
326
341
|
}
|
|
327
342
|
// add bin info if available
|