diff --git a/__tests__/github.test.ts b/__tests__/github.test.ts index 564e95f..877772d 100644 --- a/__tests__/github.test.ts +++ b/__tests__/github.test.ts @@ -226,6 +226,64 @@ describe('github', () => { ); expect(createRelease.mock.calls[0][0]).not.toHaveProperty('previous_tag_name'); }); + + it('passes discussion_category_name when finalizing a release', async () => { + const updateRelease = vi.fn(async () => ({ + data: { + id: 1, + upload_url: 'test', + html_url: 'test', + tag_name: 'v1.0.0', + name: 'v1.0.0', + body: 'test', + target_commitish: 'main', + draft: false, + prerelease: false, + assets: [], + }, + })); + + const releaser = new GitHubReleaser({ + rest: { + repos: { + generateReleaseNotes: vi.fn(), + createRelease: vi.fn(), + updateRelease, + getReleaseByTag: vi.fn(), + listReleaseAssets: vi.fn(), + deleteReleaseAsset: vi.fn(), + deleteRelease: vi.fn(), + updateReleaseAsset: vi.fn(), + listReleases: { + endpoint: { + merge: vi.fn(), + }, + }, + }, + }, + paginate: { + iterator: vi.fn(), + }, + request: vi.fn(), + } as any); + + await releaser.finalizeRelease({ + owner: 'owner', + repo: 'repo', + release_id: 1, + make_latest: 'legacy', + discussion_category_name: 'Announcements', + }); + + expect(updateRelease).toHaveBeenCalledWith({ + owner: 'owner', + repo: 'repo', + release_id: 1, + draft: false, + make_latest: 'legacy', + discussion_category_name: 'Announcements', + }); + }); }); describe('finalizeRelease input_draft behavior', () => { @@ -309,10 +367,49 @@ describe('github', () => { owner: 'owner', repo: 'repo', release_id: release.id, + make_latest: undefined, + discussion_category_name: undefined, }); } }); + it('passes discussion_category_name through when finalizing a draft release', async () => { + const finalizeReleaseSpy = vi.fn(async () => ({ data: finalizedRelease })); + + const releaser: Releaser = { + getReleaseByTag: () => Promise.reject('Not implemented'), + createRelease: () => Promise.reject('Not implemented'), + updateRelease: () => Promise.reject('Not implemented'), + finalizeRelease: finalizeReleaseSpy, + allReleases: async function* () { + throw new Error('Not implemented'); + }, + listReleaseAssets: () => Promise.reject('Not implemented'), + deleteReleaseAsset: () => Promise.reject('Not implemented'), + deleteRelease: () => Promise.reject('Not implemented'), + updateReleaseAsset: () => Promise.reject('Not implemented'), + uploadReleaseAsset: () => Promise.reject('Not implemented'), + }; + + await finalizeRelease( + { + ...config, + input_draft: false, + input_discussion_category_name: 'Announcements', + }, + releaser, + draftRelease, + ); + + expect(finalizeReleaseSpy).toHaveBeenCalledWith({ + owner: 'owner', + repo: 'repo', + release_id: draftRelease.id, + make_latest: undefined, + discussion_category_name: 'Announcements', + }); + }); + it('deletes a newly created draft when tag creation is blocked by repository rules', async () => { const finalizeReleaseSpy = vi.fn(async () => { throw { diff --git a/dist/index.js b/dist/index.js index 9040c6f..6d60094 100644 --- a/dist/index.js +++ b/dist/index.js @@ -49,10 +49,10 @@ ${o}`;break;case"retry":SB(o)&&(s[i]=o);break;case"id":UB(o)&&(s[i]=o);break;cas globstar while`,e,l,t,p,g),this.matchOne(e.slice(l),t.slice(p),s))return this.debug("globstar found match!",l,a,g),!0;if(g==="."||g===".."||!r.dot&&g.charAt(0)==="."){this.debug("dot detected!",e,l,t,p);break}this.debug("globstar swallow a segment, and continue"),l++}return!!(s&&(this.debug(` >>> no match, partial?`,e,l,t,p),l===a))}let h;if(typeof c=="string"?(h=u===c,this.debug("string match",c,u,h)):(h=c.test(u),this.debug("pattern match",c,u,h)),!h)return!1}if(o===a&&n===A)return!0;if(o===a)return s;if(n===A)return o===a-1&&e[o]==="";throw new Error("wtf?")}braceExpand(){return PI(this.pattern,this.options)}parse(e){Ja(e);let t=this.options;if(e==="**")return be;if(e==="")return"";let s,r=null;(s=e.match(RL))?r=t.dot?FL:TL:(s=e.match(BL))?r=(t.nocase?t.dot?bL:wL:t.dot?IL:CL)(s[1]):(s=e.match(SL))?r=(t.nocase?t.dot?NL:UL:t.dot?GL:ML)(s):(s=e.match(yL))?r=t.dot?vL:xL:(s=e.match(kL))&&(r=DL);let i=LI.fromGlob(e,this.options).toMMPattern();return r&&typeof i=="object"&&Reflect.defineProperty(i,"test",{value:r}),i}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let e=this.set;if(!e.length)return this.regexp=!1,this.regexp;let t=this.options,s=t.noglobstar?YL:t.dot?OL:JL,r=new Set(t.nocase?["i"]:[]),i=e.map(a=>{let A=a.map(u=>{if(u instanceof RegExp)for(let l of u.flags.split(""))r.add(l);return typeof u=="string"?WL(u):u===be?be:u._src});A.forEach((u,l)=>{let p=A[l+1],g=A[l-1];u!==be||g===be||(g===void 0?p!==void 0&&p!==be?A[l+1]="(?:\\/|"+s+"\\/)?"+p:A[l]=s:p===void 0?A[l-1]=g+"(?:\\/|\\/"+s+")?":p!==be&&(A[l-1]=g+"(?:\\/|\\/"+s+"\\/)"+p,A[l+1]=be))});let c=A.filter(u=>u!==be);if(this.partial&&c.length>=1){let u=[];for(let l=1;l<=c.length;l++)u.push(c.slice(0,l).join("/"));return"(?:"+u.join("|")+")"}return c.join("/")}).join("|"),[o,n]=e.length>1?["(?:",")"]:["",""];i="^"+o+i+n+"$",this.partial&&(i="^(?:\\/|"+o+i.slice(1,-1)+n+")$"),this.negate&&(i="^(?!"+i+").+$");try{this.regexp=new RegExp(i,[...r].join(""))}catch{this.regexp=!1}return this.regexp}slashSplit(e){return this.preserveMultipleSlashes?e.split("/"):this.isWindows&&/^\/\/[^\/]+/.test(e)?["",...e.split(/\/+/)]:e.split(/\/+/)}match(e,t=this.partial){if(this.debug("match",e,this.pattern),this.comment)return!1;if(this.empty)return e==="";if(e==="/"&&t)return!0;let s=this.options;this.isWindows&&(e=e.split("\\").join("/"));let r=this.slashSplit(e);this.debug(this.pattern,"split",r);let i=this.set;this.debug(this.pattern,"set",i);let o=r[r.length-1];if(!o)for(let n=r.length-2;!o&&n>=0;n--)o=r[n];for(let n=0;n{typeof ep.emitWarning=="function"?ep.emitWarning(e,t,s,r):console.error(`[${s}] ${t}: ${e}`)},Pa=globalThis.AbortController,EI=globalThis.AbortSignal;if(typeof Pa>"u"){EI=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(s,r){this._onabort.push(r)}},Pa=class{constructor(){t()}signal=new EI;abort(s){if(!this.signal.aborted){this.signal.reason=s,this.signal.aborted=!0;for(let r of this.signal._onabort)r(s);this.signal.onabort?.(s)}}};let e=ep.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",t=()=>{e&&(e=!1,qI("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",t))}}var zL=e=>!VI.has(e),ms=e=>e&&e===Math.floor(e)&&e>0&&isFinite(e),WI=e=>ms(e)?e<=Math.pow(2,8)?Uint8Array:e<=Math.pow(2,16)?Uint16Array:e<=Math.pow(2,32)?Uint32Array:e<=Number.MAX_SAFE_INTEGER?Ya:null:null,Ya=class extends Array{constructor(e){super(e),this.fill(0)}},ZL=class po{heap;length;static#e=!1;static create(t){let s=WI(t);if(!s)return[];po.#e=!0;let r=new po(t,s);return po.#e=!1,r}constructor(t,s){if(!po.#e)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new s(t),this.length=0}push(t){this.heap[this.length++]=t}pop(){return this.heap[--this.length]}},Va=class jI{#e;#t;#i;#s;#r;#A;#a;#c;get perf(){return this.#c}ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#l;#g;#h;#u;#n;#d;#C;#B;#E;#k;#m;#b;#y;#f;#Q;#I;#x;#o;#U;static unsafeExposeInternals(t){return{starts:t.#y,ttls:t.#f,autopurgeTimers:t.#Q,sizes:t.#b,keyMap:t.#h,keyList:t.#u,valList:t.#n,next:t.#d,prev:t.#C,get head(){return t.#B},get tail(){return t.#E},free:t.#k,isBackgroundFetch:s=>t.#p(s),backgroundFetch:(s,r,i,o)=>t.#J(s,r,i,o),moveToTail:s=>t.#G(s),indexes:s=>t.#R(s),rindexes:s=>t.#T(s),isStale:s=>t.#w(s)}}get max(){return this.#e}get maxSize(){return this.#t}get calculatedSize(){return this.#g}get size(){return this.#l}get fetchMethod(){return this.#A}get memoMethod(){return this.#a}get dispose(){return this.#i}get onInsert(){return this.#s}get disposeAfter(){return this.#r}constructor(t){let{max:s=0,ttl:r,ttlResolution:i=1,ttlAutopurge:o,updateAgeOnGet:n,updateAgeOnHas:a,allowStale:A,dispose:c,onInsert:u,disposeAfter:l,noDisposeOnSet:p,noUpdateTTL:g,maxSize:h=0,maxEntrySize:E=0,sizeCalculation:f,fetchMethod:d,memoMethod:m,noDeleteOnFetchRejection:C,noDeleteOnStaleGet:B,allowStaleOnFetchRejection:b,allowStaleOnFetchAbort:S,ignoreFetchAbort:G,perf:pe}=t;if(pe!==void 0&&typeof pe?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(this.#c=pe??jL,s!==0&&!ms(s))throw new TypeError("max option must be a nonnegative integer");let he=s?WI(s):Array;if(!he)throw new Error("invalid max value: "+s);if(this.#e=s,this.#t=h,this.maxEntrySize=E||this.#t,this.sizeCalculation=f,this.sizeCalculation){if(!this.#t&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(m!==void 0&&typeof m!="function")throw new TypeError("memoMethod must be a function if defined");if(this.#a=m,d!==void 0&&typeof d!="function")throw new TypeError("fetchMethod must be a function if specified");if(this.#A=d,this.#x=!!d,this.#h=new Map,this.#u=new Array(s).fill(void 0),this.#n=new Array(s).fill(void 0),this.#d=new he(s),this.#C=new he(s),this.#B=0,this.#E=0,this.#k=ZL.create(s),this.#l=0,this.#g=0,typeof c=="function"&&(this.#i=c),typeof u=="function"&&(this.#s=u),typeof l=="function"?(this.#r=l,this.#m=[]):(this.#r=void 0,this.#m=void 0),this.#I=!!this.#i,this.#U=!!this.#s,this.#o=!!this.#r,this.noDisposeOnSet=!!p,this.noUpdateTTL=!!g,this.noDeleteOnFetchRejection=!!C,this.allowStaleOnFetchRejection=!!b,this.allowStaleOnFetchAbort=!!S,this.ignoreFetchAbort=!!G,this.maxEntrySize!==0){if(this.#t!==0&&!ms(this.#t))throw new TypeError("maxSize must be a positive integer if specified");if(!ms(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#H()}if(this.allowStale=!!A,this.noDeleteOnStaleGet=!!B,this.updateAgeOnGet=!!n,this.updateAgeOnHas=!!a,this.ttlResolution=ms(i)||i===0?i:1,this.ttlAutopurge=!!o,this.ttl=r||0,this.ttl){if(!ms(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#F()}if(this.#e===0&&this.ttl===0&&this.#t===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#e&&!this.#t){let ht="LRU_CACHE_UNBOUNDED";zL(ht)&&(VI.add(ht),qI("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",ht,jI))}}getRemainingTTL(t){return this.#h.has(t)?1/0:0}#F(){let t=new Ya(this.#e),s=new Ya(this.#e);this.#f=t,this.#y=s;let r=this.ttlAutopurge?new Array(this.#e):void 0;this.#Q=r,this.#L=(n,a,A=this.#c.now())=>{if(s[n]=a!==0?A:0,t[n]=a,r?.[n]&&(clearTimeout(r[n]),r[n]=void 0),a!==0&&r){let c=setTimeout(()=>{this.#w(n)&&this.#D(this.#u[n],"expire")},a+1);c.unref&&c.unref(),r[n]=c}},this.#v=n=>{s[n]=t[n]!==0?this.#c.now():0},this.#S=(n,a)=>{if(t[a]){let A=t[a],c=s[a];if(!A||!c)return;n.ttl=A,n.start=c,n.now=i||o();let u=n.now-c;n.remainingTTL=A-u}};let i=0,o=()=>{let n=this.#c.now();if(this.ttlResolution>0){i=n;let a=setTimeout(()=>i=0,this.ttlResolution);a.unref&&a.unref()}return n};this.getRemainingTTL=n=>{let a=this.#h.get(n);if(a===void 0)return 0;let A=t[a],c=s[a];if(!A||!c)return 1/0;let u=(i||o())-c;return A-u},this.#w=n=>{let a=s[n],A=t[n];return!!A&&!!a&&(i||o())-a>A}}#v=()=>{};#S=()=>{};#L=()=>{};#w=()=>!1;#H(){let t=new Ya(this.#e);this.#g=0,this.#b=t,this.#M=s=>{this.#g-=t[s],t[s]=0},this.#_=(s,r,i,o)=>{if(this.#p(r))return 0;if(!ms(i))if(o){if(typeof o!="function")throw new TypeError("sizeCalculation must be a function");if(i=o(r,s),!ms(i))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return i},this.#N=(s,r,i)=>{if(t[s]=r,this.#t){let o=this.#t-t[s];for(;this.#g>o;)this.#O(!0)}this.#g+=t[s],i&&(i.entrySize=r,i.totalCalculatedSize=this.#g)}}#M=t=>{};#N=(t,s,r)=>{};#_=(t,s,r,i)=>{if(r||i)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#R({allowStale:t=this.allowStale}={}){if(this.#l)for(let s=this.#E;!(!this.#Y(s)||((t||!this.#w(s))&&(yield s),s===this.#B));)s=this.#C[s]}*#T({allowStale:t=this.allowStale}={}){if(this.#l)for(let s=this.#B;!(!this.#Y(s)||((t||!this.#w(s))&&(yield s),s===this.#E));)s=this.#d[s]}#Y(t){return t!==void 0&&this.#h.get(this.#u[t])===t}*entries(){for(let t of this.#R())this.#n[t]!==void 0&&this.#u[t]!==void 0&&!this.#p(this.#n[t])&&(yield[this.#u[t],this.#n[t]])}*rentries(){for(let t of this.#T())this.#n[t]!==void 0&&this.#u[t]!==void 0&&!this.#p(this.#n[t])&&(yield[this.#u[t],this.#n[t]])}*keys(){for(let t of this.#R()){let s=this.#u[t];s!==void 0&&!this.#p(this.#n[t])&&(yield s)}}*rkeys(){for(let t of this.#T()){let s=this.#u[t];s!==void 0&&!this.#p(this.#n[t])&&(yield s)}}*values(){for(let t of this.#R())this.#n[t]!==void 0&&!this.#p(this.#n[t])&&(yield this.#n[t])}*rvalues(){for(let t of this.#T())this.#n[t]!==void 0&&!this.#p(this.#n[t])&&(yield this.#n[t])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(t,s={}){for(let r of this.#R()){let i=this.#n[r],o=this.#p(i)?i.__staleWhileFetching:i;if(o!==void 0&&t(o,this.#u[r],this))return this.get(this.#u[r],s)}}forEach(t,s=this){for(let r of this.#R()){let i=this.#n[r],o=this.#p(i)?i.__staleWhileFetching:i;o!==void 0&&t.call(s,o,this.#u[r],this)}}rforEach(t,s=this){for(let r of this.#T()){let i=this.#n[r],o=this.#p(i)?i.__staleWhileFetching:i;o!==void 0&&t.call(s,o,this.#u[r],this)}}purgeStale(){let t=!1;for(let s of this.#T({allowStale:!0}))this.#w(s)&&(this.#D(this.#u[s],"expire"),t=!0);return t}info(t){let s=this.#h.get(t);if(s===void 0)return;let r=this.#n[s],i=this.#p(r)?r.__staleWhileFetching:r;if(i===void 0)return;let o={value:i};if(this.#f&&this.#y){let n=this.#f[s],a=this.#y[s];if(n&&a){let A=n-(this.#c.now()-a);o.ttl=A,o.start=Date.now()}}return this.#b&&(o.size=this.#b[s]),o}dump(){let t=[];for(let s of this.#R({allowStale:!0})){let r=this.#u[s],i=this.#n[s],o=this.#p(i)?i.__staleWhileFetching:i;if(o===void 0||r===void 0)continue;let n={value:o};if(this.#f&&this.#y){n.ttl=this.#f[s];let a=this.#c.now()-this.#y[s];n.start=Math.floor(Date.now()-a)}this.#b&&(n.size=this.#b[s]),t.unshift([r,n])}return t}load(t){this.clear();for(let[s,r]of t){if(r.start){let i=Date.now()-r.start;r.start=this.#c.now()-i}this.set(s,r.value,r)}}set(t,s,r={}){if(s===void 0)return this.delete(t),this;let{ttl:i=this.ttl,start:o,noDisposeOnSet:n=this.noDisposeOnSet,sizeCalculation:a=this.sizeCalculation,status:A}=r,{noUpdateTTL:c=this.noUpdateTTL}=r,u=this.#_(t,s,r.size||0,a);if(this.maxEntrySize&&u>this.maxEntrySize)return A&&(A.set="miss",A.maxEntrySizeExceeded=!0),this.#D(t,"set"),this;let l=this.#l===0?void 0:this.#h.get(t);if(l===void 0)l=this.#l===0?this.#E:this.#k.length!==0?this.#k.pop():this.#l===this.#e?this.#O(!1):this.#l,this.#u[l]=t,this.#n[l]=s,this.#h.set(t,l),this.#d[this.#E]=l,this.#C[l]=this.#E,this.#E=l,this.#l++,this.#N(l,u,A),A&&(A.set="add"),c=!1,this.#U&&this.#s?.(s,t,"add");else{this.#G(l);let p=this.#n[l];if(s!==p){if(this.#x&&this.#p(p)){p.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:g}=p;g!==void 0&&!n&&(this.#I&&this.#i?.(g,t,"set"),this.#o&&this.#m?.push([g,t,"set"]))}else n||(this.#I&&this.#i?.(p,t,"set"),this.#o&&this.#m?.push([p,t,"set"]));if(this.#M(l),this.#N(l,u,A),this.#n[l]=s,A){A.set="replace";let g=p&&this.#p(p)?p.__staleWhileFetching:p;g!==void 0&&(A.oldValue=g)}}else A&&(A.set="update");this.#U&&this.onInsert?.(s,t,s===p?"update":"replace")}if(i!==0&&!this.#f&&this.#F(),this.#f&&(c||this.#L(l,i,o),A&&this.#S(A,l)),!n&&this.#o&&this.#m){let p=this.#m,g;for(;g=p?.shift();)this.#r?.(...g)}return this}pop(){try{for(;this.#l;){let t=this.#n[this.#B];if(this.#O(!0),this.#p(t)){if(t.__staleWhileFetching)return t.__staleWhileFetching}else if(t!==void 0)return t}}finally{if(this.#o&&this.#m){let t=this.#m,s;for(;s=t?.shift();)this.#r?.(...s)}}}#O(t){let s=this.#B,r=this.#u[s],i=this.#n[s];return this.#x&&this.#p(i)?i.__abortController.abort(new Error("evicted")):(this.#I||this.#o)&&(this.#I&&this.#i?.(i,r,"evict"),this.#o&&this.#m?.push([i,r,"evict"])),this.#M(s),this.#Q?.[s]&&(clearTimeout(this.#Q[s]),this.#Q[s]=void 0),t&&(this.#u[s]=void 0,this.#n[s]=void 0,this.#k.push(s)),this.#l===1?(this.#B=this.#E=0,this.#k.length=0):this.#B=this.#d[s],this.#h.delete(r),this.#l--,s}has(t,s={}){let{updateAgeOnHas:r=this.updateAgeOnHas,status:i}=s,o=this.#h.get(t);if(o!==void 0){let n=this.#n[o];if(this.#p(n)&&n.__staleWhileFetching===void 0)return!1;if(this.#w(o))i&&(i.has="stale",this.#S(i,o));else return r&&this.#v(o),i&&(i.has="hit",this.#S(i,o)),!0}else i&&(i.has="miss");return!1}peek(t,s={}){let{allowStale:r=this.allowStale}=s,i=this.#h.get(t);if(i===void 0||!r&&this.#w(i))return;let o=this.#n[i];return this.#p(o)?o.__staleWhileFetching:o}#J(t,s,r,i){let o=s===void 0?void 0:this.#n[s];if(this.#p(o))return o;let n=new Pa,{signal:a}=r;a?.addEventListener("abort",()=>n.abort(a.reason),{signal:n.signal});let A={signal:n.signal,options:r,context:i},c=(E,f=!1)=>{let{aborted:d}=n.signal,m=r.ignoreFetchAbort&&E!==void 0,C=r.ignoreFetchAbort||!!(r.allowStaleOnFetchAbort&&E!==void 0);if(r.status&&(d&&!f?(r.status.fetchAborted=!0,r.status.fetchError=n.signal.reason,m&&(r.status.fetchAbortIgnored=!0)):r.status.fetchResolved=!0),d&&!m&&!f)return l(n.signal.reason,C);let B=g,b=this.#n[s];return(b===g||m&&f&&b===void 0)&&(E===void 0?B.__staleWhileFetching!==void 0?this.#n[s]=B.__staleWhileFetching:this.#D(t,"fetch"):(r.status&&(r.status.fetchUpdated=!0),this.set(t,E,A.options))),E},u=E=>(r.status&&(r.status.fetchRejected=!0,r.status.fetchError=E),l(E,!1)),l=(E,f)=>{let{aborted:d}=n.signal,m=d&&r.allowStaleOnFetchAbort,C=m||r.allowStaleOnFetchRejection,B=C||r.noDeleteOnFetchRejection,b=g;if(this.#n[s]===g&&(!B||!f&&b.__staleWhileFetching===void 0?this.#D(t,"fetch"):m||(this.#n[s]=b.__staleWhileFetching)),C)return r.status&&b.__staleWhileFetching!==void 0&&(r.status.returnedStale=!0),b.__staleWhileFetching;if(b.__returned===b)throw E},p=(E,f)=>{let d=this.#A?.(t,o,A);d&&d instanceof Promise&&d.then(m=>E(m===void 0?void 0:m),f),n.signal.addEventListener("abort",()=>{(!r.ignoreFetchAbort||r.allowStaleOnFetchAbort)&&(E(void 0),r.allowStaleOnFetchAbort&&(E=m=>c(m,!0)))})};r.status&&(r.status.fetchDispatched=!0);let g=new Promise(p).then(c,u),h=Object.assign(g,{__abortController:n,__staleWhileFetching:o,__returned:void 0});return s===void 0?(this.set(t,h,{...A.options,status:void 0}),s=this.#h.get(t)):this.#n[s]=h,h}#p(t){if(!this.#x)return!1;let s=t;return!!s&&s instanceof Promise&&s.hasOwnProperty("__staleWhileFetching")&&s.__abortController instanceof Pa}async fetch(t,s={}){let{allowStale:r=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,ttl:n=this.ttl,noDisposeOnSet:a=this.noDisposeOnSet,size:A=0,sizeCalculation:c=this.sizeCalculation,noUpdateTTL:u=this.noUpdateTTL,noDeleteOnFetchRejection:l=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:p=this.allowStaleOnFetchRejection,ignoreFetchAbort:g=this.ignoreFetchAbort,allowStaleOnFetchAbort:h=this.allowStaleOnFetchAbort,context:E,forceRefresh:f=!1,status:d,signal:m}=s;if(!this.#x)return d&&(d.fetch="get"),this.get(t,{allowStale:r,updateAgeOnGet:i,noDeleteOnStaleGet:o,status:d});let C={allowStale:r,updateAgeOnGet:i,noDeleteOnStaleGet:o,ttl:n,noDisposeOnSet:a,size:A,sizeCalculation:c,noUpdateTTL:u,noDeleteOnFetchRejection:l,allowStaleOnFetchRejection:p,allowStaleOnFetchAbort:h,ignoreFetchAbort:g,status:d,signal:m},B=this.#h.get(t);if(B===void 0){d&&(d.fetch="miss");let b=this.#J(t,B,C,E);return b.__returned=b}else{let b=this.#n[B];if(this.#p(b)){let he=r&&b.__staleWhileFetching!==void 0;return d&&(d.fetch="inflight",he&&(d.returnedStale=!0)),he?b.__staleWhileFetching:b.__returned=b}let S=this.#w(B);if(!f&&!S)return d&&(d.fetch="hit"),this.#G(B),i&&this.#v(B),d&&this.#S(d,B),b;let G=this.#J(t,B,C,E),pe=G.__staleWhileFetching!==void 0&&r;return d&&(d.fetch=S?"stale":"refresh",pe&&S&&(d.returnedStale=!0)),pe?G.__staleWhileFetching:G.__returned=G}}async forceFetch(t,s={}){let r=await this.fetch(t,s);if(r===void 0)throw new Error("fetch() returned undefined");return r}memo(t,s={}){let r=this.#a;if(!r)throw new Error("no memoMethod provided to constructor");let{context:i,forceRefresh:o,...n}=s,a=this.get(t,n);if(!o&&a!==void 0)return a;let A=r(t,a,{options:n,context:i});return this.set(t,A,n),A}get(t,s={}){let{allowStale:r=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,status:n}=s,a=this.#h.get(t);if(a!==void 0){let A=this.#n[a],c=this.#p(A);return n&&this.#S(n,a),this.#w(a)?(n&&(n.get="stale"),c?(n&&r&&A.__staleWhileFetching!==void 0&&(n.returnedStale=!0),r?A.__staleWhileFetching:void 0):(o||this.#D(t,"expire"),n&&r&&(n.returnedStale=!0),r?A:void 0)):(n&&(n.get="hit"),c?A.__staleWhileFetching:(this.#G(a),i&&this.#v(a),A))}else n&&(n.get="miss")}#P(t,s){this.#C[s]=t,this.#d[t]=s}#G(t){t!==this.#E&&(t===this.#B?this.#B=this.#d[t]:this.#P(this.#C[t],this.#d[t]),this.#P(this.#E,t),this.#E=t)}delete(t){return this.#D(t,"delete")}#D(t,s){let r=!1;if(this.#l!==0){let i=this.#h.get(t);if(i!==void 0)if(this.#Q?.[i]&&(clearTimeout(this.#Q?.[i]),this.#Q[i]=void 0),r=!0,this.#l===1)this.#V(s);else{this.#M(i);let o=this.#n[i];if(this.#p(o)?o.__abortController.abort(new Error("deleted")):(this.#I||this.#o)&&(this.#I&&this.#i?.(o,t,s),this.#o&&this.#m?.push([o,t,s])),this.#h.delete(t),this.#u[i]=void 0,this.#n[i]=void 0,i===this.#E)this.#E=this.#C[i];else if(i===this.#B)this.#B=this.#d[i];else{let n=this.#C[i];this.#d[n]=this.#d[i];let a=this.#d[i];this.#C[a]=this.#C[i]}this.#l--,this.#k.push(i)}}if(this.#o&&this.#m?.length){let i=this.#m,o;for(;o=i?.shift();)this.#r?.(...o)}return r}clear(){return this.#V("delete")}#V(t){for(let s of this.#T({allowStale:!0})){let r=this.#n[s];if(this.#p(r))r.__abortController.abort(new Error("deleted"));else{let i=this.#u[s];this.#I&&this.#i?.(r,i,t),this.#o&&this.#m?.push([r,i,t])}}if(this.#h.clear(),this.#n.fill(void 0),this.#u.fill(void 0),this.#f&&this.#y){this.#f.fill(0),this.#y.fill(0);for(let s of this.#Q??[])s!==void 0&&clearTimeout(s);this.#Q?.fill(void 0)}if(this.#b&&this.#b.fill(0),this.#B=0,this.#E=0,this.#k.length=0,this.#g=0,this.#l=0,this.#o&&this.#m){let s=this.#m,r;for(;r=s?.shift();)this.#r?.(...r)}}},mI=typeof process=="object"&&process?process:{stdout:null,stderr:null},XL=e=>!!e&&typeof e=="object"&&(e instanceof Ha||e instanceof rp.default||$L(e)||e_(e)),$L=e=>!!e&&typeof e=="object"&&e instanceof qa.EventEmitter&&typeof e.pipe=="function"&&e.pipe!==rp.default.Writable.prototype.pipe,e_=e=>!!e&&typeof e=="object"&&e instanceof qa.EventEmitter&&typeof e.write=="function"&&typeof e.end=="function",Vt=Symbol("EOF"),qt=Symbol("maybeEmitEnd"),Es=Symbol("emittedEnd"),Sa=Symbol("emittingEnd"),no=Symbol("emittedError"),Ua=Symbol("closed"),fI=Symbol("read"),Na=Symbol("flush"),QI=Symbol("flushChunk"),pt=Symbol("encoding"),Zr=Symbol("decoder"),ce=Symbol("flowing"),ao=Symbol("paused"),Kr=Symbol("resume"),le=Symbol("buffer"),we=Symbol("pipes"),ue=Symbol("bufferLength"),Wu=Symbol("bufferPush"),Ga=Symbol("bufferShift"),Qe=Symbol("objectMode"),se=Symbol("destroyed"),ju=Symbol("error"),zu=Symbol("emitData"),BI=Symbol("emitEnd"),Zu=Symbol("emitEnd2"),vt=Symbol("async"),Ku=Symbol("abort"),Ma=Symbol("aborted"),Ao=Symbol("signal"),Ws=Symbol("dataListeners"),Pe=Symbol("discarded"),co=e=>Promise.resolve().then(e),t_=e=>e(),s_=e=>e==="end"||e==="finish"||e==="prefinish",r_=e=>e instanceof ArrayBuffer||!!e&&typeof e=="object"&&e.constructor&&e.constructor.name==="ArrayBuffer"&&e.byteLength>=0,i_=e=>!Buffer.isBuffer(e)&&ArrayBuffer.isView(e),KI=class{src;dest;opts;ondrain;constructor(e,t,s){this.src=e,this.dest=t,this.opts=s,this.ondrain=()=>e[Kr](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(e){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},o_=class extends KI{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(e,t,s){super(e,t,s),this.proxyErrors=r=>this.dest.emit("error",r),e.on("error",this.proxyErrors)}},n_=e=>!!e.objectMode,a_=e=>!e.objectMode&&!!e.encoding&&e.encoding!=="buffer",Ha=class extends qa.EventEmitter{[ce]=!1;[ao]=!1;[we]=[];[le]=[];[Qe];[pt];[vt];[Zr];[Vt]=!1;[Es]=!1;[Sa]=!1;[Ua]=!1;[no]=null;[ue]=0;[se]=!1;[Ao];[Ma]=!1;[Ws]=0;[Pe]=!1;writable=!0;readable=!0;constructor(...e){let t=e[0]||{};if(super(),t.objectMode&&typeof t.encoding=="string")throw new TypeError("Encoding and objectMode may not be used together");n_(t)?(this[Qe]=!0,this[pt]=null):a_(t)?(this[pt]=t.encoding,this[Qe]=!1):(this[Qe]=!1,this[pt]=null),this[vt]=!!t.async,this[Zr]=this[pt]?new ZI.StringDecoder(this[pt]):null,t&&t.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:()=>this[le]}),t&&t.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:()=>this[we]});let{signal:s}=t;s&&(this[Ao]=s,s.aborted?this[Ku]():s.addEventListener("abort",()=>this[Ku]()))}get bufferLength(){return this[ue]}get encoding(){return this[pt]}set encoding(e){throw new Error("Encoding must be set at instantiation time")}setEncoding(e){throw new Error("Encoding must be set at instantiation time")}get objectMode(){return this[Qe]}set objectMode(e){throw new Error("objectMode must be set at instantiation time")}get async(){return this[vt]}set async(e){this[vt]=this[vt]||!!e}[Ku](){this[Ma]=!0,this.emit("abort",this[Ao]?.reason),this.destroy(this[Ao]?.reason)}get aborted(){return this[Ma]}set aborted(e){}write(e,t,s){if(this[Ma])return!1;if(this[Vt])throw new Error("write after end");if(this[se])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;typeof t=="function"&&(s=t,t="utf8"),t||(t="utf8");let r=this[vt]?co:t_;if(!this[Qe]&&!Buffer.isBuffer(e)){if(i_(e))e=Buffer.from(e.buffer,e.byteOffset,e.byteLength);else if(r_(e))e=Buffer.from(e);else if(typeof e!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[Qe]?(this[ce]&&this[ue]!==0&&this[Na](!0),this[ce]?this.emit("data",e):this[Wu](e),this[ue]!==0&&this.emit("readable"),s&&r(s),this[ce]):e.length?(typeof e=="string"&&!(t===this[pt]&&!this[Zr]?.lastNeed)&&(e=Buffer.from(e,t)),Buffer.isBuffer(e)&&this[pt]&&(e=this[Zr].write(e)),this[ce]&&this[ue]!==0&&this[Na](!0),this[ce]?this.emit("data",e):this[Wu](e),this[ue]!==0&&this.emit("readable"),s&&r(s),this[ce]):(this[ue]!==0&&this.emit("readable"),s&&r(s),this[ce])}read(e){if(this[se])return null;if(this[Pe]=!1,this[ue]===0||e===0||e&&e>this[ue])return this[qt](),null;this[Qe]&&(e=null),this[le].length>1&&!this[Qe]&&(this[le]=[this[pt]?this[le].join(""):Buffer.concat(this[le],this[ue])]);let t=this[fI](e||null,this[le][0]);return this[qt](),t}[fI](e,t){if(this[Qe])this[Ga]();else{let s=t;e===s.length||e===null?this[Ga]():typeof s=="string"?(this[le][0]=s.slice(e),t=s.slice(0,e),this[ue]-=e):(this[le][0]=s.subarray(e),t=s.subarray(0,e),this[ue]-=e)}return this.emit("data",t),!this[le].length&&!this[Vt]&&this.emit("drain"),t}end(e,t,s){return typeof e=="function"&&(s=e,e=void 0),typeof t=="function"&&(s=t,t="utf8"),e!==void 0&&this.write(e,t),s&&this.once("end",s),this[Vt]=!0,this.writable=!1,(this[ce]||!this[ao])&&this[qt](),this}[Kr](){this[se]||(!this[Ws]&&!this[we].length&&(this[Pe]=!0),this[ao]=!1,this[ce]=!0,this.emit("resume"),this[le].length?this[Na]():this[Vt]?this[qt]():this.emit("drain"))}resume(){return this[Kr]()}pause(){this[ce]=!1,this[ao]=!0,this[Pe]=!1}get destroyed(){return this[se]}get flowing(){return this[ce]}get paused(){return this[ao]}[Wu](e){this[Qe]?this[ue]+=1:this[ue]+=e.length,this[le].push(e)}[Ga](){return this[Qe]?this[ue]-=1:this[ue]-=this[le][0].length,this[le].shift()}[Na](e=!1){do;while(this[QI](this[Ga]())&&this[le].length);!e&&!this[le].length&&!this[Vt]&&this.emit("drain")}[QI](e){return this.emit("data",e),this[ce]}pipe(e,t){if(this[se])return e;this[Pe]=!1;let s=this[Es];return t=t||{},e===mI.stdout||e===mI.stderr?t.end=!1:t.end=t.end!==!1,t.proxyErrors=!!t.proxyErrors,s?t.end&&e.end():(this[we].push(t.proxyErrors?new o_(this,e,t):new KI(this,e,t)),this[vt]?co(()=>this[Kr]()):this[Kr]()),e}unpipe(e){let t=this[we].find(s=>s.dest===e);t&&(this[we].length===1?(this[ce]&&this[Ws]===0&&(this[ce]=!1),this[we]=[]):this[we].splice(this[we].indexOf(t),1),t.unpipe())}addListener(e,t){return this.on(e,t)}on(e,t){let s=super.on(e,t);if(e==="data")this[Pe]=!1,this[Ws]++,!this[we].length&&!this[ce]&&this[Kr]();else if(e==="readable"&&this[ue]!==0)super.emit("readable");else if(s_(e)&&this[Es])super.emit(e),this.removeAllListeners(e);else if(e==="error"&&this[no]){let r=t;this[vt]?co(()=>r.call(this,this[no])):r.call(this,this[no])}return s}removeListener(e,t){return this.off(e,t)}off(e,t){let s=super.off(e,t);return e==="data"&&(this[Ws]=this.listeners("data").length,this[Ws]===0&&!this[Pe]&&!this[we].length&&(this[ce]=!1)),s}removeAllListeners(e){let t=super.removeAllListeners(e);return(e==="data"||e===void 0)&&(this[Ws]=0,!this[Pe]&&!this[we].length&&(this[ce]=!1)),t}get emittedEnd(){return this[Es]}[qt](){!this[Sa]&&!this[Es]&&!this[se]&&this[le].length===0&&this[Vt]&&(this[Sa]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[Ua]&&this.emit("close"),this[Sa]=!1)}emit(e,...t){let s=t[0];if(e!=="error"&&e!=="close"&&e!==se&&this[se])return!1;if(e==="data")return!this[Qe]&&!s?!1:this[vt]?(co(()=>this[zu](s)),!0):this[zu](s);if(e==="end")return this[BI]();if(e==="close"){if(this[Ua]=!0,!this[Es]&&!this[se])return!1;let i=super.emit("close");return this.removeAllListeners("close"),i}else if(e==="error"){this[no]=s,super.emit(ju,s);let i=!this[Ao]||this.listeners("error").length?super.emit("error",s):!1;return this[qt](),i}else if(e==="resume"){let i=super.emit("resume");return this[qt](),i}else if(e==="finish"||e==="prefinish"){let i=super.emit(e);return this.removeAllListeners(e),i}let r=super.emit(e,...t);return this[qt](),r}[zu](e){for(let s of this[we])s.dest.write(e)===!1&&this.pause();let t=this[Pe]?!1:super.emit("data",e);return this[qt](),t}[BI](){return this[Es]?!1:(this[Es]=!0,this.readable=!1,this[vt]?(co(()=>this[Zu]()),!0):this[Zu]())}[Zu](){if(this[Zr]){let t=this[Zr].end();if(t){for(let s of this[we])s.dest.write(t);this[Pe]||super.emit("data",t)}}for(let t of this[we])t.end();let e=super.emit("end");return this.removeAllListeners("end"),e}async collect(){let e=Object.assign([],{dataLength:0});this[Qe]||(e.dataLength=0);let t=this.promise();return this.on("data",s=>{e.push(s),this[Qe]||(e.dataLength+=s.length)}),await t,e}async concat(){if(this[Qe])throw new Error("cannot concat in objectMode");let e=await this.collect();return this[pt]?e.join(""):Buffer.concat(e,e.dataLength)}async promise(){return new Promise((e,t)=>{this.on(se,()=>t(new Error("stream destroyed"))),this.on("error",s=>t(s)),this.on("end",()=>e())})}[Symbol.asyncIterator](){this[Pe]=!1;let e=!1,t=async()=>(this.pause(),e=!0,{value:void 0,done:!0});return{next:()=>{if(e)return t();let s=this.read();if(s!==null)return Promise.resolve({done:!1,value:s});if(this[Vt])return t();let r,i,o=c=>{this.off("data",n),this.off("end",a),this.off(se,A),t(),i(c)},n=c=>{this.off("error",o),this.off("end",a),this.off(se,A),this.pause(),r({value:c,done:!!this[Vt]})},a=()=>{this.off("error",o),this.off("data",n),this.off(se,A),t(),r({done:!0,value:void 0})},A=()=>o(new Error("stream destroyed"));return new Promise((c,u)=>{i=u,r=c,this.once(se,A),this.once("error",o),this.once("end",a),this.once("data",n)})},throw:t,return:t,[Symbol.asyncIterator](){return this},[Symbol.asyncDispose]:async()=>{}}}[Symbol.iterator](){this[Pe]=!1;let e=!1,t=()=>(this.pause(),this.off(ju,t),this.off(se,t),this.off("end",t),e=!0,{done:!0,value:void 0}),s=()=>{if(e)return t();let r=this.read();return r===null?t():{done:!1,value:r}};return this.once("end",t),this.once(ju,t),this.once(se,t),{next:s,throw:t,return:t,[Symbol.iterator](){return this},[Symbol.dispose]:()=>{}}}destroy(e){if(this[se])return e?this.emit("error",e):this.emit(se),this;this[se]=!0,this[Pe]=!0,this[le].length=0,this[ue]=0;let t=this;return typeof t.close=="function"&&!this[Ua]&&t.close(),e?this.emit("error",e):this.emit(se),this}static get isStream(){return XL}},A_=Dt.realpathSync.native,go={lstatSync:Dt.lstatSync,readdir:Dt.readdir,readdirSync:Dt.readdirSync,readlinkSync:Dt.readlinkSync,realpathSync:A_,promises:{lstat:Qs.lstat,readdir:Qs.readdir,readlink:Qs.readlink,realpath:Qs.realpath}},XI=e=>!e||e===go||e===KL?go:{...go,...e,promises:{...go.promises,...e.promises||{}}},$I=/^\\\\\?\\([a-z]:)\\?$/i,c_=e=>e.replace(/\//g,"\\").replace($I,"$1\\"),l_=/[\\\/]/,tt=0,ew=1,tw=2,kt=4,sw=6,rw=8,js=10,iw=12,et=15,lo=~et,Xu=16,CI=32,ho=64,gt=128,La=256,Oa=512,II=ho|gt|Oa,u_=1023,$u=e=>e.isFile()?rw:e.isDirectory()?kt:e.isSymbolicLink()?js:e.isCharacterDevice()?tw:e.isBlockDevice()?sw:e.isSocket()?iw:e.isFIFO()?ew:tt,wI=new Va({max:2**12}),Eo=e=>{let t=wI.get(e);if(t)return t;let s=e.normalize("NFKD");return wI.set(e,s),s},bI=new Va({max:2**12}),_a=e=>{let t=bI.get(e);if(t)return t;let s=Eo(e.toLowerCase());return bI.set(e,s),s},yI=class extends Va{constructor(){super({max:256})}},p_=class extends Va{constructor(e=16*1024){super({maxSize:e,sizeCalculation:t=>t.length+1})}},ow=Symbol("PathScurry setAsCwd"),Se=class{name;root;roots;parent;nocase;isCWD=!1;#e;#t;get dev(){return this.#t}#i;get mode(){return this.#i}#s;get nlink(){return this.#s}#r;get uid(){return this.#r}#A;get gid(){return this.#A}#a;get rdev(){return this.#a}#c;get blksize(){return this.#c}#l;get ino(){return this.#l}#g;get size(){return this.#g}#h;get blocks(){return this.#h}#u;get atimeMs(){return this.#u}#n;get mtimeMs(){return this.#n}#d;get ctimeMs(){return this.#d}#C;get birthtimeMs(){return this.#C}#B;get atime(){return this.#B}#E;get mtime(){return this.#E}#k;get ctime(){return this.#k}#m;get birthtime(){return this.#m}#b;#y;#f;#Q;#I;#x;#o;#U;#F;#v;get parentPath(){return(this.parent||this).fullpath()}get path(){return this.parentPath}constructor(e,t=tt,s,r,i,o,n){this.name=e,this.#b=i?_a(e):Eo(e),this.#o=t&u_,this.nocase=i,this.roots=r,this.root=s||this,this.#U=o,this.#f=n.fullpath,this.#I=n.relative,this.#x=n.relativePosix,this.parent=n.parent,this.parent?this.#e=this.parent.#e:this.#e=XI(n.fs)}depth(){return this.#y!==void 0?this.#y:this.parent?this.#y=this.parent.depth()+1:this.#y=0}childrenCache(){return this.#U}resolve(e){if(!e)return this;let t=this.getRootString(e),s=e.substring(t.length).split(this.splitSep);return t?this.getRoot(t).#S(s):this.#S(s)}#S(e){let t=this;for(let s of e)t=t.child(s);return t}children(){let e=this.#U.get(this);if(e)return e;let t=Object.assign([],{provisional:0});return this.#U.set(this,t),this.#o&=~Xu,t}child(e,t){if(e===""||e===".")return this;if(e==="..")return this.parent||this;let s=this.children(),r=this.nocase?_a(e):Eo(e);for(let a of s)if(a.#b===r)return a;let i=this.parent?this.sep:"",o=this.#f?this.#f+i+e:void 0,n=this.newChild(e,tt,{...t,parent:this,fullpath:o});return this.canReaddir()||(n.#o|=gt),s.push(n),n}relative(){if(this.isCWD)return"";if(this.#I!==void 0)return this.#I;let e=this.name,t=this.parent;if(!t)return this.#I=this.name;let s=t.relative();return s+(!s||!t.parent?"":this.sep)+e}relativePosix(){if(this.sep==="/")return this.relative();if(this.isCWD)return"";if(this.#x!==void 0)return this.#x;let e=this.name,t=this.parent;if(!t)return this.#x=this.fullpathPosix();let s=t.relativePosix();return s+(!s||!t.parent?"":"/")+e}fullpath(){if(this.#f!==void 0)return this.#f;let e=this.name,t=this.parent;if(!t)return this.#f=this.name;let s=t.fullpath()+(t.parent?this.sep:"")+e;return this.#f=s}fullpathPosix(){if(this.#Q!==void 0)return this.#Q;if(this.sep==="/")return this.#Q=this.fullpath();if(!this.parent){let r=this.fullpath().replace(/\\/g,"/");return/^[a-z]:\//i.test(r)?this.#Q=`//?/${r}`:this.#Q=r}let e=this.parent,t=e.fullpathPosix(),s=t+(!t||!e.parent?"":"/")+this.name;return this.#Q=s}isUnknown(){return(this.#o&et)===tt}isType(e){return this[`is${e}`]()}getType(){return this.isUnknown()?"Unknown":this.isDirectory()?"Directory":this.isFile()?"File":this.isSymbolicLink()?"SymbolicLink":this.isFIFO()?"FIFO":this.isCharacterDevice()?"CharacterDevice":this.isBlockDevice()?"BlockDevice":this.isSocket()?"Socket":"Unknown"}isFile(){return(this.#o&et)===rw}isDirectory(){return(this.#o&et)===kt}isCharacterDevice(){return(this.#o&et)===tw}isBlockDevice(){return(this.#o&et)===sw}isFIFO(){return(this.#o&et)===ew}isSocket(){return(this.#o&et)===iw}isSymbolicLink(){return(this.#o&js)===js}lstatCached(){return this.#o&CI?this:void 0}readlinkCached(){return this.#F}realpathCached(){return this.#v}readdirCached(){let e=this.children();return e.slice(0,e.provisional)}canReadlink(){if(this.#F)return!0;if(!this.parent)return!1;let e=this.#o&et;return!(e!==tt&&e!==js||this.#o&La||this.#o>)}calledReaddir(){return!!(this.#o&Xu)}isENOENT(){return!!(this.#o>)}isNamed(e){return this.nocase?this.#b===_a(e):this.#b===Eo(e)}async readlink(){let e=this.#F;if(e)return e;if(this.canReadlink()&&this.parent)try{let t=await this.#e.promises.readlink(this.fullpath()),s=(await this.parent.realpath())?.resolve(t);if(s)return this.#F=s}catch(t){this.#T(t.code);return}}readlinkSync(){let e=this.#F;if(e)return e;if(this.canReadlink()&&this.parent)try{let t=this.#e.readlinkSync(this.fullpath()),s=this.parent.realpathSync()?.resolve(t);if(s)return this.#F=s}catch(t){this.#T(t.code);return}}#L(e){this.#o|=Xu;for(let t=e.provisional;ts(null,e))}readdirCB(e,t=!1){if(!this.canReaddir()){t?e(null,[]):queueMicrotask(()=>e(null,[]));return}let s=this.children();if(this.calledReaddir()){let i=s.slice(0,s.provisional);t?e(null,i):queueMicrotask(()=>e(null,i));return}if(this.#G.push(e),this.#D)return;this.#D=!0;let r=this.fullpath();this.#e.readdir(r,{withFileTypes:!0},(i,o)=>{if(i)this.#_(i.code),s.provisional=0;else{for(let n of o)this.#Y(n,s);this.#L(s)}this.#V(s.slice(0,s.provisional))})}#q;async readdir(){if(!this.canReaddir())return[];let e=this.children();if(this.calledReaddir())return e.slice(0,e.provisional);let t=this.fullpath();if(this.#q)await this.#q;else{let s=()=>{};this.#q=new Promise(r=>s=r);try{for(let r of await this.#e.promises.readdir(t,{withFileTypes:!0}))this.#Y(r,e);this.#L(e)}catch(r){this.#_(r.code),e.provisional=0}this.#q=void 0,s()}return e.slice(0,e.provisional)}readdirSync(){if(!this.canReaddir())return[];let e=this.children();if(this.calledReaddir())return e.slice(0,e.provisional);let t=this.fullpath();try{for(let s of this.#e.readdirSync(t,{withFileTypes:!0}))this.#Y(s,e);this.#L(e)}catch(s){this.#_(s.code),e.provisional=0}return e.slice(0,e.provisional)}canReaddir(){if(this.#o&II)return!1;let e=et&this.#o;return e===tt||e===kt||e===js}shouldWalk(e,t){return(this.#o&kt)===kt&&!(this.#o&II)&&!e.has(this)&&(!t||t(this))}async realpath(){if(this.#v)return this.#v;if(!((Oa|La|gt)&this.#o))try{let e=await this.#e.promises.realpath(this.fullpath());return this.#v=this.resolve(e)}catch{this.#M()}}realpathSync(){if(this.#v)return this.#v;if(!((Oa|La|gt)&this.#o))try{let e=this.#e.realpathSync(this.fullpath());return this.#v=this.resolve(e)}catch{this.#M()}}[ow](e){if(e===this)return;e.isCWD=!1,this.isCWD=!0;let t=new Set([]),s=[],r=this;for(;r&&r.parent;)t.add(r),r.#I=s.join(this.sep),r.#x=s.join("/"),r=r.parent,s.push("..");for(r=e;r&&r.parent&&!t.has(r);)r.#I=void 0,r.#x=void 0,r=r.parent}},nw=class aw extends Se{sep="\\";splitSep=l_;constructor(t,s=tt,r,i,o,n,a){super(t,s,r,i,o,n,a)}newChild(t,s=tt,r={}){return new aw(t,s,this.root,this.roots,this.nocase,this.childrenCache(),r)}getRootString(t){return $r.win32.parse(t).root}getRoot(t){if(t=c_(t.toUpperCase()),t===this.root.name)return this.root;for(let[s,r]of Object.entries(this.roots))if(this.sameRoot(t,s))return this.roots[t]=r;return this.roots[t]=new ip(t,this).root}sameRoot(t,s=this.root.name){return t=t.toUpperCase().replace(/\//g,"\\").replace($I,"$1\\"),t===s}},Aw=class cw extends Se{splitSep="/";sep="/";constructor(t,s=tt,r,i,o,n,a){super(t,s,r,i,o,n,a)}getRootString(t){return t.startsWith("/")?"/":""}getRoot(t){return this.root}newChild(t,s=tt,r={}){return new cw(t,s,this.root,this.roots,this.nocase,this.childrenCache(),r)}},lw=class{root;rootPath;roots;cwd;#e;#t;#i;nocase;#s;constructor(e=process.cwd(),t,s,{nocase:r,childrenCacheSize:i=16*1024,fs:o=go}={}){this.#s=XI(o),(e instanceof URL||e.startsWith("file://"))&&(e=(0,zI.fileURLToPath)(e));let n=t.resolve(e);this.roots=Object.create(null),this.rootPath=this.parseRootPath(n),this.#e=new yI,this.#t=new yI,this.#i=new p_(i);let a=n.substring(this.rootPath.length).split(s);if(a.length===1&&!a[0]&&a.pop(),r===void 0)throw new TypeError("must provide nocase setting to PathScurryBase ctor");this.nocase=r,this.root=this.newRoot(this.#s),this.roots[this.rootPath]=this.root;let A=this.root,c=a.length-1,u=t.sep,l=this.rootPath,p=!1;for(let g of a){let h=c--;A=A.child(g,{relative:new Array(h).fill("..").join(u),relativePosix:new Array(h).fill("..").join("/"),fullpath:l+=(p?"":u)+g}),p=!0}this.cwd=A}depth(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.depth()}childrenCache(){return this.#i}resolve(...e){let t="";for(let i=e.length-1;i>=0;i--){let o=e[i];if(!(!o||o===".")&&(t=t?`${o}/${t}`:o,this.isAbsolute(o)))break}let s=this.#e.get(t);if(s!==void 0)return s;let r=this.cwd.resolve(t).fullpath();return this.#e.set(t,r),r}resolvePosix(...e){let t="";for(let i=e.length-1;i>=0;i--){let o=e[i];if(!(!o||o===".")&&(t=t?`${o}/${t}`:o,this.isAbsolute(o)))break}let s=this.#t.get(t);if(s!==void 0)return s;let r=this.cwd.resolve(t).fullpathPosix();return this.#t.set(t,r),r}relative(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.relative()}relativePosix(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.relativePosix()}basename(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.name}dirname(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),(e.parent||e).fullpath()}async readdir(e=this.cwd,t={withFileTypes:!0}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof Se||(t=e,e=this.cwd);let{withFileTypes:s}=t;if(e.canReaddir()){let r=await e.readdir();return s?r:r.map(i=>i.name)}else return[]}readdirSync(e=this.cwd,t={withFileTypes:!0}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof Se||(t=e,e=this.cwd);let{withFileTypes:s=!0}=t;return e.canReaddir()?s?e.readdirSync():e.readdirSync().map(r=>r.name):[]}async lstat(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.lstat()}lstatSync(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.lstatSync()}async readlink(e=this.cwd,{withFileTypes:t}={withFileTypes:!1}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof Se||(t=e.withFileTypes,e=this.cwd);let s=await e.readlink();return t?s:s?.fullpath()}readlinkSync(e=this.cwd,{withFileTypes:t}={withFileTypes:!1}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof Se||(t=e.withFileTypes,e=this.cwd);let s=e.readlinkSync();return t?s:s?.fullpath()}async realpath(e=this.cwd,{withFileTypes:t}={withFileTypes:!1}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof Se||(t=e.withFileTypes,e=this.cwd);let s=await e.realpath();return t?s:s?.fullpath()}realpathSync(e=this.cwd,{withFileTypes:t}={withFileTypes:!1}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof Se||(t=e.withFileTypes,e=this.cwd);let s=e.realpathSync();return t?s:s?.fullpath()}async walk(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof Se||(t=e,e=this.cwd);let{withFileTypes:s=!0,follow:r=!1,filter:i,walkFilter:o}=t,n=[];(!i||i(e))&&n.push(s?e:e.fullpath());let a=new Set,A=(u,l)=>{a.add(u),u.readdirCB((p,g)=>{if(p)return l(p);let h=g.length;if(!h)return l();let E=()=>{--h===0&&l()};for(let f of g)(!i||i(f))&&n.push(s?f:f.fullpath()),r&&f.isSymbolicLink()?f.realpath().then(d=>d?.isUnknown()?d.lstat():d).then(d=>d?.shouldWalk(a,o)?A(d,E):E()):f.shouldWalk(a,o)?A(f,E):E()},!0)},c=e;return new Promise((u,l)=>{A(c,p=>{if(p)return l(p);u(n)})})}walkSync(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof Se||(t=e,e=this.cwd);let{withFileTypes:s=!0,follow:r=!1,filter:i,walkFilter:o}=t,n=[];(!i||i(e))&&n.push(s?e:e.fullpath());let a=new Set([e]);for(let A of a){let c=A.readdirSync();for(let u of c){(!i||i(u))&&n.push(s?u:u.fullpath());let l=u;if(u.isSymbolicLink()){if(!(r&&(l=u.realpathSync())))continue;l.isUnknown()&&l.lstatSync()}l.shouldWalk(a,o)&&a.add(l)}}return n}[Symbol.asyncIterator](){return this.iterate()}iterate(e=this.cwd,t={}){return typeof e=="string"?e=this.cwd.resolve(e):e instanceof Se||(t=e,e=this.cwd),this.stream(e,t)[Symbol.asyncIterator]()}[Symbol.iterator](){return this.iterateSync()}*iterateSync(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof Se||(t=e,e=this.cwd);let{withFileTypes:s=!0,follow:r=!1,filter:i,walkFilter:o}=t;(!i||i(e))&&(yield s?e:e.fullpath());let n=new Set([e]);for(let a of n){let A=a.readdirSync();for(let c of A){(!i||i(c))&&(yield s?c:c.fullpath());let u=c;if(c.isSymbolicLink()){if(!(r&&(u=c.realpathSync())))continue;u.isUnknown()&&u.lstatSync()}u.shouldWalk(n,o)&&n.add(u)}}}stream(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof Se||(t=e,e=this.cwd);let{withFileTypes:s=!0,follow:r=!1,filter:i,walkFilter:o}=t,n=new Ha({objectMode:!0});(!i||i(e))&&n.write(s?e:e.fullpath());let a=new Set,A=[e],c=0,u=()=>{let l=!1;for(;!l;){let p=A.shift();if(!p){c===0&&n.end();return}c++,a.add(p);let g=(E,f,d=!1)=>{if(E)return n.emit("error",E);if(r&&!d){let m=[];for(let C of f)C.isSymbolicLink()&&m.push(C.realpath().then(B=>B?.isUnknown()?B.lstat():B));if(m.length){Promise.all(m).then(()=>g(null,f,!0));return}}for(let m of f)m&&(!i||i(m))&&(n.write(s?m:m.fullpath())||(l=!0));c--;for(let m of f){let C=m.realpathCached()||m;C.shouldWalk(a,o)&&A.push(C)}l&&!n.flowing?n.once("drain",u):h||u()},h=!0;p.readdirCB(g,!0),h=!1}};return u(),n}streamSync(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof Se||(t=e,e=this.cwd);let{withFileTypes:s=!0,follow:r=!1,filter:i,walkFilter:o}=t,n=new Ha({objectMode:!0}),a=new Set;(!i||i(e))&&n.write(s?e:e.fullpath());let A=[e],c=0,u=()=>{let l=!1;for(;!l;){let p=A.shift();if(!p){c===0&&n.end();return}c++,a.add(p);let g=p.readdirSync();for(let h of g)(!i||i(h))&&(n.write(s?h:h.fullpath())||(l=!0));c--;for(let h of g){let E=h;if(h.isSymbolicLink()){if(!(r&&(E=h.realpathSync())))continue;E.isUnknown()&&E.lstatSync()}E.shouldWalk(a,o)&&A.push(E)}}l&&!n.flowing&&n.once("drain",u)};return u(),n}chdir(e=this.cwd){let t=this.cwd;this.cwd=typeof e=="string"?this.cwd.resolve(e):e,this.cwd[ow](t)}},ip=class extends lw{sep="\\";constructor(e=process.cwd(),t={}){let{nocase:s=!0}=t;super(e,$r.win32,"\\",{...t,nocase:s}),this.nocase=s;for(let r=this.cwd;r;r=r.parent)r.nocase=this.nocase}parseRootPath(e){return $r.win32.parse(e).root.toUpperCase()}newRoot(e){return new nw(this.rootPath,kt,void 0,this.roots,this.nocase,this.childrenCache(),{fs:e})}isAbsolute(e){return e.startsWith("/")||e.startsWith("\\")||/^[a-z]:(\/|\\)/i.test(e)}},op=class extends lw{sep="/";constructor(e=process.cwd(),t={}){let{nocase:s=!1}=t;super(e,$r.posix,"/",{...t,nocase:s}),this.nocase=s}parseRootPath(e){return"/"}newRoot(e){return new Aw(this.rootPath,kt,void 0,this.roots,this.nocase,this.childrenCache(),{fs:e})}isAbsolute(e){return e.startsWith("/")}},uw=class extends op{constructor(e=process.cwd(),t={}){let{nocase:s=!0}=t;super(e,{...t,nocase:s})}},qJ=process.platform==="win32"?nw:Aw,g_=process.platform==="win32"?ip:process.platform==="darwin"?uw:op,h_=e=>e.length>=1,d_=e=>e.length>=1,E_=Symbol.for("nodejs.util.inspect.custom"),pw=class gw{#e;#t;#i;length;#s;#r;#A;#a;#c;#l;#g=!0;constructor(t,s,r,i){if(!h_(t))throw new TypeError("empty pattern list");if(!d_(s))throw new TypeError("empty glob list");if(s.length!==t.length)throw new TypeError("mismatched pattern list and glob list lengths");if(this.length=t.length,r<0||r>=this.length)throw new TypeError("index out of range");if(this.#e=t,this.#t=s,this.#i=r,this.#s=i,this.#i===0){if(this.isUNC()){let[o,n,a,A,...c]=this.#e,[u,l,p,g,...h]=this.#t;c[0]===""&&(c.shift(),h.shift());let E=[o,n,a,A,""].join("/"),f=[u,l,p,g,""].join("/");this.#e=[E,...c],this.#t=[f,...h],this.length=this.#e.length}else if(this.isDrive()||this.isAbsolute()){let[o,...n]=this.#e,[a,...A]=this.#t;n[0]===""&&(n.shift(),A.shift());let c=o+"/",u=a+"/";this.#e=[c,...n],this.#t=[u,...A],this.length=this.#e.length}}}[E_](){return"Pattern <"+this.#t.slice(this.#i).join("/")+">"}pattern(){return this.#e[this.#i]}isString(){return typeof this.#e[this.#i]=="string"}isGlobstar(){return this.#e[this.#i]===be}isRegExp(){return this.#e[this.#i]instanceof RegExp}globString(){return this.#A=this.#A||(this.#i===0?this.isAbsolute()?this.#t[0]+this.#t.slice(1).join("/"):this.#t.join("/"):this.#t.slice(this.#i).join("/"))}hasMore(){return this.length>this.#i+1}rest(){return this.#r!==void 0?this.#r:this.hasMore()?(this.#r=new gw(this.#e,this.#t,this.#i+1,this.#s),this.#r.#l=this.#l,this.#r.#c=this.#c,this.#r.#a=this.#a,this.#r):this.#r=null}isUNC(){let t=this.#e;return this.#c!==void 0?this.#c:this.#c=this.#s==="win32"&&this.#i===0&&t[0]===""&&t[1]===""&&typeof t[2]=="string"&&!!t[2]&&typeof t[3]=="string"&&!!t[3]}isDrive(){let t=this.#e;return this.#a!==void 0?this.#a:this.#a=this.#s==="win32"&&this.#i===0&&this.length>1&&typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0])}isAbsolute(){let t=this.#e;return this.#l!==void 0?this.#l:this.#l=t[0]===""&&t.length>1||this.isDrive()||this.isUNC()}root(){let t=this.#e[0];return typeof t=="string"&&this.isAbsolute()&&this.#i===0?t:""}checkFollowGlobstar(){return!(this.#i===0||!this.isGlobstar()||!this.#g)}markFollowGlobstar(){return this.#i===0||!this.isGlobstar()||!this.#g?!1:(this.#g=!1,!0)}},m_=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",xI=class{relative;relativeChildren;absolute;absoluteChildren;platform;mmopts;constructor(e,{nobrace:t,nocase:s,noext:r,noglobstar:i,platform:o=m_}){this.relative=[],this.absolute=[],this.relativeChildren=[],this.absoluteChildren=[],this.platform=o,this.mmopts={dot:!0,nobrace:t,nocase:s,noext:r,noglobstar:i,optimizationLevel:2,platform:o,nocomment:!0,nonegate:!0};for(let n of e)this.add(n)}add(e){let t=new fs(e,this.mmopts);for(let s=0;s[e,!!(t&2),!!(t&1)])}},B_=class{store=new Map;add(e,t){if(!e.canReaddir())return;let s=this.store.get(e);s?s.find(r=>r.globString()===t.globString())||s.push(t):this.store.set(e,[t])}get(e){let t=this.store.get(e);if(!t)throw new Error("attempting to walk unknown path");return t}entries(){return this.keys().map(e=>[e,this.store.get(e)])}keys(){return[...this.store.keys()].filter(e=>e.canReaddir())}},vI=class dw{hasWalkedCache;matches=new Q_;subwalks=new B_;patterns;follow;dot;opts;constructor(t,s){this.opts=t,this.follow=!!t.follow,this.dot=!!t.dot,this.hasWalkedCache=s?s.copy():new f_}processPatterns(t,s){this.patterns=s;let r=s.map(i=>[t,i]);for(let[i,o]of r){this.hasWalkedCache.storeWalked(i,o);let n=o.root(),a=o.isAbsolute()&&this.opts.absolute!==!1;if(n){i=i.resolve(n==="/"&&this.opts.root!==void 0?this.opts.root:n);let l=o.rest();if(l)o=l;else{this.matches.add(i,!0,!1);continue}}if(i.isENOENT())continue;let A,c,u=!1;for(;typeof(A=o.pattern())=="string"&&(c=o.rest());)i=i.resolve(A),o=c,u=!0;if(A=o.pattern(),c=o.rest(),u){if(this.hasWalkedCache.hasWalked(i,o))continue;this.hasWalkedCache.storeWalked(i,o)}if(typeof A=="string"){let l=A===".."||A===""||A===".";this.matches.add(i.resolve(A),a,l);continue}else if(A===be){(!i.isSymbolicLink()||this.follow||o.checkFollowGlobstar())&&this.subwalks.add(i,o);let l=c?.pattern(),p=c?.rest();if(!c||(l===""||l===".")&&!p)this.matches.add(i,a,l===""||l===".");else if(l===".."){let g=i.parent||i;p?this.hasWalkedCache.hasWalked(g,p)||this.subwalks.add(g,p):this.matches.add(g,a,!0)}}else A instanceof RegExp&&this.subwalks.add(i,o)}return this}subwalkTargets(){return this.subwalks.keys()}child(){return new dw(this.opts,this.hasWalkedCache)}filterEntries(t,s){let r=this.subwalks.get(t),i=this.child();for(let o of s)for(let n of r){let a=n.isAbsolute(),A=n.pattern(),c=n.rest();A===be?i.testGlobstar(o,n,c,a):A instanceof RegExp?i.testRegExp(o,A,c,a):i.testString(o,A,c,a)}return i}testGlobstar(t,s,r,i){if((this.dot||!t.name.startsWith("."))&&(s.hasMore()||this.matches.add(t,i,!1),t.canReaddir()&&(this.follow||!t.isSymbolicLink()?this.subwalks.add(t,s):t.isSymbolicLink()&&(r&&s.checkFollowGlobstar()?this.subwalks.add(t,r):s.markFollowGlobstar()&&this.subwalks.add(t,s)))),r){let o=r.pattern();if(typeof o=="string"&&o!==".."&&o!==""&&o!==".")this.testString(t,o,r.rest(),i);else if(o===".."){let n=t.parent||t;this.subwalks.add(n,r)}else o instanceof RegExp&&this.testRegExp(t,o,r.rest(),i)}}testRegExp(t,s,r,i){s.test(t.name)&&(r?this.subwalks.add(t,r):this.matches.add(t,i,!1))}testString(t,s,r,i){t.isNamed(s)&&(r?this.subwalks.add(t,r):this.matches.add(t,i,!1))}},C_=(e,t)=>typeof e=="string"?new xI([e],t):Array.isArray(e)?new xI(e,t):e,Ew=class{path;patterns;opts;seen=new Set;paused=!1;aborted=!1;#e=[];#t;#i;signal;maxDepth;includeChildMatches;constructor(e,t,s){if(this.patterns=e,this.path=t,this.opts=s,this.#i=!s.posix&&s.platform==="win32"?"\\":"/",this.includeChildMatches=s.includeChildMatches!==!1,(s.ignore||!this.includeChildMatches)&&(this.#t=C_(s.ignore??[],s),!this.includeChildMatches&&typeof this.#t.add!="function")){let r="cannot ignore child matches, ignore lacks add() method.";throw new Error(r)}this.maxDepth=s.maxDepth||1/0,s.signal&&(this.signal=s.signal,this.signal.addEventListener("abort",()=>{this.#e.length=0}))}#s(e){return this.seen.has(e)||!!this.#t?.ignored?.(e)}#r(e){return!!this.#t?.childrenIgnored?.(e)}pause(){this.paused=!0}resume(){if(this.signal?.aborted)return;this.paused=!1;let e;for(;!this.paused&&(e=this.#e.shift());)e()}onResume(e){this.signal?.aborted||(this.paused?this.#e.push(e):e())}async matchCheck(e,t){if(t&&this.opts.nodir)return;let s;if(this.opts.realpath){if(s=e.realpathCached()||await e.realpath(),!s)return;e=s}let r=e.isUnknown()||this.opts.stat?await e.lstat():e;if(this.opts.follow&&this.opts.nodir&&r?.isSymbolicLink()){let i=await r.realpath();i&&(i.isUnknown()||this.opts.stat)&&await i.lstat()}return this.matchCheckTest(r,t)}matchCheckTest(e,t){return e&&(this.maxDepth===1/0||e.depth()<=this.maxDepth)&&(!t||e.canReaddir())&&(!this.opts.nodir||!e.isDirectory())&&(!this.opts.nodir||!this.opts.follow||!e.isSymbolicLink()||!e.realpathCached()?.isDirectory())&&!this.#s(e)?e:void 0}matchCheckSync(e,t){if(t&&this.opts.nodir)return;let s;if(this.opts.realpath){if(s=e.realpathCached()||e.realpathSync(),!s)return;e=s}let r=e.isUnknown()||this.opts.stat?e.lstatSync():e;if(this.opts.follow&&this.opts.nodir&&r?.isSymbolicLink()){let i=r.realpathSync();i&&(i?.isUnknown()||this.opts.stat)&&i.lstatSync()}return this.matchCheckTest(r,t)}matchFinish(e,t){if(this.#s(e))return;if(!this.includeChildMatches&&this.#t?.add){let i=`${e.relativePosix()}/**`;this.#t.add(i)}let s=this.opts.absolute===void 0?t:this.opts.absolute;this.seen.add(e);let r=this.opts.mark&&e.isDirectory()?this.#i:"";if(this.opts.withFileTypes)this.matchEmit(e);else if(s){let i=this.opts.posix?e.fullpathPosix():e.fullpath();this.matchEmit(i+r)}else{let i=this.opts.posix?e.relativePosix():e.relative(),o=this.opts.dotRelative&&!i.startsWith(".."+this.#i)?"."+this.#i:"";this.matchEmit(i?o+i+r:"."+r)}}async match(e,t,s){let r=await this.matchCheck(e,s);r&&this.matchFinish(r,t)}matchSync(e,t,s){let r=this.matchCheckSync(e,s);r&&this.matchFinish(r,t)}walkCB(e,t,s){this.signal?.aborted&&s(),this.walkCB2(e,t,new vI(this.opts),s)}walkCB2(e,t,s,r){if(this.#r(e))return r();if(this.signal?.aborted&&r(),this.paused){this.onResume(()=>this.walkCB2(e,t,s,r));return}s.processPatterns(e,t);let i=1,o=()=>{--i===0&&r()};for(let[n,a,A]of s.matches.entries())this.#s(n)||(i++,this.match(n,a,A).then(()=>o()));for(let n of s.subwalkTargets()){if(this.maxDepth!==1/0&&n.depth()>=this.maxDepth)continue;i++;let a=n.readdirCached();n.calledReaddir()?this.walkCB3(n,a,s,o):n.readdirCB((A,c)=>this.walkCB3(n,c,s,o),!0)}o()}walkCB3(e,t,s,r){s=s.filterEntries(e,t);let i=1,o=()=>{--i===0&&r()};for(let[n,a,A]of s.matches.entries())this.#s(n)||(i++,this.match(n,a,A).then(()=>o()));for(let[n,a]of s.subwalks.entries())i++,this.walkCB2(n,a,s.child(),o);o()}walkCBSync(e,t,s){this.signal?.aborted&&s(),this.walkCB2Sync(e,t,new vI(this.opts),s)}walkCB2Sync(e,t,s,r){if(this.#r(e))return r();if(this.signal?.aborted&&r(),this.paused){this.onResume(()=>this.walkCB2Sync(e,t,s,r));return}s.processPatterns(e,t);let i=1,o=()=>{--i===0&&r()};for(let[n,a,A]of s.matches.entries())this.#s(n)||this.matchSync(n,a,A);for(let n of s.subwalkTargets()){if(this.maxDepth!==1/0&&n.depth()>=this.maxDepth)continue;i++;let a=n.readdirSync();this.walkCB3Sync(n,a,s,o)}o()}walkCB3Sync(e,t,s,r){s=s.filterEntries(e,t);let i=1,o=()=>{--i===0&&r()};for(let[n,a,A]of s.matches.entries())this.#s(n)||this.matchSync(n,a,A);for(let[n,a]of s.subwalks.entries())i++,this.walkCB2Sync(n,a,s.child(),o);o()}},kI=class extends Ew{matches=new Set;constructor(e,t,s){super(e,t,s)}matchEmit(e){this.matches.add(e)}async walk(){if(this.signal?.aborted)throw this.signal.reason;return this.path.isUnknown()&&await this.path.lstat(),await new Promise((e,t)=>{this.walkCB(this.path,this.patterns,()=>{this.signal?.aborted?t(this.signal.reason):e(this.matches)})}),this.matches}walkSync(){if(this.signal?.aborted)throw this.signal.reason;return this.path.isUnknown()&&this.path.lstatSync(),this.walkCBSync(this.path,this.patterns,()=>{if(this.signal?.aborted)throw this.signal.reason}),this.matches}},DI=class extends Ew{results;constructor(e,t,s){super(e,t,s),this.results=new Ha({signal:this.signal,objectMode:!0}),this.results.on("drain",()=>this.resume()),this.results.on("resume",()=>this.resume())}matchEmit(e){this.results.write(e),this.results.flowing||this.pause()}stream(){let e=this.path;return e.isUnknown()?e.lstat().then(()=>{this.walkCB(e,this.patterns,()=>this.results.end())}):this.walkCB(e,this.patterns,()=>this.results.end()),this.results}streamSync(){return this.path.isUnknown()&&this.path.lstatSync(),this.walkCBSync(this.path,this.patterns,()=>this.results.end()),this.results}},I_=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",zs=class{absolute;cwd;root;dot;dotRelative;follow;ignore;magicalBraces;mark;matchBase;maxDepth;nobrace;nocase;nodir;noext;noglobstar;pattern;platform;realpath;scurry;stat;signal;windowsPathsNoEscape;withFileTypes;includeChildMatches;opts;patterns;constructor(e,t){if(!t)throw new TypeError("glob options required");if(this.withFileTypes=!!t.withFileTypes,this.signal=t.signal,this.follow=!!t.follow,this.dot=!!t.dot,this.dotRelative=!!t.dotRelative,this.nodir=!!t.nodir,this.mark=!!t.mark,t.cwd?(t.cwd instanceof URL||t.cwd.startsWith("file://"))&&(t.cwd=(0,HI.fileURLToPath)(t.cwd)):this.cwd="",this.cwd=t.cwd||"",this.root=t.root,this.magicalBraces=!!t.magicalBraces,this.nobrace=!!t.nobrace,this.noext=!!t.noext,this.realpath=!!t.realpath,this.absolute=t.absolute,this.includeChildMatches=t.includeChildMatches!==!1,this.noglobstar=!!t.noglobstar,this.matchBase=!!t.matchBase,this.maxDepth=typeof t.maxDepth=="number"?t.maxDepth:1/0,this.stat=!!t.stat,this.ignore=t.ignore,this.withFileTypes&&this.absolute!==void 0)throw new Error("cannot set absolute and withFileTypes:true");if(typeof e=="string"&&(e=[e]),this.windowsPathsNoEscape=!!t.windowsPathsNoEscape||t.allowWindowsEscape===!1,this.windowsPathsNoEscape&&(e=e.map(a=>a.replace(/\\/g,"/"))),this.matchBase){if(t.noglobstar)throw new TypeError("base matching requires globstar");e=e.map(a=>a.includes("/")?a:`./**/${a}`)}if(this.pattern=e,this.platform=t.platform||I_,this.opts={...t,platform:this.platform},t.scurry){if(this.scurry=t.scurry,t.nocase!==void 0&&t.nocase!==t.scurry.nocase)throw new Error("nocase option contradicts provided scurry option")}else{let a=t.platform==="win32"?ip:t.platform==="darwin"?uw:t.platform?op:g_;this.scurry=new a(this.cwd,{nocase:t.nocase,fs:t.fs})}this.nocase=this.scurry.nocase;let s=this.platform==="darwin"||this.platform==="win32",r={braceExpandMax:1e4,...t,dot:this.dot,matchBase:this.matchBase,nobrace:this.nobrace,nocase:this.nocase,nocaseMagicOnly:s,nocomment:!0,noext:this.noext,nonegate:!0,optimizationLevel:2,platform:this.platform,windowsPathsNoEscape:this.windowsPathsNoEscape,debug:!!this.opts.debug},i=this.pattern.map(a=>new fs(a,r)),[o,n]=i.reduce((a,A)=>(a[0].push(...A.set),a[1].push(...A.globParts),a),[[],[]]);this.patterns=o.map((a,A)=>{let c=n[A];if(!c)throw new Error("invalid pattern object");return new pw(a,c,0,this.platform)})}async walk(){return[...await new kI(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walk()]}walkSync(){return[...new kI(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walkSync()]}stream(){return new DI(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).stream()}streamSync(){return new DI(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).streamSync()}iterateSync(){return this.streamSync()[Symbol.iterator]()}[Symbol.iterator](){return this.iterateSync()}iterate(){return this.stream()[Symbol.asyncIterator]()}[Symbol.asyncIterator](){return this.iterate()}},w_=(e,t={})=>{Array.isArray(e)||(e=[e]);for(let s of e)if(new fs(s,t).hasMagic())return!0;return!1};function Wa(e,t={}){return new zs(e,t).streamSync()}function mw(e,t={}){return new zs(e,t).stream()}function fw(e,t={}){return new zs(e,t).walkSync()}async function RI(e,t={}){return new zs(e,t).walk()}function ja(e,t={}){return new zs(e,t).iterateSync()}function Qw(e,t={}){return new zs(e,t).iterate()}var b_=Wa,y_=Object.assign(mw,{sync:Wa}),x_=ja,v_=Object.assign(Qw,{sync:ja}),za=Object.assign(fw,{stream:Wa,iterate:ja}),TI=Object.assign(RI,{glob:RI,globSync:fw,sync:za,globStream:mw,stream:y_,globStreamSync:Wa,streamSync:b_,globIterate:Qw,iterate:v_,globIterateSync:ja,iterateSync:x_,Glob:zs,hasMagic:w_,escape:_I,unescape:Xr});TI.glob=TI;var mo=require("fs"),np=require("os"),Zs=de(require("path")),Bw=e=>{let t=e.indexOf("{");return t>-1?e.substring(0,t):e},ap=e=>{if(e.input_body_path)try{return(0,mo.readFileSync)(e.input_body_path,"utf8")}catch(t){console.warn(`\u26A0\uFE0F Failed to read body_path "${e.input_body_path}" (${t?.code??"ERR"}). Falling back to 'body' input.`)}return e.input_body},D_=e=>{let t=[],s="",r=0;for(let i of e)i==="{"&&r++,i==="}"&&r--,i===","&&r===0?(s.trim()&&t.push(s.trim()),s=""):s+=i;return s.trim()&&t.push(s.trim()),t},R_=e=>e.split(/\r?\n/).flatMap(t=>D_(t)).filter(t=>t.trim()!==""),T_=e=>{let t=e.INPUT_TOKEN?.trim();return t||e.GITHUB_TOKEN?.trim()||""},Cw=e=>({github_token:T_(e),github_ref:e.GITHUB_REF||"",github_repository:e.INPUT_REPOSITORY||e.GITHUB_REPOSITORY||"",input_name:e.INPUT_NAME,input_tag_name:Ap(e.INPUT_TAG_NAME?.trim()),input_body:e.INPUT_BODY,input_body_path:e.INPUT_BODY_PATH,input_files:R_(e.INPUT_FILES||""),input_working_directory:e.INPUT_WORKING_DIRECTORY||void 0,input_overwrite_files:e.INPUT_OVERWRITE_FILES?e.INPUT_OVERWRITE_FILES=="true":void 0,input_draft:e.INPUT_DRAFT?e.INPUT_DRAFT==="true":void 0,input_preserve_order:e.INPUT_PRESERVE_ORDER?e.INPUT_PRESERVE_ORDER=="true":void 0,input_prerelease:e.INPUT_PRERELEASE?e.INPUT_PRERELEASE=="true":void 0,input_fail_on_unmatched_files:e.INPUT_FAIL_ON_UNMATCHED_FILES=="true",input_target_commitish:e.INPUT_TARGET_COMMITISH||void 0,input_discussion_category_name:e.INPUT_DISCUSSION_CATEGORY_NAME||void 0,input_generate_release_notes:e.INPUT_GENERATE_RELEASE_NOTES=="true",input_previous_tag:e.INPUT_PREVIOUS_TAG?.trim()||void 0,input_append_body:e.INPUT_APPEND_BODY=="true",input_make_latest:F_(e.INPUT_MAKE_LATEST)}),F_=e=>{if(e==="true"||e==="false"||e==="legacy")return e},S_=(e,t=process.platform)=>t==="win32"?e.replace(/\\/g,"/"):e,U_=(e,t=(0,np.homedir)())=>e==="~"?t:e.startsWith("~/")||e.startsWith("~\\")?Zs.join(t,e.slice(2)):e,Iw=(e,t=process.platform,s=(0,np.homedir)())=>S_(U_(e,s),t),ww=(e,t)=>e.reduce((s,r)=>{let o=za(Iw(r),{cwd:t,dot:!0,absolute:!1}).map(n=>t&&!Zs.isAbsolute(n)?Zs.join(t,n):n).filter(n=>{try{return(0,mo.statSync)(n).isFile()}catch{return!1}});return s.concat(o)},[]),bw=(e,t)=>e.reduce((s,r)=>{let o=za(Iw(r),{cwd:t,dot:!0,absolute:!1}).filter(n=>{try{let a=t&&!Zs.isAbsolute(n)?Zs.join(t,n):n;return(0,mo.statSync)(a).isFile()}catch{return!1}});return s.concat(o.length==0?[r]:[])},[]),fo=e=>e.startsWith("refs/tags/"),Ap=e=>e&&(fo(e)?e.replace("refs/tags/",""):e),yw=e=>e.replace(/ /g,".");var Za=class{github;constructor(t){this.github=t}getReleaseByTag(t){return this.github.rest.repos.getReleaseByTag(t)}async getReleaseNotes(t){return await this.github.rest.repos.generateReleaseNotes(t)}async prepareReleaseMutation(t){let{previous_tag_name:s,...r}=t;if(typeof r.make_latest=="string"&&!["true","false","legacy"].includes(r.make_latest)&&(r.make_latest=void 0),r.generate_release_notes){let i=await this.getReleaseNotes({owner:r.owner,repo:r.repo,tag_name:r.tag_name,target_commitish:r.target_commitish,previous_tag_name:s});r.generate_release_notes=!1,r.body?r.body=`${r.body} -${i.data.body}`:r.body=i.data.body}return r.body=r.body?this.truncateReleaseNotes(r.body):void 0,r}truncateReleaseNotes(t){return t.substring(0,124999)}async createRelease(t){return this.github.rest.repos.createRelease(await this.prepareReleaseMutation(t))}async updateRelease(t){return this.github.rest.repos.updateRelease(await this.prepareReleaseMutation(t))}async finalizeRelease(t){return await this.github.rest.repos.updateRelease({owner:t.owner,repo:t.repo,release_id:t.release_id,draft:!1,make_latest:t.make_latest})}allReleases(t){let s={per_page:100,...t};return this.github.paginate.iterator(this.github.rest.repos.listReleases.endpoint.merge(s))}async listReleaseAssets(t){return this.github.paginate(this.github.rest.repos.listReleaseAssets,{...t,per_page:100})}async deleteReleaseAsset(t){await this.github.rest.repos.deleteReleaseAsset(t)}async deleteRelease(t){await this.github.rest.repos.deleteRelease(t)}async updateReleaseAsset(t){return await this.github.rest.repos.updateReleaseAsset(t)}async uploadReleaseAsset(t){return this.github.request({method:"POST",url:t.url,headers:{"content-length":`${t.size}`,"content-type":t.mime,authorization:`token ${t.token}`},data:t.data})}},N_=e=>({name:(0,Rw.basename)(e),mime:G_(e),size:(0,vw.statSync)(e).size}),G_=e=>(0,Dw.lookup)(e)||"application/octet-stream",cp=(e,t)=>t.name===e||t.name===yw(e)||t.label===e,M_=e=>{let t=e?.status??e?.response?.status,s=e?.request?.url,r=e?.message,i=typeof s=="string"&&(/\/releases\/assets\//.test(s)||/\/releases\/\d+\/assets(?:\?|$)/.test(s));return t===404&&(i||typeof r=="string"&&r.includes("update-a-release-asset"))},L_=e=>{let t=e?.status??e?.response?.status,s=e?.response?.data?.message??e?.message;return t===422&&/immutable release/i.test(String(s))},__=(e,t)=>t?`Cannot upload asset ${e} to an immutable release. GitHub only allows asset uploads before a release is published, but draft prereleases publish with the release.published event instead of release.prereleased. If you need prereleases with assets on an immutable-release repository, keep the release as a draft with draft: true, then publish it later from that draft and subscribe downstream workflows to release.published.`:`Cannot upload asset ${e} to an immutable release. GitHub only allows asset uploads before a release is published, so upload assets to a draft release before you publish it.`,Tw=async(e,t,s,r,i)=>{let[o,n]=e.github_repository.split("/"),{name:a,mime:A,size:c}=N_(r),u=s.match(/\/releases\/(\d+)\/assets/),l=u?Number(u[1]):void 0,p=i.find(m=>cp(a,m));if(p){if(e.input_overwrite_files===!1)return console.log(`Asset ${a} already exists and overwrite_files is false...`),null;console.log(`\u267B\uFE0F Deleting previously uploaded asset ${a}...`),await t.deleteReleaseAsset({asset_id:p.id||1,owner:o,repo:n})}console.log(`\u2B06\uFE0F Uploading ${a}...`);let g=new URL(s);g.searchParams.append("name",a);let h=async(m,C=3)=>{if(l!==void 0)for(let B=1;B<=C;B++){let S=(await t.listReleaseAssets({owner:o,repo:n,release_id:l})).find(m);if(S)return S;BsetTimeout(G,1e3))}},E=async()=>{let m=await(0,kw.open)(r);try{return await t.uploadReleaseAsset({url:g.toString(),size:c,mime:A,token:e.github_token,data:m.readableWebStream({type:"bytes"})})}finally{await m.close()}},f=async m=>{if(!m.name||m.name===a||!m.id)return m;console.log(`\u270F\uFE0F Restoring asset label to ${a}...`);let C=async B=>{let{data:b}=await t.updateReleaseAsset({owner:o,repo:n,asset_id:B,name:m.name,label:a});return b};try{return await C(m.id)}catch(B){if((B?.status??B?.response?.status)===404&&l!==void 0)try{let S=await h(G=>G.id===m.id||G.name===m.name);if(S)return await C(S.id)}catch(S){console.warn(`error refreshing release assets for ${a}: ${S}`)}return console.warn(`error updating release asset label for ${a}: ${B}`),m}},d=async m=>{let C=m.data;if(m.status!==201)throw new Error(`Failed to upload release asset ${a}. received status code ${m.status} +${i.data.body}`:r.body=i.data.body}return r.body=r.body?this.truncateReleaseNotes(r.body):void 0,r}truncateReleaseNotes(t){return t.substring(0,124999)}async createRelease(t){return this.github.rest.repos.createRelease(await this.prepareReleaseMutation(t))}async updateRelease(t){return this.github.rest.repos.updateRelease(await this.prepareReleaseMutation(t))}async finalizeRelease(t){return await this.github.rest.repos.updateRelease({owner:t.owner,repo:t.repo,release_id:t.release_id,draft:!1,make_latest:t.make_latest,discussion_category_name:t.discussion_category_name})}allReleases(t){let s={per_page:100,...t};return this.github.paginate.iterator(this.github.rest.repos.listReleases.endpoint.merge(s))}async listReleaseAssets(t){return this.github.paginate(this.github.rest.repos.listReleaseAssets,{...t,per_page:100})}async deleteReleaseAsset(t){await this.github.rest.repos.deleteReleaseAsset(t)}async deleteRelease(t){await this.github.rest.repos.deleteRelease(t)}async updateReleaseAsset(t){return await this.github.rest.repos.updateReleaseAsset(t)}async uploadReleaseAsset(t){return this.github.request({method:"POST",url:t.url,headers:{"content-length":`${t.size}`,"content-type":t.mime,authorization:`token ${t.token}`},data:t.data})}},N_=e=>({name:(0,Rw.basename)(e),mime:G_(e),size:(0,vw.statSync)(e).size}),G_=e=>(0,Dw.lookup)(e)||"application/octet-stream",cp=(e,t)=>t.name===e||t.name===yw(e)||t.label===e,M_=e=>{let t=e?.status??e?.response?.status,s=e?.request?.url,r=e?.message,i=typeof s=="string"&&(/\/releases\/assets\//.test(s)||/\/releases\/\d+\/assets(?:\?|$)/.test(s));return t===404&&(i||typeof r=="string"&&r.includes("update-a-release-asset"))},L_=e=>{let t=e?.status??e?.response?.status,s=e?.response?.data?.message??e?.message;return t===422&&/immutable release/i.test(String(s))},__=(e,t)=>t?`Cannot upload asset ${e} to an immutable release. GitHub only allows asset uploads before a release is published, but draft prereleases publish with the release.published event instead of release.prereleased. If you need prereleases with assets on an immutable-release repository, keep the release as a draft with draft: true, then publish it later from that draft and subscribe downstream workflows to release.published.`:`Cannot upload asset ${e} to an immutable release. GitHub only allows asset uploads before a release is published, so upload assets to a draft release before you publish it.`,Tw=async(e,t,s,r,i)=>{let[o,n]=e.github_repository.split("/"),{name:a,mime:A,size:c}=N_(r),u=s.match(/\/releases\/(\d+)\/assets/),l=u?Number(u[1]):void 0,p=i.find(m=>cp(a,m));if(p){if(e.input_overwrite_files===!1)return console.log(`Asset ${a} already exists and overwrite_files is false...`),null;console.log(`\u267B\uFE0F Deleting previously uploaded asset ${a}...`),await t.deleteReleaseAsset({asset_id:p.id||1,owner:o,repo:n})}console.log(`\u2B06\uFE0F Uploading ${a}...`);let g=new URL(s);g.searchParams.append("name",a);let h=async(m,C=3)=>{if(l!==void 0)for(let B=1;B<=C;B++){let S=(await t.listReleaseAssets({owner:o,repo:n,release_id:l})).find(m);if(S)return S;BsetTimeout(G,1e3))}},E=async()=>{let m=await(0,kw.open)(r);try{return await t.uploadReleaseAsset({url:g.toString(),size:c,mime:A,token:e.github_token,data:m.readableWebStream({type:"bytes"})})}finally{await m.close()}},f=async m=>{if(!m.name||m.name===a||!m.id)return m;console.log(`\u270F\uFE0F Restoring asset label to ${a}...`);let C=async B=>{let{data:b}=await t.updateReleaseAsset({owner:o,repo:n,asset_id:B,name:m.name,label:a});return b};try{return await C(m.id)}catch(B){if((B?.status??B?.response?.status)===404&&l!==void 0)try{let S=await h(G=>G.id===m.id||G.name===m.name);if(S)return await C(S.id)}catch(S){console.warn(`error refreshing release assets for ${a}: ${S}`)}return console.warn(`error updating release asset label for ${a}: ${B}`),m}},d=async m=>{let C=m.data;if(m.status!==201)throw new Error(`Failed to upload release asset ${a}. received status code ${m.status} ${C.message} ${JSON.stringify(C.errors)}`);let B=await f(C);return console.log(`\u2705 Uploaded ${a}`),B};try{return await d(await E())}catch(m){let C=m?.status??m?.response?.status,B=m?.response?.data;if(L_(m))throw new Error(__(a,e.input_prerelease));if(l!==void 0&&M_(m))try{let b=await h(S=>cp(a,S));if(b)return console.warn(`error updating release asset metadata for ${a}: ${m}. Matching asset is present after refresh; continuing...`),b}catch(b){console.warn(`error refreshing release assets after metadata update failure: ${b}`)}if(e.input_overwrite_files!==!1&&C===422&&B?.errors?.[0]?.code==="already_exists"&&l!==void 0){console.log(`\u26A0\uFE0F Asset ${a} already exists (race condition), refreshing assets and retrying once...`);let S=(await t.listReleaseAssets({owner:o,repo:n,release_id:l})).find(G=>cp(a,G));if(S)return await t.deleteReleaseAsset({owner:o,repo:n,asset_id:S.id}),await d(await E())}throw m}},lp=async(e,t,s=3)=>{if(s<=0)throw console.log("\u274C Too many retries. Aborting..."),new Error("Too many retries.");let[r,i]=e.github_repository.split("/"),o=Ap(e.input_tag_name)||(fo(e.github_ref)?e.github_ref.replace("refs/tags/",""):""),n=e.input_discussion_category_name,a=e.input_generate_release_notes,A=e.input_previous_tag;a&&A&&console.log(`\u{1F4DD} Generating release notes using previous tag ${A}`);try{let c=await Fw(t,r,i,o);if(c===void 0)return await xw(o,e,t,r,i,n,a,s,A);let u=c;console.log(`Found release ${u.name} (with id=${u.id})`);let l=u.id,p;e.input_target_commitish&&e.input_target_commitish!==u.target_commitish?(console.log(`Updating commit from "${u.target_commitish}" to "${e.input_target_commitish}"`),p=e.input_target_commitish):p=u.target_commitish;let g=o,h=e.input_name||u.name||o,E=ap(e)||"",f=u.body||"",d;e.input_append_body&&E&&f?d=f+` -`+E:d=E||f;let m=e.input_prerelease!==void 0?e.input_prerelease:u.prerelease,C=e.input_make_latest;return{release:(await t.updateRelease({owner:r,repo:i,release_id:l,tag_name:g,target_commitish:p,name:h,body:d,draft:u.draft,prerelease:m,discussion_category_name:n,generate_release_notes:a,make_latest:C,previous_tag_name:A})).data,created:!1}}catch(c){if(c.status!==404)throw console.log(`\u26A0\uFE0F Unexpected error fetching GitHub release for tag ${e.github_ref}: ${c}`),c;return await xw(o,e,t,r,i,n,a,s,A)}},up=async(e,t,s,r=!1,i=3)=>{if(e.input_draft===!0||s.draft===!1)return s;if(i<=0)throw console.log("\u274C Too many retries. Aborting..."),new Error("Too many retries.");let[o,n]=e.github_repository.split("/");try{let{data:a}=await t.finalizeRelease({owner:o,repo:n,release_id:s.id,make_latest:e.input_make_latest});return a}catch(a){if(console.warn(`error finalizing release: ${a}`),r&&s.draft&&W_(a)){let A=!1;try{console.log(`\u{1F9F9} Deleting draft release ${s.id} for tag ${s.tag_name} because tag creation is blocked by repository rules...`),await t.deleteRelease({owner:o,repo:n,release_id:s.id}),A=!0}catch(u){console.warn(`error deleting orphan draft release ${s.id}: ${u}`)}let c=A?`Deleted draft release ${s.id} to avoid leaving an orphaned draft release.`:`Failed to delete draft release ${s.id}; manual cleanup may still be required.`;throw new Error(`Tag creation for ${s.tag_name} is blocked by repository rules. ${c}`)}return console.log(`retrying... (${i-1} retries remaining)`),up(e,t,s,r,i-1)}},pp=async(e,t,s,r=3)=>{if(r<=0)throw console.log("\u274C Too many retries. Aborting..."),new Error("Too many retries.");let[i,o]=e.github_repository.split("/");try{return await t.listReleaseAssets({owner:i,repo:o,release_id:s.id})}catch(n){return console.warn(`error listing assets of release: ${n}`),console.log(`retrying... (${r-1} retries remaining)`),pp(e,t,s,r-1)}};async function Fw(e,t,s,r){try{let{data:i}=await e.getReleaseByTag({owner:t,repo:s,tag:r});return i}catch(i){if(i.status===404)return;throw i}}var Y_=1e3,O_=2;async function J_(e){await new Promise(t=>setTimeout(t,e))}async function P_(e,t,s,r){let i=[],o=0;for await(let n of e.allReleases({owner:t,repo:s}))if(i.push(...n.data.filter(a=>a.tag_name===r)),o+=1,o>=O_)break;return i}function H_(e,t){return t&&e.some(s=>s.id===t.id)||e.length===0?t:[...e].sort((s,r)=>s.draft!==r.draft?Number(s.draft)-Number(r.draft):s.id-r.id)[0]}async function V_(e,t,s,r,i,o){let n=Array.from(new Map(o.map(a=>[a.id,a])).values());for(let a of n)if(!(a.id===i||!a.draft||a.assets.length>0))try{console.log(`\u{1F9F9} Removing duplicate draft release ${a.id} for tag ${r}...`),await e.deleteRelease({owner:t,repo:s,release_id:a.id})}catch(A){console.warn(`error deleting duplicate release ${a.id}: ${A}`)}}async function q_(e,t,s,r,i,o){let n=Math.max(o,1);for(let a=1;a<=n;a+=1){let A;try{A=await Fw(e,t,s,r)}catch(l){console.warn(`error reloading release for tag ${r}: ${l}`)}let c=[];try{c=await P_(e,t,s,r)}catch(l){console.warn(`error listing recent releases for tag ${r}: ${l}`)}let u=H_(c,A);if(u)return u.id!==i.id&&console.log(`\u21AA\uFE0F Using release ${u.id} for tag ${r} instead of duplicate draft ${i.id}`),await V_(e,t,s,r,u.id,[i,...c]),u;as==="pre_receive"&&typeof r=="string"&&r.includes("creations being restricted"))}var Sw=require("process");async function j_(){try{let e=Cw(Sw.env);if(!e.input_tag_name&&!fo(e.github_ref)&&!e.input_draft)throw new Error("\u26A0\uFE0F GitHub Releases requires a tag");if(e.input_files){let a=bw(e.input_files,e.input_working_directory);if(a.forEach(A=>{if(e.input_fail_on_unmatched_files)throw new Error(`\u26A0\uFE0F Pattern '${A}' does not match any files.`);console.warn(`\u{1F914} Pattern '${A}' does not match any files.`)}),a.length>0&&e.input_fail_on_unmatched_files)throw new Error("\u26A0\uFE0F There were unmatched files")}let t=ZC(e.github_token,{throttle:{onRateLimit:(a,A)=>{if(console.warn(`Request quota exhausted for request ${A.method} ${A.url}`),A.request.retryCount===0)return console.log(`Retrying after ${a} seconds!`),!0},onAbuseLimit:(a,A)=>{console.warn(`Abuse detected for request ${A.method} ${A.url}`)}}}),s=new Za(t),r=await lp(e,s),i=r.release,o=r.created,n=new Set;if(e.input_files&&e.input_files.length>0){let a=ww(e.input_files,e.input_working_directory);if(a.length==0){if(e.input_fail_on_unmatched_files)throw new Error(`\u26A0\uFE0F ${e.input_files} does not include a valid file.`);console.warn(`\u{1F914} ${e.input_files} does not include a valid file.`)}let A=i.assets,c=async l=>{let p=await Tw(e,s,Bw(i.upload_url),l,A);return p?p.id:void 0},u;if(!e.input_preserve_order)u=await Promise.all(a.map(c));else{u=[];for(let l of a)u.push(await c(l))}n=new Set(u.filter(l=>l!==void 0))}console.log("Finalizing release..."),i=await up(e,s,i,o),console.log("Getting assets list...");{let a=[];n.size>0&&(a=(await pp(e,s,i)).filter(c=>n.has(c.id)).map(c=>{let{uploader:u,...l}=c;return l})),eo("assets",a)}console.log(`\u{1F389} Release ready at ${i.html_url}`),eo("url",i.html_url),eo("id",i.id.toString()),eo("upload_url",i.upload_url)}catch(e){eC(e.message)}}j_(); +`+E:d=E||f;let m=e.input_prerelease!==void 0?e.input_prerelease:u.prerelease,C=e.input_make_latest;return{release:(await t.updateRelease({owner:r,repo:i,release_id:l,tag_name:g,target_commitish:p,name:h,body:d,draft:u.draft,prerelease:m,discussion_category_name:n,generate_release_notes:a,make_latest:C,previous_tag_name:A})).data,created:!1}}catch(c){if(c.status!==404)throw console.log(`\u26A0\uFE0F Unexpected error fetching GitHub release for tag ${e.github_ref}: ${c}`),c;return await xw(o,e,t,r,i,n,a,s,A)}},up=async(e,t,s,r=!1,i=3)=>{if(e.input_draft===!0||s.draft===!1)return s;if(i<=0)throw console.log("\u274C Too many retries. Aborting..."),new Error("Too many retries.");let[o,n]=e.github_repository.split("/");try{let{data:a}=await t.finalizeRelease({owner:o,repo:n,release_id:s.id,make_latest:e.input_make_latest,discussion_category_name:e.input_discussion_category_name});return a}catch(a){if(console.warn(`error finalizing release: ${a}`),r&&s.draft&&W_(a)){let A=!1;try{console.log(`\u{1F9F9} Deleting draft release ${s.id} for tag ${s.tag_name} because tag creation is blocked by repository rules...`),await t.deleteRelease({owner:o,repo:n,release_id:s.id}),A=!0}catch(u){console.warn(`error deleting orphan draft release ${s.id}: ${u}`)}let c=A?`Deleted draft release ${s.id} to avoid leaving an orphaned draft release.`:`Failed to delete draft release ${s.id}; manual cleanup may still be required.`;throw new Error(`Tag creation for ${s.tag_name} is blocked by repository rules. ${c}`)}return console.log(`retrying... (${i-1} retries remaining)`),up(e,t,s,r,i-1)}},pp=async(e,t,s,r=3)=>{if(r<=0)throw console.log("\u274C Too many retries. Aborting..."),new Error("Too many retries.");let[i,o]=e.github_repository.split("/");try{return await t.listReleaseAssets({owner:i,repo:o,release_id:s.id})}catch(n){return console.warn(`error listing assets of release: ${n}`),console.log(`retrying... (${r-1} retries remaining)`),pp(e,t,s,r-1)}};async function Fw(e,t,s,r){try{let{data:i}=await e.getReleaseByTag({owner:t,repo:s,tag:r});return i}catch(i){if(i.status===404)return;throw i}}var Y_=1e3,O_=2;async function J_(e){await new Promise(t=>setTimeout(t,e))}async function P_(e,t,s,r){let i=[],o=0;for await(let n of e.allReleases({owner:t,repo:s}))if(i.push(...n.data.filter(a=>a.tag_name===r)),o+=1,o>=O_)break;return i}function H_(e,t){return t&&e.some(s=>s.id===t.id)||e.length===0?t:[...e].sort((s,r)=>s.draft!==r.draft?Number(s.draft)-Number(r.draft):s.id-r.id)[0]}async function V_(e,t,s,r,i,o){let n=Array.from(new Map(o.map(a=>[a.id,a])).values());for(let a of n)if(!(a.id===i||!a.draft||a.assets.length>0))try{console.log(`\u{1F9F9} Removing duplicate draft release ${a.id} for tag ${r}...`),await e.deleteRelease({owner:t,repo:s,release_id:a.id})}catch(A){console.warn(`error deleting duplicate release ${a.id}: ${A}`)}}async function q_(e,t,s,r,i,o){let n=Math.max(o,1);for(let a=1;a<=n;a+=1){let A;try{A=await Fw(e,t,s,r)}catch(l){console.warn(`error reloading release for tag ${r}: ${l}`)}let c=[];try{c=await P_(e,t,s,r)}catch(l){console.warn(`error listing recent releases for tag ${r}: ${l}`)}let u=H_(c,A);if(u)return u.id!==i.id&&console.log(`\u21AA\uFE0F Using release ${u.id} for tag ${r} instead of duplicate draft ${i.id}`),await V_(e,t,s,r,u.id,[i,...c]),u;as==="pre_receive"&&typeof r=="string"&&r.includes("creations being restricted"))}var Sw=require("process");async function j_(){try{let e=Cw(Sw.env);if(!e.input_tag_name&&!fo(e.github_ref)&&!e.input_draft)throw new Error("\u26A0\uFE0F GitHub Releases requires a tag");if(e.input_files){let a=bw(e.input_files,e.input_working_directory);if(a.forEach(A=>{if(e.input_fail_on_unmatched_files)throw new Error(`\u26A0\uFE0F Pattern '${A}' does not match any files.`);console.warn(`\u{1F914} Pattern '${A}' does not match any files.`)}),a.length>0&&e.input_fail_on_unmatched_files)throw new Error("\u26A0\uFE0F There were unmatched files")}let t=ZC(e.github_token,{throttle:{onRateLimit:(a,A)=>{if(console.warn(`Request quota exhausted for request ${A.method} ${A.url}`),A.request.retryCount===0)return console.log(`Retrying after ${a} seconds!`),!0},onAbuseLimit:(a,A)=>{console.warn(`Abuse detected for request ${A.method} ${A.url}`)}}}),s=new Za(t),r=await lp(e,s),i=r.release,o=r.created,n=new Set;if(e.input_files&&e.input_files.length>0){let a=ww(e.input_files,e.input_working_directory);if(a.length==0){if(e.input_fail_on_unmatched_files)throw new Error(`\u26A0\uFE0F ${e.input_files} does not include a valid file.`);console.warn(`\u{1F914} ${e.input_files} does not include a valid file.`)}let A=i.assets,c=async l=>{let p=await Tw(e,s,Bw(i.upload_url),l,A);return p?p.id:void 0},u;if(!e.input_preserve_order)u=await Promise.all(a.map(c));else{u=[];for(let l of a)u.push(await c(l))}n=new Set(u.filter(l=>l!==void 0))}console.log("Finalizing release..."),i=await up(e,s,i,o),console.log("Getting assets list...");{let a=[];n.size>0&&(a=(await pp(e,s,i)).filter(c=>n.has(c.id)).map(c=>{let{uploader:u,...l}=c;return l})),eo("assets",a)}console.log(`\u{1F389} Release ready at ${i.html_url}`),eo("url",i.html_url),eo("id",i.id.toString()),eo("upload_url",i.upload_url)}catch(e){eC(e.message)}}j_(); /*! Bundled license information: undici/lib/web/fetch/body.js: diff --git a/src/github.ts b/src/github.ts index c6ec963..0141c44 100644 --- a/src/github.ts +++ b/src/github.ts @@ -71,6 +71,7 @@ export interface Releaser { repo: string; release_id: number; make_latest: 'true' | 'false' | 'legacy' | undefined; + discussion_category_name: string | undefined; }): Promise<{ data: Release }>; allReleases(params: { owner: string; repo: string }): AsyncIterable<{ data: Release[] }>; @@ -181,6 +182,7 @@ export class GitHubReleaser implements Releaser { repo: string; release_id: number; make_latest: 'true' | 'false' | 'legacy' | undefined; + discussion_category_name: string | undefined; }) { return await this.github.rest.repos.updateRelease({ owner: params.owner, @@ -188,6 +190,7 @@ export class GitHubReleaser implements Releaser { release_id: params.release_id, draft: false, make_latest: params.make_latest, + discussion_category_name: params.discussion_category_name, }); } @@ -641,6 +644,7 @@ export const finalizeRelease = async ( repo, release_id: release.id, make_latest: config.input_make_latest, + discussion_category_name: config.input_discussion_category_name, }); return data;