@visulima/cerebro 3.0.0-alpha.9 → 3.0.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.
Files changed (96) hide show
  1. package/CHANGELOG.md +591 -0
  2. package/LICENSE.md +1295 -3950
  3. package/README.md +182 -2
  4. package/dist/commands/completion-command.d.ts +6 -5
  5. package/dist/commands/completion-command.js +5 -203
  6. package/dist/commands/help-command.d.ts +10 -9
  7. package/dist/commands/help-command.js +1 -3
  8. package/dist/commands/readme-command.d.ts +6 -5
  9. package/dist/commands/readme-command.js +32 -330
  10. package/dist/commands/version-command.d.ts +4 -3
  11. package/dist/commands/version-command.js +1 -18
  12. package/dist/index.d.ts +516 -95
  13. package/dist/index.js +1 -7
  14. package/dist/logger/create-pail-logger.d.ts +770 -8
  15. package/dist/logger/create-pail-logger.js +1 -34
  16. package/dist/packem_chunks/has-new-version.js +1 -259
  17. package/dist/packem_shared/Cerebro-Czc4t-75.js +4 -0
  18. package/dist/packem_shared/VERBOSITY_DEBUG-XPultrIA.js +1 -0
  19. package/dist/packem_shared/VisulimaError-C90oeIMu.js +76 -0
  20. package/dist/packem_shared/VisulimaError-DTMgXonA-CzaryRgZ.js +1 -0
  21. package/dist/packem_shared/cerebro-error-BjBcYVRO.js +1 -0
  22. package/dist/packem_shared/command.d-DbhtfXF4.d.ts +639 -0
  23. package/dist/packem_shared/index-B7-8G-9s.js +29 -0
  24. package/dist/packem_shared/index.d-BL4NtVR3.d.ts +127 -0
  25. package/dist/packem_shared/lazyNamed-DMUm8mZe.js +1 -0
  26. package/dist/packem_shared/renderError-B3ePOoBG-BmZlyMcr.js +25 -0
  27. package/dist/packem_shared/runtime-process-Dmz0vCJy.js +1 -0
  28. package/dist/packem_shared/split-by-case-Dbpgd7rf.js +1 -0
  29. package/dist/plugins/error-handler-plugin.d.ts +21 -19
  30. package/dist/plugins/error-handler-plugin.js +1 -636
  31. package/dist/plugins/runtime-version-check-plugin.d.ts +22 -20
  32. package/dist/plugins/runtime-version-check-plugin.js +1 -77
  33. package/dist/plugins/update-notifier/update-notifier-plugin.d.ts +28 -8
  34. package/dist/plugins/update-notifier/update-notifier-plugin.js +1 -517
  35. package/dist/util/general/compile-cache.d.ts +41 -0
  36. package/dist/util/general/compile-cache.js +1 -0
  37. package/dist/util/general/heap-tuning.d.ts +18 -0
  38. package/dist/util/general/heap-tuning.js +1 -0
  39. package/package.json +33 -28
  40. package/dist/cli.d.ts +0 -203
  41. package/dist/constants.d.ts +0 -29
  42. package/dist/default-env.d.ts +0 -7
  43. package/dist/default-options.d.ts +0 -3
  44. package/dist/empty-toolbox.d.ts +0 -15
  45. package/dist/errors/cerebro-error.d.ts +0 -10
  46. package/dist/errors/command-not-found-error.d.ts +0 -9
  47. package/dist/errors/command-validation-error.d.ts +0 -10
  48. package/dist/errors/completion-error.d.ts +0 -9
  49. package/dist/errors/conflicting-options-error.d.ts +0 -10
  50. package/dist/errors/plugin-error.d.ts +0 -9
  51. package/dist/errors/update-notifier-error.d.ts +0 -7
  52. package/dist/packem_shared/Cerebro-C2mnCyQf.js +0 -3313
  53. package/dist/packem_shared/VERBOSITY_QUIET-Dp46zlLW.js +0 -10
  54. package/dist/packem_shared/VisulimaError-DA7QsCxH.js +0 -34
  55. package/dist/packem_shared/cerebro-error-GmJ3jN7Q.js +0 -16
  56. package/dist/packem_shared/help-command-BY7rQUvM.js +0 -249
  57. package/dist/packem_shared/index-C2-8b3A4.js +0 -259
  58. package/dist/packem_shared/runtime-process-B6ZplyWn.js +0 -187
  59. package/dist/plugin-manager.d.ts +0 -53
  60. package/dist/plugins/update-notifier/cache.d.ts +0 -11
  61. package/dist/plugins/update-notifier/get-distribution-version.d.ts +0 -2
  62. package/dist/plugins/update-notifier/has-new-version.d.ts +0 -14
  63. package/dist/types/cli.d.ts +0 -102
  64. package/dist/types/command-line-usage.d.ts +0 -37
  65. package/dist/types/command.d.ts +0 -136
  66. package/dist/types/option-types.d.ts +0 -83
  67. package/dist/types/options.d.ts +0 -4
  68. package/dist/types/plugin.d.ts +0 -53
  69. package/dist/types/toolbox.d.ts +0 -96
  70. package/dist/util/arg-processing/get-boolean-values.d.ts +0 -7
  71. package/dist/util/arg-processing/get-parameter-option.d.ts +0 -7
  72. package/dist/util/arg-processing/map-option-type-label.d.ts +0 -3
  73. package/dist/util/arg-processing/option-is-boolean.d.ts +0 -9
  74. package/dist/util/arg-processing/remove-boolean-values.d.ts +0 -9
  75. package/dist/util/command-line-commands.d.ts +0 -10
  76. package/dist/util/command-line-usage/get-terminal-width.d.ts +0 -7
  77. package/dist/util/command-line-usage/index.d.ts +0 -3
  78. package/dist/util/command-line-usage/section/base-section.d.ts +0 -8
  79. package/dist/util/command-line-usage/section/content-section.d.ts +0 -65
  80. package/dist/util/command-line-usage/section/option-list-section.d.ts +0 -44
  81. package/dist/util/command-processing/command-processor.d.ts +0 -37
  82. package/dist/util/command-processing/command-validation.d.ts +0 -17
  83. package/dist/util/command-processing/nested-command-parser.d.ts +0 -25
  84. package/dist/util/command-processing/option-processor.d.ts +0 -44
  85. package/dist/util/data-processing/list-missing-arguments.d.ts +0 -15
  86. package/dist/util/data-processing/merge-arguments.d.ts +0 -7
  87. package/dist/util/general/find-alternatives.d.ts +0 -8
  88. package/dist/util/general/hide-bin.d.ts +0 -2
  89. package/dist/util/general/parse-raw-command.d.ts +0 -7
  90. package/dist/util/general/register-exception-handler.d.ts +0 -9
  91. package/dist/util/general/runtime-process.d.ts +0 -65
  92. package/dist/util/general/semver-gt.d.ts +0 -2
  93. package/dist/util/general/validate-input.d.ts +0 -24
  94. package/dist/util/process-env-variables.d.ts +0 -9
  95. package/dist/util/security.d.ts +0 -58
  96. package/dist/util/text-processing/template-format.d.ts +0 -5
@@ -1,265 +1,36 @@
1
- import { createRequire as __cjs_createRequire } from "node:module";
2
-
3
- const __cjs_require = __cjs_createRequire(import.meta.url);
4
-
5
- const __cjs_getProcess = typeof globalThis !== "undefined" && typeof globalThis.process !== "undefined" ? globalThis.process : process;
6
-
7
- const __cjs_getBuiltinModule = (module) => {
8
- // Check if we're in Node.js and version supports getBuiltinModule
9
- if (typeof __cjs_getProcess !== "undefined" && __cjs_getProcess.versions && __cjs_getProcess.versions.node) {
10
- const [major, minor] = __cjs_getProcess.versions.node.split(".").map(Number);
11
- // Node.js 20.16.0+ and 22.3.0+
12
- if (major > 22 || (major === 22 && minor >= 3) || (major === 20 && minor >= 16)) {
13
- return __cjs_getProcess.getBuiltinModule(module);
14
- }
15
- }
16
- // Fallback to createRequire
17
- return __cjs_require(module);
18
- };
19
-
20
- const {
21
- existsSync
22
- } = __cjs_getBuiltinModule("node:fs");
23
- const {
24
- readFile,
25
- mkdir,
26
- writeFile
27
- } = __cjs_getBuiltinModule("node:fs/promises");
28
- const {
29
- resolve,
30
- join,
31
- dirname
32
- } = __cjs_getBuiltinModule("node:path");
33
- import GithubSlugger from 'github-slugger';
34
- import { c as commandLineUsage } from '../packem_shared/index-C2-8b3A4.js';
35
- import { g as getCwd, a as getVersions, b as getPlatform, c as getArch } from '../packem_shared/runtime-process-B6ZplyWn.js';
36
-
37
- const slugger = new GithubSlugger();
38
- const slugify = slugger.slug;
39
- const compact = (array) => array.filter(Boolean);
40
- const uniqBy = (array, keyFunction) => {
41
- const seen = /* @__PURE__ */ new Set();
42
- const result = [];
43
- for (const item of array) {
44
- const key = keyFunction(item);
45
- if (!seen.has(key)) {
46
- seen.add(key);
47
- result.push(item);
48
- }
49
- }
50
- return result;
51
- };
52
- const formatCommandUsage = (command, cliName) => {
53
- const fullPath = command.commandPath ? [...command.commandPath, command.name] : [command.name];
54
- const commandId = fullPath.join(" ");
55
- if (command.argument) {
56
- const argumentName = command.argument.name?.toUpperCase() ?? "ARG";
57
- const argumentString = command.argument.required ? argumentName : `[${argumentName}]`;
58
- return `${cliName} ${commandId} ${argumentString}`;
59
- }
60
- return `${cliName} ${commandId}`;
61
- };
62
- const addEnvironmentVariables = (command, usageGroups) => {
63
- if (!Array.isArray(command.env) || command.env.length === 0) {
64
- return;
65
- }
66
- const visibleEnvVariables = command.env.filter((envVariable) => !envVariable.hidden);
67
- if (visibleEnvVariables.length > 0) {
68
- usageGroups.push({
69
- content: visibleEnvVariables.map((envVariable) => [envVariable.name, envVariable.description ?? ""]),
70
- header: " Environment Variables "
71
- });
72
- }
73
- };
74
- const formatCommandHelp = (command, cliName) => {
75
- const usageGroups = [];
76
- const fullCommandPath = command.commandPath ? [...command.commandPath, command.name] : [command.name];
77
- const commandDisplay = fullCommandPath.join(" ");
78
- const hasArgument = Boolean(command.argument);
79
- const hasOptions = Boolean(command.options);
80
- usageGroups.push({
81
- content: `${cliName} ${commandDisplay}${hasArgument ? " [positional arguments]" : ""}${hasOptions ? " [options]" : ""}`,
82
- header: " Usage "
83
- });
84
- if (command.description) {
85
- usageGroups.push({ content: command.description, header: " Description " });
86
- }
87
- if (command.argument) {
88
- usageGroups.push({ header: "Command Positional Arguments", isArgument: true, optionList: [command.argument] });
89
- }
90
- if (Array.isArray(command.options) && command.options.length > 0) {
91
- usageGroups.push({
92
- header: " Command Options ",
93
- optionList: command.options.filter(
94
- (option) => typeof option === "object" && option !== null && (!("hidden" in option) || !option.hidden)
95
- )
96
- });
97
- }
98
- addEnvironmentVariables(command, usageGroups);
99
- if (command.alias !== void 0 && command.alias.length > 0) {
100
- const alias = Array.isArray(command.alias) ? command.alias : [command.alias];
101
- usageGroups.splice(1, 0, {
102
- content: alias,
103
- header: "Alias(es)"
104
- });
105
- }
106
- if (Array.isArray(command.examples) && command.examples.length > 0) {
107
- usageGroups.push({
108
- content: command.examples,
109
- header: "Examples"
110
- });
111
- }
112
- return commandLineUsage(usageGroups);
113
- };
114
- const renderCommand = (command, cliName) => {
115
- const title = command.description?.trim().split("\n")[0] ?? "";
116
- const usage = formatCommandUsage(command, cliName);
117
- const helpText = formatCommandHelp(command, cliName);
118
- return compact([`## \`${usage}\``, title, `\`\`\`
119
- ${helpText.trim()}
120
- \`\`\``]).join("\n\n");
121
- };
122
- const generateUsage = (cliName, packageName, version, nodeVersion) => {
123
- const versionFlags = ["--version", "-V"];
124
- const versionFlagsString = `(${versionFlags.join("|")})`;
125
- const platform = getPlatform();
126
- const arch = getArch();
127
- return `\`\`\`sh-session
128
- $ npm install -g ${packageName}
129
- $ ${cliName} COMMAND
1
+ import{createRequire as x}from"node:module";import{r as L}from"../packem_shared/index-B7-8G-9s.js";import{g as N,a as V,b as q}from"../packem_shared/runtime-process-Dmz0vCJy.js";const S=x(import.meta.url),h=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,O=e=>{if(typeof h<"u"&&h.versions&&h.versions.node){const[n,t]=h.versions.node.split(".").map(Number);if(n>22||n===22&&t>=3||n===20&&t>=16)return h.getBuiltinModule(e)}return S(e)},{resolve:P,join:k,dirname:B}=O("node:path"),v=async(e,n)=>{try{return await e.access(n),!0}catch{return!1}},G=async()=>{const{default:e}=await import("github-slugger"),n=new e;return t=>n.slug(t)},T=e=>e.filter(Boolean),U=(e,n)=>{const t=new Set,a=[];for(const r of e){const o=n(r);t.has(o)||(t.add(o),a.push(r))}return a},M=(e,n)=>{const t=(e.commandPath?[...e.commandPath,e.name]:[e.name]).join(" ");if(e.argument){const a=e.argument.name.toUpperCase(),r=e.argument.required?a:`[${a}]`;return`${n} ${t} ${r}`}return`${n} ${t}`},F=(e,n)=>{if(!Array.isArray(e.env)||e.env.length===0)return;const t=e.env.filter(a=>!a.hidden);t.length>0&&n.push({content:t.map(a=>[a.name,a.description??""]),header:" Environment Variables "})},I=(e,n)=>{const t=[],a=(e.commandPath?[...e.commandPath,e.name]:[e.name]).join(" "),r=!!e.argument,o=!!e.options;if(t.push({content:`${n} ${a}${r?" [positional arguments]":""}${o?" [options]":""}`,header:" Usage "}),e.description&&t.push({content:e.description,header:" Description "}),e.argument&&t.push({header:"Command Positional Arguments",isArgument:!0,optionList:[e.argument]}),Array.isArray(e.options)&&e.options.length>0&&t.push({header:" Command Options ",optionList:e.options.filter(i=>!i.hidden)}),F(e,t),e.alias!==void 0&&e.alias.length>0){const i=Array.isArray(e.alias)?e.alias:[e.alias];t.splice(1,0,{content:i,header:"Alias(es)"})}return Array.isArray(e.examples)&&e.examples.length>0&&t.push({content:e.examples,header:"Examples"}),L(t)},W=(e,n)=>{const t=e.description?.trim().split(`
2
+ `)[0]??"",a=M(e,n),r=I(e,n);return T([`## \`${a}\``,t,`\`\`\`
3
+ ${r.trim()}
4
+ \`\`\``]).join(`
5
+
6
+ `)},z=(e,n,t,a)=>{const r=`(${["--version","-V"].join("|")})`,o=V(),i=q();return`\`\`\`sh-session
7
+ $ npm install -g ${n}
8
+ $ ${e} COMMAND
130
9
  running command...
131
- $ ${cliName} ${versionFlagsString}
132
- ${packageName}/${version ?? "unknown"} ${platform}-${arch} node-v${nodeVersion}
133
- $ ${cliName} --help [COMMAND]
10
+ $ ${e} ${r}
11
+ ${n}/${t??"unknown"} ${o}-${i} node-v${a}
12
+ $ ${e} --help [COMMAND]
134
13
  USAGE
135
- $ ${cliName} COMMAND
14
+ $ ${e} COMMAND
136
15
  ...
137
16
  \`\`\`
138
- `;
139
- };
140
- const generateCommands = async (commands, cliName, _options) => {
141
- const commandList = await Promise.all(
142
- commands.map(async (command) => {
143
- const usage = formatCommandUsage(command, cliName);
144
- return `* [\`${usage}\`](#${await slugify(usage)})`;
145
- })
146
- );
147
- const commandDocumentation = commands.map((command) => renderCommand(command, cliName)).map((s) => `${s.trim()}
148
- `);
149
- return [...commandList, "", ...commandDocumentation].join("\n").trim();
150
- };
151
- const writeFileWithDirectory = async (filePath, content) => {
152
- const directory = dirname(filePath);
153
- if (!existsSync(directory)) {
154
- await mkdir(directory, { recursive: true });
155
- }
156
- await writeFile(filePath, content, "utf8");
157
- };
158
- const generateMultiCommands = async (commands, outputDirectory, cliName, options) => {
159
- const groupedCommands = /* @__PURE__ */ new Map();
160
- for (const command of commands) {
161
- const group = command.group ?? "__Other";
162
- const groupCommands = groupedCommands.get(group) ?? [];
163
- groupCommands.push(command);
164
- groupedCommands.set(group, groupCommands);
165
- }
166
- const groups = [...groupedCommands.entries()].map(([group, groupCommands]) => {
167
- if (group === "__Other") {
168
- return ["Other", groupCommands];
169
- }
170
- return [group, groupCommands];
171
- });
172
- await Promise.all(
173
- groups.map(async ([group, groupCommands]) => {
174
- const groupPath = group.replaceAll(":", "/");
175
- const filePath = join(".", outputDirectory, `${groupPath}.md`);
176
- const bin = `\`${cliName} ${group}\``;
177
- const document = `${[
178
- bin,
179
- "=".repeat(bin.length),
180
- "",
181
- `Commands in the ${group} group.`,
182
- "",
183
- await generateCommands(groupCommands, cliName)
184
- ].join("\n").trim()}
185
- `;
186
- if (!options.dryRun) {
187
- await writeFileWithDirectory(resolve(getCwd(), filePath), document);
188
- }
189
- })
190
- );
191
- const topicLinks = groups.map(([group]) => {
192
- const groupPath = group.replaceAll(":", "/");
193
- return `* [\`${cliName} ${group}\`](${outputDirectory}/${groupPath}.md)`;
194
- });
195
- return `${["# Command Topics\n", ...topicLinks].join("\n").trim()}
196
- `;
197
- };
198
- const normalizeLineEndings = (text) => text.replaceAll("\r\n", "\n").replaceAll("\r", "\n");
199
- const generateTableOfContents = async (readme) => {
200
- const normalizedReadme = normalizeLineEndings(readme);
201
- const toc = await Promise.all(
202
- normalizedReadme.split("\n").filter((line) => line.startsWith("# ")).map((line) => line.trim().slice(2)).map(async (line) => `* [${line}](#${await slugify(line)})`)
203
- );
204
- return toc.join("\n");
205
- };
206
- const escapeRegex = (string_) => string_.replaceAll(/[.*+?^${}()|[\]\\]/g, String.raw`\$&`);
207
- const replaceTag = (readme, tag, body) => {
208
- const normalizedReadme = normalizeLineEndings(readme);
209
- const tagStart = `<!-- ${tag} -->`;
210
- const tagStop = `<!-- ${tag}stop -->`;
211
- if (normalizedReadme.includes(tagStart) && normalizedReadme.includes(tagStop)) {
212
- const escapedStart = escapeRegex(tagStart);
213
- const escapedStop = escapeRegex(tagStop);
214
- const tagPattern = new RegExp(String.raw`${escapedStart}(.|\n)*${escapedStop}`, "m");
215
- return normalizedReadme.replace(tagPattern, `${tagStart}
216
- ${body}
217
- ${tagStop}`);
218
- }
219
- return normalizedReadme.replace(tagStart, `${tagStart}
220
- ${body}
221
- ${tagStop}`);
222
- };
223
- const readmeCommand = {
224
- description: "Generate README documentation for CLI commands",
225
- execute: async ({ logger, options, runtime }) => {
226
- const cliName = runtime.getCliName();
227
- const packageName = runtime.getPackageName() ?? cliName;
228
- const packageVersion = runtime.getPackageVersion();
229
- const versions = getVersions();
230
- const nodeVersion = versions.node ?? "unknown";
231
- const readmeOptions = {
232
- aliases: options?.aliases,
233
- dryRun: options?.dryRun,
234
- multi: options?.multi,
235
- outputDir: options?.outputDir ?? "docs",
236
- readmePath: options?.readmePath ?? "README.md",
237
- version: options?.version ?? packageVersion ?? void 0
238
- };
239
- const commandsMap = runtime.getCommands();
240
- const commands = [...commandsMap.values()].filter((c) => !c.hidden).filter((c) => {
241
- if (readmeOptions.aliases) {
242
- return true;
243
- }
244
- return c.name === commandsMap.get(c.name)?.name;
245
- }).toSorted((a, b) => {
246
- const aPath = a.commandPath ? [...a.commandPath, a.name].join(" ") : a.name;
247
- const bPath = b.commandPath ? [...b.commandPath, b.name].join(" ") : b.name;
248
- return aPath.localeCompare(bPath);
249
- });
250
- const uniqueCommands = uniqBy(commands, (c) => {
251
- const path = c.commandPath ? [...c.commandPath, c.name].join(" ") : c.name;
252
- return path;
253
- });
254
- logger.debug(`Processing ${uniqueCommands.length} commands for README generation`);
255
- let readme;
256
- const readmePath = resolve(getCwd(), readmeOptions.readmePath ?? "README.md");
257
- if (existsSync(readmePath)) {
258
- const rawReadme = await readFile(readmePath, "utf8");
259
- readme = normalizeLineEndings(rawReadme);
260
- } else {
261
- logger.warn(`README file not found at ${readmePath}, creating template`);
262
- readme = `# ${packageName}
17
+ `},R=(e,n,t,a)=>{const r=e.map(i=>{const p=M(i,n);return`* [\`${p}\`](#${a(p)})`}),o=e.map(i=>W(i,n)).map(i=>`${i.trim()}
18
+ `);return[...r,"",...o].join(`
19
+ `).trim()},j=async(e,n,t)=>{const a=B(n);await v(e,a)||await e.mkdir(a,{recursive:!0}),await e.writeFile(n,t,"utf8")},H=async(e,n,t,a,r,o,i)=>{const p=new Map;for(const m of t){const s=m.group??"__Other",u=p.get(s)??[];u.push(m),p.set(s,u)}const d=Array.from(p.entries(),([m,s])=>m==="__Other"?["Other",s]:[m,s]);return await Promise.all(d.map(async([m,s])=>{const u=m.replaceAll(":","/"),y=k(".",a,`${u}.md`),g=`\`${r} ${m}\``,l=`${[g,"=".repeat(g.length),"",`Commands in the ${m} group.`,"",R(s,r,o,i)].join(`
20
+ `).trim()}
21
+ `;o.dryRun||await j(e,P(n,y),l)})),`${[`# Command Topics
22
+ `,...d.map(([m])=>{const s=m.replaceAll(":","/");return`* [\`${r} ${m}\`](${a}/${s}.md)`})].join(`
23
+ `).trim()}
24
+ `},A=e=>e.replaceAll(`\r
25
+ `,`
26
+ `).replaceAll("\r",`
27
+ `),J=(e,n)=>A(e).split(`
28
+ `).filter(t=>t.startsWith("# ")).map(t=>t.trim().slice(2)).map(t=>`* [${t}](#${n(t)})`).join(`
29
+ `),E=e=>e.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`),w=(e,n,t)=>{const a=A(e),r=`<!-- ${n} -->`,o=`<!-- ${n}stop -->`;if(a.includes(r)&&a.includes(o)){const i=E(r),p=E(o),d=new RegExp(String.raw`${i}(.|\n)*${p}`,"m");return a.replace(d,`${r}
30
+ ${t}
31
+ ${o}`)}return a.replace(r,`${r}
32
+ ${t}
33
+ ${o}`)},Y={description:"Generate README documentation for CLI commands",execute:async({fs:e,logger:n,options:t,process:a,runtime:r})=>{const o=r.getCliName(),i=r.getPackageName()??o,p=r.getPackageVersion(),d=N().node??"unknown",m=await G(),s={aliases:t.aliases,dryRun:t.dryRun,multi:t.multi,outputDir:t.outputDir??"docs",readmePath:t.readmePath??"README.md",version:t.version??p??void 0},u=r.getCommands(),y=[...u.values()].filter(c=>!c.hidden).filter(c=>s.aliases?!0:c.name===u.get(c.name)?.name).toSorted((c,f)=>{const b=c.commandPath?[...c.commandPath,c.name].join(" "):c.name,C=f.commandPath?[...f.commandPath,f.name].join(" "):f.name;return b.localeCompare(C)}),g=U(y,c=>c.commandPath?[...c.commandPath,c.name].join(" "):c.name);n.debug(`Processing ${String(g.length)} commands for README generation`);let l;const $=P(a.cwd,s.readmePath??"README.md");if(await v(e,$)){const c=await e.readFile($,"utf8");l=A(c)}else n.warn(`README file not found at ${$}, creating template`),l=`# ${i}
263
34
 
264
35
  <!-- usage -->
265
36
  <!-- usagestop -->
@@ -269,75 +40,6 @@ const readmeCommand = {
269
40
 
270
41
  <!-- toc -->
271
42
  <!-- tocstop -->
272
- `;
273
- }
274
- const outputDirectory = readmeOptions.outputDir ?? "docs";
275
- const version = readmeOptions.version ?? packageVersion ?? "unknown";
276
- readme = replaceTag(readme, "usage", generateUsage(cliName, packageName, version, nodeVersion));
277
- readme = replaceTag(
278
- readme,
279
- "commands",
280
- readmeOptions.multi ? await generateMultiCommands(uniqueCommands, outputDirectory, cliName, readmeOptions) : await generateCommands(uniqueCommands, cliName)
281
- );
282
- readme = replaceTag(readme, "toc", await generateTableOfContents(readme));
283
- readme = `${readme.trimEnd()}
284
- `;
285
- if (readmeOptions.dryRun) {
286
- logger.info("Dry run mode - README not written");
287
- logger.info(`Generated README content:
288
- ${readme}`);
289
- } else {
290
- await writeFileWithDirectory(readmePath, readme);
291
- logger.info(`README generated successfully at ${readmePath}`);
292
- }
293
- },
294
- name: "readme",
295
- options: [
296
- {
297
- description: "Include aliases in command list",
298
- name: "aliases",
299
- type: Boolean
300
- },
301
- {
302
- description: "Show what would be generated without writing files",
303
- name: "dry-run",
304
- type: Boolean
305
- },
306
- {
307
- description: "Generate multi-file documentation by command groups",
308
- name: "multi",
309
- type: Boolean
310
- },
311
- {
312
- description: "Maximum depth for nested topics when using multi-file mode",
313
- name: "nested-topics-depth",
314
- type: Number
315
- },
316
- {
317
- description: "Output directory for multi-file documentation",
318
- name: "output-dir",
319
- type: String,
320
- typeLabel: "{underline directory}"
321
- },
322
- {
323
- description: "Path to README file to generate",
324
- name: "readme-path",
325
- type: String,
326
- typeLabel: "{underline path}"
327
- },
328
- {
329
- description: "Repository prefix for code links",
330
- name: "repository-prefix",
331
- type: String,
332
- typeLabel: "{underline prefix}"
333
- },
334
- {
335
- description: "Version to use in generated documentation",
336
- name: "version",
337
- type: String,
338
- typeLabel: "{underline version}"
339
- }
340
- ]
341
- };
342
-
343
- export { readmeCommand as default };
43
+ `;const D=s.outputDir??"docs",_=s.version??p??"unknown";l=w(l,"usage",z(o,i,_,d)),l=w(l,"commands",s.multi?await H(e,a.cwd,g,D,o,s,m):R(g,o,s,m)),l=w(l,"toc",J(l,m)),l=`${l.trimEnd()}
44
+ `,s.dryRun?(n.info("Dry run mode - README not written"),n.info(`Generated README content:
45
+ ${l}`)):(await j(e,$,l),n.info(`README generated successfully at ${$}`))},name:"readme",options:[{description:"Include aliases in command list",name:"aliases",type:Boolean},{description:"Show what would be generated without writing files",name:"dry-run",type:Boolean},{description:"Generate multi-file documentation by command groups",name:"multi",type:Boolean},{description:"Maximum depth for nested topics when using multi-file mode",name:"nested-topics-depth",type:Number},{description:"Output directory for multi-file documentation",name:"output-dir",type:String,typeLabel:"{underline directory}"},{description:"Path to README file to generate",name:"readme-path",type:String,typeLabel:"{underline path}"},{description:"Repository prefix for code links",name:"repository-prefix",type:String,typeLabel:"{underline prefix}"},{description:"Version to use in generated documentation",name:"version",type:String,typeLabel:"{underline version}"}]};export{Y as default};
@@ -1,3 +1,4 @@
1
- import type { Command as ICommand } from "../types/command.d.ts";
2
- declare const _default: ICommand;
3
- export default _default;
1
+ import { C as Command } from "../packem_shared/command.d-DbhtfXF4.js";
2
+ import '@visulima/tabular';
3
+ declare const _default: Command;
4
+ export { _default as default };
@@ -1,18 +1 @@
1
- const versionCommand = {
2
- alias: ["v", "V"],
3
- description: "Output the version number",
4
- execute: ({ logger, runtime }) => {
5
- const version = runtime.getPackageVersion();
6
- if (version === void 0) {
7
- logger.warn("Unknown version");
8
- logger.debug("The version number was not provided by the cli constructor.");
9
- } else {
10
- logger.info(version);
11
- }
12
- },
13
- name: "version",
14
- options: [],
15
- usage: []
16
- };
17
-
18
- export { versionCommand as default };
1
+ const r={alias:["v","V"],description:"Output the version number",execute:({logger:e,runtime:o})=>{const n=o.getPackageVersion();n===void 0?(e.warn("Unknown version"),e.debug("The version number was not provided by the cli constructor.")):e.info(n)},name:"version",options:[],usage:[]};export{r as default};