@pixelfactoryio/theway 0.9.0 → 0.11.0
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/theway.js +1856 -105
- package/package.json +2 -1
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/plugin/commands/archive.md +9 -54
- package/plugin/commands/develop-workflow.md +21 -21
- package/plugin/commands/develop.md +7 -5
- package/plugin/commands/document.md +7 -7
- package/plugin/commands/engineering-light.md +16 -49
- package/plugin/commands/engineering.md +21 -73
- package/plugin/commands/list.md +6 -4
- package/plugin/home/standards/develop.md +6 -4
- package/plugin/home/standards/interaction.md +1 -1
- package/plugin/home/standards/spec-investigation.md +26 -0
- package/plugin/home/standards/spec-review.md +61 -0
- package/plugin/home/templates/coding-standards-template.md +1 -2
- package/plugin/home/templates/fix-spec-template.md +1 -2
- package/plugin/home/templates/light-spec-template.md +1 -2
- package/plugin/home/templates/source-tree-template.md +1 -1
- package/plugin/home/templates/spec-template.md +1 -2
- package/plugin/home/templates/tasks-template.md +3 -2
- package/plugin/home/templates/tech-stack-template.md +1 -2
package/dist/theway.js
CHANGED
|
@@ -1,5 +1,35 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
function __accessProp(key) {
|
|
9
|
+
return this[key];
|
|
10
|
+
}
|
|
11
|
+
var __toESMCache_node;
|
|
12
|
+
var __toESMCache_esm;
|
|
13
|
+
var __toESM = (mod, isNodeMode, target) => {
|
|
14
|
+
var canCache = mod != null && typeof mod === "object";
|
|
15
|
+
if (canCache) {
|
|
16
|
+
var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
|
|
17
|
+
var cached = cache.get(mod);
|
|
18
|
+
if (cached)
|
|
19
|
+
return cached;
|
|
20
|
+
}
|
|
21
|
+
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
22
|
+
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
23
|
+
for (let key of __getOwnPropNames(mod))
|
|
24
|
+
if (!__hasOwnProp.call(to, key))
|
|
25
|
+
__defProp(to, key, {
|
|
26
|
+
get: __accessProp.bind(mod, key),
|
|
27
|
+
enumerable: true
|
|
28
|
+
});
|
|
29
|
+
if (canCache)
|
|
30
|
+
cache.set(mod, to);
|
|
31
|
+
return to;
|
|
32
|
+
};
|
|
3
33
|
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
4
34
|
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
5
35
|
|
|
@@ -6945,6 +6975,64 @@ var require_public_api = __commonJS((exports) => {
|
|
|
6945
6975
|
exports.stringify = stringify;
|
|
6946
6976
|
});
|
|
6947
6977
|
|
|
6978
|
+
// node_modules/sisteransi/src/index.js
|
|
6979
|
+
var require_src = __commonJS((exports, module) => {
|
|
6980
|
+
var ESC2 = "\x1B";
|
|
6981
|
+
var CSI2 = `${ESC2}[`;
|
|
6982
|
+
var beep = "\x07";
|
|
6983
|
+
var cursor = {
|
|
6984
|
+
to(x, y) {
|
|
6985
|
+
if (!y)
|
|
6986
|
+
return `${CSI2}${x + 1}G`;
|
|
6987
|
+
return `${CSI2}${y + 1};${x + 1}H`;
|
|
6988
|
+
},
|
|
6989
|
+
move(x, y) {
|
|
6990
|
+
let ret = "";
|
|
6991
|
+
if (x < 0)
|
|
6992
|
+
ret += `${CSI2}${-x}D`;
|
|
6993
|
+
else if (x > 0)
|
|
6994
|
+
ret += `${CSI2}${x}C`;
|
|
6995
|
+
if (y < 0)
|
|
6996
|
+
ret += `${CSI2}${-y}A`;
|
|
6997
|
+
else if (y > 0)
|
|
6998
|
+
ret += `${CSI2}${y}B`;
|
|
6999
|
+
return ret;
|
|
7000
|
+
},
|
|
7001
|
+
up: (count = 1) => `${CSI2}${count}A`,
|
|
7002
|
+
down: (count = 1) => `${CSI2}${count}B`,
|
|
7003
|
+
forward: (count = 1) => `${CSI2}${count}C`,
|
|
7004
|
+
backward: (count = 1) => `${CSI2}${count}D`,
|
|
7005
|
+
nextLine: (count = 1) => `${CSI2}E`.repeat(count),
|
|
7006
|
+
prevLine: (count = 1) => `${CSI2}F`.repeat(count),
|
|
7007
|
+
left: `${CSI2}G`,
|
|
7008
|
+
hide: `${CSI2}?25l`,
|
|
7009
|
+
show: `${CSI2}?25h`,
|
|
7010
|
+
save: `${ESC2}7`,
|
|
7011
|
+
restore: `${ESC2}8`
|
|
7012
|
+
};
|
|
7013
|
+
var scroll = {
|
|
7014
|
+
up: (count = 1) => `${CSI2}S`.repeat(count),
|
|
7015
|
+
down: (count = 1) => `${CSI2}T`.repeat(count)
|
|
7016
|
+
};
|
|
7017
|
+
var erase = {
|
|
7018
|
+
screen: `${CSI2}2J`,
|
|
7019
|
+
up: (count = 1) => `${CSI2}1J`.repeat(count),
|
|
7020
|
+
down: (count = 1) => `${CSI2}J`.repeat(count),
|
|
7021
|
+
line: `${CSI2}2K`,
|
|
7022
|
+
lineEnd: `${CSI2}K`,
|
|
7023
|
+
lineStart: `${CSI2}1K`,
|
|
7024
|
+
lines(count) {
|
|
7025
|
+
let clear = "";
|
|
7026
|
+
for (let i = 0;i < count; i++)
|
|
7027
|
+
clear += this.line + (i < count - 1 ? cursor.up() : "");
|
|
7028
|
+
if (count)
|
|
7029
|
+
clear += cursor.left;
|
|
7030
|
+
return clear;
|
|
7031
|
+
}
|
|
7032
|
+
};
|
|
7033
|
+
module.exports = { cursor, scroll, erase, beep };
|
|
7034
|
+
});
|
|
7035
|
+
|
|
6948
7036
|
// node_modules/commander/lib/error.js
|
|
6949
7037
|
class CommanderError extends Error {
|
|
6950
7038
|
constructor(exitCode, code, message) {
|
|
@@ -9244,9 +9332,44 @@ ${list}`);
|
|
|
9244
9332
|
return 0;
|
|
9245
9333
|
}
|
|
9246
9334
|
|
|
9247
|
-
// src/core/
|
|
9248
|
-
import {
|
|
9335
|
+
// src/core/authority.ts
|
|
9336
|
+
import { readFileSync as readFileSync4 } from "node:fs";
|
|
9249
9337
|
import { join as join3 } from "node:path";
|
|
9338
|
+
function authoritySection(path2) {
|
|
9339
|
+
let text;
|
|
9340
|
+
try {
|
|
9341
|
+
text = readFileSync4(path2, "utf-8");
|
|
9342
|
+
} catch {
|
|
9343
|
+
return null;
|
|
9344
|
+
}
|
|
9345
|
+
const lines = text.split(`
|
|
9346
|
+
`).map((l) => l.replace(/\r$/, ""));
|
|
9347
|
+
const start = lines.indexOf("## Authority");
|
|
9348
|
+
if (start === -1)
|
|
9349
|
+
return null;
|
|
9350
|
+
const next = lines.findIndex((l, i) => i > start && l.startsWith("## "));
|
|
9351
|
+
const body = lines.slice(start, next === -1 ? lines.length : next);
|
|
9352
|
+
while (body.length > 1 && (body[body.length - 1] ?? "").trim() === "")
|
|
9353
|
+
body.pop();
|
|
9354
|
+
return `${body.join(`
|
|
9355
|
+
`)}
|
|
9356
|
+
`;
|
|
9357
|
+
}
|
|
9358
|
+
function cmdAuthority() {
|
|
9359
|
+
const dir = join3(thewayHome(), "standards");
|
|
9360
|
+
const section = authoritySection(join3(dir, "interaction.md")) ?? authoritySection(join3(dir, "interaction.default.md"));
|
|
9361
|
+
if (section === null) {
|
|
9362
|
+
process.stderr.write(`theway: no ## Authority section in ${join3(dir, "interaction.md")} or interaction.default.md; run npx --yes @pixelfactoryio/theway@latest install, then /reload-plugins
|
|
9363
|
+
`);
|
|
9364
|
+
return 1;
|
|
9365
|
+
}
|
|
9366
|
+
process.stdout.write(section);
|
|
9367
|
+
return 0;
|
|
9368
|
+
}
|
|
9369
|
+
|
|
9370
|
+
// src/core/config.ts
|
|
9371
|
+
import { readdirSync as readdirSync3, readFileSync as readFileSync6 } from "node:fs";
|
|
9372
|
+
import { join as join4 } from "node:path";
|
|
9250
9373
|
|
|
9251
9374
|
// node_modules/yaml/dist/index.js
|
|
9252
9375
|
var composer = require_composer();
|
|
@@ -9301,7 +9424,7 @@ import {
|
|
|
9301
9424
|
existsSync as existsSync2,
|
|
9302
9425
|
mkdirSync as mkdirSync2,
|
|
9303
9426
|
readdirSync as readdirSync2,
|
|
9304
|
-
readFileSync as
|
|
9427
|
+
readFileSync as readFileSync5,
|
|
9305
9428
|
renameSync as renameSync2,
|
|
9306
9429
|
rmSync,
|
|
9307
9430
|
statSync as statSync2,
|
|
@@ -9312,7 +9435,7 @@ var MANIFEST = ".shipped.json";
|
|
|
9312
9435
|
var sha256 = (data) => createHash("sha256").update(data).digest("hex");
|
|
9313
9436
|
function readManifest(home) {
|
|
9314
9437
|
try {
|
|
9315
|
-
const parsed = JSON.parse(
|
|
9438
|
+
const parsed = JSON.parse(readFileSync5(`${home}/${MANIFEST}`, "utf-8"));
|
|
9316
9439
|
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed))
|
|
9317
9440
|
return;
|
|
9318
9441
|
return parsed;
|
|
@@ -9335,7 +9458,7 @@ function writeManifest(home, manifest) {
|
|
|
9335
9458
|
}
|
|
9336
9459
|
function backupPath(home, rel, current) {
|
|
9337
9460
|
const bak = `${rel}.bak`;
|
|
9338
|
-
if (!existsSync2(`${home}/${bak}`) ||
|
|
9461
|
+
if (!existsSync2(`${home}/${bak}`) || readFileSync5(`${home}/${bak}`).equals(current))
|
|
9339
9462
|
return bak;
|
|
9340
9463
|
for (let n = 1;; n++) {
|
|
9341
9464
|
if (!existsSync2(`${home}/${bak}.${n}`))
|
|
@@ -9407,7 +9530,7 @@ function copyShipped(src, home) {
|
|
|
9407
9530
|
for (const name of names) {
|
|
9408
9531
|
const rel = `${dir}/${name}`;
|
|
9409
9532
|
const dst = `${home}/${rel}`;
|
|
9410
|
-
const shipped =
|
|
9533
|
+
const shipped = readFileSync5(`${src}/${rel}`);
|
|
9411
9534
|
const old = previous?.[rel];
|
|
9412
9535
|
const sibling = `${dir}/${baseOf(name)}.default.md`;
|
|
9413
9536
|
let removeSibling = true;
|
|
@@ -9415,7 +9538,7 @@ function copyShipped(src, home) {
|
|
|
9415
9538
|
if (!existsSync2(dst)) {
|
|
9416
9539
|
writeAtomic(dst, shipped);
|
|
9417
9540
|
} else {
|
|
9418
|
-
const current =
|
|
9541
|
+
const current = readFileSync5(dst);
|
|
9419
9542
|
if (!current.equals(shipped)) {
|
|
9420
9543
|
if (typeof old === "string" && sha256(current) === old) {
|
|
9421
9544
|
writeAtomic(dst, shipped);
|
|
@@ -9452,7 +9575,7 @@ function copyShipped(src, home) {
|
|
|
9452
9575
|
const path2 = `${home}/${rel}`;
|
|
9453
9576
|
if (!existsSync2(path2))
|
|
9454
9577
|
continue;
|
|
9455
|
-
if (sha256(
|
|
9578
|
+
if (sha256(readFileSync5(path2)) === hash) {
|
|
9456
9579
|
rmSync(path2);
|
|
9457
9580
|
process.stdout.write(`Removed ${rel}: theway no longer ships it
|
|
9458
9581
|
`);
|
|
@@ -9472,15 +9595,29 @@ function copyShipped(src, home) {
|
|
|
9472
9595
|
}
|
|
9473
9596
|
writeManifest(home, manifest);
|
|
9474
9597
|
}
|
|
9475
|
-
function
|
|
9598
|
+
function enableStandards(text, enabled) {
|
|
9599
|
+
const lines = text.split(`
|
|
9600
|
+
`);
|
|
9601
|
+
for (let i = 0;i < lines.length - 1; i++) {
|
|
9602
|
+
if (lines[i + 1] !== " enabled: false")
|
|
9603
|
+
continue;
|
|
9604
|
+
if (enabled.some((key) => lines[i] === ` ${key}:`))
|
|
9605
|
+
lines[i + 1] = " enabled: true";
|
|
9606
|
+
}
|
|
9607
|
+
return lines.join(`
|
|
9608
|
+
`);
|
|
9609
|
+
}
|
|
9610
|
+
function init(src, home, enabled = []) {
|
|
9476
9611
|
try {
|
|
9477
9612
|
mkdirSync2(home, { recursive: true });
|
|
9478
9613
|
copyFileSync(`${src}/config.yaml`, `${home}/config.default.yaml`);
|
|
9479
9614
|
if (existsSync2(`${home}/config.yaml`)) {
|
|
9480
9615
|
process.stdout.write(`Kept existing config.yaml (shipped defaults: config.default.yaml)
|
|
9481
9616
|
`);
|
|
9482
|
-
} else {
|
|
9617
|
+
} else if (enabled.length === 0) {
|
|
9483
9618
|
copyFileSync(`${src}/config.yaml`, `${home}/config.yaml`);
|
|
9619
|
+
} else {
|
|
9620
|
+
writeFileSync(`${home}/config.yaml`, enableStandards(readFileSync5(`${src}/config.yaml`, "utf-8"), enabled));
|
|
9484
9621
|
}
|
|
9485
9622
|
migrateDataStandards(src, home);
|
|
9486
9623
|
copyShipped(src, home);
|
|
@@ -9499,7 +9636,7 @@ var dict = () => Object.create(null);
|
|
|
9499
9636
|
var bool = (d) => ({ rule: "boolean", default: d });
|
|
9500
9637
|
var model = (d) => ({ rule: "model", default: d });
|
|
9501
9638
|
var OPT_IN = ["core-principles.md", "sre.md", "web-development.md", "quality.md"];
|
|
9502
|
-
var CORE = ["interaction.md", "develop.md", "tamm-framework.md"];
|
|
9639
|
+
var CORE = ["interaction.md", "develop.md", "tamm-framework.md", "spec-review.md", "spec-investigation.md"];
|
|
9503
9640
|
var SHARED = new Set(["data", "templates", "standards"]);
|
|
9504
9641
|
var keyOf = (name) => name.slice(0, -".md".length).replaceAll("-", "_");
|
|
9505
9642
|
var OPT_IN_KEYS = OPT_IN.map(keyOf);
|
|
@@ -9511,11 +9648,11 @@ function mdFiles(dir) {
|
|
|
9511
9648
|
} catch {
|
|
9512
9649
|
return [];
|
|
9513
9650
|
}
|
|
9514
|
-
return names.filter((n) => n.endsWith(".md") && isFile(
|
|
9651
|
+
return names.filter((n) => n.endsWith(".md") && isFile(join4(dir, n))).sort();
|
|
9515
9652
|
}
|
|
9516
9653
|
function standardsOf(home, project) {
|
|
9517
|
-
const globalDir =
|
|
9518
|
-
const projectDir =
|
|
9654
|
+
const globalDir = join4(home, "standards");
|
|
9655
|
+
const projectDir = join4(home, project, "standards");
|
|
9519
9656
|
const projectNames = SHARED.has(project) ? [] : mdFiles(projectDir);
|
|
9520
9657
|
const shipped = readManifest(home) ?? {};
|
|
9521
9658
|
const out = [];
|
|
@@ -9525,10 +9662,10 @@ function standardsOf(home, project) {
|
|
|
9525
9662
|
const optIn = OPT_IN.includes(name);
|
|
9526
9663
|
if (!optIn && ((`standards/${name}` in shipped) || name.endsWith(".default.md")))
|
|
9527
9664
|
continue;
|
|
9528
|
-
out.push({ path:
|
|
9665
|
+
out.push({ path: join4(globalDir, name), key: keyOf(name), optIn });
|
|
9529
9666
|
}
|
|
9530
9667
|
for (const name of projectNames)
|
|
9531
|
-
out.push({ path:
|
|
9668
|
+
out.push({ path: join4(projectDir, name), key: keyOf(name), optIn: false });
|
|
9532
9669
|
return out;
|
|
9533
9670
|
}
|
|
9534
9671
|
function standardsSchema(standards) {
|
|
@@ -9610,7 +9747,7 @@ function apply(file, schema, layer, into, prefix, warn) {
|
|
|
9610
9747
|
function load(home, file) {
|
|
9611
9748
|
let text;
|
|
9612
9749
|
try {
|
|
9613
|
-
text =
|
|
9750
|
+
text = readFileSync6(join4(home, file), "utf-8");
|
|
9614
9751
|
} catch {
|
|
9615
9752
|
return { error: `theway: ${file}: cannot be read` };
|
|
9616
9753
|
}
|
|
@@ -9624,10 +9761,10 @@ function load(home, file) {
|
|
|
9624
9761
|
}
|
|
9625
9762
|
function effectiveConfig(home, project, loud) {
|
|
9626
9763
|
const files = [];
|
|
9627
|
-
if (isFile(
|
|
9764
|
+
if (isFile(join4(home, "config.yaml")))
|
|
9628
9765
|
files.push("config.yaml");
|
|
9629
|
-
if (isFile(
|
|
9630
|
-
files.push(
|
|
9766
|
+
if (isFile(join4(home, project, "config.yaml")))
|
|
9767
|
+
files.push(join4(project, "config.yaml"));
|
|
9631
9768
|
const roots = [];
|
|
9632
9769
|
for (const file of files) {
|
|
9633
9770
|
const loaded = load(home, file);
|
|
@@ -9653,27 +9790,35 @@ function enabled(config, key) {
|
|
|
9653
9790
|
const all = config.standards;
|
|
9654
9791
|
return !Object.hasOwn(all, key) || all[key].enabled === true;
|
|
9655
9792
|
}
|
|
9656
|
-
function
|
|
9657
|
-
if (
|
|
9658
|
-
return 1;
|
|
9659
|
-
const home = thewayHome();
|
|
9660
|
-
if (!isFile(join3(home, "config.yaml"))) {
|
|
9793
|
+
function loadConfig(home, project) {
|
|
9794
|
+
if (!isFile(join4(home, "config.yaml"))) {
|
|
9661
9795
|
process.stderr.write(`theway: config.yaml not found in ${home}; run npx --yes @pixelfactoryio/theway@latest install, then /reload-plugins
|
|
9662
9796
|
`);
|
|
9663
|
-
return
|
|
9797
|
+
return null;
|
|
9664
9798
|
}
|
|
9665
9799
|
const result = effectiveConfig(home, project, true);
|
|
9666
9800
|
if ("error" in result) {
|
|
9667
9801
|
process.stderr.write(`${result.error}
|
|
9668
9802
|
`);
|
|
9669
|
-
return
|
|
9803
|
+
return null;
|
|
9670
9804
|
}
|
|
9671
|
-
|
|
9805
|
+
return result;
|
|
9806
|
+
}
|
|
9807
|
+
function cmdConfig(project) {
|
|
9808
|
+
if (invalidSegments([["project", project]]))
|
|
9809
|
+
return 1;
|
|
9810
|
+
const loaded = loadConfig(thewayHome(), project);
|
|
9811
|
+
if (loaded === null)
|
|
9812
|
+
return 1;
|
|
9813
|
+
process.stdout.write($stringify(loaded.config));
|
|
9672
9814
|
return 0;
|
|
9673
9815
|
}
|
|
9674
9816
|
|
|
9817
|
+
// src/core/context.ts
|
|
9818
|
+
import { join as join5 } from "node:path";
|
|
9819
|
+
|
|
9675
9820
|
// src/core/standards.ts
|
|
9676
|
-
import { readFileSync as
|
|
9821
|
+
import { readFileSync as readFileSync7 } from "node:fs";
|
|
9677
9822
|
var PHASES = ["engineering", "develop", "document"];
|
|
9678
9823
|
var USER_PHASES = ["engineering", "develop"];
|
|
9679
9824
|
var OPT_IN_PHASES = ["engineering", "document"];
|
|
@@ -9702,7 +9847,7 @@ function parseList(first, rest) {
|
|
|
9702
9847
|
function phasesOf(path2) {
|
|
9703
9848
|
let text;
|
|
9704
9849
|
try {
|
|
9705
|
-
text =
|
|
9850
|
+
text = readFileSync7(path2, "utf-8");
|
|
9706
9851
|
} catch {
|
|
9707
9852
|
process.stderr.write(`theway: warning: ${path2}: cannot be read; skipped
|
|
9708
9853
|
`);
|
|
@@ -9727,35 +9872,59 @@ function phasesOf(path2) {
|
|
|
9727
9872
|
}
|
|
9728
9873
|
return phases;
|
|
9729
9874
|
}
|
|
9875
|
+
function checkPhase(phase) {
|
|
9876
|
+
if (isPhase(phase))
|
|
9877
|
+
return true;
|
|
9878
|
+
const shown = phase.replaceAll(`
|
|
9879
|
+
`, "\\n").replaceAll("\r", "\\r");
|
|
9880
|
+
process.stderr.write(`theway: invalid phase '${shown}': must be engineering, develop or document
|
|
9881
|
+
`);
|
|
9882
|
+
return false;
|
|
9883
|
+
}
|
|
9884
|
+
function selectStandards(loaded, phase) {
|
|
9885
|
+
return loaded.standards.filter((s) => enabled(loaded.config, s.key)).filter((s) => s.optIn ? OPT_IN_PHASES.includes(phase) : phase !== "document" && phasesOf(s.path).includes(phase)).map((s) => s.path);
|
|
9886
|
+
}
|
|
9730
9887
|
function cmdStandards(project, phase) {
|
|
9731
9888
|
if (invalidSegments([["project", project]]))
|
|
9732
9889
|
return 1;
|
|
9733
|
-
if (!
|
|
9734
|
-
const shown = phase.replaceAll(`
|
|
9735
|
-
`, "\\n").replaceAll("\r", "\\r");
|
|
9736
|
-
process.stderr.write(`theway: invalid phase '${shown}': must be engineering, develop or document
|
|
9737
|
-
`);
|
|
9890
|
+
if (!checkPhase(phase))
|
|
9738
9891
|
return 1;
|
|
9739
|
-
}
|
|
9740
9892
|
const result = effectiveConfig(thewayHome(), project, false);
|
|
9741
9893
|
if ("error" in result) {
|
|
9742
9894
|
process.stderr.write(`${result.error}
|
|
9743
9895
|
`);
|
|
9744
9896
|
return 1;
|
|
9745
9897
|
}
|
|
9746
|
-
|
|
9747
|
-
|
|
9748
|
-
|
|
9749
|
-
|
|
9750
|
-
|
|
9751
|
-
|
|
9752
|
-
|
|
9753
|
-
|
|
9754
|
-
|
|
9755
|
-
|
|
9898
|
+
process.stdout.write(selectStandards(result, phase).map((p) => `${p}
|
|
9899
|
+
`).join(""));
|
|
9900
|
+
return 0;
|
|
9901
|
+
}
|
|
9902
|
+
|
|
9903
|
+
// src/core/context.ts
|
|
9904
|
+
function cmdContext(project, phase, changeId) {
|
|
9905
|
+
if (invalidSegments([["project", project]]))
|
|
9906
|
+
return 1;
|
|
9907
|
+
if (!checkPhase(phase))
|
|
9908
|
+
return 1;
|
|
9909
|
+
if (invalidSegments([["change id", changeId]]))
|
|
9910
|
+
return 1;
|
|
9911
|
+
const home = thewayHome();
|
|
9912
|
+
const loaded = loadConfig(home, project);
|
|
9913
|
+
if (loaded === null)
|
|
9914
|
+
return 1;
|
|
9915
|
+
const doc = { home };
|
|
9916
|
+
if (changeId !== undefined)
|
|
9917
|
+
doc.change_dir = join5(home, project, "changes", changeId);
|
|
9918
|
+
doc.standards = selectStandards(loaded, phase);
|
|
9919
|
+
doc.config = loaded.config;
|
|
9920
|
+
process.stdout.write($stringify(doc));
|
|
9756
9921
|
return 0;
|
|
9757
9922
|
}
|
|
9758
9923
|
|
|
9924
|
+
// src/core/next-id.ts
|
|
9925
|
+
import { readdirSync as readdirSync4 } from "node:fs";
|
|
9926
|
+
import { join as join6 } from "node:path";
|
|
9927
|
+
|
|
9759
9928
|
// src/core/validate-id.ts
|
|
9760
9929
|
var VERB = /^(add|update|refactor|remove|fix)-/;
|
|
9761
9930
|
var KEBAB = /^(add|update|refactor|remove|fix)-[a-z0-9]+(-[a-z0-9]+)*$/;
|
|
@@ -9814,6 +9983,62 @@ function cmdValidateId(id, series) {
|
|
|
9814
9983
|
return 0;
|
|
9815
9984
|
}
|
|
9816
9985
|
|
|
9986
|
+
// src/core/next-id.ts
|
|
9987
|
+
function dirs(dir) {
|
|
9988
|
+
try {
|
|
9989
|
+
return readdirSync4(dir).filter((n) => isDir(join6(dir, n)));
|
|
9990
|
+
} catch {
|
|
9991
|
+
return [];
|
|
9992
|
+
}
|
|
9993
|
+
}
|
|
9994
|
+
function seriesIdReason(id) {
|
|
9995
|
+
const reason = formatReason(id);
|
|
9996
|
+
if (reason !== "")
|
|
9997
|
+
return reason;
|
|
9998
|
+
const tail = id.slice(id.lastIndexOf("-") + 1);
|
|
9999
|
+
if (/^[0-9]{1,2}$/.test(tail))
|
|
10000
|
+
return `ends in a number (-${tail}); a series id cannot end in a number`;
|
|
10001
|
+
return "";
|
|
10002
|
+
}
|
|
10003
|
+
function cmdNextId(project, seriesId, count) {
|
|
10004
|
+
if (invalidSegments([["project", project]]))
|
|
10005
|
+
return 1;
|
|
10006
|
+
const rest = seriesId.replace(/-[0-9]{2}$/, "");
|
|
10007
|
+
const reason = seriesIdReason(rest);
|
|
10008
|
+
if (reason !== "") {
|
|
10009
|
+
const shown = rest.replaceAll(`
|
|
10010
|
+
`, "\\n").replaceAll("\r", "\\r");
|
|
10011
|
+
process.stderr.write(`invalid change id '${shown}': ${reason}
|
|
10012
|
+
`);
|
|
10013
|
+
return 1;
|
|
10014
|
+
}
|
|
10015
|
+
const changes = join6(thewayHome(), project, "changes");
|
|
10016
|
+
const active = new RegExp(`^${rest}-([0-9]{2})$`);
|
|
10017
|
+
const archived = new RegExp(`^[0-9]{4}-[0-9]{2}-[0-9]{2}-${rest}-([0-9]{2})$`);
|
|
10018
|
+
let max = 0;
|
|
10019
|
+
for (const [dir, pattern] of [
|
|
10020
|
+
[changes, active],
|
|
10021
|
+
[join6(changes, "archive"), archived]
|
|
10022
|
+
]) {
|
|
10023
|
+
for (const name of dirs(dir)) {
|
|
10024
|
+
const m = pattern.exec(name);
|
|
10025
|
+
if (m !== null)
|
|
10026
|
+
max = Math.max(max, Number(m[1]));
|
|
10027
|
+
}
|
|
10028
|
+
}
|
|
10029
|
+
if (max + count > 99) {
|
|
10030
|
+
process.stderr.write(`theway: series ${rest} would go past -99
|
|
10031
|
+
`);
|
|
10032
|
+
return 1;
|
|
10033
|
+
}
|
|
10034
|
+
let out = "";
|
|
10035
|
+
for (let n = max + 1;n <= max + count; n++)
|
|
10036
|
+
out += `${rest}-${String(n).padStart(2, "0")}
|
|
10037
|
+
`;
|
|
10038
|
+
process.stdout.write(out);
|
|
10039
|
+
return 0;
|
|
10040
|
+
}
|
|
10041
|
+
|
|
9817
10042
|
// src/install.ts
|
|
9818
10043
|
import {
|
|
9819
10044
|
accessSync,
|
|
@@ -9824,7 +10049,7 @@ import {
|
|
|
9824
10049
|
existsSync as existsSync3,
|
|
9825
10050
|
lstatSync,
|
|
9826
10051
|
mkdirSync as mkdirSync3,
|
|
9827
|
-
readFileSync as
|
|
10052
|
+
readFileSync as readFileSync8,
|
|
9828
10053
|
readlinkSync,
|
|
9829
10054
|
realpathSync,
|
|
9830
10055
|
renameSync as renameSync3,
|
|
@@ -9834,20 +10059,1427 @@ import {
|
|
|
9834
10059
|
writeFileSync as writeFileSync2
|
|
9835
10060
|
} from "node:fs";
|
|
9836
10061
|
import { homedir as homedir2 } from "node:os";
|
|
9837
|
-
import { delimiter, dirname, join as
|
|
10062
|
+
import { delimiter, dirname, isAbsolute, join as join7, resolve as resolve3, sep } from "node:path";
|
|
9838
10063
|
import { fileURLToPath } from "node:url";
|
|
10064
|
+
|
|
10065
|
+
// node_modules/@clack/core/dist/index.mjs
|
|
10066
|
+
import { styleText } from "node:util";
|
|
10067
|
+
import { stdout, stdin } from "node:process";
|
|
10068
|
+
import l__default from "node:readline";
|
|
10069
|
+
|
|
10070
|
+
// node_modules/fast-string-truncated-width/dist/utils.js
|
|
10071
|
+
var getCodePointsLength = (() => {
|
|
10072
|
+
const SURROGATE_PAIR_RE = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g;
|
|
10073
|
+
return (input) => {
|
|
10074
|
+
let surrogatePairsNr = 0;
|
|
10075
|
+
SURROGATE_PAIR_RE.lastIndex = 0;
|
|
10076
|
+
while (SURROGATE_PAIR_RE.test(input)) {
|
|
10077
|
+
surrogatePairsNr += 1;
|
|
10078
|
+
}
|
|
10079
|
+
return input.length - surrogatePairsNr;
|
|
10080
|
+
};
|
|
10081
|
+
})();
|
|
10082
|
+
var isFullWidth = (x) => {
|
|
10083
|
+
return x === 12288 || x >= 65281 && x <= 65376 || x >= 65504 && x <= 65510;
|
|
10084
|
+
};
|
|
10085
|
+
var isWideNotCJKTNotEmoji = (x) => {
|
|
10086
|
+
return x === 8987 || x === 9001 || x >= 12272 && x <= 12287 || x >= 12289 && x <= 12350 || x >= 12441 && x <= 12543 || x >= 12549 && x <= 12591 || x >= 12593 && x <= 12686 || x >= 12688 && x <= 12771 || x >= 12783 && x <= 12830 || x >= 12832 && x <= 12871 || x >= 12880 && x <= 19903 || x >= 65040 && x <= 65049 || x >= 65072 && x <= 65106 || x >= 65108 && x <= 65126 || x >= 65128 && x <= 65131 || x >= 127488 && x <= 127490 || x >= 127504 && x <= 127547 || x >= 127552 && x <= 127560 || x >= 131072 && x <= 196605 || x >= 196608 && x <= 262141;
|
|
10087
|
+
};
|
|
10088
|
+
|
|
10089
|
+
// node_modules/fast-string-truncated-width/dist/index.js
|
|
10090
|
+
var ANSI_RE = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y;
|
|
10091
|
+
var CONTROL_RE = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y;
|
|
10092
|
+
var CJKT_WIDE_RE = /(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/yu;
|
|
10093
|
+
var TAB_RE = /\t{1,1000}/y;
|
|
10094
|
+
var EMOJI_RE = /[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/yu;
|
|
10095
|
+
var LATIN_RE = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y;
|
|
10096
|
+
var MODIFIER_RE = /\p{M}+/gu;
|
|
10097
|
+
var NO_TRUNCATION = { limit: Infinity, ellipsis: "" };
|
|
10098
|
+
var getStringTruncatedWidth = (input, truncationOptions = {}, widthOptions = {}) => {
|
|
10099
|
+
const LIMIT = truncationOptions.limit ?? Infinity;
|
|
10100
|
+
const ELLIPSIS = truncationOptions.ellipsis ?? "";
|
|
10101
|
+
const ELLIPSIS_WIDTH = truncationOptions?.ellipsisWidth ?? (ELLIPSIS ? getStringTruncatedWidth(ELLIPSIS, NO_TRUNCATION, widthOptions).width : 0);
|
|
10102
|
+
const ANSI_WIDTH = 0;
|
|
10103
|
+
const CONTROL_WIDTH = widthOptions.controlWidth ?? 0;
|
|
10104
|
+
const TAB_WIDTH = widthOptions.tabWidth ?? 8;
|
|
10105
|
+
const EMOJI_WIDTH = widthOptions.emojiWidth ?? 2;
|
|
10106
|
+
const FULL_WIDTH_WIDTH = 2;
|
|
10107
|
+
const REGULAR_WIDTH = widthOptions.regularWidth ?? 1;
|
|
10108
|
+
const WIDE_WIDTH = widthOptions.wideWidth ?? FULL_WIDTH_WIDTH;
|
|
10109
|
+
const PARSE_BLOCKS = [
|
|
10110
|
+
[LATIN_RE, REGULAR_WIDTH],
|
|
10111
|
+
[ANSI_RE, ANSI_WIDTH],
|
|
10112
|
+
[CONTROL_RE, CONTROL_WIDTH],
|
|
10113
|
+
[TAB_RE, TAB_WIDTH],
|
|
10114
|
+
[EMOJI_RE, EMOJI_WIDTH],
|
|
10115
|
+
[CJKT_WIDE_RE, WIDE_WIDTH]
|
|
10116
|
+
];
|
|
10117
|
+
let indexPrev = 0;
|
|
10118
|
+
let index = 0;
|
|
10119
|
+
let length = input.length;
|
|
10120
|
+
let lengthExtra = 0;
|
|
10121
|
+
let truncationEnabled = false;
|
|
10122
|
+
let truncationIndex = length;
|
|
10123
|
+
let truncationLimit = Math.max(0, LIMIT - ELLIPSIS_WIDTH);
|
|
10124
|
+
let unmatchedStart = 0;
|
|
10125
|
+
let unmatchedEnd = 0;
|
|
10126
|
+
let width = 0;
|
|
10127
|
+
let widthExtra = 0;
|
|
10128
|
+
outer:
|
|
10129
|
+
while (true) {
|
|
10130
|
+
if (unmatchedEnd > unmatchedStart || index >= length && index > indexPrev) {
|
|
10131
|
+
const unmatched = input.slice(unmatchedStart, unmatchedEnd) || input.slice(indexPrev, index);
|
|
10132
|
+
lengthExtra = 0;
|
|
10133
|
+
for (const char of unmatched.replaceAll(MODIFIER_RE, "")) {
|
|
10134
|
+
const codePoint = char.codePointAt(0) || 0;
|
|
10135
|
+
if (isFullWidth(codePoint)) {
|
|
10136
|
+
widthExtra = FULL_WIDTH_WIDTH;
|
|
10137
|
+
} else if (isWideNotCJKTNotEmoji(codePoint)) {
|
|
10138
|
+
widthExtra = WIDE_WIDTH;
|
|
10139
|
+
} else {
|
|
10140
|
+
widthExtra = REGULAR_WIDTH;
|
|
10141
|
+
}
|
|
10142
|
+
if (width + widthExtra > truncationLimit) {
|
|
10143
|
+
truncationIndex = Math.min(truncationIndex, Math.max(unmatchedStart, indexPrev) + lengthExtra);
|
|
10144
|
+
}
|
|
10145
|
+
if (width + widthExtra > LIMIT) {
|
|
10146
|
+
truncationEnabled = true;
|
|
10147
|
+
break outer;
|
|
10148
|
+
}
|
|
10149
|
+
lengthExtra += char.length;
|
|
10150
|
+
width += widthExtra;
|
|
10151
|
+
}
|
|
10152
|
+
unmatchedStart = unmatchedEnd = 0;
|
|
10153
|
+
}
|
|
10154
|
+
if (index >= length) {
|
|
10155
|
+
break outer;
|
|
10156
|
+
}
|
|
10157
|
+
for (let i = 0, l = PARSE_BLOCKS.length;i < l; i++) {
|
|
10158
|
+
const [BLOCK_RE, BLOCK_WIDTH] = PARSE_BLOCKS[i];
|
|
10159
|
+
BLOCK_RE.lastIndex = index;
|
|
10160
|
+
if (BLOCK_RE.test(input)) {
|
|
10161
|
+
lengthExtra = BLOCK_RE === CJKT_WIDE_RE ? getCodePointsLength(input.slice(index, BLOCK_RE.lastIndex)) : BLOCK_RE === EMOJI_RE ? 1 : BLOCK_RE.lastIndex - index;
|
|
10162
|
+
widthExtra = lengthExtra * BLOCK_WIDTH;
|
|
10163
|
+
if (width + widthExtra > truncationLimit) {
|
|
10164
|
+
truncationIndex = Math.min(truncationIndex, index + Math.floor((truncationLimit - width) / BLOCK_WIDTH));
|
|
10165
|
+
}
|
|
10166
|
+
if (width + widthExtra > LIMIT) {
|
|
10167
|
+
truncationEnabled = true;
|
|
10168
|
+
break outer;
|
|
10169
|
+
}
|
|
10170
|
+
width += widthExtra;
|
|
10171
|
+
unmatchedStart = indexPrev;
|
|
10172
|
+
unmatchedEnd = index;
|
|
10173
|
+
index = indexPrev = BLOCK_RE.lastIndex;
|
|
10174
|
+
continue outer;
|
|
10175
|
+
}
|
|
10176
|
+
}
|
|
10177
|
+
index += 1;
|
|
10178
|
+
}
|
|
10179
|
+
return {
|
|
10180
|
+
width: truncationEnabled ? truncationLimit : width,
|
|
10181
|
+
index: truncationEnabled ? truncationIndex : length,
|
|
10182
|
+
truncated: truncationEnabled,
|
|
10183
|
+
ellipsed: truncationEnabled && LIMIT >= ELLIPSIS_WIDTH
|
|
10184
|
+
};
|
|
10185
|
+
};
|
|
10186
|
+
var dist_default = getStringTruncatedWidth;
|
|
10187
|
+
|
|
10188
|
+
// node_modules/fast-string-width/dist/index.js
|
|
10189
|
+
var NO_TRUNCATION2 = {
|
|
10190
|
+
limit: Infinity,
|
|
10191
|
+
ellipsis: "",
|
|
10192
|
+
ellipsisWidth: 0
|
|
10193
|
+
};
|
|
10194
|
+
var fastStringWidth = (input, options = {}) => {
|
|
10195
|
+
return dist_default(input, NO_TRUNCATION2, options).width;
|
|
10196
|
+
};
|
|
10197
|
+
var dist_default2 = fastStringWidth;
|
|
10198
|
+
|
|
10199
|
+
// node_modules/fast-wrap-ansi/lib/main.js
|
|
10200
|
+
var ESC = "\x1B";
|
|
10201
|
+
var CSI = "";
|
|
10202
|
+
var END_CODE = 39;
|
|
10203
|
+
var ANSI_ESCAPE_BELL = "\x07";
|
|
10204
|
+
var ANSI_CSI = "[";
|
|
10205
|
+
var ANSI_OSC = "]";
|
|
10206
|
+
var ANSI_SGR_TERMINATOR = "m";
|
|
10207
|
+
var ANSI_ESCAPE_LINK = `${ANSI_OSC}8;;`;
|
|
10208
|
+
var GROUP_REGEX = new RegExp(`(?:\\${ANSI_CSI}(?<code>\\d+)m|\\${ANSI_ESCAPE_LINK}(?<uri>.*)${ANSI_ESCAPE_BELL})`, "y");
|
|
10209
|
+
var getClosingCode = (openingCode) => {
|
|
10210
|
+
if (openingCode >= 30 && openingCode <= 37)
|
|
10211
|
+
return 39;
|
|
10212
|
+
if (openingCode >= 90 && openingCode <= 97)
|
|
10213
|
+
return 39;
|
|
10214
|
+
if (openingCode >= 40 && openingCode <= 47)
|
|
10215
|
+
return 49;
|
|
10216
|
+
if (openingCode >= 100 && openingCode <= 107)
|
|
10217
|
+
return 49;
|
|
10218
|
+
if (openingCode === 1 || openingCode === 2)
|
|
10219
|
+
return 22;
|
|
10220
|
+
if (openingCode === 3)
|
|
10221
|
+
return 23;
|
|
10222
|
+
if (openingCode === 4)
|
|
10223
|
+
return 24;
|
|
10224
|
+
if (openingCode === 7)
|
|
10225
|
+
return 27;
|
|
10226
|
+
if (openingCode === 8)
|
|
10227
|
+
return 28;
|
|
10228
|
+
if (openingCode === 9)
|
|
10229
|
+
return 29;
|
|
10230
|
+
if (openingCode === 0)
|
|
10231
|
+
return 0;
|
|
10232
|
+
return;
|
|
10233
|
+
};
|
|
10234
|
+
var wrapAnsiCode = (code) => `${ESC}${ANSI_CSI}${code}${ANSI_SGR_TERMINATOR}`;
|
|
10235
|
+
var wrapAnsiHyperlink = (url) => `${ESC}${ANSI_ESCAPE_LINK}${url}${ANSI_ESCAPE_BELL}`;
|
|
10236
|
+
var wrapWord = (rows, word, columns) => {
|
|
10237
|
+
const characters = word[Symbol.iterator]();
|
|
10238
|
+
let isInsideEscape = false;
|
|
10239
|
+
let isInsideLinkEscape = false;
|
|
10240
|
+
let lastRow = rows.at(-1);
|
|
10241
|
+
let visible = lastRow === undefined ? 0 : dist_default2(lastRow);
|
|
10242
|
+
let currentCharacter = characters.next();
|
|
10243
|
+
let nextCharacter = characters.next();
|
|
10244
|
+
let rawCharacterIndex = 0;
|
|
10245
|
+
while (!currentCharacter.done) {
|
|
10246
|
+
const character = currentCharacter.value;
|
|
10247
|
+
const characterLength = dist_default2(character);
|
|
10248
|
+
if (visible + characterLength <= columns) {
|
|
10249
|
+
rows[rows.length - 1] += character;
|
|
10250
|
+
} else {
|
|
10251
|
+
rows.push(character);
|
|
10252
|
+
visible = 0;
|
|
10253
|
+
}
|
|
10254
|
+
if (character === ESC || character === CSI) {
|
|
10255
|
+
isInsideEscape = true;
|
|
10256
|
+
isInsideLinkEscape = word.startsWith(ANSI_ESCAPE_LINK, rawCharacterIndex + 1);
|
|
10257
|
+
}
|
|
10258
|
+
if (isInsideEscape) {
|
|
10259
|
+
if (isInsideLinkEscape) {
|
|
10260
|
+
if (character === ANSI_ESCAPE_BELL) {
|
|
10261
|
+
isInsideEscape = false;
|
|
10262
|
+
isInsideLinkEscape = false;
|
|
10263
|
+
}
|
|
10264
|
+
} else if (character === ANSI_SGR_TERMINATOR) {
|
|
10265
|
+
isInsideEscape = false;
|
|
10266
|
+
}
|
|
10267
|
+
} else {
|
|
10268
|
+
visible += characterLength;
|
|
10269
|
+
if (visible === columns && !nextCharacter.done) {
|
|
10270
|
+
rows.push("");
|
|
10271
|
+
visible = 0;
|
|
10272
|
+
}
|
|
10273
|
+
}
|
|
10274
|
+
currentCharacter = nextCharacter;
|
|
10275
|
+
nextCharacter = characters.next();
|
|
10276
|
+
rawCharacterIndex += character.length;
|
|
10277
|
+
}
|
|
10278
|
+
lastRow = rows.at(-1);
|
|
10279
|
+
if (!visible && lastRow !== undefined && lastRow.length && rows.length > 1) {
|
|
10280
|
+
rows[rows.length - 2] += rows.pop();
|
|
10281
|
+
}
|
|
10282
|
+
};
|
|
10283
|
+
var stringVisibleTrimSpacesRight = (string) => {
|
|
10284
|
+
const words = string.split(" ");
|
|
10285
|
+
let last2 = words.length;
|
|
10286
|
+
while (last2) {
|
|
10287
|
+
if (dist_default2(words[last2 - 1])) {
|
|
10288
|
+
break;
|
|
10289
|
+
}
|
|
10290
|
+
last2--;
|
|
10291
|
+
}
|
|
10292
|
+
if (last2 === words.length) {
|
|
10293
|
+
return string;
|
|
10294
|
+
}
|
|
10295
|
+
return words.slice(0, last2).join(" ") + words.slice(last2).join("");
|
|
10296
|
+
};
|
|
10297
|
+
var exec = (string, columns, options = {}) => {
|
|
10298
|
+
if (options.trim !== false && string.trim() === "") {
|
|
10299
|
+
return "";
|
|
10300
|
+
}
|
|
10301
|
+
let returnValue = "";
|
|
10302
|
+
let escapeCode;
|
|
10303
|
+
let escapeUrl;
|
|
10304
|
+
const words = string.split(" ");
|
|
10305
|
+
let rows = [""];
|
|
10306
|
+
let rowLength = 0;
|
|
10307
|
+
for (let index = 0;index < words.length; index++) {
|
|
10308
|
+
const word = words[index];
|
|
10309
|
+
if (options.trim !== false) {
|
|
10310
|
+
const row = rows.at(-1) ?? "";
|
|
10311
|
+
const trimmed = row.trimStart();
|
|
10312
|
+
if (row.length !== trimmed.length) {
|
|
10313
|
+
rows[rows.length - 1] = trimmed;
|
|
10314
|
+
rowLength = dist_default2(trimmed);
|
|
10315
|
+
}
|
|
10316
|
+
}
|
|
10317
|
+
if (index !== 0) {
|
|
10318
|
+
if (rowLength >= columns && (options.wordWrap === false || options.trim === false)) {
|
|
10319
|
+
rows.push("");
|
|
10320
|
+
rowLength = 0;
|
|
10321
|
+
}
|
|
10322
|
+
if (rowLength || options.trim === false) {
|
|
10323
|
+
rows[rows.length - 1] += " ";
|
|
10324
|
+
rowLength++;
|
|
10325
|
+
}
|
|
10326
|
+
}
|
|
10327
|
+
const wordLength = dist_default2(word);
|
|
10328
|
+
if (options.hard && wordLength > columns) {
|
|
10329
|
+
const remainingColumns = columns - rowLength;
|
|
10330
|
+
const breaksStartingThisLine = 1 + Math.floor((wordLength - remainingColumns - 1) / columns);
|
|
10331
|
+
const breaksStartingNextLine = Math.floor((wordLength - 1) / columns);
|
|
10332
|
+
if (breaksStartingNextLine < breaksStartingThisLine) {
|
|
10333
|
+
rows.push("");
|
|
10334
|
+
}
|
|
10335
|
+
wrapWord(rows, word, columns);
|
|
10336
|
+
rowLength = dist_default2(rows.at(-1) ?? "");
|
|
10337
|
+
continue;
|
|
10338
|
+
}
|
|
10339
|
+
if (rowLength + wordLength > columns && rowLength && wordLength) {
|
|
10340
|
+
if (options.wordWrap === false && rowLength < columns) {
|
|
10341
|
+
wrapWord(rows, word, columns);
|
|
10342
|
+
rowLength = dist_default2(rows.at(-1) ?? "");
|
|
10343
|
+
continue;
|
|
10344
|
+
}
|
|
10345
|
+
rows.push("");
|
|
10346
|
+
rowLength = 0;
|
|
10347
|
+
}
|
|
10348
|
+
if (rowLength + wordLength > columns && options.wordWrap === false) {
|
|
10349
|
+
wrapWord(rows, word, columns);
|
|
10350
|
+
rowLength = dist_default2(rows.at(-1) ?? "");
|
|
10351
|
+
continue;
|
|
10352
|
+
}
|
|
10353
|
+
rows[rows.length - 1] += word;
|
|
10354
|
+
rowLength += wordLength;
|
|
10355
|
+
}
|
|
10356
|
+
if (options.trim !== false) {
|
|
10357
|
+
rows = rows.map((row) => stringVisibleTrimSpacesRight(row));
|
|
10358
|
+
}
|
|
10359
|
+
const preString = rows.join(`
|
|
10360
|
+
`);
|
|
10361
|
+
let inSurrogate = false;
|
|
10362
|
+
for (let i = 0;i < preString.length; i++) {
|
|
10363
|
+
const character = preString[i];
|
|
10364
|
+
returnValue += character;
|
|
10365
|
+
if (!inSurrogate) {
|
|
10366
|
+
inSurrogate = character >= "\uD800" && character <= "\uDBFF";
|
|
10367
|
+
if (inSurrogate) {
|
|
10368
|
+
continue;
|
|
10369
|
+
}
|
|
10370
|
+
} else {
|
|
10371
|
+
inSurrogate = false;
|
|
10372
|
+
}
|
|
10373
|
+
if (character === ESC || character === CSI) {
|
|
10374
|
+
GROUP_REGEX.lastIndex = i + 1;
|
|
10375
|
+
const groupsResult = GROUP_REGEX.exec(preString);
|
|
10376
|
+
const groups = groupsResult?.groups;
|
|
10377
|
+
if (groups?.code !== undefined) {
|
|
10378
|
+
const code = Number.parseFloat(groups.code);
|
|
10379
|
+
escapeCode = code === END_CODE ? undefined : code;
|
|
10380
|
+
} else if (groups?.uri !== undefined) {
|
|
10381
|
+
escapeUrl = groups.uri.length === 0 ? undefined : groups.uri;
|
|
10382
|
+
}
|
|
10383
|
+
}
|
|
10384
|
+
if (preString[i + 1] === `
|
|
10385
|
+
`) {
|
|
10386
|
+
if (escapeUrl) {
|
|
10387
|
+
returnValue += wrapAnsiHyperlink("");
|
|
10388
|
+
}
|
|
10389
|
+
const closingCode = escapeCode ? getClosingCode(escapeCode) : undefined;
|
|
10390
|
+
if (escapeCode && closingCode) {
|
|
10391
|
+
returnValue += wrapAnsiCode(closingCode);
|
|
10392
|
+
}
|
|
10393
|
+
} else if (character === `
|
|
10394
|
+
`) {
|
|
10395
|
+
if (escapeCode && getClosingCode(escapeCode)) {
|
|
10396
|
+
returnValue += wrapAnsiCode(escapeCode);
|
|
10397
|
+
}
|
|
10398
|
+
if (escapeUrl) {
|
|
10399
|
+
returnValue += wrapAnsiHyperlink(escapeUrl);
|
|
10400
|
+
}
|
|
10401
|
+
}
|
|
10402
|
+
}
|
|
10403
|
+
return returnValue;
|
|
10404
|
+
};
|
|
10405
|
+
var CRLF_OR_LF = /\r?\n/;
|
|
10406
|
+
function wrapAnsi(string, columns, options) {
|
|
10407
|
+
return String(string).normalize().split(CRLF_OR_LF).map((line) => exec(line, columns, options)).join(`
|
|
10408
|
+
`);
|
|
10409
|
+
}
|
|
10410
|
+
|
|
10411
|
+
// node_modules/@clack/core/dist/index.mjs
|
|
10412
|
+
var import_sisteransi = __toESM(require_src(), 1);
|
|
10413
|
+
function findCursor(s, o, l) {
|
|
10414
|
+
if (!l.some((r) => !r.disabled))
|
|
10415
|
+
return s;
|
|
10416
|
+
const t = s + o, n = Math.max(l.length - 1, 0), e = t < 0 ? n : t > n ? 0 : t;
|
|
10417
|
+
return l[e]?.disabled ? findCursor(e, o < 0 ? -1 : 1, l) : e;
|
|
10418
|
+
}
|
|
10419
|
+
function findTextCursor(s, o, l, i) {
|
|
10420
|
+
const t = i.split(`
|
|
10421
|
+
`);
|
|
10422
|
+
let n = 0, e = s;
|
|
10423
|
+
for (const r of t) {
|
|
10424
|
+
if (e <= r.length)
|
|
10425
|
+
break;
|
|
10426
|
+
e -= r.length + 1, n++;
|
|
10427
|
+
}
|
|
10428
|
+
for (n = Math.max(0, Math.min(t.length - 1, n + l)), e = Math.min(e, t[n].length) + o;e < 0 && n > 0; )
|
|
10429
|
+
n--, e += t[n].length + 1;
|
|
10430
|
+
for (;e > t[n].length && n < t.length - 1; )
|
|
10431
|
+
e -= t[n].length + 1, n++;
|
|
10432
|
+
e = Math.max(0, Math.min(t[n].length, e));
|
|
10433
|
+
let h = 0;
|
|
10434
|
+
for (let r = 0;r < n; r++)
|
|
10435
|
+
h += t[r].length + 1;
|
|
10436
|
+
return h + e;
|
|
10437
|
+
}
|
|
10438
|
+
var a$1 = ["up", "down", "left", "right", "space", "enter", "cancel"];
|
|
10439
|
+
var t = [
|
|
10440
|
+
"January",
|
|
10441
|
+
"February",
|
|
10442
|
+
"March",
|
|
10443
|
+
"April",
|
|
10444
|
+
"May",
|
|
10445
|
+
"June",
|
|
10446
|
+
"July",
|
|
10447
|
+
"August",
|
|
10448
|
+
"September",
|
|
10449
|
+
"October",
|
|
10450
|
+
"November",
|
|
10451
|
+
"December"
|
|
10452
|
+
];
|
|
10453
|
+
var settings = {
|
|
10454
|
+
actions: new Set(a$1),
|
|
10455
|
+
aliases: /* @__PURE__ */ new Map([
|
|
10456
|
+
["k", "up"],
|
|
10457
|
+
["j", "down"],
|
|
10458
|
+
["h", "left"],
|
|
10459
|
+
["l", "right"],
|
|
10460
|
+
["\x03", "cancel"],
|
|
10461
|
+
["escape", "cancel"]
|
|
10462
|
+
]),
|
|
10463
|
+
messages: {
|
|
10464
|
+
cancel: "Canceled",
|
|
10465
|
+
error: "Something went wrong"
|
|
10466
|
+
},
|
|
10467
|
+
withGuide: true,
|
|
10468
|
+
accessible: undefined,
|
|
10469
|
+
date: {
|
|
10470
|
+
monthNames: [...t],
|
|
10471
|
+
messages: {
|
|
10472
|
+
required: "Please enter a valid date",
|
|
10473
|
+
invalidMonth: "There are only 12 months in a year",
|
|
10474
|
+
invalidDay: (n, e) => `There are only ${n} days in ${e}`,
|
|
10475
|
+
afterMin: (n) => `Date must be on or after ${n.toISOString().slice(0, 10)}`,
|
|
10476
|
+
beforeMax: (n) => `Date must be on or before ${n.toISOString().slice(0, 10)}`
|
|
10477
|
+
}
|
|
10478
|
+
}
|
|
10479
|
+
};
|
|
10480
|
+
function isAccessible(n) {
|
|
10481
|
+
if (n !== undefined)
|
|
10482
|
+
return n;
|
|
10483
|
+
if (settings.accessible !== undefined)
|
|
10484
|
+
return settings.accessible;
|
|
10485
|
+
const e = process.env.ACCESSIBLE;
|
|
10486
|
+
return e !== undefined && e !== "" && e !== "0" && e !== "false";
|
|
10487
|
+
}
|
|
10488
|
+
function isActionKey(n, e) {
|
|
10489
|
+
if (typeof n == "string")
|
|
10490
|
+
return settings.aliases.get(n) === e;
|
|
10491
|
+
for (const s of n)
|
|
10492
|
+
if (s !== undefined && isActionKey(s, e))
|
|
10493
|
+
return true;
|
|
10494
|
+
return false;
|
|
10495
|
+
}
|
|
10496
|
+
function diffLines(i, s) {
|
|
10497
|
+
if (i === s)
|
|
10498
|
+
return;
|
|
10499
|
+
const e = i.split(`
|
|
10500
|
+
`), t2 = s.split(`
|
|
10501
|
+
`), r = Math.max(e.length, t2.length), f = [];
|
|
10502
|
+
for (let n = 0;n < r; n++)
|
|
10503
|
+
e[n] !== t2[n] && f.push(n);
|
|
10504
|
+
return {
|
|
10505
|
+
lines: f,
|
|
10506
|
+
numLinesBefore: e.length,
|
|
10507
|
+
numLinesAfter: t2.length,
|
|
10508
|
+
numLines: r
|
|
10509
|
+
};
|
|
10510
|
+
}
|
|
10511
|
+
var R = globalThis.process.platform.startsWith("win");
|
|
10512
|
+
var CANCEL_SYMBOL = Symbol("clack:cancel");
|
|
10513
|
+
function isCancel(e) {
|
|
10514
|
+
return e === CANCEL_SYMBOL;
|
|
10515
|
+
}
|
|
10516
|
+
function setRawMode(e, r) {
|
|
10517
|
+
const o = e;
|
|
10518
|
+
o.isTTY && o.setRawMode(r);
|
|
10519
|
+
}
|
|
10520
|
+
var getColumns = (e) => ("columns" in e) && typeof e.columns == "number" ? e.columns : 80;
|
|
10521
|
+
var getRows = (e) => ("rows" in e) && typeof e.rows == "number" ? e.rows : 20;
|
|
10522
|
+
function wrapTextWithPrefix(e, r, o, n = o, s = o, t2) {
|
|
10523
|
+
const f = getColumns(e ?? stdout);
|
|
10524
|
+
return wrapAnsi(r, f - o.length, {
|
|
10525
|
+
hard: true,
|
|
10526
|
+
trim: false
|
|
10527
|
+
}).split(`
|
|
10528
|
+
`).map((c, i, m) => {
|
|
10529
|
+
const d = t2 ? t2(c, i) : c;
|
|
10530
|
+
return i === 0 ? `${n}${d}` : i === m.length - 1 ? `${s}${d}` : `${o}${d}`;
|
|
10531
|
+
}).join(`
|
|
10532
|
+
`);
|
|
10533
|
+
}
|
|
10534
|
+
function runValidation(e, a) {
|
|
10535
|
+
if ("~standard" in e) {
|
|
10536
|
+
const n = e["~standard"].validate(a);
|
|
10537
|
+
return n instanceof Promise ? n.then((r) => r.issues?.at(0)?.message) : n.issues?.at(0)?.message;
|
|
10538
|
+
}
|
|
10539
|
+
return e(a);
|
|
10540
|
+
}
|
|
10541
|
+
|
|
10542
|
+
class y {
|
|
10543
|
+
input;
|
|
10544
|
+
output;
|
|
10545
|
+
_abortSignal;
|
|
10546
|
+
rl;
|
|
10547
|
+
opts;
|
|
10548
|
+
_render;
|
|
10549
|
+
_track = false;
|
|
10550
|
+
_prevFrame = "";
|
|
10551
|
+
_subscribers = /* @__PURE__ */ new Map;
|
|
10552
|
+
_cursor = 0;
|
|
10553
|
+
state = "initial";
|
|
10554
|
+
error = "";
|
|
10555
|
+
value;
|
|
10556
|
+
userInput = "";
|
|
10557
|
+
get accessible() {
|
|
10558
|
+
return isAccessible(this.opts.accessible);
|
|
10559
|
+
}
|
|
10560
|
+
constructor(t2, e = true) {
|
|
10561
|
+
const { input: i = stdin, output: s = stdout, render: r, signal: n, ...o } = t2;
|
|
10562
|
+
this.opts = o, this.onKeypress = this.onKeypress.bind(this), this.close = this.close.bind(this), this.render = this.render.bind(this), this._render = r.bind(this), this._track = e, this._abortSignal = n, this.input = i, this.output = s;
|
|
10563
|
+
}
|
|
10564
|
+
unsubscribe() {
|
|
10565
|
+
this._subscribers.clear();
|
|
10566
|
+
}
|
|
10567
|
+
setSubscriber(t2, e) {
|
|
10568
|
+
const i = this._subscribers.get(t2) ?? [];
|
|
10569
|
+
i.push(e), this._subscribers.set(t2, i);
|
|
10570
|
+
}
|
|
10571
|
+
on(t2, e) {
|
|
10572
|
+
this.setSubscriber(t2, { cb: e });
|
|
10573
|
+
}
|
|
10574
|
+
once(t2, e) {
|
|
10575
|
+
this.setSubscriber(t2, { cb: e, once: true });
|
|
10576
|
+
}
|
|
10577
|
+
emit(t2, ...e) {
|
|
10578
|
+
const i = this._subscribers.get(t2) ?? [], s = [];
|
|
10579
|
+
for (const r of i)
|
|
10580
|
+
r.cb(...e), r.once && s.push(() => i.splice(i.indexOf(r), 1));
|
|
10581
|
+
for (const r of s)
|
|
10582
|
+
r();
|
|
10583
|
+
}
|
|
10584
|
+
prompt() {
|
|
10585
|
+
return new Promise((t2) => {
|
|
10586
|
+
if (this._abortSignal) {
|
|
10587
|
+
if (this._abortSignal.aborted)
|
|
10588
|
+
return this.state = "cancel", this.close(), t2(CANCEL_SYMBOL);
|
|
10589
|
+
this._abortSignal.addEventListener("abort", () => {
|
|
10590
|
+
this.state = "cancel", this.close();
|
|
10591
|
+
}, { once: true });
|
|
10592
|
+
}
|
|
10593
|
+
this.rl = l__default.createInterface({
|
|
10594
|
+
input: this.input,
|
|
10595
|
+
tabSize: 2,
|
|
10596
|
+
prompt: "",
|
|
10597
|
+
escapeCodeTimeout: 50,
|
|
10598
|
+
terminal: true
|
|
10599
|
+
}), this.rl.prompt(), this.opts.initialUserInput !== undefined && this._setUserInput(this.opts.initialUserInput, true), this.input.on("keypress", this.onKeypress), setRawMode(this.input, true), this.output.on("resize", this.render), this.render(), this.once("submit", () => {
|
|
10600
|
+
this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), setRawMode(this.input, false), t2(this.value);
|
|
10601
|
+
}), this.once("cancel", () => {
|
|
10602
|
+
this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), setRawMode(this.input, false), t2(CANCEL_SYMBOL);
|
|
10603
|
+
});
|
|
10604
|
+
});
|
|
10605
|
+
}
|
|
10606
|
+
_isActionKey(t2, e) {
|
|
10607
|
+
return t2 === "\t";
|
|
10608
|
+
}
|
|
10609
|
+
_shouldSubmit(t2, e) {
|
|
10610
|
+
return true;
|
|
10611
|
+
}
|
|
10612
|
+
_setValue(t2) {
|
|
10613
|
+
this.value = t2, this.emit("value", this.value);
|
|
10614
|
+
}
|
|
10615
|
+
_setUserInput(t2, e) {
|
|
10616
|
+
this.userInput = t2 ?? "", this.emit("userInput", this.userInput), e && this._track && this.rl && (this.rl.write(this.userInput), this._cursor = this.rl.cursor);
|
|
10617
|
+
}
|
|
10618
|
+
_clearUserInput() {
|
|
10619
|
+
this.rl?.write(null, { ctrl: true, name: "u" }), this._setUserInput("");
|
|
10620
|
+
}
|
|
10621
|
+
async onKeypress(t2, e) {
|
|
10622
|
+
if (this.state !== "validating") {
|
|
10623
|
+
if (this._track && e.name !== "return" && (e.name && this._isActionKey(t2, e) && this.rl?.write(null, { ctrl: true, name: "h" }), this._cursor = this.rl?.cursor ?? 0, this._setUserInput(this.rl?.line)), this.state === "error" && (this.state = "active"), e?.name && (!this._track && settings.aliases.has(e.name) && this.emit("cursor", settings.aliases.get(e.name)), settings.actions.has(e.name) && this.emit("cursor", e.name)), t2 && (t2.toLowerCase() === "y" || t2.toLowerCase() === "n") && this.emit("confirm", t2.toLowerCase() === "y"), this.emit("key", t2, e), e?.name === "return" && this._shouldSubmit(t2, e)) {
|
|
10624
|
+
if (this.opts.validate) {
|
|
10625
|
+
const i = runValidation(this.opts.validate, this.value);
|
|
10626
|
+
let s;
|
|
10627
|
+
i instanceof Promise ? (this.state = "validating", this.render(), s = await i) : s = i, s && (this.error = s instanceof Error ? s.message : s, this.state = "error", this.rl?.write(this.userInput));
|
|
10628
|
+
}
|
|
10629
|
+
this.state !== "error" && (this.state = "submit");
|
|
10630
|
+
}
|
|
10631
|
+
isActionKey([t2, e?.name, e?.sequence], "cancel") && (this.state = "cancel"), (this.state === "submit" || this.state === "cancel") && this.emit("finalize"), this.render(), (this.state === "submit" || this.state === "cancel") && this.close();
|
|
10632
|
+
}
|
|
10633
|
+
}
|
|
10634
|
+
close() {
|
|
10635
|
+
this.input.unpipe(), this.input.removeListener("keypress", this.onKeypress), this.output.write(`
|
|
10636
|
+
`), setRawMode(this.input, false), this.rl?.close(), this.rl = undefined, this.emit(`${this.state}`, this.value), this.unsubscribe();
|
|
10637
|
+
}
|
|
10638
|
+
restoreCursor() {
|
|
10639
|
+
const t2 = wrapAnsi(this._prevFrame, process.stdout.columns, { hard: true, trim: false }).split(`
|
|
10640
|
+
`).length - 1;
|
|
10641
|
+
this.output.write(import_sisteransi.cursor.move(-999, t2 * -1));
|
|
10642
|
+
}
|
|
10643
|
+
render() {
|
|
10644
|
+
const t2 = wrapAnsi(this._render(this) ?? "", process.stdout.columns, {
|
|
10645
|
+
hard: true,
|
|
10646
|
+
trim: false
|
|
10647
|
+
});
|
|
10648
|
+
if (t2 !== this._prevFrame) {
|
|
10649
|
+
if (this.state === "initial")
|
|
10650
|
+
this.output.write(import_sisteransi.cursor.hide);
|
|
10651
|
+
else {
|
|
10652
|
+
const e = diffLines(this._prevFrame, t2), i = getRows(this.output);
|
|
10653
|
+
if (this.restoreCursor(), e) {
|
|
10654
|
+
const s = Math.max(0, e.numLinesAfter - i), r = Math.max(0, e.numLinesBefore - i);
|
|
10655
|
+
let n = e.lines.find((o) => o >= s);
|
|
10656
|
+
if (n === undefined) {
|
|
10657
|
+
this._prevFrame = t2;
|
|
10658
|
+
return;
|
|
10659
|
+
}
|
|
10660
|
+
if (e.lines.length === 1) {
|
|
10661
|
+
this.output.write(import_sisteransi.cursor.move(0, n - r)), this.output.write(import_sisteransi.erase.lines(1));
|
|
10662
|
+
const o = t2.split(`
|
|
10663
|
+
`);
|
|
10664
|
+
this.output.write(o[n]), this._prevFrame = t2, this.output.write(import_sisteransi.cursor.move(0, o.length - n - 1));
|
|
10665
|
+
return;
|
|
10666
|
+
} else if (e.lines.length > 1) {
|
|
10667
|
+
if (s < r)
|
|
10668
|
+
n = s;
|
|
10669
|
+
else {
|
|
10670
|
+
const h = n - r;
|
|
10671
|
+
h > 0 && this.output.write(import_sisteransi.cursor.move(0, h));
|
|
10672
|
+
}
|
|
10673
|
+
this.output.write(import_sisteransi.erase.down());
|
|
10674
|
+
const f = t2.split(`
|
|
10675
|
+
`).slice(n);
|
|
10676
|
+
this.output.write(f.join(`
|
|
10677
|
+
`)), this._prevFrame = t2;
|
|
10678
|
+
return;
|
|
10679
|
+
}
|
|
10680
|
+
}
|
|
10681
|
+
this.output.write(import_sisteransi.erase.down());
|
|
10682
|
+
}
|
|
10683
|
+
this.output.write(t2), this.state === "initial" && (this.state = "active"), this._prevFrame = t2;
|
|
10684
|
+
}
|
|
10685
|
+
}
|
|
10686
|
+
}
|
|
10687
|
+
function p$1(l, e) {
|
|
10688
|
+
if (l === undefined || e.length === 0)
|
|
10689
|
+
return 0;
|
|
10690
|
+
const i = e.findIndex((s) => s.value === l);
|
|
10691
|
+
return i !== -1 ? i : 0;
|
|
10692
|
+
}
|
|
10693
|
+
function m(l, e) {
|
|
10694
|
+
return (e.label ?? String(e.value)).toLowerCase().includes(l.toLowerCase());
|
|
10695
|
+
}
|
|
10696
|
+
function g(l, e) {
|
|
10697
|
+
if (e)
|
|
10698
|
+
return l ? e : e[0];
|
|
10699
|
+
}
|
|
10700
|
+
var T$1 = class T extends y {
|
|
10701
|
+
filteredOptions;
|
|
10702
|
+
multiple;
|
|
10703
|
+
isNavigating = false;
|
|
10704
|
+
selectedValues = [];
|
|
10705
|
+
focusedValue;
|
|
10706
|
+
#e = 0;
|
|
10707
|
+
#s = "";
|
|
10708
|
+
#t;
|
|
10709
|
+
#i;
|
|
10710
|
+
#n;
|
|
10711
|
+
#l;
|
|
10712
|
+
get cursor() {
|
|
10713
|
+
return this.#e;
|
|
10714
|
+
}
|
|
10715
|
+
get userInputWithCursor() {
|
|
10716
|
+
if (!this.userInput)
|
|
10717
|
+
return styleText(["inverse", "hidden"], "_");
|
|
10718
|
+
if (this._cursor >= this.userInput.length)
|
|
10719
|
+
return `${this.userInput}█`;
|
|
10720
|
+
const e = this.userInput.slice(0, this.cursor), t2 = this.userInput.slice(this.cursor, this.cursor + 1), i = this.userInput.slice(this.cursor + 1);
|
|
10721
|
+
return `${e}${styleText("inverse", t2)}${i}`;
|
|
10722
|
+
}
|
|
10723
|
+
get options() {
|
|
10724
|
+
return typeof this.#i == "function" ? this.#i() : this.#i;
|
|
10725
|
+
}
|
|
10726
|
+
constructor(e) {
|
|
10727
|
+
super(e), this.#i = e.options, this.#n = e.placeholder, this.#l = e.completeOnTab === true;
|
|
10728
|
+
const t2 = this.options;
|
|
10729
|
+
this.filteredOptions = [...t2], this.multiple = e.multiple === true, this.#t = typeof e.options == "function" ? e.filter : e.filter ?? m;
|
|
10730
|
+
let i;
|
|
10731
|
+
if (e.initialValue && Array.isArray(e.initialValue) ? this.multiple ? i = e.initialValue : i = e.initialValue.slice(0, 1) : !this.multiple && this.options.length > 0 && (i = [this.options[0]?.value]), i)
|
|
10732
|
+
for (const s of i) {
|
|
10733
|
+
const n = t2.findIndex((r) => r.value === s);
|
|
10734
|
+
n !== -1 && (this.toggleSelected(s), this.#e = n);
|
|
10735
|
+
}
|
|
10736
|
+
this.focusedValue = this.options[this.#e]?.value, this.on("key", (s, n) => this.#u(s, n)), this.on("userInput", (s) => this.#o(s));
|
|
10737
|
+
}
|
|
10738
|
+
_isActionKey(e, t2) {
|
|
10739
|
+
return e === "\t" || this.multiple && this.isNavigating && t2.name === "space" && e !== undefined && e !== "";
|
|
10740
|
+
}
|
|
10741
|
+
#u(e, t2) {
|
|
10742
|
+
const i = t2.name === "up", s = t2.name === "down", n = t2.name === "return", r = this.userInput === "" || this.userInput === "\t", u = this.#n, d = this.options, c = u !== undefined && u !== "" && d.some((o) => !o.disabled && (this.#t ? this.#t(u, o) : true));
|
|
10743
|
+
if (t2.name === "tab" && r && c) {
|
|
10744
|
+
this.userInput === "\t" && this._clearUserInput(), this._setUserInput(u, true), this.isNavigating = false;
|
|
10745
|
+
return;
|
|
10746
|
+
}
|
|
10747
|
+
if (t2.name === "tab" && this.#l && !this.multiple && this.focusedValue !== undefined) {
|
|
10748
|
+
const o = String(this.focusedValue);
|
|
10749
|
+
this._clearUserInput(), this._setUserInput(o, true), this.isNavigating = false;
|
|
10750
|
+
return;
|
|
10751
|
+
}
|
|
10752
|
+
i || s ? (this.#e = findCursor(this.#e, i ? -1 : 1, this.filteredOptions), this.focusedValue = this.filteredOptions[this.#e]?.value, this.multiple || (this.selectedValues = [this.focusedValue]), this.isNavigating = true) : n ? this.value = g(this.multiple, this.selectedValues) : this.multiple ? this.focusedValue !== undefined && (t2.name === "tab" || this.isNavigating && t2.name === "space") ? this.toggleSelected(this.focusedValue) : this.isNavigating = false : (this.focusedValue && (this.selectedValues = [this.focusedValue]), this.isNavigating = false);
|
|
10753
|
+
}
|
|
10754
|
+
deselectAll() {
|
|
10755
|
+
this.selectedValues = [];
|
|
10756
|
+
}
|
|
10757
|
+
toggleSelected(e) {
|
|
10758
|
+
this.filteredOptions.length !== 0 && (this.multiple ? this.selectedValues.includes(e) ? this.selectedValues = this.selectedValues.filter((t2) => t2 !== e) : this.selectedValues = [...this.selectedValues, e] : this.selectedValues = [e]);
|
|
10759
|
+
}
|
|
10760
|
+
#o(e) {
|
|
10761
|
+
if (e !== this.#s) {
|
|
10762
|
+
this.#s = e;
|
|
10763
|
+
const t2 = this.options;
|
|
10764
|
+
e && this.#t ? this.filteredOptions = t2.filter((n) => this.#t?.(e, n)) : this.filteredOptions = [...t2];
|
|
10765
|
+
const i = p$1(this.focusedValue, this.filteredOptions);
|
|
10766
|
+
this.#e = findCursor(i, 0, this.filteredOptions);
|
|
10767
|
+
const s = this.filteredOptions[this.#e];
|
|
10768
|
+
s && !s.disabled ? this.focusedValue = s.value : this.focusedValue = undefined, this.multiple || (this.focusedValue !== undefined ? this.toggleSelected(this.focusedValue) : this.deselectAll());
|
|
10769
|
+
}
|
|
10770
|
+
}
|
|
10771
|
+
};
|
|
10772
|
+
var _ = {
|
|
10773
|
+
Y: { type: "year", len: 4 },
|
|
10774
|
+
M: { type: "month", len: 2 },
|
|
10775
|
+
D: { type: "day", len: 2 }
|
|
10776
|
+
};
|
|
10777
|
+
function M(r) {
|
|
10778
|
+
return [...r].map((t2) => _[t2]);
|
|
10779
|
+
}
|
|
10780
|
+
function P(r) {
|
|
10781
|
+
const i = new Intl.DateTimeFormat(r, {
|
|
10782
|
+
year: "numeric",
|
|
10783
|
+
month: "2-digit",
|
|
10784
|
+
day: "2-digit"
|
|
10785
|
+
}).formatToParts(new Date(2000, 0, 15)), s = [];
|
|
10786
|
+
let n = "/";
|
|
10787
|
+
for (const e of i)
|
|
10788
|
+
e.type === "literal" ? n = e.value.trim() || e.value : (e.type === "year" || e.type === "month" || e.type === "day") && s.push({ type: e.type, len: e.type === "year" ? 4 : 2 });
|
|
10789
|
+
return { segments: s, separator: n };
|
|
10790
|
+
}
|
|
10791
|
+
function p(r) {
|
|
10792
|
+
return Number.parseInt((r || "0").replace(/_/g, "0"), 10) || 0;
|
|
10793
|
+
}
|
|
10794
|
+
function f(r) {
|
|
10795
|
+
return {
|
|
10796
|
+
year: p(r.year),
|
|
10797
|
+
month: p(r.month),
|
|
10798
|
+
day: p(r.day)
|
|
10799
|
+
};
|
|
10800
|
+
}
|
|
10801
|
+
function c(r, t2) {
|
|
10802
|
+
return new Date(r || 2001, t2 || 1, 0).getDate();
|
|
10803
|
+
}
|
|
10804
|
+
function b(r) {
|
|
10805
|
+
const { year: t2, month: i, day: s } = f(r);
|
|
10806
|
+
if (!t2 || t2 < 0 || t2 > 9999 || !i || i < 1 || i > 12 || !s || s < 1)
|
|
10807
|
+
return;
|
|
10808
|
+
const n = new Date(Date.UTC(t2, i - 1, s));
|
|
10809
|
+
if (!(n.getUTCFullYear() !== t2 || n.getUTCMonth() !== i - 1 || n.getUTCDate() !== s))
|
|
10810
|
+
return { year: t2, month: i, day: s };
|
|
10811
|
+
}
|
|
10812
|
+
function C(r) {
|
|
10813
|
+
const t2 = b(r);
|
|
10814
|
+
return t2 ? new Date(Date.UTC(t2.year, t2.month - 1, t2.day)) : undefined;
|
|
10815
|
+
}
|
|
10816
|
+
function T2(r, t2, i, s) {
|
|
10817
|
+
const n = i ? {
|
|
10818
|
+
year: i.getUTCFullYear(),
|
|
10819
|
+
month: i.getUTCMonth() + 1,
|
|
10820
|
+
day: i.getUTCDate()
|
|
10821
|
+
} : null, e = s ? {
|
|
10822
|
+
year: s.getUTCFullYear(),
|
|
10823
|
+
month: s.getUTCMonth() + 1,
|
|
10824
|
+
day: s.getUTCDate()
|
|
10825
|
+
} : null;
|
|
10826
|
+
return r === "year" ? { min: n?.year ?? 1, max: e?.year ?? 9999 } : r === "month" ? {
|
|
10827
|
+
min: n && t2.year === n.year ? n.month : 1,
|
|
10828
|
+
max: e && t2.year === e.year ? e.month : 12
|
|
10829
|
+
} : {
|
|
10830
|
+
min: n && t2.year === n.year && t2.month === n.month ? n.day : 1,
|
|
10831
|
+
max: e && t2.year === e.year && t2.month === e.month ? e.day : c(t2.year, t2.month)
|
|
10832
|
+
};
|
|
10833
|
+
}
|
|
10834
|
+
|
|
10835
|
+
class U extends y {
|
|
10836
|
+
#i;
|
|
10837
|
+
#o;
|
|
10838
|
+
#t;
|
|
10839
|
+
#h;
|
|
10840
|
+
#u;
|
|
10841
|
+
#e = { segmentIndex: 0, positionInSegment: 0 };
|
|
10842
|
+
#n = true;
|
|
10843
|
+
#s = null;
|
|
10844
|
+
inlineError = "";
|
|
10845
|
+
get segmentCursor() {
|
|
10846
|
+
return { ...this.#e };
|
|
10847
|
+
}
|
|
10848
|
+
get segmentValues() {
|
|
10849
|
+
return { ...this.#t };
|
|
10850
|
+
}
|
|
10851
|
+
get segments() {
|
|
10852
|
+
return this.#i;
|
|
10853
|
+
}
|
|
10854
|
+
get separator() {
|
|
10855
|
+
return this.#o;
|
|
10856
|
+
}
|
|
10857
|
+
get formattedValue() {
|
|
10858
|
+
return this.#l(this.#t);
|
|
10859
|
+
}
|
|
10860
|
+
#l(t2) {
|
|
10861
|
+
return this.#i.map((i) => t2[i.type]).join(this.#o);
|
|
10862
|
+
}
|
|
10863
|
+
#r() {
|
|
10864
|
+
this._setUserInput(this.#l(this.#t)), this._setValue(C(this.#t) ?? undefined);
|
|
10865
|
+
}
|
|
10866
|
+
constructor(t2) {
|
|
10867
|
+
const i = t2.format ? { segments: M(t2.format), separator: t2.separator ?? "/" } : P(t2.locale), s = t2.separator ?? i.separator, n = t2.format ? M(t2.format) : i.segments, e = t2.initialValue ?? t2.defaultValue, m2 = e ? {
|
|
10868
|
+
year: String(e.getUTCFullYear()).padStart(4, "0"),
|
|
10869
|
+
month: String(e.getUTCMonth() + 1).padStart(2, "0"),
|
|
10870
|
+
day: String(e.getUTCDate()).padStart(2, "0")
|
|
10871
|
+
} : { year: "____", month: "__", day: "__" }, o = n.map((a) => m2[a.type]).join(s);
|
|
10872
|
+
super({ ...t2, initialUserInput: o }, false), this.#i = n, this.#o = s, this.#t = m2, this.#h = t2.minDate, this.#u = t2.maxDate, this.#r(), this.on("cursor", (a) => this.#f(a)), this.on("key", (a, u) => this.#y(a, u)), this.on("finalize", () => this.#p(t2));
|
|
10873
|
+
}
|
|
10874
|
+
#a() {
|
|
10875
|
+
const t2 = Math.max(0, Math.min(this.#e.segmentIndex, this.#i.length - 1)), i = this.#i[t2];
|
|
10876
|
+
if (i)
|
|
10877
|
+
return this.#e.positionInSegment = Math.max(0, Math.min(this.#e.positionInSegment, i.len - 1)), { segment: i, index: t2 };
|
|
10878
|
+
}
|
|
10879
|
+
#m(t2) {
|
|
10880
|
+
this.inlineError = "", this.#s = null;
|
|
10881
|
+
const i = this.#a();
|
|
10882
|
+
i && (this.#e.segmentIndex = Math.max(0, Math.min(this.#i.length - 1, i.index + t2)), this.#e.positionInSegment = 0, this.#n = true);
|
|
10883
|
+
}
|
|
10884
|
+
#d(t2) {
|
|
10885
|
+
const i = this.#a();
|
|
10886
|
+
if (!i)
|
|
10887
|
+
return;
|
|
10888
|
+
const { segment: s } = i, n = this.#t[s.type], e = !n || n.replace(/_/g, "") === "", m2 = Number.parseInt((n || "0").replace(/_/g, "0"), 10) || 0, o = T2(s.type, f(this.#t), this.#h, this.#u);
|
|
10889
|
+
let a;
|
|
10890
|
+
e ? a = t2 === 1 ? o.min : o.max : a = Math.max(Math.min(o.max, m2 + t2), o.min), this.#t = {
|
|
10891
|
+
...this.#t,
|
|
10892
|
+
[s.type]: a.toString().padStart(s.len, "0")
|
|
10893
|
+
}, this.#n = true, this.#s = null, this.#r();
|
|
10894
|
+
}
|
|
10895
|
+
#f(t2) {
|
|
10896
|
+
if (t2)
|
|
10897
|
+
switch (t2) {
|
|
10898
|
+
case "right":
|
|
10899
|
+
return this.#m(1);
|
|
10900
|
+
case "left":
|
|
10901
|
+
return this.#m(-1);
|
|
10902
|
+
case "up":
|
|
10903
|
+
return this.#d(1);
|
|
10904
|
+
case "down":
|
|
10905
|
+
return this.#d(-1);
|
|
10906
|
+
}
|
|
10907
|
+
}
|
|
10908
|
+
#y(t2, i) {
|
|
10909
|
+
if (i?.name === "backspace" || i?.sequence === "" || i?.sequence === "\b" || t2 === "" || t2 === "\b") {
|
|
10910
|
+
this.inlineError = "";
|
|
10911
|
+
const n = this.#a();
|
|
10912
|
+
if (!n)
|
|
10913
|
+
return;
|
|
10914
|
+
if (!this.#t[n.segment.type].replace(/_/g, "")) {
|
|
10915
|
+
this.#m(-1);
|
|
10916
|
+
return;
|
|
10917
|
+
}
|
|
10918
|
+
this.#t[n.segment.type] = "_".repeat(n.segment.len), this.#n = true, this.#e.positionInSegment = 0, this.#r();
|
|
10919
|
+
return;
|
|
10920
|
+
}
|
|
10921
|
+
if (i?.name === "tab") {
|
|
10922
|
+
this.inlineError = "";
|
|
10923
|
+
const n = this.#a();
|
|
10924
|
+
if (!n)
|
|
10925
|
+
return;
|
|
10926
|
+
const e = i.shift ? -1 : 1, m2 = n.index + e;
|
|
10927
|
+
m2 >= 0 && m2 < this.#i.length && (this.#e.segmentIndex = m2, this.#e.positionInSegment = 0, this.#n = true);
|
|
10928
|
+
return;
|
|
10929
|
+
}
|
|
10930
|
+
if (t2 && /^[0-9]$/.test(t2)) {
|
|
10931
|
+
const n = this.#a();
|
|
10932
|
+
if (!n)
|
|
10933
|
+
return;
|
|
10934
|
+
const { segment: e } = n, m2 = !this.#t[e.type].replace(/_/g, "");
|
|
10935
|
+
if (this.#n && this.#s !== null && !m2) {
|
|
10936
|
+
const h = this.#s + t2, d = { ...this.#t, [e.type]: h }, g2 = this.#g(d, e);
|
|
10937
|
+
if (g2) {
|
|
10938
|
+
this.inlineError = g2, this.#s = null, this.#n = false;
|
|
10939
|
+
return;
|
|
10940
|
+
}
|
|
10941
|
+
this.inlineError = "", this.#t[e.type] = h, this.#s = null, this.#n = false, this.#r(), n.index < this.#i.length - 1 && (this.#e.segmentIndex = n.index + 1, this.#e.positionInSegment = 0, this.#n = true);
|
|
10942
|
+
return;
|
|
10943
|
+
}
|
|
10944
|
+
this.#n && !m2 && (this.#t[e.type] = "_".repeat(e.len), this.#e.positionInSegment = 0), this.#n = false, this.#s = null;
|
|
10945
|
+
const o = this.#t[e.type], a = o.indexOf("_"), u = a >= 0 ? a : Math.min(this.#e.positionInSegment, e.len - 1);
|
|
10946
|
+
if (u < 0 || u >= e.len)
|
|
10947
|
+
return;
|
|
10948
|
+
let l = o.slice(0, u) + t2 + o.slice(u + 1), D = false;
|
|
10949
|
+
if (u === 0 && o === "__" && (e.type === "month" || e.type === "day")) {
|
|
10950
|
+
const h = Number.parseInt(t2, 10);
|
|
10951
|
+
l = `0${t2}`, D = h <= (e.type === "month" ? 1 : 2);
|
|
10952
|
+
}
|
|
10953
|
+
if (e.type === "year" && (l = (o.replace(/_/g, "") + t2).padStart(e.len, "_")), !l.includes("_")) {
|
|
10954
|
+
const h = { ...this.#t, [e.type]: l }, d = this.#g(h, e);
|
|
10955
|
+
if (d) {
|
|
10956
|
+
this.inlineError = d;
|
|
10957
|
+
return;
|
|
10958
|
+
}
|
|
10959
|
+
}
|
|
10960
|
+
this.inlineError = "", this.#t[e.type] = l;
|
|
10961
|
+
const y2 = l.includes("_") ? undefined : b(this.#t);
|
|
10962
|
+
if (y2) {
|
|
10963
|
+
const { year: h, month: d } = y2, g2 = c(h, d);
|
|
10964
|
+
this.#t = {
|
|
10965
|
+
year: String(Math.max(0, Math.min(9999, h))).padStart(4, "0"),
|
|
10966
|
+
month: String(Math.max(1, Math.min(12, d))).padStart(2, "0"),
|
|
10967
|
+
day: String(Math.max(1, Math.min(g2, y2.day))).padStart(2, "0")
|
|
10968
|
+
};
|
|
10969
|
+
}
|
|
10970
|
+
this.#r();
|
|
10971
|
+
const S = l.indexOf("_");
|
|
10972
|
+
D ? (this.#n = true, this.#s = t2) : S >= 0 ? this.#e.positionInSegment = S : a >= 0 && n.index < this.#i.length - 1 ? (this.#e.segmentIndex = n.index + 1, this.#e.positionInSegment = 0, this.#n = true) : this.#e.positionInSegment = Math.min(u + 1, e.len - 1);
|
|
10973
|
+
}
|
|
10974
|
+
}
|
|
10975
|
+
#g(t2, i) {
|
|
10976
|
+
const { month: s, day: n } = f(t2);
|
|
10977
|
+
if (i.type === "month" && (s < 0 || s > 12))
|
|
10978
|
+
return settings.date.messages.invalidMonth;
|
|
10979
|
+
if (i.type === "day" && (n < 0 || n > 31))
|
|
10980
|
+
return settings.date.messages.invalidDay(31, "any month");
|
|
10981
|
+
}
|
|
10982
|
+
#p(t2) {
|
|
10983
|
+
const { year: i, month: s, day: n } = f(this.#t);
|
|
10984
|
+
if (i && s && n) {
|
|
10985
|
+
const e = c(i, s);
|
|
10986
|
+
this.#t = {
|
|
10987
|
+
...this.#t,
|
|
10988
|
+
day: String(Math.min(n, e)).padStart(2, "0")
|
|
10989
|
+
};
|
|
10990
|
+
}
|
|
10991
|
+
this.value = C(this.#t) ?? t2.defaultValue ?? undefined;
|
|
10992
|
+
}
|
|
10993
|
+
}
|
|
10994
|
+
var u$2 = class u extends y {
|
|
10995
|
+
options;
|
|
10996
|
+
cursor = 0;
|
|
10997
|
+
#t;
|
|
10998
|
+
getGroupItems(t2) {
|
|
10999
|
+
return this.options.filter((r) => r.group === t2);
|
|
11000
|
+
}
|
|
11001
|
+
isGroupSelected(t2) {
|
|
11002
|
+
const r = this.getGroupItems(t2), e = this.value;
|
|
11003
|
+
return e === undefined ? false : r.every((s) => e.includes(s.value));
|
|
11004
|
+
}
|
|
11005
|
+
toggleValue() {
|
|
11006
|
+
const t2 = this.options[this.cursor];
|
|
11007
|
+
if (t2 !== undefined)
|
|
11008
|
+
if (this.value === undefined && (this.value = []), t2.group === true) {
|
|
11009
|
+
const r = t2.value, e = this.getGroupItems(r);
|
|
11010
|
+
this.isGroupSelected(r) ? this.value = this.value.filter((s) => e.findIndex((i) => i.value === s) === -1) : this.value = [...this.value, ...e.map((s) => s.value)], this.value = Array.from(new Set(this.value));
|
|
11011
|
+
} else {
|
|
11012
|
+
const r = this.value.includes(t2.value);
|
|
11013
|
+
this.value = r ? this.value.filter((e) => e !== t2.value) : [...this.value, t2.value];
|
|
11014
|
+
}
|
|
11015
|
+
}
|
|
11016
|
+
constructor(t2) {
|
|
11017
|
+
super(t2, false);
|
|
11018
|
+
const { options: r } = t2;
|
|
11019
|
+
this.#t = t2.selectableGroups !== false, this.options = Object.entries(r).flatMap(([e, s]) => [
|
|
11020
|
+
{ value: e, group: true, label: e },
|
|
11021
|
+
...s.map((i) => ({ ...i, group: e }))
|
|
11022
|
+
]), this.value = [...t2.initialValues ?? []], this.cursor = Math.max(this.options.findIndex(({ value: e }) => e === t2.cursorAt), this.#t ? 0 : 1), this.on("cursor", (e) => {
|
|
11023
|
+
switch (e) {
|
|
11024
|
+
case "left":
|
|
11025
|
+
case "up": {
|
|
11026
|
+
this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1;
|
|
11027
|
+
const s = this.options[this.cursor]?.group === true;
|
|
11028
|
+
!this.#t && s && (this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1);
|
|
11029
|
+
break;
|
|
11030
|
+
}
|
|
11031
|
+
case "down":
|
|
11032
|
+
case "right": {
|
|
11033
|
+
this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1;
|
|
11034
|
+
const s = this.options[this.cursor]?.group === true;
|
|
11035
|
+
!this.#t && s && (this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1);
|
|
11036
|
+
break;
|
|
11037
|
+
}
|
|
11038
|
+
case "space":
|
|
11039
|
+
this.toggleValue();
|
|
11040
|
+
break;
|
|
11041
|
+
}
|
|
11042
|
+
});
|
|
11043
|
+
}
|
|
11044
|
+
};
|
|
11045
|
+
var o = /* @__PURE__ */ new Set(["up", "down", "left", "right"]);
|
|
11046
|
+
|
|
11047
|
+
class h extends y {
|
|
11048
|
+
#t = false;
|
|
11049
|
+
#s;
|
|
11050
|
+
focused = "editor";
|
|
11051
|
+
get userInputWithCursor() {
|
|
11052
|
+
if (this.state === "submit")
|
|
11053
|
+
return this.userInput;
|
|
11054
|
+
const t2 = this.userInput;
|
|
11055
|
+
if (this.cursor >= t2.length)
|
|
11056
|
+
return `${t2}█`;
|
|
11057
|
+
const s = t2.slice(0, this.cursor), r = t2.slice(this.cursor, this.cursor + 1), i = t2.slice(this.cursor + 1);
|
|
11058
|
+
return r === `
|
|
11059
|
+
` ? `${s}█
|
|
11060
|
+
${i}` : `${s}${styleText("inverse", r)}${i}`;
|
|
11061
|
+
}
|
|
11062
|
+
get cursor() {
|
|
11063
|
+
return this._cursor;
|
|
11064
|
+
}
|
|
11065
|
+
#r(t2) {
|
|
11066
|
+
if (this.userInput.length === 0) {
|
|
11067
|
+
this._setUserInput(t2);
|
|
11068
|
+
return;
|
|
11069
|
+
}
|
|
11070
|
+
this._setUserInput(this.userInput.slice(0, this.cursor) + t2 + this.userInput.slice(this.cursor));
|
|
11071
|
+
}
|
|
11072
|
+
#i(t2) {
|
|
11073
|
+
const s = this.value ?? "";
|
|
11074
|
+
switch (t2) {
|
|
11075
|
+
case "up":
|
|
11076
|
+
this._cursor = findTextCursor(this._cursor, 0, -1, s);
|
|
11077
|
+
return;
|
|
11078
|
+
case "down":
|
|
11079
|
+
this._cursor = findTextCursor(this._cursor, 0, 1, s);
|
|
11080
|
+
return;
|
|
11081
|
+
case "left":
|
|
11082
|
+
this._cursor = findTextCursor(this._cursor, -1, 0, s);
|
|
11083
|
+
return;
|
|
11084
|
+
case "right":
|
|
11085
|
+
this._cursor = findTextCursor(this._cursor, 1, 0, s);
|
|
11086
|
+
return;
|
|
11087
|
+
}
|
|
11088
|
+
}
|
|
11089
|
+
_shouldSubmit(t2, s) {
|
|
11090
|
+
if (this.#s)
|
|
11091
|
+
return this.focused === "submit" ? true : (this.#r(`
|
|
11092
|
+
`), this._cursor++, false);
|
|
11093
|
+
const r = this.#t;
|
|
11094
|
+
return this.#t = true, r && this.cursor === this.userInput.length ? (this.userInput[this.cursor - 1] === `
|
|
11095
|
+
` && (this._setUserInput(this.userInput.slice(0, this.cursor - 1) + this.userInput.slice(this.cursor)), this._cursor--), true) : (this.#r(`
|
|
11096
|
+
`), this._cursor++, false);
|
|
11097
|
+
}
|
|
11098
|
+
constructor(t2) {
|
|
11099
|
+
const s = t2.initialUserInput ?? t2.initialValue;
|
|
11100
|
+
super({
|
|
11101
|
+
...t2,
|
|
11102
|
+
initialUserInput: s
|
|
11103
|
+
}, false), s !== undefined && (this._cursor = s.length), this.#s = t2.showSubmit ?? false, this.on("key", (r, i) => {
|
|
11104
|
+
if (i?.name && o.has(i.name)) {
|
|
11105
|
+
this.#t = false, this.#i(i.name);
|
|
11106
|
+
return;
|
|
11107
|
+
}
|
|
11108
|
+
if (r === "\t" && this.#s) {
|
|
11109
|
+
this.focused = this.focused === "editor" ? "submit" : "editor";
|
|
11110
|
+
return;
|
|
11111
|
+
}
|
|
11112
|
+
if (i?.name !== "return") {
|
|
11113
|
+
if (this.#t = false, i?.name === "backspace" && this.cursor > 0) {
|
|
11114
|
+
this._setUserInput(this.userInput.slice(0, this.cursor - 1) + this.userInput.slice(this.cursor)), this._cursor--;
|
|
11115
|
+
return;
|
|
11116
|
+
}
|
|
11117
|
+
if (i?.name === "delete" && this.cursor < this.userInput.length) {
|
|
11118
|
+
this._setUserInput(this.userInput.slice(0, this.cursor) + this.userInput.slice(this.cursor + 1));
|
|
11119
|
+
return;
|
|
11120
|
+
}
|
|
11121
|
+
r && (this.#s && this.focused === "submit" && (this.focused = "editor"), this.#r(r ?? ""), this._cursor++);
|
|
11122
|
+
}
|
|
11123
|
+
}), this.on("userInput", (r) => {
|
|
11124
|
+
this._setValue(r);
|
|
11125
|
+
}), this.on("finalize", () => {
|
|
11126
|
+
this.value || (this.value = t2.defaultValue), this.value === undefined && (this.value = "");
|
|
11127
|
+
});
|
|
11128
|
+
}
|
|
11129
|
+
}
|
|
11130
|
+
|
|
11131
|
+
class a extends y {
|
|
11132
|
+
options;
|
|
11133
|
+
cursor = 0;
|
|
11134
|
+
get _value() {
|
|
11135
|
+
return this.options[this.cursor]?.value;
|
|
11136
|
+
}
|
|
11137
|
+
get _enabledOptions() {
|
|
11138
|
+
return this.options.filter((e) => e.disabled !== true);
|
|
11139
|
+
}
|
|
11140
|
+
toggleAll() {
|
|
11141
|
+
const e = this._enabledOptions, i = this.value !== undefined && this.value.length === e.length;
|
|
11142
|
+
this.value = i ? [] : e.map((t2) => t2.value);
|
|
11143
|
+
}
|
|
11144
|
+
toggleInvert() {
|
|
11145
|
+
const e = this.value;
|
|
11146
|
+
if (!e)
|
|
11147
|
+
return;
|
|
11148
|
+
const i = this._enabledOptions.filter((t2) => !e.includes(t2.value));
|
|
11149
|
+
this.value = i.map((t2) => t2.value);
|
|
11150
|
+
}
|
|
11151
|
+
toggleValue() {
|
|
11152
|
+
this.value === undefined && (this.value = []);
|
|
11153
|
+
const e = this.value.includes(this._value);
|
|
11154
|
+
this.value = e ? this.value.filter((i) => i !== this._value) : [...this.value, this._value];
|
|
11155
|
+
}
|
|
11156
|
+
constructor(e) {
|
|
11157
|
+
super(e, false), this.options = e.options, this.value = [...e.initialValues ?? []];
|
|
11158
|
+
const i = Math.max(this.options.findIndex(({ value: t2 }) => t2 === e.cursorAt), 0);
|
|
11159
|
+
this.cursor = this.options[i]?.disabled ? findCursor(i, 1, this.options) : i, this.on("key", (t2, l) => {
|
|
11160
|
+
l.name === "a" && this.toggleAll(), l.name === "i" && this.toggleInvert();
|
|
11161
|
+
}), this.on("cursor", (t2) => {
|
|
11162
|
+
switch (t2) {
|
|
11163
|
+
case "left":
|
|
11164
|
+
case "up":
|
|
11165
|
+
this.cursor = findCursor(this.cursor, -1, this.options);
|
|
11166
|
+
break;
|
|
11167
|
+
case "down":
|
|
11168
|
+
case "right":
|
|
11169
|
+
this.cursor = findCursor(this.cursor, 1, this.options);
|
|
11170
|
+
break;
|
|
11171
|
+
case "space":
|
|
11172
|
+
this.toggleValue();
|
|
11173
|
+
break;
|
|
11174
|
+
}
|
|
11175
|
+
});
|
|
11176
|
+
}
|
|
11177
|
+
}
|
|
11178
|
+
class n extends y {
|
|
11179
|
+
get userInputWithCursor() {
|
|
11180
|
+
if (this.state === "submit")
|
|
11181
|
+
return this.userInput;
|
|
11182
|
+
const t2 = this.userInput;
|
|
11183
|
+
if (this.cursor >= t2.length)
|
|
11184
|
+
return `${this.userInput}█`;
|
|
11185
|
+
const r = t2.slice(0, this.cursor), s = t2.slice(this.cursor, this.cursor + 1), e = t2.slice(this.cursor + 1);
|
|
11186
|
+
return `${r}${styleText("inverse", s)}${e}`;
|
|
11187
|
+
}
|
|
11188
|
+
get cursor() {
|
|
11189
|
+
return this._cursor;
|
|
11190
|
+
}
|
|
11191
|
+
constructor(t2) {
|
|
11192
|
+
super({
|
|
11193
|
+
...t2,
|
|
11194
|
+
initialUserInput: t2.initialUserInput ?? t2.initialValue
|
|
11195
|
+
}), this.on("userInput", (r) => {
|
|
11196
|
+
this._setValue(r);
|
|
11197
|
+
}), this.on("finalize", () => {
|
|
11198
|
+
this.value || (this.value = t2.defaultValue), this.value === undefined && (this.value = "");
|
|
11199
|
+
});
|
|
11200
|
+
}
|
|
11201
|
+
}
|
|
11202
|
+
|
|
11203
|
+
// node_modules/@clack/prompts/dist/index.mjs
|
|
11204
|
+
import { styleText as styleText2, stripVTControlCharacters as stripVTControlCharacters3 } from "node:util";
|
|
11205
|
+
import process$1 from "node:process";
|
|
11206
|
+
var import_sisteransi2 = __toESM(require_src(), 1);
|
|
11207
|
+
function isUnicodeSupported() {
|
|
11208
|
+
if (process$1.platform !== "win32") {
|
|
11209
|
+
return process$1.env.TERM !== "linux";
|
|
11210
|
+
}
|
|
11211
|
+
return Boolean(process$1.env.CI) || Boolean(process$1.env.WT_SESSION) || Boolean(process$1.env.TERMINUS_SUBLIME) || process$1.env.ConEmuTask === "{cmd::Cmder}" || process$1.env.TERM_PROGRAM === "Terminus-Sublime" || process$1.env.TERM_PROGRAM === "vscode" || process$1.env.TERM === "xterm-256color" || process$1.env.TERM === "alacritty" || process$1.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
|
|
11212
|
+
}
|
|
11213
|
+
var unicode = isUnicodeSupported();
|
|
11214
|
+
var unicodeOr = (o2, e) => unicode ? o2 : e;
|
|
11215
|
+
var S_STEP_ACTIVE = unicodeOr("◆", "*");
|
|
11216
|
+
var S_STEP_CANCEL = unicodeOr("■", "x");
|
|
11217
|
+
var S_STEP_ERROR = unicodeOr("▲", "x");
|
|
11218
|
+
var S_STEP_SUBMIT = unicodeOr("◇", "o");
|
|
11219
|
+
var S_BAR_START = unicodeOr("┌", "T");
|
|
11220
|
+
var S_BAR = unicodeOr("│", "|");
|
|
11221
|
+
var S_BAR_END = unicodeOr("└", "—");
|
|
11222
|
+
var S_BAR_START_RIGHT = unicodeOr("┐", "T");
|
|
11223
|
+
var S_BAR_END_RIGHT = unicodeOr("┘", "—");
|
|
11224
|
+
var S_RADIO_ACTIVE = unicodeOr("●", ">");
|
|
11225
|
+
var S_RADIO_INACTIVE = unicodeOr("○", " ");
|
|
11226
|
+
var S_CHECKBOX_ACTIVE = unicodeOr("◻", "[•]");
|
|
11227
|
+
var S_CHECKBOX_SELECTED = unicodeOr("◼", "[+]");
|
|
11228
|
+
var S_CHECKBOX_INACTIVE = unicodeOr("◻", "[ ]");
|
|
11229
|
+
var S_PASSWORD_MASK = unicodeOr("▪", "•");
|
|
11230
|
+
var S_BAR_H = unicodeOr("─", "-");
|
|
11231
|
+
var S_CORNER_TOP_RIGHT = unicodeOr("╮", "+");
|
|
11232
|
+
var S_CONNECT_LEFT = unicodeOr("├", "+");
|
|
11233
|
+
var S_CORNER_BOTTOM_RIGHT = unicodeOr("╯", "+");
|
|
11234
|
+
var S_CORNER_BOTTOM_LEFT = unicodeOr("╰", "+");
|
|
11235
|
+
var S_CORNER_TOP_LEFT = unicodeOr("╭", "+");
|
|
11236
|
+
var S_INFO = unicodeOr("●", "•");
|
|
11237
|
+
var S_SUCCESS = unicodeOr("◆", "*");
|
|
11238
|
+
var S_WARN = unicodeOr("▲", "!");
|
|
11239
|
+
var S_ERROR = unicodeOr("■", "x");
|
|
11240
|
+
var symbol = (o2) => {
|
|
11241
|
+
switch (o2) {
|
|
11242
|
+
case "initial":
|
|
11243
|
+
case "active":
|
|
11244
|
+
return styleText2("cyan", S_STEP_ACTIVE);
|
|
11245
|
+
case "cancel":
|
|
11246
|
+
return styleText2("red", S_STEP_CANCEL);
|
|
11247
|
+
case "error":
|
|
11248
|
+
return styleText2("yellow", S_STEP_ERROR);
|
|
11249
|
+
case "submit":
|
|
11250
|
+
return styleText2("green", S_STEP_SUBMIT);
|
|
11251
|
+
case "validating":
|
|
11252
|
+
return styleText2("dim", S_STEP_ACTIVE);
|
|
11253
|
+
}
|
|
11254
|
+
};
|
|
11255
|
+
var symbolBar = (o2) => {
|
|
11256
|
+
switch (o2) {
|
|
11257
|
+
case "initial":
|
|
11258
|
+
case "active":
|
|
11259
|
+
return styleText2("cyan", S_BAR);
|
|
11260
|
+
case "cancel":
|
|
11261
|
+
return styleText2("red", S_BAR);
|
|
11262
|
+
case "error":
|
|
11263
|
+
return styleText2("yellow", S_BAR);
|
|
11264
|
+
case "submit":
|
|
11265
|
+
return styleText2("green", S_BAR);
|
|
11266
|
+
}
|
|
11267
|
+
};
|
|
11268
|
+
function formatInstructionFooter(o2, e) {
|
|
11269
|
+
const r2 = [`${e ? `${styleText2("cyan", S_BAR)} ` : ""}${o2.join(" • ")}`];
|
|
11270
|
+
return e && r2.push(styleText2("cyan", S_BAR_END)), r2;
|
|
11271
|
+
}
|
|
11272
|
+
var I = (l, e, w, p2, b2, C2 = false) => {
|
|
11273
|
+
let r2 = e, O = 0;
|
|
11274
|
+
if (C2)
|
|
11275
|
+
for (let i = p2 - 1;i >= w; i--) {
|
|
11276
|
+
const m2 = l[i];
|
|
11277
|
+
if (m2 && (r2 -= m2.length), O++, r2 <= b2)
|
|
11278
|
+
break;
|
|
11279
|
+
}
|
|
11280
|
+
else
|
|
11281
|
+
for (let i = w;i < p2; i++) {
|
|
11282
|
+
const m2 = l[i];
|
|
11283
|
+
if (m2 && (r2 -= m2.length), O++, r2 <= b2)
|
|
11284
|
+
break;
|
|
11285
|
+
}
|
|
11286
|
+
return { lineCount: r2, removals: O };
|
|
11287
|
+
};
|
|
11288
|
+
var limitOptions = ({
|
|
11289
|
+
cursor: l,
|
|
11290
|
+
options: e,
|
|
11291
|
+
style: w,
|
|
11292
|
+
output: p2 = process.stdout,
|
|
11293
|
+
maxItems: b2 = Number.POSITIVE_INFINITY,
|
|
11294
|
+
columnPadding: C2 = 0,
|
|
11295
|
+
rowPadding: r2 = 4
|
|
11296
|
+
}) => {
|
|
11297
|
+
const i = getColumns(p2) - C2, m2 = getRows(p2), M2 = styleText2("dim", "..."), v = Math.max(m2 - r2, 0), a2 = Math.max(Math.min(b2, v), 5);
|
|
11298
|
+
let f2 = 0;
|
|
11299
|
+
l >= a2 - 3 && (f2 = Math.max(Math.min(l - a2 + 3, e.length - a2), 0));
|
|
11300
|
+
let d = a2 < e.length && f2 > 0, c2 = a2 < e.length && f2 + a2 < e.length;
|
|
11301
|
+
const W = Math.min(f2 + a2, e.length), s = [];
|
|
11302
|
+
let g2 = 0;
|
|
11303
|
+
d && g2++, c2 && g2++;
|
|
11304
|
+
const T3 = f2 + (d ? 1 : 0), y2 = W - (c2 ? 1 : 0);
|
|
11305
|
+
for (let t2 = T3;t2 < y2; t2++) {
|
|
11306
|
+
const n2 = e[t2], o2 = n2 ? w(n2, t2 === l) : "", h2 = wrapAnsi(o2, i, {
|
|
11307
|
+
hard: true,
|
|
11308
|
+
trim: false
|
|
11309
|
+
}).split(`
|
|
11310
|
+
`);
|
|
11311
|
+
s.push(h2), g2 += h2.length;
|
|
11312
|
+
}
|
|
11313
|
+
if (g2 > v) {
|
|
11314
|
+
let t2 = 0, n2 = 0, o2 = g2;
|
|
11315
|
+
const h2 = l - T3;
|
|
11316
|
+
let u3 = v;
|
|
11317
|
+
const L = () => I(s, o2, 0, h2, u3), E = () => I(s, o2, h2 + 1, s.length, u3, true);
|
|
11318
|
+
d ? ({ lineCount: o2, removals: t2 } = L(), o2 > u3 && (c2 || (u3 -= 1), { lineCount: o2, removals: n2 } = E())) : (c2 || (u3 -= 1), { lineCount: o2, removals: n2 } = E(), o2 > u3 && (u3 -= 1, { lineCount: o2, removals: t2 } = L())), t2 > 0 && (d = true, s.splice(0, t2)), n2 > 0 && (c2 = true, s.splice(s.length - n2, n2));
|
|
11319
|
+
}
|
|
11320
|
+
const x = [];
|
|
11321
|
+
d && x.push(M2);
|
|
11322
|
+
for (const t2 of s)
|
|
11323
|
+
for (const n2 of t2)
|
|
11324
|
+
x.push(n2);
|
|
11325
|
+
return c2 && x.push(M2), x;
|
|
11326
|
+
};
|
|
11327
|
+
var MULTISELECT_INSTRUCTIONS = [
|
|
11328
|
+
`${styleText2("dim", "↑/↓")} to navigate`,
|
|
11329
|
+
`${styleText2("dim", "Space:")} select`,
|
|
11330
|
+
`${styleText2("dim", "Enter:")} confirm`
|
|
11331
|
+
];
|
|
11332
|
+
var m2 = (i, u3) => i.split(`
|
|
11333
|
+
`).map((d) => u3(d)).join(`
|
|
11334
|
+
`);
|
|
11335
|
+
var multiselect = (i) => {
|
|
11336
|
+
const u3 = (t2, a2) => {
|
|
11337
|
+
const r2 = t2.label ?? String(t2.value);
|
|
11338
|
+
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))}`;
|
|
11339
|
+
}, d = i.required ?? true, x = i.showInstructions ?? true;
|
|
11340
|
+
return new a({
|
|
11341
|
+
options: i.options,
|
|
11342
|
+
signal: i.signal,
|
|
11343
|
+
input: i.input,
|
|
11344
|
+
output: i.output,
|
|
11345
|
+
initialValues: i.initialValues,
|
|
11346
|
+
required: d,
|
|
11347
|
+
cursorAt: i.cursorAt,
|
|
11348
|
+
validate(t2) {
|
|
11349
|
+
if (d && (t2 === undefined || t2.length === 0))
|
|
11350
|
+
return `Please select at least one option.
|
|
11351
|
+
${styleText2("reset", styleText2("dim", `Press ${styleText2(["gray", "bgWhite", "inverse"], " space ")} to select, ${styleText2("gray", styleText2("bgWhite", styleText2("inverse", " enter ")))} to submit`))}`;
|
|
11352
|
+
},
|
|
11353
|
+
render() {
|
|
11354
|
+
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)}
|
|
11355
|
+
` : ""}${a2}
|
|
11356
|
+
`, o2 = this.value ?? [], g2 = (n2, l) => {
|
|
11357
|
+
if (n2.disabled)
|
|
11358
|
+
return u3(n2, "disabled");
|
|
11359
|
+
const s = o2.includes(n2.value);
|
|
11360
|
+
return l && s ? u3(n2, "active-selected") : s ? u3(n2, "selected") : u3(n2, l ? "active" : "inactive");
|
|
11361
|
+
};
|
|
11362
|
+
switch (this.state) {
|
|
11363
|
+
case "submit": {
|
|
11364
|
+
const n2 = this.options.filter(({ value: s }) => o2.includes(s)).map((s) => u3(s, "submitted")).join(styleText2("dim", ", ")) || styleText2("dim", "none"), l = wrapTextWithPrefix(i.output, n2, t2 ? `${styleText2("gray", S_BAR)} ` : "");
|
|
11365
|
+
return `${r2}${l}`;
|
|
11366
|
+
}
|
|
11367
|
+
case "cancel": {
|
|
11368
|
+
const n2 = this.options.filter(({ value: s }) => o2.includes(s)).map((s) => u3(s, "cancelled")).join(styleText2("dim", ", "));
|
|
11369
|
+
if (n2.trim() === "")
|
|
11370
|
+
return `${r2}${styleText2("gray", S_BAR)}`;
|
|
11371
|
+
const l = wrapTextWithPrefix(i.output, n2, t2 ? `${styleText2("gray", S_BAR)} ` : "");
|
|
11372
|
+
return `${r2}${l}${t2 ? `
|
|
11373
|
+
${styleText2("gray", S_BAR)}` : ""}`;
|
|
11374
|
+
}
|
|
11375
|
+
case "error": {
|
|
11376
|
+
const n2 = t2 ? `${styleText2("yellow", S_BAR)} ` : "", l = this.error.split(`
|
|
11377
|
+
`).map(($, v) => v === 0 ? `${t2 ? `${styleText2("yellow", S_BAR_END)} ` : ""}${styleText2("yellow", $)}` : ` ${$}`).join(`
|
|
11378
|
+
`), s = r2.split(`
|
|
11379
|
+
`).length, h2 = l.split(`
|
|
11380
|
+
`).length + 1;
|
|
11381
|
+
return `${r2}${n2}${limitOptions({
|
|
11382
|
+
output: i.output,
|
|
11383
|
+
options: this.options,
|
|
11384
|
+
cursor: this.cursor,
|
|
11385
|
+
maxItems: i.maxItems,
|
|
11386
|
+
columnPadding: n2.length,
|
|
11387
|
+
rowPadding: s + h2,
|
|
11388
|
+
style: g2
|
|
11389
|
+
}).join(`
|
|
11390
|
+
${n2}`)}
|
|
11391
|
+
${l}
|
|
11392
|
+
`;
|
|
11393
|
+
}
|
|
11394
|
+
default: {
|
|
11395
|
+
const n2 = t2 ? `${styleText2("cyan", S_BAR)} ` : "", l = r2.split(`
|
|
11396
|
+
`).length, s = x ? formatInstructionFooter(MULTISELECT_INSTRUCTIONS, t2) : t2 ? [styleText2("cyan", S_BAR_END)] : [], h2 = s.join(`
|
|
11397
|
+
`), $ = s.length + 1;
|
|
11398
|
+
return `${r2}${n2}${limitOptions({
|
|
11399
|
+
output: i.output,
|
|
11400
|
+
options: this.options,
|
|
11401
|
+
cursor: this.cursor,
|
|
11402
|
+
maxItems: i.maxItems,
|
|
11403
|
+
columnPadding: n2.length,
|
|
11404
|
+
rowPadding: l + $,
|
|
11405
|
+
style: g2
|
|
11406
|
+
}).join(`
|
|
11407
|
+
${n2}`)}
|
|
11408
|
+
${h2}
|
|
11409
|
+
`;
|
|
11410
|
+
}
|
|
11411
|
+
}
|
|
11412
|
+
}
|
|
11413
|
+
}).prompt();
|
|
11414
|
+
};
|
|
11415
|
+
var u3 = {
|
|
11416
|
+
light: unicodeOr("─", "-"),
|
|
11417
|
+
heavy: unicodeOr("━", "="),
|
|
11418
|
+
block: unicodeOr("█", "#")
|
|
11419
|
+
};
|
|
11420
|
+
var SELECT_INSTRUCTIONS = [
|
|
11421
|
+
`${styleText2("dim", "↑/↓")} to navigate`,
|
|
11422
|
+
`${styleText2("dim", "Enter:")} confirm`
|
|
11423
|
+
];
|
|
11424
|
+
var i = `${styleText2("gray", S_BAR)} `;
|
|
11425
|
+
var text = (t2) => new n({
|
|
11426
|
+
validate: t2.validate,
|
|
11427
|
+
placeholder: t2.placeholder,
|
|
11428
|
+
defaultValue: t2.defaultValue,
|
|
11429
|
+
initialValue: t2.initialValue,
|
|
11430
|
+
output: t2.output,
|
|
11431
|
+
signal: t2.signal,
|
|
11432
|
+
input: t2.input,
|
|
11433
|
+
render() {
|
|
11434
|
+
const r2 = t2?.withGuide ?? settings.withGuide, l = `${`${r2 ? `${styleText2("gray", S_BAR)}
|
|
11435
|
+
` : ""}${symbol(this.state)} `}${t2.message}
|
|
11436
|
+
`, d = t2.placeholder && t2.placeholder.length > 0 ? styleText2("inverse", t2.placeholder[0]) + styleText2("dim", t2.placeholder.slice(1)) : styleText2(["inverse", "hidden"], "_"), o2 = this.userInput ? this.userInputWithCursor : d, s = this.value ?? "";
|
|
11437
|
+
switch (this.state) {
|
|
11438
|
+
case "validating": {
|
|
11439
|
+
const n2 = r2 ? `${styleText2("cyan", S_BAR)} ` : "", i2 = r2 ? styleText2("cyan", S_BAR_END) : "", c2 = styleText2("dim", o2), $ = styleText2("dim", "Validating...");
|
|
11440
|
+
return `${l}${n2}${c2}
|
|
11441
|
+
${i2} ${$}
|
|
11442
|
+
`;
|
|
11443
|
+
}
|
|
11444
|
+
case "error": {
|
|
11445
|
+
const n2 = this.error ? ` ${styleText2("yellow", this.error)}` : "", i2 = r2 ? `${styleText2("yellow", S_BAR)} ` : "", c2 = r2 ? styleText2("yellow", S_BAR_END) : "";
|
|
11446
|
+
return `${l.trim()}
|
|
11447
|
+
${i2}${o2}
|
|
11448
|
+
${c2}${n2}
|
|
11449
|
+
`;
|
|
11450
|
+
}
|
|
11451
|
+
case "submit": {
|
|
11452
|
+
const n2 = s ? `${r2 ? " " : ""}${styleText2("dim", s)}` : "", i2 = r2 ? styleText2("gray", S_BAR) : "";
|
|
11453
|
+
return `${l}${i2}${n2}`;
|
|
11454
|
+
}
|
|
11455
|
+
case "cancel": {
|
|
11456
|
+
const n2 = s ? ` ${styleText2(["strikethrough", "dim"], s)}` : "", i2 = r2 ? styleText2("gray", S_BAR) : "";
|
|
11457
|
+
return `${l}${i2}${n2}${s.trim() ? `
|
|
11458
|
+
${i2}` : ""}`;
|
|
11459
|
+
}
|
|
11460
|
+
default: {
|
|
11461
|
+
const n2 = r2 ? `${styleText2("cyan", S_BAR)} ` : "", i2 = r2 ? styleText2("cyan", S_BAR_END) : "";
|
|
11462
|
+
return `${l}${n2}${o2}
|
|
11463
|
+
${i2}
|
|
11464
|
+
`;
|
|
11465
|
+
}
|
|
11466
|
+
}
|
|
11467
|
+
}
|
|
11468
|
+
}).prompt();
|
|
11469
|
+
|
|
11470
|
+
// src/install.ts
|
|
9839
11471
|
var self = fileURLToPath(import.meta.url);
|
|
9840
11472
|
var pkgRoot = dirname(dirname(self));
|
|
9841
|
-
var plugin =
|
|
11473
|
+
var plugin = join7(pkgRoot, "plugin");
|
|
9842
11474
|
var PLUGIN_DIRS = [".claude-plugin", "commands"];
|
|
9843
11475
|
var BINARY_MARKER = "theway-cli-binary:pixelfactoryio/theway";
|
|
9844
11476
|
function claudeHome() {
|
|
9845
11477
|
const dir = (process.env.CLAUDE_CONFIG_DIR ?? "").trim();
|
|
9846
|
-
return dir !== "" ? dir :
|
|
11478
|
+
return dir !== "" ? dir : join7(homedir2(), ".claude");
|
|
9847
11479
|
}
|
|
9848
11480
|
function installDir() {
|
|
9849
11481
|
const dir = process.env.THEWAY_INSTALL_DIR ?? "";
|
|
9850
|
-
return dir !== "" ? resolve3(dir) :
|
|
11482
|
+
return dir !== "" ? resolve3(dir) : join7(homedir2(), ".local", "bin");
|
|
9851
11483
|
}
|
|
9852
11484
|
function shownHome(home) {
|
|
9853
11485
|
return resolve3(home) === resolve3(defaultHome()) ? "~/.theway" : resolve3(home);
|
|
@@ -9885,7 +11517,7 @@ function readSettings(path2) {
|
|
|
9885
11517
|
return {};
|
|
9886
11518
|
let data;
|
|
9887
11519
|
try {
|
|
9888
|
-
data = JSON.parse(
|
|
11520
|
+
data = JSON.parse(readFileSync8(path2, "utf-8"));
|
|
9889
11521
|
} catch {
|
|
9890
11522
|
return null;
|
|
9891
11523
|
}
|
|
@@ -9930,12 +11562,12 @@ function settingsTarget(path2) {
|
|
|
9930
11562
|
function unwritableSettings(path2, reason) {
|
|
9931
11563
|
return fail(`theway: cannot write ${path2}: ${reason}; nothing was changed`);
|
|
9932
11564
|
}
|
|
9933
|
-
function writeSettings(target,
|
|
11565
|
+
function writeSettings(target, settings2) {
|
|
9934
11566
|
mkdirSync3(dirname(target), { recursive: true });
|
|
9935
11567
|
const mode = existsSync3(target) ? statSync3(target).mode & 511 : 384;
|
|
9936
11568
|
const tmp = `${target}.tmp-${process.pid}`;
|
|
9937
11569
|
try {
|
|
9938
|
-
writeFileSync2(tmp, `${JSON.stringify(
|
|
11570
|
+
writeFileSync2(tmp, `${JSON.stringify(settings2, null, 2)}
|
|
9939
11571
|
`, { mode });
|
|
9940
11572
|
chmodSync(tmp, mode);
|
|
9941
11573
|
renameSync3(tmp, target);
|
|
@@ -9947,15 +11579,15 @@ function invalidSettings(path2) {
|
|
|
9947
11579
|
return fail(`theway: ${path2} is not valid settings JSON; nothing was changed`);
|
|
9948
11580
|
}
|
|
9949
11581
|
function copyPlugin(home) {
|
|
9950
|
-
const tmp =
|
|
9951
|
-
const old =
|
|
9952
|
-
const dest =
|
|
11582
|
+
const tmp = join7(home, `.theway-install-${process.pid}`);
|
|
11583
|
+
const old = join7(home, `.theway-old-${process.pid}`);
|
|
11584
|
+
const dest = join7(home, "skills", "theway");
|
|
9953
11585
|
rmSync2(tmp, { recursive: true, force: true });
|
|
9954
11586
|
try {
|
|
9955
11587
|
for (const dir of PLUGIN_DIRS) {
|
|
9956
|
-
cpSync(
|
|
11588
|
+
cpSync(join7(plugin, dir), join7(tmp, dir), { recursive: true });
|
|
9957
11589
|
}
|
|
9958
|
-
mkdirSync3(
|
|
11590
|
+
mkdirSync3(join7(home, "skills"), { recursive: true });
|
|
9959
11591
|
if (existsSync3(dest))
|
|
9960
11592
|
renameSync3(dest, old);
|
|
9961
11593
|
renameSync3(tmp, dest);
|
|
@@ -9972,29 +11604,29 @@ function removeIfEmpty2(dir) {
|
|
|
9972
11604
|
}
|
|
9973
11605
|
function legacyText(path2, match) {
|
|
9974
11606
|
try {
|
|
9975
|
-
return lstatSync(path2).isFile() && match(
|
|
11607
|
+
return lstatSync(path2).isFile() && match(readFileSync8(path2, "utf-8"));
|
|
9976
11608
|
} catch {
|
|
9977
11609
|
return false;
|
|
9978
11610
|
}
|
|
9979
11611
|
}
|
|
9980
11612
|
function removeLegacyBin(home) {
|
|
9981
|
-
for (const
|
|
9982
|
-
const bin =
|
|
9983
|
-
if (legacyText(
|
|
9984
|
-
exec node `) &&
|
|
11613
|
+
for (const h2 of new Set([defaultHome(), resolve3(home)])) {
|
|
11614
|
+
const bin = join7(h2, "bin");
|
|
11615
|
+
if (legacyText(join7(bin, "theway"), (t2) => t2.startsWith(`#!/bin/sh
|
|
11616
|
+
exec node `) && t2.endsWith(`theway.js' "$@"
|
|
9985
11617
|
`))) {
|
|
9986
|
-
rmSync2(
|
|
11618
|
+
rmSync2(join7(bin, "theway"), { force: true });
|
|
9987
11619
|
}
|
|
9988
|
-
if (legacyText(
|
|
11620
|
+
if (legacyText(join7(bin, "theway.js"), (t2) => t2.startsWith(`#!/usr/bin/env node
|
|
9989
11621
|
`))) {
|
|
9990
|
-
rmSync2(
|
|
11622
|
+
rmSync2(join7(bin, "theway.js"), { force: true });
|
|
9991
11623
|
}
|
|
9992
11624
|
removeIfEmpty2(bin);
|
|
9993
11625
|
}
|
|
9994
11626
|
}
|
|
9995
11627
|
function writeBinary(dir) {
|
|
9996
|
-
const dest =
|
|
9997
|
-
const tmp =
|
|
11628
|
+
const dest = join7(dir, "theway");
|
|
11629
|
+
const tmp = join7(dir, `.theway-${process.pid}`);
|
|
9998
11630
|
mkdirSync3(dir, { recursive: true });
|
|
9999
11631
|
try {
|
|
10000
11632
|
copyFileSync2(self, tmp);
|
|
@@ -10017,8 +11649,8 @@ function isThewayBinary(path2) {
|
|
|
10017
11649
|
if (!isFile(path2))
|
|
10018
11650
|
return false;
|
|
10019
11651
|
try {
|
|
10020
|
-
const
|
|
10021
|
-
return
|
|
11652
|
+
const text2 = readFileSync8(path2, "utf-8");
|
|
11653
|
+
return text2.startsWith("#!/usr/bin/env node") && text2.includes(BINARY_MARKER);
|
|
10022
11654
|
} catch {
|
|
10023
11655
|
return false;
|
|
10024
11656
|
}
|
|
@@ -10058,7 +11690,7 @@ function copiesOnPath() {
|
|
|
10058
11690
|
for (const dir of (process.env.PATH ?? "").split(delimiter)) {
|
|
10059
11691
|
if (dir === "")
|
|
10060
11692
|
continue;
|
|
10061
|
-
const candidate =
|
|
11693
|
+
const candidate = join7(dir, "theway");
|
|
10062
11694
|
if (!isFile(candidate))
|
|
10063
11695
|
continue;
|
|
10064
11696
|
try {
|
|
@@ -10075,8 +11707,8 @@ function copiesOnPath() {
|
|
|
10075
11707
|
return copies;
|
|
10076
11708
|
}
|
|
10077
11709
|
function checkPath(dir, binary) {
|
|
10078
|
-
const
|
|
10079
|
-
if (!
|
|
11710
|
+
const dirs2 = (process.env.PATH ?? "").split(delimiter).filter((d) => d !== "");
|
|
11711
|
+
if (!dirs2.some((d) => resolve3(d) === dir)) {
|
|
10080
11712
|
process.stdout.write(`Add ${dir} to your PATH, e.g.: export PATH="${dir}:$PATH"
|
|
10081
11713
|
`);
|
|
10082
11714
|
}
|
|
@@ -10086,30 +11718,137 @@ function checkPath(dir, binary) {
|
|
|
10086
11718
|
`);
|
|
10087
11719
|
}
|
|
10088
11720
|
}
|
|
10089
|
-
|
|
10090
|
-
|
|
11721
|
+
var OPT_IN_HINTS = {
|
|
11722
|
+
core_principles: "Architecture philosophy (simplicity, security, pragmatic technology)",
|
|
11723
|
+
sre: "SRE operational excellence (reliability, observability, automation)",
|
|
11724
|
+
web_development: "Frontend, API and backend standards with web performance targets",
|
|
11725
|
+
quality: "Testing, deployment, monitoring and security expectations"
|
|
11726
|
+
};
|
|
11727
|
+
var CANCELLED = "theway: install cancelled; nothing was changed";
|
|
11728
|
+
function expandHome(value) {
|
|
11729
|
+
const v = value.trim();
|
|
11730
|
+
if (v === "")
|
|
11731
|
+
return { error: "must not be empty" };
|
|
11732
|
+
if (v === "~")
|
|
11733
|
+
return homedir2();
|
|
11734
|
+
if (v.startsWith("~/"))
|
|
11735
|
+
return resolve3(homedir2(), v.slice(2));
|
|
11736
|
+
if (isAbsolute(v))
|
|
11737
|
+
return resolve3(v);
|
|
11738
|
+
return { error: "must be an absolute path or start with ~/" };
|
|
11739
|
+
}
|
|
11740
|
+
function parseStandards(value) {
|
|
11741
|
+
if (value === "none")
|
|
11742
|
+
return [];
|
|
11743
|
+
const elements = value.split(",");
|
|
11744
|
+
const unknownError = (element) => ({
|
|
11745
|
+
error: `theway: unknown standard '${element}' in --standards; valid: ${OPT_IN_KEYS.join(", ")}, or none`
|
|
11746
|
+
});
|
|
11747
|
+
const unknown = elements.find((e) => e !== "none" && !OPT_IN_KEYS.includes(e));
|
|
11748
|
+
if (unknown !== undefined)
|
|
11749
|
+
return unknownError(unknown);
|
|
11750
|
+
if (!elements.includes("none"))
|
|
11751
|
+
return elements;
|
|
11752
|
+
if (elements.some((e) => e !== "none")) {
|
|
11753
|
+
return { error: "theway: --standards none cannot be combined with other standards" };
|
|
11754
|
+
}
|
|
11755
|
+
return unknownError("none");
|
|
11756
|
+
}
|
|
11757
|
+
function interactive() {
|
|
11758
|
+
return process.stdin.isTTY === true && process.stdout.isTTY === true;
|
|
11759
|
+
}
|
|
11760
|
+
async function askHome() {
|
|
11761
|
+
const answer = await text({
|
|
11762
|
+
message: "Where should theway keep its data?",
|
|
11763
|
+
placeholder: "~/.theway",
|
|
11764
|
+
defaultValue: "~/.theway",
|
|
11765
|
+
validate: (value) => {
|
|
11766
|
+
if (value === undefined || value.trim() === "")
|
|
11767
|
+
return;
|
|
11768
|
+
const home2 = expandHome(value);
|
|
11769
|
+
if (typeof home2 !== "string")
|
|
11770
|
+
return home2.error;
|
|
11771
|
+
const reason = unsafeHomeReason(home2, home2 !== resolve3(defaultHome()));
|
|
11772
|
+
return reason !== "" ? `refusing ${home2}: ${reason}` : undefined;
|
|
11773
|
+
}
|
|
11774
|
+
});
|
|
11775
|
+
if (isCancel(answer))
|
|
11776
|
+
return null;
|
|
11777
|
+
const home = expandHome(answer.trim() === "" ? "~/.theway" : answer);
|
|
11778
|
+
return typeof home === "string" ? home : null;
|
|
11779
|
+
}
|
|
11780
|
+
async function askStandards() {
|
|
11781
|
+
const answer = await multiselect({
|
|
11782
|
+
message: "Enable opt-in standards",
|
|
11783
|
+
options: OPT_IN_KEYS.map((key) => ({ value: key, label: key, hint: OPT_IN_HINTS[key] })),
|
|
11784
|
+
required: false
|
|
11785
|
+
});
|
|
11786
|
+
return isCancel(answer) ? null : answer;
|
|
11787
|
+
}
|
|
11788
|
+
async function install(opts) {
|
|
11789
|
+
if (!existsSync3(join7(plugin, ".claude-plugin"))) {
|
|
10091
11790
|
return fail("theway: run `npx --yes @pixelfactoryio/theway@latest install` to install or update theway");
|
|
10092
11791
|
}
|
|
11792
|
+
let enabled2 = [];
|
|
11793
|
+
if (opts.standards !== undefined) {
|
|
11794
|
+
const parsed = parseStandards(opts.standards);
|
|
11795
|
+
if (!Array.isArray(parsed))
|
|
11796
|
+
return fail(parsed.error);
|
|
11797
|
+
enabled2 = parsed;
|
|
11798
|
+
}
|
|
10093
11799
|
const cHome = claudeHome();
|
|
10094
|
-
|
|
11800
|
+
let tHome;
|
|
11801
|
+
if (opts.home !== undefined) {
|
|
11802
|
+
const home = expandHome(opts.home);
|
|
11803
|
+
if (typeof home !== "string")
|
|
11804
|
+
return fail(`theway: invalid --home '${opts.home}': ${home.error}; nothing was changed`);
|
|
11805
|
+
const env = process.env.THEWAY_HOME ?? "";
|
|
11806
|
+
if (env !== "" && resolve3(env) !== home) {
|
|
11807
|
+
return fail(`theway: --home ${home} and THEWAY_HOME ${resolve3(env)} differ; unset THEWAY_HOME or drop --home; nothing was changed`);
|
|
11808
|
+
}
|
|
11809
|
+
tHome = home;
|
|
11810
|
+
} else {
|
|
11811
|
+
const found = resolveHome();
|
|
11812
|
+
const neverInstalled = found.source === "default" && !existsSync3(join7(defaultHome(), "config.yaml"));
|
|
11813
|
+
if (neverInstalled && interactive()) {
|
|
11814
|
+
const home = await askHome();
|
|
11815
|
+
if (home === null)
|
|
11816
|
+
return fail(CANCELLED);
|
|
11817
|
+
tHome = home;
|
|
11818
|
+
} else {
|
|
11819
|
+
tHome = found.home;
|
|
11820
|
+
}
|
|
11821
|
+
}
|
|
10095
11822
|
const previous = recordedHome();
|
|
10096
11823
|
const custom = tHome !== resolve3(defaultHome());
|
|
10097
11824
|
const dir = installDir();
|
|
10098
|
-
const settingsPath =
|
|
11825
|
+
const settingsPath = join7(cHome, "settings.json");
|
|
10099
11826
|
const unsafe = unsafeHomeReason(tHome, custom);
|
|
10100
11827
|
if (unsafe !== "") {
|
|
10101
|
-
return fail(`theway: refusing data home ${resolve3(tHome)}: ${unsafe}; set THEWAY_HOME to a dedicated folder`);
|
|
11828
|
+
return fail(`theway: refusing data home ${resolve3(tHome)}: ${unsafe}; set THEWAY_HOME or --home to a dedicated folder`);
|
|
10102
11829
|
}
|
|
10103
11830
|
const resolved = settingsTarget(settingsPath);
|
|
10104
11831
|
if ("error" in resolved)
|
|
10105
11832
|
return unwritableSettings(settingsPath, resolved.error);
|
|
10106
|
-
const
|
|
10107
|
-
if (
|
|
11833
|
+
const settings2 = readSettings(resolved.target);
|
|
11834
|
+
if (settings2 === null)
|
|
10108
11835
|
return invalidSettings(settingsPath);
|
|
10109
|
-
const target =
|
|
11836
|
+
const target = join7(dir, "theway");
|
|
10110
11837
|
if (occupied(target) && !isThewayBinary(target)) {
|
|
10111
11838
|
return fail(`theway: ${target} exists and is not a theway binary; nothing was changed. Remove it, or set THEWAY_INSTALL_DIR to another folder`);
|
|
10112
11839
|
}
|
|
11840
|
+
const config = join7(resolve3(tHome), "config.yaml");
|
|
11841
|
+
const firstInstall = !existsSync3(config);
|
|
11842
|
+
if (opts.standards !== undefined && !firstInstall) {
|
|
11843
|
+
return fail(`theway: --standards applies only to a first install; ${config} exists, so set standards.<key>.enabled there instead; nothing was changed`);
|
|
11844
|
+
}
|
|
11845
|
+
const asked = firstInstall && opts.standards === undefined && interactive();
|
|
11846
|
+
if (asked) {
|
|
11847
|
+
const chosen = await askStandards();
|
|
11848
|
+
if (chosen === null)
|
|
11849
|
+
return fail(CANCELLED);
|
|
11850
|
+
enabled2 = chosen;
|
|
11851
|
+
}
|
|
10113
11852
|
const dest = copyPlugin(cHome);
|
|
10114
11853
|
let binary;
|
|
10115
11854
|
try {
|
|
@@ -10118,32 +11857,36 @@ function install() {
|
|
|
10118
11857
|
} catch (e) {
|
|
10119
11858
|
return fail(`theway: ${e.message}`);
|
|
10120
11859
|
}
|
|
10121
|
-
const status = init(
|
|
11860
|
+
const status = init(join7(plugin, "home"), tHome, enabled2);
|
|
10122
11861
|
if (status !== 0)
|
|
10123
11862
|
return status;
|
|
11863
|
+
if (firstInstall && opts.standards === undefined && !asked) {
|
|
11864
|
+
process.stdout.write(`Opt-in standards are off (${OPT_IN_KEYS.join(", ")}): set standards.<key>.enabled: true in ${config} to enable one
|
|
11865
|
+
`);
|
|
11866
|
+
}
|
|
10124
11867
|
try {
|
|
10125
11868
|
writePointer(tHome, custom);
|
|
10126
11869
|
} catch (e) {
|
|
10127
11870
|
return fail(`theway: ${e.message}`);
|
|
10128
11871
|
}
|
|
10129
|
-
const perms =
|
|
11872
|
+
const perms = settings2.permissions ?? {};
|
|
10130
11873
|
const allow = perms.allow ?? [];
|
|
10131
11874
|
const current = rules(tHome);
|
|
10132
11875
|
const stale = [
|
|
10133
11876
|
...legacyRules(tHome),
|
|
10134
11877
|
editRule(tHome),
|
|
10135
11878
|
editRule(previous),
|
|
10136
|
-
...homeRules(previous).filter((
|
|
11879
|
+
...homeRules(previous).filter((r2) => !current.includes(r2))
|
|
10137
11880
|
];
|
|
10138
|
-
const kept = allow.filter((
|
|
10139
|
-
const missing = current.filter((
|
|
11881
|
+
const kept = allow.filter((r2) => !(typeof r2 === "string" && stale.includes(r2)));
|
|
11882
|
+
const missing = current.filter((r2) => !kept.includes(r2));
|
|
10140
11883
|
if (missing.length > 0 || kept.length !== allow.length) {
|
|
10141
|
-
|
|
11884
|
+
settings2.permissions = { ...perms, allow: [...kept, ...missing] };
|
|
10142
11885
|
mkdirSync3(cHome, { recursive: true });
|
|
10143
|
-
writeSettings(resolved.target,
|
|
11886
|
+
writeSettings(resolved.target, settings2);
|
|
10144
11887
|
}
|
|
10145
11888
|
checkPath(dir, binary);
|
|
10146
|
-
const version = JSON.parse(
|
|
11889
|
+
const version = JSON.parse(readFileSync8(join7(pkgRoot, "package.json"), "utf-8")).version;
|
|
10147
11890
|
process.stdout.write(`Installed theway ${version} to ${dest} (theway@skills-dir), ${binary} and ${tHome}. Start a new Claude Code session or run /reload-plugins.
|
|
10148
11891
|
`);
|
|
10149
11892
|
return 0;
|
|
@@ -10152,7 +11895,7 @@ function uninstall() {
|
|
|
10152
11895
|
const cHome = claudeHome();
|
|
10153
11896
|
const tHome = resolveHome().home;
|
|
10154
11897
|
const homes = [...new Set([tHome, recordedHome(), defaultHome()])];
|
|
10155
|
-
const settingsPath =
|
|
11898
|
+
const settingsPath = join7(cHome, "settings.json");
|
|
10156
11899
|
let settingsFile = settingsPath;
|
|
10157
11900
|
if (occupied(settingsPath)) {
|
|
10158
11901
|
const resolved = settingsTarget(settingsPath);
|
|
@@ -10160,24 +11903,24 @@ function uninstall() {
|
|
|
10160
11903
|
return unwritableSettings(settingsPath, resolved.error);
|
|
10161
11904
|
settingsFile = resolved.target;
|
|
10162
11905
|
}
|
|
10163
|
-
rmSync2(
|
|
10164
|
-
const binary =
|
|
11906
|
+
rmSync2(join7(cHome, "skills", "theway"), { recursive: true, force: true });
|
|
11907
|
+
const binary = join7(installDir(), "theway");
|
|
10165
11908
|
const removed = isThewayBinary(binary);
|
|
10166
11909
|
if (removed)
|
|
10167
11910
|
rmSync2(binary, { force: true });
|
|
10168
11911
|
rmSync2(pointerPath(), { force: true });
|
|
10169
11912
|
removeIfEmpty2(dirname(pointerPath()));
|
|
10170
11913
|
if (existsSync3(settingsPath)) {
|
|
10171
|
-
const
|
|
10172
|
-
if (
|
|
11914
|
+
const settings2 = readSettings(settingsFile);
|
|
11915
|
+
if (settings2 === null)
|
|
10173
11916
|
return invalidSettings(settingsPath);
|
|
10174
|
-
const allow =
|
|
11917
|
+
const allow = settings2.permissions?.allow;
|
|
10175
11918
|
if (Array.isArray(allow)) {
|
|
10176
|
-
const drop = homes.flatMap((
|
|
10177
|
-
const kept = allow.filter((
|
|
11919
|
+
const drop = homes.flatMap((h2) => [...rules(h2), ...legacyRules(h2), editRule(h2)]);
|
|
11920
|
+
const kept = allow.filter((r2) => !(typeof r2 === "string" && drop.includes(r2)));
|
|
10178
11921
|
if (kept.length !== allow.length) {
|
|
10179
|
-
|
|
10180
|
-
writeSettings(settingsFile,
|
|
11922
|
+
settings2.permissions = { ...settings2.permissions, allow: kept };
|
|
11923
|
+
writeSettings(settingsFile, settings2);
|
|
10181
11924
|
}
|
|
10182
11925
|
}
|
|
10183
11926
|
}
|
|
@@ -10193,19 +11936,27 @@ var nonEmpty = (value) => {
|
|
|
10193
11936
|
throw new InvalidArgumentError("must not be empty");
|
|
10194
11937
|
return value;
|
|
10195
11938
|
};
|
|
11939
|
+
var positive = (value) => {
|
|
11940
|
+
if (!/^[1-9][0-9]*$/.test(value))
|
|
11941
|
+
throw new InvalidArgumentError("must be a positive integer");
|
|
11942
|
+
return Number(value);
|
|
11943
|
+
};
|
|
10196
11944
|
var exit = (code) => {
|
|
10197
11945
|
process.exitCode = code;
|
|
10198
11946
|
};
|
|
10199
11947
|
function buildProgram() {
|
|
10200
11948
|
const program2 = new Command("theway");
|
|
10201
|
-
program2.command("install").action(() => exit(install()));
|
|
11949
|
+
program2.command("install").option("--home <path>", "", nonEmpty).option("--standards <keys>").action(async (o2) => exit(await install({ home: o2.home, standards: o2.standards })));
|
|
10202
11950
|
program2.command("uninstall").action(() => exit(uninstall()));
|
|
10203
11951
|
program2.command("list").argument("<project>", "", nonEmpty).action((project) => exit(cmdList(project)));
|
|
10204
|
-
program2.command("archive").argument("<project>", "", nonEmpty).argument("<change-id>", "", nonEmpty).option("--force").action((project, change,
|
|
10205
|
-
program2.command("path").argument("[project]").argument("[change-id]").option("--verbose").action((project, change,
|
|
11952
|
+
program2.command("archive").argument("<project>", "", nonEmpty).argument("<change-id>", "", nonEmpty).option("--force").action((project, change, o2) => exit(cmdArchive(project, change, o2.force === true)));
|
|
11953
|
+
program2.command("path").argument("[project]").argument("[change-id]").option("--verbose").action((project, change, o2) => exit(cmdPath(project, change, o2.verbose === true)));
|
|
10206
11954
|
program2.command("config").argument("<project>").action((project) => exit(cmdConfig(project)));
|
|
10207
11955
|
program2.command("standards").argument("<project>").argument("<phase>").action((project, phase) => exit(cmdStandards(project, phase)));
|
|
10208
|
-
program2.command("
|
|
11956
|
+
program2.command("context").argument("<project>").argument("<phase>").argument("[change-id]").action((project, phase, change) => exit(cmdContext(project, phase, change)));
|
|
11957
|
+
program2.command("authority").action(() => exit(cmdAuthority()));
|
|
11958
|
+
program2.command("next-id").argument("<project>").argument("<series-id>").option("--count <n>", "", positive, 1).action((project, series, o2) => exit(cmdNextId(project, series, o2.count)));
|
|
11959
|
+
program2.command("validate-id").argument("<id>").option("--series").action((id, o2) => exit(cmdValidateId(id, o2.series === true)));
|
|
10209
11960
|
return program2;
|
|
10210
11961
|
}
|
|
10211
11962
|
|
|
@@ -10216,4 +11967,4 @@ if (major < 22 || major === 22 && minor < 12) {
|
|
|
10216
11967
|
`);
|
|
10217
11968
|
process.exit(1);
|
|
10218
11969
|
}
|
|
10219
|
-
buildProgram().
|
|
11970
|
+
buildProgram().parseAsync();
|