politty 0.4.15 → 0.5.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/{arg-registry-Dw0f11Zc.d.ts → arg-registry--NRaNFJM.d.cts} +238 -6
- package/dist/arg-registry--NRaNFJM.d.cts.map +1 -0
- package/dist/{arg-registry-CB5gGtzp.d.cts → arg-registry-6E0WHOh_.d.ts} +238 -6
- package/dist/arg-registry-6E0WHOh_.d.ts.map +1 -0
- package/dist/augment.d.cts +1 -1
- package/dist/augment.d.cts.map +1 -1
- package/dist/augment.d.ts +1 -1
- package/dist/augment.d.ts.map +1 -1
- package/dist/completion/index.cjs +2 -1
- package/dist/completion/index.d.cts +3 -2
- package/dist/completion/index.d.ts +3 -2
- package/dist/completion/index.js +2 -2
- package/dist/completion-BA5JMvVG.js +4067 -0
- package/dist/completion-BA5JMvVG.js.map +1 -0
- package/dist/completion-Cqs1Ja7C.cjs +4169 -0
- package/dist/completion-Cqs1Ja7C.cjs.map +1 -0
- package/dist/docs/index.cjs +89 -29
- package/dist/docs/index.cjs.map +1 -1
- package/dist/docs/index.d.cts +1 -1
- package/dist/docs/index.d.cts.map +1 -1
- package/dist/docs/index.d.ts +1 -1
- package/dist/docs/index.d.ts.map +1 -1
- package/dist/docs/index.js +92 -31
- package/dist/docs/index.js.map +1 -1
- package/dist/{index-C1gGgUeB.d.cts → index-DBMfKZ34.d.ts} +189 -17
- package/dist/index-DBMfKZ34.d.ts.map +1 -0
- package/dist/{index-Dg9Fpz0R.d.ts → index-DJp8k5Bq.d.cts} +189 -17
- package/dist/index-DJp8k5Bq.d.cts.map +1 -0
- package/dist/index.cjs +12 -10
- package/dist/index.d.cts +36 -4
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +36 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -4
- package/dist/log-collector-Cd2_mv87.cjs.map +1 -1
- package/dist/log-collector-Cu6MCtAx.js.map +1 -1
- package/dist/prompt/clack/index.cjs.map +1 -1
- package/dist/prompt/clack/index.d.cts +1 -1
- package/dist/prompt/clack/index.d.cts.map +1 -1
- package/dist/prompt/clack/index.d.ts +1 -1
- package/dist/prompt/clack/index.d.ts.map +1 -1
- package/dist/prompt/clack/index.js.map +1 -1
- package/dist/prompt/index.d.cts +1 -1
- package/dist/prompt/index.d.cts.map +1 -1
- package/dist/prompt/index.d.ts +1 -1
- package/dist/prompt/index.d.ts.map +1 -1
- package/dist/prompt/inquirer/index.cjs.map +1 -1
- package/dist/prompt/inquirer/index.d.cts +1 -1
- package/dist/prompt/inquirer/index.d.cts.map +1 -1
- package/dist/prompt/inquirer/index.d.ts +1 -1
- package/dist/prompt/inquirer/index.d.ts.map +1 -1
- package/dist/prompt/inquirer/index.js.map +1 -1
- package/dist/prompt-BKHqGrFw.js.map +1 -1
- package/dist/prompt-aXfSf27y.cjs.map +1 -1
- package/dist/{runner-DKAQBNNh.js → runner-BmSEiD9A.js} +319 -52
- package/dist/runner-BmSEiD9A.js.map +1 -0
- package/dist/{runner-CriXJlm4.cjs → runner-CRZ_7Y9i.cjs} +366 -87
- package/dist/runner-CRZ_7Y9i.cjs.map +1 -0
- package/dist/{subcommand-router-ENeCymvX.js → schema-extractor-C50R-1re.js} +175 -137
- package/dist/schema-extractor-C50R-1re.js.map +1 -0
- package/dist/{subcommand-router-CqZX3orq.cjs → schema-extractor-SLPgBNgZ.cjs} +174 -136
- package/dist/schema-extractor-SLPgBNgZ.cjs.map +1 -0
- package/package.json +16 -16
- package/dist/arg-registry-CB5gGtzp.d.cts.map +0 -1
- package/dist/arg-registry-Dw0f11Zc.d.ts.map +0 -1
- package/dist/completion-B5fgnUGm.cjs +0 -1940
- package/dist/completion-B5fgnUGm.cjs.map +0 -1
- package/dist/completion-Ca5ESJlG.js +0 -1844
- package/dist/completion-Ca5ESJlG.js.map +0 -1
- package/dist/index-C1gGgUeB.d.cts.map +0 -1
- package/dist/index-Dg9Fpz0R.d.ts.map +0 -1
- package/dist/runner-CriXJlm4.cjs.map +0 -1
- package/dist/runner-DKAQBNNh.js.map +0 -1
- package/dist/subcommand-router-CqZX3orq.cjs.map +0 -1
- package/dist/subcommand-router-ENeCymvX.js.map +0 -1
package/dist/docs/index.cjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
const require_log_collector = require('../log-collector-Cd2_mv87.cjs');
|
|
3
|
-
const
|
|
3
|
+
const require_schema_extractor = require('../schema-extractor-SLPgBNgZ.cjs');
|
|
4
4
|
let zod = require("zod");
|
|
5
|
-
let node_util = require("node:util");
|
|
6
5
|
let node_fs = require("node:fs");
|
|
7
6
|
node_fs = require_log_collector.__toESM(node_fs, 1);
|
|
8
7
|
let node_path = require("node:path");
|
|
9
8
|
node_path = require_log_collector.__toESM(node_path, 1);
|
|
9
|
+
let node_util = require("node:util");
|
|
10
10
|
|
|
11
11
|
//#region src/docs/types.ts
|
|
12
12
|
/**
|
|
@@ -114,6 +114,13 @@ function escapeTableCell$2(str) {
|
|
|
114
114
|
return str.replace(/\|/g, "\\|").replace(/\n/g, " ");
|
|
115
115
|
}
|
|
116
116
|
/**
|
|
117
|
+
* Marker appended to a custom negation row/line so readers can see which
|
|
118
|
+
* positive flag it negates (e.g. `--monochrome` → `(↔ \`--color\`)`).
|
|
119
|
+
*/
|
|
120
|
+
function negationRelationMarker(opt) {
|
|
121
|
+
return `(↔ \`--${opt.cliName}\`)`;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
117
124
|
* Format default value for display
|
|
118
125
|
*/
|
|
119
126
|
function formatDefaultValue$1(value) {
|
|
@@ -174,25 +181,39 @@ function resolvePlaceholder(opt) {
|
|
|
174
181
|
}
|
|
175
182
|
/**
|
|
176
183
|
* Format option name for table display (e.g., `--dry-run` or `--port <PORT>`)
|
|
184
|
+
*
|
|
185
|
+
* Boolean fields with a custom inline `negation` (no separate description) are
|
|
186
|
+
* shown as `\`--cache\` / \`--disable-cache\``.
|
|
177
187
|
*/
|
|
178
188
|
function formatOptionName(opt) {
|
|
179
189
|
const placeholder = resolvePlaceholder(opt);
|
|
180
|
-
|
|
190
|
+
if (opt.type === "boolean") {
|
|
191
|
+
const positive = `\`--${opt.cliName}\``;
|
|
192
|
+
if (opt.negationDisplay && !opt.negationDescription) return `${positive} / \`--${opt.negationDisplay}\``;
|
|
193
|
+
return positive;
|
|
194
|
+
}
|
|
195
|
+
return `\`--${opt.cliName} <${placeholder}>\``;
|
|
181
196
|
}
|
|
182
197
|
/**
|
|
183
|
-
* Format option flags for list display (uses kebab-case cliName)
|
|
198
|
+
* Format option flags for list display (uses kebab-case cliName).
|
|
199
|
+
* Aliases are joined with `, `; the inline negation (when no separate
|
|
200
|
+
* `negationDescription` is set) is appended with ` / ` so it stays
|
|
201
|
+
* visually distinct from aliases, matching help and table output.
|
|
184
202
|
*/
|
|
185
203
|
function formatOptionFlags(opt) {
|
|
186
204
|
const placeholder = resolvePlaceholder(opt);
|
|
187
205
|
const longFlag = opt.type === "boolean" ? `--${opt.cliName}` : `--${opt.cliName} <${placeholder}>`;
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
206
|
+
const parts = [];
|
|
207
|
+
if (opt.alias) {
|
|
208
|
+
for (const a of opt.alias) if (a.length === 1) parts.push(`\`-${a}\``);
|
|
209
|
+
}
|
|
210
|
+
parts.push(`\`${longFlag}\``);
|
|
211
|
+
if (opt.alias) {
|
|
212
|
+
for (const a of opt.alias) if (a.length > 1) parts.push(`\`--${a}\``);
|
|
213
|
+
}
|
|
214
|
+
const aliasJoined = parts.join(", ");
|
|
215
|
+
if (opt.type === "boolean" && opt.negationDisplay && !opt.negationDescription) return `${aliasJoined} / \`--${opt.negationDisplay}\``;
|
|
216
|
+
return aliasJoined;
|
|
196
217
|
}
|
|
197
218
|
/**
|
|
198
219
|
* Format aliases for a markdown table cell
|
|
@@ -244,6 +265,12 @@ function renderOptionsTable(info) {
|
|
|
244
265
|
const envNames = formatEnvNames(opt.env);
|
|
245
266
|
lines.push(`| ${optionName} | ${alias} | ${desc} | ${required} | ${defaultVal} | ${envNames} |`);
|
|
246
267
|
} else lines.push(`| ${optionName} | ${alias} | ${desc} | ${required} | ${defaultVal} |`);
|
|
268
|
+
if (opt.type === "boolean" && opt.negationDisplay && opt.negationDescription) {
|
|
269
|
+
const negName = `\`--${opt.negationDisplay}\``;
|
|
270
|
+
const negDesc = `${escapeTableCell$2(opt.negationDescription)} ${negationRelationMarker(opt)}`;
|
|
271
|
+
if (hasEnv) lines.push(`| ${negName} | - | ${negDesc} | ${required} | - | - |`);
|
|
272
|
+
else lines.push(`| ${negName} | - | ${negDesc} | ${required} | - |`);
|
|
273
|
+
}
|
|
247
274
|
}
|
|
248
275
|
return lines.join("\n");
|
|
249
276
|
}
|
|
@@ -268,6 +295,7 @@ function renderOptionsList(info) {
|
|
|
268
295
|
const defaultVal = opt.defaultValue !== void 0 ? ` (default: ${JSON.stringify(opt.defaultValue)})` : "";
|
|
269
296
|
const envInfo = formatEnvInfo(opt.env);
|
|
270
297
|
lines.push(`- ${flags}${desc}${required}${defaultVal}${envInfo}`);
|
|
298
|
+
if (opt.type === "boolean" && opt.negationDisplay && opt.negationDescription) lines.push(`- \`--${opt.negationDisplay}\` - ${opt.negationDescription} ${negationRelationMarker(opt)}`);
|
|
271
299
|
}
|
|
272
300
|
return lines.join("\n");
|
|
273
301
|
}
|
|
@@ -278,15 +306,13 @@ function generateAnchor$1(commandPath) {
|
|
|
278
306
|
return commandPath.join("-").toLowerCase();
|
|
279
307
|
}
|
|
280
308
|
/**
|
|
281
|
-
* Generate relative path from one file to another
|
|
309
|
+
* Generate relative path from one file to another.
|
|
310
|
+
* Always emits forward slashes so Markdown links remain portable across OSes.
|
|
282
311
|
*/
|
|
283
312
|
function getRelativePath(from, to) {
|
|
284
|
-
const
|
|
285
|
-
const
|
|
286
|
-
|
|
287
|
-
while (commonLength < fromParts.length && commonLength < toParts.length - 1 && fromParts[commonLength] === toParts[commonLength]) commonLength++;
|
|
288
|
-
const upCount = fromParts.length - commonLength;
|
|
289
|
-
return [...Array(upCount).fill(".."), ...toParts.slice(commonLength)].join("/") || (toParts[toParts.length - 1] ?? "");
|
|
313
|
+
const fromPosix = from.replace(/\\/g, "/");
|
|
314
|
+
const toPosix = to.replace(/\\/g, "/");
|
|
315
|
+
return node_path.default.posix.relative(node_path.default.posix.dirname(fromPosix), toPosix);
|
|
290
316
|
}
|
|
291
317
|
/**
|
|
292
318
|
* Render subcommands as table
|
|
@@ -318,6 +344,12 @@ function renderOptionsTableFromArray(options) {
|
|
|
318
344
|
const envNames = formatEnvNames(opt.env);
|
|
319
345
|
lines.push(`| ${optionName} | ${alias} | ${desc} | ${required} | ${defaultVal} | ${envNames} |`);
|
|
320
346
|
} else lines.push(`| ${optionName} | ${alias} | ${desc} | ${required} | ${defaultVal} |`);
|
|
347
|
+
if (opt.type === "boolean" && opt.negationDisplay && opt.negationDescription) {
|
|
348
|
+
const negName = `\`--${opt.negationDisplay}\``;
|
|
349
|
+
const negDesc = `${escapeTableCell$2(opt.negationDescription)} ${negationRelationMarker(opt)}`;
|
|
350
|
+
if (hasEnv) lines.push(`| ${negName} | - | ${negDesc} | ${required} | - | - |`);
|
|
351
|
+
else lines.push(`| ${negName} | - | ${negDesc} | ${required} | - |`);
|
|
352
|
+
}
|
|
321
353
|
}
|
|
322
354
|
return lines.join("\n");
|
|
323
355
|
}
|
|
@@ -399,6 +431,7 @@ function renderOptionsListFromArray(options) {
|
|
|
399
431
|
const defaultVal = opt.defaultValue !== void 0 ? ` (default: ${JSON.stringify(opt.defaultValue)})` : "";
|
|
400
432
|
const envInfo = formatEnvInfo(opt.env);
|
|
401
433
|
lines.push(`- ${flags}${desc}${required}${defaultVal}${envInfo}`);
|
|
434
|
+
if (opt.type === "boolean" && opt.negationDisplay && opt.negationDescription) lines.push(`- \`--${opt.negationDisplay}\` - ${opt.negationDescription} ${negationRelationMarker(opt)}`);
|
|
402
435
|
}
|
|
403
436
|
return lines.join("\n");
|
|
404
437
|
}
|
|
@@ -650,8 +683,11 @@ function createCommandRenderer(options = {}) {
|
|
|
650
683
|
* Default renderers presets
|
|
651
684
|
*/
|
|
652
685
|
const defaultRenderers = {
|
|
686
|
+
/** Standard command documentation */
|
|
653
687
|
command: (options) => createCommandRenderer(options),
|
|
688
|
+
/** Table style options (default) */
|
|
654
689
|
tableStyle: createCommandRenderer({ optionStyle: "table" }),
|
|
690
|
+
/** List style options */
|
|
655
691
|
listStyle: createCommandRenderer({ optionStyle: "list" })
|
|
656
692
|
};
|
|
657
693
|
|
|
@@ -756,12 +792,12 @@ function deleteFile(filePath, fileSystem = node_fs) {
|
|
|
756
792
|
* Build CommandInfo from a command
|
|
757
793
|
*/
|
|
758
794
|
async function buildCommandInfo(command, rootName, commandPath = []) {
|
|
759
|
-
const extracted =
|
|
795
|
+
const extracted = require_schema_extractor.getExtractedFields(command);
|
|
760
796
|
const positionalArgs = extracted?.fields.filter((f) => f.positional) ?? [];
|
|
761
797
|
const options = extracted?.fields.filter((f) => !f.positional) ?? [];
|
|
762
798
|
const subCommands = [];
|
|
763
799
|
if (command.subCommands) for (const [name, subCmd] of Object.entries(command.subCommands)) {
|
|
764
|
-
const resolved = await
|
|
800
|
+
const resolved = await require_schema_extractor.resolveLazyCommand(subCmd);
|
|
765
801
|
const fullPath = [...commandPath, name];
|
|
766
802
|
subCommands.push({
|
|
767
803
|
name,
|
|
@@ -797,7 +833,7 @@ async function collectAllCommands(command, rootName) {
|
|
|
797
833
|
const info = await buildCommandInfo(cmd, root, path);
|
|
798
834
|
const pathKey = path.join(" ");
|
|
799
835
|
result.set(pathKey, info);
|
|
800
|
-
if (cmd.subCommands) for (const [name, subCmd] of Object.entries(cmd.subCommands)) await traverse(await
|
|
836
|
+
if (cmd.subCommands) for (const [name, subCmd] of Object.entries(cmd.subCommands)) await traverse(await require_schema_extractor.resolveLazyCommand(subCmd), [...path, name]);
|
|
801
837
|
}
|
|
802
838
|
await traverse(command, []);
|
|
803
839
|
return result;
|
|
@@ -837,7 +873,7 @@ async function executeSingleExample(example, rootCommand, commandPath) {
|
|
|
837
873
|
collector.start();
|
|
838
874
|
let success = true;
|
|
839
875
|
try {
|
|
840
|
-
const { runCommand } = await Promise.resolve().then(() => require("../runner-
|
|
876
|
+
const { runCommand } = await Promise.resolve().then(() => require("../runner-CRZ_7Y9i.cjs")).then((n) => n.runner_exports);
|
|
841
877
|
const result = await runCommand(rootCommand, argv);
|
|
842
878
|
success = result.success;
|
|
843
879
|
if (!result.success && result.error) console.error(result.error.message);
|
|
@@ -901,7 +937,7 @@ function parseExampleCmd(cmd) {
|
|
|
901
937
|
* ResolvedFieldMeta format used by politty's rendering functions.
|
|
902
938
|
*/
|
|
903
939
|
function extractArgsFields(args) {
|
|
904
|
-
return
|
|
940
|
+
return require_schema_extractor.extractFields(zod.z.object(args)).fields;
|
|
905
941
|
}
|
|
906
942
|
/**
|
|
907
943
|
* Render args definition as a markdown options table
|
|
@@ -985,7 +1021,11 @@ function renderFilteredTable(options, columns) {
|
|
|
985
1021
|
for (const col of columns) switch (col) {
|
|
986
1022
|
case "option": {
|
|
987
1023
|
const placeholder = opt.placeholder ?? opt.cliName.toUpperCase().replace(/-/g, "_");
|
|
988
|
-
|
|
1024
|
+
let optionName;
|
|
1025
|
+
if (opt.type === "boolean") {
|
|
1026
|
+
optionName = `\`--${opt.cliName}\``;
|
|
1027
|
+
if (opt.negationDisplay && !opt.negationDescription) optionName += ` / \`--${opt.negationDisplay}\``;
|
|
1028
|
+
} else optionName = `\`--${opt.cliName} <${placeholder}>\``;
|
|
989
1029
|
cells.push(optionName);
|
|
990
1030
|
break;
|
|
991
1031
|
}
|
|
@@ -1008,6 +1048,26 @@ function renderFilteredTable(options, columns) {
|
|
|
1008
1048
|
}
|
|
1009
1049
|
}
|
|
1010
1050
|
lines.push(`| ${cells.join(" | ")} |`);
|
|
1051
|
+
if (opt.type === "boolean" && opt.negationDisplay && opt.negationDescription) {
|
|
1052
|
+
const negCells = [];
|
|
1053
|
+
for (const col of columns) switch (col) {
|
|
1054
|
+
case "option":
|
|
1055
|
+
negCells.push(`\`--${opt.negationDisplay}\``);
|
|
1056
|
+
break;
|
|
1057
|
+
case "description":
|
|
1058
|
+
negCells.push(`${escapeTableCell$1(opt.negationDescription)} ${negationRelationMarker(opt)}`);
|
|
1059
|
+
break;
|
|
1060
|
+
case "required":
|
|
1061
|
+
negCells.push(opt.required ? "Yes" : "No");
|
|
1062
|
+
break;
|
|
1063
|
+
case "alias":
|
|
1064
|
+
case "default":
|
|
1065
|
+
case "env":
|
|
1066
|
+
negCells.push("-");
|
|
1067
|
+
break;
|
|
1068
|
+
}
|
|
1069
|
+
lines.push(`| ${negCells.join(" | ")} |`);
|
|
1070
|
+
}
|
|
1011
1071
|
}
|
|
1012
1072
|
return lines.join("\n");
|
|
1013
1073
|
}
|
|
@@ -1529,7 +1589,7 @@ function isGlobalOptionsConfigWithOptions(config) {
|
|
|
1529
1589
|
* Positional args are not rendered in args tables, so they must not be excluded.
|
|
1530
1590
|
*/
|
|
1531
1591
|
function collectRenderableGlobalOptionFields(argsShape) {
|
|
1532
|
-
return
|
|
1592
|
+
return require_schema_extractor.extractFields(zod.z.object(argsShape)).fields.filter((field) => !field.positional);
|
|
1533
1593
|
}
|
|
1534
1594
|
/**
|
|
1535
1595
|
* Compare option definitions for global-options compatibility.
|
|
@@ -1952,7 +2012,7 @@ async function generateDoc(config) {
|
|
|
1952
2012
|
let rootDoc = config.rootDoc;
|
|
1953
2013
|
if (!rootDoc && usingPathConfig && (globalArgs || config.rootInfo)) rootDoc = { path: resolvedRootDocPath };
|
|
1954
2014
|
if (globalArgs && rootDoc && !rootDoc.globalOptions) {
|
|
1955
|
-
const optionFields =
|
|
2015
|
+
const optionFields = require_schema_extractor.extractFields(globalArgs).fields.filter((f) => !f.positional);
|
|
1956
2016
|
if (optionFields.length > 0) {
|
|
1957
2017
|
const globalShape = Object.fromEntries(optionFields.map((f) => [f.name, f.schema]));
|
|
1958
2018
|
rootDoc = {
|
|
@@ -2175,7 +2235,7 @@ async function generateDoc(config) {
|
|
|
2175
2235
|
if (globalOptionsResult.wasUpdated) markerUpdated = true;
|
|
2176
2236
|
}
|
|
2177
2237
|
const derivedCategories = deriveIndexFromFiles(files, rootDocFilePath, allCommands, ignores);
|
|
2178
|
-
const indexScope = node_path.relative(process.cwd(), rootDocFilePath);
|
|
2238
|
+
const indexScope = node_path.relative(process.cwd(), rootDocFilePath).replace(/\\/g, "/");
|
|
2179
2239
|
const indexResult = await processIndexMarker(content, derivedCategories, command, indexScope, updateMode, formatter, rootDoc.index);
|
|
2180
2240
|
content = indexResult.content;
|
|
2181
2241
|
rootDocDiffs.push(...indexResult.diffs);
|
|
@@ -2272,7 +2332,7 @@ exports.renderOptionsTableFromArray = renderOptionsTableFromArray;
|
|
|
2272
2332
|
exports.renderSubcommandsTable = renderSubcommandsTable;
|
|
2273
2333
|
exports.renderSubcommandsTableFromArray = renderSubcommandsTableFromArray;
|
|
2274
2334
|
exports.renderUsage = renderUsage;
|
|
2275
|
-
exports.resolveLazyCommand =
|
|
2335
|
+
exports.resolveLazyCommand = require_schema_extractor.resolveLazyCommand;
|
|
2276
2336
|
exports.rootFooterEndMarker = rootFooterEndMarker;
|
|
2277
2337
|
exports.rootFooterStartMarker = rootFooterStartMarker;
|
|
2278
2338
|
exports.rootHeaderEndMarker = rootHeaderEndMarker;
|