giget 1.2.5 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +163 -0
- package/README.md +6 -6
- package/dist/_chunks/giget.mjs +271 -0
- package/dist/_chunks/libs/@isaacs/fs-minipass.mjs +1 -0
- package/dist/_chunks/libs/chownr.mjs +1 -0
- package/dist/_chunks/libs/citty.mjs +5 -0
- package/dist/_chunks/libs/minizlib.mjs +1 -0
- package/dist/_chunks/libs/nypm.mjs +2 -0
- package/dist/_chunks/libs/tar.mjs +3 -0
- package/dist/cli.d.mts +1 -1
- package/dist/cli.mjs +87 -99
- package/dist/index.d.mts +41 -35
- package/dist/index.mjs +8 -12
- package/package.json +25 -39
- package/dist/cli.cjs +0 -104
- package/dist/cli.d.cts +0 -1
- package/dist/cli.d.ts +0 -1
- package/dist/index.cjs +0 -20
- package/dist/index.d.cts +0 -49
- package/dist/index.d.ts +0 -49
- package/dist/shared/giget.BgKdRmJH.mjs +0 -361
- package/dist/shared/giget.C0XVJdqO.cjs +0 -365
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{a as Minipass,i as WriteStreamSync,n as ReadStreamSync,r as WriteStream,t as ReadStream}from"./@isaacs/fs-minipass.mjs";import{a as ZstdCompress,i as Unzip,n as BrotliDecompress,o as ZstdDecompress,r as Gzip,t as BrotliCompress}from"./minizlib.mjs";import{n as chownrSync,t as chownr}from"./chownr.mjs";import fsp from"node:fs/promises";import fs from"node:fs";import{EventEmitter}from"events";import fs$1 from"fs";import path,{basename,join,posix,win32}from"node:path";import path$1,{dirname as dirname$1,parse}from"path";import assert from"node:assert";import{randomBytes}from"node:crypto";const argmap=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`]]),isSyncFile=d=>!!d.sync&&!!d.file,isAsyncFile=d=>!d.sync&&!!d.file,isSyncNoFile=d=>!!d.sync&&!d.file,isAsyncNoFile=d=>!d.sync&&!d.file,isFile=d=>!!d.file,dealiasKey=d=>argmap.get(d)||d,dealias=(d={})=>{if(!d)return{};let B={};for(let[V,H]of Object.entries(d)){let d=dealiasKey(V);B[d]=H}return B.chmod===void 0&&B.noChmod===!1&&(B.chmod=!0),delete B.noChmod,B},makeCommand=(d,B,V,H,U)=>Object.assign((W=[],G,K)=>{Array.isArray(W)&&(G=W,W={}),typeof G==`function`&&(K=G,G=void 0),G=G?Array.from(G):[];let q=dealias(W);if(U?.(q,G),isSyncFile(q)){if(typeof K==`function`)throw TypeError(`callback not supported for sync tar functions`);return d(q,G)}else if(isAsyncFile(q)){let d=B(q,G),V=K||void 0;return V?d.then(()=>V(),V):d}else if(isSyncNoFile(q)){if(typeof K==`function`)throw TypeError(`callback not supported for sync tar functions`);return V(q,G)}else if(isAsyncNoFile(q)){if(typeof K==`function`)throw TypeError(`callback only supported with file option`);return H(q,G)}else throw Error(`impossible options??`)},{syncFile:d,asyncFile:B,syncNoFile:V,asyncNoFile:H,validate:U}),encode$1=(d,B)=>{if(Number.isSafeInteger(d))d<0?encodeNegative(d,B):encodePositive(d,B);else throw Error(`cannot encode number outside of javascript safe integer range`);return B},encodePositive=(d,B)=>{B[0]=128;for(var V=B.length;V>1;V--)B[V-1]=d&255,d=Math.floor(d/256)},encodeNegative=(d,B)=>{B[0]=255;var V=!1;d*=-1;for(var H=B.length;H>1;H--){var U=d&255;d=Math.floor(d/256),V?B[H-1]=onesComp(U):U===0?B[H-1]=0:(V=!0,B[H-1]=twosComp(U))}},parse$2=d=>{let B=d[0],V=B===128?pos(d.subarray(1,d.length)):B===255?twos(d):null;if(V===null)throw Error(`invalid base256 encoding`);if(!Number.isSafeInteger(V))throw Error(`parsed number outside of javascript safe integer range`);return V},twos=d=>{for(var B=d.length,V=0,H=!1,U=B-1;U>-1;U--){var W=Number(d[U]),G;H?G=onesComp(W):W===0?G=W:(H=!0,G=twosComp(W)),G!==0&&(V-=G*256**(B-U-1))}return V},pos=d=>{for(var B=d.length,V=0,H=B-1;H>-1;H--){var U=Number(d[H]);U!==0&&(V+=U*256**(B-H-1))}return V},onesComp=d=>(255^d)&255,twosComp=d=>(255^d)+1&255,isCode=d=>name.has(d),name=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`]]),code=new Map(Array.from(name).map(d=>[d[1],d[0]]));var Header=class{cksumValid=!1;needPax=!1;nullBlock=!1;block;path;mode;uid;gid;size;cksum;#type=`Unsupported`;linkpath;uname;gname;devmaj=0;devmin=0;atime;ctime;mtime;charset;comment;constructor(d,B=0,V,H){Buffer.isBuffer(d)?this.decode(d,B||0,V,H):d&&this.#slurp(d)}decode(d,B,V,H){if(B||=0,!d||!(d.length>=B+512))throw Error(`need 512 bytes for header`);this.path=V?.path??decString(d,B,100),this.mode=V?.mode??H?.mode??decNumber(d,B+100,8),this.uid=V?.uid??H?.uid??decNumber(d,B+108,8),this.gid=V?.gid??H?.gid??decNumber(d,B+116,8),this.size=V?.size??H?.size??decNumber(d,B+124,12),this.mtime=V?.mtime??H?.mtime??decDate(d,B+136,12),this.cksum=decNumber(d,B+148,12),H&&this.#slurp(H,!0),V&&this.#slurp(V);let U=decString(d,B+156,1);if(isCode(U)&&(this.#type=U||`0`),this.#type===`0`&&this.path.slice(-1)===`/`&&(this.#type=`5`),this.#type===`5`&&(this.size=0),this.linkpath=decString(d,B+157,100),d.subarray(B+257,B+265).toString()===`ustar\x0000`)if(this.uname=V?.uname??H?.uname??decString(d,B+265,32),this.gname=V?.gname??H?.gname??decString(d,B+297,32),this.devmaj=V?.devmaj??H?.devmaj??decNumber(d,B+329,8)??0,this.devmin=V?.devmin??H?.devmin??decNumber(d,B+337,8)??0,d[B+475]!==0)this.path=decString(d,B+345,155)+`/`+this.path;else{let U=decString(d,B+345,130);U&&(this.path=U+`/`+this.path),this.atime=V?.atime??H?.atime??decDate(d,B+476,12),this.ctime=V?.ctime??H?.ctime??decDate(d,B+488,12)}let W=256;for(let V=B;V<B+148;V++)W+=d[V];for(let V=B+156;V<B+512;V++)W+=d[V];this.cksumValid=W===this.cksum,this.cksum===void 0&&W===256&&(this.nullBlock=!0)}#slurp(d,B=!1){Object.assign(this,Object.fromEntries(Object.entries(d).filter(([d,V])=>!(V==null||d===`path`&&B||d===`linkpath`&&B||d===`global`))))}encode(d,B=0){if(d||=this.block=Buffer.alloc(512),this.#type===`Unsupported`&&(this.#type=`0`),!(d.length>=B+512))throw Error(`need 512 bytes for header`);let V=this.ctime||this.atime?130:155,H=splitPrefix(this.path||``,V),U=H[0],W=H[1];this.needPax=!!H[2],this.needPax=encString(d,B,100,U)||this.needPax,this.needPax=encNumber(d,B+100,8,this.mode)||this.needPax,this.needPax=encNumber(d,B+108,8,this.uid)||this.needPax,this.needPax=encNumber(d,B+116,8,this.gid)||this.needPax,this.needPax=encNumber(d,B+124,12,this.size)||this.needPax,this.needPax=encDate(d,B+136,12,this.mtime)||this.needPax,d[B+156]=this.#type.charCodeAt(0),this.needPax=encString(d,B+157,100,this.linkpath)||this.needPax,d.write(`ustar\x0000`,B+257,8),this.needPax=encString(d,B+265,32,this.uname)||this.needPax,this.needPax=encString(d,B+297,32,this.gname)||this.needPax,this.needPax=encNumber(d,B+329,8,this.devmaj)||this.needPax,this.needPax=encNumber(d,B+337,8,this.devmin)||this.needPax,this.needPax=encString(d,B+345,V,W)||this.needPax,d[B+475]===0?(this.needPax=encString(d,B+345,130,W)||this.needPax,this.needPax=encDate(d,B+476,12,this.atime)||this.needPax,this.needPax=encDate(d,B+488,12,this.ctime)||this.needPax):this.needPax=encString(d,B+345,155,W)||this.needPax;let G=256;for(let V=B;V<B+148;V++)G+=d[V];for(let V=B+156;V<B+512;V++)G+=d[V];return this.cksum=G,encNumber(d,B+148,8,this.cksum),this.cksumValid=!0,this.needPax}get type(){return this.#type===`Unsupported`?this.#type:name.get(this.#type)}get typeKey(){return this.#type}set type(d){let B=String(code.get(d));if(isCode(B)||B===`Unsupported`)this.#type=B;else if(isCode(d))this.#type=d;else throw TypeError(`invalid entry type: `+d)}};const splitPrefix=(d,B)=>{let V=d,H=``,U,W=posix.parse(d).root||`.`;if(Buffer.byteLength(V)<100)U=[V,H,!1];else{H=posix.dirname(V),V=posix.basename(V);do Buffer.byteLength(V)<=100&&Buffer.byteLength(H)<=B?U=[V,H,!1]:Buffer.byteLength(V)>100&&Buffer.byteLength(H)<=B?U=[V.slice(0,99),H,!0]:(V=posix.join(posix.basename(H),V),H=posix.dirname(H));while(H!==W&&U===void 0);U||=[d.slice(0,99),``,!0]}return U},decString=(d,B,V)=>d.subarray(B,B+V).toString(`utf8`).replace(/\0.*/,``),decDate=(d,B,V)=>numToDate(decNumber(d,B,V)),numToDate=d=>d===void 0?void 0:new Date(d*1e3),decNumber=(d,B,V)=>Number(d[B])&128?parse$2(d.subarray(B,B+V)):decSmallNumber(d,B,V),nanUndef=d=>isNaN(d)?void 0:d,decSmallNumber=(d,B,V)=>nanUndef(parseInt(d.subarray(B,B+V).toString(`utf8`).replace(/\0.*$/,``).trim(),8)),MAXNUM={12:8589934591,8:2097151},encNumber=(d,B,V,H)=>H===void 0?!1:H>MAXNUM[V]||H<0?(encode$1(H,d.subarray(B,B+V)),!0):(encSmallNumber(d,B,V,H),!1),encSmallNumber=(d,B,V,H)=>d.write(octalString(H,V),B,V,`ascii`),octalString=(d,B)=>padOctal(Math.floor(d).toString(8),B),padOctal=(d,B)=>(d.length===B-1?d:Array(B-d.length-1).join(`0`)+d+` `)+`\0`,encDate=(d,B,V,H)=>H===void 0?!1:encNumber(d,B,V,H.getTime()/1e3),NULLS=Array(156).join(`\0`),encString=(d,B,V,H)=>H===void 0?!1:(d.write(H+NULLS,B,V,`utf8`),H.length!==Buffer.byteLength(H)||H.length>V);var Pax=class d{atime;mtime;ctime;charset;comment;gid;uid;gname;uname;linkpath;dev;ino;nlink;path;size;mode;global;constructor(d,B=!1){this.atime=d.atime,this.charset=d.charset,this.comment=d.comment,this.ctime=d.ctime,this.dev=d.dev,this.gid=d.gid,this.global=B,this.gname=d.gname,this.ino=d.ino,this.linkpath=d.linkpath,this.mtime=d.mtime,this.nlink=d.nlink,this.path=d.path,this.size=d.size,this.uid=d.uid,this.uname=d.uname}encode(){let d=this.encodeBody();if(d===``)return Buffer.allocUnsafe(0);let B=Buffer.byteLength(d),V=512*Math.ceil(1+B/512),H=Buffer.allocUnsafe(V);for(let d=0;d<512;d++)H[d]=0;new Header({path:(`PaxHeader/`+basename(this.path??``)).slice(0,99),mode:this.mode||420,uid:this.uid,gid:this.gid,size:B,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(H),H.write(d,512,B,`utf8`);for(let d=B+512;d<H.length;d++)H[d]=0;return H}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(d){if(this[d]===void 0)return``;let B=this[d],V=B instanceof Date?B.getTime()/1e3:B,H=` `+(d===`dev`||d===`ino`||d===`nlink`?`SCHILY.`:``)+d+`=`+V+`
|
|
2
|
+
`,U=Buffer.byteLength(H),W=Math.floor(Math.log(U)/Math.log(10))+1;return U+W>=10**W&&(W+=1),W+U+H}static parse(B,V,H=!1){return new d(merge(parseKV(B),V),H)}};const merge=(d,B)=>B?Object.assign({},B,d):d,parseKV=d=>d.replace(/\n$/,``).split(`
|
|
3
|
+
`).reduce(parseKVLine,Object.create(null)),parseKVLine=(d,B)=>{let V=parseInt(B,10);if(V!==Buffer.byteLength(B)+1)return d;B=B.slice((V+` `).length);let H=B.split(`=`),U=H.shift();if(!U)return d;let W=U.replace(/^SCHILY\.(dev|ino|nlink)/,`$1`),G=H.join(`=`);return d[W]=/^([A-Z]+\.)?([mac]|birth|creation)time$/.test(W)?new Date(Number(G)*1e3):/^[0-9]+$/.test(G)?+G:G,d},normalizeWindowsPath=(process.env.TESTING_TAR_FAKE_PLATFORM||process.platform)===`win32`?d=>d&&d.replace(/\\/g,`/`):d=>d;var ReadEntry=class extends Minipass{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(d,B,V){switch(super({}),this.pause(),this.extended=B,this.globalExtended=V,this.header=d,this.remain=d.size??0,this.startBlockSize=512*Math.ceil(this.remain/512),this.blockRemain=this.startBlockSize,this.type=d.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(!d.path)throw Error(`no path provided for tar.ReadEntry`);this.path=normalizeWindowsPath(d.path),this.mode=d.mode,this.mode&&(this.mode&=4095),this.uid=d.uid,this.gid=d.gid,this.uname=d.uname,this.gname=d.gname,this.size=this.remain,this.mtime=d.mtime,this.atime=d.atime,this.ctime=d.ctime,this.linkpath=d.linkpath?normalizeWindowsPath(d.linkpath):void 0,this.uname=d.uname,this.gname=d.gname,B&&this.#slurp(B),V&&this.#slurp(V,!0)}write(d){let B=d.length;if(B>this.blockRemain)throw Error(`writing more to entry than is appropriate`);let V=this.remain,H=this.blockRemain;return this.remain=Math.max(0,V-B),this.blockRemain=Math.max(0,H-B),this.ignore?!0:V>=B?super.write(d):super.write(d.subarray(0,V))}#slurp(d,B=!1){d.path&&=normalizeWindowsPath(d.path),d.linkpath&&=normalizeWindowsPath(d.linkpath),Object.assign(this,Object.fromEntries(Object.entries(d).filter(([d,V])=>!(V==null||d===`path`&&B))))}};const warnMethod=(d,B,V,H={})=>{d.file&&(H.file=d.file),d.cwd&&(H.cwd=d.cwd),H.code=V instanceof Error&&V.code||B,H.tarCode=B,!d.strict&&H.recoverable!==!1?(V instanceof Error&&(H=Object.assign(V,H),V=V.message),d.emit(`warn`,B,V,H)):V instanceof Error?d.emit(`error`,Object.assign(V,H)):d.emit(`error`,Object.assign(Error(`${B}: ${V}`),H))},gzipHeader=Buffer.from([31,139]),zstdHeader=Buffer.from([40,181,47,253]),ZIP_HEADER_LEN=Math.max(gzipHeader.length,zstdHeader.length),STATE=Symbol(`state`),WRITEENTRY=Symbol(`writeEntry`),READENTRY=Symbol(`readEntry`),NEXTENTRY=Symbol(`nextEntry`),PROCESSENTRY=Symbol(`processEntry`),EX=Symbol(`extendedHeader`),GEX=Symbol(`globalExtendedHeader`),META=Symbol(`meta`),EMITMETA=Symbol(`emitMeta`),BUFFER=Symbol(`buffer`),QUEUE$1=Symbol(`queue`),ENDED$2=Symbol(`ended`),EMITTEDEND=Symbol(`emittedEnd`),EMIT=Symbol(`emit`),UNZIP=Symbol(`unzip`),CONSUMECHUNK=Symbol(`consumeChunk`),CONSUMECHUNKSUB=Symbol(`consumeChunkSub`),CONSUMEBODY=Symbol(`consumeBody`),CONSUMEMETA=Symbol(`consumeMeta`),CONSUMEHEADER=Symbol(`consumeHeader`),CONSUMING=Symbol(`consuming`),BUFFERCONCAT=Symbol(`bufferConcat`),MAYBEEND=Symbol(`maybeEnd`),WRITING=Symbol(`writing`),ABORTED=Symbol(`aborted`),DONE=Symbol(`onDone`),SAW_VALID_ENTRY=Symbol(`sawValidEntry`),SAW_NULL_BLOCK=Symbol(`sawNullBlock`),SAW_EOF=Symbol(`sawEOF`),CLOSESTREAM=Symbol(`closeStream`),noop=()=>!0;var Parser=class extends EventEmitter{file;strict;maxMetaEntrySize;filter;brotli;zstd;writable=!0;readable=!1;[QUEUE$1]=[];[BUFFER];[READENTRY];[WRITEENTRY];[STATE]=`begin`;[META]=``;[EX];[GEX];[ENDED$2]=!1;[UNZIP];[ABORTED]=!1;[SAW_VALID_ENTRY];[SAW_NULL_BLOCK]=!1;[SAW_EOF]=!1;[WRITING]=!1;[CONSUMING]=!1;[EMITTEDEND]=!1;constructor(d={}){super(),this.file=d.file||``,this.on(DONE,()=>{(this[STATE]===`begin`||this[SAW_VALID_ENTRY]===!1)&&this.warn(`TAR_BAD_ARCHIVE`,`Unrecognized archive format`)}),d.ondone?this.on(DONE,d.ondone):this.on(DONE,()=>{this.emit(`prefinish`),this.emit(`finish`),this.emit(`end`)}),this.strict=!!d.strict,this.maxMetaEntrySize=d.maxMetaEntrySize||1048576,this.filter=typeof d.filter==`function`?d.filter:noop;let B=d.file&&(d.file.endsWith(`.tar.br`)||d.file.endsWith(`.tbr`));this.brotli=!(d.gzip||d.zstd)&&d.brotli!==void 0?d.brotli:B?void 0:!1;let V=d.file&&(d.file.endsWith(`.tar.zst`)||d.file.endsWith(`.tzst`));this.zstd=!(d.gzip||d.brotli)&&d.zstd!==void 0?d.zstd:V?!0:void 0,this.on(`end`,()=>this[CLOSESTREAM]()),typeof d.onwarn==`function`&&this.on(`warn`,d.onwarn),typeof d.onReadEntry==`function`&&this.on(`entry`,d.onReadEntry)}warn(d,B,V={}){warnMethod(this,d,B,V)}[CONSUMEHEADER](d,B){this[SAW_VALID_ENTRY]===void 0&&(this[SAW_VALID_ENTRY]=!1);let V;try{V=new Header(d,B,this[EX],this[GEX])}catch(d){return this.warn(`TAR_ENTRY_INVALID`,d)}if(V.nullBlock)this[SAW_NULL_BLOCK]?(this[SAW_EOF]=!0,this[STATE]===`begin`&&(this[STATE]=`header`),this[EMIT](`eof`)):(this[SAW_NULL_BLOCK]=!0,this[EMIT](`nullBlock`));else if(this[SAW_NULL_BLOCK]=!1,!V.cksumValid)this.warn(`TAR_ENTRY_INVALID`,`checksum failure`,{header:V});else if(!V.path)this.warn(`TAR_ENTRY_INVALID`,`path is required`,{header:V});else{let d=V.type;if(/^(Symbolic)?Link$/.test(d)&&!V.linkpath)this.warn(`TAR_ENTRY_INVALID`,`linkpath required`,{header:V});else if(!/^(Symbolic)?Link$/.test(d)&&!/^(Global)?ExtendedHeader$/.test(d)&&V.linkpath)this.warn(`TAR_ENTRY_INVALID`,`linkpath forbidden`,{header:V});else{let d=this[WRITEENTRY]=new ReadEntry(V,this[EX],this[GEX]);this[SAW_VALID_ENTRY]||(d.remain?d.on(`end`,()=>{d.invalid||(this[SAW_VALID_ENTRY]=!0)}):this[SAW_VALID_ENTRY]=!0),d.meta?d.size>this.maxMetaEntrySize?(d.ignore=!0,this[EMIT](`ignoredEntry`,d),this[STATE]=`ignore`,d.resume()):d.size>0&&(this[META]=``,d.on(`data`,d=>this[META]+=d),this[STATE]=`meta`):(this[EX]=void 0,d.ignore=d.ignore||!this.filter(d.path,d),d.ignore?(this[EMIT](`ignoredEntry`,d),this[STATE]=d.remain?`ignore`:`header`,d.resume()):(d.remain?this[STATE]=`body`:(this[STATE]=`header`,d.end()),this[READENTRY]?this[QUEUE$1].push(d):(this[QUEUE$1].push(d),this[NEXTENTRY]())))}}}[CLOSESTREAM](){queueMicrotask(()=>this.emit(`close`))}[PROCESSENTRY](d){let B=!0;if(!d)this[READENTRY]=void 0,B=!1;else if(Array.isArray(d)){let[B,...V]=d;this.emit(B,...V)}else this[READENTRY]=d,this.emit(`entry`,d),d.emittedEnd||(d.on(`end`,()=>this[NEXTENTRY]()),B=!1);return B}[NEXTENTRY](){do;while(this[PROCESSENTRY](this[QUEUE$1].shift()));if(!this[QUEUE$1].length){let d=this[READENTRY];!d||d.flowing||d.size===d.remain?this[WRITING]||this.emit(`drain`):d.once(`drain`,()=>this.emit(`drain`))}}[CONSUMEBODY](d,B){let V=this[WRITEENTRY];if(!V)throw Error(`attempt to consume body without entry??`);let H=V.blockRemain??0,U=H>=d.length&&B===0?d:d.subarray(B,B+H);return V.write(U),V.blockRemain||(this[STATE]=`header`,this[WRITEENTRY]=void 0,V.end()),U.length}[CONSUMEMETA](d,B){let V=this[WRITEENTRY],H=this[CONSUMEBODY](d,B);return!this[WRITEENTRY]&&V&&this[EMITMETA](V),H}[EMIT](d,B,V){!this[QUEUE$1].length&&!this[READENTRY]?this.emit(d,B,V):this[QUEUE$1].push([d,B,V])}[EMITMETA](d){switch(this[EMIT](`meta`,this[META]),d.type){case`ExtendedHeader`:case`OldExtendedHeader`:this[EX]=Pax.parse(this[META],this[EX],!1);break;case`GlobalExtendedHeader`:this[GEX]=Pax.parse(this[META],this[GEX],!0);break;case`NextFileHasLongPath`:case`OldGnuLongPath`:{let d=this[EX]??Object.create(null);this[EX]=d,d.path=this[META].replace(/\0.*/,``);break}case`NextFileHasLongLinkpath`:{let d=this[EX]||Object.create(null);this[EX]=d,d.linkpath=this[META].replace(/\0.*/,``);break}default:throw Error(`unknown meta: `+d.type)}}abort(d){this[ABORTED]=!0,this.emit(`abort`,d),this.warn(`TAR_ABORT`,d,{recoverable:!1})}write(d,B,V){if(typeof B==`function`&&(V=B,B=void 0),typeof d==`string`&&(d=Buffer.from(d,typeof B==`string`?B:`utf8`)),this[ABORTED])return V?.(),!1;if((this[UNZIP]===void 0||this.brotli===void 0&&this[UNZIP]===!1)&&d){if(this[BUFFER]&&(d=Buffer.concat([this[BUFFER],d]),this[BUFFER]=void 0),d.length<ZIP_HEADER_LEN)return this[BUFFER]=d,V?.(),!0;for(let B=0;this[UNZIP]===void 0&&B<gzipHeader.length;B++)d[B]!==gzipHeader[B]&&(this[UNZIP]=!1);let B=!1;if(this[UNZIP]===!1&&this.zstd!==!1){B=!0;for(let V=0;V<zstdHeader.length;V++)if(d[V]!==zstdHeader[V]){B=!1;break}}let H=this.brotli===void 0&&!B;if(this[UNZIP]===!1&&H)if(d.length<512)if(this[ENDED$2])this.brotli=!0;else return this[BUFFER]=d,V?.(),!0;else try{new Header(d.subarray(0,512)),this.brotli=!1}catch{this.brotli=!0}if(this[UNZIP]===void 0||this[UNZIP]===!1&&(this.brotli||B)){let H=this[ENDED$2];this[ENDED$2]=!1,this[UNZIP]=this[UNZIP]===void 0?new Unzip({}):B?new ZstdDecompress({}):new BrotliDecompress({}),this[UNZIP].on(`data`,d=>this[CONSUMECHUNK](d)),this[UNZIP].on(`error`,d=>this.abort(d)),this[UNZIP].on(`end`,()=>{this[ENDED$2]=!0,this[CONSUMECHUNK]()}),this[WRITING]=!0;let U=!!this[UNZIP][H?`end`:`write`](d);return this[WRITING]=!1,V?.(),U}}this[WRITING]=!0,this[UNZIP]?this[UNZIP].write(d):this[CONSUMECHUNK](d),this[WRITING]=!1;let H=this[QUEUE$1].length?!1:this[READENTRY]?this[READENTRY].flowing:!0;return!H&&!this[QUEUE$1].length&&this[READENTRY]?.once(`drain`,()=>this.emit(`drain`)),V?.(),H}[BUFFERCONCAT](d){d&&!this[ABORTED]&&(this[BUFFER]=this[BUFFER]?Buffer.concat([this[BUFFER],d]):d)}[MAYBEEND](){if(this[ENDED$2]&&!this[EMITTEDEND]&&!this[ABORTED]&&!this[CONSUMING]){this[EMITTEDEND]=!0;let d=this[WRITEENTRY];if(d&&d.blockRemain){let B=this[BUFFER]?this[BUFFER].length:0;this.warn(`TAR_BAD_ARCHIVE`,`Truncated input (needed ${d.blockRemain} more bytes, only ${B} available)`,{entry:d}),this[BUFFER]&&d.write(this[BUFFER]),d.end()}this[EMIT](DONE)}}[CONSUMECHUNK](d){if(this[CONSUMING]&&d)this[BUFFERCONCAT](d);else if(!d&&!this[BUFFER])this[MAYBEEND]();else if(d){if(this[CONSUMING]=!0,this[BUFFER]){this[BUFFERCONCAT](d);let B=this[BUFFER];this[BUFFER]=void 0,this[CONSUMECHUNKSUB](B)}else this[CONSUMECHUNKSUB](d);for(;this[BUFFER]&&this[BUFFER]?.length>=512&&!this[ABORTED]&&!this[SAW_EOF];){let d=this[BUFFER];this[BUFFER]=void 0,this[CONSUMECHUNKSUB](d)}this[CONSUMING]=!1}(!this[BUFFER]||this[ENDED$2])&&this[MAYBEEND]()}[CONSUMECHUNKSUB](d){let B=0,V=d.length;for(;B+512<=V&&!this[ABORTED]&&!this[SAW_EOF];)switch(this[STATE]){case`begin`:case`header`:this[CONSUMEHEADER](d,B),B+=512;break;case`ignore`:case`body`:B+=this[CONSUMEBODY](d,B);break;case`meta`:B+=this[CONSUMEMETA](d,B);break;default:throw Error(`invalid state: `+this[STATE])}B<V&&(this[BUFFER]?this[BUFFER]=Buffer.concat([d.subarray(B),this[BUFFER]]):this[BUFFER]=d.subarray(B))}end(d,B,V){return typeof d==`function`&&(V=d,B=void 0,d=void 0),typeof B==`function`&&(V=B,B=void 0),typeof d==`string`&&(d=Buffer.from(d,B)),V&&this.once(`finish`,V),this[ABORTED]||(this[UNZIP]?(d&&this[UNZIP].write(d),this[UNZIP].end()):(this[ENDED$2]=!0,(this.brotli===void 0||this.zstd===void 0)&&(d||=Buffer.alloc(0)),d&&this.write(d),this[MAYBEEND]())),this}};const stripTrailingSlashes=d=>{let B=d.length-1,V=-1;for(;B>-1&&d.charAt(B)===`/`;)V=B,B--;return V===-1?d:d.slice(0,V)},onReadEntryFunction=d=>{let B=d.onReadEntry;d.onReadEntry=B?d=>{B(d),d.resume()}:d=>d.resume()},filesFilter=(d,B)=>{let V=new Map(B.map(d=>[stripTrailingSlashes(d),!0])),H=d.filter,U=(d,B=``)=>{let H=B||parse(d).root||`.`,W;if(d===H)W=!1;else{let B=V.get(d);W=B===void 0?U(dirname$1(d),H):B}return V.set(d,W),W};d.filter=H?(d,B)=>H(d,B)&&U(stripTrailingSlashes(d)):d=>U(stripTrailingSlashes(d))},list=makeCommand(d=>{let B=new Parser(d),V=d.file,H;try{H=fs.openSync(V,`r`);let U=fs.fstatSync(H),W=d.maxReadSize||16*1024*1024;if(U.size<W){let d=Buffer.allocUnsafe(U.size),V=fs.readSync(H,d,0,U.size,0);B.end(V===d.byteLength?d:d.subarray(0,V))}else{let d=0,V=Buffer.allocUnsafe(W);for(;d<U.size;){let U=fs.readSync(H,V,0,W,d);if(U===0)break;d+=U,B.write(V.subarray(0,U))}B.end()}}finally{if(typeof H==`number`)try{fs.closeSync(H)}catch{}}},(d,B)=>{let V=new Parser(d),H=d.maxReadSize||16*1024*1024,W=d.file;return new Promise((d,B)=>{V.on(`error`,B),V.on(`end`,d),fs.stat(W,(d,G)=>{if(d)B(d);else{let d=new ReadStream(W,{readSize:H,size:G.size});d.on(`error`,B),d.pipe(V)}})})},d=>new Parser(d),d=>new Parser(d),(d,B)=>{B?.length&&filesFilter(d,B),d.noResume||onReadEntryFunction(d)}),modeFix=(d,B,V)=>(d&=4095,V&&(d=(d|384)&-19),B&&(d&256&&(d|=64),d&32&&(d|=8),d&4&&(d|=1)),d),{isAbsolute,parse:parse$1}=win32,stripAbsolutePath=d=>{let B=``,V=parse$1(d);for(;isAbsolute(d)||V.root;){let H=d.charAt(0)===`/`&&d.slice(0,4)!==`//?/`?`/`:V.root;d=d.slice(H.length),B+=H,V=parse$1(d)}return[B,d]},raw=[`|`,`<`,`>`,`?`,`:`],win=raw.map(d=>String.fromCharCode(61440+d.charCodeAt(0))),toWin=new Map(raw.map((d,B)=>[d,win[B]])),toRaw=new Map(win.map((d,B)=>[d,raw[B]])),encode=d=>raw.reduce((d,B)=>d.split(B).join(toWin.get(B)),d),decode=d=>win.reduce((d,B)=>d.split(B).join(toRaw.get(B)),d),prefixPath=(d,B)=>B?(d=normalizeWindowsPath(d).replace(/^\.(\/|$)/,``),stripTrailingSlashes(B)+`/`+d):normalizeWindowsPath(d),PROCESS$1=Symbol(`process`),FILE$1=Symbol(`file`),DIRECTORY$1=Symbol(`directory`),SYMLINK$1=Symbol(`symlink`),HARDLINK$1=Symbol(`hardlink`),HEADER=Symbol(`header`),READ=Symbol(`read`),LSTAT=Symbol(`lstat`),ONLSTAT=Symbol(`onlstat`),ONREAD=Symbol(`onread`),ONREADLINK=Symbol(`onreadlink`),OPENFILE=Symbol(`openfile`),ONOPENFILE=Symbol(`onopenfile`),CLOSE=Symbol(`close`),MODE=Symbol(`mode`),AWAITDRAIN=Symbol(`awaitDrain`),ONDRAIN$1=Symbol(`ondrain`),PREFIX=Symbol(`prefix`);var WriteEntry=class extends Minipass{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;#hadError=!1;constructor(d,B={}){let V=dealias(B);super(),this.path=normalizeWindowsPath(d),this.portable=!!V.portable,this.maxReadSize=V.maxReadSize||16777216,this.linkCache=V.linkCache||new Map,this.statCache=V.statCache||new Map,this.preservePaths=!!V.preservePaths,this.cwd=normalizeWindowsPath(V.cwd||process.cwd()),this.strict=!!V.strict,this.noPax=!!V.noPax,this.noMtime=!!V.noMtime,this.mtime=V.mtime,this.prefix=V.prefix?normalizeWindowsPath(V.prefix):void 0,this.onWriteEntry=V.onWriteEntry,typeof V.onwarn==`function`&&this.on(`warn`,V.onwarn);let H=!1;if(!this.preservePaths){let[d,B]=stripAbsolutePath(this.path);d&&typeof B==`string`&&(this.path=B,H=d)}this.win32=!!V.win32||process.platform===`win32`,this.win32&&(this.path=decode(this.path.replace(/\\/g,`/`)),d=d.replace(/\\/g,`/`)),this.absolute=normalizeWindowsPath(V.absolute||path$1.resolve(this.cwd,d)),this.path===``&&(this.path=`./`),H&&this.warn(`TAR_ENTRY_INFO`,`stripping ${H} from absolute path`,{entry:this,path:H+this.path});let U=this.statCache.get(this.absolute);U?this[ONLSTAT](U):this[LSTAT]()}warn(d,B,V={}){return warnMethod(this,d,B,V)}emit(d,...B){return d===`error`&&(this.#hadError=!0),super.emit(d,...B)}[LSTAT](){fs$1.lstat(this.absolute,(d,B)=>{if(d)return this.emit(`error`,d);this[ONLSTAT](B)})}[ONLSTAT](d){this.statCache.set(this.absolute,d),this.stat=d,d.isFile()||(d.size=0),this.type=getType(d),this.emit(`stat`,d),this[PROCESS$1]()}[PROCESS$1](){switch(this.type){case`File`:return this[FILE$1]();case`Directory`:return this[DIRECTORY$1]();case`SymbolicLink`:return this[SYMLINK$1]();default:return this.end()}}[MODE](d){return modeFix(d,this.type===`Directory`,this.portable)}[PREFIX](d){return prefixPath(d,this.prefix)}[HEADER](){if(!this.stat)throw Error(`cannot write header before stat`);this.type===`Directory`&&this.portable&&(this.noMtime=!0),this.onWriteEntry?.(this),this.header=new Header({path:this[PREFIX](this.path),linkpath:this.type===`Link`&&this.linkpath!==void 0?this[PREFIX](this.linkpath):this.linkpath,mode:this[MODE](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 Pax({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[PREFIX](this.path),linkpath:this.type===`Link`&&this.linkpath!==void 0?this[PREFIX](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 d=this.header?.block;if(!d)throw Error(`failed to encode header`);super.write(d)}[DIRECTORY$1](){if(!this.stat)throw Error(`cannot create directory entry without stat`);this.path.slice(-1)!==`/`&&(this.path+=`/`),this.stat.size=0,this[HEADER](),this.end()}[SYMLINK$1](){fs$1.readlink(this.absolute,(d,B)=>{if(d)return this.emit(`error`,d);this[ONREADLINK](B)})}[ONREADLINK](d){this.linkpath=normalizeWindowsPath(d),this[HEADER](),this.end()}[HARDLINK$1](d){if(!this.stat)throw Error(`cannot create link entry without stat`);this.type=`Link`,this.linkpath=normalizeWindowsPath(path$1.relative(this.cwd,d)),this.stat.size=0,this[HEADER](),this.end()}[FILE$1](){if(!this.stat)throw Error(`cannot create file entry without stat`);if(this.stat.nlink>1){let d=`${this.stat.dev}:${this.stat.ino}`,B=this.linkCache.get(d);if(B?.indexOf(this.cwd)===0)return this[HARDLINK$1](B);this.linkCache.set(d,this.absolute)}if(this[HEADER](),this.stat.size===0)return this.end();this[OPENFILE]()}[OPENFILE](){fs$1.open(this.absolute,`r`,(d,B)=>{if(d)return this.emit(`error`,d);this[ONOPENFILE](B)})}[ONOPENFILE](d){if(this.fd=d,this.#hadError)return this[CLOSE]();if(!this.stat)throw Error(`should stat before calling onopenfile`);this.blockLen=512*Math.ceil(this.stat.size/512),this.blockRemain=this.blockLen;let B=Math.min(this.blockLen,this.maxReadSize);this.buf=Buffer.allocUnsafe(B),this.offset=0,this.pos=0,this.remain=this.stat.size,this.length=this.buf.length,this[READ]()}[READ](){let{fd:d,buf:B,offset:V,length:H,pos:U}=this;if(d===void 0||B===void 0)throw Error(`cannot read file without first opening`);fs$1.read(d,B,V,H,U,(d,B)=>{if(d)return this[CLOSE](()=>this.emit(`error`,d));this[ONREAD](B)})}[CLOSE](d=()=>{}){this.fd!==void 0&&fs$1.close(this.fd,d)}[ONREAD](d){if(d<=0&&this.remain>0){let d=Object.assign(Error(`encountered unexpected EOF`),{path:this.absolute,syscall:`read`,code:`EOF`});return this[CLOSE](()=>this.emit(`error`,d))}if(d>this.remain){let d=Object.assign(Error(`did not encounter expected EOF`),{path:this.absolute,syscall:`read`,code:`EOF`});return this[CLOSE](()=>this.emit(`error`,d))}if(!this.buf)throw Error(`should have created buffer prior to reading`);if(d===this.remain)for(let B=d;B<this.length&&d<this.blockRemain;B++)this.buf[B+this.offset]=0,d++,this.remain++;let B=this.offset===0&&d===this.buf.length?this.buf:this.buf.subarray(this.offset,this.offset+d);this.write(B)?this[ONDRAIN$1]():this[AWAITDRAIN](()=>this[ONDRAIN$1]())}[AWAITDRAIN](d){this.once(`drain`,d)}write(d,B,V){if(typeof B==`function`&&(V=B,B=void 0),typeof d==`string`&&(d=Buffer.from(d,typeof B==`string`?B:`utf8`)),this.blockRemain<d.length){let d=Object.assign(Error(`writing more data than expected`),{path:this.absolute});return this.emit(`error`,d)}return this.remain-=d.length,this.blockRemain-=d.length,this.pos+=d.length,this.offset+=d.length,super.write(d,null,V)}[ONDRAIN$1](){if(!this.remain)return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),this[CLOSE](d=>d?this.emit(`error`,d):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[READ]()}},WriteEntrySync=class extends WriteEntry{sync=!0;[LSTAT](){this[ONLSTAT](fs$1.lstatSync(this.absolute))}[SYMLINK$1](){this[ONREADLINK](fs$1.readlinkSync(this.absolute))}[OPENFILE](){this[ONOPENFILE](fs$1.openSync(this.absolute,`r`))}[READ](){let d=!0;try{let{fd:B,buf:V,offset:H,length:U,pos:W}=this;if(B===void 0||V===void 0)throw Error(`fd and buf must be set in READ method`);let G=fs$1.readSync(B,V,H,U,W);this[ONREAD](G),d=!1}finally{if(d)try{this[CLOSE](()=>{})}catch{}}}[AWAITDRAIN](d){d()}[CLOSE](d=()=>{}){this.fd!==void 0&&fs$1.closeSync(this.fd),d()}},WriteEntryTar=class extends Minipass{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(d,B,V={}){return warnMethod(this,d,B,V)}constructor(d,B={}){let V=dealias(B);super(),this.preservePaths=!!V.preservePaths,this.portable=!!V.portable,this.strict=!!V.strict,this.noPax=!!V.noPax,this.noMtime=!!V.noMtime,this.onWriteEntry=V.onWriteEntry,this.readEntry=d;let{type:H}=d;if(H===`Unsupported`)throw Error(`writing entry that should be ignored`);this.type=H,this.type===`Directory`&&this.portable&&(this.noMtime=!0),this.prefix=V.prefix,this.path=normalizeWindowsPath(d.path),this.mode=d.mode===void 0?void 0:this[MODE](d.mode),this.uid=this.portable?void 0:d.uid,this.gid=this.portable?void 0:d.gid,this.uname=this.portable?void 0:d.uname,this.gname=this.portable?void 0:d.gname,this.size=d.size,this.mtime=this.noMtime?void 0:V.mtime||d.mtime,this.atime=this.portable?void 0:d.atime,this.ctime=this.portable?void 0:d.ctime,this.linkpath=d.linkpath===void 0?void 0:normalizeWindowsPath(d.linkpath),typeof V.onwarn==`function`&&this.on(`warn`,V.onwarn);let U=!1;if(!this.preservePaths){let[d,B]=stripAbsolutePath(this.path);d&&typeof B==`string`&&(this.path=B,U=d)}this.remain=d.size,this.blockRemain=d.startBlockSize,this.onWriteEntry?.(this),this.header=new Header({path:this[PREFIX](this.path),linkpath:this.type===`Link`&&this.linkpath!==void 0?this[PREFIX](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}),U&&this.warn(`TAR_ENTRY_INFO`,`stripping ${U} from absolute path`,{entry:this,path:U+this.path}),this.header.encode()&&!this.noPax&&super.write(new Pax({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[PREFIX](this.path),linkpath:this.type===`Link`&&this.linkpath!==void 0?this[PREFIX](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 W=this.header?.block;if(!W)throw Error(`failed to encode header`);super.write(W),d.pipe(this)}[PREFIX](d){return prefixPath(d,this.prefix)}[MODE](d){return modeFix(d,this.type===`Directory`,this.portable)}write(d,B,V){typeof B==`function`&&(V=B,B=void 0),typeof d==`string`&&(d=Buffer.from(d,typeof B==`string`?B:`utf8`));let H=d.length;if(H>this.blockRemain)throw Error(`writing more to entry than is appropriate`);return this.blockRemain-=H,super.write(d,V)}end(d,B,V){return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),typeof d==`function`&&(V=d,B=void 0,d=void 0),typeof B==`function`&&(V=B,B=void 0),typeof d==`string`&&(d=Buffer.from(d,B??`utf8`)),V&&this.once(`finish`,V),d?super.end(d,V):super.end(V),this}};const getType=d=>d.isFile()?`File`:d.isDirectory()?`Directory`:d.isSymbolicLink()?`SymbolicLink`:`Unsupported`;var Yallist=class d{tail;head;length=0;static create(B=[]){return new d(B)}constructor(d=[]){for(let B of d)this.push(B)}*[Symbol.iterator](){for(let d=this.head;d;d=d.next)yield d.value}removeNode(d){if(d.list!==this)throw Error(`removing node which does not belong to this list`);let B=d.next,V=d.prev;return B&&(B.prev=V),V&&(V.next=B),d===this.head&&(this.head=B),d===this.tail&&(this.tail=V),this.length--,d.next=void 0,d.prev=void 0,d.list=void 0,B}unshiftNode(d){if(d===this.head)return;d.list&&d.list.removeNode(d);let B=this.head;d.list=this,d.next=B,B&&(B.prev=d),this.head=d,this.tail||=d,this.length++}pushNode(d){if(d===this.tail)return;d.list&&d.list.removeNode(d);let B=this.tail;d.list=this,d.prev=B,B&&(B.next=d),this.tail=d,this.head||=d,this.length++}push(...d){for(let B=0,V=d.length;B<V;B++)push(this,d[B]);return this.length}unshift(...d){for(var B=0,V=d.length;B<V;B++)unshift(this,d[B]);return this.length}pop(){if(!this.tail)return;let d=this.tail.value,B=this.tail;return this.tail=this.tail.prev,this.tail?this.tail.next=void 0:this.head=void 0,B.list=void 0,this.length--,d}shift(){if(!this.head)return;let d=this.head.value,B=this.head;return this.head=this.head.next,this.head?this.head.prev=void 0:this.tail=void 0,B.list=void 0,this.length--,d}forEach(d,B){B||=this;for(let V=this.head,H=0;V;H++)d.call(B,V.value,H,this),V=V.next}forEachReverse(d,B){B||=this;for(let V=this.tail,H=this.length-1;V;H--)d.call(B,V.value,H,this),V=V.prev}get(d){let B=0,V=this.head;for(;V&&B<d;B++)V=V.next;if(B===d&&V)return V.value}getReverse(d){let B=0,V=this.tail;for(;V&&B<d;B++)V=V.prev;if(B===d&&V)return V.value}map(B,V){V||=this;let H=new d;for(let d=this.head;d;)H.push(B.call(V,d.value,this)),d=d.next;return H}mapReverse(B,V){V||=this;var H=new d;for(let d=this.tail;d;)H.push(B.call(V,d.value,this)),d=d.prev;return H}reduce(d,B){let V,H=this.head;if(arguments.length>1)V=B;else if(this.head)H=this.head.next,V=this.head.value;else throw TypeError(`Reduce of empty list with no initial value`);for(var U=0;H;U++)V=d(V,H.value,U),H=H.next;return V}reduceReverse(d,B){let V,H=this.tail;if(arguments.length>1)V=B;else if(this.tail)H=this.tail.prev,V=this.tail.value;else throw TypeError(`Reduce of empty list with no initial value`);for(let B=this.length-1;H;B--)V=d(V,H.value,B),H=H.prev;return V}toArray(){let d=Array(this.length);for(let B=0,V=this.head;V;B++)d[B]=V.value,V=V.next;return d}toArrayReverse(){let d=Array(this.length);for(let B=0,V=this.tail;V;B++)d[B]=V.value,V=V.prev;return d}slice(B=0,V=this.length){V<0&&(V+=this.length),B<0&&(B+=this.length);let H=new d;if(V<B||V<0)return H;B<0&&(B=0),V>this.length&&(V=this.length);let U=this.head,W=0;for(W=0;U&&W<B;W++)U=U.next;for(;U&&W<V;W++,U=U.next)H.push(U.value);return H}sliceReverse(B=0,V=this.length){V<0&&(V+=this.length),B<0&&(B+=this.length);let H=new d;if(V<B||V<0)return H;B<0&&(B=0),V>this.length&&(V=this.length);let U=this.length,W=this.tail;for(;W&&U>V;U--)W=W.prev;for(;W&&U>B;U--,W=W.prev)H.push(W.value);return H}splice(d,B=0,...V){d>this.length&&(d=this.length-1),d<0&&(d=this.length+d);let H=this.head;for(let B=0;H&&B<d;B++)H=H.next;let U=[];for(let d=0;H&&d<B;d++)U.push(H.value),H=this.removeNode(H);H?H!==this.tail&&(H=H.prev):H=this.tail;for(let d of V)H=insertAfter(this,H,d);return U}reverse(){let d=this.head,B=this.tail;for(let B=d;B;B=B.prev){let d=B.prev;B.prev=B.next,B.next=d}return this.head=B,this.tail=d,this}};function insertAfter(d,B,V){let H=new Node(V,B,B?B.next:d.head,d);return H.next===void 0&&(d.tail=H),H.prev===void 0&&(d.head=H),d.length++,H}function push(d,B){d.tail=new Node(B,d.tail,void 0,d),d.head||=d.tail,d.length++}function unshift(d,B){d.head=new Node(B,void 0,d.head,d),d.tail||=d.head,d.length++}var Node=class{list;next;prev;value;constructor(d,B,V,H){this.list=H,this.value=d,B?(B.next=this,this.prev=B):this.prev=void 0,V?(V.prev=this,this.next=V):this.next=void 0}},PackJob=class{path;absolute;entry;stat;readdir;pending=!1;ignore=!1;piped=!1;constructor(d,B){this.path=d||`./`,this.absolute=B}};const EOF=Buffer.alloc(1024),ONSTAT=Symbol(`onStat`),ENDED$1=Symbol(`ended`),QUEUE=Symbol(`queue`),CURRENT=Symbol(`current`),PROCESS=Symbol(`process`),PROCESSING=Symbol(`processing`),PROCESSJOB=Symbol(`processJob`),JOBS=Symbol(`jobs`),JOBDONE=Symbol(`jobDone`),ADDFSENTRY=Symbol(`addFSEntry`),ADDTARENTRY=Symbol(`addTarEntry`),STAT=Symbol(`stat`),READDIR=Symbol(`readdir`),ONREADDIR=Symbol(`onreaddir`),PIPE=Symbol(`pipe`),ENTRY=Symbol(`entry`),ENTRYOPT=Symbol(`entryOpt`),WRITEENTRYCLASS=Symbol(`writeEntryClass`),WRITE=Symbol(`write`),ONDRAIN=Symbol(`ondrain`);var Pack=class extends Minipass{opt;cwd;maxReadSize;preservePaths;strict;noPax;prefix;linkCache;statCache;file;portable;zip;readdirCache;noDirRecurse;follow;noMtime;mtime;filter;jobs;[WRITEENTRYCLASS];onWriteEntry;[QUEUE];[JOBS]=0;[PROCESSING]=!1;[ENDED$1]=!1;constructor(d={}){if(super(),this.opt=d,this.file=d.file||``,this.cwd=d.cwd||process.cwd(),this.maxReadSize=d.maxReadSize,this.preservePaths=!!d.preservePaths,this.strict=!!d.strict,this.noPax=!!d.noPax,this.prefix=normalizeWindowsPath(d.prefix||``),this.linkCache=d.linkCache||new Map,this.statCache=d.statCache||new Map,this.readdirCache=d.readdirCache||new Map,this.onWriteEntry=d.onWriteEntry,this[WRITEENTRYCLASS]=WriteEntry,typeof d.onwarn==`function`&&this.on(`warn`,d.onwarn),this.portable=!!d.portable,d.gzip||d.brotli||d.zstd){if((d.gzip?1:0)+(d.brotli?1:0)+(d.zstd?1:0)>1)throw TypeError(`gzip, brotli, zstd are mutually exclusive`);if(d.gzip&&(typeof d.gzip!=`object`&&(d.gzip={}),this.portable&&(d.gzip.portable=!0),this.zip=new Gzip(d.gzip)),d.brotli&&(typeof d.brotli!=`object`&&(d.brotli={}),this.zip=new BrotliCompress(d.brotli)),d.zstd&&(typeof d.zstd!=`object`&&(d.zstd={}),this.zip=new ZstdCompress(d.zstd)),!this.zip)throw Error(`impossible`);let B=this.zip;B.on(`data`,d=>super.write(d)),B.on(`end`,()=>super.end()),B.on(`drain`,()=>this[ONDRAIN]()),this.on(`resume`,()=>B.resume())}else this.on(`drain`,this[ONDRAIN]);this.noDirRecurse=!!d.noDirRecurse,this.follow=!!d.follow,this.noMtime=!!d.noMtime,d.mtime&&(this.mtime=d.mtime),this.filter=typeof d.filter==`function`?d.filter:()=>!0,this[QUEUE]=new Yallist,this[JOBS]=0,this.jobs=Number(d.jobs)||4,this[PROCESSING]=!1,this[ENDED$1]=!1}[WRITE](d){return super.write(d)}add(d){return this.write(d),this}end(d,B,V){return typeof d==`function`&&(V=d,d=void 0),typeof B==`function`&&(V=B,B=void 0),d&&this.add(d),this[ENDED$1]=!0,this[PROCESS](),V&&V(),this}write(d){if(this[ENDED$1])throw Error(`write after end`);return d instanceof ReadEntry?this[ADDTARENTRY](d):this[ADDFSENTRY](d),this.flowing}[ADDTARENTRY](d){let B=normalizeWindowsPath(path$1.resolve(this.cwd,d.path));if(!this.filter(d.path,d))d.resume();else{let V=new PackJob(d.path,B);V.entry=new WriteEntryTar(d,this[ENTRYOPT](V)),V.entry.on(`end`,()=>this[JOBDONE](V)),this[JOBS]+=1,this[QUEUE].push(V)}this[PROCESS]()}[ADDFSENTRY](d){let B=normalizeWindowsPath(path$1.resolve(this.cwd,d));this[QUEUE].push(new PackJob(d,B)),this[PROCESS]()}[STAT](d){d.pending=!0,this[JOBS]+=1,fs$1[this.follow?`stat`:`lstat`](d.absolute,(B,V)=>{d.pending=!1,--this[JOBS],B?this.emit(`error`,B):this[ONSTAT](d,V)})}[ONSTAT](d,B){this.statCache.set(d.absolute,B),d.stat=B,this.filter(d.path,B)||(d.ignore=!0),this[PROCESS]()}[READDIR](d){d.pending=!0,this[JOBS]+=1,fs$1.readdir(d.absolute,(B,V)=>{if(d.pending=!1,--this[JOBS],B)return this.emit(`error`,B);this[ONREADDIR](d,V)})}[ONREADDIR](d,B){this.readdirCache.set(d.absolute,B),d.readdir=B,this[PROCESS]()}[PROCESS](){if(!this[PROCESSING]){this[PROCESSING]=!0;for(let d=this[QUEUE].head;d&&this[JOBS]<this.jobs;d=d.next)if(this[PROCESSJOB](d.value),d.value.ignore){let B=d.next;this[QUEUE].removeNode(d),d.next=B}this[PROCESSING]=!1,this[ENDED$1]&&!this[QUEUE].length&&this[JOBS]===0&&(this.zip?this.zip.end(EOF):(super.write(EOF),super.end()))}}get[CURRENT](){return this[QUEUE]&&this[QUEUE].head&&this[QUEUE].head.value}[JOBDONE](d){this[QUEUE].shift(),--this[JOBS],this[PROCESS]()}[PROCESSJOB](d){if(!d.pending){if(d.entry){d===this[CURRENT]&&!d.piped&&this[PIPE](d);return}if(!d.stat){let B=this.statCache.get(d.absolute);B?this[ONSTAT](d,B):this[STAT](d)}if(d.stat&&!d.ignore){if(!this.noDirRecurse&&d.stat.isDirectory()&&!d.readdir){let B=this.readdirCache.get(d.absolute);if(B?this[ONREADDIR](d,B):this[READDIR](d),!d.readdir)return}if(d.entry=this[ENTRY](d),!d.entry){d.ignore=!0;return}d===this[CURRENT]&&!d.piped&&this[PIPE](d)}}}[ENTRYOPT](d){return{onwarn:(d,B,V)=>this.warn(d,B,V),noPax:this.noPax,cwd:this.cwd,absolute:d.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}}[ENTRY](d){this[JOBS]+=1;try{return new this[WRITEENTRYCLASS](d.path,this[ENTRYOPT](d)).on(`end`,()=>this[JOBDONE](d)).on(`error`,d=>this.emit(`error`,d))}catch(d){this.emit(`error`,d)}}[ONDRAIN](){this[CURRENT]&&this[CURRENT].entry&&this[CURRENT].entry.resume()}[PIPE](d){d.piped=!0,d.readdir&&d.readdir.forEach(B=>{let V=d.path,H=V===`./`?``:V.replace(/\/*$/,`/`);this[ADDFSENTRY](H+B)});let B=d.entry,V=this.zip;if(!B)throw Error(`cannot pipe without source`);V?B.on(`data`,d=>{V.write(d)||B.pause()}):B.on(`data`,d=>{super.write(d)||B.pause()})}pause(){return this.zip&&this.zip.pause(),super.pause()}warn(d,B,V={}){warnMethod(this,d,B,V)}},PackSync=class extends Pack{sync=!0;constructor(d){super(d),this[WRITEENTRYCLASS]=WriteEntrySync}pause(){}resume(){}[STAT](d){let B=this.follow?`statSync`:`lstatSync`;this[ONSTAT](d,fs$1[B](d.absolute))}[READDIR](d){this[ONREADDIR](d,fs$1.readdirSync(d.absolute))}[PIPE](d){let B=d.entry,V=this.zip;if(d.readdir&&d.readdir.forEach(B=>{let V=d.path,H=V===`./`?``:V.replace(/\/*$/,`/`);this[ADDFSENTRY](H+B)}),!B)throw Error(`Cannot pipe without source`);V?B.on(`data`,d=>{V.write(d)}):B.on(`data`,d=>{super[WRITE](d)})}};const createFileSync=(d,V)=>{let H=new PackSync(d),U=new WriteStreamSync(d.file,{mode:d.mode||438});H.pipe(U),addFilesSync$1(H,V)},createFile=(d,B)=>{let V=new Pack(d),U=new WriteStream(d.file,{mode:d.mode||438});V.pipe(U);let W=new Promise((d,B)=>{U.on(`error`,B),U.on(`close`,d),V.on(`error`,B)});return addFilesAsync$1(V,B),W},addFilesSync$1=(d,B)=>{B.forEach(B=>{B.charAt(0)===`@`?list({file:path.resolve(d.cwd,B.slice(1)),sync:!0,noResume:!0,onReadEntry:B=>d.add(B)}):d.add(B)}),d.end()},addFilesAsync$1=async(d,B)=>{for(let V=0;V<B.length;V++){let H=String(B[V]);H.charAt(0)===`@`?await list({file:path.resolve(String(d.cwd),H.slice(1)),noResume:!0,onReadEntry:B=>{d.add(B)}}):d.add(H)}d.end()};makeCommand(createFileSync,createFile,(d,B)=>{let V=new PackSync(d);return addFilesSync$1(V,B),V},(d,B)=>{let V=new Pack(d);return addFilesAsync$1(V,B),V},(d,B)=>{if(!B?.length)throw TypeError(`no paths specified to add to archive`)});const isWindows$2=(process.env.__FAKE_PLATFORM__||process.platform)===`win32`,{O_CREAT,O_TRUNC,O_WRONLY}=fs$1.constants,UV_FS_O_FILEMAP=Number(process.env.__FAKE_FS_O_FILENAME__)||fs$1.constants.UV_FS_O_FILEMAP||0,fMapEnabled=isWindows$2&&!!UV_FS_O_FILEMAP,fMapFlag=UV_FS_O_FILEMAP|O_TRUNC|O_CREAT|O_WRONLY,getWriteFlag=fMapEnabled?d=>d<524288?fMapFlag:`w`:()=>`w`;var CwdError=class extends Error{path;code;syscall=`chdir`;constructor(d,B){super(`${B}: Cannot cd into '${d}'`),this.path=d,this.code=B}get name(){return`CwdError`}},SymlinkError=class extends Error{path;symlink;syscall=`symlink`;code=`TAR_SYMLINK_ERROR`;constructor(d,B){super(`TAR_SYMLINK_ERROR: Cannot extract through symbolic link`),this.symlink=d,this.path=B}get name(){return`SymlinkError`}};const checkCwd=(d,B)=>{fs.stat(d,(V,H)=>{(V||!H.isDirectory())&&(V=new CwdError(d,V?.code||`ENOTDIR`)),B(V)})},mkdir$1=(d,B,V)=>{d=normalizeWindowsPath(d);let H=B.umask??18,U=B.mode|448,W=(U&H)!==0,G=B.uid,K=B.gid,q=typeof G==`number`&&typeof K==`number`&&(G!==B.processUid||K!==B.processGid),J=B.preserve,Y=B.unlink,X=normalizeWindowsPath(B.cwd),$=(B,H)=>{B?V(B):H&&q?chownr(H,G,K,d=>$(d)):W?fs.chmod(d,U,V):V()};if(d===X)return checkCwd(d,$);if(J)return fsp.mkdir(d,{mode:U,recursive:!0}).then(d=>$(null,d??void 0),$);mkdir_(X,normalizeWindowsPath(path.relative(X,d)).split(`/`),U,Y,X,void 0,$)},mkdir_=(d,B,V,H,U,W,G)=>{if(!B.length)return G(null,W);let K=B.shift(),q=normalizeWindowsPath(path.resolve(d+`/`+K));fs.mkdir(q,V,onmkdir(q,B,V,H,U,W,G))},onmkdir=(d,B,V,H,U,W,G)=>K=>{K?fs.lstat(d,(q,J)=>{if(q)q.path=q.path&&normalizeWindowsPath(q.path),G(q);else if(J.isDirectory())mkdir_(d,B,V,H,U,W,G);else if(H)fs.unlink(d,K=>{if(K)return G(K);fs.mkdir(d,V,onmkdir(d,B,V,H,U,W,G))});else if(J.isSymbolicLink())return G(new SymlinkError(d,d+`/`+B.join(`/`)));else G(K)}):(W||=d,mkdir_(d,B,V,H,U,W,G))},checkCwdSync=d=>{let B=!1,V;try{B=fs.statSync(d).isDirectory()}catch(d){V=d?.code}finally{if(!B)throw new CwdError(d,V??`ENOTDIR`)}},mkdirSync=(d,B)=>{d=normalizeWindowsPath(d);let V=B.umask??18,H=B.mode|448,U=(H&V)!==0,W=B.uid,G=B.gid,K=typeof W==`number`&&typeof G==`number`&&(W!==B.processUid||G!==B.processGid),q=B.preserve,J=B.unlink,Y=normalizeWindowsPath(B.cwd),Z=B=>{B&&K&&chownrSync(B,W,G),U&&fs.chmodSync(d,H)};if(d===Y)return checkCwdSync(Y),Z();if(q)return Z(fs.mkdirSync(d,{mode:H,recursive:!0})??void 0);let Q=normalizeWindowsPath(path.relative(Y,d)).split(`/`),$;for(let d=Q.shift(),B=Y;d&&(B+=`/`+d);d=Q.shift()){B=normalizeWindowsPath(path.resolve(B));try{fs.mkdirSync(B,H),$||=B}catch{let d=fs.lstatSync(B);if(d.isDirectory())continue;if(J){fs.unlinkSync(B),fs.mkdirSync(B,H),$||=B;continue}else if(d.isSymbolicLink())return new SymlinkError(B,B+`/`+Q.join(`/`))}}return Z($)},normalizeCache=Object.create(null),MAX=1e4,cache=new Set,normalizeUnicode=d=>{cache.has(d)?cache.delete(d):normalizeCache[d]=d.normalize(`NFD`).toLocaleLowerCase(`en`).toLocaleUpperCase(`en`),cache.add(d);let B=normalizeCache[d],V=cache.size-MAX;if(V>MAX/10){for(let d of cache)if(cache.delete(d),delete normalizeCache[d],--V<=0)break}return B},isWindows$1=(process.env.TESTING_TAR_FAKE_PLATFORM||process.platform)===`win32`,getDirs=d=>d.split(`/`).slice(0,-1).reduce((d,B)=>{let V=d[d.length-1];return V!==void 0&&(B=join(V,B)),d.push(B||`/`),d},[]);var PathReservations=class{#queues=new Map;#reservations=new Map;#running=new Set;reserve(d,B){d=isWindows$1?[`win32 parallelization disabled`]:d.map(d=>stripTrailingSlashes(join(normalizeUnicode(d))));let V=new Set(d.map(d=>getDirs(d)).reduce((d,B)=>d.concat(B)));this.#reservations.set(B,{dirs:V,paths:d});for(let V of d){let d=this.#queues.get(V);d?d.push(B):this.#queues.set(V,[B])}for(let d of V){let V=this.#queues.get(d);if(!V)this.#queues.set(d,[new Set([B])]);else{let d=V[V.length-1];d instanceof Set?d.add(B):V.push(new Set([B]))}}return this.#run(B)}#getQueues(d){let B=this.#reservations.get(d);if(!B)throw Error(`function does not have any path reservations`);return{paths:B.paths.map(d=>this.#queues.get(d)),dirs:[...B.dirs].map(d=>this.#queues.get(d))}}check(d){let{paths:B,dirs:V}=this.#getQueues(d);return B.every(B=>B&&B[0]===d)&&V.every(B=>B&&B[0]instanceof Set&&B[0].has(d))}#run(d){return this.#running.has(d)||!this.check(d)?!1:(this.#running.add(d),d(()=>this.#clear(d)),!0)}#clear(d){if(!this.#running.has(d))return!1;let B=this.#reservations.get(d);if(!B)throw Error(`invalid reservation`);let{paths:V,dirs:H}=B,U=new Set;for(let B of V){let V=this.#queues.get(B);if(!V||V?.[0]!==d)continue;let H=V[1];if(!H){this.#queues.delete(B);continue}if(V.shift(),typeof H==`function`)U.add(H);else for(let d of H)U.add(d)}for(let B of H){let V=this.#queues.get(B),H=V?.[0];if(!(!V||!(H instanceof Set)))if(H.size===1&&V.length===1){this.#queues.delete(B);continue}else if(H.size===1){V.shift();let d=V[0];typeof d==`function`&&U.add(d)}else H.delete(d)}return this.#running.delete(d),U.forEach(d=>this.#run(d)),!0}};const ONENTRY=Symbol(`onEntry`),CHECKFS=Symbol(`checkFs`),CHECKFS2=Symbol(`checkFs2`),ISREUSABLE=Symbol(`isReusable`),MAKEFS=Symbol(`makeFs`),FILE=Symbol(`file`),DIRECTORY=Symbol(`directory`),LINK=Symbol(`link`),SYMLINK=Symbol(`symlink`),HARDLINK=Symbol(`hardlink`),UNSUPPORTED=Symbol(`unsupported`),CHECKPATH=Symbol(`checkPath`),STRIPABSOLUTEPATH=Symbol(`stripAbsolutePath`),MKDIR=Symbol(`mkdir`),ONERROR=Symbol(`onError`),PENDING=Symbol(`pending`),PEND=Symbol(`pend`),UNPEND=Symbol(`unpend`),ENDED=Symbol(`ended`),MAYBECLOSE=Symbol(`maybeClose`),SKIP=Symbol(`skip`),DOCHOWN=Symbol(`doChown`),UID=Symbol(`uid`),GID=Symbol(`gid`),CHECKED_CWD=Symbol(`checkedCwd`),isWindows=(process.env.TESTING_TAR_FAKE_PLATFORM||process.platform)===`win32`,unlinkFile=(d,B)=>{if(!isWindows)return fs.unlink(d,B);let V=d+`.DELETE.`+randomBytes(16).toString(`hex`);fs.rename(d,V,d=>{if(d)return B(d);fs.unlink(V,B)})},unlinkFileSync=d=>{if(!isWindows)return fs.unlinkSync(d);let B=d+`.DELETE.`+randomBytes(16).toString(`hex`);fs.renameSync(d,B),fs.unlinkSync(B)},uint32=(d,B,V)=>d!==void 0&&d===d>>>0?d:B!==void 0&&B===B>>>0?B:V;var Unpack=class extends Parser{[ENDED]=!1;[CHECKED_CWD]=!1;[PENDING]=0;reservations=new PathReservations;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(d={}){if(d.ondone=()=>{this[ENDED]=!0,this[MAYBECLOSE]()},super(d),this.transform=d.transform,this.chmod=!!d.chmod,typeof d.uid==`number`||typeof d.gid==`number`){if(typeof d.uid!=`number`||typeof d.gid!=`number`)throw TypeError(`cannot set owner without number uid and gid`);if(d.preserveOwner)throw TypeError(`cannot preserve owner in archive and also set owner explicitly`);this.uid=d.uid,this.gid=d.gid,this.setOwner=!0}else this.uid=void 0,this.gid=void 0,this.setOwner=!1;d.preserveOwner===void 0&&typeof d.uid!=`number`?this.preserveOwner=!!(process.getuid&&process.getuid()===0):this.preserveOwner=!!d.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 d.maxDepth==`number`?d.maxDepth:1024,this.forceChown=d.forceChown===!0,this.win32=!!d.win32||isWindows,this.newer=!!d.newer,this.keep=!!d.keep,this.noMtime=!!d.noMtime,this.preservePaths=!!d.preservePaths,this.unlink=!!d.unlink,this.cwd=normalizeWindowsPath(path.resolve(d.cwd||process.cwd())),this.strip=Number(d.strip)||0,this.processUmask=this.chmod?typeof d.processUmask==`number`?d.processUmask:process.umask():0,this.umask=typeof d.umask==`number`?d.umask:this.processUmask,this.dmode=d.dmode||511&~this.umask,this.fmode=d.fmode||438&~this.umask,this.on(`entry`,d=>this[ONENTRY](d))}warn(d,B,V={}){return(d===`TAR_BAD_ARCHIVE`||d===`TAR_ABORT`)&&(V.recoverable=!1),super.warn(d,B,V)}[MAYBECLOSE](){this[ENDED]&&this[PENDING]===0&&(this.emit(`prefinish`),this.emit(`finish`),this.emit(`end`))}[STRIPABSOLUTEPATH](d,B){let V=d[B];if(!V||this.preservePaths)return!0;let H=V.split(`/`);if(H.includes(`..`)||isWindows&&/^[a-z]:\.\.$/i.test(H[0]??``))return this.warn(`TAR_ENTRY_ERROR`,`${B} contains '..'`,{entry:d,[B]:V}),!1;let[U,W]=stripAbsolutePath(V);return U&&(d[B]=String(W),this.warn(`TAR_ENTRY_INFO`,`stripping ${U} from absolute ${B}`,{entry:d,[B]:V})),!0}[CHECKPATH](d){let B=normalizeWindowsPath(d.path),V=B.split(`/`);if(this.strip){if(V.length<this.strip)return!1;if(d.type===`Link`){let B=normalizeWindowsPath(String(d.linkpath)).split(`/`);if(B.length>=this.strip)d.linkpath=B.slice(this.strip).join(`/`);else return!1}V.splice(0,this.strip),d.path=V.join(`/`)}if(isFinite(this.maxDepth)&&V.length>this.maxDepth)return this.warn(`TAR_ENTRY_ERROR`,`path excessively deep`,{entry:d,path:B,depth:V.length,maxDepth:this.maxDepth}),!1;if(!this[STRIPABSOLUTEPATH](d,`path`)||!this[STRIPABSOLUTEPATH](d,`linkpath`))return!1;if(path.isAbsolute(d.path)?d.absolute=normalizeWindowsPath(path.resolve(d.path)):d.absolute=normalizeWindowsPath(path.resolve(this.cwd,d.path)),!this.preservePaths&&typeof d.absolute==`string`&&d.absolute.indexOf(this.cwd+`/`)!==0&&d.absolute!==this.cwd)return this.warn(`TAR_ENTRY_ERROR`,`path escaped extraction target`,{entry:d,path:normalizeWindowsPath(d.path),resolvedPath:d.absolute,cwd:this.cwd}),!1;if(d.absolute===this.cwd&&d.type!==`Directory`&&d.type!==`GNUDumpDir`)return!1;if(this.win32){let{root:B}=path.win32.parse(String(d.absolute));d.absolute=B+encode(String(d.absolute).slice(B.length));let{root:V}=path.win32.parse(d.path);d.path=V+encode(d.path.slice(V.length))}return!0}[ONENTRY](d){if(!this[CHECKPATH](d))return d.resume();switch(assert.equal(typeof d.absolute,`string`),d.type){case`Directory`:case`GNUDumpDir`:d.mode&&(d.mode|=448);case`File`:case`OldFile`:case`ContiguousFile`:case`Link`:case`SymbolicLink`:return this[CHECKFS](d);case`CharacterDevice`:case`BlockDevice`:case`FIFO`:default:return this[UNSUPPORTED](d)}}[ONERROR](d,B){d.name===`CwdError`?this.emit(`error`,d):(this.warn(`TAR_ENTRY_ERROR`,d,{entry:B}),this[UNPEND](),B.resume())}[MKDIR](d,B,V){mkdir$1(normalizeWindowsPath(d),{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:B},V)}[DOCHOWN](d){return this.forceChown||this.preserveOwner&&(typeof d.uid==`number`&&d.uid!==this.processUid||typeof d.gid==`number`&&d.gid!==this.processGid)||typeof this.uid==`number`&&this.uid!==this.processUid||typeof this.gid==`number`&&this.gid!==this.processGid}[UID](d){return uint32(this.uid,d.uid,this.processUid)}[GID](d){return uint32(this.gid,d.gid,this.processGid)}[FILE](d,B){let V=typeof d.mode==`number`?d.mode&4095:this.fmode,U=new WriteStream(String(d.absolute),{flags:getWriteFlag(d.size),mode:V,autoClose:!1});U.on(`error`,V=>{U.fd&&fs.close(U.fd,()=>{}),U.write=()=>!0,this[ONERROR](V,d),B()});let W=1,G=V=>{if(V){U.fd&&fs.close(U.fd,()=>{}),this[ONERROR](V,d),B();return}--W===0&&U.fd!==void 0&&fs.close(U.fd,V=>{V?this[ONERROR](V,d):this[UNPEND](),B()})};U.on(`finish`,()=>{let B=String(d.absolute),V=U.fd;if(typeof V==`number`&&d.mtime&&!this.noMtime){W++;let H=d.atime||new Date,U=d.mtime;fs.futimes(V,H,U,d=>d?fs.utimes(B,H,U,B=>G(B&&d)):G())}if(typeof V==`number`&&this[DOCHOWN](d)){W++;let H=this[UID](d),U=this[GID](d);typeof H==`number`&&typeof U==`number`&&fs.fchown(V,H,U,d=>d?fs.chown(B,H,U,B=>G(B&&d)):G())}G()});let K=this.transform&&this.transform(d)||d;K!==d&&(K.on(`error`,V=>{this[ONERROR](V,d),B()}),d.pipe(K)),K.pipe(U)}[DIRECTORY](d,B){let V=typeof d.mode==`number`?d.mode&4095:this.dmode;this[MKDIR](String(d.absolute),V,V=>{if(V){this[ONERROR](V,d),B();return}let H=1,U=()=>{--H===0&&(B(),this[UNPEND](),d.resume())};d.mtime&&!this.noMtime&&(H++,fs.utimes(String(d.absolute),d.atime||new Date,d.mtime,U)),this[DOCHOWN](d)&&(H++,fs.chown(String(d.absolute),Number(this[UID](d)),Number(this[GID](d)),U)),U()})}[UNSUPPORTED](d){d.unsupported=!0,this.warn(`TAR_ENTRY_UNSUPPORTED`,`unsupported entry type: ${d.type}`,{entry:d}),d.resume()}[SYMLINK](d,B){this[LINK](d,String(d.linkpath),`symlink`,B)}[HARDLINK](d,B){let V=normalizeWindowsPath(path.resolve(this.cwd,String(d.linkpath)));this[LINK](d,V,`link`,B)}[PEND](){this[PENDING]++}[UNPEND](){this[PENDING]--,this[MAYBECLOSE]()}[SKIP](d){this[UNPEND](),d.resume()}[ISREUSABLE](d,B){return d.type===`File`&&!this.unlink&&B.isFile()&&B.nlink<=1&&!isWindows}[CHECKFS](d){this[PEND]();let B=[d.path];d.linkpath&&B.push(d.linkpath),this.reservations.reserve(B,B=>this[CHECKFS2](d,B))}[CHECKFS2](d,B){let V=d=>{B(d)},H=()=>{this[MKDIR](this.cwd,this.dmode,B=>{if(B){this[ONERROR](B,d),V();return}this[CHECKED_CWD]=!0,U()})},U=()=>{if(d.absolute!==this.cwd){let B=normalizeWindowsPath(path.dirname(String(d.absolute)));if(B!==this.cwd)return this[MKDIR](B,this.dmode,B=>{if(B){this[ONERROR](B,d),V();return}W()})}W()},W=()=>{fs.lstat(String(d.absolute),(B,H)=>{if(H&&(this.keep||this.newer&&H.mtime>(d.mtime??H.mtime))){this[SKIP](d),V();return}if(B||this[ISREUSABLE](d,H))return this[MAKEFS](null,d,V);if(H.isDirectory()){if(d.type===`Directory`){let B=this.chmod&&d.mode&&(H.mode&4095)!==d.mode,U=B=>this[MAKEFS](B??null,d,V);return B?fs.chmod(String(d.absolute),Number(d.mode),U):U()}if(d.absolute!==this.cwd)return fs.rmdir(String(d.absolute),B=>this[MAKEFS](B??null,d,V))}if(d.absolute===this.cwd)return this[MAKEFS](null,d,V);unlinkFile(String(d.absolute),B=>this[MAKEFS](B??null,d,V))})};this[CHECKED_CWD]?U():H()}[MAKEFS](d,B,V){if(d){this[ONERROR](d,B),V();return}switch(B.type){case`File`:case`OldFile`:case`ContiguousFile`:return this[FILE](B,V);case`Link`:return this[HARDLINK](B,V);case`SymbolicLink`:return this[SYMLINK](B,V);case`Directory`:case`GNUDumpDir`:return this[DIRECTORY](B,V)}}[LINK](d,B,V,H){fs[V](B,String(d.absolute),B=>{B?this[ONERROR](B,d):(this[UNPEND](),d.resume()),H()})}};const callSync=d=>{try{return[null,d()]}catch(d){return[d,null]}};var UnpackSync=class extends Unpack{sync=!0;[MAKEFS](d,B){return super[MAKEFS](d,B,()=>{})}[CHECKFS](d){if(!this[CHECKED_CWD]){let B=this[MKDIR](this.cwd,this.dmode);if(B)return this[ONERROR](B,d);this[CHECKED_CWD]=!0}if(d.absolute!==this.cwd){let B=normalizeWindowsPath(path.dirname(String(d.absolute)));if(B!==this.cwd){let V=this[MKDIR](B,this.dmode);if(V)return this[ONERROR](V,d)}}let[B,V]=callSync(()=>fs.lstatSync(String(d.absolute)));if(V&&(this.keep||this.newer&&V.mtime>(d.mtime??V.mtime)))return this[SKIP](d);if(B||this[ISREUSABLE](d,V))return this[MAKEFS](null,d);if(V.isDirectory()){if(d.type===`Directory`){let[B]=this.chmod&&d.mode&&(V.mode&4095)!==d.mode?callSync(()=>{fs.chmodSync(String(d.absolute),Number(d.mode))}):[];return this[MAKEFS](B,d)}let[B]=callSync(()=>fs.rmdirSync(String(d.absolute)));this[MAKEFS](B,d)}let[H]=d.absolute===this.cwd?[]:callSync(()=>unlinkFileSync(String(d.absolute)));this[MAKEFS](H,d)}[FILE](d,B){let V=typeof d.mode==`number`?d.mode&4095:this.fmode,H=V=>{let H;try{fs.closeSync(U)}catch(d){H=d}(V||H)&&this[ONERROR](V||H,d),B()},U;try{U=fs.openSync(String(d.absolute),getWriteFlag(d.size),V)}catch(d){return H(d)}let W=this.transform&&this.transform(d)||d;W!==d&&(W.on(`error`,B=>this[ONERROR](B,d)),d.pipe(W)),W.on(`data`,d=>{try{fs.writeSync(U,d,0,d.length)}catch(d){H(d)}}),W.on(`end`,()=>{let B=null;if(d.mtime&&!this.noMtime){let V=d.atime||new Date,H=d.mtime;try{fs.futimesSync(U,V,H)}catch(U){try{fs.utimesSync(String(d.absolute),V,H)}catch{B=U}}}if(this[DOCHOWN](d)){let V=this[UID](d),H=this[GID](d);try{fs.fchownSync(U,Number(V),Number(H))}catch(U){try{fs.chownSync(String(d.absolute),Number(V),Number(H))}catch{B||=U}}}H(B)})}[DIRECTORY](d,B){let V=typeof d.mode==`number`?d.mode&4095:this.dmode,H=this[MKDIR](String(d.absolute),V);if(H){this[ONERROR](H,d),B();return}if(d.mtime&&!this.noMtime)try{fs.utimesSync(String(d.absolute),d.atime||new Date,d.mtime)}catch{}if(this[DOCHOWN](d))try{fs.chownSync(String(d.absolute),Number(this[UID](d)),Number(this[GID](d)))}catch{}B(),d.resume()}[MKDIR](d,B){try{return mkdirSync(normalizeWindowsPath(d),{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:B})}catch(d){return d}}[LINK](d,B,V,H){let U=`${V}Sync`;try{fs[U](B,String(d.absolute)),H(),d.resume()}catch(B){return this[ONERROR](B,d)}}};const extract=makeCommand(d=>{let B=new UnpackSync(d),H=d.file,U=fs.statSync(H);new ReadStreamSync(H,{readSize:d.maxReadSize||16*1024*1024,size:U.size}).pipe(B)},(d,B)=>{let V=new Unpack(d),H=d.maxReadSize||16*1024*1024,W=d.file;return new Promise((d,B)=>{V.on(`error`,B),V.on(`close`,d),fs.stat(W,(d,G)=>{if(d)B(d);else{let d=new ReadStream(W,{readSize:H,size:G.size});d.on(`error`,B),d.pipe(V)}})})},d=>new UnpackSync(d),d=>new Unpack(d),(d,B)=>{B?.length&&filesFilter(d,B)}),replaceSync=(d,B)=>{let V=new PackSync(d),H=!0,U,W;try{try{U=fs.openSync(d.file,`r+`)}catch(B){if(B?.code===`ENOENT`)U=fs.openSync(d.file,`w+`);else throw B}let G=fs.fstatSync(U),K=Buffer.alloc(512);POSITION:for(W=0;W<G.size;W+=512){for(let d=0,B=0;d<512;d+=B){if(B=fs.readSync(U,K,d,K.length-d,W+d),W===0&&K[0]===31&&K[1]===139)throw Error(`cannot append to compressed archives`);if(!B)break POSITION}let B=new Header(K);if(!B.cksumValid)break;let V=512*Math.ceil((B.size||0)/512);if(W+V+512>G.size)break;W+=V,d.mtimeCache&&B.mtime&&d.mtimeCache.set(String(B.path),B.mtime)}H=!1,streamSync(d,V,W,U,B)}finally{if(H)try{fs.closeSync(U)}catch{}}},streamSync=(d,V,H,U,W)=>{let G=new WriteStreamSync(d.file,{fd:U,start:H});V.pipe(G),addFilesSync(V,W)},replaceAsync=(d,B)=>{B=Array.from(B);let V=new Pack(d),U=(B,V,H)=>{let U=(d,V)=>{d?fs.close(B,B=>H(d)):H(null,V)},W=0;if(V===0)return U(null,0);let G=0,K=Buffer.alloc(512),q=(H,J)=>{if(H||J===void 0)return U(H);if(G+=J,G<512&&J)return fs.read(B,K,G,K.length-G,W+G,q);if(W===0&&K[0]===31&&K[1]===139)return U(Error(`cannot append to compressed archives`));if(G<512)return U(null,W);let Y=new Header(K);if(!Y.cksumValid)return U(null,W);let X=512*Math.ceil((Y.size??0)/512);if(W+X+512>V||(W+=X+512,W>=V))return U(null,W);d.mtimeCache&&Y.mtime&&d.mtimeCache.set(String(Y.path),Y.mtime),G=0,fs.read(B,K,0,512,W,q)};fs.read(B,K,0,512,W,q)};return new Promise((W,G)=>{V.on(`error`,G);let K=`r+`,q=(J,Y)=>{if(J&&J.code===`ENOENT`&&K===`r+`)return K=`w+`,fs.open(d.file,K,q);if(J||!Y)return G(J);fs.fstat(Y,(K,q)=>{if(K)return fs.close(Y,()=>G(K));U(Y,q.size,(U,K)=>{if(U)return G(U);let q=new WriteStream(d.file,{fd:Y,start:K});V.pipe(q),q.on(`error`,G),q.on(`close`,W),addFilesAsync(V,B)})})};fs.open(d.file,K,q)})},addFilesSync=(d,B)=>{B.forEach(B=>{B.charAt(0)===`@`?list({file:path.resolve(d.cwd,B.slice(1)),sync:!0,noResume:!0,onReadEntry:B=>d.add(B)}):d.add(B)}),d.end()},addFilesAsync=async(d,B)=>{for(let V=0;V<B.length;V++){let H=String(B[V]);H.charAt(0)===`@`?await list({file:path.resolve(String(d.cwd),H.slice(1)),noResume:!0,onReadEntry:B=>d.add(B)}):d.add(H)}d.end()},replace=makeCommand(replaceSync,replaceAsync,()=>{throw TypeError(`file is required`)},()=>{throw TypeError(`file is required`)},(d,B)=>{if(!isFile(d))throw TypeError(`file is required`);if(d.gzip||d.brotli||d.zstd||d.file.endsWith(`.br`)||d.file.endsWith(`.tbr`))throw TypeError(`cannot append to compressed archives`);if(!B?.length)throw TypeError(`no paths specified to add/replace`)});makeCommand(replace.syncFile,replace.asyncFile,replace.syncNoFile,replace.asyncNoFile,(d,B=[])=>{replace.validate?.(d,B),mtimeFilter(d)});const mtimeFilter=d=>{let B=d.filter;d.mtimeCache||=new Map,d.filter=B?(V,H)=>B(V,H)&&!((d.mtimeCache?.get(V)??H.mtime??0)>(H.mtime??0)):(B,V)=>!((d.mtimeCache?.get(B)??V.mtime??0)>(V.mtime??0))};export{extract as t};
|
package/dist/cli.d.mts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export { };
|
package/dist/cli.mjs
CHANGED
|
@@ -1,102 +1,90 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import 'pathe';
|
|
10
|
-
import 'defu';
|
|
11
|
-
import 'nypm';
|
|
12
|
-
import 'node:stream';
|
|
13
|
-
import 'node:child_process';
|
|
14
|
-
import 'node:os';
|
|
15
|
-
import 'node:util';
|
|
16
|
-
import 'node-fetch-native/proxy';
|
|
2
|
+
import "./_chunks/libs/@isaacs/fs-minipass.mjs";
|
|
3
|
+
import "./_chunks/libs/tar.mjs";
|
|
4
|
+
import "./_chunks/libs/minizlib.mjs";
|
|
5
|
+
import "./_chunks/libs/chownr.mjs";
|
|
6
|
+
import { i as relative } from "./_chunks/libs/nypm.mjs";
|
|
7
|
+
import { r as startShell, t as downloadTemplate } from "./_chunks/giget.mjs";
|
|
8
|
+
import { n as runMain, t as defineCommand } from "./_chunks/libs/citty.mjs";
|
|
17
9
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
name: name,
|
|
23
|
-
version: version,
|
|
24
|
-
description: description};
|
|
10
|
+
//#region package.json
|
|
11
|
+
var name = "giget";
|
|
12
|
+
var version = "2.0.0";
|
|
13
|
+
var description = "Download templates and git repositories with pleasure!";
|
|
25
14
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
}
|
|
102
|
-
runMain(mainCommand);
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region src/cli.ts
|
|
17
|
+
runMain(defineCommand({
|
|
18
|
+
meta: {
|
|
19
|
+
name,
|
|
20
|
+
version,
|
|
21
|
+
description
|
|
22
|
+
},
|
|
23
|
+
args: {
|
|
24
|
+
template: {
|
|
25
|
+
type: "positional",
|
|
26
|
+
required: true,
|
|
27
|
+
description: "Template name or a URI describing provider, repository, subdir, and branch/ref"
|
|
28
|
+
},
|
|
29
|
+
dir: {
|
|
30
|
+
type: "positional",
|
|
31
|
+
description: "A relative or absolute path where to extract the template",
|
|
32
|
+
required: false
|
|
33
|
+
},
|
|
34
|
+
auth: {
|
|
35
|
+
type: "string",
|
|
36
|
+
description: "Custom Authorization token to use for downloading template. (Can be overridden with `GIGET_AUTH` environment variable)"
|
|
37
|
+
},
|
|
38
|
+
cwd: {
|
|
39
|
+
type: "string",
|
|
40
|
+
description: "Set current working directory to resolve dirs relative to it"
|
|
41
|
+
},
|
|
42
|
+
force: {
|
|
43
|
+
type: "boolean",
|
|
44
|
+
description: "Clone to existing directory even if exists"
|
|
45
|
+
},
|
|
46
|
+
forceClean: {
|
|
47
|
+
type: "boolean",
|
|
48
|
+
description: "Remove any existing directory or file recursively before cloning"
|
|
49
|
+
},
|
|
50
|
+
offline: {
|
|
51
|
+
type: "boolean",
|
|
52
|
+
description: "Do not attempt to download and use cached version"
|
|
53
|
+
},
|
|
54
|
+
preferOffline: {
|
|
55
|
+
type: "boolean",
|
|
56
|
+
description: "Use cache if exists otherwise try to download"
|
|
57
|
+
},
|
|
58
|
+
shell: {
|
|
59
|
+
type: "boolean",
|
|
60
|
+
description: "Open a new shell with the current working directory set to the cloned directory (experimental)"
|
|
61
|
+
},
|
|
62
|
+
install: {
|
|
63
|
+
type: "boolean",
|
|
64
|
+
description: "Install dependencies after cloning"
|
|
65
|
+
},
|
|
66
|
+
verbose: {
|
|
67
|
+
type: "boolean",
|
|
68
|
+
description: "Show verbose debugging info"
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
run: async ({ args }) => {
|
|
72
|
+
if (args.verbose) process.env.DEBUG = process.env.DEBUG || "true";
|
|
73
|
+
const r = await downloadTemplate(args.template, {
|
|
74
|
+
dir: args.dir,
|
|
75
|
+
force: args.force,
|
|
76
|
+
forceClean: args.forceClean,
|
|
77
|
+
offline: args.offline,
|
|
78
|
+
preferOffline: args.preferOffline,
|
|
79
|
+
auth: args.auth,
|
|
80
|
+
install: args.install
|
|
81
|
+
});
|
|
82
|
+
const _from = r.name || r.url;
|
|
83
|
+
const _to = relative(process.cwd(), r.dir) || "./";
|
|
84
|
+
console.log(`✨ Successfully cloned \`${_from}\` to \`${_to}\`\n`);
|
|
85
|
+
if (args.shell) startShell(r.dir);
|
|
86
|
+
}
|
|
87
|
+
}));
|
|
88
|
+
|
|
89
|
+
//#endregion
|
|
90
|
+
export { };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,49 +1,55 @@
|
|
|
1
|
+
import "node:http";
|
|
2
|
+
|
|
3
|
+
//#region src/types.d.ts
|
|
1
4
|
interface GitInfo {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
provider: "github" | "gitlab" | "bitbucket" | "sourcehut";
|
|
6
|
+
repo: string;
|
|
7
|
+
subdir: string;
|
|
8
|
+
ref: string;
|
|
6
9
|
}
|
|
7
10
|
interface TemplateInfo {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
name: string;
|
|
12
|
+
tar: string;
|
|
13
|
+
version?: string;
|
|
14
|
+
subdir?: string;
|
|
15
|
+
url?: string;
|
|
16
|
+
defaultDir?: string;
|
|
17
|
+
headers?: Record<string, string | undefined>;
|
|
18
|
+
source?: never;
|
|
19
|
+
dir?: never;
|
|
20
|
+
[key: string]: any;
|
|
18
21
|
}
|
|
19
22
|
type TemplateProvider = (input: string, options: {
|
|
20
|
-
|
|
23
|
+
auth?: string;
|
|
21
24
|
}) => TemplateInfo | Promise<TemplateInfo> | null;
|
|
22
|
-
|
|
25
|
+
//#endregion
|
|
26
|
+
//#region src/giget.d.ts
|
|
23
27
|
interface DownloadTemplateOptions {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
28
|
+
provider?: string;
|
|
29
|
+
force?: boolean;
|
|
30
|
+
forceClean?: boolean;
|
|
31
|
+
offline?: boolean;
|
|
32
|
+
preferOffline?: boolean;
|
|
33
|
+
providers?: Record<string, TemplateProvider>;
|
|
34
|
+
dir?: string;
|
|
35
|
+
registry?: false | string;
|
|
36
|
+
cwd?: string;
|
|
37
|
+
auth?: string;
|
|
38
|
+
install?: boolean;
|
|
39
|
+
silent?: boolean;
|
|
36
40
|
}
|
|
37
41
|
type DownloadTemplateResult = Omit<TemplateInfo, "dir" | "source"> & {
|
|
38
|
-
|
|
39
|
-
|
|
42
|
+
dir: string;
|
|
43
|
+
source: string;
|
|
40
44
|
};
|
|
41
45
|
declare function downloadTemplate(input: string, options?: DownloadTemplateOptions): Promise<DownloadTemplateResult>;
|
|
42
|
-
|
|
46
|
+
//#endregion
|
|
47
|
+
//#region src/registry.d.ts
|
|
43
48
|
declare const registryProvider: (registryEndpoint?: string, options?: {
|
|
44
|
-
|
|
49
|
+
auth?: string;
|
|
45
50
|
}) => TemplateProvider;
|
|
46
|
-
|
|
51
|
+
//#endregion
|
|
52
|
+
//#region src/_utils.d.ts
|
|
47
53
|
declare function startShell(cwd: string): void;
|
|
48
|
-
|
|
49
|
-
export {
|
|
54
|
+
//#endregion
|
|
55
|
+
export { DownloadTemplateOptions, DownloadTemplateResult, GitInfo, TemplateInfo, TemplateProvider, downloadTemplate, registryProvider, startShell };
|
package/dist/index.mjs
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
import 'node:child_process';
|
|
10
|
-
import 'node:os';
|
|
11
|
-
import 'node:util';
|
|
12
|
-
import 'node-fetch-native/proxy';
|
|
1
|
+
import "./_chunks/libs/@isaacs/fs-minipass.mjs";
|
|
2
|
+
import "./_chunks/libs/tar.mjs";
|
|
3
|
+
import "./_chunks/libs/minizlib.mjs";
|
|
4
|
+
import "./_chunks/libs/chownr.mjs";
|
|
5
|
+
import "./_chunks/libs/nypm.mjs";
|
|
6
|
+
import { n as registryProvider, r as startShell, t as downloadTemplate } from "./_chunks/giget.mjs";
|
|
7
|
+
|
|
8
|
+
export { downloadTemplate, registryProvider, startShell };
|
package/package.json
CHANGED
|
@@ -1,26 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "giget",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "Download templates and git repositories with pleasure!",
|
|
5
5
|
"repository": "unjs/giget",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"sideEffects": false,
|
|
8
8
|
"type": "module",
|
|
9
9
|
"exports": {
|
|
10
|
-
".":
|
|
11
|
-
"import": {
|
|
12
|
-
"types": "./dist/index.d.mts",
|
|
13
|
-
"default": "./dist/index.mjs"
|
|
14
|
-
},
|
|
15
|
-
"require": {
|
|
16
|
-
"types": "./dist/index.d.cts",
|
|
17
|
-
"default": "./dist/index.cjs"
|
|
18
|
-
}
|
|
19
|
-
}
|
|
10
|
+
".": "./dist/index.mjs"
|
|
20
11
|
},
|
|
21
|
-
"
|
|
22
|
-
"module": "./dist/index.mjs",
|
|
23
|
-
"types": "./dist/index.d.ts",
|
|
12
|
+
"types": "./dist/index.d.mts",
|
|
24
13
|
"bin": {
|
|
25
14
|
"giget": "./dist/cli.mjs"
|
|
26
15
|
},
|
|
@@ -28,37 +17,34 @@
|
|
|
28
17
|
"dist"
|
|
29
18
|
],
|
|
30
19
|
"scripts": {
|
|
31
|
-
"build": "
|
|
20
|
+
"build": "obuild",
|
|
32
21
|
"dev": "vitest dev",
|
|
33
|
-
"giget": "
|
|
22
|
+
"giget": "node ./src/cli.ts",
|
|
34
23
|
"lint": "eslint . && prettier -c src test",
|
|
35
24
|
"lint:fix": "eslint . --fix && prettier -w src test",
|
|
36
|
-
"prepack": "unbuild",
|
|
37
25
|
"play": "pnpm giget --force-clean --verbose unjs .tmp/clone",
|
|
38
|
-
"release": "pnpm test && changelogen --release && npm publish && git push --follow-tags",
|
|
39
|
-
"test": "pnpm lint && vitest run --coverage"
|
|
40
|
-
|
|
41
|
-
"dependencies": {
|
|
42
|
-
"citty": "^0.1.6",
|
|
43
|
-
"consola": "^3.4.0",
|
|
44
|
-
"defu": "^6.1.4",
|
|
45
|
-
"node-fetch-native": "^1.6.6",
|
|
46
|
-
"nypm": "^0.5.4",
|
|
47
|
-
"pathe": "^2.0.3",
|
|
48
|
-
"tar": "^6.2.1"
|
|
26
|
+
"release": "pnpm test && pnpm build && changelogen --release && npm publish && git push --follow-tags",
|
|
27
|
+
"test": "pnpm lint && pnpm test:types && vitest run --coverage",
|
|
28
|
+
"test:types": "tsgo --noEmit"
|
|
49
29
|
},
|
|
50
30
|
"devDependencies": {
|
|
51
|
-
"@types/node": "^
|
|
31
|
+
"@types/node": "^25.0.9",
|
|
52
32
|
"@types/tar": "^6.1.13",
|
|
53
|
-
"@
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"
|
|
33
|
+
"@typescript/native-preview": "7.0.0-dev.20260120.1",
|
|
34
|
+
"@vitest/coverage-v8": "^4.0.17",
|
|
35
|
+
"changelogen": "^0.6.2",
|
|
36
|
+
"citty": "^0.2.0",
|
|
37
|
+
"eslint": "^9.39.2",
|
|
38
|
+
"eslint-config-unjs": "^0.6.2",
|
|
39
|
+
"nypm": "^0.6.3",
|
|
40
|
+
"obuild": "^0.4.18",
|
|
41
|
+
"pathe": "^2.0.3",
|
|
42
|
+
"prettier": "^3.8.0",
|
|
43
|
+
"rolldown": "1.0.0-beta.60",
|
|
44
|
+
"tar": "^7.5.4",
|
|
45
|
+
"typescript": "^5.9.3",
|
|
46
|
+
"unbuild": "^3.6.1",
|
|
47
|
+
"vitest": "^4.0.17"
|
|
62
48
|
},
|
|
63
|
-
"packageManager": "pnpm@10.
|
|
49
|
+
"packageManager": "pnpm@10.28.1"
|
|
64
50
|
}
|