giget 3.1.1 → 3.1.2
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/README.md +1 -3
- package/dist/_chunks/giget.mjs +3 -16
- package/dist/_chunks/libs/@isaacs/fs-minipass.mjs +527 -1
- package/dist/_chunks/libs/chownr.mjs +48 -1
- package/dist/_chunks/libs/citty.mjs +263 -5
- package/dist/_chunks/libs/minizlib.mjs +261 -1
- package/dist/_chunks/libs/nypm.mjs +677 -2
- package/dist/_chunks/libs/tar.mjs +2102 -3
- package/dist/_chunks/rolldown-runtime.mjs +6 -14
- package/dist/cli.mjs +4 -14
- package/dist/index.mjs +1 -2
- package/package.json +21 -21
|
@@ -1,3 +1,2102 @@
|
|
|
1
|
-
import{t as __exportAll}from"../rolldown-runtime.mjs";
|
|
2
|
-
|
|
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,U=d.file;return new Promise((d,B)=>{V.on(`error`,B),V.on(`end`,d),fs.stat(U,(d,G)=>{if(d)B(d);else{let d=new ReadStream(U,{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{sync=!1;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)?B.isFile()&&B.nlink>1&&d===this[CURRENT]&&!this.linkCache.get(`${B.dev}:${B.ino}`)&&!this.sync&&this[PROCESSJOB](d):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,B)=>{let H=new PackSync(d),U=new WriteStreamSync(d.file,{mode:d.mode||438});H.pipe(U),addFilesSync$1(H,B)},createFile=(d,B)=>{let V=new Pack(d),H=new WriteStream(d.file,{mode:d.mode||438});V.pipe(H);let W=new Promise((d,B)=>{H.on(`error`,B),H.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),Z=(B,H)=>{B?V(B):H&&q?chownr(H,G,K,d=>Z(d)):W?fs.chmod(d,U,V):V()};if(d===X)return checkCwd(d,Z);if(J)return fsp.mkdir(d,{mode:U,recursive:!0}).then(d=>Z(null,d??void 0),Z);mkdir_(X,normalizeWindowsPath(path.relative(X,d)).split(`/`),U,Y,X,void 0,Z)},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),X=B=>{B&&K&&chownrSync(B,W,G),U&&fs.chmodSync(d,H)};if(d===Y)return checkCwdSync(Y),X();if(q)return X(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 X($)},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]??``)){if(B===`path`)return this.warn(`TAR_ENTRY_ERROR`,`${B} contains '..'`,{entry:d,[B]:V}),!1;{let H=path.posix.dirname(d.path),U=path.posix.normalize(path.posix.join(H,V));if(U.startsWith(`../`)||U===`..`)return this.warn(`TAR_ENTRY_ERROR`,`${B} escapes extraction directory`,{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,H=new WriteStream(String(d.absolute),{flags:getWriteFlag(d.size),mode:V,autoClose:!1});H.on(`error`,V=>{H.fd&&fs.close(H.fd,()=>{}),H.write=()=>!0,this[ONERROR](V,d),B()});let W=1,G=V=>{if(V){H.fd&&fs.close(H.fd,()=>{}),this[ONERROR](V,d),B();return}--W===0&&H.fd!==void 0&&fs.close(H.fd,V=>{V?this[ONERROR](V,d):this[UNPEND](),B()})};H.on(`finish`,()=>{let B=String(d.absolute),V=H.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(H)}[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),V=d.file,U=fs.statSync(V);new ReadStreamSync(V,{readSize:d.maxReadSize||16*1024*1024,size:U.size}).pipe(B)},(d,B)=>{let V=new Unpack(d),H=d.maxReadSize||16*1024*1024,U=d.file;return new Promise((d,B)=>{V.on(`error`,B),V.on(`close`,d),fs.stat(U,(d,G)=>{if(d)B(d);else{let d=new ReadStream(U,{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,B,H,U,W)=>{let G=new WriteStreamSync(d.file,{fd:U,start:H});B.pipe(G),addFilesSync(B,W)},replaceAsync=(d,B)=>{B=Array.from(B);let V=new Pack(d),H=(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));H(Y,q.size,(H,K)=>{if(H)return G(H);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))};var esm_exports=__exportAll({Header:()=>Header,Pack:()=>Pack,PackJob:()=>PackJob,PackSync:()=>PackSync,Parser:()=>Parser,Pax:()=>Pax,ReadEntry:()=>ReadEntry,Unpack:()=>Unpack,UnpackSync:()=>UnpackSync,WriteEntry:()=>WriteEntry,WriteEntrySync:()=>WriteEntrySync,WriteEntryTar:()=>WriteEntryTar,extract:()=>extract,filesFilter:()=>filesFilter,list:()=>list,replace:()=>replace});export{esm_exports as t};
|
|
1
|
+
import { t as __exportAll } from "../rolldown-runtime.mjs";
|
|
2
|
+
import { a as Minipass, i as WriteStreamSync, n as ReadStreamSync, r as WriteStream, t as ReadStream } from "./@isaacs/fs-minipass.mjs";
|
|
3
|
+
import { a as ZstdCompress, i as Unzip, n as BrotliDecompress, o as ZstdDecompress, r as Gzip, t as BrotliCompress } from "./minizlib.mjs";
|
|
4
|
+
import { n as chownrSync, t as chownr } from "./chownr.mjs";
|
|
5
|
+
import fsp from "node:fs/promises";
|
|
6
|
+
import fs from "node:fs";
|
|
7
|
+
import path, { basename, join, posix, win32 } from "node:path";
|
|
8
|
+
import { EventEmitter } from "events";
|
|
9
|
+
import fs$1 from "fs";
|
|
10
|
+
import path$1, { dirname as dirname$1, parse } from "path";
|
|
11
|
+
import assert from "node:assert";
|
|
12
|
+
import { randomBytes } from "node:crypto";
|
|
13
|
+
const argmap = new Map([
|
|
14
|
+
[`C`, `cwd`],
|
|
15
|
+
[`f`, `file`],
|
|
16
|
+
[`z`, `gzip`],
|
|
17
|
+
[`P`, `preservePaths`],
|
|
18
|
+
[`U`, `unlink`],
|
|
19
|
+
[`strip-components`, `strip`],
|
|
20
|
+
[`stripComponents`, `strip`],
|
|
21
|
+
[`keep-newer`, `newer`],
|
|
22
|
+
[`keepNewer`, `newer`],
|
|
23
|
+
[`keep-newer-files`, `newer`],
|
|
24
|
+
[`keepNewerFiles`, `newer`],
|
|
25
|
+
[`k`, `keep`],
|
|
26
|
+
[`keep-existing`, `keep`],
|
|
27
|
+
[`keepExisting`, `keep`],
|
|
28
|
+
[`m`, `noMtime`],
|
|
29
|
+
[`no-mtime`, `noMtime`],
|
|
30
|
+
[`p`, `preserveOwner`],
|
|
31
|
+
[`L`, `follow`],
|
|
32
|
+
[`h`, `follow`],
|
|
33
|
+
[`onentry`, `onReadEntry`]
|
|
34
|
+
]), isSyncFile = (e) => !!e.sync && !!e.file, isAsyncFile = (e) => !e.sync && !!e.file, isSyncNoFile = (e) => !!e.sync && !e.file, isAsyncNoFile = (e) => !e.sync && !e.file, isFile = (e) => !!e.file, dealiasKey = (e) => argmap.get(e) || e, dealias = (e = {}) => {
|
|
35
|
+
if (!e) return {};
|
|
36
|
+
let t = {};
|
|
37
|
+
for (let [n, r] of Object.entries(e)) {
|
|
38
|
+
let e = dealiasKey(n);
|
|
39
|
+
t[e] = r;
|
|
40
|
+
}
|
|
41
|
+
return t.chmod === void 0 && t.noChmod === !1 && (t.chmod = !0), delete t.noChmod, t;
|
|
42
|
+
}, makeCommand = (e, t, n, r, i) => Object.assign((a = [], o, s) => {
|
|
43
|
+
Array.isArray(a) && (o = a, a = {}), typeof o == `function` && (s = o, o = void 0), o = o ? Array.from(o) : [];
|
|
44
|
+
let c = dealias(a);
|
|
45
|
+
if (i?.(c, o), isSyncFile(c)) {
|
|
46
|
+
if (typeof s == `function`) throw TypeError(`callback not supported for sync tar functions`);
|
|
47
|
+
return e(c, o);
|
|
48
|
+
} else if (isAsyncFile(c)) {
|
|
49
|
+
let e = t(c, o), n = s || void 0;
|
|
50
|
+
return n ? e.then(() => n(), n) : e;
|
|
51
|
+
} else if (isSyncNoFile(c)) {
|
|
52
|
+
if (typeof s == `function`) throw TypeError(`callback not supported for sync tar functions`);
|
|
53
|
+
return n(c, o);
|
|
54
|
+
} else if (isAsyncNoFile(c)) {
|
|
55
|
+
if (typeof s == `function`) throw TypeError(`callback only supported with file option`);
|
|
56
|
+
return r(c, o);
|
|
57
|
+
} else throw Error(`impossible options??`);
|
|
58
|
+
}, {
|
|
59
|
+
syncFile: e,
|
|
60
|
+
asyncFile: t,
|
|
61
|
+
syncNoFile: n,
|
|
62
|
+
asyncNoFile: r,
|
|
63
|
+
validate: i
|
|
64
|
+
}), encode$1 = (e, t) => {
|
|
65
|
+
if (Number.isSafeInteger(e)) e < 0 ? encodeNegative(e, t) : encodePositive(e, t);
|
|
66
|
+
else throw Error(`cannot encode number outside of javascript safe integer range`);
|
|
67
|
+
return t;
|
|
68
|
+
}, encodePositive = (e, t) => {
|
|
69
|
+
t[0] = 128;
|
|
70
|
+
for (var n = t.length; n > 1; n--) t[n - 1] = e & 255, e = Math.floor(e / 256);
|
|
71
|
+
}, encodeNegative = (e, t) => {
|
|
72
|
+
t[0] = 255;
|
|
73
|
+
var n = !1;
|
|
74
|
+
e *= -1;
|
|
75
|
+
for (var r = t.length; r > 1; r--) {
|
|
76
|
+
var i = e & 255;
|
|
77
|
+
e = Math.floor(e / 256), n ? t[r - 1] = onesComp(i) : i === 0 ? t[r - 1] = 0 : (n = !0, t[r - 1] = twosComp(i));
|
|
78
|
+
}
|
|
79
|
+
}, parse$2 = (e) => {
|
|
80
|
+
let t = e[0], n = t === 128 ? pos(e.subarray(1, e.length)) : t === 255 ? twos(e) : null;
|
|
81
|
+
if (n === null) throw Error(`invalid base256 encoding`);
|
|
82
|
+
if (!Number.isSafeInteger(n)) throw Error(`parsed number outside of javascript safe integer range`);
|
|
83
|
+
return n;
|
|
84
|
+
}, twos = (e) => {
|
|
85
|
+
for (var t = e.length, n = 0, r = !1, i = t - 1; i > -1; i--) {
|
|
86
|
+
var a = Number(e[i]), o;
|
|
87
|
+
r ? o = onesComp(a) : a === 0 ? o = a : (r = !0, o = twosComp(a)), o !== 0 && (n -= o * 256 ** (t - i - 1));
|
|
88
|
+
}
|
|
89
|
+
return n;
|
|
90
|
+
}, pos = (e) => {
|
|
91
|
+
for (var t = e.length, n = 0, r = t - 1; r > -1; r--) {
|
|
92
|
+
var i = Number(e[r]);
|
|
93
|
+
i !== 0 && (n += i * 256 ** (t - r - 1));
|
|
94
|
+
}
|
|
95
|
+
return n;
|
|
96
|
+
}, onesComp = (e) => (255 ^ e) & 255, twosComp = (e) => (255 ^ e) + 1 & 255, isCode = (e) => name.has(e), name = new Map([
|
|
97
|
+
[`0`, `File`],
|
|
98
|
+
[``, `OldFile`],
|
|
99
|
+
[`1`, `Link`],
|
|
100
|
+
[`2`, `SymbolicLink`],
|
|
101
|
+
[`3`, `CharacterDevice`],
|
|
102
|
+
[`4`, `BlockDevice`],
|
|
103
|
+
[`5`, `Directory`],
|
|
104
|
+
[`6`, `FIFO`],
|
|
105
|
+
[`7`, `ContiguousFile`],
|
|
106
|
+
[`g`, `GlobalExtendedHeader`],
|
|
107
|
+
[`x`, `ExtendedHeader`],
|
|
108
|
+
[`A`, `SolarisACL`],
|
|
109
|
+
[`D`, `GNUDumpDir`],
|
|
110
|
+
[`I`, `Inode`],
|
|
111
|
+
[`K`, `NextFileHasLongLinkpath`],
|
|
112
|
+
[`L`, `NextFileHasLongPath`],
|
|
113
|
+
[`M`, `ContinuationFile`],
|
|
114
|
+
[`N`, `OldGnuLongPath`],
|
|
115
|
+
[`S`, `SparseFile`],
|
|
116
|
+
[`V`, `TapeVolumeHeader`],
|
|
117
|
+
[`X`, `OldExtendedHeader`]
|
|
118
|
+
]), code = new Map(Array.from(name).map((e) => [e[1], e[0]]));
|
|
119
|
+
var Header = class {
|
|
120
|
+
cksumValid = !1;
|
|
121
|
+
needPax = !1;
|
|
122
|
+
nullBlock = !1;
|
|
123
|
+
block;
|
|
124
|
+
path;
|
|
125
|
+
mode;
|
|
126
|
+
uid;
|
|
127
|
+
gid;
|
|
128
|
+
size;
|
|
129
|
+
cksum;
|
|
130
|
+
#type = `Unsupported`;
|
|
131
|
+
linkpath;
|
|
132
|
+
uname;
|
|
133
|
+
gname;
|
|
134
|
+
devmaj = 0;
|
|
135
|
+
devmin = 0;
|
|
136
|
+
atime;
|
|
137
|
+
ctime;
|
|
138
|
+
mtime;
|
|
139
|
+
charset;
|
|
140
|
+
comment;
|
|
141
|
+
constructor(e, t = 0, n, r) {
|
|
142
|
+
Buffer.isBuffer(e) ? this.decode(e, t || 0, n, r) : e && this.#slurp(e);
|
|
143
|
+
}
|
|
144
|
+
decode(e, t, n, r) {
|
|
145
|
+
if (t ||= 0, !e || !(e.length >= t + 512)) throw Error(`need 512 bytes for header`);
|
|
146
|
+
this.path = n?.path ?? decString(e, t, 100), this.mode = n?.mode ?? r?.mode ?? decNumber(e, t + 100, 8), this.uid = n?.uid ?? r?.uid ?? decNumber(e, t + 108, 8), this.gid = n?.gid ?? r?.gid ?? decNumber(e, t + 116, 8), this.size = n?.size ?? r?.size ?? decNumber(e, t + 124, 12), this.mtime = n?.mtime ?? r?.mtime ?? decDate(e, t + 136, 12), this.cksum = decNumber(e, t + 148, 12), r && this.#slurp(r, !0), n && this.#slurp(n);
|
|
147
|
+
let i = decString(e, t + 156, 1);
|
|
148
|
+
if (isCode(i) && (this.#type = i || `0`), this.#type === `0` && this.path.slice(-1) === `/` && (this.#type = `5`), this.#type === `5` && (this.size = 0), this.linkpath = decString(e, t + 157, 100), e.subarray(t + 257, t + 265).toString() === `ustar\x0000`) if (this.uname = n?.uname ?? r?.uname ?? decString(e, t + 265, 32), this.gname = n?.gname ?? r?.gname ?? decString(e, t + 297, 32), this.devmaj = n?.devmaj ?? r?.devmaj ?? decNumber(e, t + 329, 8) ?? 0, this.devmin = n?.devmin ?? r?.devmin ?? decNumber(e, t + 337, 8) ?? 0, e[t + 475] !== 0) this.path = decString(e, t + 345, 155) + `/` + this.path;
|
|
149
|
+
else {
|
|
150
|
+
let i = decString(e, t + 345, 130);
|
|
151
|
+
i && (this.path = i + `/` + this.path), this.atime = n?.atime ?? r?.atime ?? decDate(e, t + 476, 12), this.ctime = n?.ctime ?? r?.ctime ?? decDate(e, t + 488, 12);
|
|
152
|
+
}
|
|
153
|
+
let a = 256;
|
|
154
|
+
for (let n = t; n < t + 148; n++) a += e[n];
|
|
155
|
+
for (let n = t + 156; n < t + 512; n++) a += e[n];
|
|
156
|
+
this.cksumValid = a === this.cksum, this.cksum === void 0 && a === 256 && (this.nullBlock = !0);
|
|
157
|
+
}
|
|
158
|
+
#slurp(e, t = !1) {
|
|
159
|
+
Object.assign(this, Object.fromEntries(Object.entries(e).filter(([e, n]) => !(n == null || e === `path` && t || e === `linkpath` && t || e === `global`))));
|
|
160
|
+
}
|
|
161
|
+
encode(e, t = 0) {
|
|
162
|
+
if (e ||= this.block = Buffer.alloc(512), this.#type === `Unsupported` && (this.#type = `0`), !(e.length >= t + 512)) throw Error(`need 512 bytes for header`);
|
|
163
|
+
let n = this.ctime || this.atime ? 130 : 155, r = splitPrefix(this.path || ``, n), i = r[0], a = r[1];
|
|
164
|
+
this.needPax = !!r[2], this.needPax = encString(e, t, 100, i) || this.needPax, this.needPax = encNumber(e, t + 100, 8, this.mode) || this.needPax, this.needPax = encNumber(e, t + 108, 8, this.uid) || this.needPax, this.needPax = encNumber(e, t + 116, 8, this.gid) || this.needPax, this.needPax = encNumber(e, t + 124, 12, this.size) || this.needPax, this.needPax = encDate(e, t + 136, 12, this.mtime) || this.needPax, e[t + 156] = this.#type.charCodeAt(0), this.needPax = encString(e, t + 157, 100, this.linkpath) || this.needPax, e.write(`ustar\x0000`, t + 257, 8), this.needPax = encString(e, t + 265, 32, this.uname) || this.needPax, this.needPax = encString(e, t + 297, 32, this.gname) || this.needPax, this.needPax = encNumber(e, t + 329, 8, this.devmaj) || this.needPax, this.needPax = encNumber(e, t + 337, 8, this.devmin) || this.needPax, this.needPax = encString(e, t + 345, n, a) || this.needPax, e[t + 475] === 0 ? (this.needPax = encString(e, t + 345, 130, a) || this.needPax, this.needPax = encDate(e, t + 476, 12, this.atime) || this.needPax, this.needPax = encDate(e, t + 488, 12, this.ctime) || this.needPax) : this.needPax = encString(e, t + 345, 155, a) || this.needPax;
|
|
165
|
+
let o = 256;
|
|
166
|
+
for (let n = t; n < t + 148; n++) o += e[n];
|
|
167
|
+
for (let n = t + 156; n < t + 512; n++) o += e[n];
|
|
168
|
+
return this.cksum = o, encNumber(e, t + 148, 8, this.cksum), this.cksumValid = !0, this.needPax;
|
|
169
|
+
}
|
|
170
|
+
get type() {
|
|
171
|
+
return this.#type === `Unsupported` ? this.#type : name.get(this.#type);
|
|
172
|
+
}
|
|
173
|
+
get typeKey() {
|
|
174
|
+
return this.#type;
|
|
175
|
+
}
|
|
176
|
+
set type(e) {
|
|
177
|
+
let t = String(code.get(e));
|
|
178
|
+
if (isCode(t) || t === `Unsupported`) this.#type = t;
|
|
179
|
+
else if (isCode(e)) this.#type = e;
|
|
180
|
+
else throw TypeError(`invalid entry type: ` + e);
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
const splitPrefix = (e, t) => {
|
|
184
|
+
let n = e, r = ``, i, a = posix.parse(e).root || `.`;
|
|
185
|
+
if (Buffer.byteLength(n) < 100) i = [
|
|
186
|
+
n,
|
|
187
|
+
r,
|
|
188
|
+
!1
|
|
189
|
+
];
|
|
190
|
+
else {
|
|
191
|
+
r = posix.dirname(n), n = posix.basename(n);
|
|
192
|
+
do
|
|
193
|
+
Buffer.byteLength(n) <= 100 && Buffer.byteLength(r) <= t ? i = [
|
|
194
|
+
n,
|
|
195
|
+
r,
|
|
196
|
+
!1
|
|
197
|
+
] : Buffer.byteLength(n) > 100 && Buffer.byteLength(r) <= t ? i = [
|
|
198
|
+
n.slice(0, 99),
|
|
199
|
+
r,
|
|
200
|
+
!0
|
|
201
|
+
] : (n = posix.join(posix.basename(r), n), r = posix.dirname(r));
|
|
202
|
+
while (r !== a && i === void 0);
|
|
203
|
+
i ||= [
|
|
204
|
+
e.slice(0, 99),
|
|
205
|
+
``,
|
|
206
|
+
!0
|
|
207
|
+
];
|
|
208
|
+
}
|
|
209
|
+
return i;
|
|
210
|
+
}, decString = (e, t, n) => e.subarray(t, t + n).toString(`utf8`).replace(/\0.*/, ``), decDate = (e, t, n) => numToDate(decNumber(e, t, n)), numToDate = (e) => e === void 0 ? void 0 : /* @__PURE__ */ new Date(e * 1e3), decNumber = (e, t, n) => Number(e[t]) & 128 ? parse$2(e.subarray(t, t + n)) : decSmallNumber(e, t, n), nanUndef = (e) => isNaN(e) ? void 0 : e, decSmallNumber = (e, t, n) => nanUndef(parseInt(e.subarray(t, t + n).toString(`utf8`).replace(/\0.*$/, ``).trim(), 8)), MAXNUM = {
|
|
211
|
+
12: 8589934591,
|
|
212
|
+
8: 2097151
|
|
213
|
+
}, encNumber = (e, t, n, r) => r === void 0 ? !1 : r > MAXNUM[n] || r < 0 ? (encode$1(r, e.subarray(t, t + n)), !0) : (encSmallNumber(e, t, n, r), !1), encSmallNumber = (e, t, n, r) => e.write(octalString(r, n), t, n, `ascii`), octalString = (e, t) => padOctal(Math.floor(e).toString(8), t), padOctal = (e, t) => (e.length === t - 1 ? e : Array(t - e.length - 1).join(`0`) + e + ` `) + `\0`, encDate = (e, t, n, r) => r === void 0 ? !1 : encNumber(e, t, n, r.getTime() / 1e3), NULLS = Array(156).join(`\0`), encString = (e, t, n, r) => r === void 0 ? !1 : (e.write(r + NULLS, t, n, `utf8`), r.length !== Buffer.byteLength(r) || r.length > n);
|
|
214
|
+
var Pax = class e {
|
|
215
|
+
atime;
|
|
216
|
+
mtime;
|
|
217
|
+
ctime;
|
|
218
|
+
charset;
|
|
219
|
+
comment;
|
|
220
|
+
gid;
|
|
221
|
+
uid;
|
|
222
|
+
gname;
|
|
223
|
+
uname;
|
|
224
|
+
linkpath;
|
|
225
|
+
dev;
|
|
226
|
+
ino;
|
|
227
|
+
nlink;
|
|
228
|
+
path;
|
|
229
|
+
size;
|
|
230
|
+
mode;
|
|
231
|
+
global;
|
|
232
|
+
constructor(e, t = !1) {
|
|
233
|
+
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;
|
|
234
|
+
}
|
|
235
|
+
encode() {
|
|
236
|
+
let e = this.encodeBody();
|
|
237
|
+
if (e === ``) return Buffer.allocUnsafe(0);
|
|
238
|
+
let t = Buffer.byteLength(e), n = 512 * Math.ceil(1 + t / 512), r = Buffer.allocUnsafe(n);
|
|
239
|
+
for (let e = 0; e < 512; e++) r[e] = 0;
|
|
240
|
+
new Header({
|
|
241
|
+
path: (`PaxHeader/` + basename(this.path ?? ``)).slice(0, 99),
|
|
242
|
+
mode: this.mode || 420,
|
|
243
|
+
uid: this.uid,
|
|
244
|
+
gid: this.gid,
|
|
245
|
+
size: t,
|
|
246
|
+
mtime: this.mtime,
|
|
247
|
+
type: this.global ? `GlobalExtendedHeader` : `ExtendedHeader`,
|
|
248
|
+
linkpath: ``,
|
|
249
|
+
uname: this.uname || ``,
|
|
250
|
+
gname: this.gname || ``,
|
|
251
|
+
devmaj: 0,
|
|
252
|
+
devmin: 0,
|
|
253
|
+
atime: this.atime,
|
|
254
|
+
ctime: this.ctime
|
|
255
|
+
}).encode(r), r.write(e, 512, t, `utf8`);
|
|
256
|
+
for (let e = t + 512; e < r.length; e++) r[e] = 0;
|
|
257
|
+
return r;
|
|
258
|
+
}
|
|
259
|
+
encodeBody() {
|
|
260
|
+
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`);
|
|
261
|
+
}
|
|
262
|
+
encodeField(e) {
|
|
263
|
+
if (this[e] === void 0) return ``;
|
|
264
|
+
let t = this[e], n = t instanceof Date ? t.getTime() / 1e3 : t, r = ` ` + (e === `dev` || e === `ino` || e === `nlink` ? `SCHILY.` : ``) + e + `=` + n + `
|
|
265
|
+
`, i = Buffer.byteLength(r), a = Math.floor(Math.log(i) / Math.log(10)) + 1;
|
|
266
|
+
return i + a >= 10 ** a && (a += 1), a + i + r;
|
|
267
|
+
}
|
|
268
|
+
static parse(t, n, r = !1) {
|
|
269
|
+
return new e(merge(parseKV(t), n), r);
|
|
270
|
+
}
|
|
271
|
+
};
|
|
272
|
+
const merge = (e, t) => t ? Object.assign({}, t, e) : e, parseKV = (e) => e.replace(/\n$/, ``).split(`
|
|
273
|
+
`).reduce(parseKVLine, Object.create(null)), parseKVLine = (e, t) => {
|
|
274
|
+
let n = parseInt(t, 10);
|
|
275
|
+
if (n !== Buffer.byteLength(t) + 1) return e;
|
|
276
|
+
t = t.slice((n + ` `).length);
|
|
277
|
+
let r = t.split(`=`), i = r.shift();
|
|
278
|
+
if (!i) return e;
|
|
279
|
+
let a = i.replace(/^SCHILY\.(dev|ino|nlink)/, `$1`), o = r.join(`=`);
|
|
280
|
+
return e[a] = /^([A-Z]+\.)?([mac]|birth|creation)time$/.test(a) ? /* @__PURE__ */ new Date(Number(o) * 1e3) : /^[0-9]+$/.test(o) ? +o : o, e;
|
|
281
|
+
}, normalizeWindowsPath = (process.env.TESTING_TAR_FAKE_PLATFORM || process.platform) === `win32` ? (e) => e && e.replace(/\\/g, `/`) : (e) => e;
|
|
282
|
+
var ReadEntry = class extends Minipass {
|
|
283
|
+
extended;
|
|
284
|
+
globalExtended;
|
|
285
|
+
header;
|
|
286
|
+
startBlockSize;
|
|
287
|
+
blockRemain;
|
|
288
|
+
remain;
|
|
289
|
+
type;
|
|
290
|
+
meta = !1;
|
|
291
|
+
ignore = !1;
|
|
292
|
+
path;
|
|
293
|
+
mode;
|
|
294
|
+
uid;
|
|
295
|
+
gid;
|
|
296
|
+
uname;
|
|
297
|
+
gname;
|
|
298
|
+
size = 0;
|
|
299
|
+
mtime;
|
|
300
|
+
atime;
|
|
301
|
+
ctime;
|
|
302
|
+
linkpath;
|
|
303
|
+
dev;
|
|
304
|
+
ino;
|
|
305
|
+
nlink;
|
|
306
|
+
invalid = !1;
|
|
307
|
+
absolute;
|
|
308
|
+
unsupported = !1;
|
|
309
|
+
constructor(e, t, n) {
|
|
310
|
+
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) {
|
|
311
|
+
case `File`:
|
|
312
|
+
case `OldFile`:
|
|
313
|
+
case `Link`:
|
|
314
|
+
case `SymbolicLink`:
|
|
315
|
+
case `CharacterDevice`:
|
|
316
|
+
case `BlockDevice`:
|
|
317
|
+
case `Directory`:
|
|
318
|
+
case `FIFO`:
|
|
319
|
+
case `ContiguousFile`:
|
|
320
|
+
case `GNUDumpDir`: break;
|
|
321
|
+
case `NextFileHasLongLinkpath`:
|
|
322
|
+
case `NextFileHasLongPath`:
|
|
323
|
+
case `OldGnuLongPath`:
|
|
324
|
+
case `GlobalExtendedHeader`:
|
|
325
|
+
case `ExtendedHeader`:
|
|
326
|
+
case `OldExtendedHeader`:
|
|
327
|
+
this.meta = !0;
|
|
328
|
+
break;
|
|
329
|
+
default: this.ignore = !0;
|
|
330
|
+
}
|
|
331
|
+
if (!e.path) throw Error(`no path provided for tar.ReadEntry`);
|
|
332
|
+
this.path = normalizeWindowsPath(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 ? normalizeWindowsPath(e.linkpath) : void 0, this.uname = e.uname, this.gname = e.gname, t && this.#slurp(t), n && this.#slurp(n, !0);
|
|
333
|
+
}
|
|
334
|
+
write(e) {
|
|
335
|
+
let t = e.length;
|
|
336
|
+
if (t > this.blockRemain) throw Error(`writing more to entry than is appropriate`);
|
|
337
|
+
let n = this.remain, r = this.blockRemain;
|
|
338
|
+
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));
|
|
339
|
+
}
|
|
340
|
+
#slurp(e, t = !1) {
|
|
341
|
+
e.path &&= normalizeWindowsPath(e.path), e.linkpath &&= normalizeWindowsPath(e.linkpath), Object.assign(this, Object.fromEntries(Object.entries(e).filter(([e, n]) => !(n == null || e === `path` && t))));
|
|
342
|
+
}
|
|
343
|
+
};
|
|
344
|
+
const warnMethod = (e, t, n, r = {}) => {
|
|
345
|
+
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));
|
|
346
|
+
}, gzipHeader = Buffer.from([31, 139]), zstdHeader = Buffer.from([
|
|
347
|
+
40,
|
|
348
|
+
181,
|
|
349
|
+
47,
|
|
350
|
+
253
|
|
351
|
+
]), 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;
|
|
352
|
+
var Parser = class extends EventEmitter {
|
|
353
|
+
file;
|
|
354
|
+
strict;
|
|
355
|
+
maxMetaEntrySize;
|
|
356
|
+
filter;
|
|
357
|
+
brotli;
|
|
358
|
+
zstd;
|
|
359
|
+
writable = !0;
|
|
360
|
+
readable = !1;
|
|
361
|
+
[QUEUE$1] = [];
|
|
362
|
+
[BUFFER];
|
|
363
|
+
[READENTRY];
|
|
364
|
+
[WRITEENTRY];
|
|
365
|
+
[STATE] = `begin`;
|
|
366
|
+
[META] = ``;
|
|
367
|
+
[EX];
|
|
368
|
+
[GEX];
|
|
369
|
+
[ENDED$2] = !1;
|
|
370
|
+
[UNZIP];
|
|
371
|
+
[ABORTED] = !1;
|
|
372
|
+
[SAW_VALID_ENTRY];
|
|
373
|
+
[SAW_NULL_BLOCK] = !1;
|
|
374
|
+
[SAW_EOF] = !1;
|
|
375
|
+
[WRITING] = !1;
|
|
376
|
+
[CONSUMING] = !1;
|
|
377
|
+
[EMITTEDEND] = !1;
|
|
378
|
+
constructor(e = {}) {
|
|
379
|
+
super(), this.file = e.file || ``, this.on(DONE, () => {
|
|
380
|
+
(this[STATE] === `begin` || this[SAW_VALID_ENTRY] === !1) && this.warn(`TAR_BAD_ARCHIVE`, `Unrecognized archive format`);
|
|
381
|
+
}), e.ondone ? this.on(DONE, e.ondone) : this.on(DONE, () => {
|
|
382
|
+
this.emit(`prefinish`), this.emit(`finish`), this.emit(`end`);
|
|
383
|
+
}), this.strict = !!e.strict, this.maxMetaEntrySize = e.maxMetaEntrySize || 1048576, this.filter = typeof e.filter == `function` ? e.filter : noop;
|
|
384
|
+
let t = e.file && (e.file.endsWith(`.tar.br`) || e.file.endsWith(`.tbr`));
|
|
385
|
+
this.brotli = !(e.gzip || e.zstd) && e.brotli !== void 0 ? e.brotli : t ? void 0 : !1;
|
|
386
|
+
let n = e.file && (e.file.endsWith(`.tar.zst`) || e.file.endsWith(`.tzst`));
|
|
387
|
+
this.zstd = !(e.gzip || e.brotli) && e.zstd !== void 0 ? e.zstd : n ? !0 : void 0, this.on(`end`, () => this[CLOSESTREAM]()), typeof e.onwarn == `function` && this.on(`warn`, e.onwarn), typeof e.onReadEntry == `function` && this.on(`entry`, e.onReadEntry);
|
|
388
|
+
}
|
|
389
|
+
warn(e, t, n = {}) {
|
|
390
|
+
warnMethod(this, e, t, n);
|
|
391
|
+
}
|
|
392
|
+
[CONSUMEHEADER](e, t) {
|
|
393
|
+
this[SAW_VALID_ENTRY] === void 0 && (this[SAW_VALID_ENTRY] = !1);
|
|
394
|
+
let n;
|
|
395
|
+
try {
|
|
396
|
+
n = new Header(e, t, this[EX], this[GEX]);
|
|
397
|
+
} catch (e) {
|
|
398
|
+
return this.warn(`TAR_ENTRY_INVALID`, e);
|
|
399
|
+
}
|
|
400
|
+
if (n.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`));
|
|
401
|
+
else if (this[SAW_NULL_BLOCK] = !1, !n.cksumValid) this.warn(`TAR_ENTRY_INVALID`, `checksum failure`, { header: n });
|
|
402
|
+
else if (!n.path) this.warn(`TAR_ENTRY_INVALID`, `path is required`, { header: n });
|
|
403
|
+
else {
|
|
404
|
+
let e = n.type;
|
|
405
|
+
if (/^(Symbolic)?Link$/.test(e) && !n.linkpath) this.warn(`TAR_ENTRY_INVALID`, `linkpath required`, { header: n });
|
|
406
|
+
else if (!/^(Symbolic)?Link$/.test(e) && !/^(Global)?ExtendedHeader$/.test(e) && n.linkpath) this.warn(`TAR_ENTRY_INVALID`, `linkpath forbidden`, { header: n });
|
|
407
|
+
else {
|
|
408
|
+
let e = this[WRITEENTRY] = new ReadEntry(n, this[EX], this[GEX]);
|
|
409
|
+
this[SAW_VALID_ENTRY] || (e.remain ? e.on(`end`, () => {
|
|
410
|
+
e.invalid || (this[SAW_VALID_ENTRY] = !0);
|
|
411
|
+
}) : this[SAW_VALID_ENTRY] = !0), e.meta ? e.size > this.maxMetaEntrySize ? (e.ignore = !0, this[EMIT](`ignoredEntry`, e), this[STATE] = `ignore`, e.resume()) : e.size > 0 && (this[META] = ``, e.on(`data`, (e) => this[META] += e), this[STATE] = `meta`) : (this[EX] = void 0, e.ignore = e.ignore || !this.filter(e.path, e), e.ignore ? (this[EMIT](`ignoredEntry`, e), this[STATE] = e.remain ? `ignore` : `header`, e.resume()) : (e.remain ? this[STATE] = `body` : (this[STATE] = `header`, e.end()), this[READENTRY] ? this[QUEUE$1].push(e) : (this[QUEUE$1].push(e), this[NEXTENTRY]())));
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
[CLOSESTREAM]() {
|
|
416
|
+
queueMicrotask(() => this.emit(`close`));
|
|
417
|
+
}
|
|
418
|
+
[PROCESSENTRY](e) {
|
|
419
|
+
let t = !0;
|
|
420
|
+
if (!e) this[READENTRY] = void 0, t = !1;
|
|
421
|
+
else if (Array.isArray(e)) {
|
|
422
|
+
let [t, ...n] = e;
|
|
423
|
+
this.emit(t, ...n);
|
|
424
|
+
} else this[READENTRY] = e, this.emit(`entry`, e), e.emittedEnd || (e.on(`end`, () => this[NEXTENTRY]()), t = !1);
|
|
425
|
+
return t;
|
|
426
|
+
}
|
|
427
|
+
[NEXTENTRY]() {
|
|
428
|
+
do ;
|
|
429
|
+
while (this[PROCESSENTRY](this[QUEUE$1].shift()));
|
|
430
|
+
if (!this[QUEUE$1].length) {
|
|
431
|
+
let e = this[READENTRY];
|
|
432
|
+
!e || e.flowing || e.size === e.remain ? this[WRITING] || this.emit(`drain`) : e.once(`drain`, () => this.emit(`drain`));
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
[CONSUMEBODY](e, t) {
|
|
436
|
+
let n = this[WRITEENTRY];
|
|
437
|
+
if (!n) throw Error(`attempt to consume body without entry??`);
|
|
438
|
+
let r = n.blockRemain ?? 0, i = r >= e.length && t === 0 ? e : e.subarray(t, t + r);
|
|
439
|
+
return n.write(i), n.blockRemain || (this[STATE] = `header`, this[WRITEENTRY] = void 0, n.end()), i.length;
|
|
440
|
+
}
|
|
441
|
+
[CONSUMEMETA](e, t) {
|
|
442
|
+
let n = this[WRITEENTRY], r = this[CONSUMEBODY](e, t);
|
|
443
|
+
return !this[WRITEENTRY] && n && this[EMITMETA](n), r;
|
|
444
|
+
}
|
|
445
|
+
[EMIT](e, t, n) {
|
|
446
|
+
!this[QUEUE$1].length && !this[READENTRY] ? this.emit(e, t, n) : this[QUEUE$1].push([
|
|
447
|
+
e,
|
|
448
|
+
t,
|
|
449
|
+
n
|
|
450
|
+
]);
|
|
451
|
+
}
|
|
452
|
+
[EMITMETA](e) {
|
|
453
|
+
switch (this[EMIT](`meta`, this[META]), e.type) {
|
|
454
|
+
case `ExtendedHeader`:
|
|
455
|
+
case `OldExtendedHeader`:
|
|
456
|
+
this[EX] = Pax.parse(this[META], this[EX], !1);
|
|
457
|
+
break;
|
|
458
|
+
case `GlobalExtendedHeader`:
|
|
459
|
+
this[GEX] = Pax.parse(this[META], this[GEX], !0);
|
|
460
|
+
break;
|
|
461
|
+
case `NextFileHasLongPath`:
|
|
462
|
+
case `OldGnuLongPath`: {
|
|
463
|
+
let e = this[EX] ?? Object.create(null);
|
|
464
|
+
this[EX] = e, e.path = this[META].replace(/\0.*/, ``);
|
|
465
|
+
break;
|
|
466
|
+
}
|
|
467
|
+
case `NextFileHasLongLinkpath`: {
|
|
468
|
+
let e = this[EX] || Object.create(null);
|
|
469
|
+
this[EX] = e, e.linkpath = this[META].replace(/\0.*/, ``);
|
|
470
|
+
break;
|
|
471
|
+
}
|
|
472
|
+
default: throw Error(`unknown meta: ` + e.type);
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
abort(e) {
|
|
476
|
+
this[ABORTED] = !0, this.emit(`abort`, e), this.warn(`TAR_ABORT`, e, { recoverable: !1 });
|
|
477
|
+
}
|
|
478
|
+
write(e, t, n) {
|
|
479
|
+
if (typeof t == `function` && (n = t, t = void 0), typeof e == `string` && (e = Buffer.from(e, typeof t == `string` ? t : `utf8`)), this[ABORTED]) return n?.(), !1;
|
|
480
|
+
if ((this[UNZIP] === void 0 || this.brotli === void 0 && this[UNZIP] === !1) && e) {
|
|
481
|
+
if (this[BUFFER] && (e = Buffer.concat([this[BUFFER], e]), this[BUFFER] = void 0), e.length < ZIP_HEADER_LEN) return this[BUFFER] = e, n?.(), !0;
|
|
482
|
+
for (let t = 0; this[UNZIP] === void 0 && t < gzipHeader.length; t++) e[t] !== gzipHeader[t] && (this[UNZIP] = !1);
|
|
483
|
+
let t = !1;
|
|
484
|
+
if (this[UNZIP] === !1 && this.zstd !== !1) {
|
|
485
|
+
t = !0;
|
|
486
|
+
for (let n = 0; n < zstdHeader.length; n++) if (e[n] !== zstdHeader[n]) {
|
|
487
|
+
t = !1;
|
|
488
|
+
break;
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
let r = this.brotli === void 0 && !t;
|
|
492
|
+
if (this[UNZIP] === !1 && r) if (e.length < 512) if (this[ENDED$2]) this.brotli = !0;
|
|
493
|
+
else return this[BUFFER] = e, n?.(), !0;
|
|
494
|
+
else try {
|
|
495
|
+
new Header(e.subarray(0, 512)), this.brotli = !1;
|
|
496
|
+
} catch {
|
|
497
|
+
this.brotli = !0;
|
|
498
|
+
}
|
|
499
|
+
if (this[UNZIP] === void 0 || this[UNZIP] === !1 && (this.brotli || t)) {
|
|
500
|
+
let r = this[ENDED$2];
|
|
501
|
+
this[ENDED$2] = !1, this[UNZIP] = this[UNZIP] === void 0 ? new Unzip({}) : t ? new ZstdDecompress({}) : new BrotliDecompress({}), this[UNZIP].on(`data`, (e) => this[CONSUMECHUNK](e)), this[UNZIP].on(`error`, (e) => this.abort(e)), this[UNZIP].on(`end`, () => {
|
|
502
|
+
this[ENDED$2] = !0, this[CONSUMECHUNK]();
|
|
503
|
+
}), this[WRITING] = !0;
|
|
504
|
+
let i = !!this[UNZIP][r ? `end` : `write`](e);
|
|
505
|
+
return this[WRITING] = !1, n?.(), i;
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
this[WRITING] = !0, this[UNZIP] ? this[UNZIP].write(e) : this[CONSUMECHUNK](e), this[WRITING] = !1;
|
|
509
|
+
let r = this[QUEUE$1].length ? !1 : this[READENTRY] ? this[READENTRY].flowing : !0;
|
|
510
|
+
return !r && !this[QUEUE$1].length && this[READENTRY]?.once(`drain`, () => this.emit(`drain`)), n?.(), r;
|
|
511
|
+
}
|
|
512
|
+
[BUFFERCONCAT](e) {
|
|
513
|
+
e && !this[ABORTED] && (this[BUFFER] = this[BUFFER] ? Buffer.concat([this[BUFFER], e]) : e);
|
|
514
|
+
}
|
|
515
|
+
[MAYBEEND]() {
|
|
516
|
+
if (this[ENDED$2] && !this[EMITTEDEND] && !this[ABORTED] && !this[CONSUMING]) {
|
|
517
|
+
this[EMITTEDEND] = !0;
|
|
518
|
+
let e = this[WRITEENTRY];
|
|
519
|
+
if (e && e.blockRemain) {
|
|
520
|
+
let t = this[BUFFER] ? this[BUFFER].length : 0;
|
|
521
|
+
this.warn(`TAR_BAD_ARCHIVE`, `Truncated input (needed ${e.blockRemain} more bytes, only ${t} available)`, { entry: e }), this[BUFFER] && e.write(this[BUFFER]), e.end();
|
|
522
|
+
}
|
|
523
|
+
this[EMIT](DONE);
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
[CONSUMECHUNK](e) {
|
|
527
|
+
if (this[CONSUMING] && e) this[BUFFERCONCAT](e);
|
|
528
|
+
else if (!e && !this[BUFFER]) this[MAYBEEND]();
|
|
529
|
+
else if (e) {
|
|
530
|
+
if (this[CONSUMING] = !0, this[BUFFER]) {
|
|
531
|
+
this[BUFFERCONCAT](e);
|
|
532
|
+
let t = this[BUFFER];
|
|
533
|
+
this[BUFFER] = void 0, this[CONSUMECHUNKSUB](t);
|
|
534
|
+
} else this[CONSUMECHUNKSUB](e);
|
|
535
|
+
for (; this[BUFFER] && this[BUFFER]?.length >= 512 && !this[ABORTED] && !this[SAW_EOF];) {
|
|
536
|
+
let e = this[BUFFER];
|
|
537
|
+
this[BUFFER] = void 0, this[CONSUMECHUNKSUB](e);
|
|
538
|
+
}
|
|
539
|
+
this[CONSUMING] = !1;
|
|
540
|
+
}
|
|
541
|
+
(!this[BUFFER] || this[ENDED$2]) && this[MAYBEEND]();
|
|
542
|
+
}
|
|
543
|
+
[CONSUMECHUNKSUB](e) {
|
|
544
|
+
let t = 0, n = e.length;
|
|
545
|
+
for (; t + 512 <= n && !this[ABORTED] && !this[SAW_EOF];) switch (this[STATE]) {
|
|
546
|
+
case `begin`:
|
|
547
|
+
case `header`:
|
|
548
|
+
this[CONSUMEHEADER](e, t), t += 512;
|
|
549
|
+
break;
|
|
550
|
+
case `ignore`:
|
|
551
|
+
case `body`:
|
|
552
|
+
t += this[CONSUMEBODY](e, t);
|
|
553
|
+
break;
|
|
554
|
+
case `meta`:
|
|
555
|
+
t += this[CONSUMEMETA](e, t);
|
|
556
|
+
break;
|
|
557
|
+
default: throw Error(`invalid state: ` + this[STATE]);
|
|
558
|
+
}
|
|
559
|
+
t < n && (this[BUFFER] ? this[BUFFER] = Buffer.concat([e.subarray(t), this[BUFFER]]) : this[BUFFER] = e.subarray(t));
|
|
560
|
+
}
|
|
561
|
+
end(e, t, n) {
|
|
562
|
+
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[ABORTED] || (this[UNZIP] ? (e && this[UNZIP].write(e), this[UNZIP].end()) : (this[ENDED$2] = !0, (this.brotli === void 0 || this.zstd === void 0) && (e ||= Buffer.alloc(0)), e && this.write(e), this[MAYBEEND]())), this;
|
|
563
|
+
}
|
|
564
|
+
};
|
|
565
|
+
const stripTrailingSlashes = (e) => {
|
|
566
|
+
let t = e.length - 1, n = -1;
|
|
567
|
+
for (; t > -1 && e.charAt(t) === `/`;) n = t, t--;
|
|
568
|
+
return n === -1 ? e : e.slice(0, n);
|
|
569
|
+
}, onReadEntryFunction = (e) => {
|
|
570
|
+
let t = e.onReadEntry;
|
|
571
|
+
e.onReadEntry = t ? (e) => {
|
|
572
|
+
t(e), e.resume();
|
|
573
|
+
} : (e) => e.resume();
|
|
574
|
+
}, filesFilter = (e, t) => {
|
|
575
|
+
let n = new Map(t.map((e) => [stripTrailingSlashes(e), !0])), r = e.filter, i = (e, t = ``) => {
|
|
576
|
+
let r = t || parse(e).root || `.`, a;
|
|
577
|
+
if (e === r) a = !1;
|
|
578
|
+
else {
|
|
579
|
+
let t = n.get(e);
|
|
580
|
+
a = t === void 0 ? i(dirname$1(e), r) : t;
|
|
581
|
+
}
|
|
582
|
+
return n.set(e, a), a;
|
|
583
|
+
};
|
|
584
|
+
e.filter = r ? (e, t) => r(e, t) && i(stripTrailingSlashes(e)) : (e) => i(stripTrailingSlashes(e));
|
|
585
|
+
}, list = makeCommand((e) => {
|
|
586
|
+
let t = new Parser(e), n = e.file, r;
|
|
587
|
+
try {
|
|
588
|
+
r = fs.openSync(n, `r`);
|
|
589
|
+
let i = fs.fstatSync(r), a = e.maxReadSize || 16 * 1024 * 1024;
|
|
590
|
+
if (i.size < a) {
|
|
591
|
+
let e = Buffer.allocUnsafe(i.size), n = fs.readSync(r, e, 0, i.size, 0);
|
|
592
|
+
t.end(n === e.byteLength ? e : e.subarray(0, n));
|
|
593
|
+
} else {
|
|
594
|
+
let e = 0, n = Buffer.allocUnsafe(a);
|
|
595
|
+
for (; e < i.size;) {
|
|
596
|
+
let i = fs.readSync(r, n, 0, a, e);
|
|
597
|
+
if (i === 0) break;
|
|
598
|
+
e += i, t.write(n.subarray(0, i));
|
|
599
|
+
}
|
|
600
|
+
t.end();
|
|
601
|
+
}
|
|
602
|
+
} finally {
|
|
603
|
+
if (typeof r == `number`) try {
|
|
604
|
+
fs.closeSync(r);
|
|
605
|
+
} catch {}
|
|
606
|
+
}
|
|
607
|
+
}, (e, t) => {
|
|
608
|
+
let n = new Parser(e), r = e.maxReadSize || 16 * 1024 * 1024, i = e.file;
|
|
609
|
+
return new Promise((e, t) => {
|
|
610
|
+
n.on(`error`, t), n.on(`end`, e), fs.stat(i, (e, o) => {
|
|
611
|
+
if (e) t(e);
|
|
612
|
+
else {
|
|
613
|
+
let e = new ReadStream(i, {
|
|
614
|
+
readSize: r,
|
|
615
|
+
size: o.size
|
|
616
|
+
});
|
|
617
|
+
e.on(`error`, t), e.pipe(n);
|
|
618
|
+
}
|
|
619
|
+
});
|
|
620
|
+
});
|
|
621
|
+
}, (e) => new Parser(e), (e) => new Parser(e), (e, t) => {
|
|
622
|
+
t?.length && filesFilter(e, t), e.noResume || onReadEntryFunction(e);
|
|
623
|
+
}), modeFix = (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, parse: parse$1 } = win32, stripAbsolutePath = (e) => {
|
|
624
|
+
let t = ``, n = parse$1(e);
|
|
625
|
+
for (; isAbsolute(e) || n.root;) {
|
|
626
|
+
let r = e.charAt(0) === `/` && e.slice(0, 4) !== `//?/` ? `/` : n.root;
|
|
627
|
+
e = e.slice(r.length), t += r, n = parse$1(e);
|
|
628
|
+
}
|
|
629
|
+
return [t, e];
|
|
630
|
+
}, raw = [
|
|
631
|
+
`|`,
|
|
632
|
+
`<`,
|
|
633
|
+
`>`,
|
|
634
|
+
`?`,
|
|
635
|
+
`:`
|
|
636
|
+
], win = raw.map((e) => String.fromCharCode(61440 + e.charCodeAt(0))), toWin = new Map(raw.map((e, t) => [e, win[t]])), toRaw = new Map(win.map((e, t) => [e, raw[t]])), encode = (e) => raw.reduce((e, t) => e.split(t).join(toWin.get(t)), e), decode = (e) => win.reduce((e, t) => e.split(t).join(toRaw.get(t)), e), prefixPath = (e, t) => t ? (e = normalizeWindowsPath(e).replace(/^\.(\/|$)/, ``), stripTrailingSlashes(t) + `/` + e) : normalizeWindowsPath(e), 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`);
|
|
637
|
+
var WriteEntry = class extends Minipass {
|
|
638
|
+
path;
|
|
639
|
+
portable;
|
|
640
|
+
myuid = process.getuid && process.getuid() || 0;
|
|
641
|
+
myuser = process.env.USER || ``;
|
|
642
|
+
maxReadSize;
|
|
643
|
+
linkCache;
|
|
644
|
+
statCache;
|
|
645
|
+
preservePaths;
|
|
646
|
+
cwd;
|
|
647
|
+
strict;
|
|
648
|
+
mtime;
|
|
649
|
+
noPax;
|
|
650
|
+
noMtime;
|
|
651
|
+
prefix;
|
|
652
|
+
fd;
|
|
653
|
+
blockLen = 0;
|
|
654
|
+
blockRemain = 0;
|
|
655
|
+
buf;
|
|
656
|
+
pos = 0;
|
|
657
|
+
remain = 0;
|
|
658
|
+
length = 0;
|
|
659
|
+
offset = 0;
|
|
660
|
+
win32;
|
|
661
|
+
absolute;
|
|
662
|
+
header;
|
|
663
|
+
type;
|
|
664
|
+
linkpath;
|
|
665
|
+
stat;
|
|
666
|
+
onWriteEntry;
|
|
667
|
+
#hadError = !1;
|
|
668
|
+
constructor(e, t = {}) {
|
|
669
|
+
let n = dealias(t);
|
|
670
|
+
super(), this.path = normalizeWindowsPath(e), this.portable = !!n.portable, this.maxReadSize = n.maxReadSize || 16777216, this.linkCache = n.linkCache || /* @__PURE__ */ new Map(), this.statCache = n.statCache || /* @__PURE__ */ new Map(), this.preservePaths = !!n.preservePaths, this.cwd = normalizeWindowsPath(n.cwd || process.cwd()), this.strict = !!n.strict, this.noPax = !!n.noPax, this.noMtime = !!n.noMtime, this.mtime = n.mtime, this.prefix = n.prefix ? normalizeWindowsPath(n.prefix) : void 0, this.onWriteEntry = n.onWriteEntry, typeof n.onwarn == `function` && this.on(`warn`, n.onwarn);
|
|
671
|
+
let r = !1;
|
|
672
|
+
if (!this.preservePaths) {
|
|
673
|
+
let [e, t] = stripAbsolutePath(this.path);
|
|
674
|
+
e && typeof t == `string` && (this.path = t, r = e);
|
|
675
|
+
}
|
|
676
|
+
this.win32 = !!n.win32 || process.platform === `win32`, this.win32 && (this.path = decode(this.path.replace(/\\/g, `/`)), e = e.replace(/\\/g, `/`)), this.absolute = normalizeWindowsPath(n.absolute || path$1.resolve(this.cwd, e)), this.path === `` && (this.path = `./`), r && this.warn(`TAR_ENTRY_INFO`, `stripping ${r} from absolute path`, {
|
|
677
|
+
entry: this,
|
|
678
|
+
path: r + this.path
|
|
679
|
+
});
|
|
680
|
+
let i = this.statCache.get(this.absolute);
|
|
681
|
+
i ? this[ONLSTAT](i) : this[LSTAT]();
|
|
682
|
+
}
|
|
683
|
+
warn(e, t, n = {}) {
|
|
684
|
+
return warnMethod(this, e, t, n);
|
|
685
|
+
}
|
|
686
|
+
emit(e, ...t) {
|
|
687
|
+
return e === `error` && (this.#hadError = !0), super.emit(e, ...t);
|
|
688
|
+
}
|
|
689
|
+
[LSTAT]() {
|
|
690
|
+
fs$1.lstat(this.absolute, (e, t) => {
|
|
691
|
+
if (e) return this.emit(`error`, e);
|
|
692
|
+
this[ONLSTAT](t);
|
|
693
|
+
});
|
|
694
|
+
}
|
|
695
|
+
[ONLSTAT](e) {
|
|
696
|
+
this.statCache.set(this.absolute, e), this.stat = e, e.isFile() || (e.size = 0), this.type = getType(e), this.emit(`stat`, e), this[PROCESS$1]();
|
|
697
|
+
}
|
|
698
|
+
[PROCESS$1]() {
|
|
699
|
+
switch (this.type) {
|
|
700
|
+
case `File`: return this[FILE$1]();
|
|
701
|
+
case `Directory`: return this[DIRECTORY$1]();
|
|
702
|
+
case `SymbolicLink`: return this[SYMLINK$1]();
|
|
703
|
+
default: return this.end();
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
[MODE](e) {
|
|
707
|
+
return modeFix(e, this.type === `Directory`, this.portable);
|
|
708
|
+
}
|
|
709
|
+
[PREFIX](e) {
|
|
710
|
+
return prefixPath(e, this.prefix);
|
|
711
|
+
}
|
|
712
|
+
[HEADER]() {
|
|
713
|
+
if (!this.stat) throw Error(`cannot write header before stat`);
|
|
714
|
+
this.type === `Directory` && this.portable && (this.noMtime = !0), this.onWriteEntry?.(this), this.header = new Header({
|
|
715
|
+
path: this[PREFIX](this.path),
|
|
716
|
+
linkpath: this.type === `Link` && this.linkpath !== void 0 ? this[PREFIX](this.linkpath) : this.linkpath,
|
|
717
|
+
mode: this[MODE](this.stat.mode),
|
|
718
|
+
uid: this.portable ? void 0 : this.stat.uid,
|
|
719
|
+
gid: this.portable ? void 0 : this.stat.gid,
|
|
720
|
+
size: this.stat.size,
|
|
721
|
+
mtime: this.noMtime ? void 0 : this.mtime || this.stat.mtime,
|
|
722
|
+
type: this.type === `Unsupported` ? void 0 : this.type,
|
|
723
|
+
uname: this.portable ? void 0 : this.stat.uid === this.myuid ? this.myuser : ``,
|
|
724
|
+
atime: this.portable ? void 0 : this.stat.atime,
|
|
725
|
+
ctime: this.portable ? void 0 : this.stat.ctime
|
|
726
|
+
}), this.header.encode() && !this.noPax && super.write(new Pax({
|
|
727
|
+
atime: this.portable ? void 0 : this.header.atime,
|
|
728
|
+
ctime: this.portable ? void 0 : this.header.ctime,
|
|
729
|
+
gid: this.portable ? void 0 : this.header.gid,
|
|
730
|
+
mtime: this.noMtime ? void 0 : this.mtime || this.header.mtime,
|
|
731
|
+
path: this[PREFIX](this.path),
|
|
732
|
+
linkpath: this.type === `Link` && this.linkpath !== void 0 ? this[PREFIX](this.linkpath) : this.linkpath,
|
|
733
|
+
size: this.header.size,
|
|
734
|
+
uid: this.portable ? void 0 : this.header.uid,
|
|
735
|
+
uname: this.portable ? void 0 : this.header.uname,
|
|
736
|
+
dev: this.portable ? void 0 : this.stat.dev,
|
|
737
|
+
ino: this.portable ? void 0 : this.stat.ino,
|
|
738
|
+
nlink: this.portable ? void 0 : this.stat.nlink
|
|
739
|
+
}).encode());
|
|
740
|
+
let e = this.header?.block;
|
|
741
|
+
if (!e) throw Error(`failed to encode header`);
|
|
742
|
+
super.write(e);
|
|
743
|
+
}
|
|
744
|
+
[DIRECTORY$1]() {
|
|
745
|
+
if (!this.stat) throw Error(`cannot create directory entry without stat`);
|
|
746
|
+
this.path.slice(-1) !== `/` && (this.path += `/`), this.stat.size = 0, this[HEADER](), this.end();
|
|
747
|
+
}
|
|
748
|
+
[SYMLINK$1]() {
|
|
749
|
+
fs$1.readlink(this.absolute, (e, t) => {
|
|
750
|
+
if (e) return this.emit(`error`, e);
|
|
751
|
+
this[ONREADLINK](t);
|
|
752
|
+
});
|
|
753
|
+
}
|
|
754
|
+
[ONREADLINK](e) {
|
|
755
|
+
this.linkpath = normalizeWindowsPath(e), this[HEADER](), this.end();
|
|
756
|
+
}
|
|
757
|
+
[HARDLINK$1](e) {
|
|
758
|
+
if (!this.stat) throw Error(`cannot create link entry without stat`);
|
|
759
|
+
this.type = `Link`, this.linkpath = normalizeWindowsPath(path$1.relative(this.cwd, e)), this.stat.size = 0, this[HEADER](), this.end();
|
|
760
|
+
}
|
|
761
|
+
[FILE$1]() {
|
|
762
|
+
if (!this.stat) throw Error(`cannot create file entry without stat`);
|
|
763
|
+
if (this.stat.nlink > 1) {
|
|
764
|
+
let e = `${this.stat.dev}:${this.stat.ino}`, t = this.linkCache.get(e);
|
|
765
|
+
if (t?.indexOf(this.cwd) === 0) return this[HARDLINK$1](t);
|
|
766
|
+
this.linkCache.set(e, this.absolute);
|
|
767
|
+
}
|
|
768
|
+
if (this[HEADER](), this.stat.size === 0) return this.end();
|
|
769
|
+
this[OPENFILE]();
|
|
770
|
+
}
|
|
771
|
+
[OPENFILE]() {
|
|
772
|
+
fs$1.open(this.absolute, `r`, (e, t) => {
|
|
773
|
+
if (e) return this.emit(`error`, e);
|
|
774
|
+
this[ONOPENFILE](t);
|
|
775
|
+
});
|
|
776
|
+
}
|
|
777
|
+
[ONOPENFILE](e) {
|
|
778
|
+
if (this.fd = e, this.#hadError) return this[CLOSE]();
|
|
779
|
+
if (!this.stat) throw Error(`should stat before calling onopenfile`);
|
|
780
|
+
this.blockLen = 512 * Math.ceil(this.stat.size / 512), this.blockRemain = this.blockLen;
|
|
781
|
+
let t = Math.min(this.blockLen, this.maxReadSize);
|
|
782
|
+
this.buf = Buffer.allocUnsafe(t), this.offset = 0, this.pos = 0, this.remain = this.stat.size, this.length = this.buf.length, this[READ]();
|
|
783
|
+
}
|
|
784
|
+
[READ]() {
|
|
785
|
+
let { fd: e, buf: t, offset: n, length: r, pos: i } = this;
|
|
786
|
+
if (e === void 0 || t === void 0) throw Error(`cannot read file without first opening`);
|
|
787
|
+
fs$1.read(e, t, n, r, i, (e, t) => {
|
|
788
|
+
if (e) return this[CLOSE](() => this.emit(`error`, e));
|
|
789
|
+
this[ONREAD](t);
|
|
790
|
+
});
|
|
791
|
+
}
|
|
792
|
+
[CLOSE](e = () => {}) {
|
|
793
|
+
this.fd !== void 0 && fs$1.close(this.fd, e);
|
|
794
|
+
}
|
|
795
|
+
[ONREAD](e) {
|
|
796
|
+
if (e <= 0 && this.remain > 0) {
|
|
797
|
+
let e = Object.assign(Error(`encountered unexpected EOF`), {
|
|
798
|
+
path: this.absolute,
|
|
799
|
+
syscall: `read`,
|
|
800
|
+
code: `EOF`
|
|
801
|
+
});
|
|
802
|
+
return this[CLOSE](() => this.emit(`error`, e));
|
|
803
|
+
}
|
|
804
|
+
if (e > this.remain) {
|
|
805
|
+
let e = Object.assign(Error(`did not encounter expected EOF`), {
|
|
806
|
+
path: this.absolute,
|
|
807
|
+
syscall: `read`,
|
|
808
|
+
code: `EOF`
|
|
809
|
+
});
|
|
810
|
+
return this[CLOSE](() => this.emit(`error`, e));
|
|
811
|
+
}
|
|
812
|
+
if (!this.buf) throw Error(`should have created buffer prior to reading`);
|
|
813
|
+
if (e === this.remain) for (let t = e; t < this.length && e < this.blockRemain; t++) this.buf[t + this.offset] = 0, e++, this.remain++;
|
|
814
|
+
let t = this.offset === 0 && e === this.buf.length ? this.buf : this.buf.subarray(this.offset, this.offset + e);
|
|
815
|
+
this.write(t) ? this[ONDRAIN$1]() : this[AWAITDRAIN](() => this[ONDRAIN$1]());
|
|
816
|
+
}
|
|
817
|
+
[AWAITDRAIN](e) {
|
|
818
|
+
this.once(`drain`, e);
|
|
819
|
+
}
|
|
820
|
+
write(e, t, n) {
|
|
821
|
+
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) {
|
|
822
|
+
let e = Object.assign(Error(`writing more data than expected`), { path: this.absolute });
|
|
823
|
+
return this.emit(`error`, e);
|
|
824
|
+
}
|
|
825
|
+
return this.remain -= e.length, this.blockRemain -= e.length, this.pos += e.length, this.offset += e.length, super.write(e, null, n);
|
|
826
|
+
}
|
|
827
|
+
[ONDRAIN$1]() {
|
|
828
|
+
if (!this.remain) return this.blockRemain && super.write(Buffer.alloc(this.blockRemain)), this[CLOSE]((e) => e ? this.emit(`error`, e) : this.end());
|
|
829
|
+
if (!this.buf) throw Error(`buffer lost somehow in ONDRAIN`);
|
|
830
|
+
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]();
|
|
831
|
+
}
|
|
832
|
+
}, WriteEntrySync = class extends WriteEntry {
|
|
833
|
+
sync = !0;
|
|
834
|
+
[LSTAT]() {
|
|
835
|
+
this[ONLSTAT](fs$1.lstatSync(this.absolute));
|
|
836
|
+
}
|
|
837
|
+
[SYMLINK$1]() {
|
|
838
|
+
this[ONREADLINK](fs$1.readlinkSync(this.absolute));
|
|
839
|
+
}
|
|
840
|
+
[OPENFILE]() {
|
|
841
|
+
this[ONOPENFILE](fs$1.openSync(this.absolute, `r`));
|
|
842
|
+
}
|
|
843
|
+
[READ]() {
|
|
844
|
+
let e = !0;
|
|
845
|
+
try {
|
|
846
|
+
let { fd: t, buf: n, offset: r, length: i, pos: a } = this;
|
|
847
|
+
if (t === void 0 || n === void 0) throw Error(`fd and buf must be set in READ method`);
|
|
848
|
+
let o = fs$1.readSync(t, n, r, i, a);
|
|
849
|
+
this[ONREAD](o), e = !1;
|
|
850
|
+
} finally {
|
|
851
|
+
if (e) try {
|
|
852
|
+
this[CLOSE](() => {});
|
|
853
|
+
} catch {}
|
|
854
|
+
}
|
|
855
|
+
}
|
|
856
|
+
[AWAITDRAIN](e) {
|
|
857
|
+
e();
|
|
858
|
+
}
|
|
859
|
+
[CLOSE](e = () => {}) {
|
|
860
|
+
this.fd !== void 0 && fs$1.closeSync(this.fd), e();
|
|
861
|
+
}
|
|
862
|
+
}, WriteEntryTar = class extends Minipass {
|
|
863
|
+
blockLen = 0;
|
|
864
|
+
blockRemain = 0;
|
|
865
|
+
buf = 0;
|
|
866
|
+
pos = 0;
|
|
867
|
+
remain = 0;
|
|
868
|
+
length = 0;
|
|
869
|
+
preservePaths;
|
|
870
|
+
portable;
|
|
871
|
+
strict;
|
|
872
|
+
noPax;
|
|
873
|
+
noMtime;
|
|
874
|
+
readEntry;
|
|
875
|
+
type;
|
|
876
|
+
prefix;
|
|
877
|
+
path;
|
|
878
|
+
mode;
|
|
879
|
+
uid;
|
|
880
|
+
gid;
|
|
881
|
+
uname;
|
|
882
|
+
gname;
|
|
883
|
+
header;
|
|
884
|
+
mtime;
|
|
885
|
+
atime;
|
|
886
|
+
ctime;
|
|
887
|
+
linkpath;
|
|
888
|
+
size;
|
|
889
|
+
onWriteEntry;
|
|
890
|
+
warn(e, t, n = {}) {
|
|
891
|
+
return warnMethod(this, e, t, n);
|
|
892
|
+
}
|
|
893
|
+
constructor(e, t = {}) {
|
|
894
|
+
let n = dealias(t);
|
|
895
|
+
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;
|
|
896
|
+
let { type: r } = e;
|
|
897
|
+
if (r === `Unsupported`) throw Error(`writing entry that should be ignored`);
|
|
898
|
+
this.type = r, this.type === `Directory` && this.portable && (this.noMtime = !0), this.prefix = n.prefix, this.path = normalizeWindowsPath(e.path), this.mode = e.mode === void 0 ? void 0 : this[MODE](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 : normalizeWindowsPath(e.linkpath), typeof n.onwarn == `function` && this.on(`warn`, n.onwarn);
|
|
899
|
+
let i = !1;
|
|
900
|
+
if (!this.preservePaths) {
|
|
901
|
+
let [e, t] = stripAbsolutePath(this.path);
|
|
902
|
+
e && typeof t == `string` && (this.path = t, i = e);
|
|
903
|
+
}
|
|
904
|
+
this.remain = e.size, this.blockRemain = e.startBlockSize, this.onWriteEntry?.(this), this.header = new Header({
|
|
905
|
+
path: this[PREFIX](this.path),
|
|
906
|
+
linkpath: this.type === `Link` && this.linkpath !== void 0 ? this[PREFIX](this.linkpath) : this.linkpath,
|
|
907
|
+
mode: this.mode,
|
|
908
|
+
uid: this.portable ? void 0 : this.uid,
|
|
909
|
+
gid: this.portable ? void 0 : this.gid,
|
|
910
|
+
size: this.size,
|
|
911
|
+
mtime: this.noMtime ? void 0 : this.mtime,
|
|
912
|
+
type: this.type,
|
|
913
|
+
uname: this.portable ? void 0 : this.uname,
|
|
914
|
+
atime: this.portable ? void 0 : this.atime,
|
|
915
|
+
ctime: this.portable ? void 0 : this.ctime
|
|
916
|
+
}), i && this.warn(`TAR_ENTRY_INFO`, `stripping ${i} from absolute path`, {
|
|
917
|
+
entry: this,
|
|
918
|
+
path: i + this.path
|
|
919
|
+
}), this.header.encode() && !this.noPax && super.write(new Pax({
|
|
920
|
+
atime: this.portable ? void 0 : this.atime,
|
|
921
|
+
ctime: this.portable ? void 0 : this.ctime,
|
|
922
|
+
gid: this.portable ? void 0 : this.gid,
|
|
923
|
+
mtime: this.noMtime ? void 0 : this.mtime,
|
|
924
|
+
path: this[PREFIX](this.path),
|
|
925
|
+
linkpath: this.type === `Link` && this.linkpath !== void 0 ? this[PREFIX](this.linkpath) : this.linkpath,
|
|
926
|
+
size: this.size,
|
|
927
|
+
uid: this.portable ? void 0 : this.uid,
|
|
928
|
+
uname: this.portable ? void 0 : this.uname,
|
|
929
|
+
dev: this.portable ? void 0 : this.readEntry.dev,
|
|
930
|
+
ino: this.portable ? void 0 : this.readEntry.ino,
|
|
931
|
+
nlink: this.portable ? void 0 : this.readEntry.nlink
|
|
932
|
+
}).encode());
|
|
933
|
+
let a = this.header?.block;
|
|
934
|
+
if (!a) throw Error(`failed to encode header`);
|
|
935
|
+
super.write(a), e.pipe(this);
|
|
936
|
+
}
|
|
937
|
+
[PREFIX](e) {
|
|
938
|
+
return prefixPath(e, this.prefix);
|
|
939
|
+
}
|
|
940
|
+
[MODE](e) {
|
|
941
|
+
return modeFix(e, this.type === `Directory`, this.portable);
|
|
942
|
+
}
|
|
943
|
+
write(e, t, n) {
|
|
944
|
+
typeof t == `function` && (n = t, t = void 0), typeof e == `string` && (e = Buffer.from(e, typeof t == `string` ? t : `utf8`));
|
|
945
|
+
let r = e.length;
|
|
946
|
+
if (r > this.blockRemain) throw Error(`writing more to entry than is appropriate`);
|
|
947
|
+
return this.blockRemain -= r, super.write(e, n);
|
|
948
|
+
}
|
|
949
|
+
end(e, t, n) {
|
|
950
|
+
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;
|
|
951
|
+
}
|
|
952
|
+
};
|
|
953
|
+
const getType = (e) => e.isFile() ? `File` : e.isDirectory() ? `Directory` : e.isSymbolicLink() ? `SymbolicLink` : `Unsupported`;
|
|
954
|
+
var Yallist = class e {
|
|
955
|
+
tail;
|
|
956
|
+
head;
|
|
957
|
+
length = 0;
|
|
958
|
+
static create(t = []) {
|
|
959
|
+
return new e(t);
|
|
960
|
+
}
|
|
961
|
+
constructor(e = []) {
|
|
962
|
+
for (let t of e) this.push(t);
|
|
963
|
+
}
|
|
964
|
+
*[Symbol.iterator]() {
|
|
965
|
+
for (let e = this.head; e; e = e.next) yield e.value;
|
|
966
|
+
}
|
|
967
|
+
removeNode(e) {
|
|
968
|
+
if (e.list !== this) throw Error(`removing node which does not belong to this list`);
|
|
969
|
+
let t = e.next, n = e.prev;
|
|
970
|
+
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;
|
|
971
|
+
}
|
|
972
|
+
unshiftNode(e) {
|
|
973
|
+
if (e === this.head) return;
|
|
974
|
+
e.list && e.list.removeNode(e);
|
|
975
|
+
let t = this.head;
|
|
976
|
+
e.list = this, e.next = t, t && (t.prev = e), this.head = e, this.tail ||= e, this.length++;
|
|
977
|
+
}
|
|
978
|
+
pushNode(e) {
|
|
979
|
+
if (e === this.tail) return;
|
|
980
|
+
e.list && e.list.removeNode(e);
|
|
981
|
+
let t = this.tail;
|
|
982
|
+
e.list = this, e.prev = t, t && (t.next = e), this.tail = e, this.head ||= e, this.length++;
|
|
983
|
+
}
|
|
984
|
+
push(...e) {
|
|
985
|
+
for (let t = 0, n = e.length; t < n; t++) push(this, e[t]);
|
|
986
|
+
return this.length;
|
|
987
|
+
}
|
|
988
|
+
unshift(...e) {
|
|
989
|
+
for (var t = 0, n = e.length; t < n; t++) unshift(this, e[t]);
|
|
990
|
+
return this.length;
|
|
991
|
+
}
|
|
992
|
+
pop() {
|
|
993
|
+
if (!this.tail) return;
|
|
994
|
+
let e = this.tail.value, t = this.tail;
|
|
995
|
+
return this.tail = this.tail.prev, this.tail ? this.tail.next = void 0 : this.head = void 0, t.list = void 0, this.length--, e;
|
|
996
|
+
}
|
|
997
|
+
shift() {
|
|
998
|
+
if (!this.head) return;
|
|
999
|
+
let e = this.head.value, t = this.head;
|
|
1000
|
+
return this.head = this.head.next, this.head ? this.head.prev = void 0 : this.tail = void 0, t.list = void 0, this.length--, e;
|
|
1001
|
+
}
|
|
1002
|
+
forEach(e, t) {
|
|
1003
|
+
t ||= this;
|
|
1004
|
+
for (let n = this.head, r = 0; n; r++) e.call(t, n.value, r, this), n = n.next;
|
|
1005
|
+
}
|
|
1006
|
+
forEachReverse(e, t) {
|
|
1007
|
+
t ||= this;
|
|
1008
|
+
for (let n = this.tail, r = this.length - 1; n; r--) e.call(t, n.value, r, this), n = n.prev;
|
|
1009
|
+
}
|
|
1010
|
+
get(e) {
|
|
1011
|
+
let t = 0, n = this.head;
|
|
1012
|
+
for (; n && t < e; t++) n = n.next;
|
|
1013
|
+
if (t === e && n) return n.value;
|
|
1014
|
+
}
|
|
1015
|
+
getReverse(e) {
|
|
1016
|
+
let t = 0, n = this.tail;
|
|
1017
|
+
for (; n && t < e; t++) n = n.prev;
|
|
1018
|
+
if (t === e && n) return n.value;
|
|
1019
|
+
}
|
|
1020
|
+
map(t, n) {
|
|
1021
|
+
n ||= this;
|
|
1022
|
+
let r = new e();
|
|
1023
|
+
for (let e = this.head; e;) r.push(t.call(n, e.value, this)), e = e.next;
|
|
1024
|
+
return r;
|
|
1025
|
+
}
|
|
1026
|
+
mapReverse(t, n) {
|
|
1027
|
+
n ||= this;
|
|
1028
|
+
var r = new e();
|
|
1029
|
+
for (let e = this.tail; e;) r.push(t.call(n, e.value, this)), e = e.prev;
|
|
1030
|
+
return r;
|
|
1031
|
+
}
|
|
1032
|
+
reduce(e, t) {
|
|
1033
|
+
let n, r = this.head;
|
|
1034
|
+
if (arguments.length > 1) n = t;
|
|
1035
|
+
else if (this.head) r = this.head.next, n = this.head.value;
|
|
1036
|
+
else throw TypeError(`Reduce of empty list with no initial value`);
|
|
1037
|
+
for (var i = 0; r; i++) n = e(n, r.value, i), r = r.next;
|
|
1038
|
+
return n;
|
|
1039
|
+
}
|
|
1040
|
+
reduceReverse(e, t) {
|
|
1041
|
+
let n, r = this.tail;
|
|
1042
|
+
if (arguments.length > 1) n = t;
|
|
1043
|
+
else if (this.tail) r = this.tail.prev, n = this.tail.value;
|
|
1044
|
+
else throw TypeError(`Reduce of empty list with no initial value`);
|
|
1045
|
+
for (let t = this.length - 1; r; t--) n = e(n, r.value, t), r = r.prev;
|
|
1046
|
+
return n;
|
|
1047
|
+
}
|
|
1048
|
+
toArray() {
|
|
1049
|
+
let e = Array(this.length);
|
|
1050
|
+
for (let t = 0, n = this.head; n; t++) e[t] = n.value, n = n.next;
|
|
1051
|
+
return e;
|
|
1052
|
+
}
|
|
1053
|
+
toArrayReverse() {
|
|
1054
|
+
let e = Array(this.length);
|
|
1055
|
+
for (let t = 0, n = this.tail; n; t++) e[t] = n.value, n = n.prev;
|
|
1056
|
+
return e;
|
|
1057
|
+
}
|
|
1058
|
+
slice(t = 0, n = this.length) {
|
|
1059
|
+
n < 0 && (n += this.length), t < 0 && (t += this.length);
|
|
1060
|
+
let r = new e();
|
|
1061
|
+
if (n < t || n < 0) return r;
|
|
1062
|
+
t < 0 && (t = 0), n > this.length && (n = this.length);
|
|
1063
|
+
let i = this.head, a = 0;
|
|
1064
|
+
for (a = 0; i && a < t; a++) i = i.next;
|
|
1065
|
+
for (; i && a < n; a++, i = i.next) r.push(i.value);
|
|
1066
|
+
return r;
|
|
1067
|
+
}
|
|
1068
|
+
sliceReverse(t = 0, n = this.length) {
|
|
1069
|
+
n < 0 && (n += this.length), t < 0 && (t += this.length);
|
|
1070
|
+
let r = new e();
|
|
1071
|
+
if (n < t || n < 0) return r;
|
|
1072
|
+
t < 0 && (t = 0), n > this.length && (n = this.length);
|
|
1073
|
+
let i = this.length, a = this.tail;
|
|
1074
|
+
for (; a && i > n; i--) a = a.prev;
|
|
1075
|
+
for (; a && i > t; i--, a = a.prev) r.push(a.value);
|
|
1076
|
+
return r;
|
|
1077
|
+
}
|
|
1078
|
+
splice(e, t = 0, ...n) {
|
|
1079
|
+
e > this.length && (e = this.length - 1), e < 0 && (e = this.length + e);
|
|
1080
|
+
let r = this.head;
|
|
1081
|
+
for (let t = 0; r && t < e; t++) r = r.next;
|
|
1082
|
+
let i = [];
|
|
1083
|
+
for (let e = 0; r && e < t; e++) i.push(r.value), r = this.removeNode(r);
|
|
1084
|
+
r ? r !== this.tail && (r = r.prev) : r = this.tail;
|
|
1085
|
+
for (let e of n) r = insertAfter(this, r, e);
|
|
1086
|
+
return i;
|
|
1087
|
+
}
|
|
1088
|
+
reverse() {
|
|
1089
|
+
let e = this.head, t = this.tail;
|
|
1090
|
+
for (let t = e; t; t = t.prev) {
|
|
1091
|
+
let e = t.prev;
|
|
1092
|
+
t.prev = t.next, t.next = e;
|
|
1093
|
+
}
|
|
1094
|
+
return this.head = t, this.tail = e, this;
|
|
1095
|
+
}
|
|
1096
|
+
};
|
|
1097
|
+
function insertAfter(e, t, n) {
|
|
1098
|
+
let r = new Node(n, t, t ? t.next : e.head, e);
|
|
1099
|
+
return r.next === void 0 && (e.tail = r), r.prev === void 0 && (e.head = r), e.length++, r;
|
|
1100
|
+
}
|
|
1101
|
+
function push(e, t) {
|
|
1102
|
+
e.tail = new Node(t, e.tail, void 0, e), e.head ||= e.tail, e.length++;
|
|
1103
|
+
}
|
|
1104
|
+
function unshift(e, t) {
|
|
1105
|
+
e.head = new Node(t, void 0, e.head, e), e.tail ||= e.head, e.length++;
|
|
1106
|
+
}
|
|
1107
|
+
var Node = class {
|
|
1108
|
+
list;
|
|
1109
|
+
next;
|
|
1110
|
+
prev;
|
|
1111
|
+
value;
|
|
1112
|
+
constructor(e, t, n, r) {
|
|
1113
|
+
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;
|
|
1114
|
+
}
|
|
1115
|
+
}, PackJob = class {
|
|
1116
|
+
path;
|
|
1117
|
+
absolute;
|
|
1118
|
+
entry;
|
|
1119
|
+
stat;
|
|
1120
|
+
readdir;
|
|
1121
|
+
pending = !1;
|
|
1122
|
+
ignore = !1;
|
|
1123
|
+
piped = !1;
|
|
1124
|
+
constructor(e, t) {
|
|
1125
|
+
this.path = e || `./`, this.absolute = t;
|
|
1126
|
+
}
|
|
1127
|
+
};
|
|
1128
|
+
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`);
|
|
1129
|
+
var Pack = class extends Minipass {
|
|
1130
|
+
sync = !1;
|
|
1131
|
+
opt;
|
|
1132
|
+
cwd;
|
|
1133
|
+
maxReadSize;
|
|
1134
|
+
preservePaths;
|
|
1135
|
+
strict;
|
|
1136
|
+
noPax;
|
|
1137
|
+
prefix;
|
|
1138
|
+
linkCache;
|
|
1139
|
+
statCache;
|
|
1140
|
+
file;
|
|
1141
|
+
portable;
|
|
1142
|
+
zip;
|
|
1143
|
+
readdirCache;
|
|
1144
|
+
noDirRecurse;
|
|
1145
|
+
follow;
|
|
1146
|
+
noMtime;
|
|
1147
|
+
mtime;
|
|
1148
|
+
filter;
|
|
1149
|
+
jobs;
|
|
1150
|
+
[WRITEENTRYCLASS];
|
|
1151
|
+
onWriteEntry;
|
|
1152
|
+
[QUEUE];
|
|
1153
|
+
[JOBS] = 0;
|
|
1154
|
+
[PROCESSING] = !1;
|
|
1155
|
+
[ENDED$1] = !1;
|
|
1156
|
+
constructor(e = {}) {
|
|
1157
|
+
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 = normalizeWindowsPath(e.prefix || ``), this.linkCache = e.linkCache || /* @__PURE__ */ new Map(), this.statCache = e.statCache || /* @__PURE__ */ new Map(), this.readdirCache = e.readdirCache || /* @__PURE__ */ new Map(), this.onWriteEntry = e.onWriteEntry, this[WRITEENTRYCLASS] = WriteEntry, typeof e.onwarn == `function` && this.on(`warn`, e.onwarn), this.portable = !!e.portable, e.gzip || e.brotli || e.zstd) {
|
|
1158
|
+
if ((e.gzip ? 1 : 0) + (e.brotli ? 1 : 0) + (e.zstd ? 1 : 0) > 1) throw TypeError(`gzip, brotli, zstd are mutually exclusive`);
|
|
1159
|
+
if (e.gzip && (typeof e.gzip != `object` && (e.gzip = {}), this.portable && (e.gzip.portable = !0), this.zip = new Gzip(e.gzip)), e.brotli && (typeof e.brotli != `object` && (e.brotli = {}), this.zip = new BrotliCompress(e.brotli)), e.zstd && (typeof e.zstd != `object` && (e.zstd = {}), this.zip = new ZstdCompress(e.zstd)), !this.zip) throw Error(`impossible`);
|
|
1160
|
+
let t = this.zip;
|
|
1161
|
+
t.on(`data`, (e) => super.write(e)), t.on(`end`, () => super.end()), t.on(`drain`, () => this[ONDRAIN]()), this.on(`resume`, () => t.resume());
|
|
1162
|
+
} else this.on(`drain`, this[ONDRAIN]);
|
|
1163
|
+
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[QUEUE] = new Yallist(), this[JOBS] = 0, this.jobs = Number(e.jobs) || 4, this[PROCESSING] = !1, this[ENDED$1] = !1;
|
|
1164
|
+
}
|
|
1165
|
+
[WRITE](e) {
|
|
1166
|
+
return super.write(e);
|
|
1167
|
+
}
|
|
1168
|
+
add(e) {
|
|
1169
|
+
return this.write(e), this;
|
|
1170
|
+
}
|
|
1171
|
+
end(e, t, n) {
|
|
1172
|
+
return typeof e == `function` && (n = e, e = void 0), typeof t == `function` && (n = t, t = void 0), e && this.add(e), this[ENDED$1] = !0, this[PROCESS](), n && n(), this;
|
|
1173
|
+
}
|
|
1174
|
+
write(e) {
|
|
1175
|
+
if (this[ENDED$1]) throw Error(`write after end`);
|
|
1176
|
+
return e instanceof ReadEntry ? this[ADDTARENTRY](e) : this[ADDFSENTRY](e), this.flowing;
|
|
1177
|
+
}
|
|
1178
|
+
[ADDTARENTRY](e) {
|
|
1179
|
+
let t = normalizeWindowsPath(path$1.resolve(this.cwd, e.path));
|
|
1180
|
+
if (!this.filter(e.path, e)) e.resume();
|
|
1181
|
+
else {
|
|
1182
|
+
let n = new PackJob(e.path, t);
|
|
1183
|
+
n.entry = new WriteEntryTar(e, this[ENTRYOPT](n)), n.entry.on(`end`, () => this[JOBDONE](n)), this[JOBS] += 1, this[QUEUE].push(n);
|
|
1184
|
+
}
|
|
1185
|
+
this[PROCESS]();
|
|
1186
|
+
}
|
|
1187
|
+
[ADDFSENTRY](e) {
|
|
1188
|
+
let t = normalizeWindowsPath(path$1.resolve(this.cwd, e));
|
|
1189
|
+
this[QUEUE].push(new PackJob(e, t)), this[PROCESS]();
|
|
1190
|
+
}
|
|
1191
|
+
[STAT](e) {
|
|
1192
|
+
e.pending = !0, this[JOBS] += 1, fs$1[this.follow ? `stat` : `lstat`](e.absolute, (t, n) => {
|
|
1193
|
+
e.pending = !1, --this[JOBS], t ? this.emit(`error`, t) : this[ONSTAT](e, n);
|
|
1194
|
+
});
|
|
1195
|
+
}
|
|
1196
|
+
[ONSTAT](e, t) {
|
|
1197
|
+
this.statCache.set(e.absolute, t), e.stat = t, this.filter(e.path, t) ? t.isFile() && t.nlink > 1 && e === this[CURRENT] && !this.linkCache.get(`${t.dev}:${t.ino}`) && !this.sync && this[PROCESSJOB](e) : e.ignore = !0, this[PROCESS]();
|
|
1198
|
+
}
|
|
1199
|
+
[READDIR](e) {
|
|
1200
|
+
e.pending = !0, this[JOBS] += 1, fs$1.readdir(e.absolute, (t, n) => {
|
|
1201
|
+
if (e.pending = !1, --this[JOBS], t) return this.emit(`error`, t);
|
|
1202
|
+
this[ONREADDIR](e, n);
|
|
1203
|
+
});
|
|
1204
|
+
}
|
|
1205
|
+
[ONREADDIR](e, t) {
|
|
1206
|
+
this.readdirCache.set(e.absolute, t), e.readdir = t, this[PROCESS]();
|
|
1207
|
+
}
|
|
1208
|
+
[PROCESS]() {
|
|
1209
|
+
if (!this[PROCESSING]) {
|
|
1210
|
+
this[PROCESSING] = !0;
|
|
1211
|
+
for (let e = this[QUEUE].head; e && this[JOBS] < this.jobs; e = e.next) if (this[PROCESSJOB](e.value), e.value.ignore) {
|
|
1212
|
+
let t = e.next;
|
|
1213
|
+
this[QUEUE].removeNode(e), e.next = t;
|
|
1214
|
+
}
|
|
1215
|
+
this[PROCESSING] = !1, this[ENDED$1] && !this[QUEUE].length && this[JOBS] === 0 && (this.zip ? this.zip.end(EOF) : (super.write(EOF), super.end()));
|
|
1216
|
+
}
|
|
1217
|
+
}
|
|
1218
|
+
get [CURRENT]() {
|
|
1219
|
+
return this[QUEUE] && this[QUEUE].head && this[QUEUE].head.value;
|
|
1220
|
+
}
|
|
1221
|
+
[JOBDONE](e) {
|
|
1222
|
+
this[QUEUE].shift(), --this[JOBS], this[PROCESS]();
|
|
1223
|
+
}
|
|
1224
|
+
[PROCESSJOB](e) {
|
|
1225
|
+
if (!e.pending) {
|
|
1226
|
+
if (e.entry) {
|
|
1227
|
+
e === this[CURRENT] && !e.piped && this[PIPE](e);
|
|
1228
|
+
return;
|
|
1229
|
+
}
|
|
1230
|
+
if (!e.stat) {
|
|
1231
|
+
let t = this.statCache.get(e.absolute);
|
|
1232
|
+
t ? this[ONSTAT](e, t) : this[STAT](e);
|
|
1233
|
+
}
|
|
1234
|
+
if (e.stat && !e.ignore) {
|
|
1235
|
+
if (!this.noDirRecurse && e.stat.isDirectory() && !e.readdir) {
|
|
1236
|
+
let t = this.readdirCache.get(e.absolute);
|
|
1237
|
+
if (t ? this[ONREADDIR](e, t) : this[READDIR](e), !e.readdir) return;
|
|
1238
|
+
}
|
|
1239
|
+
if (e.entry = this[ENTRY](e), !e.entry) {
|
|
1240
|
+
e.ignore = !0;
|
|
1241
|
+
return;
|
|
1242
|
+
}
|
|
1243
|
+
e === this[CURRENT] && !e.piped && this[PIPE](e);
|
|
1244
|
+
}
|
|
1245
|
+
}
|
|
1246
|
+
}
|
|
1247
|
+
[ENTRYOPT](e) {
|
|
1248
|
+
return {
|
|
1249
|
+
onwarn: (e, t, n) => this.warn(e, t, n),
|
|
1250
|
+
noPax: this.noPax,
|
|
1251
|
+
cwd: this.cwd,
|
|
1252
|
+
absolute: e.absolute,
|
|
1253
|
+
preservePaths: this.preservePaths,
|
|
1254
|
+
maxReadSize: this.maxReadSize,
|
|
1255
|
+
strict: this.strict,
|
|
1256
|
+
portable: this.portable,
|
|
1257
|
+
linkCache: this.linkCache,
|
|
1258
|
+
statCache: this.statCache,
|
|
1259
|
+
noMtime: this.noMtime,
|
|
1260
|
+
mtime: this.mtime,
|
|
1261
|
+
prefix: this.prefix,
|
|
1262
|
+
onWriteEntry: this.onWriteEntry
|
|
1263
|
+
};
|
|
1264
|
+
}
|
|
1265
|
+
[ENTRY](e) {
|
|
1266
|
+
this[JOBS] += 1;
|
|
1267
|
+
try {
|
|
1268
|
+
return new this[WRITEENTRYCLASS](e.path, this[ENTRYOPT](e)).on(`end`, () => this[JOBDONE](e)).on(`error`, (e) => this.emit(`error`, e));
|
|
1269
|
+
} catch (e) {
|
|
1270
|
+
this.emit(`error`, e);
|
|
1271
|
+
}
|
|
1272
|
+
}
|
|
1273
|
+
[ONDRAIN]() {
|
|
1274
|
+
this[CURRENT] && this[CURRENT].entry && this[CURRENT].entry.resume();
|
|
1275
|
+
}
|
|
1276
|
+
[PIPE](e) {
|
|
1277
|
+
e.piped = !0, e.readdir && e.readdir.forEach((t) => {
|
|
1278
|
+
let n = e.path, r = n === `./` ? `` : n.replace(/\/*$/, `/`);
|
|
1279
|
+
this[ADDFSENTRY](r + t);
|
|
1280
|
+
});
|
|
1281
|
+
let t = e.entry, n = this.zip;
|
|
1282
|
+
if (!t) throw Error(`cannot pipe without source`);
|
|
1283
|
+
n ? t.on(`data`, (e) => {
|
|
1284
|
+
n.write(e) || t.pause();
|
|
1285
|
+
}) : t.on(`data`, (e) => {
|
|
1286
|
+
super.write(e) || t.pause();
|
|
1287
|
+
});
|
|
1288
|
+
}
|
|
1289
|
+
pause() {
|
|
1290
|
+
return this.zip && this.zip.pause(), super.pause();
|
|
1291
|
+
}
|
|
1292
|
+
warn(e, t, n = {}) {
|
|
1293
|
+
warnMethod(this, e, t, n);
|
|
1294
|
+
}
|
|
1295
|
+
}, PackSync = class extends Pack {
|
|
1296
|
+
sync = !0;
|
|
1297
|
+
constructor(e) {
|
|
1298
|
+
super(e), this[WRITEENTRYCLASS] = WriteEntrySync;
|
|
1299
|
+
}
|
|
1300
|
+
pause() {}
|
|
1301
|
+
resume() {}
|
|
1302
|
+
[STAT](e) {
|
|
1303
|
+
let t = this.follow ? `statSync` : `lstatSync`;
|
|
1304
|
+
this[ONSTAT](e, fs$1[t](e.absolute));
|
|
1305
|
+
}
|
|
1306
|
+
[READDIR](e) {
|
|
1307
|
+
this[ONREADDIR](e, fs$1.readdirSync(e.absolute));
|
|
1308
|
+
}
|
|
1309
|
+
[PIPE](e) {
|
|
1310
|
+
let t = e.entry, n = this.zip;
|
|
1311
|
+
if (e.readdir && e.readdir.forEach((t) => {
|
|
1312
|
+
let n = e.path, r = n === `./` ? `` : n.replace(/\/*$/, `/`);
|
|
1313
|
+
this[ADDFSENTRY](r + t);
|
|
1314
|
+
}), !t) throw Error(`Cannot pipe without source`);
|
|
1315
|
+
n ? t.on(`data`, (e) => {
|
|
1316
|
+
n.write(e);
|
|
1317
|
+
}) : t.on(`data`, (e) => {
|
|
1318
|
+
super[WRITE](e);
|
|
1319
|
+
});
|
|
1320
|
+
}
|
|
1321
|
+
};
|
|
1322
|
+
const createFileSync = (e, t) => {
|
|
1323
|
+
let r = new PackSync(e), i = new WriteStreamSync(e.file, { mode: e.mode || 438 });
|
|
1324
|
+
r.pipe(i), addFilesSync$1(r, t);
|
|
1325
|
+
}, createFile = (e, t) => {
|
|
1326
|
+
let n = new Pack(e), r = new WriteStream(e.file, { mode: e.mode || 438 });
|
|
1327
|
+
n.pipe(r);
|
|
1328
|
+
let a = new Promise((e, t) => {
|
|
1329
|
+
r.on(`error`, t), r.on(`close`, e), n.on(`error`, t);
|
|
1330
|
+
});
|
|
1331
|
+
return addFilesAsync$1(n, t), a;
|
|
1332
|
+
}, addFilesSync$1 = (e, t) => {
|
|
1333
|
+
t.forEach((t) => {
|
|
1334
|
+
t.charAt(0) === `@` ? list({
|
|
1335
|
+
file: path.resolve(e.cwd, t.slice(1)),
|
|
1336
|
+
sync: !0,
|
|
1337
|
+
noResume: !0,
|
|
1338
|
+
onReadEntry: (t) => e.add(t)
|
|
1339
|
+
}) : e.add(t);
|
|
1340
|
+
}), e.end();
|
|
1341
|
+
}, addFilesAsync$1 = async (e, t) => {
|
|
1342
|
+
for (let n = 0; n < t.length; n++) {
|
|
1343
|
+
let r = String(t[n]);
|
|
1344
|
+
r.charAt(0) === `@` ? await list({
|
|
1345
|
+
file: path.resolve(String(e.cwd), r.slice(1)),
|
|
1346
|
+
noResume: !0,
|
|
1347
|
+
onReadEntry: (t) => {
|
|
1348
|
+
e.add(t);
|
|
1349
|
+
}
|
|
1350
|
+
}) : e.add(r);
|
|
1351
|
+
}
|
|
1352
|
+
e.end();
|
|
1353
|
+
};
|
|
1354
|
+
makeCommand(createFileSync, createFile, (e, t) => {
|
|
1355
|
+
let n = new PackSync(e);
|
|
1356
|
+
return addFilesSync$1(n, t), n;
|
|
1357
|
+
}, (e, t) => {
|
|
1358
|
+
let n = new Pack(e);
|
|
1359
|
+
return addFilesAsync$1(n, t), n;
|
|
1360
|
+
}, (e, t) => {
|
|
1361
|
+
if (!t?.length) throw TypeError(`no paths specified to add to archive`);
|
|
1362
|
+
});
|
|
1363
|
+
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 ? (e) => e < 524288 ? fMapFlag : `w` : () => `w`;
|
|
1364
|
+
var CwdError = class extends Error {
|
|
1365
|
+
path;
|
|
1366
|
+
code;
|
|
1367
|
+
syscall = `chdir`;
|
|
1368
|
+
constructor(e, t) {
|
|
1369
|
+
super(`${t}: Cannot cd into '${e}'`), this.path = e, this.code = t;
|
|
1370
|
+
}
|
|
1371
|
+
get name() {
|
|
1372
|
+
return `CwdError`;
|
|
1373
|
+
}
|
|
1374
|
+
}, SymlinkError = class extends Error {
|
|
1375
|
+
path;
|
|
1376
|
+
symlink;
|
|
1377
|
+
syscall = `symlink`;
|
|
1378
|
+
code = `TAR_SYMLINK_ERROR`;
|
|
1379
|
+
constructor(e, t) {
|
|
1380
|
+
super(`TAR_SYMLINK_ERROR: Cannot extract through symbolic link`), this.symlink = e, this.path = t;
|
|
1381
|
+
}
|
|
1382
|
+
get name() {
|
|
1383
|
+
return `SymlinkError`;
|
|
1384
|
+
}
|
|
1385
|
+
};
|
|
1386
|
+
const checkCwd = (e, t) => {
|
|
1387
|
+
fs.stat(e, (n, r) => {
|
|
1388
|
+
(n || !r.isDirectory()) && (n = new CwdError(e, n?.code || `ENOTDIR`)), t(n);
|
|
1389
|
+
});
|
|
1390
|
+
}, mkdir$1 = (e, t, n) => {
|
|
1391
|
+
e = normalizeWindowsPath(e);
|
|
1392
|
+
let r = t.umask ?? 18, i = t.mode | 448, a = (i & r) !== 0, o = t.uid, s = t.gid, c = typeof o == `number` && typeof s == `number` && (o !== t.processUid || s !== t.processGid), l = t.preserve, u = t.unlink, d = normalizeWindowsPath(t.cwd), f = (t, r) => {
|
|
1393
|
+
t ? n(t) : r && c ? chownr(r, o, s, (e) => f(e)) : a ? fs.chmod(e, i, n) : n();
|
|
1394
|
+
};
|
|
1395
|
+
if (e === d) return checkCwd(e, f);
|
|
1396
|
+
if (l) return fsp.mkdir(e, {
|
|
1397
|
+
mode: i,
|
|
1398
|
+
recursive: !0
|
|
1399
|
+
}).then((e) => f(null, e ?? void 0), f);
|
|
1400
|
+
mkdir_(d, normalizeWindowsPath(path.relative(d, e)).split(`/`), i, u, d, void 0, f);
|
|
1401
|
+
}, mkdir_ = (e, t, n, r, i, a, o) => {
|
|
1402
|
+
if (!t.length) return o(null, a);
|
|
1403
|
+
let s = t.shift(), c = normalizeWindowsPath(path.resolve(e + `/` + s));
|
|
1404
|
+
fs.mkdir(c, n, onmkdir(c, t, n, r, i, a, o));
|
|
1405
|
+
}, onmkdir = (e, t, n, r, i, a, o) => (s) => {
|
|
1406
|
+
s ? fs.lstat(e, (c, l) => {
|
|
1407
|
+
if (c) c.path = c.path && normalizeWindowsPath(c.path), o(c);
|
|
1408
|
+
else if (l.isDirectory()) mkdir_(e, t, n, r, i, a, o);
|
|
1409
|
+
else if (r) fs.unlink(e, (s) => {
|
|
1410
|
+
if (s) return o(s);
|
|
1411
|
+
fs.mkdir(e, n, onmkdir(e, t, n, r, i, a, o));
|
|
1412
|
+
});
|
|
1413
|
+
else if (l.isSymbolicLink()) return o(new SymlinkError(e, e + `/` + t.join(`/`)));
|
|
1414
|
+
else o(s);
|
|
1415
|
+
}) : (a ||= e, mkdir_(e, t, n, r, i, a, o));
|
|
1416
|
+
}, checkCwdSync = (e) => {
|
|
1417
|
+
let t = !1, n;
|
|
1418
|
+
try {
|
|
1419
|
+
t = fs.statSync(e).isDirectory();
|
|
1420
|
+
} catch (e) {
|
|
1421
|
+
n = e?.code;
|
|
1422
|
+
} finally {
|
|
1423
|
+
if (!t) throw new CwdError(e, n ?? `ENOTDIR`);
|
|
1424
|
+
}
|
|
1425
|
+
}, mkdirSync = (e, t) => {
|
|
1426
|
+
e = normalizeWindowsPath(e);
|
|
1427
|
+
let n = t.umask ?? 18, r = t.mode | 448, i = (r & n) !== 0, a = t.uid, o = t.gid, s = typeof a == `number` && typeof o == `number` && (a !== t.processUid || o !== t.processGid), c = t.preserve, l = t.unlink, u = normalizeWindowsPath(t.cwd), d = (t) => {
|
|
1428
|
+
t && s && chownrSync(t, a, o), i && fs.chmodSync(e, r);
|
|
1429
|
+
};
|
|
1430
|
+
if (e === u) return checkCwdSync(u), d();
|
|
1431
|
+
if (c) return d(fs.mkdirSync(e, {
|
|
1432
|
+
mode: r,
|
|
1433
|
+
recursive: !0
|
|
1434
|
+
}) ?? void 0);
|
|
1435
|
+
let p = normalizeWindowsPath(path.relative(u, e)).split(`/`), m;
|
|
1436
|
+
for (let e = p.shift(), t = u; e && (t += `/` + e); e = p.shift()) {
|
|
1437
|
+
t = normalizeWindowsPath(path.resolve(t));
|
|
1438
|
+
try {
|
|
1439
|
+
fs.mkdirSync(t, r), m ||= t;
|
|
1440
|
+
} catch {
|
|
1441
|
+
let e = fs.lstatSync(t);
|
|
1442
|
+
if (e.isDirectory()) continue;
|
|
1443
|
+
if (l) {
|
|
1444
|
+
fs.unlinkSync(t), fs.mkdirSync(t, r), m ||= t;
|
|
1445
|
+
continue;
|
|
1446
|
+
} else if (e.isSymbolicLink()) return new SymlinkError(t, t + `/` + p.join(`/`));
|
|
1447
|
+
}
|
|
1448
|
+
}
|
|
1449
|
+
return d(m);
|
|
1450
|
+
}, normalizeCache = Object.create(null), MAX = 1e4, cache = /* @__PURE__ */ new Set(), normalizeUnicode = (e) => {
|
|
1451
|
+
cache.has(e) ? cache.delete(e) : normalizeCache[e] = e.normalize(`NFD`).toLocaleLowerCase(`en`).toLocaleUpperCase(`en`), cache.add(e);
|
|
1452
|
+
let t = normalizeCache[e], n = cache.size - MAX;
|
|
1453
|
+
if (n > MAX / 10) {
|
|
1454
|
+
for (let e of cache) if (cache.delete(e), delete normalizeCache[e], --n <= 0) break;
|
|
1455
|
+
}
|
|
1456
|
+
return t;
|
|
1457
|
+
}, isWindows$1 = (process.env.TESTING_TAR_FAKE_PLATFORM || process.platform) === `win32`, getDirs = (e) => e.split(`/`).slice(0, -1).reduce((e, t) => {
|
|
1458
|
+
let n = e[e.length - 1];
|
|
1459
|
+
return n !== void 0 && (t = join(n, t)), e.push(t || `/`), e;
|
|
1460
|
+
}, []);
|
|
1461
|
+
var PathReservations = class {
|
|
1462
|
+
#queues = /* @__PURE__ */ new Map();
|
|
1463
|
+
#reservations = /* @__PURE__ */ new Map();
|
|
1464
|
+
#running = /* @__PURE__ */ new Set();
|
|
1465
|
+
reserve(e, t) {
|
|
1466
|
+
e = isWindows$1 ? [`win32 parallelization disabled`] : e.map((e) => stripTrailingSlashes(join(normalizeUnicode(e))));
|
|
1467
|
+
let n = new Set(e.map((e) => getDirs(e)).reduce((e, t) => e.concat(t)));
|
|
1468
|
+
this.#reservations.set(t, {
|
|
1469
|
+
dirs: n,
|
|
1470
|
+
paths: e
|
|
1471
|
+
});
|
|
1472
|
+
for (let n of e) {
|
|
1473
|
+
let e = this.#queues.get(n);
|
|
1474
|
+
e ? e.push(t) : this.#queues.set(n, [t]);
|
|
1475
|
+
}
|
|
1476
|
+
for (let e of n) {
|
|
1477
|
+
let n = this.#queues.get(e);
|
|
1478
|
+
if (!n) this.#queues.set(e, [new Set([t])]);
|
|
1479
|
+
else {
|
|
1480
|
+
let e = n[n.length - 1];
|
|
1481
|
+
e instanceof Set ? e.add(t) : n.push(new Set([t]));
|
|
1482
|
+
}
|
|
1483
|
+
}
|
|
1484
|
+
return this.#run(t);
|
|
1485
|
+
}
|
|
1486
|
+
#getQueues(e) {
|
|
1487
|
+
let t = this.#reservations.get(e);
|
|
1488
|
+
if (!t) throw Error(`function does not have any path reservations`);
|
|
1489
|
+
return {
|
|
1490
|
+
paths: t.paths.map((e) => this.#queues.get(e)),
|
|
1491
|
+
dirs: [...t.dirs].map((e) => this.#queues.get(e))
|
|
1492
|
+
};
|
|
1493
|
+
}
|
|
1494
|
+
check(e) {
|
|
1495
|
+
let { paths: t, dirs: n } = this.#getQueues(e);
|
|
1496
|
+
return t.every((t) => t && t[0] === e) && n.every((t) => t && t[0] instanceof Set && t[0].has(e));
|
|
1497
|
+
}
|
|
1498
|
+
#run(e) {
|
|
1499
|
+
return this.#running.has(e) || !this.check(e) ? !1 : (this.#running.add(e), e(() => this.#clear(e)), !0);
|
|
1500
|
+
}
|
|
1501
|
+
#clear(e) {
|
|
1502
|
+
if (!this.#running.has(e)) return !1;
|
|
1503
|
+
let t = this.#reservations.get(e);
|
|
1504
|
+
if (!t) throw Error(`invalid reservation`);
|
|
1505
|
+
let { paths: n, dirs: r } = t, i = /* @__PURE__ */ new Set();
|
|
1506
|
+
for (let t of n) {
|
|
1507
|
+
let n = this.#queues.get(t);
|
|
1508
|
+
if (!n || n?.[0] !== e) continue;
|
|
1509
|
+
let r = n[1];
|
|
1510
|
+
if (!r) {
|
|
1511
|
+
this.#queues.delete(t);
|
|
1512
|
+
continue;
|
|
1513
|
+
}
|
|
1514
|
+
if (n.shift(), typeof r == `function`) i.add(r);
|
|
1515
|
+
else for (let e of r) i.add(e);
|
|
1516
|
+
}
|
|
1517
|
+
for (let t of r) {
|
|
1518
|
+
let n = this.#queues.get(t), r = n?.[0];
|
|
1519
|
+
if (!(!n || !(r instanceof Set))) if (r.size === 1 && n.length === 1) {
|
|
1520
|
+
this.#queues.delete(t);
|
|
1521
|
+
continue;
|
|
1522
|
+
} else if (r.size === 1) {
|
|
1523
|
+
n.shift();
|
|
1524
|
+
let e = n[0];
|
|
1525
|
+
typeof e == `function` && i.add(e);
|
|
1526
|
+
} else r.delete(e);
|
|
1527
|
+
}
|
|
1528
|
+
return this.#running.delete(e), i.forEach((e) => this.#run(e)), !0;
|
|
1529
|
+
}
|
|
1530
|
+
};
|
|
1531
|
+
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 = (e, t) => {
|
|
1532
|
+
if (!isWindows) return fs.unlink(e, t);
|
|
1533
|
+
let n = e + `.DELETE.` + randomBytes(16).toString(`hex`);
|
|
1534
|
+
fs.rename(e, n, (e) => {
|
|
1535
|
+
if (e) return t(e);
|
|
1536
|
+
fs.unlink(n, t);
|
|
1537
|
+
});
|
|
1538
|
+
}, unlinkFileSync = (e) => {
|
|
1539
|
+
if (!isWindows) return fs.unlinkSync(e);
|
|
1540
|
+
let t = e + `.DELETE.` + randomBytes(16).toString(`hex`);
|
|
1541
|
+
fs.renameSync(e, t), fs.unlinkSync(t);
|
|
1542
|
+
}, uint32 = (e, t, n) => e !== void 0 && e === e >>> 0 ? e : t !== void 0 && t === t >>> 0 ? t : n;
|
|
1543
|
+
var Unpack = class extends Parser {
|
|
1544
|
+
[ENDED] = !1;
|
|
1545
|
+
[CHECKED_CWD] = !1;
|
|
1546
|
+
[PENDING] = 0;
|
|
1547
|
+
reservations = new PathReservations();
|
|
1548
|
+
transform;
|
|
1549
|
+
writable = !0;
|
|
1550
|
+
readable = !1;
|
|
1551
|
+
uid;
|
|
1552
|
+
gid;
|
|
1553
|
+
setOwner;
|
|
1554
|
+
preserveOwner;
|
|
1555
|
+
processGid;
|
|
1556
|
+
processUid;
|
|
1557
|
+
maxDepth;
|
|
1558
|
+
forceChown;
|
|
1559
|
+
win32;
|
|
1560
|
+
newer;
|
|
1561
|
+
keep;
|
|
1562
|
+
noMtime;
|
|
1563
|
+
preservePaths;
|
|
1564
|
+
unlink;
|
|
1565
|
+
cwd;
|
|
1566
|
+
strip;
|
|
1567
|
+
processUmask;
|
|
1568
|
+
umask;
|
|
1569
|
+
dmode;
|
|
1570
|
+
fmode;
|
|
1571
|
+
chmod;
|
|
1572
|
+
constructor(e = {}) {
|
|
1573
|
+
if (e.ondone = () => {
|
|
1574
|
+
this[ENDED] = !0, this[MAYBECLOSE]();
|
|
1575
|
+
}, super(e), this.transform = e.transform, this.chmod = !!e.chmod, typeof e.uid == `number` || typeof e.gid == `number`) {
|
|
1576
|
+
if (typeof e.uid != `number` || typeof e.gid != `number`) throw TypeError(`cannot set owner without number uid and gid`);
|
|
1577
|
+
if (e.preserveOwner) throw TypeError(`cannot preserve owner in archive and also set owner explicitly`);
|
|
1578
|
+
this.uid = e.uid, this.gid = e.gid, this.setOwner = !0;
|
|
1579
|
+
} else this.uid = void 0, this.gid = void 0, this.setOwner = !1;
|
|
1580
|
+
e.preserveOwner === void 0 && typeof e.uid != `number` ? this.preserveOwner = !!(process.getuid && process.getuid() === 0) : this.preserveOwner = !!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 : 1024, this.forceChown = e.forceChown === !0, this.win32 = !!e.win32 || isWindows, this.newer = !!e.newer, this.keep = !!e.keep, this.noMtime = !!e.noMtime, this.preservePaths = !!e.preservePaths, this.unlink = !!e.unlink, this.cwd = normalizeWindowsPath(path.resolve(e.cwd || process.cwd())), this.strip = Number(e.strip) || 0, this.processUmask = this.chmod ? typeof e.processUmask == `number` ? e.processUmask : process.umask() : 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[ONENTRY](e));
|
|
1581
|
+
}
|
|
1582
|
+
warn(e, t, n = {}) {
|
|
1583
|
+
return (e === `TAR_BAD_ARCHIVE` || e === `TAR_ABORT`) && (n.recoverable = !1), super.warn(e, t, n);
|
|
1584
|
+
}
|
|
1585
|
+
[MAYBECLOSE]() {
|
|
1586
|
+
this[ENDED] && this[PENDING] === 0 && (this.emit(`prefinish`), this.emit(`finish`), this.emit(`end`));
|
|
1587
|
+
}
|
|
1588
|
+
[STRIPABSOLUTEPATH](e, t) {
|
|
1589
|
+
let n = e[t], { type: r } = e;
|
|
1590
|
+
if (!n || this.preservePaths) return !0;
|
|
1591
|
+
let i = n.split(`/`);
|
|
1592
|
+
if (i.includes(`..`) || isWindows && /^[a-z]:\.\.$/i.test(i[0] ?? ``)) {
|
|
1593
|
+
if (t === `path` || r === `Link`) return this.warn(`TAR_ENTRY_ERROR`, `${t} contains '..'`, {
|
|
1594
|
+
entry: e,
|
|
1595
|
+
[t]: n
|
|
1596
|
+
}), !1;
|
|
1597
|
+
{
|
|
1598
|
+
let r = path.posix.dirname(e.path), i = path.posix.normalize(path.posix.join(r, n));
|
|
1599
|
+
if (i.startsWith(`../`) || i === `..`) return this.warn(`TAR_ENTRY_ERROR`, `${t} escapes extraction directory`, {
|
|
1600
|
+
entry: e,
|
|
1601
|
+
[t]: n
|
|
1602
|
+
}), !1;
|
|
1603
|
+
}
|
|
1604
|
+
}
|
|
1605
|
+
let [a, o] = stripAbsolutePath(n);
|
|
1606
|
+
return a && (e[t] = String(o), this.warn(`TAR_ENTRY_INFO`, `stripping ${a} from absolute ${t}`, {
|
|
1607
|
+
entry: e,
|
|
1608
|
+
[t]: n
|
|
1609
|
+
})), !0;
|
|
1610
|
+
}
|
|
1611
|
+
[CHECKPATH](e) {
|
|
1612
|
+
let t = normalizeWindowsPath(e.path), n = t.split(`/`);
|
|
1613
|
+
if (this.strip) {
|
|
1614
|
+
if (n.length < this.strip) return !1;
|
|
1615
|
+
if (e.type === `Link`) {
|
|
1616
|
+
let t = normalizeWindowsPath(String(e.linkpath)).split(`/`);
|
|
1617
|
+
if (t.length >= this.strip) e.linkpath = t.slice(this.strip).join(`/`);
|
|
1618
|
+
else return !1;
|
|
1619
|
+
}
|
|
1620
|
+
n.splice(0, this.strip), e.path = n.join(`/`);
|
|
1621
|
+
}
|
|
1622
|
+
if (isFinite(this.maxDepth) && n.length > this.maxDepth) return this.warn(`TAR_ENTRY_ERROR`, `path excessively deep`, {
|
|
1623
|
+
entry: e,
|
|
1624
|
+
path: t,
|
|
1625
|
+
depth: n.length,
|
|
1626
|
+
maxDepth: this.maxDepth
|
|
1627
|
+
}), !1;
|
|
1628
|
+
if (!this[STRIPABSOLUTEPATH](e, `path`) || !this[STRIPABSOLUTEPATH](e, `linkpath`)) return !1;
|
|
1629
|
+
if (path.isAbsolute(e.path) ? e.absolute = normalizeWindowsPath(path.resolve(e.path)) : e.absolute = normalizeWindowsPath(path.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`, {
|
|
1630
|
+
entry: e,
|
|
1631
|
+
path: normalizeWindowsPath(e.path),
|
|
1632
|
+
resolvedPath: e.absolute,
|
|
1633
|
+
cwd: this.cwd
|
|
1634
|
+
}), !1;
|
|
1635
|
+
if (e.absolute === this.cwd && e.type !== `Directory` && e.type !== `GNUDumpDir`) return !1;
|
|
1636
|
+
if (this.win32) {
|
|
1637
|
+
let { root: t } = path.win32.parse(String(e.absolute));
|
|
1638
|
+
e.absolute = t + encode(String(e.absolute).slice(t.length));
|
|
1639
|
+
let { root: n } = path.win32.parse(e.path);
|
|
1640
|
+
e.path = n + encode(e.path.slice(n.length));
|
|
1641
|
+
}
|
|
1642
|
+
return !0;
|
|
1643
|
+
}
|
|
1644
|
+
[ONENTRY](e) {
|
|
1645
|
+
if (!this[CHECKPATH](e)) return e.resume();
|
|
1646
|
+
switch (assert.equal(typeof e.absolute, `string`), e.type) {
|
|
1647
|
+
case `Directory`:
|
|
1648
|
+
case `GNUDumpDir`: e.mode && (e.mode |= 448);
|
|
1649
|
+
case `File`:
|
|
1650
|
+
case `OldFile`:
|
|
1651
|
+
case `ContiguousFile`:
|
|
1652
|
+
case `Link`:
|
|
1653
|
+
case `SymbolicLink`: return this[CHECKFS](e);
|
|
1654
|
+
default: return this[UNSUPPORTED](e);
|
|
1655
|
+
}
|
|
1656
|
+
}
|
|
1657
|
+
[ONERROR](e, t) {
|
|
1658
|
+
e.name === `CwdError` ? this.emit(`error`, e) : (this.warn(`TAR_ENTRY_ERROR`, e, { entry: t }), this[UNPEND](), t.resume());
|
|
1659
|
+
}
|
|
1660
|
+
[MKDIR](e, t, n) {
|
|
1661
|
+
mkdir$1(normalizeWindowsPath(e), {
|
|
1662
|
+
uid: this.uid,
|
|
1663
|
+
gid: this.gid,
|
|
1664
|
+
processUid: this.processUid,
|
|
1665
|
+
processGid: this.processGid,
|
|
1666
|
+
umask: this.processUmask,
|
|
1667
|
+
preserve: this.preservePaths,
|
|
1668
|
+
unlink: this.unlink,
|
|
1669
|
+
cwd: this.cwd,
|
|
1670
|
+
mode: t
|
|
1671
|
+
}, n);
|
|
1672
|
+
}
|
|
1673
|
+
[DOCHOWN](e) {
|
|
1674
|
+
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;
|
|
1675
|
+
}
|
|
1676
|
+
[UID](e) {
|
|
1677
|
+
return uint32(this.uid, e.uid, this.processUid);
|
|
1678
|
+
}
|
|
1679
|
+
[GID](e) {
|
|
1680
|
+
return uint32(this.gid, e.gid, this.processGid);
|
|
1681
|
+
}
|
|
1682
|
+
[FILE](e, t) {
|
|
1683
|
+
let n = typeof e.mode == `number` ? e.mode & 4095 : this.fmode, r = new WriteStream(String(e.absolute), {
|
|
1684
|
+
flags: getWriteFlag(e.size),
|
|
1685
|
+
mode: n,
|
|
1686
|
+
autoClose: !1
|
|
1687
|
+
});
|
|
1688
|
+
r.on(`error`, (n) => {
|
|
1689
|
+
r.fd && fs.close(r.fd, () => {}), r.write = () => !0, this[ONERROR](n, e), t();
|
|
1690
|
+
});
|
|
1691
|
+
let a = 1, o = (n) => {
|
|
1692
|
+
if (n) {
|
|
1693
|
+
r.fd && fs.close(r.fd, () => {}), this[ONERROR](n, e), t();
|
|
1694
|
+
return;
|
|
1695
|
+
}
|
|
1696
|
+
--a === 0 && r.fd !== void 0 && fs.close(r.fd, (n) => {
|
|
1697
|
+
n ? this[ONERROR](n, e) : this[UNPEND](), t();
|
|
1698
|
+
});
|
|
1699
|
+
};
|
|
1700
|
+
r.on(`finish`, () => {
|
|
1701
|
+
let t = String(e.absolute), n = r.fd;
|
|
1702
|
+
if (typeof n == `number` && e.mtime && !this.noMtime) {
|
|
1703
|
+
a++;
|
|
1704
|
+
let r = e.atime || /* @__PURE__ */ new Date(), i = e.mtime;
|
|
1705
|
+
fs.futimes(n, r, i, (e) => e ? fs.utimes(t, r, i, (t) => o(t && e)) : o());
|
|
1706
|
+
}
|
|
1707
|
+
if (typeof n == `number` && this[DOCHOWN](e)) {
|
|
1708
|
+
a++;
|
|
1709
|
+
let r = this[UID](e), i = this[GID](e);
|
|
1710
|
+
typeof r == `number` && typeof i == `number` && fs.fchown(n, r, i, (e) => e ? fs.chown(t, r, i, (t) => o(t && e)) : o());
|
|
1711
|
+
}
|
|
1712
|
+
o();
|
|
1713
|
+
});
|
|
1714
|
+
let s = this.transform && this.transform(e) || e;
|
|
1715
|
+
s !== e && (s.on(`error`, (n) => {
|
|
1716
|
+
this[ONERROR](n, e), t();
|
|
1717
|
+
}), e.pipe(s)), s.pipe(r);
|
|
1718
|
+
}
|
|
1719
|
+
[DIRECTORY](e, t) {
|
|
1720
|
+
let n = typeof e.mode == `number` ? e.mode & 4095 : this.dmode;
|
|
1721
|
+
this[MKDIR](String(e.absolute), n, (n) => {
|
|
1722
|
+
if (n) {
|
|
1723
|
+
this[ONERROR](n, e), t();
|
|
1724
|
+
return;
|
|
1725
|
+
}
|
|
1726
|
+
let r = 1, i = () => {
|
|
1727
|
+
--r === 0 && (t(), this[UNPEND](), e.resume());
|
|
1728
|
+
};
|
|
1729
|
+
e.mtime && !this.noMtime && (r++, fs.utimes(String(e.absolute), e.atime || /* @__PURE__ */ new Date(), e.mtime, i)), this[DOCHOWN](e) && (r++, fs.chown(String(e.absolute), Number(this[UID](e)), Number(this[GID](e)), i)), i();
|
|
1730
|
+
});
|
|
1731
|
+
}
|
|
1732
|
+
[UNSUPPORTED](e) {
|
|
1733
|
+
e.unsupported = !0, this.warn(`TAR_ENTRY_UNSUPPORTED`, `unsupported entry type: ${e.type}`, { entry: e }), e.resume();
|
|
1734
|
+
}
|
|
1735
|
+
[SYMLINK](e, t) {
|
|
1736
|
+
this[LINK](e, String(e.linkpath), `symlink`, t);
|
|
1737
|
+
}
|
|
1738
|
+
[HARDLINK](e, t) {
|
|
1739
|
+
let n = normalizeWindowsPath(path.resolve(this.cwd, String(e.linkpath)));
|
|
1740
|
+
this[LINK](e, n, `link`, t);
|
|
1741
|
+
}
|
|
1742
|
+
[PEND]() {
|
|
1743
|
+
this[PENDING]++;
|
|
1744
|
+
}
|
|
1745
|
+
[UNPEND]() {
|
|
1746
|
+
this[PENDING]--, this[MAYBECLOSE]();
|
|
1747
|
+
}
|
|
1748
|
+
[SKIP](e) {
|
|
1749
|
+
this[UNPEND](), e.resume();
|
|
1750
|
+
}
|
|
1751
|
+
[ISREUSABLE](e, t) {
|
|
1752
|
+
return e.type === `File` && !this.unlink && t.isFile() && t.nlink <= 1 && !isWindows;
|
|
1753
|
+
}
|
|
1754
|
+
[CHECKFS](e) {
|
|
1755
|
+
this[PEND]();
|
|
1756
|
+
let t = [e.path];
|
|
1757
|
+
e.linkpath && t.push(e.linkpath), this.reservations.reserve(t, (t) => this[CHECKFS2](e, t));
|
|
1758
|
+
}
|
|
1759
|
+
[CHECKFS2](e, t) {
|
|
1760
|
+
let n = (e) => {
|
|
1761
|
+
t(e);
|
|
1762
|
+
}, r = () => {
|
|
1763
|
+
this[MKDIR](this.cwd, this.dmode, (t) => {
|
|
1764
|
+
if (t) {
|
|
1765
|
+
this[ONERROR](t, e), n();
|
|
1766
|
+
return;
|
|
1767
|
+
}
|
|
1768
|
+
this[CHECKED_CWD] = !0, i();
|
|
1769
|
+
});
|
|
1770
|
+
}, i = () => {
|
|
1771
|
+
if (e.absolute !== this.cwd) {
|
|
1772
|
+
let t = normalizeWindowsPath(path.dirname(String(e.absolute)));
|
|
1773
|
+
if (t !== this.cwd) return this[MKDIR](t, this.dmode, (t) => {
|
|
1774
|
+
if (t) {
|
|
1775
|
+
this[ONERROR](t, e), n();
|
|
1776
|
+
return;
|
|
1777
|
+
}
|
|
1778
|
+
a();
|
|
1779
|
+
});
|
|
1780
|
+
}
|
|
1781
|
+
a();
|
|
1782
|
+
}, a = () => {
|
|
1783
|
+
fs.lstat(String(e.absolute), (t, r) => {
|
|
1784
|
+
if (r && (this.keep || this.newer && r.mtime > (e.mtime ?? r.mtime))) {
|
|
1785
|
+
this[SKIP](e), n();
|
|
1786
|
+
return;
|
|
1787
|
+
}
|
|
1788
|
+
if (t || this[ISREUSABLE](e, r)) return this[MAKEFS](null, e, n);
|
|
1789
|
+
if (r.isDirectory()) {
|
|
1790
|
+
if (e.type === `Directory`) {
|
|
1791
|
+
let t = this.chmod && e.mode && (r.mode & 4095) !== e.mode, i = (t) => this[MAKEFS](t ?? null, e, n);
|
|
1792
|
+
return t ? fs.chmod(String(e.absolute), Number(e.mode), i) : i();
|
|
1793
|
+
}
|
|
1794
|
+
if (e.absolute !== this.cwd) return fs.rmdir(String(e.absolute), (t) => this[MAKEFS](t ?? null, e, n));
|
|
1795
|
+
}
|
|
1796
|
+
if (e.absolute === this.cwd) return this[MAKEFS](null, e, n);
|
|
1797
|
+
unlinkFile(String(e.absolute), (t) => this[MAKEFS](t ?? null, e, n));
|
|
1798
|
+
});
|
|
1799
|
+
};
|
|
1800
|
+
this[CHECKED_CWD] ? i() : r();
|
|
1801
|
+
}
|
|
1802
|
+
[MAKEFS](e, t, n) {
|
|
1803
|
+
if (e) {
|
|
1804
|
+
this[ONERROR](e, t), n();
|
|
1805
|
+
return;
|
|
1806
|
+
}
|
|
1807
|
+
switch (t.type) {
|
|
1808
|
+
case `File`:
|
|
1809
|
+
case `OldFile`:
|
|
1810
|
+
case `ContiguousFile`: return this[FILE](t, n);
|
|
1811
|
+
case `Link`: return this[HARDLINK](t, n);
|
|
1812
|
+
case `SymbolicLink`: return this[SYMLINK](t, n);
|
|
1813
|
+
case `Directory`:
|
|
1814
|
+
case `GNUDumpDir`: return this[DIRECTORY](t, n);
|
|
1815
|
+
}
|
|
1816
|
+
}
|
|
1817
|
+
[LINK](e, t, n, r) {
|
|
1818
|
+
fs[n](t, String(e.absolute), (t) => {
|
|
1819
|
+
t ? this[ONERROR](t, e) : (this[UNPEND](), e.resume()), r();
|
|
1820
|
+
});
|
|
1821
|
+
}
|
|
1822
|
+
};
|
|
1823
|
+
const callSync = (e) => {
|
|
1824
|
+
try {
|
|
1825
|
+
return [null, e()];
|
|
1826
|
+
} catch (e) {
|
|
1827
|
+
return [e, null];
|
|
1828
|
+
}
|
|
1829
|
+
};
|
|
1830
|
+
var UnpackSync = class extends Unpack {
|
|
1831
|
+
sync = !0;
|
|
1832
|
+
[MAKEFS](e, t) {
|
|
1833
|
+
return super[MAKEFS](e, t, () => {});
|
|
1834
|
+
}
|
|
1835
|
+
[CHECKFS](e) {
|
|
1836
|
+
if (!this[CHECKED_CWD]) {
|
|
1837
|
+
let t = this[MKDIR](this.cwd, this.dmode);
|
|
1838
|
+
if (t) return this[ONERROR](t, e);
|
|
1839
|
+
this[CHECKED_CWD] = !0;
|
|
1840
|
+
}
|
|
1841
|
+
if (e.absolute !== this.cwd) {
|
|
1842
|
+
let t = normalizeWindowsPath(path.dirname(String(e.absolute)));
|
|
1843
|
+
if (t !== this.cwd) {
|
|
1844
|
+
let n = this[MKDIR](t, this.dmode);
|
|
1845
|
+
if (n) return this[ONERROR](n, e);
|
|
1846
|
+
}
|
|
1847
|
+
}
|
|
1848
|
+
let [t, n] = callSync(() => fs.lstatSync(String(e.absolute)));
|
|
1849
|
+
if (n && (this.keep || this.newer && n.mtime > (e.mtime ?? n.mtime))) return this[SKIP](e);
|
|
1850
|
+
if (t || this[ISREUSABLE](e, n)) return this[MAKEFS](null, e);
|
|
1851
|
+
if (n.isDirectory()) {
|
|
1852
|
+
if (e.type === `Directory`) {
|
|
1853
|
+
let [t] = this.chmod && e.mode && (n.mode & 4095) !== e.mode ? callSync(() => {
|
|
1854
|
+
fs.chmodSync(String(e.absolute), Number(e.mode));
|
|
1855
|
+
}) : [];
|
|
1856
|
+
return this[MAKEFS](t, e);
|
|
1857
|
+
}
|
|
1858
|
+
let [t] = callSync(() => fs.rmdirSync(String(e.absolute)));
|
|
1859
|
+
this[MAKEFS](t, e);
|
|
1860
|
+
}
|
|
1861
|
+
let [r] = e.absolute === this.cwd ? [] : callSync(() => unlinkFileSync(String(e.absolute)));
|
|
1862
|
+
this[MAKEFS](r, e);
|
|
1863
|
+
}
|
|
1864
|
+
[FILE](e, t) {
|
|
1865
|
+
let n = typeof e.mode == `number` ? e.mode & 4095 : this.fmode, r = (n) => {
|
|
1866
|
+
let r;
|
|
1867
|
+
try {
|
|
1868
|
+
fs.closeSync(i);
|
|
1869
|
+
} catch (e) {
|
|
1870
|
+
r = e;
|
|
1871
|
+
}
|
|
1872
|
+
(n || r) && this[ONERROR](n || r, e), t();
|
|
1873
|
+
}, i;
|
|
1874
|
+
try {
|
|
1875
|
+
i = fs.openSync(String(e.absolute), getWriteFlag(e.size), n);
|
|
1876
|
+
} catch (e) {
|
|
1877
|
+
return r(e);
|
|
1878
|
+
}
|
|
1879
|
+
let a = this.transform && this.transform(e) || e;
|
|
1880
|
+
a !== e && (a.on(`error`, (t) => this[ONERROR](t, e)), e.pipe(a)), a.on(`data`, (e) => {
|
|
1881
|
+
try {
|
|
1882
|
+
fs.writeSync(i, e, 0, e.length);
|
|
1883
|
+
} catch (e) {
|
|
1884
|
+
r(e);
|
|
1885
|
+
}
|
|
1886
|
+
}), a.on(`end`, () => {
|
|
1887
|
+
let t = null;
|
|
1888
|
+
if (e.mtime && !this.noMtime) {
|
|
1889
|
+
let n = e.atime || /* @__PURE__ */ new Date(), r = e.mtime;
|
|
1890
|
+
try {
|
|
1891
|
+
fs.futimesSync(i, n, r);
|
|
1892
|
+
} catch (i) {
|
|
1893
|
+
try {
|
|
1894
|
+
fs.utimesSync(String(e.absolute), n, r);
|
|
1895
|
+
} catch {
|
|
1896
|
+
t = i;
|
|
1897
|
+
}
|
|
1898
|
+
}
|
|
1899
|
+
}
|
|
1900
|
+
if (this[DOCHOWN](e)) {
|
|
1901
|
+
let n = this[UID](e), r = this[GID](e);
|
|
1902
|
+
try {
|
|
1903
|
+
fs.fchownSync(i, Number(n), Number(r));
|
|
1904
|
+
} catch (i) {
|
|
1905
|
+
try {
|
|
1906
|
+
fs.chownSync(String(e.absolute), Number(n), Number(r));
|
|
1907
|
+
} catch {
|
|
1908
|
+
t ||= i;
|
|
1909
|
+
}
|
|
1910
|
+
}
|
|
1911
|
+
}
|
|
1912
|
+
r(t);
|
|
1913
|
+
});
|
|
1914
|
+
}
|
|
1915
|
+
[DIRECTORY](e, t) {
|
|
1916
|
+
let n = typeof e.mode == `number` ? e.mode & 4095 : this.dmode, r = this[MKDIR](String(e.absolute), n);
|
|
1917
|
+
if (r) {
|
|
1918
|
+
this[ONERROR](r, e), t();
|
|
1919
|
+
return;
|
|
1920
|
+
}
|
|
1921
|
+
if (e.mtime && !this.noMtime) try {
|
|
1922
|
+
fs.utimesSync(String(e.absolute), e.atime || /* @__PURE__ */ new Date(), e.mtime);
|
|
1923
|
+
} catch {}
|
|
1924
|
+
if (this[DOCHOWN](e)) try {
|
|
1925
|
+
fs.chownSync(String(e.absolute), Number(this[UID](e)), Number(this[GID](e)));
|
|
1926
|
+
} catch {}
|
|
1927
|
+
t(), e.resume();
|
|
1928
|
+
}
|
|
1929
|
+
[MKDIR](e, t) {
|
|
1930
|
+
try {
|
|
1931
|
+
return mkdirSync(normalizeWindowsPath(e), {
|
|
1932
|
+
uid: this.uid,
|
|
1933
|
+
gid: this.gid,
|
|
1934
|
+
processUid: this.processUid,
|
|
1935
|
+
processGid: this.processGid,
|
|
1936
|
+
umask: this.processUmask,
|
|
1937
|
+
preserve: this.preservePaths,
|
|
1938
|
+
unlink: this.unlink,
|
|
1939
|
+
cwd: this.cwd,
|
|
1940
|
+
mode: t
|
|
1941
|
+
});
|
|
1942
|
+
} catch (e) {
|
|
1943
|
+
return e;
|
|
1944
|
+
}
|
|
1945
|
+
}
|
|
1946
|
+
[LINK](e, t, n, r) {
|
|
1947
|
+
let i = `${n}Sync`;
|
|
1948
|
+
try {
|
|
1949
|
+
fs[i](t, String(e.absolute)), r(), e.resume();
|
|
1950
|
+
} catch (t) {
|
|
1951
|
+
return this[ONERROR](t, e);
|
|
1952
|
+
}
|
|
1953
|
+
}
|
|
1954
|
+
};
|
|
1955
|
+
const extract = makeCommand((e) => {
|
|
1956
|
+
let t = new UnpackSync(e), n = e.file, i = fs.statSync(n);
|
|
1957
|
+
new ReadStreamSync(n, {
|
|
1958
|
+
readSize: e.maxReadSize || 16 * 1024 * 1024,
|
|
1959
|
+
size: i.size
|
|
1960
|
+
}).pipe(t);
|
|
1961
|
+
}, (e, t) => {
|
|
1962
|
+
let n = new Unpack(e), r = e.maxReadSize || 16 * 1024 * 1024, i = e.file;
|
|
1963
|
+
return new Promise((e, t) => {
|
|
1964
|
+
n.on(`error`, t), n.on(`close`, e), fs.stat(i, (e, o) => {
|
|
1965
|
+
if (e) t(e);
|
|
1966
|
+
else {
|
|
1967
|
+
let e = new ReadStream(i, {
|
|
1968
|
+
readSize: r,
|
|
1969
|
+
size: o.size
|
|
1970
|
+
});
|
|
1971
|
+
e.on(`error`, t), e.pipe(n);
|
|
1972
|
+
}
|
|
1973
|
+
});
|
|
1974
|
+
});
|
|
1975
|
+
}, (e) => new UnpackSync(e), (e) => new Unpack(e), (e, t) => {
|
|
1976
|
+
t?.length && filesFilter(e, t);
|
|
1977
|
+
}), replaceSync = (e, t) => {
|
|
1978
|
+
let n = new PackSync(e), r = !0, i, a;
|
|
1979
|
+
try {
|
|
1980
|
+
try {
|
|
1981
|
+
i = fs.openSync(e.file, `r+`);
|
|
1982
|
+
} catch (t) {
|
|
1983
|
+
if (t?.code === `ENOENT`) i = fs.openSync(e.file, `w+`);
|
|
1984
|
+
else throw t;
|
|
1985
|
+
}
|
|
1986
|
+
let o = fs.fstatSync(i), s = Buffer.alloc(512);
|
|
1987
|
+
POSITION: for (a = 0; a < o.size; a += 512) {
|
|
1988
|
+
for (let e = 0, t = 0; e < 512; e += t) {
|
|
1989
|
+
if (t = fs.readSync(i, s, e, s.length - e, a + e), a === 0 && s[0] === 31 && s[1] === 139) throw Error(`cannot append to compressed archives`);
|
|
1990
|
+
if (!t) break POSITION;
|
|
1991
|
+
}
|
|
1992
|
+
let t = new Header(s);
|
|
1993
|
+
if (!t.cksumValid) break;
|
|
1994
|
+
let n = 512 * Math.ceil((t.size || 0) / 512);
|
|
1995
|
+
if (a + n + 512 > o.size) break;
|
|
1996
|
+
a += n, e.mtimeCache && t.mtime && e.mtimeCache.set(String(t.path), t.mtime);
|
|
1997
|
+
}
|
|
1998
|
+
r = !1, streamSync(e, n, a, i, t);
|
|
1999
|
+
} finally {
|
|
2000
|
+
if (r) try {
|
|
2001
|
+
fs.closeSync(i);
|
|
2002
|
+
} catch {}
|
|
2003
|
+
}
|
|
2004
|
+
}, streamSync = (e, t, r, i, a) => {
|
|
2005
|
+
let o = new WriteStreamSync(e.file, {
|
|
2006
|
+
fd: i,
|
|
2007
|
+
start: r
|
|
2008
|
+
});
|
|
2009
|
+
t.pipe(o), addFilesSync(t, a);
|
|
2010
|
+
}, replaceAsync = (e, t) => {
|
|
2011
|
+
t = Array.from(t);
|
|
2012
|
+
let n = new Pack(e), r = (t, n, r) => {
|
|
2013
|
+
let i = (e, n) => {
|
|
2014
|
+
e ? fs.close(t, (t) => r(e)) : r(null, n);
|
|
2015
|
+
}, a = 0;
|
|
2016
|
+
if (n === 0) return i(null, 0);
|
|
2017
|
+
let o = 0, s = Buffer.alloc(512), c = (r, l) => {
|
|
2018
|
+
if (r || l === void 0) return i(r);
|
|
2019
|
+
if (o += l, o < 512 && l) return fs.read(t, s, o, s.length - o, a + o, c);
|
|
2020
|
+
if (a === 0 && s[0] === 31 && s[1] === 139) return i(Error(`cannot append to compressed archives`));
|
|
2021
|
+
if (o < 512) return i(null, a);
|
|
2022
|
+
let u = new Header(s);
|
|
2023
|
+
if (!u.cksumValid) return i(null, a);
|
|
2024
|
+
let d = 512 * Math.ceil((u.size ?? 0) / 512);
|
|
2025
|
+
if (a + d + 512 > n || (a += d + 512, a >= n)) return i(null, a);
|
|
2026
|
+
e.mtimeCache && u.mtime && e.mtimeCache.set(String(u.path), u.mtime), o = 0, fs.read(t, s, 0, 512, a, c);
|
|
2027
|
+
};
|
|
2028
|
+
fs.read(t, s, 0, 512, a, c);
|
|
2029
|
+
};
|
|
2030
|
+
return new Promise((a, o) => {
|
|
2031
|
+
n.on(`error`, o);
|
|
2032
|
+
let s = `r+`, c = (l, u) => {
|
|
2033
|
+
if (l && l.code === `ENOENT` && s === `r+`) return s = `w+`, fs.open(e.file, s, c);
|
|
2034
|
+
if (l || !u) return o(l);
|
|
2035
|
+
fs.fstat(u, (s, c) => {
|
|
2036
|
+
if (s) return fs.close(u, () => o(s));
|
|
2037
|
+
r(u, c.size, (r, s) => {
|
|
2038
|
+
if (r) return o(r);
|
|
2039
|
+
let c = new WriteStream(e.file, {
|
|
2040
|
+
fd: u,
|
|
2041
|
+
start: s
|
|
2042
|
+
});
|
|
2043
|
+
n.pipe(c), c.on(`error`, o), c.on(`close`, a), addFilesAsync(n, t);
|
|
2044
|
+
});
|
|
2045
|
+
});
|
|
2046
|
+
};
|
|
2047
|
+
fs.open(e.file, s, c);
|
|
2048
|
+
});
|
|
2049
|
+
}, addFilesSync = (e, t) => {
|
|
2050
|
+
t.forEach((t) => {
|
|
2051
|
+
t.charAt(0) === `@` ? list({
|
|
2052
|
+
file: path.resolve(e.cwd, t.slice(1)),
|
|
2053
|
+
sync: !0,
|
|
2054
|
+
noResume: !0,
|
|
2055
|
+
onReadEntry: (t) => e.add(t)
|
|
2056
|
+
}) : e.add(t);
|
|
2057
|
+
}), e.end();
|
|
2058
|
+
}, addFilesAsync = async (e, t) => {
|
|
2059
|
+
for (let n = 0; n < t.length; n++) {
|
|
2060
|
+
let r = String(t[n]);
|
|
2061
|
+
r.charAt(0) === `@` ? await list({
|
|
2062
|
+
file: path.resolve(String(e.cwd), r.slice(1)),
|
|
2063
|
+
noResume: !0,
|
|
2064
|
+
onReadEntry: (t) => e.add(t)
|
|
2065
|
+
}) : e.add(r);
|
|
2066
|
+
}
|
|
2067
|
+
e.end();
|
|
2068
|
+
}, replace = makeCommand(replaceSync, replaceAsync, () => {
|
|
2069
|
+
throw TypeError(`file is required`);
|
|
2070
|
+
}, () => {
|
|
2071
|
+
throw TypeError(`file is required`);
|
|
2072
|
+
}, (e, t) => {
|
|
2073
|
+
if (!isFile(e)) throw TypeError(`file is required`);
|
|
2074
|
+
if (e.gzip || e.brotli || e.zstd || e.file.endsWith(`.br`) || e.file.endsWith(`.tbr`)) throw TypeError(`cannot append to compressed archives`);
|
|
2075
|
+
if (!t?.length) throw TypeError(`no paths specified to add/replace`);
|
|
2076
|
+
});
|
|
2077
|
+
makeCommand(replace.syncFile, replace.asyncFile, replace.syncNoFile, replace.asyncNoFile, (e, t = []) => {
|
|
2078
|
+
replace.validate?.(e, t), mtimeFilter(e);
|
|
2079
|
+
});
|
|
2080
|
+
const mtimeFilter = (e) => {
|
|
2081
|
+
let t = e.filter;
|
|
2082
|
+
e.mtimeCache ||= /* @__PURE__ */ 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));
|
|
2083
|
+
};
|
|
2084
|
+
var esm_exports = __exportAll({
|
|
2085
|
+
Header: () => Header,
|
|
2086
|
+
Pack: () => Pack,
|
|
2087
|
+
PackJob: () => PackJob,
|
|
2088
|
+
PackSync: () => PackSync,
|
|
2089
|
+
Parser: () => Parser,
|
|
2090
|
+
Pax: () => Pax,
|
|
2091
|
+
ReadEntry: () => ReadEntry,
|
|
2092
|
+
Unpack: () => Unpack,
|
|
2093
|
+
UnpackSync: () => UnpackSync,
|
|
2094
|
+
WriteEntry: () => WriteEntry,
|
|
2095
|
+
WriteEntrySync: () => WriteEntrySync,
|
|
2096
|
+
WriteEntryTar: () => WriteEntryTar,
|
|
2097
|
+
extract: () => extract,
|
|
2098
|
+
filesFilter: () => filesFilter,
|
|
2099
|
+
list: () => list,
|
|
2100
|
+
replace: () => replace
|
|
2101
|
+
});
|
|
2102
|
+
export { esm_exports as t };
|