diff --git a/dist/dune.mjs b/dist/cache.mjs similarity index 99% rename from dist/dune.mjs rename to dist/cache.mjs index ba19a604..297ff20a 100644 --- a/dist/dune.mjs +++ b/dist/cache.mjs @@ -565,4 +565,4 @@ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\ `,e)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){let t=e.items[e.items.length-1];switch(this.type){case`newline`:if(this.onKeyLine=!1,t.value){let n=`end`in t.value?t.value.end:void 0;(Array.isArray(n)?n[n.length-1]:void 0)?.type===`comment`?n?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case`space`:case`comment`:if(t.value)e.items.push({start:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else{if(this.atIndentedComment(t.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){l(n,t.start),n.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return}if(this.indent>=e.indent){let n=!this.onKeyLine&&this.indent===e.indent,r=n&&(t.sep||t.explicitKey)&&this.type!==`seq-item-ind`,a=[];if(r&&t.sep&&!t.value){let n=[];for(let r=0;re.indent&&(n.length=0);break;default:n.length=0}}n.length>=2&&(a=t.sep.splice(n[1]))}switch(this.type){case`anchor`:case`tag`:r||t.value?(a.push(this.sourceToken),e.items.push({start:a}),this.onKeyLine=!0):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case`explicit-key-ind`:!t.sep&&!t.explicitKey?(t.start.push(this.sourceToken),t.explicitKey=!0):r||t.value?(a.push(this.sourceToken),e.items.push({start:a,explicitKey:!0})):this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]}),this.onKeyLine=!0;return;case`map-value-ind`:if(t.explicitKey)if(!t.sep)if(i(t.start,`newline`))Object.assign(t,{key:null,sep:[this.sourceToken]});else{let e=c(t.start);this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:e,key:null,sep:[this.sourceToken]}]})}else if(t.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(i(t.sep,`map-value-ind`))this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:a,key:null,sep:[this.sourceToken]}]});else if(o(t.key)&&!i(t.sep,`newline`)){let e=c(t.start),n=t.key,r=t.sep;r.push(this.sourceToken),delete t.key,delete t.sep,this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:e,key:n,sep:r}]})}else a.length>0?t.sep=t.sep.concat(a,this.sourceToken):t.sep.push(this.sourceToken);else t.sep?t.value||r?e.items.push({start:a,key:null,sep:[this.sourceToken]}):i(t.sep,`map-value-ind`)?this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});this.onKeyLine=!0;return;case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:{let n=this.flowScalar(this.type);r||t.value?(e.items.push({start:a,key:n,sep:[]}),this.onKeyLine=!0):t.sep?this.stack.push(n):(Object.assign(t,{key:n,sep:[]}),this.onKeyLine=!0);return}default:{let r=this.startBlockValue(e);if(r){if(r.type===`block-seq`){if(!t.explicitKey&&t.sep&&!i(t.sep,`newline`)){yield*this.pop({type:`error`,offset:this.offset,message:`Unexpected block-seq-ind on same line with key`,source:this.source});return}}else n&&e.items.push({start:a});this.stack.push(r);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(e){let t=e.items[e.items.length-1];switch(this.type){case`newline`:if(t.value){let n=`end`in t.value?t.value.end:void 0;(Array.isArray(n)?n[n.length-1]:void 0)?.type===`comment`?n?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.start.push(this.sourceToken);return;case`space`:case`comment`:if(t.value)e.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(t.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){l(n,t.start),n.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return;case`anchor`:case`tag`:if(t.value||this.indent<=e.indent)break;t.start.push(this.sourceToken);return;case`seq-item-ind`:if(this.indent!==e.indent)break;t.value||i(t.start,`seq-item-ind`)?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return}if(this.indent>e.indent){let t=this.startBlockValue(e);if(t){this.stack.push(t);return}}yield*this.pop(),yield*this.step()}*flowCollection(e){let t=e.items[e.items.length-1];if(this.type===`flow-error-end`){let e;do yield*this.pop(),e=this.peek(1);while(e?.type===`flow-collection`)}else if(e.end.length===0){switch(this.type){case`comma`:case`explicit-key-ind`:!t||t.sep?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return;case`map-value-ind`:!t||t.value?e.items.push({start:[],key:null,sep:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});return;case`space`:case`comment`:case`newline`:case`anchor`:case`tag`:!t||t.value?e.items.push({start:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:{let n=this.flowScalar(this.type);!t||t.value?e.items.push({start:[],key:n,sep:[]}):t.sep?this.stack.push(n):Object.assign(t,{key:n,sep:[]});return}case`flow-map-end`:case`flow-seq-end`:e.end.push(this.sourceToken);return}let n=this.startBlockValue(e);n?this.stack.push(n):(yield*this.pop(),yield*this.step())}else{let t=this.peek(2);if(t.type===`block-map`&&(this.type===`map-value-ind`&&t.indent===e.indent||this.type===`newline`&&!t.items[t.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type===`map-value-ind`&&t.type!==`flow-collection`){let n=c(s(t));u(e);let r=e.end.splice(1,e.end.length);r.push(this.sourceToken);let i={type:`block-map`,offset:e.offset,indent:e.indent,items:[{start:n,key:e,sep:r}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=i}else yield*this.lineEnd(e)}}flowScalar(e){if(this.onNewLine){let e=this.source.indexOf(` `)+1;for(;e!==0;)this.onNewLine(this.offset+e),e=this.source.indexOf(` `,e)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:return this.flowScalar(this.type);case`block-scalar-header`:return{type:`block-scalar`,offset:this.offset,indent:this.indent,props:[this.sourceToken],source:``};case`flow-map-start`:case`flow-seq-start`:return{type:`flow-collection`,offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case`seq-item-ind`:return{type:`block-seq`,offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case`explicit-key-ind`:{this.onKeyLine=!0;let t=c(s(e));return t.push(this.sourceToken),{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,explicitKey:!0}]}}case`map-value-ind`:{this.onKeyLine=!0;let t=c(s(e));return{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){return this.type!==`comment`||this.indent<=t?!1:e.every(e=>e.type===`newline`||e.type===`space`)}*documentEnd(e){this.type!==`doc-mode`&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case`comma`:case`doc-start`:case`doc-end`:case`flow-seq-end`:case`flow-map-end`:case`map-value-ind`:yield*this.pop(),yield*this.step();break;case`newline`:this.onKeyLine=!1;default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop())}}}})),oA=R((e=>{var t=Qk(),n=Fk(),r=Ik(),i=ok(),a=WO(),o=iA(),s=aA();function c(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new o.LineCounter||null,prettyErrors:t}}function l(e,n={}){let{lineCounter:i,prettyErrors:a}=c(n),o=new s.Parser(i?.addNewLine),l=new t.Composer(n),u=Array.from(l.compose(o.parse(e)));if(a&&i)for(let t of u)t.errors.forEach(r.prettifyError(e,i)),t.warnings.forEach(r.prettifyError(e,i));return u.length>0?u:Object.assign([],{empty:!0},l.streamInfo())}function u(e,n={}){let{lineCounter:i,prettyErrors:a}=c(n),o=new s.Parser(i?.addNewLine),l=new t.Composer(n),u=null;for(let t of l.compose(o.parse(e),!0,e.length))if(!u)u=t;else if(u.options.logLevel!==`silent`){u.errors.push(new r.YAMLParseError(t.range.slice(0,2),`MULTIPLE_DOCS`,`Source contains multiple documents; please use YAML.parseAllDocuments()`));break}return a&&i&&(u.errors.forEach(r.prettifyError(e,i)),u.warnings.forEach(r.prettifyError(e,i))),u}function d(e,t,n){let r;typeof t==`function`?r=t:n===void 0&&t&&typeof t==`object`&&(n=t);let a=u(e,n);if(!a)return null;if(a.warnings.forEach(e=>i.warn(a.options.logLevel,e)),a.errors.length>0){if(a.options.logLevel!==`silent`)throw a.errors[0];a.errors=[]}return a.toJS(Object.assign({reviver:r},n))}function f(e,t,r){let i=null;if(typeof t==`function`||Array.isArray(t)?i=t:r===void 0&&t&&(r=t),typeof r==`string`&&(r=r.length),typeof r==`number`){let e=Math.round(r);r=e<1?void 0:e>8?{indent:8}:{indent:e}}if(e===void 0){let{keepUndefined:e}=r??t??{};if(!e)return}return a.isDocument(e)&&!i?e.toString(r):new n.Document(e,i,r).toString(r)}e.parse=d,e.parseAllDocuments=l,e.parseDocument=u,e.stringify=f})),sA=R((e=>{var t=Qk(),n=Fk(),r=Nk(),i=Ik(),a=ZO(),o=WO(),s=lk(),c=QO(),l=dk(),u=pk();nA();var d=rA(),f=iA(),p=aA(),m=oA(),h=GO();e.Composer=t.Composer,e.Document=n.Document,e.Schema=r.Schema,e.YAMLError=i.YAMLError,e.YAMLParseError=i.YAMLParseError,e.YAMLWarning=i.YAMLWarning,e.Alias=a.Alias,e.isAlias=o.isAlias,e.isCollection=o.isCollection,e.isDocument=o.isDocument,e.isMap=o.isMap,e.isNode=o.isNode,e.isPair=o.isPair,e.isScalar=o.isScalar,e.isSeq=o.isSeq,e.Pair=s.Pair,e.Scalar=c.Scalar,e.YAMLMap=l.YAMLMap,e.YAMLSeq=u.YAMLSeq,e.Lexer=d.Lexer,e.LineCounter=f.LineCounter,e.Parser=p.Parser,e.parse=m.parse,e.parseAllDocuments=m.parseAllDocuments,e.parseDocument=m.parseDocument,e.stringify=m.stringify,e.visit=h.visit,e.visitAsync=h.visitAsync})),cA=bO(),lA=z(UO(),1),uA=z(sA(),1);const dA=(()=>{switch(t.arch){case`arm`:return`armhf`;case`arm64`:return`arm64`;case`riscv64`:return`riscv64`;case`s390x`:return`s390x`;case`x64`:return`x86_64`;default:throw Error(`'${t.arch}' is not supported. Supported architectures: arm, arm64, riscv64, s390x, x64`)}})(),fA=(()=>{switch(t.platform){case`darwin`:return`macos`;case`linux`:return`linux`;case`win32`:return`windows`;default:throw Error(`'${t.platform}' is not supported. Supported platforms: darwin, linux, win32`)}})(),pA=(()=>{try{let e=N.readFileSync(`/etc/os-release`).toString().match(/^ID=(.*)$/m);return e?e[1]:`(unknown)`}catch{return`(unknown)`}})(),mA=[`curl`,`diffutils`,`m4`,`mingw64-i686-gcc-core`,`mingw64-i686-gcc-g++`,`mingw64-x86_64-gcc-core`,`mingw64-x86_64-gcc-g++`,`patch`,`perl`],hA=(()=>{let e=t.env.ImageOS,n=t.env.RUNNER_ENVIRONMENT;return e?`github-hosted`:n||`self-hosted`})(),gA=t.env.GITHUB_WORKSPACE??t.cwd(),_A=I.join(`C:`,`msys64`),vA=fA===`windows`?I.join(`C:`,`.opam`):I.join(te.homedir(),`.opam`),yA=I.join(vA,`.cygwin`,`root`),bA=I.join(yA,`bin`),xA=I.join(yA,`bash_env`),SA=(()=>{let e=t.env.XDG_CACHE_HOME;return e?I.join(e,`dune`):fA===`windows`?I.join(`C:`,`dune`):I.join(te.homedir(),`.cache`,`dune`)})(),CA=Or(`ocaml-compiler`,{required:!0}),wA=kr(`save-opam-post-run`),TA=(()=>{let e=uA.parse(Or(`opam-repositories`),{schema:`failsafe`});if(typeof e!=`object`||!e||Array.isArray(e))throw Error(`opam-repositories input must be a YAML mapping of name: URL pairs`);let t=Object.entries(e);if(t.length===0)throw Error(`opam-repositories input must not be empty`);return t.reverse()})(),EA=kr(`opam-pin`),DA=Or(`opam-local-packages`),OA=fA!==`windows`&&kr(`opam-disable-sandboxing`),kA=kr(`dune-cache`),AA=Or(`cache-prefix`),jA=(()=>{let e=Or(`windows-environment`).toLowerCase();if(e!==`cygwin`&&e!==`msys2`)throw Error(`Invalid windows-environment value '${e}'. Supported values: cygwin, msys2`);return e})(),MA=(()=>{let e=Or(`windows-compiler`).toLowerCase();if(e!==`mingw`&&e!==`msvc`)throw Error(`Invalid windows-compiler value '${e}'. Supported values: mingw, msvc`);return e})(),NA=kr(`allow-prerelease-opam`),PA=Or(`github-token`);var FA=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},IA=class{constructor(e,t,n){if(e<1)throw Error(`max attempts should be greater than or equal to 1`);if(this.maxAttempts=e,this.minSeconds=Math.floor(t),this.maxSeconds=Math.floor(n),this.minSeconds>this.maxSeconds)throw Error(`min seconds should be less than or equal to max seconds`)}execute(e,t){return FA(this,void 0,void 0,function*(){let n=1;for(;nsetTimeout(t,e*1e3))})}},LA=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},RA=class extends Error{constructor(e){super(`Unexpected HTTP response: ${e}`),this.httpStatusCode=e,Object.setPrototypeOf(this,new.target.prototype)}};process.platform,process.platform;function zA(e,t,n,r){return LA(this,void 0,void 0,function*(){return t||=p.join(YA(),o.randomUUID()),yield lr(p.dirname(t)),H(`Downloading ${e}`),H(`Destination ${t}`),yield new IA(3,XA(`TEST_DOWNLOAD_TOOL_RETRY_MIN_SECONDS`,10),XA(`TEST_DOWNLOAD_TOOL_RETRY_MAX_SECONDS`,20)).execute(()=>LA(this,void 0,void 0,function*(){return yield BA(e,t||``,n,r)}),e=>!(e instanceof RA&&e.httpStatusCode&&e.httpStatusCode<500&&e.httpStatusCode!==408&&e.httpStatusCode!==429))})}function BA(e,t,n,r){return LA(this,void 0,void 0,function*(){if(s.existsSync(t))throw Error(`Destination file path ${t} already exists`);let i=new jn(`actions/tool-cache`,[],{allowRetries:!1});n&&(H(`set auth`),r===void 0&&(r={}),r.authorization=n);let a=yield i.get(e,r);if(a.message.statusCode!==200){let t=new RA(a.message.statusCode);throw H(`Failed to download from "${e}". Code(${a.message.statusCode}) Message(${a.message.statusMessage})`),t}let o=b.promisify(re.pipeline),c=XA(`TEST_DOWNLOAD_TOOL_RESPONSE_MESSAGE_FACTORY`,()=>a.message)(),l=!1;try{return yield o(c,s.createWriteStream(t)),H(`download complete`),l=!0,t}finally{if(!l){H(`download failed`);try{yield cr(t)}catch(e){H(`Failed to delete '${t}'. ${e.message}`)}}}})}function VA(e,t,n,i,a){return LA(this,void 0,void 0,function*(){if(i=oa.clean(i)||i,a||=r.arch(),H(`Caching tool ${n} ${i} ${a}`),H(`source file: ${e}`),!s.statSync(e).isFile())throw Error(`sourceFile is not a file`);let o=yield WA(n,i,a),c=p.join(o,t);return H(`destination file ${c}`),yield sr(e,c),GA(n,i,a),o})}function HA(e,t,n){if(!e)throw Error(`toolName parameter is required`);if(!t)throw Error(`versionSpec parameter is required`);n||=r.arch(),KA(t)||(t=qA(UA(e,n),t));let i=``;if(t){t=oa.clean(t)||``;let r=p.join(JA(),e,t,n);H(`checking cache: ${r}`),s.existsSync(r)&&s.existsSync(`${r}.complete`)?(H(`Found tool in cache ${e} ${t} ${n}`),i=r):H(`not found`)}return i}function UA(e,t){let n=[];t||=r.arch();let i=p.join(JA(),e);if(s.existsSync(i)){let e=s.readdirSync(i);for(let r of e)if(KA(r)){let e=p.join(i,r,t||``);s.existsSync(e)&&s.existsSync(`${e}.complete`)&&n.push(r)}}return n}function WA(e,t,n){return LA(this,void 0,void 0,function*(){let r=p.join(JA(),e,oa.clean(t)||t,n||``);H(`destination ${r}`);let i=`${r}.complete`;return yield cr(r),yield cr(i),yield lr(r),r})}function GA(e,t,n){let r=`${p.join(JA(),e,oa.clean(t)||t,n||``)}.complete`;s.writeFileSync(r,``),H(`finished caching tool`)}function KA(e){let t=oa.clean(e)||``;H(`isExplicit: ${t}`);let n=oa.valid(t)!=null;return H(`explicit? ${n}`),n}function qA(e,t){let n=``;H(`evaluating ${e.length} versions`),e=e.sort((e,t)=>oa.gt(e,t)?1:-1);for(let r=e.length-1;r>=0;r--){let i=e[r];if(oa.satisfies(i,t)){n=i;break}}return H(n?`matched: ${n}`:`match not found`),n}function JA(){let e=process.env.RUNNER_TOOL_CACHE||``;return y(e,`Expected RUNNER_TOOL_CACHE to be defined`),e}function YA(){let e=process.env.RUNNER_TEMP||``;return y(e,`Expected RUNNER_TEMP to be defined`),e}function XA(e,t){let n=global[e];return n===void 0?t:n}var ZA=z(R(((e,t)=>{(function(n,r){typeof e==`object`&&t!==void 0?t.exports=r():typeof define==`function`&&define.amd?define(r):n.Bottleneck=r()})(e,(function(){var e=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{};function t(e){return e&&e.default||e}var n={load:function(e,t,n={}){var r,i;for(r in t)i=t[r],n[r]=e[r]??i;return n},overwrite:function(e,t,n={}){var r,i;for(r in e)i=e[r],t[r]!==void 0&&(n[r]=i);return n}},r=class{constructor(e,t){this.incr=e,this.decr=t,this._first=null,this._last=null,this.length=0}push(e){var t;this.length++,typeof this.incr==`function`&&this.incr(),t={value:e,prev:this._last,next:null},this._last==null?this._first=this._last=t:(this._last.next=t,this._last=t)}shift(){var e;if(this._first!=null)return this.length--,typeof this.decr==`function`&&this.decr(),e=this._first.value,(this._first=this._first.next)==null?this._last=null:this._first.prev=null,e}first(){if(this._first!=null)return this._first.value}getArray(){for(var e=this._first,t,n=[];e!=null;)n.push((t=e,e=e.next,t.value));return n}forEachShift(e){for(var t=this.shift();t!=null;)e(t),t=this.shift()}debug(){for(var e=this._first,t,n=[];e!=null;)n.push((t=e,e=e.next,{value:t.value,prev:t.prev?.value,next:t.next?.value}));return n}},i=class{constructor(e){if(this.instance=e,this._events={},this.instance.on!=null||this.instance.once!=null||this.instance.removeAllListeners!=null)throw Error(`An Emitter already exists for this object`);this.instance.on=(e,t)=>this._addListener(e,`many`,t),this.instance.once=(e,t)=>this._addListener(e,`once`,t),this.instance.removeAllListeners=(e=null)=>e==null?this._events={}:delete this._events[e]}_addListener(e,t,n){var r;return(r=this._events)[e]??(r[e]=[]),this._events[e].push({cb:n,status:t}),this.instance}listenerCount(e){return this._events[e]==null?0:this._events[e].length}async trigger(e,...t){var n,r;try{return e!==`debug`&&this.trigger(`debug`,`Event triggered: ${e}`,t),this._events[e]==null?void 0:(this._events[e]=this._events[e].filter(function(e){return e.status!==`none`}),r=this._events[e].map(async e=>{var n,r;if(e.status!==`none`){e.status===`once`&&(e.status=`none`);try{return r=typeof e.cb==`function`?e.cb(...t):void 0,typeof r?.then==`function`?await r:r}catch(e){return n=e,this.trigger(`error`,n),null}}}),(await Promise.all(r)).find(function(e){return e!=null}))}catch(e){return n=e,this.trigger(`error`,n),null}}},a=r,o=i,s=class{constructor(e){this.Events=new o(this),this._length=0,this._lists=(function(){var t,n,r=[];for(t=1,n=e;1<=n?t<=n:t>=n;1<=n?++t:--t)r.push(new a((()=>this.incr()),(()=>this.decr())));return r}).call(this)}incr(){if(this._length++===0)return this.Events.trigger(`leftzero`)}decr(){if(--this._length===0)return this.Events.trigger(`zero`)}push(e){return this._lists[e.options.priority].push(e)}queued(e){return e==null?this._length:this._lists[e].length}shiftAll(e){return this._lists.forEach(function(t){return t.forEachShift(e)})}getFirst(e=this._lists){var t,n,r;for(t=0,n=e.length;t0)return r;return[]}shiftLastFrom(e){return this.getFirst(this._lists.slice(e).reverse()).shift()}},c=class extends Error{},l,u,d,f=10,p;u=5,p=n,l=c,d=class{constructor(e,t,n,r,i,a,o,s){this.task=e,this.args=t,this.rejectOnDrop=i,this.Events=a,this._states=o,this.Promise=s,this.options=p.load(n,r),this.options.priority=this._sanitizePriority(this.options.priority),this.options.id===r.id&&(this.options.id=`${this.options.id}-${this._randomIndex()}`),this.promise=new this.Promise((e,t)=>{this._resolve=e,this._reject=t}),this.retryCount=0}_sanitizePriority(e){var t=~~e===e?e:u;return t<0?0:t>f-1?f-1:t}_randomIndex(){return Math.random().toString(36).slice(2)}doDrop({error:e,message:t=`This job has been dropped by Bottleneck`}={}){return this._states.remove(this.options.id)?(this.rejectOnDrop&&this._reject(e??new l(t)),this.Events.trigger(`dropped`,{args:this.args,options:this.options,task:this.task,promise:this.promise}),!0):!1}_assertStatus(e){var t=this._states.jobStatus(this.options.id);if(!(t===e||e===`DONE`&&t===null))throw new l(`Invalid job status ${t}, expected ${e}. Please open an issue at https://github.com/SGrondin/bottleneck/issues`)}doReceive(){return this._states.start(this.options.id),this.Events.trigger(`received`,{args:this.args,options:this.options})}doQueue(e,t){return this._assertStatus(`RECEIVED`),this._states.next(this.options.id),this.Events.trigger(`queued`,{args:this.args,options:this.options,reachedHWM:e,blocked:t})}doRun(){return this.retryCount===0?(this._assertStatus(`QUEUED`),this._states.next(this.options.id)):this._assertStatus(`EXECUTING`),this.Events.trigger(`scheduled`,{args:this.args,options:this.options})}async doExecute(e,t,n,r){var i,a,o;this.retryCount===0?(this._assertStatus(`RUNNING`),this._states.next(this.options.id)):this._assertStatus(`EXECUTING`),a={args:this.args,options:this.options,retryCount:this.retryCount},this.Events.trigger(`executing`,a);try{if(o=await(e==null?this.task(...this.args):e.schedule(this.options,this.task,...this.args)),t())return this.doDone(a),await r(this.options,a),this._assertStatus(`DONE`),this._resolve(o)}catch(e){return i=e,this._onFailure(i,a,t,n,r)}}doExpire(e,t,n){var r,i;return this._states.jobStatus(this.options.id===`RUNNING`)&&this._states.next(this.options.id),this._assertStatus(`EXECUTING`),i={args:this.args,options:this.options,retryCount:this.retryCount},r=new l(`This job timed out after ${this.options.expiration} ms.`),this._onFailure(r,i,e,t,n)}async _onFailure(e,t,n,r,i){var a,o;if(n())return a=await this.Events.trigger(`failed`,e,t),a==null?(this.doDone(t),await i(this.options,t),this._assertStatus(`DONE`),this._reject(e)):(o=~~a,this.Events.trigger(`retry`,`Retrying ${this.options.id} after ${o} ms`,t),this.retryCount++,r(o))}doDone(e){return this._assertStatus(`EXECUTING`),this._states.next(this.options.id),this.Events.trigger(`done`,e)}};var m=d,h,g,_=n;h=c,g=class{constructor(e,t,n){this.instance=e,this.storeOptions=t,this.clientId=this.instance._randomIndex(),_.load(n,n,this),this._nextRequest=this._lastReservoirRefresh=this._lastReservoirIncrease=Date.now(),this._running=0,this._done=0,this._unblockTime=0,this.ready=this.Promise.resolve(),this.clients={},this._startHeartbeat()}_startHeartbeat(){var e;return this.heartbeat==null&&(this.storeOptions.reservoirRefreshInterval!=null&&this.storeOptions.reservoirRefreshAmount!=null||this.storeOptions.reservoirIncreaseInterval!=null&&this.storeOptions.reservoirIncreaseAmount!=null)?typeof(e=this.heartbeat=setInterval(()=>{var e,t,n,r=Date.now(),i;if(this.storeOptions.reservoirRefreshInterval!=null&&r>=this._lastReservoirRefresh+this.storeOptions.reservoirRefreshInterval&&(this._lastReservoirRefresh=r,this.storeOptions.reservoir=this.storeOptions.reservoirRefreshAmount,this.instance._drainAll(this.computeCapacity())),this.storeOptions.reservoirIncreaseInterval!=null&&r>=this._lastReservoirIncrease+this.storeOptions.reservoirIncreaseInterval&&({reservoirIncreaseAmount:e,reservoirIncreaseMaximum:n,reservoir:i}=this.storeOptions,this._lastReservoirIncrease=r,t=n==null?e:Math.min(e,n-i),t>0))return this.storeOptions.reservoir+=t,this.instance._drainAll(this.computeCapacity())},this.heartbeatInterval)).unref==`function`?e.unref():void 0:clearInterval(this.heartbeat)}async __publish__(e){return await this.yieldLoop(),this.instance.Events.trigger(`message`,e.toString())}async __disconnect__(e){return await this.yieldLoop(),clearInterval(this.heartbeat),this.Promise.resolve()}yieldLoop(e=0){return new this.Promise(function(t,n){return setTimeout(t,e)})}computePenalty(){return this.storeOptions.penalty??(15*this.storeOptions.minTime||5e3)}async __updateSettings__(e){return await this.yieldLoop(),_.overwrite(e,e,this.storeOptions),this._startHeartbeat(),this.instance._drainAll(this.computeCapacity()),!0}async __running__(){return await this.yieldLoop(),this._running}async __queued__(){return await this.yieldLoop(),this.instance.queued()}async __done__(){return await this.yieldLoop(),this._done}async __groupCheck__(e){return await this.yieldLoop(),this._nextRequest+this.timeout=e}check(e,t){return this.conditionsCheck(e)&&this._nextRequest-t<=0}async __check__(e){var t;return await this.yieldLoop(),t=Date.now(),this.check(e,t)}async __register__(e,t,n){var r,i;return await this.yieldLoop(),r=Date.now(),this.conditionsCheck(t)?(this._running+=t,this.storeOptions.reservoir!=null&&(this.storeOptions.reservoir-=t),i=Math.max(this._nextRequest-r,0),this._nextRequest=r+i+this.storeOptions.minTime,{success:!0,wait:i,reservoir:this.storeOptions.reservoir}):{success:!1}}strategyIsBlock(){return this.storeOptions.strategy===3}async __submit__(e,t){var n,r,i;if(await this.yieldLoop(),this.storeOptions.maxConcurrent!=null&&t>this.storeOptions.maxConcurrent)throw new h(`Impossible to add a job having a weight of ${t} to a limiter having a maxConcurrent setting of ${this.storeOptions.maxConcurrent}`);return r=Date.now(),i=this.storeOptions.highWater!=null&&e===this.storeOptions.highWater&&!this.check(t,r),n=this.strategyIsBlock()&&(i||this.isBlocked(r)),n&&(this._unblockTime=r+this.computePenalty(),this._nextRequest=this._unblockTime+this.storeOptions.minTime,this.instance._dropAllQueued()),{reachedHWM:i,blocked:n,strategy:this.storeOptions.strategy}}async __free__(e,t){return await this.yieldLoop(),this._running-=t,this._done+=t,this.instance._drainAll(this.computeCapacity()),{running:this._running}}};var v=g,y=c,b=class{constructor(e){this.status=e,this._jobs={},this.counts=this.status.map(function(){return 0})}next(e){var t=this._jobs[e],n=t+1;if(t!=null&&n(e[this.status[n]]=t,e)),{})}},x=r,S=class{constructor(e,t){this.schedule=this.schedule.bind(this),this.name=e,this.Promise=t,this._running=0,this._queue=new x}isEmpty(){return this._queue.length===0}async _tryToRun(){var e,t,n,r,i,a,o;if(this._running<1&&this._queue.length>0)return this._running++,{task:o,args:e,resolve:i,reject:r}=this._queue.shift(),t=await(async function(){try{return a=await o(...e),function(){return i(a)}}catch(e){return n=e,function(){return r(n)}}})(),this._running--,this._tryToRun(),t()}schedule(e,...t){var n,r,i=r=null;return n=new this.Promise(function(e,t){return i=e,r=t}),this._queue.push({task:e,args:t,resolve:i,reject:r}),this._tryToRun(),n}},C=`2.19.5`,w=Object.freeze({version:C,default:{version:C}}),T=()=>console.log(`You must import the full version of Bottleneck in order to use this feature.`),E=()=>console.log(`You must import the full version of Bottleneck in order to use this feature.`),D=()=>console.log(`You must import the full version of Bottleneck in order to use this feature.`),O,k,A,j,M,N=n;O=i,j=T,A=E,M=D,k=(function(){class e{constructor(e={}){this.deleteKey=this.deleteKey.bind(this),this.limiterOptions=e,N.load(this.limiterOptions,this.defaults,this),this.Events=new O(this),this.instances={},this.Bottleneck=R,this._startAutoCleanup(),this.sharedConnection=this.connection!=null,this.connection??(this.limiterOptions.datastore===`redis`?this.connection=new j(Object.assign({},this.limiterOptions,{Events:this.Events})):this.limiterOptions.datastore===`ioredis`&&(this.connection=new A(Object.assign({},this.limiterOptions,{Events:this.Events}))))}key(e=``){return this.instances[e]??(()=>{var t=this.instances[e]=new this.Bottleneck(Object.assign(this.limiterOptions,{id:`${this.id}-${e}`,timeout:this.timeout,connection:this.connection}));return this.Events.trigger(`created`,t,e),t})()}async deleteKey(e=``){var t,n=this.instances[e];return this.connection&&(t=await this.connection.__runCommand__([`del`,...M.allKeys(`${this.id}-${e}`)])),n!=null&&(delete this.instances[e],await n.disconnect()),n!=null||t>0}limiters(){var e,t=this.instances,n=[],r;for(e in t)r=t[e],n.push({key:e,limiter:r});return n}keys(){return Object.keys(this.instances)}async clusterKeys(){var e,t,n,r,i,a,o,s,c;if(this.connection==null)return this.Promise.resolve(this.keys());for(a=[],e=null,c=`b_${this.id}-`.length,t=9;e!==0;)for([s,n]=await this.connection.__runCommand__([`scan`,e??0,`match`,`b_${this.id}-*_settings`,`count`,1e4]),e=~~s,r=0,o=n.length;r{var e,t,n,r,i=Date.now(),a;for(t in n=this.instances,r=[],n){a=n[t];try{await a._store.__groupCheck__(i)?r.push(this.deleteKey(t)):r.push(void 0)}catch(t){e=t,r.push(a.Events.trigger(`error`,e))}}return r},this.timeout/2)).unref==`function`?e.unref():void 0}updateSettings(e={}){if(N.overwrite(e,this.defaults,this),N.overwrite(e,e,this.limiterOptions),e.timeout!=null)return this._startAutoCleanup()}disconnect(e=!0){if(!this.sharedConnection)return this.connection?.disconnect(e)}}return e.prototype.defaults={timeout:1e3*60*5,connection:null,Promise,id:`group-key`},e}).call(e);var P=k,ee,te,ne=n;te=i,ee=(function(){class e{constructor(e={}){this.options=e,ne.load(this.options,this.defaults,this),this.Events=new te(this),this._arr=[],this._resetPromise(),this._lastFlush=Date.now()}_resetPromise(){return this._promise=new this.Promise((e,t)=>this._resolve=e)}_flush(){return clearTimeout(this._timeout),this._lastFlush=Date.now(),this._resolve(),this.Events.trigger(`batch`,this._arr),this._arr=[],this._resetPromise()}add(e){var t;return this._arr.push(e),t=this._promise,this._arr.length===this.maxSize?this._flush():this.maxTime!=null&&this._arr.length===1&&(this._timeout=setTimeout(()=>this._flush(),this.maxTime)),t}}return e.prototype.defaults={maxTime:null,maxSize:null,Promise},e}).call(e);var F=ee,re=()=>console.log(`You must import the full version of Bottleneck in order to use this feature.`),ie=t(w),I,ae,oe,se,ce,le,L,ue,de,fe,pe,me=[].splice;le=10,ae=5,pe=n,L=s,se=m,ce=v,ue=re,oe=i,de=b,fe=S,I=(function(){class e{constructor(t={},...n){var r,i;this._addToQueue=this._addToQueue.bind(this),this._validateOptions(t,n),pe.load(t,this.instanceDefaults,this),this._queues=new L(le),this._scheduled={},this._states=new de([`RECEIVED`,`QUEUED`,`RUNNING`,`EXECUTING`].concat(this.trackDoneStatus?[`DONE`]:[])),this._limiter=null,this.Events=new oe(this),this._submitLock=new fe(`submit`,this.Promise),this._registerLock=new fe(`register`,this.Promise),i=pe.load(t,this.storeDefaults,{}),this._store=(function(){if(this.datastore===`redis`||this.datastore===`ioredis`||this.connection!=null)return r=pe.load(t,this.redisStoreDefaults,{}),new ue(this,i,r);if(this.datastore===`local`)return r=pe.load(t,this.localStoreDefaults,{}),new ce(this,i,r);throw new e.prototype.BottleneckError(`Invalid datastore type: ${this.datastore}`)}).call(this),this._queues.on(`leftzero`,()=>{var e;return(e=this._store.heartbeat)==null?void 0:typeof e.ref==`function`?e.ref():void 0}),this._queues.on(`zero`,()=>{var e;return(e=this._store.heartbeat)==null?void 0:typeof e.unref==`function`?e.unref():void 0})}_validateOptions(t,n){if(!(typeof t==`object`&&t&&n.length===0))throw new e.prototype.BottleneckError(`Bottleneck v2 takes a single object argument. Refer to https://github.com/SGrondin/bottleneck#upgrading-to-v2 if you're upgrading from Bottleneck v1.`)}ready(){return this._store.ready}clients(){return this._store.clients}channel(){return`b_${this.id}`}channel_client(){return`b_${this.id}_${this._store.clientId}`}publish(e){return this._store.__publish__(e)}disconnect(e=!0){return this._store.__disconnect__(e)}chain(e){return this._limiter=e,this}queued(e){return this._queues.queued(e)}clusterQueued(){return this._store.__queued__()}empty(){return this.queued()===0&&this._submitLock.isEmpty()}running(){return this._store.__running__()}done(){return this._store.__done__()}jobStatus(e){return this._states.jobStatus(e)}jobs(e){return this._states.statusJobs(e)}counts(){return this._states.statusCounts()}_randomIndex(){return Math.random().toString(36).slice(2)}check(e=1){return this._store.__check__(e)}_clearGlobalState(e){return this._scheduled[e]==null?!1:(clearTimeout(this._scheduled[e].expiration),delete this._scheduled[e],!0)}async _free(e,t,n,r){var i,a;try{if({running:a}=await this._store.__free__(e,n.weight),this.Events.trigger(`debug`,`Freed ${n.id}`,r),a===0&&this.empty())return this.Events.trigger(`idle`)}catch(e){return i=e,this.Events.trigger(`error`,i)}}_run(e,t,n){var r,i,a;return t.doRun(),r=this._clearGlobalState.bind(this,e),a=this._run.bind(this,e,t),i=this._free.bind(this,e,t),this._scheduled[e]={timeout:setTimeout(()=>t.doExecute(this._limiter,r,a,i),n),expiration:t.options.expiration==null?void 0:setTimeout(function(){return t.doExpire(r,a,i)},n+t.options.expiration),job:t}}_drainOne(e){return this._registerLock.schedule(()=>{var t,n,r,i,a;return this.queued()===0||(a=this._queues.getFirst(),{options:i,args:t}=r=a.first(),e!=null&&i.weight>e)?this.Promise.resolve(null):(this.Events.trigger(`debug`,`Draining ${i.id}`,{args:t,options:i}),n=this._randomIndex(),this._store.__register__(n,i.weight,i.expiration).then(({success:e,wait:o,reservoir:s})=>{var c;return this.Events.trigger(`debug`,`Drained ${i.id}`,{success:e,args:t,options:i}),e?(a.shift(),c=this.empty(),c&&this.Events.trigger(`empty`),s===0&&this.Events.trigger(`depleted`,c),this._run(n,r,o),this.Promise.resolve(i.weight)):this.Promise.resolve(null)}))})}_drainAll(e,t=0){return this._drainOne(e).then(n=>{var r;return n==null?this.Promise.resolve(t):(r=e==null?e:e-n,this._drainAll(r,t+n))}).catch(e=>this.Events.trigger(`error`,e))}_dropAllQueued(e){return this._queues.shiftAll(function(t){return t.doDrop({message:e})})}stop(t={}){var n,r;return t=pe.load(t,this.stopDefaults),r=e=>{var t=()=>{var t=this._states.counts;return t[0]+t[1]+t[2]+t[3]===e};return new this.Promise((e,n)=>t()?e():this.on(`done`,()=>{if(t())return this.removeAllListeners(`done`),e()}))},n=t.dropWaitingJobs?(this._run=function(e,n){return n.doDrop({message:t.dropErrorMessage})},this._drainOne=()=>this.Promise.resolve(null),this._registerLock.schedule(()=>this._submitLock.schedule(()=>{var e,n=this._scheduled,i;for(e in n)i=n[e],this.jobStatus(i.job.options.id)===`RUNNING`&&(clearTimeout(i.timeout),clearTimeout(i.expiration),i.job.doDrop({message:t.dropErrorMessage}));return this._dropAllQueued(t.dropErrorMessage),r(0)}))):this.schedule({priority:le-1,weight:0},()=>r(1)),this._receive=function(n){return n._reject(new e.prototype.BottleneckError(t.enqueueErrorMessage))},this.stop=()=>this.Promise.reject(new e.prototype.BottleneckError(`stop() has already been called`)),n}async _addToQueue(t){var n,r,i,a,o,s,c;({args:n,options:a}=t);try{({reachedHWM:o,blocked:r,strategy:c}=await this._store.__submit__(this.queued(),a.weight))}catch(e){return i=e,this.Events.trigger(`debug`,`Could not queue ${a.id}`,{args:n,options:a,error:i}),t.doDrop({error:i}),!1}return r?(t.doDrop(),!0):o&&(s=c===e.prototype.strategy.LEAK?this._queues.shiftLastFrom(a.priority):c===e.prototype.strategy.OVERFLOW_PRIORITY?this._queues.shiftLastFrom(a.priority+1):c===e.prototype.strategy.OVERFLOW?t:void 0,s?.doDrop(),s==null||c===e.prototype.strategy.OVERFLOW)?(s??t.doDrop(),o):(t.doQueue(o,r),this._queues.push(t),await this._drainAll(),o)}_receive(t){return this._states.jobStatus(t.options.id)==null?(t.doReceive(),this._submitLock.schedule(this._addToQueue,t)):(t._reject(new e.prototype.BottleneckError(`A job with the same id already exists (id=${t.options.id})`)),!1)}submit(...e){var t,n,r,i,a,o,s;return typeof e[0]==`function`?(a=e,[n,...e]=a,[t]=me.call(e,-1),i=pe.load({},this.jobDefaults)):(o=e,[i,n,...e]=o,[t]=me.call(e,-1),i=pe.load(i,this.jobDefaults)),s=(...e)=>new this.Promise(function(t,r){return n(...e,function(...e){return(e[0]==null?t:r)(e)})}),r=new se(s,e,i,this.jobDefaults,this.rejectOnDrop,this.Events,this._states,this.Promise),r.promise.then(function(e){return typeof t==`function`?t(...e):void 0}).catch(function(e){return Array.isArray(e)?typeof t==`function`?t(...e):void 0:typeof t==`function`?t(e):void 0}),this._receive(r)}schedule(...e){var t,n,r;return typeof e[0]==`function`?([r,...e]=e,n={}):[n,r,...e]=e,t=new se(r,e,n,this.jobDefaults,this.rejectOnDrop,this.Events,this._states,this.Promise),this._receive(t),t.promise}wrap(e){var t=this.schedule.bind(this),n=function(...n){return t(e.bind(this),...n)};return n.withOptions=function(n,...r){return t(n,e,...r)},n}async updateSettings(e={}){return await this._store.__updateSettings__(pe.overwrite(e,this.storeDefaults)),pe.overwrite(e,this.instanceDefaults,this),this}currentReservoir(){return this._store.__currentReservoir__()}incrementReservoir(e=0){return this._store.__incrementReservoir__(e)}}return e.default=e,e.Events=oe,e.version=e.prototype.version=ie.version,e.strategy=e.prototype.strategy={LEAK:1,OVERFLOW:2,OVERFLOW_PRIORITY:4,BLOCK:3},e.BottleneckError=e.prototype.BottleneckError=c,e.Group=e.prototype.Group=P,e.RedisConnection=e.prototype.RedisConnection=T,e.IORedisConnection=e.prototype.IORedisConnection=E,e.Batcher=e.prototype.Batcher=F,e.prototype.jobDefaults={priority:ae,weight:1,expiration:null,id:``},e.prototype.storeDefaults={maxConcurrent:null,minTime:0,highWater:null,strategy:e.prototype.strategy.LEAK,penalty:null,reservoir:null,reservoirRefreshInterval:null,reservoirRefreshAmount:null,reservoirIncreaseInterval:null,reservoirIncreaseAmount:null,reservoirIncreaseMaximum:null},e.prototype.localStoreDefaults={Promise,timeout:null,heartbeatInterval:250},e.prototype.redisStoreDefaults={Promise,timeout:null,heartbeatInterval:5e3,clientTimeout:1e4,Redis:null,clientOptions:{},clusterNodes:null,clearDatastore:!1,connection:null},e.prototype.instanceDefaults={datastore:`local`,connection:null,id:``,rejectOnDrop:!0,trackDoneStatus:!1,Promise},e.prototype.stopDefaults={enqueueErrorMessage:`This limiter has been stopped and cannot accept new jobs.`,dropWaitingJobs:!0,dropErrorMessage:`This limiter has been stopped.`},e}).call(e);var R=I;return R}))}))(),1),QA=`0.0.0-development`;function $A(e){return e.request!==void 0}async function ej(e,t,n,r){if(!$A(n)||!n?.request.request)throw n;if(n.status>=400&&!e.doNotRetry.includes(n.status)){let i=r.request.retries==null?e.retries:r.request.retries,a=((r.request.retryCount||0)+1)**2;throw t.retry.retryRequest(n,i,a)}throw n}async function tj(e,t,n,r){let i=new ZA.default;return i.on(`failed`,function(t,n){let i=~~t.request.request?.retries,a=~~t.request.request?.retryAfter;if(r.request.retryCount=n.retryCount+1,i>n.retryCount)return a*e.retryAfterBaseValue}),i.schedule(nj.bind(null,e,t,n),r)}async function nj(e,t,n,r){let i=await n(r);return i.data&&i.data.errors&&i.data.errors.length>0&&/Something went wrong while executing your query/.test(i.data.errors[0].message)?ej(e,t,new fD(i.data.errors[0].message,500,{request:r,response:i}),r):i}function rj(e,t){let n=Object.assign({enabled:!0,retryAfterBaseValue:1e3,doNotRetry:[400,401,403,404,410,422,451],retries:3},t.retry),r={retry:{retryRequest:(e,t,n)=>(e.request.request=Object.assign({},e.request.request,{retries:t,retryAfter:n}),e)}};return n.enabled&&(e.hook.error(`request`,ej.bind(null,n,r)),e.hook.wrap(`request`,tj.bind(null,n,r))),r}rj.VERSION=QA;const ij=dO(PA,void 0,rj);async function aj(e){let t=null;return t=pA===`alpine`?await Sr(`apk`,[`search`,`--exact`,e]):await Sr(`sudo`,[`apt-cache`,`search`,`--names-only`,`'^${e}$'`]),t.stdout.length>0}async function oj(e){switch(fA){case`linux`:{let t=[];for(let n of e)await aj(n)&&t.push(n);return t}default:return[]}}async function sj(){let e=!1;try{await le.access(`/.dockerenv`,le.constants.R_OK),e=!0}catch{e=!1}return hA===`self-hosted`||e}async function cj(){try{await xr(`sudo`,[`debconf-communicate`],{input:Buffer.from(`set man-db/auto-update false`)})}catch(e){e instanceof Error&&Pr(e.message)}try{await xr(`sudo`,[`dpkg-reconfigure`,`man-db`])}catch(e){e instanceof Error&&Pr(e.message)}}async function lj(){if(!await sj())switch(fA){case`linux`:await cj(),await xr(`sudo`,[`apt-get`,`--yes`,`install`,`bubblewrap`,`musl-tools`,`rsync`,...await oj([`darcs`,`g++-multilib`,`gcc-multilib`,`mercurial`])]);break;case`macos`:await xr(`brew`,[`install`,`darcs`,`mercurial`]);break}}async function uj(){let e=[`make`,`tar`,`unzip`,`rsync`];MA===`mingw`&&e.push(`mingw-w64-x86_64-gcc`),await xr(I.join(_A,`usr`,`bin`,`pacman.exe`),[`-S`,`--noconfirm`,`--needed`,...e])}async function dj(){if(!await sj())switch(fA){case`linux`:await xr(`sudo`,[`apt-get`,`update`]);break;case`macos`:await xr(`brew`,[`update`])}}const fj=(async()=>{let e=NA?`*`:`>=2.5.0 < 2.5.1`,{data:t}=await ij.rest.repos.listReleases({owner:`ocaml`,repo:`opam`}),n=t.filter(t=>oa.satisfies(t.tag_name,e,{includePrerelease:NA,loose:!0})).sort(({tag_name:e},{tag_name:t})=>oa.rcompare(e,t,{loose:!0}));if(n.length===0)throw Error(`Failed to find any opam release that matches the specified version constraint. Please check your version requirements or consider allowing pre-releases.`);let r=fA===`windows`?`${dA}-${fA}.exe`:`${dA}-${fA}`;for(let e of n){let t=e.assets.find(e=>e.name.endsWith(r));if(t)return{version:e.tag_name,browserDownloadUrl:t.browser_download_url}}throw Error(`Failed to find opam binary for '${fA}' and '${dA}'. Please check if this combination is supported by opam.`)})();async function pj(){await Lr(`Installing opam`,async()=>{let{version:e,browserDownloadUrl:t}=await fj,n=HA(`opam`,e,dA),r=fA===`windows`?`opam.exe`:`opam`;if(n===``){let n=await zA(t);Pr(`Downloaded opam ${e} from ${t}`);let i=await VA(n,r,`opam`,e,dA);Pr(`Successfully cached opam to ${i}`),await ee.chmod(I.join(i,r),493),Dr(i),Pr(`Added opam to the path`)}else Dr(n),Pr(`Added cached opam to the path`)})}async function mj(){await Lr(`Initialising opam state`,async()=>{if(fA===`windows`&&jA===`msys2`&&await uj(),fA!==`windows`)try{await lj()}catch(e){e instanceof Error&&Nr(`System package installation failed. Re-synchronizing package index files and retrying installation. Error details: ${e.message.toLocaleLowerCase()}`),await dj(),await lj()}let e=[];fA===`windows`&&(jA===`msys2`&&e.push(`--cygwin-location=${_A}`),jA===`cygwin`&&(e.push(`--cygwin-internal-install`),e.push(`--cygwin-extra-packages=${mA.join(`,`)}`))),OA&&e.push(`--disable-sandboxing`),await xr(`opam`,[`init`,`--auto-setup`,`--bare`,...e,`--enable-shell-hook`])})}async function hj(){await pj(),await mj()}async function gj(e){await Lr(`Installing OCaml compiler`,async()=>{let t=[e];fA===`windows`&&MA===`msvc`&&t.push(`system-msvc`),await xr(`opam`,[`switch`,`--no-install`,`--packages=${t.join(`,`)}`,`create`,`.`])})}async function _j(e){e.length!==0&&await Lr(`Pinning local packages`,async()=>{for(let t of e){let e=I.basename(t,`.opam`),n=I.dirname(t);await xr(`opam`,[`pin`,`--no-action`,`add`,`${e}.dev`,`.`],{cwd:n})}})}async function vj(e,t){await xr(`opam`,[`repository`,`--all-switches`,`--set-default`,`add`,e,t])}async function yj(e){await Lr(`Initialising opam repositories`,async()=>{for(let[t,n]of e)await vj(t,n)})}async function bj(e){await xr(`opam`,[`repository`,`--all-switches`,`remove`,e])}async function xj(){let e=await Sr(`opam`,[`repository`,`--all-switches`,`--short`,`list`],{ignoreReturnCode:!0,silent:!0});return e.exitCode===0?e.stdout.split(` -`).map(e=>e.trim()).filter(e=>e.length>0):[]}async function Sj(){await Lr(`Removing opam repositories`,async()=>{let e=await xj();for(let t of e)await bj(t)})}async function Cj(){try{await Lr(`Updating opam repositories`,async()=>{await xr(`opam`,[`update`])})}catch(e){e instanceof Error&&Nr(`Failed to update opam. Error details: ${e.message.toLocaleLowerCase()}`)}}function wj(e){return oa.validRange(e,{loose:!0})!==null}function Tj(e){let t=I.basename(e).replace(`ocaml-base-compiler.`,``),n=oa.parse(t.replace(`~`,`-`),{loose:!0});if(n===null)return;let r=n.major<5&&n.minor<10?`0${n.minor}`:n.minor,i=n.prerelease.length>0?`-${n.prerelease.join(`.`)}`:``;return[`${n.major}.${r}.${n.patch}${i}`,t]}async function Ej(){let{data:e}=await ij.rest.repos.getContent({owner:`ocaml`,repo:`opam-repository`,path:`packages/ocaml-base-compiler`});return Array.isArray(e)?new Map(e.values().map(({path:e})=>Tj(e)).filter(e=>e!==void 0)):new Map}async function Dj(e){let t=await Ej(),n=t.keys().toArray(),r=oa.maxSatisfying(n,e,{loose:!0});if(r!==null){let e=t.get(r);if(e!==void 0)return e}let i=oa.maxSatisfying(n,e,{loose:!0,includePrerelease:!0});if(i!==null){let e=t.get(i);if(e!==void 0)return e}throw Error(`Could not find any OCaml compiler version matching '${e}' in the opam-repository. Please check if you specified a valid version number or version range.`)}const Oj=(async()=>{let e=CA.replace(`~`,`-`);return wj(e)?`ocaml-base-compiler.${await Dj(e)}`:CA})();async function kj(){let{workflow:e,job:t,runId:n}=uO,r=[await Oj,e,t].join(),i=O.createHash(`sha256`).update(r).digest(`hex`),a=`${AA}-setup-ocaml-dune-${fA}-${dA}-${i}-${n}`,o=[a,`${AA}-setup-ocaml-dune-${fA}-${dA}-${i}-`,`${AA}-setup-ocaml-dune-${fA}-${dA}-`];return H(`dune cache key: ${r}`),{key:a,restoreKeys:o}}async function Aj(){let{stdout:e}=await Sr(`vswhere`,[`-latest`,`-property`,`installationVersion`],{silent:!0});return e.trim()}async function jj(){let{version:e}=await fj,t=OA?`nosandbox`:`sandbox`,n=await Oj,r=TA.map(([e,t])=>t).join(),i=[fA,(await lA.osInfo()).release,dA,e,n,r,t];if(fA===`windows`&&(i.push(jA),i.push(MA),MA===`msvc`)){let e=await Aj();i.push(e)}i.push(`v2`);let a=i.join(),o=`${AA}-setup-ocaml-opam-${O.createHash(`sha256`).update(a).digest(`hex`)}`,s=[o];return H(`opam cache key: ${a}`),{key:o,restoreKeys:s}}function Mj(){return[SA]}function Nj(){let e=[vA,I.join(gA,`_opam`)];if(fA===`windows`){let{repo:{repo:t}}=uO;if(jA===`msys2`){let n=I.posix.join(`/d`,`a`,t,t,`_opam`);e.push(n)}if(jA===`cygwin`){let n=I.posix.join(`/cygdrive`,`d`,`a`,t,t,`_opam`);e.push(n)}}return e}async function Pj(e,t,n,r){if(!QT()){Pr(`Actions cache service feature is unavailable`);return}try{let i=await(0,cA.backOff)(async()=>await $T(n,e,t,{useAzureSdk:!0,...r}),{numOfAttempts:5});return Pr(i?`Cache restored from key: ${i}`:`Cache is not found for input keys: ${[e,...t].join(`, `)}`),i}catch(e){e instanceof Error&&Pr(e.message),Nr(`An internal error has occurred in cache backend. Please check https://www.githubstatus.com for any ongoing issue in actions.`);return}}async function Fj(e,t){if(!QT()){Pr(`Actions cache service feature is unavailable`);return}try{await(0,cA.backOff)(async()=>await nE(t,e,{useAzureSdk:!0}),{numOfAttempts:5})}catch(e){e instanceof Error&&Pr(e.message),Nr(`An internal error has occurred in cache backend. Please check https://www.githubstatus.com for any ongoing issue in actions.`)}}async function Ij(){return await Lr(`Restoring dune cache`,async()=>{let{key:e,restoreKeys:t}=await kj();return await Pj(e,t,Mj())})}async function Lj(){return await Lr(`Restoring opam cache`,async()=>{let{key:e,restoreKeys:t}=await jj();return await Pj(e,t,Nj())})}async function Rj(){await Lr(`Saving dune cache`,async()=>{let{key:e}=await kj();await Fj(e,Mj())})}async function zj(){await Lr(`Saving opam cache`,async()=>{let{key:e,restoreKeys:t}=await jj(),n=Nj();await Pj(e,t,n,{lookupOnly:!0})?Pr(`Cache entry with the same key, version, and scope already exists`):(await xr(`opam`,[`clean`,`--all-switches`,`--download-cache`,`--logs`,`--repo-cache`,`--untracked`,`--unused-repositories`]),await Fj(e,n))})}async function Bj(){await Lr(`Installing dune`,async()=>{await xr(`opam`,[`install`,`dune`])})}async function Vj(){await Lr(`Clearing old dune cache files to save space`,async()=>{let{repo:{owner:e,repo:t},runId:n}=uO,{data:{total_count:r}}=await ij.rest.actions.listJobsForWorkflowRun({owner:e,repo:t,run_id:n});await xr(`opam`,[`exec`,`--`,`dune`,`cache`,`trim`,`--size=${Math.floor(5e3/r)}MB`])})}export{Ar as A,wA as C,jr as D,H as E,Tr as O,fA as S,Dr as T,SA as _,Rj as a,TA as b,gj as c,Sj as d,hj as f,kA as g,bA as h,Lj as i,xr as j,Lr as k,_j as l,xA as m,Vj as n,zj as o,Cj as p,Ij as r,Oj as s,Bj as t,yj as u,DA as v,jA as w,vA as x,EA as y}; \ No newline at end of file +`).map(e=>e.trim()).filter(e=>e.length>0):[]}async function Sj(){await Lr(`Removing opam repositories`,async()=>{let e=await xj();for(let t of e)await bj(t)})}async function Cj(){try{await Lr(`Updating opam repositories`,async()=>{await xr(`opam`,[`update`])})}catch(e){e instanceof Error&&Nr(`Failed to update opam. Error details: ${e.message.toLocaleLowerCase()}`)}}function wj(e){return oa.validRange(e,{loose:!0})!==null}function Tj(e){let t=I.basename(e).replace(`ocaml-base-compiler.`,``),n=oa.parse(t.replace(`~`,`-`),{loose:!0});if(n===null)return;let r=n.major<5&&n.minor<10?`0${n.minor}`:n.minor,i=n.prerelease.length>0?`-${n.prerelease.join(`.`)}`:``;return[`${n.major}.${r}.${n.patch}${i}`,t]}async function Ej(){let{data:e}=await ij.rest.repos.getContent({owner:`ocaml`,repo:`opam-repository`,path:`packages/ocaml-base-compiler`});return Array.isArray(e)?new Map(e.values().map(({path:e})=>Tj(e)).filter(e=>e!==void 0)):new Map}async function Dj(e){let t=await Ej(),n=t.keys().toArray(),r=oa.maxSatisfying(n,e,{loose:!0});if(r!==null){let e=t.get(r);if(e!==void 0)return e}let i=oa.maxSatisfying(n,e,{loose:!0,includePrerelease:!0});if(i!==null){let e=t.get(i);if(e!==void 0)return e}throw Error(`Could not find any OCaml compiler version matching '${e}' in the opam-repository. Please check if you specified a valid version number or version range.`)}const Oj=(async()=>{let e=CA.replace(`~`,`-`);return wj(e)?`ocaml-base-compiler.${await Dj(e)}`:CA})();async function kj(){let{workflow:e,job:t,runId:n}=uO,r=[await Oj,e,t].join(),i=O.createHash(`sha256`).update(r).digest(`hex`),a=`${AA}-setup-ocaml-dune-${fA}-${dA}-${i}-${n}`,o=[a,`${AA}-setup-ocaml-dune-${fA}-${dA}-${i}-`,`${AA}-setup-ocaml-dune-${fA}-${dA}-`];return H(`dune cache key: ${r}`),{key:a,restoreKeys:o}}async function Aj(){let{stdout:e}=await Sr(`vswhere`,[`-latest`,`-property`,`installationVersion`],{silent:!0});return e.trim()}async function jj(){let{version:e}=await fj,t=OA?`nosandbox`:`sandbox`,n=await Oj,r=TA.map(([e,t])=>t).join(),i=[fA,(await lA.osInfo()).release,dA,e,n,r,t];if(fA===`windows`&&(i.push(jA),i.push(MA),MA===`msvc`)){let e=await Aj();i.push(e)}i.push(`v2`);let a=i.join(),o=`${AA}-setup-ocaml-opam-${O.createHash(`sha256`).update(a).digest(`hex`)}`,s=[o];return H(`opam cache key: ${a}`),{key:o,restoreKeys:s}}function Mj(){return[SA]}function Nj(){let e=[vA,I.join(gA,`_opam`)];if(fA===`windows`){let{repo:{repo:t}}=uO;if(jA===`msys2`){let n=I.posix.join(`/d`,`a`,t,t,`_opam`);e.push(n)}if(jA===`cygwin`){let n=I.posix.join(`/cygdrive`,`d`,`a`,t,t,`_opam`);e.push(n)}}return e}async function Pj(e,t,n,r){if(!QT()){Pr(`Actions cache service feature is unavailable`);return}try{let i=await(0,cA.backOff)(async()=>await $T(n,e,t,{useAzureSdk:!0,...r}),{numOfAttempts:5});return Pr(i?`Cache restored from key: ${i}`:`Cache is not found for input keys: ${[e,...t].join(`, `)}`),i}catch(e){e instanceof Error&&Pr(e.message),Nr(`An internal error has occurred in cache backend. Please check https://www.githubstatus.com for any ongoing issue in actions.`);return}}async function Fj(e,t){if(!QT()){Pr(`Actions cache service feature is unavailable`);return}try{await(0,cA.backOff)(async()=>await nE(t,e,{useAzureSdk:!0}),{numOfAttempts:5})}catch(e){e instanceof Error&&Pr(e.message),Nr(`An internal error has occurred in cache backend. Please check https://www.githubstatus.com for any ongoing issue in actions.`)}}async function Ij(){return await Lr(`Restoring dune cache`,async()=>{let{key:e,restoreKeys:t}=await kj();return await Pj(e,t,Mj())})}async function Lj(){return await Lr(`Restoring opam cache`,async()=>{let{key:e,restoreKeys:t}=await jj();return await Pj(e,t,Nj())})}async function Rj(){await Lr(`Saving dune cache`,async()=>{let{key:e}=await kj();await Fj(e,Mj())})}async function zj(){await Lr(`Saving opam cache`,async()=>{let{key:e,restoreKeys:t}=await jj(),n=Nj();await Pj(e,t,n,{lookupOnly:!0})?Pr(`Cache entry with the same key, version, and scope already exists`):(await xr(`opam`,[`clean`,`--all-switches`,`--download-cache`,`--logs`,`--repo-cache`,`--untracked`,`--unused-repositories`]),await Fj(e,n))})}export{Dr as C,Lr as D,Tr as E,Ar as O,jA as S,jr as T,EA as _,Oj as a,fA as b,yj as c,Cj as d,xA as f,DA as g,SA as h,zj as i,xr as k,Sj as l,kA as m,Lj as n,gj as o,bA as p,Rj as r,_j as s,Ij as t,hj as u,TA as v,H as w,wA as x,vA as y}; \ No newline at end of file diff --git a/dist/index.mjs b/dist/index.mjs index 21075cfe..445447e9 100644 --- a/dist/index.mjs +++ b/dist/index.mjs @@ -1,4 +1,4 @@ -import{A as e,C as t,D as n,E as r,O as i,S as a,T as o,_ as s,b as c,c as l,d as u,f as d,g as f,h as p,i as m,j as h,k as ee,l as te,m as ne,o as re,p as ie,r as ae,s as oe,t as se,u as ce,v as le,w as ue,x as de,y as fe}from"./dune.mjs";import*as g from"node:process";import*as pe from"os";import*as _ from"fs";import*as v from"path";import y from"assert";import{promises as me}from"node:fs";import*as he from"node:os";function ge(e){let t={followSymbolicLinks:!0,implicitDescendants:!0,matchDirectories:!0,omitBrokenSymbolicLinks:!0,excludeHiddenFiles:!1};return e&&(typeof e.followSymbolicLinks==`boolean`&&(t.followSymbolicLinks=e.followSymbolicLinks,r(`followSymbolicLinks '${t.followSymbolicLinks}'`)),typeof e.implicitDescendants==`boolean`&&(t.implicitDescendants=e.implicitDescendants,r(`implicitDescendants '${t.implicitDescendants}'`)),typeof e.matchDirectories==`boolean`&&(t.matchDirectories=e.matchDirectories,r(`matchDirectories '${t.matchDirectories}'`)),typeof e.omitBrokenSymbolicLinks==`boolean`&&(t.omitBrokenSymbolicLinks=e.omitBrokenSymbolicLinks,r(`omitBrokenSymbolicLinks '${t.omitBrokenSymbolicLinks}'`)),typeof e.excludeHiddenFiles==`boolean`&&(t.excludeHiddenFiles=e.excludeHiddenFiles,r(`excludeHiddenFiles '${t.excludeHiddenFiles}'`))),t}const b=process.platform===`win32`;function x(e){if(e=E(e),b&&/^\\\\[^\\]+(\\[^\\]+)?$/.test(e))return e;let t=v.dirname(e);return b&&/^\\\\[^\\]+\\[^\\]+\\$/.test(t)&&(t=E(t)),t}function S(e,t){if(y(e,`ensureAbsoluteRoot parameter 'root' must not be empty`),y(t,`ensureAbsoluteRoot parameter 'itemPath' must not be empty`),C(t))return t;if(b){if(t.match(/^[A-Z]:[^\\/]|^[A-Z]:$/i)){let e=process.cwd();return y(e.match(/^[A-Z]:\\/i),`Expected current directory to start with an absolute drive root. Actual '${e}'`),t[0].toUpperCase()===e[0].toUpperCase()?t.length===2?`${t[0]}:\\${e.substr(3)}`:(e.endsWith(`\\`)||(e+=`\\`),`${t[0]}:\\${e.substr(3)}${t.substr(2)}`):`${t[0]}:\\${t.substr(2)}`}else if(T(t).match(/^\\$|^\\[^\\]/)){let e=process.cwd();return y(e.match(/^[A-Z]:\\/i),`Expected current directory to start with an absolute drive root. Actual '${e}'`),`${e[0]}:\\${t.substr(1)}`}}return y(C(e),`ensureAbsoluteRoot parameter 'root' must have an absolute root`),e.endsWith(`/`)||b&&e.endsWith(`\\`)||(e+=v.sep),e+t}function C(e){return y(e,`hasAbsoluteRoot parameter 'itemPath' must not be empty`),e=T(e),b?e.startsWith(`\\\\`)||/^[A-Z]:\\/i.test(e):e.startsWith(`/`)}function w(e){return y(e,`isRooted parameter 'itemPath' must not be empty`),e=T(e),b?e.startsWith(`\\`)||/^[A-Z]:/i.test(e):e.startsWith(`/`)}function T(e){return e||=``,b?(e=e.replace(/\//g,`\\`),(/^\\\\+[^\\]/.test(e)?`\\`:``)+e.replace(/\\\\+/g,`\\`)):e.replace(/\/\/+/g,`/`)}function E(e){return e?(e=T(e),!e.endsWith(v.sep)||e===v.sep||b&&/^[A-Z]:\\$/i.test(e)?e:e.substr(0,e.length-1)):``}var D;(function(e){e[e.None=0]=`None`,e[e.Directory=1]=`Directory`,e[e.File=2]=`File`,e[e.All=3]=`All`})(D||={});const _e=process.platform===`win32`;function O(e){e=e.filter(e=>!e.negate);let t={};for(let n of e){let e=_e?n.searchPath.toUpperCase():n.searchPath;t[e]=`candidate`}let n=[];for(let r of e){let e=_e?r.searchPath.toUpperCase():r.searchPath;if(t[e]===`included`)continue;let i=!1,a=e,o=x(a);for(;o!==a;){if(t[o]){i=!0;break}a=o,o=x(a)}i||(n.push(r.searchPath),t[e]=`included`)}return n}function ve(e,t){let n=D.None;for(let r of e)r.negate?n&=~r.match(t):n|=r.match(t);return n}function ye(e,t){return e.some(e=>!e.negate&&e.partialMatch(t))}const k=(e,t,n)=>{let r=e instanceof RegExp?A(e,n):e,i=t instanceof RegExp?A(t,n):t,a=r!==null&&i!=null&&be(r,i,n);return a&&{start:a[0],end:a[1],pre:n.slice(0,a[0]),body:n.slice(a[0]+r.length,a[1]),post:n.slice(a[1]+i.length)}},A=(e,t)=>{let n=t.match(e);return n?n[0]:null},be=(e,t,n)=>{let r,i,a,o,s,c=n.indexOf(e),l=n.indexOf(t,c+1),u=c;if(c>=0&&l>0){if(e===t)return[c,l];for(r=[],a=n.length;u>=0&&!s;){if(u===c)r.push(u),c=n.indexOf(e,u+1);else if(r.length===1){let e=r.pop();e!==void 0&&(s=[e,l])}else i=r.pop(),i!==void 0&&i=0?c:l}r.length&&o!==void 0&&(s=[a,o])}return s},j=`\0SLASH`+Math.random()+`\0`,M=`\0OPEN`+Math.random()+`\0`,N=`\0CLOSE`+Math.random()+`\0`,P=`\0COMMA`+Math.random()+`\0`,F=`\0PERIOD`+Math.random()+`\0`,xe=new RegExp(j,`g`),Se=new RegExp(M,`g`),Ce=new RegExp(N,`g`),we=new RegExp(P,`g`),Te=new RegExp(F,`g`),Ee=/\\\\/g,De=/\\{/g,Oe=/\\}/g,ke=/\\,/g,Ae=/\\\./g;function I(e){return isNaN(e)?e.charCodeAt(0):parseInt(e,10)}function je(e){return e.replace(Ee,j).replace(De,M).replace(Oe,N).replace(ke,P).replace(Ae,F)}function Me(e){return e.replace(xe,`\\`).replace(Se,`{`).replace(Ce,`}`).replace(we,`,`).replace(Te,`.`)}function Ne(e){if(!e)return[``];let t=[],n=k(`{`,`}`,e);if(!n)return e.split(`,`);let{pre:r,body:i,post:a}=n,o=r.split(`,`);o[o.length-1]+=`{`+i+`}`;let s=Ne(a);return a.length&&(o[o.length-1]+=s.shift(),o.push.apply(o,s)),t.push.apply(t,o),t}function Pe(e,t={}){if(!e)return[];let{max:n=1e5}=t;return e.slice(0,2)===`{}`&&(e=`\\{\\}`+e.slice(2)),L(je(e),n,!0).map(Me)}function Fe(e){return`{`+e+`}`}function Ie(e){return/^-?0\d/.test(e)}function Le(e,t){return e<=t}function Re(e,t){return e>=t}function L(e,t,n){let r=[],i=k(`{`,`}`,e);if(!i)return[e];let a=i.pre,o=i.post.length?L(i.post,t,!1):[``];if(/\$$/.test(i.pre))for(let e=0;e=0;if(!l&&!u)return i.post.match(/,(?!,).*\}/)?(e=i.pre+`{`+i.body+N+i.post,L(e,t,!0)):[e];let d;if(l)d=i.body.split(/\.\./);else if(d=Ne(i.body),d.length===1&&d[0]!==void 0&&(d=L(d[0],t,!1).map(Fe),d.length===1))return o.map(e=>i.pre+d[0]+e);let f;if(l&&d[0]!==void 0&&d[1]!==void 0){let e=I(d[0]),n=I(d[1]),r=Math.max(d[0].length,d[1].length),i=d.length===3&&d[2]!==void 0?Math.max(Math.abs(I(d[2])),1):1,a=Le;n0){let n=Array(t+1).join(`0`);e=s<0?`-`+n+e.slice(1):n+e}}f.push(e)}}else{f=[];for(let e=0;e{if(typeof e!=`string`)throw TypeError(`invalid pattern`);if(e.length>65536)throw TypeError(`pattern is too long`)},ze={"[:alnum:]":[`\\p{L}\\p{Nl}\\p{Nd}`,!0],"[:alpha:]":[`\\p{L}\\p{Nl}`,!0],"[:ascii:]":[`\\x00-\\x7f`,!1],"[:blank:]":[`\\p{Zs}\\t`,!0],"[:cntrl:]":[`\\p{Cc}`,!0],"[:digit:]":[`\\p{Nd}`,!0],"[:graph:]":[`\\p{Z}\\p{C}`,!0,!0],"[:lower:]":[`\\p{Ll}`,!0],"[:print:]":[`\\p{C}`,!0],"[:punct:]":[`\\p{P}`,!0],"[:space:]":[`\\p{Z}\\t\\r\\n\\v\\f`,!0],"[:upper:]":[`\\p{Lu}`,!0],"[:word:]":[`\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}`,!0],"[:xdigit:]":[`A-Fa-f0-9`,!1]},z=e=>e.replace(/[[\]\\-]/g,`\\$&`),Be=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,`\\$&`),Ve=e=>e.join(``),He=(e,t)=>{let n=t;if(e.charAt(n)!==`[`)throw Error(`not in a brace expression`);let r=[],i=[],a=n+1,o=!1,s=!1,c=!1,l=!1,u=n,d=``;WHILE:for(;ad?r.push(z(d)+`-`+z(t)):t===d&&r.push(z(t)),d=``,a++;continue}if(e.startsWith(`-]`,a+1)){r.push(z(t+`-`)),a+=2;continue}if(e.startsWith(`-`,a+1)){d=t,a+=2;continue}r.push(z(t)),a++}if(un?t?e.replace(/\[([^/\\])\]/g,`$1`):e.replace(/((?!\\).|^)\[([^/\\])\]/g,`$1$2`).replace(/\\([^/])/g,`$1`):t?e.replace(/\[([^/\\{}])\]/g,`$1`):e.replace(/((?!\\).|^)\[([^/\\{}])\]/g,`$1$2`).replace(/\\([^/{}])/g,`$1`);var V;const Ue=new Set([`!`,`?`,`+`,`*`,`@`]),H=e=>Ue.has(e),We=e=>H(e.type),Ge=new Map([[`!`,[`@`]],[`?`,[`?`,`@`]],[`@`,[`@`]],[`*`,[`*`,`+`,`?`,`@`]],[`+`,[`+`,`@`]]]),Ke=new Map([[`!`,[`?`]],[`@`,[`?`]],[`+`,[`?`,`*`]]]),qe=new Map([[`!`,[`?`,`@`]],[`?`,[`?`,`@`]],[`@`,[`?`,`@`]],[`*`,[`*`,`+`,`?`,`@`]],[`+`,[`+`,`@`,`?`,`*`]]]),Je=new Map([[`!`,new Map([[`!`,`@`]])],[`?`,new Map([[`*`,`*`],[`+`,`*`]])],[`@`,new Map([[`!`,`!`],[`?`,`?`],[`@`,`@`],[`*`,`*`],[`+`,`+`]])],[`+`,new Map([[`?`,`*`],[`*`,`*`]])]]),U=`(?!\\.)`,Ye=new Set([`[`,`.`]),Xe=new Set([`..`,`.`]),Ze=new Set(`().*{}+?[]^$\\!`),Qe=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,`\\$&`),$e=`[^/]+?`;let et=0;var W=class{type;#e;#t;#n=!1;#r=[];#i;#a;#o;#s=!1;#c;#l;#u=!1;id=++et;get depth(){return(this.#i?.depth??-1)+1}[Symbol.for(`nodejs.util.inspect.custom`)](){return{"@@type":`AST`,id:this.id,type:this.type,root:this.#e.id,parent:this.#i?.id,depth:this.depth,partsLength:this.#r.length,parts:this.#r}}constructor(e,t,n={}){this.type=e,e&&(this.#t=!0),this.#i=t,this.#e=this.#i?this.#i.#e:this,this.#c=this.#e===this?n:this.#e.#c,this.#o=this.#e===this?[]:this.#e.#o,e===`!`&&!this.#e.#s&&this.#o.push(this),this.#a=this.#i?this.#i.#r.length:0}get hasMagic(){if(this.#t!==void 0)return this.#t;for(let e of this.#r)if(typeof e!=`string`&&(e.type||e.hasMagic))return this.#t=!0;return this.#t}toString(){return this.#l===void 0?this.type?this.#l=this.type+`(`+this.#r.map(e=>String(e)).join(`|`)+`)`:this.#l=this.#r.map(e=>String(e)).join(``):this.#l}#d(){if(this!==this.#e)throw Error(`should only call on root`);if(this.#s)return this;this.toString(),this.#s=!0;let e;for(;e=this.#o.pop();){if(e.type!==`!`)continue;let t=e,n=t.#i;for(;n;){for(let r=t.#a+1;!n.type&&rtypeof e==`string`?e:e.toJSON()):[this.type,...this.#r.map(e=>e.toJSON())];return this.isStart()&&!this.type&&e.unshift([]),this.isEnd()&&(this===this.#e||this.#e.#s&&this.#i?.type===`!`)&&e.push({}),e}isStart(){if(this.#e===this)return!0;if(!this.#i?.isStart())return!1;if(this.#a===0)return!0;let e=this.#i;for(let t=0;ttypeof e!=`string`),r=this.#r.map(t=>{let[r,i,a,o]=typeof t==`string`?V.#C(t,this.#t,n):t.toRegExpSource(e);return this.#t=this.#t||a,this.#n=this.#n||o,r}).join(``),i=``;if(this.isStart()&&typeof this.#r[0]==`string`&&!(this.#r.length===1&&Xe.has(this.#r[0]))){let n=Ye,a=t&&n.has(r.charAt(0))||r.startsWith(`\\.`)&&n.has(r.charAt(2))||r.startsWith(`\\.\\.`)&&n.has(r.charAt(4)),o=!t&&!e&&n.has(r.charAt(0));i=a?`(?!(?:^|/)\\.\\.?(?:$|/))`:o?U:``}let a=``;return this.isEnd()&&this.#e.#s&&this.#i?.type===`!`&&(a=`(?:$|\\/)`),[i+r+a,B(r),this.#t=!!this.#t,this.#n]}let n=this.type===`*`||this.type===`+`,r=this.type===`!`?`(?:(?!(?:`:`(?:`,i=this.#S(t);if(this.isStart()&&this.isEnd()&&!i&&this.type!==`!`){let e=this.toString(),t=this;return t.#r=[e],t.type=null,t.#t=void 0,[e,B(this.toString()),!1,!1]}let a=!n||e||t?``:this.#S(!0);a===i&&(a=``),a&&(i=`(?:${i})(?:${a})*?`);let o=``;if(this.type===`!`&&this.#u)o=(this.isStart()&&!t?U:``)+$e;else{let n=this.type===`!`?`))`+(this.isStart()&&!t&&!e?U:``)+`[^/]*?)`:this.type===`@`?`)`:this.type===`?`?`)?`:this.type===`+`&&a?`)`:this.type===`*`&&a?`)?`:`)${this.type}`;o=r+i+n}return[o,B(i),this.#t=!!this.#t,this.#n]}#x(){if(We(this)){let e=0,t=!1;do{t=!0;for(let e=0;e{if(typeof t==`string`)throw Error(`string type in extglob ast??`);let[n,r,i,a]=t.toRegExpSource(e);return this.#n=this.#n||a,n}).filter(e=>!(this.isStart()&&this.isEnd())||!!e).join(`|`)}static#C(e,t,n=!1){let r=!1,i=``,a=!1,o=!1;for(let s=0;sn?t?e.replace(/[?*()[\]{}]/g,`[$&]`):e.replace(/[?*()[\]\\{}]/g,`\\$&`):t?e.replace(/[?*()[\]]/g,`[$&]`):e.replace(/[?*()[\]\\]/g,`\\$&`),G=(e,t,n={})=>(R(t),!n.nocomment&&t.charAt(0)===`#`?!1:new Y(t,n).match(e)),nt=/^\*+([^+@!?*[(]*)$/,rt=e=>t=>!t.startsWith(`.`)&&t.endsWith(e),it=e=>t=>t.endsWith(e),at=e=>(e=e.toLowerCase(),t=>!t.startsWith(`.`)&&t.toLowerCase().endsWith(e)),ot=e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),st=/^\*+\.\*+$/,ct=e=>!e.startsWith(`.`)&&e.includes(`.`),lt=e=>e!==`.`&&e!==`..`&&e.includes(`.`),ut=/^\.\*+$/,dt=e=>e!==`.`&&e!==`..`&&e.startsWith(`.`),ft=/^\*+$/,pt=e=>e.length!==0&&!e.startsWith(`.`),mt=e=>e.length!==0&&e!==`.`&&e!==`..`,ht=/^\?+([^+@!?*[(]*)?$/,gt=([e,t=``])=>{let n=bt([e]);return t?(t=t.toLowerCase(),e=>n(e)&&e.toLowerCase().endsWith(t)):n},_t=([e,t=``])=>{let n=xt([e]);return t?(t=t.toLowerCase(),e=>n(e)&&e.toLowerCase().endsWith(t)):n},vt=([e,t=``])=>{let n=xt([e]);return t?e=>n(e)&&e.endsWith(t):n},yt=([e,t=``])=>{let n=bt([e]);return t?e=>n(e)&&e.endsWith(t):n},bt=([e])=>{let t=e.length;return e=>e.length===t&&!e.startsWith(`.`)},xt=([e])=>{let t=e.length;return e=>e.length===t&&e!==`.`&&e!==`..`},St=typeof process==`object`&&process?typeof process.env==`object`&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:`posix`,Ct={win32:{sep:`\\`},posix:{sep:`/`}};G.sep=St===`win32`?Ct.win32.sep:Ct.posix.sep;const K=Symbol(`globstar **`);G.GLOBSTAR=K,G.filter=(e,t={})=>n=>G(n,e,t);const q=(e,t={})=>Object.assign({},e,t);G.defaults=e=>{if(!e||typeof e!=`object`||!Object.keys(e).length)return G;let t=G;return Object.assign((n,r,i={})=>t(n,r,q(e,i)),{Minimatch:class extends t.Minimatch{constructor(t,n={}){super(t,q(e,n))}static defaults(n){return t.defaults(q(e,n)).Minimatch}},AST:class extends t.AST{constructor(t,n,r={}){super(t,n,q(e,r))}static fromGlob(n,r={}){return t.AST.fromGlob(n,q(e,r))}},unescape:(n,r={})=>t.unescape(n,q(e,r)),escape:(n,r={})=>t.escape(n,q(e,r)),filter:(n,r={})=>t.filter(n,q(e,r)),defaults:n=>t.defaults(q(e,n)),makeRe:(n,r={})=>t.makeRe(n,q(e,r)),braceExpand:(n,r={})=>t.braceExpand(n,q(e,r)),match:(n,r,i={})=>t.match(n,r,q(e,i)),sep:t.sep,GLOBSTAR:K})};const J=(e,t={})=>(R(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:Pe(e,{max:t.braceExpandMax}));G.braceExpand=J,G.makeRe=(e,t={})=>new Y(e,t).makeRe(),G.match=(e,t,n={})=>{let r=new Y(t,n);return e=e.filter(e=>r.match(e)),r.options.nonull&&!e.length&&e.push(t),e};const wt=/[?*]|[+@!]\(.*?\)|\[|\]/,Tt=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,`\\$&`);var Y=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;maxGlobstarRecursion;regexp;constructor(e,t={}){R(e),t||={},this.options=t,this.maxGlobstarRecursion=t.maxGlobstarRecursion??200,this.pattern=e,this.platform=t.platform||St,this.isWindows=this.platform===`win32`,this.windowsPathsNoEscape=!!t.windowsPathsNoEscape||t.allowWindowsEscape===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,`/`)),this.preserveMultipleSlashes=!!t.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!t.nonegate,this.comment=!1,this.empty=!1,this.partial=!!t.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=t.windowsNoMagicRoot===void 0?!!(this.isWindows&&this.nocase):t.windowsNoMagicRoot,this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(let e of this.set)for(let t of e)if(typeof t!=`string`)return!0;return!1}debug(...e){}make(){let e=this.pattern,t=this.options;if(!t.nocomment&&e.charAt(0)===`#`){this.comment=!0;return}if(!e){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],t.debug&&(this.debug=(...e)=>console.error(...e)),this.debug(this.pattern,this.globSet);let n=this.globSet.map(e=>this.slashSplit(e));this.globParts=this.preprocess(n),this.debug(this.pattern,this.globParts);let r=this.globParts.map((e,t,n)=>{if(this.isWindows&&this.windowsNoMagicRoot){let t=e[0]===``&&e[1]===``&&(e[2]===`?`||!wt.test(e[2]))&&!wt.test(e[3]),n=/^[a-z]:/i.test(e[0]);if(t)return[...e.slice(0,4),...e.slice(4).map(e=>this.parse(e))];if(n)return[e[0],...e.slice(1).map(e=>this.parse(e))]}return e.map(e=>this.parse(e))});if(this.debug(this.pattern,r),this.set=r.filter(e=>e.indexOf(!1)===-1),this.isWindows)for(let e=0;e=2?(e=this.firstPhasePreProcess(e),e=this.secondPhasePreProcess(e)):e=t>=1?this.levelOneOptimize(e):this.adjascentGlobstarOptimize(e),e}adjascentGlobstarOptimize(e){return e.map(e=>{let t=-1;for(;(t=e.indexOf(`**`,t+1))!==-1;){let n=t;for(;e[n+1]===`**`;)n++;n!==t&&e.splice(t,n-t)}return e})}levelOneOptimize(e){return e.map(e=>(e=e.reduce((e,t)=>{let n=e[e.length-1];return t===`**`&&n===`**`?e:t===`..`&&n&&n!==`..`&&n!==`.`&&n!==`**`?(e.pop(),e):(e.push(t),e)},[]),e.length===0?[``]:e))}levelTwoFileOptimize(e){Array.isArray(e)||(e=this.slashSplit(e));let t=!1;do{if(t=!1,!this.preserveMultipleSlashes){for(let n=1;nr&&n.splice(r+1,i-r);let a=n[r+1],o=n[r+2],s=n[r+3];if(a!==`..`||!o||o===`.`||o===`..`||!s||s===`.`||s===`..`)continue;t=!0,n.splice(r,1);let c=n.slice(0);c[r]=`**`,e.push(c),r--}if(!this.preserveMultipleSlashes){for(let e=1;ee.length)}partsMatch(e,t,n=!1){let r=0,i=0,a=[],o=``;for(;r=2&&(e=this.levelTwoFileOptimize(e)),t.includes(K)?this.#e(e,t,n,r,i):this.#n(e,t,n,r,i)}#e(e,t,n,r,i){let a=t.indexOf(K,i),o=t.lastIndexOf(K),[s,c,l]=n?[t.slice(i,a),t.slice(a+1),[]]:[t.slice(i,a),t.slice(a+1,o),t.slice(o+1)];if(s.length){let t=e.slice(r,r+s.length);if(!this.#n(t,s,n,0,0))return!1;r+=s.length,i+=s.length}let u=0;if(l.length){if(l.length+r>e.length)return!1;let t=e.length-l.length;if(this.#n(e,l,n,t,0))u=l.length;else{if(e[e.length-1]!==``||r+l.length===e.length||(t--,!this.#n(e,l,n,t,0)))return!1;u=l.length+1}}if(!c.length){let t=!!u;for(let n=r;n{let t=e.map(e=>{if(e instanceof RegExp)for(let t of e.flags.split(``))r.add(t);return typeof e==`string`?Tt(e):e===K?K:e._src});t.forEach((e,r)=>{let i=t[r+1],a=t[r-1];e!==K||a===K||(a===void 0?i!==void 0&&i!==K?t[r+1]=`(?:\\/|`+n+`\\/)?`+i:t[r]=n:i===void 0?t[r-1]=a+`(?:\\/|\\/`+n+`)?`:i!==K&&(t[r-1]=a+`(?:\\/|\\/`+n+`\\/)`+i,t[r+1]=K))});let i=t.filter(e=>e!==K);if(this.partial&&i.length>=1){let e=[];for(let t=1;t<=i.length;t++)e.push(i.slice(0,t).join(`/`));return`(?:`+e.join(`|`)+`)`}return i.join(`/`)}).join(`|`),[a,o]=e.length>1?[`(?:`,`)`]:[``,``];i=`^`+a+i+o+`$`,this.partial&&(i=`^(?:\\/|`+a+i.slice(1,-1)+o+`)$`),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 n=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 a=r[r.length-1];if(!a)for(let e=r.length-2;!a&&e>=0;e--)a=r[e];for(let e of i){let i=r;if(n.matchBase&&e.length===1&&(i=[a]),this.matchOne(i,e,t))return n.flipNegate?!0:!this.negate}return n.flipNegate?!1:this.negate}static defaults(e){return G.defaults(e).Minimatch}};G.AST=W,G.Minimatch=Y,G.escape=tt,G.unescape=B;const Et=process.platform===`win32`;var X=class{constructor(e){if(this.segments=[],typeof e==`string`)if(y(e,`Parameter 'itemPath' must not be empty`),e=E(e),!w(e))this.segments=e.split(v.sep);else{let t=e,n=x(t);for(;n!==t;){let e=v.basename(t);this.segments.unshift(e),t=n,n=x(t)}this.segments.unshift(t)}else{y(e.length>0,`Parameter 'itemPath' must not be an empty array`);for(let t=0;te.getLiteral(t)).filter(e=>!o&&!(o=e===``));this.searchPath=new X(s).toString(),this.rootRegExp=new RegExp(e.regExpEscape(s[0]),Z?`i`:``),this.isImplicitPattern=n;let c={dot:!0,nobrace:!0,nocase:Z,nocomment:!0,noext:!0,nonegate:!0};a=Z?a.replace(/\\/g,`/`):a,this.minimatch=new Y(a,c)}match(e){return this.segments[this.segments.length-1]===`**`?(e=T(e),!e.endsWith(v.sep)&&this.isImplicitPattern===!1&&(e=`${e}${v.sep}`)):e=E(e),this.minimatch.match(e)?this.trailingSeparator?D.Directory:D.All:D.None}partialMatch(e){return e=E(e),x(e)===e?this.rootRegExp.test(e):this.minimatch.matchOne(e.split(Z?/\\+/:/\/+/),this.minimatch.set[0],!0)}static globEscape(e){return(Z?e:e.replace(/\\/g,`\\\\`)).replace(/(\[)(?=[^/]+\])/g,`[[]`).replace(/\?/g,`[?]`).replace(/\*/g,`[*]`)}static fixupPattern(t,n){y(t,`pattern cannot be empty`);let r=new X(t).segments.map(t=>e.getLiteral(t));if(y(r.every((e,t)=>(e!==`.`||t===0)&&e!==`..`),`Invalid pattern '${t}'. Relative pathing '.' and '..' is not allowed.`),y(!w(t)||r[0],`Invalid pattern '${t}'. Root segment must not contain globs.`),t=T(t),t===`.`||t.startsWith(`.${v.sep}`))t=e.globEscape(process.cwd())+t.substr(1);else if(t===`~`||t.startsWith(`~${v.sep}`))n||=pe.homedir(),y(n,`Unable to determine HOME directory`),y(C(n),`Expected HOME directory to be a rooted path. Actual '${n}'`),t=e.globEscape(n)+t.substr(1);else if(Z&&(t.match(/^[A-Z]:$/i)||t.match(/^[A-Z]:[^\\]/i))){let n=S(`C:\\dummy-root`,t.substr(0,2));t.length>2&&!n.endsWith(`\\`)&&(n+=`\\`),t=e.globEscape(n)+t.substr(2)}else if(Z&&(t===`\\`||t.match(/^\\[^\\]/))){let n=S(`C:\\dummy-root`,`\\`);n.endsWith(`\\`)||(n+=`\\`),t=e.globEscape(n)+t.substr(1)}else t=S(e.globEscape(process.cwd()),t);return T(t)}static getLiteral(e){let t=``;for(let n=0;n=0){if(r.length>1)return``;if(r){t+=r,n=i;continue}}}t+=r}return t}static regExpEscape(e){return e.replace(/[[\\^$.|?*+()]/g,`\\$&`)}},Ot=class{constructor(e,t){this.path=e,this.level=t}},Q=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},kt=function(e){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof __values==`function`?__values(e):e[Symbol.iterator](),n={},r(`next`),r(`throw`),r(`return`),n[Symbol.asyncIterator]=function(){return this},n);function r(t){n[t]=e[t]&&function(n){return new Promise(function(r,a){n=e[t](n),i(r,a,n.done,n.value)})}}function i(e,t,n,r){Promise.resolve(r).then(function(t){e({value:t,done:n})},t)}},$=function(e){return this instanceof $?(this.v=e,this):new $(e)},At=function(e,t,n){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var r=n.apply(e,t||[]),i,a=[];return i=Object.create((typeof AsyncIterator==`function`?AsyncIterator:Object).prototype),s(`next`),s(`throw`),s(`return`,o),i[Symbol.asyncIterator]=function(){return this},i;function o(e){return function(t){return Promise.resolve(t).then(e,d)}}function s(e,t){r[e]&&(i[e]=function(t){return new Promise(function(n,r){a.push([e,t,n,r])>1||c(e,t)})},t&&(i[e]=t(i[e])))}function c(e,t){try{l(r[e](t))}catch(e){f(a[0][3],e)}}function l(e){e.value instanceof $?Promise.resolve(e.value.v).then(u,d):f(a[0][2],e)}function u(e){c(`next`,e)}function d(e){c(`throw`,e)}function f(e,t){e(t),a.shift(),a.length&&c(a[0][0],a[0][1])}};const jt=process.platform===`win32`;var Mt=class e{constructor(e){this.patterns=[],this.searchPaths=[],this.options=ge(e)}getSearchPaths(){return this.searchPaths.slice()}glob(){return Q(this,void 0,void 0,function*(){var e,t,n,r;let i=[];try{for(var a=!0,o=kt(this.globGenerator()),s;s=yield o.next(),e=s.done,!e;a=!0){r=s.value,a=!1;let e=r;i.push(e)}}catch(e){t={error:e}}finally{try{!a&&!e&&(n=o.return)&&(yield n.call(o))}finally{if(t)throw t.error}}return i})}globGenerator(){return At(this,arguments,function*(){let t=ge(this.options),n=[];for(let e of this.patterns)n.push(e),t.implicitDescendants&&(e.trailingSeparator||e.segments[e.segments.length-1]!==`**`)&&n.push(new Dt(e.negate,!0,e.segments.concat(`**`)));let i=[];for(let e of O(n)){r(`Search path '${e}'`);try{yield $(_.promises.lstat(e))}catch(e){if(e.code===`ENOENT`)continue;throw e}i.unshift(new Ot(e,1))}let a=[];for(;i.length;){let r=i.pop(),o=ve(n,r.path),s=!!o||ye(n,r.path);if(!o&&!s)continue;let c=yield $(e.stat(r,t,a));if(c&&!(t.excludeHiddenFiles&&v.basename(r.path).match(/^\./)))if(c.isDirectory()){if(o&D.Directory&&t.matchDirectories)yield yield $(r.path);else if(!s)continue;let e=r.level+1,n=(yield $(_.promises.readdir(r.path))).map(t=>new Ot(v.join(r.path,t),e));i.push(...n.reverse())}else o&D.File&&(yield yield $(r.path))}})}static create(t,n){return Q(this,void 0,void 0,function*(){let r=new e(n);jt&&(t=t.replace(/\r\n/g,` +import{C as e,D as t,E as n,O as r,S as i,T as a,_ as o,a as s,b as c,c as l,d as u,f as d,g as f,h as p,i as m,k as h,l as ee,m as te,n as ne,o as re,p as ie,s as ae,t as oe,u as se,v as ce,w as g,x as le,y as ue}from"./cache.mjs";import*as _ from"node:process";import*as de from"os";import*as v from"fs";import*as y from"path";import b from"assert";import{promises as fe}from"node:fs";import*as pe from"node:os";function me(e){let t={followSymbolicLinks:!0,implicitDescendants:!0,matchDirectories:!0,omitBrokenSymbolicLinks:!0,excludeHiddenFiles:!1};return e&&(typeof e.followSymbolicLinks==`boolean`&&(t.followSymbolicLinks=e.followSymbolicLinks,g(`followSymbolicLinks '${t.followSymbolicLinks}'`)),typeof e.implicitDescendants==`boolean`&&(t.implicitDescendants=e.implicitDescendants,g(`implicitDescendants '${t.implicitDescendants}'`)),typeof e.matchDirectories==`boolean`&&(t.matchDirectories=e.matchDirectories,g(`matchDirectories '${t.matchDirectories}'`)),typeof e.omitBrokenSymbolicLinks==`boolean`&&(t.omitBrokenSymbolicLinks=e.omitBrokenSymbolicLinks,g(`omitBrokenSymbolicLinks '${t.omitBrokenSymbolicLinks}'`)),typeof e.excludeHiddenFiles==`boolean`&&(t.excludeHiddenFiles=e.excludeHiddenFiles,g(`excludeHiddenFiles '${t.excludeHiddenFiles}'`))),t}const x=process.platform===`win32`;function S(e){if(e=D(e),x&&/^\\\\[^\\]+(\\[^\\]+)?$/.test(e))return e;let t=y.dirname(e);return x&&/^\\\\[^\\]+\\[^\\]+\\$/.test(t)&&(t=D(t)),t}function C(e,t){if(b(e,`ensureAbsoluteRoot parameter 'root' must not be empty`),b(t,`ensureAbsoluteRoot parameter 'itemPath' must not be empty`),w(t))return t;if(x){if(t.match(/^[A-Z]:[^\\/]|^[A-Z]:$/i)){let e=process.cwd();return b(e.match(/^[A-Z]:\\/i),`Expected current directory to start with an absolute drive root. Actual '${e}'`),t[0].toUpperCase()===e[0].toUpperCase()?t.length===2?`${t[0]}:\\${e.substr(3)}`:(e.endsWith(`\\`)||(e+=`\\`),`${t[0]}:\\${e.substr(3)}${t.substr(2)}`):`${t[0]}:\\${t.substr(2)}`}else if(E(t).match(/^\\$|^\\[^\\]/)){let e=process.cwd();return b(e.match(/^[A-Z]:\\/i),`Expected current directory to start with an absolute drive root. Actual '${e}'`),`${e[0]}:\\${t.substr(1)}`}}return b(w(e),`ensureAbsoluteRoot parameter 'root' must have an absolute root`),e.endsWith(`/`)||x&&e.endsWith(`\\`)||(e+=y.sep),e+t}function w(e){return b(e,`hasAbsoluteRoot parameter 'itemPath' must not be empty`),e=E(e),x?e.startsWith(`\\\\`)||/^[A-Z]:\\/i.test(e):e.startsWith(`/`)}function T(e){return b(e,`isRooted parameter 'itemPath' must not be empty`),e=E(e),x?e.startsWith(`\\`)||/^[A-Z]:/i.test(e):e.startsWith(`/`)}function E(e){return e||=``,x?(e=e.replace(/\//g,`\\`),(/^\\\\+[^\\]/.test(e)?`\\`:``)+e.replace(/\\\\+/g,`\\`)):e.replace(/\/\/+/g,`/`)}function D(e){return e?(e=E(e),!e.endsWith(y.sep)||e===y.sep||x&&/^[A-Z]:\\$/i.test(e)?e:e.substr(0,e.length-1)):``}var O;(function(e){e[e.None=0]=`None`,e[e.Directory=1]=`Directory`,e[e.File=2]=`File`,e[e.All=3]=`All`})(O||={});const he=process.platform===`win32`;function ge(e){e=e.filter(e=>!e.negate);let t={};for(let n of e){let e=he?n.searchPath.toUpperCase():n.searchPath;t[e]=`candidate`}let n=[];for(let r of e){let e=he?r.searchPath.toUpperCase():r.searchPath;if(t[e]===`included`)continue;let i=!1,a=e,o=S(a);for(;o!==a;){if(t[o]){i=!0;break}a=o,o=S(a)}i||(n.push(r.searchPath),t[e]=`included`)}return n}function _e(e,t){let n=O.None;for(let r of e)r.negate?n&=~r.match(t):n|=r.match(t);return n}function ve(e,t){return e.some(e=>!e.negate&&e.partialMatch(t))}const ye=(e,t,n)=>{let r=e instanceof RegExp?k(e,n):e,i=t instanceof RegExp?k(t,n):t,a=r!==null&&i!=null&&be(r,i,n);return a&&{start:a[0],end:a[1],pre:n.slice(0,a[0]),body:n.slice(a[0]+r.length,a[1]),post:n.slice(a[1]+i.length)}},k=(e,t)=>{let n=t.match(e);return n?n[0]:null},be=(e,t,n)=>{let r,i,a,o,s,c=n.indexOf(e),l=n.indexOf(t,c+1),u=c;if(c>=0&&l>0){if(e===t)return[c,l];for(r=[],a=n.length;u>=0&&!s;){if(u===c)r.push(u),c=n.indexOf(e,u+1);else if(r.length===1){let e=r.pop();e!==void 0&&(s=[e,l])}else i=r.pop(),i!==void 0&&i=0?c:l}r.length&&o!==void 0&&(s=[a,o])}return s},A=`\0SLASH`+Math.random()+`\0`,j=`\0OPEN`+Math.random()+`\0`,M=`\0CLOSE`+Math.random()+`\0`,N=`\0COMMA`+Math.random()+`\0`,P=`\0PERIOD`+Math.random()+`\0`,xe=new RegExp(A,`g`),Se=new RegExp(j,`g`),Ce=new RegExp(M,`g`),we=new RegExp(N,`g`),Te=new RegExp(P,`g`),Ee=/\\\\/g,De=/\\{/g,Oe=/\\}/g,ke=/\\,/g,Ae=/\\\./g;function F(e){return isNaN(e)?e.charCodeAt(0):parseInt(e,10)}function je(e){return e.replace(Ee,A).replace(De,j).replace(Oe,M).replace(ke,N).replace(Ae,P)}function Me(e){return e.replace(xe,`\\`).replace(Se,`{`).replace(Ce,`}`).replace(we,`,`).replace(Te,`.`)}function I(e){if(!e)return[``];let t=[],n=ye(`{`,`}`,e);if(!n)return e.split(`,`);let{pre:r,body:i,post:a}=n,o=r.split(`,`);o[o.length-1]+=`{`+i+`}`;let s=I(a);return a.length&&(o[o.length-1]+=s.shift(),o.push.apply(o,s)),t.push.apply(t,o),t}function Ne(e,t={}){if(!e)return[];let{max:n=1e5}=t;return e.slice(0,2)===`{}`&&(e=`\\{\\}`+e.slice(2)),L(je(e),n,!0).map(Me)}function Pe(e){return`{`+e+`}`}function Fe(e){return/^-?0\d/.test(e)}function Ie(e,t){return e<=t}function Le(e,t){return e>=t}function L(e,t,n){let r=[],i=ye(`{`,`}`,e);if(!i)return[e];let a=i.pre,o=i.post.length?L(i.post,t,!1):[``];if(/\$$/.test(i.pre))for(let e=0;e=0;if(!l&&!u)return i.post.match(/,(?!,).*\}/)?(e=i.pre+`{`+i.body+M+i.post,L(e,t,!0)):[e];let d;if(l)d=i.body.split(/\.\./);else if(d=I(i.body),d.length===1&&d[0]!==void 0&&(d=L(d[0],t,!1).map(Pe),d.length===1))return o.map(e=>i.pre+d[0]+e);let f;if(l&&d[0]!==void 0&&d[1]!==void 0){let e=F(d[0]),n=F(d[1]),r=Math.max(d[0].length,d[1].length),i=d.length===3&&d[2]!==void 0?Math.max(Math.abs(F(d[2])),1):1,a=Ie;n0){let n=Array(t+1).join(`0`);e=s<0?`-`+n+e.slice(1):n+e}}f.push(e)}}else{f=[];for(let e=0;e{if(typeof e!=`string`)throw TypeError(`invalid pattern`);if(e.length>65536)throw TypeError(`pattern is too long`)},Re={"[:alnum:]":[`\\p{L}\\p{Nl}\\p{Nd}`,!0],"[:alpha:]":[`\\p{L}\\p{Nl}`,!0],"[:ascii:]":[`\\x00-\\x7f`,!1],"[:blank:]":[`\\p{Zs}\\t`,!0],"[:cntrl:]":[`\\p{Cc}`,!0],"[:digit:]":[`\\p{Nd}`,!0],"[:graph:]":[`\\p{Z}\\p{C}`,!0,!0],"[:lower:]":[`\\p{Ll}`,!0],"[:print:]":[`\\p{C}`,!0],"[:punct:]":[`\\p{P}`,!0],"[:space:]":[`\\p{Z}\\t\\r\\n\\v\\f`,!0],"[:upper:]":[`\\p{Lu}`,!0],"[:word:]":[`\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}`,!0],"[:xdigit:]":[`A-Fa-f0-9`,!1]},z=e=>e.replace(/[[\]\\-]/g,`\\$&`),ze=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,`\\$&`),Be=e=>e.join(``),Ve=(e,t)=>{let n=t;if(e.charAt(n)!==`[`)throw Error(`not in a brace expression`);let r=[],i=[],a=n+1,o=!1,s=!1,c=!1,l=!1,u=n,d=``;WHILE:for(;ad?r.push(z(d)+`-`+z(t)):t===d&&r.push(z(t)),d=``,a++;continue}if(e.startsWith(`-]`,a+1)){r.push(z(t+`-`)),a+=2;continue}if(e.startsWith(`-`,a+1)){d=t,a+=2;continue}r.push(z(t)),a++}if(un?t?e.replace(/\[([^/\\])\]/g,`$1`):e.replace(/((?!\\).|^)\[([^/\\])\]/g,`$1$2`).replace(/\\([^/])/g,`$1`):t?e.replace(/\[([^/\\{}])\]/g,`$1`):e.replace(/((?!\\).|^)\[([^/\\{}])\]/g,`$1$2`).replace(/\\([^/{}])/g,`$1`);var V;const He=new Set([`!`,`?`,`+`,`*`,`@`]),H=e=>He.has(e),Ue=e=>H(e.type),We=new Map([[`!`,[`@`]],[`?`,[`?`,`@`]],[`@`,[`@`]],[`*`,[`*`,`+`,`?`,`@`]],[`+`,[`+`,`@`]]]),Ge=new Map([[`!`,[`?`]],[`@`,[`?`]],[`+`,[`?`,`*`]]]),Ke=new Map([[`!`,[`?`,`@`]],[`?`,[`?`,`@`]],[`@`,[`?`,`@`]],[`*`,[`*`,`+`,`?`,`@`]],[`+`,[`+`,`@`,`?`,`*`]]]),qe=new Map([[`!`,new Map([[`!`,`@`]])],[`?`,new Map([[`*`,`*`],[`+`,`*`]])],[`@`,new Map([[`!`,`!`],[`?`,`?`],[`@`,`@`],[`*`,`*`],[`+`,`+`]])],[`+`,new Map([[`?`,`*`],[`*`,`*`]])]]),U=`(?!\\.)`,Je=new Set([`[`,`.`]),Ye=new Set([`..`,`.`]),Xe=new Set(`().*{}+?[]^$\\!`),Ze=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,`\\$&`),Qe=`[^/]+?`;let $e=0;var W=class{type;#e;#t;#n=!1;#r=[];#i;#a;#o;#s=!1;#c;#l;#u=!1;id=++$e;get depth(){return(this.#i?.depth??-1)+1}[Symbol.for(`nodejs.util.inspect.custom`)](){return{"@@type":`AST`,id:this.id,type:this.type,root:this.#e.id,parent:this.#i?.id,depth:this.depth,partsLength:this.#r.length,parts:this.#r}}constructor(e,t,n={}){this.type=e,e&&(this.#t=!0),this.#i=t,this.#e=this.#i?this.#i.#e:this,this.#c=this.#e===this?n:this.#e.#c,this.#o=this.#e===this?[]:this.#e.#o,e===`!`&&!this.#e.#s&&this.#o.push(this),this.#a=this.#i?this.#i.#r.length:0}get hasMagic(){if(this.#t!==void 0)return this.#t;for(let e of this.#r)if(typeof e!=`string`&&(e.type||e.hasMagic))return this.#t=!0;return this.#t}toString(){return this.#l===void 0?this.type?this.#l=this.type+`(`+this.#r.map(e=>String(e)).join(`|`)+`)`:this.#l=this.#r.map(e=>String(e)).join(``):this.#l}#d(){if(this!==this.#e)throw Error(`should only call on root`);if(this.#s)return this;this.toString(),this.#s=!0;let e;for(;e=this.#o.pop();){if(e.type!==`!`)continue;let t=e,n=t.#i;for(;n;){for(let r=t.#a+1;!n.type&&rtypeof e==`string`?e:e.toJSON()):[this.type,...this.#r.map(e=>e.toJSON())];return this.isStart()&&!this.type&&e.unshift([]),this.isEnd()&&(this===this.#e||this.#e.#s&&this.#i?.type===`!`)&&e.push({}),e}isStart(){if(this.#e===this)return!0;if(!this.#i?.isStart())return!1;if(this.#a===0)return!0;let e=this.#i;for(let t=0;ttypeof e!=`string`),r=this.#r.map(t=>{let[r,i,a,o]=typeof t==`string`?V.#C(t,this.#t,n):t.toRegExpSource(e);return this.#t=this.#t||a,this.#n=this.#n||o,r}).join(``),i=``;if(this.isStart()&&typeof this.#r[0]==`string`&&!(this.#r.length===1&&Ye.has(this.#r[0]))){let n=Je,a=t&&n.has(r.charAt(0))||r.startsWith(`\\.`)&&n.has(r.charAt(2))||r.startsWith(`\\.\\.`)&&n.has(r.charAt(4)),o=!t&&!e&&n.has(r.charAt(0));i=a?`(?!(?:^|/)\\.\\.?(?:$|/))`:o?U:``}let a=``;return this.isEnd()&&this.#e.#s&&this.#i?.type===`!`&&(a=`(?:$|\\/)`),[i+r+a,B(r),this.#t=!!this.#t,this.#n]}let n=this.type===`*`||this.type===`+`,r=this.type===`!`?`(?:(?!(?:`:`(?:`,i=this.#S(t);if(this.isStart()&&this.isEnd()&&!i&&this.type!==`!`){let e=this.toString(),t=this;return t.#r=[e],t.type=null,t.#t=void 0,[e,B(this.toString()),!1,!1]}let a=!n||e||t?``:this.#S(!0);a===i&&(a=``),a&&(i=`(?:${i})(?:${a})*?`);let o=``;if(this.type===`!`&&this.#u)o=(this.isStart()&&!t?U:``)+Qe;else{let n=this.type===`!`?`))`+(this.isStart()&&!t&&!e?U:``)+`[^/]*?)`:this.type===`@`?`)`:this.type===`?`?`)?`:this.type===`+`&&a?`)`:this.type===`*`&&a?`)?`:`)${this.type}`;o=r+i+n}return[o,B(i),this.#t=!!this.#t,this.#n]}#x(){if(Ue(this)){let e=0,t=!1;do{t=!0;for(let e=0;e{if(typeof t==`string`)throw Error(`string type in extglob ast??`);let[n,r,i,a]=t.toRegExpSource(e);return this.#n=this.#n||a,n}).filter(e=>!(this.isStart()&&this.isEnd())||!!e).join(`|`)}static#C(e,t,n=!1){let r=!1,i=``,a=!1,o=!1;for(let s=0;sn?t?e.replace(/[?*()[\]{}]/g,`[$&]`):e.replace(/[?*()[\]\\{}]/g,`\\$&`):t?e.replace(/[?*()[\]]/g,`[$&]`):e.replace(/[?*()[\]\\]/g,`\\$&`),G=(e,t,n={})=>(R(t),!n.nocomment&&t.charAt(0)===`#`?!1:new Y(t,n).match(e)),tt=/^\*+([^+@!?*[(]*)$/,nt=e=>t=>!t.startsWith(`.`)&&t.endsWith(e),rt=e=>t=>t.endsWith(e),it=e=>(e=e.toLowerCase(),t=>!t.startsWith(`.`)&&t.toLowerCase().endsWith(e)),at=e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),ot=/^\*+\.\*+$/,st=e=>!e.startsWith(`.`)&&e.includes(`.`),ct=e=>e!==`.`&&e!==`..`&&e.includes(`.`),lt=/^\.\*+$/,ut=e=>e!==`.`&&e!==`..`&&e.startsWith(`.`),dt=/^\*+$/,ft=e=>e.length!==0&&!e.startsWith(`.`),pt=e=>e.length!==0&&e!==`.`&&e!==`..`,mt=/^\?+([^+@!?*[(]*)?$/,ht=([e,t=``])=>{let n=yt([e]);return t?(t=t.toLowerCase(),e=>n(e)&&e.toLowerCase().endsWith(t)):n},gt=([e,t=``])=>{let n=bt([e]);return t?(t=t.toLowerCase(),e=>n(e)&&e.toLowerCase().endsWith(t)):n},_t=([e,t=``])=>{let n=bt([e]);return t?e=>n(e)&&e.endsWith(t):n},vt=([e,t=``])=>{let n=yt([e]);return t?e=>n(e)&&e.endsWith(t):n},yt=([e])=>{let t=e.length;return e=>e.length===t&&!e.startsWith(`.`)},bt=([e])=>{let t=e.length;return e=>e.length===t&&e!==`.`&&e!==`..`},xt=typeof process==`object`&&process?typeof process.env==`object`&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:`posix`,St={win32:{sep:`\\`},posix:{sep:`/`}};G.sep=xt===`win32`?St.win32.sep:St.posix.sep;const K=Symbol(`globstar **`);G.GLOBSTAR=K,G.filter=(e,t={})=>n=>G(n,e,t);const q=(e,t={})=>Object.assign({},e,t);G.defaults=e=>{if(!e||typeof e!=`object`||!Object.keys(e).length)return G;let t=G;return Object.assign((n,r,i={})=>t(n,r,q(e,i)),{Minimatch:class extends t.Minimatch{constructor(t,n={}){super(t,q(e,n))}static defaults(n){return t.defaults(q(e,n)).Minimatch}},AST:class extends t.AST{constructor(t,n,r={}){super(t,n,q(e,r))}static fromGlob(n,r={}){return t.AST.fromGlob(n,q(e,r))}},unescape:(n,r={})=>t.unescape(n,q(e,r)),escape:(n,r={})=>t.escape(n,q(e,r)),filter:(n,r={})=>t.filter(n,q(e,r)),defaults:n=>t.defaults(q(e,n)),makeRe:(n,r={})=>t.makeRe(n,q(e,r)),braceExpand:(n,r={})=>t.braceExpand(n,q(e,r)),match:(n,r,i={})=>t.match(n,r,q(e,i)),sep:t.sep,GLOBSTAR:K})};const Ct=(e,t={})=>(R(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:Ne(e,{max:t.braceExpandMax}));G.braceExpand=Ct,G.makeRe=(e,t={})=>new Y(e,t).makeRe(),G.match=(e,t,n={})=>{let r=new Y(t,n);return e=e.filter(e=>r.match(e)),r.options.nonull&&!e.length&&e.push(t),e};const J=/[?*]|[+@!]\(.*?\)|\[|\]/,wt=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,`\\$&`);var Y=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;maxGlobstarRecursion;regexp;constructor(e,t={}){R(e),t||={},this.options=t,this.maxGlobstarRecursion=t.maxGlobstarRecursion??200,this.pattern=e,this.platform=t.platform||xt,this.isWindows=this.platform===`win32`,this.windowsPathsNoEscape=!!t.windowsPathsNoEscape||t.allowWindowsEscape===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,`/`)),this.preserveMultipleSlashes=!!t.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!t.nonegate,this.comment=!1,this.empty=!1,this.partial=!!t.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=t.windowsNoMagicRoot===void 0?!!(this.isWindows&&this.nocase):t.windowsNoMagicRoot,this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(let e of this.set)for(let t of e)if(typeof t!=`string`)return!0;return!1}debug(...e){}make(){let e=this.pattern,t=this.options;if(!t.nocomment&&e.charAt(0)===`#`){this.comment=!0;return}if(!e){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],t.debug&&(this.debug=(...e)=>console.error(...e)),this.debug(this.pattern,this.globSet);let n=this.globSet.map(e=>this.slashSplit(e));this.globParts=this.preprocess(n),this.debug(this.pattern,this.globParts);let r=this.globParts.map((e,t,n)=>{if(this.isWindows&&this.windowsNoMagicRoot){let t=e[0]===``&&e[1]===``&&(e[2]===`?`||!J.test(e[2]))&&!J.test(e[3]),n=/^[a-z]:/i.test(e[0]);if(t)return[...e.slice(0,4),...e.slice(4).map(e=>this.parse(e))];if(n)return[e[0],...e.slice(1).map(e=>this.parse(e))]}return e.map(e=>this.parse(e))});if(this.debug(this.pattern,r),this.set=r.filter(e=>e.indexOf(!1)===-1),this.isWindows)for(let e=0;e=2?(e=this.firstPhasePreProcess(e),e=this.secondPhasePreProcess(e)):e=t>=1?this.levelOneOptimize(e):this.adjascentGlobstarOptimize(e),e}adjascentGlobstarOptimize(e){return e.map(e=>{let t=-1;for(;(t=e.indexOf(`**`,t+1))!==-1;){let n=t;for(;e[n+1]===`**`;)n++;n!==t&&e.splice(t,n-t)}return e})}levelOneOptimize(e){return e.map(e=>(e=e.reduce((e,t)=>{let n=e[e.length-1];return t===`**`&&n===`**`?e:t===`..`&&n&&n!==`..`&&n!==`.`&&n!==`**`?(e.pop(),e):(e.push(t),e)},[]),e.length===0?[``]:e))}levelTwoFileOptimize(e){Array.isArray(e)||(e=this.slashSplit(e));let t=!1;do{if(t=!1,!this.preserveMultipleSlashes){for(let n=1;nr&&n.splice(r+1,i-r);let a=n[r+1],o=n[r+2],s=n[r+3];if(a!==`..`||!o||o===`.`||o===`..`||!s||s===`.`||s===`..`)continue;t=!0,n.splice(r,1);let c=n.slice(0);c[r]=`**`,e.push(c),r--}if(!this.preserveMultipleSlashes){for(let e=1;ee.length)}partsMatch(e,t,n=!1){let r=0,i=0,a=[],o=``;for(;r=2&&(e=this.levelTwoFileOptimize(e)),t.includes(K)?this.#e(e,t,n,r,i):this.#n(e,t,n,r,i)}#e(e,t,n,r,i){let a=t.indexOf(K,i),o=t.lastIndexOf(K),[s,c,l]=n?[t.slice(i,a),t.slice(a+1),[]]:[t.slice(i,a),t.slice(a+1,o),t.slice(o+1)];if(s.length){let t=e.slice(r,r+s.length);if(!this.#n(t,s,n,0,0))return!1;r+=s.length,i+=s.length}let u=0;if(l.length){if(l.length+r>e.length)return!1;let t=e.length-l.length;if(this.#n(e,l,n,t,0))u=l.length;else{if(e[e.length-1]!==``||r+l.length===e.length||(t--,!this.#n(e,l,n,t,0)))return!1;u=l.length+1}}if(!c.length){let t=!!u;for(let n=r;n{let t=e.map(e=>{if(e instanceof RegExp)for(let t of e.flags.split(``))r.add(t);return typeof e==`string`?wt(e):e===K?K:e._src});t.forEach((e,r)=>{let i=t[r+1],a=t[r-1];e!==K||a===K||(a===void 0?i!==void 0&&i!==K?t[r+1]=`(?:\\/|`+n+`\\/)?`+i:t[r]=n:i===void 0?t[r-1]=a+`(?:\\/|\\/`+n+`)?`:i!==K&&(t[r-1]=a+`(?:\\/|\\/`+n+`\\/)`+i,t[r+1]=K))});let i=t.filter(e=>e!==K);if(this.partial&&i.length>=1){let e=[];for(let t=1;t<=i.length;t++)e.push(i.slice(0,t).join(`/`));return`(?:`+e.join(`|`)+`)`}return i.join(`/`)}).join(`|`),[a,o]=e.length>1?[`(?:`,`)`]:[``,``];i=`^`+a+i+o+`$`,this.partial&&(i=`^(?:\\/|`+a+i.slice(1,-1)+o+`)$`),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 n=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 a=r[r.length-1];if(!a)for(let e=r.length-2;!a&&e>=0;e--)a=r[e];for(let e of i){let i=r;if(n.matchBase&&e.length===1&&(i=[a]),this.matchOne(i,e,t))return n.flipNegate?!0:!this.negate}return n.flipNegate?!1:this.negate}static defaults(e){return G.defaults(e).Minimatch}};G.AST=W,G.Minimatch=Y,G.escape=et,G.unescape=B;const Tt=process.platform===`win32`;var X=class{constructor(e){if(this.segments=[],typeof e==`string`)if(b(e,`Parameter 'itemPath' must not be empty`),e=D(e),!T(e))this.segments=e.split(y.sep);else{let t=e,n=S(t);for(;n!==t;){let e=y.basename(t);this.segments.unshift(e),t=n,n=S(t)}this.segments.unshift(t)}else{b(e.length>0,`Parameter 'itemPath' must not be an empty array`);for(let t=0;te.getLiteral(t)).filter(e=>!o&&!(o=e===``));this.searchPath=new X(s).toString(),this.rootRegExp=new RegExp(e.regExpEscape(s[0]),Z?`i`:``),this.isImplicitPattern=n;let c={dot:!0,nobrace:!0,nocase:Z,nocomment:!0,noext:!0,nonegate:!0};a=Z?a.replace(/\\/g,`/`):a,this.minimatch=new Y(a,c)}match(e){return this.segments[this.segments.length-1]===`**`?(e=E(e),!e.endsWith(y.sep)&&this.isImplicitPattern===!1&&(e=`${e}${y.sep}`)):e=D(e),this.minimatch.match(e)?this.trailingSeparator?O.Directory:O.All:O.None}partialMatch(e){return e=D(e),S(e)===e?this.rootRegExp.test(e):this.minimatch.matchOne(e.split(Z?/\\+/:/\/+/),this.minimatch.set[0],!0)}static globEscape(e){return(Z?e:e.replace(/\\/g,`\\\\`)).replace(/(\[)(?=[^/]+\])/g,`[[]`).replace(/\?/g,`[?]`).replace(/\*/g,`[*]`)}static fixupPattern(t,n){b(t,`pattern cannot be empty`);let r=new X(t).segments.map(t=>e.getLiteral(t));if(b(r.every((e,t)=>(e!==`.`||t===0)&&e!==`..`),`Invalid pattern '${t}'. Relative pathing '.' and '..' is not allowed.`),b(!T(t)||r[0],`Invalid pattern '${t}'. Root segment must not contain globs.`),t=E(t),t===`.`||t.startsWith(`.${y.sep}`))t=e.globEscape(process.cwd())+t.substr(1);else if(t===`~`||t.startsWith(`~${y.sep}`))n||=de.homedir(),b(n,`Unable to determine HOME directory`),b(w(n),`Expected HOME directory to be a rooted path. Actual '${n}'`),t=e.globEscape(n)+t.substr(1);else if(Z&&(t.match(/^[A-Z]:$/i)||t.match(/^[A-Z]:[^\\]/i))){let n=C(`C:\\dummy-root`,t.substr(0,2));t.length>2&&!n.endsWith(`\\`)&&(n+=`\\`),t=e.globEscape(n)+t.substr(2)}else if(Z&&(t===`\\`||t.match(/^\\[^\\]/))){let n=C(`C:\\dummy-root`,`\\`);n.endsWith(`\\`)||(n+=`\\`),t=e.globEscape(n)+t.substr(1)}else t=C(e.globEscape(process.cwd()),t);return E(t)}static getLiteral(e){let t=``;for(let n=0;n=0){if(r.length>1)return``;if(r){t+=r,n=i;continue}}}t+=r}return t}static regExpEscape(e){return e.replace(/[[\\^$.|?*+()]/g,`\\$&`)}},Dt=class{constructor(e,t){this.path=e,this.level=t}},Q=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},Ot=function(e){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof __values==`function`?__values(e):e[Symbol.iterator](),n={},r(`next`),r(`throw`),r(`return`),n[Symbol.asyncIterator]=function(){return this},n);function r(t){n[t]=e[t]&&function(n){return new Promise(function(r,a){n=e[t](n),i(r,a,n.done,n.value)})}}function i(e,t,n,r){Promise.resolve(r).then(function(t){e({value:t,done:n})},t)}},$=function(e){return this instanceof $?(this.v=e,this):new $(e)},kt=function(e,t,n){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var r=n.apply(e,t||[]),i,a=[];return i=Object.create((typeof AsyncIterator==`function`?AsyncIterator:Object).prototype),s(`next`),s(`throw`),s(`return`,o),i[Symbol.asyncIterator]=function(){return this},i;function o(e){return function(t){return Promise.resolve(t).then(e,d)}}function s(e,t){r[e]&&(i[e]=function(t){return new Promise(function(n,r){a.push([e,t,n,r])>1||c(e,t)})},t&&(i[e]=t(i[e])))}function c(e,t){try{l(r[e](t))}catch(e){f(a[0][3],e)}}function l(e){e.value instanceof $?Promise.resolve(e.value.v).then(u,d):f(a[0][2],e)}function u(e){c(`next`,e)}function d(e){c(`throw`,e)}function f(e,t){e(t),a.shift(),a.length&&c(a[0][0],a[0][1])}};const At=process.platform===`win32`;var jt=class e{constructor(e){this.patterns=[],this.searchPaths=[],this.options=me(e)}getSearchPaths(){return this.searchPaths.slice()}glob(){return Q(this,void 0,void 0,function*(){var e,t,n,r;let i=[];try{for(var a=!0,o=Ot(this.globGenerator()),s;s=yield o.next(),e=s.done,!e;a=!0){r=s.value,a=!1;let e=r;i.push(e)}}catch(e){t={error:e}}finally{try{!a&&!e&&(n=o.return)&&(yield n.call(o))}finally{if(t)throw t.error}}return i})}globGenerator(){return kt(this,arguments,function*(){let t=me(this.options),n=[];for(let e of this.patterns)n.push(e),t.implicitDescendants&&(e.trailingSeparator||e.segments[e.segments.length-1]!==`**`)&&n.push(new Et(e.negate,!0,e.segments.concat(`**`)));let r=[];for(let e of ge(n)){g(`Search path '${e}'`);try{yield $(v.promises.lstat(e))}catch(e){if(e.code===`ENOENT`)continue;throw e}r.unshift(new Dt(e,1))}let i=[];for(;r.length;){let a=r.pop(),o=_e(n,a.path),s=!!o||ve(n,a.path);if(!o&&!s)continue;let c=yield $(e.stat(a,t,i));if(c&&!(t.excludeHiddenFiles&&y.basename(a.path).match(/^\./)))if(c.isDirectory()){if(o&O.Directory&&t.matchDirectories)yield yield $(a.path);else if(!s)continue;let e=a.level+1,n=(yield $(v.promises.readdir(a.path))).map(t=>new Dt(y.join(a.path,t),e));r.push(...n.reverse())}else o&O.File&&(yield yield $(a.path))}})}static create(t,n){return Q(this,void 0,void 0,function*(){let r=new e(n);At&&(t=t.replace(/\r\n/g,` `),t=t.replace(/\r/g,` `));let i=t.split(` -`).map(e=>e.trim());for(let e of i)if(!e||e.startsWith(`#`))continue;else r.patterns.push(new Dt(e));return r.searchPaths.push(...O(r.patterns)),r})}static stat(e,t,n){return Q(this,void 0,void 0,function*(){let i;if(t.followSymbolicLinks)try{i=yield _.promises.stat(e.path)}catch(n){if(n.code===`ENOENT`){if(t.omitBrokenSymbolicLinks){r(`Broken symlink '${e.path}'`);return}throw Error(`No information found for the path '${e.path}'. This may indicate a broken symbolic link.`)}throw n}else i=yield _.promises.lstat(e.path);if(i.isDirectory()&&t.followSymbolicLinks){let t=yield _.promises.realpath(e.path);for(;n.length>=e.level;)n.pop();if(n.some(e=>e===t)){r(`Symlink cycle detected for path '${e.path}' and realpath '${t}'`);return}n.push(t)}return i})}},Nt=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};function Pt(e,t){return Nt(this,void 0,void 0,function*(){return yield Mt.create(e,t)})}async function Ft(){e()&&i(`OPAMVERBOSE`,1),i(`OPAMCOLOR`,`always`),i(`OPAMCONFIRMLEVEL`,`unsafe-yes`),i(`OPAMDOWNLOADJOBS`,he.availableParallelism()),i(`OPAMERRLOGLEN`,0),i(`OPAMEXTERNALSOLVER`,`builtin-0install`),i(`OPAMPRECISETRACKING`,1),i(`OPAMRETRIES`,10),i(`OPAMROOT`,de),i(`OPAMSOLVERTIMEOUT`,600),i(`OPAMYES`,1),a===`windows`&&(i(`HOME`,g.env.USERPROFILE),i(`MSYS`,`winsymlinks:native`),ue===`cygwin`&&i(`CYGWIN`,`winsymlinks:native`),await ee(`Configuring Windows symlink settings`,async()=>{await h(`fsutil`,[`behavior`,`query`,`SymlinkEvaluation`]),await h(`fsutil`,[`behavior`,`set`,`symlinkEvaluation`,`R2L:1`,`R2R:1`]),await h(`fsutil`,[`behavior`,`query`,`SymlinkEvaluation`])}));let n=await m();await d(),a===`windows`&&ue===`cygwin`&&(await me.writeFile(ne,`set -o igncr`),i(`BASH_ENV`,ne),o(p)),await u(),await ce(c),n?await ie():(await l(await oe),t||await re()),f&&(await ae(),await se(),i(`DUNE_CACHE_ROOT`,s)),i(`CLICOLOR_FORCE`,`1`),fe&&await te(await(await Pt(le)).glob()),await h(`opam`,[`config`,`report`])}async function It(){try{await Ft(),g.exit(0)}catch(e){e instanceof Error&&n(e.message),g.exit(1)}}It();export{}; \ No newline at end of file +`).map(e=>e.trim());for(let e of i)if(!e||e.startsWith(`#`))continue;else r.patterns.push(new Et(e));return r.searchPaths.push(...ge(r.patterns)),r})}static stat(e,t,n){return Q(this,void 0,void 0,function*(){let r;if(t.followSymbolicLinks)try{r=yield v.promises.stat(e.path)}catch(n){if(n.code===`ENOENT`){if(t.omitBrokenSymbolicLinks){g(`Broken symlink '${e.path}'`);return}throw Error(`No information found for the path '${e.path}'. This may indicate a broken symbolic link.`)}throw n}else r=yield v.promises.lstat(e.path);if(r.isDirectory()&&t.followSymbolicLinks){let t=yield v.promises.realpath(e.path);for(;n.length>=e.level;)n.pop();if(n.some(e=>e===t)){g(`Symlink cycle detected for path '${e.path}' and realpath '${t}'`);return}n.push(t)}return r})}},Mt=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};function Nt(e,t){return Mt(this,void 0,void 0,function*(){return yield jt.create(e,t)})}async function Pt(){await t(`Installing dune`,async()=>{await h(`opam`,[`install`,`dune`])})}async function Ft(){r()&&n(`OPAMVERBOSE`,1),n(`OPAMCOLOR`,`always`),n(`OPAMCONFIRMLEVEL`,`unsafe-yes`),n(`OPAMDOWNLOADJOBS`,pe.availableParallelism()),n(`OPAMERRLOGLEN`,0),n(`OPAMEXTERNALSOLVER`,`builtin-0install`),n(`OPAMPRECISETRACKING`,1),n(`OPAMRETRIES`,10),n(`OPAMROOT`,ue),n(`OPAMSOLVERTIMEOUT`,600),n(`OPAMYES`,1),c===`windows`&&(n(`HOME`,_.env.USERPROFILE),n(`MSYS`,`winsymlinks:native`),i===`cygwin`&&n(`CYGWIN`,`winsymlinks:native`),await t(`Configuring Windows symlink settings`,async()=>{await h(`fsutil`,[`behavior`,`query`,`SymlinkEvaluation`]),await h(`fsutil`,[`behavior`,`set`,`symlinkEvaluation`,`R2L:1`,`R2R:1`]),await h(`fsutil`,[`behavior`,`query`,`SymlinkEvaluation`])}));let a=await ne();await se(),c===`windows`&&i===`cygwin`&&(await fe.writeFile(d,`set -o igncr`),n(`BASH_ENV`,d),e(ie)),await ee(),await l(ce),a?await u():(await re(await s),le||await m()),te&&(await oe(),await Pt(),n(`DUNE_CACHE_ROOT`,p),n(`DUNE_CACHE`,`enabled`),n(`DUNE_CACHE_STORAGE_MODE`,`copy`)),n(`CLICOLOR_FORCE`,`1`),o&&await ae(await(await Nt(f)).glob()),await h(`opam`,[`config`,`report`])}async function It(){try{await Ft(),_.exit(0)}catch(e){e instanceof Error&&a(e.message),_.exit(1)}}It();export{}; \ No newline at end of file diff --git a/dist/post/index.mjs b/dist/post/index.mjs index 7e548ac8..8df624f2 100644 --- a/dist/post/index.mjs +++ b/dist/post/index.mjs @@ -1 +1 @@ -import{C as e,D as t,a as n,g as r,n as i,o as a}from"../dune.mjs";import*as o from"node:process";async function s(){try{r&&(await i(),await n()),e&&await a(),o.exit(0)}catch(e){e instanceof Error&&t(e.message),o.exit(0)}}s();export{}; \ No newline at end of file +import{T as e,i as t,m as n,r,x as i}from"../cache.mjs";import*as a from"node:process";async function o(){try{n&&await r(),i&&await t(),a.exit(0)}catch(t){t instanceof Error&&e(t.message),a.exit(0)}}o();export{}; \ No newline at end of file diff --git a/packages/setup-ocaml/src/dune.ts b/packages/setup-ocaml/src/dune.ts index 13259f87..75981784 100644 --- a/packages/setup-ocaml/src/dune.ts +++ b/packages/setup-ocaml/src/dune.ts @@ -1,30 +1,8 @@ import * as core from "@actions/core"; import { exec } from "@actions/exec"; -import * as github from "@actions/github"; -import { octokit } from "./github-client.js"; - -const DUNE_CACHE_TOTAL_SIZE_MB = 5000; export async function installDune() { await core.group("Installing dune", async () => { await exec("opam", ["install", "dune"]); }); } - -export async function trimDuneCache() { - await core.group("Clearing old dune cache files to save space", async () => { - const { - repo: { owner, repo }, - runId: run_id, - } = github.context; - const { - data: { total_count: totalCount }, - } = await octokit.rest.actions.listJobsForWorkflowRun({ - owner, - repo, - run_id, - }); - const cacheSize = Math.floor(DUNE_CACHE_TOTAL_SIZE_MB / totalCount); - await exec("opam", ["exec", "--", "dune", "cache", "trim", `--size=${cacheSize}MB`]); - }); -} diff --git a/packages/setup-ocaml/src/installer.ts b/packages/setup-ocaml/src/installer.ts index 7291c7e3..1f6cb7b7 100644 --- a/packages/setup-ocaml/src/installer.ts +++ b/packages/setup-ocaml/src/installer.ts @@ -90,6 +90,8 @@ export async function installer() { await restoreDuneCache(); await installDune(); core.exportVariable("DUNE_CACHE_ROOT", DUNE_CACHE_ROOT); + core.exportVariable("DUNE_CACHE", "enabled"); + core.exportVariable("DUNE_CACHE_STORAGE_MODE", "copy"); } core.exportVariable("CLICOLOR_FORCE", "1"); if (OPAM_PIN) { diff --git a/packages/setup-ocaml/src/post.ts b/packages/setup-ocaml/src/post.ts index 7671a21d..f6b923f2 100644 --- a/packages/setup-ocaml/src/post.ts +++ b/packages/setup-ocaml/src/post.ts @@ -2,12 +2,10 @@ import * as process from "node:process"; import * as core from "@actions/core"; import { saveDuneCache, saveOpamCache } from "./cache.js"; import { DUNE_CACHE, SAVE_OPAM_POST_RUN } from "./constants.js"; -import { trimDuneCache } from "./dune.js"; async function run() { try { if (DUNE_CACHE) { - await trimDuneCache(); await saveDuneCache(); } if (SAVE_OPAM_POST_RUN) {