cmake-ts
Version:
cmake-js rewrite in typescript to support advanced build configurations
27 lines • 334 kB
JavaScript
#!/usr/bin/env node
import ef from"node:events";import tf from"node:child_process";import rf from"node:path";import nf from"node:fs";import sf from"node:process";import le,{join as he,sep as of,normalize as af,delimiter as uf,resolve as qe,basename as co,dirname as cf,extname as lf,relative as dh}from"path";import ge,{existsSync as ar}from"fs";import hf from"constants";import ke from"stream";import Zt from"util";import ct from"assert";import lt,{tmpdir as ff}from"os";import*as ph from"child_process";import{execSync as mh}from"child_process";import ze from"events";import df from"url";import pf from"http";import mf from"https";import _h from"string_decoder";import _f from"buffer";import gh from"zlib";import gf from"process";import yh from"crypto";var $e=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ae(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}function yf(i){if(Object.prototype.hasOwnProperty.call(i,"__esModule"))return i;var s=i.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(i).forEach(function(h){var n=Object.getOwnPropertyDescriptor(i,h);Object.defineProperty(o,h,n.get?n:{enumerable:!0,get:function(){return i[h]}})}),o}var Se={},ht={},ft={},lo;function Jt(){if(lo)return ft;lo=1;class i extends Error{constructor(h,n,t){super(t),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=n,this.exitCode=h,this.nestedError=void 0}}class s extends i{constructor(h){super(1,"commander.invalidArgument",h),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}}return ft.CommanderError=i,ft.InvalidArgumentError=s,ft}var ho;function js(){if(ho)return ht;ho=1;const{InvalidArgumentError:i}=Jt();class s{constructor(n,t){switch(this.description=t||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,n[0]){case"<":this.required=!0,this._name=n.slice(1,-1);break;case"[":this.required=!1,this._name=n.slice(1,-1);break;default:this.required=!0,this._name=n;break}this._name.length>3&&this._name.slice(-3)==="..."&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_concatValue(n,t){return t===this.defaultValue||!Array.isArray(t)?[n]:t.concat(n)}default(n,t){return this.defaultValue=n,this.defaultValueDescription=t,this}argParser(n){return this.parseArg=n,this}choices(n){return this.argChoices=n.slice(),this.parseArg=(t,e)=>{if(!this.argChoices.includes(t))throw new i(`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 n=h.name()+(h.variadic===!0?"...":"");return h.required?"<"+n+">":"["+n+"]"}return ht.Argument=s,ht.humanReadableArgName=o,ht}var dt={},pt={},fo;function vh(){if(fo)return pt;fo=1;const{humanReadableArgName:i}=js();class s{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(n){this.helpWidth=this.helpWidth??n.helpWidth??80}visibleCommands(n){const t=n.commands.filter(r=>!r._hidden),e=n._getHelpCommand();return e&&!e._hidden&&t.push(e),this.sortSubcommands&&t.sort((r,u)=>r.name().localeCompare(u.name())),t}compareOptions(n,t){const e=r=>r.short?r.short.replace(/^-/,""):r.long.replace(/^--/,"");return e(n).localeCompare(e(t))}visibleOptions(n){const t=n.options.filter(r=>!r.hidden),e=n._getHelpOption();if(e&&!e.hidden){const r=e.short&&n._findOption(e.short),u=e.long&&n._findOption(e.long);!r&&!u?t.push(e):e.long&&!u?t.push(n.createOption(e.long,e.description)):e.short&&!r&&t.push(n.createOption(e.short,e.description))}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(n){if(!this.showGlobalOptions)return[];const t=[];for(let e=n.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(n){return n._argsDescription&&n.registeredArguments.forEach(t=>{t.description=t.description||n._argsDescription[t.name()]||""}),n.registeredArguments.find(t=>t.description)?n.registeredArguments:[]}subcommandTerm(n){const t=n.registeredArguments.map(e=>i(e)).join(" ");return n._name+(n._aliases[0]?"|"+n._aliases[0]:"")+(n.options.length?" [options]":"")+(t?" "+t:"")}optionTerm(n){return n.flags}argumentTerm(n){return n.name()}longestSubcommandTermLength(n,t){return t.visibleCommands(n).reduce((e,r)=>Math.max(e,this.displayWidth(t.styleSubcommandTerm(t.subcommandTerm(r)))),0)}longestOptionTermLength(n,t){return t.visibleOptions(n).reduce((e,r)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(r)))),0)}longestGlobalOptionTermLength(n,t){return t.visibleGlobalOptions(n).reduce((e,r)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(r)))),0)}longestArgumentTermLength(n,t){return t.visibleArguments(n).reduce((e,r)=>Math.max(e,this.displayWidth(t.styleArgumentTerm(t.argumentTerm(r)))),0)}commandUsage(n){let t=n._name;n._aliases[0]&&(t=t+"|"+n._aliases[0]);let e="";for(let r=n.parent;r;r=r.parent)e=r.name()+" "+e;return e+t+" "+n.usage()}commandDescription(n){return n.description()}subcommandDescription(n){return n.summary()||n.description()}optionDescription(n){const t=[];return n.argChoices&&t.push(`choices: ${n.argChoices.map(e=>JSON.stringify(e)).join(", ")}`),n.defaultValue!==void 0&&(n.required||n.optional||n.isBoolean()&&typeof n.defaultValue=="boolean")&&t.push(`default: ${n.defaultValueDescription||JSON.stringify(n.defaultValue)}`),n.presetArg!==void 0&&n.optional&&t.push(`preset: ${JSON.stringify(n.presetArg)}`),n.envVar!==void 0&&t.push(`env: ${n.envVar}`),t.length>0?`${n.description} (${t.join(", ")})`:n.description}argumentDescription(n){const t=[];if(n.argChoices&&t.push(`choices: ${n.argChoices.map(e=>JSON.stringify(e)).join(", ")}`),n.defaultValue!==void 0&&t.push(`default: ${n.defaultValueDescription||JSON.stringify(n.defaultValue)}`),t.length>0){const e=`(${t.join(", ")})`;return n.description?`${n.description} ${e}`:e}return n.description}formatHelp(n,t){const e=t.padWidth(n,t),r=t.helpWidth??80;function u(w,S){return t.formatItem(w,e,S,t)}let c=[`${t.styleTitle("Usage:")} ${t.styleUsage(t.commandUsage(n))}`,""];const d=t.commandDescription(n);d.length>0&&(c=c.concat([t.boxWrap(t.styleCommandDescription(d),r),""]));const v=t.visibleArguments(n).map(w=>u(t.styleArgumentTerm(t.argumentTerm(w)),t.styleArgumentDescription(t.argumentDescription(w))));v.length>0&&(c=c.concat([t.styleTitle("Arguments:"),...v,""]));const m=t.visibleOptions(n).map(w=>u(t.styleOptionTerm(t.optionTerm(w)),t.styleOptionDescription(t.optionDescription(w))));if(m.length>0&&(c=c.concat([t.styleTitle("Options:"),...m,""])),t.showGlobalOptions){const w=t.visibleGlobalOptions(n).map(S=>u(t.styleOptionTerm(t.optionTerm(S)),t.styleOptionDescription(t.optionDescription(S))));w.length>0&&(c=c.concat([t.styleTitle("Global Options:"),...w,""]))}const R=t.visibleCommands(n).map(w=>u(t.styleSubcommandTerm(t.subcommandTerm(w)),t.styleSubcommandDescription(t.subcommandDescription(w))));return R.length>0&&(c=c.concat([t.styleTitle("Commands:"),...R,""])),c.join(`
`)}displayWidth(n){return o(n).length}styleTitle(n){return n}styleUsage(n){return n.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(n){return this.styleDescriptionText(n)}styleOptionDescription(n){return this.styleDescriptionText(n)}styleSubcommandDescription(n){return this.styleDescriptionText(n)}styleArgumentDescription(n){return this.styleDescriptionText(n)}styleDescriptionText(n){return n}styleOptionTerm(n){return this.styleOptionText(n)}styleSubcommandTerm(n){return n.split(" ").map(t=>t==="[options]"?this.styleOptionText(t):t[0]==="["||t[0]==="<"?this.styleArgumentText(t):this.styleSubcommandText(t)).join(" ")}styleArgumentTerm(n){return this.styleArgumentText(n)}styleOptionText(n){return n}styleArgumentText(n){return n}styleSubcommandText(n){return n}styleCommandText(n){return n}padWidth(n,t){return Math.max(t.longestOptionTermLength(n,t),t.longestGlobalOptionTermLength(n,t),t.longestSubcommandTermLength(n,t),t.longestArgumentTermLength(n,t))}preformatted(n){return/\n[^\S\r\n]/.test(n)}formatItem(n,t,e,r){const c=" ".repeat(2);if(!e)return c+n;const d=n.padEnd(t+n.length-r.displayWidth(n)),v=2,R=(this.helpWidth??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)),c+d+" ".repeat(v)+w.replace(/\n/g,`
${c}`)}boxWrap(n,t){if(t<this.minWidthToWrap)return n;const e=n.split(/\r\n|\n/),r=/[\s]*[^\s]+/g,u=[];return e.forEach(c=>{const d=c.match(r);if(d===null){u.push("");return}let v=[d.shift()],m=this.displayWidth(v[0]);d.forEach(R=>{const w=this.displayWidth(R);if(m+w<=t){v.push(R),m+=w;return}u.push(v.join(""));const S=R.trimStart();v=[S],m=this.displayWidth(S)}),u.push(v.join(""))}),u.join(`
`)}}function o(h){const n=/\x1b\[\d*(;\d*)*m/g;return h.replace(n,"")}return pt.Help=s,pt.stripColor=o,pt}var mt={},po;function Eh(){if(po)return mt;po=1;const{InvalidArgumentError:i}=Jt();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=n(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 i(`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 c=this.negativeOptions.get(u).presetArg,d=c!==void 0?c:!1;return r.negate===(d===e)}}function h(t){return t.split("-").reduce((e,r)=>e+r[0].toUpperCase()+r.slice(1))}function n(t){let e,r;const u=/^-[^-]$/,c=/^--[^-]/,d=t.split(/[ |,]+/).concat("guard");if(u.test(d[0])&&(e=d.shift()),c.test(d[0])&&(r=d.shift()),!e&&u.test(d[0])&&(e=d.shift()),!e&&c.test(d[0])&&(e=r,r=d.shift()),d[0].startsWith("-")){const v=d[0],m=`option creation failed due to '${v}' in option flags '${t}'`;throw/^-[^-][^-]/.test(v)?new Error(`${m}
- 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(`${m}
- too many short flags`):c.test(v)?new Error(`${m}
- too many long flags`):new Error(`${m}
- 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 mt.Option=s,mt.DualOptions=o,mt}var ur={},mo;function vf(){if(mo)return ur;mo=1;const i=3;function s(h,n){if(Math.abs(h.length-n.length)>i)return Math.max(h.length,n.length);const t=[];for(let e=0;e<=h.length;e++)t[e]=[e];for(let e=0;e<=n.length;e++)t[0][e]=e;for(let e=1;e<=n.length;e++)for(let r=1;r<=h.length;r++){let u=1;h[r-1]===n[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]===n[e-2]&&h[r-2]===n[e-1]&&(t[r][e]=Math.min(t[r][e],t[r-2][e-2]+1))}return t[h.length][n.length]}function o(h,n){if(!n||n.length===0)return"";n=Array.from(new Set(n));const t=h.startsWith("--");t&&(h=h.slice(2),n=n.map(c=>c.slice(2)));let e=[],r=i;const u=.4;return n.forEach(c=>{if(c.length<=1)return;const d=s(h,c),v=Math.max(h.length,c.length);(v-d)/v>u&&(d<r?(r=d,e=[c]):d===r&&e.push(c))}),e.sort((c,d)=>c.localeCompare(d)),t&&(e=e.map(c=>`--${c}`)),e.length>1?`
(Did you mean one of ${e.join(", ")}?)`:e.length===1?`
(Did you mean ${e[0]}?)`:""}return ur.suggestSimilar=o,ur}var _o;function Ef(){if(_o)return dt;_o=1;const i=ef.EventEmitter,s=tf,o=rf,h=nf,n=sf,{Argument:t,humanReadableArgName:e}=js(),{CommanderError:r}=Jt(),{Help:u,stripColor:c}=vh(),{Option:d,DualOptions:v}=Eh(),{suggestSimilar:m}=vf();class R extends i{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=>n.stdout.write(f),writeErr:f=>n.stderr.write(f),outputError:(f,l)=>l(f),getOutHelpWidth:()=>n.stdout.isTTY?n.stdout.columns:void 0,getErrHelpWidth:()=>n.stderr.isTTY?n.stderr.columns:void 0,getOutHasColors:()=>S()??(n.stdout.isTTY&&n.stdout.hasColors?.()),getErrHasColors:()=>S()??(n.stderr.isTTY&&n.stderr.hasColors?.()),stripColor:f=>c(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,l){let _=f,p=l;typeof _=="object"&&_!==null&&(p=_,_=null),p=p||{};const[,E,y]=a.match(/([^ ]+) *(.*)/),b=this.createCommand(E);return _&&(b.description(_),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),_?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,l,_){const p=this.createArgument(a,f);return typeof l=="function"?p.default(_).argParser(l):p.default(l),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??"help [command]";const[,l,_]=a.match(/([^ ]+) *(.*)/),p=f??"display help for command",E=this.createCommand(l);return E.helpOption(!1),_&&E.arguments(_),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(){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(a,f){const l=["preSubcommand","preAction","postAction"];if(!l.includes(a))throw new Error(`Unexpected value for event passed to hook : '${a}'.
Expecting one of '${l.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,l){this._exitCallback&&this._exitCallback(new r(a,f,l)),n.exit(a)}action(a){const f=l=>{const _=this.registeredArguments.length,p=l.slice(0,_);return this._storeOptionsAsProperties?p[_]=this:p[_]=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,l,_){try{return a.parseArg(f,l)}catch(p){if(p.code==="commander.invalidArgument"){const E=`${_} ${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 l=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 '${l}'
- already used by option '${f.flags}'`)}this.options.push(a)}_registerCommand(a){const f=_=>[_.name()].concat(_.aliases()),l=f(a).find(_=>this._findCommand(_));if(l){const _=f(this._findCommand(l)).join("|"),p=f(a).join("|");throw new Error(`cannot add command '${p}' as already have command '${_}'`)}this.commands.push(a)}addOption(a){this._registerOption(a);const f=a.name(),l=a.attributeName();if(a.negate){const p=a.long.replace(/^--no-/,"--");this._findOption(p)||this.setOptionValueWithSource(l,a.defaultValue===void 0?!0:a.defaultValue,"default")}else a.defaultValue!==void 0&&this.setOptionValueWithSource(l,a.defaultValue,"default");const _=(p,E,y)=>{p==null&&a.presetArg!==void 0&&(p=a.presetArg);const b=this.getOptionValue(l);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(l,p,y)};return this.on("option:"+f,p=>{const E=`error: option '${a.flags}' argument '${p}' is invalid.`;_(p,E,"cli")}),a.envVar&&this.on("optionEnv:"+f,p=>{const E=`error: option '${a.flags}' value '${p}' from env '${a.envVar}' is invalid.`;_(p,E,"env")}),this}_optionEx(a,f,l,_,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,l);if(E.makeOptionMandatory(!!a.mandatory),typeof _=="function")E.default(p).argParser(_);else if(_ instanceof RegExp){const y=_;_=(b,A)=>{const P=y.exec(b);return P?P[0]:A},E.default(p).argParser(_)}else E.default(_);return this.addOption(E)}option(a,f,l,_){return this._optionEx({},a,f,l,_)}requiredOption(a,f,l,_){return this._optionEx({mandatory:!0},a,f,l,_)}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,l){return this._storeOptionsAsProperties?this[a]=f:this._optionValues[a]=f,this._optionValueSources[a]=l,this}getOptionValueSource(a){return this._optionValueSources[a]}getOptionValueSourceWithGlobals(a){let f;return this._getCommandAndAncestors().forEach(l=>{l.getOptionValueSource(a)!==void 0&&(f=l.getOptionValueSource(a))}),f}_prepareUserArgs(a,f){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){n.versions?.electron&&(f.from="electron");const _=n.execArgv??[];(_.includes("-e")||_.includes("--eval")||_.includes("-p")||_.includes("--print"))&&(f.from="eval")}a===void 0&&(a=n.argv),this.rawArgs=a.slice();let l;switch(f.from){case void 0:case"node":this._scriptPath=a[1],l=a.slice(2);break;case"electron":n.defaultApp?(this._scriptPath=a[1],l=a.slice(2)):l=a.slice(1);break;case"user":l=a.slice(0);break;case"eval":l=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",l}parse(a,f){this._prepareForParse();const l=this._prepareUserArgs(a,f);return this._parseCommand([],l),this}async parseAsync(a,f){this._prepareForParse();const l=this._prepareUserArgs(a,f);return await this._parseCommand([],l),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,l){if(h.existsSync(a))return;const _=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 '${l}' 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
- ${_}`;throw new Error(p)}_executeSubCommand(a,f){f=f.slice();let l=!1;const _=[".js",".ts",".tsx",".mjs",".cjs"];function p(P,D){const q=o.resolve(P,D);if(h.existsSync(q))return q;if(_.includes(o.extname(D)))return;const $=_.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}l=_.includes(o.extname(E));let b;n.platform!=="win32"?l?(f.unshift(E),f=w(n.execArgv).concat(f),b=s.spawn(n.argv[0],f,{stdio:"inherit"})):b=s.spawn(E,f,{stdio:"inherit"}):(this._checkForMissingExecutable(E,y,a._name),f.unshift(E),f=w(n.execArgv).concat(f),b=s.spawn(n.execPath,f,{stdio:"inherit"})),b.killed||["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach(D=>{n.on(D,()=>{b.killed===!1&&b.exitCode===null&&b.kill(D)})});const A=this._exitCallback;b.on("close",P=>{P=P??1,A?A(new r(P,"commander.executeSubCommandAsync","(close)")):n.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)n.exit(1);else{const D=new r(1,"commander.executeSubCommandAsync","(error)");D.nestedError=P,A(D)}}),this.runningCommand=b}_dispatchSubcommand(a,f,l){const _=this._findCommand(a);_||this.help({error:!0}),_._prepareForParse();let p;return p=this._chainOrCallSubCommandHook(p,_,"preSubcommand"),p=this._chainOrCall(p,()=>{if(_._executableHandler)this._executeSubCommand(_,f.concat(l));else return _._parseCommand(f,l)}),p}_dispatchHelpCommand(a){a||this.help();const f=this._findCommand(a);return f&&!f._executableHandler&&f.help(),this._dispatchSubcommand(a,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--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=(l,_,p)=>{let E=_;if(_!==null&&l.parseArg){const y=`error: command-argument value '${_}' is invalid for argument '${l.name()}'.`;E=this._callParseArg(l,_,p,y)}return E};this._checkNumberOfArguments();const f=[];this.registeredArguments.forEach((l,_)=>{let p=l.defaultValue;l.variadic?_<this.args.length?(p=this.args.slice(_),l.parseArg&&(p=p.reduce((E,y)=>a(l,y,E),l.defaultValue))):p===void 0&&(p=[]):_<this.args.length&&(p=this.args[_],l.parseArg&&(p=a(l,p,l.defaultValue))),f[_]=p}),this.processedArgs=f}_chainOrCall(a,f){return a&&a.then&&typeof a.then=="function"?a.then(()=>f()):f()}_chainOrCallHooks(a,f){let l=a;const _=[];return this._getCommandAndAncestors().reverse().filter(p=>p._lifeCycleHooks[f]!==void 0).forEach(p=>{p._lifeCycleHooks[f].forEach(E=>{_.push({hookedCommand:p,callback:E})})}),f==="postAction"&&_.reverse(),_.forEach(p=>{l=this._chainOrCall(l,()=>p.callback(p.hookedCommand,this))}),l}_chainOrCallSubCommandHook(a,f,l){let _=a;return this._lifeCycleHooks[l]!==void 0&&this._lifeCycleHooks[l].forEach(p=>{_=this._chainOrCall(_,()=>p(this,f))}),_}_parseCommand(a,f){const l=this.parseOptions(f);if(this._parseOptionsEnv(),this._parseOptionsImplied(),a=a.concat(l.operands),f=l.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(l.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();const _=()=>{l.unknown.length>0&&this.unknownOption(l.unknown[0])},p=`command:${this.name()}`;if(this._actionHandler){_(),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))_(),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():(_(),this._processArguments())}else this.commands.length?(_(),this.help({error:!0})):(_(),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(l=>{const _=l.attributeName();return this.getOptionValue(_)===void 0?!1:this.getOptionValueSource(_)!=="default"});a.filter(l=>l.conflictsWith.length>0).forEach(l=>{const _=a.find(p=>l.conflictsWith.includes(p.attributeName()));_&&this._conflictingOption(l,_)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(a=>{a._checkForConflictingLocalOptions()})}parseOptions(a){const f=[],l=[];let _=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==="--"){_===l&&_.push(b),_.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)&&(_=l),(this._enablePositionalOptions||this._passThroughOptions)&&f.length===0&&l.length===0){if(this._findCommand(b)){f.push(b),p.length>0&&l.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){l.push(b),p.length>0&&l.push(...p);break}}if(this._passThroughOptions){_.push(b),p.length>0&&_.push(...p);break}_.push(b)}return{operands:f,unknown:l}}opts(){if(this._storeOptionsAsProperties){const a={},f=this.options.length;for(let l=0;l<f;l++){const _=this.options[l].attributeName();a[_]=_===this._versionOptionName?this._version:this[_]}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 l=f||{},_=l.exitCode||1,p=l.code||"commander.error";this._exit(_,p,a)}_parseOptionsEnv(){this.options.forEach(a=>{if(a.envVar&&a.envVar in n.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()}`,n.env[a.envVar]):this.emit(`optionEnv:${a.name()}`))}})}_parseOptionsImplied(){const a=new v(this.options),f=l=>this.getOptionValue(l)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(l));this.options.filter(l=>l.implied!==void 0&&f(l.attributeName())&&a.valueFromOption(this.getOptionValue(l.attributeName()),l)).forEach(l=>{Object.keys(l.implied).filter(_=>!f(_)).forEach(_=>{this.setOptionValueWithSource(_,l.implied[_],"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 l=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},_=E=>{const y=l(E),b=y.attributeName();return this.getOptionValueSource(b)==="env"?`environment variable '${y.envVar}'`:`option '${y.flags}'`},p=`error: ${_(a)} cannot be used with ${_(f)}`;this.error(p,{code:"commander.conflictingOption"})}unknownOption(a){if(this._allowUnknownOption)return;let f="";if(a.startsWith("--")&&this._showSuggestionAfterError){let _=[],p=this;do{const E=p.createHelp().visibleOptions(p).filter(y=>y.long).map(y=>y.long);_=_.concat(E),p=p.parent}while(p&&!p._enablePositionalOptions);f=m(a,_)}const l=`error: unknown option '${a}'${f}`;this.error(l,{code:"commander.unknownOption"})}_excessArguments(a){if(this._allowExcessArguments)return;const f=this.registeredArguments.length,l=f===1?"":"s",p=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${f} argument${l} but got ${a.length}.`;this.error(p,{code:"commander.excessArguments"})}unknownCommand(){const a=this.args[0];let f="";if(this._showSuggestionAfterError){const _=[];this.createHelp().visibleCommands(this).forEach(p=>{_.push(p.name()),p.alias()&&_.push(p.alias())}),f=m(a,_)}const l=`error: unknown command '${a}'${f}`;this.error(l,{code:"commander.unknownCommand"})}version(a,f,l){if(a===void 0)return this._version;this._version=a,f=f||"-V, --version",l=l||"output the version number";const _=this.createOption(f,l);return this._versionOptionName=_.attributeName(),this._registerOption(_),this.on("option:"+_.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){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 l=this.parent?._findCommand(a);if(l){const _=[l.name()].concat(l.aliases()).join("|");throw new Error(`cannot add alias '${a}' to command '${this.name()}' as already have command '${_}'`)}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(l=>e(l));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(),l=this._getOutputContext(a);f.prepareContext({error:l.error,helpWidth:l.helpWidth,outputHasColors:l.hasColors});const _=f.formatHelp(this,f);return l.hasColors?_:this._outputConfiguration.stripColor(_)}_getOutputContext(a){a=a||{};const f=!!a.error;let l,_,p;return f?(l=y=>this._outputConfiguration.writeErr(y),_=this._outputConfiguration.getErrHasColors(),p=this._outputConfiguration.getErrHelpWidth()):(l=y=>this._outputConfiguration.writeOut(y),_=this._outputConfiguration.getOutHasColors(),p=this._outputConfiguration.getOutHelpWidth()),{error:f,write:y=>(_||(y=this._outputConfiguration.stripColor(y)),l(y)),hasColors:_,helpWidth:p}}outputHelp(a){let f;typeof a=="function"&&(f=a,a=void 0);const l=this._getOutputContext(a),_={error:l.error,write:l.write,command:this};this._getCommandAndAncestors().reverse().forEach(E=>E.emit("beforeAllHelp",_)),this.emit("beforeHelp",_);let p=this.helpInformation({error:l.error});if(f&&(p=f(p),typeof p!="string"&&!Buffer.isBuffer(p)))throw new Error("outputHelp callback must return a string or a Buffer");l.write(p),this._getHelpOption()?.long&&this.emit(this._getHelpOption().long),this.emit("afterHelp",_),this._getCommandAndAncestors().forEach(E=>E.emit("afterAllHelp",_))}helpOption(a,f){return typeof a=="boolean"?(a?this._helpOption=this._helpOption??void 0:this._helpOption=null,this):(a=a??"-h, --help",f=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){this.outputHelp(a);let f=Number(n.exitCode??0);f===0&&a&&typeof a!="function"&&a.error&&(f=1),this._exit(f,"commander.help","(outputHelp)")}addHelpText(a,f){const l=["beforeAll","before","after","afterAll"];if(!l.includes(a))throw new Error(`Unexpected value for position to addHelpText.
Expecting one of '${l.join("', '")}'`);const _=`${a}Help`;return this.on(_,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(_=>f.is(_))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}}function w(g){return g.map(a=>{if(!a.startsWith("--inspect"))return a;let f,l="127.0.0.1",_="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])?_=p[3]:l=p[3]):(p=a.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(f=p[1],l=p[3],_=p[4]),f&&_!=="0"?`${f}=${l}:${parseInt(_)+1}`:a})}function S(){if(n.env.NO_COLOR||n.env.FORCE_COLOR==="0"||n.env.FORCE_COLOR==="false")return!1;if(n.env.FORCE_COLOR||n.env.CLICOLOR_FORCE!==void 0)return!0}return dt.Command=R,dt.useColor=S,dt}var go;function Sf(){if(go)return Se;go=1;const{Argument:i}=js(),{Command:s}=Ef(),{CommanderError:o,InvalidArgumentError:h}=Jt(),{Help:n}=vh(),{Option:t}=Eh();return Se.program=new s,Se.createCommand=e=>new s(e),Se.createOption=(e,r)=>new t(e,r),Se.createArgument=(e,r)=>new i(e,r),Se.Command=s,Se.Option=t,Se.Argument=i,Se.Help=n,Se.CommanderError=o,Se.InvalidArgumentError=h,Se.InvalidOptionArgumentError=h,Se}var Rf=Sf();const wf=Ae(Rf),{program:Wy,createCommand:zy,createArgument:Yy,createOption:Ky,CommanderError:Xy,InvalidArgumentError:Zy,InvalidOptionArgumentError:Jy,Command:Of,Argument:Qy,Option:ev,Help:tv}=wf;function Qt(i){const s=process.env[i];if(typeof s=="string"&&s.length>0&&s!=="undefined"&&s!=="null")return s}class bf{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 se=new bf;function Af(i){const s=new Of("cmake-ts"),o=Qt("CMAKETSDEBUG"),h=o==="true"||o==="1",n={command:{type:"none"}};s.exitOverride(d=>{d.exitCode!==0&&d.code!=="commander.help"&&(se.error(d),n.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(()=>{n.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,n.command.type="build"}),s.command("nativeonly",{hidden:!0}).description("(deprecated) Building only for the current runtime. Use `build` instead.").action(()=>{e.nativeonly=!0,n.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,n.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,n.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,n.command.type="build"}),s.parse(i);const r={...n,...e,...s.opts()};se.setLevel(r.logger);const u=()=>{se.debug("args",JSON.stringify(r,null,2))},c=t.opts();return r.command.type==="build"?(Tf(c,r),u(),{command:{type:"build",options:c},help:r.help,logger:r.logger}):(u(),r)}function Tf(i,s){s.namedConfigs!==void 0&&(i.configs=s.namedConfigs.flatMap(o=>o.split(",")),se.warn("The --named-configs option is deprecated. Use --configs instead.")),s.nativeonly&&(i.configs.push("release"),se.warn("The --nativeonly option is deprecated. Use --configs release instead.")),s.osonly&&(i.configs.push("named-os"),se.warn("The --osonly option is deprecated. Use --configs named-os instead.")),s.devOsOnly&&(i.configs.push("named-os-dev"),se.warn("The --dev-os-only option is deprecated. Use --configs named-os-dev instead.")),s.all&&(i.configs.push("named-all"),se.warn("The --all option is deprecated. Use --configs named-all instead."))}var cr={},_t={},yo;function Re(){return yo||(yo=1,_t.fromCallback=function(i){return Object.defineProperty(function(...s){if(typeof s[s.length-1]=="function")i.apply(this,s);else return new Promise((o,h)=>{s.push((n,t)=>n!=null?h(n):o(t)),i.apply(this,s)})},"name",{value:i.name})},_t.fromPromise=function(i){return Object.defineProperty(function(...s){const o=s[s.length-1];if(typeof o!="function")return i.apply(this,s);s.pop(),i.apply(this,s).then(h=>o(null,h),o)},"name",{value:i.name})}),_t}var lr,vo;function Pf(){if(vo)return lr;vo=1;var i=hf,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 n=process.chdir;process.chdir=function(e){o=null,n.call(process,e)},Object.setPrototypeOf&&Object.setPrototypeOf(process.chdir,n)}lr=t;function t(e){i.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=c(e.chmod),e.fchmod=c(e.fchmod),e.lchmod=c(e.lchmod),e.chownSync=m(e.chownSync),e.fchownSync=m(e.fchownSync),e.lchownSync=m(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,l){l&&process.nextTick(l)},e.lchownSync=function(){}),h==="win32"&&(e.rename=typeof e.rename!="function"?e.rename:function(g){function a(f,l,_){var p=Date.now(),E=0;g(f,l,function y(b){if(b&&(b.code==="EACCES"||b.code==="EPERM"||b.code==="EBUSY")&&Date.now()-p<6e4){setTimeout(function(){e.stat(l,function(A,P){A&&A.code==="ENOENT"?g(f,l,y):_(b)})},E),E<100&&(E+=10);return}_&&_(b)})}return Object.setPrototypeOf&&Object.setPrototypeOf(a,g),a}(e.rename)),e.read=typeof e.read!="function"?e.read:function(g){function a(f,l,_,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,l,_,p,E,b);y.apply(this,arguments)}}return g.call(e,f,l,_,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,l,_,p){for(var E=0;;)try{return g.call(e,a,f,l,_,p)}catch(y){if(y.code==="EAGAIN"&&E<10){E++;continue}throw y}}}(e.readSync);function r(g){g.lchmod=function(a,f,l){g.open(a,i.O_WRONLY|i.O_SYMLINK,f,function(_,p){if(_){l&&l(_);return}g.fchmod(p,f,function(E){g.close(p,function(y){l&&l(E||y)})})})},g.lchmodSync=function(a,f){var l=g.openSync(a,i.O_WRONLY|i.O_SYMLINK,f),_=!0,p;try{p=g.fchmodSync(l,f),_=!1}finally{if(_)try{g.closeSync(l)}catch{}else g.closeSync(l)}return p}}function u(g){i.hasOwnProperty("O_SYMLINK")&&g.futimes?(g.lutimes=function(a,f,l,_){g.open(a,i.O_SYMLINK,function(p,E){if(p){_&&_(p);return}g.futimes(E,f,l,function(y){g.close(E,function(b){_&&_(y||b)})})})},g.lutimesSync=function(a,f,l){var _=g.openSync(a,i.O_SYMLINK),p,E=!0;try{p=g.futimesSync(_,f,l),E=!1}finally{if(E)try{g.closeSync(_)}catch{}else g.closeSync(_)}return p}):g.futimes&&(g.lutimes=function(a,f,l,_){_&&process.nextTick(_)},g.lutimesSync=function(){})}function c(g){return g&&function(a,f,l){return g.call(e,a,f,function(_){S(_)&&(_=null),l&&l.apply(this,arguments)})}}function d(g){return g&&function(a,f){try{return g.call(e,a,f)}catch