@baic/yolk-cli 2.1.0-alpha.228 → 2.1.0-alpha.229
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/compiled/commander/index.js +1 -1
- package/compiled/commander/package.json +1 -1
- package/es/.lintstagedrc.js +1 -1
- package/es/_util.js +1 -1
- package/es/yolk.js +1 -1
- package/lib/.lintstagedrc.js +1 -1
- package/lib/_util.js +1 -1
- package/lib/yolk.js +1 -1
- package/package.json +4 -5
- package/templates/miniprogram/config/index.ts.tpl +1 -1
- package/templates/umi-web-screen/.umirc.ts.tpl +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(){var t={81:function(t){"use strict";t.exports=require("child_process")},361:function(t){"use strict";t.exports=require("events")},147:function(t){"use strict";t.exports=require("fs")},17:function(t){"use strict";t.exports=require("path")},282:function(t){"use strict";t.exports=require("process")},400:function(t,e,i){const{InvalidArgumentError:n}=i(24);class Argument{constructor(t,e){this.description=e||"";this.variadic=false;this.parseArg=undefined;this.defaultValue=undefined;this.defaultValueDescription=undefined;this.argChoices=undefined;switch(t[0]){case"<":this.required=true;this._name=t.slice(1,-1);break;case"[":this.required=false;this._name=t.slice(1,-1);break;default:this.required=true;this._name=t;break}if(this._name.length>3&&this._name.slice(-3)==="..."){this.variadic=true;this._name=this._name.slice(0,-3)}}name(){return this._name}_concatValue(t,e){if(e===this.defaultValue||!Array.isArray(e)){return[t]}return e.concat(t)}default(t,e){this.defaultValue=t;this.defaultValueDescription=e;return this}argParser(t){this.parseArg=t;return this}choices(t){this.argChoices=t.slice();this.parseArg=(t,e)=>{if(!this.argChoices.includes(t)){throw new n(`Allowed choices are ${this.argChoices.join(", ")}.`)}if(this.variadic){return this._concatValue(t,e)}return t};return this}argRequired(){this.required=true;return this}argOptional(){this.required=false;return this}}function humanReadableArgName(t){const e=t.name()+(t.variadic===true?"...":"");return t.required?"<"+e+">":"["+e+"]"}e.Argument=Argument;e.humanReadableArgName=humanReadableArgName},220:function(t,e,i){const n=i(361).EventEmitter;const s=i(81);const r=i(17);const o=i(147);const a=i(282);const{Argument:h,humanReadableArgName:l}=i(400);const{CommanderError:u}=i(24);const{Help:c}=i(505);const{Option:p,DualOptions:d}=i(663);const{suggestSimilar:m}=i(861);class Command extends n{constructor(t){super();this.commands=[];this.options=[];this.parent=null;this._allowUnknownOption=false;this._allowExcessArguments=true;this.registeredArguments=[];this._args=this.registeredArguments;this.args=[];this.rawArgs=[];this.processedArgs=[];this._scriptPath=null;this._name=t||"";this._optionValues={};this._optionValueSources={};this._storeOptionsAsProperties=false;this._actionHandler=null;this._executableHandler=false;this._executableFile=null;this._executableDir=null;this._defaultCommandName=null;this._exitCallback=null;this._aliases=[];this._combineFlagAndOptionalValue=true;this._description="";this._summary="";this._argsDescription=undefined;this._enablePositionalOptions=false;this._passThroughOptions=false;this._lifeCycleHooks={};this._showHelpAfterError=false;this._showSuggestionAfterError=true;this._outputConfiguration={writeOut:t=>a.stdout.write(t),writeErr:t=>a.stderr.write(t),getOutHelpWidth:()=>a.stdout.isTTY?a.stdout.columns:undefined,getErrHelpWidth:()=>a.stderr.isTTY?a.stderr.columns:undefined,outputError:(t,e)=>e(t)};this._hidden=false;this._helpOption=undefined;this._addImplicitHelpCommand=undefined;this._helpCommand=undefined;this._helpConfiguration={}}copyInheritedSettings(t){this._outputConfiguration=t._outputConfiguration;this._helpOption=t._helpOption;this._helpCommand=t._helpCommand;this._helpConfiguration=t._helpConfiguration;this._exitCallback=t._exitCallback;this._storeOptionsAsProperties=t._storeOptionsAsProperties;this._combineFlagAndOptionalValue=t._combineFlagAndOptionalValue;this._allowExcessArguments=t._allowExcessArguments;this._enablePositionalOptions=t._enablePositionalOptions;this._showHelpAfterError=t._showHelpAfterError;this._showSuggestionAfterError=t._showSuggestionAfterError;return this}_getCommandAndAncestors(){const t=[];for(let e=this;e;e=e.parent){t.push(e)}return t}command(t,e,i){let n=e;let s=i;if(typeof n==="object"&&n!==null){s=n;n=null}s=s||{};const[,r,o]=t.match(/([^ ]+) *(.*)/);const a=this.createCommand(r);if(n){a.description(n);a._executableHandler=true}if(s.isDefault)this._defaultCommandName=a._name;a._hidden=!!(s.noHelp||s.hidden);a._executableFile=s.executableFile||null;if(o)a.arguments(o);this._registerCommand(a);a.parent=this;a.copyInheritedSettings(this);if(n)return this;return a}createCommand(t){return new Command(t)}createHelp(){return Object.assign(new c,this.configureHelp())}configureHelp(t){if(t===undefined)return this._helpConfiguration;this._helpConfiguration=t;return this}configureOutput(t){if(t===undefined)return this._outputConfiguration;Object.assign(this._outputConfiguration,t);return this}showHelpAfterError(t=true){if(typeof t!=="string")t=!!t;this._showHelpAfterError=t;return this}showSuggestionAfterError(t=true){this._showSuggestionAfterError=!!t;return this}addCommand(t,e){if(!t._name){throw new Error(`Command passed to .addCommand() must have a name\n- specify the name in Command constructor or using .name()`)}e=e||{};if(e.isDefault)this._defaultCommandName=t._name;if(e.noHelp||e.hidden)t._hidden=true;this._registerCommand(t);t.parent=this;t._checkForBrokenPassThrough();return this}createArgument(t,e){return new h(t,e)}argument(t,e,i,n){const s=this.createArgument(t,e);if(typeof i==="function"){s.default(n).argParser(i)}else{s.default(i)}this.addArgument(s);return this}arguments(t){t.trim().split(/ +/).forEach((t=>{this.argument(t)}));return this}addArgument(t){const e=this.registeredArguments.slice(-1)[0];if(e&&e.variadic){throw new Error(`only the last argument can be variadic '${e.name()}'`)}if(t.required&&t.defaultValue!==undefined&&t.parseArg===undefined){throw new Error(`a default value for a required argument is never used: '${t.name()}'`)}this.registeredArguments.push(t);return this}helpCommand(t,e){if(typeof t==="boolean"){this._addImplicitHelpCommand=t;return this}t=t??"help [command]";const[,i,n]=t.match(/([^ ]+) *(.*)/);const s=e??"display help for command";const r=this.createCommand(i);r.helpOption(false);if(n)r.arguments(n);if(s)r.description(s);this._addImplicitHelpCommand=true;this._helpCommand=r;return this}addHelpCommand(t,e){if(typeof t!=="object"){this.helpCommand(t,e);return this}this._addImplicitHelpCommand=true;this._helpCommand=t;return this}_getHelpCommand(){const t=this._addImplicitHelpCommand??(this.commands.length&&!this._actionHandler&&!this._findCommand("help"));if(t){if(this._helpCommand===undefined){this.helpCommand(undefined,undefined)}return this._helpCommand}return null}hook(t,e){const i=["preSubcommand","preAction","postAction"];if(!i.includes(t)){throw new Error(`Unexpected value for event passed to hook : '${t}'.\nExpecting one of '${i.join("', '")}'`)}if(this._lifeCycleHooks[t]){this._lifeCycleHooks[t].push(e)}else{this._lifeCycleHooks[t]=[e]}return this}exitOverride(t){if(t){this._exitCallback=t}else{this._exitCallback=t=>{if(t.code!=="commander.executeSubCommandAsync"){throw t}else{}}}return this}_exit(t,e,i){if(this._exitCallback){this._exitCallback(new u(t,e,i))}a.exit(t)}action(t){const listener=e=>{const i=this.registeredArguments.length;const n=e.slice(0,i);if(this._storeOptionsAsProperties){n[i]=this}else{n[i]=this.opts()}n.push(this);return t.apply(this,n)};this._actionHandler=listener;return this}createOption(t,e){return new p(t,e)}_callParseArg(t,e,i,n){try{return t.parseArg(e,i)}catch(t){if(t.code==="commander.invalidArgument"){const e=`${n} ${t.message}`;this.error(e,{exitCode:t.exitCode,code:t.code})}throw t}}_registerOption(t){const e=t.short&&this._findOption(t.short)||t.long&&this._findOption(t.long);if(e){const i=t.long&&this._findOption(t.long)?t.long:t.short;throw new Error(`Cannot add option '${t.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${i}'\n- already used by option '${e.flags}'`)}this.options.push(t)}_registerCommand(t){const knownBy=t=>[t.name()].concat(t.aliases());const e=knownBy(t).find((t=>this._findCommand(t)));if(e){const i=knownBy(this._findCommand(e)).join("|");const n=knownBy(t).join("|");throw new Error(`cannot add command '${n}' as already have command '${i}'`)}this.commands.push(t)}addOption(t){this._registerOption(t);const e=t.name();const i=t.attributeName();if(t.negate){const e=t.long.replace(/^--no-/,"--");if(!this._findOption(e)){this.setOptionValueWithSource(i,t.defaultValue===undefined?true:t.defaultValue,"default")}}else if(t.defaultValue!==undefined){this.setOptionValueWithSource(i,t.defaultValue,"default")}const handleOptionValue=(e,n,s)=>{if(e==null&&t.presetArg!==undefined){e=t.presetArg}const r=this.getOptionValue(i);if(e!==null&&t.parseArg){e=this._callParseArg(t,e,r,n)}else if(e!==null&&t.variadic){e=t._concatValue(e,r)}if(e==null){if(t.negate){e=false}else if(t.isBoolean()||t.optional){e=true}else{e=""}}this.setOptionValueWithSource(i,e,s)};this.on("option:"+e,(e=>{const i=`error: option '${t.flags}' argument '${e}' is invalid.`;handleOptionValue(e,i,"cli")}));if(t.envVar){this.on("optionEnv:"+e,(e=>{const i=`error: option '${t.flags}' value '${e}' from env '${t.envVar}' is invalid.`;handleOptionValue(e,i,"env")}))}return this}_optionEx(t,e,i,n,s){if(typeof e==="object"&&e instanceof p){throw new Error("To add an Option object use addOption() instead of option() or requiredOption()")}const r=this.createOption(e,i);r.makeOptionMandatory(!!t.mandatory);if(typeof n==="function"){r.default(s).argParser(n)}else if(n instanceof RegExp){const t=n;n=(e,i)=>{const n=t.exec(e);return n?n[0]:i};r.default(s).argParser(n)}else{r.default(n)}return this.addOption(r)}option(t,e,i,n){return this._optionEx({},t,e,i,n)}requiredOption(t,e,i,n){return this._optionEx({mandatory:true},t,e,i,n)}combineFlagAndOptionalValue(t=true){this._combineFlagAndOptionalValue=!!t;return this}allowUnknownOption(t=true){this._allowUnknownOption=!!t;return this}allowExcessArguments(t=true){this._allowExcessArguments=!!t;return this}enablePositionalOptions(t=true){this._enablePositionalOptions=!!t;return this}passThroughOptions(t=true){this._passThroughOptions=!!t;this._checkForBrokenPassThrough();return 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(t=true){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")}this._storeOptionsAsProperties=!!t;return this}getOptionValue(t){if(this._storeOptionsAsProperties){return this[t]}return this._optionValues[t]}setOptionValue(t,e){return this.setOptionValueWithSource(t,e,undefined)}setOptionValueWithSource(t,e,i){if(this._storeOptionsAsProperties){this[t]=e}else{this._optionValues[t]=e}this._optionValueSources[t]=i;return this}getOptionValueSource(t){return this._optionValueSources[t]}getOptionValueSourceWithGlobals(t){let e;this._getCommandAndAncestors().forEach((i=>{if(i.getOptionValueSource(t)!==undefined){e=i.getOptionValueSource(t)}}));return e}_prepareUserArgs(t,e){if(t!==undefined&&!Array.isArray(t)){throw new Error("first parameter to parse must be array or undefined")}e=e||{};if(t===undefined){t=a.argv;if(a.versions&&a.versions.electron){e.from="electron"}}this.rawArgs=t.slice();let i;switch(e.from){case undefined:case"node":this._scriptPath=t[1];i=t.slice(2);break;case"electron":if(a.defaultApp){this._scriptPath=t[1];i=t.slice(2)}else{i=t.slice(1)}break;case"user":i=t.slice(0);break;default:throw new Error(`unexpected parse option { from: '${e.from}' }`)}if(!this._name&&this._scriptPath)this.nameFromFilename(this._scriptPath);this._name=this._name||"program";return i}parse(t,e){const i=this._prepareUserArgs(t,e);this._parseCommand([],i);return this}async parseAsync(t,e){const i=this._prepareUserArgs(t,e);await this._parseCommand([],i);return this}_executeSubCommand(t,e){e=e.slice();let i=false;const n=[".js",".ts",".tsx",".mjs",".cjs"];function findFile(t,e){const i=r.resolve(t,e);if(o.existsSync(i))return i;if(n.includes(r.extname(e)))return undefined;const s=n.find((t=>o.existsSync(`${i}${t}`)));if(s)return`${i}${s}`;return undefined}this._checkForMissingMandatoryOptions();this._checkForConflictingOptions();let h=t._executableFile||`${this._name}-${t._name}`;let l=this._executableDir||"";if(this._scriptPath){let t;try{t=o.realpathSync(this._scriptPath)}catch(e){t=this._scriptPath}l=r.resolve(r.dirname(t),l)}if(l){let e=findFile(l,h);if(!e&&!t._executableFile&&this._scriptPath){const i=r.basename(this._scriptPath,r.extname(this._scriptPath));if(i!==this._name){e=findFile(l,`${i}-${t._name}`)}}h=e||h}i=n.includes(r.extname(h));let c;if(a.platform!=="win32"){if(i){e.unshift(h);e=incrementNodeInspectorPort(a.execArgv).concat(e);c=s.spawn(a.argv[0],e,{stdio:"inherit"})}else{c=s.spawn(h,e,{stdio:"inherit"})}}else{e.unshift(h);e=incrementNodeInspectorPort(a.execArgv).concat(e);c=s.spawn(a.execPath,e,{stdio:"inherit"})}if(!c.killed){const t=["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"];t.forEach((t=>{a.on(t,(()=>{if(c.killed===false&&c.exitCode===null){c.kill(t)}}))}))}const p=this._exitCallback;c.on("close",((t,e)=>{t=t??1;if(!p){a.exit(t)}else{p(new u(t,"commander.executeSubCommandAsync","(close)"))}}));c.on("error",(e=>{if(e.code==="ENOENT"){const e=l?`searched for local subcommand relative to directory '${l}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory";const i=`'${h}' does not exist\n - if '${t._name}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead\n - if the default executable name is not suitable, use the executableFile option to supply a custom name or path\n - ${e}`;throw new Error(i)}else if(e.code==="EACCES"){throw new Error(`'${h}' not executable`)}if(!p){a.exit(1)}else{const t=new u(1,"commander.executeSubCommandAsync","(error)");t.nestedError=e;p(t)}}));this.runningCommand=c}_dispatchSubcommand(t,e,i){const n=this._findCommand(t);if(!n)this.help({error:true});let s;s=this._chainOrCallSubCommandHook(s,n,"preSubcommand");s=this._chainOrCall(s,(()=>{if(n._executableHandler){this._executeSubCommand(n,e.concat(i))}else{return n._parseCommand(e,i)}}));return s}_dispatchHelpCommand(t){if(!t){this.help()}const e=this._findCommand(t);if(e&&!e._executableHandler){e.help()}return this._dispatchSubcommand(t,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){this.registeredArguments.forEach(((t,e)=>{if(t.required&&this.args[e]==null){this.missingArgument(t.name())}}));if(this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic){return}if(this.args.length>this.registeredArguments.length){this._excessArguments(this.args)}}_processArguments(){const myParseArg=(t,e,i)=>{let n=e;if(e!==null&&t.parseArg){const s=`error: command-argument value '${e}' is invalid for argument '${t.name()}'.`;n=this._callParseArg(t,e,i,s)}return n};this._checkNumberOfArguments();const t=[];this.registeredArguments.forEach(((e,i)=>{let n=e.defaultValue;if(e.variadic){if(i<this.args.length){n=this.args.slice(i);if(e.parseArg){n=n.reduce(((t,i)=>myParseArg(e,i,t)),e.defaultValue)}}else if(n===undefined){n=[]}}else if(i<this.args.length){n=this.args[i];if(e.parseArg){n=myParseArg(e,n,e.defaultValue)}}t[i]=n}));this.processedArgs=t}_chainOrCall(t,e){if(t&&t.then&&typeof t.then==="function"){return t.then((()=>e()))}return e()}_chainOrCallHooks(t,e){let i=t;const n=[];this._getCommandAndAncestors().reverse().filter((t=>t._lifeCycleHooks[e]!==undefined)).forEach((t=>{t._lifeCycleHooks[e].forEach((e=>{n.push({hookedCommand:t,callback:e})}))}));if(e==="postAction"){n.reverse()}n.forEach((t=>{i=this._chainOrCall(i,(()=>t.callback(t.hookedCommand,this)))}));return i}_chainOrCallSubCommandHook(t,e,i){let n=t;if(this._lifeCycleHooks[i]!==undefined){this._lifeCycleHooks[i].forEach((t=>{n=this._chainOrCall(n,(()=>t(this,e)))}))}return n}_parseCommand(t,e){const i=this.parseOptions(e);this._parseOptionsEnv();this._parseOptionsImplied();t=t.concat(i.operands);e=i.unknown;this.args=t.concat(e);if(t&&this._findCommand(t[0])){return this._dispatchSubcommand(t[0],t.slice(1),e)}if(this._getHelpCommand()&&t[0]===this._getHelpCommand().name()){return this._dispatchHelpCommand(t[1])}if(this._defaultCommandName){this._outputHelpIfRequested(e);return this._dispatchSubcommand(this._defaultCommandName,t,e)}if(this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName){this.help({error:true})}this._outputHelpIfRequested(i.unknown);this._checkForMissingMandatoryOptions();this._checkForConflictingOptions();const checkForUnknownOptions=()=>{if(i.unknown.length>0){this.unknownOption(i.unknown[0])}};const n=`command:${this.name()}`;if(this._actionHandler){checkForUnknownOptions();this._processArguments();let i;i=this._chainOrCallHooks(i,"preAction");i=this._chainOrCall(i,(()=>this._actionHandler(this.processedArgs)));if(this.parent){i=this._chainOrCall(i,(()=>{this.parent.emit(n,t,e)}))}i=this._chainOrCallHooks(i,"postAction");return i}if(this.parent&&this.parent.listenerCount(n)){checkForUnknownOptions();this._processArguments();this.parent.emit(n,t,e)}else if(t.length){if(this._findCommand("*")){return this._dispatchSubcommand("*",t,e)}if(this.listenerCount("command:*")){this.emit("command:*",t,e)}else if(this.commands.length){this.unknownCommand()}else{checkForUnknownOptions();this._processArguments()}}else if(this.commands.length){checkForUnknownOptions();this.help({error:true})}else{checkForUnknownOptions();this._processArguments()}}_findCommand(t){if(!t)return undefined;return this.commands.find((e=>e._name===t||e._aliases.includes(t)))}_findOption(t){return this.options.find((e=>e.is(t)))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach((t=>{t.options.forEach((e=>{if(e.mandatory&&t.getOptionValue(e.attributeName())===undefined){t.missingMandatoryOptionValue(e)}}))}))}_checkForConflictingLocalOptions(){const t=this.options.filter((t=>{const e=t.attributeName();if(this.getOptionValue(e)===undefined){return false}return this.getOptionValueSource(e)!=="default"}));const e=t.filter((t=>t.conflictsWith.length>0));e.forEach((e=>{const i=t.find((t=>e.conflictsWith.includes(t.attributeName())));if(i){this._conflictingOption(e,i)}}))}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach((t=>{t._checkForConflictingLocalOptions()}))}parseOptions(t){const e=[];const i=[];let n=e;const s=t.slice();function maybeOption(t){return t.length>1&&t[0]==="-"}let r=null;while(s.length){const t=s.shift();if(t==="--"){if(n===i)n.push(t);n.push(...s);break}if(r&&!maybeOption(t)){this.emit(`option:${r.name()}`,t);continue}r=null;if(maybeOption(t)){const e=this._findOption(t);if(e){if(e.required){const t=s.shift();if(t===undefined)this.optionMissingArgument(e);this.emit(`option:${e.name()}`,t)}else if(e.optional){let t=null;if(s.length>0&&!maybeOption(s[0])){t=s.shift()}this.emit(`option:${e.name()}`,t)}else{this.emit(`option:${e.name()}`)}r=e.variadic?e:null;continue}}if(t.length>2&&t[0]==="-"&&t[1]!=="-"){const e=this._findOption(`-${t[1]}`);if(e){if(e.required||e.optional&&this._combineFlagAndOptionalValue){this.emit(`option:${e.name()}`,t.slice(2))}else{this.emit(`option:${e.name()}`);s.unshift(`-${t.slice(2)}`)}continue}}if(/^--[^=]+=/.test(t)){const e=t.indexOf("=");const i=this._findOption(t.slice(0,e));if(i&&(i.required||i.optional)){this.emit(`option:${i.name()}`,t.slice(e+1));continue}}if(maybeOption(t)){n=i}if((this._enablePositionalOptions||this._passThroughOptions)&&e.length===0&&i.length===0){if(this._findCommand(t)){e.push(t);if(s.length>0)i.push(...s);break}else if(this._getHelpCommand()&&t===this._getHelpCommand().name()){e.push(t);if(s.length>0)e.push(...s);break}else if(this._defaultCommandName){i.push(t);if(s.length>0)i.push(...s);break}}if(this._passThroughOptions){n.push(t);if(s.length>0)n.push(...s);break}n.push(t)}return{operands:e,unknown:i}}opts(){if(this._storeOptionsAsProperties){const t={};const e=this.options.length;for(let i=0;i<e;i++){const e=this.options[i].attributeName();t[e]=e===this._versionOptionName?this._version:this[e]}return t}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce(((t,e)=>Object.assign(t,e.opts())),{})}error(t,e){this._outputConfiguration.outputError(`${t}\n`,this._outputConfiguration.writeErr);if(typeof this._showHelpAfterError==="string"){this._outputConfiguration.writeErr(`${this._showHelpAfterError}\n`)}else if(this._showHelpAfterError){this._outputConfiguration.writeErr("\n");this.outputHelp({error:true})}const i=e||{};const n=i.exitCode||1;const s=i.code||"commander.error";this._exit(n,s,t)}_parseOptionsEnv(){this.options.forEach((t=>{if(t.envVar&&t.envVar in a.env){const e=t.attributeName();if(this.getOptionValue(e)===undefined||["default","config","env"].includes(this.getOptionValueSource(e))){if(t.required||t.optional){this.emit(`optionEnv:${t.name()}`,a.env[t.envVar])}else{this.emit(`optionEnv:${t.name()}`)}}}}))}_parseOptionsImplied(){const t=new d(this.options);const hasCustomOptionValue=t=>this.getOptionValue(t)!==undefined&&!["default","implied"].includes(this.getOptionValueSource(t));this.options.filter((e=>e.implied!==undefined&&hasCustomOptionValue(e.attributeName())&&t.valueFromOption(this.getOptionValue(e.attributeName()),e))).forEach((t=>{Object.keys(t.implied).filter((t=>!hasCustomOptionValue(t))).forEach((e=>{this.setOptionValueWithSource(e,t.implied[e],"implied")}))}))}missingArgument(t){const e=`error: missing required argument '${t}'`;this.error(e,{code:"commander.missingArgument"})}optionMissingArgument(t){const e=`error: option '${t.flags}' argument missing`;this.error(e,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(t){const e=`error: required option '${t.flags}' not specified`;this.error(e,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(t,e){const findBestOptionFromValue=t=>{const e=t.attributeName();const i=this.getOptionValue(e);const n=this.options.find((t=>t.negate&&e===t.attributeName()));const s=this.options.find((t=>!t.negate&&e===t.attributeName()));if(n&&(n.presetArg===undefined&&i===false||n.presetArg!==undefined&&i===n.presetArg)){return n}return s||t};const getErrorMessage=t=>{const e=findBestOptionFromValue(t);const i=e.attributeName();const n=this.getOptionValueSource(i);if(n==="env"){return`environment variable '${e.envVar}'`}return`option '${e.flags}'`};const i=`error: ${getErrorMessage(t)} cannot be used with ${getErrorMessage(e)}`;this.error(i,{code:"commander.conflictingOption"})}unknownOption(t){if(this._allowUnknownOption)return;let e="";if(t.startsWith("--")&&this._showSuggestionAfterError){let i=[];let n=this;do{const t=n.createHelp().visibleOptions(n).filter((t=>t.long)).map((t=>t.long));i=i.concat(t);n=n.parent}while(n&&!n._enablePositionalOptions);e=m(t,i)}const i=`error: unknown option '${t}'${e}`;this.error(i,{code:"commander.unknownOption"})}_excessArguments(t){if(this._allowExcessArguments)return;const e=this.registeredArguments.length;const i=e===1?"":"s";const n=this.parent?` for '${this.name()}'`:"";const s=`error: too many arguments${n}. Expected ${e} argument${i} but got ${t.length}.`;this.error(s,{code:"commander.excessArguments"})}unknownCommand(){const t=this.args[0];let e="";if(this._showSuggestionAfterError){const i=[];this.createHelp().visibleCommands(this).forEach((t=>{i.push(t.name());if(t.alias())i.push(t.alias())}));e=m(t,i)}const i=`error: unknown command '${t}'${e}`;this.error(i,{code:"commander.unknownCommand"})}version(t,e,i){if(t===undefined)return this._version;this._version=t;e=e||"-V, --version";i=i||"output the version number";const n=this.createOption(e,i);this._versionOptionName=n.attributeName();this._registerOption(n);this.on("option:"+n.name(),(()=>{this._outputConfiguration.writeOut(`${t}\n`);this._exit(0,"commander.version",t)}));return this}description(t,e){if(t===undefined&&e===undefined)return this._description;this._description=t;if(e){this._argsDescription=e}return this}summary(t){if(t===undefined)return this._summary;this._summary=t;return this}alias(t){if(t===undefined)return this._aliases[0];let e=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler){e=this.commands[this.commands.length-1]}if(t===e._name)throw new Error("Command alias can't be the same as its name");const i=this.parent?._findCommand(t);if(i){const e=[i.name()].concat(i.aliases()).join("|");throw new Error(`cannot add alias '${t}' to command '${this.name()}' as already have command '${e}'`)}e._aliases.push(t);return this}aliases(t){if(t===undefined)return this._aliases;t.forEach((t=>this.alias(t)));return this}usage(t){if(t===undefined){if(this._usage)return this._usage;const t=this.registeredArguments.map((t=>l(t)));return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?t:[]).join(" ")}this._usage=t;return this}name(t){if(t===undefined)return this._name;this._name=t;return this}nameFromFilename(t){this._name=r.basename(t,r.extname(t));return this}executableDir(t){if(t===undefined)return this._executableDir;this._executableDir=t;return this}helpInformation(t){const e=this.createHelp();if(e.helpWidth===undefined){e.helpWidth=t&&t.error?this._outputConfiguration.getErrHelpWidth():this._outputConfiguration.getOutHelpWidth()}return e.formatHelp(this,e)}_getHelpContext(t){t=t||{};const e={error:!!t.error};let i;if(e.error){i=t=>this._outputConfiguration.writeErr(t)}else{i=t=>this._outputConfiguration.writeOut(t)}e.write=t.write||i;e.command=this;return e}outputHelp(t){let e;if(typeof t==="function"){e=t;t=undefined}const i=this._getHelpContext(t);this._getCommandAndAncestors().reverse().forEach((t=>t.emit("beforeAllHelp",i)));this.emit("beforeHelp",i);let n=this.helpInformation(i);if(e){n=e(n);if(typeof n!=="string"&&!Buffer.isBuffer(n)){throw new Error("outputHelp callback must return a string or a Buffer")}}i.write(n);if(this._getHelpOption()?.long){this.emit(this._getHelpOption().long)}this.emit("afterHelp",i);this._getCommandAndAncestors().forEach((t=>t.emit("afterAllHelp",i)))}helpOption(t,e){if(typeof t==="boolean"){if(t){this._helpOption=this._helpOption??undefined}else{this._helpOption=null}return this}t=t??"-h, --help";e=e??"display help for command";this._helpOption=this.createOption(t,e);return this}_getHelpOption(){if(this._helpOption===undefined){this.helpOption(undefined,undefined)}return this._helpOption}addHelpOption(t){this._helpOption=t;return this}help(t){this.outputHelp(t);let e=a.exitCode||0;if(e===0&&t&&typeof t!=="function"&&t.error){e=1}this._exit(e,"commander.help","(outputHelp)")}addHelpText(t,e){const i=["beforeAll","before","after","afterAll"];if(!i.includes(t)){throw new Error(`Unexpected value for position to addHelpText.\nExpecting one of '${i.join("', '")}'`)}const n=`${t}Help`;this.on(n,(t=>{let i;if(typeof e==="function"){i=e({error:t.error,command:t.command})}else{i=e}if(i){t.write(`${i}\n`)}}));return this}_outputHelpIfRequested(t){const e=this._getHelpOption();const i=e&&t.find((t=>e.is(t)));if(i){this.outputHelp();this._exit(0,"commander.helpDisplayed","(outputHelp)")}}}function incrementNodeInspectorPort(t){return t.map((t=>{if(!t.startsWith("--inspect")){return t}let e;let i="127.0.0.1";let n="9229";let s;if((s=t.match(/^(--inspect(-brk)?)$/))!==null){e=s[1]}else if((s=t.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null){e=s[1];if(/^\d+$/.test(s[3])){n=s[3]}else{i=s[3]}}else if((s=t.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null){e=s[1];i=s[3];n=s[4]}if(e&&n!=="0"){return`${e}=${i}:${parseInt(n)+1}`}return t}))}e.Command=Command},24:function(t,e){class CommanderError extends Error{constructor(t,e,i){super(i);Error.captureStackTrace(this,this.constructor);this.name=this.constructor.name;this.code=e;this.exitCode=t;this.nestedError=undefined}}class InvalidArgumentError extends CommanderError{constructor(t){super(1,"commander.invalidArgument",t);Error.captureStackTrace(this,this.constructor);this.name=this.constructor.name}}e.CommanderError=CommanderError;e.InvalidArgumentError=InvalidArgumentError},505:function(t,e,i){const{humanReadableArgName:n}=i(400);class Help{constructor(){this.helpWidth=undefined;this.sortSubcommands=false;this.sortOptions=false;this.showGlobalOptions=false}visibleCommands(t){const e=t.commands.filter((t=>!t._hidden));const i=t._getHelpCommand();if(i&&!i._hidden){e.push(i)}if(this.sortSubcommands){e.sort(((t,e)=>t.name().localeCompare(e.name())))}return e}compareOptions(t,e){const getSortKey=t=>t.short?t.short.replace(/^-/,""):t.long.replace(/^--/,"");return getSortKey(t).localeCompare(getSortKey(e))}visibleOptions(t){const e=t.options.filter((t=>!t.hidden));const i=t._getHelpOption();if(i&&!i.hidden){const n=i.short&&t._findOption(i.short);const s=i.long&&t._findOption(i.long);if(!n&&!s){e.push(i)}else if(i.long&&!s){e.push(t.createOption(i.long,i.description))}else if(i.short&&!n){e.push(t.createOption(i.short,i.description))}}if(this.sortOptions){e.sort(this.compareOptions)}return e}visibleGlobalOptions(t){if(!this.showGlobalOptions)return[];const e=[];for(let i=t.parent;i;i=i.parent){const t=i.options.filter((t=>!t.hidden));e.push(...t)}if(this.sortOptions){e.sort(this.compareOptions)}return e}visibleArguments(t){if(t._argsDescription){t.registeredArguments.forEach((e=>{e.description=e.description||t._argsDescription[e.name()]||""}))}if(t.registeredArguments.find((t=>t.description))){return t.registeredArguments}return[]}subcommandTerm(t){const e=t.registeredArguments.map((t=>n(t))).join(" ");return t._name+(t._aliases[0]?"|"+t._aliases[0]:"")+(t.options.length?" [options]":"")+(e?" "+e:"")}optionTerm(t){return t.flags}argumentTerm(t){return t.name()}longestSubcommandTermLength(t,e){return e.visibleCommands(t).reduce(((t,i)=>Math.max(t,e.subcommandTerm(i).length)),0)}longestOptionTermLength(t,e){return e.visibleOptions(t).reduce(((t,i)=>Math.max(t,e.optionTerm(i).length)),0)}longestGlobalOptionTermLength(t,e){return e.visibleGlobalOptions(t).reduce(((t,i)=>Math.max(t,e.optionTerm(i).length)),0)}longestArgumentTermLength(t,e){return e.visibleArguments(t).reduce(((t,i)=>Math.max(t,e.argumentTerm(i).length)),0)}commandUsage(t){let e=t._name;if(t._aliases[0]){e=e+"|"+t._aliases[0]}let i="";for(let e=t.parent;e;e=e.parent){i=e.name()+" "+i}return i+e+" "+t.usage()}commandDescription(t){return t.description()}subcommandDescription(t){return t.summary()||t.description()}optionDescription(t){const e=[];if(t.argChoices){e.push(`choices: ${t.argChoices.map((t=>JSON.stringify(t))).join(", ")}`)}if(t.defaultValue!==undefined){const i=t.required||t.optional||t.isBoolean()&&typeof t.defaultValue==="boolean";if(i){e.push(`default: ${t.defaultValueDescription||JSON.stringify(t.defaultValue)}`)}}if(t.presetArg!==undefined&&t.optional){e.push(`preset: ${JSON.stringify(t.presetArg)}`)}if(t.envVar!==undefined){e.push(`env: ${t.envVar}`)}if(e.length>0){return`${t.description} (${e.join(", ")})`}return t.description}argumentDescription(t){const e=[];if(t.argChoices){e.push(`choices: ${t.argChoices.map((t=>JSON.stringify(t))).join(", ")}`)}if(t.defaultValue!==undefined){e.push(`default: ${t.defaultValueDescription||JSON.stringify(t.defaultValue)}`)}if(e.length>0){const i=`(${e.join(", ")})`;if(t.description){return`${t.description} ${i}`}return i}return t.description}formatHelp(t,e){const i=e.padWidth(t,e);const n=e.helpWidth||80;const s=2;const r=2;function formatItem(t,o){if(o){const a=`${t.padEnd(i+r)}${o}`;return e.wrap(a,n-s,i+r)}return t}function formatList(t){return t.join("\n").replace(/^/gm," ".repeat(s))}let o=[`Usage: ${e.commandUsage(t)}`,""];const a=e.commandDescription(t);if(a.length>0){o=o.concat([e.wrap(a,n,0),""])}const h=e.visibleArguments(t).map((t=>formatItem(e.argumentTerm(t),e.argumentDescription(t))));if(h.length>0){o=o.concat(["Arguments:",formatList(h),""])}const l=e.visibleOptions(t).map((t=>formatItem(e.optionTerm(t),e.optionDescription(t))));if(l.length>0){o=o.concat(["Options:",formatList(l),""])}if(this.showGlobalOptions){const i=e.visibleGlobalOptions(t).map((t=>formatItem(e.optionTerm(t),e.optionDescription(t))));if(i.length>0){o=o.concat(["Global Options:",formatList(i),""])}}const u=e.visibleCommands(t).map((t=>formatItem(e.subcommandTerm(t),e.subcommandDescription(t))));if(u.length>0){o=o.concat(["Commands:",formatList(u),""])}return o.join("\n")}padWidth(t,e){return Math.max(e.longestOptionTermLength(t,e),e.longestGlobalOptionTermLength(t,e),e.longestSubcommandTermLength(t,e),e.longestArgumentTermLength(t,e))}wrap(t,e,i,n=40){const s=" \\f\\t\\v - \ufeff";const r=new RegExp(`[\\n][${s}]+`);if(t.match(r))return t;const o=e-i;if(o<n)return t;const a=t.slice(0,i);const h=t.slice(i).replace("\r\n","\n");const l=" ".repeat(i);const u="";const c=`\\s${u}`;const p=new RegExp(`\n|.{1,${o-1}}([${c}]|$)|[^${c}]+?([${c}]|$)`,"g");const d=h.match(p)||[];return a+d.map(((t,e)=>{if(t==="\n")return"";return(e>0?l:"")+t.trimEnd()})).join("\n")}}e.Help=Help},663:function(t,e,i){const{InvalidArgumentError:n}=i(24);class Option{constructor(t,e){this.flags=t;this.description=e||"";this.required=t.includes("<");this.optional=t.includes("[");this.variadic=/\w\.\.\.[>\]]$/.test(t);this.mandatory=false;const i=splitOptionFlags(t);this.short=i.shortFlag;this.long=i.longFlag;this.negate=false;if(this.long){this.negate=this.long.startsWith("--no-")}this.defaultValue=undefined;this.defaultValueDescription=undefined;this.presetArg=undefined;this.envVar=undefined;this.parseArg=undefined;this.hidden=false;this.argChoices=undefined;this.conflictsWith=[];this.implied=undefined}default(t,e){this.defaultValue=t;this.defaultValueDescription=e;return this}preset(t){this.presetArg=t;return this}conflicts(t){this.conflictsWith=this.conflictsWith.concat(t);return this}implies(t){let e=t;if(typeof t==="string"){e={[t]:true}}this.implied=Object.assign(this.implied||{},e);return this}env(t){this.envVar=t;return this}argParser(t){this.parseArg=t;return this}makeOptionMandatory(t=true){this.mandatory=!!t;return this}hideHelp(t=true){this.hidden=!!t;return this}_concatValue(t,e){if(e===this.defaultValue||!Array.isArray(e)){return[t]}return e.concat(t)}choices(t){this.argChoices=t.slice();this.parseArg=(t,e)=>{if(!this.argChoices.includes(t)){throw new n(`Allowed choices are ${this.argChoices.join(", ")}.`)}if(this.variadic){return this._concatValue(t,e)}return t};return this}name(){if(this.long){return this.long.replace(/^--/,"")}return this.short.replace(/^-/,"")}attributeName(){return camelcase(this.name().replace(/^no-/,""))}is(t){return this.short===t||this.long===t}isBoolean(){return!this.required&&!this.optional&&!this.negate}}class DualOptions{constructor(t){this.positiveOptions=new Map;this.negativeOptions=new Map;this.dualOptions=new Set;t.forEach((t=>{if(t.negate){this.negativeOptions.set(t.attributeName(),t)}else{this.positiveOptions.set(t.attributeName(),t)}}));this.negativeOptions.forEach(((t,e)=>{if(this.positiveOptions.has(e)){this.dualOptions.add(e)}}))}valueFromOption(t,e){const i=e.attributeName();if(!this.dualOptions.has(i))return true;const n=this.negativeOptions.get(i).presetArg;const s=n!==undefined?n:false;return e.negate===(s===t)}}function camelcase(t){return t.split("-").reduce(((t,e)=>t+e[0].toUpperCase()+e.slice(1)))}function splitOptionFlags(t){let e;let i;const n=t.split(/[ |,]+/);if(n.length>1&&!/^[[<]/.test(n[1]))e=n.shift();i=n.shift();if(!e&&/^-[^-]$/.test(i)){e=i;i=undefined}return{shortFlag:e,longFlag:i}}e.Option=Option;e.DualOptions=DualOptions},861:function(t,e){const i=3;function editDistance(t,e){if(Math.abs(t.length-e.length)>i)return Math.max(t.length,e.length);const n=[];for(let e=0;e<=t.length;e++){n[e]=[e]}for(let t=0;t<=e.length;t++){n[0][t]=t}for(let i=1;i<=e.length;i++){for(let s=1;s<=t.length;s++){let r=1;if(t[s-1]===e[i-1]){r=0}else{r=1}n[s][i]=Math.min(n[s-1][i]+1,n[s][i-1]+1,n[s-1][i-1]+r);if(s>1&&i>1&&t[s-1]===e[i-2]&&t[s-2]===e[i-1]){n[s][i]=Math.min(n[s][i],n[s-2][i-2]+1)}}}return n[t.length][e.length]}function suggestSimilar(t,e){if(!e||e.length===0)return"";e=Array.from(new Set(e));const n=t.startsWith("--");if(n){t=t.slice(2);e=e.map((t=>t.slice(2)))}let s=[];let r=i;const o=.4;e.forEach((e=>{if(e.length<=1)return;const i=editDistance(t,e);const n=Math.max(t.length,e.length);const a=(n-i)/n;if(a>o){if(i<r){r=i;s=[e]}else if(i===r){s.push(e)}}}));s.sort(((t,e)=>t.localeCompare(e)));if(n){s=s.map((t=>`--${t}`))}if(s.length>1){return`\n(Did you mean one of ${s.join(", ")}?)`}if(s.length===1){return`\n(Did you mean ${s[0]}?)`}return""}e.suggestSimilar=suggestSimilar}};var e={};function __nccwpck_require__(i){var n=e[i];if(n!==undefined){return n.exports}var s=e[i]={exports:{}};var r=true;try{t[i](s,s.exports,__nccwpck_require__);r=false}finally{if(r)delete e[i]}return s.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var i={};!function(){var t=i;const{Argument:e}=__nccwpck_require__(400);const{Command:n}=__nccwpck_require__(220);const{CommanderError:s,InvalidArgumentError:r}=__nccwpck_require__(24);const{Help:o}=__nccwpck_require__(505);const{Option:a}=__nccwpck_require__(663);t.program=new n;t.createCommand=t=>new n(t);t.createOption=(t,e)=>new a(t,e);t.createArgument=(t,i)=>new e(t,i);t.Command=n;t.Option=a;t.Argument=e;t.Help=o;t.CommanderError=s;t.InvalidArgumentError=r;t.InvalidOptionArgumentError=r}();module.exports=i})();
|
|
1
|
+
(function(){var t={718:function(t){"use strict";t.exports=require("node:child_process")},673:function(t){"use strict";t.exports=require("node:events")},561:function(t){"use strict";t.exports=require("node:fs")},411:function(t){"use strict";t.exports=require("node:path")},742:function(t){"use strict";t.exports=require("node:process")},142:function(t,e,i){const{InvalidArgumentError:n}=i(841);class Argument{constructor(t,e){this.description=e||"";this.variadic=false;this.parseArg=undefined;this.defaultValue=undefined;this.defaultValueDescription=undefined;this.argChoices=undefined;switch(t[0]){case"<":this.required=true;this._name=t.slice(1,-1);break;case"[":this.required=false;this._name=t.slice(1,-1);break;default:this.required=true;this._name=t;break}if(this._name.length>3&&this._name.slice(-3)==="..."){this.variadic=true;this._name=this._name.slice(0,-3)}}name(){return this._name}_concatValue(t,e){if(e===this.defaultValue||!Array.isArray(e)){return[t]}return e.concat(t)}default(t,e){this.defaultValue=t;this.defaultValueDescription=e;return this}argParser(t){this.parseArg=t;return this}choices(t){this.argChoices=t.slice();this.parseArg=(t,e)=>{if(!this.argChoices.includes(t)){throw new n(`Allowed choices are ${this.argChoices.join(", ")}.`)}if(this.variadic){return this._concatValue(t,e)}return t};return this}argRequired(){this.required=true;return this}argOptional(){this.required=false;return this}}function humanReadableArgName(t){const e=t.name()+(t.variadic===true?"...":"");return t.required?"<"+e+">":"["+e+"]"}e.Argument=Argument;e.humanReadableArgName=humanReadableArgName},728:function(t,e,i){const n=i(673).EventEmitter;const s=i(718);const r=i(411);const o=i(561);const a=i(742);const{Argument:h,humanReadableArgName:l}=i(142);const{CommanderError:u}=i(841);const{Help:c}=i(202);const{Option:p,DualOptions:d}=i(257);const{suggestSimilar:m}=i(824);class Command extends n{constructor(t){super();this.commands=[];this.options=[];this.parent=null;this._allowUnknownOption=false;this._allowExcessArguments=true;this.registeredArguments=[];this._args=this.registeredArguments;this.args=[];this.rawArgs=[];this.processedArgs=[];this._scriptPath=null;this._name=t||"";this._optionValues={};this._optionValueSources={};this._storeOptionsAsProperties=false;this._actionHandler=null;this._executableHandler=false;this._executableFile=null;this._executableDir=null;this._defaultCommandName=null;this._exitCallback=null;this._aliases=[];this._combineFlagAndOptionalValue=true;this._description="";this._summary="";this._argsDescription=undefined;this._enablePositionalOptions=false;this._passThroughOptions=false;this._lifeCycleHooks={};this._showHelpAfterError=false;this._showSuggestionAfterError=true;this._outputConfiguration={writeOut:t=>a.stdout.write(t),writeErr:t=>a.stderr.write(t),getOutHelpWidth:()=>a.stdout.isTTY?a.stdout.columns:undefined,getErrHelpWidth:()=>a.stderr.isTTY?a.stderr.columns:undefined,outputError:(t,e)=>e(t)};this._hidden=false;this._helpOption=undefined;this._addImplicitHelpCommand=undefined;this._helpCommand=undefined;this._helpConfiguration={}}copyInheritedSettings(t){this._outputConfiguration=t._outputConfiguration;this._helpOption=t._helpOption;this._helpCommand=t._helpCommand;this._helpConfiguration=t._helpConfiguration;this._exitCallback=t._exitCallback;this._storeOptionsAsProperties=t._storeOptionsAsProperties;this._combineFlagAndOptionalValue=t._combineFlagAndOptionalValue;this._allowExcessArguments=t._allowExcessArguments;this._enablePositionalOptions=t._enablePositionalOptions;this._showHelpAfterError=t._showHelpAfterError;this._showSuggestionAfterError=t._showSuggestionAfterError;return this}_getCommandAndAncestors(){const t=[];for(let e=this;e;e=e.parent){t.push(e)}return t}command(t,e,i){let n=e;let s=i;if(typeof n==="object"&&n!==null){s=n;n=null}s=s||{};const[,r,o]=t.match(/([^ ]+) *(.*)/);const a=this.createCommand(r);if(n){a.description(n);a._executableHandler=true}if(s.isDefault)this._defaultCommandName=a._name;a._hidden=!!(s.noHelp||s.hidden);a._executableFile=s.executableFile||null;if(o)a.arguments(o);this._registerCommand(a);a.parent=this;a.copyInheritedSettings(this);if(n)return this;return a}createCommand(t){return new Command(t)}createHelp(){return Object.assign(new c,this.configureHelp())}configureHelp(t){if(t===undefined)return this._helpConfiguration;this._helpConfiguration=t;return this}configureOutput(t){if(t===undefined)return this._outputConfiguration;Object.assign(this._outputConfiguration,t);return this}showHelpAfterError(t=true){if(typeof t!=="string")t=!!t;this._showHelpAfterError=t;return this}showSuggestionAfterError(t=true){this._showSuggestionAfterError=!!t;return this}addCommand(t,e){if(!t._name){throw new Error(`Command passed to .addCommand() must have a name\n- specify the name in Command constructor or using .name()`)}e=e||{};if(e.isDefault)this._defaultCommandName=t._name;if(e.noHelp||e.hidden)t._hidden=true;this._registerCommand(t);t.parent=this;t._checkForBrokenPassThrough();return this}createArgument(t,e){return new h(t,e)}argument(t,e,i,n){const s=this.createArgument(t,e);if(typeof i==="function"){s.default(n).argParser(i)}else{s.default(i)}this.addArgument(s);return this}arguments(t){t.trim().split(/ +/).forEach((t=>{this.argument(t)}));return this}addArgument(t){const e=this.registeredArguments.slice(-1)[0];if(e&&e.variadic){throw new Error(`only the last argument can be variadic '${e.name()}'`)}if(t.required&&t.defaultValue!==undefined&&t.parseArg===undefined){throw new Error(`a default value for a required argument is never used: '${t.name()}'`)}this.registeredArguments.push(t);return this}helpCommand(t,e){if(typeof t==="boolean"){this._addImplicitHelpCommand=t;return this}t=t??"help [command]";const[,i,n]=t.match(/([^ ]+) *(.*)/);const s=e??"display help for command";const r=this.createCommand(i);r.helpOption(false);if(n)r.arguments(n);if(s)r.description(s);this._addImplicitHelpCommand=true;this._helpCommand=r;return this}addHelpCommand(t,e){if(typeof t!=="object"){this.helpCommand(t,e);return this}this._addImplicitHelpCommand=true;this._helpCommand=t;return this}_getHelpCommand(){const t=this._addImplicitHelpCommand??(this.commands.length&&!this._actionHandler&&!this._findCommand("help"));if(t){if(this._helpCommand===undefined){this.helpCommand(undefined,undefined)}return this._helpCommand}return null}hook(t,e){const i=["preSubcommand","preAction","postAction"];if(!i.includes(t)){throw new Error(`Unexpected value for event passed to hook : '${t}'.\nExpecting one of '${i.join("', '")}'`)}if(this._lifeCycleHooks[t]){this._lifeCycleHooks[t].push(e)}else{this._lifeCycleHooks[t]=[e]}return this}exitOverride(t){if(t){this._exitCallback=t}else{this._exitCallback=t=>{if(t.code!=="commander.executeSubCommandAsync"){throw t}else{}}}return this}_exit(t,e,i){if(this._exitCallback){this._exitCallback(new u(t,e,i))}a.exit(t)}action(t){const listener=e=>{const i=this.registeredArguments.length;const n=e.slice(0,i);if(this._storeOptionsAsProperties){n[i]=this}else{n[i]=this.opts()}n.push(this);return t.apply(this,n)};this._actionHandler=listener;return this}createOption(t,e){return new p(t,e)}_callParseArg(t,e,i,n){try{return t.parseArg(e,i)}catch(t){if(t.code==="commander.invalidArgument"){const e=`${n} ${t.message}`;this.error(e,{exitCode:t.exitCode,code:t.code})}throw t}}_registerOption(t){const e=t.short&&this._findOption(t.short)||t.long&&this._findOption(t.long);if(e){const i=t.long&&this._findOption(t.long)?t.long:t.short;throw new Error(`Cannot add option '${t.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${i}'\n- already used by option '${e.flags}'`)}this.options.push(t)}_registerCommand(t){const knownBy=t=>[t.name()].concat(t.aliases());const e=knownBy(t).find((t=>this._findCommand(t)));if(e){const i=knownBy(this._findCommand(e)).join("|");const n=knownBy(t).join("|");throw new Error(`cannot add command '${n}' as already have command '${i}'`)}this.commands.push(t)}addOption(t){this._registerOption(t);const e=t.name();const i=t.attributeName();if(t.negate){const e=t.long.replace(/^--no-/,"--");if(!this._findOption(e)){this.setOptionValueWithSource(i,t.defaultValue===undefined?true:t.defaultValue,"default")}}else if(t.defaultValue!==undefined){this.setOptionValueWithSource(i,t.defaultValue,"default")}const handleOptionValue=(e,n,s)=>{if(e==null&&t.presetArg!==undefined){e=t.presetArg}const r=this.getOptionValue(i);if(e!==null&&t.parseArg){e=this._callParseArg(t,e,r,n)}else if(e!==null&&t.variadic){e=t._concatValue(e,r)}if(e==null){if(t.negate){e=false}else if(t.isBoolean()||t.optional){e=true}else{e=""}}this.setOptionValueWithSource(i,e,s)};this.on("option:"+e,(e=>{const i=`error: option '${t.flags}' argument '${e}' is invalid.`;handleOptionValue(e,i,"cli")}));if(t.envVar){this.on("optionEnv:"+e,(e=>{const i=`error: option '${t.flags}' value '${e}' from env '${t.envVar}' is invalid.`;handleOptionValue(e,i,"env")}))}return this}_optionEx(t,e,i,n,s){if(typeof e==="object"&&e instanceof p){throw new Error("To add an Option object use addOption() instead of option() or requiredOption()")}const r=this.createOption(e,i);r.makeOptionMandatory(!!t.mandatory);if(typeof n==="function"){r.default(s).argParser(n)}else if(n instanceof RegExp){const t=n;n=(e,i)=>{const n=t.exec(e);return n?n[0]:i};r.default(s).argParser(n)}else{r.default(n)}return this.addOption(r)}option(t,e,i,n){return this._optionEx({},t,e,i,n)}requiredOption(t,e,i,n){return this._optionEx({mandatory:true},t,e,i,n)}combineFlagAndOptionalValue(t=true){this._combineFlagAndOptionalValue=!!t;return this}allowUnknownOption(t=true){this._allowUnknownOption=!!t;return this}allowExcessArguments(t=true){this._allowExcessArguments=!!t;return this}enablePositionalOptions(t=true){this._enablePositionalOptions=!!t;return this}passThroughOptions(t=true){this._passThroughOptions=!!t;this._checkForBrokenPassThrough();return 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(t=true){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")}this._storeOptionsAsProperties=!!t;return this}getOptionValue(t){if(this._storeOptionsAsProperties){return this[t]}return this._optionValues[t]}setOptionValue(t,e){return this.setOptionValueWithSource(t,e,undefined)}setOptionValueWithSource(t,e,i){if(this._storeOptionsAsProperties){this[t]=e}else{this._optionValues[t]=e}this._optionValueSources[t]=i;return this}getOptionValueSource(t){return this._optionValueSources[t]}getOptionValueSourceWithGlobals(t){let e;this._getCommandAndAncestors().forEach((i=>{if(i.getOptionValueSource(t)!==undefined){e=i.getOptionValueSource(t)}}));return e}_prepareUserArgs(t,e){if(t!==undefined&&!Array.isArray(t)){throw new Error("first parameter to parse must be array or undefined")}e=e||{};if(t===undefined&&e.from===undefined){if(a.versions?.electron){e.from="electron"}const t=a.execArgv??[];if(t.includes("-e")||t.includes("--eval")||t.includes("-p")||t.includes("--print")){e.from="eval"}}if(t===undefined){t=a.argv}this.rawArgs=t.slice();let i;switch(e.from){case undefined:case"node":this._scriptPath=t[1];i=t.slice(2);break;case"electron":if(a.defaultApp){this._scriptPath=t[1];i=t.slice(2)}else{i=t.slice(1)}break;case"user":i=t.slice(0);break;case"eval":i=t.slice(1);break;default:throw new Error(`unexpected parse option { from: '${e.from}' }`)}if(!this._name&&this._scriptPath)this.nameFromFilename(this._scriptPath);this._name=this._name||"program";return i}parse(t,e){const i=this._prepareUserArgs(t,e);this._parseCommand([],i);return this}async parseAsync(t,e){const i=this._prepareUserArgs(t,e);await this._parseCommand([],i);return this}_executeSubCommand(t,e){e=e.slice();let i=false;const n=[".js",".ts",".tsx",".mjs",".cjs"];function findFile(t,e){const i=r.resolve(t,e);if(o.existsSync(i))return i;if(n.includes(r.extname(e)))return undefined;const s=n.find((t=>o.existsSync(`${i}${t}`)));if(s)return`${i}${s}`;return undefined}this._checkForMissingMandatoryOptions();this._checkForConflictingOptions();let h=t._executableFile||`${this._name}-${t._name}`;let l=this._executableDir||"";if(this._scriptPath){let t;try{t=o.realpathSync(this._scriptPath)}catch(e){t=this._scriptPath}l=r.resolve(r.dirname(t),l)}if(l){let e=findFile(l,h);if(!e&&!t._executableFile&&this._scriptPath){const i=r.basename(this._scriptPath,r.extname(this._scriptPath));if(i!==this._name){e=findFile(l,`${i}-${t._name}`)}}h=e||h}i=n.includes(r.extname(h));let c;if(a.platform!=="win32"){if(i){e.unshift(h);e=incrementNodeInspectorPort(a.execArgv).concat(e);c=s.spawn(a.argv[0],e,{stdio:"inherit"})}else{c=s.spawn(h,e,{stdio:"inherit"})}}else{e.unshift(h);e=incrementNodeInspectorPort(a.execArgv).concat(e);c=s.spawn(a.execPath,e,{stdio:"inherit"})}if(!c.killed){const t=["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"];t.forEach((t=>{a.on(t,(()=>{if(c.killed===false&&c.exitCode===null){c.kill(t)}}))}))}const p=this._exitCallback;c.on("close",(t=>{t=t??1;if(!p){a.exit(t)}else{p(new u(t,"commander.executeSubCommandAsync","(close)"))}}));c.on("error",(e=>{if(e.code==="ENOENT"){const e=l?`searched for local subcommand relative to directory '${l}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory";const i=`'${h}' does not exist\n - if '${t._name}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead\n - if the default executable name is not suitable, use the executableFile option to supply a custom name or path\n - ${e}`;throw new Error(i)}else if(e.code==="EACCES"){throw new Error(`'${h}' not executable`)}if(!p){a.exit(1)}else{const t=new u(1,"commander.executeSubCommandAsync","(error)");t.nestedError=e;p(t)}}));this.runningCommand=c}_dispatchSubcommand(t,e,i){const n=this._findCommand(t);if(!n)this.help({error:true});let s;s=this._chainOrCallSubCommandHook(s,n,"preSubcommand");s=this._chainOrCall(s,(()=>{if(n._executableHandler){this._executeSubCommand(n,e.concat(i))}else{return n._parseCommand(e,i)}}));return s}_dispatchHelpCommand(t){if(!t){this.help()}const e=this._findCommand(t);if(e&&!e._executableHandler){e.help()}return this._dispatchSubcommand(t,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){this.registeredArguments.forEach(((t,e)=>{if(t.required&&this.args[e]==null){this.missingArgument(t.name())}}));if(this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic){return}if(this.args.length>this.registeredArguments.length){this._excessArguments(this.args)}}_processArguments(){const myParseArg=(t,e,i)=>{let n=e;if(e!==null&&t.parseArg){const s=`error: command-argument value '${e}' is invalid for argument '${t.name()}'.`;n=this._callParseArg(t,e,i,s)}return n};this._checkNumberOfArguments();const t=[];this.registeredArguments.forEach(((e,i)=>{let n=e.defaultValue;if(e.variadic){if(i<this.args.length){n=this.args.slice(i);if(e.parseArg){n=n.reduce(((t,i)=>myParseArg(e,i,t)),e.defaultValue)}}else if(n===undefined){n=[]}}else if(i<this.args.length){n=this.args[i];if(e.parseArg){n=myParseArg(e,n,e.defaultValue)}}t[i]=n}));this.processedArgs=t}_chainOrCall(t,e){if(t&&t.then&&typeof t.then==="function"){return t.then((()=>e()))}return e()}_chainOrCallHooks(t,e){let i=t;const n=[];this._getCommandAndAncestors().reverse().filter((t=>t._lifeCycleHooks[e]!==undefined)).forEach((t=>{t._lifeCycleHooks[e].forEach((e=>{n.push({hookedCommand:t,callback:e})}))}));if(e==="postAction"){n.reverse()}n.forEach((t=>{i=this._chainOrCall(i,(()=>t.callback(t.hookedCommand,this)))}));return i}_chainOrCallSubCommandHook(t,e,i){let n=t;if(this._lifeCycleHooks[i]!==undefined){this._lifeCycleHooks[i].forEach((t=>{n=this._chainOrCall(n,(()=>t(this,e)))}))}return n}_parseCommand(t,e){const i=this.parseOptions(e);this._parseOptionsEnv();this._parseOptionsImplied();t=t.concat(i.operands);e=i.unknown;this.args=t.concat(e);if(t&&this._findCommand(t[0])){return this._dispatchSubcommand(t[0],t.slice(1),e)}if(this._getHelpCommand()&&t[0]===this._getHelpCommand().name()){return this._dispatchHelpCommand(t[1])}if(this._defaultCommandName){this._outputHelpIfRequested(e);return this._dispatchSubcommand(this._defaultCommandName,t,e)}if(this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName){this.help({error:true})}this._outputHelpIfRequested(i.unknown);this._checkForMissingMandatoryOptions();this._checkForConflictingOptions();const checkForUnknownOptions=()=>{if(i.unknown.length>0){this.unknownOption(i.unknown[0])}};const n=`command:${this.name()}`;if(this._actionHandler){checkForUnknownOptions();this._processArguments();let i;i=this._chainOrCallHooks(i,"preAction");i=this._chainOrCall(i,(()=>this._actionHandler(this.processedArgs)));if(this.parent){i=this._chainOrCall(i,(()=>{this.parent.emit(n,t,e)}))}i=this._chainOrCallHooks(i,"postAction");return i}if(this.parent&&this.parent.listenerCount(n)){checkForUnknownOptions();this._processArguments();this.parent.emit(n,t,e)}else if(t.length){if(this._findCommand("*")){return this._dispatchSubcommand("*",t,e)}if(this.listenerCount("command:*")){this.emit("command:*",t,e)}else if(this.commands.length){this.unknownCommand()}else{checkForUnknownOptions();this._processArguments()}}else if(this.commands.length){checkForUnknownOptions();this.help({error:true})}else{checkForUnknownOptions();this._processArguments()}}_findCommand(t){if(!t)return undefined;return this.commands.find((e=>e._name===t||e._aliases.includes(t)))}_findOption(t){return this.options.find((e=>e.is(t)))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach((t=>{t.options.forEach((e=>{if(e.mandatory&&t.getOptionValue(e.attributeName())===undefined){t.missingMandatoryOptionValue(e)}}))}))}_checkForConflictingLocalOptions(){const t=this.options.filter((t=>{const e=t.attributeName();if(this.getOptionValue(e)===undefined){return false}return this.getOptionValueSource(e)!=="default"}));const e=t.filter((t=>t.conflictsWith.length>0));e.forEach((e=>{const i=t.find((t=>e.conflictsWith.includes(t.attributeName())));if(i){this._conflictingOption(e,i)}}))}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach((t=>{t._checkForConflictingLocalOptions()}))}parseOptions(t){const e=[];const i=[];let n=e;const s=t.slice();function maybeOption(t){return t.length>1&&t[0]==="-"}let r=null;while(s.length){const t=s.shift();if(t==="--"){if(n===i)n.push(t);n.push(...s);break}if(r&&!maybeOption(t)){this.emit(`option:${r.name()}`,t);continue}r=null;if(maybeOption(t)){const e=this._findOption(t);if(e){if(e.required){const t=s.shift();if(t===undefined)this.optionMissingArgument(e);this.emit(`option:${e.name()}`,t)}else if(e.optional){let t=null;if(s.length>0&&!maybeOption(s[0])){t=s.shift()}this.emit(`option:${e.name()}`,t)}else{this.emit(`option:${e.name()}`)}r=e.variadic?e:null;continue}}if(t.length>2&&t[0]==="-"&&t[1]!=="-"){const e=this._findOption(`-${t[1]}`);if(e){if(e.required||e.optional&&this._combineFlagAndOptionalValue){this.emit(`option:${e.name()}`,t.slice(2))}else{this.emit(`option:${e.name()}`);s.unshift(`-${t.slice(2)}`)}continue}}if(/^--[^=]+=/.test(t)){const e=t.indexOf("=");const i=this._findOption(t.slice(0,e));if(i&&(i.required||i.optional)){this.emit(`option:${i.name()}`,t.slice(e+1));continue}}if(maybeOption(t)){n=i}if((this._enablePositionalOptions||this._passThroughOptions)&&e.length===0&&i.length===0){if(this._findCommand(t)){e.push(t);if(s.length>0)i.push(...s);break}else if(this._getHelpCommand()&&t===this._getHelpCommand().name()){e.push(t);if(s.length>0)e.push(...s);break}else if(this._defaultCommandName){i.push(t);if(s.length>0)i.push(...s);break}}if(this._passThroughOptions){n.push(t);if(s.length>0)n.push(...s);break}n.push(t)}return{operands:e,unknown:i}}opts(){if(this._storeOptionsAsProperties){const t={};const e=this.options.length;for(let i=0;i<e;i++){const e=this.options[i].attributeName();t[e]=e===this._versionOptionName?this._version:this[e]}return t}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce(((t,e)=>Object.assign(t,e.opts())),{})}error(t,e){this._outputConfiguration.outputError(`${t}\n`,this._outputConfiguration.writeErr);if(typeof this._showHelpAfterError==="string"){this._outputConfiguration.writeErr(`${this._showHelpAfterError}\n`)}else if(this._showHelpAfterError){this._outputConfiguration.writeErr("\n");this.outputHelp({error:true})}const i=e||{};const n=i.exitCode||1;const s=i.code||"commander.error";this._exit(n,s,t)}_parseOptionsEnv(){this.options.forEach((t=>{if(t.envVar&&t.envVar in a.env){const e=t.attributeName();if(this.getOptionValue(e)===undefined||["default","config","env"].includes(this.getOptionValueSource(e))){if(t.required||t.optional){this.emit(`optionEnv:${t.name()}`,a.env[t.envVar])}else{this.emit(`optionEnv:${t.name()}`)}}}}))}_parseOptionsImplied(){const t=new d(this.options);const hasCustomOptionValue=t=>this.getOptionValue(t)!==undefined&&!["default","implied"].includes(this.getOptionValueSource(t));this.options.filter((e=>e.implied!==undefined&&hasCustomOptionValue(e.attributeName())&&t.valueFromOption(this.getOptionValue(e.attributeName()),e))).forEach((t=>{Object.keys(t.implied).filter((t=>!hasCustomOptionValue(t))).forEach((e=>{this.setOptionValueWithSource(e,t.implied[e],"implied")}))}))}missingArgument(t){const e=`error: missing required argument '${t}'`;this.error(e,{code:"commander.missingArgument"})}optionMissingArgument(t){const e=`error: option '${t.flags}' argument missing`;this.error(e,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(t){const e=`error: required option '${t.flags}' not specified`;this.error(e,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(t,e){const findBestOptionFromValue=t=>{const e=t.attributeName();const i=this.getOptionValue(e);const n=this.options.find((t=>t.negate&&e===t.attributeName()));const s=this.options.find((t=>!t.negate&&e===t.attributeName()));if(n&&(n.presetArg===undefined&&i===false||n.presetArg!==undefined&&i===n.presetArg)){return n}return s||t};const getErrorMessage=t=>{const e=findBestOptionFromValue(t);const i=e.attributeName();const n=this.getOptionValueSource(i);if(n==="env"){return`environment variable '${e.envVar}'`}return`option '${e.flags}'`};const i=`error: ${getErrorMessage(t)} cannot be used with ${getErrorMessage(e)}`;this.error(i,{code:"commander.conflictingOption"})}unknownOption(t){if(this._allowUnknownOption)return;let e="";if(t.startsWith("--")&&this._showSuggestionAfterError){let i=[];let n=this;do{const t=n.createHelp().visibleOptions(n).filter((t=>t.long)).map((t=>t.long));i=i.concat(t);n=n.parent}while(n&&!n._enablePositionalOptions);e=m(t,i)}const i=`error: unknown option '${t}'${e}`;this.error(i,{code:"commander.unknownOption"})}_excessArguments(t){if(this._allowExcessArguments)return;const e=this.registeredArguments.length;const i=e===1?"":"s";const n=this.parent?` for '${this.name()}'`:"";const s=`error: too many arguments${n}. Expected ${e} argument${i} but got ${t.length}.`;this.error(s,{code:"commander.excessArguments"})}unknownCommand(){const t=this.args[0];let e="";if(this._showSuggestionAfterError){const i=[];this.createHelp().visibleCommands(this).forEach((t=>{i.push(t.name());if(t.alias())i.push(t.alias())}));e=m(t,i)}const i=`error: unknown command '${t}'${e}`;this.error(i,{code:"commander.unknownCommand"})}version(t,e,i){if(t===undefined)return this._version;this._version=t;e=e||"-V, --version";i=i||"output the version number";const n=this.createOption(e,i);this._versionOptionName=n.attributeName();this._registerOption(n);this.on("option:"+n.name(),(()=>{this._outputConfiguration.writeOut(`${t}\n`);this._exit(0,"commander.version",t)}));return this}description(t,e){if(t===undefined&&e===undefined)return this._description;this._description=t;if(e){this._argsDescription=e}return this}summary(t){if(t===undefined)return this._summary;this._summary=t;return this}alias(t){if(t===undefined)return this._aliases[0];let e=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler){e=this.commands[this.commands.length-1]}if(t===e._name)throw new Error("Command alias can't be the same as its name");const i=this.parent?._findCommand(t);if(i){const e=[i.name()].concat(i.aliases()).join("|");throw new Error(`cannot add alias '${t}' to command '${this.name()}' as already have command '${e}'`)}e._aliases.push(t);return this}aliases(t){if(t===undefined)return this._aliases;t.forEach((t=>this.alias(t)));return this}usage(t){if(t===undefined){if(this._usage)return this._usage;const t=this.registeredArguments.map((t=>l(t)));return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?t:[]).join(" ")}this._usage=t;return this}name(t){if(t===undefined)return this._name;this._name=t;return this}nameFromFilename(t){this._name=r.basename(t,r.extname(t));return this}executableDir(t){if(t===undefined)return this._executableDir;this._executableDir=t;return this}helpInformation(t){const e=this.createHelp();if(e.helpWidth===undefined){e.helpWidth=t&&t.error?this._outputConfiguration.getErrHelpWidth():this._outputConfiguration.getOutHelpWidth()}return e.formatHelp(this,e)}_getHelpContext(t){t=t||{};const e={error:!!t.error};let i;if(e.error){i=t=>this._outputConfiguration.writeErr(t)}else{i=t=>this._outputConfiguration.writeOut(t)}e.write=t.write||i;e.command=this;return e}outputHelp(t){let e;if(typeof t==="function"){e=t;t=undefined}const i=this._getHelpContext(t);this._getCommandAndAncestors().reverse().forEach((t=>t.emit("beforeAllHelp",i)));this.emit("beforeHelp",i);let n=this.helpInformation(i);if(e){n=e(n);if(typeof n!=="string"&&!Buffer.isBuffer(n)){throw new Error("outputHelp callback must return a string or a Buffer")}}i.write(n);if(this._getHelpOption()?.long){this.emit(this._getHelpOption().long)}this.emit("afterHelp",i);this._getCommandAndAncestors().forEach((t=>t.emit("afterAllHelp",i)))}helpOption(t,e){if(typeof t==="boolean"){if(t){this._helpOption=this._helpOption??undefined}else{this._helpOption=null}return this}t=t??"-h, --help";e=e??"display help for command";this._helpOption=this.createOption(t,e);return this}_getHelpOption(){if(this._helpOption===undefined){this.helpOption(undefined,undefined)}return this._helpOption}addHelpOption(t){this._helpOption=t;return this}help(t){this.outputHelp(t);let e=a.exitCode||0;if(e===0&&t&&typeof t!=="function"&&t.error){e=1}this._exit(e,"commander.help","(outputHelp)")}addHelpText(t,e){const i=["beforeAll","before","after","afterAll"];if(!i.includes(t)){throw new Error(`Unexpected value for position to addHelpText.\nExpecting one of '${i.join("', '")}'`)}const n=`${t}Help`;this.on(n,(t=>{let i;if(typeof e==="function"){i=e({error:t.error,command:t.command})}else{i=e}if(i){t.write(`${i}\n`)}}));return this}_outputHelpIfRequested(t){const e=this._getHelpOption();const i=e&&t.find((t=>e.is(t)));if(i){this.outputHelp();this._exit(0,"commander.helpDisplayed","(outputHelp)")}}}function incrementNodeInspectorPort(t){return t.map((t=>{if(!t.startsWith("--inspect")){return t}let e;let i="127.0.0.1";let n="9229";let s;if((s=t.match(/^(--inspect(-brk)?)$/))!==null){e=s[1]}else if((s=t.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null){e=s[1];if(/^\d+$/.test(s[3])){n=s[3]}else{i=s[3]}}else if((s=t.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null){e=s[1];i=s[3];n=s[4]}if(e&&n!=="0"){return`${e}=${i}:${parseInt(n)+1}`}return t}))}e.Command=Command},841:function(t,e){class CommanderError extends Error{constructor(t,e,i){super(i);Error.captureStackTrace(this,this.constructor);this.name=this.constructor.name;this.code=e;this.exitCode=t;this.nestedError=undefined}}class InvalidArgumentError extends CommanderError{constructor(t){super(1,"commander.invalidArgument",t);Error.captureStackTrace(this,this.constructor);this.name=this.constructor.name}}e.CommanderError=CommanderError;e.InvalidArgumentError=InvalidArgumentError},202:function(t,e,i){const{humanReadableArgName:n}=i(142);class Help{constructor(){this.helpWidth=undefined;this.sortSubcommands=false;this.sortOptions=false;this.showGlobalOptions=false}visibleCommands(t){const e=t.commands.filter((t=>!t._hidden));const i=t._getHelpCommand();if(i&&!i._hidden){e.push(i)}if(this.sortSubcommands){e.sort(((t,e)=>t.name().localeCompare(e.name())))}return e}compareOptions(t,e){const getSortKey=t=>t.short?t.short.replace(/^-/,""):t.long.replace(/^--/,"");return getSortKey(t).localeCompare(getSortKey(e))}visibleOptions(t){const e=t.options.filter((t=>!t.hidden));const i=t._getHelpOption();if(i&&!i.hidden){const n=i.short&&t._findOption(i.short);const s=i.long&&t._findOption(i.long);if(!n&&!s){e.push(i)}else if(i.long&&!s){e.push(t.createOption(i.long,i.description))}else if(i.short&&!n){e.push(t.createOption(i.short,i.description))}}if(this.sortOptions){e.sort(this.compareOptions)}return e}visibleGlobalOptions(t){if(!this.showGlobalOptions)return[];const e=[];for(let i=t.parent;i;i=i.parent){const t=i.options.filter((t=>!t.hidden));e.push(...t)}if(this.sortOptions){e.sort(this.compareOptions)}return e}visibleArguments(t){if(t._argsDescription){t.registeredArguments.forEach((e=>{e.description=e.description||t._argsDescription[e.name()]||""}))}if(t.registeredArguments.find((t=>t.description))){return t.registeredArguments}return[]}subcommandTerm(t){const e=t.registeredArguments.map((t=>n(t))).join(" ");return t._name+(t._aliases[0]?"|"+t._aliases[0]:"")+(t.options.length?" [options]":"")+(e?" "+e:"")}optionTerm(t){return t.flags}argumentTerm(t){return t.name()}longestSubcommandTermLength(t,e){return e.visibleCommands(t).reduce(((t,i)=>Math.max(t,e.subcommandTerm(i).length)),0)}longestOptionTermLength(t,e){return e.visibleOptions(t).reduce(((t,i)=>Math.max(t,e.optionTerm(i).length)),0)}longestGlobalOptionTermLength(t,e){return e.visibleGlobalOptions(t).reduce(((t,i)=>Math.max(t,e.optionTerm(i).length)),0)}longestArgumentTermLength(t,e){return e.visibleArguments(t).reduce(((t,i)=>Math.max(t,e.argumentTerm(i).length)),0)}commandUsage(t){let e=t._name;if(t._aliases[0]){e=e+"|"+t._aliases[0]}let i="";for(let e=t.parent;e;e=e.parent){i=e.name()+" "+i}return i+e+" "+t.usage()}commandDescription(t){return t.description()}subcommandDescription(t){return t.summary()||t.description()}optionDescription(t){const e=[];if(t.argChoices){e.push(`choices: ${t.argChoices.map((t=>JSON.stringify(t))).join(", ")}`)}if(t.defaultValue!==undefined){const i=t.required||t.optional||t.isBoolean()&&typeof t.defaultValue==="boolean";if(i){e.push(`default: ${t.defaultValueDescription||JSON.stringify(t.defaultValue)}`)}}if(t.presetArg!==undefined&&t.optional){e.push(`preset: ${JSON.stringify(t.presetArg)}`)}if(t.envVar!==undefined){e.push(`env: ${t.envVar}`)}if(e.length>0){return`${t.description} (${e.join(", ")})`}return t.description}argumentDescription(t){const e=[];if(t.argChoices){e.push(`choices: ${t.argChoices.map((t=>JSON.stringify(t))).join(", ")}`)}if(t.defaultValue!==undefined){e.push(`default: ${t.defaultValueDescription||JSON.stringify(t.defaultValue)}`)}if(e.length>0){const i=`(${e.join(", ")})`;if(t.description){return`${t.description} ${i}`}return i}return t.description}formatHelp(t,e){const i=e.padWidth(t,e);const n=e.helpWidth||80;const s=2;const r=2;function formatItem(t,o){if(o){const a=`${t.padEnd(i+r)}${o}`;return e.wrap(a,n-s,i+r)}return t}function formatList(t){return t.join("\n").replace(/^/gm," ".repeat(s))}let o=[`Usage: ${e.commandUsage(t)}`,""];const a=e.commandDescription(t);if(a.length>0){o=o.concat([e.wrap(a,n,0),""])}const h=e.visibleArguments(t).map((t=>formatItem(e.argumentTerm(t),e.argumentDescription(t))));if(h.length>0){o=o.concat(["Arguments:",formatList(h),""])}const l=e.visibleOptions(t).map((t=>formatItem(e.optionTerm(t),e.optionDescription(t))));if(l.length>0){o=o.concat(["Options:",formatList(l),""])}if(this.showGlobalOptions){const i=e.visibleGlobalOptions(t).map((t=>formatItem(e.optionTerm(t),e.optionDescription(t))));if(i.length>0){o=o.concat(["Global Options:",formatList(i),""])}}const u=e.visibleCommands(t).map((t=>formatItem(e.subcommandTerm(t),e.subcommandDescription(t))));if(u.length>0){o=o.concat(["Commands:",formatList(u),""])}return o.join("\n")}padWidth(t,e){return Math.max(e.longestOptionTermLength(t,e),e.longestGlobalOptionTermLength(t,e),e.longestSubcommandTermLength(t,e),e.longestArgumentTermLength(t,e))}wrap(t,e,i,n=40){const s=" \\f\\t\\v - \ufeff";const r=new RegExp(`[\\n][${s}]+`);if(t.match(r))return t;const o=e-i;if(o<n)return t;const a=t.slice(0,i);const h=t.slice(i).replace("\r\n","\n");const l=" ".repeat(i);const u="";const c=`\\s${u}`;const p=new RegExp(`\n|.{1,${o-1}}([${c}]|$)|[^${c}]+?([${c}]|$)`,"g");const d=h.match(p)||[];return a+d.map(((t,e)=>{if(t==="\n")return"";return(e>0?l:"")+t.trimEnd()})).join("\n")}}e.Help=Help},257:function(t,e,i){const{InvalidArgumentError:n}=i(841);class Option{constructor(t,e){this.flags=t;this.description=e||"";this.required=t.includes("<");this.optional=t.includes("[");this.variadic=/\w\.\.\.[>\]]$/.test(t);this.mandatory=false;const i=splitOptionFlags(t);this.short=i.shortFlag;this.long=i.longFlag;this.negate=false;if(this.long){this.negate=this.long.startsWith("--no-")}this.defaultValue=undefined;this.defaultValueDescription=undefined;this.presetArg=undefined;this.envVar=undefined;this.parseArg=undefined;this.hidden=false;this.argChoices=undefined;this.conflictsWith=[];this.implied=undefined}default(t,e){this.defaultValue=t;this.defaultValueDescription=e;return this}preset(t){this.presetArg=t;return this}conflicts(t){this.conflictsWith=this.conflictsWith.concat(t);return this}implies(t){let e=t;if(typeof t==="string"){e={[t]:true}}this.implied=Object.assign(this.implied||{},e);return this}env(t){this.envVar=t;return this}argParser(t){this.parseArg=t;return this}makeOptionMandatory(t=true){this.mandatory=!!t;return this}hideHelp(t=true){this.hidden=!!t;return this}_concatValue(t,e){if(e===this.defaultValue||!Array.isArray(e)){return[t]}return e.concat(t)}choices(t){this.argChoices=t.slice();this.parseArg=(t,e)=>{if(!this.argChoices.includes(t)){throw new n(`Allowed choices are ${this.argChoices.join(", ")}.`)}if(this.variadic){return this._concatValue(t,e)}return t};return this}name(){if(this.long){return this.long.replace(/^--/,"")}return this.short.replace(/^-/,"")}attributeName(){return camelcase(this.name().replace(/^no-/,""))}is(t){return this.short===t||this.long===t}isBoolean(){return!this.required&&!this.optional&&!this.negate}}class DualOptions{constructor(t){this.positiveOptions=new Map;this.negativeOptions=new Map;this.dualOptions=new Set;t.forEach((t=>{if(t.negate){this.negativeOptions.set(t.attributeName(),t)}else{this.positiveOptions.set(t.attributeName(),t)}}));this.negativeOptions.forEach(((t,e)=>{if(this.positiveOptions.has(e)){this.dualOptions.add(e)}}))}valueFromOption(t,e){const i=e.attributeName();if(!this.dualOptions.has(i))return true;const n=this.negativeOptions.get(i).presetArg;const s=n!==undefined?n:false;return e.negate===(s===t)}}function camelcase(t){return t.split("-").reduce(((t,e)=>t+e[0].toUpperCase()+e.slice(1)))}function splitOptionFlags(t){let e;let i;const n=t.split(/[ |,]+/);if(n.length>1&&!/^[[<]/.test(n[1]))e=n.shift();i=n.shift();if(!e&&/^-[^-]$/.test(i)){e=i;i=undefined}return{shortFlag:e,longFlag:i}}e.Option=Option;e.DualOptions=DualOptions},824:function(t,e){const i=3;function editDistance(t,e){if(Math.abs(t.length-e.length)>i)return Math.max(t.length,e.length);const n=[];for(let e=0;e<=t.length;e++){n[e]=[e]}for(let t=0;t<=e.length;t++){n[0][t]=t}for(let i=1;i<=e.length;i++){for(let s=1;s<=t.length;s++){let r=1;if(t[s-1]===e[i-1]){r=0}else{r=1}n[s][i]=Math.min(n[s-1][i]+1,n[s][i-1]+1,n[s-1][i-1]+r);if(s>1&&i>1&&t[s-1]===e[i-2]&&t[s-2]===e[i-1]){n[s][i]=Math.min(n[s][i],n[s-2][i-2]+1)}}}return n[t.length][e.length]}function suggestSimilar(t,e){if(!e||e.length===0)return"";e=Array.from(new Set(e));const n=t.startsWith("--");if(n){t=t.slice(2);e=e.map((t=>t.slice(2)))}let s=[];let r=i;const o=.4;e.forEach((e=>{if(e.length<=1)return;const i=editDistance(t,e);const n=Math.max(t.length,e.length);const a=(n-i)/n;if(a>o){if(i<r){r=i;s=[e]}else if(i===r){s.push(e)}}}));s.sort(((t,e)=>t.localeCompare(e)));if(n){s=s.map((t=>`--${t}`))}if(s.length>1){return`\n(Did you mean one of ${s.join(", ")}?)`}if(s.length===1){return`\n(Did you mean ${s[0]}?)`}return""}e.suggestSimilar=suggestSimilar}};var e={};function __nccwpck_require__(i){var n=e[i];if(n!==undefined){return n.exports}var s=e[i]={exports:{}};var r=true;try{t[i](s,s.exports,__nccwpck_require__);r=false}finally{if(r)delete e[i]}return s.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var i={};!function(){var t=i;const{Argument:e}=__nccwpck_require__(142);const{Command:n}=__nccwpck_require__(728);const{CommanderError:s,InvalidArgumentError:r}=__nccwpck_require__(841);const{Help:o}=__nccwpck_require__(202);const{Option:a}=__nccwpck_require__(257);t.program=new n;t.createCommand=t=>new n(t);t.createOption=(t,e)=>new a(t,e);t.createArgument=(t,i)=>new e(t,i);t.Command=n;t.Option=a;t.Argument=e;t.Help=o;t.CommanderError=s;t.InvalidArgumentError=r;t.InvalidOptionArgumentError=r}();module.exports=i})();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"commander","version":"12.
|
|
1
|
+
{"name":"commander","version":"12.1.0","author":"TJ Holowaychuk <tj@vision-media.ca>","license":"MIT","_lastModified":"2024-07-10T02:36:07.735Z"}
|
package/es/.lintstagedrc.js
CHANGED
package/es/_util.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{spawn as r}from"child_process";import e from"fs";import t from"path";import{rimrafSync as o,windowsSync as n}from"@baic/yolk-prebundle/compiled/rimraf";import i from"chalk";import{globSync as c}from"glob";import{program as a}from"../compiled/commander";var s=process.cwd(),f=console;export var ENCODING="utf-8";export var warn=function(r){return r&&f.log(i.yellow("warn -"),r)};export var error=function(r){return r&&f.log(i.red("error -"),r)};export var ready=function(r){return r&&f.log(i.green("ready -"),r)};export var info=function(r){return r&&f.log(i.blue("info -"),r)};var p=function(){return"win32"===process.platform},u=function(r){return p()?"".concat(r,".cmd"):r};export var rimrafSync=function(r){return p()?n(r):o(r)};export var completeExit=function(){ready("yolk complete!"),process.exit(0)};export var breakExit=function(){warn("yolk break!"),process.exit(0)};export var execCommand=function(e){var t=e.command,o=e.args,n=e.complete,i=e.close,c=e.exit,s=void 0===c||c,f=r(u(t),o||[],{stdio:"inherit"}).on("close",(function(r){r?(i&&i(),error("yolk close!"),process.exit(r)):(n&&n(),s&&completeExit())}));process.on("SIGINT",(function(){a.exitOverride(),f.kill(),breakExit()}))};export var getYolkConfig=function(){var r=c("*.yolkrc*",{cwd:s,dot:!0});if(!r.length)return{};var o=t.join(s,r[0]);if(!e.existsSync(o))return{};try{return JSON.parse(e.readFileSync(o,ENCODING))||{}}catch(error){return error(error.message||".yolkrc\u8f6c\u6362\u9519\u8bef"),{}}};export var getPrettierConfig=function(){var r=t.join(s,".prettierrc");if(e.existsSync(r))try{return JSON.parse(e.readFileSync(r,ENCODING))||{}}catch(error){return error(error.message||".prettierrc\u8f6c\u6362\u9519\u8bef"),{}}return require("./.prettierrc")};export var getProjectConfigJSON=function(){var r=t.join(s,"project.config.json");if(!e.existsSync(r))return{};try{return JSON.parse(e.readFileSync(r,ENCODING))||{}}catch(error){return error(error.message||"project.config.json\u8f6c\u6362\u9519\u8bef"),{}}};export var getPackageJSON=function(){var r=t.join(s,"package.json");if(!e.existsSync(r))return{};try{return JSON.parse(e.readFileSync(r,ENCODING))||{}}catch(error){return error(error.message||"package.json\u8f6c\u6362\u9519\u8bef"),{}}};export var getConfigFilePath=function(r){var t=getYolkConfig(),o="";try{o=require.resolve("@baic/".concat(r,"-config-yolk"))}catch(error){}var n=c("*.".concat(r,"rc*"),{cwd:s,dot:!0}),i=n[0];return!1===t.strict&&i&&e.existsSync(i)?i:e.existsSync(o)?o:i};export var getEsLintConfigPath=function(){return getConfigFilePath("eslint")};export var getStyleLintConfigPath=function(){return getConfigFilePath("stylelint")};export var getPrettierConfigPath=function(){return getConfigFilePath("prettier")};
|
|
1
|
+
import{spawn as r}from"node:child_process";import e from"node:fs";import t from"node:path";import{rimrafSync as o,windowsSync as n}from"@baic/yolk-prebundle/compiled/rimraf";import i from"chalk";import{globSync as c}from"glob";import{program as a}from"../compiled/commander";var s=process.cwd(),f=console;export var ENCODING="utf-8";export var warn=function(r){return r&&f.log(i.yellow("warn -"),r)};export var error=function(r){return r&&f.log(i.red("error -"),r)};export var ready=function(r){return r&&f.log(i.green("ready -"),r)};export var info=function(r){return r&&f.log(i.blue("info -"),r)};var p=function(){return"win32"===process.platform},u=function(r){return p()?"".concat(r,".cmd"):r};export var rimrafSync=function(r){return p()?n(r):o(r)};export var completeExit=function(){ready("yolk complete!"),process.exit(0)};export var breakExit=function(){warn("yolk break!"),process.exit(0)};export var execCommand=function(e){var t=e.command,o=e.args,n=e.complete,i=e.close,c=e.exit,s=void 0===c||c,f=r(u(t),o||[],{stdio:"inherit"}).on("close",(function(r){r?(i&&i(),error("yolk close!"),process.exit(r)):(n&&n(),s&&completeExit())}));process.on("SIGINT",(function(){a.exitOverride(),f.kill(),breakExit()}))};export var getYolkConfig=function(){var r=c("*.yolkrc*",{cwd:s,dot:!0});if(!r.length)return{};var o=t.join(s,r[0]);if(!e.existsSync(o))return{};try{return JSON.parse(e.readFileSync(o,ENCODING))||{}}catch(error){return error(error.message||".yolkrc\u8f6c\u6362\u9519\u8bef"),{}}};export var getPrettierConfig=function(){var r=t.join(s,".prettierrc");if(e.existsSync(r))try{return JSON.parse(e.readFileSync(r,ENCODING))||{}}catch(error){return error(error.message||".prettierrc\u8f6c\u6362\u9519\u8bef"),{}}return require("./.prettierrc")};export var getProjectConfigJSON=function(){var r=t.join(s,"project.config.json");if(!e.existsSync(r))return{};try{return JSON.parse(e.readFileSync(r,ENCODING))||{}}catch(error){return error(error.message||"project.config.json\u8f6c\u6362\u9519\u8bef"),{}}};export var getPackageJSON=function(){var r=t.join(s,"package.json");if(!e.existsSync(r))return{};try{return JSON.parse(e.readFileSync(r,ENCODING))||{}}catch(error){return error(error.message||"package.json\u8f6c\u6362\u9519\u8bef"),{}}};export var getConfigFilePath=function(r){var t=getYolkConfig(),o="";try{o=require.resolve("@baic/".concat(r,"-config-yolk"))}catch(error){}var n=c("*.".concat(r,"rc*"),{cwd:s,dot:!0}),i=n[0];return!1===t.strict&&i&&e.existsSync(i)?i:e.existsSync(o)?o:i};export var getEsLintConfigPath=function(){return getConfigFilePath("eslint")};export var getStyleLintConfigPath=function(){return getConfigFilePath("stylelint")};export var getPrettierConfigPath=function(){return getConfigFilePath("prettier")};
|
package/es/yolk.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#! /usr/bin/env node
|
|
2
|
-
import e from"@babel/runtime/helpers/slicedToArray";import t from"@babel/runtime/helpers/defineProperty";import o from"@babel/runtime/helpers/asyncToGenerator";import r from"lodash/isString";import n from"lodash/floor";function a(e,t){var o=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),o.push.apply(o,r)}return o}function i(e){for(var o=1;o<arguments.length;o++){var r=null!=arguments[o]?arguments[o]:{};o%2?a(Object(r),!0).forEach((function(o){t(e,o,r[o])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):a(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}import c from"@babel/runtime/regenerator";import{execSync as m}from"child_process";import{chmodSync as s,copyFileSync as p,existsSync as u,readFileSync as l,statSync as d,writeFileSync as f}from"fs";import g from"os";import{basename as v,dirname as y,join as h,relative as F}from"path";import{globSync as b}from"glob";import D from"inquirer";import*as j from"miniprogram-ci";import{mkdirpSync as k}from"mkdirp";import{program as w}from"../compiled/commander";import O from"../compiled/mustache";import P from"../package.json";import{breakExit as x,ENCODING as E,error as S,execCommand as B,getPackageJSON as _,getProjectConfigJSON as q,getYolkConfig as C,info as I,ready as Q,rimrafSync as T,warn as A}from"./_util";var R=process.cwd(),L="##### CREATED BY YOLK #####",N=function(e,t,o){D.prompt([{type:"list",name:"type",message:"\u9009\u62e9\u6a21\u7248",default:"web",choices:[{name:"web template(umi framework)",value:"umi-web"},{name:"web big screen template(umi framework)",value:"umi-web-screen"},{name:"mobile template(umi framework)",value:"umi-mobile"},{name:"mobile HBuilderX h5+app template(umi framework)",value:"umi-mobile-h5+app"},{name:"mobile HBuilderX uni-app template(umi framework)",value:"umi-mobile-uni-app"},{name:"mobile native template(umi framework)",value:"umi-mobile-native"},{name:"miniprogram template",value:"miniprogram"}]},{type:"input",name:"projectName",message:"\u9879\u76ee\u540d\u79f0",default:v(v(process.cwd()))},{type:"list",name:"dependenciesInstallType",message:"\u9009\u62e9\u4f9d\u8d56\u5b89\u88c5\u65b9\u5f0f(\u9ed8\u8ba4\uff1apnpm\uff0c\u63a8\u8350\uff1apnpm)",default:"default",choices:[{name:"\u9ed8\u8ba4\u5b89\u88c5",value:"default"},{name:"\u8df3\u8fc7\u5b89\u88c5",value:!1},{name:"pnpm install",value:"pnpm"},{name:"yarn install",value:"yarn"},{name:"npm install",value:"npm"}]}]).then((function(r){var n=r.type,a=r.projectName,i=r.dependenciesInstallType,c={projectName:a,dependenciesInstallType:"default"===i?"pnpm":i,yolkVersion:P.version};if("umi-mobile-uni-app"!==n){var m=t||h(__dirname,"../templates/".concat(n));Q("\u590d\u5236\u6a21\u7248 ".concat(v(m)));var s=b("**/*",{cwd:m,dot:!0,ignore:["**/node_modules/**","**/.git/**","**/.DS_Store","**/.idea/**"]});if(s.forEach((function(t){if(m){var o=h(m,t);if(!d(o).isDirectory())if(t.endsWith(".tpl")){var r=l(o,E),n=h(e,t.replace(/\.tpl$/,"")),a=O.render(r,c);k(y(n)),Q("\u521b\u5efa ".concat(F(e,n))),f(n,a,E)}else{Q("\u521b\u5efa ".concat(t));var i=h(e,t);k(y(i)),p(o,i)}}})),Q("\u590d\u5236\u6a21\u7248 success!"),o&&u(m)&&T(m)&&Q("\u7f13\u5b58\u5220\u9664 success! ".concat(v(m||""))),i)switch(Q("\u521d\u59cb\u5316\u4f9d\u8d56\u5305"),i){case"default":case"pnpm":B({command:"pnpm",args:["install"]});break;case"yarn":B({command:"yarn",args:["install"]});break;case"npm":B({command:"npm",args:["install"]});break;default:}Q("\u53ef\u67e5\u9605<<https://303394539.github.io/yolk-docs/>>\u4e86\u89e3\u76f8\u5173\u6587\u6863")}else A("\u6682\u4e0d\u652f\u6301")}))},K=function(e,t){return N(e,t,!0)},U=function(){return u(h(R,"project.config.json"))},W=function(){var e=u(h(R,"node_modules/.bin/max"));if(!e)try{e=u(require.resolve("@umijs/max"))}catch(r){}if(!e)try{e=/umi@4\.(\d+)\.(\d+)/.test(m("umi -v").toString())}catch(r){}if(!e){var t=h(R,"node_modules","umi","package.json");if(u(t))try{var o=JSON.parse(l(t,E))||{};e=o.version&&+o.version.split(".")[0]>3}catch(r){}}return e},$=function(){var e=h(R,"project.config.json");if(u(e)){var t=require(e);return t.appid}return""},V=function(){return u(h(R,"project.tt.json"))&&0===$().indexOf("tt")},X=function(){return 0===$().indexOf("20")},G=function(){var e=h(R,".git/"),t=h(R,".git/hooks"),o=h(t,"pre-commit"),r=u(e),n=u(o),a=n&&l(o,E).includes(L);if(r)if(n){if(!a){try{s(o,"777")}catch(c){S("chmod ".concat(o," failed: ").concat(c.message))}var i=l(o).toString();f(o,[i,i.includes("#!/")?"":"#!/bin/sh",L,"npx yolk pre-commit","RESULT=$?","[ $RESULT -ne 0 ] && exit 1","exit 0",L].join(g.EOL),E),Q("write pre-commit hook")}}else{k(t),f(o,["#!/bin/sh",L,"npx yolk pre-commit","RESULT=$?","[ $RESULT -ne 0 ] && exit 1","exit 0",L].join(g.EOL),E),Q("create pre-commit hook");try{s(o,"777")}catch(c){S("chmod ".concat(o," failed: ").concat(c.message))}Q("write pre-commit hook")}},H=function(){var e=o(c.mark((function e(){var t,o,r,n;return c.wrap((function(e){while(1)switch(e.prev=e.next){case 0:t=C(),o=!1!==t.strict,r=t.eslintIgnore,n=t.stylelintIgnore,A("\u7edf\u4e00\u4ee3\u7801\u89c4\u8303\uff0c\u8fdb\u884c\u4e25\u683c\u7684\u8bed\u6cd5\u68c0\u67e5\u3002"),o&&(A("git commit \u7981\u6b62 lint \u7684 ignore \u884c\u4e3a"),n&&A("\u901a\u8fc7 .yolkrc \u914d\u7f6e stylelintIgnore: ".concat(n,"\u3002")),r&&A("\u901a\u8fc7 .yolkrc \u914d\u7f6e eslintIgnore: ".concat(r,"\u3002"))),B({command:"lint-staged",args:["-c",require.resolve("./.lintstagedrc")]});case 7:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),J=function(e){var t=e.mAppid,o=e.mProject,r=e.mPrivateKeyPath,n=e.mVersion,a=e.mDesc,c=e.mRobot,s=e.mQrcodeFormat,p=e.mQrcodeOutputDest,l=e.mPagePath,d=e.mSearchQuery,f=u(h(R,".git"))?m("git log -1 --pretty=format:%H").toString():"",g=q(),v=t||g.appid,y=o||h(R,"dist"),F=r||h(R,"private.".concat(v,".key"));if(u(y)){if(u(F)){var b=_(),D=n||b.version||g.version||"1.0.0",k=a||b.description||g.description,w="".concat(f?" commit: ".concat(f,";"):"").concat(k?" description: ".concat(k,";"):"");f&&I("commit: ".concat(f)),I("dist: ".concat(y)),I("key: ".concat(F)),I("appid: ".concat(v)),I("version: ".concat(D)),I("desc: ".concat(w));var O=new j.Project({appid:v,type:"miniProgram",projectPath:y,privateKeyPath:F,ignores:["node_modules/**/*","**/*.txt","**/*.key","**/*.less","**/*.sass","**/*.scss","**/*.css","**/*.jsx","**/*.ts","**/*.tsx","**/*.md"]});return{appid:v,options:{project:O,version:D,desc:w,setting:i(i({},g.setting),{},{es6:!1,es7:!1,minifyJS:!1,minifyWXML:!1,minifyWXSS:!1,minify:!1}),robot:c,qrcodeFormat:s,qrcodeOutputDest:p,pagePath:l,searchQuery:d}}}throw Error("\u6ca1\u6709\u627e\u5230\u4e0a\u4f20\u5bc6\u94a5(".concat(F,")"))}throw Error("\u6ca1\u6709\u627e\u5230dist\u76ee\u5f55(".concat(y,")"))},M=function(){var e="";try{e=m("npm view ".concat(P.name," version"),{timeout:3e3}).toString().replace(/\n/g,"")}catch(t){}I("yolk version: ".concat(P.version).concat(e&&e!==P.version?"(last\uff1a".concat(e,")"):"")),I("node version: ".concat(process.version)),I("platform: ".concat(g.platform())),I("memory: ".concat(n(g.freemem()/1024/1024)," MB(").concat(n(g.totalmem()/1024/1024)," MB)"))},Y=function(e){return e.option("--appid, --mAppid <appid>","\u5c0f\u7a0b\u5e8fappid").option("--project, --mProject <project>","\u5c0f\u7a0b\u5e8f\u4e0a\u4f20\u5de5\u7a0b\u76ee\u5f55").option("--privateKeyPath, --mPrivateKeyPath <privateKeyPath>","\u5c0f\u7a0b\u5e8f\u4e0a\u4f20key\u6587\u4ef6\uff0c\u9ed8\u8ba4\uff1a{\u5f53\u524d\u76ee\u5f55}/private.{appid}.key").option("--version, --mVersion <version>","\u5c0f\u7a0b\u5e8f\u4e0a\u4f20\u7248\u672c\u53f7").option("--desc, --mDesc <desc>","\u5c0f\u7a0b\u5e8f\u4e0a\u4f20\u63cf\u8ff0").option("--robot, --mRobot <robot>","\u5c0f\u7a0b\u5e8f\u4e0a\u4f20ci\u673a\u5668\u4eba1~30").option("--qrcodeFormat, --mQrcodeFormat <qrcodeFormat>",'\u5c0f\u7a0b\u5e8f\u9884\u89c8\u8fd4\u56de\u4e8c\u7ef4\u7801\u6587\u4ef6\u7684\u683c\u5f0f "image" \u6216 "base64"\uff0c \u9ed8\u8ba4\u503c "terminal" \u4f9b\u8c03\u8bd5\u7528').option("--qrcodeOutputDest, --mQrcodeOutputDest <qrcodeOutputDest>","\u5c0f\u7a0b\u5e8f\u9884\u89c8\u4e8c\u7ef4\u7801\u6587\u4ef6\u4fdd\u5b58\u8def\u5f84").option("--pagePath, --mPagePath <pagePath>","\u5c0f\u7a0b\u5e8f\u9884\u89c8\u9884\u89c8\u9875\u9762\u8def\u5f84").option("--searchQuery, --mSearchQuery <searchQuery>","\u5c0f\u7a0b\u5e8f\u9884\u89c8\u9884\u89c8\u9875\u9762\u8def\u5f84\u542f\u52a8\u53c2\u6570")},z=/([0-9A-Z_a-z\u017F\u212A]+)=('((?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)'|"((?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)"|((?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*))/gi,Z=function(t){process.env.DID_YOU_KNOW="none",process.env.VITE_CJS_IGNORE_WARNING="true";var o=[];return null===t||void 0===t||t.forEach((function(t){if(z.test(t)){var r=t.split("="),n=e(r,2),a=n[0],i=n[1];process.env[a]=i,I("\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf\uff1a".concat(a,"=").concat(i))}else o.push(t)})),o},ee=function(){G(),process.argv.length>2?(w.version(P.version,"-v,--version","\u8f93\u51fa\u7248\u672c\u53f7").usage("[command] [options]"),w.command("init").description("\u521d\u59cb\u5316\u9879\u76ee").option("--clone <template>","\u5982\u679c\u9700\u8981\uff0c\u53ef\u901a\u8fc7git clone\u62c9\u53d6\u6a21\u7248\uff0c\u9ed8\u8ba4\u53d6cli\u9ed8\u8ba4\u6a21\u7248").action((function(e,t){var o=e.clone,r=t.args;if(M(),Q("yolk init \u5f00\u59cb"),o){var n=".yolk",a=h(R,n);u(a)&&T(a)&&Q("\u7f13\u5b58\u5220\u9664 success! ".concat(a)),B({command:"git",args:["clone","-b","master","--depth","1",o,n].concat(r)}),K(R,a)}else N(R)})),w.command("start").description("\u542f\u52a8\u9879\u76ee").option("--docs","\u6587\u6863\u6a21\u5f0f").action((function(e,t){var o=e.docs,r=t.args;M();var n=Z(r);U()?V()?B({command:"taro",args:["build","--type","tt","--watch"].concat(n)}):X()?B({command:"taro",args:["build","--type","alipay","--watch"].concat(n)}):B({command:"taro",args:["build","--type","weapp","--watch"].concat(n)}):o?B({command:"dumi",args:["dev"].concat(n)}):W()?B({command:"max",args:["dev"].concat(n)}):B({command:"umi",args:["dev"].concat(n)})})),w.command("build").description("\u7f16\u8bd1\u9879\u76ee").option("--docs","\u6587\u6863\u6a21\u5f0f").action((function(e,t){var o=e.docs,r=t.args;M();var n=Z(r);U()?V()?B({command:"taro",args:["build","--type","tt"].concat(n)}):X()?B({command:"taro",args:["build","--type","alipay"].concat(n)}):B({command:"taro",args:["build","--type","weapp"].concat(n)}):o?B({command:"dumi",args:["build"].concat(n)}):W()?B({command:"max",args:["setup"].concat(n),complete:function(){return B({command:"max",args:["build"].concat(n)})},exit:!1}):B({command:"umi",args:["build"].concat(n)})})),w.command("pre-commit").description("\u6267\u884ccommit hook").action(H),Y(w.command("miniprogram-upload").description("\u4f7f\u7528 miniprogram-ci \u4e0a\u4f20\u5c0f\u7a0b\u5e8f")).action((function(e){if(U())if(V());else if(X());else{var t=J(e),o=t.appid,n=t.options,a=n.project,i=n.version,c=n.desc,m=n.setting,s=n.robot;I("".concat(o," \u4e0a\u4f20\u5f00\u59cb")),j.upload({project:a,version:i,desc:c,setting:m,robot:s,onProgressUpdate:function(e){if(r(e))I("task: ".concat(e));else{var t=e.status,o=e.message;I("task(".concat(t,"): ").concat(o))}}}).then((function(){Q("".concat(o," \u4e0a\u4f20\u5b8c\u6210"))}))}else S("\u975e\u5c0f\u7a0b\u5e8f\u9879\u76ee\u76ee\u5f55")})),Y(w.command("miniprogram-preview").description("\u4f7f\u7528 miniprogram-ci \u9884\u89c8\u5c0f\u7a0b\u5e8f")).action((function(e){if(U())if(V());else if(X());else{var t=J(e),o=t.appid,n=t.options,a=n.project,i=n.version,c=n.desc,m=n.setting,s=n.robot,p=n.qrcodeFormat,u=n.qrcodeOutputDest,l=n.pagePath,d=n.searchQuery;I("".concat(o," \u4e0a\u4f20\u9884\u89c8\u5f00\u59cb")),j.preview({project:a,version:i,desc:c,setting:m,robot:s,qrcodeFormat:p,qrcodeOutputDest:u,pagePath:l,searchQuery:d,onProgressUpdate:function(e){if(r(e))I("task: ".concat(e));else{var t=e.status,o=e.message;I("task(".concat(t,"): ").concat(o))}}}).then((function(){Q("".concat(o," \u4e0a\u4f20\u9884\u89c8\u5b8c\u6210"))}))}else S("\u975e\u5c0f\u7a0b\u5e8f\u9879\u76ee\u76ee\u5f55")})),w.parse(process.argv)):x()};ee();
|
|
2
|
+
import e from"@babel/runtime/helpers/slicedToArray";import t from"@babel/runtime/helpers/defineProperty";import o from"@babel/runtime/helpers/asyncToGenerator";import r from"lodash/isString";import n from"lodash/floor";function a(e,t){var o=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),o.push.apply(o,r)}return o}function i(e){for(var o=1;o<arguments.length;o++){var r=null!=arguments[o]?arguments[o]:{};o%2?a(Object(r),!0).forEach((function(o){t(e,o,r[o])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):a(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}import c from"@babel/runtime/regenerator";import{execSync as m}from"node:child_process";import{chmodSync as s,copyFileSync as p,existsSync as u,readFileSync as l,statSync as d,writeFileSync as f}from"node:fs";import g from"node:os";import{basename as v,dirname as y,join as h,relative as F}from"node:path";import{globSync as b}from"glob";import D from"inquirer";import*as j from"miniprogram-ci";import{mkdirpSync as k}from"mkdirp";import{program as w}from"../compiled/commander";import O from"../compiled/mustache";import P from"../package.json";import{breakExit as x,ENCODING as E,error as S,execCommand as B,getPackageJSON as _,getProjectConfigJSON as q,getYolkConfig as C,info as I,ready as Q,rimrafSync as T,warn as A}from"./_util";var R=process.cwd(),L="##### CREATED BY YOLK #####",N=function(e,t,o){D.prompt([{type:"list",name:"type",message:"\u9009\u62e9\u6a21\u7248",default:"web",choices:[{name:"web template(umi framework)",value:"umi-web"},{name:"web big screen template(umi framework)",value:"umi-web-screen"},{name:"mobile template(umi framework)",value:"umi-mobile"},{name:"mobile HBuilderX h5+app template(umi framework)",value:"umi-mobile-h5+app"},{name:"mobile HBuilderX uni-app template(umi framework)",value:"umi-mobile-uni-app"},{name:"mobile native template(umi framework)",value:"umi-mobile-native"},{name:"miniprogram template",value:"miniprogram"}]},{type:"input",name:"projectName",message:"\u9879\u76ee\u540d\u79f0",default:v(v(process.cwd()))},{type:"list",name:"dependenciesInstallType",message:"\u9009\u62e9\u4f9d\u8d56\u5b89\u88c5\u65b9\u5f0f(\u9ed8\u8ba4\uff1apnpm\uff0c\u63a8\u8350\uff1apnpm)",default:"default",choices:[{name:"\u9ed8\u8ba4\u5b89\u88c5",value:"default"},{name:"\u8df3\u8fc7\u5b89\u88c5",value:!1},{name:"pnpm install",value:"pnpm"},{name:"yarn install",value:"yarn"},{name:"npm install",value:"npm"}]}]).then((function(r){var n=r.type,a=r.projectName,i=r.dependenciesInstallType,c={projectName:a,dependenciesInstallType:"default"===i?"pnpm":i,yolkVersion:P.version};if("umi-mobile-uni-app"!==n){var m=t||h(__dirname,"../templates/".concat(n));Q("\u590d\u5236\u6a21\u7248 ".concat(v(m)));var s=b("**/*",{cwd:m,dot:!0,ignore:["**/node_modules/**","**/.git/**","**/.DS_Store","**/.idea/**"]});if(s.forEach((function(t){if(m){var o=h(m,t);if(!d(o).isDirectory())if(t.endsWith(".tpl")){var r=l(o,E),n=h(e,t.replace(/\.tpl$/,"")),a=O.render(r,c);k(y(n)),Q("\u521b\u5efa ".concat(F(e,n))),f(n,a,E)}else{Q("\u521b\u5efa ".concat(t));var i=h(e,t);k(y(i)),p(o,i)}}})),Q("\u590d\u5236\u6a21\u7248 success!"),o&&u(m)&&T(m)&&Q("\u7f13\u5b58\u5220\u9664 success! ".concat(v(m||""))),i)switch(Q("\u521d\u59cb\u5316\u4f9d\u8d56\u5305"),i){case"default":case"pnpm":B({command:"pnpm",args:["install"]});break;case"yarn":B({command:"yarn",args:["install"]});break;case"npm":B({command:"npm",args:["install"]});break;default:}Q("\u53ef\u67e5\u9605<<https://303394539.github.io/yolk-docs/>>\u4e86\u89e3\u76f8\u5173\u6587\u6863")}else A("\u6682\u4e0d\u652f\u6301")}))},K=function(e,t){return N(e,t,!0)},U=function(){return u(h(R,"project.config.json"))},W=function(){var e=u(h(R,"node_modules/.bin/max"));if(!e)try{e=u(require.resolve("@umijs/max"))}catch(r){}if(!e)try{e=/umi@4\.(\d+)\.(\d+)/.test(m("umi -v").toString())}catch(r){}if(!e){var t=h(R,"node_modules","umi","package.json");if(u(t))try{var o=JSON.parse(l(t,E))||{};e=o.version&&+o.version.split(".")[0]>3}catch(r){}}return e},$=function(){var e=h(R,"project.config.json");if(u(e)){var t=require(e);return t.appid}return""},V=function(){return u(h(R,"project.tt.json"))&&0===$().indexOf("tt")},X=function(){return 0===$().indexOf("20")},G=function(){var e=h(R,".git/"),t=h(R,".git/hooks"),o=h(t,"pre-commit"),r=u(e),n=u(o),a=n&&l(o,E).includes(L);if(r)if(n){if(!a){try{s(o,"777")}catch(c){S("chmod ".concat(o," failed: ").concat(c.message))}var i=l(o).toString();f(o,[i,i.includes("#!/")?"":"#!/bin/sh",L,"npx yolk pre-commit","RESULT=$?","[ $RESULT -ne 0 ] && exit 1","exit 0",L].join(g.EOL),E),Q("write pre-commit hook")}}else{k(t),f(o,["#!/bin/sh",L,"npx yolk pre-commit","RESULT=$?","[ $RESULT -ne 0 ] && exit 1","exit 0",L].join(g.EOL),E),Q("create pre-commit hook");try{s(o,"777")}catch(c){S("chmod ".concat(o," failed: ").concat(c.message))}Q("write pre-commit hook")}},H=function(){var e=o(c.mark((function e(){var t,o,r,n;return c.wrap((function(e){while(1)switch(e.prev=e.next){case 0:t=C(),o=!1!==t.strict,r=t.eslintIgnore,n=t.stylelintIgnore,A("\u7edf\u4e00\u4ee3\u7801\u89c4\u8303\uff0c\u8fdb\u884c\u4e25\u683c\u7684\u8bed\u6cd5\u68c0\u67e5\u3002"),o&&(A("git commit \u7981\u6b62 lint \u7684 ignore \u884c\u4e3a"),n&&A("\u901a\u8fc7 .yolkrc \u914d\u7f6e stylelintIgnore: ".concat(n,"\u3002")),r&&A("\u901a\u8fc7 .yolkrc \u914d\u7f6e eslintIgnore: ".concat(r,"\u3002"))),B({command:"lint-staged",args:["-c",require.resolve("./.lintstagedrc")]});case 7:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),J=function(e){var t=e.mAppid,o=e.mProject,r=e.mPrivateKeyPath,n=e.mVersion,a=e.mDesc,c=e.mRobot,s=e.mQrcodeFormat,p=e.mQrcodeOutputDest,l=e.mPagePath,d=e.mSearchQuery,f=u(h(R,".git"))?m("git log -1 --pretty=format:%H").toString():"",g=q(),v=t||g.appid,y=o||h(R,"dist"),F=r||h(R,"private.".concat(v,".key"));if(u(y)){if(u(F)){var b=_(),D=n||b.version||g.version||"1.0.0",k=a||b.description||g.description,w="".concat(f?" commit: ".concat(f,";"):"").concat(k?" description: ".concat(k,";"):"");f&&I("commit: ".concat(f)),I("dist: ".concat(y)),I("key: ".concat(F)),I("appid: ".concat(v)),I("version: ".concat(D)),I("desc: ".concat(w));var O=new j.Project({appid:v,type:"miniProgram",projectPath:y,privateKeyPath:F,ignores:["node_modules/**/*","**/*.txt","**/*.key","**/*.less","**/*.sass","**/*.scss","**/*.css","**/*.jsx","**/*.ts","**/*.tsx","**/*.md"]});return{appid:v,options:{project:O,version:D,desc:w,setting:i(i({},g.setting),{},{es6:!1,es7:!1,minifyJS:!1,minifyWXML:!1,minifyWXSS:!1,minify:!1}),robot:c,qrcodeFormat:s,qrcodeOutputDest:p,pagePath:l,searchQuery:d}}}throw Error("\u6ca1\u6709\u627e\u5230\u4e0a\u4f20\u5bc6\u94a5(".concat(F,")"))}throw Error("\u6ca1\u6709\u627e\u5230dist\u76ee\u5f55(".concat(y,")"))},M=function(){var e="";try{e=m("npm view ".concat(P.name," version"),{timeout:3e3}).toString().replace(/\n/g,"")}catch(t){}I("yolk version: ".concat(P.version).concat(e&&e!==P.version?"(last\uff1a".concat(e,")"):"")),I("node version: ".concat(process.version)),I("platform: ".concat(g.platform())),I("memory: ".concat(n(g.freemem()/1024/1024)," MB(").concat(n(g.totalmem()/1024/1024)," MB)"))},Y=function(e){return e.option("--appid, --mAppid <appid>","\u5c0f\u7a0b\u5e8fappid").option("--project, --mProject <project>","\u5c0f\u7a0b\u5e8f\u4e0a\u4f20\u5de5\u7a0b\u76ee\u5f55").option("--privateKeyPath, --mPrivateKeyPath <privateKeyPath>","\u5c0f\u7a0b\u5e8f\u4e0a\u4f20key\u6587\u4ef6\uff0c\u9ed8\u8ba4\uff1a{\u5f53\u524d\u76ee\u5f55}/private.{appid}.key").option("--version, --mVersion <version>","\u5c0f\u7a0b\u5e8f\u4e0a\u4f20\u7248\u672c\u53f7").option("--desc, --mDesc <desc>","\u5c0f\u7a0b\u5e8f\u4e0a\u4f20\u63cf\u8ff0").option("--robot, --mRobot <robot>","\u5c0f\u7a0b\u5e8f\u4e0a\u4f20ci\u673a\u5668\u4eba1~30").option("--qrcodeFormat, --mQrcodeFormat <qrcodeFormat>",'\u5c0f\u7a0b\u5e8f\u9884\u89c8\u8fd4\u56de\u4e8c\u7ef4\u7801\u6587\u4ef6\u7684\u683c\u5f0f "image" \u6216 "base64"\uff0c \u9ed8\u8ba4\u503c "terminal" \u4f9b\u8c03\u8bd5\u7528').option("--qrcodeOutputDest, --mQrcodeOutputDest <qrcodeOutputDest>","\u5c0f\u7a0b\u5e8f\u9884\u89c8\u4e8c\u7ef4\u7801\u6587\u4ef6\u4fdd\u5b58\u8def\u5f84").option("--pagePath, --mPagePath <pagePath>","\u5c0f\u7a0b\u5e8f\u9884\u89c8\u9884\u89c8\u9875\u9762\u8def\u5f84").option("--searchQuery, --mSearchQuery <searchQuery>","\u5c0f\u7a0b\u5e8f\u9884\u89c8\u9884\u89c8\u9875\u9762\u8def\u5f84\u542f\u52a8\u53c2\u6570")},z=/([0-9A-Z_a-z\u017F\u212A]+)=('((?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)'|"((?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)"|((?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*))/gi,Z=function(t){process.env.DID_YOU_KNOW="none",process.env.VITE_CJS_IGNORE_WARNING="true";var o=[];return null===t||void 0===t||t.forEach((function(t){if(z.test(t)){var r=t.split("="),n=e(r,2),a=n[0],i=n[1];process.env[a]=i,I("\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf\uff1a".concat(a,"=").concat(i))}else o.push(t)})),o},ee=function(){G(),process.argv.length>2?(w.version(P.version,"-v,--version","\u8f93\u51fa\u7248\u672c\u53f7").usage("[command] [options]"),w.command("init").description("\u521d\u59cb\u5316\u9879\u76ee").option("--clone <template>","\u5982\u679c\u9700\u8981\uff0c\u53ef\u901a\u8fc7git clone\u62c9\u53d6\u6a21\u7248\uff0c\u9ed8\u8ba4\u53d6cli\u9ed8\u8ba4\u6a21\u7248").action((function(e,t){var o=e.clone,r=t.args;if(M(),Q("yolk init \u5f00\u59cb"),o){var n=".yolk",a=h(R,n);u(a)&&T(a)&&Q("\u7f13\u5b58\u5220\u9664 success! ".concat(a)),B({command:"git",args:["clone","-b","master","--depth","1",o,n].concat(r)}),K(R,a)}else N(R)})),w.command("start").description("\u542f\u52a8\u9879\u76ee").option("--docs","\u6587\u6863\u6a21\u5f0f").action((function(e,t){var o=e.docs,r=t.args;M();var n=Z(r);U()?V()?B({command:"taro",args:["build","--type","tt","--watch"].concat(n)}):X()?B({command:"taro",args:["build","--type","alipay","--watch"].concat(n)}):B({command:"taro",args:["build","--type","weapp","--watch"].concat(n)}):o?B({command:"dumi",args:["dev"].concat(n)}):W()?B({command:"max",args:["dev"].concat(n)}):B({command:"umi",args:["dev"].concat(n)})})),w.command("build").description("\u7f16\u8bd1\u9879\u76ee").option("--docs","\u6587\u6863\u6a21\u5f0f").action((function(e,t){var o=e.docs,r=t.args;M();var n=Z(r);U()?V()?B({command:"taro",args:["build","--type","tt"].concat(n)}):X()?B({command:"taro",args:["build","--type","alipay"].concat(n)}):B({command:"taro",args:["build","--type","weapp"].concat(n)}):o?B({command:"dumi",args:["build"].concat(n)}):W()?B({command:"max",args:["setup"].concat(n),complete:function(){return B({command:"max",args:["build"].concat(n)})},exit:!1}):B({command:"umi",args:["build"].concat(n)})})),w.command("pre-commit").description("\u6267\u884ccommit hook").action(H),Y(w.command("miniprogram-upload").description("\u4f7f\u7528 miniprogram-ci \u4e0a\u4f20\u5c0f\u7a0b\u5e8f")).action((function(e){if(U())if(V());else if(X());else{var t=J(e),o=t.appid,n=t.options,a=n.project,i=n.version,c=n.desc,m=n.setting,s=n.robot;I("".concat(o," \u4e0a\u4f20\u5f00\u59cb")),j.upload({project:a,version:i,desc:c,setting:m,robot:s,onProgressUpdate:function(e){if(r(e))I("task: ".concat(e));else{var t=e.status,o=e.message;I("task(".concat(t,"): ").concat(o))}}}).then((function(){Q("".concat(o," \u4e0a\u4f20\u5b8c\u6210"))}))}else S("\u975e\u5c0f\u7a0b\u5e8f\u9879\u76ee\u76ee\u5f55")})),Y(w.command("miniprogram-preview").description("\u4f7f\u7528 miniprogram-ci \u9884\u89c8\u5c0f\u7a0b\u5e8f")).action((function(e){if(U())if(V());else if(X());else{var t=J(e),o=t.appid,n=t.options,a=n.project,i=n.version,c=n.desc,m=n.setting,s=n.robot,p=n.qrcodeFormat,u=n.qrcodeOutputDest,l=n.pagePath,d=n.searchQuery;I("".concat(o," \u4e0a\u4f20\u9884\u89c8\u5f00\u59cb")),j.preview({project:a,version:i,desc:c,setting:m,robot:s,qrcodeFormat:p,qrcodeOutputDest:u,pagePath:l,searchQuery:d,onProgressUpdate:function(e){if(r(e))I("task: ".concat(e));else{var t=e.status,o=e.message;I("task(".concat(t,"): ").concat(o))}}}).then((function(){Q("".concat(o," \u4e0a\u4f20\u9884\u89c8\u5b8c\u6210"))}))}else S("\u975e\u5c0f\u7a0b\u5e8f\u9879\u76ee\u76ee\u5f55")})),w.parse(process.argv)):x()};ee();
|
package/lib/.lintstagedrc.js
CHANGED
package/lib/_util.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=Object.create,r=Object.defineProperty,t=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,n=Object.getPrototypeOf,c=Object.prototype.hasOwnProperty,a=(e,t)=>{for(var o in t)r(e,o,{get:t[o],enumerable:!0})},i=(e,n,a,i)=>{if(n&&"object"===typeof n||"function"===typeof n)for(let l of o(n))c.call(e,l)||l===a||r(e,l,{get:()=>n[l],enumerable:!(i=t(n,l))||i.enumerable});return e},l=(t,o,c)=>(c=null!=t?e(n(t)):{},i(!o&&t&&t.__esModule?c:r(c,"default",{value:t,enumerable:!0}),t)),s=e=>i(r({},"__esModule",{value:!0}),e),u={};a(u,{ENCODING:()=>O,breakExit:()=>v,completeExit:()=>C,error:()=>k,execCommand:()=>J,getConfigFilePath:()=>$,getEsLintConfigPath:()=>D,getPackageJSON:()=>I,getPrettierConfig:()=>_,getPrettierConfigPath:()=>L,getProjectConfigJSON:()=>E,getStyleLintConfigPath:()=>G,getYolkConfig:()=>F,info:()=>w,ready:()=>x,rimrafSync:()=>q,warn:()=>h}),module.exports=s(u);var f=require("child_process"),d=l(require("fs")),g=l(require("path")),p=require("@baic/yolk-prebundle/compiled/rimraf"),y=l(require("chalk")),m=require("glob"),S=require("../compiled/commander"),b=process.cwd(),j=console,O="utf-8",h=e=>e&&j.log(y.default.yellow("warn -"),e),k=e=>e&&j.log(y.default.red("error -"),e),x=e=>e&&j.log(y.default.green("ready -"),e),w=e=>e&&j.log(y.default.blue("info -"),e),P=()=>"win32"===process.platform,N=e=>P()?`${e}.cmd`:e,q=e=>P()?(0,p.windowsSync)(e):(0,p.rimrafSync)(e),C=()=>{x("yolk complete!"),process.exit(0)},v=()=>{h("yolk break!"),process.exit(0)},J=({command:e,args:r,complete:t,close:o,exit:n=!0})=>{const c=(0,f.spawn)(N(e),r||[],{stdio:"inherit"}).on("close",(e=>{e?(o&&o(),k("yolk close!"),process.exit(e)):(t&&t(),n&&C())}));process.on("SIGINT",(()=>{S.program.exitOverride(),c.kill(),v()}))},F=()=>{const e=(0,m.globSync)("*.yolkrc*",{cwd:b,dot:!0});if(!e.length)return{};const r=g.default.join(b,e[0]);if(!d.default.existsSync(r))return{};try{return JSON.parse(d.default.readFileSync(r,O))||{}}catch(t){return t(t.message||".yolkrc\u8f6c\u6362\u9519\u8bef"),{}}},_=()=>{const e=g.default.join(b,".prettierrc");if(d.default.existsSync(e))try{return JSON.parse(d.default.readFileSync(e,O))||{}}catch(r){return r(r.message||".prettierrc\u8f6c\u6362\u9519\u8bef"),{}}return require("./.prettierrc")},E=()=>{const e=g.default.join(b,"project.config.json");if(!d.default.existsSync(e))return{};try{return JSON.parse(d.default.readFileSync(e,O))||{}}catch(r){return r(r.message||"project.config.json\u8f6c\u6362\u9519\u8bef"),{}}},I=()=>{const e=g.default.join(b,"package.json");if(!d.default.existsSync(e))return{};try{return JSON.parse(d.default.readFileSync(e,O))||{}}catch(r){return r(r.message||"package.json\u8f6c\u6362\u9519\u8bef"),{}}},$=e=>{const r=F();let t="";try{t=require.resolve(`@baic/${e}-config-yolk`)}catch(c){}const o=(0,m.globSync)(`*.${e}rc*`,{cwd:b,dot:!0}),n=o[0];return!1===r.strict&&n&&d.default.existsSync(n)?n:d.default.existsSync(t)?t:n},D=()=>$("eslint"),G=()=>$("stylelint"),L=()=>$("prettier");
|
|
1
|
+
var e=Object.create,r=Object.defineProperty,t=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,n=Object.getPrototypeOf,c=Object.prototype.hasOwnProperty,a=(e,t)=>{for(var o in t)r(e,o,{get:t[o],enumerable:!0})},i=(e,n,a,i)=>{if(n&&"object"===typeof n||"function"===typeof n)for(let l of o(n))c.call(e,l)||l===a||r(e,l,{get:()=>n[l],enumerable:!(i=t(n,l))||i.enumerable});return e},l=(t,o,c)=>(c=null!=t?e(n(t)):{},i(!o&&t&&t.__esModule?c:r(c,"default",{value:t,enumerable:!0}),t)),s=e=>i(r({},"__esModule",{value:!0}),e),u={};a(u,{ENCODING:()=>O,breakExit:()=>v,completeExit:()=>C,error:()=>k,execCommand:()=>J,getConfigFilePath:()=>$,getEsLintConfigPath:()=>D,getPackageJSON:()=>I,getPrettierConfig:()=>_,getPrettierConfigPath:()=>L,getProjectConfigJSON:()=>E,getStyleLintConfigPath:()=>G,getYolkConfig:()=>F,info:()=>w,ready:()=>x,rimrafSync:()=>q,warn:()=>h}),module.exports=s(u);var f=require("node:child_process"),d=l(require("node:fs")),g=l(require("node:path")),p=require("@baic/yolk-prebundle/compiled/rimraf"),y=l(require("chalk")),m=require("glob"),S=require("../compiled/commander"),b=process.cwd(),j=console,O="utf-8",h=e=>e&&j.log(y.default.yellow("warn -"),e),k=e=>e&&j.log(y.default.red("error -"),e),x=e=>e&&j.log(y.default.green("ready -"),e),w=e=>e&&j.log(y.default.blue("info -"),e),P=()=>"win32"===process.platform,N=e=>P()?`${e}.cmd`:e,q=e=>P()?(0,p.windowsSync)(e):(0,p.rimrafSync)(e),C=()=>{x("yolk complete!"),process.exit(0)},v=()=>{h("yolk break!"),process.exit(0)},J=({command:e,args:r,complete:t,close:o,exit:n=!0})=>{const c=(0,f.spawn)(N(e),r||[],{stdio:"inherit"}).on("close",(e=>{e?(o&&o(),k("yolk close!"),process.exit(e)):(t&&t(),n&&C())}));process.on("SIGINT",(()=>{S.program.exitOverride(),c.kill(),v()}))},F=()=>{const e=(0,m.globSync)("*.yolkrc*",{cwd:b,dot:!0});if(!e.length)return{};const r=g.default.join(b,e[0]);if(!d.default.existsSync(r))return{};try{return JSON.parse(d.default.readFileSync(r,O))||{}}catch(t){return t(t.message||".yolkrc\u8f6c\u6362\u9519\u8bef"),{}}},_=()=>{const e=g.default.join(b,".prettierrc");if(d.default.existsSync(e))try{return JSON.parse(d.default.readFileSync(e,O))||{}}catch(r){return r(r.message||".prettierrc\u8f6c\u6362\u9519\u8bef"),{}}return require("./.prettierrc")},E=()=>{const e=g.default.join(b,"project.config.json");if(!d.default.existsSync(e))return{};try{return JSON.parse(d.default.readFileSync(e,O))||{}}catch(r){return r(r.message||"project.config.json\u8f6c\u6362\u9519\u8bef"),{}}},I=()=>{const e=g.default.join(b,"package.json");if(!d.default.existsSync(e))return{};try{return JSON.parse(d.default.readFileSync(e,O))||{}}catch(r){return r(r.message||"package.json\u8f6c\u6362\u9519\u8bef"),{}}},$=e=>{const r=F();let t="";try{t=require.resolve(`@baic/${e}-config-yolk`)}catch(c){}const o=(0,m.globSync)(`*.${e}rc*`,{cwd:b,dot:!0}),n=o[0];return!1===r.strict&&n&&d.default.existsSync(n)?n:d.default.existsSync(t)?t:n},D=()=>$("eslint"),G=()=>$("stylelint"),L=()=>$("prettier");
|
package/lib/yolk.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#! /usr/bin/env node
|
|
2
|
-
var e=Object.create,o=Object.defineProperty,t=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,r=Object.getPrototypeOf,n=Object.prototype.hasOwnProperty,a=(e,r,a,c)=>{if(r&&"object"===typeof r||"function"===typeof r)for(let s of i(r))n.call(e,s)||s===a||o(e,s,{get:()=>r[s],enumerable:!(c=t(r,s))||c.enumerable});return e},c=(t,i,n)=>(n=null!=t?e(r(t)):{},a(!i&&t&&t.__esModule?n:o(n,"default",{value:t,enumerable:!0}),t)),s=require("child_process"),m=require("fs"),p=c(require("os")),d=require("path"),l=require("lodash"),u=require("glob"),y=c(require("inquirer")),g=c(require("miniprogram-ci")),f=require("mkdirp"),h=require("../compiled/commander"),v=c(require("../compiled/mustache")),b=c(require("../package.json")),S=require("./_util"),x=process.cwd(),j="##### CREATED BY YOLK #####",$=(e,o,t)=>{y.default.prompt([{type:"list",name:"type",message:"\u9009\u62e9\u6a21\u7248",default:"web",choices:[{name:"web template(umi framework)",value:"umi-web"},{name:"web big screen template(umi framework)",value:"umi-web-screen"},{name:"mobile template(umi framework)",value:"umi-mobile"},{name:"mobile HBuilderX h5+app template(umi framework)",value:"umi-mobile-h5+app"},{name:"mobile HBuilderX uni-app template(umi framework)",value:"umi-mobile-uni-app"},{name:"mobile native template(umi framework)",value:"umi-mobile-native"},{name:"miniprogram template",value:"miniprogram"}]},{type:"input",name:"projectName",message:"\u9879\u76ee\u540d\u79f0",default:(0,d.basename)((0,d.basename)(process.cwd()))},{type:"list",name:"dependenciesInstallType",message:"\u9009\u62e9\u4f9d\u8d56\u5b89\u88c5\u65b9\u5f0f(\u9ed8\u8ba4\uff1apnpm\uff0c\u63a8\u8350\uff1apnpm)",default:"default",choices:[{name:"\u9ed8\u8ba4\u5b89\u88c5",value:"default"},{name:"\u8df3\u8fc7\u5b89\u88c5",value:!1},{name:"pnpm install",value:"pnpm"},{name:"yarn install",value:"yarn"},{name:"npm install",value:"npm"}]}]).then((({type:i,projectName:r,dependenciesInstallType:n})=>{const a={projectName:r,dependenciesInstallType:"default"===n?"pnpm":n,yolkVersion:b.default.version};if("umi-mobile-uni-app"===i)return void(0,S.warn)("\u6682\u4e0d\u652f\u6301");const c=o||(0,d.join)(__dirname,`../templates/${i}`);(0,S.ready)(`\u590d\u5236\u6a21\u7248 ${(0,d.basename)(c)}`);const s=(0,u.globSync)("**/*",{cwd:c,dot:!0,ignore:["**/node_modules/**","**/.git/**","**/.DS_Store","**/.idea/**"]});if(s.forEach((o=>{if(!c)return;const t=(0,d.join)(c,o);if(!(0,m.statSync)(t).isDirectory())if(o.endsWith(".tpl")){const i=(0,m.readFileSync)(t,S.ENCODING),r=(0,d.join)(e,o.replace(/\.tpl$/,"")),n=v.default.render(i,a);(0,f.mkdirpSync)((0,d.dirname)(r)),(0,S.ready)(`\u521b\u5efa ${(0,d.relative)(e,r)}`),(0,m.writeFileSync)(r,n,S.ENCODING)}else{(0,S.ready)(`\u521b\u5efa ${o}`);const i=(0,d.join)(e,o);(0,f.mkdirpSync)((0,d.dirname)(i)),(0,m.copyFileSync)(t,i)}})),(0,S.ready)("\u590d\u5236\u6a21\u7248 success!"),t&&(0,m.existsSync)(c)&&(0,S.rimrafSync)(c)&&(0,S.ready)(`\u7f13\u5b58\u5220\u9664 success! ${(0,d.basename)(c||"")}`),n)switch((0,S.ready)("\u521d\u59cb\u5316\u4f9d\u8d56\u5305"),n){case"default":case"pnpm":(0,S.execCommand)({command:"pnpm",args:["install"]});break;case"yarn":(0,S.execCommand)({command:"yarn",args:["install"]});break;case"npm":(0,S.execCommand)({command:"npm",args:["install"]});break;default:}(0,S.ready)("\u53ef\u67e5\u9605<<https://303394539.github.io/yolk-docs/>>\u4e86\u89e3\u76f8\u5173\u6587\u6863")}))},k=(e,o)=>$(e,o,!0),w=()=>(0,m.existsSync)((0,d.join)(x,"project.config.json")),O=()=>{let e=(0,m.existsSync)((0,d.join)(x,"node_modules/.bin/max"));if(!e)try{e=(0,m.existsSync)(require.resolve("@umijs/max"))}catch(o){}if(!e)try{e=/umi@4\.(\d+)\.(\d+)/.test((0,s.execSync)("umi -v").toString())}catch(o){}if(!e){const t=(0,d.join)(x,"node_modules","umi","package.json");if((0,m.existsSync)(t))try{const o=JSON.parse((0,m.readFileSync)(t,S.ENCODING))||{};e=o.version&&+o.version.split(".")[0]>3}catch(o){}}return e},P=()=>{const e=(0,d.join)(x,"project.config.json");if((0,m.existsSync)(e)){const o=require(e);return o.appid}return""},C=()=>(0,m.existsSync)((0,d.join)(x,"project.tt.json"))&&0===P().indexOf("tt"),q=()=>0===P().indexOf("20"),N=()=>{const e=(0,d.join)(x,".git/"),o=(0,d.join)(x,".git/hooks"),t=(0,d.join)(o,"pre-commit"),i=(0,m.existsSync)(e),r=(0,m.existsSync)(t),n=r&&(0,m.readFileSync)(t,S.ENCODING).includes(j);if(i)if(r){if(!n){try{(0,m.chmodSync)(t,"777")}catch(a){(0,S.error)(`chmod ${t} failed: ${a.message}`)}const e=(0,m.readFileSync)(t).toString();(0,m.writeFileSync)(t,[e,e.includes("#!/")?"":"#!/bin/sh",j,"npx yolk pre-commit","RESULT=$?","[ $RESULT -ne 0 ] && exit 1","exit 0",j].join(p.default.EOL),S.ENCODING),(0,S.ready)("write pre-commit hook")}}else{(0,f.mkdirpSync)(o),(0,m.writeFileSync)(t,["#!/bin/sh",j,"npx yolk pre-commit","RESULT=$?","[ $RESULT -ne 0 ] && exit 1","exit 0",j].join(p.default.EOL),S.ENCODING),(0,S.ready)("create pre-commit hook");try{(0,m.chmodSync)(t,"777")}catch(a){(0,S.error)(`chmod ${t} failed: ${a.message}`)}(0,S.ready)("write pre-commit hook")}},D=async()=>{const e=(0,S.getYolkConfig)(),o=!1!==e.strict,t=e.eslintIgnore,i=e.stylelintIgnore;(0,S.warn)("\u7edf\u4e00\u4ee3\u7801\u89c4\u8303\uff0c\u8fdb\u884c\u4e25\u683c\u7684\u8bed\u6cd5\u68c0\u67e5\u3002"),o&&((0,S.warn)("git commit \u7981\u6b62 lint \u7684 ignore \u884c\u4e3a"),i&&(0,S.warn)(`\u901a\u8fc7 .yolkrc \u914d\u7f6e stylelintIgnore: ${i}\u3002`),t&&(0,S.warn)(`\u901a\u8fc7 .yolkrc \u914d\u7f6e eslintIgnore: ${t}\u3002`)),(0,S.execCommand)({command:"lint-staged",args:["-c",require.resolve("./.lintstagedrc")]})},E=({mAppid:e,mProject:o,mPrivateKeyPath:t,mVersion:i,mDesc:r,mRobot:n,mQrcodeFormat:a,mQrcodeOutputDest:c,mPagePath:p,mSearchQuery:l})=>{const u=(0,m.existsSync)((0,d.join)(x,".git"))?(0,s.execSync)("git log -1 --pretty=format:%H").toString():"",y=(0,S.getProjectConfigJSON)(),f=e||y.appid,h=o||(0,d.join)(x,"dist"),v=t||(0,d.join)(x,`private.${f}.key`);if((0,m.existsSync)(h)){if((0,m.existsSync)(v)){const e=(0,S.getPackageJSON)(),o=i||e.version||y.version||"1.0.0",t=r||e.description||y.description,s=`${u?` commit: ${u};`:""}${t?` description: ${t};`:""}`;u&&(0,S.info)(`commit: ${u}`),(0,S.info)(`dist: ${h}`),(0,S.info)(`key: ${v}`),(0,S.info)(`appid: ${f}`),(0,S.info)(`version: ${o}`),(0,S.info)(`desc: ${s}`);const m=new g.Project({appid:f,type:"miniProgram",projectPath:h,privateKeyPath:v,ignores:["node_modules/**/*","**/*.txt","**/*.key","**/*.less","**/*.sass","**/*.scss","**/*.css","**/*.jsx","**/*.ts","**/*.tsx","**/*.md"]});return{appid:f,options:{project:m,version:o,desc:s,setting:{...y.setting,es6:!1,es7:!1,minifyJS:!1,minifyWXML:!1,minifyWXSS:!1,minify:!1},robot:n,qrcodeFormat:a,qrcodeOutputDest:c,pagePath:p,searchQuery:l}}}throw Error(`\u6ca1\u6709\u627e\u5230\u4e0a\u4f20\u5bc6\u94a5(${v})`)}throw Error(`\u6ca1\u6709\u627e\u5230dist\u76ee\u5f55(${h})`)},I=()=>{let e="";try{e=(0,s.execSync)(`npm view ${b.default.name} version`,{timeout:3e3}).toString().replace(/\n/g,"")}catch(o){}(0,S.info)(`yolk version: ${b.default.version}${e&&e!==b.default.version?`(last\uff1a${e})`:""}`),(0,S.info)(`node version: ${process.version}`),(0,S.info)(`platform: ${p.default.platform()}`),(0,S.info)(`memory: ${(0,l.floor)(p.default.freemem()/1024/1024)} MB(${(0,l.floor)(p.default.totalmem()/1024/1024)} MB)`)},_=e=>e.option("--appid, --mAppid <appid>","\u5c0f\u7a0b\u5e8fappid").option("--project, --mProject <project>","\u5c0f\u7a0b\u5e8f\u4e0a\u4f20\u5de5\u7a0b\u76ee\u5f55").option("--privateKeyPath, --mPrivateKeyPath <privateKeyPath>","\u5c0f\u7a0b\u5e8f\u4e0a\u4f20key\u6587\u4ef6\uff0c\u9ed8\u8ba4\uff1a{\u5f53\u524d\u76ee\u5f55}/private.{appid}.key").option("--version, --mVersion <version>","\u5c0f\u7a0b\u5e8f\u4e0a\u4f20\u7248\u672c\u53f7").option("--desc, --mDesc <desc>","\u5c0f\u7a0b\u5e8f\u4e0a\u4f20\u63cf\u8ff0").option("--robot, --mRobot <robot>","\u5c0f\u7a0b\u5e8f\u4e0a\u4f20ci\u673a\u5668\u4eba1~30").option("--qrcodeFormat, --mQrcodeFormat <qrcodeFormat>",'\u5c0f\u7a0b\u5e8f\u9884\u89c8\u8fd4\u56de\u4e8c\u7ef4\u7801\u6587\u4ef6\u7684\u683c\u5f0f "image" \u6216 "base64"\uff0c \u9ed8\u8ba4\u503c "terminal" \u4f9b\u8c03\u8bd5\u7528').option("--qrcodeOutputDest, --mQrcodeOutputDest <qrcodeOutputDest>","\u5c0f\u7a0b\u5e8f\u9884\u89c8\u4e8c\u7ef4\u7801\u6587\u4ef6\u4fdd\u5b58\u8def\u5f84").option("--pagePath, --mPagePath <pagePath>","\u5c0f\u7a0b\u5e8f\u9884\u89c8\u9884\u89c8\u9875\u9762\u8def\u5f84").option("--searchQuery, --mSearchQuery <searchQuery>","\u5c0f\u7a0b\u5e8f\u9884\u89c8\u9884\u89c8\u9875\u9762\u8def\u5f84\u542f\u52a8\u53c2\u6570"),F=/(\w+)=('(.*)'|"(.*)"|(.*))/giu,Q=e=>{process.env.DID_YOU_KNOW="none",process.env.VITE_CJS_IGNORE_WARNING="true";const o=[];return null==e||e.forEach((e=>{if(F.test(e)){const[o,t]=e.split("=");process.env[o]=t,(0,S.info)(`\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf\uff1a${o}=${t}`)}else o.push(e)})),o},R=()=>{N(),process.argv.length>2?(h.program.version(b.default.version,"-v,--version","\u8f93\u51fa\u7248\u672c\u53f7").usage("[command] [options]"),h.program.command("init").description("\u521d\u59cb\u5316\u9879\u76ee").option("--clone <template>","\u5982\u679c\u9700\u8981\uff0c\u53ef\u901a\u8fc7git clone\u62c9\u53d6\u6a21\u7248\uff0c\u9ed8\u8ba4\u53d6cli\u9ed8\u8ba4\u6a21\u7248").action((({clone:e},{args:o})=>{if(I(),(0,S.ready)("yolk init \u5f00\u59cb"),e){const t=".yolk",i=(0,d.join)(x,t);(0,m.existsSync)(i)&&(0,S.rimrafSync)(i)&&(0,S.ready)(`\u7f13\u5b58\u5220\u9664 success! ${i}`),(0,S.execCommand)({command:"git",args:["clone","-b","master","--depth","1",e,t].concat(o)}),k(x,i)}else $(x)})),h.program.command("start").description("\u542f\u52a8\u9879\u76ee").option("--docs","\u6587\u6863\u6a21\u5f0f").action((({docs:e},{args:o})=>{I();const t=Q(o);w()?C()?(0,S.execCommand)({command:"taro",args:["build","--type","tt","--watch"].concat(t)}):q()?(0,S.execCommand)({command:"taro",args:["build","--type","alipay","--watch"].concat(t)}):(0,S.execCommand)({command:"taro",args:["build","--type","weapp","--watch"].concat(t)}):e?(0,S.execCommand)({command:"dumi",args:["dev"].concat(t)}):O()?(0,S.execCommand)({command:"max",args:["dev"].concat(t)}):(0,S.execCommand)({command:"umi",args:["dev"].concat(t)})})),h.program.command("build").description("\u7f16\u8bd1\u9879\u76ee").option("--docs","\u6587\u6863\u6a21\u5f0f").action((({docs:e},{args:o})=>{I();const t=Q(o);w()?C()?(0,S.execCommand)({command:"taro",args:["build","--type","tt"].concat(t)}):q()?(0,S.execCommand)({command:"taro",args:["build","--type","alipay"].concat(t)}):(0,S.execCommand)({command:"taro",args:["build","--type","weapp"].concat(t)}):e?(0,S.execCommand)({command:"dumi",args:["build"].concat(t)}):O()?(0,S.execCommand)({command:"max",args:["setup"].concat(t),complete:()=>(0,S.execCommand)({command:"max",args:["build"].concat(t)}),exit:!1}):(0,S.execCommand)({command:"umi",args:["build"].concat(t)})})),h.program.command("pre-commit").description("\u6267\u884ccommit hook").action(D),_(h.program.command("miniprogram-upload").description("\u4f7f\u7528 miniprogram-ci \u4e0a\u4f20\u5c0f\u7a0b\u5e8f")).action((e=>{if(w())if(C());else if(q());else{const{appid:o,options:{project:t,version:i,desc:r,setting:n,robot:a}}=E(e);(0,S.info)(`${o} \u4e0a\u4f20\u5f00\u59cb`),g.upload({project:t,version:i,desc:r,setting:n,robot:a,onProgressUpdate:e=>{if((0,l.isString)(e))(0,S.info)(`task: ${e}`);else{const{status:o,message:t}=e;(0,S.info)(`task(${o}): ${t}`)}}}).then((()=>{(0,S.ready)(`${o} \u4e0a\u4f20\u5b8c\u6210`)}))}else(0,S.error)("\u975e\u5c0f\u7a0b\u5e8f\u9879\u76ee\u76ee\u5f55")})),_(h.program.command("miniprogram-preview").description("\u4f7f\u7528 miniprogram-ci \u9884\u89c8\u5c0f\u7a0b\u5e8f")).action((e=>{if(w())if(C());else if(q());else{const{appid:o,options:{project:t,version:i,desc:r,setting:n,robot:a,qrcodeFormat:c,qrcodeOutputDest:s,pagePath:m,searchQuery:p}}=E(e);(0,S.info)(`${o} \u4e0a\u4f20\u9884\u89c8\u5f00\u59cb`),g.preview({project:t,version:i,desc:r,setting:n,robot:a,qrcodeFormat:c,qrcodeOutputDest:s,pagePath:m,searchQuery:p,onProgressUpdate:e=>{if((0,l.isString)(e))(0,S.info)(`task: ${e}`);else{const{status:o,message:t}=e;(0,S.info)(`task(${o}): ${t}`)}}}).then((()=>{(0,S.ready)(`${o} \u4e0a\u4f20\u9884\u89c8\u5b8c\u6210`)}))}else(0,S.error)("\u975e\u5c0f\u7a0b\u5e8f\u9879\u76ee\u76ee\u5f55")})),h.program.parse(process.argv)):(0,S.breakExit)()};R();
|
|
2
|
+
var e=Object.create,o=Object.defineProperty,t=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,r=Object.getPrototypeOf,n=Object.prototype.hasOwnProperty,a=(e,r,a,c)=>{if(r&&"object"===typeof r||"function"===typeof r)for(let s of i(r))n.call(e,s)||s===a||o(e,s,{get:()=>r[s],enumerable:!(c=t(r,s))||c.enumerable});return e},c=(t,i,n)=>(n=null!=t?e(r(t)):{},a(!i&&t&&t.__esModule?n:o(n,"default",{value:t,enumerable:!0}),t)),s=require("node:child_process"),m=require("node:fs"),p=c(require("node:os")),d=require("node:path"),l=require("lodash"),u=require("glob"),y=c(require("inquirer")),g=c(require("miniprogram-ci")),f=require("mkdirp"),h=require("../compiled/commander"),v=c(require("../compiled/mustache")),b=c(require("../package.json")),S=require("./_util"),x=process.cwd(),j="##### CREATED BY YOLK #####",$=(e,o,t)=>{y.default.prompt([{type:"list",name:"type",message:"\u9009\u62e9\u6a21\u7248",default:"web",choices:[{name:"web template(umi framework)",value:"umi-web"},{name:"web big screen template(umi framework)",value:"umi-web-screen"},{name:"mobile template(umi framework)",value:"umi-mobile"},{name:"mobile HBuilderX h5+app template(umi framework)",value:"umi-mobile-h5+app"},{name:"mobile HBuilderX uni-app template(umi framework)",value:"umi-mobile-uni-app"},{name:"mobile native template(umi framework)",value:"umi-mobile-native"},{name:"miniprogram template",value:"miniprogram"}]},{type:"input",name:"projectName",message:"\u9879\u76ee\u540d\u79f0",default:(0,d.basename)((0,d.basename)(process.cwd()))},{type:"list",name:"dependenciesInstallType",message:"\u9009\u62e9\u4f9d\u8d56\u5b89\u88c5\u65b9\u5f0f(\u9ed8\u8ba4\uff1apnpm\uff0c\u63a8\u8350\uff1apnpm)",default:"default",choices:[{name:"\u9ed8\u8ba4\u5b89\u88c5",value:"default"},{name:"\u8df3\u8fc7\u5b89\u88c5",value:!1},{name:"pnpm install",value:"pnpm"},{name:"yarn install",value:"yarn"},{name:"npm install",value:"npm"}]}]).then((({type:i,projectName:r,dependenciesInstallType:n})=>{const a={projectName:r,dependenciesInstallType:"default"===n?"pnpm":n,yolkVersion:b.default.version};if("umi-mobile-uni-app"===i)return void(0,S.warn)("\u6682\u4e0d\u652f\u6301");const c=o||(0,d.join)(__dirname,`../templates/${i}`);(0,S.ready)(`\u590d\u5236\u6a21\u7248 ${(0,d.basename)(c)}`);const s=(0,u.globSync)("**/*",{cwd:c,dot:!0,ignore:["**/node_modules/**","**/.git/**","**/.DS_Store","**/.idea/**"]});if(s.forEach((o=>{if(!c)return;const t=(0,d.join)(c,o);if(!(0,m.statSync)(t).isDirectory())if(o.endsWith(".tpl")){const i=(0,m.readFileSync)(t,S.ENCODING),r=(0,d.join)(e,o.replace(/\.tpl$/,"")),n=v.default.render(i,a);(0,f.mkdirpSync)((0,d.dirname)(r)),(0,S.ready)(`\u521b\u5efa ${(0,d.relative)(e,r)}`),(0,m.writeFileSync)(r,n,S.ENCODING)}else{(0,S.ready)(`\u521b\u5efa ${o}`);const i=(0,d.join)(e,o);(0,f.mkdirpSync)((0,d.dirname)(i)),(0,m.copyFileSync)(t,i)}})),(0,S.ready)("\u590d\u5236\u6a21\u7248 success!"),t&&(0,m.existsSync)(c)&&(0,S.rimrafSync)(c)&&(0,S.ready)(`\u7f13\u5b58\u5220\u9664 success! ${(0,d.basename)(c||"")}`),n)switch((0,S.ready)("\u521d\u59cb\u5316\u4f9d\u8d56\u5305"),n){case"default":case"pnpm":(0,S.execCommand)({command:"pnpm",args:["install"]});break;case"yarn":(0,S.execCommand)({command:"yarn",args:["install"]});break;case"npm":(0,S.execCommand)({command:"npm",args:["install"]});break;default:}(0,S.ready)("\u53ef\u67e5\u9605<<https://303394539.github.io/yolk-docs/>>\u4e86\u89e3\u76f8\u5173\u6587\u6863")}))},k=(e,o)=>$(e,o,!0),w=()=>(0,m.existsSync)((0,d.join)(x,"project.config.json")),O=()=>{let e=(0,m.existsSync)((0,d.join)(x,"node_modules/.bin/max"));if(!e)try{e=(0,m.existsSync)(require.resolve("@umijs/max"))}catch(o){}if(!e)try{e=/umi@4\.(\d+)\.(\d+)/.test((0,s.execSync)("umi -v").toString())}catch(o){}if(!e){const t=(0,d.join)(x,"node_modules","umi","package.json");if((0,m.existsSync)(t))try{const o=JSON.parse((0,m.readFileSync)(t,S.ENCODING))||{};e=o.version&&+o.version.split(".")[0]>3}catch(o){}}return e},P=()=>{const e=(0,d.join)(x,"project.config.json");if((0,m.existsSync)(e)){const o=require(e);return o.appid}return""},C=()=>(0,m.existsSync)((0,d.join)(x,"project.tt.json"))&&0===P().indexOf("tt"),q=()=>0===P().indexOf("20"),N=()=>{const e=(0,d.join)(x,".git/"),o=(0,d.join)(x,".git/hooks"),t=(0,d.join)(o,"pre-commit"),i=(0,m.existsSync)(e),r=(0,m.existsSync)(t),n=r&&(0,m.readFileSync)(t,S.ENCODING).includes(j);if(i)if(r){if(!n){try{(0,m.chmodSync)(t,"777")}catch(a){(0,S.error)(`chmod ${t} failed: ${a.message}`)}const e=(0,m.readFileSync)(t).toString();(0,m.writeFileSync)(t,[e,e.includes("#!/")?"":"#!/bin/sh",j,"npx yolk pre-commit","RESULT=$?","[ $RESULT -ne 0 ] && exit 1","exit 0",j].join(p.default.EOL),S.ENCODING),(0,S.ready)("write pre-commit hook")}}else{(0,f.mkdirpSync)(o),(0,m.writeFileSync)(t,["#!/bin/sh",j,"npx yolk pre-commit","RESULT=$?","[ $RESULT -ne 0 ] && exit 1","exit 0",j].join(p.default.EOL),S.ENCODING),(0,S.ready)("create pre-commit hook");try{(0,m.chmodSync)(t,"777")}catch(a){(0,S.error)(`chmod ${t} failed: ${a.message}`)}(0,S.ready)("write pre-commit hook")}},D=async()=>{const e=(0,S.getYolkConfig)(),o=!1!==e.strict,t=e.eslintIgnore,i=e.stylelintIgnore;(0,S.warn)("\u7edf\u4e00\u4ee3\u7801\u89c4\u8303\uff0c\u8fdb\u884c\u4e25\u683c\u7684\u8bed\u6cd5\u68c0\u67e5\u3002"),o&&((0,S.warn)("git commit \u7981\u6b62 lint \u7684 ignore \u884c\u4e3a"),i&&(0,S.warn)(`\u901a\u8fc7 .yolkrc \u914d\u7f6e stylelintIgnore: ${i}\u3002`),t&&(0,S.warn)(`\u901a\u8fc7 .yolkrc \u914d\u7f6e eslintIgnore: ${t}\u3002`)),(0,S.execCommand)({command:"lint-staged",args:["-c",require.resolve("./.lintstagedrc")]})},E=({mAppid:e,mProject:o,mPrivateKeyPath:t,mVersion:i,mDesc:r,mRobot:n,mQrcodeFormat:a,mQrcodeOutputDest:c,mPagePath:p,mSearchQuery:l})=>{const u=(0,m.existsSync)((0,d.join)(x,".git"))?(0,s.execSync)("git log -1 --pretty=format:%H").toString():"",y=(0,S.getProjectConfigJSON)(),f=e||y.appid,h=o||(0,d.join)(x,"dist"),v=t||(0,d.join)(x,`private.${f}.key`);if((0,m.existsSync)(h)){if((0,m.existsSync)(v)){const e=(0,S.getPackageJSON)(),o=i||e.version||y.version||"1.0.0",t=r||e.description||y.description,s=`${u?` commit: ${u};`:""}${t?` description: ${t};`:""}`;u&&(0,S.info)(`commit: ${u}`),(0,S.info)(`dist: ${h}`),(0,S.info)(`key: ${v}`),(0,S.info)(`appid: ${f}`),(0,S.info)(`version: ${o}`),(0,S.info)(`desc: ${s}`);const m=new g.Project({appid:f,type:"miniProgram",projectPath:h,privateKeyPath:v,ignores:["node_modules/**/*","**/*.txt","**/*.key","**/*.less","**/*.sass","**/*.scss","**/*.css","**/*.jsx","**/*.ts","**/*.tsx","**/*.md"]});return{appid:f,options:{project:m,version:o,desc:s,setting:{...y.setting,es6:!1,es7:!1,minifyJS:!1,minifyWXML:!1,minifyWXSS:!1,minify:!1},robot:n,qrcodeFormat:a,qrcodeOutputDest:c,pagePath:p,searchQuery:l}}}throw Error(`\u6ca1\u6709\u627e\u5230\u4e0a\u4f20\u5bc6\u94a5(${v})`)}throw Error(`\u6ca1\u6709\u627e\u5230dist\u76ee\u5f55(${h})`)},I=()=>{let e="";try{e=(0,s.execSync)(`npm view ${b.default.name} version`,{timeout:3e3}).toString().replace(/\n/g,"")}catch(o){}(0,S.info)(`yolk version: ${b.default.version}${e&&e!==b.default.version?`(last\uff1a${e})`:""}`),(0,S.info)(`node version: ${process.version}`),(0,S.info)(`platform: ${p.default.platform()}`),(0,S.info)(`memory: ${(0,l.floor)(p.default.freemem()/1024/1024)} MB(${(0,l.floor)(p.default.totalmem()/1024/1024)} MB)`)},_=e=>e.option("--appid, --mAppid <appid>","\u5c0f\u7a0b\u5e8fappid").option("--project, --mProject <project>","\u5c0f\u7a0b\u5e8f\u4e0a\u4f20\u5de5\u7a0b\u76ee\u5f55").option("--privateKeyPath, --mPrivateKeyPath <privateKeyPath>","\u5c0f\u7a0b\u5e8f\u4e0a\u4f20key\u6587\u4ef6\uff0c\u9ed8\u8ba4\uff1a{\u5f53\u524d\u76ee\u5f55}/private.{appid}.key").option("--version, --mVersion <version>","\u5c0f\u7a0b\u5e8f\u4e0a\u4f20\u7248\u672c\u53f7").option("--desc, --mDesc <desc>","\u5c0f\u7a0b\u5e8f\u4e0a\u4f20\u63cf\u8ff0").option("--robot, --mRobot <robot>","\u5c0f\u7a0b\u5e8f\u4e0a\u4f20ci\u673a\u5668\u4eba1~30").option("--qrcodeFormat, --mQrcodeFormat <qrcodeFormat>",'\u5c0f\u7a0b\u5e8f\u9884\u89c8\u8fd4\u56de\u4e8c\u7ef4\u7801\u6587\u4ef6\u7684\u683c\u5f0f "image" \u6216 "base64"\uff0c \u9ed8\u8ba4\u503c "terminal" \u4f9b\u8c03\u8bd5\u7528').option("--qrcodeOutputDest, --mQrcodeOutputDest <qrcodeOutputDest>","\u5c0f\u7a0b\u5e8f\u9884\u89c8\u4e8c\u7ef4\u7801\u6587\u4ef6\u4fdd\u5b58\u8def\u5f84").option("--pagePath, --mPagePath <pagePath>","\u5c0f\u7a0b\u5e8f\u9884\u89c8\u9884\u89c8\u9875\u9762\u8def\u5f84").option("--searchQuery, --mSearchQuery <searchQuery>","\u5c0f\u7a0b\u5e8f\u9884\u89c8\u9884\u89c8\u9875\u9762\u8def\u5f84\u542f\u52a8\u53c2\u6570"),F=/(\w+)=('(.*)'|"(.*)"|(.*))/giu,Q=e=>{process.env.DID_YOU_KNOW="none",process.env.VITE_CJS_IGNORE_WARNING="true";const o=[];return null==e||e.forEach((e=>{if(F.test(e)){const[o,t]=e.split("=");process.env[o]=t,(0,S.info)(`\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf\uff1a${o}=${t}`)}else o.push(e)})),o},R=()=>{N(),process.argv.length>2?(h.program.version(b.default.version,"-v,--version","\u8f93\u51fa\u7248\u672c\u53f7").usage("[command] [options]"),h.program.command("init").description("\u521d\u59cb\u5316\u9879\u76ee").option("--clone <template>","\u5982\u679c\u9700\u8981\uff0c\u53ef\u901a\u8fc7git clone\u62c9\u53d6\u6a21\u7248\uff0c\u9ed8\u8ba4\u53d6cli\u9ed8\u8ba4\u6a21\u7248").action((({clone:e},{args:o})=>{if(I(),(0,S.ready)("yolk init \u5f00\u59cb"),e){const t=".yolk",i=(0,d.join)(x,t);(0,m.existsSync)(i)&&(0,S.rimrafSync)(i)&&(0,S.ready)(`\u7f13\u5b58\u5220\u9664 success! ${i}`),(0,S.execCommand)({command:"git",args:["clone","-b","master","--depth","1",e,t].concat(o)}),k(x,i)}else $(x)})),h.program.command("start").description("\u542f\u52a8\u9879\u76ee").option("--docs","\u6587\u6863\u6a21\u5f0f").action((({docs:e},{args:o})=>{I();const t=Q(o);w()?C()?(0,S.execCommand)({command:"taro",args:["build","--type","tt","--watch"].concat(t)}):q()?(0,S.execCommand)({command:"taro",args:["build","--type","alipay","--watch"].concat(t)}):(0,S.execCommand)({command:"taro",args:["build","--type","weapp","--watch"].concat(t)}):e?(0,S.execCommand)({command:"dumi",args:["dev"].concat(t)}):O()?(0,S.execCommand)({command:"max",args:["dev"].concat(t)}):(0,S.execCommand)({command:"umi",args:["dev"].concat(t)})})),h.program.command("build").description("\u7f16\u8bd1\u9879\u76ee").option("--docs","\u6587\u6863\u6a21\u5f0f").action((({docs:e},{args:o})=>{I();const t=Q(o);w()?C()?(0,S.execCommand)({command:"taro",args:["build","--type","tt"].concat(t)}):q()?(0,S.execCommand)({command:"taro",args:["build","--type","alipay"].concat(t)}):(0,S.execCommand)({command:"taro",args:["build","--type","weapp"].concat(t)}):e?(0,S.execCommand)({command:"dumi",args:["build"].concat(t)}):O()?(0,S.execCommand)({command:"max",args:["setup"].concat(t),complete:()=>(0,S.execCommand)({command:"max",args:["build"].concat(t)}),exit:!1}):(0,S.execCommand)({command:"umi",args:["build"].concat(t)})})),h.program.command("pre-commit").description("\u6267\u884ccommit hook").action(D),_(h.program.command("miniprogram-upload").description("\u4f7f\u7528 miniprogram-ci \u4e0a\u4f20\u5c0f\u7a0b\u5e8f")).action((e=>{if(w())if(C());else if(q());else{const{appid:o,options:{project:t,version:i,desc:r,setting:n,robot:a}}=E(e);(0,S.info)(`${o} \u4e0a\u4f20\u5f00\u59cb`),g.upload({project:t,version:i,desc:r,setting:n,robot:a,onProgressUpdate:e=>{if((0,l.isString)(e))(0,S.info)(`task: ${e}`);else{const{status:o,message:t}=e;(0,S.info)(`task(${o}): ${t}`)}}}).then((()=>{(0,S.ready)(`${o} \u4e0a\u4f20\u5b8c\u6210`)}))}else(0,S.error)("\u975e\u5c0f\u7a0b\u5e8f\u9879\u76ee\u76ee\u5f55")})),_(h.program.command("miniprogram-preview").description("\u4f7f\u7528 miniprogram-ci \u9884\u89c8\u5c0f\u7a0b\u5e8f")).action((e=>{if(w())if(C());else if(q());else{const{appid:o,options:{project:t,version:i,desc:r,setting:n,robot:a,qrcodeFormat:c,qrcodeOutputDest:s,pagePath:m,searchQuery:p}}=E(e);(0,S.info)(`${o} \u4e0a\u4f20\u9884\u89c8\u5f00\u59cb`),g.preview({project:t,version:i,desc:r,setting:n,robot:a,qrcodeFormat:c,qrcodeOutputDest:s,pagePath:m,searchQuery:p,onProgressUpdate:e=>{if((0,l.isString)(e))(0,S.info)(`task: ${e}`);else{const{status:o,message:t}=e;(0,S.info)(`task(${o}): ${t}`)}}}).then((()=>{(0,S.ready)(`${o} \u4e0a\u4f20\u9884\u89c8\u5b8c\u6210`)}))}else(0,S.error)("\u975e\u5c0f\u7a0b\u5e8f\u9879\u76ee\u76ee\u5f55")})),h.program.parse(process.argv)):(0,S.breakExit)()};R();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@baic/yolk-cli",
|
|
3
|
-
"version": "2.1.0-alpha.
|
|
3
|
+
"version": "2.1.0-alpha.229",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/303394539/yolk.git"
|
|
@@ -25,14 +25,14 @@
|
|
|
25
25
|
"prebundle": "father prebundle"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@baic/yolk-prebundle": "^2.1.0-alpha.
|
|
28
|
+
"@baic/yolk-prebundle": "^2.1.0-alpha.229",
|
|
29
29
|
"@democrance/imagemin-lint-staged": "2.x",
|
|
30
30
|
"@types/inquirer": "8.x",
|
|
31
31
|
"@types/lint-staged": "~13.3.x",
|
|
32
32
|
"@types/lodash": "~4.x",
|
|
33
33
|
"chalk": "4.x",
|
|
34
34
|
"eslint": "8.x",
|
|
35
|
-
"glob": "
|
|
35
|
+
"glob": "10.4.x",
|
|
36
36
|
"inquirer": "8.x",
|
|
37
37
|
"licia": "~1.41.x",
|
|
38
38
|
"lint-staged": "~15.2.x",
|
|
@@ -49,7 +49,6 @@
|
|
|
49
49
|
"@types/mustache": "~4.2.x",
|
|
50
50
|
"commander": "~12.1.x",
|
|
51
51
|
"mustache": "~4.2.x",
|
|
52
|
-
"rimraf": "~5.0.x",
|
|
53
52
|
"v8-compile-cache": "~2.4.x"
|
|
54
53
|
},
|
|
55
54
|
"engines": {
|
|
@@ -58,5 +57,5 @@
|
|
|
58
57
|
"publishConfig": {
|
|
59
58
|
"access": "public"
|
|
60
59
|
},
|
|
61
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "2bd0bddfbd03ee6a0761ddea0fb9a62e0dddb1a3"
|
|
62
61
|
}
|