@visulima/cerebro 1.0.18 → 1.0.20

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 CHANGED
@@ -1,3 +1,24 @@
1
+ ## @visulima/cerebro [1.0.20](https://github.com/visulima/visulima/compare/@visulima/cerebro@1.0.19...@visulima/cerebro@1.0.20) (2024-04-05)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **cerebro:** fixed exit handling on cli run ([e3f86a9](https://github.com/visulima/visulima/commit/e3f86a91074d0bcc452e821eecacc78d2f580dca))
7
+
8
+
9
+
10
+ ### Dependencies
11
+
12
+ * **@visulima/package:** upgraded to 1.6.2
13
+
14
+ ## @visulima/cerebro [1.0.19](https://github.com/visulima/visulima/compare/@visulima/cerebro@1.0.18...@visulima/cerebro@1.0.19) (2024-04-02)
15
+
16
+
17
+
18
+ ### Dependencies
19
+
20
+ * **@visulima/package:** upgraded to 1.6.1
21
+
1
22
  ## @visulima/cerebro [1.0.18](https://github.com/visulima/visulima/compare/@visulima/cerebro@1.0.17...@visulima/cerebro@1.0.18) (2024-04-02)
2
23
 
3
24
 
package/dist/index.cjs CHANGED
@@ -4,31 +4,31 @@ var process$1 = require('process');
4
4
  var boxen = require('@visulima/boxen');
5
5
  var colorize = require('@visulima/colorize');
6
6
  var server = require('@visulima/pail/server');
7
- var mt = require('command-line-args');
8
- var w = require('cli-table3');
9
- var ye = require('@visulima/colorize/template');
10
- var Oe = require('os');
7
+ var ct = require('command-line-args');
8
+ var N = require('cli-table3');
9
+ var be = require('@visulima/colorize/template');
10
+ var Ce = require('os');
11
11
  var fastestLevenshtein = require('fastest-levenshtein');
12
12
 
13
13
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
14
14
 
15
- var mt__default = /*#__PURE__*/_interopDefault(mt);
16
- var w__default = /*#__PURE__*/_interopDefault(w);
17
- var ye__default = /*#__PURE__*/_interopDefault(ye);
18
- var Oe__default = /*#__PURE__*/_interopDefault(Oe);
15
+ var ct__default = /*#__PURE__*/_interopDefault(ct);
16
+ var N__default = /*#__PURE__*/_interopDefault(N);
17
+ var be__default = /*#__PURE__*/_interopDefault(be);
18
+ var Ce__default = /*#__PURE__*/_interopDefault(Ce);
19
19
 
20
- var me=/[\p{Lu}]/u,ce=/[\p{Ll}]/u,U=/^[\p{Lu}](?![\p{Lu}])/gu,j=/([\p{Alpha}\p{N}_]|$)/u,v=/[_.\- ]+/,de=new RegExp("^"+v.source),k=new RegExp(v.source+j.source,"gu"),M=new RegExp("\\d+"+j.source,"gu"),ge=(o,e,t,i)=>{let s=!1,n=!1,r=!1,a=!1;for(let l=0;l<o.length;l++){let c=o[l];a=l>2?o[l-3]==="-":!0,s&&me.test(c)?(o=o.slice(0,l)+"-"+o.slice(l),s=!1,r=n,n=!0,l++):n&&r&&ce.test(c)&&(!a||i)?(o=o.slice(0,l-1)+"-"+o.slice(l-1),r=n,n=!1,s=!0):(s=e(c)===c&&t(c)!==c,r=n,n=t(c)===c&&e(c)!==c);}return o},ue=(o,e)=>(U.lastIndex=0,o.replaceAll(U,t=>e(t))),fe=(o,e)=>(k.lastIndex=0,M.lastIndex=0,o.replaceAll(M,(t,i,s)=>["_","-"].includes(o.charAt(s+t.length))?t:e(t)).replaceAll(k,(t,i)=>e(i)));function I(o,e){if(!(typeof o=="string"||Array.isArray(o)))throw new TypeError("Expected the input to be `string | string[]`");if(e={pascalCase:!1,preserveConsecutiveUppercase:!1,...e},Array.isArray(o)?o=o.map(n=>n.trim()).filter(n=>n.length).join("-"):o=o.trim(),o.length===0)return "";let t=e.locale===!1?n=>n.toLowerCase():n=>n.toLocaleLowerCase(e.locale),i=e.locale===!1?n=>n.toUpperCase():n=>n.toLocaleUpperCase(e.locale);return o.length===1?v.test(o)?"":e.pascalCase?i(o):t(o):(o!==t(o)&&(o=ge(o,t,i,e.preserveConsecutiveUppercase)),o=o.replace(de,""),o=e.preserveConsecutiveUppercase?ue(o,t):t(o),e.pascalCase&&(o=i(o.charAt(0))+o.slice(1)),fe(o,i))}var he=[{description:"Turn on verbose output",group:"global",name:"verbose",type:Boolean},{description:"Turn on debugging output",group:"global",name:"debug",type:Boolean},{alias:"h",description:"Print out helpful usage information",group:"global",name:"help",type:Boolean},{alias:"q",description:"Silence output",group:"global",name:"quiet",type:Boolean},{alias:"V",description:"Print version info",group:"global",name:"version",type:Boolean},{description:"Turn off colored output",group:"global",name:"no-color",type:Boolean},{description:"Force colored output",group:"global",name:"color",type:Boolean}],y=he;var be=o=>o?ye__default.default(Object.assign([],{raw:[o.replaceAll("`","\\`")]})):"",m=be;var x=class{lines;constructor(){this.lines=[];}add(e){this.lines.push(e);}toString(){return this.lines.join(Oe__default.default.EOL)}header(e){this.add(colorize.bold(e)),this.lines.push("");}},C=x;var T={chars:{bottom:"","bottom-left":"","bottom-mid":"","bottom-right":"",left:" ","left-mid":"",mid:"","mid-mid":"",middle:" ",right:"","right-mid":"",top:"","top-left":"","top-mid":"","top-right":""},colWidths:[40,60],style:{border:[],compact:!0,head:[],"padding-left":2,"padding-right":1},wordWrap:!0},N=class extends C{constructor(e){if(super(),e.header&&this.header(m(e.header)),e.content){if(e.raw)if(Array.isArray(e.content)&&e.content.every(t=>typeof t=="string"))e.content.forEach(t=>{Array.isArray(t)?t.forEach(i=>this.add(m(i))):this.add(m(t));});else if(typeof e.content=="string")this.add(m(e.content));else throw new TypeError("Invalid raw content, must be a string or array of strings.");else this.add(this.getContentLines(e.content));this.add("");}}getContentLines(e){if(typeof e=="string"){let t=new w__default.default({...T,colWidths:[80]});return t.push([m(e)]),t.toString()}if(Array.isArray(e)&&e.every(t=>typeof t=="string"||Array.isArray(t)&&t.every(i=>typeof i=="string"))){let t=new w__default.default({...T});return e.forEach(i=>{Array.isArray(i)?t.push(i.map(s=>m(s))):t.push([m(i)]);}),t.toString()}if(typeof e=="object"){let t=e;if(!t.options||!t.data)throw new Error(`Must have an "options" or "data" property
21
- ${JSON.stringify(e)}`);let i=new w__default.default({...T,...t.options,style:{...T.style,...t.options.style}});return t.data.forEach(s=>{Array.isArray(s)?i.push(s.map(n=>m(n))):i.push([m(s)]);}),i.toString()}throw new Error(`invalid input - 'content' must be a string, array of strings or a object:
20
+ var ce=/[\p{Lu}]/u,de=/[\p{Ll}]/u,k=/^[\p{Lu}](?![\p{Lu}])/gu,Y=/([\p{Alpha}\p{N}_]|$)/u,x=/[_.\- ]+/,ge=new RegExp("^"+x.source),M=new RegExp(x.source+Y.source,"gu"),j=new RegExp("\\d+"+Y.source,"gu"),ue=(o,e,t,n)=>{let r=!1,i=!1,s=!1,a=!1;for(let l=0;l<o.length;l++){let m=o[l];a=l>2?o[l-3]==="-":!0,r&&ce.test(m)?(o=o.slice(0,l)+"-"+o.slice(l),r=!1,s=i,i=!0,l++):i&&s&&de.test(m)&&(!a||n)?(o=o.slice(0,l-1)+"-"+o.slice(l-1),s=i,i=!1,r=!0):(r=e(m)===m&&t(m)!==m,s=i,i=t(m)===m&&e(m)!==m);}return o},fe=(o,e)=>(k.lastIndex=0,o.replaceAll(k,t=>e(t))),he=(o,e)=>(M.lastIndex=0,j.lastIndex=0,o.replaceAll(j,(t,n,r)=>["_","-"].includes(o.charAt(r+t.length))?t:e(t)).replaceAll(M,(t,n)=>e(n)));function w(o,e){if(!(typeof o=="string"||Array.isArray(o)))throw new TypeError("Expected the input to be `string | string[]`");if(e={pascalCase:!1,preserveConsecutiveUppercase:!1,...e},Array.isArray(o)?o=o.map(i=>i.trim()).filter(i=>i.length).join("-"):o=o.trim(),o.length===0)return "";let t=e.locale===!1?i=>i.toLowerCase():i=>i.toLocaleLowerCase(e.locale),n=e.locale===!1?i=>i.toUpperCase():i=>i.toLocaleUpperCase(e.locale);return o.length===1?x.test(o)?"":e.pascalCase?n(o):t(o):(o!==t(o)&&(o=ue(o,t,n,e.preserveConsecutiveUppercase)),o=o.replace(ge,""),o=e.preserveConsecutiveUppercase?fe(o,t):t(o),e.pascalCase&&(o=n(o.charAt(0))+o.slice(1)),he(o,n))}var ye=[{description:"Turn on verbose output",group:"global",name:"verbose",type:Boolean},{description:"Turn on debugging output",group:"global",name:"debug",type:Boolean},{alias:"h",description:"Print out helpful usage information",group:"global",name:"help",type:Boolean},{alias:"q",description:"Silence output",group:"global",name:"quiet",type:Boolean},{alias:"V",description:"Print version info",group:"global",name:"version",type:Boolean},{description:"Turn off colored output",group:"global",name:"no-color",type:Boolean},{description:"Force colored output",group:"global",name:"color",type:Boolean}],y=ye;var Oe=o=>o?be__default.default(Object.assign([],{raw:[o.replaceAll("`","\\`")]})):"",c=Oe;var A=class{lines;constructor(){this.lines=[];}add(e){this.lines.push(e);}toString(){return this.lines.join(Ce__default.default.EOL)}header(e){this.add(colorize.bold(e)),this.lines.push("");}},T=A;var E={chars:{bottom:"","bottom-left":"","bottom-mid":"","bottom-right":"",left:" ","left-mid":"",mid:"","mid-mid":"",middle:" ",right:"","right-mid":"",top:"","top-left":"","top-mid":"","top-right":""},colWidths:[40,60],style:{border:[],compact:!0,head:[],"padding-left":2,"padding-right":1},wordWrap:!0},L=class extends T{constructor(e){if(super(),e.header&&this.header(c(e.header)),e.content){if(e.raw)if(Array.isArray(e.content)&&e.content.every(t=>typeof t=="string"))e.content.forEach(t=>{Array.isArray(t)?t.forEach(n=>this.add(c(n))):this.add(c(t));});else if(typeof e.content=="string")this.add(c(e.content));else throw new TypeError("Invalid raw content, must be a string or array of strings.");else this.add(this.getContentLines(e.content));this.add("");}}getContentLines(e){if(typeof e=="string"){let t=new N__default.default({...E,colWidths:[80]});return t.push([c(e)]),t.toString()}if(Array.isArray(e)&&e.every(t=>typeof t=="string"||Array.isArray(t)&&t.every(n=>typeof n=="string"))){let t=new N__default.default({...E});return e.forEach(n=>{Array.isArray(n)?t.push(n.map(r=>c(r))):t.push([c(n)]);}),t.toString()}if(typeof e=="object"){let t=e;if(!t.options||!t.data)throw new Error(`Must have an "options" or "data" property
21
+ ${JSON.stringify(e)}`);let n=new N__default.default({...E,...t.options,style:{...E.style,...t.options.style}});return t.data.forEach(r=>{Array.isArray(r)?n.push(r.map(i=>c(i))):n.push([c(r)]);}),n.toString()}throw new Error(`invalid input - 'content' must be a string, array of strings or a object:
22
22
 
23
- ${JSON.stringify(e)}`)}},Y=N;var A=class extends C{constructor(e){super();let t=e.optionList??[],i=Array.isArray(e.hide)?e.hide:[e.hide].filter(Boolean),s=Array.isArray(e.group)?e.group:[e.group].filter(Boolean);i.length>0&&(t=t.filter(r=>!i.includes(r.name))),e.header&&this.header(m(e.header)),s.length>0&&(t=t.filter(r=>{let a=s.includes("_none")&&!r.group,l=this.intersect(Array.isArray(r.group)?r.group:[r.group],s);return a||l?r:void 0}));let n=new w__default.default({chars:{bottom:"","bottom-left":"","bottom-mid":"","bottom-right":"",left:" ","left-mid":"",mid:"","mid-mid":"",middle:" ",right:"","right-mid":"",top:"","top-left":"","top-mid":"","top-right":""},colWidths:[40,40],style:{"padding-left":2,"padding-right":1},wordWrap:!0});t.forEach(r=>n.push([this.getOptionNames(r,e.reverseNameOrder??!1,e.isArgument??!1),m(r.description)])),this.add(n.toString()),this.lines.push("");}getOptionNames(e,t,i){if(!e.name)throw new TypeError("Invalid option definition, name is required.");let s=e.type?e.type.name.toLowerCase():"string",n=e.multiple||e.lazyMultiple?"[]":"";s=m(e.typeLabel??`{underline ${s}${n}}`);let r;if(e.alias)if(e.name){let a=i?e.name:`{yellow --${e.name}}`;r=t?m(`{bold ${a}}, {bold -${e.alias}} ${s}`):m(`{bold -${e.alias}}, {bold ${a}} ${s}`);}else t?r=m(`{bold -${e.alias}} ${s}`):r=m(`{bold -${e.alias}} ${s}`);else r=m(`{bold ${i?e.name:`{yellow --${e.name}}`}} ${s}`);return r}intersect(e,t){return e.some(i=>t.includes(i))}},F=A;var Ee=o=>(Array.isArray(o)?o:[o]).length===0?"":`
24
- ${o.map(t=>t.optionList?new F(t).toString():new Y(t).toString()).join(`
25
- `)}`,L=Ee;var G="__Other",q=o=>o.charAt(0).toUpperCase()+o.slice(1),ve=(o,e,t,i)=>{o.debug("no command given, printing general help...");let s=[...new Set(t.values())].filter(r=>!r.hidden);i&&(s=s.filter(r=>r.group===i));let n=s.reduce((r,a)=>{let l=a.group??G;return r[l]||(r[l]=[]),r[l].push(a),r},{});o.raw(L([{content:`{cyan ${e.getCliName()}} {green <command>} [positional arguments] {yellow [options]}`,header:"{inverse.cyan Usage }"},...Object.keys(n).map(r=>({content:n[r].map(a=>{let l="";return typeof a.alias=="string"?l=a.alias:Array.isArray(a.alias)&&(l=a.alias.join(", ")),l!==""&&(l=` [${l}]`),[`{green ${a.name}} ${l}`,a.description??""]}),header:r===G||i?`{inverse.green Available${i?` ${q(i)}`:""} Commands }`:` {inverse.green ${q(r)} }`})),t.has("help")?{header:"{inverse.yellow Command Options }",optionList:t.get("help").options?.filter(r=>!r.hidden)}:void 0,{header:"{inverse.yellow Global Options }",optionList:y},{content:`Run "{cyan ${e.getCliName()}} {green help <command>}" or "{cyan ${e.getCliName()}} {green <command>} {yellow --help}" for help with a specific command.`,raw:!0}].filter(Boolean)));},Ie=(o,e,t,i)=>{let s=t.get(i),n=[];if(n.push({content:`{cyan ${e.getCliName()}} {green ${s.name}}${s.argument?" [positional arguments]":""}${s.options?" [options]":""}`,header:"{inverse.cyan Usage }"}),s.description&&n.push({content:s.description,header:"{inverse.green Description }"}),s.argument&&n.push({header:"Command Positional Arguments",isArgument:!0,optionList:[s.argument]}),Array.isArray(s.options)&&s.options.length>0&&n.push({header:"{inverse.yellow Command Options }",optionList:s.options.filter(r=>!r.hidden)}),n.push({header:"{inverse.yellow Global Options }",optionList:y}),s.alias!==void 0&&s.alias.length>0){let r=s.alias;typeof s.alias=="string"&&(r=[s.alias]),n.splice(1,0,{content:r,header:"Alias(es)"});}Array.isArray(s.examples)&&s.examples.length>0&&n.push({content:s.examples,header:"Examples"}),o.raw(L(n));},P=class{name="help";options=[{description:"Display only the specified group",name:"group",type:String}];commands;constructor(e){this.commands=e;}execute(e){let{commandName:t,logger:i,options:s,runtime:n}=e,{footer:r,header:a}=n.getCommandSection();a&&i.raw(m(a)),t==="help"?ve(i,n,this.commands,s?.group):Ie(i,n,this.commands,t),r&&i.raw(m(r));}},J=P;var W={alias:["v","V"],description:"Output the version number",execute:({logger:o,runtime:e})=>{let t=e.getPackageVersion();t===void 0?(o.warn("Unknown version"),o.debug("The version number was not provided by the cli constructor.")):o.info(t);},name:"version",options:[],usage:[]};var O="positionals";var _=class{result;argv;options;argument;command;commandName;runtime;logger;constructor(e,t){this.commandName=e,this.command=t;}},H=_;var xe=()=>{let o=process.env.CEREBRO_MIN_NODE_VERSION?Number(process.env.CEREBRO_MIN_NODE_VERSION):18,e=process.version.replace("v","");Number(/v([^.]+)/.exec(process.version)[1])<o&&(console.log(`cerebro supports a minimum Node version of ${o}. You have ${e}. Read our version support policy: https://github.com/visulima/visulima#supported-nodejs-versions`),process.exit(1));},K=xe;var we=/^-{1,2}(\w+)(=(\w+))?$/,Ne=(o,e)=>{let t=we.exec(o);if(t==null)return {};let i=t[1],s=e.find(n=>n.name===i||n.alias===i);return s!==void 0?{argName:s.name,argValue:t[3],option:s}:{}},E=Ne;var Ae=o=>o.type?.name==="Boolean",h=Ae;var z=(o,e)=>{if(e.type===void 0)return o;if(e.type.name==="Boolean"){if(o==="true"||o==="1")return e.type(!0);if(o==="false"||o==="0")return e.type(!1)}return e.type(o)},Le=new Set(["1","0","true","false"]),Pe=(o,e)=>{let t=(i,s)=>{let{argName:n,argValue:r,option:a}=E(s,e),{lastOption:l}=i;return a&&h(a)&&r&&n?i.partial[n]=z(r,a):i.lastName&&l&&h(l)&&Le.has(s)&&(i.partial[i.lastName]=z(s,l)),{lastName:n,lastOption:a,partial:i.partial}};return o.reduce(t,{partial:{}}).partial},Q=Pe;var _e=o=>{let e=o.type?o.type.name.toLowerCase():"string",t=o.multiple??o.lazyMultiple?"[]":"";return e&&(e=e==="boolean"?"":`{underline ${e}${t}}`),e},Re=o=>(h(o)||(o.typeLabel=o.typeLabel??_e(o),o.defaultOption&&(o.typeLabel=`${o.typeLabel} (D)`),o.required&&(o.typeLabel=`${o.typeLabel} (R)`)),o),X=Re;var $e=new Set(["1","0","true","false"]),Se=(o,e)=>{let t=(i,s)=>{let{argValue:n,option:r}=E(s,e),{lastOption:a}=i;if(a&&h(a)&&$e.has(s)){let l=[...i.args];return l.pop(),{args:l}}return r&&h(r)&&n?{args:i.args}:{args:[...i.args,s],lastOption:r}};return o.reduce(t,{args:[]}).args},Z=Se;var De=new RegExp(/^-([^\d-])$/),Ve=new RegExp(/^--(\S+)/),Be=new RegExp(/^-([^\d-]{2,})$/),Ue=o=>De.test(o)||Ve.test(o)||Be.test(o),ke=(o,e)=>{let t=e[0]&&Ue(e[0])||e.length===0?null:e.shift()??null;if(!o.includes(t)){let i=new Error(`Command not recognised: ${t}`);throw i.command=t,i.name="INVALID_COMMAND",i}return {argv:e,command:t}},ee=ke;var je=(o,e)=>fastestLevenshtein.distance(o,e)<=o.length/3||e.includes(o),Ye=(o,e)=>{let t=o.toLowerCase();return e.filter(i=>je(i.toLowerCase(),t))},R=Ye;var Fe=(o,e)=>o.filter(t=>t.required&&e[t.name]==null).filter(t=>t.type?.name==="Boolean"?(e[t.name]=!1,!1):!0),te=Fe;var Ge=o=>{let e=new Map;return o.forEach(t=>{e.set(t.name,{...e.get(t.name),...t});}),[...e.values()]},oe=Ge;var qe=()=>!!process.versions.electron,Je=()=>qe()&&!process.defaultApp,We=()=>Je()?0:1,He=o=>o.slice(We()+1),ne=He;var Ke=" ",ze=(o,e)=>o.length===e.length&&o.every((t,i)=>t===e[i]),Qe=o=>typeof o=="string"?o.split(Ke):ze(o,process.argv)?ne(o):o,ie=Qe;var Xe=o=>{process.on("uncaughtException",e=>{o.error(`Uncaught exception: ${e}`),e?.stack&&o.error(e.stack),process.exit(1);}),process.on("unhandledRejection",e=>{o.error(`Promise rejection: ${e}`),e?.stack&&o.error(e.stack),process.exit(1);});},se=Xe;var ct="CI"in process$1.env&&("GITHUB_ACTIONS"in process$1.env||"GITLAB_CI"in process$1.env||"CIRCLECI"in process$1.env),S=process$1.env.NODE_ENV==="test"||process$1.env.TEST!=="false",dt=o=>o.charAt(0).toLowerCase()+o.slice(1),D=class{logger;argv;cwd;cliName;packageVersion;packageName;extensions=[];commands;defaultCommand;updateNotifierOptions;commandSection;constructor(e,t={}){let{argv:i,cwd:s,packageName:n,packageVersion:r}={argv:process$1.argv,cwd:process$1.cwd(),...t};this.argv=ie(i),this.argv.includes("--quiet")||this.argv.includes("-q")?process$1.env.CEREBRO_OUTPUT_LEVEL=String(16):this.argv.includes("--verbose")||this.argv.includes("-v")?process$1.env.CEREBRO_OUTPUT_LEVEL=String(64):this.argv.includes("--debug")||this.argv.includes("-vvv")||"DEBUG"in process$1.env?process$1.env.CEREBRO_OUTPUT_LEVEL=String(128):process$1.env.CEREBRO_OUTPUT_LEVEL=String(32);let a={32:"informational",64:"trace",128:"debug"};this.logger=server.createPail({logLevel:process$1.env.CEREBRO_OUTPUT_LEVEL?a[process$1.env.CEREBRO_OUTPUT_LEVEL]??"informational":"informational",...t.logger}),process$1.env.CEREBRO_OUTPUT_LEVEL===String(16)&&this.logger.disable(),K(),se(this.logger),this.cliName=e,this.packageVersion=r,this.packageName=n,this.cwd=s,this.defaultCommand="help",this.commandSection={header:`${this.cliName}${this.packageVersion?` v${this.packageVersion}`:""}`},this.commands=new Map,this.addCoreExtensions(),this.addCommand(W),this.addCommand(new J(this.commands));}setCommandSection(e){return this.commandSection=e,this}getCommandSection(){return this.commandSection}setDefaultCommand(e){return this.defaultCommand=e,this}addCommand(e){if(this.commands.has(e.name))throw new Error(`Ignored command with name "${e.name}, it was found in the command list."`);if(e.options?.map(t=>X(t)),this.validateDoubleOptions(e),this.addNegatableOption(e),e.options?.forEach(t=>{t.__camelCaseName__=I(t.name);}),this.commands.set(e.name,e),e.alias!==void 0){let t=e.alias;typeof e.alias=="string"&&(t=[e.alias]),t.forEach(i=>{if(this.logger.debug("adding alias",i),this.commands.has(i))throw new Error(`Ignoring command alias "${i}, command with the same name was found."`);this.commands.set(i,e);});}return this}addExtension(e){return this.extensions.push(e),this}enableUpdateNotifier(e={}){if(!this.packageName||!this.packageVersion)throw new Error("Cannot enable update notifier without package name and version.");let t=Object.keys(e);if(t.length>0&&!t.includes("alwaysRun")&&!t.includes("distTag")&&!t.includes("updateCheckInterval"))throw new Error("Invalid update notifier options, please check the documentation.");return this.updateNotifierOptions={alwaysRun:!1,debug:process$1.env.CEREBRO_OUTPUT_LEVEL===String(128),distTag:"latest",pkg:{name:this.packageName,version:this.packageVersion},updateCheckInterval:1e3*60*60*24,...e},this}getCliName(){return this.cliName}getPackageVersion(){return this.packageVersion}getPackageName(){return this.packageName}getCommands(){return this.commands}getCwd(){return this.cwd}async run(e={}){let t=[...this.commands.keys()],i;this.logger.debug(`process.execPath: ${process$1.execPath}`),this.logger.debug(`process.execArgv: ${process$1.execArgv.join(" ")}`),this.logger.debug(`process.argv: ${process$1.argv.join(" ")}`);try{i=ee([null,...t],this.argv);}catch(f){if(f.name==="INVALID_COMMAND"&&f.command){let V="",B=R(f.command,[...this.commands.keys()]);B.length>0&&(V=` Did you mean: \r
26
- - ${B.join(` \r
27
- - `)}`),this.logger.error(`"${f.command}" is not an available command.${V}`);}else this.logger.error(f);return S?void 0:process$1.exit(1)}let s=i.command??this.defaultCommand,n=this.commands.get(s);if(typeof n.execute!="function")return this.logger.error(`Command "${n.name}" has no function to execute.`),S?void 0:process$1.exit(1);let r=i.argv;this.logger.debug(`command '${s}' found, parsing command args: ${r.join(", ")}`);let a=oe([...n.options??[],...y]);a.forEach(f=>{if(f.multiple&&f.lazyMultiple)throw new Error(`Argument "${f.name}" cannot have both multiple and lazyMultiple options, please choose one.`)}),n.argument&&(this.logger.debug("command has positional argument, parsing them..."),a=[{defaultOption:!0,description:n.argument?.description,group:"positionals",multiple:!0,name:O,type:n.argument?.type,typeLabel:n.argument?.typeLabel},...a]);let l=mt__default.default(a,{argv:Z(r,n.options??[]),camelCase:!0,partial:!0,stopAtFirstUnknown:!0}),c=Q(r,n.options??[]),u={...l,_all:{...l._all,...c}};this.validateCommandOptions(a,u,n);let g=new H(n.name,n);g.runtime=this,await this.registerExtensions(g),await this.updateNotifier(g);let{_all:b,positionals:pe}=u;return b[O]&&delete b[O],g.argument=pe?.[O]??[],g.argv=this.argv,g.options={...b,...e},this.mapNegatableOptions(g,n),this.mapImpliesOptions(g,n),this.validateCommandArgsForConflicts(a,g.options,n),this.logger.debug("command options parsed from options:"),this.logger.debug(JSON.stringify(g.options,null,2)),this.logger.debug("command argument parsed from argument:"),this.logger.debug(JSON.stringify(g.argument,null,2)),await this.prepareToolboxResult(u,g,n),S?void 0:process$1.exit(0)}validateDoubleOptions(e){if(Array.isArray(e.options)){let t=e.options.reduce((n,r)=>{let a=`${r.name}-${r.alias}`;return n[a]||(n[a]=[]),n[a].push(r),n},{}),i=Object.values(t).filter(n=>n.length>1),s="";if(i.forEach(n=>{let r=n[0],a=n[1],l="alias";r.name===a.name&&(l="name",r.alias===a.alias&&(l+=" and alias")),s+=`Cannot add option ${l} "${JSON.stringify(a)}" to command "${e.name}" due to conflicting option ${JSON.stringify(r)}
28
- `;}),s.length>0)throw new Error(s)}}addCoreExtensions(){this.addExtension({execute:e=>{e.logger=this.logger;},name:"logger"});}async prepareToolboxResult(e,t,i){if(e.global?.help){this.logger.debug("'--help' option found, running 'help' for given command...");let s=this.commands.get("help");if(!s)throw new Error("Help command not found.");await s.execute(t);return}if(e.global?.version||e.global?.V){this.logger.debug("'--version' option found, running 'version' for given command...");let s=this.commands.get("version");if(!s)throw new Error("Version command not found.");await s.execute(t);return}await i.execute(t);}async updateNotifier({logger:e}){if(this.updateNotifierOptions&&this.updateNotifierOptions.alwaysRun||!(process$1.env.NO_UPDATE_NOTIFIER||process$1.env.NODE_ENV==="test"||this.argv.includes("--no-update-notifier")||ct)&&this.updateNotifierOptions){e.raw("Checking for updates...");let i=await(await import('./has-new-version-RHNN4QW4.cjs').then(s=>s.default))(this.updateNotifierOptions);if(i){let s="Update available "+colorize.dim(this.packageVersion+"")+colorize.reset(" \u2192 ")+colorize.green(i);this.logger.error(boxen.boxen(s,{borderColor:n=>colorize.yellow(n),borderStyle:"round",margin:1,padding:1,textAlignment:"center"}));}}}validateCommandOptions(e,t,i){let s=te(e,t);if(s.length>0)throw new Error(`You called the command "${i.name}" without the required options: ${s.map(n=>n.name).join(", ")}`);if(t._unknown&&t._unknown.length>0){let n=[];if(t._unknown.forEach(r=>{let a=r.startsWith("--"),l=`Found unknown ${a?"option":"argument"} "${r}"`;if(a){let c=R(r.replace("--",""),[...(i.options??[]).map(u=>u.name),...y.map(u=>u.name)]);if(c.length>0){let[u,...g]=c.map(b=>`--${b}`);l+=g.length>0?`, did you mean ${u} or ${g.join(", ")}?`:`, did you mean ${u}?`;}}n.push(l);}),n.length>0)throw new Error(n.join(`
29
- `))}}validateCommandArgsForConflicts(e,t,i){let s=e.filter(n=>n.conflicts!==void 0);if(s.length>0){let n=s.find(r=>Array.isArray(r.conflicts)?r.conflicts.some(a=>t[a]!==void 0):t[r.conflicts]!==void 0);if(n)throw new Error(`You called the command "${i.name}" with conflicting options: ${n.name} and ${typeof n.conflicts=="string"?n.conflicts:n.conflicts?.join(", ")}`)}}addNegatableOption(e){Array.isArray(e.options)&&e.options.forEach(t=>{if(t.name.startsWith("no-")&&!e.options.some(i=>i.name===t.name.replace("no-",""))){if(t.type!==Boolean){this.logger.debug(`Cannot add negated option "${t.name}" to command "${e.name}" because it is not a boolean.`);return}let i={...t,defaultValue:t.defaultValue===void 0?!0:!t.defaultValue,name:`${t.name.replace("no-","")}`};e.options.push(i);}});}async registerExtensions(e){let t=async i=>typeof i.execute!="function"?(this.logger.warn(`Skipped ${i.name} because execute is not a function.`),null):(await i.execute(e),null);for(let i of this.extensions)await t(i);}mapNegatableOptions(e,t){Object.entries(e.options).forEach(([i,s])=>{if(/^no\w+/.test(i)){let n=dt(i.replace("no",""));this.logger.debug(`mapping negated option "${i}" to "${n}"`),e.options[n]=!s,t.options?.forEach(r=>{r.name===n&&(r.__negated__=!0);});}});}mapImpliesOptions(e,t){Object.keys(e.options).forEach(i=>{let s=t.options?.find(n=>n.__camelCaseName__===i&&n.__negated__===void 0&&n.implies!==void 0);if(s?.implies){let n=s.implies;Object.entries(n).forEach(([r,a])=>{if(e.options[r]===void 0)e.options[r]=a;else {let l=t.options?.find(c=>c.name===r);(l?.defaultValue===void 0||e.options[r]===l.defaultValue)&&(e.options[r]=a);}});}});}};
23
+ ${JSON.stringify(e)}`)}},F=L;var P=class extends T{constructor(e){super();let t=e.optionList??[],n=Array.isArray(e.hide)?e.hide:[e.hide].filter(Boolean),r=Array.isArray(e.group)?e.group:[e.group].filter(Boolean);n.length>0&&(t=t.filter(s=>!n.includes(s.name))),e.header&&this.header(c(e.header)),r.length>0&&(t=t.filter(s=>{let a=r.includes("_none")&&!s.group,l=this.intersect(Array.isArray(s.group)?s.group:[s.group],r);return a||l?s:void 0}));let i=new N__default.default({chars:{bottom:"","bottom-left":"","bottom-mid":"","bottom-right":"",left:" ","left-mid":"",mid:"","mid-mid":"",middle:" ",right:"","right-mid":"",top:"","top-left":"","top-mid":"","top-right":""},colWidths:[40,40],style:{"padding-left":2,"padding-right":1},wordWrap:!0});t.forEach(s=>i.push([this.getOptionNames(s,e.reverseNameOrder??!1,e.isArgument??!1),c(s.description)])),this.add(i.toString()),this.lines.push("");}getOptionNames(e,t,n){if(!e.name)throw new TypeError("Invalid option definition, name is required.");let r=e.type?e.type.name.toLowerCase():"string",i=e.multiple||e.lazyMultiple?"[]":"";r=c(e.typeLabel??`{underline ${r}${i}}`);let s;if(e.alias)if(e.name){let a=n?e.name:`{yellow --${e.name}}`;s=t?c(`{bold ${a}}, {bold -${e.alias}} ${r}`):c(`{bold -${e.alias}}, {bold ${a}} ${r}`);}else t?s=c(`{bold -${e.alias}} ${r}`):s=c(`{bold -${e.alias}} ${r}`);else s=c(`{bold ${n?e.name:`{yellow --${e.name}}`}} ${r}`);return s}intersect(e,t){return e.some(n=>t.includes(n))}},G=P;var ve=o=>(Array.isArray(o)?o:[o]).length===0?"":`
24
+ ${o.map(t=>t.optionList?new G(t).toString():new F(t).toString()).join(`
25
+ `)}`,_=ve;var q="__Other",J=o=>o.charAt(0).toUpperCase()+o.slice(1),Ie=(o,e,t,n)=>{o.debug("no command given, printing general help...");let r=[...new Set(t.values())].filter(s=>!s.hidden);n&&(r=r.filter(s=>s.group===n));let i=r.reduce((s,a)=>{let l=a.group??q;return s[l]||(s[l]=[]),s[l].push(a),s},{});o.raw(_([{content:`{cyan ${e.getCliName()}} {green <command>} [positional arguments] {yellow [options]}`,header:"{inverse.cyan Usage }"},...Object.keys(i).map(s=>({content:i[s].map(a=>{let l="";return typeof a.alias=="string"?l=a.alias:Array.isArray(a.alias)&&(l=a.alias.join(", ")),l!==""&&(l=` [${l}]`),[`{green ${a.name}} ${l}`,a.description??""]}),header:s===q||n?`{inverse.green Available${n?` ${J(n)}`:""} Commands }`:` {inverse.green ${J(s)} }`})),t.has("help")?{header:"{inverse.yellow Command Options }",optionList:t.get("help").options?.filter(s=>!s.hidden)}:void 0,{header:"{inverse.yellow Global Options }",optionList:y},{content:`Run "{cyan ${e.getCliName()}} {green help <command>}" or "{cyan ${e.getCliName()}} {green <command>} {yellow --help}" for help with a specific command.`,raw:!0}].filter(Boolean)));},xe=(o,e,t,n)=>{let r=t.get(n),i=[];if(i.push({content:`{cyan ${e.getCliName()}} {green ${r.name}}${r.argument?" [positional arguments]":""}${r.options?" [options]":""}`,header:"{inverse.cyan Usage }"}),r.description&&i.push({content:r.description,header:"{inverse.green Description }"}),r.argument&&i.push({header:"Command Positional Arguments",isArgument:!0,optionList:[r.argument]}),Array.isArray(r.options)&&r.options.length>0&&i.push({header:"{inverse.yellow Command Options }",optionList:r.options.filter(s=>!s.hidden)}),i.push({header:"{inverse.yellow Global Options }",optionList:y}),r.alias!==void 0&&r.alias.length>0){let s=r.alias;typeof r.alias=="string"&&(s=[r.alias]),i.splice(1,0,{content:s,header:"Alias(es)"});}Array.isArray(r.examples)&&r.examples.length>0&&i.push({content:r.examples,header:"Examples"}),o.raw(_(i));},R=class{name="help";options=[{description:"Display only the specified group",name:"group",type:String}];commands;constructor(e){this.commands=e;}execute(e){let{commandName:t,logger:n,options:r,runtime:i}=e,{footer:s,header:a}=i.getCommandSection();a&&n.raw(c(a)),t==="help"?Ie(n,i,this.commands,r?.group):xe(n,i,this.commands,t),s&&n.raw(c(s));}},W=R;var H={alias:["v","V"],description:"Output the version number",execute:({logger:o,runtime:e})=>{let t=e.getPackageVersion();t===void 0?(o.warn("Unknown version"),o.debug("The version number was not provided by the cli constructor.")):o.info(t);},name:"version",options:[],usage:[]};var O="positionals";var $=class{result;argv;options;argument;command;commandName;runtime;logger;constructor(e,t){this.commandName=e,this.command=t;}},K=$;var we=()=>{let o=process.env.CEREBRO_MIN_NODE_VERSION?Number(process.env.CEREBRO_MIN_NODE_VERSION):18,e=process.version.replace("v","");Number(/v([^.]+)/.exec(process.version)[1])<o&&(console.log(`cerebro supports a minimum Node version of ${o}. You have ${e}. Read our version support policy: https://github.com/visulima/visulima#supported-nodejs-versions`),process.exit(1));},z=we;var Ae=/^-{1,2}(\w+)(=(\w+))?$/,Ne=(o,e)=>{let t=Ae.exec(o);if(t==null)return {};let n=t[1],r=e.find(i=>i.name===n||i.alias===n);return r!==void 0?{argName:r.name,argValue:t[3],option:r}:{}},v=Ne;var Le=o=>o.type?.name==="Boolean",h=Le;var Q=(o,e)=>{if(e.type===void 0)return o;if(e.type.name==="Boolean"){if(o==="true"||o==="1")return e.type(!0);if(o==="false"||o==="0")return e.type(!1)}return e.type(o)},Pe=new Set(["1","0","true","false"]),_e=(o,e)=>{let t=(n,r)=>{let{argName:i,argValue:s,option:a}=v(r,e),{lastOption:l}=n;return a&&h(a)&&s&&i?n.partial[i]=Q(s,a):n.lastName&&l&&h(l)&&Pe.has(r)&&(n.partial[n.lastName]=Q(r,l)),{lastName:i,lastOption:a,partial:n.partial}};return o.reduce(t,{partial:{}}).partial},X=_e;var Re=o=>{let e=o.type?o.type.name.toLowerCase():"string",t=o.multiple??o.lazyMultiple?"[]":"";return e&&(e=e==="boolean"?"":`{underline ${e}${t}}`),e},$e=o=>(h(o)||(o.typeLabel=o.typeLabel??Re(o),o.defaultOption&&(o.typeLabel=`${o.typeLabel} (D)`),o.required&&(o.typeLabel=`${o.typeLabel} (R)`)),o),Z=$e;var Se=new Set(["1","0","true","false"]),De=(o,e)=>{let t=(n,r)=>{let{argValue:i,option:s}=v(r,e),{lastOption:a}=n;if(a&&h(a)&&Se.has(r)){let l=[...n.args];return l.pop(),{args:l}}return s&&h(s)&&i?{args:n.args}:{args:[...n.args,r],lastOption:s}};return o.reduce(t,{args:[]}).args},ee=De;var Ve=new RegExp(/^-([^\d-])$/),Be=new RegExp(/^--(\S+)/),Ue=new RegExp(/^-([^\d-]{2,})$/),ke=o=>Ve.test(o)||Be.test(o)||Ue.test(o),Me=(o,e)=>{let t=e[0]&&ke(e[0])||e.length===0?null:e.shift()??null;if(!o.includes(t)){let n=new Error(`Command not recognised: ${t}`);throw n.command=t,n.name="INVALID_COMMAND",n}return {argv:e,command:t}},te=Me;var Ye=(o,e)=>fastestLevenshtein.distance(o,e)<=o.length/3||e.includes(o),Fe=(o,e)=>{let t=o.toLowerCase();return e.filter(n=>Ye(n.toLowerCase(),t))},S=Fe;var Ge=(o,e)=>o.filter(t=>t.required&&e[t.name]==null).filter(t=>t.type?.name==="Boolean"?(e[t.name]=!1,!1):!0),oe=Ge;var qe=o=>{let e=new Map;return o.forEach(t=>{e.set(t.name,{...e.get(t.name),...t});}),[...e.values()]},ne=qe;var Je=()=>!!process.versions.electron,We=()=>Je()&&!process.defaultApp,He=()=>We()?0:1,Ke=o=>o.slice(He()+1),ie=Ke;var ze=" ",Qe=(o,e)=>o.length===e.length&&o.every((t,n)=>t===e[n]),Xe=o=>typeof o=="string"?o.split(ze):Qe(o,process.argv)?ie(o):o,re=Xe;var Ze=o=>{process.on("uncaughtException",e=>{o.error(`Uncaught exception: ${e}`),e?.stack&&o.error(e.stack),process.exit(1);}),process.on("unhandledRejection",e=>{o.error(`Promise rejection: ${e}`),e?.stack&&o.error(e.stack),process.exit(1);});},se=Ze;var dt="CI"in process$1.env&&("GITHUB_ACTIONS"in process$1.env||"GITLAB_CI"in process$1.env||"CIRCLECI"in process$1.env),gt=o=>o.charAt(0).toLowerCase()+o.slice(1),V=class{logger;argv;cwd;cliName;packageVersion;packageName;extensions=[];commands;defaultCommand;updateNotifierOptions;commandSection;constructor(e,t={}){let{argv:n,cwd:r,packageName:i,packageVersion:s}={argv:process$1.argv,cwd:process$1.cwd(),...t};this.argv=re(n),this.argv.includes("--quiet")||this.argv.includes("-q")?process$1.env.CEREBRO_OUTPUT_LEVEL=String(16):this.argv.includes("--verbose")||this.argv.includes("-v")?process$1.env.CEREBRO_OUTPUT_LEVEL=String(64):this.argv.includes("--debug")||this.argv.includes("-vvv")||"DEBUG"in process$1.env?process$1.env.CEREBRO_OUTPUT_LEVEL=String(128):process$1.env.CEREBRO_OUTPUT_LEVEL=String(32);let a={32:"informational",64:"trace",128:"debug"};this.logger=server.createPail({logLevel:process$1.env.CEREBRO_OUTPUT_LEVEL?a[process$1.env.CEREBRO_OUTPUT_LEVEL]??"informational":"informational",...t.logger}),process$1.env.CEREBRO_OUTPUT_LEVEL===String(16)&&this.logger.disable(),z(),se(this.logger),this.cliName=e,this.packageVersion=s,this.packageName=i,this.cwd=r,this.defaultCommand="help",this.commandSection={header:`${this.cliName}${this.packageVersion?` v${this.packageVersion}`:""}`},this.commands=new Map,this.addCoreExtensions(),this.addCommand(H),this.addCommand(new W(this.commands));}setCommandSection(e){return this.commandSection=e,this}getCommandSection(){return this.commandSection}setDefaultCommand(e){return this.defaultCommand=e,this}addCommand(e){if(this.commands.has(e.name))throw new Error(`Ignored command with name "${e.name}, it was found in the command list."`);if(e.options?.map(t=>Z(t)),this.validateDoubleOptions(e),this.addNegatableOption(e),e.options?.forEach(t=>{t.__camelCaseName__=w(t.name);}),this.commands.set(e.name,e),e.alias!==void 0){let t=e.alias;typeof e.alias=="string"&&(t=[e.alias]),t.forEach(n=>{if(this.logger.debug("adding alias",n),this.commands.has(n))throw new Error(`Ignoring command alias "${n}, command with the same name was found."`);this.commands.set(n,e);});}return this}addExtension(e){return this.extensions.push(e),this}enableUpdateNotifier(e={}){if(!this.packageName||!this.packageVersion)throw new Error("Cannot enable update notifier without package name and version.");let t=Object.keys(e);if(t.length>0&&!t.includes("alwaysRun")&&!t.includes("distTag")&&!t.includes("updateCheckInterval"))throw new Error("Invalid update notifier options, please check the documentation.");return this.updateNotifierOptions={alwaysRun:!1,debug:process$1.env.CEREBRO_OUTPUT_LEVEL===String(128),distTag:"latest",pkg:{name:this.packageName,version:this.packageVersion},updateCheckInterval:1e3*60*60*24,...e},this}getCliName(){return this.cliName}getPackageVersion(){return this.packageVersion}getPackageName(){return this.packageName}getCommands(){return this.commands}getCwd(){return this.cwd}async run(e={}){let{shouldExitProcess:t=!0,...n}=e,r=[...this.commands.keys()],i;this.logger.debug(`process.execPath: ${process$1.execPath}`),this.logger.debug(`process.execArgv: ${process$1.execArgv.join(" ")}`),this.logger.debug(`process.argv: ${process$1.argv.join(" ")}`);try{i=te([null,...r],this.argv);}catch(f){if(f.name==="INVALID_COMMAND"&&f.command){let B="",U=S(f.command,[...this.commands.keys()]);U.length>0&&(B=` Did you mean: \r
26
+ - ${U.join(` \r
27
+ - `)}`),this.logger.error(`"${f.command}" is not an available command.${B}`);}else this.logger.error(f);return t?process$1.exit(1):void 0}let s=i.command??this.defaultCommand,a=this.commands.get(s);if(typeof a.execute!="function")return this.logger.error(`Command "${a.name}" has no function to execute.`),t?process$1.exit(1):void 0;let l=i.argv;this.logger.debug(`command '${s}' found, parsing command args: ${l.join(", ")}`);let m=ne([...a.options??[],...y]);m.forEach(f=>{if(f.multiple&&f.lazyMultiple)throw new Error(`Argument "${f.name}" cannot have both multiple and lazyMultiple options, please choose one.`)}),a.argument&&(this.logger.debug("command has positional argument, parsing them..."),m=[{defaultOption:!0,description:a.argument?.description,group:"positionals",multiple:!0,name:O,type:a.argument?.type,typeLabel:a.argument?.typeLabel},...m]);let u=ct__default.default(m,{argv:ee(l,a.options??[]),camelCase:!0,partial:!0,stopAtFirstUnknown:!0}),C=X(l,a.options??[]),b={...u,_all:{...u._all,...C}};this.validateCommandOptions(m,b,a);let g=new K(a.name,a);g.runtime=this,await this.registerExtensions(g),await this.updateNotifier(g);let{_all:I,positionals:me}=b;return I[O]&&delete I[O],g.argument=me?.[O]??[],g.argv=this.argv,g.options={...I,...n},this.mapNegatableOptions(g,a),this.mapImpliesOptions(g,a),this.validateCommandArgsForConflicts(m,g.options,a),this.logger.debug("command options parsed from options:"),this.logger.debug(JSON.stringify(g.options,null,2)),this.logger.debug("command argument parsed from argument:"),this.logger.debug(JSON.stringify(g.argument,null,2)),await this.prepareToolboxResult(b,g,a),t?process$1.exit(0):void 0}validateDoubleOptions(e){if(Array.isArray(e.options)){let t=e.options.reduce((i,s)=>{let a=`${s.name}-${s.alias}`;return i[a]||(i[a]=[]),i[a].push(s),i},{}),n=Object.values(t).filter(i=>i.length>1),r="";if(n.forEach(i=>{let s=i[0],a=i[1],l="alias";s.name===a.name&&(l="name",s.alias===a.alias&&(l+=" and alias")),r+=`Cannot add option ${l} "${JSON.stringify(a)}" to command "${e.name}" due to conflicting option ${JSON.stringify(s)}
28
+ `;}),r.length>0)throw new Error(r)}}addCoreExtensions(){this.addExtension({execute:e=>{e.logger=this.logger;},name:"logger"});}async prepareToolboxResult(e,t,n){if(e.global?.help){this.logger.debug("'--help' option found, running 'help' for given command...");let r=this.commands.get("help");if(!r)throw new Error("Help command not found.");await r.execute(t);return}if(e.global?.version||e.global?.V){this.logger.debug("'--version' option found, running 'version' for given command...");let r=this.commands.get("version");if(!r)throw new Error("Version command not found.");await r.execute(t);return}await n.execute(t);}async updateNotifier({logger:e}){if(this.updateNotifierOptions&&this.updateNotifierOptions.alwaysRun||!(process$1.env.NO_UPDATE_NOTIFIER||process$1.env.NODE_ENV==="test"||this.argv.includes("--no-update-notifier")||dt)&&this.updateNotifierOptions){e.raw("Checking for updates...");let n=await(await import('./has-new-version-RHNN4QW4.cjs').then(r=>r.default))(this.updateNotifierOptions);if(n){let r="Update available "+colorize.dim(this.packageVersion+"")+colorize.reset(" \u2192 ")+colorize.green(n);this.logger.error(boxen.boxen(r,{borderColor:i=>colorize.yellow(i),borderStyle:"round",margin:1,padding:1,textAlignment:"center"}));}}}validateCommandOptions(e,t,n){let r=oe(e,t);if(r.length>0)throw new Error(`You called the command "${n.name}" without the required options: ${r.map(i=>i.name).join(", ")}`);if(t._unknown&&t._unknown.length>0){let i=[];if(t._unknown.forEach(s=>{let a=s.startsWith("--"),l=`Found unknown ${a?"option":"argument"} "${s}"`;if(a){let m=S(s.replace("--",""),[...(n.options??[]).map(u=>u.name),...y.map(u=>u.name)]);if(m.length>0){let[u,...C]=m.map(b=>`--${b}`);l+=C.length>0?`, did you mean ${u} or ${C.join(", ")}?`:`, did you mean ${u}?`;}}i.push(l);}),i.length>0)throw new Error(i.join(`
29
+ `))}}validateCommandArgsForConflicts(e,t,n){let r=e.filter(i=>i.conflicts!==void 0);if(r.length>0){let i=r.find(s=>Array.isArray(s.conflicts)?s.conflicts.some(a=>t[a]!==void 0):t[s.conflicts]!==void 0);if(i)throw new Error(`You called the command "${n.name}" with conflicting options: ${i.name} and ${typeof i.conflicts=="string"?i.conflicts:i.conflicts?.join(", ")}`)}}addNegatableOption(e){Array.isArray(e.options)&&e.options.forEach(t=>{if(t.name.startsWith("no-")&&!e.options.some(n=>n.name===t.name.replace("no-",""))){if(t.type!==Boolean){this.logger.debug(`Cannot add negated option "${t.name}" to command "${e.name}" because it is not a boolean.`);return}let n={...t,defaultValue:t.defaultValue===void 0?!0:!t.defaultValue,name:`${t.name.replace("no-","")}`};e.options.push(n);}});}async registerExtensions(e){let t=async n=>typeof n.execute!="function"?(this.logger.warn(`Skipped ${n.name} because execute is not a function.`),null):(await n.execute(e),null);for(let n of this.extensions)await t(n);}mapNegatableOptions(e,t){Object.entries(e.options).forEach(([n,r])=>{if(/^no\w+/.test(n)){let i=gt(n.replace("no",""));this.logger.debug(`mapping negated option "${n}" to "${i}"`),e.options[i]=!r,t.options?.forEach(s=>{s.name===i&&(s.__negated__=!0);});}});}mapImpliesOptions(e,t){Object.keys(e.options).forEach(n=>{let r=t.options?.find(i=>i.__camelCaseName__===n&&i.__negated__===void 0&&i.implies!==void 0);if(r?.implies){let i=r.implies;Object.entries(i).forEach(([s,a])=>{if(e.options[s]===void 0)e.options[s]=a;else {let l=t.options?.find(m=>m.name===s);(l?.defaultValue===void 0||e.options[s]===l.defaultValue)&&(e.options[s]=a);}});}});}};
30
30
 
31
- module.exports = D;
31
+ module.exports = V;
32
32
  //# sourceMappingURL=out.js.map
33
33
 
34
34
  module.exports = module.exports;