@vltpkg/graph 0.0.0-9 → 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/README.md +136 -1
- package/dist/esm/actual/load.d.ts +49 -3
- package/dist/esm/actual/load.d.ts.map +1 -1
- package/dist/esm/actual/load.js +146 -74
- package/dist/esm/actual/load.js.map +1 -1
- package/dist/esm/browser.d.ts +8 -4
- package/dist/esm/browser.d.ts.map +1 -1
- package/dist/esm/browser.js +6 -2
- package/dist/esm/browser.js.map +1 -1
- package/dist/esm/build.d.ts +29 -0
- package/dist/esm/build.d.ts.map +1 -0
- package/dist/esm/build.js +79 -0
- package/dist/esm/build.js.map +1 -0
- package/dist/esm/dependencies.d.ts +10 -3
- package/dist/esm/dependencies.d.ts.map +1 -1
- package/dist/esm/dependencies.js +63 -0
- package/dist/esm/dependencies.js.map +1 -1
- package/dist/esm/diff.d.ts +69 -0
- package/dist/esm/diff.d.ts.map +1 -1
- package/dist/esm/diff.js +25 -0
- package/dist/esm/diff.js.map +1 -1
- package/dist/esm/edge.d.ts +8 -2
- package/dist/esm/edge.d.ts.map +1 -1
- package/dist/esm/edge.js +12 -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 +34 -10
- package/dist/esm/graph.d.ts.map +1 -1
- package/dist/esm/graph.js +150 -24
- package/dist/esm/graph.js.map +1 -1
- package/dist/esm/ideal/append-nodes.d.ts +12 -1
- package/dist/esm/ideal/append-nodes.d.ts.map +1 -1
- package/dist/esm/ideal/append-nodes.js +303 -53
- 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 +35 -16
- package/dist/esm/ideal/build-ideal-from-starting-graph.js.map +1 -1
- package/dist/esm/ideal/build.d.ts +9 -0
- package/dist/esm/ideal/build.d.ts.map +1 -1
- package/dist/esm/ideal/build.js +31 -1
- package/dist/esm/ideal/build.js.map +1 -1
- package/dist/esm/ideal/get-importer-specs.d.ts +11 -3
- package/dist/esm/ideal/get-importer-specs.d.ts.map +1 -1
- package/dist/esm/ideal/get-importer-specs.js +86 -9
- 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 +9 -4
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +5 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/install.d.ts +10 -4
- package/dist/esm/install.d.ts.map +1 -1
- package/dist/esm/install.js +191 -20
- package/dist/esm/install.js.map +1 -1
- package/dist/esm/lockfile/load-edges.d.ts +8 -1
- package/dist/esm/lockfile/load-edges.d.ts.map +1 -1
- package/dist/esm/lockfile/load-edges.js +80 -15
- package/dist/esm/lockfile/load-edges.js.map +1 -1
- package/dist/esm/lockfile/load-nodes.d.ts +3 -2
- package/dist/esm/lockfile/load-nodes.d.ts.map +1 -1
- package/dist/esm/lockfile/load-nodes.js +85 -13
- package/dist/esm/lockfile/load-nodes.js.map +1 -1
- package/dist/esm/lockfile/load.d.ts +18 -5
- package/dist/esm/lockfile/load.d.ts.map +1 -1
- package/dist/esm/lockfile/load.js +28 -20
- package/dist/esm/lockfile/load.js.map +1 -1
- package/dist/esm/lockfile/save.d.ts +16 -3
- package/dist/esm/lockfile/save.d.ts.map +1 -1
- package/dist/esm/lockfile/save.js +64 -17
- package/dist/esm/lockfile/save.js.map +1 -1
- package/dist/esm/lockfile/types.d.ts +34 -4
- package/dist/esm/lockfile/types.d.ts.map +1 -1
- package/dist/esm/lockfile/types.js +31 -0
- package/dist/esm/lockfile/types.js.map +1 -1
- package/dist/esm/modifiers.d.ts +189 -0
- package/dist/esm/modifiers.d.ts.map +1 -0
- package/dist/esm/modifiers.js +330 -0
- package/dist/esm/modifiers.js.map +1 -0
- package/dist/esm/node.d.ts +91 -6
- package/dist/esm/node.d.ts.map +1 -1
- package/dist/esm/node.js +119 -5
- package/dist/esm/node.js.map +1 -1
- package/dist/esm/reify/add-edge.d.ts +1 -2
- package/dist/esm/reify/add-edge.d.ts.map +1 -1
- package/dist/esm/reify/add-edge.js +29 -18
- package/dist/esm/reify/add-edge.js.map +1 -1
- package/dist/esm/reify/add-edges.d.ts +1 -2
- package/dist/esm/reify/add-edges.d.ts.map +1 -1
- package/dist/esm/reify/add-edges.js +3 -3
- package/dist/esm/reify/add-edges.js.map +1 -1
- package/dist/esm/reify/add-nodes.d.ts.map +1 -1
- package/dist/esm/reify/add-nodes.js +4 -27
- package/dist/esm/reify/add-nodes.js.map +1 -1
- package/dist/esm/reify/bin-chmod.d.ts +11 -0
- package/dist/esm/reify/bin-chmod.d.ts.map +1 -0
- package/dist/esm/reify/bin-chmod.js +39 -0
- package/dist/esm/reify/bin-chmod.js.map +1 -0
- package/dist/esm/reify/build.d.ts +10 -1
- package/dist/esm/reify/build.d.ts.map +1 -1
- package/dist/esm/reify/build.js +36 -23
- package/dist/esm/reify/build.js.map +1 -1
- package/dist/esm/reify/calculate-save-value.d.ts +3 -0
- package/dist/esm/reify/calculate-save-value.d.ts.map +1 -0
- package/dist/esm/reify/calculate-save-value.js +45 -0
- package/dist/esm/reify/calculate-save-value.js.map +1 -0
- package/dist/esm/reify/check-needed-build.d.ts +25 -0
- package/dist/esm/reify/check-needed-build.d.ts.map +1 -0
- package/dist/esm/reify/check-needed-build.js +50 -0
- package/dist/esm/reify/check-needed-build.js.map +1 -0
- package/dist/esm/reify/delete-edge.d.ts.map +1 -1
- package/dist/esm/reify/delete-edge.js +3 -4
- package/dist/esm/reify/delete-edge.js.map +1 -1
- package/dist/esm/reify/extract-node.d.ts +24 -0
- package/dist/esm/reify/extract-node.d.ts.map +1 -0
- package/dist/esm/reify/extract-node.js +84 -0
- package/dist/esm/reify/extract-node.js.map +1 -0
- package/dist/esm/reify/index.d.ts +18 -1
- package/dist/esm/reify/index.d.ts.map +1 -1
- package/dist/esm/reify/index.js +85 -15
- package/dist/esm/reify/index.js.map +1 -1
- package/dist/esm/reify/internal-hoist.d.ts +9 -0
- package/dist/esm/reify/internal-hoist.d.ts.map +1 -0
- package/dist/esm/reify/internal-hoist.js +134 -0
- package/dist/esm/reify/internal-hoist.js.map +1 -0
- 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 +33 -24
- package/dist/esm/reify/update-importers-package-json.js.map +1 -1
- package/dist/esm/remove-optional-subgraph.js +1 -1
- package/dist/esm/remove-optional-subgraph.js.map +1 -1
- package/dist/esm/resolve-save-type.d.ts +1 -2
- package/dist/esm/resolve-save-type.d.ts.map +1 -1
- package/dist/esm/resolve-save-type.js.map +1 -1
- package/dist/esm/stringify-node.d.ts +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/transfer-data/load.d.ts +44 -0
- package/dist/esm/transfer-data/load.d.ts.map +1 -0
- package/dist/esm/transfer-data/load.js +176 -0
- package/dist/esm/transfer-data/load.js.map +1 -0
- package/dist/esm/uninstall.d.ts +5 -4
- package/dist/esm/uninstall.d.ts.map +1 -1
- package/dist/esm/uninstall.js +61 -19
- package/dist/esm/uninstall.js.map +1 -1
- package/dist/esm/update.d.ts +13 -0
- package/dist/esm/update.d.ts.map +1 -0
- package/dist/esm/update.js +73 -0
- package/dist/esm/update.js.map +1 -0
- package/dist/esm/virtual-root.d.ts +16 -0
- package/dist/esm/virtual-root.d.ts.map +1 -0
- package/dist/esm/virtual-root.js +79 -0
- package/dist/esm/virtual-root.js.map +1 -0
- package/dist/esm/visualization/human-readable-output.d.ts +4 -5
- package/dist/esm/visualization/human-readable-output.d.ts.map +1 -1
- package/dist/esm/visualization/human-readable-output.js +47 -19
- package/dist/esm/visualization/human-readable-output.js.map +1 -1
- package/dist/esm/visualization/json-output.d.ts +7 -2
- package/dist/esm/visualization/json-output.d.ts.map +1 -1
- package/dist/esm/visualization/json-output.js +35 -12
- package/dist/esm/visualization/json-output.js.map +1 -1
- package/dist/esm/visualization/mermaid-output.d.ts +7 -1
- package/dist/esm/visualization/mermaid-output.d.ts.map +1 -1
- package/dist/esm/visualization/mermaid-output.js +110 -14
- package/dist/esm/visualization/mermaid-output.js.map +1 -1
- package/dist/esm/visualization/object-like-output.d.ts +1 -1
- package/dist/esm/visualization/object-like-output.d.ts.map +1 -1
- package/dist/esm/visualization/object-like-output.js.map +1 -1
- package/package.json +35 -29
- package/dist/esm/ideal/add-nodes.d.ts +0 -19
- package/dist/esm/ideal/add-nodes.d.ts.map +0 -1
- package/dist/esm/ideal/add-nodes.js +0 -32
- 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
- package/dist/esm/reify/bin-paths.d.ts +0 -4
- package/dist/esm/reify/bin-paths.d.ts.map +0 -1
- package/dist/esm/reify/bin-paths.js +0 -23
- package/dist/esm/reify/bin-paths.js.map +0 -1
- package/dist/esm/types.d.ts +0 -42
- package/dist/esm/types.d.ts.map +0 -1
- package/dist/esm/types.js +0 -2
- package/dist/esm/types.js.map +0 -1
package/dist/esm/node.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { getId, hydrateTuple, splitDepID } from '@vltpkg/dep-id';
|
|
1
|
+
import { isPackageNameConfused, getId, hydrateTuple, splitDepID, } from '@vltpkg/dep-id';
|
|
2
2
|
import { typeError } from '@vltpkg/error-cause';
|
|
3
|
+
import { expandNormalizedManifestSymbols } from '@vltpkg/types';
|
|
3
4
|
import { Edge } from "./edge.js";
|
|
4
5
|
import { stringifyNode } from "./stringify-node.js";
|
|
5
6
|
export class Node {
|
|
@@ -8,6 +9,7 @@ export class Node {
|
|
|
8
9
|
}
|
|
9
10
|
#options;
|
|
10
11
|
#location;
|
|
12
|
+
#rawManifest;
|
|
11
13
|
#optional = false;
|
|
12
14
|
/**
|
|
13
15
|
* True if a node is only reachable via optional or peerOptional edges from
|
|
@@ -57,6 +59,14 @@ export class Node {
|
|
|
57
59
|
isDev() {
|
|
58
60
|
return this.#dev;
|
|
59
61
|
}
|
|
62
|
+
/**
|
|
63
|
+
* True if there's a manifest-confused package name.
|
|
64
|
+
*/
|
|
65
|
+
confused = false;
|
|
66
|
+
/**
|
|
67
|
+
* True if this node has been extracted to the file system.
|
|
68
|
+
*/
|
|
69
|
+
extracted = false;
|
|
60
70
|
/**
|
|
61
71
|
* List of edges coming into this node.
|
|
62
72
|
*/
|
|
@@ -66,6 +76,11 @@ export class Node {
|
|
|
66
76
|
* that the connected node is a direct dependency of this node.
|
|
67
77
|
*/
|
|
68
78
|
edgesOut = new Map();
|
|
79
|
+
/**
|
|
80
|
+
* A `mainImporter` node may have workspace connected to it,
|
|
81
|
+
* equivalent to its `edgesOut` linked deps.
|
|
82
|
+
*/
|
|
83
|
+
workspaces;
|
|
69
84
|
/**
|
|
70
85
|
* A reference to the {@link DepID} this node represents in the graph.
|
|
71
86
|
*/
|
|
@@ -100,6 +115,12 @@ export class Node {
|
|
|
100
115
|
* the same registry, if it's not the default.
|
|
101
116
|
*/
|
|
102
117
|
registry;
|
|
118
|
+
/**
|
|
119
|
+
* If this node has been modified as part of applying a {@link GraphModifier}
|
|
120
|
+
* then this field will contain the modifier query that was applied.
|
|
121
|
+
* Otherwise, it will be `undefined`.
|
|
122
|
+
*/
|
|
123
|
+
modifier;
|
|
103
124
|
/**
|
|
104
125
|
* The name of the package represented by this node, this is usually
|
|
105
126
|
* equivalent to `manifest.name` but in a few ways it may differ such as
|
|
@@ -124,6 +145,41 @@ export class Node {
|
|
|
124
145
|
* An address {@link PackageInfoClient} may use to extract this package.
|
|
125
146
|
*/
|
|
126
147
|
resolved;
|
|
148
|
+
/**
|
|
149
|
+
* Platform requirements (engines, os, cpu) extracted from manifest.
|
|
150
|
+
* Stored separately for optional dependencies to enable platform checks
|
|
151
|
+
* when manifest is not loaded.
|
|
152
|
+
*/
|
|
153
|
+
platform;
|
|
154
|
+
/**
|
|
155
|
+
* Record of binary names to their paths in the package, if any.
|
|
156
|
+
*/
|
|
157
|
+
bins;
|
|
158
|
+
/**
|
|
159
|
+
* True if this node has been built as part of the reify step.
|
|
160
|
+
*/
|
|
161
|
+
built = false;
|
|
162
|
+
/**
|
|
163
|
+
* Build state of this node - tracks whether it needs building, has been built, or failed.
|
|
164
|
+
* - 'none': No build state (default)
|
|
165
|
+
* - 'needed': Node needs to be built
|
|
166
|
+
* - 'built': Node has been successfully built
|
|
167
|
+
* - 'failed': Node build has failed
|
|
168
|
+
*/
|
|
169
|
+
buildState = 'none';
|
|
170
|
+
/**
|
|
171
|
+
* Deterministic unique string used to identify (and ultimately duplicate)
|
|
172
|
+
* nodes that are affected by a peer context set modified resolution.
|
|
173
|
+
* These are appended to the node {@link DepID} as the `extra` suffix.
|
|
174
|
+
*/
|
|
175
|
+
peerSetHash;
|
|
176
|
+
/**
|
|
177
|
+
* True if this node is detached from the graph.
|
|
178
|
+
* This is used to indicate that the node is not part of the graph
|
|
179
|
+
* although the node is still available as part of the resolution process.
|
|
180
|
+
* Allows for skipping fetching manifests for detached nodes.
|
|
181
|
+
*/
|
|
182
|
+
detached = false;
|
|
127
183
|
/**
|
|
128
184
|
* The file system location for this node.
|
|
129
185
|
*/
|
|
@@ -181,9 +237,6 @@ export class Node {
|
|
|
181
237
|
this.manifest = manifest;
|
|
182
238
|
this.#name = name || this.manifest?.name;
|
|
183
239
|
this.version = version || this.manifest?.version;
|
|
184
|
-
if (this.version?.startsWith('v')) {
|
|
185
|
-
this.version = this.version.slice(1);
|
|
186
|
-
}
|
|
187
240
|
}
|
|
188
241
|
/**
|
|
189
242
|
* return true if this node is located in the vlt store
|
|
@@ -204,6 +257,11 @@ export class Node {
|
|
|
204
257
|
this.manifest?.dist?.tarball || spec.conventionalRegistryTarball;
|
|
205
258
|
this.integrity ??= this.manifest?.dist?.integrity;
|
|
206
259
|
}
|
|
260
|
+
get options() {
|
|
261
|
+
return this.#options;
|
|
262
|
+
}
|
|
263
|
+
/* c8 ignore next */
|
|
264
|
+
set options(_opts) { }
|
|
207
265
|
equals(other) {
|
|
208
266
|
return this.id === other.id && this.location === other.location;
|
|
209
267
|
}
|
|
@@ -226,6 +284,11 @@ export class Node {
|
|
|
226
284
|
const tuple = splitDepID(this.id);
|
|
227
285
|
const [type, resolved] = tuple;
|
|
228
286
|
switch (type) {
|
|
287
|
+
case 'remote': {
|
|
288
|
+
this.resolved = resolved;
|
|
289
|
+
this.integrity ??= this.manifest?.dist?.integrity;
|
|
290
|
+
break;
|
|
291
|
+
}
|
|
229
292
|
case 'registry':
|
|
230
293
|
this.#registryNodeResolved(tuple);
|
|
231
294
|
break;
|
|
@@ -253,6 +316,33 @@ export class Node {
|
|
|
253
316
|
this.edgesOut.set(spec.name, edge);
|
|
254
317
|
return edge;
|
|
255
318
|
}
|
|
319
|
+
/**
|
|
320
|
+
* The raw manifest before any modifications.
|
|
321
|
+
* If not set, falls back to the current manifest.
|
|
322
|
+
*/
|
|
323
|
+
get rawManifest() {
|
|
324
|
+
return this.#rawManifest ?? this.manifest;
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* Sets this node as having a manifest-confused manifest.
|
|
328
|
+
*/
|
|
329
|
+
setConfusedManifest(fixed, confused) {
|
|
330
|
+
this.manifest = fixed;
|
|
331
|
+
this.#rawManifest = confused;
|
|
332
|
+
this.confused = true;
|
|
333
|
+
this.#name = this.manifest.name;
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* Sets this node as having a manifest-confused manifest.
|
|
337
|
+
*/
|
|
338
|
+
maybeSetConfusedManifest(spec, confused) {
|
|
339
|
+
if (isPackageNameConfused(spec, this.manifest?.name)) {
|
|
340
|
+
this.setConfusedManifest({
|
|
341
|
+
...this.manifest,
|
|
342
|
+
name: spec.name,
|
|
343
|
+
}, confused);
|
|
344
|
+
}
|
|
345
|
+
}
|
|
256
346
|
toJSON() {
|
|
257
347
|
return {
|
|
258
348
|
id: this.id,
|
|
@@ -260,16 +350,40 @@ export class Node {
|
|
|
260
350
|
version: this.version,
|
|
261
351
|
location: this.location,
|
|
262
352
|
importer: this.importer,
|
|
263
|
-
manifest: this.manifest
|
|
353
|
+
manifest: this.manifest &&
|
|
354
|
+
expandNormalizedManifestSymbols(this.manifest),
|
|
264
355
|
projectRoot: this.projectRoot,
|
|
265
356
|
integrity: this.integrity,
|
|
266
357
|
resolved: this.resolved,
|
|
267
358
|
dev: this.dev,
|
|
268
359
|
optional: this.optional,
|
|
360
|
+
confused: this.confused,
|
|
361
|
+
modifier: this.modifier,
|
|
362
|
+
platform: this.platform,
|
|
363
|
+
buildState: this.buildState,
|
|
364
|
+
...(this.peerSetHash ?
|
|
365
|
+
{ peerSetHash: this.peerSetHash }
|
|
366
|
+
: undefined),
|
|
367
|
+
...(this.confused ?
|
|
368
|
+
{ rawManifest: this.#rawManifest }
|
|
369
|
+
: undefined),
|
|
269
370
|
};
|
|
270
371
|
}
|
|
271
372
|
toString() {
|
|
272
373
|
return stringifyNode(this);
|
|
273
374
|
}
|
|
274
375
|
}
|
|
376
|
+
export const isNode = (value) => {
|
|
377
|
+
return (typeof value === 'object' &&
|
|
378
|
+
value != null &&
|
|
379
|
+
'id' in value &&
|
|
380
|
+
'manifest' in value &&
|
|
381
|
+
value[Symbol.toStringTag] === '@vltpkg/graph.Node');
|
|
382
|
+
};
|
|
383
|
+
export const asNode = (value) => {
|
|
384
|
+
if (!isNode(value)) {
|
|
385
|
+
throw typeError('Expected a node', { found: value });
|
|
386
|
+
}
|
|
387
|
+
return value;
|
|
388
|
+
};
|
|
275
389
|
//# sourceMappingURL=node.js.map
|
package/dist/esm/node.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.js","sourceRoot":"","sources":["../../src/node.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAEhE,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAO/C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAQnD,MAAM,OAAO,IAAI;IACf,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC;QACtB,OAAO,oBAAoB,CAAA;IAC7B,CAAC;IAED,QAAQ,CAAa;IACrB,SAAS,CAAS;IAElB,SAAS,GAAG,KAAK,CAAA;IACjB;;;;;;OAMG;IACH,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,SAAS,CAAA;IACvB,CAAC;IACD,IAAI,QAAQ,CAAC,QAAiB;QAC5B,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,CAAC,QAAQ;SACxB,CAAA;IACH,CAAC;IAED,QAAQ;QACN,OAAO,aAAa,CAAC,IAAI,CAAC,CAAA;IAC5B,CAAC;CACF","sourcesContent":["import type { PathScurry } from 'path-scurry'\nimport { getId, hydrateTuple, splitDepID } from '@vltpkg/dep-id'\nimport type { DepID, DepIDTuple } from '@vltpkg/dep-id'\nimport { typeError } from '@vltpkg/error-cause'\nimport type { Spec, SpecOptions } from '@vltpkg/spec'\nimport type {\n Integrity,\n Manifest,\n DependencyTypeShort,\n} from '@vltpkg/types'\nimport { Edge } from './edge.ts'\nimport type { GraphLike, NodeLike } from './types.ts'\nimport { stringifyNode } from './stringify-node.ts'\nimport type { PackageInfoClient } from '@vltpkg/package-info'\n\nexport type NodeOptions = SpecOptions & {\n projectRoot: string\n graph: GraphLike\n}\n\nexport class Node implements NodeLike {\n get [Symbol.toStringTag]() {\n return '@vltpkg/graph.Node'\n }\n\n #options: SpecOptions\n #location?: string\n\n #optional = false\n /**\n * True if a node is only reachable via optional or peerOptional edges from\n * any importer.\n *\n * Setting this to false, if previously set to true, will also unset\n * the flag on any optional-flagged non-optional dependencies.\n */\n get optional() {\n return this.#optional\n }\n set optional(optional: boolean) {\n const before = this.#optional\n this.#optional = optional\n if (before && !optional) {\n // unset for all deps, as well\n for (const { to, optional } of this.edgesOut.values()) {\n if (!optional && to?.optional) to.optional = false\n }\n }\n }\n\n isOptional(): this is Node & { optional: true } {\n return this.#optional\n }\n\n #dev = false\n /**\n * True if a node is only reachable via dev edges from any importer.\n *\n * Setting this to false, if previously set to true, will also unset\n * the flag on any dev-flagged non-dev dependencies.\n */\n get dev() {\n return this.#dev\n }\n set dev(dev: boolean) {\n const before = this.#dev\n this.#dev = dev\n if (before && !dev) {\n // unset for all deps, as well\n for (const { to, dev } of this.edgesOut.values()) {\n if (!dev && to?.dev) to.dev = false\n }\n }\n }\n\n isDev(): this is Node & { dev: true } {\n return this.#dev\n }\n\n /**\n * List of edges coming into this node.\n */\n edgesIn = new Set<Edge>()\n\n /**\n * List of edges from this node into other nodes. This usually represents\n * that the connected node is a direct dependency of this node.\n */\n edgesOut = new Map<string, Edge>()\n\n /**\n * A reference to the {@link DepID} this node represents in the graph.\n */\n id: DepID\n\n /**\n * True if this node is an importer node.\n */\n importer = false\n\n /**\n * True if this node is the project root node.\n */\n mainImporter = false\n\n /**\n * A reference to the graph this node is a part of.\n */\n graph: GraphLike\n\n /**\n * The manifest integrity value.\n */\n integrity?: Integrity\n\n /**\n * The manifest this node represents in the graph.\n */\n manifest?: Manifest\n\n /**\n * Project where this node resides\n */\n projectRoot: string\n\n /**\n * For registry nodes, this is the registry we fetched them from.\n * Needed because their un-prefixed dependencies need to come from\n * the same registry, if it's not the default.\n */\n registry?: string\n\n /**\n * The name of the package represented by this node, this is usually\n * equivalent to `manifest.name` but in a few ways it may differ such as\n * nodes loaded from a lockfile that lacks a loaded manifest.\n * This field should be used to retrieve package names instead.\n */\n #name?: string\n get name() {\n if (this.#name) return this.#name\n this.#name = this.id\n return this.#name\n }\n\n /**\n * The version of the package represented by this node, this is usually\n * equivalent to `manifest.version` but in a few ways it may differ such as\n * nodes loaded from a lockfile that lacks a loaded manifest.\n * This field should be used to retrieve package versions instead.\n */\n version?: string\n\n /**\n * An address {@link PackageInfoClient} may use to extract this package.\n */\n resolved?: string\n\n /**\n * The file system location for this node.\n */\n get location(): string {\n if (this.#location) {\n return this.#location\n }\n this.#location = `./node_modules/.vlt/${this.id}/node_modules/${this.name}`\n // if using the default location, it is in the store\n this.inVltStore = () => true\n return this.#location\n }\n\n set location(location: string) {\n this.#location = location\n // reset memoization, since it might be elsewhere now\n if (this.inVltStore !== Node.prototype.inVltStore) {\n this.inVltStore = Node.prototype.inVltStore\n }\n }\n\n /**\n * The resolved location of the node in the file system.\n */\n resolvedLocation(scurry: PathScurry): string {\n return scurry.cwd.resolve(this.location).fullpath()\n }\n\n /**\n * The location of the node_modules folder where this node's edgesOut\n * should be linked into. For nodes in the store, this is the parent\n * directory, since they're extracted into a node_modules folder\n * side by side with links to their deps. For nodes outside of the store\n * (ie, importers and arbitrary link deps) this is the node_modules folder\n * directly inside the node's directory.\n */\n nodeModules(scurry: PathScurry): string {\n const loc = this.resolvedLocation(scurry)\n return this.inVltStore() ?\n loc.substring(0, loc.length - this.name.length - 1)\n : scurry.resolve(loc, 'node_modules')\n }\n\n constructor(\n options: NodeOptions,\n id?: DepID,\n manifest?: Manifest,\n spec?: Spec,\n name?: string,\n version?: string,\n ) {\n this.#options = options\n this.projectRoot = options.projectRoot\n if (id) {\n this.id = id\n } else {\n if (!manifest || !spec) {\n throw typeError(\n 'A new Node needs either a manifest & spec or an id parameter',\n {\n manifest,\n },\n )\n }\n this.id = getId(spec, manifest)\n }\n this.graph = options.graph\n this.manifest = manifest\n this.#name = name || this.manifest?.name\n\n this.version = version || this.manifest?.version\n if (this.version?.startsWith('v')) {\n this.version = this.version.slice(1)\n }\n }\n\n /**\n * return true if this node is located in the vlt store\n * memoized the first time it's called, since the store location\n * doesn't change within the context of a single operation.\n */\n inVltStore(): boolean {\n // technically this just means it's in *a* vlt store, but we can safely\n // assume that a user won't construct a path like this by accident,\n // and there's only ever one store in any given project.\n const inStore = this.location.endsWith(\n `.vlt/${this.id}/node_modules/${this.name}`,\n )\n this.inVltStore = () => inStore\n return inStore\n }\n\n #registryNodeResolved(tuple: DepIDTuple) {\n const spec = hydrateTuple(tuple, this.#name, this.#options)\n this.resolved =\n this.manifest?.dist?.tarball || spec.conventionalRegistryTarball\n this.integrity ??= this.manifest?.dist?.integrity\n }\n\n equals(other: Node) {\n return this.id === other.id && this.location === other.location\n }\n\n /**\n * Sets the node as an importer along with its location.\n */\n setImporterLocation(location: string) {\n this.#location = location\n this.importer = true\n }\n\n /**\n * Sets the appropriate resolve / integrity value for this node.\n * Note that other places might also set these values, like for\n * example the lockfile that might have already have this info.\n */\n setResolved() {\n // file | remote | workspace type of ids all points to a URI that\n // can be used as the `resolved` value, so we split the dep id\n // for these cases.\n const tuple = splitDepID(this.id)\n const [type, resolved] = tuple\n switch (type) {\n case 'registry':\n this.#registryNodeResolved(tuple)\n break\n default:\n this.resolved = resolved\n break\n }\n }\n\n setDefaultLocation() {\n const def = `./node_modules/.vlt/${this.id}/node_modules/${this.name}`\n\n // only relocate if the location is in node_modules already\n if (\n !this.importer &&\n (!this.#location ||\n (this.#location !== def &&\n /^(?:\\.\\/)?node_modules\\//.test(this.#location)))\n ) {\n this.#location = def\n }\n }\n\n /**\n * Add an edge from this node connecting it to a direct dependency.\n */\n addEdgesTo(type: DependencyTypeShort, spec: Spec, node?: Node) {\n const edge = new Edge(type, spec, this, node)\n node?.edgesIn.add(edge)\n this.edgesOut.set(spec.name, edge)\n return edge\n }\n\n toJSON() {\n return {\n id: this.id,\n name: this.name,\n version: this.version,\n location: this.location,\n importer: this.importer,\n manifest: this.manifest,\n projectRoot: this.projectRoot,\n integrity: this.integrity,\n resolved: this.resolved,\n dev: this.dev,\n optional: this.optional,\n }\n }\n\n toString() {\n return stringifyNode(this)\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"node.js","sourceRoot":"","sources":["../../src/node.ts"],"names":[],"mappings":"AACA,OAAO,EACL,qBAAqB,EACrB,KAAK,EACL,YAAY,EACZ,UAAU,GACX,MAAM,gBAAgB,CAAA;AAEvB,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAE/C,OAAO,EAAE,+BAA+B,EAAE,MAAM,eAAe,CAAA;AAQ/D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AASnD,MAAM,OAAO,IAAI;IACf,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC;QACtB,OAAO,oBAAoB,CAAA;IAC7B,CAAC;IAED,QAAQ,CAAa;IACrB,SAAS,CAAS;IAClB,YAAY,CAAqB;IAEjC,SAAS,GAAG,KAAK,CAAA;IACjB;;;;;;OAMG;IACH,IAAI,QAAQ;QACV,OA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,EAAE,IAAI,CAAC,QAAQ;YACvB,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;gBACpB,EAAE,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE;gBACnC,CAAC,CAAC,SAAS,CAAC;YACZ,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;gBACjB,EAAE,WAAW,EAAE,IAAI,CAAC,YAAY,EAAE;gBACpC,CAAC,CAAC,SAAS,CAAC;SACb,CAAA;IACH,CAAC;IAED,QAAQ;QACN,OAAO,aAAa,CAAC,IAAI,CAAC,CAAA;IAC5B,CAAC;CACF;AAED,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,KAAc,EAAiB,EAAE;IACtD,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,IAAI,IAAI;QACb,IAAI,IAAI,KAAK;QACb,UAAU,IAAI,KAAK;QAClB,KAAc,CAAC,MAAM,CAAC,WAAW,CAAC,KAAK,oBAAoB,CAC7D,CAAA;AACH,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,KAAc,EAAQ,EAAE;IAC7C,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;QACnB,MAAM,SAAS,CAAC,iBAAiB,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAA;IACtD,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC,CAAA","sourcesContent":["import type { PathScurry } from 'path-scurry'\nimport {\n isPackageNameConfused,\n getId,\n hydrateTuple,\n splitDepID,\n} from '@vltpkg/dep-id'\nimport type { DepID, DepIDTuple } from '@vltpkg/dep-id'\nimport { typeError } from '@vltpkg/error-cause'\nimport type { Spec, SpecOptions } from '@vltpkg/spec'\nimport { expandNormalizedManifestSymbols } from '@vltpkg/types'\nimport type {\n Integrity,\n NormalizedManifest,\n DependencyTypeShort,\n GraphLike,\n NodeLike,\n} from '@vltpkg/types'\nimport { Edge } from './edge.ts'\nimport type { Graph } from './graph.ts'\nimport { stringifyNode } from './stringify-node.ts'\nimport type { PackageInfoClient } from '@vltpkg/package-info'\nimport type { GraphModifier } from './modifiers.ts'\n\nexport type NodeOptions = SpecOptions & {\n projectRoot: string\n graph: GraphLike\n}\n\nexport class Node implements NodeLike {\n get [Symbol.toStringTag]() {\n return '@vltpkg/graph.Node'\n }\n\n #options: SpecOptions\n #location?: string\n #rawManifest?: NormalizedManifest\n\n #optional = false\n /**\n * True if a node is only reachable via optional or peerOptional edges from\n * any importer.\n *\n * Setting this to false, if previously set to true, will also unset\n * the flag on any optional-flagged non-optional dependencies.\n */\n get optional() {\n return this.#optional\n }\n set optional(optional: boolean) {\n const before = this.#optional\n this.#optional = optional\n if (before && !optional) {\n // unset for all deps, as well\n for (const { to, optional } of this.edgesOut.values()) {\n if (!optional && to?.optional) to.optional = false\n }\n }\n }\n\n isOptional(): this is Node & { optional: true } {\n return this.#optional\n }\n\n #dev = false\n /**\n * True if a node is only reachable via dev edges from any importer.\n *\n * Setting this to false, if previously set to true, will also unset\n * the flag on any dev-flagged non-dev dependencies.\n */\n get dev() {\n return this.#dev\n }\n set dev(dev: boolean) {\n const before = this.#dev\n this.#dev = dev\n if (before && !dev) {\n // unset for all deps, as well\n for (const { to, dev } of this.edgesOut.values()) {\n if (!dev && to?.dev) to.dev = false\n }\n }\n }\n\n isDev(): this is Node & { dev: true } {\n return this.#dev\n }\n\n /**\n * True if there's a manifest-confused package name.\n */\n confused = false\n\n /**\n * True if this node has been extracted to the file system.\n */\n extracted = false\n\n /**\n * List of edges coming into this node.\n */\n edgesIn = new Set<Edge>()\n\n /**\n * List of edges from this node into other nodes. This usually represents\n * that the connected node is a direct dependency of this node.\n */\n edgesOut = new Map<string, Edge>()\n\n /**\n * A `mainImporter` node may have workspace connected to it,\n * equivalent to its `edgesOut` linked deps.\n */\n workspaces: Map<string, Edge> | undefined\n\n /**\n * A reference to the {@link DepID} this node represents in the graph.\n */\n id: DepID\n\n /**\n * True if this node is an importer node.\n */\n importer = false\n\n /**\n * True if this node is the project root node.\n */\n mainImporter = false\n\n /**\n * A reference to the graph this node is a part of.\n */\n graph: Graph\n\n /**\n * The manifest integrity value.\n */\n integrity?: Integrity\n\n /**\n * The manifest this node represents in the graph.\n */\n manifest?: NormalizedManifest\n\n /**\n * Project where this node resides\n */\n projectRoot: string\n\n /**\n * For registry nodes, this is the registry we fetched them from.\n * Needed because their un-prefixed dependencies need to come from\n * the same registry, if it's not the default.\n */\n registry?: string\n\n /**\n * If this node has been modified as part of applying a {@link GraphModifier}\n * then this field will contain the modifier query that was applied.\n * Otherwise, it will be `undefined`.\n */\n modifier: string | undefined\n\n /**\n * The name of the package represented by this node, this is usually\n * equivalent to `manifest.name` but in a few ways it may differ such as\n * nodes loaded from a lockfile that lacks a loaded manifest.\n * This field should be used to retrieve package names instead.\n */\n #name?: string\n get name() {\n if (this.#name) return this.#name\n this.#name = this.id\n return this.#name\n }\n\n /**\n * The version of the package represented by this node, this is usually\n * equivalent to `manifest.version` but in a few ways it may differ such as\n * nodes loaded from a lockfile that lacks a loaded manifest.\n * This field should be used to retrieve package versions instead.\n */\n version?: string\n\n /**\n * An address {@link PackageInfoClient} may use to extract this package.\n */\n resolved?: string\n\n /**\n * Platform requirements (engines, os, cpu) extracted from manifest.\n * Stored separately for optional dependencies to enable platform checks\n * when manifest is not loaded.\n */\n platform?: {\n engines?: Record<string, string>\n os?: string[] | string\n cpu?: string[] | string\n }\n\n /**\n * Record of binary names to their paths in the package, if any.\n */\n bins?: Record<string, string>\n\n /**\n * True if this node has been built as part of the reify step.\n */\n built = false\n\n /**\n * Build state of this node - tracks whether it needs building, has been built, or failed.\n * - 'none': No build state (default)\n * - 'needed': Node needs to be built\n * - 'built': Node has been successfully built\n * - 'failed': Node build has failed\n */\n buildState: 'none' | 'needed' | 'built' | 'failed' = 'none'\n\n /**\n * Deterministic unique string used to identify (and ultimately duplicate)\n * nodes that are affected by a peer context set modified resolution.\n * These are appended to the node {@link DepID} as the `extra` suffix.\n */\n peerSetHash?: string\n\n /**\n * True if this node is detached from the graph.\n * This is used to indicate that the node is not part of the graph\n * although the node is still available as part of the resolution process.\n * Allows for skipping fetching manifests for detached nodes.\n */\n detached = false\n\n /**\n * The file system location for this node.\n */\n get location(): string {\n if (this.#location) {\n return this.#location\n }\n this.#location = `./node_modules/.vlt/${this.id}/node_modules/${this.name}`\n // if using the default location, it is in the store\n this.inVltStore = () => true\n return this.#location\n }\n\n set location(location: string) {\n this.#location = location\n // reset memoization, since it might be elsewhere now\n if (this.inVltStore !== Node.prototype.inVltStore) {\n this.inVltStore = Node.prototype.inVltStore\n }\n }\n\n /**\n * The resolved location of the node in the file system.\n */\n resolvedLocation(scurry: PathScurry): string {\n return scurry.cwd.resolve(this.location).fullpath()\n }\n\n /**\n * The location of the node_modules folder where this node's edgesOut\n * should be linked into. For nodes in the store, this is the parent\n * directory, since they're extracted into a node_modules folder\n * side by side with links to their deps. For nodes outside of the store\n * (ie, importers and arbitrary link deps) this is the node_modules folder\n * directly inside the node's directory.\n */\n nodeModules(scurry: PathScurry): string {\n const loc = this.resolvedLocation(scurry)\n return this.inVltStore() ?\n loc.substring(0, loc.length - this.name.length - 1)\n : scurry.resolve(loc, 'node_modules')\n }\n\n constructor(\n options: NodeOptions,\n id?: DepID,\n manifest?: NormalizedManifest,\n spec?: Spec,\n name?: string,\n version?: string,\n ) {\n this.#options = options\n this.projectRoot = options.projectRoot\n if (id) {\n this.id = id\n } else {\n if (!manifest || !spec) {\n throw typeError(\n 'A new Node needs either a manifest & spec or an id parameter',\n {\n manifest,\n },\n )\n }\n this.id = getId(spec, manifest)\n }\n this.graph = options.graph as Graph\n this.manifest = manifest\n\n this.#name = name || this.manifest?.name\n this.version = version || this.manifest?.version\n }\n\n /**\n * return true if this node is located in the vlt store\n * memoized the first time it's called, since the store location\n * doesn't change within the context of a single operation.\n */\n inVltStore(): boolean {\n // technically this just means it's in *a* vlt store, but we can safely\n // assume that a user won't construct a path like this by accident,\n // and there's only ever one store in any given project.\n const inStore = this.location.endsWith(\n `.vlt/${this.id}/node_modules/${this.name}`,\n )\n this.inVltStore = () => inStore\n return inStore\n }\n\n #registryNodeResolved(tuple: DepIDTuple) {\n const spec = hydrateTuple(tuple, this.#name, this.#options)\n this.resolved =\n this.manifest?.dist?.tarball || spec.conventionalRegistryTarball\n this.integrity ??= this.manifest?.dist?.integrity\n }\n\n get options() {\n return this.#options\n }\n\n /* c8 ignore next */\n set options(_opts: SpecOptions) {}\n\n equals(other: Node) {\n return this.id === other.id && this.location === other.location\n }\n\n /**\n * Sets the node as an importer along with its location.\n */\n setImporterLocation(location: string) {\n this.#location = location\n this.importer = true\n }\n\n /**\n * Sets the appropriate resolve / integrity value for this node.\n * Note that other places might also set these values, like for\n * example the lockfile that might have already have this info.\n */\n setResolved() {\n // file | remote | workspace type of ids all points to a URI that\n // can be used as the `resolved` value, so we split the dep id\n // for these cases.\n const tuple = splitDepID(this.id)\n const [type, resolved] = tuple\n switch (type) {\n case 'remote': {\n this.resolved = resolved\n this.integrity ??= this.manifest?.dist?.integrity\n break\n }\n case 'registry':\n this.#registryNodeResolved(tuple)\n break\n default:\n this.resolved = resolved\n break\n }\n }\n\n setDefaultLocation() {\n const def = `./node_modules/.vlt/${this.id}/node_modules/${this.name}`\n\n // only relocate if the location is in node_modules already\n if (\n !this.importer &&\n (!this.#location ||\n (this.#location !== def &&\n /^(?:\\.\\/)?node_modules\\//.test(this.#location)))\n ) {\n this.#location = def\n }\n }\n\n /**\n * Add an edge from this node connecting it to a direct dependency.\n */\n addEdgesTo(type: DependencyTypeShort, spec: Spec, node?: Node) {\n const edge = new Edge(type, spec, this, node)\n node?.edgesIn.add(edge)\n this.edgesOut.set(spec.name, edge)\n return edge\n }\n\n /**\n * The raw manifest before any modifications.\n * If not set, falls back to the current manifest.\n */\n get rawManifest(): NormalizedManifest | undefined {\n return this.#rawManifest ?? this.manifest\n }\n\n /**\n * Sets this node as having a manifest-confused manifest.\n */\n setConfusedManifest(\n fixed: NormalizedManifest,\n confused?: NormalizedManifest,\n ) {\n this.manifest = fixed\n this.#rawManifest = confused\n this.confused = true\n this.#name = this.manifest.name\n }\n\n /**\n * Sets this node as having a manifest-confused manifest.\n */\n maybeSetConfusedManifest(\n spec: Spec,\n confused?: NormalizedManifest,\n ) {\n if (isPackageNameConfused(spec, this.manifest?.name)) {\n this.setConfusedManifest(\n {\n ...this.manifest,\n name: spec.name,\n },\n confused,\n )\n }\n }\n\n toJSON() {\n return {\n id: this.id,\n name: this.name,\n version: this.version,\n location: this.location,\n importer: this.importer,\n manifest:\n this.manifest &&\n expandNormalizedManifestSymbols(this.manifest),\n projectRoot: this.projectRoot,\n integrity: this.integrity,\n resolved: this.resolved,\n dev: this.dev,\n optional: this.optional,\n confused: this.confused,\n modifier: this.modifier,\n platform: this.platform,\n buildState: this.buildState,\n ...(this.peerSetHash ?\n { peerSetHash: this.peerSetHash }\n : undefined),\n ...(this.confused ?\n { rawManifest: this.#rawManifest }\n : undefined),\n }\n }\n\n toString() {\n return stringifyNode(this)\n }\n}\n\nexport const isNode = (value: unknown): value is Node => {\n return (\n typeof value === 'object' &&\n value != null &&\n 'id' in value &&\n 'manifest' in value &&\n (value as Node)[Symbol.toStringTag] === '@vltpkg/graph.Node'\n )\n}\n\nexport const asNode = (value: unknown): Node => {\n if (!isNode(value)) {\n throw typeError('Expected a node', { found: value })\n }\n return value\n}\n"]}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { RollbackRemove } from '@vltpkg/rollback-remove';
|
|
2
|
-
import type { Manifest } from '@vltpkg/types';
|
|
3
2
|
import type { PathScurry } from 'path-scurry';
|
|
4
3
|
import type { Edge } from '../edge.ts';
|
|
5
4
|
/**
|
|
@@ -7,5 +6,5 @@ import type { Edge } from '../edge.ts';
|
|
|
7
6
|
* this does NOT chmod the bins to 0o777, because they might not exist
|
|
8
7
|
* until scripts are run, in the case of non-store deps like workspaces
|
|
9
8
|
*/
|
|
10
|
-
export declare const addEdge: (edge: Edge,
|
|
9
|
+
export declare const addEdge: (edge: Edge, scurry: PathScurry, remover: RollbackRemove, bins?: Record<string, string>) => Promise<void>;
|
|
11
10
|
//# sourceMappingURL=add-edge.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add-edge.d.ts","sourceRoot":"","sources":["../../../src/reify/add-edge.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;
|
|
1
|
+
{"version":3,"file":"add-edge.d.ts","sourceRoot":"","sources":["../../../src/reify/add-edge.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAG7D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAoCtC;;;;GAIG;AACH,eAAO,MAAM,OAAO,SACZ,IAAI,UACF,UAAU,WACT,cAAc,SAChB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,kBAqC9B,CAAA"}
|
|
@@ -1,30 +1,40 @@
|
|
|
1
1
|
import { cmdShimIfExists } from '@vltpkg/cmd-shim';
|
|
2
2
|
import { mkdir, symlink } from 'node:fs/promises';
|
|
3
3
|
import { dirname, relative } from 'node:path';
|
|
4
|
-
import { binPaths } from "./bin-paths.js";
|
|
5
4
|
const clobberSymlink = async (target, link, remover, type = 'file') => {
|
|
6
5
|
await mkdir(dirname(link), { recursive: true });
|
|
7
6
|
try {
|
|
8
7
|
await symlink(target, link, type);
|
|
9
8
|
}
|
|
10
|
-
catch (
|
|
11
|
-
|
|
12
|
-
if (er.code
|
|
13
|
-
|
|
9
|
+
catch (er) {
|
|
10
|
+
/* c8 ignore start */
|
|
11
|
+
if (er.code !== 'EEXIST') {
|
|
12
|
+
throw er;
|
|
13
|
+
}
|
|
14
|
+
/* c8 ignore stop */
|
|
15
|
+
// if the symlink exists, remove it
|
|
16
|
+
await remover.rm(link);
|
|
17
|
+
try {
|
|
18
|
+
// then try to create it again
|
|
19
|
+
await symlink(target, link, type);
|
|
14
20
|
/* c8 ignore start */
|
|
15
21
|
}
|
|
16
|
-
|
|
17
|
-
|
|
22
|
+
catch (er) {
|
|
23
|
+
// if the symlink still exists, then multiple paths could be writing to it
|
|
24
|
+
// so now just ignore that error. See https://github.com/vltpkg/vltpkg/issues/797
|
|
25
|
+
if (er.code !== 'EEXIST') {
|
|
26
|
+
throw er;
|
|
27
|
+
}
|
|
18
28
|
}
|
|
29
|
+
/* c8 ignore stop */
|
|
19
30
|
}
|
|
20
|
-
/* c8 ignore stop */
|
|
21
31
|
};
|
|
22
32
|
/**
|
|
23
33
|
* reify an edge into a node_modules folder, with bins linked
|
|
24
34
|
* this does NOT chmod the bins to 0o777, because they might not exist
|
|
25
35
|
* until scripts are run, in the case of non-store deps like workspaces
|
|
26
36
|
*/
|
|
27
|
-
export const addEdge = async (edge,
|
|
37
|
+
export const addEdge = async (edge, scurry, remover, bins) => {
|
|
28
38
|
if (!edge.to)
|
|
29
39
|
return;
|
|
30
40
|
const binRoot = scurry.resolve(edge.from.nodeModules(scurry), '.bin');
|
|
@@ -38,15 +48,16 @@ export const addEdge = async (edge, manifest, scurry, remover) => {
|
|
|
38
48
|
await p;
|
|
39
49
|
else
|
|
40
50
|
promises.push(p);
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
51
|
+
if (bins) {
|
|
52
|
+
for (const [key, val] of Object.entries(bins)) {
|
|
53
|
+
const link = scurry.resolve(binRoot, key);
|
|
54
|
+
const absTarget = scurry.resolve(path, val);
|
|
55
|
+
const target = relative(binRoot, absTarget);
|
|
56
|
+
// TODO: bash/cmd/ps1 shims on Windows
|
|
57
|
+
promises.push(process.platform === 'win32' ?
|
|
58
|
+
cmdShimIfExists(absTarget, link, remover)
|
|
59
|
+
: clobberSymlink(target, link, remover));
|
|
60
|
+
}
|
|
50
61
|
}
|
|
51
62
|
if (promises.length)
|
|
52
63
|
await Promise.all(promises);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add-edge.js","sourceRoot":"","sources":["../../../src/reify/add-edge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"add-edge.js","sourceRoot":"","sources":["../../../src/reify/add-edge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAElD,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAI7C,MAAM,cAAc,GAAG,KAAK,EAC1B,MAAc,EACd,IAAY,EACZ,OAAuB,EACvB,IAAI,GAAG,MAAM,EACb,EAAE;IACF,MAAM,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;IAC/C,IAAI,CAAC;QACH,MAAM,OAAO,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA;IACnC,CAAC;IAAC,OAAO,EAAE,EAAE,CAAC;QACZ,qBAAqB;QACrB,IAAK,EAA4B,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YACpD,MAAM,EAAE,CAAA;QACV,CAAC;QACD,oBAAoB;QAEpB,mCAAmC;QACnC,MAAM,OAAO,CAAC,EAAE,CAAC,IAAI,C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GAAG,EAAE,GAAG,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;YAC9C,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;YACzC,MAAM,SAAS,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;YAC3C,MAAM,MAAM,GAAG,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAC,CAAA;YAC3C,sCAAsC;YACtC,QAAQ,CAAC,IAAI,CACX,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC;gBAC5B,eAAe,CAAC,SAAS,EAAE,IAAI,EAAE,OAAO,CAAC;gBAC3C,CAAC,CAAC,cAAc,CAAC,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC,CACxC,CAAA;QACH,CAAC;IACH,CAAC;IACD,IAAI,QAAQ,CAAC,MAAM;QAAE,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;AAClD,CAAC,CAAA","sourcesContent":["import { cmdShimIfExists } from '@vltpkg/cmd-shim'\nimport type { RollbackRemove } from '@vltpkg/rollback-remove'\nimport { mkdir, symlink } from 'node:fs/promises'\nimport { dirname, relative } from 'node:path'\nimport type { PathScurry } from 'path-scurry'\nimport type { Edge } from '../edge.ts'\n\nconst clobberSymlink = async (\n target: string,\n link: string,\n remover: RollbackRemove,\n type = 'file',\n) => {\n await mkdir(dirname(link), { recursive: true })\n try {\n await symlink(target, link, type)\n } catch (er) {\n /* c8 ignore start */\n if ((er as NodeJS.ErrnoException).code !== 'EEXIST') {\n throw er\n }\n /* c8 ignore stop */\n\n // if the symlink exists, remove it\n await remover.rm(link)\n\n try {\n // then try to create it again\n await symlink(target, link, type)\n /* c8 ignore start */\n } catch (er) {\n // if the symlink still exists, then multiple paths could be writing to it\n // so now just ignore that error. See https://github.com/vltpkg/vltpkg/issues/797\n if ((er as NodeJS.ErrnoException).code !== 'EEXIST') {\n throw er\n }\n }\n /* c8 ignore stop */\n }\n}\n\n/**\n * reify an edge into a node_modules folder, with bins linked\n * this does NOT chmod the bins to 0o777, because they might not exist\n * until scripts are run, in the case of non-store deps like workspaces\n */\nexport const addEdge = async (\n edge: Edge,\n scurry: PathScurry,\n remover: RollbackRemove,\n bins?: Record<string, string>,\n) => {\n if (!edge.to) return\n const binRoot = scurry.resolve(\n edge.from.nodeModules(scurry),\n '.bin',\n )\n const path = scurry.resolve(\n edge.from.nodeModules(scurry),\n edge.spec.name,\n )\n const promises: Promise<unknown>[] = []\n const target = relative(\n dirname(path),\n edge.to.resolvedLocation(scurry),\n )\n\n // can only parallelize this on posix, because the win32 shims\n // need to know that they will exist before being created.\n const p = clobberSymlink(target, path, remover, 'dir')\n if (process.platform === 'win32') await p\n else promises.push(p)\n\n if (bins) {\n for (const [key, val] of Object.entries(bins)) {\n const link = scurry.resolve(binRoot, key)\n const absTarget = scurry.resolve(path, val)\n const target = relative(binRoot, absTarget)\n // TODO: bash/cmd/ps1 shims on Windows\n promises.push(\n process.platform === 'win32' ?\n cmdShimIfExists(absTarget, link, remover)\n : clobberSymlink(target, link, remover),\n )\n }\n }\n if (promises.length) await Promise.all(promises)\n}\n"]}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import type { PackageJson } from '@vltpkg/package-json';
|
|
2
1
|
import type { RollbackRemove } from '@vltpkg/rollback-remove';
|
|
3
2
|
import type { PathScurry } from 'path-scurry';
|
|
4
3
|
import type { Diff } from '../diff.ts';
|
|
5
|
-
export declare const addEdges: (diff: Diff,
|
|
4
|
+
export declare const addEdges: (diff: Diff, scurry: PathScurry, remover: RollbackRemove) => (() => Promise<unknown>)[];
|
|
6
5
|
//# sourceMappingURL=add-edges.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add-edges.d.ts","sourceRoot":"","sources":["../../../src/reify/add-edges.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"add-edges.d.ts","sourceRoot":"","sources":["../../../src/reify/add-edges.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAC7D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAGtC,eAAO,MAAM,QAAQ,SACb,IAAI,UACF,UAAU,WACT,cAAc,KACtB,CAAC,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC,EAS1B,CAAA"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { addEdge } from "./add-edge.js";
|
|
2
|
-
export const addEdges = (diff,
|
|
2
|
+
export const addEdges = (diff, scurry, remover) => {
|
|
3
3
|
const actions = [];
|
|
4
4
|
for (const edge of diff.edges.add) {
|
|
5
5
|
const { to } = edge;
|
|
6
6
|
if (!to)
|
|
7
7
|
continue;
|
|
8
|
-
const
|
|
9
|
-
actions.push(addEdge(edge,
|
|
8
|
+
const bins = to.bins;
|
|
9
|
+
actions.push(() => addEdge(edge, scurry, remover, bins));
|
|
10
10
|
}
|
|
11
11
|
return actions;
|
|
12
12
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add-edges.js","sourceRoot":"","sources":["../../../src/reify/add-edges.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"add-edges.js","sourceRoot":"","sources":["../../../src/reify/add-edges.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAEvC,MAAM,CAAC,MAAM,QAAQ,GAAG,CACtB,IAAU,EACV,MAAkB,EAClB,OAAuB,EACK,EAAE;IAC9B,MAAM,OAAO,GAA+B,EAAE,CAAA;IAC9C,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;QAClC,MAAM,EAAE,EAAE,EAAE,GAAG,IAAI,CAAA;QACnB,IAAI,CAAC,EAAE;YAAE,SAAQ;QACjB,MAAM,IAAI,GAAG,EAAE,CAAC,IAAI,CAAA;QACpB,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC,CAAA;IAC1D,CAAC;IACD,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA","sourcesContent":["import type { RollbackRemove } from '@vltpkg/rollback-remove'\nimport type { PathScurry } from 'path-scurry'\nimport type { Diff } from '../diff.ts'\nimport { addEdge } from './add-edge.ts'\n\nexport const addEdges = (\n diff: Diff,\n scurry: PathScurry,\n remover: RollbackRemove,\n): (() => Promise<unknown>)[] => {\n const actions: (() => Promise<unknown>)[] = []\n for (const edge of diff.edges.add) {\n const { to } = edge\n if (!to) continue\n const bins = to.bins\n actions.push(() => addEdge(edge, scurry, remover, bins))\n }\n return actions\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add-nodes.d.ts","sourceRoot":"","sources":["../../../src/reify/add-nodes.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"add-nodes.d.ts","sourceRoot":"","sources":["../../../src/reify/add-nodes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAC7D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAC7D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAGtC,eAAO,MAAM,QAAQ,SACb,IAAI,UACF,UAAU,WACT,cAAc,WACd,WAAW,eACP,iBAAiB,KAC7B,CAAC,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC,EAgB1B,CAAA"}
|
|
@@ -1,39 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { platformCheck } from '@vltpkg/pick-manifest';
|
|
3
|
-
import { optionalFail } from "./optional-fail.js";
|
|
1
|
+
import { extractNode } from "./extract-node.js";
|
|
4
2
|
export const addNodes = (diff, scurry, remover, options, packageInfo) => {
|
|
5
3
|
const actions = [];
|
|
6
4
|
// fetch and extract all the nodes, removing any in the way
|
|
7
5
|
for (const node of diff.nodes.add) {
|
|
8
|
-
/* c8 ignore next - all nodes have manifests by this point */
|
|
9
|
-
const { manifest = {} } = node;
|
|
10
6
|
// if it's not in the store, we don't have to extract it, because
|
|
11
7
|
// we're just linking to a location that already exists.
|
|
12
8
|
if (!node.inVltStore())
|
|
13
9
|
continue;
|
|
14
|
-
//
|
|
15
|
-
|
|
16
|
-
const from = scurry.resolve('');
|
|
17
|
-
const spec = hydrate(node.id, manifest.name, options);
|
|
18
|
-
const onErr = optionalFail(diff, node);
|
|
19
|
-
const { integrity, resolved } = node;
|
|
20
|
-
// if it's optional, and we know it isn't for this platform, or it's
|
|
21
|
-
// deprecated, don't install it. if it's not optional, try our best.
|
|
22
|
-
if (onErr &&
|
|
23
|
-
(manifest.deprecated ||
|
|
24
|
-
!platformCheck(manifest, process.version, process.platform, process.arch))) {
|
|
25
|
-
onErr();
|
|
10
|
+
// skip nodes that have already been extracted
|
|
11
|
+
if (node.extracted)
|
|
26
12
|
continue;
|
|
27
|
-
|
|
28
|
-
actions.push(() => remover.rm(target).then(() => onErr ?
|
|
29
|
-
packageInfo
|
|
30
|
-
.extract(spec, target, { from, integrity, resolved })
|
|
31
|
-
.then(x => x, onErr)
|
|
32
|
-
: packageInfo.extract(spec, target, {
|
|
33
|
-
from,
|
|
34
|
-
integrity,
|
|
35
|
-
resolved,
|
|
36
|
-
})));
|
|
13
|
+
actions.push(() => extractNode(node, scurry, remover, options, packageInfo, diff));
|
|
37
14
|
}
|
|
38
15
|
return actions;
|
|
39
16
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add-nodes.js","sourceRoot":"","sources":["../../../src/reify/add-nodes.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"add-nodes.js","sourceRoot":"","sources":["../../../src/reify/add-nodes.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAE/C,MAAM,CAAC,MAAM,QAAQ,GAAG,CACtB,IAAU,EACV,MAAkB,EAClB,OAAuB,EACvB,OAAoB,EACpB,WAA8B,EACF,EAAE;IAC9B,MAAM,OAAO,GAA+B,EAAE,CAAA;IAC9C,2DAA2D;IAC3D,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;QAClC,iEAAiE;QACjE,wDAAwD;QACxD,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE;YAAE,SAAQ;QAEhC,8CAA8C;QAC9C,IAAI,IAAI,CAAC,SAAS;YAAE,SAAQ;QAE5B,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,CAChB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,IAAI,CAAC,CAC/D,CAAA;IACH,CAAC;IACD,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA","sourcesContent":["import type { PackageInfoClient } from '@vltpkg/package-info'\nimport type { RollbackRemove } from '@vltpkg/rollback-remove'\nimport type { SpecOptions } from '@vltpkg/spec'\nimport type { PathScurry } from 'path-scurry'\nimport type { Diff } from '../diff.ts'\nimport { extractNode } from './extract-node.ts'\n\nexport const addNodes = (\n diff: Diff,\n scurry: PathScurry,\n remover: RollbackRemove,\n options: SpecOptions,\n packageInfo: PackageInfoClient,\n): (() => Promise<unknown>)[] => {\n const actions: (() => Promise<unknown>)[] = []\n // fetch and extract all the nodes, removing any in the way\n for (const node of diff.nodes.add) {\n // if it's not in the store, we don't have to extract it, because\n // we're just linking to a location that already exists.\n if (!node.inVltStore()) continue\n\n // skip nodes that have already been extracted\n if (node.extracted) continue\n\n actions.push(() =>\n extractNode(node, scurry, remover, options, packageInfo, diff),\n )\n }\n return actions\n}\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { PathScurry } from 'path-scurry';
|
|
2
|
+
import type { Node } from '../node.ts';
|
|
3
|
+
/**
|
|
4
|
+
* Make all the packages' bins executable.
|
|
5
|
+
*/
|
|
6
|
+
export declare const binChmodAll: (nodes: Iterable<Node>, scurry: PathScurry) => Promise<void>;
|
|
7
|
+
/**
|
|
8
|
+
* Make all the package's bins executable.
|
|
9
|
+
*/
|
|
10
|
+
export declare const binChmod: (node: Node, scurry: PathScurry) => Promise<void>;
|
|
11
|
+
//# sourceMappingURL=bin-chmod.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bin-chmod.d.ts","sourceRoot":"","sources":["../../../src/reify/bin-chmod.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAEtC;;GAEG;AACH,eAAO,MAAM,WAAW,UACf,QAAQ,CAAC,IAAI,CAAC,UACb,UAAU,KACjB,OAAO,CAAC,IAAI,CAMd,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,QAAQ,SACb,IAAI,UACF,UAAU,KACjB,OAAO,CAAC,IAAI,CAad,CAAA"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { statSync, existsSync } from 'node:fs';
|
|
2
|
+
import { chmod } from 'node:fs/promises';
|
|
3
|
+
/**
|
|
4
|
+
* Make all the packages' bins executable.
|
|
5
|
+
*/
|
|
6
|
+
export const binChmodAll = async (nodes, scurry) => {
|
|
7
|
+
const chmods = [];
|
|
8
|
+
for (const node of nodes) {
|
|
9
|
+
chmods.push(binChmod(node, scurry));
|
|
10
|
+
}
|
|
11
|
+
await Promise.all(chmods);
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Make all the package's bins executable.
|
|
15
|
+
*/
|
|
16
|
+
export const binChmod = async (node, scurry) => {
|
|
17
|
+
const chmods = [];
|
|
18
|
+
if (!node.bins)
|
|
19
|
+
return;
|
|
20
|
+
for (const bin of Object.values(node.bins)) {
|
|
21
|
+
const path = scurry.resolve(`${node.resolvedLocation(scurry)}/${bin}`);
|
|
22
|
+
// only try to make executable if the file exists
|
|
23
|
+
if (existsSync(path)) {
|
|
24
|
+
chmods.push(makeExecutable(path));
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
await Promise.all(chmods);
|
|
28
|
+
};
|
|
29
|
+
// 0 is "not yet set"
|
|
30
|
+
// This is defined by doing `0o111 | <mode>` so that systems
|
|
31
|
+
// that create files group-writable result in 0o775 instead of 0o755
|
|
32
|
+
let execMode = 0;
|
|
33
|
+
const makeExecutable = async (path) => {
|
|
34
|
+
if (!execMode) {
|
|
35
|
+
execMode = (statSync(path).mode & 0o777) | 0o111;
|
|
36
|
+
}
|
|
37
|
+
await chmod(path, execMode);
|
|
38
|
+
};
|
|
39
|
+
//# sourceMappingURL=bin-chmod.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bin-chmod.js","sourceRoot":"","sources":["../../../src/reify/bin-chmod.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAC9C,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AAIxC;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,KAAK,EAC9B,KAAqB,EACrB,MAAkB,EACH,EAAE;IACjB,MAAM,MAAM,GAAoB,EAAE,CAAA;IAClC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAA;IACrC,CAAC;IACD,MAAM,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;AAC3B,CAAC,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,KAAK,EAC3B,IAAU,EACV,MAAkB,EACH,EAAE;IACjB,MAAM,MAAM,GAAoB,EAAE,CAAA;IAClC,IAAI,CAAC,IAAI,CAAC,IAAI;QAAE,OAAM;IACtB,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QAC3C,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,CACzB,GAAG,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,IAAI,GAAG,EAAE,CAC1C,CAAA;QACD,iDAAiD;QACjD,IAAI,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;YACrB,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAA;QACnC,CAAC;IACH,CAAC;IACD,MAAM,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;AAC3B,CAAC,CAAA;AAED,qBAAqB;AACrB,4DAA4D;AAC5D,oEAAoE;AACpE,IAAI,QAAQ,GAAG,CAAC,CAAA;AAChB,MAAM,cAAc,GAAG,KAAK,EAAE,IAAY,EAAE,EAAE;IAC5C,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,QAAQ,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,IAAI,GAAG,KAAK,CAAC,GAAG,KAAK,CAAA;IAClD,CAAC;IACD,MAAM,KAAK,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAA;AAC7B,CAAC,CAAA","sourcesContent":["import { statSync, existsSync } from 'node:fs'\nimport { chmod } from 'node:fs/promises'\nimport type { PathScurry } from 'path-scurry'\nimport type { Node } from '../node.ts'\n\n/**\n * Make all the packages' bins executable.\n */\nexport const binChmodAll = async (\n nodes: Iterable<Node>,\n scurry: PathScurry,\n): Promise<void> => {\n const chmods: Promise<void>[] = []\n for (const node of nodes) {\n chmods.push(binChmod(node, scurry))\n }\n await Promise.all(chmods)\n}\n\n/**\n * Make all the package's bins executable.\n */\nexport const binChmod = async (\n node: Node,\n scurry: PathScurry,\n): Promise<void> => {\n const chmods: Promise<void>[] = []\n if (!node.bins) return\n for (const bin of Object.values(node.bins)) {\n const path = scurry.resolve(\n `${node.resolvedLocation(scurry)}/${bin}`,\n )\n // only try to make executable if the file exists\n if (existsSync(path)) {\n chmods.push(makeExecutable(path))\n }\n }\n await Promise.all(chmods)\n}\n\n// 0 is \"not yet set\"\n// This is defined by doing `0o111 | <mode>` so that systems\n// that create files group-writable result in 0o775 instead of 0o755\nlet execMode = 0\nconst makeExecutable = async (path: string) => {\n if (!execMode) {\n execMode = (statSync(path).mode & 0o777) | 0o111\n }\n await chmod(path, execMode)\n}\n"]}
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import type { PackageJson } from '@vltpkg/package-json';
|
|
2
2
|
import type { PathScurry } from 'path-scurry';
|
|
3
|
+
import type { DepID } from '@vltpkg/dep-id';
|
|
3
4
|
import type { Diff } from '../diff.ts';
|
|
4
|
-
|
|
5
|
+
import type { Node } from '../node.ts';
|
|
6
|
+
/**
|
|
7
|
+
* Returns an object mapping registries to the names of the packages built.
|
|
8
|
+
*/
|
|
9
|
+
export type BuildResult = {
|
|
10
|
+
success: Node[];
|
|
11
|
+
failure: Node[];
|
|
12
|
+
};
|
|
13
|
+
export declare const build: (diff: Diff, packageJson: PackageJson, scurry: PathScurry, allowScriptsNodes: Set<DepID>) => Promise<BuildResult>;
|
|
5
14
|
//# sourceMappingURL=build.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../../src/reify/build.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../../src/reify/build.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAGvD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAC3C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AACtC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAKtC;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,OAAO,EAAE,IAAI,EAAE,CAAA;IACf,OAAO,EAAE,IAAI,EAAE,CAAA;CAChB,CAAA;AAED,eAAO,MAAM,KAAK,SACV,IAAI,eACG,WAAW,UAChB,UAAU,qBACC,GAAG,CAAC,KAAK,CAAC,KAC5B,OAAO,CAAC,WAAW,CA6DrB,CAAA"}
|