@turbo/codemod 2.0.5-canary.0 → 2.0.5-canary.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -40,7 +40,7 @@ ${i.message}`:y,k=[x,e,t].filter(Boolean).join(`
40
40
  `,h=Buffer.byteLength(u),f=Math.floor(Math.log(h)/Math.log(10))+1;return h+f>=Math.pow(10,f)&&(f+=1),f+h+u}};n.parse=(l,c,u)=>new n(s(o(l),c),u);var s=(l,c)=>c?Object.keys(l).reduce((u,h)=>(u[h]=l[h],u),c):l,o=l=>l.replace(/\n$/,"").split(`
41
41
  `).reduce(a,Object.create(null)),a=(l,c)=>{let u=parseInt(c,10);if(u!==Buffer.byteLength(c)+1)return l;c=c.slice((u+" ").length);let h=c.split("="),f=h.shift().replace(/^SCHILY\.(dev|ino|nlink)/,"$1");if(!f)return l;let d=h.join("=");return l[f]=/^([A-Z]+\.)?([mac]|birth|creation)time$/.test(f)?new Date(d*1e3):/^[0-9]+$/.test(d)?+d:d,l};e.exports=n}),En=ee((t,e)=>{W(),e.exports=r=>{let i=r.length-1,n=-1;for(;i>-1&&r.charAt(i)==="/";)n=i,i--;return n===-1?r:r.slice(0,n)}}),kc=ee((t,e)=>{"use strict";W(),e.exports=r=>class extends r{warn(i,n,s={}){this.file&&(s.file=this.file),this.cwd&&(s.cwd=this.cwd),s.code=n instanceof Error&&n.code||i,s.tarCode=i,!this.strict&&s.recoverable!==!1?(n instanceof Error&&(s=Object.assign(n,s),n=n.message),this.emit("warn",s.tarCode,n,s)):n instanceof Error?this.emit("error",Object.assign(n,s)):this.emit("error",Object.assign(new Error(`${i}: ${n}`),s))}}}),cg=ee((t,e)=>{"use strict";W();var r=["|","<",">","?",":"],i=r.map(o=>String.fromCharCode(61440+o.charCodeAt(0))),n=new Map(r.map((o,a)=>[o,i[a]])),s=new Map(i.map((o,a)=>[o,r[a]]));e.exports={encode:o=>r.reduce((a,l)=>a.split(l).join(n.get(l)),o),decode:o=>i.reduce((a,l)=>a.split(l).join(s.get(l)),o)}}),ug=ee((t,e)=>{W();var{isAbsolute:r,parse:i}=te("path").win32;e.exports=n=>{let s="",o=i(n);for(;r(n)||o.root;){let a=n.charAt(0)==="/"&&n.slice(0,4)!=="//?/"?"/":o.root;n=n.slice(a.length),s+=a,o=i(n)}return[s,n]}}),rk=ee((t,e)=>{"use strict";W(),e.exports=(r,i,n)=>(r&=4095,n&&(r=(r|384)&-19),i&&(r&256&&(r|=64),r&32&&(r|=8),r&4&&(r|=1)),r)}),hg=ee((t,e)=>{"use strict";W();var r=Ac(),i=Tc(),n=Sn(),s=te("fs"),o=te("path"),a=wn(),l=En(),c=(m,b)=>b?(m=a(m).replace(/^\.(\/|$)/,""),l(b)+"/"+m):a(m),u=16*1024*1024,h=Symbol("process"),f=Symbol("file"),d=Symbol("directory"),g=Symbol("symlink"),y=Symbol("hardlink"),_=Symbol("header"),x=Symbol("read"),k=Symbol("lstat"),C=Symbol("onlstat"),T=Symbol("onread"),O=Symbol("onreadlink"),I=Symbol("openfile"),w=Symbol("onopenfile"),v=Symbol("close"),F=Symbol("mode"),q=Symbol("awaitDrain"),P=Symbol("ondrain"),$=Symbol("prefix"),K=Symbol("hadError"),V=kc(),N=cg(),A=ug(),L=rk(),j=V(class extends r{constructor(m,b){if(b=b||{},super(b),typeof m!="string")throw new TypeError("path is required");this.path=a(m),this.portable=!!b.portable,this.myuid=process.getuid&&process.getuid()||0,this.myuser=process.env.USER||"",this.maxReadSize=b.maxReadSize||u,this.linkCache=b.linkCache||new Map,this.statCache=b.statCache||new Map,this.preservePaths=!!b.preservePaths,this.cwd=a(b.cwd||process.cwd()),this.strict=!!b.strict,this.noPax=!!b.noPax,this.noMtime=!!b.noMtime,this.mtime=b.mtime||null,this.prefix=b.prefix?a(b.prefix):null,this.fd=null,this.blockLen=null,this.blockRemain=null,this.buf=null,this.offset=null,this.length=null,this.pos=null,this.remain=null,typeof b.onwarn=="function"&&this.on("warn",b.onwarn);let R=!1;if(!this.preservePaths){let[E,M]=A(this.path);E&&(this.path=M,R=E)}this.win32=!!b.win32||process.platform==="win32",this.win32&&(this.path=N.decode(this.path.replace(/\\/g,"/")),m=m.replace(/\\/g,"/")),this.absolute=a(b.absolute||o.resolve(this.cwd,m)),this.path===""&&(this.path="./"),R&&this.warn("TAR_ENTRY_INFO",`stripping ${R} from absolute path`,{entry:this,path:R+this.path}),this.statCache.has(this.absolute)?this[C](this.statCache.get(this.absolute)):this[k]()}emit(m,...b){return m==="error"&&(this[K]=!0),super.emit(m,...b)}[k](){s.lstat(this.absolute,(m,b)=>{if(m)return this.emit("error",m);this[C](b)})}[C](m){this.statCache.set(this.absolute,m),this.stat=m,m.isFile()||(m.size=0),this.type=p(m),this.emit("stat",m),this[h]()}[h](){switch(this.type){case"File":return this[f]();case"Directory":return this[d]();case"SymbolicLink":return this[g]();default:return this.end()}}[F](m){return L(m,this.type==="Directory",this.portable)}[$](m){return c(m,this.prefix)}[_](){this.type==="Directory"&&this.portable&&(this.noMtime=!0),this.header=new n({path:this[$](this.path),linkpath:this.type==="Link"?this[$](this.linkpath):this.linkpath,mode:this[F](this.stat.mode),uid:this.portable?null:this.stat.uid,gid:this.portable?null:this.stat.gid,size:this.stat.size,mtime:this.noMtime?null:this.mtime||this.stat.mtime,type:this.type,uname:this.portable?null:this.stat.uid===this.myuid?this.myuser:"",atime:this.portable?null:this.stat.atime,ctime:this.portable?null:this.stat.ctime}),this.header.encode()&&!this.noPax&&super.write(new i({atime:this.portable?null:this.header.atime,ctime:this.portable?null:this.header.ctime,gid:this.portable?null:this.header.gid,mtime:this.noMtime?null:this.mtime||this.header.mtime,path:this[$](this.path),linkpath:this.type==="Link"?this[$](this.linkpath):this.linkpath,size:this.header.size,uid:this.portable?null:this.header.uid,uname:this.portable?null:this.header.uname,dev:this.portable?null:this.stat.dev,ino:this.portable?null:this.stat.ino,nlink:this.portable?null:this.stat.nlink}).encode()),super.write(this.header.block)}[d](){this.path.slice(-1)!=="/"&&(this.path+="/"),this.stat.size=0,this[_](),this.end()}[g](){s.readlink(this.absolute,(m,b)=>{if(m)return this.emit("error",m);this[O](b)})}[O](m){this.linkpath=a(m),this[_](),this.end()}[y](m){this.type="Link",this.linkpath=a(o.relative(this.cwd,m)),this.stat.size=0,this[_](),this.end()}[f](){if(this.stat.nlink>1){let m=this.stat.dev+":"+this.stat.ino;if(this.linkCache.has(m)){let b=this.linkCache.get(m);if(b.indexOf(this.cwd)===0)return this[y](b)}this.linkCache.set(m,this.absolute)}if(this[_](),this.stat.size===0)return this.end();this[I]()}[I](){s.open(this.absolute,"r",(m,b)=>{if(m)return this.emit("error",m);this[w](b)})}[w](m){if(this.fd=m,this[K])return this[v]();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[x]()}[x](){let{fd:m,buf:b,offset:R,length:E,pos:M}=this;s.read(m,b,R,E,M,(B,Z)=>{if(B)return this[v](()=>this.emit("error",B));this[T](Z)})}[v](m){s.close(this.fd,m)}[T](m){if(m<=0&&this.remain>0){let R=new Error("encountered unexpected EOF");return R.path=this.absolute,R.syscall="read",R.code="EOF",this[v](()=>this.emit("error",R))}if(m>this.remain){let R=new Error("did not encounter expected EOF");return R.path=this.absolute,R.syscall="read",R.code="EOF",this[v](()=>this.emit("error",R))}if(m===this.remain)for(let R=m;R<this.length&&m<this.blockRemain;R++)this.buf[R+this.offset]=0,m++,this.remain++;let b=this.offset===0&&m===this.buf.length?this.buf:this.buf.slice(this.offset,this.offset+m);this.write(b)?this[P]():this[q](()=>this[P]())}[q](m){this.once("drain",m)}write(m){if(this.blockRemain<m.length){let b=new Error("writing more data than expected");return b.path=this.absolute,this.emit("error",b)}return this.remain-=m.length,this.blockRemain-=m.length,this.pos+=m.length,this.offset+=m.length,super.write(m)}[P](){if(!this.remain)return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),this[v](m=>m?this.emit("error",m):this.end());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[x]()}}),z=class extends j{[k](){this[C](s.lstatSync(this.absolute))}[g](){this[O](s.readlinkSync(this.absolute))}[I](){this[w](s.openSync(this.absolute,"r"))}[x](){let m=!0;try{let{fd:b,buf:R,offset:E,length:M,pos:B}=this,Z=s.readSync(b,R,E,M,B);this[T](Z),m=!1}finally{if(m)try{this[v](()=>{})}catch{}}}[q](m){m()}[v](m){s.closeSync(this.fd),m()}},D=V(class extends r{constructor(m,b){b=b||{},super(b),this.preservePaths=!!b.preservePaths,this.portable=!!b.portable,this.strict=!!b.strict,this.noPax=!!b.noPax,this.noMtime=!!b.noMtime,this.readEntry=m,this.type=m.type,this.type==="Directory"&&this.portable&&(this.noMtime=!0),this.prefix=b.prefix||null,this.path=a(m.path),this.mode=this[F](m.mode),this.uid=this.portable?null:m.uid,this.gid=this.portable?null:m.gid,this.uname=this.portable?null:m.uname,this.gname=this.portable?null:m.gname,this.size=m.size,this.mtime=this.noMtime?null:b.mtime||m.mtime,this.atime=this.portable?null:m.atime,this.ctime=this.portable?null:m.ctime,this.linkpath=a(m.linkpath),typeof b.onwarn=="function"&&this.on("warn",b.onwarn);let R=!1;if(!this.preservePaths){let[E,M]=A(this.path);E&&(this.path=M,R=E)}this.remain=m.size,this.blockRemain=m.startBlockSize,this.header=new n({path:this[$](this.path),linkpath:this.type==="Link"?this[$](this.linkpath):this.linkpath,mode:this.mode,uid:this.portable?null:this.uid,gid:this.portable?null:this.gid,size:this.size,mtime:this.noMtime?null:this.mtime,type:this.type,uname:this.portable?null:this.uname,atime:this.portable?null:this.atime,ctime:this.portable?null:this.ctime}),R&&this.warn("TAR_ENTRY_INFO",`stripping ${R} from absolute path`,{entry:this,path:R+this.path}),this.header.encode()&&!this.noPax&&super.write(new i({atime:this.portable?null:this.atime,ctime:this.portable?null:this.ctime,gid:this.portable?null:this.gid,mtime:this.noMtime?null:this.mtime,path:this[$](this.path),linkpath:this.type==="Link"?this[$](this.linkpath):this.linkpath,size:this.size,uid:this.portable?null:this.uid,uname:this.portable?null:this.uname,dev:this.portable?null:this.readEntry.dev,ino:this.portable?null:this.readEntry.ino,nlink:this.portable?null:this.readEntry.nlink}).encode()),super.write(this.header.block),m.pipe(this)}[$](m){return c(m,this.prefix)}[F](m){return L(m,this.type==="Directory",this.portable)}write(m){let b=m.length;if(b>this.blockRemain)throw new Error("writing more to entry than is appropriate");return this.blockRemain-=b,super.write(m)}end(){return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),super.end()}});j.Sync=z,j.Tar=D;var p=m=>m.isFile()?"File":m.isDirectory()?"Directory":m.isSymbolicLink()?"SymbolicLink":"Unsupported";e.exports=j}),ik=ee((t,e)=>{"use strict";W(),e.exports=function(r){r.prototype[Symbol.iterator]=function*(){for(let i=this.head;i;i=i.next)yield i.value}}}),fg=ee((t,e)=>{"use strict";W(),e.exports=r,r.Node=o,r.create=r;function r(a){var l=this;if(l instanceof r||(l=new r),l.tail=null,l.head=null,l.length=0,a&&typeof a.forEach=="function")a.forEach(function(h){l.push(h)});else if(arguments.length>0)for(var c=0,u=arguments.length;c<u;c++)l.push(arguments[c]);return l}r.prototype.removeNode=function(a){if(a.list!==this)throw new Error("removing node which does not belong to this list");var l=a.next,c=a.prev;return l&&(l.prev=c),c&&(c.next=l),a===this.head&&(this.head=l),a===this.tail&&(this.tail=c),a.list.length--,a.next=null,a.prev=null,a.list=null,l},r.prototype.unshiftNode=function(a){if(a!==this.head){a.list&&a.list.removeNode(a);var l=this.head;a.list=this,a.next=l,l&&(l.prev=a),this.head=a,this.tail||(this.tail=a),this.length++}},r.prototype.pushNode=function(a){if(a!==this.tail){a.list&&a.list.removeNode(a);var l=this.tail;a.list=this,a.prev=l,l&&(l.next=a),this.tail=a,this.head||(this.head=a),this.length++}},r.prototype.push=function(){for(var a=0,l=arguments.length;a<l;a++)n(this,arguments[a]);return this.length},r.prototype.unshift=function(){for(var a=0,l=arguments.length;a<l;a++)s(this,arguments[a]);return this.length},r.prototype.pop=function(){if(this.tail){var a=this.tail.value;return this.tail=this.tail.prev,this.tail?this.tail.next=null:this.head=null,this.length--,a}},r.prototype.shift=function(){if(this.head){var a=this.head.value;return this.head=this.head.next,this.head?this.head.prev=null:this.tail=null,this.length--,a}},r.prototype.forEach=function(a,l){l=l||this;for(var c=this.head,u=0;c!==null;u++)a.call(l,c.value,u,this),c=c.next},r.prototype.forEachReverse=function(a,l){l=l||this;for(var c=this.tail,u=this.length-1;c!==null;u--)a.call(l,c.value,u,this),c=c.prev},r.prototype.get=function(a){for(var l=0,c=this.head;c!==null&&l<a;l++)c=c.next;if(l===a&&c!==null)return c.value},r.prototype.getReverse=function(a){for(var l=0,c=this.tail;c!==null&&l<a;l++)c=c.prev;if(l===a&&c!==null)return c.value},r.prototype.map=function(a,l){l=l||this;for(var c=new r,u=this.head;u!==null;)c.push(a.call(l,u.value,this)),u=u.next;return c},r.prototype.mapReverse=function(a,l){l=l||this;for(var c=new r,u=this.tail;u!==null;)c.push(a.call(l,u.value,this)),u=u.prev;return c},r.prototype.reduce=function(a,l){var c,u=this.head;if(arguments.length>1)c=l;else if(this.head)u=this.head.next,c=this.head.value;else throw new TypeError("Reduce of empty list with no initial value");for(var h=0;u!==null;h++)c=a(c,u.value,h),u=u.next;return c},r.prototype.reduceReverse=function(a,l){var c,u=this.tail;if(arguments.length>1)c=l;else if(this.tail)u=this.tail.prev,c=this.tail.value;else throw new TypeError("Reduce of empty list with no initial value");for(var h=this.length-1;u!==null;h--)c=a(c,u.value,h),u=u.prev;return c},r.prototype.toArray=function(){for(var a=new Array(this.length),l=0,c=this.head;c!==null;l++)a[l]=c.value,c=c.next;return a},r.prototype.toArrayReverse=function(){for(var a=new Array(this.length),l=0,c=this.tail;c!==null;l++)a[l]=c.value,c=c.prev;return a},r.prototype.slice=function(a,l){l=l||this.length,l<0&&(l+=this.length),a=a||0,a<0&&(a+=this.length);var c=new r;if(l<a||l<0)return c;a<0&&(a=0),l>this.length&&(l=this.length);for(var u=0,h=this.head;h!==null&&u<a;u++)h=h.next;for(;h!==null&&u<l;u++,h=h.next)c.push(h.value);return c},r.prototype.sliceReverse=function(a,l){l=l||this.length,l<0&&(l+=this.length),a=a||0,a<0&&(a+=this.length);var c=new r;if(l<a||l<0)return c;a<0&&(a=0),l>this.length&&(l=this.length);for(var u=this.length,h=this.tail;h!==null&&u>l;u--)h=h.prev;for(;h!==null&&u>a;u--,h=h.prev)c.push(h.value);return c},r.prototype.splice=function(a,l,...c){a>this.length&&(a=this.length-1),a<0&&(a=this.length+a);for(var u=0,h=this.head;h!==null&&u<a;u++)h=h.next;for(var f=[],u=0;h&&u<l;u++)f.push(h.value),h=this.removeNode(h);h===null&&(h=this.tail),h!==this.head&&h!==this.tail&&(h=h.prev);for(var u=0;u<c.length;u++)h=i(this,h,c[u]);return f},r.prototype.reverse=function(){for(var a=this.head,l=this.tail,c=a;c!==null;c=c.prev){var u=c.prev;c.prev=c.next,c.next=u}return this.head=l,this.tail=a,this};function i(a,l,c){var u=l===a.head?new o(c,null,l,a):new o(c,l,l.next,a);return u.next===null&&(a.tail=u),u.prev===null&&(a.head=u),a.length++,u}function n(a,l){a.tail=new o(l,a.tail,null,a),a.head||(a.head=a.tail),a.length++}function s(a,l){a.head=new o(l,null,a.head,a),a.tail||(a.tail=a.head),a.length++}function o(a,l,c,u){if(!(this instanceof o))return new o(a,l,c,u);this.list=u,this.value=a,l?(l.next=this,this.prev=l):this.prev=null,c?(c.prev=this,this.next=c):this.next=null}try{ik()(r)}catch{}}),Cc=ee((t,e)=>{"use strict";W();var r=class{constructor(p,m){this.path=p||"./",this.absolute=m,this.entry=null,this.stat=null,this.readdir=null,this.pending=!1,this.ignore=!1,this.piped=!1}},i=Ac(),n=ag(),s=Oc(),o=hg(),a=o.Sync,l=o.Tar,c=fg(),u=Buffer.alloc(1024),h=Symbol("onStat"),f=Symbol("ended"),d=Symbol("queue"),g=Symbol("current"),y=Symbol("process"),_=Symbol("processing"),x=Symbol("processJob"),k=Symbol("jobs"),C=Symbol("jobDone"),T=Symbol("addFSEntry"),O=Symbol("addTarEntry"),I=Symbol("stat"),w=Symbol("readdir"),v=Symbol("onreaddir"),F=Symbol("pipe"),q=Symbol("entry"),P=Symbol("entryOpt"),$=Symbol("writeEntryClass"),K=Symbol("write"),V=Symbol("ondrain"),N=te("fs"),A=te("path"),L=kc(),j=wn(),z=L(class extends i{constructor(p){super(p),p=p||Object.create(null),this.opt=p,this.file=p.file||"",this.cwd=p.cwd||process.cwd(),this.maxReadSize=p.maxReadSize,this.preservePaths=!!p.preservePaths,this.strict=!!p.strict,this.noPax=!!p.noPax,this.prefix=j(p.prefix||""),this.linkCache=p.linkCache||new Map,this.statCache=p.statCache||new Map,this.readdirCache=p.readdirCache||new Map,this[$]=o,typeof p.onwarn=="function"&&this.on("warn",p.onwarn),this.portable=!!p.portable,this.zip=null,p.gzip?(typeof p.gzip!="object"&&(p.gzip={}),this.portable&&(p.gzip.portable=!0),this.zip=new n.Gzip(p.gzip),this.zip.on("data",m=>super.write(m)),this.zip.on("end",m=>super.end()),this.zip.on("drain",m=>this[V]()),this.on("resume",m=>this.zip.resume())):this.on("drain",this[V]),this.noDirRecurse=!!p.noDirRecurse,this.follow=!!p.follow,this.noMtime=!!p.noMtime,this.mtime=p.mtime||null,this.filter=typeof p.filter=="function"?p.filter:m=>!0,this[d]=new c,this[k]=0,this.jobs=+p.jobs||4,this[_]=!1,this[f]=!1}[K](p){return super.write(p)}add(p){return this.write(p),this}end(p){return p&&this.write(p),this[f]=!0,this[y](),this}write(p){if(this[f])throw new Error("write after end");return p instanceof s?this[O](p):this[T](p),this.flowing}[O](p){let m=j(A.resolve(this.cwd,p.path));if(!this.filter(p.path,p))p.resume();else{let b=new r(p.path,m,!1);b.entry=new l(p,this[P](b)),b.entry.on("end",R=>this[C](b)),this[k]+=1,this[d].push(b)}this[y]()}[T](p){let m=j(A.resolve(this.cwd,p));this[d].push(new r(p,m)),this[y]()}[I](p){p.pending=!0,this[k]+=1;let m=this.follow?"stat":"lstat";N[m](p.absolute,(b,R)=>{p.pending=!1,this[k]-=1,b?this.emit("error",b):this[h](p,R)})}[h](p,m){this.statCache.set(p.absolute,m),p.stat=m,this.filter(p.path,m)||(p.ignore=!0),this[y]()}[w](p){p.pending=!0,this[k]+=1,N.readdir(p.absolute,(m,b)=>{if(p.pending=!1,this[k]-=1,m)return this.emit("error",m);this[v](p,b)})}[v](p,m){this.readdirCache.set(p.absolute,m),p.readdir=m,this[y]()}[y](){if(!this[_]){this[_]=!0;for(let p=this[d].head;p!==null&&this[k]<this.jobs;p=p.next)if(this[x](p.value),p.value.ignore){let m=p.next;this[d].removeNode(p),p.next=m}this[_]=!1,this[f]&&!this[d].length&&this[k]===0&&(this.zip?this.zip.end(u):(super.write(u),super.end()))}}get[g](){return this[d]&&this[d].head&&this[d].head.value}[C](p){this[d].shift(),this[k]-=1,this[y]()}[x](p){if(!p.pending){if(p.entry){p===this[g]&&!p.piped&&this[F](p);return}if(p.stat||(this.statCache.has(p.absolute)?this[h](p,this.statCache.get(p.absolute)):this[I](p)),!!p.stat&&!p.ignore&&!(!this.noDirRecurse&&p.stat.isDirectory()&&!p.readdir&&(this.readdirCache.has(p.absolute)?this[v](p,this.readdirCache.get(p.absolute)):this[w](p),!p.readdir))){if(p.entry=this[q](p),!p.entry){p.ignore=!0;return}p===this[g]&&!p.piped&&this[F](p)}}}[P](p){return{onwarn:(m,b,R)=>this.warn(m,b,R),noPax:this.noPax,cwd:this.cwd,absolute:p.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}}[q](p){this[k]+=1;try{return new this[$](p.path,this[P](p)).on("end",()=>this[C](p)).on("error",m=>this.emit("error",m))}catch(m){this.emit("error",m)}}[V](){this[g]&&this[g].entry&&this[g].entry.resume()}[F](p){p.piped=!0,p.readdir&&p.readdir.forEach(R=>{let E=p.path,M=E==="./"?"":E.replace(/\/*$/,"/");this[T](M+R)});let m=p.entry,b=this.zip;b?m.on("data",R=>{b.write(R)||m.pause()}):m.on("data",R=>{super.write(R)||m.pause()})}pause(){return this.zip&&this.zip.pause(),super.pause()}}),D=class extends z{constructor(p){super(p),this[$]=a}pause(){}resume(){}[I](p){let m=this.follow?"statSync":"lstatSync";this[h](p,N[m](p.absolute))}[w](p,m){this[v](p,N.readdirSync(p.absolute))}[F](p){let m=p.entry,b=this.zip;p.readdir&&p.readdir.forEach(R=>{let E=p.path,M=E==="./"?"":E.replace(/\/*$/,"/");this[T](M+R)}),b?m.on("data",R=>{b.write(R)}):m.on("data",R=>{super[K](R)})}};z.Sync=D,e.exports=z}),vn=ee(t=>{"use strict";W();var e=sg(),r=te("events").EventEmitter,i=te("fs"),n=i.writev;if(!n){let p=process.binding("fs"),m=p.FSReqWrap||p.FSReqCallback;n=(b,R,E,M)=>{let B=(U,J)=>M(U,J,R),Z=new m;Z.oncomplete=B,p.writeBuffers(b,R,E,Z)}}var s=Symbol("_autoClose"),o=Symbol("_close"),a=Symbol("_ended"),l=Symbol("_fd"),c=Symbol("_finished"),u=Symbol("_flags"),h=Symbol("_flush"),f=Symbol("_handleChunk"),d=Symbol("_makeBuf"),g=Symbol("_mode"),y=Symbol("_needDrain"),_=Symbol("_onerror"),x=Symbol("_onopen"),k=Symbol("_onread"),C=Symbol("_onwrite"),T=Symbol("_open"),O=Symbol("_path"),I=Symbol("_pos"),w=Symbol("_queue"),v=Symbol("_read"),F=Symbol("_readSize"),q=Symbol("_reading"),P=Symbol("_remain"),$=Symbol("_size"),K=Symbol("_write"),V=Symbol("_writing"),N=Symbol("_defaultFlag"),A=Symbol("_errored"),L=class extends e{constructor(p,m){if(m=m||{},super(m),this.readable=!0,this.writable=!1,typeof p!="string")throw new TypeError("path must be a string");this[A]=!1,this[l]=typeof m.fd=="number"?m.fd:null,this[O]=p,this[F]=m.readSize||16*1024*1024,this[q]=!1,this[$]=typeof m.size=="number"?m.size:1/0,this[P]=this[$],this[s]=typeof m.autoClose=="boolean"?m.autoClose:!0,typeof this[l]=="number"?this[v]():this[T]()}get fd(){return this[l]}get path(){return this[O]}write(){throw new TypeError("this is a readable stream")}end(){throw new TypeError("this is a readable stream")}[T](){i.open(this[O],"r",(p,m)=>this[x](p,m))}[x](p,m){p?this[_](p):(this[l]=m,this.emit("open",m),this[v]())}[d](){return Buffer.allocUnsafe(Math.min(this[F],this[P]))}[v](){if(!this[q]){this[q]=!0;let p=this[d]();if(p.length===0)return process.nextTick(()=>this[k](null,0,p));i.read(this[l],p,0,p.length,null,(m,b,R)=>this[k](m,b,R))}}[k](p,m,b){this[q]=!1,p?this[_](p):this[f](m,b)&&this[v]()}[o](){if(this[s]&&typeof this[l]=="number"){let p=this[l];this[l]=null,i.close(p,m=>m?this.emit("error",m):this.emit("close"))}}[_](p){this[q]=!0,this[o](),this.emit("error",p)}[f](p,m){let b=!1;return this[P]-=p,p>0&&(b=super.write(p<m.length?m.slice(0,p):m)),(p===0||this[P]<=0)&&(b=!1,this[o](),super.end()),b}emit(p,m){switch(p){case"prefinish":case"finish":break;case"drain":typeof this[l]=="number"&&this[v]();break;case"error":return this[A]?void 0:(this[A]=!0,super.emit(p,m));default:return super.emit(p,m)}}},j=class extends L{[T](){let p=!0;try{this[x](null,i.openSync(this[O],"r")),p=!1}finally{p&&this[o]()}}[v](){let p=!0;try{if(!this[q]){this[q]=!0;do{let m=this[d](),b=m.length===0?0:i.readSync(this[l],m,0,m.length,null);if(!this[f](b,m))break}while(!0);this[q]=!1}p=!1}finally{p&&this[o]()}}[o](){if(this[s]&&typeof this[l]=="number"){let p=this[l];this[l]=null,i.closeSync(p),this.emit("close")}}},z=class extends r{constructor(p,m){m=m||{},super(m),this.readable=!1,this.writable=!0,this[A]=!1,this[V]=!1,this[a]=!1,this[y]=!1,this[w]=[],this[O]=p,this[l]=typeof m.fd=="number"?m.fd:null,this[g]=m.mode===void 0?438:m.mode,this[I]=typeof m.start=="number"?m.start:null,this[s]=typeof m.autoClose=="boolean"?m.autoClose:!0;let b=this[I]!==null?"r+":"w";this[N]=m.flags===void 0,this[u]=this[N]?b:m.flags,this[l]===null&&this[T]()}emit(p,m){if(p==="error"){if(this[A])return;this[A]=!0}return super.emit(p,m)}get fd(){return this[l]}get path(){return this[O]}[_](p){this[o](),this[V]=!0,this.emit("error",p)}[T](){i.open(this[O],this[u],this[g],(p,m)=>this[x](p,m))}[x](p,m){this[N]&&this[u]==="r+"&&p&&p.code==="ENOENT"?(this[u]="w",this[T]()):p?this[_](p):(this[l]=m,this.emit("open",m),this[h]())}end(p,m){return p&&this.write(p,m),this[a]=!0,!this[V]&&!this[w].length&&typeof this[l]=="number"&&this[C](null,0),this}write(p,m){return typeof p=="string"&&(p=Buffer.from(p,m)),this[a]?(this.emit("error",new Error("write() after end()")),!1):this[l]===null||this[V]||this[w].length?(this[w].push(p),this[y]=!0,!1):(this[V]=!0,this[K](p),!0)}[K](p){i.write(this[l],p,0,p.length,this[I],(m,b)=>this[C](m,b))}[C](p,m){p?this[_](p):(this[I]!==null&&(this[I]+=m),this[w].length?this[h]():(this[V]=!1,this[a]&&!this[c]?(this[c]=!0,this[o](),this.emit("finish")):this[y]&&(this[y]=!1,this.emit("drain"))))}[h](){if(this[w].length===0)this[a]&&this[C](null,0);else if(this[w].length===1)this[K](this[w].pop());else{let p=this[w];this[w]=[],n(this[l],p,this[I],(m,b)=>this[C](m,b))}}[o](){if(this[s]&&typeof this[l]=="number"){let p=this[l];this[l]=null,i.close(p,m=>m?this.emit("error",m):this.emit("close"))}}},D=class extends z{[T](){let p;if(this[N]&&this[u]==="r+")try{p=i.openSync(this[O],this[u],this[g])}catch(m){if(m.code==="ENOENT")return this[u]="w",this[T]();throw m}else p=i.openSync(this[O],this[u],this[g]);this[x](null,p)}[o](){if(this[s]&&typeof this[l]=="number"){let p=this[l];this[l]=null,i.closeSync(p),this.emit("close")}}[K](p){let m=!0;try{this[C](null,i.writeSync(this[l],p,0,p.length,this[I])),m=!1}finally{if(m)try{this[o]()}catch{}}}};t.ReadStream=L,t.ReadStreamSync=j,t.WriteStream=z,t.WriteStreamSync=D}),Lc=ee((t,e)=>{"use strict";W();var r=kc(),i=Sn(),n=te("events"),s=fg(),o=1024*1024,a=Oc(),l=Tc(),c=ag(),{nextTick:u}=te("process"),h=Buffer.from([31,139]),f=Symbol("state"),d=Symbol("writeEntry"),g=Symbol("readEntry"),y=Symbol("nextEntry"),_=Symbol("processEntry"),x=Symbol("extendedHeader"),k=Symbol("globalExtendedHeader"),C=Symbol("meta"),T=Symbol("emitMeta"),O=Symbol("buffer"),I=Symbol("queue"),w=Symbol("ended"),v=Symbol("emittedEnd"),F=Symbol("emit"),q=Symbol("unzip"),P=Symbol("consumeChunk"),$=Symbol("consumeChunkSub"),K=Symbol("consumeBody"),V=Symbol("consumeMeta"),N=Symbol("consumeHeader"),A=Symbol("consuming"),L=Symbol("bufferConcat"),j=Symbol("maybeEnd"),z=Symbol("writing"),D=Symbol("aborted"),p=Symbol("onDone"),m=Symbol("sawValidEntry"),b=Symbol("sawNullBlock"),R=Symbol("sawEOF"),E=Symbol("closeStream"),M=B=>!0;e.exports=r(class extends n{constructor(B){B=B||{},super(B),this.file=B.file||"",this[m]=null,this.on(p,Z=>{(this[f]==="begin"||this[m]===!1)&&this.warn("TAR_BAD_ARCHIVE","Unrecognized archive format")}),B.ondone?this.on(p,B.ondone):this.on(p,Z=>{this.emit("prefinish"),this.emit("finish"),this.emit("end")}),this.strict=!!B.strict,this.maxMetaEntrySize=B.maxMetaEntrySize||o,this.filter=typeof B.filter=="function"?B.filter:M,this.writable=!0,this.readable=!1,this[I]=new s,this[O]=null,this[g]=null,this[d]=null,this[f]="begin",this[C]="",this[x]=null,this[k]=null,this[w]=!1,this[q]=null,this[D]=!1,this[b]=!1,this[R]=!1,this.on("end",()=>this[E]()),typeof B.onwarn=="function"&&this.on("warn",B.onwarn),typeof B.onentry=="function"&&this.on("entry",B.onentry)}[N](B,Z){this[m]===null&&(this[m]=!1);let U;try{U=new i(B,Z,this[x],this[k])}catch(J){return this.warn("TAR_ENTRY_INVALID",J)}if(U.nullBlock)this[b]?(this[R]=!0,this[f]==="begin"&&(this[f]="header"),this[F]("eof")):(this[b]=!0,this[F]("nullBlock"));else if(this[b]=!1,!U.cksumValid)this.warn("TAR_ENTRY_INVALID","checksum failure",{header:U});else if(!U.path)this.warn("TAR_ENTRY_INVALID","path is required",{header:U});else{let J=U.type;if(/^(Symbolic)?Link$/.test(J)&&!U.linkpath)this.warn("TAR_ENTRY_INVALID","linkpath required",{header:U});else if(!/^(Symbolic)?Link$/.test(J)&&U.linkpath)this.warn("TAR_ENTRY_INVALID","linkpath forbidden",{header:U});else{let G=this[d]=new a(U,this[x],this[k]);if(!this[m])if(G.remain){let re=()=>{G.invalid||(this[m]=!0)};G.on("end",re)}else this[m]=!0;G.meta?G.size>this.maxMetaEntrySize?(G.ignore=!0,this[F]("ignoredEntry",G),this[f]="ignore",G.resume()):G.size>0&&(this[C]="",G.on("data",re=>this[C]+=re),this[f]="meta"):(this[x]=null,G.ignore=G.ignore||!this.filter(G.path,G),G.ignore?(this[F]("ignoredEntry",G),this[f]=G.remain?"ignore":"header",G.resume()):(G.remain?this[f]="body":(this[f]="header",G.end()),this[g]?this[I].push(G):(this[I].push(G),this[y]())))}}}[E](){u(()=>this.emit("close"))}[_](B){let Z=!0;return B?Array.isArray(B)?this.emit.apply(this,B):(this[g]=B,this.emit("entry",B),B.emittedEnd||(B.on("end",U=>this[y]()),Z=!1)):(this[g]=null,Z=!1),Z}[y](){do;while(this[_](this[I].shift()));if(!this[I].length){let B=this[g];!B||B.flowing||B.size===B.remain?this[z]||this.emit("drain"):B.once("drain",Z=>this.emit("drain"))}}[K](B,Z){let U=this[d],J=U.blockRemain,G=J>=B.length&&Z===0?B:B.slice(Z,Z+J);return U.write(G),U.blockRemain||(this[f]="header",this[d]=null,U.end()),G.length}[V](B,Z){let U=this[d],J=this[K](B,Z);return this[d]||this[T](U),J}[F](B,Z,U){!this[I].length&&!this[g]?this.emit(B,Z,U):this[I].push([B,Z,U])}[T](B){switch(this[F]("meta",this[C]),B.type){case"ExtendedHeader":case"OldExtendedHeader":this[x]=l.parse(this[C],this[x],!1);break;case"GlobalExtendedHeader":this[k]=l.parse(this[C],this[k],!0);break;case"NextFileHasLongPath":case"OldGnuLongPath":this[x]=this[x]||Object.create(null),this[x].path=this[C].replace(/\0.*/,"");break;case"NextFileHasLongLinkpath":this[x]=this[x]||Object.create(null),this[x].linkpath=this[C].replace(/\0.*/,"");break;default:throw new Error("unknown meta: "+B.type)}}abort(B){this[D]=!0,this.emit("abort",B),this.warn("TAR_ABORT",B,{recoverable:!1})}write(B){if(this[D])return;if(this[q]===null&&B){if(this[O]&&(B=Buffer.concat([this[O],B]),this[O]=null),B.length<h.length)return this[O]=B,!0;for(let U=0;this[q]===null&&U<h.length;U++)B[U]!==h[U]&&(this[q]=!1);if(this[q]===null){let U=this[w];this[w]=!1,this[q]=new c.Unzip,this[q].on("data",G=>this[P](G)),this[q].on("error",G=>this.abort(G)),this[q].on("end",G=>{this[w]=!0,this[P]()}),this[z]=!0;let J=this[q][U?"end":"write"](B);return this[z]=!1,J}}this[z]=!0,this[q]?this[q].write(B):this[P](B),this[z]=!1;let Z=this[I].length?!1:this[g]?this[g].flowing:!0;return!Z&&!this[I].length&&this[g].once("drain",U=>this.emit("drain")),Z}[L](B){B&&!this[D]&&(this[O]=this[O]?Buffer.concat([this[O],B]):B)}[j](){if(this[w]&&!this[v]&&!this[D]&&!this[A]){this[v]=!0;let B=this[d];if(B&&B.blockRemain){let Z=this[O]?this[O].length:0;this.warn("TAR_BAD_ARCHIVE",`Truncated input (needed ${B.blockRemain} more bytes, only ${Z} available)`,{entry:B}),this[O]&&B.write(this[O]),B.end()}this[F](p)}}[P](B){if(this[A])this[L](B);else if(!B&&!this[O])this[j]();else{if(this[A]=!0,this[O]){this[L](B);let Z=this[O];this[O]=null,this[$](Z)}else this[$](B);for(;this[O]&&this[O].length>=512&&!this[D]&&!this[R];){let Z=this[O];this[O]=null,this[$](Z)}this[A]=!1}(!this[O]||this[w])&&this[j]()}[$](B){let Z=0,U=B.length;for(;Z+512<=U&&!this[D]&&!this[R];)switch(this[f]){case"begin":case"header":this[N](B,Z),Z+=512;break;case"ignore":case"body":Z+=this[K](B,Z);break;case"meta":Z+=this[V](B,Z);break;default:throw new Error("invalid state: "+this[f])}Z<U&&(this[O]?this[O]=Buffer.concat([B.slice(Z),this[O]]):this[O]=B.slice(Z))}end(B){this[D]||(this[q]?this[q].end(B):(this[w]=!0,this.write(B)))}})}),Pc=ee((t,e)=>{"use strict";W();var r=bn(),i=Lc(),n=te("fs"),s=vn(),o=te("path"),a=En();e.exports=(d,g,y)=>{typeof d=="function"?(y=d,g=null,d={}):Array.isArray(d)&&(g=d,d={}),typeof g=="function"&&(y=g,g=null),g?g=Array.from(g):g=[];let _=r(d);if(_.sync&&typeof y=="function")throw new TypeError("callback not supported for sync tar functions");if(!_.file&&typeof y=="function")throw new TypeError("callback only supported with file option");return g.length&&c(_,g),_.noResume||l(_),_.file&&_.sync?u(_):_.file?h(_,y):f(_)};var l=d=>{let g=d.onentry;d.onentry=g?y=>{g(y),y.resume()}:y=>y.resume()},c=(d,g)=>{let y=new Map(g.map(k=>[a(k),!0])),_=d.filter,x=(k,C)=>{let T=C||o.parse(k).root||".",O=k===T?!1:y.has(k)?y.get(k):x(o.dirname(k),T);return y.set(k,O),O};d.filter=_?(k,C)=>_(k,C)&&x(a(k)):k=>x(a(k))},u=d=>{let g=f(d),y=d.file,_=!0,x;try{let k=n.statSync(y),C=d.maxReadSize||16*1024*1024;if(k.size<C)g.end(n.readFileSync(y));else{let T=0,O=Buffer.allocUnsafe(C);for(x=n.openSync(y,"r");T<k.size;){let I=n.readSync(x,O,0,C,T);T+=I,g.write(O.slice(0,I))}g.end()}_=!1}finally{if(_&&x)try{n.closeSync(x)}catch{}}},h=(d,g)=>{let y=new i(d),_=d.maxReadSize||16*1024*1024,x=d.file,k=new Promise((C,T)=>{y.on("error",T),y.on("end",C),n.stat(x,(O,I)=>{if(O)T(O);else{let w=new s.ReadStream(x,{readSize:_,size:I.size});w.on("error",T),w.pipe(y)}})});return g?k.then(g,g):k},f=d=>new i(d)}),nk=ee((t,e)=>{"use strict";W();var r=bn(),i=Cc(),n=vn(),s=Pc(),o=te("path");e.exports=(d,g,y)=>{if(typeof g=="function"&&(y=g),Array.isArray(d)&&(g=d,d={}),!g||!Array.isArray(g)||!g.length)throw new TypeError("no files or directories specified");g=Array.from(g);let _=r(d);if(_.sync&&typeof y=="function")throw new TypeError("callback not supported for sync tar functions");if(!_.file&&typeof y=="function")throw new TypeError("callback only supported with file option");return _.file&&_.sync?a(_,g):_.file?l(_,g,y):_.sync?h(_,g):f(_,g)};var a=(d,g)=>{let y=new i.Sync(d),_=new n.WriteStreamSync(d.file,{mode:d.mode||438});y.pipe(_),c(y,g)},l=(d,g,y)=>{let _=new i(d),x=new n.WriteStream(d.file,{mode:d.mode||438});_.pipe(x);let k=new Promise((C,T)=>{x.on("error",T),x.on("close",C),_.on("error",T)});return u(_,g),y?k.then(y,y):k},c=(d,g)=>{g.forEach(y=>{y.charAt(0)==="@"?s({file:o.resolve(d.cwd,y.slice(1)),sync:!0,noResume:!0,onentry:_=>d.add(_)}):d.add(y)}),d.end()},u=(d,g)=>{for(;g.length;){let y=g.shift();if(y.charAt(0)==="@")return s({file:o.resolve(d.cwd,y.slice(1)),noResume:!0,onentry:_=>d.add(_)}).then(_=>u(d,g));d.add(y)}d.end()},h=(d,g)=>{let y=new i.Sync(d);return c(y,g),y},f=(d,g)=>{let y=new i(d);return u(y,g),y}}),pg=ee((t,e)=>{"use strict";W();var r=bn(),i=Cc(),n=te("fs"),s=vn(),o=Pc(),a=te("path"),l=Sn();e.exports=(g,y,_)=>{let x=r(g);if(!x.file)throw new TypeError("file is required");if(x.gzip)throw new TypeError("cannot append to compressed archives");if(!y||!Array.isArray(y)||!y.length)throw new TypeError("no files or directories specified");return y=Array.from(y),x.sync?c(x,y):h(x,y,_)};var c=(g,y)=>{let _=new i.Sync(g),x=!0,k,C;try{try{k=n.openSync(g.file,"r+")}catch(I){if(I.code==="ENOENT")k=n.openSync(g.file,"w+");else throw I}let T=n.fstatSync(k),O=Buffer.alloc(512);e:for(C=0;C<T.size;C+=512){for(let v=0,F=0;v<512;v+=F){if(F=n.readSync(k,O,v,O.length-v,C+v),C===0&&O[0]===31&&O[1]===139)throw new Error("cannot append to compressed archives");if(!F)break e}let I=new l(O);if(!I.cksumValid)break;let w=512*Math.ceil(I.size/512);if(C+w+512>T.size)break;C+=w,g.mtimeCache&&g.mtimeCache.set(I.path,I.mtime)}x=!1,u(g,_,C,k,y)}finally{if(x)try{n.closeSync(k)}catch{}}},u=(g,y,_,x,k)=>{let C=new s.WriteStreamSync(g.file,{fd:x,start:_});y.pipe(C),f(y,k)},h=(g,y,_)=>{y=Array.from(y);let x=new i(g),k=(T,O,I)=>{let w=($,K)=>{$?n.close(T,V=>I($)):I(null,K)},v=0;if(O===0)return w(null,0);let F=0,q=Buffer.alloc(512),P=($,K)=>{if($)return w($);if(F+=K,F<512&&K)return n.read(T,q,F,q.length-F,v+F,P);if(v===0&&q[0]===31&&q[1]===139)return w(new Error("cannot append to compressed archives"));if(F<512)return w(null,v);let V=new l(q);if(!V.cksumValid)return w(null,v);let N=512*Math.ceil(V.size/512);if(v+N+512>O||(v+=N+512,v>=O))return w(null,v);g.mtimeCache&&g.mtimeCache.set(V.path,V.mtime),F=0,n.read(T,q,0,512,v,P)};n.read(T,q,0,512,v,P)},C=new Promise((T,O)=>{x.on("error",O);let I="r+",w=(v,F)=>{if(v&&v.code==="ENOENT"&&I==="r+")return I="w+",n.open(g.file,I,w);if(v)return O(v);n.fstat(F,(q,P)=>{if(q)return n.close(F,()=>O(q));k(F,P.size,($,K)=>{if($)return O($);let V=new s.WriteStream(g.file,{fd:F,start:K});x.pipe(V),V.on("error",O),V.on("close",T),d(x,y)})})};n.open(g.file,I,w)});return _?C.then(_,_):C},f=(g,y)=>{y.forEach(_=>{_.charAt(0)==="@"?o({file:a.resolve(g.cwd,_.slice(1)),sync:!0,noResume:!0,onentry:x=>g.add(x)}):g.add(_)}),g.end()},d=(g,y)=>{for(;y.length;){let _=y.shift();if(_.charAt(0)==="@")return o({file:a.resolve(g.cwd,_.slice(1)),noResume:!0,onentry:x=>g.add(x)}).then(x=>d(g,y));g.add(_)}g.end()}}),sk=ee((t,e)=>{"use strict";W();var r=bn(),i=pg();e.exports=(s,o,a)=>{let l=r(s);if(!l.file)throw new TypeError("file is required");if(l.gzip)throw new TypeError("cannot append to compressed archives");if(!o||!Array.isArray(o)||!o.length)throw new TypeError("no files or directories specified");return o=Array.from(o),n(l),i(l,o,a)};var n=s=>{let o=s.filter;s.mtimeCache||(s.mtimeCache=new Map),s.filter=o?(a,l)=>o(a,l)&&!(s.mtimeCache.get(a)>l.mtime):(a,l)=>!(s.mtimeCache.get(a)>l.mtime)}}),ok=ee((t,e)=>{W();var{promisify:r}=te("util"),i=te("fs"),n=s=>{if(!s)s={mode:511,fs:i};else if(typeof s=="object")s={mode:511,fs:i,...s};else if(typeof s=="number")s={mode:s,fs:i};else if(typeof s=="string")s={mode:parseInt(s,8),fs:i};else throw new TypeError("invalid options argument");return s.mkdir=s.mkdir||s.fs.mkdir||i.mkdir,s.mkdirAsync=r(s.mkdir),s.stat=s.stat||s.fs.stat||i.stat,s.statAsync=r(s.stat),s.statSync=s.statSync||s.fs.statSync||i.statSync,s.mkdirSync=s.mkdirSync||s.fs.mkdirSync||i.mkdirSync,s};e.exports=n}),ak=ee((t,e)=>{W();var r=process.env.__TESTING_MKDIRP_PLATFORM__||process.platform,{resolve:i,parse:n}=te("path"),s=o=>{if(/\0/.test(o))throw Object.assign(new TypeError("path must be a string without null bytes"),{path:o,code:"ERR_INVALID_ARG_VALUE"});if(o=i(o),r==="win32"){let a=/[*|"<>?:]/,{root:l}=n(o);if(a.test(o.substr(l.length)))throw Object.assign(new Error("Illegal characters in path."),{path:o,code:"EINVAL"})}return o};e.exports=s}),lk=ee((t,e)=>{W();var{dirname:r}=te("path"),i=(s,o,a=void 0)=>a===o?Promise.resolve():s.statAsync(o).then(l=>l.isDirectory()?a:void 0,l=>l.code==="ENOENT"?i(s,r(o),o):void 0),n=(s,o,a=void 0)=>{if(a!==o)try{return s.statSync(o).isDirectory()?a:void 0}catch(l){return l.code==="ENOENT"?n(s,r(o),o):void 0}};e.exports={findMade:i,findMadeSync:n}}),dg=ee((t,e)=>{W();var{dirname:r}=te("path"),i=(s,o,a)=>{o.recursive=!1;let l=r(s);return l===s?o.mkdirAsync(s,o).catch(c=>{if(c.code!=="EISDIR")throw c}):o.mkdirAsync(s,o).then(()=>a||s,c=>{if(c.code==="ENOENT")return i(l,o).then(u=>i(s,o,u));if(c.code!=="EEXIST"&&c.code!=="EROFS")throw c;return o.statAsync(s).then(u=>{if(u.isDirectory())return a;throw c},()=>{throw c})})},n=(s,o,a)=>{let l=r(s);if(o.recursive=!1,l===s)try{return o.mkdirSync(s,o)}catch(c){if(c.code!=="EISDIR")throw c;return}try{return o.mkdirSync(s,o),a||s}catch(c){if(c.code==="ENOENT")return n(s,o,n(l,o,a));if(c.code!=="EEXIST"&&c.code!=="EROFS")throw c;try{if(!o.statSync(s).isDirectory())throw c}catch{throw c}}};e.exports={mkdirpManual:i,mkdirpManualSync:n}}),ck=ee((t,e)=>{W();var{dirname:r}=te("path"),{findMade:i,findMadeSync:n}=lk(),{mkdirpManual:s,mkdirpManualSync:o}=dg(),a=(c,u)=>(u.recursive=!0,r(c)===c?u.mkdirAsync(c,u):i(u,c).then(h=>u.mkdirAsync(c,u).then(()=>h).catch(f=>{if(f.code==="ENOENT")return s(c,u);throw f}))),l=(c,u)=>{if(u.recursive=!0,r(c)===c)return u.mkdirSync(c,u);let h=n(u,c);try{return u.mkdirSync(c,u),h}catch(f){if(f.code==="ENOENT")return o(c,u);throw f}};e.exports={mkdirpNative:a,mkdirpNativeSync:l}}),uk=ee((t,e)=>{W();var r=te("fs"),i=process.env.__TESTING_MKDIRP_NODE_VERSION__||process.version,n=i.replace(/^v/,"").split("."),s=+n[0]>10||+n[0]==10&&+n[1]>=12,o=s?l=>l.mkdir===r.mkdir:()=>!1,a=s?l=>l.mkdirSync===r.mkdirSync:()=>!1;e.exports={useNative:o,useNativeSync:a}}),hk=ee((t,e)=>{W();var r=ok(),i=ak(),{mkdirpNative:n,mkdirpNativeSync:s}=ck(),{mkdirpManual:o,mkdirpManualSync:a}=dg(),{useNative:l,useNativeSync:c}=uk(),u=(f,d)=>(f=i(f),d=r(d),l(d)?n(f,d):o(f,d)),h=(f,d)=>(f=i(f),d=r(d),c(d)?s(f,d):a(f,d));u.sync=h,u.native=(f,d)=>n(i(f),r(d)),u.manual=(f,d)=>o(i(f),r(d)),u.nativeSync=(f,d)=>s(i(f),r(d)),u.manualSync=(f,d)=>a(i(f),r(d)),e.exports=u}),fk=ee((t,e)=>{"use strict";W();var r=te("fs"),i=te("path"),n=r.lchown?"lchown":"chown",s=r.lchownSync?"lchownSync":"chownSync",o=r.lchown&&!process.version.match(/v1[1-9]+\./)&&!process.version.match(/v10\.[6-9]/),a=(C,T,O)=>{try{return r[s](C,T,O)}catch(I){if(I.code!=="ENOENT")throw I}},l=(C,T,O)=>{try{return r.chownSync(C,T,O)}catch(I){if(I.code!=="ENOENT")throw I}},c=o?(C,T,O,I)=>w=>{!w||w.code!=="EISDIR"?I(w):r.chown(C,T,O,I)}:(C,T,O,I)=>I,u=o?(C,T,O)=>{try{return a(C,T,O)}catch(I){if(I.code!=="EISDIR")throw I;l(C,T,O)}}:(C,T,O)=>a(C,T,O),h=process.version,f=(C,T,O)=>r.readdir(C,T,O),d=(C,T)=>r.readdirSync(C,T);/^v4\./.test(h)&&(f=(C,T,O)=>r.readdir(C,O));var g=(C,T,O,I)=>{r[n](C,T,O,c(C,T,O,w=>{I(w&&w.code!=="ENOENT"?w:null)}))},y=(C,T,O,I,w)=>{if(typeof T=="string")return r.lstat(i.resolve(C,T),(v,F)=>{if(v)return w(v.code!=="ENOENT"?v:null);F.name=T,y(C,F,O,I,w)});if(T.isDirectory())_(i.resolve(C,T.name),O,I,v=>{if(v)return w(v);let F=i.resolve(C,T.name);g(F,O,I,w)});else{let v=i.resolve(C,T.name);g(v,O,I,w)}},_=(C,T,O,I)=>{f(C,{withFileTypes:!0},(w,v)=>{if(w){if(w.code==="ENOENT")return I();if(w.code!=="ENOTDIR"&&w.code!=="ENOTSUP")return I(w)}if(w||!v.length)return g(C,T,O,I);let F=v.length,q=null,P=$=>{if(!q){if($)return I(q=$);if(--F===0)return g(C,T,O,I)}};v.forEach($=>y(C,$,T,O,P))})},x=(C,T,O,I)=>{if(typeof T=="string")try{let w=r.lstatSync(i.resolve(C,T));w.name=T,T=w}catch(w){if(w.code==="ENOENT")return;throw w}T.isDirectory()&&k(i.resolve(C,T.name),O,I),u(i.resolve(C,T.name),O,I)},k=(C,T,O)=>{let I;try{I=d(C,{withFileTypes:!0})}catch(w){if(w.code==="ENOENT")return;if(w.code==="ENOTDIR"||w.code==="ENOTSUP")return u(C,T,O);throw w}return I&&I.length&&I.forEach(w=>x(C,w,T,O)),u(C,T,O)};e.exports=_,_.sync=k}),pk=ee((t,e)=>{"use strict";W();var r=hk(),i=te("fs"),n=te("path"),s=fk(),o=wn(),a=class extends Error{constructor(y,_){super("Cannot extract through symbolic link"),this.path=_,this.symlink=y}get name(){return"SylinkError"}},l=class extends Error{constructor(y,_){super(_+": Cannot cd into '"+y+"'"),this.path=y,this.code=_}get name(){return"CwdError"}},c=(y,_)=>y.get(o(_)),u=(y,_,x)=>y.set(o(_),x),h=(y,_)=>{i.stat(y,(x,k)=>{(x||!k.isDirectory())&&(x=new l(y,x&&x.code||"ENOTDIR")),_(x)})};e.exports=(y,_,x)=>{y=o(y);let k=_.umask,C=_.mode|448,T=(C&k)!==0,O=_.uid,I=_.gid,w=typeof O=="number"&&typeof I=="number"&&(O!==_.processUid||I!==_.processGid),v=_.preserve,F=_.unlink,q=_.cache,P=o(_.cwd),$=(V,N)=>{V?x(V):(u(q,y,!0),N&&w?s(N,O,I,A=>$(A)):T?i.chmod(y,C,x):x())};if(q&&c(q,y)===!0)return $();if(y===P)return h(y,$);if(v)return r(y,{mode:C}).then(V=>$(null,V),$);let K=o(n.relative(P,y)).split("/");f(P,K,C,q,F,P,null,$)};var f=(y,_,x,k,C,T,O,I)=>{if(!_.length)return I(null,O);let w=_.shift(),v=o(n.resolve(y+"/"+w));if(c(k,v))return f(v,_,x,k,C,T,O,I);i.mkdir(v,x,d(v,_,x,k,C,T,O,I))},d=(y,_,x,k,C,T,O,I)=>w=>{w?i.lstat(y,(v,F)=>{if(v)v.path=v.path&&o(v.path),I(v);else if(F.isDirectory())f(y,_,x,k,C,T,O,I);else if(C)i.unlink(y,q=>{if(q)return I(q);i.mkdir(y,x,d(y,_,x,k,C,T,O,I))});else{if(F.isSymbolicLink())return I(new a(y,y+"/"+_.join("/")));I(w)}}):(O=O||y,f(y,_,x,k,C,T,O,I))},g=y=>{let _=!1,x="ENOTDIR";try{_=i.statSync(y).isDirectory()}catch(k){x=k.code}finally{if(!_)throw new l(y,x)}};e.exports.sync=(y,_)=>{y=o(y);let x=_.umask,k=_.mode|448,C=(k&x)!==0,T=_.uid,O=_.gid,I=typeof T=="number"&&typeof O=="number"&&(T!==_.processUid||O!==_.processGid),w=_.preserve,v=_.unlink,F=_.cache,q=o(_.cwd),P=V=>{u(F,y,!0),V&&I&&s.sync(V,T,O),C&&i.chmodSync(y,k)};if(F&&c(F,y)===!0)return P();if(y===q)return g(q),P();if(w)return P(r.sync(y,k));let $=o(n.relative(q,y)).split("/"),K=null;for(let V=$.shift(),N=q;V&&(N+="/"+V);V=$.shift())if(N=o(n.resolve(N)),!c(F,N))try{i.mkdirSync(N,k),K=K||N,u(F,N,!0)}catch{let A=i.lstatSync(N);if(A.isDirectory()){u(F,N,!0);continue}else if(v){i.unlinkSync(N),i.mkdirSync(N,k),K=K||N,u(F,N,!0);continue}else if(A.isSymbolicLink())return new a(N,N+"/"+$.join("/"))}return P(K)}}),mg=ee((t,e)=>{W();var r=Object.create(null),{hasOwnProperty:i}=Object.prototype;e.exports=n=>(i.call(r,n)||(r[n]=n.normalize("NFKD")),r[n])}),dk=ee((t,e)=>{W();var r=te("assert"),i=mg(),n=En(),{join:s}=te("path"),o=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,a=o==="win32";e.exports=()=>{let l=new Map,c=new Map,u=_=>_.split("/").slice(0,-1).reduce((x,k)=>(x.length&&(k=s(x[x.length-1],k)),x.push(k||"/"),x),[]),h=new Set,f=_=>{let x=c.get(_);if(!x)throw new Error("function does not have any path reservations");return{paths:x.paths.map(k=>l.get(k)),dirs:[...x.dirs].map(k=>l.get(k))}},d=_=>{let{paths:x,dirs:k}=f(_);return x.every(C=>C[0]===_)&&k.every(C=>C[0]instanceof Set&&C[0].has(_))},g=_=>h.has(_)||!d(_)?!1:(h.add(_),_(()=>y(_)),!0),y=_=>{if(!h.has(_))return!1;let{paths:x,dirs:k}=c.get(_),C=new Set;return x.forEach(T=>{let O=l.get(T);r.equal(O[0],_),O.length===1?l.delete(T):(O.shift(),typeof O[0]=="function"?C.add(O[0]):O[0].forEach(I=>C.add(I)))}),k.forEach(T=>{let O=l.get(T);r(O[0]instanceof Set),O[0].size===1&&O.length===1?l.delete(T):O[0].size===1?(O.shift(),C.add(O[0])):O[0].delete(_)}),h.delete(_),C.forEach(T=>g(T)),!0};return{check:d,reserve:(_,x)=>{_=a?["win32 parallelization disabled"]:_.map(C=>i(n(s(C))).toLowerCase());let k=new Set(_.map(C=>u(C)).reduce((C,T)=>C.concat(T)));return c.set(x,{dirs:k,paths:_}),_.forEach(C=>{let T=l.get(C);T?T.push(x):l.set(C,[x])}),k.forEach(C=>{let T=l.get(C);T?T[T.length-1]instanceof Set?T[T.length-1].add(x):T.push(new Set([x])):l.set(C,[new Set([x])])}),g(x)}}}}),mk=ee((t,e)=>{W();var r=process.env.__FAKE_PLATFORM__||process.platform,i=r==="win32",n=global.__FAKE_TESTING_FS__||te("fs"),{O_CREAT:s,O_TRUNC:o,O_WRONLY:a,UV_FS_O_FILEMAP:l=0}=n.constants,c=i&&!!l,u=512*1024,h=l|o|s|a;e.exports=c?f=>f<u?h:"w":()=>"w"}),yg=ee((t,e)=>{"use strict";W();var r=te("assert"),i=Lc(),n=te("fs"),s=vn(),o=te("path"),a=pk(),l=cg(),c=dk(),u=ug(),h=wn(),f=En(),d=mg(),g=Symbol("onEntry"),y=Symbol("checkFs"),_=Symbol("checkFs2"),x=Symbol("pruneCache"),k=Symbol("isReusable"),C=Symbol("makeFs"),T=Symbol("file"),O=Symbol("directory"),I=Symbol("link"),w=Symbol("symlink"),v=Symbol("hardlink"),F=Symbol("unsupported"),q=Symbol("checkPath"),P=Symbol("mkdir"),$=Symbol("onError"),K=Symbol("pending"),V=Symbol("pend"),N=Symbol("unpend"),A=Symbol("ended"),L=Symbol("maybeClose"),j=Symbol("skip"),z=Symbol("doChown"),D=Symbol("uid"),p=Symbol("gid"),m=Symbol("checkedCwd"),b=te("crypto"),R=mk(),E=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,M=E==="win32",B=(S,Y)=>{if(!M)return n.unlink(S,Y);let X=S+".DELETE."+b.randomBytes(16).toString("hex");n.rename(S,X,se=>{if(se)return Y(se);n.unlink(X,Y)})},Z=S=>{if(!M)return n.unlinkSync(S);let Y=S+".DELETE."+b.randomBytes(16).toString("hex");n.renameSync(S,Y),n.unlinkSync(Y)},U=(S,Y,X)=>S===S>>>0?S:Y===Y>>>0?Y:X,J=S=>d(f(h(S))).toLowerCase(),G=(S,Y)=>{Y=J(Y);for(let X of S.keys()){let se=J(X);(se===Y||se.indexOf(Y+"/")===0)&&S.delete(X)}},re=S=>{for(let Y of S.keys())S.delete(Y)},ce=class extends i{constructor(S){if(S||(S={}),S.ondone=Y=>{this[A]=!0,this[L]()},super(S),this[m]=!1,this.reservations=c(),this.transform=typeof S.transform=="function"?S.transform:null,this.writable=!0,this.readable=!1,this[K]=0,this[A]=!1,this.dirCache=S.dirCache||new Map,typeof S.uid=="number"||typeof S.gid=="number"){if(typeof S.uid!="number"||typeof S.gid!="number")throw new TypeError("cannot set owner without number uid and gid");if(S.preserveOwner)throw new TypeError("cannot preserve owner in archive and also set owner explicitly");this.uid=S.uid,this.gid=S.gid,this.setOwner=!0}else this.uid=null,this.gid=null,this.setOwner=!1;S.preserveOwner===void 0&&typeof S.uid!="number"?this.preserveOwner=process.getuid&&process.getuid()===0:this.preserveOwner=!!S.preserveOwner,this.processUid=(this.preserveOwner||this.setOwner)&&process.getuid?process.getuid():null,this.processGid=(this.preserveOwner||this.setOwner)&&process.getgid?process.getgid():null,this.forceChown=S.forceChown===!0,this.win32=!!S.win32||M,this.newer=!!S.newer,this.keep=!!S.keep,this.noMtime=!!S.noMtime,this.preservePaths=!!S.preservePaths,this.unlink=!!S.unlink,this.cwd=h(o.resolve(S.cwd||process.cwd())),this.strip=+S.strip||0,this.processUmask=S.noChmod?0:process.umask(),this.umask=typeof S.umask=="number"?S.umask:this.processUmask,this.dmode=S.dmode||511&~this.umask,this.fmode=S.fmode||438&~this.umask,this.on("entry",Y=>this[g](Y))}warn(S,Y,X={}){return(S==="TAR_BAD_ARCHIVE"||S==="TAR_ABORT")&&(X.recoverable=!1),super.warn(S,Y,X)}[L](){this[A]&&this[K]===0&&(this.emit("prefinish"),this.emit("finish"),this.emit("end"))}[q](S){if(this.strip){let Y=h(S.path).split("/");if(Y.length<this.strip)return!1;if(S.path=Y.slice(this.strip).join("/"),S.type==="Link"){let X=h(S.linkpath).split("/");if(X.length>=this.strip)S.linkpath=X.slice(this.strip).join("/");else return!1}}if(!this.preservePaths){let Y=h(S.path),X=Y.split("/");if(X.includes("..")||M&&/^[a-z]:\.\.$/i.test(X[0]))return this.warn("TAR_ENTRY_ERROR","path contains '..'",{entry:S,path:Y}),!1;let[se,le]=u(Y);se&&(S.path=le,this.warn("TAR_ENTRY_INFO",`stripping ${se} from absolute path`,{entry:S,path:Y}))}if(o.isAbsolute(S.path)?S.absolute=h(o.resolve(S.path)):S.absolute=h(o.resolve(this.cwd,S.path)),!this.preservePaths&&S.absolute.indexOf(this.cwd+"/")!==0&&S.absolute!==this.cwd)return this.warn("TAR_ENTRY_ERROR","path escaped extraction target",{entry:S,path:h(S.path),resolvedPath:S.absolute,cwd:this.cwd}),!1;if(S.absolute===this.cwd&&S.type!=="Directory"&&S.type!=="GNUDumpDir")return!1;if(this.win32){let{root:Y}=o.win32.parse(S.absolute);S.absolute=Y+l.encode(S.absolute.slice(Y.length));let{root:X}=o.win32.parse(S.path);S.path=X+l.encode(S.path.slice(X.length))}return!0}[g](S){if(!this[q](S))return S.resume();switch(r.equal(typeof S.absolute,"string"),S.type){case"Directory":case"GNUDumpDir":S.mode&&(S.mode=S.mode|448);case"File":case"OldFile":case"ContiguousFile":case"Link":case"SymbolicLink":return this[y](S);case"CharacterDevice":case"BlockDevice":case"FIFO":default:return this[F](S)}}[$](S,Y){S.name==="CwdError"?this.emit("error",S):(this.warn("TAR_ENTRY_ERROR",S,{entry:Y}),this[N](),Y.resume())}[P](S,Y,X){a(h(S),{uid:this.uid,gid:this.gid,processUid:this.processUid,processGid:this.processGid,umask:this.processUmask,preserve:this.preservePaths,unlink:this.unlink,cache:this.dirCache,cwd:this.cwd,mode:Y,noChmod:this.noChmod},X)}[z](S){return this.forceChown||this.preserveOwner&&(typeof S.uid=="number"&&S.uid!==this.processUid||typeof S.gid=="number"&&S.gid!==this.processGid)||typeof this.uid=="number"&&this.uid!==this.processUid||typeof this.gid=="number"&&this.gid!==this.processGid}[D](S){return U(this.uid,S.uid,this.processUid)}[p](S){return U(this.gid,S.gid,this.processGid)}[T](S,Y){let X=S.mode&4095||this.fmode,se=new s.WriteStream(S.absolute,{flags:R(S.size),mode:X,autoClose:!1});se.on("error",fe=>{se.fd&&n.close(se.fd,()=>{}),se.write=()=>!0,this[$](fe,S),Y()});let le=1,ge=fe=>{if(fe){se.fd&&n.close(se.fd,()=>{}),this[$](fe,S),Y();return}--le===0&&n.close(se.fd,ve=>{ve?this[$](ve,S):this[N](),Y()})};se.on("finish",fe=>{let ve=S.absolute,ut=se.fd;if(S.mtime&&!this.noMtime){le++;let ht=S.atime||new Date,Qi=S.mtime;n.futimes(ut,ht,Qi,en=>en?n.utimes(ve,ht,Qi,aa=>ge(aa&&en)):ge())}if(this[z](S)){le++;let ht=this[D](S),Qi=this[p](S);n.fchown(ut,ht,Qi,en=>en?n.chown(ve,ht,Qi,aa=>ge(aa&&en)):ge())}ge()});let ue=this.transform&&this.transform(S)||S;ue!==S&&(ue.on("error",fe=>{this[$](fe,S),Y()}),S.pipe(ue)),ue.pipe(se)}[O](S,Y){let X=S.mode&4095||this.dmode;this[P](S.absolute,X,se=>{if(se){this[$](se,S),Y();return}let le=1,ge=ue=>{--le===0&&(Y(),this[N](),S.resume())};S.mtime&&!this.noMtime&&(le++,n.utimes(S.absolute,S.atime||new Date,S.mtime,ge)),this[z](S)&&(le++,n.chown(S.absolute,this[D](S),this[p](S),ge)),ge()})}[F](S){S.unsupported=!0,this.warn("TAR_ENTRY_UNSUPPORTED",`unsupported entry type: ${S.type}`,{entry:S}),S.resume()}[w](S,Y){this[I](S,S.linkpath,"symlink",Y)}[v](S,Y){let X=h(o.resolve(this.cwd,S.linkpath));this[I](S,X,"link",Y)}[V](){this[K]++}[N](){this[K]--,this[L]()}[j](S){this[N](),S.resume()}[k](S,Y){return S.type==="File"&&!this.unlink&&Y.isFile()&&Y.nlink<=1&&!M}[y](S){this[V]();let Y=[S.path];S.linkpath&&Y.push(S.linkpath),this.reservations.reserve(Y,X=>this[_](S,X))}[x](S){S.type==="SymbolicLink"?re(this.dirCache):S.type!=="Directory"&&G(this.dirCache,S.absolute)}[_](S,Y){this[x](S);let X=ue=>{this[x](S),Y(ue)},se=()=>{this[P](this.cwd,this.dmode,ue=>{if(ue){this[$](ue,S),X();return}this[m]=!0,le()})},le=()=>{if(S.absolute!==this.cwd){let ue=h(o.dirname(S.absolute));if(ue!==this.cwd)return this[P](ue,this.dmode,fe=>{if(fe){this[$](fe,S),X();return}ge()})}ge()},ge=()=>{n.lstat(S.absolute,(ue,fe)=>{if(fe&&(this.keep||this.newer&&fe.mtime>S.mtime)){this[j](S),X();return}if(ue||this[k](S,fe))return this[C](null,S,X);if(fe.isDirectory()){if(S.type==="Directory"){let ve=!this.noChmod&&S.mode&&(fe.mode&4095)!==S.mode,ut=ht=>this[C](ht,S,X);return ve?n.chmod(S.absolute,S.mode,ut):ut()}if(S.absolute!==this.cwd)return n.rmdir(S.absolute,ve=>this[C](ve,S,X))}if(S.absolute===this.cwd)return this[C](null,S,X);B(S.absolute,ve=>this[C](ve,S,X))})};this[m]?le():se()}[C](S,Y,X){if(S){this[$](S,Y),X();return}switch(Y.type){case"File":case"OldFile":case"ContiguousFile":return this[T](Y,X);case"Link":return this[v](Y,X);case"SymbolicLink":return this[w](Y,X);case"Directory":case"GNUDumpDir":return this[O](Y,X)}}[I](S,Y,X,se){n[X](Y,S.absolute,le=>{le?this[$](le,S):(this[N](),S.resume()),se()})}},Se=S=>{try{return[null,S()]}catch(Y){return[Y,null]}},_e=class extends ce{[C](S,Y){return super[C](S,Y,()=>{})}[y](S){if(this[x](S),!this[m]){let le=this[P](this.cwd,this.dmode);if(le)return this[$](le,S);this[m]=!0}if(S.absolute!==this.cwd){let le=h(o.dirname(S.absolute));if(le!==this.cwd){let ge=this[P](le,this.dmode);if(ge)return this[$](ge,S)}}let[Y,X]=Se(()=>n.lstatSync(S.absolute));if(X&&(this.keep||this.newer&&X.mtime>S.mtime))return this[j](S);if(Y||this[k](S,X))return this[C](null,S);if(X.isDirectory()){if(S.type==="Directory"){let ge=!this.noChmod&&S.mode&&(X.mode&4095)!==S.mode,[ue]=ge?Se(()=>{n.chmodSync(S.absolute,S.mode)}):[];return this[C](ue,S)}let[le]=Se(()=>n.rmdirSync(S.absolute));this[C](le,S)}let[se]=S.absolute===this.cwd?[]:Se(()=>Z(S.absolute));this[C](se,S)}[T](S,Y){let X=S.mode&4095||this.fmode,se=ue=>{let fe;try{n.closeSync(le)}catch(ve){fe=ve}(ue||fe)&&this[$](ue||fe,S),Y()},le;try{le=n.openSync(S.absolute,R(S.size),X)}catch(ue){return se(ue)}let ge=this.transform&&this.transform(S)||S;ge!==S&&(ge.on("error",ue=>this[$](ue,S)),S.pipe(ge)),ge.on("data",ue=>{try{n.writeSync(le,ue,0,ue.length)}catch(fe){se(fe)}}),ge.on("end",ue=>{let fe=null;if(S.mtime&&!this.noMtime){let ve=S.atime||new Date,ut=S.mtime;try{n.futimesSync(le,ve,ut)}catch(ht){try{n.utimesSync(S.absolute,ve,ut)}catch{fe=ht}}}if(this[z](S)){let ve=this[D](S),ut=this[p](S);try{n.fchownSync(le,ve,ut)}catch(ht){try{n.chownSync(S.absolute,ve,ut)}catch{fe=fe||ht}}}se(fe)})}[O](S,Y){let X=S.mode&4095||this.dmode,se=this[P](S.absolute,X);if(se){this[$](se,S),Y();return}if(S.mtime&&!this.noMtime)try{n.utimesSync(S.absolute,S.atime||new Date,S.mtime)}catch{}if(this[z](S))try{n.chownSync(S.absolute,this[D](S),this[p](S))}catch{}Y(),S.resume()}[P](S,Y){try{return a.sync(h(S),{uid:this.uid,gid:this.gid,processUid:this.processUid,processGid:this.processGid,umask:this.processUmask,preserve:this.preservePaths,unlink:this.unlink,cache:this.dirCache,cwd:this.cwd,mode:Y})}catch(X){return X}}[I](S,Y,X,se){try{n[X+"Sync"](Y,S.absolute),se(),S.resume()}catch(le){return this[$](le,S)}}};ce.Sync=_e,e.exports=ce}),yk=ee((t,e)=>{"use strict";W();var r=bn(),i=yg(),n=te("fs"),s=vn(),o=te("path"),a=En();e.exports=(d,g,y)=>{typeof d=="function"?(y=d,g=null,d={}):Array.isArray(d)&&(g=d,d={}),typeof g=="function"&&(y=g,g=null),g?g=Array.from(g):g=[];let _=r(d);if(_.sync&&typeof y=="function")throw new TypeError("callback not supported for sync tar functions");if(!_.file&&typeof y=="function")throw new TypeError("callback only supported with file option");return g.length&&l(_,g),_.file&&_.sync?c(_):_.file?u(_,y):_.sync?h(_):f(_)};var l=(d,g)=>{let y=new Map(g.map(k=>[a(k),!0])),_=d.filter,x=(k,C)=>{let T=C||o.parse(k).root||".",O=k===T?!1:y.has(k)?y.get(k):x(o.dirname(k),T);return y.set(k,O),O};d.filter=_?(k,C)=>_(k,C)&&x(a(k)):k=>x(a(k))},c=d=>{let g=new i.Sync(d),y=d.file,_=n.statSync(y),x=d.maxReadSize||16*1024*1024;new s.ReadStreamSync(y,{readSize:x,size:_.size}).pipe(g)},u=(d,g)=>{let y=new i(d),_=d.maxReadSize||16*1024*1024,x=d.file,k=new Promise((C,T)=>{y.on("error",T),y.on("close",C),n.stat(x,(O,I)=>{if(O)T(O);else{let w=new s.ReadStream(x,{readSize:_,size:I.size});w.on("error",T),w.pipe(y)}})});return g?k.then(g,g):k},h=d=>new i.Sync(d),f=d=>new i(d)}),gk=ee(t=>{"use strict";W(),t.c=t.create=nk(),t.r=t.replace=pg(),t.t=t.list=Pc(),t.u=t.update=sk(),t.x=t.extract=yk(),t.Pack=Cc(),t.Unpack=yg(),t.Parse=Lc(),t.ReadEntry=Oc(),t.WriteEntry=hg(),t.Header=Sn(),t.Pax=Tc(),t.types=lg()}),_k=ee((t,e)=>{W();function r(i,n){typeof n=="boolean"&&(n={forever:n}),this._originalTimeouts=JSON.parse(JSON.stringify(i)),this._timeouts=i,this._options=n||{},this._maxRetryTime=n&&n.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._timer=null,this._options.forever&&(this._cachedTimeouts=this._timeouts.slice(0))}e.exports=r,r.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts.slice(0)},r.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timer&&clearTimeout(this._timer),this._timeouts=[],this._cachedTimeouts=null},r.prototype.retry=function(i){if(this._timeout&&clearTimeout(this._timeout),!i)return!1;var n=new Date().getTime();if(i&&n-this._operationStart>=this._maxRetryTime)return this._errors.push(i),this._errors.unshift(new Error("RetryOperation timeout occurred")),!1;this._errors.push(i);var s=this._timeouts.shift();if(s===void 0)if(this._cachedTimeouts)this._errors.splice(0,this._errors.length-1),s=this._cachedTimeouts.slice(-1);else return!1;var o=this;return this._timer=setTimeout(function(){o._attempts++,o._operationTimeoutCb&&(o._timeout=setTimeout(function(){o._operationTimeoutCb(o._attempts)},o._operationTimeout),o._options.unref&&o._timeout.unref()),o._fn(o._attempts)},s),this._options.unref&&this._timer.unref(),!0},r.prototype.attempt=function(i,n){this._fn=i,n&&(n.timeout&&(this._operationTimeout=n.timeout),n.cb&&(this._operationTimeoutCb=n.cb));var s=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){s._operationTimeoutCb()},s._operationTimeout)),this._operationStart=new Date().getTime(),this._fn(this._attempts)},r.prototype.try=function(i){console.log("Using RetryOperation.try() is deprecated"),this.attempt(i)},r.prototype.start=function(i){console.log("Using RetryOperation.start() is deprecated"),this.attempt(i)},r.prototype.start=r.prototype.try,r.prototype.errors=function(){return this._errors},r.prototype.attempts=function(){return this._attempts},r.prototype.mainError=function(){if(this._errors.length===0)return null;for(var i={},n=null,s=0,o=0;o<this._errors.length;o++){var a=this._errors[o],l=a.message,c=(i[l]||0)+1;i[l]=c,c>=s&&(n=a,s=c)}return n}}),bk=ee(t=>{W();var e=_k();t.operation=function(r){var i=t.timeouts(r);return new e(i,{forever:r&&(r.forever||r.retries===1/0),unref:r&&r.unref,maxRetryTime:r&&r.maxRetryTime})},t.timeouts=function(r){if(r instanceof Array)return[].concat(r);var i={retries:10,factor:2,minTimeout:1*1e3,maxTimeout:1/0,randomize:!1};for(var n in r)i[n]=r[n];if(i.minTimeout>i.maxTimeout)throw new Error("minTimeout is greater than maxTimeout");for(var s=[],o=0;o<i.retries;o++)s.push(this.createTimeout(o,i));return r&&r.forever&&!s.length&&s.push(this.createTimeout(o,i)),s.sort(function(a,l){return a-l}),s},t.createTimeout=function(r,i){var n=i.randomize?Math.random()+1:1,s=Math.round(n*Math.max(i.minTimeout,1)*Math.pow(i.factor,r));return s=Math.min(s,i.maxTimeout),s},t.wrap=function(r,i,n){if(i instanceof Array&&(n=i,i=null),!n){n=[];for(var s in r)typeof r[s]=="function"&&n.push(s)}for(var o=0;o<n.length;o++){var a=n[o],l=r[a];r[a]=function(c){var u=t.operation(i),h=Array.prototype.slice.call(arguments,1),f=h.pop();h.push(function(d){u.retry(d)||(d&&(arguments[0]=u.mainError()),f.apply(this,arguments))}),u.attempt(function(){c.apply(r,h)})}.bind(r,l),r[a].options=i}}}),wk=ee((t,e)=>{W(),e.exports=bk()}),Sk=ee((t,e)=>{W();var r=wk();function i(n,s){function o(a,l){var c=s||{},u;"randomize"in c||(c.randomize=!0),u=r.operation(c);function h(g){l(g||new Error("Aborted"))}function f(g,y){if(g.bail){h(g);return}u.retry(g)?c.onRetry&&c.onRetry(g,y):l(u.mainError())}function d(g){var y;try{y=n(h,g)}catch(_){f(_,g);return}Promise.resolve(y).then(a).catch(function(_){f(_,g)})}u.attempt(d)}return new Promise(o)}e.exports=i}),Ek={};$T(Ek,{bold:()=>Ok,dimmed:()=>kk,error:()=>Ik,grey:()=>Ck,info:()=>Ak,item:()=>Lk,log:()=>jr,turboBlue:()=>vi,turboGradient:()=>Rk,turboLoader:()=>xk,turboRed:()=>Sg,underline:()=>Tk,warn:()=>Pk,yellow:()=>Eg});W();var bg="#0099F7",wg="#F11712",vk="#FFFF00",Rk=(0,_g.default)(bg,wg),vi=ur.default.hex(bg),Sg=ur.default.hex(wg),Eg=ur.default.hex(vk),xk=t=>(0,gg.default)({text:t,spinner:{frames:[" ",vi("> "),vi(">> "),vi(">>>")]}}),Ak=(...t)=>{jr(vi.bold(">>>"),...t)},Ok=(...t)=>{jr(ur.default.bold(...t))},Tk=(...t)=>{jr(ur.default.underline(...t))},kk=(...t)=>{jr(ur.default.dim(...t))},Ck=(...t)=>{jr(ur.default.grey(...t))},Lk=(...t)=>{jr(vi.bold(" \u2022"),...t)},jr=(...t)=>{console.log(...t)},Pk=(...t)=>{console.error(Eg.bold(">>>"),...t)},Ik=(...t)=>{console.error(Sg.bold(">>>"),...t)};W();W();W();W();var KN=zs(YT());W();W();function Dk(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}W();W();function vc(t){return vc=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},vc(t)}W();function Mk(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function Fk(t,e){if(e&&(vc(e)==="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Mk(t)}W();function Gs(t){return Gs=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},Gs(t)}W();W();function yn(t,e){return yn=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,i){return r.__proto__=i,r},yn(t,e)}function Bk(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&yn(t,e)}W();W();function jk(t){return Function.toString.call(t).indexOf("[native code]")!==-1}W();W();function Hk(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function $s(t,e,r){return Hk()?$s=Reflect.construct.bind():$s=function(i,n,s){var o=[null];o.push.apply(o,n);var a=Function.bind.apply(i,o),l=new a;return s&&yn(l,s.prototype),l},$s.apply(null,arguments)}function Rc(t){var e=typeof Map=="function"?new Map:void 0;return Rc=function(r){if(r===null||!jk(r))return r;if(typeof r!="function")throw new TypeError("Super expression must either be null or a function");if(typeof e<"u"){if(e.has(r))return e.get(r);e.set(r,i)}function i(){return $s(r,arguments,Gs(this).constructor)}return i.prototype=Object.create(r.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),yn(i,r)},Rc(t)}var VN=zs(QT()),JN=function(t){Bk(e,t);function e(r){var i;return Dk(this,e),i=Fk(this,Gs(e).call(this,"No package.json could be found upwards from the directory ".concat(r))),i.directory=r,i}return e}(Rc(Error));W();W();W();W();W();W();var cD=zs(gk()),uD=(0,Rg.promisify)(vg.Stream.pipeline);W();W();var dD=zs(Sk());W();W();W();var Ie=class extends Error{constructor(t,e){var r;super(t),this.name="ConvertError",this.type=(r=e==null?void 0:e.type)!=null?r:"unknown",Error.captureStackTrace(this,Ie)}};W();W();W();W();var qk=/^(?!_)(?<manager>.+)@(?<version>.+)$/;function $e({workspaceRoot:t}){let e=Ft.default.join(t,"package.json");try{return(0,Ze.readJsonSync)(e,"utf8")}catch(r){if(r&&typeof r=="object"&&"code"in r){if(r.code==="ENOENT")throw new Ie(`no "package.json" found at ${t}`,{type:"package_json-missing"});if(r.code==="EJSONPARSE")throw new Ie(`failed to parse "package.json" at ${t}`,{type:"package_json-parse_error"})}throw new Error(`unexpected error reading "package.json" at ${t}`)}}function Ws({workspaceRoot:t}){let{packageManager:e}=$e({workspaceRoot:t});if(e)try{let r=qk.exec(e);if(r){let[i,n]=r;return n}}catch{}}function Rn({workspaceRoot:t}){let e=$e({workspaceRoot:t}),r=Ft.default.basename(t),{name:i=r,description:n}=e;return{name:i,description:n}}function ig({workspaceRoot:t}){let e=Ft.default.join(t,"pnpm-workspace.yaml");if((0,Ze.existsSync)(e))try{let r=qa.load((0,Ze.readFileSync)(e,"utf8"));if(r instanceof Object&&"packages"in r&&Array.isArray(r.packages))return r.packages}catch{throw new Ie(`failed to parse ${e}`,{type:"pnpm-workspace_parse_error"})}return[]}function Ys({root:t,lockFile:e,workspaceConfig:r}){let i=s=>Ft.default.join(t,s),n={root:t,lockfile:i(e),packageJson:i("package.json"),nodeModules:i("node_modules")};return r&&(n.workspaceConfig=i(r)),n}function Ic({workspaces:t}){var e;return t?Array.isArray(t)?t:"packages"in t?(e=t.packages)!=null?e:[]:[]:[]}function Ks({workspaceRoot:t,workspaceGlobs:e}){if(!e)return[];let r=e.filter(i=>i.startsWith("!")).map(i=>i.slice(1));return e.filter(i=>!i.startsWith("!")).flatMap(i=>{let n=[`${i}/package.json`];return(0,Cg.sync)(n,{onlyFiles:!0,absolute:!0,cwd:t,ignore:["**/node_modules/**",...r]})}).map(i=>{let n=Ft.default.dirname(i),{name:s,description:o}=Rn({workspaceRoot:n});return{name:s,description:o,paths:{root:n,packageJson:i,nodeModules:Ft.default.join(n,"node_modules")}}})}function Uk({directory:t}){let e=Ft.default.resolve(process.cwd(),t);return{exists:(0,Ze.existsSync)(e),absolute:e}}function hr({packageManager:t,action:e,project:r}){let i=r.workspaceData.globs.length>0;return`${e==="remove"?"Removing":"Adding"} ${t} ${i?"workspaces":""} ${e==="remove"?"from":"to"} ${r.name}`}function $k({project:t}){let e=r=>!(r.includes("*")&&(r.includes("**")||r.split("/").slice(0,-1).join("/").includes("*"))||["!","[","]","{","}"].some(i=>r.includes(i)));return t.workspaceData.globs.every(e)}function Mt({project:t,options:e}){e!=null&&e.dry||(0,Ze.rmSync)(t.paths.lockfile,{force:!0})}async function Lg({project:t,options:e}){if(!(e!=null&&e.dry)&&(0,Ze.existsSync)(t.paths.lockfile))try{let{stdout:r}=await(0,kg.default)("bun",["bun.lockb"],{stdin:"ignore",cwd:t.paths.root});await(0,Ze.writeFile)(Ft.default.join(t.paths.root,"yarn.lock"),r)}catch{}finally{(0,Ze.rmSync)(t.paths.lockfile,{force:!0})}}function Gk({dependencyList:t,project:e,to:r}){let i=[];return e.workspaceData.workspaces.forEach(n=>{let{name:s}=n;if(t[s]){let o=t[s],a=o.startsWith("workspace:")?o.slice(10):o;t[s]=r.name==="pnpm"?`workspace:${a}`:a,i.push(s)}}),{dependencyList:t,updated:i}}function lr({project:t,workspace:e,to:r,logger:i,options:n}){if(["yarn","npm","bun"].includes(r.name)&&["yarn","npm","bun"].includes(t.packageManager))return;let s=$e({workspaceRoot:e.paths.root}),o={dependencies:[],devDependencies:[],peerDependencies:[],optionalDependencies:[]},a=["dependencies","devDependencies","peerDependencies","optionalDependencies"];a.forEach(h=>{let f=s[h];if(f){let{updated:d,dependencyList:g}=Gk({dependencyList:f,project:t,to:r});s[h]=g,o[h]=d}});let l=h=>{let f=o[h].length;if(f>0)return`${Tg.default.green(f.toString())} ${h}`},c=a.map(l).filter(Boolean),u=`./${Ag.default.relative(t.paths.root,e.paths.packageJson)}`;if(c.length>=1){let h="updating";c.forEach((f,d)=>{c.length===1?h+=` ${f} in ${u}`:d===c.length-1?h+=`and ${f} in ${u}`:h+=` ${f}, `}),i.workspaceStep(h)}else i.workspaceStep(`no workspace dependencies found in ${u}`);n!=null&&n.dry||(0,Og.writeJSONSync)(e.paths.packageJson,s,{spaces:2})}var cr={name:"pnpm",lock:"pnpm-lock.yaml"};async function Pg(t){let e=Fr.default.join(t.workspaceRoot,cr.lock),r=Fr.default.join(t.workspaceRoot,"pnpm-workspace.yaml"),i=Ws({workspaceRoot:t.workspaceRoot});return(0,He.existsSync)(e)||(0,He.existsSync)(r)||i===cr.name}async function zk(t){if(!await Pg(t))throw new Ie("Not a pnpm project",{type:"package_manager-unexpected"});let{name:e,description:r}=Rn(t);return{name:e,description:r,packageManager:cr.name,paths:Ys({root:t.workspaceRoot,lockFile:cr.lock,workspaceConfig:"pnpm-workspace.yaml"}),workspaceData:{globs:ig(t),workspaces:Ks({workspaceGlobs:ig(t),...t})}}}async function Wk(t){let{project:e,to:r,logger:i,options:n}=t,s=e.workspaceData.globs.length>0;i.mainStep(hr({action:"create",packageManager:cr.name,project:e}));let o=$e({workspaceRoot:e.paths.root});i.rootHeader(),o.packageManager=`${r.name}@${r.version}`,i.rootStep(`adding "packageManager" field to ${e.name} root "package.json"`),n!=null&&n.dry||((0,He.writeJSONSync)(e.paths.packageJson,o,{spaces:2}),s&&(i.rootStep('adding "pnpm-workspace.yaml"'),(0,He.writeFileSync)(Fr.default.join(e.paths.root,"pnpm-workspace.yaml"),`packages:
42
42
  ${e.workspaceData.globs.map(a=>` - "${a}"`).join(`
43
- `)}`))),s&&(lr({workspace:{name:"root",paths:e.paths},project:e,to:r,logger:i,options:n}),i.workspaceHeader(),e.workspaceData.workspaces.forEach(a=>{lr({workspace:a,project:e,to:r,logger:i,options:n})}))}async function Yk(t){let{project:e,logger:r,options:i}=t,n=e.workspaceData.globs.length>0;r.mainStep(hr({action:"remove",packageManager:cr.name,project:e}));let s=$e({workspaceRoot:e.paths.root});if(e.paths.workspaceConfig&&n&&(r.subStep('removing "pnpm-workspace.yaml"'),i!=null&&i.dry||(0,He.rmSync)(e.paths.workspaceConfig,{force:!0})),r.subStep(`removing "packageManager" field in ${e.name} root "package.json"`),delete s.packageManager,!(i!=null&&i.dry)){(0,He.writeJSONSync)(e.paths.packageJson,s,{spaces:2});let o=[e.paths.nodeModules,...e.workspaceData.workspaces.map(a=>a.paths.nodeModules)];try{r.subStep('removing "node_modules"'),await Promise.all(o.map(a=>(0,He.rm)(a,{recursive:!0,force:!0})))}catch{throw new Ie("Failed to remove node_modules",{type:"error_removing_node_modules"})}}}async function Kk(t){let{project:e,logger:r,options:i}=t;r.subStep(`removing ${Fr.default.relative(e.paths.root,e.paths.lockfile)}`),i!=null&&i.dry||(0,He.rmSync)(e.paths.lockfile,{force:!0})}async function Vk(t){let{project:e,options:r,logger:i}=t,n=()=>{i.subStep(`converting ${Fr.default.relative(e.paths.root,e.paths.lockfile)} to ${cr.lock}`)},s=async()=>{if(!(r!=null&&r.dry)&&(0,He.existsSync)(e.paths.lockfile))try{await(0,xg.default)(cr.name,["import"],{stdio:"ignore",cwd:e.paths.root})}catch{}finally{Mt({project:e,options:r})}};switch(e.packageManager){case"pnpm":break;case"bun":n(),await Lg({project:e,options:r}),await s(),(0,He.rmSync)(Fr.default.join(e.paths.root,"yarn.lock"),{force:!0});break;case"npm":n(),await s();break;case"yarn":n(),await s();break}}var Zk={detect:Pg,read:zk,create:Wk,remove:Yk,clean:Kk,convertLock:Vk};W();var Ri={name:"npm",lock:"package-lock.json"};async function Ig(t){let e=gn.default.join(t.workspaceRoot,Ri.lock),r=Ws({workspaceRoot:t.workspaceRoot});return(0,Et.existsSync)(e)||r===Ri.name}async function Xk(t){if(!await Ig(t))throw new Ie("Not an npm project",{type:"package_manager-unexpected"});let e=$e(t),{name:r,description:i}=Rn(t),n=Ic({workspaces:e.workspaces});return{name:r,description:i,packageManager:Ri.name,paths:Ys({root:t.workspaceRoot,lockFile:Ri.lock}),workspaceData:{globs:n,workspaces:Ks({workspaceGlobs:n,...t})}}}async function Jk(t){let{project:e,options:r,to:i,logger:n}=t,s=e.workspaceData.globs.length>0;n.mainStep(hr({packageManager:Ri.name,action:"create",project:e}));let o=$e({workspaceRoot:e.paths.root});n.rootHeader(),n.rootStep(`adding "packageManager" field to ${gn.default.relative(e.paths.root,e.paths.packageJson)}`),o.packageManager=`${i.name}@${i.version}`,s?(n.rootStep(`adding "workspaces" field to ${gn.default.relative(e.paths.root,e.paths.packageJson)}`),o.workspaces=e.workspaceData.globs,r!=null&&r.dry||(0,Et.writeJSONSync)(e.paths.packageJson,o,{spaces:2}),lr({workspace:{name:"root",paths:e.paths},project:e,to:i,logger:n,options:r}),n.workspaceHeader(),e.workspaceData.workspaces.forEach(a=>{lr({workspace:a,project:e,to:i,logger:n,options:r})})):r!=null&&r.dry||(0,Et.writeJSONSync)(e.paths.packageJson,o,{spaces:2})}async function Qk(t){let{project:e,logger:r,options:i}=t,n=e.workspaceData.globs.length>0;r.mainStep(hr({packageManager:Ri.name,action:"remove",project:e}));let s=$e({workspaceRoot:e.paths.root});if(n&&(r.subStep(`removing "workspaces" field in ${e.name} root "package.json"`),delete s.workspaces),r.subStep(`removing "packageManager" field in ${e.name} root "package.json"`),delete s.packageManager,!(i!=null&&i.dry)){(0,Et.writeJSONSync)(e.paths.packageJson,s,{spaces:2});let o=[e.paths.nodeModules,...e.workspaceData.workspaces.map(a=>a.paths.nodeModules)];try{r.subStep('removing "node_modules"'),await Promise.all(o.map(a=>(0,Et.rm)(a,{recursive:!0,force:!0})))}catch{throw new Ie("Failed to remove node_modules",{type:"error_removing_node_modules"})}}}async function e1(t){let{project:e,logger:r,options:i}=t;r.subStep(`removing ${gn.default.relative(e.paths.root,e.paths.lockfile)}`),i!=null&&i.dry||(0,Et.rmSync)(e.paths.lockfile,{force:!0})}async function t1(t){let{project:e,options:r}=t;switch(e.packageManager){case"pnpm":Mt({project:e,options:r});break;case"bun":Mt({project:e,options:r});break;case"npm":break;case"yarn":Mt({project:e,options:r});break}}var r1={detect:Ig,read:Xk,create:Jk,remove:Qk,clean:e1,convertLock:t1};W();var Br={name:"yarn",lock:"yarn.lock"};async function Ng(t){let e=xi.default.join(t.workspaceRoot,Br.lock),r=Ws({workspaceRoot:t.workspaceRoot});return(0,vt.existsSync)(e)||r===Br.name}async function i1(t){if(!await Ng(t))throw new Ie("Not a yarn project",{type:"package_manager-unexpected"});let e=$e(t),{name:r,description:i}=Rn(t),n=Ic({workspaces:e.workspaces});return{name:r,description:i,packageManager:Br.name,paths:Ys({root:t.workspaceRoot,lockFile:Br.lock}),workspaceData:{globs:n,workspaces:Ks({workspaceGlobs:n,...t})}}}async function n1(t){let{project:e,to:r,logger:i,options:n}=t,s=e.workspaceData.globs.length>0;i.mainStep(hr({packageManager:Br.name,action:"create",project:e}));let o=$e({workspaceRoot:e.paths.root});i.rootHeader(),i.rootStep(`adding "packageManager" field to ${xi.default.relative(e.paths.root,e.paths.packageJson)}`),o.packageManager=`${r.name}@${r.version}`,s?(i.rootStep(`adding "workspaces" field to ${xi.default.relative(e.paths.root,e.paths.packageJson)}`),o.workspaces=e.workspaceData.globs,n!=null&&n.dry||(0,vt.writeJSONSync)(e.paths.packageJson,o,{spaces:2}),lr({workspace:{name:"root",paths:e.paths},project:e,to:r,logger:i,options:n}),i.workspaceHeader(),e.workspaceData.workspaces.forEach(a=>{lr({workspace:a,project:e,to:r,logger:i,options:n})})):n!=null&&n.dry||(0,vt.writeJSONSync)(e.paths.packageJson,o,{spaces:2})}async function s1(t){let{project:e,logger:r,options:i}=t,n=e.workspaceData.globs.length>0;r.mainStep(hr({packageManager:Br.name,action:"remove",project:e}));let s=$e({workspaceRoot:e.paths.root});if(n&&(r.subStep(`removing "workspaces" field in ${e.name} root "package.json"`),delete s.workspaces),r.subStep(`removing "packageManager" field in ${e.name} root "package.json"`),delete s.packageManager,!(i!=null&&i.dry)){(0,vt.writeJSONSync)(e.paths.packageJson,s,{spaces:2});let o=[e.paths.nodeModules,...e.workspaceData.workspaces.map(a=>a.paths.nodeModules)];try{r.subStep('removing "node_modules"'),await Promise.all(o.map(a=>(0,vt.rm)(a,{recursive:!0,force:!0})))}catch{throw new Ie("Failed to remove node_modules",{type:"error_removing_node_modules"})}}}async function o1(t){let{project:e,logger:r,options:i}=t;r.subStep(`removing ${xi.default.relative(e.paths.root,e.paths.lockfile)}`),i!=null&&i.dry||(0,vt.rmSync)(e.paths.lockfile,{force:!0})}async function a1(t){let{project:e,options:r,logger:i}=t,n=()=>{i.subStep(`converting ${xi.default.relative(e.paths.root,e.paths.lockfile)} to ${Br.lock}`)};switch(e.packageManager){case"pnpm":Mt({project:e,options:r});break;case"bun":n(),await Lg({project:e,options:r});break;case"npm":Mt({project:e,options:r});break;case"yarn":break}}var l1={detect:Ng,read:i1,create:n1,remove:s1,clean:o1,convertLock:a1};W();var Ai={name:"bun",lock:"bun.lockb"};async function Dg(t){let e=_n.default.join(t.workspaceRoot,Ai.lock),r=Ws({workspaceRoot:t.workspaceRoot});return(0,Rt.existsSync)(e)||r===Ai.name}async function c1(t){if(!await Dg(t))throw new Ie("Not a bun project",{type:"package_manager-unexpected"});let e=$e(t),{name:r,description:i}=Rn(t),n=Ic({workspaces:e.workspaces});return{name:r,description:i,packageManager:Ai.name,paths:Ys({root:t.workspaceRoot,lockFile:Ai.lock}),workspaceData:{globs:n,workspaces:Ks({workspaceGlobs:n,...t})}}}async function u1(t){let{project:e,to:r,logger:i,options:n}=t,s=e.workspaceData.globs.length>0;if(!$k({project:e}))throw new Ie("Unable to convert project to bun - workspace globs unsupported",{type:"bun-workspace_glob_error"});i.mainStep(hr({packageManager:Ai.name,action:"create",project:e}));let o=$e({workspaceRoot:e.paths.root});i.rootHeader(),i.rootStep(`adding "packageManager" field to ${_n.default.relative(e.paths.root,e.paths.packageJson)}`),o.packageManager=`${r.name}@${r.version}`,s?(i.rootStep(`adding "workspaces" field to ${_n.default.relative(e.paths.root,e.paths.packageJson)}`),o.workspaces=e.workspaceData.globs,n!=null&&n.dry||(0,Rt.writeJSONSync)(e.paths.packageJson,o,{spaces:2}),lr({workspace:{name:"root",paths:e.paths},project:e,to:r,logger:i,options:n}),i.workspaceHeader(),e.workspaceData.workspaces.forEach(a=>{lr({workspace:a,project:e,to:r,logger:i,options:n})})):n!=null&&n.dry||(0,Rt.writeJSONSync)(e.paths.packageJson,o,{spaces:2})}async function h1(t){let{project:e,logger:r,options:i}=t,n=e.workspaceData.globs.length>0;r.mainStep(hr({packageManager:Ai.name,action:"remove",project:e}));let s=$e({workspaceRoot:e.paths.root});if(n&&(r.subStep(`removing "workspaces" field in ${e.name} root "package.json"`),delete s.workspaces),r.subStep(`removing "packageManager" field in ${e.name} root "package.json"`),delete s.packageManager,!(i!=null&&i.dry)){(0,Rt.writeJSONSync)(e.paths.packageJson,s,{spaces:2});let o=[e.paths.nodeModules,...e.workspaceData.workspaces.map(a=>a.paths.nodeModules)];try{r.subStep('removing "node_modules"'),await Promise.all(o.map(a=>(0,Rt.rm)(a,{recursive:!0,force:!0})))}catch{throw new Ie("Failed to remove node_modules",{type:"error_removing_node_modules"})}}}async function f1(t){let{project:e,logger:r,options:i}=t;r.subStep(`removing ${_n.default.relative(e.paths.root,e.paths.lockfile)}`),i!=null&&i.dry||(0,Rt.rmSync)(e.paths.lockfile,{force:!0})}async function p1(t){let{project:e,options:r}=t;switch(e.packageManager){case"pnpm":Mt({project:e,options:r});break;case"bun":break;case"npm":Mt({project:e,options:r});break;case"yarn":Mt({project:e,options:r});break}}var d1={detect:Dg,read:c1,create:u1,remove:h1,clean:f1,convertLock:p1},Mg={pnpm:Zk,yarn:l1,npm:r1,bun:d1};W();async function Nc({root:t}){let{exists:e,absolute:r}=Uk({directory:t});if(!e)throw new Ie(`Could not find directory at ${r}. Ensure the directory exists.`,{type:"invalid_directory"});for(let{detect:i,read:n}of Object.values(Mg))if(await i({workspaceRoot:r}))return n({workspaceRoot:r});throw new Ie("Could not determine package manager. Add `packageManager` to `package.json` or ensure a lockfile is present.",{type:"package_manager-unable_to_detect"})}W();W();W();W();var S1=ie(Ug());function Mc(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function xn(t){return xn=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},xn(t)}function Fc(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function Bc(t,e){if(e&&(xn(e)==="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Fc(t)}function Hr(t){return Hr=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},Hr(t)}function Ht(t,e){return Ht=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(i,n){return i.__proto__=n,i},Ht(t,e)}function jc(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Ht(t,e)}function Hc(t){return Function.toString.call(t).indexOf("[native code]")!==-1}function qc(){if(typeof Reflect=="undefined"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Oi(t,e,r){return qc()?Oi=Reflect.construct.bind():Oi=function(n,s,o){var a=[null];a.push.apply(a,s);var l=Function.bind.apply(n,a),c=new l;return o&&Ht(c,o.prototype),c},Oi.apply(null,arguments)}function An(t){var e=typeof Map=="function"?new Map:void 0;return An=function(i){if(i===null||!Hc(i))return i;if(typeof i!="function")throw new TypeError("Super expression must either be null or a function");if(typeof e!="undefined"){if(e.has(i))return e.get(i);e.set(i,n)}function n(){return Oi(i,arguments,Hr(this).constructor)}return n.prototype=Object.create(i.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),Ht(n,i)},An(t)}var $g=ie(require("find-up"));var E1=ie(require("fs-extra")),WM=function(t){jc(e,t);function e(r){var i;return Mc(this,e),i=Bc(this,Hr(e).call(this,"No package.json could be found upwards from the directory ".concat(r))),i.directory=r,i}return e}(An(Error));var A1=ie(require("json5"));var v1=ie(require("fs")),R1=ie(require("path"));var M1=ie(require("fs")),F1=ie(require("path"));var B1=ie(Us()),j1=ie(require("json5"));var it={};Ch(it,{bold:()=>C1,dimmed:()=>P1,error:()=>Jg,grey:()=>I1,info:()=>k1,item:()=>N1,log:()=>pr,turboBlue:()=>Ti,turboGradient:()=>T1,turboLoader:()=>Zg,turboRed:()=>Kg,underline:()=>L1,warn:()=>Xg,yellow:()=>Vg});var fr=ie(require("chalk")),Gg=ie(require("ora")),zg=ie(require("gradient-string")),Wg="#0099F7",Yg="#F11712",O1="#FFFF00",T1=(0,zg.default)(Wg,Yg),Ti=fr.default.hex(Wg),Kg=fr.default.hex(Yg),Vg=fr.default.hex(O1),Zg=t=>(0,Gg.default)({text:t,spinner:{frames:[" ",Ti("> "),Ti(">> "),Ti(">>>")]}}),k1=(...t)=>{pr(Ti.bold(">>>"),...t)},C1=(...t)=>{pr(fr.default.bold(...t))},L1=(...t)=>{pr(fr.default.underline(...t))},P1=(...t)=>{pr(fr.default.dim(...t))},I1=(...t)=>{pr(fr.default.grey(...t))},N1=(...t)=>{pr(Ti.bold(" \u2022"),...t)},pr=(...t)=>{console.log(...t)},Xg=(...t)=>{console.error(Vg.bold(">>>"),...t)},Jg=(...t)=>{console.error(Kg.bold(">>>"),...t)};var Qg=ie(require("os")),e_=ie(li());async function Zs(t,e=[],r){let i={cwd:Qg.default.tmpdir(),env:{COREPACK_ENABLE_STRICT:"0"},...r};try{let{stdout:n}=await(0,e_.default)(t,e,i);return n.trim()}catch{return}}async function Uc(){let[t,e,r,i]=await Promise.all([Zs("yarnpkg",["--version"]),Zs("npm",["--version"]),Zs("pnpm",["--version"]),Zs("bun",["--version"])]);return{yarn:t,pnpm:r,npm:e,bun:i}}var H1=ie(require("fs-extra"));var q1=ie(require("path")),U1=ie(require("fs-extra")),$1=ie(require("chalk"));var Qw=require("stream"),eS=require("util"),xP=require("path"),AP=require("os"),tS=require("fs"),OP=ie(Jw());var tB=(0,eS.promisify)(Qw.Stream.pipeline);var rS=require("fs-extra");var FP=ie(require("path")),BP=ie(cS()),jP=ie(require("chalk")),Th=require("fs-extra");var oa=ie(require("chalk"));var dt=ie(require("chalk")),Ji=class{constructor(e){this.transform=e.transformer,this.dry=e.dryRun}_log(...e){console.log(...e)}modified(...e){this._log(dt.default.green(" MODIFIED "),...e,this.dry?dt.default.dim("(dry run)"):"")}unchanged(...e){this._log(dt.default.gray(" UNCHANGED "),...e,this.dry?dt.default.dim("(dry run)"):"")}skipped(...e){this._log(dt.default.yellow(" SKIPPED "),...e,this.dry?dt.default.dim("(dry run)"):"")}error(...e){this._log(dt.default.red(" ERROR "),...e,this.dry?dt.default.dim("(dry run)"):"")}info(...e){this._log(dt.default.bold(" INFO "),...e,this.dry?dt.default.dim("(dry run)"):"")}};var uS=ie(require("os")),kh=ie(require("path"));var ia=ie(require("chalk")),sa=require("diff"),Or=require("fs-extra"),na=class{constructor(e){this.changes=[];if(this.filePath=e.filePath,this.rootPath=e.rootPath,this.after=e.after,this.error=e.error,e.before===void 0)try{kh.default.extname(e.filePath)===".json"?this.before=(0,Or.readJsonSync)(e.filePath):this.before=(0,Or.readFileSync)(e.filePath)}catch{this.before=""}else e.before===null?this.before="":this.before=e.before;e.after?typeof this.before=="object"||typeof e.after=="object"?this.changes=(0,sa.diffJson)(this.before,e.after):this.changes=(0,sa.diffLines)(this.before,e.after):this.changes=[]}fileName(){return kh.default.relative(this.rootPath,this.filePath)}write(){this.after&&(typeof this.after=="object"?(0,Or.writeJsonSync)(this.filePath,this.after,{spaces:2}):(0,Or.writeFileSync)(this.filePath,this.after))}additions(){return this.changes.filter(e=>e.added).length}deletions(){return this.changes.filter(e=>e.removed).length}hasChanges(){return this.additions()>0||this.deletions()>0}log(e){e.diff?(this.changes.forEach(r=>{r.added?process.stdout.write(ia.default.green(r.value)):r.removed?process.stdout.write(ia.default.red(r.value)):process.stdout.write(ia.default.dim(r.value))}),it.log(uS.default.EOL)):it.log(this.after)}};var Yn=class{constructor(e){this.modifications={};this.transform=e.transformer,this.rootPath=e.rootPath,this.dry=e.dryRun,this.print=e.print,this.logger=new Ji(e)}abortTransform(e){return this.logger.error(e.reason),{fatalError:new Error(e.reason),changes:e.changes||{}}}modifyFile(e){this.modifications[e.filePath]=new na({rootPath:this.rootPath,...e})}finish(){let e={changes:{}};return Object.keys(this.modifications).forEach(i=>{let n=this.modifications[i],s={action:"unchanged",additions:n.additions(),deletions:n.deletions()};if(n.hasChanges()){if(this.dry)s.action="skipped",this.logger.skipped(oa.default.dim(n.fileName()));else try{n.write(),s.action="modified",this.logger.modified(oa.default.bold(n.fileName()))}catch(o){let a="Unknown error";o instanceof Error&&(a=o.message),s.error=new Error(a),s.action="error",this.logger.error(n.fileName(),a)}this.print&&n.log({diff:!0})}else this.logger.unchanged(oa.default.dim(n.fileName()));e.changes[n.fileName()]=s}),Object.keys(e.changes).some(i=>e.changes[i].action==="error")?this.abortTransform({reason:"Encountered an error while transforming files",changes:e.changes}):e}static logResults(e){let r=Object.keys(e.changes);if(it.log(),r.length>0){it.bold("Results:");let i={};r.forEach(n=>{var o;let s=e.changes[n];i[n]={action:s.action,additions:s.additions,deletions:s.deletions,error:((o=s.error)==null?void 0:o.message)||"None"}}),console.table(i),it.log()}}};function hS({transformer:t,rootPath:e,options:r}){let i={transformer:t,rootPath:e,...r},n=new Ji(i),s=new Yn(i);return{log:n,runner:s}}var dS="add-package-manager",HP="Set the `packageManager` key in root `package.json` file",qP="1.1.0";async function mS({root:t,options:e}){let{log:r,runner:i}=hS({transformer:dS,rootPath:t,options:e});r.info('Set "packageManager" key in root "package.json" file...');let n;try{n=await Nc({root:t})}catch{return i.abortTransform({reason:`Unable to determine package manager for ${t}`})}let s=await Uc(),{packageManager:o}=n,a=s[o];if(!a)return i.abortTransform({reason:`Unable to determine package manager version for ${t}`});let l=`${o}@${a}`,c=fS.default.join(t,"package.json"),u=(0,pS.readJsonSync)(c),h=[{name:"package.json",path:t,packageJson:{...u,packageJsonPath:c}}];for(let f of h){let{packageJsonPath:d,...g}=f.packageJson,y={...g,packageManager:l};i.modifyFile({filePath:d,after:y})}return i.finish()}var UP={name:dS,description:HP,introducedIn:qP,transformer:mS},$P=UP;0&&(module.exports={transformer});
43
+ `)}`))),s&&(lr({workspace:{name:"root",paths:e.paths},project:e,to:r,logger:i,options:n}),i.workspaceHeader(),e.workspaceData.workspaces.forEach(a=>{lr({workspace:a,project:e,to:r,logger:i,options:n})}))}async function Yk(t){let{project:e,logger:r,options:i}=t,n=e.workspaceData.globs.length>0;r.mainStep(hr({action:"remove",packageManager:cr.name,project:e}));let s=$e({workspaceRoot:e.paths.root});if(e.paths.workspaceConfig&&n&&(r.subStep('removing "pnpm-workspace.yaml"'),i!=null&&i.dry||(0,He.rmSync)(e.paths.workspaceConfig,{force:!0})),r.subStep(`removing "packageManager" field in ${e.name} root "package.json"`),delete s.packageManager,!(i!=null&&i.dry)){(0,He.writeJSONSync)(e.paths.packageJson,s,{spaces:2});let o=[e.paths.nodeModules,...e.workspaceData.workspaces.map(a=>a.paths.nodeModules)];try{r.subStep('removing "node_modules"'),await Promise.all(o.map(a=>(0,He.rm)(a,{recursive:!0,force:!0})))}catch{throw new Ie("Failed to remove node_modules",{type:"error_removing_node_modules"})}}}async function Kk(t){let{project:e,logger:r,options:i}=t;r.subStep(`removing ${Fr.default.relative(e.paths.root,e.paths.lockfile)}`),i!=null&&i.dry||(0,He.rmSync)(e.paths.lockfile,{force:!0})}async function Vk(t){let{project:e,options:r,logger:i}=t,n=()=>{i.subStep(`converting ${Fr.default.relative(e.paths.root,e.paths.lockfile)} to ${cr.lock}`)},s=async()=>{if(!(r!=null&&r.dry)&&(0,He.existsSync)(e.paths.lockfile))try{await(0,xg.default)(cr.name,["import"],{stdio:"ignore",cwd:e.paths.root})}catch{}finally{Mt({project:e,options:r})}};switch(e.packageManager){case"pnpm":break;case"bun":n(),await Lg({project:e,options:r}),await s(),(0,He.rmSync)(Fr.default.join(e.paths.root,"yarn.lock"),{force:!0});break;case"npm":n(),await s();break;case"yarn":n(),await s();break}}var Zk={detect:Pg,read:zk,create:Wk,remove:Yk,clean:Kk,convertLock:Vk};W();var Ri={name:"npm",lock:"package-lock.json"};async function Ig(t){let e=gn.default.join(t.workspaceRoot,Ri.lock),r=Ws({workspaceRoot:t.workspaceRoot});return(0,Et.existsSync)(e)||r===Ri.name}async function Xk(t){if(!await Ig(t))throw new Ie("Not an npm project",{type:"package_manager-unexpected"});let e=$e(t),{name:r,description:i}=Rn(t),n=Ic({workspaces:e.workspaces});return{name:r,description:i,packageManager:Ri.name,paths:Ys({root:t.workspaceRoot,lockFile:Ri.lock}),workspaceData:{globs:n,workspaces:Ks({workspaceGlobs:n,...t})}}}async function Jk(t){let{project:e,options:r,to:i,logger:n}=t,s=e.workspaceData.globs.length>0;n.mainStep(hr({packageManager:Ri.name,action:"create",project:e}));let o=$e({workspaceRoot:e.paths.root});n.rootHeader(),n.rootStep(`adding "packageManager" field to ${gn.default.relative(e.paths.root,e.paths.packageJson)}`),o.packageManager=`${i.name}@${i.version}`,s?(n.rootStep(`adding "workspaces" field to ${gn.default.relative(e.paths.root,e.paths.packageJson)}`),o.workspaces=e.workspaceData.globs,r!=null&&r.dry||(0,Et.writeJSONSync)(e.paths.packageJson,o,{spaces:2}),lr({workspace:{name:"root",paths:e.paths},project:e,to:i,logger:n,options:r}),n.workspaceHeader(),e.workspaceData.workspaces.forEach(a=>{lr({workspace:a,project:e,to:i,logger:n,options:r})})):r!=null&&r.dry||(0,Et.writeJSONSync)(e.paths.packageJson,o,{spaces:2})}async function Qk(t){let{project:e,logger:r,options:i}=t,n=e.workspaceData.globs.length>0;r.mainStep(hr({packageManager:Ri.name,action:"remove",project:e}));let s=$e({workspaceRoot:e.paths.root});if(n&&(r.subStep(`removing "workspaces" field in ${e.name} root "package.json"`),delete s.workspaces),r.subStep(`removing "packageManager" field in ${e.name} root "package.json"`),delete s.packageManager,!(i!=null&&i.dry)){(0,Et.writeJSONSync)(e.paths.packageJson,s,{spaces:2});let o=[e.paths.nodeModules,...e.workspaceData.workspaces.map(a=>a.paths.nodeModules)];try{r.subStep('removing "node_modules"'),await Promise.all(o.map(a=>(0,Et.rm)(a,{recursive:!0,force:!0})))}catch{throw new Ie("Failed to remove node_modules",{type:"error_removing_node_modules"})}}}async function e1(t){let{project:e,logger:r,options:i}=t;r.subStep(`removing ${gn.default.relative(e.paths.root,e.paths.lockfile)}`),i!=null&&i.dry||(0,Et.rmSync)(e.paths.lockfile,{force:!0})}async function t1(t){let{project:e,options:r}=t;switch(e.packageManager){case"pnpm":Mt({project:e,options:r});break;case"bun":Mt({project:e,options:r});break;case"npm":break;case"yarn":Mt({project:e,options:r});break}}var r1={detect:Ig,read:Xk,create:Jk,remove:Qk,clean:e1,convertLock:t1};W();var Br={name:"yarn",lock:"yarn.lock"};async function Ng(t){let e=xi.default.join(t.workspaceRoot,Br.lock),r=Ws({workspaceRoot:t.workspaceRoot});return(0,vt.existsSync)(e)||r===Br.name}async function i1(t){if(!await Ng(t))throw new Ie("Not a yarn project",{type:"package_manager-unexpected"});let e=$e(t),{name:r,description:i}=Rn(t),n=Ic({workspaces:e.workspaces});return{name:r,description:i,packageManager:Br.name,paths:Ys({root:t.workspaceRoot,lockFile:Br.lock}),workspaceData:{globs:n,workspaces:Ks({workspaceGlobs:n,...t})}}}async function n1(t){let{project:e,to:r,logger:i,options:n}=t,s=e.workspaceData.globs.length>0;i.mainStep(hr({packageManager:Br.name,action:"create",project:e}));let o=$e({workspaceRoot:e.paths.root});i.rootHeader(),i.rootStep(`adding "packageManager" field to ${xi.default.relative(e.paths.root,e.paths.packageJson)}`),o.packageManager=`${r.name}@${r.version}`,s?(i.rootStep(`adding "workspaces" field to ${xi.default.relative(e.paths.root,e.paths.packageJson)}`),o.workspaces=e.workspaceData.globs,n!=null&&n.dry||(0,vt.writeJSONSync)(e.paths.packageJson,o,{spaces:2}),lr({workspace:{name:"root",paths:e.paths},project:e,to:r,logger:i,options:n}),i.workspaceHeader(),e.workspaceData.workspaces.forEach(a=>{lr({workspace:a,project:e,to:r,logger:i,options:n})})):n!=null&&n.dry||(0,vt.writeJSONSync)(e.paths.packageJson,o,{spaces:2})}async function s1(t){let{project:e,logger:r,options:i}=t,n=e.workspaceData.globs.length>0;r.mainStep(hr({packageManager:Br.name,action:"remove",project:e}));let s=$e({workspaceRoot:e.paths.root});if(n&&(r.subStep(`removing "workspaces" field in ${e.name} root "package.json"`),delete s.workspaces),r.subStep(`removing "packageManager" field in ${e.name} root "package.json"`),delete s.packageManager,!(i!=null&&i.dry)){(0,vt.writeJSONSync)(e.paths.packageJson,s,{spaces:2});let o=[e.paths.nodeModules,...e.workspaceData.workspaces.map(a=>a.paths.nodeModules)];try{r.subStep('removing "node_modules"'),await Promise.all(o.map(a=>(0,vt.rm)(a,{recursive:!0,force:!0})))}catch{throw new Ie("Failed to remove node_modules",{type:"error_removing_node_modules"})}}}async function o1(t){let{project:e,logger:r,options:i}=t;r.subStep(`removing ${xi.default.relative(e.paths.root,e.paths.lockfile)}`),i!=null&&i.dry||(0,vt.rmSync)(e.paths.lockfile,{force:!0})}async function a1(t){let{project:e,options:r,logger:i}=t,n=()=>{i.subStep(`converting ${xi.default.relative(e.paths.root,e.paths.lockfile)} to ${Br.lock}`)};switch(e.packageManager){case"pnpm":Mt({project:e,options:r});break;case"bun":n(),await Lg({project:e,options:r});break;case"npm":Mt({project:e,options:r});break;case"yarn":break}}var l1={detect:Ng,read:i1,create:n1,remove:s1,clean:o1,convertLock:a1};W();var Ai={name:"bun",lock:"bun.lockb"};async function Dg(t){let e=_n.default.join(t.workspaceRoot,Ai.lock),r=Ws({workspaceRoot:t.workspaceRoot});return(0,Rt.existsSync)(e)||r===Ai.name}async function c1(t){if(!await Dg(t))throw new Ie("Not a bun project",{type:"package_manager-unexpected"});let e=$e(t),{name:r,description:i}=Rn(t),n=Ic({workspaces:e.workspaces});return{name:r,description:i,packageManager:Ai.name,paths:Ys({root:t.workspaceRoot,lockFile:Ai.lock}),workspaceData:{globs:n,workspaces:Ks({workspaceGlobs:n,...t})}}}async function u1(t){let{project:e,to:r,logger:i,options:n}=t,s=e.workspaceData.globs.length>0;if(!$k({project:e}))throw new Ie("Unable to convert project to bun - workspace globs unsupported",{type:"bun-workspace_glob_error"});i.mainStep(hr({packageManager:Ai.name,action:"create",project:e}));let o=$e({workspaceRoot:e.paths.root});i.rootHeader(),i.rootStep(`adding "packageManager" field to ${_n.default.relative(e.paths.root,e.paths.packageJson)}`),o.packageManager=`${r.name}@${r.version}`,s?(i.rootStep(`adding "workspaces" field to ${_n.default.relative(e.paths.root,e.paths.packageJson)}`),o.workspaces=e.workspaceData.globs,n!=null&&n.dry||(0,Rt.writeJSONSync)(e.paths.packageJson,o,{spaces:2}),lr({workspace:{name:"root",paths:e.paths},project:e,to:r,logger:i,options:n}),i.workspaceHeader(),e.workspaceData.workspaces.forEach(a=>{lr({workspace:a,project:e,to:r,logger:i,options:n})})):n!=null&&n.dry||(0,Rt.writeJSONSync)(e.paths.packageJson,o,{spaces:2})}async function h1(t){let{project:e,logger:r,options:i}=t,n=e.workspaceData.globs.length>0;r.mainStep(hr({packageManager:Ai.name,action:"remove",project:e}));let s=$e({workspaceRoot:e.paths.root});if(n&&(r.subStep(`removing "workspaces" field in ${e.name} root "package.json"`),delete s.workspaces),r.subStep(`removing "packageManager" field in ${e.name} root "package.json"`),delete s.packageManager,!(i!=null&&i.dry)){(0,Rt.writeJSONSync)(e.paths.packageJson,s,{spaces:2});let o=[e.paths.nodeModules,...e.workspaceData.workspaces.map(a=>a.paths.nodeModules)];try{r.subStep('removing "node_modules"'),await Promise.all(o.map(a=>(0,Rt.rm)(a,{recursive:!0,force:!0})))}catch{throw new Ie("Failed to remove node_modules",{type:"error_removing_node_modules"})}}}async function f1(t){let{project:e,logger:r,options:i}=t;r.subStep(`removing ${_n.default.relative(e.paths.root,e.paths.lockfile)}`),i!=null&&i.dry||(0,Rt.rmSync)(e.paths.lockfile,{force:!0})}async function p1(t){let{project:e,options:r}=t;switch(e.packageManager){case"pnpm":Mt({project:e,options:r});break;case"bun":break;case"npm":Mt({project:e,options:r});break;case"yarn":Mt({project:e,options:r});break}}var d1={detect:Dg,read:c1,create:u1,remove:h1,clean:f1,convertLock:p1},Mg={pnpm:Zk,yarn:l1,npm:r1,bun:d1};W();async function Nc({root:t}){let{exists:e,absolute:r}=Uk({directory:t});if(!e)throw new Ie(`Could not find directory at ${r}. Ensure the directory exists.`,{type:"invalid_directory"});for(let{detect:i,read:n}of Object.values(Mg))if(await i({workspaceRoot:r}))return n({workspaceRoot:r});throw new Ie("Could not determine package manager. Add `packageManager` to `package.json` or ensure a lockfile is present.",{type:"package_manager-unable_to_detect"})}W();W();W();W();var S1=ie(Ug());function Mc(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function xn(t){return xn=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},xn(t)}function Fc(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function Bc(t,e){if(e&&(xn(e)==="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Fc(t)}function Hr(t){return Hr=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},Hr(t)}function Ht(t,e){return Ht=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(i,n){return i.__proto__=n,i},Ht(t,e)}function jc(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Ht(t,e)}function Hc(t){return Function.toString.call(t).indexOf("[native code]")!==-1}function qc(){if(typeof Reflect=="undefined"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Oi(t,e,r){return qc()?Oi=Reflect.construct.bind():Oi=function(n,s,o){var a=[null];a.push.apply(a,s);var l=Function.bind.apply(n,a),c=new l;return o&&Ht(c,o.prototype),c},Oi.apply(null,arguments)}function An(t){var e=typeof Map=="function"?new Map:void 0;return An=function(i){if(i===null||!Hc(i))return i;if(typeof i!="function")throw new TypeError("Super expression must either be null or a function");if(typeof e!="undefined"){if(e.has(i))return e.get(i);e.set(i,n)}function n(){return Oi(i,arguments,Hr(this).constructor)}return n.prototype=Object.create(i.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),Ht(n,i)},An(t)}var $g=ie(require("find-up"));var E1=ie(require("fs-extra")),WM=function(t){jc(e,t);function e(r){var i;return Mc(this,e),i=Bc(this,Hr(e).call(this,"No package.json could be found upwards from the directory ".concat(r))),i.directory=r,i}return e}(An(Error));var A1=ie(require("json5"));var v1=ie(require("fs")),R1=ie(require("path"));var M1=ie(require("fs")),F1=ie(require("path"));var B1=ie(Us()),j1=ie(require("json5"));var it={};Ch(it,{bold:()=>C1,dimmed:()=>P1,error:()=>Jg,grey:()=>I1,info:()=>k1,item:()=>N1,log:()=>pr,turboBlue:()=>Ti,turboGradient:()=>T1,turboLoader:()=>Zg,turboRed:()=>Kg,underline:()=>L1,warn:()=>Xg,yellow:()=>Vg});var fr=ie(require("chalk")),Gg=ie(require("ora")),zg=ie(require("gradient-string")),Wg="#0099F7",Yg="#F11712",O1="#FFFF00",T1=(0,zg.default)(Wg,Yg),Ti=fr.default.hex(Wg),Kg=fr.default.hex(Yg),Vg=fr.default.hex(O1),Zg=t=>(0,Gg.default)({text:t,spinner:{frames:[" ",Ti("> "),Ti(">> "),Ti(">>>")]}}),k1=(...t)=>{pr(Ti.bold(">>>"),...t)},C1=(...t)=>{pr(fr.default.bold(...t))},L1=(...t)=>{pr(fr.default.underline(...t))},P1=(...t)=>{pr(fr.default.dim(...t))},I1=(...t)=>{pr(fr.default.grey(...t))},N1=(...t)=>{pr(Ti.bold(" \u2022"),...t)},pr=(...t)=>{console.log(...t)},Xg=(...t)=>{console.error(Vg.bold(">>>"),...t)},Jg=(...t)=>{console.error(Kg.bold(">>>"),...t)};var Qg=ie(require("os")),e_=ie(li());async function Zs(t,e=[],r){let i={cwd:Qg.default.tmpdir(),env:{COREPACK_ENABLE_STRICT:"0"},...r};try{let{stdout:n}=await(0,e_.default)(t,e,i);return n.trim()}catch{return}}async function Uc(){let[t,e,r,i]=await Promise.all([Zs("yarnpkg",["--version"]),Zs("npm",["--version"]),Zs("pnpm",["--version"]),Zs("bun",["--version"])]);return{yarn:t,pnpm:r,npm:e,bun:i}}var H1=ie(require("fs-extra"));var q1=ie(require("path")),U1=ie(require("fs-extra")),$1=ie(require("chalk"));var Qw=require("stream"),eS=require("util"),xP=require("path"),AP=require("os"),tS=require("fs"),OP=ie(Jw());var tB=(0,eS.promisify)(Qw.Stream.pipeline);var rS=require("fs-extra");var FP=ie(require("path")),BP=ie(cS()),jP=ie(require("chalk")),Th=require("fs-extra");var oa=ie(require("chalk"));var dt=ie(require("chalk")),Ji=class{constructor(e){this.transform=e.transformer,this.dry=e.dryRun}_log(...e){console.log(...e)}modified(...e){this._log(dt.default.green(" MODIFIED "),...e,this.dry?dt.default.dim("(dry run)"):"")}unchanged(...e){this._log(dt.default.gray(" UNCHANGED "),...e,this.dry?dt.default.dim("(dry run)"):"")}skipped(...e){this._log(dt.default.yellow(" SKIPPED "),...e,this.dry?dt.default.dim("(dry run)"):"")}error(...e){this._log(dt.default.red(" ERROR "),...e,this.dry?dt.default.dim("(dry run)"):"")}info(...e){this._log(dt.default.bold(" INFO "),...e,this.dry?dt.default.dim("(dry run)"):"")}};var uS=ie(require("os")),kh=ie(require("path"));var ia=ie(require("chalk")),sa=require("diff"),Or=require("fs-extra"),na=class{constructor(e){this.changes=[];if(this.filePath=e.filePath,this.rootPath=e.rootPath,this.after=e.after,this.error=e.error,e.before===void 0)try{kh.default.extname(e.filePath)===".json"?this.before=(0,Or.readJsonSync)(e.filePath):this.before=(0,Or.readFileSync)(e.filePath)}catch{this.before=""}else e.before===null?this.before="":this.before=e.before;e.after?typeof this.before=="object"||typeof e.after=="object"?this.changes=(0,sa.diffJson)(this.before,e.after):this.changes=(0,sa.diffLines)(this.before,e.after):this.changes=[]}fileName(){return kh.default.relative(this.rootPath,this.filePath)}write(){this.after&&(typeof this.after=="object"?(0,Or.writeJsonSync)(this.filePath,this.after,{spaces:2}):(0,Or.writeFileSync)(this.filePath,this.after))}additions(){return this.changes.filter(e=>e.added).length}deletions(){return this.changes.filter(e=>e.removed).length}hasChanges(){return this.additions()>0||this.deletions()>0}log(e){e.diff?(this.changes.forEach(r=>{r.added?process.stdout.write(ia.default.green(r.value)):r.removed?process.stdout.write(ia.default.red(r.value)):process.stdout.write(ia.default.dim(r.value))}),it.log(uS.default.EOL)):it.log(this.after)}};var Yn=class{constructor(e){this.modifications={};this.transform=e.transformer,this.rootPath=e.rootPath,this.dry=e.dryRun,this.print=e.print,this.logger=new Ji(e)}abortTransform(e){return this.logger.error(e.reason),{fatalError:new Error(e.reason),changes:e.changes||{}}}modifyFile(e){this.modifications[e.filePath]=new na({rootPath:this.rootPath,...e})}finish(){let e={changes:{}};return Object.keys(this.modifications).forEach(i=>{let n=this.modifications[i],s={action:"unchanged",additions:n.additions(),deletions:n.deletions()};if(n.hasChanges()){if(this.dry)s.action="skipped",this.logger.skipped(oa.default.dim(n.fileName()));else try{n.write(),s.action="modified",this.logger.modified(oa.default.bold(n.fileName()))}catch(o){let a="Unknown error";o instanceof Error&&(a=o.message),s.error=new Error(a),s.action="error",this.logger.error(n.fileName(),a)}this.print&&n.log({diff:!0})}else this.logger.unchanged(oa.default.dim(n.fileName()));e.changes[n.fileName()]=s}),Object.keys(e.changes).some(i=>e.changes[i].action==="error")?this.abortTransform({reason:"Encountered an error while transforming files",changes:e.changes}):e}static logResults(e){let r=Object.keys(e.changes);if(it.log(),r.length>0){it.bold("Results:");let i={};r.forEach(n=>{var o;let s=e.changes[n];i[n]={action:s.action,additions:s.additions,deletions:s.deletions,error:((o=s.error)==null?void 0:o.message)||"None"}}),console.table(i),it.log()}}};function hS({transformer:t,rootPath:e,options:r}){let i={transformer:t,rootPath:e,...r},n=new Ji(i),s=new Yn(i);return{log:n,runner:s}}var dS="add-package-manager",HP="Set the `packageManager` key in root `package.json` file",qP="1.1.0";async function mS({root:t,options:e}){let{log:r,runner:i}=hS({transformer:dS,rootPath:t,options:e}),n=fS.default.join(t,"package.json"),s=(0,pS.readJsonSync)(n);if("packageManager"in s)return r.info('"packageManager" already set in root "package.json"'),i.finish();r.info('Set "packageManager" key in root "package.json" file...');let o;try{o=await Nc({root:t})}catch{return i.abortTransform({reason:`Unable to determine package manager for ${t}`})}let a=await Uc(),{packageManager:l}=o,c=a[l];if(!c)return i.abortTransform({reason:`Unable to determine package manager version for ${t}`});let u=`${l}@${c}`,h=[{name:"package.json",path:t,packageJson:{...s,packageJsonPath:n}}];for(let f of h){let{packageJsonPath:d,...g}=f.packageJson,y={...g,packageManager:u};i.modifyFile({filePath:d,after:y})}return i.finish()}var UP={name:dS,description:HP,introducedIn:qP,transformer:mS},$P=UP;0&&(module.exports={transformer});
44
44
  /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
45
45
  /*! Bundled license information:
46
46