@tobelabs/chainwright 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +3 -0
- package/dist/cli/index.d.ts +4 -0
- package/dist/cli/index.js +36 -0
- package/dist/core/index.d.ts +26 -0
- package/dist/core/index.js +1 -0
- package/dist/types-dJRYhQT9.d.ts +22 -0
- package/dist/wallets/index.d.ts +975 -0
- package/dist/wallets/index.js +16 -0
- package/package.json +88 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 amaify
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
var rn=Object.create;var Ye=Object.defineProperty;var on=Object.getOwnPropertyDescriptor;var sn=Object.getOwnPropertyNames;var an=Object.getPrototypeOf,ln=Object.prototype.hasOwnProperty;var M=(o=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(o,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):o)(function(o){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+o+'" is not supported')});var T=(o,e)=>()=>(e||o((e={exports:{}}).exports,e),e.exports);var cn=(o,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of sn(e))!ln.call(o,r)&&r!==t&&Ye(o,r,{get:()=>e[r],enumerable:!(n=on(e,r))||n.enumerable});return o};var Je=(o,e,t)=>(t=o!=null?rn(an(o)):{},cn(e||!o||!o.__esModule?Ye(t,"default",{value:o,enumerable:!0}):t,o));var Q=T(Se=>{"use strict";var le=class extends Error{constructor(e,t,n){super(n),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}},Oe=class extends le{constructor(e){super(1,"commander.invalidArgument",e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};Se.CommanderError=le;Se.InvalidArgumentError=Oe});var ce=T(xe=>{"use strict";var{InvalidArgumentError:un}=Q(),we=class{constructor(e,t){switch(this.description=t||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case"<":this.required=!0,this._name=e.slice(1,-1);break;case"[":this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e;break}this._name.endsWith("...")&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(t,n)=>{if(!this.argChoices.includes(t))throw new un(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._collectValue(t,n):t},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function fn(o){let e=o.name()+(o.variadic===!0?"...":"");return o.required?"<"+e+">":"["+e+"]"}xe.Argument=we;xe.humanReadableArgName=fn});var Le=T(Ie=>{"use strict";var{humanReadableArgName:hn}=ce(),Ae=class{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(e){this.helpWidth=this.helpWidth??e.helpWidth??80}visibleCommands(e){let t=e.commands.filter(r=>!r._hidden),n=e._getHelpCommand();return n&&!n._hidden&&t.push(n),this.sortSubcommands&&t.sort((r,i)=>r.name().localeCompare(i.name())),t}compareOptions(e,t){let n=r=>r.short?r.short.replace(/^-/,""):r.long.replace(/^--/,"");return n(e).localeCompare(n(t))}visibleOptions(e){let t=e.options.filter(r=>!r.hidden),n=e._getHelpOption();if(n&&!n.hidden){let r=n.short&&e._findOption(n.short),i=n.long&&e._findOption(n.long);!r&&!i?t.push(n):n.long&&!i?t.push(e.createOption(n.long,n.description)):n.short&&!r&&t.push(e.createOption(n.short,n.description))}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let n=e.parent;n;n=n.parent){let r=n.options.filter(i=>!i.hidden);t.push(...r)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach(t=>{t.description=t.description||e._argsDescription[t.name()]||""}),e.registeredArguments.find(t=>t.description)?e.registeredArguments:[]}subcommandTerm(e){let t=e.registeredArguments.map(n=>hn(n)).join(" ");return e._name+(e._aliases[0]?"|"+e._aliases[0]:"")+(e.options.length?" [options]":"")+(t?" "+t:"")}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce((n,r)=>Math.max(n,this.displayWidth(t.styleSubcommandTerm(t.subcommandTerm(r)))),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((n,r)=>Math.max(n,this.displayWidth(t.styleOptionTerm(t.optionTerm(r)))),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((n,r)=>Math.max(n,this.displayWidth(t.styleOptionTerm(t.optionTerm(r)))),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((n,r)=>Math.max(n,this.displayWidth(t.styleArgumentTerm(t.argumentTerm(r)))),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+"|"+e._aliases[0]);let n="";for(let r=e.parent;r;r=r.parent)n=r.name()+" "+n;return n+t+" "+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(n=>JSON.stringify(n)).join(", ")}`),e.defaultValue!==void 0&&(e.required||e.optional||e.isBoolean()&&typeof e.defaultValue=="boolean")&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),e.presetArg!==void 0&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),e.envVar!==void 0&&t.push(`env: ${e.envVar}`),t.length>0){let n=`(${t.join(", ")})`;return e.description?`${e.description} ${n}`:n}return e.description}argumentDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(n=>JSON.stringify(n)).join(", ")}`),e.defaultValue!==void 0&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){let n=`(${t.join(", ")})`;return e.description?`${e.description} ${n}`:n}return e.description}formatItemList(e,t,n){return t.length===0?[]:[n.styleTitle(e),...t,""]}groupItems(e,t,n){let r=new Map;return e.forEach(i=>{let a=n(i);r.has(a)||r.set(a,[])}),t.forEach(i=>{let a=n(i);r.has(a)||r.set(a,[]),r.get(a).push(i)}),r}formatHelp(e,t){let n=t.padWidth(e,t),r=t.helpWidth??80;function i(E,S){return t.formatItem(E,n,S,t)}let a=[`${t.styleTitle("Usage:")} ${t.styleUsage(t.commandUsage(e))}`,""],c=t.commandDescription(e);c.length>0&&(a=a.concat([t.boxWrap(t.styleCommandDescription(c),r),""]));let d=t.visibleArguments(e).map(E=>i(t.styleArgumentTerm(t.argumentTerm(E)),t.styleArgumentDescription(t.argumentDescription(E))));if(a=a.concat(this.formatItemList("Arguments:",d,t)),this.groupItems(e.options,t.visibleOptions(e),E=>E.helpGroupHeading??"Options:").forEach((E,S)=>{let l=E.map(u=>i(t.styleOptionTerm(t.optionTerm(u)),t.styleOptionDescription(t.optionDescription(u))));a=a.concat(this.formatItemList(S,l,t))}),t.showGlobalOptions){let E=t.visibleGlobalOptions(e).map(S=>i(t.styleOptionTerm(t.optionTerm(S)),t.styleOptionDescription(t.optionDescription(S))));a=a.concat(this.formatItemList("Global Options:",E,t))}return this.groupItems(e.commands,t.visibleCommands(e),E=>E.helpGroup()||"Commands:").forEach((E,S)=>{let l=E.map(u=>i(t.styleSubcommandTerm(t.subcommandTerm(u)),t.styleSubcommandDescription(t.subcommandDescription(u))));a=a.concat(this.formatItemList(S,l,t))}),a.join(`
|
|
3
|
+
`)}displayWidth(e){return Qe(e).length}styleTitle(e){return e}styleUsage(e){return e.split(" ").map(t=>t==="[options]"?this.styleOptionText(t):t==="[command]"?this.styleSubcommandText(t):t[0]==="["||t[0]==="<"?this.styleArgumentText(t):this.styleCommandText(t)).join(" ")}styleCommandDescription(e){return this.styleDescriptionText(e)}styleOptionDescription(e){return this.styleDescriptionText(e)}styleSubcommandDescription(e){return this.styleDescriptionText(e)}styleArgumentDescription(e){return this.styleDescriptionText(e)}styleDescriptionText(e){return e}styleOptionTerm(e){return this.styleOptionText(e)}styleSubcommandTerm(e){return e.split(" ").map(t=>t==="[options]"?this.styleOptionText(t):t[0]==="["||t[0]==="<"?this.styleArgumentText(t):this.styleSubcommandText(t)).join(" ")}styleArgumentTerm(e){return this.styleArgumentText(e)}styleOptionText(e){return e}styleArgumentText(e){return e}styleSubcommandText(e){return e}styleCommandText(e){return e}padWidth(e,t){return Math.max(t.longestOptionTermLength(e,t),t.longestGlobalOptionTermLength(e,t),t.longestSubcommandTermLength(e,t),t.longestArgumentTermLength(e,t))}preformatted(e){return/\n[^\S\r\n]/.test(e)}formatItem(e,t,n,r){let a=" ".repeat(2);if(!n)return a+e;let c=e.padEnd(t+e.length-r.displayWidth(e)),d=2,C=(this.helpWidth??80)-t-d-2,E;return C<this.minWidthToWrap||r.preformatted(n)?E=n:E=r.boxWrap(n,C).replace(/\n/g,`
|
|
4
|
+
`+" ".repeat(t+d)),a+c+" ".repeat(d)+E.replace(/\n/g,`
|
|
5
|
+
${a}`)}boxWrap(e,t){if(t<this.minWidthToWrap)return e;let n=e.split(/\r\n|\n/),r=/[\s]*[^\s]+/g,i=[];return n.forEach(a=>{let c=a.match(r);if(c===null){i.push("");return}let d=[c.shift()],g=this.displayWidth(d[0]);c.forEach(C=>{let E=this.displayWidth(C);if(g+E<=t){d.push(C),g+=E;return}i.push(d.join(""));let S=C.trimStart();d=[S],g=this.displayWidth(S)}),i.push(d.join(""))}),i.join(`
|
|
6
|
+
`)}};function Qe(o){let e=/\x1b\[\d*(;\d*)*m/g;return o.replace(e,"")}Ie.Help=Ae;Ie.stripColor=Qe});var ve=T(Te=>{"use strict";var{InvalidArgumentError:dn}=Q(),De=class{constructor(e,t){this.flags=e,this.description=t||"",this.required=e.includes("<"),this.optional=e.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(e),this.mandatory=!1;let n=mn(e);this.short=n.shortFlag,this.long=n.longFlag,this.negate=!1,this.long&&(this.negate=this.long.startsWith("--no-")),this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0,this.helpGroupHeading=void 0}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}preset(e){return this.presetArg=e,this}conflicts(e){return this.conflictsWith=this.conflictsWith.concat(e),this}implies(e){let t=e;return typeof e=="string"&&(t={[e]:!0}),this.implied=Object.assign(this.implied||{},t),this}env(e){return this.envVar=e,this}argParser(e){return this.parseArg=e,this}makeOptionMandatory(e=!0){return this.mandatory=!!e,this}hideHelp(e=!0){return this.hidden=!!e,this}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}choices(e){return this.argChoices=e.slice(),this.parseArg=(t,n)=>{if(!this.argChoices.includes(t))throw new dn(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._collectValue(t,n):t},this}name(){return this.long?this.long.replace(/^--/,""):this.short.replace(/^-/,"")}attributeName(){return this.negate?et(this.name().replace(/^no-/,"")):et(this.name())}helpGroup(e){return this.helpGroupHeading=e,this}is(e){return this.short===e||this.long===e}isBoolean(){return!this.required&&!this.optional&&!this.negate}},Ne=class{constructor(e){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,e.forEach(t=>{t.negate?this.negativeOptions.set(t.attributeName(),t):this.positiveOptions.set(t.attributeName(),t)}),this.negativeOptions.forEach((t,n)=>{this.positiveOptions.has(n)&&this.dualOptions.add(n)})}valueFromOption(e,t){let n=t.attributeName();if(!this.dualOptions.has(n))return!0;let r=this.negativeOptions.get(n).presetArg,i=r!==void 0?r:!1;return t.negate===(i===e)}};function et(o){return o.split("-").reduce((e,t)=>e+t[0].toUpperCase()+t.slice(1))}function mn(o){let e,t,n=/^-[^-]$/,r=/^--[^-]/,i=o.split(/[ |,]+/).concat("guard");if(n.test(i[0])&&(e=i.shift()),r.test(i[0])&&(t=i.shift()),!e&&n.test(i[0])&&(e=i.shift()),!e&&r.test(i[0])&&(e=t,t=i.shift()),i[0].startsWith("-")){let a=i[0],c=`option creation failed due to '${a}' in option flags '${o}'`;throw/^-[^-][^-]/.test(a)?new Error(`${c}
|
|
7
|
+
- a short flag is a single dash and a single character
|
|
8
|
+
- either use a single dash and a single character (for a short flag)
|
|
9
|
+
- or use a double dash for a long option (and can have two, like '--ws, --workspace')`):n.test(a)?new Error(`${c}
|
|
10
|
+
- too many short flags`):r.test(a)?new Error(`${c}
|
|
11
|
+
- too many long flags`):new Error(`${c}
|
|
12
|
+
- unrecognised flag format`)}if(e===void 0&&t===void 0)throw new Error(`option creation failed due to no flags found in '${o}'.`);return{shortFlag:e,longFlag:t}}Te.Option=De;Te.DualOptions=Ne});var nt=T(tt=>{"use strict";function pn(o,e){if(Math.abs(o.length-e.length)>3)return Math.max(o.length,e.length);let t=[];for(let n=0;n<=o.length;n++)t[n]=[n];for(let n=0;n<=e.length;n++)t[0][n]=n;for(let n=1;n<=e.length;n++)for(let r=1;r<=o.length;r++){let i=1;o[r-1]===e[n-1]?i=0:i=1,t[r][n]=Math.min(t[r-1][n]+1,t[r][n-1]+1,t[r-1][n-1]+i),r>1&&n>1&&o[r-1]===e[n-2]&&o[r-2]===e[n-1]&&(t[r][n]=Math.min(t[r][n],t[r-2][n-2]+1))}return t[o.length][e.length]}function gn(o,e){if(!e||e.length===0)return"";e=Array.from(new Set(e));let t=o.startsWith("--");t&&(o=o.slice(2),e=e.map(a=>a.slice(2)));let n=[],r=3,i=.4;return e.forEach(a=>{if(a.length<=1)return;let c=pn(o,a),d=Math.max(o.length,a.length);(d-c)/d>i&&(c<r?(r=c,n=[a]):c===r&&n.push(a))}),n.sort((a,c)=>a.localeCompare(c)),t&&(n=n.map(a=>`--${a}`)),n.length>1?`
|
|
13
|
+
(Did you mean one of ${n.join(", ")}?)`:n.length===1?`
|
|
14
|
+
(Did you mean ${n[0]}?)`:""}tt.suggestSimilar=gn});var st=T(Ue=>{"use strict";var En=M("events").EventEmitter,Fe=M("child_process"),G=M("path"),ue=M("fs"),A=M("process"),{Argument:_n,humanReadableArgName:Cn}=ce(),{CommanderError:be}=Q(),{Help:yn,stripColor:On}=Le(),{Option:rt,DualOptions:Sn}=ve(),{suggestSimilar:it}=nt(),Re=class o extends En{constructor(e){super(),this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!1,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=e||"",this._optionValues={},this._optionValueSources={},this._storeOptionsAsProperties=!1,this._actionHandler=null,this._executableHandler=!1,this._executableFile=null,this._executableDir=null,this._defaultCommandName=null,this._exitCallback=null,this._aliases=[],this._combineFlagAndOptionalValue=!0,this._description="",this._summary="",this._argsDescription=void 0,this._enablePositionalOptions=!1,this._passThroughOptions=!1,this._lifeCycleHooks={},this._showHelpAfterError=!1,this._showSuggestionAfterError=!0,this._savedState=null,this._outputConfiguration={writeOut:t=>A.stdout.write(t),writeErr:t=>A.stderr.write(t),outputError:(t,n)=>n(t),getOutHelpWidth:()=>A.stdout.isTTY?A.stdout.columns:void 0,getErrHelpWidth:()=>A.stderr.isTTY?A.stderr.columns:void 0,getOutHasColors:()=>He()??(A.stdout.isTTY&&A.stdout.hasColors?.()),getErrHasColors:()=>He()??(A.stderr.isTTY&&A.stderr.hasColors?.()),stripColor:t=>On(t)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={},this._helpGroupHeading=void 0,this._defaultCommandGroup=void 0,this._defaultOptionGroup=void 0}copyInheritedSettings(e){return this._outputConfiguration=e._outputConfiguration,this._helpOption=e._helpOption,this._helpCommand=e._helpCommand,this._helpConfiguration=e._helpConfiguration,this._exitCallback=e._exitCallback,this._storeOptionsAsProperties=e._storeOptionsAsProperties,this._combineFlagAndOptionalValue=e._combineFlagAndOptionalValue,this._allowExcessArguments=e._allowExcessArguments,this._enablePositionalOptions=e._enablePositionalOptions,this._showHelpAfterError=e._showHelpAfterError,this._showSuggestionAfterError=e._showSuggestionAfterError,this}_getCommandAndAncestors(){let e=[];for(let t=this;t;t=t.parent)e.push(t);return e}command(e,t,n){let r=t,i=n;typeof r=="object"&&r!==null&&(i=r,r=null),i=i||{};let[,a,c]=e.match(/([^ ]+) *(.*)/),d=this.createCommand(a);return r&&(d.description(r),d._executableHandler=!0),i.isDefault&&(this._defaultCommandName=d._name),d._hidden=!!(i.noHelp||i.hidden),d._executableFile=i.executableFile||null,c&&d.arguments(c),this._registerCommand(d),d.parent=this,d.copyInheritedSettings(this),r?this:d}createCommand(e){return new o(e)}createHelp(){return Object.assign(new yn,this.configureHelp())}configureHelp(e){return e===void 0?this._helpConfiguration:(this._helpConfiguration=e,this)}configureOutput(e){return e===void 0?this._outputConfiguration:(this._outputConfiguration={...this._outputConfiguration,...e},this)}showHelpAfterError(e=!0){return typeof e!="string"&&(e=!!e),this._showHelpAfterError=e,this}showSuggestionAfterError(e=!0){return this._showSuggestionAfterError=!!e,this}addCommand(e,t){if(!e._name)throw new Error(`Command passed to .addCommand() must have a name
|
|
15
|
+
- specify the name in Command constructor or using .name()`);return t=t||{},t.isDefault&&(this._defaultCommandName=e._name),(t.noHelp||t.hidden)&&(e._hidden=!0),this._registerCommand(e),e.parent=this,e._checkForBrokenPassThrough(),this}createArgument(e,t){return new _n(e,t)}argument(e,t,n,r){let i=this.createArgument(e,t);return typeof n=="function"?i.default(r).argParser(n):i.default(n),this.addArgument(i),this}arguments(e){return e.trim().split(/ +/).forEach(t=>{this.argument(t)}),this}addArgument(e){let t=this.registeredArguments.slice(-1)[0];if(t?.variadic)throw new Error(`only the last argument can be variadic '${t.name()}'`);if(e.required&&e.defaultValue!==void 0&&e.parseArg===void 0)throw new Error(`a default value for a required argument is never used: '${e.name()}'`);return this.registeredArguments.push(e),this}helpCommand(e,t){if(typeof e=="boolean")return this._addImplicitHelpCommand=e,e&&this._defaultCommandGroup&&this._initCommandGroup(this._getHelpCommand()),this;let n=e??"help [command]",[,r,i]=n.match(/([^ ]+) *(.*)/),a=t??"display help for command",c=this.createCommand(r);return c.helpOption(!1),i&&c.arguments(i),a&&c.description(a),this._addImplicitHelpCommand=!0,this._helpCommand=c,(e||t)&&this._initCommandGroup(c),this}addHelpCommand(e,t){return typeof e!="object"?(this.helpCommand(e,t),this):(this._addImplicitHelpCommand=!0,this._helpCommand=e,this._initCommandGroup(e),this)}_getHelpCommand(){return this._addImplicitHelpCommand??(this.commands.length&&!this._actionHandler&&!this._findCommand("help"))?(this._helpCommand===void 0&&this.helpCommand(void 0,void 0),this._helpCommand):null}hook(e,t){let n=["preSubcommand","preAction","postAction"];if(!n.includes(e))throw new Error(`Unexpected value for event passed to hook : '${e}'.
|
|
16
|
+
Expecting one of '${n.join("', '")}'`);return this._lifeCycleHooks[e]?this._lifeCycleHooks[e].push(t):this._lifeCycleHooks[e]=[t],this}exitOverride(e){return e?this._exitCallback=e:this._exitCallback=t=>{if(t.code!=="commander.executeSubCommandAsync")throw t},this}_exit(e,t,n){this._exitCallback&&this._exitCallback(new be(e,t,n)),A.exit(e)}action(e){let t=n=>{let r=this.registeredArguments.length,i=n.slice(0,r);return this._storeOptionsAsProperties?i[r]=this:i[r]=this.opts(),i.push(this),e.apply(this,i)};return this._actionHandler=t,this}createOption(e,t){return new rt(e,t)}_callParseArg(e,t,n,r){try{return e.parseArg(t,n)}catch(i){if(i.code==="commander.invalidArgument"){let a=`${r} ${i.message}`;this.error(a,{exitCode:i.exitCode,code:i.code})}throw i}}_registerOption(e){let t=e.short&&this._findOption(e.short)||e.long&&this._findOption(e.long);if(t){let n=e.long&&this._findOption(e.long)?e.long:e.short;throw new Error(`Cannot add option '${e.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${n}'
|
|
17
|
+
- already used by option '${t.flags}'`)}this._initOptionGroup(e),this.options.push(e)}_registerCommand(e){let t=r=>[r.name()].concat(r.aliases()),n=t(e).find(r=>this._findCommand(r));if(n){let r=t(this._findCommand(n)).join("|"),i=t(e).join("|");throw new Error(`cannot add command '${i}' as already have command '${r}'`)}this._initCommandGroup(e),this.commands.push(e)}addOption(e){this._registerOption(e);let t=e.name(),n=e.attributeName();if(e.negate){let i=e.long.replace(/^--no-/,"--");this._findOption(i)||this.setOptionValueWithSource(n,e.defaultValue===void 0?!0:e.defaultValue,"default")}else e.defaultValue!==void 0&&this.setOptionValueWithSource(n,e.defaultValue,"default");let r=(i,a,c)=>{i==null&&e.presetArg!==void 0&&(i=e.presetArg);let d=this.getOptionValue(n);i!==null&&e.parseArg?i=this._callParseArg(e,i,d,a):i!==null&&e.variadic&&(i=e._collectValue(i,d)),i==null&&(e.negate?i=!1:e.isBoolean()||e.optional?i=!0:i=""),this.setOptionValueWithSource(n,i,c)};return this.on("option:"+t,i=>{let a=`error: option '${e.flags}' argument '${i}' is invalid.`;r(i,a,"cli")}),e.envVar&&this.on("optionEnv:"+t,i=>{let a=`error: option '${e.flags}' value '${i}' from env '${e.envVar}' is invalid.`;r(i,a,"env")}),this}_optionEx(e,t,n,r,i){if(typeof t=="object"&&t instanceof rt)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");let a=this.createOption(t,n);if(a.makeOptionMandatory(!!e.mandatory),typeof r=="function")a.default(i).argParser(r);else if(r instanceof RegExp){let c=r;r=(d,g)=>{let C=c.exec(d);return C?C[0]:g},a.default(i).argParser(r)}else a.default(r);return this.addOption(a)}option(e,t,n,r){return this._optionEx({},e,t,n,r)}requiredOption(e,t,n,r){return this._optionEx({mandatory:!0},e,t,n,r)}combineFlagAndOptionalValue(e=!0){return this._combineFlagAndOptionalValue=!!e,this}allowUnknownOption(e=!0){return this._allowUnknownOption=!!e,this}allowExcessArguments(e=!0){return this._allowExcessArguments=!!e,this}enablePositionalOptions(e=!0){return this._enablePositionalOptions=!!e,this}passThroughOptions(e=!0){return this._passThroughOptions=!!e,this._checkForBrokenPassThrough(),this}_checkForBrokenPassThrough(){if(this.parent&&this._passThroughOptions&&!this.parent._enablePositionalOptions)throw new Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}storeOptionsAsProperties(e=!0){if(this.options.length)throw new Error("call .storeOptionsAsProperties() before adding options");if(Object.keys(this._optionValues).length)throw new Error("call .storeOptionsAsProperties() before setting option values");return this._storeOptionsAsProperties=!!e,this}getOptionValue(e){return this._storeOptionsAsProperties?this[e]:this._optionValues[e]}setOptionValue(e,t){return this.setOptionValueWithSource(e,t,void 0)}setOptionValueWithSource(e,t,n){return this._storeOptionsAsProperties?this[e]=t:this._optionValues[e]=t,this._optionValueSources[e]=n,this}getOptionValueSource(e){return this._optionValueSources[e]}getOptionValueSourceWithGlobals(e){let t;return this._getCommandAndAncestors().forEach(n=>{n.getOptionValueSource(e)!==void 0&&(t=n.getOptionValueSource(e))}),t}_prepareUserArgs(e,t){if(e!==void 0&&!Array.isArray(e))throw new Error("first parameter to parse must be array or undefined");if(t=t||{},e===void 0&&t.from===void 0){A.versions?.electron&&(t.from="electron");let r=A.execArgv??[];(r.includes("-e")||r.includes("--eval")||r.includes("-p")||r.includes("--print"))&&(t.from="eval")}e===void 0&&(e=A.argv),this.rawArgs=e.slice();let n;switch(t.from){case void 0:case"node":this._scriptPath=e[1],n=e.slice(2);break;case"electron":A.defaultApp?(this._scriptPath=e[1],n=e.slice(2)):n=e.slice(1);break;case"user":n=e.slice(0);break;case"eval":n=e.slice(1);break;default:throw new Error(`unexpected parse option { from: '${t.from}' }`)}return!this._name&&this._scriptPath&&this.nameFromFilename(this._scriptPath),this._name=this._name||"program",n}parse(e,t){this._prepareForParse();let n=this._prepareUserArgs(e,t);return this._parseCommand([],n),this}async parseAsync(e,t){this._prepareForParse();let n=this._prepareUserArgs(e,t);return await this._parseCommand([],n),this}_prepareForParse(){this._savedState===null?this.saveStateBeforeParse():this.restoreStateBeforeParse()}saveStateBeforeParse(){this._savedState={_name:this._name,_optionValues:{...this._optionValues},_optionValueSources:{...this._optionValueSources}}}restoreStateBeforeParse(){if(this._storeOptionsAsProperties)throw new Error(`Can not call parse again when storeOptionsAsProperties is true.
|
|
18
|
+
- either make a new Command for each call to parse, or stop storing options as properties`);this._name=this._savedState._name,this._scriptPath=null,this.rawArgs=[],this._optionValues={...this._savedState._optionValues},this._optionValueSources={...this._savedState._optionValueSources},this.args=[],this.processedArgs=[]}_checkForMissingExecutable(e,t,n){if(ue.existsSync(e))return;let r=t?`searched for local subcommand relative to directory '${t}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",i=`'${e}' does not exist
|
|
19
|
+
- if '${n}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
|
|
20
|
+
- if the default executable name is not suitable, use the executableFile option to supply a custom name or path
|
|
21
|
+
- ${r}`;throw new Error(i)}_executeSubCommand(e,t){t=t.slice();let n=!1,r=[".js",".ts",".tsx",".mjs",".cjs"];function i(C,E){let S=G.resolve(C,E);if(ue.existsSync(S))return S;if(r.includes(G.extname(E)))return;let l=r.find(u=>ue.existsSync(`${S}${u}`));if(l)return`${S}${l}`}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let a=e._executableFile||`${this._name}-${e._name}`,c=this._executableDir||"";if(this._scriptPath){let C;try{C=ue.realpathSync(this._scriptPath)}catch{C=this._scriptPath}c=G.resolve(G.dirname(C),c)}if(c){let C=i(c,a);if(!C&&!e._executableFile&&this._scriptPath){let E=G.basename(this._scriptPath,G.extname(this._scriptPath));E!==this._name&&(C=i(c,`${E}-${e._name}`))}a=C||a}n=r.includes(G.extname(a));let d;A.platform!=="win32"?n?(t.unshift(a),t=ot(A.execArgv).concat(t),d=Fe.spawn(A.argv[0],t,{stdio:"inherit"})):d=Fe.spawn(a,t,{stdio:"inherit"}):(this._checkForMissingExecutable(a,c,e._name),t.unshift(a),t=ot(A.execArgv).concat(t),d=Fe.spawn(A.execPath,t,{stdio:"inherit"})),d.killed||["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach(E=>{A.on(E,()=>{d.killed===!1&&d.exitCode===null&&d.kill(E)})});let g=this._exitCallback;d.on("close",C=>{C=C??1,g?g(new be(C,"commander.executeSubCommandAsync","(close)")):A.exit(C)}),d.on("error",C=>{if(C.code==="ENOENT")this._checkForMissingExecutable(a,c,e._name);else if(C.code==="EACCES")throw new Error(`'${a}' not executable`);if(!g)A.exit(1);else{let E=new be(1,"commander.executeSubCommandAsync","(error)");E.nestedError=C,g(E)}}),this.runningCommand=d}_dispatchSubcommand(e,t,n){let r=this._findCommand(e);r||this.help({error:!0}),r._prepareForParse();let i;return i=this._chainOrCallSubCommandHook(i,r,"preSubcommand"),i=this._chainOrCall(i,()=>{if(r._executableHandler)this._executeSubCommand(r,t.concat(n));else return r._parseCommand(t,n)}),i}_dispatchHelpCommand(e){e||this.help();let t=this._findCommand(e);return t&&!t._executableHandler&&t.help(),this._dispatchSubcommand(e,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){this.registeredArguments.forEach((e,t)=>{e.required&&this.args[t]==null&&this.missingArgument(e.name())}),!(this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic)&&this.args.length>this.registeredArguments.length&&this._excessArguments(this.args)}_processArguments(){let e=(n,r,i)=>{let a=r;if(r!==null&&n.parseArg){let c=`error: command-argument value '${r}' is invalid for argument '${n.name()}'.`;a=this._callParseArg(n,r,i,c)}return a};this._checkNumberOfArguments();let t=[];this.registeredArguments.forEach((n,r)=>{let i=n.defaultValue;n.variadic?r<this.args.length?(i=this.args.slice(r),n.parseArg&&(i=i.reduce((a,c)=>e(n,c,a),n.defaultValue))):i===void 0&&(i=[]):r<this.args.length&&(i=this.args[r],n.parseArg&&(i=e(n,i,n.defaultValue))),t[r]=i}),this.processedArgs=t}_chainOrCall(e,t){return e?.then&&typeof e.then=="function"?e.then(()=>t()):t()}_chainOrCallHooks(e,t){let n=e,r=[];return this._getCommandAndAncestors().reverse().filter(i=>i._lifeCycleHooks[t]!==void 0).forEach(i=>{i._lifeCycleHooks[t].forEach(a=>{r.push({hookedCommand:i,callback:a})})}),t==="postAction"&&r.reverse(),r.forEach(i=>{n=this._chainOrCall(n,()=>i.callback(i.hookedCommand,this))}),n}_chainOrCallSubCommandHook(e,t,n){let r=e;return this._lifeCycleHooks[n]!==void 0&&this._lifeCycleHooks[n].forEach(i=>{r=this._chainOrCall(r,()=>i(this,t))}),r}_parseCommand(e,t){let n=this.parseOptions(t);if(this._parseOptionsEnv(),this._parseOptionsImplied(),e=e.concat(n.operands),t=n.unknown,this.args=e.concat(t),e&&this._findCommand(e[0]))return this._dispatchSubcommand(e[0],e.slice(1),t);if(this._getHelpCommand()&&e[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(e[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(t),this._dispatchSubcommand(this._defaultCommandName,e,t);this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName&&this.help({error:!0}),this._outputHelpIfRequested(n.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let r=()=>{n.unknown.length>0&&this.unknownOption(n.unknown[0])},i=`command:${this.name()}`;if(this._actionHandler){r(),this._processArguments();let a;return a=this._chainOrCallHooks(a,"preAction"),a=this._chainOrCall(a,()=>this._actionHandler(this.processedArgs)),this.parent&&(a=this._chainOrCall(a,()=>{this.parent.emit(i,e,t)})),a=this._chainOrCallHooks(a,"postAction"),a}if(this.parent?.listenerCount(i))r(),this._processArguments(),this.parent.emit(i,e,t);else if(e.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",e,t);this.listenerCount("command:*")?this.emit("command:*",e,t):this.commands.length?this.unknownCommand():(r(),this._processArguments())}else this.commands.length?(r(),this.help({error:!0})):(r(),this._processArguments())}_findCommand(e){if(e)return this.commands.find(t=>t._name===e||t._aliases.includes(e))}_findOption(e){return this.options.find(t=>t.is(e))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(e=>{e.options.forEach(t=>{t.mandatory&&e.getOptionValue(t.attributeName())===void 0&&e.missingMandatoryOptionValue(t)})})}_checkForConflictingLocalOptions(){let e=this.options.filter(n=>{let r=n.attributeName();return this.getOptionValue(r)===void 0?!1:this.getOptionValueSource(r)!=="default"});e.filter(n=>n.conflictsWith.length>0).forEach(n=>{let r=e.find(i=>n.conflictsWith.includes(i.attributeName()));r&&this._conflictingOption(n,r)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(e=>{e._checkForConflictingLocalOptions()})}parseOptions(e){let t=[],n=[],r=t;function i(C){return C.length>1&&C[0]==="-"}let a=C=>/^-(\d+|\d*\.\d+)(e[+-]?\d+)?$/.test(C)?!this._getCommandAndAncestors().some(E=>E.options.map(S=>S.short).some(S=>/^-\d$/.test(S))):!1,c=null,d=null,g=0;for(;g<e.length||d;){let C=d??e[g++];if(d=null,C==="--"){r===n&&r.push(C),r.push(...e.slice(g));break}if(c&&(!i(C)||a(C))){this.emit(`option:${c.name()}`,C);continue}if(c=null,i(C)){let E=this._findOption(C);if(E){if(E.required){let S=e[g++];S===void 0&&this.optionMissingArgument(E),this.emit(`option:${E.name()}`,S)}else if(E.optional){let S=null;g<e.length&&(!i(e[g])||a(e[g]))&&(S=e[g++]),this.emit(`option:${E.name()}`,S)}else this.emit(`option:${E.name()}`);c=E.variadic?E:null;continue}}if(C.length>2&&C[0]==="-"&&C[1]!=="-"){let E=this._findOption(`-${C[1]}`);if(E){E.required||E.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${E.name()}`,C.slice(2)):(this.emit(`option:${E.name()}`),d=`-${C.slice(2)}`);continue}}if(/^--[^=]+=/.test(C)){let E=C.indexOf("="),S=this._findOption(C.slice(0,E));if(S&&(S.required||S.optional)){this.emit(`option:${S.name()}`,C.slice(E+1));continue}}if(r===t&&i(C)&&!(this.commands.length===0&&a(C))&&(r=n),(this._enablePositionalOptions||this._passThroughOptions)&&t.length===0&&n.length===0){if(this._findCommand(C)){t.push(C),n.push(...e.slice(g));break}else if(this._getHelpCommand()&&C===this._getHelpCommand().name()){t.push(C,...e.slice(g));break}else if(this._defaultCommandName){n.push(C,...e.slice(g));break}}if(this._passThroughOptions){r.push(C,...e.slice(g));break}r.push(C)}return{operands:t,unknown:n}}opts(){if(this._storeOptionsAsProperties){let e={},t=this.options.length;for(let n=0;n<t;n++){let r=this.options[n].attributeName();e[r]=r===this._versionOptionName?this._version:this[r]}return e}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((e,t)=>Object.assign(e,t.opts()),{})}error(e,t){this._outputConfiguration.outputError(`${e}
|
|
22
|
+
`,this._outputConfiguration.writeErr),typeof this._showHelpAfterError=="string"?this._outputConfiguration.writeErr(`${this._showHelpAfterError}
|
|
23
|
+
`):this._showHelpAfterError&&(this._outputConfiguration.writeErr(`
|
|
24
|
+
`),this.outputHelp({error:!0}));let n=t||{},r=n.exitCode||1,i=n.code||"commander.error";this._exit(r,i,e)}_parseOptionsEnv(){this.options.forEach(e=>{if(e.envVar&&e.envVar in A.env){let t=e.attributeName();(this.getOptionValue(t)===void 0||["default","config","env"].includes(this.getOptionValueSource(t)))&&(e.required||e.optional?this.emit(`optionEnv:${e.name()}`,A.env[e.envVar]):this.emit(`optionEnv:${e.name()}`))}})}_parseOptionsImplied(){let e=new Sn(this.options),t=n=>this.getOptionValue(n)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(n));this.options.filter(n=>n.implied!==void 0&&t(n.attributeName())&&e.valueFromOption(this.getOptionValue(n.attributeName()),n)).forEach(n=>{Object.keys(n.implied).filter(r=>!t(r)).forEach(r=>{this.setOptionValueWithSource(r,n.implied[r],"implied")})})}missingArgument(e){let t=`error: missing required argument '${e}'`;this.error(t,{code:"commander.missingArgument"})}optionMissingArgument(e){let t=`error: option '${e.flags}' argument missing`;this.error(t,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(e){let t=`error: required option '${e.flags}' not specified`;this.error(t,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(e,t){let n=a=>{let c=a.attributeName(),d=this.getOptionValue(c),g=this.options.find(E=>E.negate&&c===E.attributeName()),C=this.options.find(E=>!E.negate&&c===E.attributeName());return g&&(g.presetArg===void 0&&d===!1||g.presetArg!==void 0&&d===g.presetArg)?g:C||a},r=a=>{let c=n(a),d=c.attributeName();return this.getOptionValueSource(d)==="env"?`environment variable '${c.envVar}'`:`option '${c.flags}'`},i=`error: ${r(e)} cannot be used with ${r(t)}`;this.error(i,{code:"commander.conflictingOption"})}unknownOption(e){if(this._allowUnknownOption)return;let t="";if(e.startsWith("--")&&this._showSuggestionAfterError){let r=[],i=this;do{let a=i.createHelp().visibleOptions(i).filter(c=>c.long).map(c=>c.long);r=r.concat(a),i=i.parent}while(i&&!i._enablePositionalOptions);t=it(e,r)}let n=`error: unknown option '${e}'${t}`;this.error(n,{code:"commander.unknownOption"})}_excessArguments(e){if(this._allowExcessArguments)return;let t=this.registeredArguments.length,n=t===1?"":"s",i=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${t} argument${n} but got ${e.length}.`;this.error(i,{code:"commander.excessArguments"})}unknownCommand(){let e=this.args[0],t="";if(this._showSuggestionAfterError){let r=[];this.createHelp().visibleCommands(this).forEach(i=>{r.push(i.name()),i.alias()&&r.push(i.alias())}),t=it(e,r)}let n=`error: unknown command '${e}'${t}`;this.error(n,{code:"commander.unknownCommand"})}version(e,t,n){if(e===void 0)return this._version;this._version=e,t=t||"-V, --version",n=n||"output the version number";let r=this.createOption(t,n);return this._versionOptionName=r.attributeName(),this._registerOption(r),this.on("option:"+r.name(),()=>{this._outputConfiguration.writeOut(`${e}
|
|
25
|
+
`),this._exit(0,"commander.version",e)}),this}description(e,t){return e===void 0&&t===void 0?this._description:(this._description=e,t&&(this._argsDescription=t),this)}summary(e){return e===void 0?this._summary:(this._summary=e,this)}alias(e){if(e===void 0)return this._aliases[0];let t=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(t=this.commands[this.commands.length-1]),e===t._name)throw new Error("Command alias can't be the same as its name");let n=this.parent?._findCommand(e);if(n){let r=[n.name()].concat(n.aliases()).join("|");throw new Error(`cannot add alias '${e}' to command '${this.name()}' as already have command '${r}'`)}return t._aliases.push(e),this}aliases(e){return e===void 0?this._aliases:(e.forEach(t=>this.alias(t)),this)}usage(e){if(e===void 0){if(this._usage)return this._usage;let t=this.registeredArguments.map(n=>Cn(n));return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?t:[]).join(" ")}return this._usage=e,this}name(e){return e===void 0?this._name:(this._name=e,this)}helpGroup(e){return e===void 0?this._helpGroupHeading??"":(this._helpGroupHeading=e,this)}commandsGroup(e){return e===void 0?this._defaultCommandGroup??"":(this._defaultCommandGroup=e,this)}optionsGroup(e){return e===void 0?this._defaultOptionGroup??"":(this._defaultOptionGroup=e,this)}_initOptionGroup(e){this._defaultOptionGroup&&!e.helpGroupHeading&&e.helpGroup(this._defaultOptionGroup)}_initCommandGroup(e){this._defaultCommandGroup&&!e.helpGroup()&&e.helpGroup(this._defaultCommandGroup)}nameFromFilename(e){return this._name=G.basename(e,G.extname(e)),this}executableDir(e){return e===void 0?this._executableDir:(this._executableDir=e,this)}helpInformation(e){let t=this.createHelp(),n=this._getOutputContext(e);t.prepareContext({error:n.error,helpWidth:n.helpWidth,outputHasColors:n.hasColors});let r=t.formatHelp(this,t);return n.hasColors?r:this._outputConfiguration.stripColor(r)}_getOutputContext(e){e=e||{};let t=!!e.error,n,r,i;return t?(n=c=>this._outputConfiguration.writeErr(c),r=this._outputConfiguration.getErrHasColors(),i=this._outputConfiguration.getErrHelpWidth()):(n=c=>this._outputConfiguration.writeOut(c),r=this._outputConfiguration.getOutHasColors(),i=this._outputConfiguration.getOutHelpWidth()),{error:t,write:c=>(r||(c=this._outputConfiguration.stripColor(c)),n(c)),hasColors:r,helpWidth:i}}outputHelp(e){let t;typeof e=="function"&&(t=e,e=void 0);let n=this._getOutputContext(e),r={error:n.error,write:n.write,command:this};this._getCommandAndAncestors().reverse().forEach(a=>a.emit("beforeAllHelp",r)),this.emit("beforeHelp",r);let i=this.helpInformation({error:n.error});if(t&&(i=t(i),typeof i!="string"&&!Buffer.isBuffer(i)))throw new Error("outputHelp callback must return a string or a Buffer");n.write(i),this._getHelpOption()?.long&&this.emit(this._getHelpOption().long),this.emit("afterHelp",r),this._getCommandAndAncestors().forEach(a=>a.emit("afterAllHelp",r))}helpOption(e,t){return typeof e=="boolean"?(e?(this._helpOption===null&&(this._helpOption=void 0),this._defaultOptionGroup&&this._initOptionGroup(this._getHelpOption())):this._helpOption=null,this):(this._helpOption=this.createOption(e??"-h, --help",t??"display help for command"),(e||t)&&this._initOptionGroup(this._helpOption),this)}_getHelpOption(){return this._helpOption===void 0&&this.helpOption(void 0,void 0),this._helpOption}addHelpOption(e){return this._helpOption=e,this._initOptionGroup(e),this}help(e){this.outputHelp(e);let t=Number(A.exitCode??0);t===0&&e&&typeof e!="function"&&e.error&&(t=1),this._exit(t,"commander.help","(outputHelp)")}addHelpText(e,t){let n=["beforeAll","before","after","afterAll"];if(!n.includes(e))throw new Error(`Unexpected value for position to addHelpText.
|
|
26
|
+
Expecting one of '${n.join("', '")}'`);let r=`${e}Help`;return this.on(r,i=>{let a;typeof t=="function"?a=t({error:i.error,command:i.command}):a=t,a&&i.write(`${a}
|
|
27
|
+
`)}),this}_outputHelpIfRequested(e){let t=this._getHelpOption();t&&e.find(r=>t.is(r))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function ot(o){return o.map(e=>{if(!e.startsWith("--inspect"))return e;let t,n="127.0.0.1",r="9229",i;return(i=e.match(/^(--inspect(-brk)?)$/))!==null?t=i[1]:(i=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(t=i[1],/^\d+$/.test(i[3])?r=i[3]:n=i[3]):(i=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(t=i[1],n=i[3],r=i[4]),t&&r!=="0"?`${t}=${n}:${parseInt(r)+1}`:e})}function He(){if(A.env.NO_COLOR||A.env.FORCE_COLOR==="0"||A.env.FORCE_COLOR==="false")return!1;if(A.env.FORCE_COLOR||A.env.CLICOLOR_FORCE!==void 0)return!0}Ue.Command=Re;Ue.useColor=He});var ut=T(W=>{"use strict";var{Argument:at}=ce(),{Command:Pe}=st(),{CommanderError:wn,InvalidArgumentError:lt}=Q(),{Help:xn}=Le(),{Option:ct}=ve();W.program=new Pe;W.createCommand=o=>new Pe(o);W.createOption=(o,e)=>new ct(o,e);W.createArgument=(o,e)=>new at(o,e);W.Command=Pe;W.Option=ct;W.Argument=at;W.Help=xn;W.CommanderError=wn;W.InvalidArgumentError=lt;W.InvalidOptionArgumentError=lt});var We=T((ui,_t)=>{"use strict";_t.exports={LOCHDR:30,LOCSIG:67324752,LOCVER:4,LOCFLG:6,LOCHOW:8,LOCTIM:10,LOCCRC:14,LOCSIZ:18,LOCLEN:22,LOCNAM:26,LOCEXT:28,EXTSIG:134695760,EXTHDR:16,EXTCRC:4,EXTSIZ:8,EXTLEN:12,CENHDR:46,CENSIG:33639248,CENVEM:4,CENVER:6,CENFLG:8,CENHOW:10,CENTIM:12,CENCRC:16,CENSIZ:20,CENLEN:24,CENNAM:28,CENEXT:30,CENCOM:32,CENDSK:34,CENATT:36,CENATX:38,CENOFF:42,ENDHDR:22,ENDSIG:101010256,ENDSUB:8,ENDTOT:10,ENDSIZ:12,ENDOFF:16,ENDCOM:20,END64HDR:20,END64SIG:117853008,END64START:4,END64OFF:8,END64NUMDISKS:16,ZIP64SIG:101075792,ZIP64HDR:56,ZIP64LEAD:12,ZIP64SIZE:4,ZIP64VEM:12,ZIP64VER:14,ZIP64DSK:16,ZIP64DSKDIR:20,ZIP64SUB:24,ZIP64TOT:32,ZIP64SIZB:40,ZIP64OFF:48,ZIP64EXTRA:56,STORED:0,SHRUNK:1,REDUCED1:2,REDUCED2:3,REDUCED3:4,REDUCED4:5,IMPLODED:6,DEFLATED:8,ENHANCED_DEFLATED:9,PKWARE:10,BZIP2:12,LZMA:14,IBM_TERSE:18,IBM_LZ77:19,AES_ENCRYPT:99,FLG_ENC:1,FLG_COMP1:2,FLG_COMP2:4,FLG_DESC:8,FLG_ENH:16,FLG_PATCH:32,FLG_STR:64,FLG_EFS:2048,FLG_MSK:4096,FILE:2,BUFFER:1,NONE:0,EF_ID:0,EF_SIZE:2,ID_ZIP64:1,ID_AVINFO:7,ID_PFS:8,ID_OS2:9,ID_NTFS:10,ID_OPENVMS:12,ID_UNIX:13,ID_FORK:14,ID_PATCH:15,ID_X509_PKCS7:20,ID_X509_CERTID_F:21,ID_X509_CERTID_C:22,ID_STRONGENC:23,ID_RECORD_MGT:24,ID_X509_PKCS7_RL:25,ID_IBM1:101,ID_IBM2:102,ID_POSZIP:18064,EF_ZIP64_OR_32:4294967295,EF_ZIP64_OR_16:65535,EF_ZIP64_SUNCOMP:0,EF_ZIP64_SCOMP:8,EF_ZIP64_RHO:16,EF_ZIP64_DSN:24}});var de=T(yt=>{"use strict";var Ct={INVALID_LOC:"Invalid LOC header (bad signature)",INVALID_CEN:"Invalid CEN header (bad signature)",INVALID_END:"Invalid END header (bad signature)",DESCRIPTOR_NOT_EXIST:"No descriptor present",DESCRIPTOR_UNKNOWN:"Unknown descriptor format",DESCRIPTOR_FAULTY:"Descriptor data is malformed",NO_DATA:"Nothing to decompress",BAD_CRC:"CRC32 checksum failed {0}",FILE_IN_THE_WAY:"There is a file in the way: {0}",UNKNOWN_METHOD:"Invalid/unsupported compression method",AVAIL_DATA:"inflate::Available inflate data did not terminate",INVALID_DISTANCE:"inflate::Invalid literal/length or distance code in fixed or dynamic block",TO_MANY_CODES:"inflate::Dynamic block code description: too many length or distance codes",INVALID_REPEAT_LEN:"inflate::Dynamic block code description: repeat more than specified lengths",INVALID_REPEAT_FIRST:"inflate::Dynamic block code description: repeat lengths with no first length",INCOMPLETE_CODES:"inflate::Dynamic block code description: code lengths codes incomplete",INVALID_DYN_DISTANCE:"inflate::Dynamic block code description: invalid distance code lengths",INVALID_CODES_LEN:"inflate::Dynamic block code description: invalid literal/length code lengths",INVALID_STORE_BLOCK:"inflate::Stored block length did not match one's complement",INVALID_BLOCK_TYPE:"inflate::Invalid block type (type == 3)",CANT_EXTRACT_FILE:"Could not extract the file",CANT_OVERRIDE:"Target file already exists",DISK_ENTRY_TOO_LARGE:"Number of disk entries is too large",NO_ZIP:"No zip file was loaded",NO_ENTRY:"Entry doesn't exist",DIRECTORY_CONTENT_ERROR:"A directory cannot have content",FILE_NOT_FOUND:'File not found: "{0}"',NOT_IMPLEMENTED:"Not implemented",INVALID_FILENAME:"Invalid filename",INVALID_FORMAT:"Invalid or unsupported zip format. No END header found",INVALID_PASS_PARAM:"Incompatible password parameter",WRONG_PASSWORD:"Wrong Password",COMMENT_TOO_LONG:"Comment is too long",EXTRA_FIELD_PARSE_ERROR:"Extra field parsing error"};function qn(o){return function(...e){return e.length&&(o=o.replace(/\{(\d)\}/g,(t,n)=>e[n]||"")),new Error("ADM-ZIP: "+o)}}for(let o of Object.keys(Ct))yt[o]=qn(Ct[o])});var At=T((hi,xt)=>{"use strict";var Xn=M("fs"),U=M("path"),Ot=We(),Kn=de(),Yn=typeof process=="object"&&process.platform==="win32",St=o=>typeof o=="object"&&o!==null,wt=new Uint32Array(256).map((o,e)=>{for(let t=0;t<8;t++)(e&1)!==0?e=3988292384^e>>>1:e>>>=1;return e>>>0});function R(o){this.sep=U.sep,this.fs=Xn,St(o)&&St(o.fs)&&typeof o.fs.statSync=="function"&&(this.fs=o.fs)}xt.exports=R;R.prototype.makeDir=function(o){let e=this;function t(n){let r=n.split(e.sep)[0];n.split(e.sep).forEach(function(i){if(!(!i||i.substr(-1,1)===":")){r+=e.sep+i;var a;try{a=e.fs.statSync(r)}catch(c){if(c.message&&c.message.startsWith("ENOENT"))e.fs.mkdirSync(r);else throw c}if(a&&a.isFile())throw Kn.FILE_IN_THE_WAY(`"${r}"`)}})}t(o)};R.prototype.writeFileTo=function(o,e,t,n){let r=this;if(r.fs.existsSync(o)){if(!t)return!1;var i=r.fs.statSync(o);if(i.isDirectory())return!1}var a=U.dirname(o);r.fs.existsSync(a)||r.makeDir(a);var c;try{c=r.fs.openSync(o,"w",438)}catch{r.fs.chmodSync(o,438),c=r.fs.openSync(o,"w",438)}if(c)try{r.fs.writeSync(c,e,0,e.length,0)}finally{r.fs.closeSync(c)}return r.fs.chmodSync(o,n||438),!0};R.prototype.writeFileToAsync=function(o,e,t,n,r){typeof n=="function"&&(r=n,n=void 0);let i=this;i.fs.exists(o,function(a){if(a&&!t)return r(!1);i.fs.stat(o,function(c,d){if(a&&d.isDirectory())return r(!1);var g=U.dirname(o);i.fs.exists(g,function(C){C||i.makeDir(g),i.fs.open(o,"w",438,function(E,S){E?i.fs.chmod(o,438,function(){i.fs.open(o,"w",438,function(l,u){i.fs.write(u,e,0,e.length,0,function(){i.fs.close(u,function(){i.fs.chmod(o,n||438,function(){r(!0)})})})})}):S?i.fs.write(S,e,0,e.length,0,function(){i.fs.close(S,function(){i.fs.chmod(o,n||438,function(){r(!0)})})}):i.fs.chmod(o,n||438,function(){r(!0)})})})})})};R.prototype.findFiles=function(o){let e=this;function t(n,r,i){typeof r=="boolean"&&(i=r,r=void 0);let a=[];return e.fs.readdirSync(n).forEach(function(c){let d=U.join(n,c),g=e.fs.statSync(d);(!r||r.test(d))&&a.push(U.normalize(d)+(g.isDirectory()?e.sep:"")),g.isDirectory()&&i&&(a=a.concat(t(d,r,i)))}),a}return t(o,void 0,!0)};R.prototype.findFilesAsync=function(o,e){let t=this,n=[];t.fs.readdir(o,function(r,i){if(r)return e(r);let a=i.length;if(!a)return e(null,n);i.forEach(function(c){c=U.join(o,c),t.fs.stat(c,function(d,g){if(d)return e(d);g&&(n.push(U.normalize(c)+(g.isDirectory()?t.sep:"")),g.isDirectory()?t.findFilesAsync(c,function(C,E){if(C)return e(C);n=n.concat(E),--a||e(null,n)}):--a||e(null,n))})})})};R.prototype.getAttributes=function(){};R.prototype.setAttributes=function(){};R.crc32update=function(o,e){return wt[(o^e)&255]^o>>>8};R.crc32=function(o){typeof o=="string"&&(o=Buffer.from(o,"utf8"));let e=o.length,t=-1;for(let n=0;n<e;)t=R.crc32update(t,o[n++]);return~t>>>0};R.methodToString=function(o){switch(o){case Ot.STORED:return"STORED ("+o+")";case Ot.DEFLATED:return"DEFLATED ("+o+")";default:return"UNSUPPORTED ("+o+")"}};R.canonical=function(o){if(!o)return"";let e=U.posix.normalize("/"+o.split("\\").join("/"));return U.join(".",e)};R.zipnamefix=function(o){if(!o)return"";let e=U.posix.normalize("/"+o.split("\\").join("/"));return U.posix.join(".",e)};R.findLast=function(o,e){if(!Array.isArray(o))throw new TypeError("arr is not array");let t=o.length>>>0;for(let n=t-1;n>=0;n--)if(e(o[n],n,o))return o[n]};R.sanitize=function(o,e){o=U.resolve(U.normalize(o));for(var t=e.split("/"),n=0,r=t.length;n<r;n++){var i=U.normalize(U.join(o,t.slice(n,r).join(U.sep)));if(i.indexOf(o)===0)return i}return U.normalize(U.join(o,U.basename(e)))};R.toBuffer=function(e,t){return Buffer.isBuffer(e)?e:e instanceof Uint8Array?Buffer.from(e):typeof e=="string"?t(e):Buffer.alloc(0)};R.readBigUInt64LE=function(o,e){let t=o.readUInt32LE(e);return o.readUInt32LE(e+4)*4294967296+t};R.fromDOS2Date=function(o){return new Date((o>>25&127)+1980,Math.max((o>>21&15)-1,0),Math.max(o>>16&31,1),o>>11&31,o>>5&63,(o&31)<<1)};R.fromDate2DOS=function(o){let e=0,t=0;return o.getFullYear()>1979&&(e=(o.getFullYear()-1980&127)<<9|o.getMonth()+1<<5|o.getDate(),t=o.getHours()<<11|o.getMinutes()<<5|o.getSeconds()>>1),e<<16|t};R.isWin=Yn;R.crcTable=wt});var Lt=T((di,It)=>{"use strict";var Jn=M("path");It.exports=function(o,{fs:e}){var t=o||"",n=i(),r=null;function i(){return{directory:!1,readonly:!1,hidden:!1,executable:!1,mtime:0,atime:0}}return t&&e.existsSync(t)?(r=e.statSync(t),n.directory=r.isDirectory(),n.mtime=r.mtime,n.atime=r.atime,n.executable=(73&r.mode)!==0,n.readonly=(128&r.mode)===0,n.hidden=Jn.basename(t)[0]==="."):console.warn("Invalid path: "+t),{get directory(){return n.directory},get readOnly(){return n.readonly},get hidden(){return n.hidden},get mtime(){return n.mtime},get atime(){return n.atime},get executable(){return n.executable},decodeAttributes:function(){},encodeAttributes:function(){},toJSON:function(){return{path:t,isDirectory:n.directory,isReadOnly:n.readonly,isHidden:n.hidden,isExecutable:n.executable,mTime:n.mtime,aTime:n.atime}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var Nt=T((mi,Dt)=>{"use strict";Dt.exports={efs:!0,encode:o=>Buffer.from(o,"utf8"),decode:o=>o.toString("utf8")}});var Y=T((pi,K)=>{"use strict";K.exports=At();K.exports.Constants=We();K.exports.Errors=de();K.exports.FileAttr=Lt();K.exports.decoder=Nt()});var vt=T((gi,Tt)=>{"use strict";var j=Y(),O=j.Constants;Tt.exports=function(){var o=20,e=10,t=0,n=0,r=0,i=0,a=0,c=0,d=0,g=0,C=0,E=0,S=0,l=0,u=0;o|=j.isWin?2560:768,t|=O.FLG_EFS;let p={extraLen:0},f=s=>Math.max(0,s)>>>0,m=s=>Math.max(0,s)&65535,y=s=>Math.max(0,s)&255;return r=j.fromDate2DOS(new Date),{get made(){return o},set made(s){o=s},get version(){return e},set version(s){e=s},get flags(){return t},set flags(s){t=s},get flags_efs(){return(t&O.FLG_EFS)>0},set flags_efs(s){s?t|=O.FLG_EFS:t&=~O.FLG_EFS},get flags_desc(){return(t&O.FLG_DESC)>0},set flags_desc(s){s?t|=O.FLG_DESC:t&=~O.FLG_DESC},get method(){return n},set method(s){switch(s){case O.STORED:this.version=10;case O.DEFLATED:default:this.version=20}n=s},get time(){return j.fromDOS2Date(this.timeval)},set time(s){s=new Date(s),this.timeval=j.fromDate2DOS(s)},get timeval(){return r},set timeval(s){r=f(s)},get timeHighByte(){return y(r>>>8)},get crc(){return i},set crc(s){i=f(s)},get compressedSize(){return a},set compressedSize(s){a=f(s)},get size(){return c},set size(s){c=f(s)},get fileNameLength(){return d},set fileNameLength(s){d=s},get extraLength(){return g},set extraLength(s){g=s},get extraLocalLength(){return p.extraLen},set extraLocalLength(s){p.extraLen=s},get commentLength(){return C},set commentLength(s){C=s},get diskNumStart(){return E},set diskNumStart(s){E=f(s)},get inAttr(){return S},set inAttr(s){S=f(s)},get attr(){return l},set attr(s){l=f(s)},get fileAttr(){return(l||0)>>16&4095},get offset(){return u},set offset(s){u=f(s)},get encrypted(){return(t&O.FLG_ENC)===O.FLG_ENC},get centralHeaderSize(){return O.CENHDR+d+g+C},get realDataOffset(){return u+O.LOCHDR+p.fnameLen+p.extraLen},get localHeader(){return p},loadLocalHeaderFromBinary:function(s){var h=s.slice(u,u+O.LOCHDR);if(h.readUInt32LE(0)!==O.LOCSIG)throw j.Errors.INVALID_LOC();p.version=h.readUInt16LE(O.LOCVER),p.flags=h.readUInt16LE(O.LOCFLG),p.flags_desc=(p.flags&O.FLG_DESC)>0,p.method=h.readUInt16LE(O.LOCHOW),p.time=h.readUInt32LE(O.LOCTIM),p.crc=h.readUInt32LE(O.LOCCRC),p.compressedSize=h.readUInt32LE(O.LOCSIZ),p.size=h.readUInt32LE(O.LOCLEN),p.fnameLen=h.readUInt16LE(O.LOCNAM),p.extraLen=h.readUInt16LE(O.LOCEXT);let _=u+O.LOCHDR+p.fnameLen,x=_+p.extraLen;return s.slice(_,x)},loadFromBinary:function(s){if(s.length!==O.CENHDR||s.readUInt32LE(0)!==O.CENSIG)throw j.Errors.INVALID_CEN();o=s.readUInt16LE(O.CENVEM),e=s.readUInt16LE(O.CENVER),t=s.readUInt16LE(O.CENFLG),n=s.readUInt16LE(O.CENHOW),r=s.readUInt32LE(O.CENTIM),i=s.readUInt32LE(O.CENCRC),a=s.readUInt32LE(O.CENSIZ),c=s.readUInt32LE(O.CENLEN),d=s.readUInt16LE(O.CENNAM),g=s.readUInt16LE(O.CENEXT),C=s.readUInt16LE(O.CENCOM),E=s.readUInt16LE(O.CENDSK),S=s.readUInt16LE(O.CENATT),l=s.readUInt32LE(O.CENATX),u=s.readUInt32LE(O.CENOFF)},localHeaderToBinary:function(){var s=Buffer.alloc(O.LOCHDR);return s.writeUInt32LE(O.LOCSIG,0),s.writeUInt16LE(e,O.LOCVER),s.writeUInt16LE(t,O.LOCFLG),s.writeUInt16LE(n,O.LOCHOW),s.writeUInt32LE(r,O.LOCTIM),s.writeUInt32LE(i,O.LOCCRC),s.writeUInt32LE(a,O.LOCSIZ),s.writeUInt32LE(c,O.LOCLEN),s.writeUInt16LE(d,O.LOCNAM),s.writeUInt16LE(p.extraLen,O.LOCEXT),s},centralHeaderToBinary:function(){var s=Buffer.alloc(O.CENHDR+d+g+C);return s.writeUInt32LE(O.CENSIG,0),s.writeUInt16LE(o,O.CENVEM),s.writeUInt16LE(e,O.CENVER),s.writeUInt16LE(t,O.CENFLG),s.writeUInt16LE(n,O.CENHOW),s.writeUInt32LE(r,O.CENTIM),s.writeUInt32LE(i,O.CENCRC),s.writeUInt32LE(a,O.CENSIZ),s.writeUInt32LE(c,O.CENLEN),s.writeUInt16LE(d,O.CENNAM),s.writeUInt16LE(g,O.CENEXT),s.writeUInt16LE(C,O.CENCOM),s.writeUInt16LE(E,O.CENDSK),s.writeUInt16LE(S,O.CENATT),s.writeUInt32LE(l,O.CENATX),s.writeUInt32LE(u,O.CENOFF),s},toJSON:function(){let s=function(h){return h+" bytes"};return{made:o,version:e,flags:t,method:j.methodToString(n),time:this.time,crc:"0x"+i.toString(16).toUpperCase(),compressedSize:s(a),size:s(c),fileNameLength:s(d),extraLength:s(g),commentLength:s(C),diskNumStart:E,inAttr:S,attr:l,offset:u,centralHeaderSize:s(O.CENHDR+d+g+C)}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var bt=T((Ei,Ft)=>{"use strict";var J=Y(),v=J.Constants;Ft.exports=function(){var o=0,e=0,t=0,n=0,r=0;return{get diskEntries(){return o},set diskEntries(i){o=e=i},get totalEntries(){return e},set totalEntries(i){e=o=i},get size(){return t},set size(i){t=i},get offset(){return n},set offset(i){n=i},get commentLength(){return r},set commentLength(i){r=i},get mainHeaderSize(){return v.ENDHDR+r},loadFromBinary:function(i){if((i.length!==v.ENDHDR||i.readUInt32LE(0)!==v.ENDSIG)&&(i.length<v.ZIP64HDR||i.readUInt32LE(0)!==v.ZIP64SIG))throw J.Errors.INVALID_END();i.readUInt32LE(0)===v.ENDSIG?(o=i.readUInt16LE(v.ENDSUB),e=i.readUInt16LE(v.ENDTOT),t=i.readUInt32LE(v.ENDSIZ),n=i.readUInt32LE(v.ENDOFF),r=i.readUInt16LE(v.ENDCOM)):(o=J.readBigUInt64LE(i,v.ZIP64SUB),e=J.readBigUInt64LE(i,v.ZIP64TOT),t=J.readBigUInt64LE(i,v.ZIP64SIZE),n=J.readBigUInt64LE(i,v.ZIP64OFF),r=0)},toBinary:function(){var i=Buffer.alloc(v.ENDHDR+r);return i.writeUInt32LE(v.ENDSIG,0),i.writeUInt32LE(0,4),i.writeUInt16LE(o,v.ENDSUB),i.writeUInt16LE(e,v.ENDTOT),i.writeUInt32LE(t,v.ENDSIZ),i.writeUInt32LE(n,v.ENDOFF),i.writeUInt16LE(r,v.ENDCOM),i.fill(" ",v.ENDHDR),i},toJSON:function(){let i=function(a,c){let d=a.toString(16).toUpperCase();for(;d.length<c;)d="0"+d;return"0x"+d};return{diskEntries:o,totalEntries:e,size:t+" bytes",offset:i(n,4),commentLength:r}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var ke=T(Ve=>{"use strict";Ve.EntryHeader=vt();Ve.MainHeader=bt()});var Ht=T((Ci,Rt)=>{"use strict";Rt.exports=function(o){var e=M("zlib"),t={chunkSize:(parseInt(o.length/1024)+1)*1024};return{deflate:function(){return e.deflateRawSync(o,t)},deflateAsync:function(n){var r=e.createDeflateRaw(t),i=[],a=0;r.on("data",function(c){i.push(c),a+=c.length}),r.on("end",function(){var c=Buffer.alloc(a),d=0;c.fill(0);for(var g=0;g<i.length;g++){var C=i[g];C.copy(c,d),d+=C.length}n&&n(c)}),r.end(o)}}}});var Pt=T((yi,Ut)=>{"use strict";var Qn=+(process.versions?process.versions.node:"").split(".")[0]||0;Ut.exports=function(o,e){var t=M("zlib");let n=Qn>=15&&e>0?{maxOutputLength:e}:{};return{inflate:function(){return t.inflateRawSync(o,n)},inflateAsync:function(r){var i=t.createInflateRaw(n),a=[],c=0;i.on("data",function(d){a.push(d),c+=d.length}),i.on("end",function(){var d=Buffer.alloc(c),g=0;d.fill(0);for(var C=0;C<a.length;C++){var E=a[C];E.copy(d,g),g+=E.length}r&&r(d)}),i.end(o)}}}});var Vt=T((Oi,Wt)=>{"use strict";var{randomFillSync:$t}=M("crypto"),er=de(),tr=new Uint32Array(256).map((o,e)=>{for(let t=0;t<8;t++)(e&1)!==0?e=e>>>1^3988292384:e>>>=1;return e>>>0}),Mt=(o,e)=>Math.imul(o,e)>>>0,Bt=(o,e)=>tr[(o^e)&255]^o>>>8,ie=()=>typeof $t=="function"?$t(Buffer.alloc(12)):ie.node();ie.node=()=>{let o=Buffer.alloc(12),e=o.length;for(let t=0;t<e;t++)o[t]=Math.random()*256&255;return o};var me={genSalt:ie};function pe(o){let e=Buffer.isBuffer(o)?o:Buffer.from(o);this.keys=new Uint32Array([305419896,591751049,878082192]);for(let t=0;t<e.length;t++)this.updateKeys(e[t])}pe.prototype.updateKeys=function(o){let e=this.keys;return e[0]=Bt(e[0],o),e[1]+=e[0]&255,e[1]=Mt(e[1],134775813)+1,e[2]=Bt(e[2],e[1]>>>24),o};pe.prototype.next=function(){let o=(this.keys[2]|2)>>>0;return Mt(o,o^1)>>8&255};function nr(o){let e=new pe(o);return function(t){let n=Buffer.alloc(t.length),r=0;for(let i of t)n[r++]=e.updateKeys(i^e.next());return n}}function rr(o){let e=new pe(o);return function(t,n,r=0){n||(n=Buffer.alloc(t.length));for(let i of t){let a=e.next();n[r++]=i^a,e.updateKeys(i)}return n}}function ir(o,e,t){if(!o||!Buffer.isBuffer(o)||o.length<12)return Buffer.alloc(0);let n=nr(t),r=n(o.slice(0,12)),i=(e.flags&8)===8?e.timeHighByte:e.crc>>>24;if(r[11]!==i)throw er.WRONG_PASSWORD();return n(o.slice(12))}function or(o){Buffer.isBuffer(o)&&o.length>=12?me.genSalt=function(){return o.slice(0,12)}:o==="node"?me.genSalt=ie.node:me.genSalt=ie}function sr(o,e,t,n=!1){o==null&&(o=Buffer.alloc(0)),Buffer.isBuffer(o)||(o=Buffer.from(o.toString()));let r=rr(t),i=me.genSalt();i[11]=e.crc>>>24&255,n&&(i[10]=e.crc>>>16&255);let a=Buffer.alloc(o.length+12);return r(i,a),r(o,a,12)}Wt.exports={decrypt:ir,encrypt:sr,_salter:or}});var kt=T(ge=>{"use strict";ge.Deflater=Ht();ge.Inflater=Pt();ge.ZipCrypto=Vt()});var je=T((wi,Gt)=>{"use strict";var L=Y(),ar=ke(),H=L.Constants,Ge=kt();Gt.exports=function(o,e){var t=new ar.EntryHeader,n=Buffer.alloc(0),r=Buffer.alloc(0),i=!1,a=null,c=Buffer.alloc(0),d=Buffer.alloc(0),g=!0;let C=o,E=typeof C.decoder=="object"?C.decoder:L.decoder;g=E.hasOwnProperty("efs")?E.efs:!1;function S(){return!e||!(e instanceof Uint8Array)?Buffer.alloc(0):(d=t.loadLocalHeaderFromBinary(e),e.slice(t.realDataOffset,t.realDataOffset+t.compressedSize))}function l(s){if(!t.flags_desc&&!t.localHeader.flags_desc){if(L.crc32(s)!==t.localHeader.crc)return!1}else{let h={},_=t.realDataOffset+t.compressedSize;if(e.readUInt32LE(_)==H.LOCSIG||e.readUInt32LE(_)==H.CENSIG)throw L.Errors.DESCRIPTOR_NOT_EXIST();if(e.readUInt32LE(_)==H.EXTSIG)h.crc=e.readUInt32LE(_+H.EXTCRC),h.compressedSize=e.readUInt32LE(_+H.EXTSIZ),h.size=e.readUInt32LE(_+H.EXTLEN);else if(e.readUInt16LE(_+12)===19280)h.crc=e.readUInt32LE(_+H.EXTCRC-4),h.compressedSize=e.readUInt32LE(_+H.EXTSIZ-4),h.size=e.readUInt32LE(_+H.EXTLEN-4);else throw L.Errors.DESCRIPTOR_UNKNOWN();if(h.compressedSize!==t.compressedSize||h.size!==t.size||h.crc!==t.crc)throw L.Errors.DESCRIPTOR_FAULTY();if(L.crc32(s)!==h.crc)return!1}return!0}function u(s,h,_){if(typeof h>"u"&&typeof s=="string"&&(_=s,s=void 0),i)return s&&h&&h(Buffer.alloc(0),L.Errors.DIRECTORY_CONTENT_ERROR()),Buffer.alloc(0);var x=S();if(x.length===0)return s&&h&&h(x),x;if(t.encrypted){if(typeof _!="string"&&!Buffer.isBuffer(_))throw L.Errors.INVALID_PASS_PARAM();x=Ge.ZipCrypto.decrypt(x,t,_)}var w=Buffer.alloc(t.size);switch(t.method){case L.Constants.STORED:if(x.copy(w),l(w))return s&&h&&h(w),w;throw s&&h&&h(w,L.Errors.BAD_CRC()),L.Errors.BAD_CRC();case L.Constants.DEFLATED:var D=new Ge.Inflater(x,t.size);if(s)D.inflateAsync(function(I){I.copy(I,0),h&&(l(I)?h(I):h(I,L.Errors.BAD_CRC()))});else{if(D.inflate(w).copy(w,0),!l(w))throw L.Errors.BAD_CRC(`"${E.decode(n)}"`);return w}break;default:throw s&&h&&h(Buffer.alloc(0),L.Errors.UNKNOWN_METHOD()),L.Errors.UNKNOWN_METHOD()}}function p(s,h){if((!a||!a.length)&&Buffer.isBuffer(e))return s&&h&&h(S()),S();if(a.length&&!i){var _;switch(t.method){case L.Constants.STORED:return t.compressedSize=t.size,_=Buffer.alloc(a.length),a.copy(_),s&&h&&h(_),_;default:case L.Constants.DEFLATED:var x=new Ge.Deflater(a);if(s)x.deflateAsync(function(D){_=Buffer.alloc(D.length),t.compressedSize=D.length,D.copy(_),h&&h(_)});else{var w=x.deflate();return t.compressedSize=w.length,w}x=null;break}}else if(s&&h)h(Buffer.alloc(0));else return Buffer.alloc(0)}function f(s,h){return L.readBigUInt64LE(s,h)}function m(s){try{for(var h=0,_,x,w;h+4<s.length;)_=s.readUInt16LE(h),h+=2,x=s.readUInt16LE(h),h+=2,w=s.slice(h,h+x),h+=x,H.ID_ZIP64===_&&y(w)}catch{throw L.Errors.EXTRA_FIELD_PARSE_ERROR()}}function y(s){var h,_,x,w;s.length>=H.EF_ZIP64_SCOMP&&(h=f(s,H.EF_ZIP64_SUNCOMP),t.size===H.EF_ZIP64_OR_32&&(t.size=h)),s.length>=H.EF_ZIP64_RHO&&(_=f(s,H.EF_ZIP64_SCOMP),t.compressedSize===H.EF_ZIP64_OR_32&&(t.compressedSize=_)),s.length>=H.EF_ZIP64_DSN&&(x=f(s,H.EF_ZIP64_RHO),t.offset===H.EF_ZIP64_OR_32&&(t.offset=x)),s.length>=H.EF_ZIP64_DSN+4&&(w=s.readUInt32LE(H.EF_ZIP64_DSN),t.diskNumStart===H.EF_ZIP64_OR_16&&(t.diskNumStart=w))}return{get entryName(){return E.decode(n)},get rawEntryName(){return n},set entryName(s){n=L.toBuffer(s,E.encode);var h=n[n.length-1];i=h===47||h===92,t.fileNameLength=n.length},get efs(){return typeof g=="function"?g(this.entryName):g},get extra(){return c},set extra(s){c=s,t.extraLength=s.length,m(s)},get comment(){return E.decode(r)},set comment(s){if(r=L.toBuffer(s,E.encode),t.commentLength=r.length,r.length>65535)throw L.Errors.COMMENT_TOO_LONG()},get name(){var s=E.decode(n);return i?s.substr(s.length-1).split("/").pop():s.split("/").pop()},get isDirectory(){return i},getCompressedData:function(){return p(!1,null)},getCompressedDataAsync:function(s){p(!0,s)},setData:function(s){a=L.toBuffer(s,L.decoder.encode),!i&&a.length?(t.size=a.length,t.method=L.Constants.DEFLATED,t.crc=L.crc32(s),t.changed=!0):t.method=L.Constants.STORED},getData:function(s){return t.changed?a:u(!1,null,s)},getDataAsync:function(s,h){t.changed?s(a):u(!0,s,h)},set attr(s){t.attr=s},get attr(){return t.attr},set header(s){t.loadFromBinary(s)},get header(){return t},packCentralHeader:function(){t.flags_efs=this.efs,t.extraLength=c.length;var s=t.centralHeaderToBinary(),h=L.Constants.CENHDR;return n.copy(s,h),h+=n.length,c.copy(s,h),h+=t.extraLength,r.copy(s,h),s},packLocalHeader:function(){let s=0;t.flags_efs=this.efs,t.extraLocalLength=d.length;let h=t.localHeaderToBinary(),_=Buffer.alloc(h.length+n.length+t.extraLocalLength);return h.copy(_,s),s+=h.length,n.copy(_,s),s+=n.length,d.copy(_,s),s+=d.length,_},toJSON:function(){let s=function(h){return"<"+(h&&h.length+" bytes buffer"||"null")+">"};return{entryName:this.entryName,name:this.name,comment:this.comment,isDirectory:this.isDirectory,header:t.toJSON(),compressedData:s(e),data:s(a)}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var Zt=T((xi,zt)=>{"use strict";var jt=je(),lr=ke(),$=Y();zt.exports=function(o,e){var t=[],n={},r=Buffer.alloc(0),i=new lr.MainHeader,a=!1,c=null;let d=new Set,g=e,{noSort:C,decoder:E}=g;o?u(g.readEntries):a=!0;function S(){let f=new Set;for(let m of Object.keys(n)){let y=m.split("/");if(y.pop(),!!y.length)for(let s=0;s<y.length;s++){let h=y.slice(0,s+1).join("/")+"/";f.add(h)}}for(let m of f)if(!(m in n)){let y=new jt(g);y.entryName=m,y.attr=16,y.temporary=!0,t.push(y),n[y.entryName]=y,d.add(y)}}function l(){if(a=!0,n={},i.diskEntries>(o.length-i.offset)/$.Constants.CENHDR)throw $.Errors.DISK_ENTRY_TOO_LARGE();t=new Array(i.diskEntries);for(var f=i.offset,m=0;m<t.length;m++){var y=f,s=new jt(g,o);s.header=o.slice(y,y+=$.Constants.CENHDR),s.entryName=o.slice(y,y+=s.header.fileNameLength),s.header.extraLength&&(s.extra=o.slice(y,y+=s.header.extraLength)),s.header.commentLength&&(s.comment=o.slice(y,y+s.header.commentLength)),f+=s.header.centralHeaderSize,t[m]=s,n[s.entryName]=s}d.clear(),S()}function u(f){var m=o.length-$.Constants.ENDHDR,y=Math.max(0,m-65535),s=y,h=o.length,_=-1,x=0;for(typeof g.trailingSpace=="boolean"&&g.trailingSpace&&(y=0),m;m>=s;m--)if(o[m]===80){if(o.readUInt32LE(m)===$.Constants.ENDSIG){_=m,x=m,h=m+$.Constants.ENDHDR,s=m-$.Constants.END64HDR;continue}if(o.readUInt32LE(m)===$.Constants.END64SIG){s=y;continue}if(o.readUInt32LE(m)===$.Constants.ZIP64SIG){_=m,h=m+$.readBigUInt64LE(o,m+$.Constants.ZIP64SIZE)+$.Constants.ZIP64LEAD;break}}if(_==-1)throw $.Errors.INVALID_FORMAT();i.loadFromBinary(o.slice(_,h)),i.commentLength&&(r=o.slice(x+$.Constants.ENDHDR)),f&&l()}function p(){t.length>1&&!C&&t.sort((f,m)=>f.entryName.toLowerCase().localeCompare(m.entryName.toLowerCase()))}return{get entries(){return a||l(),t.filter(f=>!d.has(f))},get comment(){return E.decode(r)},set comment(f){r=$.toBuffer(f,E.encode),i.commentLength=r.length},getEntryCount:function(){return a?t.length:i.diskEntries},forEach:function(f){this.entries.forEach(f)},getEntry:function(f){return a||l(),n[f]||null},setEntry:function(f){a||l(),t.push(f),n[f.entryName]=f,i.totalEntries=t.length},deleteFile:function(f,m=!0){a||l();let y=n[f];this.getEntryChildren(y,m).map(h=>h.entryName).forEach(this.deleteEntry)},deleteEntry:function(f){a||l();let m=n[f],y=t.indexOf(m);y>=0&&(t.splice(y,1),delete n[f],i.totalEntries=t.length)},getEntryChildren:function(f,m=!0){if(a||l(),typeof f=="object")if(f.isDirectory&&m){let y=[],s=f.entryName;for(let h of t)h.entryName.startsWith(s)&&y.push(h);return y}else return[f];return[]},getChildCount:function(f){if(f&&f.isDirectory){let m=this.getEntryChildren(f);return m.includes(f)?m.length-1:m.length}return 0},compressToBuffer:function(){a||l(),p();let f=[],m=[],y=0,s=0;i.size=0,i.offset=0;let h=0;for(let w of this.entries){let D=w.getCompressedData();w.header.offset=s;let I=w.packLocalHeader(),P=I.length+D.length;s+=P,f.push(I),f.push(D);let N=w.packCentralHeader();m.push(N),i.size+=N.length,y+=P+N.length,h++}y+=i.mainHeaderSize,i.offset=s,i.totalEntries=h,s=0;let _=Buffer.alloc(y);for(let w of f)w.copy(_,s),s+=w.length;for(let w of m)w.copy(_,s),s+=w.length;let x=i.toBinary();return r&&r.copy(x,$.Constants.ENDHDR),x.copy(_,s),o=_,a=!1,_},toAsyncBuffer:function(f,m,y,s){try{a||l(),p();let h=[],_=[],x=0,w=0,D=0;i.size=0,i.offset=0;let I=function(P){if(P.length>0){let N=P.shift(),k=N.entryName+N.extra.toString();y&&y(k),N.getCompressedDataAsync(function(B){s&&s(k),N.header.offset=w;let ae=N.packLocalHeader(),Ke=ae.length+B.length;w+=Ke,h.push(ae),h.push(B);let ye=N.packCentralHeader();_.push(ye),i.size+=ye.length,x+=Ke+ye.length,D++,I(P)})}else{x+=i.mainHeaderSize,i.offset=w,i.totalEntries=D,w=0;let N=Buffer.alloc(x);h.forEach(function(B){B.copy(N,w),w+=B.length}),_.forEach(function(B){B.copy(N,w),w+=B.length});let k=i.toBinary();r&&r.copy(k,$.Constants.ENDHDR),k.copy(N,w),o=N,a=!1,f(N)}};I(Array.from(this.entries))}catch(h){m(h)}}}}});var Kt=T((Ai,Xt)=>{"use strict";var b=Y(),F=M("path"),cr=je(),ur=Zt(),q=(...o)=>b.findLast(o,e=>typeof e=="boolean"),qt=(...o)=>b.findLast(o,e=>typeof e=="string"),fr=(...o)=>b.findLast(o,e=>typeof e=="function"),hr={noSort:!1,readEntries:!1,method:b.Constants.NONE,fs:null};Xt.exports=function(o,e){let t=null,n=Object.assign(Object.create(null),hr);o&&typeof o=="object"&&(o instanceof Uint8Array||(Object.assign(n,o),o=n.input?n.input:void 0,n.input&&delete n.input),Buffer.isBuffer(o)&&(t=o,n.method=b.Constants.BUFFER,o=void 0)),Object.assign(n,e);let r=new b(n);if((typeof n.decoder!="object"||typeof n.decoder.encode!="function"||typeof n.decoder.decode!="function")&&(n.decoder=b.decoder),o&&typeof o=="string")if(r.fs.existsSync(o))n.method=b.Constants.FILE,n.filename=o,t=r.fs.readFileSync(o);else throw b.Errors.INVALID_FILENAME();let i=new ur(t,n),{canonical:a,sanitize:c,zipnamefix:d}=b;function g(l){if(l&&i){var u;if(typeof l=="string"&&(u=i.getEntry(F.posix.normalize(l))),typeof l=="object"&&typeof l.entryName<"u"&&typeof l.header<"u"&&(u=i.getEntry(l.entryName)),u)return u}return null}function C(l){let{join:u,normalize:p,sep:f}=F.posix;return u(F.isAbsolute(l)?"/":".",p(f+l.split("\\").join(f)+f))}function E(l){return l instanceof RegExp?(function(u){return function(p){return u.test(p)}})(l):typeof l!="function"?()=>!0:l}let S=(l,u)=>{let p=u.slice(-1);return p=p===r.sep?r.sep:"",F.relative(l,u)+p};return{readFile:function(l,u){var p=g(l);return p&&p.getData(u)||null},childCount:function(l){let u=g(l);if(u)return i.getChildCount(u)},readFileAsync:function(l,u){var p=g(l);p?p.getDataAsync(u):u(null,"getEntry failed for:"+l)},readAsText:function(l,u){var p=g(l);if(p){var f=p.getData();if(f&&f.length)return f.toString(u||"utf8")}return""},readAsTextAsync:function(l,u,p){var f=g(l);f?f.getDataAsync(function(m,y){if(y){u(m,y);return}m&&m.length?u(m.toString(p||"utf8")):u("")}):u("")},deleteFile:function(l,u=!0){var p=g(l);p&&i.deleteFile(p.entryName,u)},deleteEntry:function(l){var u=g(l);u&&i.deleteEntry(u.entryName)},addZipComment:function(l){i.comment=l},getZipComment:function(){return i.comment||""},addZipEntryComment:function(l,u){var p=g(l);p&&(p.comment=u)},getZipEntryComment:function(l){var u=g(l);return u&&u.comment||""},updateFile:function(l,u){var p=g(l);p&&p.setData(u)},addLocalFile:function(l,u,p,f){if(r.fs.existsSync(l)){u=u?C(u):"";let m=F.win32.basename(F.win32.normalize(l));u+=p||m;let y=r.fs.statSync(l),s=y.isFile()?r.fs.readFileSync(l):Buffer.alloc(0);y.isDirectory()&&(u+=r.sep),this.addFile(u,s,f,y)}else throw b.Errors.FILE_NOT_FOUND(l)},addLocalFileAsync:function(l,u){l=typeof l=="object"?l:{localPath:l};let p=F.resolve(l.localPath),{comment:f}=l,{zipPath:m,zipName:y}=l,s=this;r.fs.stat(p,function(h,_){if(h)return u(h,!1);m=m?C(m):"";let x=F.win32.basename(F.win32.normalize(p));if(m+=y||x,_.isFile())r.fs.readFile(p,function(w,D){return w?u(w,!1):(s.addFile(m,D,f,_),setImmediate(u,void 0,!0))});else if(_.isDirectory())return m+=r.sep,s.addFile(m,Buffer.alloc(0),f,_),setImmediate(u,void 0,!0)})},addLocalFolder:function(l,u,p){if(p=E(p),u=u?C(u):"",l=F.normalize(l),r.fs.existsSync(l)){let f=r.findFiles(l),m=this;if(f.length)for(let y of f){let s=F.join(u,S(l,y));p(s)&&m.addLocalFile(y,F.dirname(s))}}else throw b.Errors.FILE_NOT_FOUND(l)},addLocalFolderAsync:function(l,u,p,f){f=E(f),p=p?C(p):"",l=F.normalize(l);var m=this;r.fs.open(l,"r",function(y){if(y&&y.code==="ENOENT")u(void 0,b.Errors.FILE_NOT_FOUND(l));else if(y)u(void 0,y);else{var s=r.findFiles(l),h=-1,_=function(){if(h+=1,h<s.length){var x=s[h],w=S(l,x).split("\\").join("/");w=w.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,""),f(w)?r.fs.stat(x,function(D,I){D&&u(void 0,D),I.isFile()?r.fs.readFile(x,function(P,N){P?u(void 0,P):(m.addFile(p+w,N,"",I),_())}):(m.addFile(p+w+"/",Buffer.alloc(0),"",I),_())}):process.nextTick(()=>{_()})}else u(!0,void 0)};_()}})},addLocalFolderAsync2:function(l,u){let p=this;l=typeof l=="object"?l:{localPath:l},localPath=F.resolve(C(l.localPath));let{zipPath:f,filter:m,namefix:y}=l;m instanceof RegExp?m=(function(_){return function(x){return _.test(x)}})(m):typeof m!="function"&&(m=function(){return!0}),f=f?C(f):"",y=="latin1"&&(y=_=>_.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,"")),typeof y!="function"&&(y=_=>_);let s=_=>F.join(f,y(S(localPath,_))),h=_=>F.win32.basename(F.win32.normalize(y(_)));r.fs.open(localPath,"r",function(_){_&&_.code==="ENOENT"?u(void 0,b.Errors.FILE_NOT_FOUND(localPath)):_?u(void 0,_):r.findFilesAsync(localPath,function(x,w){if(x)return u(x);w=w.filter(D=>m(s(D))),w.length||u(void 0,!1),setImmediate(w.reverse().reduce(function(D,I){return function(P,N){if(P||N===!1)return setImmediate(D,P,!1);p.addLocalFileAsync({localPath:I,zipPath:F.dirname(s(I)),zipName:h(I)},D)}},u))})})},addLocalFolderPromise:function(l,u){return new Promise((p,f)=>{this.addLocalFolderAsync2(Object.assign({localPath:l},u),(m,y)=>{m&&f(m),y&&p(this)})})},addFile:function(l,u,p,f){l=d(l);let m=g(l),y=m!=null;y||(m=new cr(n),m.entryName=l),m.comment=p||"";let s=typeof f=="object"&&f instanceof r.fs.Stats;s&&(m.header.time=f.mtime);var h=m.isDirectory?16:0;let _=m.isDirectory?16384:32768;return s?_|=4095&f.mode:typeof f=="number"?_|=4095&f:_|=m.isDirectory?493:420,h=(h|_<<16)>>>0,m.attr=h,m.setData(u),y||i.setEntry(m),m},getEntries:function(l){return i.password=l,i?i.entries:[]},getEntry:function(l){return g(l)},getEntryCount:function(){return i.getEntryCount()},forEach:function(l){return i.forEach(l)},extractEntryTo:function(l,u,p,f,m,y){f=q(!1,f),m=q(!1,m),p=q(!0,p),y=qt(m,y);var s=g(l);if(!s)throw b.Errors.NO_ENTRY();var h=a(s.entryName),_=c(u,y&&!s.isDirectory?y:p?h:F.basename(h));if(s.isDirectory){var x=i.getEntryChildren(s);return x.forEach(function(I){if(I.isDirectory)return;var P=I.getData();if(!P)throw b.Errors.CANT_EXTRACT_FILE();var N=a(I.entryName),k=c(u,p?N:F.basename(N));let B=m?I.header.fileAttr:void 0;r.writeFileTo(k,P,f,B)}),!0}var w=s.getData(i.password);if(!w)throw b.Errors.CANT_EXTRACT_FILE();if(r.fs.existsSync(_)&&!f)throw b.Errors.CANT_OVERRIDE();let D=m?l.header.fileAttr:void 0;return r.writeFileTo(_,w,f,D),!0},test:function(l){if(!i)return!1;for(var u in i.entries)try{if(u.isDirectory)continue;var p=i.entries[u].getData(l);if(!p)return!1}catch{return!1}return!0},extractAllTo:function(l,u,p,f){if(p=q(!1,p),f=qt(p,f),u=q(!1,u),!i)throw b.Errors.NO_ZIP();i.entries.forEach(function(m){var y=c(l,a(m.entryName));if(m.isDirectory){r.makeDir(y);return}var s=m.getData(f);if(!s)throw b.Errors.CANT_EXTRACT_FILE();let h=p?m.header.fileAttr:void 0;r.writeFileTo(y,s,u,h);try{r.fs.utimesSync(y,m.header.time,m.header.time)}catch{throw b.Errors.CANT_EXTRACT_FILE()}})},extractAllToAsync:function(l,u,p,f){if(f=fr(u,p,f),p=q(!1,p),u=q(!1,u),!f)return new Promise((_,x)=>{this.extractAllToAsync(l,u,p,function(w){w?x(w):_(this)})});if(!i){f(b.Errors.NO_ZIP());return}l=F.resolve(l);let m=_=>c(l,F.normalize(a(_.entryName))),y=(_,x)=>new Error(_+': "'+x+'"'),s=[],h=[];i.entries.forEach(_=>{_.isDirectory?s.push(_):h.push(_)});for(let _ of s){let x=m(_),w=p?_.header.fileAttr:void 0;try{r.makeDir(x),w&&r.fs.chmodSync(x,w),r.fs.utimesSync(x,_.header.time,_.header.time)}catch{f(y("Unable to create folder",x))}}h.reverse().reduce(function(_,x){return function(w){if(w)_(w);else{let D=F.normalize(a(x.entryName)),I=c(l,D);x.getDataAsync(function(P,N){if(N)_(N);else if(!P)_(b.Errors.CANT_EXTRACT_FILE());else{let k=p?x.header.fileAttr:void 0;r.writeFileToAsync(I,P,u,k,function(B){B||_(y("Unable to write file",I)),r.fs.utimes(I,x.header.time,x.header.time,function(ae){ae?_(y("Unable to set times",I)):_()})})}})}}},f)()},writeZip:function(l,u){if(arguments.length===1&&typeof l=="function"&&(u=l,l=""),!l&&n.filename&&(l=n.filename),!!l){var p=i.compressToBuffer();if(p){var f=r.writeFileTo(l,p,!0);typeof u=="function"&&u(f?null:new Error("failed"),"")}}},writeZipPromise:function(l,u){let{overwrite:p,perm:f}=Object.assign({overwrite:!0},u);return new Promise((m,y)=>{!l&&n.filename&&(l=n.filename),l||y("ADM-ZIP: ZIP File Name Missing"),this.toBufferPromise().then(s=>{let h=_=>_?m(_):y("ADM-ZIP: Wasn't able to write zip file");r.writeFileToAsync(l,s,p,f,h)},y)})},toBufferPromise:function(){return new Promise((l,u)=>{i.toAsyncBuffer(l,u)})},toBuffer:function(l,u,p,f){return typeof l=="function"?(i.toAsyncBuffer(l,u,p,f),null):i.compressToBuffer()}}}});import Ce from"path";import{fileURLToPath as Or}from"url";import{styleText as V}from"util";import Sr from"@inquirer/checkbox";var ft=Je(ut(),1),{program:Hr,createCommand:Ur,createArgument:Pr,createOption:$r,CommanderError:Br,InvalidArgumentError:Mr,InvalidOptionArgumentError:Wr,Command:ht,Argument:Vr,Option:kr,Help:Gr}=ft.default;import ee from"fs";import dt from"path";import{fileURLToPath as An}from"url";var In=An(import.meta.url),Ln=dt.dirname(In),te=dt.resolve(Ln,"..","..","generated-profile-name.types.ts"),Dn=o=>o.replace(/(^\w)/g,e=>e.toUpperCase());async function mt({walletName:o,profileName:e}){let t=Dn(o),n=`export type ${t}Profiles = "${e}";`;if(ee.existsSync(te)){let r=ee.readFileSync(te,"utf-8"),i=r.match(new RegExp(`export type ${t}Profiles = ("[^"]+"(?:\\s*\\|\\s*"[^"]+")*)`));if(i){let a=i[0];if(!a.includes(`"${e}"`)){let c=a.concat(` | "${e}"`),d=r.replace(a,c);try{ee.writeFileSync(te,d)}catch(g){console.error("Error updating existing profile name type: ",g)}}}else try{ee.appendFileSync(te,`
|
|
28
|
+
${n}`,{encoding:"utf-8"})}catch(a){console.error("Error appending new profile name type: ",a)}}else try{ee.writeFileSync(te,n)}catch(r){console.error("Error writing new profile name type: ",r)}}import Tn from"path";import{pathToFileURL as vn}from"url";import{styleText as Fn}from"util";import{glob as bn}from"glob";import Nn from"path";function $e(o){let e=Nn.basename(o),t=e.match(/^([a-z0-9_]+)(?:-[a-z0-9_]+)*\.setup\.(?:ts|js|mjs)$/i);if(!t)throw new Error(`Invalid wallet setup filename: ${e} (expected "<name>[ -variant].setup.{ts,js,mjs}")`);return t[1]}var Rn=o=>o.replace(/\\/g,"/"),Hn=o=>`${Rn(Tn.resolve(o))}/**/*.setup.{ts,js,}`;async function Be({walletSetupDir:o,selectedWallets:e}){let t=Hn(o),n=(await bn(t,{dot:!0,absolute:!0,nodir:!0,windowsPathsNoEscape:!0})).sort(),r=e.length===1?e[0]:e,i=["metamask","solflare","petra","meteor","keplr","phantom"];Array.isArray(r)&&r.forEach(g=>{i.includes(g)||console.warn(Fn("magenta",`Unsupported wallet: "${g}". Supported wallets are: ${i.join(", ")}`,{validateStream:!1}))});let c=(r==="all"?n:Array.isArray(r)?n.filter(g=>r.some(C=>g.includes(C))):n.filter(g=>g.includes(r))).map(g=>({filePath:g,walletName:$e(g)}));if(!c.length||c.length===0)throw new Error([`No wallet setup file found at ${o} for wallet: "${e}".`,'Setup files must use a ".setup.{ts,js,mjs}" extension and include a valid wallet name.','Examples: "metamask.setup.ts", "solflare.setup.ts", "phantom.setup.ts", "metamask-connected.setup.ts"'].join(`
|
|
29
|
+
`));return await Promise.all(c.map(async({filePath:g,walletName:C})=>{let S=await import(new URL(vn(g)).href).then(f=>f.default),{fn:l,config:u,password:p}=S;return{walletName:C,fileList:c,config:u,walletPassword:p,setupFunction:l}}))}import z from"fs";import _e from"path";import{styleText as Z}from"util";import{chromium as yr}from"@playwright/test";import Me from"path";import{fileURLToPath as Un}from"url";var Pn=Un(import.meta.url),$n=Me.dirname(Pn),Bn=Me.resolve($n,"..","../.wallet-cache");function ne(o){return Me.resolve(`${Bn}/${o}`)}import{z as fe}from"zod";var Mn=fe.object({id:fe.string(),name:fe.string()}),Wn=fe.array(Mn);async function pt(o,e){let t=await o.newPage();await t.goto("chrome://extensions");let n=await t.evaluate("chrome.management.getAll()"),r=Wn.parse(n),i=r.find(a=>a.name.toLowerCase()===e.toLowerCase());if(!i)throw new Error([`[GetExtensionId] Extension with name ${e} not found.`,`Available extensions: ${r.map(a=>a.name).join(", ")}`].join(`
|
|
30
|
+
`));return await t.close(),i.id}var Et="wallet-setup",gt="13.22.0",re="https://github.com/amaify/chainwright/releases/download/v0.1.0/",Vn=`https://github.com/MetaMask/metamask-extension/releases/download/v${gt}/metamask-chrome-${gt}.zip`,kn=`${re}solflare-wallet-extension-v2.19.1.zip`,Gn=`${re}petra-wallet-extension-v2.2.2.zip`,jn=`${re}phantom-wallet-extension-v26.10.0.zip`,zn=`${re}meteor-wallet-extension-v0.7.0.zip`,Zn=`${re}keplr-wallet-extension-v0.13.3.zip`,he={metamask:{downloadUrl:Vn,extensionName:"MetaMask"},solflare:{downloadUrl:kn,extensionName:"Solflare Wallet"},petra:{downloadUrl:Gn,extensionName:"Petra Aptos Wallet"},phantom:{downloadUrl:jn,extensionName:"Phantom"},meteor:{downloadUrl:zn,extensionName:"Meteor Wallet"},keplr:{downloadUrl:Zn,extensionName:"Keplr"}};var Qt=Je(Kt(),1);import X from"fs";import Ze from"path";import{styleText as oe}from"util";import{createWriteStream as dr}from"fs";import{Readable as mr}from"stream";import{styleText as ze}from"util";import pr from"cli-progress";var gr=12e4;async function Yt({url:o,destination:e}){let t=new AbortController,n=setTimeout(()=>t.abort(),gr),r=await fetch(o,{redirect:"follow",signal:t.signal});r.ok||(console.error(ze("redBright",`\u274C Download failed: HTTP ${r.status}`,{validateStream:!1})),t.abort(),process.exit(1));let i=parseInt(r.headers.get("content-length")||"0",10),a=0,c=mr.fromWeb(r.body);try{let d=new pr.SingleBar({format:`Downloading ${ze("cyan","{bar}",{validateStream:!1})} {percentage}%`,clearOnComplete:!0,barCompleteChar:"\u2588",barIncompleteChar:"\u2591",hideCursor:!0});d.start(i,0,{speed:"N/A"}),await new Promise((g,C)=>{let E=dr(e);c.pipe(E),c.on("data",S=>{a+=S.length,d.update(a)}),E.on("error",C),E.on("finish",()=>{d.stop(),g(void 0)})})}catch(d){console.error(ze("redBright",`\u274C Download failed: ${d}`,{validateStream:!1})),process.exit(1)}finally{clearTimeout(n)}}var Jt=!1;async function en({downloadUrl:o,name:e,force:t}){let n=ne(e),i=he[e].extensionName,a=Ze.join(n,`${e}-extension.zip`),c=Ze.join(n,`${e}-extension`);if(t&&X.existsSync(n)&&(X.rmSync(n,{recursive:!0}),console.info(oe("magenta",`\u{1F9F9} Removed ${i} because of the force flag`,{validateStream:!1}))),X.existsSync(n)||X.mkdir(n,{recursive:!0},g=>{if(g)throw Error("Failed to create cache directory");console.info(`\u2705 ${i} Cache directory created successfully.`)}),X.existsSync(c)?console.info(`\u2705 ${i} Version is downloaded already.`):(console.info(oe("cyanBright",`\u{1F4E5} Downloading ${i} extension...`,{validateStream:!1})),await Yt({url:o,destination:a}),console.info(oe("green",`\u2705 ${e.toUpperCase()} Extension downloaded successfully.`,{validateStream:!1}))),!X.existsSync(c))console.info("\u{1F4E6} Extracting extension..."),new Qt.default(a).extractAllTo(c,!0),console.info(`\u2705 ${i} Extension extracted successfully.`);else{if(Jt)return console.info(oe("magentaBright",`Using the cached ${i} extension for profile creation.`,{validateStream:!1})),c;console.info(oe("yellow",`\u26A0\uFE0F Skipping ${i} cache creation: Cache already exists at ${c}. Use --force to overwrite.`,{validateStream:!1}))}let d=Ze.join(c,"manifest.json");if(!X.existsSync(d))throw new Error(`\u274C (${i}) Invalid extension: manifest.json not found`);return Jt=!0,c}import{styleText as Er}from"util";function qe(o){return new Promise(e=>setTimeout(e,o))}var Ee=20,_r=6e3,tn=4e3;async function Cr(o){return o.pages().find(n=>{try{return n.url().startsWith("chrome-extension://")}catch(r){return console.error("[WaitForExtensionOnLoadPage] Error checking page URL:",r),!1}})}async function nn(o,e){let t=0,n=null;if(e==="meteor")return await o.newPage();for(console.info(`Waiting ${tn}ms for browser to initialize...`),await qe(tn);t<=Ee;)try{if(console.info(`Looking for extension page (attempt ${t+1}/${Ee})...`),t===Ee)throw new Error("Extension page not found after maximum retries");let r=await Cr(o);if(r){console.info(`Found extension page after ${t+1} polling attempts`),n=r;break}r||(t++,console.info(`Extension page not found, retrying (${t}/${Ee})...`),await qe(_r))}catch(r){throw console.error("Error waiting for extension page:",r instanceof Error?r.message:"Unknown error"),new Error(`Extension failed to load properly after ${t} attempts!`)}return console.info(Er("greenBright","\u2705 Extension page is properly loaded and ready",{validateStream:!1})),n}async function Xe({walletName:o,force:e,config:t,fileList:n,walletPassword:r,setupFunction:i}){let{downloadUrl:a,extensionName:c}=he[o],d=ne(o),g=t?.profileName,C=g?`${g}`:"wallet-data",E=_e.resolve(d,"extension-id.txt"),S=_e.resolve(d,"extension-path.txt"),l=_e.resolve(d,"password.txt"),u=_e.resolve(d,C),p=await en({downloadUrl:a,name:o,force:e}),f=[`--disable-extensions-except=${p}`,`--load-extension=${p}`];if(z.existsSync(u)&&n.length>1)throw Error([Z("yellowBright",[`\u274C ${C} directory already exists for ${c}.`,`
|
|
31
|
+
To setup another wallet profile, add a profile name to the wallet setup function.`,Z(["blueBright","italic"],'Example: defineWalletSetup(async ({ context, walletPage }) => { ... }, { profileName: "profile-name" });'),Z("italic","You can also use the --force flag to overwrite the existing cache.")].join(`
|
|
32
|
+
`),{validateStream:!1})].join(`
|
|
33
|
+
`));if(z.existsSync(u))return;let m=await yr.launchPersistentContext(u,{headless:!1,args:f,slowMo:t?.slowMo??0});console.info(Z("magentaBright",`\u{1F9E9}\u{1F680} Starting Chrome extension for ${o.toUpperCase()}`,{validateStream:!1}));let y=await nn(m,o);if(!z.existsSync(E)&&!z.existsSync(S)){let s=await pt(m,c);console.info(Z("magentaBright",`\u{1F194} ${c} extension ID: ${s}`,{validateStream:!1})),z.writeFileSync(E,s,"utf-8"),console.info(Z("cyanBright",`\u{1F4BE} Saved extension ID to: ${E}`,{validateStream:!1})),z.writeFileSync(S,p,"utf-8"),console.info(Z("blueBright",`\u{1F4C1} Saved extension Path to: ${S}`,{validateStream:!1})),z.writeFileSync(l,r,"utf-8"),console.info(Z("yellowBright",`\u{1F511} Saved ${o} password to: ${l}`,{validateStream:!1}))}try{await i({context:m,walletPage:y})}catch(s){await m.close(),z.rmSync(d,{force:!0,recursive:!0}),console.error("Error setting up wallet: ",s.message)}await m.close()}var wr=Or(import.meta.url),xr=Ce.dirname(wr),Ar=Ce.join(xr,"..","tests",Et),se=2;async function Ir(){let o=new ht;o.name(V("yellow","Chainwright")).description(V("green","A CLI tool for setting up wallet cache for E2E testing of web3 applications")).version(V("blue","0.0.0")),o.command("chainwright").argument("[dir]","Directory containing the wallet setup functions",Ce.resolve(Ar)).option("--headless","Build cache in the headless browser mode. Alternatively, set the `HEADLESS` env variable to `true`",!1).option("-f, --force","Force the creation of cache even if it already exists",!1).option("-a, --all","Setup all wallets","all").option("--kp, --keplr","Setup Keplr","keplr").option("-m, --metamask","Setup MetaMask","metamask").option("--mt, --meteor","Setup Meteor","meteor").option("--pt, --petra","Setup Petra","petra").option("--ph, --phantom","Setup Phantom","phantom").option("-s, --solflare","Setup Solflare","solflare").option("--wls, --wallets <wallets...>","Specify wallets to setup (e.g., --wallets keplr metamask)").action(async(e,t)=>{let n=["all","metamask","solflare","petra","meteor","keplr","phantom"],r=Object.keys(t).filter(E=>n.includes(E)?t[E]===!0:!1),i=r.length>0,a=t.wallets,c=a||(i?r:await Sr({message:"Select the wallet you want to setup",choices:[{name:"All",value:"all"},{name:"Keplr",value:"keplr"},{name:"MetaMask",value:"metamask"},{name:"Meteor",value:"meteor"},{name:"Petra",value:"petra"},{name:"Phantom",value:"phantom"},{name:"Solflare",value:"solflare"}],validate:E=>{let S=E.map(l=>l.value);return S.includes("all")&&S.length>1?'Select either "All" or specific wallets, not both.':!0},pageSize:10})),d=e,g=o.commands[0]?.args??[];g[0]&&(d=Ce.resolve(process.cwd(),g[0])),t.headless&&(process.env.HEADLESS=!0);let C=await Be({walletSetupDir:d,selectedWallets:c});for(let{walletName:E,config:S,walletPassword:l,setupFunction:u,fileList:p}of C)try{console.info(V("cyanBright",`
|
|
34
|
+
Setting up cache for ${E}...`,{validateStream:!1})),await Xe({walletName:E,config:S,setupFunction:u,fileList:p,force:t.force,walletPassword:l}),S.profileName&&await mt({walletName:E,profileName:S.profileName})}catch(f){if(f.message.includes("directory already exists")&&console.warn(f.message),!f.message.includes("directory already exists")){console.error(V("redBright",`
|
|
35
|
+
\u274C Failed to setup cache for ${E}: ${f.message}`,{validateStream:!1}));let m=0;for(;se>m;){console.info(`${V("yellow",`Retry Attempt ${m+1} of ${se} for ${E}...`,{validateStream:!1})}`),console.info(V("yellow","Retrying wallet setup...",{validateStream:!1}));try{await Xe({walletName:E,config:S,setupFunction:u,fileList:p,force:t.force,walletPassword:l});break}catch(y){m+1<se&&console.error(V("redBright",`
|
|
36
|
+
\u274C Attempt ${m+1} failed! Retrying...`,{validateStream:!1})),m++,m===se&&console.error(V("redBright",`\u274C Failed to setup cache after ${se} attempts for ${E}: ${y.message}`,{validateStream:!1}))}}}}}),await o.parseAsync(process.argv)}Ir().catch(o=>console.error(V("redBright",`Failed to run the CLI: ${o.message})`,{validateStream:!1})));export{Ir as clientEntry};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { W as WalletSetupFunction, a as WalletSetupConfig } from '../types-dJRYhQT9.js';
|
|
2
|
+
import { Fixtures, TestType } from '@playwright/test';
|
|
3
|
+
|
|
4
|
+
declare function defineWalletSetup(password: string, fn: WalletSetupFunction, config?: WalletSetupConfig): Promise<{
|
|
5
|
+
fn: WalletSetupFunction;
|
|
6
|
+
password: string;
|
|
7
|
+
config: WalletSetupConfig;
|
|
8
|
+
}>;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Builds a Playwright `test` with Chainwright fixtures.
|
|
12
|
+
*
|
|
13
|
+
* Chainwright extends Playwright for Web3 testing, especially wallet flows.
|
|
14
|
+
*
|
|
15
|
+
* @param customFixtures - Extra fixtures to merge into the base test.
|
|
16
|
+
* @returns A composed `test` with Playwright + Chainwright.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* const test = testWithChainwright(myCustomFixtures);
|
|
21
|
+
* test('Web3 test', async ({ page, chainwright }) => {});
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
declare function testWithChainwright<CustomFixtures extends Fixtures>(customFixtures: TestType<CustomFixtures, object>): TestType<CustomFixtures, object>;
|
|
25
|
+
|
|
26
|
+
export { defineWalletSetup, testWithChainwright };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
async function i(t,e,r={}){return{fn:e,password:t,config:r}}import{test as o,mergeTests as s}from"@playwright/test";function n(t){return s(o,t)}export{i as defineWalletSetup,n as testWithChainwright};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { BrowserContext, Page } from '@playwright/test';
|
|
2
|
+
|
|
3
|
+
type Args = {
|
|
4
|
+
context: BrowserContext;
|
|
5
|
+
walletPage: Page;
|
|
6
|
+
};
|
|
7
|
+
type WalletSetupFunction = ({ context, walletPage }: Args) => Promise<void>;
|
|
8
|
+
type WalletSetupConfig = {
|
|
9
|
+
profileName?: string;
|
|
10
|
+
slowMo?: number;
|
|
11
|
+
};
|
|
12
|
+
type WorkerScopeFixtureArgs = {
|
|
13
|
+
slowMo?: number;
|
|
14
|
+
profileName?: string;
|
|
15
|
+
dappUrl?: string;
|
|
16
|
+
};
|
|
17
|
+
type WalletProfileFixtureArgs = {
|
|
18
|
+
slowMo?: number;
|
|
19
|
+
profileName?: string;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export type { WalletSetupFunction as W, WalletSetupConfig as a, WalletProfileFixtureArgs as b, WorkerScopeFixtureArgs as c };
|