@vltpkg/graph 1.0.0-rc.2 → 1.0.0-rc.22
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 +101 -22
- package/package.json +51 -63
- package/dist/esm/actual/load.d.ts +0 -100
- package/dist/esm/actual/load.d.ts.map +0 -1
- package/dist/esm/actual/load.js +0 -304
- package/dist/esm/actual/load.js.map +0 -1
- package/dist/esm/browser.d.ts +0 -15
- package/dist/esm/browser.d.ts.map +0 -1
- package/dist/esm/browser.js +0 -17
- package/dist/esm/browser.js.map +0 -1
- package/dist/esm/build.d.ts +0 -29
- package/dist/esm/build.d.ts.map +0 -1
- package/dist/esm/build.js +0 -79
- package/dist/esm/build.js.map +0 -1
- package/dist/esm/dependencies.d.ts +0 -66
- package/dist/esm/dependencies.d.ts.map +0 -1
- package/dist/esm/dependencies.js +0 -112
- package/dist/esm/dependencies.js.map +0 -1
- package/dist/esm/diff.d.ts +0 -116
- package/dist/esm/diff.d.ts.map +0 -1
- package/dist/esm/diff.js +0 -148
- package/dist/esm/diff.js.map +0 -1
- package/dist/esm/edge.d.ts +0 -46
- package/dist/esm/edge.d.ts.map +0 -1
- package/dist/esm/edge.js +0 -74
- package/dist/esm/edge.js.map +0 -1
- package/dist/esm/graph.d.ts +0 -133
- package/dist/esm/graph.d.ts.map +0 -1
- package/dist/esm/graph.js +0 -407
- package/dist/esm/graph.js.map +0 -1
- package/dist/esm/ideal/add-nodes.d.ts +0 -34
- package/dist/esm/ideal/add-nodes.d.ts.map +0 -1
- package/dist/esm/ideal/add-nodes.js +0 -39
- package/dist/esm/ideal/add-nodes.js.map +0 -1
- package/dist/esm/ideal/append-nodes.d.ts +0 -19
- package/dist/esm/ideal/append-nodes.d.ts.map +0 -1
- package/dist/esm/ideal/append-nodes.js +0 -289
- package/dist/esm/ideal/append-nodes.js.map +0 -1
- package/dist/esm/ideal/build-ideal-from-starting-graph.d.ts +0 -15
- package/dist/esm/ideal/build-ideal-from-starting-graph.d.ts.map +0 -1
- package/dist/esm/ideal/build-ideal-from-starting-graph.js +0 -55
- package/dist/esm/ideal/build-ideal-from-starting-graph.js.map +0 -1
- package/dist/esm/ideal/build.d.ts +0 -41
- package/dist/esm/ideal/build.d.ts.map +0 -1
- package/dist/esm/ideal/build.js +0 -48
- package/dist/esm/ideal/build.js.map +0 -1
- package/dist/esm/ideal/get-importer-specs.d.ts +0 -14
- package/dist/esm/ideal/get-importer-specs.d.ts.map +0 -1
- package/dist/esm/ideal/get-importer-specs.js +0 -106
- package/dist/esm/ideal/get-importer-specs.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/ideal/remove-satisfied-specs.d.ts +0 -8
- package/dist/esm/ideal/remove-satisfied-specs.d.ts.map +0 -1
- package/dist/esm/ideal/remove-satisfied-specs.js +0 -35
- package/dist/esm/ideal/remove-satisfied-specs.js.map +0 -1
- package/dist/esm/ideal/types.d.ts +0 -35
- package/dist/esm/ideal/types.d.ts.map +0 -1
- package/dist/esm/ideal/types.js +0 -2
- package/dist/esm/ideal/types.js.map +0 -1
- package/dist/esm/index.d.ts +0 -38
- package/dist/esm/index.d.ts.map +0 -1
- package/dist/esm/index.js +0 -32
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/install.d.ts +0 -19
- package/dist/esm/install.d.ts.map +0 -1
- package/dist/esm/install.js +0 -173
- package/dist/esm/install.js.map +0 -1
- package/dist/esm/lockfile/load-edges.d.ts +0 -12
- package/dist/esm/lockfile/load-edges.d.ts.map +0 -1
- package/dist/esm/lockfile/load-edges.js +0 -105
- package/dist/esm/lockfile/load-edges.js.map +0 -1
- package/dist/esm/lockfile/load-nodes.d.ts +0 -5
- package/dist/esm/lockfile/load-nodes.d.ts.map +0 -1
- package/dist/esm/lockfile/load-nodes.js +0 -95
- package/dist/esm/lockfile/load-nodes.js.map +0 -1
- package/dist/esm/lockfile/load.d.ts +0 -50
- package/dist/esm/lockfile/load.d.ts.map +0 -1
- package/dist/esm/lockfile/load.js +0 -89
- package/dist/esm/lockfile/load.js.map +0 -1
- package/dist/esm/lockfile/save.d.ts +0 -31
- package/dist/esm/lockfile/save.d.ts.map +0 -1
- package/dist/esm/lockfile/save.js +0 -173
- package/dist/esm/lockfile/save.js.map +0 -1
- package/dist/esm/lockfile/types.d.ts +0 -89
- package/dist/esm/lockfile/types.d.ts.map +0 -1
- package/dist/esm/lockfile/types.js +0 -44
- package/dist/esm/lockfile/types.js.map +0 -1
- package/dist/esm/modifiers.d.ts +0 -189
- package/dist/esm/modifiers.d.ts.map +0 -1
- package/dist/esm/modifiers.js +0 -330
- package/dist/esm/modifiers.js.map +0 -1
- package/dist/esm/node.d.ts +0 -219
- package/dist/esm/node.d.ts.map +0 -1
- package/dist/esm/node.js +0 -368
- package/dist/esm/node.js.map +0 -1
- package/dist/esm/non-empty-list.d.ts +0 -3
- package/dist/esm/non-empty-list.d.ts.map +0 -1
- package/dist/esm/non-empty-list.js +0 -3
- package/dist/esm/non-empty-list.js.map +0 -1
- package/dist/esm/package.json +0 -3
- package/dist/esm/reify/add-edge.d.ts +0 -10
- package/dist/esm/reify/add-edge.d.ts.map +0 -1
- package/dist/esm/reify/add-edge.js +0 -65
- package/dist/esm/reify/add-edge.js.map +0 -1
- package/dist/esm/reify/add-edges.d.ts +0 -5
- package/dist/esm/reify/add-edges.d.ts.map +0 -1
- package/dist/esm/reify/add-edges.js +0 -12
- package/dist/esm/reify/add-edges.js.map +0 -1
- package/dist/esm/reify/add-nodes.d.ts +0 -7
- package/dist/esm/reify/add-nodes.d.ts.map +0 -1
- package/dist/esm/reify/add-nodes.js +0 -17
- package/dist/esm/reify/add-nodes.js.map +0 -1
- package/dist/esm/reify/bin-chmod.d.ts +0 -11
- package/dist/esm/reify/bin-chmod.d.ts.map +0 -1
- package/dist/esm/reify/bin-chmod.js +0 -39
- package/dist/esm/reify/bin-chmod.js.map +0 -1
- package/dist/esm/reify/build.d.ts +0 -14
- package/dist/esm/reify/build.d.ts.map +0 -1
- package/dist/esm/reify/build.js +0 -103
- package/dist/esm/reify/build.js.map +0 -1
- package/dist/esm/reify/calculate-save-value.d.ts +0 -3
- package/dist/esm/reify/calculate-save-value.d.ts.map +0 -1
- package/dist/esm/reify/calculate-save-value.js +0 -45
- package/dist/esm/reify/calculate-save-value.js.map +0 -1
- package/dist/esm/reify/check-needed-build.d.ts +0 -25
- package/dist/esm/reify/check-needed-build.d.ts.map +0 -1
- package/dist/esm/reify/check-needed-build.js +0 -50
- package/dist/esm/reify/check-needed-build.js.map +0 -1
- package/dist/esm/reify/delete-edge.d.ts +0 -5
- package/dist/esm/reify/delete-edge.d.ts.map +0 -1
- package/dist/esm/reify/delete-edge.js +0 -28
- package/dist/esm/reify/delete-edge.js.map +0 -1
- package/dist/esm/reify/delete-edges.d.ts +0 -5
- package/dist/esm/reify/delete-edges.d.ts.map +0 -1
- package/dist/esm/reify/delete-edges.js +0 -14
- package/dist/esm/reify/delete-edges.js.map +0 -1
- package/dist/esm/reify/delete-nodes.d.ts +0 -5
- package/dist/esm/reify/delete-nodes.d.ts.map +0 -1
- package/dist/esm/reify/delete-nodes.js +0 -16
- package/dist/esm/reify/delete-nodes.js.map +0 -1
- package/dist/esm/reify/extract-node.d.ts +0 -24
- package/dist/esm/reify/extract-node.d.ts.map +0 -1
- package/dist/esm/reify/extract-node.js +0 -76
- package/dist/esm/reify/extract-node.js.map +0 -1
- package/dist/esm/reify/index.d.ts +0 -34
- package/dist/esm/reify/index.d.ts.map +0 -1
- package/dist/esm/reify/index.js +0 -161
- package/dist/esm/reify/index.js.map +0 -1
- package/dist/esm/reify/internal-hoist.d.ts +0 -9
- package/dist/esm/reify/internal-hoist.d.ts.map +0 -1
- package/dist/esm/reify/internal-hoist.js +0 -134
- package/dist/esm/reify/internal-hoist.js.map +0 -1
- package/dist/esm/reify/optional-fail.d.ts +0 -16
- package/dist/esm/reify/optional-fail.d.ts.map +0 -1
- package/dist/esm/reify/optional-fail.js +0 -16
- package/dist/esm/reify/optional-fail.js.map +0 -1
- package/dist/esm/reify/rollback.d.ts +0 -5
- package/dist/esm/reify/rollback.d.ts.map +0 -1
- package/dist/esm/reify/rollback.js +0 -24
- package/dist/esm/reify/rollback.js.map +0 -1
- package/dist/esm/reify/update-importers-package-json.d.ts +0 -36
- package/dist/esm/reify/update-importers-package-json.d.ts.map +0 -1
- package/dist/esm/reify/update-importers-package-json.js +0 -120
- package/dist/esm/reify/update-importers-package-json.js.map +0 -1
- package/dist/esm/remove-optional-subgraph.d.ts +0 -34
- package/dist/esm/remove-optional-subgraph.d.ts.map +0 -1
- package/dist/esm/remove-optional-subgraph.js +0 -48
- package/dist/esm/remove-optional-subgraph.js.map +0 -1
- package/dist/esm/resolve-save-type.d.ts +0 -6
- package/dist/esm/resolve-save-type.d.ts.map +0 -1
- package/dist/esm/resolve-save-type.js +0 -5
- package/dist/esm/resolve-save-type.js.map +0 -1
- package/dist/esm/stringify-node.d.ts +0 -3
- package/dist/esm/stringify-node.d.ts.map +0 -1
- package/dist/esm/stringify-node.js +0 -24
- package/dist/esm/stringify-node.js.map +0 -1
- package/dist/esm/transfer-data/load.d.ts +0 -44
- package/dist/esm/transfer-data/load.d.ts.map +0 -1
- package/dist/esm/transfer-data/load.js +0 -176
- package/dist/esm/transfer-data/load.js.map +0 -1
- package/dist/esm/uninstall.d.ts +0 -15
- package/dist/esm/uninstall.d.ts.map +0 -1
- package/dist/esm/uninstall.js +0 -58
- package/dist/esm/uninstall.js.map +0 -1
- package/dist/esm/update.d.ts +0 -13
- package/dist/esm/update.d.ts.map +0 -1
- package/dist/esm/update.js +0 -63
- package/dist/esm/update.js.map +0 -1
- package/dist/esm/virtual-root.d.ts +0 -16
- package/dist/esm/virtual-root.d.ts.map +0 -1
- package/dist/esm/virtual-root.js +0 -79
- package/dist/esm/virtual-root.js.map +0 -1
- package/dist/esm/visualization/human-readable-output.d.ts +0 -27
- package/dist/esm/visualization/human-readable-output.d.ts.map +0 -1
- package/dist/esm/visualization/human-readable-output.js +0 -159
- package/dist/esm/visualization/human-readable-output.js.map +0 -1
- package/dist/esm/visualization/json-output.d.ts +0 -41
- package/dist/esm/visualization/json-output.d.ts.map +0 -1
- package/dist/esm/visualization/json-output.js +0 -51
- package/dist/esm/visualization/json-output.js.map +0 -1
- package/dist/esm/visualization/mermaid-output.d.ts +0 -17
- package/dist/esm/visualization/mermaid-output.d.ts.map +0 -1
- package/dist/esm/visualization/mermaid-output.js +0 -123
- package/dist/esm/visualization/mermaid-output.js.map +0 -1
- package/dist/esm/visualization/object-like-output.d.ts +0 -3
- package/dist/esm/visualization/object-like-output.d.ts.map +0 -1
- package/dist/esm/visualization/object-like-output.js +0 -48
- package/dist/esm/visualization/object-like-output.js.map +0 -1
package/dist/esm/node.js
DELETED
|
@@ -1,368 +0,0 @@
|
|
|
1
|
-
import { isPackageNameConfused, getId, hydrateTuple, splitDepID, } from '@vltpkg/dep-id';
|
|
2
|
-
import { typeError } from '@vltpkg/error-cause';
|
|
3
|
-
import { expandNormalizedManifestSymbols } from '@vltpkg/types';
|
|
4
|
-
import { Edge } from "./edge.js";
|
|
5
|
-
import { stringifyNode } from "./stringify-node.js";
|
|
6
|
-
export class Node {
|
|
7
|
-
get [Symbol.toStringTag]() {
|
|
8
|
-
return '@vltpkg/graph.Node';
|
|
9
|
-
}
|
|
10
|
-
#options;
|
|
11
|
-
#location;
|
|
12
|
-
#rawManifest;
|
|
13
|
-
#optional = false;
|
|
14
|
-
/**
|
|
15
|
-
* True if a node is only reachable via optional or peerOptional edges from
|
|
16
|
-
* any importer.
|
|
17
|
-
*
|
|
18
|
-
* Setting this to false, if previously set to true, will also unset
|
|
19
|
-
* the flag on any optional-flagged non-optional dependencies.
|
|
20
|
-
*/
|
|
21
|
-
get optional() {
|
|
22
|
-
return this.#optional;
|
|
23
|
-
}
|
|
24
|
-
set optional(optional) {
|
|
25
|
-
const before = this.#optional;
|
|
26
|
-
this.#optional = optional;
|
|
27
|
-
if (before && !optional) {
|
|
28
|
-
// unset for all deps, as well
|
|
29
|
-
for (const { to, optional } of this.edgesOut.values()) {
|
|
30
|
-
if (!optional && to?.optional)
|
|
31
|
-
to.optional = false;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
isOptional() {
|
|
36
|
-
return this.#optional;
|
|
37
|
-
}
|
|
38
|
-
#dev = false;
|
|
39
|
-
/**
|
|
40
|
-
* True if a node is only reachable via dev edges from any importer.
|
|
41
|
-
*
|
|
42
|
-
* Setting this to false, if previously set to true, will also unset
|
|
43
|
-
* the flag on any dev-flagged non-dev dependencies.
|
|
44
|
-
*/
|
|
45
|
-
get dev() {
|
|
46
|
-
return this.#dev;
|
|
47
|
-
}
|
|
48
|
-
set dev(dev) {
|
|
49
|
-
const before = this.#dev;
|
|
50
|
-
this.#dev = dev;
|
|
51
|
-
if (before && !dev) {
|
|
52
|
-
// unset for all deps, as well
|
|
53
|
-
for (const { to, dev } of this.edgesOut.values()) {
|
|
54
|
-
if (!dev && to?.dev)
|
|
55
|
-
to.dev = false;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
isDev() {
|
|
60
|
-
return this.#dev;
|
|
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;
|
|
70
|
-
/**
|
|
71
|
-
* List of edges coming into this node.
|
|
72
|
-
*/
|
|
73
|
-
edgesIn = new Set();
|
|
74
|
-
/**
|
|
75
|
-
* List of edges from this node into other nodes. This usually represents
|
|
76
|
-
* that the connected node is a direct dependency of this node.
|
|
77
|
-
*/
|
|
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;
|
|
84
|
-
/**
|
|
85
|
-
* A reference to the {@link DepID} this node represents in the graph.
|
|
86
|
-
*/
|
|
87
|
-
id;
|
|
88
|
-
/**
|
|
89
|
-
* True if this node is an importer node.
|
|
90
|
-
*/
|
|
91
|
-
importer = false;
|
|
92
|
-
/**
|
|
93
|
-
* True if this node is the project root node.
|
|
94
|
-
*/
|
|
95
|
-
mainImporter = false;
|
|
96
|
-
/**
|
|
97
|
-
* A reference to the graph this node is a part of.
|
|
98
|
-
*/
|
|
99
|
-
graph;
|
|
100
|
-
/**
|
|
101
|
-
* The manifest integrity value.
|
|
102
|
-
*/
|
|
103
|
-
integrity;
|
|
104
|
-
/**
|
|
105
|
-
* The manifest this node represents in the graph.
|
|
106
|
-
*/
|
|
107
|
-
manifest;
|
|
108
|
-
/**
|
|
109
|
-
* Project where this node resides
|
|
110
|
-
*/
|
|
111
|
-
projectRoot;
|
|
112
|
-
/**
|
|
113
|
-
* For registry nodes, this is the registry we fetched them from.
|
|
114
|
-
* Needed because their un-prefixed dependencies need to come from
|
|
115
|
-
* the same registry, if it's not the default.
|
|
116
|
-
*/
|
|
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;
|
|
124
|
-
/**
|
|
125
|
-
* The name of the package represented by this node, this is usually
|
|
126
|
-
* equivalent to `manifest.name` but in a few ways it may differ such as
|
|
127
|
-
* nodes loaded from a lockfile that lacks a loaded manifest.
|
|
128
|
-
* This field should be used to retrieve package names instead.
|
|
129
|
-
*/
|
|
130
|
-
#name;
|
|
131
|
-
get name() {
|
|
132
|
-
if (this.#name)
|
|
133
|
-
return this.#name;
|
|
134
|
-
this.#name = this.id;
|
|
135
|
-
return this.#name;
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* The version of the package represented by this node, this is usually
|
|
139
|
-
* equivalent to `manifest.version` but in a few ways it may differ such as
|
|
140
|
-
* nodes loaded from a lockfile that lacks a loaded manifest.
|
|
141
|
-
* This field should be used to retrieve package versions instead.
|
|
142
|
-
*/
|
|
143
|
-
version;
|
|
144
|
-
/**
|
|
145
|
-
* An address {@link PackageInfoClient} may use to extract this package.
|
|
146
|
-
*/
|
|
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
|
-
* The file system location for this node.
|
|
172
|
-
*/
|
|
173
|
-
get location() {
|
|
174
|
-
if (this.#location) {
|
|
175
|
-
return this.#location;
|
|
176
|
-
}
|
|
177
|
-
this.#location = `./node_modules/.vlt/${this.id}/node_modules/${this.name}`;
|
|
178
|
-
// if using the default location, it is in the store
|
|
179
|
-
this.inVltStore = () => true;
|
|
180
|
-
return this.#location;
|
|
181
|
-
}
|
|
182
|
-
set location(location) {
|
|
183
|
-
this.#location = location;
|
|
184
|
-
// reset memoization, since it might be elsewhere now
|
|
185
|
-
if (this.inVltStore !== Node.prototype.inVltStore) {
|
|
186
|
-
this.inVltStore = Node.prototype.inVltStore;
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
/**
|
|
190
|
-
* The resolved location of the node in the file system.
|
|
191
|
-
*/
|
|
192
|
-
resolvedLocation(scurry) {
|
|
193
|
-
return scurry.cwd.resolve(this.location).fullpath();
|
|
194
|
-
}
|
|
195
|
-
/**
|
|
196
|
-
* The location of the node_modules folder where this node's edgesOut
|
|
197
|
-
* should be linked into. For nodes in the store, this is the parent
|
|
198
|
-
* directory, since they're extracted into a node_modules folder
|
|
199
|
-
* side by side with links to their deps. For nodes outside of the store
|
|
200
|
-
* (ie, importers and arbitrary link deps) this is the node_modules folder
|
|
201
|
-
* directly inside the node's directory.
|
|
202
|
-
*/
|
|
203
|
-
nodeModules(scurry) {
|
|
204
|
-
const loc = this.resolvedLocation(scurry);
|
|
205
|
-
return this.inVltStore() ?
|
|
206
|
-
loc.substring(0, loc.length - this.name.length - 1)
|
|
207
|
-
: scurry.resolve(loc, 'node_modules');
|
|
208
|
-
}
|
|
209
|
-
constructor(options, id, manifest, spec, name, version) {
|
|
210
|
-
this.#options = options;
|
|
211
|
-
this.projectRoot = options.projectRoot;
|
|
212
|
-
if (id) {
|
|
213
|
-
this.id = id;
|
|
214
|
-
}
|
|
215
|
-
else {
|
|
216
|
-
if (!manifest || !spec) {
|
|
217
|
-
throw typeError('A new Node needs either a manifest & spec or an id parameter', {
|
|
218
|
-
manifest,
|
|
219
|
-
});
|
|
220
|
-
}
|
|
221
|
-
this.id = getId(spec, manifest);
|
|
222
|
-
}
|
|
223
|
-
this.graph = options.graph;
|
|
224
|
-
this.manifest = manifest;
|
|
225
|
-
this.#name = name || this.manifest?.name;
|
|
226
|
-
this.version = version || this.manifest?.version;
|
|
227
|
-
}
|
|
228
|
-
/**
|
|
229
|
-
* return true if this node is located in the vlt store
|
|
230
|
-
* memoized the first time it's called, since the store location
|
|
231
|
-
* doesn't change within the context of a single operation.
|
|
232
|
-
*/
|
|
233
|
-
inVltStore() {
|
|
234
|
-
// technically this just means it's in *a* vlt store, but we can safely
|
|
235
|
-
// assume that a user won't construct a path like this by accident,
|
|
236
|
-
// and there's only ever one store in any given project.
|
|
237
|
-
const inStore = this.location.endsWith(`.vlt/${this.id}/node_modules/${this.name}`);
|
|
238
|
-
this.inVltStore = () => inStore;
|
|
239
|
-
return inStore;
|
|
240
|
-
}
|
|
241
|
-
#registryNodeResolved(tuple) {
|
|
242
|
-
const spec = hydrateTuple(tuple, this.#name, this.#options);
|
|
243
|
-
this.resolved =
|
|
244
|
-
this.manifest?.dist?.tarball || spec.conventionalRegistryTarball;
|
|
245
|
-
this.integrity ??= this.manifest?.dist?.integrity;
|
|
246
|
-
}
|
|
247
|
-
get options() {
|
|
248
|
-
return this.#options;
|
|
249
|
-
}
|
|
250
|
-
/* c8 ignore next */
|
|
251
|
-
set options(_opts) { }
|
|
252
|
-
equals(other) {
|
|
253
|
-
return this.id === other.id && this.location === other.location;
|
|
254
|
-
}
|
|
255
|
-
/**
|
|
256
|
-
* Sets the node as an importer along with its location.
|
|
257
|
-
*/
|
|
258
|
-
setImporterLocation(location) {
|
|
259
|
-
this.#location = location;
|
|
260
|
-
this.importer = true;
|
|
261
|
-
}
|
|
262
|
-
/**
|
|
263
|
-
* Sets the appropriate resolve / integrity value for this node.
|
|
264
|
-
* Note that other places might also set these values, like for
|
|
265
|
-
* example the lockfile that might have already have this info.
|
|
266
|
-
*/
|
|
267
|
-
setResolved() {
|
|
268
|
-
// file | remote | workspace type of ids all points to a URI that
|
|
269
|
-
// can be used as the `resolved` value, so we split the dep id
|
|
270
|
-
// for these cases.
|
|
271
|
-
const tuple = splitDepID(this.id);
|
|
272
|
-
const [type, resolved] = tuple;
|
|
273
|
-
switch (type) {
|
|
274
|
-
case 'registry':
|
|
275
|
-
this.#registryNodeResolved(tuple);
|
|
276
|
-
break;
|
|
277
|
-
default:
|
|
278
|
-
this.resolved = resolved;
|
|
279
|
-
break;
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
setDefaultLocation() {
|
|
283
|
-
const def = `./node_modules/.vlt/${this.id}/node_modules/${this.name}`;
|
|
284
|
-
// only relocate if the location is in node_modules already
|
|
285
|
-
if (!this.importer &&
|
|
286
|
-
(!this.#location ||
|
|
287
|
-
(this.#location !== def &&
|
|
288
|
-
/^(?:\.\/)?node_modules\//.test(this.#location)))) {
|
|
289
|
-
this.#location = def;
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
/**
|
|
293
|
-
* Add an edge from this node connecting it to a direct dependency.
|
|
294
|
-
*/
|
|
295
|
-
addEdgesTo(type, spec, node) {
|
|
296
|
-
const edge = new Edge(type, spec, this, node);
|
|
297
|
-
node?.edgesIn.add(edge);
|
|
298
|
-
this.edgesOut.set(spec.name, edge);
|
|
299
|
-
return edge;
|
|
300
|
-
}
|
|
301
|
-
/**
|
|
302
|
-
* The raw manifest before any modifications.
|
|
303
|
-
* If not set, falls back to the current manifest.
|
|
304
|
-
*/
|
|
305
|
-
get rawManifest() {
|
|
306
|
-
return this.#rawManifest ?? this.manifest;
|
|
307
|
-
}
|
|
308
|
-
/**
|
|
309
|
-
* Sets this node as having a manifest-confused manifest.
|
|
310
|
-
*/
|
|
311
|
-
setConfusedManifest(fixed, confused) {
|
|
312
|
-
this.manifest = fixed;
|
|
313
|
-
this.#rawManifest = confused;
|
|
314
|
-
this.confused = true;
|
|
315
|
-
this.#name = this.manifest.name;
|
|
316
|
-
}
|
|
317
|
-
/**
|
|
318
|
-
* Sets this node as having a manifest-confused manifest.
|
|
319
|
-
*/
|
|
320
|
-
maybeSetConfusedManifest(spec, confused) {
|
|
321
|
-
if (isPackageNameConfused(spec, this.manifest?.name)) {
|
|
322
|
-
this.setConfusedManifest({
|
|
323
|
-
...this.manifest,
|
|
324
|
-
name: spec.name,
|
|
325
|
-
}, confused);
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
toJSON() {
|
|
329
|
-
return {
|
|
330
|
-
id: this.id,
|
|
331
|
-
name: this.name,
|
|
332
|
-
version: this.version,
|
|
333
|
-
location: this.location,
|
|
334
|
-
importer: this.importer,
|
|
335
|
-
manifest: this.manifest &&
|
|
336
|
-
expandNormalizedManifestSymbols(this.manifest),
|
|
337
|
-
projectRoot: this.projectRoot,
|
|
338
|
-
integrity: this.integrity,
|
|
339
|
-
resolved: this.resolved,
|
|
340
|
-
dev: this.dev,
|
|
341
|
-
optional: this.optional,
|
|
342
|
-
confused: this.confused,
|
|
343
|
-
modifier: this.modifier,
|
|
344
|
-
platform: this.platform,
|
|
345
|
-
buildState: this.buildState,
|
|
346
|
-
...(this.confused ?
|
|
347
|
-
{ rawManifest: this.#rawManifest }
|
|
348
|
-
: undefined),
|
|
349
|
-
};
|
|
350
|
-
}
|
|
351
|
-
toString() {
|
|
352
|
-
return stringifyNode(this);
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
export const isNode = (value) => {
|
|
356
|
-
return (typeof value === 'object' &&
|
|
357
|
-
value != null &&
|
|
358
|
-
'id' in value &&
|
|
359
|
-
'manifest' in value &&
|
|
360
|
-
value[Symbol.toStringTag] === '@vltpkg/graph.Node');
|
|
361
|
-
};
|
|
362
|
-
export const asNode = (value) => {
|
|
363
|
-
if (!isNode(value)) {
|
|
364
|
-
throw typeError('Expected a node', { found: value });
|
|
365
|
-
}
|
|
366
|
-
return value;
|
|
367
|
-
};
|
|
368
|
-
//# sourceMappingURL=node.js.map
|
package/dist/esm/node.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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,eA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WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,QAAQ,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,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 * 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 '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.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 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"non-empty-list.d.ts","sourceRoot":"","sources":["../../src/non-empty-list.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,GAAI,CAAC,QACxB,CAAC,EAAE,KACR,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,CAAC,EAAE,CAAkB,CAAA;AAEpD,eAAO,MAAM,YAAY,GAAI,CAAC,SAAS,CAAC,EAAE,yCACC,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"non-empty-list.js","sourceRoot":"","sources":["../../src/non-empty-list.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,cAAc,GAAG,CAC5B,IAAS,EACyB,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAA;AAEpD,MAAM,CAAC,MAAM,YAAY,GAAG,CAAI,KAAU,EAAE,EAAE,CAC5C,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAA","sourcesContent":["export const isNonEmptyList = <T>(\n list: T[],\n): list is [first: T, ...rest: T[]] => !!list.length\n\nexport const nonEmptyList = <T>(nodes: T[]) =>\n isNonEmptyList(nodes) ? nodes : undefined\n"]}
|
package/dist/esm/package.json
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { RollbackRemove } from '@vltpkg/rollback-remove';
|
|
2
|
-
import type { PathScurry } from 'path-scurry';
|
|
3
|
-
import type { Edge } from '../edge.ts';
|
|
4
|
-
/**
|
|
5
|
-
* reify an edge into a node_modules folder, with bins linked
|
|
6
|
-
* this does NOT chmod the bins to 0o777, because they might not exist
|
|
7
|
-
* until scripts are run, in the case of non-store deps like workspaces
|
|
8
|
-
*/
|
|
9
|
-
export declare const addEdge: (edge: Edge, scurry: PathScurry, remover: RollbackRemove, bins?: Record<string, string>) => Promise<void>;
|
|
10
|
-
//# sourceMappingURL=add-edge.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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,65 +0,0 @@
|
|
|
1
|
-
import { cmdShimIfExists } from '@vltpkg/cmd-shim';
|
|
2
|
-
import { mkdir, symlink } from 'node:fs/promises';
|
|
3
|
-
import { dirname, relative } from 'node:path';
|
|
4
|
-
const clobberSymlink = async (target, link, remover, type = 'file') => {
|
|
5
|
-
await mkdir(dirname(link), { recursive: true });
|
|
6
|
-
try {
|
|
7
|
-
await symlink(target, link, type);
|
|
8
|
-
}
|
|
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);
|
|
20
|
-
/* c8 ignore start */
|
|
21
|
-
}
|
|
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
|
-
}
|
|
28
|
-
}
|
|
29
|
-
/* c8 ignore stop */
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
/**
|
|
33
|
-
* reify an edge into a node_modules folder, with bins linked
|
|
34
|
-
* this does NOT chmod the bins to 0o777, because they might not exist
|
|
35
|
-
* until scripts are run, in the case of non-store deps like workspaces
|
|
36
|
-
*/
|
|
37
|
-
export const addEdge = async (edge, scurry, remover, bins) => {
|
|
38
|
-
if (!edge.to)
|
|
39
|
-
return;
|
|
40
|
-
const binRoot = scurry.resolve(edge.from.nodeModules(scurry), '.bin');
|
|
41
|
-
const path = scurry.resolve(edge.from.nodeModules(scurry), edge.spec.name);
|
|
42
|
-
const promises = [];
|
|
43
|
-
const target = relative(dirname(path), edge.to.resolvedLocation(scurry));
|
|
44
|
-
// can only parallelize this on posix, because the win32 shims
|
|
45
|
-
// need to know that they will exist before being created.
|
|
46
|
-
const p = clobberSymlink(target, path, remover, 'dir');
|
|
47
|
-
if (process.platform === 'win32')
|
|
48
|
-
await p;
|
|
49
|
-
else
|
|
50
|
-
promises.push(p);
|
|
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
|
-
}
|
|
61
|
-
}
|
|
62
|
-
if (promises.length)
|
|
63
|
-
await Promise.all(promises);
|
|
64
|
-
};
|
|
65
|
-
//# sourceMappingURL=add-edge.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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;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,CAAC,CAAC,CAAA;IAErB,IAAI,IAAI,EAAE,CAAC;QACT,KAAK,MAAM,CAAC,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,5 +0,0 @@
|
|
|
1
|
-
import type { RollbackRemove } from '@vltpkg/rollback-remove';
|
|
2
|
-
import type { PathScurry } from 'path-scurry';
|
|
3
|
-
import type { Diff } from '../diff.ts';
|
|
4
|
-
export declare const addEdges: (diff: Diff, scurry: PathScurry, remover: RollbackRemove) => Promise<unknown>[];
|
|
5
|
-
//# sourceMappingURL=add-edges.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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,OAAO,CAAC,OAAO,CAAC,EAQlB,CAAA"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { addEdge } from "./add-edge.js";
|
|
2
|
-
export const addEdges = (diff, scurry, remover) => {
|
|
3
|
-
const actions = [];
|
|
4
|
-
for (const edge of diff.edges.add) {
|
|
5
|
-
const { to } = edge;
|
|
6
|
-
if (!to)
|
|
7
|
-
continue;
|
|
8
|
-
actions.push(addEdge(edge, scurry, remover, to.bins));
|
|
9
|
-
}
|
|
10
|
-
return actions;
|
|
11
|
-
};
|
|
12
|
-
//# sourceMappingURL=add-edges.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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,EACH,EAAE;IACtB,MAAM,OAAO,GAAuB,EAAE,CAAA;IACtC,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,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,CAAA;IACvD,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 actions.push(addEdge(edge, scurry, remover, to.bins))\n }\n return actions\n}\n"]}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { PackageInfoClient } from '@vltpkg/package-info';
|
|
2
|
-
import type { RollbackRemove } from '@vltpkg/rollback-remove';
|
|
3
|
-
import type { SpecOptions } from '@vltpkg/spec';
|
|
4
|
-
import type { PathScurry } from 'path-scurry';
|
|
5
|
-
import type { Diff } from '../diff.ts';
|
|
6
|
-
export declare const addNodes: (diff: Diff, scurry: PathScurry, remover: RollbackRemove, options: SpecOptions, packageInfo: PackageInfoClient) => (() => Promise<unknown>)[];
|
|
7
|
-
//# sourceMappingURL=add-nodes.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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,17 +0,0 @@
|
|
|
1
|
-
import { extractNode } from "./extract-node.js";
|
|
2
|
-
export const addNodes = (diff, scurry, remover, options, packageInfo) => {
|
|
3
|
-
const actions = [];
|
|
4
|
-
// fetch and extract all the nodes, removing any in the way
|
|
5
|
-
for (const node of diff.nodes.add) {
|
|
6
|
-
// if it's not in the store, we don't have to extract it, because
|
|
7
|
-
// we're just linking to a location that already exists.
|
|
8
|
-
if (!node.inVltStore())
|
|
9
|
-
continue;
|
|
10
|
-
// skip nodes that have already been extracted
|
|
11
|
-
if (node.extracted)
|
|
12
|
-
continue;
|
|
13
|
-
actions.push(() => extractNode(node, scurry, remover, options, packageInfo, diff));
|
|
14
|
-
}
|
|
15
|
-
return actions;
|
|
16
|
-
};
|
|
17
|
-
//# sourceMappingURL=add-nodes.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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"]}
|
|
@@ -1,11 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,39 +0,0 @@
|
|
|
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
|