create-mugnavo 0.4.2 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs
CHANGED
|
@@ -1,92 +1,86 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{
|
|
3
|
-
`),u=!1;for(let e=0;e<l.length;e++){let t=l[e];if(r+=t,u)u=!1;else if(u=t>=`\ud800`&&t<=`\udbff`,u)continue;if(t===`\x1B`||t===``){
|
|
4
|
-
`){a&&(r+=
|
|
5
|
-
`&&(i&&
|
|
6
|
-
`)}var
|
|
2
|
+
import{createRequire as e}from"node:module";import{parseArgs as t,promisify as n,styleText as r}from"node:util";import i,{cwd as a,stdin as o,stdout as s}from"node:process";import*as c from"node:readline";import l from"node:readline";import{ReadStream as u}from"node:tty";import{closeSync as d,constants as f,createWriteStream as p,existsSync as m,openSync as h,readSync as g,readdirSync as _,renameSync as v,statSync as y}from"node:fs";import{basename as b,delimiter as x,dirname as S,join as C,normalize as ee,resolve as w}from"node:path";import{copyFile as te,mkdir as T,mkdtemp as ne,readFile as E,readdir as D,rm as O,writeFile as k}from"node:fs/promises";import{PassThrough as re,Readable as ie,pipeline as ae}from"node:stream";import{spawn as oe}from"node:child_process";import{pipeline as se}from"node:stream/promises";import{homedir as ce,tmpdir as le}from"node:os";var ue=Object.defineProperty,de=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),fe=(e,t)=>{let n={};for(var r in e)ue(n,r,{get:e[r],enumerable:!0});return t||ue(n,Symbol.toStringTag,{value:`Module`}),n};const pe=(()=>{let e=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;return t=>{let n=0;for(e.lastIndex=0;e.test(t);)n+=1;return t.length-n}})(),me=e=>e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510,he=e=>e===8987||e===9001||e>=12272&&e<=12287||e>=12289&&e<=12350||e>=12441&&e<=12543||e>=12549&&e<=12591||e>=12593&&e<=12686||e>=12688&&e<=12771||e>=12783&&e<=12830||e>=12832&&e<=12871||e>=12880&&e<=19903||e>=65040&&e<=65049||e>=65072&&e<=65106||e>=65108&&e<=65126||e>=65128&&e<=65131||e>=127488&&e<=127490||e>=127504&&e<=127547||e>=127552&&e<=127560||e>=131072&&e<=196605||e>=196608&&e<=262141,ge=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,_e=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,ve=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/uy,ye=/\t{1,1000}/y,be=/[\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?))*/uy,xe=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,Se=/\p{M}+/gu,Ce={limit:1/0,ellipsis:``},we=(e,t={},n={})=>{let r=t.limit??1/0,i=t.ellipsis??``,a=t?.ellipsisWidth??(i?we(i,Ce,n).width:0),o=n.controlWidth??0,s=n.tabWidth??8,c=n.emojiWidth??2,l=n.regularWidth??1,u=n.wideWidth??2,d=[[xe,l],[ge,0],[_e,o],[ye,s],[be,c],[ve,u]],f=0,p=0,m=e.length,h=0,g=!1,_=m,v=Math.max(0,r-a),y=0,b=0,x=0,S=0;outer:for(;;){if(b>y||p>=m&&p>f){let t=e.slice(y,b)||e.slice(f,p);h=0;for(let e of t.replaceAll(Se,``)){let t=e.codePointAt(0)||0;if(S=me(t)?2:he(t)?u:l,x+S>v&&(_=Math.min(_,Math.max(y,f)+h)),x+S>r){g=!0;break outer}h+=e.length,x+=S}y=b=0}if(p>=m)break outer;for(let t=0,n=d.length;t<n;t++){let[n,i]=d[t];if(n.lastIndex=p,n.test(e)){if(h=n===ve?pe(e.slice(p,n.lastIndex)):n===be?1:n.lastIndex-p,S=h*i,x+S>v&&(_=Math.min(_,p+Math.floor((v-x)/i))),x+S>r){g=!0;break outer}x+=S,y=f,b=p,p=f=n.lastIndex;continue outer}}p+=1}return{width:g?v:x,index:g?_:m,truncated:g,ellipsed:g&&r>=a}},Te={limit:1/0,ellipsis:``,ellipsisWidth:0},A=(e,t={})=>we(e,Te,t).width,Ee=`]8;;`,De=RegExp(`(?:\\[(?<code>\\d+)m|\\${Ee}(?<uri>.*))`,`y`),Oe=e=>{if(e>=30&&e<=37||e>=90&&e<=97)return 39;if(e>=40&&e<=47||e>=100&&e<=107)return 49;if(e===1||e===2)return 22;if(e===3)return 23;if(e===4)return 24;if(e===7)return 27;if(e===8)return 28;if(e===9)return 29;if(e===0)return 0},ke=e=>`[${e}m`,Ae=e=>`${Ee}${e}`,je=(e,t,n)=>{let r=t[Symbol.iterator](),i=!1,a=!1,o=e.at(-1),s=o===void 0?0:A(o),c=r.next(),l=r.next(),u=0;for(;!c.done;){let o=c.value,d=A(o);s+d<=n?e[e.length-1]+=o:(e.push(o),s=0),(o===`\x1B`||o===``)&&(i=!0,a=t.startsWith(Ee,u+1)),i?a?o===`\x07`&&(i=!1,a=!1):o===`m`&&(i=!1):(s+=d,s===n&&!l.done&&(e.push(``),s=0)),c=l,l=r.next(),u+=o.length}o=e.at(-1),!s&&o!==void 0&&o.length&&e.length>1&&(e[e.length-2]+=e.pop())},Me=e=>{let t=e.split(` `),n=t.length;for(;n&&!A(t[n-1]);)n--;return n===t.length?e:t.slice(0,n).join(` `)+t.slice(n).join(``)},Ne=(e,t,n={})=>{if(n.trim!==!1&&e.trim()===``)return``;let r=``,i,a,o=e.split(` `),s=[``],c=0;for(let e=0;e<o.length;e++){let r=o[e];if(n.trim!==!1){let e=s.at(-1)??``,t=e.trimStart();e.length!==t.length&&(s[s.length-1]=t,c=A(t))}e!==0&&(c>=t&&(n.wordWrap===!1||n.trim===!1)&&(s.push(``),c=0),(c||n.trim===!1)&&(s[s.length-1]+=` `,c++));let i=A(r);if(n.hard&&i>t){let e=t-c,n=1+Math.floor((i-e-1)/t);Math.floor((i-1)/t)<n&&s.push(``),je(s,r,t),c=A(s.at(-1)??``);continue}if(c+i>t&&c&&i){if(n.wordWrap===!1&&c<t){je(s,r,t),c=A(s.at(-1)??``);continue}s.push(``),c=0}if(c+i>t&&n.wordWrap===!1){je(s,r,t),c=A(s.at(-1)??``);continue}s[s.length-1]+=r,c+=i}n.trim!==!1&&(s=s.map(e=>Me(e)));let l=s.join(`
|
|
3
|
+
`),u=!1;for(let e=0;e<l.length;e++){let t=l[e];if(r+=t,u)u=!1;else if(u=t>=`\ud800`&&t<=`\udbff`,u)continue;if(t===`\x1B`||t===``){De.lastIndex=e+1;let t=De.exec(l)?.groups;if(t?.code!==void 0){let e=Number.parseFloat(t.code);i=e===39?void 0:e}else t?.uri!==void 0&&(a=t.uri.length===0?void 0:t.uri)}if(l[e+1]===`
|
|
4
|
+
`){a&&(r+=Ae(``));let e=i?Oe(i):void 0;i&&e&&(r+=ke(e))}else t===`
|
|
5
|
+
`&&(i&&Oe(i)&&(r+=ke(i)),a&&(r+=Ae(a)))}return r},Pe=/\r?\n/;function j(e,t,n){return String(e).normalize().split(Pe).map(e=>Ne(e,t,n)).join(`
|
|
6
|
+
`)}var M=de(((e,t)=>{let n={to(e,t){return t?`[${t+1};${e+1}H`:`[${e+1}G`},move(e,t){let n=``;return e<0?n+=`[${-e}D`:e>0&&(n+=`[${e}C`),t<0?n+=`[${-t}A`:t>0&&(n+=`[${t}B`),n},up:(e=1)=>`[${e}A`,down:(e=1)=>`[${e}B`,forward:(e=1)=>`[${e}C`,backward:(e=1)=>`[${e}D`,nextLine:(e=1)=>`\x1B[E`.repeat(e),prevLine:(e=1)=>`\x1B[F`.repeat(e),left:`\x1B[G`,hide:`\x1B[?25l`,show:`\x1B[?25h`,save:`\x1B7`,restore:`\x1B8`};t.exports={cursor:n,scroll:{up:(e=1)=>`\x1B[S`.repeat(e),down:(e=1)=>`\x1B[T`.repeat(e)},erase:{screen:`\x1B[2J`,up:(e=1)=>`\x1B[1J`.repeat(e),down:(e=1)=>`\x1B[J`.repeat(e),line:`\x1B[2K`,lineEnd:`\x1B[K`,lineStart:`\x1B[1K`,lines(e){let t=``;for(let r=0;r<e;r++)t+=this.line+(r<e-1?n.up():``);return e&&(t+=n.left),t}},beep:`\x07`}}))();function Fe(e,t,n){if(!n.some(e=>!e.disabled))return e;let r=e+t,i=Math.max(n.length-1,0),a=r<0?i:r>i?0:r;return n[a].disabled?Fe(a,t<0?-1:1,n):a}const N={actions:new Set([`up`,`down`,`left`,`right`,`space`,`enter`,`cancel`]),aliases:new Map([[`k`,`up`],[`j`,`down`],[`h`,`left`],[`l`,`right`],[``,`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:(e,t)=>`There are only ${e} days in ${t}`,afterMin:e=>`Date must be on or after ${e.toISOString().slice(0,10)}`,beforeMax:e=>`Date must be on or before ${e.toISOString().slice(0,10)}`}}};function Ie(e,t){if(typeof e==`string`)return N.aliases.get(e)===t;for(let n of e)if(n!==void 0&&Ie(n,t))return!0;return!1}function Le(e,t){if(e===t)return;let n=e.split(`
|
|
7
7
|
`),r=t.split(`
|
|
8
|
-
`),i=Math.max(n.length,r.length),a=[];for(let e=0;e<i;e++)n[e]!==r[e]&&a.push(e);return{lines:a,numLinesBefore:n.length,numLinesAfter:r.length,numLines:i}}const
|
|
9
|
-
`).map((e,t)=>{let a
|
|
10
|
-
`)}let Ke=class{input;output;_abortSignal;rl;opts;_render;_track=!1;_prevFrame=``;_subscribers=new Map;_cursor=0;state=`initial`;error=``;value;userInput=``;constructor(e,t=!0){let{input:n=
|
|
11
|
-
`),
|
|
12
|
-
`).length-1;this.output.write(
|
|
13
|
-
`);this.output.write(t[a]),this._prevFrame=e,this.output.write(
|
|
8
|
+
`),i=Math.max(n.length,r.length),a=[];for(let e=0;e<i;e++)n[e]!==r[e]&&a.push(e);return{lines:a,numLinesBefore:n.length,numLinesAfter:r.length,numLines:i}}const Re=globalThis.process.platform.startsWith(`win`),ze=Symbol(`clack:cancel`);function Be(e){return e===ze}function Ve(e,t){let n=e;n.isTTY&&n.setRawMode(t)}function He({input:e=o,output:t=s,overwrite:n=!0,hideCursor:r=!0}={}){let i=c.createInterface({input:e,output:t,prompt:``,tabSize:1});c.emitKeypressEvents(e,i),e instanceof u&&e.isTTY&&e.setRawMode(!0);let a=(i,{name:o,sequence:s})=>{if(Ie([String(i),o,s],`cancel`)){r&&t.write(M.cursor.show),process.exit(0);return}if(!n)return;let l=o===`return`?0:-1,u=o===`return`?-1:0;c.moveCursor(t,l,u,()=>{c.clearLine(t,1,()=>{e.once(`keypress`,a)})})};return r&&t.write(M.cursor.hide),e.once(`keypress`,a),()=>{e.off(`keypress`,a),r&&t.write(M.cursor.show),e instanceof u&&e.isTTY&&!Re&&e.setRawMode(!1),i.terminal=!1,i.close()}}const P=e=>`columns`in e&&typeof e.columns==`number`?e.columns:80,Ue=e=>`rows`in e&&typeof e.rows==`number`?e.rows:20;function We(e,t,n,r=n,i=n,a){return j(t,P(e??s)-n.length,{hard:!0,trim:!1}).split(`
|
|
9
|
+
`).map((e,t,o)=>{let s=a?a(e,t):e;return t===0?`${r}${s}`:t===o.length-1?`${i}${s}`:`${n}${s}`}).join(`
|
|
10
|
+
`)}function Ge(e,t){if(`~standard`in e){let n=e[`~standard`].validate(t);if(n instanceof Promise)throw TypeError("Schema validation must be synchronous. Update `validate()` and remove any asynchronous logic.");return n.issues?.at(0)?.message}return e(t)}var Ke=class{input;output;_abortSignal;rl;opts;_render;_track=!1;_prevFrame=``;_subscribers=new Map;_cursor=0;state=`initial`;error=``;value;userInput=``;constructor(e,t=!0){let{input:n=o,output:r=s,render:i,signal:a,...c}=e;this.opts=c,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=i.bind(this),this._track=t,this._abortSignal=a,this.input=n,this.output=r}unsubscribe(){this._subscribers.clear()}setSubscriber(e,t){let n=this._subscribers.get(e)??[];n.push(t),this._subscribers.set(e,n)}on(e,t){this.setSubscriber(e,{cb:t})}once(e,t){this.setSubscriber(e,{cb:t,once:!0})}emit(e,...t){let n=this._subscribers.get(e)??[],r=[];for(let e of n)e.cb(...t),e.once&&r.push(()=>n.splice(n.indexOf(e),1));for(let e of r)e()}prompt(){return new Promise(e=>{if(this._abortSignal){if(this._abortSignal.aborted)return this.state=`cancel`,this.close(),e(ze);this._abortSignal.addEventListener(`abort`,()=>{this.state=`cancel`,this.close()},{once:!0})}this.rl=l.createInterface({input:this.input,tabSize:2,prompt:``,escapeCodeTimeout:50,terminal:!0}),this.rl.prompt(),this.opts.initialUserInput!==void 0&&this._setUserInput(this.opts.initialUserInput,!0),this.input.on(`keypress`,this.onKeypress),Ve(this.input,!0),this.output.on(`resize`,this.render),this.render(),this.once(`submit`,()=>{this.output.write(M.cursor.show),this.output.off(`resize`,this.render),Ve(this.input,!1),e(this.value)}),this.once(`cancel`,()=>{this.output.write(M.cursor.show),this.output.off(`resize`,this.render),Ve(this.input,!1),e(ze)})})}_isActionKey(e,t){return e===` `}_shouldSubmit(e,t){return!0}_setValue(e){this.value=e,this.emit(`value`,this.value)}_setUserInput(e,t){this.userInput=e??``,this.emit(`userInput`,this.userInput),t&&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(e,t){if(this._track&&t.name!==`return`&&(t.name&&this._isActionKey(e,t)&&this.rl?.write(null,{ctrl:!0,name:`h`}),this._cursor=this.rl?.cursor??0,this._setUserInput(this.rl?.line)),this.state===`error`&&(this.state=`active`),t?.name&&(!this._track&&N.aliases.has(t.name)&&this.emit(`cursor`,N.aliases.get(t.name)),N.actions.has(t.name)&&this.emit(`cursor`,t.name)),e&&(e.toLowerCase()===`y`||e.toLowerCase()===`n`)&&this.emit(`confirm`,e.toLowerCase()===`y`),this.emit(`key`,e,t),t?.name===`return`&&this._shouldSubmit(e,t)){if(this.opts.validate){let e=Ge(this.opts.validate,this.value);e&&(this.error=e instanceof Error?e.message:e,this.state=`error`,this.rl?.write(this.userInput))}this.state!==`error`&&(this.state=`submit`)}Ie([e,t?.name,t?.sequence],`cancel`)&&(this.state=`cancel`),(this.state===`submit`||this.state===`cancel`)&&this.emit(`finalize`),this.render(),(this.state===`submit`||this.state===`cancel`)&&this.close()}close(){this.input.unpipe(),this.input.removeListener(`keypress`,this.onKeypress),this.output.write(`
|
|
11
|
+
`),Ve(this.input,!1),this.rl?.close(),this.rl=void 0,this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){let e=j(this._prevFrame,process.stdout.columns,{hard:!0,trim:!1}).split(`
|
|
12
|
+
`).length-1;this.output.write(M.cursor.move(-999,e*-1))}render(){let e=j(this._render(this)??``,process.stdout.columns,{hard:!0,trim:!1});if(e!==this._prevFrame){if(this.state===`initial`)this.output.write(M.cursor.hide);else{let t=Le(this._prevFrame,e),n=Ue(this.output);if(this.restoreCursor(),t){let r=Math.max(0,t.numLinesAfter-n),i=Math.max(0,t.numLinesBefore-n),a=t.lines.find(e=>e>=r);if(a===void 0){this._prevFrame=e;return}if(t.lines.length===1){this.output.write(M.cursor.move(0,a-i)),this.output.write(M.erase.lines(1));let t=e.split(`
|
|
13
|
+
`);this.output.write(t[a]),this._prevFrame=e,this.output.write(M.cursor.move(0,t.length-a-1));return}else if(t.lines.length>1){if(r<i)a=r;else{let e=a-i;e>0&&this.output.write(M.cursor.move(0,e))}this.output.write(M.erase.down());let t=e.split(`
|
|
14
14
|
`).slice(a);this.output.write(t.join(`
|
|
15
|
-
`)),this._prevFrame=e;return}}this.output.write(
|
|
16
|
-
`);_.push(i),v+=i.length}if(v>d){let t=0,n=0,r=v,i=e-y,a=(
|
|
15
|
+
`)),this._prevFrame=e;return}}this.output.write(M.erase.down())}this.output.write(e),this.state===`initial`&&(this.state=`active`),this._prevFrame=e}}},qe=class extends Ke{get cursor(){return+!this.value}get _value(){return this.cursor===0}constructor(e){super(e,!1),this.value=!!e.initialValue,this.on(`userInput`,()=>{this.value=this._value}),this.on(`confirm`,e=>{this.output.write(M.cursor.move(0,-1)),this.value=e,this.state=`submit`,this.close()}),this.on(`cursor`,()=>{this.value=!this.value})}},Je=class extends Ke{options;cursor=0;get _selectedValue(){return this.options[this.cursor]}changeValue(){this.value=this._selectedValue.value}constructor(e){super(e,!1),this.options=e.options;let t=this.options.findIndex(({value:t})=>t===e.initialValue),n=t===-1?0:t;this.cursor=this.options[n].disabled?Fe(n,1,this.options):n,this.changeValue(),this.on(`cursor`,e=>{switch(e){case`left`:case`up`:this.cursor=Fe(this.cursor,-1,this.options);break;case`down`:case`right`:this.cursor=Fe(this.cursor,1,this.options);break}this.changeValue()})}},Ye=class extends Ke{get userInputWithCursor(){if(this.state===`submit`)return this.userInput;let e=this.userInput;if(this.cursor>=e.length)return`${this.userInput}\u2588`;let t=e.slice(0,this.cursor),[n,...i]=e.slice(this.cursor);return`${t}${r(`inverse`,n)}${i.join(``)}`}get cursor(){return this._cursor}constructor(e){super({...e,initialUserInput:e.initialUserInput??e.initialValue}),this.on(`userInput`,e=>{this._setValue(e)}),this.on(`finalize`,()=>{this.value||=e.defaultValue,this.value===void 0&&(this.value=``)})}};function Xe(){return i.platform===`win32`?!!i.env.CI||!!i.env.WT_SESSION||!!i.env.TERMINUS_SUBLIME||i.env.ConEmuTask===`{cmd::Cmder}`||i.env.TERM_PROGRAM===`Terminus-Sublime`||i.env.TERM_PROGRAM===`vscode`||i.env.TERM===`xterm-256color`||i.env.TERM===`alacritty`||i.env.TERMINAL_EMULATOR===`JetBrains-JediTerm`:i.env.TERM!==`linux`}const Ze=Xe(),Qe=()=>process.env.CI===`true`,$e=e=>e.isTTY===!0,F=(e,t)=>Ze?e:t,et=F(`◆`,`*`),tt=F(`■`,`x`),nt=F(`▲`,`x`),I=F(`◇`,`o`),L=F(`│`,`|`),R=F(`└`,`—`),rt=F(`●`,`>`),z=F(`○`,` `),it=F(`─`,`-`),at=F(`╮`,`+`),ot=F(`├`,`+`),st=F(`╯`,`+`),ct=F(`╰`,`+`),lt=F(`●`,`•`),ut=F(`◆`,`*`),dt=F(`▲`,`!`),ft=F(`■`,`x`),pt=e=>{switch(e){case`initial`:case`active`:return r(`cyan`,et);case`cancel`:return r(`red`,tt);case`error`:return r(`yellow`,nt);case`submit`:return r(`green`,I)}},mt=e=>{switch(e){case`initial`:case`active`:return r(`cyan`,L);case`cancel`:return r(`red`,L);case`error`:return r(`yellow`,L);case`submit`:return r(`green`,L)}},ht=(e,t,n,r,i,a=!1)=>{let o=t,s=0;if(a)for(let t=r-1;t>=n&&(o-=e[t].length,s++,!(o<=i));t--);else for(let t=n;t<r&&(o-=e[t].length,s++,!(o<=i));t++);return{lineCount:o,removals:s}},gt=({cursor:e,options:t,style:n,output:i=process.stdout,maxItems:a=1/0,columnPadding:o=0,rowPadding:s=4})=>{let c=P(i)-o,l=Ue(i),u=r(`dim`,`...`),d=Math.max(l-s,0),f=Math.max(Math.min(a,d),5),p=0;e>=f-3&&(p=Math.max(Math.min(e-f+3,t.length-f),0));let m=f<t.length&&p>0,h=f<t.length&&p+f<t.length,g=Math.min(p+f,t.length),_=[],v=0;m&&v++,h&&v++;let y=p+ +!!m,b=g-+!!h;for(let r=y;r<b;r++){let i=j(n(t[r],r===e),c,{hard:!0,trim:!1}).split(`
|
|
16
|
+
`);_.push(i),v+=i.length}if(v>d){let t=0,n=0,r=v,i=e-y,a=d,o=()=>ht(_,r,0,i,a),s=()=>ht(_,r,i+1,_.length,a,!0);m?({lineCount:r,removals:t}=o(),r>a&&(h||--a,{lineCount:r,removals:n}=s())):(h||--a,{lineCount:r,removals:n}=s(),r>a&&(--a,{lineCount:r,removals:t}=o())),t>0&&(m=!0,_.splice(0,t)),n>0&&(h=!0,_.splice(_.length-n,n))}let x=[];m&&x.push(u);for(let e of _)for(let t of e)x.push(t);return h&&x.push(u),x},_t=e=>{let t=e.active??`Yes`,n=e.inactive??`No`;return new qe({active:t,inactive:n,signal:e.signal,input:e.input,output:e.output,initialValue:e.initialValue??!0,render(){let i=e.withGuide??N.withGuide,a=`${pt(this.state)} `,o=i?`${r(`gray`,L)} `:``,s=We(e.output,e.message,o,a),c=`${i?`${r(`gray`,L)}
|
|
17
17
|
`:``}${s}
|
|
18
|
-
`,l=this.value?t:n;switch(this.state){case`submit`:return`${c}${
|
|
19
|
-
${
|
|
20
|
-
${
|
|
21
|
-
`:` ${
|
|
18
|
+
`,l=this.value?t:n;switch(this.state){case`submit`:return`${c}${i?`${r(`gray`,L)} `:``}${r(`dim`,l)}`;case`cancel`:return`${c}${i?`${r(`gray`,L)} `:``}${r([`strikethrough`,`dim`],l)}${i?`
|
|
19
|
+
${r(`gray`,L)}`:``}`;default:{let a=i?`${r(`cyan`,L)} `:``,o=i?r(`cyan`,R):``;return`${c}${a}${this.value?`${r(`green`,rt)} ${t}`:`${r(`dim`,z)} ${r(`dim`,t)}`}${e.vertical?i?`
|
|
20
|
+
${r(`cyan`,L)} `:`
|
|
21
|
+
`:` ${r(`dim`,`/`)} `}${this.value?`${r(`dim`,z)} ${r(`dim`,n)}`:`${r(`green`,rt)} ${n}`}
|
|
22
22
|
${o}
|
|
23
|
-
`}}}}).prompt()},
|
|
24
|
-
`);if(f.length>0){let[e,...r]=f;e.length>0?s.push(`${u}${e}`):s.push(c?t:``);for(let e of r)e.length>0?s.push(`${d}${e}`):s.push(c?n:``)}
|
|
23
|
+
`}}}}).prompt()},B={message:(e=[],{symbol:t=r(`gray`,L),secondarySymbol:n=r(`gray`,L),output:i=process.stdout,spacing:a=1,withGuide:o}={})=>{let s=[],c=o??N.withGuide,l=c?n:``,u=c?`${t} `:``,d=c?`${n} `:``;for(let e=0;e<a;e++)s.push(l);let f=Array.isArray(e)?e:e.split(`
|
|
24
|
+
`);if(f.length>0){let[e,...r]=f;e.length>0?s.push(`${u}${e}`):s.push(c?t:``);for(let e of r)e.length>0?s.push(`${d}${e}`):s.push(c?n:``)}i.write(`${s.join(`
|
|
25
25
|
`)}
|
|
26
|
-
`)},info:(e,t)=>{
|
|
26
|
+
`)},info:(e,t)=>{B.message(e,{...t,symbol:r(`blue`,lt)})},success:(e,t)=>{B.message(e,{...t,symbol:r(`green`,ut)})},step:(e,t)=>{B.message(e,{...t,symbol:r(`green`,I)})},warn:(e,t)=>{B.message(e,{...t,symbol:r(`yellow`,dt)})},warning:(e,t)=>{B.warn(e,t)},error:(e,t)=>{B.message(e,{...t,symbol:r(`red`,ft)})}},V=(e=``,t)=>{let n=t?.output??process.stdout,i=t?.withGuide??N.withGuide?`${r(`gray`,R)} `:``;n.write(`${i}${r(`red`,e)}
|
|
27
27
|
|
|
28
|
-
`)},
|
|
29
|
-
${
|
|
28
|
+
`)},vt=(e=``,t)=>{let n=t?.output??process.stdout,i=t?.withGuide??N.withGuide?`${r(`gray`,L)}
|
|
29
|
+
${r(`gray`,R)} `:``;n.write(`${i}${e}
|
|
30
30
|
|
|
31
|
-
`)},
|
|
32
|
-
`),a=i.reduce((e,t)=>Math.max(
|
|
33
|
-
`).map(s),``],l=
|
|
34
|
-
`),f=
|
|
35
|
-
`:``,p=
|
|
31
|
+
`)},yt=e=>r(`dim`,e),bt=(e,t,n)=>{let r={hard:!0,trim:!1},i=j(e,t,r).split(`
|
|
32
|
+
`),a=i.reduce((e,t)=>Math.max(A(t),e),0);return j(e,t-(i.map(n).reduce((e,t)=>Math.max(A(t),e),0)-a),r)},xt=(e=``,t=``,n)=>{let a=n?.output??i.stdout,o=n?.withGuide??N.withGuide,s=n?.format??yt,c=[``,...bt(e,P(a)-6,s).split(`
|
|
33
|
+
`).map(s),``],l=A(t),u=Math.max(c.reduce((e,t)=>{let n=A(t);return n>e?n:e},0),l)+2,d=c.map(e=>`${r(`gray`,L)} ${e}${` `.repeat(u-A(e))}${r(`gray`,L)}`).join(`
|
|
34
|
+
`),f=o?`${r(`gray`,L)}
|
|
35
|
+
`:``,p=o?ot:ct;a.write(`${f}${r(`green`,I)} ${r(`reset`,t)} ${r(`gray`,it.repeat(Math.max(u-l-1,1))+at)}
|
|
36
36
|
${d}
|
|
37
|
-
${
|
|
38
|
-
`)},
|
|
39
|
-
`);let e=
|
|
40
|
-
`);e.length>1&&n.write(
|
|
41
|
-
`);let
|
|
37
|
+
${r(`gray`,p+it.repeat(u+2)+st)}
|
|
38
|
+
`)},St=e=>r(`magenta`,e),Ct=({indicator:e=`dots`,onCancel:t,output:n=process.stdout,cancelMessage:i,errorMessage:a,frames:o=Ze?[`◒`,`◐`,`◓`,`◑`]:[`•`,`o`,`O`,`0`],delay:s=Ze?80:120,signal:c,...l}={})=>{let u=Qe(),d,f,p=!1,m=!1,h=``,g,_=performance.now(),v=P(n),y=l?.styleFrame??St,b=e=>{let n=e>1?a??N.messages.error:i??N.messages.cancel;m=e===1,p&&(D(n,e),m&&typeof t==`function`&&t())},x=()=>b(2),S=()=>b(1),C=()=>{process.on(`uncaughtExceptionMonitor`,x),process.on(`unhandledRejection`,x),process.on(`SIGINT`,S),process.on(`SIGTERM`,S),process.on(`exit`,b),c&&c.addEventListener(`abort`,S)},ee=()=>{process.removeListener(`uncaughtExceptionMonitor`,x),process.removeListener(`unhandledRejection`,x),process.removeListener(`SIGINT`,S),process.removeListener(`SIGTERM`,S),process.removeListener(`exit`,b),c&&c.removeEventListener(`abort`,S)},w=()=>{if(g===void 0)return;u&&n.write(`
|
|
39
|
+
`);let e=j(g,v,{hard:!0,trim:!1}).split(`
|
|
40
|
+
`);e.length>1&&n.write(M.cursor.up(e.length-1)),n.write(M.cursor.to(0)),n.write(M.erase.down())},te=e=>e.replace(/\.+$/,``),T=e=>{let t=(performance.now()-e)/1e3,n=Math.floor(t/60),r=Math.floor(t%60);return n>0?`[${n}m ${r}s]`:`[${r}s]`},ne=l.withGuide??N.withGuide,E=(t=``)=>{p=!0,d=He({output:n}),h=te(t),_=performance.now(),ne&&n.write(`${r(`gray`,L)}
|
|
41
|
+
`);let i=0,a=0;C(),f=setInterval(()=>{if(u&&h===g)return;w(),g=h;let t=y(o[i]),r;if(u)r=`${t} ${h}...`;else if(e===`timer`)r=`${t} ${h} ${T(_)}`;else{let e=`.`.repeat(Math.floor(a)).slice(0,3);r=`${t} ${h}${e}`}let s=j(r,v,{hard:!0,trim:!1});n.write(s),i=i+1<o.length?i+1:0,a=a<4?a+.125:0},s)},D=(t=``,i=0,a=!1)=>{if(!p)return;p=!1,clearInterval(f),w();let o=i===0?r(`green`,I):i===1?r(`red`,tt):r(`red`,nt);h=t??h,a||(e===`timer`?n.write(`${o} ${h} ${T(_)}
|
|
42
42
|
`):n.write(`${o} ${h}
|
|
43
|
-
`)),
|
|
43
|
+
`)),ee(),d()};return{start:E,stop:(e=``)=>D(e,0),message:(e=``)=>{h=te(e??h)},cancel:(e=``)=>D(e,1),error:(e=``)=>D(e,2),clear:()=>D(``,0,!0),get isCancelled(){return m}}},wt=(e,t)=>e.includes(`
|
|
44
44
|
`)?e.split(`
|
|
45
45
|
`).map(e=>t(e)).join(`
|
|
46
|
-
`):t(e),
|
|
46
|
+
`):t(e),Tt=e=>{let t=(e,t)=>{let n=e.label??String(e.value);switch(t){case`disabled`:return`${r(`gray`,z)} ${wt(n,e=>r(`gray`,e))}${e.hint?` ${r(`dim`,`(${e.hint??`disabled`})`)}`:``}`;case`selected`:return`${wt(n,e=>r(`dim`,e))}`;case`active`:return`${r(`green`,rt)} ${n}${e.hint?` ${r(`dim`,`(${e.hint})`)}`:``}`;case`cancelled`:return`${wt(n,e=>r([`strikethrough`,`dim`],e))}`;default:return`${r(`dim`,z)} ${wt(n,e=>r(`dim`,e))}`}};return new Je({options:e.options,signal:e.signal,input:e.input,output:e.output,initialValue:e.initialValue,render(){let n=e.withGuide??N.withGuide,i=`${pt(this.state)} `,a=`${mt(this.state)} `,o=We(e.output,e.message,a,i),s=`${n?`${r(`gray`,L)}
|
|
47
47
|
`:``}${o}
|
|
48
|
-
`;switch(this.state){case`submit`:{let
|
|
49
|
-
${
|
|
50
|
-
`).length,c=n?2:1;return`${s}${
|
|
51
|
-
${
|
|
52
|
-
${
|
|
53
|
-
`}}}}).prompt()}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
`)&&(
|
|
57
|
-
`))).length);let e=i(t).length;n+e<process.stdout.columns?(n+=e,process.stdout.write(t)):(process.stdout.write(`
|
|
58
|
-
${Dt}${t.trimStart()}`),n=3+i(t.trimStart()).length)}process.stdout.write(`
|
|
59
|
-
`)},info:e=>R.message(e,{symbol:a(`blue`,ut)}),success:e=>R.message(e,{symbol:a(`green`,dt)}),step:e=>R.message(e,{symbol:a(`green`,N)}),warn:e=>R.message(e,{symbol:a(`yellow`,ft)}),warning:e=>R.warn(e),error:e=>R.message(e,{symbol:a(`red`,pt)})},Ot=e=>e.replace(/\x1b\[(?:\d+;)*\d*[ABCDEFGHfJKSTsu]|\x1b\[(s|u)/g,``),kt=e=>{let t=e.output??process.stdout,n=j(t),r=a(`gray`,P),i=e.spacing??1,o=e.retainLog===!0,s=!Qe()&&$e(t);t.write(`${r}
|
|
60
|
-
`),t.write(`${a(`green`,N)} ${e.title}
|
|
61
|
-
`);for(let e=0;e<i;e++)t.write(`${r}
|
|
62
|
-
`);let c=[{value:``,full:``}],l=!1,u=e=>{if(c.length===0)return;let r=0;e&&(r+=i+2);for(let e of c){let{value:t,result:i}=e,a=i?.message??t;if(a.length===0)continue;i===void 0&&e.header!==void 0&&e.header!==``&&(a+=`
|
|
48
|
+
`;switch(this.state){case`submit`:{let i=n?`${r(`gray`,L)} `:``;return`${s}${We(e.output,t(this.options[this.cursor],`selected`),i)}`}case`cancel`:{let i=n?`${r(`gray`,L)} `:``;return`${s}${We(e.output,t(this.options[this.cursor],`cancelled`),i)}${n?`
|
|
49
|
+
${r(`gray`,L)}`:``}`}default:{let i=n?`${r(`cyan`,L)} `:``,a=n?r(`cyan`,R):``,o=s.split(`
|
|
50
|
+
`).length,c=n?2:1;return`${s}${i}${gt({output:e.output,cursor:this.cursor,options:this.options,maxItems:e.maxItems,columnPadding:i.length,rowPadding:o+c,style:(e,n)=>t(e,e.disabled?`disabled`:n?`active`:`inactive`)}).join(`
|
|
51
|
+
${i}`)}
|
|
52
|
+
${a}
|
|
53
|
+
`}}}}).prompt()};`${r(`gray`,L)}`;const Et=e=>e.replace(/\x1b\[(?:\d+;)*\d*[ABCDEFGHfJKSTsu]|\x1b\[(s|u)/g,``),Dt=e=>{let t=e.output??process.stdout,n=P(t),i=r(`gray`,L),a=e.spacing??1,o=e.retainLog===!0,s=!Qe()&&$e(t);t.write(`${i}
|
|
54
|
+
`),t.write(`${r(`green`,I)} ${e.title}
|
|
55
|
+
`);for(let e=0;e<a;e++)t.write(`${i}
|
|
56
|
+
`);let c=[{value:``,full:``}],l=!1,u=e=>{if(c.length===0)return;let r=0;e&&(r+=a+2);for(let e of c){let{value:t,result:i}=e,a=i?.message??t;if(a.length===0)continue;i===void 0&&e.header!==void 0&&e.header!==``&&(a+=`
|
|
63
57
|
${e.header}`);let o=a.split(`
|
|
64
|
-
`).reduce((e,t)=>t===``?e+1:e+Math.ceil((t.length+3)/n),0);r+=o}r>0&&(r+=1,t.write(
|
|
65
|
-
${e.value}`:e.value;e.header!==void 0&&e.header!==``&&
|
|
66
|
-
`).map(e=>
|
|
67
|
-
`).map(e=>
|
|
68
|
-
`),t.value+=
|
|
58
|
+
`).reduce((e,t)=>t===``?e+1:e+Math.ceil((t.length+3)/n),0);r+=o}r>0&&(r+=1,t.write(M.erase.lines(r)))},d=(e,n,o)=>{let s=o?`${e.full}
|
|
59
|
+
${e.value}`:e.value;e.header!==void 0&&e.header!==``&&B.message(e.header.split(`
|
|
60
|
+
`).map(e=>r(`bold`,e)),{output:t,secondarySymbol:i,symbol:i,spacing:0}),B.message(s.split(`
|
|
61
|
+
`).map(e=>r(`dim`,e)),{output:t,secondarySymbol:i,symbol:i,spacing:n??a})},f=()=>{for(let e of c){let{header:t,value:n,full:r}=e;(t===void 0||t.length===0)&&n.length===0||d(e,void 0,o===!0&&r.length>0)}},p=(t,n,r)=>{if(u(!1),(r?.raw!==!0||!l)&&t.value!==``&&(t.value+=`
|
|
62
|
+
`),t.value+=Et(n),l=r?.raw===!0,e.limit!==void 0){let n=t.value.split(`
|
|
69
63
|
`),r=n.length-e.limit;if(r>0){let e=n.splice(0,r);o&&(t.full+=(t.full===``?``:`
|
|
70
64
|
`)+e.join(`
|
|
71
65
|
`))}t.value=n.join(`
|
|
72
|
-
`)}s&&m()},m=()=>{for(let e of c)e.result?e.result.status===`error`?
|
|
73
|
-
`:``}${
|
|
74
|
-
`,
|
|
75
|
-
${
|
|
66
|
+
`)}s&&m()},m=()=>{for(let e of c)e.result?e.result.status===`error`?B.error(e.result.message,{output:t,secondarySymbol:i,spacing:0}):B.success(e.result.message,{output:t,secondarySymbol:i,spacing:0}):e.value!==``&&d(e,0)},h=(e,t)=>{u(!1),e.result=t,s&&m()};return{message(e,t){p(c[0],e,t)},group(e){let t={header:e,value:``,full:``};return c.push(t),{message(e,n){p(t,e,n)},error(e){h(t,{status:`error`,message:e})},success(e){h(t,{status:`success`,message:e})}}},error(e,n){u(!0),B.error(e,{output:t,secondarySymbol:i,spacing:1}),n?.showLog!==!1&&f(),c.splice(1,c.length-1),c[0].value=``,c[0].full=``},success(e,n){u(!0),B.success(e,{output:t,secondarySymbol:i,spacing:1}),n?.showLog===!0&&f(),c.splice(1,c.length-1),c[0].value=``,c[0].full=``}}},Ot=e=>new Ye({validate:e.validate,placeholder:e.placeholder,defaultValue:e.defaultValue,initialValue:e.initialValue,output:e.output,signal:e.signal,input:e.input,render(){let t=e?.withGuide??N.withGuide,n=`${`${t?`${r(`gray`,L)}
|
|
67
|
+
`:``}${pt(this.state)} `}${e.message}
|
|
68
|
+
`,i=e.placeholder?r(`inverse`,e.placeholder[0])+r(`dim`,e.placeholder.slice(1)):r([`inverse`,`hidden`],`_`),a=this.userInput?this.userInputWithCursor:i,o=this.value??``;switch(this.state){case`error`:{let e=this.error?` ${r(`yellow`,this.error)}`:``,i=t?`${r(`yellow`,L)} `:``,o=t?r(`yellow`,R):``;return`${n.trim()}
|
|
69
|
+
${i}${a}
|
|
76
70
|
${o}${e}
|
|
77
|
-
`}case`submit`:{let e=o?` ${
|
|
78
|
-
${
|
|
79
|
-
${t?
|
|
80
|
-
`}}}).prompt(),
|
|
81
|
-
`)}function
|
|
82
|
-
`)}catch(e){console.error(e)}}const
|
|
83
|
-
`)}function
|
|
84
|
-
`),process.exit(1)}}async function un(e){let t=await B(e.args||{}),n=new Set,r=new Set;for(let[e,i]of Object.entries(t)){n.add(e);for(let e of z(i.alias))r.add(e)}return{help:dn(`help`,`h`,n,r),version:dn(`version`,`v`,n,r)}}function dn(e,t,n,r){return n.has(e)||r.has(e)?[]:n.has(t)||r.has(t)?[`--${e}`]:[`--${e}`,`-${t}`]}var fn=pe({a:()=>W,n:()=>Sn,r:()=>xn,t:()=>Zn});const pn=/^[A-Za-z]:\//;function U(e=``){return e&&e.replace(/\\/g,`/`).replace(pn,e=>e.toUpperCase())}const mn=/^[/\\]{2}/,hn=/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/,gn=/^[A-Za-z]:$/,_n=function(e){if(e.length===0)return`.`;e=U(e);let t=e.match(mn),n=G(e),r=e[e.length-1]===`/`;return e=bn(e,!n),e.length===0?n?`/`:r?`./`:`.`:(r&&(e+=`/`),gn.test(e)&&(e+=`/`),t?n?`//${e}`:`//./${e}`:n&&!G(e)?`/${e}`:e)},vn=function(...e){let t=``;for(let n of e)if(n)if(t.length>0){let e=t[t.length-1]===`/`,r=n[0]===`/`;e&&r?t+=n.slice(1):t+=e||r?n:`/${n}`}else t+=n;return _n(t)};function yn(){return typeof process<`u`&&typeof process.cwd==`function`?process.cwd().replace(/\\/g,`/`):`/`}const W=function(...e){e=e.map(e=>U(e));let t=``,n=!1;for(let r=e.length-1;r>=-1&&!n;r--){let i=r>=0?e[r]:yn();!i||i.length===0||(t=`${i}/${t}`,n=G(i))}return t=bn(t,!n),n&&!G(t)?`/${t}`:t.length>0?t:`.`};function bn(e,t){let n=``,r=0,i=-1,a=0,o=null;for(let s=0;s<=e.length;++s){if(s<e.length)o=e[s];else if(o===`/`)break;else o=`/`;if(o===`/`){if(!(i===s-1||a===1))if(a===2){if(n.length<2||r!==2||n[n.length-1]!==`.`||n[n.length-2]!==`.`){if(n.length>2){let e=n.lastIndexOf(`/`);e===-1?(n=``,r=0):(n=n.slice(0,e),r=n.length-1-n.lastIndexOf(`/`)),i=s,a=0;continue}else if(n.length>0){n=``,r=0,i=s,a=0;continue}}t&&(n+=n.length>0?`/..`:`..`,r=2)}else n.length>0?n+=`/${e.slice(i+1,s)}`:n=e.slice(i+1,s),r=s-i-1;i=s,a=0}else o===`.`&&a!==-1?++a:a=-1}return n}const G=function(e){return hn.test(e)},xn=function(e){let t=U(e).replace(/\/$/,``).split(`/`).slice(0,-1);return t.length===1&&gn.test(t[0])&&(t[0]+=`/`),t.join(`/`)||(G(e)?`/`:`.`)},Sn=function(e,t){let n=U(e).split(`/`),r=``;for(let e=n.length-1;e>=0;e--){let t=n[e];if(t){r=t;break}}return t&&r.endsWith(t)?r.slice(0,-t.length):r};globalThis.process?.platform;var K=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),q=t(import.meta.url);const Cn=/^path$/i,wn={key:`PATH`,value:``};function Tn(e){for(let t in e){if(!Object.prototype.hasOwnProperty.call(e,t)||!Cn.test(t))continue;let n=e[t];return n?{key:t,value:n}:wn}return wn}function En(e,t){let n=t.value.split(y),r=[],i=e,a;do r.push(ee(i,`node_modules`,`.bin`)),a=i,i=b(i);while(i!==a);let o=r.concat(n).join(y);return{key:t.key,value:o}}function Dn(e,t){let n={...process.env,...t},r=En(e,Tn(n));return n[r.key]=r.value,n}const On=e=>{let t=e.length,n=new ie,r=()=>{--t===0&&n.emit(`end`)};for(let t of e)t.pipe(n,{end:!1}),t.on(`end`,r);return n};var kn=K(((e,t)=>{t.exports=a,a.sync=o;var n=q(`fs`);function r(e,t){var n=t.pathExt===void 0?process.env.PATHEXT:t.pathExt;if(!n||(n=n.split(`;`),n.indexOf(``)!==-1))return!0;for(var r=0;r<n.length;r++){var i=n[r].toLowerCase();if(i&&e.substr(-i.length).toLowerCase()===i)return!0}return!1}function i(e,t,n){return!e.isSymbolicLink()&&!e.isFile()?!1:r(t,n)}function a(e,t,r){n.stat(e,function(n,a){r(n,n?!1:i(a,e,t))})}function o(e,t){return i(n.statSync(e),e,t)}})),An=K(((e,t)=>{t.exports=r,r.sync=i;var n=q(`fs`);function r(e,t,r){n.stat(e,function(e,n){r(e,e?!1:a(n,t))})}function i(e,t){return a(n.statSync(e),t)}function a(e,t){return e.isFile()&&o(e,t)}function o(e,t){var n=e.mode,r=e.uid,i=e.gid,a=t.uid===void 0?process.getuid&&process.getuid():t.uid,o=t.gid===void 0?process.getgid&&process.getgid():t.gid,s=64,c=8,l=1,u=s|c;return n&l||n&c&&i===o||n&s&&r===a||n&u&&a===0}})),jn=K(((e,t)=>{q(`fs`);var n=process.platform===`win32`||global.TESTING_WINDOWS?kn():An();t.exports=r,r.sync=i;function r(e,t,i){if(typeof t==`function`&&(i=t,t={}),!i){if(typeof Promise!=`function`)throw TypeError(`callback not provided`);return new Promise(function(n,i){r(e,t||{},function(e,t){e?i(e):n(t)})})}n(e,t||{},function(e,n){e&&(e.code===`EACCES`||t&&t.ignoreErrors)&&(e=null,n=!1),i(e,n)})}function i(e,t){try{return n.sync(e,t||{})}catch(e){if(t&&t.ignoreErrors||e.code===`EACCES`)return!1;throw e}}})),Mn=K(((e,t)=>{let n=process.platform===`win32`||process.env.OSTYPE===`cygwin`||process.env.OSTYPE===`msys`,r=q(`path`),i=n?`;`:`:`,a=jn(),o=e=>Object.assign(Error(`not found: ${e}`),{code:`ENOENT`}),s=(e,t)=>{let r=t.colon||i,a=e.match(/\//)||n&&e.match(/\\/)?[``]:[...n?[process.cwd()]:[],...(t.path||process.env.PATH||``).split(r)],o=n?t.pathExt||process.env.PATHEXT||`.EXE;.CMD;.BAT;.COM`:``,s=n?o.split(r):[``];return n&&e.indexOf(`.`)!==-1&&s[0]!==``&&s.unshift(``),{pathEnv:a,pathExt:s,pathExtExe:o}},c=(e,t,n)=>{typeof t==`function`&&(n=t,t={}),t||={};let{pathEnv:i,pathExt:c,pathExtExe:l}=s(e,t),u=[],d=n=>new Promise((a,s)=>{if(n===i.length)return t.all&&u.length?a(u):s(o(e));let c=i[n],l=/^".*"$/.test(c)?c.slice(1,-1):c,d=r.join(l,e);a(f(!l&&/^\.[\\\/]/.test(e)?e.slice(0,2)+d:d,n,0))}),f=(e,n,r)=>new Promise((i,o)=>{if(r===c.length)return i(d(n+1));let s=c[r];a(e+s,{pathExt:l},(a,o)=>{if(!a&&o)if(t.all)u.push(e+s);else return i(e+s);return i(f(e,n,r+1))})});return n?d(0).then(e=>n(null,e),n):d(0)};t.exports=c,c.sync=(e,t)=>{t||={};let{pathEnv:n,pathExt:i,pathExtExe:c}=s(e,t),l=[];for(let o=0;o<n.length;o++){let s=n[o],u=/^".*"$/.test(s)?s.slice(1,-1):s,d=r.join(u,e),f=!u&&/^\.[\\\/]/.test(e)?e.slice(0,2)+d:d;for(let e=0;e<i.length;e++){let n=f+i[e];try{if(a.sync(n,{pathExt:c}))if(t.all)l.push(n);else return n}catch{}}}if(t.all&&l.length)return l;if(t.nothrow)return null;throw o(e)}})),Nn=K(((e,t)=>{let n=(e={})=>{let t=e.env||process.env;return(e.platform||process.platform)===`win32`?Object.keys(t).reverse().find(e=>e.toUpperCase()===`PATH`)||`Path`:`PATH`};t.exports=n,t.exports.default=n})),Pn=K(((e,t)=>{let n=q(`path`),r=Mn(),i=Nn();function a(e,t){let a=e.options.env||process.env,o=process.cwd(),s=e.options.cwd!=null,c=s&&process.chdir!==void 0&&!process.chdir.disabled;if(c)try{process.chdir(e.options.cwd)}catch{}let l;try{l=r.sync(e.command,{path:a[i({env:a})],pathExt:t?n.delimiter:void 0})}catch{}finally{c&&process.chdir(o)}return l&&=n.resolve(s?e.options.cwd:``,l),l}function o(e){return a(e)||a(e,!0)}t.exports=o})),Fn=K(((e,t)=>{let n=/([()\][%!^"`<>&|;, *?])/g;function r(e){return e=e.replace(n,`^$1`),e}function i(e,t){return e=`${e}`,e=e.replace(/(?=(\\+?)?)\1"/g,`$1$1\\"`),e=e.replace(/(?=(\\+?)?)\1$/,`$1$1`),e=`"${e}"`,e=e.replace(n,`^$1`),t&&(e=e.replace(n,`^$1`)),e}t.exports.command=r,t.exports.argument=i})),In=K(((e,t)=>{t.exports=/^#!(.*)/})),Ln=K(((e,t)=>{let n=In();t.exports=(e=``)=>{let t=e.match(n);if(!t)return null;let[r,i]=t[0].replace(/#! ?/,``).split(` `),a=r.split(`/`).pop();return a===`env`?i:i?`${a} ${i}`:a}})),Rn=K(((e,t)=>{let n=q(`fs`),r=Ln();function i(e){let t=Buffer.alloc(150),i;try{i=n.openSync(e,`r`),n.readSync(i,t,0,150,0),n.closeSync(i)}catch{}return r(t.toString())}t.exports=i})),zn=K(((e,t)=>{let n=q(`path`),r=Pn(),i=Fn(),a=Rn(),o=process.platform===`win32`,s=/\.(?:com|exe)$/i,c=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function l(e){e.file=r(e);let t=e.file&&a(e.file);return t?(e.args.unshift(e.file),e.command=t,r(e)):e.file}function u(e){if(!o)return e;let t=l(e),r=!s.test(t);if(e.options.forceShell||r){let r=c.test(t);e.command=n.normalize(e.command),e.command=i.command(e.command),e.args=e.args.map(e=>i.argument(e,r)),e.args=[`/d`,`/s`,`/c`,`"${[e.command].concat(e.args).join(` `)}"`],e.command=process.env.comspec||`cmd.exe`,e.options.windowsVerbatimArguments=!0}return e}function d(e,t,n){t&&!Array.isArray(t)&&(n=t,t=null),t=t?t.slice(0):[],n=Object.assign({},n);let r={command:e,args:t,options:n,file:void 0,original:{command:e,args:t}};return n.shell?r:u(r)}t.exports=d})),Bn=K(((e,t)=>{let n=process.platform===`win32`;function r(e,t){return Object.assign(Error(`${t} ${e.command} ENOENT`),{code:`ENOENT`,errno:`ENOENT`,syscall:`${t} ${e.command}`,path:e.command,spawnargs:e.args})}function i(e,t){if(!n)return;let r=e.emit;e.emit=function(n,i){if(n===`exit`){let n=a(i,t);if(n)return r.call(e,`error`,n)}return r.apply(e,arguments)}}function a(e,t){return n&&e===1&&!t.file?r(t.original,`spawn`):null}function o(e,t){return n&&e===1&&!t.file?r(t.original,`spawnSync`):null}t.exports={hookChildProcess:i,verifyENOENT:a,verifyENOENTSync:o,notFoundError:r}})),Vn=K(((e,t)=>{let n=q(`child_process`),r=zn(),i=Bn();function a(e,t,a){let o=r(e,t,a),s=n.spawn(o.command,o.args,o.options);return i.hookChildProcess(s,o),s}function o(e,t,a){let o=r(e,t,a),s=n.spawnSync(o.command,o.args,o.options);return s.error=s.error||i.verifyENOENTSync(s.status,o),s}t.exports=a,t.exports.spawn=a,t.exports.sync=o,t.exports._parse=r,t.exports._enoent=i}))(),Hn=class extends Error{result;output;get exitCode(){if(this.result.exitCode!==null)return this.result.exitCode}constructor(e,t){super(`Process exited with non-zero status (${e.exitCode})`),this.result=e,this.output=t}};const Un={timeout:void 0,persist:!1},Wn={windowsHide:!0};function Gn(e,t){return{command:S(e),args:t??[]}}function Kn(e){let t=new AbortController;for(let n of e){if(n.aborted)return t.abort(),n;n.addEventListener(`abort`,()=>{t.abort(n.reason)},{signal:t.signal})}return t.signal}async function qn(e){let t=``;for await(let n of e)t+=n.toString();return t}var Jn=class{_process;_aborted=!1;_options;_command;_args;_resolveClose;_processClosed;_thrownError;get process(){return this._process}get pid(){return this._process?.pid}get exitCode(){if(this._process&&this._process.exitCode!==null)return this._process.exitCode}constructor(e,t,n){this._options={...Un,...n},this._command=e,this._args=t??[],this._processClosed=new Promise(e=>{this._resolveClose=e})}kill(e){return this._process?.kill(e)===!0}get aborted(){return this._aborted}get killed(){return this._process?.killed===!0}pipe(e,t,n){return Xn(e,t,{...n,stdin:this})}async*[Symbol.asyncIterator](){let e=this._process;if(!e)return;let t=[];this._streamErr&&t.push(this._streamErr),this._streamOut&&t.push(this._streamOut);let n=On(t),r=d.createInterface({input:n});for await(let e of r)yield e.toString();if(await this._processClosed,e.removeAllListeners(),this._thrownError)throw this._thrownError;if(this._options?.throwOnError&&this.exitCode!==0&&this.exitCode!==void 0)throw new Hn(this)}async _waitForOutput(){let e=this._process;if(!e)throw Error(`No process was started`);let[t,n]=await Promise.all([this._streamOut?qn(this._streamOut):``,this._streamErr?qn(this._streamErr):``]);if(await this._processClosed,this._options?.stdin&&await this._options.stdin,e.removeAllListeners(),this._thrownError)throw this._thrownError;let r={stderr:n,stdout:t,exitCode:this.exitCode};if(this._options.throwOnError&&this.exitCode!==0&&this.exitCode!==void 0)throw new Hn(this,r);return r}then(e,t){return this._waitForOutput().then(e,t)}_streamOut;_streamErr;spawn(){let e=s(),t=this._options,n={...Wn,...t.nodeOptions},r=[];this._resetState(),t.timeout!==void 0&&r.push(AbortSignal.timeout(t.timeout)),t.signal!==void 0&&r.push(t.signal),t.persist===!0&&(n.detached=!0),r.length>0&&(n.signal=Kn(r)),n.env=Dn(e,n.env);let{command:i,args:a}=Gn(this._command,this._args),o=(0,Vn._parse)(i,a,n),c=se(o.command,o.args,o.options);if(c.stderr&&(this._streamErr=c.stderr),c.stdout&&(this._streamOut=c.stdout),this._process=c,c.once(`error`,this._onError),c.once(`close`,this._onClose),t.stdin!==void 0&&c.stdin&&t.stdin.process){let{stdout:e}=t.stdin.process;e&&e.pipe(c.stdin)}}_resetState(){this._aborted=!1,this._processClosed=new Promise(e=>{this._resolveClose=e}),this._thrownError=void 0}_onError=e=>{if(e.name===`AbortError`&&(!(e.cause instanceof Error)||e.cause.name!==`TimeoutError`)){this._aborted=!0;return}this._thrownError=e};_onClose=()=>{this._resolveClose&&this._resolveClose()}};const Yn=(e,t,n)=>{let r=new Jn(e,t,n);return r.spawn(),r},Xn=Yn;var Zn=e({detectPackageManager:()=>ir,installDependencies:()=>ar,packageManagers:()=>J});async function Qn(e,t,n={}){let r=_n(e).split(`/`);for(;r.length>0;){let e=await t(r.join(`/`)||`/`);if(e||!n.includeParentDirs)return e;r.pop()}}function $n(e){let t;return()=>(t===void 0&&(t=e().then(e=>(t=e,t))),t)}const er=$n(async()=>{if(globalThis.process?.versions?.webcontainer)return!1;try{let{exitCode:e}=await Yn(`corepack`,[`--version`]);return e===0}catch{return!1}});async function tr(e,t,n={}){let r=e!==`npm`&&e!==`bun`&&e!==`deno`&&n.corepack!==!1&&await er()?[`corepack`,[e,...t]]:[e,t],{exitCode:i,stdout:a,stderr:o}=await Yn(r[0],r[1],{nodeOptions:{cwd:W(n.cwd||process.cwd()),env:n.env,stdio:n.silent?`pipe`:`inherit`}});if(i!==0)throw Error(`\`${r.flat().join(` `)}\` failed.${n.silent?[``,a,o].join(`
|
|
85
|
-
`):``}`)}async function nr(e={}){let t=e.cwd||process.cwd(),n={...process.env,...e.env},r=(typeof e.packageManager==`string`?J.find(t=>t.name===e.packageManager):e.packageManager)||await ir(e.cwd||process.cwd());if(!r)throw Error(`No package manager auto-detected.`);return{cwd:t,env:n,silent:e.silent??!1,packageManager:r,dev:e.dev??!1,workspace:e.workspace,global:e.global??!1,dry:e.dry??!1,corepack:e.corepack??!0}}function rr(e){let[t,n]=(e||``).split(`@`),[r,i]=n?.split(`+`)||[];if(t&&t!==`-`&&/^(@[a-z0-9-~][a-z0-9-._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/.test(t))return{name:t,version:r,buildMeta:i};let a=(t||``).replace(/\W+/g,``);return{name:a,version:r,buildMeta:i,warnings:[`Abnormal characters found in \`packageManager\` field, sanitizing from \`${t}\` to \`${a}\``]}}const J=[{name:`npm`,command:`npm`,lockFile:`package-lock.json`},{name:`pnpm`,command:`pnpm`,lockFile:`pnpm-lock.yaml`,files:[`pnpm-workspace.yaml`]},{name:`bun`,command:`bun`,lockFile:[`bun.lockb`,`bun.lock`]},{name:`yarn`,command:`yarn`,lockFile:`yarn.lock`,files:[`.yarnrc.yml`]},{name:`deno`,command:`deno`,lockFile:`deno.lock`,files:[`deno.json`]}];async function ir(e,t={}){let n=await Qn(W(e||`.`),async e=>{if(!t.ignorePackageJSON){let t=vn(e,`package.json`);if(h(t)){let e=JSON.parse(await w(t,`utf8`));if(e?.packageManager){let{name:t,version:n=`0.0.0`,buildMeta:r,warnings:i}=rr(e.packageManager);if(t){let e=n.split(`.`)[0],a=J.find(n=>n.name===t&&n.majorVersion===e)||J.find(e=>e.name===t);return{name:t,command:t,version:n,majorVersion:e,buildMeta:r,warnings:i,files:a?.files,lockFile:a?.lockFile}}}}if(h(vn(e,`deno.json`)))return J.find(e=>e.name===`deno`)}if(!t.ignoreLockFile){for(let t of J)if([t.lockFile,t.files].flat().filter(Boolean).some(t=>h(W(e,t))))return{...t}}},{includeParentDirs:t.includeParentDirs??!0});if(!n&&!t.ignoreArgv){let e=process.argv[1];if(e){for(let t of J)if(RegExp(`[/\\\\]\\.?${t.command}`).test(e))return t}}return n}async function ar(e={}){let t=await nr(e),n=e.frozenLockFile?{npm:[`ci`],yarn:[`install`,`--immutable`],bun:[`install`,`--frozen-lockfile`],pnpm:[`install`,`--frozen-lockfile`],deno:[`install`,`--frozen`]}[t.packageManager.name]:[`install`];return e.ignoreWorkspace&&t.packageManager.name===`pnpm`&&n.push(`--ignore-workspace`),t.dry||await tr(t.packageManager.command,n,{cwd:t.cwd,silent:t.silent,corepack:t.corepack}),{exec:{command:t.packageManager.command,args:n}}}async function or(e,t,n={}){let i=t+`.json`,a=JSON.parse(await w(i,`utf8`).catch(()=>`{}`)),o=(await X(e,{method:`HEAD`,headers:n.headers}).catch(()=>void 0))?.headers.get(`etag`);if(a.etag===o&&h(t))return;typeof o==`string`&&(a.etag=o);let s=await X(e,{headers:n.headers});if(s.status>=400)throw Error(`Failed to download ${e}: ${s.status} ${s.statusText}`);let c=m(t);await r(oe)(s.body,c),await E(i,JSON.stringify(a),`utf8`)}const sr=/^(?<repo>[-\w.]+\/[-\w.]+)(?<subdir>[^#]+)?(?<ref>#[-\w./@]+)?/,cr=/^(?<repo>[-\w.]+(?:\/[-\w.]+)+?)(?:::(?<subdir>[^#]*))?(?<ref>#[-\w./@]+)?$/;function lr(e,t){let n=t?.expandRepo||e.includes(`::`),r=e.match(n?cr:sr)?.groups||{},i=n?r.subdir?`/`+r.subdir:`/`:r.subdir||`/`;return{repo:r.repo||``,subdir:i,ref:r.ref?r.ref.slice(1):`main`}}function Y(...e){process.env.DEBUG&&console.debug(`[giget]`,...e)}async function X(e,t={}){t.headers?.[`sec-fetch-mode`]&&(t.mode=t.headers[`sec-fetch-mode`]);let n=await fetch(e,{...t,headers:dr(t.headers)}).catch(t=>{throw Error(`Failed to download ${e}: ${t}`,{cause:t})});if(t.validateStatus&&n.status>=400)throw Error(`Failed to fetch ${e}: ${n.status} ${n.statusText}`);return n}function ur(){let e=process.env.XDG_CACHE_HOME?W(process.env.XDG_CACHE_HOME,`giget`):W(le(),`.cache/giget`);if(process.platform===`win32`){let t=W(ue(),`giget`);if(!h(t)&&h(e))try{_(e,t)}catch{}return t}return e}function dr(e={}){let t={};for(let[n,r]of Object.entries(e))r&&(t[n.toLowerCase()]=r);return t}const fr=(e,t)=>{let n=pr(e);return{name:n.name,version:n.subdir?`${n.version||`default`}-${n.subdir.replaceAll(`/`,`-`)}`:n.version,tar:({auth:e}={})=>mr(n,e??t.auth)}};function pr(e,t={}){let n=t.cwd??process.cwd(),r=e.replace(/#.*$/,``),i;if(/^[./]/.test(e))r=W(n,r);else if(/^https?:\/\//.test(r)){let e=/^(https?:\/\/[^/]+)\/([\w.-]+\/[\w.-]+?)(?:\.git)?(?:\/(.+))?$/.exec(r);if(e){let[,t,n,a]=e;r=`${t}/${n}`,a&&(i=a)}}else if(r.includes(`@`)){let e=/^(.*?:[\w.-]+\/[\w.-]+?)(?:\.git)?(?:\/(.+))?$/.exec(r);if(e){let[,t,n]=e;r=t,n&&(i=n)}}else{let e={"github:":`https://github.com/`,"gh:":`https://github.com/`,"gitlab:":`https://gitlab.com/`,"bitbucket:":`https://bitbucket.org/`,"sourcehut:":`https://git.sr.ht/~`},t=/^(.+?:)/.exec(r)?.at(1);t&&e[t]?r=r.replace(t,e[t]):t||(r=`${(process.env.GIGET_GIT_HOST||`https://github.com/`).replace(/\/$/,``)}/${r}`);let n=/^(https?:\/\/[^/]+\/~?[\w.-]+\/[\w.-]+?)(?:\.git)?(?:\/(.+))?$/.exec(r);if(n){let[,e,t]=n;r=e,t&&(i=t)}}let a=r.replace(/^https?:\/\//,``).replace(/^.+@/,``).replace(/(\.git)?(#.*)?$/,``).replace(/^\W+/,``).replaceAll(/[:/]/g,`-`),[o,s]=/#(.+)$/.exec(e)?.at(1)?.split(`:`)??[],c=o||void 0,l=s||i;return{uri:r,name:a,...c&&{version:c},...l&&{subdir:l}}}async function mr(e,t){let n=await ne(x(ue(),`giget-git-`));if(t&&/[\r\n]/.test(t))throw Error(`Auth token must not contain newline characters`);let r={...process.env,GIT_TERMINAL_PROMPT:`0`};t&&(r.GIT_CONFIG_COUNT=`1`,r.GIT_CONFIG_KEY_0=`http.extraHeader`,r.GIT_CONFIG_VALUE_0=`Authorization: Bearer ${t}`);let i={env:r,timeout:6e4},a=_r(),o=e=>gr(e,i,a),s=e=>gr(e,{...i,cwd:n},a);try{let t=[`clone`,`--progress`,`--depth`,`1`];e.subdir&&t.push(`--filter=blob:none`,`--sparse`,`--no-checkout`),e.version&&t.push(`--branch`,e.version),t.push(`--`,e.uri,n);try{a.update(`Cloning...`),await o(t),a.update(`Cloned.`)}catch(t){if(!e.version)throw t;Y(`Shallow clone failed, falling back to full clone:`,t),a.update(`Shallow clone failed, cloning...`),await T(n,{recursive:!0,force:!0}),await C(n,{recursive:!0}),await s([`init`]),await s([`remote`,`add`,`origin`,e.uri]),await s([`fetch`,`origin`]),await s([`checkout`,e.version]),a.update(`Fetched.`)}e.subdir&&(a.update(`Sparse checkout ${e.subdir}...`),await s([`sparse-checkout`,`set`,e.subdir]),await s([`checkout`])),a.update(`Packing...`);let r=e.subdir?x(n,e.subdir):n,{create:i}=await import(`./tar-Bd_UMghg.mjs`).then(e=>e.t);a.done();let c=i({gzip:!0,cwd:r,filter:e=>!e.startsWith(`.git/`)&&e!==`.git`&&!e.startsWith(`./.git/`)&&e!==`./.git`},[`.`]).pipe(new ie),l=!1,u=()=>{l||(l=!0,T(n,{recursive:!0,force:!0}))};return c.on(`end`,u),c.on(`error`,u),c.on(`close`,u),c}catch(e){throw a.done(),await T(n,{recursive:!0,force:!0}),e}}const hr=[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`];function gr(e,t,n){return new Promise((r,i)=>{let a=se(`git`,e,{...t,stdio:[`ignore`,`pipe`,`pipe`]});a.stdout.resume();let o=``;a.stderr?.on(`data`,e=>{let t=e.toString();for(let e of t.split(/[\r\n]/)){let t=e.trim();t&&(o=t)}n&&n.update(o)}),a.on(`close`,t=>{t===0?r(o):i(Error(`git ${e[0]} exited with code ${t}. Is git installed?`))}),a.on(`error`,e=>{e.code===`ENOENT`?i(Error(`git is not installed or not found in PATH`)):i(e)})})}function _r(){if(!process.stderr.isTTY)return{update(e){},done(){}};let e=``,t=0,n=()=>{let n=hr[t%hr.length];t++,process.stderr.write(`\x1B[2K\r\x1B[2m${n} ${e}\x1B[0m`)},r=setInterval(n,80);return{update(t){e=t,n()},done(){clearInterval(r),process.stderr.write(`\x1B[2K\r`)}}}const vr=async(e,t)=>{if(e.endsWith(`.json`))return await yr(e,t);let n=new URL(e),r=Sn(n.pathname);try{let i=await X(n.href,{method:`HEAD`,validateStatus:!0,headers:{authorization:t.auth?`Bearer ${t.auth}`:void 0}});if((i.headers.get(`content-type`)||``).includes(`application/json`))return await yr(e,t);let a=i.headers.get(`content-disposition`)?.match(/filename="?(.+)"?/)?.[1];a&&(r=a.split(`.`)[0])}catch(e){Y(`Failed to fetch HEAD for ${n.href}:`,e)}return{name:`${r}-${n.href.slice(0,8)}`,version:``,subdir:``,tar:n.href,defaultDir:r,headers:{Authorization:t.auth?`Bearer ${t.auth}`:void 0}}},yr=async(e,t)=>{let n=await(await X(e,{validateStatus:!0,headers:{authorization:t.auth?`Bearer ${t.auth}`:void 0}})).json();if(!n.tar||!n.name)throw Error(`Invalid template info from ${e}. name or tar fields are missing!`);return n},br=(e,t)=>{let n=lr(e),r=process.env.GIGET_GITHUB_URL||`https://api.github.com`;return{name:n.repo.replace(`/`,`-`),version:n.ref,subdir:n.subdir,headers:{Authorization:t.auth?`Bearer ${t.auth}`:void 0,Accept:`application/vnd.github+json`,"X-GitHub-Api-Version":`2022-11-28`},url:`${r.replace(`api.github.com`,`github.com`)}/${n.repo}/tree/${n.ref}${n.subdir}`,tar:`${r}/repos/${n.repo}/tarball/${n.ref}`}},xr={http:vr,https:vr,git:fr,github:br,gh:br,gitlab:(e,t)=>{let n=lr(e,{expandRepo:!0}),r=process.env.GIGET_GITLAB_URL||`https://gitlab.com`;return{name:n.repo.replace(`/`,`-`),version:n.ref,subdir:n.subdir,headers:{authorization:t.auth?`Bearer ${t.auth}`:void 0,"sec-fetch-mode":`same-origin`},url:`${r}/${n.repo}/tree/${n.ref}${n.subdir}`,tar:`${r}/${n.repo}/-/archive/${n.ref}.tar.gz`}},bitbucket:(e,t)=>{let n=lr(e);return{name:n.repo.replace(`/`,`-`),version:n.ref,subdir:n.subdir,headers:{authorization:t.auth?`Bearer ${t.auth}`:void 0},url:`https://bitbucket.com/${n.repo}/src/${n.ref}${n.subdir}`,tar:`https://bitbucket.org/${n.repo}/get/${n.ref}.tar.gz`}},sourcehut:(e,t)=>{let n=lr(e);return{name:n.repo.replace(`/`,`-`),version:n.ref,subdir:n.subdir,headers:{authorization:t.auth?`Bearer ${t.auth}`:void 0},url:`https://git.sr.ht/~${n.repo}/tree/${n.ref}/item${n.subdir}`,tar:`https://git.sr.ht/~${n.repo}/archive/${n.ref}.tar.gz`}}},Sr=(e=`https://raw.githubusercontent.com/unjs/giget/main/templates`,t={})=>(async n=>{let r=Date.now(),i=`${e}/${n}.json`,a=await X(i,{headers:{authorization:t.auth?`Bearer ${t.auth}`:void 0}});if(a.status>=400)throw Error(`Failed to download ${n} template info from ${i}: ${a.status} ${a.statusText}`);let o=await a.json();if(!o.tar||!o.name)throw Error(`Invalid template info from ${i}. name or tar fields are missing!`);return Y(`Fetched ${n} template info from ${i} in ${Date.now()-r}ms`),o}),Cr=/^([\w+-.]+):/;async function wr(e,t={}){t.registry=process.env.GIGET_REGISTRY??t.registry,t.auth=process.env.GIGET_AUTH??t.auth;let n=t.registry===!1?void 0:Sr(t.registry,{auth:t.auth}),r=t.provider||(n?`registry`:`github`),i=e,a=e.match(Cr);a&&(r=a[1],i=e.slice(a[0].length),(r===`http`||r===`https`)&&(i=e)),r.endsWith(`+git`)&&(i=`${r.slice(0,-4)}:${i}`,r=`git`);let o=t.providers?.[r]||xr[r]||n;if(!o)throw Error(`Unsupported provider: ${r}`);let s=await Promise.resolve().then(()=>o(i,{auth:t.auth})).catch(e=>{throw Error(`Failed to download template from ${r}: ${e.message}`)});if(!s)throw Error(`Failed to resolve template from ${r}`);s.name=(s.name||`template`).replace(/[^\da-z-]/gi,`-`),s.defaultDir=(s.defaultDir||s.name).replace(/[^\da-z-]/gi,`-`);let c=W(W(ur(),r,s.name),(s.version||s.name)+`.tar.gz`);if(t.preferOffline&&h(c)&&(t.offline=!0),!t.offline){await C(xn(c),{recursive:!0});let e=Date.now();if(typeof s.tar==`function`){let e=s.tar;await(async()=>{let n=await e({auth:t.auth});await ce(n instanceof ae?n:ae.fromWeb(n),m(c))})().catch(e=>{if(!h(c))throw e;Y(`Download error. Using cached version:`,e),t.offline=!0})}else await or(s.tar,c,{headers:{Authorization:t.auth?`Bearer ${t.auth}`:void 0,...dr(s.headers)}}).catch(e=>{if(!h(c))throw e;Y(`Download error. Using cached version:`,e),t.offline=!0});Y(`Downloaded to ${c} in ${Date.now()-e}ms`)}if(!h(c))throw Error(`Tarball not found: ${c} (offline: ${t.offline})`);let l=W(W(t.cwd||`.`),t.dir||s.defaultDir);if(t.forceClean&&await T(l,{recursive:!0,force:!0}),!t.force&&h(l)&&g(l).length>0)throw Error(`Destination ${l} already exists.`);await C(l,{recursive:!0});let u=Date.now(),d=s.subdir?.replace(/^\//,``)||``,{extract:f}=await import(`./tar-Bd_UMghg.mjs`).then(e=>e.t);if(await f({file:c,cwd:l,onReadEntry(e){e.path=e.path.split(`/`).splice(1).join(`/`),d&&(e.path.startsWith(d+`/`)?e.path=e.path.slice(d.length):e.path=``)}}),Y(`Extracted to ${l} in ${Date.now()-u}ms`),t.install){Y(`Installing dependencies...`);let{installDependencies:e}=await Promise.resolve().then(()=>fn).then(e=>e.t);await e({cwd:l,silent:t.silent,...typeof t.install==`object`?t.install:{}})}return{...s,source:i,dir:l}}function Tr(e){return e}const Er=Tr([`default`,`monorepo`]),Dr=Tr([`pnpm`,`npm`,`bun`,`yarn`,`deno`]),Or={name:{type:`positional`,description:`Project name`,required:!1},template:{type:`enum`,description:`Template to use`,options:Er,required:!1,alias:[`t`]},install:{type:`boolean`,description:`Install dependencies`,required:!1,alias:[`i`]},packageManager:{type:`enum`,description:`Package manager to use`,options:Dr,required:!1,alias:[`p`]}};var Z=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),Q=t(import.meta.url);const kr=/^path$/i,Ar={key:`PATH`,value:``};function jr(e){for(let t in e){if(!Object.prototype.hasOwnProperty.call(e,t)||!kr.test(t))continue;let n=e[t];return n?{key:t,value:n}:Ar}return Ar}function Mr(e,t){let n=t.value.split(y),r=[],i=e,a;do r.push(ee(i,`node_modules`,`.bin`)),a=i,i=b(i);while(i!==a);r.push(b(process.execPath));let o=r.concat(n).join(y);return{key:t.key,value:o}}function Nr(e,t){let n={...process.env,...t},r=Mr(e,jr(n));return n[r.key]=r.value,n}const Pr=e=>{let t=e.length,n=new ie,r=()=>{--t===0&&n.end()};for(let t of e)ce(t,n,{end:!1}).then(r).catch(r);return n};var Fr=Z(((e,t)=>{t.exports=a,a.sync=o;var n=Q(`fs`);function r(e,t){var n=t.pathExt===void 0?process.env.PATHEXT:t.pathExt;if(!n||(n=n.split(`;`),n.indexOf(``)!==-1))return!0;for(var r=0;r<n.length;r++){var i=n[r].toLowerCase();if(i&&e.substr(-i.length).toLowerCase()===i)return!0}return!1}function i(e,t,n){return!e.isSymbolicLink()&&!e.isFile()?!1:r(t,n)}function a(e,t,r){n.stat(e,function(n,a){r(n,n?!1:i(a,e,t))})}function o(e,t){return i(n.statSync(e),e,t)}})),Ir=Z(((e,t)=>{t.exports=r,r.sync=i;var n=Q(`fs`);function r(e,t,r){n.stat(e,function(e,n){r(e,e?!1:a(n,t))})}function i(e,t){return a(n.statSync(e),t)}function a(e,t){return e.isFile()&&o(e,t)}function o(e,t){var n=e.mode,r=e.uid,i=e.gid,a=t.uid===void 0?process.getuid&&process.getuid():t.uid,o=t.gid===void 0?process.getgid&&process.getgid():t.gid,s=64,c=8,l=1,u=s|c;return n&l||n&c&&i===o||n&s&&r===a||n&u&&a===0}})),Lr=Z(((e,t)=>{Q(`fs`);var n=process.platform===`win32`||global.TESTING_WINDOWS?Fr():Ir();t.exports=r,r.sync=i;function r(e,t,i){if(typeof t==`function`&&(i=t,t={}),!i){if(typeof Promise!=`function`)throw TypeError(`callback not provided`);return new Promise(function(n,i){r(e,t||{},function(e,t){e?i(e):n(t)})})}n(e,t||{},function(e,n){e&&(e.code===`EACCES`||t&&t.ignoreErrors)&&(e=null,n=!1),i(e,n)})}function i(e,t){try{return n.sync(e,t||{})}catch(e){if(t&&t.ignoreErrors||e.code===`EACCES`)return!1;throw e}}})),Rr=Z(((e,t)=>{let n=process.platform===`win32`||process.env.OSTYPE===`cygwin`||process.env.OSTYPE===`msys`,r=Q(`path`),i=n?`;`:`:`,a=Lr(),o=e=>Object.assign(Error(`not found: ${e}`),{code:`ENOENT`}),s=(e,t)=>{let r=t.colon||i,a=e.match(/\//)||n&&e.match(/\\/)?[``]:[...n?[process.cwd()]:[],...(t.path||process.env.PATH||``).split(r)],o=n?t.pathExt||process.env.PATHEXT||`.EXE;.CMD;.BAT;.COM`:``,s=n?o.split(r):[``];return n&&e.indexOf(`.`)!==-1&&s[0]!==``&&s.unshift(``),{pathEnv:a,pathExt:s,pathExtExe:o}},c=(e,t,n)=>{typeof t==`function`&&(n=t,t={}),t||={};let{pathEnv:i,pathExt:c,pathExtExe:l}=s(e,t),u=[],d=n=>new Promise((a,s)=>{if(n===i.length)return t.all&&u.length?a(u):s(o(e));let c=i[n],l=/^".*"$/.test(c)?c.slice(1,-1):c,d=r.join(l,e);a(f(!l&&/^\.[\\\/]/.test(e)?e.slice(0,2)+d:d,n,0))}),f=(e,n,r)=>new Promise((i,o)=>{if(r===c.length)return i(d(n+1));let s=c[r];a(e+s,{pathExt:l},(a,o)=>{if(!a&&o)if(t.all)u.push(e+s);else return i(e+s);return i(f(e,n,r+1))})});return n?d(0).then(e=>n(null,e),n):d(0)};t.exports=c,c.sync=(e,t)=>{t||={};let{pathEnv:n,pathExt:i,pathExtExe:c}=s(e,t),l=[];for(let o=0;o<n.length;o++){let s=n[o],u=/^".*"$/.test(s)?s.slice(1,-1):s,d=r.join(u,e),f=!u&&/^\.[\\\/]/.test(e)?e.slice(0,2)+d:d;for(let e=0;e<i.length;e++){let n=f+i[e];try{if(a.sync(n,{pathExt:c}))if(t.all)l.push(n);else return n}catch{}}}if(t.all&&l.length)return l;if(t.nothrow)return null;throw o(e)}})),zr=Z(((e,t)=>{let n=(e={})=>{let t=e.env||process.env;return(e.platform||process.platform)===`win32`?Object.keys(t).reverse().find(e=>e.toUpperCase()===`PATH`)||`Path`:`PATH`};t.exports=n,t.exports.default=n})),Br=Z(((e,t)=>{let n=Q(`path`),r=Rr(),i=zr();function a(e,t){let a=e.options.env||process.env,o=process.cwd(),s=e.options.cwd!=null,c=s&&process.chdir!==void 0&&!process.chdir.disabled;if(c)try{process.chdir(e.options.cwd)}catch{}let l;try{l=r.sync(e.command,{path:a[i({env:a})],pathExt:t?n.delimiter:void 0})}catch{}finally{c&&process.chdir(o)}return l&&=n.resolve(s?e.options.cwd:``,l),l}function o(e){return a(e)||a(e,!0)}t.exports=o})),Vr=Z(((e,t)=>{let n=/([()\][%!^"`<>&|;, *?])/g;function r(e){return e=e.replace(n,`^$1`),e}function i(e,t){return e=`${e}`,e=e.replace(/(?=(\\+?)?)\1"/g,`$1$1\\"`),e=e.replace(/(?=(\\+?)?)\1$/,`$1$1`),e=`"${e}"`,e=e.replace(n,`^$1`),t&&(e=e.replace(n,`^$1`)),e}t.exports.command=r,t.exports.argument=i})),Hr=Z(((e,t)=>{t.exports=/^#!(.*)/})),Ur=Z(((e,t)=>{let n=Hr();t.exports=(e=``)=>{let t=e.match(n);if(!t)return null;let[r,i]=t[0].replace(/#! ?/,``).split(` `),a=r.split(`/`).pop();return a===`env`?i:i?`${a} ${i}`:a}})),Wr=Z(((e,t)=>{let n=Q(`fs`),r=Ur();function i(e){let t=Buffer.alloc(150),i;try{i=n.openSync(e,`r`),n.readSync(i,t,0,150,0),n.closeSync(i)}catch{}return r(t.toString())}t.exports=i})),Gr=Z(((e,t)=>{let n=Q(`path`),r=Br(),i=Vr(),a=Wr(),o=process.platform===`win32`,s=/\.(?:com|exe)$/i,c=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function l(e){e.file=r(e);let t=e.file&&a(e.file);return t?(e.args.unshift(e.file),e.command=t,r(e)):e.file}function u(e){if(!o)return e;let t=l(e),r=!s.test(t);if(e.options.forceShell||r){let r=c.test(t);e.command=n.normalize(e.command),e.command=i.command(e.command),e.args=e.args.map(e=>i.argument(e,r)),e.args=[`/d`,`/s`,`/c`,`"${[e.command].concat(e.args).join(` `)}"`],e.command=process.env.comspec||`cmd.exe`,e.options.windowsVerbatimArguments=!0}return e}function d(e,t,n){t&&!Array.isArray(t)&&(n=t,t=null),t=t?t.slice(0):[],n=Object.assign({},n);let r={command:e,args:t,options:n,file:void 0,original:{command:e,args:t}};return n.shell?r:u(r)}t.exports=d})),Kr=Z(((e,t)=>{let n=process.platform===`win32`;function r(e,t){return Object.assign(Error(`${t} ${e.command} ENOENT`),{code:`ENOENT`,errno:`ENOENT`,syscall:`${t} ${e.command}`,path:e.command,spawnargs:e.args})}function i(e,t){if(!n)return;let r=e.emit;e.emit=function(n,i){if(n===`exit`){let n=a(i,t);if(n)return r.call(e,`error`,n)}return r.apply(e,arguments)}}function a(e,t){return n&&e===1&&!t.file?r(t.original,`spawn`):null}function o(e,t){return n&&e===1&&!t.file?r(t.original,`spawnSync`):null}t.exports={hookChildProcess:i,verifyENOENT:a,verifyENOENTSync:o,notFoundError:r}})),qr=Z(((e,t)=>{let n=Q(`child_process`),r=Gr(),i=Kr();function a(e,t,a){let o=r(e,t,a),s=n.spawn(o.command,o.args,o.options);return i.hookChildProcess(s,o),s}function o(e,t,a){let o=r(e,t,a),s=n.spawnSync(o.command,o.args,o.options);return s.error=s.error||i.verifyENOENTSync(s.status,o),s}t.exports=a,t.exports.spawn=a,t.exports.sync=o,t.exports._parse=r,t.exports._enoent=i}))(),Jr=class extends Error{get exitCode(){if(this.result.exitCode!==null)return this.result.exitCode}constructor(e,t){super(`Process exited with non-zero status (${e.exitCode})`),this.result=e,this.output=t}};const Yr={timeout:void 0,persist:!1},Xr={windowsHide:!0};function Zr(e){let t=new AbortController;for(let n of e){if(n.aborted)return t.abort(),n;n.addEventListener(`abort`,()=>{t.abort(n.reason)},{signal:t.signal})}return t.signal}async function Qr(e){let t=``;try{for await(let n of e)t+=n.toString()}catch{}return t}var $r=class{_process;_aborted=!1;_options;_command;_args;_resolveClose;_processClosed;_thrownError;get process(){return this._process}get pid(){return this._process?.pid}get exitCode(){if(this._process&&this._process.exitCode!==null)return this._process.exitCode}constructor(e,t,n){this._options={...Yr,...n},this._command=e,this._args=t??[],this._processClosed=new Promise(e=>{this._resolveClose=e})}kill(e){return this._process?.kill(e)===!0}get aborted(){return this._aborted}get killed(){return this._process?.killed===!0}pipe(e,t,n){return ei(e,t,{...n,stdin:this})}async*[Symbol.asyncIterator](){let e=this._process;if(!e)return;let t=[];this._streamErr&&t.push(this._streamErr),this._streamOut&&t.push(this._streamOut);let n=Pr(t),r=d.createInterface({input:n});for await(let e of r)yield e.toString();if(await this._processClosed,e.removeAllListeners(),this._thrownError)throw this._thrownError;if(this._options?.throwOnError&&this.exitCode!==0&&this.exitCode!==void 0)throw new Jr(this)}async _waitForOutput(){let e=this._process;if(!e)throw Error(`No process was started`);let[t,n]=await Promise.all([this._streamOut?Qr(this._streamOut):``,this._streamErr?Qr(this._streamErr):``]);await this._processClosed;let{stdin:r}=this._options;if(r&&typeof r!=`string`&&await r,e.removeAllListeners(),this._thrownError)throw this._thrownError;let i={stderr:n,stdout:t,exitCode:this.exitCode};if(this._options.throwOnError&&this.exitCode!==0&&this.exitCode!==void 0)throw new Jr(this,i);return i}then(e,t){return this._waitForOutput().then(e,t)}_streamOut;_streamErr;spawn(){let e=s(),t=this._options,n={...Xr,...t.nodeOptions},r=[];this._resetState(),t.timeout!==void 0&&r.push(AbortSignal.timeout(t.timeout)),t.signal!==void 0&&r.push(t.signal),t.persist===!0&&(n.detached=!0),r.length>0&&(n.signal=Zr(r)),n.env=Nr(e,n.env);let i=(0,qr._parse)(this._command,this._args,n),a=se(i.command,i.args,i.options);if(a.stderr&&(this._streamErr=a.stderr),a.stdout&&(this._streamOut=a.stdout),this._process=a,a.once(`error`,this._onError),a.once(`close`,this._onClose),a.stdin){let{stdin:e}=t;typeof e==`string`?a.stdin.end(e):e?.process?.stdout?.pipe(a.stdin)}}_resetState(){this._aborted=!1,this._processClosed=new Promise(e=>{this._resolveClose=e}),this._thrownError=void 0}_onError=e=>{if(e.name===`AbortError`&&(!(e.cause instanceof Error)||e.cause.name!==`TimeoutError`)){this._aborted=!0;return}this._thrownError=e};_onClose=()=>{this._resolveClose&&this._resolveClose()}};const $=(e,t,n)=>{let r=new $r(e,t,n);return r.spawn(),r},ei=$;function ti(){let e=process.env.npm_config_user_agent??``;return e.startsWith(`pnpm/`)?`pnpm`:e.startsWith(`yarn/`)?`yarn`:e.startsWith(`bun/`)?`bun`:e.startsWith(`deno/`)?`deno`:`npm`}async function ni(){try{return await $(`pnpm`,[`--version`],{throwOnError:!0}),!0}catch{return!1}}async function ri(e){await $(`git`,[`init`],{throwOnError:!1,nodeOptions:{cwd:e,stdio:`inherit`}})}async function ii(e,t){let n=kt({title:`Installing dependencies with ${t}...`,limit:5,retainLog:!1}),r=wt();r.start();let i=[`install`];t===`npm`&&i.push(`--legacy-peer-deps`);let a=$(t,i,{throwOnError:!1,nodeOptions:{cwd:e}});for await(let e of a){let t=e.trim();t&&n.message(t)}let o=await a;return r.stop(),o.exitCode===0?(n.success(`Dependencies installed`),!0):(n.error(`Dependency installation failed. You can run \`${t} install\` manually.`),!1)}function ai(e){return e===`npm`?`npm run dev`:e===`deno`?`deno task dev`:`${e} dev`}const oi=/^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/;function si(e){for(let t of e){let e=t.codePointAt(0);if(e!==void 0&&(e<=31||`<>:"|?*`.includes(t)))return!0}return!1}function ci(e){let t=e.trim();if(t.length===0)return`Project name is required`;if(t!==`.`){if(t.includes(`/`)||t.includes(`\\`))return`Project name cannot contain path separators`;if(si(t))return`Project name contains invalid characters`;if(t===`..`)return`Project name cannot be ..`;if(t.startsWith(`.`))return`Project name cannot start with a period`;if(t.endsWith(`.`)||t.endsWith(`-`))return`Project name cannot end with a period or hyphen`;if(t.length>214)return`Project name must be 214 characters or fewer`;if(!oi.test(t))return`Use letters, numbers, periods, underscores, or hyphens`}}function li(e,t){return typeof t==`string`&&e.includes(t)}async function ui(e){let t;try{t=await re(e)}catch(e){if(e&&typeof e==`object`&&`code`in e&&e.code===`ENOENT`)return;throw e}if(t.length>0)return`Directory must be empty.`}async function di(){let e=await At({message:`Project name:`,placeholder:`my-project`,defaultValue:`my-project`,validate(e){if(typeof e==`string`)return ci(e)}});if(Ve(e)){L(`Operation cancelled.`);return}return e}async function fi(){let e=await Et({message:`Select a template:`,options:[{value:`default`,label:`Default`,hint:`minimal TanStarter template`},{value:`monorepo`,label:`Monorepo (beta)`,hint:`TanStarter via Vite+ with pnpm`}]});if(Ve(e)){L(`Operation cancelled.`);return}return e}async function pi(){let e=await vt({message:`Install dependencies after scaffolding?`,initialValue:!0});if(Ve(e)){L(`Operation cancelled.`);return}return e}async function mi(e){let t=await Et({message:`Select a package manager:`,options:[{value:`pnpm`,label:`pnpm (Recommended)`},{value:`npm`,label:`npm`},{value:`bun`,label:`bun`},{value:`yarn`,label:`yarn`},{value:`deno`,label:`deno`}],initialValue:e});if(Ve(t)){L(`Operation cancelled.`);return}return t}async function hi(e){let t=e.name,n=e.template,r=e.install,i=e.packageManager,a=await ni()?`pnpm`:ti();if(!t&&(t=await di(),!t))return;t=String(t).trim();let o=await ui(t===`.`?process.cwd():x(process.cwd(),t));if(o){L(o);return}let s=ci(t);if(s){L(s);return}if(!(!n&&(n=await fi(),!n))&&!(r===void 0&&(r=await pi(),r===void 0))&&!(r&&!i&&(i=await mi(a),!i))&&!(!li(Er,n)||typeof r!=`boolean`)&&!(i!==void 0&&!li(Dr,i)))return{projectName:t,template:n,install:r,selectedPackageManager:i,preferredPackageManager:a}}const gi={default:{source:`github:mugnavo/tanstarter`,homeUrl:`https://github.com/mugnavo/tanstarter`},monorepo:{source:`github:mugnavo/tanstarter-plus`,homeUrl:`https://github.com/mugnavo/tanstarter-plus`}};function _i(e){return gi[e]}function vi(e,t){if(!t)return"This project was scaffolded with [`create-mugnavo`](https://github.com/mugnavo/create-mugnavo).";let n=_i(e);return`This project was scaffolded with \`create-mugnavo\` from commit [\`${t.slice(0,7)}\`](${`${n.homeUrl}/tree/${t}`}). See the [template changelog](${`${n.homeUrl}/compare/${t}...main`}) for newer changes.`}function yi(e,t,n){if(!n)return!1;let r=e.findIndex(e=>e.trim()===`## Issue watchlist`);if(r===-1)return!1;let i=e.findIndex((e,t)=>t>r&&e.startsWith(`## `)),a=i===-1?e.length:i,o=`${_i(t).homeUrl}/compare/${n}...main`;if(e.slice(r+1,a).some(e=>e.includes(o)))return!1;let s=r+1;for(;s<a&&e[s]?.trim()===``;)s+=1;return e.splice(s,0,`- [Template changelog](${o}) - Track template updates since this project was created.`),!0}function bi(e,t){return t===`.`?v(ee(e))||`app`:t}async function xi(e){await T(x(e,`LICENSE`),{force:!0})}async function Si(e,t){if(t===`default`){await te(x(e,`.env.example`),x(e,`.env`),p.COPYFILE_EXCL);return}if(t===`monorepo`){await te(x(e,`apps`,`web`,`.env.example`),x(e,`apps`,`web`,`.env`),p.COPYFILE_EXCL);return}}async function Ci(e,t){let n=x(e,`package.json`),r=JSON.parse(await w(n,`utf8`));r.name=bi(e,t),await E(n,`${JSON.stringify(r,null,2)}\n`)}async function wi(e,t,n,r){let i=x(e,`README.md`),a=bi(e,n),o=await w(i,`utf8`),s=o.includes(`\r
|
|
71
|
+
`}case`submit`:{let e=o?` ${r(`dim`,o)}`:``;return`${n}${t?r(`gray`,L):``}${e}`}case`cancel`:{let e=o?` ${r([`strikethrough`,`dim`],o)}`:``,i=t?r(`gray`,L):``;return`${n}${i}${e}${o.trim()?`
|
|
72
|
+
${i}`:``}`}default:return`${n}${t?`${r(`cyan`,L)} `:``}${a}
|
|
73
|
+
${t?r(`cyan`,R):``}
|
|
74
|
+
`}}}).prompt(),kt=/\d/,At=[`-`,`_`,`/`,`.`];function jt(e=``){if(!kt.test(e))return e!==e.toLowerCase()}function Mt(e,t){let n=t??At,r=[];if(!e||typeof e!=`string`)return r;let i=``,a,o;for(let t of e){let e=n.includes(t);if(e===!0){r.push(i),i=``,a=void 0;continue}let s=jt(t);if(o===!1){if(a===!1&&s===!0){r.push(i),i=t,a=s;continue}if(a===!0&&s===!1&&i.length>1){let e=i.at(-1);r.push(i.slice(0,Math.max(0,i.length-1))),i=e+t,a=s;continue}}i+=t,a=s,o=e}return r.push(i),r}function Nt(e){return e?e[0].toUpperCase()+e.slice(1):``}function Pt(e){return e?e[0].toLowerCase()+e.slice(1):``}function Ft(e,t){return e?(Array.isArray(e)?e:Mt(e)).map(e=>Nt(t?.normalize?e.toLowerCase():e)).join(``):``}function It(e,t){return Pt(Ft(e||``,t))}function Lt(e,t){return e?(Array.isArray(e)?e:Mt(e)).map(e=>e.toLowerCase()).join(t??`-`):``}function Rt(e){return Lt(e||``,`_`)}function H(e){return Array.isArray(e)?e:e===void 0?[]:[e]}function zt(e,t=``){let n=[];for(let t of e)for(let[e,r]of t.entries())n[e]=Math.max(n[e]||0,r.length);return e.map(e=>e.map((e,r)=>t+e[r===0?`padStart`:`padEnd`](n[r])).join(` `)).join(`
|
|
75
|
+
`)}function U(e){return typeof e==`function`?e():e}var W=class extends Error{code;constructor(e,t){super(e),this.name=`CLIError`,this.code=t}};function Bt(e=[],n={}){let r=new Set(n.boolean||[]),i=new Set(n.string||[]),a=n.alias||{},o=n.default||{},s=new Map,c=new Map;for(let[e,t]of Object.entries(a)){let n=t;for(let t of n)s.set(e,t),c.has(t)||c.set(t,[]),c.get(t).push(e),s.set(t,e),c.has(e)||c.set(e,[]),c.get(e).push(t)}let l={};function u(e){if(r.has(e))return`boolean`;let t=c.get(e)||[];for(let e of t)if(r.has(e))return`boolean`;return`string`}function d(e){if(i.has(e))return!0;let t=c.get(e)||[];for(let e of t)if(i.has(e))return!0;return!1}let f=new Set([...r,...i,...Object.keys(a),...Object.values(a).flat(),...Object.keys(o)]);for(let e of f)l[e]||(l[e]={type:u(e),default:o[e]});for(let[e,t]of s.entries())e.length===1&&l[t]&&!l[t].short&&(l[t].short=e);let p=[],m={};for(let t=0;t<e.length;t++){let n=e[t];if(n===`--`){p.push(...e.slice(t));break}if(n.startsWith(`--no-`)){let e=n.slice(5);m[e]=!0;continue}p.push(n)}let h;try{h=t({args:p,options:Object.keys(l).length>0?l:void 0,allowPositionals:!0,strict:!1})}catch{h={values:{},positionals:p}}let g={_:[]};g._=h.positionals;for(let[e,t]of Object.entries(h.values)){let n=t;u(e)===`boolean`&&typeof t==`string`?n=t!==`false`:d(e)&&typeof t==`boolean`&&(n=``),g[e]=n}for(let[e]of Object.entries(m)){g[e]=!1;let t=s.get(e);t&&(g[t]=!1);let n=c.get(e);if(n)for(let e of n)g[e]=!1}for(let[e,t]of s.entries())g[e]!==void 0&&g[t]===void 0&&(g[t]=g[e]),g[t]!==void 0&&g[e]===void 0&&(g[e]=g[t]),g[e]!==g[t]&&o[t]===g[t]&&(g[t]=g[e]);return g}const Vt=(()=>{let e=globalThis.process?.env??{};return e.NO_COLOR===`1`||e.TERM===`dumb`||e.TEST||e.CI})(),G=(e,t=39)=>n=>Vt?n:`\u001B[${e}m${n}\u001B[${t}m`,Ht=G(1,22),K=G(36),Ut=G(90),Wt=G(4,24);function Gt(e,t){let n={boolean:[],string:[],alias:{},default:{}},r=Kt(t);for(let e of r){if(e.type===`positional`)continue;e.type===`string`||e.type===`enum`?n.string.push(e.name):e.type===`boolean`&&n.boolean.push(e.name),e.default!==void 0&&(n.default[e.name]=e.default),e.alias&&(n.alias[e.name]=e.alias);let t=It(e.name),r=Lt(e.name);if(t!==e.name||r!==e.name){let i=H(n.alias[e.name]||[]);t!==e.name&&!i.includes(t)&&i.push(t),r!==e.name&&!i.includes(r)&&i.push(r),i.length>0&&(n.alias[e.name]=i)}}let i=Bt(e,n),[...a]=i._,o=new Proxy(i,{get(e,t){return e[t]??e[It(t)]??e[Lt(t)]}});for(let[,e]of r.entries())if(e.type===`positional`){let t=a.shift();if(t!==void 0)o[e.name]=t;else if(e.default===void 0&&e.required!==!1)throw new W(`Missing required positional argument: ${e.name.toUpperCase()}`,`EARG`);else o[e.name]=e.default}else if(e.type===`enum`){let t=o[e.name],n=e.options||[];if(t!==void 0&&n.length>0&&!n.includes(t))throw new W(`Invalid value for argument: ${K(`--${e.name}`)} (${K(t)}). Expected one of: ${n.map(e=>K(e)).join(`, `)}.`,`EARG`)}else if(e.required&&o[e.name]===void 0)throw new W(`Missing required argument: --${e.name}`,`EARG`);return o}function Kt(e){let t=[];for(let[n,r]of Object.entries(e||{}))t.push({...r,name:n,alias:H(r.alias)});return t}async function qt(e){return Promise.all(e.map(e=>U(e)))}function Jt(e){return e}async function Yt(e,t){let n=await U(e.args||{}),r=Gt(t.rawArgs,n),i={rawArgs:t.rawArgs,args:r,data:t.data,cmd:e},a=await qt(e.plugins??[]),o,s;try{for(let e of a)await e.setup?.(i);typeof e.setup==`function`&&await e.setup(i);let r=await U(e.subCommands);if(r&&Object.keys(r).length>0){let i=Qt(t.rawArgs,n),a=t.rawArgs[i];if(a){let e=await Zt(r,a);if(!e)throw new W(`Unknown command ${K(a)}`,`E_UNKNOWN_COMMAND`);await Yt(e,{rawArgs:t.rawArgs.slice(i+1)})}else{let n=await U(e.default);if(n){if(e.run)throw new W(`Cannot specify both 'run' and 'default' on the same command.`,`E_DEFAULT_CONFLICT`);let i=await Zt(r,n);if(!i)throw new W(`Default sub command ${K(n)} not found in subCommands.`,`E_UNKNOWN_COMMAND`);await Yt(i,{rawArgs:t.rawArgs})}else if(!e.run)throw new W(`No command specified.`,`E_NO_COMMAND`)}}typeof e.run==`function`&&(o=await e.run(i))}catch(e){s=e}let c=[];if(typeof e.cleanup==`function`)try{await e.cleanup(i)}catch(e){c.push(e)}for(let e of[...a].reverse())try{await e.cleanup?.(i)}catch(e){c.push(e)}if(s)throw s;if(c.length===1)throw c[0];if(c.length>1)throw Error(`Multiple cleanup errors`,{cause:c});return{result:o}}async function Xt(e,t,n){let r=await U(e.subCommands);if(r&&Object.keys(r).length>0){let n=Qt(t,await U(e.args||{})),i=t[n],a=await Zt(r,i);if(a)return Xt(a,t.slice(n+1),e)}return[e,n]}async function Zt(e,t){if(t in e)return U(e[t]);for(let n of Object.values(e)){let e=await U(n),r=await U(e?.meta);if(r?.alias&&H(r.alias).includes(t))return e}}function Qt(e,t){for(let n=0;n<e.length;n++){let r=e[n];if(r===`--`)return-1;if(r.startsWith(`-`)){!r.includes(`=`)&&$t(r,t)&&n++;continue}return n}return-1}function $t(e,t){let n=e.replace(/^-{1,2}/,``),r=It(n);for(let[e,i]of Object.entries(t))if(!(i.type!==`string`&&i.type!==`enum`)&&(r===It(e)||(Array.isArray(i.alias)?i.alias:i.alias?[i.alias]:[]).includes(n)))return!0;return!1}async function en(e,t){try{console.log(await nn(e,t)+`
|
|
76
|
+
`)}catch(e){console.error(e)}}const tn=/^no[-A-Z]/;async function nn(e,t){let n=await U(e.meta||{}),r=Kt(await U(e.args||{})),i=await U(t?.meta||{}),a=`${i.name?`${i.name} `:``}`+(n.name||process.argv[1]),o=[],s=[],c=[],l=[];for(let e of r)if(e.type===`positional`){let t=e.name.toUpperCase(),n=e.required!==!1&&e.default===void 0;s.push([K(t+rn(e)),an(e,n)]),l.push(n?`<${t}>`:`[${t}]`)}else{let t=e.required===!0&&e.default===void 0,n=[...(e.alias||[]).map(e=>`-${e}`),`--${e.name}`].join(`, `)+rn(e);if(o.push([K(n),an(e,t)]),e.type===`boolean`&&(e.default===!0||e.negativeDescription)&&!tn.test(e.name)){let n=[...(e.alias||[]).map(e=>`--no-${e}`),`--no-${e.name}`].join(`, `);o.push([K(n),[e.negativeDescription,t?Ut(`(Required)`):``].filter(Boolean).join(` `)])}t&&l.push(`--${e.name}`+rn(e))}if(e.subCommands){let t=[],n=await U(e.subCommands);for(let[e,r]of Object.entries(n)){let n=await U((await U(r))?.meta);if(n?.hidden)continue;let i=H(n?.alias),a=[e,...i].join(`, `);c.push([K(a),n?.description||``]),t.push(e,...i)}l.push(t.join(`|`))}let u=[],d=n.version||i.version;u.push(Ut(`${n.description} (${a+(d?` v${d}`:``)})`),``);let f=o.length>0||s.length>0;return u.push(`${Wt(Ht(`USAGE`))} ${K(`${a}${f?` [OPTIONS]`:``} ${l.join(` `)}`)}`,``),s.length>0&&(u.push(Wt(Ht(`ARGUMENTS`)),``),u.push(zt(s,` `)),u.push(``)),o.length>0&&(u.push(Wt(Ht(`OPTIONS`)),``),u.push(zt(o,` `)),u.push(``)),c.length>0&&(u.push(Wt(Ht(`COMMANDS`)),``),u.push(zt(c,` `)),u.push(``,`Use ${K(`${a} <command> --help`)} for more information about a command.`)),u.filter(e=>typeof e==`string`).join(`
|
|
77
|
+
`)}function rn(e){let t=e.valueHint?`=<${e.valueHint}>`:``,n=t||`=<${Rt(e.name)}>`;return!e.type||e.type===`positional`||e.type===`boolean`?t:e.type===`enum`&&e.options?.length?`=<${e.options.join(`|`)}>`:n}function an(e,t){let n=t?Ut(`(Required)`):``,r=e.default===void 0?``:Ut(`(Default: ${e.default})`);return[e.description,n,r].filter(Boolean).join(` `)}async function on(e,t={}){let n=t.rawArgs||process.argv.slice(2),r=t.showUsage||en;try{let t=await sn(e);if(t.help.length>0&&n.some(e=>t.help.includes(e)))await r(...await Xt(e,n)),process.exit(0);else if(n.length===1&&t.version.includes(n[0])){let t=typeof e.meta==`function`?await e.meta():await e.meta;if(!t?.version)throw new W(`No version specified`,`E_NO_VERSION`);console.log(t.version)}else await Yt(e,{rawArgs:n})}catch(t){t instanceof W?(await r(...await Xt(e,n)),console.error(t.message)):console.error(t,`
|
|
78
|
+
`),process.exit(1)}}async function sn(e){let t=await U(e.args||{}),n=new Set,r=new Set;for(let[e,i]of Object.entries(t)){n.add(e);for(let e of H(i.alias))r.add(e)}return{help:cn(`help`,`h`,n,r),version:cn(`version`,`v`,n,r)}}function cn(e,t,n,r){return n.has(e)||r.has(e)?[]:n.has(t)||r.has(t)?[`--${e}`]:[`--${e}`,`-${t}`]}var ln=Object.defineProperty,un=(e,t)=>{let n={};for(var r in e)ln(n,r,{get:e[r],enumerable:!0});return t||ln(n,Symbol.toStringTag,{value:`Module`}),n},dn=fe({a:()=>q,n:()=>Sn,r:()=>xn,t:()=>Zn});const fn=/^[A-Za-z]:\//;function pn(e=``){return e&&e.replace(/\\/g,`/`).replace(fn,e=>e.toUpperCase())}const mn=/^[/\\]{2}/,hn=/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/,gn=/^[A-Za-z]:$/,_n=function(e){if(e.length===0)return`.`;e=pn(e);let t=e.match(mn),n=J(e),r=e[e.length-1]===`/`;return e=bn(e,!n),e.length===0?n?`/`:r?`./`:`.`:(r&&(e+=`/`),gn.test(e)&&(e+=`/`),t?n?`//${e}`:`//./${e}`:n&&!J(e)?`/${e}`:e)},vn=function(...e){let t=``;for(let n of e)if(n)if(t.length>0){let e=t[t.length-1]===`/`,r=n[0]===`/`;e&&r?t+=n.slice(1):t+=e||r?n:`/${n}`}else t+=n;return _n(t)};function yn(){return typeof process<`u`&&typeof process.cwd==`function`?process.cwd().replace(/\\/g,`/`):`/`}const q=function(...e){e=e.map(e=>pn(e));let t=``,n=!1;for(let r=e.length-1;r>=-1&&!n;r--){let i=r>=0?e[r]:yn();!i||i.length===0||(t=`${i}/${t}`,n=J(i))}return t=bn(t,!n),n&&!J(t)?`/${t}`:t.length>0?t:`.`};function bn(e,t){let n=``,r=0,i=-1,a=0,o=null;for(let s=0;s<=e.length;++s){if(s<e.length)o=e[s];else if(o===`/`)break;else o=`/`;if(o===`/`){if(!(i===s-1||a===1))if(a===2){if(n.length<2||r!==2||n[n.length-1]!==`.`||n[n.length-2]!==`.`){if(n.length>2){let e=n.lastIndexOf(`/`);e===-1?(n=``,r=0):(n=n.slice(0,e),r=n.length-1-n.lastIndexOf(`/`)),i=s,a=0;continue}else if(n.length>0){n=``,r=0,i=s,a=0;continue}}t&&(n+=n.length>0?`/..`:`..`,r=2)}else n.length>0?n+=`/${e.slice(i+1,s)}`:n=e.slice(i+1,s),r=s-i-1;i=s,a=0}else o===`.`&&a!==-1?++a:a=-1}return n}const J=function(e){return hn.test(e)},xn=function(e){let t=pn(e).replace(/\/$/,``).split(`/`).slice(0,-1);return t.length===1&&gn.test(t[0])&&(t[0]+=`/`),t.join(`/`)||(J(e)?`/`:`.`)},Sn=function(e,t){let n=pn(e).split(`/`),r=``;for(let e=n.length-1;e>=0;e--){let t=n[e];if(t){r=t;break}}return t&&r.endsWith(t)?r.slice(0,-t.length):r};globalThis.process?.platform;var Y=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),X=e(import.meta.url);const Cn=/^path$/i,wn={key:`PATH`,value:``};function Tn(e){for(let t in e){if(!Object.prototype.hasOwnProperty.call(e,t)||!Cn.test(t))continue;let n=e[t];return n?{key:t,value:n}:wn}return wn}function En(e,t){let n=t.value.split(x),r=[],i=e,a;do r.push(w(i,`node_modules`,`.bin`)),a=i,i=S(i);while(i!==a);let o=r.concat(n).join(x);return{key:t.key,value:o}}function Dn(e,t){let n={...process.env,...t},r=En(e,Tn(n));return n[r.key]=r.value,n}const On=e=>{let t=e.length,n=new re,r=()=>{--t===0&&n.emit(`end`)};for(let t of e)t.pipe(n,{end:!1}),t.on(`end`,r);return n};var kn=Y(((e,t)=>{t.exports=a,a.sync=o;var n=X(`fs`);function r(e,t){var n=t.pathExt===void 0?process.env.PATHEXT:t.pathExt;if(!n||(n=n.split(`;`),n.indexOf(``)!==-1))return!0;for(var r=0;r<n.length;r++){var i=n[r].toLowerCase();if(i&&e.substr(-i.length).toLowerCase()===i)return!0}return!1}function i(e,t,n){return!e.isSymbolicLink()&&!e.isFile()?!1:r(t,n)}function a(e,t,r){n.stat(e,function(n,a){r(n,n?!1:i(a,e,t))})}function o(e,t){return i(n.statSync(e),e,t)}})),An=Y(((e,t)=>{t.exports=r,r.sync=i;var n=X(`fs`);function r(e,t,r){n.stat(e,function(e,n){r(e,e?!1:a(n,t))})}function i(e,t){return a(n.statSync(e),t)}function a(e,t){return e.isFile()&&o(e,t)}function o(e,t){var n=e.mode,r=e.uid,i=e.gid,a=t.uid===void 0?process.getuid&&process.getuid():t.uid,o=t.gid===void 0?process.getgid&&process.getgid():t.gid,s=64,c=8,l=1,u=s|c;return n&l||n&c&&i===o||n&s&&r===a||n&u&&a===0}})),jn=Y(((e,t)=>{X(`fs`);var n=process.platform===`win32`||global.TESTING_WINDOWS?kn():An();t.exports=r,r.sync=i;function r(e,t,i){if(typeof t==`function`&&(i=t,t={}),!i){if(typeof Promise!=`function`)throw TypeError(`callback not provided`);return new Promise(function(n,i){r(e,t||{},function(e,t){e?i(e):n(t)})})}n(e,t||{},function(e,n){e&&(e.code===`EACCES`||t&&t.ignoreErrors)&&(e=null,n=!1),i(e,n)})}function i(e,t){try{return n.sync(e,t||{})}catch(e){if(t&&t.ignoreErrors||e.code===`EACCES`)return!1;throw e}}})),Mn=Y(((e,t)=>{let n=process.platform===`win32`||process.env.OSTYPE===`cygwin`||process.env.OSTYPE===`msys`,r=X(`path`),i=n?`;`:`:`,a=jn(),o=e=>Object.assign(Error(`not found: ${e}`),{code:`ENOENT`}),s=(e,t)=>{let r=t.colon||i,a=e.match(/\//)||n&&e.match(/\\/)?[``]:[...n?[process.cwd()]:[],...(t.path||process.env.PATH||``).split(r)],o=n?t.pathExt||process.env.PATHEXT||`.EXE;.CMD;.BAT;.COM`:``,s=n?o.split(r):[``];return n&&e.indexOf(`.`)!==-1&&s[0]!==``&&s.unshift(``),{pathEnv:a,pathExt:s,pathExtExe:o}},c=(e,t,n)=>{typeof t==`function`&&(n=t,t={}),t||={};let{pathEnv:i,pathExt:c,pathExtExe:l}=s(e,t),u=[],d=n=>new Promise((a,s)=>{if(n===i.length)return t.all&&u.length?a(u):s(o(e));let c=i[n],l=/^".*"$/.test(c)?c.slice(1,-1):c,d=r.join(l,e);a(f(!l&&/^\.[\\\/]/.test(e)?e.slice(0,2)+d:d,n,0))}),f=(e,n,r)=>new Promise((i,o)=>{if(r===c.length)return i(d(n+1));let s=c[r];a(e+s,{pathExt:l},(a,o)=>{if(!a&&o)if(t.all)u.push(e+s);else return i(e+s);return i(f(e,n,r+1))})});return n?d(0).then(e=>n(null,e),n):d(0)};t.exports=c,c.sync=(e,t)=>{t||={};let{pathEnv:n,pathExt:i,pathExtExe:c}=s(e,t),l=[];for(let o=0;o<n.length;o++){let s=n[o],u=/^".*"$/.test(s)?s.slice(1,-1):s,d=r.join(u,e),f=!u&&/^\.[\\\/]/.test(e)?e.slice(0,2)+d:d;for(let e=0;e<i.length;e++){let n=f+i[e];try{if(a.sync(n,{pathExt:c}))if(t.all)l.push(n);else return n}catch{}}}if(t.all&&l.length)return l;if(t.nothrow)return null;throw o(e)}})),Nn=Y(((e,t)=>{let n=(e={})=>{let t=e.env||process.env;return(e.platform||process.platform)===`win32`?Object.keys(t).reverse().find(e=>e.toUpperCase()===`PATH`)||`Path`:`PATH`};t.exports=n,t.exports.default=n})),Pn=Y(((e,t)=>{let n=X(`path`),r=Mn(),i=Nn();function a(e,t){let a=e.options.env||process.env,o=process.cwd(),s=e.options.cwd!=null,c=s&&process.chdir!==void 0&&!process.chdir.disabled;if(c)try{process.chdir(e.options.cwd)}catch{}let l;try{l=r.sync(e.command,{path:a[i({env:a})],pathExt:t?n.delimiter:void 0})}catch{}finally{c&&process.chdir(o)}return l&&=n.resolve(s?e.options.cwd:``,l),l}function o(e){return a(e)||a(e,!0)}t.exports=o})),Fn=Y(((e,t)=>{let n=/([()\][%!^"`<>&|;, *?])/g;function r(e){return e=e.replace(n,`^$1`),e}function i(e,t){return e=`${e}`,e=e.replace(/(?=(\\+?)?)\1"/g,`$1$1\\"`),e=e.replace(/(?=(\\+?)?)\1$/,`$1$1`),e=`"${e}"`,e=e.replace(n,`^$1`),t&&(e=e.replace(n,`^$1`)),e}t.exports.command=r,t.exports.argument=i})),In=Y(((e,t)=>{t.exports=/^#!(.*)/})),Ln=Y(((e,t)=>{let n=In();t.exports=(e=``)=>{let t=e.match(n);if(!t)return null;let[r,i]=t[0].replace(/#! ?/,``).split(` `),a=r.split(`/`).pop();return a===`env`?i:i?`${a} ${i}`:a}})),Rn=Y(((e,t)=>{let n=X(`fs`),r=Ln();function i(e){let t=Buffer.alloc(150),i;try{i=n.openSync(e,`r`),n.readSync(i,t,0,150,0),n.closeSync(i)}catch{}return r(t.toString())}t.exports=i})),zn=Y(((e,t)=>{let n=X(`path`),r=Pn(),i=Fn(),a=Rn(),o=process.platform===`win32`,s=/\.(?:com|exe)$/i,c=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function l(e){e.file=r(e);let t=e.file&&a(e.file);return t?(e.args.unshift(e.file),e.command=t,r(e)):e.file}function u(e){if(!o)return e;let t=l(e),r=!s.test(t);if(e.options.forceShell||r){let r=c.test(t);e.command=n.normalize(e.command),e.command=i.command(e.command),e.args=e.args.map(e=>i.argument(e,r)),e.args=[`/d`,`/s`,`/c`,`"${[e.command].concat(e.args).join(` `)}"`],e.command=process.env.comspec||`cmd.exe`,e.options.windowsVerbatimArguments=!0}return e}function d(e,t,n){t&&!Array.isArray(t)&&(n=t,t=null),t=t?t.slice(0):[],n=Object.assign({},n);let r={command:e,args:t,options:n,file:void 0,original:{command:e,args:t}};return n.shell?r:u(r)}t.exports=d})),Bn=Y(((e,t)=>{let n=process.platform===`win32`;function r(e,t){return Object.assign(Error(`${t} ${e.command} ENOENT`),{code:`ENOENT`,errno:`ENOENT`,syscall:`${t} ${e.command}`,path:e.command,spawnargs:e.args})}function i(e,t){if(!n)return;let r=e.emit;e.emit=function(n,i){if(n===`exit`){let n=a(i,t);if(n)return r.call(e,`error`,n)}return r.apply(e,arguments)}}function a(e,t){return n&&e===1&&!t.file?r(t.original,`spawn`):null}function o(e,t){return n&&e===1&&!t.file?r(t.original,`spawnSync`):null}t.exports={hookChildProcess:i,verifyENOENT:a,verifyENOENTSync:o,notFoundError:r}})),Vn=Y(((e,t)=>{let n=X(`child_process`),r=zn(),i=Bn();function a(e,t,a){let o=r(e,t,a),s=n.spawn(o.command,o.args,o.options);return i.hookChildProcess(s,o),s}function o(e,t,a){let o=r(e,t,a),s=n.spawnSync(o.command,o.args,o.options);return s.error=s.error||i.verifyENOENTSync(s.status,o),s}t.exports=a,t.exports.spawn=a,t.exports.sync=o,t.exports._parse=r,t.exports._enoent=i}))(),Hn=class extends Error{result;output;get exitCode(){if(this.result.exitCode!==null)return this.result.exitCode}constructor(e,t){super(`Process exited with non-zero status (${e.exitCode})`),this.result=e,this.output=t}};const Un={timeout:void 0,persist:!1},Wn={windowsHide:!0};function Gn(e,t){return{command:ee(e),args:t??[]}}function Kn(e){let t=new AbortController;for(let n of e){if(n.aborted)return t.abort(),n;n.addEventListener(`abort`,()=>{t.abort(n.reason)},{signal:t.signal})}return t.signal}async function qn(e){let t=``;for await(let n of e)t+=n.toString();return t}var Jn=class{_process;_aborted=!1;_options;_command;_args;_resolveClose;_processClosed;_thrownError;get process(){return this._process}get pid(){return this._process?.pid}get exitCode(){if(this._process&&this._process.exitCode!==null)return this._process.exitCode}constructor(e,t,n){this._options={...Un,...n},this._command=e,this._args=t??[],this._processClosed=new Promise(e=>{this._resolveClose=e})}kill(e){return this._process?.kill(e)===!0}get aborted(){return this._aborted}get killed(){return this._process?.killed===!0}pipe(e,t,n){return Xn(e,t,{...n,stdin:this})}async*[Symbol.asyncIterator](){let e=this._process;if(!e)return;let t=[];this._streamErr&&t.push(this._streamErr),this._streamOut&&t.push(this._streamOut);let n=On(t),r=l.createInterface({input:n});for await(let e of r)yield e.toString();if(await this._processClosed,e.removeAllListeners(),this._thrownError)throw this._thrownError;if(this._options?.throwOnError&&this.exitCode!==0&&this.exitCode!==void 0)throw new Hn(this)}async _waitForOutput(){let e=this._process;if(!e)throw Error(`No process was started`);let[t,n]=await Promise.all([this._streamOut?qn(this._streamOut):``,this._streamErr?qn(this._streamErr):``]);if(await this._processClosed,this._options?.stdin&&await this._options.stdin,e.removeAllListeners(),this._thrownError)throw this._thrownError;let r={stderr:n,stdout:t,exitCode:this.exitCode};if(this._options.throwOnError&&this.exitCode!==0&&this.exitCode!==void 0)throw new Hn(this,r);return r}then(e,t){return this._waitForOutput().then(e,t)}_streamOut;_streamErr;spawn(){let e=a(),t=this._options,n={...Wn,...t.nodeOptions},r=[];this._resetState(),t.timeout!==void 0&&r.push(AbortSignal.timeout(t.timeout)),t.signal!==void 0&&r.push(t.signal),t.persist===!0&&(n.detached=!0),r.length>0&&(n.signal=Kn(r)),n.env=Dn(e,n.env);let{command:i,args:o}=Gn(this._command,this._args),s=(0,Vn._parse)(i,o,n),c=oe(s.command,s.args,s.options);if(c.stderr&&(this._streamErr=c.stderr),c.stdout&&(this._streamOut=c.stdout),this._process=c,c.once(`error`,this._onError),c.once(`close`,this._onClose),t.stdin!==void 0&&c.stdin&&t.stdin.process){let{stdout:e}=t.stdin.process;e&&e.pipe(c.stdin)}}_resetState(){this._aborted=!1,this._processClosed=new Promise(e=>{this._resolveClose=e}),this._thrownError=void 0}_onError=e=>{if(e.name===`AbortError`&&(!(e.cause instanceof Error)||e.cause.name!==`TimeoutError`)){this._aborted=!0;return}this._thrownError=e};_onClose=()=>{this._resolveClose&&this._resolveClose()}};const Yn=(e,t,n)=>{let r=new Jn(e,t,n);return r.spawn(),r},Xn=Yn;var Zn=un({detectPackageManager:()=>ir,installDependencies:()=>ar,packageManagers:()=>Z});async function Qn(e,t,n={}){let r=_n(e).split(`/`);for(;r.length>0;){let e=await t(r.join(`/`)||`/`);if(e||!n.includeParentDirs)return e;r.pop()}}function $n(e){let t;return()=>(t===void 0&&(t=e().then(e=>(t=e,t))),t)}const er=$n(async()=>{if(globalThis.process?.versions?.webcontainer)return!1;try{let{exitCode:e}=await Yn(`corepack`,[`--version`]);return e===0}catch{return!1}});async function tr(e,t,n={}){let r=e!==`npm`&&e!==`bun`&&e!==`deno`&&n.corepack!==!1&&await er()?[`corepack`,[e,...t]]:[e,t],{exitCode:i,stdout:a,stderr:o}=await Yn(r[0],r[1],{nodeOptions:{cwd:q(n.cwd||process.cwd()),env:n.env,stdio:n.silent?`pipe`:`inherit`}});if(i!==0)throw Error(`\`${r.flat().join(` `)}\` failed.${n.silent?[``,a,o].join(`
|
|
79
|
+
`):``}`)}async function nr(e={}){let t=e.cwd||process.cwd(),n={...process.env,...e.env},r=(typeof e.packageManager==`string`?Z.find(t=>t.name===e.packageManager):e.packageManager)||await ir(e.cwd||process.cwd());if(!r)throw Error(`No package manager auto-detected.`);return{cwd:t,env:n,silent:e.silent??!1,packageManager:r,dev:e.dev??!1,workspace:e.workspace,global:e.global??!1,dry:e.dry??!1,corepack:e.corepack??!0}}function rr(e){let[t,n]=(e||``).split(`@`),[r,i]=n?.split(`+`)||[];if(t&&t!==`-`&&/^(@[a-z0-9-~][a-z0-9-._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/.test(t))return{name:t,version:r,buildMeta:i};let a=(t||``).replace(/\W+/g,``);return{name:a,version:r,buildMeta:i,warnings:[`Abnormal characters found in \`packageManager\` field, sanitizing from \`${t}\` to \`${a}\``]}}const Z=[{name:`npm`,command:`npm`,lockFile:`package-lock.json`},{name:`pnpm`,command:`pnpm`,lockFile:`pnpm-lock.yaml`,files:[`pnpm-workspace.yaml`]},{name:`bun`,command:`bun`,lockFile:[`bun.lockb`,`bun.lock`]},{name:`yarn`,command:`yarn`,lockFile:`yarn.lock`,files:[`.yarnrc.yml`]},{name:`deno`,command:`deno`,lockFile:`deno.lock`,files:[`deno.json`]}];async function ir(e,t={}){let n=await Qn(q(e||`.`),async e=>{if(!t.ignorePackageJSON){let t=vn(e,`package.json`);if(m(t)){let e=JSON.parse(await E(t,`utf8`));if(e?.packageManager){let{name:t,version:n=`0.0.0`,buildMeta:r,warnings:i}=rr(e.packageManager);if(t){let e=n.split(`.`)[0],a=Z.find(n=>n.name===t&&n.majorVersion===e)||Z.find(e=>e.name===t);return{name:t,command:t,version:n,majorVersion:e,buildMeta:r,warnings:i,files:a?.files,lockFile:a?.lockFile}}}}if(m(vn(e,`deno.json`)))return Z.find(e=>e.name===`deno`)}if(!t.ignoreLockFile){for(let t of Z)if([t.lockFile,t.files].flat().filter(Boolean).some(t=>m(q(e,t))))return{...t}}},{includeParentDirs:t.includeParentDirs??!0});if(!n&&!t.ignoreArgv){let e=process.argv[1];if(e){for(let t of Z)if(RegExp(`[/\\\\]\\.?${t.command}`).test(e))return t}}return n}async function ar(e={}){let t=await nr(e),n=e.frozenLockFile?{npm:[`ci`],yarn:[`install`,`--immutable`],bun:[`install`,`--frozen-lockfile`],pnpm:[`install`,`--frozen-lockfile`],deno:[`install`,`--frozen`]}[t.packageManager.name]:[`install`];return e.ignoreWorkspace&&t.packageManager.name===`pnpm`&&n.push(`--ignore-workspace`),t.dry||await tr(t.packageManager.command,n,{cwd:t.cwd,silent:t.silent,corepack:t.corepack}),{exec:{command:t.packageManager.command,args:n}}}async function or(e,t,r={}){let i=t+`.json`,a=JSON.parse(await E(i,`utf8`).catch(()=>`{}`)),o=(await $(e,{method:`HEAD`,headers:r.headers}).catch(()=>void 0))?.headers.get(`etag`);if(a.etag===o&&m(t))return;typeof o==`string`&&(a.etag=o);let s=await $(e,{headers:r.headers});if(s.status>=400)throw Error(`Failed to download ${e}: ${s.status} ${s.statusText}`);let c=p(t);await n(ae)(s.body,c),await k(i,JSON.stringify(a),`utf8`)}const sr=/^(?<repo>[-\w.]+\/[-\w.]+)(?<subdir>[^#]+)?(?<ref>#[-\w./@]+)?/,cr=/^(?<repo>[-\w.]+(?:\/[-\w.]+)+?)(?:::(?<subdir>[^#]*))?(?<ref>#[-\w./@]+)?$/;function lr(e,t){let n=t?.expandRepo||e.includes(`::`),r=e.match(n?cr:sr)?.groups||{},i=n?r.subdir?`/`+r.subdir:`/`:r.subdir||`/`;return{repo:r.repo||``,subdir:i,ref:r.ref?r.ref.slice(1):`main`}}function Q(...e){process.env.DEBUG&&console.debug(`[giget]`,...e)}async function $(e,t={}){t.headers?.[`sec-fetch-mode`]&&(t.mode=t.headers[`sec-fetch-mode`]);let n=await fetch(e,{...t,headers:dr(t.headers)}).catch(t=>{throw Error(`Failed to download ${e}: ${t}`,{cause:t})});if(t.validateStatus&&n.status>=400)throw Error(`Failed to fetch ${e}: ${n.status} ${n.statusText}`);return n}function ur(){let e=process.env.XDG_CACHE_HOME?q(process.env.XDG_CACHE_HOME,`giget`):q(ce(),`.cache/giget`);if(process.platform===`win32`){let t=q(le(),`giget`);if(!m(t)&&m(e))try{v(e,t)}catch{}return t}return e}function dr(e={}){let t={};for(let[n,r]of Object.entries(e))r&&(t[n.toLowerCase()]=r);return t}const fr=(e,t)=>{let n=pr(e);return{name:n.name,version:n.subdir?`${n.version||`default`}-${n.subdir.replaceAll(`/`,`-`)}`:n.version,tar:({auth:e}={})=>mr(n,e??t.auth)}};function pr(e,t={}){let n=t.cwd??process.cwd(),r=e.replace(/#.*$/,``),i;if(/^[./]/.test(e))r=q(n,r);else if(/^https?:\/\//.test(r)){let e=/^(https?:\/\/[^/]+)\/([\w.-]+\/[\w.-]+?)(?:\.git)?(?:\/(.+))?$/.exec(r);if(e){let[,t,n,a]=e;r=`${t}/${n}`,a&&(i=a)}}else if(r.includes(`@`)){let e=/^(.*?:[\w.-]+\/[\w.-]+?)(?:\.git)?(?:\/(.+))?$/.exec(r);if(e){let[,t,n]=e;r=t,n&&(i=n)}}else{let e={"github:":`https://github.com/`,"gh:":`https://github.com/`,"gitlab:":`https://gitlab.com/`,"bitbucket:":`https://bitbucket.org/`,"sourcehut:":`https://git.sr.ht/~`},t=/^(.+?:)/.exec(r)?.at(1);t&&e[t]?r=r.replace(t,e[t]):t||(r=`${(process.env.GIGET_GIT_HOST||`https://github.com/`).replace(/\/$/,``)}/${r}`);let n=/^(https?:\/\/[^/]+\/~?[\w.-]+\/[\w.-]+?)(?:\.git)?(?:\/(.+))?$/.exec(r);if(n){let[,e,t]=n;r=e,t&&(i=t)}}let a=r.replace(/^https?:\/\//,``).replace(/^.+@/,``).replace(/(\.git)?(#.*)?$/,``).replace(/^\W+/,``).replaceAll(/[:/]/g,`-`),[o,s]=/#(.+)$/.exec(e)?.at(1)?.split(`:`)??[],c=o||void 0,l=s||i;return{uri:r,name:a,...c&&{version:c},...l&&{subdir:l}}}async function mr(e,t){let n=await ne(C(le(),`giget-git-`));if(t&&/[\r\n]/.test(t))throw Error(`Auth token must not contain newline characters`);let r={...process.env,GIT_TERMINAL_PROMPT:`0`};t&&(r.GIT_CONFIG_COUNT=`1`,r.GIT_CONFIG_KEY_0=`http.extraHeader`,r.GIT_CONFIG_VALUE_0=`Authorization: Bearer ${t}`);let i={env:r,timeout:6e4},a=_r(),o=e=>gr(e,i,a),s=e=>gr(e,{...i,cwd:n},a);try{let t=[`clone`,`--progress`,`--depth`,`1`];e.subdir&&t.push(`--filter=blob:none`,`--sparse`,`--no-checkout`),e.version&&t.push(`--branch`,e.version),t.push(`--`,e.uri,n);try{a.update(`Cloning...`),await o(t),a.update(`Cloned.`)}catch(t){if(!e.version)throw t;Q(`Shallow clone failed, falling back to full clone:`,t),a.update(`Shallow clone failed, cloning...`),await O(n,{recursive:!0,force:!0}),await T(n,{recursive:!0}),await s([`init`]),await s([`remote`,`add`,`origin`,e.uri]),await s([`fetch`,`origin`]),await s([`checkout`,e.version]),a.update(`Fetched.`)}e.subdir&&(a.update(`Sparse checkout ${e.subdir}...`),await s([`sparse-checkout`,`set`,e.subdir]),await s([`checkout`])),a.update(`Packing...`);let r=e.subdir?C(n,e.subdir):n,{create:i}=await import(`./tar-BEYLyU6F.mjs`).then(e=>e.t);a.done();let c=i({gzip:!0,cwd:r,filter:e=>!e.startsWith(`.git/`)&&e!==`.git`&&!e.startsWith(`./.git/`)&&e!==`./.git`},[`.`]).pipe(new re),l=!1,u=()=>{l||(l=!0,O(n,{recursive:!0,force:!0}))};return c.on(`end`,u),c.on(`error`,u),c.on(`close`,u),c}catch(e){throw a.done(),await O(n,{recursive:!0,force:!0}),e}}const hr=[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`];function gr(e,t,n){return new Promise((r,i)=>{let a=oe(`git`,e,{...t,stdio:[`ignore`,`pipe`,`pipe`]});a.stdout.resume();let o=``;a.stderr?.on(`data`,e=>{let t=e.toString();for(let e of t.split(/[\r\n]/)){let t=e.trim();t&&(o=t)}n&&n.update(o)}),a.on(`close`,t=>{t===0?r(o):i(Error(`git ${e[0]} exited with code ${t}. Is git installed?`))}),a.on(`error`,e=>{e.code===`ENOENT`?i(Error(`git is not installed or not found in PATH`)):i(e)})})}function _r(){if(!process.stderr.isTTY)return{update(e){},done(){}};let e=``,t=0,n=()=>{let n=hr[t%hr.length];t++,process.stderr.write(`\x1B[2K\r\x1B[2m${n} ${e}\x1B[0m`)},r=setInterval(n,80);return{update(t){e=t,n()},done(){clearInterval(r),process.stderr.write(`\x1B[2K\r`)}}}const vr=async(e,t)=>{if(e.endsWith(`.json`))return await yr(e,t);let n=new URL(e),r=Sn(n.pathname);try{let i=await $(n.href,{method:`HEAD`,validateStatus:!0,headers:{authorization:t.auth?`Bearer ${t.auth}`:void 0}});if((i.headers.get(`content-type`)||``).includes(`application/json`))return await yr(e,t);let a=i.headers.get(`content-disposition`)?.match(/filename="?(.+)"?/)?.[1];a&&(r=a.split(`.`)[0])}catch(e){Q(`Failed to fetch HEAD for ${n.href}:`,e)}return{name:`${r}-${n.href.slice(0,8)}`,version:``,subdir:``,tar:n.href,defaultDir:r,headers:{Authorization:t.auth?`Bearer ${t.auth}`:void 0}}},yr=async(e,t)=>{let n=await(await $(e,{validateStatus:!0,headers:{authorization:t.auth?`Bearer ${t.auth}`:void 0}})).json();if(!n.tar||!n.name)throw Error(`Invalid template info from ${e}. name or tar fields are missing!`);return n},br=(e,t)=>{let n=lr(e),r=process.env.GIGET_GITHUB_URL||`https://api.github.com`;return{name:n.repo.replace(`/`,`-`),version:n.ref,subdir:n.subdir,headers:{Authorization:t.auth?`Bearer ${t.auth}`:void 0,Accept:`application/vnd.github+json`,"X-GitHub-Api-Version":`2022-11-28`},url:`${r.replace(`api.github.com`,`github.com`)}/${n.repo}/tree/${n.ref}${n.subdir}`,tar:`${r}/repos/${n.repo}/tarball/${n.ref}`}},xr={http:vr,https:vr,git:fr,github:br,gh:br,gitlab:(e,t)=>{let n=lr(e,{expandRepo:!0}),r=process.env.GIGET_GITLAB_URL||`https://gitlab.com`;return{name:n.repo.replace(`/`,`-`),version:n.ref,subdir:n.subdir,headers:{authorization:t.auth?`Bearer ${t.auth}`:void 0,"sec-fetch-mode":`same-origin`},url:`${r}/${n.repo}/tree/${n.ref}${n.subdir}`,tar:`${r}/${n.repo}/-/archive/${n.ref}.tar.gz`}},bitbucket:(e,t)=>{let n=lr(e);return{name:n.repo.replace(`/`,`-`),version:n.ref,subdir:n.subdir,headers:{authorization:t.auth?`Bearer ${t.auth}`:void 0},url:`https://bitbucket.com/${n.repo}/src/${n.ref}${n.subdir}`,tar:`https://bitbucket.org/${n.repo}/get/${n.ref}.tar.gz`}},sourcehut:(e,t)=>{let n=lr(e);return{name:n.repo.replace(`/`,`-`),version:n.ref,subdir:n.subdir,headers:{authorization:t.auth?`Bearer ${t.auth}`:void 0},url:`https://git.sr.ht/~${n.repo}/tree/${n.ref}/item${n.subdir}`,tar:`https://git.sr.ht/~${n.repo}/archive/${n.ref}.tar.gz`}}},Sr=(e=`https://raw.githubusercontent.com/unjs/giget/main/templates`,t={})=>(async n=>{let r=Date.now(),i=`${e}/${n}.json`,a=await $(i,{headers:{authorization:t.auth?`Bearer ${t.auth}`:void 0}});if(a.status>=400)throw Error(`Failed to download ${n} template info from ${i}: ${a.status} ${a.statusText}`);let o=await a.json();if(!o.tar||!o.name)throw Error(`Invalid template info from ${i}. name or tar fields are missing!`);return Q(`Fetched ${n} template info from ${i} in ${Date.now()-r}ms`),o}),Cr=/^([\w+-.]+):/;async function wr(e,t={}){t.registry=process.env.GIGET_REGISTRY??t.registry,t.auth=process.env.GIGET_AUTH??t.auth;let n=t.registry===!1?void 0:Sr(t.registry,{auth:t.auth}),r=t.provider||(n?`registry`:`github`),i=e,a=e.match(Cr);a&&(r=a[1],i=e.slice(a[0].length),(r===`http`||r===`https`)&&(i=e)),r.endsWith(`+git`)&&(i=`${r.slice(0,-4)}:${i}`,r=`git`);let o=t.providers?.[r]||xr[r]||n;if(!o)throw Error(`Unsupported provider: ${r}`);let s=await Promise.resolve().then(()=>o(i,{auth:t.auth})).catch(e=>{throw Error(`Failed to download template from ${r}: ${e.message}`)});if(!s)throw Error(`Failed to resolve template from ${r}`);s.name=(s.name||`template`).replace(/[^\da-z-]/gi,`-`),s.defaultDir=(s.defaultDir||s.name).replace(/[^\da-z-]/gi,`-`);let c=q(q(ur(),r,s.name),(s.version||s.name)+`.tar.gz`);if(t.preferOffline&&m(c)&&(t.offline=!0),!t.offline){await T(xn(c),{recursive:!0});let e=Date.now();if(typeof s.tar==`function`){let e=s.tar;await(async()=>{let n=await e({auth:t.auth});await se(n instanceof ie?n:ie.fromWeb(n),p(c))})().catch(e=>{if(!m(c))throw e;Q(`Download error. Using cached version:`,e),t.offline=!0})}else await or(s.tar,c,{headers:{Authorization:t.auth?`Bearer ${t.auth}`:void 0,...dr(s.headers)}}).catch(e=>{if(!m(c))throw e;Q(`Download error. Using cached version:`,e),t.offline=!0});Q(`Downloaded to ${c} in ${Date.now()-e}ms`)}if(!m(c))throw Error(`Tarball not found: ${c} (offline: ${t.offline})`);let l=q(q(t.cwd||`.`),t.dir||s.defaultDir);if(t.forceClean&&await O(l,{recursive:!0,force:!0}),!t.force&&m(l)&&_(l).length>0)throw Error(`Destination ${l} already exists.`);await T(l,{recursive:!0});let u=Date.now(),d=s.subdir?.replace(/^\//,``)||``,{extract:f}=await import(`./tar-BEYLyU6F.mjs`).then(e=>e.t);if(await f({file:c,cwd:l,onReadEntry(e){e.path=e.path.split(`/`).splice(1).join(`/`),d&&(e.path.startsWith(d+`/`)?e.path=e.path.slice(d.length):e.path=``)}}),Q(`Extracted to ${l} in ${Date.now()-u}ms`),t.install){Q(`Installing dependencies...`);let{installDependencies:e}=await Promise.resolve().then(()=>dn).then(e=>e.t);await e({cwd:l,silent:t.silent,...typeof t.install==`object`?t.install:{}})}return{...s,source:i,dir:l}}function Tr(e){return e}const Er=Tr([`default`,`monorepo`]),Dr={name:{type:`positional`,description:`Project name`,required:!1},template:{type:`enum`,description:`Template to use`,options:Er,required:!1,alias:[`t`]},install:{type:`boolean`,description:`Install dependencies with pnpm`,required:!1,alias:[`i`]}},Or=/^path$/i,kr={key:`PATH`,value:``};function Ar(e){for(let t in e){if(!Object.prototype.hasOwnProperty.call(e,t)||!Or.test(t))continue;let n=e[t];return n?{key:t,value:n}:kr}return kr}function jr(e,t){let n=t.value.split(x),r=[],i=e,a;do r.push(w(i,`node_modules`,`.bin`)),a=i,i=S(i);while(i!==a);r.push(S(process.execPath));let o=r.concat(n).join(x);return{key:t.key,value:o}}function Mr(e,t,n=!0){let r={...process.env,...t};if(!n)return r;let i=jr(e,Ar(r));return r[i.key]=i.value,r}const Nr=e=>{let t=e.length,n=new re,r=()=>{--t===0&&n.end()};for(let t of e)se(t,n,{end:!1}).then(r).catch(r);return n},Pr=/([()\][%!^"`<>&|;, *?])/g,Fr=/^#!\s*(.+)/,Ir=/\.(?:com|exe)$/i,Lr=/node_modules[\\/]\.bin[\\/][^\\/]+\.cmd$/i,Rr=process.platform===`win32`,zr=[`.EXE`,`.CMD`,`.BAT`,`.COM`];function Br(e,t=[],n={}){if(n.shell===!0||!Rr)return{command:e,args:t,options:n};let r=Vr(e,n),i=null;if(r!==null){let e=Buffer.alloc(150),t=null;try{t=h(r,`r`),g(t,e,0,150,0)}catch{}finally{t!==null&&d(t)}let n=e.toString().match(Fr);if(n!==null){let e=n[1].trim(),t=e.indexOf(` `),r=t===-1?e:e.slice(0,t),a=t===-1?``:e.slice(t+1),o=b(r);i=o===`env`?a||null:o}}if(i!==null&&r!==null&&(t=[r,...t],e=i,r=Vr(e,n)),r===null||!Ir.test(r)){let i=r!==null&&Lr.test(r);e=ee(e),e=e.replace(Pr,`^$1`),t=t.map(e=>(e=e.replace(/(?=(\\+?)?)\1"/g,`$1$1\\"`),e=e.replace(/(?=(\\+?)?)\1$/,`$1$1`),e=`"${e}"`,e=e.replace(Pr,`^$1`),i&&(e=e.replace(Pr,`^$1`)),e)),t=[`/d`,`/s`,`/c`,`"${[e,...t].join(` `)}"`],e=n.env?.comspec??`cmd.exe`,n={...n,windowsVerbatimArguments:!0}}return{command:e,args:t,options:n}}function Vr(e,t){let n=(t.cwd??a()).toString(),r=t.env??process.env,i=Ar(r).value,o=e.includes(`/`)||e.includes(`\\`)?[``]:[n,...i.split(x)],s=r.PATHEXT?r.PATHEXT.split(x):zr;e.includes(`.`)&&s[0]!==``&&s.unshift(``);for(let t of o){let r=w(n,t.startsWith(`"`)&&t.endsWith(`"`)&&t.length>1?t.slice(1,-1):t,e);for(let e of s){let t=r+e;try{if(y(t).isFile())return t}catch{}}}return null}var Hr=class extends Error{result;output;get exitCode(){if(this.result.exitCode!==null)return this.result.exitCode}constructor(e,t){super(`Process exited with non-zero status (${e.exitCode})`),this.result=e,this.output=t}};const Ur={timeout:void 0,persist:!1},Wr={windowsHide:!0};function Gr(e){let t=new AbortController;for(let n of e){if(n.aborted)return t.abort(),n;n.addEventListener(`abort`,()=>{t.abort(n.reason)},{signal:t.signal})}return t.signal}async function Kr(e){let t=``;try{for await(let n of e)t+=n.toString()}catch{}return t}var qr=class{_process;_aborted=!1;_options;_command;_args;_resolveClose;_processClosed;_thrownError;get process(){return this._process}get pid(){return this._process?.pid}get exitCode(){if(this._process&&this._process.exitCode!==null)return this._process.exitCode}constructor(e,t,n){this._options={...Ur,...n},this._command=e,this._args=t??[],this._processClosed=new Promise(e=>{this._resolveClose=e})}kill(e){return this._process?.kill(e)===!0}get aborted(){return this._aborted}get killed(){return this._process?.killed===!0}pipe(e,t,n){return Yr(e,t,{...n,stdin:this})}async*[Symbol.asyncIterator](){let e=this._process;if(!e)return;let t=[];this._streamErr&&t.push(this._streamErr),this._streamOut&&t.push(this._streamOut);let n=Nr(t),r=l.createInterface({input:n});for await(let e of r)yield e.toString();if(await this._processClosed,e.removeAllListeners(),this._thrownError)throw this._thrownError;if(this._options?.throwOnError&&this.exitCode!==0&&this.exitCode!==void 0)throw new Hr(this)}async _waitForOutput(){let e=this._process;if(!e)throw Error(`No process was started`);let[t,n]=await Promise.all([this._streamOut?Kr(this._streamOut):``,this._streamErr?Kr(this._streamErr):``]);await this._processClosed;let{stdin:r}=this._options;if(r&&typeof r!=`string`&&await r,e.removeAllListeners(),this._thrownError)throw this._thrownError;let i={stderr:n,stdout:t,exitCode:this.exitCode};if(this._options.throwOnError&&this.exitCode!==0&&this.exitCode!==void 0)throw new Hr(this,i);return i}then(e,t){return this._waitForOutput().then(e,t)}_streamOut;_streamErr;spawn(){let e=a(),t=this._options,n={...Wr,...t.nodeOptions},r=[];this._resetState(),t.timeout!==void 0&&r.push(AbortSignal.timeout(t.timeout)),t.signal!==void 0&&r.push(t.signal),t.persist===!0&&(n.detached=!0),r.length>0&&(n.signal=Gr(r)),n.env=Mr(e,n.env,t.nodePath);let i=Br(this._command,this._args,n),o=oe(i.command,i.args,i.options);if(o.stderr&&(this._streamErr=o.stderr),o.stdout&&(this._streamOut=o.stdout),this._process=o,o.once(`error`,this._onError),o.once(`close`,this._onClose),o.stdin){let{stdin:e}=t;typeof e==`string`?o.stdin.end(e):e?.process?.stdout?.pipe(o.stdin)}}_resetState(){this._aborted=!1,this._processClosed=new Promise(e=>{this._resolveClose=e}),this._thrownError=void 0}_onError=e=>{if(e.name===`AbortError`&&(!(e.cause instanceof Error)||e.cause.name!==`TimeoutError`)){this._aborted=!0;return}this._thrownError=e};_onClose=()=>{this._resolveClose&&this._resolveClose()}};const Jr=(e,t,n)=>{let r=new qr(e,t,n);return r.spawn(),r},Yr=Jr;function Xr(){let e=process.env.npm_config_user_agent??``;return e.startsWith(`pnpm/`)?`pnpm`:e.startsWith(`yarn/`)?`yarn`:e.startsWith(`bun/`)?`bun`:e.startsWith(`deno/`)?`deno`:`npm`}async function Zr(){try{return await Jr(`pnpm`,[`--version`],{throwOnError:!0}),!0}catch{return!1}}async function Qr(e){await Jr(`git`,[`init`],{throwOnError:!1,nodeOptions:{cwd:e,stdio:`inherit`}})}async function $r(e,t){let n=Dt({title:`Installing dependencies with ${t}...`,limit:5,retainLog:!1}),r=Ct();r.start();let i=[`install`];t===`npm`&&i.push(`--legacy-peer-deps`);let a=Jr(t,i,{throwOnError:!1,nodeOptions:{cwd:e}});for await(let e of a){let t=e.trim();t&&n.message(t)}let o=await a;return r.stop(),o.exitCode===0?(n.success(`Dependencies installed`),!0):(n.error(`Dependency installation failed. You can run \`${t} install\` manually.`),!1)}function ei(e){return e===`npm`?`npm run dev`:e===`deno`?`deno task dev`:`${e} dev`}const ti=/^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/;function ni(e){for(let t of e){let e=t.codePointAt(0);if(e!==void 0&&(e<=31||`<>:"|?*`.includes(t)))return!0}return!1}function ri(e){let t=e.trim();if(t.length===0)return`Project name is required`;if(t!==`.`){if(t.includes(`/`)||t.includes(`\\`))return`Project name cannot contain path separators`;if(ni(t))return`Project name contains invalid characters`;if(t===`..`)return`Project name cannot be ..`;if(t.startsWith(`.`))return`Project name cannot start with a period`;if(t.endsWith(`.`)||t.endsWith(`-`))return`Project name cannot end with a period or hyphen`;if(t.length>214)return`Project name must be 214 characters or fewer`;if(!ti.test(t))return`Use letters, numbers, periods, underscores, or hyphens`}}function ii(e,t){return typeof t==`string`&&e.includes(t)}async function ai(e){let t;try{t=await D(e)}catch(e){if(e&&typeof e==`object`&&`code`in e&&e.code===`ENOENT`)return;throw e}if(t.length>0)return`Directory must be empty.`}async function oi(){let e=await Ot({message:`Project name:`,placeholder:`my-project`,defaultValue:`my-project`,validate(e){if(typeof e==`string`)return ri(e)}});if(Be(e)){V(`Operation cancelled.`);return}return e}async function si(){let e=await Tt({message:`Select a template:`,options:[{value:`default`,label:`Default`,hint:`minimal TanStarter template`},{value:`monorepo`,label:`Monorepo (beta)`,hint:`TanStarter via Vite+ with pnpm`}]});if(Be(e)){V(`Operation cancelled.`);return}return e}async function ci(){let e=await _t({message:`Install dependencies after scaffolding?`,initialValue:!0});if(Be(e)){V(`Operation cancelled.`);return}return e}async function li(e){let t=e.name,n=e.template,r=e.install,i=await Zr()?`pnpm`:Xr();if(!t&&(t=await oi(),!t))return;t=String(t).trim();let a=await ai(t===`.`?process.cwd():C(process.cwd(),t));if(a){V(a);return}let o=ri(t);if(o){V(o);return}if(!(!n&&(n=await si(),!n))&&!(r===void 0&&i===`pnpm`&&(r=await ci(),r===void 0))&&!(!ii(Er,n)||typeof r!=`boolean`))return{projectName:t,template:n,install:r,selectedPackageManager:void 0,preferredPackageManager:i}}const ui={default:{source:`github:mugnavo/tanstarter`,homeUrl:`https://github.com/mugnavo/tanstarter`},monorepo:{source:`github:mugnavo/tanstarter-plus`,homeUrl:`https://github.com/mugnavo/tanstarter-plus`}};function di(e){return ui[e]}function fi(e,t){if(!t)return"This project was scaffolded with [`create-mugnavo`](https://github.com/mugnavo/create-mugnavo).";let n=di(e);return`This project was scaffolded with \`create-mugnavo\` from commit [\`${t.slice(0,7)}\`](${`${n.homeUrl}/tree/${t}`}). See the [template changelog](${`${n.homeUrl}/compare/${t}...main`}) for newer changes.`}function pi(e,t,n){if(!n)return!1;let r=e.findIndex(e=>e.trim()===`## Issue watchlist`);if(r===-1)return!1;let i=e.findIndex((e,t)=>t>r&&e.startsWith(`## `)),a=i===-1?e.length:i,o=`${di(t).homeUrl}/compare/${n}...main`;if(e.slice(r+1,a).some(e=>e.includes(o)))return!1;let s=r+1;for(;s<a&&e[s]?.trim()===``;)s+=1;return e.splice(s,0,`- [Template changelog](${o}) - Track template updates since this project was created.`),!0}function mi(e,t){return t===`.`?b(w(e))||`app`:t}async function hi(e){await O(C(e,`LICENSE`),{force:!0})}async function gi(e,t){if(t==="default"){await te(C(e,`.env.example`),C(e,`.env`),f.COPYFILE_EXCL);return}if(t===`monorepo`){await te(C(e,`apps`,`web`,`.env.example`),C(e,`apps`,`web`,`.env`),f.COPYFILE_EXCL);return}}async function _i(e,t){let n=C(e,`package.json`),r=JSON.parse(await E(n,`utf8`));r.name=mi(e,t),await k(n,`${JSON.stringify(r,null,2)}\n`)}async function vi(e,t,n,r){let i=C(e,`README.md`),a=mi(e,n),o=await E(i,`utf8`),s=o.includes(`\r
|
|
86
80
|
`)?`\r
|
|
87
81
|
`:`
|
|
88
|
-
`,c=o.split(/\r?\n/),l=c.findIndex(e=>e.startsWith(`# `));l===-1?c.length>0&&(c[0]=`# ${a}`):c[l]=`# ${a}`,
|
|
82
|
+
`,c=o.split(/\r?\n/),l=c.findIndex(e=>e.startsWith(`# `));l===-1?c.length>0&&(c[0]=`# ${a}`):c[l]=`# ${a}`,yi(c,[{marker:`<!-- scaffold:description -->`,replacementContent:fi(t,r),skipEmptyLinesAfterMarker:!0}]),pi(c,t,r);let u=c.join(s);u!==o&&await k(i,u)}function yi(e,t){let n=!1;for(let{marker:r,replacementContent:i,skipEmptyLinesAfterMarker:a}of t){let t=e.findIndex(e=>e.trim()===r);if(t===-1)continue;let o=t+1;if(a)for(;e[o]!==void 0&&e[o]?.trim()===``;)o+=1;let s=e[o];if(s===void 0){e.splice(t,1),n=!0;continue}let c=`${s.match(/^\s*/)?.[0]??``}${i}`;e.splice(t,o-t+1,c),n=!0}return n}async function bi(e,t){let n=await E(e,`utf8`),r=n.includes(`\r
|
|
89
83
|
`)?`\r
|
|
90
84
|
`:`
|
|
91
|
-
`,i=n.split(/\r?\n/);
|
|
92
|
-
`)}
|
|
85
|
+
`,i=n.split(/\r?\n/);yi(i,t)&&await k(e,i.join(r))}async function xi(e,t,n){let r=mi(e,n);await bi(t==="default"?C(e,`src`,`routes`,`__root.tsx`):C(e,`apps`,`web`,`src`,`routes`,`__root.tsx`),[{marker:`// scaffold:title`,replacementContent:`title: ${JSON.stringify(r)},`},{marker:`// scaffold:description`,replacementContent:`content: "A TanStack Start project scaffolded with create-mugnavo.",`}])}async function Si(e,t,n,r){await Promise.allSettled([hi(e),gi(e,t),_i(e,n),vi(e,t,n,r),xi(e,t,n)])}function Ci(e){return new URL(e).pathname.replace(/^\/|\/$/g,``)}async function wi(e){try{let t=Ci(e.homeUrl),n=await fetch(`https://api.github.com/repos/${t}/commits/main`,{headers:{accept:`application/vnd.github+json`,"user-agent":`create-mugnavo`},signal:AbortSignal.timeout(5e3)});if(!n.ok)throw Error(`GitHub API request failed with status ${n.status}`);let r=await n.json();if(!r.sha)throw Error(`GitHub API response did not include commit metadata`);return r.sha}catch{return}}function Ti(e,t,n,r){let i=[];return e!==`.`&&i.push(`cd ${e}`),t||i.push(`${n} install${n===`npm`?` --legacy-peer-deps`:``}`),i.push(r,``,`See README.md for next steps`),i.join(`
|
|
86
|
+
`)}on(Jt({meta:{name:`create-mugnavo`,version:`0.5.1`,description:`Create a project using Mugnavo templates.`},args:Dr,async run({args:e}){let t=await li(e);if(!t)return;let{projectName:n,template:r,install:i,selectedPackageManager:a,preferredPackageManager:o}=t,s=Ct();try{let e=di(r),t=wi(e);s.start(`Cloning project...`);let{dir:c,source:l}=await wr(e.source,{dir:n,force:!0,forceClean:!0});await Si(c,r,n,await t);let u=a||o;s.stop(`Project cloned from ${l}`),await Qr(c),i&&(await $r(c,u)||(i=!1)),xt(`${Ti(n,i,u,ei(u))}\n${e.homeUrl}`,`Next steps`),vt(`All set. Happy coding! 🚀`)}catch(e){s.stop(),vt(`Failed to download template. Please try again later.`),console.error(e);return}}}));export{un as t};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{t as e}from"./rolldown-runtime-Dh0vTgs_.mjs";import t from"node:fs";import n,{basename as r,join as i,posix as a,win32 as o}from"node:path";import s from"node:fs/promises";import c from"node:stream";import l,{EventEmitter as u}from"events";import d from"fs";import{EventEmitter as f}from"node:events";import{StringDecoder as ee}from"node:string_decoder";import p,{dirname as m,parse as te}from"path";import ne from"assert";import{Buffer as re}from"buffer";import*as ie from"zlib";import ae from"zlib";import oe from"node:assert";import{randomBytes as se}from"node:crypto";var ce=e({Header:()=>I,Pack:()=>ni,PackJob:()=>Ir,PackSync:()=>ri,Parser:()=>Jn,Pax:()=>hn,ReadEntry:()=>yn,Unpack:()=>_a,UnpackSync:()=>ya,WriteEntry:()=>Dr,WriteEntrySync:()=>Or,WriteEntryTar:()=>kr,c:()=>ci,create:()=>ci,extract:()=>ba,filesFilter:()=>Zn,list:()=>Qn,r:()=>Ea,replace:()=>Ea,t:()=>Qn,types:()=>Xt,x:()=>ba}),le=Object.defineProperty,ue=(e,t)=>{for(var n in t)le(e,n,{get:t[n],enumerable:!0})},de=typeof process==`object`&&process?process:{stdout:null,stderr:null},fe=e=>!!e&&typeof e==`object`&&(e instanceof Ue||e instanceof c||pe(e)||me(e)),pe=e=>!!e&&typeof e==`object`&&e instanceof f&&typeof e.pipe==`function`&&e.pipe!==c.Writable.prototype.pipe,me=e=>!!e&&typeof e==`object`&&e instanceof f&&typeof e.write==`function`&&typeof e.end==`function`,h=Symbol(`EOF`),g=Symbol(`maybeEmitEnd`),_=Symbol(`emittedEnd`),he=Symbol(`emittingEnd`),ge=Symbol(`emittedError`),_e=Symbol(`closed`),ve=Symbol(`read`),ye=Symbol(`flush`),be=Symbol(`flushChunk`),v=Symbol(`encoding`),xe=Symbol(`decoder`),y=Symbol(`flowing`),Se=Symbol(`paused`),Ce=Symbol(`resume`),b=Symbol(`buffer`),x=Symbol(`pipes`),S=Symbol(`bufferLength`),we=Symbol(`bufferPush`),Te=Symbol(`bufferShift`),C=Symbol(`objectMode`),w=Symbol(`destroyed`),Ee=Symbol(`error`),De=Symbol(`emitData`),Oe=Symbol(`emitEnd`),ke=Symbol(`emitEnd2`),T=Symbol(`async`),Ae=Symbol(`abort`),je=Symbol(`aborted`),Me=Symbol(`signal`),Ne=Symbol(`dataListeners`),E=Symbol(`discarded`),Pe=e=>Promise.resolve().then(e),Fe=e=>e(),Ie=e=>e===`end`||e===`finish`||e===`prefinish`,Le=e=>e instanceof ArrayBuffer||!!e&&typeof e==`object`&&e.constructor&&e.constructor.name===`ArrayBuffer`&&e.byteLength>=0,Re=e=>!Buffer.isBuffer(e)&&ArrayBuffer.isView(e),ze=class{src;dest;opts;ondrain;constructor(e,t,n){this.src=e,this.dest=t,this.opts=n,this.ondrain=()=>e[Ce](),this.dest.on(`drain`,this.ondrain)}unpipe(){this.dest.removeListener(`drain`,this.ondrain)}proxyErrors(e){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},Be=class extends ze{unpipe(){this.src.removeListener(`error`,this.proxyErrors),super.unpipe()}constructor(e,t,n){super(e,t,n),this.proxyErrors=e=>this.dest.emit(`error`,e),e.on(`error`,this.proxyErrors)}},Ve=e=>!!e.objectMode,He=e=>!e.objectMode&&!!e.encoding&&e.encoding!==`buffer`,Ue=class extends f{[y]=!1;[Se]=!1;[x]=[];[b]=[];[C];[v];[T];[xe];[h]=!1;[_]=!1;[he]=!1;[_e]=!1;[ge]=null;[S]=0;[w]=!1;[Me];[je]=!1;[Ne]=0;[E]=!1;writable=!0;readable=!0;constructor(...e){let t=e[0]||{};if(super(),t.objectMode&&typeof t.encoding==`string`)throw TypeError(`Encoding and objectMode may not be used together`);Ve(t)?(this[C]=!0,this[v]=null):He(t)?(this[v]=t.encoding,this[C]=!1):(this[C]=!1,this[v]=null),this[T]=!!t.async,this[xe]=this[v]?new ee(this[v]):null,t&&t.debugExposeBuffer===!0&&Object.defineProperty(this,`buffer`,{get:()=>this[b]}),t&&t.debugExposePipes===!0&&Object.defineProperty(this,`pipes`,{get:()=>this[x]});let{signal:n}=t;n&&(this[Me]=n,n.aborted?this[Ae]():n.addEventListener(`abort`,()=>this[Ae]()))}get bufferLength(){return this[S]}get encoding(){return this[v]}set encoding(e){throw Error(`Encoding must be set at instantiation time`)}setEncoding(e){throw Error(`Encoding must be set at instantiation time`)}get objectMode(){return this[C]}set objectMode(e){throw Error(`objectMode must be set at instantiation time`)}get async(){return this[T]}set async(e){this[T]=this[T]||!!e}[Ae](){this[je]=!0,this.emit(`abort`,this[Me]?.reason),this.destroy(this[Me]?.reason)}get aborted(){return this[je]}set aborted(e){}write(e,t,n){if(this[je])return!1;if(this[h])throw Error(`write after end`);if(this[w])return this.emit(`error`,Object.assign(Error(`Cannot call write after a stream was destroyed`),{code:`ERR_STREAM_DESTROYED`})),!0;typeof t==`function`&&(n=t,t=`utf8`),t||=`utf8`;let r=this[T]?Pe:Fe;if(!this[C]&&!Buffer.isBuffer(e)){if(Re(e))e=Buffer.from(e.buffer,e.byteOffset,e.byteLength);else if(Le(e))e=Buffer.from(e);else if(typeof e!=`string`)throw Error(`Non-contiguous data written to non-objectMode stream`)}return this[C]?(this[y]&&this[S]!==0&&this[ye](!0),this[y]?this.emit(`data`,e):this[we](e),this[S]!==0&&this.emit(`readable`),n&&r(n),this[y]):e.length?(typeof e==`string`&&!(t===this[v]&&!this[xe]?.lastNeed)&&(e=Buffer.from(e,t)),Buffer.isBuffer(e)&&this[v]&&(e=this[xe].write(e)),this[y]&&this[S]!==0&&this[ye](!0),this[y]?this.emit(`data`,e):this[we](e),this[S]!==0&&this.emit(`readable`),n&&r(n),this[y]):(this[S]!==0&&this.emit(`readable`),n&&r(n),this[y])}read(e){if(this[w])return null;if(this[E]=!1,this[S]===0||e===0||e&&e>this[S])return this[g](),null;this[C]&&(e=null),this[b].length>1&&!this[C]&&(this[b]=[this[v]?this[b].join(``):Buffer.concat(this[b],this[S])]);let t=this[ve](e||null,this[b][0]);return this[g](),t}[ve](e,t){if(this[C])this[Te]();else{let n=t;e===n.length||e===null?this[Te]():typeof n==`string`?(this[b][0]=n.slice(e),t=n.slice(0,e),this[S]-=e):(this[b][0]=n.subarray(e),t=n.subarray(0,e),this[S]-=e)}return this.emit(`data`,t),!this[b].length&&!this[h]&&this.emit(`drain`),t}end(e,t,n){return typeof e==`function`&&(n=e,e=void 0),typeof t==`function`&&(n=t,t=`utf8`),e!==void 0&&this.write(e,t),n&&this.once(`end`,n),this[h]=!0,this.writable=!1,(this[y]||!this[Se])&&this[g](),this}[Ce](){this[w]||(!this[Ne]&&!this[x].length&&(this[E]=!0),this[Se]=!1,this[y]=!0,this.emit(`resume`),this[b].length?this[ye]():this[h]?this[g]():this.emit(`drain`))}resume(){return this[Ce]()}pause(){this[y]=!1,this[Se]=!0,this[E]=!1}get destroyed(){return this[w]}get flowing(){return this[y]}get paused(){return this[Se]}[we](e){this[C]?this[S]+=1:this[S]+=e.length,this[b].push(e)}[Te](){return this[C]?--this[S]:this[S]-=this[b][0].length,this[b].shift()}[ye](e=!1){do;while(this[be](this[Te]())&&this[b].length);!e&&!this[b].length&&!this[h]&&this.emit(`drain`)}[be](e){return this.emit(`data`,e),this[y]}pipe(e,t){if(this[w])return e;this[E]=!1;let n=this[_];return t||={},e===de.stdout||e===de.stderr?t.end=!1:t.end=t.end!==!1,t.proxyErrors=!!t.proxyErrors,n?t.end&&e.end():(this[x].push(t.proxyErrors?new Be(this,e,t):new ze(this,e,t)),this[T]?Pe(()=>this[Ce]()):this[Ce]()),e}unpipe(e){let t=this[x].find(t=>t.dest===e);t&&(this[x].length===1?(this[y]&&this[Ne]===0&&(this[y]=!1),this[x]=[]):this[x].splice(this[x].indexOf(t),1),t.unpipe())}addListener(e,t){return this.on(e,t)}on(e,t){let n=super.on(e,t);if(e===`data`)this[E]=!1,this[Ne]++,!this[x].length&&!this[y]&&this[Ce]();else if(e===`readable`&&this[S]!==0)super.emit(`readable`);else if(Ie(e)&&this[_])super.emit(e),this.removeAllListeners(e);else if(e===`error`&&this[ge]){let e=t;this[T]?Pe(()=>e.call(this,this[ge])):e.call(this,this[ge])}return n}removeListener(e,t){return this.off(e,t)}off(e,t){let n=super.off(e,t);return e===`data`&&(this[Ne]=this.listeners(`data`).length,this[Ne]===0&&!this[E]&&!this[x].length&&(this[y]=!1)),n}removeAllListeners(e){let t=super.removeAllListeners(e);return(e===`data`||e===void 0)&&(this[Ne]=0,!this[E]&&!this[x].length&&(this[y]=!1)),t}get emittedEnd(){return this[_]}[g](){!this[he]&&!this[_]&&!this[w]&&this[b].length===0&&this[h]&&(this[he]=!0,this.emit(`end`),this.emit(`prefinish`),this.emit(`finish`),this[_e]&&this.emit(`close`),this[he]=!1)}emit(e,...t){let n=t[0];if(e!==`error`&&e!==`close`&&e!==w&&this[w])return!1;if(e===`data`)return!this[C]&&!n?!1:this[T]?(Pe(()=>this[De](n)),!0):this[De](n);if(e===`end`)return this[Oe]();if(e===`close`){if(this[_e]=!0,!this[_]&&!this[w])return!1;let e=super.emit(`close`);return this.removeAllListeners(`close`),e}else if(e===`error`){this[ge]=n,super.emit(Ee,n);let e=!this[Me]||this.listeners(`error`).length?super.emit(`error`,n):!1;return this[g](),e}else if(e===`resume`){let e=super.emit(`resume`);return this[g](),e}else if(e===`finish`||e===`prefinish`){let t=super.emit(e);return this.removeAllListeners(e),t}let r=super.emit(e,...t);return this[g](),r}[De](e){for(let t of this[x])t.dest.write(e)===!1&&this.pause();let t=this[E]?!1:super.emit(`data`,e);return this[g](),t}[Oe](){return this[_]?!1:(this[_]=!0,this.readable=!1,this[T]?(Pe(()=>this[ke]()),!0):this[ke]())}[ke](){if(this[xe]){let e=this[xe].end();if(e){for(let t of this[x])t.dest.write(e);this[E]||super.emit(`data`,e)}}for(let e of this[x])e.end();let e=super.emit(`end`);return this.removeAllListeners(`end`),e}async collect(){let e=Object.assign([],{dataLength:0});this[C]||(e.dataLength=0);let t=this.promise();return this.on(`data`,t=>{e.push(t),this[C]||(e.dataLength+=t.length)}),await t,e}async concat(){if(this[C])throw Error(`cannot concat in objectMode`);let e=await this.collect();return this[v]?e.join(``):Buffer.concat(e,e.dataLength)}async promise(){return new Promise((e,t)=>{this.on(w,()=>t(Error(`stream destroyed`))),this.on(`error`,e=>t(e)),this.on(`end`,()=>e())})}[Symbol.asyncIterator](){this[E]=!1;let e=!1,t=async()=>(this.pause(),e=!0,{value:void 0,done:!0});return{next:()=>{if(e)return t();let n=this.read();if(n!==null)return Promise.resolve({done:!1,value:n});if(this[h])return t();let r,i,a=e=>{this.off(`data`,o),this.off(`end`,s),this.off(w,c),t(),i(e)},o=e=>{this.off(`error`,a),this.off(`end`,s),this.off(w,c),this.pause(),r({value:e,done:!!this[h]})},s=()=>{this.off(`error`,a),this.off(`data`,o),this.off(w,c),t(),r({done:!0,value:void 0})},c=()=>a(Error(`stream destroyed`));return new Promise((e,t)=>{i=t,r=e,this.once(w,c),this.once(`error`,a),this.once(`end`,s),this.once(`data`,o)})},throw:t,return:t,[Symbol.asyncIterator](){return this},[Symbol.asyncDispose]:async()=>{}}}[Symbol.iterator](){this[E]=!1;let e=!1,t=()=>(this.pause(),this.off(Ee,t),this.off(w,t),this.off(`end`,t),e=!0,{done:!0,value:void 0});return this.once(`end`,t),this.once(Ee,t),this.once(w,t),{next:()=>{if(e)return t();let n=this.read();return n===null?t():{done:!1,value:n}},throw:t,return:t,[Symbol.iterator](){return this},[Symbol.dispose]:()=>{}}}destroy(e){if(this[w])return e?this.emit(`error`,e):this.emit(w),this;this[w]=!0,this[E]=!0,this[b].length=0,this[S]=0;let t=this;return typeof t.close==`function`&&!this[_e]&&t.close(),e?this.emit(`error`,e):this.emit(w),this}static get isStream(){return fe}},We=d.writev,D=Symbol(`_autoClose`),O=Symbol(`_close`),Ge=Symbol(`_ended`),k=Symbol(`_fd`),Ke=Symbol(`_finished`),A=Symbol(`_flags`),qe=Symbol(`_flush`),Je=Symbol(`_handleChunk`),Ye=Symbol(`_makeBuf`),Xe=Symbol(`_mode`),Ze=Symbol(`_needDrain`),Qe=Symbol(`_onerror`),$e=Symbol(`_onopen`),et=Symbol(`_onread`),tt=Symbol(`_onwrite`),j=Symbol(`_open`),M=Symbol(`_path`),nt=Symbol(`_pos`),N=Symbol(`_queue`),rt=Symbol(`_read`),it=Symbol(`_readSize`),P=Symbol(`_reading`),at=Symbol(`_remain`),ot=Symbol(`_size`),st=Symbol(`_write`),ct=Symbol(`_writing`),lt=Symbol(`_defaultFlag`),ut=Symbol(`_errored`),dt=class extends Ue{[ut]=!1;[k];[M];[it];[P]=!1;[ot];[at];[D];constructor(e,t){if(t||={},super(t),this.readable=!0,this.writable=!1,typeof e!=`string`)throw TypeError(`path must be a string`);this[ut]=!1,this[k]=typeof t.fd==`number`?t.fd:void 0,this[M]=e,this[it]=t.readSize||16*1024*1024,this[P]=!1,this[ot]=typeof t.size==`number`?t.size:1/0,this[at]=this[ot],this[D]=typeof t.autoClose==`boolean`?t.autoClose:!0,typeof this[k]==`number`?this[rt]():this[j]()}get fd(){return this[k]}get path(){return this[M]}write(){throw TypeError(`this is a readable stream`)}end(){throw TypeError(`this is a readable stream`)}[j](){d.open(this[M],`r`,(e,t)=>this[$e](e,t))}[$e](e,t){e?this[Qe](e):(this[k]=t,this.emit(`open`,t),this[rt]())}[Ye](){return Buffer.allocUnsafe(Math.min(this[it],this[at]))}[rt](){if(!this[P]){this[P]=!0;let e=this[Ye]();if(e.length===0)return process.nextTick(()=>this[et](null,0,e));d.read(this[k],e,0,e.length,null,(e,t,n)=>this[et](e,t,n))}}[et](e,t,n){this[P]=!1,e?this[Qe](e):this[Je](t,n)&&this[rt]()}[O](){if(this[D]&&typeof this[k]==`number`){let e=this[k];this[k]=void 0,d.close(e,e=>e?this.emit(`error`,e):this.emit(`close`))}}[Qe](e){this[P]=!0,this[O](),this.emit(`error`,e)}[Je](e,t){let n=!1;return this[at]-=e,e>0&&(n=super.write(e<t.length?t.subarray(0,e):t)),(e===0||this[at]<=0)&&(n=!1,this[O](),super.end()),n}emit(e,...t){switch(e){case`prefinish`:case`finish`:return!1;case`drain`:return typeof this[k]==`number`&&this[rt](),!1;case`error`:return this[ut]?!1:(this[ut]=!0,super.emit(e,...t));default:return super.emit(e,...t)}}},ft=class extends dt{[j](){let e=!0;try{this[$e](null,d.openSync(this[M],`r`)),e=!1}finally{e&&this[O]()}}[rt](){let e=!0;try{if(!this[P]){this[P]=!0;do{let e=this[Ye](),t=e.length===0?0:d.readSync(this[k],e,0,e.length,null);if(!this[Je](t,e))break}while(!0);this[P]=!1}e=!1}finally{e&&this[O]()}}[O](){if(this[D]&&typeof this[k]==`number`){let e=this[k];this[k]=void 0,d.closeSync(e),this.emit(`close`)}}},pt=class extends l{readable=!1;writable=!0;[ut]=!1;[ct]=!1;[Ge]=!1;[N]=[];[Ze]=!1;[M];[Xe];[D];[k];[lt];[A];[Ke]=!1;[nt];constructor(e,t){t||={},super(t),this[M]=e,this[k]=typeof t.fd==`number`?t.fd:void 0,this[Xe]=t.mode===void 0?438:t.mode,this[nt]=typeof t.start==`number`?t.start:void 0,this[D]=typeof t.autoClose==`boolean`?t.autoClose:!0;let n=this[nt]===void 0?`w`:`r+`;this[lt]=t.flags===void 0,this[A]=t.flags===void 0?n:t.flags,this[k]===void 0&&this[j]()}emit(e,...t){if(e===`error`){if(this[ut])return!1;this[ut]=!0}return super.emit(e,...t)}get fd(){return this[k]}get path(){return this[M]}[Qe](e){this[O](),this[ct]=!0,this.emit(`error`,e)}[j](){d.open(this[M],this[A],this[Xe],(e,t)=>this[$e](e,t))}[$e](e,t){this[lt]&&this[A]===`r+`&&e&&e.code===`ENOENT`?(this[A]=`w`,this[j]()):e?this[Qe](e):(this[k]=t,this.emit(`open`,t),this[ct]||this[qe]())}end(e,t){return e&&this.write(e,t),this[Ge]=!0,!this[ct]&&!this[N].length&&typeof this[k]==`number`&&this[tt](null,0),this}write(e,t){return typeof e==`string`&&(e=Buffer.from(e,t)),this[Ge]?(this.emit(`error`,Error(`write() after end()`)),!1):this[k]===void 0||this[ct]||this[N].length?(this[N].push(e),this[Ze]=!0,!1):(this[ct]=!0,this[st](e),!0)}[st](e){d.write(this[k],e,0,e.length,this[nt],(e,t)=>this[tt](e,t))}[tt](e,t){e?this[Qe](e):(this[nt]!==void 0&&typeof t==`number`&&(this[nt]+=t),this[N].length?this[qe]():(this[ct]=!1,this[Ge]&&!this[Ke]?(this[Ke]=!0,this[O](),this.emit(`finish`)):this[Ze]&&(this[Ze]=!1,this.emit(`drain`))))}[qe](){if(this[N].length===0)this[Ge]&&this[tt](null,0);else if(this[N].length===1)this[st](this[N].pop());else{let e=this[N];this[N]=[],We(this[k],e,this[nt],(e,t)=>this[tt](e,t))}}[O](){if(this[D]&&typeof this[k]==`number`){let e=this[k];this[k]=void 0,d.close(e,e=>e?this.emit(`error`,e):this.emit(`close`))}}},mt=class extends pt{[j](){let e;if(this[lt]&&this[A]===`r+`)try{e=d.openSync(this[M],this[A],this[Xe])}catch(e){if(e?.code===`ENOENT`)return this[A]=`w`,this[j]();throw e}else e=d.openSync(this[M],this[A],this[Xe]);this[$e](null,e)}[O](){if(this[D]&&typeof this[k]==`number`){let e=this[k];this[k]=void 0,d.closeSync(e),this.emit(`close`)}}[st](e){let t=!0;try{this[tt](null,d.writeSync(this[k],e,0,e.length,this[nt])),t=!1}finally{if(t)try{this[O]()}catch{}}}},ht=new Map([[`C`,`cwd`],[`f`,`file`],[`z`,`gzip`],[`P`,`preservePaths`],[`U`,`unlink`],[`strip-components`,`strip`],[`stripComponents`,`strip`],[`keep-newer`,`newer`],[`keepNewer`,`newer`],[`keep-newer-files`,`newer`],[`keepNewerFiles`,`newer`],[`k`,`keep`],[`keep-existing`,`keep`],[`keepExisting`,`keep`],[`m`,`noMtime`],[`no-mtime`,`noMtime`],[`p`,`preserveOwner`],[`L`,`follow`],[`h`,`follow`],[`onentry`,`onReadEntry`]]),gt=e=>!!e.sync&&!!e.file,_t=e=>!e.sync&&!!e.file,vt=e=>!!e.sync&&!e.file,yt=e=>!e.sync&&!e.file,bt=e=>!!e.file,xt=e=>ht.get(e)||e,St=(e={})=>{if(!e)return{};let t={};for(let[n,r]of Object.entries(e)){let e=xt(n);t[e]=r}return t.chmod===void 0&&t.noChmod===!1&&(t.chmod=!0),delete t.noChmod,t},Ct=(e,t,n,r,i)=>Object.assign((a=[],o,s)=>{Array.isArray(a)&&(o=a,a={}),typeof o==`function`&&(s=o,o=void 0),o=o?Array.from(o):[];let c=St(a);if(i?.(c,o),gt(c)){if(typeof s==`function`)throw TypeError(`callback not supported for sync tar functions`);return e(c,o)}else if(_t(c)){let e=t(c,o);return s?e.then(()=>s(),s):e}else if(vt(c)){if(typeof s==`function`)throw TypeError(`callback not supported for sync tar functions`);return n(c,o)}else if(yt(c)){if(typeof s==`function`)throw TypeError(`callback only supported with file option`);return r(c,o)}throw Error(`impossible options??`)},{syncFile:e,asyncFile:t,syncNoFile:n,asyncNoFile:r,validate:i}),wt=ae.constants||{ZLIB_VERNUM:4736},F=Object.freeze(Object.assign(Object.create(null),{Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_VERSION_ERROR:-6,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,DEFLATE:1,INFLATE:2,GZIP:3,GUNZIP:4,DEFLATERAW:5,INFLATERAW:6,UNZIP:7,BROTLI_DECODE:8,BROTLI_ENCODE:9,Z_MIN_WINDOWBITS:8,Z_MAX_WINDOWBITS:15,Z_DEFAULT_WINDOWBITS:15,Z_MIN_CHUNK:64,Z_MAX_CHUNK:1/0,Z_DEFAULT_CHUNK:16384,Z_MIN_MEMLEVEL:1,Z_MAX_MEMLEVEL:9,Z_DEFAULT_MEMLEVEL:8,Z_MIN_LEVEL:-1,Z_MAX_LEVEL:9,Z_DEFAULT_LEVEL:-1,BROTLI_OPERATION_PROCESS:0,BROTLI_OPERATION_FLUSH:1,BROTLI_OPERATION_FINISH:2,BROTLI_OPERATION_EMIT_METADATA:3,BROTLI_MODE_GENERIC:0,BROTLI_MODE_TEXT:1,BROTLI_MODE_FONT:2,BROTLI_DEFAULT_MODE:0,BROTLI_MIN_QUALITY:0,BROTLI_MAX_QUALITY:11,BROTLI_DEFAULT_QUALITY:11,BROTLI_MIN_WINDOW_BITS:10,BROTLI_MAX_WINDOW_BITS:24,BROTLI_LARGE_MAX_WINDOW_BITS:30,BROTLI_DEFAULT_WINDOW:22,BROTLI_MIN_INPUT_BLOCK_BITS:16,BROTLI_MAX_INPUT_BLOCK_BITS:24,BROTLI_PARAM_MODE:0,BROTLI_PARAM_QUALITY:1,BROTLI_PARAM_LGWIN:2,BROTLI_PARAM_LGBLOCK:3,BROTLI_PARAM_DISABLE_LITERAL_CONTEXT_MODELING:4,BROTLI_PARAM_SIZE_HINT:5,BROTLI_PARAM_LARGE_WINDOW:6,BROTLI_PARAM_NPOSTFIX:7,BROTLI_PARAM_NDIRECT:8,BROTLI_DECODER_RESULT_ERROR:0,BROTLI_DECODER_RESULT_SUCCESS:1,BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT:2,BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT:3,BROTLI_DECODER_PARAM_DISABLE_RING_BUFFER_REALLOCATION:0,BROTLI_DECODER_PARAM_LARGE_WINDOW:1,BROTLI_DECODER_NO_ERROR:0,BROTLI_DECODER_SUCCESS:1,BROTLI_DECODER_NEEDS_MORE_INPUT:2,BROTLI_DECODER_NEEDS_MORE_OUTPUT:3,BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_NIBBLE:-1,BROTLI_DECODER_ERROR_FORMAT_RESERVED:-2,BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_META_NIBBLE:-3,BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_ALPHABET:-4,BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_SAME:-5,BROTLI_DECODER_ERROR_FORMAT_CL_SPACE:-6,BROTLI_DECODER_ERROR_FORMAT_HUFFMAN_SPACE:-7,BROTLI_DECODER_ERROR_FORMAT_CONTEXT_MAP_REPEAT:-8,BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_1:-9,BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_2:-10,BROTLI_DECODER_ERROR_FORMAT_TRANSFORM:-11,BROTLI_DECODER_ERROR_FORMAT_DICTIONARY:-12,BROTLI_DECODER_ERROR_FORMAT_WINDOW_BITS:-13,BROTLI_DECODER_ERROR_FORMAT_PADDING_1:-14,BROTLI_DECODER_ERROR_FORMAT_PADDING_2:-15,BROTLI_DECODER_ERROR_FORMAT_DISTANCE:-16,BROTLI_DECODER_ERROR_DICTIONARY_NOT_SET:-19,BROTLI_DECODER_ERROR_INVALID_ARGUMENTS:-20,BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MODES:-21,BROTLI_DECODER_ERROR_ALLOC_TREE_GROUPS:-22,BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MAP:-25,BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_1:-26,BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_2:-27,BROTLI_DECODER_ERROR_ALLOC_BLOCK_TYPE_TREES:-30,BROTLI_DECODER_ERROR_UNREACHABLE:-31},wt)),Tt=re.concat,Et=Object.getOwnPropertyDescriptor(re,`concat`),Dt=e=>e,Ot=Et?.writable===!0||Et?.set!==void 0?e=>{re.concat=e?Dt:Tt}:e=>{},kt=Symbol(`_superWrite`),At=class extends Error{code;errno;constructor(e,t){super(`zlib: `+e.message,{cause:e}),this.code=e.code,this.errno=e.errno,this.code||=`ZLIB_ERROR`,this.message=`zlib: `+e.message,Error.captureStackTrace(this,t??this.constructor)}get name(){return`ZlibError`}},jt=Symbol(`flushFlag`),Mt=class extends Ue{#e=!1;#t=!1;#n;#r;#i;#a;#o;get sawError(){return this.#e}get handle(){return this.#a}get flushFlag(){return this.#n}constructor(e,t){if(!e||typeof e!=`object`)throw TypeError(`invalid options for ZlibBase constructor`);if(super(e),this.#n=e.flush??0,this.#r=e.finishFlush??0,this.#i=e.fullFlushFlag??0,typeof ie[t]!=`function`)throw TypeError(`Compression method not supported: `+t);try{this.#a=new ie[t](e)}catch(e){throw new At(e,this.constructor)}this.#o=e=>{this.#e||(this.#e=!0,this.close(),this.emit(`error`,e))},this.#a?.on(`error`,e=>this.#o(new At(e))),this.once(`end`,()=>this.close)}close(){this.#a&&(this.#a.close(),this.#a=void 0,this.emit(`close`))}reset(){if(!this.#e)return ne(this.#a,`zlib binding closed`),this.#a.reset?.()}flush(e){this.ended||(typeof e!=`number`&&(e=this.#i),this.write(Object.assign(re.alloc(0),{[jt]:e})))}end(e,t,n){return typeof e==`function`&&(n=e,t=void 0,e=void 0),typeof t==`function`&&(n=t,t=void 0),e&&(t?this.write(e,t):this.write(e)),this.flush(this.#r),this.#t=!0,super.end(n)}get ended(){return this.#t}[kt](e){return super.write(e)}write(e,t,n){if(typeof t==`function`&&(n=t,t=`utf8`),typeof e==`string`&&(e=re.from(e,t)),this.#e)return;ne(this.#a,`zlib binding closed`);let r=this.#a._handle,i=r.close;r.close=()=>{};let a=this.#a.close;this.#a.close=()=>{},Ot(!0);let o;try{let t=typeof e[jt]==`number`?e[jt]:this.#n;o=this.#a._processChunk(e,t),Ot(!1)}catch(e){Ot(!1),this.#o(new At(e,this.write))}finally{this.#a&&(this.#a._handle=r,r.close=i,this.#a.close=a,this.#a.removeAllListeners(`error`))}this.#a&&this.#a.on(`error`,e=>this.#o(new At(e,this.write)));let s;if(o)if(Array.isArray(o)&&o.length>0){let e=o[0];s=this[kt](re.from(e));for(let e=1;e<o.length;e++)s=this[kt](o[e])}else s=this[kt](re.from(o));return n&&n(),s}},Nt=class extends Mt{#e;#t;constructor(e,t){e||={},e.flush=e.flush||F.Z_NO_FLUSH,e.finishFlush=e.finishFlush||F.Z_FINISH,e.fullFlushFlag=F.Z_FULL_FLUSH,super(e,t),this.#e=e.level,this.#t=e.strategy}params(e,t){if(!this.sawError){if(!this.handle)throw Error(`cannot switch params when binding is closed`);if(!this.handle.params)throw Error(`not supported in this implementation`);if(this.#e!==e||this.#t!==t){this.flush(F.Z_SYNC_FLUSH),ne(this.handle,`zlib binding closed`);let n=this.handle.flush;this.handle.flush=(e,t)=>{typeof e==`function`&&(t=e,e=this.flushFlag),this.flush(e),t?.()};try{this.handle.params(e,t)}finally{this.handle.flush=n}this.handle&&(this.#e=e,this.#t=t)}}}},Pt=class extends Nt{#e;constructor(e){super(e,`Gzip`),this.#e=e&&!!e.portable}[kt](e){return this.#e?(this.#e=!1,e[9]=255,super[kt](e)):super[kt](e)}},Ft=class extends Nt{constructor(e){super(e,`Unzip`)}},It=class extends Mt{constructor(e,t){e||={},e.flush=e.flush||F.BROTLI_OPERATION_PROCESS,e.finishFlush=e.finishFlush||F.BROTLI_OPERATION_FINISH,e.fullFlushFlag=F.BROTLI_OPERATION_FLUSH,super(e,t)}},Lt=class extends It{constructor(e){super(e,`BrotliCompress`)}},Rt=class extends It{constructor(e){super(e,`BrotliDecompress`)}},zt=class extends Mt{constructor(e,t){e||={},e.flush=e.flush||F.ZSTD_e_continue,e.finishFlush=e.finishFlush||F.ZSTD_e_end,e.fullFlushFlag=F.ZSTD_e_flush,super(e,t)}},Bt=class extends zt{constructor(e){super(e,`ZstdCompress`)}},Vt=class extends zt{constructor(e){super(e,`ZstdDecompress`)}},Ht=(e,t)=>{if(Number.isSafeInteger(e))e<0?Wt(e,t):Ut(e,t);else throw Error(`cannot encode number outside of javascript safe integer range`);return t},Ut=(e,t)=>{t[0]=128;for(var n=t.length;n>1;n--)t[n-1]=e&255,e=Math.floor(e/256)},Wt=(e,t)=>{t[0]=255;var n=!1;e*=-1;for(var r=t.length;r>1;r--){var i=e&255;e=Math.floor(e/256),n?t[r-1]=Jt(i):i===0?t[r-1]=0:(n=!0,t[r-1]=Yt(i))}},Gt=e=>{let t=e[0],n=t===128?qt(e.subarray(1,e.length)):t===255?Kt(e):null;if(n===null)throw Error(`invalid base256 encoding`);if(!Number.isSafeInteger(n))throw Error(`parsed number outside of javascript safe integer range`);return n},Kt=e=>{for(var t=e.length,n=0,r=!1,i=t-1;i>-1;i--){var a=Number(e[i]),o;r?o=Jt(a):a===0?o=a:(r=!0,o=Yt(a)),o!==0&&(n-=o*256**(t-i-1))}return n},qt=e=>{for(var t=e.length,n=0,r=t-1;r>-1;r--){var i=Number(e[r]);i!==0&&(n+=i*256**(t-r-1))}return n},Jt=e=>(255^e)&255,Yt=e=>(255^e)+1&255,Xt={};ue(Xt,{code:()=>en,isCode:()=>Zt,isName:()=>Qt,name:()=>$t});var Zt=e=>$t.has(e),Qt=e=>en.has(e),$t=new Map([[`0`,`File`],[``,`OldFile`],[`1`,`Link`],[`2`,`SymbolicLink`],[`3`,`CharacterDevice`],[`4`,`BlockDevice`],[`5`,`Directory`],[`6`,`FIFO`],[`7`,`ContiguousFile`],[`g`,`GlobalExtendedHeader`],[`x`,`ExtendedHeader`],[`A`,`SolarisACL`],[`D`,`GNUDumpDir`],[`I`,`Inode`],[`K`,`NextFileHasLongLinkpath`],[`L`,`NextFileHasLongPath`],[`M`,`ContinuationFile`],[`N`,`OldGnuLongPath`],[`S`,`SparseFile`],[`V`,`TapeVolumeHeader`],[`X`,`OldExtendedHeader`]]),en=new Map(Array.from($t).map(e=>[e[1],e[0]])),I=class{cksumValid=!1;needPax=!1;nullBlock=!1;block;path;mode;uid;gid;size;cksum;#e=`Unsupported`;linkpath;uname;gname;devmaj=0;devmin=0;atime;ctime;mtime;charset;comment;constructor(e,t=0,n,r){Buffer.isBuffer(e)?this.decode(e,t||0,n,r):e&&this.#t(e)}decode(e,t,n,r){if(t||=0,!e||!(e.length>=t+512))throw Error(`need 512 bytes for header`);this.path=n?.path??nn(e,t,100),this.mode=n?.mode??r?.mode??L(e,t+100,8),this.uid=n?.uid??r?.uid??L(e,t+108,8),this.gid=n?.gid??r?.gid??L(e,t+116,8),this.size=n?.size??r?.size??L(e,t+124,12),this.mtime=n?.mtime??r?.mtime??rn(e,t+136,12),this.cksum=L(e,t+148,12),r&&this.#t(r,!0),n&&this.#t(n);let i=nn(e,t+156,1);if(Zt(i)&&(this.#e=i||`0`),this.#e===`0`&&this.path.slice(-1)===`/`&&(this.#e=`5`),this.#e===`5`&&(this.size=0),this.linkpath=nn(e,t+157,100),e.subarray(t+257,t+265).toString()===`ustar\x0000`)if(this.uname=n?.uname??r?.uname??nn(e,t+265,32),this.gname=n?.gname??r?.gname??nn(e,t+297,32),this.devmaj=n?.devmaj??r?.devmaj??L(e,t+329,8)??0,this.devmin=n?.devmin??r?.devmin??L(e,t+337,8)??0,e[t+475]!==0)this.path=nn(e,t+345,155)+`/`+this.path;else{let i=nn(e,t+345,130);i&&(this.path=i+`/`+this.path),this.atime=n?.atime??r?.atime??rn(e,t+476,12),this.ctime=n?.ctime??r?.ctime??rn(e,t+488,12)}let a=256;for(let n=t;n<t+148;n++)a+=e[n];for(let n=t+156;n<t+512;n++)a+=e[n];this.cksumValid=a===this.cksum,this.cksum===void 0&&a===256&&(this.nullBlock=!0)}#t(e,t=!1){Object.assign(this,Object.fromEntries(Object.entries(e).filter(([e,n])=>!(n==null||e===`path`&&t||e===`linkpath`&&t||e===`global`))))}encode(e,t=0){if(e||=this.block=Buffer.alloc(512),this.#e===`Unsupported`&&(this.#e=`0`),!(e.length>=t+512))throw Error(`need 512 bytes for header`);let n=this.ctime||this.atime?130:155,r=tn(this.path||``,n),i=r[0],a=r[1];this.needPax=!!r[2],this.needPax=mn(e,t,100,i)||this.needPax,this.needPax=R(e,t+100,8,this.mode)||this.needPax,this.needPax=R(e,t+108,8,this.uid)||this.needPax,this.needPax=R(e,t+116,8,this.gid)||this.needPax,this.needPax=R(e,t+124,12,this.size)||this.needPax,this.needPax=fn(e,t+136,12,this.mtime)||this.needPax,e[t+156]=Number(this.#e.codePointAt(0)),this.needPax=mn(e,t+157,100,this.linkpath)||this.needPax,e.write(`ustar\x0000`,t+257,8),this.needPax=mn(e,t+265,32,this.uname)||this.needPax,this.needPax=mn(e,t+297,32,this.gname)||this.needPax,this.needPax=R(e,t+329,8,this.devmaj)||this.needPax,this.needPax=R(e,t+337,8,this.devmin)||this.needPax,this.needPax=mn(e,t+345,n,a)||this.needPax,e[t+475]===0?(this.needPax=mn(e,t+345,130,a)||this.needPax,this.needPax=fn(e,t+476,12,this.atime)||this.needPax,this.needPax=fn(e,t+488,12,this.ctime)||this.needPax):this.needPax=mn(e,t+345,155,a)||this.needPax;let o=256;for(let n=t;n<t+148;n++)o+=e[n];for(let n=t+156;n<t+512;n++)o+=e[n];return this.cksum=o,R(e,t+148,8,this.cksum),this.cksumValid=!0,this.needPax}get type(){return this.#e===`Unsupported`?this.#e:$t.get(this.#e)}get typeKey(){return this.#e}set type(e){let t=String(en.get(e));if(Zt(t)||t===`Unsupported`)this.#e=t;else if(Zt(e))this.#e=e;else throw TypeError(`invalid entry type: `+e)}},tn=(e,t)=>{let n=e,r=``,i,o=a.parse(e).root||`.`;if(Buffer.byteLength(n)<100)i=[n,r,!1];else{r=a.dirname(n),n=a.basename(n);do Buffer.byteLength(n)<=100&&Buffer.byteLength(r)<=t?i=[n,r,!1]:Buffer.byteLength(n)>100&&Buffer.byteLength(r)<=t?i=[n.slice(0,99),r,!0]:(n=a.join(a.basename(r),n),r=a.dirname(r));while(r!==o&&i===void 0);i||=[e.slice(0,99),``,!0]}return i},nn=(e,t,n)=>e.subarray(t,t+n).toString(`utf8`).replace(/\0.*/,``),rn=(e,t,n)=>an(L(e,t,n)),an=e=>e===void 0?void 0:new Date(e*1e3),L=(e,t,n)=>Number(e[t])&128?Gt(e.subarray(t,t+n)):sn(e,t,n),on=e=>isNaN(e)?void 0:e,sn=(e,t,n)=>on(parseInt(e.subarray(t,t+n).toString(`utf8`).replace(/\0.*$/,``).trim(),8)),cn={12:8589934591,8:2097151},R=(e,t,n,r)=>r===void 0?!1:r>cn[n]||r<0?(Ht(r,e.subarray(t,t+n)),!0):(ln(e,t,n,r),!1),ln=(e,t,n,r)=>e.write(un(r,n),t,n,`ascii`),un=(e,t)=>dn(Math.floor(e).toString(8),t),dn=(e,t)=>(e.length===t-1?e:Array(t-e.length-1).join(`0`)+e+` `)+`\0`,fn=(e,t,n,r)=>r===void 0?!1:R(e,t,n,r.getTime()/1e3),pn=Array(156).join(`\0`),mn=(e,t,n,r)=>r===void 0?!1:(e.write(r+pn,t,n,`utf8`),r.length!==Buffer.byteLength(r)||r.length>n),hn=class e{atime;mtime;ctime;charset;comment;gid;uid;gname;uname;linkpath;dev;ino;nlink;path;size;mode;global;constructor(e,t=!1){this.atime=e.atime,this.charset=e.charset,this.comment=e.comment,this.ctime=e.ctime,this.dev=e.dev,this.gid=e.gid,this.global=t,this.gname=e.gname,this.ino=e.ino,this.linkpath=e.linkpath,this.mtime=e.mtime,this.nlink=e.nlink,this.path=e.path,this.size=e.size,this.uid=e.uid,this.uname=e.uname}encode(){let e=this.encodeBody();if(e===``)return Buffer.allocUnsafe(0);let t=Buffer.byteLength(e),n=512*Math.ceil(1+t/512),i=Buffer.allocUnsafe(n);for(let e=0;e<512;e++)i[e]=0;new I({path:(`PaxHeader/`+r(this.path??``)).slice(0,99),mode:this.mode||420,uid:this.uid,gid:this.gid,size:t,mtime:this.mtime,type:this.global?`GlobalExtendedHeader`:`ExtendedHeader`,linkpath:``,uname:this.uname||``,gname:this.gname||``,devmaj:0,devmin:0,atime:this.atime,ctime:this.ctime}).encode(i),i.write(e,512,t,`utf8`);for(let e=t+512;e<i.length;e++)i[e]=0;return i}encodeBody(){return this.encodeField(`path`)+this.encodeField(`ctime`)+this.encodeField(`atime`)+this.encodeField(`dev`)+this.encodeField(`ino`)+this.encodeField(`nlink`)+this.encodeField(`charset`)+this.encodeField(`comment`)+this.encodeField(`gid`)+this.encodeField(`gname`)+this.encodeField(`linkpath`)+this.encodeField(`mtime`)+this.encodeField(`size`)+this.encodeField(`uid`)+this.encodeField(`uname`)}encodeField(e){if(this[e]===void 0)return``;let t=this[e],n=t instanceof Date?t.getTime()/1e3:t,r=` `+(e===`dev`||e===`ino`||e===`nlink`?`SCHILY.`:``)+e+`=`+n+`
|
|
2
|
+
import{t as e}from"./index.mjs";import t from"node:fs";import n,{basename as r,join as i,posix as a,win32 as o}from"node:path";import s from"node:fs/promises";import c from"node:stream";import l,{EventEmitter as u}from"events";import d from"fs";import{EventEmitter as f}from"node:events";import{StringDecoder as ee}from"node:string_decoder";import p,{dirname as m,parse as te}from"path";import ne from"assert";import{Buffer as re}from"buffer";import*as ie from"zlib";import ae from"zlib";import oe from"node:assert";import{randomBytes as se}from"node:crypto";var ce=e({Header:()=>I,Pack:()=>ni,PackJob:()=>Ir,PackSync:()=>ri,Parser:()=>Jn,Pax:()=>hn,ReadEntry:()=>yn,Unpack:()=>_a,UnpackSync:()=>ya,WriteEntry:()=>Dr,WriteEntrySync:()=>Or,WriteEntryTar:()=>kr,c:()=>ci,create:()=>ci,extract:()=>ba,filesFilter:()=>Zn,list:()=>Qn,r:()=>Ea,replace:()=>Ea,t:()=>Qn,types:()=>Xt,x:()=>ba}),le=Object.defineProperty,ue=(e,t)=>{for(var n in t)le(e,n,{get:t[n],enumerable:!0})},de=typeof process==`object`&&process?process:{stdout:null,stderr:null},fe=e=>!!e&&typeof e==`object`&&(e instanceof Ue||e instanceof c||pe(e)||me(e)),pe=e=>!!e&&typeof e==`object`&&e instanceof f&&typeof e.pipe==`function`&&e.pipe!==c.Writable.prototype.pipe,me=e=>!!e&&typeof e==`object`&&e instanceof f&&typeof e.write==`function`&&typeof e.end==`function`,h=Symbol(`EOF`),g=Symbol(`maybeEmitEnd`),_=Symbol(`emittedEnd`),he=Symbol(`emittingEnd`),ge=Symbol(`emittedError`),_e=Symbol(`closed`),ve=Symbol(`read`),ye=Symbol(`flush`),be=Symbol(`flushChunk`),v=Symbol(`encoding`),xe=Symbol(`decoder`),y=Symbol(`flowing`),Se=Symbol(`paused`),Ce=Symbol(`resume`),b=Symbol(`buffer`),x=Symbol(`pipes`),S=Symbol(`bufferLength`),we=Symbol(`bufferPush`),Te=Symbol(`bufferShift`),C=Symbol(`objectMode`),w=Symbol(`destroyed`),Ee=Symbol(`error`),De=Symbol(`emitData`),Oe=Symbol(`emitEnd`),ke=Symbol(`emitEnd2`),T=Symbol(`async`),Ae=Symbol(`abort`),je=Symbol(`aborted`),Me=Symbol(`signal`),Ne=Symbol(`dataListeners`),E=Symbol(`discarded`),Pe=e=>Promise.resolve().then(e),Fe=e=>e(),Ie=e=>e===`end`||e===`finish`||e===`prefinish`,Le=e=>e instanceof ArrayBuffer||!!e&&typeof e==`object`&&e.constructor&&e.constructor.name===`ArrayBuffer`&&e.byteLength>=0,Re=e=>!Buffer.isBuffer(e)&&ArrayBuffer.isView(e),ze=class{src;dest;opts;ondrain;constructor(e,t,n){this.src=e,this.dest=t,this.opts=n,this.ondrain=()=>e[Ce](),this.dest.on(`drain`,this.ondrain)}unpipe(){this.dest.removeListener(`drain`,this.ondrain)}proxyErrors(e){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},Be=class extends ze{unpipe(){this.src.removeListener(`error`,this.proxyErrors),super.unpipe()}constructor(e,t,n){super(e,t,n),this.proxyErrors=e=>this.dest.emit(`error`,e),e.on(`error`,this.proxyErrors)}},Ve=e=>!!e.objectMode,He=e=>!e.objectMode&&!!e.encoding&&e.encoding!==`buffer`,Ue=class extends f{[y]=!1;[Se]=!1;[x]=[];[b]=[];[C];[v];[T];[xe];[h]=!1;[_]=!1;[he]=!1;[_e]=!1;[ge]=null;[S]=0;[w]=!1;[Me];[je]=!1;[Ne]=0;[E]=!1;writable=!0;readable=!0;constructor(...e){let t=e[0]||{};if(super(),t.objectMode&&typeof t.encoding==`string`)throw TypeError(`Encoding and objectMode may not be used together`);Ve(t)?(this[C]=!0,this[v]=null):He(t)?(this[v]=t.encoding,this[C]=!1):(this[C]=!1,this[v]=null),this[T]=!!t.async,this[xe]=this[v]?new ee(this[v]):null,t&&t.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:()=>this[b]}),t&&t.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:()=>this[x]});let{signal:n}=t;n&&(this[Me]=n,n.aborted?this[Ae]():n.addEventListener(`abort`,()=>this[Ae]()))}get bufferLength(){return this[S]}get encoding(){return this[v]}set encoding(e){throw Error(`Encoding must be set at instantiation time`)}setEncoding(e){throw Error(`Encoding must be set at instantiation time`)}get objectMode(){return this[C]}set objectMode(e){throw Error(`objectMode must be set at instantiation time`)}get async(){return this[T]}set async(e){this[T]=this[T]||!!e}[Ae](){this[je]=!0,this.emit(`abort`,this[Me]?.reason),this.destroy(this[Me]?.reason)}get aborted(){return this[je]}set aborted(e){}write(e,t,n){if(this[je])return!1;if(this[h])throw Error(`write after end`);if(this[w])return this.emit(`error`,Object.assign(Error(`Cannot call write after a stream was destroyed`),{code:`ERR_STREAM_DESTROYED`})),!0;typeof t==`function`&&(n=t,t=`utf8`),t||=`utf8`;let r=this[T]?Pe:Fe;if(!this[C]&&!Buffer.isBuffer(e)){if(Re(e))e=Buffer.from(e.buffer,e.byteOffset,e.byteLength);else if(Le(e))e=Buffer.from(e);else if(typeof e!=`string`)throw Error(`Non-contiguous data written to non-objectMode stream`)}return this[C]?(this[y]&&this[S]!==0&&this[ye](!0),this[y]?this.emit(`data`,e):this[we](e),this[S]!==0&&this.emit(`readable`),n&&r(n),this[y]):e.length?(typeof e==`string`&&!(t===this[v]&&!this[xe]?.lastNeed)&&(e=Buffer.from(e,t)),Buffer.isBuffer(e)&&this[v]&&(e=this[xe].write(e)),this[y]&&this[S]!==0&&this[ye](!0),this[y]?this.emit(`data`,e):this[we](e),this[S]!==0&&this.emit(`readable`),n&&r(n),this[y]):(this[S]!==0&&this.emit(`readable`),n&&r(n),this[y])}read(e){if(this[w])return null;if(this[E]=!1,this[S]===0||e===0||e&&e>this[S])return this[g](),null;this[C]&&(e=null),this[b].length>1&&!this[C]&&(this[b]=[this[v]?this[b].join(``):Buffer.concat(this[b],this[S])]);let t=this[ve](e||null,this[b][0]);return this[g](),t}[ve](e,t){if(this[C])this[Te]();else{let n=t;e===n.length||e===null?this[Te]():typeof n==`string`?(this[b][0]=n.slice(e),t=n.slice(0,e),this[S]-=e):(this[b][0]=n.subarray(e),t=n.subarray(0,e),this[S]-=e)}return this.emit(`data`,t),!this[b].length&&!this[h]&&this.emit(`drain`),t}end(e,t,n){return typeof e==`function`&&(n=e,e=void 0),typeof t==`function`&&(n=t,t=`utf8`),e!==void 0&&this.write(e,t),n&&this.once(`end`,n),this[h]=!0,this.writable=!1,(this[y]||!this[Se])&&this[g](),this}[Ce](){this[w]||(!this[Ne]&&!this[x].length&&(this[E]=!0),this[Se]=!1,this[y]=!0,this.emit(`resume`),this[b].length?this[ye]():this[h]?this[g]():this.emit(`drain`))}resume(){return this[Ce]()}pause(){this[y]=!1,this[Se]=!0,this[E]=!1}get destroyed(){return this[w]}get flowing(){return this[y]}get paused(){return this[Se]}[we](e){this[C]?this[S]+=1:this[S]+=e.length,this[b].push(e)}[Te](){return this[C]?--this[S]:this[S]-=this[b][0].length,this[b].shift()}[ye](e=!1){do;while(this[be](this[Te]())&&this[b].length);!e&&!this[b].length&&!this[h]&&this.emit(`drain`)}[be](e){return this.emit(`data`,e),this[y]}pipe(e,t){if(this[w])return e;this[E]=!1;let n=this[_];return t||={},e===de.stdout||e===de.stderr?t.end=!1:t.end=t.end!==!1,t.proxyErrors=!!t.proxyErrors,n?t.end&&e.end():(this[x].push(t.proxyErrors?new Be(this,e,t):new ze(this,e,t)),this[T]?Pe(()=>this[Ce]()):this[Ce]()),e}unpipe(e){let t=this[x].find(t=>t.dest===e);t&&(this[x].length===1?(this[y]&&this[Ne]===0&&(this[y]=!1),this[x]=[]):this[x].splice(this[x].indexOf(t),1),t.unpipe())}addListener(e,t){return this.on(e,t)}on(e,t){let n=super.on(e,t);if(e===`data`)this[E]=!1,this[Ne]++,!this[x].length&&!this[y]&&this[Ce]();else if(e===`readable`&&this[S]!==0)super.emit(`readable`);else if(Ie(e)&&this[_])super.emit(e),this.removeAllListeners(e);else if(e===`error`&&this[ge]){let e=t;this[T]?Pe(()=>e.call(this,this[ge])):e.call(this,this[ge])}return n}removeListener(e,t){return this.off(e,t)}off(e,t){let n=super.off(e,t);return e===`data`&&(this[Ne]=this.listeners(`data`).length,this[Ne]===0&&!this[E]&&!this[x].length&&(this[y]=!1)),n}removeAllListeners(e){let t=super.removeAllListeners(e);return(e===`data`||e===void 0)&&(this[Ne]=0,!this[E]&&!this[x].length&&(this[y]=!1)),t}get emittedEnd(){return this[_]}[g](){!this[he]&&!this[_]&&!this[w]&&this[b].length===0&&this[h]&&(this[he]=!0,this.emit(`end`),this.emit(`prefinish`),this.emit(`finish`),this[_e]&&this.emit(`close`),this[he]=!1)}emit(e,...t){let n=t[0];if(e!==`error`&&e!==`close`&&e!==w&&this[w])return!1;if(e===`data`)return!this[C]&&!n?!1:this[T]?(Pe(()=>this[De](n)),!0):this[De](n);if(e===`end`)return this[Oe]();if(e===`close`){if(this[_e]=!0,!this[_]&&!this[w])return!1;let e=super.emit(`close`);return this.removeAllListeners(`close`),e}else if(e===`error`){this[ge]=n,super.emit(Ee,n);let e=!this[Me]||this.listeners(`error`).length?super.emit(`error`,n):!1;return this[g](),e}else if(e===`resume`){let e=super.emit(`resume`);return this[g](),e}else if(e===`finish`||e===`prefinish`){let t=super.emit(e);return this.removeAllListeners(e),t}let r=super.emit(e,...t);return this[g](),r}[De](e){for(let t of this[x])t.dest.write(e)===!1&&this.pause();let t=this[E]?!1:super.emit(`data`,e);return this[g](),t}[Oe](){return this[_]?!1:(this[_]=!0,this.readable=!1,this[T]?(Pe(()=>this[ke]()),!0):this[ke]())}[ke](){if(this[xe]){let e=this[xe].end();if(e){for(let t of this[x])t.dest.write(e);this[E]||super.emit(`data`,e)}}for(let e of this[x])e.end();let e=super.emit(`end`);return this.removeAllListeners(`end`),e}async collect(){let e=Object.assign([],{dataLength:0});this[C]||(e.dataLength=0);let t=this.promise();return this.on(`data`,t=>{e.push(t),this[C]||(e.dataLength+=t.length)}),await t,e}async concat(){if(this[C])throw Error(`cannot concat in objectMode`);let e=await this.collect();return this[v]?e.join(``):Buffer.concat(e,e.dataLength)}async promise(){return new Promise((e,t)=>{this.on(w,()=>t(Error(`stream destroyed`))),this.on(`error`,e=>t(e)),this.on(`end`,()=>e())})}[Symbol.asyncIterator](){this[E]=!1;let e=!1,t=async()=>(this.pause(),e=!0,{value:void 0,done:!0});return{next:()=>{if(e)return t();let n=this.read();if(n!==null)return Promise.resolve({done:!1,value:n});if(this[h])return t();let r,i,a=e=>{this.off(`data`,o),this.off(`end`,s),this.off(w,c),t(),i(e)},o=e=>{this.off(`error`,a),this.off(`end`,s),this.off(w,c),this.pause(),r({value:e,done:!!this[h]})},s=()=>{this.off(`error`,a),this.off(`data`,o),this.off(w,c),t(),r({done:!0,value:void 0})},c=()=>a(Error(`stream destroyed`));return new Promise((e,t)=>{i=t,r=e,this.once(w,c),this.once(`error`,a),this.once(`end`,s),this.once(`data`,o)})},throw:t,return:t,[Symbol.asyncIterator](){return this},[Symbol.asyncDispose]:async()=>{}}}[Symbol.iterator](){this[E]=!1;let e=!1,t=()=>(this.pause(),this.off(Ee,t),this.off(w,t),this.off(`end`,t),e=!0,{done:!0,value:void 0});return this.once(`end`,t),this.once(Ee,t),this.once(w,t),{next:()=>{if(e)return t();let n=this.read();return n===null?t():{done:!1,value:n}},throw:t,return:t,[Symbol.iterator](){return this},[Symbol.dispose]:()=>{}}}destroy(e){if(this[w])return e?this.emit(`error`,e):this.emit(w),this;this[w]=!0,this[E]=!0,this[b].length=0,this[S]=0;let t=this;return typeof t.close==`function`&&!this[_e]&&t.close(),e?this.emit(`error`,e):this.emit(w),this}static get isStream(){return fe}},We=d.writev,D=Symbol(`_autoClose`),O=Symbol(`_close`),Ge=Symbol(`_ended`),k=Symbol(`_fd`),Ke=Symbol(`_finished`),A=Symbol(`_flags`),qe=Symbol(`_flush`),Je=Symbol(`_handleChunk`),Ye=Symbol(`_makeBuf`),Xe=Symbol(`_mode`),Ze=Symbol(`_needDrain`),Qe=Symbol(`_onerror`),$e=Symbol(`_onopen`),et=Symbol(`_onread`),tt=Symbol(`_onwrite`),j=Symbol(`_open`),M=Symbol(`_path`),nt=Symbol(`_pos`),N=Symbol(`_queue`),rt=Symbol(`_read`),it=Symbol(`_readSize`),P=Symbol(`_reading`),at=Symbol(`_remain`),ot=Symbol(`_size`),st=Symbol(`_write`),ct=Symbol(`_writing`),lt=Symbol(`_defaultFlag`),ut=Symbol(`_errored`),dt=class extends Ue{[ut]=!1;[k];[M];[it];[P]=!1;[ot];[at];[D];constructor(e,t){if(t||={},super(t),this.readable=!0,this.writable=!1,typeof e!=`string`)throw TypeError(`path must be a string`);this[ut]=!1,this[k]=typeof t.fd==`number`?t.fd:void 0,this[M]=e,this[it]=t.readSize||16*1024*1024,this[P]=!1,this[ot]=typeof t.size==`number`?t.size:1/0,this[at]=this[ot],this[D]=typeof t.autoClose==`boolean`?t.autoClose:!0,typeof this[k]==`number`?this[rt]():this[j]()}get fd(){return this[k]}get path(){return this[M]}write(){throw TypeError(`this is a readable stream`)}end(){throw TypeError(`this is a readable stream`)}[j](){d.open(this[M],`r`,(e,t)=>this[$e](e,t))}[$e](e,t){e?this[Qe](e):(this[k]=t,this.emit(`open`,t),this[rt]())}[Ye](){return Buffer.allocUnsafe(Math.min(this[it],this[at]))}[rt](){if(!this[P]){this[P]=!0;let e=this[Ye]();if(e.length===0)return process.nextTick(()=>this[et](null,0,e));d.read(this[k],e,0,e.length,null,(e,t,n)=>this[et](e,t,n))}}[et](e,t,n){this[P]=!1,e?this[Qe](e):this[Je](t,n)&&this[rt]()}[O](){if(this[D]&&typeof this[k]==`number`){let e=this[k];this[k]=void 0,d.close(e,e=>e?this.emit(`error`,e):this.emit(`close`))}}[Qe](e){this[P]=!0,this[O](),this.emit(`error`,e)}[Je](e,t){let n=!1;return this[at]-=e,e>0&&(n=super.write(e<t.length?t.subarray(0,e):t)),(e===0||this[at]<=0)&&(n=!1,this[O](),super.end()),n}emit(e,...t){switch(e){case`prefinish`:case`finish`:return!1;case`drain`:return typeof this[k]==`number`&&this[rt](),!1;case`error`:return this[ut]?!1:(this[ut]=!0,super.emit(e,...t));default:return super.emit(e,...t)}}},ft=class extends dt{[j](){let e=!0;try{this[$e](null,d.openSync(this[M],`r`)),e=!1}finally{e&&this[O]()}}[rt](){let e=!0;try{if(!this[P]){this[P]=!0;do{let e=this[Ye](),t=e.length===0?0:d.readSync(this[k],e,0,e.length,null);if(!this[Je](t,e))break}while(!0);this[P]=!1}e=!1}finally{e&&this[O]()}}[O](){if(this[D]&&typeof this[k]==`number`){let e=this[k];this[k]=void 0,d.closeSync(e),this.emit(`close`)}}},pt=class extends l{readable=!1;writable=!0;[ut]=!1;[ct]=!1;[Ge]=!1;[N]=[];[Ze]=!1;[M];[Xe];[D];[k];[lt];[A];[Ke]=!1;[nt];constructor(e,t){t||={},super(t),this[M]=e,this[k]=typeof t.fd==`number`?t.fd:void 0,this[Xe]=t.mode===void 0?438:t.mode,this[nt]=typeof t.start==`number`?t.start:void 0,this[D]=typeof t.autoClose==`boolean`?t.autoClose:!0;let n=this[nt]===void 0?`w`:`r+`;this[lt]=t.flags===void 0,this[A]=t.flags===void 0?n:t.flags,this[k]===void 0&&this[j]()}emit(e,...t){if(e===`error`){if(this[ut])return!1;this[ut]=!0}return super.emit(e,...t)}get fd(){return this[k]}get path(){return this[M]}[Qe](e){this[O](),this[ct]=!0,this.emit(`error`,e)}[j](){d.open(this[M],this[A],this[Xe],(e,t)=>this[$e](e,t))}[$e](e,t){this[lt]&&this[A]===`r+`&&e&&e.code===`ENOENT`?(this[A]=`w`,this[j]()):e?this[Qe](e):(this[k]=t,this.emit(`open`,t),this[ct]||this[qe]())}end(e,t){return e&&this.write(e,t),this[Ge]=!0,!this[ct]&&!this[N].length&&typeof this[k]==`number`&&this[tt](null,0),this}write(e,t){return typeof e==`string`&&(e=Buffer.from(e,t)),this[Ge]?(this.emit(`error`,Error(`write() after end()`)),!1):this[k]===void 0||this[ct]||this[N].length?(this[N].push(e),this[Ze]=!0,!1):(this[ct]=!0,this[st](e),!0)}[st](e){d.write(this[k],e,0,e.length,this[nt],(e,t)=>this[tt](e,t))}[tt](e,t){e?this[Qe](e):(this[nt]!==void 0&&typeof t==`number`&&(this[nt]+=t),this[N].length?this[qe]():(this[ct]=!1,this[Ge]&&!this[Ke]?(this[Ke]=!0,this[O](),this.emit(`finish`)):this[Ze]&&(this[Ze]=!1,this.emit(`drain`))))}[qe](){if(this[N].length===0)this[Ge]&&this[tt](null,0);else if(this[N].length===1)this[st](this[N].pop());else{let e=this[N];this[N]=[],We(this[k],e,this[nt],(e,t)=>this[tt](e,t))}}[O](){if(this[D]&&typeof this[k]==`number`){let e=this[k];this[k]=void 0,d.close(e,e=>e?this.emit(`error`,e):this.emit(`close`))}}},mt=class extends pt{[j](){let e;if(this[lt]&&this[A]===`r+`)try{e=d.openSync(this[M],this[A],this[Xe])}catch(e){if(e?.code===`ENOENT`)return this[A]=`w`,this[j]();throw e}else e=d.openSync(this[M],this[A],this[Xe]);this[$e](null,e)}[O](){if(this[D]&&typeof this[k]==`number`){let e=this[k];this[k]=void 0,d.closeSync(e),this.emit(`close`)}}[st](e){let t=!0;try{this[tt](null,d.writeSync(this[k],e,0,e.length,this[nt])),t=!1}finally{if(t)try{this[O]()}catch{}}}},ht=new Map([[`C`,`cwd`],[`f`,`file`],[`z`,`gzip`],[`P`,`preservePaths`],[`U`,`unlink`],[`strip-components`,`strip`],[`stripComponents`,`strip`],[`keep-newer`,`newer`],[`keepNewer`,`newer`],[`keep-newer-files`,`newer`],[`keepNewerFiles`,`newer`],[`k`,`keep`],[`keep-existing`,`keep`],[`keepExisting`,`keep`],[`m`,`noMtime`],[`no-mtime`,`noMtime`],[`p`,`preserveOwner`],[`L`,`follow`],[`h`,`follow`],[`onentry`,`onReadEntry`]]),gt=e=>!!e.sync&&!!e.file,_t=e=>!e.sync&&!!e.file,vt=e=>!!e.sync&&!e.file,yt=e=>!e.sync&&!e.file,bt=e=>!!e.file,xt=e=>ht.get(e)||e,St=(e={})=>{if(!e)return{};let t={};for(let[n,r]of Object.entries(e)){let e=xt(n);t[e]=r}return t.chmod===void 0&&t.noChmod===!1&&(t.chmod=!0),delete t.noChmod,t},Ct=(e,t,n,r,i)=>Object.assign((a=[],o,s)=>{Array.isArray(a)&&(o=a,a={}),typeof o==`function`&&(s=o,o=void 0),o=o?Array.from(o):[];let c=St(a);if(i?.(c,o),gt(c)){if(typeof s==`function`)throw TypeError(`callback not supported for sync tar functions`);return e(c,o)}else if(_t(c)){let e=t(c,o);return s?e.then(()=>s(),s):e}else if(vt(c)){if(typeof s==`function`)throw TypeError(`callback not supported for sync tar functions`);return n(c,o)}else if(yt(c)){if(typeof s==`function`)throw TypeError(`callback only supported with file option`);return r(c,o)}throw Error(`impossible options??`)},{syncFile:e,asyncFile:t,syncNoFile:n,asyncNoFile:r,validate:i}),wt=ae.constants||{ZLIB_VERNUM:4736},F=Object.freeze(Object.assign(Object.create(null),{Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_VERSION_ERROR:-6,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,DEFLATE:1,INFLATE:2,GZIP:3,GUNZIP:4,DEFLATERAW:5,INFLATERAW:6,UNZIP:7,BROTLI_DECODE:8,BROTLI_ENCODE:9,Z_MIN_WINDOWBITS:8,Z_MAX_WINDOWBITS:15,Z_DEFAULT_WINDOWBITS:15,Z_MIN_CHUNK:64,Z_MAX_CHUNK:1/0,Z_DEFAULT_CHUNK:16384,Z_MIN_MEMLEVEL:1,Z_MAX_MEMLEVEL:9,Z_DEFAULT_MEMLEVEL:8,Z_MIN_LEVEL:-1,Z_MAX_LEVEL:9,Z_DEFAULT_LEVEL:-1,BROTLI_OPERATION_PROCESS:0,BROTLI_OPERATION_FLUSH:1,BROTLI_OPERATION_FINISH:2,BROTLI_OPERATION_EMIT_METADATA:3,BROTLI_MODE_GENERIC:0,BROTLI_MODE_TEXT:1,BROTLI_MODE_FONT:2,BROTLI_DEFAULT_MODE:0,BROTLI_MIN_QUALITY:0,BROTLI_MAX_QUALITY:11,BROTLI_DEFAULT_QUALITY:11,BROTLI_MIN_WINDOW_BITS:10,BROTLI_MAX_WINDOW_BITS:24,BROTLI_LARGE_MAX_WINDOW_BITS:30,BROTLI_DEFAULT_WINDOW:22,BROTLI_MIN_INPUT_BLOCK_BITS:16,BROTLI_MAX_INPUT_BLOCK_BITS:24,BROTLI_PARAM_MODE:0,BROTLI_PARAM_QUALITY:1,BROTLI_PARAM_LGWIN:2,BROTLI_PARAM_LGBLOCK:3,BROTLI_PARAM_DISABLE_LITERAL_CONTEXT_MODELING:4,BROTLI_PARAM_SIZE_HINT:5,BROTLI_PARAM_LARGE_WINDOW:6,BROTLI_PARAM_NPOSTFIX:7,BROTLI_PARAM_NDIRECT:8,BROTLI_DECODER_RESULT_ERROR:0,BROTLI_DECODER_RESULT_SUCCESS:1,BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT:2,BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT:3,BROTLI_DECODER_PARAM_DISABLE_RING_BUFFER_REALLOCATION:0,BROTLI_DECODER_PARAM_LARGE_WINDOW:1,BROTLI_DECODER_NO_ERROR:0,BROTLI_DECODER_SUCCESS:1,BROTLI_DECODER_NEEDS_MORE_INPUT:2,BROTLI_DECODER_NEEDS_MORE_OUTPUT:3,BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_NIBBLE:-1,BROTLI_DECODER_ERROR_FORMAT_RESERVED:-2,BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_META_NIBBLE:-3,BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_ALPHABET:-4,BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_SAME:-5,BROTLI_DECODER_ERROR_FORMAT_CL_SPACE:-6,BROTLI_DECODER_ERROR_FORMAT_HUFFMAN_SPACE:-7,BROTLI_DECODER_ERROR_FORMAT_CONTEXT_MAP_REPEAT:-8,BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_1:-9,BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_2:-10,BROTLI_DECODER_ERROR_FORMAT_TRANSFORM:-11,BROTLI_DECODER_ERROR_FORMAT_DICTIONARY:-12,BROTLI_DECODER_ERROR_FORMAT_WINDOW_BITS:-13,BROTLI_DECODER_ERROR_FORMAT_PADDING_1:-14,BROTLI_DECODER_ERROR_FORMAT_PADDING_2:-15,BROTLI_DECODER_ERROR_FORMAT_DISTANCE:-16,BROTLI_DECODER_ERROR_DICTIONARY_NOT_SET:-19,BROTLI_DECODER_ERROR_INVALID_ARGUMENTS:-20,BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MODES:-21,BROTLI_DECODER_ERROR_ALLOC_TREE_GROUPS:-22,BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MAP:-25,BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_1:-26,BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_2:-27,BROTLI_DECODER_ERROR_ALLOC_BLOCK_TYPE_TREES:-30,BROTLI_DECODER_ERROR_UNREACHABLE:-31},wt)),Tt=re.concat,Et=Object.getOwnPropertyDescriptor(re,`concat`),Dt=e=>e,Ot=Et?.writable===!0||Et?.set!==void 0?e=>{re.concat=e?Dt:Tt}:e=>{},kt=Symbol(`_superWrite`),At=class extends Error{code;errno;constructor(e,t){super(`zlib: `+e.message,{cause:e}),this.code=e.code,this.errno=e.errno,this.code||=`ZLIB_ERROR`,this.message=`zlib: `+e.message,Error.captureStackTrace(this,t??this.constructor)}get name(){return`ZlibError`}},jt=Symbol(`flushFlag`),Mt=class extends Ue{#e=!1;#t=!1;#n;#r;#i;#a;#o;get sawError(){return this.#e}get handle(){return this.#a}get flushFlag(){return this.#n}constructor(e,t){if(!e||typeof e!=`object`)throw TypeError(`invalid options for ZlibBase constructor`);if(super(e),this.#n=e.flush??0,this.#r=e.finishFlush??0,this.#i=e.fullFlushFlag??0,typeof ie[t]!=`function`)throw TypeError(`Compression method not supported: `+t);try{this.#a=new ie[t](e)}catch(e){throw new At(e,this.constructor)}this.#o=e=>{this.#e||(this.#e=!0,this.close(),this.emit(`error`,e))},this.#a?.on(`error`,e=>this.#o(new At(e))),this.once(`end`,()=>this.close)}close(){this.#a&&(this.#a.close(),this.#a=void 0,this.emit(`close`))}reset(){if(!this.#e)return ne(this.#a,`zlib binding closed`),this.#a.reset?.()}flush(e){this.ended||(typeof e!=`number`&&(e=this.#i),this.write(Object.assign(re.alloc(0),{[jt]:e})))}end(e,t,n){return typeof e==`function`&&(n=e,t=void 0,e=void 0),typeof t==`function`&&(n=t,t=void 0),e&&(t?this.write(e,t):this.write(e)),this.flush(this.#r),this.#t=!0,super.end(n)}get ended(){return this.#t}[kt](e){return super.write(e)}write(e,t,n){if(typeof t==`function`&&(n=t,t=`utf8`),typeof e==`string`&&(e=re.from(e,t)),this.#e)return;ne(this.#a,`zlib binding closed`);let r=this.#a._handle,i=r.close;r.close=()=>{};let a=this.#a.close;this.#a.close=()=>{},Ot(!0);let o;try{let t=typeof e[jt]==`number`?e[jt]:this.#n;o=this.#a._processChunk(e,t),Ot(!1)}catch(e){Ot(!1),this.#o(new At(e,this.write))}finally{this.#a&&(this.#a._handle=r,r.close=i,this.#a.close=a,this.#a.removeAllListeners(`error`))}this.#a&&this.#a.on(`error`,e=>this.#o(new At(e,this.write)));let s;if(o)if(Array.isArray(o)&&o.length>0){let e=o[0];s=this[kt](re.from(e));for(let e=1;e<o.length;e++)s=this[kt](o[e])}else s=this[kt](re.from(o));return n&&n(),s}},Nt=class extends Mt{#e;#t;constructor(e,t){e||={},e.flush=e.flush||F.Z_NO_FLUSH,e.finishFlush=e.finishFlush||F.Z_FINISH,e.fullFlushFlag=F.Z_FULL_FLUSH,super(e,t),this.#e=e.level,this.#t=e.strategy}params(e,t){if(!this.sawError){if(!this.handle)throw Error(`cannot switch params when binding is closed`);if(!this.handle.params)throw Error(`not supported in this implementation`);if(this.#e!==e||this.#t!==t){this.flush(F.Z_SYNC_FLUSH),ne(this.handle,`zlib binding closed`);let n=this.handle.flush;this.handle.flush=(e,t)=>{typeof e==`function`&&(t=e,e=this.flushFlag),this.flush(e),t?.()};try{this.handle.params(e,t)}finally{this.handle.flush=n}this.handle&&(this.#e=e,this.#t=t)}}}},Pt=class extends Nt{#e;constructor(e){super(e,`Gzip`),this.#e=e&&!!e.portable}[kt](e){return this.#e?(this.#e=!1,e[9]=255,super[kt](e)):super[kt](e)}},Ft=class extends Nt{constructor(e){super(e,`Unzip`)}},It=class extends Mt{constructor(e,t){e||={},e.flush=e.flush||F.BROTLI_OPERATION_PROCESS,e.finishFlush=e.finishFlush||F.BROTLI_OPERATION_FINISH,e.fullFlushFlag=F.BROTLI_OPERATION_FLUSH,super(e,t)}},Lt=class extends It{constructor(e){super(e,`BrotliCompress`)}},Rt=class extends It{constructor(e){super(e,`BrotliDecompress`)}},zt=class extends Mt{constructor(e,t){e||={},e.flush=e.flush||F.ZSTD_e_continue,e.finishFlush=e.finishFlush||F.ZSTD_e_end,e.fullFlushFlag=F.ZSTD_e_flush,super(e,t)}},Bt=class extends zt{constructor(e){super(e,`ZstdCompress`)}},Vt=class extends zt{constructor(e){super(e,`ZstdDecompress`)}},Ht=(e,t)=>{if(Number.isSafeInteger(e))e<0?Wt(e,t):Ut(e,t);else throw Error(`cannot encode number outside of javascript safe integer range`);return t},Ut=(e,t)=>{t[0]=128;for(var n=t.length;n>1;n--)t[n-1]=e&255,e=Math.floor(e/256)},Wt=(e,t)=>{t[0]=255;var n=!1;e*=-1;for(var r=t.length;r>1;r--){var i=e&255;e=Math.floor(e/256),n?t[r-1]=Jt(i):i===0?t[r-1]=0:(n=!0,t[r-1]=Yt(i))}},Gt=e=>{let t=e[0],n=t===128?qt(e.subarray(1,e.length)):t===255?Kt(e):null;if(n===null)throw Error(`invalid base256 encoding`);if(!Number.isSafeInteger(n))throw Error(`parsed number outside of javascript safe integer range`);return n},Kt=e=>{for(var t=e.length,n=0,r=!1,i=t-1;i>-1;i--){var a=Number(e[i]),o;r?o=Jt(a):a===0?o=a:(r=!0,o=Yt(a)),o!==0&&(n-=o*256**(t-i-1))}return n},qt=e=>{for(var t=e.length,n=0,r=t-1;r>-1;r--){var i=Number(e[r]);i!==0&&(n+=i*256**(t-r-1))}return n},Jt=e=>(255^e)&255,Yt=e=>(255^e)+1&255,Xt={};ue(Xt,{code:()=>en,isCode:()=>Zt,isName:()=>Qt,name:()=>$t});var Zt=e=>$t.has(e),Qt=e=>en.has(e),$t=new Map([[`0`,`File`],[``,`OldFile`],[`1`,`Link`],[`2`,`SymbolicLink`],[`3`,`CharacterDevice`],[`4`,`BlockDevice`],[`5`,`Directory`],[`6`,`FIFO`],[`7`,`ContiguousFile`],[`g`,`GlobalExtendedHeader`],[`x`,`ExtendedHeader`],[`A`,`SolarisACL`],[`D`,`GNUDumpDir`],[`I`,`Inode`],[`K`,`NextFileHasLongLinkpath`],[`L`,`NextFileHasLongPath`],[`M`,`ContinuationFile`],[`N`,`OldGnuLongPath`],[`S`,`SparseFile`],[`V`,`TapeVolumeHeader`],[`X`,`OldExtendedHeader`]]),en=new Map(Array.from($t).map(e=>[e[1],e[0]])),I=class{cksumValid=!1;needPax=!1;nullBlock=!1;block;path;mode;uid;gid;size;cksum;#e=`Unsupported`;linkpath;uname;gname;devmaj=0;devmin=0;atime;ctime;mtime;charset;comment;constructor(e,t=0,n,r){Buffer.isBuffer(e)?this.decode(e,t||0,n,r):e&&this.#t(e)}decode(e,t,n,r){if(t||=0,!e||!(e.length>=t+512))throw Error(`need 512 bytes for header`);this.path=n?.path??nn(e,t,100),this.mode=n?.mode??r?.mode??L(e,t+100,8),this.uid=n?.uid??r?.uid??L(e,t+108,8),this.gid=n?.gid??r?.gid??L(e,t+116,8),this.size=n?.size??r?.size??L(e,t+124,12),this.mtime=n?.mtime??r?.mtime??rn(e,t+136,12),this.cksum=L(e,t+148,12),r&&this.#t(r,!0),n&&this.#t(n);let i=nn(e,t+156,1);if(Zt(i)&&(this.#e=i||`0`),this.#e===`0`&&this.path.slice(-1)===`/`&&(this.#e=`5`),this.#e===`5`&&(this.size=0),this.linkpath=nn(e,t+157,100),e.subarray(t+257,t+265).toString()===`ustar\x0000`)if(this.uname=n?.uname??r?.uname??nn(e,t+265,32),this.gname=n?.gname??r?.gname??nn(e,t+297,32),this.devmaj=n?.devmaj??r?.devmaj??L(e,t+329,8)??0,this.devmin=n?.devmin??r?.devmin??L(e,t+337,8)??0,e[t+475]!==0)this.path=nn(e,t+345,155)+`/`+this.path;else{let i=nn(e,t+345,130);i&&(this.path=i+`/`+this.path),this.atime=n?.atime??r?.atime??rn(e,t+476,12),this.ctime=n?.ctime??r?.ctime??rn(e,t+488,12)}let a=256;for(let n=t;n<t+148;n++)a+=e[n];for(let n=t+156;n<t+512;n++)a+=e[n];this.cksumValid=a===this.cksum,this.cksum===void 0&&a===256&&(this.nullBlock=!0)}#t(e,t=!1){Object.assign(this,Object.fromEntries(Object.entries(e).filter(([e,n])=>!(n==null||e===`path`&&t||e===`linkpath`&&t||e===`global`))))}encode(e,t=0){if(e||=this.block=Buffer.alloc(512),this.#e===`Unsupported`&&(this.#e=`0`),!(e.length>=t+512))throw Error(`need 512 bytes for header`);let n=this.ctime||this.atime?130:155,r=tn(this.path||``,n),i=r[0],a=r[1];this.needPax=!!r[2],this.needPax=mn(e,t,100,i)||this.needPax,this.needPax=R(e,t+100,8,this.mode)||this.needPax,this.needPax=R(e,t+108,8,this.uid)||this.needPax,this.needPax=R(e,t+116,8,this.gid)||this.needPax,this.needPax=R(e,t+124,12,this.size)||this.needPax,this.needPax=fn(e,t+136,12,this.mtime)||this.needPax,e[t+156]=Number(this.#e.codePointAt(0)),this.needPax=mn(e,t+157,100,this.linkpath)||this.needPax,e.write(`ustar\x0000`,t+257,8),this.needPax=mn(e,t+265,32,this.uname)||this.needPax,this.needPax=mn(e,t+297,32,this.gname)||this.needPax,this.needPax=R(e,t+329,8,this.devmaj)||this.needPax,this.needPax=R(e,t+337,8,this.devmin)||this.needPax,this.needPax=mn(e,t+345,n,a)||this.needPax,e[t+475]===0?(this.needPax=mn(e,t+345,130,a)||this.needPax,this.needPax=fn(e,t+476,12,this.atime)||this.needPax,this.needPax=fn(e,t+488,12,this.ctime)||this.needPax):this.needPax=mn(e,t+345,155,a)||this.needPax;let o=256;for(let n=t;n<t+148;n++)o+=e[n];for(let n=t+156;n<t+512;n++)o+=e[n];return this.cksum=o,R(e,t+148,8,this.cksum),this.cksumValid=!0,this.needPax}get type(){return this.#e===`Unsupported`?this.#e:$t.get(this.#e)}get typeKey(){return this.#e}set type(e){let t=String(en.get(e));if(Zt(t)||t===`Unsupported`)this.#e=t;else if(Zt(e))this.#e=e;else throw TypeError(`invalid entry type: `+e)}},tn=(e,t)=>{let n=e,r=``,i,o=a.parse(e).root||`.`;if(Buffer.byteLength(n)<100)i=[n,r,!1];else{r=a.dirname(n),n=a.basename(n);do Buffer.byteLength(n)<=100&&Buffer.byteLength(r)<=t?i=[n,r,!1]:Buffer.byteLength(n)>100&&Buffer.byteLength(r)<=t?i=[n.slice(0,99),r,!0]:(n=a.join(a.basename(r),n),r=a.dirname(r));while(r!==o&&i===void 0);i||=[e.slice(0,99),``,!0]}return i},nn=(e,t,n)=>e.subarray(t,t+n).toString(`utf8`).replace(/\0.*/,``),rn=(e,t,n)=>an(L(e,t,n)),an=e=>e===void 0?void 0:new Date(e*1e3),L=(e,t,n)=>Number(e[t])&128?Gt(e.subarray(t,t+n)):sn(e,t,n),on=e=>isNaN(e)?void 0:e,sn=(e,t,n)=>on(parseInt(e.subarray(t,t+n).toString(`utf8`).replace(/\0.*$/,``).trim(),8)),cn={12:8589934591,8:2097151},R=(e,t,n,r)=>r===void 0?!1:r>cn[n]||r<0?(Ht(r,e.subarray(t,t+n)),!0):(ln(e,t,n,r),!1),ln=(e,t,n,r)=>e.write(un(r,n),t,n,`ascii`),un=(e,t)=>dn(Math.floor(e).toString(8),t),dn=(e,t)=>(e.length===t-1?e:Array(t-e.length-1).join(`0`)+e+` `)+`\0`,fn=(e,t,n,r)=>r===void 0?!1:R(e,t,n,r.getTime()/1e3),pn=Array(156).join(`\0`),mn=(e,t,n,r)=>r===void 0?!1:(e.write(r+pn,t,n,`utf8`),r.length!==Buffer.byteLength(r)||r.length>n),hn=class e{atime;mtime;ctime;charset;comment;gid;uid;gname;uname;linkpath;dev;ino;nlink;path;size;mode;global;constructor(e,t=!1){this.atime=e.atime,this.charset=e.charset,this.comment=e.comment,this.ctime=e.ctime,this.dev=e.dev,this.gid=e.gid,this.global=t,this.gname=e.gname,this.ino=e.ino,this.linkpath=e.linkpath,this.mtime=e.mtime,this.nlink=e.nlink,this.path=e.path,this.size=e.size,this.uid=e.uid,this.uname=e.uname}encode(){let e=this.encodeBody();if(e===``)return Buffer.allocUnsafe(0);let t=Buffer.byteLength(e),n=512*Math.ceil(1+t/512),i=Buffer.allocUnsafe(n);for(let e=0;e<512;e++)i[e]=0;new I({path:(`PaxHeader/`+r(this.path??``)).slice(0,99),mode:this.mode||420,uid:this.uid,gid:this.gid,size:t,mtime:this.mtime,type:this.global?`GlobalExtendedHeader`:`ExtendedHeader`,linkpath:``,uname:this.uname||``,gname:this.gname||``,devmaj:0,devmin:0,atime:this.atime,ctime:this.ctime}).encode(i),i.write(e,512,t,`utf8`);for(let e=t+512;e<i.length;e++)i[e]=0;return i}encodeBody(){return this.encodeField(`path`)+this.encodeField(`ctime`)+this.encodeField(`atime`)+this.encodeField(`dev`)+this.encodeField(`ino`)+this.encodeField(`nlink`)+this.encodeField(`charset`)+this.encodeField(`comment`)+this.encodeField(`gid`)+this.encodeField(`gname`)+this.encodeField(`linkpath`)+this.encodeField(`mtime`)+this.encodeField(`size`)+this.encodeField(`uid`)+this.encodeField(`uname`)}encodeField(e){if(this[e]===void 0)return``;let t=this[e],n=t instanceof Date?t.getTime()/1e3:t,r=` `+(e===`dev`||e===`ino`||e===`nlink`?`SCHILY.`:``)+e+`=`+n+`
|
|
3
3
|
`,i=Buffer.byteLength(r),a=Math.floor(Math.log(i)/Math.log(10))+1;return i+a>=10**a&&(a+=1),a+i+r}static parse(t,n,r=!1){return new e(gn(_n(t),n),r)}},gn=(e,t)=>t?Object.assign({},t,e):e,_n=e=>e.replace(/\n$/,``).split(`
|
|
4
4
|
`).reduce(vn,Object.create(null)),vn=(e,t)=>{let n=parseInt(t,10);if(n!==Buffer.byteLength(t)+1)return e;t=t.slice((n+` `).length);let r=t.split(`=`),i=r.shift();if(!i)return e;let a=i.replace(/^SCHILY\.(dev|ino|nlink)/,`$1`),o=r.join(`=`);return e[a]=/^([A-Z]+\.)?([mac]|birth|creation)time$/.test(a)?new Date(Number(o)*1e3):/^[0-9]+$/.test(o)?+o:o,e},z=(process.env.TESTING_TAR_FAKE_PLATFORM||process.platform)===`win32`?e=>e&&e.replaceAll(/\\/g,`/`):e=>e,yn=class extends Ue{extended;globalExtended;header;startBlockSize;blockRemain;remain;type;meta=!1;ignore=!1;path;mode;uid;gid;uname;gname;size=0;mtime;atime;ctime;linkpath;dev;ino;nlink;invalid=!1;absolute;unsupported=!1;constructor(e,t,n){switch(super({}),this.pause(),this.extended=t,this.globalExtended=n,this.header=e,this.remain=e.size??0,this.startBlockSize=512*Math.ceil(this.remain/512),this.blockRemain=this.startBlockSize,this.type=e.type,this.type){case`File`:case`OldFile`:case`Link`:case`SymbolicLink`:case`CharacterDevice`:case`BlockDevice`:case`Directory`:case`FIFO`:case`ContiguousFile`:case`GNUDumpDir`:break;case`NextFileHasLongLinkpath`:case`NextFileHasLongPath`:case`OldGnuLongPath`:case`GlobalExtendedHeader`:case`ExtendedHeader`:case`OldExtendedHeader`:this.meta=!0;break;default:this.ignore=!0}if(!e.path)throw Error(`no path provided for tar.ReadEntry`);this.path=z(e.path),this.mode=e.mode,this.mode&&(this.mode&=4095),this.uid=e.uid,this.gid=e.gid,this.uname=e.uname,this.gname=e.gname,this.size=this.remain,this.mtime=e.mtime,this.atime=e.atime,this.ctime=e.ctime,this.linkpath=e.linkpath?z(e.linkpath):void 0,this.uname=e.uname,this.gname=e.gname,t&&this.#e(t),n&&this.#e(n,!0)}write(e){let t=e.length;if(t>this.blockRemain)throw Error(`writing more to entry than is appropriate`);let n=this.remain,r=this.blockRemain;return this.remain=Math.max(0,n-t),this.blockRemain=Math.max(0,r-t),this.ignore?!0:n>=t?super.write(e):super.write(e.subarray(0,n))}#e(e,t=!1){e.path&&=z(e.path),e.linkpath&&=z(e.linkpath),Object.assign(this,Object.fromEntries(Object.entries(e).filter(([e,n])=>!(n==null||e===`path`&&t))))}},bn=(e,t,n,r={})=>{e.file&&(r.file=e.file),e.cwd&&(r.cwd=e.cwd),r.code=n instanceof Error&&n.code||t,r.tarCode=t,!e.strict&&r.recoverable!==!1?(n instanceof Error&&(r=Object.assign(n,r),n=n.message),e.emit(`warn`,t,n,r)):n instanceof Error?e.emit(`error`,Object.assign(n,r)):e.emit(`error`,Object.assign(Error(`${t}: ${n}`),r))},xn=1024*1024,Sn=Buffer.from([31,139]),Cn=Buffer.from([40,181,47,253]),wn=Math.max(Sn.length,Cn.length),B=Symbol(`state`),Tn=Symbol(`writeEntry`),V=Symbol(`readEntry`),En=Symbol(`nextEntry`),Dn=Symbol(`processEntry`),H=Symbol(`extendedHeader`),On=Symbol(`globalExtendedHeader`),kn=Symbol(`meta`),An=Symbol(`emitMeta`),U=Symbol(`buffer`),W=Symbol(`queue`),G=Symbol(`ended`),jn=Symbol(`emittedEnd`),Mn=Symbol(`emit`),K=Symbol(`unzip`),Nn=Symbol(`consumeChunk`),Pn=Symbol(`consumeChunkSub`),Fn=Symbol(`consumeBody`),In=Symbol(`consumeMeta`),Ln=Symbol(`consumeHeader`),Rn=Symbol(`consuming`),zn=Symbol(`bufferConcat`),Bn=Symbol(`maybeEnd`),Vn=Symbol(`writing`),q=Symbol(`aborted`),Hn=Symbol(`onDone`),Un=Symbol(`sawValidEntry`),Wn=Symbol(`sawNullBlock`),Gn=Symbol(`sawEOF`),Kn=Symbol(`closeStream`),qn=()=>!0,Jn=class extends u{file;strict;maxMetaEntrySize;filter;brotli;zstd;writable=!0;readable=!1;[W]=[];[U];[V];[Tn];[B]=`begin`;[kn]=``;[H];[On];[G]=!1;[K];[q]=!1;[Un];[Wn]=!1;[Gn]=!1;[Vn]=!1;[Rn]=!1;[jn]=!1;constructor(e={}){super(),this.file=e.file||``,this.on(Hn,()=>{(this[B]===`begin`||this[Un]===!1)&&this.warn(`TAR_BAD_ARCHIVE`,`Unrecognized archive format`)}),e.ondone?this.on(Hn,e.ondone):this.on(Hn,()=>{this.emit(`prefinish`),this.emit(`finish`),this.emit(`end`)}),this.strict=!!e.strict,this.maxMetaEntrySize=e.maxMetaEntrySize||xn,this.filter=typeof e.filter==`function`?e.filter:qn;let t=e.file&&(e.file.endsWith(`.tar.br`)||e.file.endsWith(`.tbr`));this.brotli=!(e.gzip||e.zstd)&&e.brotli!==void 0?e.brotli:t?void 0:!1;let n=e.file&&(e.file.endsWith(`.tar.zst`)||e.file.endsWith(`.tzst`));this.zstd=!(e.gzip||e.brotli)&&e.zstd!==void 0?e.zstd:n?!0:void 0,this.on(`end`,()=>this[Kn]()),typeof e.onwarn==`function`&&this.on(`warn`,e.onwarn),typeof e.onReadEntry==`function`&&this.on(`entry`,e.onReadEntry)}warn(e,t,n={}){bn(this,e,t,n)}[Ln](e,t){this[Un]===void 0&&(this[Un]=!1);let n;try{n=new I(e,t,this[H],this[On])}catch(e){return this.warn(`TAR_ENTRY_INVALID`,e)}if(n.nullBlock)this[Wn]?(this[Gn]=!0,this[B]===`begin`&&(this[B]=`header`),this[Mn](`eof`)):(this[Wn]=!0,this[Mn](`nullBlock`));else if(this[Wn]=!1,!n.cksumValid)this.warn(`TAR_ENTRY_INVALID`,`checksum failure`,{header:n});else if(!n.path)this.warn(`TAR_ENTRY_INVALID`,`path is required`,{header:n});else{let e=n.type;if(/^(Symbolic)?Link$/.test(e)&&!n.linkpath)this.warn(`TAR_ENTRY_INVALID`,`linkpath required`,{header:n});else if(!/^(Symbolic)?Link$/.test(e)&&!/^(Global)?ExtendedHeader$/.test(e)&&n.linkpath)this.warn(`TAR_ENTRY_INVALID`,`linkpath forbidden`,{header:n});else{let e=this[Tn]=new yn(n,this[H],this[On]);this[Un]||(e.remain?e.on(`end`,()=>{e.invalid||(this[Un]=!0)}):this[Un]=!0),e.meta?e.size>this.maxMetaEntrySize?(e.ignore=!0,this[Mn](`ignoredEntry`,e),this[B]=`ignore`,e.resume()):e.size>0&&(this[kn]=``,e.on(`data`,e=>this[kn]+=e),this[B]=`meta`):(this[H]=void 0,e.ignore=e.ignore||!this.filter(e.path,e),e.ignore?(this[Mn](`ignoredEntry`,e),this[B]=e.remain?`ignore`:`header`,e.resume()):(e.remain?this[B]=`body`:(this[B]=`header`,e.end()),this[V]?this[W].push(e):(this[W].push(e),this[En]())))}}}[Kn](){queueMicrotask(()=>this.emit(`close`))}[Dn](e){let t=!0;if(!e)this[V]=void 0,t=!1;else if(Array.isArray(e)){let[t,...n]=e;this.emit(t,...n)}else this[V]=e,this.emit(`entry`,e),e.emittedEnd||(e.on(`end`,()=>this[En]()),t=!1);return t}[En](){do;while(this[Dn](this[W].shift()));if(this[W].length===0){let e=this[V];!e||e.flowing||e.size===e.remain?this[Vn]||this.emit(`drain`):e.once(`drain`,()=>this.emit(`drain`))}}[Fn](e,t){let n=this[Tn];if(!n)throw Error(`attempt to consume body without entry??`);let r=n.blockRemain??0,i=r>=e.length&&t===0?e:e.subarray(t,t+r);return n.write(i),n.blockRemain||(this[B]=`header`,this[Tn]=void 0,n.end()),i.length}[In](e,t){let n=this[Tn],r=this[Fn](e,t);return!this[Tn]&&n&&this[An](n),r}[Mn](e,t,n){this[W].length===0&&!this[V]?this.emit(e,t,n):this[W].push([e,t,n])}[An](e){switch(this[Mn](`meta`,this[kn]),e.type){case`ExtendedHeader`:case`OldExtendedHeader`:this[H]=hn.parse(this[kn],this[H],!1);break;case`GlobalExtendedHeader`:this[On]=hn.parse(this[kn],this[On],!0);break;case`NextFileHasLongPath`:case`OldGnuLongPath`:{let e=this[H]??Object.create(null);this[H]=e,e.path=this[kn].replace(/\0.*/,``);break}case`NextFileHasLongLinkpath`:{let e=this[H]||Object.create(null);this[H]=e,e.linkpath=this[kn].replace(/\0.*/,``);break}default:throw Error(`unknown meta: `+e.type)}}abort(e){this[q]=!0,this.emit(`abort`,e),this.warn(`TAR_ABORT`,e,{recoverable:!1})}write(e,t,n){if(typeof t==`function`&&(n=t,t=void 0),typeof e==`string`&&(e=Buffer.from(e,typeof t==`string`?t:`utf8`)),this[q])return n?.(),!1;if((this[K]===void 0||this.brotli===void 0&&this[K]===!1)&&e){if(this[U]&&(e=Buffer.concat([this[U],e]),this[U]=void 0),e.length<wn)return this[U]=e,n?.(),!0;for(let t=0;this[K]===void 0&&t<Sn.length;t++)e[t]!==Sn[t]&&(this[K]=!1);let t=!1;if(this[K]===!1&&this.zstd!==!1){t=!0;for(let n=0;n<Cn.length;n++)if(e[n]!==Cn[n]){t=!1;break}}let r=this.brotli===void 0&&!t;if(this[K]===!1&&r)if(e.length<512)if(this[G])this.brotli=!0;else return this[U]=e,n?.(),!0;else try{new I(e.subarray(0,512)),this.brotli=!1}catch{this.brotli=!0}if(this[K]===void 0||this[K]===!1&&(this.brotli||t)){let r=this[G];this[G]=!1,this[K]=this[K]===void 0?new Ft({}):t?new Vt({}):new Rt({}),this[K].on(`data`,e=>this[Nn](e)),this[K].on(`error`,e=>this.abort(e)),this[K].on(`end`,()=>{this[G]=!0,this[Nn]()}),this[Vn]=!0;let i=!!this[K][r?`end`:`write`](e);return this[Vn]=!1,n?.(),i}}this[Vn]=!0,this[K]?this[K].write(e):this[Nn](e),this[Vn]=!1;let r=this[W].length>0?!1:this[V]?this[V].flowing:!0;return!r&&this[W].length===0&&this[V]?.once(`drain`,()=>this.emit(`drain`)),n?.(),r}[zn](e){e&&!this[q]&&(this[U]=this[U]?Buffer.concat([this[U],e]):e)}[Bn](){if(this[G]&&!this[jn]&&!this[q]&&!this[Rn]){this[jn]=!0;let e=this[Tn];if(e&&e.blockRemain){let t=this[U]?this[U].length:0;this.warn(`TAR_BAD_ARCHIVE`,`Truncated input (needed ${e.blockRemain} more bytes, only ${t} available)`,{entry:e}),this[U]&&e.write(this[U]),e.end()}this[Mn](Hn)}}[Nn](e){if(this[Rn]&&e)this[zn](e);else if(!e&&!this[U])this[Bn]();else if(e){if(this[Rn]=!0,this[U]){this[zn](e);let t=this[U];this[U]=void 0,this[Pn](t)}else this[Pn](e);for(;this[U]&&this[U]?.length>=512&&!this[q]&&!this[Gn];){let e=this[U];this[U]=void 0,this[Pn](e)}this[Rn]=!1}(!this[U]||this[G])&&this[Bn]()}[Pn](e){let t=0,n=e.length;for(;t+512<=n&&!this[q]&&!this[Gn];)switch(this[B]){case`begin`:case`header`:this[Ln](e,t),t+=512;break;case`ignore`:case`body`:t+=this[Fn](e,t);break;case`meta`:t+=this[In](e,t);break;default:throw Error(`invalid state: `+this[B])}t<n&&(this[U]=this[U]?Buffer.concat([e.subarray(t),this[U]]):e.subarray(t))}end(e,t,n){return typeof e==`function`&&(n=e,t=void 0,e=void 0),typeof t==`function`&&(n=t,t=void 0),typeof e==`string`&&(e=Buffer.from(e,t)),n&&this.once(`finish`,n),this[q]||(this[K]?(e&&this[K].write(e),this[K].end()):(this[G]=!0,(this.brotli===void 0||this.zstd===void 0)&&(e||=Buffer.alloc(0)),e&&this.write(e),this[Bn]())),this}},Yn=e=>{let t=e.length-1,n=-1;for(;t>-1&&e.charAt(t)===`/`;)n=t,t--;return n===-1?e:e.slice(0,n)},Xn=e=>{let t=e.onReadEntry;e.onReadEntry=t?e=>{t(e),e.resume()}:e=>e.resume()},Zn=(e,t)=>{let n=new Map(t.map(e=>[Yn(e),!0])),r=e.filter,i=(e,t=``)=>{let r=t||te(e).root||`.`,a;if(e===r)a=!1;else{let t=n.get(e);a=t===void 0?i(m(e),r):t}return n.set(e,a),a};e.filter=r?(e,t)=>r(e,t)&&i(Yn(e)):e=>i(Yn(e))},Qn=Ct(e=>{let n=new Jn(e),r=e.file,i;try{i=t.openSync(r,`r`);let a=t.fstatSync(i),o=e.maxReadSize||16*1024*1024;if(a.size<o){let e=Buffer.allocUnsafe(a.size),r=t.readSync(i,e,0,a.size,0);n.end(r===e.byteLength?e:e.subarray(0,r))}else{let e=0,r=Buffer.allocUnsafe(o);for(;e<a.size;){let a=t.readSync(i,r,0,o,e);if(a===0)break;e+=a,n.write(r.subarray(0,a))}n.end()}}finally{if(typeof i==`number`)try{t.closeSync(i)}catch{}}},(e,n)=>{let r=new Jn(e),i=e.maxReadSize||16*1024*1024,a=e.file;return new Promise((e,n)=>{r.on(`error`,n),r.on(`end`,e),t.stat(a,(e,t)=>{if(e)n(e);else{let e=new dt(a,{readSize:i,size:t.size});e.on(`error`,n),e.pipe(r)}})})},e=>new Jn(e),e=>new Jn(e),(e,t)=>{t?.length&&Zn(e,t),e.noResume||Xn(e)}),$n=(e,t,n)=>(e&=4095,n&&(e=(e|384)&-19),t&&(e&256&&(e|=64),e&32&&(e|=8),e&4&&(e|=1)),e),{isAbsolute:er,parse:tr}=o,nr=e=>{let t=``,n=tr(e);for(;er(e)||n.root;){let r=e.charAt(0)===`/`&&e.slice(0,4)!==`//?/`?`/`:n.root;e=e.slice(r.length),t+=r,n=tr(e)}return[t,e]},rr=[`|`,`<`,`>`,`?`,`:`],ir=rr.map(e=>String.fromCodePoint(61440+Number(e.codePointAt(0)))),ar=new Map(rr.map((e,t)=>[e,ir[t]])),or=new Map(ir.map((e,t)=>[e,rr[t]])),sr=e=>rr.reduce((e,t)=>e.split(t).join(ar.get(t)),e),cr=e=>ir.reduce((e,t)=>e.split(t).join(or.get(t)),e),lr=(e,t)=>t?(e=z(e).replace(/^\.(\/|$)/,``),Yn(t)+`/`+e):z(e),ur=16*1024*1024,dr=Symbol(`process`),fr=Symbol(`file`),pr=Symbol(`directory`),mr=Symbol(`symlink`),hr=Symbol(`hardlink`),gr=Symbol(`header`),_r=Symbol(`read`),vr=Symbol(`lstat`),yr=Symbol(`onlstat`),br=Symbol(`onread`),xr=Symbol(`onreadlink`),Sr=Symbol(`openfile`),Cr=Symbol(`onopenfile`),J=Symbol(`close`),wr=Symbol(`mode`),Tr=Symbol(`awaitDrain`),Er=Symbol(`ondrain`),Y=Symbol(`prefix`),Dr=class extends Ue{path;portable;myuid=process.getuid&&process.getuid()||0;myuser=process.env.USER||``;maxReadSize;linkCache;statCache;preservePaths;cwd;strict;mtime;noPax;noMtime;prefix;fd;blockLen=0;blockRemain=0;buf;pos=0;remain=0;length=0;offset=0;win32;absolute;header;type;linkpath;stat;onWriteEntry;#e=!1;constructor(e,t={}){let n=St(t);super(),this.path=z(e),this.portable=!!n.portable,this.maxReadSize=n.maxReadSize||ur,this.linkCache=n.linkCache||new Map,this.statCache=n.statCache||new Map,this.preservePaths=!!n.preservePaths,this.cwd=z(n.cwd||process.cwd()),this.strict=!!n.strict,this.noPax=!!n.noPax,this.noMtime=!!n.noMtime,this.mtime=n.mtime,this.prefix=n.prefix?z(n.prefix):void 0,this.onWriteEntry=n.onWriteEntry,typeof n.onwarn==`function`&&this.on(`warn`,n.onwarn);let r=!1;if(!this.preservePaths){let[e,t]=nr(this.path);e&&typeof t==`string`&&(this.path=t,r=e)}this.win32=!!n.win32||process.platform===`win32`,this.win32&&(this.path=cr(this.path.replaceAll(/\\/g,`/`)),e=e.replaceAll(/\\/g,`/`)),this.absolute=z(n.absolute||p.resolve(this.cwd,e)),this.path===``&&(this.path=`./`),r&&this.warn(`TAR_ENTRY_INFO`,`stripping ${r} from absolute path`,{entry:this,path:r+this.path});let i=this.statCache.get(this.absolute);i?this[yr](i):this[vr]()}warn(e,t,n={}){return bn(this,e,t,n)}emit(e,...t){return e===`error`&&(this.#e=!0),super.emit(e,...t)}[vr](){d.lstat(this.absolute,(e,t)=>{if(e)return this.emit(`error`,e);this[yr](t)})}[yr](e){this.statCache.set(this.absolute,e),this.stat=e,e.isFile()||(e.size=0),this.type=Ar(e),this.emit(`stat`,e),this[dr]()}[dr](){switch(this.type){case`File`:return this[fr]();case`Directory`:return this[pr]();case`SymbolicLink`:return this[mr]();default:return this.end()}}[wr](e){return $n(e,this.type===`Directory`,this.portable)}[Y](e){return lr(e,this.prefix)}[gr](){if(!this.stat)throw Error(`cannot write header before stat`);this.type===`Directory`&&this.portable&&(this.noMtime=!0),this.onWriteEntry?.(this),this.header=new I({path:this[Y](this.path),linkpath:this.type===`Link`&&this.linkpath!==void 0?this[Y](this.linkpath):this.linkpath,mode:this[wr](this.stat.mode),uid:this.portable?void 0:this.stat.uid,gid:this.portable?void 0:this.stat.gid,size:this.stat.size,mtime:this.noMtime?void 0:this.mtime||this.stat.mtime,type:this.type===`Unsupported`?void 0:this.type,uname:this.portable?void 0:this.stat.uid===this.myuid?this.myuser:``,atime:this.portable?void 0:this.stat.atime,ctime:this.portable?void 0:this.stat.ctime}),this.header.encode()&&!this.noPax&&super.write(new hn({atime:this.portable?void 0:this.header.atime,ctime:this.portable?void 0:this.header.ctime,gid:this.portable?void 0:this.header.gid,mtime:this.noMtime?void 0:this.mtime||this.header.mtime,path:this[Y](this.path),linkpath:this.type===`Link`&&this.linkpath!==void 0?this[Y](this.linkpath):this.linkpath,size:this.header.size,uid:this.portable?void 0:this.header.uid,uname:this.portable?void 0:this.header.uname,dev:this.portable?void 0:this.stat.dev,ino:this.portable?void 0:this.stat.ino,nlink:this.portable?void 0:this.stat.nlink}).encode());let e=this.header?.block;if(!e)throw Error(`failed to encode header`);super.write(e)}[pr](){if(!this.stat)throw Error(`cannot create directory entry without stat`);this.path.slice(-1)!==`/`&&(this.path+=`/`),this.stat.size=0,this[gr](),this.end()}[mr](){d.readlink(this.absolute,(e,t)=>{if(e)return this.emit(`error`,e);this[xr](t)})}[xr](e){this.linkpath=z(e),this[gr](),this.end()}[hr](e){if(!this.stat)throw Error(`cannot create link entry without stat`);this.type=`Link`,this.linkpath=z(p.relative(this.cwd,e)),this.stat.size=0,this[gr](),this.end()}[fr](){if(!this.stat)throw Error(`cannot create file entry without stat`);if(this.stat.nlink>1){let e=`${this.stat.dev}:${this.stat.ino}`,t=this.linkCache.get(e);if(t?.indexOf(this.cwd)===0)return this[hr](t);this.linkCache.set(e,this.absolute)}if(this[gr](),this.stat.size===0)return this.end();this[Sr]()}[Sr](){d.open(this.absolute,`r`,(e,t)=>{if(e)return this.emit(`error`,e);this[Cr](t)})}[Cr](e){if(this.fd=e,this.#e)return this[J]();if(!this.stat)throw Error(`should stat before calling onopenfile`);this.blockLen=512*Math.ceil(this.stat.size/512),this.blockRemain=this.blockLen;let t=Math.min(this.blockLen,this.maxReadSize);this.buf=Buffer.allocUnsafe(t),this.offset=0,this.pos=0,this.remain=this.stat.size,this.length=this.buf.length,this[_r]()}[_r](){let{fd:e,buf:t,offset:n,length:r,pos:i}=this;if(e===void 0||t===void 0)throw Error(`cannot read file without first opening`);d.read(e,t,n,r,i,(e,t)=>{if(e)return this[J](()=>this.emit(`error`,e));this[br](t)})}[J](e=()=>{}){this.fd!==void 0&&d.close(this.fd,e)}[br](e){if(e<=0&&this.remain>0){let e=Object.assign(Error(`encountered unexpected EOF`),{path:this.absolute,syscall:`read`,code:`EOF`});return this[J](()=>this.emit(`error`,e))}if(e>this.remain){let e=Object.assign(Error(`did not encounter expected EOF`),{path:this.absolute,syscall:`read`,code:`EOF`});return this[J](()=>this.emit(`error`,e))}if(!this.buf)throw Error(`should have created buffer prior to reading`);if(e===this.remain)for(let t=e;t<this.length&&e<this.blockRemain;t++)this.buf[t+this.offset]=0,e++,this.remain++;let t=this.offset===0&&e===this.buf.length?this.buf:this.buf.subarray(this.offset,this.offset+e);this.write(t)?this[Er]():this[Tr](()=>this[Er]())}[Tr](e){this.once(`drain`,e)}write(e,t,n){if(typeof t==`function`&&(n=t,t=void 0),typeof e==`string`&&(e=Buffer.from(e,typeof t==`string`?t:`utf8`)),this.blockRemain<e.length){let e=Object.assign(Error(`writing more data than expected`),{path:this.absolute});return this.emit(`error`,e)}return this.remain-=e.length,this.blockRemain-=e.length,this.pos+=e.length,this.offset+=e.length,super.write(e,null,n)}[Er](){if(!this.remain)return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),this[J](e=>e?this.emit(`error`,e):this.end());if(!this.buf)throw Error(`buffer lost somehow in ONDRAIN`);this.offset>=this.length&&(this.buf=Buffer.allocUnsafe(Math.min(this.blockRemain,this.buf.length)),this.offset=0),this.length=this.buf.length-this.offset,this[_r]()}},Or=class extends Dr{sync=!0;[vr](){this[yr](d.lstatSync(this.absolute))}[mr](){this[xr](d.readlinkSync(this.absolute))}[Sr](){this[Cr](d.openSync(this.absolute,`r`))}[_r](){let e=!0;try{let{fd:t,buf:n,offset:r,length:i,pos:a}=this;if(t===void 0||n===void 0)throw Error(`fd and buf must be set in READ method`);let o=d.readSync(t,n,r,i,a);this[br](o),e=!1}finally{if(e)try{this[J](()=>{})}catch{}}}[Tr](e){e()}[J](e=()=>{}){this.fd!==void 0&&d.closeSync(this.fd),e()}},kr=class extends Ue{blockLen=0;blockRemain=0;buf=0;pos=0;remain=0;length=0;preservePaths;portable;strict;noPax;noMtime;readEntry;type;prefix;path;mode;uid;gid;uname;gname;header;mtime;atime;ctime;linkpath;size;onWriteEntry;warn(e,t,n={}){return bn(this,e,t,n)}constructor(e,t={}){let n=St(t);super(),this.preservePaths=!!n.preservePaths,this.portable=!!n.portable,this.strict=!!n.strict,this.noPax=!!n.noPax,this.noMtime=!!n.noMtime,this.onWriteEntry=n.onWriteEntry,this.readEntry=e;let{type:r}=e;if(r===`Unsupported`)throw Error(`writing entry that should be ignored`);this.type=r,this.type===`Directory`&&this.portable&&(this.noMtime=!0),this.prefix=n.prefix,this.path=z(e.path),this.mode=e.mode===void 0?void 0:this[wr](e.mode),this.uid=this.portable?void 0:e.uid,this.gid=this.portable?void 0:e.gid,this.uname=this.portable?void 0:e.uname,this.gname=this.portable?void 0:e.gname,this.size=e.size,this.mtime=this.noMtime?void 0:n.mtime||e.mtime,this.atime=this.portable?void 0:e.atime,this.ctime=this.portable?void 0:e.ctime,this.linkpath=e.linkpath===void 0?void 0:z(e.linkpath),typeof n.onwarn==`function`&&this.on(`warn`,n.onwarn);let i=!1;if(!this.preservePaths){let[e,t]=nr(this.path);e&&typeof t==`string`&&(this.path=t,i=e)}this.remain=e.size,this.blockRemain=e.startBlockSize,this.onWriteEntry?.(this),this.header=new I({path:this[Y](this.path),linkpath:this.type===`Link`&&this.linkpath!==void 0?this[Y](this.linkpath):this.linkpath,mode:this.mode,uid:this.portable?void 0:this.uid,gid:this.portable?void 0:this.gid,size:this.size,mtime:this.noMtime?void 0:this.mtime,type:this.type,uname:this.portable?void 0:this.uname,atime:this.portable?void 0:this.atime,ctime:this.portable?void 0:this.ctime}),i&&this.warn(`TAR_ENTRY_INFO`,`stripping ${i} from absolute path`,{entry:this,path:i+this.path}),this.header.encode()&&!this.noPax&&super.write(new hn({atime:this.portable?void 0:this.atime,ctime:this.portable?void 0:this.ctime,gid:this.portable?void 0:this.gid,mtime:this.noMtime?void 0:this.mtime,path:this[Y](this.path),linkpath:this.type===`Link`&&this.linkpath!==void 0?this[Y](this.linkpath):this.linkpath,size:this.size,uid:this.portable?void 0:this.uid,uname:this.portable?void 0:this.uname,dev:this.portable?void 0:this.readEntry.dev,ino:this.portable?void 0:this.readEntry.ino,nlink:this.portable?void 0:this.readEntry.nlink}).encode());let a=this.header?.block;if(!a)throw Error(`failed to encode header`);super.write(a),e.pipe(this)}[Y](e){return lr(e,this.prefix)}[wr](e){return $n(e,this.type===`Directory`,this.portable)}write(e,t,n){typeof t==`function`&&(n=t,t=void 0),typeof e==`string`&&(e=Buffer.from(e,typeof t==`string`?t:`utf8`));let r=e.length;if(r>this.blockRemain)throw Error(`writing more to entry than is appropriate`);return this.blockRemain-=r,super.write(e,n)}end(e,t,n){return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),typeof e==`function`&&(n=e,t=void 0,e=void 0),typeof t==`function`&&(n=t,t=void 0),typeof e==`string`&&(e=Buffer.from(e,t??`utf8`)),n&&this.once(`finish`,n),e?super.end(e,n):super.end(n),this}},Ar=e=>e.isFile()?`File`:e.isDirectory()?`Directory`:e.isSymbolicLink()?`SymbolicLink`:`Unsupported`,jr=class e{tail;head;length=0;static create(t=[]){return new e(t)}constructor(e=[]){for(let t of e)this.push(t)}*[Symbol.iterator](){for(let e=this.head;e;e=e.next)yield e.value}removeNode(e){if(e.list!==this)throw Error(`removing node which does not belong to this list`);let t=e.next,n=e.prev;return t&&(t.prev=n),n&&(n.next=t),e===this.head&&(this.head=t),e===this.tail&&(this.tail=n),this.length--,e.next=void 0,e.prev=void 0,e.list=void 0,t}unshiftNode(e){if(e===this.head)return;e.list&&e.list.removeNode(e);let t=this.head;e.list=this,e.next=t,t&&(t.prev=e),this.head=e,this.tail||=e,this.length++}pushNode(e){if(e===this.tail)return;e.list&&e.list.removeNode(e);let t=this.tail;e.list=this,e.prev=t,t&&(t.next=e),this.tail=e,this.head||=e,this.length++}push(...e){for(let t=0,n=e.length;t<n;t++)Nr(this,e[t]);return this.length}unshift(...e){for(var t=0,n=e.length;t<n;t++)Pr(this,e[t]);return this.length}pop(){if(!this.tail)return;let e=this.tail.value,t=this.tail;return this.tail=this.tail.prev,this.tail?this.tail.next=void 0:this.head=void 0,t.list=void 0,this.length--,e}shift(){if(!this.head)return;let e=this.head.value,t=this.head;return this.head=this.head.next,this.head?this.head.prev=void 0:this.tail=void 0,t.list=void 0,this.length--,e}forEach(e,t){t||=this;for(let n=this.head,r=0;n;r++)e.call(t,n.value,r,this),n=n.next}forEachReverse(e,t){t||=this;for(let n=this.tail,r=this.length-1;n;r--)e.call(t,n.value,r,this),n=n.prev}get(e){let t=0,n=this.head;for(;n&&t<e;t++)n=n.next;if(t===e&&n)return n.value}getReverse(e){let t=0,n=this.tail;for(;n&&t<e;t++)n=n.prev;if(t===e&&n)return n.value}map(t,n){n||=this;let r=new e;for(let e=this.head;e;)r.push(t.call(n,e.value,this)),e=e.next;return r}mapReverse(t,n){n||=this;var r=new e;for(let e=this.tail;e;)r.push(t.call(n,e.value,this)),e=e.prev;return r}reduce(e,t){let n,r=this.head;if(arguments.length>1)n=t;else if(this.head)r=this.head.next,n=this.head.value;else throw TypeError(`Reduce of empty list with no initial value`);for(var i=0;r;i++)n=e(n,r.value,i),r=r.next;return n}reduceReverse(e,t){let n,r=this.tail;if(arguments.length>1)n=t;else if(this.tail)r=this.tail.prev,n=this.tail.value;else throw TypeError(`Reduce of empty list with no initial value`);for(let t=this.length-1;r;t--)n=e(n,r.value,t),r=r.prev;return n}toArray(){let e=Array(this.length);for(let t=0,n=this.head;n;t++)e[t]=n.value,n=n.next;return e}toArrayReverse(){let e=Array(this.length);for(let t=0,n=this.tail;n;t++)e[t]=n.value,n=n.prev;return e}slice(t=0,n=this.length){n<0&&(n+=this.length),t<0&&(t+=this.length);let r=new e;if(n<t||n<0)return r;t<0&&(t=0),n>this.length&&(n=this.length);let i=this.head,a=0;for(a=0;i&&a<t;a++)i=i.next;for(;i&&a<n;a++,i=i.next)r.push(i.value);return r}sliceReverse(t=0,n=this.length){n<0&&(n+=this.length),t<0&&(t+=this.length);let r=new e;if(n<t||n<0)return r;t<0&&(t=0),n>this.length&&(n=this.length);let i=this.length,a=this.tail;for(;a&&i>n;i--)a=a.prev;for(;a&&i>t;i--,a=a.prev)r.push(a.value);return r}splice(e,t=0,...n){e>this.length&&(e=this.length-1),e<0&&(e=this.length+e);let r=this.head;for(let t=0;r&&t<e;t++)r=r.next;let i=[];for(let e=0;r&&e<t;e++)i.push(r.value),r=this.removeNode(r);r?r!==this.tail&&(r=r.prev):r=this.tail;for(let e of n)r=Mr(this,r,e);return i}reverse(){let e=this.head,t=this.tail;for(let t=e;t;t=t.prev){let e=t.prev;t.prev=t.next,t.next=e}return this.head=t,this.tail=e,this}};function Mr(e,t,n){let r=new Fr(n,t,t?t.next:e.head,e);return r.next===void 0&&(e.tail=r),r.prev===void 0&&(e.head=r),e.length++,r}function Nr(e,t){e.tail=new Fr(t,e.tail,void 0,e),e.head||=e.tail,e.length++}function Pr(e,t){e.head=new Fr(t,void 0,e.head,e),e.tail||=e.head,e.length++}var Fr=class{list;next;prev;value;constructor(e,t,n,r){this.list=r,this.value=e,t?(t.next=this,this.prev=t):this.prev=void 0,n?(n.prev=this,this.next=n):this.next=void 0}},Ir=class{path;absolute;entry;stat;readdir;pending=!1;ignore=!1;piped=!1;constructor(e,t){this.path=e||`./`,this.absolute=t}},Lr=Buffer.alloc(1024),Rr=Symbol(`onStat`),zr=Symbol(`ended`),X=Symbol(`queue`),Br=Symbol(`current`),Vr=Symbol(`process`),Hr=Symbol(`processing`),Ur=Symbol(`processJob`),Z=Symbol(`jobs`),Wr=Symbol(`jobDone`),Gr=Symbol(`addFSEntry`),Kr=Symbol(`addTarEntry`),qr=Symbol(`stat`),Jr=Symbol(`readdir`),Yr=Symbol(`onreaddir`),Xr=Symbol(`pipe`),Zr=Symbol(`entry`),Qr=Symbol(`entryOpt`),$r=Symbol(`writeEntryClass`),ei=Symbol(`write`),ti=Symbol(`ondrain`),ni=class extends Ue{sync=!1;opt;cwd;maxReadSize;preservePaths;strict;noPax;prefix;linkCache;statCache;file;portable;zip;readdirCache;noDirRecurse;follow;noMtime;mtime;filter;jobs;[$r];onWriteEntry;[X];[Z]=0;[Hr]=!1;[zr]=!1;constructor(e={}){if(super(),this.opt=e,this.file=e.file||``,this.cwd=e.cwd||process.cwd(),this.maxReadSize=e.maxReadSize,this.preservePaths=!!e.preservePaths,this.strict=!!e.strict,this.noPax=!!e.noPax,this.prefix=z(e.prefix||``),this.linkCache=e.linkCache||new Map,this.statCache=e.statCache||new Map,this.readdirCache=e.readdirCache||new Map,this.onWriteEntry=e.onWriteEntry,this[$r]=Dr,typeof e.onwarn==`function`&&this.on(`warn`,e.onwarn),this.portable=!!e.portable,e.gzip||e.brotli||e.zstd){if(+!!e.gzip+ +!!e.brotli+ +!!e.zstd>1)throw TypeError(`gzip, brotli, zstd are mutually exclusive`);if(e.gzip&&(typeof e.gzip!=`object`&&(e.gzip={}),this.portable&&(e.gzip.portable=!0),this.zip=new Pt(e.gzip)),e.brotli&&(typeof e.brotli!=`object`&&(e.brotli={}),this.zip=new Lt(e.brotli)),e.zstd&&(typeof e.zstd!=`object`&&(e.zstd={}),this.zip=new Bt(e.zstd)),!this.zip)throw Error(`impossible`);let t=this.zip;t.on(`data`,e=>super.write(e)),t.on(`end`,()=>super.end()),t.on(`drain`,()=>this[ti]()),this.on(`resume`,()=>t.resume())}else this.on(`drain`,this[ti]);this.noDirRecurse=!!e.noDirRecurse,this.follow=!!e.follow,this.noMtime=!!e.noMtime,e.mtime&&(this.mtime=e.mtime),this.filter=typeof e.filter==`function`?e.filter:()=>!0,this[X]=new jr,this[Z]=0,this.jobs=Number(e.jobs)||4,this[Hr]=!1,this[zr]=!1}[ei](e){return super.write(e)}add(e){return this.write(e),this}end(e,t,n){return typeof e==`function`&&(n=e,e=void 0),typeof t==`function`&&(n=t,t=void 0),e&&this.add(e),this[zr]=!0,this[Vr](),n&&n(),this}write(e){if(this[zr])throw Error(`write after end`);return e instanceof yn?this[Kr](e):this[Gr](e),this.flowing}[Kr](e){let t=z(p.resolve(this.cwd,e.path));if(!this.filter(e.path,e))e.resume();else{let n=new Ir(e.path,t);n.entry=new kr(e,this[Qr](n)),n.entry.on(`end`,()=>this[Wr](n)),this[Z]+=1,this[X].push(n)}this[Vr]()}[Gr](e){let t=z(p.resolve(this.cwd,e));this[X].push(new Ir(e,t)),this[Vr]()}[qr](e){e.pending=!0,this[Z]+=1,d[this.follow?`stat`:`lstat`](e.absolute,(t,n)=>{e.pending=!1,--this[Z],t?this.emit(`error`,t):this[Rr](e,n)})}[Rr](e,t){this.statCache.set(e.absolute,t),e.stat=t,this.filter(e.path,t)?t.isFile()&&t.nlink>1&&e===this[Br]&&!this.linkCache.get(`${t.dev}:${t.ino}`)&&!this.sync&&this[Ur](e):e.ignore=!0,this[Vr]()}[Jr](e){e.pending=!0,this[Z]+=1,d.readdir(e.absolute,(t,n)=>{if(e.pending=!1,--this[Z],t)return this.emit(`error`,t);this[Yr](e,n)})}[Yr](e,t){this.readdirCache.set(e.absolute,t),e.readdir=t,this[Vr]()}[Vr](){if(!this[Hr]){this[Hr]=!0;for(let e=this[X].head;e&&this[Z]<this.jobs;e=e.next)if(this[Ur](e.value),e.value.ignore){let t=e.next;this[X].removeNode(e),e.next=t}this[Hr]=!1,this[zr]&&this[X].length===0&&this[Z]===0&&(this.zip?this.zip.end(Lr):(super.write(Lr),super.end()))}}get[Br](){return this[X]&&this[X].head&&this[X].head.value}[Wr](e){this[X].shift(),--this[Z],this[Vr]()}[Ur](e){if(!e.pending){if(e.entry){e===this[Br]&&!e.piped&&this[Xr](e);return}if(!e.stat){let t=this.statCache.get(e.absolute);t?this[Rr](e,t):this[qr](e)}if(e.stat&&!e.ignore){if(!this.noDirRecurse&&e.stat.isDirectory()&&!e.readdir){let t=this.readdirCache.get(e.absolute);if(t?this[Yr](e,t):this[Jr](e),!e.readdir)return}if(e.entry=this[Zr](e),!e.entry){e.ignore=!0;return}e===this[Br]&&!e.piped&&this[Xr](e)}}}[Qr](e){return{onwarn:(e,t,n)=>this.warn(e,t,n),noPax:this.noPax,cwd:this.cwd,absolute:e.absolute,preservePaths:this.preservePaths,maxReadSize:this.maxReadSize,strict:this.strict,portable:this.portable,linkCache:this.linkCache,statCache:this.statCache,noMtime:this.noMtime,mtime:this.mtime,prefix:this.prefix,onWriteEntry:this.onWriteEntry}}[Zr](e){this[Z]+=1;try{return new this[$r](e.path,this[Qr](e)).on(`end`,()=>this[Wr](e)).on(`error`,e=>this.emit(`error`,e))}catch(e){this.emit(`error`,e)}}[ti](){this[Br]&&this[Br].entry&&this[Br].entry.resume()}[Xr](e){e.piped=!0,e.readdir&&e.readdir.forEach(t=>{let n=e.path,r=n===`./`?``:n.replace(/\/*$/,`/`);this[Gr](r+t)});let t=e.entry,n=this.zip;if(!t)throw Error(`cannot pipe without source`);n?t.on(`data`,e=>{n.write(e)||t.pause()}):t.on(`data`,e=>{super.write(e)||t.pause()})}pause(){return this.zip&&this.zip.pause(),super.pause()}warn(e,t,n={}){bn(this,e,t,n)}},ri=class extends ni{sync=!0;constructor(e){super(e),this[$r]=Or}pause(){}resume(){}[qr](e){let t=this.follow?`statSync`:`lstatSync`;this[Rr](e,d[t](e.absolute))}[Jr](e){this[Yr](e,d.readdirSync(e.absolute))}[Xr](e){let t=e.entry,n=this.zip;if(e.readdir&&e.readdir.forEach(t=>{let n=e.path,r=n===`./`?``:n.replace(/\/*$/,`/`);this[Gr](r+t)}),!t)throw Error(`Cannot pipe without source`);n?t.on(`data`,e=>{n.write(e)}):t.on(`data`,e=>{super[ei](e)})}},ii=(e,t)=>{let n=new ri(e),r=new mt(e.file,{mode:e.mode||438});n.pipe(r),oi(n,t)},ai=(e,t)=>{let n=new ni(e),r=new pt(e.file,{mode:e.mode||438});n.pipe(r);let i=new Promise((e,t)=>{r.on(`error`,t),r.on(`close`,e),n.on(`error`,t)});return si(n,t).catch(e=>n.emit(`error`,e)),i},oi=(e,t)=>{t.forEach(t=>{t.charAt(0)===`@`?Qn({file:n.resolve(e.cwd,t.slice(1)),sync:!0,noResume:!0,onReadEntry:t=>e.add(t)}):e.add(t)}),e.end()},si=async(e,t)=>{for(let r of t)r.charAt(0)===`@`?await Qn({file:n.resolve(String(e.cwd),r.slice(1)),noResume:!0,onReadEntry:t=>{e.add(t)}}):e.add(r);e.end()},ci=Ct(ii,ai,(e,t)=>{let n=new ri(e);return oi(n,t),n},(e,t)=>{let n=new ni(e);return si(n,t).catch(e=>n.emit(`error`,e)),n},(e,t)=>{if(!t?.length)throw TypeError(`no paths specified to add to archive`)}),li=(process.env.__FAKE_PLATFORM__||process.platform)===`win32`,{O_CREAT:ui,O_NOFOLLOW:di,O_TRUNC:fi,O_WRONLY:pi}=d.constants,mi=Number(process.env.__FAKE_FS_O_FILENAME__)||d.constants.UV_FS_O_FILEMAP||0,hi=li&&!!mi,gi=512*1024,_i=mi|fi|ui|pi,vi=!li&&typeof di==`number`?di|fi|ui|pi:null,yi=vi===null?hi?e=>e<gi?_i:`w`:()=>`w`:()=>vi,bi=(e,n,r)=>{try{return t.lchownSync(e,n,r)}catch(e){if(e?.code!==`ENOENT`)throw e}},xi=(e,n,r,i)=>{t.lchown(e,n,r,e=>{i(e&&e?.code!==`ENOENT`?e:null)})},Si=(e,t,r,i,a)=>{t.isDirectory()?Ci(n.resolve(e,t.name),r,i,o=>{if(o)return a(o);xi(n.resolve(e,t.name),r,i,a)}):xi(n.resolve(e,t.name),r,i,a)},Ci=(e,n,r,i)=>{t.readdir(e,{withFileTypes:!0},(t,a)=>{if(t){if(t.code===`ENOENT`)return i();if(t.code!==`ENOTDIR`&&t.code!==`ENOTSUP`)return i(t)}if(t||!a.length)return xi(e,n,r,i);let o=a.length,s=null,c=t=>{if(!s){if(t)return i(s=t);if(--o===0)return xi(e,n,r,i)}};for(let t of a)Si(e,t,n,r,c)})},wi=(e,t,r,i)=>{t.isDirectory()&&Ti(n.resolve(e,t.name),r,i),bi(n.resolve(e,t.name),r,i)},Ti=(e,n,r)=>{let i;try{i=t.readdirSync(e,{withFileTypes:!0})}catch(t){let i=t;if(i?.code===`ENOENT`)return;if(i?.code===`ENOTDIR`||i?.code===`ENOTSUP`)return bi(e,n,r);throw i}for(let t of i)wi(e,t,n,r);return bi(e,n,r)},Ei=class extends Error{path;code;syscall=`chdir`;constructor(e,t){super(`${t}: Cannot cd into '${e}'`),this.path=e,this.code=t}get name(){return`CwdError`}},Di=class extends Error{path;symlink;syscall=`symlink`;code=`TAR_SYMLINK_ERROR`;constructor(e,t){super(`TAR_SYMLINK_ERROR: Cannot extract through symbolic link`),this.symlink=e,this.path=t}get name(){return`SymlinkError`}},Oi=(e,n)=>{t.stat(e,(t,r)=>{(t||!r.isDirectory())&&(t=new Ei(e,t?.code||`ENOTDIR`)),n(t)})},ki=(e,r,i)=>{e=z(e);let a=r.umask??18,o=r.mode|448,c=(o&a)!==0,l=r.uid,u=r.gid,d=typeof l==`number`&&typeof u==`number`&&(l!==r.processUid||u!==r.processGid),f=r.preserve,ee=r.unlink,p=z(r.cwd),m=(n,r)=>{n?i(n):r&&d?Ci(r,l,u,e=>m(e)):c?t.chmod(e,o,i):i()};if(e===p)return Oi(e,m);if(f)return s.mkdir(e,{mode:o,recursive:!0}).then(e=>m(null,e??void 0),m);Ai(p,z(n.relative(p,e)).split(`/`),o,ee,p,void 0,m)},Ai=(e,r,i,a,o,s,c)=>{if(r.length===0)return c(null,s);let l=r.shift(),u=z(n.resolve(e+`/`+l));t.mkdir(u,i,ji(u,r,i,a,o,s,c))},ji=(e,n,r,i,a,o,s)=>c=>{c?t.lstat(e,(l,u)=>{if(l)l.path=l.path&&z(l.path),s(l);else if(u.isDirectory())Ai(e,n,r,i,a,o,s);else if(i)t.unlink(e,c=>{if(c)return s(c);t.mkdir(e,r,ji(e,n,r,i,a,o,s))});else{if(u.isSymbolicLink())return s(new Di(e,e+`/`+n.join(`/`)));s(c)}}):(o||=e,Ai(e,n,r,i,a,o,s))},Mi=e=>{let n=!1,r;try{n=t.statSync(e).isDirectory()}catch(e){r=e?.code}finally{if(!n)throw new Ei(e,r??`ENOTDIR`)}},Ni=(e,r)=>{e=z(e);let i=r.umask??18,a=r.mode|448,o=(a&i)!==0,s=r.uid,c=r.gid,l=typeof s==`number`&&typeof c==`number`&&(s!==r.processUid||c!==r.processGid),u=r.preserve,d=r.unlink,f=z(r.cwd),ee=n=>{n&&l&&Ti(n,s,c),o&&t.chmodSync(e,a)};if(e===f)return Mi(f),ee();if(u)return ee(t.mkdirSync(e,{mode:a,recursive:!0})??void 0);let p=z(n.relative(f,e)).split(`/`),m;for(let e=p.shift(),r=f;e&&(r+=`/`+e);e=p.shift()){r=z(n.resolve(r));try{t.mkdirSync(r,a),m||=r}catch{let e=t.lstatSync(r);if(e.isDirectory())continue;if(d){t.unlinkSync(r),t.mkdirSync(r,a),m||=r;continue}else if(e.isSymbolicLink())return new Di(r,r+`/`+p.join(`/`))}}return ee(m)},Pi=Object.create(null),Fi=1e4,Ii=new Set,Li=e=>{Ii.has(e)?Ii.delete(e):Pi[e]=e.normalize(`NFD`).toLocaleLowerCase(`en`).toLocaleUpperCase(`en`),Ii.add(e);let t=Pi[e],n=Ii.size-Fi;if(n>Fi/10){for(let e of Ii)if(Ii.delete(e),delete Pi[e],--n<=0)break}return t},Ri=(process.env.TESTING_TAR_FAKE_PLATFORM||process.platform)===`win32`,zi=e=>e.split(`/`).slice(0,-1).reduce((e,t)=>{let n=e.at(-1);return n!==void 0&&(t=i(n,t)),e.push(t||`/`),e},[]),Bi=class{#e=new Map;#t=new Map;#n=new Set;reserve(e,t){e=Ri?[`win32 parallelization disabled`]:e.map(e=>Yn(i(Li(e))));let n=new Set(e.map(e=>zi(e)).reduce((e,t)=>e.concat(t)));this.#t.set(t,{dirs:n,paths:e});for(let n of e){let e=this.#e.get(n);e?e.push(t):this.#e.set(n,[t])}for(let e of n){let n=this.#e.get(e);if(!n)this.#e.set(e,[new Set([t])]);else{let e=n.at(-1);e instanceof Set?e.add(t):n.push(new Set([t]))}}return this.#i(t)}#r(e){let t=this.#t.get(e);if(!t)throw Error(`function does not have any path reservations`);return{paths:t.paths.map(e=>this.#e.get(e)),dirs:[...t.dirs].map(e=>this.#e.get(e))}}check(e){let{paths:t,dirs:n}=this.#r(e);return t.every(t=>t&&t[0]===e)&&n.every(t=>t&&t[0]instanceof Set&&t[0].has(e))}#i(e){return this.#n.has(e)||!this.check(e)?!1:(this.#n.add(e),e(()=>this.#a(e)),!0)}#a(e){if(!this.#n.has(e))return!1;let t=this.#t.get(e);if(!t)throw Error(`invalid reservation`);let{paths:n,dirs:r}=t,i=new Set;for(let t of n){let n=this.#e.get(t);if(!n||n?.[0]!==e)continue;let r=n[1];if(!r){this.#e.delete(t);continue}if(n.shift(),typeof r==`function`)i.add(r);else for(let e of r)i.add(e)}for(let t of r){let n=this.#e.get(t),r=n?.[0];if(!(!n||!(r instanceof Set)))if(r.size===1&&n.length===1){this.#e.delete(t);continue}else if(r.size===1){n.shift();let e=n[0];typeof e==`function`&&i.add(e)}else r.delete(e)}return this.#n.delete(e),i.forEach(e=>this.#i(e)),!0}},Vi=()=>process.umask(),Hi=Symbol(`onEntry`),Ui=Symbol(`checkFs`),Wi=Symbol(`checkFs2`),Gi=Symbol(`isReusable`),Q=Symbol(`makeFs`),Ki=Symbol(`file`),qi=Symbol(`directory`),Ji=Symbol(`link`),Yi=Symbol(`symlink`),Xi=Symbol(`hardlink`),Zi=Symbol(`ensureNoSymlink`),Qi=Symbol(`unsupported`),$i=Symbol(`checkPath`),ea=Symbol(`stripAbsolutePath`),ta=Symbol(`mkdir`),$=Symbol(`onError`),na=Symbol(`pending`),ra=Symbol(`pend`),ia=Symbol(`unpend`),aa=Symbol(`ended`),oa=Symbol(`maybeClose`),sa=Symbol(`skip`),ca=Symbol(`doChown`),la=Symbol(`uid`),ua=Symbol(`gid`),da=Symbol(`checkedCwd`),fa=(process.env.TESTING_TAR_FAKE_PLATFORM||process.platform)===`win32`,pa=1024,ma=(e,n)=>{if(!fa)return t.unlink(e,n);let r=e+`.DELETE.`+se(16).toString(`hex`);t.rename(e,r,e=>{if(e)return n(e);t.unlink(r,n)})},ha=e=>{if(!fa)return t.unlinkSync(e);let n=e+`.DELETE.`+se(16).toString(`hex`);t.renameSync(e,n),t.unlinkSync(n)},ga=(e,t,n)=>e!==void 0&&e===e>>>0?e:t!==void 0&&t===t>>>0?t:n,_a=class extends Jn{[aa]=!1;[da]=!1;[na]=0;reservations=new Bi;transform;writable=!0;readable=!1;uid;gid;setOwner;preserveOwner;processGid;processUid;maxDepth;forceChown;win32;newer;keep;noMtime;preservePaths;unlink;cwd;strip;processUmask;umask;dmode;fmode;chmod;constructor(e={}){if(e.ondone=()=>{this[aa]=!0,this[oa]()},super(e),this.transform=e.transform,this.chmod=!!e.chmod,typeof e.uid==`number`||typeof e.gid==`number`){if(typeof e.uid!=`number`||typeof e.gid!=`number`)throw TypeError(`cannot set owner without number uid and gid`);if(e.preserveOwner)throw TypeError(`cannot preserve owner in archive and also set owner explicitly`);this.uid=e.uid,this.gid=e.gid,this.setOwner=!0}else this.uid=void 0,this.gid=void 0,this.setOwner=!1;this.preserveOwner=e.preserveOwner===void 0&&typeof e.uid!=`number`?!!(process.getuid&&process.getuid()===0):!!e.preserveOwner,this.processUid=(this.preserveOwner||this.setOwner)&&process.getuid?process.getuid():void 0,this.processGid=(this.preserveOwner||this.setOwner)&&process.getgid?process.getgid():void 0,this.maxDepth=typeof e.maxDepth==`number`?e.maxDepth:pa,this.forceChown=e.forceChown===!0,this.win32=!!e.win32||fa,this.newer=!!e.newer,this.keep=!!e.keep,this.noMtime=!!e.noMtime,this.preservePaths=!!e.preservePaths,this.unlink=!!e.unlink,this.cwd=z(n.resolve(e.cwd||process.cwd())),this.strip=Number(e.strip)||0,this.processUmask=this.chmod?typeof e.processUmask==`number`?e.processUmask:Vi():0,this.umask=typeof e.umask==`number`?e.umask:this.processUmask,this.dmode=e.dmode||511&~this.umask,this.fmode=e.fmode||438&~this.umask,this.on(`entry`,e=>this[Hi](e))}warn(e,t,n={}){return(e===`TAR_BAD_ARCHIVE`||e===`TAR_ABORT`)&&(n.recoverable=!1),super.warn(e,t,n)}[oa](){this[aa]&&this[na]===0&&(this.emit(`prefinish`),this.emit(`finish`),this.emit(`end`))}[ea](e,t){let r=e[t],{type:i}=e;if(!r||this.preservePaths)return!0;let[a,o]=nr(r),s=o.replaceAll(/\\/g,`/`).split(`/`);if(s.includes(`..`)||fa&&/^[a-z]:\.\.$/i.test(s[0]??``)){if(t===`path`||i===`Link`)return this.warn(`TAR_ENTRY_ERROR`,`${t} contains '..'`,{entry:e,[t]:r}),!1;let a=n.posix.dirname(e.path),o=n.posix.normalize(n.posix.join(a,s.join(`/`)));if(o.startsWith(`../`)||o===`..`)return this.warn(`TAR_ENTRY_ERROR`,`${t} escapes extraction directory`,{entry:e,[t]:r}),!1}return a&&(e[t]=String(o),this.warn(`TAR_ENTRY_INFO`,`stripping ${a} from absolute ${t}`,{entry:e,[t]:r})),!0}[$i](e){let t=z(e.path),r=t.split(`/`);if(this.strip){if(r.length<this.strip)return!1;if(e.type===`Link`){let t=z(String(e.linkpath)).split(`/`);if(t.length>=this.strip)e.linkpath=t.slice(this.strip).join(`/`);else return!1}r.splice(0,this.strip),e.path=r.join(`/`)}if(isFinite(this.maxDepth)&&r.length>this.maxDepth)return this.warn(`TAR_ENTRY_ERROR`,`path excessively deep`,{entry:e,path:t,depth:r.length,maxDepth:this.maxDepth}),!1;if(!this[ea](e,`path`)||!this[ea](e,`linkpath`))return!1;if(e.absolute=n.isAbsolute(e.path)?z(n.resolve(e.path)):z(n.resolve(this.cwd,e.path)),!this.preservePaths&&typeof e.absolute==`string`&&e.absolute.indexOf(this.cwd+`/`)!==0&&e.absolute!==this.cwd)return this.warn(`TAR_ENTRY_ERROR`,`path escaped extraction target`,{entry:e,path:z(e.path),resolvedPath:e.absolute,cwd:this.cwd}),!1;if(e.absolute===this.cwd&&e.type!==`Directory`&&e.type!==`GNUDumpDir`)return!1;if(this.win32){let{root:t}=n.win32.parse(String(e.absolute));e.absolute=t+sr(String(e.absolute).slice(t.length));let{root:r}=n.win32.parse(e.path);e.path=r+sr(e.path.slice(r.length))}return!0}[Hi](e){if(!this[$i](e))return e.resume();switch(oe.equal(typeof e.absolute,`string`),e.type){case`Directory`:case`GNUDumpDir`:e.mode&&(e.mode|=448);case`File`:case`OldFile`:case`ContiguousFile`:case`Link`:case`SymbolicLink`:return this[Ui](e);default:return this[Qi](e)}}[$](e,t){e.name===`CwdError`?this.emit(`error`,e):(this.warn(`TAR_ENTRY_ERROR`,e,{entry:t}),this[ia](),t.resume())}[ta](e,t,n){ki(z(e),{uid:this.uid,gid:this.gid,processUid:this.processUid,processGid:this.processGid,umask:this.processUmask,preserve:this.preservePaths,unlink:this.unlink,cwd:this.cwd,mode:t},n)}[ca](e){return this.forceChown||this.preserveOwner&&(typeof e.uid==`number`&&e.uid!==this.processUid||typeof e.gid==`number`&&e.gid!==this.processGid)||typeof this.uid==`number`&&this.uid!==this.processUid||typeof this.gid==`number`&&this.gid!==this.processGid}[la](e){return ga(this.uid,e.uid,this.processUid)}[ua](e){return ga(this.gid,e.gid,this.processGid)}[Ki](e,n){let r=typeof e.mode==`number`?e.mode&4095:this.fmode,i=new pt(String(e.absolute),{flags:yi(e.size),mode:r,autoClose:!1});i.on(`error`,r=>{i.fd&&t.close(i.fd,()=>{}),i.write=()=>!0,this[$](r,e),n()});let a=1,o=r=>{if(r){i.fd&&t.close(i.fd,()=>{}),this[$](r,e),n();return}--a===0&&i.fd!==void 0&&t.close(i.fd,t=>{t?this[$](t,e):this[ia](),n()})};i.on(`finish`,()=>{let n=String(e.absolute),r=i.fd;if(typeof r==`number`&&e.mtime&&!this.noMtime){a++;let i=e.atime||new Date,s=e.mtime;t.futimes(r,i,s,e=>e?t.utimes(n,i,s,t=>o(t&&e)):o())}if(typeof r==`number`&&this[ca](e)){a++;let i=this[la](e),s=this[ua](e);typeof i==`number`&&typeof s==`number`&&t.fchown(r,i,s,e=>e?t.chown(n,i,s,t=>o(t&&e)):o())}o()});let s=this.transform&&this.transform(e)||e;s!==e&&(s.on(`error`,t=>{this[$](t,e),n()}),e.pipe(s)),s.pipe(i)}[qi](e,n){let r=typeof e.mode==`number`?e.mode&4095:this.dmode;this[ta](String(e.absolute),r,r=>{if(r){this[$](r,e),n();return}let i=1,a=()=>{--i===0&&(n(),this[ia](),e.resume())};e.mtime&&!this.noMtime&&(i++,t.utimes(String(e.absolute),e.atime||new Date,e.mtime,a)),this[ca](e)&&(i++,t.chown(String(e.absolute),Number(this[la](e)),Number(this[ua](e)),a)),a()})}[Qi](e){e.unsupported=!0,this.warn(`TAR_ENTRY_UNSUPPORTED`,`unsupported entry type: ${e.type}`,{entry:e}),e.resume()}[Yi](e,t){let r=z(n.relative(this.cwd,n.resolve(n.dirname(String(e.absolute)),String(e.linkpath)))).split(`/`);this[Zi](e,this.cwd,r,()=>this[Ji](e,String(e.linkpath),`symlink`,t),n=>{this[$](n,e),t()})}[Xi](e,t){let r=z(n.resolve(this.cwd,String(e.linkpath))),i=z(String(e.linkpath)).split(`/`);this[Zi](e,this.cwd,i,()=>this[Ji](e,r,`link`,t),n=>{this[$](n,e),t()})}[Zi](e,r,i,a,o){let s=i.shift();if(this.preservePaths||s===void 0)return a();let c=n.resolve(r,s);t.lstat(c,(t,r)=>{if(t)return a();if(r?.isSymbolicLink())return o(new Di(c,n.resolve(c,i.join(`/`))));this[Zi](e,c,i,a,o)})}[ra](){this[na]++}[ia](){this[na]--,this[oa]()}[sa](e){this[ia](),e.resume()}[Gi](e,t){return e.type===`File`&&!this.unlink&&t.isFile()&&t.nlink<=1&&!fa}[Ui](e){this[ra]();let t=[e.path];e.linkpath&&t.push(e.linkpath),this.reservations.reserve(t,t=>this[Wi](e,t))}[Wi](e,r){let i=e=>{r(e)},a=()=>{this[ta](this.cwd,this.dmode,t=>{if(t){this[$](t,e),i();return}this[da]=!0,o()})},o=()=>{if(e.absolute!==this.cwd){let t=z(n.dirname(String(e.absolute)));if(t!==this.cwd)return this[ta](t,this.dmode,t=>{if(t){this[$](t,e),i();return}s()})}s()},s=()=>{t.lstat(String(e.absolute),(n,r)=>{if(r&&(this.keep||this.newer&&r.mtime>(e.mtime??r.mtime))){this[sa](e),i();return}if(n||this[Gi](e,r))return this[Q](null,e,i);if(r.isDirectory()){if(e.type===`Directory`){let n=this.chmod&&e.mode&&(r.mode&4095)!==e.mode,a=t=>this[Q](t??null,e,i);return n?t.chmod(String(e.absolute),Number(e.mode),a):a()}if(e.absolute!==this.cwd)return t.rmdir(String(e.absolute),t=>this[Q](t??null,e,i))}if(e.absolute===this.cwd)return this[Q](null,e,i);ma(String(e.absolute),t=>this[Q](t??null,e,i))})};this[da]?o():a()}[Q](e,t,n){if(e){this[$](e,t),n();return}switch(t.type){case`File`:case`OldFile`:case`ContiguousFile`:return this[Ki](t,n);case`Link`:return this[Xi](t,n);case`SymbolicLink`:return this[Yi](t,n);case`Directory`:case`GNUDumpDir`:return this[qi](t,n)}}[Ji](e,n,r,i){t[r](n,String(e.absolute),t=>{t?this[$](t,e):(this[ia](),e.resume()),i()})}},va=e=>{try{return[null,e()]}catch(e){return[e,null]}},ya=class extends _a{sync=!0;[Q](e,t){return super[Q](e,t,()=>{})}[Ui](e){if(!this[da]){let t=this[ta](this.cwd,this.dmode);if(t)return this[$](t,e);this[da]=!0}if(e.absolute!==this.cwd){let t=z(n.dirname(String(e.absolute)));if(t!==this.cwd){let n=this[ta](t,this.dmode);if(n)return this[$](n,e)}}let[r,i]=va(()=>t.lstatSync(String(e.absolute)));if(i&&(this.keep||this.newer&&i.mtime>(e.mtime??i.mtime)))return this[sa](e);if(r||this[Gi](e,i))return this[Q](null,e);if(i.isDirectory()){if(e.type===`Directory`){let[n]=this.chmod&&e.mode&&(i.mode&4095)!==e.mode?va(()=>{t.chmodSync(String(e.absolute),Number(e.mode))}):[];return this[Q](n,e)}let[n]=va(()=>t.rmdirSync(String(e.absolute)));this[Q](n,e)}let[a]=e.absolute===this.cwd?[]:va(()=>ha(String(e.absolute)));this[Q](a,e)}[Ki](e,n){let r=typeof e.mode==`number`?e.mode&4095:this.fmode,i=r=>{let i;try{t.closeSync(a)}catch(e){i=e}(r||i)&&this[$](r||i,e),n()},a;try{a=t.openSync(String(e.absolute),yi(e.size),r)}catch(e){return i(e)}let o=this.transform&&this.transform(e)||e;o!==e&&(o.on(`error`,t=>this[$](t,e)),e.pipe(o)),o.on(`data`,e=>{try{t.writeSync(a,e,0,e.length)}catch(e){i(e)}}),o.on(`end`,()=>{let n=null;if(e.mtime&&!this.noMtime){let r=e.atime||new Date,i=e.mtime;try{t.futimesSync(a,r,i)}catch(a){try{t.utimesSync(String(e.absolute),r,i)}catch{n=a}}}if(this[ca](e)){let r=this[la](e),i=this[ua](e);try{t.fchownSync(a,Number(r),Number(i))}catch(a){try{t.chownSync(String(e.absolute),Number(r),Number(i))}catch{n||=a}}}i(n)})}[qi](e,n){let r=typeof e.mode==`number`?e.mode&4095:this.dmode,i=this[ta](String(e.absolute),r);if(i){this[$](i,e),n();return}if(e.mtime&&!this.noMtime)try{t.utimesSync(String(e.absolute),e.atime||new Date,e.mtime)}catch{}if(this[ca](e))try{t.chownSync(String(e.absolute),Number(this[la](e)),Number(this[ua](e)))}catch{}n(),e.resume()}[ta](e,t){try{return Ni(z(e),{uid:this.uid,gid:this.gid,processUid:this.processUid,processGid:this.processGid,umask:this.processUmask,preserve:this.preservePaths,unlink:this.unlink,cwd:this.cwd,mode:t})}catch(e){return e}}[Zi](e,r,i,a,o){if(this.preservePaths||i.length===0)return a();let s=r;for(let e of i){s=n.resolve(s,e);let[c,l]=va(()=>t.lstatSync(s));if(c)return a();if(l.isSymbolicLink())return o(new Di(s,n.resolve(r,i.join(`/`))))}a()}[Ji](e,n,r,i){let a=`${r}Sync`;try{t[a](n,String(e.absolute)),i(),e.resume()}catch(t){return this[$](t,e)}}},ba=Ct(e=>{let n=new ya(e),r=e.file,i=t.statSync(r);new ft(r,{readSize:e.maxReadSize||16*1024*1024,size:i.size}).pipe(n)},(e,n)=>{let r=new _a(e),i=e.maxReadSize||16*1024*1024,a=e.file;return new Promise((e,n)=>{r.on(`error`,n),r.on(`close`,e),t.stat(a,(e,t)=>{if(e)n(e);else{let e=new dt(a,{readSize:i,size:t.size});e.on(`error`,n),e.pipe(r)}})})},e=>new ya(e),e=>new _a(e),(e,t)=>{t?.length&&Zn(e,t)}),xa=(e,n)=>{let r=new ri(e),i=!0,a,o;try{try{a=t.openSync(e.file,`r+`)}catch(n){if(n?.code===`ENOENT`)a=t.openSync(e.file,`w+`);else throw n}let s=t.fstatSync(a),c=Buffer.alloc(512);t:for(o=0;o<s.size;o+=512){for(let e=0,n=0;e<512;e+=n){if(n=t.readSync(a,c,e,c.length-e,o+e),o===0&&c[0]===31&&c[1]===139)throw Error(`cannot append to compressed archives`);if(!n)break t}let n=new I(c);if(!n.cksumValid)break;let r=512*Math.ceil((n.size||0)/512);if(o+r+512>s.size)break;o+=r,e.mtimeCache&&n.mtime&&e.mtimeCache.set(String(n.path),n.mtime)}i=!1,Sa(e,r,o,a,n)}finally{if(i)try{t.closeSync(a)}catch{}}},Sa=(e,t,n,r,i)=>{let a=new mt(e.file,{fd:r,start:n});t.pipe(a),wa(t,i)},Ca=(e,n)=>{n=Array.from(n);let r=new ni(e),i=(n,r,i)=>{let a=(e,r)=>{e?t.close(n,t=>i(e)):i(null,r)},o=0;if(r===0)return a(null,0);let s=0,c=Buffer.alloc(512),l=(i,u)=>{if(i||u===void 0)return a(i);if(s+=u,s<512&&u)return t.read(n,c,s,c.length-s,o+s,l);if(o===0&&c[0]===31&&c[1]===139)return a(Error(`cannot append to compressed archives`));if(s<512)return a(null,o);let d=new I(c);if(!d.cksumValid)return a(null,o);let f=512*Math.ceil((d.size??0)/512);if(o+f+512>r||(o+=f+512,o>=r))return a(null,o);e.mtimeCache&&d.mtime&&e.mtimeCache.set(String(d.path),d.mtime),s=0,t.read(n,c,0,512,o,l)};t.read(n,c,0,512,o,l)};return new Promise((a,o)=>{r.on(`error`,o);let s=`r+`,c=(l,u)=>{if(l&&l.code===`ENOENT`&&s===`r+`)return s=`w+`,t.open(e.file,s,c);if(l||!u)return o(l);t.fstat(u,(s,c)=>{if(s)return t.close(u,()=>o(s));i(u,c.size,(t,i)=>{if(t)return o(t);let s=new pt(e.file,{fd:u,start:i});r.pipe(s),s.on(`error`,o),s.on(`close`,a),Ta(r,n)})})};t.open(e.file,s,c)})},wa=(e,t)=>{t.forEach(t=>{t.charAt(0)===`@`?Qn({file:n.resolve(e.cwd,t.slice(1)),sync:!0,noResume:!0,onReadEntry:t=>e.add(t)}):e.add(t)}),e.end()},Ta=async(e,t)=>{for(let r of t)r.charAt(0)===`@`?await Qn({file:n.resolve(String(e.cwd),r.slice(1)),noResume:!0,onReadEntry:t=>e.add(t)}):e.add(r);e.end()},Ea=Ct(xa,Ca,()=>{throw TypeError(`file is required`)},()=>{throw TypeError(`file is required`)},(e,t)=>{if(!bt(e))throw TypeError(`file is required`);if(e.gzip||e.brotli||e.zstd||e.file.endsWith(`.br`)||e.file.endsWith(`.tbr`))throw TypeError(`cannot append to compressed archives`);if(!t?.length)throw TypeError(`no paths specified to add/replace`)});Ct(Ea.syncFile,Ea.asyncFile,Ea.syncNoFile,Ea.asyncNoFile,(e,t=[])=>{Ea.validate?.(e,t),Da(e)});var Da=e=>{let t=e.filter;e.mtimeCache||=new Map,e.filter=t?(n,r)=>t(n,r)&&!((e.mtimeCache?.get(n)??r.mtime??0)>(r.mtime??0)):(t,n)=>!((e.mtimeCache?.get(t)??n.mtime??0)>(n.mtime??0))};export{ce as t};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-mugnavo",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "Create a project using Mugnavo templates.",
|
|
5
5
|
"homepage": "https://github.com/mugnavo/create-mugnavo#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -17,18 +17,18 @@
|
|
|
17
17
|
],
|
|
18
18
|
"type": "module",
|
|
19
19
|
"devDependencies": {
|
|
20
|
-
"@clack/prompts": "^1.
|
|
21
|
-
"@types/node": "^
|
|
20
|
+
"@clack/prompts": "^1.5.1",
|
|
21
|
+
"@types/node": "^25.9.2",
|
|
22
22
|
"bumpp": "^11.1.0",
|
|
23
23
|
"citty": "^0.2.2",
|
|
24
24
|
"giget": "^3.2.0",
|
|
25
|
-
"oxfmt": "^0.
|
|
26
|
-
"oxlint": "^1.
|
|
27
|
-
"oxlint-tsgolint": "^0.
|
|
28
|
-
"tinyexec": "^1.
|
|
29
|
-
"tsdown": "^0.22.
|
|
25
|
+
"oxfmt": "^0.54.0",
|
|
26
|
+
"oxlint": "^1.69.0",
|
|
27
|
+
"oxlint-tsgolint": "^0.23.0",
|
|
28
|
+
"tinyexec": "^1.2.4",
|
|
29
|
+
"tsdown": "^0.22.2",
|
|
30
30
|
"typescript": "^6.0.3",
|
|
31
|
-
"vitest": "^4.1.
|
|
31
|
+
"vitest": "^4.1.8"
|
|
32
32
|
},
|
|
33
33
|
"engines": {
|
|
34
34
|
"node": ">=24"
|