@sakana-y/vue-grab-cli 0.0.1 → 0.1.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/dist/bin.cjs CHANGED
@@ -6,4 +6,4 @@ const e=require(`./init-BY4F7nfe.cjs`);let t=require(`events`);function n(e){ret
6
6
  `)}),i&&(a=i(a)||a),console.log(a.map(e=>e.title?`${e.title}:
7
7
  ${e.body}`:e.body).join(`
8
8
 
9
- `))}outputVersion(){let{name:e}=this.cli,{versionNumber:t}=this.cli.globalCommand;t&&console.log(`${e}/${t} ${v}`)}checkRequiredArgs(){let e=this.args.filter(e=>e.required).length;if(this.cli.args.length<e)throw new h(`missing required args for command \`${this.rawName}\``)}checkUnknownOptions(){let{options:e,globalCommand:t}=this.cli;if(!this.config.allowUnknownOptions){for(let n of Object.keys(e))if(n!==`--`&&!this.hasOption(n)&&!t.hasOption(n))throw new h(`Unknown option \`${n.length>1?`--${n}`:`-${n}`}\``)}}checkOptionValue(){let{options:e,globalCommand:t}=this.cli,n=[...t.options,...this.options];for(let t of n){let r=e[t.name.split(`.`)[0]];if(t.required){let e=n.some(e=>e.negated&&e.names.includes(t.name));if(r===!0||r===!1&&!e)throw new h(`option \`${t.rawName}\` value is missing`)}}}},b=class extends y{constructor(e){super(`@@global@@`,``,{},e)}},x=Object.assign,S=class extends t.EventEmitter{constructor(e=``){super(),this.name=e,this.commands=[],this.rawArgs=[],this.args=[],this.options={},this.globalCommand=new b(this),this.globalCommand.usage(`<command> [options]`)}usage(e){return this.globalCommand.usage(e),this}command(e,t,n){let r=new y(e,t||``,n,this);return r.globalCommand=this.globalCommand,this.commands.push(r),r}option(e,t,n){return this.globalCommand.option(e,t,n),this}help(e){return this.globalCommand.option(`-h, --help`,`Display this message`),this.globalCommand.helpCallback=e,this.showHelpOnExit=!0,this}version(e,t=`-v, --version`){return this.globalCommand.version(e,t),this.showVersionOnExit=!0,this}example(e){return this.globalCommand.example(e),this}outputHelp(){this.matchedCommand?this.matchedCommand.outputHelp():this.globalCommand.outputHelp()}outputVersion(){this.globalCommand.outputVersion()}setParsedInfo({args:e,options:t},n,r){return this.args=e,this.options=t,n&&(this.matchedCommand=n),r&&(this.matchedCommandName=r),this}unsetMatchedCommand(){this.matchedCommand=void 0,this.matchedCommandName=void 0}parse(e=_,{run:t=!0}={}){this.rawArgs=e,this.name||=e[1]?p(e[1]):`cli`;let n=!0;for(let t of this.commands){let r=this.mri(e.slice(2),t),i=r.args[0];if(t.isMatched(i)){n=!1;let e=x(x({},r),{args:r.args.slice(1)});this.setParsedInfo(e,t,i),this.emit(`command:${i}`,t)}}if(n){for(let t of this.commands)if(t.name===``){n=!1;let r=this.mri(e.slice(2),t);this.setParsedInfo(r,t),this.emit(`command:!`,t)}}if(n){let t=this.mri(e.slice(2));this.setParsedInfo(t)}this.options.help&&this.showHelpOnExit&&(this.outputHelp(),t=!1,this.unsetMatchedCommand()),this.options.version&&this.showVersionOnExit&&this.matchedCommandName==null&&(this.outputVersion(),t=!1,this.unsetMatchedCommand());let r={args:this.args,options:this.options};return t&&this.runMatchedCommand(),!this.matchedCommand&&this.args[0]&&this.emit(`command:*`),r}mri(e,t){let n=[...this.globalCommand.options,...t?t.options:[]],r=s(n),a=[],o=e.indexOf(`--`);o>-1&&(a=e.slice(o+1),e=e.slice(0,o));let c=i(e,r);c=Object.keys(c).reduce((e,t)=>x(x({},e),{[m(t)]:c[t]}),{_:[]});let l=c._,u={"--":a},p=t&&t.config.ignoreOptionDefaultValue?t.config.ignoreOptionDefaultValue:this.globalCommand.config.ignoreOptionDefaultValue,h=Object.create(null);for(let e of n){if(!p&&e.config.default!==void 0)for(let t of e.names)u[t]=e.config.default;Array.isArray(e.config.type)&&h[e.name]===void 0&&(h[e.name]=Object.create(null),h[e.name].shouldTransform=!0,h[e.name].transformFunction=e.config.type[0])}for(let e of Object.keys(c))e!==`_`&&(d(u,e.split(`.`),c[e]),f(u,h));return{args:l,options:u}}runMatchedCommand(){let{args:e,options:t,matchedCommand:n}=this;if(!n||!n.commandAction)return;n.checkUnknownOptions(),n.checkOptionValue(),n.checkRequiredArgs();let r=[];return n.args.forEach((t,n)=>{t.variadic?r.push(e.slice(n)):r.push(e[n])}),r.push(t),n.commandAction.apply(this,r)}},C=(e=``)=>new S(e),w=`0.0.1`,T=C(`vue-grab`);T.command(`init`,`Initialize vue-grab in your project`).option(`-y, --yes`,`Skip prompts and use defaults`).action(async t=>{await e.t(t)}),T.help(),T.version(w),T.parse();
9
+ `))}outputVersion(){let{name:e}=this.cli,{versionNumber:t}=this.cli.globalCommand;t&&console.log(`${e}/${t} ${v}`)}checkRequiredArgs(){let e=this.args.filter(e=>e.required).length;if(this.cli.args.length<e)throw new h(`missing required args for command \`${this.rawName}\``)}checkUnknownOptions(){let{options:e,globalCommand:t}=this.cli;if(!this.config.allowUnknownOptions){for(let n of Object.keys(e))if(n!==`--`&&!this.hasOption(n)&&!t.hasOption(n))throw new h(`Unknown option \`${n.length>1?`--${n}`:`-${n}`}\``)}}checkOptionValue(){let{options:e,globalCommand:t}=this.cli,n=[...t.options,...this.options];for(let t of n){let r=e[t.name.split(`.`)[0]];if(t.required){let e=n.some(e=>e.negated&&e.names.includes(t.name));if(r===!0||r===!1&&!e)throw new h(`option \`${t.rawName}\` value is missing`)}}}},b=class extends y{constructor(e){super(`@@global@@`,``,{},e)}},x=Object.assign,S=class extends t.EventEmitter{constructor(e=``){super(),this.name=e,this.commands=[],this.rawArgs=[],this.args=[],this.options={},this.globalCommand=new b(this),this.globalCommand.usage(`<command> [options]`)}usage(e){return this.globalCommand.usage(e),this}command(e,t,n){let r=new y(e,t||``,n,this);return r.globalCommand=this.globalCommand,this.commands.push(r),r}option(e,t,n){return this.globalCommand.option(e,t,n),this}help(e){return this.globalCommand.option(`-h, --help`,`Display this message`),this.globalCommand.helpCallback=e,this.showHelpOnExit=!0,this}version(e,t=`-v, --version`){return this.globalCommand.version(e,t),this.showVersionOnExit=!0,this}example(e){return this.globalCommand.example(e),this}outputHelp(){this.matchedCommand?this.matchedCommand.outputHelp():this.globalCommand.outputHelp()}outputVersion(){this.globalCommand.outputVersion()}setParsedInfo({args:e,options:t},n,r){return this.args=e,this.options=t,n&&(this.matchedCommand=n),r&&(this.matchedCommandName=r),this}unsetMatchedCommand(){this.matchedCommand=void 0,this.matchedCommandName=void 0}parse(e=_,{run:t=!0}={}){this.rawArgs=e,this.name||=e[1]?p(e[1]):`cli`;let n=!0;for(let t of this.commands){let r=this.mri(e.slice(2),t),i=r.args[0];if(t.isMatched(i)){n=!1;let e=x(x({},r),{args:r.args.slice(1)});this.setParsedInfo(e,t,i),this.emit(`command:${i}`,t)}}if(n){for(let t of this.commands)if(t.name===``){n=!1;let r=this.mri(e.slice(2),t);this.setParsedInfo(r,t),this.emit(`command:!`,t)}}if(n){let t=this.mri(e.slice(2));this.setParsedInfo(t)}this.options.help&&this.showHelpOnExit&&(this.outputHelp(),t=!1,this.unsetMatchedCommand()),this.options.version&&this.showVersionOnExit&&this.matchedCommandName==null&&(this.outputVersion(),t=!1,this.unsetMatchedCommand());let r={args:this.args,options:this.options};return t&&this.runMatchedCommand(),!this.matchedCommand&&this.args[0]&&this.emit(`command:*`),r}mri(e,t){let n=[...this.globalCommand.options,...t?t.options:[]],r=s(n),a=[],o=e.indexOf(`--`);o>-1&&(a=e.slice(o+1),e=e.slice(0,o));let c=i(e,r);c=Object.keys(c).reduce((e,t)=>x(x({},e),{[m(t)]:c[t]}),{_:[]});let l=c._,u={"--":a},p=t&&t.config.ignoreOptionDefaultValue?t.config.ignoreOptionDefaultValue:this.globalCommand.config.ignoreOptionDefaultValue,h=Object.create(null);for(let e of n){if(!p&&e.config.default!==void 0)for(let t of e.names)u[t]=e.config.default;Array.isArray(e.config.type)&&h[e.name]===void 0&&(h[e.name]=Object.create(null),h[e.name].shouldTransform=!0,h[e.name].transformFunction=e.config.type[0])}for(let e of Object.keys(c))e!==`_`&&(d(u,e.split(`.`),c[e]),f(u,h));return{args:l,options:u}}runMatchedCommand(){let{args:e,options:t,matchedCommand:n}=this;if(!n||!n.commandAction)return;n.checkUnknownOptions(),n.checkOptionValue(),n.checkRequiredArgs();let r=[];return n.args.forEach((t,n)=>{t.variadic?r.push(e.slice(n)):r.push(e[n])}),r.push(t),n.commandAction.apply(this,r)}},C=(e=``)=>new S(e),w=`0.1.0`,T=C(`vue-grab`);T.command(`init`,`Initialize vue-grab in your project`).option(`-y, --yes`,`Skip prompts and use defaults`).action(async t=>{await e.t(t)}),T.help(),T.version(w),T.parse();
package/dist/bin.mjs CHANGED
@@ -271,7 +271,7 @@ ${e.body}` : e.body).join("\n\n"));
271
271
  t.variadic ? r.push(e.slice(n)) : r.push(e[n]);
272
272
  }), r.push(t), n.commandAction.apply(this, r);
273
273
  }
274
- }, C = (e = "") => new S(e), w = "0.0.1", T = C("vue-grab");
274
+ }, C = (e = "") => new S(e), w = "0.1.0", T = C("vue-grab");
275
275
  T.command("init", "Initialize vue-grab in your project").option("-y, --yes", "Skip prompts and use defaults").action(async (t) => {
276
276
  await e(t);
277
277
  }), T.help(), T.version(w), T.parse();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sakana-y/vue-grab-cli",
3
- "version": "0.0.1",
3
+ "version": "0.1.0",
4
4
  "private": false,
5
5
  "bin": {
6
6
  "vue-grab": "./dist/bin.mjs"