@seeka-labs/cli-apps 1.1.1 → 1.1.3
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/index.js +9 -9
- package/package.json +4 -2
package/dist/index.js
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
#! /usr/bin/env node
|
|
2
|
-
"use strict";var xt=Object.create;var ce=Object.defineProperty;var St=Object.getOwnPropertyDescriptor;var kt=Object.getOwnPropertyNames;var $t=Object.getPrototypeOf,Vt=Object.prototype.hasOwnProperty;var _=(i,e)=>()=>(e||i((e={exports:{}}).exports,e),e.exports);var Nt=(i,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of kt(e))!Vt.call(i,s)&&s!==t&&ce(i,s,{get:()=>e[s],enumerable:!(n=St(e,s))||n.enumerable});return i};var v=(i,e,t)=>(t=i!=null?xt($t(i)):{},Nt(e||!i||!i.__esModule?ce(t,"default",{value:i,enumerable:!0}):t,i));var V=_(
|
|
2
|
+
"use strict";var xt=Object.create;var ce=Object.defineProperty;var St=Object.getOwnPropertyDescriptor;var kt=Object.getOwnPropertyNames;var $t=Object.getPrototypeOf,Vt=Object.prototype.hasOwnProperty;var _=(i,e)=>()=>(e||i((e={exports:{}}).exports,e),e.exports);var Nt=(i,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of kt(e))!Vt.call(i,s)&&s!==t&&ce(i,s,{get:()=>e[s],enumerable:!(n=St(e,s))||n.enumerable});return i};var v=(i,e,t)=>(t=i!=null?xt($t(i)):{},Nt(e||!i||!i.__esModule?ce(t,"default",{value:i,enumerable:!0}):t,i));var V=_(I=>{var H=class extends Error{constructor(e,t,n){super(n),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}},D=class extends H{constructor(e){super(1,"commander.invalidArgument",e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};I.CommanderError=H;I.InvalidArgumentError=D});var P=_(F=>{var{InvalidArgumentError:Ht}=V(),q=class{constructor(e,t){switch(this.description=t||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case"<":this.required=!0,this._name=e.slice(1,-1);break;case"[":this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e;break}this._name.length>3&&this._name.slice(-3)==="..."&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_concatValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:t.concat(e)}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(t,n)=>{if(!this.argChoices.includes(t))throw new Ht(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(t,n):t},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function Pt(i){let e=i.name()+(i.variadic===!0?"...":"");return i.required?"<"+e+">":"["+e+"]"}F.Argument=q;F.humanReadableArgName=Pt});var L=_(ue=>{var{humanReadableArgName:jt}=P(),M=class{constructor(){this.helpWidth=void 0,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}visibleCommands(e){let t=e.commands.filter(s=>!s._hidden),n=e._getHelpCommand();return n&&!n._hidden&&t.push(n),this.sortSubcommands&&t.sort((s,r)=>s.name().localeCompare(r.name())),t}compareOptions(e,t){let n=s=>s.short?s.short.replace(/^-/,""):s.long.replace(/^--/,"");return n(e).localeCompare(n(t))}visibleOptions(e){let t=e.options.filter(s=>!s.hidden),n=e._getHelpOption();if(n&&!n.hidden){let s=n.short&&e._findOption(n.short),r=n.long&&e._findOption(n.long);!s&&!r?t.push(n):n.long&&!r?t.push(e.createOption(n.long,n.description)):n.short&&!s&&t.push(e.createOption(n.short,n.description))}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let n=e.parent;n;n=n.parent){let s=n.options.filter(r=>!r.hidden);t.push(...s)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach(t=>{t.description=t.description||e._argsDescription[t.name()]||""}),e.registeredArguments.find(t=>t.description)?e.registeredArguments:[]}subcommandTerm(e){let t=e.registeredArguments.map(n=>jt(n)).join(" ");return e._name+(e._aliases[0]?"|"+e._aliases[0]:"")+(e.options.length?" [options]":"")+(t?" "+t:"")}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce((n,s)=>Math.max(n,t.subcommandTerm(s).length),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((n,s)=>Math.max(n,t.optionTerm(s).length),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((n,s)=>Math.max(n,t.optionTerm(s).length),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((n,s)=>Math.max(n,t.argumentTerm(s).length),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+"|"+e._aliases[0]);let n="";for(let s=e.parent;s;s=s.parent)n=s.name()+" "+n;return n+t+" "+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let t=[];return e.argChoices&&t.push(`choices: ${e.argChoices.map(n=>JSON.stringify(n)).join(", ")}`),e.defaultValue!==void 0&&(e.required||e.optional||e.isBoolean()&&typeof e.defaultValue=="boolean")&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),e.presetArg!==void 0&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),e.envVar!==void 0&&t.push(`env: ${e.envVar}`),t.length>0?`${e.description} (${t.join(", ")})`:e.description}argumentDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(n=>JSON.stringify(n)).join(", ")}`),e.defaultValue!==void 0&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){let n=`(${t.join(", ")})`;return e.description?`${e.description} ${n}`:n}return e.description}formatHelp(e,t){let n=t.padWidth(e,t),s=t.helpWidth||80,r=2,m=2;function l(d,w){if(w){let $=`${d.padEnd(n+m)}${w}`;return t.wrap($,s-r,n+m)}return d}function o(d){return d.join(`
|
|
3
3
|
`).replace(/^/gm," ".repeat(r))}let a=[`Usage: ${t.commandUsage(e)}`,""],c=t.commandDescription(e);c.length>0&&(a=a.concat([t.wrap(c,s,0),""]));let h=t.visibleArguments(e).map(d=>l(t.argumentTerm(d),t.argumentDescription(d)));h.length>0&&(a=a.concat(["Arguments:",o(h),""]));let f=t.visibleOptions(e).map(d=>l(t.optionTerm(d),t.optionDescription(d)));if(f.length>0&&(a=a.concat(["Options:",o(f),""])),this.showGlobalOptions){let d=t.visibleGlobalOptions(e).map(w=>l(t.optionTerm(w),t.optionDescription(w)));d.length>0&&(a=a.concat(["Global Options:",o(d),""]))}let b=t.visibleCommands(e).map(d=>l(t.subcommandTerm(d),t.subcommandDescription(d)));return b.length>0&&(a=a.concat(["Commands:",o(b),""])),a.join(`
|
|
4
4
|
`)}padWidth(e,t){return Math.max(t.longestOptionTermLength(e,t),t.longestGlobalOptionTermLength(e,t),t.longestSubcommandTermLength(e,t),t.longestArgumentTermLength(e,t))}wrap(e,t,n,s=40){let r=" \\f\\t\\v\xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF",m=new RegExp(`[\\n][${r}]+`);if(e.match(m))return e;let l=t-n;if(l<s)return e;let o=e.slice(0,n),a=e.slice(n).replace(`\r
|
|
5
5
|
`,`
|
|
6
6
|
`),c=" ".repeat(n),f="\\s\u200B",b=new RegExp(`
|
|
7
7
|
|.{1,${l-1}}([${f}]|$)|[^${f}]+?([${f}]|$)`,"g"),d=a.match(b)||[];return o+d.map((w,$)=>w===`
|
|
8
8
|
`?"":($>0?c:"")+w.trimEnd()).join(`
|
|
9
|
-
`)}};ue.Help=M});var B=_(U=>{var{InvalidArgumentError:Tt}=V(),R=class{constructor(e,t){this.flags=e,this.description=t||"",this.required=e.includes("<"),this.optional=e.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(e),this.mandatory=!1;let n=
|
|
9
|
+
`)}};ue.Help=M});var B=_(U=>{var{InvalidArgumentError:Tt}=V(),R=class{constructor(e,t){this.flags=e,this.description=t||"",this.required=e.includes("<"),this.optional=e.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(e),this.mandatory=!1;let n=It(e);this.short=n.shortFlag,this.long=n.longFlag,this.negate=!1,this.long&&(this.negate=this.long.startsWith("--no-")),this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}preset(e){return this.presetArg=e,this}conflicts(e){return this.conflictsWith=this.conflictsWith.concat(e),this}implies(e){let t=e;return typeof e=="string"&&(t={[e]:!0}),this.implied=Object.assign(this.implied||{},t),this}env(e){return this.envVar=e,this}argParser(e){return this.parseArg=e,this}makeOptionMandatory(e=!0){return this.mandatory=!!e,this}hideHelp(e=!0){return this.hidden=!!e,this}_concatValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:t.concat(e)}choices(e){return this.argChoices=e.slice(),this.parseArg=(t,n)=>{if(!this.argChoices.includes(t))throw new Tt(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(t,n):t},this}name(){return this.long?this.long.replace(/^--/,""):this.short.replace(/^-/,"")}attributeName(){return Dt(this.name().replace(/^no-/,""))}is(e){return this.short===e||this.long===e}isBoolean(){return!this.required&&!this.optional&&!this.negate}},W=class{constructor(e){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,e.forEach(t=>{t.negate?this.negativeOptions.set(t.attributeName(),t):this.positiveOptions.set(t.attributeName(),t)}),this.negativeOptions.forEach((t,n)=>{this.positiveOptions.has(n)&&this.dualOptions.add(n)})}valueFromOption(e,t){let n=t.attributeName();if(!this.dualOptions.has(n))return!0;let s=this.negativeOptions.get(n).presetArg,r=s!==void 0?s:!1;return t.negate===(r===e)}};function Dt(i){return i.split("-").reduce((e,t)=>e+t[0].toUpperCase()+t.slice(1))}function It(i){let e,t,n=i.split(/[ |,]+/);return n.length>1&&!/^[[<]/.test(n[1])&&(e=n.shift()),t=n.shift(),!e&&/^-[^-]$/.test(t)&&(e=t,t=void 0),{shortFlag:e,longFlag:t}}U.Option=R;U.DualOptions=W});var pe=_(he=>{function qt(i,e){if(Math.abs(i.length-e.length)>3)return Math.max(i.length,e.length);let t=[];for(let n=0;n<=i.length;n++)t[n]=[n];for(let n=0;n<=e.length;n++)t[0][n]=n;for(let n=1;n<=e.length;n++)for(let s=1;s<=i.length;s++){let r=1;i[s-1]===e[n-1]?r=0:r=1,t[s][n]=Math.min(t[s-1][n]+1,t[s][n-1]+1,t[s-1][n-1]+r),s>1&&n>1&&i[s-1]===e[n-2]&&i[s-2]===e[n-1]&&(t[s][n]=Math.min(t[s][n],t[s-2][n-2]+1))}return t[i.length][e.length]}function Ft(i,e){if(!e||e.length===0)return"";e=Array.from(new Set(e));let t=i.startsWith("--");t&&(i=i.slice(2),e=e.map(m=>m.slice(2)));let n=[],s=3,r=.4;return e.forEach(m=>{if(m.length<=1)return;let l=qt(i,m),o=Math.max(i.length,m.length);(o-l)/o>r&&(l<s?(s=l,n=[m]):l===s&&n.push(m))}),n.sort((m,l)=>m.localeCompare(l)),t&&(n=n.map(m=>`--${m}`)),n.length>1?`
|
|
10
10
|
(Did you mean one of ${n.join(", ")}?)`:n.length===1?`
|
|
11
|
-
(Did you mean ${n[0]}?)`:""}he.suggestSimilar=
|
|
11
|
+
(Did you mean ${n[0]}?)`:""}he.suggestSimilar=Ft});var be=_(_e=>{var Mt=require("events").EventEmitter,G=require("child_process"),A=require("path"),z=require("fs"),g=require("process"),{Argument:Lt,humanReadableArgName:Rt}=P(),{CommanderError:K}=V(),{Help:Wt}=L(),{Option:de,DualOptions:Ut}=B(),{suggestSimilar:fe}=pe(),J=class i extends Mt{constructor(e){super(),this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!0,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=e||"",this._optionValues={},this._optionValueSources={},this._storeOptionsAsProperties=!1,this._actionHandler=null,this._executableHandler=!1,this._executableFile=null,this._executableDir=null,this._defaultCommandName=null,this._exitCallback=null,this._aliases=[],this._combineFlagAndOptionalValue=!0,this._description="",this._summary="",this._argsDescription=void 0,this._enablePositionalOptions=!1,this._passThroughOptions=!1,this._lifeCycleHooks={},this._showHelpAfterError=!1,this._showSuggestionAfterError=!0,this._outputConfiguration={writeOut:t=>g.stdout.write(t),writeErr:t=>g.stderr.write(t),getOutHelpWidth:()=>g.stdout.isTTY?g.stdout.columns:void 0,getErrHelpWidth:()=>g.stderr.isTTY?g.stderr.columns:void 0,outputError:(t,n)=>n(t)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={}}copyInheritedSettings(e){return this._outputConfiguration=e._outputConfiguration,this._helpOption=e._helpOption,this._helpCommand=e._helpCommand,this._helpConfiguration=e._helpConfiguration,this._exitCallback=e._exitCallback,this._storeOptionsAsProperties=e._storeOptionsAsProperties,this._combineFlagAndOptionalValue=e._combineFlagAndOptionalValue,this._allowExcessArguments=e._allowExcessArguments,this._enablePositionalOptions=e._enablePositionalOptions,this._showHelpAfterError=e._showHelpAfterError,this._showSuggestionAfterError=e._showSuggestionAfterError,this}_getCommandAndAncestors(){let e=[];for(let t=this;t;t=t.parent)e.push(t);return e}command(e,t,n){let s=t,r=n;typeof s=="object"&&s!==null&&(r=s,s=null),r=r||{};let[,m,l]=e.match(/([^ ]+) *(.*)/),o=this.createCommand(m);return s&&(o.description(s),o._executableHandler=!0),r.isDefault&&(this._defaultCommandName=o._name),o._hidden=!!(r.noHelp||r.hidden),o._executableFile=r.executableFile||null,l&&o.arguments(l),this._registerCommand(o),o.parent=this,o.copyInheritedSettings(this),s?this:o}createCommand(e){return new i(e)}createHelp(){return Object.assign(new Wt,this.configureHelp())}configureHelp(e){return e===void 0?this._helpConfiguration:(this._helpConfiguration=e,this)}configureOutput(e){return e===void 0?this._outputConfiguration:(Object.assign(this._outputConfiguration,e),this)}showHelpAfterError(e=!0){return typeof e!="string"&&(e=!!e),this._showHelpAfterError=e,this}showSuggestionAfterError(e=!0){return this._showSuggestionAfterError=!!e,this}addCommand(e,t){if(!e._name)throw new Error(`Command passed to .addCommand() must have a name
|
|
12
12
|
- specify the name in Command constructor or using .name()`);return t=t||{},t.isDefault&&(this._defaultCommandName=e._name),(t.noHelp||t.hidden)&&(e._hidden=!0),this._registerCommand(e),e.parent=this,e._checkForBrokenPassThrough(),this}createArgument(e,t){return new Lt(e,t)}argument(e,t,n,s){let r=this.createArgument(e,t);return typeof n=="function"?r.default(s).argParser(n):r.default(n),this.addArgument(r),this}arguments(e){return e.trim().split(/ +/).forEach(t=>{this.argument(t)}),this}addArgument(e){let t=this.registeredArguments.slice(-1)[0];if(t&&t.variadic)throw new Error(`only the last argument can be variadic '${t.name()}'`);if(e.required&&e.defaultValue!==void 0&&e.parseArg===void 0)throw new Error(`a default value for a required argument is never used: '${e.name()}'`);return this.registeredArguments.push(e),this}helpCommand(e,t){if(typeof e=="boolean")return this._addImplicitHelpCommand=e,this;e=e??"help [command]";let[,n,s]=e.match(/([^ ]+) *(.*)/),r=t??"display help for command",m=this.createCommand(n);return m.helpOption(!1),s&&m.arguments(s),r&&m.description(r),this._addImplicitHelpCommand=!0,this._helpCommand=m,this}addHelpCommand(e,t){return typeof e!="object"?(this.helpCommand(e,t),this):(this._addImplicitHelpCommand=!0,this._helpCommand=e,this)}_getHelpCommand(){return this._addImplicitHelpCommand??(this.commands.length&&!this._actionHandler&&!this._findCommand("help"))?(this._helpCommand===void 0&&this.helpCommand(void 0,void 0),this._helpCommand):null}hook(e,t){let n=["preSubcommand","preAction","postAction"];if(!n.includes(e))throw new Error(`Unexpected value for event passed to hook : '${e}'.
|
|
13
|
-
Expecting one of '${n.join("', '")}'`);return this._lifeCycleHooks[e]?this._lifeCycleHooks[e].push(t):this._lifeCycleHooks[e]=[t],this}exitOverride(e){return e?this._exitCallback=e:this._exitCallback=t=>{if(t.code!=="commander.executeSubCommandAsync")throw t},this}_exit(e,t,n){this._exitCallback&&this._exitCallback(new
|
|
14
|
-
- already used by option '${t.flags}'`)}this.options.push(e)}_registerCommand(e){let t=s=>[s.name()].concat(s.aliases()),n=t(e).find(s=>this._findCommand(s));if(n){let s=t(this._findCommand(n)).join("|"),r=t(e).join("|");throw new Error(`cannot add command '${r}' as already have command '${s}'`)}this.commands.push(e)}addOption(e){this._registerOption(e);let t=e.name(),n=e.attributeName();if(e.negate){let r=e.long.replace(/^--no-/,"--");this._findOption(r)||this.setOptionValueWithSource(n,e.defaultValue===void 0?!0:e.defaultValue,"default")}else e.defaultValue!==void 0&&this.setOptionValueWithSource(n,e.defaultValue,"default");let s=(r,m,l)=>{r==null&&e.presetArg!==void 0&&(r=e.presetArg);let o=this.getOptionValue(n);r!==null&&e.parseArg?r=this._callParseArg(e,r,o,m):r!==null&&e.variadic&&(r=e._concatValue(r,o)),r==null&&(e.negate?r=!1:e.isBoolean()||e.optional?r=!0:r=""),this.setOptionValueWithSource(n,r,l)};return this.on("option:"+t,r=>{let m=`error: option '${e.flags}' argument '${r}' is invalid.`;s(r,m,"cli")}),e.envVar&&this.on("optionEnv:"+t,r=>{let m=`error: option '${e.flags}' value '${r}' from env '${e.envVar}' is invalid.`;s(r,m,"env")}),this}_optionEx(e,t,n,s,r){if(typeof t=="object"&&t instanceof de)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");let m=this.createOption(t,n);if(m.makeOptionMandatory(!!e.mandatory),typeof s=="function")m.default(r).argParser(s);else if(s instanceof RegExp){let l=s;s=(o,a)=>{let c=l.exec(o);return c?c[0]:a},m.default(r).argParser(s)}else m.default(s);return this.addOption(m)}option(e,t,n,s){return this._optionEx({},e,t,n,s)}requiredOption(e,t,n,s){return this._optionEx({mandatory:!0},e,t,n,s)}combineFlagAndOptionalValue(e=!0){return this._combineFlagAndOptionalValue=!!e,this}allowUnknownOption(e=!0){return this._allowUnknownOption=!!e,this}allowExcessArguments(e=!0){return this._allowExcessArguments=!!e,this}enablePositionalOptions(e=!0){return this._enablePositionalOptions=!!e,this}passThroughOptions(e=!0){return this._passThroughOptions=!!e,this._checkForBrokenPassThrough(),this}_checkForBrokenPassThrough(){if(this.parent&&this._passThroughOptions&&!this.parent._enablePositionalOptions)throw new Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}storeOptionsAsProperties(e=!0){if(this.options.length)throw new Error("call .storeOptionsAsProperties() before adding options");if(Object.keys(this._optionValues).length)throw new Error("call .storeOptionsAsProperties() before setting option values");return this._storeOptionsAsProperties=!!e,this}getOptionValue(e){return this._storeOptionsAsProperties?this[e]:this._optionValues[e]}setOptionValue(e,t){return this.setOptionValueWithSource(e,t,void 0)}setOptionValueWithSource(e,t,n){return this._storeOptionsAsProperties?this[e]=t:this._optionValues[e]=t,this._optionValueSources[e]=n,this}getOptionValueSource(e){return this._optionValueSources[e]}getOptionValueSourceWithGlobals(e){let t;return this._getCommandAndAncestors().forEach(n=>{n.getOptionValueSource(e)!==void 0&&(t=n.getOptionValueSource(e))}),t}_prepareUserArgs(e,t){if(e!==void 0&&!Array.isArray(e))throw new Error("first parameter to parse must be array or undefined");t=t||{},e===void 0&&(e=g.argv,g.versions&&g.versions.electron&&(t.from="electron")),this.rawArgs=e.slice();let n;switch(t.from){case void 0:case"node":this._scriptPath=e[1],n=e.slice(2);break;case"electron":g.defaultApp?(this._scriptPath=e[1],n=e.slice(2)):n=e.slice(1);break;case"user":n=e.slice(0);break;default:throw new Error(`unexpected parse option { from: '${t.from}' }`)}return!this._name&&this._scriptPath&&this.nameFromFilename(this._scriptPath),this._name=this._name||"program",n}parse(e,t){let n=this._prepareUserArgs(e,t);return this._parseCommand([],n),this}async parseAsync(e,t){let n=this._prepareUserArgs(e,t);return await this._parseCommand([],n),this}_executeSubCommand(e,t){t=t.slice();let n=!1,s=[".js",".ts",".tsx",".mjs",".cjs"];function r(c,h){let f=
|
|
13
|
+
Expecting one of '${n.join("', '")}'`);return this._lifeCycleHooks[e]?this._lifeCycleHooks[e].push(t):this._lifeCycleHooks[e]=[t],this}exitOverride(e){return e?this._exitCallback=e:this._exitCallback=t=>{if(t.code!=="commander.executeSubCommandAsync")throw t},this}_exit(e,t,n){this._exitCallback&&this._exitCallback(new K(e,t,n)),g.exit(e)}action(e){let t=n=>{let s=this.registeredArguments.length,r=n.slice(0,s);return this._storeOptionsAsProperties?r[s]=this:r[s]=this.opts(),r.push(this),e.apply(this,r)};return this._actionHandler=t,this}createOption(e,t){return new de(e,t)}_callParseArg(e,t,n,s){try{return e.parseArg(t,n)}catch(r){if(r.code==="commander.invalidArgument"){let m=`${s} ${r.message}`;this.error(m,{exitCode:r.exitCode,code:r.code})}throw r}}_registerOption(e){let t=e.short&&this._findOption(e.short)||e.long&&this._findOption(e.long);if(t){let n=e.long&&this._findOption(e.long)?e.long:e.short;throw new Error(`Cannot add option '${e.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${n}'
|
|
14
|
+
- already used by option '${t.flags}'`)}this.options.push(e)}_registerCommand(e){let t=s=>[s.name()].concat(s.aliases()),n=t(e).find(s=>this._findCommand(s));if(n){let s=t(this._findCommand(n)).join("|"),r=t(e).join("|");throw new Error(`cannot add command '${r}' as already have command '${s}'`)}this.commands.push(e)}addOption(e){this._registerOption(e);let t=e.name(),n=e.attributeName();if(e.negate){let r=e.long.replace(/^--no-/,"--");this._findOption(r)||this.setOptionValueWithSource(n,e.defaultValue===void 0?!0:e.defaultValue,"default")}else e.defaultValue!==void 0&&this.setOptionValueWithSource(n,e.defaultValue,"default");let s=(r,m,l)=>{r==null&&e.presetArg!==void 0&&(r=e.presetArg);let o=this.getOptionValue(n);r!==null&&e.parseArg?r=this._callParseArg(e,r,o,m):r!==null&&e.variadic&&(r=e._concatValue(r,o)),r==null&&(e.negate?r=!1:e.isBoolean()||e.optional?r=!0:r=""),this.setOptionValueWithSource(n,r,l)};return this.on("option:"+t,r=>{let m=`error: option '${e.flags}' argument '${r}' is invalid.`;s(r,m,"cli")}),e.envVar&&this.on("optionEnv:"+t,r=>{let m=`error: option '${e.flags}' value '${r}' from env '${e.envVar}' is invalid.`;s(r,m,"env")}),this}_optionEx(e,t,n,s,r){if(typeof t=="object"&&t instanceof de)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");let m=this.createOption(t,n);if(m.makeOptionMandatory(!!e.mandatory),typeof s=="function")m.default(r).argParser(s);else if(s instanceof RegExp){let l=s;s=(o,a)=>{let c=l.exec(o);return c?c[0]:a},m.default(r).argParser(s)}else m.default(s);return this.addOption(m)}option(e,t,n,s){return this._optionEx({},e,t,n,s)}requiredOption(e,t,n,s){return this._optionEx({mandatory:!0},e,t,n,s)}combineFlagAndOptionalValue(e=!0){return this._combineFlagAndOptionalValue=!!e,this}allowUnknownOption(e=!0){return this._allowUnknownOption=!!e,this}allowExcessArguments(e=!0){return this._allowExcessArguments=!!e,this}enablePositionalOptions(e=!0){return this._enablePositionalOptions=!!e,this}passThroughOptions(e=!0){return this._passThroughOptions=!!e,this._checkForBrokenPassThrough(),this}_checkForBrokenPassThrough(){if(this.parent&&this._passThroughOptions&&!this.parent._enablePositionalOptions)throw new Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}storeOptionsAsProperties(e=!0){if(this.options.length)throw new Error("call .storeOptionsAsProperties() before adding options");if(Object.keys(this._optionValues).length)throw new Error("call .storeOptionsAsProperties() before setting option values");return this._storeOptionsAsProperties=!!e,this}getOptionValue(e){return this._storeOptionsAsProperties?this[e]:this._optionValues[e]}setOptionValue(e,t){return this.setOptionValueWithSource(e,t,void 0)}setOptionValueWithSource(e,t,n){return this._storeOptionsAsProperties?this[e]=t:this._optionValues[e]=t,this._optionValueSources[e]=n,this}getOptionValueSource(e){return this._optionValueSources[e]}getOptionValueSourceWithGlobals(e){let t;return this._getCommandAndAncestors().forEach(n=>{n.getOptionValueSource(e)!==void 0&&(t=n.getOptionValueSource(e))}),t}_prepareUserArgs(e,t){if(e!==void 0&&!Array.isArray(e))throw new Error("first parameter to parse must be array or undefined");t=t||{},e===void 0&&(e=g.argv,g.versions&&g.versions.electron&&(t.from="electron")),this.rawArgs=e.slice();let n;switch(t.from){case void 0:case"node":this._scriptPath=e[1],n=e.slice(2);break;case"electron":g.defaultApp?(this._scriptPath=e[1],n=e.slice(2)):n=e.slice(1);break;case"user":n=e.slice(0);break;default:throw new Error(`unexpected parse option { from: '${t.from}' }`)}return!this._name&&this._scriptPath&&this.nameFromFilename(this._scriptPath),this._name=this._name||"program",n}parse(e,t){let n=this._prepareUserArgs(e,t);return this._parseCommand([],n),this}async parseAsync(e,t){let n=this._prepareUserArgs(e,t);return await this._parseCommand([],n),this}_executeSubCommand(e,t){t=t.slice();let n=!1,s=[".js",".ts",".tsx",".mjs",".cjs"];function r(c,h){let f=A.resolve(c,h);if(z.existsSync(f))return f;if(s.includes(A.extname(h)))return;let b=s.find(d=>z.existsSync(`${f}${d}`));if(b)return`${f}${b}`}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let m=e._executableFile||`${this._name}-${e._name}`,l=this._executableDir||"";if(this._scriptPath){let c;try{c=z.realpathSync(this._scriptPath)}catch{c=this._scriptPath}l=A.resolve(A.dirname(c),l)}if(l){let c=r(l,m);if(!c&&!e._executableFile&&this._scriptPath){let h=A.basename(this._scriptPath,A.extname(this._scriptPath));h!==this._name&&(c=r(l,`${h}-${e._name}`))}m=c||m}n=s.includes(A.extname(m));let o;g.platform!=="win32"?n?(t.unshift(m),t=ge(g.execArgv).concat(t),o=G.spawn(g.argv[0],t,{stdio:"inherit"})):o=G.spawn(m,t,{stdio:"inherit"}):(t.unshift(m),t=ge(g.execArgv).concat(t),o=G.spawn(g.execPath,t,{stdio:"inherit"})),o.killed||["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach(h=>{g.on(h,()=>{o.killed===!1&&o.exitCode===null&&o.kill(h)})});let a=this._exitCallback;o.on("close",(c,h)=>{c=c??1,a?a(new K(c,"commander.executeSubCommandAsync","(close)")):g.exit(c)}),o.on("error",c=>{if(c.code==="ENOENT"){let h=l?`searched for local subcommand relative to directory '${l}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",f=`'${m}' does not exist
|
|
15
15
|
- if '${e._name}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
|
|
16
16
|
- if the default executable name is not suitable, use the executableFile option to supply a custom name or path
|
|
17
|
-
- ${h}`;throw new Error(f)}else if(c.code==="EACCES")throw new Error(`'${m}' not executable`);if(!a)g.exit(1);else{let h=new
|
|
17
|
+
- ${h}`;throw new Error(f)}else if(c.code==="EACCES")throw new Error(`'${m}' not executable`);if(!a)g.exit(1);else{let h=new K(1,"commander.executeSubCommandAsync","(error)");h.nestedError=c,a(h)}}),this.runningCommand=o}_dispatchSubcommand(e,t,n){let s=this._findCommand(e);s||this.help({error:!0});let r;return r=this._chainOrCallSubCommandHook(r,s,"preSubcommand"),r=this._chainOrCall(r,()=>{if(s._executableHandler)this._executeSubCommand(s,t.concat(n));else return s._parseCommand(t,n)}),r}_dispatchHelpCommand(e){e||this.help();let t=this._findCommand(e);return t&&!t._executableHandler&&t.help(),this._dispatchSubcommand(e,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){this.registeredArguments.forEach((e,t)=>{e.required&&this.args[t]==null&&this.missingArgument(e.name())}),!(this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic)&&this.args.length>this.registeredArguments.length&&this._excessArguments(this.args)}_processArguments(){let e=(n,s,r)=>{let m=s;if(s!==null&&n.parseArg){let l=`error: command-argument value '${s}' is invalid for argument '${n.name()}'.`;m=this._callParseArg(n,s,r,l)}return m};this._checkNumberOfArguments();let t=[];this.registeredArguments.forEach((n,s)=>{let r=n.defaultValue;n.variadic?s<this.args.length?(r=this.args.slice(s),n.parseArg&&(r=r.reduce((m,l)=>e(n,l,m),n.defaultValue))):r===void 0&&(r=[]):s<this.args.length&&(r=this.args[s],n.parseArg&&(r=e(n,r,n.defaultValue))),t[s]=r}),this.processedArgs=t}_chainOrCall(e,t){return e&&e.then&&typeof e.then=="function"?e.then(()=>t()):t()}_chainOrCallHooks(e,t){let n=e,s=[];return this._getCommandAndAncestors().reverse().filter(r=>r._lifeCycleHooks[t]!==void 0).forEach(r=>{r._lifeCycleHooks[t].forEach(m=>{s.push({hookedCommand:r,callback:m})})}),t==="postAction"&&s.reverse(),s.forEach(r=>{n=this._chainOrCall(n,()=>r.callback(r.hookedCommand,this))}),n}_chainOrCallSubCommandHook(e,t,n){let s=e;return this._lifeCycleHooks[n]!==void 0&&this._lifeCycleHooks[n].forEach(r=>{s=this._chainOrCall(s,()=>r(this,t))}),s}_parseCommand(e,t){let n=this.parseOptions(t);if(this._parseOptionsEnv(),this._parseOptionsImplied(),e=e.concat(n.operands),t=n.unknown,this.args=e.concat(t),e&&this._findCommand(e[0]))return this._dispatchSubcommand(e[0],e.slice(1),t);if(this._getHelpCommand()&&e[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(e[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(t),this._dispatchSubcommand(this._defaultCommandName,e,t);this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName&&this.help({error:!0}),this._outputHelpIfRequested(n.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let s=()=>{n.unknown.length>0&&this.unknownOption(n.unknown[0])},r=`command:${this.name()}`;if(this._actionHandler){s(),this._processArguments();let m;return m=this._chainOrCallHooks(m,"preAction"),m=this._chainOrCall(m,()=>this._actionHandler(this.processedArgs)),this.parent&&(m=this._chainOrCall(m,()=>{this.parent.emit(r,e,t)})),m=this._chainOrCallHooks(m,"postAction"),m}if(this.parent&&this.parent.listenerCount(r))s(),this._processArguments(),this.parent.emit(r,e,t);else if(e.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",e,t);this.listenerCount("command:*")?this.emit("command:*",e,t):this.commands.length?this.unknownCommand():(s(),this._processArguments())}else this.commands.length?(s(),this.help({error:!0})):(s(),this._processArguments())}_findCommand(e){if(e)return this.commands.find(t=>t._name===e||t._aliases.includes(e))}_findOption(e){return this.options.find(t=>t.is(e))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(e=>{e.options.forEach(t=>{t.mandatory&&e.getOptionValue(t.attributeName())===void 0&&e.missingMandatoryOptionValue(t)})})}_checkForConflictingLocalOptions(){let e=this.options.filter(n=>{let s=n.attributeName();return this.getOptionValue(s)===void 0?!1:this.getOptionValueSource(s)!=="default"});e.filter(n=>n.conflictsWith.length>0).forEach(n=>{let s=e.find(r=>n.conflictsWith.includes(r.attributeName()));s&&this._conflictingOption(n,s)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(e=>{e._checkForConflictingLocalOptions()})}parseOptions(e){let t=[],n=[],s=t,r=e.slice();function m(o){return o.length>1&&o[0]==="-"}let l=null;for(;r.length;){let o=r.shift();if(o==="--"){s===n&&s.push(o),s.push(...r);break}if(l&&!m(o)){this.emit(`option:${l.name()}`,o);continue}if(l=null,m(o)){let a=this._findOption(o);if(a){if(a.required){let c=r.shift();c===void 0&&this.optionMissingArgument(a),this.emit(`option:${a.name()}`,c)}else if(a.optional){let c=null;r.length>0&&!m(r[0])&&(c=r.shift()),this.emit(`option:${a.name()}`,c)}else this.emit(`option:${a.name()}`);l=a.variadic?a:null;continue}}if(o.length>2&&o[0]==="-"&&o[1]!=="-"){let a=this._findOption(`-${o[1]}`);if(a){a.required||a.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${a.name()}`,o.slice(2)):(this.emit(`option:${a.name()}`),r.unshift(`-${o.slice(2)}`));continue}}if(/^--[^=]+=/.test(o)){let a=o.indexOf("="),c=this._findOption(o.slice(0,a));if(c&&(c.required||c.optional)){this.emit(`option:${c.name()}`,o.slice(a+1));continue}}if(m(o)&&(s=n),(this._enablePositionalOptions||this._passThroughOptions)&&t.length===0&&n.length===0){if(this._findCommand(o)){t.push(o),r.length>0&&n.push(...r);break}else if(this._getHelpCommand()&&o===this._getHelpCommand().name()){t.push(o),r.length>0&&t.push(...r);break}else if(this._defaultCommandName){n.push(o),r.length>0&&n.push(...r);break}}if(this._passThroughOptions){s.push(o),r.length>0&&s.push(...r);break}s.push(o)}return{operands:t,unknown:n}}opts(){if(this._storeOptionsAsProperties){let e={},t=this.options.length;for(let n=0;n<t;n++){let s=this.options[n].attributeName();e[s]=s===this._versionOptionName?this._version:this[s]}return e}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((e,t)=>Object.assign(e,t.opts()),{})}error(e,t){this._outputConfiguration.outputError(`${e}
|
|
18
18
|
`,this._outputConfiguration.writeErr),typeof this._showHelpAfterError=="string"?this._outputConfiguration.writeErr(`${this._showHelpAfterError}
|
|
19
19
|
`):this._showHelpAfterError&&(this._outputConfiguration.writeErr(`
|
|
20
20
|
`),this.outputHelp({error:!0}));let n=t||{},s=n.exitCode||1,r=n.code||"commander.error";this._exit(s,r,e)}_parseOptionsEnv(){this.options.forEach(e=>{if(e.envVar&&e.envVar in g.env){let t=e.attributeName();(this.getOptionValue(t)===void 0||["default","config","env"].includes(this.getOptionValueSource(t)))&&(e.required||e.optional?this.emit(`optionEnv:${e.name()}`,g.env[e.envVar]):this.emit(`optionEnv:${e.name()}`))}})}_parseOptionsImplied(){let e=new Ut(this.options),t=n=>this.getOptionValue(n)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(n));this.options.filter(n=>n.implied!==void 0&&t(n.attributeName())&&e.valueFromOption(this.getOptionValue(n.attributeName()),n)).forEach(n=>{Object.keys(n.implied).filter(s=>!t(s)).forEach(s=>{this.setOptionValueWithSource(s,n.implied[s],"implied")})})}missingArgument(e){let t=`error: missing required argument '${e}'`;this.error(t,{code:"commander.missingArgument"})}optionMissingArgument(e){let t=`error: option '${e.flags}' argument missing`;this.error(t,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(e){let t=`error: required option '${e.flags}' not specified`;this.error(t,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(e,t){let n=m=>{let l=m.attributeName(),o=this.getOptionValue(l),a=this.options.find(h=>h.negate&&l===h.attributeName()),c=this.options.find(h=>!h.negate&&l===h.attributeName());return a&&(a.presetArg===void 0&&o===!1||a.presetArg!==void 0&&o===a.presetArg)?a:c||m},s=m=>{let l=n(m),o=l.attributeName();return this.getOptionValueSource(o)==="env"?`environment variable '${l.envVar}'`:`option '${l.flags}'`},r=`error: ${s(e)} cannot be used with ${s(t)}`;this.error(r,{code:"commander.conflictingOption"})}unknownOption(e){if(this._allowUnknownOption)return;let t="";if(e.startsWith("--")&&this._showSuggestionAfterError){let s=[],r=this;do{let m=r.createHelp().visibleOptions(r).filter(l=>l.long).map(l=>l.long);s=s.concat(m),r=r.parent}while(r&&!r._enablePositionalOptions);t=fe(e,s)}let n=`error: unknown option '${e}'${t}`;this.error(n,{code:"commander.unknownOption"})}_excessArguments(e){if(this._allowExcessArguments)return;let t=this.registeredArguments.length,n=t===1?"":"s",r=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${t} argument${n} but got ${e.length}.`;this.error(r,{code:"commander.excessArguments"})}unknownCommand(){let e=this.args[0],t="";if(this._showSuggestionAfterError){let s=[];this.createHelp().visibleCommands(this).forEach(r=>{s.push(r.name()),r.alias()&&s.push(r.alias())}),t=fe(e,s)}let n=`error: unknown command '${e}'${t}`;this.error(n,{code:"commander.unknownCommand"})}version(e,t,n){if(e===void 0)return this._version;this._version=e,t=t||"-V, --version",n=n||"output the version number";let s=this.createOption(t,n);return this._versionOptionName=s.attributeName(),this._registerOption(s),this.on("option:"+s.name(),()=>{this._outputConfiguration.writeOut(`${e}
|
|
21
|
-
`),this._exit(0,"commander.version",e)}),this}description(e,t){return e===void 0&&t===void 0?this._description:(this._description=e,t&&(this._argsDescription=t),this)}summary(e){return e===void 0?this._summary:(this._summary=e,this)}alias(e){if(e===void 0)return this._aliases[0];let t=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(t=this.commands[this.commands.length-1]),e===t._name)throw new Error("Command alias can't be the same as its name");let n=this.parent?._findCommand(e);if(n){let s=[n.name()].concat(n.aliases()).join("|");throw new Error(`cannot add alias '${e}' to command '${this.name()}' as already have command '${s}'`)}return t._aliases.push(e),this}aliases(e){return e===void 0?this._aliases:(e.forEach(t=>this.alias(t)),this)}usage(e){if(e===void 0){if(this._usage)return this._usage;let t=this.registeredArguments.map(n=>Rt(n));return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?t:[]).join(" ")}return this._usage=e,this}name(e){return e===void 0?this._name:(this._name=e,this)}nameFromFilename(e){return this._name=
|
|
21
|
+
`),this._exit(0,"commander.version",e)}),this}description(e,t){return e===void 0&&t===void 0?this._description:(this._description=e,t&&(this._argsDescription=t),this)}summary(e){return e===void 0?this._summary:(this._summary=e,this)}alias(e){if(e===void 0)return this._aliases[0];let t=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(t=this.commands[this.commands.length-1]),e===t._name)throw new Error("Command alias can't be the same as its name");let n=this.parent?._findCommand(e);if(n){let s=[n.name()].concat(n.aliases()).join("|");throw new Error(`cannot add alias '${e}' to command '${this.name()}' as already have command '${s}'`)}return t._aliases.push(e),this}aliases(e){return e===void 0?this._aliases:(e.forEach(t=>this.alias(t)),this)}usage(e){if(e===void 0){if(this._usage)return this._usage;let t=this.registeredArguments.map(n=>Rt(n));return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?t:[]).join(" ")}return this._usage=e,this}name(e){return e===void 0?this._name:(this._name=e,this)}nameFromFilename(e){return this._name=A.basename(e,A.extname(e)),this}executableDir(e){return e===void 0?this._executableDir:(this._executableDir=e,this)}helpInformation(e){let t=this.createHelp();return t.helpWidth===void 0&&(t.helpWidth=e&&e.error?this._outputConfiguration.getErrHelpWidth():this._outputConfiguration.getOutHelpWidth()),t.formatHelp(this,t)}_getHelpContext(e){e=e||{};let t={error:!!e.error},n;return t.error?n=s=>this._outputConfiguration.writeErr(s):n=s=>this._outputConfiguration.writeOut(s),t.write=e.write||n,t.command=this,t}outputHelp(e){let t;typeof e=="function"&&(t=e,e=void 0);let n=this._getHelpContext(e);this._getCommandAndAncestors().reverse().forEach(r=>r.emit("beforeAllHelp",n)),this.emit("beforeHelp",n);let s=this.helpInformation(n);if(t&&(s=t(s),typeof s!="string"&&!Buffer.isBuffer(s)))throw new Error("outputHelp callback must return a string or a Buffer");n.write(s),this._getHelpOption()?.long&&this.emit(this._getHelpOption().long),this.emit("afterHelp",n),this._getCommandAndAncestors().forEach(r=>r.emit("afterAllHelp",n))}helpOption(e,t){return typeof e=="boolean"?(e?this._helpOption=this._helpOption??void 0:this._helpOption=null,this):(e=e??"-h, --help",t=t??"display help for command",this._helpOption=this.createOption(e,t),this)}_getHelpOption(){return this._helpOption===void 0&&this.helpOption(void 0,void 0),this._helpOption}addHelpOption(e){return this._helpOption=e,this}help(e){this.outputHelp(e);let t=g.exitCode||0;t===0&&e&&typeof e!="function"&&e.error&&(t=1),this._exit(t,"commander.help","(outputHelp)")}addHelpText(e,t){let n=["beforeAll","before","after","afterAll"];if(!n.includes(e))throw new Error(`Unexpected value for position to addHelpText.
|
|
22
22
|
Expecting one of '${n.join("', '")}'`);let s=`${e}Help`;return this.on(s,r=>{let m;typeof t=="function"?m=t({error:r.error,command:r.command}):m=t,m&&r.write(`${m}
|
|
23
|
-
`)}),this}_outputHelpIfRequested(e){let t=this._getHelpOption();t&&e.find(s=>t.is(s))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function ge(i){return i.map(e=>{if(!e.startsWith("--inspect"))return e;let t,n="127.0.0.1",s="9229",r;return(r=e.match(/^(--inspect(-brk)?)$/))!==null?t=r[1]:(r=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(t=r[1],/^\d+$/.test(r[3])?s=r[3]:n=r[3]):(r=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(t=r[1],n=r[3],s=r[4]),t&&s!=="0"?`${t}=${n}:${parseInt(s)+1}`:e})}_e.Command=
|
|
23
|
+
`)}),this}_outputHelpIfRequested(e){let t=this._getHelpOption();t&&e.find(s=>t.is(s))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function ge(i){return i.map(e=>{if(!e.startsWith("--inspect"))return e;let t,n="127.0.0.1",s="9229",r;return(r=e.match(/^(--inspect(-brk)?)$/))!==null?t=r[1]:(r=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(t=r[1],/^\d+$/.test(r[3])?s=r[3]:n=r[3]):(r=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(t=r[1],n=r[3],s=r[4]),t&&s!=="0"?`${t}=${n}:${parseInt(s)+1}`:e})}_e.Command=J});var Oe=_(y=>{var{Argument:we}=P(),{Command:Y}=be(),{CommanderError:Bt,InvalidArgumentError:ye}=V(),{Help:Gt}=L(),{Option:Ae}=B();y.program=new Y;y.createCommand=i=>new Y(i);y.createOption=(i,e)=>new Ae(i,e);y.createArgument=(i,e)=>new we(i,e);y.Command=Y;y.Option=Ae;y.Argument=we;y.Help=Gt;y.CommanderError=Bt;y.InvalidArgumentError=ye;y.InvalidOptionArgumentError=ye});var $e=_((Zn,ke)=>{ke.exports=Se;Se.sync=Kt;var ve=require("fs");function zt(i,e){var t=e.pathExt!==void 0?e.pathExt:process.env.PATHEXT;if(!t||(t=t.split(";"),t.indexOf("")!==-1))return!0;for(var n=0;n<t.length;n++){var s=t[n].toLowerCase();if(s&&i.substr(-s.length).toLowerCase()===s)return!0}return!1}function xe(i,e,t){return!i.isSymbolicLink()&&!i.isFile()?!1:zt(e,t)}function Se(i,e,t){ve.stat(i,function(n,s){t(n,n?!1:xe(s,i,e))})}function Kt(i,e){return xe(ve.statSync(i),i,e)}});var je=_((Qn,Pe)=>{Pe.exports=Ne;Ne.sync=Jt;var Ve=require("fs");function Ne(i,e,t){Ve.stat(i,function(n,s){t(n,n?!1:He(s,e))})}function Jt(i,e){return He(Ve.statSync(i),e)}function He(i,e){return i.isFile()&&Yt(i,e)}function Yt(i,e){var t=i.mode,n=i.uid,s=i.gid,r=e.uid!==void 0?e.uid:process.getuid&&process.getuid(),m=e.gid!==void 0?e.gid:process.getgid&&process.getgid(),l=parseInt("100",8),o=parseInt("010",8),a=parseInt("001",8),c=l|o,h=t&a||t&o&&s===m||t&l&&n===r||t&c&&r===0;return h}});var De=_((ti,Te)=>{var ei=require("fs"),j;process.platform==="win32"||global.TESTING_WINDOWS?j=$e():j=je();Te.exports=X;X.sync=Xt;function X(i,e,t){if(typeof e=="function"&&(t=e,e={}),!t){if(typeof Promise!="function")throw new TypeError("callback not provided");return new Promise(function(n,s){X(i,e||{},function(r,m){r?s(r):n(m)})})}j(i,e||{},function(n,s){n&&(n.code==="EACCES"||e&&e.ignoreErrors)&&(n=null,s=!1),t(n,s)})}function Xt(i,e){try{return j.sync(i,e||{})}catch(t){if(e&&e.ignoreErrors||t.code==="EACCES")return!1;throw t}}});var We=_((ni,Re)=>{var x=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys",Ie=require("path"),Zt=x?";":":",qe=De(),Fe=i=>Object.assign(new Error(`not found: ${i}`),{code:"ENOENT"}),Me=(i,e)=>{let t=e.colon||Zt,n=i.match(/\//)||x&&i.match(/\\/)?[""]:[...x?[process.cwd()]:[],...(e.path||process.env.PATH||"").split(t)],s=x?e.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",r=x?s.split(t):[""];return x&&i.indexOf(".")!==-1&&r[0]!==""&&r.unshift(""),{pathEnv:n,pathExt:r,pathExtExe:s}},Le=(i,e,t)=>{typeof e=="function"&&(t=e,e={}),e||(e={});let{pathEnv:n,pathExt:s,pathExtExe:r}=Me(i,e),m=[],l=a=>new Promise((c,h)=>{if(a===n.length)return e.all&&m.length?c(m):h(Fe(i));let f=n[a],b=/^".*"$/.test(f)?f.slice(1,-1):f,d=Ie.join(b,i),w=!b&&/^\.[\\\/]/.test(i)?i.slice(0,2)+d:d;c(o(w,a,0))}),o=(a,c,h)=>new Promise((f,b)=>{if(h===s.length)return f(l(c+1));let d=s[h];qe(a+d,{pathExt:r},(w,$)=>{if(!w&&$)if(e.all)m.push(a+d);else return f(a+d);return f(o(a,c,h+1))})});return t?l(0).then(a=>t(null,a),t):l(0)},Qt=(i,e)=>{e=e||{};let{pathEnv:t,pathExt:n,pathExtExe:s}=Me(i,e),r=[];for(let m=0;m<t.length;m++){let l=t[m],o=/^".*"$/.test(l)?l.slice(1,-1):l,a=Ie.join(o,i),c=!o&&/^\.[\\\/]/.test(i)?i.slice(0,2)+a:a;for(let h=0;h<n.length;h++){let f=c+n[h];try{if(qe.sync(f,{pathExt:s}))if(e.all)r.push(f);else return f}catch{}}}if(e.all&&r.length)return r;if(e.nothrow)return null;throw Fe(i)};Re.exports=Le;Le.sync=Qt});var Be=_((ii,Z)=>{"use strict";var Ue=(i={})=>{let e=i.env||process.env;return(i.platform||process.platform)!=="win32"?"PATH":Object.keys(e).reverse().find(n=>n.toUpperCase()==="PATH")||"Path"};Z.exports=Ue;Z.exports.default=Ue});var Je=_((si,Ke)=>{"use strict";var Ge=require("path"),en=We(),tn=Be();function ze(i,e){let t=i.options.env||process.env,n=process.cwd(),s=i.options.cwd!=null,r=s&&process.chdir!==void 0&&!process.chdir.disabled;if(r)try{process.chdir(i.options.cwd)}catch{}let m;try{m=en.sync(i.command,{path:t[tn({env:t})],pathExt:e?Ge.delimiter:void 0})}catch{}finally{r&&process.chdir(n)}return m&&(m=Ge.resolve(s?i.options.cwd:"",m)),m}function nn(i){return ze(i)||ze(i,!0)}Ke.exports=nn});var Ye=_((ri,ee)=>{"use strict";var Q=/([()\][%!^"`<>&|;, *?])/g;function sn(i){return i=i.replace(Q,"^$1"),i}function rn(i,e){return i=`${i}`,i=i.replace(/(\\*)"/g,'$1$1\\"'),i=i.replace(/(\\*)$/,"$1$1"),i=`"${i}"`,i=i.replace(Q,"^$1"),e&&(i=i.replace(Q,"^$1")),i}ee.exports.command=sn;ee.exports.argument=rn});var Ze=_((mi,Xe)=>{"use strict";Xe.exports=/^#!(.*)/});var et=_((oi,Qe)=>{"use strict";var mn=Ze();Qe.exports=(i="")=>{let e=i.match(mn);if(!e)return null;let[t,n]=e[0].replace(/#! ?/,"").split(" "),s=t.split("/").pop();return s==="env"?n:n?`${s} ${n}`:s}});var nt=_((ai,tt)=>{"use strict";var te=require("fs"),on=et();function an(i){let t=Buffer.alloc(150),n;try{n=te.openSync(i,"r"),te.readSync(n,t,0,150,0),te.closeSync(n)}catch{}return on(t.toString())}tt.exports=an});var mt=_((li,rt)=>{"use strict";var ln=require("path"),it=Je(),st=Ye(),cn=nt(),un=process.platform==="win32",hn=/\.(?:com|exe)$/i,pn=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function dn(i){i.file=it(i);let e=i.file&&cn(i.file);return e?(i.args.unshift(i.file),i.command=e,it(i)):i.file}function fn(i){if(!un)return i;let e=dn(i),t=!hn.test(e);if(i.options.forceShell||t){let n=pn.test(e);i.command=ln.normalize(i.command),i.command=st.command(i.command),i.args=i.args.map(r=>st.argument(r,n));let s=[i.command].concat(i.args).join(" ");i.args=["/d","/s","/c",`"${s}"`],i.command=process.env.comspec||"cmd.exe",i.options.windowsVerbatimArguments=!0}return i}function gn(i,e,t){e&&!Array.isArray(e)&&(t=e,e=null),e=e?e.slice(0):[],t=Object.assign({},t);let n={command:i,args:e,options:t,file:void 0,original:{command:i,args:e}};return t.shell?n:fn(n)}rt.exports=gn});var lt=_((ci,at)=>{"use strict";var ne=process.platform==="win32";function ie(i,e){return Object.assign(new Error(`${e} ${i.command} ENOENT`),{code:"ENOENT",errno:"ENOENT",syscall:`${e} ${i.command}`,path:i.command,spawnargs:i.args})}function _n(i,e){if(!ne)return;let t=i.emit;i.emit=function(n,s){if(n==="exit"){let r=ot(s,e,"spawn");if(r)return t.call(i,"error",r)}return t.apply(i,arguments)}}function ot(i,e){return ne&&i===1&&!e.file?ie(e.original,"spawn"):null}function bn(i,e){return ne&&i===1&&!e.file?ie(e.original,"spawnSync"):null}at.exports={hookChildProcess:_n,verifyENOENT:ot,verifyENOENTSync:bn,notFoundError:ie}});var ht=_((ui,S)=>{"use strict";var ct=require("child_process"),se=mt(),re=lt();function ut(i,e,t){let n=se(i,e,t),s=ct.spawn(n.command,n.args,n.options);return re.hookChildProcess(s,n),s}function wn(i,e,t){let n=se(i,e,t),s=ct.spawnSync(n.command,n.args,n.options);return s.error=s.error||re.verifyENOENTSync(s.status,n),s}S.exports=ut;S.exports.spawn=ut;S.exports.sync=wn;S.exports._parse=se;S.exports._enoent=re});var Ce=v(Oe(),1),{program:Rn,createCommand:Wn,createArgument:Un,createOption:Bn,CommanderError:Gn,InvalidArgumentError:zn,InvalidOptionArgumentError:Kn,Command:Ee,Argument:Jn,Option:C,Help:Yn}=Ce.default;var E=v(ht()),p=v(require("fs")),Et=v(require("os")),u=v(require("path"));var yn=/[\p{Lu}]/u,An=/[\p{Ll}]/u,pt=/^[\p{Lu}](?![\p{Lu}])/gu,gt=/([\p{Alpha}\p{N}_]|$)/u,me=/[_.\- ]+/,On=new RegExp("^"+me.source),dt=new RegExp(me.source+gt.source,"gu"),ft=new RegExp("\\d+"+gt.source,"gu"),Cn=(i,e,t,n)=>{let s=!1,r=!1,m=!1,l=!1;for(let o=0;o<i.length;o++){let a=i[o];l=o>2?i[o-3]==="-":!0,s&&yn.test(a)?(i=i.slice(0,o)+"-"+i.slice(o),s=!1,m=r,r=!0,o++):r&&m&&An.test(a)&&(!l||n)?(i=i.slice(0,o-1)+"-"+i.slice(o-1),m=r,r=!1,s=!0):(s=e(a)===a&&t(a)!==a,m=r,r=t(a)===a&&e(a)!==a)}return i},En=(i,e)=>(pt.lastIndex=0,i.replaceAll(pt,t=>e(t))),vn=(i,e)=>(dt.lastIndex=0,ft.lastIndex=0,i.replaceAll(ft,(t,n,s)=>["_","-"].includes(i.charAt(s+t.length))?t:e(t)).replaceAll(dt,(t,n)=>e(n)));function oe(i,e){if(!(typeof i=="string"||Array.isArray(i)))throw new TypeError("Expected the input to be `string | string[]`");if(e={pascalCase:!1,preserveConsecutiveUppercase:!1,...e},Array.isArray(i)?i=i.map(r=>r.trim()).filter(r=>r.length).join("-"):i=i.trim(),i.length===0)return"";let t=e.locale===!1?r=>r.toLowerCase():r=>r.toLocaleLowerCase(e.locale),n=e.locale===!1?r=>r.toUpperCase():r=>r.toLocaleUpperCase(e.locale);return i.length===1?me.test(i)?"":e.pascalCase?n(i):t(i):(i!==t(i)&&(i=Cn(i,t,n,e.preserveConsecutiveUppercase)),i=i.replace(On,""),i=e.preserveConsecutiveUppercase?En(i,t):t(i),e.pascalCase&&(i=n(i.charAt(0))+i.slice(1)),vn(i,n))}var T="1.1.3";var bt=()=>{N(),console.log(`
|
|
24
24
|
\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@
|
|
25
25
|
\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m \x1B[38;5;016m \x1B[38;5;016m \x1B[38;5;016m \x1B[38;5;016m \x1B[38;5;016m \x1B[38;5;016m \x1B[38;5;016m \x1B[38;5;016m \x1B[38;5;016m \x1B[38;5;016m \x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@
|
|
26
26
|
\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;016m \x1B[38;5;016m \x1B[38;5;016m \x1B[38;5;016m \x1B[38;5;016m \x1B[38;5;016m \x1B[38;5;016m \x1B[38;5;016m \x1B[38;5;016m \x1B[38;5;016m \x1B[38;5;016m \x1B[38;5;016m \x1B[38;5;016m \x1B[38;5;016m \x1B[38;5;016m \x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@
|
|
@@ -44,4 +44,4 @@ Expecting one of '${n.join("', '")}'`);let s=`${e}Help`;return this.on(s,r=>{let
|
|
|
44
44
|
\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;016m \x1B[38;5;016m \x1B[38;5;016m \x1B[38;5;016m \x1B[38;5;016m \x1B[38;5;016m \x1B[38;5;016m \x1B[38;5;016m \x1B[38;5;016m \x1B[38;5;016m \x1B[38;5;016m \x1B[38;5;016m \x1B[38;5;016m \x1B[38;5;016m \x1B[38;5;m \x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@
|
|
45
45
|
\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m/\x1B[38;5;016m \x1B[38;5;016m \x1B[38;5;016m \x1B[38;5;016m \x1B[38;5;016m \x1B[38;5;016m \x1B[38;5;016m \x1B[38;5;016m \x1B[38;5;016m \x1B[38;5;016m \x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@
|
|
46
46
|
\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@\x1B[38;5;m@
|
|
47
|
-
\x1B[0m`),console.log(""),console.log("---------------------- Seeka Apps CLI ----------------------"),console.log(`-------------------------- v${T} -------------------------`),console.log(""),console.log("https://developers.seeka.co"),console.log("for help: npx @seeka-labs/cli-apps@latest --help"),console.log("for scaffolding help: npx @seeka-labs/cli-apps@latest init --help"),N()},N=()=>{console.log(""),console.log("------------------------------------------------------------"),console.log("")};var k=v(require("fs")),wt=require("os"),yt=i=>/^[a-zA-Z0-9-]+$/.test(i);function
|
|
47
|
+
\x1B[0m`),console.log(""),console.log("---------------------- Seeka Apps CLI ----------------------"),console.log(`-------------------------- v${T} -------------------------`),console.log(""),console.log("https://developers.seeka.co"),console.log("for help: npx @seeka-labs/cli-apps@latest --help"),console.log("for scaffolding help: npx @seeka-labs/cli-apps@latest init --help"),N()},N=()=>{console.log(""),console.log("------------------------------------------------------------"),console.log("")};var k=v(require("fs")),wt=require("os"),yt=i=>/^[a-zA-Z0-9-]+$/.test(i);function At(i){try{let e=k.opendirSync(i),t=e.readSync();return e.closeSync(),t===null}catch{return!1}}function Ot(i){let e={};return!i||i.length===0||i.forEach(t=>{let n=t.indexOf("=");if(n===-1){e[t]="";return}let s=t.substring(0,n),r=t.substring(n+1);e[s]=r}),e}var Sn=i=>k.readFileSync(i,"utf-8").split(wt.EOL);var kn=(i,e,t)=>{let n=Sn(i),s=n.find(r=>r.split("=")[0]===e);if(s!==void 0){let r=n.indexOf(s);n.splice(r,1,`${e}="${t}"`)}else n.push(`${e}="${t}"`);k.writeFileSync(i,n.join(wt.EOL))},ae=(i,e)=>{e&&Object.keys(e).forEach(t=>{kn(i,t,e[t])})};var vt=i=>{if(!yt(i.appName)){console.error("App name must be alphanumeric and hyphens only");return}if(!i.appName.startsWith("seeka-app-")){console.error("App name must start with seeka-app-");return}let e=i.appName,t=oe(i.appName.replace("seeka-app-",""),{pascalCase:!0}),n=u.resolve(i.outputDirectory,i.skipSubDir?"":i.directoryName||e);console.log(`Creating new ${i.template.replace(/-/g," ")} Seeka app in ${n}`),console.log("");let s=u.resolve(n,".git"),r=p.existsSync(s),m=u.resolve(Et.default.tmpdir(),".seeka-app-init-git-"+new Date().getTime());if(!i.skipSubDir&&p.existsSync(n)&&At(n)===!1)if(i.force)console.log("--force was used and destination directory is not empty. Clearing out the directory"),r&&(console.info(".git directory found in directory, I will preserve it and remove all other files and directories to prepare for the app creation"),p.cpSync(s,m,{recursive:!0})),p.rmSync(n,{recursive:!0,force:!0});else{console.error("Directory is not empty. Use --force to create app in non-empty directory");return}p.existsSync(n)||p.mkdirSync(n,{recursive:!0}),r&&(p.cpSync(m,s,{recursive:!0}),p.rmSync(m,{recursive:!0}),console.info("Restored .git directory"));let l=u.resolve(__dirname,"init-templates"),o=u.resolve(l,i.template);p.cpSync(o,n,{recursive:!0}),p.renameSync(u.join(n,".example.gitignore"),u.join(n,".gitignore"));let a=require(u.join(n,"package.json"));a.name=i.appName,a.version=T,a.description=`Seeka app ${i.appName}`,a.author=`${i.developerName} <${i.developerEmail}>`,a.scripts.deploy=a.scripts.deploy.replace(/seeka-app-example-name/i,i.appName),a.scripts.tunnel=a.scripts.tunnel.replace(/seeka-app-example-name/i,i.appName);let c=u.join(n,"README.md"),h=p.readFileSync(c,"utf8");h=h.replace(/seeka-app-example-name/g,i.appName),p.writeFileSync(c,h);let f=u.join(n,".gitlab-ci.yml"),b=p.readFileSync(f,"utf8");switch(b=b.replace(/seeka-app-example-name/g,i.appName),p.writeFileSync(f,b),i.template){case"aws-lambda":Pn(i,n,a,t);break;case"azure-function":Nn(i,n,a,t);break;case"netlify-function":Hn(i,n,a,t);break}if(O(u.join(n,"src","lib","state","seeka","installations.ts"),{SampleApp:t+"App"}),Vn(i,n,l,t),$n(i,a),p.writeFileSync(u.join(n,"package.json"),JSON.stringify(a,null,2)),console.info("Scaffolded package.json"),console.log(""),i.installDependencies)switch(console.info("Installing dependencies with "+i.packageManager),i.packageManager){case"npm":E.sync("npm",["install"],{stdio:"inherit",cwd:n}),i.browser&&E.sync("npm",["install"],{stdio:"inherit",cwd:u.join(n,"src","browser")});break;case"pnpm":E.sync("pnpm",["install"],{stdio:"inherit",cwd:n}),i.browser&&E.sync("pnpm",["install"],{stdio:"inherit",cwd:u.join(n,"src","browser")});break;case"yarn":E.sync("yarn",["install"],{stdio:"inherit",cwd:n}),i.browser&&E.sync("yarn",["install"],{stdio:"inherit",cwd:u.join(n,"src","browser")});break;default:console.error("Invalid package manager");return}N(),console.log(`Created ${e} in ${n}`),console.log("Boom! Your new Seeka app is ready!"),N();let d=i.skipSubDir?n:u.relative(process.cwd(),n);console.log(`Run "cd ${d}" to change to your apps directory and start creating some magic!`),console.log(""),console.log("")},$n=(i,e)=>{let t;switch(i.packageManager){case"npm":t="npm run";break;case"pnpm":t="pnpm run";break;case"yarn":t="yarn";break;default:console.error("Invalid package manager");return}for(let n in e.scripts)e.scripts[n]=e.scripts[n].replace(/<packageManagerRunPrefix>/g,t);e.dependencies&&e.dependencies["@seeka-labs/sdk-apps-server"]&&(e.dependencies["@seeka-labs/sdk-apps-server"]="^"+e.version)},Vn=(i,e,t,n)=>{if(!i.browser){Ct(e);return}if(i.template!=="azure-function"){console.warn("Browser plugin is only supported for Azure function template, skipping browser plugin creation"),Ct(e);return}p.mkdirSync(u.join(e,"src","browser"),{recursive:!0}),p.cpSync(u.join(t,"browser"),u.join(e,"src","browser"),{recursive:!0});let s=u.join(e,"src","browser"),r=require(u.join(s,"package.json"));r.name=r.name.replace(/seeka-app-example-name/i,i.appName),r.description=r.description.replace(/seeka-app-example-name/i,i.appName),r.scripts.build=r.scripts.build.replace(/seeka-app-example-name/i,i.appName),r.scripts["build:dev"]=r.scripts["build:dev"].replace(/seeka-app-example-name/i,i.appName),r.scripts.watch=r.scripts.watch.replace(/seeka-app-example-name/i,i.appName),p.writeFileSync(u.join(s,"package.json"),JSON.stringify(r,null,2)),O(u.join(e,"src","lib","browser","index.ts"),{"seeka-app-example-name":i.appName}),O(u.join(s,"README.md"),{"seeka-app-example-name":i.appName}),O(u.join(s,"src","plugin","index.ts"),{"seeka-app-example-name":i.appName,SampleApp:n+"App"}),O(u.join(s,"src","browser.ts"),{SampleApp:n+"App"}),O(u.join(s,"package.json"),{SampleApp:n+"App"}),console.info("Scaffolded browser plugin"),console.log("")},O=(i,e)=>{let t=p.readFileSync(i,"utf8");for(let n in e)t=t.replace(new RegExp(n,"g"),e[n]);p.writeFileSync(i,t)},Ct=i=>{p.rmSync(u.join(i,"src","lib","browser"),{recursive:!0})},Nn=(i,e,t,n)=>{if(p.renameSync(u.join(e,"local.settings.example.json"),u.join(e,"local.settings.json")),i.environmentVariables&&Object.keys(i.environmentVariables).length>0){let s=require(u.join(e,"local.settings.json"));s.Values={...s.Values,...i.environmentVariables},p.writeFileSync(u.join(e,"local.settings.json"),JSON.stringify(s,null,2))}i.browser&&(t.scripts.build="tsc && cd src/browser && yarn && yarn build && cd ../",t.scripts.watch="cd src/browser && yarn && yarn build && cd ../ && tsc -w"),O(u.join(e,"src","lib","browser","models","index.ts"),{SampleApp:n+"App"}),O(u.join(e,"src","lib","browser","index.ts"),{SampleApp:n+"App"}),console.info("Scaffolded Azure function")},Hn=(i,e,t,n)=>{p.renameSync(u.join(e,".env.example"),u.join(e,".env")),i.environmentVariables&&Object.keys(i.environmentVariables).length>0&&ae(u.join(e,".env"),i.environmentVariables),console.info("Scaffolded Netlify function")},Pn=(i,e,t,n)=>{p.renameSync(u.join(e,".env.example"),u.join(e,".env")),i.environmentVariables&&Object.keys(i.environmentVariables).length>0&&ae(u.join(e,".env"),i.environmentVariables),console.info("Scaffolded AWS lambda function")};var le=new Ee;bt();le.command("init").description("initialises a new Seeka app").argument("<name>",'name of your app. alphanumeric and hyphens only and must start with "seeka-app-"').addOption(new C("--template <template>","app template").choices(["azure-function","aws-lambda","netlify-function"]).makeOptionMandatory()).addOption(new C("--developer <developer>","app developer name or company").makeOptionMandatory()).addOption(new C("--email <email>","app developer email").makeOptionMandatory()).addOption(new C("--outName [outName]","directory name of the app. a new directory will be created with this name to contain the app.")).addOption(new C("--outDir [outDir]","output directory to create the app in. a new directory will be created here that contains the app.").default("","current working dir")).addOption(new C("--packageManager [packageManager]","package manager").choices(["yarn","npm","pnpm"]).default("yarn")).option("--noDependencies","skip installing dependencies").option("--skipSubDir","use sub directory for app files instead of root folder").option("--force","force creation of app in non-empty directory").option("--browser","adds support for browser plugin served from the app").option("--env [env...]","sets environment variables for the app. Use format of --env KEY1=VALUE1 KEY2=VALUE2").action((i,e)=>{let t={appName:i,template:e.template,skipSubDir:e.skipSubDir,browser:e.browser,outputDirectory:e.outDir||process.cwd(),directoryName:e.outName||void 0,packageManager:e.packageManager,developerEmail:e.email,developerName:e.developer,installDependencies:!e.noDependencies,force:e.force,environmentVariables:Ot(e.env)};vt(t)}).showHelpAfterError(!0);le.showHelpAfterError(!0);le.parse();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@seeka-labs/cli-apps",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.3",
|
|
4
4
|
"description": "Seeka - Apps CLI",
|
|
5
5
|
"author": "SEEKA <platform@seeka.co>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -26,7 +26,9 @@
|
|
|
26
26
|
"build:templates": "node ./scripts/build-templates.js",
|
|
27
27
|
"watch": "tsc -w",
|
|
28
28
|
"clean": "yarn rimraf dist",
|
|
29
|
-
"dev": "yarn run clean && yarn build && rimraf seeka-app-test1 && node dist/index.js init seeka-app-test1 --template azure-function --email 'dev@seeka.co' --developer Seeka --noDependencies --browser --env 'SEEKA_APP_ID=123' 'SEEKA_APP_SECRET=345' --packageManager yarn"
|
|
29
|
+
"dev": "yarn run clean && yarn build && rimraf seeka-app-test1 && node dist/index.js init seeka-app-test1 --template azure-function --email 'dev@seeka.co' --developer Seeka --noDependencies --browser --env 'SEEKA_APP_ID=123' 'SEEKA_APP_SECRET=345' --packageManager yarn",
|
|
30
|
+
"dev:skipSubDir": "yarn run clean && yarn build && rimraf seeka-app-test1 && mkdir seeka-app-test1 && cd seeka-app-test1 && mkdir rootfolder && cd rootfolder && node ../../dist/index.js init seeka-app-test1 --template azure-function --skipSubDir --email 'dev@seeka.co' --developer Seeka --noDependencies --browser --env 'SEEKA_APP_ID=123' 'SEEKA_APP_SECRET=345' --packageManager yarn",
|
|
31
|
+
"dev:skipSubDir2": "yarn run clean && yarn build && cd seeka-app-test2 && node ../dist/index.js init seeka-app-test1 --template azure-function --skipSubDir --email 'dev@seeka.co' --developer Seeka --noDependencies --browser --env 'SEEKA_APP_ID=123' 'SEEKA_APP_SECRET=345' --packageManager yarn"
|
|
30
32
|
},
|
|
31
33
|
"devDependencies": {
|
|
32
34
|
"@jest/globals": "^29.7.0",
|