@funkai/cli 0.1.2 → 0.1.4
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/.turbo/turbo-build.log +2 -2
- package/CHANGELOG.md +21 -0
- package/dist/index.mjs +1538 -2335
- package/dist/index.mjs.map +1 -1
- package/package.json +9 -7
- package/src/commands/generate.ts +1 -1
- package/src/commands/prompts/create.ts +3 -3
- package/src/commands/prompts/generate.ts +10 -5
- package/src/commands/prompts/lint.ts +9 -8
- package/src/commands/prompts/setup.ts +34 -17
- package/src/commands/validate.ts +1 -1
- package/src/index.ts +30 -1
- package/src/lib/prompts/__tests__/extract-variables.test.ts +1 -1
- package/src/lib/prompts/__tests__/flatten.test.ts +1 -1
- package/src/lib/prompts/__tests__/frontmatter.test.ts +1 -1
- package/src/lib/prompts/__tests__/lint.test.ts +5 -5
- package/src/lib/prompts/codegen.ts +47 -20
- package/src/lib/prompts/extract-variables.ts +7 -1
- package/src/lib/prompts/flatten.ts +10 -5
- package/src/lib/prompts/frontmatter.ts +37 -23
- package/src/lib/prompts/paths.ts +2 -2
- package/src/lib/prompts/pipeline.ts +22 -13
package/dist/index.mjs
CHANGED
|
@@ -11,19 +11,19 @@ import ot from "node:readline";
|
|
|
11
11
|
import { ReadStream } from "node:tty";
|
|
12
12
|
import fs, { existsSync, lstatSync, mkdirSync, promises, readFileSync, readdirSync, realpathSync, statSync, writeFileSync } from "node:fs";
|
|
13
13
|
import path, { basename, dirname, extname, isAbsolute, join, resolve } from "node:path";
|
|
14
|
-
import {
|
|
15
|
-
import { access, mkdir, readFile, rm, writeFile } from "node:fs/promises";
|
|
16
|
-
import { parse, stringify } from "yaml";
|
|
14
|
+
import { mkdir, readFile, rm, writeFile } from "node:fs/promises";
|
|
17
15
|
import { URL as URL$1, fileURLToPath, pathToFileURL } from "node:url";
|
|
16
|
+
import { homedir } from "node:os";
|
|
18
17
|
import assert from "node:assert";
|
|
19
18
|
import v8 from "node:v8";
|
|
20
19
|
import { readFileSync as readFileSync$1, readdirSync as readdirSync$1, statSync as statSync$1, writeFile as writeFile$1 } from "fs";
|
|
21
20
|
import { basename as basename$1, dirname as dirname$1, extname as extname$1, join as join$1, normalize, relative, resolve as resolve$1 } from "path";
|
|
22
21
|
import { createHash } from "node:crypto";
|
|
22
|
+
import { parse, stringify } from "yaml";
|
|
23
23
|
import { notStrictEqual, strictEqual } from "assert";
|
|
24
24
|
import { format as format$1, inspect as inspect$1 } from "util";
|
|
25
25
|
import { fileURLToPath as fileURLToPath$1 } from "url";
|
|
26
|
-
import { PARTIALS_DIR, clean } from "@funkai/prompts";
|
|
26
|
+
import { PARTIALS_DIR, clean } from "@funkai/prompts/cli";
|
|
27
27
|
import { Liquid } from "liquidjs";
|
|
28
28
|
|
|
29
29
|
//#region \0rolldown/runtime.js
|
|
@@ -139,7 +139,20 @@ var require_picocolors = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
139
139
|
}));
|
|
140
140
|
|
|
141
141
|
//#endregion
|
|
142
|
-
//#region ../../node_modules/.pnpm/@kidd-cli+core@0.
|
|
142
|
+
//#region ../../node_modules/.pnpm/@kidd-cli+core@0.10.0_chokidar@5.0.0_jiti@2.6.1_magicast@0.5.2_vitest@4.1.0_@opentelemetry+ap_h5jt7i6rdfwaknd5di57zdj5zy/node_modules/@kidd-cli/core/dist/tally-KfEitTrZ.js
|
|
143
|
+
/**
|
|
144
|
+
* Format a duration in milliseconds to a human-readable string.
|
|
145
|
+
*
|
|
146
|
+
* @param ms - Duration in milliseconds.
|
|
147
|
+
* @returns A formatted duration string.
|
|
148
|
+
*/
|
|
149
|
+
function formatDuration(ms) {
|
|
150
|
+
return match(ms).when((v) => v < 1, () => "< 1ms").when((v) => v < 1e3, (v) => `${Math.round(v)}ms`).when((v) => v < 6e4, (v) => `${(v / 1e3).toFixed(2)}s`).otherwise((v) => {
|
|
151
|
+
const minutes = Math.floor(v / 6e4);
|
|
152
|
+
const seconds = Math.round(v % 6e4 / 1e3);
|
|
153
|
+
return `${String(minutes)}m ${String(seconds)}s`;
|
|
154
|
+
});
|
|
155
|
+
}
|
|
143
156
|
/**
|
|
144
157
|
* Format a single pass/fail/warn check row.
|
|
145
158
|
*
|
|
@@ -169,7 +182,7 @@ function formatOptionalDetail(detail) {
|
|
|
169
182
|
* @returns Formatted duration or empty string.
|
|
170
183
|
*/
|
|
171
184
|
function formatOptionalDuration(duration) {
|
|
172
|
-
return match(duration).with(void 0, () => "").otherwise((d) => ` ${import_picocolors$1.default.gray(`(${
|
|
185
|
+
return match(duration).with(void 0, () => "").otherwise((d) => ` ${import_picocolors$1.default.gray(`(${formatDuration(d)})`)}`);
|
|
173
186
|
}
|
|
174
187
|
/**
|
|
175
188
|
* Format optional hint text.
|
|
@@ -182,16 +195,6 @@ function formatOptionalHint(hint) {
|
|
|
182
195
|
return match(hint).with(void 0, () => "").otherwise((h) => ` ${import_picocolors$1.default.dim(`[${h}]`)}`);
|
|
183
196
|
}
|
|
184
197
|
/**
|
|
185
|
-
* Inline duration format for check rows (compact).
|
|
186
|
-
*
|
|
187
|
-
* @private
|
|
188
|
-
* @param ms - Duration in milliseconds.
|
|
189
|
-
* @returns A compact formatted duration string.
|
|
190
|
-
*/
|
|
191
|
-
function formatDurationInline(ms) {
|
|
192
|
-
return match(ms).when((v) => v < 1, () => "< 1ms").when((v) => v < 1e3, (v) => `${Math.round(v)}ms`).otherwise((v) => `${(v / 1e3).toFixed(2)}s`);
|
|
193
|
-
}
|
|
194
|
-
/**
|
|
195
198
|
* Format an annotated code frame (oxlint style).
|
|
196
199
|
*
|
|
197
200
|
* @param input - The code frame data to format.
|
|
@@ -307,7 +310,7 @@ function formatTallyInline(input) {
|
|
|
307
310
|
return ` ${input.stats.join(import_picocolors$1.default.gray(" | "))}`;
|
|
308
311
|
}
|
|
309
312
|
var import_picocolors$1, GLYPHS, CheckStatusSchema, CodeFrameAnnotationSchema;
|
|
310
|
-
var
|
|
313
|
+
var init_tally_KfEitTrZ = __esmMin((() => {
|
|
311
314
|
import_picocolors$1 = /* @__PURE__ */ __toESM(require_picocolors(), 1);
|
|
312
315
|
GLYPHS = Object.freeze({
|
|
313
316
|
arrow: "›",
|
|
@@ -481,7 +484,7 @@ function St$2(t, e) {
|
|
|
481
484
|
if (e) return t ? e : e[0];
|
|
482
485
|
}
|
|
483
486
|
var import_src$1, at$2, lt$1, ht$1, O$2, y$2, L$1, P$4, M$2, ct$1, ft$2, X$2, pt$2, S$2, T$2, Z$1, Ft$2, j$2, Q$2, dt$1, tt$1, U$2, et$1, mt$2, st$1, it$1, gt$2, G$1, vt$2, Et$2, _$2, bt$2, z$3, rt$1, nt$1, B$1, Vt$2, kt$2, yt$2, Lt$2, Mt$2, Tt$2, Wt$2, $t$1;
|
|
484
|
-
var init_dist$
|
|
487
|
+
var init_dist$10 = __esmMin((() => {
|
|
485
488
|
import_src$1 = require_src();
|
|
486
489
|
at$2 = (t) => t === 161 || t === 164 || t === 167 || t === 168 || t === 170 || t === 173 || t === 174 || t >= 176 && t <= 180 || t >= 182 && t <= 186 || t >= 188 && t <= 191 || t === 198 || t === 208 || t === 215 || t === 216 || t >= 222 && t <= 225 || t === 230 || t >= 232 && t <= 234 || t === 236 || t === 237 || t === 240 || t === 242 || t === 243 || t >= 247 && t <= 250 || t === 252 || t === 254 || t === 257 || t === 273 || t === 275 || t === 283 || t === 294 || t === 295 || t === 299 || t >= 305 && t <= 307 || t === 312 || t >= 319 && t <= 322 || t === 324 || t >= 328 && t <= 331 || t === 333 || t === 338 || t === 339 || t === 358 || t === 359 || t === 363 || t === 462 || t === 464 || t === 466 || t === 468 || t === 470 || t === 472 || t === 474 || t === 476 || t === 593 || t === 609 || t === 708 || t === 711 || t >= 713 && t <= 715 || t === 717 || t === 720 || t >= 728 && t <= 731 || t === 733 || t === 735 || t >= 768 && t <= 879 || t >= 913 && t <= 929 || t >= 931 && t <= 937 || t >= 945 && t <= 961 || t >= 963 && t <= 969 || t === 1025 || t >= 1040 && t <= 1103 || t === 1105 || t === 8208 || t >= 8211 && t <= 8214 || t === 8216 || t === 8217 || t === 8220 || t === 8221 || t >= 8224 && t <= 8226 || t >= 8228 && t <= 8231 || t === 8240 || t === 8242 || t === 8243 || t === 8245 || t === 8251 || t === 8254 || t === 8308 || t === 8319 || t >= 8321 && t <= 8324 || t === 8364 || t === 8451 || t === 8453 || t === 8457 || t === 8467 || t === 8470 || t === 8481 || t === 8482 || t === 8486 || t === 8491 || t === 8531 || t === 8532 || t >= 8539 && t <= 8542 || t >= 8544 && t <= 8555 || t >= 8560 && t <= 8569 || t === 8585 || t >= 8592 && t <= 8601 || t === 8632 || t === 8633 || t === 8658 || t === 8660 || t === 8679 || t === 8704 || t === 8706 || t === 8707 || t === 8711 || t === 8712 || t === 8715 || t === 8719 || t === 8721 || t === 8725 || t === 8730 || t >= 8733 && t <= 8736 || t === 8739 || t === 8741 || t >= 8743 && t <= 8748 || t === 8750 || t >= 8756 && t <= 8759 || t === 8764 || t === 8765 || t === 8776 || t === 8780 || t === 8786 || t === 8800 || t === 8801 || t >= 8804 && t <= 8807 || t === 8810 || t === 8811 || t === 8814 || t === 8815 || t === 8834 || t === 8835 || t === 8838 || t === 8839 || t === 8853 || t === 8857 || t === 8869 || t === 8895 || t === 8978 || t >= 9312 && t <= 9449 || t >= 9451 && t <= 9547 || t >= 9552 && t <= 9587 || t >= 9600 && t <= 9615 || t >= 9618 && t <= 9621 || t === 9632 || t === 9633 || t >= 9635 && t <= 9641 || t === 9650 || t === 9651 || t === 9654 || t === 9655 || t === 9660 || t === 9661 || t === 9664 || t === 9665 || t >= 9670 && t <= 9672 || t === 9675 || t >= 9678 && t <= 9681 || t >= 9698 && t <= 9701 || t === 9711 || t === 9733 || t === 9734 || t === 9737 || t === 9742 || t === 9743 || t === 9756 || t === 9758 || t === 9792 || t === 9794 || t === 9824 || t === 9825 || t >= 9827 && t <= 9829 || t >= 9831 && t <= 9834 || t === 9836 || t === 9837 || t === 9839 || t === 9886 || t === 9887 || t === 9919 || t >= 9926 && t <= 9933 || t >= 9935 && t <= 9939 || t >= 9941 && t <= 9953 || t === 9955 || t === 9960 || t === 9961 || t >= 9963 && t <= 9969 || t === 9972 || t >= 9974 && t <= 9977 || t === 9979 || t === 9980 || t === 9982 || t === 9983 || t === 10045 || t >= 10102 && t <= 10111 || t >= 11094 && t <= 11097 || t >= 12872 && t <= 12879 || t >= 57344 && t <= 63743 || t >= 65024 && t <= 65039 || t === 65533 || t >= 127232 && t <= 127242 || t >= 127248 && t <= 127277 || t >= 127280 && t <= 127337 || t >= 127344 && t <= 127373 || t === 127375 || t === 127376 || t >= 127387 && t <= 127404 || t >= 917760 && t <= 917999 || t >= 983040 && t <= 1048573 || t >= 1048576 && t <= 1114109, lt$1 = (t) => t === 12288 || t >= 65281 && t <= 65376 || t >= 65504 && t <= 65510, ht$1 = (t) => t >= 4352 && t <= 4447 || t === 8986 || t === 8987 || t === 9001 || t === 9002 || t >= 9193 && t <= 9196 || t === 9200 || t === 9203 || t === 9725 || t === 9726 || t === 9748 || t === 9749 || t >= 9800 && t <= 9811 || t === 9855 || t === 9875 || t === 9889 || t === 9898 || t === 9899 || t === 9917 || t === 9918 || t === 9924 || t === 9925 || t === 9934 || t === 9940 || t === 9962 || t === 9970 || t === 9971 || t === 9973 || t === 9978 || t === 9981 || t === 9989 || t === 9994 || t === 9995 || t === 10024 || t === 10060 || t === 10062 || t >= 10067 && t <= 10069 || t === 10071 || t >= 10133 && t <= 10135 || t === 10160 || t === 10175 || t === 11035 || t === 11036 || t === 11088 || t === 11093 || t >= 11904 && t <= 11929 || t >= 11931 && t <= 12019 || t >= 12032 && t <= 12245 || t >= 12272 && t <= 12287 || t >= 12289 && t <= 12350 || t >= 12353 && t <= 12438 || t >= 12441 && t <= 12543 || t >= 12549 && t <= 12591 || t >= 12593 && t <= 12686 || t >= 12688 && t <= 12771 || t >= 12783 && t <= 12830 || t >= 12832 && t <= 12871 || t >= 12880 && t <= 19903 || t >= 19968 && t <= 42124 || t >= 42128 && t <= 42182 || t >= 43360 && t <= 43388 || t >= 44032 && t <= 55203 || t >= 63744 && t <= 64255 || t >= 65040 && t <= 65049 || t >= 65072 && t <= 65106 || t >= 65108 && t <= 65126 || t >= 65128 && t <= 65131 || t >= 94176 && t <= 94180 || t === 94192 || t === 94193 || t >= 94208 && t <= 100343 || t >= 100352 && t <= 101589 || t >= 101632 && t <= 101640 || t >= 110576 && t <= 110579 || t >= 110581 && t <= 110587 || t === 110589 || t === 110590 || t >= 110592 && t <= 110882 || t === 110898 || t >= 110928 && t <= 110930 || t === 110933 || t >= 110948 && t <= 110951 || t >= 110960 && t <= 111355 || t === 126980 || t === 127183 || t === 127374 || t >= 127377 && t <= 127386 || t >= 127488 && t <= 127490 || t >= 127504 && t <= 127547 || t >= 127552 && t <= 127560 || t === 127568 || t === 127569 || t >= 127584 && t <= 127589 || t >= 127744 && t <= 127776 || t >= 127789 && t <= 127797 || t >= 127799 && t <= 127868 || t >= 127870 && t <= 127891 || t >= 127904 && t <= 127946 || t >= 127951 && t <= 127955 || t >= 127968 && t <= 127984 || t === 127988 || t >= 127992 && t <= 128062 || t === 128064 || t >= 128066 && t <= 128252 || t >= 128255 && t <= 128317 || t >= 128331 && t <= 128334 || t >= 128336 && t <= 128359 || t === 128378 || t === 128405 || t === 128406 || t === 128420 || t >= 128507 && t <= 128591 || t >= 128640 && t <= 128709 || t === 128716 || t >= 128720 && t <= 128722 || t >= 128725 && t <= 128727 || t >= 128732 && t <= 128735 || t === 128747 || t === 128748 || t >= 128756 && t <= 128764 || t >= 128992 && t <= 129003 || t === 129008 || t >= 129292 && t <= 129338 || t >= 129340 && t <= 129349 || t >= 129351 && t <= 129535 || t >= 129648 && t <= 129660 || t >= 129664 && t <= 129672 || t >= 129680 && t <= 129725 || t >= 129727 && t <= 129733 || t >= 129742 && t <= 129755 || t >= 129760 && t <= 129768 || t >= 129776 && t <= 129784 || t >= 131072 && t <= 196605 || t >= 196608 && t <= 262141, O$2 = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y, y$2 = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y, L$1 = /\t{1,1000}/y, P$4 = /[\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?))*/uy, M$2 = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y, ct$1 = /\p{M}+/gu, ft$2 = {
|
|
487
490
|
limit: Infinity,
|
|
@@ -1088,8 +1091,8 @@ function Ye$1(e, r, s, i) {
|
|
|
1088
1091
|
return i === "center" ? a = Math.floor((r - e) / 2) : i === "right" && (a = r - e - s), o = r - a - e, [a, o];
|
|
1089
1092
|
}
|
|
1090
1093
|
var import_src, ee$1, ce$1, Me$1, I$1, Re$1, $e$1, de$1, V$1, he$1, h$3, x$2, Oe$1, Pe$1, z$2, H$1, te$1, U$1, q$1, Ne$1, se$1, pe$1, We$1, me$1, ge$1, Ge$1, fe$1, Fe$1, ye$1, Ee$1, W$1, ve$1, mt$1, gt$1, ft$1, we$1, re$1, ie$1, Ae$1, ne$1, Ft$1, yt$1, Le$1, Et$1, D$2, ae$1, je$1, vt$1, Ce$1, ke$1, wt$1, Ve$1, Se$1, He$1, At$1, Ue$1, Ke$1, Ct$1, Ie$1, St$1, It$1, bt$1, X$1, Xe$1, xt$1, _t$1, Dt$1, Tt$1, Mt$1, Rt$1, Ot$1, Pt$1, R$1, Nt$1, Wt$1, Gt$1, Q$1, Lt$1, jt$1, kt$1, Vt$1, Ht$1, Ut$1, Kt$1, be$1, ze$1, oe$1, Jt$1, Xt$1, Qe$1, K$1, Yt$1, zt$1, Qt$1, Zt$1;
|
|
1091
|
-
var init_dist$
|
|
1092
|
-
init_dist$
|
|
1094
|
+
var init_dist$9 = __esmMin((() => {
|
|
1095
|
+
init_dist$10();
|
|
1093
1096
|
import_src = require_src();
|
|
1094
1097
|
ee$1 = pt$1(), ce$1 = () => process.env.CI === "true", Me$1 = (e) => e.isTTY === !0, I$1 = (e, r) => ee$1 ? e : r, Re$1 = I$1("◆", "*"), $e$1 = I$1("■", "x"), de$1 = I$1("▲", "x"), V$1 = I$1("◇", "o"), he$1 = I$1("┌", "T"), h$3 = I$1("│", "|"), x$2 = I$1("└", "—"), Oe$1 = I$1("┐", "T"), Pe$1 = I$1("┘", "—"), z$2 = I$1("●", ">"), H$1 = I$1("○", " "), te$1 = I$1("◻", "[•]"), U$1 = I$1("◼", "[+]"), q$1 = I$1("◻", "[ ]"), Ne$1 = I$1("▪", "•"), se$1 = I$1("─", "-"), pe$1 = I$1("╮", "+"), We$1 = I$1("├", "+"), me$1 = I$1("╯", "+"), ge$1 = I$1("╰", "+"), Ge$1 = I$1("╭", "+"), fe$1 = I$1("●", "•"), Fe$1 = I$1("◆", "*"), ye$1 = I$1("▲", "!"), Ee$1 = I$1("■", "x"), W$1 = (e) => {
|
|
1095
1098
|
switch (e) {
|
|
@@ -2148,7 +2151,7 @@ ${r ? styleText("cyan", x$2) : ""}
|
|
|
2148
2151
|
}));
|
|
2149
2152
|
|
|
2150
2153
|
//#endregion
|
|
2151
|
-
//#region ../../node_modules/.pnpm/@kidd-cli+core@0.
|
|
2154
|
+
//#region ../../node_modules/.pnpm/@kidd-cli+core@0.10.0_chokidar@5.0.0_jiti@2.6.1_magicast@0.5.2_vitest@4.1.0_@opentelemetry+ap_h5jt7i6rdfwaknd5di57zdj5zy/node_modules/@kidd-cli/core/dist/lib/logger.js
|
|
2152
2155
|
/**
|
|
2153
2156
|
* Create a new {@link CliLogger} instance.
|
|
2154
2157
|
*
|
|
@@ -2204,13 +2207,13 @@ function createCliLogger(options = {}) {
|
|
|
2204
2207
|
}
|
|
2205
2208
|
var cliLogger;
|
|
2206
2209
|
var init_logger = __esmMin((() => {
|
|
2207
|
-
|
|
2208
|
-
init_dist$
|
|
2210
|
+
init_tally_KfEitTrZ();
|
|
2211
|
+
init_dist$9();
|
|
2209
2212
|
cliLogger = createCliLogger();
|
|
2210
2213
|
}));
|
|
2211
2214
|
|
|
2212
2215
|
//#endregion
|
|
2213
|
-
//#region ../../node_modules/.pnpm/@kidd-cli+utils@0.1.
|
|
2216
|
+
//#region ../../node_modules/.pnpm/@kidd-cli+utils@0.1.5/node_modules/@kidd-cli/utils/dist/tag.js
|
|
2214
2217
|
/**
|
|
2215
2218
|
* Create a shallow copy of `obj` with a non-enumerable {@link TAG} property.
|
|
2216
2219
|
*
|
|
@@ -2248,7 +2251,7 @@ var init_tag = __esmMin((() => {
|
|
|
2248
2251
|
}));
|
|
2249
2252
|
|
|
2250
2253
|
//#endregion
|
|
2251
|
-
//#region ../../node_modules/.pnpm/@kidd-cli+utils@0.1.
|
|
2254
|
+
//#region ../../node_modules/.pnpm/@kidd-cli+utils@0.1.5/node_modules/@kidd-cli/utils/dist/result-U5VP3FRv.js
|
|
2252
2255
|
/**
|
|
2253
2256
|
* Normalize an unknown caught value into an Error instance.
|
|
2254
2257
|
*
|
|
@@ -2261,31 +2264,23 @@ function toError(value) {
|
|
|
2261
2264
|
if (value instanceof Error) return value;
|
|
2262
2265
|
return new Error(String(value));
|
|
2263
2266
|
}
|
|
2264
|
-
/**
|
|
2265
|
-
* Extract a human-readable message from an unknown caught value.
|
|
2266
|
-
*
|
|
2267
|
-
* If an Error, returns `error.message`. Otherwise returns `String(value)`.
|
|
2268
|
-
*
|
|
2269
|
-
* @param value - The unknown value to extract a message from.
|
|
2270
|
-
* @returns The error message string.
|
|
2271
|
-
*/
|
|
2272
|
-
function toErrorMessage(value) {
|
|
2273
|
-
if (value instanceof Error) return value.message;
|
|
2274
|
-
return String(value);
|
|
2275
|
-
}
|
|
2276
2267
|
function ok(value) {
|
|
2277
2268
|
return [null, value];
|
|
2278
2269
|
}
|
|
2279
2270
|
/**
|
|
2280
|
-
* Construct a failure Result tuple
|
|
2271
|
+
* Construct a failure Result tuple.
|
|
2272
|
+
*
|
|
2273
|
+
* Coerces any value to an `Error` via {@link toError} and returns `[Error, null]`.
|
|
2274
|
+
* For domain-specific error types (e.g. `AuthError`, `IconsError`), use raw
|
|
2275
|
+
* tuple literals instead: `[domainError, null] as const`.
|
|
2281
2276
|
*
|
|
2282
|
-
* @param error - The error value (coerced to Error
|
|
2277
|
+
* @param error - The error value (coerced to Error).
|
|
2283
2278
|
* @returns A Result tuple `[Error, null]`.
|
|
2284
2279
|
*/
|
|
2285
2280
|
function err(error) {
|
|
2286
2281
|
return [toError(error), null];
|
|
2287
2282
|
}
|
|
2288
|
-
var
|
|
2283
|
+
var init_result_U5VP3FRv = __esmMin((() => {}));
|
|
2289
2284
|
|
|
2290
2285
|
//#endregion
|
|
2291
2286
|
//#region ../../node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/array/at.mjs
|
|
@@ -4877,7 +4872,7 @@ var init_invariant = __esmMin((() => {}));
|
|
|
4877
4872
|
|
|
4878
4873
|
//#endregion
|
|
4879
4874
|
//#region ../../node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/index.mjs
|
|
4880
|
-
var init_dist$
|
|
4875
|
+
var init_dist$8 = __esmMin((() => {
|
|
4881
4876
|
init_at();
|
|
4882
4877
|
init_chunk();
|
|
4883
4878
|
init_compact();
|
|
@@ -5061,1725 +5056,563 @@ var init_dist$9 = __esmMin((() => {
|
|
|
5061
5056
|
}));
|
|
5062
5057
|
|
|
5063
5058
|
//#endregion
|
|
5064
|
-
//#region ../../node_modules/.pnpm/@kidd-cli+utils@0.1.
|
|
5065
|
-
var fp_exports = /* @__PURE__ */ __exportAll$1({
|
|
5066
|
-
AbortError: () => AbortError,
|
|
5067
|
-
Mutex: () => Mutex,
|
|
5068
|
-
Semaphore: () => Semaphore,
|
|
5069
|
-
TimeoutError: () => TimeoutError,
|
|
5070
|
-
after: () => after,
|
|
5071
|
-
ary: () => ary,
|
|
5072
|
-
assert: () => invariant,
|
|
5073
|
-
asyncNoop: () => asyncNoop,
|
|
5074
|
-
at: () => at$1,
|
|
5075
|
-
attempt: () => attempt,
|
|
5076
|
-
attemptAsync: () => attemptAsync,
|
|
5077
|
-
before: () => before,
|
|
5078
|
-
camelCase: () => camelCase$1,
|
|
5079
|
-
capitalize: () => capitalize,
|
|
5080
|
-
chunk: () => chunk,
|
|
5081
|
-
clamp: () => clamp,
|
|
5082
|
-
clone: () => clone,
|
|
5083
|
-
cloneDeep: () => cloneDeep,
|
|
5084
|
-
cloneDeepWith: () => cloneDeepWith,
|
|
5085
|
-
compact: () => compact,
|
|
5086
|
-
constantCase: () => constantCase,
|
|
5087
|
-
countBy: () => countBy,
|
|
5088
|
-
curry: () => curry,
|
|
5089
|
-
curryRight: () => curryRight,
|
|
5090
|
-
debounce: () => debounce,
|
|
5091
|
-
deburr: () => deburr,
|
|
5092
|
-
delay: () => delay,
|
|
5093
|
-
difference: () => difference,
|
|
5094
|
-
differenceBy: () => differenceBy,
|
|
5095
|
-
differenceWith: () => differenceWith,
|
|
5096
|
-
drop: () => drop,
|
|
5097
|
-
dropRight: () => dropRight,
|
|
5098
|
-
dropRightWhile: () => dropRightWhile,
|
|
5099
|
-
dropWhile: () => dropWhile,
|
|
5100
|
-
err: () => err,
|
|
5101
|
-
escape: () => escape,
|
|
5102
|
-
escapeRegExp: () => escapeRegExp,
|
|
5103
|
-
fill: () => fill,
|
|
5104
|
-
filterAsync: () => filterAsync,
|
|
5105
|
-
findKey: () => findKey,
|
|
5106
|
-
flatMap: () => flatMap,
|
|
5107
|
-
flatMapAsync: () => flatMapAsync,
|
|
5108
|
-
flatMapDeep: () => flatMapDeep,
|
|
5109
|
-
flatten: () => flatten$1,
|
|
5110
|
-
flattenDeep: () => flattenDeep,
|
|
5111
|
-
flattenObject: () => flattenObject,
|
|
5112
|
-
flow: () => flow,
|
|
5113
|
-
flowRight: () => flowRight,
|
|
5114
|
-
forEachAsync: () => forEachAsync,
|
|
5115
|
-
forEachRight: () => forEachRight,
|
|
5116
|
-
groupBy: () => groupBy,
|
|
5117
|
-
head: () => head,
|
|
5118
|
-
identity: () => identity,
|
|
5119
|
-
inRange: () => inRange,
|
|
5120
|
-
initial: () => initial,
|
|
5121
|
-
intersection: () => intersection,
|
|
5122
|
-
intersectionBy: () => intersectionBy,
|
|
5123
|
-
intersectionWith: () => intersectionWith,
|
|
5124
|
-
invariant: () => invariant,
|
|
5125
|
-
invert: () => invert,
|
|
5126
|
-
isArrayBuffer: () => isArrayBuffer,
|
|
5127
|
-
isBlob: () => isBlob,
|
|
5128
|
-
isBoolean: () => isBoolean$1,
|
|
5129
|
-
isBrowser: () => isBrowser,
|
|
5130
|
-
isBuffer: () => isBuffer$1,
|
|
5131
|
-
isDate: () => isDate,
|
|
5132
|
-
isEmptyObject: () => isEmptyObject,
|
|
5133
|
-
isEqual: () => isEqual,
|
|
5134
|
-
isEqualWith: () => isEqualWith,
|
|
5135
|
-
isError: () => isError,
|
|
5136
|
-
isFile: () => isFile,
|
|
5137
|
-
isFunction: () => isFunction$1,
|
|
5138
|
-
isJSON: () => isJSON,
|
|
5139
|
-
isJSONArray: () => isJSONArray,
|
|
5140
|
-
isJSONObject: () => isJSONObject,
|
|
5141
|
-
isJSONValue: () => isJSONValue,
|
|
5142
|
-
isLength: () => isLength,
|
|
5143
|
-
isMap: () => isMap,
|
|
5144
|
-
isNil: () => isNil,
|
|
5145
|
-
isNode: () => isNode,
|
|
5146
|
-
isNotNil: () => isNotNil,
|
|
5147
|
-
isNull: () => isNull,
|
|
5148
|
-
isNumber: () => isNumber,
|
|
5149
|
-
isPlainObject: () => isPlainObject$2,
|
|
5150
|
-
isPrimitive: () => isPrimitive,
|
|
5151
|
-
isPromise: () => isPromise$1,
|
|
5152
|
-
isRegExp: () => isRegExp,
|
|
5153
|
-
isSet: () => isSet,
|
|
5154
|
-
isString: () => isString,
|
|
5155
|
-
isSubset: () => isSubset,
|
|
5156
|
-
isSubsetWith: () => isSubsetWith,
|
|
5157
|
-
isSymbol: () => isSymbol,
|
|
5158
|
-
isTypedArray: () => isTypedArray,
|
|
5159
|
-
isUndefined: () => isUndefined,
|
|
5160
|
-
isWeakMap: () => isWeakMap,
|
|
5161
|
-
isWeakSet: () => isWeakSet,
|
|
5162
|
-
kebabCase: () => kebabCase,
|
|
5163
|
-
keyBy: () => keyBy,
|
|
5164
|
-
last: () => last,
|
|
5165
|
-
limitAsync: () => limitAsync,
|
|
5166
|
-
lowerCase: () => lowerCase,
|
|
5167
|
-
lowerFirst: () => lowerFirst,
|
|
5168
|
-
mapAsync: () => mapAsync,
|
|
5169
|
-
mapKeys: () => mapKeys,
|
|
5170
|
-
mapValues: () => mapValues,
|
|
5171
|
-
maxBy: () => maxBy,
|
|
5172
|
-
mean: () => mean,
|
|
5173
|
-
meanBy: () => meanBy,
|
|
5174
|
-
median: () => median,
|
|
5175
|
-
medianBy: () => medianBy,
|
|
5176
|
-
memoize: () => memoize,
|
|
5177
|
-
merge: () => merge,
|
|
5178
|
-
mergeWith: () => mergeWith,
|
|
5179
|
-
minBy: () => minBy,
|
|
5180
|
-
negate: () => negate,
|
|
5181
|
-
noop: () => noop,
|
|
5182
|
-
ok: () => ok,
|
|
5183
|
-
omit: () => omit,
|
|
5184
|
-
omitBy: () => omitBy,
|
|
5185
|
-
once: () => once,
|
|
5186
|
-
orderBy: () => orderBy,
|
|
5187
|
-
pad: () => pad,
|
|
5188
|
-
partial: () => partial,
|
|
5189
|
-
partialRight: () => partialRight,
|
|
5190
|
-
partition: () => partition,
|
|
5191
|
-
pascalCase: () => pascalCase,
|
|
5192
|
-
pick: () => pick,
|
|
5193
|
-
pickBy: () => pickBy,
|
|
5194
|
-
pull: () => pull,
|
|
5195
|
-
pullAt: () => pullAt,
|
|
5196
|
-
random: () => random,
|
|
5197
|
-
randomInt: () => randomInt,
|
|
5198
|
-
range: () => range,
|
|
5199
|
-
rangeRight: () => rangeRight,
|
|
5200
|
-
reduceAsync: () => reduceAsync,
|
|
5201
|
-
remove: () => remove,
|
|
5202
|
-
rest: () => rest,
|
|
5203
|
-
retry: () => retry,
|
|
5204
|
-
reverseString: () => reverseString,
|
|
5205
|
-
round: () => round,
|
|
5206
|
-
sample: () => sample,
|
|
5207
|
-
sampleSize: () => sampleSize,
|
|
5208
|
-
shuffle: () => shuffle,
|
|
5209
|
-
snakeCase: () => snakeCase,
|
|
5210
|
-
sortBy: () => sortBy,
|
|
5211
|
-
spread: () => spread,
|
|
5212
|
-
startCase: () => startCase,
|
|
5213
|
-
sum: () => sum,
|
|
5214
|
-
sumBy: () => sumBy,
|
|
5215
|
-
tail: () => tail,
|
|
5216
|
-
take: () => take,
|
|
5217
|
-
takeRight: () => takeRight,
|
|
5218
|
-
takeRightWhile: () => takeRightWhile,
|
|
5219
|
-
takeWhile: () => takeWhile,
|
|
5220
|
-
throttle: () => throttle,
|
|
5221
|
-
timeout: () => timeout,
|
|
5222
|
-
toCamelCaseKeys: () => toCamelCaseKeys,
|
|
5223
|
-
toError: () => toError,
|
|
5224
|
-
toErrorMessage: () => toErrorMessage,
|
|
5225
|
-
toFilled: () => toFilled,
|
|
5226
|
-
toMerged: () => toMerged,
|
|
5227
|
-
toSnakeCaseKeys: () => toSnakeCaseKeys,
|
|
5228
|
-
trim: () => trim,
|
|
5229
|
-
trimEnd: () => trimEnd,
|
|
5230
|
-
trimStart: () => trimStart,
|
|
5231
|
-
unary: () => unary,
|
|
5232
|
-
unescape: () => unescape,
|
|
5233
|
-
union: () => union,
|
|
5234
|
-
unionBy: () => unionBy,
|
|
5235
|
-
unionWith: () => unionWith,
|
|
5236
|
-
uniq: () => uniq,
|
|
5237
|
-
uniqBy: () => uniqBy,
|
|
5238
|
-
uniqWith: () => uniqWith,
|
|
5239
|
-
unzip: () => unzip,
|
|
5240
|
-
unzipWith: () => unzipWith,
|
|
5241
|
-
upperCase: () => upperCase,
|
|
5242
|
-
upperFirst: () => upperFirst,
|
|
5243
|
-
windowed: () => windowed,
|
|
5244
|
-
withTimeout: () => withTimeout,
|
|
5245
|
-
without: () => without,
|
|
5246
|
-
words: () => words,
|
|
5247
|
-
xor: () => xor,
|
|
5248
|
-
xorBy: () => xorBy,
|
|
5249
|
-
xorWith: () => xorWith,
|
|
5250
|
-
zip: () => zip,
|
|
5251
|
-
zipObject: () => zipObject,
|
|
5252
|
-
zipWith: () => zipWith
|
|
5253
|
-
});
|
|
5254
|
-
import * as import_ts_pattern from "ts-pattern";
|
|
5255
|
-
__reExport(fp_exports, import_ts_pattern);
|
|
5256
|
-
var init_fp = __esmMin((() => {
|
|
5257
|
-
init_result_6q08bxKW();
|
|
5258
|
-
init_dist$9();
|
|
5259
|
-
}));
|
|
5260
|
-
|
|
5261
|
-
//#endregion
|
|
5262
|
-
//#region ../../node_modules/.pnpm/@kidd-cli+core@0.5.0_chokidar@5.0.0_jiti@2.6.1_magicast@0.5.2/node_modules/@kidd-cli/core/dist/project-CoWHMVc8.js
|
|
5263
|
-
/**
|
|
5264
|
-
* Walk up the directory tree to find the nearest git project root.
|
|
5265
|
-
*
|
|
5266
|
-
* @param startDir - Directory to start searching from (defaults to cwd).
|
|
5267
|
-
* @returns The project root info, or null if no git root is found.
|
|
5268
|
-
*/
|
|
5269
|
-
function findProjectRoot(startDir = process.cwd()) {
|
|
5270
|
-
/**
|
|
5271
|
-
* Recursively walk up the directory tree searching for a `.git` marker.
|
|
5272
|
-
*
|
|
5273
|
-
* @private
|
|
5274
|
-
*/
|
|
5275
|
-
const findRootRecursive = (currentDir, visited) => {
|
|
5276
|
-
if (visited.has(currentDir)) return null;
|
|
5277
|
-
const nextVisited = new Set([...visited, currentDir]);
|
|
5278
|
-
const gitPath = join(currentDir, ".git");
|
|
5279
|
-
const [checkError, result] = attempt(() => checkGitPath(gitPath, currentDir));
|
|
5280
|
-
if (!checkError && result) return result;
|
|
5281
|
-
const parent = dirname(currentDir);
|
|
5282
|
-
if (parent === currentDir) return null;
|
|
5283
|
-
return findRootRecursive(parent, nextVisited);
|
|
5284
|
-
};
|
|
5285
|
-
return findRootRecursive(resolve(startDir), /* @__PURE__ */ new Set());
|
|
5286
|
-
}
|
|
5059
|
+
//#region ../../node_modules/.pnpm/@kidd-cli+utils@0.1.5/node_modules/@kidd-cli/utils/dist/json.js
|
|
5287
5060
|
/**
|
|
5288
|
-
*
|
|
5061
|
+
* Serialize a value to a JSON string, returning a {@link Result} instead of throwing.
|
|
5289
5062
|
*
|
|
5290
|
-
* @param
|
|
5291
|
-
* @
|
|
5292
|
-
* @
|
|
5063
|
+
* @param data - The value to serialize.
|
|
5064
|
+
* @param options - Serialization options.
|
|
5065
|
+
* @returns A Result tuple with the JSON string or an error message.
|
|
5293
5066
|
*/
|
|
5294
|
-
function
|
|
5295
|
-
const
|
|
5296
|
-
|
|
5297
|
-
|
|
5067
|
+
function jsonStringify(data, options = {}) {
|
|
5068
|
+
const { pretty = false } = options;
|
|
5069
|
+
const [error, value] = attempt(() => {
|
|
5070
|
+
if (pretty) return JSON.stringify(data, null, JSON_INDENT);
|
|
5071
|
+
return JSON.stringify(data);
|
|
5072
|
+
});
|
|
5073
|
+
if (error) return err(`Failed to stringify JSON: ${error.message}`);
|
|
5074
|
+
return ok(value);
|
|
5298
5075
|
}
|
|
5076
|
+
var JSON_INDENT;
|
|
5077
|
+
var init_json$1 = __esmMin((() => {
|
|
5078
|
+
init_result_U5VP3FRv();
|
|
5079
|
+
init_dist$8();
|
|
5080
|
+
JSON_INDENT = 2;
|
|
5081
|
+
}));
|
|
5082
|
+
|
|
5083
|
+
//#endregion
|
|
5084
|
+
//#region ../../node_modules/.pnpm/@kidd-cli+core@0.10.0_chokidar@5.0.0_jiti@2.6.1_magicast@0.5.2_vitest@4.1.0_@opentelemetry+ap_h5jt7i6rdfwaknd5di57zdj5zy/node_modules/@kidd-cli/core/dist/create-context-vWwSL8R5.js
|
|
5299
5085
|
/**
|
|
5300
|
-
*
|
|
5086
|
+
* Create a ContextError with an exit code and optional error code.
|
|
5301
5087
|
*
|
|
5302
|
-
*
|
|
5088
|
+
* Used to surface user-facing CLI errors with clean messages.
|
|
5089
|
+
* The error carries a Symbol-based tag for reliable type-narrowing
|
|
5090
|
+
* via {@link isContextError}.
|
|
5091
|
+
*
|
|
5092
|
+
* @param message - Human-readable error message.
|
|
5093
|
+
* @param options - Optional error code and exit code overrides.
|
|
5094
|
+
* @returns A ContextError instance.
|
|
5303
5095
|
*/
|
|
5304
|
-
function
|
|
5305
|
-
const
|
|
5306
|
-
|
|
5307
|
-
|
|
5308
|
-
|
|
5309
|
-
|
|
5310
|
-
|
|
5311
|
-
|
|
5312
|
-
|
|
5313
|
-
|
|
5314
|
-
|
|
5315
|
-
|
|
5316
|
-
|
|
5317
|
-
}
|
|
5318
|
-
|
|
5096
|
+
function createContextError(message, options) {
|
|
5097
|
+
const data = createContextErrorData(message, options);
|
|
5098
|
+
const error = new Error(data.message);
|
|
5099
|
+
error.name = "ContextError";
|
|
5100
|
+
Object.defineProperty(error, TAG, {
|
|
5101
|
+
enumerable: false,
|
|
5102
|
+
value: "ContextError",
|
|
5103
|
+
writable: false
|
|
5104
|
+
});
|
|
5105
|
+
Object.defineProperty(error, "code", {
|
|
5106
|
+
enumerable: true,
|
|
5107
|
+
value: data.code,
|
|
5108
|
+
writable: false
|
|
5109
|
+
});
|
|
5110
|
+
Object.defineProperty(error, "exitCode", {
|
|
5111
|
+
enumerable: true,
|
|
5112
|
+
value: data.exitCode,
|
|
5113
|
+
writable: false
|
|
5114
|
+
});
|
|
5115
|
+
return error;
|
|
5319
5116
|
}
|
|
5320
5117
|
/**
|
|
5321
|
-
*
|
|
5118
|
+
* Type guard that narrows an unknown value to {@link ContextError}.
|
|
5119
|
+
*
|
|
5120
|
+
* Checks that the value is an Error instance whose `[TAG]` property
|
|
5121
|
+
* equals `'ContextError'`, which distinguishes CLI-layer errors from
|
|
5122
|
+
* unexpected exceptions.
|
|
5123
|
+
*
|
|
5124
|
+
* @param error - The value to check.
|
|
5125
|
+
* @returns `true` when the value is a ContextError.
|
|
5126
|
+
*/
|
|
5127
|
+
function isContextError(error) {
|
|
5128
|
+
if (error instanceof Error) return hasTag(error, "ContextError");
|
|
5129
|
+
return false;
|
|
5130
|
+
}
|
|
5131
|
+
function resolveExitCode(options) {
|
|
5132
|
+
if (options && options.exitCode !== void 0) return options.exitCode;
|
|
5133
|
+
return 1;
|
|
5134
|
+
}
|
|
5135
|
+
function resolveCode(options) {
|
|
5136
|
+
if (options && options.code !== void 0) return options.code;
|
|
5137
|
+
}
|
|
5138
|
+
function createContextErrorData(message, options) {
|
|
5139
|
+
return withTag({
|
|
5140
|
+
code: resolveCode(options),
|
|
5141
|
+
exitCode: resolveExitCode(options),
|
|
5142
|
+
message
|
|
5143
|
+
}, "ContextError");
|
|
5144
|
+
}
|
|
5145
|
+
/**
|
|
5146
|
+
* Create the pure string formatter methods for a context.
|
|
5322
5147
|
*
|
|
5323
5148
|
* @private
|
|
5149
|
+
* @returns A Format instance with json and table formatters.
|
|
5324
5150
|
*/
|
|
5325
|
-
function
|
|
5326
|
-
|
|
5327
|
-
|
|
5328
|
-
|
|
5329
|
-
|
|
5330
|
-
|
|
5331
|
-
|
|
5332
|
-
|
|
5333
|
-
|
|
5151
|
+
function createContextFormat() {
|
|
5152
|
+
return Object.freeze({
|
|
5153
|
+
json(data) {
|
|
5154
|
+
const [, json] = jsonStringify(data, { pretty: true });
|
|
5155
|
+
return `${json}\n`;
|
|
5156
|
+
},
|
|
5157
|
+
table(rows) {
|
|
5158
|
+
if (rows.length === 0) return "";
|
|
5159
|
+
const [firstRow] = rows;
|
|
5160
|
+
if (!firstRow) return "";
|
|
5161
|
+
return formatTable(rows, Object.keys(firstRow));
|
|
5162
|
+
}
|
|
5163
|
+
});
|
|
5334
5164
|
}
|
|
5335
|
-
var GITDIR_RE;
|
|
5336
|
-
var init_project_CoWHMVc8 = __esmMin((() => {
|
|
5337
|
-
init_fp();
|
|
5338
|
-
GITDIR_RE = /^gitdir:\s*(.+)$/;
|
|
5339
|
-
}));
|
|
5340
|
-
|
|
5341
|
-
//#endregion
|
|
5342
|
-
//#region ../../node_modules/.pnpm/@kidd-cli+utils@0.1.4/node_modules/@kidd-cli/utils/dist/json.js
|
|
5343
5165
|
/**
|
|
5344
|
-
*
|
|
5166
|
+
* Format an unknown value as a string for table cell display.
|
|
5345
5167
|
*
|
|
5346
|
-
* @
|
|
5347
|
-
* @
|
|
5168
|
+
* @private
|
|
5169
|
+
* @param val - The value to format.
|
|
5170
|
+
* @returns The stringified value, or empty string for undefined.
|
|
5348
5171
|
*/
|
|
5349
|
-
function
|
|
5350
|
-
|
|
5351
|
-
|
|
5352
|
-
return ok(value);
|
|
5172
|
+
function formatStringValue(val) {
|
|
5173
|
+
if (val === void 0) return "";
|
|
5174
|
+
return String(val);
|
|
5353
5175
|
}
|
|
5354
5176
|
/**
|
|
5355
|
-
*
|
|
5177
|
+
* Create a padded header row string from column keys and widths.
|
|
5356
5178
|
*
|
|
5357
|
-
* @
|
|
5358
|
-
* @param options -
|
|
5359
|
-
* @returns A
|
|
5179
|
+
* @private
|
|
5180
|
+
* @param options - The keys and column widths.
|
|
5181
|
+
* @returns A formatted header string.
|
|
5360
5182
|
*/
|
|
5361
|
-
function
|
|
5362
|
-
const {
|
|
5363
|
-
|
|
5364
|
-
|
|
5365
|
-
|
|
5183
|
+
function createTableHeader(options) {
|
|
5184
|
+
const { keys, widths } = options;
|
|
5185
|
+
return keys.map((key, idx) => {
|
|
5186
|
+
const width = widths[idx];
|
|
5187
|
+
if (width === void 0) return key;
|
|
5188
|
+
return key.padEnd(width);
|
|
5189
|
+
}).join(" ");
|
|
5190
|
+
}
|
|
5191
|
+
/**
|
|
5192
|
+
* Create a padded row string from a data record, column keys, and widths.
|
|
5193
|
+
*
|
|
5194
|
+
* @private
|
|
5195
|
+
* @param options - The row data, keys, and column widths.
|
|
5196
|
+
* @returns A formatted row string.
|
|
5197
|
+
*/
|
|
5198
|
+
function createTableRow(options) {
|
|
5199
|
+
const { row, keys, widths } = options;
|
|
5200
|
+
return keys.map((key, idx) => {
|
|
5201
|
+
const width = widths[idx];
|
|
5202
|
+
const val = formatStringValue(row[key]);
|
|
5203
|
+
if (width === void 0) return val;
|
|
5204
|
+
return val.padEnd(width);
|
|
5205
|
+
}).join(" ");
|
|
5206
|
+
}
|
|
5207
|
+
/**
|
|
5208
|
+
* Compute the maximum column width for each key across all rows.
|
|
5209
|
+
*
|
|
5210
|
+
* @private
|
|
5211
|
+
* @param rows - The data rows.
|
|
5212
|
+
* @param keys - The column keys.
|
|
5213
|
+
* @returns An array of column widths.
|
|
5214
|
+
*/
|
|
5215
|
+
function computeColumnWidths(rows, keys) {
|
|
5216
|
+
return keys.map((key) => {
|
|
5217
|
+
const values = rows.map((row) => formatStringValue(row[key]));
|
|
5218
|
+
return Math.max(key.length, ...values.map((val) => val.length));
|
|
5366
5219
|
});
|
|
5367
|
-
if (error) return err(`Failed to stringify JSON: ${error.message}`);
|
|
5368
|
-
return ok(value);
|
|
5369
5220
|
}
|
|
5370
|
-
var JSON_INDENT;
|
|
5371
|
-
var init_json$1 = __esmMin((() => {
|
|
5372
|
-
init_result_6q08bxKW();
|
|
5373
|
-
init_dist$9();
|
|
5374
|
-
JSON_INDENT = 2;
|
|
5375
|
-
}));
|
|
5376
|
-
|
|
5377
|
-
//#endregion
|
|
5378
|
-
//#region ../../node_modules/.pnpm/@kidd-cli+utils@0.1.4/node_modules/@kidd-cli/utils/dist/validate.js
|
|
5379
5221
|
/**
|
|
5380
|
-
* Format
|
|
5222
|
+
* Format a table (header, separator, rows) as a string.
|
|
5381
5223
|
*
|
|
5382
|
-
* @
|
|
5383
|
-
* @
|
|
5224
|
+
* @private
|
|
5225
|
+
* @param rows - The data rows.
|
|
5226
|
+
* @param keys - The column keys.
|
|
5227
|
+
* @returns The formatted table string.
|
|
5384
5228
|
*/
|
|
5385
|
-
function
|
|
5386
|
-
const
|
|
5387
|
-
|
|
5388
|
-
|
|
5389
|
-
|
|
5229
|
+
function formatTable(rows, keys) {
|
|
5230
|
+
const widths = computeColumnWidths(rows, keys);
|
|
5231
|
+
return `${[
|
|
5232
|
+
createTableHeader({
|
|
5233
|
+
keys,
|
|
5234
|
+
widths
|
|
5235
|
+
}),
|
|
5236
|
+
widths.map((width) => "-".repeat(width)).join(" "),
|
|
5237
|
+
...rows.map((row) => createTableRow({
|
|
5238
|
+
keys,
|
|
5239
|
+
row,
|
|
5240
|
+
widths
|
|
5241
|
+
}))
|
|
5242
|
+
].join("\n")}\n`;
|
|
5243
|
+
}
|
|
5244
|
+
/**
|
|
5245
|
+
* Create the interactive prompt methods for a context.
|
|
5246
|
+
*
|
|
5247
|
+
* @returns A Prompts instance backed by clack.
|
|
5248
|
+
*/
|
|
5249
|
+
function createContextPrompts() {
|
|
5390
5250
|
return {
|
|
5391
|
-
|
|
5392
|
-
|
|
5393
|
-
|
|
5394
|
-
|
|
5395
|
-
|
|
5251
|
+
async confirm(opts) {
|
|
5252
|
+
return unwrapCancelSignal(await Rt$1(opts));
|
|
5253
|
+
},
|
|
5254
|
+
async multiselect(opts) {
|
|
5255
|
+
return unwrapCancelSignal(await Lt$1(opts));
|
|
5256
|
+
},
|
|
5257
|
+
async password(opts) {
|
|
5258
|
+
return unwrapCancelSignal(await Ht$1(opts));
|
|
5259
|
+
},
|
|
5260
|
+
async select(opts) {
|
|
5261
|
+
return unwrapCancelSignal(await Jt$1(opts));
|
|
5262
|
+
},
|
|
5263
|
+
async text(opts) {
|
|
5264
|
+
return unwrapCancelSignal(await Zt$1(opts));
|
|
5265
|
+
}
|
|
5396
5266
|
};
|
|
5397
5267
|
}
|
|
5398
|
-
var init_validate$2 = __esmMin((() => {}));
|
|
5399
|
-
|
|
5400
|
-
//#endregion
|
|
5401
|
-
//#region ../../node_modules/.pnpm/@kidd-cli+utils@0.1.4/node_modules/@kidd-cli/utils/dist/fs.js
|
|
5402
5268
|
/**
|
|
5403
|
-
*
|
|
5269
|
+
* Unwrap a prompt result that may be a cancel symbol.
|
|
5404
5270
|
*
|
|
5405
|
-
*
|
|
5406
|
-
*
|
|
5271
|
+
* If the user cancelled (Ctrl-C), throws a ContextError. Otherwise returns
|
|
5272
|
+
* the typed result value.
|
|
5407
5273
|
*
|
|
5408
|
-
* @
|
|
5409
|
-
* @
|
|
5274
|
+
* @private
|
|
5275
|
+
* @param result - The raw prompt result (value or cancel symbol).
|
|
5276
|
+
* @returns The unwrapped typed value.
|
|
5410
5277
|
*/
|
|
5411
|
-
|
|
5412
|
-
|
|
5413
|
-
|
|
5278
|
+
function unwrapCancelSignal(result) {
|
|
5279
|
+
if (Ct$2(result)) {
|
|
5280
|
+
Nt$1("Operation cancelled.");
|
|
5281
|
+
throw createContextError("Prompt cancelled by user", {
|
|
5282
|
+
code: "PROMPT_CANCELLED",
|
|
5283
|
+
exitCode: 1
|
|
5284
|
+
});
|
|
5285
|
+
}
|
|
5286
|
+
return result;
|
|
5414
5287
|
}
|
|
5415
|
-
var init_fs = __esmMin((() => {
|
|
5416
|
-
init_dist$9();
|
|
5417
|
-
}));
|
|
5418
|
-
|
|
5419
|
-
//#endregion
|
|
5420
|
-
//#region ../../node_modules/.pnpm/jsonc-parser@3.3.1/node_modules/jsonc-parser/lib/esm/impl/scanner.js
|
|
5421
5288
|
/**
|
|
5422
|
-
*
|
|
5423
|
-
*
|
|
5289
|
+
* Create an in-memory key-value store.
|
|
5290
|
+
*
|
|
5291
|
+
* @private
|
|
5292
|
+
* @returns A Store instance backed by a Map.
|
|
5424
5293
|
*/
|
|
5425
|
-
function
|
|
5426
|
-
const
|
|
5427
|
-
|
|
5428
|
-
|
|
5429
|
-
|
|
5430
|
-
|
|
5431
|
-
|
|
5432
|
-
|
|
5433
|
-
|
|
5434
|
-
|
|
5435
|
-
|
|
5436
|
-
|
|
5437
|
-
|
|
5438
|
-
|
|
5294
|
+
function createMemoryStore() {
|
|
5295
|
+
const map = /* @__PURE__ */ new Map();
|
|
5296
|
+
return {
|
|
5297
|
+
clear() {
|
|
5298
|
+
map.clear();
|
|
5299
|
+
},
|
|
5300
|
+
delete(key) {
|
|
5301
|
+
return map.delete(key);
|
|
5302
|
+
},
|
|
5303
|
+
get(key) {
|
|
5304
|
+
return map.get(key);
|
|
5305
|
+
},
|
|
5306
|
+
has(key) {
|
|
5307
|
+
return map.has(key);
|
|
5308
|
+
},
|
|
5309
|
+
set(key, value) {
|
|
5310
|
+
map.set(key, value);
|
|
5439
5311
|
}
|
|
5440
|
-
if (digits < count) value = -1;
|
|
5441
|
-
return value;
|
|
5442
|
-
}
|
|
5443
|
-
function setPosition(newPosition) {
|
|
5444
|
-
pos = newPosition;
|
|
5445
|
-
value = "";
|
|
5446
|
-
tokenOffset = 0;
|
|
5447
|
-
token = 16;
|
|
5448
|
-
scanError = 0;
|
|
5449
|
-
}
|
|
5450
|
-
function scanNumber() {
|
|
5451
|
-
let start = pos;
|
|
5452
|
-
if (text.charCodeAt(pos) === 48) pos++;
|
|
5453
|
-
else {
|
|
5454
|
-
pos++;
|
|
5455
|
-
while (pos < text.length && isDigit(text.charCodeAt(pos))) pos++;
|
|
5456
|
-
}
|
|
5457
|
-
if (pos < text.length && text.charCodeAt(pos) === 46) {
|
|
5458
|
-
pos++;
|
|
5459
|
-
if (pos < text.length && isDigit(text.charCodeAt(pos))) {
|
|
5460
|
-
pos++;
|
|
5461
|
-
while (pos < text.length && isDigit(text.charCodeAt(pos))) pos++;
|
|
5462
|
-
} else {
|
|
5463
|
-
scanError = 3;
|
|
5464
|
-
return text.substring(start, pos);
|
|
5465
|
-
}
|
|
5466
|
-
}
|
|
5467
|
-
let end = pos;
|
|
5468
|
-
if (pos < text.length && (text.charCodeAt(pos) === 69 || text.charCodeAt(pos) === 101)) {
|
|
5469
|
-
pos++;
|
|
5470
|
-
if (pos < text.length && text.charCodeAt(pos) === 43 || text.charCodeAt(pos) === 45) pos++;
|
|
5471
|
-
if (pos < text.length && isDigit(text.charCodeAt(pos))) {
|
|
5472
|
-
pos++;
|
|
5473
|
-
while (pos < text.length && isDigit(text.charCodeAt(pos))) pos++;
|
|
5474
|
-
end = pos;
|
|
5475
|
-
} else scanError = 3;
|
|
5476
|
-
}
|
|
5477
|
-
return text.substring(start, end);
|
|
5478
|
-
}
|
|
5479
|
-
function scanString() {
|
|
5480
|
-
let result = "", start = pos;
|
|
5481
|
-
while (true) {
|
|
5482
|
-
if (pos >= len) {
|
|
5483
|
-
result += text.substring(start, pos);
|
|
5484
|
-
scanError = 2;
|
|
5485
|
-
break;
|
|
5486
|
-
}
|
|
5487
|
-
const ch = text.charCodeAt(pos);
|
|
5488
|
-
if (ch === 34) {
|
|
5489
|
-
result += text.substring(start, pos);
|
|
5490
|
-
pos++;
|
|
5491
|
-
break;
|
|
5492
|
-
}
|
|
5493
|
-
if (ch === 92) {
|
|
5494
|
-
result += text.substring(start, pos);
|
|
5495
|
-
pos++;
|
|
5496
|
-
if (pos >= len) {
|
|
5497
|
-
scanError = 2;
|
|
5498
|
-
break;
|
|
5499
|
-
}
|
|
5500
|
-
switch (text.charCodeAt(pos++)) {
|
|
5501
|
-
case 34:
|
|
5502
|
-
result += "\"";
|
|
5503
|
-
break;
|
|
5504
|
-
case 92:
|
|
5505
|
-
result += "\\";
|
|
5506
|
-
break;
|
|
5507
|
-
case 47:
|
|
5508
|
-
result += "/";
|
|
5509
|
-
break;
|
|
5510
|
-
case 98:
|
|
5511
|
-
result += "\b";
|
|
5512
|
-
break;
|
|
5513
|
-
case 102:
|
|
5514
|
-
result += "\f";
|
|
5515
|
-
break;
|
|
5516
|
-
case 110:
|
|
5517
|
-
result += "\n";
|
|
5518
|
-
break;
|
|
5519
|
-
case 114:
|
|
5520
|
-
result += "\r";
|
|
5521
|
-
break;
|
|
5522
|
-
case 116:
|
|
5523
|
-
result += " ";
|
|
5524
|
-
break;
|
|
5525
|
-
case 117:
|
|
5526
|
-
const ch3 = scanHexDigits(4, true);
|
|
5527
|
-
if (ch3 >= 0) result += String.fromCharCode(ch3);
|
|
5528
|
-
else scanError = 4;
|
|
5529
|
-
break;
|
|
5530
|
-
default: scanError = 5;
|
|
5531
|
-
}
|
|
5532
|
-
start = pos;
|
|
5533
|
-
continue;
|
|
5534
|
-
}
|
|
5535
|
-
if (ch >= 0 && ch <= 31) if (isLineBreak(ch)) {
|
|
5536
|
-
result += text.substring(start, pos);
|
|
5537
|
-
scanError = 2;
|
|
5538
|
-
break;
|
|
5539
|
-
} else scanError = 6;
|
|
5540
|
-
pos++;
|
|
5541
|
-
}
|
|
5542
|
-
return result;
|
|
5543
|
-
}
|
|
5544
|
-
function scanNext() {
|
|
5545
|
-
value = "";
|
|
5546
|
-
scanError = 0;
|
|
5547
|
-
tokenOffset = pos;
|
|
5548
|
-
lineStartOffset = lineNumber;
|
|
5549
|
-
prevTokenLineStartOffset = tokenLineStartOffset;
|
|
5550
|
-
if (pos >= len) {
|
|
5551
|
-
tokenOffset = len;
|
|
5552
|
-
return token = 17;
|
|
5553
|
-
}
|
|
5554
|
-
let code = text.charCodeAt(pos);
|
|
5555
|
-
if (isWhiteSpace(code)) {
|
|
5556
|
-
do {
|
|
5557
|
-
pos++;
|
|
5558
|
-
value += String.fromCharCode(code);
|
|
5559
|
-
code = text.charCodeAt(pos);
|
|
5560
|
-
} while (isWhiteSpace(code));
|
|
5561
|
-
return token = 15;
|
|
5562
|
-
}
|
|
5563
|
-
if (isLineBreak(code)) {
|
|
5564
|
-
pos++;
|
|
5565
|
-
value += String.fromCharCode(code);
|
|
5566
|
-
if (code === 13 && text.charCodeAt(pos) === 10) {
|
|
5567
|
-
pos++;
|
|
5568
|
-
value += "\n";
|
|
5569
|
-
}
|
|
5570
|
-
lineNumber++;
|
|
5571
|
-
tokenLineStartOffset = pos;
|
|
5572
|
-
return token = 14;
|
|
5573
|
-
}
|
|
5574
|
-
switch (code) {
|
|
5575
|
-
case 123:
|
|
5576
|
-
pos++;
|
|
5577
|
-
return token = 1;
|
|
5578
|
-
case 125:
|
|
5579
|
-
pos++;
|
|
5580
|
-
return token = 2;
|
|
5581
|
-
case 91:
|
|
5582
|
-
pos++;
|
|
5583
|
-
return token = 3;
|
|
5584
|
-
case 93:
|
|
5585
|
-
pos++;
|
|
5586
|
-
return token = 4;
|
|
5587
|
-
case 58:
|
|
5588
|
-
pos++;
|
|
5589
|
-
return token = 6;
|
|
5590
|
-
case 44:
|
|
5591
|
-
pos++;
|
|
5592
|
-
return token = 5;
|
|
5593
|
-
case 34:
|
|
5594
|
-
pos++;
|
|
5595
|
-
value = scanString();
|
|
5596
|
-
return token = 10;
|
|
5597
|
-
case 47:
|
|
5598
|
-
const start = pos - 1;
|
|
5599
|
-
if (text.charCodeAt(pos + 1) === 47) {
|
|
5600
|
-
pos += 2;
|
|
5601
|
-
while (pos < len) {
|
|
5602
|
-
if (isLineBreak(text.charCodeAt(pos))) break;
|
|
5603
|
-
pos++;
|
|
5604
|
-
}
|
|
5605
|
-
value = text.substring(start, pos);
|
|
5606
|
-
return token = 12;
|
|
5607
|
-
}
|
|
5608
|
-
if (text.charCodeAt(pos + 1) === 42) {
|
|
5609
|
-
pos += 2;
|
|
5610
|
-
const safeLength = len - 1;
|
|
5611
|
-
let commentClosed = false;
|
|
5612
|
-
while (pos < safeLength) {
|
|
5613
|
-
const ch = text.charCodeAt(pos);
|
|
5614
|
-
if (ch === 42 && text.charCodeAt(pos + 1) === 47) {
|
|
5615
|
-
pos += 2;
|
|
5616
|
-
commentClosed = true;
|
|
5617
|
-
break;
|
|
5618
|
-
}
|
|
5619
|
-
pos++;
|
|
5620
|
-
if (isLineBreak(ch)) {
|
|
5621
|
-
if (ch === 13 && text.charCodeAt(pos) === 10) pos++;
|
|
5622
|
-
lineNumber++;
|
|
5623
|
-
tokenLineStartOffset = pos;
|
|
5624
|
-
}
|
|
5625
|
-
}
|
|
5626
|
-
if (!commentClosed) {
|
|
5627
|
-
pos++;
|
|
5628
|
-
scanError = 1;
|
|
5629
|
-
}
|
|
5630
|
-
value = text.substring(start, pos);
|
|
5631
|
-
return token = 13;
|
|
5632
|
-
}
|
|
5633
|
-
value += String.fromCharCode(code);
|
|
5634
|
-
pos++;
|
|
5635
|
-
return token = 16;
|
|
5636
|
-
case 45:
|
|
5637
|
-
value += String.fromCharCode(code);
|
|
5638
|
-
pos++;
|
|
5639
|
-
if (pos === len || !isDigit(text.charCodeAt(pos))) return token = 16;
|
|
5640
|
-
case 48:
|
|
5641
|
-
case 49:
|
|
5642
|
-
case 50:
|
|
5643
|
-
case 51:
|
|
5644
|
-
case 52:
|
|
5645
|
-
case 53:
|
|
5646
|
-
case 54:
|
|
5647
|
-
case 55:
|
|
5648
|
-
case 56:
|
|
5649
|
-
case 57:
|
|
5650
|
-
value += scanNumber();
|
|
5651
|
-
return token = 11;
|
|
5652
|
-
default:
|
|
5653
|
-
while (pos < len && isUnknownContentCharacter(code)) {
|
|
5654
|
-
pos++;
|
|
5655
|
-
code = text.charCodeAt(pos);
|
|
5656
|
-
}
|
|
5657
|
-
if (tokenOffset !== pos) {
|
|
5658
|
-
value = text.substring(tokenOffset, pos);
|
|
5659
|
-
switch (value) {
|
|
5660
|
-
case "true": return token = 8;
|
|
5661
|
-
case "false": return token = 9;
|
|
5662
|
-
case "null": return token = 7;
|
|
5663
|
-
}
|
|
5664
|
-
return token = 16;
|
|
5665
|
-
}
|
|
5666
|
-
value += String.fromCharCode(code);
|
|
5667
|
-
pos++;
|
|
5668
|
-
return token = 16;
|
|
5669
|
-
}
|
|
5670
|
-
}
|
|
5671
|
-
function isUnknownContentCharacter(code) {
|
|
5672
|
-
if (isWhiteSpace(code) || isLineBreak(code)) return false;
|
|
5673
|
-
switch (code) {
|
|
5674
|
-
case 125:
|
|
5675
|
-
case 93:
|
|
5676
|
-
case 123:
|
|
5677
|
-
case 91:
|
|
5678
|
-
case 34:
|
|
5679
|
-
case 58:
|
|
5680
|
-
case 44:
|
|
5681
|
-
case 47: return false;
|
|
5682
|
-
}
|
|
5683
|
-
return true;
|
|
5684
|
-
}
|
|
5685
|
-
function scanNextNonTrivia() {
|
|
5686
|
-
let result;
|
|
5687
|
-
do
|
|
5688
|
-
result = scanNext();
|
|
5689
|
-
while (result >= 12 && result <= 15);
|
|
5690
|
-
return result;
|
|
5691
|
-
}
|
|
5692
|
-
return {
|
|
5693
|
-
setPosition,
|
|
5694
|
-
getPosition: () => pos,
|
|
5695
|
-
scan: ignoreTrivia ? scanNextNonTrivia : scanNext,
|
|
5696
|
-
getToken: () => token,
|
|
5697
|
-
getTokenValue: () => value,
|
|
5698
|
-
getTokenOffset: () => tokenOffset,
|
|
5699
|
-
getTokenLength: () => pos - tokenOffset,
|
|
5700
|
-
getTokenStartLine: () => lineStartOffset,
|
|
5701
|
-
getTokenStartCharacter: () => tokenOffset - prevTokenLineStartOffset,
|
|
5702
|
-
getTokenError: () => scanError
|
|
5703
5312
|
};
|
|
5704
5313
|
}
|
|
5705
|
-
function isWhiteSpace(ch) {
|
|
5706
|
-
return ch === 32 || ch === 9;
|
|
5707
|
-
}
|
|
5708
|
-
function isLineBreak(ch) {
|
|
5709
|
-
return ch === 10 || ch === 13;
|
|
5710
|
-
}
|
|
5711
|
-
function isDigit(ch) {
|
|
5712
|
-
return ch >= 48 && ch <= 57;
|
|
5713
|
-
}
|
|
5714
|
-
var CharacterCodes;
|
|
5715
|
-
var init_scanner = __esmMin((() => {
|
|
5716
|
-
;
|
|
5717
|
-
(function(CharacterCodes) {
|
|
5718
|
-
CharacterCodes[CharacterCodes["lineFeed"] = 10] = "lineFeed";
|
|
5719
|
-
CharacterCodes[CharacterCodes["carriageReturn"] = 13] = "carriageReturn";
|
|
5720
|
-
CharacterCodes[CharacterCodes["space"] = 32] = "space";
|
|
5721
|
-
CharacterCodes[CharacterCodes["_0"] = 48] = "_0";
|
|
5722
|
-
CharacterCodes[CharacterCodes["_1"] = 49] = "_1";
|
|
5723
|
-
CharacterCodes[CharacterCodes["_2"] = 50] = "_2";
|
|
5724
|
-
CharacterCodes[CharacterCodes["_3"] = 51] = "_3";
|
|
5725
|
-
CharacterCodes[CharacterCodes["_4"] = 52] = "_4";
|
|
5726
|
-
CharacterCodes[CharacterCodes["_5"] = 53] = "_5";
|
|
5727
|
-
CharacterCodes[CharacterCodes["_6"] = 54] = "_6";
|
|
5728
|
-
CharacterCodes[CharacterCodes["_7"] = 55] = "_7";
|
|
5729
|
-
CharacterCodes[CharacterCodes["_8"] = 56] = "_8";
|
|
5730
|
-
CharacterCodes[CharacterCodes["_9"] = 57] = "_9";
|
|
5731
|
-
CharacterCodes[CharacterCodes["a"] = 97] = "a";
|
|
5732
|
-
CharacterCodes[CharacterCodes["b"] = 98] = "b";
|
|
5733
|
-
CharacterCodes[CharacterCodes["c"] = 99] = "c";
|
|
5734
|
-
CharacterCodes[CharacterCodes["d"] = 100] = "d";
|
|
5735
|
-
CharacterCodes[CharacterCodes["e"] = 101] = "e";
|
|
5736
|
-
CharacterCodes[CharacterCodes["f"] = 102] = "f";
|
|
5737
|
-
CharacterCodes[CharacterCodes["g"] = 103] = "g";
|
|
5738
|
-
CharacterCodes[CharacterCodes["h"] = 104] = "h";
|
|
5739
|
-
CharacterCodes[CharacterCodes["i"] = 105] = "i";
|
|
5740
|
-
CharacterCodes[CharacterCodes["j"] = 106] = "j";
|
|
5741
|
-
CharacterCodes[CharacterCodes["k"] = 107] = "k";
|
|
5742
|
-
CharacterCodes[CharacterCodes["l"] = 108] = "l";
|
|
5743
|
-
CharacterCodes[CharacterCodes["m"] = 109] = "m";
|
|
5744
|
-
CharacterCodes[CharacterCodes["n"] = 110] = "n";
|
|
5745
|
-
CharacterCodes[CharacterCodes["o"] = 111] = "o";
|
|
5746
|
-
CharacterCodes[CharacterCodes["p"] = 112] = "p";
|
|
5747
|
-
CharacterCodes[CharacterCodes["q"] = 113] = "q";
|
|
5748
|
-
CharacterCodes[CharacterCodes["r"] = 114] = "r";
|
|
5749
|
-
CharacterCodes[CharacterCodes["s"] = 115] = "s";
|
|
5750
|
-
CharacterCodes[CharacterCodes["t"] = 116] = "t";
|
|
5751
|
-
CharacterCodes[CharacterCodes["u"] = 117] = "u";
|
|
5752
|
-
CharacterCodes[CharacterCodes["v"] = 118] = "v";
|
|
5753
|
-
CharacterCodes[CharacterCodes["w"] = 119] = "w";
|
|
5754
|
-
CharacterCodes[CharacterCodes["x"] = 120] = "x";
|
|
5755
|
-
CharacterCodes[CharacterCodes["y"] = 121] = "y";
|
|
5756
|
-
CharacterCodes[CharacterCodes["z"] = 122] = "z";
|
|
5757
|
-
CharacterCodes[CharacterCodes["A"] = 65] = "A";
|
|
5758
|
-
CharacterCodes[CharacterCodes["B"] = 66] = "B";
|
|
5759
|
-
CharacterCodes[CharacterCodes["C"] = 67] = "C";
|
|
5760
|
-
CharacterCodes[CharacterCodes["D"] = 68] = "D";
|
|
5761
|
-
CharacterCodes[CharacterCodes["E"] = 69] = "E";
|
|
5762
|
-
CharacterCodes[CharacterCodes["F"] = 70] = "F";
|
|
5763
|
-
CharacterCodes[CharacterCodes["G"] = 71] = "G";
|
|
5764
|
-
CharacterCodes[CharacterCodes["H"] = 72] = "H";
|
|
5765
|
-
CharacterCodes[CharacterCodes["I"] = 73] = "I";
|
|
5766
|
-
CharacterCodes[CharacterCodes["J"] = 74] = "J";
|
|
5767
|
-
CharacterCodes[CharacterCodes["K"] = 75] = "K";
|
|
5768
|
-
CharacterCodes[CharacterCodes["L"] = 76] = "L";
|
|
5769
|
-
CharacterCodes[CharacterCodes["M"] = 77] = "M";
|
|
5770
|
-
CharacterCodes[CharacterCodes["N"] = 78] = "N";
|
|
5771
|
-
CharacterCodes[CharacterCodes["O"] = 79] = "O";
|
|
5772
|
-
CharacterCodes[CharacterCodes["P"] = 80] = "P";
|
|
5773
|
-
CharacterCodes[CharacterCodes["Q"] = 81] = "Q";
|
|
5774
|
-
CharacterCodes[CharacterCodes["R"] = 82] = "R";
|
|
5775
|
-
CharacterCodes[CharacterCodes["S"] = 83] = "S";
|
|
5776
|
-
CharacterCodes[CharacterCodes["T"] = 84] = "T";
|
|
5777
|
-
CharacterCodes[CharacterCodes["U"] = 85] = "U";
|
|
5778
|
-
CharacterCodes[CharacterCodes["V"] = 86] = "V";
|
|
5779
|
-
CharacterCodes[CharacterCodes["W"] = 87] = "W";
|
|
5780
|
-
CharacterCodes[CharacterCodes["X"] = 88] = "X";
|
|
5781
|
-
CharacterCodes[CharacterCodes["Y"] = 89] = "Y";
|
|
5782
|
-
CharacterCodes[CharacterCodes["Z"] = 90] = "Z";
|
|
5783
|
-
CharacterCodes[CharacterCodes["asterisk"] = 42] = "asterisk";
|
|
5784
|
-
CharacterCodes[CharacterCodes["backslash"] = 92] = "backslash";
|
|
5785
|
-
CharacterCodes[CharacterCodes["closeBrace"] = 125] = "closeBrace";
|
|
5786
|
-
CharacterCodes[CharacterCodes["closeBracket"] = 93] = "closeBracket";
|
|
5787
|
-
CharacterCodes[CharacterCodes["colon"] = 58] = "colon";
|
|
5788
|
-
CharacterCodes[CharacterCodes["comma"] = 44] = "comma";
|
|
5789
|
-
CharacterCodes[CharacterCodes["dot"] = 46] = "dot";
|
|
5790
|
-
CharacterCodes[CharacterCodes["doubleQuote"] = 34] = "doubleQuote";
|
|
5791
|
-
CharacterCodes[CharacterCodes["minus"] = 45] = "minus";
|
|
5792
|
-
CharacterCodes[CharacterCodes["openBrace"] = 123] = "openBrace";
|
|
5793
|
-
CharacterCodes[CharacterCodes["openBracket"] = 91] = "openBracket";
|
|
5794
|
-
CharacterCodes[CharacterCodes["plus"] = 43] = "plus";
|
|
5795
|
-
CharacterCodes[CharacterCodes["slash"] = 47] = "slash";
|
|
5796
|
-
CharacterCodes[CharacterCodes["formFeed"] = 12] = "formFeed";
|
|
5797
|
-
CharacterCodes[CharacterCodes["tab"] = 9] = "tab";
|
|
5798
|
-
})(CharacterCodes || (CharacterCodes = {}));
|
|
5799
|
-
}));
|
|
5800
|
-
|
|
5801
|
-
//#endregion
|
|
5802
|
-
//#region ../../node_modules/.pnpm/jsonc-parser@3.3.1/node_modules/jsonc-parser/lib/esm/impl/string-intern.js
|
|
5803
|
-
var cachedSpaces, maxCachedValues, cachedBreakLinesWithSpaces;
|
|
5804
|
-
var init_string_intern = __esmMin((() => {
|
|
5805
|
-
cachedSpaces = new Array(20).fill(0).map((_, index) => {
|
|
5806
|
-
return " ".repeat(index);
|
|
5807
|
-
});
|
|
5808
|
-
maxCachedValues = 200;
|
|
5809
|
-
cachedBreakLinesWithSpaces = {
|
|
5810
|
-
" ": {
|
|
5811
|
-
"\n": new Array(maxCachedValues).fill(0).map((_, index) => {
|
|
5812
|
-
return "\n" + " ".repeat(index);
|
|
5813
|
-
}),
|
|
5814
|
-
"\r": new Array(maxCachedValues).fill(0).map((_, index) => {
|
|
5815
|
-
return "\r" + " ".repeat(index);
|
|
5816
|
-
}),
|
|
5817
|
-
"\r\n": new Array(maxCachedValues).fill(0).map((_, index) => {
|
|
5818
|
-
return "\r\n" + " ".repeat(index);
|
|
5819
|
-
})
|
|
5820
|
-
},
|
|
5821
|
-
" ": {
|
|
5822
|
-
"\n": new Array(maxCachedValues).fill(0).map((_, index) => {
|
|
5823
|
-
return "\n" + " ".repeat(index);
|
|
5824
|
-
}),
|
|
5825
|
-
"\r": new Array(maxCachedValues).fill(0).map((_, index) => {
|
|
5826
|
-
return "\r" + " ".repeat(index);
|
|
5827
|
-
}),
|
|
5828
|
-
"\r\n": new Array(maxCachedValues).fill(0).map((_, index) => {
|
|
5829
|
-
return "\r\n" + " ".repeat(index);
|
|
5830
|
-
})
|
|
5831
|
-
}
|
|
5832
|
-
};
|
|
5833
|
-
}));
|
|
5834
|
-
|
|
5835
|
-
//#endregion
|
|
5836
|
-
//#region ../../node_modules/.pnpm/jsonc-parser@3.3.1/node_modules/jsonc-parser/lib/esm/impl/format.js
|
|
5837
|
-
var init_format = __esmMin((() => {
|
|
5838
|
-
init_scanner();
|
|
5839
|
-
init_string_intern();
|
|
5840
|
-
}));
|
|
5841
|
-
|
|
5842
|
-
//#endregion
|
|
5843
|
-
//#region ../../node_modules/.pnpm/jsonc-parser@3.3.1/node_modules/jsonc-parser/lib/esm/impl/parser.js
|
|
5844
5314
|
/**
|
|
5845
|
-
*
|
|
5315
|
+
* Create the {@link Context} object threaded through middleware and command handlers.
|
|
5316
|
+
*
|
|
5317
|
+
* Assembles logger, spinner, format, store, prompts, and meta from
|
|
5318
|
+
* the provided options into a single immutable context. Each sub-system is
|
|
5319
|
+
* constructed via its own factory so this function remains a lean orchestrator.
|
|
5320
|
+
*
|
|
5321
|
+
* @param options - Args, config, and meta for the current invocation.
|
|
5322
|
+
* @returns A fully constructed Context.
|
|
5846
5323
|
*/
|
|
5847
|
-
function
|
|
5848
|
-
const
|
|
5849
|
-
const
|
|
5850
|
-
|
|
5851
|
-
const
|
|
5852
|
-
|
|
5853
|
-
|
|
5854
|
-
|
|
5855
|
-
|
|
5856
|
-
|
|
5324
|
+
function createContext(options) {
|
|
5325
|
+
const ctxLogger = options.logger ?? createCliLogger();
|
|
5326
|
+
const ctxSpinner = options.spinner ?? be$1();
|
|
5327
|
+
const ctxFormat = createContextFormat();
|
|
5328
|
+
const ctxStore = createMemoryStore();
|
|
5329
|
+
const ctxPrompts = options.prompts ?? createContextPrompts();
|
|
5330
|
+
const ctxMeta = {
|
|
5331
|
+
command: options.meta.command,
|
|
5332
|
+
dirs: Object.freeze({ ...options.meta.dirs }),
|
|
5333
|
+
name: options.meta.name,
|
|
5334
|
+
version: options.meta.version
|
|
5857
5335
|
};
|
|
5858
|
-
let isAtPropertyKey = false;
|
|
5859
|
-
function setPreviousNode(value, offset, length, type) {
|
|
5860
|
-
previousNodeInst.value = value;
|
|
5861
|
-
previousNodeInst.offset = offset;
|
|
5862
|
-
previousNodeInst.length = length;
|
|
5863
|
-
previousNodeInst.type = type;
|
|
5864
|
-
previousNodeInst.colonOffset = void 0;
|
|
5865
|
-
previousNode = previousNodeInst;
|
|
5866
|
-
}
|
|
5867
|
-
try {
|
|
5868
|
-
visit$1(text, {
|
|
5869
|
-
onObjectBegin: (offset, length) => {
|
|
5870
|
-
if (position <= offset) throw earlyReturnException;
|
|
5871
|
-
previousNode = void 0;
|
|
5872
|
-
isAtPropertyKey = position > offset;
|
|
5873
|
-
segments.push("");
|
|
5874
|
-
},
|
|
5875
|
-
onObjectProperty: (name, offset, length) => {
|
|
5876
|
-
if (position < offset) throw earlyReturnException;
|
|
5877
|
-
setPreviousNode(name, offset, length, "property");
|
|
5878
|
-
segments[segments.length - 1] = name;
|
|
5879
|
-
if (position <= offset + length) throw earlyReturnException;
|
|
5880
|
-
},
|
|
5881
|
-
onObjectEnd: (offset, length) => {
|
|
5882
|
-
if (position <= offset) throw earlyReturnException;
|
|
5883
|
-
previousNode = void 0;
|
|
5884
|
-
segments.pop();
|
|
5885
|
-
},
|
|
5886
|
-
onArrayBegin: (offset, length) => {
|
|
5887
|
-
if (position <= offset) throw earlyReturnException;
|
|
5888
|
-
previousNode = void 0;
|
|
5889
|
-
segments.push(0);
|
|
5890
|
-
},
|
|
5891
|
-
onArrayEnd: (offset, length) => {
|
|
5892
|
-
if (position <= offset) throw earlyReturnException;
|
|
5893
|
-
previousNode = void 0;
|
|
5894
|
-
segments.pop();
|
|
5895
|
-
},
|
|
5896
|
-
onLiteralValue: (value, offset, length) => {
|
|
5897
|
-
if (position < offset) throw earlyReturnException;
|
|
5898
|
-
setPreviousNode(value, offset, length, getNodeType(value));
|
|
5899
|
-
if (position <= offset + length) throw earlyReturnException;
|
|
5900
|
-
},
|
|
5901
|
-
onSeparator: (sep, offset, length) => {
|
|
5902
|
-
if (position <= offset) throw earlyReturnException;
|
|
5903
|
-
if (sep === ":" && previousNode && previousNode.type === "property") {
|
|
5904
|
-
previousNode.colonOffset = offset;
|
|
5905
|
-
isAtPropertyKey = false;
|
|
5906
|
-
previousNode = void 0;
|
|
5907
|
-
} else if (sep === ",") {
|
|
5908
|
-
const last = segments[segments.length - 1];
|
|
5909
|
-
if (typeof last === "number") segments[segments.length - 1] = last + 1;
|
|
5910
|
-
else {
|
|
5911
|
-
isAtPropertyKey = true;
|
|
5912
|
-
segments[segments.length - 1] = "";
|
|
5913
|
-
}
|
|
5914
|
-
previousNode = void 0;
|
|
5915
|
-
}
|
|
5916
|
-
}
|
|
5917
|
-
});
|
|
5918
|
-
} catch (e) {
|
|
5919
|
-
if (e !== earlyReturnException) throw e;
|
|
5920
|
-
}
|
|
5921
5336
|
return {
|
|
5922
|
-
|
|
5923
|
-
|
|
5924
|
-
|
|
5925
|
-
|
|
5926
|
-
|
|
5927
|
-
for (let i = 0; k < pattern.length && i < segments.length; i++) if (pattern[k] === segments[i] || pattern[k] === "*") k++;
|
|
5928
|
-
else if (pattern[k] !== "**") return false;
|
|
5929
|
-
return k === pattern.length;
|
|
5930
|
-
}
|
|
5931
|
-
};
|
|
5932
|
-
}
|
|
5933
|
-
/**
|
|
5934
|
-
* Parses the given text and returns the object the JSON content represents. On invalid input, the parser tries to be as fault tolerant as possible, but still return a result.
|
|
5935
|
-
* Therefore always check the errors list to find out if the input was valid.
|
|
5936
|
-
*/
|
|
5937
|
-
function parse$3(text, errors = [], options = ParseOptions.DEFAULT) {
|
|
5938
|
-
let currentProperty = null;
|
|
5939
|
-
let currentParent = [];
|
|
5940
|
-
const previousParents = [];
|
|
5941
|
-
function onValue(value) {
|
|
5942
|
-
if (Array.isArray(currentParent)) currentParent.push(value);
|
|
5943
|
-
else if (currentProperty !== null) currentParent[currentProperty] = value;
|
|
5944
|
-
}
|
|
5945
|
-
visit$1(text, {
|
|
5946
|
-
onObjectBegin: () => {
|
|
5947
|
-
const object = {};
|
|
5948
|
-
onValue(object);
|
|
5949
|
-
previousParents.push(currentParent);
|
|
5950
|
-
currentParent = object;
|
|
5951
|
-
currentProperty = null;
|
|
5952
|
-
},
|
|
5953
|
-
onObjectProperty: (name) => {
|
|
5954
|
-
currentProperty = name;
|
|
5955
|
-
},
|
|
5956
|
-
onObjectEnd: () => {
|
|
5957
|
-
currentParent = previousParents.pop();
|
|
5958
|
-
},
|
|
5959
|
-
onArrayBegin: () => {
|
|
5960
|
-
const array = [];
|
|
5961
|
-
onValue(array);
|
|
5962
|
-
previousParents.push(currentParent);
|
|
5963
|
-
currentParent = array;
|
|
5964
|
-
currentProperty = null;
|
|
5965
|
-
},
|
|
5966
|
-
onArrayEnd: () => {
|
|
5967
|
-
currentParent = previousParents.pop();
|
|
5337
|
+
args: options.args,
|
|
5338
|
+
colors: Object.freeze({ ...import_picocolors.default }),
|
|
5339
|
+
config: options.config,
|
|
5340
|
+
fail(message, failOptions) {
|
|
5341
|
+
throw createContextError(message, failOptions);
|
|
5968
5342
|
},
|
|
5969
|
-
|
|
5970
|
-
|
|
5971
|
-
|
|
5972
|
-
|
|
5973
|
-
|
|
5974
|
-
|
|
5975
|
-
});
|
|
5976
|
-
}
|
|
5977
|
-
}, options);
|
|
5978
|
-
return currentParent[0];
|
|
5979
|
-
}
|
|
5980
|
-
/**
|
|
5981
|
-
* Parses the given text and returns a tree representation the JSON content. On invalid input, the parser tries to be as fault tolerant as possible, but still return a result.
|
|
5982
|
-
*/
|
|
5983
|
-
function parseTree$1(text, errors = [], options = ParseOptions.DEFAULT) {
|
|
5984
|
-
let currentParent = {
|
|
5985
|
-
type: "array",
|
|
5986
|
-
offset: -1,
|
|
5987
|
-
length: -1,
|
|
5988
|
-
children: [],
|
|
5989
|
-
parent: void 0
|
|
5343
|
+
format: ctxFormat,
|
|
5344
|
+
logger: ctxLogger,
|
|
5345
|
+
meta: ctxMeta,
|
|
5346
|
+
prompts: ctxPrompts,
|
|
5347
|
+
spinner: ctxSpinner,
|
|
5348
|
+
store: ctxStore
|
|
5990
5349
|
};
|
|
5991
|
-
function ensurePropertyComplete(endOffset) {
|
|
5992
|
-
if (currentParent.type === "property") {
|
|
5993
|
-
currentParent.length = endOffset - currentParent.offset;
|
|
5994
|
-
currentParent = currentParent.parent;
|
|
5995
|
-
}
|
|
5996
|
-
}
|
|
5997
|
-
function onValue(valueNode) {
|
|
5998
|
-
currentParent.children.push(valueNode);
|
|
5999
|
-
return valueNode;
|
|
6000
|
-
}
|
|
6001
|
-
visit$1(text, {
|
|
6002
|
-
onObjectBegin: (offset) => {
|
|
6003
|
-
currentParent = onValue({
|
|
6004
|
-
type: "object",
|
|
6005
|
-
offset,
|
|
6006
|
-
length: -1,
|
|
6007
|
-
parent: currentParent,
|
|
6008
|
-
children: []
|
|
6009
|
-
});
|
|
6010
|
-
},
|
|
6011
|
-
onObjectProperty: (name, offset, length) => {
|
|
6012
|
-
currentParent = onValue({
|
|
6013
|
-
type: "property",
|
|
6014
|
-
offset,
|
|
6015
|
-
length: -1,
|
|
6016
|
-
parent: currentParent,
|
|
6017
|
-
children: []
|
|
6018
|
-
});
|
|
6019
|
-
currentParent.children.push({
|
|
6020
|
-
type: "string",
|
|
6021
|
-
value: name,
|
|
6022
|
-
offset,
|
|
6023
|
-
length,
|
|
6024
|
-
parent: currentParent
|
|
6025
|
-
});
|
|
6026
|
-
},
|
|
6027
|
-
onObjectEnd: (offset, length) => {
|
|
6028
|
-
ensurePropertyComplete(offset + length);
|
|
6029
|
-
currentParent.length = offset + length - currentParent.offset;
|
|
6030
|
-
currentParent = currentParent.parent;
|
|
6031
|
-
ensurePropertyComplete(offset + length);
|
|
6032
|
-
},
|
|
6033
|
-
onArrayBegin: (offset, length) => {
|
|
6034
|
-
currentParent = onValue({
|
|
6035
|
-
type: "array",
|
|
6036
|
-
offset,
|
|
6037
|
-
length: -1,
|
|
6038
|
-
parent: currentParent,
|
|
6039
|
-
children: []
|
|
6040
|
-
});
|
|
6041
|
-
},
|
|
6042
|
-
onArrayEnd: (offset, length) => {
|
|
6043
|
-
currentParent.length = offset + length - currentParent.offset;
|
|
6044
|
-
currentParent = currentParent.parent;
|
|
6045
|
-
ensurePropertyComplete(offset + length);
|
|
6046
|
-
},
|
|
6047
|
-
onLiteralValue: (value, offset, length) => {
|
|
6048
|
-
onValue({
|
|
6049
|
-
type: getNodeType(value),
|
|
6050
|
-
offset,
|
|
6051
|
-
length,
|
|
6052
|
-
parent: currentParent,
|
|
6053
|
-
value
|
|
6054
|
-
});
|
|
6055
|
-
ensurePropertyComplete(offset + length);
|
|
6056
|
-
},
|
|
6057
|
-
onSeparator: (sep, offset, length) => {
|
|
6058
|
-
if (currentParent.type === "property") {
|
|
6059
|
-
if (sep === ":") currentParent.colonOffset = offset;
|
|
6060
|
-
else if (sep === ",") ensurePropertyComplete(offset);
|
|
6061
|
-
}
|
|
6062
|
-
},
|
|
6063
|
-
onError: (error, offset, length) => {
|
|
6064
|
-
errors.push({
|
|
6065
|
-
error,
|
|
6066
|
-
offset,
|
|
6067
|
-
length
|
|
6068
|
-
});
|
|
6069
|
-
}
|
|
6070
|
-
}, options);
|
|
6071
|
-
const result = currentParent.children[0];
|
|
6072
|
-
if (result) delete result.parent;
|
|
6073
|
-
return result;
|
|
6074
|
-
}
|
|
6075
|
-
/**
|
|
6076
|
-
* Finds the node at the given path in a JSON DOM.
|
|
6077
|
-
*/
|
|
6078
|
-
function findNodeAtLocation$1(root, path) {
|
|
6079
|
-
if (!root) return;
|
|
6080
|
-
let node = root;
|
|
6081
|
-
for (let segment of path) if (typeof segment === "string") {
|
|
6082
|
-
if (node.type !== "object" || !Array.isArray(node.children)) return;
|
|
6083
|
-
let found = false;
|
|
6084
|
-
for (const propertyNode of node.children) if (Array.isArray(propertyNode.children) && propertyNode.children[0].value === segment && propertyNode.children.length === 2) {
|
|
6085
|
-
node = propertyNode.children[1];
|
|
6086
|
-
found = true;
|
|
6087
|
-
break;
|
|
6088
|
-
}
|
|
6089
|
-
if (!found) return;
|
|
6090
|
-
} else {
|
|
6091
|
-
const index = segment;
|
|
6092
|
-
if (node.type !== "array" || index < 0 || !Array.isArray(node.children) || index >= node.children.length) return;
|
|
6093
|
-
node = node.children[index];
|
|
6094
|
-
}
|
|
6095
|
-
return node;
|
|
6096
|
-
}
|
|
6097
|
-
/**
|
|
6098
|
-
* Gets the JSON path of the given JSON DOM node
|
|
6099
|
-
*/
|
|
6100
|
-
function getNodePath$1(node) {
|
|
6101
|
-
if (!node.parent || !node.parent.children) return [];
|
|
6102
|
-
const path = getNodePath$1(node.parent);
|
|
6103
|
-
if (node.parent.type === "property") {
|
|
6104
|
-
const key = node.parent.children[0].value;
|
|
6105
|
-
path.push(key);
|
|
6106
|
-
} else if (node.parent.type === "array") {
|
|
6107
|
-
const index = node.parent.children.indexOf(node);
|
|
6108
|
-
if (index !== -1) path.push(index);
|
|
6109
|
-
}
|
|
6110
|
-
return path;
|
|
6111
|
-
}
|
|
6112
|
-
/**
|
|
6113
|
-
* Evaluates the JavaScript object of the given JSON DOM node
|
|
6114
|
-
*/
|
|
6115
|
-
function getNodeValue$1(node) {
|
|
6116
|
-
switch (node.type) {
|
|
6117
|
-
case "array": return node.children.map(getNodeValue$1);
|
|
6118
|
-
case "object":
|
|
6119
|
-
const obj = Object.create(null);
|
|
6120
|
-
for (let prop of node.children) {
|
|
6121
|
-
const valueNode = prop.children[1];
|
|
6122
|
-
if (valueNode) obj[prop.children[0].value] = getNodeValue$1(valueNode);
|
|
6123
|
-
}
|
|
6124
|
-
return obj;
|
|
6125
|
-
case "null":
|
|
6126
|
-
case "string":
|
|
6127
|
-
case "number":
|
|
6128
|
-
case "boolean": return node.value;
|
|
6129
|
-
default: return;
|
|
6130
|
-
}
|
|
6131
|
-
}
|
|
6132
|
-
function contains(node, offset, includeRightBound = false) {
|
|
6133
|
-
return offset >= node.offset && offset < node.offset + node.length || includeRightBound && offset === node.offset + node.length;
|
|
6134
|
-
}
|
|
6135
|
-
/**
|
|
6136
|
-
* Finds the most inner node at the given offset. If includeRightBound is set, also finds nodes that end at the given offset.
|
|
6137
|
-
*/
|
|
6138
|
-
function findNodeAtOffset$1(node, offset, includeRightBound = false) {
|
|
6139
|
-
if (contains(node, offset, includeRightBound)) {
|
|
6140
|
-
const children = node.children;
|
|
6141
|
-
if (Array.isArray(children)) for (let i = 0; i < children.length && children[i].offset <= offset; i++) {
|
|
6142
|
-
const item = findNodeAtOffset$1(children[i], offset, includeRightBound);
|
|
6143
|
-
if (item) return item;
|
|
6144
|
-
}
|
|
6145
|
-
return node;
|
|
6146
|
-
}
|
|
6147
|
-
}
|
|
6148
|
-
/**
|
|
6149
|
-
* Parses the given text and invokes the visitor functions for each object, array and literal reached.
|
|
6150
|
-
*/
|
|
6151
|
-
function visit$1(text, visitor, options = ParseOptions.DEFAULT) {
|
|
6152
|
-
const _scanner = createScanner$1(text, false);
|
|
6153
|
-
const _jsonPath = [];
|
|
6154
|
-
let suppressedCallbacks = 0;
|
|
6155
|
-
function toNoArgVisit(visitFunction) {
|
|
6156
|
-
return visitFunction ? () => suppressedCallbacks === 0 && visitFunction(_scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter()) : () => true;
|
|
6157
|
-
}
|
|
6158
|
-
function toOneArgVisit(visitFunction) {
|
|
6159
|
-
return visitFunction ? (arg) => suppressedCallbacks === 0 && visitFunction(arg, _scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter()) : () => true;
|
|
6160
|
-
}
|
|
6161
|
-
function toOneArgVisitWithPath(visitFunction) {
|
|
6162
|
-
return visitFunction ? (arg) => suppressedCallbacks === 0 && visitFunction(arg, _scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter(), () => _jsonPath.slice()) : () => true;
|
|
6163
|
-
}
|
|
6164
|
-
function toBeginVisit(visitFunction) {
|
|
6165
|
-
return visitFunction ? () => {
|
|
6166
|
-
if (suppressedCallbacks > 0) suppressedCallbacks++;
|
|
6167
|
-
else if (visitFunction(_scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter(), () => _jsonPath.slice()) === false) suppressedCallbacks = 1;
|
|
6168
|
-
} : () => true;
|
|
6169
|
-
}
|
|
6170
|
-
function toEndVisit(visitFunction) {
|
|
6171
|
-
return visitFunction ? () => {
|
|
6172
|
-
if (suppressedCallbacks > 0) suppressedCallbacks--;
|
|
6173
|
-
if (suppressedCallbacks === 0) visitFunction(_scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter());
|
|
6174
|
-
} : () => true;
|
|
6175
|
-
}
|
|
6176
|
-
const onObjectBegin = toBeginVisit(visitor.onObjectBegin), onObjectProperty = toOneArgVisitWithPath(visitor.onObjectProperty), onObjectEnd = toEndVisit(visitor.onObjectEnd), onArrayBegin = toBeginVisit(visitor.onArrayBegin), onArrayEnd = toEndVisit(visitor.onArrayEnd), onLiteralValue = toOneArgVisitWithPath(visitor.onLiteralValue), onSeparator = toOneArgVisit(visitor.onSeparator), onComment = toNoArgVisit(visitor.onComment), onError = toOneArgVisit(visitor.onError);
|
|
6177
|
-
const disallowComments = options && options.disallowComments;
|
|
6178
|
-
const allowTrailingComma = options && options.allowTrailingComma;
|
|
6179
|
-
function scanNext() {
|
|
6180
|
-
while (true) {
|
|
6181
|
-
const token = _scanner.scan();
|
|
6182
|
-
switch (_scanner.getTokenError()) {
|
|
6183
|
-
case 4:
|
|
6184
|
-
handleError(14);
|
|
6185
|
-
break;
|
|
6186
|
-
case 5:
|
|
6187
|
-
handleError(15);
|
|
6188
|
-
break;
|
|
6189
|
-
case 3:
|
|
6190
|
-
handleError(13);
|
|
6191
|
-
break;
|
|
6192
|
-
case 1:
|
|
6193
|
-
if (!disallowComments) handleError(11);
|
|
6194
|
-
break;
|
|
6195
|
-
case 2:
|
|
6196
|
-
handleError(12);
|
|
6197
|
-
break;
|
|
6198
|
-
case 6:
|
|
6199
|
-
handleError(16);
|
|
6200
|
-
break;
|
|
6201
|
-
}
|
|
6202
|
-
switch (token) {
|
|
6203
|
-
case 12:
|
|
6204
|
-
case 13:
|
|
6205
|
-
if (disallowComments) handleError(10);
|
|
6206
|
-
else onComment();
|
|
6207
|
-
break;
|
|
6208
|
-
case 16:
|
|
6209
|
-
handleError(1);
|
|
6210
|
-
break;
|
|
6211
|
-
case 15:
|
|
6212
|
-
case 14: break;
|
|
6213
|
-
default: return token;
|
|
6214
|
-
}
|
|
6215
|
-
}
|
|
6216
|
-
}
|
|
6217
|
-
function handleError(error, skipUntilAfter = [], skipUntil = []) {
|
|
6218
|
-
onError(error);
|
|
6219
|
-
if (skipUntilAfter.length + skipUntil.length > 0) {
|
|
6220
|
-
let token = _scanner.getToken();
|
|
6221
|
-
while (token !== 17) {
|
|
6222
|
-
if (skipUntilAfter.indexOf(token) !== -1) {
|
|
6223
|
-
scanNext();
|
|
6224
|
-
break;
|
|
6225
|
-
} else if (skipUntil.indexOf(token) !== -1) break;
|
|
6226
|
-
token = scanNext();
|
|
6227
|
-
}
|
|
6228
|
-
}
|
|
6229
|
-
}
|
|
6230
|
-
function parseString(isValue) {
|
|
6231
|
-
const value = _scanner.getTokenValue();
|
|
6232
|
-
if (isValue) onLiteralValue(value);
|
|
6233
|
-
else {
|
|
6234
|
-
onObjectProperty(value);
|
|
6235
|
-
_jsonPath.push(value);
|
|
6236
|
-
}
|
|
6237
|
-
scanNext();
|
|
6238
|
-
return true;
|
|
6239
|
-
}
|
|
6240
|
-
function parseLiteral() {
|
|
6241
|
-
switch (_scanner.getToken()) {
|
|
6242
|
-
case 11:
|
|
6243
|
-
const tokenValue = _scanner.getTokenValue();
|
|
6244
|
-
let value = Number(tokenValue);
|
|
6245
|
-
if (isNaN(value)) {
|
|
6246
|
-
handleError(2);
|
|
6247
|
-
value = 0;
|
|
6248
|
-
}
|
|
6249
|
-
onLiteralValue(value);
|
|
6250
|
-
break;
|
|
6251
|
-
case 7:
|
|
6252
|
-
onLiteralValue(null);
|
|
6253
|
-
break;
|
|
6254
|
-
case 8:
|
|
6255
|
-
onLiteralValue(true);
|
|
6256
|
-
break;
|
|
6257
|
-
case 9:
|
|
6258
|
-
onLiteralValue(false);
|
|
6259
|
-
break;
|
|
6260
|
-
default: return false;
|
|
6261
|
-
}
|
|
6262
|
-
scanNext();
|
|
6263
|
-
return true;
|
|
6264
|
-
}
|
|
6265
|
-
function parseProperty() {
|
|
6266
|
-
if (_scanner.getToken() !== 10) {
|
|
6267
|
-
handleError(3, [], [2, 5]);
|
|
6268
|
-
return false;
|
|
6269
|
-
}
|
|
6270
|
-
parseString(false);
|
|
6271
|
-
if (_scanner.getToken() === 6) {
|
|
6272
|
-
onSeparator(":");
|
|
6273
|
-
scanNext();
|
|
6274
|
-
if (!parseValue()) handleError(4, [], [2, 5]);
|
|
6275
|
-
} else handleError(5, [], [2, 5]);
|
|
6276
|
-
_jsonPath.pop();
|
|
6277
|
-
return true;
|
|
6278
|
-
}
|
|
6279
|
-
function parseObject() {
|
|
6280
|
-
onObjectBegin();
|
|
6281
|
-
scanNext();
|
|
6282
|
-
let needsComma = false;
|
|
6283
|
-
while (_scanner.getToken() !== 2 && _scanner.getToken() !== 17) {
|
|
6284
|
-
if (_scanner.getToken() === 5) {
|
|
6285
|
-
if (!needsComma) handleError(4, [], []);
|
|
6286
|
-
onSeparator(",");
|
|
6287
|
-
scanNext();
|
|
6288
|
-
if (_scanner.getToken() === 2 && allowTrailingComma) break;
|
|
6289
|
-
} else if (needsComma) handleError(6, [], []);
|
|
6290
|
-
if (!parseProperty()) handleError(4, [], [2, 5]);
|
|
6291
|
-
needsComma = true;
|
|
6292
|
-
}
|
|
6293
|
-
onObjectEnd();
|
|
6294
|
-
if (_scanner.getToken() !== 2) handleError(7, [2], []);
|
|
6295
|
-
else scanNext();
|
|
6296
|
-
return true;
|
|
6297
|
-
}
|
|
6298
|
-
function parseArray() {
|
|
6299
|
-
onArrayBegin();
|
|
6300
|
-
scanNext();
|
|
6301
|
-
let isFirstElement = true;
|
|
6302
|
-
let needsComma = false;
|
|
6303
|
-
while (_scanner.getToken() !== 4 && _scanner.getToken() !== 17) {
|
|
6304
|
-
if (_scanner.getToken() === 5) {
|
|
6305
|
-
if (!needsComma) handleError(4, [], []);
|
|
6306
|
-
onSeparator(",");
|
|
6307
|
-
scanNext();
|
|
6308
|
-
if (_scanner.getToken() === 4 && allowTrailingComma) break;
|
|
6309
|
-
} else if (needsComma) handleError(6, [], []);
|
|
6310
|
-
if (isFirstElement) {
|
|
6311
|
-
_jsonPath.push(0);
|
|
6312
|
-
isFirstElement = false;
|
|
6313
|
-
} else _jsonPath[_jsonPath.length - 1]++;
|
|
6314
|
-
if (!parseValue()) handleError(4, [], [4, 5]);
|
|
6315
|
-
needsComma = true;
|
|
6316
|
-
}
|
|
6317
|
-
onArrayEnd();
|
|
6318
|
-
if (!isFirstElement) _jsonPath.pop();
|
|
6319
|
-
if (_scanner.getToken() !== 4) handleError(8, [4], []);
|
|
6320
|
-
else scanNext();
|
|
6321
|
-
return true;
|
|
6322
|
-
}
|
|
6323
|
-
function parseValue() {
|
|
6324
|
-
switch (_scanner.getToken()) {
|
|
6325
|
-
case 3: return parseArray();
|
|
6326
|
-
case 1: return parseObject();
|
|
6327
|
-
case 10: return parseString(true);
|
|
6328
|
-
default: return parseLiteral();
|
|
6329
|
-
}
|
|
6330
|
-
}
|
|
6331
|
-
scanNext();
|
|
6332
|
-
if (_scanner.getToken() === 17) {
|
|
6333
|
-
if (options.allowEmptyContent) return true;
|
|
6334
|
-
handleError(4, [], []);
|
|
6335
|
-
return false;
|
|
6336
|
-
}
|
|
6337
|
-
if (!parseValue()) {
|
|
6338
|
-
handleError(4, [], []);
|
|
6339
|
-
return false;
|
|
6340
|
-
}
|
|
6341
|
-
if (_scanner.getToken() !== 17) handleError(9, [], []);
|
|
6342
|
-
return true;
|
|
6343
|
-
}
|
|
6344
|
-
/**
|
|
6345
|
-
* Takes JSON with JavaScript-style comments and remove
|
|
6346
|
-
* them. Optionally replaces every none-newline character
|
|
6347
|
-
* of comments with a replaceCharacter
|
|
6348
|
-
*/
|
|
6349
|
-
function stripComments$1(text, replaceCh) {
|
|
6350
|
-
let _scanner = createScanner$1(text), parts = [], kind, offset = 0, pos;
|
|
6351
|
-
do {
|
|
6352
|
-
pos = _scanner.getPosition();
|
|
6353
|
-
kind = _scanner.scan();
|
|
6354
|
-
switch (kind) {
|
|
6355
|
-
case 12:
|
|
6356
|
-
case 13:
|
|
6357
|
-
case 17:
|
|
6358
|
-
if (offset !== pos) parts.push(text.substring(offset, pos));
|
|
6359
|
-
if (replaceCh !== void 0) parts.push(_scanner.getTokenValue().replace(/[^\r\n]/g, replaceCh));
|
|
6360
|
-
offset = _scanner.getPosition();
|
|
6361
|
-
break;
|
|
6362
|
-
}
|
|
6363
|
-
} while (kind !== 17);
|
|
6364
|
-
return parts.join("");
|
|
6365
5350
|
}
|
|
6366
|
-
|
|
6367
|
-
|
|
6368
|
-
|
|
6369
|
-
|
|
6370
|
-
|
|
6371
|
-
|
|
6372
|
-
|
|
6373
|
-
else if (Array.isArray(value)) return "array";
|
|
6374
|
-
return "object";
|
|
6375
|
-
default: return "null";
|
|
6376
|
-
}
|
|
6377
|
-
}
|
|
6378
|
-
var ParseOptions;
|
|
6379
|
-
var init_parser = __esmMin((() => {
|
|
6380
|
-
init_scanner();
|
|
6381
|
-
;
|
|
6382
|
-
(function(ParseOptions) {
|
|
6383
|
-
ParseOptions.DEFAULT = { allowTrailingComma: false };
|
|
6384
|
-
})(ParseOptions || (ParseOptions = {}));
|
|
5351
|
+
var import_picocolors;
|
|
5352
|
+
var init_create_context_vWwSL8R5 = __esmMin((() => {
|
|
5353
|
+
init_logger();
|
|
5354
|
+
init_dist$9();
|
|
5355
|
+
import_picocolors = /* @__PURE__ */ __toESM(require_picocolors(), 1);
|
|
5356
|
+
init_tag();
|
|
5357
|
+
init_json$1();
|
|
6385
5358
|
}));
|
|
6386
5359
|
|
|
6387
5360
|
//#endregion
|
|
6388
|
-
//#region ../../node_modules/.pnpm
|
|
6389
|
-
var
|
|
6390
|
-
|
|
6391
|
-
|
|
6392
|
-
|
|
6393
|
-
|
|
6394
|
-
|
|
6395
|
-
|
|
6396
|
-
|
|
6397
|
-
|
|
6398
|
-
|
|
6399
|
-
|
|
6400
|
-
|
|
6401
|
-
|
|
6402
|
-
|
|
6403
|
-
|
|
6404
|
-
|
|
6405
|
-
|
|
6406
|
-
|
|
6407
|
-
|
|
6408
|
-
|
|
6409
|
-
|
|
6410
|
-
|
|
6411
|
-
|
|
6412
|
-
|
|
6413
|
-
|
|
6414
|
-
|
|
6415
|
-
|
|
6416
|
-
|
|
6417
|
-
|
|
6418
|
-
|
|
6419
|
-
|
|
6420
|
-
|
|
6421
|
-
|
|
6422
|
-
|
|
6423
|
-
|
|
6424
|
-
|
|
6425
|
-
(
|
|
6426
|
-
|
|
6427
|
-
|
|
6428
|
-
|
|
6429
|
-
|
|
6430
|
-
|
|
6431
|
-
|
|
6432
|
-
|
|
6433
|
-
|
|
6434
|
-
|
|
6435
|
-
(
|
|
6436
|
-
|
|
6437
|
-
|
|
6438
|
-
|
|
6439
|
-
|
|
6440
|
-
|
|
6441
|
-
|
|
6442
|
-
|
|
6443
|
-
|
|
6444
|
-
|
|
6445
|
-
|
|
6446
|
-
|
|
6447
|
-
|
|
6448
|
-
|
|
6449
|
-
|
|
6450
|
-
|
|
6451
|
-
|
|
6452
|
-
|
|
6453
|
-
|
|
6454
|
-
|
|
6455
|
-
|
|
6456
|
-
|
|
6457
|
-
|
|
6458
|
-
|
|
6459
|
-
|
|
6460
|
-
|
|
6461
|
-
|
|
6462
|
-
|
|
6463
|
-
|
|
6464
|
-
(
|
|
6465
|
-
|
|
6466
|
-
|
|
6467
|
-
|
|
6468
|
-
|
|
6469
|
-
|
|
6470
|
-
|
|
6471
|
-
|
|
6472
|
-
|
|
6473
|
-
|
|
6474
|
-
|
|
6475
|
-
|
|
6476
|
-
|
|
6477
|
-
|
|
6478
|
-
|
|
6479
|
-
|
|
6480
|
-
|
|
6481
|
-
|
|
5361
|
+
//#region ../../node_modules/.pnpm/@kidd-cli+utils@0.1.5/node_modules/@kidd-cli/utils/dist/fp.js
|
|
5362
|
+
var fp_exports = /* @__PURE__ */ __exportAll$1({
|
|
5363
|
+
AbortError: () => AbortError,
|
|
5364
|
+
Mutex: () => Mutex,
|
|
5365
|
+
Semaphore: () => Semaphore,
|
|
5366
|
+
TimeoutError: () => TimeoutError,
|
|
5367
|
+
after: () => after,
|
|
5368
|
+
ary: () => ary,
|
|
5369
|
+
assert: () => invariant,
|
|
5370
|
+
asyncNoop: () => asyncNoop,
|
|
5371
|
+
at: () => at$1,
|
|
5372
|
+
attempt: () => attempt,
|
|
5373
|
+
attemptAsync: () => attemptAsync,
|
|
5374
|
+
before: () => before,
|
|
5375
|
+
camelCase: () => camelCase$1,
|
|
5376
|
+
capitalize: () => capitalize,
|
|
5377
|
+
chunk: () => chunk,
|
|
5378
|
+
clamp: () => clamp,
|
|
5379
|
+
clone: () => clone,
|
|
5380
|
+
cloneDeep: () => cloneDeep,
|
|
5381
|
+
cloneDeepWith: () => cloneDeepWith,
|
|
5382
|
+
compact: () => compact,
|
|
5383
|
+
constantCase: () => constantCase,
|
|
5384
|
+
countBy: () => countBy,
|
|
5385
|
+
curry: () => curry,
|
|
5386
|
+
curryRight: () => curryRight,
|
|
5387
|
+
debounce: () => debounce,
|
|
5388
|
+
deburr: () => deburr,
|
|
5389
|
+
delay: () => delay,
|
|
5390
|
+
difference: () => difference,
|
|
5391
|
+
differenceBy: () => differenceBy,
|
|
5392
|
+
differenceWith: () => differenceWith,
|
|
5393
|
+
drop: () => drop,
|
|
5394
|
+
dropRight: () => dropRight,
|
|
5395
|
+
dropRightWhile: () => dropRightWhile,
|
|
5396
|
+
dropWhile: () => dropWhile,
|
|
5397
|
+
err: () => err,
|
|
5398
|
+
escape: () => escape,
|
|
5399
|
+
escapeRegExp: () => escapeRegExp,
|
|
5400
|
+
fill: () => fill,
|
|
5401
|
+
filterAsync: () => filterAsync,
|
|
5402
|
+
findKey: () => findKey,
|
|
5403
|
+
flatMap: () => flatMap,
|
|
5404
|
+
flatMapAsync: () => flatMapAsync,
|
|
5405
|
+
flatMapDeep: () => flatMapDeep,
|
|
5406
|
+
flatten: () => flatten$1,
|
|
5407
|
+
flattenDeep: () => flattenDeep,
|
|
5408
|
+
flattenObject: () => flattenObject,
|
|
5409
|
+
flow: () => flow,
|
|
5410
|
+
flowRight: () => flowRight,
|
|
5411
|
+
forEachAsync: () => forEachAsync,
|
|
5412
|
+
forEachRight: () => forEachRight,
|
|
5413
|
+
groupBy: () => groupBy,
|
|
5414
|
+
head: () => head,
|
|
5415
|
+
identity: () => identity,
|
|
5416
|
+
inRange: () => inRange,
|
|
5417
|
+
initial: () => initial,
|
|
5418
|
+
intersection: () => intersection,
|
|
5419
|
+
intersectionBy: () => intersectionBy,
|
|
5420
|
+
intersectionWith: () => intersectionWith,
|
|
5421
|
+
invariant: () => invariant,
|
|
5422
|
+
invert: () => invert,
|
|
5423
|
+
isArrayBuffer: () => isArrayBuffer,
|
|
5424
|
+
isBlob: () => isBlob,
|
|
5425
|
+
isBoolean: () => isBoolean$1,
|
|
5426
|
+
isBrowser: () => isBrowser,
|
|
5427
|
+
isBuffer: () => isBuffer$1,
|
|
5428
|
+
isDate: () => isDate,
|
|
5429
|
+
isEmptyObject: () => isEmptyObject,
|
|
5430
|
+
isEqual: () => isEqual,
|
|
5431
|
+
isEqualWith: () => isEqualWith,
|
|
5432
|
+
isError: () => isError,
|
|
5433
|
+
isFile: () => isFile,
|
|
5434
|
+
isFunction: () => isFunction$1,
|
|
5435
|
+
isJSON: () => isJSON,
|
|
5436
|
+
isJSONArray: () => isJSONArray,
|
|
5437
|
+
isJSONObject: () => isJSONObject,
|
|
5438
|
+
isJSONValue: () => isJSONValue,
|
|
5439
|
+
isLength: () => isLength,
|
|
5440
|
+
isMap: () => isMap,
|
|
5441
|
+
isNil: () => isNil,
|
|
5442
|
+
isNode: () => isNode,
|
|
5443
|
+
isNotNil: () => isNotNil,
|
|
5444
|
+
isNull: () => isNull,
|
|
5445
|
+
isNumber: () => isNumber,
|
|
5446
|
+
isPlainObject: () => isPlainObject$2,
|
|
5447
|
+
isPrimitive: () => isPrimitive,
|
|
5448
|
+
isPromise: () => isPromise$1,
|
|
5449
|
+
isRegExp: () => isRegExp,
|
|
5450
|
+
isSet: () => isSet,
|
|
5451
|
+
isString: () => isString,
|
|
5452
|
+
isSubset: () => isSubset,
|
|
5453
|
+
isSubsetWith: () => isSubsetWith,
|
|
5454
|
+
isSymbol: () => isSymbol,
|
|
5455
|
+
isTypedArray: () => isTypedArray,
|
|
5456
|
+
isUndefined: () => isUndefined,
|
|
5457
|
+
isWeakMap: () => isWeakMap,
|
|
5458
|
+
isWeakSet: () => isWeakSet,
|
|
5459
|
+
kebabCase: () => kebabCase,
|
|
5460
|
+
keyBy: () => keyBy,
|
|
5461
|
+
last: () => last,
|
|
5462
|
+
limitAsync: () => limitAsync,
|
|
5463
|
+
lowerCase: () => lowerCase,
|
|
5464
|
+
lowerFirst: () => lowerFirst,
|
|
5465
|
+
mapAsync: () => mapAsync,
|
|
5466
|
+
mapKeys: () => mapKeys,
|
|
5467
|
+
mapValues: () => mapValues,
|
|
5468
|
+
maxBy: () => maxBy,
|
|
5469
|
+
mean: () => mean,
|
|
5470
|
+
meanBy: () => meanBy,
|
|
5471
|
+
median: () => median,
|
|
5472
|
+
medianBy: () => medianBy,
|
|
5473
|
+
memoize: () => memoize,
|
|
5474
|
+
merge: () => merge,
|
|
5475
|
+
mergeWith: () => mergeWith,
|
|
5476
|
+
minBy: () => minBy,
|
|
5477
|
+
negate: () => negate,
|
|
5478
|
+
noop: () => noop,
|
|
5479
|
+
ok: () => ok,
|
|
5480
|
+
omit: () => omit,
|
|
5481
|
+
omitBy: () => omitBy,
|
|
5482
|
+
once: () => once,
|
|
5483
|
+
orderBy: () => orderBy,
|
|
5484
|
+
pad: () => pad,
|
|
5485
|
+
partial: () => partial,
|
|
5486
|
+
partialRight: () => partialRight,
|
|
5487
|
+
partition: () => partition,
|
|
5488
|
+
pascalCase: () => pascalCase,
|
|
5489
|
+
pick: () => pick,
|
|
5490
|
+
pickBy: () => pickBy,
|
|
5491
|
+
pull: () => pull,
|
|
5492
|
+
pullAt: () => pullAt,
|
|
5493
|
+
random: () => random,
|
|
5494
|
+
randomInt: () => randomInt,
|
|
5495
|
+
range: () => range,
|
|
5496
|
+
rangeRight: () => rangeRight,
|
|
5497
|
+
reduceAsync: () => reduceAsync,
|
|
5498
|
+
remove: () => remove,
|
|
5499
|
+
rest: () => rest,
|
|
5500
|
+
retry: () => retry,
|
|
5501
|
+
reverseString: () => reverseString,
|
|
5502
|
+
round: () => round,
|
|
5503
|
+
sample: () => sample,
|
|
5504
|
+
sampleSize: () => sampleSize,
|
|
5505
|
+
shuffle: () => shuffle,
|
|
5506
|
+
snakeCase: () => snakeCase,
|
|
5507
|
+
sortBy: () => sortBy,
|
|
5508
|
+
spread: () => spread,
|
|
5509
|
+
startCase: () => startCase,
|
|
5510
|
+
sum: () => sum,
|
|
5511
|
+
sumBy: () => sumBy,
|
|
5512
|
+
tail: () => tail,
|
|
5513
|
+
take: () => take,
|
|
5514
|
+
takeRight: () => takeRight,
|
|
5515
|
+
takeRightWhile: () => takeRightWhile,
|
|
5516
|
+
takeWhile: () => takeWhile,
|
|
5517
|
+
throttle: () => throttle,
|
|
5518
|
+
timeout: () => timeout,
|
|
5519
|
+
toCamelCaseKeys: () => toCamelCaseKeys,
|
|
5520
|
+
toError: () => toError,
|
|
5521
|
+
toFilled: () => toFilled,
|
|
5522
|
+
toMerged: () => toMerged,
|
|
5523
|
+
toSnakeCaseKeys: () => toSnakeCaseKeys,
|
|
5524
|
+
trim: () => trim,
|
|
5525
|
+
trimEnd: () => trimEnd,
|
|
5526
|
+
trimStart: () => trimStart,
|
|
5527
|
+
unary: () => unary,
|
|
5528
|
+
unescape: () => unescape,
|
|
5529
|
+
union: () => union,
|
|
5530
|
+
unionBy: () => unionBy,
|
|
5531
|
+
unionWith: () => unionWith,
|
|
5532
|
+
uniq: () => uniq,
|
|
5533
|
+
uniqBy: () => uniqBy,
|
|
5534
|
+
uniqWith: () => uniqWith,
|
|
5535
|
+
unzip: () => unzip,
|
|
5536
|
+
unzipWith: () => unzipWith,
|
|
5537
|
+
upperCase: () => upperCase,
|
|
5538
|
+
upperFirst: () => upperFirst,
|
|
5539
|
+
windowed: () => windowed,
|
|
5540
|
+
withTimeout: () => withTimeout,
|
|
5541
|
+
without: () => without,
|
|
5542
|
+
words: () => words,
|
|
5543
|
+
xor: () => xor,
|
|
5544
|
+
xorBy: () => xorBy,
|
|
5545
|
+
xorWith: () => xorWith,
|
|
5546
|
+
zip: () => zip,
|
|
5547
|
+
zipObject: () => zipObject,
|
|
5548
|
+
zipWith: () => zipWith
|
|
5549
|
+
});
|
|
5550
|
+
import * as import_ts_pattern from "ts-pattern";
|
|
5551
|
+
__reExport(fp_exports, import_ts_pattern);
|
|
5552
|
+
var init_fp = __esmMin((() => {
|
|
5553
|
+
init_result_U5VP3FRv();
|
|
5554
|
+
init_dist$8();
|
|
6482
5555
|
}));
|
|
6483
5556
|
|
|
6484
5557
|
//#endregion
|
|
6485
|
-
//#region ../../node_modules/.pnpm/@kidd-cli+
|
|
6486
|
-
/**
|
|
6487
|
-
* Generate the list of config file names to search for based on the CLI name.
|
|
6488
|
-
*
|
|
6489
|
-
* Produces names like `.myapp.jsonc`, `.myapp.json`, `.myapp.yaml` from the
|
|
6490
|
-
* supported extension list.
|
|
6491
|
-
*
|
|
6492
|
-
* @param name - The CLI name used to derive config file names.
|
|
6493
|
-
* @returns An array of config file names to search for.
|
|
6494
|
-
*/
|
|
6495
|
-
function getConfigFileNames(name) {
|
|
6496
|
-
return CONFIG_EXTENSIONS.map((ext) => `.${name}${ext}`);
|
|
6497
|
-
}
|
|
5558
|
+
//#region ../../node_modules/.pnpm/@kidd-cli+utils@0.1.5/node_modules/@kidd-cli/utils/dist/validate.js
|
|
6498
5559
|
/**
|
|
6499
|
-
*
|
|
5560
|
+
* Validate unknown input against a Zod schema.
|
|
6500
5561
|
*
|
|
6501
|
-
*
|
|
6502
|
-
*
|
|
6503
|
-
*
|
|
5562
|
+
* When validation fails, issues are automatically formatted into a human-readable
|
|
5563
|
+
* message. If a `createError` factory is provided, it receives the formatted
|
|
5564
|
+
* issues and message. Otherwise, a plain `Error` with the formatted message is
|
|
5565
|
+
* returned.
|
|
6504
5566
|
*
|
|
6505
|
-
* @param options -
|
|
6506
|
-
* @
|
|
5567
|
+
* @param options - The validation options.
|
|
5568
|
+
* @param options.schema - The Zod schema to validate against.
|
|
5569
|
+
* @param options.params - The unknown value to validate.
|
|
5570
|
+
* @param options.createError - Optional factory invoked when validation fails.
|
|
5571
|
+
* @returns A Result tuple - either [Error, null] on failure or [null, T] on success.
|
|
6507
5572
|
*/
|
|
6508
|
-
|
|
6509
|
-
const
|
|
6510
|
-
if (
|
|
6511
|
-
const
|
|
6512
|
-
if (
|
|
6513
|
-
|
|
6514
|
-
const fromCwd = await findConfigFile(cwd, fileNames);
|
|
6515
|
-
if (fromCwd) return fromCwd;
|
|
6516
|
-
const projectRoot = findProjectRoot(cwd);
|
|
6517
|
-
if (projectRoot && projectRoot.path !== cwd) {
|
|
6518
|
-
const fromRoot = await findConfigFile(projectRoot.path, fileNames);
|
|
6519
|
-
if (fromRoot) return fromRoot;
|
|
5573
|
+
function validate$1({ schema, params, createError }) {
|
|
5574
|
+
const result = schema.safeParse(params);
|
|
5575
|
+
if (!result.success) {
|
|
5576
|
+
const formatted = formatZodIssues(result.error.issues);
|
|
5577
|
+
if (createError) return err(createError(formatted));
|
|
5578
|
+
return err(formatted.message);
|
|
6520
5579
|
}
|
|
6521
|
-
return
|
|
5580
|
+
return ok(result.data);
|
|
6522
5581
|
}
|
|
6523
5582
|
/**
|
|
6524
|
-
*
|
|
6525
|
-
*
|
|
6526
|
-
* Checks each candidate file name in order and returns the path of the first
|
|
6527
|
-
* one that exists on disk.
|
|
5583
|
+
* Format raw Zod validation issues into structured objects and a human-readable string.
|
|
6528
5584
|
*
|
|
6529
|
-
* @param dir - The directory to search in.
|
|
6530
|
-
* @param fileNames - Candidate config file names to look for.
|
|
6531
|
-
* @returns The full path to the first matching config file, or null if none found.
|
|
6532
5585
|
* @private
|
|
5586
|
+
* @param issues - Raw Zod validation issues.
|
|
5587
|
+
* @param separator - Separator between formatted issue strings.
|
|
5588
|
+
* @returns An object containing the formatted issues array and a joined message string.
|
|
6533
5589
|
*/
|
|
6534
|
-
|
|
6535
|
-
|
|
6536
|
-
|
|
6537
|
-
|
|
6538
|
-
|
|
6539
|
-
|
|
6540
|
-
|
|
6541
|
-
|
|
6542
|
-
|
|
6543
|
-
|
|
6544
|
-
|
|
6545
|
-
|
|
6546
|
-
*/
|
|
6547
|
-
function getFormat(filePath) {
|
|
6548
|
-
return (0, fp_exports.match)(extname(filePath)).with(".jsonc", () => "jsonc").with(".yaml", () => "yaml").otherwise(() => "json");
|
|
6549
|
-
}
|
|
6550
|
-
/**
|
|
6551
|
-
* Parse config file content using the appropriate parser for the given format.
|
|
6552
|
-
*
|
|
6553
|
-
* @param options - Parse content options.
|
|
6554
|
-
* @returns A ConfigOperationResult with the parsed data or an error.
|
|
6555
|
-
*/
|
|
6556
|
-
function parseContent(options) {
|
|
6557
|
-
const { content, filePath, format } = options;
|
|
6558
|
-
return (0, fp_exports.match)(format).with("json", () => parseJson(content, filePath)).with("jsonc", () => parseJsoncContent(content, filePath)).with("yaml", () => parseYamlContent$1(content, filePath)).exhaustive();
|
|
5590
|
+
function formatZodIssues(issues, separator = "\n ") {
|
|
5591
|
+
const formatted = issues.map((issue) => ({
|
|
5592
|
+
message: issue.message,
|
|
5593
|
+
path: issue.path.map(String).join(".")
|
|
5594
|
+
}));
|
|
5595
|
+
return {
|
|
5596
|
+
issues: formatted,
|
|
5597
|
+
message: formatted.map((item) => {
|
|
5598
|
+
if (item.path.length > 0) return `${item.path}: ${item.message}`;
|
|
5599
|
+
return item.message;
|
|
5600
|
+
}).join(separator)
|
|
5601
|
+
};
|
|
6559
5602
|
}
|
|
6560
|
-
|
|
6561
|
-
|
|
6562
|
-
|
|
6563
|
-
|
|
6564
|
-
|
|
6565
|
-
|
|
6566
|
-
|
|
6567
|
-
|
|
6568
|
-
return (
|
|
6569
|
-
const [, json] = jsonStringify(data, { pretty: true });
|
|
6570
|
-
return `${json}\n`;
|
|
6571
|
-
}).with("jsonc", () => {
|
|
6572
|
-
const [, json] = jsonStringify(data, { pretty: true });
|
|
6573
|
-
return `${json}\n`;
|
|
6574
|
-
}).with("yaml", () => stringify(data)).exhaustive();
|
|
5603
|
+
var init_validate$2 = __esmMin((() => {
|
|
5604
|
+
init_result_U5VP3FRv();
|
|
5605
|
+
}));
|
|
5606
|
+
|
|
5607
|
+
//#endregion
|
|
5608
|
+
//#region ../../node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs
|
|
5609
|
+
function normalizeWindowsPath(input = "") {
|
|
5610
|
+
if (!input) return input;
|
|
5611
|
+
return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
|
|
6575
5612
|
}
|
|
6576
|
-
|
|
6577
|
-
|
|
6578
|
-
|
|
6579
|
-
* @param format - The config format.
|
|
6580
|
-
* @returns The file extension including the leading dot (e.g. '.json').
|
|
6581
|
-
*/
|
|
6582
|
-
function getExtension(format) {
|
|
6583
|
-
return (0, fp_exports.match)(format).with("json", () => ".json").with("jsonc", () => ".jsonc").with("yaml", () => ".yaml").exhaustive();
|
|
6584
|
-
}
|
|
6585
|
-
/**
|
|
6586
|
-
* Parse a JSON string and return the result as a ConfigOperationResult.
|
|
6587
|
-
*
|
|
6588
|
-
* @param content - The raw JSON string to parse.
|
|
6589
|
-
* @param filePath - The file path used in error messages.
|
|
6590
|
-
* @returns A ConfigOperationResult with the parsed data or a parse error.
|
|
6591
|
-
* @private
|
|
6592
|
-
*/
|
|
6593
|
-
function parseJson(content, filePath) {
|
|
6594
|
-
const [error, result] = jsonParse(content);
|
|
6595
|
-
if (error) return err(`Failed to parse JSON in ${filePath}: ${error.message}`);
|
|
6596
|
-
return [null, result];
|
|
6597
|
-
}
|
|
6598
|
-
/**
|
|
6599
|
-
* Parse a JSONC (JSON with comments) string and return the result as a ConfigOperationResult.
|
|
6600
|
-
*
|
|
6601
|
-
* @param content - The raw JSONC string to parse.
|
|
6602
|
-
* @param filePath - The file path used in error messages.
|
|
6603
|
-
* @returns A ConfigOperationResult with the parsed data or a parse error.
|
|
6604
|
-
* @private
|
|
6605
|
-
*/
|
|
6606
|
-
function parseJsoncContent(content, filePath) {
|
|
6607
|
-
const errors = [];
|
|
6608
|
-
const result = parse$2(content, errors, {
|
|
6609
|
-
allowEmptyContent: false,
|
|
6610
|
-
allowTrailingComma: true
|
|
6611
|
-
});
|
|
6612
|
-
if (errors.length > 0) return err(`Failed to parse JSONC in ${filePath}:\n${errors.map((parseError) => ` - ${printParseErrorCode(parseError.error)} at offset ${parseError.offset}`).join("\n")}`);
|
|
6613
|
-
return [null, result];
|
|
6614
|
-
}
|
|
6615
|
-
/**
|
|
6616
|
-
* Parse a YAML string and return the result as a ConfigOperationResult.
|
|
6617
|
-
*
|
|
6618
|
-
* @param content - The raw YAML string to parse.
|
|
6619
|
-
* @param filePath - The file path used in error messages.
|
|
6620
|
-
* @returns A ConfigOperationResult with the parsed data or a parse error.
|
|
6621
|
-
* @private
|
|
6622
|
-
*/
|
|
6623
|
-
function parseYamlContent$1(content, filePath) {
|
|
6624
|
-
const [error, result] = attempt(() => parse(content));
|
|
6625
|
-
if (error) return err(`Failed to parse YAML in ${filePath}: ${String(error)}`);
|
|
6626
|
-
return [null, result];
|
|
6627
|
-
}
|
|
6628
|
-
/**
|
|
6629
|
-
* Create a typed config client that loads, validates, and writes config files.
|
|
6630
|
-
*
|
|
6631
|
-
* @param options - Config client options including name and Zod schema.
|
|
6632
|
-
* @returns A {@link Config} client instance.
|
|
6633
|
-
*/
|
|
6634
|
-
function createConfigClient(options) {
|
|
6635
|
-
const { name, schema, searchPaths } = options;
|
|
6636
|
-
const fileNames = getConfigFileNames(name);
|
|
6637
|
-
/**
|
|
6638
|
-
* Find a config file in the given directory.
|
|
6639
|
-
*
|
|
6640
|
-
* @private
|
|
6641
|
-
* @param cwd - Working directory to search from.
|
|
6642
|
-
* @returns The path to the config file, or null if not found.
|
|
6643
|
-
*/
|
|
6644
|
-
async function find(cwd) {
|
|
6645
|
-
return findConfig({
|
|
6646
|
-
cwd: cwd ?? process.cwd(),
|
|
6647
|
-
fileNames,
|
|
6648
|
-
searchPaths
|
|
6649
|
-
});
|
|
6650
|
-
}
|
|
6651
|
-
/**
|
|
6652
|
-
* Load and validate a config file.
|
|
6653
|
-
*
|
|
6654
|
-
* @private
|
|
6655
|
-
* @param cwd - Working directory to search from.
|
|
6656
|
-
* @returns A ConfigOperationResult with the loaded config, or [null, null] if not found.
|
|
6657
|
-
*/
|
|
6658
|
-
async function load(cwd) {
|
|
6659
|
-
const filePath = await find(cwd);
|
|
6660
|
-
if (!filePath) return [null, null];
|
|
6661
|
-
const [readError, content] = await attemptAsync(() => readFile(filePath, "utf8"));
|
|
6662
|
-
if (readError || content === null) return err(`Failed to read config at ${filePath}: ${resolveReadErrorDetail(readError)}`);
|
|
6663
|
-
const format = getFormat(filePath);
|
|
6664
|
-
const parsedResult = parseContent({
|
|
6665
|
-
content,
|
|
6666
|
-
filePath,
|
|
6667
|
-
format
|
|
6668
|
-
});
|
|
6669
|
-
if (parsedResult[0]) return [parsedResult[0], null];
|
|
6670
|
-
const result = schema.safeParse(parsedResult[1]);
|
|
6671
|
-
if (!result.success) {
|
|
6672
|
-
const { message } = formatZodIssues(result.error.issues, "\n");
|
|
6673
|
-
return err(`Invalid config in ${filePath}:\n${message}`);
|
|
6674
|
-
}
|
|
6675
|
-
return [null, {
|
|
6676
|
-
config: result.data,
|
|
6677
|
-
filePath,
|
|
6678
|
-
format
|
|
6679
|
-
}];
|
|
6680
|
-
}
|
|
6681
|
-
/**
|
|
6682
|
-
* Validate and write config data to a file.
|
|
6683
|
-
*
|
|
6684
|
-
* @private
|
|
6685
|
-
* @param data - The config data to write.
|
|
6686
|
-
* @param writeOptions - Write options including path and format.
|
|
6687
|
-
* @returns A ConfigOperationResult with the write result.
|
|
6688
|
-
*/
|
|
6689
|
-
async function write(data, writeOptions = {}) {
|
|
6690
|
-
const result = schema.safeParse(data);
|
|
6691
|
-
if (!result.success) {
|
|
6692
|
-
const { message } = formatZodIssues(result.error.issues, "\n");
|
|
6693
|
-
return err(`Invalid config data:\n${message}`);
|
|
6694
|
-
}
|
|
6695
|
-
const resolvedFormat = (0, fp_exports.match)(writeOptions).when((opts) => opts.format !== null && opts.format !== void 0, (opts) => opts.format ?? "jsonc").when((opts) => opts.filePath !== null && opts.filePath !== void 0, (opts) => getFormat(opts.filePath ?? "")).otherwise(() => "jsonc");
|
|
6696
|
-
const resolvedFilePath = (0, fp_exports.match)(writeOptions.filePath).when((fp) => fp !== null && fp !== void 0, (fp) => fp ?? "").otherwise(() => {
|
|
6697
|
-
return join(writeOptions.dir ?? process.cwd(), `.${name}${getExtension(resolvedFormat)}`);
|
|
6698
|
-
});
|
|
6699
|
-
const serialized = serializeContent(result.data, resolvedFormat);
|
|
6700
|
-
const [mkdirError] = await attemptAsync(() => mkdir(dirname(resolvedFilePath), { recursive: true }));
|
|
6701
|
-
if (mkdirError) return err(`Failed to create directory for ${resolvedFilePath}: ${String(mkdirError)}`);
|
|
6702
|
-
const [writeError] = await attemptAsync(() => writeFile(resolvedFilePath, serialized, "utf8"));
|
|
6703
|
-
if (writeError) return err(`Failed to write config to ${resolvedFilePath}: ${String(writeError)}`);
|
|
6704
|
-
return [null, {
|
|
6705
|
-
filePath: resolvedFilePath,
|
|
6706
|
-
format: resolvedFormat
|
|
6707
|
-
}];
|
|
6708
|
-
}
|
|
6709
|
-
return {
|
|
6710
|
-
find,
|
|
6711
|
-
load,
|
|
6712
|
-
write
|
|
6713
|
-
};
|
|
6714
|
-
}
|
|
6715
|
-
/**
|
|
6716
|
-
* Resolve the error detail string from a read error.
|
|
6717
|
-
*
|
|
6718
|
-
* @private
|
|
6719
|
-
* @param readError - The error from the read operation, or null.
|
|
6720
|
-
* @returns A descriptive error string.
|
|
6721
|
-
*/
|
|
6722
|
-
function resolveReadErrorDetail(readError) {
|
|
6723
|
-
if (readError) return String(readError);
|
|
6724
|
-
return "empty file";
|
|
6725
|
-
}
|
|
6726
|
-
var CONFIG_EXTENSIONS;
|
|
6727
|
-
var init_config_BiEi8RG2 = __esmMin((() => {
|
|
6728
|
-
init_project_CoWHMVc8();
|
|
6729
|
-
init_fp();
|
|
6730
|
-
init_json$1();
|
|
6731
|
-
init_validate$2();
|
|
6732
|
-
init_fs();
|
|
6733
|
-
init_main();
|
|
6734
|
-
CONFIG_EXTENSIONS = [
|
|
6735
|
-
".jsonc",
|
|
6736
|
-
".json",
|
|
6737
|
-
".yaml"
|
|
6738
|
-
];
|
|
6739
|
-
}));
|
|
6740
|
-
|
|
6741
|
-
//#endregion
|
|
6742
|
-
//#region ../../node_modules/.pnpm/@kidd-cli+utils@0.1.4/node_modules/@kidd-cli/utils/dist/manifest.js
|
|
6743
|
-
var ManifestSchema;
|
|
6744
|
-
var init_manifest = __esmMin((() => {
|
|
6745
|
-
ManifestSchema = z.object({
|
|
6746
|
-
author: z.union([z.string(), z.object({
|
|
6747
|
-
email: z.string().optional(),
|
|
6748
|
-
name: z.string(),
|
|
6749
|
-
url: z.string().optional()
|
|
6750
|
-
})]).optional(),
|
|
6751
|
-
bin: z.union([z.string(), z.record(z.string(), z.string())]).optional(),
|
|
6752
|
-
description: z.string().optional(),
|
|
6753
|
-
homepage: z.string().optional(),
|
|
6754
|
-
keywords: z.array(z.string()).optional(),
|
|
6755
|
-
license: z.string().optional(),
|
|
6756
|
-
name: z.string().optional(),
|
|
6757
|
-
repository: z.union([z.string(), z.object({
|
|
6758
|
-
directory: z.string().optional(),
|
|
6759
|
-
type: z.string().optional(),
|
|
6760
|
-
url: z.string()
|
|
6761
|
-
})]).optional(),
|
|
6762
|
-
version: z.string().trim().min(1).optional()
|
|
6763
|
-
});
|
|
6764
|
-
}));
|
|
6765
|
-
|
|
6766
|
-
//#endregion
|
|
6767
|
-
//#region ../../node_modules/.pnpm/@kidd-cli+utils@0.1.4/node_modules/@kidd-cli/utils/dist/index.js
|
|
6768
|
-
var init_dist$8 = __esmMin((() => {
|
|
6769
|
-
init_result_6q08bxKW();
|
|
6770
|
-
init_fp();
|
|
6771
|
-
init_manifest();
|
|
6772
|
-
}));
|
|
6773
|
-
|
|
6774
|
-
//#endregion
|
|
6775
|
-
//#region ../../node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs
|
|
6776
|
-
function normalizeWindowsPath(input = "") {
|
|
6777
|
-
if (!input) return input;
|
|
6778
|
-
return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
|
|
6779
|
-
}
|
|
6780
|
-
function cwd() {
|
|
6781
|
-
if (typeof process !== "undefined" && typeof process.cwd === "function") return process.cwd().replace(/\\/g, "/");
|
|
6782
|
-
return "/";
|
|
5613
|
+
function cwd() {
|
|
5614
|
+
if (typeof process !== "undefined" && typeof process.cwd === "function") return process.cwd().replace(/\\/g, "/");
|
|
5615
|
+
return "/";
|
|
6783
5616
|
}
|
|
6784
5617
|
function normalizeString(path, allowAboveRoot) {
|
|
6785
5618
|
let res = "";
|
|
@@ -11687,7 +10520,7 @@ var require_main = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
11687
10520
|
}));
|
|
11688
10521
|
|
|
11689
10522
|
//#endregion
|
|
11690
|
-
//#region ../../node_modules/.pnpm/c12@4.0.0-beta.
|
|
10523
|
+
//#region ../../node_modules/.pnpm/c12@4.0.0-beta.4_chokidar@5.0.0_dotenv@17.3.1_jiti@2.6.1_magicast@0.5.2/node_modules/c12/dist/_chunks/libs/ohash.mjs
|
|
11691
10524
|
var ohash_exports = /* @__PURE__ */ __exportAll$1({
|
|
11692
10525
|
n: () => dist_exports,
|
|
11693
10526
|
t: () => utils_exports
|
|
@@ -16356,7 +15189,12 @@ var init_jiti = __esmMin((() => {
|
|
|
16356
15189
|
}));
|
|
16357
15190
|
|
|
16358
15191
|
//#endregion
|
|
16359
|
-
//#region ../../node_modules/.pnpm/c12@4.0.0-beta.
|
|
15192
|
+
//#region ../../node_modules/.pnpm/c12@4.0.0-beta.4_chokidar@5.0.0_dotenv@17.3.1_jiti@2.6.1_magicast@0.5.2/node_modules/c12/dist/index.mjs
|
|
15193
|
+
/**
|
|
15194
|
+
* Load and interpolate environment variables into `process.env`.
|
|
15195
|
+
* If you need more control (or access to the values), consider using `loadDotenv` instead
|
|
15196
|
+
*
|
|
15197
|
+
*/
|
|
16360
15198
|
async function setupDotenv(options) {
|
|
16361
15199
|
const targetEnvironment = options.env ?? process.env;
|
|
16362
15200
|
const environment = await loadDotenv({
|
|
@@ -16373,6 +15211,7 @@ async function setupDotenv(options) {
|
|
|
16373
15211
|
}
|
|
16374
15212
|
return environment;
|
|
16375
15213
|
}
|
|
15214
|
+
/** Load environment variables into an object. */
|
|
16376
15215
|
async function loadDotenv(options) {
|
|
16377
15216
|
const environment = Object.create(null);
|
|
16378
15217
|
const cwd = resolve$2(options.cwd || ".");
|
|
@@ -16626,7 +15465,7 @@ async function resolveConfig$1(source, options, sourceOptions = {}) {
|
|
|
16626
15465
|
}
|
|
16627
15466
|
if (NPM_PACKAGE_RE.test(source)) source = tryResolve(source, options) || source;
|
|
16628
15467
|
const ext = extname$3(source);
|
|
16629
|
-
const isDir = !ext || ext === basename$2(source);
|
|
15468
|
+
const isDir = _isDirectory(resolve$2(options.cwd, source)) ?? (!ext || ext === basename$2(source));
|
|
16630
15469
|
const cwd = resolve$2(options.cwd, isDir ? source : dirname$2(source));
|
|
16631
15470
|
if (isDir) source = options.configFile;
|
|
16632
15471
|
const res = {
|
|
@@ -16644,18 +15483,22 @@ async function resolveConfig$1(source, options, sourceOptions = {}) {
|
|
|
16644
15483
|
else {
|
|
16645
15484
|
const _resolveModule = options.resolveModule || ((mod) => mod.default || mod);
|
|
16646
15485
|
if (options.import) res.config = _resolveModule(await options.import(res.configFile));
|
|
16647
|
-
else
|
|
16648
|
-
const
|
|
16649
|
-
|
|
16650
|
-
|
|
16651
|
-
|
|
16652
|
-
|
|
16653
|
-
|
|
16654
|
-
|
|
15486
|
+
else {
|
|
15487
|
+
const _configURL = pathToFileURL(res.configFile);
|
|
15488
|
+
_configURL.search = `_${++importCounter}`;
|
|
15489
|
+
res.config = await import(_configURL.href).then(_resolveModule, async (error) => {
|
|
15490
|
+
const { createJiti } = await Promise.resolve().then(() => (init_jiti(), jiti_exports)).catch(() => {
|
|
15491
|
+
throw new Error(`Failed to load config file \`${res.configFile}\`: ${error?.message}. Hint install \`jiti\` for compatibility.`, { cause: error });
|
|
15492
|
+
});
|
|
15493
|
+
const jiti = createJiti(join$2(options.cwd || ".", options.configFile || "/"), {
|
|
15494
|
+
interopDefault: true,
|
|
15495
|
+
moduleCache: false,
|
|
15496
|
+
extensions: [...SUPPORTED_EXTENSIONS]
|
|
15497
|
+
});
|
|
15498
|
+
options.import = (id) => jiti.import(id);
|
|
15499
|
+
return _resolveModule(await options.import(res.configFile));
|
|
16655
15500
|
});
|
|
16656
|
-
|
|
16657
|
-
return _resolveModule(await options.import(res.configFile));
|
|
16658
|
-
});
|
|
15501
|
+
}
|
|
16659
15502
|
}
|
|
16660
15503
|
if (typeof res.config === "function") res.config = await res.config(options.context);
|
|
16661
15504
|
if (options.envName) {
|
|
@@ -16682,7 +15525,15 @@ function tryResolve(id, options) {
|
|
|
16682
15525
|
});
|
|
16683
15526
|
return res ? normalize$1(res) : void 0;
|
|
16684
15527
|
}
|
|
16685
|
-
|
|
15528
|
+
/** Returns `true`/`false` if the path exists, `null` if it doesn't. */
|
|
15529
|
+
function _isDirectory(path) {
|
|
15530
|
+
try {
|
|
15531
|
+
return statSync(path).isDirectory();
|
|
15532
|
+
} catch {
|
|
15533
|
+
return null;
|
|
15534
|
+
}
|
|
15535
|
+
}
|
|
15536
|
+
var _parseEnv, _normalize, importCounter, ASYNC_LOADERS, SUPPORTED_EXTENSIONS, GIGET_PREFIXES, NPM_PACKAGE_RE;
|
|
16686
15537
|
var init_dist$1 = __esmMin((() => {
|
|
16687
15538
|
init_dist$7();
|
|
16688
15539
|
init_dist$6();
|
|
@@ -16691,6 +15542,7 @@ var init_dist$1 = __esmMin((() => {
|
|
|
16691
15542
|
init_dist$2();
|
|
16692
15543
|
_parseEnv = nodeUtil.parseEnv;
|
|
16693
15544
|
_normalize = (p) => p?.replace(/\\/g, "/");
|
|
15545
|
+
importCounter = 0;
|
|
16694
15546
|
ASYNC_LOADERS = {
|
|
16695
15547
|
".yaml": () => Promise.resolve().then(() => (init_yaml(), yaml_exports)).then((r) => r.parseYAML),
|
|
16696
15548
|
".yml": () => Promise.resolve().then(() => (init_yaml(), yaml_exports)).then((r) => r.parseYAML),
|
|
@@ -16724,145 +15576,416 @@ var init_dist$1 = __esmMin((() => {
|
|
|
16724
15576
|
}));
|
|
16725
15577
|
|
|
16726
15578
|
//#endregion
|
|
16727
|
-
//#region ../../node_modules/.pnpm/@kidd-cli+
|
|
15579
|
+
//#region ../../node_modules/.pnpm/@kidd-cli+core@0.10.0_chokidar@5.0.0_jiti@2.6.1_magicast@0.5.2_vitest@4.1.0_@opentelemetry+ap_h5jt7i6rdfwaknd5di57zdj5zy/node_modules/@kidd-cli/core/dist/config-BSyREvk7.js
|
|
16728
15580
|
/**
|
|
16729
|
-
*
|
|
15581
|
+
* Determine the config format from a file path's extension.
|
|
16730
15582
|
*
|
|
16731
|
-
* @param
|
|
16732
|
-
* @returns
|
|
15583
|
+
* @param filePath - The file path to inspect.
|
|
15584
|
+
* @returns The detected config format.
|
|
16733
15585
|
*/
|
|
16734
|
-
function
|
|
16735
|
-
|
|
16736
|
-
if (!result.success) {
|
|
16737
|
-
const { message } = formatZodIssues(result.error.issues);
|
|
16738
|
-
return err(`Invalid kidd config:\n ${message}`);
|
|
16739
|
-
}
|
|
16740
|
-
return [null, result.data];
|
|
15586
|
+
function getFormat(filePath) {
|
|
15587
|
+
return (0, fp_exports.match)(extname(filePath)).with(".jsonc", () => "jsonc").with(".json5", () => "json5").with(".yaml", ".yml", () => "yaml").with(".toml", () => "toml").with(".ts", ".mts", ".cts", () => "ts").with(".js", ".mjs", ".cjs", () => "js").otherwise(() => "json");
|
|
16741
15588
|
}
|
|
16742
15589
|
/**
|
|
16743
|
-
*
|
|
16744
|
-
*
|
|
16745
|
-
* Searches for a config file named `kidd` (e.g. `kidd.config.ts`, `kidd.config.mts`)
|
|
16746
|
-
* in the given working directory, validates it against the build config schema,
|
|
16747
|
-
* and returns a tagged config object.
|
|
15590
|
+
* Serialize data to a string in the specified config format.
|
|
16748
15591
|
*
|
|
16749
|
-
* @param
|
|
16750
|
-
* @
|
|
15592
|
+
* @param data - The data to serialize.
|
|
15593
|
+
* @param format - The target config format.
|
|
15594
|
+
* @returns A ConfigOperationResult with the serialized string or an error.
|
|
16751
15595
|
*/
|
|
16752
|
-
|
|
16753
|
-
|
|
16754
|
-
const [loadError, loaded] = await attemptAsync(() => loadConfig$1({
|
|
16755
|
-
cwd,
|
|
16756
|
-
defaults,
|
|
16757
|
-
name: "kidd",
|
|
16758
|
-
overrides
|
|
16759
|
-
}));
|
|
16760
|
-
if (loadError || !loaded) return err(`Failed to load kidd config: ${toErrorMessage(loadError)}`);
|
|
16761
|
-
const [validateError, config] = validateConfig(loaded.config);
|
|
16762
|
-
if (validateError) return [validateError, null];
|
|
16763
|
-
return [null, {
|
|
16764
|
-
config: withTag(config, "KiddConfig"),
|
|
16765
|
-
configFile: loaded.configFile
|
|
16766
|
-
}];
|
|
16767
|
-
}
|
|
16768
|
-
var CompileTargetSchema, BuildOptionsSchema, CompileOptionsSchema, KiddConfigSchema;
|
|
16769
|
-
var init_loader = __esmMin((() => {
|
|
16770
|
-
init_tag();
|
|
16771
|
-
init_dist$8();
|
|
16772
|
-
init_fp();
|
|
16773
|
-
init_dist$1();
|
|
16774
|
-
init_dist$9();
|
|
16775
|
-
init_validate$2();
|
|
16776
|
-
CompileTargetSchema = z.enum([
|
|
16777
|
-
"darwin-arm64",
|
|
16778
|
-
"darwin-x64",
|
|
16779
|
-
"linux-arm64",
|
|
16780
|
-
"linux-x64",
|
|
16781
|
-
"linux-x64-musl",
|
|
16782
|
-
"windows-arm64",
|
|
16783
|
-
"windows-x64"
|
|
16784
|
-
]);
|
|
16785
|
-
BuildOptionsSchema = z.object({
|
|
16786
|
-
external: z.array(z.string()).optional(),
|
|
16787
|
-
minify: z.boolean().optional(),
|
|
16788
|
-
out: z.string().optional(),
|
|
16789
|
-
sourcemap: z.boolean().optional(),
|
|
16790
|
-
target: z.string().optional()
|
|
16791
|
-
}).strict();
|
|
16792
|
-
CompileOptionsSchema = z.object({
|
|
16793
|
-
name: z.string().optional(),
|
|
16794
|
-
out: z.string().optional(),
|
|
16795
|
-
targets: z.array(CompileTargetSchema).optional()
|
|
16796
|
-
}).strict();
|
|
16797
|
-
KiddConfigSchema = z.object({
|
|
16798
|
-
build: BuildOptionsSchema.optional(),
|
|
16799
|
-
commands: z.string().optional(),
|
|
16800
|
-
compile: z.union([z.boolean(), CompileOptionsSchema]).optional(),
|
|
16801
|
-
entry: z.string().optional(),
|
|
16802
|
-
include: z.array(z.string()).optional()
|
|
16803
|
-
}).strict();
|
|
16804
|
-
}));
|
|
16805
|
-
|
|
16806
|
-
//#endregion
|
|
16807
|
-
//#region ../../node_modules/.pnpm/cliui@9.0.1/node_modules/cliui/build/lib/index.js
|
|
16808
|
-
function addBorder(col, ts, style) {
|
|
16809
|
-
if (col.border) {
|
|
16810
|
-
if (/[.']-+[.']/.test(ts)) return "";
|
|
16811
|
-
if (ts.trim().length !== 0) return style;
|
|
16812
|
-
return " ";
|
|
16813
|
-
}
|
|
16814
|
-
return "";
|
|
16815
|
-
}
|
|
16816
|
-
function _minWidth(col) {
|
|
16817
|
-
const padding = col.padding || [];
|
|
16818
|
-
const minWidth = 1 + (padding[left] || 0) + (padding[right] || 0);
|
|
16819
|
-
if (col.border) return minWidth + 4;
|
|
16820
|
-
return minWidth;
|
|
16821
|
-
}
|
|
16822
|
-
function getWindowWidth() {
|
|
16823
|
-
/* c8 ignore next 5: depends on terminal */
|
|
16824
|
-
if (typeof process === "object" && process.stdout && process.stdout.columns) return process.stdout.columns;
|
|
16825
|
-
return 80;
|
|
15596
|
+
function serializeContent(data, format) {
|
|
15597
|
+
return (0, fp_exports.match)(format).with("json", "jsonc", () => serializeJson(data)).with("yaml", () => serializeYaml(data)).exhaustive();
|
|
16826
15598
|
}
|
|
16827
|
-
|
|
16828
|
-
|
|
16829
|
-
|
|
16830
|
-
|
|
16831
|
-
|
|
15599
|
+
/**
|
|
15600
|
+
* Get the file extension string for a given write format.
|
|
15601
|
+
*
|
|
15602
|
+
* @param format - The config write format.
|
|
15603
|
+
* @returns The file extension including the leading dot (e.g. '.json').
|
|
15604
|
+
*/
|
|
15605
|
+
function getExtension(format) {
|
|
15606
|
+
return (0, fp_exports.match)(format).with("json", () => ".json").with("jsonc", () => ".jsonc").with("yaml", () => ".yaml").exhaustive();
|
|
16832
15607
|
}
|
|
16833
|
-
|
|
16834
|
-
|
|
16835
|
-
|
|
16836
|
-
|
|
16837
|
-
|
|
16838
|
-
|
|
15608
|
+
/**
|
|
15609
|
+
* Serialize data as pretty-printed JSON with a trailing newline.
|
|
15610
|
+
*
|
|
15611
|
+
* @private
|
|
15612
|
+
* @param data - The data to serialize.
|
|
15613
|
+
* @returns A ConfigOperationResult with the JSON string or a serialization error.
|
|
15614
|
+
*/
|
|
15615
|
+
function serializeJson(data) {
|
|
15616
|
+
const [serializeError, json] = jsonStringify(data, { pretty: true });
|
|
15617
|
+
if (serializeError) return err(`Failed to serialize config as JSON: ${serializeError.message}`);
|
|
15618
|
+
return ok(`${json}\n`);
|
|
16839
15619
|
}
|
|
16840
|
-
|
|
16841
|
-
|
|
16842
|
-
|
|
16843
|
-
|
|
16844
|
-
|
|
16845
|
-
|
|
15620
|
+
/**
|
|
15621
|
+
* Serialize data as YAML.
|
|
15622
|
+
*
|
|
15623
|
+
* @private
|
|
15624
|
+
* @param data - The data to serialize.
|
|
15625
|
+
* @returns A ConfigOperationResult with the YAML string or a serialization error.
|
|
15626
|
+
*/
|
|
15627
|
+
function serializeYaml(data) {
|
|
15628
|
+
const [yamlError, yaml] = attempt(() => stringify(data));
|
|
15629
|
+
if (yamlError) return err(`Failed to serialize config as YAML: ${String(yamlError)}`);
|
|
15630
|
+
return ok(yaml);
|
|
16846
15631
|
}
|
|
16847
|
-
|
|
16848
|
-
|
|
16849
|
-
|
|
16850
|
-
|
|
16851
|
-
|
|
16852
|
-
|
|
16853
|
-
|
|
16854
|
-
|
|
16855
|
-
|
|
16856
|
-
|
|
16857
|
-
|
|
16858
|
-
|
|
16859
|
-
|
|
16860
|
-
|
|
16861
|
-
|
|
16862
|
-
|
|
16863
|
-
|
|
16864
|
-
|
|
16865
|
-
|
|
15632
|
+
/**
|
|
15633
|
+
* Create a typed config client that loads, validates, and writes config files.
|
|
15634
|
+
*
|
|
15635
|
+
* Uses c12 to resolve config files in two passes:
|
|
15636
|
+
*
|
|
15637
|
+
* 1. `name.config.*` — all formats (TS, JS, JSON, JSONC, YAML, TOML)
|
|
15638
|
+
* 2. `name.*` — data formats only (JSON, JSONC, YAML, TOML)
|
|
15639
|
+
*
|
|
15640
|
+
* @param options - Config client options including name and Zod schema.
|
|
15641
|
+
* @returns A {@link ConfigClient} client instance.
|
|
15642
|
+
*/
|
|
15643
|
+
function createConfigClient(options) {
|
|
15644
|
+
const { name, schema, searchPaths } = options;
|
|
15645
|
+
/**
|
|
15646
|
+
* Resolve a config file via c12 for a single directory.
|
|
15647
|
+
*
|
|
15648
|
+
* @private
|
|
15649
|
+
* @param cwd - Directory to search in.
|
|
15650
|
+
* @param configFile - The base config file name (without extension).
|
|
15651
|
+
* @returns The c12 result, or null if nothing was found.
|
|
15652
|
+
*/
|
|
15653
|
+
async function resolveFromDir(cwd, configFile) {
|
|
15654
|
+
const [loadError, loaded] = await attemptAsync(() => loadConfig$1({
|
|
15655
|
+
configFile,
|
|
15656
|
+
cwd,
|
|
15657
|
+
dotenv: false,
|
|
15658
|
+
globalRc: false,
|
|
15659
|
+
name,
|
|
15660
|
+
packageJson: false,
|
|
15661
|
+
rcFile: false
|
|
15662
|
+
}));
|
|
15663
|
+
if (loadError) return err(`Failed to load config from ${cwd}: ${String(loadError)}`);
|
|
15664
|
+
if (!loaded || !hasResolvedConfigFile(loaded.configFile)) return ok(null);
|
|
15665
|
+
return ok(loaded);
|
|
15666
|
+
}
|
|
15667
|
+
/**
|
|
15668
|
+
* Resolve a config file across searchPaths then cwd.
|
|
15669
|
+
*
|
|
15670
|
+
* @private
|
|
15671
|
+
* @param cwd - Working directory.
|
|
15672
|
+
* @param configFile - The base config file name (without extension).
|
|
15673
|
+
* @returns The c12 result, or null if nothing was found.
|
|
15674
|
+
*/
|
|
15675
|
+
async function resolveConfig(cwd, configFile) {
|
|
15676
|
+
if (searchPaths && searchPaths.length > 0) {
|
|
15677
|
+
const results = await Promise.all(searchPaths.map((dir) => resolveFromDir(dir, configFile)));
|
|
15678
|
+
const firstError = results.find(([e]) => e !== null);
|
|
15679
|
+
if (firstError) return firstError;
|
|
15680
|
+
const found = results.find((r) => r[1] !== null);
|
|
15681
|
+
if (found) return found;
|
|
15682
|
+
}
|
|
15683
|
+
return resolveFromDir(cwd, configFile);
|
|
15684
|
+
}
|
|
15685
|
+
/**
|
|
15686
|
+
* Load config using c12 with two-pass resolution.
|
|
15687
|
+
*
|
|
15688
|
+
* First pass: `name.config.*` (all formats).
|
|
15689
|
+
* Second pass: `name.*` (data formats only — no TS/JS).
|
|
15690
|
+
*
|
|
15691
|
+
* @private
|
|
15692
|
+
* @param cwd - Working directory to search from.
|
|
15693
|
+
* @returns The c12 result, or null if nothing was found.
|
|
15694
|
+
*/
|
|
15695
|
+
async function loadConfig$1$1(cwd) {
|
|
15696
|
+
const [longError, longForm] = await resolveConfig(cwd, `${name}.config`);
|
|
15697
|
+
if (longError) return err(longError);
|
|
15698
|
+
if (longForm && hasResolvedConfigFile(longForm.configFile)) return ok(longForm);
|
|
15699
|
+
const [shortError, shortForm] = await resolveConfig(cwd, name);
|
|
15700
|
+
if (shortError) return err(shortError);
|
|
15701
|
+
if (shortForm && hasResolvedConfigFile(shortForm.configFile)) {
|
|
15702
|
+
if (!isDataExtension(shortForm.configFile)) return ok(null);
|
|
15703
|
+
return ok(shortForm);
|
|
15704
|
+
}
|
|
15705
|
+
return ok(null);
|
|
15706
|
+
}
|
|
15707
|
+
/**
|
|
15708
|
+
* Find a config file in the given directory.
|
|
15709
|
+
*
|
|
15710
|
+
* @private
|
|
15711
|
+
* @param cwd - Working directory to search from.
|
|
15712
|
+
* @returns The path to the config file, or null if not found.
|
|
15713
|
+
*/
|
|
15714
|
+
async function find(cwd) {
|
|
15715
|
+
const [, result] = await loadConfig$1$1(cwd ?? process.cwd());
|
|
15716
|
+
if (result && hasResolvedConfigFile(result.configFile)) return result.configFile;
|
|
15717
|
+
return null;
|
|
15718
|
+
}
|
|
15719
|
+
/**
|
|
15720
|
+
* Load and validate a config file.
|
|
15721
|
+
*
|
|
15722
|
+
* @private
|
|
15723
|
+
* @param cwd - Working directory to search from.
|
|
15724
|
+
* @returns A ConfigOperationResult with the loaded config, or null if not found.
|
|
15725
|
+
*/
|
|
15726
|
+
async function load(cwd) {
|
|
15727
|
+
const [loadError, result] = await loadConfig$1$1(cwd ?? process.cwd());
|
|
15728
|
+
if (loadError) return err(loadError);
|
|
15729
|
+
if (!result || !hasResolvedConfigFile(result.configFile)) return ok(null);
|
|
15730
|
+
return validateAndReturn(result.config, result.configFile);
|
|
15731
|
+
}
|
|
15732
|
+
/**
|
|
15733
|
+
* Validate and write config data to a file.
|
|
15734
|
+
*
|
|
15735
|
+
* Defaults to `name.config.jsonc` when no explicit path is given.
|
|
15736
|
+
*
|
|
15737
|
+
* @private
|
|
15738
|
+
* @param data - The config data to write.
|
|
15739
|
+
* @param writeOptions - Write options including path and format.
|
|
15740
|
+
* @returns A ConfigOperationResult with the write result.
|
|
15741
|
+
*/
|
|
15742
|
+
async function write(data, writeOptions = {}) {
|
|
15743
|
+
if (writeOptions.filePath) {
|
|
15744
|
+
const pathFormat = getFormat(writeOptions.filePath);
|
|
15745
|
+
if (pathFormat === "ts" || pathFormat === "js") return err(`Cannot write config to ${writeOptions.filePath}: TS/JS formats are not writable`);
|
|
15746
|
+
}
|
|
15747
|
+
const [validationError, validated] = validate$1({
|
|
15748
|
+
schema,
|
|
15749
|
+
params: data,
|
|
15750
|
+
createError: ({ message }) => /* @__PURE__ */ new Error(`Invalid config data:\n${message}`)
|
|
15751
|
+
});
|
|
15752
|
+
if (validationError) return err(validationError);
|
|
15753
|
+
const resolvedFormat = (0, fp_exports.match)(writeOptions).when((opts) => opts.format !== null && opts.format !== void 0, (opts) => opts.format).when((opts) => opts.filePath !== null && opts.filePath !== void 0, (opts) => getWriteFormat(opts.filePath)).otherwise(() => "jsonc");
|
|
15754
|
+
const resolvedFilePath = (0, fp_exports.match)(writeOptions.filePath).when((fp) => fp !== null && fp !== void 0, (fp) => fp).otherwise(() => {
|
|
15755
|
+
return join(writeOptions.dir ?? process.cwd(), `${name}.config${getExtension(resolvedFormat)}`);
|
|
15756
|
+
});
|
|
15757
|
+
const [serializeError, serialized] = serializeContent(validated, resolvedFormat);
|
|
15758
|
+
if (serializeError) return err(serializeError);
|
|
15759
|
+
const [mkdirError] = await attemptAsync(() => mkdir(dirname(resolvedFilePath), { recursive: true }));
|
|
15760
|
+
if (mkdirError) return err(`Failed to create directory for ${resolvedFilePath}: ${String(mkdirError)}`);
|
|
15761
|
+
const [writeError] = await attemptAsync(() => writeFile(resolvedFilePath, serialized, "utf8"));
|
|
15762
|
+
if (writeError) return err(`Failed to write config to ${resolvedFilePath}: ${String(writeError)}`);
|
|
15763
|
+
return ok({
|
|
15764
|
+
filePath: resolvedFilePath,
|
|
15765
|
+
format: resolvedFormat
|
|
15766
|
+
});
|
|
15767
|
+
}
|
|
15768
|
+
/**
|
|
15769
|
+
* Validate parsed config data and return a typed result.
|
|
15770
|
+
*
|
|
15771
|
+
* @private
|
|
15772
|
+
* @param data - The parsed config data.
|
|
15773
|
+
* @param filePath - Path to the config file.
|
|
15774
|
+
* @returns A ConfigOperationResult with the validated config.
|
|
15775
|
+
*/
|
|
15776
|
+
function validateAndReturn(data, filePath) {
|
|
15777
|
+
const [validationError, validated] = validate$1({
|
|
15778
|
+
schema,
|
|
15779
|
+
params: data,
|
|
15780
|
+
createError: ({ message }) => /* @__PURE__ */ new Error(`Invalid config in ${filePath}:\n${message}`)
|
|
15781
|
+
});
|
|
15782
|
+
if (validationError) return err(validationError);
|
|
15783
|
+
return ok({
|
|
15784
|
+
config: validated,
|
|
15785
|
+
filePath,
|
|
15786
|
+
format: getFormat(filePath)
|
|
15787
|
+
});
|
|
15788
|
+
}
|
|
15789
|
+
return Object.freeze({
|
|
15790
|
+
find,
|
|
15791
|
+
load,
|
|
15792
|
+
write
|
|
15793
|
+
});
|
|
15794
|
+
}
|
|
15795
|
+
/**
|
|
15796
|
+
* Check whether c12 resolved to an actual config file on disk.
|
|
15797
|
+
*
|
|
15798
|
+
* c12 returns just the config name (e.g. `'myapp.config'`) when no file is
|
|
15799
|
+
* found, so an absolute path indicates a real resolution.
|
|
15800
|
+
*
|
|
15801
|
+
* @private
|
|
15802
|
+
* @param configFile - The `configFile` value from c12's result.
|
|
15803
|
+
* @returns `true` when the value is an absolute file path.
|
|
15804
|
+
*/
|
|
15805
|
+
function hasResolvedConfigFile(configFile) {
|
|
15806
|
+
return configFile !== void 0 && isAbsolute(configFile);
|
|
15807
|
+
}
|
|
15808
|
+
/**
|
|
15809
|
+
* Check whether a resolved config file has a data-only extension.
|
|
15810
|
+
*
|
|
15811
|
+
* Used to restrict the short-form config (`name.*`) to data formats,
|
|
15812
|
+
* preventing accidental resolution of `name.ts` or `name.js`.
|
|
15813
|
+
*
|
|
15814
|
+
* @private
|
|
15815
|
+
* @param configFile - The resolved config file path.
|
|
15816
|
+
* @returns `true` when the file has a data extension (JSON, JSONC, YAML, TOML).
|
|
15817
|
+
*/
|
|
15818
|
+
function isDataExtension(configFile) {
|
|
15819
|
+
const ext = extname(configFile);
|
|
15820
|
+
return CONFIG_DATA_EXTENSIONS.has(ext);
|
|
15821
|
+
}
|
|
15822
|
+
/**
|
|
15823
|
+
* Extract a write-safe format from a file path extension.
|
|
15824
|
+
*
|
|
15825
|
+
* Falls back to 'jsonc' for non-writable formats (ts, js).
|
|
15826
|
+
*
|
|
15827
|
+
* @private
|
|
15828
|
+
* @param filePath - The file path to inspect.
|
|
15829
|
+
* @returns A write-compatible format.
|
|
15830
|
+
*/
|
|
15831
|
+
function getWriteFormat(filePath) {
|
|
15832
|
+
return (0, fp_exports.match)(getFormat(filePath)).with("json", () => "json").with("jsonc", () => "jsonc").with("yaml", () => "yaml").otherwise(() => "jsonc");
|
|
15833
|
+
}
|
|
15834
|
+
var CONFIG_DATA_EXTENSIONS;
|
|
15835
|
+
var init_config_BSyREvk7 = __esmMin((() => {
|
|
15836
|
+
init_fp();
|
|
15837
|
+
init_json$1();
|
|
15838
|
+
init_validate$2();
|
|
15839
|
+
init_dist$1();
|
|
15840
|
+
CONFIG_DATA_EXTENSIONS = new Set([
|
|
15841
|
+
".json",
|
|
15842
|
+
".jsonc",
|
|
15843
|
+
".json5",
|
|
15844
|
+
".yaml",
|
|
15845
|
+
".yml",
|
|
15846
|
+
".toml"
|
|
15847
|
+
]);
|
|
15848
|
+
}));
|
|
15849
|
+
|
|
15850
|
+
//#endregion
|
|
15851
|
+
//#region ../../node_modules/.pnpm/@kidd-cli+config@0.1.6_chokidar@5.0.0_dotenv@17.3.1_jiti@2.6.1_magicast@0.5.2/node_modules/@kidd-cli/config/dist/loader.js
|
|
15852
|
+
/**
|
|
15853
|
+
* Validate arbitrary data against the {@link KiddConfigSchema}.
|
|
15854
|
+
*
|
|
15855
|
+
* @param data - The unknown value to validate.
|
|
15856
|
+
* @returns A Result tuple - `[null, KiddConfig]` on success or `[Error, null]` on failure.
|
|
15857
|
+
*/
|
|
15858
|
+
function validateConfig(data) {
|
|
15859
|
+
return validate$1({
|
|
15860
|
+
schema: KiddConfigSchema,
|
|
15861
|
+
params: data,
|
|
15862
|
+
createError: ({ message }) => /* @__PURE__ */ new Error(`Invalid kidd config:\n ${message}`)
|
|
15863
|
+
});
|
|
15864
|
+
}
|
|
15865
|
+
/**
|
|
15866
|
+
* Load and validate a `kidd.config.ts` file using c12.
|
|
15867
|
+
*
|
|
15868
|
+
* Searches for a config file named `kidd` (e.g. `kidd.config.ts`, `kidd.config.mts`)
|
|
15869
|
+
* in the given working directory, validates it against the build config schema,
|
|
15870
|
+
* and returns a tagged config object.
|
|
15871
|
+
*
|
|
15872
|
+
* @param options - Optional loader configuration.
|
|
15873
|
+
* @returns A Result tuple - `[null, LoadConfigResult]` on success or `[Error, null]` on failure.
|
|
15874
|
+
*/
|
|
15875
|
+
async function loadConfig(options) {
|
|
15876
|
+
const { cwd, defaults, overrides } = options ?? {};
|
|
15877
|
+
const [loadError, loaded] = await attemptAsync(() => loadConfig$1({
|
|
15878
|
+
cwd,
|
|
15879
|
+
defaults,
|
|
15880
|
+
name: "kidd",
|
|
15881
|
+
overrides
|
|
15882
|
+
}));
|
|
15883
|
+
if (loadError) return err(`Failed to load kidd config: ${toError(loadError).message}`);
|
|
15884
|
+
if (!loaded) return err("Failed to load kidd config: no configuration was returned");
|
|
15885
|
+
const [validateError, config] = validateConfig(loaded.config);
|
|
15886
|
+
if (validateError) return err(validateError);
|
|
15887
|
+
return ok({
|
|
15888
|
+
config: withTag(config, "KiddConfig"),
|
|
15889
|
+
configFile: loaded.configFile
|
|
15890
|
+
});
|
|
15891
|
+
}
|
|
15892
|
+
var CompileTargetSchema, BuildOptionsSchema, CompileOptionsSchema, KiddConfigSchema;
|
|
15893
|
+
var init_loader = __esmMin((() => {
|
|
15894
|
+
init_tag();
|
|
15895
|
+
init_fp();
|
|
15896
|
+
init_dist$1();
|
|
15897
|
+
init_dist$8();
|
|
15898
|
+
init_validate$2();
|
|
15899
|
+
CompileTargetSchema = z.enum([
|
|
15900
|
+
"darwin-arm64",
|
|
15901
|
+
"darwin-x64",
|
|
15902
|
+
"linux-arm64",
|
|
15903
|
+
"linux-x64",
|
|
15904
|
+
"linux-x64-musl",
|
|
15905
|
+
"windows-arm64",
|
|
15906
|
+
"windows-x64"
|
|
15907
|
+
]);
|
|
15908
|
+
BuildOptionsSchema = z.object({
|
|
15909
|
+
external: z.array(z.string()).optional(),
|
|
15910
|
+
minify: z.boolean().optional(),
|
|
15911
|
+
out: z.string().optional(),
|
|
15912
|
+
sourcemap: z.boolean().optional(),
|
|
15913
|
+
target: z.string().optional()
|
|
15914
|
+
}).strict();
|
|
15915
|
+
CompileOptionsSchema = z.object({
|
|
15916
|
+
name: z.string().optional(),
|
|
15917
|
+
out: z.string().optional(),
|
|
15918
|
+
targets: z.array(CompileTargetSchema).optional()
|
|
15919
|
+
}).strict();
|
|
15920
|
+
KiddConfigSchema = z.object({
|
|
15921
|
+
build: BuildOptionsSchema.optional(),
|
|
15922
|
+
commands: z.string().optional(),
|
|
15923
|
+
compile: z.union([z.boolean(), CompileOptionsSchema]).optional(),
|
|
15924
|
+
entry: z.string().optional(),
|
|
15925
|
+
include: z.array(z.string()).optional()
|
|
15926
|
+
}).strict();
|
|
15927
|
+
}));
|
|
15928
|
+
|
|
15929
|
+
//#endregion
|
|
15930
|
+
//#region ../../node_modules/.pnpm/cliui@9.0.1/node_modules/cliui/build/lib/index.js
|
|
15931
|
+
function addBorder(col, ts, style) {
|
|
15932
|
+
if (col.border) {
|
|
15933
|
+
if (/[.']-+[.']/.test(ts)) return "";
|
|
15934
|
+
if (ts.trim().length !== 0) return style;
|
|
15935
|
+
return " ";
|
|
15936
|
+
}
|
|
15937
|
+
return "";
|
|
15938
|
+
}
|
|
15939
|
+
function _minWidth(col) {
|
|
15940
|
+
const padding = col.padding || [];
|
|
15941
|
+
const minWidth = 1 + (padding[left] || 0) + (padding[right] || 0);
|
|
15942
|
+
if (col.border) return minWidth + 4;
|
|
15943
|
+
return minWidth;
|
|
15944
|
+
}
|
|
15945
|
+
function getWindowWidth() {
|
|
15946
|
+
/* c8 ignore next 5: depends on terminal */
|
|
15947
|
+
if (typeof process === "object" && process.stdout && process.stdout.columns) return process.stdout.columns;
|
|
15948
|
+
return 80;
|
|
15949
|
+
}
|
|
15950
|
+
function alignRight(str, width) {
|
|
15951
|
+
str = str.trim();
|
|
15952
|
+
const strWidth = mixin$1.stringWidth(str);
|
|
15953
|
+
if (strWidth < width) return " ".repeat(width - strWidth) + str;
|
|
15954
|
+
return str;
|
|
15955
|
+
}
|
|
15956
|
+
function alignCenter(str, width) {
|
|
15957
|
+
str = str.trim();
|
|
15958
|
+
const strWidth = mixin$1.stringWidth(str);
|
|
15959
|
+
/* c8 ignore next 3 */
|
|
15960
|
+
if (strWidth >= width) return str;
|
|
15961
|
+
return " ".repeat(width - strWidth >> 1) + str;
|
|
15962
|
+
}
|
|
15963
|
+
function cliui(opts, _mixin) {
|
|
15964
|
+
mixin$1 = _mixin;
|
|
15965
|
+
return new UI({
|
|
15966
|
+
width: (opts === null || opts === void 0 ? void 0 : opts.width) || getWindowWidth(),
|
|
15967
|
+
wrap: opts === null || opts === void 0 ? void 0 : opts.wrap
|
|
15968
|
+
});
|
|
15969
|
+
}
|
|
15970
|
+
var align, top, right, bottom, left, UI, mixin$1;
|
|
15971
|
+
var init_lib$2 = __esmMin((() => {
|
|
15972
|
+
align = {
|
|
15973
|
+
right: alignRight,
|
|
15974
|
+
center: alignCenter
|
|
15975
|
+
};
|
|
15976
|
+
top = 0;
|
|
15977
|
+
right = 1;
|
|
15978
|
+
bottom = 2;
|
|
15979
|
+
left = 3;
|
|
15980
|
+
UI = class {
|
|
15981
|
+
constructor(opts) {
|
|
15982
|
+
var _a;
|
|
15983
|
+
this.width = opts.width;
|
|
15984
|
+
this.wrap = (_a = opts.wrap) !== null && _a !== void 0 ? _a : true;
|
|
15985
|
+
this.rows = [];
|
|
15986
|
+
}
|
|
15987
|
+
span(...args) {
|
|
15988
|
+
const cols = this.div(...args);
|
|
16866
15989
|
cols.span = true;
|
|
16867
15990
|
}
|
|
16868
15991
|
resetOutput() {
|
|
@@ -22139,7 +21262,7 @@ var init_yargs = __esmMin((() => {
|
|
|
22139
21262
|
* @private
|
|
22140
21263
|
*/
|
|
22141
21264
|
function toPascalCase(name) {
|
|
22142
|
-
return name.split("-").map((part) => part.charAt(0).toUpperCase()
|
|
21265
|
+
return name.split("-").map((part) => `${part.charAt(0).toUpperCase()}${part.slice(1)}`).join("");
|
|
22143
21266
|
}
|
|
22144
21267
|
/**
|
|
22145
21268
|
* Convert a kebab-case name to camelCase.
|
|
@@ -22151,7 +21274,7 @@ function toPascalCase(name) {
|
|
|
22151
21274
|
*/
|
|
22152
21275
|
function toCamelCase(name) {
|
|
22153
21276
|
const pascal = toPascalCase(name);
|
|
22154
|
-
return pascal.charAt(0).toLowerCase()
|
|
21277
|
+
return `${pascal.charAt(0).toLowerCase()}${pascal.slice(1)}`;
|
|
22155
21278
|
}
|
|
22156
21279
|
/**
|
|
22157
21280
|
* Escape a template string for embedding inside a JS template literal.
|
|
@@ -22161,7 +21284,7 @@ function toCamelCase(name) {
|
|
|
22161
21284
|
* @private
|
|
22162
21285
|
*/
|
|
22163
21286
|
function escapeTemplateLiteral(str) {
|
|
22164
|
-
return str.
|
|
21287
|
+
return str.replaceAll("\\", String.raw`\\`).replaceAll("`", "\\`").replaceAll("${", "\\${");
|
|
22165
21288
|
}
|
|
22166
21289
|
/**
|
|
22167
21290
|
* Generate the Zod schema expression for a list of schema variables.
|
|
@@ -22172,7 +21295,10 @@ function generateSchemaExpression(vars) {
|
|
|
22172
21295
|
if (vars.length === 0) return "z.object({})";
|
|
22173
21296
|
return `z.object({\n${vars.map((v) => {
|
|
22174
21297
|
const base = "z.string()";
|
|
22175
|
-
const expr =
|
|
21298
|
+
const expr = (() => {
|
|
21299
|
+
if (v.required) return base;
|
|
21300
|
+
return `${base}.optional()`;
|
|
21301
|
+
})();
|
|
22176
21302
|
return ` ${v.name}: ${expr},`;
|
|
22177
21303
|
}).join("\n")}\n})`;
|
|
22178
21304
|
}
|
|
@@ -22185,13 +21311,16 @@ function generateSchemaExpression(vars) {
|
|
|
22185
21311
|
function generatePromptModule(prompt) {
|
|
22186
21312
|
const escaped = escapeTemplateLiteral(prompt.template);
|
|
22187
21313
|
const schemaExpr = generateSchemaExpression(prompt.schema);
|
|
22188
|
-
const groupValue =
|
|
21314
|
+
const groupValue = (() => {
|
|
21315
|
+
if (prompt.group) return `'${prompt.group}' as const`;
|
|
21316
|
+
return "undefined";
|
|
21317
|
+
})();
|
|
22189
21318
|
return [
|
|
22190
21319
|
HEADER,
|
|
22191
21320
|
`// Source: ${prompt.sourcePath}`,
|
|
22192
21321
|
"",
|
|
22193
21322
|
"import { z } from 'zod'",
|
|
22194
|
-
"import { liquidEngine } from '@funkai/prompts'",
|
|
21323
|
+
"import { liquidEngine } from '@funkai/prompts/runtime'",
|
|
22195
21324
|
"",
|
|
22196
21325
|
`const schema = ${schemaExpr}`,
|
|
22197
21326
|
"",
|
|
@@ -22234,10 +21363,13 @@ function generatePromptModule(prompt) {
|
|
|
22234
21363
|
function buildTree(prompts) {
|
|
22235
21364
|
return prompts.reduce((root, prompt) => {
|
|
22236
21365
|
const importName = toCamelCase(prompt.name);
|
|
22237
|
-
const target = (
|
|
21366
|
+
const target = (() => {
|
|
21367
|
+
if (prompt.group) return prompt.group.split("/").map(toCamelCase);
|
|
21368
|
+
return [];
|
|
21369
|
+
})().reduce((current, segment) => {
|
|
22238
21370
|
const existing = current[segment];
|
|
22239
|
-
if (typeof existing === "string") throw new
|
|
22240
|
-
if (existing
|
|
21371
|
+
if (typeof existing === "string") throw new TypeError(`Collision: prompt "${existing}" and group namespace "${segment}" share the same key at the same level.`);
|
|
21372
|
+
if (existing === null || existing === void 0) current[segment] = {};
|
|
22241
21373
|
return current[segment];
|
|
22242
21374
|
}, root);
|
|
22243
21375
|
if (typeof target[importName] === "object" && target[importName] !== null) throw new Error(`Collision: prompt "${importName}" conflicts with existing group namespace "${importName}" at the same level.`);
|
|
@@ -22256,11 +21388,14 @@ function buildTree(prompts) {
|
|
|
22256
21388
|
*/
|
|
22257
21389
|
function serializeTree(node, indent) {
|
|
22258
21390
|
const pad = " ".repeat(indent);
|
|
22259
|
-
|
|
22260
|
-
|
|
22261
|
-
|
|
22262
|
-
`${pad}}
|
|
22263
|
-
|
|
21391
|
+
const lines = [];
|
|
21392
|
+
for (const [key, value] of Object.entries(node)) if (typeof value === "string") lines.push(`${pad}${key},`);
|
|
21393
|
+
else {
|
|
21394
|
+
lines.push(`${pad}${key}: {`);
|
|
21395
|
+
for (const child of serializeTree(value, indent + 1)) lines.push(child);
|
|
21396
|
+
lines.push(`${pad}},`);
|
|
21397
|
+
}
|
|
21398
|
+
return lines;
|
|
22264
21399
|
}
|
|
22265
21400
|
/**
|
|
22266
21401
|
* Generate the registry `index.ts` that wires all prompt modules
|
|
@@ -22354,7 +21489,10 @@ function extractVariables(template) {
|
|
|
22354
21489
|
const parsed = engine.parse(template);
|
|
22355
21490
|
const variables = engine.variablesSync(parsed);
|
|
22356
21491
|
return [...new Set(variables.map((variable) => {
|
|
22357
|
-
const root =
|
|
21492
|
+
const root = (() => {
|
|
21493
|
+
if (Array.isArray(variable)) return String(variable[0]);
|
|
21494
|
+
return String(variable);
|
|
21495
|
+
})();
|
|
22358
21496
|
if (DANGEROUS_NAMES.has(root)) throw new Error(`Dangerous variable name "${root}" is not allowed in prompt templates`);
|
|
22359
21497
|
return root;
|
|
22360
21498
|
}))].toSorted();
|
|
@@ -22390,8 +21528,11 @@ function parseParams(raw, partialName) {
|
|
|
22390
21528
|
*/
|
|
22391
21529
|
function parseRenderTags(template) {
|
|
22392
21530
|
return [...template.matchAll(RENDER_TAG_RE)].map((m) => {
|
|
22393
|
-
const rawParams = m[2]
|
|
22394
|
-
const params =
|
|
21531
|
+
const rawParams = (m[2] ?? "").trim();
|
|
21532
|
+
const params = (() => {
|
|
21533
|
+
if (rawParams.length > 0) return parseParams(rawParams, m[1]);
|
|
21534
|
+
return {};
|
|
21535
|
+
})();
|
|
22395
21536
|
return {
|
|
22396
21537
|
fullMatch: m[0],
|
|
22397
21538
|
partialName: m[1],
|
|
@@ -22417,8 +21558,8 @@ function flattenPartials(template, partialsDirs) {
|
|
|
22417
21558
|
const tags = parseRenderTags(template);
|
|
22418
21559
|
if (tags.length === 0) return template;
|
|
22419
21560
|
const engine = new Liquid({
|
|
22420
|
-
root: partialsDirs,
|
|
22421
|
-
partials: partialsDirs,
|
|
21561
|
+
root: [...partialsDirs],
|
|
21562
|
+
partials: [...partialsDirs],
|
|
22422
21563
|
extname: ".prompt"
|
|
22423
21564
|
});
|
|
22424
21565
|
return tags.reduce((acc, tag) => {
|
|
@@ -22447,8 +21588,8 @@ var init_flatten = __esmMin((() => {
|
|
|
22447
21588
|
function parseYamlContent(yaml, filePath) {
|
|
22448
21589
|
try {
|
|
22449
21590
|
return parse(yaml);
|
|
22450
|
-
} catch (
|
|
22451
|
-
throw new Error(`Failed to parse YAML frontmatter in ${filePath}: ${
|
|
21591
|
+
} catch (error) {
|
|
21592
|
+
throw new Error(`Failed to parse YAML frontmatter in ${filePath}: ${error}`, { cause: error });
|
|
22452
21593
|
}
|
|
22453
21594
|
}
|
|
22454
21595
|
/**
|
|
@@ -22467,18 +21608,22 @@ function parseFrontmatter(content, filePath) {
|
|
|
22467
21608
|
if (!fmMatch) throw new Error(`No frontmatter found in ${filePath}`);
|
|
22468
21609
|
const parsed = parseYamlContent(fmMatch[1], filePath);
|
|
22469
21610
|
if (!parsed || typeof parsed !== "object") throw new Error(`Frontmatter is not a valid object in ${filePath}`);
|
|
22470
|
-
const name = parsed
|
|
21611
|
+
const { name } = parsed;
|
|
22471
21612
|
if (typeof name !== "string" || name.length === 0) throw new Error(`Missing or empty "name" in frontmatter: ${filePath}`);
|
|
22472
21613
|
if (!NAME_RE.test(name)) throw new Error(`Invalid prompt name "${name}" in ${filePath}. Names must be lowercase alphanumeric with hyphens only.`);
|
|
22473
21614
|
return {
|
|
22474
21615
|
name,
|
|
22475
|
-
group:
|
|
22476
|
-
|
|
22477
|
-
|
|
22478
|
-
|
|
22479
|
-
|
|
22480
|
-
|
|
22481
|
-
|
|
21616
|
+
group: (() => {
|
|
21617
|
+
if (typeof parsed.group === "string") {
|
|
21618
|
+
const g = parsed.group;
|
|
21619
|
+
const invalidSegment = g.split("/").find((segment) => !NAME_RE.test(segment));
|
|
21620
|
+
if (invalidSegment !== void 0) throw new Error(`Invalid group segment "${invalidSegment}" in ${filePath}. Group segments must be lowercase alphanumeric with hyphens only.`);
|
|
21621
|
+
return g;
|
|
21622
|
+
}
|
|
21623
|
+
})(),
|
|
21624
|
+
version: (() => {
|
|
21625
|
+
if (parsed.version !== null && parsed.version !== void 0) return String(parsed.version);
|
|
21626
|
+
})(),
|
|
22482
21627
|
schema: parseSchemaBlock(parsed.schema, filePath)
|
|
22483
21628
|
};
|
|
22484
21629
|
}
|
|
@@ -22488,8 +21633,8 @@ function parseFrontmatter(content, filePath) {
|
|
|
22488
21633
|
* @private
|
|
22489
21634
|
*/
|
|
22490
21635
|
function parseSchemaBlock(raw, filePath) {
|
|
22491
|
-
if (raw
|
|
22492
|
-
if (typeof raw !== "object" || Array.isArray(raw)) throw new
|
|
21636
|
+
if (raw === null || raw === void 0) return [];
|
|
21637
|
+
if (typeof raw !== "object" || Array.isArray(raw)) throw new TypeError(`Invalid "schema" in ${filePath}: expected an object mapping variable names to definitions`);
|
|
22493
21638
|
const schema = raw;
|
|
22494
21639
|
return Object.entries(schema).map(([varName, value]) => {
|
|
22495
21640
|
if (typeof value === "string") return {
|
|
@@ -22501,9 +21646,14 @@ function parseSchemaBlock(raw, filePath) {
|
|
|
22501
21646
|
const def = value;
|
|
22502
21647
|
return {
|
|
22503
21648
|
name: varName,
|
|
22504
|
-
type:
|
|
21649
|
+
type: (() => {
|
|
21650
|
+
if (typeof def.type === "string") return def.type;
|
|
21651
|
+
return "string";
|
|
21652
|
+
})(),
|
|
22505
21653
|
required: def.required !== false,
|
|
22506
|
-
description:
|
|
21654
|
+
description: (() => {
|
|
21655
|
+
if (typeof def.description === "string") return def.description;
|
|
21656
|
+
})()
|
|
22507
21657
|
};
|
|
22508
21658
|
}
|
|
22509
21659
|
throw new Error(`Invalid schema definition for "${varName}" in ${filePath}. Expected a type string or an object with { type, required?, description? }.`);
|
|
@@ -22526,7 +21676,8 @@ var init_frontmatter = __esmMin((() => {
|
|
|
22526
21676
|
function extractName(content) {
|
|
22527
21677
|
const match = content.match(FRONTMATTER_RE);
|
|
22528
21678
|
if (!match) return;
|
|
22529
|
-
const
|
|
21679
|
+
const [, frontmatter] = match;
|
|
21680
|
+
const nameLine = frontmatter.split("\n").find((line) => line.startsWith("name:"));
|
|
22530
21681
|
if (!nameLine) return;
|
|
22531
21682
|
return nameLine.slice(5).trim();
|
|
22532
21683
|
}
|
|
@@ -22552,7 +21703,7 @@ function scanDirectory(dir, depth) {
|
|
|
22552
21703
|
return readdirSync(dir, { withFileTypes: true }).filter((entry) => !entry.isSymbolicLink()).flatMap((entry) => {
|
|
22553
21704
|
const fullPath = join(dir, entry.name);
|
|
22554
21705
|
if (entry.isFile() && extname(entry.name) === PROMPT_EXT) {
|
|
22555
|
-
const name = extractName(readFileSync(fullPath, "
|
|
21706
|
+
const name = extractName(readFileSync(fullPath, "utf8")) ?? deriveNameFromPath(fullPath);
|
|
22556
21707
|
if (!NAME_RE.test(name)) throw new Error(`Invalid prompt name "${name}" from ${fullPath}. Names must be lowercase alphanumeric with hyphens only.`);
|
|
22557
21708
|
return [{
|
|
22558
21709
|
name,
|
|
@@ -22590,6 +21741,16 @@ var init_paths = __esmMin((() => {
|
|
|
22590
21741
|
//#endregion
|
|
22591
21742
|
//#region src/lib/prompts/pipeline.ts
|
|
22592
21743
|
/**
|
|
21744
|
+
* Resolve the list of partial directories to search.
|
|
21745
|
+
*
|
|
21746
|
+
* @param customDir - Custom partials directory path.
|
|
21747
|
+
* @returns Array of directories to search for partials.
|
|
21748
|
+
*/
|
|
21749
|
+
function resolvePartialsDirs(customDir) {
|
|
21750
|
+
if (existsSync(customDir)) return [customDir, PARTIALS_DIR];
|
|
21751
|
+
return [PARTIALS_DIR];
|
|
21752
|
+
}
|
|
21753
|
+
/**
|
|
22593
21754
|
* Run the prompts lint pipeline: discover, parse, and validate .prompt files.
|
|
22594
21755
|
*
|
|
22595
21756
|
* @param options - Pipeline configuration.
|
|
@@ -22597,10 +21758,9 @@ var init_paths = __esmMin((() => {
|
|
|
22597
21758
|
*/
|
|
22598
21759
|
function runLintPipeline(options) {
|
|
22599
21760
|
const discovered = discoverPrompts([...options.roots]);
|
|
22600
|
-
const
|
|
22601
|
-
const partialsDirs = existsSync(customPartialsDir) ? [customPartialsDir, PARTIALS_DIR] : [PARTIALS_DIR];
|
|
21761
|
+
const partialsDirs = resolvePartialsDirs(resolve(options.partials ?? ".prompts/partials"));
|
|
22602
21762
|
const results = discovered.map((d) => {
|
|
22603
|
-
const raw = readFileSync(d.filePath, "
|
|
21763
|
+
const raw = readFileSync(d.filePath, "utf8");
|
|
22604
21764
|
const frontmatter = parseFrontmatter(raw, d.filePath);
|
|
22605
21765
|
const templateVars = extractVariables(flattenPartials(clean(raw), partialsDirs));
|
|
22606
21766
|
return lintPrompt(frontmatter.name, d.filePath, frontmatter.schema, templateVars);
|
|
@@ -22620,10 +21780,9 @@ function runLintPipeline(options) {
|
|
|
22620
21780
|
*/
|
|
22621
21781
|
function runGeneratePipeline(options) {
|
|
22622
21782
|
const discovered = discoverPrompts([...options.roots]);
|
|
22623
|
-
const
|
|
22624
|
-
const partialsDirs = existsSync(customPartialsDir) ? [customPartialsDir, PARTIALS_DIR] : [PARTIALS_DIR];
|
|
21783
|
+
const partialsDirs = resolvePartialsDirs(resolve(options.partials ?? resolve(options.out, "../partials")));
|
|
22625
21784
|
const processed = discovered.map((d) => {
|
|
22626
|
-
const raw = readFileSync(d.filePath, "
|
|
21785
|
+
const raw = readFileSync(d.filePath, "utf8");
|
|
22627
21786
|
const frontmatter = parseFrontmatter(raw, d.filePath);
|
|
22628
21787
|
const template = flattenPartials(clean(raw), partialsDirs);
|
|
22629
21788
|
const templateVars = extractVariables(template);
|
|
@@ -22670,7 +21829,10 @@ function handleGenerate(args, logger, fail) {
|
|
|
22670
21829
|
});
|
|
22671
21830
|
if (!silent) logger.info(`Found ${discovered} prompt(s)`);
|
|
22672
21831
|
if (!silent) for (const prompt of prompts) {
|
|
22673
|
-
const varList =
|
|
21832
|
+
const varList = (() => {
|
|
21833
|
+
if (prompt.schema.length > 0) return ` (${prompt.schema.map((v) => v.name).join(", ")})`;
|
|
21834
|
+
return "";
|
|
21835
|
+
})();
|
|
22674
21836
|
logger.step(`${prompt.name}${varList}`);
|
|
22675
21837
|
}
|
|
22676
21838
|
for (const result of lintResults) for (const diag of result.diagnostics) if (diag.level === "error") logger.error(diag.message);
|
|
@@ -22680,10 +21842,10 @@ function handleGenerate(args, logger, fail) {
|
|
|
22680
21842
|
mkdirSync(outDir, { recursive: true });
|
|
22681
21843
|
for (const prompt of prompts) {
|
|
22682
21844
|
const content = generatePromptModule(prompt);
|
|
22683
|
-
writeFileSync(resolve(outDir, `${prompt.name}.ts`), content, "
|
|
21845
|
+
writeFileSync(resolve(outDir, `${prompt.name}.ts`), content, "utf8");
|
|
22684
21846
|
}
|
|
22685
21847
|
const registryContent = generateRegistry(prompts);
|
|
22686
|
-
writeFileSync(resolve(outDir, "index.ts"), registryContent, "
|
|
21848
|
+
writeFileSync(resolve(outDir, "index.ts"), registryContent, "utf8");
|
|
22687
21849
|
if (!silent) logger.success(`Generated ${prompts.length} prompt module(s) + registry → ${outDir}`);
|
|
22688
21850
|
}
|
|
22689
21851
|
var generateArgs, generate_default$1;
|
|
@@ -22700,7 +21862,7 @@ var init_generate$1 = __esmMin((() => {
|
|
|
22700
21862
|
});
|
|
22701
21863
|
generate_default$1 = command({
|
|
22702
21864
|
description: "Generate TypeScript modules from .prompt files",
|
|
22703
|
-
|
|
21865
|
+
options: generateArgs,
|
|
22704
21866
|
handler(ctx) {
|
|
22705
21867
|
handleGenerate(ctx.args, ctx.logger, ctx.fail);
|
|
22706
21868
|
}
|
|
@@ -22715,7 +21877,7 @@ var init_generate = __esmMin((() => {
|
|
|
22715
21877
|
init_generate$1();
|
|
22716
21878
|
generate_default = command({
|
|
22717
21879
|
description: "Run all code generation across the funkai SDK",
|
|
22718
|
-
|
|
21880
|
+
options: generateArgs,
|
|
22719
21881
|
handler(ctx) {
|
|
22720
21882
|
const { silent } = ctx.args;
|
|
22721
21883
|
if (!silent) ctx.logger.info("Running prompts code generation...");
|
|
@@ -22763,11 +21925,10 @@ function handleLint(args, logger, fail) {
|
|
|
22763
21925
|
const errorCount = diagnostics.filter((d) => d.level === "error").length;
|
|
22764
21926
|
const warnCount = diagnostics.filter((d) => d.level !== "error").length;
|
|
22765
21927
|
if (!silent) {
|
|
22766
|
-
const
|
|
22767
|
-
|
|
22768
|
-
|
|
22769
|
-
|
|
22770
|
-
].filter(Boolean).join(", ");
|
|
21928
|
+
const summaryParts = [`${discovered} prompt(s) linted`];
|
|
21929
|
+
if (errorCount > 0) summaryParts.push(`${errorCount} error(s)`);
|
|
21930
|
+
if (warnCount > 0) summaryParts.push(`${warnCount} warning(s)`);
|
|
21931
|
+
const summary = summaryParts.join(", ");
|
|
22771
21932
|
logger.info(summary);
|
|
22772
21933
|
}
|
|
22773
21934
|
if (hasLintErrors(results)) fail("Lint errors found.");
|
|
@@ -22784,7 +21945,7 @@ var init_lint = __esmMin((() => {
|
|
|
22784
21945
|
});
|
|
22785
21946
|
lint_default = command({
|
|
22786
21947
|
description: "Validate .prompt files for schema/template mismatches",
|
|
22787
|
-
|
|
21948
|
+
options: lintArgs,
|
|
22788
21949
|
handler(ctx) {
|
|
22789
21950
|
handleLint(ctx.args, ctx.logger, ctx.fail);
|
|
22790
21951
|
}
|
|
@@ -22799,7 +21960,7 @@ var init_validate$1 = __esmMin((() => {
|
|
|
22799
21960
|
init_lint();
|
|
22800
21961
|
validate_default$1 = command({
|
|
22801
21962
|
description: "Run all validations across the funkai SDK",
|
|
22802
|
-
|
|
21963
|
+
options: lintArgs,
|
|
22803
21964
|
handler(ctx) {
|
|
22804
21965
|
const { silent } = ctx.args;
|
|
22805
21966
|
if (!silent) ctx.logger.info("Running prompts validation...");
|
|
@@ -22825,17 +21986,17 @@ var init_validate = __esmMin((() => {
|
|
|
22825
21986
|
|
|
22826
21987
|
//#endregion
|
|
22827
21988
|
//#region src/commands/prompts/create.ts
|
|
22828
|
-
var
|
|
21989
|
+
var createTemplate, create_default;
|
|
22829
21990
|
var init_create = __esmMin((() => {
|
|
22830
21991
|
init_dist();
|
|
22831
|
-
|
|
21992
|
+
createTemplate = (name) => `---
|
|
22832
21993
|
name: ${name}
|
|
22833
21994
|
---
|
|
22834
21995
|
|
|
22835
21996
|
`;
|
|
22836
21997
|
create_default = command({
|
|
22837
21998
|
description: "Create a new .prompt file",
|
|
22838
|
-
|
|
21999
|
+
options: z.object({
|
|
22839
22000
|
name: z.string().describe("Prompt name (kebab-case)"),
|
|
22840
22001
|
out: z.string().optional().describe("Output directory (defaults to cwd)"),
|
|
22841
22002
|
partial: z.boolean().default(false).describe("Create as a partial in .prompts/partials/")
|
|
@@ -22849,7 +22010,7 @@ name: ${name}
|
|
|
22849
22010
|
const filePath = resolve(dir, `${name}.prompt`);
|
|
22850
22011
|
if (existsSync(filePath)) ctx.fail(`File already exists: ${filePath}`);
|
|
22851
22012
|
mkdirSync(dir, { recursive: true });
|
|
22852
|
-
writeFileSync(filePath,
|
|
22013
|
+
writeFileSync(filePath, createTemplate(name), "utf8");
|
|
22853
22014
|
ctx.logger.success(`Created ${filePath}`);
|
|
22854
22015
|
}
|
|
22855
22016
|
});
|
|
@@ -22864,7 +22025,7 @@ name: ${name}
|
|
|
22864
22025
|
function readJsonFile(filePath) {
|
|
22865
22026
|
if (!existsSync(filePath)) return {};
|
|
22866
22027
|
try {
|
|
22867
|
-
const content = readFileSync(filePath, "
|
|
22028
|
+
const content = readFileSync(filePath, "utf8");
|
|
22868
22029
|
return JSON.parse(content);
|
|
22869
22030
|
} catch {
|
|
22870
22031
|
return {};
|
|
@@ -22890,374 +22051,121 @@ var init_setup = __esmMin((() => {
|
|
|
22890
22051
|
initialValue: true
|
|
22891
22052
|
})) {
|
|
22892
22053
|
const vscodeDir = resolve(VSCODE_DIR);
|
|
22893
|
-
mkdirSync(vscodeDir, { recursive: true });
|
|
22894
|
-
const settingsPath = resolve(vscodeDir, SETTINGS_FILE);
|
|
22895
|
-
const settings = readJsonFile(settingsPath);
|
|
22896
|
-
const updatedSettings = {
|
|
22897
|
-
...settings,
|
|
22898
|
-
"files.associations": {
|
|
22899
|
-
...settings["files.associations"] ?? {},
|
|
22900
|
-
"*.prompt": "markdown"
|
|
22901
|
-
},
|
|
22902
|
-
"liquid.engine": "standard"
|
|
22903
|
-
};
|
|
22904
|
-
writeFileSync(settingsPath, JSON.stringify(updatedSettings, null, 2)
|
|
22905
|
-
ctx.logger.success(`Updated ${settingsPath}`);
|
|
22906
|
-
}
|
|
22907
|
-
if (await ctx.prompts.confirm({
|
|
22908
|
-
message: "Add Shopify Liquid extension to VSCode recommendations?",
|
|
22909
|
-
initialValue: true
|
|
22910
|
-
})) {
|
|
22911
|
-
const vscodeDir = resolve(VSCODE_DIR);
|
|
22912
|
-
mkdirSync(vscodeDir, { recursive: true });
|
|
22913
|
-
const extensionsPath = resolve(vscodeDir, EXTENSIONS_FILE);
|
|
22914
|
-
const extensions = readJsonFile(extensionsPath);
|
|
22915
|
-
const currentRecs = extensions.recommendations ?? [];
|
|
22916
|
-
const extensionId = "sissel.shopify-liquid";
|
|
22917
|
-
const
|
|
22918
|
-
|
|
22919
|
-
|
|
22920
|
-
};
|
|
22921
|
-
|
|
22922
|
-
|
|
22923
|
-
|
|
22924
|
-
|
|
22925
|
-
|
|
22926
|
-
|
|
22927
|
-
}
|
|
22928
|
-
|
|
22929
|
-
|
|
22930
|
-
|
|
22931
|
-
|
|
22932
|
-
|
|
22933
|
-
|
|
22934
|
-
|
|
22935
|
-
|
|
22936
|
-
|
|
22937
|
-
|
|
22938
|
-
|
|
22939
|
-
|
|
22940
|
-
|
|
22941
|
-
|
|
22942
|
-
|
|
22943
|
-
|
|
22944
|
-
|
|
22945
|
-
|
|
22946
|
-
|
|
22947
|
-
|
|
22948
|
-
|
|
22949
|
-
|
|
22950
|
-
|
|
22951
|
-
|
|
22952
|
-
|
|
22953
|
-
|
|
22954
|
-
|
|
22955
|
-
|
|
22956
|
-
|
|
22957
|
-
|
|
22958
|
-
|
|
22959
|
-
|
|
22960
|
-
|
|
22961
|
-
|
|
22962
|
-
|
|
22963
|
-
|
|
22964
|
-
|
|
22965
|
-
|
|
22966
|
-
|
|
22967
|
-
|
|
22968
|
-
}
|
|
22969
|
-
|
|
22970
|
-
|
|
22971
|
-
init_tag();
|
|
22972
|
-
init_generate();
|
|
22973
|
-
init_setup$1();
|
|
22974
|
-
init_validate$1();
|
|
22975
|
-
init_validate();
|
|
22976
|
-
init_create();
|
|
22977
|
-
init_generate$1();
|
|
22978
|
-
init_lint();
|
|
22979
|
-
init_setup();
|
|
22980
|
-
commands = {
|
|
22981
|
-
"generate": generate_default,
|
|
22982
|
-
"setup": setup_default$1,
|
|
22983
|
-
"validate": validate_default$1,
|
|
22984
|
-
"agents": withTag({ commands: { "validate": validate_default } }, "Command"),
|
|
22985
|
-
"prompts": withTag({ commands: {
|
|
22986
|
-
"create": create_default,
|
|
22987
|
-
"generate": generate_default$1,
|
|
22988
|
-
"lint": lint_default,
|
|
22989
|
-
"setup": setup_default
|
|
22990
|
-
} }, "Command")
|
|
22991
|
-
};
|
|
22992
|
-
}));
|
|
22993
|
-
|
|
22994
|
-
//#endregion
|
|
22995
|
-
//#region ../../node_modules/.pnpm/@kidd-cli+core@0.5.0_chokidar@5.0.0_jiti@2.6.1_magicast@0.5.2/node_modules/@kidd-cli/core/dist/index.js
|
|
22996
|
-
/**
|
|
22997
|
-
* Create a ContextError with an exit code and optional error code.
|
|
22998
|
-
*
|
|
22999
|
-
* Used to surface user-facing CLI errors with clean messages.
|
|
23000
|
-
* The error carries a Symbol-based tag for reliable type-narrowing
|
|
23001
|
-
* via {@link isContextError}.
|
|
23002
|
-
*
|
|
23003
|
-
* @param message - Human-readable error message.
|
|
23004
|
-
* @param options - Optional error code and exit code overrides.
|
|
23005
|
-
* @returns A ContextError instance.
|
|
23006
|
-
*/
|
|
23007
|
-
function createContextError(message, options) {
|
|
23008
|
-
const data = createContextErrorData(message, options);
|
|
23009
|
-
const error = new Error(data.message);
|
|
23010
|
-
error.name = "ContextError";
|
|
23011
|
-
Object.defineProperty(error, TAG, {
|
|
23012
|
-
enumerable: false,
|
|
23013
|
-
value: "ContextError",
|
|
23014
|
-
writable: false
|
|
23015
|
-
});
|
|
23016
|
-
Object.defineProperty(error, "code", {
|
|
23017
|
-
enumerable: true,
|
|
23018
|
-
value: data.code,
|
|
23019
|
-
writable: false
|
|
23020
|
-
});
|
|
23021
|
-
Object.defineProperty(error, "exitCode", {
|
|
23022
|
-
enumerable: true,
|
|
23023
|
-
value: data.exitCode,
|
|
23024
|
-
writable: false
|
|
23025
|
-
});
|
|
23026
|
-
return error;
|
|
23027
|
-
}
|
|
23028
|
-
/**
|
|
23029
|
-
* Type guard that narrows an unknown value to {@link ContextError}.
|
|
23030
|
-
*
|
|
23031
|
-
* Checks that the value is an Error instance whose `[TAG]` property
|
|
23032
|
-
* equals `'ContextError'`, which distinguishes CLI-layer errors from
|
|
23033
|
-
* unexpected exceptions.
|
|
23034
|
-
*
|
|
23035
|
-
* @param error - The value to check.
|
|
23036
|
-
* @returns `true` when the value is a ContextError.
|
|
23037
|
-
*/
|
|
23038
|
-
function isContextError(error) {
|
|
23039
|
-
if (error instanceof Error) return hasTag(error, "ContextError");
|
|
23040
|
-
return false;
|
|
23041
|
-
}
|
|
23042
|
-
function resolveExitCode(options) {
|
|
23043
|
-
if (options && options.exitCode !== void 0) return options.exitCode;
|
|
23044
|
-
return 1;
|
|
23045
|
-
}
|
|
23046
|
-
function resolveCode(options) {
|
|
23047
|
-
if (options && options.code !== void 0) return options.code;
|
|
23048
|
-
}
|
|
23049
|
-
function createContextErrorData(message, options) {
|
|
23050
|
-
return withTag({
|
|
23051
|
-
code: resolveCode(options),
|
|
23052
|
-
exitCode: resolveExitCode(options),
|
|
23053
|
-
message
|
|
23054
|
-
}, "ContextError");
|
|
23055
|
-
}
|
|
23056
|
-
/**
|
|
23057
|
-
* Create the pure string formatter methods for a context.
|
|
23058
|
-
*
|
|
23059
|
-
* @private
|
|
23060
|
-
* @returns A Format instance with json and table formatters.
|
|
23061
|
-
*/
|
|
23062
|
-
function createContextFormat() {
|
|
23063
|
-
return Object.freeze({
|
|
23064
|
-
json(data) {
|
|
23065
|
-
const [, json] = jsonStringify(data, { pretty: true });
|
|
23066
|
-
return `${json}\n`;
|
|
23067
|
-
},
|
|
23068
|
-
table(rows) {
|
|
23069
|
-
if (rows.length === 0) return "";
|
|
23070
|
-
const [firstRow] = rows;
|
|
23071
|
-
if (!firstRow) return "";
|
|
23072
|
-
return formatTable(rows, Object.keys(firstRow));
|
|
23073
|
-
}
|
|
23074
|
-
});
|
|
23075
|
-
}
|
|
23076
|
-
/**
|
|
23077
|
-
* Format an unknown value as a string for table cell display.
|
|
23078
|
-
*
|
|
23079
|
-
* @private
|
|
23080
|
-
* @param val - The value to format.
|
|
23081
|
-
* @returns The stringified value, or empty string for undefined.
|
|
23082
|
-
*/
|
|
23083
|
-
function formatStringValue(val) {
|
|
23084
|
-
if (val === void 0) return "";
|
|
23085
|
-
return String(val);
|
|
23086
|
-
}
|
|
23087
|
-
/**
|
|
23088
|
-
* Create a padded header row string from column keys and widths.
|
|
23089
|
-
*
|
|
23090
|
-
* @private
|
|
23091
|
-
* @param options - The keys and column widths.
|
|
23092
|
-
* @returns A formatted header string.
|
|
23093
|
-
*/
|
|
23094
|
-
function createTableHeader(options) {
|
|
23095
|
-
const { keys, widths } = options;
|
|
23096
|
-
return keys.map((key, idx) => {
|
|
23097
|
-
const width = widths[idx];
|
|
23098
|
-
if (width === void 0) return key;
|
|
23099
|
-
return key.padEnd(width);
|
|
23100
|
-
}).join(" ");
|
|
23101
|
-
}
|
|
23102
|
-
/**
|
|
23103
|
-
* Create a padded row string from a data record, column keys, and widths.
|
|
23104
|
-
*
|
|
23105
|
-
* @private
|
|
23106
|
-
* @param options - The row data, keys, and column widths.
|
|
23107
|
-
* @returns A formatted row string.
|
|
23108
|
-
*/
|
|
23109
|
-
function createTableRow(options) {
|
|
23110
|
-
const { row, keys, widths } = options;
|
|
23111
|
-
return keys.map((key, idx) => {
|
|
23112
|
-
const width = widths[idx];
|
|
23113
|
-
const val = formatStringValue(row[key]);
|
|
23114
|
-
if (width === void 0) return val;
|
|
23115
|
-
return val.padEnd(width);
|
|
23116
|
-
}).join(" ");
|
|
23117
|
-
}
|
|
23118
|
-
/**
|
|
23119
|
-
* Compute the maximum column width for each key across all rows.
|
|
23120
|
-
*
|
|
23121
|
-
* @private
|
|
23122
|
-
* @param rows - The data rows.
|
|
23123
|
-
* @param keys - The column keys.
|
|
23124
|
-
* @returns An array of column widths.
|
|
23125
|
-
*/
|
|
23126
|
-
function computeColumnWidths(rows, keys) {
|
|
23127
|
-
return keys.map((key) => {
|
|
23128
|
-
const values = rows.map((row) => formatStringValue(row[key]));
|
|
23129
|
-
return Math.max(key.length, ...values.map((val) => val.length));
|
|
23130
|
-
});
|
|
23131
|
-
}
|
|
23132
|
-
/**
|
|
23133
|
-
* Format a table (header, separator, rows) as a string.
|
|
23134
|
-
*
|
|
23135
|
-
* @private
|
|
23136
|
-
* @param rows - The data rows.
|
|
23137
|
-
* @param keys - The column keys.
|
|
23138
|
-
* @returns The formatted table string.
|
|
23139
|
-
*/
|
|
23140
|
-
function formatTable(rows, keys) {
|
|
23141
|
-
const widths = computeColumnWidths(rows, keys);
|
|
23142
|
-
return `${[
|
|
23143
|
-
createTableHeader({
|
|
23144
|
-
keys,
|
|
23145
|
-
widths
|
|
23146
|
-
}),
|
|
23147
|
-
widths.map((width) => "-".repeat(width)).join(" "),
|
|
23148
|
-
...rows.map((row) => createTableRow({
|
|
23149
|
-
keys,
|
|
23150
|
-
row,
|
|
23151
|
-
widths
|
|
23152
|
-
}))
|
|
23153
|
-
].join("\n")}\n`;
|
|
23154
|
-
}
|
|
23155
|
-
/**
|
|
23156
|
-
* Create the interactive prompt methods for a context.
|
|
23157
|
-
*
|
|
23158
|
-
* @returns A Prompts instance backed by clack.
|
|
23159
|
-
*/
|
|
23160
|
-
function createContextPrompts() {
|
|
23161
|
-
return {
|
|
23162
|
-
async confirm(opts) {
|
|
23163
|
-
return unwrapCancelSignal(await Rt$1(opts));
|
|
23164
|
-
},
|
|
23165
|
-
async multiselect(opts) {
|
|
23166
|
-
return unwrapCancelSignal(await Lt$1(opts));
|
|
23167
|
-
},
|
|
23168
|
-
async password(opts) {
|
|
23169
|
-
return unwrapCancelSignal(await Ht$1(opts));
|
|
23170
|
-
},
|
|
23171
|
-
async select(opts) {
|
|
23172
|
-
return unwrapCancelSignal(await Jt$1(opts));
|
|
23173
|
-
},
|
|
23174
|
-
async text(opts) {
|
|
23175
|
-
return unwrapCancelSignal(await Zt$1(opts));
|
|
23176
|
-
}
|
|
23177
|
-
};
|
|
23178
|
-
}
|
|
23179
|
-
/**
|
|
23180
|
-
* Unwrap a prompt result that may be a cancel symbol.
|
|
23181
|
-
*
|
|
23182
|
-
* If the user cancelled (Ctrl-C), throws a ContextError. Otherwise returns
|
|
23183
|
-
* the typed result value.
|
|
23184
|
-
*
|
|
23185
|
-
* @private
|
|
23186
|
-
* @param result - The raw prompt result (value or cancel symbol).
|
|
23187
|
-
* @returns The unwrapped typed value.
|
|
23188
|
-
*/
|
|
23189
|
-
function unwrapCancelSignal(result) {
|
|
23190
|
-
if (Ct$2(result)) {
|
|
23191
|
-
Nt$1("Operation cancelled.");
|
|
23192
|
-
throw createContextError("Prompt cancelled by user", {
|
|
23193
|
-
code: "PROMPT_CANCELLED",
|
|
23194
|
-
exitCode: 1
|
|
23195
|
-
});
|
|
23196
|
-
}
|
|
23197
|
-
return result;
|
|
23198
|
-
}
|
|
23199
|
-
/**
|
|
23200
|
-
* Create an in-memory key-value store.
|
|
23201
|
-
*
|
|
23202
|
-
* @private
|
|
23203
|
-
* @returns A Store instance backed by a Map.
|
|
23204
|
-
*/
|
|
23205
|
-
function createMemoryStore() {
|
|
23206
|
-
const map = /* @__PURE__ */ new Map();
|
|
23207
|
-
return {
|
|
23208
|
-
clear() {
|
|
23209
|
-
map.clear();
|
|
23210
|
-
},
|
|
23211
|
-
delete(key) {
|
|
23212
|
-
return map.delete(key);
|
|
23213
|
-
},
|
|
23214
|
-
get(key) {
|
|
23215
|
-
return map.get(key);
|
|
23216
|
-
},
|
|
23217
|
-
has(key) {
|
|
23218
|
-
return map.has(key);
|
|
23219
|
-
},
|
|
23220
|
-
set(key, value) {
|
|
23221
|
-
map.set(key, value);
|
|
22054
|
+
mkdirSync(vscodeDir, { recursive: true });
|
|
22055
|
+
const settingsPath = resolve(vscodeDir, SETTINGS_FILE);
|
|
22056
|
+
const settings = readJsonFile(settingsPath);
|
|
22057
|
+
const updatedSettings = {
|
|
22058
|
+
...settings,
|
|
22059
|
+
"files.associations": {
|
|
22060
|
+
...settings["files.associations"] ?? {},
|
|
22061
|
+
"*.prompt": "markdown"
|
|
22062
|
+
},
|
|
22063
|
+
"liquid.engine": "standard"
|
|
22064
|
+
};
|
|
22065
|
+
writeFileSync(settingsPath, `${JSON.stringify(updatedSettings, null, 2)}\n`, "utf8");
|
|
22066
|
+
ctx.logger.success(`Updated ${settingsPath}`);
|
|
22067
|
+
}
|
|
22068
|
+
if (await ctx.prompts.confirm({
|
|
22069
|
+
message: "Add Shopify Liquid extension to VSCode recommendations?",
|
|
22070
|
+
initialValue: true
|
|
22071
|
+
})) {
|
|
22072
|
+
const vscodeDir = resolve(VSCODE_DIR);
|
|
22073
|
+
mkdirSync(vscodeDir, { recursive: true });
|
|
22074
|
+
const extensionsPath = resolve(vscodeDir, EXTENSIONS_FILE);
|
|
22075
|
+
const extensions = readJsonFile(extensionsPath);
|
|
22076
|
+
const currentRecs = extensions.recommendations ?? [];
|
|
22077
|
+
const extensionId = "sissel.shopify-liquid";
|
|
22078
|
+
const recommendations = (() => {
|
|
22079
|
+
if (currentRecs.includes(extensionId)) return currentRecs;
|
|
22080
|
+
return [...currentRecs, extensionId];
|
|
22081
|
+
})();
|
|
22082
|
+
const updatedExtensions = {
|
|
22083
|
+
...extensions,
|
|
22084
|
+
recommendations
|
|
22085
|
+
};
|
|
22086
|
+
writeFileSync(extensionsPath, `${JSON.stringify(updatedExtensions, null, 2)}\n`, "utf8");
|
|
22087
|
+
ctx.logger.success(`Updated ${extensionsPath}`);
|
|
22088
|
+
}
|
|
22089
|
+
if (await ctx.prompts.confirm({
|
|
22090
|
+
message: "Add .prompts/client/ to .gitignore? (generated client should not be committed)",
|
|
22091
|
+
initialValue: true
|
|
22092
|
+
})) {
|
|
22093
|
+
const gitignorePath = resolve(GITIGNORE_FILE);
|
|
22094
|
+
const existing = (() => {
|
|
22095
|
+
if (existsSync(gitignorePath)) return readFileSync(gitignorePath, "utf8");
|
|
22096
|
+
return "";
|
|
22097
|
+
})();
|
|
22098
|
+
if (existing.includes(GITIGNORE_ENTRY)) ctx.logger.info(`${GITIGNORE_ENTRY} already in ${gitignorePath}`);
|
|
22099
|
+
else {
|
|
22100
|
+
writeFileSync(gitignorePath, `${existing}${`${(() => {
|
|
22101
|
+
if (existing.length > 0 && !existing.endsWith("\n")) return "\n";
|
|
22102
|
+
return "";
|
|
22103
|
+
})()}\n# Generated prompt client (created by \`funkai prompts generate\`)\n${GITIGNORE_ENTRY}\n`}`, "utf8");
|
|
22104
|
+
ctx.logger.success(`Added ${GITIGNORE_ENTRY} to ${gitignorePath}`);
|
|
22105
|
+
}
|
|
22106
|
+
}
|
|
22107
|
+
if (await ctx.prompts.confirm({
|
|
22108
|
+
message: "Add ~prompts path alias to tsconfig.json?",
|
|
22109
|
+
initialValue: true
|
|
22110
|
+
})) {
|
|
22111
|
+
const tsconfigPath = resolve(TSCONFIG_FILE);
|
|
22112
|
+
const tsconfig = readJsonFile(tsconfigPath);
|
|
22113
|
+
const compilerOptions = tsconfig.compilerOptions ?? {};
|
|
22114
|
+
const existingPaths = compilerOptions.paths ?? {};
|
|
22115
|
+
if (existingPaths[PROMPTS_ALIAS]) ctx.logger.info(`${PROMPTS_ALIAS} alias already in ${tsconfigPath}`);
|
|
22116
|
+
else {
|
|
22117
|
+
const updatedTsconfig = {
|
|
22118
|
+
...tsconfig,
|
|
22119
|
+
compilerOptions: {
|
|
22120
|
+
...compilerOptions,
|
|
22121
|
+
paths: {
|
|
22122
|
+
...existingPaths,
|
|
22123
|
+
[PROMPTS_ALIAS]: [PROMPTS_ALIAS_PATH]
|
|
22124
|
+
}
|
|
22125
|
+
}
|
|
22126
|
+
};
|
|
22127
|
+
writeFileSync(tsconfigPath, `${JSON.stringify(updatedTsconfig, null, 2)}\n`, "utf8");
|
|
22128
|
+
ctx.logger.success(`Added ${PROMPTS_ALIAS} alias to ${tsconfigPath}`);
|
|
22129
|
+
}
|
|
22130
|
+
}
|
|
22131
|
+
ctx.logger.outro("Project setup complete.");
|
|
23222
22132
|
}
|
|
23223
|
-
};
|
|
22133
|
+
});
|
|
22134
|
+
}));
|
|
22135
|
+
|
|
22136
|
+
//#endregion
|
|
22137
|
+
//#region \0virtual:kidd-static-commands
|
|
22138
|
+
var _virtual_kidd_static_commands_exports = /* @__PURE__ */ __exportAll$1({ autoload: () => autoload$1 });
|
|
22139
|
+
async function autoload$1() {
|
|
22140
|
+
return commands;
|
|
23224
22141
|
}
|
|
23225
|
-
|
|
23226
|
-
|
|
23227
|
-
|
|
23228
|
-
|
|
23229
|
-
|
|
23230
|
-
|
|
23231
|
-
|
|
23232
|
-
|
|
23233
|
-
|
|
23234
|
-
|
|
23235
|
-
|
|
23236
|
-
|
|
23237
|
-
|
|
23238
|
-
|
|
23239
|
-
|
|
23240
|
-
|
|
23241
|
-
|
|
23242
|
-
|
|
23243
|
-
|
|
23244
|
-
|
|
23245
|
-
|
|
23246
|
-
|
|
23247
|
-
args: options.args,
|
|
23248
|
-
colors: Object.freeze({ ...import_picocolors.default }),
|
|
23249
|
-
config: options.config,
|
|
23250
|
-
fail(message, failOptions) {
|
|
23251
|
-
throw createContextError(message, failOptions);
|
|
23252
|
-
},
|
|
23253
|
-
format: ctxFormat,
|
|
23254
|
-
logger: ctxLogger,
|
|
23255
|
-
meta: ctxMeta,
|
|
23256
|
-
prompts: ctxPrompts,
|
|
23257
|
-
spinner: ctxSpinner,
|
|
23258
|
-
store: ctxStore
|
|
22142
|
+
var commands;
|
|
22143
|
+
var init__virtual_kidd_static_commands = __esmMin((() => {
|
|
22144
|
+
init_tag();
|
|
22145
|
+
init_generate();
|
|
22146
|
+
init_setup$1();
|
|
22147
|
+
init_validate$1();
|
|
22148
|
+
init_validate();
|
|
22149
|
+
init_create();
|
|
22150
|
+
init_generate$1();
|
|
22151
|
+
init_lint();
|
|
22152
|
+
init_setup();
|
|
22153
|
+
commands = {
|
|
22154
|
+
"generate": generate_default,
|
|
22155
|
+
"setup": setup_default$1,
|
|
22156
|
+
"validate": validate_default$1,
|
|
22157
|
+
"agents": withTag({ commands: { "validate": validate_default } }, "Command"),
|
|
22158
|
+
"prompts": withTag({ commands: {
|
|
22159
|
+
"create": create_default,
|
|
22160
|
+
"generate": generate_default$1,
|
|
22161
|
+
"lint": lint_default,
|
|
22162
|
+
"setup": setup_default
|
|
22163
|
+
} }, "Command")
|
|
23259
22164
|
};
|
|
23260
|
-
}
|
|
22165
|
+
}));
|
|
22166
|
+
|
|
22167
|
+
//#endregion
|
|
22168
|
+
//#region ../../node_modules/.pnpm/@kidd-cli+core@0.10.0_chokidar@5.0.0_jiti@2.6.1_magicast@0.5.2_vitest@4.1.0_@opentelemetry+ap_h5jt7i6rdfwaknd5di57zdj5zy/node_modules/@kidd-cli/core/dist/cli-DhHGZzjZ.js
|
|
23261
22169
|
async function autoload() {
|
|
23262
22170
|
return (await Promise.resolve().then(() => (init__virtual_kidd_static_commands(), _virtual_kidd_static_commands_exports))).autoload();
|
|
23263
22171
|
}
|
|
@@ -23273,10 +22181,10 @@ async function autoload() {
|
|
|
23273
22181
|
*/
|
|
23274
22182
|
function isCommandsConfig(value) {
|
|
23275
22183
|
if (typeof value !== "object" || value === null || value instanceof Promise) return false;
|
|
23276
|
-
return "order"
|
|
22184
|
+
return Object.hasOwn(value, "order") && Array.isArray(value.order) || Object.hasOwn(value, "path") && typeof value.path === "string";
|
|
23277
22185
|
}
|
|
23278
22186
|
/**
|
|
23279
|
-
* Define a CLI command with typed
|
|
22187
|
+
* Define a CLI command with typed options, positionals, config, and handler.
|
|
23280
22188
|
*
|
|
23281
22189
|
* The `const TMiddleware` generic preserves the middleware tuple as a literal type,
|
|
23282
22190
|
* enabling TypeScript to extract and intersect `Variables` from each middleware
|
|
@@ -23286,18 +22194,36 @@ function isCommandsConfig(value) {
|
|
|
23286
22194
|
* normalizes it into flat `commands` and `order` fields on the output
|
|
23287
22195
|
* `Command` object so downstream consumers never need to handle the grouped form.
|
|
23288
22196
|
*
|
|
23289
|
-
* @param def - Command definition including description,
|
|
22197
|
+
* @param def - Command definition including description, options, positionals, middleware, and handler.
|
|
23290
22198
|
* @returns A resolved Command object for registration in the command map.
|
|
23291
22199
|
*/
|
|
23292
22200
|
function command(def) {
|
|
23293
|
-
|
|
22201
|
+
const resolved = {
|
|
22202
|
+
...def,
|
|
22203
|
+
deprecated: resolveValue$1(def.deprecated),
|
|
22204
|
+
description: resolveValue$1(def.description),
|
|
22205
|
+
hidden: resolveValue$1(def.hidden)
|
|
22206
|
+
};
|
|
22207
|
+
return (0, fp_exports.match)(resolved.commands).when(isCommandsConfig, (cfg) => {
|
|
23294
22208
|
const { order, commands: innerCommands } = cfg;
|
|
23295
22209
|
return withTag({
|
|
23296
|
-
...
|
|
22210
|
+
...resolved,
|
|
23297
22211
|
commands: innerCommands,
|
|
23298
22212
|
order
|
|
23299
22213
|
}, "Command");
|
|
23300
|
-
}).otherwise(() => withTag({ ...
|
|
22214
|
+
}).otherwise(() => withTag({ ...resolved }, "Command"));
|
|
22215
|
+
}
|
|
22216
|
+
/**
|
|
22217
|
+
* Resolve a {@link Resolvable} value by invoking it if it is a function,
|
|
22218
|
+
* or returning the value directly.
|
|
22219
|
+
*
|
|
22220
|
+
* @private
|
|
22221
|
+
* @param value - A static value or zero-argument factory function.
|
|
22222
|
+
* @returns The resolved value, or `undefined` when the input is `undefined`.
|
|
22223
|
+
*/
|
|
22224
|
+
function resolveValue$1(value) {
|
|
22225
|
+
if (typeof value === "function") return value();
|
|
22226
|
+
return value;
|
|
23301
22227
|
}
|
|
23302
22228
|
/**
|
|
23303
22229
|
* Type guard that checks whether a value is a zod object schema.
|
|
@@ -23306,7 +22232,7 @@ function command(def) {
|
|
|
23306
22232
|
* @returns True when args is a ZodObject.
|
|
23307
22233
|
*/
|
|
23308
22234
|
function isZodSchema(args) {
|
|
23309
|
-
return typeof args === "object" && args !== null && "_def"
|
|
22235
|
+
return typeof args === "object" && args !== null && Object.hasOwn(args, "_def") && typeof args._def === "object" && args._def !== null && args._def.type === "object";
|
|
23310
22236
|
}
|
|
23311
22237
|
/**
|
|
23312
22238
|
* Convert an entire zod object schema into a record of yargs options.
|
|
@@ -23315,8 +22241,59 @@ function isZodSchema(args) {
|
|
|
23315
22241
|
* @returns A record mapping field names to yargs option definitions.
|
|
23316
22242
|
*/
|
|
23317
22243
|
function zodSchemaToYargsOptions(schema) {
|
|
22244
|
+
return mapSchemaShape(schema, (fieldSchema) => buildZodFieldOption(fieldSchema, resolveZodYargsType));
|
|
22245
|
+
}
|
|
22246
|
+
/**
|
|
22247
|
+
* Extract positional metadata from a zod object schema.
|
|
22248
|
+
*
|
|
22249
|
+
* Returns an ordered array of positional names with their required/optional status.
|
|
22250
|
+
* Key order from `Object.keys(schema.shape)` determines positional order.
|
|
22251
|
+
*
|
|
22252
|
+
* @param schema - The zod object schema for positionals.
|
|
22253
|
+
* @returns An ordered array of positional metadata.
|
|
22254
|
+
*/
|
|
22255
|
+
function zodSchemaToPositionalMeta(schema) {
|
|
22256
|
+
return getShapeEntries(schema).map(([key, fieldSchema]) => {
|
|
22257
|
+
const { isOptional } = unwrapZodType(fieldSchema);
|
|
22258
|
+
return {
|
|
22259
|
+
isOptional,
|
|
22260
|
+
name: key
|
|
22261
|
+
};
|
|
22262
|
+
});
|
|
22263
|
+
}
|
|
22264
|
+
/**
|
|
22265
|
+
* Convert a zod object schema into a record of yargs positional options.
|
|
22266
|
+
*
|
|
22267
|
+
* Each field in the schema becomes a positional argument. Positionals support
|
|
22268
|
+
* `string`, `number`, and `boolean` types — other types fall back to `string`.
|
|
22269
|
+
*
|
|
22270
|
+
* @param schema - The zod object schema for positionals.
|
|
22271
|
+
* @returns A record mapping field names to yargs positional option definitions.
|
|
22272
|
+
*/
|
|
22273
|
+
function zodSchemaToYargsPositionals(schema) {
|
|
22274
|
+
return mapSchemaShape(schema, (fieldSchema) => buildZodFieldOption(fieldSchema, resolvePositionalType));
|
|
22275
|
+
}
|
|
22276
|
+
/**
|
|
22277
|
+
* Extract typed shape entries from a zod object schema.
|
|
22278
|
+
*
|
|
22279
|
+
* @private
|
|
22280
|
+
* @param schema - The zod object schema.
|
|
22281
|
+
* @returns An array of [key, fieldSchema] pairs.
|
|
22282
|
+
*/
|
|
22283
|
+
function getShapeEntries(schema) {
|
|
23318
22284
|
const shape = schema.shape;
|
|
23319
|
-
return Object.
|
|
22285
|
+
return Object.entries(shape);
|
|
22286
|
+
}
|
|
22287
|
+
/**
|
|
22288
|
+
* Map every field in a zod object schema through a converter, returning a record.
|
|
22289
|
+
*
|
|
22290
|
+
* @private
|
|
22291
|
+
* @param schema - The zod object schema.
|
|
22292
|
+
* @param converter - A function converting a single zod field schema to a yargs option.
|
|
22293
|
+
* @returns A record mapping field names to converted option definitions.
|
|
22294
|
+
*/
|
|
22295
|
+
function mapSchemaShape(schema, converter) {
|
|
22296
|
+
return Object.fromEntries(getShapeEntries(schema).map(([key, fieldSchema]) => [key, converter(fieldSchema)]));
|
|
23320
22297
|
}
|
|
23321
22298
|
/**
|
|
23322
22299
|
* Extract a default value from a zod definition, falling back to the provided value.
|
|
@@ -23422,6 +22399,19 @@ function resolveZodYargsType(typeName) {
|
|
|
23422
22399
|
return match(typeName).with("string", () => "string").with("number", () => "number").with("boolean", () => "boolean").with("array", () => "array").otherwise(() => "string");
|
|
23423
22400
|
}
|
|
23424
22401
|
/**
|
|
22402
|
+
* Map a type name to a valid yargs positional type.
|
|
22403
|
+
*
|
|
22404
|
+
* Positionals support `'string'`, `'number'`, and `'boolean'`.
|
|
22405
|
+
* All other types fall back to `'string'`. Used for both Zod and
|
|
22406
|
+
* yargs-native positional definitions.
|
|
22407
|
+
*
|
|
22408
|
+
* @param typeName - The type name to resolve.
|
|
22409
|
+
* @returns A positional-compatible type.
|
|
22410
|
+
*/
|
|
22411
|
+
function resolvePositionalType(typeName) {
|
|
22412
|
+
return match(typeName).with("number", () => "number").with("boolean", () => "boolean").otherwise(() => "string");
|
|
22413
|
+
}
|
|
22414
|
+
/**
|
|
23425
22415
|
* Build a base yargs option from a zod schema's description and default.
|
|
23426
22416
|
*
|
|
23427
22417
|
* @private
|
|
@@ -23430,25 +22420,29 @@ function resolveZodYargsType(typeName) {
|
|
|
23430
22420
|
* @returns A partial yargs option object.
|
|
23431
22421
|
*/
|
|
23432
22422
|
function buildBaseOption(inner, defaultValue) {
|
|
23433
|
-
const base = {};
|
|
23434
22423
|
const { description } = inner;
|
|
22424
|
+
const base = {};
|
|
23435
22425
|
if (description) base.describe = description;
|
|
23436
22426
|
if (defaultValue !== void 0) base.default = defaultValue;
|
|
23437
22427
|
return base;
|
|
23438
22428
|
}
|
|
23439
22429
|
/**
|
|
23440
|
-
* Convert a single zod field schema into a
|
|
22430
|
+
* Convert a single zod field schema into a yargs option or positional definition.
|
|
22431
|
+
*
|
|
22432
|
+
* Accepts a type resolver to support both full options (string/number/boolean/array)
|
|
22433
|
+
* and positionals (string/number only).
|
|
23441
22434
|
*
|
|
23442
22435
|
* @private
|
|
23443
22436
|
* @param schema - A single zod field type.
|
|
23444
|
-
* @
|
|
22437
|
+
* @param typeResolver - Function to map zod type name to a yargs-compatible type.
|
|
22438
|
+
* @returns A yargs option/positional object.
|
|
23445
22439
|
*/
|
|
23446
|
-
function
|
|
22440
|
+
function buildZodFieldOption(schema, typeResolver) {
|
|
23447
22441
|
const { inner, isOptional, defaultValue } = unwrapZodType(schema);
|
|
23448
22442
|
const innerDef = inner._def;
|
|
23449
22443
|
const base = {
|
|
23450
22444
|
...buildBaseOption(inner, defaultValue),
|
|
23451
|
-
type:
|
|
22445
|
+
type: typeResolver(innerDef.type)
|
|
23452
22446
|
};
|
|
23453
22447
|
if (!isOptional) return {
|
|
23454
22448
|
...base,
|
|
@@ -23459,19 +22453,40 @@ function getZodTypeOption(schema) {
|
|
|
23459
22453
|
/**
|
|
23460
22454
|
* Create an args parser that cleans and validates raw parsed arguments.
|
|
23461
22455
|
*
|
|
23462
|
-
* Captures
|
|
23463
|
-
* whose `parse` method strips yargs-internal keys and validates
|
|
23464
|
-
* a zod schema when one is defined.
|
|
22456
|
+
* Captures both option and positional definitions in a closure and returns an
|
|
22457
|
+
* ArgsParser whose `parse` method strips yargs-internal keys and validates
|
|
22458
|
+
* against a merged zod schema when one is defined.
|
|
23465
22459
|
*
|
|
23466
|
-
* @param
|
|
22460
|
+
* @param defs - The option and positional definitions from the command.
|
|
23467
22461
|
* @returns An ArgsParser with a parse method.
|
|
23468
22462
|
*/
|
|
23469
|
-
function createArgsParser(
|
|
22463
|
+
function createArgsParser(defs) {
|
|
22464
|
+
const mergedSchema = buildMergedSchema(defs.options, defs.positionals);
|
|
23470
22465
|
return { parse(rawArgs) {
|
|
23471
|
-
return validateArgs(
|
|
22466
|
+
return validateArgs(mergedSchema, cleanParsedArgs(rawArgs));
|
|
23472
22467
|
} };
|
|
23473
22468
|
}
|
|
23474
22469
|
/**
|
|
22470
|
+
* Build a merged Zod schema from options and positionals definitions.
|
|
22471
|
+
*
|
|
22472
|
+
* When both are Zod schemas, merges them into a single schema for validation.
|
|
22473
|
+
* When only one is a Zod schema, returns that schema with `.passthrough()` so
|
|
22474
|
+
* yargs-native keys from the other side are preserved. When neither is Zod,
|
|
22475
|
+
* returns undefined (no validation).
|
|
22476
|
+
*
|
|
22477
|
+
* @private
|
|
22478
|
+
* @param options - Option definitions (flags).
|
|
22479
|
+
* @param positionals - Positional argument definitions.
|
|
22480
|
+
* @returns A merged Zod schema or undefined.
|
|
22481
|
+
*/
|
|
22482
|
+
function buildMergedSchema(options, positionals) {
|
|
22483
|
+
const optionsIsZod = options && isZodSchema(options);
|
|
22484
|
+
const positionalsIsZod = positionals && isZodSchema(positionals);
|
|
22485
|
+
if (optionsIsZod && positionalsIsZod) return options.merge(positionals);
|
|
22486
|
+
if (optionsIsZod) return options.passthrough();
|
|
22487
|
+
if (positionalsIsZod) return positionals.passthrough();
|
|
22488
|
+
}
|
|
22489
|
+
/**
|
|
23475
22490
|
* Strip yargs-internal keys (`_`, `$0`) and camelCase-duplicated hyphenated keys
|
|
23476
22491
|
* from a parsed argv record, returning only user-defined arguments.
|
|
23477
22492
|
*
|
|
@@ -23485,36 +22500,61 @@ function cleanParsedArgs(argv) {
|
|
|
23485
22500
|
/**
|
|
23486
22501
|
* Validate parsed arguments against a zod schema when one is defined.
|
|
23487
22502
|
*
|
|
23488
|
-
*
|
|
23489
|
-
*
|
|
23490
|
-
*
|
|
22503
|
+
* When no zod schema is present, the parsed args are returned as-is.
|
|
22504
|
+
* When a zod schema is present, validation is performed and a Result error
|
|
22505
|
+
* is returned on failure.
|
|
23491
22506
|
*
|
|
23492
22507
|
* @private
|
|
23493
|
-
* @param
|
|
22508
|
+
* @param schema - The merged zod schema or undefined.
|
|
23494
22509
|
* @param parsedArgs - The cleaned parsed arguments.
|
|
23495
22510
|
* @returns A Result containing validated arguments (zod-parsed when applicable).
|
|
23496
22511
|
*/
|
|
23497
|
-
function validateArgs(
|
|
23498
|
-
if (!
|
|
23499
|
-
|
|
23500
|
-
|
|
23501
|
-
|
|
22512
|
+
function validateArgs(schema, parsedArgs) {
|
|
22513
|
+
if (!schema) return ok(parsedArgs);
|
|
22514
|
+
return validate$1({
|
|
22515
|
+
schema,
|
|
22516
|
+
params: parsedArgs,
|
|
22517
|
+
createError: ({ message }) => /* @__PURE__ */ new Error(`Invalid arguments:\n ${message}`)
|
|
22518
|
+
});
|
|
23502
22519
|
}
|
|
23503
22520
|
/**
|
|
23504
|
-
* Register
|
|
22521
|
+
* Register option and positional definitions on a yargs builder.
|
|
22522
|
+
*
|
|
22523
|
+
* Accepts `options` (flags) and `positionals` as either zod object schemas or
|
|
22524
|
+
* records of yargs-native arg definitions. Options are registered via
|
|
22525
|
+
* `builder.option()` and positionals via `builder.positional()`.
|
|
23505
22526
|
*
|
|
23506
|
-
*
|
|
23507
|
-
*
|
|
22527
|
+
* @param params - Builder instance, option definitions, and positional definitions.
|
|
22528
|
+
* @returns Nothing; mutates the yargs builder in place.
|
|
22529
|
+
*/
|
|
22530
|
+
function registerCommandArgs({ builder, options, positionals }) {
|
|
22531
|
+
if (positionals) registerArgsDef({
|
|
22532
|
+
builder,
|
|
22533
|
+
def: positionals,
|
|
22534
|
+
register: (b, key, opt) => b.positional(key, opt),
|
|
22535
|
+
toYargsNative: yargsArgDefToPositional,
|
|
22536
|
+
toZod: zodSchemaToYargsPositionals
|
|
22537
|
+
});
|
|
22538
|
+
if (options) registerArgsDef({
|
|
22539
|
+
builder,
|
|
22540
|
+
def: options,
|
|
22541
|
+
register: (b, key, opt) => b.option(key, opt),
|
|
22542
|
+
toYargsNative: yargsArgDefToOption,
|
|
22543
|
+
toZod: zodSchemaToYargsOptions
|
|
22544
|
+
});
|
|
22545
|
+
}
|
|
22546
|
+
/**
|
|
22547
|
+
* Register an `ArgsDef` (Zod or yargs-native) on a yargs builder.
|
|
23508
22548
|
*
|
|
23509
|
-
* @
|
|
23510
|
-
* @param
|
|
22549
|
+
* @private
|
|
22550
|
+
* @param params - Registration parameters including the builder, definition, and converters.
|
|
23511
22551
|
*/
|
|
23512
|
-
function
|
|
23513
|
-
|
|
23514
|
-
if (isZodSchema(
|
|
23515
|
-
const
|
|
23516
|
-
|
|
23517
|
-
} else
|
|
22552
|
+
function registerArgsDef(params) {
|
|
22553
|
+
const { builder, def, register, toZod, toYargsNative } = params;
|
|
22554
|
+
if (isZodSchema(def)) {
|
|
22555
|
+
const opts = toZod(def);
|
|
22556
|
+
Object.entries(opts).map(([key, opt]) => register(builder, key, opt));
|
|
22557
|
+
} else Object.entries(def).map(([key, argDef]) => register(builder, key, toYargsNative(argDef)));
|
|
23518
22558
|
}
|
|
23519
22559
|
/**
|
|
23520
22560
|
* Convert a yargs-native arg definition into a yargs option object.
|
|
@@ -23529,11 +22569,42 @@ function yargsArgDefToOption(def) {
|
|
|
23529
22569
|
choices: def.choices,
|
|
23530
22570
|
default: def.default,
|
|
23531
22571
|
demandOption: def.required ?? false,
|
|
22572
|
+
deprecated: resolveValue(def.deprecated),
|
|
23532
22573
|
describe: def.description,
|
|
22574
|
+
group: def.group,
|
|
22575
|
+
hidden: resolveValue(def.hidden) ?? false,
|
|
23533
22576
|
type: def.type
|
|
23534
22577
|
};
|
|
23535
22578
|
}
|
|
23536
22579
|
/**
|
|
22580
|
+
* Convert a yargs-native arg definition into a yargs positional option object.
|
|
22581
|
+
*
|
|
22582
|
+
* @private
|
|
22583
|
+
* @param def - The yargs arg definition for a positional.
|
|
22584
|
+
* @returns A yargs positional option object.
|
|
22585
|
+
*/
|
|
22586
|
+
function yargsArgDefToPositional(def) {
|
|
22587
|
+
return {
|
|
22588
|
+
choices: def.choices,
|
|
22589
|
+
default: def.default,
|
|
22590
|
+
demandOption: def.required ?? false,
|
|
22591
|
+
describe: def.description,
|
|
22592
|
+
type: resolvePositionalType(def.type)
|
|
22593
|
+
};
|
|
22594
|
+
}
|
|
22595
|
+
/**
|
|
22596
|
+
* Resolve a {@link Resolvable} value by invoking it if it is a function,
|
|
22597
|
+
* or returning the value directly.
|
|
22598
|
+
*
|
|
22599
|
+
* @private
|
|
22600
|
+
* @param value - A static value or zero-argument factory function.
|
|
22601
|
+
* @returns The resolved value, or `undefined` when the input is `undefined`.
|
|
22602
|
+
*/
|
|
22603
|
+
function resolveValue(value) {
|
|
22604
|
+
if (typeof value === "function") return value();
|
|
22605
|
+
return value;
|
|
22606
|
+
}
|
|
22607
|
+
/**
|
|
23537
22608
|
* Validate that every name in the order array exists in the provided command names.
|
|
23538
22609
|
*
|
|
23539
22610
|
* @param params - The order array and available command names to validate against.
|
|
@@ -23589,7 +22660,7 @@ function isCommand(value) {
|
|
|
23589
22660
|
*/
|
|
23590
22661
|
function registerCommands(options) {
|
|
23591
22662
|
const { instance, commands, resolved, parentPath, order, errorRef } = options;
|
|
23592
|
-
const commandEntries = Object.entries(commands).filter((pair) => isCommand(pair[1]));
|
|
22663
|
+
const commandEntries = Object.entries(commands).filter((pair) => isCommand(pair[1])).map(([key, entry]) => [entry.name ?? key, entry]);
|
|
23593
22664
|
if (order && order.length > 0) {
|
|
23594
22665
|
const [validationError] = validateCommandOrder({
|
|
23595
22666
|
commandNames: commandEntries.map(([name]) => name),
|
|
@@ -23603,7 +22674,7 @@ function registerCommands(options) {
|
|
|
23603
22674
|
sortCommandEntries({
|
|
23604
22675
|
entries: commandEntries,
|
|
23605
22676
|
order
|
|
23606
|
-
}).map(([name, entry]) =>
|
|
22677
|
+
}).map(([name, entry]) => registerSingleCommand({
|
|
23607
22678
|
builder: instance,
|
|
23608
22679
|
cmd: entry,
|
|
23609
22680
|
errorRef,
|
|
@@ -23623,13 +22694,17 @@ function registerCommands(options) {
|
|
|
23623
22694
|
* @private
|
|
23624
22695
|
* @param options - Command registration context.
|
|
23625
22696
|
*/
|
|
23626
|
-
function
|
|
22697
|
+
function registerSingleCommand(options) {
|
|
23627
22698
|
const { instance, name, cmd, resolved, parentPath, errorRef } = options;
|
|
23628
|
-
const
|
|
23629
|
-
|
|
23630
|
-
registerCommandArgs(
|
|
22699
|
+
const commandSpec = formatCommandSpec(formatCommandString(name, cmd.positionals), cmd.aliases);
|
|
22700
|
+
const builder = (yargsBuilder) => {
|
|
22701
|
+
registerCommandArgs({
|
|
22702
|
+
builder: yargsBuilder,
|
|
22703
|
+
options: cmd.options,
|
|
22704
|
+
positionals: cmd.positionals
|
|
22705
|
+
});
|
|
23631
22706
|
if (cmd.commands) {
|
|
23632
|
-
const subCommands = Object.entries(cmd.commands).filter((pair) => isCommand(pair[1]));
|
|
22707
|
+
const subCommands = Object.entries(cmd.commands).filter((pair) => isCommand(pair[1])).map(([key, entry]) => [entry.name ?? key, entry]);
|
|
23633
22708
|
if (cmd.order && cmd.order.length > 0) {
|
|
23634
22709
|
const [validationError] = validateCommandOrder({
|
|
23635
22710
|
commandNames: subCommands.map(([n]) => n),
|
|
@@ -23637,33 +22712,95 @@ function registerResolvedCommand(options) {
|
|
|
23637
22712
|
});
|
|
23638
22713
|
if (validationError && errorRef) {
|
|
23639
22714
|
errorRef.error = validationError;
|
|
23640
|
-
return
|
|
22715
|
+
return yargsBuilder;
|
|
23641
22716
|
}
|
|
23642
22717
|
}
|
|
23643
22718
|
sortCommandEntries({
|
|
23644
22719
|
entries: subCommands,
|
|
23645
22720
|
order: cmd.order
|
|
23646
|
-
}).map(([subName, subEntry]) =>
|
|
23647
|
-
builder,
|
|
22721
|
+
}).map(([subName, subEntry]) => registerSingleCommand({
|
|
22722
|
+
builder: yargsBuilder,
|
|
23648
22723
|
cmd: subEntry,
|
|
23649
22724
|
errorRef,
|
|
23650
|
-
instance:
|
|
22725
|
+
instance: yargsBuilder,
|
|
23651
22726
|
name: subName,
|
|
23652
22727
|
parentPath: [...parentPath, name],
|
|
23653
22728
|
resolved
|
|
23654
22729
|
}));
|
|
23655
|
-
if (cmd.handler)
|
|
23656
|
-
else
|
|
22730
|
+
if (cmd.handler) yargsBuilder.demandCommand(0);
|
|
22731
|
+
else yargsBuilder.demandCommand(1, "You must specify a subcommand.");
|
|
23657
22732
|
}
|
|
23658
|
-
return
|
|
23659
|
-
}
|
|
22733
|
+
return yargsBuilder;
|
|
22734
|
+
};
|
|
22735
|
+
const handler = () => {
|
|
23660
22736
|
resolved.ref = {
|
|
23661
|
-
args: cmd.args,
|
|
23662
22737
|
commandPath: [...parentPath, name],
|
|
23663
22738
|
handler: cmd.handler,
|
|
23664
|
-
middleware: cmd.middleware ?? []
|
|
22739
|
+
middleware: cmd.middleware ?? [],
|
|
22740
|
+
options: cmd.options,
|
|
22741
|
+
positionals: cmd.positionals
|
|
23665
22742
|
};
|
|
23666
|
-
}
|
|
22743
|
+
};
|
|
22744
|
+
if (cmd.hidden === true) instance.command(commandSpec, false, builder, handler, [], cmd.deprecated);
|
|
22745
|
+
else instance.command(commandSpec, cmd.description ?? "", builder, handler, [], cmd.deprecated);
|
|
22746
|
+
}
|
|
22747
|
+
/**
|
|
22748
|
+
* Build a yargs command string with positional placeholders.
|
|
22749
|
+
*
|
|
22750
|
+
* Normalizes both Zod and yargs-native positional definitions to a common
|
|
22751
|
+
* intermediate representation, then formats each as `<name>` (required) or
|
|
22752
|
+
* `[name]` (optional).
|
|
22753
|
+
*
|
|
22754
|
+
* @private
|
|
22755
|
+
* @param name - The base command name.
|
|
22756
|
+
* @param positionals - Optional positional definitions (Zod schema or yargs-native record).
|
|
22757
|
+
* @returns The command string with positional placeholders appended.
|
|
22758
|
+
*/
|
|
22759
|
+
function formatCommandString(name, positionals) {
|
|
22760
|
+
if (!positionals) return name;
|
|
22761
|
+
const meta = extractPositionalMeta(positionals);
|
|
22762
|
+
return match(meta.length).with(0, () => name).otherwise(() => [name, ...meta.map(formatPlaceholder)].join(" "));
|
|
22763
|
+
}
|
|
22764
|
+
/**
|
|
22765
|
+
* Normalize an `ArgsDef` into an ordered array of positional metadata.
|
|
22766
|
+
*
|
|
22767
|
+
* Handles both Zod schemas (via `zodSchemaToPositionalMeta`) and yargs-native
|
|
22768
|
+
* records (via `Object.entries` with `required` check).
|
|
22769
|
+
*
|
|
22770
|
+
* @private
|
|
22771
|
+
* @param positionals - The positional definitions.
|
|
22772
|
+
* @returns An ordered array of positional metadata.
|
|
22773
|
+
*/
|
|
22774
|
+
function extractPositionalMeta(positionals) {
|
|
22775
|
+
if (isZodSchema(positionals)) return zodSchemaToPositionalMeta(positionals);
|
|
22776
|
+
return Object.entries(positionals).map(([key, def]) => ({
|
|
22777
|
+
isOptional: def.required !== true,
|
|
22778
|
+
name: key
|
|
22779
|
+
}));
|
|
22780
|
+
}
|
|
22781
|
+
/**
|
|
22782
|
+
* Format a positional metadata entry as a yargs placeholder string.
|
|
22783
|
+
*
|
|
22784
|
+
* @private
|
|
22785
|
+
* @param meta - The positional metadata.
|
|
22786
|
+
* @returns `<name>` for required positionals, `[name]` for optional ones.
|
|
22787
|
+
*/
|
|
22788
|
+
function formatPlaceholder(meta) {
|
|
22789
|
+
return match(meta.isOptional).with(true, () => `[${meta.name}]`).otherwise(() => `<${meta.name}>`);
|
|
22790
|
+
}
|
|
22791
|
+
/**
|
|
22792
|
+
* Build the first argument to `yargs.command()`.
|
|
22793
|
+
*
|
|
22794
|
+
* Returns a plain string when there are no aliases, or a `[commandString, ...aliases]`
|
|
22795
|
+
* array when aliases are present — both forms are accepted by yargs.
|
|
22796
|
+
*
|
|
22797
|
+
* @private
|
|
22798
|
+
* @param commandString - The primary command string (may include positional placeholders).
|
|
22799
|
+
* @param aliases - Optional alternative names for the command.
|
|
22800
|
+
* @returns A string or string array suitable for `yargs.command()`.
|
|
22801
|
+
*/
|
|
22802
|
+
function formatCommandSpec(commandString, aliases) {
|
|
22803
|
+
return match(aliases).with(void 0, () => commandString).otherwise((a) => match(a.length).with(0, () => commandString).otherwise(() => [commandString, ...a]));
|
|
23667
22804
|
}
|
|
23668
22805
|
/**
|
|
23669
22806
|
* Create a runner that executes root and command middleware chains.
|
|
@@ -23680,9 +22817,9 @@ function registerResolvedCommand(options) {
|
|
|
23680
22817
|
* ```
|
|
23681
22818
|
*
|
|
23682
22819
|
* @param rootMiddleware - Root-level middleware from `cli({ middleware })`.
|
|
23683
|
-
* @returns A
|
|
22820
|
+
* @returns A MiddlewareExecutor with an execute method.
|
|
23684
22821
|
*/
|
|
23685
|
-
function
|
|
22822
|
+
function createMiddlewareExecutor(rootMiddleware) {
|
|
23686
22823
|
return { async execute({ ctx, handler, middleware }) {
|
|
23687
22824
|
const commandHandler = async (innerCtx) => {
|
|
23688
22825
|
await runMiddlewareChain(middleware, innerCtx, handler);
|
|
@@ -23725,15 +22862,19 @@ async function runMiddlewareChain(middlewares, ctx, finalHandler) {
|
|
|
23725
22862
|
*/
|
|
23726
22863
|
async function createRuntime(options) {
|
|
23727
22864
|
const config = await resolveConfig(options.config, options.name);
|
|
23728
|
-
const runner =
|
|
22865
|
+
const runner = createMiddlewareExecutor(options.middleware ?? []);
|
|
23729
22866
|
return ok({ async execute(command) {
|
|
23730
|
-
const [argsError, validatedArgs] = createArgsParser(
|
|
22867
|
+
const [argsError, validatedArgs] = createArgsParser({
|
|
22868
|
+
options: command.options,
|
|
22869
|
+
positionals: command.positionals
|
|
22870
|
+
}).parse(command.rawArgs);
|
|
23731
22871
|
if (argsError) return err(argsError);
|
|
23732
22872
|
const ctx = createContext({
|
|
23733
22873
|
args: validatedArgs,
|
|
23734
22874
|
config,
|
|
23735
22875
|
meta: {
|
|
23736
22876
|
command: [...command.commandPath],
|
|
22877
|
+
dirs: options.dirs,
|
|
23737
22878
|
name: options.name,
|
|
23738
22879
|
version: options.version
|
|
23739
22880
|
}
|
|
@@ -23814,18 +22955,21 @@ async function cli(options) {
|
|
|
23814
22955
|
});
|
|
23815
22956
|
return;
|
|
23816
22957
|
}
|
|
22958
|
+
const dirs = resolveDirs(options.name, options.dirs);
|
|
23817
22959
|
const [runtimeError, runtime] = await createRuntime({
|
|
23818
22960
|
config: options.config,
|
|
22961
|
+
dirs,
|
|
23819
22962
|
middleware: options.middleware,
|
|
23820
22963
|
name: options.name,
|
|
23821
22964
|
version
|
|
23822
22965
|
});
|
|
23823
22966
|
if (runtimeError) return runtimeError;
|
|
23824
22967
|
const [executeError] = await runtime.execute({
|
|
23825
|
-
args: resolved.ref.args,
|
|
23826
22968
|
commandPath: resolved.ref.commandPath,
|
|
23827
22969
|
handler: resolved.ref.handler,
|
|
23828
22970
|
middleware: resolved.ref.middleware,
|
|
22971
|
+
options: resolved.ref.options,
|
|
22972
|
+
positionals: resolved.ref.positionals,
|
|
23829
22973
|
rawArgs: argv
|
|
23830
22974
|
});
|
|
23831
22975
|
return executeError;
|
|
@@ -23856,7 +23000,7 @@ function resolveVersion(explicit) {
|
|
|
23856
23000
|
return err(VERSION_ERROR);
|
|
23857
23001
|
}
|
|
23858
23002
|
{
|
|
23859
|
-
const parsed = VersionSchema.safeParse("0.1.
|
|
23003
|
+
const parsed = VersionSchema.safeParse("0.1.4");
|
|
23860
23004
|
if (parsed.success) return ok(parsed.data);
|
|
23861
23005
|
}
|
|
23862
23006
|
return err(VERSION_ERROR);
|
|
@@ -23962,6 +23106,37 @@ function extractFooter(help) {
|
|
|
23962
23106
|
return help.footer;
|
|
23963
23107
|
}
|
|
23964
23108
|
/**
|
|
23109
|
+
* Resolve directory config into a {@link ResolvedDirs} with defaults.
|
|
23110
|
+
*
|
|
23111
|
+
* Both `local` and `global` default to `.<name>` when not provided.
|
|
23112
|
+
*
|
|
23113
|
+
* @private
|
|
23114
|
+
* @param name - The CLI name used to derive defaults.
|
|
23115
|
+
* @param dirs - Optional user-provided directory overrides.
|
|
23116
|
+
* @returns Resolved dirs with both local and global guaranteed.
|
|
23117
|
+
*/
|
|
23118
|
+
function resolveDirs(name, dirs) {
|
|
23119
|
+
const defaultDir = `.${name}`;
|
|
23120
|
+
if (isNil(dirs)) return {
|
|
23121
|
+
global: defaultDir,
|
|
23122
|
+
local: defaultDir
|
|
23123
|
+
};
|
|
23124
|
+
return {
|
|
23125
|
+
global: (0, fp_exports.match)(dirs.global).with(fp_exports.P.nullish, () => defaultDir).when(isEmptyString, () => defaultDir).otherwise((v) => v),
|
|
23126
|
+
local: (0, fp_exports.match)(dirs.local).with(fp_exports.P.nullish, () => defaultDir).when(isEmptyString, () => defaultDir).otherwise((v) => v)
|
|
23127
|
+
};
|
|
23128
|
+
}
|
|
23129
|
+
/**
|
|
23130
|
+
* Check whether a value is an empty string (after trimming whitespace).
|
|
23131
|
+
*
|
|
23132
|
+
* @private
|
|
23133
|
+
* @param value - The value to check.
|
|
23134
|
+
* @returns True when the value is an empty or whitespace-only string.
|
|
23135
|
+
*/
|
|
23136
|
+
function isEmptyString(value) {
|
|
23137
|
+
return value.trim().length === 0;
|
|
23138
|
+
}
|
|
23139
|
+
/**
|
|
23965
23140
|
* Handle a CLI error by logging the message and exiting with the appropriate code.
|
|
23966
23141
|
*
|
|
23967
23142
|
* ContextErrors carry a custom exit code; all other errors exit with code 1.
|
|
@@ -23984,32 +23159,60 @@ function exitOnError(error, logger) {
|
|
|
23984
23159
|
logger.error(info.message);
|
|
23985
23160
|
process.exit(info.exitCode);
|
|
23986
23161
|
}
|
|
23987
|
-
var
|
|
23988
|
-
var
|
|
23989
|
-
init_tally_ioa20iGw();
|
|
23162
|
+
var ARGV_SLICE_START, VERSION_ERROR, VersionSchema;
|
|
23163
|
+
var init_cli_DhHGZzjZ = __esmMin((() => {
|
|
23990
23164
|
init_logger();
|
|
23991
|
-
|
|
23992
|
-
|
|
23165
|
+
init_create_context_vWwSL8R5();
|
|
23166
|
+
init_config_BSyREvk7();
|
|
23993
23167
|
init_loader();
|
|
23994
23168
|
init_fp();
|
|
23995
23169
|
init_yargs();
|
|
23996
|
-
init_dist$10();
|
|
23997
|
-
import_picocolors = /* @__PURE__ */ __toESM(require_picocolors(), 1);
|
|
23998
23170
|
init_tag();
|
|
23999
|
-
init_json$1();
|
|
24000
23171
|
init_validate$2();
|
|
24001
23172
|
ARGV_SLICE_START = 2;
|
|
24002
23173
|
VERSION_ERROR = /* @__PURE__ */ new Error("No CLI version available. Either pass `version` to cli() or build with the kidd bundler.");
|
|
24003
23174
|
VersionSchema = z.string().trim().min(1);
|
|
24004
23175
|
}));
|
|
24005
23176
|
|
|
23177
|
+
//#endregion
|
|
23178
|
+
//#region ../../node_modules/.pnpm/@kidd-cli+core@0.10.0_chokidar@5.0.0_jiti@2.6.1_magicast@0.5.2_vitest@4.1.0_@opentelemetry+ap_h5jt7i6rdfwaknd5di57zdj5zy/node_modules/@kidd-cli/core/dist/index.js
|
|
23179
|
+
var init_dist = __esmMin((() => {
|
|
23180
|
+
init_cli_DhHGZzjZ();
|
|
23181
|
+
}));
|
|
23182
|
+
|
|
24006
23183
|
//#endregion
|
|
24007
23184
|
//#region src/index.ts
|
|
24008
23185
|
init_dist();
|
|
23186
|
+
init_validate();
|
|
23187
|
+
init_generate();
|
|
23188
|
+
init_create();
|
|
23189
|
+
init_generate$1();
|
|
23190
|
+
init_lint();
|
|
23191
|
+
init_setup();
|
|
23192
|
+
init_setup$1();
|
|
23193
|
+
init_validate$1();
|
|
24009
23194
|
await cli({
|
|
24010
23195
|
description: "CLI for the funkai AI SDK framework",
|
|
24011
23196
|
name: "funkai",
|
|
24012
|
-
version: createRequire(import.meta.url)("../package.json").version
|
|
23197
|
+
version: createRequire(import.meta.url)("../package.json").version,
|
|
23198
|
+
commands: {
|
|
23199
|
+
generate: generate_default,
|
|
23200
|
+
setup: setup_default$1,
|
|
23201
|
+
validate: validate_default$1,
|
|
23202
|
+
agents: command({
|
|
23203
|
+
description: "Agent-related commands",
|
|
23204
|
+
commands: { validate: validate_default }
|
|
23205
|
+
}),
|
|
23206
|
+
prompts: command({
|
|
23207
|
+
description: "Prompt-related commands",
|
|
23208
|
+
commands: {
|
|
23209
|
+
create: create_default,
|
|
23210
|
+
generate: generate_default$1,
|
|
23211
|
+
lint: lint_default,
|
|
23212
|
+
setup: setup_default
|
|
23213
|
+
}
|
|
23214
|
+
})
|
|
23215
|
+
}
|
|
24013
23216
|
});
|
|
24014
23217
|
|
|
24015
23218
|
//#endregion
|