@turbo/codemod 2.6.4-canary.0 → 2.6.4-canary.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +1 -1
- package/package.json +4 -4
package/dist/cli.js
CHANGED
|
@@ -41,7 +41,7 @@ ${i.message}`:y,k=[x,e,t].filter(Boolean).join(`
|
|
|
41
41
|
`,f=Buffer.byteLength(u),h=Math.floor(Math.log(f)/Math.log(10))+1;return f+h>=Math.pow(10,h)&&(h+=1),h+f+u}};n.parse=(l,c,u)=>new n(s(o(l),c),u);var s=(l,c)=>c?Object.keys(l).reduce((u,f)=>(u[f]=l[f],u),c):l,o=l=>l.replace(/\n$/,"").split(`
|
|
42
42
|
`).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 f=c.split("="),h=f.shift().replace(/^SCHILY\.(dev|ino|nlink)/,"$1");if(!h)return l;let p=f.join("=");return l[h]=/^([A-Z]+\.)?([mac]|birth|creation)time$/.test(h)?new Date(p*1e3):/^[0-9]+$/.test(p)?+p:p,l};e.exports=n}),Qn=te((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)}}),jh=te((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))}}}),tS=te((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)}}),rS=te((t,e)=>{W();var{isAbsolute:r,parse:i}=re("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]}}),aP=te((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)}),iS=te((t,e)=>{"use strict";W();var r=Mh(),i=Bh(),n=Jn(),s=re("fs"),o=re("path"),a=Xn(),l=Qn(),c=(m,_)=>_?(m=a(m).replace(/^\.(\/|$)/,""),l(_)+"/"+m):a(m),u=16*1024*1024,f=Symbol("process"),h=Symbol("file"),p=Symbol("directory"),g=Symbol("symlink"),y=Symbol("hardlink"),b=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"),U=Symbol("awaitDrain"),P=Symbol("ondrain"),q=Symbol("prefix"),V=Symbol("hadError"),K=jh(),N=tS(),A=rS(),L=aP(),j=K(class extends r{constructor(m,_){if(_=_||{},super(_),typeof m!="string")throw new TypeError("path is required");this.path=a(m),this.portable=!!_.portable,this.myuid=process.getuid&&process.getuid()||0,this.myuser=process.env.USER||"",this.maxReadSize=_.maxReadSize||u,this.linkCache=_.linkCache||new Map,this.statCache=_.statCache||new Map,this.preservePaths=!!_.preservePaths,this.cwd=a(_.cwd||process.cwd()),this.strict=!!_.strict,this.noPax=!!_.noPax,this.noMtime=!!_.noMtime,this.mtime=_.mtime||null,this.prefix=_.prefix?a(_.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 _.onwarn=="function"&&this.on("warn",_.onwarn);let R=!1;if(!this.preservePaths){let[E,M]=A(this.path);E&&(this.path=M,R=E)}this.win32=!!_.win32||process.platform==="win32",this.win32&&(this.path=N.decode(this.path.replace(/\\/g,"/")),m=m.replace(/\\/g,"/")),this.absolute=a(_.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,..._){return m==="error"&&(this[V]=!0),super.emit(m,..._)}[k](){s.lstat(this.absolute,(m,_)=>{if(m)return this.emit("error",m);this[C](_)})}[C](m){this.statCache.set(this.absolute,m),this.stat=m,m.isFile()||(m.size=0),this.type=d(m),this.emit("stat",m),this[f]()}[f](){switch(this.type){case"File":return this[h]();case"Directory":return this[p]();case"SymbolicLink":return this[g]();default:return this.end()}}[F](m){return L(m,this.type==="Directory",this.portable)}[q](m){return c(m,this.prefix)}[b](){this.type==="Directory"&&this.portable&&(this.noMtime=!0),this.header=new n({path:this[q](this.path),linkpath:this.type==="Link"?this[q](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[q](this.path),linkpath:this.type==="Link"?this[q](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)}[p](){this.path.slice(-1)!=="/"&&(this.path+="/"),this.stat.size=0,this[b](),this.end()}[g](){s.readlink(this.absolute,(m,_)=>{if(m)return this.emit("error",m);this[O](_)})}[O](m){this.linkpath=a(m),this[b](),this.end()}[y](m){this.type="Link",this.linkpath=a(o.relative(this.cwd,m)),this.stat.size=0,this[b](),this.end()}[h](){if(this.stat.nlink>1){let m=this.stat.dev+":"+this.stat.ino;if(this.linkCache.has(m)){let _=this.linkCache.get(m);if(_.indexOf(this.cwd)===0)return this[y](_)}this.linkCache.set(m,this.absolute)}if(this[b](),this.stat.size===0)return this.end();this[I]()}[I](){s.open(this.absolute,"r",(m,_)=>{if(m)return this.emit("error",m);this[w](_)})}[w](m){if(this.fd=m,this[V])return this[v]();this.blockLen=512*Math.ceil(this.stat.size/512),this.blockRemain=this.blockLen;let _=Math.min(this.blockLen,this.maxReadSize);this.buf=Buffer.allocUnsafe(_),this.offset=0,this.pos=0,this.remain=this.stat.size,this.length=this.buf.length,this[x]()}[x](){let{fd:m,buf:_,offset:R,length:E,pos:M}=this;s.read(m,_,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 _=this.offset===0&&m===this.buf.length?this.buf:this.buf.slice(this.offset,this.offset+m);this.write(_)?this[P]():this[U](()=>this[P]())}[U](m){this.once("drain",m)}write(m){if(this.blockRemain<m.length){let _=new Error("writing more data than expected");return _.path=this.absolute,this.emit("error",_)}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:_,buf:R,offset:E,length:M,pos:B}=this,Z=s.readSync(_,R,E,M,B);this[T](Z),m=!1}finally{if(m)try{this[v](()=>{})}catch{}}}[U](m){m()}[v](m){s.closeSync(this.fd),m()}},D=K(class extends r{constructor(m,_){_=_||{},super(_),this.preservePaths=!!_.preservePaths,this.portable=!!_.portable,this.strict=!!_.strict,this.noPax=!!_.noPax,this.noMtime=!!_.noMtime,this.readEntry=m,this.type=m.type,this.type==="Directory"&&this.portable&&(this.noMtime=!0),this.prefix=_.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:_.mtime||m.mtime,this.atime=this.portable?null:m.atime,this.ctime=this.portable?null:m.ctime,this.linkpath=a(m.linkpath),typeof _.onwarn=="function"&&this.on("warn",_.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[q](this.path),linkpath:this.type==="Link"?this[q](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[q](this.path),linkpath:this.type==="Link"?this[q](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)}[q](m){return c(m,this.prefix)}[F](m){return L(m,this.type==="Directory",this.portable)}write(m){let _=m.length;if(_>this.blockRemain)throw new Error("writing more to entry than is appropriate");return this.blockRemain-=_,super.write(m)}end(){return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),super.end()}});j.Sync=z,j.Tar=D;var d=m=>m.isFile()?"File":m.isDirectory()?"Directory":m.isSymbolicLink()?"SymbolicLink":"Unsupported";e.exports=j}),lP=te((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}}}),nS=te((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(f){l.push(f)});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 f=0;u!==null;f++)c=a(c,u.value,f),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 f=this.length-1;u!==null;f--)c=a(c,u.value,f),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,f=this.head;f!==null&&u<a;u++)f=f.next;for(;f!==null&&u<l;u++,f=f.next)c.push(f.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,f=this.tail;f!==null&&u>l;u--)f=f.prev;for(;f!==null&&u>a;u--,f=f.prev)c.push(f.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,f=this.head;f!==null&&u<a;u++)f=f.next;for(var h=[],u=0;f&&u<l;u++)h.push(f.value),f=this.removeNode(f);f===null&&(f=this.tail),f!==this.head&&f!==this.tail&&(f=f.prev);for(var u=0;u<c.length;u++)f=i(this,f,c[u]);return h},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{lP()(r)}catch{}}),$h=te((t,e)=>{"use strict";W();var r=class{constructor(d,m){this.path=d||"./",this.absolute=m,this.entry=null,this.stat=null,this.readdir=null,this.pending=!1,this.ignore=!1,this.piped=!1}},i=Mh(),n=Qw(),s=Fh(),o=iS(),a=o.Sync,l=o.Tar,c=nS(),u=Buffer.alloc(1024),f=Symbol("onStat"),h=Symbol("ended"),p=Symbol("queue"),g=Symbol("current"),y=Symbol("process"),b=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"),U=Symbol("entry"),P=Symbol("entryOpt"),q=Symbol("writeEntryClass"),V=Symbol("write"),K=Symbol("ondrain"),N=re("fs"),A=re("path"),L=jh(),j=Xn(),z=L(class extends i{constructor(d){super(d),d=d||Object.create(null),this.opt=d,this.file=d.file||"",this.cwd=d.cwd||process.cwd(),this.maxReadSize=d.maxReadSize,this.preservePaths=!!d.preservePaths,this.strict=!!d.strict,this.noPax=!!d.noPax,this.prefix=j(d.prefix||""),this.linkCache=d.linkCache||new Map,this.statCache=d.statCache||new Map,this.readdirCache=d.readdirCache||new Map,this[q]=o,typeof d.onwarn=="function"&&this.on("warn",d.onwarn),this.portable=!!d.portable,this.zip=null,d.gzip?(typeof d.gzip!="object"&&(d.gzip={}),this.portable&&(d.gzip.portable=!0),this.zip=new n.Gzip(d.gzip),this.zip.on("data",m=>super.write(m)),this.zip.on("end",m=>super.end()),this.zip.on("drain",m=>this[K]()),this.on("resume",m=>this.zip.resume())):this.on("drain",this[K]),this.noDirRecurse=!!d.noDirRecurse,this.follow=!!d.follow,this.noMtime=!!d.noMtime,this.mtime=d.mtime||null,this.filter=typeof d.filter=="function"?d.filter:m=>!0,this[p]=new c,this[k]=0,this.jobs=+d.jobs||4,this[b]=!1,this[h]=!1}[V](d){return super.write(d)}add(d){return this.write(d),this}end(d){return d&&this.write(d),this[h]=!0,this[y](),this}write(d){if(this[h])throw new Error("write after end");return d instanceof s?this[O](d):this[T](d),this.flowing}[O](d){let m=j(A.resolve(this.cwd,d.path));if(!this.filter(d.path,d))d.resume();else{let _=new r(d.path,m,!1);_.entry=new l(d,this[P](_)),_.entry.on("end",R=>this[C](_)),this[k]+=1,this[p].push(_)}this[y]()}[T](d){let m=j(A.resolve(this.cwd,d));this[p].push(new r(d,m)),this[y]()}[I](d){d.pending=!0,this[k]+=1;let m=this.follow?"stat":"lstat";N[m](d.absolute,(_,R)=>{d.pending=!1,this[k]-=1,_?this.emit("error",_):this[f](d,R)})}[f](d,m){this.statCache.set(d.absolute,m),d.stat=m,this.filter(d.path,m)||(d.ignore=!0),this[y]()}[w](d){d.pending=!0,this[k]+=1,N.readdir(d.absolute,(m,_)=>{if(d.pending=!1,this[k]-=1,m)return this.emit("error",m);this[v](d,_)})}[v](d,m){this.readdirCache.set(d.absolute,m),d.readdir=m,this[y]()}[y](){if(!this[b]){this[b]=!0;for(let d=this[p].head;d!==null&&this[k]<this.jobs;d=d.next)if(this[x](d.value),d.value.ignore){let m=d.next;this[p].removeNode(d),d.next=m}this[b]=!1,this[h]&&!this[p].length&&this[k]===0&&(this.zip?this.zip.end(u):(super.write(u),super.end()))}}get[g](){return this[p]&&this[p].head&&this[p].head.value}[C](d){this[p].shift(),this[k]-=1,this[y]()}[x](d){if(!d.pending){if(d.entry){d===this[g]&&!d.piped&&this[F](d);return}if(d.stat||(this.statCache.has(d.absolute)?this[f](d,this.statCache.get(d.absolute)):this[I](d)),!!d.stat&&!d.ignore&&!(!this.noDirRecurse&&d.stat.isDirectory()&&!d.readdir&&(this.readdirCache.has(d.absolute)?this[v](d,this.readdirCache.get(d.absolute)):this[w](d),!d.readdir))){if(d.entry=this[U](d),!d.entry){d.ignore=!0;return}d===this[g]&&!d.piped&&this[F](d)}}}[P](d){return{onwarn:(m,_,R)=>this.warn(m,_,R),noPax:this.noPax,cwd:this.cwd,absolute:d.absolute,preservePaths:this.preservePaths,maxReadSize:this.maxReadSize,strict:this.strict,portable:this.portable,linkCache:this.linkCache,statCache:this.statCache,noMtime:this.noMtime,mtime:this.mtime,prefix:this.prefix}}[U](d){this[k]+=1;try{return new this[q](d.path,this[P](d)).on("end",()=>this[C](d)).on("error",m=>this.emit("error",m))}catch(m){this.emit("error",m)}}[K](){this[g]&&this[g].entry&&this[g].entry.resume()}[F](d){d.piped=!0,d.readdir&&d.readdir.forEach(R=>{let E=d.path,M=E==="./"?"":E.replace(/\/*$/,"/");this[T](M+R)});let m=d.entry,_=this.zip;_?m.on("data",R=>{_.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(d){super(d),this[q]=a}pause(){}resume(){}[I](d){let m=this.follow?"statSync":"lstatSync";this[f](d,N[m](d.absolute))}[w](d,m){this[v](d,N.readdirSync(d.absolute))}[F](d){let m=d.entry,_=this.zip;d.readdir&&d.readdir.forEach(R=>{let E=d.path,M=E==="./"?"":E.replace(/\/*$/,"/");this[T](M+R)}),_?m.on("data",R=>{_.write(R)}):m.on("data",R=>{super[V](R)})}};z.Sync=D,e.exports=z}),es=te(t=>{"use strict";W();var e=Xw(),r=re("events").EventEmitter,i=re("fs"),n=i.writev;if(!n){let d=process.binding("fs"),m=d.FSReqWrap||d.FSReqCallback;n=(_,R,E,M)=>{let B=(H,Q)=>M(H,Q,R),Z=new m;Z.oncomplete=B,d.writeBuffers(_,R,E,Z)}}var s=Symbol("_autoClose"),o=Symbol("_close"),a=Symbol("_ended"),l=Symbol("_fd"),c=Symbol("_finished"),u=Symbol("_flags"),f=Symbol("_flush"),h=Symbol("_handleChunk"),p=Symbol("_makeBuf"),g=Symbol("_mode"),y=Symbol("_needDrain"),b=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"),U=Symbol("_reading"),P=Symbol("_remain"),q=Symbol("_size"),V=Symbol("_write"),K=Symbol("_writing"),N=Symbol("_defaultFlag"),A=Symbol("_errored"),L=class extends e{constructor(d,m){if(m=m||{},super(m),this.readable=!0,this.writable=!1,typeof d!="string")throw new TypeError("path must be a string");this[A]=!1,this[l]=typeof m.fd=="number"?m.fd:null,this[O]=d,this[F]=m.readSize||16*1024*1024,this[U]=!1,this[q]=typeof m.size=="number"?m.size:1/0,this[P]=this[q],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",(d,m)=>this[x](d,m))}[x](d,m){d?this[b](d):(this[l]=m,this.emit("open",m),this[v]())}[p](){return Buffer.allocUnsafe(Math.min(this[F],this[P]))}[v](){if(!this[U]){this[U]=!0;let d=this[p]();if(d.length===0)return process.nextTick(()=>this[k](null,0,d));i.read(this[l],d,0,d.length,null,(m,_,R)=>this[k](m,_,R))}}[k](d,m,_){this[U]=!1,d?this[b](d):this[h](m,_)&&this[v]()}[o](){if(this[s]&&typeof this[l]=="number"){let d=this[l];this[l]=null,i.close(d,m=>m?this.emit("error",m):this.emit("close"))}}[b](d){this[U]=!0,this[o](),this.emit("error",d)}[h](d,m){let _=!1;return this[P]-=d,d>0&&(_=super.write(d<m.length?m.slice(0,d):m)),(d===0||this[P]<=0)&&(_=!1,this[o](),super.end()),_}emit(d,m){switch(d){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(d,m));default:return super.emit(d,m)}}},j=class extends L{[T](){let d=!0;try{this[x](null,i.openSync(this[O],"r")),d=!1}finally{d&&this[o]()}}[v](){let d=!0;try{if(!this[U]){this[U]=!0;do{let m=this[p](),_=m.length===0?0:i.readSync(this[l],m,0,m.length,null);if(!this[h](_,m))break}while(!0);this[U]=!1}d=!1}finally{d&&this[o]()}}[o](){if(this[s]&&typeof this[l]=="number"){let d=this[l];this[l]=null,i.closeSync(d),this.emit("close")}}},z=class extends r{constructor(d,m){m=m||{},super(m),this.readable=!1,this.writable=!0,this[A]=!1,this[K]=!1,this[a]=!1,this[y]=!1,this[w]=[],this[O]=d,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 _=this[I]!==null?"r+":"w";this[N]=m.flags===void 0,this[u]=this[N]?_:m.flags,this[l]===null&&this[T]()}emit(d,m){if(d==="error"){if(this[A])return;this[A]=!0}return super.emit(d,m)}get fd(){return this[l]}get path(){return this[O]}[b](d){this[o](),this[K]=!0,this.emit("error",d)}[T](){i.open(this[O],this[u],this[g],(d,m)=>this[x](d,m))}[x](d,m){this[N]&&this[u]==="r+"&&d&&d.code==="ENOENT"?(this[u]="w",this[T]()):d?this[b](d):(this[l]=m,this.emit("open",m),this[f]())}end(d,m){return d&&this.write(d,m),this[a]=!0,!this[K]&&!this[w].length&&typeof this[l]=="number"&&this[C](null,0),this}write(d,m){return typeof d=="string"&&(d=Buffer.from(d,m)),this[a]?(this.emit("error",new Error("write() after end()")),!1):this[l]===null||this[K]||this[w].length?(this[w].push(d),this[y]=!0,!1):(this[K]=!0,this[V](d),!0)}[V](d){i.write(this[l],d,0,d.length,this[I],(m,_)=>this[C](m,_))}[C](d,m){d?this[b](d):(this[I]!==null&&(this[I]+=m),this[w].length?this[f]():(this[K]=!1,this[a]&&!this[c]?(this[c]=!0,this[o](),this.emit("finish")):this[y]&&(this[y]=!1,this.emit("drain"))))}[f](){if(this[w].length===0)this[a]&&this[C](null,0);else if(this[w].length===1)this[V](this[w].pop());else{let d=this[w];this[w]=[],n(this[l],d,this[I],(m,_)=>this[C](m,_))}}[o](){if(this[s]&&typeof this[l]=="number"){let d=this[l];this[l]=null,i.close(d,m=>m?this.emit("error",m):this.emit("close"))}}},D=class extends z{[T](){let d;if(this[N]&&this[u]==="r+")try{d=i.openSync(this[O],this[u],this[g])}catch(m){if(m.code==="ENOENT")return this[u]="w",this[T]();throw m}else d=i.openSync(this[O],this[u],this[g]);this[x](null,d)}[o](){if(this[s]&&typeof this[l]=="number"){let d=this[l];this[l]=null,i.closeSync(d),this.emit("close")}}[V](d){let m=!0;try{this[C](null,i.writeSync(this[l],d,0,d.length,this[I])),m=!1}finally{if(m)try{this[o]()}catch{}}}};t.ReadStream=L,t.ReadStreamSync=j,t.WriteStream=z,t.WriteStreamSync=D}),Uh=te((t,e)=>{"use strict";W();var r=jh(),i=Jn(),n=re("events"),s=nS(),o=1024*1024,a=Fh(),l=Bh(),c=Qw(),{nextTick:u}=re("process"),f=Buffer.from([31,139]),h=Symbol("state"),p=Symbol("writeEntry"),g=Symbol("readEntry"),y=Symbol("nextEntry"),b=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"),U=Symbol("unzip"),P=Symbol("consumeChunk"),q=Symbol("consumeChunkSub"),V=Symbol("consumeBody"),K=Symbol("consumeMeta"),N=Symbol("consumeHeader"),A=Symbol("consuming"),L=Symbol("bufferConcat"),j=Symbol("maybeEnd"),z=Symbol("writing"),D=Symbol("aborted"),d=Symbol("onDone"),m=Symbol("sawValidEntry"),_=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(d,Z=>{(this[h]==="begin"||this[m]===!1)&&this.warn("TAR_BAD_ARCHIVE","Unrecognized archive format")}),B.ondone?this.on(d,B.ondone):this.on(d,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[p]=null,this[h]="begin",this[C]="",this[x]=null,this[k]=null,this[w]=!1,this[U]=null,this[D]=!1,this[_]=!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 H;try{H=new i(B,Z,this[x],this[k])}catch(Q){return this.warn("TAR_ENTRY_INVALID",Q)}if(H.nullBlock)this[_]?(this[R]=!0,this[h]==="begin"&&(this[h]="header"),this[F]("eof")):(this[_]=!0,this[F]("nullBlock"));else if(this[_]=!1,!H.cksumValid)this.warn("TAR_ENTRY_INVALID","checksum failure",{header:H});else if(!H.path)this.warn("TAR_ENTRY_INVALID","path is required",{header:H});else{let Q=H.type;if(/^(Symbolic)?Link$/.test(Q)&&!H.linkpath)this.warn("TAR_ENTRY_INVALID","linkpath required",{header:H});else if(!/^(Symbolic)?Link$/.test(Q)&&H.linkpath)this.warn("TAR_ENTRY_INVALID","linkpath forbidden",{header:H});else{let G=this[p]=new a(H,this[x],this[k]);if(!this[m])if(G.remain){let ie=()=>{G.invalid||(this[m]=!0)};G.on("end",ie)}else this[m]=!0;G.meta?G.size>this.maxMetaEntrySize?(G.ignore=!0,this[F]("ignoredEntry",G),this[h]="ignore",G.resume()):G.size>0&&(this[C]="",G.on("data",ie=>this[C]+=ie),this[h]="meta"):(this[x]=null,G.ignore=G.ignore||!this.filter(G.path,G),G.ignore?(this[F]("ignoredEntry",G),this[h]=G.remain?"ignore":"header",G.resume()):(G.remain?this[h]="body":(this[h]="header",G.end()),this[g]?this[I].push(G):(this[I].push(G),this[y]())))}}}[E](){u(()=>this.emit("close"))}[b](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",H=>this[y]()),Z=!1)):(this[g]=null,Z=!1),Z}[y](){do;while(this[b](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"))}}[V](B,Z){let H=this[p],Q=H.blockRemain,G=Q>=B.length&&Z===0?B:B.slice(Z,Z+Q);return H.write(G),H.blockRemain||(this[h]="header",this[p]=null,H.end()),G.length}[K](B,Z){let H=this[p],Q=this[V](B,Z);return this[p]||this[T](H),Q}[F](B,Z,H){!this[I].length&&!this[g]?this.emit(B,Z,H):this[I].push([B,Z,H])}[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[U]===null&&B){if(this[O]&&(B=Buffer.concat([this[O],B]),this[O]=null),B.length<f.length)return this[O]=B,!0;for(let H=0;this[U]===null&&H<f.length;H++)B[H]!==f[H]&&(this[U]=!1);if(this[U]===null){let H=this[w];this[w]=!1,this[U]=new c.Unzip,this[U].on("data",G=>this[P](G)),this[U].on("error",G=>this.abort(G)),this[U].on("end",G=>{this[w]=!0,this[P]()}),this[z]=!0;let Q=this[U][H?"end":"write"](B);return this[z]=!1,Q}}this[z]=!0,this[U]?this[U].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",H=>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[p];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](d)}}[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[q](Z)}else this[q](B);for(;this[O]&&this[O].length>=512&&!this[D]&&!this[R];){let Z=this[O];this[O]=null,this[q](Z)}this[A]=!1}(!this[O]||this[w])&&this[j]()}[q](B){let Z=0,H=B.length;for(;Z+512<=H&&!this[D]&&!this[R];)switch(this[h]){case"begin":case"header":this[N](B,Z),Z+=512;break;case"ignore":case"body":Z+=this[V](B,Z);break;case"meta":Z+=this[K](B,Z);break;default:throw new Error("invalid state: "+this[h])}Z<H&&(this[O]?this[O]=Buffer.concat([B.slice(Z),this[O]]):this[O]=B.slice(Z))}end(B){this[D]||(this[U]?this[U].end(B):(this[w]=!0,this.write(B)))}})}),Hh=te((t,e)=>{"use strict";W();var r=Zn(),i=Uh(),n=re("fs"),s=es(),o=re("path"),a=Qn();e.exports=(p,g,y)=>{typeof p=="function"?(y=p,g=null,p={}):Array.isArray(p)&&(g=p,p={}),typeof g=="function"&&(y=g,g=null),g?g=Array.from(g):g=[];let b=r(p);if(b.sync&&typeof y=="function")throw new TypeError("callback not supported for sync tar functions");if(!b.file&&typeof y=="function")throw new TypeError("callback only supported with file option");return g.length&&c(b,g),b.noResume||l(b),b.file&&b.sync?u(b):b.file?f(b,y):h(b)};var l=p=>{let g=p.onentry;p.onentry=g?y=>{g(y),y.resume()}:y=>y.resume()},c=(p,g)=>{let y=new Map(g.map(k=>[a(k),!0])),b=p.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};p.filter=b?(k,C)=>b(k,C)&&x(a(k)):k=>x(a(k))},u=p=>{let g=h(p),y=p.file,b=!0,x;try{let k=n.statSync(y),C=p.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()}b=!1}finally{if(b&&x)try{n.closeSync(x)}catch{}}},f=(p,g)=>{let y=new i(p),b=p.maxReadSize||16*1024*1024,x=p.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:b,size:I.size});w.on("error",T),w.pipe(y)}})});return g?k.then(g,g):k},h=p=>new i(p)}),cP=te((t,e)=>{"use strict";W();var r=Zn(),i=$h(),n=es(),s=Hh(),o=re("path");e.exports=(p,g,y)=>{if(typeof g=="function"&&(y=g),Array.isArray(p)&&(g=p,p={}),!g||!Array.isArray(g)||!g.length)throw new TypeError("no files or directories specified");g=Array.from(g);let b=r(p);if(b.sync&&typeof y=="function")throw new TypeError("callback not supported for sync tar functions");if(!b.file&&typeof y=="function")throw new TypeError("callback only supported with file option");return b.file&&b.sync?a(b,g):b.file?l(b,g,y):b.sync?f(b,g):h(b,g)};var a=(p,g)=>{let y=new i.Sync(p),b=new n.WriteStreamSync(p.file,{mode:p.mode||438});y.pipe(b),c(y,g)},l=(p,g,y)=>{let b=new i(p),x=new n.WriteStream(p.file,{mode:p.mode||438});b.pipe(x);let k=new Promise((C,T)=>{x.on("error",T),x.on("close",C),b.on("error",T)});return u(b,g),y?k.then(y,y):k},c=(p,g)=>{g.forEach(y=>{y.charAt(0)==="@"?s({file:o.resolve(p.cwd,y.slice(1)),sync:!0,noResume:!0,onentry:b=>p.add(b)}):p.add(y)}),p.end()},u=(p,g)=>{for(;g.length;){let y=g.shift();if(y.charAt(0)==="@")return s({file:o.resolve(p.cwd,y.slice(1)),noResume:!0,onentry:b=>p.add(b)}).then(b=>u(p,g));p.add(y)}p.end()},f=(p,g)=>{let y=new i.Sync(p);return c(y,g),y},h=(p,g)=>{let y=new i(p);return u(y,g),y}}),sS=te((t,e)=>{"use strict";W();var r=Zn(),i=$h(),n=re("fs"),s=es(),o=Hh(),a=re("path"),l=Jn();e.exports=(g,y,b)=>{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):f(x,y,b)};var c=(g,y)=>{let b=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,b,C,k,y)}finally{if(x)try{n.closeSync(k)}catch{}}},u=(g,y,b,x,k)=>{let C=new s.WriteStreamSync(g.file,{fd:x,start:b});y.pipe(C),h(y,k)},f=(g,y,b)=>{y=Array.from(y);let x=new i(g),k=(T,O,I)=>{let w=(q,V)=>{q?n.close(T,K=>I(q)):I(null,V)},v=0;if(O===0)return w(null,0);let F=0,U=Buffer.alloc(512),P=(q,V)=>{if(q)return w(q);if(F+=V,F<512&&V)return n.read(T,U,F,U.length-F,v+F,P);if(v===0&&U[0]===31&&U[1]===139)return w(new Error("cannot append to compressed archives"));if(F<512)return w(null,v);let K=new l(U);if(!K.cksumValid)return w(null,v);let N=512*Math.ceil(K.size/512);if(v+N+512>O||(v+=N+512,v>=O))return w(null,v);g.mtimeCache&&g.mtimeCache.set(K.path,K.mtime),F=0,n.read(T,U,0,512,v,P)};n.read(T,U,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,(U,P)=>{if(U)return n.close(F,()=>O(U));k(F,P.size,(q,V)=>{if(q)return O(q);let K=new s.WriteStream(g.file,{fd:F,start:V});x.pipe(K),K.on("error",O),K.on("close",T),p(x,y)})})};n.open(g.file,I,w)});return b?C.then(b,b):C},h=(g,y)=>{y.forEach(b=>{b.charAt(0)==="@"?o({file:a.resolve(g.cwd,b.slice(1)),sync:!0,noResume:!0,onentry:x=>g.add(x)}):g.add(b)}),g.end()},p=(g,y)=>{for(;y.length;){let b=y.shift();if(b.charAt(0)==="@")return o({file:a.resolve(g.cwd,b.slice(1)),noResume:!0,onentry:x=>g.add(x)}).then(x=>p(g,y));g.add(b)}g.end()}}),uP=te((t,e)=>{"use strict";W();var r=Zn(),i=sS();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)}}),hP=te((t,e)=>{W();var{promisify:r}=re("util"),i=re("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}),fP=te((t,e)=>{W();var r=process.env.__TESTING_MKDIRP_PLATFORM__||process.platform,{resolve:i,parse:n}=re("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}),pP=te((t,e)=>{W();var{dirname:r}=re("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}}),oS=te((t,e)=>{W();var{dirname:r}=re("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}}),dP=te((t,e)=>{W();var{dirname:r}=re("path"),{findMade:i,findMadeSync:n}=pP(),{mkdirpManual:s,mkdirpManualSync:o}=oS(),a=(c,u)=>(u.recursive=!0,r(c)===c?u.mkdirAsync(c,u):i(u,c).then(f=>u.mkdirAsync(c,u).then(()=>f).catch(h=>{if(h.code==="ENOENT")return s(c,u);throw h}))),l=(c,u)=>{if(u.recursive=!0,r(c)===c)return u.mkdirSync(c,u);let f=n(u,c);try{return u.mkdirSync(c,u),f}catch(h){if(h.code==="ENOENT")return o(c,u);throw h}};e.exports={mkdirpNative:a,mkdirpNativeSync:l}}),mP=te((t,e)=>{W();var r=re("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}}),gP=te((t,e)=>{W();var r=hP(),i=fP(),{mkdirpNative:n,mkdirpNativeSync:s}=dP(),{mkdirpManual:o,mkdirpManualSync:a}=oS(),{useNative:l,useNativeSync:c}=mP(),u=(h,p)=>(h=i(h),p=r(p),l(p)?n(h,p):o(h,p)),f=(h,p)=>(h=i(h),p=r(p),c(p)?s(h,p):a(h,p));u.sync=f,u.native=(h,p)=>n(i(h),r(p)),u.manual=(h,p)=>o(i(h),r(p)),u.nativeSync=(h,p)=>s(i(h),r(p)),u.manualSync=(h,p)=>a(i(h),r(p)),e.exports=u}),yP=te((t,e)=>{"use strict";W();var r=re("fs"),i=re("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),f=process.version,h=(C,T,O)=>r.readdir(C,T,O),p=(C,T)=>r.readdirSync(C,T);/^v4\./.test(f)&&(h=(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())b(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)}},b=(C,T,O,I)=>{h(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,U=null,P=q=>{if(!U){if(q)return I(U=q);if(--F===0)return g(C,T,O,I)}};v.forEach(q=>y(C,q,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=p(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=b,b.sync=k}),bP=te((t,e)=>{"use strict";W();var r=gP(),i=re("fs"),n=re("path"),s=yP(),o=Xn(),a=class extends Error{constructor(y,b){super("Cannot extract through symbolic link"),this.path=b,this.symlink=y}get name(){return"SylinkError"}},l=class extends Error{constructor(y,b){super(b+": Cannot cd into '"+y+"'"),this.path=y,this.code=b}get name(){return"CwdError"}},c=(y,b)=>y.get(o(b)),u=(y,b,x)=>y.set(o(b),x),f=(y,b)=>{i.stat(y,(x,k)=>{(x||!k.isDirectory())&&(x=new l(y,x&&x.code||"ENOTDIR")),b(x)})};e.exports=(y,b,x)=>{y=o(y);let k=b.umask,C=b.mode|448,T=(C&k)!==0,O=b.uid,I=b.gid,w=typeof O=="number"&&typeof I=="number"&&(O!==b.processUid||I!==b.processGid),v=b.preserve,F=b.unlink,U=b.cache,P=o(b.cwd),q=(K,N)=>{K?x(K):(u(U,y,!0),N&&w?s(N,O,I,A=>q(A)):T?i.chmod(y,C,x):x())};if(U&&c(U,y)===!0)return q();if(y===P)return f(y,q);if(v)return r(y,{mode:C}).then(K=>q(null,K),q);let V=o(n.relative(P,y)).split("/");h(P,V,C,U,F,P,null,q)};var h=(y,b,x,k,C,T,O,I)=>{if(!b.length)return I(null,O);let w=b.shift(),v=o(n.resolve(y+"/"+w));if(c(k,v))return h(v,b,x,k,C,T,O,I);i.mkdir(v,x,p(v,b,x,k,C,T,O,I))},p=(y,b,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())h(y,b,x,k,C,T,O,I);else if(C)i.unlink(y,U=>{if(U)return I(U);i.mkdir(y,x,p(y,b,x,k,C,T,O,I))});else{if(F.isSymbolicLink())return I(new a(y,y+"/"+b.join("/")));I(w)}}):(O=O||y,h(y,b,x,k,C,T,O,I))},g=y=>{let b=!1,x="ENOTDIR";try{b=i.statSync(y).isDirectory()}catch(k){x=k.code}finally{if(!b)throw new l(y,x)}};e.exports.sync=(y,b)=>{y=o(y);let x=b.umask,k=b.mode|448,C=(k&x)!==0,T=b.uid,O=b.gid,I=typeof T=="number"&&typeof O=="number"&&(T!==b.processUid||O!==b.processGid),w=b.preserve,v=b.unlink,F=b.cache,U=o(b.cwd),P=K=>{u(F,y,!0),K&&I&&s.sync(K,T,O),C&&i.chmodSync(y,k)};if(F&&c(F,y)===!0)return P();if(y===U)return g(U),P();if(w)return P(r.sync(y,k));let q=o(n.relative(U,y)).split("/"),V=null;for(let K=q.shift(),N=U;K&&(N+="/"+K);K=q.shift())if(N=o(n.resolve(N)),!c(F,N))try{i.mkdirSync(N,k),V=V||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),V=V||N,u(F,N,!0);continue}else if(A.isSymbolicLink())return new a(N,N+"/"+q.join("/"))}return P(V)}}),aS=te((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])}),_P=te((t,e)=>{W();var r=re("assert"),i=aS(),n=Qn(),{join:s}=re("path"),o=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,a=o==="win32";e.exports=()=>{let l=new Map,c=new Map,u=b=>b.split("/").slice(0,-1).reduce((x,k)=>(x.length&&(k=s(x[x.length-1],k)),x.push(k||"/"),x),[]),f=new Set,h=b=>{let x=c.get(b);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))}},p=b=>{let{paths:x,dirs:k}=h(b);return x.every(C=>C[0]===b)&&k.every(C=>C[0]instanceof Set&&C[0].has(b))},g=b=>f.has(b)||!p(b)?!1:(f.add(b),b(()=>y(b)),!0),y=b=>{if(!f.has(b))return!1;let{paths:x,dirs:k}=c.get(b),C=new Set;return x.forEach(T=>{let O=l.get(T);r.equal(O[0],b),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(b)}),f.delete(b),C.forEach(T=>g(T)),!0};return{check:p,reserve:(b,x)=>{b=a?["win32 parallelization disabled"]:b.map(C=>i(n(s(C))).toLowerCase());let k=new Set(b.map(C=>u(C)).reduce((C,T)=>C.concat(T)));return c.set(x,{dirs:k,paths:b}),b.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)}}}}),wP=te((t,e)=>{W();var r=process.env.__FAKE_PLATFORM__||process.platform,i=r==="win32",n=global.__FAKE_TESTING_FS__||re("fs"),{O_CREAT:s,O_TRUNC:o,O_WRONLY:a,UV_FS_O_FILEMAP:l=0}=n.constants,c=i&&!!l,u=512*1024,f=l|o|s|a;e.exports=c?h=>h<u?f:"w":()=>"w"}),lS=te((t,e)=>{"use strict";W();var r=re("assert"),i=Uh(),n=re("fs"),s=es(),o=re("path"),a=bP(),l=tS(),c=_P(),u=rS(),f=Xn(),h=Qn(),p=aS(),g=Symbol("onEntry"),y=Symbol("checkFs"),b=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"),U=Symbol("checkPath"),P=Symbol("mkdir"),q=Symbol("onError"),V=Symbol("pending"),K=Symbol("pend"),N=Symbol("unpend"),A=Symbol("ended"),L=Symbol("maybeClose"),j=Symbol("skip"),z=Symbol("doChown"),D=Symbol("uid"),d=Symbol("gid"),m=Symbol("checkedCwd"),_=re("crypto"),R=wP(),E=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,M=E==="win32",B=(S,Y)=>{if(!M)return n.unlink(S,Y);let J=S+".DELETE."+_.randomBytes(16).toString("hex");n.rename(S,J,oe=>{if(oe)return Y(oe);n.unlink(J,Y)})},Z=S=>{if(!M)return n.unlinkSync(S);let Y=S+".DELETE."+_.randomBytes(16).toString("hex");n.renameSync(S,Y),n.unlinkSync(Y)},H=(S,Y,J)=>S===S>>>0?S:Y===Y>>>0?Y:J,Q=S=>p(h(f(S))).toLowerCase(),G=(S,Y)=>{Y=Q(Y);for(let J of S.keys()){let oe=Q(J);(oe===Y||oe.indexOf(Y+"/")===0)&&S.delete(J)}},ie=S=>{for(let Y of S.keys())S.delete(Y)},ue=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[V]=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=f(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,J={}){return(S==="TAR_BAD_ARCHIVE"||S==="TAR_ABORT")&&(J.recoverable=!1),super.warn(S,Y,J)}[L](){this[A]&&this[V]===0&&(this.emit("prefinish"),this.emit("finish"),this.emit("end"))}[U](S){if(this.strip){let Y=f(S.path).split("/");if(Y.length<this.strip)return!1;if(S.path=Y.slice(this.strip).join("/"),S.type==="Link"){let J=f(S.linkpath).split("/");if(J.length>=this.strip)S.linkpath=J.slice(this.strip).join("/");else return!1}}if(!this.preservePaths){let Y=f(S.path),J=Y.split("/");if(J.includes("..")||M&&/^[a-z]:\.\.$/i.test(J[0]))return this.warn("TAR_ENTRY_ERROR","path contains '..'",{entry:S,path:Y}),!1;let[oe,ce]=u(Y);oe&&(S.path=ce,this.warn("TAR_ENTRY_INFO",`stripping ${oe} from absolute path`,{entry:S,path:Y}))}if(o.isAbsolute(S.path)?S.absolute=f(o.resolve(S.path)):S.absolute=f(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:f(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:J}=o.win32.parse(S.path);S.path=J+l.encode(S.path.slice(J.length))}return!0}[g](S){if(!this[U](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)}}[q](S,Y){S.name==="CwdError"?this.emit("error",S):(this.warn("TAR_ENTRY_ERROR",S,{entry:Y}),this[N](),Y.resume())}[P](S,Y,J){a(f(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},J)}[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 H(this.uid,S.uid,this.processUid)}[d](S){return H(this.gid,S.gid,this.processGid)}[T](S,Y){let J=S.mode&4095||this.fmode,oe=new s.WriteStream(S.absolute,{flags:R(S.size),mode:J,autoClose:!1});oe.on("error",pe=>{oe.fd&&n.close(oe.fd,()=>{}),oe.write=()=>!0,this[q](pe,S),Y()});let ce=1,be=pe=>{if(pe){oe.fd&&n.close(oe.fd,()=>{}),this[q](pe,S),Y();return}--ce===0&&n.close(oe.fd,Re=>{Re?this[q](Re,S):this[N](),Y()})};oe.on("finish",pe=>{let Re=S.absolute,pt=oe.fd;if(S.mtime&&!this.noMtime){ce++;let dt=S.atime||new Date,ln=S.mtime;n.futimes(pt,dt,ln,cn=>cn?n.utimes(Re,dt,ln,wa=>be(wa&&cn)):be())}if(this[z](S)){ce++;let dt=this[D](S),ln=this[d](S);n.fchown(pt,dt,ln,cn=>cn?n.chown(Re,dt,ln,wa=>be(wa&&cn)):be())}be()});let he=this.transform&&this.transform(S)||S;he!==S&&(he.on("error",pe=>{this[q](pe,S),Y()}),S.pipe(he)),he.pipe(oe)}[O](S,Y){let J=S.mode&4095||this.dmode;this[P](S.absolute,J,oe=>{if(oe){this[q](oe,S),Y();return}let ce=1,be=he=>{--ce===0&&(Y(),this[N](),S.resume())};S.mtime&&!this.noMtime&&(ce++,n.utimes(S.absolute,S.atime||new Date,S.mtime,be)),this[z](S)&&(ce++,n.chown(S.absolute,this[D](S),this[d](S),be)),be()})}[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 J=f(o.resolve(this.cwd,S.linkpath));this[I](S,J,"link",Y)}[K](){this[V]++}[N](){this[V]--,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[K]();let Y=[S.path];S.linkpath&&Y.push(S.linkpath),this.reservations.reserve(Y,J=>this[b](S,J))}[x](S){S.type==="SymbolicLink"?ie(this.dirCache):S.type!=="Directory"&&G(this.dirCache,S.absolute)}[b](S,Y){this[x](S);let J=he=>{this[x](S),Y(he)},oe=()=>{this[P](this.cwd,this.dmode,he=>{if(he){this[q](he,S),J();return}this[m]=!0,ce()})},ce=()=>{if(S.absolute!==this.cwd){let he=f(o.dirname(S.absolute));if(he!==this.cwd)return this[P](he,this.dmode,pe=>{if(pe){this[q](pe,S),J();return}be()})}be()},be=()=>{n.lstat(S.absolute,(he,pe)=>{if(pe&&(this.keep||this.newer&&pe.mtime>S.mtime)){this[j](S),J();return}if(he||this[k](S,pe))return this[C](null,S,J);if(pe.isDirectory()){if(S.type==="Directory"){let Re=!this.noChmod&&S.mode&&(pe.mode&4095)!==S.mode,pt=dt=>this[C](dt,S,J);return Re?n.chmod(S.absolute,S.mode,pt):pt()}if(S.absolute!==this.cwd)return n.rmdir(S.absolute,Re=>this[C](Re,S,J))}if(S.absolute===this.cwd)return this[C](null,S,J);B(S.absolute,Re=>this[C](Re,S,J))})};this[m]?ce():oe()}[C](S,Y,J){if(S){this[q](S,Y),J();return}switch(Y.type){case"File":case"OldFile":case"ContiguousFile":return this[T](Y,J);case"Link":return this[v](Y,J);case"SymbolicLink":return this[w](Y,J);case"Directory":case"GNUDumpDir":return this[O](Y,J)}}[I](S,Y,J,oe){n[J](Y,S.absolute,ce=>{ce?this[q](ce,S):(this[N](),S.resume()),oe()})}},Ee=S=>{try{return[null,S()]}catch(Y){return[Y,null]}},_e=class extends ue{[C](S,Y){return super[C](S,Y,()=>{})}[y](S){if(this[x](S),!this[m]){let ce=this[P](this.cwd,this.dmode);if(ce)return this[q](ce,S);this[m]=!0}if(S.absolute!==this.cwd){let ce=f(o.dirname(S.absolute));if(ce!==this.cwd){let be=this[P](ce,this.dmode);if(be)return this[q](be,S)}}let[Y,J]=Ee(()=>n.lstatSync(S.absolute));if(J&&(this.keep||this.newer&&J.mtime>S.mtime))return this[j](S);if(Y||this[k](S,J))return this[C](null,S);if(J.isDirectory()){if(S.type==="Directory"){let be=!this.noChmod&&S.mode&&(J.mode&4095)!==S.mode,[he]=be?Ee(()=>{n.chmodSync(S.absolute,S.mode)}):[];return this[C](he,S)}let[ce]=Ee(()=>n.rmdirSync(S.absolute));this[C](ce,S)}let[oe]=S.absolute===this.cwd?[]:Ee(()=>Z(S.absolute));this[C](oe,S)}[T](S,Y){let J=S.mode&4095||this.fmode,oe=he=>{let pe;try{n.closeSync(ce)}catch(Re){pe=Re}(he||pe)&&this[q](he||pe,S),Y()},ce;try{ce=n.openSync(S.absolute,R(S.size),J)}catch(he){return oe(he)}let be=this.transform&&this.transform(S)||S;be!==S&&(be.on("error",he=>this[q](he,S)),S.pipe(be)),be.on("data",he=>{try{n.writeSync(ce,he,0,he.length)}catch(pe){oe(pe)}}),be.on("end",he=>{let pe=null;if(S.mtime&&!this.noMtime){let Re=S.atime||new Date,pt=S.mtime;try{n.futimesSync(ce,Re,pt)}catch(dt){try{n.utimesSync(S.absolute,Re,pt)}catch{pe=dt}}}if(this[z](S)){let Re=this[D](S),pt=this[d](S);try{n.fchownSync(ce,Re,pt)}catch(dt){try{n.chownSync(S.absolute,Re,pt)}catch{pe=pe||dt}}}oe(pe)})}[O](S,Y){let J=S.mode&4095||this.dmode,oe=this[P](S.absolute,J);if(oe){this[q](oe,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[d](S))}catch{}Y(),S.resume()}[P](S,Y){try{return a.sync(f(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(J){return J}}[I](S,Y,J,oe){try{n[J+"Sync"](Y,S.absolute),oe(),S.resume()}catch(ce){return this[q](ce,S)}}};ue.Sync=_e,e.exports=ue}),SP=te((t,e)=>{"use strict";W();var r=Zn(),i=lS(),n=re("fs"),s=es(),o=re("path"),a=Qn();e.exports=(p,g,y)=>{typeof p=="function"?(y=p,g=null,p={}):Array.isArray(p)&&(g=p,p={}),typeof g=="function"&&(y=g,g=null),g?g=Array.from(g):g=[];let b=r(p);if(b.sync&&typeof y=="function")throw new TypeError("callback not supported for sync tar functions");if(!b.file&&typeof y=="function")throw new TypeError("callback only supported with file option");return g.length&&l(b,g),b.file&&b.sync?c(b):b.file?u(b,y):b.sync?f(b):h(b)};var l=(p,g)=>{let y=new Map(g.map(k=>[a(k),!0])),b=p.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};p.filter=b?(k,C)=>b(k,C)&&x(a(k)):k=>x(a(k))},c=p=>{let g=new i.Sync(p),y=p.file,b=n.statSync(y),x=p.maxReadSize||16*1024*1024;new s.ReadStreamSync(y,{readSize:x,size:b.size}).pipe(g)},u=(p,g)=>{let y=new i(p),b=p.maxReadSize||16*1024*1024,x=p.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:b,size:I.size});w.on("error",T),w.pipe(y)}})});return g?k.then(g,g):k},f=p=>new i.Sync(p),h=p=>new i(p)}),EP=te(t=>{"use strict";W(),t.c=t.create=cP(),t.r=t.replace=sS(),t.t=t.list=Hh(),t.u=t.update=uP(),t.x=t.extract=SP(),t.Pack=$h(),t.Unpack=lS(),t.Parse=Uh(),t.ReadEntry=Fh(),t.WriteEntry=iS(),t.Header=Jn(),t.Pax=Bh(),t.types=eS()}),vP=te((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}}),RP=te(t=>{W();var e=vP();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),f=Array.prototype.slice.call(arguments,1),h=f.pop();f.push(function(p){u.retry(p)||(p&&(arguments[0]=u.mainError()),h.apply(this,arguments))}),u.attempt(function(){c.apply(r,f)})}.bind(r,l),r[a].options=i}}}),xP=te((t,e)=>{W(),e.exports=RP()}),AP=te((t,e)=>{W();var r=xP();function i(n,s){function o(a,l){var c=s||{},u;"randomize"in c||(c.randomize=!0),u=r.operation(c);function f(g){l(g||new Error("Aborted"))}function h(g,y){if(g.bail){f(g);return}u.retry(g)?c.onRetry&&c.onRetry(g,y):l(u.mainError())}function p(g){var y;try{y=n(f,g)}catch(b){h(b,g);return}Promise.resolve(y).then(a).catch(function(b){h(b,g)})}u.attempt(p)}return new Promise(o)}e.exports=i}),OP={};VL(OP,{bold:()=>PP,dimmed:()=>NP,error:()=>BP,grey:()=>DP,info:()=>LP,item:()=>MP,log:()=>si,turboBlue:()=>tn,turboGradient:()=>kP,turboLoader:()=>CP,turboRed:()=>pS,underline:()=>IP,warn:()=>FP,yellow:()=>dS});W();var hS="#0099F7",fS="#F11712",TP="#FFFF00",qh=t=>{let e=jP(t);return r=>`\x1B[38;5;${e}m${r}${(0,Ke.reset)("")}`},kP=(0,uS.default)(hS,fS),tn=qh(hS),pS=qh(fS),dS=qh(TP),CP=t=>(0,cS.default)({text:t,spinner:{frames:[" ",tn("> "),tn(">> "),tn(">>>")]}}),LP=(...t)=>{si(tn((0,Ke.bold)(">>>")),t.join(" "))},PP=(...t)=>{si((0,Ke.bold)(t.join(" ")))},IP=(...t)=>{si((0,Ke.underline)(t.join(" ")))},NP=(...t)=>{si((0,Ke.dim)(t.join(" ")))},DP=(...t)=>{si((0,Ke.gray)(t.join(" ")))},MP=(...t)=>{si(tn((0,Ke.bold)(" \u2022")),t.join(" "))},si=(...t)=>{console.log(...t)},FP=(...t)=>{console.error(dS((0,Ke.bold)(">>>")),t.join(" "))},BP=(...t)=>{console.error(pS((0,Ke.bold)(">>>")),t.join(" "))};function jP(t){let e=parseInt(t.slice(1),16),r=Math.floor(e/(256*256))%256,i=Math.floor(e/256)%256,n=e%256;return 16+36*Math.round(r/255*5)+6*Math.round(i/255*5)+Math.round(n/255*5)}W();W();W();W();W();var oB=aa(JL());W();W();function qP(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}W();W();function Ih(t){return Ih=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},Ih(t)}W();function GP(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function zP(t,e){if(e&&(Ih(e)==="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return GP(t)}W();function oa(t){return oa=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},oa(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 WP(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 YP(t){return Function.toString.call(t).indexOf("[native code]")!==-1}W();W();function VP(){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 sa(t,e,r){return VP()?sa=Reflect.construct.bind():sa=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},sa.apply(null,arguments)}function Nh(t){var e=typeof Map=="function"?new Map:void 0;return Nh=function(r){if(r===null||!YP(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 sa(r,arguments,oa(this).constructor)}return i.prototype=Object.create(r.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),Yn(i,r)},Nh(t)}var aB=aa(nP()),uB=function(t){WP(e,t);function e(r){var i;return qP(this,e),i=zP(this,oa(e).call(this,"No package.json could be found upwards from the directory ".concat(r))),i.directory=r,i}return e}(Nh(Error));W();W();W();W();W();W();var SB=aa(EP()),EB=(0,gS.promisify)(mS.Stream.pipeline);W();W();var xB=aa(AP());W();W();W();var je=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,je)}};W();W();W();W();var KP=/^(?!_)(?<manager>.+)@(?<version>.+)$/;function Ze({workspaceRoot:t}){let e=ir.default.join(t,"package.json");try{return(0,nt.readJsonSync)(e,"utf8")}catch(r){if(r&&typeof r=="object"&&"code"in r){if(r.code==="ENOENT")throw new je(`no "package.json" found at ${t}`,{type:"package_json-missing"});if(r.code==="EJSONPARSE")throw new je(`failed to parse "package.json" at ${t}`,{type:"package_json-parse_error"})}throw new Error(`unexpected error reading "package.json" at ${t}`)}}function la({workspaceRoot:t}){let{packageManager:e}=Ze({workspaceRoot:t});if(e)try{let r=KP.exec(e);if(r){let[i,n]=r;return n}}catch{}}function ts({workspaceRoot:t}){let e=Ze({workspaceRoot:t}),r=ir.default.basename(t),{name:i=r,description:n}=e;return{name:i,description:n}}function Kw({workspaceRoot:t}){let e=ir.default.join(t,"pnpm-workspace.yaml");if((0,nt.existsSync)(e))try{let r=qa.load((0,nt.readFileSync)(e,"utf8"));if(r instanceof Object&&"packages"in r&&Array.isArray(r.packages))return r.packages}catch{throw new je(`failed to parse ${e}`,{type:"pnpm-workspace_parse_error"})}return[]}function ca({root:t,lockFile:e,workspaceConfig:r}){let i=s=>ir.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 Gh({workspaces:t}){var e;return t?Array.isArray(t)?t:"packages"in t?(e=t.packages)!=null?e:[]:[]:[]}function ua({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,ES.sync)(n,{onlyFiles:!0,absolute:!0,cwd:t,ignore:["**/node_modules/**",...r]})}).map(i=>{let n=ir.default.dirname(i),{name:s,description:o}=ts({workspaceRoot:n});return{name:s,description:o,paths:{root:n,packageJson:i,nodeModules:ir.default.join(n,"node_modules")}}})}function ZP({directory:t}){let e=ir.default.resolve(process.cwd(),t);return{exists:(0,nt.existsSync)(e),absolute:e}}function Tr({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 XP({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 rr({project:t,options:e}){e!=null&&e.dry||(0,nt.rmSync)(t.paths.lockfile,{force:!0})}async function vS({project:t,options:e}){if(!(e!=null&&e.dry)&&(0,nt.existsSync)(t.paths.lockfile))try{let{stdout:r}=await(0,SS.default)("bun",["bun.lockb"],{stdin:"ignore",cwd:t.paths.root,preferLocal:!0,shell:process.platform==="win32"});await(0,nt.writeFile)(ir.default.join(t.paths.root,"yarn.lock"),r)}catch{}finally{(0,nt.rmSync)(t.paths.lockfile,{force:!0})}}function JP({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 Ar({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=Ze({workspaceRoot:e.paths.root}),o={dependencies:[],devDependencies:[],peerDependencies:[],optionalDependencies:[]},a=["dependencies","devDependencies","peerDependencies","optionalDependencies"];a.forEach(f=>{let h=s[f];if(h){let{updated:p,dependencyList:g}=JP({dependencyList:h,project:t,to:r});s[f]=g,o[f]=p}});let l=f=>{let h=o[f].length;if(h>0)return`${wS.default.green(h.toString())} ${f}`},c=a.map(l).filter(Boolean),u=`./${bS.default.relative(t.paths.root,e.paths.packageJson)}`;if(c.length>=1){let f="updating";c.forEach((h,p)=>{c.length===1?f+=` ${h} in ${u}`:p===c.length-1?f+=`and ${h} in ${u}`:f+=` ${h}, `}),i.workspaceStep(f)}else i.workspaceStep(`no workspace dependencies found in ${u}`);n!=null&&n.dry||_S.default.writeJSONSync(e.paths.packageJson,s,{spaces:2})}var Or={name:"pnpm",lock:"pnpm-lock.yaml"};async function RS(t){let e=ei.default.join(t.workspaceRoot,Or.lock),r=ei.default.join(t.workspaceRoot,"pnpm-workspace.yaml"),i=la({workspaceRoot:t.workspaceRoot});return yt.default.existsSync(e)||yt.default.existsSync(r)||i===Or.name}async function QP(t){if(!await RS(t))throw new je("Not a pnpm project",{type:"package_manager-unexpected"});let{name:e,description:r}=ts(t);return{name:e,description:r,packageManager:Or.name,paths:ca({root:t.workspaceRoot,lockFile:Or.lock,workspaceConfig:"pnpm-workspace.yaml"}),workspaceData:{globs:Kw(t),workspaces:ua({workspaceGlobs:Kw(t),...t})}}}async function eI(t){let{project:e,to:r,logger:i,options:n}=t,s=e.workspaceData.globs.length>0;i.mainStep(Tr({action:"create",packageManager:Or.name,project:e}));let o=Ze({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||(yt.default.writeJSONSync(e.paths.packageJson,o,{spaces:2}),s&&(i.rootStep('adding "pnpm-workspace.yaml"'),yt.default.writeFileSync(ei.default.join(e.paths.root,"pnpm-workspace.yaml"),`packages:
|
|
43
43
|
${e.workspaceData.globs.map(a=>` - "${a}"`).join(`
|
|
44
|
-
`)}`))),s&&(Ar({workspace:{name:"root",paths:e.paths},project:e,to:r,logger:i,options:n}),i.workspaceHeader(),e.workspaceData.workspaces.forEach(a=>{Ar({workspace:a,project:e,to:r,logger:i,options:n})}))}async function tI(t){let{project:e,logger:r,options:i}=t,n=e.workspaceData.globs.length>0;r.mainStep(Tr({action:"remove",packageManager:Or.name,project:e}));let s=Ze({workspaceRoot:e.paths.root});if(e.paths.workspaceConfig&&n&&(r.subStep('removing "pnpm-workspace.yaml"'),i!=null&&i.dry||yt.default.rmSync(e.paths.workspaceConfig,{force:!0})),r.subStep(`removing "packageManager" field in ${e.name} root "package.json"`),delete s.packageManager,!(i!=null&&i.dry)){yt.default.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=>yt.default.rm(a,{recursive:!0,force:!0})))}catch{throw new je("Failed to remove node_modules",{type:"error_removing_node_modules"})}}}async function rI(t){let{project:e,logger:r,options:i}=t;r.subStep(`removing ${ei.default.relative(e.paths.root,e.paths.lockfile)}`),i!=null&&i.dry||yt.default.rmSync(e.paths.lockfile,{force:!0})}async function iI(t){let{project:e,options:r,logger:i}=t,n=()=>{i.subStep(`converting ${ei.default.relative(e.paths.root,e.paths.lockfile)} to ${Or.lock}`)},s=async()=>{if(!(r!=null&&r.dry)&&yt.default.existsSync(e.paths.lockfile))try{await(0,yS.default)(Or.name,["import"],{stdio:"ignore",cwd:e.paths.root,preferLocal:!0,shell:process.platform==="win32"})}catch{}finally{rr({project:e,options:r})}};switch(e.packageManager){case"pnpm":break;case"bun":n(),await vS({project:e,options:r}),await s(),yt.default.rmSync(ei.default.join(e.paths.root,"yarn.lock"),{force:!0});break;case"npm":n(),await s();break;case"yarn":n(),await s();break}}var nI={detect:RS,read:QP,create:eI,remove:tI,clean:rI,convertLock:iI};W();var rn={name:"npm",lock:"package-lock.json"};async function xS(t){let e=Vn.default.join(t.workspaceRoot,rn.lock),r=la({workspaceRoot:t.workspaceRoot});return ti.default.existsSync(e)||r===rn.name}async function sI(t){if(!await xS(t))throw new je("Not an npm project",{type:"package_manager-unexpected"});let e=Ze(t),{name:r,description:i}=ts(t),n=Gh({workspaces:e.workspaces});return{name:r,description:i,packageManager:rn.name,paths:ca({root:t.workspaceRoot,lockFile:rn.lock}),workspaceData:{globs:n,workspaces:ua({workspaceGlobs:n,...t})}}}async function oI(t){let{project:e,options:r,to:i,logger:n}=t,s=e.workspaceData.globs.length>0;n.mainStep(Tr({packageManager:rn.name,action:"create",project:e}));let o=Ze({workspaceRoot:e.paths.root});n.rootHeader(),n.rootStep(`adding "packageManager" field to ${Vn.default.relative(e.paths.root,e.paths.packageJson)}`),o.packageManager=`${i.name}@${i.version}`,s?(n.rootStep(`adding "workspaces" field to ${Vn.default.relative(e.paths.root,e.paths.packageJson)}`),o.workspaces=e.workspaceData.globs,r!=null&&r.dry||ti.default.writeJSONSync(e.paths.packageJson,o,{spaces:2}),Ar({workspace:{name:"root",paths:e.paths},project:e,to:i,logger:n,options:r}),n.workspaceHeader(),e.workspaceData.workspaces.forEach(a=>{Ar({workspace:a,project:e,to:i,logger:n,options:r})})):r!=null&&r.dry||ti.default.writeJSONSync(e.paths.packageJson,o,{spaces:2})}async function aI(t){let{project:e,logger:r,options:i}=t,n=e.workspaceData.globs.length>0;r.mainStep(Tr({packageManager:rn.name,action:"remove",project:e}));let s=Ze({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)){ti.default.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=>ti.default.rm(a,{recursive:!0,force:!0})))}catch{throw new je("Failed to remove node_modules",{type:"error_removing_node_modules"})}}}async function lI(t){let{project:e,logger:r,options:i}=t;r.subStep(`removing ${Vn.default.relative(e.paths.root,e.paths.lockfile)}`),i!=null&&i.dry||ti.default.rmSync(e.paths.lockfile,{force:!0})}async function cI(t){let{project:e,options:r}=t;switch(e.packageManager){case"pnpm":rr({project:e,options:r});break;case"bun":rr({project:e,options:r});break;case"npm":break;case"yarn":rr({project:e,options:r});break}}var uI={detect:xS,read:sI,create:oI,remove:aI,clean:lI,convertLock:cI};W();var ii={name:"yarn",lock:"yarn.lock"};async function AS(t){let e=nn.default.join(t.workspaceRoot,ii.lock),r=la({workspaceRoot:t.workspaceRoot});return ri.default.existsSync(e)||r===ii.name}async function hI(t){if(!await AS(t))throw new je("Not a yarn project",{type:"package_manager-unexpected"});let e=Ze(t),{name:r,description:i}=ts(t),n=Gh({workspaces:e.workspaces});return{name:r,description:i,packageManager:ii.name,paths:ca({root:t.workspaceRoot,lockFile:ii.lock}),workspaceData:{globs:n,workspaces:ua({workspaceGlobs:n,...t})}}}async function fI(t){let{project:e,to:r,logger:i,options:n}=t,s=e.workspaceData.globs.length>0;i.mainStep(Tr({packageManager:ii.name,action:"create",project:e}));let o=Ze({workspaceRoot:e.paths.root});i.rootHeader(),i.rootStep(`adding "packageManager" field to ${nn.default.relative(e.paths.root,e.paths.packageJson)}`),o.packageManager=`${r.name}@${r.version}`,s?(i.rootStep(`adding "workspaces" field to ${nn.default.relative(e.paths.root,e.paths.packageJson)}`),o.workspaces=e.workspaceData.globs,n!=null&&n.dry||ri.default.writeJSONSync(e.paths.packageJson,o,{spaces:2}),Ar({workspace:{name:"root",paths:e.paths},project:e,to:r,logger:i,options:n}),i.workspaceHeader(),e.workspaceData.workspaces.forEach(a=>{Ar({workspace:a,project:e,to:r,logger:i,options:n})})):n!=null&&n.dry||ri.default.writeJSONSync(e.paths.packageJson,o,{spaces:2})}async function pI(t){let{project:e,logger:r,options:i}=t,n=e.workspaceData.globs.length>0;r.mainStep(Tr({packageManager:ii.name,action:"remove",project:e}));let s=Ze({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)){ri.default.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=>ri.default.rm(a,{recursive:!0,force:!0})))}catch{throw new je("Failed to remove node_modules",{type:"error_removing_node_modules"})}}}async function dI(t){let{project:e,logger:r,options:i}=t;r.subStep(`removing ${nn.default.relative(e.paths.root,e.paths.lockfile)}`),i!=null&&i.dry||ri.default.rmSync(e.paths.lockfile,{force:!0})}async function mI(t){let{project:e,options:r,logger:i}=t,n=()=>{i.subStep(`converting ${nn.default.relative(e.paths.root,e.paths.lockfile)} to ${ii.lock}`)};switch(e.packageManager){case"pnpm":rr({project:e,options:r});break;case"bun":n(),await vS({project:e,options:r});break;case"npm":rr({project:e,options:r});break;case"yarn":break}}var gI={detect:AS,read:hI,create:fI,remove:pI,clean:dI,convertLock:mI};W();var sn={name:"bun",lock:"bun.lockb"};async function OS(t){let e=Kn.default.join(t.workspaceRoot,sn.lock),r=la({workspaceRoot:t.workspaceRoot});return ni.default.existsSync(e)||r===sn.name}async function yI(t){if(!await OS(t))throw new je("Not a bun project",{type:"package_manager-unexpected"});let e=Ze(t),{name:r,description:i}=ts(t),n=Gh({workspaces:e.workspaces});return{name:r,description:i,packageManager:sn.name,paths:ca({root:t.workspaceRoot,lockFile:sn.lock}),workspaceData:{globs:n,workspaces:ua({workspaceGlobs:n,...t})}}}async function bI(t){let{project:e,to:r,logger:i,options:n}=t,s=e.workspaceData.globs.length>0;if(!XP({project:e}))throw new je("Unable to convert project to bun - workspace globs unsupported",{type:"bun-workspace_glob_error"});i.mainStep(Tr({packageManager:sn.name,action:"create",project:e}));let o=Ze({workspaceRoot:e.paths.root});i.rootHeader(),i.rootStep(`adding "packageManager" field to ${Kn.default.relative(e.paths.root,e.paths.packageJson)}`),o.packageManager=`${r.name}@${r.version}`,s?(i.rootStep(`adding "workspaces" field to ${Kn.default.relative(e.paths.root,e.paths.packageJson)}`),o.workspaces=e.workspaceData.globs,n!=null&&n.dry||ni.default.writeJSONSync(e.paths.packageJson,o,{spaces:2}),Ar({workspace:{name:"root",paths:e.paths},project:e,to:r,logger:i,options:n}),i.workspaceHeader(),e.workspaceData.workspaces.forEach(a=>{Ar({workspace:a,project:e,to:r,logger:i,options:n})})):n!=null&&n.dry||ni.default.writeJSONSync(e.paths.packageJson,o,{spaces:2})}async function _I(t){let{project:e,logger:r,options:i}=t,n=e.workspaceData.globs.length>0;r.mainStep(Tr({packageManager:sn.name,action:"remove",project:e}));let s=Ze({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)){ni.default.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=>ni.default.rm(a,{recursive:!0,force:!0})))}catch{throw new je("Failed to remove node_modules",{type:"error_removing_node_modules"})}}}async function wI(t){let{project:e,logger:r,options:i}=t;r.subStep(`removing ${Kn.default.relative(e.paths.root,e.paths.lockfile)}`),i!=null&&i.dry||ni.default.rmSync(e.paths.lockfile,{force:!0})}async function SI(t){let{project:e,options:r}=t;switch(e.packageManager){case"pnpm":rr({project:e,options:r});break;case"bun":break;case"npm":rr({project:e,options:r});break;case"yarn":rr({project:e,options:r});break}}var EI={detect:OS,read:yI,create:bI,remove:_I,clean:wI,convertLock:SI},TS={pnpm:nI,yarn:gI,npm:uI,bun:EI};W();async function rs({root:t}){let{exists:e,absolute:r}=ZP({directory:t});if(!e)throw new je(`Could not find directory at ${r}. Ensure the directory exists.`,{type:"invalid_directory"});for(let{detect:i,read:n}of Object.values(TS))if(await i({workspaceRoot:r}))return n({workspaceRoot:r});throw new je("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 XS=require("commander");var zh={name:"@turbo/codemod",version:"2.6.4-canary.0",description:"Provides Codemod transformations to help upgrade your Turborepo codebase when a feature is deprecated.",homepage:"https://turborepo.com",license:"MIT",repository:{type:"git",url:"https://github.com/vercel/turborepo",directory:"packages/turbo-codemod"},bugs:{url:"https://github.com/vercel/turborepo/issues"},bin:"dist/cli.js",scripts:{build:"tsup",test:"jest",lint:"eslint src/","check-types":"tsc --noEmit","add-transformer":"plop","lint:prettier":"prettier -c . --cache --ignore-path=../../.prettierignore"},dependencies:{axios:"0.27.2",commander:"^9.5.0",diff:"^5.1.0","find-up":"4.1.0","fs-extra":"^10.0.0","gradient-string":"^2.0.0",inquirer:"^8.2.4","inquirer-file-tree-selection-prompt":"^1.0.19",json5:"^2.2.3","is-git-clean":"^1.1.0",ora:"4.1.1",picocolors:"1.0.1",semver:"^7.3.7","update-check":"^1.5.4"},devDependencies:{"@jest/globals":"^29.7.0","@turbo/eslint-config":"workspace:*","@turbo/gen":"workspace:*","@turbo/test-utils":"workspace:*","@turbo/tsconfig":"workspace:*","@turbo/types":"workspace:*","@turbo/utils":"workspace:*","@turbo/workspaces":"workspace:*","@types/diff":"^5.0.2","@types/fs-extra":"^9.0.13","@types/gradient-string":"^1.1.2","@types/inquirer":"^8.2.0","@types/node":"^18.17.2","@types/semver":"^7.3.9","@types/uuid":"^9.0.0",deepmerge:"^4.2.2",jest:"^29.7.0",plop:"^3.1.1",semver:"^7.3.5","ts-jest":"^29.2.5",tsup:"^6.7.0",typescript:"5.5.4"},files:["dist"],publishConfig:{access:"public"}};var an=X(require("os")),WS=require("child_process"),$e=X(require("picocolors")),YS=require("inquirer");var Wh=X(require("picocolors")),kS=X(require("is-git-clean"));function ha({directory:t,force:e}){var n;let r=!1,i="Unable to determine if git directory is clean";try{r=kS.default.sync(t||process.cwd()),i="Git directory is not clean"}catch(s){(n=s.stderr)!=null&&n.includes("not a git repository")&&(r=!0)}r||(e?se.log(`${Wh.default.yellow("WARNING")}: ${i}. Forcibly continuing...`):(se.log("Thank you for using @turbo/codemod!"),se.log(Wh.default.yellow(`
|
|
44
|
+
`)}`))),s&&(Ar({workspace:{name:"root",paths:e.paths},project:e,to:r,logger:i,options:n}),i.workspaceHeader(),e.workspaceData.workspaces.forEach(a=>{Ar({workspace:a,project:e,to:r,logger:i,options:n})}))}async function tI(t){let{project:e,logger:r,options:i}=t,n=e.workspaceData.globs.length>0;r.mainStep(Tr({action:"remove",packageManager:Or.name,project:e}));let s=Ze({workspaceRoot:e.paths.root});if(e.paths.workspaceConfig&&n&&(r.subStep('removing "pnpm-workspace.yaml"'),i!=null&&i.dry||yt.default.rmSync(e.paths.workspaceConfig,{force:!0})),r.subStep(`removing "packageManager" field in ${e.name} root "package.json"`),delete s.packageManager,!(i!=null&&i.dry)){yt.default.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=>yt.default.rm(a,{recursive:!0,force:!0})))}catch{throw new je("Failed to remove node_modules",{type:"error_removing_node_modules"})}}}async function rI(t){let{project:e,logger:r,options:i}=t;r.subStep(`removing ${ei.default.relative(e.paths.root,e.paths.lockfile)}`),i!=null&&i.dry||yt.default.rmSync(e.paths.lockfile,{force:!0})}async function iI(t){let{project:e,options:r,logger:i}=t,n=()=>{i.subStep(`converting ${ei.default.relative(e.paths.root,e.paths.lockfile)} to ${Or.lock}`)},s=async()=>{if(!(r!=null&&r.dry)&&yt.default.existsSync(e.paths.lockfile))try{await(0,yS.default)(Or.name,["import"],{stdio:"ignore",cwd:e.paths.root,preferLocal:!0,shell:process.platform==="win32"})}catch{}finally{rr({project:e,options:r})}};switch(e.packageManager){case"pnpm":break;case"bun":n(),await vS({project:e,options:r}),await s(),yt.default.rmSync(ei.default.join(e.paths.root,"yarn.lock"),{force:!0});break;case"npm":n(),await s();break;case"yarn":n(),await s();break}}var nI={detect:RS,read:QP,create:eI,remove:tI,clean:rI,convertLock:iI};W();var rn={name:"npm",lock:"package-lock.json"};async function xS(t){let e=Vn.default.join(t.workspaceRoot,rn.lock),r=la({workspaceRoot:t.workspaceRoot});return ti.default.existsSync(e)||r===rn.name}async function sI(t){if(!await xS(t))throw new je("Not an npm project",{type:"package_manager-unexpected"});let e=Ze(t),{name:r,description:i}=ts(t),n=Gh({workspaces:e.workspaces});return{name:r,description:i,packageManager:rn.name,paths:ca({root:t.workspaceRoot,lockFile:rn.lock}),workspaceData:{globs:n,workspaces:ua({workspaceGlobs:n,...t})}}}async function oI(t){let{project:e,options:r,to:i,logger:n}=t,s=e.workspaceData.globs.length>0;n.mainStep(Tr({packageManager:rn.name,action:"create",project:e}));let o=Ze({workspaceRoot:e.paths.root});n.rootHeader(),n.rootStep(`adding "packageManager" field to ${Vn.default.relative(e.paths.root,e.paths.packageJson)}`),o.packageManager=`${i.name}@${i.version}`,s?(n.rootStep(`adding "workspaces" field to ${Vn.default.relative(e.paths.root,e.paths.packageJson)}`),o.workspaces=e.workspaceData.globs,r!=null&&r.dry||ti.default.writeJSONSync(e.paths.packageJson,o,{spaces:2}),Ar({workspace:{name:"root",paths:e.paths},project:e,to:i,logger:n,options:r}),n.workspaceHeader(),e.workspaceData.workspaces.forEach(a=>{Ar({workspace:a,project:e,to:i,logger:n,options:r})})):r!=null&&r.dry||ti.default.writeJSONSync(e.paths.packageJson,o,{spaces:2})}async function aI(t){let{project:e,logger:r,options:i}=t,n=e.workspaceData.globs.length>0;r.mainStep(Tr({packageManager:rn.name,action:"remove",project:e}));let s=Ze({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)){ti.default.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=>ti.default.rm(a,{recursive:!0,force:!0})))}catch{throw new je("Failed to remove node_modules",{type:"error_removing_node_modules"})}}}async function lI(t){let{project:e,logger:r,options:i}=t;r.subStep(`removing ${Vn.default.relative(e.paths.root,e.paths.lockfile)}`),i!=null&&i.dry||ti.default.rmSync(e.paths.lockfile,{force:!0})}async function cI(t){let{project:e,options:r}=t;switch(e.packageManager){case"pnpm":rr({project:e,options:r});break;case"bun":rr({project:e,options:r});break;case"npm":break;case"yarn":rr({project:e,options:r});break}}var uI={detect:xS,read:sI,create:oI,remove:aI,clean:lI,convertLock:cI};W();var ii={name:"yarn",lock:"yarn.lock"};async function AS(t){let e=nn.default.join(t.workspaceRoot,ii.lock),r=la({workspaceRoot:t.workspaceRoot});return ri.default.existsSync(e)||r===ii.name}async function hI(t){if(!await AS(t))throw new je("Not a yarn project",{type:"package_manager-unexpected"});let e=Ze(t),{name:r,description:i}=ts(t),n=Gh({workspaces:e.workspaces});return{name:r,description:i,packageManager:ii.name,paths:ca({root:t.workspaceRoot,lockFile:ii.lock}),workspaceData:{globs:n,workspaces:ua({workspaceGlobs:n,...t})}}}async function fI(t){let{project:e,to:r,logger:i,options:n}=t,s=e.workspaceData.globs.length>0;i.mainStep(Tr({packageManager:ii.name,action:"create",project:e}));let o=Ze({workspaceRoot:e.paths.root});i.rootHeader(),i.rootStep(`adding "packageManager" field to ${nn.default.relative(e.paths.root,e.paths.packageJson)}`),o.packageManager=`${r.name}@${r.version}`,s?(i.rootStep(`adding "workspaces" field to ${nn.default.relative(e.paths.root,e.paths.packageJson)}`),o.workspaces=e.workspaceData.globs,n!=null&&n.dry||ri.default.writeJSONSync(e.paths.packageJson,o,{spaces:2}),Ar({workspace:{name:"root",paths:e.paths},project:e,to:r,logger:i,options:n}),i.workspaceHeader(),e.workspaceData.workspaces.forEach(a=>{Ar({workspace:a,project:e,to:r,logger:i,options:n})})):n!=null&&n.dry||ri.default.writeJSONSync(e.paths.packageJson,o,{spaces:2})}async function pI(t){let{project:e,logger:r,options:i}=t,n=e.workspaceData.globs.length>0;r.mainStep(Tr({packageManager:ii.name,action:"remove",project:e}));let s=Ze({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)){ri.default.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=>ri.default.rm(a,{recursive:!0,force:!0})))}catch{throw new je("Failed to remove node_modules",{type:"error_removing_node_modules"})}}}async function dI(t){let{project:e,logger:r,options:i}=t;r.subStep(`removing ${nn.default.relative(e.paths.root,e.paths.lockfile)}`),i!=null&&i.dry||ri.default.rmSync(e.paths.lockfile,{force:!0})}async function mI(t){let{project:e,options:r,logger:i}=t,n=()=>{i.subStep(`converting ${nn.default.relative(e.paths.root,e.paths.lockfile)} to ${ii.lock}`)};switch(e.packageManager){case"pnpm":rr({project:e,options:r});break;case"bun":n(),await vS({project:e,options:r});break;case"npm":rr({project:e,options:r});break;case"yarn":break}}var gI={detect:AS,read:hI,create:fI,remove:pI,clean:dI,convertLock:mI};W();var sn={name:"bun",lock:"bun.lockb"};async function OS(t){let e=Kn.default.join(t.workspaceRoot,sn.lock),r=la({workspaceRoot:t.workspaceRoot});return ni.default.existsSync(e)||r===sn.name}async function yI(t){if(!await OS(t))throw new je("Not a bun project",{type:"package_manager-unexpected"});let e=Ze(t),{name:r,description:i}=ts(t),n=Gh({workspaces:e.workspaces});return{name:r,description:i,packageManager:sn.name,paths:ca({root:t.workspaceRoot,lockFile:sn.lock}),workspaceData:{globs:n,workspaces:ua({workspaceGlobs:n,...t})}}}async function bI(t){let{project:e,to:r,logger:i,options:n}=t,s=e.workspaceData.globs.length>0;if(!XP({project:e}))throw new je("Unable to convert project to bun - workspace globs unsupported",{type:"bun-workspace_glob_error"});i.mainStep(Tr({packageManager:sn.name,action:"create",project:e}));let o=Ze({workspaceRoot:e.paths.root});i.rootHeader(),i.rootStep(`adding "packageManager" field to ${Kn.default.relative(e.paths.root,e.paths.packageJson)}`),o.packageManager=`${r.name}@${r.version}`,s?(i.rootStep(`adding "workspaces" field to ${Kn.default.relative(e.paths.root,e.paths.packageJson)}`),o.workspaces=e.workspaceData.globs,n!=null&&n.dry||ni.default.writeJSONSync(e.paths.packageJson,o,{spaces:2}),Ar({workspace:{name:"root",paths:e.paths},project:e,to:r,logger:i,options:n}),i.workspaceHeader(),e.workspaceData.workspaces.forEach(a=>{Ar({workspace:a,project:e,to:r,logger:i,options:n})})):n!=null&&n.dry||ni.default.writeJSONSync(e.paths.packageJson,o,{spaces:2})}async function _I(t){let{project:e,logger:r,options:i}=t,n=e.workspaceData.globs.length>0;r.mainStep(Tr({packageManager:sn.name,action:"remove",project:e}));let s=Ze({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)){ni.default.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=>ni.default.rm(a,{recursive:!0,force:!0})))}catch{throw new je("Failed to remove node_modules",{type:"error_removing_node_modules"})}}}async function wI(t){let{project:e,logger:r,options:i}=t;r.subStep(`removing ${Kn.default.relative(e.paths.root,e.paths.lockfile)}`),i!=null&&i.dry||ni.default.rmSync(e.paths.lockfile,{force:!0})}async function SI(t){let{project:e,options:r}=t;switch(e.packageManager){case"pnpm":rr({project:e,options:r});break;case"bun":break;case"npm":rr({project:e,options:r});break;case"yarn":rr({project:e,options:r});break}}var EI={detect:OS,read:yI,create:bI,remove:_I,clean:wI,convertLock:SI},TS={pnpm:nI,yarn:gI,npm:uI,bun:EI};W();async function rs({root:t}){let{exists:e,absolute:r}=ZP({directory:t});if(!e)throw new je(`Could not find directory at ${r}. Ensure the directory exists.`,{type:"invalid_directory"});for(let{detect:i,read:n}of Object.values(TS))if(await i({workspaceRoot:r}))return n({workspaceRoot:r});throw new je("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 XS=require("commander");var zh={name:"@turbo/codemod",version:"2.6.4-canary.2",description:"Provides Codemod transformations to help upgrade your Turborepo codebase when a feature is deprecated.",homepage:"https://turborepo.com",license:"MIT",repository:{type:"git",url:"https://github.com/vercel/turborepo",directory:"packages/turbo-codemod"},bugs:{url:"https://github.com/vercel/turborepo/issues"},bin:"dist/cli.js",scripts:{build:"tsup",test:"jest",lint:"eslint src/","check-types":"tsc --noEmit","add-transformer":"plop","lint:prettier":"prettier -c . --cache --ignore-path=../../.prettierignore"},dependencies:{axios:"0.27.2",commander:"^9.5.0",diff:"^5.1.0","find-up":"4.1.0","fs-extra":"^10.0.0","gradient-string":"^2.0.0",inquirer:"^8.2.4","inquirer-file-tree-selection-prompt":"^1.0.19",json5:"^2.2.3","is-git-clean":"^1.1.0",ora:"4.1.1",picocolors:"1.0.1",semver:"^7.3.7","update-check":"^1.5.4"},devDependencies:{"@jest/globals":"^29.7.0","@turbo/eslint-config":"workspace:*","@turbo/gen":"workspace:*","@turbo/test-utils":"workspace:*","@turbo/tsconfig":"workspace:*","@turbo/types":"workspace:*","@turbo/utils":"workspace:*","@turbo/workspaces":"workspace:*","@types/diff":"^5.0.2","@types/fs-extra":"^9.0.13","@types/gradient-string":"^1.1.2","@types/inquirer":"^8.2.0","@types/node":"^18.17.2","@types/semver":"^7.3.9","@types/uuid":"^9.0.0",deepmerge:"^4.2.2",jest:"^29.7.0",plop:"^3.1.1",semver:"^7.3.5","ts-jest":"^29.2.5",tsup:"^6.7.0",typescript:"5.5.4"},files:["dist"],publishConfig:{access:"public"}};var an=X(require("os")),WS=require("child_process"),$e=X(require("picocolors")),YS=require("inquirer");var Wh=X(require("picocolors")),kS=X(require("is-git-clean"));function ha({directory:t,force:e}){var n;let r=!1,i="Unable to determine if git directory is clean";try{r=kS.default.sync(t||process.cwd()),i="Git directory is not clean"}catch(s){(n=s.stderr)!=null&&n.includes("not a git repository")&&(r=!0)}r||(e?se.log(`${Wh.default.yellow("WARNING")}: ${i}. Forcibly continuing...`):(se.log("Thank you for using @turbo/codemod!"),se.log(Wh.default.yellow(`
|
|
45
45
|
But before we continue, please stash or commit your git changes.`)),se.log(`
|
|
46
46
|
You may use the --force flag to override this safety check.`),process.exit(1)))}var Yh=X(require("path")),CS=X(require("fs"));function on({directory:t}){let e=Yh.default.isAbsolute(t)?t:Yh.default.join(process.cwd(),t);return{exists:CS.default.existsSync(e),absolute:e}}var ga=X(require("picocolors"));var bt=X(require("picocolors")),fa=class{constructor(e){this.transform=e.transformer,this.dry=e.dryRun}_log(...e){console.log(...e)}modified(...e){this._log(bt.default.green(" MODIFIED "),...e,this.dry?bt.default.dim("(dry run)"):"")}unchanged(...e){this._log(bt.default.gray(" UNCHANGED "),...e,this.dry?bt.default.dim("(dry run)"):"")}skipped(...e){this._log(bt.default.yellow(" SKIPPED "),...e,this.dry?bt.default.dim("(dry run)"):"")}error(...e){this._log(bt.default.red(" ERROR "),...e,this.dry?bt.default.dim("(dry run)"):"")}info(...e){this._log(bt.default.bold(" INFO "),...e,this.dry?bt.default.dim("(dry run)"):"")}};var LS=X(require("os")),Vh=X(require("path"));var pa=X(require("picocolors")),ma=require("diff"),kr=require("fs-extra"),da=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{Vh.default.extname(e.filePath)===".json"?this.before=(0,kr.readJsonSync)(e.filePath):this.before=(0,kr.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,ma.diffJson)(this.before,e.after):this.changes=(0,ma.diffLines)(this.before,e.after):this.changes=[]}fileName(){return Vh.default.relative(this.rootPath,this.filePath)}write(){this.after&&(typeof this.after=="object"?(0,kr.writeJsonSync)(this.filePath,this.after,{spaces:2}):(0,kr.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(pa.default.green(r.value)):r.removed?process.stdout.write(pa.default.red(r.value)):process.stdout.write(pa.default.dim(r.value))}),se.log(LS.default.EOL)):se.log(this.after)}};var oi=class{constructor(e){this.modifications={};this.transform=e.transformer,this.rootPath=e.rootPath,this.dry=e.dryRun,this.print=e.print,this.logger=new fa(e)}abortTransform(e){return this.logger.error(e.reason),{fatalError:new Error(e.reason),changes:e.changes||{}}}modifyFile(e){this.modifications[e.filePath]=new da({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(ga.default.dim(n.fileName()));else try{n.write(),s.action="modified",this.logger.modified(ga.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(ga.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(se.log(),r.length>0){se.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),se.log()}}};var PS=X(require("path")),IS=X(require("fs-extra")),CI=["package.json","turbo.json",".git"];function NS({directory:t}){return CI.some(e=>IS.default.existsSync(PS.default.join(t,e)))}var DS=require("child_process");function _t(t,e,r){try{return(0,DS.execSync)(t,{stdio:"pipe",...e}).toString("utf8").trim()}catch{return r||void 0}}function MS(t,e){let{from:r}=e;if(r)return r;let i=_t("turbo --version",{cwd:t.paths.root});if(i)return i;let{packageManager:n}=t;return n==="yarn"?_t("yarn turbo --version",{cwd:t.paths.root}):n==="pnpm"?_t("pnpm turbo --version",{cwd:t.paths.root}):_t("npm exec -c 'turbo --version'",{cwd:t.paths.root})}var FS=X(require("axios")),LI="https://registry.npmjs.org";async function PI({packageName:t}){var r;let e=((r=process.env.npm_config_registry)==null?void 0:r.replace(/\/$/,""))||LI;try{return(await FS.default.get(`${e}/${t}`)).data}catch{throw new Error(`Unable to fetch the latest version of ${t}`)}}async function BS({to:t}){let e=await PI({packageName:"turbo"}),{"dist-tags":r,versions:i}=e;if(t){if(r[t]||t in i)return t;throw new Error(`turbo@${t} does not exist`)}return r.latest}var nr=require("semver");var ya=X(require("path")),$S=X(require("fs-extra")),jS=process.env.NODE_ENV==="test"?ya.default.join(__dirname,"../transforms"):ya.default.join(__dirname,"./transforms");function ba(){return $S.default.readdirSync(jS).map(e=>{let r=ya.default.join(jS,e);try{return require(r).default}catch{return}}).filter(Boolean)}function US({fromVersion:t,toVersion:e}){let r=t.split(".")[0],n=r!==e.split(".")[0]?`${r}.0.0`:t,s=ba().filter(o=>{var c;let a=(0,nr.gt)(o.introducedIn,t)&&(0,nr.lte)(o.introducedIn,e),l=((c=o.idempotent)!=null?c:!0)&&(0,nr.gt)(o.introducedIn,n)&&(0,nr.lte)(o.introducedIn,e);return a||l});return s.sort((o,a)=>(0,nr.gt)(o.introducedIn,a.introducedIn)?1:(0,nr.eq)(o.introducedIn,a.introducedIn)?0:-1),s}var HS=X(require("path")),Kh=X(require("fs-extra")),qS=require("semver");function II(t,e="latest"){switch(t){case"yarn":return`yarn global add turbo@${e}`;case"npm":return`npm install turbo@${e} --global`;case"pnpm":return`pnpm add turbo@${e} --global`;case"bun":return`bun add turbo@${e} --global`}}function NI({packageManager:t,packageManagerVersion:e,installType:r,isUsingWorkspaces:i,to:n="latest"}){let s=o=>o.filter(Boolean).join(" ");switch(t){case"yarn":return(0,qS.gte)(e,"2.0.0")?s(["yarn","add",`turbo@${n}`,r==="devDependencies"&&"--dev"]):s(["yarn","add",`turbo@${n}`,r==="devDependencies"&&"--dev",i&&"-W"]);case"npm":return s(["npm","install",`turbo@${n}`,r==="devDependencies"&&"--save-dev"]);case"pnpm":return s(["pnpm","add",`turbo@${n}`,r==="devDependencies"&&"--save-dev",i&&"-w"]);case"bun":return s(["bun","add",`turbo@${n}`,r==="devDependencies"&&"--dev"])}}function DI({root:t}){let e=HS.default.join(t,"package.json");if(!Kh.default.existsSync(e)){se.error(`Unable to find package.json at ${e}`);return}let r=Kh.default.readJsonSync(e),i=r.devDependencies&&"turbo"in r.devDependencies,n=r.dependencies&&"turbo"in r.dependencies;if(n||i)return n?"dependencies":"devDependencies"}async function GS({project:t,to:e}){let r=_t("turbo bin",{cwd:t.paths.root,stdio:"pipe"}),i=await Wc(),n=Object.keys(i).find(u=>{let f=i[u];return f&&r?r.includes(f):!1});if(r&&n)return II(n,e);let{packageManager:s}=t,o=t.workspaceData.globs.length>0,a=DI({root:t.paths.root}),c=(await zc())[s];if(c&&a)return NI({packageManager:s,packageManagerVersion:c,installType:a,isUsingWorkspaces:o,to:e})}function zS({project:t}){try{let e={cwd:t.paths.root,stdio:"ignore"};if(_t("turbo bin",e))_t("turbo daemon stop",e);else{let i=`${t.packageManager} turbo daemon stop`;t.packageManager==="npm"&&(i="npm exec -c 'turbo daemon stop'"),_t(i,e)}}catch{}}function wt({message:t,success:e}){return e?(se.bold($e.default.green("Migration completed")),t&&se.log(t),process.exit(0)):(se.bold($e.default.red("Migration failed")),t&&se.log(t),process.exit(1))}async function Zh(t,e){e.dryRun||ha({directory:t,force:e.force});let r=await(0,YS.prompt)([{type:"input",name:"directoryInput",message:"Where is the root of the repo to migrate?",when:!t,default:".",validate:p=>{let{exists:g,absolute:y}=on({directory:p});return g?!0:`Directory ${$e.default.dim(`(${y})`)} does not exist`},filter:p=>p.trim()}]),{directoryInput:i=t}=r,{exists:n,absolute:s}=on({directory:i});if(!n)return wt({success:!1,message:`Directory ${$e.default.dim(`(${s})`)} does not exist`});if(!NS({directory:s}))return wt({success:!1,message:`Directory (${$e.default.dim(s)}) does not appear to be a repository`});let o;try{o=await rs({root:s})}catch{return wt({success:!1,message:`Unable to read determine package manager details from ${$e.default.dim(s)}`})}let a=MS(o,e);if(!a)return wt({success:!1,message:`Unable to infer the version of turbo being used by ${o.name}`});let l=e.to;try{l=await BS(e)}catch(p){let g="UNKNOWN_ERROR";return p instanceof Error&&(g=p.message),wt({success:!1,message:g})}if(!l)return wt({success:!1,message:"Unable to fetch the latest version of turbo"});if(a===l)return wt({success:!0,message:`Nothing to do, current version (${$e.default.bold(a)}) is the same as the requested version (${$e.default.bold(l)})`});let c=US({fromVersion:a,toVersion:l});c.length===0&&se.log(`No codemods required to migrate from ${a} to ${l}`,an.default.EOL),e.dryRun||zS({project:o}),se.log(`Upgrading turbo from ${$e.default.bold(a)} to ${$e.default.bold(l)} (${c.length===0?"no codemods required":`${c.length} required codemod${c.length===1?"":"s"}`})`,an.default.EOL);let u=[];for(let[p,g]of c.entries()){se.log(`(${p+1}/${c.length}) ${$e.default.bold(`Running ${g.name}`)}`);let y=await g.transformer({root:o.paths.root,options:e});oi.logResults(y),u.push(y)}if(u.some(p=>p.fatalError||Object.keys(p.changes).some(g=>p.changes[g].error)))return wt({success:!1,message:"Could not complete migration due to codemod errors. Please fix the errors and try again."});let h=await GS({project:o,to:e.to});if(!h)return wt({success:!1,message:"Unable to determine upgrade command"});if(e.install)if(e.dryRun)se.log(`Upgrading turbo with ${$e.default.bold(h)} ${$e.default.dim("(dry run)")}`,an.default.EOL);else{se.log(`Upgrading turbo with ${$e.default.bold(h)}`,an.default.EOL);try{(0,WS.execSync)(h,{stdio:"pipe",cwd:o.paths.root})}catch(p){return wt({success:!1,message:`Unable to upgrade turbo: ${String(p)}`})}}else se.log(`Upgrade turbo with ${$e.default.bold(h)}`,an.default.EOL);wt({success:!0})}var Cr=X(require("picocolors")),VS=require("inquirer");async function Xh(t,e,r){let i=ba();if(r.list)return se.log(i.map(h=>`- ${Cr.default.cyan(h.name)}`).join(`
|
|
47
47
|
`)),process.exit(0);r.dryRun||ha({directory:e,force:r.force});let n=await(0,VS.prompt)([{type:"input",name:"directoryInput",message:"Where is the root of the repo where the transform should run?",when:!e,default:".",validate:h=>{let{exists:p,absolute:g}=on({directory:h});return p?!0:`Directory ${Cr.default.dim(`(${g})`)} does not exist`},filter:h=>h.trim()},{type:"list",name:"transformerInput",message:"Which transform would you like to apply?",when:!t,pageSize:i.length,choices:i.map(h=>({name:`${Cr.default.bold(h.name)} - ${Cr.default.gray(h.description)} ${Cr.default.gray(`(${h.introducedIn})`)}`,value:h.name}))}]),{directoryInput:s=e,transformerInput:o=t}=n,{exists:a,absolute:l}=on({directory:s});if(!a)return se.error(`Directory ${Cr.default.dim(`(${l})`)} does not exist`),process.exit(1);let c=i.map(h=>h.name),u=i.find(h=>h.name===o);if(!u)return se.error(`Invalid transform choice ${Cr.default.dim(`(${t})`)}, pick one of:`),se.error(c.map(h=>`- ${h}`).join(`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@turbo/codemod",
|
|
3
|
-
"version": "2.6.4-canary.
|
|
3
|
+
"version": "2.6.4-canary.2",
|
|
4
4
|
"description": "Provides Codemod transformations to help upgrade your Turborepo codebase when a feature is deprecated.",
|
|
5
5
|
"homepage": "https://turborepo.com",
|
|
6
6
|
"license": "MIT",
|
|
@@ -46,12 +46,12 @@
|
|
|
46
46
|
"tsup": "^6.7.0",
|
|
47
47
|
"typescript": "5.5.4",
|
|
48
48
|
"@turbo/eslint-config": "0.0.0",
|
|
49
|
+
"@turbo/gen": "2.6.4-canary.2",
|
|
49
50
|
"@turbo/test-utils": "0.0.0",
|
|
50
51
|
"@turbo/tsconfig": "0.0.0",
|
|
52
|
+
"@turbo/types": "2.6.4-canary.2",
|
|
51
53
|
"@turbo/utils": "0.0.0",
|
|
52
|
-
"@turbo/
|
|
53
|
-
"@turbo/workspaces": "2.6.4-canary.0",
|
|
54
|
-
"@turbo/gen": "2.6.4-canary.0"
|
|
54
|
+
"@turbo/workspaces": "2.6.4-canary.2"
|
|
55
55
|
},
|
|
56
56
|
"files": [
|
|
57
57
|
"dist"
|