guardian-framework 0.1.59 → 0.1.61
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.js +1213 -293
- package/dist/exports.js +2 -2
- package/package.json +1 -1
- package/templates/pi/preflight_report.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -475,6 +475,25 @@ function findTextCursor(s, o, l2, i) {
|
|
|
475
475
|
h += t[r].length + 1;
|
|
476
476
|
return h + e;
|
|
477
477
|
}
|
|
478
|
+
function updateSettings(n) {
|
|
479
|
+
if (n.aliases !== undefined) {
|
|
480
|
+
const e = n.aliases;
|
|
481
|
+
for (const s in e) {
|
|
482
|
+
if (!Object.hasOwn(e, s))
|
|
483
|
+
continue;
|
|
484
|
+
const i = e[s];
|
|
485
|
+
i === undefined || !settings.actions.has(i) || settings.aliases.has(s) || settings.aliases.set(s, i);
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
if (n.messages !== undefined) {
|
|
489
|
+
const e = n.messages;
|
|
490
|
+
e.cancel !== undefined && (settings.messages.cancel = e.cancel), e.error !== undefined && (settings.messages.error = e.error);
|
|
491
|
+
}
|
|
492
|
+
if (n.withGuide !== undefined && (settings.withGuide = n.withGuide !== false), n.date !== undefined) {
|
|
493
|
+
const e = n.date;
|
|
494
|
+
e.monthNames !== undefined && (settings.date.monthNames = [...e.monthNames]), e.messages !== undefined && (e.messages.required !== undefined && (settings.date.messages.required = e.messages.required), e.messages.invalidMonth !== undefined && (settings.date.messages.invalidMonth = e.messages.invalidMonth), e.messages.invalidDay !== undefined && (settings.date.messages.invalidDay = e.messages.invalidDay), e.messages.afterMin !== undefined && (settings.date.messages.afterMin = e.messages.afterMin), e.messages.beforeMax !== undefined && (settings.date.messages.beforeMax = e.messages.beforeMax));
|
|
495
|
+
}
|
|
496
|
+
}
|
|
478
497
|
function isActionKey(n, e) {
|
|
479
498
|
if (typeof n == "string")
|
|
480
499
|
return settings.aliases.get(n) === e;
|
|
@@ -768,7 +787,7 @@ function T2(r2, t2, i, s) {
|
|
|
768
787
|
max: e && t2.year === e.year && t2.month === e.month ? e.day : c(t2.year, t2.month)
|
|
769
788
|
};
|
|
770
789
|
}
|
|
771
|
-
var import_sisteransi, a$1, t, settings, R, CANCEL_SYMBOL, getColumns = (e) => ("columns" in e) && typeof e.columns == "number" ? e.columns : 80, getRows = (e) => ("rows" in e) && typeof e.rows == "number" ? e.rows : 20, T$1, r, _, U, u$2, o, h, a, n$1, n2;
|
|
790
|
+
var import_sisteransi, a$1, t, settings, R, CANCEL_SYMBOL, getColumns = (e) => ("columns" in e) && typeof e.columns == "number" ? e.columns : 80, getRows = (e) => ("rows" in e) && typeof e.rows == "number" ? e.rows : 20, T$1, r, _, U, u$2, o, h, a, u$1, n$1, u3, n2;
|
|
772
791
|
var init_dist3 = __esm(() => {
|
|
773
792
|
init_main();
|
|
774
793
|
import_sisteransi = __toESM(require_src(), 1);
|
|
@@ -1244,6 +1263,34 @@ ${i}` : `${s}${styleText("inverse", r2)}${i}`;
|
|
|
1244
1263
|
});
|
|
1245
1264
|
}
|
|
1246
1265
|
};
|
|
1266
|
+
u$1 = class u2 extends V {
|
|
1267
|
+
_mask = "\u2022";
|
|
1268
|
+
get cursor() {
|
|
1269
|
+
return this._cursor;
|
|
1270
|
+
}
|
|
1271
|
+
get masked() {
|
|
1272
|
+
return this.userInput.replaceAll(/./g, this._mask);
|
|
1273
|
+
}
|
|
1274
|
+
get userInputWithCursor() {
|
|
1275
|
+
if (this.state === "submit" || this.state === "cancel")
|
|
1276
|
+
return this.masked;
|
|
1277
|
+
const t2 = this.userInput;
|
|
1278
|
+
if (this.cursor >= t2.length)
|
|
1279
|
+
return `${this.masked}${styleText(["inverse", "hidden"], "_")}`;
|
|
1280
|
+
const s = this.masked, r2 = s.slice(0, this.cursor), i = s.slice(this.cursor, this.cursor + 1), o2 = s.slice(this.cursor + 1);
|
|
1281
|
+
return `${r2}${styleText("inverse", i)}${o2}`;
|
|
1282
|
+
}
|
|
1283
|
+
clear() {
|
|
1284
|
+
this._clearUserInput();
|
|
1285
|
+
}
|
|
1286
|
+
constructor({ mask: t2, ...s }) {
|
|
1287
|
+
super(s), this._mask = t2 ?? "\u2022", this.on("userInput", (r2) => {
|
|
1288
|
+
this._setValue(r2);
|
|
1289
|
+
}), this.on("finalize", () => {
|
|
1290
|
+
this.value === undefined && (this.value = "");
|
|
1291
|
+
});
|
|
1292
|
+
}
|
|
1293
|
+
};
|
|
1247
1294
|
n$1 = class n extends V {
|
|
1248
1295
|
options;
|
|
1249
1296
|
cursor = 0;
|
|
@@ -1272,6 +1319,23 @@ ${i}` : `${s}${styleText("inverse", r2)}${i}`;
|
|
|
1272
1319
|
});
|
|
1273
1320
|
}
|
|
1274
1321
|
};
|
|
1322
|
+
u3 = class u3 extends V {
|
|
1323
|
+
options;
|
|
1324
|
+
cursor = 0;
|
|
1325
|
+
constructor(t2) {
|
|
1326
|
+
super(t2, false), this.options = t2.options;
|
|
1327
|
+
const s = t2.caseSensitive === true, i = this.options.map(({ value: [e] }) => s ? e : e?.toLowerCase());
|
|
1328
|
+
this.cursor = Math.max(i.indexOf(t2.initialValue), 0), this.on("key", (e) => {
|
|
1329
|
+
if (!e)
|
|
1330
|
+
return;
|
|
1331
|
+
const o2 = s ? e : e.toLowerCase();
|
|
1332
|
+
if (!i.includes(o2))
|
|
1333
|
+
return;
|
|
1334
|
+
const n2 = this.options.find(({ value: [r2] }) => s ? r2 === o2 : r2?.toLowerCase() === o2);
|
|
1335
|
+
n2 && (this.value = n2.value, this.state = "submit", this.emit("submit"));
|
|
1336
|
+
});
|
|
1337
|
+
}
|
|
1338
|
+
};
|
|
1275
1339
|
n2 = class n2 extends V {
|
|
1276
1340
|
get userInputWithCursor() {
|
|
1277
1341
|
if (this.state === "submit")
|
|
@@ -1299,8 +1363,75 @@ ${i}` : `${s}${styleText("inverse", r2)}${i}`;
|
|
|
1299
1363
|
});
|
|
1300
1364
|
|
|
1301
1365
|
// node_modules/@clack/prompts/dist/index.mjs
|
|
1366
|
+
var exports_dist = {};
|
|
1367
|
+
__export(exports_dist, {
|
|
1368
|
+
updateSettings: () => updateSettings,
|
|
1369
|
+
unicodeOr: () => unicodeOr,
|
|
1370
|
+
unicode: () => unicode,
|
|
1371
|
+
text: () => text,
|
|
1372
|
+
tasks: () => tasks,
|
|
1373
|
+
taskLog: () => taskLog,
|
|
1374
|
+
symbolBar: () => symbolBar,
|
|
1375
|
+
symbol: () => symbol,
|
|
1376
|
+
stream: () => stream,
|
|
1377
|
+
spinner: () => spinner,
|
|
1378
|
+
settings: () => settings,
|
|
1379
|
+
selectKey: () => selectKey,
|
|
1380
|
+
select: () => select,
|
|
1381
|
+
progress: () => progress,
|
|
1382
|
+
path: () => path,
|
|
1383
|
+
password: () => password,
|
|
1384
|
+
outro: () => outro,
|
|
1385
|
+
note: () => note,
|
|
1386
|
+
multiselect: () => multiselect,
|
|
1387
|
+
multiline: () => multiline,
|
|
1388
|
+
log: () => log,
|
|
1389
|
+
limitOptions: () => limitOptions,
|
|
1390
|
+
isTTY: () => isTTY,
|
|
1391
|
+
isCancel: () => isCancel,
|
|
1392
|
+
isCI: () => isCI,
|
|
1393
|
+
intro: () => intro,
|
|
1394
|
+
groupMultiselect: () => groupMultiselect,
|
|
1395
|
+
group: () => group,
|
|
1396
|
+
formatInstructionFooter: () => formatInstructionFooter,
|
|
1397
|
+
date: () => date,
|
|
1398
|
+
confirm: () => confirm,
|
|
1399
|
+
cancel: () => cancel,
|
|
1400
|
+
box: () => box,
|
|
1401
|
+
autocompleteMultiselect: () => autocompleteMultiselect,
|
|
1402
|
+
autocomplete: () => autocomplete,
|
|
1403
|
+
S_WARN: () => S_WARN,
|
|
1404
|
+
S_SUCCESS: () => S_SUCCESS,
|
|
1405
|
+
S_STEP_SUBMIT: () => S_STEP_SUBMIT,
|
|
1406
|
+
S_STEP_ERROR: () => S_STEP_ERROR,
|
|
1407
|
+
S_STEP_CANCEL: () => S_STEP_CANCEL,
|
|
1408
|
+
S_STEP_ACTIVE: () => S_STEP_ACTIVE,
|
|
1409
|
+
S_RADIO_INACTIVE: () => S_RADIO_INACTIVE,
|
|
1410
|
+
S_RADIO_ACTIVE: () => S_RADIO_ACTIVE,
|
|
1411
|
+
S_PASSWORD_MASK: () => S_PASSWORD_MASK,
|
|
1412
|
+
S_INFO: () => S_INFO,
|
|
1413
|
+
S_ERROR: () => S_ERROR,
|
|
1414
|
+
S_CORNER_TOP_RIGHT: () => S_CORNER_TOP_RIGHT,
|
|
1415
|
+
S_CORNER_TOP_LEFT: () => S_CORNER_TOP_LEFT,
|
|
1416
|
+
S_CORNER_BOTTOM_RIGHT: () => S_CORNER_BOTTOM_RIGHT,
|
|
1417
|
+
S_CORNER_BOTTOM_LEFT: () => S_CORNER_BOTTOM_LEFT,
|
|
1418
|
+
S_CONNECT_LEFT: () => S_CONNECT_LEFT,
|
|
1419
|
+
S_CHECKBOX_SELECTED: () => S_CHECKBOX_SELECTED,
|
|
1420
|
+
S_CHECKBOX_INACTIVE: () => S_CHECKBOX_INACTIVE,
|
|
1421
|
+
S_CHECKBOX_ACTIVE: () => S_CHECKBOX_ACTIVE,
|
|
1422
|
+
S_BAR_START_RIGHT: () => S_BAR_START_RIGHT,
|
|
1423
|
+
S_BAR_START: () => S_BAR_START,
|
|
1424
|
+
S_BAR_H: () => S_BAR_H,
|
|
1425
|
+
S_BAR_END_RIGHT: () => S_BAR_END_RIGHT,
|
|
1426
|
+
S_BAR_END: () => S_BAR_END,
|
|
1427
|
+
S_BAR: () => S_BAR,
|
|
1428
|
+
SELECT_INSTRUCTIONS: () => SELECT_INSTRUCTIONS,
|
|
1429
|
+
MULTISELECT_INSTRUCTIONS: () => MULTISELECT_INSTRUCTIONS
|
|
1430
|
+
});
|
|
1302
1431
|
import { styleText as styleText2, stripVTControlCharacters } from "util";
|
|
1303
1432
|
import process$1 from "process";
|
|
1433
|
+
import { existsSync, lstatSync, readdirSync } from "fs";
|
|
1434
|
+
import { dirname, join } from "path";
|
|
1304
1435
|
function isUnicodeSupported() {
|
|
1305
1436
|
if (process$1.platform !== "win32") {
|
|
1306
1437
|
return process$1.env.TERM !== "linux";
|
|
@@ -1311,7 +1442,80 @@ function formatInstructionFooter(o2, e) {
|
|
|
1311
1442
|
const r2 = [`${e ? `${styleText2("cyan", S_BAR)} ` : ""}${o2.join(" \u2022 ")}`];
|
|
1312
1443
|
return e && r2.push(styleText2("cyan", S_BAR_END)), r2;
|
|
1313
1444
|
}
|
|
1314
|
-
|
|
1445
|
+
function P2(t2) {
|
|
1446
|
+
return t2.label ?? String(t2.value ?? "");
|
|
1447
|
+
}
|
|
1448
|
+
function E(t2, c2) {
|
|
1449
|
+
if (!t2)
|
|
1450
|
+
return true;
|
|
1451
|
+
const n3 = (c2.label ?? String(c2.value ?? "")).toLowerCase(), i = (c2.hint ?? "").toLowerCase(), l2 = String(c2.value).toLowerCase(), o2 = t2.toLowerCase();
|
|
1452
|
+
return n3.includes(o2) || i.includes(o2) || l2.includes(o2);
|
|
1453
|
+
}
|
|
1454
|
+
function N(t2, c2) {
|
|
1455
|
+
const n3 = [];
|
|
1456
|
+
for (const i of c2)
|
|
1457
|
+
t2.includes(i.value) && n3.push(i);
|
|
1458
|
+
return n3;
|
|
1459
|
+
}
|
|
1460
|
+
function A$1(n3, e, t2, o2) {
|
|
1461
|
+
let i = t2, f2 = t2;
|
|
1462
|
+
return o2 === "center" ? i = Math.floor((e - n3) / 2) : o2 === "right" && (i = e - n3 - t2), f2 = e - i - n3, [i, f2];
|
|
1463
|
+
}
|
|
1464
|
+
function b2(e, r2) {
|
|
1465
|
+
const { segmentValues: t2, segmentCursor: o2 } = e;
|
|
1466
|
+
if (r2 === "submit" || r2 === "cancel")
|
|
1467
|
+
return e.formattedValue;
|
|
1468
|
+
const i = styleText2("gray", e.separator);
|
|
1469
|
+
return e.segments.map((l2, d) => {
|
|
1470
|
+
const c2 = d === o2.segmentIndex && !["submit", "cancel"].includes(r2), a2 = p2[l2.type];
|
|
1471
|
+
return x(t2[l2.type], { isActive: c2, label: a2 });
|
|
1472
|
+
}).join(i);
|
|
1473
|
+
}
|
|
1474
|
+
function x(e, r2) {
|
|
1475
|
+
const t2 = !e || e.replace(/_/g, "") === "";
|
|
1476
|
+
return r2.isActive ? styleText2("inverse", t2 ? r2.label : e.replace(/_/g, " ")) : t2 ? styleText2("dim", r2.label) : e.replace(/_/g, styleText2("dim", " "));
|
|
1477
|
+
}
|
|
1478
|
+
function progress({
|
|
1479
|
+
style: o2 = "heavy",
|
|
1480
|
+
max: d = 100,
|
|
1481
|
+
size: v = 40,
|
|
1482
|
+
...x2
|
|
1483
|
+
} = {}) {
|
|
1484
|
+
const r2 = spinner(x2);
|
|
1485
|
+
let a2 = 0, n3 = "";
|
|
1486
|
+
const c2 = Math.max(1, d), l2 = Math.max(1, v), S = (t2) => {
|
|
1487
|
+
switch (t2) {
|
|
1488
|
+
case "initial":
|
|
1489
|
+
case "active":
|
|
1490
|
+
return (e) => styleText2("magenta", e);
|
|
1491
|
+
case "error":
|
|
1492
|
+
case "cancel":
|
|
1493
|
+
return (e) => styleText2("red", e);
|
|
1494
|
+
case "submit":
|
|
1495
|
+
return (e) => styleText2("green", e);
|
|
1496
|
+
default:
|
|
1497
|
+
return (e) => styleText2("magenta", e);
|
|
1498
|
+
}
|
|
1499
|
+
}, p3 = (t2, e) => {
|
|
1500
|
+
const m3 = Math.floor(a2 / c2 * l2);
|
|
1501
|
+
return `${S(t2)(u4[o2].repeat(m3))}${styleText2("dim", u4[o2].repeat(l2 - m3))} ${e}`;
|
|
1502
|
+
}, h2 = (t2 = "") => {
|
|
1503
|
+
n3 = t2, r2.start(p3("initial", t2));
|
|
1504
|
+
}, g2 = (t2 = 1, e) => {
|
|
1505
|
+
a2 = Math.min(c2, t2 + a2), r2.message(p3("active", e ?? n3)), n3 = e ?? n3;
|
|
1506
|
+
};
|
|
1507
|
+
return {
|
|
1508
|
+
start: h2,
|
|
1509
|
+
stop: r2.stop,
|
|
1510
|
+
cancel: r2.cancel,
|
|
1511
|
+
error: r2.error,
|
|
1512
|
+
clear: r2.clear,
|
|
1513
|
+
advance: g2,
|
|
1514
|
+
isCancelled: r2.isCancelled,
|
|
1515
|
+
message: (t2) => g2(0, t2)
|
|
1516
|
+
};
|
|
1517
|
+
}
|
|
1518
|
+
var import_sisteransi2, unicode, isCI = () => process.env.CI === "true", isTTY = (o2) => o2.isTTY === true, unicodeOr = (o2, e) => unicode ? o2 : e, S_STEP_ACTIVE, S_STEP_CANCEL, S_STEP_ERROR, S_STEP_SUBMIT, S_BAR_START, S_BAR, S_BAR_END, S_BAR_START_RIGHT, S_BAR_END_RIGHT, S_RADIO_ACTIVE, S_RADIO_INACTIVE, S_CHECKBOX_ACTIVE, S_CHECKBOX_SELECTED, S_CHECKBOX_INACTIVE, S_PASSWORD_MASK, S_BAR_H, S_CORNER_TOP_RIGHT, S_CONNECT_LEFT, S_CORNER_BOTTOM_RIGHT, S_CORNER_BOTTOM_LEFT, S_CORNER_TOP_LEFT, S_INFO, S_SUCCESS, S_WARN, S_ERROR, symbol = (o2) => {
|
|
1315
1519
|
switch (o2) {
|
|
1316
1520
|
case "initial":
|
|
1317
1521
|
case "active":
|
|
@@ -1378,9 +1582,9 @@ var import_sisteransi2, unicode, isCI = () => process.env.CI === "true", unicode
|
|
|
1378
1582
|
if (g2 > v) {
|
|
1379
1583
|
let t2 = 0, n3 = 0, o2 = g2;
|
|
1380
1584
|
const h2 = l2 - T3;
|
|
1381
|
-
let
|
|
1382
|
-
const L = () => I(s, o2, 0, h2,
|
|
1383
|
-
d ? ({ lineCount: o2, removals: t2 } = L(), o2 >
|
|
1585
|
+
let u4 = v;
|
|
1586
|
+
const L = () => I(s, o2, 0, h2, u4), E = () => I(s, o2, h2 + 1, s.length, u4, true);
|
|
1587
|
+
d ? ({ lineCount: o2, removals: t2 } = L(), o2 > u4 && (c2 || (u4 -= 1), { lineCount: o2, removals: n3 } = E())) : (c2 || (u4 -= 1), { lineCount: o2, removals: n3 } = E(), o2 > u4 && (u4 -= 1, { lineCount: o2, removals: t2 } = L())), t2 > 0 && (d = true, s.splice(0, t2)), n3 > 0 && (c2 = true, s.splice(s.length - n3, n3));
|
|
1384
1588
|
}
|
|
1385
1589
|
const x = [];
|
|
1386
1590
|
d && x.push(M2);
|
|
@@ -1388,6 +1592,160 @@ var import_sisteransi2, unicode, isCI = () => process.env.CI === "true", unicode
|
|
|
1388
1592
|
for (const n3 of t2)
|
|
1389
1593
|
x.push(n3);
|
|
1390
1594
|
return c2 && x.push(M2), x;
|
|
1595
|
+
}, autocomplete = (t2) => new T$1({
|
|
1596
|
+
options: t2.options,
|
|
1597
|
+
initialValue: t2.initialValue ? [t2.initialValue] : undefined,
|
|
1598
|
+
initialUserInput: t2.initialUserInput,
|
|
1599
|
+
placeholder: t2.placeholder,
|
|
1600
|
+
filter: t2.filter ?? ((n3, i) => E(n3, i)),
|
|
1601
|
+
signal: t2.signal,
|
|
1602
|
+
input: t2.input,
|
|
1603
|
+
output: t2.output,
|
|
1604
|
+
validate: t2.validate,
|
|
1605
|
+
render() {
|
|
1606
|
+
const n3 = t2.withGuide ?? settings.withGuide, i = n3 ? [`${styleText2("gray", S_BAR)}`, `${symbol(this.state)} ${t2.message}`] : [`${symbol(this.state)} ${t2.message}`], l2 = this.userInput, o2 = this.options, m2 = t2.placeholder, p2 = l2 === "" && m2 !== undefined, $ = (r2, s) => {
|
|
1607
|
+
const a2 = P2(r2), u4 = r2.hint && r2.value === this.focusedValue ? styleText2("dim", ` (${r2.hint})`) : "";
|
|
1608
|
+
switch (s) {
|
|
1609
|
+
case "active":
|
|
1610
|
+
return `${styleText2("green", S_RADIO_ACTIVE)} ${a2}${u4}`;
|
|
1611
|
+
case "inactive":
|
|
1612
|
+
return `${styleText2("dim", S_RADIO_INACTIVE)} ${styleText2("dim", a2)}`;
|
|
1613
|
+
case "disabled":
|
|
1614
|
+
return `${styleText2("gray", S_RADIO_INACTIVE)} ${styleText2(["strikethrough", "gray"], a2)}`;
|
|
1615
|
+
}
|
|
1616
|
+
};
|
|
1617
|
+
switch (this.state) {
|
|
1618
|
+
case "submit": {
|
|
1619
|
+
const r2 = N(this.selectedValues, o2), s = r2.length > 0 ? ` ${styleText2("dim", r2.map(P2).join(", "))}` : "", a2 = n3 ? styleText2("gray", S_BAR) : "";
|
|
1620
|
+
return `${i.join(`
|
|
1621
|
+
`)}
|
|
1622
|
+
${a2}${s}`;
|
|
1623
|
+
}
|
|
1624
|
+
case "cancel": {
|
|
1625
|
+
const r2 = l2 ? ` ${styleText2(["strikethrough", "dim"], l2)}` : "", s = n3 ? styleText2("gray", S_BAR) : "";
|
|
1626
|
+
return `${i.join(`
|
|
1627
|
+
`)}
|
|
1628
|
+
${s}${r2}`;
|
|
1629
|
+
}
|
|
1630
|
+
default: {
|
|
1631
|
+
const r2 = this.state === "error" ? "yellow" : "cyan", s = n3 ? `${styleText2(r2, S_BAR)} ` : "", a2 = n3 ? styleText2(r2, S_BAR_END) : "";
|
|
1632
|
+
let u4 = "";
|
|
1633
|
+
if (this.isNavigating || p2) {
|
|
1634
|
+
const d = p2 ? m2 : l2;
|
|
1635
|
+
u4 = d !== "" ? ` ${styleText2("dim", d)}` : "";
|
|
1636
|
+
} else
|
|
1637
|
+
u4 = ` ${this.userInputWithCursor}`;
|
|
1638
|
+
const V2 = this.filteredOptions.length !== o2.length ? styleText2("dim", ` (${this.filteredOptions.length} match${this.filteredOptions.length === 1 ? "" : "es"})`) : "", y = this.filteredOptions.length === 0 && l2 ? [`${s}${styleText2("yellow", "No matches found")}`] : [], b2 = this.state === "error" ? [`${s}${styleText2("yellow", this.error)}`] : [];
|
|
1639
|
+
n3 && i.push(`${s.trimEnd()}`), i.push(`${s}${styleText2("dim", "Search:")}${u4}${V2}`, ...y, ...b2);
|
|
1640
|
+
const v = [
|
|
1641
|
+
`${styleText2("dim", "\u2191/\u2193")} to select`,
|
|
1642
|
+
`${styleText2("dim", "Enter:")} confirm`,
|
|
1643
|
+
`${styleText2("dim", "Type:")} to search`
|
|
1644
|
+
], g2 = [`${s}${v.join(" \u2022 ")}`, a2], O = this.filteredOptions.length === 0 ? [] : limitOptions({
|
|
1645
|
+
cursor: this.cursor,
|
|
1646
|
+
options: this.filteredOptions,
|
|
1647
|
+
columnPadding: n3 ? 3 : 0,
|
|
1648
|
+
rowPadding: i.length + g2.length,
|
|
1649
|
+
style: (d, f2) => $(d, d.disabled ? "disabled" : f2 ? "active" : "inactive"),
|
|
1650
|
+
maxItems: t2.maxItems,
|
|
1651
|
+
output: t2.output
|
|
1652
|
+
});
|
|
1653
|
+
return [
|
|
1654
|
+
...i,
|
|
1655
|
+
...O.map((d) => `${s}${d}`),
|
|
1656
|
+
...g2
|
|
1657
|
+
].join(`
|
|
1658
|
+
`);
|
|
1659
|
+
}
|
|
1660
|
+
}
|
|
1661
|
+
}
|
|
1662
|
+
}).prompt(), autocompleteMultiselect = (t2) => {
|
|
1663
|
+
const c2 = (i, l2, o2, m2) => {
|
|
1664
|
+
const p2 = o2.includes(i.value), $ = i.label ?? String(i.value ?? ""), r2 = i.hint && m2 !== undefined && i.value === m2 ? styleText2("dim", ` (${i.hint})`) : "", s = p2 ? styleText2("green", S_CHECKBOX_SELECTED) : styleText2("dim", S_CHECKBOX_INACTIVE);
|
|
1665
|
+
return i.disabled ? `${styleText2("gray", S_CHECKBOX_INACTIVE)} ${styleText2(["strikethrough", "gray"], $)}` : l2 ? `${s} ${$}${r2}` : `${s} ${styleText2("dim", $)}`;
|
|
1666
|
+
}, n3 = new T$1({
|
|
1667
|
+
options: t2.options,
|
|
1668
|
+
multiple: true,
|
|
1669
|
+
placeholder: t2.placeholder,
|
|
1670
|
+
filter: t2.filter ?? ((i, l2) => E(i, l2)),
|
|
1671
|
+
validate: () => {
|
|
1672
|
+
if (t2.required && n3.selectedValues.length === 0)
|
|
1673
|
+
return "Please select at least one item";
|
|
1674
|
+
},
|
|
1675
|
+
initialValue: t2.initialValues,
|
|
1676
|
+
signal: t2.signal,
|
|
1677
|
+
input: t2.input,
|
|
1678
|
+
output: t2.output,
|
|
1679
|
+
render() {
|
|
1680
|
+
const i = t2.withGuide ?? settings.withGuide, l2 = `${i ? `${styleText2("gray", S_BAR)}
|
|
1681
|
+
` : ""}${symbol(this.state)} ${t2.message}
|
|
1682
|
+
`, o2 = this.userInput, m2 = t2.placeholder, p2 = o2 === "" && m2 !== undefined, $ = this.isNavigating || p2 ? styleText2("dim", p2 ? m2 : o2) : this.userInputWithCursor, r2 = this.options, s = this.filteredOptions.length !== r2.length ? styleText2("dim", ` (${this.filteredOptions.length} match${this.filteredOptions.length === 1 ? "" : "es"})`) : "";
|
|
1683
|
+
switch (this.state) {
|
|
1684
|
+
case "submit":
|
|
1685
|
+
return `${l2}${i ? `${styleText2("gray", S_BAR)} ` : ""}${styleText2("dim", `${this.selectedValues.length} items selected`)}`;
|
|
1686
|
+
case "cancel":
|
|
1687
|
+
return `${l2}${i ? `${styleText2("gray", S_BAR)} ` : ""}${styleText2(["strikethrough", "dim"], o2)}`;
|
|
1688
|
+
default: {
|
|
1689
|
+
const a2 = this.state === "error" ? "yellow" : "cyan", u4 = i ? `${styleText2(a2, S_BAR)} ` : "", V2 = i ? styleText2(a2, S_BAR_END) : "", y = [
|
|
1690
|
+
`${styleText2("dim", "\u2191/\u2193")} to navigate`,
|
|
1691
|
+
`${styleText2("dim", this.isNavigating ? "Space/Tab:" : "Tab:")} select`,
|
|
1692
|
+
`${styleText2("dim", "Enter:")} confirm`,
|
|
1693
|
+
`${styleText2("dim", "Type:")} to search`
|
|
1694
|
+
], b2 = this.filteredOptions.length === 0 && o2 ? [`${u4}${styleText2("yellow", "No matches found")}`] : [], v = this.state === "error" ? [`${u4}${styleText2("yellow", this.error)}`] : [], g2 = [
|
|
1695
|
+
...`${l2}${i ? styleText2(a2, S_BAR) : ""}`.split(`
|
|
1696
|
+
`),
|
|
1697
|
+
`${u4}${styleText2("dim", "Search:")} ${$}${s}`,
|
|
1698
|
+
...b2,
|
|
1699
|
+
...v
|
|
1700
|
+
], O = [`${u4}${y.join(" \u2022 ")}`, V2], d = limitOptions({
|
|
1701
|
+
cursor: this.cursor,
|
|
1702
|
+
options: this.filteredOptions,
|
|
1703
|
+
style: (f2, _2) => c2(f2, _2, this.selectedValues, this.focusedValue),
|
|
1704
|
+
maxItems: t2.maxItems,
|
|
1705
|
+
output: t2.output,
|
|
1706
|
+
rowPadding: g2.length + O.length
|
|
1707
|
+
});
|
|
1708
|
+
return [
|
|
1709
|
+
...g2,
|
|
1710
|
+
...d.map((f2) => `${u4}${f2}`),
|
|
1711
|
+
...O
|
|
1712
|
+
].join(`
|
|
1713
|
+
`);
|
|
1714
|
+
}
|
|
1715
|
+
}
|
|
1716
|
+
}
|
|
1717
|
+
});
|
|
1718
|
+
return n3.prompt();
|
|
1719
|
+
}, J, K, Q = (n3) => n3, box = (n3 = "", e = "", t2) => {
|
|
1720
|
+
const o2 = t2?.output ?? process.stdout, i = getColumns(o2), R2 = 1 * 2, u4 = t2?.titlePadding ?? 1, h2 = t2?.contentPadding ?? 2, w = t2?.width === undefined || t2.width === "auto" ? 1 : Math.min(1, t2.width), m2 = t2?.withGuide ?? settings.withGuide ? `${S_BAR} ` : "", b2 = t2?.formatBorder ?? Q, a2 = ((t2?.rounded) ? J : K).map(b2), _2 = b2(S_BAR_H), B = b2(S_BAR), p2 = dist_default2(m2), x = dist_default2(e), O = i - p2;
|
|
1721
|
+
let r2 = Math.floor(i * w) - p2;
|
|
1722
|
+
if (t2?.width === "auto") {
|
|
1723
|
+
const c2 = n3.split(`
|
|
1724
|
+
`);
|
|
1725
|
+
let s = x + u4 * 2;
|
|
1726
|
+
for (const G of c2) {
|
|
1727
|
+
const P3 = dist_default2(G) + h2 * 2;
|
|
1728
|
+
P3 > s && (s = P3);
|
|
1729
|
+
}
|
|
1730
|
+
const g2 = s + R2;
|
|
1731
|
+
g2 < r2 && (r2 = g2);
|
|
1732
|
+
}
|
|
1733
|
+
r2 % 2 !== 0 && (r2 < O ? r2++ : r2--);
|
|
1734
|
+
const d = r2 - R2, S = d - u4 * 2, T3 = x > S ? `${e.slice(0, S - 3)}...` : e, [y, W] = A$1(dist_default2(T3), d, u4, t2?.titleAlign), L = wrapAnsi(n3, d - h2 * 2, {
|
|
1735
|
+
hard: true,
|
|
1736
|
+
trim: false
|
|
1737
|
+
});
|
|
1738
|
+
o2.write(`${m2}${a2[0]}${_2.repeat(y)}${T3}${_2.repeat(W)}${a2[1]}
|
|
1739
|
+
`);
|
|
1740
|
+
const E2 = L.split(`
|
|
1741
|
+
`);
|
|
1742
|
+
for (const c2 of E2) {
|
|
1743
|
+
const [s, g2] = A$1(dist_default2(c2), d, h2, t2?.contentAlign);
|
|
1744
|
+
o2.write(`${m2}${B}${" ".repeat(s)}${c2}${" ".repeat(g2)}${B}
|
|
1745
|
+
`);
|
|
1746
|
+
}
|
|
1747
|
+
o2.write(`${m2}${a2[2]}${_2.repeat(d)}${a2[3]}
|
|
1748
|
+
`);
|
|
1391
1749
|
}, confirm = (i) => {
|
|
1392
1750
|
const a2 = i.active ?? "Yes", s = i.inactive ?? "No";
|
|
1393
1751
|
return new r({
|
|
@@ -1398,7 +1756,7 @@ var import_sisteransi2, unicode, isCI = () => process.env.CI === "true", unicode
|
|
|
1398
1756
|
output: i.output,
|
|
1399
1757
|
initialValue: i.initialValue ?? true,
|
|
1400
1758
|
render() {
|
|
1401
|
-
const e = i.withGuide ?? settings.withGuide,
|
|
1759
|
+
const e = i.withGuide ?? settings.withGuide, u4 = `${symbol(this.state)} `, l2 = e ? `${styleText2("gray", S_BAR)} ` : "", f2 = wrapTextWithPrefix(i.output, i.message, l2, u4), o2 = `${e ? `${styleText2("gray", S_BAR)}
|
|
1402
1760
|
` : ""}${f2}
|
|
1403
1761
|
`, c2 = this.value ? a2 : s;
|
|
1404
1762
|
switch (this.state) {
|
|
@@ -1422,10 +1780,69 @@ ${g2}
|
|
|
1422
1780
|
}
|
|
1423
1781
|
}
|
|
1424
1782
|
}).prompt();
|
|
1425
|
-
},
|
|
1426
|
-
|
|
1783
|
+
}, date = (e) => {
|
|
1784
|
+
const r2 = e.validate;
|
|
1785
|
+
return new U({
|
|
1786
|
+
...e,
|
|
1787
|
+
validate(t2) {
|
|
1788
|
+
if (t2 === undefined)
|
|
1789
|
+
return e.defaultValue !== undefined ? undefined : r2 ? runValidation(r2, t2) : settings.date.messages.required;
|
|
1790
|
+
const o2 = (i) => i.toISOString().slice(0, 10);
|
|
1791
|
+
if (e.minDate && o2(t2) < o2(e.minDate))
|
|
1792
|
+
return settings.date.messages.afterMin(e.minDate);
|
|
1793
|
+
if (e.maxDate && o2(t2) > o2(e.maxDate))
|
|
1794
|
+
return settings.date.messages.beforeMax(e.maxDate);
|
|
1795
|
+
if (r2)
|
|
1796
|
+
return runValidation(r2, t2);
|
|
1797
|
+
},
|
|
1798
|
+
render() {
|
|
1799
|
+
const t2 = (e?.withGuide ?? settings.withGuide) !== false, i = `${`${t2 ? `${styleText2("gray", S_BAR)}
|
|
1800
|
+
` : ""}${symbol(this.state)} `}${e.message}
|
|
1801
|
+
`, l2 = this.state !== "initial" ? this.state : "active", d = b2(this, l2), c2 = this.value instanceof Date ? this.formattedValue : "";
|
|
1802
|
+
switch (this.state) {
|
|
1803
|
+
case "error": {
|
|
1804
|
+
const a2 = this.error ? ` ${styleText2("yellow", this.error)}` : "", s = t2 ? `${styleText2("yellow", S_BAR)} ` : "", f2 = t2 ? styleText2("yellow", S_BAR_END) : "";
|
|
1805
|
+
return `${i.trim()}
|
|
1806
|
+
${s}${d}
|
|
1807
|
+
${f2}${a2}
|
|
1808
|
+
`;
|
|
1809
|
+
}
|
|
1810
|
+
case "submit": {
|
|
1811
|
+
const a2 = c2 ? ` ${styleText2("dim", c2)}` : "", s = t2 ? styleText2("gray", S_BAR) : "";
|
|
1812
|
+
return `${i}${s}${a2}`;
|
|
1813
|
+
}
|
|
1814
|
+
case "cancel": {
|
|
1815
|
+
const a2 = c2 ? ` ${styleText2(["strikethrough", "dim"], c2)}` : "", s = t2 ? styleText2("gray", S_BAR) : "";
|
|
1816
|
+
return `${i}${s}${a2}${c2.trim() ? `
|
|
1817
|
+
${s}` : ""}`;
|
|
1818
|
+
}
|
|
1819
|
+
default: {
|
|
1820
|
+
const a2 = t2 ? `${styleText2("cyan", S_BAR)} ` : "", s = t2 ? styleText2("cyan", S_BAR_END) : "", f2 = t2 ? `${styleText2("cyan", S_BAR)} ` : "", g2 = this.inlineError ? `
|
|
1821
|
+
${f2}${styleText2("yellow", this.inlineError)}` : "";
|
|
1822
|
+
return `${i}${a2}${d}${g2}
|
|
1823
|
+
${s}
|
|
1824
|
+
`;
|
|
1825
|
+
}
|
|
1826
|
+
}
|
|
1827
|
+
}
|
|
1828
|
+
}).prompt();
|
|
1829
|
+
}, p2, group = async (o2, r2) => {
|
|
1830
|
+
const t2 = {}, p3 = Object.keys(o2);
|
|
1831
|
+
for (const e of p3) {
|
|
1832
|
+
const i = o2[e], n3 = await i({ results: t2 })?.catch((a2) => {
|
|
1833
|
+
throw a2;
|
|
1834
|
+
});
|
|
1835
|
+
if (typeof r2?.onCancel == "function" && isCancel(n3)) {
|
|
1836
|
+
t2[e] = "canceled", r2.onCancel({ results: t2 });
|
|
1837
|
+
continue;
|
|
1838
|
+
}
|
|
1839
|
+
t2[e] = n3;
|
|
1840
|
+
}
|
|
1841
|
+
return t2;
|
|
1842
|
+
}, MULTISELECT_INSTRUCTIONS, m2 = (i, u4) => i.split(`
|
|
1843
|
+
`).map((d) => u4(d)).join(`
|
|
1427
1844
|
`), multiselect = (i) => {
|
|
1428
|
-
const
|
|
1845
|
+
const u4 = (t2, a2) => {
|
|
1429
1846
|
const r2 = t2.label ?? String(t2.value);
|
|
1430
1847
|
return a2 === "disabled" ? `${styleText2("gray", S_CHECKBOX_INACTIVE)} ${m2(r2, (o2) => styleText2(["strikethrough", "gray"], o2))}${t2.hint ? ` ${styleText2("dim", `(${t2.hint ?? "disabled"})`)}` : ""}` : a2 === "active" ? `${styleText2("cyan", S_CHECKBOX_ACTIVE)} ${r2}${t2.hint ? ` ${styleText2("dim", `(${t2.hint})`)}` : ""}` : a2 === "selected" ? `${styleText2("green", S_CHECKBOX_SELECTED)} ${m2(r2, (o2) => styleText2("dim", o2))}${t2.hint ? ` ${styleText2("dim", `(${t2.hint})`)}` : ""}` : a2 === "cancelled" ? `${m2(r2, (o2) => styleText2(["strikethrough", "dim"], o2))}` : a2 === "active-selected" ? `${styleText2("green", S_CHECKBOX_SELECTED)} ${r2}${t2.hint ? ` ${styleText2("dim", `(${t2.hint})`)}` : ""}` : a2 === "submitted" ? `${m2(r2, (o2) => styleText2("dim", o2))}` : `${styleText2("dim", S_CHECKBOX_INACTIVE)} ${m2(r2, (o2) => styleText2("dim", o2))}`;
|
|
1431
1848
|
}, d = i.required ?? true, v = i.showInstructions ?? true;
|
|
@@ -1445,19 +1862,19 @@ ${styleText2("reset", styleText2("dim", `Press ${styleText2(["gray", "bgWhite",
|
|
|
1445
1862
|
render() {
|
|
1446
1863
|
const t2 = i.withGuide ?? settings.withGuide, a2 = wrapTextWithPrefix(i.output, i.message, t2 ? `${symbolBar(this.state)} ` : "", `${symbol(this.state)} `), r2 = `${t2 ? `${styleText2("gray", S_BAR)}
|
|
1447
1864
|
` : ""}${a2}
|
|
1448
|
-
`, o2 = this.value ?? [],
|
|
1865
|
+
`, o2 = this.value ?? [], p3 = (n3, l2) => {
|
|
1449
1866
|
if (n3.disabled)
|
|
1450
|
-
return
|
|
1867
|
+
return u4(n3, "disabled");
|
|
1451
1868
|
const s = o2.includes(n3.value);
|
|
1452
|
-
return l2 && s ?
|
|
1869
|
+
return l2 && s ? u4(n3, "active-selected") : s ? u4(n3, "selected") : u4(n3, l2 ? "active" : "inactive");
|
|
1453
1870
|
};
|
|
1454
1871
|
switch (this.state) {
|
|
1455
1872
|
case "submit": {
|
|
1456
|
-
const n3 = this.options.filter(({ value: s }) => o2.includes(s)).map((s) =>
|
|
1873
|
+
const n3 = this.options.filter(({ value: s }) => o2.includes(s)).map((s) => u4(s, "submitted")).join(styleText2("dim", ", ")) || styleText2("dim", "none"), l2 = wrapTextWithPrefix(i.output, n3, t2 ? `${styleText2("gray", S_BAR)} ` : "");
|
|
1457
1874
|
return `${r2}${l2}`;
|
|
1458
1875
|
}
|
|
1459
1876
|
case "cancel": {
|
|
1460
|
-
const n3 = this.options.filter(({ value: s }) => o2.includes(s)).map((s) =>
|
|
1877
|
+
const n3 = this.options.filter(({ value: s }) => o2.includes(s)).map((s) => u4(s, "cancelled")).join(styleText2("dim", ", "));
|
|
1461
1878
|
if (n3.trim() === "")
|
|
1462
1879
|
return `${r2}${styleText2("gray", S_BAR)}`;
|
|
1463
1880
|
const l2 = wrapTextWithPrefix(i.output, n3, t2 ? `${styleText2("gray", S_BAR)} ` : "");
|
|
@@ -1477,7 +1894,7 @@ ${styleText2("gray", S_BAR)}` : ""}`;
|
|
|
1477
1894
|
maxItems: i.maxItems,
|
|
1478
1895
|
columnPadding: n3.length,
|
|
1479
1896
|
rowPadding: s + h2,
|
|
1480
|
-
style:
|
|
1897
|
+
style: p3
|
|
1481
1898
|
}).join(`
|
|
1482
1899
|
${n3}`)}
|
|
1483
1900
|
${l2}
|
|
@@ -1494,7 +1911,7 @@ ${l2}
|
|
|
1494
1911
|
maxItems: i.maxItems,
|
|
1495
1912
|
columnPadding: n3.length,
|
|
1496
1913
|
rowPadding: l2 + $,
|
|
1497
|
-
style:
|
|
1914
|
+
style: p3
|
|
1498
1915
|
}).join(`
|
|
1499
1916
|
${n3}`)}
|
|
1500
1917
|
${h2}
|
|
@@ -1503,7 +1920,103 @@ ${h2}
|
|
|
1503
1920
|
}
|
|
1504
1921
|
}
|
|
1505
1922
|
}).prompt();
|
|
1506
|
-
},
|
|
1923
|
+
}, groupMultiselect = (o2) => {
|
|
1924
|
+
const { selectableGroups: h2 = true, groupSpacing: x2 = 0 } = o2, m3 = (n3, l2, g2 = []) => {
|
|
1925
|
+
const a2 = n3.label ?? String(n3.value), t2 = typeof n3.group == "string", s = t2 && (g2[g2.indexOf(n3) + 1] ?? { group: true }), u4 = t2 && s && s.group === true;
|
|
1926
|
+
let r2 = "", c2 = "";
|
|
1927
|
+
t2 && (h2 ? (r2 = u4 ? `${S_BAR_END} ` : `${S_BAR} `, c2 = u4 ? " " : `${S_BAR} `) : r2 = " ");
|
|
1928
|
+
let i = "";
|
|
1929
|
+
if (x2 > 0 && !t2 && (i = `
|
|
1930
|
+
`.repeat(x2)), l2 === "active")
|
|
1931
|
+
return wrapTextWithPrefix(o2.output, `${a2}${n3.hint ? ` ${styleText2("dim", `(${n3.hint})`)}` : ""}`, `${i}${styleText2("dim", r2)} `, `${i}${styleText2("dim", r2)}${styleText2("cyan", S_CHECKBOX_ACTIVE)} `, `${i}${styleText2("dim", c2)} `);
|
|
1932
|
+
if (l2 === "group-active")
|
|
1933
|
+
return wrapTextWithPrefix(o2.output, a2, `${i}${r2} `, `${i}${r2}${styleText2("cyan", S_CHECKBOX_ACTIVE)} `, `${i}${c2} `, (d) => styleText2("dim", d));
|
|
1934
|
+
if (l2 === "group-active-selected")
|
|
1935
|
+
return wrapTextWithPrefix(o2.output, a2, `${i}${r2} `, `${i}${r2}${styleText2("green", S_CHECKBOX_SELECTED)} `, `${i}${c2} `, (d) => styleText2("dim", d));
|
|
1936
|
+
if (l2 === "selected") {
|
|
1937
|
+
const d = t2 || h2 ? styleText2("green", S_CHECKBOX_SELECTED) : "";
|
|
1938
|
+
return wrapTextWithPrefix(o2.output, `${a2}${n3.hint ? ` (${n3.hint})` : ""}`, `${i}${styleText2("dim", r2)} `, `${i}${styleText2("dim", r2)}${d} `, `${i}${styleText2("dim", c2)} `, (S) => styleText2("dim", S));
|
|
1939
|
+
}
|
|
1940
|
+
if (l2 === "cancelled")
|
|
1941
|
+
return `${styleText2(["strikethrough", "dim"], a2)}`;
|
|
1942
|
+
if (l2 === "active-selected")
|
|
1943
|
+
return wrapTextWithPrefix(o2.output, `${a2}${n3.hint ? ` ${styleText2("dim", `(${n3.hint})`)}` : ""}`, `${i}${styleText2("dim", r2)} `, `${i}${styleText2("dim", r2)}${styleText2("green", S_CHECKBOX_SELECTED)} `, `${i}${styleText2("dim", c2)} `);
|
|
1944
|
+
if (l2 === "submitted")
|
|
1945
|
+
return `${styleText2("dim", a2)}`;
|
|
1946
|
+
const f2 = t2 || h2 ? styleText2("dim", S_CHECKBOX_INACTIVE) : "";
|
|
1947
|
+
return wrapTextWithPrefix(o2.output, a2, `${i}${styleText2("dim", r2)} `, `${i}${styleText2("dim", r2)}${f2} `, `${i}${styleText2("dim", c2)} `, (d) => styleText2("dim", d));
|
|
1948
|
+
}, y = o2.required ?? true, I2 = o2.showInstructions ?? true;
|
|
1949
|
+
return new u$2({
|
|
1950
|
+
options: o2.options,
|
|
1951
|
+
signal: o2.signal,
|
|
1952
|
+
input: o2.input,
|
|
1953
|
+
output: o2.output,
|
|
1954
|
+
initialValues: o2.initialValues,
|
|
1955
|
+
required: y,
|
|
1956
|
+
cursorAt: o2.cursorAt,
|
|
1957
|
+
selectableGroups: h2,
|
|
1958
|
+
validate(n3) {
|
|
1959
|
+
if (y && (n3 === undefined || n3.length === 0))
|
|
1960
|
+
return `Please select at least one option.
|
|
1961
|
+
${styleText2("reset", styleText2("dim", `Press ${styleText2(["gray", "bgWhite", "inverse"], " space ")} to select, ${styleText2("gray", styleText2(["bgWhite", "inverse"], " enter "))} to submit`))}`;
|
|
1962
|
+
},
|
|
1963
|
+
render() {
|
|
1964
|
+
const n3 = o2.withGuide ?? settings.withGuide, l2 = `${n3 ? `${styleText2("gray", S_BAR)}
|
|
1965
|
+
` : ""}${symbol(this.state)} ${o2.message}
|
|
1966
|
+
`, g2 = this.value ?? [], a2 = (t2, s) => {
|
|
1967
|
+
const u4 = this.options, r2 = g2.includes(t2.value) || t2.group === true && this.isGroupSelected(`${t2.value}`);
|
|
1968
|
+
return !s && typeof t2.group == "string" && this.options[this.cursor]?.value === t2.group ? m3(t2, r2 ? "group-active-selected" : "group-active", u4) : s && r2 ? m3(t2, "active-selected", u4) : r2 ? m3(t2, "selected", u4) : m3(t2, s ? "active" : "inactive", u4);
|
|
1969
|
+
};
|
|
1970
|
+
switch (this.state) {
|
|
1971
|
+
case "submit": {
|
|
1972
|
+
const t2 = this.options.filter(({ value: u4 }) => g2.includes(u4)).map((u4) => m3(u4, "submitted")), s = t2.length === 0 ? "" : ` ${t2.join(styleText2("dim", ", "))}`;
|
|
1973
|
+
return `${l2}${n3 ? styleText2("gray", S_BAR) : ""}${s}`;
|
|
1974
|
+
}
|
|
1975
|
+
case "cancel": {
|
|
1976
|
+
const t2 = this.options.filter(({ value: s }) => g2.includes(s)).map((s) => m3(s, "cancelled")).join(styleText2("dim", ", "));
|
|
1977
|
+
return `${l2}${n3 ? `${styleText2("gray", S_BAR)} ` : ""}${t2.trim() ? `${t2}${n3 ? `
|
|
1978
|
+
${styleText2("gray", S_BAR)}` : ""}` : ""}`;
|
|
1979
|
+
}
|
|
1980
|
+
case "error": {
|
|
1981
|
+
const t2 = n3 ? `${styleText2("yellow", S_BAR)} ` : "", s = this.error.split(`
|
|
1982
|
+
`).map((i, f2) => f2 === 0 ? `${n3 ? `${styleText2("yellow", S_BAR_END)} ` : ""}${styleText2("yellow", i)}` : ` ${i}`).join(`
|
|
1983
|
+
`), u4 = l2.split(`
|
|
1984
|
+
`).length, r2 = s.split(`
|
|
1985
|
+
`).length + 1, c2 = limitOptions({
|
|
1986
|
+
output: o2.output,
|
|
1987
|
+
options: this.options,
|
|
1988
|
+
cursor: this.cursor,
|
|
1989
|
+
maxItems: o2.maxItems,
|
|
1990
|
+
columnPadding: t2.length,
|
|
1991
|
+
rowPadding: u4 + r2,
|
|
1992
|
+
style: a2
|
|
1993
|
+
}).join(`
|
|
1994
|
+
${t2}`);
|
|
1995
|
+
return `${l2}${t2}${c2}
|
|
1996
|
+
${s}
|
|
1997
|
+
`;
|
|
1998
|
+
}
|
|
1999
|
+
default: {
|
|
2000
|
+
const t2 = n3 ? `${styleText2("cyan", S_BAR)} ` : "", s = l2.split(`
|
|
2001
|
+
`).length, u4 = I2 ? formatInstructionFooter(MULTISELECT_INSTRUCTIONS, n3) : n3 ? [styleText2("cyan", S_BAR_END)] : [], r2 = u4.join(`
|
|
2002
|
+
`), c2 = u4.length + 1, i = limitOptions({
|
|
2003
|
+
output: o2.output,
|
|
2004
|
+
options: this.options,
|
|
2005
|
+
cursor: this.cursor,
|
|
2006
|
+
maxItems: o2.maxItems,
|
|
2007
|
+
columnPadding: t2.length,
|
|
2008
|
+
rowPadding: s + c2,
|
|
2009
|
+
style: a2
|
|
2010
|
+
}).join(`
|
|
2011
|
+
${t2}`);
|
|
2012
|
+
return `${l2}${t2}${i}
|
|
2013
|
+
${r2}
|
|
2014
|
+
`;
|
|
2015
|
+
}
|
|
2016
|
+
}
|
|
2017
|
+
}
|
|
2018
|
+
}).prompt();
|
|
2019
|
+
}, log, cancel = (o2 = "", t2) => {
|
|
1507
2020
|
const i = t2?.output ?? process.stdout, e = t2?.withGuide ?? settings.withGuide ? `${styleText2("gray", S_BAR_END)} ` : "";
|
|
1508
2021
|
i.write(`${e}${styleText2("red", o2)}
|
|
1509
2022
|
|
|
@@ -1518,20 +2031,148 @@ ${styleText2("gray", S_BAR_END)} ` : "";
|
|
|
1518
2031
|
i.write(`${e}${o2}
|
|
1519
2032
|
|
|
1520
2033
|
`);
|
|
2034
|
+
}, multiline = (e) => new h({
|
|
2035
|
+
validate: e.validate,
|
|
2036
|
+
placeholder: e.placeholder,
|
|
2037
|
+
defaultValue: e.defaultValue,
|
|
2038
|
+
initialValue: e.initialValue,
|
|
2039
|
+
showSubmit: e.showSubmit,
|
|
2040
|
+
output: e.output,
|
|
2041
|
+
signal: e.signal,
|
|
2042
|
+
input: e.input,
|
|
2043
|
+
render() {
|
|
2044
|
+
const i = e?.withGuide ?? settings.withGuide, o2 = `${`${i ? `${styleText2("gray", S_BAR)}
|
|
2045
|
+
` : ""}${symbol(this.state)} `}${e.message}
|
|
2046
|
+
`, m3 = e.placeholder && e.placeholder.length > 0 ? styleText2("inverse", e.placeholder[0]) + styleText2("dim", e.placeholder.slice(1)) : styleText2(["inverse", "hidden"], "_"), a2 = this.userInput ? this.userInputWithCursor : m3, l2 = this.value ?? "", c2 = e.showSubmit ? `
|
|
2047
|
+
${styleText2(this.focused === "submit" ? "cyan" : "dim", "[ submit ]")}` : "";
|
|
2048
|
+
switch (this.state) {
|
|
2049
|
+
case "error": {
|
|
2050
|
+
const n3 = `${styleText2("yellow", S_BAR)} `, r2 = i ? wrapTextWithPrefix(e.output, a2, n3, undefined) : a2, u4 = styleText2("yellow", S_BAR_END);
|
|
2051
|
+
return `${o2}${r2}
|
|
2052
|
+
${u4} ${styleText2("yellow", this.error)}${c2}
|
|
2053
|
+
`;
|
|
2054
|
+
}
|
|
2055
|
+
case "submit": {
|
|
2056
|
+
const n3 = `${styleText2("gray", S_BAR)} `, r2 = i ? wrapTextWithPrefix(e.output, l2, n3, undefined, undefined, (u4) => styleText2("dim", u4)) : l2 ? styleText2("dim", l2) : "";
|
|
2057
|
+
return `${o2}${r2}`;
|
|
2058
|
+
}
|
|
2059
|
+
case "cancel": {
|
|
2060
|
+
const n3 = `${styleText2("gray", S_BAR)} `, r2 = i ? wrapTextWithPrefix(e.output, l2, n3, undefined, undefined, (u4) => styleText2(["strikethrough", "dim"], u4)) : l2 ? styleText2(["strikethrough", "dim"], l2) : "";
|
|
2061
|
+
return `${o2}${r2}`;
|
|
2062
|
+
}
|
|
2063
|
+
default: {
|
|
2064
|
+
const n3 = i ? `${styleText2("cyan", S_BAR)} ` : "", r2 = i ? styleText2("cyan", S_BAR_END) : "", u4 = i ? wrapTextWithPrefix(e.output, a2, n3) : a2;
|
|
2065
|
+
return `${o2}${u4}
|
|
2066
|
+
${r2}${c2}
|
|
2067
|
+
`;
|
|
2068
|
+
}
|
|
2069
|
+
}
|
|
2070
|
+
}
|
|
2071
|
+
}).prompt(), W$1 = (o2) => o2, C2 = (o2, e, s) => {
|
|
2072
|
+
const a2 = {
|
|
2073
|
+
hard: true,
|
|
2074
|
+
trim: false
|
|
2075
|
+
}, i = wrapAnsi(o2, e, a2).split(`
|
|
2076
|
+
`), c2 = i.reduce((n3, t2) => Math.max(dist_default2(t2), n3), 0), u4 = i.map(s).reduce((n3, t2) => Math.max(dist_default2(t2), n3), 0), g2 = e - (u4 - c2);
|
|
2077
|
+
return wrapAnsi(o2, g2, a2);
|
|
2078
|
+
}, note = (o2 = "", e = "", s) => {
|
|
2079
|
+
const a2 = s?.output ?? process$1.stdout, i = s?.withGuide ?? settings.withGuide, c2 = s?.format ?? W$1, g2 = ["", ...C2(o2, getColumns(a2) - 6, c2).split(`
|
|
2080
|
+
`).map(c2), ""], n3 = dist_default2(e), t2 = Math.max(g2.reduce((m3, F) => {
|
|
2081
|
+
const O = dist_default2(F);
|
|
2082
|
+
return O > m3 ? O : m3;
|
|
2083
|
+
}, 0), n3) + 2, h2 = g2.map((m3) => `${styleText2("gray", S_BAR)} ${m3}${" ".repeat(t2 - dist_default2(m3))}${styleText2("gray", S_BAR)}`).join(`
|
|
2084
|
+
`), T3 = i ? `${styleText2("gray", S_BAR)}
|
|
2085
|
+
` : "", l$1 = i ? S_CONNECT_LEFT : S_CORNER_BOTTOM_LEFT;
|
|
2086
|
+
a2.write(`${T3}${styleText2("green", S_STEP_SUBMIT)} ${styleText2("reset", e)} ${styleText2("gray", S_BAR_H.repeat(Math.max(t2 - n3 - 1, 1)) + S_CORNER_TOP_RIGHT)}
|
|
2087
|
+
${h2}
|
|
2088
|
+
${styleText2("gray", l$1 + S_BAR_H.repeat(t2 + 2) + S_CORNER_BOTTOM_RIGHT)}
|
|
2089
|
+
`);
|
|
2090
|
+
}, password = (r2) => new u$1({
|
|
2091
|
+
validate: r2.validate,
|
|
2092
|
+
mask: r2.mask ?? S_PASSWORD_MASK,
|
|
2093
|
+
signal: r2.signal,
|
|
2094
|
+
input: r2.input,
|
|
2095
|
+
output: r2.output,
|
|
2096
|
+
render() {
|
|
2097
|
+
const e = r2.withGuide ?? settings.withGuide, o2 = `${e ? `${styleText2("gray", S_BAR)}
|
|
2098
|
+
` : ""}${symbol(this.state)} ${r2.message}
|
|
2099
|
+
`, c2 = this.userInputWithCursor, i = this.masked;
|
|
2100
|
+
switch (this.state) {
|
|
2101
|
+
case "error": {
|
|
2102
|
+
const s = e ? `${styleText2("yellow", S_BAR)} ` : "", n3 = e ? `${styleText2("yellow", S_BAR_END)} ` : "", l2 = i ?? "";
|
|
2103
|
+
return r2.clearOnError && this.clear(), `${o2.trim()}
|
|
2104
|
+
${s}${l2}
|
|
2105
|
+
${n3}${styleText2("yellow", this.error)}
|
|
2106
|
+
`;
|
|
2107
|
+
}
|
|
2108
|
+
case "submit": {
|
|
2109
|
+
const s = e ? `${styleText2("gray", S_BAR)} ` : "", n3 = i ? styleText2("dim", i) : "";
|
|
2110
|
+
return `${o2}${s}${n3}`;
|
|
2111
|
+
}
|
|
2112
|
+
case "cancel": {
|
|
2113
|
+
const s = e ? `${styleText2("gray", S_BAR)} ` : "", n3 = i ? styleText2(["strikethrough", "dim"], i) : "";
|
|
2114
|
+
return `${o2}${s}${n3}${i && e ? `
|
|
2115
|
+
${styleText2("gray", S_BAR)}` : ""}`;
|
|
2116
|
+
}
|
|
2117
|
+
default: {
|
|
2118
|
+
const s = e ? `${styleText2("cyan", S_BAR)} ` : "", n3 = e ? styleText2("cyan", S_BAR_END) : "";
|
|
2119
|
+
return `${o2}${s}${c2}
|
|
2120
|
+
${n3}
|
|
2121
|
+
`;
|
|
2122
|
+
}
|
|
2123
|
+
}
|
|
2124
|
+
}
|
|
2125
|
+
}).prompt(), path = (e) => {
|
|
2126
|
+
const a2 = e.validate;
|
|
2127
|
+
return autocomplete({
|
|
2128
|
+
...e,
|
|
2129
|
+
initialUserInput: e.initialValue ?? e.root ?? process.cwd(),
|
|
2130
|
+
maxItems: 5,
|
|
2131
|
+
validate(t2) {
|
|
2132
|
+
if (!Array.isArray(t2)) {
|
|
2133
|
+
if (!t2)
|
|
2134
|
+
return "Please select a path";
|
|
2135
|
+
if (a2)
|
|
2136
|
+
return runValidation(a2, t2);
|
|
2137
|
+
}
|
|
2138
|
+
},
|
|
2139
|
+
options() {
|
|
2140
|
+
const t2 = this.userInput;
|
|
2141
|
+
if (t2 === "")
|
|
2142
|
+
return [];
|
|
2143
|
+
try {
|
|
2144
|
+
let i;
|
|
2145
|
+
existsSync(t2) ? lstatSync(t2).isDirectory() && (!e.directory || t2.endsWith("/")) ? i = t2 : i = dirname(t2) : i = dirname(t2);
|
|
2146
|
+
const c2 = t2.length > 1 && t2.endsWith("/") ? t2.slice(0, -1) : t2;
|
|
2147
|
+
return readdirSync(i).map((r2) => {
|
|
2148
|
+
const n3 = join(i, r2), m3 = lstatSync(n3);
|
|
2149
|
+
return {
|
|
2150
|
+
name: r2,
|
|
2151
|
+
path: n3,
|
|
2152
|
+
isDirectory: m3.isDirectory()
|
|
2153
|
+
};
|
|
2154
|
+
}).filter(({ path: r2, isDirectory: n3 }) => r2.startsWith(c2) && (n3 || !e.directory)).map((r2) => ({
|
|
2155
|
+
value: r2.path
|
|
2156
|
+
}));
|
|
2157
|
+
} catch {
|
|
2158
|
+
return [];
|
|
2159
|
+
}
|
|
2160
|
+
}
|
|
2161
|
+
});
|
|
1521
2162
|
}, W = (l2) => styleText2("magenta", l2), spinner = ({
|
|
1522
2163
|
indicator: l2 = "dots",
|
|
1523
2164
|
onCancel: h2,
|
|
1524
2165
|
output: n3 = process.stdout,
|
|
1525
2166
|
cancelMessage: G,
|
|
1526
2167
|
errorMessage: O,
|
|
1527
|
-
frames:
|
|
2168
|
+
frames: E2 = unicode ? ["\u25D2", "\u25D0", "\u25D3", "\u25D1"] : ["\u2022", "o", "O", "0"],
|
|
1528
2169
|
delay: F = unicode ? 80 : 120,
|
|
1529
2170
|
signal: m3,
|
|
1530
2171
|
...I2
|
|
1531
2172
|
} = {}) => {
|
|
1532
|
-
const
|
|
1533
|
-
let M2, T3, d = false, S = false, s = "",
|
|
1534
|
-
const
|
|
2173
|
+
const u4 = isCI();
|
|
2174
|
+
let M2, T3, d = false, S = false, s = "", p3, w = performance.now();
|
|
2175
|
+
const x2 = getColumns(n3), k = I2?.styleFrame ?? W, g2 = (e) => {
|
|
1535
2176
|
const r2 = e > 1 ? O ?? settings.messages.error : G ?? settings.messages.cancel;
|
|
1536
2177
|
S = e === 1, d && (a2(r2, e), S && typeof h2 == "function" && h2());
|
|
1537
2178
|
}, f2 = () => g2(2), i = () => g2(1), A = () => {
|
|
@@ -1539,30 +2180,30 @@ ${styleText2("gray", S_BAR_END)} ` : "";
|
|
|
1539
2180
|
}, H = () => {
|
|
1540
2181
|
process.removeListener("uncaughtExceptionMonitor", f2), process.removeListener("unhandledRejection", f2), process.removeListener("SIGINT", i), process.removeListener("SIGTERM", i), process.removeListener("exit", g2), m3 && m3.removeEventListener("abort", i);
|
|
1541
2182
|
}, y = () => {
|
|
1542
|
-
if (
|
|
2183
|
+
if (p3 === undefined)
|
|
1543
2184
|
return;
|
|
1544
|
-
|
|
2185
|
+
u4 && n3.write(`
|
|
1545
2186
|
`);
|
|
1546
|
-
const r2 = wrapAnsi(
|
|
2187
|
+
const r2 = wrapAnsi(p3, x2, {
|
|
1547
2188
|
hard: true,
|
|
1548
2189
|
trim: false
|
|
1549
2190
|
}).split(`
|
|
1550
2191
|
`);
|
|
1551
2192
|
r2.length > 1 && n3.write(import_sisteransi2.cursor.up(r2.length - 1)), n3.write(import_sisteransi2.cursor.to(0)), n3.write(import_sisteransi2.erase.down());
|
|
1552
|
-
},
|
|
2193
|
+
}, C3 = (e) => e.replace(/\.+$/, ""), _2 = (e) => {
|
|
1553
2194
|
const r2 = (performance.now() - e) / 1000, t2 = Math.floor(r2 / 60), o2 = Math.floor(r2 % 60);
|
|
1554
2195
|
return t2 > 0 ? `[${t2}m ${o2}s]` : `[${o2}s]`;
|
|
1555
|
-
},
|
|
1556
|
-
d = true, M2 = block({ output: n3 }), s =
|
|
2196
|
+
}, N2 = I2.withGuide ?? settings.withGuide, P3 = (e = "") => {
|
|
2197
|
+
d = true, M2 = block({ output: n3 }), s = C3(e), w = performance.now(), N2 && n3.write(`${styleText2("gray", S_BAR)}
|
|
1557
2198
|
`);
|
|
1558
2199
|
let r2 = 0, t2 = 0;
|
|
1559
2200
|
A(), T3 = setInterval(() => {
|
|
1560
|
-
if (
|
|
2201
|
+
if (u4 && s === p3)
|
|
1561
2202
|
return;
|
|
1562
|
-
y(),
|
|
1563
|
-
const o2 = k(
|
|
2203
|
+
y(), p3 = s;
|
|
2204
|
+
const o2 = k(E2[r2]);
|
|
1564
2205
|
let v;
|
|
1565
|
-
if (
|
|
2206
|
+
if (u4)
|
|
1566
2207
|
v = `${o2} ${s}...`;
|
|
1567
2208
|
else if (l2 === "timer")
|
|
1568
2209
|
v = `${o2} ${s} ${_2(w)}`;
|
|
@@ -1570,11 +2211,11 @@ ${styleText2("gray", S_BAR_END)} ` : "";
|
|
|
1570
2211
|
const B = ".".repeat(Math.floor(t2)).slice(0, 3);
|
|
1571
2212
|
v = `${o2} ${s}${B}`;
|
|
1572
2213
|
}
|
|
1573
|
-
const j = wrapAnsi(v,
|
|
2214
|
+
const j = wrapAnsi(v, x2, {
|
|
1574
2215
|
hard: true,
|
|
1575
2216
|
trim: false
|
|
1576
2217
|
});
|
|
1577
|
-
n3.write(j), r2 = r2 + 1 <
|
|
2218
|
+
n3.write(j), r2 = r2 + 1 < E2.length ? r2 + 1 : 0, t2 = t2 < 4 ? t2 + 0.125 : 0;
|
|
1578
2219
|
}, F);
|
|
1579
2220
|
}, a2 = (e = "", r2 = 0, t2 = false) => {
|
|
1580
2221
|
if (!d)
|
|
@@ -1586,10 +2227,10 @@ ${styleText2("gray", S_BAR_END)} ` : "";
|
|
|
1586
2227
|
`)), H(), M2();
|
|
1587
2228
|
};
|
|
1588
2229
|
return {
|
|
1589
|
-
start:
|
|
2230
|
+
start: P3,
|
|
1590
2231
|
stop: (e = "") => a2(e, 0),
|
|
1591
2232
|
message: (e = "") => {
|
|
1592
|
-
s =
|
|
2233
|
+
s = C3(e ?? s);
|
|
1593
2234
|
},
|
|
1594
2235
|
cancel: (e = "") => a2(e, 1),
|
|
1595
2236
|
error: (e = "") => a2(e, 2),
|
|
@@ -1598,7 +2239,7 @@ ${styleText2("gray", S_BAR_END)} ` : "";
|
|
|
1598
2239
|
return S;
|
|
1599
2240
|
}
|
|
1600
2241
|
};
|
|
1601
|
-
},
|
|
2242
|
+
}, u4, SELECT_INSTRUCTIONS, c2 = (t2, o2) => t2.includes(`
|
|
1602
2243
|
`) ? t2.split(`
|
|
1603
2244
|
`).map((d) => o2(d)).join(`
|
|
1604
2245
|
`) : o2(t2), select = (t2) => {
|
|
@@ -1626,40 +2267,196 @@ ${styleText2("gray", S_BAR_END)} ` : "";
|
|
|
1626
2267
|
output: t2.output,
|
|
1627
2268
|
initialValue: t2.initialValue,
|
|
1628
2269
|
render() {
|
|
1629
|
-
const n3 = t2.withGuide ?? settings.withGuide, m3 = `${symbol(this.state)} `, s = `${symbolBar(this.state)} `, i = wrapTextWithPrefix(t2.output, t2.message, s, m3),
|
|
2270
|
+
const n3 = t2.withGuide ?? settings.withGuide, m3 = `${symbol(this.state)} `, s = `${symbolBar(this.state)} `, i = wrapTextWithPrefix(t2.output, t2.message, s, m3), u5 = `${n3 ? `${styleText2("gray", S_BAR)}
|
|
1630
2271
|
` : ""}${i}
|
|
1631
2272
|
`;
|
|
1632
2273
|
switch (this.state) {
|
|
1633
2274
|
case "submit": {
|
|
1634
2275
|
const r2 = n3 ? `${styleText2("gray", S_BAR)} ` : "", a2 = wrapTextWithPrefix(t2.output, o2(this.options[this.cursor], "selected"), r2);
|
|
1635
|
-
return `${
|
|
2276
|
+
return `${u5}${a2}`;
|
|
1636
2277
|
}
|
|
1637
2278
|
case "cancel": {
|
|
1638
2279
|
const r2 = n3 ? `${styleText2("gray", S_BAR)} ` : "", a2 = wrapTextWithPrefix(t2.output, o2(this.options[this.cursor], "cancelled"), r2);
|
|
1639
|
-
return `${
|
|
2280
|
+
return `${u5}${a2}${n3 ? `
|
|
1640
2281
|
${styleText2("gray", S_BAR)}` : ""}`;
|
|
1641
2282
|
}
|
|
1642
2283
|
default: {
|
|
1643
|
-
const r2 = n3 ? `${styleText2("cyan", S_BAR)} ` : "", a2 =
|
|
1644
|
-
`).length,
|
|
1645
|
-
`), f2 =
|
|
1646
|
-
return `${
|
|
2284
|
+
const r2 = n3 ? `${styleText2("cyan", S_BAR)} ` : "", a2 = u5.split(`
|
|
2285
|
+
`).length, p3 = d ? formatInstructionFooter(SELECT_INSTRUCTIONS, n3) : n3 ? [styleText2("cyan", S_BAR_END)] : [], b3 = p3.join(`
|
|
2286
|
+
`), f2 = p3.length + 1;
|
|
2287
|
+
return `${u5}${r2}${limitOptions({
|
|
1647
2288
|
output: t2.output,
|
|
1648
2289
|
cursor: this.cursor,
|
|
1649
2290
|
options: this.options,
|
|
1650
2291
|
maxItems: t2.maxItems,
|
|
1651
2292
|
columnPadding: r2.length,
|
|
1652
2293
|
rowPadding: a2 + f2,
|
|
1653
|
-
style: (g2,
|
|
2294
|
+
style: (g2, x2) => o2(g2, g2.disabled ? "disabled" : x2 ? "active" : "inactive")
|
|
1654
2295
|
}).join(`
|
|
1655
2296
|
${r2}`)}
|
|
1656
|
-
${
|
|
2297
|
+
${b3}
|
|
2298
|
+
`;
|
|
2299
|
+
}
|
|
2300
|
+
}
|
|
2301
|
+
}
|
|
2302
|
+
}).prompt();
|
|
2303
|
+
}, selectKey = (t2) => {
|
|
2304
|
+
const l2 = (e, a2 = "inactive") => {
|
|
2305
|
+
if (e === undefined)
|
|
2306
|
+
return "";
|
|
2307
|
+
const n3 = e.label ?? String(e.value);
|
|
2308
|
+
return a2 === "selected" ? `${styleText2("dim", n3)}` : a2 === "cancelled" ? `${styleText2(["strikethrough", "dim"], n3)}` : a2 === "active" ? `${styleText2(["bgCyan", "gray"], ` ${e.value} `)} ${n3}${e.hint ? ` ${styleText2("dim", `(${e.hint})`)}` : ""}` : `${styleText2(["gray", "bgWhite", "inverse"], ` ${e.value} `)} ${n3}${e.hint ? ` ${styleText2("dim", `(${e.hint})`)}` : ""}`;
|
|
2309
|
+
};
|
|
2310
|
+
return new u3({
|
|
2311
|
+
options: t2.options,
|
|
2312
|
+
signal: t2.signal,
|
|
2313
|
+
input: t2.input,
|
|
2314
|
+
output: t2.output,
|
|
2315
|
+
initialValue: t2.initialValue,
|
|
2316
|
+
caseSensitive: t2.caseSensitive,
|
|
2317
|
+
render() {
|
|
2318
|
+
const e = t2.withGuide ?? settings.withGuide, a2 = `${e ? `${styleText2("gray", S_BAR)}
|
|
2319
|
+
` : ""}${symbol(this.state)} ${t2.message}
|
|
2320
|
+
`;
|
|
2321
|
+
switch (this.state) {
|
|
2322
|
+
case "submit": {
|
|
2323
|
+
const n3 = e ? `${styleText2("gray", S_BAR)} ` : "", s = this.options.find((u5) => u5.value === this.value) ?? t2.options[0], c3 = wrapTextWithPrefix(t2.output, l2(s, "selected"), n3);
|
|
2324
|
+
return `${a2}${c3}`;
|
|
2325
|
+
}
|
|
2326
|
+
case "cancel": {
|
|
2327
|
+
const n3 = e ? `${styleText2("gray", S_BAR)} ` : "", s = wrapTextWithPrefix(t2.output, l2(this.options[0], "cancelled"), n3);
|
|
2328
|
+
return `${a2}${s}${e ? `
|
|
2329
|
+
${styleText2("gray", S_BAR)}` : ""}`;
|
|
2330
|
+
}
|
|
2331
|
+
default: {
|
|
2332
|
+
const n3 = e ? `${styleText2("cyan", S_BAR)} ` : "", s = e ? styleText2("cyan", S_BAR_END) : "", c3 = this.options.map((u5, d) => wrapTextWithPrefix(t2.output, l2(u5, d === this.cursor ? "active" : "inactive"), n3)).join(`
|
|
2333
|
+
`);
|
|
2334
|
+
return `${a2}${c3}
|
|
2335
|
+
${s}
|
|
1657
2336
|
`;
|
|
1658
2337
|
}
|
|
1659
2338
|
}
|
|
1660
2339
|
}
|
|
1661
2340
|
}).prompt();
|
|
1662
|
-
}, i,
|
|
2341
|
+
}, i, stream, tasks = async (o2, e) => {
|
|
2342
|
+
for (const t2 of o2) {
|
|
2343
|
+
if (t2.enabled === false)
|
|
2344
|
+
continue;
|
|
2345
|
+
const s = spinner(e);
|
|
2346
|
+
s.start(t2.title);
|
|
2347
|
+
const n3 = await t2.task(s.message);
|
|
2348
|
+
s.stop(n3 || t2.title);
|
|
2349
|
+
}
|
|
2350
|
+
}, A = (l2) => l2.replace(/\x1b\[(?:\d+;)*\d*[ABCDEFGHfJKSTsu]|\x1b\[(s|u)/g, ""), taskLog = (l2) => {
|
|
2351
|
+
const r2 = l2.output ?? process.stdout, O = getColumns(r2), i2 = styleText2("gray", S_BAR), p3 = l2.spacing ?? 1, k = 3, m3 = l2.retainLog === true, d = !isCI() && isTTY(r2);
|
|
2352
|
+
r2.write(`${i2}
|
|
2353
|
+
`), r2.write(`${styleText2("green", S_STEP_SUBMIT)} ${l2.title}
|
|
2354
|
+
`);
|
|
2355
|
+
for (let e = 0;e < p3; e++)
|
|
2356
|
+
r2.write(`${i2}
|
|
2357
|
+
`);
|
|
2358
|
+
const n3 = [
|
|
2359
|
+
{
|
|
2360
|
+
value: "",
|
|
2361
|
+
full: ""
|
|
2362
|
+
}
|
|
2363
|
+
];
|
|
2364
|
+
let v = false;
|
|
2365
|
+
const f2 = (e) => {
|
|
2366
|
+
if (n3.length === 0)
|
|
2367
|
+
return;
|
|
2368
|
+
let s = 0;
|
|
2369
|
+
e && (s += p3 + 2);
|
|
2370
|
+
for (const t2 of n3) {
|
|
2371
|
+
const { value: o2, result: a2 } = t2;
|
|
2372
|
+
let g2 = a2?.message ?? o2;
|
|
2373
|
+
if (g2.length === 0)
|
|
2374
|
+
continue;
|
|
2375
|
+
a2 === undefined && t2.header !== undefined && t2.header !== "" && (g2 += `
|
|
2376
|
+
${t2.header}`);
|
|
2377
|
+
const E2 = g2.split(`
|
|
2378
|
+
`).reduce((b3, w) => w === "" ? b3 + 1 : b3 + Math.ceil((w.length + k) / O), 0);
|
|
2379
|
+
s += E2;
|
|
2380
|
+
}
|
|
2381
|
+
s > 0 && (s += 1, r2.write(import_sisteransi2.erase.lines(s)));
|
|
2382
|
+
}, h2 = (e, s, t2) => {
|
|
2383
|
+
const o2 = t2 ? `${e.full}
|
|
2384
|
+
${e.value}` : e.value;
|
|
2385
|
+
e.header !== undefined && e.header !== "" && log.message(e.header.split(`
|
|
2386
|
+
`).map((a2) => styleText2("bold", a2)), {
|
|
2387
|
+
output: r2,
|
|
2388
|
+
secondarySymbol: i2,
|
|
2389
|
+
symbol: i2,
|
|
2390
|
+
spacing: 0
|
|
2391
|
+
}), log.message(o2.split(`
|
|
2392
|
+
`).map((a2) => styleText2("dim", a2)), {
|
|
2393
|
+
output: r2,
|
|
2394
|
+
secondarySymbol: i2,
|
|
2395
|
+
symbol: i2,
|
|
2396
|
+
spacing: s ?? p3
|
|
2397
|
+
});
|
|
2398
|
+
}, T3 = () => {
|
|
2399
|
+
for (const e of n3) {
|
|
2400
|
+
const { header: s, value: t2, full: o2 } = e;
|
|
2401
|
+
(s === undefined || s.length === 0) && t2.length === 0 || h2(e, undefined, m3 === true && o2.length > 0);
|
|
2402
|
+
}
|
|
2403
|
+
}, L = (e, s, t2) => {
|
|
2404
|
+
if (f2(false), (t2?.raw !== true || !v) && e.value !== "" && (e.value += `
|
|
2405
|
+
`), e.value += A(s), v = t2?.raw === true, l2.limit !== undefined) {
|
|
2406
|
+
const o2 = e.value.split(`
|
|
2407
|
+
`), a2 = o2.length - l2.limit;
|
|
2408
|
+
if (a2 > 0) {
|
|
2409
|
+
const g2 = o2.splice(0, a2);
|
|
2410
|
+
m3 && (e.full += (e.full === "" ? "" : `
|
|
2411
|
+
`) + g2.join(`
|
|
2412
|
+
`));
|
|
2413
|
+
}
|
|
2414
|
+
e.value = o2.join(`
|
|
2415
|
+
`);
|
|
2416
|
+
}
|
|
2417
|
+
d && y();
|
|
2418
|
+
}, y = () => {
|
|
2419
|
+
for (const e of n3)
|
|
2420
|
+
e.result ? e.result.status === "error" ? log.error(e.result.message, { output: r2, secondarySymbol: i2, spacing: 0 }) : log.success(e.result.message, { output: r2, secondarySymbol: i2, spacing: 0 }) : e.value !== "" && h2(e, 0);
|
|
2421
|
+
}, B = (e, s) => {
|
|
2422
|
+
f2(false), e.result = s, d && y();
|
|
2423
|
+
};
|
|
2424
|
+
return {
|
|
2425
|
+
message(e, s) {
|
|
2426
|
+
L(n3[0], e, s);
|
|
2427
|
+
},
|
|
2428
|
+
group(e) {
|
|
2429
|
+
const s = {
|
|
2430
|
+
header: e,
|
|
2431
|
+
value: "",
|
|
2432
|
+
full: ""
|
|
2433
|
+
};
|
|
2434
|
+
return n3.push(s), {
|
|
2435
|
+
message(t2, o2) {
|
|
2436
|
+
L(s, t2, o2);
|
|
2437
|
+
},
|
|
2438
|
+
error(t2) {
|
|
2439
|
+
B(s, {
|
|
2440
|
+
status: "error",
|
|
2441
|
+
message: t2
|
|
2442
|
+
});
|
|
2443
|
+
},
|
|
2444
|
+
success(t2) {
|
|
2445
|
+
B(s, {
|
|
2446
|
+
status: "success",
|
|
2447
|
+
message: t2
|
|
2448
|
+
});
|
|
2449
|
+
}
|
|
2450
|
+
};
|
|
2451
|
+
},
|
|
2452
|
+
error(e, s) {
|
|
2453
|
+
f2(true), log.error(e, { output: r2, secondarySymbol: i2, spacing: 1 }), s?.showLog !== false && T3(), n3.splice(1, n3.length - 1), n3[0].value = "", n3[0].full = "";
|
|
2454
|
+
},
|
|
2455
|
+
success(e, s) {
|
|
2456
|
+
f2(true), log.success(e, { output: r2, secondarySymbol: i2, spacing: 1 }), s?.showLog === true && T3(), n3.splice(1, n3.length - 1), n3[0].value = "", n3[0].full = "";
|
|
2457
|
+
}
|
|
2458
|
+
};
|
|
2459
|
+
}, text = (e) => new n2({
|
|
1663
2460
|
validate: e.validate,
|
|
1664
2461
|
placeholder: e.placeholder,
|
|
1665
2462
|
defaultValue: e.defaultValue,
|
|
@@ -1729,12 +2526,66 @@ var init_dist4 = __esm(() => {
|
|
|
1729
2526
|
S_SUCCESS = unicodeOr("\u25C6", "*");
|
|
1730
2527
|
S_WARN = unicodeOr("\u25B2", "!");
|
|
1731
2528
|
S_ERROR = unicodeOr("\u25A0", "x");
|
|
2529
|
+
J = [
|
|
2530
|
+
S_CORNER_TOP_LEFT,
|
|
2531
|
+
S_CORNER_TOP_RIGHT,
|
|
2532
|
+
S_CORNER_BOTTOM_LEFT,
|
|
2533
|
+
S_CORNER_BOTTOM_RIGHT
|
|
2534
|
+
];
|
|
2535
|
+
K = [S_BAR_START, S_BAR_START_RIGHT, S_BAR_END, S_BAR_END_RIGHT];
|
|
2536
|
+
p2 = {
|
|
2537
|
+
year: "yyyy",
|
|
2538
|
+
month: "mm",
|
|
2539
|
+
day: "dd"
|
|
2540
|
+
};
|
|
1732
2541
|
MULTISELECT_INSTRUCTIONS = [
|
|
1733
2542
|
`${styleText2("dim", "\u2191/\u2193")} to navigate`,
|
|
1734
2543
|
`${styleText2("dim", "Space:")} select`,
|
|
1735
2544
|
`${styleText2("dim", "Enter:")} confirm`
|
|
1736
2545
|
];
|
|
1737
|
-
|
|
2546
|
+
log = {
|
|
2547
|
+
message: (s = [], {
|
|
2548
|
+
symbol: e = styleText2("gray", S_BAR),
|
|
2549
|
+
secondarySymbol: r2 = styleText2("gray", S_BAR),
|
|
2550
|
+
output: m3 = process.stdout,
|
|
2551
|
+
spacing: l2 = 1,
|
|
2552
|
+
withGuide: c2
|
|
2553
|
+
} = {}) => {
|
|
2554
|
+
const t2 = [], o2 = c2 ?? settings.withGuide, f2 = o2 ? r2 : "", O = o2 ? `${e} ` : "", u4 = o2 ? `${r2} ` : "";
|
|
2555
|
+
for (let i = 0;i < l2; i++)
|
|
2556
|
+
t2.push(f2);
|
|
2557
|
+
const g2 = Array.isArray(s) ? s : s.split(`
|
|
2558
|
+
`);
|
|
2559
|
+
if (g2.length > 0) {
|
|
2560
|
+
const [i, ...y] = g2;
|
|
2561
|
+
i.length > 0 ? t2.push(`${O}${i}`) : t2.push(o2 ? e : "");
|
|
2562
|
+
for (const p3 of y)
|
|
2563
|
+
p3.length > 0 ? t2.push(`${u4}${p3}`) : t2.push(o2 ? r2 : "");
|
|
2564
|
+
}
|
|
2565
|
+
m3.write(`${t2.join(`
|
|
2566
|
+
`)}
|
|
2567
|
+
`);
|
|
2568
|
+
},
|
|
2569
|
+
info: (s, e) => {
|
|
2570
|
+
log.message(s, { ...e, symbol: styleText2("blue", S_INFO) });
|
|
2571
|
+
},
|
|
2572
|
+
success: (s, e) => {
|
|
2573
|
+
log.message(s, { ...e, symbol: styleText2("green", S_SUCCESS) });
|
|
2574
|
+
},
|
|
2575
|
+
step: (s, e) => {
|
|
2576
|
+
log.message(s, { ...e, symbol: styleText2("green", S_STEP_SUBMIT) });
|
|
2577
|
+
},
|
|
2578
|
+
warn: (s, e) => {
|
|
2579
|
+
log.message(s, { ...e, symbol: styleText2("yellow", S_WARN) });
|
|
2580
|
+
},
|
|
2581
|
+
warning: (s, e) => {
|
|
2582
|
+
log.warn(s, e);
|
|
2583
|
+
},
|
|
2584
|
+
error: (s, e) => {
|
|
2585
|
+
log.message(s, { ...e, symbol: styleText2("red", S_ERROR) });
|
|
2586
|
+
}
|
|
2587
|
+
};
|
|
2588
|
+
u4 = {
|
|
1738
2589
|
light: unicodeOr("\u2500", "-"),
|
|
1739
2590
|
heavy: unicodeOr("\u2501", "="),
|
|
1740
2591
|
block: unicodeOr("\u2588", "#")
|
|
@@ -1744,6 +2595,30 @@ var init_dist4 = __esm(() => {
|
|
|
1744
2595
|
`${styleText2("dim", "Enter:")} confirm`
|
|
1745
2596
|
];
|
|
1746
2597
|
i = `${styleText2("gray", S_BAR)} `;
|
|
2598
|
+
stream = {
|
|
2599
|
+
message: async (e, { symbol: l2 = styleText2("gray", S_BAR) } = {}) => {
|
|
2600
|
+
process.stdout.write(`${styleText2("gray", S_BAR)}
|
|
2601
|
+
${l2} `);
|
|
2602
|
+
let s = 3;
|
|
2603
|
+
for await (let r2 of e) {
|
|
2604
|
+
r2 = r2.replace(/\n/g, `
|
|
2605
|
+
${i}`), r2.includes(`
|
|
2606
|
+
`) && (s = 3 + stripVTControlCharacters(r2.slice(r2.lastIndexOf(`
|
|
2607
|
+
`))).length);
|
|
2608
|
+
const o2 = stripVTControlCharacters(r2).length;
|
|
2609
|
+
s + o2 < process.stdout.columns ? (s += o2, process.stdout.write(r2)) : (process.stdout.write(`
|
|
2610
|
+
${i}${r2.trimStart()}`), s = 3 + stripVTControlCharacters(r2.trimStart()).length);
|
|
2611
|
+
}
|
|
2612
|
+
process.stdout.write(`
|
|
2613
|
+
`);
|
|
2614
|
+
},
|
|
2615
|
+
info: (e) => stream.message(e, { symbol: styleText2("blue", S_INFO) }),
|
|
2616
|
+
success: (e) => stream.message(e, { symbol: styleText2("green", S_SUCCESS) }),
|
|
2617
|
+
step: (e) => stream.message(e, { symbol: styleText2("green", S_STEP_SUBMIT) }),
|
|
2618
|
+
warn: (e) => stream.message(e, { symbol: styleText2("yellow", S_WARN) }),
|
|
2619
|
+
warning: (e) => stream.warn(e),
|
|
2620
|
+
error: (e) => stream.message(e, { symbol: styleText2("red", S_ERROR) })
|
|
2621
|
+
};
|
|
1747
2622
|
});
|
|
1748
2623
|
|
|
1749
2624
|
// src/lib/export-mappings.ts
|
|
@@ -2053,7 +2928,7 @@ Generated by Guardian
|
|
|
2053
2928
|
// src/lib/manifest.ts
|
|
2054
2929
|
import * as crypto2 from "crypto";
|
|
2055
2930
|
import * as fs3 from "fs";
|
|
2056
|
-
import * as
|
|
2931
|
+
import * as path4 from "path";
|
|
2057
2932
|
import { fileURLToPath } from "url";
|
|
2058
2933
|
function hashFile(filePath) {
|
|
2059
2934
|
if (!fs3.existsSync(filePath)) {
|
|
@@ -2069,7 +2944,7 @@ function hashDirectory(dirPath) {
|
|
|
2069
2944
|
const hashes = [];
|
|
2070
2945
|
const files = getAllFiles(dirPath);
|
|
2071
2946
|
for (const file of files.sort()) {
|
|
2072
|
-
const relativePath =
|
|
2947
|
+
const relativePath = path4.relative(dirPath, file);
|
|
2073
2948
|
const fileHash = hashFile(file);
|
|
2074
2949
|
hashes.push(`${relativePath}:${fileHash}`);
|
|
2075
2950
|
}
|
|
@@ -2081,7 +2956,7 @@ function getAllFiles(dirPath) {
|
|
|
2081
2956
|
function walk(dir) {
|
|
2082
2957
|
const entries = fs3.readdirSync(dir, { withFileTypes: true });
|
|
2083
2958
|
for (const entry of entries) {
|
|
2084
|
-
const fullPath =
|
|
2959
|
+
const fullPath = path4.join(dir, entry.name);
|
|
2085
2960
|
if (entry.isDirectory()) {
|
|
2086
2961
|
walk(fullPath);
|
|
2087
2962
|
} else if (entry.isFile()) {
|
|
@@ -2093,11 +2968,11 @@ function getAllFiles(dirPath) {
|
|
|
2093
2968
|
return files;
|
|
2094
2969
|
}
|
|
2095
2970
|
function manifestExists(targetDir) {
|
|
2096
|
-
const manifestPath =
|
|
2971
|
+
const manifestPath = path4.join(targetDir, MANIFEST_FILE);
|
|
2097
2972
|
return fs3.existsSync(manifestPath);
|
|
2098
2973
|
}
|
|
2099
2974
|
function readManifest(targetDir) {
|
|
2100
|
-
const manifestPath =
|
|
2975
|
+
const manifestPath = path4.join(targetDir, MANIFEST_FILE);
|
|
2101
2976
|
if (!fs3.existsSync(manifestPath)) {
|
|
2102
2977
|
return null;
|
|
2103
2978
|
}
|
|
@@ -2109,7 +2984,7 @@ function readManifest(targetDir) {
|
|
|
2109
2984
|
}
|
|
2110
2985
|
}
|
|
2111
2986
|
function writeManifest(targetDir, manifest) {
|
|
2112
|
-
const manifestPath =
|
|
2987
|
+
const manifestPath = path4.join(targetDir, MANIFEST_FILE);
|
|
2113
2988
|
const tempPath = `${manifestPath}.tmp`;
|
|
2114
2989
|
fs3.writeFileSync(tempPath, JSON.stringify(manifest, null, 2), "utf-8");
|
|
2115
2990
|
fs3.renameSync(tempPath, manifestPath);
|
|
@@ -2157,7 +3032,7 @@ function updateManifestAfterScaffold(targetDir, manifest, scaffoldedFiles) {
|
|
|
2157
3032
|
for (const tool of manifest.tools) {
|
|
2158
3033
|
if (tool !== "pi") {
|
|
2159
3034
|
const exportPath = `.${tool}/`;
|
|
2160
|
-
addExportRecord(manifest, tool, exportPath,
|
|
3035
|
+
addExportRecord(manifest, tool, exportPath, path4.join(targetDir, ".pi"));
|
|
2161
3036
|
}
|
|
2162
3037
|
}
|
|
2163
3038
|
manifest.lastUpdatedAt = new Date().toISOString();
|
|
@@ -2181,7 +3056,7 @@ function getStoredHash(record) {
|
|
|
2181
3056
|
}
|
|
2182
3057
|
function categorizeFile(relativePath) {
|
|
2183
3058
|
const userEditable = ["agent/AGENTS.md", "context/project.md", "context/patterns.md", "domain/"];
|
|
2184
|
-
if (userEditable.some((
|
|
3059
|
+
if (userEditable.some((p3) => relativePath.includes(p3))) {
|
|
2185
3060
|
return "user";
|
|
2186
3061
|
}
|
|
2187
3062
|
const frameworkPatterns = [
|
|
@@ -2192,7 +3067,7 @@ function categorizeFile(relativePath) {
|
|
|
2192
3067
|
"context/checklists.md",
|
|
2193
3068
|
"context/output-formats.md"
|
|
2194
3069
|
];
|
|
2195
|
-
if (frameworkPatterns.some((
|
|
3070
|
+
if (frameworkPatterns.some((p3) => relativePath.startsWith(p3))) {
|
|
2196
3071
|
return "framework";
|
|
2197
3072
|
}
|
|
2198
3073
|
if (relativePath.startsWith(".claude/") || relativePath.startsWith(".opencode/") || relativePath.startsWith(".agents/")) {
|
|
@@ -2208,7 +3083,7 @@ function calculateTokenStats(targetDir, manifest) {
|
|
|
2208
3083
|
const byFile = {};
|
|
2209
3084
|
let totalTokens = 0;
|
|
2210
3085
|
for (const [filePath, record] of Object.entries(manifest.files)) {
|
|
2211
|
-
const fullPath =
|
|
3086
|
+
const fullPath = path4.join(targetDir, filePath);
|
|
2212
3087
|
if (!fs3.existsSync(fullPath))
|
|
2213
3088
|
continue;
|
|
2214
3089
|
const content = fs3.readFileSync(fullPath, "utf-8");
|
|
@@ -2224,10 +3099,10 @@ function calculateTokenStats(targetDir, manifest) {
|
|
|
2224
3099
|
lastCalculatedAt: new Date().toISOString()
|
|
2225
3100
|
};
|
|
2226
3101
|
}
|
|
2227
|
-
var _filename, _dirname, MANIFEST_FILE = "guardian-manifest.json", FRAMEWORK_VERSION = "0.1.
|
|
3102
|
+
var _filename, _dirname, MANIFEST_FILE = "guardian-manifest.json", FRAMEWORK_VERSION = "0.1.61", SCHEMA_VERSION = "0.1";
|
|
2228
3103
|
var init_manifest = __esm(() => {
|
|
2229
3104
|
_filename = fileURLToPath(import.meta.url);
|
|
2230
|
-
_dirname =
|
|
3105
|
+
_dirname = path4.dirname(_filename);
|
|
2231
3106
|
});
|
|
2232
3107
|
|
|
2233
3108
|
// src/lib/retry.ts
|
|
@@ -2303,7 +3178,7 @@ __export(exports_package, {
|
|
|
2303
3178
|
bin: () => bin,
|
|
2304
3179
|
author: () => author
|
|
2305
3180
|
});
|
|
2306
|
-
var name = "guardian-framework", version = "0.1.
|
|
3181
|
+
var name = "guardian-framework", version = "0.1.61", description = "Token-optimized agentic framework scaffolder with pi-first architecture", type = "module", main = "dist/exports.js", exports, types = "dist/exports.d.ts", bin, files, engines, scripts, publishConfig, pi, repository, homepage = "https://github.com/arman-jalili/guardian-framework#readme", bugs, dependencies, devDependencies, keywords, author = "Arman Wolkensteiner-Jalili", license = "MIT", package_default;
|
|
2307
3182
|
var init_package = __esm(() => {
|
|
2308
3183
|
exports = {
|
|
2309
3184
|
".": {
|
|
@@ -2400,22 +3275,22 @@ var init_package = __esm(() => {
|
|
|
2400
3275
|
|
|
2401
3276
|
// src/lib/templates.ts
|
|
2402
3277
|
import * as fs4 from "fs";
|
|
2403
|
-
import * as
|
|
3278
|
+
import * as path5 from "path";
|
|
2404
3279
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
2405
3280
|
function findTemplateDir() {
|
|
2406
3281
|
const possiblePaths = [
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
3282
|
+
path5.join(__dirname2, "..", "..", "templates"),
|
|
3283
|
+
path5.join(__dirname2, "..", "..", "..", "templates"),
|
|
3284
|
+
path5.resolve(path5.dirname(fs4.realpathSync(__filename2)), "..", "templates")
|
|
2410
3285
|
];
|
|
2411
|
-
for (const
|
|
2412
|
-
if (fs4.existsSync(
|
|
2413
|
-
return
|
|
3286
|
+
for (const p3 of possiblePaths) {
|
|
3287
|
+
if (fs4.existsSync(p3) && isPathInPackage(p3)) {
|
|
3288
|
+
return p3;
|
|
2414
3289
|
}
|
|
2415
3290
|
}
|
|
2416
3291
|
try {
|
|
2417
3292
|
const pkgPath = __require.resolve("/Users/arman/project/guardian-framework/package.json");
|
|
2418
|
-
const resolved =
|
|
3293
|
+
const resolved = path5.join(path5.dirname(pkgPath), "templates");
|
|
2419
3294
|
if (isPathInPackage(resolved)) {
|
|
2420
3295
|
return resolved;
|
|
2421
3296
|
}
|
|
@@ -2424,9 +3299,9 @@ function findTemplateDir() {
|
|
|
2424
3299
|
}
|
|
2425
3300
|
function isPathInPackage(resolvedPath) {
|
|
2426
3301
|
try {
|
|
2427
|
-
const resolved =
|
|
2428
|
-
const root =
|
|
2429
|
-
return resolved.startsWith(root +
|
|
3302
|
+
const resolved = path5.resolve(resolvedPath);
|
|
3303
|
+
const root = path5.resolve(PACKAGE_ROOT);
|
|
3304
|
+
return resolved.startsWith(root + path5.sep) || resolved === root;
|
|
2430
3305
|
} catch {
|
|
2431
3306
|
return false;
|
|
2432
3307
|
}
|
|
@@ -2439,11 +3314,11 @@ function getPiTemplateFiles() {
|
|
|
2439
3314
|
function walk(dir) {
|
|
2440
3315
|
const entries = fs4.readdirSync(dir, { withFileTypes: true });
|
|
2441
3316
|
for (const entry of entries) {
|
|
2442
|
-
const fullPath =
|
|
3317
|
+
const fullPath = path5.join(dir, entry.name);
|
|
2443
3318
|
if (entry.isDirectory()) {
|
|
2444
3319
|
walk(fullPath);
|
|
2445
3320
|
} else {
|
|
2446
|
-
const relativePath =
|
|
3321
|
+
const relativePath = path5.relative(PI_TEMPLATE_DIR, fullPath);
|
|
2447
3322
|
files2.push(relativePath);
|
|
2448
3323
|
}
|
|
2449
3324
|
}
|
|
@@ -2454,14 +3329,14 @@ function getPiTemplateFiles() {
|
|
|
2454
3329
|
return files2;
|
|
2455
3330
|
}
|
|
2456
3331
|
function readTemplate(relativePath) {
|
|
2457
|
-
const fullPath =
|
|
3332
|
+
const fullPath = path5.join(PI_TEMPLATE_DIR, relativePath);
|
|
2458
3333
|
if (!fs4.existsSync(fullPath)) {
|
|
2459
3334
|
return { ok: false, error: new Error(`Template not found: ${relativePath}`) };
|
|
2460
3335
|
}
|
|
2461
3336
|
return tryCatch(() => fs4.readFileSync(fullPath, "utf-8"));
|
|
2462
3337
|
}
|
|
2463
3338
|
function readLanguagePatterns(language) {
|
|
2464
|
-
const fullPath =
|
|
3339
|
+
const fullPath = path5.join(LANGUAGES_DIR, `${language}-patterns.md`);
|
|
2465
3340
|
if (!fs4.existsSync(fullPath)) {
|
|
2466
3341
|
return { ok: false, error: new Error(`Language patterns not found: ${language}`) };
|
|
2467
3342
|
}
|
|
@@ -2533,11 +3408,11 @@ function getDefaultContext(language, projectName, repoTool, buildTool, groupId)
|
|
|
2533
3408
|
var __filename2, __dirname2, PACKAGE_ROOT, TEMPLATE_DIR, PI_TEMPLATE_DIR, LANGUAGES_DIR, SUPPORTED_LANGUAGES, AVAILABLE_VALIDATORS, AVAILABLE_WORKFLOWS, PROJECT_DEFAULTS, LANGUAGE_DEFAULTS, GRADLE_COMMANDS;
|
|
2534
3409
|
var init_templates = __esm(() => {
|
|
2535
3410
|
__filename2 = fileURLToPath2(import.meta.url);
|
|
2536
|
-
__dirname2 =
|
|
2537
|
-
PACKAGE_ROOT =
|
|
3411
|
+
__dirname2 = path5.dirname(__filename2);
|
|
3412
|
+
PACKAGE_ROOT = path5.resolve(__dirname2, "..", "..");
|
|
2538
3413
|
TEMPLATE_DIR = findTemplateDir();
|
|
2539
|
-
PI_TEMPLATE_DIR =
|
|
2540
|
-
LANGUAGES_DIR =
|
|
3414
|
+
PI_TEMPLATE_DIR = path5.join(TEMPLATE_DIR, "pi");
|
|
3415
|
+
LANGUAGES_DIR = path5.join(TEMPLATE_DIR, "languages");
|
|
2541
3416
|
SUPPORTED_LANGUAGES = ["typescript", "rust", "python", "go", "java", "nextjs", "angular"];
|
|
2542
3417
|
AVAILABLE_VALIDATORS = [
|
|
2543
3418
|
"ci",
|
|
@@ -2752,17 +3627,17 @@ var require_visit = __commonJS((exports2) => {
|
|
|
2752
3627
|
visit.BREAK = BREAK;
|
|
2753
3628
|
visit.SKIP = SKIP;
|
|
2754
3629
|
visit.REMOVE = REMOVE;
|
|
2755
|
-
function visit_(key, node, visitor,
|
|
2756
|
-
const ctrl = callVisitor(key, node, visitor,
|
|
3630
|
+
function visit_(key, node, visitor, path6) {
|
|
3631
|
+
const ctrl = callVisitor(key, node, visitor, path6);
|
|
2757
3632
|
if (identity.isNode(ctrl) || identity.isPair(ctrl)) {
|
|
2758
|
-
replaceNode(key,
|
|
2759
|
-
return visit_(key, ctrl, visitor,
|
|
3633
|
+
replaceNode(key, path6, ctrl);
|
|
3634
|
+
return visit_(key, ctrl, visitor, path6);
|
|
2760
3635
|
}
|
|
2761
3636
|
if (typeof ctrl !== "symbol") {
|
|
2762
3637
|
if (identity.isCollection(node)) {
|
|
2763
|
-
|
|
3638
|
+
path6 = Object.freeze(path6.concat(node));
|
|
2764
3639
|
for (let i2 = 0;i2 < node.items.length; ++i2) {
|
|
2765
|
-
const ci = visit_(i2, node.items[i2], visitor,
|
|
3640
|
+
const ci = visit_(i2, node.items[i2], visitor, path6);
|
|
2766
3641
|
if (typeof ci === "number")
|
|
2767
3642
|
i2 = ci - 1;
|
|
2768
3643
|
else if (ci === BREAK)
|
|
@@ -2773,13 +3648,13 @@ var require_visit = __commonJS((exports2) => {
|
|
|
2773
3648
|
}
|
|
2774
3649
|
}
|
|
2775
3650
|
} else if (identity.isPair(node)) {
|
|
2776
|
-
|
|
2777
|
-
const ck = visit_("key", node.key, visitor,
|
|
3651
|
+
path6 = Object.freeze(path6.concat(node));
|
|
3652
|
+
const ck = visit_("key", node.key, visitor, path6);
|
|
2778
3653
|
if (ck === BREAK)
|
|
2779
3654
|
return BREAK;
|
|
2780
3655
|
else if (ck === REMOVE)
|
|
2781
3656
|
node.key = null;
|
|
2782
|
-
const cv = visit_("value", node.value, visitor,
|
|
3657
|
+
const cv = visit_("value", node.value, visitor, path6);
|
|
2783
3658
|
if (cv === BREAK)
|
|
2784
3659
|
return BREAK;
|
|
2785
3660
|
else if (cv === REMOVE)
|
|
@@ -2800,17 +3675,17 @@ var require_visit = __commonJS((exports2) => {
|
|
|
2800
3675
|
visitAsync.BREAK = BREAK;
|
|
2801
3676
|
visitAsync.SKIP = SKIP;
|
|
2802
3677
|
visitAsync.REMOVE = REMOVE;
|
|
2803
|
-
async function visitAsync_(key, node, visitor,
|
|
2804
|
-
const ctrl = await callVisitor(key, node, visitor,
|
|
3678
|
+
async function visitAsync_(key, node, visitor, path6) {
|
|
3679
|
+
const ctrl = await callVisitor(key, node, visitor, path6);
|
|
2805
3680
|
if (identity.isNode(ctrl) || identity.isPair(ctrl)) {
|
|
2806
|
-
replaceNode(key,
|
|
2807
|
-
return visitAsync_(key, ctrl, visitor,
|
|
3681
|
+
replaceNode(key, path6, ctrl);
|
|
3682
|
+
return visitAsync_(key, ctrl, visitor, path6);
|
|
2808
3683
|
}
|
|
2809
3684
|
if (typeof ctrl !== "symbol") {
|
|
2810
3685
|
if (identity.isCollection(node)) {
|
|
2811
|
-
|
|
3686
|
+
path6 = Object.freeze(path6.concat(node));
|
|
2812
3687
|
for (let i2 = 0;i2 < node.items.length; ++i2) {
|
|
2813
|
-
const ci = await visitAsync_(i2, node.items[i2], visitor,
|
|
3688
|
+
const ci = await visitAsync_(i2, node.items[i2], visitor, path6);
|
|
2814
3689
|
if (typeof ci === "number")
|
|
2815
3690
|
i2 = ci - 1;
|
|
2816
3691
|
else if (ci === BREAK)
|
|
@@ -2821,13 +3696,13 @@ var require_visit = __commonJS((exports2) => {
|
|
|
2821
3696
|
}
|
|
2822
3697
|
}
|
|
2823
3698
|
} else if (identity.isPair(node)) {
|
|
2824
|
-
|
|
2825
|
-
const ck = await visitAsync_("key", node.key, visitor,
|
|
3699
|
+
path6 = Object.freeze(path6.concat(node));
|
|
3700
|
+
const ck = await visitAsync_("key", node.key, visitor, path6);
|
|
2826
3701
|
if (ck === BREAK)
|
|
2827
3702
|
return BREAK;
|
|
2828
3703
|
else if (ck === REMOVE)
|
|
2829
3704
|
node.key = null;
|
|
2830
|
-
const cv = await visitAsync_("value", node.value, visitor,
|
|
3705
|
+
const cv = await visitAsync_("value", node.value, visitor, path6);
|
|
2831
3706
|
if (cv === BREAK)
|
|
2832
3707
|
return BREAK;
|
|
2833
3708
|
else if (cv === REMOVE)
|
|
@@ -2854,23 +3729,23 @@ var require_visit = __commonJS((exports2) => {
|
|
|
2854
3729
|
}
|
|
2855
3730
|
return visitor;
|
|
2856
3731
|
}
|
|
2857
|
-
function callVisitor(key, node, visitor,
|
|
3732
|
+
function callVisitor(key, node, visitor, path6) {
|
|
2858
3733
|
if (typeof visitor === "function")
|
|
2859
|
-
return visitor(key, node,
|
|
3734
|
+
return visitor(key, node, path6);
|
|
2860
3735
|
if (identity.isMap(node))
|
|
2861
|
-
return visitor.Map?.(key, node,
|
|
3736
|
+
return visitor.Map?.(key, node, path6);
|
|
2862
3737
|
if (identity.isSeq(node))
|
|
2863
|
-
return visitor.Seq?.(key, node,
|
|
3738
|
+
return visitor.Seq?.(key, node, path6);
|
|
2864
3739
|
if (identity.isPair(node))
|
|
2865
|
-
return visitor.Pair?.(key, node,
|
|
3740
|
+
return visitor.Pair?.(key, node, path6);
|
|
2866
3741
|
if (identity.isScalar(node))
|
|
2867
|
-
return visitor.Scalar?.(key, node,
|
|
3742
|
+
return visitor.Scalar?.(key, node, path6);
|
|
2868
3743
|
if (identity.isAlias(node))
|
|
2869
|
-
return visitor.Alias?.(key, node,
|
|
3744
|
+
return visitor.Alias?.(key, node, path6);
|
|
2870
3745
|
return;
|
|
2871
3746
|
}
|
|
2872
|
-
function replaceNode(key,
|
|
2873
|
-
const parent =
|
|
3747
|
+
function replaceNode(key, path6, node) {
|
|
3748
|
+
const parent = path6[path6.length - 1];
|
|
2874
3749
|
if (identity.isCollection(parent)) {
|
|
2875
3750
|
parent.items[key] = node;
|
|
2876
3751
|
} else if (identity.isPair(parent)) {
|
|
@@ -3429,10 +4304,10 @@ var require_Collection = __commonJS((exports2) => {
|
|
|
3429
4304
|
var createNode = require_createNode();
|
|
3430
4305
|
var identity = require_identity();
|
|
3431
4306
|
var Node = require_Node();
|
|
3432
|
-
function collectionFromPath(schema,
|
|
4307
|
+
function collectionFromPath(schema, path6, value) {
|
|
3433
4308
|
let v = value;
|
|
3434
|
-
for (let i2 =
|
|
3435
|
-
const k =
|
|
4309
|
+
for (let i2 = path6.length - 1;i2 >= 0; --i2) {
|
|
4310
|
+
const k = path6[i2];
|
|
3436
4311
|
if (typeof k === "number" && Number.isInteger(k) && k >= 0) {
|
|
3437
4312
|
const a2 = [];
|
|
3438
4313
|
a2[k] = v;
|
|
@@ -3451,7 +4326,7 @@ var require_Collection = __commonJS((exports2) => {
|
|
|
3451
4326
|
sourceObjects: new Map
|
|
3452
4327
|
});
|
|
3453
4328
|
}
|
|
3454
|
-
var isEmptyPath = (
|
|
4329
|
+
var isEmptyPath = (path6) => path6 == null || typeof path6 === "object" && !!path6[Symbol.iterator]().next().done;
|
|
3455
4330
|
|
|
3456
4331
|
class Collection extends Node.NodeBase {
|
|
3457
4332
|
constructor(type2, schema) {
|
|
@@ -3472,11 +4347,11 @@ var require_Collection = __commonJS((exports2) => {
|
|
|
3472
4347
|
copy.range = this.range.slice();
|
|
3473
4348
|
return copy;
|
|
3474
4349
|
}
|
|
3475
|
-
addIn(
|
|
3476
|
-
if (isEmptyPath(
|
|
4350
|
+
addIn(path6, value) {
|
|
4351
|
+
if (isEmptyPath(path6))
|
|
3477
4352
|
this.add(value);
|
|
3478
4353
|
else {
|
|
3479
|
-
const [key, ...rest] =
|
|
4354
|
+
const [key, ...rest] = path6;
|
|
3480
4355
|
const node = this.get(key, true);
|
|
3481
4356
|
if (identity.isCollection(node))
|
|
3482
4357
|
node.addIn(rest, value);
|
|
@@ -3486,8 +4361,8 @@ var require_Collection = __commonJS((exports2) => {
|
|
|
3486
4361
|
throw new Error(`Expected YAML collection at ${key}. Remaining path: ${rest}`);
|
|
3487
4362
|
}
|
|
3488
4363
|
}
|
|
3489
|
-
deleteIn(
|
|
3490
|
-
const [key, ...rest] =
|
|
4364
|
+
deleteIn(path6) {
|
|
4365
|
+
const [key, ...rest] = path6;
|
|
3491
4366
|
if (rest.length === 0)
|
|
3492
4367
|
return this.delete(key);
|
|
3493
4368
|
const node = this.get(key, true);
|
|
@@ -3496,8 +4371,8 @@ var require_Collection = __commonJS((exports2) => {
|
|
|
3496
4371
|
else
|
|
3497
4372
|
throw new Error(`Expected YAML collection at ${key}. Remaining path: ${rest}`);
|
|
3498
4373
|
}
|
|
3499
|
-
getIn(
|
|
3500
|
-
const [key, ...rest] =
|
|
4374
|
+
getIn(path6, keepScalar) {
|
|
4375
|
+
const [key, ...rest] = path6;
|
|
3501
4376
|
const node = this.get(key, true);
|
|
3502
4377
|
if (rest.length === 0)
|
|
3503
4378
|
return !keepScalar && identity.isScalar(node) ? node.value : node;
|
|
@@ -3512,15 +4387,15 @@ var require_Collection = __commonJS((exports2) => {
|
|
|
3512
4387
|
return n3 == null || allowScalar && identity.isScalar(n3) && n3.value == null && !n3.commentBefore && !n3.comment && !n3.tag;
|
|
3513
4388
|
});
|
|
3514
4389
|
}
|
|
3515
|
-
hasIn(
|
|
3516
|
-
const [key, ...rest] =
|
|
4390
|
+
hasIn(path6) {
|
|
4391
|
+
const [key, ...rest] = path6;
|
|
3517
4392
|
if (rest.length === 0)
|
|
3518
4393
|
return this.has(key);
|
|
3519
4394
|
const node = this.get(key, true);
|
|
3520
4395
|
return identity.isCollection(node) ? node.hasIn(rest) : false;
|
|
3521
4396
|
}
|
|
3522
|
-
setIn(
|
|
3523
|
-
const [key, ...rest] =
|
|
4397
|
+
setIn(path6, value) {
|
|
4398
|
+
const [key, ...rest] = path6;
|
|
3524
4399
|
if (rest.length === 0) {
|
|
3525
4400
|
this.set(key, value);
|
|
3526
4401
|
} else {
|
|
@@ -4326,7 +5201,7 @@ var require_merge = __commonJS((exports2) => {
|
|
|
4326
5201
|
|
|
4327
5202
|
// node_modules/yaml/dist/nodes/addPairToJSMap.js
|
|
4328
5203
|
var require_addPairToJSMap = __commonJS((exports2) => {
|
|
4329
|
-
var
|
|
5204
|
+
var log2 = require_log();
|
|
4330
5205
|
var merge = require_merge();
|
|
4331
5206
|
var stringify = require_stringify();
|
|
4332
5207
|
var identity = require_identity();
|
|
@@ -4375,7 +5250,7 @@ var require_addPairToJSMap = __commonJS((exports2) => {
|
|
|
4375
5250
|
let jsonStr = JSON.stringify(strKey);
|
|
4376
5251
|
if (jsonStr.length > 40)
|
|
4377
5252
|
jsonStr = jsonStr.substring(0, 36) + '..."';
|
|
4378
|
-
|
|
5253
|
+
log2.warn(ctx.doc.options.logLevel, `Keys with collection values will be stringified due to JS Object restrictions: ${jsonStr}. Set mapAsMap: true to use object keys.`);
|
|
4379
5254
|
ctx.mapKeyWarned = true;
|
|
4380
5255
|
}
|
|
4381
5256
|
return strKey;
|
|
@@ -5526,7 +6401,7 @@ var require_timestamp = __commonJS((exports2) => {
|
|
|
5526
6401
|
const sign = str[0];
|
|
5527
6402
|
const parts = sign === "-" || sign === "+" ? str.substring(1) : str;
|
|
5528
6403
|
const num = (n3) => asBigInt ? BigInt(n3) : Number(n3);
|
|
5529
|
-
const res = parts.replace(/_/g, "").split(":").reduce((res2,
|
|
6404
|
+
const res = parts.replace(/_/g, "").split(":").reduce((res2, p3) => res2 * num(60) + num(p3), num(0));
|
|
5530
6405
|
return sign === "-" ? num(-1) * res : res;
|
|
5531
6406
|
}
|
|
5532
6407
|
function stringifySexagesimal(node) {
|
|
@@ -5584,15 +6459,15 @@ var require_timestamp = __commonJS((exports2) => {
|
|
|
5584
6459
|
throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");
|
|
5585
6460
|
const [, year, month, day, hour, minute, second] = match.map(Number);
|
|
5586
6461
|
const millisec = match[7] ? Number((match[7] + "00").substr(1, 3)) : 0;
|
|
5587
|
-
let
|
|
6462
|
+
let date2 = Date.UTC(year, month - 1, day, hour || 0, minute || 0, second || 0, millisec);
|
|
5588
6463
|
const tz = match[8];
|
|
5589
6464
|
if (tz && tz !== "Z") {
|
|
5590
6465
|
let d = parseSexagesimal(tz, false);
|
|
5591
6466
|
if (Math.abs(d) < 30)
|
|
5592
6467
|
d *= 60;
|
|
5593
|
-
|
|
6468
|
+
date2 -= 60000 * d;
|
|
5594
6469
|
}
|
|
5595
|
-
return new Date(
|
|
6470
|
+
return new Date(date2);
|
|
5596
6471
|
},
|
|
5597
6472
|
stringify: ({ value }) => value?.toISOString().replace(/(T00:00:00)?\.000Z$/, "") ?? ""
|
|
5598
6473
|
};
|
|
@@ -5740,7 +6615,7 @@ var require_Schema = __commonJS((exports2) => {
|
|
|
5740
6615
|
var seq = require_seq();
|
|
5741
6616
|
var string = require_string();
|
|
5742
6617
|
var tags = require_tags();
|
|
5743
|
-
var sortMapEntriesByKey = (a2,
|
|
6618
|
+
var sortMapEntriesByKey = (a2, b3) => a2.key < b3.key ? -1 : a2.key > b3.key ? 1 : 0;
|
|
5744
6619
|
|
|
5745
6620
|
class Schema {
|
|
5746
6621
|
constructor({ compat, customTags, merge, resolveKnownTags, schema, sortMapEntries, toStringDefaults }) {
|
|
@@ -5913,9 +6788,9 @@ var require_Document = __commonJS((exports2) => {
|
|
|
5913
6788
|
if (assertCollection(this.contents))
|
|
5914
6789
|
this.contents.add(value);
|
|
5915
6790
|
}
|
|
5916
|
-
addIn(
|
|
6791
|
+
addIn(path6, value) {
|
|
5917
6792
|
if (assertCollection(this.contents))
|
|
5918
|
-
this.contents.addIn(
|
|
6793
|
+
this.contents.addIn(path6, value);
|
|
5919
6794
|
}
|
|
5920
6795
|
createAlias(node, name2) {
|
|
5921
6796
|
if (!node.anchor) {
|
|
@@ -5964,30 +6839,30 @@ var require_Document = __commonJS((exports2) => {
|
|
|
5964
6839
|
delete(key) {
|
|
5965
6840
|
return assertCollection(this.contents) ? this.contents.delete(key) : false;
|
|
5966
6841
|
}
|
|
5967
|
-
deleteIn(
|
|
5968
|
-
if (Collection.isEmptyPath(
|
|
6842
|
+
deleteIn(path6) {
|
|
6843
|
+
if (Collection.isEmptyPath(path6)) {
|
|
5969
6844
|
if (this.contents == null)
|
|
5970
6845
|
return false;
|
|
5971
6846
|
this.contents = null;
|
|
5972
6847
|
return true;
|
|
5973
6848
|
}
|
|
5974
|
-
return assertCollection(this.contents) ? this.contents.deleteIn(
|
|
6849
|
+
return assertCollection(this.contents) ? this.contents.deleteIn(path6) : false;
|
|
5975
6850
|
}
|
|
5976
6851
|
get(key, keepScalar) {
|
|
5977
6852
|
return identity.isCollection(this.contents) ? this.contents.get(key, keepScalar) : undefined;
|
|
5978
6853
|
}
|
|
5979
|
-
getIn(
|
|
5980
|
-
if (Collection.isEmptyPath(
|
|
6854
|
+
getIn(path6, keepScalar) {
|
|
6855
|
+
if (Collection.isEmptyPath(path6))
|
|
5981
6856
|
return !keepScalar && identity.isScalar(this.contents) ? this.contents.value : this.contents;
|
|
5982
|
-
return identity.isCollection(this.contents) ? this.contents.getIn(
|
|
6857
|
+
return identity.isCollection(this.contents) ? this.contents.getIn(path6, keepScalar) : undefined;
|
|
5983
6858
|
}
|
|
5984
6859
|
has(key) {
|
|
5985
6860
|
return identity.isCollection(this.contents) ? this.contents.has(key) : false;
|
|
5986
6861
|
}
|
|
5987
|
-
hasIn(
|
|
5988
|
-
if (Collection.isEmptyPath(
|
|
6862
|
+
hasIn(path6) {
|
|
6863
|
+
if (Collection.isEmptyPath(path6))
|
|
5989
6864
|
return this.contents !== undefined;
|
|
5990
|
-
return identity.isCollection(this.contents) ? this.contents.hasIn(
|
|
6865
|
+
return identity.isCollection(this.contents) ? this.contents.hasIn(path6) : false;
|
|
5991
6866
|
}
|
|
5992
6867
|
set(key, value) {
|
|
5993
6868
|
if (this.contents == null) {
|
|
@@ -5996,13 +6871,13 @@ var require_Document = __commonJS((exports2) => {
|
|
|
5996
6871
|
this.contents.set(key, value);
|
|
5997
6872
|
}
|
|
5998
6873
|
}
|
|
5999
|
-
setIn(
|
|
6000
|
-
if (Collection.isEmptyPath(
|
|
6874
|
+
setIn(path6, value) {
|
|
6875
|
+
if (Collection.isEmptyPath(path6)) {
|
|
6001
6876
|
this.contents = value;
|
|
6002
6877
|
} else if (this.contents == null) {
|
|
6003
|
-
this.contents = Collection.collectionFromPath(this.schema, Array.from(
|
|
6878
|
+
this.contents = Collection.collectionFromPath(this.schema, Array.from(path6), value);
|
|
6004
6879
|
} else if (assertCollection(this.contents)) {
|
|
6005
|
-
this.contents.setIn(
|
|
6880
|
+
this.contents.setIn(path6, value);
|
|
6006
6881
|
}
|
|
6007
6882
|
}
|
|
6008
6883
|
setSchema(version2, options = {}) {
|
|
@@ -6335,7 +7210,7 @@ var require_util_map_includes = __commonJS((exports2) => {
|
|
|
6335
7210
|
const { uniqueKeys } = ctx.options;
|
|
6336
7211
|
if (uniqueKeys === false)
|
|
6337
7212
|
return false;
|
|
6338
|
-
const isEqual = typeof uniqueKeys === "function" ? uniqueKeys : (a2,
|
|
7213
|
+
const isEqual = typeof uniqueKeys === "function" ? uniqueKeys : (a2, b3) => a2 === b3 || identity.isScalar(a2) && identity.isScalar(b3) && a2.value === b3.value;
|
|
6339
7214
|
return items.some((pair) => isEqual(pair.key, search));
|
|
6340
7215
|
}
|
|
6341
7216
|
exports2.mapIncludes = mapIncludes;
|
|
@@ -7899,9 +8774,9 @@ var require_cst_visit = __commonJS((exports2) => {
|
|
|
7899
8774
|
visit.BREAK = BREAK;
|
|
7900
8775
|
visit.SKIP = SKIP;
|
|
7901
8776
|
visit.REMOVE = REMOVE;
|
|
7902
|
-
visit.itemAtPath = (cst,
|
|
8777
|
+
visit.itemAtPath = (cst, path6) => {
|
|
7903
8778
|
let item = cst;
|
|
7904
|
-
for (const [field, index] of
|
|
8779
|
+
for (const [field, index] of path6) {
|
|
7905
8780
|
const tok = item?.[field];
|
|
7906
8781
|
if (tok && "items" in tok) {
|
|
7907
8782
|
item = tok.items[index];
|
|
@@ -7910,23 +8785,23 @@ var require_cst_visit = __commonJS((exports2) => {
|
|
|
7910
8785
|
}
|
|
7911
8786
|
return item;
|
|
7912
8787
|
};
|
|
7913
|
-
visit.parentCollection = (cst,
|
|
7914
|
-
const parent = visit.itemAtPath(cst,
|
|
7915
|
-
const field =
|
|
8788
|
+
visit.parentCollection = (cst, path6) => {
|
|
8789
|
+
const parent = visit.itemAtPath(cst, path6.slice(0, -1));
|
|
8790
|
+
const field = path6[path6.length - 1][0];
|
|
7916
8791
|
const coll = parent?.[field];
|
|
7917
8792
|
if (coll && "items" in coll)
|
|
7918
8793
|
return coll;
|
|
7919
8794
|
throw new Error("Parent collection not found");
|
|
7920
8795
|
};
|
|
7921
|
-
function _visit(
|
|
7922
|
-
let ctrl = visitor(item,
|
|
8796
|
+
function _visit(path6, item, visitor) {
|
|
8797
|
+
let ctrl = visitor(item, path6);
|
|
7923
8798
|
if (typeof ctrl === "symbol")
|
|
7924
8799
|
return ctrl;
|
|
7925
8800
|
for (const field of ["key", "value"]) {
|
|
7926
8801
|
const token = item[field];
|
|
7927
8802
|
if (token && "items" in token) {
|
|
7928
8803
|
for (let i2 = 0;i2 < token.items.length; ++i2) {
|
|
7929
|
-
const ci = _visit(Object.freeze(
|
|
8804
|
+
const ci = _visit(Object.freeze(path6.concat([[field, i2]])), token.items[i2], visitor);
|
|
7930
8805
|
if (typeof ci === "number")
|
|
7931
8806
|
i2 = ci - 1;
|
|
7932
8807
|
else if (ci === BREAK)
|
|
@@ -7937,10 +8812,10 @@ var require_cst_visit = __commonJS((exports2) => {
|
|
|
7937
8812
|
}
|
|
7938
8813
|
}
|
|
7939
8814
|
if (typeof ctrl === "function" && field === "key")
|
|
7940
|
-
ctrl = ctrl(item,
|
|
8815
|
+
ctrl = ctrl(item, path6);
|
|
7941
8816
|
}
|
|
7942
8817
|
}
|
|
7943
|
-
return typeof ctrl === "function" ? ctrl(item,
|
|
8818
|
+
return typeof ctrl === "function" ? ctrl(item, path6) : ctrl;
|
|
7944
8819
|
}
|
|
7945
8820
|
exports2.visit = visit;
|
|
7946
8821
|
});
|
|
@@ -9532,7 +10407,7 @@ var require_public_api = __commonJS((exports2) => {
|
|
|
9532
10407
|
var composer = require_composer();
|
|
9533
10408
|
var Document = require_Document();
|
|
9534
10409
|
var errors = require_errors();
|
|
9535
|
-
var
|
|
10410
|
+
var log2 = require_log();
|
|
9536
10411
|
var identity = require_identity();
|
|
9537
10412
|
var lineCounter = require_line_counter();
|
|
9538
10413
|
var parser = require_parser();
|
|
@@ -9584,7 +10459,7 @@ var require_public_api = __commonJS((exports2) => {
|
|
|
9584
10459
|
const doc = parseDocument(src, options);
|
|
9585
10460
|
if (!doc)
|
|
9586
10461
|
return null;
|
|
9587
|
-
doc.warnings.forEach((warning) =>
|
|
10462
|
+
doc.warnings.forEach((warning) => log2.warn(doc.options.logLevel, warning));
|
|
9588
10463
|
if (doc.errors.length > 0) {
|
|
9589
10464
|
if (doc.options.logLevel !== "silent")
|
|
9590
10465
|
throw doc.errors[0];
|
|
@@ -9672,9 +10547,9 @@ var require_dist = __commonJS((exports2) => {
|
|
|
9672
10547
|
|
|
9673
10548
|
// src/lib/workflow-config.ts
|
|
9674
10549
|
import * as fs5 from "fs";
|
|
9675
|
-
import * as
|
|
10550
|
+
import * as path6 from "path";
|
|
9676
10551
|
function loadWorkflowConfig(piDir) {
|
|
9677
|
-
const agentsPath =
|
|
10552
|
+
const agentsPath = path6.join(piDir, "agent", "AGENTS.md");
|
|
9678
10553
|
let frontMatter = {};
|
|
9679
10554
|
if (fs5.existsSync(agentsPath)) {
|
|
9680
10555
|
const content = fs5.readFileSync(agentsPath, "utf-8");
|
|
@@ -9910,7 +10785,7 @@ var init_workspace_hooks = () => {};
|
|
|
9910
10785
|
|
|
9911
10786
|
// src/commands/generate.ts
|
|
9912
10787
|
import * as fs7 from "fs";
|
|
9913
|
-
import * as
|
|
10788
|
+
import * as path7 from "path";
|
|
9914
10789
|
async function runGenerate(targetDir, options) {
|
|
9915
10790
|
if (!templatesExist()) {
|
|
9916
10791
|
outro("Templates not found. Ensure templates/pi/ exists in package.");
|
|
@@ -9929,7 +10804,7 @@ async function runGenerate(targetDir, options) {
|
|
|
9929
10804
|
const s = spinner();
|
|
9930
10805
|
s.start("Generating exports from .pi/ source...");
|
|
9931
10806
|
try {
|
|
9932
|
-
const piDir =
|
|
10807
|
+
const piDir = path7.join(targetDir, ".pi");
|
|
9933
10808
|
const config = loadWorkflowConfig(piDir);
|
|
9934
10809
|
const onConflict = config.generate.on_conflict;
|
|
9935
10810
|
const modifiedExports = detectExternallyModifiedExports(targetDir, manifest, toolsToGenerate, onConflict);
|
|
@@ -9950,7 +10825,7 @@ Run with --force to overwrite.`);
|
|
|
9950
10825
|
console.log();
|
|
9951
10826
|
}
|
|
9952
10827
|
}
|
|
9953
|
-
const workspacePath =
|
|
10828
|
+
const workspacePath = path7.join(piDir, "workspaces");
|
|
9954
10829
|
const wsResult = await ensureWorkspace(workspacePath, config.workspace.hooks);
|
|
9955
10830
|
if (!wsResult.ok) {
|
|
9956
10831
|
s.stop();
|
|
@@ -9965,7 +10840,7 @@ Run with --force to overwrite.`);
|
|
|
9965
10840
|
}
|
|
9966
10841
|
const generatedFiles = {};
|
|
9967
10842
|
for (const tool of toolsToGenerate) {
|
|
9968
|
-
const exportDir = tool === "pi" ?
|
|
10843
|
+
const exportDir = tool === "pi" ? path7.join(targetDir, ".agents") : path7.join(targetDir, `.${tool}`);
|
|
9969
10844
|
if (options.dryRun) {
|
|
9970
10845
|
if (s)
|
|
9971
10846
|
s.stop(`Dry run: Would generate .${tool}/ from .pi/`);
|
|
@@ -10016,31 +10891,31 @@ Next steps:
|
|
|
10016
10891
|
function generateExport(exportDir, tool, piDir, manifest, generatedFiles) {
|
|
10017
10892
|
const structure = getExportStructure(tool);
|
|
10018
10893
|
for (const dir of structure) {
|
|
10019
|
-
fs7.mkdirSync(
|
|
10894
|
+
fs7.mkdirSync(path7.join(exportDir, dir), { recursive: true });
|
|
10020
10895
|
}
|
|
10021
10896
|
const mappings = getExportMappings(tool);
|
|
10022
10897
|
for (const mapping of mappings) {
|
|
10023
|
-
const sourcePath =
|
|
10024
|
-
const targetPath =
|
|
10898
|
+
const sourcePath = path7.join(piDir, mapping.source);
|
|
10899
|
+
const targetPath = path7.join(exportDir, mapping.dest);
|
|
10025
10900
|
if (!fs7.existsSync(sourcePath)) {
|
|
10026
10901
|
continue;
|
|
10027
10902
|
}
|
|
10028
10903
|
const content = fs7.readFileSync(sourcePath, "utf-8");
|
|
10029
10904
|
const transformed = mapping.transform ? mapping.transform(content) : content;
|
|
10030
10905
|
const withHeader = addCanonicalHeader(transformed, mapping.source);
|
|
10031
|
-
fs7.mkdirSync(
|
|
10906
|
+
fs7.mkdirSync(path7.dirname(targetPath), { recursive: true });
|
|
10032
10907
|
fs7.writeFileSync(targetPath, withHeader, "utf-8");
|
|
10033
10908
|
const manifestPath = `.${tool}/${mapping.dest}`;
|
|
10034
10909
|
generatedFiles[manifestPath] = { category: "generated", content: withHeader };
|
|
10035
10910
|
}
|
|
10036
|
-
const scriptsDir =
|
|
10911
|
+
const scriptsDir = path7.join(piDir, "scripts");
|
|
10037
10912
|
if (fs7.existsSync(scriptsDir)) {
|
|
10038
|
-
const scriptsTargetDir =
|
|
10913
|
+
const scriptsTargetDir = path7.join(exportDir, "scripts");
|
|
10039
10914
|
fs7.mkdirSync(scriptsTargetDir, { recursive: true });
|
|
10040
10915
|
for (const validator of manifest.validators) {
|
|
10041
10916
|
const scriptFile = `validate-${normalizeValidatorName(validator)}.sh`;
|
|
10042
|
-
const sourceScript =
|
|
10043
|
-
const targetScript =
|
|
10917
|
+
const sourceScript = path7.join(scriptsDir, scriptFile);
|
|
10918
|
+
const targetScript = path7.join(scriptsTargetDir, scriptFile);
|
|
10044
10919
|
if (fs7.existsSync(sourceScript)) {
|
|
10045
10920
|
const scriptContent = fs7.readFileSync(sourceScript, "utf-8");
|
|
10046
10921
|
fs7.writeFileSync(targetScript, scriptContent, "utf-8");
|
|
@@ -10050,9 +10925,9 @@ function generateExport(exportDir, tool, piDir, manifest, generatedFiles) {
|
|
|
10050
10925
|
};
|
|
10051
10926
|
}
|
|
10052
10927
|
}
|
|
10053
|
-
const cacheScript =
|
|
10928
|
+
const cacheScript = path7.join(scriptsDir, "validation-cache.sh");
|
|
10054
10929
|
if (fs7.existsSync(cacheScript)) {
|
|
10055
|
-
const targetCacheScript =
|
|
10930
|
+
const targetCacheScript = path7.join(scriptsTargetDir, "validation-cache.sh");
|
|
10056
10931
|
const cacheContent = fs7.readFileSync(cacheScript, "utf-8");
|
|
10057
10932
|
fs7.writeFileSync(targetCacheScript, cacheContent, "utf-8");
|
|
10058
10933
|
generatedFiles[`.${tool}/scripts/validation-cache.sh`] = {
|
|
@@ -10061,7 +10936,7 @@ function generateExport(exportDir, tool, piDir, manifest, generatedFiles) {
|
|
|
10061
10936
|
};
|
|
10062
10937
|
}
|
|
10063
10938
|
}
|
|
10064
|
-
const readmePath =
|
|
10939
|
+
const readmePath = path7.join(exportDir, "README.md");
|
|
10065
10940
|
const readmeContent = generateExportReadme(tool);
|
|
10066
10941
|
fs7.writeFileSync(readmePath, readmeContent, "utf-8");
|
|
10067
10942
|
generatedFiles[`.${tool}/README.md`] = {
|
|
@@ -10098,13 +10973,13 @@ function detectExternallyModifiedExports(targetDir, manifest, toolsToGenerate, o
|
|
|
10098
10973
|
return [];
|
|
10099
10974
|
const modified = [];
|
|
10100
10975
|
for (const tool of toolsToGenerate) {
|
|
10101
|
-
const exportDir =
|
|
10976
|
+
const exportDir = path7.join(targetDir, `.${tool}`);
|
|
10102
10977
|
if (!fs7.existsSync(exportDir))
|
|
10103
10978
|
continue;
|
|
10104
10979
|
for (const [filePath, record] of Object.entries(manifest.files)) {
|
|
10105
10980
|
if (!filePath.startsWith(`.${tool}/`))
|
|
10106
10981
|
continue;
|
|
10107
|
-
const fullPath =
|
|
10982
|
+
const fullPath = path7.join(targetDir, filePath);
|
|
10108
10983
|
if (!fs7.existsSync(fullPath))
|
|
10109
10984
|
continue;
|
|
10110
10985
|
const currentContent = fs7.readFileSync(fullPath, "utf-8");
|
|
@@ -10130,7 +11005,7 @@ __export(exports_update, {
|
|
|
10130
11005
|
runUpdate: () => runUpdate
|
|
10131
11006
|
});
|
|
10132
11007
|
import * as fs10 from "fs";
|
|
10133
|
-
import * as
|
|
11008
|
+
import * as path9 from "path";
|
|
10134
11009
|
async function runUpdate(targetDir, options) {
|
|
10135
11010
|
if (!templatesExist()) {
|
|
10136
11011
|
outro("Templates not found. Ensure templates/pi/ exists in package.");
|
|
@@ -10185,7 +11060,7 @@ function analyzeChanges(targetDir, manifest, templateFiles, context, options) {
|
|
|
10185
11060
|
for (const [filePath, record] of Object.entries(manifest.files)) {
|
|
10186
11061
|
if (!filePath.startsWith(".pi/"))
|
|
10187
11062
|
continue;
|
|
10188
|
-
const fullPath =
|
|
11063
|
+
const fullPath = path9.join(targetDir, filePath);
|
|
10189
11064
|
if (!templatePaths.has(filePath.replace(".pi/", ""))) {
|
|
10190
11065
|
changes.push({
|
|
10191
11066
|
path: filePath,
|
|
@@ -10291,13 +11166,13 @@ function applyChanges(targetDir, manifest, changes, context, options) {
|
|
|
10291
11166
|
return result;
|
|
10292
11167
|
}
|
|
10293
11168
|
function addFile(targetDir, manifest, filePath, context) {
|
|
10294
|
-
const fullPath =
|
|
11169
|
+
const fullPath = path9.join(targetDir, filePath);
|
|
10295
11170
|
const relativePath = filePath.replace(".pi/", "");
|
|
10296
11171
|
const tmplResult = readTemplate(relativePath);
|
|
10297
11172
|
if (!tmplResult.ok)
|
|
10298
11173
|
return;
|
|
10299
11174
|
const content = renderTemplate(tmplResult.value, context);
|
|
10300
|
-
fs10.mkdirSync(
|
|
11175
|
+
fs10.mkdirSync(path9.dirname(fullPath), { recursive: true });
|
|
10301
11176
|
fs10.writeFileSync(fullPath, content, "utf-8");
|
|
10302
11177
|
manifest.files[filePath] = {
|
|
10303
11178
|
category: categorizeFile(relativePath),
|
|
@@ -10306,13 +11181,13 @@ function addFile(targetDir, manifest, filePath, context) {
|
|
|
10306
11181
|
};
|
|
10307
11182
|
}
|
|
10308
11183
|
function updateFile(targetDir, manifest, filePath, context) {
|
|
10309
|
-
const fullPath =
|
|
11184
|
+
const fullPath = path9.join(targetDir, filePath);
|
|
10310
11185
|
const relativePath = filePath.replace(".pi/", "");
|
|
10311
11186
|
const tmplResult = readTemplate(relativePath);
|
|
10312
11187
|
if (!tmplResult.ok)
|
|
10313
11188
|
return;
|
|
10314
11189
|
const content = renderTemplate(tmplResult.value, context);
|
|
10315
|
-
fs10.mkdirSync(
|
|
11190
|
+
fs10.mkdirSync(path9.dirname(fullPath), { recursive: true });
|
|
10316
11191
|
fs10.writeFileSync(fullPath, content, "utf-8");
|
|
10317
11192
|
manifest.files[filePath] = {
|
|
10318
11193
|
category: categorizeFile(relativePath),
|
|
@@ -10326,7 +11201,7 @@ function preserveFile(targetDir, manifest, filePath) {
|
|
|
10326
11201
|
}
|
|
10327
11202
|
}
|
|
10328
11203
|
function mergeFrontMatterFile(targetDir, manifest, filePath, context) {
|
|
10329
|
-
const fullPath =
|
|
11204
|
+
const fullPath = path9.join(targetDir, filePath);
|
|
10330
11205
|
const relativePath = filePath.replace(".pi/", "");
|
|
10331
11206
|
const userContent = fs10.readFileSync(fullPath, "utf-8");
|
|
10332
11207
|
const tmplResult = readTemplate(relativePath);
|
|
@@ -10366,11 +11241,11 @@ function isFrontMatterFile(userContent, newContent) {
|
|
|
10366
11241
|
`);
|
|
10367
11242
|
}
|
|
10368
11243
|
function regenerateAllExports(targetDir, manifest) {
|
|
10369
|
-
const piDir =
|
|
11244
|
+
const piDir = path9.join(targetDir, ".pi");
|
|
10370
11245
|
for (const tool of manifest.tools) {
|
|
10371
11246
|
if (tool === "pi")
|
|
10372
11247
|
continue;
|
|
10373
|
-
const exportDir =
|
|
11248
|
+
const exportDir = path9.join(targetDir, `.${tool}`);
|
|
10374
11249
|
generateExport(exportDir, tool, piDir, manifest, {});
|
|
10375
11250
|
}
|
|
10376
11251
|
}
|
|
@@ -10507,13 +11382,13 @@ __export(exports_trust, {
|
|
|
10507
11382
|
});
|
|
10508
11383
|
import * as crypto3 from "crypto";
|
|
10509
11384
|
import * as fs17 from "fs";
|
|
10510
|
-
import * as
|
|
11385
|
+
import * as path16 from "path";
|
|
10511
11386
|
function hashFile2(filePath) {
|
|
10512
11387
|
const content = fs17.readFileSync(filePath, "utf-8");
|
|
10513
11388
|
return crypto3.createHash("sha256").update(content).digest("hex");
|
|
10514
11389
|
}
|
|
10515
11390
|
function loadTrustFile(cwd) {
|
|
10516
|
-
const trustPath =
|
|
11391
|
+
const trustPath = path16.join(cwd, TRUST_FILE);
|
|
10517
11392
|
if (!fs17.existsSync(trustPath))
|
|
10518
11393
|
return [];
|
|
10519
11394
|
try {
|
|
@@ -10523,9 +11398,9 @@ function loadTrustFile(cwd) {
|
|
|
10523
11398
|
}
|
|
10524
11399
|
}
|
|
10525
11400
|
function saveTrustFile(cwd, records) {
|
|
10526
|
-
const trustPath =
|
|
11401
|
+
const trustPath = path16.join(cwd, TRUST_FILE);
|
|
10527
11402
|
const tmpPath = `${trustPath}.tmp`;
|
|
10528
|
-
fs17.mkdirSync(
|
|
11403
|
+
fs17.mkdirSync(path16.dirname(trustPath), { recursive: true });
|
|
10529
11404
|
fs17.writeFileSync(tmpPath, JSON.stringify(records, null, 2), "utf-8");
|
|
10530
11405
|
fs17.renameSync(tmpPath, trustPath);
|
|
10531
11406
|
}
|
|
@@ -10585,7 +11460,7 @@ __export(exports_integrity, {
|
|
|
10585
11460
|
});
|
|
10586
11461
|
import * as crypto4 from "crypto";
|
|
10587
11462
|
import * as fs18 from "fs";
|
|
10588
|
-
import * as
|
|
11463
|
+
import * as path17 from "path";
|
|
10589
11464
|
function hashFile3(filePath) {
|
|
10590
11465
|
const content = fs18.readFileSync(filePath, "utf-8");
|
|
10591
11466
|
return crypto4.createHash("sha256").update(content).digest("hex");
|
|
@@ -10593,7 +11468,7 @@ function hashFile3(filePath) {
|
|
|
10593
11468
|
function hashPathFor(filePath) {
|
|
10594
11469
|
const rel = filePath.replace(/^\.\//, "");
|
|
10595
11470
|
const hashName = rel.replace(/[/\\]/g, "_") + HASH_EXT;
|
|
10596
|
-
return
|
|
11471
|
+
return path17.join(HASH_DIR, hashName);
|
|
10597
11472
|
}
|
|
10598
11473
|
function storeHash(filePath) {
|
|
10599
11474
|
const hash = hashFile3(filePath);
|
|
@@ -10635,22 +11510,22 @@ function verifyFile(filePath) {
|
|
|
10635
11510
|
}
|
|
10636
11511
|
function verifyDirectory(dirPath) {
|
|
10637
11512
|
const results = [];
|
|
10638
|
-
const hashDir =
|
|
11513
|
+
const hashDir = path17.join(dirPath, HASH_DIR);
|
|
10639
11514
|
if (fs18.existsSync(hashDir)) {
|
|
10640
11515
|
const hashFiles = fs18.readdirSync(hashDir).filter((f2) => f2.endsWith(HASH_EXT));
|
|
10641
11516
|
for (const hf of hashFiles) {
|
|
10642
|
-
const hashPath =
|
|
11517
|
+
const hashPath = path17.join(hashDir, hf);
|
|
10643
11518
|
const content = fs18.readFileSync(hashPath, "utf-8");
|
|
10644
11519
|
const filePath = content.split(" ")[1]?.trim() ?? hf.replace(HASH_EXT, "");
|
|
10645
|
-
const fullPath =
|
|
11520
|
+
const fullPath = path17.isAbsolute(filePath) ? filePath : path17.join(dirPath, filePath);
|
|
10646
11521
|
results.push(verifyFile(fullPath));
|
|
10647
11522
|
}
|
|
10648
11523
|
}
|
|
10649
|
-
const manifestPath =
|
|
11524
|
+
const manifestPath = path17.join(dirPath, "guardian-manifest.json");
|
|
10650
11525
|
if (fs18.existsSync(manifestPath)) {
|
|
10651
11526
|
const manifest = JSON.parse(fs18.readFileSync(manifestPath, "utf-8"));
|
|
10652
11527
|
for (const filePath of Object.keys(manifest.files ?? {})) {
|
|
10653
|
-
const fullPath =
|
|
11528
|
+
const fullPath = path17.join(dirPath, filePath);
|
|
10654
11529
|
const alreadyChecked = results.some((r2) => r2.filePath === fullPath);
|
|
10655
11530
|
if (!alreadyChecked) {
|
|
10656
11531
|
results.push(verifyFile(fullPath));
|
|
@@ -10681,17 +11556,19 @@ var HASH_DIR = ".guardian", HASH_EXT = ".sha256";
|
|
|
10681
11556
|
var init_integrity = () => {};
|
|
10682
11557
|
|
|
10683
11558
|
// src/index.ts
|
|
11559
|
+
init_dist4();
|
|
11560
|
+
import { execFileSync } from "child_process";
|
|
10684
11561
|
import { parseArgs } from "util";
|
|
10685
11562
|
|
|
10686
11563
|
// src/commands/domain.ts
|
|
10687
11564
|
init_dist4();
|
|
10688
11565
|
import * as fs2 from "fs";
|
|
10689
|
-
import * as
|
|
11566
|
+
import * as path3 from "path";
|
|
10690
11567
|
|
|
10691
11568
|
// src/lib/domain-explorer.ts
|
|
10692
11569
|
import * as crypto from "crypto";
|
|
10693
11570
|
import * as fs from "fs";
|
|
10694
|
-
import * as
|
|
11571
|
+
import * as path2 from "path";
|
|
10695
11572
|
var __dirname = "/Users/arman/project/guardian-framework/src/lib", __filename = "/Users/arman/project/guardian-framework/src/lib/domain-explorer.ts";
|
|
10696
11573
|
var MAX_BUSINESS_CONTEXT_LENGTH = 5000;
|
|
10697
11574
|
function sanitizeBusinessContext(context) {
|
|
@@ -11070,14 +11947,14 @@ async function exploreDomain(context, options) {
|
|
|
11070
11947
|
const projectDir = options?.projectDir ?? process.cwd();
|
|
11071
11948
|
const dryRun = options?.dryRun ?? false;
|
|
11072
11949
|
const sessionId = options?.sessionId ?? crypto.randomUUID();
|
|
11073
|
-
const explorationDir =
|
|
11950
|
+
const explorationDir = path2.join(projectDir, ".pi", "domain", "exploration");
|
|
11074
11951
|
if (!fs.existsSync(explorationDir)) {
|
|
11075
11952
|
fs.mkdirSync(explorationDir, { recursive: true });
|
|
11076
11953
|
}
|
|
11077
11954
|
let lang = options?.language;
|
|
11078
11955
|
if (!lang) {
|
|
11079
11956
|
try {
|
|
11080
|
-
const manifestPath =
|
|
11957
|
+
const manifestPath = path2.join(projectDir, "guardian-manifest.json");
|
|
11081
11958
|
if (fs.existsSync(manifestPath)) {
|
|
11082
11959
|
const manifest = JSON.parse(fs.readFileSync(manifestPath, "utf-8"));
|
|
11083
11960
|
if (manifest.language)
|
|
@@ -11100,7 +11977,7 @@ async function exploreDomain(context, options) {
|
|
|
11100
11977
|
prompt
|
|
11101
11978
|
].join(`
|
|
11102
11979
|
`);
|
|
11103
|
-
const promptPath =
|
|
11980
|
+
const promptPath = path2.join(explorationDir, `${sessionId}.prompt.md`);
|
|
11104
11981
|
if (!dryRun) {
|
|
11105
11982
|
fs.writeFileSync(promptPath, promptContent, "utf-8");
|
|
11106
11983
|
console.error("[domain-explore] Prompt written to: ${promptPath}");
|
|
@@ -11133,7 +12010,7 @@ function answerExploration(sessionId, responseJson, options) {
|
|
|
11133
12010
|
}
|
|
11134
12011
|
function readExplorationSession(sessionId, projectDir) {
|
|
11135
12012
|
const root = projectDir ?? process.cwd();
|
|
11136
|
-
const filePath =
|
|
12013
|
+
const filePath = path2.join(root, ".pi", "domain", "exploration", `${sessionId}.md`);
|
|
11137
12014
|
if (!fs.existsSync(filePath)) {
|
|
11138
12015
|
return null;
|
|
11139
12016
|
}
|
|
@@ -11246,7 +12123,7 @@ function scaffoldFromExploration(sessionId, options) {
|
|
|
11246
12123
|
let lang = options?.language;
|
|
11247
12124
|
if (!lang) {
|
|
11248
12125
|
try {
|
|
11249
|
-
const manifestPath =
|
|
12126
|
+
const manifestPath = path2.join(projectDir, "guardian-manifest.json");
|
|
11250
12127
|
if (fs.existsSync(manifestPath)) {
|
|
11251
12128
|
const manifest = JSON.parse(fs.readFileSync(manifestPath, "utf-8"));
|
|
11252
12129
|
if (manifest.language)
|
|
@@ -11260,7 +12137,7 @@ function scaffoldFromExploration(sessionId, options) {
|
|
|
11260
12137
|
throw new Error(`Exploration session not found: ${sessionId}`);
|
|
11261
12138
|
}
|
|
11262
12139
|
const result = sessionResult;
|
|
11263
|
-
const modulesDir =
|
|
12140
|
+
const modulesDir = path2.join(projectDir, ".pi", "architecture", "modules");
|
|
11264
12141
|
const modules = [];
|
|
11265
12142
|
const warnings = [];
|
|
11266
12143
|
const timestamp = new Date().toISOString().split("T")[0];
|
|
@@ -11313,7 +12190,7 @@ function scaffoldFromExploration(sessionId, options) {
|
|
|
11313
12190
|
for (const bc of result.boundedContexts) {
|
|
11314
12191
|
const moduleName = contextToModule(bc.name);
|
|
11315
12192
|
const fileName = `${moduleName}.md`;
|
|
11316
|
-
const filePath =
|
|
12193
|
+
const filePath = path2.join(modulesDir, fileName);
|
|
11317
12194
|
const contextEntities = entitiesByContext[bc.name] || [];
|
|
11318
12195
|
const contextEvents = result.domainEvents.filter((ev) => ev.context === bc.name);
|
|
11319
12196
|
const contextTerms = result.ubiquitousLanguage.filter((t2) => t2.boundedContext === bc.name);
|
|
@@ -11758,13 +12635,13 @@ ${bc.description}
|
|
|
11758
12635
|
}
|
|
11759
12636
|
function loadExplorationTemplate() {
|
|
11760
12637
|
const possiblePaths = [
|
|
11761
|
-
|
|
11762
|
-
|
|
11763
|
-
|
|
12638
|
+
path2.join(__dirname, "..", "..", "templates", "pi", "domain", "exploration.md"),
|
|
12639
|
+
path2.join(__dirname, "..", "..", "..", "templates", "pi", "domain", "exploration.md"),
|
|
12640
|
+
path2.resolve(path2.dirname(fs.realpathSync(__filename)), "..", "..", "..", "templates", "pi", "domain", "exploration.md")
|
|
11764
12641
|
];
|
|
11765
|
-
for (const
|
|
11766
|
-
if (fs.existsSync(
|
|
11767
|
-
return fs.readFileSync(
|
|
12642
|
+
for (const p3 of possiblePaths) {
|
|
12643
|
+
if (fs.existsSync(p3)) {
|
|
12644
|
+
return fs.readFileSync(p3, "utf-8");
|
|
11768
12645
|
}
|
|
11769
12646
|
}
|
|
11770
12647
|
throw new Error("Exploration template not found in templates/pi/domain/exploration.md");
|
|
@@ -11856,7 +12733,7 @@ function parseTableRow(row) {
|
|
|
11856
12733
|
var GLOSSARY_TABLE_HEADER = `| Term | Definition | Bounded Context | Aliases/Synonyms | Examples |
|
|
11857
12734
|
|------|-----------|----------------|-----------------|---------|`;
|
|
11858
12735
|
function renderGlossaryTable(terms) {
|
|
11859
|
-
const sorted = [...terms].sort((a2,
|
|
12736
|
+
const sorted = [...terms].sort((a2, b3) => a2.term.localeCompare(b3.term));
|
|
11860
12737
|
const rows = sorted.map((t2) => {
|
|
11861
12738
|
const aliasesStr = t2.aliases.length > 0 ? t2.aliases.join(", ") : "";
|
|
11862
12739
|
return `| ${t2.term} | ${t2.definition} | ${t2.boundedContext} | ${aliasesStr} | ${t2.examples} |`;
|
|
@@ -11866,14 +12743,14 @@ function renderGlossaryTable(terms) {
|
|
|
11866
12743
|
}
|
|
11867
12744
|
function updateUbiquitousLanguage(newTerms, options = {}) {
|
|
11868
12745
|
const projectDir = options.projectDir ?? process.cwd();
|
|
11869
|
-
const glossaryPath = options.glossaryPath ??
|
|
12746
|
+
const glossaryPath = options.glossaryPath ?? path2.join(projectDir, ".pi", "domain", "ubiquitous-language.md");
|
|
11870
12747
|
const dryRun = options.dryRun ?? false;
|
|
11871
12748
|
const existingTerms = parseUbiquitousLanguageGlossary(glossaryPath);
|
|
11872
12749
|
const existingNames = new Set(existingTerms.map((t2) => t2.term.toLowerCase()));
|
|
11873
12750
|
const uniqueNewTerms = newTerms.filter((t2) => !existingNames.has(t2.term.toLowerCase()));
|
|
11874
12751
|
const skipped = newTerms.length - uniqueNewTerms.length;
|
|
11875
12752
|
const mergedTerms = [...existingTerms, ...uniqueNewTerms];
|
|
11876
|
-
mergedTerms.sort((a2,
|
|
12753
|
+
mergedTerms.sort((a2, b3) => a2.term.localeCompare(b3.term));
|
|
11877
12754
|
const addedLines = uniqueNewTerms.map((t2) => ` + ${t2.term}`);
|
|
11878
12755
|
const diff = addedLines.length > 0 ? `Would add ${addedLines.length} term(s):
|
|
11879
12756
|
${addedLines.join(`
|
|
@@ -11920,7 +12797,7 @@ ${originalForAppend.slice(addingSectionIndex)}`;
|
|
|
11920
12797
|
}
|
|
11921
12798
|
}
|
|
11922
12799
|
const tempPath = `${glossaryPath}.tmp`;
|
|
11923
|
-
fs.mkdirSync(
|
|
12800
|
+
fs.mkdirSync(path2.dirname(glossaryPath), { recursive: true });
|
|
11924
12801
|
fs.writeFileSync(tempPath, fullContent, "utf-8");
|
|
11925
12802
|
fs.renameSync(tempPath, glossaryPath);
|
|
11926
12803
|
return {
|
|
@@ -11932,8 +12809,8 @@ ${originalForAppend.slice(addingSectionIndex)}`;
|
|
|
11932
12809
|
}
|
|
11933
12810
|
function writeExplorationSession(result, projectDir, dryRun) {
|
|
11934
12811
|
const root = projectDir ?? process.cwd();
|
|
11935
|
-
const explorationDir =
|
|
11936
|
-
const outputPath =
|
|
12812
|
+
const explorationDir = path2.join(root, ".pi", "domain", "exploration");
|
|
12813
|
+
const outputPath = path2.join(explorationDir, `${result.sessionId}.md`);
|
|
11937
12814
|
const content = renderExplorationTemplate(result);
|
|
11938
12815
|
if (dryRun) {
|
|
11939
12816
|
return `[dry-run] Would write to ${outputPath}
|
|
@@ -12021,7 +12898,7 @@ async function runAnswer(targetDir, sessionId, responseFile, options) {
|
|
|
12021
12898
|
return;
|
|
12022
12899
|
}
|
|
12023
12900
|
try {
|
|
12024
|
-
const responsePath =
|
|
12901
|
+
const responsePath = path3.resolve(targetDir, responseFile);
|
|
12025
12902
|
if (!fs2.existsSync(responsePath)) {
|
|
12026
12903
|
outro(`Response file not found: ${responsePath}`);
|
|
12027
12904
|
return;
|
|
@@ -12083,7 +12960,7 @@ async function runScaffold(targetDir, sessionId, options) {
|
|
|
12083
12960
|
}
|
|
12084
12961
|
}
|
|
12085
12962
|
function runList(targetDir) {
|
|
12086
|
-
const explorationDir =
|
|
12963
|
+
const explorationDir = path3.join(targetDir, ".pi", "domain", "exploration");
|
|
12087
12964
|
if (!fs2.existsSync(explorationDir)) {
|
|
12088
12965
|
outro("No exploration sessions found");
|
|
12089
12966
|
return;
|
|
@@ -12096,12 +12973,12 @@ function runList(targetDir) {
|
|
|
12096
12973
|
}
|
|
12097
12974
|
console.log("Exploration sessions:");
|
|
12098
12975
|
for (const file of files) {
|
|
12099
|
-
const filePath =
|
|
12976
|
+
const filePath = path3.join(explorationDir, file);
|
|
12100
12977
|
const stats = fs2.statSync(filePath);
|
|
12101
12978
|
const sessionId = file.replace(".md", "");
|
|
12102
12979
|
const modified = stats.mtime.toISOString().split("T")[0];
|
|
12103
12980
|
const size = stats.size;
|
|
12104
|
-
const promptFile =
|
|
12981
|
+
const promptFile = path3.join(explorationDir, `${sessionId}.prompt.md`);
|
|
12105
12982
|
const status = fs2.existsSync(promptFile) ? "awaiting-response" : "complete";
|
|
12106
12983
|
console.log(` ${sessionId.padEnd(40)}${String(size).padStart(6)}B ${modified} [${status}]`);
|
|
12107
12984
|
}
|
|
@@ -12120,7 +12997,7 @@ import * as nodePath from "path";
|
|
|
12120
12997
|
// src/lib/tracking.ts
|
|
12121
12998
|
import * as fs8 from "fs";
|
|
12122
12999
|
import * as os from "os";
|
|
12123
|
-
import * as
|
|
13000
|
+
import * as path8 from "path";
|
|
12124
13001
|
var DEFAULT_PRICING = {
|
|
12125
13002
|
openai: { name: "OpenAI", inputPerM: 5, outputPerM: 15 },
|
|
12126
13003
|
anthropic: { name: "Anthropic", inputPerM: 3, outputPerM: 15 },
|
|
@@ -12129,11 +13006,11 @@ var DEFAULT_PRICING = {
|
|
|
12129
13006
|
};
|
|
12130
13007
|
var HISTORY_DAYS = 90;
|
|
12131
13008
|
function getDbPath() {
|
|
12132
|
-
const dataDir =
|
|
13009
|
+
const dataDir = path8.join(os.homedir(), ".local", "share", "guardian");
|
|
12133
13010
|
if (!fs8.existsSync(dataDir)) {
|
|
12134
13011
|
fs8.mkdirSync(dataDir, { recursive: true });
|
|
12135
13012
|
}
|
|
12136
|
-
return
|
|
13013
|
+
return path8.join(dataDir, "history.json");
|
|
12137
13014
|
}
|
|
12138
13015
|
function loadRecords() {
|
|
12139
13016
|
const dbPath = getDbPath();
|
|
@@ -12199,15 +13076,15 @@ function getStats(sinceDays = 30) {
|
|
|
12199
13076
|
for (const r2 of recent) {
|
|
12200
13077
|
validatorCounts.set(r2.validator, (validatorCounts.get(r2.validator) ?? 0) + 1);
|
|
12201
13078
|
}
|
|
12202
|
-
const topValidators = [...validatorCounts.entries()].sort((a2,
|
|
13079
|
+
const topValidators = [...validatorCounts.entries()].sort((a2, b3) => b3[1] - a2[1]).slice(0, 10).map(([validator, count]) => ({ validator, count }));
|
|
12203
13080
|
const dailyMap = new Map;
|
|
12204
13081
|
for (const r2 of recent) {
|
|
12205
|
-
const
|
|
12206
|
-
const entry = dailyMap.get(
|
|
13082
|
+
const date2 = r2.timestamp.split("T")[0];
|
|
13083
|
+
const entry = dailyMap.get(date2) ?? { tokens: 0, usd: 0 };
|
|
12207
13084
|
entry.tokens += r2.savedTokens;
|
|
12208
|
-
dailyMap.set(
|
|
13085
|
+
dailyMap.set(date2, entry);
|
|
12209
13086
|
}
|
|
12210
|
-
const dailyBreakdown = [...dailyMap.entries()].sort((a2,
|
|
13087
|
+
const dailyBreakdown = [...dailyMap.entries()].sort((a2, b3) => a2[0].localeCompare(b3[0])).map(([date2, { tokens, usd }]) => ({ date: date2, tokens, usd: estimateUsdSaved(tokens) }));
|
|
12211
13088
|
return {
|
|
12212
13089
|
totalCommands,
|
|
12213
13090
|
totalInputTokens: totalInput,
|
|
@@ -12350,7 +13227,7 @@ ${Object.entries(exportSyncStatus).map(([tool, synced]) => `\u2502 .${tool.padEn
|
|
|
12350
13227
|
\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518
|
|
12351
13228
|
|
|
12352
13229
|
${modifiedFiles.length > 0 ? `Modified files:
|
|
12353
|
-
${modifiedFiles.map(([
|
|
13230
|
+
${modifiedFiles.map(([p3]) => p3).join(`
|
|
12354
13231
|
`)}` : "No modified files."}
|
|
12355
13232
|
|
|
12356
13233
|
${Object.entries(exportSyncStatus).some(([_2, s]) => !s) ? "\u26A0\uFE0F Some exports out of sync. Run: guardian-framework generate" : "\u2705 All exports in sync."}
|
|
@@ -12361,7 +13238,7 @@ ${Object.entries(exportSyncStatus).some(([_2, s]) => !s) ? "\u26A0\uFE0F Some e
|
|
|
12361
13238
|
init_dist4();
|
|
12362
13239
|
init_manifest();
|
|
12363
13240
|
import * as fs11 from "fs";
|
|
12364
|
-
import * as
|
|
13241
|
+
import * as path10 from "path";
|
|
12365
13242
|
|
|
12366
13243
|
// src/lib/prompts.ts
|
|
12367
13244
|
init_dist4();
|
|
@@ -12635,25 +13512,25 @@ async function scaffoldFramework(targetDir, options) {
|
|
|
12635
13512
|
templateContext: context
|
|
12636
13513
|
});
|
|
12637
13514
|
const scaffoldedFiles = {};
|
|
12638
|
-
const piDir =
|
|
13515
|
+
const piDir = path10.join(targetDir, PI_DIR);
|
|
12639
13516
|
const scaffoldErrors = scaffoldPiDirectory(piDir, context, scaffoldedFiles);
|
|
12640
13517
|
const generatedFiles = {};
|
|
12641
13518
|
for (const tool of options.tools) {
|
|
12642
|
-
const exportDir = tool === "pi" ?
|
|
13519
|
+
const exportDir = tool === "pi" ? path10.join(targetDir, AGENTS_DIR) : path10.join(targetDir, `.${tool}`);
|
|
12643
13520
|
generateExport(exportDir, tool, piDir, manifest, generatedFiles);
|
|
12644
13521
|
}
|
|
12645
13522
|
for (const [filePath, record] of Object.entries(generatedFiles)) {
|
|
12646
13523
|
scaffoldedFiles[filePath] = record;
|
|
12647
13524
|
}
|
|
12648
|
-
const gitignorePath =
|
|
12649
|
-
const gitignoreTemplatePath =
|
|
13525
|
+
const gitignorePath = path10.join(targetDir, ".gitignore");
|
|
13526
|
+
const gitignoreTemplatePath = path10.join(TEMPLATE_DIR, ".gitignore");
|
|
12650
13527
|
if (fs11.existsSync(gitignoreTemplatePath)) {
|
|
12651
13528
|
const gitignoreContent = fs11.readFileSync(gitignoreTemplatePath, "utf-8");
|
|
12652
13529
|
await fs11.promises.writeFile(gitignorePath, gitignoreContent);
|
|
12653
13530
|
scaffoldedFiles[".gitignore"] = { category: "framework", content: gitignoreContent };
|
|
12654
13531
|
}
|
|
12655
|
-
const workflowPath =
|
|
12656
|
-
const workflowTemplatePath =
|
|
13532
|
+
const workflowPath = path10.join(targetDir, "WORKFLOW.md");
|
|
13533
|
+
const workflowTemplatePath = path10.join(TEMPLATE_DIR, "workflow.md");
|
|
12657
13534
|
if (fs11.existsSync(workflowTemplatePath)) {
|
|
12658
13535
|
let workflowContent = fs11.readFileSync(workflowTemplatePath, "utf-8");
|
|
12659
13536
|
workflowContent = workflowContent.replace(/\[Project Name\]/g, options.projectName).replace(/\[FrameworkVersion\]/g, FRAMEWORK_VERSION).replace(/\[Date\]/g, new Date().toISOString().split("T")[0]);
|
|
@@ -12699,12 +13576,12 @@ function scaffoldPiDirectory(piDir, context, scaffoldedFiles) {
|
|
|
12699
13576
|
"extensions"
|
|
12700
13577
|
];
|
|
12701
13578
|
for (const dir of directories) {
|
|
12702
|
-
const fullPath =
|
|
13579
|
+
const fullPath = path10.join(piDir, dir);
|
|
12703
13580
|
fs11.mkdirSync(fullPath, { recursive: true });
|
|
12704
13581
|
}
|
|
12705
13582
|
const templateFiles = getPiTemplateFiles();
|
|
12706
13583
|
for (const relativePath of templateFiles) {
|
|
12707
|
-
const targetPath =
|
|
13584
|
+
const targetPath = path10.join(piDir, relativePath);
|
|
12708
13585
|
if (shouldSkipFile(relativePath, context.language)) {
|
|
12709
13586
|
continue;
|
|
12710
13587
|
}
|
|
@@ -12714,13 +13591,13 @@ function scaffoldPiDirectory(piDir, context, scaffoldedFiles) {
|
|
|
12714
13591
|
continue;
|
|
12715
13592
|
}
|
|
12716
13593
|
const rendered = renderTemplate(templateResult.value, context);
|
|
12717
|
-
fs11.mkdirSync(
|
|
13594
|
+
fs11.mkdirSync(path10.dirname(targetPath), { recursive: true });
|
|
12718
13595
|
fs11.writeFileSync(targetPath, rendered, "utf-8");
|
|
12719
13596
|
const manifestPath = `${PI_DIR}/${relativePath}`;
|
|
12720
13597
|
const category = categorizeFile(relativePath);
|
|
12721
13598
|
scaffoldedFiles[manifestPath] = { category, content: rendered };
|
|
12722
13599
|
}
|
|
12723
|
-
const patternsPath =
|
|
13600
|
+
const patternsPath = path10.join(piDir, "context/patterns.md");
|
|
12724
13601
|
const patternsResult = readLanguagePatterns(context.language);
|
|
12725
13602
|
if (patternsResult.ok) {
|
|
12726
13603
|
const renderedPatterns = renderTemplate(patternsResult.value, context);
|
|
@@ -12732,8 +13609,8 @@ function scaffoldPiDirectory(piDir, context, scaffoldedFiles) {
|
|
|
12732
13609
|
} else {
|
|
12733
13610
|
errors.push(`context/patterns.md: ${patternsResult.error.message}`);
|
|
12734
13611
|
}
|
|
12735
|
-
const explorationPath =
|
|
12736
|
-
const domainDir =
|
|
13612
|
+
const explorationPath = path10.join(piDir, "domain", "exploration.md");
|
|
13613
|
+
const domainDir = path10.dirname(explorationPath);
|
|
12737
13614
|
if (!fs11.existsSync(domainDir)) {
|
|
12738
13615
|
fs11.mkdirSync(domainDir, { recursive: true });
|
|
12739
13616
|
}
|
|
@@ -12826,7 +13703,7 @@ function scaffoldPiDirectory(piDir, context, scaffoldedFiles) {
|
|
|
12826
13703
|
content: placeholder
|
|
12827
13704
|
};
|
|
12828
13705
|
}
|
|
12829
|
-
const indexPath =
|
|
13706
|
+
const indexPath = path10.join(piDir, "INDEX.md");
|
|
12830
13707
|
const indexResult = readTemplate("INDEX.md");
|
|
12831
13708
|
if (indexResult.ok) {
|
|
12832
13709
|
fs11.writeFileSync(indexPath, indexResult.value, "utf-8");
|
|
@@ -12873,12 +13750,12 @@ async function confirmOverwrite(targetDir) {
|
|
|
12873
13750
|
|
|
12874
13751
|
// src/commands/project.ts
|
|
12875
13752
|
import * as fs15 from "fs";
|
|
12876
|
-
import * as
|
|
13753
|
+
import * as path14 from "path";
|
|
12877
13754
|
|
|
12878
13755
|
// src/lib/build-config.ts
|
|
12879
13756
|
init_templates();
|
|
12880
13757
|
import * as fs12 from "fs";
|
|
12881
|
-
import * as
|
|
13758
|
+
import * as path11 from "path";
|
|
12882
13759
|
function getSubLayerDeps(layers, language) {
|
|
12883
13760
|
const deps = [];
|
|
12884
13761
|
if (language === "java") {
|
|
@@ -13061,18 +13938,18 @@ test {
|
|
|
13061
13938
|
finalizedBy jacocoTestReport
|
|
13062
13939
|
}
|
|
13063
13940
|
`;
|
|
13064
|
-
files2.push({ path:
|
|
13941
|
+
files2.push({ path: path11.join(targetDir, "build.gradle"), content: gradleContent });
|
|
13065
13942
|
} else {
|
|
13066
13943
|
const pomContent = generateJavaMavenPom(groupId, projectName, version2, layers);
|
|
13067
|
-
files2.push({ path:
|
|
13944
|
+
files2.push({ path: path11.join(targetDir, "pom.xml"), content: pomContent });
|
|
13068
13945
|
}
|
|
13069
13946
|
} else if (language === "typescript") {
|
|
13070
13947
|
const packageJson = generateTypeScriptPackageJson(projectName, version2, layers);
|
|
13071
|
-
files2.push({ path:
|
|
13948
|
+
files2.push({ path: path11.join(targetDir, "package.json"), content: packageJson });
|
|
13072
13949
|
}
|
|
13073
13950
|
if (!dryRun) {
|
|
13074
13951
|
for (const file of files2) {
|
|
13075
|
-
fs12.mkdirSync(
|
|
13952
|
+
fs12.mkdirSync(path11.dirname(file.path), { recursive: true });
|
|
13076
13953
|
fs12.writeFileSync(file.path, file.content, "utf-8");
|
|
13077
13954
|
}
|
|
13078
13955
|
}
|
|
@@ -13081,7 +13958,7 @@ test {
|
|
|
13081
13958
|
|
|
13082
13959
|
// src/lib/ci-generator.ts
|
|
13083
13960
|
import * as fs13 from "fs";
|
|
13084
|
-
import * as
|
|
13961
|
+
import * as path12 from "path";
|
|
13085
13962
|
function generateCiPipeline(targetDir, options) {
|
|
13086
13963
|
const { language, buildTool, repoTool, validators, dryRun } = options;
|
|
13087
13964
|
const files2 = [];
|
|
@@ -13100,7 +13977,7 @@ jobs:
|
|
|
13100
13977
|
- name: Run Guardian hardening pipeline
|
|
13101
13978
|
run: bash .pi/scripts/local-ci.sh
|
|
13102
13979
|
`;
|
|
13103
|
-
files2.push({ path:
|
|
13980
|
+
files2.push({ path: path12.join(targetDir, ".github/workflows/ci.yml"), content: ciYaml });
|
|
13104
13981
|
} else {
|
|
13105
13982
|
const ciYaml = `stages:
|
|
13106
13983
|
- validate
|
|
@@ -13113,13 +13990,13 @@ validate:
|
|
|
13113
13990
|
only:
|
|
13114
13991
|
- branches
|
|
13115
13992
|
`;
|
|
13116
|
-
files2.push({ path:
|
|
13993
|
+
files2.push({ path: path12.join(targetDir, ".gitlab-ci.yml"), content: ciYaml });
|
|
13117
13994
|
}
|
|
13118
13995
|
const stageScripts = generateStageScripts(language, validators);
|
|
13119
13996
|
files2.push(...stageScripts);
|
|
13120
13997
|
if (!dryRun) {
|
|
13121
13998
|
for (const file of files2) {
|
|
13122
|
-
fs13.mkdirSync(
|
|
13999
|
+
fs13.mkdirSync(path12.dirname(file.path), { recursive: true });
|
|
13123
14000
|
fs13.writeFileSync(file.path, file.content, "utf-8");
|
|
13124
14001
|
}
|
|
13125
14002
|
}
|
|
@@ -13169,9 +14046,9 @@ exit 0
|
|
|
13169
14046
|
|
|
13170
14047
|
// src/lib/project-generator.ts
|
|
13171
14048
|
import * as fs14 from "fs";
|
|
13172
|
-
import * as
|
|
14049
|
+
import * as path13 from "path";
|
|
13173
14050
|
function discoverModules(archDir) {
|
|
13174
|
-
const modulesDir =
|
|
14051
|
+
const modulesDir = path13.join(archDir, "modules");
|
|
13175
14052
|
if (!fs14.existsSync(modulesDir)) {
|
|
13176
14053
|
return [];
|
|
13177
14054
|
}
|
|
@@ -13183,7 +14060,7 @@ function discoverModules(archDir) {
|
|
|
13183
14060
|
continue;
|
|
13184
14061
|
if (file === "module-template.md")
|
|
13185
14062
|
continue;
|
|
13186
|
-
const content = fs14.readFileSync(
|
|
14063
|
+
const content = fs14.readFileSync(path13.join(modulesDir, file), "utf-8");
|
|
13187
14064
|
const match = content.match(/^#\s+(.+)/m);
|
|
13188
14065
|
if (match) {
|
|
13189
14066
|
const name2 = match[1].trim();
|
|
@@ -13194,14 +14071,14 @@ function discoverModules(archDir) {
|
|
|
13194
14071
|
return modules;
|
|
13195
14072
|
}
|
|
13196
14073
|
function resolveLayers(archDir, language, defaults) {
|
|
13197
|
-
const modulesDir =
|
|
14074
|
+
const modulesDir = path13.join(archDir, "modules");
|
|
13198
14075
|
if (fs14.existsSync(modulesDir)) {
|
|
13199
14076
|
try {
|
|
13200
14077
|
const files2 = fs14.readdirSync(modulesDir);
|
|
13201
14078
|
for (const file of files2) {
|
|
13202
14079
|
if (!file.endsWith(".md"))
|
|
13203
14080
|
continue;
|
|
13204
|
-
const content = fs14.readFileSync(
|
|
14081
|
+
const content = fs14.readFileSync(path13.join(modulesDir, file), "utf-8");
|
|
13205
14082
|
const layersMatch = content.match(/^layers:\s*\[(.*?)\]/m);
|
|
13206
14083
|
if (layersMatch) {
|
|
13207
14084
|
return layersMatch[1].split(",").map((s) => s.trim().replace(/['"]/g, "")).filter(Boolean);
|
|
@@ -13209,7 +14086,7 @@ function resolveLayers(archDir, language, defaults) {
|
|
|
13209
14086
|
}
|
|
13210
14087
|
} catch {}
|
|
13211
14088
|
}
|
|
13212
|
-
const decisionsDir =
|
|
14089
|
+
const decisionsDir = path13.join(archDir, "decisions");
|
|
13213
14090
|
const adrLayers = new Set;
|
|
13214
14091
|
adrLayers.add("domain");
|
|
13215
14092
|
adrLayers.add("application");
|
|
@@ -13220,7 +14097,7 @@ function resolveLayers(archDir, language, defaults) {
|
|
|
13220
14097
|
for (const file of files2) {
|
|
13221
14098
|
if (!file.endsWith(".md"))
|
|
13222
14099
|
continue;
|
|
13223
|
-
const content = fs14.readFileSync(
|
|
14100
|
+
const content = fs14.readFileSync(path13.join(decisionsDir, file), "utf-8").toLowerCase();
|
|
13224
14101
|
if (content.includes("rest") || content.includes("http") || content.includes("grpc")) {
|
|
13225
14102
|
adrLayers.add("interfaces/http");
|
|
13226
14103
|
}
|
|
@@ -13245,12 +14122,12 @@ function resolveLayers(archDir, language, defaults) {
|
|
|
13245
14122
|
function generateProjectStructure(targetDir, options) {
|
|
13246
14123
|
const { language, groupId, modules, layers, dryRun } = options;
|
|
13247
14124
|
const files2 = [];
|
|
13248
|
-
const srcPrefix = language === "java" ?
|
|
14125
|
+
const srcPrefix = language === "java" ? path13.join("src", "main", "java") : "src";
|
|
13249
14126
|
const groupPath = groupId.replace(/\./g, "/");
|
|
13250
14127
|
for (const moduleName of modules) {
|
|
13251
14128
|
for (const layer of layers) {
|
|
13252
|
-
const dirPath =
|
|
13253
|
-
const gitkeepPath =
|
|
14129
|
+
const dirPath = path13.join(targetDir, srcPrefix, groupPath, moduleName, layer);
|
|
14130
|
+
const gitkeepPath = path13.join(dirPath, ".gitkeep");
|
|
13254
14131
|
files2.push({
|
|
13255
14132
|
path: gitkeepPath,
|
|
13256
14133
|
content: ""
|
|
@@ -13261,7 +14138,7 @@ function generateProjectStructure(targetDir, options) {
|
|
|
13261
14138
|
}
|
|
13262
14139
|
const ext = language === "java" ? ".java" : ".ts";
|
|
13263
14140
|
const placeholderFileName = `${moduleName}_${layer.replace(/[/ ]/g, "_")}${ext}`;
|
|
13264
|
-
const placeholderPath =
|
|
14141
|
+
const placeholderPath = path13.join(dirPath, placeholderFileName);
|
|
13265
14142
|
const moduleDocName = moduleName.toLowerCase().replace(/\s+/g, "-");
|
|
13266
14143
|
const canonicalRef = `// Canonical Reference: .pi/architecture/modules/${moduleDocName}.md#${layer}`;
|
|
13267
14144
|
files2.push({
|
|
@@ -13294,7 +14171,7 @@ function runProjectGenerator(targetDir, archDir, options) {
|
|
|
13294
14171
|
init_templates();
|
|
13295
14172
|
var PI_DIR2 = ".pi";
|
|
13296
14173
|
function existingProjectDetected(targetDir) {
|
|
13297
|
-
const srcDir =
|
|
14174
|
+
const srcDir = path14.join(targetDir, "src");
|
|
13298
14175
|
return fs15.existsSync(srcDir);
|
|
13299
14176
|
}
|
|
13300
14177
|
async function runProjectCreate(targetDir, options) {
|
|
@@ -13310,7 +14187,7 @@ async function runProjectCreate(targetDir, options) {
|
|
|
13310
14187
|
`);
|
|
13311
14188
|
return;
|
|
13312
14189
|
}
|
|
13313
|
-
const archDir =
|
|
14190
|
+
const archDir = path14.join(targetDir, PI_DIR2, "architecture");
|
|
13314
14191
|
if (!fs15.existsSync(archDir)) {
|
|
13315
14192
|
console.log(`
|
|
13316
14193
|
\u2139\uFE0F No .pi/architecture/ directory found. Using defaults.
|
|
@@ -13356,14 +14233,14 @@ async function runProjectCreate(targetDir, options) {
|
|
|
13356
14233
|
language,
|
|
13357
14234
|
buildTool: buildTool ?? "maven",
|
|
13358
14235
|
groupId,
|
|
13359
|
-
projectName:
|
|
14236
|
+
projectName: path14.basename(targetDir),
|
|
13360
14237
|
version: "0.1.0",
|
|
13361
14238
|
layers: structurePlan.layers,
|
|
13362
14239
|
dryRun
|
|
13363
14240
|
});
|
|
13364
14241
|
if (dryRun) {
|
|
13365
14242
|
for (const file of buildPlan.files) {
|
|
13366
|
-
console.log(` - ${
|
|
14243
|
+
console.log(` - ${path14.relative(targetDir, file.path)}`);
|
|
13367
14244
|
}
|
|
13368
14245
|
console.log("");
|
|
13369
14246
|
} else {
|
|
@@ -13380,7 +14257,7 @@ async function runProjectCreate(targetDir, options) {
|
|
|
13380
14257
|
});
|
|
13381
14258
|
if (dryRun) {
|
|
13382
14259
|
for (const file of ciPlan.files) {
|
|
13383
|
-
console.log(` - ${
|
|
14260
|
+
console.log(` - ${path14.relative(targetDir, file.path)}`);
|
|
13384
14261
|
}
|
|
13385
14262
|
console.log(`
|
|
13386
14263
|
\uD83D\uDCCB Dry run complete. Pass --dryRun to see this plan before creating files.
|
|
@@ -13453,7 +14330,7 @@ Estimated USD savings based on average API pricing ($3/M input, $10/M output).
|
|
|
13453
14330
|
init_dist4();
|
|
13454
14331
|
init_manifest();
|
|
13455
14332
|
import * as fs16 from "fs";
|
|
13456
|
-
import * as
|
|
14333
|
+
import * as path15 from "path";
|
|
13457
14334
|
var MANAGED_ROOTS = [".pi", ".claude", ".opencode", ".agents", ".github", ".omp"];
|
|
13458
14335
|
async function runUninstall(targetDir, options = {}) {
|
|
13459
14336
|
const manifest = readManifest(targetDir);
|
|
@@ -13509,7 +14386,7 @@ function createUninstallPlan(targetDir) {
|
|
|
13509
14386
|
if (!safePath) {
|
|
13510
14387
|
continue;
|
|
13511
14388
|
}
|
|
13512
|
-
const fullPath =
|
|
14389
|
+
const fullPath = path15.join(targetDir, safePath);
|
|
13513
14390
|
if (!fs16.existsSync(fullPath) || !fs16.statSync(fullPath).isFile()) {
|
|
13514
14391
|
continue;
|
|
13515
14392
|
}
|
|
@@ -13530,13 +14407,13 @@ function createUninstallPlan(targetDir) {
|
|
|
13530
14407
|
}
|
|
13531
14408
|
function applyUninstallPlan(targetDir, plan) {
|
|
13532
14409
|
for (const filePath of plan.filesToRemove) {
|
|
13533
|
-
const fullPath =
|
|
14410
|
+
const fullPath = path15.join(targetDir, filePath);
|
|
13534
14411
|
if (fs16.existsSync(fullPath) && fs16.statSync(fullPath).isFile()) {
|
|
13535
14412
|
fs16.rmSync(fullPath);
|
|
13536
14413
|
}
|
|
13537
14414
|
}
|
|
13538
14415
|
for (const dirPath of plan.directoriesToPrune) {
|
|
13539
|
-
const fullPath =
|
|
14416
|
+
const fullPath = path15.join(targetDir, dirPath);
|
|
13540
14417
|
if (fs16.existsSync(fullPath) && fs16.statSync(fullPath).isDirectory()) {
|
|
13541
14418
|
try {
|
|
13542
14419
|
fs16.rmdirSync(fullPath);
|
|
@@ -13545,30 +14422,30 @@ function applyUninstallPlan(targetDir, plan) {
|
|
|
13545
14422
|
}
|
|
13546
14423
|
}
|
|
13547
14424
|
function normalizeManagedPath(filePath) {
|
|
13548
|
-
const normalized =
|
|
13549
|
-
if (normalized.startsWith("..") ||
|
|
14425
|
+
const normalized = path15.normalize(filePath);
|
|
14426
|
+
if (normalized.startsWith("..") || path15.isAbsolute(normalized)) {
|
|
13550
14427
|
return null;
|
|
13551
14428
|
}
|
|
13552
14429
|
if (normalized === MANIFEST_FILE) {
|
|
13553
14430
|
return normalized;
|
|
13554
14431
|
}
|
|
13555
|
-
return MANAGED_ROOTS.some((root) => normalized === root || normalized.startsWith(`${root}${
|
|
14432
|
+
return MANAGED_ROOTS.some((root) => normalized === root || normalized.startsWith(`${root}${path15.sep}`)) ? normalized : null;
|
|
13556
14433
|
}
|
|
13557
14434
|
function collectDirectoriesToPrune(files2) {
|
|
13558
14435
|
const directories = new Set;
|
|
13559
14436
|
for (const file of files2) {
|
|
13560
|
-
let dir =
|
|
13561
|
-
while (dir !== "." && dir !==
|
|
13562
|
-
if (MANAGED_ROOTS.some((root) => dir === root || dir.startsWith(`${root}${
|
|
14437
|
+
let dir = path15.dirname(file);
|
|
14438
|
+
while (dir !== "." && dir !== path15.dirname(dir)) {
|
|
14439
|
+
if (MANAGED_ROOTS.some((root) => dir === root || dir.startsWith(`${root}${path15.sep}`))) {
|
|
13563
14440
|
directories.add(dir);
|
|
13564
14441
|
}
|
|
13565
|
-
dir =
|
|
14442
|
+
dir = path15.dirname(dir);
|
|
13566
14443
|
}
|
|
13567
14444
|
}
|
|
13568
14445
|
for (const root of MANAGED_ROOTS) {
|
|
13569
14446
|
directories.add(root);
|
|
13570
14447
|
}
|
|
13571
|
-
return [...directories].sort((a2,
|
|
14448
|
+
return [...directories].sort((a2, b3) => b3.length - a2.length);
|
|
13572
14449
|
}
|
|
13573
14450
|
|
|
13574
14451
|
// src/index.ts
|
|
@@ -13651,7 +14528,7 @@ function migrateSchemaV0ToV1(manifest) {
|
|
|
13651
14528
|
init_dist4();
|
|
13652
14529
|
import * as child_process2 from "child_process";
|
|
13653
14530
|
import * as fs19 from "fs";
|
|
13654
|
-
import * as
|
|
14531
|
+
import * as path18 from "path";
|
|
13655
14532
|
|
|
13656
14533
|
// src/lib/toml-filter.ts
|
|
13657
14534
|
function parseTomlValue(raw) {
|
|
@@ -13868,23 +14745,23 @@ function applyFilter(filter, stdout2) {
|
|
|
13868
14745
|
}
|
|
13869
14746
|
}
|
|
13870
14747
|
if (filter.strip_lines_matching?.length) {
|
|
13871
|
-
const patterns = filter.strip_lines_matching.map((
|
|
14748
|
+
const patterns = filter.strip_lines_matching.map((p3) => {
|
|
13872
14749
|
try {
|
|
13873
|
-
return new RegExp(
|
|
14750
|
+
return new RegExp(p3);
|
|
13874
14751
|
} catch {
|
|
13875
14752
|
return null;
|
|
13876
14753
|
}
|
|
13877
14754
|
});
|
|
13878
|
-
lines = lines.filter((l2) => !patterns.some((
|
|
14755
|
+
lines = lines.filter((l2) => !patterns.some((p3) => p3?.test(l2)));
|
|
13879
14756
|
} else if (filter.keep_lines_matching?.length) {
|
|
13880
|
-
const patterns = filter.keep_lines_matching.map((
|
|
14757
|
+
const patterns = filter.keep_lines_matching.map((p3) => {
|
|
13881
14758
|
try {
|
|
13882
|
-
return new RegExp(
|
|
14759
|
+
return new RegExp(p3);
|
|
13883
14760
|
} catch {
|
|
13884
14761
|
return null;
|
|
13885
14762
|
}
|
|
13886
14763
|
});
|
|
13887
|
-
lines = lines.filter((l2) => patterns.some((
|
|
14764
|
+
lines = lines.filter((l2) => patterns.some((p3) => p3?.test(l2)));
|
|
13888
14765
|
}
|
|
13889
14766
|
if (filter.truncate_lines_at) {
|
|
13890
14767
|
lines = lines.map((l2) => truncateUnicode(l2, filter.truncate_lines_at));
|
|
@@ -13963,15 +14840,15 @@ function calculateSavings(filter, input) {
|
|
|
13963
14840
|
init_trust();
|
|
13964
14841
|
var __dirname = "/Users/arman/project/guardian-framework/src/commands";
|
|
13965
14842
|
var PI_VALIDATORS_DIR = ".pi/validators";
|
|
13966
|
-
var USER_GLOBAL_PATH =
|
|
13967
|
-
var BUILTIN_PATH =
|
|
14843
|
+
var USER_GLOBAL_PATH = path18.join(process.env.HOME ?? process.env.USERPROFILE ?? "", ".config", "guardian", "filters.toml");
|
|
14844
|
+
var BUILTIN_PATH = path18.join(__dirname, "..", "..", "templates", "pi", "validators", "default.toml");
|
|
13968
14845
|
function loadFilters(targetDir) {
|
|
13969
14846
|
const filters = [];
|
|
13970
14847
|
const warnings = [];
|
|
13971
|
-
const projectDir =
|
|
14848
|
+
const projectDir = path18.join(targetDir, PI_VALIDATORS_DIR);
|
|
13972
14849
|
if (fs19.existsSync(projectDir)) {
|
|
13973
14850
|
for (const file of fs19.readdirSync(projectDir).filter((f2) => f2.endsWith(".toml"))) {
|
|
13974
|
-
const filePath =
|
|
14851
|
+
const filePath = path18.join(projectDir, file);
|
|
13975
14852
|
const trustStatus = checkTrust(targetDir, filePath);
|
|
13976
14853
|
if (trustStatus === "untrusted" || trustStatus === "content-changed") {
|
|
13977
14854
|
warnings.push(trustStatusMessage(trustStatus, filePath));
|
|
@@ -14208,7 +15085,43 @@ async function runVerify(targetDir = process.cwd()) {
|
|
|
14208
15085
|
|
|
14209
15086
|
// src/index.ts
|
|
14210
15087
|
init_manifest();
|
|
14211
|
-
var VERSION = "0.1.
|
|
15088
|
+
var VERSION = "0.1.61";
|
|
15089
|
+
var PKG_NAME = "guardian-framework";
|
|
15090
|
+
var _newerVersion = null;
|
|
15091
|
+
function checkForUpdateSync() {
|
|
15092
|
+
try {
|
|
15093
|
+
const latest = execFileSync("npm", ["view", PKG_NAME, "version", "--no-workspaces", "--silent"], { timeout: 3000, encoding: "utf-8", stdio: ["ignore", "pipe", "ignore"] }).trim();
|
|
15094
|
+
if (latest && latest !== VERSION) {
|
|
15095
|
+
_newerVersion = latest;
|
|
15096
|
+
}
|
|
15097
|
+
} catch {}
|
|
15098
|
+
}
|
|
15099
|
+
async function askAndUpdate() {
|
|
15100
|
+
if (!_newerVersion)
|
|
15101
|
+
return;
|
|
15102
|
+
const shouldUpdate = await confirm({
|
|
15103
|
+
message: `\u2728 Update available: v${VERSION} \u2192 v${_newerVersion}. Update now?`
|
|
15104
|
+
});
|
|
15105
|
+
if (isCancel(shouldUpdate) || !shouldUpdate) {
|
|
15106
|
+
outro(`Run \`npm install -g ${PKG_NAME}@latest\` to update later.`);
|
|
15107
|
+
return;
|
|
15108
|
+
}
|
|
15109
|
+
const s = (await Promise.resolve().then(() => (init_dist4(), exports_dist))).spinner();
|
|
15110
|
+
s.start("Updating...");
|
|
15111
|
+
try {
|
|
15112
|
+
execFileSync("npm", ["install", "-g", `${PKG_NAME}@latest`], {
|
|
15113
|
+
timeout: 60000,
|
|
15114
|
+
encoding: "utf-8",
|
|
15115
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
15116
|
+
});
|
|
15117
|
+
s.stop("Update complete! \u2705");
|
|
15118
|
+
outro(`Updated to v${_newerVersion}. Run \`guardian-framework update\` to sync project files.`);
|
|
15119
|
+
} catch (e) {
|
|
15120
|
+
s.stop("Update failed!");
|
|
15121
|
+
const err = e;
|
|
15122
|
+
outro(`Error: ${err.stderr || err.message || "Unknown error"}`);
|
|
15123
|
+
}
|
|
15124
|
+
}
|
|
14212
15125
|
async function runCli() {
|
|
14213
15126
|
const args = parseArgs({
|
|
14214
15127
|
allowPositionals: true,
|
|
@@ -14232,8 +15145,14 @@ async function runCli() {
|
|
|
14232
15145
|
session: { type: "string" }
|
|
14233
15146
|
}
|
|
14234
15147
|
});
|
|
15148
|
+
if (!args.values.version && !args.values.help) {
|
|
15149
|
+
checkForUpdateSync();
|
|
15150
|
+
}
|
|
14235
15151
|
if (args.values.version) {
|
|
14236
15152
|
console.log(`guardian-framework v${VERSION}`);
|
|
15153
|
+
if (_newerVersion) {
|
|
15154
|
+
outro(`Update available: v${_newerVersion} \u2014 run \`npm install -g ${PKG_NAME}@latest\``);
|
|
15155
|
+
}
|
|
14237
15156
|
return;
|
|
14238
15157
|
}
|
|
14239
15158
|
if (args.values.help) {
|
|
@@ -14398,6 +15317,7 @@ async function runCommand(command, args) {
|
|
|
14398
15317
|
console.error(`Unknown command: ${command}`);
|
|
14399
15318
|
console.log("Run 'guardian-framework --help' for usage");
|
|
14400
15319
|
}
|
|
15320
|
+
await askAndUpdate();
|
|
14401
15321
|
}
|
|
14402
15322
|
|
|
14403
15323
|
// src/cli.ts
|