cmake-ts
Version:
cmake-js rewrite in typescript to support advanced build configurations
27 lines • 337 kB
JavaScript
#!/usr/bin/env node
"use strict";var tf=Object.create;var uo=Object.defineProperty;var rf=Object.getOwnPropertyDescriptor;var nf=Object.getOwnPropertyNames;var sf=Object.getPrototypeOf,of=Object.prototype.hasOwnProperty;var af=(n,s,o,h)=>{if(s&&typeof s=="object"||typeof s=="function")for(let i of nf(s))!of.call(n,i)&&i!==o&&uo(n,i,{get:()=>s[i],enumerable:!(h=rf(s,i))||h.enumerable});return n};var uf=(n,s,o)=>(o=n!=null?tf(sf(n)):{},af(s||!n||!n.__esModule?uo(o,"default",{value:n,enumerable:!0}):o,n));const Fe=require("events"),Kt=require("child_process"),Q=require("path"),pe=require("fs"),mh=require("process"),lf=require("constants"),qe=require("stream"),Xt=require("util"),ut=require("assert"),We=require("os"),cf=require("url"),hf=require("http"),ff=require("https"),_h=require("string_decoder"),df=require("buffer"),gh=require("zlib"),yh=require("crypto");var or=typeof document<"u"?document.currentScript:null;function pf(n){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const o in n)if(o!=="default"){const h=Object.getOwnPropertyDescriptor(n,o);Object.defineProperty(s,o,h.get?h:{enumerable:!0,get:()=>n[o]})}}return s.default=n,Object.freeze(s)}const vh=pf(Kt);var xe=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function be(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}function mf(n){if(Object.prototype.hasOwnProperty.call(n,"__esModule"))return n;var s=n.default;if(typeof s=="function"){var o=function h(){return this instanceof h?Reflect.construct(s,arguments,this.constructor):s.apply(this,arguments)};o.prototype=s.prototype}else o={};return Object.defineProperty(o,"__esModule",{value:!0}),Object.keys(n).forEach(function(h){var i=Object.getOwnPropertyDescriptor(n,h);Object.defineProperty(o,h,i.get?i:{enumerable:!0,get:function(){return n[h]}})}),o}var Ee={},lt={},ct={},lo;function Zt(){if(lo)return ct;lo=1;class n extends Error{constructor(h,i,t){super(t),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=i,this.exitCode=h,this.nestedError=void 0}}class s extends n{constructor(h){super(1,"commander.invalidArgument",h),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}}return ct.CommanderError=n,ct.InvalidArgumentError=s,ct}var co;function js(){if(co)return lt;co=1;const{InvalidArgumentError:n}=Zt();class s{constructor(i,t){switch(this.description=t||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,i[0]){case"<":this.required=!0,this._name=i.slice(1,-1);break;case"[":this.required=!1,this._name=i.slice(1,-1);break;default:this.required=!0,this._name=i;break}this._name.length>3&&this._name.slice(-3)==="..."&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_concatValue(i,t){return t===this.defaultValue||!Array.isArray(t)?[i]:t.concat(i)}default(i,t){return this.defaultValue=i,this.defaultValueDescription=t,this}argParser(i){return this.parseArg=i,this}choices(i){return this.argChoices=i.slice(),this.parseArg=(t,e)=>{if(!this.argChoices.includes(t))throw new n(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(t,e):t},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}}function o(h){const i=h.name()+(h.variadic===!0?"...":"");return h.required?"<"+i+">":"["+i+"]"}return lt.Argument=s,lt.humanReadableArgName=o,lt}var ht={},ft={},ho;function Eh(){if(ho)return ft;ho=1;const{humanReadableArgName:n}=js();class s{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(i){var t,e;this.helpWidth=(e=(t=this.helpWidth)!=null?t:i.helpWidth)!=null?e:80}visibleCommands(i){const t=i.commands.filter(r=>!r._hidden),e=i._getHelpCommand();return e&&!e._hidden&&t.push(e),this.sortSubcommands&&t.sort((r,u)=>r.name().localeCompare(u.name())),t}compareOptions(i,t){const e=r=>r.short?r.short.replace(/^-/,""):r.long.replace(/^--/,"");return e(i).localeCompare(e(t))}visibleOptions(i){const t=i.options.filter(r=>!r.hidden),e=i._getHelpOption();if(e&&!e.hidden){const r=e.short&&i._findOption(e.short),u=e.long&&i._findOption(e.long);!r&&!u?t.push(e):e.long&&!u?t.push(i.createOption(e.long,e.description)):e.short&&!r&&t.push(i.createOption(e.short,e.description))}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(i){if(!this.showGlobalOptions)return[];const t=[];for(let e=i.parent;e;e=e.parent){const r=e.options.filter(u=>!u.hidden);t.push(...r)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(i){return i._argsDescription&&i.registeredArguments.forEach(t=>{t.description=t.description||i._argsDescription[t.name()]||""}),i.registeredArguments.find(t=>t.description)?i.registeredArguments:[]}subcommandTerm(i){const t=i.registeredArguments.map(e=>n(e)).join(" ");return i._name+(i._aliases[0]?"|"+i._aliases[0]:"")+(i.options.length?" [options]":"")+(t?" "+t:"")}optionTerm(i){return i.flags}argumentTerm(i){return i.name()}longestSubcommandTermLength(i,t){return t.visibleCommands(i).reduce((e,r)=>Math.max(e,this.displayWidth(t.styleSubcommandTerm(t.subcommandTerm(r)))),0)}longestOptionTermLength(i,t){return t.visibleOptions(i).reduce((e,r)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(r)))),0)}longestGlobalOptionTermLength(i,t){return t.visibleGlobalOptions(i).reduce((e,r)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(r)))),0)}longestArgumentTermLength(i,t){return t.visibleArguments(i).reduce((e,r)=>Math.max(e,this.displayWidth(t.styleArgumentTerm(t.argumentTerm(r)))),0)}commandUsage(i){let t=i._name;i._aliases[0]&&(t=t+"|"+i._aliases[0]);let e="";for(let r=i.parent;r;r=r.parent)e=r.name()+" "+e;return e+t+" "+i.usage()}commandDescription(i){return i.description()}subcommandDescription(i){return i.summary()||i.description()}optionDescription(i){const t=[];return i.argChoices&&t.push(`choices: ${i.argChoices.map(e=>JSON.stringify(e)).join(", ")}`),i.defaultValue!==void 0&&(i.required||i.optional||i.isBoolean()&&typeof i.defaultValue=="boolean")&&t.push(`default: ${i.defaultValueDescription||JSON.stringify(i.defaultValue)}`),i.presetArg!==void 0&&i.optional&&t.push(`preset: ${JSON.stringify(i.presetArg)}`),i.envVar!==void 0&&t.push(`env: ${i.envVar}`),t.length>0?`${i.description} (${t.join(", ")})`:i.description}argumentDescription(i){const t=[];if(i.argChoices&&t.push(`choices: ${i.argChoices.map(e=>JSON.stringify(e)).join(", ")}`),i.defaultValue!==void 0&&t.push(`default: ${i.defaultValueDescription||JSON.stringify(i.defaultValue)}`),t.length>0){const e=`(${t.join(", ")})`;return i.description?`${i.description} ${e}`:e}return i.description}formatHelp(i,t){var w;const e=t.padWidth(i,t),r=(w=t.helpWidth)!=null?w:80;function u(S,g){return t.formatItem(S,e,g,t)}let l=[`${t.styleTitle("Usage:")} ${t.styleUsage(t.commandUsage(i))}`,""];const d=t.commandDescription(i);d.length>0&&(l=l.concat([t.boxWrap(t.styleCommandDescription(d),r),""]));const v=t.visibleArguments(i).map(S=>u(t.styleArgumentTerm(t.argumentTerm(S)),t.styleArgumentDescription(t.argumentDescription(S))));v.length>0&&(l=l.concat([t.styleTitle("Arguments:"),...v,""]));const _=t.visibleOptions(i).map(S=>u(t.styleOptionTerm(t.optionTerm(S)),t.styleOptionDescription(t.optionDescription(S))));if(_.length>0&&(l=l.concat([t.styleTitle("Options:"),..._,""])),t.showGlobalOptions){const S=t.visibleGlobalOptions(i).map(g=>u(t.styleOptionTerm(t.optionTerm(g)),t.styleOptionDescription(t.optionDescription(g))));S.length>0&&(l=l.concat([t.styleTitle("Global Options:"),...S,""]))}const R=t.visibleCommands(i).map(S=>u(t.styleSubcommandTerm(t.subcommandTerm(S)),t.styleSubcommandDescription(t.subcommandDescription(S))));return R.length>0&&(l=l.concat([t.styleTitle("Commands:"),...R,""])),l.join(`
`)}displayWidth(i){return o(i).length}styleTitle(i){return i}styleUsage(i){return i.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(i){return this.styleDescriptionText(i)}styleOptionDescription(i){return this.styleDescriptionText(i)}styleSubcommandDescription(i){return this.styleDescriptionText(i)}styleArgumentDescription(i){return this.styleDescriptionText(i)}styleDescriptionText(i){return i}styleOptionTerm(i){return this.styleOptionText(i)}styleSubcommandTerm(i){return i.split(" ").map(t=>t==="[options]"?this.styleOptionText(t):t[0]==="["||t[0]==="<"?this.styleArgumentText(t):this.styleSubcommandText(t)).join(" ")}styleArgumentTerm(i){return this.styleArgumentText(i)}styleOptionText(i){return i}styleArgumentText(i){return i}styleSubcommandText(i){return i}styleCommandText(i){return i}padWidth(i,t){return Math.max(t.longestOptionTermLength(i,t),t.longestGlobalOptionTermLength(i,t),t.longestSubcommandTermLength(i,t),t.longestArgumentTermLength(i,t))}preformatted(i){return/\n[^\S\r\n]/.test(i)}formatItem(i,t,e,r){var S;const l=" ".repeat(2);if(!e)return l+i;const d=i.padEnd(t+i.length-r.displayWidth(i)),v=2,R=((S=this.helpWidth)!=null?S:80)-t-v-2;let w;return R<this.minWidthToWrap||r.preformatted(e)?w=e:w=r.boxWrap(e,R).replace(/\n/g,`
`+" ".repeat(t+v)),l+d+" ".repeat(v)+w.replace(/\n/g,`
${l}`)}boxWrap(i,t){if(t<this.minWidthToWrap)return i;const e=i.split(/\r\n|\n/),r=/[\s]*[^\s]+/g,u=[];return e.forEach(l=>{const d=l.match(r);if(d===null){u.push("");return}let v=[d.shift()],_=this.displayWidth(v[0]);d.forEach(R=>{const w=this.displayWidth(R);if(_+w<=t){v.push(R),_+=w;return}u.push(v.join(""));const S=R.trimStart();v=[S],_=this.displayWidth(S)}),u.push(v.join(""))}),u.join(`
`)}}function o(h){const i=/\x1b\[\d*(;\d*)*m/g;return h.replace(i,"")}return ft.Help=s,ft.stripColor=o,ft}var dt={},fo;function Sh(){if(fo)return dt;fo=1;const{InvalidArgumentError:n}=Zt();class s{constructor(e,r){this.flags=e,this.description=r||"",this.required=e.includes("<"),this.optional=e.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(e),this.mandatory=!1;const u=i(e);this.short=u.shortFlag,this.long=u.longFlag,this.negate=!1,this.long&&(this.negate=this.long.startsWith("--no-")),this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0}default(e,r){return this.defaultValue=e,this.defaultValueDescription=r,this}preset(e){return this.presetArg=e,this}conflicts(e){return this.conflictsWith=this.conflictsWith.concat(e),this}implies(e){let r=e;return typeof e=="string"&&(r={[e]:!0}),this.implied=Object.assign(this.implied||{},r),this}env(e){return this.envVar=e,this}argParser(e){return this.parseArg=e,this}makeOptionMandatory(e=!0){return this.mandatory=!!e,this}hideHelp(e=!0){return this.hidden=!!e,this}_concatValue(e,r){return r===this.defaultValue||!Array.isArray(r)?[e]:r.concat(e)}choices(e){return this.argChoices=e.slice(),this.parseArg=(r,u)=>{if(!this.argChoices.includes(r))throw new n(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(r,u):r},this}name(){return this.long?this.long.replace(/^--/,""):this.short.replace(/^-/,"")}attributeName(){return this.negate?h(this.name().replace(/^no-/,"")):h(this.name())}is(e){return this.short===e||this.long===e}isBoolean(){return!this.required&&!this.optional&&!this.negate}}class o{constructor(e){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,e.forEach(r=>{r.negate?this.negativeOptions.set(r.attributeName(),r):this.positiveOptions.set(r.attributeName(),r)}),this.negativeOptions.forEach((r,u)=>{this.positiveOptions.has(u)&&this.dualOptions.add(u)})}valueFromOption(e,r){const u=r.attributeName();if(!this.dualOptions.has(u))return!0;const l=this.negativeOptions.get(u).presetArg,d=l!==void 0?l:!1;return r.negate===(d===e)}}function h(t){return t.split("-").reduce((e,r)=>e+r[0].toUpperCase()+r.slice(1))}function i(t){let e,r;const u=/^-[^-]$/,l=/^--[^-]/,d=t.split(/[ |,]+/).concat("guard");if(u.test(d[0])&&(e=d.shift()),l.test(d[0])&&(r=d.shift()),!e&&u.test(d[0])&&(e=d.shift()),!e&&l.test(d[0])&&(e=r,r=d.shift()),d[0].startsWith("-")){const v=d[0],_=`option creation failed due to '${v}' in option flags '${t}'`;throw/^-[^-][^-]/.test(v)?new Error(`${_}
- a short flag is a single dash and a single character
- either use a single dash and a single character (for a short flag)
- or use a double dash for a long option (and can have two, like '--ws, --workspace')`):u.test(v)?new Error(`${_}
- too many short flags`):l.test(v)?new Error(`${_}
- too many long flags`):new Error(`${_}
- unrecognised flag format`)}if(e===void 0&&r===void 0)throw new Error(`option creation failed due to no flags found in '${t}'.`);return{shortFlag:e,longFlag:r}}return dt.Option=s,dt.DualOptions=o,dt}var ar={},po;function _f(){if(po)return ar;po=1;const n=3;function s(h,i){if(Math.abs(h.length-i.length)>n)return Math.max(h.length,i.length);const t=[];for(let e=0;e<=h.length;e++)t[e]=[e];for(let e=0;e<=i.length;e++)t[0][e]=e;for(let e=1;e<=i.length;e++)for(let r=1;r<=h.length;r++){let u=1;h[r-1]===i[e-1]?u=0:u=1,t[r][e]=Math.min(t[r-1][e]+1,t[r][e-1]+1,t[r-1][e-1]+u),r>1&&e>1&&h[r-1]===i[e-2]&&h[r-2]===i[e-1]&&(t[r][e]=Math.min(t[r][e],t[r-2][e-2]+1))}return t[h.length][i.length]}function o(h,i){if(!i||i.length===0)return"";i=Array.from(new Set(i));const t=h.startsWith("--");t&&(h=h.slice(2),i=i.map(l=>l.slice(2)));let e=[],r=n;const u=.4;return i.forEach(l=>{if(l.length<=1)return;const d=s(h,l),v=Math.max(h.length,l.length);(v-d)/v>u&&(d<r?(r=d,e=[l]):d===r&&e.push(l))}),e.sort((l,d)=>l.localeCompare(d)),t&&(e=e.map(l=>`--${l}`)),e.length>1?`
(Did you mean one of ${e.join(", ")}?)`:e.length===1?`
(Did you mean ${e[0]}?)`:""}return ar.suggestSimilar=o,ar}var mo;function gf(){if(mo)return ht;mo=1;const n=Fe.EventEmitter,s=Kt,o=Q,h=pe,i=mh,{Argument:t,humanReadableArgName:e}=js(),{CommanderError:r}=Zt(),{Help:u,stripColor:l}=Eh(),{Option:d,DualOptions:v}=Sh(),{suggestSimilar:_}=_f();class R extends n{constructor(a){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=a||"",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:f=>i.stdout.write(f),writeErr:f=>i.stderr.write(f),outputError:(f,c)=>c(f),getOutHelpWidth:()=>i.stdout.isTTY?i.stdout.columns:void 0,getErrHelpWidth:()=>i.stderr.isTTY?i.stderr.columns:void 0,getOutHasColors:()=>{var f,c,m;return(m=S())!=null?m:i.stdout.isTTY&&((c=(f=i.stdout).hasColors)==null?void 0:c.call(f))},getErrHasColors:()=>{var f,c,m;return(m=S())!=null?m:i.stderr.isTTY&&((c=(f=i.stderr).hasColors)==null?void 0:c.call(f))},stripColor:f=>l(f)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={}}copyInheritedSettings(a){return this._outputConfiguration=a._outputConfiguration,this._helpOption=a._helpOption,this._helpCommand=a._helpCommand,this._helpConfiguration=a._helpConfiguration,this._exitCallback=a._exitCallback,this._storeOptionsAsProperties=a._storeOptionsAsProperties,this._combineFlagAndOptionalValue=a._combineFlagAndOptionalValue,this._allowExcessArguments=a._allowExcessArguments,this._enablePositionalOptions=a._enablePositionalOptions,this._showHelpAfterError=a._showHelpAfterError,this._showSuggestionAfterError=a._showSuggestionAfterError,this}_getCommandAndAncestors(){const a=[];for(let f=this;f;f=f.parent)a.push(f);return a}command(a,f,c){let m=f,p=c;typeof m=="object"&&m!==null&&(p=m,m=null),p=p||{};const[,E,y]=a.match(/([^ ]+) *(.*)/),b=this.createCommand(E);return m&&(b.description(m),b._executableHandler=!0),p.isDefault&&(this._defaultCommandName=b._name),b._hidden=!!(p.noHelp||p.hidden),b._executableFile=p.executableFile||null,y&&b.arguments(y),this._registerCommand(b),b.parent=this,b.copyInheritedSettings(this),m?this:b}createCommand(a){return new R(a)}createHelp(){return Object.assign(new u,this.configureHelp())}configureHelp(a){return a===void 0?this._helpConfiguration:(this._helpConfiguration=a,this)}configureOutput(a){return a===void 0?this._outputConfiguration:(Object.assign(this._outputConfiguration,a),this)}showHelpAfterError(a=!0){return typeof a!="string"&&(a=!!a),this._showHelpAfterError=a,this}showSuggestionAfterError(a=!0){return this._showSuggestionAfterError=!!a,this}addCommand(a,f){if(!a._name)throw new Error(`Command passed to .addCommand() must have a name
- specify the name in Command constructor or using .name()`);return f=f||{},f.isDefault&&(this._defaultCommandName=a._name),(f.noHelp||f.hidden)&&(a._hidden=!0),this._registerCommand(a),a.parent=this,a._checkForBrokenPassThrough(),this}createArgument(a,f){return new t(a,f)}argument(a,f,c,m){const p=this.createArgument(a,f);return typeof c=="function"?p.default(m).argParser(c):p.default(c),this.addArgument(p),this}arguments(a){return a.trim().split(/ +/).forEach(f=>{this.argument(f)}),this}addArgument(a){const f=this.registeredArguments.slice(-1)[0];if(f&&f.variadic)throw new Error(`only the last argument can be variadic '${f.name()}'`);if(a.required&&a.defaultValue!==void 0&&a.parseArg===void 0)throw new Error(`a default value for a required argument is never used: '${a.name()}'`);return this.registeredArguments.push(a),this}helpCommand(a,f){if(typeof a=="boolean")return this._addImplicitHelpCommand=a,this;a=a!=null?a:"help [command]";const[,c,m]=a.match(/([^ ]+) *(.*)/),p=f!=null?f:"display help for command",E=this.createCommand(c);return E.helpOption(!1),m&&E.arguments(m),p&&E.description(p),this._addImplicitHelpCommand=!0,this._helpCommand=E,this}addHelpCommand(a,f){return typeof a!="object"?(this.helpCommand(a,f),this):(this._addImplicitHelpCommand=!0,this._helpCommand=a,this)}_getHelpCommand(){var f;return((f=this._addImplicitHelpCommand)!=null?f:this.commands.length&&!this._actionHandler&&!this._findCommand("help"))?(this._helpCommand===void 0&&this.helpCommand(void 0,void 0),this._helpCommand):null}hook(a,f){const c=["preSubcommand","preAction","postAction"];if(!c.includes(a))throw new Error(`Unexpected value for event passed to hook : '${a}'.
Expecting one of '${c.join("', '")}'`);return this._lifeCycleHooks[a]?this._lifeCycleHooks[a].push(f):this._lifeCycleHooks[a]=[f],this}exitOverride(a){return a?this._exitCallback=a:this._exitCallback=f=>{if(f.code!=="commander.executeSubCommandAsync")throw f},this}_exit(a,f,c){this._exitCallback&&this._exitCallback(new r(a,f,c)),i.exit(a)}action(a){const f=c=>{const m=this.registeredArguments.length,p=c.slice(0,m);return this._storeOptionsAsProperties?p[m]=this:p[m]=this.opts(),p.push(this),a.apply(this,p)};return this._actionHandler=f,this}createOption(a,f){return new d(a,f)}_callParseArg(a,f,c,m){try{return a.parseArg(f,c)}catch(p){if(p.code==="commander.invalidArgument"){const E=`${m} ${p.message}`;this.error(E,{exitCode:p.exitCode,code:p.code})}throw p}}_registerOption(a){const f=a.short&&this._findOption(a.short)||a.long&&this._findOption(a.long);if(f){const c=a.long&&this._findOption(a.long)?a.long:a.short;throw new Error(`Cannot add option '${a.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${c}'
- already used by option '${f.flags}'`)}this.options.push(a)}_registerCommand(a){const f=m=>[m.name()].concat(m.aliases()),c=f(a).find(m=>this._findCommand(m));if(c){const m=f(this._findCommand(c)).join("|"),p=f(a).join("|");throw new Error(`cannot add command '${p}' as already have command '${m}'`)}this.commands.push(a)}addOption(a){this._registerOption(a);const f=a.name(),c=a.attributeName();if(a.negate){const p=a.long.replace(/^--no-/,"--");this._findOption(p)||this.setOptionValueWithSource(c,a.defaultValue===void 0?!0:a.defaultValue,"default")}else a.defaultValue!==void 0&&this.setOptionValueWithSource(c,a.defaultValue,"default");const m=(p,E,y)=>{p==null&&a.presetArg!==void 0&&(p=a.presetArg);const b=this.getOptionValue(c);p!==null&&a.parseArg?p=this._callParseArg(a,p,b,E):p!==null&&a.variadic&&(p=a._concatValue(p,b)),p==null&&(a.negate?p=!1:a.isBoolean()||a.optional?p=!0:p=""),this.setOptionValueWithSource(c,p,y)};return this.on("option:"+f,p=>{const E=`error: option '${a.flags}' argument '${p}' is invalid.`;m(p,E,"cli")}),a.envVar&&this.on("optionEnv:"+f,p=>{const E=`error: option '${a.flags}' value '${p}' from env '${a.envVar}' is invalid.`;m(p,E,"env")}),this}_optionEx(a,f,c,m,p){if(typeof f=="object"&&f instanceof d)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");const E=this.createOption(f,c);if(E.makeOptionMandatory(!!a.mandatory),typeof m=="function")E.default(p).argParser(m);else if(m instanceof RegExp){const y=m;m=(b,A)=>{const P=y.exec(b);return P?P[0]:A},E.default(p).argParser(m)}else E.default(m);return this.addOption(E)}option(a,f,c,m){return this._optionEx({},a,f,c,m)}requiredOption(a,f,c,m){return this._optionEx({mandatory:!0},a,f,c,m)}combineFlagAndOptionalValue(a=!0){return this._combineFlagAndOptionalValue=!!a,this}allowUnknownOption(a=!0){return this._allowUnknownOption=!!a,this}allowExcessArguments(a=!0){return this._allowExcessArguments=!!a,this}enablePositionalOptions(a=!0){return this._enablePositionalOptions=!!a,this}passThroughOptions(a=!0){return this._passThroughOptions=!!a,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(a=!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=!!a,this}getOptionValue(a){return this._storeOptionsAsProperties?this[a]:this._optionValues[a]}setOptionValue(a,f){return this.setOptionValueWithSource(a,f,void 0)}setOptionValueWithSource(a,f,c){return this._storeOptionsAsProperties?this[a]=f:this._optionValues[a]=f,this._optionValueSources[a]=c,this}getOptionValueSource(a){return this._optionValueSources[a]}getOptionValueSourceWithGlobals(a){let f;return this._getCommandAndAncestors().forEach(c=>{c.getOptionValueSource(a)!==void 0&&(f=c.getOptionValueSource(a))}),f}_prepareUserArgs(a,f){var m,p;if(a!==void 0&&!Array.isArray(a))throw new Error("first parameter to parse must be array or undefined");if(f=f||{},a===void 0&&f.from===void 0){(m=i.versions)!=null&&m.electron&&(f.from="electron");const E=(p=i.execArgv)!=null?p:[];(E.includes("-e")||E.includes("--eval")||E.includes("-p")||E.includes("--print"))&&(f.from="eval")}a===void 0&&(a=i.argv),this.rawArgs=a.slice();let c;switch(f.from){case void 0:case"node":this._scriptPath=a[1],c=a.slice(2);break;case"electron":i.defaultApp?(this._scriptPath=a[1],c=a.slice(2)):c=a.slice(1);break;case"user":c=a.slice(0);break;case"eval":c=a.slice(1);break;default:throw new Error(`unexpected parse option { from: '${f.from}' }`)}return!this._name&&this._scriptPath&&this.nameFromFilename(this._scriptPath),this._name=this._name||"program",c}parse(a,f){this._prepareForParse();const c=this._prepareUserArgs(a,f);return this._parseCommand([],c),this}async parseAsync(a,f){this._prepareForParse();const c=this._prepareUserArgs(a,f);return await this._parseCommand([],c),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.
- 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(a,f,c){if(h.existsSync(a))return;const m=f?`searched for local subcommand relative to directory '${f}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",p=`'${a}' does not exist
- if '${c}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
- if the default executable name is not suitable, use the executableFile option to supply a custom name or path
- ${m}`;throw new Error(p)}_executeSubCommand(a,f){f=f.slice();let c=!1;const m=[".js",".ts",".tsx",".mjs",".cjs"];function p(P,D){const q=o.resolve(P,D);if(h.existsSync(q))return q;if(m.includes(o.extname(D)))return;const $=m.find(L=>h.existsSync(`${q}${L}`));if($)return`${q}${$}`}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let E=a._executableFile||`${this._name}-${a._name}`,y=this._executableDir||"";if(this._scriptPath){let P;try{P=h.realpathSync(this._scriptPath)}catch{P=this._scriptPath}y=o.resolve(o.dirname(P),y)}if(y){let P=p(y,E);if(!P&&!a._executableFile&&this._scriptPath){const D=o.basename(this._scriptPath,o.extname(this._scriptPath));D!==this._name&&(P=p(y,`${D}-${a._name}`))}E=P||E}c=m.includes(o.extname(E));let b;i.platform!=="win32"?c?(f.unshift(E),f=w(i.execArgv).concat(f),b=s.spawn(i.argv[0],f,{stdio:"inherit"})):b=s.spawn(E,f,{stdio:"inherit"}):(this._checkForMissingExecutable(E,y,a._name),f.unshift(E),f=w(i.execArgv).concat(f),b=s.spawn(i.execPath,f,{stdio:"inherit"})),b.killed||["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach(D=>{i.on(D,()=>{b.killed===!1&&b.exitCode===null&&b.kill(D)})});const A=this._exitCallback;b.on("close",P=>{P=P!=null?P:1,A?A(new r(P,"commander.executeSubCommandAsync","(close)")):i.exit(P)}),b.on("error",P=>{if(P.code==="ENOENT")this._checkForMissingExecutable(E,y,a._name);else if(P.code==="EACCES")throw new Error(`'${E}' not executable`);if(!A)i.exit(1);else{const D=new r(1,"commander.executeSubCommandAsync","(error)");D.nestedError=P,A(D)}}),this.runningCommand=b}_dispatchSubcommand(a,f,c){const m=this._findCommand(a);m||this.help({error:!0}),m._prepareForParse();let p;return p=this._chainOrCallSubCommandHook(p,m,"preSubcommand"),p=this._chainOrCall(p,()=>{if(m._executableHandler)this._executeSubCommand(m,f.concat(c));else return m._parseCommand(f,c)}),p}_dispatchHelpCommand(a){var c,m,p,E;a||this.help();const f=this._findCommand(a);return f&&!f._executableHandler&&f.help(),this._dispatchSubcommand(a,[],[(E=(p=(c=this._getHelpOption())==null?void 0:c.long)!=null?p:(m=this._getHelpOption())==null?void 0:m.short)!=null?E:"--help"])}_checkNumberOfArguments(){this.registeredArguments.forEach((a,f)=>{a.required&&this.args[f]==null&&this.missingArgument(a.name())}),!(this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic)&&this.args.length>this.registeredArguments.length&&this._excessArguments(this.args)}_processArguments(){const a=(c,m,p)=>{let E=m;if(m!==null&&c.parseArg){const y=`error: command-argument value '${m}' is invalid for argument '${c.name()}'.`;E=this._callParseArg(c,m,p,y)}return E};this._checkNumberOfArguments();const f=[];this.registeredArguments.forEach((c,m)=>{let p=c.defaultValue;c.variadic?m<this.args.length?(p=this.args.slice(m),c.parseArg&&(p=p.reduce((E,y)=>a(c,y,E),c.defaultValue))):p===void 0&&(p=[]):m<this.args.length&&(p=this.args[m],c.parseArg&&(p=a(c,p,c.defaultValue))),f[m]=p}),this.processedArgs=f}_chainOrCall(a,f){return a&&a.then&&typeof a.then=="function"?a.then(()=>f()):f()}_chainOrCallHooks(a,f){let c=a;const m=[];return this._getCommandAndAncestors().reverse().filter(p=>p._lifeCycleHooks[f]!==void 0).forEach(p=>{p._lifeCycleHooks[f].forEach(E=>{m.push({hookedCommand:p,callback:E})})}),f==="postAction"&&m.reverse(),m.forEach(p=>{c=this._chainOrCall(c,()=>p.callback(p.hookedCommand,this))}),c}_chainOrCallSubCommandHook(a,f,c){let m=a;return this._lifeCycleHooks[c]!==void 0&&this._lifeCycleHooks[c].forEach(p=>{m=this._chainOrCall(m,()=>p(this,f))}),m}_parseCommand(a,f){const c=this.parseOptions(f);if(this._parseOptionsEnv(),this._parseOptionsImplied(),a=a.concat(c.operands),f=c.unknown,this.args=a.concat(f),a&&this._findCommand(a[0]))return this._dispatchSubcommand(a[0],a.slice(1),f);if(this._getHelpCommand()&&a[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(a[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(f),this._dispatchSubcommand(this._defaultCommandName,a,f);this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName&&this.help({error:!0}),this._outputHelpIfRequested(c.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();const m=()=>{c.unknown.length>0&&this.unknownOption(c.unknown[0])},p=`command:${this.name()}`;if(this._actionHandler){m(),this._processArguments();let E;return E=this._chainOrCallHooks(E,"preAction"),E=this._chainOrCall(E,()=>this._actionHandler(this.processedArgs)),this.parent&&(E=this._chainOrCall(E,()=>{this.parent.emit(p,a,f)})),E=this._chainOrCallHooks(E,"postAction"),E}if(this.parent&&this.parent.listenerCount(p))m(),this._processArguments(),this.parent.emit(p,a,f);else if(a.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",a,f);this.listenerCount("command:*")?this.emit("command:*",a,f):this.commands.length?this.unknownCommand():(m(),this._processArguments())}else this.commands.length?(m(),this.help({error:!0})):(m(),this._processArguments())}_findCommand(a){if(a)return this.commands.find(f=>f._name===a||f._aliases.includes(a))}_findOption(a){return this.options.find(f=>f.is(a))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(a=>{a.options.forEach(f=>{f.mandatory&&a.getOptionValue(f.attributeName())===void 0&&a.missingMandatoryOptionValue(f)})})}_checkForConflictingLocalOptions(){const a=this.options.filter(c=>{const m=c.attributeName();return this.getOptionValue(m)===void 0?!1:this.getOptionValueSource(m)!=="default"});a.filter(c=>c.conflictsWith.length>0).forEach(c=>{const m=a.find(p=>c.conflictsWith.includes(p.attributeName()));m&&this._conflictingOption(c,m)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(a=>{a._checkForConflictingLocalOptions()})}parseOptions(a){const f=[],c=[];let m=f;const p=a.slice();function E(b){return b.length>1&&b[0]==="-"}let y=null;for(;p.length;){const b=p.shift();if(b==="--"){m===c&&m.push(b),m.push(...p);break}if(y&&!E(b)){this.emit(`option:${y.name()}`,b);continue}if(y=null,E(b)){const A=this._findOption(b);if(A){if(A.required){const P=p.shift();P===void 0&&this.optionMissingArgument(A),this.emit(`option:${A.name()}`,P)}else if(A.optional){let P=null;p.length>0&&!E(p[0])&&(P=p.shift()),this.emit(`option:${A.name()}`,P)}else this.emit(`option:${A.name()}`);y=A.variadic?A:null;continue}}if(b.length>2&&b[0]==="-"&&b[1]!=="-"){const A=this._findOption(`-${b[1]}`);if(A){A.required||A.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${A.name()}`,b.slice(2)):(this.emit(`option:${A.name()}`),p.unshift(`-${b.slice(2)}`));continue}}if(/^--[^=]+=/.test(b)){const A=b.indexOf("="),P=this._findOption(b.slice(0,A));if(P&&(P.required||P.optional)){this.emit(`option:${P.name()}`,b.slice(A+1));continue}}if(E(b)&&(m=c),(this._enablePositionalOptions||this._passThroughOptions)&&f.length===0&&c.length===0){if(this._findCommand(b)){f.push(b),p.length>0&&c.push(...p);break}else if(this._getHelpCommand()&&b===this._getHelpCommand().name()){f.push(b),p.length>0&&f.push(...p);break}else if(this._defaultCommandName){c.push(b),p.length>0&&c.push(...p);break}}if(this._passThroughOptions){m.push(b),p.length>0&&m.push(...p);break}m.push(b)}return{operands:f,unknown:c}}opts(){if(this._storeOptionsAsProperties){const a={},f=this.options.length;for(let c=0;c<f;c++){const m=this.options[c].attributeName();a[m]=m===this._versionOptionName?this._version:this[m]}return a}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((a,f)=>Object.assign(a,f.opts()),{})}error(a,f){this._outputConfiguration.outputError(`${a}
`,this._outputConfiguration.writeErr),typeof this._showHelpAfterError=="string"?this._outputConfiguration.writeErr(`${this._showHelpAfterError}
`):this._showHelpAfterError&&(this._outputConfiguration.writeErr(`
`),this.outputHelp({error:!0}));const c=f||{},m=c.exitCode||1,p=c.code||"commander.error";this._exit(m,p,a)}_parseOptionsEnv(){this.options.forEach(a=>{if(a.envVar&&a.envVar in i.env){const f=a.attributeName();(this.getOptionValue(f)===void 0||["default","config","env"].includes(this.getOptionValueSource(f)))&&(a.required||a.optional?this.emit(`optionEnv:${a.name()}`,i.env[a.envVar]):this.emit(`optionEnv:${a.name()}`))}})}_parseOptionsImplied(){const a=new v(this.options),f=c=>this.getOptionValue(c)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(c));this.options.filter(c=>c.implied!==void 0&&f(c.attributeName())&&a.valueFromOption(this.getOptionValue(c.attributeName()),c)).forEach(c=>{Object.keys(c.implied).filter(m=>!f(m)).forEach(m=>{this.setOptionValueWithSource(m,c.implied[m],"implied")})})}missingArgument(a){const f=`error: missing required argument '${a}'`;this.error(f,{code:"commander.missingArgument"})}optionMissingArgument(a){const f=`error: option '${a.flags}' argument missing`;this.error(f,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(a){const f=`error: required option '${a.flags}' not specified`;this.error(f,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(a,f){const c=E=>{const y=E.attributeName(),b=this.getOptionValue(y),A=this.options.find(D=>D.negate&&y===D.attributeName()),P=this.options.find(D=>!D.negate&&y===D.attributeName());return A&&(A.presetArg===void 0&&b===!1||A.presetArg!==void 0&&b===A.presetArg)?A:P||E},m=E=>{const y=c(E),b=y.attributeName();return this.getOptionValueSource(b)==="env"?`environment variable '${y.envVar}'`:`option '${y.flags}'`},p=`error: ${m(a)} cannot be used with ${m(f)}`;this.error(p,{code:"commander.conflictingOption"})}unknownOption(a){if(this._allowUnknownOption)return;let f="";if(a.startsWith("--")&&this._showSuggestionAfterError){let m=[],p=this;do{const E=p.createHelp().visibleOptions(p).filter(y=>y.long).map(y=>y.long);m=m.concat(E),p=p.parent}while(p&&!p._enablePositionalOptions);f=_(a,m)}const c=`error: unknown option '${a}'${f}`;this.error(c,{code:"commander.unknownOption"})}_excessArguments(a){if(this._allowExcessArguments)return;const f=this.registeredArguments.length,c=f===1?"":"s",p=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${f} argument${c} but got ${a.length}.`;this.error(p,{code:"commander.excessArguments"})}unknownCommand(){const a=this.args[0];let f="";if(this._showSuggestionAfterError){const m=[];this.createHelp().visibleCommands(this).forEach(p=>{m.push(p.name()),p.alias()&&m.push(p.alias())}),f=_(a,m)}const c=`error: unknown command '${a}'${f}`;this.error(c,{code:"commander.unknownCommand"})}version(a,f,c){if(a===void 0)return this._version;this._version=a,f=f||"-V, --version",c=c||"output the version number";const m=this.createOption(f,c);return this._versionOptionName=m.attributeName(),this._registerOption(m),this.on("option:"+m.name(),()=>{this._outputConfiguration.writeOut(`${a}
`),this._exit(0,"commander.version",a)}),this}description(a,f){return a===void 0&&f===void 0?this._description:(this._description=a,f&&(this._argsDescription=f),this)}summary(a){return a===void 0?this._summary:(this._summary=a,this)}alias(a){var m;if(a===void 0)return this._aliases[0];let f=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(f=this.commands[this.commands.length-1]),a===f._name)throw new Error("Command alias can't be the same as its name");const c=(m=this.parent)==null?void 0:m._findCommand(a);if(c){const p=[c.name()].concat(c.aliases()).join("|");throw new Error(`cannot add alias '${a}' to command '${this.name()}' as already have command '${p}'`)}return f._aliases.push(a),this}aliases(a){return a===void 0?this._aliases:(a.forEach(f=>this.alias(f)),this)}usage(a){if(a===void 0){if(this._usage)return this._usage;const f=this.registeredArguments.map(c=>e(c));return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?f:[]).join(" ")}return this._usage=a,this}name(a){return a===void 0?this._name:(this._name=a,this)}nameFromFilename(a){return this._name=o.basename(a,o.extname(a)),this}executableDir(a){return a===void 0?this._executableDir:(this._executableDir=a,this)}helpInformation(a){const f=this.createHelp(),c=this._getOutputContext(a);f.prepareContext({error:c.error,helpWidth:c.helpWidth,outputHasColors:c.hasColors});const m=f.formatHelp(this,f);return c.hasColors?m:this._outputConfiguration.stripColor(m)}_getOutputContext(a){a=a||{};const f=!!a.error;let c,m,p;return f?(c=y=>this._outputConfiguration.writeErr(y),m=this._outputConfiguration.getErrHasColors(),p=this._outputConfiguration.getErrHelpWidth()):(c=y=>this._outputConfiguration.writeOut(y),m=this._outputConfiguration.getOutHasColors(),p=this._outputConfiguration.getOutHelpWidth()),{error:f,write:y=>(m||(y=this._outputConfiguration.stripColor(y)),c(y)),hasColors:m,helpWidth:p}}outputHelp(a){var E;let f;typeof a=="function"&&(f=a,a=void 0);const c=this._getOutputContext(a),m={error:c.error,write:c.write,command:this};this._getCommandAndAncestors().reverse().forEach(y=>y.emit("beforeAllHelp",m)),this.emit("beforeHelp",m);let p=this.helpInformation({error:c.error});if(f&&(p=f(p),typeof p!="string"&&!Buffer.isBuffer(p)))throw new Error("outputHelp callback must return a string or a Buffer");c.write(p),(E=this._getHelpOption())!=null&&E.long&&this.emit(this._getHelpOption().long),this.emit("afterHelp",m),this._getCommandAndAncestors().forEach(y=>y.emit("afterAllHelp",m))}helpOption(a,f){var c;return typeof a=="boolean"?(a?this._helpOption=(c=this._helpOption)!=null?c:void 0:this._helpOption=null,this):(a=a!=null?a:"-h, --help",f=f!=null?f:"display help for command",this._helpOption=this.createOption(a,f),this)}_getHelpOption(){return this._helpOption===void 0&&this.helpOption(void 0,void 0),this._helpOption}addHelpOption(a){return this._helpOption=a,this}help(a){var c;this.outputHelp(a);let f=Number((c=i.exitCode)!=null?c:0);f===0&&a&&typeof a!="function"&&a.error&&(f=1),this._exit(f,"commander.help","(outputHelp)")}addHelpText(a,f){const c=["beforeAll","before","after","afterAll"];if(!c.includes(a))throw new Error(`Unexpected value for position to addHelpText.
Expecting one of '${c.join("', '")}'`);const m=`${a}Help`;return this.on(m,p=>{let E;typeof f=="function"?E=f({error:p.error,command:p.command}):E=f,E&&p.write(`${E}
`)}),this}_outputHelpIfRequested(a){const f=this._getHelpOption();f&&a.find(m=>f.is(m))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}}function w(g){return g.map(a=>{if(!a.startsWith("--inspect"))return a;let f,c="127.0.0.1",m="9229",p;return(p=a.match(/^(--inspect(-brk)?)$/))!==null?f=p[1]:(p=a.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(f=p[1],/^\d+$/.test(p[3])?m=p[3]:c=p[3]):(p=a.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(f=p[1],c=p[3],m=p[4]),f&&m!=="0"?`${f}=${c}:${parseInt(m)+1}`:a})}function S(){if(i.env.NO_COLOR||i.env.FORCE_COLOR==="0"||i.env.FORCE_COLOR==="false")return!1;if(i.env.FORCE_COLOR||i.env.CLICOLOR_FORCE!==void 0)return!0}return ht.Command=R,ht.useColor=S,ht}var _o;function yf(){if(_o)return Ee;_o=1;const{Argument:n}=js(),{Command:s}=gf(),{CommanderError:o,InvalidArgumentError:h}=Zt(),{Help:i}=Eh(),{Option:t}=Sh();return Ee.program=new s,Ee.createCommand=e=>new s(e),Ee.createOption=(e,r)=>new t(e,r),Ee.createArgument=(e,r)=>new n(e,r),Ee.Command=s,Ee.Option=t,Ee.Argument=n,Ee.Help=i,Ee.CommanderError=o,Ee.InvalidArgumentError=h,Ee.InvalidOptionArgumentError=h,Ee}var vf=yf();const Ef=be(vf),{program:Ry,createCommand:wy,createArgument:Oy,createOption:by,CommanderError:Ay,InvalidArgumentError:Ty,InvalidOptionArgumentError:Py,Command:Sf,Argument:Cy,Option:Iy,Help:xy}=Ef;function Jt(n){const s=process.env[n];if(typeof s=="string"&&s.length>0&&s!=="undefined"&&s!=="null")return s}class Rf{level=2;setLevel(s="info"){this.level=s==="trace"?4:s==="debug"?3:s==="info"?2:s==="warn"?1:s==="error"?0:-1}error(...s){this.level>=0&&console.error("\x1B[31m[ERROR cmake-ts]\x1B[0m",...s)}warn(...s){this.level>=1&&console.warn("\x1B[33m[WARN cmake-ts]\x1B[0m",...s)}info(...s){this.level>=2&&console.info("\x1B[32m[INFO cmake-ts]\x1B[0m",...s)}log(...s){return this.info(...s)}debug(...s){this.level>=3&&console.debug("\x1B[34m[DEBUG cmake-ts]\x1B[0m",...s)}trace(...s){this.level>=4&&console.trace("\x1B[34m[TRACE cmake-ts]\x1B[0m",...s)}}const ae=new Rf;function wf(n){const s=new Sf("cmake-ts"),o=Jt("CMAKETSDEBUG"),h=o==="true"||o==="1",i={command:{type:"none"}};s.exitOverride(d=>{d.exitCode!==0&&d.code!=="commander.help"&&(ae.error(d),i.command.type="error")}).description("A CMake-based build system for native NodeJS and Electron addons.").usage("[build or help] [options]").option("--logger <level>","Set the log level (trace, debug, info, warn, error, off)",h?"debug":"info").showHelpAfterError(!1).showSuggestionAfterError(!0);const t=s.command("build").description("Build the project").option("--config, --configs <configs...>","\n Named config(s) to build, which could be from default configs or the ones defined in the config file (package.json)\n \n If no config is provided, it will build for the current runtime on the current system with the Release build type\n \n The default configs are combinations of `<Runtime>`, `<BuildType>`, `<Platform>`, and `<Architecture>`.\n \n - `<Runtime>`: the runtime to use\n \n e.g.: `node`, `electron`, `iojs`\n \n - `<BuildType>`: the cmake build type (optimization level)\n \n e.g.: `debug`, `release`, `relwithdebinfo`, or `minsizerel`\n \n - `<Platform>`: the target platform\n \n e.g.: `win32`, `linux`, `darwin`, `aix`, `android`, `freebsd`, `haiku`, `openbsd`, `sunos`, `cygwin`, `netbsd`\n \n - `<Architecture>`: the target architecture\n \n e.g.: `x64`, `arm64`, `ia32`, `arm`, `loong64`, `mips`, `mipsel`, `ppc`, `ppc64`, `riscv64`, `s390`, `s390x`\n \n Any combination of `<BuildType>`, `<Runtime>`, `<Platform>`, and `<Architecture>` is valid. Some examples:\n \n - `release`\n - `debug`\n - `relwithdebinfo`\n - `node-release`\n - `node-debug`\n - `electron-release`\n - `electron-debug`\n - `win32-x64`\n - `win32-x64-debug`\n - `linux-x64-debug`\n - `linux-x64-node-debug`\n - `linux-x64-electron-release`\n - `darwin-x64-node-release`\n - `darwin-arm64-node-release`\n - `darwin-arm64-electron-relwithdebinfo`\n\n To explicitly indicate cross-compilation, prefix the config name with `cross-`:\n\n - `cross-win32-ia32-node-release`\n - `cross-linux-arm64-node-release`\n - `cross-darwin-x64-electron-relwithdebinfo`\n \n You can also define your own configs in the config file (package.json).\n \n - `<ConfigName>`: the name of the config\n \n e.g.: `my-config`\n \n The configs can also be in format of `named-<property>`, which builds the configs that match the property.\n \n - `named-os`: build all the configs in the config file that have the same OS\n - `named-os-dev`: build all the configs in the config file that have the same OS and `dev` is true\n - `named-all`: build all the configs in the config file\n \n \n The configs can be combined with `,` or multiple `--config` flags. They will be merged together.\n",[]).option("--project-name <name>","The name of the built node addon.").option("--addon-subdirectory <subdirectory>","The subdirectory of the package which is being built.").option("--package-directory <directory>","The directory of the package which is being built.").option("--target-directory <directory>","The directory where the binaries will end.").option("--staging-directory <directory>","The directory where intermediate files will end up.").action(()=>{i.command.type="build"}),e={all:!1,nativeonly:!1,osonly:!1,devOsOnly:!1,namedConfigs:void 0};s.command("all",{hidden:!0}).description("(deprecated) Build all configurations. Use `build --configs named-all` instead.").action(()=>{e.all=!0,i.command.type="build"}),s.command("nativeonly",{hidden:!0}).description("(deprecated) Building only for the current runtime. Use `build` instead.").action(()=>{e.nativeonly=!0,i.command.type="build"}),s.command("osonly",{hidden:!0}).description("(deprecated) Building only for the current OS. Use `build --configs named-os` instead.").action(()=>{e.osonly=!0,i.command.type="build"}),s.command("dev-os-only",{hidden:!0}).description("(deprecated) Build only dev OS configurations. Use `build --configs named-os-dev` instead.").action(()=>{e.devOsOnly=!0,i.command.type="build"}),s.command("named-configs <configs...>",{hidden:!0}).description("(deprecated) Build only named configurations. Use `build --configs <configs...>` instead").action(d=>{e.namedConfigs=d,i.command.type="build"}),s.parse(n);const r={...i,...e,...s.opts()};ae.setLevel(r.logger);const u=()=>{ae.debug("args",JSON.stringify(r,null,2))},l=t.opts();return r.command.type==="build"?(Of(l,r),u(),{command:{type:"build",options:l},help:r.help,logger:r.logger}):(u(),r)}function Of(n,s){s.namedConfigs!==void 0&&(n.configs=s.namedConfigs.flatMap(o=>o.split(",")),ae.warn("The --named-configs option is deprecated. Use --configs instead.")),s.nativeonly&&(n.configs.push("release"),ae.warn("The --nativeonly option is deprecated. Use --configs release instead.")),s.osonly&&(n.configs.push("named-os"),ae.warn("The --osonly option is deprecated. Use --configs named-os instead.")),s.devOsOnly&&(n.configs.push("named-os-dev"),ae.warn("The --dev-os-only option is deprecated. Use --configs named-os-dev instead.")),s.all&&(n.configs.push("named-all"),ae.warn("The --all option is deprecated. Use --configs named-all instead."))}var ur={},pt={},go;function Se(){return go||(go=1,pt.fromCallback=function(n){return Object.defineProperty(function(...s){if(typeof s[s.length-1]=="function")n.apply(this,s);else return new Promise((o,h)=>{s.push((i,t)=>i!=null?h(i):o(t)),n.apply(this,s)})},"name",{value:n.name})},pt.fromPromise=function(n){return Object.defineProperty(function(...s){const o=s[s.length-1];if(typeof o!="function")return n.apply(this,s);s.pop(),n.apply(this,s).then(h=>o(null,h),o)},"name",{value:n.name})}),pt}var lr,yo;function bf(){if(yo)return lr;yo=1;var n=lf,s=process.cwd,o=null,h=process.env.GRACEFUL_FS_PLATFORM||process.platform;process.cwd=function(){return o||(o=s.call(process)),o};try{process.cwd()}catch{}if(typeof process.chdir=="function"){var i=process.chdir;process.chdir=function(e){o=null,i.call(process,e)},Object.setPrototypeOf&&Object.setPrototypeOf(process.chdir,i)}lr=t;function t(e){n.hasOwnProperty("O_SYMLINK")&&process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)&&r(e),e.lutimes||u(e),e.chown=v(e.chown),e.fchown=v(e.fchown),e.lchown=v(e.lchown),e.chmod=l(e.chmod),e.fchmod=l(e.fchmod),e.lchmod=l(e.lchmod),e.chownSync=_(e.chownSync),e.fchownSync=_(e.fchownSync),e.lchownSync=_(e.lchownSync),e.chmodSync=d(e.chmodSync),e.fchmodSync=d(e.fchmodSync),e.lchmodSync=d(e.lchmodSync),e.stat=R(e.stat),e.fstat=R(e.fstat),e.lstat=R(e.lstat),e.statSync=w(e.statSync),e.fstatSync=w(e.fstatSync),e.lstatSync=w(e.lstatSync),e.chmod&&!e.lchmod&&(e.lchmod=function(g,a,f){f&&process.nextTick(f)},e.lchmodSync=function(){}),e.chown&&!e.lchown&&(e.lchown=function(g,a,f,c){c&&process.nextTick(c)},e.lchownSync=function(){}),h==="win32"&&(e.rename=typeof e.rename!="function"?e.rename:function(g){function a(f,c,m){var p=Date.now(),E=0;g(f,c,function y(b){if(b&&(b.code==="EACCES"||b.code==="EPERM"||b.code==="EBUSY")&&Date.now()-p<6e4){setTimeout(function(){e.stat(c,function(A,P){A&&A.code==="ENOENT"?g(f,c,y):m(b)})},E),E<100&&(E+=10);return}m&&m(b)})}return Object.setPrototypeOf&&Object.setPrototypeOf(a,g),a}(e.rename)),e.read=typeof e.read!="function"?e.read:function(g){function a(f,c,m,p,E,y){var b;if(y&&typeof y=="function"){var A=0;b=function(P,D,q){if(P&&P.code==="EAGAIN"&&A<10)return A++,g.call(e,f,c,m,p,E,b);y.apply(this,arguments)}}return g.call(e,f,c,m,p,E,b)}return Object.setPrototypeOf&&Object.setPrototypeOf(a,g),a}(e.read),e.readSync=typeof e.readSync!="function"?e.readSync:function(g){return function(a,f,c,m,p){for(var E=0;;)try{return g.call(e,a,f,c,m,p)}catch(y){if(y.code==="EAGAIN"&&E<10){E++;continue}throw y}}}(e.readSync);function r(g){g.lchmod=function(a,f,c){g.open(a,n.O_WRONLY|n.O_SYMLINK,f,function(m,p){if(m){c&&c(m);return}g.fchmod(p,f,function(E){g.close(p,funct