politty 0.7.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +1 -1
- package/dist/docs/index.d.ts +44 -2
- package/dist/docs/index.js +827 -43
- package/dist/index.js +1 -1
- package/dist/{runner-D43SkHt5.js → runner-APRZYXUS.js} +74 -3
- package/package.json +22 -67
- package/dist/arg-registry-DDJpsUea.d.cts +0 -942
- package/dist/arg-registry-DDJpsUea.d.cts.map +0 -1
- package/dist/arg-registry-DDJpsUea.d.ts.map +0 -1
- package/dist/augment.cjs +0 -0
- package/dist/augment.d.cts +0 -17
- package/dist/augment.d.cts.map +0 -1
- package/dist/augment.d.ts.map +0 -1
- package/dist/cli.cjs +0 -54
- package/dist/cli.cjs.map +0 -1
- package/dist/cli.d.cts +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/completion/index.cjs +0 -23
- package/dist/completion/index.d.cts +0 -3
- package/dist/completion-CLHO3Xaz.cjs +0 -5769
- package/dist/completion-CLHO3Xaz.cjs.map +0 -1
- package/dist/completion-DHnVx9Zk.js.map +0 -1
- package/dist/docs/index.cjs +0 -2343
- package/dist/docs/index.cjs.map +0 -1
- package/dist/docs/index.d.cts +0 -710
- package/dist/docs/index.d.cts.map +0 -1
- package/dist/docs/index.d.ts.map +0 -1
- package/dist/docs/index.js.map +0 -1
- package/dist/index-DKGn3lIl.d.ts.map +0 -1
- package/dist/index-WyViqW59.d.cts +0 -663
- package/dist/index-WyViqW59.d.cts.map +0 -1
- package/dist/index.cjs +0 -45
- package/dist/index.d.cts +0 -685
- package/dist/index.d.cts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/log-collector-DK32-73m.js.map +0 -1
- package/dist/log-collector-DUqC427m.cjs +0 -185
- package/dist/log-collector-DUqC427m.cjs.map +0 -1
- package/dist/prompt/clack/index.cjs +0 -33
- package/dist/prompt/clack/index.cjs.map +0 -1
- package/dist/prompt/clack/index.d.cts +0 -18
- package/dist/prompt/clack/index.d.cts.map +0 -1
- package/dist/prompt/clack/index.d.ts.map +0 -1
- package/dist/prompt/clack/index.js.map +0 -1
- package/dist/prompt/index.cjs +0 -7
- package/dist/prompt/index.d.cts +0 -108
- package/dist/prompt/index.d.cts.map +0 -1
- package/dist/prompt/index.d.ts.map +0 -1
- package/dist/prompt/inquirer/index.cjs +0 -48
- package/dist/prompt/inquirer/index.cjs.map +0 -1
- package/dist/prompt/inquirer/index.d.cts +0 -18
- package/dist/prompt/inquirer/index.d.cts.map +0 -1
- package/dist/prompt/inquirer/index.d.ts.map +0 -1
- package/dist/prompt/inquirer/index.js.map +0 -1
- package/dist/prompt-Bs9e-Em3.cjs +0 -196
- package/dist/prompt-Bs9e-Em3.cjs.map +0 -1
- package/dist/prompt-Cc8Tfmdv.js.map +0 -1
- package/dist/runner-D43SkHt5.js.map +0 -1
- package/dist/runner-DvFvokV6.cjs +0 -2865
- package/dist/runner-DvFvokV6.cjs.map +0 -1
- package/dist/schema-extractor-BxSRwLrx.cjs +0 -710
- package/dist/schema-extractor-BxSRwLrx.cjs.map +0 -1
- package/dist/schema-extractor-Dqe7_kyQ.js.map +0 -1
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/core/case-types.ts","../src/core/case-proxy.ts","../src/core/command.ts","../src/core/runner.ts","../src/output/help-generator.ts","../src/output/logger.ts","../src/output/markdown-renderer.ts","../src/parser/argv-parser.ts","../src/validator/validation-errors.ts","../src/validator/command-validator.ts","../src/validator/zod-validator.ts"],"mappings":";;;;;;;;;;AAcA;;;;;;;;KAAY,SAAA,qBAA8B,CAAA,gDACnC,CAAA,GAAI,SAAA,CAAU,CAAA,IAAK,SAAA,CAAU,CAAA,MAChC,CAAA;;;;;;;;;;;;;;KAeC,cAAA,qBAAmC,CAAA,yCACpC,IAAA,cACE,KAAA,SAAc,SAAA,CAAU,KAAA,IACtB,KAAA,OACI,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BSujBsB,eAAA,CACpB,OAAA,EAAS,UAAA,EACT,OAAA,GAAS,sBAAA,GACR,OAAA,CAAQ,uBAAA;;;AT1jBkE;AAc7E;;;iBSolBgB,6BAAA,CAA8B,MAAgC,EAAxB,sBAAsB;;;;;;UCtpB3D,eAAA;EVQI;EUNnB,IAAA;EVMwC;EUJxC,OAAA;EVKmB;EUHnB,IAAA;EVGkC;EUDlC,QAAA;EVEE;EUAF,QAAA;AAAA;;;;KAMU,gBAAA;EACN,OAAA;EAAe,IAAA,EAAM,CAAA;AAAA;EACrB,OAAA;EAAgB,MAAA,EAAQ,eAAe;AAAA;;;;iBA4C7B,sBAAA,CAAuB,MAAyB,EAAjB,eAAe"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"log-collector-DK32-73m.js","names":[],"sources":["../src/executor/log-collector.ts"],"sourcesContent":["import type { CollectedLogs, LogEntry, LogLevel, LogStream } from \"../types.js\";\n\n/**\n * Mapping from log level to output stream\n */\nconst LOG_STREAM_MAP: Record<LogLevel, LogStream> = {\n log: \"stdout\",\n info: \"stdout\",\n debug: \"stdout\",\n warn: \"stderr\",\n error: \"stderr\",\n};\n\n/**\n * All log levels\n */\nconst ALL_LOG_LEVELS: LogLevel[] = [\"log\", \"info\", \"debug\", \"warn\", \"error\"];\n\n/**\n * Options for log collector\n */\nexport interface LogCollectorOptions {\n /** Log levels to capture (default: all) */\n levels?: LogLevel[];\n /** Whether to call original console methods (default: true) */\n passthrough?: boolean;\n}\n\n/**\n * Log collector that intercepts console methods\n */\nexport interface LogCollector {\n /** Get collected logs */\n getLogs: () => CollectedLogs;\n /** Start collecting logs */\n start: () => void;\n /** Stop collecting and restore original console methods */\n stop: () => void;\n}\n\n/**\n * Format console arguments to string\n */\nexport function formatArgs(args: unknown[]): string {\n return args\n .map((arg) => {\n if (arg instanceof Error) {\n return arg.message;\n }\n if (typeof arg === \"object\" && arg !== null) {\n try {\n return JSON.stringify(arg);\n } catch {\n return String(arg);\n }\n }\n return String(arg);\n })\n .join(\" \");\n}\n\n/**\n * Create a log collector that intercepts console methods\n *\n * @param options - Options for the log collector\n * @returns A log collector instance\n *\n * @example\n * ```ts\n * const collector = createLogCollector();\n * collector.start();\n *\n * console.log(\"Info message\");\n * console.error(\"Something went wrong\");\n * console.warn(\"This is a warning\");\n *\n * collector.stop();\n * const logs = collector.getLogs();\n * // {\n * // entries: [\n * // { message: \"Info message\", level: \"log\", stream: \"stdout\", timestamp: ... },\n * // { message: \"Something went wrong\", level: \"error\", stream: \"stderr\", timestamp: ... },\n * // { message: \"This is a warning\", level: \"warn\", stream: \"stderr\", timestamp: ... }\n * // ]\n * // }\n * ```\n */\nexport function createLogCollector(options: LogCollectorOptions = {}): LogCollector {\n const entries: LogEntry[] = [];\n const levels = options.levels ?? ALL_LOG_LEVELS;\n const passthrough = options.passthrough ?? true;\n\n let originals: Record<LogLevel, typeof console.log> | null = null;\n\n const createInterceptor = (level: LogLevel, original: typeof console.log) => {\n return (...args: unknown[]) => {\n entries.push({\n message: formatArgs(args),\n timestamp: new Date(),\n level,\n stream: LOG_STREAM_MAP[level],\n });\n if (passthrough) {\n original.apply(console, args);\n }\n };\n };\n\n return {\n getLogs() {\n return { entries: [...entries] };\n },\n start() {\n if (originals !== null) {\n // Already started\n return;\n }\n originals = {\n log: console.log,\n info: console.info,\n debug: console.debug,\n warn: console.warn,\n error: console.error,\n };\n for (const level of levels) {\n console[level] = createInterceptor(level, originals[level]);\n }\n },\n stop() {\n if (originals === null) {\n return;\n }\n for (const level of levels) {\n console[level] = originals[level];\n }\n originals = null;\n },\n };\n}\n\n/**\n * Merge multiple CollectedLogs into one (sorted by timestamp)\n */\nexport function mergeLogs(...logsArray: CollectedLogs[]): CollectedLogs {\n return {\n entries: logsArray\n .flatMap((l) => l.entries)\n .sort((a, b) => a.timestamp.getTime() - b.timestamp.getTime()),\n };\n}\n\n/**\n * Create an empty CollectedLogs object\n */\nexport function emptyLogs(): CollectedLogs {\n return { entries: [] };\n}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7B,YAAY;EACd;CACF;AACF;;;;AAKA,SAAgB,UAAU,GAAG,WAA2C;CACtE,OAAO,EACL,SAAS,UACN,SAAS,MAAM,EAAE,OAAO,CAAC,CACzB,MAAM,GAAG,MAAM,EAAE,UAAU,QAAQ,IAAI,EAAE,UAAU,QAAQ,CAAC,EACjE;AACF;;;;AAKA,SAAgB,YAA2B;CACzC,OAAO,EAAE,SAAS,CAAC,EAAE;AACvB"}
|
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
//#region \0rolldown/runtime.js
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __exportAll = (all, no_symbols) => {
|
|
9
|
-
let target = {};
|
|
10
|
-
for (var name in all) {
|
|
11
|
-
__defProp(target, name, {
|
|
12
|
-
get: all[name],
|
|
13
|
-
enumerable: true
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
if (!no_symbols) {
|
|
17
|
-
__defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
18
|
-
}
|
|
19
|
-
return target;
|
|
20
|
-
};
|
|
21
|
-
var __copyProps = (to, from, except, desc) => {
|
|
22
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
23
|
-
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
24
|
-
key = keys[i];
|
|
25
|
-
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
26
|
-
__defProp(to, key, {
|
|
27
|
-
get: ((k) => from[k]).bind(null, key),
|
|
28
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
return to;
|
|
34
|
-
};
|
|
35
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
36
|
-
value: mod,
|
|
37
|
-
enumerable: true
|
|
38
|
-
}) : target, mod));
|
|
39
|
-
|
|
40
|
-
//#endregion
|
|
41
|
-
|
|
42
|
-
//#region src/executor/log-collector.ts
|
|
43
|
-
/**
|
|
44
|
-
* Mapping from log level to output stream
|
|
45
|
-
*/
|
|
46
|
-
const LOG_STREAM_MAP = {
|
|
47
|
-
log: "stdout",
|
|
48
|
-
info: "stdout",
|
|
49
|
-
debug: "stdout",
|
|
50
|
-
warn: "stderr",
|
|
51
|
-
error: "stderr"
|
|
52
|
-
};
|
|
53
|
-
/**
|
|
54
|
-
* All log levels
|
|
55
|
-
*/
|
|
56
|
-
const ALL_LOG_LEVELS = [
|
|
57
|
-
"log",
|
|
58
|
-
"info",
|
|
59
|
-
"debug",
|
|
60
|
-
"warn",
|
|
61
|
-
"error"
|
|
62
|
-
];
|
|
63
|
-
/**
|
|
64
|
-
* Format console arguments to string
|
|
65
|
-
*/
|
|
66
|
-
function formatArgs(args) {
|
|
67
|
-
return args.map((arg) => {
|
|
68
|
-
if (arg instanceof Error) return arg.message;
|
|
69
|
-
if (typeof arg === "object" && arg !== null) try {
|
|
70
|
-
return JSON.stringify(arg);
|
|
71
|
-
} catch {
|
|
72
|
-
return String(arg);
|
|
73
|
-
}
|
|
74
|
-
return String(arg);
|
|
75
|
-
}).join(" ");
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Create a log collector that intercepts console methods
|
|
79
|
-
*
|
|
80
|
-
* @param options - Options for the log collector
|
|
81
|
-
* @returns A log collector instance
|
|
82
|
-
*
|
|
83
|
-
* @example
|
|
84
|
-
* ```ts
|
|
85
|
-
* const collector = createLogCollector();
|
|
86
|
-
* collector.start();
|
|
87
|
-
*
|
|
88
|
-
* console.log("Info message");
|
|
89
|
-
* console.error("Something went wrong");
|
|
90
|
-
* console.warn("This is a warning");
|
|
91
|
-
*
|
|
92
|
-
* collector.stop();
|
|
93
|
-
* const logs = collector.getLogs();
|
|
94
|
-
* // {
|
|
95
|
-
* // entries: [
|
|
96
|
-
* // { message: "Info message", level: "log", stream: "stdout", timestamp: ... },
|
|
97
|
-
* // { message: "Something went wrong", level: "error", stream: "stderr", timestamp: ... },
|
|
98
|
-
* // { message: "This is a warning", level: "warn", stream: "stderr", timestamp: ... }
|
|
99
|
-
* // ]
|
|
100
|
-
* // }
|
|
101
|
-
* ```
|
|
102
|
-
*/
|
|
103
|
-
function createLogCollector(options = {}) {
|
|
104
|
-
const entries = [];
|
|
105
|
-
const levels = options.levels ?? ALL_LOG_LEVELS;
|
|
106
|
-
const passthrough = options.passthrough ?? true;
|
|
107
|
-
let originals = null;
|
|
108
|
-
const createInterceptor = (level, original) => {
|
|
109
|
-
return (...args) => {
|
|
110
|
-
entries.push({
|
|
111
|
-
message: formatArgs(args),
|
|
112
|
-
timestamp: /* @__PURE__ */ new Date(),
|
|
113
|
-
level,
|
|
114
|
-
stream: LOG_STREAM_MAP[level]
|
|
115
|
-
});
|
|
116
|
-
if (passthrough) original.apply(console, args);
|
|
117
|
-
};
|
|
118
|
-
};
|
|
119
|
-
return {
|
|
120
|
-
getLogs() {
|
|
121
|
-
return { entries: [...entries] };
|
|
122
|
-
},
|
|
123
|
-
start() {
|
|
124
|
-
if (originals !== null) return;
|
|
125
|
-
originals = {
|
|
126
|
-
log: console.log,
|
|
127
|
-
info: console.info,
|
|
128
|
-
debug: console.debug,
|
|
129
|
-
warn: console.warn,
|
|
130
|
-
error: console.error
|
|
131
|
-
};
|
|
132
|
-
for (const level of levels) console[level] = createInterceptor(level, originals[level]);
|
|
133
|
-
},
|
|
134
|
-
stop() {
|
|
135
|
-
if (originals === null) return;
|
|
136
|
-
for (const level of levels) console[level] = originals[level];
|
|
137
|
-
originals = null;
|
|
138
|
-
}
|
|
139
|
-
};
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* Merge multiple CollectedLogs into one (sorted by timestamp)
|
|
143
|
-
*/
|
|
144
|
-
function mergeLogs(...logsArray) {
|
|
145
|
-
return { entries: logsArray.flatMap((l) => l.entries).sort((a, b) => a.timestamp.getTime() - b.timestamp.getTime()) };
|
|
146
|
-
}
|
|
147
|
-
/**
|
|
148
|
-
* Create an empty CollectedLogs object
|
|
149
|
-
*/
|
|
150
|
-
function emptyLogs() {
|
|
151
|
-
return { entries: [] };
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
//#endregion
|
|
155
|
-
Object.defineProperty(exports, '__exportAll', {
|
|
156
|
-
enumerable: true,
|
|
157
|
-
get: function () {
|
|
158
|
-
return __exportAll;
|
|
159
|
-
}
|
|
160
|
-
});
|
|
161
|
-
Object.defineProperty(exports, '__toESM', {
|
|
162
|
-
enumerable: true,
|
|
163
|
-
get: function () {
|
|
164
|
-
return __toESM;
|
|
165
|
-
}
|
|
166
|
-
});
|
|
167
|
-
Object.defineProperty(exports, 'createLogCollector', {
|
|
168
|
-
enumerable: true,
|
|
169
|
-
get: function () {
|
|
170
|
-
return createLogCollector;
|
|
171
|
-
}
|
|
172
|
-
});
|
|
173
|
-
Object.defineProperty(exports, 'emptyLogs', {
|
|
174
|
-
enumerable: true,
|
|
175
|
-
get: function () {
|
|
176
|
-
return emptyLogs;
|
|
177
|
-
}
|
|
178
|
-
});
|
|
179
|
-
Object.defineProperty(exports, 'mergeLogs', {
|
|
180
|
-
enumerable: true,
|
|
181
|
-
get: function () {
|
|
182
|
-
return mergeLogs;
|
|
183
|
-
}
|
|
184
|
-
});
|
|
185
|
-
//# sourceMappingURL=log-collector-DUqC427m.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"log-collector-DUqC427m.cjs","names":[],"sources":["../src/executor/log-collector.ts"],"sourcesContent":["import type { CollectedLogs, LogEntry, LogLevel, LogStream } from \"../types.js\";\n\n/**\n * Mapping from log level to output stream\n */\nconst LOG_STREAM_MAP: Record<LogLevel, LogStream> = {\n log: \"stdout\",\n info: \"stdout\",\n debug: \"stdout\",\n warn: \"stderr\",\n error: \"stderr\",\n};\n\n/**\n * All log levels\n */\nconst ALL_LOG_LEVELS: LogLevel[] = [\"log\", \"info\", \"debug\", \"warn\", \"error\"];\n\n/**\n * Options for log collector\n */\nexport interface LogCollectorOptions {\n /** Log levels to capture (default: all) */\n levels?: LogLevel[];\n /** Whether to call original console methods (default: true) */\n passthrough?: boolean;\n}\n\n/**\n * Log collector that intercepts console methods\n */\nexport interface LogCollector {\n /** Get collected logs */\n getLogs: () => CollectedLogs;\n /** Start collecting logs */\n start: () => void;\n /** Stop collecting and restore original console methods */\n stop: () => void;\n}\n\n/**\n * Format console arguments to string\n */\nexport function formatArgs(args: unknown[]): string {\n return args\n .map((arg) => {\n if (arg instanceof Error) {\n return arg.message;\n }\n if (typeof arg === \"object\" && arg !== null) {\n try {\n return JSON.stringify(arg);\n } catch {\n return String(arg);\n }\n }\n return String(arg);\n })\n .join(\" \");\n}\n\n/**\n * Create a log collector that intercepts console methods\n *\n * @param options - Options for the log collector\n * @returns A log collector instance\n *\n * @example\n * ```ts\n * const collector = createLogCollector();\n * collector.start();\n *\n * console.log(\"Info message\");\n * console.error(\"Something went wrong\");\n * console.warn(\"This is a warning\");\n *\n * collector.stop();\n * const logs = collector.getLogs();\n * // {\n * // entries: [\n * // { message: \"Info message\", level: \"log\", stream: \"stdout\", timestamp: ... },\n * // { message: \"Something went wrong\", level: \"error\", stream: \"stderr\", timestamp: ... },\n * // { message: \"This is a warning\", level: \"warn\", stream: \"stderr\", timestamp: ... }\n * // ]\n * // }\n * ```\n */\nexport function createLogCollector(options: LogCollectorOptions = {}): LogCollector {\n const entries: LogEntry[] = [];\n const levels = options.levels ?? ALL_LOG_LEVELS;\n const passthrough = options.passthrough ?? true;\n\n let originals: Record<LogLevel, typeof console.log> | null = null;\n\n const createInterceptor = (level: LogLevel, original: typeof console.log) => {\n return (...args: unknown[]) => {\n entries.push({\n message: formatArgs(args),\n timestamp: new Date(),\n level,\n stream: LOG_STREAM_MAP[level],\n });\n if (passthrough) {\n original.apply(console, args);\n }\n };\n };\n\n return {\n getLogs() {\n return { entries: [...entries] };\n },\n start() {\n if (originals !== null) {\n // Already started\n return;\n }\n originals = {\n log: console.log,\n info: console.info,\n debug: console.debug,\n warn: console.warn,\n error: console.error,\n };\n for (const level of levels) {\n console[level] = createInterceptor(level, originals[level]);\n }\n },\n stop() {\n if (originals === null) {\n return;\n }\n for (const level of levels) {\n console[level] = originals[level];\n }\n originals = null;\n },\n };\n}\n\n/**\n * Merge multiple CollectedLogs into one (sorted by timestamp)\n */\nexport function mergeLogs(...logsArray: CollectedLogs[]): CollectedLogs {\n return {\n entries: logsArray\n .flatMap((l) => l.entries)\n .sort((a, b) => a.timestamp.getTime() - b.timestamp.getTime()),\n };\n}\n\n/**\n * Create an empty CollectedLogs object\n */\nexport function emptyLogs(): CollectedLogs {\n return { entries: [] };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,MAAM,iBAA8C;CAClD,KAAK;CACL,MAAM;CACN,OAAO;CACP,MAAM;CACN,OAAO;AACT;;;;AAKA,MAAM,iBAA6B;CAAC;CAAO;CAAQ;CAAS;CAAQ;AAAO;;;;AA2B3E,SAAgB,WAAW,MAAyB;CAClD,OAAO,KACJ,KAAK,QAAQ;EACZ,IAAI,eAAe,OACjB,OAAO,IAAI;EAEb,IAAI,OAAO,QAAQ,YAAY,QAAQ,MACrC,IAAI;GACF,OAAO,KAAK,UAAU,GAAG;EAC3B,QAAQ;GACN,OAAO,OAAO,GAAG;EACnB;EAEF,OAAO,OAAO,GAAG;CACnB,CAAC,CAAC,CACD,KAAK,GAAG;AACb;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,SAAgB,mBAAmB,UAA+B,CAAC,GAAiB;CAClF,MAAM,UAAsB,CAAC;CAC7B,MAAM,SAAS,QAAQ,UAAU;CACjC,MAAM,cAAc,QAAQ,eAAe;CAE3C,IAAI,YAAyD;CAE7D,MAAM,qBAAqB,OAAiB,aAAiC;EAC3E,QAAQ,GAAG,SAAoB;GAC7B,QAAQ,KAAK;IACX,SAAS,WAAW,IAAI;IACxB,2BAAW,IAAI,KAAK;IACpB;IACA,QAAQ,eAAe;GACzB,CAAC;GACD,IAAI,aACF,SAAS,MAAM,SAAS,IAAI;EAEhC;CACF;CAEA,OAAO;EACL,UAAU;GACR,OAAO,EAAE,SAAS,CAAC,GAAG,OAAO,EAAE;EACjC;EACA,QAAQ;GACN,IAAI,cAAc,MAEhB;GAEF,YAAY;IACV,KAAK,QAAQ;IACb,MAAM,QAAQ;IACd,OAAO,QAAQ;IACf,MAAM,QAAQ;IACd,OAAO,QAAQ;GACjB;GACA,KAAK,MAAM,SAAS,QAClB,QAAQ,SAAS,kBAAkB,OAAO,UAAU,MAAM;EAE9D;EACA,OAAO;GACL,IAAI,cAAc,MAChB;GAEF,KAAK,MAAM,SAAS,QAClB,QAAQ,SAAS,UAAU;GAE7B,YAAY;EACd;CACF;AACF;;;;AAKA,SAAgB,UAAU,GAAG,WAA2C;CACtE,OAAO,EACL,SAAS,UACN,SAAS,MAAM,EAAE,OAAO,CAAC,CACzB,MAAM,GAAG,MAAM,EAAE,UAAU,QAAQ,IAAI,EAAE,UAAU,QAAQ,CAAC,EACjE;AACF;;;;AAKA,SAAgB,YAA2B;CACzC,OAAO,EAAE,SAAS,CAAC,EAAE;AACvB"}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_prompt = require('../../prompt-Bs9e-Em3.cjs');
|
|
3
|
-
let _clack_prompts = require("@clack/prompts");
|
|
4
|
-
|
|
5
|
-
//#region src/prompt/clack/index.ts
|
|
6
|
-
function createClackAdapter() {
|
|
7
|
-
return {
|
|
8
|
-
text: (config) => (0, _clack_prompts.text)({
|
|
9
|
-
message: config.message,
|
|
10
|
-
...config.placeholder !== void 0 && { placeholder: config.placeholder }
|
|
11
|
-
}),
|
|
12
|
-
password: (config) => (0, _clack_prompts.password)(config),
|
|
13
|
-
confirm: (config) => (0, _clack_prompts.confirm)(config),
|
|
14
|
-
select: (config) => (0, _clack_prompts.select)(config),
|
|
15
|
-
isCancelled: _clack_prompts.isCancel
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Prompt resolver backed by @clack/prompts.
|
|
20
|
-
*
|
|
21
|
-
* @example
|
|
22
|
-
* ```ts
|
|
23
|
-
* import { runMain, defineCommand } from "politty";
|
|
24
|
-
* import { prompt } from "politty/prompt/clack";
|
|
25
|
-
*
|
|
26
|
-
* runMain(cmd, { version: "1.0.0", prompt });
|
|
27
|
-
* ```
|
|
28
|
-
*/
|
|
29
|
-
const prompt = (rawArgs, extracted) => require_prompt.promptMissingArgs(rawArgs, extracted, { adapter: createClackAdapter() });
|
|
30
|
-
|
|
31
|
-
//#endregion
|
|
32
|
-
exports.prompt = prompt;
|
|
33
|
-
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["isCancel","promptMissingArgs"],"sources":["../../../src/prompt/clack/index.ts"],"sourcesContent":["import { confirm, isCancel, password, select, text } from \"@clack/prompts\";\nimport type { PromptResolver } from \"../../types.js\";\nimport { promptMissingArgs } from \"../index.js\";\nimport type { PromptAdapter } from \"../types.js\";\n\nfunction createClackAdapter(): PromptAdapter {\n return {\n text: (config) =>\n text({\n message: config.message,\n ...(config.placeholder !== undefined && { placeholder: config.placeholder }),\n }),\n password: (config) => password(config),\n confirm: (config) => confirm(config),\n select: (config) => select(config),\n isCancelled: isCancel,\n };\n}\n\n/**\n * Prompt resolver backed by @clack/prompts.\n *\n * @example\n * ```ts\n * import { runMain, defineCommand } from \"politty\";\n * import { prompt } from \"politty/prompt/clack\";\n *\n * runMain(cmd, { version: \"1.0.0\", prompt });\n * ```\n */\nexport const prompt: PromptResolver = (rawArgs, extracted) =>\n promptMissingArgs(rawArgs, extracted, { adapter: createClackAdapter() });\n"],"mappings":";;;;;AAKA,SAAS,qBAAoC;CAC3C,OAAO;EACL,OAAO,oCACA;GACH,SAAS,OAAO;GAChB,GAAI,OAAO,gBAAgB,UAAa,EAAE,aAAa,OAAO,YAAY;EAC5E,CAAC;EACH,WAAW,wCAAoB,MAAM;EACrC,UAAU,uCAAmB,MAAM;EACnC,SAAS,sCAAkB,MAAM;EACjC,aAAaA;CACf;AACF;;;;;;;;;;;;AAaA,MAAa,UAA0B,SAAS,cAC9CC,iCAAkB,SAAS,WAAW,EAAE,SAAS,mBAAmB,EAAE,CAAC"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { P as PromptResolver } from "../../arg-registry-DDJpsUea.cjs";
|
|
2
|
-
|
|
3
|
-
//#region src/prompt/clack/index.d.ts
|
|
4
|
-
/**
|
|
5
|
-
* Prompt resolver backed by @clack/prompts.
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* ```ts
|
|
9
|
-
* import { runMain, defineCommand } from "politty";
|
|
10
|
-
* import { prompt } from "politty/prompt/clack";
|
|
11
|
-
*
|
|
12
|
-
* runMain(cmd, { version: "1.0.0", prompt });
|
|
13
|
-
* ```
|
|
14
|
-
*/
|
|
15
|
-
declare const prompt: PromptResolver;
|
|
16
|
-
//#endregion
|
|
17
|
-
export { prompt };
|
|
18
|
-
//# sourceMappingURL=index.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../../../src/prompt/clack/index.ts"],"mappings":";;;;;AA8BA;;;;AAC0E;;;;;cAD7D,MAAA,EAAQ,cACqD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/prompt/clack/index.ts"],"mappings":";;;;;AA8BA;;;;AAC0E;;;;;cAD7D,MAAA,EAAQ,cACqD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/prompt/clack/index.ts"],"sourcesContent":["import { confirm, isCancel, password, select, text } from \"@clack/prompts\";\nimport type { PromptResolver } from \"../../types.js\";\nimport { promptMissingArgs } from \"../index.js\";\nimport type { PromptAdapter } from \"../types.js\";\n\nfunction createClackAdapter(): PromptAdapter {\n return {\n text: (config) =>\n text({\n message: config.message,\n ...(config.placeholder !== undefined && { placeholder: config.placeholder }),\n }),\n password: (config) => password(config),\n confirm: (config) => confirm(config),\n select: (config) => select(config),\n isCancelled: isCancel,\n };\n}\n\n/**\n * Prompt resolver backed by @clack/prompts.\n *\n * @example\n * ```ts\n * import { runMain, defineCommand } from \"politty\";\n * import { prompt } from \"politty/prompt/clack\";\n *\n * runMain(cmd, { version: \"1.0.0\", prompt });\n * ```\n */\nexport const prompt: PromptResolver = (rawArgs, extracted) =>\n promptMissingArgs(rawArgs, extracted, { adapter: createClackAdapter() });\n"],"mappings":";;;;AAKA,SAAS,qBAAoC;CAC3C,OAAO;EACL,OAAO,WACL,KAAK;GACH,SAAS,OAAO;GAChB,GAAI,OAAO,gBAAgB,UAAa,EAAE,aAAa,OAAO,YAAY;EAC5E,CAAC;EACH,WAAW,WAAW,SAAS,MAAM;EACrC,UAAU,WAAW,QAAQ,MAAM;EACnC,SAAS,WAAW,OAAO,MAAM;EACjC,aAAa;CACf;AACF;;;;;;;;;;;;AAaA,MAAa,UAA0B,SAAS,cAC9C,kBAAkB,SAAS,WAAW,EAAE,SAAS,mBAAmB,EAAE,CAAC"}
|
package/dist/prompt/index.cjs
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_prompt = require('../prompt-Bs9e-Em3.cjs');
|
|
3
|
-
|
|
4
|
-
exports.getFieldsToPrompt = require_prompt.getFieldsToPrompt;
|
|
5
|
-
exports.isInteractive = require_prompt.isInteractive;
|
|
6
|
-
exports.promptMissingArgs = require_prompt.promptMissingArgs;
|
|
7
|
-
exports.resolvePromptConfig = require_prompt.resolvePromptConfig;
|
package/dist/prompt/index.d.cts
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import { J as ResolvedFieldMeta, q as ExtractedFields } from "../arg-registry-DDJpsUea.cjs";
|
|
2
|
-
|
|
3
|
-
//#region src/prompt/types.d.ts
|
|
4
|
-
/**
|
|
5
|
-
* Resolved prompt configuration for a single field
|
|
6
|
-
*/
|
|
7
|
-
interface ResolvedPromptConfig {
|
|
8
|
-
/** Field metadata */
|
|
9
|
-
field: ResolvedFieldMeta;
|
|
10
|
-
/** Resolved prompt type */
|
|
11
|
-
type: "text" | "password" | "confirm" | "select";
|
|
12
|
-
/** Message to display to the user */
|
|
13
|
-
message: string;
|
|
14
|
-
/** Choices for select prompts */
|
|
15
|
-
choices?: Array<{
|
|
16
|
-
label: string;
|
|
17
|
-
value: string;
|
|
18
|
-
}>;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Adapter interface for prompt rendering.
|
|
22
|
-
* Implement this to use a custom prompt library instead of the default @clack/prompts.
|
|
23
|
-
*/
|
|
24
|
-
interface PromptAdapter {
|
|
25
|
-
/** Prompt for free-form text input */
|
|
26
|
-
text(config: {
|
|
27
|
-
message: string;
|
|
28
|
-
placeholder?: string | undefined;
|
|
29
|
-
}): Promise<string | symbol>;
|
|
30
|
-
/** Prompt for masked text input */
|
|
31
|
-
password(config: {
|
|
32
|
-
message: string;
|
|
33
|
-
}): Promise<string | symbol>;
|
|
34
|
-
/** Prompt for yes/no confirmation */
|
|
35
|
-
confirm(config: {
|
|
36
|
-
message: string;
|
|
37
|
-
}): Promise<boolean | symbol>;
|
|
38
|
-
/** Prompt for single selection from options */
|
|
39
|
-
select(config: {
|
|
40
|
-
message: string;
|
|
41
|
-
options: Array<{
|
|
42
|
-
label: string;
|
|
43
|
-
value: string;
|
|
44
|
-
}>;
|
|
45
|
-
}): Promise<string | symbol>;
|
|
46
|
-
/** Check if a prompt result indicates user cancellation */
|
|
47
|
-
isCancelled(value: unknown): boolean;
|
|
48
|
-
}
|
|
49
|
-
//#endregion
|
|
50
|
-
//#region src/prompt/prompt-resolver.d.ts
|
|
51
|
-
/**
|
|
52
|
-
* Resolve prompt configuration for a field.
|
|
53
|
-
*
|
|
54
|
-
* Priority for prompt type:
|
|
55
|
-
* 1. Explicit type from prompt.type
|
|
56
|
-
* 2. Explicit choices from prompt.choices (forces "select")
|
|
57
|
-
* 3. Inherited from completion metadata (file/directory -> "text")
|
|
58
|
-
* 4. Auto-detected from Zod schema type:
|
|
59
|
-
* - enum (has enumValues) -> "select"
|
|
60
|
-
* - boolean -> "confirm"
|
|
61
|
-
* - string/number/unknown -> "text"
|
|
62
|
-
*
|
|
63
|
-
* Returns null if the field has no prompt metadata or prompting is disabled.
|
|
64
|
-
*/
|
|
65
|
-
declare function resolvePromptConfig(field: ResolvedFieldMeta): ResolvedPromptConfig | null;
|
|
66
|
-
/**
|
|
67
|
-
* Filter fields that need prompting (missing value + prompt configured).
|
|
68
|
-
*
|
|
69
|
-
* For discriminatedUnion schemas, variant-aware narrowing is handled by the
|
|
70
|
-
* caller (promptMissingArgs) which prompts the discriminator first and then
|
|
71
|
-
* passes only the active variant's fields. For plain union schemas, this
|
|
72
|
-
* iterates all fields across every variant without narrowing.
|
|
73
|
-
*
|
|
74
|
-
* Fields with Zod defaults that also have prompt metadata will be prompted
|
|
75
|
-
* when the raw value is undefined. This is intentional: `prompt: {}` is an
|
|
76
|
-
* explicit opt-in to interactive input. Omit prompt metadata to let the
|
|
77
|
-
* default apply silently.
|
|
78
|
-
*/
|
|
79
|
-
declare function getFieldsToPrompt(fields: ResolvedFieldMeta[], rawArgs: Record<string, unknown>): ResolvedPromptConfig[];
|
|
80
|
-
//#endregion
|
|
81
|
-
//#region src/prompt/tty-detector.d.ts
|
|
82
|
-
/**
|
|
83
|
-
* Detect whether the current environment supports interactive prompts.
|
|
84
|
-
* Returns false in CI, piped input, or non-TTY environments.
|
|
85
|
-
*/
|
|
86
|
-
declare function isInteractive(): boolean;
|
|
87
|
-
//#endregion
|
|
88
|
-
//#region src/prompt/index.d.ts
|
|
89
|
-
/**
|
|
90
|
-
* Options for promptMissingArgs behavior
|
|
91
|
-
*/
|
|
92
|
-
interface PromptOptions {
|
|
93
|
-
/** Prompt adapter to use for rendering prompts */
|
|
94
|
-
adapter: PromptAdapter;
|
|
95
|
-
/** Override interactive detection (force enable/disable prompts) */
|
|
96
|
-
interactive?: boolean;
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Prompt for missing argument values interactively.
|
|
100
|
-
*
|
|
101
|
-
* Only prompts for fields that have `prompt` metadata set via `arg()` and
|
|
102
|
-
* whose values are still undefined after CLI and env resolution.
|
|
103
|
-
* Returns rawArgs unchanged in non-interactive environments.
|
|
104
|
-
*/
|
|
105
|
-
declare function promptMissingArgs(rawArgs: Record<string, unknown>, extracted: ExtractedFields, options: PromptOptions): Promise<Record<string, unknown>>;
|
|
106
|
-
//#endregion
|
|
107
|
-
export { type PromptAdapter, PromptOptions, type ResolvedPromptConfig, getFieldsToPrompt, isInteractive, promptMissingArgs, resolvePromptConfig };
|
|
108
|
-
//# sourceMappingURL=index.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../../src/prompt/types.ts","../../src/prompt/prompt-resolver.ts","../../src/prompt/tty-detector.ts","../../src/prompt/index.ts"],"mappings":";;;;;AAKA;UAAiB,oBAAA;;EAEf,KAAA,EAAO,iBAAA;EAAP;EAEA,IAAA;EAAA;EAEA,OAAA;EAEA;EAAA,OAAA,GAAU,KAAK;IAAG,KAAA;IAAe,KAAA;EAAA;AAAA;AAOnC;;;;AAAA,UAAiB,aAAA;EAMuB;EAJtC,IAAA,CAAK,MAAA;IAAU,OAAA;IAAiB,WAAA;EAAA,IAAqC,OAAA;EAArE;EAEA,QAAA,CAAS,MAAA;IAAU,OAAA;EAAA,IAAoB,OAAA;EAF8B;EAIrE,OAAA,CAAQ,MAAA;IAAU,OAAA;EAAA,IAAoB,OAAA;EAFC;EAIvC,MAAA,CAAO,MAAA;IACL,OAAA;IACA,OAAA,EAAS,KAAA;MAAQ,KAAA;MAAe,KAAA;IAAA;EAAA,IAC9B,OAAA;EADO;EAGX,WAAA,CAAY,KAAA;AAAA;;;;AA5Bd;;;;;;;;;;;;;iBCYgB,mBAAA,CAAoB,KAAA,EAAO,iBAAA,GAAoB,oBAAoB;ADGnF;;;;;;;;;;;;;AAAA,iBC+DgB,iBAAA,CACd,MAAA,EAAQ,iBAAA,IACR,OAAA,EAAS,MAAA,oBACR,oBAAA;;;;;;ADjFH;iBEDgB,aAAA;;;;;;UCQC,aAAA;EHHf;EGKA,OAAA,EAAS,aAAa;EHDtB;EGGA,WAAA;AAAA;;;AHHsC;AAOxC;;;;iBGMsB,iBAAA,CACpB,OAAA,EAAS,MAAA,mBACT,SAAA,EAAW,eAAA,EACX,OAAA,EAAS,aAAA,GACR,OAAA,CAAQ,MAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/prompt/types.ts","../../src/prompt/prompt-resolver.ts","../../src/prompt/tty-detector.ts","../../src/prompt/index.ts"],"mappings":";;;;;AAKA;UAAiB,oBAAA;;EAEf,KAAA,EAAO,iBAAA;EAAP;EAEA,IAAA;EAAA;EAEA,OAAA;EAEA;EAAA,OAAA,GAAU,KAAK;IAAG,KAAA;IAAe,KAAA;EAAA;AAAA;AAOnC;;;;AAAA,UAAiB,aAAA;EAMuB;EAJtC,IAAA,CAAK,MAAA;IAAU,OAAA;IAAiB,WAAA;EAAA,IAAqC,OAAA;EAArE;EAEA,QAAA,CAAS,MAAA;IAAU,OAAA;EAAA,IAAoB,OAAA;EAF8B;EAIrE,OAAA,CAAQ,MAAA;IAAU,OAAA;EAAA,IAAoB,OAAA;EAFC;EAIvC,MAAA,CAAO,MAAA;IACL,OAAA;IACA,OAAA,EAAS,KAAA;MAAQ,KAAA;MAAe,KAAA;IAAA;EAAA,IAC9B,OAAA;EADO;EAGX,WAAA,CAAY,KAAA;AAAA;;;;AA5Bd;;;;;;;;;;;;;iBCYgB,mBAAA,CAAoB,KAAA,EAAO,iBAAA,GAAoB,oBAAoB;ADGnF;;;;;;;;;;;;;AAAA,iBC+DgB,iBAAA,CACd,MAAA,EAAQ,iBAAA,IACR,OAAA,EAAS,MAAA,oBACR,oBAAA;;;;;;ADjFH;iBEDgB,aAAA;;;;;;UCQC,aAAA;EHHf;EGKA,OAAA,EAAS,aAAa;EHDtB;EGGA,WAAA;AAAA;;;AHHsC;AAOxC;;;;iBGMsB,iBAAA,CACpB,OAAA,EAAS,MAAA,mBACT,SAAA,EAAW,eAAA,EACX,OAAA,EAAS,aAAA,GACR,OAAA,CAAQ,MAAA"}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_prompt = require('../../prompt-Bs9e-Em3.cjs');
|
|
3
|
-
let _inquirer_prompts = require("@inquirer/prompts");
|
|
4
|
-
|
|
5
|
-
//#region src/prompt/inquirer/index.ts
|
|
6
|
-
const cancelSymbol = Symbol("inquirer-cancel");
|
|
7
|
-
async function wrapCancellation(fn) {
|
|
8
|
-
try {
|
|
9
|
-
return await fn();
|
|
10
|
-
} catch (error) {
|
|
11
|
-
if (error instanceof Error && error.name === "ExitPromptError") return cancelSymbol;
|
|
12
|
-
throw error;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
function createInquirerAdapter() {
|
|
16
|
-
return {
|
|
17
|
-
text: (config) => wrapCancellation(() => (0, _inquirer_prompts.input)({
|
|
18
|
-
message: config.message,
|
|
19
|
-
...config.placeholder !== void 0 && { default: config.placeholder }
|
|
20
|
-
})),
|
|
21
|
-
password: (config) => wrapCancellation(() => (0, _inquirer_prompts.password)({ message: config.message })),
|
|
22
|
-
confirm: (config) => wrapCancellation(() => (0, _inquirer_prompts.confirm)({ message: config.message })),
|
|
23
|
-
select: (config) => wrapCancellation(() => (0, _inquirer_prompts.select)({
|
|
24
|
-
message: config.message,
|
|
25
|
-
choices: config.options.map((o) => ({
|
|
26
|
-
name: o.label,
|
|
27
|
-
value: o.value
|
|
28
|
-
}))
|
|
29
|
-
})),
|
|
30
|
-
isCancelled: (value) => value === cancelSymbol
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Prompt resolver backed by @inquirer/prompts.
|
|
35
|
-
*
|
|
36
|
-
* @example
|
|
37
|
-
* ```ts
|
|
38
|
-
* import { runMain, defineCommand } from "politty";
|
|
39
|
-
* import { prompt } from "politty/prompt/inquirer";
|
|
40
|
-
*
|
|
41
|
-
* runMain(cmd, { version: "1.0.0", prompt });
|
|
42
|
-
* ```
|
|
43
|
-
*/
|
|
44
|
-
const prompt = (rawArgs, extracted) => require_prompt.promptMissingArgs(rawArgs, extracted, { adapter: createInquirerAdapter() });
|
|
45
|
-
|
|
46
|
-
//#endregion
|
|
47
|
-
exports.prompt = prompt;
|
|
48
|
-
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["promptMissingArgs"],"sources":["../../../src/prompt/inquirer/index.ts"],"sourcesContent":["import { confirm, input, password, select } from \"@inquirer/prompts\";\nimport type { PromptResolver } from \"../../types.js\";\nimport { promptMissingArgs } from \"../index.js\";\nimport type { PromptAdapter } from \"../types.js\";\n\nconst cancelSymbol = Symbol(\"inquirer-cancel\");\n\nasync function wrapCancellation<T>(fn: () => Promise<T>): Promise<T | symbol> {\n try {\n return await fn();\n } catch (error) {\n if (error instanceof Error && error.name === \"ExitPromptError\") {\n return cancelSymbol;\n }\n throw error;\n }\n}\n\nfunction createInquirerAdapter(): PromptAdapter {\n return {\n text: (config) =>\n wrapCancellation(() =>\n input({\n message: config.message,\n ...(config.placeholder !== undefined && { default: config.placeholder }),\n }),\n ),\n password: (config) => wrapCancellation(() => password({ message: config.message })),\n confirm: (config) => wrapCancellation(() => confirm({ message: config.message })),\n select: (config) =>\n wrapCancellation(() =>\n select({\n message: config.message,\n choices: config.options.map((o) => ({ name: o.label, value: o.value })),\n }),\n ),\n isCancelled: (value) => value === cancelSymbol,\n };\n}\n\n/**\n * Prompt resolver backed by @inquirer/prompts.\n *\n * @example\n * ```ts\n * import { runMain, defineCommand } from \"politty\";\n * import { prompt } from \"politty/prompt/inquirer\";\n *\n * runMain(cmd, { version: \"1.0.0\", prompt });\n * ```\n */\nexport const prompt: PromptResolver = (rawArgs, extracted) =>\n promptMissingArgs(rawArgs, extracted, { adapter: createInquirerAdapter() });\n"],"mappings":";;;;;AAKA,MAAM,eAAe,OAAO,iBAAiB;AAE7C,eAAe,iBAAoB,IAA2C;CAC5E,IAAI;EACF,OAAO,MAAM,GAAG;CAClB,SAAS,OAAO;EACd,IAAI,iBAAiB,SAAS,MAAM,SAAS,mBAC3C,OAAO;EAET,MAAM;CACR;AACF;AAEA,SAAS,wBAAuC;CAC9C,OAAO;EACL,OAAO,WACL,oDACQ;GACJ,SAAS,OAAO;GAChB,GAAI,OAAO,gBAAgB,UAAa,EAAE,SAAS,OAAO,YAAY;EACxE,CAAC,CACH;EACF,WAAW,WAAW,uDAAgC,EAAE,SAAS,OAAO,QAAQ,CAAC,CAAC;EAClF,UAAU,WAAW,sDAA+B,EAAE,SAAS,OAAO,QAAQ,CAAC,CAAC;EAChF,SAAS,WACP,qDACS;GACL,SAAS,OAAO;GAChB,SAAS,OAAO,QAAQ,KAAK,OAAO;IAAE,MAAM,EAAE;IAAO,OAAO,EAAE;GAAM,EAAE;EACxE,CAAC,CACH;EACF,cAAc,UAAU,UAAU;CACpC;AACF;;;;;;;;;;;;AAaA,MAAa,UAA0B,SAAS,cAC9CA,iCAAkB,SAAS,WAAW,EAAE,SAAS,sBAAsB,EAAE,CAAC"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { P as PromptResolver } from "../../arg-registry-DDJpsUea.cjs";
|
|
2
|
-
|
|
3
|
-
//#region src/prompt/inquirer/index.d.ts
|
|
4
|
-
/**
|
|
5
|
-
* Prompt resolver backed by @inquirer/prompts.
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* ```ts
|
|
9
|
-
* import { runMain, defineCommand } from "politty";
|
|
10
|
-
* import { prompt } from "politty/prompt/inquirer";
|
|
11
|
-
*
|
|
12
|
-
* runMain(cmd, { version: "1.0.0", prompt });
|
|
13
|
-
* ```
|
|
14
|
-
*/
|
|
15
|
-
declare const prompt: PromptResolver;
|
|
16
|
-
//#endregion
|
|
17
|
-
export { prompt };
|
|
18
|
-
//# sourceMappingURL=index.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../../../src/prompt/inquirer/index.ts"],"mappings":";;;;;AAmDA;;;;AAC6E;;;;;cADhE,MAAA,EAAQ,cACwD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/prompt/inquirer/index.ts"],"mappings":";;;;;AAmDA;;;;AAC6E;;;;;cADhE,MAAA,EAAQ,cACwD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/prompt/inquirer/index.ts"],"sourcesContent":["import { confirm, input, password, select } from \"@inquirer/prompts\";\nimport type { PromptResolver } from \"../../types.js\";\nimport { promptMissingArgs } from \"../index.js\";\nimport type { PromptAdapter } from \"../types.js\";\n\nconst cancelSymbol = Symbol(\"inquirer-cancel\");\n\nasync function wrapCancellation<T>(fn: () => Promise<T>): Promise<T | symbol> {\n try {\n return await fn();\n } catch (error) {\n if (error instanceof Error && error.name === \"ExitPromptError\") {\n return cancelSymbol;\n }\n throw error;\n }\n}\n\nfunction createInquirerAdapter(): PromptAdapter {\n return {\n text: (config) =>\n wrapCancellation(() =>\n input({\n message: config.message,\n ...(config.placeholder !== undefined && { default: config.placeholder }),\n }),\n ),\n password: (config) => wrapCancellation(() => password({ message: config.message })),\n confirm: (config) => wrapCancellation(() => confirm({ message: config.message })),\n select: (config) =>\n wrapCancellation(() =>\n select({\n message: config.message,\n choices: config.options.map((o) => ({ name: o.label, value: o.value })),\n }),\n ),\n isCancelled: (value) => value === cancelSymbol,\n };\n}\n\n/**\n * Prompt resolver backed by @inquirer/prompts.\n *\n * @example\n * ```ts\n * import { runMain, defineCommand } from \"politty\";\n * import { prompt } from \"politty/prompt/inquirer\";\n *\n * runMain(cmd, { version: \"1.0.0\", prompt });\n * ```\n */\nexport const prompt: PromptResolver = (rawArgs, extracted) =>\n promptMissingArgs(rawArgs, extracted, { adapter: createInquirerAdapter() });\n"],"mappings":";;;;AAKA,MAAM,eAAe,OAAO,iBAAiB;AAE7C,eAAe,iBAAoB,IAA2C;CAC5E,IAAI;EACF,OAAO,MAAM,GAAG;CAClB,SAAS,OAAO;EACd,IAAI,iBAAiB,SAAS,MAAM,SAAS,mBAC3C,OAAO;EAET,MAAM;CACR;AACF;AAEA,SAAS,wBAAuC;CAC9C,OAAO;EACL,OAAO,WACL,uBACE,MAAM;GACJ,SAAS,OAAO;GAChB,GAAI,OAAO,gBAAgB,UAAa,EAAE,SAAS,OAAO,YAAY;EACxE,CAAC,CACH;EACF,WAAW,WAAW,uBAAuB,SAAS,EAAE,SAAS,OAAO,QAAQ,CAAC,CAAC;EAClF,UAAU,WAAW,uBAAuB,QAAQ,EAAE,SAAS,OAAO,QAAQ,CAAC,CAAC;EAChF,SAAS,WACP,uBACE,OAAO;GACL,SAAS,OAAO;GAChB,SAAS,OAAO,QAAQ,KAAK,OAAO;IAAE,MAAM,EAAE;IAAO,OAAO,EAAE;GAAM,EAAE;EACxE,CAAC,CACH;EACF,cAAc,UAAU,UAAU;CACpC;AACF;;;;;;;;;;;;AAaA,MAAa,UAA0B,SAAS,cAC9C,kBAAkB,SAAS,WAAW,EAAE,SAAS,sBAAsB,EAAE,CAAC"}
|