@visulima/fs 1.2.1 → 1.3.0
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/CHANGELOG.md +7 -0
- package/README.md +87 -0
- package/dist/chunk-3EHZOWRU.js +5 -0
- package/dist/chunk-3EHZOWRU.js.map +1 -0
- package/dist/chunk-7UNFLLNN.js +12 -0
- package/dist/chunk-7UNFLLNN.js.map +1 -0
- package/dist/chunk-C4ULY5SU.cjs +14 -0
- package/dist/chunk-C4ULY5SU.cjs.map +1 -0
- package/dist/chunk-KXYI7M76.cjs +8 -0
- package/dist/chunk-KXYI7M76.cjs.map +1 -0
- package/dist/chunk-N5NZURYL.cjs +10 -0
- package/dist/chunk-N5NZURYL.cjs.map +1 -0
- package/dist/chunk-UPN3Y5W3.js +8 -0
- package/dist/chunk-UPN3Y5W3.js.map +1 -0
- package/dist/error.cjs +24 -0
- package/dist/error.cjs.map +1 -0
- package/dist/error.d.cts +32 -0
- package/dist/error.d.ts +32 -0
- package/dist/error.js +8 -0
- package/dist/error.js.map +1 -0
- package/dist/index.cjs +26 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +23 -31
- package/dist/index.d.ts +23 -31
- package/dist/index.js +13 -4
- package/dist/index.js.map +1 -1
- package/dist/json-error-UVjLdb7z.d.cts +11 -0
- package/dist/json-error-UVjLdb7z.d.ts +11 -0
- package/dist/types-4y_sJiOD.d.cts +60 -0
- package/dist/types-4y_sJiOD.d.ts +60 -0
- package/dist/utils.cjs +18 -0
- package/dist/utils.cjs.map +1 -0
- package/dist/utils.d.cts +13 -0
- package/dist/utils.d.ts +13 -0
- package/dist/utils.js +8 -0
- package/dist/utils.js.map +1 -0
- package/package.json +37 -5
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/walk.ts","../src/error/walk-error.ts","../src/utils/glob-to-regex.ts","../src/utils/to-path.ts","../src/utils/walk-include.ts","../src/collect.ts","../src/walk-sync.ts","../src/collect-sync.ts","../src/find-up.ts","../src/find-up-sync.ts","../src/is-accessible.ts","../src/is-accessible-sync.ts","../src/read-file.ts","../src/read-file-sync.ts"],"names":["readdir","realpath","stat","basename","join","normalize","resolve","WalkError","cause","root","walk_error_default","globToRegExp","glob","reString","glob_to_regex_default","fileURLToPath","toPath","urlOrPath","to_path_default","walkInclude","path","extensions","match","skip","extension","pattern","walk_include_default","_createWalkEntry","normalizePath","name","info","walk","directory","followSymlinks","includeDirectories","includeFiles","includeSymlinks","maxDepth","mappedMatch","mappedSkip","entry","error","collect","options","config","entries","collect_default","readdirSync","realpathSync","statSync","walkSync","collectSync","collect_sync_default","dirname","isAbsolute","parse","findUp","stopAt","type","filePath","stats","find_up_default","findUpSync","find_up_sync_default","access","isAccessible","mode","index","is_accessible_default","accessSync","isAccessibleSync","is_accessible_sync_default","nodeReadFile","brotliDecompress","unzip","decompressionMethods","buffer","callback","readFile","compression","encoding","flag","content","result","read_file_default","nodeReadFileSync","brotliDecompressSync","unzipSync","readFileSync","decompressed","read_file_sync_default"],"mappings":"AAMA,OAAS,WAAAA,EAAS,YAAAC,EAAU,QAAAC,MAAY,mBACxC,OAAS,YAAAC,EAAU,QAAAC,EAAM,aAAAC,EAAW,WAAAC,MAAe,YCDnD,IAAMC,EAAN,cAAwB,KAAM,CAEnB,KAGA,YAAYC,EAAgBC,EAAc,CAE7C,MAAM,GAAGD,aAAiB,MAAQA,EAAM,QAAUA,CAAK,cAAcC,CAAI,GAAG,EAE5E,KAAK,MAAQD,EACb,KAAK,KAAO,YACZ,KAAK,KAAOC,CAChB,CACJ,EAEOC,EAAQH,ECrBf,IAAMI,EAAgBC,GAAyB,CAC3C,IAAMC,EAAWD,EAEZ,QAAQ,QAAS,UAAU,EAE3B,QAAQ,QAAS,MAAM,EAEvB,QAAQ,mBAAoB,SAAS,EAErC,QAAQ,MAAO,MAAM,EAErB,QAAQ,YAAa,KAAK,EAE1B,QAAQ,MAAO,GAAG,EA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BAAAC,GAAsB,aAAAC,OAAiB,YAIhD,IAAMZ,GAAuB,CACzB,OAAQW,GACR,KAAMC,GACN,KAAOX,GAAmBA,CAC9B,EAEMY,GAAe,CACjBpE,EACAuB,IAC6B,CAC7B,GAAM,CAAE,OAAAiC,EAAQ,YAAAG,EAAa,SAAAC,EAAU,KAAAC,CAAK,EAAItC,GAAW,CAAC,EAE5D,GAAI,CAGA,IAAMuC,EAAUG,GAAiBjE,EAAM6D,EAAO,CAAE,SAAAD,EAAU,KAAAC,CAAK,EAAI,CAAE,SAAAD,CAAS,CAAC,EAEzES,EAAed,GAAqBI,GAAe,MAAM,EAAEG,CAAO,EAExE,OAAQN,EAASa,EAAeA,EAAa,SAAS,CAC1D,MAAQ,CACJ,MACJ,CACJ,EAEOC,GAAQF","sourcesContent":["// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.\n// Documentation and interface for walk were adapted from Go\n// https://golang.org/pkg/path/filepath/#Walk\n// Copyright 2009 The Go Authors. All rights reserved. BSD license.\n\nimport type { Stats } from \"node:fs\";\nimport { readdir, realpath, stat } from \"node:fs/promises\";\nimport { basename, join, normalize, resolve } from \"node:path\";\n\nimport WalkError from \"./error/walk-error\";\nimport type { WalkEntry, WalkOptions } from \"./types\";\nimport globToRegExp from \"./utils/glob-to-regex\";\nimport toPath from \"./utils/to-path\";\nimport walkInclude from \"./utils/walk-include\";\n\n// eslint-disable-next-line @typescript-eslint/naming-convention,no-underscore-dangle\nconst _createWalkEntry = async (path: string): Promise<WalkEntry> => {\n const normalizePath: string = normalize(path as string);\n\n const name = basename(normalizePath);\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n const info: Stats = await stat(normalizePath);\n\n return {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isDirectory: info.isDirectory,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isFile: info.isFile,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isSymbolicLink: info.isSymbolicLink,\n name,\n path: normalizePath,\n };\n};\n\n/**\n * Walks the file tree rooted at root, yielding each file or directory in the\n * tree filtered according to the given options.\n * Options:\n * - maxDepth?: number = Infinity;\n * - includeFiles?: boolean = true;\n * - includeDirs?: boolean = true;\n * - includeSymlinks?: boolean = true;\n * - followSymlinks?: boolean = false;\n * - extensions?: string[];\n * - match?: string | ReadonlyArray<string>;\n * - skip?: string | ReadonlyArray<string>;\n */\n// eslint-disable-next-line sonarjs/cognitive-complexity\nexport default async function* walk(\n directory: URL | string,\n {\n extensions,\n followSymlinks = false,\n includeDirs: includeDirectories = true,\n includeFiles = true,\n includeSymlinks = true,\n match,\n maxDepth = Number.POSITIVE_INFINITY,\n skip,\n }: WalkOptions = {},\n): AsyncIterableIterator<WalkEntry> {\n if (maxDepth < 0) {\n return;\n }\n\n const mappedMatch = match ? match.map((pattern): RegExp => (typeof pattern === \"string\" ? globToRegExp(pattern) : pattern)) : undefined;\n const mappedSkip = skip ? skip.map((pattern): RegExp => (typeof pattern === \"string\" ? globToRegExp(pattern) : pattern)) : undefined;\n\n // eslint-disable-next-line no-param-reassign\n directory = resolve(toPath(directory));\n\n if (includeDirectories && walkInclude(directory, extensions, mappedMatch, mappedSkip)) {\n yield await _createWalkEntry(directory);\n }\n\n if (maxDepth < 1 || !walkInclude(directory, undefined, undefined, mappedSkip)) {\n return;\n }\n\n try {\n // eslint-disable-next-line no-restricted-syntax,security/detect-non-literal-fs-filename,no-loops/no-loops\n for await (const entry of await readdir(directory, {\n withFileTypes: true,\n })) {\n let path = join(directory, entry.name);\n\n if (entry.isSymbolicLink()) {\n if (followSymlinks) {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n path = await realpath(path);\n } else if (includeSymlinks && walkInclude(path, extensions, mappedMatch, mappedSkip)) {\n yield {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isDirectory: entry.isDirectory,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isFile: entry.isFile,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isSymbolicLink: entry.isSymbolicLink,\n name: entry.name,\n path,\n };\n } else {\n // eslint-disable-next-line no-continue\n continue;\n }\n }\n\n if (entry.isSymbolicLink() || entry.isDirectory()) {\n yield* walk(path, {\n extensions,\n followSymlinks,\n includeDirs: includeDirectories,\n includeFiles,\n includeSymlinks,\n match: mappedMatch,\n maxDepth: maxDepth - 1,\n skip: mappedSkip,\n } as WalkOptions);\n } else if (entry.isFile() && includeFiles && walkInclude(path, extensions, mappedMatch, mappedSkip)) {\n yield {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isDirectory: entry.isDirectory,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isFile: entry.isFile,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isSymbolicLink: entry.isSymbolicLink,\n name: entry.name,\n path,\n };\n }\n }\n } catch (error) {\n if (error instanceof WalkError) {\n throw error;\n }\n\n throw new WalkError(error, directory);\n }\n}\n","// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.\n// Documentation and interface for walk were adapted from Go\n// https://golang.org/pkg/path/filepath/#Walk\n// Copyright 2009 The Go Authors. All rights reserved. BSD license.\n\n/** Error thrown in {@linkcode walk} or {@linkcode walkSync} during iteration. */\nclass WalkError extends Error {\n /** File path of the root that's being walked. */\n public root: string;\n\n /** Constructs a new instance. */\n public constructor(cause: unknown, root: string) {\n // eslint-disable-next-line @typescript-eslint/restrict-template-expressions\n super(`${cause instanceof Error ? cause.message : cause} for path \"${root}\"`);\n\n this.cause = cause;\n this.name = \"WalkError\";\n this.root = root;\n }\n}\n\nexport default WalkError;\n","const globToRegExp = (glob: string): RegExp => {\n const reString = glob\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/\\.\\*/g, \".([^/]*)\") // Replace .* with .([^/]*)\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/\\*\\*/g, \"(.*)\") // Replace ** with (.*)\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/(?<!\\.)\\*(?!\\*)/g, \"([^/]*)\") // Replace * (not preceded by . or followed by *) with ([^/]*)\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/\\?/g, \"[^/]\") // Replace ? with [^/]\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/\\.(?!\\*)/g, \"\\\\.\") // Escape . that is not preceded by *\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/\\{/g, \"(\") // Replace { with (\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/\\}/g, \")\") // Replace } with )\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/,/g, \"|\") // Replace , with |\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/\\[!(.*?)\\]/g, \"[^$1]\"); // Replace [!number-number] with [^number-number]\n\n // eslint-disable-next-line @rushstack/security/no-unsafe-regexp,security/detect-non-literal-regexp\n return new RegExp(`^${reString}$`);\n};\n\nexport default globToRegExp;\n","import { fileURLToPath } from \"node:url\";\n\nconst toPath = (urlOrPath: URL | string): string => (urlOrPath instanceof URL ? fileURLToPath(urlOrPath) : urlOrPath);\n\nexport default toPath;\n","const walkInclude = (path: string, extensions?: string[], match?: RegExp[], skip?: RegExp[]): boolean => {\n if (extensions && !extensions.some((extension): boolean => path.endsWith(extension))) {\n return false;\n }\n\n if (match && !match.some((pattern): boolean => pattern.test(path))) {\n return false;\n }\n\n return !(skip && skip.some((pattern): boolean => pattern.test(path)));\n};\n\nexport default walkInclude;\n","import type { WalkOptions } from \"./types\";\nimport walk from \"./walk\";\n\nconst collect = async (directory: string, options: WalkOptions = {}): Promise<string[]> => {\n const config = {\n extensions: [\"js\", \"mjs\", \"cjs\", \"ts\"],\n ...options,\n } as WalkOptions;\n\n const entries: string[] = [];\n\n // eslint-disable-next-line no-restricted-syntax,no-loops/no-loops\n for await (const entry of walk(directory, config)) {\n entries.push(entry.path);\n }\n\n return entries;\n};\n\nexport default collect;\n","// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.\n// Documentation and interface for walk were adapted from Go\n// https://golang.org/pkg/path/filepath/#Walk\n// Copyright 2009 The Go Authors. All rights reserved. BSD license.\n\nimport type { Stats } from \"node:fs\";\nimport { readdirSync, realpathSync, statSync } from \"node:fs\";\nimport { basename, join, normalize, resolve } from \"node:path\";\n\nimport WalkError from \"./error/walk-error\";\nimport type { WalkEntry, WalkOptions } from \"./types\";\nimport globToRegExp from \"./utils/glob-to-regex\";\nimport toPath from \"./utils/to-path\";\nimport walkInclude from \"./utils/walk-include\";\n\n/** Create {@linkcode WalkEntry} for the `path` synchronously. */\n// eslint-disable-next-line @typescript-eslint/naming-convention,no-underscore-dangle\nconst _createWalkEntry = (path: string): WalkEntry => {\n const normalizePath: string = normalize(path as string);\n\n const name = basename(normalizePath);\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n const info: Stats = statSync(normalizePath);\n\n return {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isDirectory: info.isDirectory,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isFile: info.isFile,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isSymbolicLink: info.isSymbolicLink,\n name,\n path: normalizePath,\n };\n};\n\n/** Same as {@linkcode walk} but uses synchronous ops */\n// eslint-disable-next-line sonarjs/cognitive-complexity\nexport default function* walkSync(\n directory: URL | string,\n {\n extensions,\n followSymlinks = false,\n includeDirs: includeDirectories = true,\n includeFiles = true,\n includeSymlinks = true,\n match,\n maxDepth = Number.POSITIVE_INFINITY,\n skip,\n }: WalkOptions = {},\n): IterableIterator<WalkEntry> {\n if (maxDepth < 0) {\n return;\n }\n\n const mappedMatch = match ? match.map((pattern): RegExp => (typeof pattern === \"string\" ? globToRegExp(pattern) : pattern)) : undefined;\n const mappedSkip = skip ? skip.map((pattern): RegExp => (typeof pattern === \"string\" ? globToRegExp(pattern) : pattern)) : undefined;\n\n // eslint-disable-next-line no-param-reassign\n directory = resolve(toPath(directory));\n\n if (includeDirectories && walkInclude(directory, extensions, mappedMatch, mappedSkip)) {\n yield _createWalkEntry(directory);\n }\n\n if (maxDepth < 1 || !walkInclude(directory, undefined, undefined, mappedSkip)) {\n return;\n }\n\n try {\n // eslint-disable-next-line no-restricted-syntax,no-loops/no-loops,security/detect-non-literal-fs-filename\n for (const entry of readdirSync(directory, {\n withFileTypes: true,\n })) {\n let path = join(directory, entry.name);\n\n if (entry.isSymbolicLink()) {\n if (followSymlinks) {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n path = realpathSync(path);\n } else if (includeSymlinks && walkInclude(path, extensions, mappedMatch, mappedSkip)) {\n yield {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isDirectory: entry.isDirectory,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isFile: entry.isFile,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isSymbolicLink: entry.isSymbolicLink,\n name: entry.name,\n path,\n };\n } else {\n // eslint-disable-next-line no-continue\n continue;\n }\n }\n\n if (entry.isSymbolicLink() || entry.isDirectory()) {\n yield* walkSync(path, {\n extensions,\n followSymlinks,\n includeDirs: includeDirectories,\n includeFiles,\n includeSymlinks,\n match: mappedMatch,\n maxDepth: maxDepth - 1,\n skip: mappedSkip,\n } as WalkOptions);\n } else if (entry.isFile() && includeFiles && walkInclude(path, extensions, mappedMatch, mappedSkip)) {\n yield {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isDirectory: entry.isDirectory,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isFile: entry.isFile,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isSymbolicLink: entry.isSymbolicLink,\n name: entry.name,\n path,\n };\n }\n }\n } catch (error) {\n if (error instanceof WalkError) {\n throw error;\n }\n\n throw new WalkError(error, directory);\n }\n}\n","import type { WalkOptions } from \"./types\";\nimport walkSync from \"./walk-sync\";\n\nconst collectSync = (directory: string, options: WalkOptions = {}): string[] => {\n const config = {\n extensions: [\"js\", \"mjs\", \"cjs\", \"ts\"],\n ...options,\n } as WalkOptions;\n\n const entries: string[] = [];\n\n // eslint-disable-next-line no-restricted-syntax,no-loops/no-loops\n for (const entry of walkSync(directory, config)) {\n entries.push(entry.path);\n }\n\n return entries;\n};\n\nexport default collectSync;\n","import { stat } from \"node:fs/promises\";\nimport { dirname, isAbsolute, join, parse, resolve } from \"node:path\";\n\nimport toPath from \"./utils/to-path\";\n\nconst findUp = async (\n name: string,\n options: {\n cwd?: URL | string;\n stopAt?: URL | string;\n type?: \"directory\" | \"file\";\n } = {},\n): Promise<string | undefined> => {\n let directory = resolve(options.cwd ? toPath(options.cwd) : process.cwd());\n const { root } = parse(directory);\n const stopAt = resolve(directory, toPath(options.stopAt ?? root));\n\n const type = options.type ?? \"file\";\n\n // eslint-disable-next-line no-loops/no-loops\n while (directory && directory !== stopAt && directory !== root) {\n const filePath = isAbsolute(name) ? name : join(directory, name);\n\n try {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n const stats = await stat(filePath); // eslint-disable-line no-await-in-loop\n\n if ((type === \"file\" && stats.isFile()) || (type === \"directory\" && stats.isDirectory())) {\n return filePath;\n }\n } catch {\n /* empty */\n }\n\n directory = dirname(directory);\n }\n\n return undefined;\n};\n\nexport default findUp;\n","import { statSync } from \"node:fs\";\nimport { dirname, isAbsolute, join, parse, resolve } from \"node:path\";\n\nimport toPath from \"./utils/to-path\";\n\nconst findUpSync = (\n name: string,\n options: {\n cwd?: URL | string;\n stopAt?: URL | string;\n type?: \"directory\" | \"file\";\n } = {},\n): string | undefined => {\n let directory = resolve(options.cwd ? toPath(options.cwd) : process.cwd());\n const { root } = parse(directory);\n const stopAt = resolve(directory, toPath(options.stopAt ?? root));\n\n const type = options.type ?? \"file\";\n\n // eslint-disable-next-line no-loops/no-loops\n while (directory && directory !== stopAt && directory !== root) {\n const filePath = isAbsolute(name) ? name : join(directory, name);\n\n try {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n const stats = statSync(filePath);\n\n if ((type === \"file\" && stats.isFile()) || (type === \"directory\" && stats.isDirectory())) {\n return filePath;\n }\n } catch {\n /* empty */\n }\n\n directory = dirname(directory);\n }\n\n return undefined;\n};\n\nexport default findUpSync;\n","import { access } from \"node:fs/promises\";\n\nimport { F_OK } from \"./constants\";\n\n/** Returns a Promise that resolves to a boolean indicating if the path is accessible or not. */\nasync function isAccessible(path: string, mode?: number): Promise<boolean>;\nasync function isAccessible(path: string[], mode?: number): Promise<boolean[]>;\n// eslint-disable-next-line func-style\nasync function isAccessible(path: string[] | string, mode: number = F_OK): Promise<boolean[] | boolean> {\n if (Array.isArray(path)) {\n return await Promise.all(path.map(async (index) => await isAccessible(index, mode)));\n }\n\n try {\n await access(path, mode);\n\n return true;\n } catch {\n return false;\n }\n}\n\nexport default isAccessible;\n","import { accessSync } from \"node:fs\";\n\nimport { F_OK } from \"./constants\";\n\n/** Returns a boolean indicating if the path is accessible or not. */\nfunction isAccessibleSync(path: string, mode?: number): boolean;\nfunction isAccessibleSync(path: string[], mode?: number): boolean[];\n// eslint-disable-next-line func-style\nfunction isAccessibleSync(path: string[] | string, mode: number = F_OK): boolean[] | boolean {\n if (Array.isArray(path)) {\n return path.map((index) => isAccessibleSync(index, mode));\n }\n\n try {\n accessSync(path, mode);\n\n return true;\n } catch {\n return false;\n }\n}\n\nexport default isAccessibleSync;\n","import { readFile as nodeReadFile } from \"node:fs/promises\";\nimport { brotliDecompress, unzip } from \"node:zlib\";\n\nimport type { ContentType, ReadFileOptions } from \"./types\";\n\nconst decompressionMethods = {\n brotli: brotliDecompress,\n gzip: unzip,\n none: (buffer: Buffer, callback: (error: Error | null, result: Buffer) => void) => {\n callback(null, buffer);\n },\n} as const;\n\nconst readFile = async <O extends ReadFileOptions<keyof typeof decompressionMethods> | undefined = undefined>(\n path: string,\n options?: O,\n): Promise<ContentType<O> | undefined> => {\n const { buffer, compression, encoding, flag } = options ?? {};\n\n // @ts-expect-error - TS doesn't like our typed `encoding` option\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n return await nodeReadFile(path, flag ? { encoding, flag } : { encoding })\n .then(\n async (content) =>\n // eslint-disable-next-line compat/compat\n await new Promise<ContentType<O> | undefined>((resolve) => {\n decompressionMethods[compression ?? \"none\"](content, (error, result) => {\n if (error) {\n resolve(undefined);\n } else {\n resolve((buffer ? result : result.toString()) as ContentType<O>);\n }\n });\n }),\n )\n .catch(() => undefined);\n};\n\nexport default readFile;\n","import { readFileSync as nodeReadFileSync } from \"node:fs\";\nimport { brotliDecompressSync, unzipSync } from \"node:zlib\";\n\nimport type { ContentType, ReadFileOptions } from \"./types\";\n\nconst decompressionMethods = {\n brotli: brotliDecompressSync,\n gzip: unzipSync,\n none: (buffer: Buffer) => buffer,\n} as const;\n\nconst readFileSync = <O extends ReadFileOptions<keyof typeof decompressionMethods> | undefined = undefined>(\n path: string,\n options?: O,\n): ContentType<O> | undefined => {\n const { buffer, compression, encoding, flag } = options ?? {};\n\n try {\n // @ts-expect-error - TS doesn't like our typed `encoding` option\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n const content = nodeReadFileSync(path, flag ? { encoding, flag } : { encoding });\n\n const decompressed = decompressionMethods[compression ?? \"none\"](content);\n\n return (buffer ? decompressed : decompressed.toString()) as ContentType<O>;\n } catch {\n return undefined;\n }\n};\n\nexport default readFileSync;\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/walk.ts","../src/utils/assert-valid-file-or-directory-path.ts","../src/utils/glob-to-regex.ts","../src/utils/to-path.ts","../src/utils/walk-include.ts","../src/collect.ts","../src/walk-sync.ts","../src/collect-sync.ts","../src/find-up.ts","../src/find-up-sync.ts","../src/is-accessible.ts","../src/is-accessible-sync.ts","../src/read-file.ts","../src/read-file-sync.ts","../src/read-json.ts","../src/read-json-sync.ts","../src/write-file.ts","../src/utils/assert-valid-file-contents.ts","../src/utils/to-uint-8-array.ts","../src/write-file-sync.ts","../src/write-json.ts","../../../node_modules/.pnpm/detect-indent@7.0.1/node_modules/detect-indent/index.js","../src/write-json-sync.ts"],"names":["readdir","realpath","stat","basename","join","normalize","resolve","assertValidFileOrDirectoryPath","fileOrDirectoryPath","assert_valid_file_or_directory_path_default","globToRegExp","glob","reString","glob_to_regex_default","fileURLToPath","toPath","urlOrPath","to_path_default","walkInclude","path","extensions","match","skip","extension","pattern","walk_include_default","_createWalkEntry","normalizePath","name","info","walk","directory","followSymlinks","includeDirectories","includeFiles","includeSymlinks","maxDepth","mappedMatch","mappedSkip","entry","error","walk_error_default","collect","options","config","entries","collect_default","readdirSync","realpathSync","statSync","walkSync","collectSync","collect_sync_default","dirname","isAbsolute","parse","findUp","cwd","root","stopPath","stopAt","type","filePath","stats","find_up_default","findUpSync","find_up_sync_default","access","isAccessible","mode","is_accessible_default","accessSync","isAccessibleSync","is_accessible_sync_default","nodeReadFile","brotliDecompress","unzip","decompressionMethods","buffer","callback","readFile","permission_error_default","compression","encoding","flag","content","reject","result","read_file_default","nodeReadFileSync","brotliDecompressSync","unzipSync","readFileSync","decompressed","read_file_sync_default","readJson","reviver","data","beforeParse","color","parse_json_default","read_json_default","readJsonSync","read_json_sync_default","chmod","chown","mkdir","rename","nodeStat","unlink","nodeWriteFile","assertValidFileContents","contents","assert_valid_file_contents_default","encoder","toUint8Array","bytes","to_uint_8_array_default","writeFile","pathExists","temporaryPath","write_file_default","chmodSync","chownSync","mkdirSync","renameSync","unlinkSync","nodeWriteFileSync","writeFileSync","write_file_sync_default","INDENT_REGEX","INDENT_TYPE_SPACE","INDENT_TYPE_TAB","makeIndentsMap","string","ignoreSingleSpaces","indents","previousSize","previousIndentType","key","line","indent","indentType","use","weight","matches","indentDifference","absoluteIndentDifference","encodeIndentsKey","indentAmount","decodeIndentsKey","indentsKey","amount","getMostUsedKey","maxUsed","maxWeight","usedCount","makeIndentString","detectIndent","keyOfMostUsedIndent","writeJson","indentOption","replacer","writeOptions","trailingNewline","file","dIndent","json","write_json_default","writeJsonSync","write_json_sync_default"],"mappings":"mHAMA,OAAS,WAAAA,EAAS,YAAAC,EAAU,QAAAC,MAAY,mBACxC,OAAS,YAAAC,EAAU,QAAAC,EAAM,aAAAC,GAAW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M,GAAGxH,CAAO,EAEjGkG,EAASoB,EACTG,EAAkB;AAAA,EAEtB,GAAI3F,EAAiBtD,EAAM,CAAI,EAC3B,GAAI,CAEA,IAAMkJ,EAAOzE,GAAazE,EAAM,MAAM,EAEtC,GAAI2I,EAAc,CAEd,GAAM,CAAE,OAAQQ,CAAQ,EAAIR,EAAeO,CAAI,EAE/CxB,EAASyB,CACb,CAEAF,EAAkBC,EAAK,SAAS;AAAA,CAAI,EAAI;AAAA,EAAO,EAEnD,OAAS7H,EAAY,CAEjB,GAAIA,EAAM,OAAS,SACf,MAAMA,CAEd,CAIJ,IAAM+H,EAAO,KAAK,UAAUtE,EAAMiE,EAAUrB,CAAM,EAElDZ,EAAc9G,EAAM,GAAGoJ,CAAI,GAAGH,CAAe,GAAID,CAAY,CACjE,EAEOO,GAAQD","sourcesContent":["// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.\n// Documentation and interface for walk were adapted from Go\n// https://golang.org/pkg/path/filepath/#Walk\n// Copyright 2009 The Go Authors. All rights reserved. BSD license.\n\nimport type { Stats } from \"node:fs\";\nimport { readdir, realpath, stat } from \"node:fs/promises\";\nimport { basename, join, normalize, resolve } from \"node:path\";\n\nimport WalkError from \"./error/walk-error\";\nimport type { WalkEntry, WalkOptions } from \"./types\";\nimport assertValidFileOrDirectoryPath from \"./utils/assert-valid-file-or-directory-path\";\nimport globToRegExp from \"./utils/glob-to-regex\";\nimport toPath from \"./utils/to-path\";\nimport walkInclude from \"./utils/walk-include\";\n\n// eslint-disable-next-line @typescript-eslint/naming-convention,no-underscore-dangle\nconst _createWalkEntry = async (path: string): Promise<WalkEntry> => {\n const normalizePath: string = normalize(path as string);\n\n const name = basename(normalizePath);\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n const info: Stats = await stat(normalizePath);\n\n return {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isDirectory: info.isDirectory,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isFile: info.isFile,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isSymbolicLink: info.isSymbolicLink,\n name,\n path: normalizePath,\n };\n};\n\n/**\n * Walks the file tree rooted at root, yielding each file or directory in the\n * tree filtered according to the given options.\n * Options:\n * - maxDepth?: number = Infinity;\n * - includeFiles?: boolean = true;\n * - includeDirs?: boolean = true;\n * - includeSymlinks?: boolean = true;\n * - followSymlinks?: boolean = false;\n * - extensions?: string[];\n * - match?: string | ReadonlyArray<string>;\n * - skip?: string | ReadonlyArray<string>;\n */\n// eslint-disable-next-line sonarjs/cognitive-complexity\nexport default async function* walk(\n directory: URL | string,\n {\n extensions,\n followSymlinks = false,\n includeDirs: includeDirectories = true,\n includeFiles = true,\n includeSymlinks = true,\n match,\n maxDepth = Number.POSITIVE_INFINITY,\n skip,\n }: WalkOptions = {},\n): AsyncIterableIterator<WalkEntry> {\n assertValidFileOrDirectoryPath(directory);\n\n if (maxDepth < 0) {\n return;\n }\n\n const mappedMatch = match ? match.map((pattern): RegExp => (typeof pattern === \"string\" ? globToRegExp(pattern) : pattern)) : undefined;\n const mappedSkip = skip ? skip.map((pattern): RegExp => (typeof pattern === \"string\" ? globToRegExp(pattern) : pattern)) : undefined;\n\n // eslint-disable-next-line no-param-reassign\n directory = resolve(toPath(directory));\n\n if (includeDirectories && walkInclude(directory, extensions, mappedMatch, mappedSkip)) {\n yield await _createWalkEntry(directory);\n }\n\n if (maxDepth < 1 || !walkInclude(directory, undefined, undefined, mappedSkip)) {\n return;\n }\n\n try {\n // eslint-disable-next-line no-restricted-syntax,security/detect-non-literal-fs-filename,no-loops/no-loops\n for await (const entry of await readdir(directory, {\n withFileTypes: true,\n })) {\n let path = join(directory, entry.name);\n\n if (entry.isSymbolicLink()) {\n if (followSymlinks) {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n path = await realpath(path);\n } else if (includeSymlinks && walkInclude(path, extensions, mappedMatch, mappedSkip)) {\n yield {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isDirectory: entry.isDirectory,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isFile: entry.isFile,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isSymbolicLink: entry.isSymbolicLink,\n name: entry.name,\n path,\n };\n } else {\n // eslint-disable-next-line no-continue\n continue;\n }\n }\n\n if (entry.isSymbolicLink() || entry.isDirectory()) {\n yield* walk(path, {\n extensions,\n followSymlinks,\n includeDirs: includeDirectories,\n includeFiles,\n includeSymlinks,\n match: mappedMatch,\n maxDepth: maxDepth - 1,\n skip: mappedSkip,\n } as WalkOptions);\n } else if (entry.isFile() && includeFiles && walkInclude(path, extensions, mappedMatch, mappedSkip)) {\n yield {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isDirectory: entry.isDirectory,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isFile: entry.isFile,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isSymbolicLink: entry.isSymbolicLink,\n name: entry.name,\n path,\n };\n }\n }\n } catch (error) {\n if (error instanceof WalkError) {\n throw error;\n }\n\n throw new WalkError(error, directory);\n }\n}\n","// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types,@typescript-eslint/no-explicit-any\nconst assertValidFileOrDirectoryPath = (fileOrDirectoryPath: any): void => {\n if (!fileOrDirectoryPath || (!(fileOrDirectoryPath instanceof URL) && typeof fileOrDirectoryPath !== \"string\")) {\n throw new TypeError(\"Path must be a non-empty string or URL.\");\n }\n};\n\nexport default assertValidFileOrDirectoryPath;\n","const globToRegExp = (glob: string): RegExp => {\n const reString = glob\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/\\.\\*/g, \".([^/]*)\") // Replace .* with .([^/]*)\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/\\*\\*/g, \"(.*)\") // Replace ** with (.*)\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/(?<!\\.)\\*(?!\\*)/g, \"([^/]*)\") // Replace * (not preceded by . or followed by *) with ([^/]*)\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/\\?/g, \"[^/]\") // Replace ? with [^/]\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/\\.(?!\\*)/g, \"\\\\.\") // Escape . that is not preceded by *\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/\\{/g, \"(\") // Replace { with (\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/\\}/g, \")\") // Replace } with )\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/,/g, \"|\") // Replace , with |\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/\\[!(.*?)\\]/g, \"[^$1]\"); // Replace [!number-number] with [^number-number]\n\n // eslint-disable-next-line @rushstack/security/no-unsafe-regexp,security/detect-non-literal-regexp\n return new RegExp(`^${reString}$`);\n};\n\nexport default globToRegExp;\n","import { fileURLToPath } from \"node:url\";\n\nconst toPath = (urlOrPath: URL | string): string => (urlOrPath instanceof URL ? fileURLToPath(urlOrPath) : urlOrPath);\n\nexport default toPath;\n","const walkInclude = (path: string, extensions?: string[], match?: RegExp[], skip?: RegExp[]): boolean => {\n if (extensions && !extensions.some((extension): boolean => path.endsWith(extension))) {\n return false;\n }\n\n if (match && !match.some((pattern): boolean => pattern.test(path))) {\n return false;\n }\n\n return !(skip && skip.some((pattern): boolean => pattern.test(path)));\n};\n\nexport default walkInclude;\n","import type { WalkOptions } from \"./types\";\nimport walk from \"./walk\";\n\nconst collect = async (directory: string, options: WalkOptions = {}): Promise<string[]> => {\n const config = {\n extensions: [\"js\", \"mjs\", \"cjs\", \"ts\"],\n ...options,\n } as WalkOptions;\n\n const entries: string[] = [];\n\n // eslint-disable-next-line no-restricted-syntax,no-loops/no-loops\n for await (const entry of walk(directory, config)) {\n entries.push(entry.path);\n }\n\n return entries;\n};\n\nexport default collect;\n","// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.\n// Documentation and interface for walk were adapted from Go\n// https://golang.org/pkg/path/filepath/#Walk\n// Copyright 2009 The Go Authors. All rights reserved. BSD license.\n\nimport type { Stats } from \"node:fs\";\nimport { readdirSync, realpathSync, statSync } from \"node:fs\";\nimport { basename, join, normalize, resolve } from \"node:path\";\n\nimport WalkError from \"./error/walk-error\";\nimport type { WalkEntry, WalkOptions } from \"./types\";\nimport assertValidFileOrDirectoryPath from \"./utils/assert-valid-file-or-directory-path\";\nimport globToRegExp from \"./utils/glob-to-regex\";\nimport toPath from \"./utils/to-path\";\nimport walkInclude from \"./utils/walk-include\";\n\n/** Create {@linkcode WalkEntry} for the `path` synchronously. */\n// eslint-disable-next-line @typescript-eslint/naming-convention,no-underscore-dangle\nconst _createWalkEntry = (path: string): WalkEntry => {\n const normalizePath: string = normalize(path as string);\n\n const name = basename(normalizePath);\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n const info: Stats = statSync(normalizePath);\n\n return {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isDirectory: info.isDirectory,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isFile: info.isFile,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isSymbolicLink: info.isSymbolicLink,\n name,\n path: normalizePath,\n };\n};\n\n/** Same as {@linkcode walk} but uses synchronous ops */\n// eslint-disable-next-line sonarjs/cognitive-complexity\nexport default function* walkSync(\n directory: URL | string,\n {\n extensions,\n followSymlinks = false,\n includeDirs: includeDirectories = true,\n includeFiles = true,\n includeSymlinks = true,\n match,\n maxDepth = Number.POSITIVE_INFINITY,\n skip,\n }: WalkOptions = {},\n): IterableIterator<WalkEntry> {\n assertValidFileOrDirectoryPath(directory);\n\n if (maxDepth < 0) {\n return;\n }\n\n const mappedMatch = match ? match.map((pattern): RegExp => (typeof pattern === \"string\" ? globToRegExp(pattern) : pattern)) : undefined;\n const mappedSkip = skip ? skip.map((pattern): RegExp => (typeof pattern === \"string\" ? globToRegExp(pattern) : pattern)) : undefined;\n\n // eslint-disable-next-line no-param-reassign\n directory = resolve(toPath(directory));\n\n if (includeDirectories && walkInclude(directory, extensions, mappedMatch, mappedSkip)) {\n yield _createWalkEntry(directory);\n }\n\n if (maxDepth < 1 || !walkInclude(directory, undefined, undefined, mappedSkip)) {\n return;\n }\n\n try {\n // eslint-disable-next-line no-restricted-syntax,no-loops/no-loops,security/detect-non-literal-fs-filename\n for (const entry of readdirSync(directory, {\n withFileTypes: true,\n })) {\n let path = join(directory, entry.name);\n\n if (entry.isSymbolicLink()) {\n if (followSymlinks) {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n path = realpathSync(path);\n } else if (includeSymlinks && walkInclude(path, extensions, mappedMatch, mappedSkip)) {\n yield {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isDirectory: entry.isDirectory,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isFile: entry.isFile,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isSymbolicLink: entry.isSymbolicLink,\n name: entry.name,\n path,\n };\n } else {\n // eslint-disable-next-line no-continue\n continue;\n }\n }\n\n if (entry.isSymbolicLink() || entry.isDirectory()) {\n yield* walkSync(path, {\n extensions,\n followSymlinks,\n includeDirs: includeDirectories,\n includeFiles,\n includeSymlinks,\n match: mappedMatch,\n maxDepth: maxDepth - 1,\n skip: mappedSkip,\n } as WalkOptions);\n } else if (entry.isFile() && includeFiles && walkInclude(path, extensions, mappedMatch, mappedSkip)) {\n yield {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isDirectory: entry.isDirectory,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isFile: entry.isFile,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isSymbolicLink: entry.isSymbolicLink,\n name: entry.name,\n path,\n };\n }\n }\n } catch (error) {\n if (error instanceof WalkError) {\n throw error;\n }\n\n throw new WalkError(error, directory);\n }\n}\n","import type { WalkOptions } from \"./types\";\nimport walkSync from \"./walk-sync\";\n\nconst collectSync = (directory: string, options: WalkOptions = {}): string[] => {\n const config = {\n extensions: [\"js\", \"mjs\", \"cjs\", \"ts\"],\n ...options,\n } as WalkOptions;\n\n const entries: string[] = [];\n\n // eslint-disable-next-line no-restricted-syntax,no-loops/no-loops\n for (const entry of walkSync(directory, config)) {\n entries.push(entry.path);\n }\n\n return entries;\n};\n\nexport default collectSync;\n","import { stat } from \"node:fs/promises\";\nimport { dirname, isAbsolute, join, parse, resolve } from \"node:path\";\n\nimport assertValidFileOrDirectoryPath from \"./utils/assert-valid-file-or-directory-path\";\nimport toPath from \"./utils/to-path\";\n\nconst findUp = async (\n name: string,\n options: {\n cwd?: URL | string;\n stopAt?: URL | string;\n type?: \"directory\" | \"file\";\n } = {},\n): Promise<string | undefined> => {\n const cwd = options.cwd ? toPath(options.cwd) : process.cwd();\n\n assertValidFileOrDirectoryPath(cwd);\n\n let directory = resolve(cwd);\n\n const { root } = parse(directory);\n const stopPath = toPath(options.stopAt ?? root);\n\n assertValidFileOrDirectoryPath(stopPath);\n\n const stopAt = resolve(directory, stopPath);\n const type = options.type ?? \"file\";\n\n // eslint-disable-next-line no-loops/no-loops\n while (directory && directory !== stopAt && directory !== root) {\n const filePath = isAbsolute(name) ? name : join(directory, name);\n\n try {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n const stats = await stat(filePath); // eslint-disable-line no-await-in-loop\n\n if ((type === \"file\" && stats.isFile()) || (type === \"directory\" && stats.isDirectory())) {\n return filePath;\n }\n } catch {\n /* empty */\n }\n\n directory = dirname(directory);\n }\n\n return undefined;\n};\n\nexport default findUp;\n","import { statSync } from \"node:fs\";\nimport { dirname, isAbsolute, join, parse, resolve } from \"node:path\";\n\nimport assertValidFileOrDirectoryPath from \"./utils/assert-valid-file-or-directory-path\";\nimport toPath from \"./utils/to-path\";\n\nconst findUpSync = (\n name: string,\n options: {\n cwd?: URL | string;\n stopAt?: URL | string;\n type?: \"directory\" | \"file\";\n } = {},\n): string | undefined => {\n const cwd = options.cwd ? toPath(options.cwd) : process.cwd();\n\n assertValidFileOrDirectoryPath(cwd);\n\n let directory = resolve(cwd);\n\n const { root } = parse(directory);\n const stopPath = toPath(options.stopAt ?? root);\n\n assertValidFileOrDirectoryPath(stopPath);\n\n const stopAt = resolve(directory, stopPath);\n const type = options.type ?? \"file\";\n\n // eslint-disable-next-line no-loops/no-loops\n while (directory && directory !== stopAt && directory !== root) {\n const filePath = isAbsolute(name) ? name : join(directory, name);\n\n try {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n const stats = statSync(filePath);\n\n if ((type === \"file\" && stats.isFile()) || (type === \"directory\" && stats.isDirectory())) {\n return filePath;\n }\n } catch {\n /* empty */\n }\n\n directory = dirname(directory);\n }\n\n return undefined;\n};\n\nexport default findUpSync;\n","import { access } from \"node:fs/promises\";\n\nimport { F_OK } from \"./constants\";\nimport assertValidFileOrDirectoryPath from \"./utils/assert-valid-file-or-directory-path\";\nimport toPath from \"./utils/to-path\";\n\n/** Returns a Promise that resolves to a boolean indicating if the path is accessible or not. */\nasync function isAccessible(path: URL | string, mode?: number): Promise<boolean>;\n// eslint-disable-next-line func-style\nasync function isAccessible(path: URL | string, mode: number = F_OK): Promise<boolean> {\n assertValidFileOrDirectoryPath(path);\n\n // eslint-disable-next-line no-param-reassign\n path = toPath(path);\n\n try {\n await access(path, mode);\n\n return true;\n } catch {\n return false;\n }\n}\n\nexport default isAccessible;\n","import { accessSync } from \"node:fs\";\n\nimport { F_OK } from \"./constants\";\nimport assertValidFileOrDirectoryPath from \"./utils/assert-valid-file-or-directory-path\";\nimport toPath from \"./utils/to-path\";\n\n/** Returns a boolean indicating if the path is accessible or not. */\nfunction isAccessibleSync(path: URL | string, mode?: number): boolean;\n// eslint-disable-next-line func-style\nfunction isAccessibleSync(path: URL | string, mode: number = F_OK): boolean {\n assertValidFileOrDirectoryPath(path);\n\n // eslint-disable-next-line no-param-reassign\n path = toPath(path);\n\n try {\n accessSync(path, mode);\n\n return true;\n } catch {\n return false;\n }\n}\n\nexport default isAccessibleSync;\n","import { readFile as nodeReadFile } from \"node:fs/promises\";\nimport { brotliDecompress, unzip } from \"node:zlib\";\n\nimport { R_OK } from \"./constants\";\nimport PermissionError from \"./error/permission-error\";\nimport isAccessible from \"./is-accessible\";\nimport type { ContentType, ReadFileOptions } from \"./types\";\nimport assertValidFileOrDirectoryPath from \"./utils/assert-valid-file-or-directory-path\";\nimport toPath from \"./utils/to-path\";\n\nconst decompressionMethods = {\n brotli: brotliDecompress,\n gzip: unzip,\n none: (buffer: Buffer, callback: (error: Error | null, result: Buffer) => void) => {\n callback(null, buffer);\n },\n} as const;\n\nconst readFile = async <O extends ReadFileOptions<keyof typeof decompressionMethods> | undefined = undefined>(\n path: URL | string,\n options?: O,\n): Promise<ContentType<O> | undefined> => {\n assertValidFileOrDirectoryPath(path);\n\n // eslint-disable-next-line no-param-reassign\n path = toPath(path);\n\n if (!(await isAccessible(path))) {\n throw new PermissionError(`unable to read the non-accessible file: ${path}`);\n }\n\n if (!(await isAccessible(path, R_OK))) {\n throw new Error(`Unable to read the non-readable file: ${path}`);\n }\n\n const { buffer, compression, encoding, flag } = options ?? {};\n\n // @ts-expect-error - TS doesn't like our typed `encoding` option\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n return await nodeReadFile(path, flag ? { encoding, flag } : { encoding })\n .then(\n async (content) =>\n // eslint-disable-next-line compat/compat\n await new Promise<ContentType<O> | undefined>((resolve, reject) => {\n decompressionMethods[compression ?? \"none\"](content, (error, result) => {\n if (error) {\n reject(error);\n } else {\n resolve((buffer ? result : result.toString()) as ContentType<O>);\n }\n });\n }),\n )\n .catch((error: unknown) => {\n throw error;\n });\n};\n\nexport default readFile;\n","import { readFileSync as nodeReadFileSync } from \"node:fs\";\nimport { brotliDecompressSync, unzipSync } from \"node:zlib\";\n\nimport { R_OK } from \"./constants\";\nimport PermissionError from \"./error/permission-error\";\nimport isAccessibleSync from \"./is-accessible-sync\";\nimport type { ContentType, ReadFileOptions } from \"./types\";\nimport assertValidFileOrDirectoryPath from \"./utils/assert-valid-file-or-directory-path\";\nimport toPath from \"./utils/to-path\";\n\nconst decompressionMethods = {\n brotli: brotliDecompressSync,\n gzip: unzipSync,\n none: (buffer: Buffer) => buffer,\n} as const;\n\nconst readFileSync = <O extends ReadFileOptions<keyof typeof decompressionMethods> | undefined = undefined>(\n path: URL | string,\n options?: O,\n): ContentType<O> | undefined => {\n assertValidFileOrDirectoryPath(path);\n\n // eslint-disable-next-line no-param-reassign\n path = toPath(path);\n\n if (!isAccessibleSync(path)) {\n throw new PermissionError(`unable to read the non-accessible file: ${path}`);\n }\n\n if (!isAccessibleSync(path, R_OK)) {\n throw new PermissionError(`invalid access to read file at: ${path}`);\n }\n\n const { buffer, compression, encoding, flag } = options ?? {};\n\n // @ts-expect-error - TS doesn't like our typed `encoding` option\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n const content = nodeReadFileSync(path, flag ? { encoding, flag } : { encoding });\n\n const decompressed = decompressionMethods[compression ?? \"none\"](content);\n\n return (buffer ? decompressed : decompressed.toString()) as ContentType<O>;\n};\n\nexport default readFileSync;\n","import type { JsonValue } from \"type-fest\";\n\nimport readFile from \"./read-file\";\nimport type { JsonReviver, ReadJsonOptions } from \"./types\";\nimport parseJson from \"./utils/parse-json\";\nimport toPath from \"./utils/to-path\";\n\nasync function readJson<T extends JsonValue>(path: URL | string, options?: ReadJsonOptions): Promise<T>;\n\nasync function readJson<T extends JsonValue>(path: URL | string, reviver: JsonReviver, options?: ReadJsonOptions): Promise<T>;\n// eslint-disable-next-line func-style\nasync function readJson<T extends JsonValue>(path: URL | string, reviver: JsonReviver | ReadJsonOptions, options?: ReadJsonOptions): Promise<T> {\n if (typeof reviver === \"object\") {\n // eslint-disable-next-line no-param-reassign\n options = reviver;\n // eslint-disable-next-line no-param-reassign\n reviver = undefined;\n }\n\n const content = await readFile(path, {\n buffer: true,\n encoding: undefined,\n });\n\n // Unlike `buffer.toString()` and `fs.readFile(path, 'utf8')`, `TextDecoder` will remove BOM.\n let data = new TextDecoder().decode(content);\n\n const { beforeParse, color } = options ?? {};\n\n if (typeof beforeParse === \"function\") {\n data = beforeParse(data);\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return parseJson<T>(data, reviver, toPath(path), { color });\n}\n\nexport default readJson;\n","import type { JsonValue } from \"type-fest\";\n\nimport readFileSync from \"./read-file-sync\";\nimport type { JsonReviver, ReadJsonOptions } from \"./types\";\nimport parseJson from \"./utils/parse-json\";\nimport toPath from \"./utils/to-path\";\n\nfunction readJsonSync<T extends JsonValue>(path: URL | string, options?: ReadJsonOptions): T;\n\nfunction readJsonSync<T extends JsonValue>(path: URL | string, reviver: JsonReviver, options?: ReadJsonOptions): T;\n// eslint-disable-next-line func-style\nfunction readJsonSync<T extends JsonValue>(path: URL | string, reviver: JsonReviver | ReadJsonOptions, options?: ReadJsonOptions): T {\n if (typeof reviver === \"object\") {\n // eslint-disable-next-line no-param-reassign\n options = reviver;\n // eslint-disable-next-line no-param-reassign\n reviver = undefined;\n }\n\n const content = readFileSync(path, {\n buffer: true,\n encoding: undefined,\n });\n\n // Unlike `buffer.toString()` and `fs.readFile(path, 'utf8')`, `TextDecoder` will remove BOM.\n let data = new TextDecoder().decode(content);\n\n const { beforeParse, color } = options ?? {};\n\n if (typeof beforeParse === \"function\") {\n data = beforeParse(data);\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return parseJson<T>(data, reviver, toPath(path), { color });\n}\n\nexport default readJsonSync;\n","import type { Stats } from \"node:fs\";\nimport { chmod, chown, mkdir, rename, stat as nodeStat, unlink, writeFile as nodeWriteFile } from \"node:fs/promises\";\nimport { dirname } from \"node:path\";\n\nimport { F_OK } from \"./constants\";\nimport isAccessible from \"./is-accessible\";\nimport type { WriteFileOptions } from \"./types\";\nimport assertValidFileContents from \"./utils/assert-valid-file-contents\";\nimport assertValidFileOrDirectoryPath from \"./utils/assert-valid-file-or-directory-path\";\nimport toPath from \"./utils/to-path\";\nimport toUint8Array from \"./utils/to-uint-8-array\";\n\n// eslint-disable-next-line sonarjs/cognitive-complexity\nconst writeFile = async (path: URL | string, content: ArrayBuffer | ArrayBufferView | string, options?: WriteFileOptions): Promise<void> => {\n // eslint-disable-next-line no-param-reassign\n options = {\n encoding: \"utf8\",\n flag: \"w\",\n overwrite: true,\n recursive: true,\n ...options,\n };\n\n assertValidFileOrDirectoryPath(path);\n assertValidFileContents(content);\n\n // eslint-disable-next-line no-param-reassign\n path = toPath(path);\n\n try {\n const pathExists = await isAccessible(path, F_OK);\n\n if (!pathExists && options.recursive) {\n const directory = dirname(path);\n\n if (!(await isAccessible(directory, F_OK))) {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n await mkdir(directory, { recursive: true });\n }\n }\n\n let stat: Stats | undefined;\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n await nodeWriteFile(`${path}.tmp`, toUint8Array(content), { encoding: options.encoding, flag: options.flag });\n\n if (pathExists && !options.overwrite) {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n stat = await nodeStat(path);\n\n if (options.chown === undefined) {\n // eslint-disable-next-line no-param-reassign\n options.chown = { gid: stat.gid, uid: stat.uid };\n }\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n await rename(path, `${path}.bak`);\n }\n\n const temporaryPath = `${path}.tmp`;\n\n if (options.chown) {\n try {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n await chown(temporaryPath, options.chown.uid, options.chown.gid);\n } catch {\n // On linux permissionless filesystems like exfat and fat32 the entire filesystem is normally owned by root,\n // and trying to chown it causes as permissions error.\n }\n }\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n await chmod(temporaryPath, stat && !options.mode ? stat.mode : options.mode ?? 0o666);\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n await rename(temporaryPath, path);\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n throw new Error(`Failed to write file at: ${path} - ${error.message}`, { cause: error });\n } finally {\n if (await isAccessible(`${path}.tmp`)) {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n await unlink(`${path}.tmp`);\n }\n }\n};\n\nexport default writeFile;\n","// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types,@typescript-eslint/no-explicit-any\nconst assertValidFileContents = (contents: any): void => {\n if (typeof contents !== \"string\" && !(contents instanceof ArrayBuffer) && !ArrayBuffer.isView(contents)) {\n throw new TypeError(\"File contents must be a string, ArrayBuffer, or ArrayBuffer view.\");\n }\n};\n\nexport default assertValidFileContents;\n","const encoder = new TextEncoder();\n\n// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types,@typescript-eslint/no-explicit-any\nconst toUint8Array = (contents: any) => {\n if (contents instanceof Uint8Array) {\n return contents;\n }\n\n if (typeof contents === \"string\") {\n return encoder.encode(contents);\n }\n\n if (contents instanceof ArrayBuffer) {\n return new Uint8Array(contents);\n }\n\n if (ArrayBuffer.isView(contents)) {\n const bytes = contents.buffer.slice(contents.byteOffset, contents.byteOffset + contents.byteLength);\n\n return new Uint8Array(bytes);\n }\n\n throw new TypeError(\"Invalid contents type. Expected string or ArrayBuffer.\");\n};\n\nexport default toUint8Array;\n","import type { Stats } from \"node:fs\";\nimport { chmodSync, chownSync, mkdirSync, renameSync, statSync, unlinkSync, writeFileSync as nodeWriteFileSync } from \"node:fs\";\nimport { dirname } from \"node:path\";\n\nimport { F_OK } from \"./constants\";\nimport isAccessibleSync from \"./is-accessible-sync\";\nimport type { WriteFileOptions } from \"./types\";\nimport assertValidFileContents from \"./utils/assert-valid-file-contents\";\nimport assertValidFileOrDirectoryPath from \"./utils/assert-valid-file-or-directory-path\";\nimport toPath from \"./utils/to-path\";\nimport toUint8Array from \"./utils/to-uint-8-array\";\n\n// eslint-disable-next-line sonarjs/cognitive-complexity\nconst writeFileSync = (path: URL | string, content: ArrayBuffer | ArrayBufferView | string, options?: WriteFileOptions): void => {\n // eslint-disable-next-line no-param-reassign\n options = {\n encoding: \"utf8\",\n flag: \"w\",\n overwrite: true,\n recursive: true,\n ...options,\n };\n\n assertValidFileOrDirectoryPath(path);\n assertValidFileContents(content);\n\n // eslint-disable-next-line no-param-reassign\n path = toPath(path);\n\n try {\n const pathExists = isAccessibleSync(path, F_OK);\n\n if (!pathExists && options.recursive) {\n const directory = dirname(path);\n\n if (!isAccessibleSync(directory, F_OK)) {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n mkdirSync(directory, { recursive: true });\n }\n }\n\n let stat: Stats | undefined;\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n nodeWriteFileSync(`${path}.tmp`, toUint8Array(content), { encoding: options.encoding, flag: options.flag });\n\n if (pathExists && !options.overwrite) {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n stat = statSync(path);\n\n if (options.chown === undefined) {\n // eslint-disable-next-line no-param-reassign\n options.chown = { gid: stat.gid, uid: stat.uid };\n }\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n renameSync(path, `${path}.bak`);\n }\n\n const temporaryPath = `${path}.tmp`;\n\n if (options.chown) {\n try {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n chownSync(temporaryPath, options.chown.uid, options.chown.gid);\n } catch {\n // On linux permissionless filesystems like exfat and fat32 the entire filesystem is normally owned by root,\n // and trying to chown it causes as permissions error.\n }\n }\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n chmodSync(temporaryPath, stat && !options.mode ? stat.mode : options.mode ?? 0o666);\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n renameSync(temporaryPath, path);\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n throw new Error(`Failed to write file at: ${path} - ${error.message}`, { cause: error });\n } finally {\n if (isAccessibleSync(`${path}.tmp`)) {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n unlinkSync(`${path}.tmp`);\n }\n }\n};\n\nexport default writeFileSync;\n","import { readFile } from \"node:fs/promises\";\n\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport detectIndentFn from \"detect-indent\";\n\nimport { R_OK } from \"./constants\";\nimport isAccessible from \"./is-accessible\";\nimport type { WriteJsonOptions } from \"./types\";\nimport writeFile from \"./write-file\";\n\nconst writeJson = async (path: URL | string, data: unknown, options: WriteJsonOptions = {}): Promise<void> => {\n const { detectIndent, indent: indentOption , replacer, ...writeOptions } = { indent: \"\\t\", ...options};\n\n let indent = indentOption;\n let trailingNewline = \"\\n\";\n\n if (await isAccessible(path, R_OK)) {\n try {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n const file = await readFile(path, \"utf8\");\n\n if (detectIndent) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-assignment\n const { indent: dIndent } = detectIndentFn(file);\n\n indent = dIndent as string;\n }\n\n trailingNewline = file.endsWith(\"\\n\") ? \"\\n\" : \"\";\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n if (error.code !== \"ENOENT\") {\n throw error;\n }\n }\n }\n\n // @ts-expect-error - `replacer` is a valid argument for `JSON.stringify`\n const json = JSON.stringify(data, replacer, indent);\n\n await writeFile(path, `${json}${trailingNewline}`, writeOptions);\n};\n\nexport default writeJson;\n","// Detect either spaces or tabs but not both to properly handle tabs for indentation and spaces for alignment\nconst INDENT_REGEX = /^(?:( )+|\\t+)/;\n\nconst INDENT_TYPE_SPACE = 'space';\nconst INDENT_TYPE_TAB = 'tab';\n\n/**\nMake a Map that counts how many indents/unindents have occurred for a given size and how many lines follow a given indentation.\n\nThe key is a concatenation of the indentation type (s = space and t = tab) and the size of the indents/unindents.\n\n```\nindents = {\n\tt3: [1, 0],\n\tt4: [1, 5],\n\ts5: [1, 0],\n\ts12: [1, 0],\n}\n```\n*/\nfunction makeIndentsMap(string, ignoreSingleSpaces) {\n\tconst indents = new Map();\n\n\t// Remember the size of previous line's indentation\n\tlet previousSize = 0;\n\tlet previousIndentType;\n\n\t// Indents key (ident type + size of the indents/unindents)\n\tlet key;\n\n\tfor (const line of string.split(/\\n/g)) {\n\t\tif (!line) {\n\t\t\t// Ignore empty lines\n\t\t\tcontinue;\n\t\t}\n\n\t\tlet indent;\n\t\tlet indentType;\n\t\tlet use;\n\t\tlet weight;\n\t\tlet entry;\n\t\tconst matches = line.match(INDENT_REGEX);\n\n\t\tif (matches === null) {\n\t\t\tpreviousSize = 0;\n\t\t\tpreviousIndentType = '';\n\t\t} else {\n\t\t\tindent = matches[0].length;\n\t\t\tindentType = matches[1] ? INDENT_TYPE_SPACE : INDENT_TYPE_TAB;\n\n\t\t\t// Ignore single space unless it's the only indent detected to prevent common false positives\n\t\t\tif (ignoreSingleSpaces && indentType === INDENT_TYPE_SPACE && indent === 1) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (indentType !== previousIndentType) {\n\t\t\t\tpreviousSize = 0;\n\t\t\t}\n\n\t\t\tpreviousIndentType = indentType;\n\n\t\t\tuse = 1;\n\t\t\tweight = 0;\n\n\t\t\tconst indentDifference = indent - previousSize;\n\t\t\tpreviousSize = indent;\n\n\t\t\t// Previous line have same indent?\n\t\t\tif (indentDifference === 0) {\n\t\t\t\t// Not a new \"use\" of the current indent:\n\t\t\t\tuse = 0;\n\t\t\t\t// But do add a bit to it for breaking ties:\n\t\t\t\tweight = 1;\n\t\t\t\t// We use the key from previous loop\n\t\t\t} else {\n\t\t\t\tconst absoluteIndentDifference = indentDifference > 0 ? indentDifference : -indentDifference;\n\t\t\t\tkey = encodeIndentsKey(indentType, absoluteIndentDifference);\n\t\t\t}\n\n\t\t\t// Update the stats\n\t\t\tentry = indents.get(key);\n\t\t\tentry = entry === undefined ? [1, 0] : [entry[0] + use, entry[1] + weight];\n\n\t\t\tindents.set(key, entry);\n\t\t}\n\t}\n\n\treturn indents;\n}\n\n// Encode the indent type and amount as a string (e.g. 's4') for use as a compound key in the indents Map.\nfunction encodeIndentsKey(indentType, indentAmount) {\n\tconst typeCharacter = indentType === INDENT_TYPE_SPACE ? 's' : 't';\n\treturn typeCharacter + String(indentAmount);\n}\n\n// Extract the indent type and amount from a key of the indents Map.\nfunction decodeIndentsKey(indentsKey) {\n\tconst keyHasTypeSpace = indentsKey[0] === 's';\n\tconst type = keyHasTypeSpace ? INDENT_TYPE_SPACE : INDENT_TYPE_TAB;\n\n\tconst amount = Number(indentsKey.slice(1));\n\n\treturn {type, amount};\n}\n\n// Return the key (e.g. 's4') from the indents Map that represents the most common indent,\n// or return undefined if there are no indents.\nfunction getMostUsedKey(indents) {\n\tlet result;\n\tlet maxUsed = 0;\n\tlet maxWeight = 0;\n\n\tfor (const [key, [usedCount, weight]] of indents) {\n\t\tif (usedCount > maxUsed || (usedCount === maxUsed && weight > maxWeight)) {\n\t\t\tmaxUsed = usedCount;\n\t\t\tmaxWeight = weight;\n\t\t\tresult = key;\n\t\t}\n\t}\n\n\treturn result;\n}\n\nfunction makeIndentString(type, amount) {\n\tconst indentCharacter = type === INDENT_TYPE_SPACE ? ' ' : '\\t';\n\treturn indentCharacter.repeat(amount);\n}\n\nexport default function detectIndent(string) {\n\tif (typeof string !== 'string') {\n\t\tthrow new TypeError('Expected a string');\n\t}\n\n\t// Identify indents while skipping single space indents to avoid common edge cases (e.g. code comments)\n\t// If no indents are identified, run again and include all indents for comprehensive detection\n\tlet indents = makeIndentsMap(string, true);\n\tif (indents.size === 0) {\n\t\tindents = makeIndentsMap(string, false);\n\t}\n\n\tconst keyOfMostUsedIndent = getMostUsedKey(indents);\n\n\tlet type;\n\tlet amount = 0;\n\tlet indent = '';\n\n\tif (keyOfMostUsedIndent !== undefined) {\n\t\t({type, amount} = decodeIndentsKey(keyOfMostUsedIndent));\n\t\tindent = makeIndentString(type, amount);\n\t}\n\n\treturn {\n\t\tamount,\n\t\ttype,\n\t\tindent,\n\t};\n}\n","import { readFileSync } from \"node:fs\";\n\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport detectIndentFn from \"detect-indent\";\n\nimport { R_OK } from \"./constants\";\nimport isAccessibleSync from \"./is-accessible-sync\";\nimport type { WriteJsonOptions } from \"./types\";\nimport writeFileSync from \"./write-file-sync\";\n\nconst writeJsonSync = (path: URL | string, data: unknown, options: WriteJsonOptions = {}): void => {\n const { detectIndent, indent: indentOption , replacer, ...writeOptions } = { indent: \"\\t\", ...options};\n\n let indent = indentOption;\n let trailingNewline = \"\\n\";\n\n if (isAccessibleSync(path, R_OK)) {\n try {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n const file = readFileSync(path, \"utf8\");\n\n if (detectIndent) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-assignment\n const { indent: dIndent } = detectIndentFn(file);\n\n indent = dIndent as string;\n }\n\n trailingNewline = file.endsWith(\"\\n\") ? \"\\n\" : \"\";\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n if (error.code !== \"ENOENT\") {\n throw error;\n }\n }\n }\n\n // @ts-expect-error - `replacer` is a valid argument for `JSON.stringify`\n const json = JSON.stringify(data, replacer, indent);\n\n writeFileSync(path, `${json}${trailingNewline}`, writeOptions);\n};\n\nexport default writeJsonSync;\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
declare class JSONError extends Error {
|
|
2
|
+
#private;
|
|
3
|
+
fileName: string | undefined;
|
|
4
|
+
codeFrame: string | undefined;
|
|
5
|
+
readonly name = "JSONError";
|
|
6
|
+
constructor(message: string);
|
|
7
|
+
get message(): string;
|
|
8
|
+
set message(message: string);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export { JSONError as J };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
declare class JSONError extends Error {
|
|
2
|
+
#private;
|
|
3
|
+
fileName: string | undefined;
|
|
4
|
+
codeFrame: string | undefined;
|
|
5
|
+
readonly name = "JSONError";
|
|
6
|
+
constructor(message: string);
|
|
7
|
+
get message(): string;
|
|
8
|
+
set message(message: string);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export { JSONError as J };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { Dirent } from 'node:fs';
|
|
2
|
+
|
|
3
|
+
type ColorizeMethod = (value: string) => string;
|
|
4
|
+
interface WalkOptions {
|
|
5
|
+
extensions?: string[];
|
|
6
|
+
followSymlinks?: boolean;
|
|
7
|
+
includeDirs?: boolean;
|
|
8
|
+
includeFiles?: boolean;
|
|
9
|
+
includeSymlinks?: boolean;
|
|
10
|
+
match?: (RegExp | string)[];
|
|
11
|
+
maxDepth?: number;
|
|
12
|
+
skip?: (RegExp | string)[];
|
|
13
|
+
}
|
|
14
|
+
interface WalkEntry extends Pick<Dirent, "isDirectory" | "isFile" | "isSymbolicLink" | "name"> {
|
|
15
|
+
path: string;
|
|
16
|
+
}
|
|
17
|
+
type ReadFileEncoding = "ascii" | "base64" | "base64url" | "hex" | "latin1" | "ucs-2" | "ucs2" | "utf-8" | "utf-16le" | "utf8" | "utf16le";
|
|
18
|
+
type ReadFileOptions<C> = {
|
|
19
|
+
buffer?: boolean;
|
|
20
|
+
compression?: C;
|
|
21
|
+
encoding?: ReadFileEncoding | undefined;
|
|
22
|
+
flag?: number | string | undefined;
|
|
23
|
+
};
|
|
24
|
+
type ContentType<O = undefined> = O extends {
|
|
25
|
+
buffer: true;
|
|
26
|
+
} ? Buffer : string;
|
|
27
|
+
type JsonReviver = Parameters<(typeof JSON)["parse"]>["1"];
|
|
28
|
+
type CodeFrameLocation = {
|
|
29
|
+
column?: number;
|
|
30
|
+
line: number;
|
|
31
|
+
};
|
|
32
|
+
type CodeFrameOptions = {
|
|
33
|
+
color?: {
|
|
34
|
+
gutter?: ColorizeMethod;
|
|
35
|
+
marker?: ColorizeMethod;
|
|
36
|
+
message?: ColorizeMethod;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
type ReadJsonOptions = CodeFrameOptions & {
|
|
40
|
+
beforeParse?: (source: string) => string;
|
|
41
|
+
};
|
|
42
|
+
type WriteFileOptions = {
|
|
43
|
+
chown?: {
|
|
44
|
+
gid: number;
|
|
45
|
+
uid: number;
|
|
46
|
+
};
|
|
47
|
+
encoding?: BufferEncoding | null | undefined;
|
|
48
|
+
flag?: string | undefined;
|
|
49
|
+
mode?: number;
|
|
50
|
+
overwrite?: boolean;
|
|
51
|
+
recursive?: boolean;
|
|
52
|
+
};
|
|
53
|
+
type JsonReplacer = (this: unknown, key: string, value: unknown) => unknown;
|
|
54
|
+
type WriteJsonOptions = WriteFileOptions & {
|
|
55
|
+
detectIndent?: boolean;
|
|
56
|
+
indent?: number | string | undefined;
|
|
57
|
+
replacer?: (number | string)[] | JsonReplacer | null;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export type { ContentType as C, JsonReviver as J, ReadFileOptions as R, WalkOptions as W, ReadJsonOptions as a, WalkEntry as b, WriteFileOptions as c, WriteJsonOptions as d, CodeFrameLocation as e, JsonReplacer as f, ReadFileEncoding as g, CodeFrameOptions as h };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { Dirent } from 'node:fs';
|
|
2
|
+
|
|
3
|
+
type ColorizeMethod = (value: string) => string;
|
|
4
|
+
interface WalkOptions {
|
|
5
|
+
extensions?: string[];
|
|
6
|
+
followSymlinks?: boolean;
|
|
7
|
+
includeDirs?: boolean;
|
|
8
|
+
includeFiles?: boolean;
|
|
9
|
+
includeSymlinks?: boolean;
|
|
10
|
+
match?: (RegExp | string)[];
|
|
11
|
+
maxDepth?: number;
|
|
12
|
+
skip?: (RegExp | string)[];
|
|
13
|
+
}
|
|
14
|
+
interface WalkEntry extends Pick<Dirent, "isDirectory" | "isFile" | "isSymbolicLink" | "name"> {
|
|
15
|
+
path: string;
|
|
16
|
+
}
|
|
17
|
+
type ReadFileEncoding = "ascii" | "base64" | "base64url" | "hex" | "latin1" | "ucs-2" | "ucs2" | "utf-8" | "utf-16le" | "utf8" | "utf16le";
|
|
18
|
+
type ReadFileOptions<C> = {
|
|
19
|
+
buffer?: boolean;
|
|
20
|
+
compression?: C;
|
|
21
|
+
encoding?: ReadFileEncoding | undefined;
|
|
22
|
+
flag?: number | string | undefined;
|
|
23
|
+
};
|
|
24
|
+
type ContentType<O = undefined> = O extends {
|
|
25
|
+
buffer: true;
|
|
26
|
+
} ? Buffer : string;
|
|
27
|
+
type JsonReviver = Parameters<(typeof JSON)["parse"]>["1"];
|
|
28
|
+
type CodeFrameLocation = {
|
|
29
|
+
column?: number;
|
|
30
|
+
line: number;
|
|
31
|
+
};
|
|
32
|
+
type CodeFrameOptions = {
|
|
33
|
+
color?: {
|
|
34
|
+
gutter?: ColorizeMethod;
|
|
35
|
+
marker?: ColorizeMethod;
|
|
36
|
+
message?: ColorizeMethod;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
type ReadJsonOptions = CodeFrameOptions & {
|
|
40
|
+
beforeParse?: (source: string) => string;
|
|
41
|
+
};
|
|
42
|
+
type WriteFileOptions = {
|
|
43
|
+
chown?: {
|
|
44
|
+
gid: number;
|
|
45
|
+
uid: number;
|
|
46
|
+
};
|
|
47
|
+
encoding?: BufferEncoding | null | undefined;
|
|
48
|
+
flag?: string | undefined;
|
|
49
|
+
mode?: number;
|
|
50
|
+
overwrite?: boolean;
|
|
51
|
+
recursive?: boolean;
|
|
52
|
+
};
|
|
53
|
+
type JsonReplacer = (this: unknown, key: string, value: unknown) => unknown;
|
|
54
|
+
type WriteJsonOptions = WriteFileOptions & {
|
|
55
|
+
detectIndent?: boolean;
|
|
56
|
+
indent?: number | string | undefined;
|
|
57
|
+
replacer?: (number | string)[] | JsonReplacer | null;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export type { ContentType as C, JsonReviver as J, ReadFileOptions as R, WalkOptions as W, ReadJsonOptions as a, WalkEntry as b, WriteFileOptions as c, WriteJsonOptions as d, CodeFrameLocation as e, JsonReplacer as f, ReadFileEncoding as g, CodeFrameOptions as h };
|
package/dist/utils.cjs
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkC4ULY5SU_cjs = require('./chunk-C4ULY5SU.cjs');
|
|
4
|
+
var chunkN5NZURYL_cjs = require('./chunk-N5NZURYL.cjs');
|
|
5
|
+
|
|
6
|
+
var p=(e,{whitespace:t=!0}={})=>e.replace(f,r=>r.startsWith('"')||r[1]==="*"&&!r.endsWith("*/")?r:t?r.replaceAll(/\S/g," "):""),f=/"(?:[^"\\]|\\.)*"?|\/\/[^\r\n]*|\/\*(?:[^*]|\*[^/])*(?:\*\/)?/g,l=p;
|
|
7
|
+
|
|
8
|
+
Object.defineProperty(exports, 'parseJson', {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function () { return chunkC4ULY5SU_cjs.a; }
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, 'JSONError', {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () { return chunkN5NZURYL_cjs.a; }
|
|
15
|
+
});
|
|
16
|
+
exports.stripJsonComments = l;
|
|
17
|
+
//# sourceMappingURL=out.js.map
|
|
18
|
+
//# sourceMappingURL=utils.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/strip-json-comments.ts"],"names":["stripJsonComments","jsonString","whitespace","INTERNAL_STRIP_JSON_REGEX","match","strip_json_comments_default"],"mappings":"kFAEA,IAAMA,EAAoB,CAACC,EAAoB,CAAE,WAAAC,EAAa,EAAK,EAAI,CAAC,IASpED,EAAW,QAAQE,EAA4BC,GAEvCA,EAAM,WAAW,GAAG,GAAMA,EAAM,CAAC,IAAM,KAAO,CAACA,EAAM,SAAS,IAAI,EAC3DA,EAIJF,EAAaE,EAAM,WAAW,MAAO,GAAG,EAAI,EACtD,EAEQD,EAA4B,iEAElCE,EAAQL","sourcesContent":["// Copyright by https://github.com/swansontec\n\nconst stripJsonComments = (jsonString: string, { whitespace = true } = {}): string =>\n // This regular expression translates to:\n //\n // /quoted-string|line-comment|block-comment/g\n //\n // This means that comment characters inside of strings will match\n // as strings, not comments, so we can just skip the whole string\n // in the replacer function.\n // eslint-disable-next-line unicorn/prefer-string-replace-all,@typescript-eslint/no-use-before-define\n jsonString.replace(INTERNAL_STRIP_JSON_REGEX, (match) => {\n // Skip strings & broken block comments:\n if (match.startsWith('\"') || (match[1] === \"*\" && !match.endsWith(\"*/\"))) {\n return match;\n }\n\n // Replace comments with whitespace (or not):\n return whitespace ? match.replaceAll(/\\S/g, \" \") : \"\";\n });\n\nexport const INTERNAL_STRIP_JSON_REGEX = /\"(?:[^\"\\\\]|\\\\.)*\"?|\\/\\/[^\\r\\n]*|\\/\\*(?:[^*]|\\*[^/])*(?:\\*\\/)?/g;\n\nexport default stripJsonComments;\n"]}
|
package/dist/utils.d.cts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export { J as JSONError } from './json-error-UVjLdb7z.cjs';
|
|
2
|
+
import { JsonValue } from 'type-fest';
|
|
3
|
+
import { h as CodeFrameOptions, J as JsonReviver } from './types-4y_sJiOD.cjs';
|
|
4
|
+
import 'node:fs';
|
|
5
|
+
|
|
6
|
+
declare function parseJson<T = JsonValue>(string: string, filename?: string, options?: CodeFrameOptions): T;
|
|
7
|
+
declare function parseJson<T = JsonValue>(string: string, reviver: JsonReviver, fileName?: string, options?: CodeFrameOptions): T;
|
|
8
|
+
|
|
9
|
+
declare const stripJsonComments: (jsonString: string, { whitespace }?: {
|
|
10
|
+
whitespace?: boolean | undefined;
|
|
11
|
+
}) => string;
|
|
12
|
+
|
|
13
|
+
export { parseJson, stripJsonComments };
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export { J as JSONError } from './json-error-UVjLdb7z.js';
|
|
2
|
+
import { JsonValue } from 'type-fest';
|
|
3
|
+
import { h as CodeFrameOptions, J as JsonReviver } from './types-4y_sJiOD.js';
|
|
4
|
+
import 'node:fs';
|
|
5
|
+
|
|
6
|
+
declare function parseJson<T = JsonValue>(string: string, filename?: string, options?: CodeFrameOptions): T;
|
|
7
|
+
declare function parseJson<T = JsonValue>(string: string, reviver: JsonReviver, fileName?: string, options?: CodeFrameOptions): T;
|
|
8
|
+
|
|
9
|
+
declare const stripJsonComments: (jsonString: string, { whitespace }?: {
|
|
10
|
+
whitespace?: boolean | undefined;
|
|
11
|
+
}) => string;
|
|
12
|
+
|
|
13
|
+
export { parseJson, stripJsonComments };
|
package/dist/utils.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { a as parseJson } from './chunk-7UNFLLNN.js';
|
|
2
|
+
export { a as JSONError } from './chunk-UPN3Y5W3.js';
|
|
3
|
+
|
|
4
|
+
var f=(e,{whitespace:t=!0}={})=>e.replace(l,r=>r.startsWith('"')||r[1]==="*"&&!r.endsWith("*/")?r:t?r.replaceAll(/\S/g," "):""),l=/"(?:[^"\\]|\\.)*"?|\/\/[^\r\n]*|\/\*(?:[^*]|\*[^/])*(?:\*\/)?/g,a=f;
|
|
5
|
+
|
|
6
|
+
export { a as stripJsonComments };
|
|
7
|
+
//# sourceMappingURL=out.js.map
|
|
8
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/strip-json-comments.ts"],"names":["stripJsonComments","jsonString","whitespace","INTERNAL_STRIP_JSON_REGEX","match","strip_json_comments_default"],"mappings":"gFAEA,IAAMA,EAAoB,CAACC,EAAoB,CAAE,WAAAC,EAAa,EAAK,EAAI,CAAC,IASpED,EAAW,QAAQE,EAA4BC,GAEvCA,EAAM,WAAW,GAAG,GAAMA,EAAM,CAAC,IAAM,KAAO,CAACA,EAAM,SAAS,IAAI,EAC3DA,EAIJF,EAAaE,EAAM,WAAW,MAAO,GAAG,EAAI,EACtD,EAEQD,EAA4B,iEAElCE,EAAQL","sourcesContent":["// Copyright by https://github.com/swansontec\n\nconst stripJsonComments = (jsonString: string, { whitespace = true } = {}): string =>\n // This regular expression translates to:\n //\n // /quoted-string|line-comment|block-comment/g\n //\n // This means that comment characters inside of strings will match\n // as strings, not comments, so we can just skip the whole string\n // in the replacer function.\n // eslint-disable-next-line unicorn/prefer-string-replace-all,@typescript-eslint/no-use-before-define\n jsonString.replace(INTERNAL_STRIP_JSON_REGEX, (match) => {\n // Skip strings & broken block comments:\n if (match.startsWith('\"') || (match[1] === \"*\" && !match.endsWith(\"*/\"))) {\n return match;\n }\n\n // Replace comments with whitespace (or not):\n return whitespace ? match.replaceAll(/\\S/g, \" \") : \"\";\n });\n\nexport const INTERNAL_STRIP_JSON_REGEX = /\"(?:[^\"\\\\]|\\\\.)*\"?|\\/\\/[^\\r\\n]*|\\/\\*(?:[^*]|\\*[^/])*(?:\\*\\/)?/g;\n\nexport default stripJsonComments;\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@visulima/fs",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Human friendly file system utilities for Node.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"anolilab",
|
|
@@ -17,6 +17,8 @@
|
|
|
17
17
|
"fs-safe",
|
|
18
18
|
"look",
|
|
19
19
|
"look-up",
|
|
20
|
+
"json",
|
|
21
|
+
"read-json",
|
|
20
22
|
"match",
|
|
21
23
|
"package",
|
|
22
24
|
"parent",
|
|
@@ -70,11 +72,30 @@
|
|
|
70
72
|
"default": "./dist/index.js"
|
|
71
73
|
}
|
|
72
74
|
},
|
|
75
|
+
"./utils": {
|
|
76
|
+
"require": {
|
|
77
|
+
"types": "./dist/utils.d.cts",
|
|
78
|
+
"default": "./dist/utils.cjs"
|
|
79
|
+
},
|
|
80
|
+
"import": {
|
|
81
|
+
"types": "./dist/utils.d.ts",
|
|
82
|
+
"default": "./dist/utils.js"
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
"./error": {
|
|
86
|
+
"require": {
|
|
87
|
+
"types": "./dist/error.d.cts",
|
|
88
|
+
"default": "./dist/error.cjs"
|
|
89
|
+
},
|
|
90
|
+
"import": {
|
|
91
|
+
"types": "./dist/error.d.ts",
|
|
92
|
+
"default": "./dist/error.js"
|
|
93
|
+
}
|
|
94
|
+
},
|
|
73
95
|
"./package.json": "./package.json"
|
|
74
96
|
},
|
|
75
97
|
"main": "dist/index.cjs",
|
|
76
98
|
"module": "dist/index.js",
|
|
77
|
-
"source": "src/index.ts",
|
|
78
99
|
"types": "dist/index.d.ts",
|
|
79
100
|
"files": [
|
|
80
101
|
"dist/**",
|
|
@@ -98,14 +119,18 @@
|
|
|
98
119
|
"test:ui": "vitest --ui --coverage.enabled=true",
|
|
99
120
|
"test:watch": "vitest"
|
|
100
121
|
},
|
|
122
|
+
"dependencies": {
|
|
123
|
+
"type-fest": "^4.12.0"
|
|
124
|
+
},
|
|
101
125
|
"devDependencies": {
|
|
126
|
+
"detect-indent": "^7.0.1",
|
|
102
127
|
"@anolilab/eslint-config": "^15.0.3",
|
|
103
128
|
"@anolilab/prettier-config": "^5.0.14",
|
|
104
129
|
"@anolilab/semantic-release-preset": "^8.0.3",
|
|
105
130
|
"@babel/core": "^7.24.0",
|
|
106
131
|
"@rushstack/eslint-plugin-security": "^0.8.1",
|
|
107
|
-
"@types/micromatch": "^4.0.6",
|
|
108
132
|
"@types/node": "18.18.14",
|
|
133
|
+
"@visulima/error": "3.2.0",
|
|
109
134
|
"@vitest/coverage-v8": "^1.3.1",
|
|
110
135
|
"@vitest/ui": "^1.3.1",
|
|
111
136
|
"cross-env": "^7.0.3",
|
|
@@ -114,10 +139,12 @@
|
|
|
114
139
|
"eslint-plugin-etc": "^2.0.3",
|
|
115
140
|
"eslint-plugin-import": "npm:eslint-plugin-i@^2.29.1",
|
|
116
141
|
"eslint-plugin-mdx": "^3.1.5",
|
|
117
|
-
"eslint-plugin-vitest": "^0.3.
|
|
142
|
+
"eslint-plugin-vitest": "^0.3.25",
|
|
118
143
|
"eslint-plugin-vitest-globals": "^1.4.0",
|
|
119
144
|
"prettier": "^3.2.5",
|
|
145
|
+
"redos-detector": "^5.1.0",
|
|
120
146
|
"rimraf": "^5.0.5",
|
|
147
|
+
"safe-regex2": "^3.1.0",
|
|
121
148
|
"semantic-release": "^23.0.2",
|
|
122
149
|
"sort-package-json": "^2.8.0",
|
|
123
150
|
"tempy": "^3.1.0",
|
|
@@ -143,5 +170,10 @@
|
|
|
143
170
|
"info_on_disabling_jsonc_sort_keys_rule": false,
|
|
144
171
|
"info_on_disabling_etc_no_deprecated": false
|
|
145
172
|
}
|
|
146
|
-
}
|
|
173
|
+
},
|
|
174
|
+
"sources": [
|
|
175
|
+
"src/index.ts",
|
|
176
|
+
"src/error.ts",
|
|
177
|
+
"src/utils.ts"
|
|
178
|
+
]
|
|
147
179
|
}
|