@diagonal-hq/cli 0.43.0 → 0.43.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.mjs
CHANGED
|
@@ -46,7 +46,7 @@ import {
|
|
|
46
46
|
routeBindingsSource,
|
|
47
47
|
routeParamNames,
|
|
48
48
|
workspace_settings_catalog_default
|
|
49
|
-
} from "./cli-chunk-
|
|
49
|
+
} from "./cli-chunk-HQJJ3ZAJ.mjs";
|
|
50
50
|
import {
|
|
51
51
|
TRIGGER_TYPES,
|
|
52
52
|
compareVersions,
|
|
@@ -184,9 +184,1104 @@ import {
|
|
|
184
184
|
} from "./cli-chunk-KP2RSHLJ.mjs";
|
|
185
185
|
import {
|
|
186
186
|
__commonJS,
|
|
187
|
+
__require,
|
|
187
188
|
__toESM
|
|
188
189
|
} from "./cli-chunk-LRS5IEI3.mjs";
|
|
189
190
|
|
|
191
|
+
// node_modules/lru-cache/dist/commonjs/node/index.min.js
|
|
192
|
+
var require_index_min = __commonJS({
|
|
193
|
+
"node_modules/lru-cache/dist/commonjs/node/index.min.js"(exports) {
|
|
194
|
+
"use strict";
|
|
195
|
+
var j = (u, t) => () => (t || u((t = { exports: {} }).exports, t), t.exports);
|
|
196
|
+
var I = j((O) => {
|
|
197
|
+
"use strict";
|
|
198
|
+
Object.defineProperty(O, "__esModule", { value: true });
|
|
199
|
+
O.tracing = O.metrics = void 0;
|
|
200
|
+
var U = __require("node:diagnostics_channel");
|
|
201
|
+
O.metrics = (0, U.channel)("lru-cache:metrics");
|
|
202
|
+
O.tracing = (0, U.tracingChannel)("lru-cache");
|
|
203
|
+
});
|
|
204
|
+
var P = j((R) => {
|
|
205
|
+
"use strict";
|
|
206
|
+
Object.defineProperty(R, "__esModule", { value: true });
|
|
207
|
+
R.defaultPerf = void 0;
|
|
208
|
+
R.defaultPerf = typeof performance == "object" && performance && typeof performance.now == "function" ? performance : Date;
|
|
209
|
+
});
|
|
210
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
211
|
+
exports.LRUCache = void 0;
|
|
212
|
+
var g = I();
|
|
213
|
+
var N = P();
|
|
214
|
+
var C = () => g.metrics.hasSubscribers || g.tracing.hasSubscribers;
|
|
215
|
+
var k = /* @__PURE__ */ new Set();
|
|
216
|
+
var G = typeof process == "object" && process ? process : {};
|
|
217
|
+
var V = (u, t, e, i) => {
|
|
218
|
+
typeof G.emitWarning == "function" ? G.emitWarning(u, t, e, i) : console.error(`[${e}] ${t}: ${u}`);
|
|
219
|
+
};
|
|
220
|
+
var q = (u) => !k.has(u);
|
|
221
|
+
var T = (u) => !!u && u === Math.floor(u) && u > 0 && isFinite(u);
|
|
222
|
+
var H = (u) => T(u) ? u <= Math.pow(2, 8) ? Uint8Array : u <= Math.pow(2, 16) ? Uint16Array : u <= Math.pow(2, 32) ? Uint32Array : u <= Number.MAX_SAFE_INTEGER ? W : null : null;
|
|
223
|
+
var W = class extends Array {
|
|
224
|
+
constructor(t) {
|
|
225
|
+
super(t), this.fill(0);
|
|
226
|
+
}
|
|
227
|
+
};
|
|
228
|
+
var L = class u {
|
|
229
|
+
heap;
|
|
230
|
+
length;
|
|
231
|
+
static #o = false;
|
|
232
|
+
static create(t) {
|
|
233
|
+
let e = H(t);
|
|
234
|
+
if (!e) return [];
|
|
235
|
+
u.#o = true;
|
|
236
|
+
let i = new u(t, e);
|
|
237
|
+
return u.#o = false, i;
|
|
238
|
+
}
|
|
239
|
+
constructor(t, e) {
|
|
240
|
+
if (!u.#o) throw new TypeError("instantiate Stack using Stack.create(n)");
|
|
241
|
+
this.heap = new e(t), this.length = 0;
|
|
242
|
+
}
|
|
243
|
+
push(t) {
|
|
244
|
+
this.heap[this.length++] = t;
|
|
245
|
+
}
|
|
246
|
+
pop() {
|
|
247
|
+
return this.heap[--this.length];
|
|
248
|
+
}
|
|
249
|
+
};
|
|
250
|
+
var M = class u {
|
|
251
|
+
#o;
|
|
252
|
+
#c;
|
|
253
|
+
#m;
|
|
254
|
+
#W;
|
|
255
|
+
#S;
|
|
256
|
+
#x;
|
|
257
|
+
#j;
|
|
258
|
+
#w;
|
|
259
|
+
get perf() {
|
|
260
|
+
return this.#w;
|
|
261
|
+
}
|
|
262
|
+
ttl;
|
|
263
|
+
ttlResolution;
|
|
264
|
+
ttlAutopurge;
|
|
265
|
+
updateAgeOnGet;
|
|
266
|
+
updateAgeOnHas;
|
|
267
|
+
allowStale;
|
|
268
|
+
noDisposeOnSet;
|
|
269
|
+
noUpdateTTL;
|
|
270
|
+
maxEntrySize;
|
|
271
|
+
sizeCalculation;
|
|
272
|
+
noDeleteOnFetchRejection;
|
|
273
|
+
noDeleteOnStaleGet;
|
|
274
|
+
allowStaleOnFetchAbort;
|
|
275
|
+
allowStaleOnFetchRejection;
|
|
276
|
+
ignoreFetchAbort;
|
|
277
|
+
backgroundFetchSize;
|
|
278
|
+
#n;
|
|
279
|
+
#b;
|
|
280
|
+
#s;
|
|
281
|
+
#i;
|
|
282
|
+
#t;
|
|
283
|
+
#l;
|
|
284
|
+
#u;
|
|
285
|
+
#a;
|
|
286
|
+
#h;
|
|
287
|
+
#_;
|
|
288
|
+
#r;
|
|
289
|
+
#y;
|
|
290
|
+
#F;
|
|
291
|
+
#d;
|
|
292
|
+
#g;
|
|
293
|
+
#T;
|
|
294
|
+
#U;
|
|
295
|
+
#f;
|
|
296
|
+
#R;
|
|
297
|
+
static unsafeExposeInternals(t) {
|
|
298
|
+
return { starts: t.#F, ttls: t.#d, autopurgeTimers: t.#g, sizes: t.#y, keyMap: t.#s, keyList: t.#i, valList: t.#t, next: t.#l, prev: t.#u, get head() {
|
|
299
|
+
return t.#a;
|
|
300
|
+
}, get tail() {
|
|
301
|
+
return t.#h;
|
|
302
|
+
}, free: t.#_, isBackgroundFetch: (e) => t.#e(e), backgroundFetch: (e, i, s, n) => t.#G(e, i, s, n), moveToTail: (e) => t.#M(e), indexes: (e) => t.#A(e), rindexes: (e) => t.#z(e), isStale: (e) => t.#p(e) };
|
|
303
|
+
}
|
|
304
|
+
get max() {
|
|
305
|
+
return this.#o;
|
|
306
|
+
}
|
|
307
|
+
get maxSize() {
|
|
308
|
+
return this.#c;
|
|
309
|
+
}
|
|
310
|
+
get calculatedSize() {
|
|
311
|
+
return this.#b;
|
|
312
|
+
}
|
|
313
|
+
get size() {
|
|
314
|
+
return this.#n;
|
|
315
|
+
}
|
|
316
|
+
get fetchMethod() {
|
|
317
|
+
return this.#x;
|
|
318
|
+
}
|
|
319
|
+
get memoMethod() {
|
|
320
|
+
return this.#j;
|
|
321
|
+
}
|
|
322
|
+
get dispose() {
|
|
323
|
+
return this.#m;
|
|
324
|
+
}
|
|
325
|
+
get onInsert() {
|
|
326
|
+
return this.#W;
|
|
327
|
+
}
|
|
328
|
+
get disposeAfter() {
|
|
329
|
+
return this.#S;
|
|
330
|
+
}
|
|
331
|
+
constructor(t) {
|
|
332
|
+
let { max: e = 0, ttl: i, ttlResolution: s = 1, ttlAutopurge: n, updateAgeOnGet: o, updateAgeOnHas: l, allowStale: h, dispose: r, onInsert: c, disposeAfter: w, noDisposeOnSet: y, noUpdateTTL: d, maxSize: p = 0, maxEntrySize: f = 0, sizeCalculation: _, fetchMethod: a, memoMethod: S, noDeleteOnFetchRejection: F, noDeleteOnStaleGet: b, allowStaleOnFetchRejection: m, allowStaleOnFetchAbort: A, ignoreFetchAbort: z, backgroundFetchSize: x = 1, perf: v } = t;
|
|
333
|
+
if (this.backgroundFetchSize = x, v !== void 0 && typeof v?.now != "function") throw new TypeError("perf option must have a now() method if specified");
|
|
334
|
+
if (this.#w = v ?? N.defaultPerf, e !== 0 && !T(e)) throw new TypeError("max option must be a nonnegative integer");
|
|
335
|
+
let E = e ? H(e) : Array;
|
|
336
|
+
if (!E) throw new Error("invalid max value: " + e);
|
|
337
|
+
if (this.#o = e, this.#c = p, this.maxEntrySize = f || this.#c, this.sizeCalculation = _, this.sizeCalculation) {
|
|
338
|
+
if (!this.#c && !this.maxEntrySize) throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");
|
|
339
|
+
if (typeof this.sizeCalculation != "function") throw new TypeError("sizeCalculation set to non-function");
|
|
340
|
+
}
|
|
341
|
+
if (S !== void 0 && typeof S != "function") throw new TypeError("memoMethod must be a function if defined");
|
|
342
|
+
if (this.#j = S, a !== void 0 && typeof a != "function") throw new TypeError("fetchMethod must be a function if specified");
|
|
343
|
+
if (this.#x = a, this.#U = !!a, this.#s = /* @__PURE__ */ new Map(), this.#i = Array.from({ length: e }).fill(void 0), this.#t = Array.from({ length: e }).fill(void 0), this.#l = new E(e), this.#u = new E(e), this.#a = 0, this.#h = 0, this.#_ = L.create(e), this.#n = 0, this.#b = 0, typeof r == "function" && (this.#m = r), typeof c == "function" && (this.#W = c), typeof w == "function" ? (this.#S = w, this.#r = []) : (this.#S = void 0, this.#r = void 0), this.#T = !!this.#m, this.#R = !!this.#W, this.#f = !!this.#S, this.noDisposeOnSet = !!y, this.noUpdateTTL = !!d, this.noDeleteOnFetchRejection = !!F, this.allowStaleOnFetchRejection = !!m, this.allowStaleOnFetchAbort = !!A, this.ignoreFetchAbort = !!z, this.maxEntrySize !== 0) {
|
|
344
|
+
if (this.#c !== 0 && !T(this.#c)) throw new TypeError("maxSize must be a positive integer if specified");
|
|
345
|
+
if (!T(this.maxEntrySize)) throw new TypeError("maxEntrySize must be a positive integer if specified");
|
|
346
|
+
this.#X();
|
|
347
|
+
}
|
|
348
|
+
if (this.allowStale = !!h, this.noDeleteOnStaleGet = !!b, this.updateAgeOnGet = !!o, this.updateAgeOnHas = !!l, this.ttlResolution = T(s) || s === 0 ? s : 1, this.ttlAutopurge = !!n, this.ttl = i || 0, this.ttl) {
|
|
349
|
+
if (!T(this.ttl)) throw new TypeError("ttl must be a positive integer if specified");
|
|
350
|
+
this.#k();
|
|
351
|
+
}
|
|
352
|
+
if (this.#o === 0 && this.ttl === 0 && this.#c === 0) throw new TypeError("At least one of max, maxSize, or ttl is required");
|
|
353
|
+
if (!this.ttlAutopurge && !this.#o && !this.#c) {
|
|
354
|
+
let D = "LRU_CACHE_UNBOUNDED";
|
|
355
|
+
q(D) && (k.add(D), V("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.", "UnboundedCacheWarning", D, u));
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
getRemainingTTL(t) {
|
|
359
|
+
return this.#s.has(t) ? 1 / 0 : 0;
|
|
360
|
+
}
|
|
361
|
+
#k() {
|
|
362
|
+
let t = new W(this.#o), e = new W(this.#o);
|
|
363
|
+
this.#d = t, this.#F = e;
|
|
364
|
+
let i = this.ttlAutopurge ? Array.from({ length: this.#o }) : void 0;
|
|
365
|
+
this.#g = i, this.#H = (h, r, c = this.#w.now()) => {
|
|
366
|
+
e[h] = r !== 0 ? c : 0, t[h] = r, s(h, r);
|
|
367
|
+
}, this.#D = (h) => {
|
|
368
|
+
e[h] = t[h] !== 0 ? this.#w.now() : 0, s(h, t[h]);
|
|
369
|
+
};
|
|
370
|
+
let s = this.ttlAutopurge ? (h, r) => {
|
|
371
|
+
if (i?.[h] && (clearTimeout(i[h]), i[h] = void 0), r && r !== 0 && i) {
|
|
372
|
+
let c = setTimeout(() => {
|
|
373
|
+
this.#p(h) ? (this.#v(this.#i[h], "expire"), i[h] = void 0) : s(h, l(h));
|
|
374
|
+
}, r + 1);
|
|
375
|
+
c.unref && c.unref(), i[h] = c;
|
|
376
|
+
}
|
|
377
|
+
} : () => {
|
|
378
|
+
};
|
|
379
|
+
this.#E = (h, r) => {
|
|
380
|
+
if (t[r]) {
|
|
381
|
+
let c = t[r], w = e[r];
|
|
382
|
+
if (!c || !w) return;
|
|
383
|
+
h.ttl = c, h.start = w, h.now = n || o();
|
|
384
|
+
let y = h.now - w;
|
|
385
|
+
h.remainingTTL = c - y;
|
|
386
|
+
}
|
|
387
|
+
};
|
|
388
|
+
let n = 0, o = () => {
|
|
389
|
+
let h = this.#w.now();
|
|
390
|
+
if (this.ttlResolution > 0) {
|
|
391
|
+
n = h;
|
|
392
|
+
let r = setTimeout(() => n = 0, this.ttlResolution);
|
|
393
|
+
r.unref && r.unref();
|
|
394
|
+
}
|
|
395
|
+
return h;
|
|
396
|
+
};
|
|
397
|
+
this.getRemainingTTL = (h) => {
|
|
398
|
+
let r = this.#s.get(h);
|
|
399
|
+
return r === void 0 ? 0 : l(r);
|
|
400
|
+
};
|
|
401
|
+
let l = (h) => {
|
|
402
|
+
let r = t[h], c = e[h];
|
|
403
|
+
if (!r || !c) return 1 / 0;
|
|
404
|
+
let w = (n || o()) - c;
|
|
405
|
+
return r - w;
|
|
406
|
+
};
|
|
407
|
+
this.#p = (h) => {
|
|
408
|
+
let r = e[h], c = t[h];
|
|
409
|
+
return !!c && !!r && (n || o()) - r > c;
|
|
410
|
+
};
|
|
411
|
+
}
|
|
412
|
+
#D = () => {
|
|
413
|
+
};
|
|
414
|
+
#E = () => {
|
|
415
|
+
};
|
|
416
|
+
#H = () => {
|
|
417
|
+
};
|
|
418
|
+
#p = () => false;
|
|
419
|
+
#X() {
|
|
420
|
+
let t = new W(this.#o);
|
|
421
|
+
this.#b = 0, this.#y = t, this.#C = (e) => {
|
|
422
|
+
this.#b -= t[e], t[e] = 0;
|
|
423
|
+
}, this.#N = (e, i, s, n) => {
|
|
424
|
+
if (!T(s)) {
|
|
425
|
+
if (this.#e(i)) return this.backgroundFetchSize;
|
|
426
|
+
if (n) {
|
|
427
|
+
if (typeof n != "function") throw new TypeError("sizeCalculation must be a function");
|
|
428
|
+
if (s = n(i, e), !T(s)) throw new TypeError("sizeCalculation return invalid (expect positive integer)");
|
|
429
|
+
} else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");
|
|
430
|
+
}
|
|
431
|
+
return s;
|
|
432
|
+
}, this.#I = (e, i, s) => {
|
|
433
|
+
if (t[e] = i, this.#c) {
|
|
434
|
+
let n = this.#c - t[e];
|
|
435
|
+
for (; this.#b > n; ) this.#P(true);
|
|
436
|
+
}
|
|
437
|
+
this.#b += t[e], s && (s.entrySize = i, s.totalCalculatedSize = this.#b);
|
|
438
|
+
};
|
|
439
|
+
}
|
|
440
|
+
#C = (t) => {
|
|
441
|
+
};
|
|
442
|
+
#I = (t, e, i) => {
|
|
443
|
+
};
|
|
444
|
+
#N = (t, e, i, s) => {
|
|
445
|
+
if (i || s) throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");
|
|
446
|
+
return 0;
|
|
447
|
+
};
|
|
448
|
+
*#A({ allowStale: t = this.allowStale } = {}) {
|
|
449
|
+
if (this.#n) for (let e = this.#h; this.#V(e) && ((t || !this.#p(e)) && (yield e), e !== this.#a); ) e = this.#u[e];
|
|
450
|
+
}
|
|
451
|
+
*#z({ allowStale: t = this.allowStale } = {}) {
|
|
452
|
+
if (this.#n) for (let e = this.#a; this.#V(e) && ((t || !this.#p(e)) && (yield e), e !== this.#h); ) e = this.#l[e];
|
|
453
|
+
}
|
|
454
|
+
#V(t) {
|
|
455
|
+
return t !== void 0 && this.#s.get(this.#i[t]) === t;
|
|
456
|
+
}
|
|
457
|
+
*entries() {
|
|
458
|
+
for (let t of this.#A()) this.#t[t] !== void 0 && this.#i[t] !== void 0 && !this.#e(this.#t[t]) && (yield [this.#i[t], this.#t[t]]);
|
|
459
|
+
}
|
|
460
|
+
*rentries() {
|
|
461
|
+
for (let t of this.#z()) this.#t[t] !== void 0 && this.#i[t] !== void 0 && !this.#e(this.#t[t]) && (yield [this.#i[t], this.#t[t]]);
|
|
462
|
+
}
|
|
463
|
+
*keys() {
|
|
464
|
+
for (let t of this.#A()) {
|
|
465
|
+
let e = this.#i[t];
|
|
466
|
+
e !== void 0 && !this.#e(this.#t[t]) && (yield e);
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
*rkeys() {
|
|
470
|
+
for (let t of this.#z()) {
|
|
471
|
+
let e = this.#i[t];
|
|
472
|
+
e !== void 0 && !this.#e(this.#t[t]) && (yield e);
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
*values() {
|
|
476
|
+
for (let t of this.#A()) this.#t[t] !== void 0 && !this.#e(this.#t[t]) && (yield this.#t[t]);
|
|
477
|
+
}
|
|
478
|
+
*rvalues() {
|
|
479
|
+
for (let t of this.#z()) this.#t[t] !== void 0 && !this.#e(this.#t[t]) && (yield this.#t[t]);
|
|
480
|
+
}
|
|
481
|
+
[Symbol.iterator]() {
|
|
482
|
+
return this.entries();
|
|
483
|
+
}
|
|
484
|
+
[Symbol.toStringTag] = "LRUCache";
|
|
485
|
+
find(t, e = {}) {
|
|
486
|
+
for (let i of this.#A()) {
|
|
487
|
+
let s = this.#t[i], n = this.#e(s) ? s.__staleWhileFetching : s;
|
|
488
|
+
if (n !== void 0 && t(n, this.#i[i], this)) return this.#L(this.#i[i], e);
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
forEach(t, e = this) {
|
|
492
|
+
for (let i of this.#A()) {
|
|
493
|
+
let s = this.#t[i], n = this.#e(s) ? s.__staleWhileFetching : s;
|
|
494
|
+
n !== void 0 && t.call(e, n, this.#i[i], this);
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
rforEach(t, e = this) {
|
|
498
|
+
for (let i of this.#z()) {
|
|
499
|
+
let s = this.#t[i], n = this.#e(s) ? s.__staleWhileFetching : s;
|
|
500
|
+
n !== void 0 && t.call(e, n, this.#i[i], this);
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
purgeStale() {
|
|
504
|
+
let t = false;
|
|
505
|
+
for (let e of this.#z({ allowStale: true })) this.#p(e) && (this.#v(this.#i[e], "expire"), t = true);
|
|
506
|
+
return t;
|
|
507
|
+
}
|
|
508
|
+
info(t) {
|
|
509
|
+
let e = this.#s.get(t);
|
|
510
|
+
if (e === void 0) return;
|
|
511
|
+
let i = this.#t[e], s = this.#e(i) ? i.__staleWhileFetching : i;
|
|
512
|
+
if (s === void 0) return;
|
|
513
|
+
let n = { value: s };
|
|
514
|
+
if (this.#d && this.#F) {
|
|
515
|
+
let o = this.#d[e], l = this.#F[e];
|
|
516
|
+
if (o && l) {
|
|
517
|
+
let h = o - (this.#w.now() - l);
|
|
518
|
+
n.ttl = h, n.start = Date.now();
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
return this.#y && (n.size = this.#y[e]), n;
|
|
522
|
+
}
|
|
523
|
+
dump() {
|
|
524
|
+
let t = [];
|
|
525
|
+
for (let e of this.#A({ allowStale: true })) {
|
|
526
|
+
let i = this.#i[e], s = this.#t[e], n = this.#e(s) ? s.__staleWhileFetching : s;
|
|
527
|
+
if (n === void 0 || i === void 0) continue;
|
|
528
|
+
let o = { value: n };
|
|
529
|
+
if (this.#d && this.#F) {
|
|
530
|
+
o.ttl = this.#d[e];
|
|
531
|
+
let l = this.#w.now() - this.#F[e];
|
|
532
|
+
o.start = Math.floor(Date.now() - l);
|
|
533
|
+
}
|
|
534
|
+
this.#y && (o.size = this.#y[e]), t.unshift([i, o]);
|
|
535
|
+
}
|
|
536
|
+
return t;
|
|
537
|
+
}
|
|
538
|
+
load(t) {
|
|
539
|
+
this.clear();
|
|
540
|
+
for (let [e, i] of t) {
|
|
541
|
+
if (i.start) {
|
|
542
|
+
let s = Date.now() - i.start;
|
|
543
|
+
i.start = this.#w.now() - s;
|
|
544
|
+
}
|
|
545
|
+
this.#O(e, i.value, i);
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
set(t, e, i = {}) {
|
|
549
|
+
let { status: s = g.metrics.hasSubscribers ? {} : void 0 } = i;
|
|
550
|
+
i.status = s, s && (s.op = "set", s.key = t, e !== void 0 && (s.value = e), s.cache = this);
|
|
551
|
+
let n = this.#O(t, e, i);
|
|
552
|
+
return s && g.metrics.hasSubscribers && g.metrics.publish(s), n;
|
|
553
|
+
}
|
|
554
|
+
#O(t, e, i, s) {
|
|
555
|
+
let { ttl: n = this.ttl, start: o, noDisposeOnSet: l = this.noDisposeOnSet, sizeCalculation: h = this.sizeCalculation, status: r } = i, c = this.#e(e);
|
|
556
|
+
if (e === void 0) return r && (r.set = "deleted"), this.delete(t), this;
|
|
557
|
+
let { noUpdateTTL: w = this.noUpdateTTL } = i;
|
|
558
|
+
r && !c && (r.value = e);
|
|
559
|
+
let y = this.#N(t, e, i.size || 0, h, r);
|
|
560
|
+
if (this.maxEntrySize && y > this.maxEntrySize) return this.#v(t, "set"), r && (r.set = "miss", r.maxEntrySizeExceeded = true), this;
|
|
561
|
+
let d = this.#n === 0 ? void 0 : this.#s.get(t);
|
|
562
|
+
if (d === void 0) d = this.#n === 0 ? this.#h : this.#_.length !== 0 ? this.#_.pop() : this.#n === this.#o ? this.#P(false) : this.#n, this.#i[d] = t, this.#t[d] = e, this.#s.set(t, d), this.#l[this.#h] = d, this.#u[d] = this.#h, this.#h = d, this.#n++, this.#I(d, y, r), r && (r.set = "add"), w = false, this.#R && !c && this.#W?.(e, t, "add");
|
|
563
|
+
else {
|
|
564
|
+
this.#M(d);
|
|
565
|
+
let p = this.#t[d];
|
|
566
|
+
if (e !== p) {
|
|
567
|
+
if (!l) if (this.#e(p)) {
|
|
568
|
+
p !== s && p.__abortController.abort(new Error("replaced"));
|
|
569
|
+
let { __staleWhileFetching: f } = p;
|
|
570
|
+
f !== void 0 && f !== e && (this.#T && this.#m?.(f, t, "set"), this.#f && this.#r?.push([f, t, "set"]));
|
|
571
|
+
} else this.#T && this.#m?.(p, t, "set"), this.#f && this.#r?.push([p, t, "set"]);
|
|
572
|
+
if (this.#C(d), this.#I(d, y, r), this.#t[d] = e, !c) {
|
|
573
|
+
let f = p && this.#e(p) ? p.__staleWhileFetching : p, _ = f === void 0 ? "add" : e !== f ? "replace" : "update";
|
|
574
|
+
r && (r.set = _, f !== void 0 && (r.oldValue = f)), this.#R && this.onInsert?.(e, t, _);
|
|
575
|
+
}
|
|
576
|
+
} else c || (r && (r.set = "update"), this.#R && this.onInsert?.(e, t, "update"));
|
|
577
|
+
}
|
|
578
|
+
if (n !== 0 && !this.#d && this.#k(), this.#d && (w || this.#H(d, n, o), r && this.#E(r, d)), !l && this.#f && this.#r) {
|
|
579
|
+
let p = this.#r, f;
|
|
580
|
+
for (; f = p?.shift(); ) this.#S?.(...f);
|
|
581
|
+
}
|
|
582
|
+
return this;
|
|
583
|
+
}
|
|
584
|
+
pop() {
|
|
585
|
+
try {
|
|
586
|
+
for (; this.#n; ) {
|
|
587
|
+
let t = this.#t[this.#a];
|
|
588
|
+
if (this.#P(true), this.#e(t)) {
|
|
589
|
+
if (t.__staleWhileFetching) return t.__staleWhileFetching;
|
|
590
|
+
} else if (t !== void 0) return t;
|
|
591
|
+
}
|
|
592
|
+
} finally {
|
|
593
|
+
if (this.#f && this.#r) {
|
|
594
|
+
let t = this.#r, e;
|
|
595
|
+
for (; e = t?.shift(); ) this.#S?.(...e);
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
#P(t) {
|
|
600
|
+
let e = this.#a, i = this.#i[e], s = this.#t[e], n = this.#e(s);
|
|
601
|
+
n && s.__abortController.abort(new Error("evicted"));
|
|
602
|
+
let o = n ? s.__staleWhileFetching : s;
|
|
603
|
+
return (this.#T || this.#f) && o !== void 0 && (this.#T && this.#m?.(o, i, "evict"), this.#f && this.#r?.push([o, i, "evict"])), this.#C(e), this.#g?.[e] && (clearTimeout(this.#g[e]), this.#g[e] = void 0), t && (this.#i[e] = void 0, this.#t[e] = void 0, this.#_.push(e)), this.#n === 1 ? (this.#a = this.#h = 0, this.#_.length = 0) : this.#a = this.#l[e], this.#s.delete(i), this.#n--, e;
|
|
604
|
+
}
|
|
605
|
+
has(t, e = {}) {
|
|
606
|
+
let { status: i = g.metrics.hasSubscribers ? {} : void 0 } = e;
|
|
607
|
+
e.status = i, i && (i.op = "has", i.key = t, i.cache = this);
|
|
608
|
+
let s = this.#Y(t, e);
|
|
609
|
+
return g.metrics.hasSubscribers && g.metrics.publish(i), s;
|
|
610
|
+
}
|
|
611
|
+
#Y(t, e = {}) {
|
|
612
|
+
let { updateAgeOnHas: i = this.updateAgeOnHas, status: s } = e, n = this.#s.get(t);
|
|
613
|
+
if (n !== void 0) {
|
|
614
|
+
let o = this.#t[n];
|
|
615
|
+
if (this.#e(o) && o.__staleWhileFetching === void 0) return false;
|
|
616
|
+
if (this.#p(n)) s && (s.has = "stale", this.#E(s, n));
|
|
617
|
+
else return i && this.#D(n), s && (s.has = "hit", this.#E(s, n)), true;
|
|
618
|
+
} else s && (s.has = "miss");
|
|
619
|
+
return false;
|
|
620
|
+
}
|
|
621
|
+
peek(t, e = {}) {
|
|
622
|
+
let { status: i = C() ? {} : void 0 } = e;
|
|
623
|
+
i && (i.op = "peek", i.key = t, i.cache = this), e.status = i;
|
|
624
|
+
let s = this.#J(t, e);
|
|
625
|
+
return g.metrics.hasSubscribers && g.metrics.publish(i), s;
|
|
626
|
+
}
|
|
627
|
+
#J(t, e) {
|
|
628
|
+
let { status: i, allowStale: s = this.allowStale } = e, n = this.#s.get(t);
|
|
629
|
+
if (n === void 0 || !s && this.#p(n)) {
|
|
630
|
+
i && (i.peek = n === void 0 ? "miss" : "stale");
|
|
631
|
+
return;
|
|
632
|
+
}
|
|
633
|
+
let o = this.#t[n], l = this.#e(o) ? o.__staleWhileFetching : o;
|
|
634
|
+
return i && (l !== void 0 ? (i.peek = "hit", i.value = l) : i.peek = "miss"), l;
|
|
635
|
+
}
|
|
636
|
+
#G(t, e, i, s) {
|
|
637
|
+
let n = e === void 0 ? void 0 : this.#t[e];
|
|
638
|
+
if (this.#e(n)) return n;
|
|
639
|
+
let o = new AbortController(), { signal: l } = i;
|
|
640
|
+
l?.addEventListener("abort", () => o.abort(l.reason), { signal: o.signal });
|
|
641
|
+
let h = { signal: o.signal, options: i, context: s }, r = (f, _ = false) => {
|
|
642
|
+
let { aborted: a } = o.signal, S = i.ignoreFetchAbort && f !== void 0, F = i.ignoreFetchAbort || !!(i.allowStaleOnFetchAbort && f !== void 0);
|
|
643
|
+
if (i.status && (a && !_ ? (i.status.fetchAborted = true, i.status.fetchError = o.signal.reason, S && (i.status.fetchAbortIgnored = true)) : i.status.fetchResolved = true), a && !S && !_) return w(o.signal.reason, F);
|
|
644
|
+
let b = d, m = this.#t[e];
|
|
645
|
+
return (m === d || m === void 0 && S && _) && (f === void 0 ? b.__staleWhileFetching !== void 0 ? this.#t[e] = b.__staleWhileFetching : this.#v(t, "fetch") : (i.status && (i.status.fetchUpdated = true), this.#O(t, f, h.options, b))), f;
|
|
646
|
+
}, c = (f) => (i.status && (i.status.fetchRejected = true, i.status.fetchError = f), w(f, false)), w = (f, _) => {
|
|
647
|
+
let { aborted: a } = o.signal, S = a && i.allowStaleOnFetchAbort, F = S || i.allowStaleOnFetchRejection, b = F || i.noDeleteOnFetchRejection, m = d;
|
|
648
|
+
if (this.#t[e] === d && (!b || !_ && m.__staleWhileFetching === void 0 ? this.#v(t, "fetch") : S || (this.#t[e] = m.__staleWhileFetching)), F) return i.status && m.__staleWhileFetching !== void 0 && (i.status.returnedStale = true), m.__staleWhileFetching;
|
|
649
|
+
if (m.__returned === m) throw f;
|
|
650
|
+
}, y = (f, _) => {
|
|
651
|
+
let a = this.#x?.(t, n, h);
|
|
652
|
+
o.signal.addEventListener("abort", () => {
|
|
653
|
+
(!i.ignoreFetchAbort || i.allowStaleOnFetchAbort) && (f(void 0), i.allowStaleOnFetchAbort && (f = (S) => r(S, true)));
|
|
654
|
+
}), a && a instanceof Promise ? a.then((S) => f(S === void 0 ? void 0 : S), _) : a !== void 0 && f(a);
|
|
655
|
+
};
|
|
656
|
+
i.status && (i.status.fetchDispatched = true);
|
|
657
|
+
let d = new Promise(y).then(r, c), p = Object.assign(d, { __abortController: o, __staleWhileFetching: n, __returned: void 0 });
|
|
658
|
+
return e === void 0 ? (this.#O(t, p, { ...h.options, status: void 0 }), e = this.#s.get(t)) : this.#t[e] = p, p;
|
|
659
|
+
}
|
|
660
|
+
#e(t) {
|
|
661
|
+
if (!this.#U) return false;
|
|
662
|
+
let e = t;
|
|
663
|
+
return !!e && e instanceof Promise && e.hasOwnProperty("__staleWhileFetching") && e.__abortController instanceof AbortController;
|
|
664
|
+
}
|
|
665
|
+
fetch(t, e = {}) {
|
|
666
|
+
let i = g.tracing.hasSubscribers, { status: s = C() ? {} : void 0 } = e;
|
|
667
|
+
e.status = s, s && e.context && (s.context = e.context);
|
|
668
|
+
let n = this.#q(t, e);
|
|
669
|
+
return s && i && (s.trace = true, g.tracing.tracePromise(() => n, s).catch(() => {
|
|
670
|
+
})), n;
|
|
671
|
+
}
|
|
672
|
+
async #q(t, e = {}) {
|
|
673
|
+
let { allowStale: i = this.allowStale, updateAgeOnGet: s = this.updateAgeOnGet, noDeleteOnStaleGet: n = this.noDeleteOnStaleGet, ttl: o = this.ttl, noDisposeOnSet: l = this.noDisposeOnSet, size: h = 0, sizeCalculation: r = this.sizeCalculation, noUpdateTTL: c = this.noUpdateTTL, noDeleteOnFetchRejection: w = this.noDeleteOnFetchRejection, allowStaleOnFetchRejection: y = this.allowStaleOnFetchRejection, ignoreFetchAbort: d = this.ignoreFetchAbort, allowStaleOnFetchAbort: p = this.allowStaleOnFetchAbort, context: f, forceRefresh: _ = false, status: a, signal: S } = e;
|
|
674
|
+
if (a && (a.op = "fetch", a.key = t, _ && (a.forceRefresh = true), a.cache = this), !this.#U) return a && (a.fetch = "get"), this.#L(t, { allowStale: i, updateAgeOnGet: s, noDeleteOnStaleGet: n, status: a });
|
|
675
|
+
let F = { allowStale: i, updateAgeOnGet: s, noDeleteOnStaleGet: n, ttl: o, noDisposeOnSet: l, size: h, sizeCalculation: r, noUpdateTTL: c, noDeleteOnFetchRejection: w, allowStaleOnFetchRejection: y, allowStaleOnFetchAbort: p, ignoreFetchAbort: d, status: a, signal: S }, b = this.#s.get(t);
|
|
676
|
+
if (b === void 0) {
|
|
677
|
+
a && (a.fetch = "miss");
|
|
678
|
+
let m = this.#G(t, b, F, f);
|
|
679
|
+
return m.__returned = m;
|
|
680
|
+
} else {
|
|
681
|
+
let m = this.#t[b];
|
|
682
|
+
if (this.#e(m)) {
|
|
683
|
+
let E = i && m.__staleWhileFetching !== void 0;
|
|
684
|
+
return a && (a.fetch = "inflight", E && (a.returnedStale = true)), E ? m.__staleWhileFetching : m.__returned = m;
|
|
685
|
+
}
|
|
686
|
+
let A = this.#p(b);
|
|
687
|
+
if (!_ && !A) return a && (a.fetch = "hit"), this.#M(b), s && this.#D(b), a && this.#E(a, b), m;
|
|
688
|
+
let z = this.#G(t, b, F, f), v = z.__staleWhileFetching !== void 0 && i;
|
|
689
|
+
return a && (a.fetch = A ? "stale" : "refresh", v && A && (a.returnedStale = true)), v ? z.__staleWhileFetching : z.__returned = z;
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
forceFetch(t, e = {}) {
|
|
693
|
+
let i = g.tracing.hasSubscribers, { status: s = C() ? {} : void 0 } = e;
|
|
694
|
+
e.status = s, s && e.context && (s.context = e.context);
|
|
695
|
+
let n = this.#K(t, e);
|
|
696
|
+
return s && i && (s.trace = true, g.tracing.tracePromise(() => n, s).catch(() => {
|
|
697
|
+
})), n;
|
|
698
|
+
}
|
|
699
|
+
async #K(t, e = {}) {
|
|
700
|
+
let i = await this.#q(t, e);
|
|
701
|
+
if (i === void 0) throw new Error("fetch() returned undefined");
|
|
702
|
+
return i;
|
|
703
|
+
}
|
|
704
|
+
memo(t, e = {}) {
|
|
705
|
+
let { status: i = g.metrics.hasSubscribers ? {} : void 0 } = e;
|
|
706
|
+
e.status = i, i && (i.op = "memo", i.key = t, e.context && (i.context = e.context), i.cache = this);
|
|
707
|
+
let s = this.#Q(t, e);
|
|
708
|
+
return i && (i.value = s), g.metrics.hasSubscribers && g.metrics.publish(i), s;
|
|
709
|
+
}
|
|
710
|
+
#Q(t, e = {}) {
|
|
711
|
+
let i = this.#j;
|
|
712
|
+
if (!i) throw new Error("no memoMethod provided to constructor");
|
|
713
|
+
let { context: s, status: n, forceRefresh: o, ...l } = e;
|
|
714
|
+
n && o && (n.forceRefresh = true);
|
|
715
|
+
let h = this.#L(t, l), r = o || h === void 0;
|
|
716
|
+
if (n && (n.memo = r ? "miss" : "hit", r || (n.value = h)), !r) return h;
|
|
717
|
+
let c = i(t, h, { options: l, context: s });
|
|
718
|
+
return n && (n.value = c), this.#O(t, c, l), c;
|
|
719
|
+
}
|
|
720
|
+
get(t, e = {}) {
|
|
721
|
+
let { status: i = g.metrics.hasSubscribers ? {} : void 0 } = e;
|
|
722
|
+
e.status = i, i && (i.op = "get", i.key = t, i.cache = this);
|
|
723
|
+
let s = this.#L(t, e);
|
|
724
|
+
return i && (s !== void 0 && (i.value = s), g.metrics.hasSubscribers && g.metrics.publish(i)), s;
|
|
725
|
+
}
|
|
726
|
+
#L(t, e = {}) {
|
|
727
|
+
let { allowStale: i = this.allowStale, updateAgeOnGet: s = this.updateAgeOnGet, noDeleteOnStaleGet: n = this.noDeleteOnStaleGet, status: o } = e, l = this.#s.get(t);
|
|
728
|
+
if (l === void 0) {
|
|
729
|
+
o && (o.get = "miss");
|
|
730
|
+
return;
|
|
731
|
+
}
|
|
732
|
+
let h = this.#t[l], r = this.#e(h);
|
|
733
|
+
return o && this.#E(o, l), this.#p(l) ? r ? (o && (o.get = "stale-fetching"), i && h.__staleWhileFetching !== void 0 ? (o && (o.returnedStale = true), h.__staleWhileFetching) : void 0) : (n || this.#v(t, "expire"), o && (o.get = "stale"), i ? (o && (o.returnedStale = true), h) : void 0) : (o && (o.get = r ? "fetching" : "hit"), this.#M(l), s && this.#D(l), r ? h.__staleWhileFetching : h);
|
|
734
|
+
}
|
|
735
|
+
#B(t, e) {
|
|
736
|
+
this.#u[e] = t, this.#l[t] = e;
|
|
737
|
+
}
|
|
738
|
+
#M(t) {
|
|
739
|
+
t !== this.#h && (t === this.#a ? this.#a = this.#l[t] : this.#B(this.#u[t], this.#l[t]), this.#B(this.#h, t), this.#h = t);
|
|
740
|
+
}
|
|
741
|
+
delete(t) {
|
|
742
|
+
return this.#v(t, "delete");
|
|
743
|
+
}
|
|
744
|
+
#v(t, e) {
|
|
745
|
+
g.metrics.hasSubscribers && g.metrics.publish({ op: "delete", delete: e, key: t, cache: this });
|
|
746
|
+
let i = false;
|
|
747
|
+
if (this.#n !== 0) {
|
|
748
|
+
let s = this.#s.get(t);
|
|
749
|
+
if (s !== void 0) if (this.#g?.[s] && (clearTimeout(this.#g[s]), this.#g[s] = void 0), i = true, this.#n === 1) this.#$(e);
|
|
750
|
+
else {
|
|
751
|
+
this.#C(s);
|
|
752
|
+
let n = this.#t[s];
|
|
753
|
+
if (this.#e(n) ? n.__abortController.abort(new Error("deleted")) : (this.#T || this.#f) && (this.#T && this.#m?.(n, t, e), this.#f && this.#r?.push([n, t, e])), this.#s.delete(t), this.#i[s] = void 0, this.#t[s] = void 0, s === this.#h) this.#h = this.#u[s];
|
|
754
|
+
else if (s === this.#a) this.#a = this.#l[s];
|
|
755
|
+
else {
|
|
756
|
+
let o = this.#u[s];
|
|
757
|
+
this.#l[o] = this.#l[s];
|
|
758
|
+
let l = this.#l[s];
|
|
759
|
+
this.#u[l] = this.#u[s];
|
|
760
|
+
}
|
|
761
|
+
this.#n--, this.#_.push(s);
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
if (this.#f && this.#r?.length) {
|
|
765
|
+
let s = this.#r, n;
|
|
766
|
+
for (; n = s?.shift(); ) this.#S?.(...n);
|
|
767
|
+
}
|
|
768
|
+
return i;
|
|
769
|
+
}
|
|
770
|
+
clear() {
|
|
771
|
+
return this.#$("delete");
|
|
772
|
+
}
|
|
773
|
+
#$(t) {
|
|
774
|
+
for (let e of this.#z({ allowStale: true })) {
|
|
775
|
+
let i = this.#t[e];
|
|
776
|
+
if (this.#e(i)) i.__abortController.abort(new Error("deleted"));
|
|
777
|
+
else {
|
|
778
|
+
let s = this.#i[e];
|
|
779
|
+
this.#T && this.#m?.(i, s, t), this.#f && this.#r?.push([i, s, t]);
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
if (this.#s.clear(), this.#t.fill(void 0), this.#i.fill(void 0), this.#d && this.#F) {
|
|
783
|
+
this.#d.fill(0), this.#F.fill(0);
|
|
784
|
+
for (let e of this.#g ?? []) e !== void 0 && clearTimeout(e);
|
|
785
|
+
this.#g?.fill(void 0);
|
|
786
|
+
}
|
|
787
|
+
if (this.#y && this.#y.fill(0), this.#a = 0, this.#h = 0, this.#_.length = 0, this.#b = 0, this.#n = 0, this.#f && this.#r) {
|
|
788
|
+
let e = this.#r, i;
|
|
789
|
+
for (; i = e?.shift(); ) this.#S?.(...i);
|
|
790
|
+
}
|
|
791
|
+
}
|
|
792
|
+
};
|
|
793
|
+
exports.LRUCache = M;
|
|
794
|
+
}
|
|
795
|
+
});
|
|
796
|
+
|
|
797
|
+
// node_modules/hosted-git-info/lib/hosts.js
|
|
798
|
+
var require_hosts = __commonJS({
|
|
799
|
+
"node_modules/hosted-git-info/lib/hosts.js"(exports, module) {
|
|
800
|
+
"use strict";
|
|
801
|
+
var maybeJoin = (...args) => args.every((arg) => arg) ? args.join("") : "";
|
|
802
|
+
var maybeEncode = (arg) => arg ? encodeURIComponent(arg) : "";
|
|
803
|
+
var formatHashFragment = (f) => f.toLowerCase().replace(/^\W+/g, "").replace(/(?<!\W)\W+$/, "").replace(/\//g, "").replace(/\W+/g, "-");
|
|
804
|
+
var defaults = {
|
|
805
|
+
sshtemplate: ({ domain, user, project, committish }) => `git@${domain}:${user}/${project}.git${maybeJoin("#", committish)}`,
|
|
806
|
+
sshurltemplate: ({ domain, user, project, committish }) => `git+ssh://git@${domain}/${user}/${project}.git${maybeJoin("#", committish)}`,
|
|
807
|
+
edittemplate: ({ domain, user, project, committish, editpath, path }) => `https://${domain}/${user}/${project}${maybeJoin("/", editpath, "/", maybeEncode(committish || "HEAD"), "/", path)}`,
|
|
808
|
+
browsetemplate: ({ domain, user, project, committish, treepath }) => `https://${domain}/${user}/${project}${maybeJoin("/", treepath, "/", maybeEncode(committish))}`,
|
|
809
|
+
browsetreetemplate: ({ domain, user, project, committish, treepath, path, fragment, hashformat }) => `https://${domain}/${user}/${project}/${treepath}/${maybeEncode(committish || "HEAD")}/${path}${maybeJoin("#", hashformat(fragment || ""))}`,
|
|
810
|
+
browseblobtemplate: ({ domain, user, project, committish, blobpath, path, fragment, hashformat }) => `https://${domain}/${user}/${project}/${blobpath}/${maybeEncode(committish || "HEAD")}/${path}${maybeJoin("#", hashformat(fragment || ""))}`,
|
|
811
|
+
docstemplate: ({ domain, user, project, treepath, committish }) => `https://${domain}/${user}/${project}${maybeJoin("/", treepath, "/", maybeEncode(committish))}#readme`,
|
|
812
|
+
httpstemplate: ({ auth, domain, user, project, committish }) => `git+https://${maybeJoin(auth, "@")}${domain}/${user}/${project}.git${maybeJoin("#", committish)}`,
|
|
813
|
+
filetemplate: ({ domain, user, project, committish, path }) => `https://${domain}/${user}/${project}/raw/${maybeEncode(committish || "HEAD")}/${path}`,
|
|
814
|
+
shortcuttemplate: ({ type, user, project, committish }) => `${type}:${user}/${project}${maybeJoin("#", committish)}`,
|
|
815
|
+
pathtemplate: ({ user, project, committish }) => `${user}/${project}${maybeJoin("#", committish)}`,
|
|
816
|
+
bugstemplate: ({ domain, user, project }) => `https://${domain}/${user}/${project}/issues`,
|
|
817
|
+
hashformat: formatHashFragment
|
|
818
|
+
};
|
|
819
|
+
var hosts = {};
|
|
820
|
+
hosts.github = {
|
|
821
|
+
// First two are insecure and generally shouldn't be used any more, but
|
|
822
|
+
// they are still supported.
|
|
823
|
+
protocols: ["git:", "http:", "git+ssh:", "git+https:", "ssh:", "https:"],
|
|
824
|
+
domain: "github.com",
|
|
825
|
+
treepath: "tree",
|
|
826
|
+
blobpath: "blob",
|
|
827
|
+
editpath: "edit",
|
|
828
|
+
filetemplate: ({ auth, user, project, committish, path }) => `https://${maybeJoin(auth, "@")}raw.githubusercontent.com/${user}/${project}/${maybeEncode(committish || "HEAD")}/${path}`,
|
|
829
|
+
gittemplate: ({ auth, domain, user, project, committish }) => `git://${maybeJoin(auth, "@")}${domain}/${user}/${project}.git${maybeJoin("#", committish)}`,
|
|
830
|
+
tarballtemplate: ({ domain, user, project, committish }) => `https://codeload.${domain}/${user}/${project}/tar.gz/${maybeEncode(committish || "HEAD")}`,
|
|
831
|
+
extract: (url) => {
|
|
832
|
+
let [, user, project, type, committish] = url.pathname.split("/", 5);
|
|
833
|
+
if (type && type !== "tree") {
|
|
834
|
+
return;
|
|
835
|
+
}
|
|
836
|
+
if (!type) {
|
|
837
|
+
committish = url.hash.slice(1);
|
|
838
|
+
}
|
|
839
|
+
if (project && project.endsWith(".git")) {
|
|
840
|
+
project = project.slice(0, -4);
|
|
841
|
+
}
|
|
842
|
+
if (!user || !project) {
|
|
843
|
+
return;
|
|
844
|
+
}
|
|
845
|
+
return { user, project, committish };
|
|
846
|
+
}
|
|
847
|
+
};
|
|
848
|
+
hosts.bitbucket = {
|
|
849
|
+
protocols: ["git+ssh:", "git+https:", "ssh:", "https:"],
|
|
850
|
+
domain: "bitbucket.org",
|
|
851
|
+
treepath: "src",
|
|
852
|
+
blobpath: "src",
|
|
853
|
+
editpath: "?mode=edit",
|
|
854
|
+
edittemplate: ({ domain, user, project, committish, treepath, path, editpath }) => `https://${domain}/${user}/${project}${maybeJoin("/", treepath, "/", maybeEncode(committish || "HEAD"), "/", path, editpath)}`,
|
|
855
|
+
tarballtemplate: ({ domain, user, project, committish }) => `https://${domain}/${user}/${project}/get/${maybeEncode(committish || "HEAD")}.tar.gz`,
|
|
856
|
+
extract: (url) => {
|
|
857
|
+
let [, user, project, aux] = url.pathname.split("/", 4);
|
|
858
|
+
if (["get"].includes(aux)) {
|
|
859
|
+
return;
|
|
860
|
+
}
|
|
861
|
+
if (project && project.endsWith(".git")) {
|
|
862
|
+
project = project.slice(0, -4);
|
|
863
|
+
}
|
|
864
|
+
if (!user || !project) {
|
|
865
|
+
return;
|
|
866
|
+
}
|
|
867
|
+
return { user, project, committish: url.hash.slice(1) };
|
|
868
|
+
}
|
|
869
|
+
};
|
|
870
|
+
hosts.gitlab = {
|
|
871
|
+
protocols: ["git+ssh:", "git+https:", "ssh:", "https:"],
|
|
872
|
+
domain: "gitlab.com",
|
|
873
|
+
treepath: "tree",
|
|
874
|
+
blobpath: "tree",
|
|
875
|
+
editpath: "-/edit",
|
|
876
|
+
tarballtemplate: ({ domain, user, project, committish }) => `https://${domain}/api/v4/projects/${maybeEncode(user + "/" + project)}/repository/archive.tar.gz?sha=${maybeEncode(committish || "HEAD")}`,
|
|
877
|
+
extract: (url) => {
|
|
878
|
+
const path = url.pathname.slice(1);
|
|
879
|
+
if (path.includes("/-/") || path.includes("/archive.tar.gz")) {
|
|
880
|
+
return;
|
|
881
|
+
}
|
|
882
|
+
const segments = path.split("/");
|
|
883
|
+
let project = segments.pop();
|
|
884
|
+
if (project.endsWith(".git")) {
|
|
885
|
+
project = project.slice(0, -4);
|
|
886
|
+
}
|
|
887
|
+
const user = segments.join("/");
|
|
888
|
+
if (!user || !project) {
|
|
889
|
+
return;
|
|
890
|
+
}
|
|
891
|
+
return { user, project, committish: url.hash.slice(1) };
|
|
892
|
+
}
|
|
893
|
+
};
|
|
894
|
+
hosts.gist = {
|
|
895
|
+
protocols: ["git:", "git+ssh:", "git+https:", "ssh:", "https:"],
|
|
896
|
+
domain: "gist.github.com",
|
|
897
|
+
editpath: "edit",
|
|
898
|
+
sshtemplate: ({ domain, project, committish }) => `git@${domain}:${project}.git${maybeJoin("#", committish)}`,
|
|
899
|
+
sshurltemplate: ({ domain, project, committish }) => `git+ssh://git@${domain}/${project}.git${maybeJoin("#", committish)}`,
|
|
900
|
+
edittemplate: ({ domain, user, project, committish, editpath }) => `https://${domain}/${user}/${project}${maybeJoin("/", maybeEncode(committish))}/${editpath}`,
|
|
901
|
+
browsetemplate: ({ domain, project, committish }) => `https://${domain}/${project}${maybeJoin("/", maybeEncode(committish))}`,
|
|
902
|
+
browsetreetemplate: ({ domain, project, committish, path, hashformat }) => `https://${domain}/${project}${maybeJoin("/", maybeEncode(committish))}${maybeJoin("#", hashformat(path))}`,
|
|
903
|
+
browseblobtemplate: ({ domain, project, committish, path, hashformat }) => `https://${domain}/${project}${maybeJoin("/", maybeEncode(committish))}${maybeJoin("#", hashformat(path))}`,
|
|
904
|
+
docstemplate: ({ domain, project, committish }) => `https://${domain}/${project}${maybeJoin("/", maybeEncode(committish))}`,
|
|
905
|
+
httpstemplate: ({ domain, project, committish }) => `git+https://${domain}/${project}.git${maybeJoin("#", committish)}`,
|
|
906
|
+
filetemplate: ({ user, project, committish, path }) => `https://gist.githubusercontent.com/${user}/${project}/raw${maybeJoin("/", maybeEncode(committish))}/${path}`,
|
|
907
|
+
shortcuttemplate: ({ type, project, committish }) => `${type}:${project}${maybeJoin("#", committish)}`,
|
|
908
|
+
pathtemplate: ({ project, committish }) => `${project}${maybeJoin("#", committish)}`,
|
|
909
|
+
bugstemplate: ({ domain, project }) => `https://${domain}/${project}`,
|
|
910
|
+
gittemplate: ({ domain, project, committish }) => `git://${domain}/${project}.git${maybeJoin("#", committish)}`,
|
|
911
|
+
tarballtemplate: ({ project, committish }) => `https://codeload.github.com/gist/${project}/tar.gz/${maybeEncode(committish || "HEAD")}`,
|
|
912
|
+
extract: (url) => {
|
|
913
|
+
let [, user, project, aux] = url.pathname.split("/", 4);
|
|
914
|
+
if (aux === "raw") {
|
|
915
|
+
return;
|
|
916
|
+
}
|
|
917
|
+
if (!project) {
|
|
918
|
+
if (!user) {
|
|
919
|
+
return;
|
|
920
|
+
}
|
|
921
|
+
project = user;
|
|
922
|
+
user = null;
|
|
923
|
+
}
|
|
924
|
+
if (project.endsWith(".git")) {
|
|
925
|
+
project = project.slice(0, -4);
|
|
926
|
+
}
|
|
927
|
+
return { user, project, committish: url.hash.slice(1) };
|
|
928
|
+
},
|
|
929
|
+
hashformat: function(fragment) {
|
|
930
|
+
return fragment && "file-" + formatHashFragment(fragment);
|
|
931
|
+
}
|
|
932
|
+
};
|
|
933
|
+
hosts.sourcehut = {
|
|
934
|
+
protocols: ["git+ssh:", "https:"],
|
|
935
|
+
domain: "git.sr.ht",
|
|
936
|
+
treepath: "tree",
|
|
937
|
+
blobpath: "tree",
|
|
938
|
+
filetemplate: ({ domain, user, project, committish, path }) => `https://${domain}/${user}/${project}/blob/${maybeEncode(committish) || "HEAD"}/${path}`,
|
|
939
|
+
httpstemplate: ({ domain, user, project, committish }) => `https://${domain}/${user}/${project}${maybeJoin("#", committish)}`,
|
|
940
|
+
tarballtemplate: ({ domain, user, project, committish }) => `https://${domain}/${user}/${project}/archive/${maybeEncode(committish) || "HEAD"}.tar.gz`,
|
|
941
|
+
bugstemplate: () => null,
|
|
942
|
+
extract: (url) => {
|
|
943
|
+
let [, user, project, aux] = url.pathname.split("/", 4);
|
|
944
|
+
if (["archive"].includes(aux)) {
|
|
945
|
+
return;
|
|
946
|
+
}
|
|
947
|
+
if (project && project.endsWith(".git")) {
|
|
948
|
+
project = project.slice(0, -4);
|
|
949
|
+
}
|
|
950
|
+
if (!user || !project) {
|
|
951
|
+
return;
|
|
952
|
+
}
|
|
953
|
+
return { user, project, committish: url.hash.slice(1) };
|
|
954
|
+
}
|
|
955
|
+
};
|
|
956
|
+
for (const [name, host] of Object.entries(hosts)) {
|
|
957
|
+
hosts[name] = Object.assign({}, defaults, host);
|
|
958
|
+
}
|
|
959
|
+
module.exports = hosts;
|
|
960
|
+
}
|
|
961
|
+
});
|
|
962
|
+
|
|
963
|
+
// node_modules/hosted-git-info/lib/parse-url.js
|
|
964
|
+
var require_parse_url = __commonJS({
|
|
965
|
+
"node_modules/hosted-git-info/lib/parse-url.js"(exports, module) {
|
|
966
|
+
var url = __require("url");
|
|
967
|
+
var lastIndexOfBefore = (str, char, beforeChar) => {
|
|
968
|
+
const startPosition = str.indexOf(beforeChar);
|
|
969
|
+
return str.lastIndexOf(char, startPosition > -1 ? startPosition : Infinity);
|
|
970
|
+
};
|
|
971
|
+
var safeUrl = (u) => {
|
|
972
|
+
try {
|
|
973
|
+
return new url.URL(u);
|
|
974
|
+
} catch {
|
|
975
|
+
}
|
|
976
|
+
};
|
|
977
|
+
var correctProtocol = (arg, protocols) => {
|
|
978
|
+
const firstColon = arg.indexOf(":");
|
|
979
|
+
const proto = arg.slice(0, firstColon + 1);
|
|
980
|
+
if (Object.prototype.hasOwnProperty.call(protocols, proto)) {
|
|
981
|
+
return arg;
|
|
982
|
+
}
|
|
983
|
+
if (arg.substr(firstColon, 3) === "://") {
|
|
984
|
+
return arg;
|
|
985
|
+
}
|
|
986
|
+
const firstAt = arg.indexOf("@");
|
|
987
|
+
if (firstAt > -1) {
|
|
988
|
+
if (firstAt > firstColon) {
|
|
989
|
+
return `git+ssh://${arg}`;
|
|
990
|
+
} else {
|
|
991
|
+
return arg;
|
|
992
|
+
}
|
|
993
|
+
}
|
|
994
|
+
return `${arg.slice(0, firstColon + 1)}//${arg.slice(firstColon + 1)}`;
|
|
995
|
+
};
|
|
996
|
+
var correctUrl = (giturl) => {
|
|
997
|
+
const firstAt = lastIndexOfBefore(giturl, "@", "#");
|
|
998
|
+
const lastColonBeforeHash = lastIndexOfBefore(giturl, ":", "#");
|
|
999
|
+
if (lastColonBeforeHash > firstAt) {
|
|
1000
|
+
giturl = giturl.slice(0, lastColonBeforeHash) + "/" + giturl.slice(lastColonBeforeHash + 1);
|
|
1001
|
+
}
|
|
1002
|
+
if (lastIndexOfBefore(giturl, ":", "#") === -1 && giturl.indexOf("//") === -1) {
|
|
1003
|
+
giturl = `git+ssh://${giturl}`;
|
|
1004
|
+
}
|
|
1005
|
+
return giturl;
|
|
1006
|
+
};
|
|
1007
|
+
module.exports = (giturl, protocols) => {
|
|
1008
|
+
const withProtocol = protocols ? correctProtocol(giturl, protocols) : giturl;
|
|
1009
|
+
return safeUrl(withProtocol) || safeUrl(correctUrl(withProtocol));
|
|
1010
|
+
};
|
|
1011
|
+
}
|
|
1012
|
+
});
|
|
1013
|
+
|
|
1014
|
+
// node_modules/hosted-git-info/lib/from-url.js
|
|
1015
|
+
var require_from_url = __commonJS({
|
|
1016
|
+
"node_modules/hosted-git-info/lib/from-url.js"(exports, module) {
|
|
1017
|
+
"use strict";
|
|
1018
|
+
var parseUrl = require_parse_url();
|
|
1019
|
+
var isGitHubShorthand = (arg) => {
|
|
1020
|
+
const firstHash = arg.indexOf("#");
|
|
1021
|
+
const firstSlash = arg.indexOf("/");
|
|
1022
|
+
const secondSlash = arg.indexOf("/", firstSlash + 1);
|
|
1023
|
+
const firstColon = arg.indexOf(":");
|
|
1024
|
+
const firstSpace = /\s/.exec(arg);
|
|
1025
|
+
const firstAt = arg.indexOf("@");
|
|
1026
|
+
const spaceOnlyAfterHash = !firstSpace || firstHash > -1 && firstSpace.index > firstHash;
|
|
1027
|
+
const atOnlyAfterHash = firstAt === -1 || firstHash > -1 && firstAt > firstHash;
|
|
1028
|
+
const colonOnlyAfterHash = firstColon === -1 || firstHash > -1 && firstColon > firstHash;
|
|
1029
|
+
const secondSlashOnlyAfterHash = secondSlash === -1 || firstHash > -1 && secondSlash > firstHash;
|
|
1030
|
+
const hasSlash = firstSlash > 0;
|
|
1031
|
+
const doesNotEndWithSlash = firstHash > -1 ? arg[firstHash - 1] !== "/" : !arg.endsWith("/");
|
|
1032
|
+
const doesNotStartWithDot = !arg.startsWith(".");
|
|
1033
|
+
return spaceOnlyAfterHash && hasSlash && doesNotEndWithSlash && doesNotStartWithDot && atOnlyAfterHash && colonOnlyAfterHash && secondSlashOnlyAfterHash;
|
|
1034
|
+
};
|
|
1035
|
+
module.exports = (giturl, opts, { gitHosts, protocols }) => {
|
|
1036
|
+
if (!giturl) {
|
|
1037
|
+
return;
|
|
1038
|
+
}
|
|
1039
|
+
const correctedUrl = isGitHubShorthand(giturl) ? `github:${giturl}` : giturl;
|
|
1040
|
+
const parsed = parseUrl(correctedUrl, protocols);
|
|
1041
|
+
if (!parsed) {
|
|
1042
|
+
return;
|
|
1043
|
+
}
|
|
1044
|
+
const gitHostShortcut = gitHosts.byShortcut[parsed.protocol];
|
|
1045
|
+
const gitHostDomain = gitHosts.byDomain[parsed.hostname.startsWith("www.") ? parsed.hostname.slice(4) : parsed.hostname];
|
|
1046
|
+
const gitHostName = gitHostShortcut || gitHostDomain;
|
|
1047
|
+
if (!gitHostName) {
|
|
1048
|
+
return;
|
|
1049
|
+
}
|
|
1050
|
+
const gitHostInfo = gitHosts[gitHostShortcut || gitHostDomain];
|
|
1051
|
+
let auth = null;
|
|
1052
|
+
if (protocols[parsed.protocol]?.auth && (parsed.username || parsed.password)) {
|
|
1053
|
+
auth = `${parsed.username}${parsed.password ? ":" + parsed.password : ""}`;
|
|
1054
|
+
}
|
|
1055
|
+
let committish = null;
|
|
1056
|
+
let user = null;
|
|
1057
|
+
let project = null;
|
|
1058
|
+
let defaultRepresentation = null;
|
|
1059
|
+
try {
|
|
1060
|
+
if (gitHostShortcut) {
|
|
1061
|
+
let pathname = parsed.pathname.startsWith("/") ? parsed.pathname.slice(1) : parsed.pathname;
|
|
1062
|
+
const firstAt = pathname.indexOf("@");
|
|
1063
|
+
if (firstAt > -1) {
|
|
1064
|
+
pathname = pathname.slice(firstAt + 1);
|
|
1065
|
+
}
|
|
1066
|
+
const lastSlash = pathname.lastIndexOf("/");
|
|
1067
|
+
if (lastSlash > -1) {
|
|
1068
|
+
user = decodeURIComponent(pathname.slice(0, lastSlash));
|
|
1069
|
+
if (!user) {
|
|
1070
|
+
user = null;
|
|
1071
|
+
}
|
|
1072
|
+
project = decodeURIComponent(pathname.slice(lastSlash + 1));
|
|
1073
|
+
} else {
|
|
1074
|
+
project = decodeURIComponent(pathname);
|
|
1075
|
+
}
|
|
1076
|
+
if (project.endsWith(".git")) {
|
|
1077
|
+
project = project.slice(0, -4);
|
|
1078
|
+
}
|
|
1079
|
+
if (parsed.hash) {
|
|
1080
|
+
committish = decodeURIComponent(parsed.hash.slice(1));
|
|
1081
|
+
}
|
|
1082
|
+
defaultRepresentation = "shortcut";
|
|
1083
|
+
} else {
|
|
1084
|
+
if (!gitHostInfo.protocols.includes(parsed.protocol)) {
|
|
1085
|
+
return;
|
|
1086
|
+
}
|
|
1087
|
+
const segments = gitHostInfo.extract(parsed);
|
|
1088
|
+
if (!segments) {
|
|
1089
|
+
return;
|
|
1090
|
+
}
|
|
1091
|
+
user = segments.user && decodeURIComponent(segments.user);
|
|
1092
|
+
project = decodeURIComponent(segments.project);
|
|
1093
|
+
committish = decodeURIComponent(segments.committish);
|
|
1094
|
+
defaultRepresentation = protocols[parsed.protocol]?.name || parsed.protocol.slice(0, -1);
|
|
1095
|
+
}
|
|
1096
|
+
} catch (err) {
|
|
1097
|
+
if (err instanceof URIError) {
|
|
1098
|
+
return;
|
|
1099
|
+
} else {
|
|
1100
|
+
throw err;
|
|
1101
|
+
}
|
|
1102
|
+
}
|
|
1103
|
+
return [gitHostName, user, auth, project, committish, defaultRepresentation, opts];
|
|
1104
|
+
};
|
|
1105
|
+
}
|
|
1106
|
+
});
|
|
1107
|
+
|
|
1108
|
+
// node_modules/hosted-git-info/lib/index.js
|
|
1109
|
+
var require_lib = __commonJS({
|
|
1110
|
+
"node_modules/hosted-git-info/lib/index.js"(exports, module) {
|
|
1111
|
+
"use strict";
|
|
1112
|
+
var { LRUCache } = require_index_min();
|
|
1113
|
+
var hosts = require_hosts();
|
|
1114
|
+
var fromUrl = require_from_url();
|
|
1115
|
+
var parseUrl = require_parse_url();
|
|
1116
|
+
var cache = new LRUCache({ max: 1e3 });
|
|
1117
|
+
function unknownHostedUrl(url) {
|
|
1118
|
+
try {
|
|
1119
|
+
const {
|
|
1120
|
+
protocol,
|
|
1121
|
+
hostname,
|
|
1122
|
+
pathname
|
|
1123
|
+
} = new URL(url);
|
|
1124
|
+
if (!hostname) {
|
|
1125
|
+
return null;
|
|
1126
|
+
}
|
|
1127
|
+
const proto = /(?:git\+)http:$/.test(protocol) ? "http:" : "https:";
|
|
1128
|
+
const path = pathname.replace(/\.git$/, "");
|
|
1129
|
+
return `${proto}//${hostname}${path}`;
|
|
1130
|
+
} catch {
|
|
1131
|
+
return null;
|
|
1132
|
+
}
|
|
1133
|
+
}
|
|
1134
|
+
var GitHost = class _GitHost {
|
|
1135
|
+
constructor(type, user, auth, project, committish, defaultRepresentation, opts = {}) {
|
|
1136
|
+
Object.assign(this, _GitHost.#gitHosts[type], {
|
|
1137
|
+
type,
|
|
1138
|
+
user,
|
|
1139
|
+
auth,
|
|
1140
|
+
project,
|
|
1141
|
+
committish,
|
|
1142
|
+
default: defaultRepresentation,
|
|
1143
|
+
opts
|
|
1144
|
+
});
|
|
1145
|
+
}
|
|
1146
|
+
static #gitHosts = { byShortcut: {}, byDomain: {} };
|
|
1147
|
+
static #protocols = {
|
|
1148
|
+
"git+ssh:": { name: "sshurl" },
|
|
1149
|
+
"ssh:": { name: "sshurl" },
|
|
1150
|
+
"git+https:": { name: "https", auth: true },
|
|
1151
|
+
"git:": { auth: true },
|
|
1152
|
+
"http:": { auth: true },
|
|
1153
|
+
"https:": { auth: true },
|
|
1154
|
+
"git+http:": { auth: true }
|
|
1155
|
+
};
|
|
1156
|
+
static addHost(name, host) {
|
|
1157
|
+
_GitHost.#gitHosts[name] = host;
|
|
1158
|
+
_GitHost.#gitHosts.byDomain[host.domain] = name;
|
|
1159
|
+
_GitHost.#gitHosts.byShortcut[`${name}:`] = name;
|
|
1160
|
+
_GitHost.#protocols[`${name}:`] = { name };
|
|
1161
|
+
}
|
|
1162
|
+
static fromUrl(giturl, opts) {
|
|
1163
|
+
if (typeof giturl !== "string") {
|
|
1164
|
+
return;
|
|
1165
|
+
}
|
|
1166
|
+
const key = giturl + JSON.stringify(opts || {});
|
|
1167
|
+
if (!cache.has(key)) {
|
|
1168
|
+
const hostArgs = fromUrl(giturl, opts, {
|
|
1169
|
+
gitHosts: _GitHost.#gitHosts,
|
|
1170
|
+
protocols: _GitHost.#protocols
|
|
1171
|
+
});
|
|
1172
|
+
cache.set(key, hostArgs ? new _GitHost(...hostArgs) : void 0);
|
|
1173
|
+
}
|
|
1174
|
+
return cache.get(key);
|
|
1175
|
+
}
|
|
1176
|
+
static fromManifest(manifest, opts = {}) {
|
|
1177
|
+
if (!manifest || typeof manifest !== "object") {
|
|
1178
|
+
return;
|
|
1179
|
+
}
|
|
1180
|
+
const r = manifest.repository;
|
|
1181
|
+
const rurl = r && (typeof r === "string" ? r : typeof r === "object" && typeof r.url === "string" ? r.url : null);
|
|
1182
|
+
if (!rurl) {
|
|
1183
|
+
throw new Error("no repository");
|
|
1184
|
+
}
|
|
1185
|
+
const info = rurl && _GitHost.fromUrl(rurl.replace(/^git\+/, ""), opts) || null;
|
|
1186
|
+
if (info) {
|
|
1187
|
+
return info;
|
|
1188
|
+
}
|
|
1189
|
+
const unk = unknownHostedUrl(rurl);
|
|
1190
|
+
return _GitHost.fromUrl(unk, opts) || unk;
|
|
1191
|
+
}
|
|
1192
|
+
static parseUrl(url) {
|
|
1193
|
+
return parseUrl(url);
|
|
1194
|
+
}
|
|
1195
|
+
#fill(template, opts) {
|
|
1196
|
+
if (typeof template !== "function") {
|
|
1197
|
+
return null;
|
|
1198
|
+
}
|
|
1199
|
+
const options = { ...this, ...this.opts, ...opts };
|
|
1200
|
+
if (!options.path) {
|
|
1201
|
+
options.path = "";
|
|
1202
|
+
}
|
|
1203
|
+
if (options.path.startsWith("/")) {
|
|
1204
|
+
options.path = options.path.slice(1);
|
|
1205
|
+
}
|
|
1206
|
+
if (options.noCommittish) {
|
|
1207
|
+
options.committish = null;
|
|
1208
|
+
}
|
|
1209
|
+
const result = template(options);
|
|
1210
|
+
return options.noGitPlus && result.startsWith("git+") ? result.slice(4) : result;
|
|
1211
|
+
}
|
|
1212
|
+
hash() {
|
|
1213
|
+
return this.committish ? `#${this.committish}` : "";
|
|
1214
|
+
}
|
|
1215
|
+
ssh(opts) {
|
|
1216
|
+
return this.#fill(this.sshtemplate, opts);
|
|
1217
|
+
}
|
|
1218
|
+
sshurl(opts) {
|
|
1219
|
+
return this.#fill(this.sshurltemplate, opts);
|
|
1220
|
+
}
|
|
1221
|
+
browse(path, ...args) {
|
|
1222
|
+
if (typeof path !== "string") {
|
|
1223
|
+
return this.#fill(this.browsetemplate, path);
|
|
1224
|
+
}
|
|
1225
|
+
if (typeof args[0] !== "string") {
|
|
1226
|
+
return this.#fill(this.browsetreetemplate, { ...args[0], path });
|
|
1227
|
+
}
|
|
1228
|
+
return this.#fill(this.browsetreetemplate, { ...args[1], fragment: args[0], path });
|
|
1229
|
+
}
|
|
1230
|
+
// If the path is known to be a file, then browseFile should be used. For some hosts
|
|
1231
|
+
// the url is the same as browse, but for others like GitHub a file can use both `/tree/`
|
|
1232
|
+
// and `/blob/` in the path. When using a default committish of `HEAD` then the `/tree/`
|
|
1233
|
+
// path will redirect to a specific commit. Using the `/blob/` path avoids this and
|
|
1234
|
+
// does not redirect to a different commit.
|
|
1235
|
+
browseFile(path, ...args) {
|
|
1236
|
+
if (typeof args[0] !== "string") {
|
|
1237
|
+
return this.#fill(this.browseblobtemplate, { ...args[0], path });
|
|
1238
|
+
}
|
|
1239
|
+
return this.#fill(this.browseblobtemplate, { ...args[1], fragment: args[0], path });
|
|
1240
|
+
}
|
|
1241
|
+
docs(opts) {
|
|
1242
|
+
return this.#fill(this.docstemplate, opts);
|
|
1243
|
+
}
|
|
1244
|
+
bugs(opts) {
|
|
1245
|
+
return this.#fill(this.bugstemplate, opts);
|
|
1246
|
+
}
|
|
1247
|
+
https(opts) {
|
|
1248
|
+
return this.#fill(this.httpstemplate, opts);
|
|
1249
|
+
}
|
|
1250
|
+
git(opts) {
|
|
1251
|
+
return this.#fill(this.gittemplate, opts);
|
|
1252
|
+
}
|
|
1253
|
+
shortcut(opts) {
|
|
1254
|
+
return this.#fill(this.shortcuttemplate, opts);
|
|
1255
|
+
}
|
|
1256
|
+
path(opts) {
|
|
1257
|
+
return this.#fill(this.pathtemplate, opts);
|
|
1258
|
+
}
|
|
1259
|
+
tarball(opts) {
|
|
1260
|
+
return this.#fill(this.tarballtemplate, { ...opts, noCommittish: false });
|
|
1261
|
+
}
|
|
1262
|
+
file(path, opts) {
|
|
1263
|
+
return this.#fill(this.filetemplate, { ...opts, path });
|
|
1264
|
+
}
|
|
1265
|
+
edit(path, opts) {
|
|
1266
|
+
return this.#fill(this.edittemplate, { ...opts, path });
|
|
1267
|
+
}
|
|
1268
|
+
getDefaultRepresentation() {
|
|
1269
|
+
return this.default;
|
|
1270
|
+
}
|
|
1271
|
+
toString(opts) {
|
|
1272
|
+
if (this.default && typeof this[this.default] === "function") {
|
|
1273
|
+
return this[this.default](opts);
|
|
1274
|
+
}
|
|
1275
|
+
return this.sshurl(opts);
|
|
1276
|
+
}
|
|
1277
|
+
};
|
|
1278
|
+
for (const [name, host] of Object.entries(hosts)) {
|
|
1279
|
+
GitHost.addHost(name, host);
|
|
1280
|
+
}
|
|
1281
|
+
module.exports = GitHost;
|
|
1282
|
+
}
|
|
1283
|
+
});
|
|
1284
|
+
|
|
190
1285
|
// node_modules/semver/internal/constants.js
|
|
191
1286
|
var require_constants = __commonJS({
|
|
192
1287
|
"node_modules/semver/internal/constants.js"(exports, module) {
|
|
@@ -2181,45 +3276,703 @@ var require_semver2 = __commonJS({
|
|
|
2181
3276
|
}
|
|
2182
3277
|
});
|
|
2183
3278
|
|
|
2184
|
-
//
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
var import_semver = __toESM(require_semver2(), 1);
|
|
2191
|
-
import {
|
|
2192
|
-
cpSync,
|
|
2193
|
-
existsSync,
|
|
2194
|
-
mkdirSync,
|
|
2195
|
-
mkdtempSync,
|
|
2196
|
-
readFileSync as readFileSync2,
|
|
2197
|
-
rmSync,
|
|
2198
|
-
statSync,
|
|
2199
|
-
symlinkSync,
|
|
2200
|
-
writeFileSync
|
|
2201
|
-
} from "node:fs";
|
|
2202
|
-
import { tmpdir } from "node:os";
|
|
2203
|
-
import { dirname as dirname2, join as join3, relative as relative2 } from "node:path";
|
|
3279
|
+
// node_modules/validate-npm-package-name/lib/builtin-modules.json
|
|
3280
|
+
var require_builtin_modules = __commonJS({
|
|
3281
|
+
"node_modules/validate-npm-package-name/lib/builtin-modules.json"(exports, module) {
|
|
3282
|
+
module.exports = ["_http_agent", "_http_client", "_http_common", "_http_incoming", "_http_outgoing", "_http_server", "_stream_duplex", "_stream_passthrough", "_stream_readable", "_stream_transform", "_stream_wrap", "_stream_writable", "_tls_common", "_tls_wrap", "assert", "assert/strict", "async_hooks", "buffer", "child_process", "cluster", "console", "constants", "crypto", "dgram", "diagnostics_channel", "dns", "dns/promises", "domain", "events", "fs", "fs/promises", "http", "http2", "https", "inspector", "inspector/promises", "module", "net", "os", "path", "path/posix", "path/win32", "perf_hooks", "process", "punycode", "querystring", "readline", "readline/promises", "repl", "stream", "stream/consumers", "stream/promises", "stream/web", "string_decoder", "sys", "timers", "timers/promises", "tls", "trace_events", "tty", "url", "util", "util/types", "v8", "vm", "wasi", "worker_threads", "zlib", "node:sea", "node:sqlite", "node:test", "node:test/reporters"];
|
|
3283
|
+
}
|
|
3284
|
+
});
|
|
2204
3285
|
|
|
2205
|
-
//
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
3286
|
+
// node_modules/validate-npm-package-name/lib/index.js
|
|
3287
|
+
var require_lib2 = __commonJS({
|
|
3288
|
+
"node_modules/validate-npm-package-name/lib/index.js"(exports, module) {
|
|
3289
|
+
"use strict";
|
|
3290
|
+
var builtins = require_builtin_modules();
|
|
3291
|
+
var scopedPackagePattern = new RegExp("^(?:@([^/]+?)[/])?([^/]+?)$");
|
|
3292
|
+
var exclusionList = [
|
|
3293
|
+
"node_modules",
|
|
3294
|
+
"favicon.ico"
|
|
3295
|
+
];
|
|
3296
|
+
function validate(name) {
|
|
3297
|
+
var warnings = [];
|
|
3298
|
+
var errors = [];
|
|
3299
|
+
if (name === null) {
|
|
3300
|
+
errors.push("name cannot be null");
|
|
3301
|
+
return done(warnings, errors);
|
|
2217
3302
|
}
|
|
2218
|
-
if (
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
3303
|
+
if (name === void 0) {
|
|
3304
|
+
errors.push("name cannot be undefined");
|
|
3305
|
+
return done(warnings, errors);
|
|
3306
|
+
}
|
|
3307
|
+
if (typeof name !== "string") {
|
|
3308
|
+
errors.push("name must be a string");
|
|
3309
|
+
return done(warnings, errors);
|
|
3310
|
+
}
|
|
3311
|
+
if (!name.length) {
|
|
3312
|
+
errors.push("name length must be greater than zero");
|
|
3313
|
+
}
|
|
3314
|
+
if (name.startsWith(".")) {
|
|
3315
|
+
errors.push("name cannot start with a period");
|
|
3316
|
+
}
|
|
3317
|
+
if (name.startsWith("-")) {
|
|
3318
|
+
errors.push("name cannot start with a hyphen");
|
|
3319
|
+
}
|
|
3320
|
+
if (name.match(/^_/)) {
|
|
3321
|
+
errors.push("name cannot start with an underscore");
|
|
3322
|
+
}
|
|
3323
|
+
if (name.trim() !== name) {
|
|
3324
|
+
errors.push("name cannot contain leading or trailing spaces");
|
|
3325
|
+
}
|
|
3326
|
+
exclusionList.forEach(function(excludedName) {
|
|
3327
|
+
if (name.toLowerCase() === excludedName) {
|
|
3328
|
+
errors.push(excludedName + " is not a valid package name");
|
|
3329
|
+
}
|
|
3330
|
+
});
|
|
3331
|
+
if (builtins.includes(name.toLowerCase())) {
|
|
3332
|
+
warnings.push(name + " is a core module name");
|
|
3333
|
+
}
|
|
3334
|
+
if (name.length > 214) {
|
|
3335
|
+
warnings.push("name can no longer contain more than 214 characters");
|
|
3336
|
+
}
|
|
3337
|
+
if (name.toLowerCase() !== name) {
|
|
3338
|
+
warnings.push("name can no longer contain capital letters");
|
|
3339
|
+
}
|
|
3340
|
+
if (/[~'!()*]/.test(name.split("/").slice(-1)[0])) {
|
|
3341
|
+
warnings.push(`name can no longer contain special characters ("~'!()*")`);
|
|
3342
|
+
}
|
|
3343
|
+
if (encodeURIComponent(name) !== name) {
|
|
3344
|
+
var nameMatch = name.match(scopedPackagePattern);
|
|
3345
|
+
if (nameMatch) {
|
|
3346
|
+
var user = nameMatch[1];
|
|
3347
|
+
var pkg = nameMatch[2];
|
|
3348
|
+
if (pkg.startsWith(".")) {
|
|
3349
|
+
errors.push("name cannot start with a period");
|
|
3350
|
+
}
|
|
3351
|
+
if (encodeURIComponent(user) === user && encodeURIComponent(pkg) === pkg) {
|
|
3352
|
+
return done(warnings, errors);
|
|
3353
|
+
}
|
|
3354
|
+
}
|
|
3355
|
+
errors.push("name can only contain URL-friendly characters");
|
|
3356
|
+
}
|
|
3357
|
+
return done(warnings, errors);
|
|
3358
|
+
}
|
|
3359
|
+
var done = function(warnings, errors) {
|
|
3360
|
+
var result = {
|
|
3361
|
+
validForNewPackages: errors.length === 0 && warnings.length === 0,
|
|
3362
|
+
validForOldPackages: errors.length === 0,
|
|
3363
|
+
warnings,
|
|
3364
|
+
errors
|
|
3365
|
+
};
|
|
3366
|
+
if (!result.warnings.length) {
|
|
3367
|
+
delete result.warnings;
|
|
3368
|
+
}
|
|
3369
|
+
if (!result.errors.length) {
|
|
3370
|
+
delete result.errors;
|
|
3371
|
+
}
|
|
3372
|
+
return result;
|
|
3373
|
+
};
|
|
3374
|
+
module.exports = validate;
|
|
3375
|
+
}
|
|
3376
|
+
});
|
|
3377
|
+
|
|
3378
|
+
// node_modules/proc-log/lib/index.js
|
|
3379
|
+
var require_lib3 = __commonJS({
|
|
3380
|
+
"node_modules/proc-log/lib/index.js"(exports, module) {
|
|
3381
|
+
var META = /* @__PURE__ */ Symbol("proc-log.meta");
|
|
3382
|
+
module.exports = {
|
|
3383
|
+
META,
|
|
3384
|
+
output: {
|
|
3385
|
+
LEVELS: [
|
|
3386
|
+
"standard",
|
|
3387
|
+
"error",
|
|
3388
|
+
"buffer",
|
|
3389
|
+
"flush"
|
|
3390
|
+
],
|
|
3391
|
+
KEYS: {
|
|
3392
|
+
standard: "standard",
|
|
3393
|
+
error: "error",
|
|
3394
|
+
buffer: "buffer",
|
|
3395
|
+
flush: "flush"
|
|
3396
|
+
},
|
|
3397
|
+
standard: function(...args) {
|
|
3398
|
+
return process.emit("output", "standard", ...args);
|
|
3399
|
+
},
|
|
3400
|
+
error: function(...args) {
|
|
3401
|
+
return process.emit("output", "error", ...args);
|
|
3402
|
+
},
|
|
3403
|
+
buffer: function(...args) {
|
|
3404
|
+
return process.emit("output", "buffer", ...args);
|
|
3405
|
+
},
|
|
3406
|
+
flush: function(...args) {
|
|
3407
|
+
return process.emit("output", "flush", ...args);
|
|
3408
|
+
}
|
|
3409
|
+
},
|
|
3410
|
+
log: {
|
|
3411
|
+
LEVELS: [
|
|
3412
|
+
"notice",
|
|
3413
|
+
"error",
|
|
3414
|
+
"warn",
|
|
3415
|
+
"info",
|
|
3416
|
+
"verbose",
|
|
3417
|
+
"http",
|
|
3418
|
+
"silly",
|
|
3419
|
+
"timing",
|
|
3420
|
+
"pause",
|
|
3421
|
+
"resume"
|
|
3422
|
+
],
|
|
3423
|
+
KEYS: {
|
|
3424
|
+
notice: "notice",
|
|
3425
|
+
error: "error",
|
|
3426
|
+
warn: "warn",
|
|
3427
|
+
info: "info",
|
|
3428
|
+
verbose: "verbose",
|
|
3429
|
+
http: "http",
|
|
3430
|
+
silly: "silly",
|
|
3431
|
+
timing: "timing",
|
|
3432
|
+
pause: "pause",
|
|
3433
|
+
resume: "resume"
|
|
3434
|
+
},
|
|
3435
|
+
error: function(...args) {
|
|
3436
|
+
return process.emit("log", "error", ...args);
|
|
3437
|
+
},
|
|
3438
|
+
notice: function(...args) {
|
|
3439
|
+
return process.emit("log", "notice", ...args);
|
|
3440
|
+
},
|
|
3441
|
+
warn: function(...args) {
|
|
3442
|
+
return process.emit("log", "warn", ...args);
|
|
3443
|
+
},
|
|
3444
|
+
info: function(...args) {
|
|
3445
|
+
return process.emit("log", "info", ...args);
|
|
3446
|
+
},
|
|
3447
|
+
verbose: function(...args) {
|
|
3448
|
+
return process.emit("log", "verbose", ...args);
|
|
3449
|
+
},
|
|
3450
|
+
http: function(...args) {
|
|
3451
|
+
return process.emit("log", "http", ...args);
|
|
3452
|
+
},
|
|
3453
|
+
silly: function(...args) {
|
|
3454
|
+
return process.emit("log", "silly", ...args);
|
|
3455
|
+
},
|
|
3456
|
+
timing: function(...args) {
|
|
3457
|
+
return process.emit("log", "timing", ...args);
|
|
3458
|
+
},
|
|
3459
|
+
pause: function() {
|
|
3460
|
+
return process.emit("log", "pause");
|
|
3461
|
+
},
|
|
3462
|
+
resume: function() {
|
|
3463
|
+
return process.emit("log", "resume");
|
|
3464
|
+
}
|
|
3465
|
+
},
|
|
3466
|
+
time: {
|
|
3467
|
+
LEVELS: [
|
|
3468
|
+
"start",
|
|
3469
|
+
"end"
|
|
3470
|
+
],
|
|
3471
|
+
KEYS: {
|
|
3472
|
+
start: "start",
|
|
3473
|
+
end: "end"
|
|
3474
|
+
},
|
|
3475
|
+
start: function(name, fn) {
|
|
3476
|
+
process.emit("time", "start", name);
|
|
3477
|
+
function end() {
|
|
3478
|
+
return process.emit("time", "end", name);
|
|
3479
|
+
}
|
|
3480
|
+
if (typeof fn === "function") {
|
|
3481
|
+
const res = fn();
|
|
3482
|
+
if (res && res.finally) {
|
|
3483
|
+
return res.finally(end);
|
|
3484
|
+
}
|
|
3485
|
+
end();
|
|
3486
|
+
return res;
|
|
3487
|
+
}
|
|
3488
|
+
return end;
|
|
3489
|
+
},
|
|
3490
|
+
end: function(name) {
|
|
3491
|
+
return process.emit("time", "end", name);
|
|
3492
|
+
}
|
|
3493
|
+
},
|
|
3494
|
+
input: {
|
|
3495
|
+
LEVELS: [
|
|
3496
|
+
"start",
|
|
3497
|
+
"end",
|
|
3498
|
+
"read"
|
|
3499
|
+
],
|
|
3500
|
+
KEYS: {
|
|
3501
|
+
start: "start",
|
|
3502
|
+
end: "end",
|
|
3503
|
+
read: "read"
|
|
3504
|
+
},
|
|
3505
|
+
start: function(...args) {
|
|
3506
|
+
let fn;
|
|
3507
|
+
if (typeof args[0] === "function") {
|
|
3508
|
+
fn = args.shift();
|
|
3509
|
+
}
|
|
3510
|
+
process.emit("input", "start", ...args);
|
|
3511
|
+
function end() {
|
|
3512
|
+
return process.emit("input", "end", ...args);
|
|
3513
|
+
}
|
|
3514
|
+
if (typeof fn === "function") {
|
|
3515
|
+
const res = fn();
|
|
3516
|
+
if (res && res.finally) {
|
|
3517
|
+
return res.finally(end);
|
|
3518
|
+
}
|
|
3519
|
+
end();
|
|
3520
|
+
return res;
|
|
3521
|
+
}
|
|
3522
|
+
return end;
|
|
3523
|
+
},
|
|
3524
|
+
end: function(...args) {
|
|
3525
|
+
return process.emit("input", "end", ...args);
|
|
3526
|
+
},
|
|
3527
|
+
read: function(...args) {
|
|
3528
|
+
let resolve3, reject;
|
|
3529
|
+
const promise = new Promise((_resolve, _reject) => {
|
|
3530
|
+
resolve3 = _resolve;
|
|
3531
|
+
reject = _reject;
|
|
3532
|
+
});
|
|
3533
|
+
process.emit("input", "read", resolve3, reject, ...args);
|
|
3534
|
+
return promise;
|
|
3535
|
+
}
|
|
3536
|
+
}
|
|
3537
|
+
};
|
|
3538
|
+
}
|
|
3539
|
+
});
|
|
3540
|
+
|
|
3541
|
+
// node_modules/npm-package-arg/lib/npa.js
|
|
3542
|
+
var require_npa = __commonJS({
|
|
3543
|
+
"node_modules/npm-package-arg/lib/npa.js"(exports, module) {
|
|
3544
|
+
"use strict";
|
|
3545
|
+
var isWindows = process.platform === "win32";
|
|
3546
|
+
var { URL: URL2 } = __require("node:url");
|
|
3547
|
+
var path = isWindows ? __require("node:path/win32") : __require("node:path");
|
|
3548
|
+
var { homedir } = __require("node:os");
|
|
3549
|
+
var HostedGit = require_lib();
|
|
3550
|
+
var semver = require_semver2();
|
|
3551
|
+
var validatePackageName = require_lib2();
|
|
3552
|
+
var { log } = require_lib3();
|
|
3553
|
+
var hasSlashes = isWindows ? /\\|[/]/ : /[/]/;
|
|
3554
|
+
var isURL = /^(?:git[+])?[a-z]+:/i;
|
|
3555
|
+
var isGit = /^[^@]+@[^:.]+\.[^:]+:.+$/i;
|
|
3556
|
+
var isFileType = /[.](?:tgz|tar\.gz|tar)$/i;
|
|
3557
|
+
var isPortNumber = /:[0-9]+(\/|$)/i;
|
|
3558
|
+
var isWindowsFile = /^(?:[.]|~[/]|[/\\]|[a-zA-Z]:)/;
|
|
3559
|
+
var isPosixFile = /^(?:[.]|~[/]|[/]|[a-zA-Z]:)/;
|
|
3560
|
+
var defaultRegistry = "https://registry.npmjs.org";
|
|
3561
|
+
function npa(arg, where) {
|
|
3562
|
+
let name;
|
|
3563
|
+
let spec;
|
|
3564
|
+
if (typeof arg === "object") {
|
|
3565
|
+
if (arg instanceof Result && (!where || where === arg.where)) {
|
|
3566
|
+
return arg;
|
|
3567
|
+
} else if (arg.name && arg.rawSpec) {
|
|
3568
|
+
return npa.resolve(arg.name, arg.rawSpec, where || arg.where);
|
|
3569
|
+
} else {
|
|
3570
|
+
return npa(arg.raw, where || arg.where);
|
|
3571
|
+
}
|
|
3572
|
+
}
|
|
3573
|
+
const nameEndsAt = arg.indexOf("@", 1);
|
|
3574
|
+
const namePart = nameEndsAt > 0 ? arg.slice(0, nameEndsAt) : arg;
|
|
3575
|
+
if (isURL.test(arg)) {
|
|
3576
|
+
spec = arg;
|
|
3577
|
+
} else if (isGit.test(arg)) {
|
|
3578
|
+
spec = `git+ssh://${arg}`;
|
|
3579
|
+
} else if (!namePart.startsWith("@") && (hasSlashes.test(namePart) || isFileType.test(namePart))) {
|
|
3580
|
+
spec = arg;
|
|
3581
|
+
} else if (nameEndsAt > 0) {
|
|
3582
|
+
name = namePart;
|
|
3583
|
+
spec = arg.slice(nameEndsAt + 1) || "*";
|
|
3584
|
+
} else {
|
|
3585
|
+
const valid = validatePackageName(arg);
|
|
3586
|
+
if (valid.validForOldPackages) {
|
|
3587
|
+
name = arg;
|
|
3588
|
+
spec = "*";
|
|
3589
|
+
} else {
|
|
3590
|
+
spec = arg;
|
|
3591
|
+
}
|
|
3592
|
+
}
|
|
3593
|
+
return resolve3(name, spec, where, arg);
|
|
3594
|
+
}
|
|
3595
|
+
function isFileSpec(spec) {
|
|
3596
|
+
if (!spec) {
|
|
3597
|
+
return false;
|
|
3598
|
+
}
|
|
3599
|
+
if (spec.toLowerCase().startsWith("file:")) {
|
|
3600
|
+
return true;
|
|
3601
|
+
}
|
|
3602
|
+
if (isWindows) {
|
|
3603
|
+
return isWindowsFile.test(spec);
|
|
3604
|
+
}
|
|
3605
|
+
return isPosixFile.test(spec);
|
|
3606
|
+
}
|
|
3607
|
+
function isAliasSpec(spec) {
|
|
3608
|
+
if (!spec) {
|
|
3609
|
+
return false;
|
|
3610
|
+
}
|
|
3611
|
+
return spec.toLowerCase().startsWith("npm:");
|
|
3612
|
+
}
|
|
3613
|
+
function resolve3(name, spec, where, arg) {
|
|
3614
|
+
const res = new Result({
|
|
3615
|
+
raw: arg,
|
|
3616
|
+
name,
|
|
3617
|
+
rawSpec: spec,
|
|
3618
|
+
fromArgument: arg != null
|
|
3619
|
+
});
|
|
3620
|
+
if (name) {
|
|
3621
|
+
res.name = name;
|
|
3622
|
+
}
|
|
3623
|
+
if (!where) {
|
|
3624
|
+
where = process.cwd();
|
|
3625
|
+
}
|
|
3626
|
+
if (isFileSpec(spec)) {
|
|
3627
|
+
return fromFile(res, where);
|
|
3628
|
+
} else if (isAliasSpec(spec)) {
|
|
3629
|
+
return fromAlias(res, where);
|
|
3630
|
+
}
|
|
3631
|
+
const hosted = HostedGit.fromUrl(spec, {
|
|
3632
|
+
noGitPlus: true,
|
|
3633
|
+
noCommittish: true
|
|
3634
|
+
});
|
|
3635
|
+
if (hosted) {
|
|
3636
|
+
return fromHostedGit(res, hosted);
|
|
3637
|
+
} else if (spec && isURL.test(spec)) {
|
|
3638
|
+
return fromURL(res);
|
|
3639
|
+
} else if (spec && (hasSlashes.test(spec) || isFileType.test(spec))) {
|
|
3640
|
+
return fromFile(res, where);
|
|
3641
|
+
} else {
|
|
3642
|
+
return fromRegistry(res);
|
|
3643
|
+
}
|
|
3644
|
+
}
|
|
3645
|
+
function toPurl(arg, reg = defaultRegistry) {
|
|
3646
|
+
const res = npa(arg);
|
|
3647
|
+
if (res.type !== "version") {
|
|
3648
|
+
throw invalidPurlType(res.type, res.raw);
|
|
3649
|
+
}
|
|
3650
|
+
let purl = "pkg:npm/" + res.name.replace(/^@/, "%40") + "@" + res.rawSpec;
|
|
3651
|
+
if (reg !== defaultRegistry) {
|
|
3652
|
+
purl += "?repository_url=" + reg;
|
|
3653
|
+
}
|
|
3654
|
+
return purl;
|
|
3655
|
+
}
|
|
3656
|
+
function invalidPackageName(name, valid, raw) {
|
|
3657
|
+
const err = new Error(`Invalid package name "${name}" of package "${raw}": ${valid.errors.join("; ")}.`);
|
|
3658
|
+
err.code = "EINVALIDPACKAGENAME";
|
|
3659
|
+
return err;
|
|
3660
|
+
}
|
|
3661
|
+
function invalidTagName(name, raw) {
|
|
3662
|
+
const err = new Error(`Invalid tag name "${name}" of package "${raw}": Tags may not have any characters that encodeURIComponent encodes.`);
|
|
3663
|
+
err.code = "EINVALIDTAGNAME";
|
|
3664
|
+
return err;
|
|
3665
|
+
}
|
|
3666
|
+
function invalidPurlType(type, raw) {
|
|
3667
|
+
const err = new Error(`Invalid type "${type}" of package "${raw}": Purl can only be generated for "version" types.`);
|
|
3668
|
+
err.code = "EINVALIDPURLTYPE";
|
|
3669
|
+
return err;
|
|
3670
|
+
}
|
|
3671
|
+
var Result = class {
|
|
3672
|
+
constructor(opts) {
|
|
3673
|
+
this.type = opts.type;
|
|
3674
|
+
this.registry = opts.registry;
|
|
3675
|
+
this.where = opts.where;
|
|
3676
|
+
if (opts.raw == null) {
|
|
3677
|
+
this.raw = opts.name ? `${opts.name}@${opts.rawSpec}` : opts.rawSpec;
|
|
3678
|
+
} else {
|
|
3679
|
+
this.raw = opts.raw;
|
|
3680
|
+
}
|
|
3681
|
+
this.name = void 0;
|
|
3682
|
+
this.escapedName = void 0;
|
|
3683
|
+
this.scope = void 0;
|
|
3684
|
+
this.rawSpec = opts.rawSpec || "";
|
|
3685
|
+
this.saveSpec = opts.saveSpec;
|
|
3686
|
+
this.fetchSpec = opts.fetchSpec;
|
|
3687
|
+
if (opts.name) {
|
|
3688
|
+
this.setName(opts.name);
|
|
3689
|
+
}
|
|
3690
|
+
this.gitRange = opts.gitRange;
|
|
3691
|
+
this.gitCommittish = opts.gitCommittish;
|
|
3692
|
+
this.gitSubdir = opts.gitSubdir;
|
|
3693
|
+
this.hosted = opts.hosted;
|
|
3694
|
+
}
|
|
3695
|
+
// TODO move this to a getter/setter in a semver major
|
|
3696
|
+
setName(name) {
|
|
3697
|
+
const valid = validatePackageName(name);
|
|
3698
|
+
if (!valid.validForOldPackages) {
|
|
3699
|
+
throw invalidPackageName(name, valid, this.raw);
|
|
3700
|
+
}
|
|
3701
|
+
this.name = name;
|
|
3702
|
+
this.scope = name[0] === "@" ? name.slice(0, name.indexOf("/")) : void 0;
|
|
3703
|
+
this.escapedName = name.replace("/", "%2f");
|
|
3704
|
+
return this;
|
|
3705
|
+
}
|
|
3706
|
+
toString() {
|
|
3707
|
+
const full = [];
|
|
3708
|
+
if (this.name != null && this.name !== "") {
|
|
3709
|
+
full.push(this.name);
|
|
3710
|
+
}
|
|
3711
|
+
const spec = this.saveSpec || this.fetchSpec || this.rawSpec;
|
|
3712
|
+
if (spec != null && spec !== "") {
|
|
3713
|
+
full.push(spec);
|
|
3714
|
+
}
|
|
3715
|
+
return full.length ? full.join("@") : this.raw;
|
|
3716
|
+
}
|
|
3717
|
+
toJSON() {
|
|
3718
|
+
const result = Object.assign({}, this);
|
|
3719
|
+
delete result.hosted;
|
|
3720
|
+
return result;
|
|
3721
|
+
}
|
|
3722
|
+
};
|
|
3723
|
+
function setGitAttrs(res, committish) {
|
|
3724
|
+
if (!committish) {
|
|
3725
|
+
res.gitCommittish = null;
|
|
3726
|
+
return;
|
|
3727
|
+
}
|
|
3728
|
+
for (const part of committish.split("::")) {
|
|
3729
|
+
if (!part.includes(":")) {
|
|
3730
|
+
if (res.gitRange) {
|
|
3731
|
+
throw new Error("cannot override existing semver range with a committish");
|
|
3732
|
+
}
|
|
3733
|
+
if (res.gitCommittish) {
|
|
3734
|
+
throw new Error("cannot override existing committish with a second committish");
|
|
3735
|
+
}
|
|
3736
|
+
res.gitCommittish = part;
|
|
3737
|
+
continue;
|
|
3738
|
+
}
|
|
3739
|
+
const [name, value] = part.split(":");
|
|
3740
|
+
if (name === "semver") {
|
|
3741
|
+
if (res.gitCommittish) {
|
|
3742
|
+
throw new Error("cannot override existing committish with a semver range");
|
|
3743
|
+
}
|
|
3744
|
+
if (res.gitRange) {
|
|
3745
|
+
throw new Error("cannot override existing semver range with a second semver range");
|
|
3746
|
+
}
|
|
3747
|
+
res.gitRange = decodeURIComponent(value);
|
|
3748
|
+
continue;
|
|
3749
|
+
}
|
|
3750
|
+
if (name === "path") {
|
|
3751
|
+
if (res.gitSubdir) {
|
|
3752
|
+
throw new Error("cannot override existing path with a second path");
|
|
3753
|
+
}
|
|
3754
|
+
res.gitSubdir = `/${value}`;
|
|
3755
|
+
continue;
|
|
3756
|
+
}
|
|
3757
|
+
log.warn("npm-package-arg", `ignoring unknown key "${name}"`);
|
|
3758
|
+
}
|
|
3759
|
+
}
|
|
3760
|
+
var encodedPathChars = /* @__PURE__ */ new Map([
|
|
3761
|
+
["\0", "%00"],
|
|
3762
|
+
[" ", "%09"],
|
|
3763
|
+
["\n", "%0A"],
|
|
3764
|
+
["\r", "%0D"],
|
|
3765
|
+
[" ", "%20"],
|
|
3766
|
+
['"', "%22"],
|
|
3767
|
+
["#", "%23"],
|
|
3768
|
+
["%", "%25"],
|
|
3769
|
+
["?", "%3F"],
|
|
3770
|
+
["[", "%5B"],
|
|
3771
|
+
["\\", isWindows ? "/" : "%5C"],
|
|
3772
|
+
["]", "%5D"],
|
|
3773
|
+
["^", "%5E"],
|
|
3774
|
+
["|", "%7C"],
|
|
3775
|
+
["~", "%7E"]
|
|
3776
|
+
]);
|
|
3777
|
+
function pathToFileURL(str) {
|
|
3778
|
+
let result = "";
|
|
3779
|
+
for (let i = 0; i < str.length; i++) {
|
|
3780
|
+
result = `${result}${encodedPathChars.get(str[i]) ?? str[i]}`;
|
|
3781
|
+
}
|
|
3782
|
+
if (result.startsWith("file:")) {
|
|
3783
|
+
return result;
|
|
3784
|
+
}
|
|
3785
|
+
return `file:${result}`;
|
|
3786
|
+
}
|
|
3787
|
+
function fromFile(res, where) {
|
|
3788
|
+
res.type = isFileType.test(res.rawSpec) ? "file" : "directory";
|
|
3789
|
+
res.where = where;
|
|
3790
|
+
let rawSpec = pathToFileURL(res.rawSpec);
|
|
3791
|
+
if (rawSpec.startsWith("file:/")) {
|
|
3792
|
+
if (/^file:\/\/[^/]/.test(rawSpec)) {
|
|
3793
|
+
rawSpec = `file:/${rawSpec.slice(5)}`;
|
|
3794
|
+
}
|
|
3795
|
+
if (/^\/{1,3}\.\.?(\/|$)/.test(rawSpec.slice(5))) {
|
|
3796
|
+
rawSpec = rawSpec.replace(/^file:\/{1,3}/, "file:");
|
|
3797
|
+
}
|
|
3798
|
+
}
|
|
3799
|
+
let resolvedUrl;
|
|
3800
|
+
let specUrl;
|
|
3801
|
+
try {
|
|
3802
|
+
resolvedUrl = new URL2(rawSpec, `${pathToFileURL(path.resolve(where))}/`);
|
|
3803
|
+
specUrl = new URL2(rawSpec);
|
|
3804
|
+
} catch (originalError) {
|
|
3805
|
+
const er = new Error("Invalid file: URL, must comply with RFC 8089");
|
|
3806
|
+
throw Object.assign(er, {
|
|
3807
|
+
raw: res.rawSpec,
|
|
3808
|
+
spec: res,
|
|
3809
|
+
where,
|
|
3810
|
+
originalError
|
|
3811
|
+
});
|
|
3812
|
+
}
|
|
3813
|
+
let specPath = decodeURIComponent(specUrl.pathname);
|
|
3814
|
+
let resolvedPath = decodeURIComponent(resolvedUrl.pathname);
|
|
3815
|
+
if (isWindows) {
|
|
3816
|
+
specPath = specPath.replace(/^\/+([a-z]:\/)/i, "$1");
|
|
3817
|
+
resolvedPath = resolvedPath.replace(/^\/+([a-z]:\/)/i, "$1");
|
|
3818
|
+
}
|
|
3819
|
+
if (/^\/~(\/|$)/.test(specPath)) {
|
|
3820
|
+
res.saveSpec = `file:${specPath.substr(1)}`;
|
|
3821
|
+
resolvedPath = path.resolve(homedir(), specPath.substr(3));
|
|
3822
|
+
} else if (!path.isAbsolute(rawSpec.slice(5))) {
|
|
3823
|
+
res.saveSpec = `file:${path.relative(where, resolvedPath)}`;
|
|
3824
|
+
} else {
|
|
3825
|
+
res.saveSpec = `file:${path.resolve(resolvedPath)}`;
|
|
3826
|
+
}
|
|
3827
|
+
res.fetchSpec = path.resolve(where, resolvedPath);
|
|
3828
|
+
res.saveSpec = res.saveSpec.split("\\").join("/");
|
|
3829
|
+
if (res.saveSpec.startsWith("file://")) {
|
|
3830
|
+
res.saveSpec = `file:/${res.saveSpec.slice(7)}`;
|
|
3831
|
+
}
|
|
3832
|
+
return res;
|
|
3833
|
+
}
|
|
3834
|
+
function fromHostedGit(res, hosted) {
|
|
3835
|
+
res.type = "git";
|
|
3836
|
+
res.hosted = hosted;
|
|
3837
|
+
res.saveSpec = hosted.toString({ noGitPlus: false, noCommittish: false });
|
|
3838
|
+
res.fetchSpec = hosted.getDefaultRepresentation() === "shortcut" ? null : hosted.toString();
|
|
3839
|
+
setGitAttrs(res, hosted.committish);
|
|
3840
|
+
return res;
|
|
3841
|
+
}
|
|
3842
|
+
function unsupportedURLType(protocol, spec) {
|
|
3843
|
+
const err = new Error(`Unsupported URL Type "${protocol}": ${spec}`);
|
|
3844
|
+
err.code = "EUNSUPPORTEDPROTOCOL";
|
|
3845
|
+
return err;
|
|
3846
|
+
}
|
|
3847
|
+
function fromURL(res) {
|
|
3848
|
+
let rawSpec = res.rawSpec;
|
|
3849
|
+
res.saveSpec = rawSpec;
|
|
3850
|
+
if (rawSpec.startsWith("git+ssh:")) {
|
|
3851
|
+
const matched = rawSpec.match(/^git\+ssh:\/\/([^:#]+:[^#]+(?:\.git)?)(?:#(.*))?$/i);
|
|
3852
|
+
if (matched && !matched[1].match(isPortNumber)) {
|
|
3853
|
+
res.type = "git";
|
|
3854
|
+
setGitAttrs(res, matched[2]);
|
|
3855
|
+
res.fetchSpec = matched[1];
|
|
3856
|
+
return res;
|
|
3857
|
+
}
|
|
3858
|
+
} else if (rawSpec.startsWith("git+file://")) {
|
|
3859
|
+
rawSpec = rawSpec.replace(/\\/g, "/");
|
|
3860
|
+
}
|
|
3861
|
+
const parsedUrl = new URL2(rawSpec);
|
|
3862
|
+
switch (parsedUrl.protocol) {
|
|
3863
|
+
case "git:":
|
|
3864
|
+
case "git+http:":
|
|
3865
|
+
case "git+https:":
|
|
3866
|
+
case "git+rsync:":
|
|
3867
|
+
case "git+ftp:":
|
|
3868
|
+
case "git+file:":
|
|
3869
|
+
case "git+ssh:":
|
|
3870
|
+
res.type = "git";
|
|
3871
|
+
setGitAttrs(res, parsedUrl.hash.slice(1));
|
|
3872
|
+
if (parsedUrl.protocol === "git+file:" && /^git\+file:\/\/[a-z]:/i.test(rawSpec)) {
|
|
3873
|
+
res.fetchSpec = `git+file://${parsedUrl.host.toLowerCase()}:${parsedUrl.pathname}`;
|
|
3874
|
+
} else {
|
|
3875
|
+
parsedUrl.hash = "";
|
|
3876
|
+
res.fetchSpec = parsedUrl.toString();
|
|
3877
|
+
}
|
|
3878
|
+
if (res.fetchSpec.startsWith("git+")) {
|
|
3879
|
+
res.fetchSpec = res.fetchSpec.slice(4);
|
|
3880
|
+
}
|
|
3881
|
+
break;
|
|
3882
|
+
case "http:":
|
|
3883
|
+
case "https:":
|
|
3884
|
+
res.type = "remote";
|
|
3885
|
+
res.fetchSpec = res.saveSpec;
|
|
3886
|
+
break;
|
|
3887
|
+
default:
|
|
3888
|
+
throw unsupportedURLType(parsedUrl.protocol, rawSpec);
|
|
3889
|
+
}
|
|
3890
|
+
return res;
|
|
3891
|
+
}
|
|
3892
|
+
function fromAlias(res, where) {
|
|
3893
|
+
const subSpec = npa(res.rawSpec.substr(4), where);
|
|
3894
|
+
if (subSpec.type === "alias") {
|
|
3895
|
+
throw new Error("nested aliases not supported");
|
|
3896
|
+
}
|
|
3897
|
+
if (!subSpec.registry) {
|
|
3898
|
+
throw new Error("aliases only work for registry deps");
|
|
3899
|
+
}
|
|
3900
|
+
if (!subSpec.name) {
|
|
3901
|
+
throw new Error("aliases must have a name");
|
|
3902
|
+
}
|
|
3903
|
+
res.subSpec = subSpec;
|
|
3904
|
+
res.registry = true;
|
|
3905
|
+
res.type = "alias";
|
|
3906
|
+
res.saveSpec = null;
|
|
3907
|
+
res.fetchSpec = null;
|
|
3908
|
+
return res;
|
|
3909
|
+
}
|
|
3910
|
+
function fromRegistry(res) {
|
|
3911
|
+
res.registry = true;
|
|
3912
|
+
const spec = res.rawSpec.trim();
|
|
3913
|
+
res.saveSpec = null;
|
|
3914
|
+
res.fetchSpec = spec;
|
|
3915
|
+
const version = semver.valid(spec, true);
|
|
3916
|
+
const range = semver.validRange(spec, true);
|
|
3917
|
+
if (version) {
|
|
3918
|
+
res.type = "version";
|
|
3919
|
+
} else if (range) {
|
|
3920
|
+
res.type = "range";
|
|
3921
|
+
} else {
|
|
3922
|
+
if (encodeURIComponent(spec) !== spec) {
|
|
3923
|
+
throw invalidTagName(spec, res.raw);
|
|
3924
|
+
}
|
|
3925
|
+
res.type = "tag";
|
|
3926
|
+
}
|
|
3927
|
+
return res;
|
|
3928
|
+
}
|
|
3929
|
+
module.exports = npa;
|
|
3930
|
+
module.exports.resolve = resolve3;
|
|
3931
|
+
module.exports.toPurl = toPurl;
|
|
3932
|
+
module.exports.Result = Result;
|
|
3933
|
+
}
|
|
3934
|
+
});
|
|
3935
|
+
|
|
3936
|
+
// scripts/lib/runtime-build/check-cli.mjs
|
|
3937
|
+
import { existsSync as existsSync4, readdirSync as readdirSync4, statSync as statSync4 } from "node:fs";
|
|
3938
|
+
import { join as join7, resolve as resolve2 } from "node:path";
|
|
3939
|
+
import { fileURLToPath } from "node:url";
|
|
3940
|
+
|
|
3941
|
+
// scripts/lib/runtime-build/installed-packages.mjs
|
|
3942
|
+
import {
|
|
3943
|
+
cpSync,
|
|
3944
|
+
existsSync as existsSync2,
|
|
3945
|
+
mkdirSync,
|
|
3946
|
+
mkdtempSync,
|
|
3947
|
+
readFileSync as readFileSync3,
|
|
3948
|
+
rmSync,
|
|
3949
|
+
statSync,
|
|
3950
|
+
symlinkSync,
|
|
3951
|
+
writeFileSync
|
|
3952
|
+
} from "node:fs";
|
|
3953
|
+
var import_npm_package_arg = __toESM(require_npa(), 1);
|
|
3954
|
+
var import_semver = __toESM(require_semver2(), 1);
|
|
3955
|
+
import { tmpdir } from "node:os";
|
|
3956
|
+
import { basename as basename5, dirname as dirname2, isAbsolute, join as join4, relative as relative2, sep as sep2 } from "node:path";
|
|
3957
|
+
|
|
3958
|
+
// scripts/lib/runtime-build/checkout-files.mjs
|
|
3959
|
+
import { readdirSync } from "node:fs";
|
|
3960
|
+
import { join, relative, sep } from "node:path";
|
|
3961
|
+
var PACKAGE_DIRECTORY = "node_modules";
|
|
3962
|
+
function listCheckoutFiles(root, skippedRootDirectories) {
|
|
3963
|
+
const files = [];
|
|
3964
|
+
const pending = [root];
|
|
3965
|
+
while (pending.length > 0) {
|
|
3966
|
+
const directory = pending.pop();
|
|
3967
|
+
for (const entry2 of readdirSync(directory, { withFileTypes: true })) {
|
|
3968
|
+
if (entry2.name.startsWith(".")) {
|
|
3969
|
+
continue;
|
|
3970
|
+
}
|
|
3971
|
+
if (entry2.isDirectory()) {
|
|
3972
|
+
const skipped = entry2.name === PACKAGE_DIRECTORY || directory === root && skippedRootDirectories.has(entry2.name);
|
|
3973
|
+
if (!skipped) {
|
|
3974
|
+
pending.push(join(directory, entry2.name));
|
|
3975
|
+
}
|
|
2223
3976
|
} else if (entry2.isFile()) {
|
|
2224
3977
|
files.push(relative(root, join(directory, entry2.name)).split(sep).join("/"));
|
|
2225
3978
|
}
|
|
@@ -3824,7 +5577,11 @@ function inputSchemaField(definition, presentation) {
|
|
|
3824
5577
|
var SOURCE_TRANSFORM_SCHEMA = "diagonal.source-transform/v1";
|
|
3825
5578
|
var SOURCE_TRANSFORM_RESULT_SCHEMA = "diagonal.source-transform-result/v1";
|
|
3826
5579
|
var PROFILE = Object.freeze({ target: "runtime-esm", version: 1 });
|
|
5580
|
+
var MAX_RESULT_BYTES = 64 * 1024 * 1024;
|
|
5581
|
+
var MAX_SOURCE_FILES = 1e4;
|
|
3827
5582
|
var MAX_SOURCE_BYTES = 50 * 1024 * 1024;
|
|
5583
|
+
var PACKAGE_NAME = new RegExp(package_rules_default.package_name);
|
|
5584
|
+
var VENDOR_FILE = /^vendor\/((?:@[^/@]+\/)?[^/@][^/]*)\/(.+)$/;
|
|
3828
5585
|
function isValidSourcePath(path) {
|
|
3829
5586
|
if (typeof path !== "string" || path === "" || path.startsWith("/") || path.endsWith("/") || path.includes("\\")) {
|
|
3830
5587
|
return false;
|
|
@@ -3836,6 +5593,11 @@ function isValidSourcePath(path) {
|
|
|
3836
5593
|
}
|
|
3837
5594
|
return /^[A-Za-z0-9._\-/[\]@+ ]+$/.test(path);
|
|
3838
5595
|
}
|
|
5596
|
+
function vendorFile(path) {
|
|
5597
|
+
if (!isValidSourcePath(path)) return null;
|
|
5598
|
+
const match = VENDOR_FILE.exec(path);
|
|
5599
|
+
return match === null || !PACKAGE_NAME.test(match[1]) ? null : { name: match[1], path: match[2] };
|
|
5600
|
+
}
|
|
3839
5601
|
|
|
3840
5602
|
// scripts/lib/runtime-build/source-transforms.mjs
|
|
3841
5603
|
import { isDeepStrictEqual as isDeepStrictEqual2 } from "node:util";
|
|
@@ -5810,9 +7572,61 @@ var notificationTypeAdapter = Object.freeze({
|
|
|
5810
7572
|
}
|
|
5811
7573
|
});
|
|
5812
7574
|
|
|
7575
|
+
// scripts/lib/runtime-build/source-adapters/package-inputs.mjs
|
|
7576
|
+
var inputPaths = ["package.json", "package-lock.json", "npm-shrinkwrap.json", "diagonal.config.ts"];
|
|
7577
|
+
var packageInputsAdapter = Object.freeze({
|
|
7578
|
+
contextFields: [],
|
|
7579
|
+
accepts: (path) => path === "package.json",
|
|
7580
|
+
read({ source }) {
|
|
7581
|
+
let inputs;
|
|
7582
|
+
try {
|
|
7583
|
+
inputs = JSON.parse(source);
|
|
7584
|
+
} catch (error) {
|
|
7585
|
+
if (!(error instanceof SyntaxError)) throw error;
|
|
7586
|
+
throw new SourceTransformRequestError("Package inputs must contain a JSON object of file contents.");
|
|
7587
|
+
}
|
|
7588
|
+
keys(inputs, inputPaths, "package inputs");
|
|
7589
|
+
if (Object.values(inputs).some((value) => typeof value !== "string")) {
|
|
7590
|
+
throw new SourceTransformRequestError("Package input contents must be strings.");
|
|
7591
|
+
}
|
|
7592
|
+
const files = new Map(Object.entries(inputs));
|
|
7593
|
+
const diagnostics = packageInputDiagnosticsFromFiles(files);
|
|
7594
|
+
if (files.has("diagonal.config.ts")) {
|
|
7595
|
+
try {
|
|
7596
|
+
const choices = readConfigPackages(files.get("diagonal.config.ts"));
|
|
7597
|
+
for (const name of Object.keys(choices)) {
|
|
7598
|
+
diagnostics.push(diagnosticAt("diagonal.config.ts", null, `Package input choices name the unavailable package "${name}"`));
|
|
7599
|
+
}
|
|
7600
|
+
} catch (error) {
|
|
7601
|
+
if (!(error instanceof SourceError || error instanceof SyntaxError)) throw error;
|
|
7602
|
+
diagnostics.push(diagnosticFromError("diagonal.config.ts", error));
|
|
7603
|
+
}
|
|
7604
|
+
}
|
|
7605
|
+
if (diagnostics.length > 0) return { diagnostics: diagnostics.map((diagnostic) => ({ ...diagnostic, code: "package_sources_invalid" })), has_package_candidates: false };
|
|
7606
|
+
const manifest = JSON.parse(files.get("package.json") ?? "{}");
|
|
7607
|
+
const dependencyFields = files.has("package-lock.json") || files.has("npm-shrinkwrap.json") ? ["dependencies", "optionalDependencies", "peerDependencies"] : ["dependencies"];
|
|
7608
|
+
return { diagnostics, has_package_candidates: dependencyFields.some((field) => Object.keys(manifest[field] ?? {}).length > 0) };
|
|
7609
|
+
}
|
|
7610
|
+
});
|
|
7611
|
+
|
|
5813
7612
|
// scripts/lib/runtime-build/page-file.mjs
|
|
5814
7613
|
import { posix as posix3 } from "node:path";
|
|
5815
7614
|
|
|
7615
|
+
// scripts/lib/runtime-build/package-input-bindings.mjs
|
|
7616
|
+
import { readFileSync } from "node:fs";
|
|
7617
|
+
import { basename, join as join2 } from "node:path";
|
|
7618
|
+
|
|
7619
|
+
// scripts/lib/workflow-code/workflow-evaluator.mjs
|
|
7620
|
+
function textTemplateFields(template, variables) {
|
|
7621
|
+
return {
|
|
7622
|
+
template,
|
|
7623
|
+
values: Object.entries(variables).map(([key, replacement]) => ({
|
|
7624
|
+
search: `{{${key}}}`,
|
|
7625
|
+
replacement
|
|
7626
|
+
}))
|
|
7627
|
+
};
|
|
7628
|
+
}
|
|
7629
|
+
|
|
5816
7630
|
// scripts/lib/workflow-code/ast-values.mjs
|
|
5817
7631
|
function memberPropertyName(node) {
|
|
5818
7632
|
if (node?.type !== "MemberExpression" && node?.type !== "OptionalMemberExpression") {
|
|
@@ -5843,54 +7657,266 @@ function literalValue(node) {
|
|
|
5843
7657
|
return void 0;
|
|
5844
7658
|
}
|
|
5845
7659
|
|
|
5846
|
-
// scripts/lib/
|
|
5847
|
-
|
|
5848
|
-
|
|
5849
|
-
|
|
5850
|
-
|
|
5851
|
-
|
|
5852
|
-
|
|
5853
|
-
|
|
5854
|
-
|
|
5855
|
-
}
|
|
5856
|
-
|
|
5857
|
-
|
|
5858
|
-
|
|
5859
|
-
|
|
5860
|
-
["description", "description"],
|
|
5861
|
-
["ogImage", "image"]
|
|
5862
|
-
];
|
|
5863
|
-
var SEO_KEYS = FLAT_SEO_KEYS.map(([, key]) => key);
|
|
5864
|
-
var PAGE_META_RESOLVERS = new Set(page_meta_resolvers_default);
|
|
5865
|
-
var PLACEHOLDER = /\{\{([^{}]+)\}\}/g;
|
|
5866
|
-
var FILE_ID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
5867
|
-
var TIPTAP_PARSE = "tiptap.parse";
|
|
5868
|
-
var FieldRead = class {
|
|
5869
|
-
constructor(binding, fields2, node) {
|
|
5870
|
-
this.binding = binding;
|
|
5871
|
-
this.fields = fields2;
|
|
5872
|
-
this.node = node;
|
|
5873
|
-
}
|
|
5874
|
-
get key() {
|
|
5875
|
-
return [this.binding, ...this.fields].join(".");
|
|
7660
|
+
// scripts/lib/runtime-build/package-input-bindings.mjs
|
|
7661
|
+
var traverse3 = traverse.default ?? traverse;
|
|
7662
|
+
var KINDS = {
|
|
7663
|
+
resource: { module: "resources", exportName: "Resources", argument: defineResourceArgument },
|
|
7664
|
+
role: { module: "roles", exportName: "Roles", argument: defineRoleArgument },
|
|
7665
|
+
permission: {
|
|
7666
|
+
module: "permissions",
|
|
7667
|
+
exportName: "Permissions",
|
|
7668
|
+
argument: definePermissionArgument
|
|
7669
|
+
},
|
|
7670
|
+
workspace_field: {
|
|
7671
|
+
module: "workspace-fields",
|
|
7672
|
+
exportName: "WorkspaceFields",
|
|
7673
|
+
argument: defineWorkspaceFieldArgument
|
|
5876
7674
|
}
|
|
5877
7675
|
};
|
|
5878
|
-
|
|
5879
|
-
|
|
5880
|
-
|
|
5881
|
-
|
|
5882
|
-
if (node.type === "StringLiteral") {
|
|
5883
|
-
return node.value;
|
|
7676
|
+
var GENERATED_PATHS = new Set(Object.values(KINDS).map(({ module }) => `generated/${module}.ts`));
|
|
7677
|
+
function definitionKind(path) {
|
|
7678
|
+
if (isResourcePath(path)) {
|
|
7679
|
+
return "resource";
|
|
5884
7680
|
}
|
|
5885
|
-
if (
|
|
5886
|
-
return
|
|
7681
|
+
if (/^roles\/[^/]+\.ts$/.test(path)) {
|
|
7682
|
+
return "role";
|
|
5887
7683
|
}
|
|
5888
|
-
|
|
5889
|
-
|
|
5890
|
-
|
|
5891
|
-
|
|
5892
|
-
|
|
5893
|
-
|
|
7684
|
+
if (/^permissions\/[^/]+\.ts$/.test(path)) {
|
|
7685
|
+
return "permission";
|
|
7686
|
+
}
|
|
7687
|
+
if (/^workspace-fields\/[^/]+\.ts$/.test(path)) {
|
|
7688
|
+
return "workspace_field";
|
|
7689
|
+
}
|
|
7690
|
+
return null;
|
|
7691
|
+
}
|
|
7692
|
+
function targetsByUid(root, sources) {
|
|
7693
|
+
const targets = /* @__PURE__ */ new Map();
|
|
7694
|
+
for (const { path, source } of sources) {
|
|
7695
|
+
const kind = definitionKind(path);
|
|
7696
|
+
if (kind === null) {
|
|
7697
|
+
continue;
|
|
7698
|
+
}
|
|
7699
|
+
try {
|
|
7700
|
+
const ast = parseSource(readFileSync(join2(root, source), "utf8"), { jsx: false });
|
|
7701
|
+
const uid = readUid(KINDS[kind].argument(ast));
|
|
7702
|
+
if (uid === null) {
|
|
7703
|
+
continue;
|
|
7704
|
+
}
|
|
7705
|
+
const key = `${kind}:${uid}`;
|
|
7706
|
+
const folder = kind === "resource" ? resourceFolderOf(path) : null;
|
|
7707
|
+
const name = studlyName(folder ?? basename(withoutDevInfix(path), ".ts"));
|
|
7708
|
+
const entries = targets.get(key) ?? [];
|
|
7709
|
+
entries.push({ kind, uid, name, path, folder });
|
|
7710
|
+
targets.set(key, entries);
|
|
7711
|
+
} catch (error) {
|
|
7712
|
+
if (!(error instanceof SourceError || error instanceof SyntaxError)) {
|
|
7713
|
+
throw error;
|
|
7714
|
+
}
|
|
7715
|
+
}
|
|
7716
|
+
}
|
|
7717
|
+
return targets;
|
|
7718
|
+
}
|
|
7719
|
+
function resolvePackageInputBindings(root, workspaceManifest, choices, candidates, workspaceFiles, diagnostics) {
|
|
7720
|
+
const bindings = /* @__PURE__ */ new Map();
|
|
7721
|
+
const problem2 = (message) => diagnostics.push(diagnosticAt("diagonal.config.ts", null, message));
|
|
7722
|
+
const sources = [...workspaceFiles].map((path) => ({ path, source: path }));
|
|
7723
|
+
for (const { owned } of candidates) {
|
|
7724
|
+
for (const [path, source] of owned) {
|
|
7725
|
+
if (!isDevPath(path)) {
|
|
7726
|
+
sources.push({ path, source });
|
|
7727
|
+
}
|
|
7728
|
+
}
|
|
7729
|
+
}
|
|
7730
|
+
let targets = null;
|
|
7731
|
+
const names = new Set(candidates.map(({ name }) => name));
|
|
7732
|
+
for (const name of Object.keys(choices)) {
|
|
7733
|
+
if (!names.has(name)) {
|
|
7734
|
+
problem2(`Package input choices name the unavailable package "${name}"`);
|
|
7735
|
+
}
|
|
7736
|
+
}
|
|
7737
|
+
for (const { name, manifest, owned } of candidates) {
|
|
7738
|
+
const inputs = manifest.diagonal.requirements?.inputs ?? [];
|
|
7739
|
+
const selected = Object.hasOwn(choices, name) ? choices[name] : {};
|
|
7740
|
+
const resolved = [];
|
|
7741
|
+
bindings.set(name, resolved);
|
|
7742
|
+
if (!Array.isArray(inputs) || !isPlainObject(selected)) {
|
|
7743
|
+
problem2(`Package "${name}" must have an input list and an object of choices`);
|
|
7744
|
+
continue;
|
|
7745
|
+
}
|
|
7746
|
+
const known = /* @__PURE__ */ new Set();
|
|
7747
|
+
for (const input of inputs) {
|
|
7748
|
+
if (!isPlainObject(input) || !Object.hasOwn(KINDS, input.kind) || !isUid(input.uid) || !["mapping", "value"].includes(input.mode) || input.mode === "mapping" && typeof input.name !== "string") {
|
|
7749
|
+
problem2(`Package "${name}" has an invalid input descriptor`);
|
|
7750
|
+
continue;
|
|
7751
|
+
}
|
|
7752
|
+
const key = `${input.kind}:${input.uid}`;
|
|
7753
|
+
if (known.has(key)) {
|
|
7754
|
+
problem2(`Package "${name}" declares input "${key}" more than once`);
|
|
7755
|
+
continue;
|
|
7756
|
+
}
|
|
7757
|
+
known.add(key);
|
|
7758
|
+
if (input.mode === "value") {
|
|
7759
|
+
const source = owned.get(input.path);
|
|
7760
|
+
if (source === void 0) {
|
|
7761
|
+
problem2(`Package "${name}" input "${key}" has no field source.`);
|
|
7762
|
+
continue;
|
|
7763
|
+
}
|
|
7764
|
+
if (source.startsWith(`vendor/${name}/`) && workspaceManifest?.dependencies?.[name]?.startsWith("file:") !== true) {
|
|
7765
|
+
problem2(
|
|
7766
|
+
`Package "${name}" input "${key}" also has a vendor field copy. Remove that copy and set the value in diagonal.config.ts packages.`
|
|
7767
|
+
);
|
|
7768
|
+
continue;
|
|
7769
|
+
}
|
|
7770
|
+
try {
|
|
7771
|
+
validatePackageFieldSource(input, readFileSync(join2(root, source), "utf8"));
|
|
7772
|
+
resolved.push({ input, selected: resolvePackageFieldInput(input, selected[key]) });
|
|
7773
|
+
} catch (error) {
|
|
7774
|
+
if (!(error instanceof SourceError)) throw error;
|
|
7775
|
+
problem2(`Package "${name}": ${error.message}`);
|
|
7776
|
+
}
|
|
7777
|
+
continue;
|
|
7778
|
+
}
|
|
7779
|
+
const targetUid = selected[key];
|
|
7780
|
+
if (!isUid(targetUid)) {
|
|
7781
|
+
problem2(
|
|
7782
|
+
`Choose a ${input.kind} for package "${name}" input "${input.name}" (${key})`
|
|
7783
|
+
);
|
|
7784
|
+
continue;
|
|
7785
|
+
}
|
|
7786
|
+
targets ??= targetsByUid(root, sources);
|
|
7787
|
+
const matches = targets.get(`${input.kind}:${targetUid}`) ?? [];
|
|
7788
|
+
if (matches.length !== 1) {
|
|
7789
|
+
problem2(
|
|
7790
|
+
`Package "${name}" input "${input.name}" does not name a unique ${input.kind} in this workspace`
|
|
7791
|
+
);
|
|
7792
|
+
continue;
|
|
7793
|
+
}
|
|
7794
|
+
resolved.push({ input, target: matches[0] });
|
|
7795
|
+
}
|
|
7796
|
+
for (const key of Object.keys(selected)) {
|
|
7797
|
+
if (!known.has(key)) {
|
|
7798
|
+
problem2(`Package "${name}" has no input "${key}"`);
|
|
7799
|
+
}
|
|
7800
|
+
}
|
|
7801
|
+
}
|
|
7802
|
+
return bindings;
|
|
7803
|
+
}
|
|
7804
|
+
function boundPackagePath(path, bindings) {
|
|
7805
|
+
const child = resourceChildOf(path);
|
|
7806
|
+
if (child?.kind !== "resource_field") {
|
|
7807
|
+
return path;
|
|
7808
|
+
}
|
|
7809
|
+
const binding = bindings.find(
|
|
7810
|
+
({ input }) => input.kind === "resource" && input.name === studlyName(child.folder)
|
|
7811
|
+
);
|
|
7812
|
+
return binding === void 0 ? path : path.replace(`resources/${child.folder}/`, `resources/${binding.target.folder}/`);
|
|
7813
|
+
}
|
|
7814
|
+
function bindPackageSource(source, path, bindings) {
|
|
7815
|
+
bindings = bindings.filter(({ input }) => input.mode === "mapping");
|
|
7816
|
+
if (bindings.length === 0 || !/\.[jt]sx?$/.test(path)) {
|
|
7817
|
+
return source;
|
|
7818
|
+
}
|
|
7819
|
+
let ast;
|
|
7820
|
+
try {
|
|
7821
|
+
ast = parseSource(source, { jsx: path.endsWith("x") });
|
|
7822
|
+
} catch (error) {
|
|
7823
|
+
if (!(error instanceof SyntaxError)) {
|
|
7824
|
+
throw error;
|
|
7825
|
+
}
|
|
7826
|
+
return source;
|
|
7827
|
+
}
|
|
7828
|
+
const locals = /* @__PURE__ */ new Map();
|
|
7829
|
+
for (const node of ast.program.body) {
|
|
7830
|
+
if (node.type !== "ImportDeclaration") {
|
|
7831
|
+
continue;
|
|
7832
|
+
}
|
|
7833
|
+
for (const binding of bindings) {
|
|
7834
|
+
const kind = KINDS[binding.input.kind];
|
|
7835
|
+
const importedPath = resolveLocalSpecifierIn(GENERATED_PATHS, path, node.source.value);
|
|
7836
|
+
if (importedPath !== `generated/${kind.module}.ts`) {
|
|
7837
|
+
continue;
|
|
7838
|
+
}
|
|
7839
|
+
for (const specifier of node.specifiers) {
|
|
7840
|
+
if (specifier.type !== "ImportSpecifier" || (specifier.imported.name ?? specifier.imported.value) !== kind.exportName) {
|
|
7841
|
+
continue;
|
|
7842
|
+
}
|
|
7843
|
+
const names = locals.get(specifier.local.name) ?? /* @__PURE__ */ new Map();
|
|
7844
|
+
names.set(binding.input.name, binding.target.name);
|
|
7845
|
+
locals.set(specifier.local.name, names);
|
|
7846
|
+
}
|
|
7847
|
+
}
|
|
7848
|
+
}
|
|
7849
|
+
const edits = [];
|
|
7850
|
+
traverse3(ast, {
|
|
7851
|
+
TSQualifiedName(nodePath) {
|
|
7852
|
+
const node = nodePath.node;
|
|
7853
|
+
if (node.left.type !== "Identifier" || nodePath.scope.getBinding(node.left.name)?.kind !== "module" || !nodePath.findParent((parent) => parent.isTSTypeQuery())) {
|
|
7854
|
+
return;
|
|
7855
|
+
}
|
|
7856
|
+
const target = locals.get(node.left.name)?.get(node.right.name);
|
|
7857
|
+
if (target !== void 0) {
|
|
7858
|
+
edits.push({ start: node.right.start, end: node.right.end, text: target });
|
|
7859
|
+
}
|
|
7860
|
+
},
|
|
7861
|
+
"MemberExpression|OptionalMemberExpression"(nodePath) {
|
|
7862
|
+
const node = nodePath.node;
|
|
7863
|
+
if (node.object.type !== "Identifier" || nodePath.scope.getBinding(node.object.name)?.kind !== "module") {
|
|
7864
|
+
return;
|
|
7865
|
+
}
|
|
7866
|
+
const target = locals.get(node.object.name)?.get(memberPropertyName(node));
|
|
7867
|
+
if (target === void 0) {
|
|
7868
|
+
return;
|
|
7869
|
+
}
|
|
7870
|
+
edits.push({
|
|
7871
|
+
start: node.property.start,
|
|
7872
|
+
end: node.property.end,
|
|
7873
|
+
text: node.computed ? JSON.stringify(target) : target
|
|
7874
|
+
});
|
|
7875
|
+
}
|
|
7876
|
+
});
|
|
7877
|
+
for (const edit2 of edits.toSorted((a, b) => b.start - a.start)) {
|
|
7878
|
+
source = source.slice(0, edit2.start) + edit2.text + source.slice(edit2.end);
|
|
7879
|
+
}
|
|
7880
|
+
return source;
|
|
7881
|
+
}
|
|
7882
|
+
|
|
7883
|
+
// scripts/lib/runtime-build/page-seo.mjs
|
|
7884
|
+
var FLAT_SEO_KEYS = [
|
|
7885
|
+
["title", "title"],
|
|
7886
|
+
["description", "description"],
|
|
7887
|
+
["ogImage", "image"]
|
|
7888
|
+
];
|
|
7889
|
+
var SEO_KEYS = FLAT_SEO_KEYS.map(([, key]) => key);
|
|
7890
|
+
var PAGE_META_RESOLVERS = new Set(page_meta_resolvers_default);
|
|
7891
|
+
var PLACEHOLDER = /\{\{([^{}]+)\}\}/g;
|
|
7892
|
+
var FILE_ID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
7893
|
+
var TIPTAP_PARSE = "tiptap.parse";
|
|
7894
|
+
var FieldRead = class {
|
|
7895
|
+
constructor(binding, fields2, node) {
|
|
7896
|
+
this.binding = binding;
|
|
7897
|
+
this.fields = fields2;
|
|
7898
|
+
this.node = node;
|
|
7899
|
+
}
|
|
7900
|
+
get key() {
|
|
7901
|
+
return [this.binding, ...this.fields].join(".");
|
|
7902
|
+
}
|
|
7903
|
+
};
|
|
7904
|
+
function seoError(key, message, node) {
|
|
7905
|
+
return new SourceError(`seo.${key}: ${message}`, node);
|
|
7906
|
+
}
|
|
7907
|
+
function staticText(node) {
|
|
7908
|
+
if (node.type === "StringLiteral") {
|
|
7909
|
+
return node.value;
|
|
7910
|
+
}
|
|
7911
|
+
if (node.type === "TemplateLiteral" && node.expressions.length === 0) {
|
|
7912
|
+
return node.quasis[0].value.cooked;
|
|
7913
|
+
}
|
|
7914
|
+
return void 0;
|
|
7915
|
+
}
|
|
7916
|
+
function unwrap2(node) {
|
|
7917
|
+
return node.type === "TSAsExpression" || node.type === "TSSatisfiesExpression" || node.type === "TSNonNullExpression" || node.type === "ParenthesizedExpression" ? unwrap2(node.expression) : node;
|
|
7918
|
+
}
|
|
7919
|
+
function isResolver(value) {
|
|
5894
7920
|
return isPlainObject(value) && Object.hasOwn(value, "$type");
|
|
5895
7921
|
}
|
|
5896
7922
|
function hasResolver(value) {
|
|
@@ -7035,14 +9061,15 @@ function readLayoutOption(ast, source, path, property2, branchPaths) {
|
|
|
7035
9061
|
if (value.type === "NullLiteral") {
|
|
7036
9062
|
return null;
|
|
7037
9063
|
}
|
|
7038
|
-
const paths = new Set(branchPaths ?? []);
|
|
9064
|
+
const paths = new Set((branchPaths ?? []).filter((candidate) => vendorFile(candidate) === null));
|
|
9065
|
+
const providedPath = vendorFile(path)?.path ?? path;
|
|
7039
9066
|
const statement = value.type === "Identifier" ? layoutImportOf(ast, value.name) : null;
|
|
7040
9067
|
let target = null;
|
|
7041
9068
|
if (value.type === "StringLiteral") {
|
|
7042
9069
|
const named = `layouts/${value.value}.tsx`;
|
|
7043
9070
|
target = paths.has(named) ? named : null;
|
|
7044
9071
|
} else if (statement !== null) {
|
|
7045
|
-
target = resolveLocalSpecifierIn(paths,
|
|
9072
|
+
target = resolveLocalSpecifierIn(paths, providedPath, statement.source.value);
|
|
7046
9073
|
}
|
|
7047
9074
|
return {
|
|
7048
9075
|
read_only: true,
|
|
@@ -7058,8 +9085,33 @@ function layoutImportOf(ast, local) {
|
|
|
7058
9085
|
)
|
|
7059
9086
|
) ?? null;
|
|
7060
9087
|
}
|
|
7061
|
-
function readPageFile(path, source, resources, branchPaths = null, permissions = []) {
|
|
7062
|
-
return readPage(path, source,
|
|
9088
|
+
function readPageFile(path, source, resources, branchPaths = null, permissions = [], { resourceAliases = {}, permissionAliases = {} } = {}) {
|
|
9089
|
+
return readPage(path, source, pageResourceNames(resources, resourceAliases), branchPaths, pagePermissionEntries(permissions, permissionAliases));
|
|
9090
|
+
}
|
|
9091
|
+
function pagePermissionEntries(permissions, aliases) {
|
|
9092
|
+
const entries = declaredPermissionEntries(permissions);
|
|
9093
|
+
const known = new Set(permissions.map(({ uid }) => uid));
|
|
9094
|
+
for (const [name, uid] of Object.entries(aliases)) {
|
|
9095
|
+
if (uid !== null && !known.has(uid)) {
|
|
9096
|
+
throw new SourceError(`Unknown permission uid "${uid}" for Permissions.${name}`, null);
|
|
9097
|
+
}
|
|
9098
|
+
entries[name] = { uid };
|
|
9099
|
+
}
|
|
9100
|
+
return Object.assign(Object.fromEntries(Object.entries(aliases).map(([name, uid]) => [name, { uid }])), entries);
|
|
9101
|
+
}
|
|
9102
|
+
function pageResourceNames(resources, aliases) {
|
|
9103
|
+
const names = branchResourceNames(resources);
|
|
9104
|
+
for (const [name, slug] of Object.entries(aliases)) {
|
|
9105
|
+
if (!names.namesBySlug.has(slug)) {
|
|
9106
|
+
throw new SourceError(`Unknown resource slug "${slug}" for Resources.${name}`, null);
|
|
9107
|
+
}
|
|
9108
|
+
names.slugsByName.set(name, slug);
|
|
9109
|
+
}
|
|
9110
|
+
const namesBySlug = new Map([...names.slugsByName].map(([name, slug]) => [slug, name]));
|
|
9111
|
+
for (const [name, slug] of Object.entries(aliases)) {
|
|
9112
|
+
namesBySlug.set(slug, name);
|
|
9113
|
+
}
|
|
9114
|
+
return { ...names, namesBySlug, hasAliases: Object.keys(aliases).length > 0 };
|
|
7063
9115
|
}
|
|
7064
9116
|
function readResourceSlugs(files) {
|
|
7065
9117
|
return {
|
|
@@ -7125,8 +9177,44 @@ ${returned}`,
|
|
|
7125
9177
|
return { ok: false, diagnostic: diagnosticFromError(path, error) };
|
|
7126
9178
|
}
|
|
7127
9179
|
}
|
|
7128
|
-
function writePageFile(path, options, code, previous, resources, keep = [], { branchPaths = null, previousPath = null, permissions = [], imports: extraImports = [], sourceOptions = {} } = {}) {
|
|
9180
|
+
function writePageFile(path, options, code, previous, resources, keep = [], { branchPaths = null, previousPath = null, permissions = [], resourceAliases = {}, permissionAliases = {}, previousReferences = null, imports: extraImports = [], sourceOptions = {} } = {}) {
|
|
7129
9181
|
try {
|
|
9182
|
+
if (previous !== null && previousPath !== null && previousPath !== path && previousReferences !== null) {
|
|
9183
|
+
const names = branchResourceNames(resources).namesBySlug;
|
|
9184
|
+
const entries = declaredPermissionEntries(permissions);
|
|
9185
|
+
const bindings = [];
|
|
9186
|
+
const unresolved = [];
|
|
9187
|
+
for (const [name, slug] of Object.entries(previousReferences.resourceAliases)) {
|
|
9188
|
+
const target = names.get(slug);
|
|
9189
|
+
if (target === void 0) throw new SourceError(`Unknown resource slug "${slug}" in copied page`, null);
|
|
9190
|
+
bindings.push({ input: { mode: "mapping", kind: "resource", name }, target: { name: target } });
|
|
9191
|
+
}
|
|
9192
|
+
for (const [name, uid] of Object.entries(previousReferences.permissionAliases)) {
|
|
9193
|
+
if (uid === null) {
|
|
9194
|
+
unresolved.push({ input: { mode: "mapping", kind: "permission", name }, target: { name: `${name}_unresolved` } });
|
|
9195
|
+
continue;
|
|
9196
|
+
}
|
|
9197
|
+
const target = permissionUidReference(uid, entries);
|
|
9198
|
+
if (target === null) throw new SourceError(`Unknown permission uid "${uid}" in copied page`, null);
|
|
9199
|
+
bindings.push({ input: { mode: "mapping", kind: "permission", name }, target: { name: target.name } });
|
|
9200
|
+
}
|
|
9201
|
+
const authoringPath = vendorFile(previousPath)?.path ?? previousPath;
|
|
9202
|
+
const wrapped = `${importsOf(previous)}
|
|
9203
|
+
(function () {
|
|
9204
|
+
${code}
|
|
9205
|
+
});`;
|
|
9206
|
+
for (const source of [previous, wrapped]) {
|
|
9207
|
+
if (bindPackageSource(source, authoringPath, unresolved) !== source) {
|
|
9208
|
+
throw new SourceError("The copied page references a permission without a valid uid", null);
|
|
9209
|
+
}
|
|
9210
|
+
}
|
|
9211
|
+
const rebound = bindPackageSource(wrapped, authoringPath, bindings);
|
|
9212
|
+
const ast = parseSource(rebound, { jsx: true });
|
|
9213
|
+
const factory = ast.program.body.find((node) => node.type === "ExpressionStatement" && node.expression.type === "FunctionExpression")?.expression;
|
|
9214
|
+
if (factory === void 0) throw new SourceError("The copied page body could not be read", null);
|
|
9215
|
+
code = rebound.slice(factory.body.start + 1, factory.body.end - 1).trim();
|
|
9216
|
+
previous = bindPackageSource(previous, vendorFile(previousPath)?.path ?? previousPath, bindings);
|
|
9217
|
+
}
|
|
7130
9218
|
const parts = () => {
|
|
7131
9219
|
const { helpers, component } = splitFactoryBody(code);
|
|
7132
9220
|
let imports = previous === null ? [DEFAULT_IMPORT, ...extraImports].join("\n") : importsOf(previous);
|
|
@@ -7138,8 +9226,8 @@ function writePageFile(path, options, code, previous, resources, keep = [], { br
|
|
|
7138
9226
|
return writeParts(path, options, parts, {
|
|
7139
9227
|
previous,
|
|
7140
9228
|
readPath: previousPath ?? path,
|
|
7141
|
-
names:
|
|
7142
|
-
permissionEntries:
|
|
9229
|
+
names: pageResourceNames(resources, resourceAliases),
|
|
9230
|
+
permissionEntries: pagePermissionEntries(permissions, permissionAliases),
|
|
7143
9231
|
keep,
|
|
7144
9232
|
branchPaths,
|
|
7145
9233
|
sourceOptions,
|
|
@@ -7149,10 +9237,10 @@ function writePageFile(path, options, code, previous, resources, keep = [], { br
|
|
|
7149
9237
|
return { ok: false, diagnostic: diagnosticFromError(path, error) };
|
|
7150
9238
|
}
|
|
7151
9239
|
}
|
|
7152
|
-
function writeWholePageFile(path, file, options, resources, keep = [], { branchPaths = null, permissions = [], sourceOptions = {} } = {}) {
|
|
9240
|
+
function writeWholePageFile(path, file, options, resources, keep = [], { branchPaths = null, permissions = [], resourceAliases = {}, permissionAliases = {}, sourceOptions = {} } = {}) {
|
|
7153
9241
|
try {
|
|
7154
|
-
const names =
|
|
7155
|
-
const permissionEntries =
|
|
9242
|
+
const names = pageResourceNames(resources, resourceAliases);
|
|
9243
|
+
const permissionEntries = pagePermissionEntries(permissions, permissionAliases);
|
|
7156
9244
|
if (options === null) {
|
|
7157
9245
|
if (keep.length > 0 || Object.keys(sourceOptions).length > 0) {
|
|
7158
9246
|
throw new SourceError("A page file that is written as it is keeps no options", null);
|
|
@@ -7186,7 +9274,7 @@ function writeWholePageFile(path, file, options, resources, keep = [], { branchP
|
|
|
7186
9274
|
return { ok: false, diagnostic: diagnosticFromError(path, error) };
|
|
7187
9275
|
}
|
|
7188
9276
|
}
|
|
7189
|
-
function writePagePaused(path, source, paused, resources, { branchPaths = null, permissions = [] } = {}) {
|
|
9277
|
+
function writePagePaused(path, source, paused, resources, { branchPaths = null, permissions = [], resourceAliases = {}, permissionAliases = {} } = {}) {
|
|
7190
9278
|
try {
|
|
7191
9279
|
const ast = parseSource(source, { jsx: true });
|
|
7192
9280
|
const exportStatement = ast.program.body.find(
|
|
@@ -7218,9 +9306,9 @@ function writePagePaused(path, source, paused, resources, { branchPaths = null,
|
|
|
7218
9306
|
return checkedPage(
|
|
7219
9307
|
path,
|
|
7220
9308
|
written,
|
|
7221
|
-
|
|
9309
|
+
pageResourceNames(resources, resourceAliases),
|
|
7222
9310
|
branchPaths,
|
|
7223
|
-
|
|
9311
|
+
pagePermissionEntries(permissions, permissionAliases)
|
|
7224
9312
|
);
|
|
7225
9313
|
} catch (error) {
|
|
7226
9314
|
return { ok: false, diagnostic: diagnosticFromError(path, error) };
|
|
@@ -7258,7 +9346,7 @@ function writeParts(path, options, parts, { previous, readPath: readPath2, names
|
|
|
7258
9346
|
}
|
|
7259
9347
|
const binding = resourcesBinding(parseSource(imports, { jsx: false }), names);
|
|
7260
9348
|
const local = binding?.local ?? freeName("Resources", parseSource([imports, helpers, `(${component});`].join("\n"), { jsx: true }));
|
|
7261
|
-
const references2 = withResourceReferences(options, names
|
|
9349
|
+
const references2 = withResourceReferences(options, names, local, previous);
|
|
7262
9350
|
if (references2.used && binding === null) {
|
|
7263
9351
|
imports = `${imports}
|
|
7264
9352
|
${resourcesImport(local)}`;
|
|
@@ -7278,7 +9366,8 @@ ${domainsImport(domainsLocal)}`;
|
|
|
7278
9366
|
pageOptions.authorizer.permissions,
|
|
7279
9367
|
imports,
|
|
7280
9368
|
[helpers, `(${component});`].join("\n"),
|
|
7281
|
-
permissionEntries
|
|
9369
|
+
permissionEntries,
|
|
9370
|
+
previous
|
|
7282
9371
|
);
|
|
7283
9372
|
pageOptions = { ...pageOptions, authorizer: { ...pageOptions.authorizer, permissions: written2.permissions } };
|
|
7284
9373
|
imports = written2.imports;
|
|
@@ -7634,9 +9723,10 @@ function checkPageName(path, branchPaths) {
|
|
|
7634
9723
|
if (branchPaths === null) {
|
|
7635
9724
|
return;
|
|
7636
9725
|
}
|
|
7637
|
-
const
|
|
9726
|
+
const providedPath = vendorFile(path)?.path ?? path;
|
|
9727
|
+
const name = pageName(providedPath);
|
|
7638
9728
|
const other = branchPaths.find(
|
|
7639
|
-
(candidate) => candidate !==
|
|
9729
|
+
(candidate) => candidate !== providedPath && candidate.startsWith("pages/") && candidate.endsWith(".tsx") && pageName(candidate) === name
|
|
7640
9730
|
);
|
|
7641
9731
|
if (other !== void 0) {
|
|
7642
9732
|
throw new SourceError(
|
|
@@ -7706,13 +9796,38 @@ function domainReference(key, local) {
|
|
|
7706
9796
|
}
|
|
7707
9797
|
return new SourceExpression2(`${local}.${studlyName(key)}.key`);
|
|
7708
9798
|
}
|
|
7709
|
-
function
|
|
7710
|
-
|
|
7711
|
-
|
|
7712
|
-
|
|
7713
|
-
|
|
7714
|
-
|
|
7715
|
-
|
|
9799
|
+
function optionValueNode(object2, key) {
|
|
9800
|
+
const value = object2?.type === "ObjectExpression" ? object2 : object2?.expression;
|
|
9801
|
+
if (value?.type !== "ObjectExpression") {
|
|
9802
|
+
return null;
|
|
9803
|
+
}
|
|
9804
|
+
return value.properties.find(
|
|
9805
|
+
(entry2) => entry2.type === "ObjectProperty" && !entry2.computed && (entry2.key.name ?? entry2.key.value) === key
|
|
9806
|
+
)?.value ?? null;
|
|
9807
|
+
}
|
|
9808
|
+
function withPermissionReferences(permissions, imports, body, entries, previous) {
|
|
9809
|
+
let authored = [];
|
|
9810
|
+
if (previous !== null) {
|
|
9811
|
+
const ast = parseSource(previous, { jsx: true });
|
|
9812
|
+
const local = generatedBindingLocal(ast, "@app/generated/permissions", "Permissions");
|
|
9813
|
+
try {
|
|
9814
|
+
const { declaration } = defaultExportOf(ast, { helpers: "above", allowAppImports: true });
|
|
9815
|
+
const [options] = expectDefineCall(declaration, "definePage", 2);
|
|
9816
|
+
const nodes = optionValueNode(optionValueNode(options, "authorizer"), "permissions");
|
|
9817
|
+
authored = nodes?.type === "ArrayExpression" ? nodes.elements.map((node) => {
|
|
9818
|
+
const member = node?.type === "MemberExpression" && !node.computed && node.property.name === "uid" ? node.object : null;
|
|
9819
|
+
return member?.type === "MemberExpression" && !member.computed && member.object.type === "Identifier" && member.object.name === local ? member.property.name : null;
|
|
9820
|
+
}) : [];
|
|
9821
|
+
} catch (error) {
|
|
9822
|
+
if (!(error instanceof SourceError)) throw error;
|
|
9823
|
+
}
|
|
9824
|
+
}
|
|
9825
|
+
let result = imports;
|
|
9826
|
+
const locals = /* @__PURE__ */ new Map();
|
|
9827
|
+
const localOf = ({ module, exportName }) => {
|
|
9828
|
+
if (!locals.has(exportName)) {
|
|
9829
|
+
const bound = generatedBindingLocal(parseSource(result, { jsx: false }), module, exportName);
|
|
9830
|
+
const local = bound ?? freeName(exportName, parseSource([result, body].join("\n"), { jsx: true }));
|
|
7716
9831
|
if (bound === null) {
|
|
7717
9832
|
result = withNamedImport(result, module, exportName, local);
|
|
7718
9833
|
}
|
|
@@ -7720,29 +9835,61 @@ function withPermissionReferences(permissions, imports, body, entries) {
|
|
|
7720
9835
|
}
|
|
7721
9836
|
return locals.get(exportName);
|
|
7722
9837
|
};
|
|
7723
|
-
const written = permissions.map((uid) => {
|
|
9838
|
+
const written = permissions.map((uid, index) => {
|
|
7724
9839
|
const reference = typeof uid === "string" ? permissionUidReference(uid, entries) : null;
|
|
7725
|
-
|
|
9840
|
+
if (reference === null) return uid;
|
|
9841
|
+
const name = authored[index];
|
|
9842
|
+
const kept = typeof name === "string" && entries[name]?.uid === uid && reference.exportName === "Permissions";
|
|
9843
|
+
return new SourceExpression2(`${localOf(reference)}.${kept ? name : reference.name}.uid`);
|
|
7726
9844
|
});
|
|
7727
9845
|
return { permissions: written, imports: result };
|
|
7728
9846
|
}
|
|
7729
|
-
function withResourceReferences(options,
|
|
9847
|
+
function withResourceReferences(options, names, local, previous) {
|
|
9848
|
+
const { namesBySlug } = names;
|
|
9849
|
+
let previousOptions = null;
|
|
9850
|
+
let previousBinding = null;
|
|
9851
|
+
if (previous !== null && names.hasAliases) {
|
|
9852
|
+
const ast = parseSource(previous, { jsx: true });
|
|
9853
|
+
previousBinding = resourcesBinding(ast, names);
|
|
9854
|
+
try {
|
|
9855
|
+
const { declaration } = defaultExportOf(ast, { helpers: "above", allowAppImports: true });
|
|
9856
|
+
[previousOptions] = expectDefineCall(declaration, "definePage", 2);
|
|
9857
|
+
} catch (error) {
|
|
9858
|
+
if (!(error instanceof SourceError)) {
|
|
9859
|
+
throw error;
|
|
9860
|
+
}
|
|
9861
|
+
previousOptions = null;
|
|
9862
|
+
}
|
|
9863
|
+
}
|
|
7730
9864
|
let used = false;
|
|
7731
|
-
const reference = (slug) => {
|
|
9865
|
+
const reference = (slug, authored) => {
|
|
7732
9866
|
if (typeof slug !== "string" || !namesBySlug.has(slug)) {
|
|
7733
9867
|
return slug;
|
|
7734
9868
|
}
|
|
7735
9869
|
used = true;
|
|
9870
|
+
const member = authored?.type === "MemberExpression" && !authored.computed && authored.property.name === "slug" ? authored.object : null;
|
|
9871
|
+
if (member?.type === "MemberExpression" && !member.computed && member.object.type === "Identifier" && member.object.name === previousBinding?.local && names.slugsByName.get(member.property.name) === slug) {
|
|
9872
|
+
return new SourceExpression2(`${local}.${member.property.name}.slug`);
|
|
9873
|
+
}
|
|
7736
9874
|
return new SourceExpression2(`${local}.${namesBySlug.get(slug)}.slug`);
|
|
7737
9875
|
};
|
|
7738
|
-
const withResource = (value) => isPlainObject(value) && Object.hasOwn(value, "resource") ? { ...value, resource: reference(value.resource) } : value;
|
|
7739
|
-
const result = {
|
|
9876
|
+
const withResource = (value, authored) => isPlainObject(value) && Object.hasOwn(value, "resource") ? { ...value, resource: reference(value.resource, optionValueNode(authored, "resource")) } : value;
|
|
9877
|
+
const result = {
|
|
9878
|
+
...options,
|
|
9879
|
+
authorizer: withResource(options.authorizer, optionValueNode(previousOptions, "authorizer"))
|
|
9880
|
+
};
|
|
7740
9881
|
if (isPlainObject(options.bindings)) {
|
|
7741
9882
|
result.bindings = routeBindingsSource(
|
|
7742
9883
|
options.bindings,
|
|
7743
9884
|
String(options.route ?? "/"),
|
|
7744
9885
|
"bindings",
|
|
7745
|
-
|
|
9886
|
+
(slug) => slug
|
|
9887
|
+
);
|
|
9888
|
+
result.bindings = Object.fromEntries(
|
|
9889
|
+
Object.entries(result.bindings).map(([key, binding]) => [
|
|
9890
|
+
key,
|
|
9891
|
+
withResource(binding, optionValueNode(optionValueNode(previousOptions, "bindings"), key))
|
|
9892
|
+
])
|
|
7746
9893
|
);
|
|
7747
9894
|
}
|
|
7748
9895
|
return { options: result, used };
|
|
@@ -7798,12 +9945,24 @@ function sourceOptionsOf(value) {
|
|
|
7798
9945
|
}
|
|
7799
9946
|
return value;
|
|
7800
9947
|
}
|
|
7801
|
-
function contextOf(context) {
|
|
9948
|
+
function contextOf(context, path) {
|
|
7802
9949
|
if (context.previous_path !== void 0 && context.previous_path !== null && typeof context.previous_path !== "string") {
|
|
7803
9950
|
throw new SourceTransformRequestError("previous_path must be a string or null.");
|
|
7804
9951
|
}
|
|
9952
|
+
const packages = object(context.package_references ?? {}, "package_references");
|
|
9953
|
+
const packageName2 = vendorFile(path)?.name;
|
|
9954
|
+
const references2 = object((packageName2 === void 0 ? void 0 : packages[packageName2]) ?? {}, "package references");
|
|
9955
|
+
const resourceAliases = object(references2.resources ?? {}, "resource aliases");
|
|
9956
|
+
const permissionAliases = object(references2.permissions ?? {}, "permission aliases");
|
|
9957
|
+
for (const aliases of [resourceAliases, permissionAliases]) {
|
|
9958
|
+
if (Object.entries(aliases).some(([name, value]) => !/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(name) || !(typeof value === "string" || aliases === permissionAliases && value === null))) {
|
|
9959
|
+
throw new SourceTransformRequestError("Package references must map resource members to strings and permission members to strings or null.");
|
|
9960
|
+
}
|
|
9961
|
+
}
|
|
7805
9962
|
return {
|
|
7806
9963
|
resources: branchResources(context),
|
|
9964
|
+
resourceAliases,
|
|
9965
|
+
permissionAliases,
|
|
7807
9966
|
branchPaths: context.branch_paths == null ? null : strings(context.branch_paths, "branch_paths"),
|
|
7808
9967
|
keep: strings(context.keep ?? [], "keep"),
|
|
7809
9968
|
sourceOptions: sourceOptionsOf(context.source_options ?? {}),
|
|
@@ -7821,7 +9980,7 @@ function writeFile({ path, data, context }) {
|
|
|
7821
9980
|
if (data.options !== void 0 && data.options !== null) {
|
|
7822
9981
|
object(data.options, "options");
|
|
7823
9982
|
}
|
|
7824
|
-
const { resources, branchPaths, permissions, keep, sourceOptions } = contextOf(context);
|
|
9983
|
+
const { resources, resourceAliases, permissionAliases, branchPaths, permissions, keep, sourceOptions } = contextOf(context, path);
|
|
7825
9984
|
if ((keep.length || Object.keys(sourceOptions).length) && (data.options ?? null) === null) {
|
|
7826
9985
|
throw new SourceTransformRequestError("Keeping or writing page options requires options.");
|
|
7827
9986
|
}
|
|
@@ -7829,6 +9988,8 @@ function writeFile({ path, data, context }) {
|
|
|
7829
9988
|
writeWholePageFile(path, data.file, data.options ?? null, resources, keep, {
|
|
7830
9989
|
branchPaths,
|
|
7831
9990
|
permissions,
|
|
9991
|
+
resourceAliases,
|
|
9992
|
+
permissionAliases,
|
|
7832
9993
|
sourceOptions
|
|
7833
9994
|
})
|
|
7834
9995
|
).source;
|
|
@@ -7843,11 +10004,13 @@ function writePaused({ path, source, data, context }) {
|
|
|
7843
10004
|
if (typeof source !== "string") {
|
|
7844
10005
|
throw new SourceTransformRequestError("A pause write edits an existing page file.");
|
|
7845
10006
|
}
|
|
7846
|
-
const { resources, branchPaths, permissions } = contextOf(context);
|
|
10007
|
+
const { resources, resourceAliases, permissionAliases, branchPaths, permissions } = contextOf(context, path);
|
|
7847
10008
|
return checked(
|
|
7848
10009
|
writePagePaused(path, source, data.paused, resources, {
|
|
7849
10010
|
branchPaths,
|
|
7850
|
-
permissions
|
|
10011
|
+
permissions,
|
|
10012
|
+
resourceAliases,
|
|
10013
|
+
permissionAliases
|
|
7851
10014
|
})
|
|
7852
10015
|
).source;
|
|
7853
10016
|
}
|
|
@@ -7858,15 +10021,15 @@ function checked(result) {
|
|
|
7858
10021
|
return result;
|
|
7859
10022
|
}
|
|
7860
10023
|
var pageAdapter = Object.freeze({
|
|
7861
|
-
contextFields: ["resources", "resource_slugs", "branch_paths", "permissions", "keep", "previous_path", "source_options"],
|
|
10024
|
+
contextFields: ["resources", "resource_slugs", "branch_paths", "permissions", "keep", "previous_path", "package_references", "source_options"],
|
|
7862
10025
|
// `code` is the factory body of the page function, with `options`. `file` is
|
|
7863
10026
|
// the whole file, as the page builder edits it: it is written as it is, or
|
|
7864
10027
|
// with `options` in place of its own. `paused` alone writes only that option.
|
|
7865
10028
|
writeFields: ["options", "code", "file", "paused"],
|
|
7866
10029
|
accepts: (path) => /^pages\/.+\.tsx$/.test(path),
|
|
7867
10030
|
read({ path, source, context }) {
|
|
7868
|
-
const { resources, branchPaths, permissions } = contextOf(context);
|
|
7869
|
-
const { options, code, imports } = checked(readPageFile(path, source, resources, branchPaths, permissions));
|
|
10031
|
+
const { resources, resourceAliases, permissionAliases, branchPaths, permissions } = contextOf(context, path);
|
|
10032
|
+
const { options, code, imports } = checked(readPageFile(path, source, resources, branchPaths, permissions, { resourceAliases, permissionAliases }));
|
|
7870
10033
|
return { options, code, imports };
|
|
7871
10034
|
},
|
|
7872
10035
|
write({ path, source, data, context }) {
|
|
@@ -7880,7 +10043,7 @@ var pageAdapter = Object.freeze({
|
|
|
7880
10043
|
if (typeof data.code !== "string") {
|
|
7881
10044
|
throw new SourceTransformRequestError("code must be a string.");
|
|
7882
10045
|
}
|
|
7883
|
-
const { resources, branchPaths, permissions, keep, previousPath } = contextOf(context);
|
|
10046
|
+
const { resources, resourceAliases, permissionAliases, branchPaths, permissions, keep, previousPath } = contextOf(context, path);
|
|
7884
10047
|
if (keep.length && source === null) {
|
|
7885
10048
|
throw new SourceTransformRequestError("Keeping page options requires source.");
|
|
7886
10049
|
}
|
|
@@ -7888,7 +10051,10 @@ var pageAdapter = Object.freeze({
|
|
|
7888
10051
|
writePageFile(path, data.options, data.code, source, resources, keep, {
|
|
7889
10052
|
branchPaths,
|
|
7890
10053
|
previousPath,
|
|
7891
|
-
|
|
10054
|
+
previousReferences: contextOf(context, previousPath ?? path),
|
|
10055
|
+
permissions,
|
|
10056
|
+
resourceAliases,
|
|
10057
|
+
permissionAliases
|
|
7892
10058
|
})
|
|
7893
10059
|
).source;
|
|
7894
10060
|
},
|
|
@@ -9113,7 +11279,7 @@ var skillAdapter = Object.freeze({
|
|
|
9113
11279
|
});
|
|
9114
11280
|
|
|
9115
11281
|
// scripts/lib/runtime-build/test-suites.mjs
|
|
9116
|
-
import { basename, dirname } from "node:path";
|
|
11282
|
+
import { basename as basename2, dirname } from "node:path";
|
|
9117
11283
|
var TEST_SUITE_DEFINE = "defineTestSuite";
|
|
9118
11284
|
var TEST_DEFINE = "defineTest";
|
|
9119
11285
|
var TEST_FILE_PATTERN = /^tests\/[^/]+\/([^/]+)\.ts$/;
|
|
@@ -9215,7 +11381,7 @@ function readSuite(file, report) {
|
|
|
9215
11381
|
}
|
|
9216
11382
|
const read = readConfig(
|
|
9217
11383
|
node,
|
|
9218
|
-
{ allowed: SUITE_PROPERTIES, noun: "test suite", fallbackName:
|
|
11384
|
+
{ allowed: SUITE_PROPERTIES, noun: "test suite", fallbackName: basename2(dirname(file.path)) },
|
|
9219
11385
|
report
|
|
9220
11386
|
);
|
|
9221
11387
|
if (read === null) {
|
|
@@ -9294,7 +11460,7 @@ var DEFAULT_BROWSER_HANDLER = ` async test({ page, expect }) {
|
|
|
9294
11460
|
}`;
|
|
9295
11461
|
var BROWSER_HANDLER = "async test({ page, context, request, browser, expect })";
|
|
9296
11462
|
var WORKFLOW_SDKS = /* @__PURE__ */ new Set(["@diagonal/workflow", "@diagonal-hq/workflows/test"]);
|
|
9297
|
-
var
|
|
11463
|
+
var traverse4 = traverse.default ?? traverse;
|
|
9298
11464
|
function scriptParts(source, phase) {
|
|
9299
11465
|
if (typeof source !== "string") {
|
|
9300
11466
|
throw new SourceError(`"${phase}" must be a workflow module.`);
|
|
@@ -9312,7 +11478,7 @@ function scriptParts(source, phase) {
|
|
|
9312
11478
|
}
|
|
9313
11479
|
let globals;
|
|
9314
11480
|
let wrapperUsed;
|
|
9315
|
-
|
|
11481
|
+
traverse4(ast, {
|
|
9316
11482
|
Program(path) {
|
|
9317
11483
|
globals = Object.keys(path.scope.globals);
|
|
9318
11484
|
wrapperUsed = path.scope.getBinding(callee).referencePaths.some((reference) => reference.node !== call.callee);
|
|
@@ -9569,7 +11735,7 @@ var testSuiteAdapter = Object.freeze({
|
|
|
9569
11735
|
});
|
|
9570
11736
|
|
|
9571
11737
|
// scripts/lib/runtime-build/workflow-config-file.mjs
|
|
9572
|
-
import { basename as
|
|
11738
|
+
import { basename as basename3 } from "node:path";
|
|
9573
11739
|
var WORKFLOW_PATH = /^workflows\/[^/]+\.ts$/;
|
|
9574
11740
|
var HTTP_METHODS = ["GET", "POST", "PUT", "PATCH", "DELETE"];
|
|
9575
11741
|
var RECORD_EVENTS = ["created", "updated", "deleted", "restored", "saved"];
|
|
@@ -9831,7 +11997,7 @@ function referenceWriter(ast, resources, permissions) {
|
|
|
9831
11997
|
}
|
|
9832
11998
|
const name = pathName(
|
|
9833
11999
|
value.path,
|
|
9834
|
-
|
|
12000
|
+
basename3(withoutDevInfix(value.path), ".ts"),
|
|
9835
12001
|
{ exportName: WORKFLOWS_EXPORT, label: "workflow" },
|
|
9836
12002
|
[]
|
|
9837
12003
|
);
|
|
@@ -10523,7 +12689,7 @@ var workspaceDomainsAdapter = Object.freeze({
|
|
|
10523
12689
|
});
|
|
10524
12690
|
|
|
10525
12691
|
// scripts/lib/runtime-build/source-adapters/workspace-field.mjs
|
|
10526
|
-
import { basename as
|
|
12692
|
+
import { basename as basename4 } from "node:path";
|
|
10527
12693
|
var fields = ["uid", "key", "type", "label", "description", "guard", "settings", "section", "definition", "value"];
|
|
10528
12694
|
function entry(source) {
|
|
10529
12695
|
const node = defineWorkspaceFieldArgument(parseSource(source, { jsx: false }));
|
|
@@ -10579,7 +12745,7 @@ var workspaceFieldAdapter = Object.freeze({
|
|
|
10579
12745
|
const node = entry(source);
|
|
10580
12746
|
const uid = property(node, "uid");
|
|
10581
12747
|
const key = property(node, "key");
|
|
10582
|
-
const fieldKey = key ? staticValue(key.value) :
|
|
12748
|
+
const fieldKey = key ? staticValue(key.value) : basename4(path, ".ts");
|
|
10583
12749
|
const definition = property(node, "definition")?.value;
|
|
10584
12750
|
const { metadata } = readWorkspaceFieldDefinition(
|
|
10585
12751
|
fieldKey,
|
|
@@ -10736,6 +12902,7 @@ var SOURCE_ADAPTERS = Object.freeze({
|
|
|
10736
12902
|
"notification-type": notificationTypeAdapter,
|
|
10737
12903
|
"notification-template": notificationTemplateAdapter,
|
|
10738
12904
|
"notification-schedule": notificationScheduleAdapter,
|
|
12905
|
+
"package-inputs": packageInputsAdapter,
|
|
10739
12906
|
page: pageAdapter,
|
|
10740
12907
|
resource: resourceAdapter,
|
|
10741
12908
|
role: roleAdapter,
|
|
@@ -10967,229 +13134,26 @@ function transformField(op, path, source, data) {
|
|
|
10967
13134
|
return result;
|
|
10968
13135
|
}
|
|
10969
13136
|
|
|
10970
|
-
// scripts/lib/runtime-build/
|
|
10971
|
-
import { readFileSync } from "node:fs";
|
|
10972
|
-
import {
|
|
10973
|
-
var
|
|
10974
|
-
|
|
10975
|
-
|
|
10976
|
-
|
|
10977
|
-
|
|
10978
|
-
module: "permissions",
|
|
10979
|
-
exportName: "Permissions",
|
|
10980
|
-
argument: definePermissionArgument
|
|
10981
|
-
},
|
|
10982
|
-
workspace_field: {
|
|
10983
|
-
module: "workspace-fields",
|
|
10984
|
-
exportName: "WorkspaceFields",
|
|
10985
|
-
argument: defineWorkspaceFieldArgument
|
|
10986
|
-
}
|
|
10987
|
-
};
|
|
10988
|
-
var GENERATED_PATHS = new Set(Object.values(KINDS).map(({ module }) => `generated/${module}.ts`));
|
|
10989
|
-
function definitionKind(path) {
|
|
10990
|
-
if (isResourcePath(path)) {
|
|
10991
|
-
return "resource";
|
|
10992
|
-
}
|
|
10993
|
-
if (/^roles\/[^/]+\.ts$/.test(path)) {
|
|
10994
|
-
return "role";
|
|
10995
|
-
}
|
|
10996
|
-
if (/^permissions\/[^/]+\.ts$/.test(path)) {
|
|
10997
|
-
return "permission";
|
|
10998
|
-
}
|
|
10999
|
-
if (/^workspace-fields\/[^/]+\.ts$/.test(path)) {
|
|
11000
|
-
return "workspace_field";
|
|
11001
|
-
}
|
|
11002
|
-
return null;
|
|
11003
|
-
}
|
|
11004
|
-
function targetsByUid(root, sources) {
|
|
11005
|
-
const targets = /* @__PURE__ */ new Map();
|
|
11006
|
-
for (const { path, source } of sources) {
|
|
11007
|
-
const kind = definitionKind(path);
|
|
11008
|
-
if (kind === null) {
|
|
11009
|
-
continue;
|
|
13137
|
+
// scripts/lib/runtime-build/sdk-packages.mjs
|
|
13138
|
+
import { existsSync, readFileSync as readFileSync2 } from "node:fs";
|
|
13139
|
+
import { join as join3 } from "node:path";
|
|
13140
|
+
var DIAGONAL_PACKAGE = /^@diagonal(-hq)?\//;
|
|
13141
|
+
function readPackageFiles(root, diagnostics) {
|
|
13142
|
+
const read = (path) => {
|
|
13143
|
+
if (!existsSync(join3(root, path))) {
|
|
13144
|
+
return null;
|
|
11010
13145
|
}
|
|
11011
13146
|
try {
|
|
11012
|
-
|
|
11013
|
-
const uid = readUid(KINDS[kind].argument(ast));
|
|
11014
|
-
if (uid === null) {
|
|
11015
|
-
continue;
|
|
11016
|
-
}
|
|
11017
|
-
const key = `${kind}:${uid}`;
|
|
11018
|
-
const folder = kind === "resource" ? resourceFolderOf(path) : null;
|
|
11019
|
-
const name = studlyName(folder ?? basename4(withoutDevInfix(path), ".ts"));
|
|
11020
|
-
const entries = targets.get(key) ?? [];
|
|
11021
|
-
entries.push({ kind, uid, name, path, folder });
|
|
11022
|
-
targets.set(key, entries);
|
|
13147
|
+
return JSON.parse(readFileSync2(join3(root, path), "utf8"));
|
|
11023
13148
|
} catch (error) {
|
|
11024
|
-
if (!(error instanceof
|
|
13149
|
+
if (!(error instanceof SyntaxError)) {
|
|
11025
13150
|
throw error;
|
|
11026
13151
|
}
|
|
13152
|
+
diagnostics.push(diagnosticAt(path, null, `${path} is not valid JSON: ${error.message}`));
|
|
13153
|
+
return null;
|
|
11027
13154
|
}
|
|
11028
|
-
}
|
|
11029
|
-
return
|
|
11030
|
-
}
|
|
11031
|
-
function resolvePackageInputBindings(root, workspaceManifest, choices, candidates, workspaceFiles, diagnostics) {
|
|
11032
|
-
const bindings = /* @__PURE__ */ new Map();
|
|
11033
|
-
const problem2 = (message) => diagnostics.push(diagnosticAt("diagonal.config.ts", null, message));
|
|
11034
|
-
const sources = [...workspaceFiles].map((path) => ({ path, source: path }));
|
|
11035
|
-
for (const { owned } of candidates) {
|
|
11036
|
-
for (const [path, source] of owned) {
|
|
11037
|
-
if (!isDevPath(path)) {
|
|
11038
|
-
sources.push({ path, source });
|
|
11039
|
-
}
|
|
11040
|
-
}
|
|
11041
|
-
}
|
|
11042
|
-
let targets = null;
|
|
11043
|
-
const names = new Set(candidates.map(({ name }) => name));
|
|
11044
|
-
for (const name of Object.keys(choices)) {
|
|
11045
|
-
if (!names.has(name)) {
|
|
11046
|
-
problem2(`Package input choices name the unavailable package "${name}"`);
|
|
11047
|
-
}
|
|
11048
|
-
}
|
|
11049
|
-
for (const { name, manifest, owned } of candidates) {
|
|
11050
|
-
const inputs = manifest.diagonal.requirements?.inputs ?? [];
|
|
11051
|
-
const selected = Object.hasOwn(choices, name) ? choices[name] : {};
|
|
11052
|
-
const resolved = [];
|
|
11053
|
-
bindings.set(name, resolved);
|
|
11054
|
-
if (!Array.isArray(inputs) || !isPlainObject(selected)) {
|
|
11055
|
-
problem2(`Package "${name}" must have an input list and an object of choices`);
|
|
11056
|
-
continue;
|
|
11057
|
-
}
|
|
11058
|
-
const known = /* @__PURE__ */ new Set();
|
|
11059
|
-
for (const input of inputs) {
|
|
11060
|
-
if (!isPlainObject(input) || !Object.hasOwn(KINDS, input.kind) || !isUid(input.uid) || !["mapping", "value"].includes(input.mode) || input.mode === "mapping" && typeof input.name !== "string") {
|
|
11061
|
-
problem2(`Package "${name}" has an invalid input descriptor`);
|
|
11062
|
-
continue;
|
|
11063
|
-
}
|
|
11064
|
-
const key = `${input.kind}:${input.uid}`;
|
|
11065
|
-
if (known.has(key)) {
|
|
11066
|
-
problem2(`Package "${name}" declares input "${key}" more than once`);
|
|
11067
|
-
continue;
|
|
11068
|
-
}
|
|
11069
|
-
known.add(key);
|
|
11070
|
-
if (input.mode === "value") {
|
|
11071
|
-
const source = owned.get(input.path);
|
|
11072
|
-
if (source === void 0) {
|
|
11073
|
-
problem2(`Package "${name}" input "${key}" has no field source.`);
|
|
11074
|
-
continue;
|
|
11075
|
-
}
|
|
11076
|
-
if (source.startsWith(`vendor/${name}/`) && workspaceManifest?.dependencies?.[name]?.startsWith("file:") !== true) {
|
|
11077
|
-
problem2(
|
|
11078
|
-
`Package "${name}" input "${key}" also has a vendor field copy. Remove that copy and set the value in diagonal.config.ts packages.`
|
|
11079
|
-
);
|
|
11080
|
-
continue;
|
|
11081
|
-
}
|
|
11082
|
-
try {
|
|
11083
|
-
validatePackageFieldSource(input, readFileSync(join2(root, source), "utf8"));
|
|
11084
|
-
resolved.push({ input, selected: resolvePackageFieldInput(input, selected[key]) });
|
|
11085
|
-
} catch (error) {
|
|
11086
|
-
if (!(error instanceof SourceError)) throw error;
|
|
11087
|
-
problem2(`Package "${name}": ${error.message}`);
|
|
11088
|
-
}
|
|
11089
|
-
continue;
|
|
11090
|
-
}
|
|
11091
|
-
const targetUid = selected[key];
|
|
11092
|
-
if (!isUid(targetUid)) {
|
|
11093
|
-
problem2(
|
|
11094
|
-
`Choose a ${input.kind} for package "${name}" input "${input.name}" (${key})`
|
|
11095
|
-
);
|
|
11096
|
-
continue;
|
|
11097
|
-
}
|
|
11098
|
-
targets ??= targetsByUid(root, sources);
|
|
11099
|
-
const matches = targets.get(`${input.kind}:${targetUid}`) ?? [];
|
|
11100
|
-
if (matches.length !== 1) {
|
|
11101
|
-
problem2(
|
|
11102
|
-
`Package "${name}" input "${input.name}" does not name a unique ${input.kind} in this workspace`
|
|
11103
|
-
);
|
|
11104
|
-
continue;
|
|
11105
|
-
}
|
|
11106
|
-
resolved.push({ input, target: matches[0] });
|
|
11107
|
-
}
|
|
11108
|
-
for (const key of Object.keys(selected)) {
|
|
11109
|
-
if (!known.has(key)) {
|
|
11110
|
-
problem2(`Package "${name}" has no input "${key}"`);
|
|
11111
|
-
}
|
|
11112
|
-
}
|
|
11113
|
-
}
|
|
11114
|
-
return bindings;
|
|
11115
|
-
}
|
|
11116
|
-
function boundPackagePath(path, bindings) {
|
|
11117
|
-
const child = resourceChildOf(path);
|
|
11118
|
-
if (child?.kind !== "resource_field") {
|
|
11119
|
-
return path;
|
|
11120
|
-
}
|
|
11121
|
-
const binding = bindings.find(
|
|
11122
|
-
({ input }) => input.kind === "resource" && input.name === studlyName(child.folder)
|
|
11123
|
-
);
|
|
11124
|
-
return binding === void 0 ? path : path.replace(`resources/${child.folder}/`, `resources/${binding.target.folder}/`);
|
|
11125
|
-
}
|
|
11126
|
-
function bindPackageSource(source, path, bindings) {
|
|
11127
|
-
bindings = bindings.filter(({ input }) => input.mode === "mapping");
|
|
11128
|
-
if (bindings.length === 0 || !/\.[jt]sx?$/.test(path)) {
|
|
11129
|
-
return source;
|
|
11130
|
-
}
|
|
11131
|
-
let ast;
|
|
11132
|
-
try {
|
|
11133
|
-
ast = parseSource(source, { jsx: path.endsWith("x") });
|
|
11134
|
-
} catch (error) {
|
|
11135
|
-
if (!(error instanceof SyntaxError)) {
|
|
11136
|
-
throw error;
|
|
11137
|
-
}
|
|
11138
|
-
return source;
|
|
11139
|
-
}
|
|
11140
|
-
const locals = /* @__PURE__ */ new Map();
|
|
11141
|
-
for (const node of ast.program.body) {
|
|
11142
|
-
if (node.type !== "ImportDeclaration") {
|
|
11143
|
-
continue;
|
|
11144
|
-
}
|
|
11145
|
-
for (const binding of bindings) {
|
|
11146
|
-
const kind = KINDS[binding.input.kind];
|
|
11147
|
-
const importedPath = resolveLocalSpecifierIn(GENERATED_PATHS, path, node.source.value);
|
|
11148
|
-
if (importedPath !== `generated/${kind.module}.ts`) {
|
|
11149
|
-
continue;
|
|
11150
|
-
}
|
|
11151
|
-
for (const specifier of node.specifiers) {
|
|
11152
|
-
if (specifier.type !== "ImportSpecifier" || (specifier.imported.name ?? specifier.imported.value) !== kind.exportName) {
|
|
11153
|
-
continue;
|
|
11154
|
-
}
|
|
11155
|
-
const names = locals.get(specifier.local.name) ?? /* @__PURE__ */ new Map();
|
|
11156
|
-
names.set(binding.input.name, binding.target.name);
|
|
11157
|
-
locals.set(specifier.local.name, names);
|
|
11158
|
-
}
|
|
11159
|
-
}
|
|
11160
|
-
}
|
|
11161
|
-
const edits = [];
|
|
11162
|
-
traverse4(ast, {
|
|
11163
|
-
TSQualifiedName(nodePath) {
|
|
11164
|
-
const node = nodePath.node;
|
|
11165
|
-
if (node.left.type !== "Identifier" || nodePath.scope.getBinding(node.left.name)?.kind !== "module" || !nodePath.findParent((parent) => parent.isTSTypeQuery())) {
|
|
11166
|
-
return;
|
|
11167
|
-
}
|
|
11168
|
-
const target = locals.get(node.left.name)?.get(node.right.name);
|
|
11169
|
-
if (target !== void 0) {
|
|
11170
|
-
edits.push({ start: node.right.start, end: node.right.end, text: target });
|
|
11171
|
-
}
|
|
11172
|
-
},
|
|
11173
|
-
"MemberExpression|OptionalMemberExpression"(nodePath) {
|
|
11174
|
-
const node = nodePath.node;
|
|
11175
|
-
if (node.object.type !== "Identifier" || nodePath.scope.getBinding(node.object.name)?.kind !== "module") {
|
|
11176
|
-
return;
|
|
11177
|
-
}
|
|
11178
|
-
const target = locals.get(node.object.name)?.get(memberPropertyName(node));
|
|
11179
|
-
if (target === void 0) {
|
|
11180
|
-
return;
|
|
11181
|
-
}
|
|
11182
|
-
edits.push({
|
|
11183
|
-
start: node.property.start,
|
|
11184
|
-
end: node.property.end,
|
|
11185
|
-
text: node.computed ? JSON.stringify(target) : target
|
|
11186
|
-
});
|
|
11187
|
-
}
|
|
11188
|
-
});
|
|
11189
|
-
for (const edit2 of edits.toSorted((a, b) => b.start - a.start)) {
|
|
11190
|
-
source = source.slice(0, edit2.start) + edit2.text + source.slice(edit2.end);
|
|
11191
|
-
}
|
|
11192
|
-
return source;
|
|
13155
|
+
};
|
|
13156
|
+
return { manifest: read("package.json"), lock: read("package-lock.json") };
|
|
11193
13157
|
}
|
|
11194
13158
|
|
|
11195
13159
|
// scripts/lib/runtime-build/installed-packages.mjs
|
|
@@ -11197,60 +13161,74 @@ var DIAGONAL_PACKAGE_FIELD = "diagonal";
|
|
|
11197
13161
|
var WORKSPACE_ONLY_FILES = /* @__PURE__ */ new Set(["diagonal.config.ts", "assets.ts", "redirects.ts"]);
|
|
11198
13162
|
var ROOT_MODULE_EXTENSIONS = [...SOURCE_EXTENSIONS, ".css"];
|
|
11199
13163
|
var SKIPPED_DIRECTORIES = /* @__PURE__ */ new Set(["vendor", "generated"]);
|
|
11200
|
-
var
|
|
13164
|
+
var PACKAGE_NAME2 = new RegExp(package_rules_default.package_name);
|
|
13165
|
+
var DEPENDENCY_FIELDS = ["dependencies", "devDependencies", "peerDependencies", "optionalDependencies"];
|
|
11201
13166
|
function composePackages(root) {
|
|
13167
|
+
const sourceDiagnostics = packageInputDiagnostics(root);
|
|
11202
13168
|
const diagnostics = [];
|
|
11203
13169
|
const packages = [];
|
|
11204
13170
|
const files = /* @__PURE__ */ new Map();
|
|
11205
13171
|
const dependencies = /* @__PURE__ */ new Set();
|
|
11206
|
-
const manifest = readJson(
|
|
11207
|
-
const declared = Object.entries(manifest?.dependencies ?? {}).filter(([name, specifier]) =>
|
|
13172
|
+
const manifest = readJson(join4(root, "package.json"));
|
|
13173
|
+
const declared = Object.entries(manifest?.dependencies ?? {}).filter(([name, specifier]) => PACKAGE_NAME2.test(name) && typeof specifier === "string").toSorted(([left], [right]) => left < right ? -1 : left > right ? 1 : 0);
|
|
13174
|
+
const overridePaths = isDirectory(join4(root, "vendor")) ? listCheckoutFiles(join4(root, "vendor"), /* @__PURE__ */ new Set()).map((path) => `vendor/${path}`) : [];
|
|
13175
|
+
const localSources = overridePaths.length === 0 ? /* @__PURE__ */ new Set() : localPackageSources(root, manifest);
|
|
11208
13176
|
let choices = {};
|
|
11209
|
-
const configPath =
|
|
11210
|
-
if (
|
|
13177
|
+
const configPath = join4(root, "diagonal.config.ts");
|
|
13178
|
+
if (existsSync2(configPath)) {
|
|
11211
13179
|
try {
|
|
11212
|
-
choices = readConfigPackages(
|
|
13180
|
+
choices = readConfigPackages(readFileSync3(configPath, "utf8"));
|
|
11213
13181
|
} catch (error) {
|
|
11214
13182
|
if (!(error instanceof SourceError || error instanceof SyntaxError)) throw error;
|
|
11215
13183
|
diagnostics.push(diagnosticFromError("diagonal.config.ts", error));
|
|
11216
|
-
return { packages, files, dependencies, diagnostics, bindings: /* @__PURE__ */ new Map() };
|
|
13184
|
+
return { packages, files, dependencies, diagnostics, sourceDiagnostics, bindings: /* @__PURE__ */ new Map() };
|
|
11217
13185
|
}
|
|
11218
13186
|
}
|
|
11219
|
-
if (declared.length === 0 && Object.keys(choices).length === 0) {
|
|
11220
|
-
return { packages, files, dependencies, diagnostics, bindings: /* @__PURE__ */ new Map() };
|
|
13187
|
+
if (declared.length === 0 && Object.keys(choices).length === 0 && overridePaths.length === 0) {
|
|
13188
|
+
return { packages, files, dependencies, diagnostics, sourceDiagnostics, bindings: /* @__PURE__ */ new Map() };
|
|
11221
13189
|
}
|
|
11222
13190
|
const workspaceFiles = new Set(listCheckoutFiles(root, /* @__PURE__ */ new Set(["vendor"])));
|
|
11223
13191
|
const candidates = [];
|
|
11224
|
-
|
|
11225
|
-
|
|
11226
|
-
const
|
|
13192
|
+
const ordinary = /* @__PURE__ */ new Set();
|
|
13193
|
+
for (const [name] of declared) {
|
|
13194
|
+
const installed = join4(root, "node_modules", name);
|
|
13195
|
+
const overrides = join4(root, "vendor", name);
|
|
11227
13196
|
const hasOverrides = isDirectory(overrides);
|
|
11228
|
-
const installedManifest = readJson(
|
|
13197
|
+
const installedManifest = readJson(join4(installed, "package.json"));
|
|
11229
13198
|
if (installedManifest === null) {
|
|
11230
|
-
if (
|
|
11231
|
-
|
|
11232
|
-
|
|
11233
|
-
`vendor/${name}`,
|
|
11234
|
-
null,
|
|
11235
|
-
`vendor/${name} changes the files of the package "${name}", which is not installed. Run npm install`
|
|
11236
|
-
)
|
|
11237
|
-
);
|
|
13199
|
+
if (!DIAGONAL_PACKAGE.test(name)) {
|
|
13200
|
+
const problem2 = diagnosticAt("package.json", null, `The dependency "${name}" is missing or has an invalid installed package.json. Run npm install with a valid lockfile`);
|
|
13201
|
+
sourceDiagnostics.push({ ...problem2, code: "package_dependency_unavailable" });
|
|
11238
13202
|
}
|
|
11239
13203
|
continue;
|
|
11240
13204
|
}
|
|
13205
|
+
sourceDiagnostics.push(...manifestInputDiagnostics(installedManifest, `node_modules/${name}/package.json`));
|
|
11241
13206
|
if (!isDiagonalPackage(installedManifest)) {
|
|
13207
|
+
ordinary.add(name);
|
|
11242
13208
|
continue;
|
|
11243
13209
|
}
|
|
11244
13210
|
const owned = /* @__PURE__ */ new Map();
|
|
13211
|
+
const upstream = /* @__PURE__ */ new Set();
|
|
11245
13212
|
for (const path of listCheckoutFiles(installed, SKIPPED_DIRECTORIES)) {
|
|
11246
13213
|
owned.set(path, `node_modules/${name}/${path}`);
|
|
13214
|
+
upstream.add(path);
|
|
11247
13215
|
}
|
|
11248
13216
|
if (hasOverrides) {
|
|
11249
13217
|
for (const path of listCheckoutFiles(overrides, SKIPPED_DIRECTORIES)) {
|
|
11250
13218
|
owned.set(path, `vendor/${name}/${path}`);
|
|
11251
13219
|
}
|
|
11252
13220
|
}
|
|
11253
|
-
candidates.push({ name, manifest: installedManifest, owned });
|
|
13221
|
+
candidates.push({ name, manifest: installedManifest, owned, upstream });
|
|
13222
|
+
}
|
|
13223
|
+
const installedNames = new Set(candidates.map(({ name }) => name));
|
|
13224
|
+
const declaredNames = new Set(declared.map(([name]) => name));
|
|
13225
|
+
for (const path of overridePaths) {
|
|
13226
|
+
const name = vendorFile(path)?.name;
|
|
13227
|
+
if (name === void 0 || installedNames.has(name) || [...localSources].some((source) => path === source || path.startsWith(`${source}/`))) {
|
|
13228
|
+
continue;
|
|
13229
|
+
}
|
|
13230
|
+
const message = ordinary.has(name) ? `vendor/${name} changes a dependency that is not a Diagonal package. Remove these overrides or install a Diagonal package` : declaredNames.has(name) ? `vendor/${name} changes the files of the package "${name}", which is not installed. Run npm install` : `The package "${name}" is not declared. Add it to package.json or remove vendor/${name}`;
|
|
13231
|
+
diagnostics.push(diagnosticAt(path, null, message));
|
|
11254
13232
|
}
|
|
11255
13233
|
diagnostics.push(...packageRequirementProblems(candidates));
|
|
11256
13234
|
const bindings = resolvePackageInputBindings(
|
|
@@ -11261,7 +13239,7 @@ function composePackages(root) {
|
|
|
11261
13239
|
workspaceFiles,
|
|
11262
13240
|
diagnostics
|
|
11263
13241
|
);
|
|
11264
|
-
for (const { name, manifest: installedManifest, owned } of candidates) {
|
|
13242
|
+
for (const { name, manifest: installedManifest, owned, upstream } of candidates) {
|
|
11265
13243
|
const packageFiles = [];
|
|
11266
13244
|
const selected = bindings.get(name) ?? [];
|
|
11267
13245
|
for (const [originalPath, source] of owned) {
|
|
@@ -11295,7 +13273,7 @@ function composePackages(root) {
|
|
|
11295
13273
|
);
|
|
11296
13274
|
continue;
|
|
11297
13275
|
}
|
|
11298
|
-
files.set(path, { name, source });
|
|
13276
|
+
files.set(path, { name, source, authoringPath: originalPath, upstream: upstream.has(originalPath) ? `node_modules/${name}/${originalPath}` : null });
|
|
11299
13277
|
packageFiles.push({ path, source });
|
|
11300
13278
|
}
|
|
11301
13279
|
const packageDependencies = /* @__PURE__ */ new Set();
|
|
@@ -11313,7 +13291,123 @@ function composePackages(root) {
|
|
|
11313
13291
|
});
|
|
11314
13292
|
}
|
|
11315
13293
|
diagnostics.push(...resourceOwnershipProblems(files));
|
|
11316
|
-
return { packages, files, dependencies, diagnostics, bindings };
|
|
13294
|
+
return { packages, files, dependencies, diagnostics, sourceDiagnostics, bindings };
|
|
13295
|
+
}
|
|
13296
|
+
function packageInputDiagnostics(root) {
|
|
13297
|
+
const files = /* @__PURE__ */ new Map();
|
|
13298
|
+
for (const path of ["package.json", "package-lock.json", "npm-shrinkwrap.json"]) {
|
|
13299
|
+
if (existsSync2(join4(root, path))) files.set(path, readFileSync3(join4(root, path), "utf8"));
|
|
13300
|
+
}
|
|
13301
|
+
return packageInputDiagnosticsFromFiles(files);
|
|
13302
|
+
}
|
|
13303
|
+
function packageInputDiagnosticsFromFiles(files) {
|
|
13304
|
+
const diagnostics = [];
|
|
13305
|
+
for (const path of ["package.json", "package-lock.json", "npm-shrinkwrap.json"]) {
|
|
13306
|
+
if (!files.has(path)) continue;
|
|
13307
|
+
let value;
|
|
13308
|
+
try {
|
|
13309
|
+
value = JSON.parse(files.get(path));
|
|
13310
|
+
} catch (error) {
|
|
13311
|
+
if (!(error instanceof SyntaxError)) throw error;
|
|
13312
|
+
value = null;
|
|
13313
|
+
}
|
|
13314
|
+
if (!isPlainObject(value)) {
|
|
13315
|
+
diagnostics.push(diagnosticAt(path, null, `${path} must contain a valid JSON object`));
|
|
13316
|
+
continue;
|
|
13317
|
+
}
|
|
13318
|
+
if (path === "package.json") {
|
|
13319
|
+
diagnostics.push(...manifestInputDiagnostics(value, path));
|
|
13320
|
+
continue;
|
|
13321
|
+
}
|
|
13322
|
+
if (path !== "package.json" && (!files.has("package.json") || ![1, 2, 3].includes(value.lockfileVersion) || value.lockfileVersion >= 2 && !isPlainObject(value.packages) || isPlainObject(value.packages) && Object.values(value.packages).some((entry2) => !isPlainObject(entry2)) || !validLockDependencies(value))) {
|
|
13323
|
+
diagnostics.push(diagnosticAt(path, null, `${path} has an invalid npm lockfile structure`));
|
|
13324
|
+
continue;
|
|
13325
|
+
}
|
|
13326
|
+
if (value.packages !== void 0 && !isPlainObject(value.packages)) {
|
|
13327
|
+
diagnostics.push(diagnosticAt(path, null, `${path} has an invalid packages object`));
|
|
13328
|
+
}
|
|
13329
|
+
if (value.lockfileVersion >= 2) {
|
|
13330
|
+
for (const entry2 of Object.values(value.packages)) {
|
|
13331
|
+
diagnostics.push(...manifestInputDiagnostics(entry2, path));
|
|
13332
|
+
}
|
|
13333
|
+
}
|
|
13334
|
+
}
|
|
13335
|
+
return diagnostics;
|
|
13336
|
+
}
|
|
13337
|
+
function validLockDependencies(lock) {
|
|
13338
|
+
const pending = [lock];
|
|
13339
|
+
let count = 0;
|
|
13340
|
+
for (const value of pending) {
|
|
13341
|
+
if (value.dependencies === void 0) continue;
|
|
13342
|
+
if (!isPlainObject(value.dependencies)) return false;
|
|
13343
|
+
for (const [name, dependency] of Object.entries(value.dependencies)) {
|
|
13344
|
+
count++;
|
|
13345
|
+
if (count > MAX_SOURCE_FILES || !validDependencyName(name) || !isPlainObject(dependency)) return false;
|
|
13346
|
+
pending.push(dependency);
|
|
13347
|
+
}
|
|
13348
|
+
}
|
|
13349
|
+
return true;
|
|
13350
|
+
}
|
|
13351
|
+
function validDependencyName(name) {
|
|
13352
|
+
if (name === "" || !name.isWellFormed()) return false;
|
|
13353
|
+
try {
|
|
13354
|
+
import_npm_package_arg.default.resolve(name, "*");
|
|
13355
|
+
return true;
|
|
13356
|
+
} catch (error) {
|
|
13357
|
+
if (error.code !== "EINVALIDPACKAGENAME") throw error;
|
|
13358
|
+
return false;
|
|
13359
|
+
}
|
|
13360
|
+
}
|
|
13361
|
+
function manifestInputDiagnostics(value, path) {
|
|
13362
|
+
const diagnostics = [];
|
|
13363
|
+
for (const field of DEPENDENCY_FIELDS) {
|
|
13364
|
+
if (value[field] === void 0) continue;
|
|
13365
|
+
if (!isPlainObject(value[field]) || Object.entries(value[field]).some(([name, specifier]) => !validDependencyName(name) || typeof specifier !== "string" || specifier === "")) {
|
|
13366
|
+
diagnostics.push(diagnosticAt(path, null, `${path} has an invalid ${field} object`));
|
|
13367
|
+
}
|
|
13368
|
+
}
|
|
13369
|
+
if (value.diagonal !== void 0 && !isPlainObject(value.diagonal)) {
|
|
13370
|
+
diagnostics.push(diagnosticAt(path, null, `${path} has an invalid diagonal object`));
|
|
13371
|
+
}
|
|
13372
|
+
return diagnostics;
|
|
13373
|
+
}
|
|
13374
|
+
function localPackageDirectory(specifier, directory) {
|
|
13375
|
+
if (typeof specifier !== "string") {
|
|
13376
|
+
return null;
|
|
13377
|
+
}
|
|
13378
|
+
let dependency;
|
|
13379
|
+
try {
|
|
13380
|
+
dependency = import_npm_package_arg.default.resolve(null, specifier, directory);
|
|
13381
|
+
} catch (error) {
|
|
13382
|
+
if (!(error instanceof Error)) {
|
|
13383
|
+
throw error;
|
|
13384
|
+
}
|
|
13385
|
+
return null;
|
|
13386
|
+
}
|
|
13387
|
+
return dependency.type === "directory" ? dependency.fetchSpec : null;
|
|
13388
|
+
}
|
|
13389
|
+
function localPackageSources(root, manifest = readJson(join4(root, "package.json")), readManifest = (directory) => readJson(join4(directory, "package.json"))) {
|
|
13390
|
+
const paths = /* @__PURE__ */ new Set();
|
|
13391
|
+
const visited = /* @__PURE__ */ new Set([root]);
|
|
13392
|
+
const pending = [{ directory: root, manifest }];
|
|
13393
|
+
for (const entry2 of pending) {
|
|
13394
|
+
for (const field of ["dependencies", "devDependencies", "optionalDependencies", "peerDependencies"]) {
|
|
13395
|
+
for (const specifier of Object.values(entry2.manifest?.[field] ?? {})) {
|
|
13396
|
+
const directory = localPackageDirectory(specifier, entry2.directory);
|
|
13397
|
+
if (directory === null) {
|
|
13398
|
+
continue;
|
|
13399
|
+
}
|
|
13400
|
+
const path = relative2(root, directory);
|
|
13401
|
+
if (visited.has(directory) || path === ".." || path.startsWith(`..${sep2}`) || isAbsolute(path)) {
|
|
13402
|
+
continue;
|
|
13403
|
+
}
|
|
13404
|
+
visited.add(directory);
|
|
13405
|
+
paths.add(path.split(sep2).join("/"));
|
|
13406
|
+
pending.push({ directory, manifest: readManifest(directory) });
|
|
13407
|
+
}
|
|
13408
|
+
}
|
|
13409
|
+
}
|
|
13410
|
+
return paths;
|
|
11317
13411
|
}
|
|
11318
13412
|
function resourceOwnershipProblems(files) {
|
|
11319
13413
|
const diagnostics = [];
|
|
@@ -11341,12 +13435,12 @@ function packageRequirementProblems(candidates) {
|
|
|
11341
13435
|
if (required === void 0) {
|
|
11342
13436
|
continue;
|
|
11343
13437
|
}
|
|
11344
|
-
if (!
|
|
13438
|
+
if (!isPlainObject(required)) {
|
|
11345
13439
|
diagnostics.push(diagnosticAt("package.json", null, `The package "${name}" has invalid published package requirements.`));
|
|
11346
13440
|
continue;
|
|
11347
13441
|
}
|
|
11348
13442
|
for (const [dependency, range] of Object.entries(required)) {
|
|
11349
|
-
if (!
|
|
13443
|
+
if (!PACKAGE_NAME2.test(dependency) || typeof range !== "string" || (0, import_semver.validRange)(range) === null) {
|
|
11350
13444
|
diagnostics.push(diagnosticAt("package.json", null, `The package "${name}" has an invalid published requirement for "${dependency}".`));
|
|
11351
13445
|
continue;
|
|
11352
13446
|
}
|
|
@@ -11364,7 +13458,7 @@ function packageRequirementProblems(candidates) {
|
|
|
11364
13458
|
return diagnostics;
|
|
11365
13459
|
}
|
|
11366
13460
|
function packageBuildSource(root, path, source, bindings) {
|
|
11367
|
-
const content =
|
|
13461
|
+
const content = readFileSync3(join4(root, source));
|
|
11368
13462
|
if (bindings.length === 0 || !/\.[jt]sx?$/.test(source)) {
|
|
11369
13463
|
return content;
|
|
11370
13464
|
}
|
|
@@ -11372,13 +13466,13 @@ function packageBuildSource(root, path, source, bindings) {
|
|
|
11372
13466
|
}
|
|
11373
13467
|
function materializePackages(root, plan) {
|
|
11374
13468
|
for (const [path, { source, name }] of plan.files) {
|
|
11375
|
-
const target =
|
|
13469
|
+
const target = join4(root, path);
|
|
11376
13470
|
mkdirSync(dirname2(target), { recursive: true });
|
|
11377
13471
|
writeFileSync(target, packageBuildSource(root, path, source, plan.bindings.get(name) ?? []));
|
|
11378
13472
|
}
|
|
11379
13473
|
}
|
|
11380
13474
|
function buildComposedCheckout(root, plan, options, build) {
|
|
11381
|
-
const composed = mkdtempSync(
|
|
13475
|
+
const composed = mkdtempSync(join4(tmpdir(), "diagonal-packages-"));
|
|
11382
13476
|
try {
|
|
11383
13477
|
cpSync(root, composed, {
|
|
11384
13478
|
recursive: true,
|
|
@@ -11387,14 +13481,14 @@ function buildComposedCheckout(root, plan, options, build) {
|
|
|
11387
13481
|
return path !== "node_modules" && path !== ".git";
|
|
11388
13482
|
}
|
|
11389
13483
|
});
|
|
11390
|
-
if (
|
|
11391
|
-
symlinkSync(
|
|
13484
|
+
if (existsSync2(join4(root, "node_modules"))) {
|
|
13485
|
+
symlinkSync(join4(root, "node_modules"), join4(composed, "node_modules"), "dir");
|
|
11392
13486
|
}
|
|
11393
13487
|
materializePackages(composed, plan);
|
|
11394
13488
|
const result = build(composed, plan, options);
|
|
11395
13489
|
for (const path of listCheckoutFiles(composed, /* @__PURE__ */ new Set())) {
|
|
11396
13490
|
const owner = plan.files.get(path);
|
|
11397
|
-
const content =
|
|
13491
|
+
const content = readFileSync3(join4(composed, path));
|
|
11398
13492
|
if (owner !== void 0) {
|
|
11399
13493
|
if (!content.equals(packageBuildSource(root, path, owner.source, plan.bindings.get(owner.name) ?? []))) {
|
|
11400
13494
|
result.diagnostics.push(
|
|
@@ -11410,8 +13504,8 @@ function buildComposedCheckout(root, plan, options, build) {
|
|
|
11410
13504
|
if (options.writeSource !== true) {
|
|
11411
13505
|
continue;
|
|
11412
13506
|
}
|
|
11413
|
-
const target =
|
|
11414
|
-
if (!
|
|
13507
|
+
const target = join4(root, path);
|
|
13508
|
+
if (!existsSync2(target) || !readFileSync3(target).equals(content)) {
|
|
11415
13509
|
mkdirSync(dirname2(target), { recursive: true });
|
|
11416
13510
|
writeFileSync(target, content);
|
|
11417
13511
|
}
|
|
@@ -11423,26 +13517,21 @@ function buildComposedCheckout(root, plan, options, build) {
|
|
|
11423
13517
|
rmSync(composed, { recursive: true, force: true });
|
|
11424
13518
|
}
|
|
11425
13519
|
}
|
|
11426
|
-
var VENDOR_FILE = /^vendor\/((?:@[^/@]+\/)?[^/@][^/]*)\/(.+)$/;
|
|
11427
|
-
function vendorFile(path) {
|
|
11428
|
-
const match = VENDOR_FILE.exec(path);
|
|
11429
|
-
return match === null ? null : { name: match[1], path: match[2] };
|
|
11430
|
-
}
|
|
11431
13520
|
var TYPESCRIPT_CONFIG = "tsconfig.json";
|
|
11432
13521
|
var APP_PATH_PATTERN = "@app/*";
|
|
11433
13522
|
var PACKAGE_TREE = /^\.\/(?:vendor|node_modules)\/.+/;
|
|
11434
13523
|
function writeTypeScriptConfig(root, plan) {
|
|
11435
|
-
const path =
|
|
13524
|
+
const path = join4(root, TYPESCRIPT_CONFIG);
|
|
11436
13525
|
const config2 = readJson(path);
|
|
11437
13526
|
if (config2 === null) {
|
|
11438
13527
|
return false;
|
|
11439
13528
|
}
|
|
11440
|
-
const options =
|
|
13529
|
+
const options = isPlainObject(config2.compilerOptions) ? config2.compilerOptions : {};
|
|
11441
13530
|
const trees = plan.packages.flatMap(({ name }) => [`./vendor/${name}`, `./node_modules/${name}`]);
|
|
11442
13531
|
const ownRootDirs = (Array.isArray(options.rootDirs) ? options.rootDirs : []).filter(
|
|
11443
13532
|
(entry2) => typeof entry2 !== "string" || entry2 !== "." && !PACKAGE_TREE.test(entry2)
|
|
11444
13533
|
);
|
|
11445
|
-
const paths =
|
|
13534
|
+
const paths = isPlainObject(options.paths) ? options.paths : {};
|
|
11446
13535
|
const ownAppPaths = (Array.isArray(paths[APP_PATH_PATTERN]) ? paths[APP_PATH_PATTERN] : ["./*"]).filter(
|
|
11447
13536
|
(entry2) => typeof entry2 !== "string" || !PACKAGE_TREE.test(entry2)
|
|
11448
13537
|
);
|
|
@@ -11463,22 +13552,22 @@ function writeTypeScriptConfig(root, plan) {
|
|
|
11463
13552
|
}
|
|
11464
13553
|
const text = `${JSON.stringify(next, null, 2)}
|
|
11465
13554
|
`;
|
|
11466
|
-
if (
|
|
13555
|
+
if (readFileSync3(path, "utf8") === text) {
|
|
11467
13556
|
return false;
|
|
11468
13557
|
}
|
|
11469
13558
|
writeFileSync(path, text);
|
|
11470
13559
|
return true;
|
|
11471
13560
|
}
|
|
11472
13561
|
function isDiagonalPackage(manifest) {
|
|
11473
|
-
return
|
|
13562
|
+
return isPlainObject(manifest[DIAGONAL_PACKAGE_FIELD]);
|
|
11474
13563
|
}
|
|
11475
13564
|
function readJson(path) {
|
|
11476
|
-
if (!
|
|
13565
|
+
if (!existsSync2(path)) {
|
|
11477
13566
|
return null;
|
|
11478
13567
|
}
|
|
11479
13568
|
try {
|
|
11480
|
-
const value = JSON.parse(
|
|
11481
|
-
return
|
|
13569
|
+
const value = JSON.parse(readFileSync3(path, "utf8"));
|
|
13570
|
+
return isPlainObject(value) ? value : null;
|
|
11482
13571
|
} catch (error) {
|
|
11483
13572
|
if (error instanceof SyntaxError) {
|
|
11484
13573
|
return null;
|
|
@@ -11486,16 +13575,13 @@ function readJson(path) {
|
|
|
11486
13575
|
throw error;
|
|
11487
13576
|
}
|
|
11488
13577
|
}
|
|
11489
|
-
function isPlainObject2(value) {
|
|
11490
|
-
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
11491
|
-
}
|
|
11492
13578
|
function isDirectory(path) {
|
|
11493
|
-
return
|
|
13579
|
+
return existsSync2(path) && statSync(path).isDirectory();
|
|
11494
13580
|
}
|
|
11495
13581
|
|
|
11496
13582
|
// scripts/lib/runtime-build/migration-cli.mjs
|
|
11497
13583
|
import { mkdirSync as mkdirSync2, readdirSync as readdirSync2, statSync as statSync2, writeFileSync as writeFileSync2 } from "node:fs";
|
|
11498
|
-
import { join as
|
|
13584
|
+
import { join as join5 } from "node:path";
|
|
11499
13585
|
|
|
11500
13586
|
// scripts/lib/runtime-build/migration-file.mjs
|
|
11501
13587
|
var MIGRATION_ID = /^(?=.{1,100}$)(\d{14})_[a-z0-9][a-z0-9_]*$/;
|
|
@@ -11522,12 +13608,12 @@ ${MIGRATION_USAGE}
|
|
|
11522
13608
|
);
|
|
11523
13609
|
return 2;
|
|
11524
13610
|
}
|
|
11525
|
-
if (!statSync2(
|
|
13611
|
+
if (!statSync2(join5(cwd, "diagonal.config.ts"), { throwIfNoEntry: false })?.isFile()) {
|
|
11526
13612
|
stderr.write("Run this command in a workspace directory with diagonal.config.ts.\n");
|
|
11527
13613
|
return 2;
|
|
11528
13614
|
}
|
|
11529
13615
|
const name = args[0];
|
|
11530
|
-
const directory =
|
|
13616
|
+
const directory = join5(cwd, "migrations");
|
|
11531
13617
|
mkdirSync2(directory, { recursive: true });
|
|
11532
13618
|
const used = new Set(
|
|
11533
13619
|
readdirSync2(directory).filter((file) => file.endsWith(".ts") && !file.endsWith(".test.ts")).map((file) => migrationTimestamp(file.slice(0, -3))).filter((timestamp2) => timestamp2 !== null)
|
|
@@ -11551,7 +13637,7 @@ export default defineWorkflow(
|
|
|
11551
13637
|
async () => {}
|
|
11552
13638
|
);
|
|
11553
13639
|
`;
|
|
11554
|
-
writeFileSync2(
|
|
13640
|
+
writeFileSync2(join5(cwd, path), source, { flag: "wx" });
|
|
11555
13641
|
stdout.write(`Created ${path}
|
|
11556
13642
|
`);
|
|
11557
13643
|
return 0;
|
|
@@ -11559,8 +13645,8 @@ export default defineWorkflow(
|
|
|
11559
13645
|
|
|
11560
13646
|
// scripts/lib/runtime-build/update-cli.mjs
|
|
11561
13647
|
import { execFileSync, spawnSync } from "node:child_process";
|
|
11562
|
-
import { existsSync as
|
|
11563
|
-
import { basename as
|
|
13648
|
+
import { existsSync as existsSync3, readdirSync as readdirSync3, readFileSync as readFileSync4, rmSync as rmSync2, statSync as statSync3, writeFileSync as writeFileSync3 } from "node:fs";
|
|
13649
|
+
import { basename as basename6, dirname as dirname3, isAbsolute as isAbsolute2, join as join6, relative as relative3, resolve } from "node:path";
|
|
11564
13650
|
var UPDATE_USAGE = "Usage: diagonal update";
|
|
11565
13651
|
var SCOPE = "@diagonal-hq/";
|
|
11566
13652
|
var COMPILER_SCOPE = "@diagonal-hq/workflow-script-compiler-";
|
|
@@ -11578,7 +13664,7 @@ function newestTarball(name, directory) {
|
|
|
11578
13664
|
newest = version;
|
|
11579
13665
|
}
|
|
11580
13666
|
}
|
|
11581
|
-
return newest === null ? null :
|
|
13667
|
+
return newest === null ? null : join6(directory, tarballName(name, newest));
|
|
11582
13668
|
}
|
|
11583
13669
|
function fileSpecifier(cwd, path, absolute) {
|
|
11584
13670
|
return `${FILE}${absolute ? path : relative3(cwd, path)}`;
|
|
@@ -11603,17 +13689,17 @@ function packedCliCompilerOverrides(cliTarball, cwd, absolute) {
|
|
|
11603
13689
|
);
|
|
11604
13690
|
const overrides = {};
|
|
11605
13691
|
for (const [name, version] of Object.entries(cli.optionalDependencies ?? {})) {
|
|
11606
|
-
const tarball =
|
|
11607
|
-
if (name.startsWith(COMPILER_SCOPE) &&
|
|
13692
|
+
const tarball = join6(dirname3(cliTarball), tarballName(name, version));
|
|
13693
|
+
if (name.startsWith(COMPILER_SCOPE) && existsSync3(tarball)) {
|
|
11608
13694
|
overrides[name] = fileSpecifier(cwd, tarball, absolute);
|
|
11609
13695
|
}
|
|
11610
13696
|
}
|
|
11611
13697
|
return overrides;
|
|
11612
13698
|
}
|
|
11613
13699
|
function forgetInstalledPackages(cwd) {
|
|
11614
|
-
const lockPath =
|
|
11615
|
-
if (
|
|
11616
|
-
const lock = JSON.parse(
|
|
13700
|
+
const lockPath = join6(cwd, "package-lock.json");
|
|
13701
|
+
if (existsSync3(lockPath)) {
|
|
13702
|
+
const lock = JSON.parse(readFileSync4(lockPath, "utf8"));
|
|
11617
13703
|
for (const path of Object.keys(lock.packages ?? {})) {
|
|
11618
13704
|
if (path.startsWith(`node_modules/${SCOPE}`)) {
|
|
11619
13705
|
delete lock.packages[path];
|
|
@@ -11622,7 +13708,7 @@ function forgetInstalledPackages(cwd) {
|
|
|
11622
13708
|
writeFileSync3(lockPath, `${JSON.stringify(lock, null, 2)}
|
|
11623
13709
|
`);
|
|
11624
13710
|
}
|
|
11625
|
-
rmSync2(
|
|
13711
|
+
rmSync2(join6(cwd, "node_modules", SCOPE), { recursive: true, force: true });
|
|
11626
13712
|
}
|
|
11627
13713
|
function updatePackages(args, { cwd, env, stdout, stderr }) {
|
|
11628
13714
|
if (args.length > 0) {
|
|
@@ -11630,12 +13716,12 @@ function updatePackages(args, { cwd, env, stdout, stderr }) {
|
|
|
11630
13716
|
`);
|
|
11631
13717
|
return 2;
|
|
11632
13718
|
}
|
|
11633
|
-
const manifestPath =
|
|
13719
|
+
const manifestPath = join6(cwd, "package.json");
|
|
11634
13720
|
if (!statSync3(manifestPath, { throwIfNoEntry: false })?.isFile()) {
|
|
11635
13721
|
stderr.write("Run this command in a workspace directory with package.json.\n");
|
|
11636
13722
|
return 2;
|
|
11637
13723
|
}
|
|
11638
|
-
const manifest = JSON.parse(
|
|
13724
|
+
const manifest = JSON.parse(readFileSync4(manifestPath, "utf8"));
|
|
11639
13725
|
const latest = [];
|
|
11640
13726
|
let packed = false;
|
|
11641
13727
|
for (const section of SECTIONS2) {
|
|
@@ -11662,13 +13748,13 @@ function updatePackages(args, { cwd, env, stdout, stderr }) {
|
|
|
11662
13748
|
`);
|
|
11663
13749
|
return 1;
|
|
11664
13750
|
}
|
|
11665
|
-
manifest[section][name] = fileSpecifier(cwd, newest,
|
|
11666
|
-
stdout.write(`${name}: ${
|
|
13751
|
+
manifest[section][name] = fileSpecifier(cwd, newest, isAbsolute2(path));
|
|
13752
|
+
stdout.write(`${name}: ${basename6(current)} -> ${basename6(newest)}
|
|
11667
13753
|
`);
|
|
11668
13754
|
if (name === `${SCOPE}cli`) {
|
|
11669
13755
|
replaceCompilerOverrides(
|
|
11670
13756
|
manifest,
|
|
11671
|
-
packedCliCompilerOverrides(newest, cwd,
|
|
13757
|
+
packedCliCompilerOverrides(newest, cwd, isAbsolute2(path))
|
|
11672
13758
|
);
|
|
11673
13759
|
}
|
|
11674
13760
|
}
|
|
@@ -11699,27 +13785,6 @@ function updatePackages(args, { cwd, env, stdout, stderr }) {
|
|
|
11699
13785
|
return 0;
|
|
11700
13786
|
}
|
|
11701
13787
|
|
|
11702
|
-
// scripts/lib/runtime-build/sdk-packages.mjs
|
|
11703
|
-
import { existsSync as existsSync3, readFileSync as readFileSync4 } from "node:fs";
|
|
11704
|
-
import { join as join6 } from "node:path";
|
|
11705
|
-
function readPackageFiles(root, diagnostics) {
|
|
11706
|
-
const read = (path) => {
|
|
11707
|
-
if (!existsSync3(join6(root, path))) {
|
|
11708
|
-
return null;
|
|
11709
|
-
}
|
|
11710
|
-
try {
|
|
11711
|
-
return JSON.parse(readFileSync4(join6(root, path), "utf8"));
|
|
11712
|
-
} catch (error) {
|
|
11713
|
-
if (!(error instanceof SyntaxError)) {
|
|
11714
|
-
throw error;
|
|
11715
|
-
}
|
|
11716
|
-
diagnostics.push(diagnosticAt(path, null, `${path} is not valid JSON: ${error.message}`));
|
|
11717
|
-
return null;
|
|
11718
|
-
}
|
|
11719
|
-
};
|
|
11720
|
-
return { manifest: read("package.json"), lock: read("package-lock.json") };
|
|
11721
|
-
}
|
|
11722
|
-
|
|
11723
13788
|
// scripts/lib/runtime-build/workspace-build.mjs
|
|
11724
13789
|
var CONFIG_PATH = "diagonal.config.ts";
|
|
11725
13790
|
function checkWorkspaceBuild(root, plan, options, sources, needs = void 0) {
|
|
@@ -11825,7 +13890,7 @@ async function checkSources() {
|
|
|
11825
13890
|
if (existsSync4(DATA_FILE) && existsSync4(SDK_FILE)) {
|
|
11826
13891
|
return { dataFile: DATA_FILE, sdkFile: SDK_FILE };
|
|
11827
13892
|
}
|
|
11828
|
-
const { checkData, scriptSdk } = await import("./cli-check-data-
|
|
13893
|
+
const { checkData, scriptSdk } = await import("./cli-check-data-EFGW2377.mjs");
|
|
11829
13894
|
return { data: checkData(), sdk: scriptSdk() };
|
|
11830
13895
|
}
|
|
11831
13896
|
function isScriptTestPath(path) {
|