@visulima/cerebro 3.0.0-alpha.6 → 3.0.0-alpha.8

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.
@@ -1,36 +1,265 @@
1
- var O=Object.defineProperty;var f=(e,n)=>O(e,"name",{value:n,configurable:!0});import{createRequire as L}from"node:module";import G from"github-slugger";import{p as U}from"../packem_shared/index-DQ3pvLQH.js";import{g as F,a as M,b as W,c as z}from"../packem_shared/runtime-process-G-n-wOub.js";const N=L(import.meta.url),g=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,w=f(e=>{if(typeof g<"u"&&g.versions&&g.versions.node){const[n,t]=g.versions.node.split(".").map(Number);if(n>22||n===22&&t>=3||n===20&&t>=16)return g.getBuiltinModule(e)}return N(e)},"__cjs_getBuiltinModule"),{existsSync:E}=w("node:fs"),{readFile:T,mkdir:k,writeFile:B}=w("node:fs/promises"),{resolve:v,join:V,dirname:q}=w("node:path");var H=Object.defineProperty,d=f((e,n)=>H(e,"name",{value:n,configurable:!0}),"d");const I=new G,b=I.slug,J=d(e=>e.filter(Boolean),"compact"),K=d((e,n)=>{const t=new Set,a=[];for(const r of e){const i=n(r);t.has(i)||(t.add(i),a.push(r))}return a},"uniqBy"),D=d((e,n)=>{const t=(e.commandPath?[...e.commandPath,e.name]:[e.name]).join(" ");if(e.argument){const a=e.argument.name?.toUpperCase()??"ARG",r=e.argument.required?a:`[${a}]`;return`${n} ${t} ${r}`}return`${n} ${t}`},"formatCommandUsage"),Q=d((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 "})},"addEnvironmentVariables"),X=d((e,n)=>{const t=[],a=(e.commandPath?[...e.commandPath,e.name]:[e.name]).join(" "),r=!!e.argument,i=!!e.options;if(t.push({content:`${n} ${a}${r?" [positional arguments]":""}${i?" [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(o=>typeof o=="object"&&o!==null&&(!("hidden"in o)||!o.hidden))}),Q(e,t),e.alias!==void 0&&e.alias.length>0){const o=Array.isArray(e.alias)?e.alias:[e.alias];t.splice(1,0,{content:o,header:"Alias(es)"})}return Array.isArray(e.examples)&&e.examples.length>0&&t.push({content:e.examples,header:"Examples"}),U(t)},"formatCommandHelp"),Y=d((e,n)=>{const t=e.description?.trim().split(`
2
- `)[0]??"",a=D(e,n),r=X(e,n);return J([`## \`${a}\``,t,`\`\`\`
3
- ${r.trim()}
4
- \`\`\``]).join(`
5
-
6
- `)},"renderCommand"),Z=d((e,n,t,a)=>{const r=`(${["--version","-V"].join("|")})`,i=W(),o=z();return`\`\`\`sh-session
7
- $ npm install -g ${n}
8
- $ ${e} COMMAND
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
9
130
  running command...
10
- $ ${e} ${r}
11
- ${n}/${t??"unknown"} ${i}-${o} node-v${a}
12
- $ ${e} --help [COMMAND]
131
+ $ ${cliName} ${versionFlagsString}
132
+ ${packageName}/${version ?? "unknown"} ${platform}-${arch} node-v${nodeVersion}
133
+ $ ${cliName} --help [COMMAND]
13
134
  USAGE
14
- $ ${e} COMMAND
135
+ $ ${cliName} COMMAND
15
136
  ...
16
137
  \`\`\`
17
- `},"generateUsage"),R=d(async(e,n,t)=>{const a=await Promise.all(e.map(async i=>{const o=D(i,n);return`* [\`${o}\`](#${await b(o)})`})),r=e.map(i=>Y(i,n)).map(i=>`${i.trim()}
18
- `);return[...a,"",...r].join(`
19
- `).trim()},"generateCommands"),j=d(async(e,n)=>{const t=q(e);E(t)||await k(t,{recursive:!0}),await B(e,n,"utf8")},"writeFileWithDirectory"),ee=d(async(e,n,t,a)=>{const r=new Map;for(const o of e){const s=o.group??"__Other",l=r.get(s)??[];l.push(o),r.set(s,l)}const i=[...r.entries()].map(([o,s])=>o==="__Other"?["Other",s]:[o,s]);return await Promise.all(i.map(async([o,s])=>{const l=o.replaceAll(":","/"),$=V(".",n,`${l}.md`),p=`\`${t} ${o}\``,c=`${[p,"=".repeat(p.length),"",`Commands in the ${o} group.`,"",await R(s,t,a)].join(`
20
- `).trim()}
21
- `;a.dryRun||await j(v(M(),$),c)})),`${[`# Command Topics
22
- `,...i.map(([o])=>{const s=o.replaceAll(":","/");return`* [\`${t} ${o}\`](${n}/${s}.md)`})].join(`
23
- `).trim()}
24
- `},"generateMultiCommands"),A=d(e=>e.replaceAll(`\r
25
- `,`
26
- `).replaceAll("\r",`
27
- `),"normalizeLineEndings"),te=d(async e=>{const n=A(e);return(await Promise.all(n.split(`
28
- `).filter(t=>t.startsWith("# ")).map(t=>t.trim().slice(2)).map(async t=>`* [${t}](#${await b(t)})`))).join(`
29
- `)},"generateTableOfContents"),P=d(e=>e.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`),"escapeRegex"),y=d((e,n,t)=>{const a=A(e),r=`<!-- ${n} -->`,i=`<!-- ${n}stop -->`;if(a.includes(r)&&a.includes(i)){const o=P(r),s=P(i),l=new RegExp(String.raw`${o}(.|\n)*${s}`,"m");return a.replace(l,`${r}
30
- ${t}
31
- ${i}`)}return a.replace(r,`${r}
32
- ${t}
33
- ${i}`)},"replaceTag"),se={description:"Generate README documentation for CLI commands",execute:d(async({logger:e,options:n,runtime:t})=>{const a=t.getCliName(),r=t.getPackageName()??a,i=t.getPackageVersion(),o=F().node??"unknown",s={aliases:n?.aliases,dryRun:n?.dryRun,multi:n?.multi,nestedTopicsDepth:n?.nestedTopicsDepth,outputDir:n?.outputDir??"docs",readmePath:n?.readmePath??"README.md",repositoryPrefix:n?.repositoryPrefix,version:n?.version??i??void 0},l=t.getCommands(),$=[...l.values()].filter(m=>!m.hidden).filter(m=>s.aliases?!0:m.name===l.get(m.name)?.name).toSorted((m,h)=>{const _=m.commandPath?[...m.commandPath,m.name].join(" "):m.name,S=h.commandPath?[...h.commandPath,h.name].join(" "):h.name;return _.localeCompare(S)}),p=K($,m=>m.commandPath?[...m.commandPath,m.name].join(" "):m.name);e.debug(`Processing ${p.length} commands for README generation`);let c;const u=v(M(),s.readmePath??"README.md");if(E(u)){const m=await T(u,"utf8");c=A(m)}else e.warn(`README file not found at ${u}, creating template`),c=`# ${r}
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}
34
263
 
35
264
  <!-- usage -->
36
265
  <!-- usagestop -->
@@ -40,6 +269,75 @@ ${i}`)},"replaceTag"),se={description:"Generate README documentation for CLI com
40
269
 
41
270
  <!-- toc -->
42
271
  <!-- tocstop -->
43
- `;const C=s.outputDir??"docs",x=s.version??i??"unknown";c=y(c,"usage",Z(a,r,x,o)),c=y(c,"commands",s.multi?await ee(p,C,a,s):await R(p,a,s)),c=y(c,"toc",await te(c)),c=`${c.trimEnd()}
44
- `,s.dryRun?(e.info("Dry run mode - README not written"),e.info(`Generated README content:
45
- ${c}`)):(await j(u,c),e.info(`README generated successfully at ${u}`))},"execute"),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{se as default};
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 };
@@ -1 +1,18 @@
1
- var t=Object.defineProperty;var r=(e,n)=>t(e,"name",{value:n,configurable:!0});var i=Object.defineProperty,a=r((e,n)=>i(e,"name",{value:n,configurable:!0}),"s");const u={alias:["v","V"],description:"Output the version number",execute:a(({logger:e,runtime:n})=>{const o=n.getPackageVersion();o===void 0?(e.warn("Unknown version"),e.debug("The version number was not provided by the cli constructor.")):e.info(o)},"execute"),name:"version",options:[],usage:[]};export{u as default};
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 };
package/dist/index.js CHANGED
@@ -1 +1,7 @@
1
- var t=Object.defineProperty;var o=(r,e)=>t(r,"name",{value:e,configurable:!0});import{Cli as a}from"./packem_shared/Cerebro-CI6nbG1o.js";import{VERBOSITY_DEBUG as b,VERBOSITY_NORMAL as c,VERBOSITY_QUIET as f,VERBOSITY_VERBOSE as n}from"./packem_shared/VERBOSITY_QUIET-XPultrIA.js";import{VisulimaError as I}from"./packem_shared/VisulimaError-rZ7cJo5A.js";var E=Object.defineProperty,O=o((r,e)=>E(r,"name",{value:e,configurable:!0}),"t");const B=O((r,e)=>new a(r,e),"createCerebro");export{a as Cerebro,b as VERBOSITY_DEBUG,c as VERBOSITY_NORMAL,f as VERBOSITY_QUIET,n as VERBOSITY_VERBOSE,I as VisulimaError,B as createCerebro};
1
+ import { Cli } from './packem_shared/Cerebro-C2mnCyQf.js';
2
+ export { VERBOSITY_DEBUG, VERBOSITY_NORMAL, VERBOSITY_QUIET, VERBOSITY_VERBOSE } from './packem_shared/VERBOSITY_QUIET-Dp46zlLW.js';
3
+ export { VisulimaError } from './packem_shared/VisulimaError-DA7QsCxH.js';
4
+
5
+ const createCerebro = (name, options) => new Cli(name, options);
6
+
7
+ export { Cli as Cerebro, createCerebro };
@@ -1 +1,34 @@
1
- var l=Object.defineProperty;var i=(o,r)=>l(o,"name",{value:r,configurable:!0});import m from"@visulima/pail/processor/caller";import c from"@visulima/pail/processor/message-formatter";import{createPail as f}from"@visulima/pail/server";import{VERBOSITY_DEBUG as g,VERBOSITY_QUIET as p}from"../packem_shared/VERBOSITY_QUIET-XPultrIA.js";import{d as E}from"../packem_shared/runtime-process-G-n-wOub.js";var u=Object.defineProperty,d=i((o,r)=>u(o,"name",{value:r,configurable:!0}),"i");const B=d(o=>{const r={16:"informational",32:"informational",64:"trace",128:"debug",256:"debug"},t=[new c],e=E().CEREBRO_OUTPUT_LEVEL;(e===String(128)||e===String(g))&&t.push(new m);const n=e&&r[e]||"informational",s={...o,logLevel:o?.logLevel??n,processors:o?.processors?[...t,...o.processors]:t},a=f(s);return e===String(p)&&a.disable(),a},"createPailLogger");export{B as default};
1
+ import CallerProcessor from '@visulima/pail/processor/caller';
2
+ import MessageFormatterProcessor from '@visulima/pail/processor/message-formatter';
3
+ import { createPail } from '@visulima/pail/server';
4
+ import { VERBOSITY_DEBUG, VERBOSITY_QUIET } from '../packem_shared/VERBOSITY_QUIET-Dp46zlLW.js';
5
+ import { d as getEnv } from '../packem_shared/runtime-process-B6ZplyWn.js';
6
+
7
+ const createPailLogger = (options) => {
8
+ const cerebroLevelToPailLevel = {
9
+ 16: "informational",
10
+ 32: "informational",
11
+ 64: "trace",
12
+ 128: "debug",
13
+ 256: "debug"
14
+ };
15
+ const processors = [new MessageFormatterProcessor()];
16
+ const env = getEnv();
17
+ const outputLevel = env.CEREBRO_OUTPUT_LEVEL;
18
+ if (outputLevel === String(128) || outputLevel === String(VERBOSITY_DEBUG)) {
19
+ processors.push(new CallerProcessor());
20
+ }
21
+ const envLogLevel = outputLevel && cerebroLevelToPailLevel[outputLevel] || "informational";
22
+ const loggerOptions = {
23
+ ...options,
24
+ logLevel: options?.logLevel ?? envLogLevel,
25
+ processors: options?.processors ? [...processors, ...options.processors] : processors
26
+ };
27
+ const logger = createPail(loggerOptions);
28
+ if (outputLevel === String(VERBOSITY_QUIET)) {
29
+ logger.disable();
30
+ }
31
+ return logger;
32
+ };
33
+
34
+ export { createPailLogger as default };