UNPKG

@pplancq/create-react-app

Version:
60 lines (56 loc) 65.7 kB
#!/usr/bin/env node let t;import e,{execFile as i}from"node:child_process";import r,{platform as s,stdin as n,stdout as o}from"node:process";import{promisify as a,stripVTControlCharacters as l,styleText as h}from"node:util";import{ReadStream as u}from"node:tty";import p,{cpSync as m,existsSync as c,mkdirSync as d,readFileSync as g,rmSync as f}from"node:fs";import _,{resolve as b}from"node:path";import{EventEmitter as v}from"node:events";import*as x from"node:readline";var y={},w={};function O(t){var e=w[t];if(void 0!==e)return e.exports;var i=w[t]={exports:{}};return y[t](i,i.exports,O),i.exports}O.m=y,O.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return O.d(e,{a:e}),e},O.d=(t,e,i)=>{var r=(e,i)=>{for(var r in e)O.o(e,r)&&!O.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,[i]:e[r]})};r(e,"get"),r(i,"value")},O.add=function(t){Object.assign(O.m,t)},O.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),O.add({"../../node_modules/picocolors/picocolors.js"(t){let e=process||{},i=e.argv||[],r=e.env||{},s=!(r.NO_COLOR||i.includes("--no-color"))&&(!!r.FORCE_COLOR||i.includes("--color")||"win32"===e.platform||(e.stdout||{}).isTTY&&"dumb"!==r.TERM||!!r.CI),n=(t,e,i=t)=>r=>{let s=""+r,n=s.indexOf(e,t.length);return~n?t+o(s,e,i,n)+e:t+s+e},o=(t,e,i,r)=>{let s="",n=0;do s+=t.substring(n,r)+i,n=r+e.length,r=t.indexOf(e,n);while(~r);return s+t.substring(n)},a=(t=s)=>{let e=t?n:()=>String;return{isColorSupported:t,reset:e("\x1b[0m","\x1b[0m"),bold:e("\x1b[1m","\x1b[22m","\x1b[22m\x1b[1m"),dim:e("\x1b[2m","\x1b[22m","\x1b[22m\x1b[2m"),italic:e("\x1b[3m","\x1b[23m"),underline:e("\x1b[4m","\x1b[24m"),inverse:e("\x1b[7m","\x1b[27m"),hidden:e("\x1b[8m","\x1b[28m"),strikethrough:e("\x1b[9m","\x1b[29m"),black:e("\x1b[30m","\x1b[39m"),red:e("\x1b[31m","\x1b[39m"),green:e("\x1b[32m","\x1b[39m"),yellow:e("\x1b[33m","\x1b[39m"),blue:e("\x1b[34m","\x1b[39m"),magenta:e("\x1b[35m","\x1b[39m"),cyan:e("\x1b[36m","\x1b[39m"),white:e("\x1b[37m","\x1b[39m"),gray:e("\x1b[90m","\x1b[39m"),bgBlack:e("\x1b[40m","\x1b[49m"),bgRed:e("\x1b[41m","\x1b[49m"),bgGreen:e("\x1b[42m","\x1b[49m"),bgYellow:e("\x1b[43m","\x1b[49m"),bgBlue:e("\x1b[44m","\x1b[49m"),bgMagenta:e("\x1b[45m","\x1b[49m"),bgCyan:e("\x1b[46m","\x1b[49m"),bgWhite:e("\x1b[47m","\x1b[49m"),blackBright:e("\x1b[90m","\x1b[39m"),redBright:e("\x1b[91m","\x1b[39m"),greenBright:e("\x1b[92m","\x1b[39m"),yellowBright:e("\x1b[93m","\x1b[39m"),blueBright:e("\x1b[94m","\x1b[39m"),magentaBright:e("\x1b[95m","\x1b[39m"),cyanBright:e("\x1b[96m","\x1b[39m"),whiteBright:e("\x1b[97m","\x1b[39m"),bgBlackBright:e("\x1b[100m","\x1b[49m"),bgRedBright:e("\x1b[101m","\x1b[49m"),bgGreenBright:e("\x1b[102m","\x1b[49m"),bgYellowBright:e("\x1b[103m","\x1b[49m"),bgBlueBright:e("\x1b[104m","\x1b[49m"),bgMagentaBright:e("\x1b[105m","\x1b[49m"),bgCyanBright:e("\x1b[106m","\x1b[49m"),bgWhiteBright:e("\x1b[107m","\x1b[49m")}};t.exports=a(),t.exports.createColors=a},"../../node_modules/sisteransi/src/index.js"(t){let e={to:(t,e)=>e?`[${e+1};${t+1}H`:`[${t+1}G`,move(t,e){let i="";return t<0?i+=`[${-t}D`:t>0&&(i+=`[${t}C`),e<0?i+=`[${-e}A`:e>0&&(i+=`[${e}B`),i},up:(t=1)=>`[${t}A`,down:(t=1)=>`[${t}B`,forward:(t=1)=>`[${t}C`,backward:(t=1)=>`[${t}D`,nextLine:(t=1)=>"\x1b[E".repeat(t),prevLine:(t=1)=>"\x1b[F".repeat(t),left:"\x1b[G",hide:"\x1b[?25l",show:"\x1b[?25h",save:"\x1b7",restore:"\x1b8"},i={screen:"\x1b[2J",up:(t=1)=>"\x1b[1J".repeat(t),down:(t=1)=>"\x1b[J".repeat(t),line:"\x1b[2K",lineEnd:"\x1b[K",lineStart:"\x1b[1K",lines(t){let i="";for(let r=0;r<t;r++)i+=this.line+(r<t-1?e.up():"");return t&&(i+=e.left),i}};t.exports={cursor:e,scroll:{up:(t=1)=>"\x1b[S".repeat(t),down:(t=1)=>"\x1b[T".repeat(t)},erase:i,beep:"\x07"}}});let $=(t=!1)=>{process.exit(+!!t)};class C extends Error{constructor(t){super(t),this.name="RunCommandError"}}let A=a(i),E=async(t,e=[],i)=>{try{let r={shell:"win32"===s,...i};await A(t,e,r)}catch{let i=[t,...e].join(" ");throw new C(`Failed to execute ${i}`)}},S=(t=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,e=>{let i=0;for(t.lastIndex=0;t.test(e);)i+=1;return e.length-i}),k=t=>12288===t||t>=65281&&t<=65376||t>=65504&&t<=65510,T=t=>8987===t||9001===t||t>=12272&&t<=12287||t>=12289&&t<=12350||t>=12441&&t<=12543||t>=12549&&t<=12591||t>=12593&&t<=12686||t>=12688&&t<=12771||t>=12783&&t<=12830||t>=12832&&t<=12871||t>=12880&&t<=19903||t>=65040&&t<=65049||t>=65072&&t<=65106||t>=65108&&t<=65126||t>=65128&&t<=65131||t>=127488&&t<=127490||t>=127504&&t<=127547||t>=127552&&t<=127560||t>=131072&&t<=196605||t>=196608&&t<=262141,H=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,V=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,I=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/yu,F=/\t{1,1000}/y,M=/[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/yu,G=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,j=/\p{M}+/gu,W={limit:1/0,ellipsis:""},P=(t,e={},i={})=>{let r=e.limit??1/0,s=e.ellipsis??"",n=e?.ellipsisWidth??(s?P(s,W,i).width:0),o=i.controlWidth??0,a=i.tabWidth??8,l=i.emojiWidth??2,h=i.regularWidth??1,u=i.wideWidth??2,p=[[G,h],[H,0],[V,o],[F,a],[M,l],[I,u]],m=0,c=0,d=t.length,g=0,f=!1,_=d,b=Math.max(0,r-n),v=0,x=0,y=0,w=0;t:for(;;){if(x>v||c>=d&&c>m){for(let e of(g=0,(t.slice(v,x)||t.slice(m,c)).replaceAll(j,""))){let t=e.codePointAt(0)||0;if(y+(w=k(t)?2:T(t)?u:h)>b&&(_=Math.min(_,Math.max(v,m)+g)),y+w>r){f=!0;break t}g+=e.length,y+=w}v=x=0}if(c>=d)break;for(let e=0,i=p.length;e<i;e++){let[i,s]=p[e];if(i.lastIndex=c,i.test(t)){if(y+(w=(g=i===I?S(t.slice(c,i.lastIndex)):i===M?1:i.lastIndex-c)*s)>b&&(_=Math.min(_,c+Math.floor((b-y)/s))),y+w>r){f=!0;break t}y+=w,v=m,x=c,c=m=i.lastIndex;continue t}}c+=1}return{width:f?b:y,index:f?_:d,truncated:f,ellipsed:f&&r>=n}},D={limit:1/0,ellipsis:"",ellipsisWidth:0},N=(t,e={})=>P(t,D,e).width,R="]8;;",L=RegExp(`(?:\\[(?<code>\\d+)m|\\${R}(?<uri>.*)\u0007)`,"y"),B=t=>t>=30&&t<=37||t>=90&&t<=97?39:t>=40&&t<=47||t>=100&&t<=107?49:1===t||2===t?22:3===t?23:4===t?24:7===t?27:8===t?28:9===t?29:0===t?0:void 0,U=t=>`\x1b[${t}m`,q=t=>`\x1b${R}${t}\u0007`,z=(t,e,i)=>{let r=e[Symbol.iterator](),s=!1,n=!1,o=t.at(-1),a=void 0===o?0:N(o),l=r.next(),h=r.next(),u=0;for(;!l.done;){let o=l.value,p=N(o);a+p<=i?t[t.length-1]+=o:(t.push(o),a=0),("\x1b"===o||"\x9b"===o)&&(s=!0,n=e.startsWith(R,u+1)),s?n?"\x07"===o&&(s=!1,n=!1):"m"===o&&(s=!1):(a+=p)!==i||h.done||(t.push(""),a=0),l=h,h=r.next(),u+=o.length}o=t.at(-1),!a&&void 0!==o&&o.length&&t.length>1&&(t[t.length-2]+=t.pop())},J=/\r?\n/;function K(t,e,i){return String(t).normalize().split(J).map(t=>((t,e,i={})=>{let r,s;if(!1!==i.trim&&""===t.trim())return"";let n="",o=t.split(" "),a=[""],l=0;for(let t=0;t<o.length;t++){let r=o[t];if(!1!==i.trim){let t=a.at(-1)??"",e=t.trimStart();t.length!==e.length&&(a[a.length-1]=e,l=N(e))}0!==t&&(l>=e&&(!1===i.wordWrap||!1===i.trim)&&(a.push(""),l=0),(l||!1===i.trim)&&(a[a.length-1]+=" ",l++));let s=N(r);if(i.hard&&s>e){let t=1+Math.floor((s-(e-l)-1)/e);Math.floor((s-1)/e)<t&&a.push(""),z(a,r,e),l=N(a.at(-1)??"");continue}if(l+s>e&&l&&s){if(!1===i.wordWrap&&l<e){z(a,r,e),l=N(a.at(-1)??"");continue}a.push(""),l=0}if(l+s>e&&!1===i.wordWrap){z(a,r,e),l=N(a.at(-1)??"");continue}a[a.length-1]+=r,l+=s}!1!==i.trim&&(a=a.map(t=>(t=>{let e=t.split(" "),i=e.length;for(;i&&!N(e[i-1]);)i--;return i===e.length?t:e.slice(0,i).join(" ")+e.slice(i).join("")})(t)));let h=a.join("\n"),u=!1;for(let t=0;t<h.length;t++){let e=h[t];if(n+=e,u)u=!1;else if(u=e>="\uD800"&&e<="\uDBFF")continue;if("\x1b"===e||"\x9b"===e){L.lastIndex=t+1;let e=L.exec(h),i=e?.groups;if(i?.code!==void 0){let t=Number.parseFloat(i.code);r=39===t?void 0:t}else i?.uri!==void 0&&(s=0===i.uri.length?void 0:i.uri)}if("\n"===h[t+1]){s&&(n+=q(""));let t=r?B(r):void 0;r&&t&&(n+=U(t))}else"\n"===e&&(r&&B(r)&&(n+=U(r)),s&&(n+=q(s)))}return n})(t,e,i)).join("\n")}let Y=O("../../node_modules/sisteransi/src/index.js"),Z={actions:new Set(["up","down","left","right","space","enter","cancel"]),aliases:new Map([["k","up"],["j","down"],["h","left"],["l","right"],["\x03","cancel"],["escape","cancel"]]),messages:{cancel:"Canceled",error:"Something went wrong"},withGuide:!0,date:{monthNames:["January","February","March","April","May","June","July","August","September","October","November","December"],messages:{required:"Please enter a valid date",invalidMonth:"There are only 12 months in a year",invalidDay:(t,e)=>`There are only ${t} days in ${e}`,afterMin:t=>`Date must be on or after ${t.toISOString().slice(0,10)}`,beforeMax:t=>`Date must be on or before ${t.toISOString().slice(0,10)}`}}};function Q(t,e){if("string"==typeof t)return Z.aliases.get(t)===e;for(let i of t)if(void 0!==i&&Q(i,e))return!0;return!1}let X=globalThis.process.platform.startsWith("win"),tt=Symbol("clack:cancel");function te(t,e){t.isTTY&&t.setRawMode(e)}let ti=t=>"columns"in t&&"number"==typeof t.columns?t.columns:80;class tr{input;output;_abortSignal;rl;opts;_render;_track=!1;_prevFrame="";_subscribers=new Map;_cursor=0;state="initial";error="";value;userInput="";constructor(t,e=!0){let{input:i=n,output:r=o,render:s,signal:a,...l}=t;this.opts=l,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=s.bind(this),this._track=e,this._abortSignal=a,this.input=i,this.output=r}unsubscribe(){this._subscribers.clear()}setSubscriber(t,e){let i=this._subscribers.get(t)??[];i.push(e),this._subscribers.set(t,i)}on(t,e){this.setSubscriber(t,{cb:e})}once(t,e){this.setSubscriber(t,{cb:e,once:!0})}emit(t,...e){let i=this._subscribers.get(t)??[],r=[];for(let t of i)t.cb(...e),t.once&&r.push(()=>i.splice(i.indexOf(t),1));for(let t of r)t()}prompt(){return new Promise(t=>{if(this._abortSignal){if(this._abortSignal.aborted)return this.state="cancel",this.close(),t(tt);this._abortSignal.addEventListener("abort",()=>{this.state="cancel",this.close()},{once:!0})}this.rl=x.default.createInterface({input:this.input,tabSize:2,prompt:"",escapeCodeTimeout:50,terminal:!0}),this.rl.prompt(),void 0!==this.opts.initialUserInput&&this._setUserInput(this.opts.initialUserInput,!0),this.input.on("keypress",this.onKeypress),te(this.input,!0),this.output.on("resize",this.render),this.render(),this.once("submit",()=>{this.output.write(Y.cursor.show),this.output.off("resize",this.render),te(this.input,!1),t(this.value)}),this.once("cancel",()=>{this.output.write(Y.cursor.show),this.output.off("resize",this.render),te(this.input,!1),t(tt)})})}_isActionKey(t,e){return" "===t}_shouldSubmit(t,e){return!0}_setValue(t){this.value=t,this.emit("value",this.value)}_setUserInput(t,e){this.userInput=t??"",this.emit("userInput",this.userInput),e&&this._track&&this.rl&&(this.rl.write(this.userInput),this._cursor=this.rl.cursor)}_clearUserInput(){this.rl?.write(null,{ctrl:!0,name:"u"}),this._setUserInput("")}onKeypress(t,e){if(this._track&&"return"!==e.name&&(e.name&&this._isActionKey(t,e)&&this.rl?.write(null,{ctrl:!0,name:"h"}),this._cursor=this.rl?.cursor??0,this._setUserInput(this.rl?.line)),"error"===this.state&&(this.state="active"),e?.name&&(!this._track&&Z.aliases.has(e.name)&&this.emit("cursor",Z.aliases.get(e.name)),Z.actions.has(e.name)&&this.emit("cursor",e.name)),t&&("y"===t.toLowerCase()||"n"===t.toLowerCase())&&this.emit("confirm","y"===t.toLowerCase()),this.emit("key",t,e),e?.name==="return"&&this._shouldSubmit(t,e)){if(this.opts.validate){let t=function(t,e){if("~standard"in t){let i=t["~standard"].validate(e);if(i instanceof Promise)throw TypeError("Schema validation must be synchronous. Update `validate()` and remove any asynchronous logic.");return i.issues?.at(0)?.message}return t(e)}(this.opts.validate,this.value);t&&(this.error=t instanceof Error?t.message:t,this.state="error",this.rl?.write(this.userInput))}"error"!==this.state&&(this.state="submit")}Q([t,e?.name,e?.sequence],"cancel")&&(this.state="cancel"),("submit"===this.state||"cancel"===this.state)&&this.emit("finalize"),this.render(),("submit"===this.state||"cancel"===this.state)&&this.close()}close(){this.input.unpipe(),this.input.removeListener("keypress",this.onKeypress),this.output.write(` `),te(this.input,!1),this.rl?.close(),this.rl=void 0,this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){let t=K(this._prevFrame,process.stdout.columns,{hard:!0,trim:!1}).split(` `).length-1;this.output.write(Y.cursor.move(-999,-1*t))}render(){let t=K(this._render(this)??"",process.stdout.columns,{hard:!0,trim:!1});if(t!==this._prevFrame){if("initial"===this.state)this.output.write(Y.cursor.hide);else{let e,i=function(t,e){if(t===e)return;let i=t.split(` `),r=e.split(` `),s=Math.max(i.length,r.length),n=[];for(let t=0;t<s;t++)i[t]!==r[t]&&n.push(t);return{lines:n,numLinesBefore:i.length,numLinesAfter:r.length,numLines:s}}(this._prevFrame,t),r="rows"in(e=this.output)&&"number"==typeof e.rows?e.rows:20;if(this.restoreCursor(),i){let e=Math.max(0,i.numLinesAfter-r),s=Math.max(0,i.numLinesBefore-r),n=i.lines.find(t=>t>=e);if(void 0===n){this._prevFrame=t;return}if(1===i.lines.length){this.output.write(Y.cursor.move(0,n-s)),this.output.write(Y.erase.lines(1));let e=t.split(` `);this.output.write(e[n]),this._prevFrame=t,this.output.write(Y.cursor.move(0,e.length-n-1));return}if(i.lines.length>1){if(e<s)n=e;else{let t=n-s;t>0&&this.output.write(Y.cursor.move(0,t))}this.output.write(Y.erase.down());let i=t.split(` `).slice(n);this.output.write(i.join(` `)),this._prevFrame=t;return}}this.output.write(Y.erase.down())}this.output.write(t),"initial"===this.state&&(this.state="active"),this._prevFrame=t}}}class ts extends tr{get cursor(){return+!this.value}get _value(){return 0===this.cursor}constructor(t){super(t,!1),this.value=!!t.initialValue,this.on("userInput",()=>{this.value=this._value}),this.on("confirm",t=>{this.output.write(Y.cursor.move(0,-1)),this.value=t,this.state="submit",this.close()}),this.on("cursor",()=>{this.value=!this.value})}}class tn extends tr{get userInputWithCursor(){if("submit"===this.state)return this.userInput;let t=this.userInput;if(this.cursor>=t.length)return`${this.userInput}\u2588`;let e=t.slice(0,this.cursor),i=t.slice(this.cursor,this.cursor+1),r=t.slice(this.cursor+1);return`${e}${h("inverse",i)}${r}`}get cursor(){return this._cursor}constructor(t){super({...t,initialUserInput:t.initialUserInput??t.initialValue}),this.on("userInput",t=>{this._setValue(t)}),this.on("finalize",()=>{this.value||(this.value=t.defaultValue),void 0===this.value&&(this.value="")})}}let to="win32"!==r.platform?"linux"!==r.env.TERM:!!r.env.CI||!!r.env.WT_SESSION||!!r.env.TERMINUS_SUBLIME||"{cmd::Cmder}"===r.env.ConEmuTask||"Terminus-Sublime"===r.env.TERM_PROGRAM||"vscode"===r.env.TERM_PROGRAM||"xterm-256color"===r.env.TERM||"alacritty"===r.env.TERM||"JetBrains-JediTerm"===r.env.TERMINAL_EMULATOR,ta=(t,e)=>to?t:e,tl=ta("◆","*"),th=ta("■","x"),tu=ta("▲","x"),tp=ta("◇","o"),tm=ta("┌","T"),tc=ta("│","|"),td=ta("└","—"),tg=ta("●",">"),tf=ta("○"," "),t_=ta("─","-"),tb=ta("╮","+"),tv=ta("├","+"),tx=ta("╯","+"),ty=ta("╰","+"),tw=ta("●","•"),tO=ta("◆","*"),t$=ta("▲","!"),tC=ta("■","x"),tA=t=>{switch(t){case"initial":case"active":return h("cyan",tl);case"cancel":return h("red",th);case"error":return h("yellow",tu);case"submit":return h("green",tp)}},tE=t=>{let e=t.active??"Yes",i=t.inactive??"No";return new ts({active:e,inactive:i,signal:t.signal,input:t.input,output:t.output,initialValue:t.initialValue??!0,render(){let r=t.withGuide??Z.withGuide,s=`${tA(this.state)} `,n=r?`${h("gray",tc)} `:"",a=function(t,e,i,r=i,s=i){return K(e,ti(t??o)-i.length,{hard:!0,trim:!1}).split(` `).map((t,e,n)=>0===e?`${r}${t}`:e===n.length-1?`${s}${t}`:`${i}${t}`).join(` `)}(t.output,t.message,n,s),l=`${r?`${h("gray",tc)} `:""}${a} `,u=this.value?e:i;switch(this.state){case"submit":{let t=r?`${h("gray",tc)} `:"";return`${l}${t}${h("dim",u)}`}case"cancel":{let t=r?`${h("gray",tc)} `:"";return`${l}${t}${h(["strikethrough","dim"],u)}${r?` ${h("gray",tc)}`:""}`}default:{let s=r?`${h("cyan",tc)} `:"",n=r?h("cyan",td):"";return`${l}${s}${this.value?`${h("green",tg)} ${e}`:`${h("dim",tf)} ${h("dim",e)}`}${t.vertical?r?` ${h("cyan",tc)} `:` `:` ${h("dim","/")} `}${this.value?`${h("dim",tf)} ${h("dim",i)}`:`${h("green",tg)} ${i}`} ${n} `}}}}).prompt()},tS=async(t,e)=>{let i={};for(let r of Object.keys(t)){let s=t[r],n=await s({results:i})?.catch(t=>{throw t});if("function"==typeof e?.onCancel&&n===tt){i[r]="canceled",e.onCancel({results:i});continue}i[r]=n}return i};h("dim","↑/↓"),h("dim","Space:"),h("dim","Enter:");let tk={message:(t=[],{symbol:e=h("gray",tc),secondarySymbol:i=h("gray",tc),output:r=process.stdout,spacing:s=1,withGuide:n}={})=>{let o=[],a=n??Z.withGuide,l=a?i:"",u=a?`${e} `:"",p=a?`${i} `:"";for(let t=0;t<s;t++)o.push(l);let m=Array.isArray(t)?t:t.split(` `);if(m.length>0){let[t,...r]=m;for(let s of(t.length>0?o.push(`${u}${t}`):o.push(a?e:""),r))s.length>0?o.push(`${p}${s}`):o.push(a?i:"")}r.write(`${o.join(` `)} `)},info:(t,e)=>{tk.message(t,{...e,symbol:h("blue",tw)})},success:(t,e)=>{tk.message(t,{...e,symbol:h("green",tO)})},step:(t,e)=>{tk.message(t,{...e,symbol:h("green",tp)})},warn:(t,e)=>{tk.message(t,{...e,symbol:h("yellow",t$)})},warning:(t,e)=>{tk.warn(t,e)},error:(t,e)=>{tk.message(t,{...e,symbol:h("red",tC)})}},tT=(t="",e)=>{let i=e?.output??process.stdout,r=e?.withGuide??Z.withGuide?`${h("gray",tc)} ${h("gray",td)} `:"";i.write(`${r}${t} `)},tH=t=>t,tV=t=>h("magenta",t),tI=({indicator:t="dots",onCancel:e,output:i=process.stdout,cancelMessage:r,errorMessage:s,frames:a=to?["◒","◐","◓","◑"]:["•","o","O","0"],delay:l=to?80:120,signal:p,...m}={})=>{let c="true"===process.env.CI,d,g,f=!1,_=!1,b="",v,y=performance.now(),w=ti(i),O=m?.styleFrame??tV,$=t=>{let i=t>1?s??Z.messages.error:r??Z.messages.cancel;_=1===t,f&&(T(i,t),_&&"function"==typeof e&&e())},C=()=>$(2),A=()=>$(1),E=()=>{if(void 0===v)return;c&&i.write(` `);let t=K(v,w,{hard:!0,trim:!1}).split(` `);t.length>1&&i.write(Y.cursor.up(t.length-1)),i.write(Y.cursor.to(0)),i.write(Y.erase.down())},S=t=>{let e=(performance.now()-t)/1e3,i=Math.floor(e/60),r=Math.floor(e%60);return i>0?`[${i}m ${r}s]`:`[${r}s]`},k=m.withGuide??Z.withGuide,T=(e="",r=0,s=!1)=>{if(!f)return;f=!1,clearInterval(g),E();let n=0===r?h("green",tp):1===r?h("red",th):h("red",tu);b=e??b,s||("timer"===t?i.write(`${n} ${b} ${S(y)} `):i.write(`${n} ${b} `)),process.removeListener("uncaughtExceptionMonitor",C),process.removeListener("unhandledRejection",C),process.removeListener("SIGINT",A),process.removeListener("SIGTERM",A),process.removeListener("exit",$),p&&p.removeEventListener("abort",A),d()};return{start:(e="")=>{f=!0,d=function({input:t=n,output:e=o,overwrite:i=!0,hideCursor:r=!0}={}){let s=x.createInterface({input:t,output:e,prompt:"",tabSize:1});x.emitKeypressEvents(t,s),t instanceof u&&t.isTTY&&t.setRawMode(!0);let a=(s,{name:n,sequence:o})=>{if(Q([String(s),n,o],"cancel")){r&&e.write(Y.cursor.show),process.exit(0);return}i&&x.moveCursor(e,"return"===n?0:-1,"return"===n?-1:0,()=>{x.clearLine(e,1,()=>{t.once("keypress",a)})})};return r&&e.write(Y.cursor.hide),t.once("keypress",a),()=>{t.off("keypress",a),r&&e.write(Y.cursor.show),t instanceof u&&t.isTTY&&!X&&t.setRawMode(!1),s.terminal=!1,s.close()}}({output:i}),b=e.replace(/\.+$/,""),y=performance.now(),k&&i.write(`${h("gray",tc)} `);let r=0,s=0;process.on("uncaughtExceptionMonitor",C),process.on("unhandledRejection",C),process.on("SIGINT",A),process.on("SIGTERM",A),process.on("exit",$),p&&p.addEventListener("abort",A),g=setInterval(()=>{let e;if(c&&b===v)return;E(),v=b;let n=O(a[r]);if(c)e=`${n} ${b}...`;else if("timer"===t)e=`${n} ${b} ${S(y)}`;else{let t=".".repeat(Math.floor(s)).slice(0,3);e=`${n} ${b}${t}`}let o=K(e,w,{hard:!0,trim:!1});i.write(o),r=r+1<a.length?r+1:0,s=s<4?s+.125:0},l)},stop:(t="")=>T(t,0),message:(t="")=>{b=(t??b).replace(/\.+$/,"")},cancel:(t="")=>T(t,1),error:(t="")=>T(t,2),clear:()=>T("",0,!0),get isCancelled(){return _}}};ta("─","-"),ta("━","="),ta("█","#"),h("dim","↑/↓"),h("dim","Enter:"),h("gray",tc);let tF=t=>new tn({validate:t.validate,placeholder:t.placeholder,defaultValue:t.defaultValue,initialValue:t.initialValue,output:t.output,signal:t.signal,input:t.input,render(){let e=t?.withGuide??Z.withGuide,i=`${e?`${h("gray",tc)} `:""}${tA(this.state)} ${t.message} `,r=t.placeholder&&t.placeholder.length>0?h("inverse",t.placeholder[0])+h("dim",t.placeholder.slice(1)):h(["inverse","hidden"],"_"),s=this.userInput?this.userInputWithCursor:r,n=this.value??"";switch(this.state){case"error":{let t=this.error?` ${h("yellow",this.error)}`:"",r=e?`${h("yellow",tc)} `:"",n=e?h("yellow",td):"";return`${i.trim()} ${r}${s} ${n}${t} `}case"submit":{let t=n?` ${h("dim",n)}`:"",r=e?h("gray",tc):"";return`${i}${r}${t}`}case"cancel":{let t=n?` ${h(["strikethrough","dim"],n)}`:"",r=e?h("gray",tc):"";return`${i}${r}${t}${n.trim()?` ${r}`:""}`}default:{let t=e?`${h("cyan",tc)} `:"",r=e?h("cyan",td):"";return`${i}${t}${s} ${r} `}}}}).prompt(),tM=O("../../node_modules/picocolors/picocolors.js");var tG=O.n(tM);let tj=async t=>{let e=tI(),i=b(r.cwd(),t);return e.start(`Creating a React App in ${tG().green(i)}.`),d(i),await E("npm",["init","-y"],{cwd:i}),e.stop(`React App created in ${tG().green(i)}.`),{repoDir:i}},tW=t=>(t===tt&&(((t="")=>{let e=(void 0)??process.stdout,i=(void 0)??Z.withGuide?`${h("gray",td)} `:"";e.write(`${i}${h("red",t)} `)})("Operation cancelled."),$()),t),tP=t=>"string"==typeof t&&/^(@[a-z0-9-~][a-z0-9-._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/.test(t)?c(b(r.cwd(),t))?`The directory ${tG().green(t)} already exists. Either try using a new directory name, or remove the files listed above.`:"":`The project name '${t}' is not valid. A valid npm project name must start with a lowercase letter, a number, a hyphen, or a tilde, and can include dots, hyphens, tildes, or underscores. If the project name starts with '@', it must be followed by a valid scope name and a '/'.`,tD=t=>"string"==typeof t&&/^(@[a-z0-9-~][a-z0-9-._~]*\/)?[a-z0-9-~][a-z0-9-._~]*(?:@[^\s@][^\s]*)?$/.test(t)?"":`The template name '${t}' is not valid.`,tN=async({projectName:t,skipDepInstall:e,skipGitInit:i,template:r})=>({projectName:t||tW(await tF({message:"What is the name of your project?",placeholder:"my-project",validate:tP})).toString(),skipDepInstall:e||!!tW(await tE({message:"Do you want to skip installing dependencies (npm install)?",initialValue:!1})),skipGitInit:i||!!tW(await tE({message:"Do you want to skip initializing a git repository?",initialValue:!1})),template:r||tW((await tS({useCustomTemplate:async()=>!!await tE({message:"Do you want to use a custom template?",initialValue:!1}),template:async({results:t})=>t.useCustomTemplate?(await tF({message:"Enter the custom template name (e.g., @pplancq/react-template):",placeholder:"@pplancq/react-template",validate:tD})).toString():"@pplancq/react-template"})).template)});class tR extends Error{constructor(t,e,i){super(i),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=e,this.exitCode=t,this.nestedError=void 0}}class tL extends tR{constructor(t){super(1,"commander.invalidArgument",t),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}}class tB{constructor(t,e){switch(this.description=e||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,t[0]){case"<":this.required=!0,this._name=t.slice(1,-1);break;case"[":this.required=!1,this._name=t.slice(1,-1);break;default:this.required=!0,this._name=t}this._name.endsWith("...")&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_collectValue(t,e){return e!==this.defaultValue&&Array.isArray(e)?(e.push(t),e):[t]}default(t,e){return this.defaultValue=t,this.defaultValueDescription=e,this}argParser(t){return this.parseArg=t,this}choices(t){return this.argChoices=t.slice(),this.parseArg=(t,e)=>{if(!this.argChoices.includes(t))throw new tL(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._collectValue(t,e):t},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}}function tU(t){let e=t.name()+(!0===t.variadic?"...":"");return t.required?"<"+e+">":"["+e+"]"}class tq{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(t){this.helpWidth=this.helpWidth??t.helpWidth??80}visibleCommands(t){let e=t.commands.filter(t=>!t._hidden),i=t._getHelpCommand();return i&&!i._hidden&&e.push(i),this.sortSubcommands&&e.sort((t,e)=>t.name().localeCompare(e.name())),e}compareOptions(t,e){let i=t=>t.short?t.short.replace(/^-/,""):t.long.replace(/^--/,"");return i(t).localeCompare(i(e))}visibleOptions(t){let e=t.options.filter(t=>!t.hidden),i=t._getHelpOption();if(i&&!i.hidden){let r=i.short&&t._findOption(i.short),s=i.long&&t._findOption(i.long);r||s?i.long&&!s?e.push(t.createOption(i.long,i.description)):i.short&&!r&&e.push(t.createOption(i.short,i.description)):e.push(i)}return this.sortOptions&&e.sort(this.compareOptions),e}visibleGlobalOptions(t){if(!this.showGlobalOptions)return[];let e=[];for(let i=t.parent;i;i=i.parent){let t=i.options.filter(t=>!t.hidden);e.push(...t)}return this.sortOptions&&e.sort(this.compareOptions),e}visibleArguments(t){return(t._argsDescription&&t.registeredArguments.forEach(e=>{e.description=e.description||t._argsDescription[e.name()]||""}),t.registeredArguments.find(t=>t.description))?t.registeredArguments:[]}subcommandTerm(t){let e=t.registeredArguments.map(t=>tU(t)).join(" ");return t._name+(t._aliases[0]?"|"+t._aliases[0]:"")+(t.options.length?" [options]":"")+(e?" "+e:"")}optionTerm(t){return t.flags}argumentTerm(t){return t.name()}longestSubcommandTermLength(t,e){return e.visibleCommands(t).reduce((t,i)=>Math.max(t,this.displayWidth(e.styleSubcommandTerm(e.subcommandTerm(i)))),0)}longestOptionTermLength(t,e){return e.visibleOptions(t).reduce((t,i)=>Math.max(t,this.displayWidth(e.styleOptionTerm(e.optionTerm(i)))),0)}longestGlobalOptionTermLength(t,e){return e.visibleGlobalOptions(t).reduce((t,i)=>Math.max(t,this.displayWidth(e.styleOptionTerm(e.optionTerm(i)))),0)}longestArgumentTermLength(t,e){return e.visibleArguments(t).reduce((t,i)=>Math.max(t,this.displayWidth(e.styleArgumentTerm(e.argumentTerm(i)))),0)}commandUsage(t){let e=t._name;t._aliases[0]&&(e=e+"|"+t._aliases[0]);let i="";for(let e=t.parent;e;e=e.parent)i=e.name()+" "+i;return i+e+" "+t.usage()}commandDescription(t){return t.description()}subcommandDescription(t){return t.summary()||t.description()}optionDescription(t){let e=[];if(t.argChoices&&e.push(`choices: ${t.argChoices.map(t=>JSON.stringify(t)).join(", ")}`),void 0!==t.defaultValue&&(t.required||t.optional||t.isBoolean()&&"boolean"==typeof t.defaultValue)&&e.push(`default: ${t.defaultValueDescription||JSON.stringify(t.defaultValue)}`),void 0!==t.presetArg&&t.optional&&e.push(`preset: ${JSON.stringify(t.presetArg)}`),void 0!==t.envVar&&e.push(`env: ${t.envVar}`),e.length>0){let i=`(${e.join(", ")})`;return t.description?`${t.description} ${i}`:i}return t.description}argumentDescription(t){let e=[];if(t.argChoices&&e.push(`choices: ${t.argChoices.map(t=>JSON.stringify(t)).join(", ")}`),void 0!==t.defaultValue&&e.push(`default: ${t.defaultValueDescription||JSON.stringify(t.defaultValue)}`),e.length>0){let i=`(${e.join(", ")})`;return t.description?`${t.description} ${i}`:i}return t.description}formatItemList(t,e,i){return 0===e.length?[]:[i.styleTitle(t),...e,""]}groupItems(t,e,i){let r=new Map;return t.forEach(t=>{let e=i(t);r.has(e)||r.set(e,[])}),e.forEach(t=>{let e=i(t);r.has(e)||r.set(e,[]),r.get(e).push(t)}),r}formatHelp(t,e){let i=e.padWidth(t,e),r=e.helpWidth??80;function s(t,r){return e.formatItem(t,i,r,e)}let n=[`${e.styleTitle("Usage:")} ${e.styleUsage(e.commandUsage(t))}`,""],o=e.commandDescription(t);o.length>0&&(n=n.concat([e.boxWrap(e.styleCommandDescription(o),r),""]));let a=e.visibleArguments(t).map(t=>s(e.styleArgumentTerm(e.argumentTerm(t)),e.styleArgumentDescription(e.argumentDescription(t))));if(n=n.concat(this.formatItemList("Arguments:",a,e)),this.groupItems(t.options,e.visibleOptions(t),t=>t.helpGroupHeading??"Options:").forEach((t,i)=>{let r=t.map(t=>s(e.styleOptionTerm(e.optionTerm(t)),e.styleOptionDescription(e.optionDescription(t))));n=n.concat(this.formatItemList(i,r,e))}),e.showGlobalOptions){let i=e.visibleGlobalOptions(t).map(t=>s(e.styleOptionTerm(e.optionTerm(t)),e.styleOptionDescription(e.optionDescription(t))));n=n.concat(this.formatItemList("Global Options:",i,e))}return this.groupItems(t.commands,e.visibleCommands(t),t=>t.helpGroup()||"Commands:").forEach((t,i)=>{let r=t.map(t=>s(e.styleSubcommandTerm(e.subcommandTerm(t)),e.styleSubcommandDescription(e.subcommandDescription(t))));n=n.concat(this.formatItemList(i,r,e))}),n.join("\n")}displayWidth(t){return l(t).length}styleTitle(t){return t}styleUsage(t){return t.split(" ").map(t=>"[options]"===t?this.styleOptionText(t):"[command]"===t?this.styleSubcommandText(t):"["===t[0]||"<"===t[0]?this.styleArgumentText(t):this.styleCommandText(t)).join(" ")}styleCommandDescription(t){return this.styleDescriptionText(t)}styleOptionDescription(t){return this.styleDescriptionText(t)}styleSubcommandDescription(t){return this.styleDescriptionText(t)}styleArgumentDescription(t){return this.styleDescriptionText(t)}styleDescriptionText(t){return t}styleOptionTerm(t){return this.styleOptionText(t)}styleSubcommandTerm(t){return t.split(" ").map(t=>"[options]"===t?this.styleOptionText(t):"["===t[0]||"<"===t[0]?this.styleArgumentText(t):this.styleSubcommandText(t)).join(" ")}styleArgumentTerm(t){return this.styleArgumentText(t)}styleOptionText(t){return t}styleArgumentText(t){return t}styleSubcommandText(t){return t}styleCommandText(t){return t}padWidth(t,e){return Math.max(e.longestOptionTermLength(t,e),e.longestGlobalOptionTermLength(t,e),e.longestSubcommandTermLength(t,e),e.longestArgumentTermLength(t,e))}preformatted(t){return/\n[^\S\r\n]/.test(t)}formatItem(t,e,i,r){let s,n=" ".repeat(2);if(!i)return n+t;let o=t.padEnd(e+t.length-r.displayWidth(t)),a=(this.helpWidth??80)-e-2-2;return s=a<this.minWidthToWrap||r.preformatted(i)?i:r.boxWrap(i,a).replace(/\n/g,"\n"+" ".repeat(e+2)),n+o+" ".repeat(2)+s.replace(/\n/g,` ${n}`)}boxWrap(t,e){if(e<this.minWidthToWrap)return t;let i=t.split(/\r\n|\n/),r=/[\s]*[^\s]+/g,s=[];return i.forEach(t=>{let i=t.match(r);if(null===i)return void s.push("");let n=[i.shift()],o=this.displayWidth(n[0]);i.forEach(t=>{let i=this.displayWidth(t);if(o+i<=e){n.push(t),o+=i;return}s.push(n.join(""));let r=t.trimStart();n=[r],o=this.displayWidth(r)}),s.push(n.join(""))}),s.join("\n")}}class tz{constructor(t,e){this.flags=t,this.description=e||"",this.required=t.includes("<"),this.optional=t.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(t),this.mandatory=!1;let i=function(t){let e,i,r=/^-[^-]$/,s=/^--[^-]/,n=t.split(/[ |,]+/).concat("guard");if(r.test(n[0])&&(e=n.shift()),s.test(n[0])&&(i=n.shift()),!e&&r.test(n[0])&&(e=n.shift()),!e&&s.test(n[0])&&(e=i,i=n.shift()),n[0].startsWith("-")){let e=n[0],i=`option creation failed due to '${e}' in option flags '${t}'`;if(/^-[^-][^-]/.test(e))throw Error(`${i} - 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')`);if(r.test(e))throw Error(`${i} - too many short flags`);if(s.test(e))throw Error(`${i} - too many long flags`);throw Error(`${i} - unrecognised flag format`)}if(void 0===e&&void 0===i)throw Error(`option creation failed due to no flags found in '${t}'.`);return{shortFlag:e,longFlag:i}}(t);this.short=i.shortFlag,this.long=i.longFlag,this.negate=!1,this.long&&(this.negate=this.long.startsWith("--no-")),this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0,this.helpGroupHeading=void 0}default(t,e){return this.defaultValue=t,this.defaultValueDescription=e,this}preset(t){return this.presetArg=t,this}conflicts(t){return this.conflictsWith=this.conflictsWith.concat(t),this}implies(t){let e=t;return"string"==typeof t&&(e={[t]:!0}),this.implied=Object.assign(this.implied||{},e),this}env(t){return this.envVar=t,this}argParser(t){return this.parseArg=t,this}makeOptionMandatory(t=!0){return this.mandatory=!!t,this}hideHelp(t=!0){return this.hidden=!!t,this}_collectValue(t,e){return e!==this.defaultValue&&Array.isArray(e)?(e.push(t),e):[t]}choices(t){return this.argChoices=t.slice(),this.parseArg=(t,e)=>{if(!this.argChoices.includes(t))throw new tL(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._collectValue(t,e):t},this}name(){return this.long?this.long.replace(/^--/,""):this.short.replace(/^-/,"")}attributeName(){return this.negate?tK(this.name().replace(/^no-/,"")):tK(this.name())}helpGroup(t){return this.helpGroupHeading=t,this}is(t){return this.short===t||this.long===t}isBoolean(){return!this.required&&!this.optional&&!this.negate}}class tJ{constructor(t){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,t.forEach(t=>{t.negate?this.negativeOptions.set(t.attributeName(),t):this.positiveOptions.set(t.attributeName(),t)}),this.negativeOptions.forEach((t,e)=>{this.positiveOptions.has(e)&&this.dualOptions.add(e)})}valueFromOption(t,e){let i=e.attributeName();if(!this.dualOptions.has(i))return!0;let r=this.negativeOptions.get(i).presetArg;return e.negate===((void 0!==r&&r)===t)}}function tK(t){return t.split("-").reduce((t,e)=>t+e[0].toUpperCase()+e.slice(1))}function tY(t,e){if(!e||0===e.length)return"";e=Array.from(new Set(e));let i=t.startsWith("--");i&&(t=t.slice(2),e=e.map(t=>t.slice(2)));let r=[],s=3;return(e.forEach(e=>{if(e.length<=1)return;let i=function(t,e){if(Math.abs(t.length-e.length)>3)return Math.max(t.length,e.length);let i=[];for(let e=0;e<=t.length;e++)i[e]=[e];for(let t=0;t<=e.length;t++)i[0][t]=t;for(let r=1;r<=e.length;r++)for(let s=1;s<=t.length;s++){let n;n=+(t[s-1]!==e[r-1]),i[s][r]=Math.min(i[s-1][r]+1,i[s][r-1]+1,i[s-1][r-1]+n),s>1&&r>1&&t[s-1]===e[r-2]&&t[s-2]===e[r-1]&&(i[s][r]=Math.min(i[s][r],i[s-2][r-2]+1))}return i[t.length][e.length]}(t,e),n=Math.max(t.length,e.length);(n-i)/n>.4&&(i<s?(s=i,r=[e]):i===s&&r.push(e))}),r.sort((t,e)=>t.localeCompare(e)),i&&(r=r.map(t=>`--${t}`)),r.length>1)?` (Did you mean one of ${r.join(", ")}?)`:1===r.length?` (Did you mean ${r[0]}?)`:""}class tZ extends v{constructor(t){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=t||"",this._optionValues={},this._optionValueSources={},this._storeOptionsAsProperties=!1,this._actionHandler=null,this._executableHandler=!1,this._executableFile=null,this._executableDir=null,this._defaultCommandName=null,this._exitCallback=null,this._aliases=[],this._combineFlagAndOptionalValue=!0,this._description="",this._summary="",this._argsDescription=void 0,this._enablePositionalOptions=!1,this._passThroughOptions=!1,this._lifeCycleHooks={},this._showHelpAfterError=!1,this._showSuggestionAfterError=!0,this._savedState=null,this._outputConfiguration={writeOut:t=>r.stdout.write(t),writeErr:t=>r.stderr.write(t),outputError:(t,e)=>e(t),getOutHelpWidth:()=>r.stdout.isTTY?r.stdout.columns:void 0,getErrHelpWidth:()=>r.stderr.isTTY?r.stderr.columns:void 0,getOutHasColors:()=>tX()??(r.stdout.isTTY&&r.stdout.hasColors?.()),getErrHasColors:()=>tX()??(r.stderr.isTTY&&r.stderr.hasColors?.()),stripColor:t=>l(t)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={},this._helpGroupHeading=void 0,this._defaultCommandGroup=void 0,this._defaultOptionGroup=void 0}copyInheritedSettings(t){return this._outputConfiguration=t._outputConfiguration,this._helpOption=t._helpOption,this._helpCommand=t._helpCommand,this._helpConfiguration=t._helpConfiguration,this._exitCallback=t._exitCallback,this._storeOptionsAsProperties=t._storeOptionsAsProperties,this._combineFlagAndOptionalValue=t._combineFlagAndOptionalValue,this._allowExcessArguments=t._allowExcessArguments,this._enablePositionalOptions=t._enablePositionalOptions,this._showHelpAfterError=t._showHelpAfterError,this._showSuggestionAfterError=t._showSuggestionAfterError,this}_getCommandAndAncestors(){let t=[];for(let e=this;e;e=e.parent)t.push(e);return t}command(t,e,i){let r=e,s=i;"object"==typeof r&&null!==r&&(s=r,r=null),s=s||{};let[,n,o]=t.match(/([^ ]+) *(.*)/),a=this.createCommand(n);return(r&&(a.description(r),a._executableHandler=!0),s.isDefault&&(this._defaultCommandName=a._name),a._hidden=!!(s.noHelp||s.hidden),a._executableFile=s.executableFile||null,o&&a.arguments(o),this._registerCommand(a),a.parent=this,a.copyInheritedSettings(this),r)?this:a}createCommand(t){return new tZ(t)}createHelp(){return Object.assign(new tq,this.configureHelp())}configureHelp(t){return void 0===t?this._helpConfiguration:(this._helpConfiguration=t,this)}configureOutput(t){return void 0===t?this._outputConfiguration:(this._outputConfiguration={...this._outputConfiguration,...t},this)}showHelpAfterError(t=!0){return"string"!=typeof t&&(t=!!t),this._showHelpAfterError=t,this}showSuggestionAfterError(t=!0){return this._showSuggestionAfterError=!!t,this}addCommand(t,e){if(!t._name)throw Error(`Command passed to .addCommand() must have a name - specify the name in Command constructor or using .name()`);return(e=e||{}).isDefault&&(this._defaultCommandName=t._name),(e.noHelp||e.hidden)&&(t._hidden=!0),this._registerCommand(t),t.parent=this,t._checkForBrokenPassThrough(),this}createArgument(t,e){return new tB(t,e)}argument(t,e,i,r){let s=this.createArgument(t,e);return"function"==typeof i?s.default(r).argParser(i):s.default(i),this.addArgument(s),this}arguments(t){return t.trim().split(/ +/).forEach(t=>{this.argument(t)}),this}addArgument(t){let e=this.registeredArguments.slice(-1)[0];if(e?.variadic)throw Error(`only the last argument can be variadic '${e.name()}'`);if(t.required&&void 0!==t.defaultValue&&void 0===t.parseArg)throw Error(`a default value for a required argument is never used: '${t.name()}'`);return this.registeredArguments.push(t),this}helpCommand(t,e){if("boolean"==typeof t)return this._addImplicitHelpCommand=t,t&&this._defaultCommandGroup&&this._initCommandGroup(this._getHelpCommand()),this;let[,i,r]=(t??"help [command]").match(/([^ ]+) *(.*)/),s=e??"display help for command",n=this.createCommand(i);return n.helpOption(!1),r&&n.arguments(r),s&&n.description(s),this._addImplicitHelpCommand=!0,this._helpCommand=n,(t||e)&&this._initCommandGroup(n),this}addHelpCommand(t,e){return"object"!=typeof t?this.helpCommand(t,e):(this._addImplicitHelpCommand=!0,this._helpCommand=t,this._initCommandGroup(t)),this}_getHelpCommand(){return this._addImplicitHelpCommand??(this.commands.length&&!this._actionHandler&&!this._findCommand("help"))?(void 0===this._helpCommand&&this.helpCommand(void 0,void 0),this._helpCommand):null}hook(t,e){let i=["preSubcommand","preAction","postAction"];if(!i.includes(t))throw Error(`Unexpected value for event passed to hook : '${t}'. Expecting one of '${i.join("', '")}'`);return this._lifeCycleHooks[t]?this._lifeCycleHooks[t].push(e):this._lifeCycleHooks[t]=[e],this}exitOverride(t){return t?this._exitCallback=t:this._exitCallback=t=>{if("commander.executeSubCommandAsync"!==t.code)throw t},this}_exit(t,e,i){this._exitCallback&&this._exitCallback(new tR(t,e,i)),r.exit(t)}action(t){let e=e=>{let i=this.registeredArguments.length,r=e.slice(0,i);return this._storeOptionsAsProperties?r[i]=this:r[i]=this.opts(),r.push(this),t.apply(this,r)};return this._actionHandler=e,this}createOption(t,e){return new tz(t,e)}_callParseArg(t,e,i,r){try{return t.parseArg(e,i)}catch(t){if("commander.invalidArgument"===t.code){let e=`${r} ${t.message}`;this.error(e,{exitCode:t.exitCode,code:t.code})}throw t}}_registerOption(t){let e=t.short&&this._findOption(t.short)||t.long&&this._findOption(t.long);if(e){let i=t.long&&this._findOption(t.long)?t.long:t.short;throw Error(`Cannot add option '${t.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${i}' - already used by option '${e.flags}'`)}this._initOptionGroup(t),this.options.push(t)}_registerCommand(t){let e=t=>[t.name()].concat(t.aliases()),i=e(t).find(t=>this._findCommand(t));if(i){let r=e(this._findCommand(i)).join("|"),s=e(t).join("|");throw Error(`cannot add command '${s}' as already have command '${r}'`)}this._initCommandGroup(t),this.commands.push(t)}addOption(t){this._registerOption(t);let e=t.name(),i=t.attributeName();void 0!==t.defaultValue&&this.setOptionValueWithSource(i,t.defaultValue,"default");let r=(e,r,s)=>{null==e&&void 0!==t.presetArg&&(e=t.presetArg);let n=this.getOptionValue(i);null!==e&&t.parseArg?e=this._callParseArg(t,e,n,r):null!==e&&t.variadic&&(e=t._collectValue(e,n)),null==e&&(e=!t.negate&&(!!t.isBoolean()||!!t.optional||"")),this.setOptionValueWithSource(i,e,s)};return this.on("option:"+e,e=>{let i=`error: option '${t.flags}' argument '${e}' is invalid.`;r(e,i,"cli")}),t.envVar&&this.on("optionEnv:"+e,e=>{let i=`error: option '${t.flags}' value '${e}' from env '${t.envVar}' is invalid.`;r(e,i,"env")}),this}_optionEx(t,e,i,r,s){if("object"==typeof e&&e instanceof tz)throw Error("To add an Option object use addOption() instead of option() or requiredOption()");let n=this.createOption(e,i);if(n.makeOptionMandatory(!!t.mandatory),"function"==typeof r)n.default(s).argParser(r);else if(r instanceof RegExp){let t=r;r=(e,i)=>{let r=t.exec(e);return r?r[0]:i},n.default(s).argParser(r)}else n.default(r);return this.addOption(n)}option(t,e,i,r){return this._optionEx({},t,e,i,r)}requiredOption(t,e,i,r){return this._optionEx({mandatory:!0},t,e,i,r)}combineFlagAndOptionalValue(t=!0){return this._combineFlagAndOptionalValue=!!t,this}allowUnknownOption(t=!0){return this._allowUnknownOption=!!t,this}allowExcessArguments(t=!0){return this._allowExcessArguments=!!t,this}enablePositionalOptions(t=!0){return this._enablePositionalOptions=!!t,this}passThroughOptions(t=!0){return this._passThroughOptions=!!t,this._checkForBrokenPassThrough(),this}_checkForBrokenPassThrough(){if(this.parent&&this._passThroughOptions&&!this.parent._enablePositionalOptions)throw Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}storeOptionsAsProperties(t=!0){if(this.options.length)throw Error("call .storeOptionsAsProperties() before adding options");if(Object.keys(this._optionValues).length)throw Error("call .storeOptionsAsProperties() before setting option values");return this._storeOptionsAsProperties=!!t,this}getOptionValue(t){return this._storeOptionsAsProperties?this[t]:this._optionValues[t]}setOptionValue(t,e){return this.setOptionValueWithSource(t,e,void 0)}setOptionValueWithSource(t,e,i){return this._storeOptionsAsProperties?this[t]=e:this._optionValues[t]=e,this._optionValueSources[t]=i,this}getOptionValueSource(t){return this._optionValueSources[t]}getOptionValueSourceWithGlobals(t){let e;return this._getCommandAndAncestors().forEach(i=>{void 0!==i.getOptionValueSource(t)&&(e=i.getOptionValueSource(t))}),e}_prepareUserArgs(t,e){let i;if(void 0!==t&&!Array.isArray(t))throw Error("first parameter to parse must be array or undefined");if(e=e||{},void 0===t&&void 0===e.from){r.versions?.electron&&(e.from="electron");let t=r.execArgv??[];(t.includes("-e")||t.includes("--eval")||t.includes("-p")||t.includes("--print"))&&(e.from="eval")}switch(void 0===t&&(t=r.argv),this.rawArgs=t.slice(),e.from){case void 0:case"node":this._scriptPath=t[1],i=t.slice(2);break;case"electron":r.defaultApp?(this._scriptPath=t[1],i=t.slice(2)):i=t.slice(1);break;case"user":i=t.slice(0);break;case"eval":i=t.slice(1);break;default:throw Error(`unexpected parse option { from: '${e.from}' }`)}return!this._name&&this._scriptPath&&this.nameFromFilename(this._scriptPath),this._name=this._name||"program",i}parse(t,e){this._prepareForParse();let i=this._prepareUserArgs(t,e);return this._parseCommand([],i),this}async parseAsync(t,e){this._prepareForParse();let i=this._prepareUserArgs(t,e);return await this._parseCommand([],i),this}_prepareForParse(){null===this._savedState?(this.options.filter(t=>t.negate&&void 0===t.defaultValue&&void 0===this.getOptionValue(t.attributeName())).forEach(t=>{let e=t.long.replace(/^--no-/,"--");this._findOption(e)||this.setOptionValueWithSource(t.attributeName(),!0,"default")}),this.saveStateBeforeParse()):this.restoreStateBeforeParse()}saveStateBeforeParse(){this._savedState={_name:this._name,_optionValues:{...this._optionValues},_optionValueSources:{...this._optionValueSources}}}restoreStateBeforeParse(){if(this._storeOptionsAsProperties)throw 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(t,e,i){if(p.existsSync(t))return;let r=e?`searched for local subcommand relative to directory '${e}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory";throw Error(`'${t}' does not exist - if '${i}' 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 - ${r}`)}_executeSubCommand(t,i){let s;i=i.slice();let n=[".js",".ts",".tsx",".mjs",".cjs"];function o(t,e){let i=_.resolve(t,e);if(p.existsSync(i))return i;if(n.includes(_.extname(e)))return;let r=n.find(t=>p.existsSync(`${i}${t}`));if(r)return`${i}${r}`}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let a=t._executableFile||`${this._name}-${t._name}`,l=this._executableDir||"";if(this._scriptPath){let t;try{t=p.realpathSync(this._scriptPath)}catch{t=this._scriptPath}l=_.resolve(_.dirname(t),l)}if(l){let e=o(l,a);if(!e&&!t._executableFile&&this._scriptPath){let i=_.basename(this._scriptPath,_.extname(this._scriptPath));i!==this._name&&(e=o(l,`${i}-${t._name}`))}a=e||a}let h=n.includes(_.extname(a));"win32"!==r.platform?h?(i.unshift(a),i=tQ(r.execArgv).concat(i),s=e.spawn(r.argv["0"],i,{stdio:"inherit"})):s=e.spawn(a,i,{stdio:"inherit"}):(this._checkForMissingExecutable(a,l,t._name),i.unshift(a),i=tQ(r.execArgv).concat(i),s=e.spawn(r.execPath,i,{stdio:"inherit"})),s.killed||["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach(t=>{r.on(t,()=>{!1===s.killed&&null===s.exitCode&&s.kill(t)})});let u=this._exitCallback;s.on("close",t=>{t=t??1,u?u(new tR(t,"commander.executeSubCommandAsync","(close)")):r.exit(t)}),s.on("error",e=>{if("ENOENT"===e.code)this._checkForMissingExecutable(a,l,t._name);else if("EACCES"===e.code)throw Error(`'${a}' not executable`);if(u){let t=new tR(1,"commander.executeSubCommandAsync","(error)");t.nestedError=e,u(t)}else r.exit(1)}),this.runningCommand=s}_dispatchSubcommand(t,e,i){let r,s=this._findCommand(t);return s||this.help({error:!0}),s._prepareForParse(),r=this._chainOrCallSubCommandHook(r,s,"preSubcommand"),r=this._chainOrCall(r,()=>{if(!s._executableHandler)return s._parseCommand(e,i);this._executeSubCommand(s,e.concat(i))})}_dispatchHelpCommand(t){t||this.help();let e=this._findCommand(t);return e&&!e._executableHandler&&e.help(),this._dispatchSubcommand(t,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){this.registeredArguments.forEach((t,e)=>{t.required&&null==this.args[e]&&this.missingArgument(t.name())}),this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic||this.args.length>this.registeredArguments.length&&this._excessArguments(this.args)}_processArguments(){let t=(t,e,i)=>{let r=e;if(null!==e&&t.parseArg){let s=`error: command-argument value '${e}' is invalid for argument '${t.name()}'.`;r=this._callParseArg(t,e,i,s)}return r};this._checkNumberOfArguments();let e=[];this.registeredArguments.forEach((i,r)=>{let s=i.defaultValue;i.variadic?r<this.args.length?(s=this.args.slice(r),i.parseArg&&(s=s.reduce((e,r)=>t(i,r,e),i.defaultValue))):void 0===s&&(s=[]):r<this.args.length&&(s=this.args[r],i.parseArg&&(s=t(i,s,i.defaultValue))),e[r]=s}),this.processedArgs=e}_chainOrCall(t,e){return t?.then&&"function"==typeof t.then?t.then(()=>e()):e()}_chainOrCallHooks(t,e){let i=t,r=[];return this._getCommandAndAncestors().reverse().filter(t=>void 0!==t._lifeCycleHooks[e]).forEach(t=>{t._lifeCycleHooks[e].forEach(e=>{r.push({hookedCommand:t,callback:e})})}),"postAction"===e&&r.reverse(),r.forEach(t=>{i=this._chainOrCall(i,()=>t.callback(t.hookedCommand,this))}),i}_chainOrCallSubCommandHook(t,e,i){let r=t;return void 0!==this._lifeCycleHooks[i]&&this._lifeCycleHooks[i].forEach(t=>{r=this._chainOrCall(r,()=>t(this,e))}),r}_parseCommand(t,e){let i=this.parseOptions(e);if(this._parseOptionsEnv(),this._parseOptionsImplied(),t=t.concat(i.operands),e=i.unknown,this.args=t.concat(e),t&&this._findCommand(t[0]))return this._dispatchSubcommand(t[0],t.slice(1),e);if(this._getHelpCommand()&&t[0]===this._getH