vlt 0.0.0-3 → 0.0.0-5
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 +2 -1
- package/package.json +17 -10
- package/postinstall.cjs +56 -0
- package/vlix +25 -0
- package/vlr +25 -0
- package/vlrx +25 -0
- package/vlt +25 -0
- package/vlx +25 -0
- package/cache-unzip-src-unzip.js +0 -7896
- package/cache-unzip-src-unzip.js.map +0 -7
- package/chunk-227OF2U2.js +0 -1183
- package/chunk-227OF2U2.js.map +0 -7
- package/chunk-3HXIYJS2.js +0 -54
- package/chunk-3HXIYJS2.js.map +0 -7
- package/chunk-AA6MVXJX.js +0 -19823
- package/chunk-AA6MVXJX.js.map +0 -7
- package/chunk-BCK4ZGNG.js +0 -41
- package/chunk-BCK4ZGNG.js.map +0 -7
- package/chunk-DH36SF3E.js +0 -35
- package/chunk-DH36SF3E.js.map +0 -7
- package/chunk-FNKWJ7AZ.js +0 -1379
- package/chunk-FNKWJ7AZ.js.map +0 -7
- package/chunk-H77UDCL3.js +0 -9820
- package/chunk-H77UDCL3.js.map +0 -7
- package/chunk-HL76E44L.js +0 -73
- package/chunk-HL76E44L.js.map +0 -7
- package/chunk-IN7DEH7F.js +0 -44
- package/chunk-IN7DEH7F.js.map +0 -7
- package/chunk-JLP2QDXQ.js +0 -1137
- package/chunk-JLP2QDXQ.js.map +0 -7
- package/chunk-JMGSFQ32.js +0 -969
- package/chunk-JMGSFQ32.js.map +0 -7
- package/chunk-JQRUGUZ3.js +0 -512
- package/chunk-JQRUGUZ3.js.map +0 -7
- package/chunk-K2BYYPM7.js +0 -8656
- package/chunk-K2BYYPM7.js.map +0 -7
- package/chunk-LNUDEBGP.js +0 -2071
- package/chunk-LNUDEBGP.js.map +0 -7
- package/chunk-MV5ZQ3LW.js +0 -1105
- package/chunk-MV5ZQ3LW.js.map +0 -7
- package/chunk-O7CDQZDW.js +0 -5234
- package/chunk-O7CDQZDW.js.map +0 -7
- package/chunk-OFW7MWFP.js +0 -82
- package/chunk-OFW7MWFP.js.map +0 -7
- package/chunk-PGDJ2ZZ6.js +0 -4810
- package/chunk-PGDJ2ZZ6.js.map +0 -7
- package/chunk-POVPHE2F.js +0 -1864
- package/chunk-POVPHE2F.js.map +0 -7
- package/chunk-PTVPYZHU.js +0 -72
- package/chunk-PTVPYZHU.js.map +0 -7
- package/chunk-SXBMMXTY.js +0 -11837
- package/chunk-SXBMMXTY.js.map +0 -7
- package/chunk-UZZ72UON.js +0 -152
- package/chunk-UZZ72UON.js.map +0 -7
- package/chunk-V7KRP7IO.js +0 -481
- package/chunk-V7KRP7IO.js.map +0 -7
- package/chunk-WVNUD273.js +0 -83
- package/chunk-WVNUD273.js.map +0 -7
- package/chunk-WYPE3MV4.js +0 -62
- package/chunk-WYPE3MV4.js.map +0 -7
- package/chunk-ZRNJWPYC.js +0 -37
- package/chunk-ZRNJWPYC.js.map +0 -7
- package/cli-package.json +0 -107
- package/config-3QQHUYLI.js +0 -179
- package/config-3QQHUYLI.js.map +0 -7
- package/devtools-5BBQJTDW.js +0 -16682
- package/devtools-5BBQJTDW.js.map +0 -7
- package/exec-C6GK336U.js +0 -50
- package/exec-C6GK336U.js.map +0 -7
- package/gui-IQ4M4K5X.js +0 -46
- package/gui-IQ4M4K5X.js.map +0 -7
- package/gui-assets/favicon.ico +0 -0
- package/gui-assets/fonts/geist-mono.ttf +0 -0
- package/gui-assets/fonts/inter.ttf +0 -0
- package/gui-assets/images/folder.png +0 -0
- package/gui-assets/index.html +0 -34
- package/gui-assets/index.js +0 -1549
- package/gui-assets/index.js.map +0 -7
- package/gui-assets/main.css +0 -1
- package/help-R6TSKVEA.js +0 -25
- package/help-R6TSKVEA.js.map +0 -7
- package/init-UTJGYULC.js +0 -25
- package/init-UTJGYULC.js.map +0 -7
- package/install-5XDTGLAU.js +0 -56
- package/install-5XDTGLAU.js.map +0 -7
- package/install-exec-VMPN3JE7.js +0 -28
- package/install-exec-VMPN3JE7.js.map +0 -7
- package/list-Q7IANZ3I.js +0 -129
- package/list-Q7IANZ3I.js.map +0 -7
- package/login-VHJEIRVU.js +0 -36
- package/login-VHJEIRVU.js.map +0 -7
- package/logout-5KMCSSR4.js +0 -36
- package/logout-5KMCSSR4.js.map +0 -7
- package/pkg-WYFDWETL.js +0 -364
- package/pkg-WYFDWETL.js.map +0 -7
- package/query-KP4F5D2Y.js +0 -117
- package/query-KP4F5D2Y.js.map +0 -7
- package/registry-client-package.json +0 -85
- package/reporter-LFGXWL6N.js +0 -18
- package/reporter-LFGXWL6N.js.map +0 -7
- package/rollback-remove-src-remove.js +0 -7398
- package/rollback-remove-src-remove.js.map +0 -7
- package/run-XNDZH72D.js +0 -68
- package/run-XNDZH72D.js.map +0 -7
- package/run-exec-NXA33NXJ.js +0 -41
- package/run-exec-NXA33NXJ.js.map +0 -7
- package/source-JWPG6PR3.js +0 -33
- package/source-JWPG6PR3.js.map +0 -7
- package/token-6IJNGEMI.js +0 -86
- package/token-6IJNGEMI.js.map +0 -7
- package/uninstall-MI7NFD27.js +0 -45
- package/uninstall-MI7NFD27.js.map +0 -7
- package/vlix.js +0 -25
- package/vlix.js.map +0 -7
- package/vlr.js +0 -25
- package/vlr.js.map +0 -7
- package/vlrx.js +0 -25
- package/vlrx.js.map +0 -7
- package/vlt.js +0 -24
- package/vlt.js.map +0 -7
- package/vlx.js +0 -25
- package/vlx.js.map +0 -7
- package/whoami-3IEXJF3U.js +0 -46
- package/whoami-3IEXJF3U.js.map +0 -7
- package/yoga.wasm +0 -0
package/chunk-JMGSFQ32.js
DELETED
|
@@ -1,969 +0,0 @@
|
|
|
1
|
-
var global = globalThis;
|
|
2
|
-
import {Buffer} from "node:buffer";
|
|
3
|
-
import {setImmediate, clearImmediate} from "node:timers";
|
|
4
|
-
import {createRequire as _vlt_createRequire} from 'node:module';
|
|
5
|
-
var require = _vlt_createRequire(import.meta.filename);
|
|
6
|
-
import {
|
|
7
|
-
PathScurry,
|
|
8
|
-
globSync,
|
|
9
|
-
minimatch
|
|
10
|
-
} from "./chunk-O7CDQZDW.js";
|
|
11
|
-
import {
|
|
12
|
-
PackageJson,
|
|
13
|
-
Spec2 as Spec,
|
|
14
|
-
parse
|
|
15
|
-
} from "./chunk-POVPHE2F.js";
|
|
16
|
-
import {
|
|
17
|
-
error
|
|
18
|
-
} from "./chunk-ZRNJWPYC.js";
|
|
19
|
-
|
|
20
|
-
// ../../src/dep-id/src/index.ts
|
|
21
|
-
var delimiter = "\xB7";
|
|
22
|
-
var depIDRegExp = new RegExp(
|
|
23
|
-
`^((git)?${delimiter}[^${delimiter}]*${delimiter}[^${delimiter}]*(${delimiter}[^${delimiter}]*)?$|^(file|remote|workspace)${delimiter}[^${delimiter}]*)(${delimiter}[^${delimiter}]*)?$`
|
|
24
|
-
);
|
|
25
|
-
var isDepID = (str) => typeof str === "string" && depIDRegExp.test(str);
|
|
26
|
-
var asDepID = (str) => {
|
|
27
|
-
if (!isDepID(str)) {
|
|
28
|
-
throw error("Expected dep id", {
|
|
29
|
-
found: str
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
return str;
|
|
33
|
-
};
|
|
34
|
-
var joinDepIDTuple = (list) => {
|
|
35
|
-
const [type, first, second, extra] = list;
|
|
36
|
-
const f = encode(first);
|
|
37
|
-
switch (type) {
|
|
38
|
-
case "registry":
|
|
39
|
-
return `${delimiter}${f}${delimiter}${encode(second)}${extra ? `${delimiter}${encode(extra)}` : ""}`;
|
|
40
|
-
case "git":
|
|
41
|
-
return `${type}${delimiter}${f}${delimiter}${encode(second)}${extra ? `${delimiter}${encode(extra)}` : ""}`;
|
|
42
|
-
default:
|
|
43
|
-
return `${type}${delimiter}${f}${second ? `${delimiter}${encode(second)}` : ""}`;
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
var encode = (s) => encodeURIComponent(s).replaceAll("%40", "@").replaceAll("%2f", "\xA7").replaceAll("%2F", "\xA7");
|
|
47
|
-
var splitDepID = (id) => {
|
|
48
|
-
const [type, first = "", second, extra] = id.replaceAll("\xA7", "/").split(delimiter, 4);
|
|
49
|
-
const f = decodeURIComponent(first);
|
|
50
|
-
switch (type) {
|
|
51
|
-
case "git":
|
|
52
|
-
case "": {
|
|
53
|
-
if (second === void 0) {
|
|
54
|
-
throw error(`invalid ${type} id`, { found: id });
|
|
55
|
-
}
|
|
56
|
-
const t = [
|
|
57
|
-
type || "registry",
|
|
58
|
-
f,
|
|
59
|
-
decodeURIComponent(second)
|
|
60
|
-
];
|
|
61
|
-
if (extra) t.push(decodeURIComponent(extra));
|
|
62
|
-
return t;
|
|
63
|
-
}
|
|
64
|
-
case "file":
|
|
65
|
-
case "remote":
|
|
66
|
-
case "workspace": {
|
|
67
|
-
const t = [type, f];
|
|
68
|
-
if (second) t.push(decodeURIComponent(second));
|
|
69
|
-
return t;
|
|
70
|
-
}
|
|
71
|
-
default: {
|
|
72
|
-
throw error("invalid DepID type", {
|
|
73
|
-
found: type,
|
|
74
|
-
validOptions: ["git", "file", "workspace", "remote", ""]
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
var hydrate = (id, name, options = {}) => hydrateTuple(splitDepID(id), name, options);
|
|
80
|
-
var hydrateTuple = (tuple, name, options = {}) => {
|
|
81
|
-
const [type, first, second] = tuple;
|
|
82
|
-
switch (type) {
|
|
83
|
-
case "remote": {
|
|
84
|
-
if (!first)
|
|
85
|
-
throw error("no remoteURL found on remote id", {
|
|
86
|
-
found: tuple
|
|
87
|
-
});
|
|
88
|
-
return Spec.parse(name ?? "(unknown)", first);
|
|
89
|
-
}
|
|
90
|
-
case "file": {
|
|
91
|
-
if (!first) {
|
|
92
|
-
throw error("no file path found on remote id", {
|
|
93
|
-
found: tuple
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
return Spec.parse(name ?? "(unknown)", `file:${first}`, options);
|
|
97
|
-
}
|
|
98
|
-
case "registry": {
|
|
99
|
-
if (typeof first !== "string") {
|
|
100
|
-
throw error("no registry url or name in registry ID", {
|
|
101
|
-
found: tuple
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
if (!second) {
|
|
105
|
-
throw error("no name/specifier in registry ID", {
|
|
106
|
-
found: tuple
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
if (!first) {
|
|
110
|
-
const s2 = Spec.parse(second);
|
|
111
|
-
if (name && s2.name !== name) {
|
|
112
|
-
return Spec.parse(`${name}@npm:${second}`);
|
|
113
|
-
} else {
|
|
114
|
-
return s2;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
if (!/^https?:\/\//.test(first)) {
|
|
118
|
-
const reg = options.registries?.[first];
|
|
119
|
-
if (first !== "npm" && !reg) {
|
|
120
|
-
throw error("named registry not found in options", {
|
|
121
|
-
name: first,
|
|
122
|
-
found: tuple
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
return Spec.parse(
|
|
126
|
-
name ?? "(unknown)",
|
|
127
|
-
`${first}:${second}`,
|
|
128
|
-
options
|
|
129
|
-
);
|
|
130
|
-
}
|
|
131
|
-
const s = Spec.parse(
|
|
132
|
-
name ?? "(unknown)",
|
|
133
|
-
`registry:${first}#${second}`,
|
|
134
|
-
options
|
|
135
|
-
);
|
|
136
|
-
return name && s.final.name !== name ? Spec.parse(s.final.name + "@" + s.bareSpec) : s;
|
|
137
|
-
}
|
|
138
|
-
case "git": {
|
|
139
|
-
if (!first) {
|
|
140
|
-
throw error("no git remote in git ID", {
|
|
141
|
-
found: tuple
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
return Spec.parse(
|
|
145
|
-
name ?? "(unknown)",
|
|
146
|
-
first + "#" + second,
|
|
147
|
-
options
|
|
148
|
-
);
|
|
149
|
-
}
|
|
150
|
-
case "workspace": {
|
|
151
|
-
if (!first) {
|
|
152
|
-
throw error("no name/path on workspace id", { found: tuple });
|
|
153
|
-
}
|
|
154
|
-
return name && name !== first ? Spec.parse(name, `workspace:${first}@*`, options) : Spec.parse(first, `workspace:*`, options);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
};
|
|
158
|
-
var omitDefReg = (s) => !s || s === "https://registry.npmjs.org" || s === "https://registry.npmjs.org/" ? "" : s;
|
|
159
|
-
var getTuple = (spec, mani) => {
|
|
160
|
-
const f = spec.final;
|
|
161
|
-
switch (f.type) {
|
|
162
|
-
case "registry": {
|
|
163
|
-
const reg = omitDefReg(f.registry);
|
|
164
|
-
if (!f.namedRegistry && reg) {
|
|
165
|
-
for (const [alias, host] of Object.entries(
|
|
166
|
-
spec.options.registries
|
|
167
|
-
)) {
|
|
168
|
-
if (reg === host) {
|
|
169
|
-
f.namedRegistry = alias;
|
|
170
|
-
break;
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
return [
|
|
175
|
-
f.type,
|
|
176
|
-
f.namedRegistry ?? reg,
|
|
177
|
-
`${mani.name ?? spec.name}@${mani.version ?? spec.bareSpec}`
|
|
178
|
-
];
|
|
179
|
-
}
|
|
180
|
-
case "git": {
|
|
181
|
-
const {
|
|
182
|
-
namedGitHost,
|
|
183
|
-
namedGitHostPath,
|
|
184
|
-
gitRemote,
|
|
185
|
-
gitSelector = ""
|
|
186
|
-
} = f;
|
|
187
|
-
if (!gitRemote)
|
|
188
|
-
throw error("no host on git specifier", { spec });
|
|
189
|
-
if (namedGitHost) {
|
|
190
|
-
if (!namedGitHostPath) {
|
|
191
|
-
throw error("named git host without path portion", {
|
|
192
|
-
spec
|
|
193
|
-
});
|
|
194
|
-
}
|
|
195
|
-
return [
|
|
196
|
-
f.type,
|
|
197
|
-
`${namedGitHost}:${namedGitHostPath}`,
|
|
198
|
-
gitSelector
|
|
199
|
-
];
|
|
200
|
-
} else {
|
|
201
|
-
return [f.type, gitRemote, gitSelector];
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
case "remote": {
|
|
205
|
-
const { remoteURL } = f;
|
|
206
|
-
if (!remoteURL)
|
|
207
|
-
throw error("no URL on remote specifier", { spec });
|
|
208
|
-
return [f.type, remoteURL];
|
|
209
|
-
}
|
|
210
|
-
case "file":
|
|
211
|
-
case "workspace":
|
|
212
|
-
throw error("Path-based dep ids are not supported", { spec });
|
|
213
|
-
}
|
|
214
|
-
};
|
|
215
|
-
var getId = (spec, mani) => joinDepIDTuple(getTuple(spec, mani));
|
|
216
|
-
|
|
217
|
-
// ../../src/workspaces/src/index.ts
|
|
218
|
-
import { readFileSync, statSync } from "node:fs";
|
|
219
|
-
|
|
220
|
-
// ../../node_modules/.pnpm/graph-run@1.0.4/node_modules/graph-run/dist/esm/index.js
|
|
221
|
-
import { setMaxListeners } from "node:events";
|
|
222
|
-
var RunnerBase = class {
|
|
223
|
-
results = /* @__PURE__ */ new Map();
|
|
224
|
-
settled = /* @__PURE__ */ new Map();
|
|
225
|
-
dependents = /* @__PURE__ */ new Map();
|
|
226
|
-
directDependents = /* @__PURE__ */ new Map();
|
|
227
|
-
options;
|
|
228
|
-
abortController;
|
|
229
|
-
failFast;
|
|
230
|
-
errors = [];
|
|
231
|
-
from;
|
|
232
|
-
constructor(options, from) {
|
|
233
|
-
const ac = new AbortController();
|
|
234
|
-
this.from = from ?? this.constructor;
|
|
235
|
-
this.abortController = ac;
|
|
236
|
-
setMaxListeners(Infinity, ac.signal);
|
|
237
|
-
this.options = options;
|
|
238
|
-
if (!options.graph.length) {
|
|
239
|
-
const er = new Error("no nodes provided to graph traversal", {
|
|
240
|
-
cause: {
|
|
241
|
-
found: options.graph,
|
|
242
|
-
wanted: "[first: Node, ...rest: Node[]]"
|
|
243
|
-
}
|
|
244
|
-
});
|
|
245
|
-
Error.captureStackTrace(er, from);
|
|
246
|
-
throw er;
|
|
247
|
-
}
|
|
248
|
-
this.failFast = options.failFast !== false;
|
|
249
|
-
const { signal } = options;
|
|
250
|
-
if (signal !== void 0) {
|
|
251
|
-
signal.addEventListener("abort", (reason) => ac.abort(reason), {
|
|
252
|
-
once: true,
|
|
253
|
-
signal: ac.signal
|
|
254
|
-
});
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
route(n, d) {
|
|
258
|
-
const dependents = this.dependents.get(d);
|
|
259
|
-
if (!dependents?.has(n))
|
|
260
|
-
return void 0;
|
|
261
|
-
const directDependents = this.directDependents.get(d);
|
|
262
|
-
if (!directDependents)
|
|
263
|
-
return void 0;
|
|
264
|
-
if (directDependents.has(n)) {
|
|
265
|
-
return [n, d];
|
|
266
|
-
}
|
|
267
|
-
const queue = [
|
|
268
|
-
...directDependents
|
|
269
|
-
].map((dd) => [dd, d]);
|
|
270
|
-
let step = void 0;
|
|
271
|
-
while (void 0 !== (step = queue.shift())) {
|
|
272
|
-
if (!dependents.has(step[0]))
|
|
273
|
-
continue;
|
|
274
|
-
if (step[0] === n) {
|
|
275
|
-
return step;
|
|
276
|
-
}
|
|
277
|
-
const ddd = this.directDependents.get(step[0]);
|
|
278
|
-
if (ddd) {
|
|
279
|
-
for (const d2 of ddd) {
|
|
280
|
-
queue.push([d2, ...step]);
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
cycleCheck(n, path, d) {
|
|
286
|
-
const dependents = this.dependents.get(n) ?? /* @__PURE__ */ new Set();
|
|
287
|
-
this.dependents.set(n, dependents);
|
|
288
|
-
const isCycle = dependents.has(d);
|
|
289
|
-
if (isCycle) {
|
|
290
|
-
const cycle = this.route(d, n);
|
|
291
|
-
if (!cycle) {
|
|
292
|
-
throw new Error("cycle detected, but cycle route not found");
|
|
293
|
-
}
|
|
294
|
-
cycle.unshift(n);
|
|
295
|
-
this.onCycle(d, cycle, path);
|
|
296
|
-
return true;
|
|
297
|
-
}
|
|
298
|
-
const depDD = this.directDependents.get(d) ?? /* @__PURE__ */ new Set();
|
|
299
|
-
this.directDependents.set(d, depDD);
|
|
300
|
-
depDD.add(n);
|
|
301
|
-
const depDependents = this.dependents.get(d) ?? /* @__PURE__ */ new Set();
|
|
302
|
-
this.dependents.set(d, depDependents);
|
|
303
|
-
for (const n2 of dependents) {
|
|
304
|
-
depDependents.add(n2);
|
|
305
|
-
}
|
|
306
|
-
depDependents.add(n);
|
|
307
|
-
return false;
|
|
308
|
-
}
|
|
309
|
-
handleError(er, n, path) {
|
|
310
|
-
this.errors.push(er);
|
|
311
|
-
this.settled.set(n, {
|
|
312
|
-
status: "rejected",
|
|
313
|
-
reason: er
|
|
314
|
-
});
|
|
315
|
-
if (this.failFast) {
|
|
316
|
-
this.abortController.abort(er);
|
|
317
|
-
const e = new Error("failed graph traversal", {
|
|
318
|
-
cause: {
|
|
319
|
-
node: n,
|
|
320
|
-
path,
|
|
321
|
-
cause: er
|
|
322
|
-
}
|
|
323
|
-
});
|
|
324
|
-
Error.captureStackTrace(e, this.from);
|
|
325
|
-
throw e;
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
handleValue(value, n) {
|
|
329
|
-
this.results.set(n, value);
|
|
330
|
-
this.settled.set(n, {
|
|
331
|
-
status: "fulfilled",
|
|
332
|
-
value
|
|
333
|
-
});
|
|
334
|
-
}
|
|
335
|
-
};
|
|
336
|
-
var Runner = class extends RunnerBase {
|
|
337
|
-
running = /* @__PURE__ */ new Map();
|
|
338
|
-
async getDeps(n) {
|
|
339
|
-
if (this.abortController.signal.aborted)
|
|
340
|
-
return [];
|
|
341
|
-
const deps = await this.options.getDeps(n);
|
|
342
|
-
for (const d of deps) {
|
|
343
|
-
const dependents = this.dependents.get(d) ?? /* @__PURE__ */ new Set();
|
|
344
|
-
this.dependents.set(d, dependents);
|
|
345
|
-
dependents.add(n);
|
|
346
|
-
const depDD = this.directDependents.get(d) ?? /* @__PURE__ */ new Set();
|
|
347
|
-
this.directDependents.set(d, depDD);
|
|
348
|
-
depDD.add(n);
|
|
349
|
-
}
|
|
350
|
-
return deps;
|
|
351
|
-
}
|
|
352
|
-
async visit(n, path, depResults) {
|
|
353
|
-
const { signal } = this.abortController;
|
|
354
|
-
return this.options.visit(n, signal, path, depResults);
|
|
355
|
-
}
|
|
356
|
-
async onCycle(n, cycle, path) {
|
|
357
|
-
if (this.abortController.signal.aborted)
|
|
358
|
-
return;
|
|
359
|
-
await this.options.onCycle?.(n, cycle, path);
|
|
360
|
-
}
|
|
361
|
-
async #walk(n, path) {
|
|
362
|
-
const r = this.running.get(n);
|
|
363
|
-
if (r)
|
|
364
|
-
return r;
|
|
365
|
-
if (this.settled.get(n))
|
|
366
|
-
return;
|
|
367
|
-
const p = this.#step(n, path).then(() => {
|
|
368
|
-
this.running.delete(n);
|
|
369
|
-
}, (er) => {
|
|
370
|
-
this.running.delete(n);
|
|
371
|
-
throw er;
|
|
372
|
-
});
|
|
373
|
-
this.running.set(n, p);
|
|
374
|
-
return p;
|
|
375
|
-
}
|
|
376
|
-
async #step(n, path) {
|
|
377
|
-
const dependents = this.dependents.get(n) ?? /* @__PURE__ */ new Set();
|
|
378
|
-
this.dependents.set(n, dependents);
|
|
379
|
-
const deps = await this.getDeps(n);
|
|
380
|
-
const awaiting = [];
|
|
381
|
-
const depPath = [...path, n];
|
|
382
|
-
for (const d of deps) {
|
|
383
|
-
if (this.abortController.signal.aborted)
|
|
384
|
-
return;
|
|
385
|
-
if (d === n)
|
|
386
|
-
continue;
|
|
387
|
-
if (this.cycleCheck(n, depPath, d))
|
|
388
|
-
continue;
|
|
389
|
-
if (this.settled.get(d))
|
|
390
|
-
continue;
|
|
391
|
-
awaiting.push(this.running.get(d) ?? this.#walk(d, depPath));
|
|
392
|
-
}
|
|
393
|
-
if (this.abortController.signal.aborted)
|
|
394
|
-
return;
|
|
395
|
-
await Promise.all(awaiting);
|
|
396
|
-
if (this.abortController.signal.aborted)
|
|
397
|
-
return;
|
|
398
|
-
const depRes = new Map(deps.map((d) => [d, this.results.get(d)]));
|
|
399
|
-
try {
|
|
400
|
-
this.handleValue(await this.visit(n, path, depRes), n);
|
|
401
|
-
} catch (er) {
|
|
402
|
-
this.handleError(er, n, path);
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
async run() {
|
|
406
|
-
const promises = [];
|
|
407
|
-
for (const n of this.options.graph) {
|
|
408
|
-
promises.push(this.#walk(n, []));
|
|
409
|
-
}
|
|
410
|
-
await Promise.all(promises);
|
|
411
|
-
}
|
|
412
|
-
};
|
|
413
|
-
var RunnerSync = class extends RunnerBase {
|
|
414
|
-
getDeps(n) {
|
|
415
|
-
if (this.abortController.signal.aborted)
|
|
416
|
-
return [];
|
|
417
|
-
return this.options.getDeps(n);
|
|
418
|
-
}
|
|
419
|
-
visit(n, path, depResults) {
|
|
420
|
-
const { signal } = this.abortController;
|
|
421
|
-
return this.options.visit(n, signal, path, depResults);
|
|
422
|
-
}
|
|
423
|
-
onCycle(n, cycle, path) {
|
|
424
|
-
if (this.abortController.signal.aborted)
|
|
425
|
-
return;
|
|
426
|
-
this.options.onCycle?.(n, cycle, path);
|
|
427
|
-
}
|
|
428
|
-
#walk(n, path) {
|
|
429
|
-
if (this.settled.get(n))
|
|
430
|
-
return;
|
|
431
|
-
this.#step(n, path);
|
|
432
|
-
}
|
|
433
|
-
#step(n, path) {
|
|
434
|
-
const dependents = this.dependents.get(n) ?? /* @__PURE__ */ new Set();
|
|
435
|
-
this.dependents.set(n, dependents);
|
|
436
|
-
const deps = this.getDeps(n);
|
|
437
|
-
const depPath = [...path, n];
|
|
438
|
-
for (const d of deps) {
|
|
439
|
-
if (this.abortController.signal.aborted)
|
|
440
|
-
return;
|
|
441
|
-
if (d === n)
|
|
442
|
-
continue;
|
|
443
|
-
if (this.cycleCheck(n, depPath, d))
|
|
444
|
-
continue;
|
|
445
|
-
if (!this.settled.get(d))
|
|
446
|
-
this.#walk(d, depPath);
|
|
447
|
-
}
|
|
448
|
-
if (this.abortController.signal.aborted)
|
|
449
|
-
return;
|
|
450
|
-
const depRes = new Map(deps.map((d) => [d, this.results.get(d)]));
|
|
451
|
-
try {
|
|
452
|
-
this.handleValue(this.visit(n, path, depRes), n);
|
|
453
|
-
} catch (er) {
|
|
454
|
-
this.handleError(er, n, path);
|
|
455
|
-
}
|
|
456
|
-
}
|
|
457
|
-
run() {
|
|
458
|
-
for (const n of this.options.graph) {
|
|
459
|
-
this.#walk(n, []);
|
|
460
|
-
}
|
|
461
|
-
return this.results;
|
|
462
|
-
}
|
|
463
|
-
};
|
|
464
|
-
var graphRun = async (options) => {
|
|
465
|
-
const runner = new Runner(options, graphRun);
|
|
466
|
-
await runner.run();
|
|
467
|
-
if (runner.errors.length) {
|
|
468
|
-
const e = new AggregateError(runner.errors, "failed graph traversal");
|
|
469
|
-
Error.captureStackTrace(e, graphRun);
|
|
470
|
-
throw e;
|
|
471
|
-
}
|
|
472
|
-
return runner.results;
|
|
473
|
-
};
|
|
474
|
-
var graphRunSync = (options) => {
|
|
475
|
-
const runner = new RunnerSync(options, graphRunSync);
|
|
476
|
-
runner.run();
|
|
477
|
-
if (runner.errors.length) {
|
|
478
|
-
const e = new AggregateError(runner.errors, "failed graph traversal");
|
|
479
|
-
Error.captureStackTrace(e, graphRunSync);
|
|
480
|
-
throw e;
|
|
481
|
-
}
|
|
482
|
-
return runner.results;
|
|
483
|
-
};
|
|
484
|
-
|
|
485
|
-
// ../../src/workspaces/src/index.ts
|
|
486
|
-
import { basename, resolve, posix } from "node:path";
|
|
487
|
-
var asWSConfig = (conf, path) => {
|
|
488
|
-
assertWSConfig(conf, path);
|
|
489
|
-
return typeof conf === "string" ? { packages: [conf] } : Array.isArray(conf) ? { packages: conf } : conf;
|
|
490
|
-
};
|
|
491
|
-
var assertWSConfig = (conf, path) => {
|
|
492
|
-
if (typeof conf === "string") return conf;
|
|
493
|
-
if (Array.isArray(conf)) {
|
|
494
|
-
for (const c of conf) {
|
|
495
|
-
if (typeof c !== "string") {
|
|
496
|
-
throw error("Invalid workspace definition", {
|
|
497
|
-
path,
|
|
498
|
-
found: c,
|
|
499
|
-
wanted: "string"
|
|
500
|
-
});
|
|
501
|
-
}
|
|
502
|
-
}
|
|
503
|
-
return;
|
|
504
|
-
}
|
|
505
|
-
if (conf && typeof conf === "object") {
|
|
506
|
-
for (const [group, value] of Object.entries(conf)) {
|
|
507
|
-
if (typeof value === "string") continue;
|
|
508
|
-
if (Array.isArray(value)) {
|
|
509
|
-
for (const c of value) {
|
|
510
|
-
if (typeof c !== "string") {
|
|
511
|
-
throw error("Invalid workspace definition", {
|
|
512
|
-
path,
|
|
513
|
-
name: group,
|
|
514
|
-
found: c,
|
|
515
|
-
wanted: "string"
|
|
516
|
-
});
|
|
517
|
-
}
|
|
518
|
-
}
|
|
519
|
-
continue;
|
|
520
|
-
}
|
|
521
|
-
throw error("Invalid workspace definition", {
|
|
522
|
-
path,
|
|
523
|
-
name: group,
|
|
524
|
-
found: value,
|
|
525
|
-
wanted: "string | string[]"
|
|
526
|
-
});
|
|
527
|
-
}
|
|
528
|
-
return;
|
|
529
|
-
}
|
|
530
|
-
throw error("Invalid workspace definition", {
|
|
531
|
-
path,
|
|
532
|
-
found: conf,
|
|
533
|
-
wanted: "string | string[] | { [group: string]: string | string[] }"
|
|
534
|
-
});
|
|
535
|
-
};
|
|
536
|
-
var Monorepo = class _Monorepo {
|
|
537
|
-
/** The project root where vlt-workspaces.json is found */
|
|
538
|
-
projectRoot;
|
|
539
|
-
/** Scurry object to cache all filesystem calls (mostly globs) */
|
|
540
|
-
scurry;
|
|
541
|
-
// maps both name and path to the workspace objects
|
|
542
|
-
#workspaces = /* @__PURE__ */ new Map();
|
|
543
|
-
#groups = /* @__PURE__ */ new Map();
|
|
544
|
-
#config;
|
|
545
|
-
packageJson;
|
|
546
|
-
/**
|
|
547
|
-
* Number of {@link Workspace} objects loaded in this Monorepo
|
|
548
|
-
*/
|
|
549
|
-
get size() {
|
|
550
|
-
return [...this.values()].length;
|
|
551
|
-
}
|
|
552
|
-
constructor(projectRoot, options = {}) {
|
|
553
|
-
this.projectRoot = resolve(projectRoot);
|
|
554
|
-
this.scurry = options.scurry ?? new PathScurry(projectRoot);
|
|
555
|
-
this.packageJson = options.packageJson ?? new PackageJson();
|
|
556
|
-
this.#config = options.config;
|
|
557
|
-
if (options.load) this.load(options.load);
|
|
558
|
-
}
|
|
559
|
-
/**
|
|
560
|
-
* Load the workspace definitions from vlt-workspaces.json,
|
|
561
|
-
* canonicalizing the result into the effective `{[group:string]:string[]}`
|
|
562
|
-
* form.
|
|
563
|
-
*
|
|
564
|
-
* Eg:
|
|
565
|
-
* - `"src/*"` => `{packages:["src/*"]}`
|
|
566
|
-
* - `{"apps": "src/*"}` => `{apps: ["src/*"]}`
|
|
567
|
-
*/
|
|
568
|
-
get config() {
|
|
569
|
-
if (this.#config) return this.#config;
|
|
570
|
-
const file = resolve(this.projectRoot, "vlt-workspaces.json");
|
|
571
|
-
let confData;
|
|
572
|
-
try {
|
|
573
|
-
confData = readFileSync(file, "utf8");
|
|
574
|
-
} catch (er) {
|
|
575
|
-
throw error("Not in a monorepo, no vlt-workspaces.json found", {
|
|
576
|
-
path: this.projectRoot,
|
|
577
|
-
cause: er
|
|
578
|
-
});
|
|
579
|
-
}
|
|
580
|
-
let parsed;
|
|
581
|
-
try {
|
|
582
|
-
parsed = parse(confData);
|
|
583
|
-
} catch (er) {
|
|
584
|
-
throw error("Invalid vlt-workspaces.json file", {
|
|
585
|
-
path: this.projectRoot,
|
|
586
|
-
cause: er
|
|
587
|
-
});
|
|
588
|
-
}
|
|
589
|
-
this.#config = asWSConfig(parsed, file);
|
|
590
|
-
return this.#config;
|
|
591
|
-
}
|
|
592
|
-
/**
|
|
593
|
-
* Iterating the Monorepo object yields the workspace objects, in as close to
|
|
594
|
-
* topological dependency order as possible.
|
|
595
|
-
*/
|
|
596
|
-
*[Symbol.iterator]() {
|
|
597
|
-
const [ws] = [...this.values()];
|
|
598
|
-
if (!ws) return;
|
|
599
|
-
for (const workspace of this.runSync(() => {
|
|
600
|
-
}).keys()) {
|
|
601
|
-
yield workspace;
|
|
602
|
-
}
|
|
603
|
-
}
|
|
604
|
-
/**
|
|
605
|
-
* Iterating the Monorepo object yields the workspace objects, in as close to
|
|
606
|
-
* topological dependency order as possible.
|
|
607
|
-
*/
|
|
608
|
-
async *[Symbol.asyncIterator]() {
|
|
609
|
-
const [ws] = [...this.values()];
|
|
610
|
-
if (!ws) return;
|
|
611
|
-
for (const workspace of (await this.run(() => {
|
|
612
|
-
})).keys()) {
|
|
613
|
-
yield workspace;
|
|
614
|
-
}
|
|
615
|
-
}
|
|
616
|
-
/**
|
|
617
|
-
* By default, loads all workspaces reachable in the Monorepo.
|
|
618
|
-
*
|
|
619
|
-
* If provided with one (`string`)or more (`string[]`) group names in
|
|
620
|
-
* the {@link LoadQuery#groups} field, then only Workspaces in the named
|
|
621
|
-
* group(s) will be considered. Note that group names are unique string
|
|
622
|
-
* matches, not globs.
|
|
623
|
-
*
|
|
624
|
-
* If provided with a set of arbitrary path arguments, then only paths
|
|
625
|
-
* patching the provided pattern(s) will be included.
|
|
626
|
-
*
|
|
627
|
-
* These two options intersect, so
|
|
628
|
-
* `load({groups:'foo', paths:'./foo/[xy]*'})` will only load the workspaces
|
|
629
|
-
* in the group `foo` that match the paths glob.
|
|
630
|
-
*/
|
|
631
|
-
load(query = {}) {
|
|
632
|
-
const paths = new Set(
|
|
633
|
-
typeof query.paths === "string" ? [query.paths] : query.paths ?? []
|
|
634
|
-
);
|
|
635
|
-
const groups = new Set(
|
|
636
|
-
typeof query.groups === "string" ? [query.groups] : query.groups ?? []
|
|
637
|
-
);
|
|
638
|
-
const groupsExpanded = {};
|
|
639
|
-
for (const [group, pattern] of Object.entries(this.config)) {
|
|
640
|
-
if (groups.size && !groups.has(group)) continue;
|
|
641
|
-
groupsExpanded[group] = this.#glob(pattern);
|
|
642
|
-
}
|
|
643
|
-
const filter = paths.size ? this.#glob([...paths]) : paths;
|
|
644
|
-
if (paths.size && !filter.size) return this;
|
|
645
|
-
for (const [group, matches] of Object.entries(groupsExpanded)) {
|
|
646
|
-
for (const path of matches) {
|
|
647
|
-
if (filter.size && !filter.has(path)) continue;
|
|
648
|
-
this.#loadWS(path, group);
|
|
649
|
-
}
|
|
650
|
-
}
|
|
651
|
-
return this;
|
|
652
|
-
}
|
|
653
|
-
// Either load a workspace from disk, or from our internal set,
|
|
654
|
-
// and assign it to the named group
|
|
655
|
-
#loadWS(path, group) {
|
|
656
|
-
const fullpath = resolve(this.projectRoot, path);
|
|
657
|
-
const loaded = this.#workspaces.get(fullpath);
|
|
658
|
-
if (loaded) return loaded;
|
|
659
|
-
const fromCache = workspaceCache.get(fullpath);
|
|
660
|
-
const manifest = fromCache?.manifest ?? this.packageJson.read(fullpath);
|
|
661
|
-
const ws = fromCache ?? new Workspace(path, manifest, fullpath);
|
|
662
|
-
if (group) ws.groups.push(group);
|
|
663
|
-
this.#workspaces.set(ws.fullpath, ws);
|
|
664
|
-
this.#workspaces.set(ws.path, ws);
|
|
665
|
-
this.#workspaces.set(ws.name, ws);
|
|
666
|
-
for (const name of ws.groups) {
|
|
667
|
-
const group2 = this.#groups.get(name) ?? /* @__PURE__ */ new Set();
|
|
668
|
-
group2.add(ws);
|
|
669
|
-
this.#groups.set(name, group2);
|
|
670
|
-
}
|
|
671
|
-
return ws;
|
|
672
|
-
}
|
|
673
|
-
// can't be cached, because it's dependent on the matches set
|
|
674
|
-
// but still worthwhile to have it defined in one place
|
|
675
|
-
#globOptions(matches) {
|
|
676
|
-
const inMatches = (p) => {
|
|
677
|
-
return !!p?.relativePosix() && (matches.has(p.relativePosix()) || inMatches(p.parent));
|
|
678
|
-
};
|
|
679
|
-
return {
|
|
680
|
-
root: this.projectRoot,
|
|
681
|
-
cwd: this.projectRoot,
|
|
682
|
-
posix: true,
|
|
683
|
-
scurry: this.scurry,
|
|
684
|
-
withFileTypes: false,
|
|
685
|
-
ignore: {
|
|
686
|
-
childrenIgnored: (p) => basename(p.relativePosix()) === "node_modules" || inMatches(p),
|
|
687
|
-
// ignore if fails to load package.json
|
|
688
|
-
ignored: (p) => {
|
|
689
|
-
p.lstatSync();
|
|
690
|
-
const rel = p.relativePosix();
|
|
691
|
-
if (!rel) return true;
|
|
692
|
-
const maybeDelete = [];
|
|
693
|
-
for (const m of matches) {
|
|
694
|
-
if (rel.startsWith(m + "/")) return true;
|
|
695
|
-
if (m.startsWith(rel + "/")) {
|
|
696
|
-
maybeDelete.push(m);
|
|
697
|
-
}
|
|
698
|
-
}
|
|
699
|
-
if (!p.isDirectory()) return true;
|
|
700
|
-
const pj = p.resolve("package.json").lstatSync();
|
|
701
|
-
if (!pj?.isFile()) return true;
|
|
702
|
-
try {
|
|
703
|
-
this.packageJson.read(p.fullpath());
|
|
704
|
-
} catch {
|
|
705
|
-
return true;
|
|
706
|
-
}
|
|
707
|
-
for (const m of maybeDelete) {
|
|
708
|
-
matches.delete(m);
|
|
709
|
-
}
|
|
710
|
-
matches.add(rel);
|
|
711
|
-
return false;
|
|
712
|
-
}
|
|
713
|
-
}
|
|
714
|
-
};
|
|
715
|
-
}
|
|
716
|
-
#glob(pattern) {
|
|
717
|
-
const matches = /* @__PURE__ */ new Set();
|
|
718
|
-
globSync(pattern, this.#globOptions(matches));
|
|
719
|
-
return matches;
|
|
720
|
-
}
|
|
721
|
-
/**
|
|
722
|
-
* Return the array of workspace dependencies that are found in
|
|
723
|
-
* the loaded set, for use in calculating dependency graph order for
|
|
724
|
-
* build operations.
|
|
725
|
-
*
|
|
726
|
-
* This does *not* get the full set of dependencies, or expand any
|
|
727
|
-
* `workspace:` dependencies that are not loaded.
|
|
728
|
-
*
|
|
729
|
-
* Call with the `forceLoad` param set to `true` to attempt a full
|
|
730
|
-
* load if any deps are not currently loaded.
|
|
731
|
-
*/
|
|
732
|
-
getDeps(ws, forceLoad = false) {
|
|
733
|
-
const { manifest } = ws;
|
|
734
|
-
const depWorkspaces = [];
|
|
735
|
-
let didForceLoad = false;
|
|
736
|
-
for (const depType of [
|
|
737
|
-
"dependencies",
|
|
738
|
-
"devDependencies",
|
|
739
|
-
"optionalDependencies",
|
|
740
|
-
"peerDependencies"
|
|
741
|
-
]) {
|
|
742
|
-
const deps = manifest[depType];
|
|
743
|
-
if (!deps) continue;
|
|
744
|
-
for (const [dep, spec] of Object.entries(deps)) {
|
|
745
|
-
if (spec.startsWith("workspace:")) {
|
|
746
|
-
let depWS = this.#workspaces.get(dep);
|
|
747
|
-
if (!depWS) {
|
|
748
|
-
if (!forceLoad) continue;
|
|
749
|
-
if (didForceLoad) continue;
|
|
750
|
-
didForceLoad = true;
|
|
751
|
-
this.load();
|
|
752
|
-
depWS = this.#workspaces.get(dep);
|
|
753
|
-
if (!depWS) continue;
|
|
754
|
-
}
|
|
755
|
-
depWorkspaces.push(depWS);
|
|
756
|
-
}
|
|
757
|
-
}
|
|
758
|
-
}
|
|
759
|
-
return depWorkspaces;
|
|
760
|
-
}
|
|
761
|
-
onCycle(_ws, _cycle, _depPath) {
|
|
762
|
-
}
|
|
763
|
-
/**
|
|
764
|
-
* Return the set of workspaces in the named group.
|
|
765
|
-
* If the group is not one we know about, then undefined is returned.
|
|
766
|
-
*/
|
|
767
|
-
group(group) {
|
|
768
|
-
return this.#groups.get(group);
|
|
769
|
-
}
|
|
770
|
-
/**
|
|
771
|
-
* Get a loaded workspace by path or name.
|
|
772
|
-
*
|
|
773
|
-
* Note that this can only return workspaces that were ingested via a
|
|
774
|
-
* previous call to {@link Monorepo#load}.
|
|
775
|
-
*/
|
|
776
|
-
get(nameOrPath) {
|
|
777
|
-
return this.#workspaces.get(nameOrPath);
|
|
778
|
-
}
|
|
779
|
-
/**
|
|
780
|
-
* get the list of all loaded workspace names used as keys
|
|
781
|
-
*/
|
|
782
|
-
*names() {
|
|
783
|
-
for (const [key, ws] of this.#workspaces) {
|
|
784
|
-
if (key === ws.name) yield key;
|
|
785
|
-
}
|
|
786
|
-
}
|
|
787
|
-
/**
|
|
788
|
-
* get the list of all loaded workspace paths used as keys
|
|
789
|
-
*/
|
|
790
|
-
*paths() {
|
|
791
|
-
for (const [key, ws] of this.#workspaces) {
|
|
792
|
-
if (key === ws.path) yield key;
|
|
793
|
-
}
|
|
794
|
-
}
|
|
795
|
-
/**
|
|
796
|
-
* get the workspace objects in no particular order.
|
|
797
|
-
* this is ever so slightly faster than iterating, because it doesn't
|
|
798
|
-
* explore the graph to yield results in topological dependency order,
|
|
799
|
-
* and should be used instead when order doesn't matter.
|
|
800
|
-
*/
|
|
801
|
-
*values() {
|
|
802
|
-
const seen = /* @__PURE__ */ new Set();
|
|
803
|
-
for (const ws of this.#workspaces.values()) {
|
|
804
|
-
if (seen.has(ws.fullpath)) continue;
|
|
805
|
-
seen.add(ws.fullpath);
|
|
806
|
-
yield ws;
|
|
807
|
-
}
|
|
808
|
-
}
|
|
809
|
-
/**
|
|
810
|
-
* Get all the keys (package names and paths) for loaded workspaces.
|
|
811
|
-
* Union of {@link Monorepo#names} and {@link Monorepo#paths}
|
|
812
|
-
*/
|
|
813
|
-
*keys() {
|
|
814
|
-
for (const ws of this.values()) {
|
|
815
|
-
yield ws.path;
|
|
816
|
-
if (ws.name !== ws.path) yield ws.name;
|
|
817
|
-
}
|
|
818
|
-
}
|
|
819
|
-
/**
|
|
820
|
-
* Filter the monorepo object yielding the workspace objects that matches
|
|
821
|
-
* either of the {@link WorkspacesLoadedConfig} options provided, in as close
|
|
822
|
-
* to topological dependency order as possible.
|
|
823
|
-
*/
|
|
824
|
-
*filter({
|
|
825
|
-
workspace: namesOrPaths,
|
|
826
|
-
"workspace-group": groupName
|
|
827
|
-
}) {
|
|
828
|
-
const globPatternChecks = namesOrPaths?.map(
|
|
829
|
-
(glob) => minimatch.filter(posix.join(glob))
|
|
830
|
-
);
|
|
831
|
-
for (const ws of this) {
|
|
832
|
-
if (groupName?.some((i) => ws.groups.includes(i))) {
|
|
833
|
-
yield ws;
|
|
834
|
-
continue;
|
|
835
|
-
}
|
|
836
|
-
if (namesOrPaths?.map((i) => posix.join(i)).some((i) => ws.keys.includes(i))) {
|
|
837
|
-
yield ws;
|
|
838
|
-
continue;
|
|
839
|
-
}
|
|
840
|
-
if (ws.keys.some((key) => globPatternChecks?.some((fn) => fn(key)))) {
|
|
841
|
-
yield ws;
|
|
842
|
-
}
|
|
843
|
-
}
|
|
844
|
-
}
|
|
845
|
-
/**
|
|
846
|
-
* Run an operation asynchronously over all loaded workspaces
|
|
847
|
-
*
|
|
848
|
-
* If the `forceLoad` param is true, then it will attempt to do a full load
|
|
849
|
-
* when encountering a `workspace:` dependency that isn't loaded.
|
|
850
|
-
*
|
|
851
|
-
* Note that because the return type appears in the parameters of the
|
|
852
|
-
* operation function, it must be set explicitly either in the operation
|
|
853
|
-
* function signature or by calling `run<MyType>` or it'll fall back to
|
|
854
|
-
* `unknown`, similar to `Array.reduce()`, and for the same reason.
|
|
855
|
-
*/
|
|
856
|
-
async run(operation, forceLoad = false) {
|
|
857
|
-
const [ws, ...rest] = [...this.#workspaces.values()];
|
|
858
|
-
if (!ws) {
|
|
859
|
-
throw error("No workspaces loaded", void 0, this.run);
|
|
860
|
-
}
|
|
861
|
-
return graphRun({
|
|
862
|
-
graph: [ws, ...rest],
|
|
863
|
-
getDeps: (ws2) => this.getDeps(ws2, forceLoad),
|
|
864
|
-
visit: async (ws2, signal, _, depResults) => await operation(ws2, signal, depResults),
|
|
865
|
-
onCycle: (ws2, cycle, path) => this.onCycle(ws2, cycle, path)
|
|
866
|
-
});
|
|
867
|
-
}
|
|
868
|
-
/**
|
|
869
|
-
* Run an operation synchronously over all loaded workspaces
|
|
870
|
-
*
|
|
871
|
-
* If the `forceLoad` param is true, then it will attempt to do a full load
|
|
872
|
-
* when encountering a `workspace:` dependency that isn't loaded.
|
|
873
|
-
*
|
|
874
|
-
* Note that because the return type appears in the parameters of the
|
|
875
|
-
* operation function, it must be set explicitly either in the operation
|
|
876
|
-
* function signature or by calling `runSync<MyType>` or it'll fall back to
|
|
877
|
-
* `unknown`, similar to `Array.reduce()`, and for the same reason.
|
|
878
|
-
*/
|
|
879
|
-
runSync(operation, forceLoad = false) {
|
|
880
|
-
const [ws, ...rest] = [...this.#workspaces.values()];
|
|
881
|
-
if (!ws) {
|
|
882
|
-
throw error("No workspaces loaded", void 0, this.run);
|
|
883
|
-
}
|
|
884
|
-
return graphRunSync({
|
|
885
|
-
graph: [ws, ...rest],
|
|
886
|
-
getDeps: (ws2) => this.getDeps(ws2, forceLoad),
|
|
887
|
-
visit: (ws2, signal, _, depResults) => operation(ws2, signal, depResults),
|
|
888
|
-
onCycle: (ws2, cycle, path) => this.onCycle(ws2, cycle, path)
|
|
889
|
-
});
|
|
890
|
-
}
|
|
891
|
-
/**
|
|
892
|
-
* Convenience method to instantiate and load in one call.
|
|
893
|
-
* Returns undefined if the project is not a monorepo workspaces
|
|
894
|
-
* root, otherwise returns the loaded Monorepo.
|
|
895
|
-
*/
|
|
896
|
-
static maybeLoad(projectRoot, options = { load: {} }) {
|
|
897
|
-
try {
|
|
898
|
-
if (!statSync(
|
|
899
|
-
resolve(projectRoot, "vlt-workspaces.json")
|
|
900
|
-
).isFile()) {
|
|
901
|
-
return;
|
|
902
|
-
}
|
|
903
|
-
} catch {
|
|
904
|
-
return;
|
|
905
|
-
}
|
|
906
|
-
const { load = {} } = options;
|
|
907
|
-
return new _Monorepo(projectRoot, { ...options, load });
|
|
908
|
-
}
|
|
909
|
-
/**
|
|
910
|
-
* Convenience method to instantiate and load in one call.
|
|
911
|
-
* Throws if called on a directory that is not a workspaces root.
|
|
912
|
-
*/
|
|
913
|
-
static load(projectRoot, options = { load: {} }) {
|
|
914
|
-
const { load = {} } = options;
|
|
915
|
-
return new _Monorepo(projectRoot, { ...options, load });
|
|
916
|
-
}
|
|
917
|
-
};
|
|
918
|
-
var workspaceCache = /* @__PURE__ */ new Map();
|
|
919
|
-
var Workspace = class {
|
|
920
|
-
id;
|
|
921
|
-
path;
|
|
922
|
-
fullpath;
|
|
923
|
-
manifest;
|
|
924
|
-
groups = [];
|
|
925
|
-
name;
|
|
926
|
-
#keys;
|
|
927
|
-
constructor(path, manifest, fullpath) {
|
|
928
|
-
this.id = joinDepIDTuple(["workspace", path]);
|
|
929
|
-
workspaceCache.set(fullpath, this);
|
|
930
|
-
this.path = path;
|
|
931
|
-
this.fullpath = fullpath;
|
|
932
|
-
this.manifest = manifest;
|
|
933
|
-
this.name = manifest.name ?? path;
|
|
934
|
-
}
|
|
935
|
-
get keys() {
|
|
936
|
-
if (this.#keys) {
|
|
937
|
-
return this.#keys;
|
|
938
|
-
}
|
|
939
|
-
this.#keys = [this.name, this.path, this.fullpath];
|
|
940
|
-
return this.#keys;
|
|
941
|
-
}
|
|
942
|
-
};
|
|
943
|
-
|
|
944
|
-
// ../../node_modules/.pnpm/walk-up-path@4.0.0/node_modules/walk-up-path/dist/esm/index.js
|
|
945
|
-
import { dirname, resolve as resolve2 } from "node:path";
|
|
946
|
-
var walkUp = function* (path) {
|
|
947
|
-
for (path = resolve2(path); path; ) {
|
|
948
|
-
yield path;
|
|
949
|
-
const pp = dirname(path);
|
|
950
|
-
if (pp === path) {
|
|
951
|
-
break;
|
|
952
|
-
} else {
|
|
953
|
-
path = pp;
|
|
954
|
-
}
|
|
955
|
-
}
|
|
956
|
-
};
|
|
957
|
-
|
|
958
|
-
export {
|
|
959
|
-
asDepID,
|
|
960
|
-
joinDepIDTuple,
|
|
961
|
-
splitDepID,
|
|
962
|
-
hydrate,
|
|
963
|
-
hydrateTuple,
|
|
964
|
-
getId,
|
|
965
|
-
graphRun,
|
|
966
|
-
Monorepo,
|
|
967
|
-
walkUp
|
|
968
|
-
};
|
|
969
|
-
//# sourceMappingURL=chunk-JMGSFQ32.js.map
|