@upstart.gg/sdk 0.0.66 → 0.0.67
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/node/cli/api.js +2 -2
- package/dist/node/cli/commands/build/cmd-build.js +4 -2
- package/dist/node/cli/commands/login/cmd-login.js +4 -4
- package/dist/node/cli/commands/publish/cmd-publish.js +15 -15
- package/dist/node/cli/commands/publish/uploader.js +7 -7
- package/dist/node/cli/program.js +32 -30
- package/dist/node/cli/store.js +2 -2
- package/dist/node/metafile-esm.json +1 -1
- package/dist/node/shared/config.js +4 -4
- package/dist/node/shared/logger.js +2 -2
- package/dist/shared/env.d.ts +1 -3
- package/dist/shared/metafile-esm.json +1 -1
- package/package.json +11 -42
package/dist/node/cli/program.js
CHANGED
|
@@ -1,44 +1,46 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/*! Enpage - Copyright (C) 2024 Flippable - https://github.com/enpage/enpage/blob/main/LICENSE */
|
|
3
|
-
import{program as
|
|
4
|
-
`)),{...
|
|
5
|
-
${c}`:c,
|
|
6
|
-
${
|
|
3
|
+
var Mr=Object.create;var Ts=Object.defineProperty;var Fr=Object.getOwnPropertyDescriptor;var Ir=Object.getOwnPropertyNames;var jr=Object.getPrototypeOf,$r=Object.prototype.hasOwnProperty;var Os=(i,t)=>()=>(t||i((t={exports:{}}).exports,t),t.exports);var Ur=(i,t,e,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Ir(t))!$r.call(i,r)&&r!==e&&Ts(i,r,{get:()=>t[r],enumerable:!(s=Fr(t,r))||s.enumerable});return i};var Wr=(i,t,e)=>(e=i!=null?Mr(jr(i)):{},Ur(t||!i||!i.__esModule?Ts(e,"default",{value:i,enumerable:!0}):e,i));var si=Os((Lc,ei)=>{"use strict";ei.exports=Qs;function Qs(i,t,e){i instanceof RegExp&&(i=Zs(i,e)),t instanceof RegExp&&(t=Zs(t,e));var s=ti(i,t,e);return s&&{start:s[0],end:s[1],pre:e.slice(0,s[0]),body:e.slice(s[0]+i.length,s[1]),post:e.slice(s[1]+t.length)}}function Zs(i,t){var e=t.match(i);return e?e[0]:null}Qs.range=ti;function ti(i,t,e){var s,r,n,o,a,l=e.indexOf(i),c=e.indexOf(t,l+1),h=l;if(l>=0&&c>0){if(i===t)return[l,c];for(s=[],n=e.length;h>=0&&!a;)h==l?(s.push(h),l=e.indexOf(i,h+1)):s.length==1?a=[s.pop(),c]:(r=s.pop(),r<n&&(n=r,o=c),c=e.indexOf(t,h+1)),h=l<c&&l>=0?l:c;s.length&&(a=[n,o])}return a}});var hi=Os((Mc,ci)=>{"use strict";var ii=si();ci.exports=zn;var ri="\0SLASH"+Math.random()+"\0",ni="\0OPEN"+Math.random()+"\0",ze="\0CLOSE"+Math.random()+"\0",oi="\0COMMA"+Math.random()+"\0",ai="\0PERIOD"+Math.random()+"\0";function Be(i){return parseInt(i,10)==i?parseInt(i,10):i.charCodeAt(0)}function Wn(i){return i.split("\\\\").join(ri).split("\\{").join(ni).split("\\}").join(ze).split("\\,").join(oi).split("\\.").join(ai)}function Bn(i){return i.split(ri).join("\\").split(ni).join("{").split(ze).join("}").split(oi).join(",").split(ai).join(".")}function li(i){if(!i)return[""];var t=[],e=ii("{","}",i);if(!e)return i.split(",");var s=e.pre,r=e.body,n=e.post,o=s.split(",");o[o.length-1]+="{"+r+"}";var a=li(n);return n.length&&(o[o.length-1]+=a.shift(),o.push.apply(o,a)),t.push.apply(t,o),t}function zn(i){return i?(i.substr(0,2)==="{}"&&(i="\\{\\}"+i.substr(2)),Ut(Wn(i),!0).map(Bn)):[]}function Gn(i){return"{"+i+"}"}function Hn(i){return/^-?0\d/.test(i)}function qn(i,t){return i<=t}function Vn(i,t){return i>=t}function Ut(i,t){var e=[],s=ii("{","}",i);if(!s)return[i];var r=s.pre,n=s.post.length?Ut(s.post,!1):[""];if(/\$$/.test(s.pre))for(var o=0;o<n.length;o++){var a=r+"{"+s.body+"}"+n[o];e.push(a)}else{var l=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(s.body),c=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(s.body),h=l||c,f=s.body.indexOf(",")>=0;if(!h&&!f)return s.post.match(/,.*\}/)?(i=s.pre+"{"+s.body+ze+s.post,Ut(i)):[i];var u;if(h)u=s.body.split(/\.\./);else if(u=li(s.body),u.length===1&&(u=Ut(u[0],!1).map(Gn),u.length===1))return n.map(function(ie){return s.pre+u[0]+ie});var d;if(h){var g=Be(u[0]),p=Be(u[1]),y=Math.max(u[0].length,u[1].length),m=u.length==3?Math.abs(Be(u[2])):1,b=qn,w=p<g;w&&(m*=-1,b=Vn);var S=u.some(Hn);d=[];for(var E=g;b(E,p);E+=m){var x;if(c)x=String.fromCharCode(E),x==="\\"&&(x="");else if(x=String(E),S){var R=y-x.length;if(R>0){var Y=new Array(R+1).join("0");E<0?x="-"+Y+x.slice(1):x=Y+x}}d.push(x)}}else{d=[];for(var B=0;B<u.length;B++)d.push.apply(d,Ut(u[B],!1))}for(var B=0;B<d.length;B++)for(var o=0;o<n.length;o++){var a=r+d[B]+n[o];(!t||h||a)&&e.push(a)}}return e}});import{program as Mt}from"commander";import{resolve as Q}from"node:path";import{existsSync as $t,readFileSync as Dn,writeFileSync as Ln}from"node:fs";import nt from"chalk";function re(){let i;if(process.env.npm_config_user_agent){let t=process.env.npm_config_user_agent.split(" ")[0];i=t.slice(0,t.lastIndexOf("/"))}return i||(console.log("Warning: could not detect package manager"),i="npm"),i}function As(i){return`[${i.error}]${i.error_description?`: ${i.error_description}`:""}`}var Rs="enpage-cli";var Ue=process.env.PUBLIC_ENPAGE_OAUTH_CLIENT_ID??"50000000-0000-0000-0000-000000000001",ft=process.env.PUBLIC_ENPAGE_API_BASE_URL??"https://api.enpage.co",gl=process.env.PUBLIC_ENPAGE_FRONTEND_BASE_URL??"https://enpage.co",Cs=10,ks="oauth/devicecode",_s="oauth/token",Ns="oauth/userinfo",Ps="v1/templates";import Gr from"conf";import{createLogger as zr}from"vite";var Ds="0.0.67";import mt from"chalk";function We(i,t,e=!1){let s=zr(i==="debug"?"info":i,{prefix:"[enpage]",allowClearScreen:t});return e&&s.info(mt.hex("#7270c6").bold(`\u{1F680} Enpage v${Ds}
|
|
4
|
+
`)),{...s,success:(r,n)=>s.info(mt.green(r),n),error:(r,n)=>s.error(mt.red(r),n),warn:(r,n)=>s.warn(mt.yellow(r),n),warnOnce:(r,n)=>s.warnOnce(mt.yellow(r),n),debug:(r,n)=>{i==="debug"&&s.info(mt.gray(r),n)}}}var k=We();async function ut(i,t,e={}){j.get("access_token")&&(e.Authorization=`Bearer ${j.get("access_token")}`);let s=await fetch(Ms(i),{method:"POST",headers:{"Content-Type":t instanceof URLSearchParams?"application/x-www-form-urlencoded":"application/json",...e},body:t instanceof URLSearchParams?t:JSON.stringify(t)}).catch(r=>{k.error(`Fatal Error requesting API: ${r.message} (${r.cause.code})`),k.error("Please check your internet connection and try again, or retry later."),process.exit(1)});return Fs(s)}async function Ls(i,t={}){j.get("access_token")&&(t.Authorization=`Bearer ${j.get("access_token")}`);let e=await fetch(Ms(i),{headers:t,method:"GET"}).catch(s=>{k.error(`Fatal Error requesting API: ${s.message} (${s.cause.code})`),k.error("Please check your internet connection and try again, or retry later."),process.exit(1)});return Fs(e)}function Ms(i){let t=new URL(ft.endsWith("/")?ft:`${ft}/`);return new URL(i,t)}async function Fs(i){let t=i.headers.get("content-type")?.startsWith("application/json")?await i.json():await i.text();return i.ok?{isSuccess:!0,isError:!1,status:i.status,statusText:i.statusText,data:t}:{isSuccess:!1,isError:!0,status:i.status,statusText:i.statusText,data:t}}import Ft from"node:path";import Hr from"node:crypto";import gt from"node:fs";import{fileURLToPath as qr}from"node:url";import Vr from"chalk";var Kr=qr(new URL(".",import.meta.url)),Xr=Jr(),j=new Gr({projectName:Rs,encryptionKey:Xr,clearInvalidConfig:!0});async function Is(i=!1){let t=j.get("access_token"),e=j.get("expires_at");if(!t)return!1;if(e&&e<Date.now())return console.log("Seems like your token expired..."),!1;if(!i)return!0;let{isSuccess:s}=await Ls(Ns);return s}function js(){let i=j.get("access_token");if(!i){let t=re();throw new Error(`Access token not found. Please run ${Vr.cyan(`${t} run enpage:login`)} to authenticate.`)}return i}function Yr(){let i=Kr;for(;i!==Ft.parse(i).root;){let t=Ft.join(i,"node_modules");if(gt.existsSync(t))return t;i=Ft.dirname(i)}return null}function Jr(){let i=Yr();if(!i)throw new Error("Could not find nearest node_modules directory.");let t=Ft.join(i,".enpage-tmp");gt.existsSync(t)||gt.mkdirSync(t,{recursive:!0,mode:448});let e=Ft.join(t,".enpage-key");if(!gt.existsSync(e)){let r=Hr.randomBytes(32).toString("hex");return gt.writeFileSync(e,r,{mode:384,flush:!0}),r}return gt.readFileSync(e,"utf8")}import It from"node:path";import jt from"node:fs";import hn from"node:crypto";import fn from"fast-glob";import Bs from"node:http";import un from"node:https";import{pipeline as dn}from"node:stream";import Ws from"chalk";import pn from"form-data";import*as ne from"node:fs";var Zr=/[<>"|?*\n\r\t\f\x00-\x1F]/,Qr=/(?:^|\/)[*]{2}($|\/)/,tn=248,en=i=>i!==null&&typeof i=="object"&&!Array.isArray(i),sn=i=>typeof i=="string"&&i.length<=tn&&!Zr.test(i),rn=i=>i.split(/\r\n?|\n/);var nn=i=>en(i)&&Array.isArray(i.patterns)&&Array.isArray(i.sections);var oe=(i,t={})=>{let e=t.path;if(nn(i))return i;sn(i)&&ne.existsSync(i)&&(e=i,i=ne.readFileSync(i,"utf8"));let s=rn(i),r=new Map,n={sections:[],patterns:[]},o={name:"default",patterns:[]},a=null;for(let l of s){let c=l.trim();if(c.startsWith("#")){let[,h]=/^#+\s*(.*)\s*$/.exec(c)||[];if(a){r.delete(a.name),a.comment=a.comment?`${a.comment}
|
|
5
|
+
${c}`:c,a.name=h?`${a.name.trim()}
|
|
6
|
+
${h.trim()}`:a.name.trim(),r.set(a.name.toLowerCase().trim(),a);continue}o={name:h?.trim()||"",comment:c,patterns:[]},r.set(o.name.toLowerCase(),o),n.sections.push(o),a=o;continue}c!==""&&(o.patterns.push(c),n.patterns.push(c)),a=null}return(t.dedupe===!0||t.unique===!0)&&(n=$s(n,{...t,format:!1})),n.path=e,n.input=Buffer.from(i),n.format=l=>cn(n,{...t,...l}),n.dedupe=l=>$s(n,{...t,...l}),n.globs=l=>an(n,{path:e,...t,...l}),n};var $s=(i,t)=>{let e=oe(i,{...t,dedupe:!1}),s=new Map,r={sections:[],patterns:[]},n;for(let o of e.sections){let{name:a="",comment:l,patterns:c}=o,h=a.trim().toLowerCase();for(let f of c)r.patterns.includes(f)||r.patterns.push(f);a&&s.has(h)?(n=s.get(h),n.patterns=[...n.patterns,...c]):(n={name:a,comment:l,patterns:c},r.sections.push(n),s.set(h,n))}for(let o of r.sections)o.patterns=[...new Set(o.patterns)];return r},on=i=>{if(Qr.test(i))return i;let t=!1;return i.startsWith("/")?(i=i.slice(1),t=!0):i.slice(1,i.length-1).includes("/")&&(t=!0),i+=i.endsWith("/")?"**/":"/**",t?i:`**/${i}`},an=(i,t={})=>{let e=oe(i,t),s=[],r=0,n=e.patterns.concat(t.ignore||[]).concat((t.unignore||[]).map(a=>a.startsWith("!")?a:`!${a}`)),o=(a,l)=>{let c=s[s.length-1],h=a?"unignore":"ignore";c&&c.type===h?c.patterns.includes(l)||c.patterns.push(l):(s.push({type:h,path:t.path||null,patterns:[l],index:r}),r++)};for(let a of n){let l="";a.startsWith("!")&&(a=a.slice(1),l="!"),o(l,a.startsWith("/")?a.slice(1):a),o(l,on(a))}return s},ln=(i={name:"",patterns:[]})=>{let t=[i.comment||""];return i.patterns?.length&&(t.push(i.patterns.join(`
|
|
7
7
|
`)),t.push("")),t.join(`
|
|
8
|
-
`)},
|
|
9
|
-
`)};var
|
|
10
|
-
`))}async function
|
|
11
|
-
`),
|
|
8
|
+
`)},cn=(i,t={})=>{let e=oe(i,t),s=t.formatSection||ln,r=e.sections||e,n=[];for(let o of[].concat(r))n.push(s(o));return n.join(`
|
|
9
|
+
`)};var Us=oe;import mn from"p-queue";import gn from"ora";import{customAlphabet as wn}from"nanoid";var wt=class extends Error{constructor(e,s,r){super(`${e}: ${s}`);this.error=e;this.error_description=s;this.filename=r;this.name="UploadError"}},yn={maxDataSize:12*1024*1024,retryAttempts:2,retryDelay:1e3},Sn=new Bs.Agent({keepAlive:!0,maxSockets:10,keepAliveMsecs:3e3});async function bn(i){let t=It.join(i,".gitignore"),s=jt.existsSync(t)?Us(jt.readFileSync(t,"utf-8")).patterns:[];return fn("**/*",{cwd:i,onlyFiles:!0,dot:!0,absolute:!0,ignore:["node_modules/**",".cache/**","**/.DS_Store",".gitignore",".env",".env.*",".git/**","dist/**",...s]})}async function En(i,t,e,s,r,n,o){let a=async l=>{try{return await vn(i,t,e,s,r,n,o)}catch(c){if(l<o.retryAttempts)return k.warn(`Retrying upload for ${t} (attempt ${l+1})`),await new Promise(h=>setTimeout(h,o.retryDelay)),a(l+1);throw c}};return a(0)}async function vn(i,t,e,s,r,n,o){return new Promise((a,l)=>{let c=jt.statSync(i),h=It.basename(i),f=Date.now(),u=new pn({maxDataSize:o.maxDataSize}),d=jt.createReadStream(i),g=0,p=w=>{g+=w.length};d.on("data",p),u.append("file",d,{filename:h,knownLength:c.size});let y={agent:Sn,method:"POST",headers:{authorization:`Bearer ${n}`,"x-enpage-template-file-path":t,"x-enpage-template-id":s,...u.getHeaders()}},b=(e.startsWith("https")?un:Bs).request(e,y,w=>{let S="";w.on("data",E=>{S+=E}),w.on("end",()=>{let E=Date.now(),x={fileName:h,fileSize:c.size,uploadDuration:E-f,statusCode:w.statusCode??0,serverResponse:S};if(w.statusCode&&w.statusCode>=200&&w.statusCode<300)r.text=`Uploaded ${t}`,a(x);else{let R;if(w.headers["content-type"]?.startsWith("application/json")){let Y=JSON.parse(S);R=new wt(Y.error||"unknown_error",Y.error_description||"Unknown error occurred",t)}else R=new wt("unknown_error",S||"Unknown error occurred",t);r.fail(`Failed to upload ${t} [${R.error}] ${R.error_description}`),l(R)}})});b.on("error",w=>{l(new wt("request_error",w.message,t))}),dn(u,b,w=>{w&&l(new wt("pipeline_error",`Pipeline failed for ${h}: ${w.message}`,t))})})}function xn(i,t,e){e.length>0?(k.error(Ws.red(`Failed to upload ${e.length} files:`)),e.forEach(s=>{let r=s.reason;k.error(`- ${r.filename}: ${r.error_description} (${r.error})`)})):k.info(Ws.green(`Uploaded ${t.length} files successfully for template ${i}.
|
|
10
|
+
`))}async function zs(i,t,e,s=!1,r={}){let n={...yn,...r},o=new mn({concurrency:Cs}),a=await bn(t),l=a.length,c={},h=On(),f=0;for(let m of a){let b=It.relative(t,m),w=await Tn(m);c[b]=w}s&&(k.info(`Dry run mode enabled. Skipping upload.
|
|
11
|
+
`),k.info("The following files would have been uploaded:"),a.forEach(m=>k.info(`- ${m}`)),process.exit(0));let u=gn(`Uploading ${l} files...`).start(),d=a.map(m=>{let b=It.resolve(t,m),w=It.relative(t,m),S=`${ft}/v1/templates/${i}/upload/${h}`;return o.add(async()=>{let E=await En(b,w,S,i,u,e,n);return f++,E})}),g=await Promise.allSettled(d);u.stop();let p=g.filter(m=>m.status==="fulfilled"),y=g.filter(m=>m.status==="rejected");if(xn(i,p.map(m=>m.value),y),!y.length&&p.length){let m=`${ft}/v1/templates/${i}/upload/${h}/finalize`,w=await ut(m,{signatures:c});if(w.isError)return k.error(`Failed to finalize upload: ${w.data.error_description} (${w.data.error})`),{filesCount:l,uploadedFiles:p.map(S=>S.value),failedFiles:[],success:!1}}return{filesCount:l,uploadedFiles:p.map(m=>m.value),failedFiles:y,success:y.length===0}}async function Tn(i){let t=await hn.subtle.digest("SHA-1",jt.readFileSync(i));return Array.from(new Uint8Array(t)).map(e=>e.toString(16).padStart(2,"0")).join("")}function On(){let i=wn("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",5),t=new Date,e=t.getUTCFullYear(),s=(t.getUTCMonth()+1).toString().padStart(2,"0"),r=t.getUTCDate().toString().padStart(2,"0"),n=t.getUTCHours().toString().padStart(2,"0"),o=t.getUTCMinutes().toString().padStart(2,"0"),a=t.getUTCSeconds().toString().padStart(2,"0");return`${e}${s}${r}${n}${o}${a}_${i()}`}import Xs from"node:path";import z from"zod";var Gs=z.object({id:z.string().optional(),name:z.string(),description:z.string(),readme:z.record(z.string()).optional(),tags:z.array(z.string()).optional(),author:z.string(),thumbnail:z.string().url().optional(),homepage:z.string().url().optional()});import{Type as _}from"@sinclair/typebox";import{Value as nc}from"@sinclair/typebox/value";function Hs(i){for(let t in i)if(t.startsWith("$"))throw new Error(`Attribute names starting with '$' (like "${t}") are reserved for internal use. Please rename it.`);return _.Object({...An,...i},{$id:"attributes"})}var G={string(i,t="",e){return _.String({title:i,default:t,...e})},number(i,t=0,e){return _.Number({title:i,default:t,...e})},boolean(i,t=!1,e){let s={"ui:field":"switch"};return _.Boolean({title:i,default:t,...s,...e})},enum(i,t,e){let s={"ui:field":"enum","ui:display":e.displayAs||"select"},{options:r,displayAs:n,...o}=e;return _.Union(r.map(a=>_.Literal(typeof a=="string"?a:a.value,{title:typeof a=="string"?a:a.title,"ui:icon":typeof a=="string"?void 0:a.icon})),{title:i,default:t,...s,...o})},file(i,t="",e={}){return _.String({title:i,default:t,...e,format:"data-url"})},url(i,t="",e={}){return _.String({title:i,default:t,...e,format:"uri"})},color(i,t="",e){let s={"ui:field":"color"};return _.String({title:i,default:t,...s,...e})},date(i,t=new Date,e={}){return _.String({title:i,default:t.toISOString(),...e,format:"date"})},datetime(i,t=new Date,e={}){return _.String({title:i,default:t.toISOString(),...e,format:"date-time"})},geolocation(i,t,e={}){return _.Object({lat:_.Number({minimum:-90,maximum:90}),lng:_.Number({minimum:-180,maximum:180}),name:_.Optional(_.String({title:"Name"}))},{title:i,default:t,...e})}},An={$pageLanguage:G.enum("Page language","en",{options:[{value:"ar",title:"Arabic"},{value:"zh",title:"Chinese"},{value:"cs",title:"Czech"},{value:"nl",title:"Dutch"},{value:"en",title:"English"},{value:"fr",title:"French"},{value:"de",title:"German"},{value:"he",title:"Hebrew"},{value:"hi",title:"Hindi"},{value:"it",title:"Italian"},{value:"ja",title:"Japanese"},{value:"ko",title:"Korean"},{value:"fa",title:"Persian"},{value:"pl",title:"Polish"},{value:"pt",title:"Portuguese"},{value:"ru",title:"Russian"},{value:"es",title:"Spanish"},{value:"tr",title:"Turkish"},{value:"vi",title:"Vietnamese"}],"ui:group":"meta","ui:group:title":"Meta tags / SEO"}),$pagePath:G.string("Page path","/",{description:"The URL path of the page","ui:group":"location","ui:group:title":"Location","ui:group:order":1,"ui:field":"path"}),$pageTitle:G.string("Page title","Untitled",{"ui:group":"meta","ui:group:title":"Meta tags / SEO"}),$pageDescription:G.string("Page description","",{"ui:widget":"textarea","ui:options":{rows:3,widget:"textarea"},"ui:group":"meta","ui:group:title":"Meta tags / SEO"}),$pageKeywords:G.string("Page keywords","",{"ui:group":"meta","ui:group:title":"Meta tags / SEO"}),$pageLastUpdated:G.datetime("Last updated",void 0,{"ui:hidden":!0}),$pageWidth:G.enum("Page width","max-w-screen-2xl",{options:[{value:"max-w-screen-lg",title:"M",description:"Common for text-heavy content/blog posts"},{value:"max-w-screen-xl",title:"L",description:"Usefull or some landing pages"},{value:"max-w-screen-2xl",title:"XL",description:"Common width"},{value:"max-w-full",title:"Full",description:"Takes the entire space"}],description:"The maximum width of the page. Desktop only.",displayAs:"button-group","ui:group":"layout","ui:group:title":"Page Layout & Design"}),$pagePaddingVertical:G.enum("Page vertical spacing","20",{options:[{value:"0",title:"None"},{value:"10",title:"S"},{value:"20",title:"M"},{value:"30",title:"L"},{value:"50",title:"XL"}],description:"Vertical spacing. Desktop only.",displayAs:"button-group","ui:group":"layout","ui:group:title":"Page Layout & Design"}),$pagePaddingHorizontal:G.enum("Page horizontal spacing","20",{options:[{value:"0",title:"None"},{value:"10",title:"S"},{value:"20",title:"M"},{value:"30",title:"L"},{value:"50",title:"XL"}],description:"Horizontal spacing. Desktop only.",displayAs:"button-group","ui:group":"layout","ui:group:title":"Page Layout & Design"}),$backgroundColor:G.color("Page background color","#ffffff",{"ui:field":"color","ui:group":"layout","ui:group:title":"Page Layout & Design"}),$textColor:G.color("Default text color","#222222",{"ui:field":"color","ui:group":"layout","ui:group:title":"Page Layout & Design","ui:color-type":"page-text"})};import Rn from"node:fs";import{readFile as Cn}from"node:fs/promises";import kn from"fast-glob";import{fromError as _n}from"zod-validation-error";import{basename as qs,dirname as Nn,extname as Pn}from"node:path";async function Vs(i,t=k){Rn.existsSync(i)||(t.error(`\u{1F534} No enpage.config.js found!
|
|
12
12
|
Your project must have an enpage.config.js file in the root directory.
|
|
13
13
|
|
|
14
|
-
`),process.exit(1));let
|
|
15
|
-
`);let
|
|
14
|
+
`),process.exit(1));let e=await import(i),s=Nn(i),r={},n=await kn(["README.enpage.md","README.enpage.*.md"],{cwd:s,onlyFiles:!0,absolute:!0,caseSensitiveMatch:!1});for(let o of n){let a=qs(o,".md"),l=Pn(a),c=(l===".enpage"?"en":l.substring(1)).toLowerCase();t.debug(`Found template readme file (${c}): ${qs(o)}`),r[c]=await Cn(o,"utf-8")}return e.manifest.readme=r,e}function Ks(i,t){for(let s in i.datasources)!(i.datasources[s].provider||i.datasources[s].provider==="json")&&!i.datasources[s].sampleData&&(t.error(`\u{1F534} Error: Datasource "${s}" is missing sample data - nothing will be rendered during development! Please check your enpage.config.js file and add a "sampleData" key to your ${s} datasource.`),process.exit(1));i.attributes||(i.attributes=Hs({}));let e=Gs.safeParse(i.manifest);if(!e.success){t.error(`\u{1F534} Error: template manifest is invalid. Check your call to defineManifest().
|
|
15
|
+
`);let s=_n(e.error);t.error(`Hint: ${s.toString()}
|
|
16
16
|
|
|
17
|
-
`),process.exit(1)}return
|
|
18
|
-
`),process.exit(1)}let
|
|
19
|
-
`),process.exit(1));let
|
|
17
|
+
`),process.exit(1)}return i}async function Ys({options:i,args:t,logger:e}){if(!await Is(!0)){let f=re();e.error(` ${nt.redBright("Error")}: User token not found. Please run ${nt.cyan(`${f} run enpage:login`)} to authenticate or set the ${nt.cyan("ENPAGE_API_TOKEN")} environment variable.
|
|
18
|
+
`),process.exit(1)}let s=t.length?Xs.isAbsolute(t[0])?t[0]:Q(process.cwd(),t[0]):process.cwd();$t(s)||(e.error(` Template directory not found: ${s}. Aborting.
|
|
19
|
+
`),process.exit(1));let r=t.length>1?Xs.isAbsolute(t[1])?t[1]:Q(process.cwd(),t[1]):Q(s,"dist");$t(r)||(e.error(` Dist directory not found: ${r}.
|
|
20
20
|
Please run 'build' before publishing. Aborting.
|
|
21
|
-
`),process.exit(1))
|
|
22
|
-
`),process.exit(1));let
|
|
23
|
-
`),process.exit(1));let
|
|
24
|
-
`),process.exit(1)),!
|
|
25
|
-
`),process.exit(1)),
|
|
26
|
-
`),process.exit(1)}}let c=
|
|
27
|
-
`),(await
|
|
21
|
+
`),process.exit(1)),$t(Q(s,"enpage.config.js"))||(e.error(` ${nt.redBright("Error")}: file enpage.config.js not found in ${s}. Aborting.
|
|
22
|
+
`),process.exit(1));let n=await Vs(Q(s,"enpage.config.js"),e);Ks(n,e);let o=js(),a=Mn(s);a||(e.error(` ${nt.redBright("Error")}: package.json file not found in ${s}. Aborting.
|
|
23
|
+
`),process.exit(1));let l=await Fn(a);if(l||(e.error(` ${nt.redBright("Error")}: cannot read/parse package.json file in ${s}. Aborting.
|
|
24
|
+
`),process.exit(1)),!l.enpage?.id){let{data:f,isError:u,status:d}=await ut(Ps,{manifest:n.manifest});u&&(e.error(` ${nt.redBright("Error")}: Cannot register template: ${As(f)}
|
|
25
|
+
`),process.exit(1)),l.enpage??={},l.enpage.id=f.template.id;try{i.dryRun||Ln(a,JSON.stringify(l,null,2))}catch{e.error(` ${nt.redBright("Error")}: Cannot update template id in package.json file located in ${s}. Aborting.
|
|
26
|
+
`),process.exit(1)}}let c=l.enpage.id;e.info(`Submitting template to Enpage...
|
|
27
|
+
`),(await zs(c,s,o,i.dryRun)).success||(e.error(`
|
|
28
28
|
Upload failed. See details above.
|
|
29
|
-
`),process.exit(1)),
|
|
30
|
-
`)}function
|
|
31
|
-
`);let{isError:
|
|
29
|
+
`),process.exit(1)),e.success(`Template ${c} published.
|
|
30
|
+
`)}function Mn(i){return $t(Q(i,"package.json"))?Q(i,"package.json"):$t(Q(i,"template-package.json"))?Q(i,"template-package.json"):!1}function Fn(i){try{return JSON.parse(Dn(i,"utf-8"))}catch{return null}}import In from"chalk";import{confirm as jn}from"@inquirer/prompts";import $n from"open";async function Un(i,t){for(;;){let e=new URLSearchParams({grant_type:"device_code",device_code:i,client_id:Ue}),s=await ut(_s,e),{data:r,isSuccess:n}=s;if(n)return r;if(r.error==="authorization_pending")await new Promise(o=>setTimeout(o,5e3));else return t.error(`Error while polling for login: ${r.error_description??r.error}`),!1}}async function Js({options:i,logger:t}){t.info(`Logging in to Enpage...
|
|
31
|
+
`);let{isError:e,data:s}=await ut(ks,{client_id:Ue,scope:"profile,templates:publish"});e&&(t.error("Failed to get device code. Please try again."),t.error(`Error: ${s.error_description??s.error}`),process.exit(1));let{verification_uri:r,device_code:n}=s;await jn({message:"Would you like to open the login page in your browser?",default:!0}).catch(l=>{process.exit(0)})?$n(r):t.info(`
|
|
32
32
|
Please visit the following URL to login:
|
|
33
|
-
${
|
|
34
|
-
`),t.info(
|
|
33
|
+
${r}
|
|
34
|
+
`),t.info(In.gray(`
|
|
35
35
|
Waiting for login...
|
|
36
|
-
`));let
|
|
37
|
-
`),process.exitCode=0}import{build as q}from"vite";import Pt,{resolve as xe}from"node:path";import{fileURLToPath as _t}from"node:url";import{sync as Tt}from"rimraf";var Ee=_t(new URL(".",import.meta.url)),V=xe(Ee,"../builder/vite-config.js"),Lt=xe(Ee,"../builder/vite-entry-server.js");async function we({options:e,logger:t}){t.info(`Building template...
|
|
38
|
-
|
|
39
|
-
`),process.exit(0)}var J;C.name("enpage").option("-l, --logLevel <level>","[string] info | warn | error | silent | debug").option("--clearScreen","[boolean] allow/disable clear screen when logging").option("--dry-run","[boolean] run command without making changes").hook("preAction",e=>{J=H(e.optsWithGlobals().logLevel,e.optsWithGlobals().clearScreen,!0),process.removeAllListeners("warning"),process.on("warning",t=>{t.name==="DeprecationWarning"&&t.message.includes("util.isArray")||J.warnOnce(`Warning: ${t.name} - ${t.message}`)})});C.command("build").description("Build template").option("--ssr [type]",`Enable server side rendering.
|
|
36
|
+
`));let a=await Un(n,t);a||(t.error("Login failed. Please try again."),process.exit(1)),j.set({...a,...a.expires_in?{expires_at:Date.now()+a.expires_in*1e3}:{}}),t.info(`Login successful!
|
|
37
|
+
`),process.exitCode=0}import{build as Es}from"vite";import fl,{resolve as Nr}from"node:path";import{fileURLToPath as ul}from"node:url";var yi=Wr(hi(),1);var Wt=i=>{if(typeof i!="string")throw new TypeError("invalid pattern");if(i.length>65536)throw new TypeError("pattern is too long")};var Kn={"[: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]},Bt=i=>i.replace(/[[\]\\-]/g,"\\$&"),Xn=i=>i.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),fi=i=>i.join(""),ui=(i,t)=>{let e=t;if(i.charAt(e)!=="[")throw new Error("not in a brace expression");let s=[],r=[],n=e+1,o=!1,a=!1,l=!1,c=!1,h=e,f="";t:for(;n<i.length;){let p=i.charAt(n);if((p==="!"||p==="^")&&n===e+1){c=!0,n++;continue}if(p==="]"&&o&&!l){h=n+1;break}if(o=!0,p==="\\"&&!l){l=!0,n++;continue}if(p==="["&&!l){for(let[y,[m,b,w]]of Object.entries(Kn))if(i.startsWith(y,n)){if(f)return["$.",!1,i.length-e,!0];n+=y.length,w?r.push(m):s.push(m),a=a||b;continue t}}if(l=!1,f){p>f?s.push(Bt(f)+"-"+Bt(p)):p===f&&s.push(Bt(p)),f="",n++;continue}if(i.startsWith("-]",n+1)){s.push(Bt(p+"-")),n+=2;continue}if(i.startsWith("-",n+1)){f=p,n+=2;continue}s.push(Bt(p)),n++}if(h<n)return["",!1,0,!1];if(!s.length&&!r.length)return["$.",!1,i.length-e,!0];if(r.length===0&&s.length===1&&/^\\?.$/.test(s[0])&&!c){let p=s[0].length===2?s[0].slice(-1):s[0];return[Xn(p),!1,h-e,!1]}let u="["+(c?"^":"")+fi(s)+"]",d="["+(c?"":"^")+fi(r)+"]";return[s.length&&r.length?"("+u+"|"+d+")":s.length?u:d,a,h-e,!0]};var H=(i,{windowsPathsNoEscape:t=!1}={})=>t?i.replace(/\[([^\/\\])\]/g,"$1"):i.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1");var Yn=new Set(["!","?","+","*","@"]),di=i=>Yn.has(i),Jn="(?!(?:^|/)\\.\\.?(?:$|/))",ae="(?!\\.)",Zn=new Set(["[","."]),Qn=new Set(["..","."]),to=new Set("().*{}+?[]^$\\!"),eo=i=>i.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Ge="[^/]",pi=Ge+"*?",mi=Ge+"+?",yt=class i{type;#t;#e;#n=!1;#i=[];#o;#b;#c;#f=!1;#a;#l;#r=!1;constructor(t,e,s={}){this.type=t,t&&(this.#e=!0),this.#o=e,this.#t=this.#o?this.#o.#t:this,this.#a=this.#t===this?s:this.#t.#a,this.#c=this.#t===this?[]:this.#t.#c,t==="!"&&!this.#t.#f&&this.#c.push(this),this.#b=this.#o?this.#o.#i.length:0}get hasMagic(){if(this.#e!==void 0)return this.#e;for(let t of this.#i)if(typeof t!="string"&&(t.type||t.hasMagic))return this.#e=!0;return this.#e}toString(){return this.#l!==void 0?this.#l:this.type?this.#l=this.type+"("+this.#i.map(t=>String(t)).join("|")+")":this.#l=this.#i.map(t=>String(t)).join("")}#g(){if(this!==this.#t)throw new Error("should only call on root");if(this.#f)return this;this.toString(),this.#f=!0;let t;for(;t=this.#c.pop();){if(t.type!=="!")continue;let e=t,s=e.#o;for(;s;){for(let r=e.#b+1;!s.type&&r<s.#i.length;r++)for(let n of t.#i){if(typeof n=="string")throw new Error("string part in extglob AST??");n.copyIn(s.#i[r])}e=s,s=e.#o}}return this}push(...t){for(let e of t)if(e!==""){if(typeof e!="string"&&!(e instanceof i&&e.#o===this))throw new Error("invalid part: "+e);this.#i.push(e)}}toJSON(){let t=this.type===null?this.#i.slice().map(e=>typeof e=="string"?e:e.toJSON()):[this.type,...this.#i.map(e=>e.toJSON())];return this.isStart()&&!this.type&&t.unshift([]),this.isEnd()&&(this===this.#t||this.#t.#f&&this.#o?.type==="!")&&t.push({}),t}isStart(){if(this.#t===this)return!0;if(!this.#o?.isStart())return!1;if(this.#b===0)return!0;let t=this.#o;for(let e=0;e<this.#b;e++){let s=t.#i[e];if(!(s instanceof i&&s.type==="!"))return!1}return!0}isEnd(){if(this.#t===this||this.#o?.type==="!")return!0;if(!this.#o?.isEnd())return!1;if(!this.type)return this.#o?.isEnd();let t=this.#o?this.#o.#i.length:0;return this.#b===t-1}copyIn(t){typeof t=="string"?this.push(t):this.push(t.clone(this))}clone(t){let e=new i(this.type,t);for(let s of this.#i)e.copyIn(s);return e}static#w(t,e,s,r){let n=!1,o=!1,a=-1,l=!1;if(e.type===null){let d=s,g="";for(;d<t.length;){let p=t.charAt(d++);if(n||p==="\\"){n=!n,g+=p;continue}if(o){d===a+1?(p==="^"||p==="!")&&(l=!0):p==="]"&&!(d===a+2&&l)&&(o=!1),g+=p;continue}else if(p==="["){o=!0,a=d,l=!1,g+=p;continue}if(!r.noext&&di(p)&&t.charAt(d)==="("){e.push(g),g="";let y=new i(p,e);d=i.#w(t,y,d,r),e.push(y);continue}g+=p}return e.push(g),d}let c=s+1,h=new i(null,e),f=[],u="";for(;c<t.length;){let d=t.charAt(c++);if(n||d==="\\"){n=!n,u+=d;continue}if(o){c===a+1?(d==="^"||d==="!")&&(l=!0):d==="]"&&!(c===a+2&&l)&&(o=!1),u+=d;continue}else if(d==="["){o=!0,a=c,l=!1,u+=d;continue}if(di(d)&&t.charAt(c)==="("){h.push(u),u="";let g=new i(d,h);h.push(g),c=i.#w(t,g,c,r);continue}if(d==="|"){h.push(u),u="",f.push(h),h=new i(null,e);continue}if(d===")")return u===""&&e.#i.length===0&&(e.#r=!0),h.push(u),u="",e.push(...f,h),c;u+=d}return e.type=null,e.#e=void 0,e.#i=[t.substring(s-1)],c}static fromGlob(t,e={}){let s=new i(null,void 0,e);return i.#w(t,s,0,e),s}toMMPattern(){if(this!==this.#t)return this.#t.toMMPattern();let t=this.toString(),[e,s,r,n]=this.toRegExpSource();if(!(r||this.#e||this.#a.nocase&&!this.#a.nocaseMagicOnly&&t.toUpperCase()!==t.toLowerCase()))return s;let a=(this.#a.nocase?"i":"")+(n?"u":"");return Object.assign(new RegExp(`^${e}$`,a),{_src:e,_glob:t})}get options(){return this.#a}toRegExpSource(t){let e=t??!!this.#a.dot;if(this.#t===this&&this.#g(),!this.type){let l=this.isStart()&&this.isEnd(),c=this.#i.map(d=>{let[g,p,y,m]=typeof d=="string"?i.#u(d,this.#e,l):d.toRegExpSource(t);return this.#e=this.#e||y,this.#n=this.#n||m,g}).join(""),h="";if(this.isStart()&&typeof this.#i[0]=="string"&&!(this.#i.length===1&&Qn.has(this.#i[0]))){let g=Zn,p=e&&g.has(c.charAt(0))||c.startsWith("\\.")&&g.has(c.charAt(2))||c.startsWith("\\.\\.")&&g.has(c.charAt(4)),y=!e&&!t&&g.has(c.charAt(0));h=p?Jn:y?ae:""}let f="";return this.isEnd()&&this.#t.#f&&this.#o?.type==="!"&&(f="(?:$|\\/)"),[h+c+f,H(c),this.#e=!!this.#e,this.#n]}let s=this.type==="*"||this.type==="+",r=this.type==="!"?"(?:(?!(?:":"(?:",n=this.#d(e);if(this.isStart()&&this.isEnd()&&!n&&this.type!=="!"){let l=this.toString();return this.#i=[l],this.type=null,this.#e=void 0,[l,H(this.toString()),!1,!1]}let o=!s||t||e||!ae?"":this.#d(!0);o===n&&(o=""),o&&(n=`(?:${n})(?:${o})*?`);let a="";if(this.type==="!"&&this.#r)a=(this.isStart()&&!e?ae:"")+mi;else{let l=this.type==="!"?"))"+(this.isStart()&&!e&&!t?ae:"")+pi+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&o?")":this.type==="*"&&o?")?":`)${this.type}`;a=r+n+l}return[a,H(n),this.#e=!!this.#e,this.#n]}#d(t){return this.#i.map(e=>{if(typeof e=="string")throw new Error("string type in extglob ast??");let[s,r,n,o]=e.toRegExpSource(t);return this.#n=this.#n||o,s}).filter(e=>!(this.isStart()&&this.isEnd())||!!e).join("|")}static#u(t,e,s=!1){let r=!1,n="",o=!1;for(let a=0;a<t.length;a++){let l=t.charAt(a);if(r){r=!1,n+=(to.has(l)?"\\":"")+l;continue}if(l==="\\"){a===t.length-1?n+="\\\\":r=!0;continue}if(l==="["){let[c,h,f,u]=ui(t,a);if(f){n+=c,o=o||h,a+=f-1,e=e||u;continue}}if(l==="*"){s&&t==="*"?n+=mi:n+=pi,e=!0;continue}if(l==="?"){n+=Ge,e=!0;continue}n+=eo(l)}return[n,H(t),!!e,o]}};var St=(i,{windowsPathsNoEscape:t=!1}={})=>t?i.replace(/[?*()[\]]/g,"[$&]"):i.replace(/[?*()[\]\\]/g,"\\$&");var D=(i,t,e={})=>(Wt(t),!e.nocomment&&t.charAt(0)==="#"?!1:new F(t,e).match(i)),so=/^\*+([^+@!?\*\[\(]*)$/,io=i=>t=>!t.startsWith(".")&&t.endsWith(i),ro=i=>t=>t.endsWith(i),no=i=>(i=i.toLowerCase(),t=>!t.startsWith(".")&&t.toLowerCase().endsWith(i)),oo=i=>(i=i.toLowerCase(),t=>t.toLowerCase().endsWith(i)),ao=/^\*+\.\*+$/,lo=i=>!i.startsWith(".")&&i.includes("."),co=i=>i!=="."&&i!==".."&&i.includes("."),ho=/^\.\*+$/,fo=i=>i!=="."&&i!==".."&&i.startsWith("."),uo=/^\*+$/,po=i=>i.length!==0&&!i.startsWith("."),mo=i=>i.length!==0&&i!=="."&&i!=="..",go=/^\?+([^+@!?\*\[\(]*)?$/,wo=([i,t=""])=>{let e=Si([i]);return t?(t=t.toLowerCase(),s=>e(s)&&s.toLowerCase().endsWith(t)):e},yo=([i,t=""])=>{let e=bi([i]);return t?(t=t.toLowerCase(),s=>e(s)&&s.toLowerCase().endsWith(t)):e},So=([i,t=""])=>{let e=bi([i]);return t?s=>e(s)&&s.endsWith(t):e},bo=([i,t=""])=>{let e=Si([i]);return t?s=>e(s)&&s.endsWith(t):e},Si=([i])=>{let t=i.length;return e=>e.length===t&&!e.startsWith(".")},bi=([i])=>{let t=i.length;return e=>e.length===t&&e!=="."&&e!==".."},Ei=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",gi={win32:{sep:"\\"},posix:{sep:"/"}},Eo=Ei==="win32"?gi.win32.sep:gi.posix.sep;D.sep=Eo;var C=Symbol("globstar **");D.GLOBSTAR=C;var vo="[^/]",xo=vo+"*?",To="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",Oo="(?:(?!(?:\\/|^)\\.).)*?",Ao=(i,t={})=>e=>D(e,i,t);D.filter=Ao;var $=(i,t={})=>Object.assign({},i,t),Ro=i=>{if(!i||typeof i!="object"||!Object.keys(i).length)return D;let t=D;return Object.assign((s,r,n={})=>t(s,r,$(i,n)),{Minimatch:class extends t.Minimatch{constructor(r,n={}){super(r,$(i,n))}static defaults(r){return t.defaults($(i,r)).Minimatch}},AST:class extends t.AST{constructor(r,n,o={}){super(r,n,$(i,o))}static fromGlob(r,n={}){return t.AST.fromGlob(r,$(i,n))}},unescape:(s,r={})=>t.unescape(s,$(i,r)),escape:(s,r={})=>t.escape(s,$(i,r)),filter:(s,r={})=>t.filter(s,$(i,r)),defaults:s=>t.defaults($(i,s)),makeRe:(s,r={})=>t.makeRe(s,$(i,r)),braceExpand:(s,r={})=>t.braceExpand(s,$(i,r)),match:(s,r,n={})=>t.match(s,r,$(i,n)),sep:t.sep,GLOBSTAR:C})};D.defaults=Ro;var vi=(i,t={})=>(Wt(i),t.nobrace||!/\{(?:(?!\{).)*\}/.test(i)?[i]:(0,yi.default)(i));D.braceExpand=vi;var Co=(i,t={})=>new F(i,t).makeRe();D.makeRe=Co;var ko=(i,t,e={})=>{let s=new F(t,e);return i=i.filter(r=>s.match(r)),s.options.nonull&&!i.length&&i.push(t),i};D.match=ko;var wi=/[?*]|[+@!]\(.*?\)|\[|\]/,_o=i=>i.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),F=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;regexp;constructor(t,e={}){Wt(t),e=e||{},this.options=e,this.pattern=t,this.platform=e.platform||Ei,this.isWindows=this.platform==="win32",this.windowsPathsNoEscape=!!e.windowsPathsNoEscape||e.allowWindowsEscape===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,"/")),this.preserveMultipleSlashes=!!e.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!e.nonegate,this.comment=!1,this.empty=!1,this.partial=!!e.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=e.windowsNoMagicRoot!==void 0?e.windowsNoMagicRoot:!!(this.isWindows&&this.nocase),this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(let t of this.set)for(let e of t)if(typeof e!="string")return!0;return!1}debug(...t){}make(){let t=this.pattern,e=this.options;if(!e.nocomment&&t.charAt(0)==="#"){this.comment=!0;return}if(!t){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],e.debug&&(this.debug=(...n)=>console.error(...n)),this.debug(this.pattern,this.globSet);let s=this.globSet.map(n=>this.slashSplit(n));this.globParts=this.preprocess(s),this.debug(this.pattern,this.globParts);let r=this.globParts.map((n,o,a)=>{if(this.isWindows&&this.windowsNoMagicRoot){let l=n[0]===""&&n[1]===""&&(n[2]==="?"||!wi.test(n[2]))&&!wi.test(n[3]),c=/^[a-z]:/i.test(n[0]);if(l)return[...n.slice(0,4),...n.slice(4).map(h=>this.parse(h))];if(c)return[n[0],...n.slice(1).map(h=>this.parse(h))]}return n.map(l=>this.parse(l))});if(this.debug(this.pattern,r),this.set=r.filter(n=>n.indexOf(!1)===-1),this.isWindows)for(let n=0;n<this.set.length;n++){let o=this.set[n];o[0]===""&&o[1]===""&&this.globParts[n][2]==="?"&&typeof o[3]=="string"&&/^[a-z]:$/i.test(o[3])&&(o[2]="?")}this.debug(this.pattern,this.set)}preprocess(t){if(this.options.noglobstar)for(let s=0;s<t.length;s++)for(let r=0;r<t[s].length;r++)t[s][r]==="**"&&(t[s][r]="*");let{optimizationLevel:e=1}=this.options;return e>=2?(t=this.firstPhasePreProcess(t),t=this.secondPhasePreProcess(t)):e>=1?t=this.levelOneOptimize(t):t=this.adjascentGlobstarOptimize(t),t}adjascentGlobstarOptimize(t){return t.map(e=>{let s=-1;for(;(s=e.indexOf("**",s+1))!==-1;){let r=s;for(;e[r+1]==="**";)r++;r!==s&&e.splice(s,r-s)}return e})}levelOneOptimize(t){return t.map(e=>(e=e.reduce((s,r)=>{let n=s[s.length-1];return r==="**"&&n==="**"?s:r===".."&&n&&n!==".."&&n!=="."&&n!=="**"?(s.pop(),s):(s.push(r),s)},[]),e.length===0?[""]:e))}levelTwoFileOptimize(t){Array.isArray(t)||(t=this.slashSplit(t));let e=!1;do{if(e=!1,!this.preserveMultipleSlashes){for(let r=1;r<t.length-1;r++){let n=t[r];r===1&&n===""&&t[0]===""||(n==="."||n==="")&&(e=!0,t.splice(r,1),r--)}t[0]==="."&&t.length===2&&(t[1]==="."||t[1]==="")&&(e=!0,t.pop())}let s=0;for(;(s=t.indexOf("..",s+1))!==-1;){let r=t[s-1];r&&r!=="."&&r!==".."&&r!=="**"&&(e=!0,t.splice(s-1,2),s-=2)}}while(e);return t.length===0?[""]:t}firstPhasePreProcess(t){let e=!1;do{e=!1;for(let s of t){let r=-1;for(;(r=s.indexOf("**",r+1))!==-1;){let o=r;for(;s[o+1]==="**";)o++;o>r&&s.splice(r+1,o-r);let a=s[r+1],l=s[r+2],c=s[r+3];if(a!==".."||!l||l==="."||l===".."||!c||c==="."||c==="..")continue;e=!0,s.splice(r,1);let h=s.slice(0);h[r]="**",t.push(h),r--}if(!this.preserveMultipleSlashes){for(let o=1;o<s.length-1;o++){let a=s[o];o===1&&a===""&&s[0]===""||(a==="."||a==="")&&(e=!0,s.splice(o,1),o--)}s[0]==="."&&s.length===2&&(s[1]==="."||s[1]==="")&&(e=!0,s.pop())}let n=0;for(;(n=s.indexOf("..",n+1))!==-1;){let o=s[n-1];if(o&&o!=="."&&o!==".."&&o!=="**"){e=!0;let l=n===1&&s[n+1]==="**"?["."]:[];s.splice(n-1,2,...l),s.length===0&&s.push(""),n-=2}}}}while(e);return t}secondPhasePreProcess(t){for(let e=0;e<t.length-1;e++)for(let s=e+1;s<t.length;s++){let r=this.partsMatch(t[e],t[s],!this.preserveMultipleSlashes);if(r){t[e]=[],t[s]=r;break}}return t.filter(e=>e.length)}partsMatch(t,e,s=!1){let r=0,n=0,o=[],a="";for(;r<t.length&&n<e.length;)if(t[r]===e[n])o.push(a==="b"?e[n]:t[r]),r++,n++;else if(s&&t[r]==="**"&&e[n]===t[r+1])o.push(t[r]),r++;else if(s&&e[n]==="**"&&t[r]===e[n+1])o.push(e[n]),n++;else if(t[r]==="*"&&e[n]&&(this.options.dot||!e[n].startsWith("."))&&e[n]!=="**"){if(a==="b")return!1;a="a",o.push(t[r]),r++,n++}else if(e[n]==="*"&&t[r]&&(this.options.dot||!t[r].startsWith("."))&&t[r]!=="**"){if(a==="a")return!1;a="b",o.push(e[n]),r++,n++}else return!1;return t.length===e.length&&o}parseNegate(){if(this.nonegate)return;let t=this.pattern,e=!1,s=0;for(let r=0;r<t.length&&t.charAt(r)==="!";r++)e=!e,s++;s&&(this.pattern=t.slice(s)),this.negate=e}matchOne(t,e,s=!1){let r=this.options;if(this.isWindows){let p=typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0]),y=!p&&t[0]===""&&t[1]===""&&t[2]==="?"&&/^[a-z]:$/i.test(t[3]),m=typeof e[0]=="string"&&/^[a-z]:$/i.test(e[0]),b=!m&&e[0]===""&&e[1]===""&&e[2]==="?"&&typeof e[3]=="string"&&/^[a-z]:$/i.test(e[3]),w=y?3:p?0:void 0,S=b?3:m?0:void 0;if(typeof w=="number"&&typeof S=="number"){let[E,x]=[t[w],e[S]];E.toLowerCase()===x.toLowerCase()&&(e[S]=E,S>w?e=e.slice(S):w>S&&(t=t.slice(w)))}}let{optimizationLevel:n=1}=this.options;n>=2&&(t=this.levelTwoFileOptimize(t)),this.debug("matchOne",this,{file:t,pattern:e}),this.debug("matchOne",t.length,e.length);for(var o=0,a=0,l=t.length,c=e.length;o<l&&a<c;o++,a++){this.debug("matchOne loop");var h=e[a],f=t[o];if(this.debug(e,h,f),h===!1)return!1;if(h===C){this.debug("GLOBSTAR",[e,h,f]);var u=o,d=a+1;if(d===c){for(this.debug("** at the end");o<l;o++)if(t[o]==="."||t[o]===".."||!r.dot&&t[o].charAt(0)===".")return!1;return!0}for(;u<l;){var g=t[u];if(this.debug(`
|
|
38
|
+
globstar while`,t,u,e,d,g),this.matchOne(t.slice(u),e.slice(d),s))return this.debug("globstar found match!",u,l,g),!0;if(g==="."||g===".."||!r.dot&&g.charAt(0)==="."){this.debug("dot detected!",t,u,e,d);break}this.debug("globstar swallow a segment, and continue"),u++}return!!(s&&(this.debug(`
|
|
39
|
+
>>> no match, partial?`,t,u,e,d),u===l))}let p;if(typeof h=="string"?(p=f===h,this.debug("string match",h,f,p)):(p=h.test(f),this.debug("pattern match",h,f,p)),!p)return!1}if(o===l&&a===c)return!0;if(o===l)return s;if(a===c)return o===l-1&&t[o]==="";throw new Error("wtf?")}braceExpand(){return vi(this.pattern,this.options)}parse(t){Wt(t);let e=this.options;if(t==="**")return C;if(t==="")return"";let s,r=null;(s=t.match(uo))?r=e.dot?mo:po:(s=t.match(so))?r=(e.nocase?e.dot?oo:no:e.dot?ro:io)(s[1]):(s=t.match(go))?r=(e.nocase?e.dot?yo:wo:e.dot?So:bo)(s):(s=t.match(ao))?r=e.dot?co:lo:(s=t.match(ho))&&(r=fo);let n=yt.fromGlob(t,this.options).toMMPattern();return r&&typeof n=="object"&&Reflect.defineProperty(n,"test",{value:r}),n}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let t=this.set;if(!t.length)return this.regexp=!1,this.regexp;let e=this.options,s=e.noglobstar?xo:e.dot?To:Oo,r=new Set(e.nocase?["i"]:[]),n=t.map(l=>{let c=l.map(h=>{if(h instanceof RegExp)for(let f of h.flags.split(""))r.add(f);return typeof h=="string"?_o(h):h===C?C:h._src});return c.forEach((h,f)=>{let u=c[f+1],d=c[f-1];h!==C||d===C||(d===void 0?u!==void 0&&u!==C?c[f+1]="(?:\\/|"+s+"\\/)?"+u:c[f]=s:u===void 0?c[f-1]=d+"(?:\\/|"+s+")?":u!==C&&(c[f-1]=d+"(?:\\/|\\/"+s+"\\/)"+u,c[f+1]=C))}),c.filter(h=>h!==C).join("/")}).join("|"),[o,a]=t.length>1?["(?:",")"]:["",""];n="^"+o+n+a+"$",this.negate&&(n="^(?!"+n+").+$");try{this.regexp=new RegExp(n,[...r].join(""))}catch{this.regexp=!1}return this.regexp}slashSplit(t){return this.preserveMultipleSlashes?t.split("/"):this.isWindows&&/^\/\/[^\/]+/.test(t)?["",...t.split(/\/+/)]:t.split(/\/+/)}match(t,e=this.partial){if(this.debug("match",t,this.pattern),this.comment)return!1;if(this.empty)return t==="";if(t==="/"&&e)return!0;let s=this.options;this.isWindows&&(t=t.split("\\").join("/"));let r=this.slashSplit(t);this.debug(this.pattern,"split",r);let n=this.set;this.debug(this.pattern,"set",n);let o=r[r.length-1];if(!o)for(let a=r.length-2;!o&&a>=0;a--)o=r[a];for(let a=0;a<n.length;a++){let l=n[a],c=r;if(s.matchBase&&l.length===1&&(c=[o]),this.matchOne(c,l,e))return s.flipNegate?!0:!this.negate}return s.flipNegate?!1:this.negate}static defaults(t){return D.defaults(t).Minimatch}};D.AST=yt;D.Minimatch=F;D.escape=St;D.unescape=H;import{fileURLToPath as la}from"node:url";var bt=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,Ti=new Set,He=typeof process=="object"&&process?process:{},Oi=(i,t,e,s)=>{typeof He.emitWarning=="function"?He.emitWarning(i,t,e,s):console.error(`[${e}] ${t}: ${i}`)},le=globalThis.AbortController,xi=globalThis.AbortSignal;if(typeof le>"u"){xi=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(s,r){this._onabort.push(r)}},le=class{constructor(){t()}signal=new xi;abort(s){if(!this.signal.aborted){this.signal.reason=s,this.signal.aborted=!0;for(let r of this.signal._onabort)r(s);this.signal.onabort?.(s)}}};let i=He.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",t=()=>{i&&(i=!1,Oi("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",t))}}var No=i=>!Ti.has(i),eh=Symbol("type"),ot=i=>i&&i===Math.floor(i)&&i>0&&isFinite(i),Ai=i=>ot(i)?i<=Math.pow(2,8)?Uint8Array:i<=Math.pow(2,16)?Uint16Array:i<=Math.pow(2,32)?Uint32Array:i<=Number.MAX_SAFE_INTEGER?Et:null:null,Et=class extends Array{constructor(t){super(t),this.fill(0)}},qe=class i{heap;length;static#t=!1;static create(t){let e=Ai(t);if(!e)return[];i.#t=!0;let s=new i(t,e);return i.#t=!1,s}constructor(t,e){if(!i.#t)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new e(t),this.length=0}push(t){this.heap[this.length++]=t}pop(){return this.heap[--this.length]}},zt=class i{#t;#e;#n;#i;#o;#b;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#c;#f;#a;#l;#r;#g;#w;#d;#u;#x;#m;#T;#O;#S;#E;#v;#p;static unsafeExposeInternals(t){return{starts:t.#O,ttls:t.#S,sizes:t.#T,keyMap:t.#a,keyList:t.#l,valList:t.#r,next:t.#g,prev:t.#w,get head(){return t.#d},get tail(){return t.#u},free:t.#x,isBackgroundFetch:e=>t.#h(e),backgroundFetch:(e,s,r,n)=>t.#j(e,s,r,n),moveToTail:e=>t.#U(e),indexes:e=>t.#R(e),rindexes:e=>t.#C(e),isStale:e=>t.#y(e)}}get max(){return this.#t}get maxSize(){return this.#e}get calculatedSize(){return this.#f}get size(){return this.#c}get fetchMethod(){return this.#o}get memoMethod(){return this.#b}get dispose(){return this.#n}get disposeAfter(){return this.#i}constructor(t){let{max:e=0,ttl:s,ttlResolution:r=1,ttlAutopurge:n,updateAgeOnGet:o,updateAgeOnHas:a,allowStale:l,dispose:c,disposeAfter:h,noDisposeOnSet:f,noUpdateTTL:u,maxSize:d=0,maxEntrySize:g=0,sizeCalculation:p,fetchMethod:y,memoMethod:m,noDeleteOnFetchRejection:b,noDeleteOnStaleGet:w,allowStaleOnFetchRejection:S,allowStaleOnFetchAbort:E,ignoreFetchAbort:x}=t;if(e!==0&&!ot(e))throw new TypeError("max option must be a nonnegative integer");let R=e?Ai(e):Array;if(!R)throw new Error("invalid max value: "+e);if(this.#t=e,this.#e=d,this.maxEntrySize=g||this.#e,this.sizeCalculation=p,this.sizeCalculation){if(!this.#e&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(m!==void 0&&typeof m!="function")throw new TypeError("memoMethod must be a function if defined");if(this.#b=m,y!==void 0&&typeof y!="function")throw new TypeError("fetchMethod must be a function if specified");if(this.#o=y,this.#v=!!y,this.#a=new Map,this.#l=new Array(e).fill(void 0),this.#r=new Array(e).fill(void 0),this.#g=new R(e),this.#w=new R(e),this.#d=0,this.#u=0,this.#x=qe.create(e),this.#c=0,this.#f=0,typeof c=="function"&&(this.#n=c),typeof h=="function"?(this.#i=h,this.#m=[]):(this.#i=void 0,this.#m=void 0),this.#E=!!this.#n,this.#p=!!this.#i,this.noDisposeOnSet=!!f,this.noUpdateTTL=!!u,this.noDeleteOnFetchRejection=!!b,this.allowStaleOnFetchRejection=!!S,this.allowStaleOnFetchAbort=!!E,this.ignoreFetchAbort=!!x,this.maxEntrySize!==0){if(this.#e!==0&&!ot(this.#e))throw new TypeError("maxSize must be a positive integer if specified");if(!ot(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#_()}if(this.allowStale=!!l,this.noDeleteOnStaleGet=!!w,this.updateAgeOnGet=!!o,this.updateAgeOnHas=!!a,this.ttlResolution=ot(r)||r===0?r:1,this.ttlAutopurge=!!n,this.ttl=s||0,this.ttl){if(!ot(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#k()}if(this.#t===0&&this.ttl===0&&this.#e===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#t&&!this.#e){let Y="LRU_CACHE_UNBOUNDED";No(Y)&&(Ti.add(Y),Oi("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",Y,i))}}getRemainingTTL(t){return this.#a.has(t)?1/0:0}#k(){let t=new Et(this.#t),e=new Et(this.#t);this.#S=t,this.#O=e,this.#P=(n,o,a=bt.now())=>{if(e[n]=o!==0?a:0,t[n]=o,o!==0&&this.ttlAutopurge){let l=setTimeout(()=>{this.#y(n)&&this.#N(this.#l[n],"expire")},o+1);l.unref&&l.unref()}},this.#A=n=>{e[n]=t[n]!==0?bt.now():0},this.#s=(n,o)=>{if(t[o]){let a=t[o],l=e[o];if(!a||!l)return;n.ttl=a,n.start=l,n.now=s||r();let c=n.now-l;n.remainingTTL=a-c}};let s=0,r=()=>{let n=bt.now();if(this.ttlResolution>0){s=n;let o=setTimeout(()=>s=0,this.ttlResolution);o.unref&&o.unref()}return n};this.getRemainingTTL=n=>{let o=this.#a.get(n);if(o===void 0)return 0;let a=t[o],l=e[o];if(!a||!l)return 1/0;let c=(s||r())-l;return a-c},this.#y=n=>{let o=e[n],a=t[n];return!!a&&!!o&&(s||r())-o>a}}#A=()=>{};#s=()=>{};#P=()=>{};#y=()=>!1;#_(){let t=new Et(this.#t);this.#f=0,this.#T=t,this.#D=e=>{this.#f-=t[e],t[e]=0},this.#M=(e,s,r,n)=>{if(this.#h(s))return 0;if(!ot(r))if(n){if(typeof n!="function")throw new TypeError("sizeCalculation must be a function");if(r=n(s,e),!ot(r))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return r},this.#L=(e,s,r)=>{if(t[e]=s,this.#e){let n=this.#e-t[e];for(;this.#f>n;)this.#I(!0)}this.#f+=t[e],r&&(r.entrySize=s,r.totalCalculatedSize=this.#f)}}#D=t=>{};#L=(t,e,s)=>{};#M=(t,e,s,r)=>{if(s||r)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#R({allowStale:t=this.allowStale}={}){if(this.#c)for(let e=this.#u;!(!this.#F(e)||((t||!this.#y(e))&&(yield e),e===this.#d));)e=this.#w[e]}*#C({allowStale:t=this.allowStale}={}){if(this.#c)for(let e=this.#d;!(!this.#F(e)||((t||!this.#y(e))&&(yield e),e===this.#u));)e=this.#g[e]}#F(t){return t!==void 0&&this.#a.get(this.#l[t])===t}*entries(){for(let t of this.#R())this.#r[t]!==void 0&&this.#l[t]!==void 0&&!this.#h(this.#r[t])&&(yield[this.#l[t],this.#r[t]])}*rentries(){for(let t of this.#C())this.#r[t]!==void 0&&this.#l[t]!==void 0&&!this.#h(this.#r[t])&&(yield[this.#l[t],this.#r[t]])}*keys(){for(let t of this.#R()){let e=this.#l[t];e!==void 0&&!this.#h(this.#r[t])&&(yield e)}}*rkeys(){for(let t of this.#C()){let e=this.#l[t];e!==void 0&&!this.#h(this.#r[t])&&(yield e)}}*values(){for(let t of this.#R())this.#r[t]!==void 0&&!this.#h(this.#r[t])&&(yield this.#r[t])}*rvalues(){for(let t of this.#C())this.#r[t]!==void 0&&!this.#h(this.#r[t])&&(yield this.#r[t])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(t,e={}){for(let s of this.#R()){let r=this.#r[s],n=this.#h(r)?r.__staleWhileFetching:r;if(n!==void 0&&t(n,this.#l[s],this))return this.get(this.#l[s],e)}}forEach(t,e=this){for(let s of this.#R()){let r=this.#r[s],n=this.#h(r)?r.__staleWhileFetching:r;n!==void 0&&t.call(e,n,this.#l[s],this)}}rforEach(t,e=this){for(let s of this.#C()){let r=this.#r[s],n=this.#h(r)?r.__staleWhileFetching:r;n!==void 0&&t.call(e,n,this.#l[s],this)}}purgeStale(){let t=!1;for(let e of this.#C({allowStale:!0}))this.#y(e)&&(this.#N(this.#l[e],"expire"),t=!0);return t}info(t){let e=this.#a.get(t);if(e===void 0)return;let s=this.#r[e],r=this.#h(s)?s.__staleWhileFetching:s;if(r===void 0)return;let n={value:r};if(this.#S&&this.#O){let o=this.#S[e],a=this.#O[e];if(o&&a){let l=o-(bt.now()-a);n.ttl=l,n.start=Date.now()}}return this.#T&&(n.size=this.#T[e]),n}dump(){let t=[];for(let e of this.#R({allowStale:!0})){let s=this.#l[e],r=this.#r[e],n=this.#h(r)?r.__staleWhileFetching:r;if(n===void 0||s===void 0)continue;let o={value:n};if(this.#S&&this.#O){o.ttl=this.#S[e];let a=bt.now()-this.#O[e];o.start=Math.floor(Date.now()-a)}this.#T&&(o.size=this.#T[e]),t.unshift([s,o])}return t}load(t){this.clear();for(let[e,s]of t){if(s.start){let r=Date.now()-s.start;s.start=bt.now()-r}this.set(e,s.value,s)}}set(t,e,s={}){if(e===void 0)return this.delete(t),this;let{ttl:r=this.ttl,start:n,noDisposeOnSet:o=this.noDisposeOnSet,sizeCalculation:a=this.sizeCalculation,status:l}=s,{noUpdateTTL:c=this.noUpdateTTL}=s,h=this.#M(t,e,s.size||0,a);if(this.maxEntrySize&&h>this.maxEntrySize)return l&&(l.set="miss",l.maxEntrySizeExceeded=!0),this.#N(t,"set"),this;let f=this.#c===0?void 0:this.#a.get(t);if(f===void 0)f=this.#c===0?this.#u:this.#x.length!==0?this.#x.pop():this.#c===this.#t?this.#I(!1):this.#c,this.#l[f]=t,this.#r[f]=e,this.#a.set(t,f),this.#g[this.#u]=f,this.#w[f]=this.#u,this.#u=f,this.#c++,this.#L(f,h,l),l&&(l.set="add"),c=!1;else{this.#U(f);let u=this.#r[f];if(e!==u){if(this.#v&&this.#h(u)){u.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:d}=u;d!==void 0&&!o&&(this.#E&&this.#n?.(d,t,"set"),this.#p&&this.#m?.push([d,t,"set"]))}else o||(this.#E&&this.#n?.(u,t,"set"),this.#p&&this.#m?.push([u,t,"set"]));if(this.#D(f),this.#L(f,h,l),this.#r[f]=e,l){l.set="replace";let d=u&&this.#h(u)?u.__staleWhileFetching:u;d!==void 0&&(l.oldValue=d)}}else l&&(l.set="update")}if(r!==0&&!this.#S&&this.#k(),this.#S&&(c||this.#P(f,r,n),l&&this.#s(l,f)),!o&&this.#p&&this.#m){let u=this.#m,d;for(;d=u?.shift();)this.#i?.(...d)}return this}pop(){try{for(;this.#c;){let t=this.#r[this.#d];if(this.#I(!0),this.#h(t)){if(t.__staleWhileFetching)return t.__staleWhileFetching}else if(t!==void 0)return t}}finally{if(this.#p&&this.#m){let t=this.#m,e;for(;e=t?.shift();)this.#i?.(...e)}}}#I(t){let e=this.#d,s=this.#l[e],r=this.#r[e];return this.#v&&this.#h(r)?r.__abortController.abort(new Error("evicted")):(this.#E||this.#p)&&(this.#E&&this.#n?.(r,s,"evict"),this.#p&&this.#m?.push([r,s,"evict"])),this.#D(e),t&&(this.#l[e]=void 0,this.#r[e]=void 0,this.#x.push(e)),this.#c===1?(this.#d=this.#u=0,this.#x.length=0):this.#d=this.#g[e],this.#a.delete(s),this.#c--,e}has(t,e={}){let{updateAgeOnHas:s=this.updateAgeOnHas,status:r}=e,n=this.#a.get(t);if(n!==void 0){let o=this.#r[n];if(this.#h(o)&&o.__staleWhileFetching===void 0)return!1;if(this.#y(n))r&&(r.has="stale",this.#s(r,n));else return s&&this.#A(n),r&&(r.has="hit",this.#s(r,n)),!0}else r&&(r.has="miss");return!1}peek(t,e={}){let{allowStale:s=this.allowStale}=e,r=this.#a.get(t);if(r===void 0||!s&&this.#y(r))return;let n=this.#r[r];return this.#h(n)?n.__staleWhileFetching:n}#j(t,e,s,r){let n=e===void 0?void 0:this.#r[e];if(this.#h(n))return n;let o=new le,{signal:a}=s;a?.addEventListener("abort",()=>o.abort(a.reason),{signal:o.signal});let l={signal:o.signal,options:s,context:r},c=(p,y=!1)=>{let{aborted:m}=o.signal,b=s.ignoreFetchAbort&&p!==void 0;if(s.status&&(m&&!y?(s.status.fetchAborted=!0,s.status.fetchError=o.signal.reason,b&&(s.status.fetchAbortIgnored=!0)):s.status.fetchResolved=!0),m&&!b&&!y)return f(o.signal.reason);let w=d;return this.#r[e]===d&&(p===void 0?w.__staleWhileFetching?this.#r[e]=w.__staleWhileFetching:this.#N(t,"fetch"):(s.status&&(s.status.fetchUpdated=!0),this.set(t,p,l.options))),p},h=p=>(s.status&&(s.status.fetchRejected=!0,s.status.fetchError=p),f(p)),f=p=>{let{aborted:y}=o.signal,m=y&&s.allowStaleOnFetchAbort,b=m||s.allowStaleOnFetchRejection,w=b||s.noDeleteOnFetchRejection,S=d;if(this.#r[e]===d&&(!w||S.__staleWhileFetching===void 0?this.#N(t,"fetch"):m||(this.#r[e]=S.__staleWhileFetching)),b)return s.status&&S.__staleWhileFetching!==void 0&&(s.status.returnedStale=!0),S.__staleWhileFetching;if(S.__returned===S)throw p},u=(p,y)=>{let m=this.#o?.(t,n,l);m&&m instanceof Promise&&m.then(b=>p(b===void 0?void 0:b),y),o.signal.addEventListener("abort",()=>{(!s.ignoreFetchAbort||s.allowStaleOnFetchAbort)&&(p(void 0),s.allowStaleOnFetchAbort&&(p=b=>c(b,!0)))})};s.status&&(s.status.fetchDispatched=!0);let d=new Promise(u).then(c,h),g=Object.assign(d,{__abortController:o,__staleWhileFetching:n,__returned:void 0});return e===void 0?(this.set(t,g,{...l.options,status:void 0}),e=this.#a.get(t)):this.#r[e]=g,g}#h(t){if(!this.#v)return!1;let e=t;return!!e&&e instanceof Promise&&e.hasOwnProperty("__staleWhileFetching")&&e.__abortController instanceof le}async fetch(t,e={}){let{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:n=this.noDeleteOnStaleGet,ttl:o=this.ttl,noDisposeOnSet:a=this.noDisposeOnSet,size:l=0,sizeCalculation:c=this.sizeCalculation,noUpdateTTL:h=this.noUpdateTTL,noDeleteOnFetchRejection:f=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:u=this.allowStaleOnFetchRejection,ignoreFetchAbort:d=this.ignoreFetchAbort,allowStaleOnFetchAbort:g=this.allowStaleOnFetchAbort,context:p,forceRefresh:y=!1,status:m,signal:b}=e;if(!this.#v)return m&&(m.fetch="get"),this.get(t,{allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:n,status:m});let w={allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:n,ttl:o,noDisposeOnSet:a,size:l,sizeCalculation:c,noUpdateTTL:h,noDeleteOnFetchRejection:f,allowStaleOnFetchRejection:u,allowStaleOnFetchAbort:g,ignoreFetchAbort:d,status:m,signal:b},S=this.#a.get(t);if(S===void 0){m&&(m.fetch="miss");let E=this.#j(t,S,w,p);return E.__returned=E}else{let E=this.#r[S];if(this.#h(E)){let ie=s&&E.__staleWhileFetching!==void 0;return m&&(m.fetch="inflight",ie&&(m.returnedStale=!0)),ie?E.__staleWhileFetching:E.__returned=E}let x=this.#y(S);if(!y&&!x)return m&&(m.fetch="hit"),this.#U(S),r&&this.#A(S),m&&this.#s(m,S),E;let R=this.#j(t,S,w,p),B=R.__staleWhileFetching!==void 0&&s;return m&&(m.fetch=x?"stale":"refresh",B&&x&&(m.returnedStale=!0)),B?R.__staleWhileFetching:R.__returned=R}}async forceFetch(t,e={}){let s=await this.fetch(t,e);if(s===void 0)throw new Error("fetch() returned undefined");return s}memo(t,e={}){let s=this.#b;if(!s)throw new Error("no memoMethod provided to constructor");let{context:r,forceRefresh:n,...o}=e,a=this.get(t,o);if(!n&&a!==void 0)return a;let l=s(t,a,{options:o,context:r});return this.set(t,l,o),l}get(t,e={}){let{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:n=this.noDeleteOnStaleGet,status:o}=e,a=this.#a.get(t);if(a!==void 0){let l=this.#r[a],c=this.#h(l);return o&&this.#s(o,a),this.#y(a)?(o&&(o.get="stale"),c?(o&&s&&l.__staleWhileFetching!==void 0&&(o.returnedStale=!0),s?l.__staleWhileFetching:void 0):(n||this.#N(t,"expire"),o&&s&&(o.returnedStale=!0),s?l:void 0)):(o&&(o.get="hit"),c?l.__staleWhileFetching:(this.#U(a),r&&this.#A(a),l))}else o&&(o.get="miss")}#$(t,e){this.#w[e]=t,this.#g[t]=e}#U(t){t!==this.#u&&(t===this.#d?this.#d=this.#g[t]:this.#$(this.#w[t],this.#g[t]),this.#$(this.#u,t),this.#u=t)}delete(t){return this.#N(t,"delete")}#N(t,e){let s=!1;if(this.#c!==0){let r=this.#a.get(t);if(r!==void 0)if(s=!0,this.#c===1)this.#W(e);else{this.#D(r);let n=this.#r[r];if(this.#h(n)?n.__abortController.abort(new Error("deleted")):(this.#E||this.#p)&&(this.#E&&this.#n?.(n,t,e),this.#p&&this.#m?.push([n,t,e])),this.#a.delete(t),this.#l[r]=void 0,this.#r[r]=void 0,r===this.#u)this.#u=this.#w[r];else if(r===this.#d)this.#d=this.#g[r];else{let o=this.#w[r];this.#g[o]=this.#g[r];let a=this.#g[r];this.#w[a]=this.#w[r]}this.#c--,this.#x.push(r)}}if(this.#p&&this.#m?.length){let r=this.#m,n;for(;n=r?.shift();)this.#i?.(...n)}return s}clear(){return this.#W("delete")}#W(t){for(let e of this.#C({allowStale:!0})){let s=this.#r[e];if(this.#h(s))s.__abortController.abort(new Error("deleted"));else{let r=this.#l[e];this.#E&&this.#n?.(s,r,t),this.#p&&this.#m?.push([s,r,t])}}if(this.#a.clear(),this.#r.fill(void 0),this.#l.fill(void 0),this.#S&&this.#O&&(this.#S.fill(0),this.#O.fill(0)),this.#T&&this.#T.fill(0),this.#d=0,this.#u=0,this.#x.length=0,this.#f=0,this.#c=0,this.#p&&this.#m){let e=this.#m,s;for(;s=e?.shift();)this.#i?.(...s)}}};import{posix as Bo,win32 as ss}from"node:path";import{fileURLToPath as zo}from"node:url";import{lstatSync as Go,readdir as Ho,readdirSync as qo,readlinkSync as Vo,realpathSync as Ko}from"fs";import*as Xo from"node:fs";import{lstat as Jo,readdir as Zo,readlink as Qo,realpath as ta}from"node:fs/promises";import{EventEmitter as Qe}from"node:events";import Ni from"node:stream";import{StringDecoder as Po}from"node:string_decoder";var Ri=typeof process=="object"&&process?process:{stdout:null,stderr:null},Do=i=>!!i&&typeof i=="object"&&(i instanceof lt||i instanceof Ni||Lo(i)||Mo(i)),Lo=i=>!!i&&typeof i=="object"&&i instanceof Qe&&typeof i.pipe=="function"&&i.pipe!==Ni.Writable.prototype.pipe,Mo=i=>!!i&&typeof i=="object"&&i instanceof Qe&&typeof i.write=="function"&&typeof i.end=="function",tt=Symbol("EOF"),et=Symbol("maybeEmitEnd"),at=Symbol("emittedEnd"),ce=Symbol("emittingEnd"),Gt=Symbol("emittedError"),he=Symbol("closed"),Ci=Symbol("read"),fe=Symbol("flush"),ki=Symbol("flushChunk"),q=Symbol("encoding"),vt=Symbol("decoder"),T=Symbol("flowing"),Ht=Symbol("paused"),xt=Symbol("resume"),O=Symbol("buffer"),L=Symbol("pipes"),A=Symbol("bufferLength"),Ve=Symbol("bufferPush"),ue=Symbol("bufferShift"),N=Symbol("objectMode"),v=Symbol("destroyed"),Ke=Symbol("error"),Xe=Symbol("emitData"),_i=Symbol("emitEnd"),Ye=Symbol("emitEnd2"),J=Symbol("async"),Je=Symbol("abort"),de=Symbol("aborted"),qt=Symbol("signal"),dt=Symbol("dataListeners"),I=Symbol("discarded"),Vt=i=>Promise.resolve().then(i),Fo=i=>i(),Io=i=>i==="end"||i==="finish"||i==="prefinish",jo=i=>i instanceof ArrayBuffer||!!i&&typeof i=="object"&&i.constructor&&i.constructor.name==="ArrayBuffer"&&i.byteLength>=0,$o=i=>!Buffer.isBuffer(i)&&ArrayBuffer.isView(i),pe=class{src;dest;opts;ondrain;constructor(t,e,s){this.src=t,this.dest=e,this.opts=s,this.ondrain=()=>t[xt](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(t){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},Ze=class extends pe{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(t,e,s){super(t,e,s),this.proxyErrors=r=>e.emit("error",r),t.on("error",this.proxyErrors)}},Uo=i=>!!i.objectMode,Wo=i=>!i.objectMode&&!!i.encoding&&i.encoding!=="buffer",lt=class extends Qe{[T]=!1;[Ht]=!1;[L]=[];[O]=[];[N];[q];[J];[vt];[tt]=!1;[at]=!1;[ce]=!1;[he]=!1;[Gt]=null;[A]=0;[v]=!1;[qt];[de]=!1;[dt]=0;[I]=!1;writable=!0;readable=!0;constructor(...t){let e=t[0]||{};if(super(),e.objectMode&&typeof e.encoding=="string")throw new TypeError("Encoding and objectMode may not be used together");Uo(e)?(this[N]=!0,this[q]=null):Wo(e)?(this[q]=e.encoding,this[N]=!1):(this[N]=!1,this[q]=null),this[J]=!!e.async,this[vt]=this[q]?new Po(this[q]):null,e&&e.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:()=>this[O]}),e&&e.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:()=>this[L]});let{signal:s}=e;s&&(this[qt]=s,s.aborted?this[Je]():s.addEventListener("abort",()=>this[Je]()))}get bufferLength(){return this[A]}get encoding(){return this[q]}set encoding(t){throw new Error("Encoding must be set at instantiation time")}setEncoding(t){throw new Error("Encoding must be set at instantiation time")}get objectMode(){return this[N]}set objectMode(t){throw new Error("objectMode must be set at instantiation time")}get async(){return this[J]}set async(t){this[J]=this[J]||!!t}[Je](){this[de]=!0,this.emit("abort",this[qt]?.reason),this.destroy(this[qt]?.reason)}get aborted(){return this[de]}set aborted(t){}write(t,e,s){if(this[de])return!1;if(this[tt])throw new Error("write after end");if(this[v])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;typeof e=="function"&&(s=e,e="utf8"),e||(e="utf8");let r=this[J]?Vt:Fo;if(!this[N]&&!Buffer.isBuffer(t)){if($o(t))t=Buffer.from(t.buffer,t.byteOffset,t.byteLength);else if(jo(t))t=Buffer.from(t);else if(typeof t!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[N]?(this[T]&&this[A]!==0&&this[fe](!0),this[T]?this.emit("data",t):this[Ve](t),this[A]!==0&&this.emit("readable"),s&&r(s),this[T]):t.length?(typeof t=="string"&&!(e===this[q]&&!this[vt]?.lastNeed)&&(t=Buffer.from(t,e)),Buffer.isBuffer(t)&&this[q]&&(t=this[vt].write(t)),this[T]&&this[A]!==0&&this[fe](!0),this[T]?this.emit("data",t):this[Ve](t),this[A]!==0&&this.emit("readable"),s&&r(s),this[T]):(this[A]!==0&&this.emit("readable"),s&&r(s),this[T])}read(t){if(this[v])return null;if(this[I]=!1,this[A]===0||t===0||t&&t>this[A])return this[et](),null;this[N]&&(t=null),this[O].length>1&&!this[N]&&(this[O]=[this[q]?this[O].join(""):Buffer.concat(this[O],this[A])]);let e=this[Ci](t||null,this[O][0]);return this[et](),e}[Ci](t,e){if(this[N])this[ue]();else{let s=e;t===s.length||t===null?this[ue]():typeof s=="string"?(this[O][0]=s.slice(t),e=s.slice(0,t),this[A]-=t):(this[O][0]=s.subarray(t),e=s.subarray(0,t),this[A]-=t)}return this.emit("data",e),!this[O].length&&!this[tt]&&this.emit("drain"),e}end(t,e,s){return typeof t=="function"&&(s=t,t=void 0),typeof e=="function"&&(s=e,e="utf8"),t!==void 0&&this.write(t,e),s&&this.once("end",s),this[tt]=!0,this.writable=!1,(this[T]||!this[Ht])&&this[et](),this}[xt](){this[v]||(!this[dt]&&!this[L].length&&(this[I]=!0),this[Ht]=!1,this[T]=!0,this.emit("resume"),this[O].length?this[fe]():this[tt]?this[et]():this.emit("drain"))}resume(){return this[xt]()}pause(){this[T]=!1,this[Ht]=!0,this[I]=!1}get destroyed(){return this[v]}get flowing(){return this[T]}get paused(){return this[Ht]}[Ve](t){this[N]?this[A]+=1:this[A]+=t.length,this[O].push(t)}[ue](){return this[N]?this[A]-=1:this[A]-=this[O][0].length,this[O].shift()}[fe](t=!1){do;while(this[ki](this[ue]())&&this[O].length);!t&&!this[O].length&&!this[tt]&&this.emit("drain")}[ki](t){return this.emit("data",t),this[T]}pipe(t,e){if(this[v])return t;this[I]=!1;let s=this[at];return e=e||{},t===Ri.stdout||t===Ri.stderr?e.end=!1:e.end=e.end!==!1,e.proxyErrors=!!e.proxyErrors,s?e.end&&t.end():(this[L].push(e.proxyErrors?new Ze(this,t,e):new pe(this,t,e)),this[J]?Vt(()=>this[xt]()):this[xt]()),t}unpipe(t){let e=this[L].find(s=>s.dest===t);e&&(this[L].length===1?(this[T]&&this[dt]===0&&(this[T]=!1),this[L]=[]):this[L].splice(this[L].indexOf(e),1),e.unpipe())}addListener(t,e){return this.on(t,e)}on(t,e){let s=super.on(t,e);if(t==="data")this[I]=!1,this[dt]++,!this[L].length&&!this[T]&&this[xt]();else if(t==="readable"&&this[A]!==0)super.emit("readable");else if(Io(t)&&this[at])super.emit(t),this.removeAllListeners(t);else if(t==="error"&&this[Gt]){let r=e;this[J]?Vt(()=>r.call(this,this[Gt])):r.call(this,this[Gt])}return s}removeListener(t,e){return this.off(t,e)}off(t,e){let s=super.off(t,e);return t==="data"&&(this[dt]=this.listeners("data").length,this[dt]===0&&!this[I]&&!this[L].length&&(this[T]=!1)),s}removeAllListeners(t){let e=super.removeAllListeners(t);return(t==="data"||t===void 0)&&(this[dt]=0,!this[I]&&!this[L].length&&(this[T]=!1)),e}get emittedEnd(){return this[at]}[et](){!this[ce]&&!this[at]&&!this[v]&&this[O].length===0&&this[tt]&&(this[ce]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[he]&&this.emit("close"),this[ce]=!1)}emit(t,...e){let s=e[0];if(t!=="error"&&t!=="close"&&t!==v&&this[v])return!1;if(t==="data")return!this[N]&&!s?!1:this[J]?(Vt(()=>this[Xe](s)),!0):this[Xe](s);if(t==="end")return this[_i]();if(t==="close"){if(this[he]=!0,!this[at]&&!this[v])return!1;let n=super.emit("close");return this.removeAllListeners("close"),n}else if(t==="error"){this[Gt]=s,super.emit(Ke,s);let n=!this[qt]||this.listeners("error").length?super.emit("error",s):!1;return this[et](),n}else if(t==="resume"){let n=super.emit("resume");return this[et](),n}else if(t==="finish"||t==="prefinish"){let n=super.emit(t);return this.removeAllListeners(t),n}let r=super.emit(t,...e);return this[et](),r}[Xe](t){for(let s of this[L])s.dest.write(t)===!1&&this.pause();let e=this[I]?!1:super.emit("data",t);return this[et](),e}[_i](){return this[at]?!1:(this[at]=!0,this.readable=!1,this[J]?(Vt(()=>this[Ye]()),!0):this[Ye]())}[Ye](){if(this[vt]){let e=this[vt].end();if(e){for(let s of this[L])s.dest.write(e);this[I]||super.emit("data",e)}}for(let e of this[L])e.end();let t=super.emit("end");return this.removeAllListeners("end"),t}async collect(){let t=Object.assign([],{dataLength:0});this[N]||(t.dataLength=0);let e=this.promise();return this.on("data",s=>{t.push(s),this[N]||(t.dataLength+=s.length)}),await e,t}async concat(){if(this[N])throw new Error("cannot concat in objectMode");let t=await this.collect();return this[q]?t.join(""):Buffer.concat(t,t.dataLength)}async promise(){return new Promise((t,e)=>{this.on(v,()=>e(new Error("stream destroyed"))),this.on("error",s=>e(s)),this.on("end",()=>t())})}[Symbol.asyncIterator](){this[I]=!1;let t=!1,e=async()=>(this.pause(),t=!0,{value:void 0,done:!0});return{next:()=>{if(t)return e();let r=this.read();if(r!==null)return Promise.resolve({done:!1,value:r});if(this[tt])return e();let n,o,a=f=>{this.off("data",l),this.off("end",c),this.off(v,h),e(),o(f)},l=f=>{this.off("error",a),this.off("end",c),this.off(v,h),this.pause(),n({value:f,done:!!this[tt]})},c=()=>{this.off("error",a),this.off("data",l),this.off(v,h),e(),n({done:!0,value:void 0})},h=()=>a(new Error("stream destroyed"));return new Promise((f,u)=>{o=u,n=f,this.once(v,h),this.once("error",a),this.once("end",c),this.once("data",l)})},throw:e,return:e,[Symbol.asyncIterator](){return this}}}[Symbol.iterator](){this[I]=!1;let t=!1,e=()=>(this.pause(),this.off(Ke,e),this.off(v,e),this.off("end",e),t=!0,{done:!0,value:void 0}),s=()=>{if(t)return e();let r=this.read();return r===null?e():{done:!1,value:r}};return this.once("end",e),this.once(Ke,e),this.once(v,e),{next:s,throw:e,return:e,[Symbol.iterator](){return this}}}destroy(t){if(this[v])return t?this.emit("error",t):this.emit(v),this;this[v]=!0,this[I]=!0,this[O].length=0,this[A]=0;let e=this;return typeof e.close=="function"&&!this[he]&&e.close(),t?this.emit("error",t):this.emit(v),this}static get isStream(){return Do}};var Yo=Ko.native,Xt={lstatSync:Go,readdir:Ho,readdirSync:qo,readlinkSync:Vo,realpathSync:Yo,promises:{lstat:Jo,readdir:Zo,readlink:Qo,realpath:ta}},Fi=i=>!i||i===Xt||i===Xo?Xt:{...Xt,...i,promises:{...Xt.promises,...i.promises||{}}},Ii=/^\\\\\?\\([a-z]:)\\?$/i,ea=i=>i.replace(/\//g,"\\").replace(Ii,"$1\\"),sa=/[\\\/]/,W=0,ji=1,$i=2,Z=4,Ui=6,Wi=8,pt=10,Bi=12,U=15,Kt=~U,ts=16,Pi=32,Yt=64,V=128,me=256,we=512,Di=Yt|V|we,ia=1023,es=i=>i.isFile()?Wi:i.isDirectory()?Z:i.isSymbolicLink()?pt:i.isCharacterDevice()?$i:i.isBlockDevice()?Ui:i.isSocket()?Bi:i.isFIFO()?ji:W,Li=new Map,Jt=i=>{let t=Li.get(i);if(t)return t;let e=i.normalize("NFKD");return Li.set(i,e),e},Mi=new Map,ge=i=>{let t=Mi.get(i);if(t)return t;let e=Jt(i.toLowerCase());return Mi.set(i,e),e},ye=class extends zt{constructor(){super({max:256})}},is=class extends zt{constructor(t=16*1024){super({maxSize:t,sizeCalculation:e=>e.length+1})}},zi=Symbol("PathScurry setAsCwd"),P=class{name;root;roots;parent;nocase;isCWD=!1;#t;#e;get dev(){return this.#e}#n;get mode(){return this.#n}#i;get nlink(){return this.#i}#o;get uid(){return this.#o}#b;get gid(){return this.#b}#c;get rdev(){return this.#c}#f;get blksize(){return this.#f}#a;get ino(){return this.#a}#l;get size(){return this.#l}#r;get blocks(){return this.#r}#g;get atimeMs(){return this.#g}#w;get mtimeMs(){return this.#w}#d;get ctimeMs(){return this.#d}#u;get birthtimeMs(){return this.#u}#x;get atime(){return this.#x}#m;get mtime(){return this.#m}#T;get ctime(){return this.#T}#O;get birthtime(){return this.#O}#S;#E;#v;#p;#k;#A;#s;#P;#y;#_;get parentPath(){return(this.parent||this).fullpath()}get path(){return this.parentPath}constructor(t,e=W,s,r,n,o,a){this.name=t,this.#S=n?ge(t):Jt(t),this.#s=e&ia,this.nocase=n,this.roots=r,this.root=s||this,this.#P=o,this.#v=a.fullpath,this.#k=a.relative,this.#A=a.relativePosix,this.parent=a.parent,this.parent?this.#t=this.parent.#t:this.#t=Fi(a.fs)}depth(){return this.#E!==void 0?this.#E:this.parent?this.#E=this.parent.depth()+1:this.#E=0}childrenCache(){return this.#P}resolve(t){if(!t)return this;let e=this.getRootString(t),r=t.substring(e.length).split(this.splitSep);return e?this.getRoot(e).#D(r):this.#D(r)}#D(t){let e=this;for(let s of t)e=e.child(s);return e}children(){let t=this.#P.get(this);if(t)return t;let e=Object.assign([],{provisional:0});return this.#P.set(this,e),this.#s&=~ts,e}child(t,e){if(t===""||t===".")return this;if(t==="..")return this.parent||this;let s=this.children(),r=this.nocase?ge(t):Jt(t);for(let l of s)if(l.#S===r)return l;let n=this.parent?this.sep:"",o=this.#v?this.#v+n+t:void 0,a=this.newChild(t,W,{...e,parent:this,fullpath:o});return this.canReaddir()||(a.#s|=V),s.push(a),a}relative(){if(this.isCWD)return"";if(this.#k!==void 0)return this.#k;let t=this.name,e=this.parent;if(!e)return this.#k=this.name;let s=e.relative();return s+(!s||!e.parent?"":this.sep)+t}relativePosix(){if(this.sep==="/")return this.relative();if(this.isCWD)return"";if(this.#A!==void 0)return this.#A;let t=this.name,e=this.parent;if(!e)return this.#A=this.fullpathPosix();let s=e.relativePosix();return s+(!s||!e.parent?"":"/")+t}fullpath(){if(this.#v!==void 0)return this.#v;let t=this.name,e=this.parent;if(!e)return this.#v=this.name;let r=e.fullpath()+(e.parent?this.sep:"")+t;return this.#v=r}fullpathPosix(){if(this.#p!==void 0)return this.#p;if(this.sep==="/")return this.#p=this.fullpath();if(!this.parent){let r=this.fullpath().replace(/\\/g,"/");return/^[a-z]:\//i.test(r)?this.#p=`//?/${r}`:this.#p=r}let t=this.parent,e=t.fullpathPosix(),s=e+(!e||!t.parent?"":"/")+this.name;return this.#p=s}isUnknown(){return(this.#s&U)===W}isType(t){return this[`is${t}`]()}getType(){return this.isUnknown()?"Unknown":this.isDirectory()?"Directory":this.isFile()?"File":this.isSymbolicLink()?"SymbolicLink":this.isFIFO()?"FIFO":this.isCharacterDevice()?"CharacterDevice":this.isBlockDevice()?"BlockDevice":this.isSocket()?"Socket":"Unknown"}isFile(){return(this.#s&U)===Wi}isDirectory(){return(this.#s&U)===Z}isCharacterDevice(){return(this.#s&U)===$i}isBlockDevice(){return(this.#s&U)===Ui}isFIFO(){return(this.#s&U)===ji}isSocket(){return(this.#s&U)===Bi}isSymbolicLink(){return(this.#s&pt)===pt}lstatCached(){return this.#s&Pi?this:void 0}readlinkCached(){return this.#y}realpathCached(){return this.#_}readdirCached(){let t=this.children();return t.slice(0,t.provisional)}canReadlink(){if(this.#y)return!0;if(!this.parent)return!1;let t=this.#s&U;return!(t!==W&&t!==pt||this.#s&me||this.#s&V)}calledReaddir(){return!!(this.#s&ts)}isENOENT(){return!!(this.#s&V)}isNamed(t){return this.nocase?this.#S===ge(t):this.#S===Jt(t)}async readlink(){let t=this.#y;if(t)return t;if(this.canReadlink()&&this.parent)try{let e=await this.#t.promises.readlink(this.fullpath()),s=(await this.parent.realpath())?.resolve(e);if(s)return this.#y=s}catch(e){this.#h(e.code);return}}readlinkSync(){let t=this.#y;if(t)return t;if(this.canReadlink()&&this.parent)try{let e=this.#t.readlinkSync(this.fullpath()),s=this.parent.realpathSync()?.resolve(e);if(s)return this.#y=s}catch(e){this.#h(e.code);return}}#L(t){this.#s|=ts;for(let e=t.provisional;e<t.length;e++){let s=t[e];s&&s.#M()}}#M(){this.#s&V||(this.#s=(this.#s|V)&Kt,this.#R())}#R(){let t=this.children();t.provisional=0;for(let e of t)e.#M()}#C(){this.#s|=we,this.#F()}#F(){if(this.#s&Yt)return;let t=this.#s;(t&U)===Z&&(t&=Kt),this.#s=t|Yt,this.#R()}#I(t=""){t==="ENOTDIR"||t==="EPERM"?this.#F():t==="ENOENT"?this.#M():this.children().provisional=0}#j(t=""){t==="ENOTDIR"?this.parent.#F():t==="ENOENT"&&this.#M()}#h(t=""){let e=this.#s;e|=me,t==="ENOENT"&&(e|=V),(t==="EINVAL"||t==="UNKNOWN")&&(e&=Kt),this.#s=e,t==="ENOTDIR"&&this.parent&&this.parent.#F()}#$(t,e){return this.#N(t,e)||this.#U(t,e)}#U(t,e){let s=es(t),r=this.newChild(t.name,s,{parent:this}),n=r.#s&U;return n!==Z&&n!==pt&&n!==W&&(r.#s|=Yt),e.unshift(r),e.provisional++,r}#N(t,e){for(let s=e.provisional;s<e.length;s++){let r=e[s];if((this.nocase?ge(t.name):Jt(t.name))===r.#S)return this.#W(t,r,s,e)}}#W(t,e,s,r){let n=e.name;return e.#s=e.#s&Kt|es(t),n!==t.name&&(e.name=t.name),s!==r.provisional&&(s===r.length-1?r.pop():r.splice(s,1),r.unshift(e)),r.provisional++,e}async lstat(){if(!(this.#s&V))try{return this.#H(await this.#t.promises.lstat(this.fullpath())),this}catch(t){this.#j(t.code)}}lstatSync(){if(!(this.#s&V))try{return this.#H(this.#t.lstatSync(this.fullpath())),this}catch(t){this.#j(t.code)}}#H(t){let{atime:e,atimeMs:s,birthtime:r,birthtimeMs:n,blksize:o,blocks:a,ctime:l,ctimeMs:c,dev:h,gid:f,ino:u,mode:d,mtime:g,mtimeMs:p,nlink:y,rdev:m,size:b,uid:w}=t;this.#x=e,this.#g=s,this.#O=r,this.#u=n,this.#f=o,this.#r=a,this.#T=l,this.#d=c,this.#e=h,this.#b=f,this.#a=u,this.#n=d,this.#m=g,this.#w=p,this.#i=y,this.#c=m,this.#l=b,this.#o=w;let S=es(t);this.#s=this.#s&Kt|S|Pi,S!==W&&S!==Z&&S!==pt&&(this.#s|=Yt)}#z=[];#G=!1;#q(t){this.#G=!1;let e=this.#z.slice();this.#z.length=0,e.forEach(s=>s(null,t))}readdirCB(t,e=!1){if(!this.canReaddir()){e?t(null,[]):queueMicrotask(()=>t(null,[]));return}let s=this.children();if(this.calledReaddir()){let n=s.slice(0,s.provisional);e?t(null,n):queueMicrotask(()=>t(null,n));return}if(this.#z.push(t),this.#G)return;this.#G=!0;let r=this.fullpath();this.#t.readdir(r,{withFileTypes:!0},(n,o)=>{if(n)this.#I(n.code),s.provisional=0;else{for(let a of o)this.#$(a,s);this.#L(s)}this.#q(s.slice(0,s.provisional))})}#B;async readdir(){if(!this.canReaddir())return[];let t=this.children();if(this.calledReaddir())return t.slice(0,t.provisional);let e=this.fullpath();if(this.#B)await this.#B;else{let s=()=>{};this.#B=new Promise(r=>s=r);try{for(let r of await this.#t.promises.readdir(e,{withFileTypes:!0}))this.#$(r,t);this.#L(t)}catch(r){this.#I(r.code),t.provisional=0}this.#B=void 0,s()}return t.slice(0,t.provisional)}readdirSync(){if(!this.canReaddir())return[];let t=this.children();if(this.calledReaddir())return t.slice(0,t.provisional);let e=this.fullpath();try{for(let s of this.#t.readdirSync(e,{withFileTypes:!0}))this.#$(s,t);this.#L(t)}catch(s){this.#I(s.code),t.provisional=0}return t.slice(0,t.provisional)}canReaddir(){if(this.#s&Di)return!1;let t=U&this.#s;return t===W||t===Z||t===pt}shouldWalk(t,e){return(this.#s&Z)===Z&&!(this.#s&Di)&&!t.has(this)&&(!e||e(this))}async realpath(){if(this.#_)return this.#_;if(!((we|me|V)&this.#s))try{let t=await this.#t.promises.realpath(this.fullpath());return this.#_=this.resolve(t)}catch{this.#C()}}realpathSync(){if(this.#_)return this.#_;if(!((we|me|V)&this.#s))try{let t=this.#t.realpathSync(this.fullpath());return this.#_=this.resolve(t)}catch{this.#C()}}[zi](t){if(t===this)return;t.isCWD=!1,this.isCWD=!0;let e=new Set([]),s=[],r=this;for(;r&&r.parent;)e.add(r),r.#k=s.join(this.sep),r.#A=s.join("/"),r=r.parent,s.push("..");for(r=t;r&&r.parent&&!e.has(r);)r.#k=void 0,r.#A=void 0,r=r.parent}},Se=class i extends P{sep="\\";splitSep=sa;constructor(t,e=W,s,r,n,o,a){super(t,e,s,r,n,o,a)}newChild(t,e=W,s={}){return new i(t,e,this.root,this.roots,this.nocase,this.childrenCache(),s)}getRootString(t){return ss.parse(t).root}getRoot(t){if(t=ea(t.toUpperCase()),t===this.root.name)return this.root;for(let[e,s]of Object.entries(this.roots))if(this.sameRoot(t,e))return this.roots[t]=s;return this.roots[t]=new Tt(t,this).root}sameRoot(t,e=this.root.name){return t=t.toUpperCase().replace(/\//g,"\\").replace(Ii,"$1\\"),t===e}},be=class i extends P{splitSep="/";sep="/";constructor(t,e=W,s,r,n,o,a){super(t,e,s,r,n,o,a)}getRootString(t){return t.startsWith("/")?"/":""}getRoot(t){return this.root}newChild(t,e=W,s={}){return new i(t,e,this.root,this.roots,this.nocase,this.childrenCache(),s)}},Ee=class{root;rootPath;roots;cwd;#t;#e;#n;nocase;#i;constructor(t=process.cwd(),e,s,{nocase:r,childrenCacheSize:n=16*1024,fs:o=Xt}={}){this.#i=Fi(o),(t instanceof URL||t.startsWith("file://"))&&(t=zo(t));let a=e.resolve(t);this.roots=Object.create(null),this.rootPath=this.parseRootPath(a),this.#t=new ye,this.#e=new ye,this.#n=new is(n);let l=a.substring(this.rootPath.length).split(s);if(l.length===1&&!l[0]&&l.pop(),r===void 0)throw new TypeError("must provide nocase setting to PathScurryBase ctor");this.nocase=r,this.root=this.newRoot(this.#i),this.roots[this.rootPath]=this.root;let c=this.root,h=l.length-1,f=e.sep,u=this.rootPath,d=!1;for(let g of l){let p=h--;c=c.child(g,{relative:new Array(p).fill("..").join(f),relativePosix:new Array(p).fill("..").join("/"),fullpath:u+=(d?"":f)+g}),d=!0}this.cwd=c}depth(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.depth()}childrenCache(){return this.#n}resolve(...t){let e="";for(let n=t.length-1;n>=0;n--){let o=t[n];if(!(!o||o===".")&&(e=e?`${o}/${e}`:o,this.isAbsolute(o)))break}let s=this.#t.get(e);if(s!==void 0)return s;let r=this.cwd.resolve(e).fullpath();return this.#t.set(e,r),r}resolvePosix(...t){let e="";for(let n=t.length-1;n>=0;n--){let o=t[n];if(!(!o||o===".")&&(e=e?`${o}/${e}`:o,this.isAbsolute(o)))break}let s=this.#e.get(e);if(s!==void 0)return s;let r=this.cwd.resolve(e).fullpathPosix();return this.#e.set(e,r),r}relative(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.relative()}relativePosix(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.relativePosix()}basename(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.name}dirname(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),(t.parent||t).fullpath()}async readdir(t=this.cwd,e={withFileTypes:!0}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof P||(e=t,t=this.cwd);let{withFileTypes:s}=e;if(t.canReaddir()){let r=await t.readdir();return s?r:r.map(n=>n.name)}else return[]}readdirSync(t=this.cwd,e={withFileTypes:!0}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof P||(e=t,t=this.cwd);let{withFileTypes:s=!0}=e;return t.canReaddir()?s?t.readdirSync():t.readdirSync().map(r=>r.name):[]}async lstat(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.lstat()}lstatSync(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.lstatSync()}async readlink(t=this.cwd,{withFileTypes:e}={withFileTypes:!1}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof P||(e=t.withFileTypes,t=this.cwd);let s=await t.readlink();return e?s:s?.fullpath()}readlinkSync(t=this.cwd,{withFileTypes:e}={withFileTypes:!1}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof P||(e=t.withFileTypes,t=this.cwd);let s=t.readlinkSync();return e?s:s?.fullpath()}async realpath(t=this.cwd,{withFileTypes:e}={withFileTypes:!1}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof P||(e=t.withFileTypes,t=this.cwd);let s=await t.realpath();return e?s:s?.fullpath()}realpathSync(t=this.cwd,{withFileTypes:e}={withFileTypes:!1}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof P||(e=t.withFileTypes,t=this.cwd);let s=t.realpathSync();return e?s:s?.fullpath()}async walk(t=this.cwd,e={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof P||(e=t,t=this.cwd);let{withFileTypes:s=!0,follow:r=!1,filter:n,walkFilter:o}=e,a=[];(!n||n(t))&&a.push(s?t:t.fullpath());let l=new Set,c=(f,u)=>{l.add(f),f.readdirCB((d,g)=>{if(d)return u(d);let p=g.length;if(!p)return u();let y=()=>{--p===0&&u()};for(let m of g)(!n||n(m))&&a.push(s?m:m.fullpath()),r&&m.isSymbolicLink()?m.realpath().then(b=>b?.isUnknown()?b.lstat():b).then(b=>b?.shouldWalk(l,o)?c(b,y):y()):m.shouldWalk(l,o)?c(m,y):y()},!0)},h=t;return new Promise((f,u)=>{c(h,d=>{if(d)return u(d);f(a)})})}walkSync(t=this.cwd,e={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof P||(e=t,t=this.cwd);let{withFileTypes:s=!0,follow:r=!1,filter:n,walkFilter:o}=e,a=[];(!n||n(t))&&a.push(s?t:t.fullpath());let l=new Set([t]);for(let c of l){let h=c.readdirSync();for(let f of h){(!n||n(f))&&a.push(s?f:f.fullpath());let u=f;if(f.isSymbolicLink()){if(!(r&&(u=f.realpathSync())))continue;u.isUnknown()&&u.lstatSync()}u.shouldWalk(l,o)&&l.add(u)}}return a}[Symbol.asyncIterator](){return this.iterate()}iterate(t=this.cwd,e={}){return typeof t=="string"?t=this.cwd.resolve(t):t instanceof P||(e=t,t=this.cwd),this.stream(t,e)[Symbol.asyncIterator]()}[Symbol.iterator](){return this.iterateSync()}*iterateSync(t=this.cwd,e={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof P||(e=t,t=this.cwd);let{withFileTypes:s=!0,follow:r=!1,filter:n,walkFilter:o}=e;(!n||n(t))&&(yield s?t:t.fullpath());let a=new Set([t]);for(let l of a){let c=l.readdirSync();for(let h of c){(!n||n(h))&&(yield s?h:h.fullpath());let f=h;if(h.isSymbolicLink()){if(!(r&&(f=h.realpathSync())))continue;f.isUnknown()&&f.lstatSync()}f.shouldWalk(a,o)&&a.add(f)}}}stream(t=this.cwd,e={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof P||(e=t,t=this.cwd);let{withFileTypes:s=!0,follow:r=!1,filter:n,walkFilter:o}=e,a=new lt({objectMode:!0});(!n||n(t))&&a.write(s?t:t.fullpath());let l=new Set,c=[t],h=0,f=()=>{let u=!1;for(;!u;){let d=c.shift();if(!d){h===0&&a.end();return}h++,l.add(d);let g=(y,m,b=!1)=>{if(y)return a.emit("error",y);if(r&&!b){let w=[];for(let S of m)S.isSymbolicLink()&&w.push(S.realpath().then(E=>E?.isUnknown()?E.lstat():E));if(w.length){Promise.all(w).then(()=>g(null,m,!0));return}}for(let w of m)w&&(!n||n(w))&&(a.write(s?w:w.fullpath())||(u=!0));h--;for(let w of m){let S=w.realpathCached()||w;S.shouldWalk(l,o)&&c.push(S)}u&&!a.flowing?a.once("drain",f):p||f()},p=!0;d.readdirCB(g,!0),p=!1}};return f(),a}streamSync(t=this.cwd,e={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof P||(e=t,t=this.cwd);let{withFileTypes:s=!0,follow:r=!1,filter:n,walkFilter:o}=e,a=new lt({objectMode:!0}),l=new Set;(!n||n(t))&&a.write(s?t:t.fullpath());let c=[t],h=0,f=()=>{let u=!1;for(;!u;){let d=c.shift();if(!d){h===0&&a.end();return}h++,l.add(d);let g=d.readdirSync();for(let p of g)(!n||n(p))&&(a.write(s?p:p.fullpath())||(u=!0));h--;for(let p of g){let y=p;if(p.isSymbolicLink()){if(!(r&&(y=p.realpathSync())))continue;y.isUnknown()&&y.lstatSync()}y.shouldWalk(l,o)&&c.push(y)}}u&&!a.flowing&&a.once("drain",f)};return f(),a}chdir(t=this.cwd){let e=this.cwd;this.cwd=typeof t=="string"?this.cwd.resolve(t):t,this.cwd[zi](e)}},Tt=class extends Ee{sep="\\";constructor(t=process.cwd(),e={}){let{nocase:s=!0}=e;super(t,ss,"\\",{...e,nocase:s}),this.nocase=s;for(let r=this.cwd;r;r=r.parent)r.nocase=this.nocase}parseRootPath(t){return ss.parse(t).root.toUpperCase()}newRoot(t){return new Se(this.rootPath,Z,void 0,this.roots,this.nocase,this.childrenCache(),{fs:t})}isAbsolute(t){return t.startsWith("/")||t.startsWith("\\")||/^[a-z]:(\/|\\)/i.test(t)}},Ot=class extends Ee{sep="/";constructor(t=process.cwd(),e={}){let{nocase:s=!1}=e;super(t,Bo,"/",{...e,nocase:s}),this.nocase=s}parseRootPath(t){return"/"}newRoot(t){return new be(this.rootPath,Z,void 0,this.roots,this.nocase,this.childrenCache(),{fs:t})}isAbsolute(t){return t.startsWith("/")}},Zt=class extends Ot{constructor(t=process.cwd(),e={}){let{nocase:s=!0}=e;super(t,{...e,nocase:s})}},dh=process.platform==="win32"?Se:be,Gi=process.platform==="win32"?Tt:process.platform==="darwin"?Zt:Ot;var ra=i=>i.length>=1,na=i=>i.length>=1,At=class i{#t;#e;#n;length;#i;#o;#b;#c;#f;#a;#l=!0;constructor(t,e,s,r){if(!ra(t))throw new TypeError("empty pattern list");if(!na(e))throw new TypeError("empty glob list");if(e.length!==t.length)throw new TypeError("mismatched pattern list and glob list lengths");if(this.length=t.length,s<0||s>=this.length)throw new TypeError("index out of range");if(this.#t=t,this.#e=e,this.#n=s,this.#i=r,this.#n===0){if(this.isUNC()){let[n,o,a,l,...c]=this.#t,[h,f,u,d,...g]=this.#e;c[0]===""&&(c.shift(),g.shift());let p=[n,o,a,l,""].join("/"),y=[h,f,u,d,""].join("/");this.#t=[p,...c],this.#e=[y,...g],this.length=this.#t.length}else if(this.isDrive()||this.isAbsolute()){let[n,...o]=this.#t,[a,...l]=this.#e;o[0]===""&&(o.shift(),l.shift());let c=n+"/",h=a+"/";this.#t=[c,...o],this.#e=[h,...l],this.length=this.#t.length}}}pattern(){return this.#t[this.#n]}isString(){return typeof this.#t[this.#n]=="string"}isGlobstar(){return this.#t[this.#n]===C}isRegExp(){return this.#t[this.#n]instanceof RegExp}globString(){return this.#b=this.#b||(this.#n===0?this.isAbsolute()?this.#e[0]+this.#e.slice(1).join("/"):this.#e.join("/"):this.#e.slice(this.#n).join("/"))}hasMore(){return this.length>this.#n+1}rest(){return this.#o!==void 0?this.#o:this.hasMore()?(this.#o=new i(this.#t,this.#e,this.#n+1,this.#i),this.#o.#a=this.#a,this.#o.#f=this.#f,this.#o.#c=this.#c,this.#o):this.#o=null}isUNC(){let t=this.#t;return this.#f!==void 0?this.#f:this.#f=this.#i==="win32"&&this.#n===0&&t[0]===""&&t[1]===""&&typeof t[2]=="string"&&!!t[2]&&typeof t[3]=="string"&&!!t[3]}isDrive(){let t=this.#t;return this.#c!==void 0?this.#c:this.#c=this.#i==="win32"&&this.#n===0&&this.length>1&&typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0])}isAbsolute(){let t=this.#t;return this.#a!==void 0?this.#a:this.#a=t[0]===""&&t.length>1||this.isDrive()||this.isUNC()}root(){let t=this.#t[0];return typeof t=="string"&&this.isAbsolute()&&this.#n===0?t:""}checkFollowGlobstar(){return!(this.#n===0||!this.isGlobstar()||!this.#l)}markFollowGlobstar(){return this.#n===0||!this.isGlobstar()||!this.#l?!1:(this.#l=!1,!0)}};var oa=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",Rt=class{relative;relativeChildren;absolute;absoluteChildren;platform;mmopts;constructor(t,{nobrace:e,nocase:s,noext:r,noglobstar:n,platform:o=oa}){this.relative=[],this.absolute=[],this.relativeChildren=[],this.absoluteChildren=[],this.platform=o,this.mmopts={dot:!0,nobrace:e,nocase:s,noext:r,noglobstar:n,optimizationLevel:2,platform:o,nocomment:!0,nonegate:!0};for(let a of t)this.add(a)}add(t){let e=new F(t,this.mmopts);for(let s=0;s<e.set.length;s++){let r=e.set[s],n=e.globParts[s];if(!r||!n)throw new Error("invalid pattern object");for(;r[0]==="."&&n[0]===".";)r.shift(),n.shift();let o=new At(r,n,0,this.platform),a=new F(o.globString(),this.mmopts),l=n[n.length-1]==="**",c=o.isAbsolute();c?this.absolute.push(a):this.relative.push(a),l&&(c?this.absoluteChildren.push(a):this.relativeChildren.push(a))}}ignored(t){let e=t.fullpath(),s=`${e}/`,r=t.relative()||".",n=`${r}/`;for(let o of this.relative)if(o.match(r)||o.match(n))return!0;for(let o of this.absolute)if(o.match(e)||o.match(s))return!0;return!1}childrenIgnored(t){let e=t.fullpath()+"/",s=(t.relative()||".")+"/";for(let r of this.relativeChildren)if(r.match(s))return!0;for(let r of this.absoluteChildren)if(r.match(e))return!0;return!1}};var rs=class i{store;constructor(t=new Map){this.store=t}copy(){return new i(new Map(this.store))}hasWalked(t,e){return this.store.get(t.fullpath())?.has(e.globString())}storeWalked(t,e){let s=t.fullpath(),r=this.store.get(s);r?r.add(e.globString()):this.store.set(s,new Set([e.globString()]))}},ns=class{store=new Map;add(t,e,s){let r=(e?2:0)|(s?1:0),n=this.store.get(t);this.store.set(t,n===void 0?r:r&n)}entries(){return[...this.store.entries()].map(([t,e])=>[t,!!(e&2),!!(e&1)])}},os=class{store=new Map;add(t,e){if(!t.canReaddir())return;let s=this.store.get(t);s?s.find(r=>r.globString()===e.globString())||s.push(e):this.store.set(t,[e])}get(t){let e=this.store.get(t);if(!e)throw new Error("attempting to walk unknown path");return e}entries(){return this.keys().map(t=>[t,this.store.get(t)])}keys(){return[...this.store.keys()].filter(t=>t.canReaddir())}},Qt=class i{hasWalkedCache;matches=new ns;subwalks=new os;patterns;follow;dot;opts;constructor(t,e){this.opts=t,this.follow=!!t.follow,this.dot=!!t.dot,this.hasWalkedCache=e?e.copy():new rs}processPatterns(t,e){this.patterns=e;let s=e.map(r=>[t,r]);for(let[r,n]of s){this.hasWalkedCache.storeWalked(r,n);let o=n.root(),a=n.isAbsolute()&&this.opts.absolute!==!1;if(o){r=r.resolve(o==="/"&&this.opts.root!==void 0?this.opts.root:o);let f=n.rest();if(f)n=f;else{this.matches.add(r,!0,!1);continue}}if(r.isENOENT())continue;let l,c,h=!1;for(;typeof(l=n.pattern())=="string"&&(c=n.rest());)r=r.resolve(l),n=c,h=!0;if(l=n.pattern(),c=n.rest(),h){if(this.hasWalkedCache.hasWalked(r,n))continue;this.hasWalkedCache.storeWalked(r,n)}if(typeof l=="string"){let f=l===".."||l===""||l===".";this.matches.add(r.resolve(l),a,f);continue}else if(l===C){(!r.isSymbolicLink()||this.follow||n.checkFollowGlobstar())&&this.subwalks.add(r,n);let f=c?.pattern(),u=c?.rest();if(!c||(f===""||f===".")&&!u)this.matches.add(r,a,f===""||f===".");else if(f===".."){let d=r.parent||r;u?this.hasWalkedCache.hasWalked(d,u)||this.subwalks.add(d,u):this.matches.add(d,a,!0)}}else l instanceof RegExp&&this.subwalks.add(r,n)}return this}subwalkTargets(){return this.subwalks.keys()}child(){return new i(this.opts,this.hasWalkedCache)}filterEntries(t,e){let s=this.subwalks.get(t),r=this.child();for(let n of e)for(let o of s){let a=o.isAbsolute(),l=o.pattern(),c=o.rest();l===C?r.testGlobstar(n,o,c,a):l instanceof RegExp?r.testRegExp(n,l,c,a):r.testString(n,l,c,a)}return r}testGlobstar(t,e,s,r){if((this.dot||!t.name.startsWith("."))&&(e.hasMore()||this.matches.add(t,r,!1),t.canReaddir()&&(this.follow||!t.isSymbolicLink()?this.subwalks.add(t,e):t.isSymbolicLink()&&(s&&e.checkFollowGlobstar()?this.subwalks.add(t,s):e.markFollowGlobstar()&&this.subwalks.add(t,e)))),s){let n=s.pattern();if(typeof n=="string"&&n!==".."&&n!==""&&n!==".")this.testString(t,n,s.rest(),r);else if(n===".."){let o=t.parent||t;this.subwalks.add(o,s)}else n instanceof RegExp&&this.testRegExp(t,n,s.rest(),r)}}testRegExp(t,e,s,r){e.test(t.name)&&(s?this.subwalks.add(t,s):this.matches.add(t,r,!1))}testString(t,e,s,r){t.isNamed(e)&&(s?this.subwalks.add(t,s):this.matches.add(t,r,!1))}};var aa=(i,t)=>typeof i=="string"?new Rt([i],t):Array.isArray(i)?new Rt(i,t):i,ve=class{path;patterns;opts;seen=new Set;paused=!1;aborted=!1;#t=[];#e;#n;signal;maxDepth;includeChildMatches;constructor(t,e,s){if(this.patterns=t,this.path=e,this.opts=s,this.#n=!s.posix&&s.platform==="win32"?"\\":"/",this.includeChildMatches=s.includeChildMatches!==!1,(s.ignore||!this.includeChildMatches)&&(this.#e=aa(s.ignore??[],s),!this.includeChildMatches&&typeof this.#e.add!="function")){let r="cannot ignore child matches, ignore lacks add() method.";throw new Error(r)}this.maxDepth=s.maxDepth||1/0,s.signal&&(this.signal=s.signal,this.signal.addEventListener("abort",()=>{this.#t.length=0}))}#i(t){return this.seen.has(t)||!!this.#e?.ignored?.(t)}#o(t){return!!this.#e?.childrenIgnored?.(t)}pause(){this.paused=!0}resume(){if(this.signal?.aborted)return;this.paused=!1;let t;for(;!this.paused&&(t=this.#t.shift());)t()}onResume(t){this.signal?.aborted||(this.paused?this.#t.push(t):t())}async matchCheck(t,e){if(e&&this.opts.nodir)return;let s;if(this.opts.realpath){if(s=t.realpathCached()||await t.realpath(),!s)return;t=s}let n=t.isUnknown()||this.opts.stat?await t.lstat():t;if(this.opts.follow&&this.opts.nodir&&n?.isSymbolicLink()){let o=await n.realpath();o&&(o.isUnknown()||this.opts.stat)&&await o.lstat()}return this.matchCheckTest(n,e)}matchCheckTest(t,e){return t&&(this.maxDepth===1/0||t.depth()<=this.maxDepth)&&(!e||t.canReaddir())&&(!this.opts.nodir||!t.isDirectory())&&(!this.opts.nodir||!this.opts.follow||!t.isSymbolicLink()||!t.realpathCached()?.isDirectory())&&!this.#i(t)?t:void 0}matchCheckSync(t,e){if(e&&this.opts.nodir)return;let s;if(this.opts.realpath){if(s=t.realpathCached()||t.realpathSync(),!s)return;t=s}let n=t.isUnknown()||this.opts.stat?t.lstatSync():t;if(this.opts.follow&&this.opts.nodir&&n?.isSymbolicLink()){let o=n.realpathSync();o&&(o?.isUnknown()||this.opts.stat)&&o.lstatSync()}return this.matchCheckTest(n,e)}matchFinish(t,e){if(this.#i(t))return;if(!this.includeChildMatches&&this.#e?.add){let n=`${t.relativePosix()}/**`;this.#e.add(n)}let s=this.opts.absolute===void 0?e:this.opts.absolute;this.seen.add(t);let r=this.opts.mark&&t.isDirectory()?this.#n:"";if(this.opts.withFileTypes)this.matchEmit(t);else if(s){let n=this.opts.posix?t.fullpathPosix():t.fullpath();this.matchEmit(n+r)}else{let n=this.opts.posix?t.relativePosix():t.relative(),o=this.opts.dotRelative&&!n.startsWith(".."+this.#n)?"."+this.#n:"";this.matchEmit(n?o+n+r:"."+r)}}async match(t,e,s){let r=await this.matchCheck(t,s);r&&this.matchFinish(r,e)}matchSync(t,e,s){let r=this.matchCheckSync(t,s);r&&this.matchFinish(r,e)}walkCB(t,e,s){this.signal?.aborted&&s(),this.walkCB2(t,e,new Qt(this.opts),s)}walkCB2(t,e,s,r){if(this.#o(t))return r();if(this.signal?.aborted&&r(),this.paused){this.onResume(()=>this.walkCB2(t,e,s,r));return}s.processPatterns(t,e);let n=1,o=()=>{--n===0&&r()};for(let[a,l,c]of s.matches.entries())this.#i(a)||(n++,this.match(a,l,c).then(()=>o()));for(let a of s.subwalkTargets()){if(this.maxDepth!==1/0&&a.depth()>=this.maxDepth)continue;n++;let l=a.readdirCached();a.calledReaddir()?this.walkCB3(a,l,s,o):a.readdirCB((c,h)=>this.walkCB3(a,h,s,o),!0)}o()}walkCB3(t,e,s,r){s=s.filterEntries(t,e);let n=1,o=()=>{--n===0&&r()};for(let[a,l,c]of s.matches.entries())this.#i(a)||(n++,this.match(a,l,c).then(()=>o()));for(let[a,l]of s.subwalks.entries())n++,this.walkCB2(a,l,s.child(),o);o()}walkCBSync(t,e,s){this.signal?.aborted&&s(),this.walkCB2Sync(t,e,new Qt(this.opts),s)}walkCB2Sync(t,e,s,r){if(this.#o(t))return r();if(this.signal?.aborted&&r(),this.paused){this.onResume(()=>this.walkCB2Sync(t,e,s,r));return}s.processPatterns(t,e);let n=1,o=()=>{--n===0&&r()};for(let[a,l,c]of s.matches.entries())this.#i(a)||this.matchSync(a,l,c);for(let a of s.subwalkTargets()){if(this.maxDepth!==1/0&&a.depth()>=this.maxDepth)continue;n++;let l=a.readdirSync();this.walkCB3Sync(a,l,s,o)}o()}walkCB3Sync(t,e,s,r){s=s.filterEntries(t,e);let n=1,o=()=>{--n===0&&r()};for(let[a,l,c]of s.matches.entries())this.#i(a)||this.matchSync(a,l,c);for(let[a,l]of s.subwalks.entries())n++,this.walkCB2Sync(a,l,s.child(),o);o()}},te=class extends ve{matches=new Set;constructor(t,e,s){super(t,e,s)}matchEmit(t){this.matches.add(t)}async walk(){if(this.signal?.aborted)throw this.signal.reason;return this.path.isUnknown()&&await this.path.lstat(),await new Promise((t,e)=>{this.walkCB(this.path,this.patterns,()=>{this.signal?.aborted?e(this.signal.reason):t(this.matches)})}),this.matches}walkSync(){if(this.signal?.aborted)throw this.signal.reason;return this.path.isUnknown()&&this.path.lstatSync(),this.walkCBSync(this.path,this.patterns,()=>{if(this.signal?.aborted)throw this.signal.reason}),this.matches}},ee=class extends ve{results;constructor(t,e,s){super(t,e,s),this.results=new lt({signal:this.signal,objectMode:!0}),this.results.on("drain",()=>this.resume()),this.results.on("resume",()=>this.resume())}matchEmit(t){this.results.write(t),this.results.flowing||this.pause()}stream(){let t=this.path;return t.isUnknown()?t.lstat().then(()=>{this.walkCB(t,this.patterns,()=>this.results.end())}):this.walkCB(t,this.patterns,()=>this.results.end()),this.results}streamSync(){return this.path.isUnknown()&&this.path.lstatSync(),this.walkCBSync(this.path,this.patterns,()=>this.results.end()),this.results}};var ca=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",K=class{absolute;cwd;root;dot;dotRelative;follow;ignore;magicalBraces;mark;matchBase;maxDepth;nobrace;nocase;nodir;noext;noglobstar;pattern;platform;realpath;scurry;stat;signal;windowsPathsNoEscape;withFileTypes;includeChildMatches;opts;patterns;constructor(t,e){if(!e)throw new TypeError("glob options required");if(this.withFileTypes=!!e.withFileTypes,this.signal=e.signal,this.follow=!!e.follow,this.dot=!!e.dot,this.dotRelative=!!e.dotRelative,this.nodir=!!e.nodir,this.mark=!!e.mark,e.cwd?(e.cwd instanceof URL||e.cwd.startsWith("file://"))&&(e.cwd=la(e.cwd)):this.cwd="",this.cwd=e.cwd||"",this.root=e.root,this.magicalBraces=!!e.magicalBraces,this.nobrace=!!e.nobrace,this.noext=!!e.noext,this.realpath=!!e.realpath,this.absolute=e.absolute,this.includeChildMatches=e.includeChildMatches!==!1,this.noglobstar=!!e.noglobstar,this.matchBase=!!e.matchBase,this.maxDepth=typeof e.maxDepth=="number"?e.maxDepth:1/0,this.stat=!!e.stat,this.ignore=e.ignore,this.withFileTypes&&this.absolute!==void 0)throw new Error("cannot set absolute and withFileTypes:true");if(typeof t=="string"&&(t=[t]),this.windowsPathsNoEscape=!!e.windowsPathsNoEscape||e.allowWindowsEscape===!1,this.windowsPathsNoEscape&&(t=t.map(l=>l.replace(/\\/g,"/"))),this.matchBase){if(e.noglobstar)throw new TypeError("base matching requires globstar");t=t.map(l=>l.includes("/")?l:`./**/${l}`)}if(this.pattern=t,this.platform=e.platform||ca,this.opts={...e,platform:this.platform},e.scurry){if(this.scurry=e.scurry,e.nocase!==void 0&&e.nocase!==e.scurry.nocase)throw new Error("nocase option contradicts provided scurry option")}else{let l=e.platform==="win32"?Tt:e.platform==="darwin"?Zt:e.platform?Ot:Gi;this.scurry=new l(this.cwd,{nocase:e.nocase,fs:e.fs})}this.nocase=this.scurry.nocase;let s=this.platform==="darwin"||this.platform==="win32",r={...e,dot:this.dot,matchBase:this.matchBase,nobrace:this.nobrace,nocase:this.nocase,nocaseMagicOnly:s,nocomment:!0,noext:this.noext,nonegate:!0,optimizationLevel:2,platform:this.platform,windowsPathsNoEscape:this.windowsPathsNoEscape,debug:!!this.opts.debug},n=this.pattern.map(l=>new F(l,r)),[o,a]=n.reduce((l,c)=>(l[0].push(...c.set),l[1].push(...c.globParts),l),[[],[]]);this.patterns=o.map((l,c)=>{let h=a[c];if(!h)throw new Error("invalid pattern object");return new At(l,h,0,this.platform)})}async walk(){return[...await new te(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walk()]}walkSync(){return[...new te(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walkSync()]}stream(){return new ee(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).stream()}streamSync(){return new ee(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).streamSync()}iterateSync(){return this.streamSync()[Symbol.iterator]()}[Symbol.iterator](){return this.iterateSync()}iterate(){return this.stream()[Symbol.asyncIterator]()}[Symbol.asyncIterator](){return this.iterate()}};var as=(i,t={})=>{Array.isArray(i)||(i=[i]);for(let e of i)if(new F(e,t).hasMagic())return!0;return!1};function Te(i,t={}){return new K(i,t).streamSync()}function qi(i,t={}){return new K(i,t).stream()}function Oe(i,t={}){return new K(i,t).walkSync()}async function Hi(i,t={}){return new K(i,t).walk()}function Ae(i,t={}){return new K(i,t).iterateSync()}function Vi(i,t={}){return new K(i,t).iterate()}var ha=Te,fa=Object.assign(qi,{sync:Te}),ua=Ae,da=Object.assign(Vi,{sync:Ae}),pa=Object.assign(Oe,{stream:Te,iterate:Ae}),xe=Object.assign(Hi,{glob:Hi,globSync:Oe,sync:pa,globStream:qi,stream:fa,globStreamSync:Te,streamSync:ha,globIterate:Vi,iterate:da,globIterateSync:Ae,iterateSync:ua,Glob:K,hasMagic:as,escape:St,unescape:H});xe.glob=xe;var ct=(i,t)=>typeof i>"u"||typeof i===t,Ki=i=>!!i&&typeof i=="object"&&ct(i.preserveRoot,"boolean")&&ct(i.tmp,"string")&&ct(i.maxRetries,"number")&&ct(i.retryDelay,"number")&&ct(i.backoff,"number")&&ct(i.maxBackoff,"number")&&(ct(i.glob,"boolean")||i.glob&&typeof i.glob=="object")&&ct(i.filter,"function"),Xi=i=>{if(!Ki(i))throw new Error("invalid rimraf options")},Yi=i=>{Xi(i);let{glob:t,...e}=i;if(!t)return e;let s=t===!0?i.signal?{signal:i.signal}:{}:i.signal?{signal:i.signal,...t}:t;return{...e,glob:{...s,absolute:!0,withFileTypes:!1}}},Ji=(i={})=>Yi(i),Zi=(i={})=>Yi(i);import{parse as Qi,resolve as ma}from"path";import{inspect as ga}from"util";var X=process.env.__TESTING_RIMRAF_PLATFORM__||process.platform;var wa=(i,t={})=>{let e=typeof i;if(e!=="string"){let r=i&&e==="object"&&i.constructor,o=`The "path" argument must be of type string. Received ${r&&r.name?`an instance of ${r.name}`:e==="object"?ga(i):`type ${e} ${i}`}`;throw Object.assign(new TypeError(o),{path:i,code:"ERR_INVALID_ARG_TYPE"})}if(/\0/.test(i)){let r="path must be a string without null bytes";throw Object.assign(new TypeError(r),{path:i,code:"ERR_INVALID_ARG_VALUE"})}i=ma(i);let{root:s}=Qi(i);if(i===s&&t.preserveRoot!==!1){let r="refusing to remove root directory without preserveRoot:false";throw Object.assign(new Error(r),{path:i,code:"ERR_PRESERVE_ROOT"})}if(X==="win32"){let r=/[*|"<>?:]/,{root:n}=Qi(i);if(r.test(i.substring(n.length)))throw Object.assign(new Error("Illegal characters in path."),{path:i,code:"EINVAL"})}return i},se=wa;import st from"fs";import{chmodSync as Re,mkdirSync as Zh,renameSync as er,rmdirSync as Ct,rmSync as sr,statSync as ir,lstatSync as kt,unlinkSync as _t}from"fs";import{readdirSync as ya}from"fs";var tr=i=>ya(i,{withFileTypes:!0}),Sa=(i,t)=>new Promise((e,s)=>st.chmod(i,t,(r,...n)=>r?s(r):e(...n))),ba=(i,t)=>new Promise((e,s)=>st.mkdir(i,t,(r,n)=>r?s(r):e(n))),Ea=i=>new Promise((t,e)=>st.readdir(i,{withFileTypes:!0},(s,r)=>s?e(s):t(r))),va=(i,t)=>new Promise((e,s)=>st.rename(i,t,(r,...n)=>r?s(r):e(...n))),xa=(i,t)=>new Promise((e,s)=>st.rm(i,t,(r,...n)=>r?s(r):e(...n))),Ta=i=>new Promise((t,e)=>st.rmdir(i,(s,...r)=>s?e(s):t(...r))),Oa=i=>new Promise((t,e)=>st.stat(i,(s,r)=>s?e(s):t(r))),Aa=i=>new Promise((t,e)=>st.lstat(i,(s,r)=>s?e(s):t(r))),Ra=i=>new Promise((t,e)=>st.unlink(i,(s,...r)=>s?e(s):t(...r))),M={chmod:Sa,mkdir:ba,readdir:Ea,rename:va,rm:xa,rmdir:Ta,stat:Oa,lstat:Aa,unlink:Ra};import{parse as rr,resolve as nr}from"path";var{readdir:Ca}=M,Nt=i=>Ca(i).catch(t=>t),Pt=i=>{try{return tr(i)}catch(t){return t}};var it=async i=>i.catch(t=>{if(t.code!=="ENOENT")throw t}),rt=i=>{try{return i()}catch(t){if(t?.code!=="ENOENT")throw t}};var{lstat:ka,rmdir:_a,unlink:Na}=M,Ce=async(i,t)=>{if(t?.signal?.aborted)throw t.signal.reason;try{return await or(i,t,await ka(i))}catch(e){if(e?.code==="ENOENT")return!0;throw e}},ke=(i,t)=>{if(t?.signal?.aborted)throw t.signal.reason;try{return ar(i,t,kt(i))}catch(e){if(e?.code==="ENOENT")return!0;throw e}},or=async(i,t,e)=>{if(t?.signal?.aborted)throw t.signal.reason;let s=e.isDirectory()?await Nt(i):null;if(!Array.isArray(s)){if(s){if(s.code==="ENOENT")return!0;if(s.code!=="ENOTDIR")throw s}return t.filter&&!await t.filter(i,e)?!1:(await it(Na(i)),!0)}return!(await Promise.all(s.map(n=>or(nr(i,n.name),t,n)))).reduce((n,o)=>n&&o,!0)||t.preserveRoot===!1&&i===rr(i).root||t.filter&&!await t.filter(i,e)?!1:(await it(_a(i)),!0)},ar=(i,t,e)=>{if(t?.signal?.aborted)throw t.signal.reason;let s=e.isDirectory()?Pt(i):null;if(!Array.isArray(s)){if(s){if(s.code==="ENOENT")return!0;if(s.code!=="ENOTDIR")throw s}return t.filter&&!t.filter(i,e)?!1:(rt(()=>_t(i)),!0)}let r=!0;for(let n of s){let o=nr(i,n.name);r=ar(o,t,n)&&r}return t.preserveRoot===!1&&i===rr(i).root||!r||t.filter&&!t.filter(i,e)?!1:(rt(()=>Ct(i)),!0)};import{parse as gr,resolve as wr}from"path";var{chmod:Pa}=M,ls=i=>async t=>{try{return await i(t)}catch(e){let s=e;if(s?.code==="ENOENT")return;if(s?.code==="EPERM"){try{await Pa(t,438)}catch(r){if(r?.code==="ENOENT")return;throw e}return await i(t)}throw e}},cs=i=>t=>{try{return i(t)}catch(e){let s=e;if(s?.code==="ENOENT")return;if(s?.code==="EPERM"){try{Re(t,438)}catch(r){if(r?.code==="ENOENT")return;throw e}return i(t)}throw e}};var lr=new Set(["EMFILE","ENFILE","EBUSY"]),hs=i=>{let t=async(e,s,r=1,n=0)=>{let o=s.maxBackoff||200,a=s.backoff||1.2,l=s.maxRetries||10,c=0;for(;;)try{return await i(e)}catch(h){let f=h;if(f?.path===e&&f?.code&&lr.has(f.code)){if(r=Math.ceil(r*a),n=r+n,n<o)return new Promise((u,d)=>{setTimeout(()=>{t(e,s,r,n).then(u,d)},r)});if(c<l){c++;continue}}throw h}};return t},fs=i=>(e,s)=>{let r=s.maxRetries||10,n=0;for(;;)try{return i(e)}catch(o){let a=o;if(a?.path===e&&a?.code&&lr.has(a.code)&&n<r){n++;continue}throw o}};import{basename as Ua,parse as Pe,resolve as De}from"path";import{tmpdir as Ne}from"os";import{parse as _e,resolve as cr}from"path";var{stat:Da}=M,La=i=>{try{return ir(i).isDirectory()}catch{return!1}},Ma=i=>Da(i).then(t=>t.isDirectory(),()=>!1),Fa=async i=>{let{root:t}=_e(i),e=Ne(),{root:s}=_e(e);if(t.toLowerCase()===s.toLowerCase())return e;let r=cr(t,"/temp");return await Ma(r)?r:t},Ia=i=>{let{root:t}=_e(i),e=Ne(),{root:s}=_e(e);if(t.toLowerCase()===s.toLowerCase())return e;let r=cr(t,"/temp");return La(r)?r:t},ja=async()=>Ne(),$a=()=>Ne(),hr=X==="win32"?Fa:ja,fr=X==="win32"?Ia:$a;var{lstat:Wa,rename:Ba,unlink:ur,rmdir:za,chmod:Ga}=M,mr=i=>`.${Ua(i)}.${Math.random()}`,Ha=async i=>ur(i).catch(t=>{if(t.code==="EPERM")return Ga(i,438).then(()=>ur(i),e=>{if(e.code!=="ENOENT")throw t});if(t.code==="ENOENT")return;throw t}),qa=i=>{try{_t(i)}catch(t){if(t?.code==="EPERM")try{return Re(i,438)}catch(e){if(e?.code==="ENOENT")return;throw t}else if(t?.code==="ENOENT")return;throw t}},Le=async(i,t)=>{if(t?.signal?.aborted)throw t.signal.reason;try{return await us(i,t,await Wa(i))}catch(e){if(e?.code==="ENOENT")return!0;throw e}},us=async(i,t,e)=>{if(t?.signal?.aborted)throw t.signal.reason;if(!t.tmp)return us(i,{...t,tmp:await hr(i)},e);if(i===t.tmp&&Pe(i).root!==i)throw new Error("cannot delete temp directory used for deletion");let s=e.isDirectory()?await Nt(i):null;if(!Array.isArray(s)){if(s){if(s.code==="ENOENT")return!0;if(s.code!=="ENOTDIR")throw s}return t.filter&&!await t.filter(i,e)?!1:(await it(dr(i,t.tmp,Ha)),!0)}return!(await Promise.all(s.map(n=>us(De(i,n.name),t,n)))).reduce((n,o)=>n&&o,!0)||t.preserveRoot===!1&&i===Pe(i).root||t.filter&&!await t.filter(i,e)?!1:(await it(dr(i,t.tmp,za)),!0)},dr=async(i,t,e)=>{let s=De(t,mr(i));return await Ba(i,s),await e(s)},Me=(i,t)=>{if(t?.signal?.aborted)throw t.signal.reason;try{return ds(i,t,kt(i))}catch(e){if(e?.code==="ENOENT")return!0;throw e}},ds=(i,t,e)=>{if(t?.signal?.aborted)throw t.signal.reason;if(!t.tmp)return ds(i,{...t,tmp:fr(i)},e);let s=t.tmp;if(i===t.tmp&&Pe(i).root!==i)throw new Error("cannot delete temp directory used for deletion");let r=e.isDirectory()?Pt(i):null;if(!Array.isArray(r)){if(r){if(r.code==="ENOENT")return!0;if(r.code!=="ENOTDIR")throw r}return t.filter&&!t.filter(i,e)?!1:(rt(()=>pr(i,s,qa)),!0)}let n=!0;for(let o of r){let a=De(i,o.name);n=ds(a,t,o)&&n}return!n||t.preserveRoot===!1&&i===Pe(i).root||t.filter&&!t.filter(i,e)?!1:(rt(()=>pr(i,s,Ct)),!0)},pr=(i,t,e)=>{let s=De(t,mr(i));return er(i,s),e(s)};var{unlink:Va,rmdir:Ka,lstat:Xa}=M,Ya=hs(ls(Va)),Ja=fs(cs(_t)),Za=hs(ls(Ka)),Qa=fs(cs(Ct)),tl=async(i,t)=>{if(t?.signal?.aborted)throw t.signal.reason;let{filter:e,...s}=t;try{return await Za(i,s)}catch(r){if(r?.code==="ENOTEMPTY")return await Le(i,s);throw r}},el=(i,t)=>{if(t?.signal?.aborted)throw t.signal.reason;let{filter:e,...s}=t;try{return Qa(i,s)}catch(r){if(r?.code==="ENOTEMPTY")return Me(i,s);throw r}},ht=Symbol("start"),yr=Symbol("child"),Fe=Symbol("finish"),Ie=async(i,t)=>{if(t?.signal?.aborted)throw t.signal.reason;try{return await ps(i,t,await Xa(i),ht)}catch(e){if(e?.code==="ENOENT")return!0;throw e}},je=(i,t)=>{if(t?.signal?.aborted)throw t.signal.reason;try{return ms(i,t,kt(i),ht)}catch(e){if(e?.code==="ENOENT")return!0;throw e}},ps=async(i,t,e,s=ht)=>{if(t?.signal?.aborted)throw t.signal.reason;let r=e.isDirectory()?await Nt(i):null;if(!Array.isArray(r)){if(r){if(r.code==="ENOENT")return!0;if(r.code!=="ENOTDIR")throw r}return t.filter&&!await t.filter(i,e)?!1:(await it(Ya(i,t)),!0)}let n=s===ht?yr:s,o=(await Promise.all(r.map(a=>ps(wr(i,a.name),t,a,n)))).reduce((a,l)=>a&&l,!0);if(s===ht)return ps(i,t,e,Fe);if(s===Fe){if(t.preserveRoot===!1&&i===gr(i).root||!o||t.filter&&!await t.filter(i,e))return!1;await it(tl(i,t))}return!0},ms=(i,t,e,s=ht)=>{let r=e.isDirectory()?Pt(i):null;if(!Array.isArray(r)){if(r){if(r.code==="ENOENT")return!0;if(r.code!=="ENOTDIR")throw r}return t.filter&&!t.filter(i,e)?!1:(rt(()=>Ja(i,t)),!0)}let n=!0;for(let o of r){let a=s===ht?yr:s,l=wr(i,o.name);n=ms(l,t,o,a)&&n}if(s===ht)return ms(i,t,e,Fe);if(s===Fe){if(t.preserveRoot===!1&&i===gr(i).root||!n||t.filter&&!t.filter(i,e))return!1;rt(()=>{el(i,t)})}return!0};var gs=X==="win32"?Ie:Ce,ws=X==="win32"?je:ke;var{rm:sl}=M,ys=async(i,t)=>(await sl(i,{...t,force:!0,recursive:!0}),!0),Ss=(i,t)=>(sr(i,{...t,force:!0,recursive:!0}),!0);var il=process.env.__TESTING_RIMRAF_NODE_VERSION__||process.version,rl=il.replace(/^v/,"").split("."),[Sr=0,nl=0]=rl.map(i=>parseInt(i,10)),br=Sr>14||Sr===14&&nl>=14,Er=!br||X==="win32"?()=>!1:i=>!i?.signal&&!i?.filter,vr=!br||X==="win32"?()=>!1:i=>!i?.signal&&!i?.filter;var Dt=i=>async(t,e)=>{let s=Ji(e);return s.glob&&(t=await xe(t,s.glob)),Array.isArray(t)?!!(await Promise.all(t.map(r=>i(se(r,s),s)))).reduce((r,n)=>r&&n,!0):!!await i(se(t,s),s)},Lt=i=>(t,e)=>{let s=Zi(e);return s.glob&&(t=Oe(t,s.glob)),Array.isArray(t)?!!t.map(r=>i(se(r,s),s)).reduce((r,n)=>r&&n,!0):!!i(se(t,s),s)},Or=Lt(Ss),ol=Object.assign(Dt(ys),{sync:Or}),Ar=Lt(ws),al=Object.assign(Dt(gs),{sync:Ar}),Rr=Lt(je),ll=Object.assign(Dt(Ie),{sync:Rr}),Cr=Lt(ke),cl=Object.assign(Dt(Ce),{sync:Cr}),kr=Lt(Me),hl=Object.assign(Dt(Le),{sync:kr}),bs=Lt((i,t)=>vr(t)?Ss(i,t):ws(i,t)),_r=bs,xr=Dt((i,t)=>Er(t)?ys(i,t):gs(i,t)),Tr=Object.assign(xr,{rimraf:xr,sync:bs,rimrafSync:bs,manual:al,manualSync:Ar,native:ol,nativeSync:Or,posix:cl,posixSync:Cr,windows:ll,windowsSync:Rr,moveRemove:hl,moveRemoveSync:kr});Tr.rimraf=Tr;var Pr=ul(new URL(".",import.meta.url)),vs=Nr(Pr,"../builder/vite-config.js"),dl=Nr(Pr,"../builder/vite-entry-server.js");async function Dr({options:i,logger:t}){t.info(`Building template...
|
|
40
|
+
`),i.clean&&_r(fl.join(process.cwd(),"dist"));let e="production";i.ssr==="local"&&(e="development",process.env.NODE_ENV=e),i.ssr?(await Es({configFile:vs,customLogger:t,mode:e,logLevel:i.logLevel,clearScreen:i.clearScreen,build:{ssrManifest:!0,emptyOutDir:!0}}),await Es({configFile:vs,customLogger:t,mode:e,logLevel:i.logLevel,clearScreen:i.clearScreen,ssr:{target:"webworker"},build:{ssr:dl}})):await Es({configFile:vs,customLogger:t,logLevel:i.logLevel,clearScreen:i.clearScreen,build:{emptyOutDir:!0}})}async function Lr({options:i,logger:t}){t.info("Logging out fom Enpage..."),j.clear(),t.info(`Done.
|
|
41
|
+
`),process.exit(0)}var xs;Mt.name("enpage").option("-l, --logLevel <level>","[string] info | warn | error | silent | debug").option("--clearScreen","[boolean] allow/disable clear screen when logging").option("--dry-run","[boolean] run command without making changes").hook("preAction",i=>{xs=We(i.optsWithGlobals().logLevel,i.optsWithGlobals().clearScreen,!0),process.removeAllListeners("warning"),process.on("warning",t=>{t.name==="DeprecationWarning"&&t.message.includes("util.isArray")||xs.warnOnce(`Warning: ${t.name} - ${t.message}`)})});Mt.command("build").description("Build template").option("--ssr [type]",`Enable server side rendering.
|
|
40
42
|
Pass --ssr to generate a SSR-enabled build.
|
|
41
|
-
Pass --ssr=local to generate a SSR-enabled build that can be tested locally.`,Boolean,!1).option("--no-clean","Don't clean directory before buidling").action(function(){
|
|
43
|
+
Pass --ssr=local to generate a SSR-enabled build that can be tested locally.`,Boolean,!1).option("--no-clean","Don't clean directory before buidling").action(function(){Dr($e(this))});Mt.command("publish").description("Publish a template to Enpage").argument("[directory]","Directory to publish").option("--no-check","Don't check for required files").action(function(){Ys($e(this))});Mt.command("login").description("Login to Enpage").action(function(){Js($e(this))});Mt.command("logout").description("Logout from Enpage").action(function(){Lr($e(this))});Mt.parse();function $e(i){return{options:i.optsWithGlobals(),args:i.args,logger:xs}}
|
|
42
44
|
/*!
|
|
43
45
|
* parse-gitignore <https://github.com/jonschlinkert/parse-gitignore>
|
|
44
46
|
* Copyright (c) 2015-present, Jon Schlinkert.
|
package/dist/node/cli/store.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/*! Enpage - Copyright (C) 2024 Flippable - https://github.com/enpage/enpage/blob/main/LICENSE */
|
|
2
|
-
var g="enpage-cli";var
|
|
3
|
-
`)),{...
|
|
2
|
+
var g="enpage-cli";var I=process.env.PUBLIC_ENPAGE_OAUTH_CLIENT_ID??"50000000-0000-0000-0000-000000000001",d=process.env.PUBLIC_ENPAGE_API_BASE_URL??"https://api.enpage.co",w=process.env.PUBLIC_ENPAGE_FRONTEND_BASE_URL??"https://enpage.co";var m="oauth/userinfo";import L from"conf";import{createLogger as _}from"vite";var l="0.0.67";import i from"chalk";function h(e,t,o=!1){let r=_(e==="debug"?"info":e,{prefix:"[enpage]",allowClearScreen:t});return o&&r.info(i.hex("#7270c6").bold(`\u{1F680} Enpage v${l}
|
|
3
|
+
`)),{...r,success:(s,n)=>r.info(i.green(s),n),error:(s,n)=>r.error(i.red(s),n),warn:(s,n)=>r.warn(i.yellow(s),n),warnOnce:(s,n)=>r.warnOnce(i.yellow(s),n),debug:(s,n)=>{e==="debug"&&r.info(i.gray(s),n)}}}var u=h();async function y(e,t={}){a.get("access_token")&&(t.Authorization=`Bearer ${a.get("access_token")}`);let o=await fetch(T(e),{headers:t,method:"GET"}).catch(r=>{u.error(`Fatal Error requesting API: ${r.message} (${r.cause.code})`),u.error("Please check your internet connection and try again, or retry later."),process.exit(1)});return x(o)}function T(e){let t=new URL(d.endsWith("/")?d:`${d}/`);return new URL(e,t)}async function x(e){let t=e.headers.get("content-type")?.startsWith("application/json")?await e.json():await e.text();return e.ok?{isSuccess:!0,isError:!1,status:e.status,statusText:e.statusText,data:t}:{isSuccess:!1,isError:!0,status:e.status,statusText:e.statusText,data:t}}import c from"node:path";import R from"node:crypto";import p from"node:fs";import{fileURLToPath as O}from"node:url";function f(){let e;if(process.env.npm_config_user_agent){let t=process.env.npm_config_user_agent.split(" ")[0];e=t.slice(0,t.lastIndexOf("/"))}return e||(console.log("Warning: could not detect package manager"),e="npm"),e}import k from"chalk";var P=O(new URL(".",import.meta.url)),S=v(),a=new L({projectName:g,encryptionKey:S,clearInvalidConfig:!0});async function Q(e=!1){let t=a.get("access_token"),o=a.get("expires_at");if(!t)return!1;if(o&&o<Date.now())return console.log("Seems like your token expired..."),!1;if(!e)return!0;let{isSuccess:r}=await y(m);return r}function Z(){let e=a.get("access_token");if(!e){let t=f();throw new Error(`Access token not found. Please run ${k.cyan(`${t} run enpage:login`)} to authenticate.`)}return e}function N(){let e=P;for(;e!==c.parse(e).root;){let t=c.join(e,"node_modules");if(p.existsSync(t))return t;e=c.dirname(e)}return null}function v(){let e=N();if(!e)throw new Error("Could not find nearest node_modules directory.");let t=c.join(e,".enpage-tmp");p.existsSync(t)||p.mkdirSync(t,{recursive:!0,mode:448});let o=c.join(t,".enpage-key");if(!p.existsSync(o)){let s=R.randomBytes(32).toString("hex");return p.writeFileSync(o,s,{mode:384,flush:!0}),s}return p.readFileSync(o,"utf8")}export{a as accessStore,Z as getTokenOrThrow,Q as isLoggedIn};
|