@sakana-y/vue-grab-cli 0.0.1
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/LICENSE +21 -0
- package/dist/bin.cjs +9 -0
- package/dist/bin.mjs +278 -0
- package/dist/index.cjs +1 -0
- package/dist/index.mjs +2 -0
- package/dist/init-BY4F7nfe.cjs +1 -0
- package/dist/init-TuWkkzkd.js +64 -0
- package/package.json +39 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 sakana
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/bin.cjs
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const e=require(`./init-BY4F7nfe.cjs`);let t=require(`events`);function n(e){return e==null?[]:Array.isArray(e)?e:[e]}function r(e,t,n,r){var i,a=e[t],o=~r.string.indexOf(t)?n==null||n===!0?``:String(n):typeof n==`boolean`?n:~r.boolean.indexOf(t)?n===`false`?!1:n===`true`||(e._.push((i=+n,i*0==0?i:n)),!!n):(i=+n,i*0==0?i:n);e[t]=a==null?o:Array.isArray(a)?a.concat(o):[a,o]}function i(e,t){e||=[],t||={};var i,a,o,s,c,l={_:[]},u=0,d=0,f=0,p=e.length;let m=t.alias!==void 0,h=t.unknown!==void 0,g=t.default!==void 0;if(t.alias=t.alias||{},t.string=n(t.string),t.boolean=n(t.boolean),m)for(i in t.alias)for(a=t.alias[i]=n(t.alias[i]),u=0;u<a.length;u++)(t.alias[a[u]]=a.concat(i)).splice(u,1);for(u=t.boolean.length;u-- >0;)for(a=t.alias[t.boolean[u]]||[],d=a.length;d-- >0;)t.boolean.push(a[d]);for(u=t.string.length;u-- >0;)for(a=t.alias[t.string[u]]||[],d=a.length;d-- >0;)t.string.push(a[d]);if(g){for(i in t.default)if(s=typeof t.default[i],a=t.alias[i]=t.alias[i]||[],t[s]!==void 0)for(t[s].push(i),u=0;u<a.length;u++)t[s].push(a[u])}let _=h?Object.keys(t.alias):[];for(u=0;u<p;u++){if(o=e[u],o===`--`){l._=l._.concat(e.slice(++u));break}for(d=0;d<o.length&&o.charCodeAt(d)===45;d++);if(d===0)l._.push(o);else if(o.substring(d,d+3)===`no-`){if(s=o.substring(d+3),h&&!~_.indexOf(s))return t.unknown(o);l[s]=!1}else{for(f=d+1;f<o.length&&o.charCodeAt(f)!==61;f++);for(s=o.substring(d,f),c=o.substring(++f)||u+1===p||(``+e[u+1]).charCodeAt(0)===45||e[++u],a=d===2?[s]:s,f=0;f<a.length;f++){if(s=a[f],h&&!~_.indexOf(s))return t.unknown(`-`.repeat(d)+s);r(l,s,f+1<a.length||c,t)}}}if(g)for(i in t.default)l[i]===void 0&&(l[i]=t.default[i]);if(m)for(i in l)for(a=t.alias[i]||[];a.length>0;)l[a.shift()]=l[i];return l}var a=e=>e.replace(/[<[].+/,``).trim(),o=e=>{let t=/<([^>]+)>/g,n=/\[([^\]]+)\]/g,r=[],i=e=>{let t=!1,n=e[1];return n.startsWith(`...`)&&(n=n.slice(3),t=!0),{required:e[0].startsWith(`<`),value:n,variadic:t}},a;for(;a=t.exec(e);)r.push(i(a));let o;for(;o=n.exec(e);)r.push(i(o));return r},s=e=>{let t={alias:{},boolean:[]};for(let[n,r]of e.entries())r.names.length>1&&(t.alias[r.names[0]]=r.names.slice(1)),r.isBoolean&&(r.negated&&e.some((e,t)=>t!==n&&e.names.some(e=>r.names.includes(e))&&typeof e.required==`boolean`)||t.boolean.push(r.names[0]));return t},c=e=>e.sort((e,t)=>e.length>t.length?-1:1)[0],l=(e,t)=>e.length>=t?e:`${e}${` `.repeat(t-e.length)}`,u=e=>e.replace(/([a-z])-([a-z])/g,(e,t,n)=>t+n.toUpperCase()),d=(e,t,n)=>{let r=0,i=t.length,a=e,o;for(;r<i;++r)o=a[t[r]],a=a[t[r]]=r===i-1?n:o??(~t[r+1].indexOf(`.`)||!(+t[r+1]>-1)?{}:[])},f=(e,t)=>{for(let n of Object.keys(t)){let r=t[n];r.shouldTransform&&(e[n]=Array.prototype.concat.call([],e[n]),typeof r.transformFunction==`function`&&(e[n]=e[n].map(r.transformFunction)))}},p=e=>{let t=/([^\\\/]+)$/.exec(e);return t?t[1]:``},m=e=>e.split(`.`).map((e,t)=>t===0?u(e):e).join(`.`),h=class extends Error{constructor(e){super(e),this.name=this.constructor.name,typeof Error.captureStackTrace==`function`?Error.captureStackTrace(this,this.constructor):this.stack=Error(e).stack}},g=class{constructor(e,t,n){this.rawName=e,this.description=t,this.config=Object.assign({},n),e=e.replace(/\.\*/g,``),this.negated=!1,this.names=a(e).split(`,`).map(e=>{let t=e.trim().replace(/^-{1,2}/,``);return t.startsWith(`no-`)&&(this.negated=!0,t=t.replace(/^no-/,``)),m(t)}).sort((e,t)=>e.length>t.length?1:-1),this.name=this.names[this.names.length-1],this.negated&&this.config.default==null&&(this.config.default=!0),e.includes(`<`)?this.required=!0:e.includes(`[`)?this.required=!1:this.isBoolean=!0}},_=process.argv,v=`${process.platform}-${process.arch} node-${process.version}`,y=class{constructor(e,t,n={},r){this.rawName=e,this.description=t,this.config=n,this.cli=r,this.options=[],this.aliasNames=[],this.name=a(e),this.args=o(e),this.examples=[]}usage(e){return this.usageText=e,this}allowUnknownOptions(){return this.config.allowUnknownOptions=!0,this}ignoreOptionDefaultValue(){return this.config.ignoreOptionDefaultValue=!0,this}version(e,t=`-v, --version`){return this.versionNumber=e,this.option(t,`Display version number`),this}example(e){return this.examples.push(e),this}option(e,t,n){let r=new g(e,t,n);return this.options.push(r),this}alias(e){return this.aliasNames.push(e),this}action(e){return this.commandAction=e,this}isMatched(e){return this.name===e||this.aliasNames.includes(e)}get isDefaultCommand(){return this.name===``||this.aliasNames.includes(`!`)}get isGlobalCommand(){return this instanceof b}hasOption(e){return e=e.split(`.`)[0],this.options.find(t=>t.names.includes(e))}outputHelp(){let{name:e,commands:t}=this.cli,{versionNumber:n,options:r,helpCallback:i}=this.cli.globalCommand,a=[{body:`${e}${n?`/${n}`:``}`}];if(a.push({title:`Usage`,body:` $ ${e} ${this.usageText||this.rawName}`}),(this.isGlobalCommand||this.isDefaultCommand)&&t.length>0){let n=c(t.map(e=>e.rawName));a.push({title:`Commands`,body:t.map(e=>` ${l(e.rawName,n.length)} ${e.description}`).join(`
|
|
3
|
+
`)}),a.push({title:"For more info, run any command with the `--help` flag",body:t.map(t=>` $ ${e}${t.name===``?``:` ${t.name}`} --help`).join(`
|
|
4
|
+
`)})}let o=this.isGlobalCommand?r:[...this.options,...r||[]];if(!this.isGlobalCommand&&!this.isDefaultCommand&&(o=o.filter(e=>e.name!==`version`)),o.length>0){let e=c(o.map(e=>e.rawName));a.push({title:`Options`,body:o.map(t=>` ${l(t.rawName,e.length)} ${t.description} ${t.config.default===void 0?``:`(default: ${t.config.default})`}`).join(`
|
|
5
|
+
`)})}this.examples.length>0&&a.push({title:`Examples`,body:this.examples.map(t=>typeof t==`function`?t(e):t).join(`
|
|
6
|
+
`)}),i&&(a=i(a)||a),console.log(a.map(e=>e.title?`${e.title}:
|
|
7
|
+
${e.body}`:e.body).join(`
|
|
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();
|
package/dist/bin.mjs
ADDED
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { t as e } from "./init-TuWkkzkd.js";
|
|
3
|
+
import { EventEmitter as t } from "events";
|
|
4
|
+
//#region ../../node_modules/.pnpm/cac@6.7.14/node_modules/cac/dist/index.mjs
|
|
5
|
+
function n(e) {
|
|
6
|
+
return e == null ? [] : Array.isArray(e) ? e : [e];
|
|
7
|
+
}
|
|
8
|
+
function r(e, t, n, r) {
|
|
9
|
+
var i, a = e[t], o = ~r.string.indexOf(t) ? n == null || n === !0 ? "" : String(n) : typeof n == "boolean" ? n : ~r.boolean.indexOf(t) ? n === "false" ? !1 : n === "true" || (e._.push((i = +n, i * 0 == 0 ? i : n)), !!n) : (i = +n, i * 0 == 0 ? i : n);
|
|
10
|
+
e[t] = a == null ? o : Array.isArray(a) ? a.concat(o) : [a, o];
|
|
11
|
+
}
|
|
12
|
+
function i(e, t) {
|
|
13
|
+
e ||= [], t ||= {};
|
|
14
|
+
var i, a, o, s, c, l = { _: [] }, u = 0, d = 0, f = 0, p = e.length;
|
|
15
|
+
let m = t.alias !== void 0, h = t.unknown !== void 0, g = t.default !== void 0;
|
|
16
|
+
if (t.alias = t.alias || {}, t.string = n(t.string), t.boolean = n(t.boolean), m) for (i in t.alias) for (a = t.alias[i] = n(t.alias[i]), u = 0; u < a.length; u++) (t.alias[a[u]] = a.concat(i)).splice(u, 1);
|
|
17
|
+
for (u = t.boolean.length; u-- > 0;) for (a = t.alias[t.boolean[u]] || [], d = a.length; d-- > 0;) t.boolean.push(a[d]);
|
|
18
|
+
for (u = t.string.length; u-- > 0;) for (a = t.alias[t.string[u]] || [], d = a.length; d-- > 0;) t.string.push(a[d]);
|
|
19
|
+
if (g) {
|
|
20
|
+
for (i in t.default) if (s = typeof t.default[i], a = t.alias[i] = t.alias[i] || [], t[s] !== void 0) for (t[s].push(i), u = 0; u < a.length; u++) t[s].push(a[u]);
|
|
21
|
+
}
|
|
22
|
+
let _ = h ? Object.keys(t.alias) : [];
|
|
23
|
+
for (u = 0; u < p; u++) {
|
|
24
|
+
if (o = e[u], o === "--") {
|
|
25
|
+
l._ = l._.concat(e.slice(++u));
|
|
26
|
+
break;
|
|
27
|
+
}
|
|
28
|
+
for (d = 0; d < o.length && o.charCodeAt(d) === 45; d++);
|
|
29
|
+
if (d === 0) l._.push(o);
|
|
30
|
+
else if (o.substring(d, d + 3) === "no-") {
|
|
31
|
+
if (s = o.substring(d + 3), h && !~_.indexOf(s)) return t.unknown(o);
|
|
32
|
+
l[s] = !1;
|
|
33
|
+
} else {
|
|
34
|
+
for (f = d + 1; f < o.length && o.charCodeAt(f) !== 61; f++);
|
|
35
|
+
for (s = o.substring(d, f), c = o.substring(++f) || u + 1 === p || ("" + e[u + 1]).charCodeAt(0) === 45 || e[++u], a = d === 2 ? [s] : s, f = 0; f < a.length; f++) {
|
|
36
|
+
if (s = a[f], h && !~_.indexOf(s)) return t.unknown("-".repeat(d) + s);
|
|
37
|
+
r(l, s, f + 1 < a.length || c, t);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
if (g) for (i in t.default) l[i] === void 0 && (l[i] = t.default[i]);
|
|
42
|
+
if (m) for (i in l) for (a = t.alias[i] || []; a.length > 0;) l[a.shift()] = l[i];
|
|
43
|
+
return l;
|
|
44
|
+
}
|
|
45
|
+
var a = (e) => e.replace(/[<[].+/, "").trim(), o = (e) => {
|
|
46
|
+
let t = /<([^>]+)>/g, n = /\[([^\]]+)\]/g, r = [], i = (e) => {
|
|
47
|
+
let t = !1, n = e[1];
|
|
48
|
+
return n.startsWith("...") && (n = n.slice(3), t = !0), {
|
|
49
|
+
required: e[0].startsWith("<"),
|
|
50
|
+
value: n,
|
|
51
|
+
variadic: t
|
|
52
|
+
};
|
|
53
|
+
}, a;
|
|
54
|
+
for (; a = t.exec(e);) r.push(i(a));
|
|
55
|
+
let o;
|
|
56
|
+
for (; o = n.exec(e);) r.push(i(o));
|
|
57
|
+
return r;
|
|
58
|
+
}, s = (e) => {
|
|
59
|
+
let t = {
|
|
60
|
+
alias: {},
|
|
61
|
+
boolean: []
|
|
62
|
+
};
|
|
63
|
+
for (let [n, r] of e.entries()) r.names.length > 1 && (t.alias[r.names[0]] = r.names.slice(1)), r.isBoolean && (r.negated && e.some((e, t) => t !== n && e.names.some((e) => r.names.includes(e)) && typeof e.required == "boolean") || t.boolean.push(r.names[0]));
|
|
64
|
+
return t;
|
|
65
|
+
}, c = (e) => e.sort((e, t) => e.length > t.length ? -1 : 1)[0], l = (e, t) => e.length >= t ? e : `${e}${" ".repeat(t - e.length)}`, u = (e) => e.replace(/([a-z])-([a-z])/g, (e, t, n) => t + n.toUpperCase()), d = (e, t, n) => {
|
|
66
|
+
let r = 0, i = t.length, a = e, o;
|
|
67
|
+
for (; r < i; ++r) o = a[t[r]], a = a[t[r]] = r === i - 1 ? n : o ?? (~t[r + 1].indexOf(".") || !(+t[r + 1] > -1) ? {} : []);
|
|
68
|
+
}, f = (e, t) => {
|
|
69
|
+
for (let n of Object.keys(t)) {
|
|
70
|
+
let r = t[n];
|
|
71
|
+
r.shouldTransform && (e[n] = Array.prototype.concat.call([], e[n]), typeof r.transformFunction == "function" && (e[n] = e[n].map(r.transformFunction)));
|
|
72
|
+
}
|
|
73
|
+
}, p = (e) => {
|
|
74
|
+
let t = /([^\\\/]+)$/.exec(e);
|
|
75
|
+
return t ? t[1] : "";
|
|
76
|
+
}, m = (e) => e.split(".").map((e, t) => t === 0 ? u(e) : e).join("."), h = class extends Error {
|
|
77
|
+
constructor(e) {
|
|
78
|
+
super(e), this.name = this.constructor.name, typeof Error.captureStackTrace == "function" ? Error.captureStackTrace(this, this.constructor) : this.stack = Error(e).stack;
|
|
79
|
+
}
|
|
80
|
+
}, g = class {
|
|
81
|
+
constructor(e, t, n) {
|
|
82
|
+
this.rawName = e, this.description = t, this.config = Object.assign({}, n), e = e.replace(/\.\*/g, ""), this.negated = !1, this.names = a(e).split(",").map((e) => {
|
|
83
|
+
let t = e.trim().replace(/^-{1,2}/, "");
|
|
84
|
+
return t.startsWith("no-") && (this.negated = !0, t = t.replace(/^no-/, "")), m(t);
|
|
85
|
+
}).sort((e, t) => e.length > t.length ? 1 : -1), this.name = this.names[this.names.length - 1], this.negated && this.config.default == null && (this.config.default = !0), e.includes("<") ? this.required = !0 : e.includes("[") ? this.required = !1 : this.isBoolean = !0;
|
|
86
|
+
}
|
|
87
|
+
}, _ = process.argv, v = `${process.platform}-${process.arch} node-${process.version}`, y = class {
|
|
88
|
+
constructor(e, t, n = {}, r) {
|
|
89
|
+
this.rawName = e, this.description = t, this.config = n, this.cli = r, this.options = [], this.aliasNames = [], this.name = a(e), this.args = o(e), this.examples = [];
|
|
90
|
+
}
|
|
91
|
+
usage(e) {
|
|
92
|
+
return this.usageText = e, this;
|
|
93
|
+
}
|
|
94
|
+
allowUnknownOptions() {
|
|
95
|
+
return this.config.allowUnknownOptions = !0, this;
|
|
96
|
+
}
|
|
97
|
+
ignoreOptionDefaultValue() {
|
|
98
|
+
return this.config.ignoreOptionDefaultValue = !0, this;
|
|
99
|
+
}
|
|
100
|
+
version(e, t = "-v, --version") {
|
|
101
|
+
return this.versionNumber = e, this.option(t, "Display version number"), this;
|
|
102
|
+
}
|
|
103
|
+
example(e) {
|
|
104
|
+
return this.examples.push(e), this;
|
|
105
|
+
}
|
|
106
|
+
option(e, t, n) {
|
|
107
|
+
let r = new g(e, t, n);
|
|
108
|
+
return this.options.push(r), this;
|
|
109
|
+
}
|
|
110
|
+
alias(e) {
|
|
111
|
+
return this.aliasNames.push(e), this;
|
|
112
|
+
}
|
|
113
|
+
action(e) {
|
|
114
|
+
return this.commandAction = e, this;
|
|
115
|
+
}
|
|
116
|
+
isMatched(e) {
|
|
117
|
+
return this.name === e || this.aliasNames.includes(e);
|
|
118
|
+
}
|
|
119
|
+
get isDefaultCommand() {
|
|
120
|
+
return this.name === "" || this.aliasNames.includes("!");
|
|
121
|
+
}
|
|
122
|
+
get isGlobalCommand() {
|
|
123
|
+
return this instanceof b;
|
|
124
|
+
}
|
|
125
|
+
hasOption(e) {
|
|
126
|
+
return e = e.split(".")[0], this.options.find((t) => t.names.includes(e));
|
|
127
|
+
}
|
|
128
|
+
outputHelp() {
|
|
129
|
+
let { name: e, commands: t } = this.cli, { versionNumber: n, options: r, helpCallback: i } = this.cli.globalCommand, a = [{ body: `${e}${n ? `/${n}` : ""}` }];
|
|
130
|
+
if (a.push({
|
|
131
|
+
title: "Usage",
|
|
132
|
+
body: ` $ ${e} ${this.usageText || this.rawName}`
|
|
133
|
+
}), (this.isGlobalCommand || this.isDefaultCommand) && t.length > 0) {
|
|
134
|
+
let n = c(t.map((e) => e.rawName));
|
|
135
|
+
a.push({
|
|
136
|
+
title: "Commands",
|
|
137
|
+
body: t.map((e) => ` ${l(e.rawName, n.length)} ${e.description}`).join("\n")
|
|
138
|
+
}), a.push({
|
|
139
|
+
title: "For more info, run any command with the `--help` flag",
|
|
140
|
+
body: t.map((t) => ` $ ${e}${t.name === "" ? "" : ` ${t.name}`} --help`).join("\n")
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
let o = this.isGlobalCommand ? r : [...this.options, ...r || []];
|
|
144
|
+
if (!this.isGlobalCommand && !this.isDefaultCommand && (o = o.filter((e) => e.name !== "version")), o.length > 0) {
|
|
145
|
+
let e = c(o.map((e) => e.rawName));
|
|
146
|
+
a.push({
|
|
147
|
+
title: "Options",
|
|
148
|
+
body: o.map((t) => ` ${l(t.rawName, e.length)} ${t.description} ${t.config.default === void 0 ? "" : `(default: ${t.config.default})`}`).join("\n")
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
this.examples.length > 0 && a.push({
|
|
152
|
+
title: "Examples",
|
|
153
|
+
body: this.examples.map((t) => typeof t == "function" ? t(e) : t).join("\n")
|
|
154
|
+
}), i && (a = i(a) || a), console.log(a.map((e) => e.title ? `${e.title}:
|
|
155
|
+
${e.body}` : e.body).join("\n\n"));
|
|
156
|
+
}
|
|
157
|
+
outputVersion() {
|
|
158
|
+
let { name: e } = this.cli, { versionNumber: t } = this.cli.globalCommand;
|
|
159
|
+
t && console.log(`${e}/${t} ${v}`);
|
|
160
|
+
}
|
|
161
|
+
checkRequiredArgs() {
|
|
162
|
+
let e = this.args.filter((e) => e.required).length;
|
|
163
|
+
if (this.cli.args.length < e) throw new h(`missing required args for command \`${this.rawName}\``);
|
|
164
|
+
}
|
|
165
|
+
checkUnknownOptions() {
|
|
166
|
+
let { options: e, globalCommand: t } = this.cli;
|
|
167
|
+
if (!this.config.allowUnknownOptions) {
|
|
168
|
+
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}`}\``);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
checkOptionValue() {
|
|
172
|
+
let { options: e, globalCommand: t } = this.cli, n = [...t.options, ...this.options];
|
|
173
|
+
for (let t of n) {
|
|
174
|
+
let r = e[t.name.split(".")[0]];
|
|
175
|
+
if (t.required) {
|
|
176
|
+
let e = n.some((e) => e.negated && e.names.includes(t.name));
|
|
177
|
+
if (r === !0 || r === !1 && !e) throw new h(`option \`${t.rawName}\` value is missing`);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}, b = class extends y {
|
|
182
|
+
constructor(e) {
|
|
183
|
+
super("@@global@@", "", {}, e);
|
|
184
|
+
}
|
|
185
|
+
}, x = Object.assign, S = class extends t {
|
|
186
|
+
constructor(e = "") {
|
|
187
|
+
super(), this.name = e, this.commands = [], this.rawArgs = [], this.args = [], this.options = {}, this.globalCommand = new b(this), this.globalCommand.usage("<command> [options]");
|
|
188
|
+
}
|
|
189
|
+
usage(e) {
|
|
190
|
+
return this.globalCommand.usage(e), this;
|
|
191
|
+
}
|
|
192
|
+
command(e, t, n) {
|
|
193
|
+
let r = new y(e, t || "", n, this);
|
|
194
|
+
return r.globalCommand = this.globalCommand, this.commands.push(r), r;
|
|
195
|
+
}
|
|
196
|
+
option(e, t, n) {
|
|
197
|
+
return this.globalCommand.option(e, t, n), this;
|
|
198
|
+
}
|
|
199
|
+
help(e) {
|
|
200
|
+
return this.globalCommand.option("-h, --help", "Display this message"), this.globalCommand.helpCallback = e, this.showHelpOnExit = !0, this;
|
|
201
|
+
}
|
|
202
|
+
version(e, t = "-v, --version") {
|
|
203
|
+
return this.globalCommand.version(e, t), this.showVersionOnExit = !0, this;
|
|
204
|
+
}
|
|
205
|
+
example(e) {
|
|
206
|
+
return this.globalCommand.example(e), this;
|
|
207
|
+
}
|
|
208
|
+
outputHelp() {
|
|
209
|
+
this.matchedCommand ? this.matchedCommand.outputHelp() : this.globalCommand.outputHelp();
|
|
210
|
+
}
|
|
211
|
+
outputVersion() {
|
|
212
|
+
this.globalCommand.outputVersion();
|
|
213
|
+
}
|
|
214
|
+
setParsedInfo({ args: e, options: t }, n, r) {
|
|
215
|
+
return this.args = e, this.options = t, n && (this.matchedCommand = n), r && (this.matchedCommandName = r), this;
|
|
216
|
+
}
|
|
217
|
+
unsetMatchedCommand() {
|
|
218
|
+
this.matchedCommand = void 0, this.matchedCommandName = void 0;
|
|
219
|
+
}
|
|
220
|
+
parse(e = _, { run: t = !0 } = {}) {
|
|
221
|
+
this.rawArgs = e, this.name ||= e[1] ? p(e[1]) : "cli";
|
|
222
|
+
let n = !0;
|
|
223
|
+
for (let t of this.commands) {
|
|
224
|
+
let r = this.mri(e.slice(2), t), i = r.args[0];
|
|
225
|
+
if (t.isMatched(i)) {
|
|
226
|
+
n = !1;
|
|
227
|
+
let e = x(x({}, r), { args: r.args.slice(1) });
|
|
228
|
+
this.setParsedInfo(e, t, i), this.emit(`command:${i}`, t);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
if (n) {
|
|
232
|
+
for (let t of this.commands) if (t.name === "") {
|
|
233
|
+
n = !1;
|
|
234
|
+
let r = this.mri(e.slice(2), t);
|
|
235
|
+
this.setParsedInfo(r, t), this.emit("command:!", t);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
if (n) {
|
|
239
|
+
let t = this.mri(e.slice(2));
|
|
240
|
+
this.setParsedInfo(t);
|
|
241
|
+
}
|
|
242
|
+
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());
|
|
243
|
+
let r = {
|
|
244
|
+
args: this.args,
|
|
245
|
+
options: this.options
|
|
246
|
+
};
|
|
247
|
+
return t && this.runMatchedCommand(), !this.matchedCommand && this.args[0] && this.emit("command:*"), r;
|
|
248
|
+
}
|
|
249
|
+
mri(e, t) {
|
|
250
|
+
let n = [...this.globalCommand.options, ...t ? t.options : []], r = s(n), a = [], o = e.indexOf("--");
|
|
251
|
+
o > -1 && (a = e.slice(o + 1), e = e.slice(0, o));
|
|
252
|
+
let c = i(e, r);
|
|
253
|
+
c = Object.keys(c).reduce((e, t) => x(x({}, e), { [m(t)]: c[t] }), { _: [] });
|
|
254
|
+
let l = c._, u = { "--": a }, p = t && t.config.ignoreOptionDefaultValue ? t.config.ignoreOptionDefaultValue : this.globalCommand.config.ignoreOptionDefaultValue, h = Object.create(null);
|
|
255
|
+
for (let e of n) {
|
|
256
|
+
if (!p && e.config.default !== void 0) for (let t of e.names) u[t] = e.config.default;
|
|
257
|
+
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]);
|
|
258
|
+
}
|
|
259
|
+
for (let e of Object.keys(c)) e !== "_" && (d(u, e.split("."), c[e]), f(u, h));
|
|
260
|
+
return {
|
|
261
|
+
args: l,
|
|
262
|
+
options: u
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
runMatchedCommand() {
|
|
266
|
+
let { args: e, options: t, matchedCommand: n } = this;
|
|
267
|
+
if (!n || !n.commandAction) return;
|
|
268
|
+
n.checkUnknownOptions(), n.checkOptionValue(), n.checkRequiredArgs();
|
|
269
|
+
let r = [];
|
|
270
|
+
return n.args.forEach((t, n) => {
|
|
271
|
+
t.variadic ? r.push(e.slice(n)) : r.push(e[n]);
|
|
272
|
+
}), r.push(t), n.commandAction.apply(this, r);
|
|
273
|
+
}
|
|
274
|
+
}, C = (e = "") => new S(e), w = "0.0.1", T = C("vue-grab");
|
|
275
|
+
T.command("init", "Initialize vue-grab in your project").option("-y, --yes", "Skip prompts and use defaults").action(async (t) => {
|
|
276
|
+
await e(t);
|
|
277
|
+
}), T.help(), T.version(w), T.parse();
|
|
278
|
+
//#endregion
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./init-BY4F7nfe.cjs`);exports.initProject=e.t;
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),s=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},c=(n,r,a)=>(a=n==null?{}:e(i(n)),s(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n)),l=c(o(((e,t)=>{var n=String,r=function(){return{isColorSupported:!1,reset:n,bold:n,dim:n,italic:n,underline:n,inverse:n,hidden:n,strikethrough:n,black:n,red:n,green:n,yellow:n,blue:n,magenta:n,cyan:n,white:n,gray:n,bgBlack:n,bgRed:n,bgGreen:n,bgYellow:n,bgBlue:n,bgMagenta:n,bgCyan:n,bgWhite:n,blackBright:n,redBright:n,greenBright:n,yellowBright:n,blueBright:n,magentaBright:n,cyanBright:n,whiteBright:n,bgBlackBright:n,bgRedBright:n,bgGreenBright:n,bgYellowBright:n,bgBlueBright:n,bgMagentaBright:n,bgCyanBright:n,bgWhiteBright:n}};t.exports=r(),t.exports.createColors=r}))(),1);async function u(e={}){console.log(l.default.cyan(`vue-grab`)+` — Initializing...`),console.log(l.default.green(`Done!`))}Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return u}});
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescriptor, r = Object.getOwnPropertyNames, i = Object.getPrototypeOf, a = Object.prototype.hasOwnProperty, o = (e, t) => () => (t || e((t = { exports: {} }).exports, t), t.exports), s = (e, i, o, s) => {
|
|
3
|
+
if (i && typeof i == "object" || typeof i == "function") for (var c = r(i), l = 0, u = c.length, d; l < u; l++) d = c[l], !a.call(e, d) && d !== o && t(e, d, {
|
|
4
|
+
get: ((e) => i[e]).bind(null, d),
|
|
5
|
+
enumerable: !(s = n(i, d)) || s.enumerable
|
|
6
|
+
});
|
|
7
|
+
return e;
|
|
8
|
+
}, c = /* @__PURE__ */ ((n, r, a) => (a = n == null ? {} : e(i(n)), s(r || !n || !n.__esModule ? t(a, "default", {
|
|
9
|
+
value: n,
|
|
10
|
+
enumerable: !0
|
|
11
|
+
}) : a, n)))((/* @__PURE__ */ o(((e, t) => {
|
|
12
|
+
var n = String, r = function() {
|
|
13
|
+
return {
|
|
14
|
+
isColorSupported: !1,
|
|
15
|
+
reset: n,
|
|
16
|
+
bold: n,
|
|
17
|
+
dim: n,
|
|
18
|
+
italic: n,
|
|
19
|
+
underline: n,
|
|
20
|
+
inverse: n,
|
|
21
|
+
hidden: n,
|
|
22
|
+
strikethrough: n,
|
|
23
|
+
black: n,
|
|
24
|
+
red: n,
|
|
25
|
+
green: n,
|
|
26
|
+
yellow: n,
|
|
27
|
+
blue: n,
|
|
28
|
+
magenta: n,
|
|
29
|
+
cyan: n,
|
|
30
|
+
white: n,
|
|
31
|
+
gray: n,
|
|
32
|
+
bgBlack: n,
|
|
33
|
+
bgRed: n,
|
|
34
|
+
bgGreen: n,
|
|
35
|
+
bgYellow: n,
|
|
36
|
+
bgBlue: n,
|
|
37
|
+
bgMagenta: n,
|
|
38
|
+
bgCyan: n,
|
|
39
|
+
bgWhite: n,
|
|
40
|
+
blackBright: n,
|
|
41
|
+
redBright: n,
|
|
42
|
+
greenBright: n,
|
|
43
|
+
yellowBright: n,
|
|
44
|
+
blueBright: n,
|
|
45
|
+
magentaBright: n,
|
|
46
|
+
cyanBright: n,
|
|
47
|
+
whiteBright: n,
|
|
48
|
+
bgBlackBright: n,
|
|
49
|
+
bgRedBright: n,
|
|
50
|
+
bgGreenBright: n,
|
|
51
|
+
bgYellowBright: n,
|
|
52
|
+
bgBlueBright: n,
|
|
53
|
+
bgMagentaBright: n,
|
|
54
|
+
bgCyanBright: n,
|
|
55
|
+
bgWhiteBright: n
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
t.exports = r(), t.exports.createColors = r;
|
|
59
|
+
})))(), 1);
|
|
60
|
+
async function l(e = {}) {
|
|
61
|
+
console.log(c.default.cyan("vue-grab") + " — Initializing..."), console.log(c.default.green("Done!"));
|
|
62
|
+
}
|
|
63
|
+
//#endregion
|
|
64
|
+
export { l as t };
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@sakana-y/vue-grab-cli",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"private": false,
|
|
5
|
+
"bin": {
|
|
6
|
+
"vue-grab": "./dist/bin.mjs"
|
|
7
|
+
},
|
|
8
|
+
"files": [
|
|
9
|
+
"dist"
|
|
10
|
+
],
|
|
11
|
+
"type": "module",
|
|
12
|
+
"main": "./dist/index.cjs",
|
|
13
|
+
"module": "./dist/index.mjs",
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"import": "./dist/index.mjs",
|
|
18
|
+
"require": "./dist/index.cjs",
|
|
19
|
+
"types": "./dist/index.d.ts"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"publishConfig": {
|
|
23
|
+
"access": "public"
|
|
24
|
+
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"cac": "^6.7.14",
|
|
27
|
+
"picocolors": "^1.1.0"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"typescript": "~5.9.3",
|
|
31
|
+
"vite": "^8.0.0",
|
|
32
|
+
"vitest": "^4.1.0"
|
|
33
|
+
},
|
|
34
|
+
"scripts": {
|
|
35
|
+
"build": "vite build",
|
|
36
|
+
"test": "vitest run",
|
|
37
|
+
"typecheck": "tsc --noEmit"
|
|
38
|
+
}
|
|
39
|
+
}
|