@visulima/cerebro
Advanced tools
Comparing version 1.0.35 to 1.0.36
@@ -0,1 +1,10 @@ | ||
## @visulima/cerebro [1.0.36](https://github.com/visulima/visulima/compare/@visulima/cerebro@1.0.35...@visulima/cerebro@1.0.36) (2024-06-13) | ||
### Dependencies | ||
* **@visulima/boxen:** upgraded to 1.0.10 | ||
* **@visulima/colorize:** upgraded to 1.4.3 | ||
* **@visulima/pail:** upgraded to 1.1.13 | ||
## @visulima/cerebro [1.0.35](https://github.com/visulima/visulima/compare/@visulima/cerebro@1.0.34...@visulima/cerebro@1.0.35) (2024-06-11) | ||
@@ -2,0 +11,0 @@ |
@@ -20,3 +20,3 @@ import { c } from './chunk-5IGWF4F6.js'; | ||
- `)}`),this.logger.error(`"${y.command}" is not an available command.${k}`);}else this.logger.error(y);return t?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?exit(1):void 0;let p=i.argv;this.logger.debug(`command '${s}' found, parsing command args: ${p.join(", ")}`);let d=re([...a.options??[],...O]);d.forEach(y=>{if(y.multiple&&y.lazyMultiple)throw new Error(`Argument "${y.name}" cannot have both multiple and lazyMultiple options, please choose one.`)}),a.argument&&(this.logger.debug("command has positional argument, parsing them..."),d=[{defaultOption:!0,description:a.argument?.description,group:"positionals",multiple:!0,name:T,type:a.argument?.type,typeLabel:a.argument?.typeLabel},...d]);let h=gt(d,{argv:oe(p,a.options??[]),camelCase:!0,partial:!0,stopAtFirstUnknown:!0}),E=ee(p,a.options??[]),C={...h,_all:{...h._all,...E}};this.validateCommandOptions(d,C,a);let f=new Q(a.name,a);f.runtime=this,await this.registerExtensions(f),await this.updateNotifier(f);let{_all:w,positionals:de}=C;return w[T]&&delete w[T],f.argument=de?.[T]??[],f.argv=this.argv,f.options={...w,...n},this.mapNegatableOptions(f,a),this.mapImpliesOptions(f,a),this.validateCommandArgsForConflicts(d,f.options,a),this.logger.debug("command options parsed from options:"),this.logger.debug(JSON.stringify(f.options,null,2)),this.logger.debug("command argument parsed from argument:"),this.logger.debug(JSON.stringify(f.argument,null,2)),await this.prepareToolboxResult(C,f,a),t?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],p="alias";s.name===a.name&&(p="name",s.alias===a.alias&&(p+=" and alias")),r+=`Cannot add option ${p} "${JSON.stringify(a)}" to command "${e.name}" due to conflicting option ${JSON.stringify(s)} | ||
`;}),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||!(env.NO_UPDATE_NOTIFIER||env.NODE_ENV==="test"||this.argv.includes("--no-update-notifier")||ut)&&this.updateNotifierOptions){e.raw("Checking for updates...");let n=await(await import('./has-new-version-CDF2NFVH.js').then(r=>r.default))(this.updateNotifierOptions);if(n){let r="Update available "+dim(this.packageVersion+"")+reset(" \u2192 ")+green(n);this.logger.error(boxen(r,{borderColor:i=>yellow(i),borderStyle:"round",margin:1,padding:1,textAlignment:"center"}));}}}validateCommandOptions(e,t,n){let r=ie(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("--"),p=`Found unknown ${a?"option":"argument"} "${s}"`;if(a){let d=V(s.replace("--",""),[...(n.options??[]).map(h=>h.name),...O.map(h=>h.name)]);if(d.length>0){let[h,...E]=d.map(C=>`--${C}`);p+=E.length>0?`, did you mean ${h} or ${E.join(", ")}?`:`, did you mean ${h}?`;}}i.push(p);}),i.length>0)throw new Error(i.join(` | ||
`;}),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||!(env.NO_UPDATE_NOTIFIER||env.NODE_ENV==="test"||this.argv.includes("--no-update-notifier")||ut)&&this.updateNotifierOptions){e.raw("Checking for updates...");let n=await(await import('./has-new-version-DAOL7F5M.js').then(r=>r.default))(this.updateNotifierOptions);if(n){let r="Update available "+dim(this.packageVersion+"")+reset(" \u2192 ")+green(n);this.logger.error(boxen(r,{borderColor:i=>yellow(i),borderStyle:"round",margin:1,padding:1,textAlignment:"center"}));}}}validateCommandOptions(e,t,n){let r=ie(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("--"),p=`Found unknown ${a?"option":"argument"} "${s}"`;if(a){let d=V(s.replace("--",""),[...(n.options??[]).map(h=>h.name),...O.map(h=>h.name)]);if(d.length>0){let[h,...E]=d.map(C=>`--${C}`);p+=E.length>0?`, did you mean ${h} or ${E.join(", ")}?`:`, did you mean ${h}?`;}}i.push(p);}),i.length>0)throw new Error(i.join(` | ||
`))}}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=ft(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 p=t.options?.find(d=>d.name===s);(p?.defaultValue===void 0||e.options[s]===p.defaultValue)&&(e.options[s]=a);}});}});}}; | ||
@@ -23,0 +23,0 @@ |
{ | ||
"name": "@visulima/cerebro", | ||
"version": "1.0.35", | ||
"version": "1.0.36", | ||
"description": "A delightful toolkit for building Node-powered CLIs.", | ||
@@ -80,5 +80,5 @@ "keywords": [ | ||
"dependencies": { | ||
"@visulima/boxen": "1.0.9", | ||
"@visulima/colorize": "1.4.2", | ||
"@visulima/pail": "1.1.12", | ||
"@visulima/boxen": "1.0.10", | ||
"@visulima/colorize": "1.4.3", | ||
"@visulima/pail": "1.1.13", | ||
"cli-table3": "^0.6.5", | ||
@@ -85,0 +85,0 @@ "command-line-args": "^5.2.1", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
1523445
+ Added@visulima/boxen@1.0.10(transitive)
+ Added@visulima/colorize@1.4.3(transitive)
+ Added@visulima/is-ansi-color-supported@2.2.2(transitive)
+ Added@visulima/pail@1.1.13(transitive)
- Removed@visulima/boxen@1.0.9(transitive)
- Removed@visulima/colorize@1.4.2(transitive)
- Removed@visulima/is-ansi-color-supported@2.2.1(transitive)
- Removed@visulima/pail@1.1.12(transitive)
Updated@visulima/boxen@1.0.10
Updated@visulima/colorize@1.4.3
Updated@visulima/pail@1.1.13