@visulima/cerebro 1.1.58 → 2.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.
- package/CHANGELOG.md +72 -1
- package/LICENSE.md +1360 -7
- package/README.md +74 -5
- package/dist/commands/completion-command.d.ts +6 -0
- package/dist/commands/completion-command.js +5 -0
- package/dist/commands/help-command.d.ts +12 -0
- package/dist/commands/help-command.js +1 -0
- package/dist/commands/readme-command.d.ts +6 -0
- package/dist/commands/readme-command.js +45 -0
- package/dist/commands/version-command.d.ts +6 -0
- package/dist/commands/version-command.js +1 -0
- package/dist/index.d.ts +39 -141
- package/dist/index.js +1 -0
- package/dist/logger/create-pail-logger.d.ts +5 -0
- package/dist/logger/create-pail-logger.js +1 -0
- package/dist/packem_chunks/has-new-version.js +1 -0
- package/dist/packem_shared/Cerebro-UuSm4ZWa.js +4 -0
- package/dist/packem_shared/VERBOSITY_QUIET-XPultrIA.js +1 -0
- package/dist/packem_shared/VisulimaError--04oA1Oy.js +76 -0
- package/dist/packem_shared/cerebro-error-BnJTixb2.js +1 -0
- package/dist/packem_shared/help-command-C_CdZQSd.js +1 -0
- package/dist/packem_shared/index-DQ3pvLQH.js +6 -0
- package/dist/packem_shared/index.d-BkzZomTF.d.ts +65 -0
- package/dist/packem_shared/isVisulimaError-jVZgumOU-C4fgdbWg.js +1 -0
- package/dist/packem_shared/plugin-manager-BjEuiNxv.d.ts +147 -0
- package/dist/packem_shared/renderError-ZMlMvw1N-eVUSdl6c.js +24 -0
- package/dist/packem_shared/runtime-process-G-n-wOub.js +1 -0
- package/dist/plugins/error-handler-plugin.d.ts +15 -0
- package/dist/plugins/error-handler-plugin.js +1 -0
- package/dist/plugins/runtime-version-check-plugin.d.ts +18 -0
- package/dist/plugins/runtime-version-check-plugin.js +1 -0
- package/dist/plugins/update-notifier/update-notifier-plugin.d.ts +21 -0
- package/dist/plugins/update-notifier/update-notifier-plugin.js +1 -0
- package/package.json +63 -27
- package/dist/index.cjs +0 -1
- package/dist/index.d.cts +0 -158
- package/dist/index.d.mts +0 -158
- package/dist/index.mjs +0 -1
- package/dist/packem_chunks/has-new-version.cjs +0 -1
- package/dist/packem_chunks/has-new-version.mjs +0 -1
- package/dist/packem_shared/default-BkkIk32s.mjs +0 -10
- package/dist/packem_shared/default-DpvcDeMt.cjs +0 -10
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<div align="center">
|
|
2
2
|
<h3>Visulima Cerebro</h3>
|
|
3
3
|
<p>
|
|
4
|
-
Cerebro is a delightful toolkit for building
|
|
4
|
+
Cerebro is a delightful toolkit for building cross-runtime command-line interfaces (CLIs) for Node.js, Deno, and Bun, built on top of
|
|
5
5
|
|
|
6
6
|
[boxen](https://github.com/visulima/visulima/tree/main/packages/boxen),
|
|
7
7
|
[colorize](https://github.com/visulima/visulima/tree/main/packages/colorize),
|
|
@@ -70,14 +70,83 @@ cli.addCommand({
|
|
|
70
70
|
await cli.run();
|
|
71
71
|
```
|
|
72
72
|
|
|
73
|
-
Now you can run your CLI with `node index.js` and you should see the following output:
|
|
73
|
+
Now you can run your CLI with `node index.js` (or `deno run index.js`, `bun index.js`) and you should see the following output:
|
|
74
74
|
|
|
75
75
|

|
|
76
76
|
|
|
77
|
-
##
|
|
77
|
+
## Shell Completions
|
|
78
78
|
|
|
79
|
-
|
|
80
|
-
|
|
79
|
+
Cerebro supports shell autocompletions for bash, zsh, fish, and powershell through the optional `@bomb.sh/tab` integration.
|
|
80
|
+
|
|
81
|
+
### Installation
|
|
82
|
+
|
|
83
|
+
To enable completions, first install the optional peer dependency:
|
|
84
|
+
|
|
85
|
+
```sh
|
|
86
|
+
pnpm add @bomb.sh/tab
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Adding Completion Command
|
|
90
|
+
|
|
91
|
+
Import and add the completion command to your CLI:
|
|
92
|
+
|
|
93
|
+
```ts
|
|
94
|
+
import Cli from "@visulima/cerebro";
|
|
95
|
+
import completionCommand from "@visulima/cerebro/command/completion";
|
|
96
|
+
|
|
97
|
+
const cli = new Cli("my-cli");
|
|
98
|
+
|
|
99
|
+
// Add your commands
|
|
100
|
+
cli.addCommand({
|
|
101
|
+
name: "build",
|
|
102
|
+
description: "Build the project",
|
|
103
|
+
options: [
|
|
104
|
+
{
|
|
105
|
+
name: "output",
|
|
106
|
+
alias: "o",
|
|
107
|
+
type: String,
|
|
108
|
+
description: "Output directory",
|
|
109
|
+
},
|
|
110
|
+
],
|
|
111
|
+
execute: ({ options }) => {
|
|
112
|
+
console.log(`Building to ${options.output || "dist"}`);
|
|
113
|
+
},
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
// Add completion command
|
|
117
|
+
cli.addCommand(completionCommand);
|
|
118
|
+
|
|
119
|
+
await cli.run();
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### Generating Completion Scripts
|
|
123
|
+
|
|
124
|
+
Users can generate completion scripts for their shell:
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
# For zsh
|
|
128
|
+
my-cli completion --shell=zsh > ~/.my-cli-completion.zsh
|
|
129
|
+
echo 'source ~/.my-cli-completion.zsh' >> ~/.zshrc
|
|
130
|
+
|
|
131
|
+
# For bash
|
|
132
|
+
my-cli completion --shell=bash > ~/.my-cli-completion.bash
|
|
133
|
+
echo 'source ~/.my-cli-completion.bash' >> ~/.bashrc
|
|
134
|
+
|
|
135
|
+
# For fish
|
|
136
|
+
my-cli completion --shell=fish > ~/.config/fish/completions/my-cli.fish
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
After setting up, users can use `TAB` to autocomplete commands and options.
|
|
140
|
+
|
|
141
|
+
## Supported Runtimes
|
|
142
|
+
|
|
143
|
+
Cerebro supports multiple JavaScript runtimes:
|
|
144
|
+
|
|
145
|
+
- **Node.js**: 18+ (follows [Node.js' release schedule](https://github.com/nodejs/release#release-schedule))
|
|
146
|
+
- **Deno**: 1.0+
|
|
147
|
+
- **Bun**: 1.0+
|
|
148
|
+
|
|
149
|
+
The library uses runtime-agnostic APIs to ensure compatibility across all supported runtimes. Here's [a post on why we think tracking Node.js releases is important](https://medium.com/the-node-js-collection/maintainers-should-consider-following-node-js-release-schedule-ab08ed4de71a).
|
|
81
150
|
|
|
82
151
|
## Contributing
|
|
83
152
|
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
var g=Object.defineProperty;var a=(e,t)=>g(e,"name",{value:t,configurable:!0});import S from"@bomb.sh/tab";import{c as $}from"../packem_shared/cerebro-error-BnJTixb2.js";var w=Object.defineProperty,y=a((e,t)=>w(e,"name",{value:t,configurable:!0}),"n");class p extends ${static{a(this,"l")}static{y(this,"CompletionError")}troubleshooting;constructor(t,o,n=[]){super(t,o,{troubleshooting:n}),this.name="CompletionError",this.troubleshooting=n,n.length>0&&(this.hint=n.join(`
|
|
2
|
+
`))}}var C=Object.defineProperty,s=a((e,t)=>C(e,"name",{value:t,configurable:!0}),"s");const h=["bash","zsh","fish","powershell"],d=["node","bun","deno"],v=s(e=>"Deno"in e,"hasDeno"),L=s(e=>"Bun"in e,"hasBun"),u=s(()=>v(globalThis)?"deno":L(globalThis)?"bun":"node","detectRuntime"),m=s(e=>{const t=e?.starshipShell??e?.shell;if(t){const r=t.toLowerCase();if(r.includes("zsh"))return"zsh";if(r.includes("bash"))return"bash";if(r.includes("fish"))return"fish"}const o=e?.psModulePath,n=e?.prompt;if(o||n?.includes("PS"))return"powershell";if(e?.comSpec?.toLowerCase().includes("cmd.exe"))return"bash"},"detectShell"),f=S,I=s((e,t)=>{for(const o of t)o.hidden||(o.name&&e.option(o.name,o.description||""),o.alias&&e.option(o.alias,o.description||""))},"registerCommandOptions"),P=s((e,t)=>{for(const[o,n]of t){if(n.name!==o||n.hidden)continue;const r=e.command(n.name,n.description||"");n.options&&I(r,n.options)}},"registerCommands"),E=s(e=>{if(!h.includes(e))throw new p(`Invalid shell type: ${e}`,"INVALID_SHELL",[`Valid shells are: ${h.join(", ")}`,"Shell will be auto-detected if not specified"])},"validateShell"),j=s(e=>{if(e&&!d.includes(e))throw new p(`Invalid runtime: ${e}`,"INVALID_RUNTIME",[`Valid runtimes are: ${d.join(", ")}`,"Runtime will be auto-detected if not specified"])},"validateRuntime"),z=s((e,t)=>{e.error("Could not detect current shell");const o=[`Usage: ${t} completion --shell=<bash|zsh|fish|powershell> [--runtime=<node|bun|deno>]`,"","Examples:"," # Install completions for zsh:",` ${t} completion --shell=zsh > ~/.${t}-completion.zsh`,` echo 'source ~/.${t}-completion.zsh' >> ~/.zshrc`,""," # Install completions for bash with custom runtime:",` ${t} completion --shell=bash --runtime=bun > ~/.${t}-completion.bash`,` echo 'source ~/.${t}-completion.bash' >> ~/.bashrc`,""," # Install completions for fish:",` ${t} completion --shell=fish > ~/.config/fish/completions/${t}.fish`].join(`
|
|
3
|
+
`);e.info(o)},"printUsageInstructions"),x={description:"Generate shell completion scripts",env:[{description:"Shell path (Unix-like systems). Used for shell detection.",name:"SHELL",type:String},{description:"Starship shell configuration. Takes precedence over SHELL for detection.",name:"STARSHIP_SHELL",type:String},{description:"PowerShell module path (Windows). Used for PowerShell detection.",name:"PSModulePath",type:String},{description:"Command prompt variable (Windows). Used for PowerShell detection.",name:"PROMPT",type:String},{description:"Command processor (Windows). Used for Windows Command Prompt detection.",name:"ComSpec",type:String}],execute:s(async({env:e,logger:t,options:o,runtime:n})=>{const r=n.getCliName(),c=o?.shell||m(e);if(!c){z(t,r);return}try{E(c),j(o?.runtime),P(f,n.getCommands());const i=`${o?.runtime||u()} ${r}`;f.setup(r,i,c)}catch(i){if(i instanceof p){const l=[`Failed to generate completion script: ${i.message}`,`Error code: ${i.code}`];throw i.troubleshooting.length>0&&l.push("","Troubleshooting:",...i.troubleshooting.map(b=>` • ${b}`)),t.error(l.join(`
|
|
4
|
+
`)),i}else{const l=["Failed to generate completion script",`Error: ${i instanceof Error?i.message:String(i)}`,"","Troubleshooting:"," • Ensure @bomb.sh/tab is installed: pnpm add @bomb.sh/tab",` • Verify shell is supported: ${h.join(", ")}`,` • Verify runtime is supported: ${d.join(", ")}`," • Check that your CLI name is correct"];t.error(l.join(`
|
|
5
|
+
`))}}},"execute"),name:"completion",options:[{defaultOption:!0,defaultValue:m(),description:"Shell type (bash, zsh, fish, powershell). Defaults to current shell if detected.",name:"shell",type:String,typeLabel:"{underline shell}"},{defaultOption:!0,defaultValue:u(),description:"JavaScript runtime (node, bun, deno). Defaults to current runtime if detected.",name:"runtime",type:String,typeLabel:"{underline runtime}"}]};export{x as default};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { b as Command, O as OptionDefinition, T as Toolbox } from '../packem_shared/plugin-manager-BjEuiNxv.js';
|
|
2
|
+
import '@visulima/tabular';
|
|
3
|
+
|
|
4
|
+
declare class HelpCommand implements Command {
|
|
5
|
+
name: string;
|
|
6
|
+
options: OptionDefinition<string>[];
|
|
7
|
+
private readonly commands;
|
|
8
|
+
constructor(commands: Map<string, Command>);
|
|
9
|
+
execute(toolbox: Toolbox): void;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export { HelpCommand as default };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"@visulima/colorize";import{O as p}from"../packem_shared/help-command-C_CdZQSd.js";import"../packem_shared/index-DQ3pvLQH.js";export{p as default};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
var S=Object.defineProperty;var f=(e,n)=>S(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
|
|
9
|
+
running command...
|
|
10
|
+
$ ${e} ${r}
|
|
11
|
+
${n}/${t??"unknown"} ${i}-${o} node-v${a}
|
|
12
|
+
$ ${e} --help [COMMAND]
|
|
13
|
+
USAGE
|
|
14
|
+
$ ${e} COMMAND
|
|
15
|
+
...
|
|
16
|
+
\`\`\`
|
|
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(`${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,O=h.commandPath?[...h.commandPath,h.name].join(" "):h.name;return _.localeCompare(O)}),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}
|
|
34
|
+
|
|
35
|
+
<!-- usage -->
|
|
36
|
+
<!-- usagestop -->
|
|
37
|
+
|
|
38
|
+
<!-- commands -->
|
|
39
|
+
<!-- commandsstop -->
|
|
40
|
+
|
|
41
|
+
<!-- toc -->
|
|
42
|
+
<!-- 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};
|
|
@@ -0,0 +1 @@
|
|
|
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};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,158 +1,56 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import
|
|
1
|
+
import { E as ExtendedLogger, C as Cli$1, a as CommandSection, O as OptionDefinition, b as Command, P as Plugin, c as PluginManager, d as CliRunOptions, R as RunCommandOptions } from './packem_shared/plugin-manager-BjEuiNxv.js';
|
|
2
|
+
export { A as ArgumentDefinition, f as EnvDefinition, e as OutputType, g as PluginContext, T as Toolbox, V as VERBOSITY_LEVEL } from './packem_shared/plugin-manager-BjEuiNxv.js';
|
|
3
|
+
export { V as VisulimaError } from './packem_shared/index.d-BkzZomTF.js';
|
|
4
|
+
import '@visulima/tabular';
|
|
5
5
|
|
|
6
|
-
type
|
|
7
|
-
|
|
8
|
-
debug?: boolean;
|
|
9
|
-
distTag?: string;
|
|
10
|
-
pkg: {
|
|
11
|
-
name: string;
|
|
12
|
-
version: string;
|
|
13
|
-
};
|
|
14
|
-
registryUrl?: string;
|
|
15
|
-
shouldNotifyInNpmScript?: boolean;
|
|
16
|
-
updateCheckInterval?: number;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
interface Content {
|
|
20
|
-
content?: string[] | string[][] | string | {
|
|
21
|
-
data: string[];
|
|
22
|
-
options: TableConstructorOptions;
|
|
23
|
-
};
|
|
24
|
-
header?: string;
|
|
25
|
-
raw?: boolean;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
type Options = Record<string, any>;
|
|
29
|
-
|
|
30
|
-
interface Toolbox extends Cerebro.ExtensionOverrides {
|
|
31
|
-
argument: string[];
|
|
32
|
-
argv: Record<string, any>;
|
|
33
|
-
command: Command;
|
|
34
|
-
commandName: string;
|
|
35
|
-
logger: Pail;
|
|
36
|
-
options: Options;
|
|
37
|
-
runtime: Cli$1;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
type TypeConstructor<T> = (value: any) => T extends (infer R)[] ? R | undefined : T | undefined;
|
|
41
|
-
type MultiplePropertyOptions<T> = any[] extends T ? {
|
|
42
|
-
lazyMultiple: true;
|
|
43
|
-
} | {
|
|
44
|
-
multiple: true;
|
|
45
|
-
} : unknown;
|
|
46
|
-
type OptionDefinition<T> = MultiplePropertyOptions<T> & Omit<OptionDefinition$1, "type|defaultValue"> & {
|
|
47
|
-
conflicts?: string[] | string;
|
|
48
|
-
defaultValue?: T | undefined;
|
|
49
|
-
description?: string | undefined;
|
|
50
|
-
hidden?: boolean;
|
|
51
|
-
implies?: Record<string, any>;
|
|
52
|
-
required?: boolean;
|
|
53
|
-
type?: TypeConstructor<T> | undefined;
|
|
54
|
-
typeLabel?: string | undefined;
|
|
55
|
-
};
|
|
56
|
-
type ArgumentDefinition<T = any> = Omit<OptionDefinition<T>, "multiple|lazyMultiple|defaultOption|alias|group|defaultValue">;
|
|
57
|
-
interface Command<O extends OptionDefinition<any> = any, TContext extends Toolbox = Toolbox> {
|
|
58
|
-
alias?: string[] | string;
|
|
59
|
-
argument?: ArgumentDefinition;
|
|
60
|
-
commandPath?: string[];
|
|
61
|
-
description?: string;
|
|
62
|
-
examples?: string[] | string[][];
|
|
63
|
-
execute: ((toolbox: TContext) => Promise<void>) | ((toolbox: TContext) => void);
|
|
64
|
-
file?: string;
|
|
65
|
-
group?: string;
|
|
66
|
-
hidden?: boolean;
|
|
67
|
-
name: string;
|
|
68
|
-
options?: (O | OptionDefinition<boolean[]> | OptionDefinition<boolean> | OptionDefinition<number[]> | OptionDefinition<number> | OptionDefinition<string[]> | OptionDefinition<string>)[];
|
|
69
|
-
usage?: Content[];
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
type ExtensionSetup = (toolbox: Toolbox) => Promise<void> | void;
|
|
73
|
-
interface Extension {
|
|
74
|
-
description?: string;
|
|
75
|
-
execute: ExtensionSetup;
|
|
76
|
-
file?: string;
|
|
77
|
-
name: string;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
type CommandSection = {
|
|
81
|
-
footer?: string;
|
|
82
|
-
header?: string;
|
|
83
|
-
};
|
|
84
|
-
type CliRunOptions = {
|
|
85
|
-
[key: string]: any;
|
|
86
|
-
shouldExitProcess?: boolean;
|
|
87
|
-
};
|
|
88
|
-
interface Cli$1 {
|
|
89
|
-
addCommand: <OD extends OptionDefinition<any> = any>(command: Command<OD>) => this;
|
|
90
|
-
addExtension: (extension: Extension) => this;
|
|
91
|
-
enableUpdateNotifier: ({ alwaysRun, distTag, updateCheckInterval }: Partial<Omit<UpdateNotifierOptions, "debug | pkg">>) => this;
|
|
92
|
-
getCliName: () => string;
|
|
93
|
-
getCommands: () => Map<string, Command>;
|
|
94
|
-
getCommandSection: () => CommandSection;
|
|
95
|
-
getCwd: () => string;
|
|
96
|
-
getPackageName: () => string | undefined;
|
|
97
|
-
getPackageVersion: () => string | undefined;
|
|
98
|
-
run: (extraOptions: CliRunOptions) => Promise<void>;
|
|
99
|
-
setCommandSection: (commandSection: CommandSection) => this;
|
|
100
|
-
setDefaultCommand: (commandName: string) => this;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
declare global {
|
|
104
|
-
namespace Cerebro {
|
|
105
|
-
interface ExtensionOverrides {
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
type CliOptions = {
|
|
111
|
-
argv?: string[];
|
|
6
|
+
type CliOptions<T extends ExtendedLogger = ExtendedLogger> = {
|
|
7
|
+
argv?: ReadonlyArray<string>;
|
|
112
8
|
cwd?: string;
|
|
113
|
-
logger?:
|
|
9
|
+
logger?: T;
|
|
114
10
|
packageName?: string;
|
|
115
11
|
packageVersion?: string;
|
|
116
12
|
};
|
|
117
|
-
declare class Cli implements Cli$1 {
|
|
118
|
-
private
|
|
119
|
-
|
|
120
|
-
private readonly cwd;
|
|
121
|
-
private readonly cliName;
|
|
122
|
-
private readonly packageVersion;
|
|
123
|
-
private readonly packageName;
|
|
124
|
-
private readonly extensions;
|
|
125
|
-
private readonly commands;
|
|
126
|
-
private defaultCommand;
|
|
127
|
-
private updateNotifierOptions;
|
|
128
|
-
private commandSection;
|
|
129
|
-
constructor(cliName: string, options?: CliOptions);
|
|
13
|
+
declare class Cli<T extends ExtendedLogger = ExtendedLogger> implements Cli$1 {
|
|
14
|
+
#private;
|
|
15
|
+
constructor(cliName: string, options?: CliOptions<T>);
|
|
130
16
|
setCommandSection(commandSection: CommandSection): this;
|
|
131
17
|
getCommandSection(): CommandSection;
|
|
132
18
|
setDefaultCommand(commandName: string): this;
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
19
|
+
get defaultCommand(): string;
|
|
20
|
+
addCommand<OD extends OptionDefinition<unknown> = OptionDefinition<unknown>>(command: Command<OD>): this;
|
|
21
|
+
addPlugin(plugin: Plugin): this;
|
|
22
|
+
getPluginManager(): PluginManager;
|
|
136
23
|
getCliName(): string;
|
|
137
24
|
getPackageVersion(): string | undefined;
|
|
138
25
|
getPackageName(): string | undefined;
|
|
139
26
|
getCommands(): Map<string, Command>;
|
|
140
27
|
getCwd(): string;
|
|
28
|
+
dispose(): void;
|
|
141
29
|
run(extraOptions?: CliRunOptions): Promise<void>;
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
30
|
+
runCommand(commandName: string, options?: RunCommandOptions): Promise<unknown>;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
declare const VERBOSITY_QUIET = 16;
|
|
34
|
+
declare const VERBOSITY_NORMAL = 32;
|
|
35
|
+
declare const VERBOSITY_VERBOSE = 64;
|
|
36
|
+
declare const VERBOSITY_DEBUG = 128;
|
|
37
|
+
|
|
38
|
+
type OptionNameToCamelCase<T extends string> = T extends `${infer Start}-${infer Rest}` ? `${Lowercase<Start>}${Capitalize<OptionNameToCamelCase<Rest>>}` : T extends `${infer Start}_${infer Rest}` ? `${Lowercase<Start>}${Capitalize<OptionNameToCamelCase<Rest>>}` : Lowercase<T>;
|
|
39
|
+
type CreateOptions<T extends Record<string, unknown>> = {
|
|
40
|
+
[K in keyof T as OptionNameToCamelCase<K & string>]: T[K];
|
|
41
|
+
};
|
|
42
|
+
type CreateEnv<T extends Record<string, unknown>> = {
|
|
43
|
+
[K in keyof T as OptionNameToCamelCase<K & string>]: T[K];
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
declare global {
|
|
47
|
+
namespace Cerebro {
|
|
48
|
+
interface ExtensionOverrides {
|
|
49
|
+
}
|
|
50
|
+
}
|
|
152
51
|
}
|
|
153
52
|
|
|
154
|
-
|
|
155
|
-
type VERBOSITY_LEVEL = 16 | 32 | 64 | 128 | 256;
|
|
53
|
+
declare const createCerebro: <T extends ExtendedLogger = ExtendedLogger>(name: string, options?: CliOptions<T>) => InstanceType<typeof Cli<T>>;
|
|
156
54
|
|
|
157
|
-
export
|
|
158
|
-
export type {
|
|
55
|
+
export { Cli as Cerebro, Cli$1 as Cli, CliRunOptions, Command, ExtendedLogger, OptionDefinition, Plugin, RunCommandOptions, VERBOSITY_DEBUG, VERBOSITY_NORMAL, VERBOSITY_QUIET, VERBOSITY_VERBOSE, createCerebro };
|
|
56
|
+
export type { CliOptions, CreateEnv, CreateOptions, OptionNameToCamelCase };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var t=Object.defineProperty;var o=(r,e)=>t(r,"name",{value:e,configurable:!0});import{Cli as a}from"./packem_shared/Cerebro-UuSm4ZWa.js";import{VERBOSITY_DEBUG as V,VERBOSITY_NORMAL as b,VERBOSITY_QUIET as c,VERBOSITY_VERBOSE as f}from"./packem_shared/VERBOSITY_QUIET-XPultrIA.js";import{p as I}from"./packem_shared/isVisulimaError-jVZgumOU-C4fgdbWg.js";var E=Object.defineProperty,O=o((r,e)=>E(r,"name",{value:e,configurable:!0}),"t");const p=O((r,e)=>new a(r,e),"createCerebro");export{a as Cerebro,V as VERBOSITY_DEBUG,b as VERBOSITY_NORMAL,c as VERBOSITY_QUIET,f as VERBOSITY_VERBOSE,I as VisulimaError,p as createCerebro};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var n=Object.defineProperty;var a=(e,r)=>n(e,"name",{value:r,configurable:!0});import i from"@visulima/pail/processor/caller";import m from"@visulima/pail/processor/message-formatter";import{createPail as s}from"@visulima/pail/server";import{VERBOSITY_DEBUG as f,VERBOSITY_QUIET as l}from"../packem_shared/VERBOSITY_QUIET-XPultrIA.js";import{d as c}from"../packem_shared/runtime-process-G-n-wOub.js";var g=Object.defineProperty,p=a((e,r)=>g(e,"name",{value:r,configurable:!0}),"i");const S=p(async()=>{const e={16:"informational",32:"informational",64:"trace",128:"debug",256:"debug"},r=[new m],o=c().CEREBRO_OUTPUT_LEVEL;(o===String(128)||o===String(f))&&r.push(new i);const t=s({logLevel:o&&e[o]||"informational",processors:r});return o===String(l)&&t.disable(),t},"createPailLogger");export{S as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var Xt=Object.defineProperty;var _=(r,a)=>Xt(r,"name",{value:a,configurable:!0});import{createRequire as en}from"node:module";import{findCacheDirSync as sn}from"@visulima/find-cache-dir";import{c as an}from"../packem_shared/cerebro-error-BnJTixb2.js";const tn=en(import.meta.url),U=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,ve=_(r=>{if(typeof U<"u"&&U.versions&&U.versions.node){const[a,i]=U.versions.node.split(".").map(Number);if(a>22||a===22&&i>=3||a===20&&i>=16)return U.getBuiltinModule(r)}return tn(r)},"__cjs_getBuiltinModule"),{existsSync:be,mkdirSync:nn,writeFileSync:rn,readFileSync:on}=ve("node:fs"),{get:cn}=ve("node:https");var un=Object.defineProperty,ln=_((r,a)=>un(r,"name",{value:a,configurable:!0}),"o$1");const fn=ln((r,a)=>{const i=r.split(".").map(Number),f=a.split(".").map(Number);for(const[d,h]of i.entries()){if(h>f[d])return!0;if(h<f[d])return!1}return!1},"semverGt");var pn=Object.defineProperty,gn=_((r,a)=>pn(r,"name",{value:a,configurable:!0}),"$e"),dn=Object.defineProperty,H=gn((r,a)=>dn(r,"name",{value:a,configurable:!0}),"W"),hn=Object.defineProperty,u=H((r,a)=>hn(r,"name",{value:a,configurable:!0}),"u$1");let xe=u(()=>{var r=(()=>{var a=Object.defineProperty,i=Object.getOwnPropertyDescriptor,f=Object.getOwnPropertyNames,d=Object.prototype.hasOwnProperty,h=u((e,t)=>{for(var n in t)a(e,n,{get:t[n],enumerable:!0})},"ne"),$=u((e,t,n,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of f(t))!d.call(e,o)&&o!==n&&a(e,o,{get:u(()=>t[o],"get"),enumerable:!(s=i(t,o))||s.enumerable});return e},"ae"),m=u(e=>$(a({},"__esModule",{value:!0}),e),"oe"),y={};h(y,{zeptomatch:u(()=>me,"zeptomatch")});var K=u(e=>{const t=new Set,n=[e];for(let s=0;s<n.length;s++){const o=n[s];if(t.has(o))continue;t.add(o);const{children:c}=o;if(c?.length)for(let l=0,g=c.length;l<g;l++)n.push(c[l])}return Array.from(t)},"M"),Ee=u(e=>{let t="";const n=K(e);for(let s=0,o=n.length;s<o;s++){const c=n[s];if(!c.regex)continue;const l=c.regex.flags;if(t||(t=l),t!==l)throw new Error(`Inconsistent RegExp flags used: "${t}" and "${l}"`)}return t},"se"),Q=u((e,t,n)=>{const s=n.get(e);if(s!==void 0)return s;const o=e.partial??t;let c="";if(e.regex&&(c+=o?"(?:$|":"",c+=e.regex.source),e.children?.length){const l=Re(e.children.map(g=>Q(g,t,n)).filter(Boolean));if(l?.length){const g=e.children.some(I=>!I.regex||!(I.partial??t)),v=l.length>1||o&&(!c.length||g);c+=v?o?"(?:$|":"(?:":"",c+=l.join("|"),c+=v?")":""}}return e.regex&&(c+=o?")":""),n.set(e,c),c},"O"),ke=u((e,t)=>{const n=new Map,s=K(e);for(let o=s.length-1;o>=0;o--){const c=Q(s[o],t,n);if(!(o>0))return c}return""},"ie"),Re=u(e=>Array.from(new Set(e)),"ue"),D=u((e,t,n)=>D.compile(e,n).test(t),"R");D.compile=(e,t)=>{const n=t?.partial??!1,s=ke(e,n),o=Ee(e);return new RegExp(`^(?:${s})$`,o)};var Ae=D,Me=u((e,t)=>{const n=Ae.compile(e,t),s=`${n.source.slice(0,-1)}[\\\\/]?$`,o=n.flags;return new RegExp(s,o)},"le"),Ne=Me,Pe=u(e=>{const t=e.map(s=>s.source).join("|")||"$^",n=e[0]?.flags;return new RegExp(t,n)},"ve"),ze=Pe,X=u(e=>Array.isArray(e),"j"),z=u(e=>typeof e=="function","_"),Ce=u(e=>e.length===0,"he"),Ie=(()=>{const{toString:e}=Function.prototype,t=/(?:^\(\s*(?:[^,.()]|\.(?!\.\.))*\s*\)\s*=>|^\s*[a-zA-Z$_][a-zA-Z0-9$_]*\s*=>)/;return n=>(n.length===0||n.length===1)&&t.test(e.call(n))})(),Se=u(e=>typeof e=="number","de"),Ue=u(e=>typeof e=="object"&&e!==null,"xe"),Te=u(e=>e instanceof RegExp,"me"),Be=(()=>{const e=/\\\(|\((?!\?(?::|=|!|<=|<!))/;return t=>e.test(t.source)})(),De=(()=>{const e=/^[a-zA-Z0-9_-]+$/;return t=>e.test(t.source)&&!t.flags.includes("i")})(),ee=u(e=>typeof e=="string","A"),O=u(e=>e===void 0,"f"),Fe=u(e=>{const t=new Map;return n=>{const s=t.get(n);if(s!==void 0)return s;const o=e(n);return t.set(n,o),o}},"ye"),te=u((e,t,n={})=>{const s={cache:{},input:e,index:0,indexBacktrackMax:0,options:n,output:[]},o=E(t)(s),c=Math.max(s.index,s.indexBacktrackMax);if(o&&s.index===e.length)return s.output;throw new Error(`Failed to parse at index ${c}`)},"I"),p=u((e,t)=>X(e)?Le(e,t):ee(e)?ne(e,t):qe(e,t),"i"),Le=u((e,t)=>{const n={};for(const s of e){if(s.length!==1)throw new Error(`Invalid character: "${s}"`);const o=s.charCodeAt(0);n[o]=!0}return s=>{const o=s.input;let c=s.index,l=c;for(;l<o.length&&o.charCodeAt(l)in n;)l+=1;if(l>c){if(!O(t)&&!s.options.silent){const g=o.slice(c,l),v=z(t)?t(g,o,`${c}`):t;O(v)||s.output.push(v)}s.index=l}return!0}},"we"),qe=u((e,t)=>{if(De(e))return ne(e.source,t);{const n=e.source,s=e.flags.replace(/y|$/,"y"),o=new RegExp(n,s);return Be(e)&&z(t)&&!Ie(t)?We(o,t):Ze(o,t)}},"$e"),We=u((e,t)=>n=>{const s=n.index,o=n.input;e.lastIndex=s;const c=e.exec(o);if(c){const l=e.lastIndex;if(!n.options.silent){const g=t(...c,o,`${s}`);O(g)||n.output.push(g)}return n.index=l,!0}else return!1},"Ee"),Ze=u((e,t)=>n=>{const s=n.index,o=n.input;if(e.lastIndex=s,e.test(o)){const c=e.lastIndex;if(!O(t)&&!n.options.silent){const l=z(t)?t(o.slice(s,c),o,`${s}`):t;O(l)||n.output.push(l)}return n.index=c,!0}else return!1},"Ce"),ne=u((e,t)=>n=>{const s=n.index,o=n.input;if(o.startsWith(e,s)){if(!O(t)&&!n.options.silent){const c=z(t)?t(e,o,`${s}`):t;O(c)||n.output.push(c)}return n.index+=e.length,!0}else return!1},"F"),F=u((e,t,n,s)=>{const o=E(e),c=t>1;return q(L(oe(l=>{let g=0;for(;g<n;){const v=l.index;if(!o(l)||(g+=1,l.index===v))break}return g>=t},c),s))},"k"),re=u((e,t)=>F(e,0,1,t),"L"),B=u((e,t)=>F(e,0,1/0,t),"$"),Ve=u((e,t)=>F(e,1,1/0,t),"Re"),M=u((e,t)=>{const n=e.map(E);return q(L(oe(s=>{for(let o=0,c=n.length;o<c;o++)if(!n[o](s))return!1;return!0}),t))},"x"),w=u((e,t)=>{const n=e.map(E);return q(L(s=>{for(let o=0,c=n.length;o<c;o++)if(n[o](s))return!0;return!1},t))},"p"),oe=u((e,t=!0,n=!1)=>{const s=E(e);return t?o=>{const c=o.index,l=o.output.length,g=s(o);return!g&&!n&&(o.indexBacktrackMax=Math.max(o.indexBacktrackMax,o.index)),(!g||n)&&(o.index=c,o.output.length!==l&&(o.output.length=l)),g}:s},"q"),L=u((e,t)=>{const n=E(e);return t?s=>{if(s.options.silent)return n(s);const o=s.output.length;if(n(s)){const c=s.output.splice(o,1/0),l=t(c);return O(l)||s.output.push(l),!0}else return!1}:n},"B"),q=(()=>{let e=0;return t=>{const n=E(t),s=e+=1;return o=>{var c;if(o.options.memoization===!1)return n(o);const l=o.index,g=(c=o.cache)[s]||(c[s]={indexMax:-1,queue:[]}),v=g.queue;if(l<=g.indexMax){const S=g.store||(g.store=new Map);if(v.length){for(let P=0,Yt=v.length;P<Yt;P+=2){const Kt=v[P*2],Qt=v[P*2+1];S.set(Kt,Qt)}v.length=0}const j=S.get(l);if(j===!1)return!1;if(Se(j))return o.index=j,!0;if(j)return o.index=j.index,j.output?.length&&o.output.push(...j.output),!0}const I=o.output.length,Ht=n(o);if(g.indexMax=Math.max(g.indexMax,l),Ht){const S=o.index,j=o.output.length;if(j>I){const P=o.output.slice(I,j);v.push(l,{index:S,output:P})}else v.push(l,S);return!0}else return v.push(l,!1),!1}}})(),se=u(e=>{let t;return n=>(t||(t=E(e())),t(n))},"G"),E=Fe(e=>{if(z(e))return Ce(e)?se(e):e;if(ee(e)||Te(e))return p(e);if(X(e))return M(e);if(Ue(e))return w(Object.values(e));throw new Error("Invalid rule")}),R=u(e=>e,"d"),Ge=u(e=>typeof e=="string","ke"),Je=u(e=>{const t=new WeakMap,n=new WeakMap;return(s,o)=>{const c=o?.partial?n:t,l=c.get(s);if(l!==void 0)return l;const g=e(s,o);return c.set(s,g),g}},"Be"),He=u(e=>{const t={},n={};return(s,o)=>{const c=o?.partial?n:t;return c[s]??(c[s]=e(s,o))}},"Pe"),Ye=p(/\\./,R),Ke=p(/./,R),Qe=p(/\*\*\*+/,"*"),Xe=p(/([^/{[(!])\*\*/,(e,t)=>`${t}*`),et=p(/(^|.)\*\*(?=[^*/)\]}])/,(e,t)=>`${t}*`),tt=B(w([Ye,Qe,Xe,et,Ke])),nt=tt,rt=u(e=>te(e,nt,{memoization:!1}).join(""),"Ie"),ot=rt,ae="abcdefghijklmnopqrstuvwxyz",st=u(e=>{let t="";for(;e>0;){const n=(e-1)%26;t=ae[n]+t,e=Math.floor((e-1)/26)}return t},"Le"),ie=u(e=>{let t=0;for(let n=0,s=e.length;n<s;n++)t=t*26+ae.indexOf(e[n])+1;return t},"V"),W=u((e,t)=>{if(t<e)return W(t,e);const n=[];for(;e<=t;)n.push(e++);return n},"b"),at=u((e,t,n)=>W(e,t).map(s=>String(s).padStart(n,"0")),"qe"),ce=u((e,t)=>W(ie(e),ie(t)).map(st),"W"),x=u(e=>({partial:!1,regex:new RegExp(e,"s"),children:[]}),"c"),C=u(e=>({children:e}),"y"),N=(()=>{const e=u((t,n,s)=>{if(s.has(t))return;s.add(t);const{children:o}=t;if(!o.length)o.push(n);else for(let c=0,l=o.length;c<l;c++)e(o[c],n,s)},"e");return t=>{if(!t.length)return C([]);for(let n=t.length-1;n>=1;n--){const s=new Set,o=t[n-1],c=t[n];e(o,c,s)}return t[0]}})(),k=u(()=>({regex:new RegExp("[\\\\/]","s"),children:[]}),"g"),it=p(/\\./,x),ct=p(/[$.*+?^(){}[\]\|]/,e=>x(`\\${e}`)),ut=p(/[\\\/]/,k),lt=p(/[^$.*+?^(){}[\]\|\\\/]+/,x),ft=p(/^(?:!!)*!(.*)$/,(e,t)=>x(`(?!^${me.compile(t).source}$).*?`)),pt=p(/^(!!)+/),gt=w([ft,pt]),dt=p(/\/(\*\*\/)+/,()=>C([N([k(),x(".+?"),k()]),k()])),ht=p(/^(\*\*\/)+/,()=>C([x("^"),N([x(".*?"),k()])])),mt=p(/\/(\*\*)$/,()=>C([N([k(),x(".*?")]),x("$")])),xt=p(/\*\*/,()=>x(".*?")),ue=w([dt,ht,mt,xt]),$t=p(/\*\/(?!\*\*\/|\*$)/,()=>N([x("[^\\\\/]*?"),k()])),vt=p(/\*/,()=>x("[^\\\\/]*")),le=w([$t,vt]),fe=p("?",()=>x("[^\\\\/]")),bt=p("[",R),yt=p("]",R),wt=p(/[!^]/,"^\\\\/"),jt=p(/[a-z]-[a-z]|[0-9]-[0-9]/i,R),_t=p(/\\./,R),Ot=p(/[$.*+?^(){}[\|]/,e=>`\\${e}`),Et=p(/[\\\/]/,"\\\\/"),kt=p(/[^$.*+?^(){}[\]\|\\\/]+/,R),Rt=w([_t,Ot,Et,jt,kt]),pe=M([bt,re(wt),B(Rt),yt],e=>x(e.join(""))),At=p("{","(?:"),Mt=p("}",")"),Nt=p(/(\d+)\.\.(\d+)/,(e,t,n)=>at(+t,+n,Math.min(t.length,n.length)).join("|")),Pt=p(/([a-z]+)\.\.([a-z]+)/,(e,t,n)=>ce(t,n).join("|")),zt=p(/([A-Z]+)\.\.([A-Z]+)/,(e,t,n)=>ce(t.toLowerCase(),n.toLowerCase()).join("|").toUpperCase()),Ct=w([Nt,Pt,zt]),ge=M([At,Ct,Mt],e=>x(e.join(""))),It=p("{"),St=p("}"),Ut=p(","),Tt=p(/\\./,x),Bt=p(/[$.*+?^(){[\]\|]/,e=>x(`\\${e}`)),Dt=p(/[\\\/]/,k),Ft=p(/[^$.*+?^(){}[\]\|\\\/,]+/,x),Lt=se(()=>he),qt=p("",()=>x("(?:)")),Wt=Ve(w([ue,le,fe,pe,ge,Lt,Tt,Bt,Dt,Ft]),N),de=w([Wt,qt]),he=M([It,re(M([de,B(M([Ut,de]))])),St],C),Zt=B(w([gt,ue,le,fe,pe,ge,he,it,ct,ut,lt]),N),Vt=Zt,Gt=u(e=>te(e,Vt,{memoization:!1})[0],"kr"),Jt=Gt,Z=u((e,t,n)=>Z.compile(e,n).test(t),"N");Z.compile=(()=>{const e=He((n,s)=>Ne(Jt(ot(n)),s)),t=Je((n,s)=>ze(n.map(o=>e(o,s))));return(n,s)=>Ge(n)?e(n,s):t(n,s)})();var me=Z;return m(y)})();return r.default||r},"_lazyMatch"),V;const mn=u((r,a)=>(V||(V=xe(),xe=null),V(r,a)),"default");var xn=Object.defineProperty,$n=H((r,a)=>xn(r,"name",{value:a,configurable:!0}),"t");const vn=/^[A-Z]:\//i,A=$n((r="")=>r&&r.replaceAll("\\","/").replace(vn,a=>a.toUpperCase()),"normalizeWindowsPath");var bn=Object.defineProperty,b=H((r,a)=>bn(r,"name",{value:a,configurable:!0}),"r");const yn=/^[/\\]{2}/,wn=/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Z]:[/\\]/i,ye=/^[A-Z]:$/i,$e=/^\/([A-Z]:)?$/i,jn=/.(\.[^./]+)$/,_n=/^[/\\]|^[a-z]:[/\\]/i,On=b(()=>typeof process.cwd=="function"?process.cwd().replaceAll("\\","/"):"/","cwd"),we=b((r,a)=>{let i="",f=0,d=-1,h=0,$;for(let m=0;m<=r.length;++m){if(m<r.length)$=r[m];else{if($==="/")break;$="/"}if($==="/"){if(!(d===m-1||h===1))if(h===2){if(i.length<2||f!==2||!i.endsWith(".")||i.at(-2)!=="."){if(i.length>2){const y=i.lastIndexOf("/");y===-1?(i="",f=0):(i=i.slice(0,y),f=i.length-1-i.lastIndexOf("/")),d=m,h=0;continue}else if(i.length>0){i="",f=0,d=m,h=0;continue}}a&&(i+=i.length>0?"/..":"..",f=2)}else i.length>0?i+=`/${r.slice(d+1,m)}`:i=r.slice(d+1,m),f=m-d-1;d=m,h=0}else $==="."&&h!==-1?++h:h=-1}return i},"normalizeString"),T=b(r=>wn.test(r),"isAbsolute"),je=b(function(r){if(r.length===0)return".";r=A(r);const a=yn.exec(r),i=T(r),f=r.at(-1)==="/";return r=we(r,!i),r.length===0?i?"/":f?"./":".":(f&&(r+="/"),ye.test(r)&&(r+="/"),a?i?`//${r}`:`//./${r}`:i&&!T(r)?`/${r}`:r)},"normalize"),En=b((...r)=>{let a="";for(const i of r)if(i)if(a.length>0){const f=a[a.length-1]==="/",d=i[0]==="/";f&&d?a+=i.slice(1):a+=f||d?i:`/${i}`}else a+=i;return je(a)},"join"),G=b(function(...r){r=r.map(f=>A(f));let a="",i=!1;for(let f=r.length-1;f>=-1&&!i;f--){const d=f>=0?r[f]:On();!d||d.length===0||(a=`${d}/${a}`,i=T(d))}return a=we(a,!i),i&&!T(a)?`/${a}`:a.length>0?a:"."},"resolve");b(function(r){return A(r)},"toNamespacedPath");const kn=b(function(r){return jn.exec(A(r))?.[1]??""},"extname");b(function(r,a){const i=G(r).replace($e,"$1").split("/"),f=G(a).replace($e,"$1").split("/");if(f[0][1]===":"&&i[0][1]===":"&&i[0]!==f[0])return f.join("/");const d=[...i];for(const h of d){if(f[0]!==h)break;i.shift(),f.shift()}return[...i.map(()=>".."),...f].join("/")},"relative");const _e=b(r=>{const a=A(r).replace(/\/$/,"").split("/").slice(0,-1);return a.length===1&&ye.test(a[0])&&(a[0]+="/"),a.join("/")||(T(r)?"/":".")},"dirname");b(function(r){const a=[r.root,r.dir,r.base??r.name+r.ext].filter(Boolean);return A(r.root?G(...a):a.join("/"))},"format");const Rn=b((r,a)=>{const i=A(r).split("/").pop();return a&&i.endsWith(a)?i.slice(0,-a.length):i},"basename");b(function(r){const a=_n.exec(r)?.[0]?.replaceAll("\\","/")??"",i=Rn(r),f=kn(i);return{base:i,dir:_e(r),ext:f,name:i.slice(0,i.length-f.length),root:a}},"parse");b((r,a)=>mn(a,je(r)),"matchesGlob");var An=Object.defineProperty,Mn=_((r,a)=>An(r,"name",{value:a,configurable:!0}),"e");let J=class extends an{static{_(this,"p")}static{Mn(this,"UpdateNotifierError")}constructor(a,i="UPDATE_NOTIFIER_ERROR",f){super(a,i,f),this.name="UpdateNotifierError"}};var Nn=Object.defineProperty,Y=_((r,a)=>Nn(r,"name",{value:a,configurable:!0}),"n");const Pn="last-update-check.json",Oe=Y(r=>{const a=sn(r);if(a===void 0)throw new J("Could not find cache directory","CACHE_DIRECTORY_NOT_FOUND",{packageName:r});return En(a,Pn)},"getConfigFile"),zn=Y(r=>{const a=Oe(r);try{if(!be(a))return;const{lastUpdateCheck:i}=JSON.parse(on(a,"utf8"));return i}catch{return}},"getLastUpdate"),Cn=Y(r=>{const a=Oe(r),i=_e(a);be(i)||nn(i,{recursive:!0}),rn(a,JSON.stringify({lastUpdateCheck:Date.now()}))},"saveLastUpdate");var In=Object.defineProperty,Sn=_((r,a)=>In(r,"name",{value:a,configurable:!0}),"g");const Un=Sn(async(r,a,i)=>{const f=i.replace("__NAME__",r);return await new Promise((d,h)=>{cn(f,$=>{let m="";$.on("data",y=>m+=y),$.on("end",()=>{try{const y=JSON.parse(m)[a];y||h(new J("Error getting version","VERSION_FETCH_ERROR",{distributionTag:a,packageName:r})),d(y)}catch{h(new J("Could not parse version response","VERSION_PARSE_ERROR",{distributionTag:a,packageName:r}))}})}).on("error",$=>h($))})},"getDistributionVersion");var Tn=Object.defineProperty,Bn=_((r,a)=>Tn(r,"name",{value:a,configurable:!0}),"i");const Zn=Bn(async({alwaysRun:r,debug:a,distTag:i="latest",pkg:f,registryUrl:d="https://registry.npmjs.org/-/package/__NAME__/dist-tags",updateCheckInterval:h=1e3*60*60*24})=>{const $=zn(f.name);if(r||!$||$<Date.now()-h){const m=await Un(f.name,i,d);if(Cn(f.name),fn(m,f.version))return m;a&&console.error(`Latest version (${m}) not newer than current version (${f.version})`)}else a&&console.error(`Too recent to check for a new update. simpleUpdateNotifier() interval set to ${h}ms but only ${Date.now()-$}ms since last check.`)},"hasNewVersion");export{Zn as default};
|