@visulima/fs 1.11.1 → 2.0.1

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/index.d.ts CHANGED
@@ -1,17 +1,9 @@
1
- import { W as WalkOptions, E as EmptyDirOptions, M as Match, F as FindUpOptions, R as ReadFileOptions, C as ContentType, a as ReadJsonOptions, J as JsonReviver, b as ReadYamlOptions, Y as YamlReviver, c as WalkEntry, d as WriteFileOptions, e as WriteJsonOptions, f as YamlReplacer } from './types-HVB0D8On.js';
2
- export { k as CodeFrameLocation, h as FIND_UP_STOP, g as F_OK, l as JsonReplacer, i as R_OK, m as ReadFileEncoding, j as W_OK, X as X_OK } from './types-HVB0D8On.js';
1
+ import { W as WalkOptions, M as Match, F as FindUpOptions, a as WalkEntry, R as ReadFileOptions, C as ContentType, b as ReadJsonOptions, J as JsonReviver, c as ReadYamlOptions, Y as YamlReviver, E as EmptyDirOptions, d as WriteFileOptions, e as WriteJsonOptions, f as YamlReplacer } from './types-BtNfXx_X.js';
2
+ export { k as CodeFrameLocation, h as FIND_UP_STOP, g as F_OK, l as JsonReplacer, i as R_OK, m as ReadFileEncoding, j as W_OK, X as X_OK } from './types-BtNfXx_X.js';
3
3
  import { JsonValue } from 'type-fest';
4
4
  import { CreateNodeOptions, DocumentOptions, ParseOptions, SchemaOptions, ToStringOptions } from 'yaml';
5
5
  import 'node:fs';
6
6
 
7
- declare const collect: (directory: string, options?: WalkOptions) => Promise<string[]>;
8
-
9
- declare const collectSync: (directory: string, options?: WalkOptions) => string[];
10
-
11
- declare const emptyDir$1: (dir: URL | string, options?: EmptyDirOptions) => Promise<void>;
12
-
13
- declare const emptyDir: (dir: URL | string, options?: EmptyDirOptions) => void;
14
-
15
7
  declare const ensureDir: (directory: URL | string) => Promise<void>;
16
8
 
17
9
  declare const ensureDirSync: (directory: URL | string) => void;
@@ -30,10 +22,18 @@ declare const EOL: "\n" | "\r\n";
30
22
  declare const detect: (content: string) => typeof EOL | null;
31
23
  declare const format: (content: string, eol: typeof EOL) => string;
32
24
 
25
+ declare const collect: (directory: string, options?: WalkOptions) => Promise<string[]>;
26
+
27
+ declare const collectSync: (directory: string, options?: WalkOptions) => string[];
28
+
33
29
  declare const findUp: (name: string | string[] | readonly string[] | ((directory: string) => Match | Promise<Match>), options?: FindUpOptions) => Promise<string | undefined>;
34
30
 
35
31
  declare const findUpSync: (name: string | string[] | readonly string[] | ((directory: string) => Match), options?: FindUpOptions) => string | undefined;
36
32
 
33
+ declare function walk(directory: URL | string, { extensions, followSymlinks, includeDirs: includeDirectories, includeFiles, includeSymlinks, match, maxDepth, skip, }?: WalkOptions): AsyncIterableIterator<WalkEntry>;
34
+
35
+ declare function walkSync(directory: URL | string, { extensions, followSymlinks, includeDirs: includeDirectories, includeFiles, includeSymlinks, match, maxDepth, skip, }?: WalkOptions): IterableIterator<WalkEntry>;
36
+
37
37
  declare function isAccessible(path: URL | string, mode?: number): Promise<boolean>;
38
38
 
39
39
  declare function isAccessibleSync(path: URL | string, mode?: number): boolean;
@@ -54,6 +54,10 @@ declare function readYaml<R = Record<string, unknown>>(path: URL | string, reviv
54
54
  declare function readYamlSync<R = Record<string, unknown>>(path: URL | string, options?: ReadYamlOptions<"brotli" | "gzip" | "none">): R;
55
55
  declare function readYamlSync<R = Record<string, unknown>>(path: URL | string, reviver?: YamlReviver, options?: ReadYamlOptions<"brotli" | "gzip" | "none">): R;
56
56
 
57
+ declare const emptyDir$1: (dir: URL | string, options?: EmptyDirOptions) => Promise<void>;
58
+
59
+ declare const emptyDir: (dir: URL | string, options?: EmptyDirOptions) => void;
60
+
57
61
  declare const remove: (path: URL | string, options?: {
58
62
  maxRetries?: number | undefined;
59
63
  retryDelay?: number | undefined;
@@ -64,10 +68,6 @@ declare const removeSync: (path: URL | string, options?: {
64
68
  retryDelay?: number | undefined;
65
69
  }) => void;
66
70
 
67
- declare function walk(directory: URL | string, { extensions, followSymlinks, includeDirs: includeDirectories, includeFiles, includeSymlinks, match, maxDepth, skip, }?: WalkOptions): AsyncIterableIterator<WalkEntry>;
68
-
69
- declare function walkSync(directory: URL | string, { extensions, followSymlinks, includeDirs: includeDirectories, includeFiles, includeSymlinks, match, maxDepth, skip, }?: WalkOptions): IterableIterator<WalkEntry>;
70
-
71
71
  declare const writeFile: (path: URL | string, content: ArrayBuffer | ArrayBufferView | string, options?: WriteFileOptions) => Promise<void>;
72
72
 
73
73
  declare const writeFileSync: (path: URL | string, content: ArrayBuffer | ArrayBufferView | string, options?: WriteFileOptions) => void;
package/dist/index.js CHANGED
@@ -1,23 +1,24 @@
1
- import { a as a$2, b } from './chunk-3EHZOWRU.js';
2
- import { a as a$1, b as b$1 } from './chunk-4WZBYISP.js';
1
+ import { a as a$1, b as b$1 } from './chunk-X5PFFPHW.js';
2
+ import { a, b, c, d } from './chunk-DXCWJAJU.js';
3
3
  import './chunk-UPN3Y5W3.js';
4
- import { readdir, realpath, stat, mkdir, rm, lstat, writeFile, link, access, readFile, unlink, rename, chown, chmod } from 'node:fs/promises';
5
- import { resolve, join, normalize, basename, dirname, parse, isAbsolute } from 'node:path';
6
- import { readdirSync, realpathSync, statSync, existsSync, mkdirSync, rmSync, lstatSync, writeFileSync, linkSync, accessSync, readFileSync, unlinkSync, renameSync, chownSync, chmodSync } from 'node:fs';
4
+ import { readdir, realpath, lstat, mkdir, writeFile, link, stat, access, readFile, rm, unlink, rename, chown, chmod } from 'node:fs/promises';
5
+ import { readdirSync, realpathSync, lstatSync, mkdirSync, writeFileSync, linkSync, statSync, accessSync, readFileSync, existsSync, rmSync, unlinkSync, renameSync, chownSync, chmodSync } from 'node:fs';
6
+ import { resolve, join, normalize, dirname, basename, isAbsolute } from 'pathe';
7
7
  import { platform } from 'node:process';
8
+ import { parse } from 'node:path';
8
9
  import { brotliDecompress, unzip, brotliDecompressSync, unzipSync } from 'node:zlib';
9
10
  import { parse as parse$1, stringify } from 'yaml';
10
11
 
11
- var st=t=>{if(!t||!(t instanceof URL)&&typeof t!="string")throw new TypeError("Path must be a non-empty string or URL.")},a=st;var at=t=>{let e=t.replace(/\.\*/g,".([^/]*)").replace(/\*\*/g,"(.*)").replace(/(?<!\.)\*(?!\*)/g,"([^/]*)").replace(/\?/g,"[^/]").replace(/\.(?!\*)/g,"\\.").replace(/\{/g,"(").replace(/\}/g,")").replace(/,/g,"|").replace(/\[!(.*?)\]/g,"[^$1]");return new RegExp(`^${e}$`)},F=at;var ft=(t,e,r,o)=>e&&!e.some(i=>t.endsWith(i))||r&&!r.some(i=>i.test(t))?!1:!(o&&o.some(i=>i.test(t))),w=ft;var gt=async t=>{let e=normalize(t),r=basename(e),o=await stat(e);return {isDirectory:o.isDirectory,isFile:o.isFile,isSymbolicLink:o.isSymbolicLink,name:r,path:e}};async function*P(t,{extensions:e,followSymlinks:r=!1,includeDirs:o=!0,includeFiles:i=!0,includeSymlinks:s=!0,match:m,maxDepth:d=Number.POSITIVE_INFINITY,skip:u}={}){if(a(t),d<0)return;let p=m?m.map(n=>typeof n=="string"?F(n):n):void 0,y=u?u.map(n=>typeof n=="string"?F(n):n):void 0;if(t=resolve(a$1(t)),o&&w(t,e,p,y)&&(yield await gt(t)),!(d<1||!w(t,void 0,void 0,y)))try{for await(let n of await readdir(t,{withFileTypes:!0})){let g=join(t,n.name);if(n.isSymbolicLink())if(r)g=await realpath(g);else if(s&&w(g,e,p,y))yield {isDirectory:n.isDirectory,isFile:n.isFile,isSymbolicLink:n.isSymbolicLink,name:n.name,path:g};else continue;n.isSymbolicLink()||n.isDirectory()?yield*P(g,{extensions:e,followSymlinks:r,includeDirs:o,includeFiles:i,includeSymlinks:s,match:p,maxDepth:d-1,skip:y}):n.isFile()&&i&&w(g,e,p,y)&&(yield {isDirectory:n.isDirectory,isFile:n.isFile,isSymbolicLink:n.isSymbolicLink,name:n.name,path:g});}}catch(n){throw n instanceof a$2?n:new a$2(n,t)}}var wt=async(t,e={})=>{let r={extensions:["js","mjs","cjs","ts"],...e},o=[];for await(let i of P(t,r))o.push(i.path);return o},Ot=wt;var kt=t=>{let e=normalize(t),r=basename(e),o=statSync(e);return {isDirectory:o.isDirectory,isFile:o.isFile,isSymbolicLink:o.isSymbolicLink,name:r,path:e}};function*k(t,{extensions:e,followSymlinks:r=!1,includeDirs:o=!0,includeFiles:i=!0,includeSymlinks:s=!0,match:m,maxDepth:d=Number.POSITIVE_INFINITY,skip:u}={}){if(a(t),d<0)return;let p=m?m.map(n=>typeof n=="string"?F(n):n):void 0,y=u?u.map(n=>typeof n=="string"?F(n):n):void 0;if(t=resolve(a$1(t)),o&&w(t,e,p,y)&&(yield kt(t)),!(d<1||!w(t,void 0,void 0,y)))try{for(let n of readdirSync(t,{withFileTypes:!0})){let g=join(t,n.name);if(n.isSymbolicLink())if(r)g=realpathSync(g);else if(s&&w(g,e,p,y))yield {isDirectory:n.isDirectory,isFile:n.isFile,isSymbolicLink:n.isSymbolicLink,name:n.name,path:g};else continue;n.isSymbolicLink()||n.isDirectory()?yield*k(g,{extensions:e,followSymlinks:r,includeDirs:o,includeFiles:i,includeSymlinks:s,match:p,maxDepth:d-1,skip:y}):n.isFile()&&i&&w(g,e,p,y)&&(yield {isDirectory:n.isDirectory,isFile:n.isFile,isSymbolicLink:n.isSymbolicLink,name:n.name,path:g});}}catch(n){throw n instanceof a$2?n:new a$2(n,t)}}var Et=(t,e={})=>{let r={extensions:["js","mjs","cjs","ts"],...e},o=[];for(let i of k(t,r))o.push(i.path);return o},Dt=Et;var h=0,E=4,Lt=2,Tt=1,D=Symbol("findUpStop");var Yt=async(t,e)=>{if(a(t),!existsSync(t)){await mkdir(t,{recursive:!0});return}for await(let r of await readdir(t))await rm(join(a$1(t),r),{...e,force:!0,recursive:!0});},Nt=Yt;var zt=(t,e)=>{if(a(t),!existsSync(t)){mkdirSync(t,{recursive:!0});return}for(let r of readdirSync(t))rmSync(join(a$1(t),r),{...e,force:!0,recursive:!0});},Kt=zt;var O=t=>{if(t.isFile())return "file";if(t.isDirectory())return "dir";if(t.isSymbolicLink())return "symlink"};var Bt=async t=>{a(t);try{let e=await lstat(t);if(!e.isDirectory())throw new Error(`Ensure path exists, expected 'dir', got '${O(e)}'`);return}catch(e){if(e.code!=="ENOENT")throw e}try{await mkdir(t,{recursive:!0});}catch(e){if(e.code!=="EEXIST")throw e;let r=await lstat(t);if(!r.isDirectory())throw new Error(`Ensure path exists, expected 'dir', got '${O(r)}'`)}},L=Bt;var Xt=t=>{a(t);try{let e=lstatSync(t);if(!e.isDirectory())throw new Error(`Ensure path exists, expected 'dir', got '${O(e)}'`);return}catch(e){if(e.code!=="ENOENT")throw e}try{mkdirSync(t,{recursive:!0});}catch(e){if(e.code!=="EEXIST")throw e;let r=lstatSync(t);if(!r.isDirectory())throw new Error(`Ensure path exists, expected 'dir', got '${O(r)}'`)}},T=Xt;var Qt=async t=>{a(t);try{let e=await lstat(t);if(!e.isFile())throw new Error(`Ensure path exists, expected 'file', got '${O(e)}'`)}catch(e){if(e.code==="ENOENT"){await L(dirname(a$1(t))),await writeFile(t,new Uint8Array);return}throw e}},Zt=Qt;var oe=t=>{a(t);try{let e=lstatSync(t);if(!e.isFile())throw new Error(`Ensure path exists, expected 'file', got '${O(e)}'`)}catch(e){if(e.code==="ENOENT"){T(dirname(a$1(t))),writeFileSync(t,new Uint8Array);return}throw e}},ie=oe;var ne=(t,e)=>!!e.ino&&!!e.dev&&e.ino===t.ino&&e.dev===t.dev,V=ne;var fe=async(t,e)=>{a(t),a(e);let r;try{r=await lstat(e);}catch{}let o;try{o=await lstat(t);}catch(i){throw i.message=i.message.replace("lstat","ensureLink"),i}r&&V(o,r)||(await L(dirname(a$1(e))),await link(t,e));},ce=fe;var le=(t,e)=>{a(t),a(e);let r;try{r=lstatSync(e);}catch{}let o;try{o=lstatSync(t);}catch(i){throw i.message=i.message.replace("lstat","ensureLink"),i}r&&V(o,r)||(T(dirname(a$1(e))),linkSync(t,e));},de=le;var G=/\r?\n/g,z=`
12
- `,_=`\r
13
- `,ue=platform==="win32"?_:z,ge=t=>{let e=t.match(G);if(!e||e.length===0)return null;let r=e.filter(i=>i===_).length,o=e.length-r;return r>o?_:z},we=(t,e)=>t.replaceAll(G,e);var xe=async(t,e={})=>{if(typeof t!="string"&&!Array.isArray(t)&&typeof t!="function")throw new TypeError("The `name` argument must be of type `string` or `string[]`");let r=e.cwd?a$1(e.cwd):process.cwd();a(r);let o=resolve(r),{root:i}=parse(o),s=a$1(e.stopAt??i);a(s);let m=resolve(o,s),d=e.type??"file",u=async function(p){return typeof t=="function"?[await t(p)]:typeof t=="string"?[t]:Array.isArray(t)?t:[t]};for(;o&&o!==m&&o!==i;){for await(let p of await u(o)){if(p===D)return;if(p===void 0)continue;let y=isAbsolute(p)?p:resolve(o,p);try{let n=await stat(y);if(d==="file"&&n.isFile()||d==="directory"&&n.isDirectory())return y}catch{}}o=dirname(o);}},Fe=xe;var De=(t,e={})=>{if(typeof t!="string"&&!Array.isArray(t)&&typeof t!="function")throw new TypeError("The `name` argument must be of type `string` or `string[]`");let r=e.cwd?a$1(e.cwd):process.cwd();a(r);let o=resolve(r),{root:i}=parse(o),s=a$1(e.stopAt??i);a(s);let m=resolve(o,s),d=e.type??"file",u=function(p){return typeof t=="function"?[t(p)]:typeof t=="string"?[t]:Array.isArray(t)?t:[t]};for(;o&&o!==m&&o!==i;){for(let p of u(o)){if(p===D)return;if(p===void 0)continue;let y=isAbsolute(p)?p:resolve(o,p);try{let n=statSync(y);if(d==="file"&&n.isFile()||d==="directory"&&n.isDirectory())return y}catch{}}o=dirname(o);}},Le=De;async function ve(t,e=0){a(t),t=a$1(t);try{return await access(t,e),!0}catch{return !1}}var R=ve;function Ae(t,e=0){a(t),t=a$1(t);try{return accessSync(t,e),!0}catch{return !1}}var S=Ae;var Ne={brotli:brotliDecompress,gzip:unzip,none:(t,e)=>{e(null,t);}},We=async(t,e)=>{if(a(t),t=a$1(t),!await R(t))throw new b(`unable to read the non-accessible file: ${t}`);if(!await R(t,4))throw new Error(`Unable to read the non-readable file: ${t}`);let{buffer:r,compression:o,encoding:i,flag:s}=e??{};return await readFile(t,s?{encoding:i,flag:s}:{encoding:i}).then(async m=>await new Promise((d,u)=>{Ne[o??"none"](m,(p,y)=>{p?u(p):d(r?y:y.toString());});})).catch(m=>{throw m})},v=We;var Ce={brotli:brotliDecompressSync,gzip:unzipSync,none:t=>t},ze=(t,e)=>{if(a(t),t=a$1(t),!S(t))throw new b(`unable to read the non-accessible file: ${t}`);if(!S(t,4))throw new b(`invalid access to read file at: ${t}`);let{buffer:r,compression:o,encoding:i,flag:s}=e??{},m=readFileSync(t,s?{encoding:i,flag:s}:{encoding:i}),d=Ce[o??"none"](m);return r?d:d.toString()},U=ze;async function Ke(t,e,r){typeof e=="object"&&(r=e,e=void 0);let o=await v(t,{buffer:!0,encoding:void 0}),i=new TextDecoder().decode(o),{beforeParse:s,color:m}=r??{};return typeof s=="function"&&(i=s(i)),b$1(i,e,a$1(t),{color:m})}var Me=Ke;function Be(t,e,r){typeof e=="object"&&(r=e,e=void 0);let o=U(t,{buffer:!0,encoding:void 0}),i=new TextDecoder().decode(o),{beforeParse:s,color:m}=r??{};return typeof s=="function"&&(i=s(i)),b$1(i,e,a$1(t),{color:m})}var je=Be;async function Xe(t,e,r){let{buffer:o,compression:i,encoding:s="utf8",flag:m,...d}=r??{},u=await v(t,{buffer:o,compression:i,encoding:s,flag:m});return typeof e=="function"?parse$1(u,e,d):parse$1(u,d)}var He=Xe;function Ge(t,e,r){let{buffer:o,compression:i,encoding:s="utf8",flag:m,...d}=r??{},u=U(t,{buffer:o,compression:i,encoding:s,flag:m});return typeof e=="function"?parse$1(u,e,d):parse$1(u,d)}var qe=Ge;var tr=async(t,e={})=>{a(t);try{await unlink(t);}catch{}try{await rm(t,{force:!0,maxRetries:e?.maxRetries,recursive:!0,retryDelay:e?.retryDelay});}catch{}},er=tr;var ir=(t,e={})=>{a(t);try{unlinkSync(t);}catch{}try{rmSync(t,{force:!0,maxRetries:e?.maxRetries,recursive:!0,retryDelay:e?.retryDelay});}catch{}},nr=ir;var sr=t=>{if(typeof t!="string"&&!(t instanceof ArrayBuffer)&&!ArrayBuffer.isView(t))throw new TypeError("File contents must be a string, ArrayBuffer, or ArrayBuffer view.")},$=sr;var ar=new TextEncoder,fr=t=>{if(t instanceof Uint8Array)return t;if(typeof t=="string")return ar.encode(t);if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t)){let e=t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength);return new Uint8Array(e)}throw new TypeError("Invalid contents type. Expected string or ArrayBuffer.")},C=fr;var gr=async(t,e,r)=>{r={encoding:"utf8",flag:"w",overwrite:!0,recursive:!0,...r},a(t),$(e),t=a$1(t);try{let o=await R(t,0);if(!o&&r.recursive){let m=dirname(t);await R(m,0)||await mkdir(m,{recursive:!0});}let i;await writeFile(`${t}.tmp`,C(e),{encoding:r.encoding,flag:r.flag}),o&&!r.overwrite&&(i=await stat(t),r.chown===void 0&&(r.chown={gid:i.gid,uid:i.uid}),await rename(t,`${t}.bak`));let s=`${t}.tmp`;if(r.chown)try{await chown(s,r.chown.uid,r.chown.gid);}catch{}await chmod(s,i&&!r.mode?i.mode:r.mode??438),await rename(s,t);}catch(o){throw new Error(`Failed to write file at: ${t} - ${o.message}`,{cause:o})}finally{await R(`${t}.tmp`)&&await unlink(`${t}.tmp`);}},A=gr;var br=(t,e,r)=>{r={encoding:"utf8",flag:"w",overwrite:!0,recursive:!0,...r},a(t),$(e),t=a$1(t);try{let o=S(t,0);if(!o&&r.recursive){let m=dirname(t);S(m,0)||mkdirSync(m,{recursive:!0});}let i;writeFileSync(`${t}.tmp`,C(e),{encoding:r.encoding,flag:r.flag}),o&&!r.overwrite&&(i=statSync(t),r.chown===void 0&&(r.chown={gid:i.gid,uid:i.uid}),renameSync(t,`${t}.bak`));let s=`${t}.tmp`;if(r.chown)try{chownSync(s,r.chown.uid,r.chown.gid);}catch{}chmodSync(s,i&&!r.mode?i.mode:r.mode??438),renameSync(s,t);}catch(o){throw new Error(`Failed to write file at: ${t} - ${o.message}`,{cause:o})}finally{S(`${t}.tmp`)&&unlinkSync(`${t}.tmp`);}},I=br;var Pr=/^(?:( )+|\t+)/,J="space",rt="tab";function et(t,e){let r=new Map,o=0,i,s;for(let m of t.split(/\n/g)){if(!m)continue;let d,u,p,y,n,g=m.match(Pr);if(g===null)o=0,i="";else {if(d=g[0].length,u=g[1]?J:rt,e&&u===J&&d===1)continue;u!==i&&(o=0),i=u,p=1,y=0;let N=d-o;if(o=d,N===0)p=0,y=1;else {let nt=N>0?N:-N;s=kr(u,nt);}n=r.get(s),n=n===void 0?[1,0]:[n[0]+p,n[1]+y],r.set(s,n);}}return r}function kr(t,e){return (t===J?"s":"t")+String(e)}function Er(t){let r=t[0]==="s"?J:rt,o=Number(t.slice(1));return {type:r,amount:o}}function Dr(t){let e,r=0,o=0;for(let[i,[s,m]]of t)(s>r||s===r&&m>o)&&(r=s,o=m,e=i);return e}function Lr(t,e){return (t===J?" ":" ").repeat(e)}function Y(t){if(typeof t!="string")throw new TypeError("Expected a string");let e=et(t,!0);e.size===0&&(e=et(t,!1));let r=Dr(e),o,i=0,s="";return r!==void 0&&({type:o,amount:i}=Er(r),s=Lr(o,i)),{amount:i,type:o,indent:s}}var vr=async(t,e,r={})=>{let{detectIndent:o,indent:i,replacer:s,stringify:m=JSON.stringify,...d}={indent:" ",...r},u=i,p=`
14
- `;if(await R(t,4))try{let n=await readFile(t,"utf8");if(o){let{indent:g}=Y(n);u=g;}p=n.endsWith(`
12
+ var h=0,P=4,at=2,ft=1,k=Symbol("findUpStop");var w=t=>{if(t.isFile())return "file";if(t.isDirectory())return "dir";if(t.isSymbolicLink())return "symlink"};var mt=async t=>{a(t);try{let e=await lstat(t);if(!e.isDirectory())throw new Error(`Ensure path exists, expected 'dir', got '${w(e)}'`);return}catch(e){if(e.code!=="ENOENT")throw e}try{await mkdir(t,{recursive:!0});}catch(e){if(e.code!=="EEXIST")throw e;let r=await lstat(t);if(!r.isDirectory())throw new Error(`Ensure path exists, expected 'dir', got '${w(r)}'`)}},E=mt;var lt=t=>{a(t);try{let e=lstatSync(t);if(!e.isDirectory())throw new Error(`Ensure path exists, expected 'dir', got '${w(e)}'`);return}catch(e){if(e.code!=="ENOENT")throw e}try{mkdirSync(t,{recursive:!0});}catch(e){if(e.code!=="EEXIST")throw e;let r=lstatSync(t);if(!r.isDirectory())throw new Error(`Ensure path exists, expected 'dir', got '${w(r)}'`)}},D=lt;var gt=async t=>{a(t);try{let e=await lstat(t);if(!e.isFile())throw new Error(`Ensure path exists, expected 'file', got '${w(e)}'`)}catch(e){if(e.code==="ENOENT"){await E(dirname(b(t))),await writeFile(t,new Uint8Array);return}throw e}},wt=gt;var ht=t=>{a(t);try{let e=lstatSync(t);if(!e.isFile())throw new Error(`Ensure path exists, expected 'file', got '${w(e)}'`)}catch(e){if(e.code==="ENOENT"){D(dirname(b(t))),writeFileSync(t,new Uint8Array);return}throw e}},xt=ht;var Ft=(t,e)=>!!e.ino&&!!e.dev&&e.ino===t.ino&&e.dev===t.dev,V=Ft;var kt=async(t,e)=>{a(t),a(e);let r;try{r=await lstat(e);}catch{}let o;try{o=await lstat(t);}catch(i){throw i.message=i.message.replace("lstat","ensureLink"),i}r&&V(o,r)||(await E(dirname(b(e))),await link(t,e));},Et=kt;var Tt=(t,e)=>{a(t),a(e);let r;try{r=lstatSync(e);}catch{}let o;try{o=lstatSync(t);}catch(i){throw i.message=i.message.replace("lstat","ensureLink"),i}r&&V(o,r)||(D(dirname(b(e))),linkSync(t,e));},vt=Tt;var q=/\r?\n/g,z=`
13
+ `,$=`\r
14
+ `,It=platform==="win32"?$:z,At=t=>{let e=t.match(q);if(!e||e.length===0)return null;let r=e.filter(i=>i===$).length,o=e.length-r;return r>o?$:z},Jt=(t,e)=>t.replaceAll(q,e);var Yt=t=>{let e=t.replace(/\.\*/g,".([^/]*)").replace(/\*\*/g,"(.*)").replace(/(?<!\.)\*(?!\*)/g,"([^/]*)").replace(/\?/g,"[^/]").replace(/\.(?!\*)/g,"\\.").replace(/\{/g,"(").replace(/\}/g,")").replace(/,/g,"|").replace(/\[!(.*?)\]/g,"[^$1]");return new RegExp(`^${e}$`)},F=Yt;var Nt=(t,e,r,o)=>e&&!e.some(i=>t.endsWith(i))||r&&!r.some(i=>i.test(t))?!1:!(o&&o.some(i=>i.test(t))),O=Nt;var Mt=async t=>{let e=normalize(t),r=basename(e),o=await stat(e);return {isDirectory:o.isDirectory,isFile:o.isFile,isSymbolicLink:o.isSymbolicLink,name:r,path:e}};async function*L(t,{extensions:e,followSymlinks:r=!1,includeDirs:o=!0,includeFiles:i=!0,includeSymlinks:s=!0,match:a$2,maxDepth:d=Number.POSITIVE_INFINITY,skip:u}={}){if(a(t),d<0)return;let f=a$2?a$2.map(n=>typeof n=="string"?F(n):n):void 0,y=u?u.map(n=>typeof n=="string"?F(n):n):void 0;if(t=resolve(b(t)),o&&O(t,e,f,y)&&(yield await Mt(t)),!(d<1||!O(t,void 0,void 0,y)))try{for await(let n of await readdir(t,{withFileTypes:!0})){let g=join(t,n.name);if(n.isSymbolicLink())if(r)g=await realpath(g);else if(s&&O(g,e,f,y))yield {isDirectory:n.isDirectory,isFile:n.isFile,isSymbolicLink:n.isSymbolicLink,name:n.name,path:g};else continue;n.isSymbolicLink()||n.isDirectory()?yield*L(g,{extensions:e,followSymlinks:r,includeDirs:o,includeFiles:i,includeSymlinks:s,match:f,maxDepth:d-1,skip:y}):n.isFile()&&i&&O(g,e,f,y)&&(yield {isDirectory:n.isDirectory,isFile:n.isFile,isSymbolicLink:n.isSymbolicLink,name:n.name,path:g});}}catch(n){throw n instanceof a$1?n:new a$1(n,t)}}var jt=async(t,e={})=>{let r={extensions:["js","mjs","cjs","ts"],...e},o=[];for await(let i of L(t,r))o.push(i.path);return o},Bt=jt;var te=t=>{let e=normalize(t),r=statSync(e);return {isDirectory:r.isDirectory,isFile:r.isFile,isSymbolicLink:r.isSymbolicLink,name:basename(e),path:e}};function*T(t,{extensions:e,followSymlinks:r=!1,includeDirs:o=!0,includeFiles:i=!0,includeSymlinks:s=!0,match:a$2,maxDepth:d=Number.POSITIVE_INFINITY,skip:u}={}){if(a(t),d<0)return;let f=a$2?a$2.map(n=>typeof n=="string"?F(n):n):void 0,y=u?u.map(n=>typeof n=="string"?F(n):n):void 0;if(t=resolve(b(t)),o&&O(t,e,f,y)&&(yield te(t)),!(d<1||!O(t,void 0,void 0,y)))try{for(let n of readdirSync(t,{withFileTypes:!0})){let g=join(t,n.name);if(n.isSymbolicLink())if(r)g=realpathSync(g);else if(s&&O(g,e,f,y))yield {isDirectory:n.isDirectory,isFile:n.isFile,isSymbolicLink:n.isSymbolicLink,name:n.name,path:normalize(g)};else continue;n.isSymbolicLink()||n.isDirectory()?yield*T(g,{extensions:e,followSymlinks:r,includeDirs:o,includeFiles:i,includeSymlinks:s,match:f,maxDepth:d-1,skip:y}):n.isFile()&&i&&O(g,e,f,y)&&(yield {isDirectory:n.isDirectory,isFile:n.isFile,isSymbolicLink:n.isSymbolicLink,name:n.name,path:normalize(g)});}}catch(n){throw n instanceof a$1?n:new a$1(n,t)}}var ee=(t,e={})=>{let r={extensions:["js","mjs","cjs","ts"],...e},o=[];for(let i of T(t,r))o.push(i.path);return o},re=ee;var ae=async(t,e={})=>{if(typeof t!="string"&&!Array.isArray(t)&&typeof t!="function")throw new TypeError("The `name` argument must be of type `string` or `string[]`");let r=e.cwd?b(e.cwd):process.cwd(),o=resolve(r),{root:i}=parse(o),s=b(e.stopAt??i),a=resolve(o,s),d=e.type??"file",u=async function(f){return typeof t=="function"?[await t(f)]:typeof t=="string"?[t]:Array.isArray(t)?t:[t]};for(;o&&o!==a&&o!==i;){for await(let f of await u(o)){if(f===k)return;if(f===void 0)continue;let y=isAbsolute(f)?f:resolve(o,f);try{let n=await stat(y);if(d==="file"&&n.isFile()||d==="directory"&&n.isDirectory())return y}catch{}}o=dirname(o);}},fe=ae;var de=(t,e={})=>{if(typeof t!="string"&&!Array.isArray(t)&&typeof t!="function")throw new TypeError("The `name` argument must be of type `string` or `string[]`");let r=e.cwd?b(e.cwd):process.cwd(),o=resolve(r),{root:i}=parse(o),s=b(e.stopAt??i),a=resolve(o,s),d=e.type??"file",u=function(f){return typeof t=="function"?[t(f)]:typeof t=="string"?[t]:Array.isArray(t)?t:[t]};for(;o&&o!==a&&o!==i;){for(let f of u(o)){if(f===k)return;if(f===void 0)continue;let y=isAbsolute(f)?f:resolve(o,f);try{let n=statSync(y);if(d==="file"&&n.isFile()||d==="directory"&&n.isDirectory())return y}catch{}}o=dirname(o);}},ye=de;async function ge(t,e=0){a(t),t=b(t);try{return await access(t,e),!0}catch{return !1}}var R=ge;function Oe(t,e=0){a(t),t=b(t);try{return accessSync(t,e),!0}catch{return !1}}var S=Oe;var xe={brotli:brotliDecompress,gzip:unzip,none:(t,e)=>{e(null,t);}},Fe=async(t,e)=>{if(a(t),t=b(t),!await R(t))throw new b$1(`unable to read the non-accessible file: ${t}`);if(!await R(t,4))throw new Error(`Unable to read the non-readable file: ${t}`);let{buffer:r,compression:o,encoding:i,flag:s}=e??{};return await readFile(t,s?{encoding:i,flag:s}:{encoding:i}).then(async a=>await new Promise((d,u)=>{xe[o??"none"](a,(f,y)=>{f?u(f):d(r?y:y.toString());});})).catch(a=>{throw a})},v=Fe;var Ee={brotli:brotliDecompressSync,gzip:unzipSync,none:t=>t},De=(t,e)=>{if(a(t),t=b(t),!S(t))throw new b$1(`unable to read the non-accessible file: ${t}`);if(!S(t,4))throw new b$1(`invalid access to read file at: ${t}`);let{buffer:r,compression:o,encoding:i,flag:s}=e??{},a$1=readFileSync(t,s?{encoding:i,flag:s}:{encoding:i}),d=Ee[o??"none"](a$1);return r?d:d.toString()},U=De;async function Le(t,e,r){typeof e=="object"&&(r=e,e=void 0);let o=await v(t,{buffer:!0,encoding:void 0}),i=new TextDecoder().decode(o),{beforeParse:s,color:a}=r??{};return typeof s=="function"&&(i=s(i)),c(i,e,b(t),{color:a})}var Te=Le;function ve(t,e,r){typeof e=="object"&&(r=e,e=void 0);let o=U(t,{buffer:!0,encoding:void 0}),i=new TextDecoder().decode(o),{beforeParse:s,color:a}=r??{};return typeof s=="function"&&(i=s(i)),c(i,e,b(t),{color:a})}var Ue=ve;async function Ie(t,e,r){let{buffer:o,compression:i,encoding:s="utf8",flag:a,...d}=r??{},u=await v(t,{buffer:o,compression:i,encoding:s,flag:a});return typeof e=="function"?parse$1(u,e,d):parse$1(u,d)}var Ae=Ie;function Je(t,e,r){let{buffer:o,compression:i,encoding:s="utf8",flag:a,...d}=r??{},u=U(t,{buffer:o,compression:i,encoding:s,flag:a});return typeof e=="function"?parse$1(u,e,d):parse$1(u,d)}var Ye=Je;var Ce=async(t,e)=>{if(a(t),!existsSync(t)){await mkdir(t,{recursive:!0});return}for await(let r of await readdir(t))await rm(join(b(t),r),{...e,force:!0,recursive:!0});},ze=Ce;var He=(t,e)=>{if(a(t),!existsSync(t)){mkdirSync(t,{recursive:!0});return}for(let r of readdirSync(t))rmSync(join(b(t),r),{...e,force:!0,recursive:!0});},Ge=He;var Ze=async(t,e={})=>{a(t);try{await unlink(t);}catch{}try{await rm(t,{force:!0,maxRetries:e?.maxRetries,recursive:!0,retryDelay:e?.retryDelay});}catch{}},tr=Ze;var or=(t,e={})=>{a(t);try{unlinkSync(t);}catch{}try{rmSync(t,{force:!0,maxRetries:e?.maxRetries,recursive:!0,retryDelay:e?.retryDelay});}catch{}},ir=or;var nr=new TextEncoder,sr=t=>{if(t instanceof Uint8Array)return t;if(typeof t=="string")return nr.encode(t);if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t)){let e=t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength);return new Uint8Array(e)}throw new TypeError("Invalid contents type. Expected string or ArrayBuffer.")},C=sr;var yr=async(t,e,r)=>{r={encoding:"utf8",flag:"w",overwrite:!0,recursive:!0,...r},a(t),d(e),t=b(t);try{let o=await R(t,0);if(!o&&r.recursive){let a=dirname(t);await R(a,0)||await mkdir(a,{recursive:!0});}let i;await writeFile(`${t}.tmp`,C(e),{encoding:r.encoding,flag:r.flag}),o&&!r.overwrite&&(i=await stat(t),r.chown===void 0&&(r.chown={gid:i.gid,uid:i.uid}),await rename(t,`${t}.bak`));let s=`${t}.tmp`;if(r.chown)try{await chown(s,r.chown.uid,r.chown.gid);}catch{}await chmod(s,i&&!r.mode?i.mode:r.mode??438),await rename(s,t);}catch(o){throw new Error(`Failed to write file at: ${t} - ${o.message}`,{cause:o})}finally{await R(`${t}.tmp`)&&await unlink(`${t}.tmp`);}},I=yr;var xr=(t,e,r)=>{r={encoding:"utf8",flag:"w",overwrite:!0,recursive:!0,...r},a(t),d(e),t=b(t);try{let o=S(t,0);if(!o&&r.recursive){let a=dirname(t);S(a,0)||mkdirSync(a,{recursive:!0});}let i;writeFileSync(`${t}.tmp`,C(e),{encoding:r.encoding,flag:r.flag}),o&&!r.overwrite&&(i=statSync(t),r.chown===void 0&&(r.chown={gid:i.gid,uid:i.uid}),renameSync(t,`${t}.bak`));let s=`${t}.tmp`;if(r.chown)try{chownSync(s,r.chown.uid,r.chown.gid);}catch{}chmodSync(s,i&&!r.mode?i.mode:r.mode??438),renameSync(s,t);}catch(o){throw new Error(`Failed to write file at: ${t} - ${o.message}`,{cause:o})}finally{S(`${t}.tmp`)&&unlinkSync(`${t}.tmp`);}},A=xr;var Fr=/^(?:( )+|\t+)/,J="space",ot="tab";function rt(t,e){let r=new Map,o=0,i,s;for(let a of t.split(/\n/g)){if(!a)continue;let d,u,f,y,n,g=a.match(Fr);if(g===null)o=0,i="";else {if(d=g[0].length,u=g[1]?J:ot,e&&u===J&&d===1)continue;u!==i&&(o=0),i=u,f=1,y=0;let N=d-o;if(o=d,N===0)f=0,y=1;else {let st=N>0?N:-N;s=br(u,st);}n=r.get(s),n=n===void 0?[1,0]:[n[0]+f,n[1]+y],r.set(s,n);}}return r}function br(t,e){return (t===J?"s":"t")+String(e)}function Pr(t){let r=t[0]==="s"?J:ot,o=Number(t.slice(1));return {type:r,amount:o}}function kr(t){let e,r=0,o=0;for(let[i,[s,a]]of t)(s>r||s===r&&a>o)&&(r=s,o=a,e=i);return e}function Er(t,e){return (t===J?" ":" ").repeat(e)}function Y(t){if(typeof t!="string")throw new TypeError("Expected a string");let e=rt(t,!0);e.size===0&&(e=rt(t,!1));let r=kr(e),o,i=0,s="";return r!==void 0&&({type:o,amount:i}=Pr(r),s=Er(o,i)),{amount:i,type:o,indent:s}}var Lr=async(t,e,r={})=>{let{detectIndent:o,indent:i,replacer:s,stringify:a=JSON.stringify,...d}={indent:" ",...r},u=i,f=`
15
+ `;if(await R(t,4))try{let n=await readFile(t,"utf8");if(o){let{indent:g}=Y(n);u=g;}f=n.endsWith(`
15
16
  `)?`
16
- `:"";}catch(n){if(n.code!=="ENOENT")throw n}let y=m(e,s,u);await A(t,`${y}${p}`,d);},Ur=vr;var Ir=(t,e,r={})=>{let{detectIndent:o,indent:i,replacer:s,stringify:m=JSON.stringify,...d}={indent:" ",...r},u=i,p=`
17
- `;if(S(t,4))try{let n=readFileSync(t,"utf8");if(o){let{indent:g}=Y(n);u=g;}p=n.endsWith(`
17
+ `:"";}catch(n){if(n.code!=="ENOENT")throw n}let y=a(e,s,u);await I(t,`${y}${f}`,d);},Tr=Lr;var Ur=(t,e,r={})=>{let{detectIndent:o,indent:i,replacer:s,stringify:a=JSON.stringify,...d}={indent:" ",...r},u=i,f=`
18
+ `;if(S(t,4))try{let n=readFileSync(t,"utf8");if(o){let{indent:g}=Y(n);u=g;}f=n.endsWith(`
18
19
  `)?`
19
- `:"";}catch(n){if(n.code!=="ENOENT")throw n}let y=m(e,s,u);I(t,`${y}${p}`,d);},Jr=Ir;async function Yr(t,e,r,o){let i=typeof r=="function"||Array.isArray(r)?stringify(e,r,o):stringify(e,r);await A(t,i);}var Nr=Yr;function Wr(t,e,r,o){let i=typeof r=="function"||Array.isArray(r)?stringify(e,r,o):stringify(e,r);I(t,i);}var Vr=Wr;
20
+ `:"";}catch(n){if(n.code!=="ENOENT")throw n}let y=a(e,s,u);A(t,`${y}${f}`,d);},Ir=Ur;async function Ar(t,e,r,o){let i=typeof r=="function"||Array.isArray(r)?stringify(e,r,o):stringify(e,r);await I(t,i);}var Jr=Ar;function Yr(t,e,r,o){let i=typeof r=="function"||Array.isArray(r)?stringify(e,r,o):stringify(e,r);A(t,i);}var Nr=Yr;
20
21
 
21
- export { _ as CRLF, ue as EOL, D as FIND_UP_STOP, h as F_OK, z as LF, E as R_OK, Lt as W_OK, Tt as X_OK, Ot as collect, Dt as collectSync, ge as detect, Nt as emptyDir, Kt as emptyDirSync, L as ensureDir, T as ensureDirSync, Zt as ensureFile, ie as ensureFileSync, ce as ensureLink, de as ensureLinkSync, Fe as findUp, Le as findUpSync, we as format, R as isAccessible, S as isAccessibleSync, v as readFile, U as readFileSync, Me as readJson, je as readJsonSync, He as readYaml, qe as readYamlSync, er as remove, nr as removeSync, P as walk, k as walkSync, A as writeFile, I as writeFileSync, Ur as writeJson, Jr as writeJsonSync, Nr as writeYaml, Vr as writeYamlSync };
22
+ export { $ as CRLF, It as EOL, k as FIND_UP_STOP, h as F_OK, z as LF, P as R_OK, at as W_OK, ft as X_OK, Bt as collect, re as collectSync, At as detect, ze as emptyDir, Ge as emptyDirSync, E as ensureDir, D as ensureDirSync, wt as ensureFile, xt as ensureFileSync, Et as ensureLink, vt as ensureLinkSync, fe as findUp, ye as findUpSync, Jt as format, R as isAccessible, S as isAccessibleSync, v as readFile, U as readFileSync, Te as readJson, Ue as readJsonSync, Ae as readYaml, Ye as readYamlSync, tr as remove, ir as removeSync, L as walk, T as walkSync, I as writeFile, A as writeFileSync, Tr as writeJson, Ir as writeJsonSync, Jr as writeYaml, Nr as writeYamlSync };
22
23
  //# sourceMappingURL=out.js.map
23
24
  //# sourceMappingURL=index.js.map