@turbo/codemod 2.7.2-canary.1 → 2.7.2-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 +5 -5
package/dist/cli.js
CHANGED
|
@@ -41,7 +41,7 @@ ${i.message}`:y,L=[O,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)}}),qh=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))}}}),iS=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)}}),nS=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]}}),hP=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)}),sS=te((t,e)=>{"use strict";W();var r=$h(),i=Hh(),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"),O=Symbol("read"),L=Symbol("lstat"),k=Symbol("onlstat"),T=Symbol("onread"),A=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=qh(),N=iS(),x=nS(),C=hP(),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]=x(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[k](this.statCache.get(this.absolute)):this[L]()}emit(m,..._){return m==="error"&&(this[V]=!0),super.emit(m,..._)}[L](){s.lstat(this.absolute,(m,_)=>{if(m)return this.emit("error",m);this[k](_)})}[k](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 C(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[A](_)})}[A](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[O]()}[O](){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[O]()}}),z=class extends j{[L](){this[k](s.lstatSync(this.absolute))}[g](){this[A](s.readlinkSync(this.absolute))}[I](){this[w](s.openSync(this.absolute,"r"))}[O](){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]=x(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 C(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}),fP=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}}}),oS=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{fP()(r)}catch{}}),Gh=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=$h(),n=tS(),s=Uh(),o=sS(),a=o.Sync,l=o.Tar,c=oS(),u=Buffer.alloc(1024),f=Symbol("onStat"),h=Symbol("ended"),p=Symbol("queue"),g=Symbol("current"),y=Symbol("process"),b=Symbol("processing"),O=Symbol("processJob"),L=Symbol("jobs"),k=Symbol("jobDone"),T=Symbol("addFSEntry"),A=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"),x=re("path"),C=qh(),j=Xn(),z=C(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[L]=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[A](d):this[T](d),this.flowing}[A](d){let m=j(x.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[k](_)),this[L]+=1,this[p].push(_)}this[y]()}[T](d){let m=j(x.resolve(this.cwd,d));this[p].push(new r(d,m)),this[y]()}[I](d){d.pending=!0,this[L]+=1;let m=this.follow?"stat":"lstat";N[m](d.absolute,(_,R)=>{d.pending=!1,this[L]-=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[L]+=1,N.readdir(d.absolute,(m,_)=>{if(d.pending=!1,this[L]-=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[L]<this.jobs;d=d.next)if(this[O](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[L]===0&&(this.zip?this.zip.end(u):(super.write(u),super.end()))}}get[g](){return this[p]&&this[p].head&&this[p].head.value}[k](d){this[p].shift(),this[L]-=1,this[y]()}[O](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[L]+=1;try{return new this[q](d.path,this[P](d)).on("end",()=>this[k](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=Qw(),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"),O=Symbol("_onopen"),L=Symbol("_onread"),k=Symbol("_onwrite"),T=Symbol("_open"),A=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"),x=Symbol("_errored"),C=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[x]=!1,this[l]=typeof m.fd=="number"?m.fd:null,this[A]=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[A]}write(){throw new TypeError("this is a readable stream")}end(){throw new TypeError("this is a readable stream")}[T](){i.open(this[A],"r",(d,m)=>this[O](d,m))}[O](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[L](null,0,d));i.read(this[l],d,0,d.length,null,(m,_,R)=>this[L](m,_,R))}}[L](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[x]?void 0:(this[x]=!0,super.emit(d,m));default:return super.emit(d,m)}}},j=class extends C{[T](){let d=!0;try{this[O](null,i.openSync(this[A],"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[x]=!1,this[K]=!1,this[a]=!1,this[y]=!1,this[w]=[],this[A]=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[x])return;this[x]=!0}return super.emit(d,m)}get fd(){return this[l]}get path(){return this[A]}[b](d){this[o](),this[K]=!0,this.emit("error",d)}[T](){i.open(this[A],this[u],this[g],(d,m)=>this[O](d,m))}[O](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[k](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[k](m,_))}[k](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[k](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[k](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[A],this[u],this[g])}catch(m){if(m.code==="ENOENT")return this[u]="w",this[T]();throw m}else d=i.openSync(this[A],this[u],this[g]);this[O](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[k](null,i.writeSync(this[l],d,0,d.length,this[I])),m=!1}finally{if(m)try{this[o]()}catch{}}}};t.ReadStream=C,t.ReadStreamSync=j,t.WriteStream=z,t.WriteStreamSync=D}),zh=te((t,e)=>{"use strict";W();var r=qh(),i=Jn(),n=re("events"),s=oS(),o=1024*1024,a=Uh(),l=Hh(),c=tS(),{nextTick:u}=re("process"),f=Buffer.from([31,139]),h=Symbol("state"),p=Symbol("writeEntry"),g=Symbol("readEntry"),y=Symbol("nextEntry"),b=Symbol("processEntry"),O=Symbol("extendedHeader"),L=Symbol("globalExtendedHeader"),k=Symbol("meta"),T=Symbol("emitMeta"),A=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"),x=Symbol("consuming"),C=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[A]=null,this[g]=null,this[p]=null,this[h]="begin",this[k]="",this[O]=null,this[L]=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[O],this[L])}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[O],this[L]);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[k]="",G.on("data",ie=>this[k]+=ie),this[h]="meta"):(this[O]=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[k]),B.type){case"ExtendedHeader":case"OldExtendedHeader":this[O]=l.parse(this[k],this[O],!1);break;case"GlobalExtendedHeader":this[L]=l.parse(this[k],this[L],!0);break;case"NextFileHasLongPath":case"OldGnuLongPath":this[O]=this[O]||Object.create(null),this[O].path=this[k].replace(/\0.*/,"");break;case"NextFileHasLongLinkpath":this[O]=this[O]||Object.create(null),this[O].linkpath=this[k].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[A]&&(B=Buffer.concat([this[A],B]),this[A]=null),B.length<f.length)return this[A]=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}[C](B){B&&!this[D]&&(this[A]=this[A]?Buffer.concat([this[A],B]):B)}[j](){if(this[w]&&!this[v]&&!this[D]&&!this[x]){this[v]=!0;let B=this[p];if(B&&B.blockRemain){let Z=this[A]?this[A].length:0;this.warn("TAR_BAD_ARCHIVE",`Truncated input (needed ${B.blockRemain} more bytes, only ${Z} available)`,{entry:B}),this[A]&&B.write(this[A]),B.end()}this[F](d)}}[P](B){if(this[x])this[C](B);else if(!B&&!this[A])this[j]();else{if(this[x]=!0,this[A]){this[C](B);let Z=this[A];this[A]=null,this[q](Z)}else this[q](B);for(;this[A]&&this[A].length>=512&&!this[D]&&!this[R];){let Z=this[A];this[A]=null,this[q](Z)}this[x]=!1}(!this[A]||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[A]?this[A]=Buffer.concat([B.slice(Z),this[A]]):this[A]=B.slice(Z))}end(B){this[D]||(this[U]?this[U].end(B):(this[w]=!0,this.write(B)))}})}),Wh=te((t,e)=>{"use strict";W();var r=Zn(),i=zh(),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(L=>[a(L),!0])),b=p.filter,O=(L,k)=>{let T=k||o.parse(L).root||".",A=L===T?!1:y.has(L)?y.get(L):O(o.dirname(L),T);return y.set(L,A),A};p.filter=b?(L,k)=>b(L,k)&&O(a(L)):L=>O(a(L))},u=p=>{let g=h(p),y=p.file,b=!0,O;try{let L=n.statSync(y),k=p.maxReadSize||16*1024*1024;if(L.size<k)g.end(n.readFileSync(y));else{let T=0,A=Buffer.allocUnsafe(k);for(O=n.openSync(y,"r");T<L.size;){let I=n.readSync(O,A,0,k,T);T+=I,g.write(A.slice(0,I))}g.end()}b=!1}finally{if(b&&O)try{n.closeSync(O)}catch{}}},f=(p,g)=>{let y=new i(p),b=p.maxReadSize||16*1024*1024,O=p.file,L=new Promise((k,T)=>{y.on("error",T),y.on("end",k),n.stat(O,(A,I)=>{if(A)T(A);else{let w=new s.ReadStream(O,{readSize:b,size:I.size});w.on("error",T),w.pipe(y)}})});return g?L.then(g,g):L},h=p=>new i(p)}),pP=te((t,e)=>{"use strict";W();var r=Zn(),i=Gh(),n=es(),s=Wh(),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),O=new n.WriteStream(p.file,{mode:p.mode||438});b.pipe(O);let L=new Promise((k,T)=>{O.on("error",T),O.on("close",k),b.on("error",T)});return u(b,g),y?L.then(y,y):L},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}}),aS=te((t,e)=>{"use strict";W();var r=Zn(),i=Gh(),n=re("fs"),s=es(),o=Wh(),a=re("path"),l=Jn();e.exports=(g,y,b)=>{let O=r(g);if(!O.file)throw new TypeError("file is required");if(O.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),O.sync?c(O,y):f(O,y,b)};var c=(g,y)=>{let b=new i.Sync(g),O=!0,L,k;try{try{L=n.openSync(g.file,"r+")}catch(I){if(I.code==="ENOENT")L=n.openSync(g.file,"w+");else throw I}let T=n.fstatSync(L),A=Buffer.alloc(512);e:for(k=0;k<T.size;k+=512){for(let v=0,F=0;v<512;v+=F){if(F=n.readSync(L,A,v,A.length-v,k+v),k===0&&A[0]===31&&A[1]===139)throw new Error("cannot append to compressed archives");if(!F)break e}let I=new l(A);if(!I.cksumValid)break;let w=512*Math.ceil(I.size/512);if(k+w+512>T.size)break;k+=w,g.mtimeCache&&g.mtimeCache.set(I.path,I.mtime)}O=!1,u(g,b,k,L,y)}finally{if(O)try{n.closeSync(L)}catch{}}},u=(g,y,b,O,L)=>{let k=new s.WriteStreamSync(g.file,{fd:O,start:b});y.pipe(k),h(y,L)},f=(g,y,b)=>{y=Array.from(y);let O=new i(g),L=(T,A,I)=>{let w=(q,V)=>{q?n.close(T,K=>I(q)):I(null,V)},v=0;if(A===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>A||(v+=N+512,v>=A))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)},k=new Promise((T,A)=>{O.on("error",A);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 A(v);n.fstat(F,(U,P)=>{if(U)return n.close(F,()=>A(U));L(F,P.size,(q,V)=>{if(q)return A(q);let K=new s.WriteStream(g.file,{fd:F,start:V});O.pipe(K),K.on("error",A),K.on("close",T),p(O,y)})})};n.open(g.file,I,w)});return b?k.then(b,b):k},h=(g,y)=>{y.forEach(b=>{b.charAt(0)==="@"?o({file:a.resolve(g.cwd,b.slice(1)),sync:!0,noResume:!0,onentry:O=>g.add(O)}):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:O=>g.add(O)}).then(O=>p(g,y));g.add(b)}g.end()}}),dP=te((t,e)=>{"use strict";W();var r=Zn(),i=aS();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)}}),mP=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}),gP=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}),yP=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}}),lS=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}}),bP=te((t,e)=>{W();var{dirname:r}=re("path"),{findMade:i,findMadeSync:n}=yP(),{mkdirpManual:s,mkdirpManualSync:o}=lS(),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}}),_P=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}}),wP=te((t,e)=>{W();var r=mP(),i=gP(),{mkdirpNative:n,mkdirpNativeSync:s}=bP(),{mkdirpManual:o,mkdirpManualSync:a}=lS(),{useNative:l,useNativeSync:c}=_P(),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}),SP=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=(k,T,A)=>{try{return r[s](k,T,A)}catch(I){if(I.code!=="ENOENT")throw I}},l=(k,T,A)=>{try{return r.chownSync(k,T,A)}catch(I){if(I.code!=="ENOENT")throw I}},c=o?(k,T,A,I)=>w=>{!w||w.code!=="EISDIR"?I(w):r.chown(k,T,A,I)}:(k,T,A,I)=>I,u=o?(k,T,A)=>{try{return a(k,T,A)}catch(I){if(I.code!=="EISDIR")throw I;l(k,T,A)}}:(k,T,A)=>a(k,T,A),f=process.version,h=(k,T,A)=>r.readdir(k,T,A),p=(k,T)=>r.readdirSync(k,T);/^v4\./.test(f)&&(h=(k,T,A)=>r.readdir(k,A));var g=(k,T,A,I)=>{r[n](k,T,A,c(k,T,A,w=>{I(w&&w.code!=="ENOENT"?w:null)}))},y=(k,T,A,I,w)=>{if(typeof T=="string")return r.lstat(i.resolve(k,T),(v,F)=>{if(v)return w(v.code!=="ENOENT"?v:null);F.name=T,y(k,F,A,I,w)});if(T.isDirectory())b(i.resolve(k,T.name),A,I,v=>{if(v)return w(v);let F=i.resolve(k,T.name);g(F,A,I,w)});else{let v=i.resolve(k,T.name);g(v,A,I,w)}},b=(k,T,A,I)=>{h(k,{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(k,T,A,I);let F=v.length,U=null,P=q=>{if(!U){if(q)return I(U=q);if(--F===0)return g(k,T,A,I)}};v.forEach(q=>y(k,q,T,A,P))})},O=(k,T,A,I)=>{if(typeof T=="string")try{let w=r.lstatSync(i.resolve(k,T));w.name=T,T=w}catch(w){if(w.code==="ENOENT")return;throw w}T.isDirectory()&&L(i.resolve(k,T.name),A,I),u(i.resolve(k,T.name),A,I)},L=(k,T,A)=>{let I;try{I=p(k,{withFileTypes:!0})}catch(w){if(w.code==="ENOENT")return;if(w.code==="ENOTDIR"||w.code==="ENOTSUP")return u(k,T,A);throw w}return I&&I.length&&I.forEach(w=>O(k,w,T,A)),u(k,T,A)};e.exports=b,b.sync=L}),EP=te((t,e)=>{"use strict";W();var r=wP(),i=re("fs"),n=re("path"),s=SP(),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,O)=>y.set(o(b),O),f=(y,b)=>{i.stat(y,(O,L)=>{(O||!L.isDirectory())&&(O=new l(y,O&&O.code||"ENOTDIR")),b(O)})};e.exports=(y,b,O)=>{y=o(y);let L=b.umask,k=b.mode|448,T=(k&L)!==0,A=b.uid,I=b.gid,w=typeof A=="number"&&typeof I=="number"&&(A!==b.processUid||I!==b.processGid),v=b.preserve,F=b.unlink,U=b.cache,P=o(b.cwd),q=(K,N)=>{K?O(K):(u(U,y,!0),N&&w?s(N,A,I,x=>q(x)):T?i.chmod(y,k,O):O())};if(U&&c(U,y)===!0)return q();if(y===P)return f(y,q);if(v)return r(y,{mode:k}).then(K=>q(null,K),q);let V=o(n.relative(P,y)).split("/");h(P,V,k,U,F,P,null,q)};var h=(y,b,O,L,k,T,A,I)=>{if(!b.length)return I(null,A);let w=b.shift(),v=o(n.resolve(y+"/"+w));if(c(L,v))return h(v,b,O,L,k,T,A,I);i.mkdir(v,O,p(v,b,O,L,k,T,A,I))},p=(y,b,O,L,k,T,A,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,O,L,k,T,A,I);else if(k)i.unlink(y,U=>{if(U)return I(U);i.mkdir(y,O,p(y,b,O,L,k,T,A,I))});else{if(F.isSymbolicLink())return I(new a(y,y+"/"+b.join("/")));I(w)}}):(A=A||y,h(y,b,O,L,k,T,A,I))},g=y=>{let b=!1,O="ENOTDIR";try{b=i.statSync(y).isDirectory()}catch(L){O=L.code}finally{if(!b)throw new l(y,O)}};e.exports.sync=(y,b)=>{y=o(y);let O=b.umask,L=b.mode|448,k=(L&O)!==0,T=b.uid,A=b.gid,I=typeof T=="number"&&typeof A=="number"&&(T!==b.processUid||A!==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,A),k&&i.chmodSync(y,L)};if(F&&c(F,y)===!0)return P();if(y===U)return g(U),P();if(w)return P(r.sync(y,L));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,L),V=V||N,u(F,N,!0)}catch{let x=i.lstatSync(N);if(x.isDirectory()){u(F,N,!0);continue}else if(v){i.unlinkSync(N),i.mkdirSync(N,L),V=V||N,u(F,N,!0);continue}else if(x.isSymbolicLink())return new a(N,N+"/"+q.join("/"))}return P(V)}}),cS=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])}),vP=te((t,e)=>{W();var r=re("assert"),i=cS(),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((O,L)=>(O.length&&(L=s(O[O.length-1],L)),O.push(L||"/"),O),[]),f=new Set,h=b=>{let O=c.get(b);if(!O)throw new Error("function does not have any path reservations");return{paths:O.paths.map(L=>l.get(L)),dirs:[...O.dirs].map(L=>l.get(L))}},p=b=>{let{paths:O,dirs:L}=h(b);return O.every(k=>k[0]===b)&&L.every(k=>k[0]instanceof Set&&k[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:O,dirs:L}=c.get(b),k=new Set;return O.forEach(T=>{let A=l.get(T);r.equal(A[0],b),A.length===1?l.delete(T):(A.shift(),typeof A[0]=="function"?k.add(A[0]):A[0].forEach(I=>k.add(I)))}),L.forEach(T=>{let A=l.get(T);r(A[0]instanceof Set),A[0].size===1&&A.length===1?l.delete(T):A[0].size===1?(A.shift(),k.add(A[0])):A[0].delete(b)}),f.delete(b),k.forEach(T=>g(T)),!0};return{check:p,reserve:(b,O)=>{b=a?["win32 parallelization disabled"]:b.map(k=>i(n(s(k))).toLowerCase());let L=new Set(b.map(k=>u(k)).reduce((k,T)=>k.concat(T)));return c.set(O,{dirs:L,paths:b}),b.forEach(k=>{let T=l.get(k);T?T.push(O):l.set(k,[O])}),L.forEach(k=>{let T=l.get(k);T?T[T.length-1]instanceof Set?T[T.length-1].add(O):T.push(new Set([O])):l.set(k,[new Set([O])])}),g(O)}}}}),RP=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"}),uS=te((t,e)=>{"use strict";W();var r=re("assert"),i=zh(),n=re("fs"),s=es(),o=re("path"),a=EP(),l=iS(),c=vP(),u=nS(),f=Xn(),h=Qn(),p=cS(),g=Symbol("onEntry"),y=Symbol("checkFs"),b=Symbol("checkFs2"),O=Symbol("pruneCache"),L=Symbol("isReusable"),k=Symbol("makeFs"),T=Symbol("file"),A=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"),x=Symbol("ended"),C=Symbol("maybeClose"),j=Symbol("skip"),z=Symbol("doChown"),D=Symbol("uid"),d=Symbol("gid"),m=Symbol("checkedCwd"),_=re("crypto"),R=RP(),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[x]=!0,this[C]()},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[x]=!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)}[C](){this[x]&&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,cn=S.mtime;n.futimes(pt,dt,cn,un=>un?n.utimes(Re,dt,cn,va=>be(va&&un)):be())}if(this[z](S)){ce++;let dt=this[D](S),cn=this[d](S);n.fchown(pt,dt,cn,un=>un?n.chown(Re,dt,cn,va=>be(va&&un)):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)}[A](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[C]()}[j](S){this[N](),S.resume()}[L](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))}[O](S){S.type==="SymbolicLink"?ie(this.dirCache):S.type!=="Directory"&&G(this.dirCache,S.absolute)}[b](S,Y){this[O](S);let J=he=>{this[O](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[L](S,pe))return this[k](null,S,J);if(pe.isDirectory()){if(S.type==="Directory"){let Re=!this.noChmod&&S.mode&&(pe.mode&4095)!==S.mode,pt=dt=>this[k](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[k](Re,S,J))}if(S.absolute===this.cwd)return this[k](null,S,J);B(S.absolute,Re=>this[k](Re,S,J))})};this[m]?ce():oe()}[k](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[A](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{[k](S,Y){return super[k](S,Y,()=>{})}[y](S){if(this[O](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[L](S,J))return this[k](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[k](he,S)}let[ce]=Ee(()=>n.rmdirSync(S.absolute));this[k](ce,S)}let[oe]=S.absolute===this.cwd?[]:Ee(()=>Z(S.absolute));this[k](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)})}[A](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}),xP=te((t,e)=>{"use strict";W();var r=Zn(),i=uS(),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(L=>[a(L),!0])),b=p.filter,O=(L,k)=>{let T=k||o.parse(L).root||".",A=L===T?!1:y.has(L)?y.get(L):O(o.dirname(L),T);return y.set(L,A),A};p.filter=b?(L,k)=>b(L,k)&&O(a(L)):L=>O(a(L))},c=p=>{let g=new i.Sync(p),y=p.file,b=n.statSync(y),O=p.maxReadSize||16*1024*1024;new s.ReadStreamSync(y,{readSize:O,size:b.size}).pipe(g)},u=(p,g)=>{let y=new i(p),b=p.maxReadSize||16*1024*1024,O=p.file,L=new Promise((k,T)=>{y.on("error",T),y.on("close",k),n.stat(O,(A,I)=>{if(A)T(A);else{let w=new s.ReadStream(O,{readSize:b,size:I.size});w.on("error",T),w.pipe(y)}})});return g?L.then(g,g):L},f=p=>new i.Sync(p),h=p=>new i(p)}),AP=te(t=>{"use strict";W(),t.c=t.create=pP(),t.r=t.replace=aS(),t.t=t.list=Wh(),t.u=t.update=dP(),t.x=t.extract=xP(),t.Pack=Gh(),t.Unpack=uS(),t.Parse=zh(),t.ReadEntry=Uh(),t.WriteEntry=sS(),t.Header=Jn(),t.Pax=Hh(),t.types=rS()}),OP=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}}),TP=te(t=>{W();var e=OP();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}}}),kP=te((t,e)=>{W(),e.exports=TP()}),CP=te((t,e)=>{W();var r=kP();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}),LP={};JL(LP,{bold:()=>MP,dimmed:()=>BP,error:()=>HP,grey:()=>jP,info:()=>DP,item:()=>$P,log:()=>si,turboBlue:()=>rn,turboGradient:()=>IP,turboLoader:()=>NP,turboRed:()=>mS,underline:()=>FP,warn:()=>UP,yellow:()=>gS});W();var pS="#0099F7",dS="#F11712",PP="#FFFF00",Yh=t=>{let e=qP(t);return r=>`\x1B[38;5;${e}m${r}${(0,Ke.reset)("")}`},IP=(0,fS.default)(pS,dS),rn=Yh(pS),mS=Yh(dS),gS=Yh(PP),NP=t=>(0,hS.default)({text:t,spinner:{frames:[" ",rn("> "),rn(">> "),rn(">>>")]}}),DP=(...t)=>{si(rn((0,Ke.bold)(">>>")),t.join(" "))},MP=(...t)=>{si((0,Ke.bold)(t.join(" ")))},FP=(...t)=>{si((0,Ke.underline)(t.join(" ")))},BP=(...t)=>{si((0,Ke.dim)(t.join(" ")))},jP=(...t)=>{si((0,Ke.gray)(t.join(" ")))},$P=(...t)=>{si(rn((0,Ke.bold)(" \u2022")),t.join(" "))},si=(...t)=>{console.log(...t)},UP=(...t)=>{console.error(gS((0,Ke.bold)(">>>")),t.join(" "))},HP=(...t)=>{console.error(mS((0,Ke.bold)(">>>")),t.join(" "))};function qP(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 uB=ua(rP());W();W();function YP(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}W();W();function Fh(t){return Fh=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},Fh(t)}W();function VP(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function KP(t,e){if(e&&(Fh(e)==="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return VP(t)}W();function ca(t){return ca=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},ca(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 ZP(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 XP(t){return Function.toString.call(t).indexOf("[native code]")!==-1}W();W();function JP(){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 la(t,e,r){return JP()?la=Reflect.construct.bind():la=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},la.apply(null,arguments)}function Bh(t){var e=typeof Map=="function"?new Map:void 0;return Bh=function(r){if(r===null||!XP(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 la(r,arguments,ca(this).constructor)}return i.prototype=Object.create(r.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),Yn(i,r)},Bh(t)}var hB=ua(lP()),dB=function(t){ZP(e,t);function e(r){var i;return YP(this,e),i=KP(this,ca(e).call(this,"No package.json could be found upwards from the directory ".concat(r))),i.directory=r,i}return e}(Bh(Error));W();W();W();W();W();W();var xB=ua(AP());W();W();var TB=ua(CP());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 QP=/^(?!_)(?<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 ha({workspaceRoot:t}){let{packageManager:e}=Ze({workspaceRoot:t});if(e)try{let r=QP.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 Xw({workspaceRoot:t}){let e=ir.default.join(t,"pnpm-workspace.yaml");if((0,nt.existsSync)(e))try{let r=Wa.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 fa({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 Vh({workspaces:t}){var e;return t?Array.isArray(t)?t:"packages"in t?(e=t.packages)!=null?e:[]:[]:[]}function pa({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 eI({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 tI({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 rI({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}=rI({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=ha({workspaceRoot:t.workspaceRoot});return yt.default.existsSync(e)||yt.default.existsSync(r)||i===Or.name}async function iI(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:fa({root:t.workspaceRoot,lockFile:Or.lock,workspaceConfig:"pnpm-workspace.yaml"}),workspaceData:{globs:Xw(t),workspaces:pa({workspaceGlobs:Xw(t),...t})}}}async function nI(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 sI(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 oI(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 aI(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 lI={detect:RS,read:iI,create:nI,remove:sI,clean:oI,convertLock:aI};W();var nn={name:"npm",lock:"package-lock.json"};async function xS(t){let e=Vn.default.join(t.workspaceRoot,nn.lock),r=ha({workspaceRoot:t.workspaceRoot});return ti.default.existsSync(e)||r===nn.name}async function cI(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=Vh({workspaces:e.workspaces});return{name:r,description:i,packageManager:nn.name,paths:fa({root:t.workspaceRoot,lockFile:nn.lock}),workspaceData:{globs:n,workspaces:pa({workspaceGlobs:n,...t})}}}async function uI(t){let{project:e,options:r,to:i,logger:n}=t,s=e.workspaceData.globs.length>0;n.mainStep(Tr({packageManager:nn.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 hI(t){let{project:e,logger:r,options:i}=t,n=e.workspaceData.globs.length>0;r.mainStep(Tr({packageManager:nn.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 fI(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 pI(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 dI={detect:xS,read:cI,create:uI,remove:hI,clean:fI,convertLock:pI};W();var ii={name:"yarn",lock:"yarn.lock"};async function AS(t){let e=sn.default.join(t.workspaceRoot,ii.lock),r=ha({workspaceRoot:t.workspaceRoot});return ri.default.existsSync(e)||r===ii.name}async function mI(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=Vh({workspaces:e.workspaces});return{name:r,description:i,packageManager:ii.name,paths:fa({root:t.workspaceRoot,lockFile:ii.lock}),workspaceData:{globs:n,workspaces:pa({workspaceGlobs:n,...t})}}}async function gI(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 ${sn.default.relative(e.paths.root,e.paths.packageJson)}`),o.packageManager=`${r.name}@${r.version}`,s?(i.rootStep(`adding "workspaces" field to ${sn.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 yI(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 bI(t){let{project:e,logger:r,options:i}=t;r.subStep(`removing ${sn.default.relative(e.paths.root,e.paths.lockfile)}`),i!=null&&i.dry||ri.default.rmSync(e.paths.lockfile,{force:!0})}async function _I(t){let{project:e,options:r,logger:i}=t,n=()=>{i.subStep(`converting ${sn.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 wI={detect:AS,read:mI,create:gI,remove:yI,clean:bI,convertLock:_I};W();var on={name:"bun",lock:"bun.lockb"};async function OS(t){let e=Kn.default.join(t.workspaceRoot,on.lock),r=ha({workspaceRoot:t.workspaceRoot});return ni.default.existsSync(e)||r===on.name}async function SI(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=Vh({workspaces:e.workspaces});return{name:r,description:i,packageManager:on.name,paths:fa({root:t.workspaceRoot,lockFile:on.lock}),workspaceData:{globs:n,workspaces:pa({workspaceGlobs:n,...t})}}}async function EI(t){let{project:e,to:r,logger:i,options:n}=t,s=e.workspaceData.globs.length>0;if(!tI({project:e}))throw new je("Unable to convert project to bun - workspace globs unsupported",{type:"bun-workspace_glob_error"});i.mainStep(Tr({packageManager:on.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 vI(t){let{project:e,logger:r,options:i}=t,n=e.workspaceData.globs.length>0;r.mainStep(Tr({packageManager:on.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 RI(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 xI(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 AI={detect:OS,read:SI,create:EI,remove:vI,clean:RI,convertLock:xI},TS={pnpm:lI,yarn:wI,npm:dI,bun:AI};W();async function rs({root:t}){let{exists:e,absolute:r}=eI({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 Kh={name:"@turbo/codemod",version:"2.7.2-canary.1",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.1.0","gradient-string":"2.0.1",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.5.0","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.5","@types/node":"18.17.4","@types/semver":"7.3.12","@types/uuid":"9.0.0",deepmerge:"4.2.2",jest:"29.7.0",plop:"3.1.1",semver:"7.5.0","ts-jest":"29.2.5",tsup:"6.7.0",typescript:"5.5.4"},files:["dist"],publishConfig:{access:"public"}};var ln=X(require("os")),WS=require("child_process"),$e=X(require("picocolors")),YS=require("inquirer");var Zh=X(require("picocolors")),kS=X(require("is-git-clean"));function da({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(`${Zh.default.yellow("WARNING")}: ${i}. Forcibly continuing...`):(se.log("Thank you for using @turbo/codemod!"),se.log(Zh.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 sI(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 oI(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 aI(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 lI={detect:RS,read:iI,create:nI,remove:sI,clean:oI,convertLock:aI};W();var nn={name:"npm",lock:"package-lock.json"};async function xS(t){let e=Vn.default.join(t.workspaceRoot,nn.lock),r=ha({workspaceRoot:t.workspaceRoot});return ti.default.existsSync(e)||r===nn.name}async function cI(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=Vh({workspaces:e.workspaces});return{name:r,description:i,packageManager:nn.name,paths:fa({root:t.workspaceRoot,lockFile:nn.lock}),workspaceData:{globs:n,workspaces:pa({workspaceGlobs:n,...t})}}}async function uI(t){let{project:e,options:r,to:i,logger:n}=t,s=e.workspaceData.globs.length>0;n.mainStep(Tr({packageManager:nn.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 hI(t){let{project:e,logger:r,options:i}=t,n=e.workspaceData.globs.length>0;r.mainStep(Tr({packageManager:nn.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 fI(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 pI(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 dI={detect:xS,read:cI,create:uI,remove:hI,clean:fI,convertLock:pI};W();var ii={name:"yarn",lock:"yarn.lock"};async function AS(t){let e=sn.default.join(t.workspaceRoot,ii.lock),r=ha({workspaceRoot:t.workspaceRoot});return ri.default.existsSync(e)||r===ii.name}async function mI(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=Vh({workspaces:e.workspaces});return{name:r,description:i,packageManager:ii.name,paths:fa({root:t.workspaceRoot,lockFile:ii.lock}),workspaceData:{globs:n,workspaces:pa({workspaceGlobs:n,...t})}}}async function gI(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 ${sn.default.relative(e.paths.root,e.paths.packageJson)}`),o.packageManager=`${r.name}@${r.version}`,s?(i.rootStep(`adding "workspaces" field to ${sn.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 yI(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 bI(t){let{project:e,logger:r,options:i}=t;r.subStep(`removing ${sn.default.relative(e.paths.root,e.paths.lockfile)}`),i!=null&&i.dry||ri.default.rmSync(e.paths.lockfile,{force:!0})}async function _I(t){let{project:e,options:r,logger:i}=t,n=()=>{i.subStep(`converting ${sn.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 wI={detect:AS,read:mI,create:gI,remove:yI,clean:bI,convertLock:_I};W();var on={name:"bun",lock:"bun.lockb"};async function OS(t){let e=Kn.default.join(t.workspaceRoot,on.lock),r=ha({workspaceRoot:t.workspaceRoot});return ni.default.existsSync(e)||r===on.name}async function SI(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=Vh({workspaces:e.workspaces});return{name:r,description:i,packageManager:on.name,paths:fa({root:t.workspaceRoot,lockFile:on.lock}),workspaceData:{globs:n,workspaces:pa({workspaceGlobs:n,...t})}}}async function EI(t){let{project:e,to:r,logger:i,options:n}=t,s=e.workspaceData.globs.length>0;if(!tI({project:e}))throw new je("Unable to convert project to bun - workspace globs unsupported",{type:"bun-workspace_glob_error"});i.mainStep(Tr({packageManager:on.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 vI(t){let{project:e,logger:r,options:i}=t,n=e.workspaceData.globs.length>0;r.mainStep(Tr({packageManager:on.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 RI(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 xI(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 AI={detect:OS,read:SI,create:EI,remove:vI,clean:RI,convertLock:xI},TS={pnpm:lI,yarn:wI,npm:dI,bun:AI};W();async function rs({root:t}){let{exists:e,absolute:r}=eI({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 Kh={name:"@turbo/codemod",version:"2.7.2-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.1.0","gradient-string":"2.0.1",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.5.0","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.5","@types/node":"18.17.4","@types/semver":"7.3.12","@types/uuid":"9.0.0",deepmerge:"4.2.2",jest:"29.7.0",plop:"3.1.1",semver:"7.5.0","ts-jest":"29.2.5",tsup:"6.7.0",typescript:"5.5.4"},files:["dist"],publishConfig:{access:"public"}};var ln=X(require("os")),WS=require("child_process"),$e=X(require("picocolors")),YS=require("inquirer");var Zh=X(require("picocolors")),kS=X(require("is-git-clean"));function da({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(`${Zh.default.yellow("WARNING")}: ${i}. Forcibly continuing...`):(se.log("Thank you for using @turbo/codemod!"),se.log(Zh.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 Xh=X(require("path")),CS=X(require("fs"));function an({directory:t}){let e=Xh.default.isAbsolute(t)?t:Xh.default.join(process.cwd(),t);return{exists:CS.default.existsSync(e),absolute:e}}var _a=X(require("picocolors"));var bt=X(require("picocolors")),ma=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")),Jh=X(require("path"));var ga=X(require("picocolors")),ba=require("diff"),kr=require("fs-extra"),ya=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{Jh.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,ba.diffJson)(this.before,e.after):this.changes=(0,ba.diffLines)(this.before,e.after):this.changes=[]}fileName(){return Jh.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(ga.default.green(r.value)):r.removed?process.stdout.write(ga.default.red(r.value)):process.stdout.write(ga.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 ma(e)}abortTransform(e){return this.logger.error(e.reason),{fatalError:new Error(e.reason),changes:e.changes||{}}}modifyFile(e){this.modifications[e.filePath]=new ya({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(_a.default.dim(n.fileName()));else try{n.write(),s.action="modified",this.logger.modified(_a.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(_a.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")),NI=["package.json","turbo.json",".git"];function NS({directory:t}){return NI.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")),DI="https://registry.npmjs.org";async function MI({packageName:t}){var r;let e=((r=process.env.npm_config_registry)==null?void 0:r.replace(/\/$/,""))||DI;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 MI({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 wa=X(require("path")),$S=X(require("fs-extra")),jS=process.env.NODE_ENV==="test"?wa.default.join(__dirname,"../transforms"):wa.default.join(__dirname,"./transforms");function Sa(){return $S.default.readdirSync(jS).map(e=>{let r=wa.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=Sa().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")),Qh=X(require("fs-extra")),qS=require("semver");function FI(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 BI({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 jI({root:t}){let e=HS.default.join(t,"package.json");if(!Qh.default.existsSync(e)){se.error(`Unable to find package.json at ${e}`);return}let r=Qh.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 Zc(),n=Object.keys(i).find(u=>{let f=i[u];return f&&r?r.includes(f):!1});if(r&&n)return FI(n,e);let{packageManager:s}=t,o=t.workspaceData.globs.length>0,a=jI({root:t.paths.root}),c=(await Kc())[s];if(c&&a)return BI({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 ef(t,e){e.dryRun||da({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}=an({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}=an({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}`,ln.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"}`})`,ln.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)")}`,ln.default.EOL);else{se.log(`Upgrading turbo with ${$e.default.bold(h)}`,ln.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)}`,ln.default.EOL);wt({success:!0})}var Cr=X(require("picocolors")),VS=require("inquirer");async function tf(t,e,r){let i=Sa();if(r.list)return se.log(i.map(h=>`- ${Cr.default.cyan(h.name)}`).join(`
|
|
47
47
|
`)),process.exit(0);r.dryRun||da({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}=an({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}=an({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.7.2-canary.
|
|
3
|
+
"version": "2.7.2-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",
|
|
@@ -45,13 +45,13 @@
|
|
|
45
45
|
"ts-jest": "29.2.5",
|
|
46
46
|
"tsup": "6.7.0",
|
|
47
47
|
"typescript": "5.5.4",
|
|
48
|
+
"@turbo/gen": "2.7.2-canary.2",
|
|
48
49
|
"@turbo/eslint-config": "0.0.0",
|
|
49
50
|
"@turbo/test-utils": "0.0.0",
|
|
50
|
-
"@turbo/gen": "2.7.2-canary.1",
|
|
51
|
-
"@turbo/types": "2.7.2-canary.1",
|
|
52
|
-
"@turbo/utils": "0.0.0",
|
|
53
51
|
"@turbo/tsconfig": "0.0.0",
|
|
54
|
-
"@turbo/
|
|
52
|
+
"@turbo/utils": "0.0.0",
|
|
53
|
+
"@turbo/types": "2.7.2-canary.2",
|
|
54
|
+
"@turbo/workspaces": "2.7.2-canary.2"
|
|
55
55
|
},
|
|
56
56
|
"files": [
|
|
57
57
|
"dist"
|