@donotdev/cli 0.2.2 → 0.3.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/dependencies-matrix.json +44 -42
- package/dist/bin/commands/agent-setup.js +135 -67
- package/dist/bin/commands/build.js +352 -234
- package/dist/bin/commands/bump.js +385 -257
- package/dist/bin/commands/cacheout.js +59 -49
- package/dist/bin/commands/coach.js +80 -50
- package/dist/bin/commands/create-app.js +501 -228
- package/dist/bin/commands/create-project.js +377 -241
- package/dist/bin/commands/db-check.js +192804 -0
- package/dist/bin/commands/db.js +1889 -1805
- package/dist/bin/commands/deploy.js +476 -287
- package/dist/bin/commands/dev.js +139 -108
- package/dist/bin/commands/doctor.js +91 -57
- package/dist/bin/commands/emu.js +196 -154
- package/dist/bin/commands/format.js +83 -50
- package/dist/bin/commands/get-demo.js +422 -197
- package/dist/bin/commands/make-admin.js +835 -713
- package/dist/bin/commands/preview.js +139 -108
- package/dist/bin/commands/seed.js +2186 -2044
- package/dist/bin/commands/setup-cicd.js +258 -204
- package/dist/bin/commands/setup.js +890 -339
- package/dist/bin/commands/staging.js +476 -287
- package/dist/bin/commands/sync-secrets.js +472 -141
- package/dist/bin/commands/type-check.js +163 -119
- package/dist/bin/commands/wai.js +53 -46
- package/dist/bin/dndev.js +32 -7
- package/dist/bin/donotdev.js +18 -8
- package/dist/index.js +654 -375
- package/package.json +2 -2
- package/templates/app-demo/index.html.example +1 -1
- package/templates/app-dndev/index.html.example +1 -1
- package/templates/app-dndev/src/globals.css.example +1 -1
- package/templates/app-dndev/src/pages/legal/LegalNoticePage.tsx.example +1 -1
- package/templates/app-dndev/src/pages/legal/PrivacyPage.tsx.example +1 -1
- package/templates/app-dndev/src/pages/legal/TermsPage.tsx.example +1 -1
- package/templates/app-next/src/app/AppDocument.tsx.example +58 -0
- package/templates/app-next/src/app/ClientLayout.tsx.example +6 -2
- package/templates/app-next/src/globals.css.example +1 -1
- package/templates/app-next/src/pages/legal/LegalNoticePage.tsx.example +1 -1
- package/templates/app-next/src/pages/legal/PrivacyPage.tsx.example +1 -1
- package/templates/app-next/src/pages/legal/TermsPage.tsx.example +1 -1
- package/templates/app-vite/csp.example.json +1 -1
- package/templates/app-vite/index.html.example +1 -1
- package/templates/app-vite/src/globals.css.example +1 -1
- package/templates/app-vite/src/pages/FormPageExample.tsx.example +21 -16
- package/templates/app-vite/src/pages/legal/LegalNoticePage.tsx.example +1 -1
- package/templates/app-vite/src/pages/legal/PrivacyPage.tsx.example +1 -1
- package/templates/app-vite/src/pages/legal/TermsPage.tsx.example +1 -1
- package/templates/deploy-config/vercel.json.example +2 -2
- package/templates/functions-supabase/supabase/migrations/20250101000006_crud_bulk_status_guard.sql +258 -0
- package/templates/functions-supabase/supabase/migrations/20250101000007_rate_limit_check.sql +76 -0
- package/templates/overlay-supabase/src/config/providers.nextjs.ts.example +37 -0
- package/templates/root-consumer/.claude/hooks/guard-bash.sh.example +3 -3
- package/templates/root-consumer/.claude/hooks/guard-write.sh.example +5 -1
- package/templates/root-consumer/.claude/hooks/typecheck-stop.sh.example +2 -2
- package/templates/root-consumer/.claude/rules/definition-of-done.md.example +2 -2
- package/templates/root-consumer/.claude/rules/framework.md.example +1 -1
- package/templates/root-consumer/.claude/skills/build/SKILL.md.example +1 -1
- package/templates/root-consumer/.claude/skills/polish/SKILL.md.example +1 -1
- package/templates/root-consumer/.gitignore.example +7 -1
- package/templates/root-consumer/AGENTS.md.example +25 -2
- package/templates/root-consumer/README.md.example +1 -1
- package/templates/app-next/src/app/layout.tsx.example +0 -80
- package/templates/app-next/src/app/not-found.tsx.example +0 -40
|
@@ -139,7 +139,7 @@ var init_dist = __esm({
|
|
|
139
139
|
if (index >= length) {
|
|
140
140
|
break outer;
|
|
141
141
|
}
|
|
142
|
-
for (let i2 = 0,
|
|
142
|
+
for (let i2 = 0, l = PARSE_BLOCKS.length; i2 < l; i2++) {
|
|
143
143
|
const [BLOCK_RE, BLOCK_WIDTH] = PARSE_BLOCKS[i2];
|
|
144
144
|
BLOCK_RE.lastIndex = index;
|
|
145
145
|
if (BLOCK_RE.test(input)) {
|
|
@@ -405,25 +405,29 @@ var init_main = __esm({
|
|
|
405
405
|
}
|
|
406
406
|
});
|
|
407
407
|
|
|
408
|
-
// node_modules/.bun/sisteransi@
|
|
409
|
-
var
|
|
410
|
-
|
|
411
|
-
|
|
408
|
+
// node_modules/.bun/sisteransi@2.0.0/node_modules/sisteransi/dist/index.js
|
|
409
|
+
var ESC2, CSI2, cursor, erase, clear;
|
|
410
|
+
var init_dist3 = __esm({
|
|
411
|
+
"node_modules/.bun/sisteransi@2.0.0/node_modules/sisteransi/dist/index.js"() {
|
|
412
412
|
init_utils2();
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
return `${CSI2}${
|
|
413
|
+
ESC2 = "\x1B";
|
|
414
|
+
CSI2 = `${ESC2}[`;
|
|
415
|
+
cursor = {
|
|
416
|
+
to(x, y) {
|
|
417
|
+
if (!y)
|
|
418
|
+
return `${CSI2}${x + 1}G`;
|
|
419
|
+
return `${CSI2}${y + 1};${x + 1}H`;
|
|
420
420
|
},
|
|
421
|
-
move(x,
|
|
421
|
+
move(x, y) {
|
|
422
422
|
let ret = "";
|
|
423
|
-
if (x < 0)
|
|
424
|
-
|
|
425
|
-
if (
|
|
426
|
-
|
|
423
|
+
if (x < 0)
|
|
424
|
+
ret += `${CSI2}${-x}D`;
|
|
425
|
+
else if (x > 0)
|
|
426
|
+
ret += `${CSI2}${x}C`;
|
|
427
|
+
if (y < 0)
|
|
428
|
+
ret += `${CSI2}${-y}A`;
|
|
429
|
+
else if (y > 0)
|
|
430
|
+
ret += `${CSI2}${y}B`;
|
|
427
431
|
return ret;
|
|
428
432
|
},
|
|
429
433
|
up: (count = 1) => `${CSI2}${count}A`,
|
|
@@ -438,11 +442,7 @@ var require_src = __commonJS({
|
|
|
438
442
|
save: `${ESC2}7`,
|
|
439
443
|
restore: `${ESC2}8`
|
|
440
444
|
};
|
|
441
|
-
|
|
442
|
-
up: (count = 1) => `${CSI2}S`.repeat(count),
|
|
443
|
-
down: (count = 1) => `${CSI2}T`.repeat(count)
|
|
444
|
-
};
|
|
445
|
-
var erase3 = {
|
|
445
|
+
erase = {
|
|
446
446
|
screen: `${CSI2}2J`,
|
|
447
447
|
up: (count = 1) => `${CSI2}1J`.repeat(count),
|
|
448
448
|
down: (count = 1) => `${CSI2}J`.repeat(count),
|
|
@@ -450,29 +450,31 @@ var require_src = __commonJS({
|
|
|
450
450
|
lineEnd: `${CSI2}K`,
|
|
451
451
|
lineStart: `${CSI2}1K`,
|
|
452
452
|
lines(count) {
|
|
453
|
-
let
|
|
453
|
+
let clear2 = "";
|
|
454
454
|
for (let i2 = 0; i2 < count; i2++)
|
|
455
|
-
|
|
455
|
+
clear2 += this.line + (i2 < count - 1 ? cursor.up() : "");
|
|
456
456
|
if (count)
|
|
457
|
-
|
|
458
|
-
return
|
|
457
|
+
clear2 += cursor.left;
|
|
458
|
+
return clear2;
|
|
459
459
|
}
|
|
460
460
|
};
|
|
461
|
-
|
|
461
|
+
clear = {
|
|
462
|
+
screen: `${ESC2}c`
|
|
463
|
+
};
|
|
462
464
|
}
|
|
463
465
|
});
|
|
464
466
|
|
|
465
|
-
// node_modules/.bun/@clack+core@1.
|
|
467
|
+
// node_modules/.bun/@clack+core@1.6.0/node_modules/@clack/core/dist/index.mjs
|
|
466
468
|
import { styleText } from "node:util";
|
|
467
469
|
import { stdout, stdin } from "node:process";
|
|
468
|
-
import * as
|
|
469
|
-
import
|
|
470
|
+
import * as f$1 from "node:readline";
|
|
471
|
+
import f__default from "node:readline";
|
|
470
472
|
import { ReadStream } from "node:tty";
|
|
471
|
-
function findCursor(
|
|
472
|
-
if (!
|
|
473
|
-
return
|
|
474
|
-
const t2 =
|
|
475
|
-
return
|
|
473
|
+
function findCursor(o, s, l) {
|
|
474
|
+
if (!l.some((r2) => !r2.disabled))
|
|
475
|
+
return o;
|
|
476
|
+
const t2 = o + s, n2 = Math.max(l.length - 1, 0), e = t2 < 0 ? n2 : t2 > n2 ? 0 : t2;
|
|
477
|
+
return l[e]?.disabled ? findCursor(e, s < 0 ? -1 : 1, l) : e;
|
|
476
478
|
}
|
|
477
479
|
function isAccessible(n2) {
|
|
478
480
|
if (n2 !== void 0) return n2;
|
|
@@ -515,40 +517,40 @@ function block({
|
|
|
515
517
|
overwrite: o = true,
|
|
516
518
|
hideCursor: n2 = true
|
|
517
519
|
} = {}) {
|
|
518
|
-
const s =
|
|
520
|
+
const s = f$1.createInterface({
|
|
519
521
|
input: e,
|
|
520
522
|
output: r2,
|
|
521
523
|
prompt: "",
|
|
522
524
|
tabSize: 1
|
|
523
525
|
});
|
|
524
|
-
|
|
525
|
-
const t2 = (
|
|
526
|
-
const
|
|
527
|
-
if (isActionKey([
|
|
528
|
-
n2 && r2.write(
|
|
526
|
+
f$1.emitKeypressEvents(e, s), e instanceof ReadStream && e.isTTY && e.setRawMode(true);
|
|
527
|
+
const t2 = (l, { name: i2, sequence: p }) => {
|
|
528
|
+
const w = String(l);
|
|
529
|
+
if (isActionKey([w, i2, p], "cancel")) {
|
|
530
|
+
n2 && r2.write(cursor.show), process.exit(0);
|
|
529
531
|
return;
|
|
530
532
|
}
|
|
531
533
|
if (!o) return;
|
|
532
|
-
const
|
|
533
|
-
|
|
534
|
-
|
|
534
|
+
const c2 = i2 === "return" ? 0 : -1, a2 = i2 === "return" ? -1 : 0;
|
|
535
|
+
f$1.moveCursor(r2, c2, a2, () => {
|
|
536
|
+
f$1.clearLine(r2, 1, () => {
|
|
535
537
|
e.once("keypress", t2);
|
|
536
538
|
});
|
|
537
539
|
});
|
|
538
540
|
};
|
|
539
|
-
return n2 && r2.write(
|
|
540
|
-
e.off("keypress", t2), n2 && r2.write(
|
|
541
|
+
return n2 && r2.write(cursor.hide), e.once("keypress", t2), () => {
|
|
542
|
+
e.off("keypress", t2), n2 && r2.write(cursor.show), e instanceof ReadStream && e.isTTY && !R && e.setRawMode(false), s.terminal = false, s.close();
|
|
541
543
|
};
|
|
542
544
|
}
|
|
543
545
|
function wrapTextWithPrefix(e, r2, o, n2 = o, s = o, t2) {
|
|
544
|
-
const
|
|
545
|
-
return wrapAnsi(r2,
|
|
546
|
+
const l = getColumns(e ?? stdout), i2 = dist_default2(o);
|
|
547
|
+
return wrapAnsi(r2, l - i2, {
|
|
546
548
|
hard: true,
|
|
547
549
|
trim: false
|
|
548
550
|
}).split(`
|
|
549
|
-
`).map((
|
|
550
|
-
const
|
|
551
|
-
return
|
|
551
|
+
`).map((c2, a2, g) => {
|
|
552
|
+
const m2 = t2 ? t2(c2, a2) : c2;
|
|
553
|
+
return a2 === 0 ? `${n2}${m2}` : a2 === g.length - 1 ? `${s}${m2}` : `${o}${m2}`;
|
|
552
554
|
}).join(`
|
|
553
555
|
`);
|
|
554
556
|
}
|
|
@@ -559,12 +561,13 @@ function runValidation(e, a2) {
|
|
|
559
561
|
}
|
|
560
562
|
return e(a2);
|
|
561
563
|
}
|
|
562
|
-
var
|
|
563
|
-
var
|
|
564
|
-
"node_modules/.bun/@clack+core@1.
|
|
564
|
+
var a$1, t, settings, R, CANCEL_SYMBOL, getColumns, getRows, C$1, r, a;
|
|
565
|
+
var init_dist4 = __esm({
|
|
566
|
+
"node_modules/.bun/@clack+core@1.6.0/node_modules/@clack/core/dist/index.mjs"() {
|
|
565
567
|
init_utils2();
|
|
566
568
|
init_main();
|
|
567
|
-
|
|
569
|
+
init_dist3();
|
|
570
|
+
init_dist2();
|
|
568
571
|
a$1 = ["up", "down", "left", "right", "space", "enter", "cancel"];
|
|
569
572
|
t = [
|
|
570
573
|
"January",
|
|
@@ -613,7 +616,7 @@ var init_dist3 = __esm({
|
|
|
613
616
|
CANCEL_SYMBOL = /* @__PURE__ */ Symbol("clack:cancel");
|
|
614
617
|
getColumns = (e) => "columns" in e && typeof e.columns == "number" ? e.columns : 80;
|
|
615
618
|
getRows = (e) => "rows" in e && typeof e.rows == "number" ? e.rows : 20;
|
|
616
|
-
|
|
619
|
+
C$1 = class C {
|
|
617
620
|
input;
|
|
618
621
|
output;
|
|
619
622
|
_abortSignal;
|
|
@@ -695,16 +698,16 @@ var init_dist3 = __esm({
|
|
|
695
698
|
{ once: true }
|
|
696
699
|
);
|
|
697
700
|
}
|
|
698
|
-
this.rl =
|
|
701
|
+
this.rl = f__default.createInterface({
|
|
699
702
|
input: this.input,
|
|
700
703
|
tabSize: 2,
|
|
701
704
|
prompt: "",
|
|
702
705
|
escapeCodeTimeout: 50,
|
|
703
706
|
terminal: true
|
|
704
707
|
}), this.rl.prompt(), this.opts.initialUserInput !== void 0 && 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", () => {
|
|
705
|
-
this.output.write(
|
|
708
|
+
this.output.write(cursor.show), this.output.off("resize", this.render), setRawMode(this.input, false), t2(this.value);
|
|
706
709
|
}), this.once("cancel", () => {
|
|
707
|
-
this.output.write(
|
|
710
|
+
this.output.write(cursor.show), this.output.off("resize", this.render), setRawMode(this.input, false), t2(CANCEL_SYMBOL);
|
|
708
711
|
});
|
|
709
712
|
});
|
|
710
713
|
}
|
|
@@ -741,18 +744,18 @@ var init_dist3 = __esm({
|
|
|
741
744
|
`), setRawMode(this.input, false), this.rl?.close(), this.rl = void 0, this.emit(`${this.state}`, this.value), this.unsubscribe();
|
|
742
745
|
}
|
|
743
746
|
restoreCursor() {
|
|
744
|
-
const t2 = wrapAnsi(this._prevFrame,
|
|
747
|
+
const t2 = wrapAnsi(this._prevFrame, getColumns(this.output), { hard: true, trim: false }).split(`
|
|
745
748
|
`).length - 1;
|
|
746
|
-
this.output.write(
|
|
749
|
+
this.output.write(cursor.move(-999, t2 * -1));
|
|
747
750
|
}
|
|
748
751
|
render() {
|
|
749
|
-
const t2 = wrapAnsi(this._render(this) ?? "",
|
|
752
|
+
const t2 = wrapAnsi(this._render(this) ?? "", getColumns(this.output), {
|
|
750
753
|
hard: true,
|
|
751
754
|
trim: false
|
|
752
755
|
});
|
|
753
756
|
if (t2 !== this._prevFrame) {
|
|
754
757
|
if (this.state === "initial")
|
|
755
|
-
this.output.write(
|
|
758
|
+
this.output.write(cursor.hide);
|
|
756
759
|
else {
|
|
757
760
|
const e = diffLines(this._prevFrame, t2), i2 = getRows(this.output);
|
|
758
761
|
if (this.restoreCursor(), e) {
|
|
@@ -763,33 +766,33 @@ var init_dist3 = __esm({
|
|
|
763
766
|
return;
|
|
764
767
|
}
|
|
765
768
|
if (e.lines.length === 1) {
|
|
766
|
-
this.output.write(
|
|
769
|
+
this.output.write(cursor.move(0, n2 - r2)), this.output.write(erase.lines(1));
|
|
767
770
|
const o = t2.split(`
|
|
768
771
|
`);
|
|
769
|
-
this.output.write(o[n2]), this._prevFrame = t2, this.output.write(
|
|
772
|
+
this.output.write(o[n2]), this._prevFrame = t2, this.output.write(cursor.move(0, o.length - n2 - 1));
|
|
770
773
|
return;
|
|
771
774
|
} else if (e.lines.length > 1) {
|
|
772
775
|
if (s < r2)
|
|
773
776
|
n2 = s;
|
|
774
777
|
else {
|
|
775
778
|
const h2 = n2 - r2;
|
|
776
|
-
h2 > 0 && this.output.write(
|
|
779
|
+
h2 > 0 && this.output.write(cursor.move(0, h2));
|
|
777
780
|
}
|
|
778
|
-
this.output.write(
|
|
779
|
-
const
|
|
781
|
+
this.output.write(erase.down());
|
|
782
|
+
const m2 = t2.split(`
|
|
780
783
|
`).slice(n2);
|
|
781
|
-
this.output.write(
|
|
784
|
+
this.output.write(m2.join(`
|
|
782
785
|
`)), this._prevFrame = t2;
|
|
783
786
|
return;
|
|
784
787
|
}
|
|
785
788
|
}
|
|
786
|
-
this.output.write(
|
|
789
|
+
this.output.write(erase.down());
|
|
787
790
|
}
|
|
788
791
|
this.output.write(t2), this.state === "initial" && (this.state = "active"), this._prevFrame = t2;
|
|
789
792
|
}
|
|
790
793
|
}
|
|
791
794
|
};
|
|
792
|
-
r = class extends
|
|
795
|
+
r = class extends C$1 {
|
|
793
796
|
get cursor() {
|
|
794
797
|
return this.value ? 0 : 1;
|
|
795
798
|
}
|
|
@@ -800,13 +803,13 @@ var init_dist3 = __esm({
|
|
|
800
803
|
super(t2, false), this.value = !!t2.initialValue, this.on("userInput", () => {
|
|
801
804
|
this.value = this._value;
|
|
802
805
|
}), this.on("confirm", (i2) => {
|
|
803
|
-
this.output.write(
|
|
806
|
+
this.output.write(cursor.move(0, -1)), this.value = i2, this.state = "submit", this.close();
|
|
804
807
|
}), this.on("cursor", () => {
|
|
805
808
|
this.value = !this.value;
|
|
806
809
|
});
|
|
807
810
|
}
|
|
808
811
|
};
|
|
809
|
-
a = class extends
|
|
812
|
+
a = class extends C$1 {
|
|
810
813
|
options;
|
|
811
814
|
cursor = 0;
|
|
812
815
|
get _value() {
|
|
@@ -837,8 +840,8 @@ var init_dist3 = __esm({
|
|
|
837
840
|
this.options.findIndex(({ value: t2 }) => t2 === e.cursorAt),
|
|
838
841
|
0
|
|
839
842
|
);
|
|
840
|
-
this.cursor = this.options[i2]?.disabled ? findCursor(i2, 1, this.options) : i2, this.on("key", (t2,
|
|
841
|
-
|
|
843
|
+
this.cursor = this.options[i2]?.disabled ? findCursor(i2, 1, this.options) : i2, this.on("key", (t2, s) => {
|
|
844
|
+
s.name === "a" && this.toggleAll(), s.name === "i" && this.toggleInvert(), s.name === void 0 && t2 === "\u3000" && this.toggleValue();
|
|
842
845
|
}), this.on("cursor", (t2) => {
|
|
843
846
|
switch (t2) {
|
|
844
847
|
case "left":
|
|
@@ -859,7 +862,7 @@ var init_dist3 = __esm({
|
|
|
859
862
|
}
|
|
860
863
|
});
|
|
861
864
|
|
|
862
|
-
// node_modules/.bun/@clack+prompts@1.
|
|
865
|
+
// node_modules/.bun/@clack+prompts@1.9.0/node_modules/@clack/prompts/dist/index.mjs
|
|
863
866
|
import { styleText as styleText2, stripVTControlCharacters } from "node:util";
|
|
864
867
|
import process$1 from "node:process";
|
|
865
868
|
import { existsSync, lstatSync, readdirSync } from "node:fs";
|
|
@@ -870,22 +873,23 @@ function isUnicodeSupported() {
|
|
|
870
873
|
}
|
|
871
874
|
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";
|
|
872
875
|
}
|
|
873
|
-
function formatInstructionFooter(o,
|
|
874
|
-
const
|
|
875
|
-
|
|
876
|
+
function formatInstructionFooter(e, o, r2) {
|
|
877
|
+
const s = r2 ? `${styleText2("cyan", S_BAR)} ` : "", n2 = wrapTextWithPrefix(e, o.join(" \u2022 "), s).split(`
|
|
878
|
+
`);
|
|
879
|
+
return r2 && n2.push(styleText2("cyan", S_BAR_END)), n2;
|
|
876
880
|
}
|
|
877
|
-
var
|
|
878
|
-
var
|
|
879
|
-
"node_modules/.bun/@clack+prompts@1.
|
|
881
|
+
var unicode, isCI, unicodeOr, S_STEP_ACTIVE, S_STEP_CANCEL, S_STEP_ERROR, S_STEP_SUBMIT, S_BAR_START, S_BAR, S_BAR_END, S_BAR_START_RIGHT, S_BAR_END_RIGHT, S_RADIO_ACTIVE, S_RADIO_INACTIVE, S_CHECKBOX_ACTIVE, S_CHECKBOX_SELECTED, S_CHECKBOX_INACTIVE, S_PASSWORD_MASK, S_BAR_H, S_CORNER_TOP_RIGHT, S_CONNECT_LEFT, S_CORNER_BOTTOM_RIGHT, S_CORNER_BOTTOM_LEFT, S_CORNER_TOP_LEFT, S_INFO, S_SUCCESS, S_WARN, S_ERROR, symbol, symbolBar, E$1, limitOptions, confirm, MULTISELECT_INSTRUCTIONS, m, multiselect, log, cancel, intro, outro, W, C2, note, Y, Z, spinner, u2, SELECT_INSTRUCTIONS, i;
|
|
882
|
+
var init_dist5 = __esm({
|
|
883
|
+
"node_modules/.bun/@clack+prompts@1.9.0/node_modules/@clack/prompts/dist/index.mjs"() {
|
|
880
884
|
init_utils2();
|
|
881
|
-
|
|
882
|
-
|
|
885
|
+
init_dist4();
|
|
886
|
+
init_dist4();
|
|
883
887
|
init_main();
|
|
884
888
|
init_dist2();
|
|
885
|
-
|
|
889
|
+
init_dist3();
|
|
886
890
|
unicode = isUnicodeSupported();
|
|
887
891
|
isCI = () => process.env.CI === "true";
|
|
888
|
-
unicodeOr = (
|
|
892
|
+
unicodeOr = (e, o) => unicode ? e : o;
|
|
889
893
|
S_STEP_ACTIVE = unicodeOr("\u25C6", "*");
|
|
890
894
|
S_STEP_CANCEL = unicodeOr("\u25A0", "x");
|
|
891
895
|
S_STEP_ERROR = unicodeOr("\u25B2", "x");
|
|
@@ -911,8 +915,8 @@ var init_dist4 = __esm({
|
|
|
911
915
|
S_SUCCESS = unicodeOr("\u25C6", "*");
|
|
912
916
|
S_WARN = unicodeOr("\u25B2", "!");
|
|
913
917
|
S_ERROR = unicodeOr("\u25A0", "x");
|
|
914
|
-
symbol = (
|
|
915
|
-
switch (
|
|
918
|
+
symbol = (e) => {
|
|
919
|
+
switch (e) {
|
|
916
920
|
case "initial":
|
|
917
921
|
case "active":
|
|
918
922
|
return styleText2("cyan", S_STEP_ACTIVE);
|
|
@@ -926,8 +930,8 @@ var init_dist4 = __esm({
|
|
|
926
930
|
return styleText2("dim", S_STEP_ACTIVE);
|
|
927
931
|
}
|
|
928
932
|
};
|
|
929
|
-
symbolBar = (
|
|
930
|
-
switch (
|
|
933
|
+
symbolBar = (e) => {
|
|
934
|
+
switch (e) {
|
|
931
935
|
case "initial":
|
|
932
936
|
case "active":
|
|
933
937
|
return styleText2("cyan", S_BAR);
|
|
@@ -939,45 +943,45 @@ var init_dist4 = __esm({
|
|
|
939
943
|
return styleText2("green", S_BAR);
|
|
940
944
|
}
|
|
941
945
|
};
|
|
942
|
-
|
|
946
|
+
E$1 = (l, e, w, p, b, C3 = false) => {
|
|
943
947
|
let r2 = e, O = 0;
|
|
944
|
-
if (
|
|
948
|
+
if (C3)
|
|
945
949
|
for (let i2 = p - 1; i2 >= w; i2--) {
|
|
946
|
-
const m2 =
|
|
950
|
+
const m2 = l[i2];
|
|
947
951
|
if (m2 && (r2 -= m2.length), O++, r2 <= b) break;
|
|
948
952
|
}
|
|
949
953
|
else
|
|
950
954
|
for (let i2 = w; i2 < p; i2++) {
|
|
951
|
-
const m2 =
|
|
955
|
+
const m2 = l[i2];
|
|
952
956
|
if (m2 && (r2 -= m2.length), O++, r2 <= b) break;
|
|
953
957
|
}
|
|
954
958
|
return { lineCount: r2, removals: O };
|
|
955
959
|
};
|
|
956
960
|
limitOptions = ({
|
|
957
|
-
cursor:
|
|
961
|
+
cursor: l,
|
|
958
962
|
options: e,
|
|
959
963
|
style: w,
|
|
960
964
|
output: p = process.stdout,
|
|
961
965
|
maxItems: b = Number.POSITIVE_INFINITY,
|
|
962
|
-
columnPadding:
|
|
966
|
+
columnPadding: C3 = 0,
|
|
963
967
|
rowPadding: r2 = 4
|
|
964
968
|
}) => {
|
|
965
|
-
const i2 = getColumns(p) -
|
|
969
|
+
const i2 = getColumns(p) - C3, m2 = getRows(p), M = styleText2("dim", "..."), v = Math.max(m2 - r2, 0), a2 = Math.max(Math.min(b, v), 5);
|
|
966
970
|
let f = 0;
|
|
967
|
-
|
|
968
|
-
Math.min(
|
|
971
|
+
l >= a2 - 3 && (f = Math.max(
|
|
972
|
+
Math.min(l - a2 + 3, e.length - a2),
|
|
969
973
|
0
|
|
970
974
|
));
|
|
971
|
-
let d = a2 < e.length && f > 0,
|
|
972
|
-
const
|
|
975
|
+
let d = a2 < e.length && f > 0, c2 = a2 < e.length && f + a2 < e.length;
|
|
976
|
+
const I = Math.min(
|
|
973
977
|
f + a2,
|
|
974
978
|
e.length
|
|
975
979
|
), s = [];
|
|
976
980
|
let g = 0;
|
|
977
|
-
d && g++,
|
|
978
|
-
const T = f + (d ? 1 : 0),
|
|
979
|
-
for (let t2 = T; t2 <
|
|
980
|
-
const n2 = e[t2], o = n2 ? w(n2, t2 ===
|
|
981
|
+
d && g++, c2 && g++;
|
|
982
|
+
const T = f + (d ? 1 : 0), W2 = I - (c2 ? 1 : 0);
|
|
983
|
+
for (let t2 = T; t2 < W2; t2++) {
|
|
984
|
+
const n2 = e[t2], o = n2 !== void 0 ? w(n2, t2 === l) : "", h2 = wrapAnsi(o, i2, {
|
|
981
985
|
hard: true,
|
|
982
986
|
trim: false
|
|
983
987
|
}).split(`
|
|
@@ -986,9 +990,9 @@ var init_dist4 = __esm({
|
|
|
986
990
|
}
|
|
987
991
|
if (g > v) {
|
|
988
992
|
let t2 = 0, n2 = 0, o = g;
|
|
989
|
-
const h2 =
|
|
993
|
+
const h2 = l - T;
|
|
990
994
|
let u3 = v;
|
|
991
|
-
const L = () =>
|
|
995
|
+
const L = () => E$1(s, o, 0, h2, u3), y = () => E$1(
|
|
992
996
|
s,
|
|
993
997
|
o,
|
|
994
998
|
h2 + 1,
|
|
@@ -996,14 +1000,14 @@ var init_dist4 = __esm({
|
|
|
996
1000
|
u3,
|
|
997
1001
|
true
|
|
998
1002
|
);
|
|
999
|
-
d ? ({ lineCount: o, removals: t2 } = L(), o > u3 && (
|
|
1003
|
+
d ? ({ lineCount: o, removals: t2 } = L(), o > u3 && (c2 || (u3 -= 1), { lineCount: o, removals: n2 } = y())) : (c2 || (u3 -= 1), { lineCount: o, removals: n2 } = y(), o > u3 && (u3 -= 1, { lineCount: o, removals: t2 } = L())), t2 > 0 && (d = true, s.splice(0, t2)), n2 > 0 && (c2 = true, s.splice(s.length - n2, n2));
|
|
1000
1004
|
}
|
|
1001
1005
|
const x = [];
|
|
1002
1006
|
d && x.push(M);
|
|
1003
1007
|
for (const t2 of s)
|
|
1004
1008
|
for (const n2 of t2)
|
|
1005
1009
|
x.push(n2);
|
|
1006
|
-
return
|
|
1010
|
+
return c2 && x.push(M), x;
|
|
1007
1011
|
};
|
|
1008
1012
|
confirm = (e) => {
|
|
1009
1013
|
const a2 = e.active ?? "Yes", o = e.inactive ?? "No";
|
|
@@ -1015,22 +1019,22 @@ var init_dist4 = __esm({
|
|
|
1015
1019
|
output: e.output,
|
|
1016
1020
|
initialValue: e.initialValue ?? true,
|
|
1017
1021
|
render() {
|
|
1018
|
-
const i2 = e.withGuide ?? settings.withGuide, u3 = `${symbol(this.state)} `,
|
|
1022
|
+
const i2 = e.withGuide ?? settings.withGuide, u3 = `${symbol(this.state)} `, l = i2 ? `${styleText2("gray", S_BAR)} ` : "", f = wrapTextWithPrefix(
|
|
1019
1023
|
e.output,
|
|
1020
1024
|
e.message,
|
|
1021
|
-
|
|
1025
|
+
l,
|
|
1022
1026
|
u3
|
|
1023
1027
|
), s = `${i2 ? `${styleText2("gray", S_BAR)}
|
|
1024
1028
|
` : ""}${f}
|
|
1025
|
-
`,
|
|
1029
|
+
`, c2 = this.value ? a2 : o;
|
|
1026
1030
|
switch (this.state) {
|
|
1027
1031
|
case "submit": {
|
|
1028
1032
|
const r2 = i2 ? `${styleText2("gray", S_BAR)} ` : "";
|
|
1029
|
-
return `${s}${r2}${styleText2("dim",
|
|
1033
|
+
return `${s}${r2}${styleText2("dim", c2)}`;
|
|
1030
1034
|
}
|
|
1031
1035
|
case "cancel": {
|
|
1032
1036
|
const r2 = i2 ? `${styleText2("gray", S_BAR)} ` : "";
|
|
1033
|
-
return `${s}${r2}${styleText2(["strikethrough", "dim"],
|
|
1037
|
+
return `${s}${r2}${styleText2(["strikethrough", "dim"], c2)}${i2 ? `
|
|
1034
1038
|
${styleText2("gray", S_BAR)}` : ""}`;
|
|
1035
1039
|
}
|
|
1036
1040
|
default: {
|
|
@@ -1050,22 +1054,22 @@ ${g}
|
|
|
1050
1054
|
`${styleText2("dim", "Space:")} select`,
|
|
1051
1055
|
`${styleText2("dim", "Enter:")} confirm`
|
|
1052
1056
|
];
|
|
1053
|
-
m = (
|
|
1057
|
+
m = (n2, u3) => n2.split(`
|
|
1054
1058
|
`).map((d) => u3(d)).join(`
|
|
1055
1059
|
`);
|
|
1056
|
-
multiselect = (
|
|
1060
|
+
multiselect = (n2) => {
|
|
1057
1061
|
const u3 = (t2, a2) => {
|
|
1058
1062
|
const r2 = t2.label ?? String(t2.value);
|
|
1059
1063
|
return a2 === "disabled" ? `${styleText2("gray", S_CHECKBOX_INACTIVE)} ${m(r2, (o) => styleText2(["strikethrough", "gray"], o))}${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)} ${m(r2, (o) => styleText2("dim", o))}${t2.hint ? ` ${styleText2("dim", `(${t2.hint})`)}` : ""}` : a2 === "cancelled" ? `${m(r2, (o) => styleText2(["strikethrough", "dim"], o))}` : a2 === "active-selected" ? `${styleText2("green", S_CHECKBOX_SELECTED)} ${r2}${t2.hint ? ` ${styleText2("dim", `(${t2.hint})`)}` : ""}` : a2 === "submitted" ? `${m(r2, (o) => styleText2("dim", o))}` : `${styleText2("dim", S_CHECKBOX_INACTIVE)} ${m(r2, (o) => styleText2("dim", o))}`;
|
|
1060
|
-
}, d =
|
|
1064
|
+
}, d = n2.required ?? true, x = n2.showInstructions ?? true;
|
|
1061
1065
|
return new a({
|
|
1062
|
-
options:
|
|
1063
|
-
signal:
|
|
1064
|
-
input:
|
|
1065
|
-
output:
|
|
1066
|
-
initialValues:
|
|
1066
|
+
options: n2.options,
|
|
1067
|
+
signal: n2.signal,
|
|
1068
|
+
input: n2.input,
|
|
1069
|
+
output: n2.output,
|
|
1070
|
+
initialValues: n2.initialValues,
|
|
1067
1071
|
required: d,
|
|
1068
|
-
cursorAt:
|
|
1072
|
+
cursorAt: n2.cursorAt,
|
|
1069
1073
|
validate(t2) {
|
|
1070
1074
|
if (d && (t2 === void 0 || t2.length === 0))
|
|
1071
1075
|
return `Please select at least one option.
|
|
@@ -1081,75 +1085,75 @@ ${styleText2(
|
|
|
1081
1085
|
)}`;
|
|
1082
1086
|
},
|
|
1083
1087
|
render() {
|
|
1084
|
-
const t2 =
|
|
1085
|
-
|
|
1086
|
-
|
|
1088
|
+
const t2 = n2.withGuide ?? settings.withGuide, a2 = wrapTextWithPrefix(
|
|
1089
|
+
n2.output,
|
|
1090
|
+
n2.message,
|
|
1087
1091
|
t2 ? `${symbolBar(this.state)} ` : "",
|
|
1088
1092
|
`${symbol(this.state)} `
|
|
1089
1093
|
), r2 = `${t2 ? `${styleText2("gray", S_BAR)}
|
|
1090
1094
|
` : ""}${a2}
|
|
1091
|
-
`, o = this.value ?? [], g = (
|
|
1092
|
-
if (
|
|
1093
|
-
return u3(
|
|
1094
|
-
const s = o.includes(
|
|
1095
|
-
return
|
|
1095
|
+
`, o = this.value ?? [], g = (i2, l) => {
|
|
1096
|
+
if (i2.disabled)
|
|
1097
|
+
return u3(i2, "disabled");
|
|
1098
|
+
const s = o.includes(i2.value);
|
|
1099
|
+
return l && s ? u3(i2, "active-selected") : s ? u3(i2, "selected") : u3(i2, l ? "active" : "inactive");
|
|
1096
1100
|
};
|
|
1097
1101
|
switch (this.state) {
|
|
1098
1102
|
case "submit": {
|
|
1099
|
-
const
|
|
1100
|
-
|
|
1101
|
-
|
|
1103
|
+
const i2 = this.options.filter(({ value: s }) => o.includes(s)).map((s) => u3(s, "submitted")).join(styleText2("dim", ", ")) || styleText2("dim", "none"), l = wrapTextWithPrefix(
|
|
1104
|
+
n2.output,
|
|
1105
|
+
i2,
|
|
1102
1106
|
t2 ? `${styleText2("gray", S_BAR)} ` : ""
|
|
1103
1107
|
);
|
|
1104
|
-
return `${r2}${
|
|
1108
|
+
return `${r2}${l}`;
|
|
1105
1109
|
}
|
|
1106
1110
|
case "cancel": {
|
|
1107
|
-
const
|
|
1108
|
-
if (
|
|
1111
|
+
const i2 = this.options.filter(({ value: s }) => o.includes(s)).map((s) => u3(s, "cancelled")).join(styleText2("dim", ", "));
|
|
1112
|
+
if (i2.trim() === "")
|
|
1109
1113
|
return `${r2}${styleText2("gray", S_BAR)}`;
|
|
1110
|
-
const
|
|
1111
|
-
|
|
1112
|
-
|
|
1114
|
+
const l = wrapTextWithPrefix(
|
|
1115
|
+
n2.output,
|
|
1116
|
+
i2,
|
|
1113
1117
|
t2 ? `${styleText2("gray", S_BAR)} ` : ""
|
|
1114
1118
|
);
|
|
1115
|
-
return `${r2}${
|
|
1119
|
+
return `${r2}${l}${t2 ? `
|
|
1116
1120
|
${styleText2("gray", S_BAR)}` : ""}`;
|
|
1117
1121
|
}
|
|
1118
1122
|
case "error": {
|
|
1119
|
-
const
|
|
1123
|
+
const i2 = t2 ? `${styleText2("yellow", S_BAR)} ` : "", l = this.error.split(`
|
|
1120
1124
|
`).map(
|
|
1121
1125
|
($, v) => v === 0 ? `${t2 ? `${styleText2("yellow", S_BAR_END)} ` : ""}${styleText2("yellow", $)}` : ` ${$}`
|
|
1122
1126
|
).join(`
|
|
1123
1127
|
`), s = r2.split(`
|
|
1124
|
-
`).length, h2 =
|
|
1128
|
+
`).length, h2 = l.split(`
|
|
1125
1129
|
`).length + 1;
|
|
1126
|
-
return `${r2}${
|
|
1127
|
-
output:
|
|
1130
|
+
return `${r2}${i2}${limitOptions({
|
|
1131
|
+
output: n2.output,
|
|
1128
1132
|
options: this.options,
|
|
1129
1133
|
cursor: this.cursor,
|
|
1130
|
-
maxItems:
|
|
1131
|
-
columnPadding:
|
|
1134
|
+
maxItems: n2.maxItems,
|
|
1135
|
+
columnPadding: i2.length,
|
|
1132
1136
|
rowPadding: s + h2,
|
|
1133
1137
|
style: g
|
|
1134
1138
|
}).join(`
|
|
1135
|
-
${
|
|
1136
|
-
${
|
|
1139
|
+
${i2}`)}
|
|
1140
|
+
${l}
|
|
1137
1141
|
`;
|
|
1138
1142
|
}
|
|
1139
1143
|
default: {
|
|
1140
|
-
const
|
|
1141
|
-
`).length, s = x ? formatInstructionFooter(MULTISELECT_INSTRUCTIONS, t2) : t2 ? [styleText2("cyan", S_BAR_END)] : [], h2 = s.join(`
|
|
1144
|
+
const i2 = t2 ? `${styleText2("cyan", S_BAR)} ` : "", l = r2.split(`
|
|
1145
|
+
`).length, s = x ? formatInstructionFooter(n2.output, MULTISELECT_INSTRUCTIONS, t2) : t2 ? [styleText2("cyan", S_BAR_END)] : [], h2 = s.join(`
|
|
1142
1146
|
`), $ = s.length + 1;
|
|
1143
|
-
return `${r2}${
|
|
1144
|
-
output:
|
|
1147
|
+
return `${r2}${i2}${limitOptions({
|
|
1148
|
+
output: n2.output,
|
|
1145
1149
|
options: this.options,
|
|
1146
1150
|
cursor: this.cursor,
|
|
1147
|
-
maxItems:
|
|
1148
|
-
columnPadding:
|
|
1149
|
-
rowPadding:
|
|
1151
|
+
maxItems: n2.maxItems,
|
|
1152
|
+
columnPadding: i2.length,
|
|
1153
|
+
rowPadding: l + $,
|
|
1150
1154
|
style: g
|
|
1151
1155
|
}).join(`
|
|
1152
|
-
${
|
|
1156
|
+
${i2}`)}
|
|
1153
1157
|
${h2}
|
|
1154
1158
|
`;
|
|
1155
1159
|
}
|
|
@@ -1162,18 +1166,18 @@ ${h2}
|
|
|
1162
1166
|
symbol: e = styleText2("gray", S_BAR),
|
|
1163
1167
|
secondarySymbol: r2 = styleText2("gray", S_BAR),
|
|
1164
1168
|
output: m2 = process.stdout,
|
|
1165
|
-
spacing:
|
|
1166
|
-
withGuide:
|
|
1169
|
+
spacing: l = 1,
|
|
1170
|
+
withGuide: c2
|
|
1167
1171
|
} = {}) => {
|
|
1168
|
-
const t2 = [], o =
|
|
1169
|
-
for (let i2 = 0; i2 <
|
|
1172
|
+
const t2 = [], o = c2 ?? settings.withGuide, f = o ? r2 : "", O = o ? `${e} ` : "", u3 = o ? `${r2} ` : "";
|
|
1173
|
+
for (let i2 = 0; i2 < l; i2++)
|
|
1170
1174
|
t2.push(f);
|
|
1171
1175
|
const g = Array.isArray(s) ? s : s.split(`
|
|
1172
1176
|
`);
|
|
1173
1177
|
if (g.length > 0) {
|
|
1174
|
-
const [i2, ...
|
|
1178
|
+
const [i2, ...y] = g;
|
|
1175
1179
|
i2.length > 0 ? t2.push(`${O}${i2}`) : t2.push(o ? e : "");
|
|
1176
|
-
for (const p of
|
|
1180
|
+
for (const p of y)
|
|
1177
1181
|
p.length > 0 ? t2.push(`${u3}${p}`) : t2.push(o ? r2 : "");
|
|
1178
1182
|
}
|
|
1179
1183
|
m2.write(`${t2.join(`
|
|
@@ -1218,18 +1222,18 @@ ${styleText2("gray", S_BAR_END)} ` : "";
|
|
|
1218
1222
|
|
|
1219
1223
|
`);
|
|
1220
1224
|
};
|
|
1221
|
-
W
|
|
1222
|
-
|
|
1225
|
+
W = (o) => o;
|
|
1226
|
+
C2 = (o, e, s) => {
|
|
1223
1227
|
const a2 = {
|
|
1224
1228
|
hard: true,
|
|
1225
1229
|
trim: false
|
|
1226
1230
|
}, i2 = wrapAnsi(o, e, a2).split(`
|
|
1227
|
-
`),
|
|
1231
|
+
`), c2 = i2.reduce((n2, t2) => Math.max(dist_default2(t2), n2), 0), u3 = i2.map(s).reduce((n2, t2) => Math.max(dist_default2(t2), n2), 0), g = e - (u3 - c2);
|
|
1228
1232
|
return wrapAnsi(o, g, a2);
|
|
1229
1233
|
};
|
|
1230
1234
|
note = (o = "", e = "", s) => {
|
|
1231
|
-
const a2 = s?.output ?? process$1.stdout, i2 = s?.withGuide ?? settings.withGuide,
|
|
1232
|
-
`).map(
|
|
1235
|
+
const a2 = s?.output ?? process$1.stdout, i2 = s?.withGuide ?? settings.withGuide, c2 = s?.format ?? W, g = ["", ...C2(o, getColumns(a2) - 6, c2).split(`
|
|
1236
|
+
`).map(c2), ""], n2 = dist_default2(e), t2 = Math.max(
|
|
1233
1237
|
g.reduce((m2, F) => {
|
|
1234
1238
|
const O = dist_default2(F);
|
|
1235
1239
|
return O > m2 ? O : m2;
|
|
@@ -1250,83 +1254,102 @@ ${styleText2("gray", l$1 + S_BAR_H.repeat(t2 + 2) + S_CORNER_BOTTOM_RIGHT)}
|
|
|
1250
1254
|
`
|
|
1251
1255
|
);
|
|
1252
1256
|
};
|
|
1253
|
-
|
|
1257
|
+
Y = 3e4;
|
|
1258
|
+
Z = (c2) => styleText2("magenta", c2);
|
|
1254
1259
|
spinner = ({
|
|
1255
|
-
indicator:
|
|
1256
|
-
onCancel:
|
|
1260
|
+
indicator: c2 = "dots",
|
|
1261
|
+
onCancel: b,
|
|
1257
1262
|
output: n2 = process.stdout,
|
|
1258
|
-
cancelMessage:
|
|
1259
|
-
errorMessage:
|
|
1260
|
-
frames:
|
|
1261
|
-
delay:
|
|
1262
|
-
signal:
|
|
1263
|
-
...
|
|
1263
|
+
cancelMessage: _,
|
|
1264
|
+
errorMessage: C3,
|
|
1265
|
+
frames: M = unicode ? ["\u25D2", "\u25D0", "\u25D3", "\u25D1"] : ["\u2022", "o", "O", "0"],
|
|
1266
|
+
delay: O = unicode ? 80 : 120,
|
|
1267
|
+
signal: g,
|
|
1268
|
+
...E
|
|
1264
1269
|
} = {}) => {
|
|
1265
|
-
const u3 = isCI();
|
|
1266
|
-
let
|
|
1267
|
-
const
|
|
1268
|
-
const
|
|
1269
|
-
|
|
1270
|
-
},
|
|
1271
|
-
process.on("uncaughtExceptionMonitor",
|
|
1272
|
-
},
|
|
1273
|
-
process.removeListener("uncaughtExceptionMonitor",
|
|
1274
|
-
},
|
|
1275
|
-
if (
|
|
1270
|
+
const u3 = isCI(), h2 = isAccessible(E.accessible);
|
|
1271
|
+
let x, I, p = false, l = false, r2 = "", v, w = performance.now();
|
|
1272
|
+
const y = getColumns(n2), F = E?.styleFrame ?? Z, S = (e) => {
|
|
1273
|
+
const s = e > 1 ? C3 ?? settings.messages.error : _ ?? settings.messages.cancel;
|
|
1274
|
+
l = e === 1, p && (m2(s, e), l && typeof b == "function" && b());
|
|
1275
|
+
}, $ = () => S(2), a2 = () => S(1), H = () => {
|
|
1276
|
+
process.on("uncaughtExceptionMonitor", $), process.on("unhandledRejection", $), process.on("SIGINT", a2), process.on("SIGTERM", a2), process.on("exit", S), g && g.addEventListener("abort", a2);
|
|
1277
|
+
}, B = () => {
|
|
1278
|
+
process.removeListener("uncaughtExceptionMonitor", $), process.removeListener("unhandledRejection", $), process.removeListener("SIGINT", a2), process.removeListener("SIGTERM", a2), process.removeListener("exit", S), g && g.removeEventListener("abort", a2);
|
|
1279
|
+
}, R2 = () => {
|
|
1280
|
+
if (v === void 0) return;
|
|
1276
1281
|
u3 && n2.write(`
|
|
1277
1282
|
`);
|
|
1278
|
-
const
|
|
1283
|
+
const s = wrapAnsi(v, y, {
|
|
1279
1284
|
hard: true,
|
|
1280
1285
|
trim: false
|
|
1281
1286
|
}).split(`
|
|
1282
1287
|
`);
|
|
1283
|
-
|
|
1284
|
-
},
|
|
1285
|
-
const
|
|
1286
|
-
return
|
|
1287
|
-
}, N =
|
|
1288
|
-
|
|
1288
|
+
s.length > 1 && n2.write(cursor.up(s.length - 1)), n2.write(cursor.to(0)), n2.write(erase.down());
|
|
1289
|
+
}, L = (e) => e.replace(/\.+$/, ""), T = (e) => {
|
|
1290
|
+
const s = (performance.now() - e) / 1e3, i2 = Math.floor(s / 60), t2 = Math.floor(s % 60);
|
|
1291
|
+
return i2 > 0 ? `[${i2}m ${t2}s]` : `[${t2}s]`;
|
|
1292
|
+
}, N = E.withGuide ?? settings.withGuide, P = (e = "") => {
|
|
1293
|
+
if (p = true, l = false, r2 = L(e), w = performance.now(), H(), h2) {
|
|
1294
|
+
r2 !== "" && n2.write(`${r2}
|
|
1295
|
+
`), I = setInterval(() => {
|
|
1296
|
+
n2.write(r2 === "" ? `still working
|
|
1297
|
+
` : `still working: ${r2}
|
|
1289
1298
|
`);
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1299
|
+
}, Y);
|
|
1300
|
+
return;
|
|
1301
|
+
}
|
|
1302
|
+
x = block({ output: n2 }), N && n2.write(`${styleText2("gray", S_BAR)}
|
|
1303
|
+
`);
|
|
1304
|
+
let s = 0, i2 = 0;
|
|
1305
|
+
I = setInterval(() => {
|
|
1306
|
+
if (u3 && r2 === v)
|
|
1293
1307
|
return;
|
|
1294
|
-
|
|
1295
|
-
const
|
|
1296
|
-
let
|
|
1308
|
+
R2(), v = r2;
|
|
1309
|
+
const t2 = F(M[s]);
|
|
1310
|
+
let o;
|
|
1297
1311
|
if (u3)
|
|
1298
|
-
|
|
1299
|
-
else if (
|
|
1300
|
-
|
|
1312
|
+
o = `${t2} ${r2}...`;
|
|
1313
|
+
else if (c2 === "timer")
|
|
1314
|
+
o = `${t2} ${r2} ${T(w)}`;
|
|
1301
1315
|
else {
|
|
1302
|
-
const
|
|
1303
|
-
|
|
1316
|
+
const j = ".".repeat(Math.floor(i2)).slice(0, 3);
|
|
1317
|
+
o = `${t2} ${r2}${j}`;
|
|
1304
1318
|
}
|
|
1305
|
-
const
|
|
1319
|
+
const D = wrapAnsi(o, y, {
|
|
1306
1320
|
hard: true,
|
|
1307
1321
|
trim: false
|
|
1308
1322
|
});
|
|
1309
|
-
n2.write(
|
|
1310
|
-
},
|
|
1311
|
-
},
|
|
1312
|
-
if (
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
`)
|
|
1323
|
+
n2.write(D), s = s + 1 < M.length ? s + 1 : 0, i2 = i2 < 4 ? i2 + 0.125 : 0;
|
|
1324
|
+
}, O);
|
|
1325
|
+
}, m2 = (e = "", s = 0, i2 = false) => {
|
|
1326
|
+
if (p) {
|
|
1327
|
+
if (p = false, l = s === 1, clearInterval(I), h2 || R2(), r2 = e ?? r2, !i2)
|
|
1328
|
+
if (h2) {
|
|
1329
|
+
const t2 = s === 1 ? _ ?? settings.messages.cancel : s === 2 ? C3 ?? settings.messages.error : "Done", o = r2 || t2;
|
|
1330
|
+
c2 === "timer" ? n2.write(`${o} ${T(w)}
|
|
1331
|
+
`) : n2.write(`${o}
|
|
1332
|
+
`);
|
|
1333
|
+
} else {
|
|
1334
|
+
const t2 = s === 0 ? styleText2("green", S_STEP_SUBMIT) : s === 1 ? styleText2("red", S_STEP_CANCEL) : styleText2("red", S_STEP_ERROR);
|
|
1335
|
+
c2 === "timer" ? n2.write(`${t2} ${r2} ${T(w)}
|
|
1336
|
+
`) : n2.write(`${t2} ${r2}
|
|
1337
|
+
`);
|
|
1338
|
+
}
|
|
1339
|
+
B(), x?.();
|
|
1340
|
+
}
|
|
1318
1341
|
};
|
|
1319
1342
|
return {
|
|
1320
1343
|
start: P,
|
|
1321
|
-
stop: (e = "") =>
|
|
1344
|
+
stop: (e = "") => m2(e, 0),
|
|
1322
1345
|
message: (e = "") => {
|
|
1323
|
-
|
|
1346
|
+
r2 = L(e ?? r2);
|
|
1324
1347
|
},
|
|
1325
|
-
cancel: (e = "") =>
|
|
1326
|
-
error: (e = "") =>
|
|
1327
|
-
clear: () =>
|
|
1348
|
+
cancel: (e = "") => m2(e, 1),
|
|
1349
|
+
error: (e = "") => m2(e, 2),
|
|
1350
|
+
clear: () => m2("", 0, true),
|
|
1328
1351
|
get isCancelled() {
|
|
1329
|
-
return
|
|
1352
|
+
return l;
|
|
1330
1353
|
}
|
|
1331
1354
|
};
|
|
1332
1355
|
};
|
|
@@ -1389,8 +1412,8 @@ var init_cli_output = __esm({
|
|
|
1389
1412
|
"packages/tooling/src/utils/cli-output.ts"() {
|
|
1390
1413
|
"use strict";
|
|
1391
1414
|
init_utils2();
|
|
1392
|
-
|
|
1393
|
-
|
|
1415
|
+
init_dist5();
|
|
1416
|
+
init_dist5();
|
|
1394
1417
|
colors = {
|
|
1395
1418
|
reset: "\x1B[0m",
|
|
1396
1419
|
// Success (green)
|
|
@@ -1541,7 +1564,7 @@ var init_errors = __esm({
|
|
|
1541
1564
|
* @param {DoNotDevErrorCode} code - Error code
|
|
1542
1565
|
* @param {object} [options] - Additional error options
|
|
1543
1566
|
* @param {Error} [options.originalError] - Original error if wrapping
|
|
1544
|
-
* @param {Record<string,
|
|
1567
|
+
* @param {Record<string, unknown>} [options.context] - Additional context data
|
|
1545
1568
|
* @param {boolean} [options.displayable=true] - Whether this error should be displayed to the user
|
|
1546
1569
|
*/
|
|
1547
1570
|
constructor(message, code = DO_NOT_DEV_ERROR_CODES.UNKNOWN_ERROR, options) {
|
|
@@ -1571,7 +1594,7 @@ var init_errors = __esm({
|
|
|
1571
1594
|
* @param {string} [context] - Additional context for the error
|
|
1572
1595
|
* @param {DoNotDevErrorCode} [code='unknown-error'] - Error code
|
|
1573
1596
|
* @param {object} [options] - Additional error options
|
|
1574
|
-
* @param {Record<string,
|
|
1597
|
+
* @param {Record<string, unknown>} [options.context] - Additional context data
|
|
1575
1598
|
* @param {boolean} [options.displayable=true] - Whether this error should be displayed to the user
|
|
1576
1599
|
* @returns {DoNotDevError} New DoNotDev error wrapping the original
|
|
1577
1600
|
*/
|
|
@@ -7622,6 +7645,9 @@ import {
|
|
|
7622
7645
|
extname
|
|
7623
7646
|
} from "node:path";
|
|
7624
7647
|
import { fileURLToPath } from "node:url";
|
|
7648
|
+
function isEexistError(error2) {
|
|
7649
|
+
return typeof error2 === "object" && error2 !== null && "code" in error2 && error2.code === "EEXIST";
|
|
7650
|
+
}
|
|
7625
7651
|
function safeExecuteAsync(fn, message) {
|
|
7626
7652
|
return fn().catch((error2) => {
|
|
7627
7653
|
throw new Error(
|
|
@@ -7993,7 +8019,7 @@ var init_PathResolver = __esm({
|
|
|
7993
8019
|
try {
|
|
7994
8020
|
await fs.promises.mkdir(dir, { recursive: true });
|
|
7995
8021
|
} catch (error2) {
|
|
7996
|
-
if (error2
|
|
8022
|
+
if (!isEexistError(error2)) throw error2;
|
|
7997
8023
|
}
|
|
7998
8024
|
const detectedFormat = this._detectFormat(filePath, format);
|
|
7999
8025
|
let writeContent;
|
|
@@ -8055,7 +8081,7 @@ var init_PathResolver = __esm({
|
|
|
8055
8081
|
try {
|
|
8056
8082
|
fs.mkdirSync(dir, { recursive: true });
|
|
8057
8083
|
} catch (error2) {
|
|
8058
|
-
if (error2
|
|
8084
|
+
if (!isEexistError(error2)) throw error2;
|
|
8059
8085
|
}
|
|
8060
8086
|
const detectedFormat = this._detectFormat(filePath, format);
|
|
8061
8087
|
let writeContent;
|
|
@@ -8112,7 +8138,7 @@ var init_PathResolver = __esm({
|
|
|
8112
8138
|
try {
|
|
8113
8139
|
await fs.promises.mkdir(dir, { recursive: true });
|
|
8114
8140
|
} catch (error2) {
|
|
8115
|
-
if (error2
|
|
8141
|
+
if (!isEexistError(error2)) throw error2;
|
|
8116
8142
|
}
|
|
8117
8143
|
try {
|
|
8118
8144
|
return await safeExecuteAsync(async () => {
|
|
@@ -8154,7 +8180,7 @@ var init_PathResolver = __esm({
|
|
|
8154
8180
|
try {
|
|
8155
8181
|
fs.mkdirSync(dir, { recursive: true });
|
|
8156
8182
|
} catch (error2) {
|
|
8157
|
-
if (error2
|
|
8183
|
+
if (!isEexistError(error2)) throw error2;
|
|
8158
8184
|
}
|
|
8159
8185
|
try {
|
|
8160
8186
|
fs.copyFileSync(srcPath, normalizedDestPath);
|
|
@@ -8270,7 +8296,7 @@ var init_PathResolver = __esm({
|
|
|
8270
8296
|
try {
|
|
8271
8297
|
await fs.promises.mkdir(dirPath, { recursive: true });
|
|
8272
8298
|
} catch (error2) {
|
|
8273
|
-
if (error2
|
|
8299
|
+
if (!isEexistError(error2)) throw error2;
|
|
8274
8300
|
}
|
|
8275
8301
|
}
|
|
8276
8302
|
/**
|
|
@@ -8282,7 +8308,7 @@ var init_PathResolver = __esm({
|
|
|
8282
8308
|
try {
|
|
8283
8309
|
fs.mkdirSync(dirPath, { recursive: true });
|
|
8284
8310
|
} catch (error2) {
|
|
8285
|
-
if (error2
|
|
8311
|
+
if (!isEexistError(error2)) throw error2;
|
|
8286
8312
|
}
|
|
8287
8313
|
}
|
|
8288
8314
|
/**
|
|
@@ -8531,6 +8557,7 @@ var init_PathResolver = __esm({
|
|
|
8531
8557
|
* @param patternType - Type of patterns (css, routes, i18n, assets, pwa)
|
|
8532
8558
|
* @returns Resolved patterns with absolute paths
|
|
8533
8559
|
*/
|
|
8560
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- why: mirrors the public PathResolver.d.ts signature; tightening it is a breaking change (any-audit)
|
|
8534
8561
|
async resolvePatterns(patternType) {
|
|
8535
8562
|
if (!constants.getPatternsFor) {
|
|
8536
8563
|
return { framework: [], consumer: [], all: [] };
|
|
@@ -8823,7 +8850,7 @@ function globSync(pattern, options = {}) {
|
|
|
8823
8850
|
});
|
|
8824
8851
|
return results.map((p) => pathResolverInstance.normalizePath(p));
|
|
8825
8852
|
}
|
|
8826
|
-
var pathResolverInstance, getRepoRoot, getAppRoot, resolveFrameworkPackage, normalizePath, pathExists, read, readSync, write, writeSync, removeSync, ensureDir, getRelativePathBetween, getDirname, joinPath;
|
|
8853
|
+
var pathResolverInstance, getRepoRoot, getAppRoot, resolveFrameworkPackage, normalizePath, pathExists, read, readSync, write, writeSync, removeSync, ensureDir, getRelativePathBetween, getDirname, getBasename, joinPath;
|
|
8827
8854
|
var init_pathResolver = __esm({
|
|
8828
8855
|
"packages/tooling/src/utils/pathResolver.ts"() {
|
|
8829
8856
|
"use strict";
|
|
@@ -8849,12 +8876,29 @@ var init_pathResolver = __esm({
|
|
|
8849
8876
|
getDirname = (filePath) => {
|
|
8850
8877
|
return normalizePath(dirname3(filePath));
|
|
8851
8878
|
};
|
|
8879
|
+
getBasename = (filePath, ext) => {
|
|
8880
|
+
return basename2(filePath, ext);
|
|
8881
|
+
};
|
|
8852
8882
|
joinPath = (...pathSegments) => {
|
|
8853
8883
|
return normalizePath(...pathSegments);
|
|
8854
8884
|
};
|
|
8855
8885
|
}
|
|
8856
8886
|
});
|
|
8857
8887
|
|
|
8888
|
+
// packages/tooling/src/utils/type-guards.ts
|
|
8889
|
+
function isRecord(value) {
|
|
8890
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
8891
|
+
}
|
|
8892
|
+
function asText(value) {
|
|
8893
|
+
return typeof value === "string" ? value : null;
|
|
8894
|
+
}
|
|
8895
|
+
var init_type_guards = __esm({
|
|
8896
|
+
"packages/tooling/src/utils/type-guards.ts"() {
|
|
8897
|
+
"use strict";
|
|
8898
|
+
init_utils2();
|
|
8899
|
+
}
|
|
8900
|
+
});
|
|
8901
|
+
|
|
8858
8902
|
// packages/tooling/src/bundler/utils.ts
|
|
8859
8903
|
import { Buffer as Buffer2 } from "node:buffer";
|
|
8860
8904
|
import { copyFileSync as copyFileSync2, readFileSync as readFileSync2, writeFileSync as writeFileSync2, mkdirSync as mkdirSync2 } from "node:fs";
|
|
@@ -8900,7 +8944,7 @@ async function askForMultiSelection(message, choices, defaultIndices = []) {
|
|
|
8900
8944
|
label: choice.title,
|
|
8901
8945
|
hint: choice.hint
|
|
8902
8946
|
}));
|
|
8903
|
-
const initialValues = defaultIndices.map((i2) => choices[i2]?.value).filter(Boolean);
|
|
8947
|
+
const initialValues = defaultIndices.map((i2) => choices[i2]?.value).filter((value) => Boolean(value));
|
|
8904
8948
|
const result = await multiselect({
|
|
8905
8949
|
message,
|
|
8906
8950
|
options,
|
|
@@ -8916,7 +8960,7 @@ var init_cli_input = __esm({
|
|
|
8916
8960
|
"packages/tooling/src/utils/cli-input.ts"() {
|
|
8917
8961
|
"use strict";
|
|
8918
8962
|
init_utils2();
|
|
8919
|
-
|
|
8963
|
+
init_dist5();
|
|
8920
8964
|
}
|
|
8921
8965
|
});
|
|
8922
8966
|
|
|
@@ -9048,7 +9092,8 @@ function writePackageJson(filePath, pkg) {
|
|
|
9048
9092
|
if (!obj) return void 0;
|
|
9049
9093
|
const sorted2 = {};
|
|
9050
9094
|
for (const key of Object.keys(obj).sort()) {
|
|
9051
|
-
|
|
9095
|
+
const value = obj[key];
|
|
9096
|
+
if (value !== void 0) sorted2[key] = value;
|
|
9052
9097
|
}
|
|
9053
9098
|
return sorted2;
|
|
9054
9099
|
};
|
|
@@ -9090,24 +9135,24 @@ function ensureCaretPrefix(version) {
|
|
|
9090
9135
|
return `^${version}`;
|
|
9091
9136
|
}
|
|
9092
9137
|
function compareVersions(current, expected) {
|
|
9093
|
-
const
|
|
9138
|
+
const c2 = normalizeVersion(current).split(".").map(Number);
|
|
9094
9139
|
const e = normalizeVersion(expected).split(".").map(Number);
|
|
9095
|
-
for (let i2 = 0; i2 < Math.max(
|
|
9096
|
-
const cv =
|
|
9140
|
+
for (let i2 = 0; i2 < Math.max(c2.length, e.length); i2++) {
|
|
9141
|
+
const cv = c2[i2] || 0;
|
|
9097
9142
|
const ev = e[i2] || 0;
|
|
9098
9143
|
if (cv < ev)
|
|
9099
9144
|
return {
|
|
9100
9145
|
behind: true,
|
|
9101
9146
|
ahead: false,
|
|
9102
9147
|
equal: false,
|
|
9103
|
-
isMajor: (
|
|
9148
|
+
isMajor: (c2[0] || 0) !== (e[0] || 0)
|
|
9104
9149
|
};
|
|
9105
9150
|
if (cv > ev)
|
|
9106
9151
|
return {
|
|
9107
9152
|
behind: false,
|
|
9108
9153
|
ahead: true,
|
|
9109
9154
|
equal: false,
|
|
9110
|
-
isMajor: (
|
|
9155
|
+
isMajor: (c2[0] || 0) !== (e[0] || 0)
|
|
9111
9156
|
};
|
|
9112
9157
|
}
|
|
9113
9158
|
return { behind: false, ahead: false, equal: true, isMajor: false };
|
|
@@ -9160,7 +9205,7 @@ function syncDonotdevToMatrix(matrix, donotdevVersions, dryRun) {
|
|
|
9160
9205
|
}
|
|
9161
9206
|
}
|
|
9162
9207
|
if (changes.length > 0 && !dryRun) {
|
|
9163
|
-
matrix.lastUpdated = (/* @__PURE__ */ new Date()).toISOString().
|
|
9208
|
+
matrix.lastUpdated = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
9164
9209
|
try {
|
|
9165
9210
|
const require3 = createRequire5(import.meta.url);
|
|
9166
9211
|
const matrixPath = require3.resolve("@donotdev/cli/dependencies-matrix.json");
|
|
@@ -9378,6 +9423,7 @@ init_utils2();
|
|
|
9378
9423
|
init_cli_output();
|
|
9379
9424
|
init_errors();
|
|
9380
9425
|
init_pathResolver();
|
|
9426
|
+
init_type_guards();
|
|
9381
9427
|
var PRESERVE_MAP = {
|
|
9382
9428
|
demo: [],
|
|
9383
9429
|
dndev: ["commands.ts"]
|
|
@@ -9530,10 +9576,10 @@ async function syncApp(appName, options = {}) {
|
|
|
9530
9576
|
continue;
|
|
9531
9577
|
}
|
|
9532
9578
|
if (!pathExists(sourceFile)) continue;
|
|
9533
|
-
const content = await read(sourceFile, { format: "text" });
|
|
9579
|
+
const content = asText(await read(sourceFile, { format: "text" }));
|
|
9534
9580
|
if (!content) continue;
|
|
9535
9581
|
if (pathExists(destFile)) {
|
|
9536
|
-
const existing = await read(destFile, { format: "text" });
|
|
9582
|
+
const existing = asText(await read(destFile, { format: "text" }));
|
|
9537
9583
|
if (existing === content) continue;
|
|
9538
9584
|
}
|
|
9539
9585
|
if (dryRun) {
|
|
@@ -9564,6 +9610,7 @@ init_utils2();
|
|
|
9564
9610
|
init_cli_output();
|
|
9565
9611
|
init_errors();
|
|
9566
9612
|
init_pathResolver();
|
|
9613
|
+
init_type_guards();
|
|
9567
9614
|
var SYNC_PATHS = [
|
|
9568
9615
|
// Documentation
|
|
9569
9616
|
"guides/**/*.md.example",
|
|
@@ -9575,10 +9622,14 @@ var SYNC_PATHS = [
|
|
|
9575
9622
|
".claude/skills/**/*.md",
|
|
9576
9623
|
// Agents
|
|
9577
9624
|
".claude/agents/**/*.md.example",
|
|
9625
|
+
// Hooks (template-owned, overwritten) + their registration (merged)
|
|
9626
|
+
".claude/hooks/**/*.example",
|
|
9627
|
+
".claude/settings.json.example",
|
|
9578
9628
|
// AI instructions (SSOT for agent behavior)
|
|
9579
9629
|
"AGENTS.md.example",
|
|
9580
9630
|
"CLAUDE.md.example",
|
|
9581
|
-
|
|
9631
|
+
// Rules
|
|
9632
|
+
".claude/rules/**/*.md.example",
|
|
9582
9633
|
// Config files
|
|
9583
9634
|
".claude/mcp.json.example",
|
|
9584
9635
|
// MCP config
|
|
@@ -9595,6 +9646,78 @@ var PRESERVE_IF_EXISTS = [
|
|
|
9595
9646
|
"args.json"
|
|
9596
9647
|
// User/agent may have customized features
|
|
9597
9648
|
];
|
|
9649
|
+
var PROJECT_SECTION_MARKER = "<!-- dndev:project-specific -->";
|
|
9650
|
+
function mergeProjectSection(template, existing) {
|
|
9651
|
+
const templateIndex = template.indexOf(PROJECT_SECTION_MARKER);
|
|
9652
|
+
if (templateIndex === -1 || existing === null) return template;
|
|
9653
|
+
const existingIndex = existing.indexOf(PROJECT_SECTION_MARKER);
|
|
9654
|
+
if (existingIndex === -1) return template;
|
|
9655
|
+
return template.slice(0, templateIndex + PROJECT_SECTION_MARKER.length) + existing.slice(existingIndex + PROJECT_SECTION_MARKER.length);
|
|
9656
|
+
}
|
|
9657
|
+
function mergeMcpConfig(template, existing) {
|
|
9658
|
+
if (existing === null) return template;
|
|
9659
|
+
const templateConfig = JSON.parse(template);
|
|
9660
|
+
const existingConfig = JSON.parse(existing);
|
|
9661
|
+
const merged = {
|
|
9662
|
+
...existingConfig,
|
|
9663
|
+
...templateConfig,
|
|
9664
|
+
mcpServers: {
|
|
9665
|
+
...existingConfig.mcpServers,
|
|
9666
|
+
...templateConfig.mcpServers
|
|
9667
|
+
}
|
|
9668
|
+
};
|
|
9669
|
+
if (JSON.stringify(merged) === JSON.stringify(existingConfig)) {
|
|
9670
|
+
return existing;
|
|
9671
|
+
}
|
|
9672
|
+
return JSON.stringify(merged, null, 2) + "\n";
|
|
9673
|
+
}
|
|
9674
|
+
function mergeHookGroups(existing, template) {
|
|
9675
|
+
const groupHooks = (group2) => isRecord(group2) && Array.isArray(group2.hooks) ? group2.hooks : [];
|
|
9676
|
+
const hookCommand = (hook) => isRecord(hook) ? hook.command : void 0;
|
|
9677
|
+
const templateCommands = new Set(
|
|
9678
|
+
template.flatMap((group2) => groupHooks(group2).map(hookCommand))
|
|
9679
|
+
);
|
|
9680
|
+
const kept = existing.flatMap((group2) => {
|
|
9681
|
+
if (!isRecord(group2)) return [group2];
|
|
9682
|
+
const ownHooks = groupHooks(group2).filter(
|
|
9683
|
+
(hook) => !templateCommands.has(hookCommand(hook))
|
|
9684
|
+
);
|
|
9685
|
+
return ownHooks.length > 0 ? [{ ...group2, hooks: ownHooks }] : [];
|
|
9686
|
+
});
|
|
9687
|
+
return [...template, ...kept];
|
|
9688
|
+
}
|
|
9689
|
+
function mergeJsonValue(existing, template, path) {
|
|
9690
|
+
if (Array.isArray(existing) && Array.isArray(template)) {
|
|
9691
|
+
if (path.length === 2 && path[0] === "hooks") {
|
|
9692
|
+
return mergeHookGroups(existing, template);
|
|
9693
|
+
}
|
|
9694
|
+
const existingItems = new Set(existing.map((item) => JSON.stringify(item)));
|
|
9695
|
+
return [
|
|
9696
|
+
...existing,
|
|
9697
|
+
...template.filter((item) => !existingItems.has(JSON.stringify(item)))
|
|
9698
|
+
];
|
|
9699
|
+
}
|
|
9700
|
+
if (isRecord(existing) && isRecord(template)) {
|
|
9701
|
+
const merged = {};
|
|
9702
|
+
for (const key of Object.keys(existing)) {
|
|
9703
|
+
merged[key] = key in template ? mergeJsonValue(existing[key], template[key], [...path, key]) : existing[key];
|
|
9704
|
+
}
|
|
9705
|
+
for (const key of Object.keys(template)) {
|
|
9706
|
+
if (!(key in existing)) merged[key] = template[key];
|
|
9707
|
+
}
|
|
9708
|
+
return merged;
|
|
9709
|
+
}
|
|
9710
|
+
return template;
|
|
9711
|
+
}
|
|
9712
|
+
function mergeClaudeSettings(template, existing) {
|
|
9713
|
+
if (existing === null) return template;
|
|
9714
|
+
const existingSettings = JSON.parse(existing);
|
|
9715
|
+
const merged = mergeJsonValue(existingSettings, JSON.parse(template), []);
|
|
9716
|
+
if (JSON.stringify(merged) === JSON.stringify(existingSettings)) {
|
|
9717
|
+
return existing;
|
|
9718
|
+
}
|
|
9719
|
+
return JSON.stringify(merged, null, 2) + "\n";
|
|
9720
|
+
}
|
|
9598
9721
|
function getSourceTemplatesPath() {
|
|
9599
9722
|
try {
|
|
9600
9723
|
const templatesRoot = getTemplatesRoot();
|
|
@@ -9638,18 +9761,23 @@ async function syncFile(sourcePath, destPath, preserveIfExists, appRoot) {
|
|
|
9638
9761
|
log2.warn(`Source file not found: ${sourcePath}`);
|
|
9639
9762
|
return false;
|
|
9640
9763
|
}
|
|
9641
|
-
const
|
|
9642
|
-
if (!
|
|
9764
|
+
const templateContent = asText(await read(sourcePath, { format: "text" }));
|
|
9765
|
+
if (!templateContent) {
|
|
9643
9766
|
log2.warn(`Source file is empty: ${sourcePath}`);
|
|
9644
9767
|
return false;
|
|
9645
9768
|
}
|
|
9646
|
-
|
|
9647
|
-
|
|
9648
|
-
|
|
9649
|
-
|
|
9650
|
-
|
|
9651
|
-
|
|
9652
|
-
|
|
9769
|
+
const existingContent = pathExists(destPathWithoutExample) ? asText(await read(destPathWithoutExample, { format: "text" })) : null;
|
|
9770
|
+
const relativeDest = getRelativePathBetween(appRoot, destPathWithoutExample);
|
|
9771
|
+
let content;
|
|
9772
|
+
if (getBasename(relativeDest).endsWith("mcp.json")) {
|
|
9773
|
+
content = mergeMcpConfig(templateContent, existingContent);
|
|
9774
|
+
} else if (relativeDest === ".claude/settings.json") {
|
|
9775
|
+
content = mergeClaudeSettings(templateContent, existingContent);
|
|
9776
|
+
} else {
|
|
9777
|
+
content = mergeProjectSection(templateContent, existingContent);
|
|
9778
|
+
}
|
|
9779
|
+
if (existingContent === content) {
|
|
9780
|
+
return false;
|
|
9653
9781
|
}
|
|
9654
9782
|
await ensureDir(getDirname(destPathWithoutExample));
|
|
9655
9783
|
await write(destPathWithoutExample, content, {
|
|
@@ -9869,9 +9997,9 @@ function formatDeprecatedList(deprecated, appRoot) {
|
|
|
9869
9997
|
const lines = [];
|
|
9870
9998
|
for (const d of deprecated) {
|
|
9871
9999
|
lines.push(` ${d.name} \u2014 ${d.message}`);
|
|
9872
|
-
const locs = d.locations.map((
|
|
9873
|
-
const rel = appRoot ? getRelativePathBetween(appRoot,
|
|
9874
|
-
return `${rel} (${
|
|
10000
|
+
const locs = d.locations.map((l) => {
|
|
10001
|
+
const rel = appRoot ? getRelativePathBetween(appRoot, l.file) : l.file;
|
|
10002
|
+
return `${rel} (${l.field})`;
|
|
9875
10003
|
});
|
|
9876
10004
|
lines.push(` Found in: ${locs.join(", ")}`);
|
|
9877
10005
|
}
|