@socketsecurity/lib 2.10.3 → 3.0.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.
Files changed (76) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/README.md +231 -40
  3. package/dist/constants/platform.js +1 -1
  4. package/dist/constants/platform.js.map +3 -3
  5. package/dist/cover/code.js +1 -1
  6. package/dist/cover/code.js.map +3 -3
  7. package/dist/debug.js +2 -2
  8. package/dist/debug.js.map +3 -3
  9. package/dist/dlx-binary.d.ts +29 -6
  10. package/dist/dlx-binary.js +7 -7
  11. package/dist/dlx-binary.js.map +3 -3
  12. package/dist/dlx-package.d.ts +16 -1
  13. package/dist/dlx-package.js +7 -7
  14. package/dist/dlx-package.js.map +3 -3
  15. package/dist/dlx.js +4 -4
  16. package/dist/dlx.js.map +3 -3
  17. package/dist/env/rewire.js +1 -1
  18. package/dist/env/rewire.js.map +3 -3
  19. package/dist/env/socket-cli.d.ts +7 -0
  20. package/dist/env/socket-cli.js +1 -1
  21. package/dist/env/socket-cli.js.map +2 -2
  22. package/dist/external/yoctocolors-cjs.d.ts +14 -0
  23. package/dist/fs.d.ts +82 -27
  24. package/dist/fs.js +7 -7
  25. package/dist/fs.js.map +3 -3
  26. package/dist/git.js +1 -1
  27. package/dist/git.js.map +3 -3
  28. package/dist/http-request.js +1 -1
  29. package/dist/http-request.js.map +3 -3
  30. package/dist/ipc.js +1 -1
  31. package/dist/ipc.js.map +3 -3
  32. package/dist/links/index.d.ts +65 -0
  33. package/dist/links/index.js +3 -0
  34. package/dist/links/index.js.map +7 -0
  35. package/dist/logger.d.ts +21 -18
  36. package/dist/logger.js +1 -1
  37. package/dist/logger.js.map +3 -3
  38. package/dist/packages/isolation.js +1 -1
  39. package/dist/packages/isolation.js.map +3 -3
  40. package/dist/paths.js +1 -1
  41. package/dist/paths.js.map +2 -2
  42. package/dist/process-lock.js +2 -2
  43. package/dist/process-lock.js.map +3 -3
  44. package/dist/promises.d.ts +6 -21
  45. package/dist/promises.js +1 -1
  46. package/dist/promises.js.map +2 -2
  47. package/dist/prompts/index.d.ts +115 -0
  48. package/dist/prompts/index.js +3 -0
  49. package/dist/prompts/index.js.map +7 -0
  50. package/dist/spinner.d.ts +33 -23
  51. package/dist/spinner.js +1 -1
  52. package/dist/spinner.js.map +3 -3
  53. package/dist/stdio/mask.d.ts +2 -2
  54. package/dist/stdio/mask.js +4 -4
  55. package/dist/stdio/mask.js.map +3 -3
  56. package/dist/stdio/stdout.js +1 -1
  57. package/dist/stdio/stdout.js.map +3 -3
  58. package/dist/themes/context.d.ts +80 -0
  59. package/dist/themes/context.js +3 -0
  60. package/dist/themes/context.js.map +7 -0
  61. package/dist/themes/index.d.ts +53 -0
  62. package/dist/themes/index.js +3 -0
  63. package/dist/themes/index.js.map +7 -0
  64. package/dist/themes/themes.d.ts +49 -0
  65. package/dist/themes/themes.js +3 -0
  66. package/dist/themes/themes.js.map +7 -0
  67. package/dist/themes/types.d.ts +92 -0
  68. package/dist/themes/types.js +3 -0
  69. package/dist/themes/types.js.map +7 -0
  70. package/dist/themes/utils.d.ts +78 -0
  71. package/dist/themes/utils.js +3 -0
  72. package/dist/themes/utils.js.map +7 -0
  73. package/package.json +40 -8
  74. package/dist/download-lock.d.ts +0 -49
  75. package/dist/download-lock.js +0 -10
  76. package/dist/download-lock.js.map +0 -7
package/dist/fs.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/fs.ts"],
4
- "sourcesContent": ["/**\n * @fileoverview File system utilities with cross-platform path handling.\n * Provides enhanced fs operations, glob matching, and directory traversal functions.\n */\n\nimport type { Abortable } from 'node:events'\nimport type {\n Dirent,\n ObjectEncodingOptions,\n OpenMode,\n PathLike,\n StatSyncOptions,\n WriteFileOptions,\n} from 'node:fs'\n\nimport { getAbortSignal } from '#constants/process'\n\nimport { isArray } from './arrays'\n\nconst abortSignal = getAbortSignal()\n\nimport { defaultIgnore, getGlobMatcher } from './globs'\nimport type { JsonReviver } from './json'\nimport { jsonParse } from './json'\nimport { objectFreeze, type Remap } from './objects'\nimport { normalizePath, pathLikeToString } from './path'\nimport { registerCacheInvalidation } from './paths/rewire'\nimport { naturalCompare } from './sorts'\n\n/**\n * Supported text encodings for Node.js Buffers.\n * Includes ASCII, UTF-8/16, base64, binary, and hexadecimal encodings.\n */\nexport type BufferEncoding =\n | 'ascii'\n | 'utf8'\n | 'utf-8'\n | 'utf16le'\n | 'ucs2'\n | 'ucs-2'\n | 'base64'\n | 'base64url'\n | 'latin1'\n | 'binary'\n | 'hex'\n\n/**\n * Represents any valid JSON content type.\n */\nexport type JsonContent = unknown\n\n/**\n * Options for asynchronous `findUp` operations.\n */\nexport interface FindUpOptions {\n /**\n * Starting directory for the search.\n * @default process.cwd()\n */\n cwd?: string | undefined\n /**\n * Only match directories, not files.\n * @default false\n */\n onlyDirectories?: boolean | undefined\n /**\n * Only match files, not directories.\n * @default true\n */\n onlyFiles?: boolean | undefined\n /**\n * Abort signal to cancel the search operation.\n */\n signal?: AbortSignal | undefined\n}\n\n/**\n * Options for synchronous `findUpSync` operations.\n */\nexport interface FindUpSyncOptions {\n /**\n * Starting directory for the search.\n * @default process.cwd()\n */\n cwd?: string | undefined\n /**\n * Directory to stop searching at (inclusive).\n * When provided, search will stop at this directory even if the root hasn't been reached.\n */\n stopAt?: string | undefined\n /**\n * Only match directories, not files.\n * @default false\n */\n onlyDirectories?: boolean | undefined\n /**\n * Only match files, not directories.\n * @default true\n */\n onlyFiles?: boolean | undefined\n}\n\n/**\n * Options for checking if a directory is empty.\n */\nexport interface IsDirEmptyOptions {\n /**\n * Glob patterns for files to ignore when checking emptiness.\n * Files matching these patterns are not counted.\n * @default defaultIgnore\n */\n ignore?: string[] | readonly string[] | undefined\n}\n\n/**\n * Options for read operations with abort support.\n */\nexport interface ReadOptions extends Abortable {\n /**\n * Character encoding to use for reading.\n * @default 'utf8'\n */\n encoding?: BufferEncoding | string | undefined\n /**\n * File system flag for reading behavior.\n * @default 'r'\n */\n flag?: string | undefined\n}\n\n/**\n * Options for reading directories with filtering and sorting.\n */\nexport interface ReadDirOptions {\n /**\n * Glob patterns for directories to ignore.\n * @default undefined\n */\n ignore?: string[] | readonly string[] | undefined\n /**\n * Include empty directories in results.\n * When `false`, empty directories are filtered out.\n * @default true\n */\n includeEmpty?: boolean | undefined\n /**\n * Sort directory names alphabetically using natural sort order.\n * @default true\n */\n sort?: boolean | undefined\n}\n\n/**\n * Options for reading files with encoding and abort support.\n * Can be either an options object, an encoding string, or null.\n */\nexport type ReadFileOptions =\n | Remap<\n ObjectEncodingOptions &\n Abortable & {\n flag?: OpenMode | undefined\n }\n >\n | BufferEncoding\n | null\n\n/**\n * Options for reading and parsing JSON files.\n */\nexport type ReadJsonOptions = Remap<\n ReadFileOptions & {\n /**\n * Whether to throw errors on parse failure.\n * When `false`, returns `undefined` on error instead of throwing.\n * @default true\n */\n throws?: boolean | undefined\n /**\n * JSON reviver function to transform parsed values.\n * Same as the second parameter to `JSON.parse()`.\n */\n reviver?: Parameters<typeof JSON.parse>[1] | undefined\n }\n>\n\n/**\n * Options for file/directory removal operations.\n */\nexport interface RemoveOptions {\n /**\n * Force deletion even outside normally safe directories.\n * When `false`, prevents deletion outside temp, cacache, and ~/.socket.\n * @default true for safe directories, false otherwise\n */\n force?: boolean | undefined\n /**\n * Maximum number of retry attempts on failure.\n * @default 3\n */\n maxRetries?: number | undefined\n /**\n * Recursively delete directories and contents.\n * @default true\n */\n recursive?: boolean | undefined\n /**\n * Delay in milliseconds between retry attempts.\n * @default 200\n */\n retryDelay?: number | undefined\n /**\n * Abort signal to cancel the operation.\n */\n signal?: AbortSignal | undefined\n}\n\n/**\n * Options for safe read operations that don't throw on errors.\n */\nexport interface SafeReadOptions extends ReadOptions {\n /**\n * Default value to return on read failure.\n * If not provided, `undefined` is returned on error.\n */\n defaultValue?: unknown | undefined\n}\n\n/**\n * Options for write operations with encoding and mode control.\n */\nexport interface WriteOptions extends Abortable {\n /**\n * Character encoding for writing.\n * @default 'utf8'\n */\n encoding?: BufferEncoding | string | undefined\n /**\n * File mode (permissions) to set.\n * Uses standard Unix permission bits (e.g., 0o644).\n * @default 0o666 (read/write for all, respecting umask)\n */\n mode?: number | undefined\n /**\n * File system flag for write behavior.\n * @default 'w' (create or truncate)\n */\n flag?: string | undefined\n}\n\n/**\n * Options for writing JSON files with formatting control.\n */\nexport interface WriteJsonOptions extends WriteOptions {\n /**\n * End-of-line sequence to use.\n * @default '\\n'\n * @example\n * ```ts\n * // Windows-style line endings\n * writeJson('data.json', data, { EOL: '\\r\\n' })\n * ```\n */\n EOL?: string | undefined\n /**\n * Whether to add a final newline at end of file.\n * @default true\n */\n finalEOL?: boolean | undefined\n /**\n * JSON replacer function to transform values during stringification.\n * Same as the second parameter to `JSON.stringify()`.\n */\n replacer?: JsonReviver | undefined\n /**\n * Number of spaces for indentation, or string to use for indentation.\n * @default 2\n * @example\n * ```ts\n * // Use tabs instead of spaces\n * writeJson('data.json', data, { spaces: '\\t' })\n *\n * // Use 4 spaces for indentation\n * writeJson('data.json', data, { spaces: 4 })\n * ```\n */\n spaces?: number | string | undefined\n}\n\nconst defaultRemoveOptions = objectFreeze({\n __proto__: null,\n force: true,\n maxRetries: 3,\n recursive: true,\n retryDelay: 200,\n})\n\nlet _fs: typeof import('fs') | undefined\n/**\n * Lazily load the fs module to avoid Webpack errors.\n * Uses non-'node:' prefixed require to prevent Webpack bundling issues.\n *\n * @returns The Node.js fs module\n * @private\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction getFs() {\n if (_fs === undefined) {\n // Use non-'node:' prefixed require to avoid Webpack errors.\n\n _fs = /*@__PURE__*/ require('node:fs')\n }\n return _fs as typeof import('fs')\n}\n\nlet _path: typeof import('path') | undefined\n/**\n * Lazily load the path module to avoid Webpack errors.\n * Uses non-'node:' prefixed require to prevent Webpack bundling issues.\n *\n * @returns The Node.js path module\n * @private\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction getPath() {\n if (_path === undefined) {\n // Use non-'node:' prefixed require to avoid Webpack errors.\n\n _path = /*@__PURE__*/ require('node:path')\n }\n return _path as typeof import('path')\n}\n\n/**\n * Process directory entries and filter for directories.\n * Filters entries to include only directories, optionally excluding empty ones.\n * Applies ignore patterns and natural sorting.\n *\n * @param dirents - Directory entries from readdir\n * @param dirname - Parent directory path\n * @param options - Filtering and sorting options\n * @returns Array of directory names, optionally sorted\n * @private\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction innerReadDirNames(\n dirents: Dirent[],\n dirname: string | undefined,\n options?: ReadDirOptions | undefined,\n): string[] {\n const {\n ignore,\n includeEmpty = true,\n sort = true,\n } = { __proto__: null, ...options } as ReadDirOptions\n const path = getPath()\n const names = dirents\n .filter(\n (d: Dirent) =>\n d.isDirectory() &&\n (includeEmpty ||\n !isDirEmptySync(path.join(dirname || d.parentPath, d.name), {\n ignore,\n })),\n )\n .map((d: Dirent) => d.name)\n return sort ? names.sort(naturalCompare) : names\n}\n\n/**\n * Stringify JSON with custom formatting options.\n * Formats JSON with configurable line endings and indentation.\n *\n * @param json - Value to stringify\n * @param EOL - End-of-line sequence\n * @param finalEOL - Whether to add final newline\n * @param replacer - JSON replacer function\n * @param spaces - Indentation spaces or string\n * @returns Formatted JSON string\n * @private\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction stringify(\n json: unknown,\n EOL: string,\n finalEOL: boolean,\n replacer: JsonReviver | undefined,\n spaces: number | string = 2,\n): string {\n const EOF = finalEOL ? EOL : ''\n const str = JSON.stringify(json, replacer, spaces)\n return `${str.replace(/\\n/g, EOL)}${EOF}`\n}\n\n/**\n * Find a file or directory by traversing up parent directories.\n * Searches from the starting directory upward to the filesystem root.\n * Useful for finding configuration files or project roots.\n *\n * @param name - Filename(s) to search for\n * @param options - Search options including cwd and type filters\n * @returns Normalized absolute path if found, undefined otherwise\n *\n * @example\n * ```ts\n * // Find package.json starting from current directory\n * const pkgPath = await findUp('package.json')\n *\n * // Find any of multiple config files\n * const configPath = await findUp(['.config.js', '.config.json'])\n *\n * // Find a directory instead of file\n * const nodeModules = await findUp('node_modules', { onlyDirectories: true })\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport async function findUp(\n name: string | string[] | readonly string[],\n options?: FindUpOptions | undefined,\n): Promise<string | undefined> {\n const { cwd = process.cwd(), signal = abortSignal } = {\n __proto__: null,\n ...options,\n } as FindUpOptions\n let { onlyDirectories = false, onlyFiles = true } = {\n __proto__: null,\n ...options,\n } as FindUpOptions\n if (onlyDirectories) {\n onlyFiles = false\n }\n if (onlyFiles) {\n onlyDirectories = false\n }\n const fs = getFs()\n const path = getPath()\n let dir = path.resolve(cwd)\n const { root } = path.parse(dir)\n const names = isArray(name) ? name : [name as string]\n while (dir && dir !== root) {\n for (const n of names) {\n if (signal?.aborted) {\n return undefined\n }\n const thePath = path.join(dir, n)\n try {\n // eslint-disable-next-line no-await-in-loop\n const stats = await fs.promises.stat(thePath)\n if (!onlyDirectories && stats.isFile()) {\n return normalizePath(thePath)\n }\n if (!onlyFiles && stats.isDirectory()) {\n return normalizePath(thePath)\n }\n } catch {}\n }\n dir = path.dirname(dir)\n }\n return undefined\n}\n\n/**\n * Synchronously find a file or directory by traversing up parent directories.\n * Searches from the starting directory upward to the filesystem root or `stopAt` directory.\n * Useful for finding configuration files or project roots in synchronous contexts.\n *\n * @param name - Filename(s) to search for\n * @param options - Search options including cwd, stopAt, and type filters\n * @returns Normalized absolute path if found, undefined otherwise\n *\n * @example\n * ```ts\n * // Find package.json starting from current directory\n * const pkgPath = findUpSync('package.json')\n *\n * // Find .git directory but stop at home directory\n * const gitPath = findUpSync('.git', {\n * onlyDirectories: true,\n * stopAt: process.env.HOME\n * })\n *\n * // Find any of multiple config files\n * const configPath = findUpSync(['.eslintrc.js', '.eslintrc.json'])\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function findUpSync(\n name: string | string[] | readonly string[],\n options?: FindUpSyncOptions | undefined,\n) {\n const { cwd = process.cwd(), stopAt } = {\n __proto__: null,\n ...options,\n } as FindUpSyncOptions\n let { onlyDirectories = false, onlyFiles = true } = {\n __proto__: null,\n ...options,\n } as FindUpSyncOptions\n if (onlyDirectories) {\n onlyFiles = false\n }\n if (onlyFiles) {\n onlyDirectories = false\n }\n const fs = getFs()\n const path = getPath()\n let dir = path.resolve(cwd)\n const { root } = path.parse(dir)\n const stopDir = stopAt ? path.resolve(stopAt) : undefined\n const names = isArray(name) ? name : [name as string]\n while (dir && dir !== root) {\n // Check if we should stop at this directory.\n if (stopDir && dir === stopDir) {\n // Check current directory but don't go up.\n for (const n of names) {\n const thePath = path.join(dir, n)\n try {\n const stats = fs.statSync(thePath)\n if (!onlyDirectories && stats.isFile()) {\n return normalizePath(thePath)\n }\n if (!onlyFiles && stats.isDirectory()) {\n return normalizePath(thePath)\n }\n } catch {}\n }\n return undefined\n }\n for (const n of names) {\n const thePath = path.join(dir, n)\n try {\n const stats = fs.statSync(thePath)\n if (!onlyDirectories && stats.isFile()) {\n return normalizePath(thePath)\n }\n if (!onlyFiles && stats.isDirectory()) {\n return normalizePath(thePath)\n }\n } catch {}\n }\n dir = path.dirname(dir)\n }\n return undefined\n}\n\n/**\n * Check if a path is a directory asynchronously.\n * Returns `true` for directories, `false` for files or non-existent paths.\n *\n * @param filepath - Path to check\n * @returns `true` if path is a directory, `false` otherwise\n *\n * @example\n * ```ts\n * if (await isDir('./src')) {\n * console.log('src is a directory')\n * }\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport async function isDir(filepath: PathLike) {\n return !!(await safeStats(filepath))?.isDirectory()\n}\n\n/**\n * Check if a path is a directory synchronously.\n * Returns `true` for directories, `false` for files or non-existent paths.\n *\n * @param filepath - Path to check\n * @returns `true` if path is a directory, `false` otherwise\n *\n * @example\n * ```ts\n * if (isDirSync('./src')) {\n * console.log('src is a directory')\n * }\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function isDirSync(filepath: PathLike) {\n return !!safeStatsSync(filepath)?.isDirectory()\n}\n\n/**\n * Check if a directory is empty synchronously.\n * A directory is considered empty if it contains no files after applying ignore patterns.\n * Uses glob patterns to filter ignored files.\n *\n * @param dirname - Directory path to check\n * @param options - Options including ignore patterns\n * @returns `true` if directory is empty (or doesn't exist), `false` otherwise\n *\n * @example\n * ```ts\n * // Check if directory is completely empty\n * isDirEmptySync('./build')\n *\n * // Check if directory is empty, ignoring .DS_Store files\n * isDirEmptySync('./cache', { ignore: ['.DS_Store'] })\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function isDirEmptySync(\n dirname: PathLike,\n options?: IsDirEmptyOptions | undefined,\n) {\n const { ignore = defaultIgnore } = {\n __proto__: null,\n ...options,\n } as IsDirEmptyOptions\n const fs = getFs()\n try {\n const files = fs.readdirSync(dirname)\n const { length } = files\n if (length === 0) {\n return true\n }\n const matcher = getGlobMatcher(\n ignore as string[],\n {\n cwd: pathLikeToString(dirname),\n } as { cwd?: string; dot?: boolean; ignore?: string[]; nocase?: boolean },\n )\n let ignoredCount = 0\n for (let i = 0; i < length; i += 1) {\n const file = files[i]\n if (file && matcher(file)) {\n ignoredCount += 1\n }\n }\n return ignoredCount === length\n } catch {\n // Return false for non-existent paths or other errors.\n return false\n }\n}\n\n/**\n * Check if a path is a symbolic link synchronously.\n * Uses `lstat` to check the link itself, not the target.\n *\n * @param filepath - Path to check\n * @returns `true` if path is a symbolic link, `false` otherwise\n *\n * @example\n * ```ts\n * if (isSymLinkSync('./my-link')) {\n * console.log('Path is a symbolic link')\n * }\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function isSymLinkSync(filepath: PathLike) {\n const fs = getFs()\n try {\n return fs.lstatSync(filepath).isSymbolicLink()\n } catch {}\n return false\n}\n\n/**\n * Result of file readability validation.\n * Contains lists of valid and invalid file paths.\n */\nexport interface ValidateFilesResult {\n /**\n * File paths that passed validation and are readable.\n */\n validPaths: string[]\n /**\n * File paths that failed validation (unreadable, permission denied, or non-existent).\n * Common with Yarn Berry PnP virtual filesystem, pnpm symlinks, or filesystem race conditions.\n */\n invalidPaths: string[]\n}\n\n/**\n * Validate that file paths are readable before processing.\n * Filters out files from glob results that cannot be accessed (common with\n * Yarn Berry PnP virtual filesystem, pnpm content-addressable store symlinks,\n * or filesystem race conditions in CI/CD environments).\n *\n * This defensive pattern prevents ENOENT errors when files exist in glob\n * results but are not accessible via standard filesystem operations.\n *\n * @param filepaths - Array of file paths to validate\n * @returns Object with `validPaths` (readable) and `invalidPaths` (unreadable)\n *\n * @example\n * ```ts\n * import { validateFiles } from '@socketsecurity/lib/fs'\n *\n * const files = ['package.json', '.pnp.cjs/virtual-file.json']\n * const { validPaths, invalidPaths } = validateFiles(files)\n *\n * console.log(`Valid: ${validPaths.length}`)\n * console.log(`Invalid: ${invalidPaths.length}`)\n * ```\n *\n * @example\n * ```ts\n * // Typical usage in Socket CLI commands\n * const packagePaths = await getPackageFilesForScan(targets)\n * const { validPaths } = validateFiles(packagePaths)\n * await sdk.uploadManifestFiles(orgSlug, validPaths)\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function validateFiles(\n filepaths: string[] | readonly string[],\n): ValidateFilesResult {\n const fs = getFs()\n const validPaths: string[] = []\n const invalidPaths: string[] = []\n const { R_OK } = fs.constants\n\n for (const filepath of filepaths) {\n try {\n fs.accessSync(filepath, R_OK)\n validPaths.push(filepath)\n } catch {\n invalidPaths.push(filepath)\n }\n }\n\n return { __proto__: null, validPaths, invalidPaths } as ValidateFilesResult\n}\n\n/**\n * Read directory names asynchronously with filtering and sorting.\n * Returns only directory names (not files), with optional filtering for empty directories\n * and glob-based ignore patterns. Results are naturally sorted by default.\n *\n * @param dirname - Directory path to read\n * @param options - Options for filtering and sorting\n * @returns Array of directory names, empty array on error\n *\n * @example\n * ```ts\n * // Get all subdirectories, sorted naturally\n * const dirs = await readDirNames('./packages')\n *\n * // Get non-empty directories only\n * const nonEmpty = await readDirNames('./cache', { includeEmpty: false })\n *\n * // Get directories without sorting\n * const unsorted = await readDirNames('./src', { sort: false })\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport async function readDirNames(\n dirname: PathLike,\n options?: ReadDirOptions | undefined,\n) {\n const fs = getFs()\n try {\n return innerReadDirNames(\n await fs.promises.readdir(dirname, {\n __proto__: null,\n encoding: 'utf8',\n withFileTypes: true,\n } as ObjectEncodingOptions & { withFileTypes: true }),\n String(dirname),\n options,\n )\n } catch {}\n return []\n}\n\n/**\n * Read directory names synchronously with filtering and sorting.\n * Returns only directory names (not files), with optional filtering for empty directories\n * and glob-based ignore patterns. Results are naturally sorted by default.\n *\n * @param dirname - Directory path to read\n * @param options - Options for filtering and sorting\n * @returns Array of directory names, empty array on error\n *\n * @example\n * ```ts\n * // Get all subdirectories, sorted naturally\n * const dirs = readDirNamesSync('./packages')\n *\n * // Get non-empty directories only, ignoring node_modules\n * const nonEmpty = readDirNamesSync('./src', {\n * includeEmpty: false,\n * ignore: ['node_modules']\n * })\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function readDirNamesSync(dirname: PathLike, options?: ReadDirOptions) {\n const fs = getFs()\n try {\n return innerReadDirNames(\n fs.readdirSync(dirname, {\n __proto__: null,\n encoding: 'utf8',\n withFileTypes: true,\n } as ObjectEncodingOptions & { withFileTypes: true }),\n String(dirname),\n options,\n )\n } catch {}\n return []\n}\n\n/**\n * Read a file as binary data asynchronously.\n * Returns a Buffer without encoding the contents.\n * Useful for reading images, archives, or other binary formats.\n *\n * @param filepath - Path to file\n * @param options - Read options (encoding is forced to null for binary)\n * @returns Promise resolving to Buffer containing file contents\n *\n * @example\n * ```ts\n * // Read an image file\n * const imageBuffer = await readFileBinary('./image.png')\n *\n * // Read with abort signal\n * const buffer = await readFileBinary('./data.bin', { signal: abortSignal })\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport async function readFileBinary(\n filepath: PathLike,\n options?: ReadFileOptions | undefined,\n) {\n // Don't specify encoding to get a Buffer.\n const opts = typeof options === 'string' ? { encoding: options } : options\n const fs = getFs()\n return await fs.promises.readFile(filepath, {\n signal: abortSignal,\n ...opts,\n encoding: null,\n })\n}\n\n/**\n * Read a file as UTF-8 text asynchronously.\n * Returns a string with the file contents decoded as UTF-8.\n * This is the most common way to read text files.\n *\n * @param filepath - Path to file\n * @param options - Read options including encoding and abort signal\n * @returns Promise resolving to string containing file contents\n *\n * @example\n * ```ts\n * // Read a text file\n * const content = await readFileUtf8('./README.md')\n *\n * // Read with custom encoding\n * const content = await readFileUtf8('./data.txt', { encoding: 'utf-8' })\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport async function readFileUtf8(\n filepath: PathLike,\n options?: ReadFileOptions | undefined,\n) {\n const opts = typeof options === 'string' ? { encoding: options } : options\n const fs = getFs()\n return await fs.promises.readFile(filepath, {\n signal: abortSignal,\n ...opts,\n encoding: 'utf8',\n })\n}\n\n/**\n * Read a file as binary data synchronously.\n * Returns a Buffer without encoding the contents.\n * Useful for reading images, archives, or other binary formats.\n *\n * @param filepath - Path to file\n * @param options - Read options (encoding is forced to null for binary)\n * @returns Buffer containing file contents\n *\n * @example\n * ```ts\n * // Read an image file\n * const imageBuffer = readFileBinarySync('./logo.png')\n *\n * // Read a compressed file\n * const gzipData = readFileBinarySync('./archive.gz')\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function readFileBinarySync(\n filepath: PathLike,\n options?: ReadFileOptions | undefined,\n) {\n // Don't specify encoding to get a Buffer\n const opts = typeof options === 'string' ? { encoding: options } : options\n const fs = getFs()\n return fs.readFileSync(filepath, {\n ...opts,\n encoding: null,\n } as ObjectEncodingOptions)\n}\n\n/**\n * Read a file as UTF-8 text synchronously.\n * Returns a string with the file contents decoded as UTF-8.\n * This is the most common way to read text files synchronously.\n *\n * @param filepath - Path to file\n * @param options - Read options including encoding\n * @returns String containing file contents\n *\n * @example\n * ```ts\n * // Read a configuration file\n * const config = readFileUtf8Sync('./config.txt')\n *\n * // Read with custom options\n * const data = readFileUtf8Sync('./data.txt', { encoding: 'utf8' })\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function readFileUtf8Sync(\n filepath: PathLike,\n options?: ReadFileOptions | undefined,\n) {\n const opts = typeof options === 'string' ? { encoding: options } : options\n const fs = getFs()\n return fs.readFileSync(filepath, {\n ...opts,\n encoding: 'utf8',\n } as ObjectEncodingOptions)\n}\n\n/**\n * Read and parse a JSON file asynchronously.\n * Reads the file as UTF-8 text and parses it as JSON.\n * Optionally accepts a reviver function to transform parsed values.\n *\n * @param filepath - Path to JSON file\n * @param options - Read and parse options\n * @returns Promise resolving to parsed JSON value, or undefined if throws is false and an error occurs\n *\n * @example\n * ```ts\n * // Read and parse package.json\n * const pkg = await readJson('./package.json')\n *\n * // Read JSON with custom reviver\n * const data = await readJson('./data.json', {\n * reviver: (key, value) => {\n * if (key === 'date') return new Date(value)\n * return value\n * }\n * })\n *\n * // Don't throw on parse errors\n * const config = await readJson('./config.json', { throws: false })\n * if (config === undefined) {\n * console.log('Failed to parse config')\n * }\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport async function readJson(\n filepath: PathLike,\n options?: ReadJsonOptions | string | undefined,\n) {\n const opts = typeof options === 'string' ? { encoding: options } : options\n const { reviver, throws, ...fsOptions } = {\n __proto__: null,\n ...opts,\n } as unknown as ReadJsonOptions\n const shouldThrow = throws === undefined || !!throws\n const fs = getFs()\n let content = ''\n try {\n content = await fs.promises.readFile(filepath, {\n __proto__: null,\n encoding: 'utf8',\n ...fsOptions,\n } as unknown as Parameters<typeof fs.promises.readFile>[1] & {\n encoding: string\n })\n } catch (e) {\n if (shouldThrow) {\n const code = (e as NodeJS.ErrnoException).code\n if (code === 'ENOENT') {\n throw new Error(\n `JSON file not found: ${filepath}\\n` +\n 'Ensure the file exists or create it with the expected structure.',\n { cause: e },\n )\n }\n if (code === 'EACCES' || code === 'EPERM') {\n throw new Error(\n `Permission denied reading JSON file: ${filepath}\\n` +\n 'Check file permissions or run with appropriate access.',\n { cause: e },\n )\n }\n throw e\n }\n return undefined\n }\n return jsonParse(content, {\n filepath: String(filepath),\n reviver,\n throws: shouldThrow,\n })\n}\n\n/**\n * Read and parse a JSON file synchronously.\n * Reads the file as UTF-8 text and parses it as JSON.\n * Optionally accepts a reviver function to transform parsed values.\n *\n * @param filepath - Path to JSON file\n * @param options - Read and parse options\n * @returns Parsed JSON value, or undefined if throws is false and an error occurs\n *\n * @example\n * ```ts\n * // Read and parse tsconfig.json\n * const tsconfig = readJsonSync('./tsconfig.json')\n *\n * // Read JSON with custom reviver\n * const data = readJsonSync('./data.json', {\n * reviver: (key, value) => {\n * if (typeof value === 'string' && /^\\d{4}-\\d{2}-\\d{2}/.test(value)) {\n * return new Date(value)\n * }\n * return value\n * }\n * })\n *\n * // Don't throw on parse errors\n * const config = readJsonSync('./config.json', { throws: false })\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function readJsonSync(\n filepath: PathLike,\n options?: ReadJsonOptions | string | undefined,\n) {\n const opts = typeof options === 'string' ? { encoding: options } : options\n const { reviver, throws, ...fsOptions } = {\n __proto__: null,\n ...opts,\n } as unknown as ReadJsonOptions\n const shouldThrow = throws === undefined || !!throws\n const fs = getFs()\n let content = ''\n try {\n content = fs.readFileSync(filepath, {\n __proto__: null,\n encoding: 'utf8',\n ...fsOptions,\n } as unknown as Parameters<typeof fs.readFileSync>[1] & {\n encoding: string\n })\n } catch (e) {\n if (shouldThrow) {\n const code = (e as NodeJS.ErrnoException).code\n if (code === 'ENOENT') {\n throw new Error(\n `JSON file not found: ${filepath}\\n` +\n 'Ensure the file exists or create it with the expected structure.',\n { cause: e },\n )\n }\n if (code === 'EACCES' || code === 'EPERM') {\n throw new Error(\n `Permission denied reading JSON file: ${filepath}\\n` +\n 'Check file permissions or run with appropriate access.',\n { cause: e },\n )\n }\n throw e\n }\n return undefined\n }\n return jsonParse(content, {\n filepath: String(filepath),\n reviver,\n throws: shouldThrow,\n })\n}\n\n// Cache for resolved allowed directories\nlet _cachedAllowedDirs: string[] | undefined\n\n/**\n * Get resolved allowed directories for safe deletion with lazy caching.\n * These directories are resolved once and cached for the process lifetime.\n */\nfunction getAllowedDirectories(): string[] {\n if (_cachedAllowedDirs === undefined) {\n const path = getPath()\n const {\n getOsTmpDir,\n getSocketCacacheDir,\n getSocketUserDir,\n } = /*@__PURE__*/ require('#lib/paths')\n\n _cachedAllowedDirs = [\n path.resolve(getOsTmpDir()),\n path.resolve(getSocketCacacheDir()),\n path.resolve(getSocketUserDir()),\n ]\n }\n return _cachedAllowedDirs\n}\n\n/**\n * Invalidate the cached allowed directories.\n * Called automatically by the paths/rewire module when paths are overridden in tests.\n *\n * @internal Used for test rewiring\n */\nexport function invalidatePathCache(): void {\n _cachedAllowedDirs = undefined\n}\n\n// Register cache invalidation with the rewire module\nregisterCacheInvalidation(invalidatePathCache)\n\n/**\n * Safely delete a file or directory asynchronously with built-in protections.\n * Uses `del` for safer deletion that prevents removing cwd and above by default.\n * Automatically uses force: true for temp directory, cacache, and ~/.socket subdirectories.\n *\n * @param filepath - Path or array of paths to delete (supports glob patterns)\n * @param options - Deletion options including force, retries, and recursion\n * @throws {Error} When attempting to delete protected paths without force option\n *\n * @example\n * ```ts\n * // Delete a single file\n * await safeDelete('./temp-file.txt')\n *\n * // Delete a directory recursively\n * await safeDelete('./build', { recursive: true })\n *\n * // Delete multiple paths\n * await safeDelete(['./dist', './coverage'])\n *\n * // Delete with custom retry settings\n * await safeDelete('./flaky-dir', { maxRetries: 5, retryDelay: 500 })\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport async function safeDelete(\n filepath: PathLike | PathLike[],\n options?: RemoveOptions | undefined,\n) {\n const del = /*@__PURE__*/ require('./external/del')\n const { deleteAsync } = del\n const opts = { __proto__: null, ...options } as RemoveOptions\n const patterns = isArray(filepath)\n ? filepath.map(pathLikeToString)\n : [pathLikeToString(filepath)]\n\n // Check if we're deleting within allowed directories.\n let shouldForce = opts.force !== false\n if (!shouldForce && patterns.length > 0) {\n const path = getPath()\n const allowedDirs = getAllowedDirectories()\n\n // Check if all patterns are within allowed directories.\n const allInAllowedDirs = patterns.every(pattern => {\n const resolvedPath = path.resolve(pattern)\n\n // Check each allowed directory\n for (const allowedDir of allowedDirs) {\n const isInAllowedDir =\n resolvedPath.startsWith(allowedDir + path.sep) ||\n resolvedPath === allowedDir\n const relativePath = path.relative(allowedDir, resolvedPath)\n const isGoingBackward = relativePath.startsWith('..')\n\n if (isInAllowedDir && !isGoingBackward) {\n return true\n }\n }\n\n return false\n })\n\n if (allInAllowedDirs) {\n shouldForce = true\n }\n }\n\n await deleteAsync(patterns, {\n concurrency: opts.maxRetries || defaultRemoveOptions.maxRetries,\n dryRun: false,\n force: shouldForce,\n onlyFiles: false,\n })\n}\n\n/**\n * Safely delete a file or directory synchronously with built-in protections.\n * Uses `del` for safer deletion that prevents removing cwd and above by default.\n * Automatically uses force: true for temp directory, cacache, and ~/.socket subdirectories.\n *\n * @param filepath - Path or array of paths to delete (supports glob patterns)\n * @param options - Deletion options including force, retries, and recursion\n * @throws {Error} When attempting to delete protected paths without force option\n *\n * @example\n * ```ts\n * // Delete a single file\n * safeDeleteSync('./temp-file.txt')\n *\n * // Delete a directory recursively\n * safeDeleteSync('./build', { recursive: true })\n *\n * // Delete multiple paths with globs\n * safeDeleteSync(['./dist/**', './coverage/**'])\n *\n * // Force delete a protected path (use with caution)\n * safeDeleteSync('./important', { force: true })\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function safeDeleteSync(\n filepath: PathLike | PathLike[],\n options?: RemoveOptions | undefined,\n) {\n const del = /*@__PURE__*/ require('./external/del')\n const { deleteSync } = del\n const opts = { __proto__: null, ...options } as RemoveOptions\n const patterns = isArray(filepath)\n ? filepath.map(pathLikeToString)\n : [pathLikeToString(filepath)]\n\n // Check if we're deleting within allowed directories.\n let shouldForce = opts.force !== false\n if (!shouldForce && patterns.length > 0) {\n const path = getPath()\n const allowedDirs = getAllowedDirectories()\n\n // Check if all patterns are within allowed directories.\n const allInAllowedDirs = patterns.every(pattern => {\n const resolvedPath = path.resolve(pattern)\n\n // Check each allowed directory\n for (const allowedDir of allowedDirs) {\n const isInAllowedDir =\n resolvedPath.startsWith(allowedDir + path.sep) ||\n resolvedPath === allowedDir\n const relativePath = path.relative(allowedDir, resolvedPath)\n const isGoingBackward = relativePath.startsWith('..')\n\n if (isInAllowedDir && !isGoingBackward) {\n return true\n }\n }\n\n return false\n })\n\n if (allInAllowedDirs) {\n shouldForce = true\n }\n }\n\n deleteSync(patterns, {\n concurrency: opts.maxRetries || defaultRemoveOptions.maxRetries,\n dryRun: false,\n force: shouldForce,\n onlyFiles: false,\n })\n}\n\n/**\n * Safely read a file asynchronously, returning undefined on error.\n * Useful when you want to attempt reading a file without handling errors explicitly.\n * Returns undefined for any error (file not found, permission denied, etc.).\n *\n * @param filepath - Path to file\n * @param options - Read options including encoding and default value\n * @returns Promise resolving to file contents, or undefined on error\n *\n * @example\n * ```ts\n * // Try to read a file, get undefined if it doesn't exist\n * const content = await safeReadFile('./optional-config.txt')\n * if (content) {\n * console.log('Config found:', content)\n * }\n *\n * // Read with specific encoding\n * const data = await safeReadFile('./data.txt', { encoding: 'utf8' })\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport async function safeReadFile(\n filepath: PathLike,\n options?: SafeReadOptions | undefined,\n) {\n const opts = typeof options === 'string' ? { encoding: options } : options\n const fs = getFs()\n try {\n return await fs.promises.readFile(filepath, {\n signal: abortSignal,\n ...opts,\n } as Abortable)\n } catch {}\n return undefined\n}\n\n/**\n * Safely get file stats asynchronously, returning undefined on error.\n * Useful for checking file existence and properties without error handling.\n * Returns undefined for any error (file not found, permission denied, etc.).\n *\n * @param filepath - Path to check\n * @returns Promise resolving to Stats object, or undefined on error\n *\n * @example\n * ```ts\n * // Check if file exists and get its stats\n * const stats = await safeStats('./file.txt')\n * if (stats) {\n * console.log('File size:', stats.size)\n * console.log('Modified:', stats.mtime)\n * }\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport async function safeStats(filepath: PathLike) {\n const fs = getFs()\n try {\n return await fs.promises.stat(filepath)\n } catch {}\n return undefined\n}\n\n/**\n * Safely get file stats synchronously, returning undefined on error.\n * Useful for checking file existence and properties without error handling.\n * Returns undefined for any error (file not found, permission denied, etc.).\n *\n * @param filepath - Path to check\n * @param options - Read options (currently unused but kept for API consistency)\n * @returns Stats object, or undefined on error\n *\n * @example\n * ```ts\n * // Check if file exists and get its size\n * const stats = safeStatsSync('./file.txt')\n * if (stats) {\n * console.log('File size:', stats.size)\n * console.log('Is directory:', stats.isDirectory())\n * }\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function safeStatsSync(\n filepath: PathLike,\n options?: ReadFileOptions | undefined,\n) {\n const opts = typeof options === 'string' ? { encoding: options } : options\n const fs = getFs()\n try {\n return fs.statSync(filepath, {\n __proto__: null,\n throwIfNoEntry: false,\n ...opts,\n } as StatSyncOptions)\n } catch {}\n return undefined\n}\n\n/**\n * Safely read a file synchronously, returning undefined on error.\n * Useful when you want to attempt reading a file without handling errors explicitly.\n * Returns undefined for any error (file not found, permission denied, etc.).\n *\n * @param filepath - Path to file\n * @param options - Read options including encoding and default value\n * @returns File contents, or undefined on error\n *\n * @example\n * ```ts\n * // Try to read a config file\n * const config = safeReadFileSync('./config.txt')\n * if (config) {\n * console.log('Config loaded successfully')\n * }\n *\n * // Read binary file safely\n * const buffer = safeReadFileSync('./image.png', { encoding: null })\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function safeReadFileSync(\n filepath: PathLike,\n options?: SafeReadOptions | undefined,\n) {\n const opts = typeof options === 'string' ? { encoding: options } : options\n const fs = getFs()\n try {\n return fs.readFileSync(filepath, {\n __proto__: null,\n ...opts,\n } as ObjectEncodingOptions)\n } catch {}\n return undefined\n}\n\n/**\n * Generate a unique filepath by adding number suffix if the path exists.\n * Appends `-1`, `-2`, etc. before the file extension until a non-existent path is found.\n * Useful for creating files without overwriting existing ones.\n *\n * @param filepath - Desired file path\n * @returns Normalized unique filepath (original if it doesn't exist, or with number suffix)\n *\n * @example\n * ```ts\n * // If 'report.pdf' exists, returns 'report-1.pdf'\n * const uniquePath = uniqueSync('./report.pdf')\n *\n * // If 'data.json' and 'data-1.json' exist, returns 'data-2.json'\n * const path = uniqueSync('./data.json')\n *\n * // If 'backup' doesn't exist, returns 'backup' unchanged\n * const backupPath = uniqueSync('./backup')\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function uniqueSync(filepath: PathLike): string {\n const fs = getFs()\n const path = getPath()\n const filepathStr = String(filepath)\n\n // If the file doesn't exist, return as is\n if (!fs.existsSync(filepathStr)) {\n return normalizePath(filepathStr)\n }\n\n const dirname = path.dirname(filepathStr)\n const ext = path.extname(filepathStr)\n const basename = path.basename(filepathStr, ext)\n\n let counter = 1\n let uniquePath: string\n do {\n uniquePath = path.join(dirname, `${basename}-${counter}${ext}`)\n counter++\n } while (fs.existsSync(uniquePath))\n\n return normalizePath(uniquePath)\n}\n\n/**\n * Write JSON content to a file asynchronously with formatting.\n * Stringifies the value with configurable indentation and line endings.\n * Automatically adds a final newline by default for POSIX compliance.\n *\n * @param filepath - Path to write to\n * @param jsonContent - Value to stringify and write\n * @param options - Write options including formatting and encoding\n * @returns Promise that resolves when write completes\n *\n * @example\n * ```ts\n * // Write formatted JSON with default 2-space indentation\n * await writeJson('./data.json', { name: 'example', version: '1.0.0' })\n *\n * // Write with custom indentation\n * await writeJson('./config.json', config, { spaces: 4 })\n *\n * // Write with tabs instead of spaces\n * await writeJson('./data.json', data, { spaces: '\\t' })\n *\n * // Write without final newline\n * await writeJson('./inline.json', obj, { finalEOL: false })\n *\n * // Write with Windows line endings\n * await writeJson('./win.json', data, { EOL: '\\r\\n' })\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport async function writeJson(\n filepath: PathLike,\n jsonContent: unknown,\n options?: WriteJsonOptions | string,\n): Promise<void> {\n const opts = typeof options === 'string' ? { encoding: options } : options\n const { EOL, finalEOL, replacer, spaces, ...fsOptions } = {\n __proto__: null,\n ...opts,\n } as WriteJsonOptions\n const fs = getFs()\n const jsonString = stringify(\n jsonContent,\n EOL || '\\n',\n finalEOL !== undefined ? finalEOL : true,\n replacer,\n spaces,\n )\n await fs.promises.writeFile(filepath, jsonString, {\n encoding: 'utf8',\n ...fsOptions,\n __proto__: null,\n } as ObjectEncodingOptions)\n}\n\n/**\n * Write JSON content to a file synchronously with formatting.\n * Stringifies the value with configurable indentation and line endings.\n * Automatically adds a final newline by default for POSIX compliance.\n *\n * @param filepath - Path to write to\n * @param jsonContent - Value to stringify and write\n * @param options - Write options including formatting and encoding\n *\n * @example\n * ```ts\n * // Write formatted JSON with default 2-space indentation\n * writeJsonSync('./package.json', pkg)\n *\n * // Write with custom indentation\n * writeJsonSync('./tsconfig.json', tsconfig, { spaces: 4 })\n *\n * // Write with tabs for indentation\n * writeJsonSync('./data.json', data, { spaces: '\\t' })\n *\n * // Write compacted (no indentation)\n * writeJsonSync('./compact.json', data, { spaces: 0 })\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function writeJsonSync(\n filepath: PathLike,\n jsonContent: unknown,\n options?: WriteJsonOptions | string | undefined,\n): void {\n const opts = typeof options === 'string' ? { encoding: options } : options\n const { EOL, finalEOL, replacer, spaces, ...fsOptions } = {\n __proto__: null,\n ...opts,\n }\n const fs = getFs()\n const jsonString = stringify(\n jsonContent,\n EOL || '\\n',\n finalEOL !== undefined ? finalEOL : true,\n replacer,\n spaces,\n )\n fs.writeFileSync(filepath, jsonString, {\n encoding: 'utf8',\n ...fsOptions,\n __proto__: null,\n } as WriteFileOptions)\n}\n"],
5
- "mappings": ";4ZAAA,IAAAA,GAAA,GAAAC,EAAAD,GAAA,YAAAE,EAAA,eAAAC,EAAA,wBAAAC,EAAA,UAAAC,EAAA,mBAAAC,EAAA,cAAAC,EAAA,kBAAAC,EAAA,iBAAAC,EAAA,qBAAA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,OACV,GAAG3B,EACH,UAAW,IACb,CAA0B,CAC5B,CA2BO,SAAS5D,GACd8C,EACAwC,EACAnE,EACM,CACN,MAAMsC,EAAO,OAAOtC,GAAY,SAAW,CAAE,SAAUA,CAAQ,EAAIA,EAC7D,CAAE,IAAAS,EAAK,SAAAC,EAAU,SAAAC,EAAU,OAAAC,EAAQ,GAAG6B,CAAU,EAAI,CACxD,UAAW,KACX,GAAGH,CACL,EACMnB,EAAKzB,EAAM,EACX0E,EAAa7D,EACjB4D,EACA1D,GAAO;AAAA,EACPC,IAAa,OAAYA,EAAW,GACpCC,EACAC,CACF,EACAO,EAAG,cAAcQ,EAAUyC,EAAY,CACrC,SAAU,OACV,GAAG3B,EACH,UAAW,IACb,CAAqB,CACvB",
6
- "names": ["fs_exports", "__export", "findUp", "findUpSync", "invalidatePathCache", "isDir", "isDirEmptySync", "isDirSync", "isSymLinkSync", "readDirNames", "readDirNamesSync", "readFileBinary", "readFileBinarySync", "readFileUtf8", "readFileUtf8Sync", "readJson", "readJsonSync", "safeDelete", "safeDeleteSync", "safeReadFile", "safeReadFileSync", "safeStats", "safeStatsSync", "uniqueSync", "validateFiles", "writeJson", "writeJsonSync", "__toCommonJS", "import_process", "import_arrays", "import_globs", "import_json", "import_objects", "import_path", "import_rewire", "import_sorts", "abortSignal", "defaultRemoveOptions", "_fs", "getFs", "_path", "getPath", "innerReadDirNames", "dirents", "dirname", "options", "ignore", "includeEmpty", "sort", "path", "names", "d", "stringify", "json", "EOL", "finalEOL", "replacer", "spaces", "EOF", "name", "cwd", "signal", "onlyDirectories", "onlyFiles", "fs", "dir", "root", "n", "thePath", "stats", "stopAt", "stopDir", "filepath", "files", "length", "matcher", "ignoredCount", "i", "file", "filepaths", "validPaths", "invalidPaths", "R_OK", "opts", "reviver", "throws", "fsOptions", "shouldThrow", "content", "e", "code", "_cachedAllowedDirs", "getAllowedDirectories", "getOsTmpDir", "getSocketCacacheDir", "getSocketUserDir", "del", "deleteAsync", "patterns", "shouldForce", "allowedDirs", "pattern", "resolvedPath", "allowedDir", "isInAllowedDir", "isGoingBackward", "deleteSync", "filepathStr", "ext", "basename", "counter", "uniquePath", "jsonContent", "jsonString"]
4
+ "sourcesContent": ["/**\n * @fileoverview File system utilities with cross-platform path handling.\n * Provides enhanced fs operations, glob matching, and directory traversal functions.\n */\n\nimport type { Abortable } from 'events'\n\nimport type {\n Dirent,\n MakeDirectoryOptions,\n ObjectEncodingOptions,\n OpenMode,\n PathLike,\n StatSyncOptions,\n WriteFileOptions,\n} from 'fs'\n\nimport { getAbortSignal } from '#constants/process'\n\nimport { isArray } from './arrays'\n\nconst abortSignal = getAbortSignal()\n\nimport { defaultIgnore, getGlobMatcher } from './globs'\nimport type { JsonReviver } from './json'\nimport { jsonParse } from './json'\nimport { objectFreeze, type Remap } from './objects'\nimport { normalizePath, pathLikeToString } from './path'\nimport { registerCacheInvalidation } from './paths/rewire'\nimport { naturalCompare } from './sorts'\n\n/**\n * Supported text encodings for Node.js Buffers.\n * Includes ASCII, UTF-8/16, base64, binary, and hexadecimal encodings.\n */\nexport type BufferEncoding =\n | 'ascii'\n | 'utf8'\n | 'utf-8'\n | 'utf16le'\n | 'ucs2'\n | 'ucs-2'\n | 'base64'\n | 'base64url'\n | 'latin1'\n | 'binary'\n | 'hex'\n\n/**\n * Represents any valid JSON content type.\n */\nexport type JsonContent = unknown\n\n/**\n * Options for asynchronous `findUp` operations.\n */\nexport interface FindUpOptions {\n /**\n * Starting directory for the search.\n * @default process.cwd()\n */\n cwd?: string | undefined\n /**\n * Only match directories, not files.\n * @default false\n */\n onlyDirectories?: boolean | undefined\n /**\n * Only match files, not directories.\n * @default true\n */\n onlyFiles?: boolean | undefined\n /**\n * Abort signal to cancel the search operation.\n */\n signal?: AbortSignal | undefined\n}\n\n/**\n * Options for synchronous `findUpSync` operations.\n */\nexport interface FindUpSyncOptions {\n /**\n * Starting directory for the search.\n * @default process.cwd()\n */\n cwd?: string | undefined\n /**\n * Directory to stop searching at (inclusive).\n * When provided, search will stop at this directory even if the root hasn't been reached.\n */\n stopAt?: string | undefined\n /**\n * Only match directories, not files.\n * @default false\n */\n onlyDirectories?: boolean | undefined\n /**\n * Only match files, not directories.\n * @default true\n */\n onlyFiles?: boolean | undefined\n}\n\n/**\n * Options for checking if a directory is empty.\n */\nexport interface IsDirEmptyOptions {\n /**\n * Glob patterns for files to ignore when checking emptiness.\n * Files matching these patterns are not counted.\n * @default defaultIgnore\n */\n ignore?: string[] | readonly string[] | undefined\n}\n\n/**\n * Options for read operations with abort support.\n */\nexport interface ReadOptions extends Abortable {\n /**\n * Character encoding to use for reading.\n * @default 'utf8'\n */\n encoding?: BufferEncoding | string | undefined\n /**\n * File system flag for reading behavior.\n * @default 'r'\n */\n flag?: string | undefined\n}\n\n/**\n * Options for reading directories with filtering and sorting.\n */\nexport interface ReadDirOptions {\n /**\n * Glob patterns for directories to ignore.\n * @default undefined\n */\n ignore?: string[] | readonly string[] | undefined\n /**\n * Include empty directories in results.\n * When `false`, empty directories are filtered out.\n * @default true\n */\n includeEmpty?: boolean | undefined\n /**\n * Sort directory names alphabetically using natural sort order.\n * @default true\n */\n sort?: boolean | undefined\n}\n\n/**\n * Options for reading files with encoding and abort support.\n * Can be either an options object, an encoding string, or null.\n */\nexport type ReadFileOptions =\n | Remap<\n ObjectEncodingOptions &\n Abortable & {\n flag?: OpenMode | undefined\n }\n >\n | BufferEncoding\n | null\n\n/**\n * Options for reading and parsing JSON files.\n */\nexport type ReadJsonOptions = Remap<\n ReadFileOptions & {\n /**\n * Whether to throw errors on parse failure.\n * When `false`, returns `undefined` on error instead of throwing.\n * @default true\n */\n throws?: boolean | undefined\n /**\n * JSON reviver function to transform parsed values.\n * Same as the second parameter to `JSON.parse()`.\n */\n reviver?: Parameters<typeof JSON.parse>[1] | undefined\n }\n>\n\n/**\n * Options for file/directory removal operations.\n */\nexport interface RemoveOptions {\n /**\n * Force deletion even outside normally safe directories.\n * When `false`, prevents deletion outside temp, cacache, and ~/.socket.\n * @default true for safe directories, false otherwise\n */\n force?: boolean | undefined\n /**\n * Maximum number of retry attempts on failure.\n * @default 3\n */\n maxRetries?: number | undefined\n /**\n * Recursively delete directories and contents.\n * @default true\n */\n recursive?: boolean | undefined\n /**\n * Delay in milliseconds between retry attempts.\n * @default 200\n */\n retryDelay?: number | undefined\n /**\n * Abort signal to cancel the operation.\n */\n signal?: AbortSignal | undefined\n}\n\n/**\n * Options for safe read operations that don't throw on errors.\n */\nexport interface SafeReadOptions extends ReadOptions {\n /**\n * Default value to return on read failure.\n * If not provided, `undefined` is returned on error.\n */\n defaultValue?: unknown | undefined\n}\n\n/**\n * Options for write operations with encoding and mode control.\n */\nexport interface WriteOptions extends Abortable {\n /**\n * Character encoding for writing.\n * @default 'utf8'\n */\n encoding?: BufferEncoding | string | undefined\n /**\n * File mode (permissions) to set.\n * Uses standard Unix permission bits (e.g., 0o644).\n * @default 0o666 (read/write for all, respecting umask)\n */\n mode?: number | undefined\n /**\n * File system flag for write behavior.\n * @default 'w' (create or truncate)\n */\n flag?: string | undefined\n}\n\n/**\n * Options for writing JSON files with formatting control.\n */\nexport interface WriteJsonOptions extends WriteOptions {\n /**\n * End-of-line sequence to use.\n * @default '\\n'\n * @example\n * ```ts\n * // Windows-style line endings\n * writeJson('data.json', data, { EOL: '\\r\\n' })\n * ```\n */\n EOL?: string | undefined\n /**\n * Whether to add a final newline at end of file.\n * @default true\n */\n finalEOL?: boolean | undefined\n /**\n * JSON replacer function to transform values during stringification.\n * Same as the second parameter to `JSON.stringify()`.\n */\n replacer?: JsonReviver | undefined\n /**\n * Number of spaces for indentation, or string to use for indentation.\n * @default 2\n * @example\n * ```ts\n * // Use tabs instead of spaces\n * writeJson('data.json', data, { spaces: '\\t' })\n *\n * // Use 4 spaces for indentation\n * writeJson('data.json', data, { spaces: 4 })\n * ```\n */\n spaces?: number | string | undefined\n}\n\nconst defaultRemoveOptions = objectFreeze({\n __proto__: null,\n force: true,\n maxRetries: 3,\n recursive: true,\n retryDelay: 200,\n})\n\nlet _fs: typeof import('fs') | undefined\n/**\n * Lazily load the fs module to avoid Webpack errors.\n * Uses non-'node:' prefixed require to prevent Webpack bundling issues.\n *\n * @returns The Node.js fs module\n * @private\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction getFs() {\n if (_fs === undefined) {\n // Use non-'node:' prefixed require to avoid Webpack errors.\n _fs = /*@__PURE__*/ require('node:fs')\n }\n return _fs as typeof import('fs')\n}\n\nlet _path: typeof import('path') | undefined\n/**\n * Lazily load the path module to avoid Webpack errors.\n * Uses non-'node:' prefixed require to prevent Webpack bundling issues.\n *\n * @returns The Node.js path module\n * @private\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction getPath() {\n if (_path === undefined) {\n // Use non-'node:' prefixed require to avoid Webpack errors.\n\n _path = /*@__PURE__*/ require('node:path')\n }\n return _path as typeof import('path')\n}\n\n/**\n * Process directory entries and filter for directories.\n * Filters entries to include only directories, optionally excluding empty ones.\n * Applies ignore patterns and natural sorting.\n *\n * @param dirents - Directory entries from readdir\n * @param dirname - Parent directory path\n * @param options - Filtering and sorting options\n * @returns Array of directory names, optionally sorted\n * @private\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction innerReadDirNames(\n dirents: Dirent[],\n dirname: string | undefined,\n options?: ReadDirOptions | undefined,\n): string[] {\n const {\n ignore,\n includeEmpty = true,\n sort = true,\n } = { __proto__: null, ...options } as ReadDirOptions\n const path = getPath()\n const names = dirents\n .filter(\n (d: Dirent) =>\n d.isDirectory() &&\n (includeEmpty ||\n !isDirEmptySync(path.join(dirname || d.parentPath, d.name), {\n ignore,\n })),\n )\n .map((d: Dirent) => d.name)\n return sort ? names.sort(naturalCompare) : names\n}\n\n/**\n * Stringify JSON with custom formatting options.\n * Formats JSON with configurable line endings and indentation.\n *\n * @param json - Value to stringify\n * @param EOL - End-of-line sequence\n * @param finalEOL - Whether to add final newline\n * @param replacer - JSON replacer function\n * @param spaces - Indentation spaces or string\n * @returns Formatted JSON string\n * @private\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction stringify(\n json: unknown,\n EOL: string,\n finalEOL: boolean,\n replacer: JsonReviver | undefined,\n spaces: number | string = 2,\n): string {\n const EOF = finalEOL ? EOL : ''\n const str = JSON.stringify(json, replacer, spaces)\n return `${str.replace(/\\n/g, EOL)}${EOF}`\n}\n\n/**\n * Find a file or directory by traversing up parent directories.\n * Searches from the starting directory upward to the filesystem root.\n * Useful for finding configuration files or project roots.\n *\n * @param name - Filename(s) to search for\n * @param options - Search options including cwd and type filters\n * @returns Normalized absolute path if found, undefined otherwise\n *\n * @example\n * ```ts\n * // Find package.json starting from current directory\n * const pkgPath = await findUp('package.json')\n *\n * // Find any of multiple config files\n * const configPath = await findUp(['.config.js', '.config.json'])\n *\n * // Find a directory instead of file\n * const nodeModules = await findUp('node_modules', { onlyDirectories: true })\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport async function findUp(\n name: string | string[] | readonly string[],\n options?: FindUpOptions | undefined,\n): Promise<string | undefined> {\n const { cwd = process.cwd(), signal = abortSignal } = {\n __proto__: null,\n ...options,\n } as FindUpOptions\n let { onlyDirectories = false, onlyFiles = true } = {\n __proto__: null,\n ...options,\n } as FindUpOptions\n if (onlyDirectories) {\n onlyFiles = false\n }\n if (onlyFiles) {\n onlyDirectories = false\n }\n const fs = getFs()\n const path = getPath()\n let dir = path.resolve(cwd)\n const { root } = path.parse(dir)\n const names = isArray(name) ? name : [name as string]\n while (dir && dir !== root) {\n for (const n of names) {\n if (signal?.aborted) {\n return undefined\n }\n const thePath = path.join(dir, n)\n try {\n // eslint-disable-next-line no-await-in-loop\n const stats = await fs.promises.stat(thePath)\n if (!onlyDirectories && stats.isFile()) {\n return normalizePath(thePath)\n }\n if (!onlyFiles && stats.isDirectory()) {\n return normalizePath(thePath)\n }\n } catch {}\n }\n dir = path.dirname(dir)\n }\n return undefined\n}\n\n/**\n * Synchronously find a file or directory by traversing up parent directories.\n * Searches from the starting directory upward to the filesystem root or `stopAt` directory.\n * Useful for finding configuration files or project roots in synchronous contexts.\n *\n * @param name - Filename(s) to search for\n * @param options - Search options including cwd, stopAt, and type filters\n * @returns Normalized absolute path if found, undefined otherwise\n *\n * @example\n * ```ts\n * // Find package.json starting from current directory\n * const pkgPath = findUpSync('package.json')\n *\n * // Find .git directory but stop at home directory\n * const gitPath = findUpSync('.git', {\n * onlyDirectories: true,\n * stopAt: process.env.HOME\n * })\n *\n * // Find any of multiple config files\n * const configPath = findUpSync(['.eslintrc.js', '.eslintrc.json'])\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function findUpSync(\n name: string | string[] | readonly string[],\n options?: FindUpSyncOptions | undefined,\n) {\n const { cwd = process.cwd(), stopAt } = {\n __proto__: null,\n ...options,\n } as FindUpSyncOptions\n let { onlyDirectories = false, onlyFiles = true } = {\n __proto__: null,\n ...options,\n } as FindUpSyncOptions\n if (onlyDirectories) {\n onlyFiles = false\n }\n if (onlyFiles) {\n onlyDirectories = false\n }\n const fs = getFs()\n const path = getPath()\n let dir = path.resolve(cwd)\n const { root } = path.parse(dir)\n const stopDir = stopAt ? path.resolve(stopAt) : undefined\n const names = isArray(name) ? name : [name as string]\n while (dir && dir !== root) {\n // Check if we should stop at this directory.\n if (stopDir && dir === stopDir) {\n // Check current directory but don't go up.\n for (const n of names) {\n const thePath = path.join(dir, n)\n try {\n const stats = fs.statSync(thePath)\n if (!onlyDirectories && stats.isFile()) {\n return normalizePath(thePath)\n }\n if (!onlyFiles && stats.isDirectory()) {\n return normalizePath(thePath)\n }\n } catch {}\n }\n return undefined\n }\n for (const n of names) {\n const thePath = path.join(dir, n)\n try {\n const stats = fs.statSync(thePath)\n if (!onlyDirectories && stats.isFile()) {\n return normalizePath(thePath)\n }\n if (!onlyFiles && stats.isDirectory()) {\n return normalizePath(thePath)\n }\n } catch {}\n }\n dir = path.dirname(dir)\n }\n return undefined\n}\n\n/**\n * Check if a path is a directory asynchronously.\n * Returns `true` for directories, `false` for files or non-existent paths.\n *\n * @param filepath - Path to check\n * @returns `true` if path is a directory, `false` otherwise\n *\n * @example\n * ```ts\n * if (await isDir('./src')) {\n * console.log('src is a directory')\n * }\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport async function isDir(filepath: PathLike) {\n return !!(await safeStats(filepath))?.isDirectory()\n}\n\n/**\n * Check if a path is a directory synchronously.\n * Returns `true` for directories, `false` for files or non-existent paths.\n *\n * @param filepath - Path to check\n * @returns `true` if path is a directory, `false` otherwise\n *\n * @example\n * ```ts\n * if (isDirSync('./src')) {\n * console.log('src is a directory')\n * }\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function isDirSync(filepath: PathLike) {\n return !!safeStatsSync(filepath)?.isDirectory()\n}\n\n/**\n * Check if a directory is empty synchronously.\n * A directory is considered empty if it contains no files after applying ignore patterns.\n * Uses glob patterns to filter ignored files.\n *\n * @param dirname - Directory path to check\n * @param options - Options including ignore patterns\n * @returns `true` if directory is empty (or doesn't exist), `false` otherwise\n *\n * @example\n * ```ts\n * // Check if directory is completely empty\n * isDirEmptySync('./build')\n *\n * // Check if directory is empty, ignoring .DS_Store files\n * isDirEmptySync('./cache', { ignore: ['.DS_Store'] })\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function isDirEmptySync(\n dirname: PathLike,\n options?: IsDirEmptyOptions | undefined,\n) {\n const { ignore = defaultIgnore } = {\n __proto__: null,\n ...options,\n } as IsDirEmptyOptions\n const fs = getFs()\n try {\n const files = fs.readdirSync(dirname)\n const { length } = files\n if (length === 0) {\n return true\n }\n const matcher = getGlobMatcher(\n ignore as string[],\n {\n cwd: pathLikeToString(dirname),\n } as { cwd?: string; dot?: boolean; ignore?: string[]; nocase?: boolean },\n )\n let ignoredCount = 0\n for (let i = 0; i < length; i += 1) {\n const file = files[i]\n if (file && matcher(file)) {\n ignoredCount += 1\n }\n }\n return ignoredCount === length\n } catch {\n // Return false for non-existent paths or other errors.\n return false\n }\n}\n\n/**\n * Check if a path is a symbolic link synchronously.\n * Uses `lstat` to check the link itself, not the target.\n *\n * @param filepath - Path to check\n * @returns `true` if path is a symbolic link, `false` otherwise\n *\n * @example\n * ```ts\n * if (isSymLinkSync('./my-link')) {\n * console.log('Path is a symbolic link')\n * }\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function isSymLinkSync(filepath: PathLike) {\n const fs = getFs()\n try {\n return fs.lstatSync(filepath).isSymbolicLink()\n } catch {}\n return false\n}\n\n/**\n * Result of file readability validation.\n * Contains lists of valid and invalid file paths.\n */\nexport interface ValidateFilesResult {\n /**\n * File paths that passed validation and are readable.\n */\n validPaths: string[]\n /**\n * File paths that failed validation (unreadable, permission denied, or non-existent).\n * Common with Yarn Berry PnP virtual filesystem, pnpm symlinks, or filesystem race conditions.\n */\n invalidPaths: string[]\n}\n\n/**\n * Validate that file paths are readable before processing.\n * Filters out files from glob results that cannot be accessed (common with\n * Yarn Berry PnP virtual filesystem, pnpm content-addressable store symlinks,\n * or filesystem race conditions in CI/CD environments).\n *\n * This defensive pattern prevents ENOENT errors when files exist in glob\n * results but are not accessible via standard filesystem operations.\n *\n * @param filepaths - Array of file paths to validate\n * @returns Object with `validPaths` (readable) and `invalidPaths` (unreadable)\n *\n * @example\n * ```ts\n * import { validateFiles } from '@socketsecurity/lib/fs'\n *\n * const files = ['package.json', '.pnp.cjs/virtual-file.json']\n * const { validPaths, invalidPaths } = validateFiles(files)\n *\n * console.log(`Valid: ${validPaths.length}`)\n * console.log(`Invalid: ${invalidPaths.length}`)\n * ```\n *\n * @example\n * ```ts\n * // Typical usage in Socket CLI commands\n * const packagePaths = await getPackageFilesForScan(targets)\n * const { validPaths } = validateFiles(packagePaths)\n * await sdk.uploadManifestFiles(orgSlug, validPaths)\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function validateFiles(\n filepaths: string[] | readonly string[],\n): ValidateFilesResult {\n const fs = getFs()\n const validPaths: string[] = []\n const invalidPaths: string[] = []\n const { R_OK } = fs.constants\n\n for (const filepath of filepaths) {\n try {\n fs.accessSync(filepath, R_OK)\n validPaths.push(filepath)\n } catch {\n invalidPaths.push(filepath)\n }\n }\n\n return { __proto__: null, validPaths, invalidPaths } as ValidateFilesResult\n}\n\n/**\n * Read directory names asynchronously with filtering and sorting.\n * Returns only directory names (not files), with optional filtering for empty directories\n * and glob-based ignore patterns. Results are naturally sorted by default.\n *\n * @param dirname - Directory path to read\n * @param options - Options for filtering and sorting\n * @returns Array of directory names, empty array on error\n *\n * @example\n * ```ts\n * // Get all subdirectories, sorted naturally\n * const dirs = await readDirNames('./packages')\n *\n * // Get non-empty directories only\n * const nonEmpty = await readDirNames('./cache', { includeEmpty: false })\n *\n * // Get directories without sorting\n * const unsorted = await readDirNames('./src', { sort: false })\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport async function readDirNames(\n dirname: PathLike,\n options?: ReadDirOptions | undefined,\n) {\n const fs = getFs()\n try {\n return innerReadDirNames(\n await fs.promises.readdir(dirname, {\n __proto__: null,\n encoding: 'utf8',\n withFileTypes: true,\n } as ObjectEncodingOptions & { withFileTypes: true }),\n String(dirname),\n options,\n )\n } catch {}\n return []\n}\n\n/**\n * Read directory names synchronously with filtering and sorting.\n * Returns only directory names (not files), with optional filtering for empty directories\n * and glob-based ignore patterns. Results are naturally sorted by default.\n *\n * @param dirname - Directory path to read\n * @param options - Options for filtering and sorting\n * @returns Array of directory names, empty array on error\n *\n * @example\n * ```ts\n * // Get all subdirectories, sorted naturally\n * const dirs = readDirNamesSync('./packages')\n *\n * // Get non-empty directories only, ignoring node_modules\n * const nonEmpty = readDirNamesSync('./src', {\n * includeEmpty: false,\n * ignore: ['node_modules']\n * })\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function readDirNamesSync(dirname: PathLike, options?: ReadDirOptions) {\n const fs = getFs()\n try {\n return innerReadDirNames(\n fs.readdirSync(dirname, {\n __proto__: null,\n encoding: 'utf8',\n withFileTypes: true,\n } as ObjectEncodingOptions & { withFileTypes: true }),\n String(dirname),\n options,\n )\n } catch {}\n return []\n}\n\n/**\n * Read a file as binary data asynchronously.\n * Returns a Buffer without encoding the contents.\n * Useful for reading images, archives, or other binary formats.\n *\n * @param filepath - Path to file\n * @param options - Read options (encoding is forced to null for binary)\n * @returns Promise resolving to Buffer containing file contents\n *\n * @example\n * ```ts\n * // Read an image file\n * const imageBuffer = await readFileBinary('./image.png')\n *\n * // Read with abort signal\n * const buffer = await readFileBinary('./data.bin', { signal: abortSignal })\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport async function readFileBinary(\n filepath: PathLike,\n options?: ReadFileOptions | undefined,\n) {\n // Don't specify encoding to get a Buffer.\n const opts = typeof options === 'string' ? { encoding: options } : options\n const fs = getFs()\n return await fs.promises.readFile(filepath, {\n signal: abortSignal,\n ...opts,\n encoding: null,\n })\n}\n\n/**\n * Read a file as UTF-8 text asynchronously.\n * Returns a string with the file contents decoded as UTF-8.\n * This is the most common way to read text files.\n *\n * @param filepath - Path to file\n * @param options - Read options including encoding and abort signal\n * @returns Promise resolving to string containing file contents\n *\n * @example\n * ```ts\n * // Read a text file\n * const content = await readFileUtf8('./README.md')\n *\n * // Read with custom encoding\n * const content = await readFileUtf8('./data.txt', { encoding: 'utf-8' })\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport async function readFileUtf8(\n filepath: PathLike,\n options?: ReadFileOptions | undefined,\n) {\n const opts = typeof options === 'string' ? { encoding: options } : options\n const fs = getFs()\n return await fs.promises.readFile(filepath, {\n signal: abortSignal,\n ...opts,\n encoding: 'utf8',\n })\n}\n\n/**\n * Read a file as binary data synchronously.\n * Returns a Buffer without encoding the contents.\n * Useful for reading images, archives, or other binary formats.\n *\n * @param filepath - Path to file\n * @param options - Read options (encoding is forced to null for binary)\n * @returns Buffer containing file contents\n *\n * @example\n * ```ts\n * // Read an image file\n * const imageBuffer = readFileBinarySync('./logo.png')\n *\n * // Read a compressed file\n * const gzipData = readFileBinarySync('./archive.gz')\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function readFileBinarySync(\n filepath: PathLike,\n options?: ReadFileOptions | undefined,\n) {\n // Don't specify encoding to get a Buffer\n const opts = typeof options === 'string' ? { encoding: options } : options\n const fs = getFs()\n return fs.readFileSync(filepath, {\n ...opts,\n encoding: null,\n } as ObjectEncodingOptions)\n}\n\n/**\n * Read a file as UTF-8 text synchronously.\n * Returns a string with the file contents decoded as UTF-8.\n * This is the most common way to read text files synchronously.\n *\n * @param filepath - Path to file\n * @param options - Read options including encoding\n * @returns String containing file contents\n *\n * @example\n * ```ts\n * // Read a configuration file\n * const config = readFileUtf8Sync('./config.txt')\n *\n * // Read with custom options\n * const data = readFileUtf8Sync('./data.txt', { encoding: 'utf8' })\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function readFileUtf8Sync(\n filepath: PathLike,\n options?: ReadFileOptions | undefined,\n) {\n const opts = typeof options === 'string' ? { encoding: options } : options\n const fs = getFs()\n return fs.readFileSync(filepath, {\n ...opts,\n encoding: 'utf8',\n } as ObjectEncodingOptions)\n}\n\n/**\n * Read and parse a JSON file asynchronously.\n * Reads the file as UTF-8 text and parses it as JSON.\n * Optionally accepts a reviver function to transform parsed values.\n *\n * @param filepath - Path to JSON file\n * @param options - Read and parse options\n * @returns Promise resolving to parsed JSON value, or undefined if throws is false and an error occurs\n *\n * @example\n * ```ts\n * // Read and parse package.json\n * const pkg = await readJson('./package.json')\n *\n * // Read JSON with custom reviver\n * const data = await readJson('./data.json', {\n * reviver: (key, value) => {\n * if (key === 'date') return new Date(value)\n * return value\n * }\n * })\n *\n * // Don't throw on parse errors\n * const config = await readJson('./config.json', { throws: false })\n * if (config === undefined) {\n * console.log('Failed to parse config')\n * }\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport async function readJson(\n filepath: PathLike,\n options?: ReadJsonOptions | string | undefined,\n) {\n const opts = typeof options === 'string' ? { encoding: options } : options\n const { reviver, throws, ...fsOptions } = {\n __proto__: null,\n ...opts,\n } as unknown as ReadJsonOptions\n const shouldThrow = throws === undefined || !!throws\n const fs = getFs()\n let content = ''\n try {\n content = await fs.promises.readFile(filepath, {\n __proto__: null,\n encoding: 'utf8',\n ...fsOptions,\n } as unknown as Parameters<typeof fs.promises.readFile>[1] & {\n encoding: string\n })\n } catch (e) {\n if (shouldThrow) {\n const code = (e as NodeJS.ErrnoException).code\n if (code === 'ENOENT') {\n throw new Error(\n `JSON file not found: ${filepath}\\n` +\n 'Ensure the file exists or create it with the expected structure.',\n { cause: e },\n )\n }\n if (code === 'EACCES' || code === 'EPERM') {\n throw new Error(\n `Permission denied reading JSON file: ${filepath}\\n` +\n 'Check file permissions or run with appropriate access.',\n { cause: e },\n )\n }\n throw e\n }\n return undefined\n }\n return jsonParse(content, {\n filepath: String(filepath),\n reviver,\n throws: shouldThrow,\n })\n}\n\n/**\n * Read and parse a JSON file synchronously.\n * Reads the file as UTF-8 text and parses it as JSON.\n * Optionally accepts a reviver function to transform parsed values.\n *\n * @param filepath - Path to JSON file\n * @param options - Read and parse options\n * @returns Parsed JSON value, or undefined if throws is false and an error occurs\n *\n * @example\n * ```ts\n * // Read and parse tsconfig.json\n * const tsconfig = readJsonSync('./tsconfig.json')\n *\n * // Read JSON with custom reviver\n * const data = readJsonSync('./data.json', {\n * reviver: (key, value) => {\n * if (typeof value === 'string' && /^\\d{4}-\\d{2}-\\d{2}/.test(value)) {\n * return new Date(value)\n * }\n * return value\n * }\n * })\n *\n * // Don't throw on parse errors\n * const config = readJsonSync('./config.json', { throws: false })\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function readJsonSync(\n filepath: PathLike,\n options?: ReadJsonOptions | string | undefined,\n) {\n const opts = typeof options === 'string' ? { encoding: options } : options\n const { reviver, throws, ...fsOptions } = {\n __proto__: null,\n ...opts,\n } as unknown as ReadJsonOptions\n const shouldThrow = throws === undefined || !!throws\n const fs = getFs()\n let content = ''\n try {\n content = fs.readFileSync(filepath, {\n __proto__: null,\n encoding: 'utf8',\n ...fsOptions,\n } as unknown as Parameters<typeof fs.readFileSync>[1] & {\n encoding: string\n })\n } catch (e) {\n if (shouldThrow) {\n const code = (e as NodeJS.ErrnoException).code\n if (code === 'ENOENT') {\n throw new Error(\n `JSON file not found: ${filepath}\\n` +\n 'Ensure the file exists or create it with the expected structure.',\n { cause: e },\n )\n }\n if (code === 'EACCES' || code === 'EPERM') {\n throw new Error(\n `Permission denied reading JSON file: ${filepath}\\n` +\n 'Check file permissions or run with appropriate access.',\n { cause: e },\n )\n }\n throw e\n }\n return undefined\n }\n return jsonParse(content, {\n filepath: String(filepath),\n reviver,\n throws: shouldThrow,\n })\n}\n\n// Cache for resolved allowed directories\nlet _cachedAllowedDirs: string[] | undefined\n\n/**\n * Get resolved allowed directories for safe deletion with lazy caching.\n * These directories are resolved once and cached for the process lifetime.\n */\nfunction getAllowedDirectories(): string[] {\n if (_cachedAllowedDirs === undefined) {\n const path = getPath()\n const {\n getOsTmpDir,\n getSocketCacacheDir,\n getSocketUserDir,\n } = /*@__PURE__*/ require('#lib/paths')\n\n _cachedAllowedDirs = [\n path.resolve(getOsTmpDir()),\n path.resolve(getSocketCacacheDir()),\n path.resolve(getSocketUserDir()),\n ]\n }\n return _cachedAllowedDirs\n}\n\n/**\n * Invalidate the cached allowed directories.\n * Called automatically by the paths/rewire module when paths are overridden in tests.\n *\n * @internal Used for test rewiring\n */\nexport function invalidatePathCache(): void {\n _cachedAllowedDirs = undefined\n}\n\n// Register cache invalidation with the rewire module\nregisterCacheInvalidation(invalidatePathCache)\n\n/**\n * Safely delete a file or directory asynchronously with built-in protections.\n * Uses `del` for safer deletion that prevents removing cwd and above by default.\n * Automatically uses force: true for temp directory, cacache, and ~/.socket subdirectories.\n *\n * @param filepath - Path or array of paths to delete (supports glob patterns)\n * @param options - Deletion options including force, retries, and recursion\n * @throws {Error} When attempting to delete protected paths without force option\n *\n * @example\n * ```ts\n * // Delete a single file\n * await safeDelete('./temp-file.txt')\n *\n * // Delete a directory recursively\n * await safeDelete('./build', { recursive: true })\n *\n * // Delete multiple paths\n * await safeDelete(['./dist', './coverage'])\n *\n * // Delete with custom retry settings\n * await safeDelete('./flaky-dir', { maxRetries: 5, retryDelay: 500 })\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport async function safeDelete(\n filepath: PathLike | PathLike[],\n options?: RemoveOptions | undefined,\n) {\n const del = /*@__PURE__*/ require('./external/del')\n const { deleteAsync } = del\n const opts = { __proto__: null, ...options } as RemoveOptions\n const patterns = isArray(filepath)\n ? filepath.map(pathLikeToString)\n : [pathLikeToString(filepath)]\n\n // Check if we're deleting within allowed directories.\n let shouldForce = opts.force !== false\n if (!shouldForce && patterns.length > 0) {\n const path = getPath()\n const allowedDirs = getAllowedDirectories()\n\n // Check if all patterns are within allowed directories.\n const allInAllowedDirs = patterns.every(pattern => {\n const resolvedPath = path.resolve(pattern)\n\n // Check each allowed directory\n for (const allowedDir of allowedDirs) {\n const isInAllowedDir =\n resolvedPath.startsWith(allowedDir + path.sep) ||\n resolvedPath === allowedDir\n const relativePath = path.relative(allowedDir, resolvedPath)\n const isGoingBackward = relativePath.startsWith('..')\n\n if (isInAllowedDir && !isGoingBackward) {\n return true\n }\n }\n\n return false\n })\n\n if (allInAllowedDirs) {\n shouldForce = true\n }\n }\n\n await deleteAsync(patterns, {\n concurrency: opts.maxRetries || defaultRemoveOptions.maxRetries,\n dryRun: false,\n force: shouldForce,\n onlyFiles: false,\n })\n}\n\n/**\n * Safely delete a file or directory synchronously with built-in protections.\n * Uses `del` for safer deletion that prevents removing cwd and above by default.\n * Automatically uses force: true for temp directory, cacache, and ~/.socket subdirectories.\n *\n * @param filepath - Path or array of paths to delete (supports glob patterns)\n * @param options - Deletion options including force, retries, and recursion\n * @throws {Error} When attempting to delete protected paths without force option\n *\n * @example\n * ```ts\n * // Delete a single file\n * safeDeleteSync('./temp-file.txt')\n *\n * // Delete a directory recursively\n * safeDeleteSync('./build', { recursive: true })\n *\n * // Delete multiple paths with globs\n * safeDeleteSync(['./dist/**', './coverage/**'])\n *\n * // Force delete a protected path (use with caution)\n * safeDeleteSync('./important', { force: true })\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function safeDeleteSync(\n filepath: PathLike | PathLike[],\n options?: RemoveOptions | undefined,\n) {\n const del = /*@__PURE__*/ require('./external/del')\n const { deleteSync } = del\n const opts = { __proto__: null, ...options } as RemoveOptions\n const patterns = isArray(filepath)\n ? filepath.map(pathLikeToString)\n : [pathLikeToString(filepath)]\n\n // Check if we're deleting within allowed directories.\n let shouldForce = opts.force !== false\n if (!shouldForce && patterns.length > 0) {\n const path = getPath()\n const allowedDirs = getAllowedDirectories()\n\n // Check if all patterns are within allowed directories.\n const allInAllowedDirs = patterns.every(pattern => {\n const resolvedPath = path.resolve(pattern)\n\n // Check each allowed directory\n for (const allowedDir of allowedDirs) {\n const isInAllowedDir =\n resolvedPath.startsWith(allowedDir + path.sep) ||\n resolvedPath === allowedDir\n const relativePath = path.relative(allowedDir, resolvedPath)\n const isGoingBackward = relativePath.startsWith('..')\n\n if (isInAllowedDir && !isGoingBackward) {\n return true\n }\n }\n\n return false\n })\n\n if (allInAllowedDirs) {\n shouldForce = true\n }\n }\n\n deleteSync(patterns, {\n concurrency: opts.maxRetries || defaultRemoveOptions.maxRetries,\n dryRun: false,\n force: shouldForce,\n onlyFiles: false,\n })\n}\n\n/**\n * Safely create a directory asynchronously, ignoring EEXIST errors.\n * This function wraps fs.promises.mkdir and handles the race condition where\n * the directory might already exist, which is common in concurrent code.\n *\n * Unlike fs.promises.mkdir with recursive:true, this function:\n * - Silently ignores EEXIST errors (directory already exists)\n * - Re-throws all other errors (permissions, invalid path, etc.)\n * - Works reliably in multi-process/concurrent scenarios\n *\n * @param path - Directory path to create\n * @param options - Options including recursive and mode settings\n * @returns Promise that resolves when directory is created or already exists\n *\n * @example\n * ```ts\n * // Create a directory, no error if it exists\n * await safeMkdir('./config')\n *\n * // Create nested directories\n * await safeMkdir('./data/cache/temp', { recursive: true })\n *\n * // Create with specific permissions\n * await safeMkdir('./secure', { mode: 0o700 })\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport async function safeMkdir(\n path: PathLike,\n options?: MakeDirectoryOptions | undefined,\n): Promise<void> {\n const fs = getFs()\n try {\n await fs.promises.mkdir(path, options)\n } catch (e: unknown) {\n // Ignore EEXIST error - directory already exists.\n if (\n typeof e === 'object' &&\n e !== null &&\n 'code' in e &&\n e.code !== 'EEXIST'\n ) {\n throw e\n }\n }\n}\n\n/**\n * Safely create a directory synchronously, ignoring EEXIST errors.\n * This function wraps fs.mkdirSync and handles the race condition where\n * the directory might already exist, which is common in concurrent code.\n *\n * Unlike fs.mkdirSync with recursive:true, this function:\n * - Silently ignores EEXIST errors (directory already exists)\n * - Re-throws all other errors (permissions, invalid path, etc.)\n * - Works reliably in multi-process/concurrent scenarios\n *\n * @param path - Directory path to create\n * @param options - Options including recursive and mode settings\n *\n * @example\n * ```ts\n * // Create a directory, no error if it exists\n * safeMkdirSync('./config')\n *\n * // Create nested directories\n * safeMkdirSync('./data/cache/temp', { recursive: true })\n *\n * // Create with specific permissions\n * safeMkdirSync('./secure', { mode: 0o700 })\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function safeMkdirSync(\n path: PathLike,\n options?: MakeDirectoryOptions | undefined,\n): void {\n const fs = getFs()\n try {\n fs.mkdirSync(path, options)\n } catch (e: unknown) {\n // Ignore EEXIST error - directory already exists.\n if (\n typeof e === 'object' &&\n e !== null &&\n 'code' in e &&\n e.code !== 'EEXIST'\n ) {\n throw e\n }\n }\n}\n\n/**\n * Safely read a file asynchronously, returning undefined on error.\n * Useful when you want to attempt reading a file without handling errors explicitly.\n * Returns undefined for any error (file not found, permission denied, etc.).\n *\n * @param filepath - Path to file\n * @param options - Read options including encoding and default value\n * @returns Promise resolving to file contents, or undefined on error\n *\n * @example\n * ```ts\n * // Try to read a file, get undefined if it doesn't exist\n * const content = await safeReadFile('./optional-config.txt')\n * if (content) {\n * console.log('Config found:', content)\n * }\n *\n * // Read with specific encoding\n * const data = await safeReadFile('./data.txt', { encoding: 'utf8' })\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport async function safeReadFile(\n filepath: PathLike,\n options?: SafeReadOptions | undefined,\n) {\n const opts = typeof options === 'string' ? { encoding: options } : options\n const fs = getFs()\n try {\n return await fs.promises.readFile(filepath, {\n signal: abortSignal,\n ...opts,\n } as Abortable)\n } catch {}\n return undefined\n}\n\n/**\n * Safely read a file synchronously, returning undefined on error.\n * Useful when you want to attempt reading a file without handling errors explicitly.\n * Returns undefined for any error (file not found, permission denied, etc.).\n *\n * @param filepath - Path to file\n * @param options - Read options including encoding and default value\n * @returns File contents, or undefined on error\n *\n * @example\n * ```ts\n * // Try to read a config file\n * const config = safeReadFileSync('./config.txt')\n * if (config) {\n * console.log('Config loaded successfully')\n * }\n *\n * // Read binary file safely\n * const buffer = safeReadFileSync('./image.png', { encoding: null })\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function safeReadFileSync(\n filepath: PathLike,\n options?: SafeReadOptions | undefined,\n) {\n const opts = typeof options === 'string' ? { encoding: options } : options\n const fs = getFs()\n try {\n return fs.readFileSync(filepath, {\n __proto__: null,\n ...opts,\n } as ObjectEncodingOptions)\n } catch {}\n return undefined\n}\n\n/**\n * Safely get file stats asynchronously, returning undefined on error.\n * Useful for checking file existence and properties without error handling.\n * Returns undefined for any error (file not found, permission denied, etc.).\n *\n * @param filepath - Path to check\n * @returns Promise resolving to Stats object, or undefined on error\n *\n * @example\n * ```ts\n * // Check if file exists and get its stats\n * const stats = await safeStats('./file.txt')\n * if (stats) {\n * console.log('File size:', stats.size)\n * console.log('Modified:', stats.mtime)\n * }\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport async function safeStats(filepath: PathLike) {\n const fs = getFs()\n try {\n return await fs.promises.stat(filepath)\n } catch {}\n return undefined\n}\n\n/**\n * Safely get file stats synchronously, returning undefined on error.\n * Useful for checking file existence and properties without error handling.\n * Returns undefined for any error (file not found, permission denied, etc.).\n *\n * @param filepath - Path to check\n * @param options - Read options (currently unused but kept for API consistency)\n * @returns Stats object, or undefined on error\n *\n * @example\n * ```ts\n * // Check if file exists and get its size\n * const stats = safeStatsSync('./file.txt')\n * if (stats) {\n * console.log('File size:', stats.size)\n * console.log('Is directory:', stats.isDirectory())\n * }\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function safeStatsSync(\n filepath: PathLike,\n options?: ReadFileOptions | undefined,\n) {\n const opts = typeof options === 'string' ? { encoding: options } : options\n const fs = getFs()\n try {\n return fs.statSync(filepath, {\n __proto__: null,\n throwIfNoEntry: false,\n ...opts,\n } as StatSyncOptions)\n } catch {}\n return undefined\n}\n\n/**\n * Generate a unique filepath by adding number suffix if the path exists.\n * Appends `-1`, `-2`, etc. before the file extension until a non-existent path is found.\n * Useful for creating files without overwriting existing ones.\n *\n * @param filepath - Desired file path\n * @returns Normalized unique filepath (original if it doesn't exist, or with number suffix)\n *\n * @example\n * ```ts\n * // If 'report.pdf' exists, returns 'report-1.pdf'\n * const uniquePath = uniqueSync('./report.pdf')\n *\n * // If 'data.json' and 'data-1.json' exist, returns 'data-2.json'\n * const path = uniqueSync('./data.json')\n *\n * // If 'backup' doesn't exist, returns 'backup' unchanged\n * const backupPath = uniqueSync('./backup')\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function uniqueSync(filepath: PathLike): string {\n const fs = getFs()\n const path = getPath()\n const filepathStr = String(filepath)\n\n // If the file doesn't exist, return as is\n if (!fs.existsSync(filepathStr)) {\n return normalizePath(filepathStr)\n }\n\n const dirname = path.dirname(filepathStr)\n const ext = path.extname(filepathStr)\n const basename = path.basename(filepathStr, ext)\n\n let counter = 1\n let uniquePath: string\n do {\n uniquePath = path.join(dirname, `${basename}-${counter}${ext}`)\n counter++\n } while (fs.existsSync(uniquePath))\n\n return normalizePath(uniquePath)\n}\n\n/**\n * Write JSON content to a file asynchronously with formatting.\n * Stringifies the value with configurable indentation and line endings.\n * Automatically adds a final newline by default for POSIX compliance.\n *\n * @param filepath - Path to write to\n * @param jsonContent - Value to stringify and write\n * @param options - Write options including formatting and encoding\n * @returns Promise that resolves when write completes\n *\n * @example\n * ```ts\n * // Write formatted JSON with default 2-space indentation\n * await writeJson('./data.json', { name: 'example', version: '1.0.0' })\n *\n * // Write with custom indentation\n * await writeJson('./config.json', config, { spaces: 4 })\n *\n * // Write with tabs instead of spaces\n * await writeJson('./data.json', data, { spaces: '\\t' })\n *\n * // Write without final newline\n * await writeJson('./inline.json', obj, { finalEOL: false })\n *\n * // Write with Windows line endings\n * await writeJson('./win.json', data, { EOL: '\\r\\n' })\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport async function writeJson(\n filepath: PathLike,\n jsonContent: unknown,\n options?: WriteJsonOptions | string,\n): Promise<void> {\n const opts = typeof options === 'string' ? { encoding: options } : options\n const { EOL, finalEOL, replacer, spaces, ...fsOptions } = {\n __proto__: null,\n ...opts,\n } as WriteJsonOptions\n const fs = getFs()\n const jsonString = stringify(\n jsonContent,\n EOL || '\\n',\n finalEOL !== undefined ? finalEOL : true,\n replacer,\n spaces,\n )\n await fs.promises.writeFile(filepath, jsonString, {\n encoding: 'utf8',\n ...fsOptions,\n __proto__: null,\n } as ObjectEncodingOptions)\n}\n\n/**\n * Write JSON content to a file synchronously with formatting.\n * Stringifies the value with configurable indentation and line endings.\n * Automatically adds a final newline by default for POSIX compliance.\n *\n * @param filepath - Path to write to\n * @param jsonContent - Value to stringify and write\n * @param options - Write options including formatting and encoding\n *\n * @example\n * ```ts\n * // Write formatted JSON with default 2-space indentation\n * writeJsonSync('./package.json', pkg)\n *\n * // Write with custom indentation\n * writeJsonSync('./tsconfig.json', tsconfig, { spaces: 4 })\n *\n * // Write with tabs for indentation\n * writeJsonSync('./data.json', data, { spaces: '\\t' })\n *\n * // Write compacted (no indentation)\n * writeJsonSync('./compact.json', data, { spaces: 0 })\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function writeJsonSync(\n filepath: PathLike,\n jsonContent: unknown,\n options?: WriteJsonOptions | string | undefined,\n): void {\n const opts = typeof options === 'string' ? { encoding: options } : options\n const { EOL, finalEOL, replacer, spaces, ...fsOptions } = {\n __proto__: null,\n ...opts,\n }\n const fs = getFs()\n const jsonString = stringify(\n jsonContent,\n EOL || '\\n',\n finalEOL !== undefined ? finalEOL : true,\n replacer,\n spaces,\n )\n fs.writeFileSync(filepath, jsonString, {\n encoding: 'utf8',\n ...fsOptions,\n __proto__: null,\n } as WriteFileOptions)\n}\n"],
5
+ "mappings": ";4ZAAA,IAAAA,GAAA,GAAAC,EAAAD,GAAA,YAAAE,EAAA,eAAAC,EAAA,wBAAAC,EAAA,UAAAC,EAAA,mBAAAC,EAAA,cAAAC,EAAA,kBAAAC,EAAA,iBAAAC,EAAA,qBAAAC,EAAA,mBAAAC,EAAA,uBAAAC,GAAA,iBAAAC,GAAA,qBAAAC,GAAA,aAAAC,GAAA,iBAAAC,GAAA,eAAAC,GAAA,mBAAAC,GAAA,cAAAC,GAAA,kBAAAC,GAAA,iBAAAC,GAAA,qBAAAC,GAAA,cAAAC,EAAA,kBAAAC,EAAA,eAAAC,GAAA,kBAAAC,EAAA,cAAAC,GAAA,kBAAAC,KAAA,eAAAC,EAAA7B,IAiBA,IAAA8B,EAA+B,8BAE/BC,EAAwB,oBAIxBC,EAA8C,mBAE9CC,EAA0B,kBAC1BC,EAAyC,qBACzCC,EAAgD,kBAChDC,EAA0C,0BAC1CC,EAA+B,mBAR/B,MAAMC,KAAc,kBAAe,EA6Q7BC,KAAuB,gBAAa,CACxC,UAAW,KACX,MAAO,GACP,WAAY,EACZ,UAAW,GACX,WAAY,GACd,CAAC,EAED,IAAIC,EASJ,SAASC,GAAQ,CACf,OAAID,IAAQ,SAEVA,EAAoB,QAAQ,SAAS,GAEhCA,CACT,CAEA,IAAIE,EASJ,SAASC,GAAU,CACjB,OAAID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AAC,EAAU,SAAAC,EAAU,OAAAC,EAAQ,GAAG6B,CAAU,EAAI,CACxD,UAAW,KACX,GAAGH,CACL,EACMnB,EAAKzB,EAAM,EACX0E,EAAa7D,EACjB4D,EACA1D,GAAO;AAAA,EACPC,IAAa,OAAYA,EAAW,GACpCC,EACAC,CACF,EACAO,EAAG,cAAcQ,EAAUyC,EAAY,CACrC,SAAU,OACV,GAAG3B,EACH,UAAW,IACb,CAAqB,CACvB",
6
+ "names": ["fs_exports", "__export", "findUp", "findUpSync", "invalidatePathCache", "isDir", "isDirEmptySync", "isDirSync", "isSymLinkSync", "readDirNames", "readDirNamesSync", "readFileBinary", "readFileBinarySync", "readFileUtf8", "readFileUtf8Sync", "readJson", "readJsonSync", "safeDelete", "safeDeleteSync", "safeMkdir", "safeMkdirSync", "safeReadFile", "safeReadFileSync", "safeStats", "safeStatsSync", "uniqueSync", "validateFiles", "writeJson", "writeJsonSync", "__toCommonJS", "import_process", "import_arrays", "import_globs", "import_json", "import_objects", "import_path", "import_rewire", "import_sorts", "abortSignal", "defaultRemoveOptions", "_fs", "getFs", "_path", "getPath", "innerReadDirNames", "dirents", "dirname", "options", "ignore", "includeEmpty", "sort", "path", "names", "d", "stringify", "json", "EOL", "finalEOL", "replacer", "spaces", "EOF", "name", "cwd", "signal", "onlyDirectories", "onlyFiles", "fs", "dir", "root", "n", "thePath", "stats", "stopAt", "stopDir", "filepath", "files", "length", "matcher", "ignoredCount", "i", "file", "filepaths", "validPaths", "invalidPaths", "R_OK", "opts", "reviver", "throws", "fsOptions", "shouldThrow", "content", "e", "code", "_cachedAllowedDirs", "getAllowedDirectories", "getOsTmpDir", "getSocketCacacheDir", "getSocketUserDir", "del", "deleteAsync", "patterns", "shouldForce", "allowedDirs", "pattern", "resolvedPath", "allowedDir", "isInAllowedDir", "isGoingBackward", "deleteSync", "filepathStr", "ext", "basename", "counter", "uniquePath", "jsonContent", "jsonString"]
7
7
  }
package/dist/git.js CHANGED
@@ -1,4 +1,4 @@
1
1
  /* Socket Lib - Built with esbuild */
2
- var M=Object.create;var y=Object.defineProperty;var z=Object.getOwnPropertyDescriptor;var I=Object.getOwnPropertyNames;var W=Object.getPrototypeOf,H=Object.prototype.hasOwnProperty;var L=(t,n)=>{for(var e in n)y(t,e,{get:n[e],enumerable:!0})},A=(t,n,e,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let i of I(n))!H.call(t,i)&&i!==e&&y(t,i,{get:()=>n[i],enumerable:!(r=z(n,i))||r.enumerable});return t};var Q=(t,n,e)=>(e=t!=null?M(W(t)):{},A(n||!t||!t.__esModule?y(e,"default",{value:t,enumerable:!0}):e,t)),T=t=>A(y({},"__esModule",{value:!0}),t);var it={};L(it,{findGitRoot:()=>$,getChangedFiles:()=>R,getChangedFilesSync:()=>j,getStagedFiles:()=>E,getStagedFilesSync:()=>K,getUnstagedFiles:()=>N,getUnstagedFilesSync:()=>U,isChanged:()=>X,isChangedSync:()=>Y,isStaged:()=>nt,isStagedSync:()=>et,isUnstaged:()=>Z,isUnstagedSync:()=>tt});module.exports=T(it);var d=Q(require("node:path")),G=require("#constants/platform"),D=require("./debug"),F=require("./globs"),f=require("./path"),S=require("./spawn"),k=require("./strings");const m=new Map;let _;function a(){return _===void 0&&(_=require("node:fs")),_}let b;function V(){return b===void 0&&(b=require("node:path")),b}function P(){return"git"}function l(){return a().realpathSync(process.cwd())}function p(t){const n=t?a().realpathSync(t):l();return{all:[P(),["status","--porcelain"],{cwd:n,shell:G.WIN32}],unstaged:[P(),["diff","--name-only"],{cwd:n}],staged:[P(),["diff","--cached","--name-only"],{cwd:n,shell:G.WIN32}]}}async function O(t,n){const{cache:e=!0,...r}={__proto__:null,...n},i=e?JSON.stringify({args:t,parseOptions:r}):void 0;if(e&&i){const o=m.get(i);if(o)return o}let s;try{const o=await(0,S.spawn)(t[0],t[1],{...t[2],stdioString:!1}),g=Buffer.isBuffer(o.stdout)?o.stdout.toString("utf8"):String(o.stdout),u=typeof t[2].cwd=="string"?t[2].cwd:void 0;s=B(g,r,u)}catch(o){return(0,D.debugNs)("git",`Git command failed (${t[0]} ${t[1].join(" ")}): ${o.message}`),[]}return e&&i&&m.set(i,s),s}function v(t,n){const{cache:e=!0,...r}={__proto__:null,...n},i=e?JSON.stringify({args:t,parseOptions:r}):void 0;if(e&&i){const o=m.get(i);if(o)return o}let s;try{const o=(0,S.spawnSync)(t[0],t[1],{...t[2],stdioString:!1}),g=Buffer.isBuffer(o.stdout)?o.stdout.toString("utf8"):String(o.stdout),u=typeof t[2].cwd=="string"?t[2].cwd:void 0;s=B(g,r,u)}catch(o){return(0,D.debugNs)("git",`Git command failed (${t[0]} ${t[1].join(" ")}): ${o.message}`),[]}return e&&i&&m.set(i,s),s}function $(t){const n=a(),e=V();let r=t;for(;;){try{const s=e.join(r,".git");if(n.existsSync(s))return r}catch{}const i=e.dirname(r);if(i===r)return t;r=i}}function B(t,n,e){const r=e?$(e):l(),{absolute:i=!1,cwd:s=r,porcelain:o=!1,...g}={__proto__:null,...n},u=s===r?r:a().realpathSync(s),w=r;let h=t?(0,k.stripAnsi)(t).split(`
2
+ var M=Object.create;var y=Object.defineProperty;var z=Object.getOwnPropertyDescriptor;var I=Object.getOwnPropertyNames;var W=Object.getPrototypeOf,H=Object.prototype.hasOwnProperty;var L=(t,n)=>{for(var e in n)y(t,e,{get:n[e],enumerable:!0})},A=(t,n,e,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let i of I(n))!H.call(t,i)&&i!==e&&y(t,i,{get:()=>n[i],enumerable:!(r=z(n,i))||r.enumerable});return t};var Q=(t,n,e)=>(e=t!=null?M(W(t)):{},A(n||!t||!t.__esModule?y(e,"default",{value:t,enumerable:!0}):e,t)),T=t=>A(y({},"__esModule",{value:!0}),t);var it={};L(it,{findGitRoot:()=>$,getChangedFiles:()=>R,getChangedFilesSync:()=>j,getStagedFiles:()=>E,getStagedFilesSync:()=>K,getUnstagedFiles:()=>N,getUnstagedFilesSync:()=>U,isChanged:()=>X,isChangedSync:()=>Y,isStaged:()=>nt,isStagedSync:()=>et,isUnstaged:()=>Z,isUnstagedSync:()=>tt});module.exports=T(it);var d=Q(require("path")),G=require("#constants/platform"),D=require("./debug"),F=require("./globs"),f=require("./path"),S=require("./spawn"),k=require("./strings");const m=new Map;let _;function a(){return _===void 0&&(_=require("node:fs")),_}let b;function V(){return b===void 0&&(b=require("node:path")),b}function P(){return"git"}function l(){return a().realpathSync(process.cwd())}function p(t){const n=t?a().realpathSync(t):l();return{all:[P(),["status","--porcelain"],{cwd:n,shell:G.WIN32}],unstaged:[P(),["diff","--name-only"],{cwd:n}],staged:[P(),["diff","--cached","--name-only"],{cwd:n,shell:G.WIN32}]}}async function O(t,n){const{cache:e=!0,...r}={__proto__:null,...n},i=e?JSON.stringify({args:t,parseOptions:r}):void 0;if(e&&i){const o=m.get(i);if(o)return o}let s;try{const o=await(0,S.spawn)(t[0],t[1],{...t[2],stdioString:!1}),g=Buffer.isBuffer(o.stdout)?o.stdout.toString("utf8"):String(o.stdout),u=typeof t[2].cwd=="string"?t[2].cwd:void 0;s=B(g,r,u)}catch(o){return(0,D.debugNs)("git",`Git command failed (${t[0]} ${t[1].join(" ")}): ${o.message}`),[]}return e&&i&&m.set(i,s),s}function v(t,n){const{cache:e=!0,...r}={__proto__:null,...n},i=e?JSON.stringify({args:t,parseOptions:r}):void 0;if(e&&i){const o=m.get(i);if(o)return o}let s;try{const o=(0,S.spawnSync)(t[0],t[1],{...t[2],stdioString:!1}),g=Buffer.isBuffer(o.stdout)?o.stdout.toString("utf8"):String(o.stdout),u=typeof t[2].cwd=="string"?t[2].cwd:void 0;s=B(g,r,u)}catch(o){return(0,D.debugNs)("git",`Git command failed (${t[0]} ${t[1].join(" ")}): ${o.message}`),[]}return e&&i&&m.set(i,s),s}function $(t){const n=a(),e=V();let r=t;for(;;){try{const s=e.join(r,".git");if(n.existsSync(s))return r}catch{}const i=e.dirname(r);if(i===r)return t;r=i}}function B(t,n,e){const r=e?$(e):l(),{absolute:i=!1,cwd:s=r,porcelain:o=!1,...g}={__proto__:null,...n},u=s===r?r:a().realpathSync(s),w=r;let h=t?(0,k.stripAnsi)(t).split(`
3
3
  `).map(c=>c.trimEnd()).filter(c=>c):[];o&&(h=h.map(c=>c.length>3?c.substring(3):c));const x=i?h.map(c=>(0,f.normalizePath)(d.default.join(w,c))):h.map(c=>(0,f.normalizePath)(c));if(u===w)return x;const q=(0,f.normalizePath)(d.default.relative(w,u)),J=(0,F.getGlobMatcher)([`${q}/**`],{...g,absolute:i,cwd:w}),C=[];for(const c of x)J(c)&&C.push(c);return C}async function R(t){const n=p(t?.cwd).all;return await O(n,{__proto__:null,...t,porcelain:!0})}function j(t){const n=p(t?.cwd).all;return v(n,{__proto__:null,...t,porcelain:!0})}async function N(t){const n=p(t?.cwd).unstaged;return await O(n,t)}function U(t){const n=p(t?.cwd).unstaged;return v(n,t)}async function E(t){const n=p(t?.cwd).staged;return await O(n,t)}function K(t){const n=p(t?.cwd).staged;return v(n,t)}async function X(t,n){const e=await R({__proto__:null,...n,absolute:!1}),r=a().realpathSync(t),i=n?.cwd?a().realpathSync(n.cwd):l(),s=(0,f.normalizePath)(d.default.relative(i,r));return e.includes(s)}function Y(t,n){const e=j({__proto__:null,...n,absolute:!1}),r=a().realpathSync(t),i=n?.cwd?a().realpathSync(n.cwd):l(),s=(0,f.normalizePath)(d.default.relative(i,r));return e.includes(s)}async function Z(t,n){const e=await N({__proto__:null,...n,absolute:!1}),r=a().realpathSync(t),i=n?.cwd?a().realpathSync(n.cwd):l(),s=(0,f.normalizePath)(d.default.relative(i,r));return e.includes(s)}function tt(t,n){const e=U({__proto__:null,...n,absolute:!1}),r=a().realpathSync(t),i=n?.cwd?a().realpathSync(n.cwd):l(),s=(0,f.normalizePath)(d.default.relative(i,r));return e.includes(s)}async function nt(t,n){const e=await E({__proto__:null,...n,absolute:!1}),r=a().realpathSync(t),i=n?.cwd?a().realpathSync(n.cwd):l(),s=(0,f.normalizePath)(d.default.relative(i,r));return e.includes(s)}function et(t,n){const e=K({__proto__:null,...n,absolute:!1}),r=a().realpathSync(t),i=n?.cwd?a().realpathSync(n.cwd):l(),s=(0,f.normalizePath)(d.default.relative(i,r));return e.includes(s)}0&&(module.exports={findGitRoot,getChangedFiles,getChangedFilesSync,getStagedFiles,getStagedFilesSync,getUnstagedFiles,getUnstagedFilesSync,isChanged,isChangedSync,isStaged,isStagedSync,isUnstaged,isUnstagedSync});
4
4
  //# sourceMappingURL=git.js.map
package/dist/git.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/git.ts"],
4
- "sourcesContent": ["import path from 'node:path'\n\nimport { WIN32 } from '#constants/platform'\nimport { debugNs } from './debug'\nimport { getGlobMatcher } from './globs'\nimport { normalizePath } from './path'\nimport { spawn, spawnSync } from './spawn'\nimport { stripAnsi } from './strings'\n\n/**\n * Options for git diff operations.\n *\n * Controls how git diff results are processed and returned.\n *\n * @example\n * ```typescript\n * // Get absolute file paths\n * const files = await getChangedFiles({ absolute: true })\n * // => ['/path/to/repo/src/file.ts']\n *\n * // Get relative paths with caching disabled\n * const files = await getChangedFiles({ cache: false })\n * // => ['src/file.ts']\n *\n * // Get files from specific directory\n * const files = await getChangedFiles({ cwd: '/path/to/repo/src' })\n * ```\n */\nexport interface GitDiffOptions {\n /**\n * Return absolute file paths instead of relative paths.\n *\n * @default false\n */\n absolute?: boolean | undefined\n /**\n * Cache git diff results to avoid repeated git subprocess calls.\n *\n * Caching is keyed by the git command and options used, so different\n * option combinations maintain separate cache entries.\n *\n * @default true\n */\n cache?: boolean | undefined\n /**\n * Working directory for git operations.\n *\n * Git operations will be run from this directory, and returned paths\n * will be relative to the git repository root. Symlinks are resolved\n * using `fs.realpathSync()`.\n *\n * @default process.cwd()\n */\n cwd?: string | undefined\n /**\n * Parse git porcelain format output (status codes like `M`, `A`, `??`).\n *\n * When `true`, strips the two-character status code and space from the\n * beginning of each line. Automatically enabled for `getChangedFiles()`.\n *\n * @default false\n */\n porcelain?: boolean | undefined\n /**\n * Return results as a `Set` instead of an array.\n *\n * @default false\n */\n asSet?: boolean | undefined\n /**\n * Additional options passed to glob matcher.\n *\n * Supports options like `dot`, `ignore`, `nocase` for filtering results.\n */\n [key: string]: unknown\n}\n\n/**\n * Options for filtering packages by git changes.\n *\n * Used to determine which packages in a monorepo have changed files.\n *\n * @example\n * ```typescript\n * // Filter packages with changes\n * const changed = filterPackagesByChanges(packages)\n *\n * // Force include all packages\n * const all = filterPackagesByChanges(packages, { force: true })\n *\n * // Use custom package key\n * const changed = filterPackagesByChanges(\n * packages,\n * { packageKey: 'directory' }\n * )\n * ```\n */\nexport interface FilterPackagesByChangesOptions {\n /**\n * Force include all packages regardless of changes.\n *\n * @default false\n */\n force?: boolean | undefined\n /**\n * Key to access package path in package objects.\n *\n * @default 'path'\n */\n packageKey?: string | undefined\n /**\n * Additional options for filtering.\n */\n [key: string]: unknown\n}\n\ntype SpawnArgs = [string, string[], Record<string, unknown>]\n\ninterface GitDiffSpawnArgs {\n all: SpawnArgs\n unstaged: SpawnArgs\n staged: SpawnArgs\n}\n\nconst gitDiffCache = new Map<string, string[]>()\n\nlet _fs: typeof import('fs') | undefined\n/**\n * Lazily load the `fs` module to avoid Webpack errors.\n *\n * Uses non-`node:` prefixed require internally to prevent Webpack from\n * attempting to bundle Node.js built-in modules.\n *\n * @returns The Node.js `fs` module.\n *\n * @example\n * ```typescript\n * const fs = getFs()\n * const exists = fs.existsSync('/path/to/file')\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction getFs() {\n if (_fs === undefined) {\n // Use non-'node:' prefixed require to avoid Webpack errors.\n\n _fs = /*@__PURE__*/ require('node:fs')\n }\n return _fs as typeof import('fs')\n}\n\nlet _path: typeof import('path') | undefined\n/**\n * Lazily load the `path` module to avoid Webpack errors.\n *\n * Uses non-`node:` prefixed require internally to prevent Webpack from\n * attempting to bundle Node.js built-in modules.\n *\n * @returns The Node.js `path` module.\n *\n * @example\n * ```typescript\n * const path = getPath()\n * const joined = path.join('/foo', 'bar')\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction getPath() {\n if (_path === undefined) {\n _path = /*@__PURE__*/ require('node:path')\n }\n return _path as typeof import('path')\n}\n\n/**\n * Get the git executable path.\n *\n * Currently always returns `'git'`, relying on the system PATH to resolve\n * the git binary location. This may be extended in the future to support\n * custom git paths.\n *\n * @returns The git executable name or path.\n *\n * @example\n * ```typescript\n * const git = getGitPath()\n * // => 'git'\n * ```\n */\nfunction getGitPath(): string {\n return 'git'\n}\n\n/**\n * Get the current working directory for git operations.\n *\n * Returns the real path to handle symlinks correctly. This is important\n * because symlinked directories like `/tmp -> /private/tmp` can cause\n * path mismatches when comparing git output.\n *\n * @returns The resolved real path of `process.cwd()`.\n *\n * @example\n * ```typescript\n * const cwd = getCwd()\n * // In /tmp (symlink to /private/tmp):\n * // => '/private/tmp'\n * ```\n */\nfunction getCwd(): string {\n return getFs().realpathSync(process.cwd())\n}\n\n/**\n * Get spawn arguments for different git diff operations.\n *\n * Prepares argument arrays for `spawn()`/`spawnSync()` calls that retrieve:\n * - `all`: All changed files (staged, unstaged, untracked) via `git status --porcelain`\n * - `unstaged`: Unstaged modifications via `git diff --name-only`\n * - `staged`: Staged changes via `git diff --cached --name-only`\n *\n * Automatically resolves symlinks in the provided `cwd` and enables shell\n * mode on Windows for proper command execution.\n *\n * @param cwd - Working directory for git operations, defaults to `process.cwd()`.\n * @returns Object containing spawn arguments for all, unstaged, and staged operations.\n */\nfunction getGitDiffSpawnArgs(cwd?: string | undefined): GitDiffSpawnArgs {\n const resolvedCwd = cwd ? getFs().realpathSync(cwd) : getCwd()\n return {\n all: [\n getGitPath(),\n ['status', '--porcelain'],\n {\n cwd: resolvedCwd,\n shell: WIN32,\n },\n ],\n unstaged: [\n getGitPath(),\n ['diff', '--name-only'],\n {\n cwd: resolvedCwd,\n },\n ],\n staged: [\n getGitPath(),\n ['diff', '--cached', '--name-only'],\n {\n cwd: resolvedCwd,\n shell: WIN32,\n },\n ],\n }\n}\n\n/**\n * Execute git diff command asynchronously and parse results.\n *\n * Internal helper for async git operations. Handles caching, command execution,\n * and result parsing. Returns empty array on git command failure.\n *\n * @param args - Spawn arguments tuple `[command, args, options]`.\n * @param options - Git diff options for caching and parsing.\n * @returns Promise resolving to array of file paths.\n */\nasync function innerDiff(\n args: SpawnArgs,\n options?: GitDiffOptions | undefined,\n): Promise<string[]> {\n const { cache = true, ...parseOptions } = { __proto__: null, ...options }\n const cacheKey = cache ? JSON.stringify({ args, parseOptions }) : undefined\n if (cache && cacheKey) {\n const result = gitDiffCache.get(cacheKey)\n if (result) {\n return result\n }\n }\n let result: string[]\n try {\n // Use stdioString: false to get raw Buffer, then convert ourselves to preserve exact output.\n const spawnResult = await spawn(args[0], args[1], {\n ...args[2],\n stdioString: false,\n })\n const stdout = Buffer.isBuffer(spawnResult.stdout)\n ? spawnResult.stdout.toString('utf8')\n : String(spawnResult.stdout)\n // Extract spawn cwd from args to pass to parser\n const spawnCwd =\n typeof args[2]['cwd'] === 'string' ? args[2]['cwd'] : undefined\n result = parseGitDiffStdout(stdout, parseOptions, spawnCwd)\n } catch (e) {\n // Git command failed. This is expected if:\n // - Not in a git repository\n // - Git is not installed\n // - Permission issues accessing .git directory\n // Log warning in debug mode for troubleshooting.\n debugNs(\n 'git',\n `Git command failed (${args[0]} ${args[1].join(' ')}): ${(e as Error).message}`,\n )\n return []\n }\n if (cache && cacheKey) {\n gitDiffCache.set(cacheKey, result)\n }\n return result\n}\n\n/**\n * Execute git diff command synchronously and parse results.\n *\n * Internal helper for sync git operations. Handles caching, command execution,\n * and result parsing. Returns empty array on git command failure.\n *\n * @param args - Spawn arguments tuple `[command, args, options]`.\n * @param options - Git diff options for caching and parsing.\n * @returns Array of file paths.\n */\nfunction innerDiffSync(\n args: SpawnArgs,\n options?: GitDiffOptions | undefined,\n): string[] {\n const { cache = true, ...parseOptions } = { __proto__: null, ...options }\n const cacheKey = cache ? JSON.stringify({ args, parseOptions }) : undefined\n if (cache && cacheKey) {\n const result = gitDiffCache.get(cacheKey)\n if (result) {\n return result\n }\n }\n let result: string[]\n try {\n // Use stdioString: false to get raw Buffer, then convert ourselves to preserve exact output.\n const spawnResult = spawnSync(args[0], args[1], {\n ...args[2],\n stdioString: false,\n })\n const stdout = Buffer.isBuffer(spawnResult.stdout)\n ? spawnResult.stdout.toString('utf8')\n : String(spawnResult.stdout)\n // Extract spawn cwd from args to pass to parser\n const spawnCwd =\n typeof args[2]['cwd'] === 'string' ? args[2]['cwd'] : undefined\n result = parseGitDiffStdout(stdout, parseOptions, spawnCwd)\n } catch (e) {\n // Git command failed. This is expected if:\n // - Not in a git repository\n // - Git is not installed\n // - Permission issues accessing .git directory\n // Log warning in debug mode for troubleshooting.\n debugNs(\n 'git',\n `Git command failed (${args[0]} ${args[1].join(' ')}): ${(e as Error).message}`,\n )\n return []\n }\n if (cache && cacheKey) {\n gitDiffCache.set(cacheKey, result)\n }\n return result\n}\n\n/**\n * Find git repository root by walking up from the given directory.\n *\n * Searches for a `.git` directory or file by traversing parent directories\n * upward until found or filesystem root is reached. Returns the original path\n * if no git repository is found.\n *\n * This function is exported primarily for testing purposes.\n *\n * @param startPath - Directory path to start searching from.\n * @returns Git repository root path, or `startPath` if not found.\n *\n * @example\n * ```typescript\n * const root = findGitRoot('/path/to/repo/src/subdir')\n * // => '/path/to/repo'\n *\n * const notFound = findGitRoot('/not/a/repo')\n * // => '/not/a/repo'\n * ```\n */\nexport function findGitRoot(startPath: string): string {\n const fs = getFs()\n const path = getPath()\n let currentPath = startPath\n // Walk up the directory tree looking for .git\n while (true) {\n try {\n const gitPath = path.join(currentPath, '.git')\n if (fs.existsSync(gitPath)) {\n return currentPath\n }\n } catch {\n // Ignore errors and continue walking up\n }\n const parentPath = path.dirname(currentPath)\n // Stop if we've reached the root or can't go up anymore\n if (parentPath === currentPath) {\n // Return original path if no .git found\n return startPath\n }\n currentPath = parentPath\n }\n}\n\n/**\n * Parse git diff stdout output into file path array.\n *\n * Internal helper that processes raw git command output by:\n * 1. Finding git repository root from spawn cwd\n * 2. Stripping ANSI codes and splitting into lines\n * 3. Parsing porcelain format status codes if requested\n * 4. Normalizing and optionally making paths absolute\n * 5. Filtering paths based on cwd and glob options\n *\n * Git always returns paths relative to the repository root, regardless of\n * where the command was executed. This function handles the path resolution\n * correctly by finding the repo root and adjusting paths accordingly.\n *\n * @param stdout - Raw stdout from git command.\n * @param options - Git diff options for path processing.\n * @param spawnCwd - Working directory where git command was executed.\n * @returns Array of processed file paths.\n */\nfunction parseGitDiffStdout(\n stdout: string,\n options?: GitDiffOptions | undefined,\n spawnCwd?: string | undefined,\n): string[] {\n // Find git repo root from spawnCwd. Git always returns paths relative to the repo root,\n // not the cwd where it was run. So we need to find the repo root to correctly parse paths.\n const defaultRoot = spawnCwd ? findGitRoot(spawnCwd) : getCwd()\n const {\n absolute = false,\n cwd: cwdOption = defaultRoot,\n porcelain = false,\n ...matcherOptions\n } = { __proto__: null, ...options }\n // Resolve cwd to handle symlinks.\n const cwd =\n cwdOption === defaultRoot ? defaultRoot : getFs().realpathSync(cwdOption)\n const rootPath = defaultRoot\n // Split into lines without trimming to preserve leading spaces in porcelain format.\n let rawFiles = stdout\n ? stripAnsi(stdout)\n .split('\\n')\n .map(line => line.trimEnd())\n .filter(line => line)\n : []\n // Parse porcelain format: strip status codes.\n // Git status --porcelain format is: XY filename\n // where X and Y are single characters and there's a space before the filename.\n if (porcelain) {\n rawFiles = rawFiles.map(line => {\n // Status is first 2 chars, then space, then filename.\n return line.length > 3 ? line.substring(3) : line\n })\n }\n const files = absolute\n ? rawFiles.map(relPath => normalizePath(path.join(rootPath, relPath)))\n : rawFiles.map(relPath => normalizePath(relPath))\n if (cwd === rootPath) {\n return files\n }\n const relPath = normalizePath(path.relative(rootPath, cwd))\n const matcher = getGlobMatcher([`${relPath}/**`], {\n ...(matcherOptions as {\n dot?: boolean\n ignore?: string[]\n nocase?: boolean\n }),\n absolute,\n cwd: rootPath,\n } as {\n absolute?: boolean\n cwd?: string\n dot?: boolean\n ignore?: string[]\n nocase?: boolean\n })\n const filtered: string[] = []\n for (const filepath of files) {\n if (matcher(filepath)) {\n filtered.push(filepath)\n }\n }\n return filtered\n}\n\n/**\n * Get all changed files including staged, unstaged, and untracked files.\n *\n * Uses `git status --porcelain` which returns the full working tree status\n * with status codes:\n * - `M` - Modified\n * - `A` - Added\n * - `D` - Deleted\n * - `??` - Untracked\n * - `R` - Renamed\n * - `C` - Copied\n *\n * This is the most comprehensive check - captures everything that differs\n * from the last commit, including:\n * - Files modified and staged with `git add`\n * - Files modified but not staged\n * - New files not yet tracked by git\n *\n * Status codes are automatically stripped from the output.\n *\n * @param options - Options controlling path format and filtering.\n * @returns Promise resolving to array of changed file paths.\n *\n * @example\n * ```typescript\n * // Get all changed files as relative paths\n * const files = await getChangedFiles()\n * // => ['src/foo.ts', 'src/bar.ts', 'newfile.ts']\n *\n * // Get absolute paths\n * const files = await getChangedFiles({ absolute: true })\n * // => ['/path/to/repo/src/foo.ts', ...]\n *\n * // Get changed files in specific directory\n * const files = await getChangedFiles({ cwd: '/path/to/repo/src' })\n * // => ['foo.ts', 'bar.ts']\n * ```\n */\nexport async function getChangedFiles(\n options?: GitDiffOptions | undefined,\n): Promise<string[]> {\n const args = getGitDiffSpawnArgs(options?.cwd).all\n return await innerDiff(args, {\n __proto__: null,\n ...options,\n porcelain: true,\n })\n}\n\n/**\n * Get all changed files including staged, unstaged, and untracked files.\n *\n * Synchronous version of `getChangedFiles()`. Uses `git status --porcelain`\n * which returns the full working tree status with status codes:\n * - `M` - Modified\n * - `A` - Added\n * - `D` - Deleted\n * - `??` - Untracked\n * - `R` - Renamed\n * - `C` - Copied\n *\n * This is the most comprehensive check - captures everything that differs\n * from the last commit, including:\n * - Files modified and staged with `git add`\n * - Files modified but not staged\n * - New files not yet tracked by git\n *\n * Status codes are automatically stripped from the output.\n *\n * @param options - Options controlling path format and filtering.\n * @returns Array of changed file paths.\n *\n * @example\n * ```typescript\n * // Get all changed files as relative paths\n * const files = getChangedFilesSync()\n * // => ['src/foo.ts', 'src/bar.ts', 'newfile.ts']\n *\n * // Get absolute paths\n * const files = getChangedFilesSync({ absolute: true })\n * // => ['/path/to/repo/src/foo.ts', ...]\n *\n * // Get changed files in specific directory\n * const files = getChangedFilesSync({ cwd: '/path/to/repo/src' })\n * // => ['foo.ts', 'bar.ts']\n * ```\n */\nexport function getChangedFilesSync(\n options?: GitDiffOptions | undefined,\n): string[] {\n const args = getGitDiffSpawnArgs(options?.cwd).all\n return innerDiffSync(args, {\n __proto__: null,\n ...options,\n porcelain: true,\n })\n}\n\n/**\n * Get unstaged modified files (changes not yet staged for commit).\n *\n * Uses `git diff --name-only` which returns only unstaged modifications\n * to tracked files. Does NOT include:\n * - Untracked files (new files not added to git)\n * - Staged changes (files added with `git add`)\n *\n * This is a focused check for uncommitted changes to existing tracked files.\n * Useful for detecting work-in-progress modifications before staging.\n *\n * @param options - Options controlling path format and filtering.\n * @returns Promise resolving to array of unstaged file paths.\n *\n * @example\n * ```typescript\n * // Get unstaged files\n * const files = await getUnstagedFiles()\n * // => ['src/foo.ts', 'src/bar.ts']\n *\n * // After staging some files\n * await spawn('git', ['add', 'src/foo.ts'])\n * const files = await getUnstagedFiles()\n * // => ['src/bar.ts'] (foo.ts no longer included)\n *\n * // Get absolute paths\n * const files = await getUnstagedFiles({ absolute: true })\n * // => ['/path/to/repo/src/bar.ts']\n * ```\n */\nexport async function getUnstagedFiles(\n options?: GitDiffOptions | undefined,\n): Promise<string[]> {\n const args = getGitDiffSpawnArgs(options?.cwd).unstaged\n return await innerDiff(args, options)\n}\n\n/**\n * Get unstaged modified files (changes not yet staged for commit).\n *\n * Synchronous version of `getUnstagedFiles()`. Uses `git diff --name-only`\n * which returns only unstaged modifications to tracked files. Does NOT include:\n * - Untracked files (new files not added to git)\n * - Staged changes (files added with `git add`)\n *\n * This is a focused check for uncommitted changes to existing tracked files.\n * Useful for detecting work-in-progress modifications before staging.\n *\n * @param options - Options controlling path format and filtering.\n * @returns Array of unstaged file paths.\n *\n * @example\n * ```typescript\n * // Get unstaged files\n * const files = getUnstagedFilesSync()\n * // => ['src/foo.ts', 'src/bar.ts']\n *\n * // After staging some files\n * spawnSync('git', ['add', 'src/foo.ts'])\n * const files = getUnstagedFilesSync()\n * // => ['src/bar.ts'] (foo.ts no longer included)\n *\n * // Get absolute paths\n * const files = getUnstagedFilesSync({ absolute: true })\n * // => ['/path/to/repo/src/bar.ts']\n * ```\n */\nexport function getUnstagedFilesSync(\n options?: GitDiffOptions | undefined,\n): string[] {\n const args = getGitDiffSpawnArgs(options?.cwd).unstaged\n return innerDiffSync(args, options)\n}\n\n/**\n * Get staged files ready for commit (changes added with `git add`).\n *\n * Uses `git diff --cached --name-only` which returns only staged changes.\n * Does NOT include:\n * - Unstaged modifications (changes not added with `git add`)\n * - Untracked files (new files not added to git)\n *\n * This is a focused check for what will be included in the next commit.\n * Useful for validating changes before committing or running pre-commit hooks.\n *\n * @param options - Options controlling path format and filtering.\n * @returns Promise resolving to array of staged file paths.\n *\n * @example\n * ```typescript\n * // Get currently staged files\n * const files = await getStagedFiles()\n * // => ['src/foo.ts']\n *\n * // Stage more files\n * await spawn('git', ['add', 'src/bar.ts'])\n * const files = await getStagedFiles()\n * // => ['src/foo.ts', 'src/bar.ts']\n *\n * // Get absolute paths\n * const files = await getStagedFiles({ absolute: true })\n * // => ['/path/to/repo/src/foo.ts', ...]\n * ```\n */\nexport async function getStagedFiles(\n options?: GitDiffOptions | undefined,\n): Promise<string[]> {\n const args = getGitDiffSpawnArgs(options?.cwd).staged\n return await innerDiff(args, options)\n}\n\n/**\n * Get staged files ready for commit (changes added with `git add`).\n *\n * Synchronous version of `getStagedFiles()`. Uses `git diff --cached --name-only`\n * which returns only staged changes. Does NOT include:\n * - Unstaged modifications (changes not added with `git add`)\n * - Untracked files (new files not added to git)\n *\n * This is a focused check for what will be included in the next commit.\n * Useful for validating changes before committing or running pre-commit hooks.\n *\n * @param options - Options controlling path format and filtering.\n * @returns Array of staged file paths.\n *\n * @example\n * ```typescript\n * // Get currently staged files\n * const files = getStagedFilesSync()\n * // => ['src/foo.ts']\n *\n * // Stage more files\n * spawnSync('git', ['add', 'src/bar.ts'])\n * const files = getStagedFilesSync()\n * // => ['src/foo.ts', 'src/bar.ts']\n *\n * // Get absolute paths\n * const files = getStagedFilesSync({ absolute: true })\n * // => ['/path/to/repo/src/foo.ts', ...]\n * ```\n */\nexport function getStagedFilesSync(\n options?: GitDiffOptions | undefined,\n): string[] {\n const args = getGitDiffSpawnArgs(options?.cwd).staged\n return innerDiffSync(args, options)\n}\n\n/**\n * Check if a file or directory has any git changes.\n *\n * Checks if the given pathname has any changes including:\n * - Staged modifications (added with `git add`)\n * - Unstaged modifications (not yet staged)\n * - Untracked status (new file/directory not in git)\n *\n * For directories, returns `true` if ANY file within the directory has changes.\n *\n * Symlinks in the pathname and cwd are automatically resolved using\n * `fs.realpathSync()` before comparison.\n *\n * @param pathname - File or directory path to check.\n * @param options - Options for the git status check.\n * @returns Promise resolving to `true` if path has any changes, `false` otherwise.\n *\n * @example\n * ```typescript\n * // Check if file is changed\n * const changed = await isChanged('src/foo.ts')\n * // => true\n *\n * // Check if directory has any changes\n * const changed = await isChanged('src/')\n * // => true (if any file in src/ is changed)\n *\n * // Check from different cwd\n * const changed = await isChanged(\n * '/path/to/repo/src/foo.ts',\n * { cwd: '/path/to/repo' }\n * )\n * ```\n */\nexport async function isChanged(\n pathname: string,\n options?: GitDiffOptions | undefined,\n): Promise<boolean> {\n const files = await getChangedFiles({\n __proto__: null,\n ...options,\n absolute: false,\n })\n // Resolve pathname to handle symlinks before computing relative path.\n const resolvedPathname = getFs().realpathSync(pathname)\n const baseCwd = options?.cwd ? getFs().realpathSync(options['cwd']) : getCwd()\n const relativePath = normalizePath(path.relative(baseCwd, resolvedPathname))\n return files.includes(relativePath)\n}\n\n/**\n * Check if a file or directory has any git changes.\n *\n * Synchronous version of `isChanged()`. Checks if the given pathname has\n * any changes including:\n * - Staged modifications (added with `git add`)\n * - Unstaged modifications (not yet staged)\n * - Untracked status (new file/directory not in git)\n *\n * For directories, returns `true` if ANY file within the directory has changes.\n *\n * Symlinks in the pathname and cwd are automatically resolved using\n * `fs.realpathSync()` before comparison.\n *\n * @param pathname - File or directory path to check.\n * @param options - Options for the git status check.\n * @returns `true` if path has any changes, `false` otherwise.\n *\n * @example\n * ```typescript\n * // Check if file is changed\n * const changed = isChangedSync('src/foo.ts')\n * // => true\n *\n * // Check if directory has any changes\n * const changed = isChangedSync('src/')\n * // => true (if any file in src/ is changed)\n *\n * // Check from different cwd\n * const changed = isChangedSync(\n * '/path/to/repo/src/foo.ts',\n * { cwd: '/path/to/repo' }\n * )\n * ```\n */\nexport function isChangedSync(\n pathname: string,\n options?: GitDiffOptions | undefined,\n): boolean {\n const files = getChangedFilesSync({\n __proto__: null,\n ...options,\n absolute: false,\n })\n // Resolve pathname to handle symlinks before computing relative path.\n const resolvedPathname = getFs().realpathSync(pathname)\n const baseCwd = options?.cwd ? getFs().realpathSync(options['cwd']) : getCwd()\n const relativePath = normalizePath(path.relative(baseCwd, resolvedPathname))\n return files.includes(relativePath)\n}\n\n/**\n * Check if a file or directory has unstaged changes.\n *\n * Checks if the given pathname has modifications that are not yet staged\n * for commit (changes not added with `git add`). Does NOT include:\n * - Staged changes (already added with `git add`)\n * - Untracked files (new files not in git)\n *\n * For directories, returns `true` if ANY file within the directory has\n * unstaged changes.\n *\n * Symlinks in the pathname and cwd are automatically resolved using\n * `fs.realpathSync()` before comparison.\n *\n * @param pathname - File or directory path to check.\n * @param options - Options for the git diff check.\n * @returns Promise resolving to `true` if path has unstaged changes, `false` otherwise.\n *\n * @example\n * ```typescript\n * // Check if file has unstaged changes\n * const unstaged = await isUnstaged('src/foo.ts')\n * // => true\n *\n * // After staging the file\n * await spawn('git', ['add', 'src/foo.ts'])\n * const unstaged = await isUnstaged('src/foo.ts')\n * // => false\n *\n * // Check directory\n * const unstaged = await isUnstaged('src/')\n * // => true (if any file in src/ has unstaged changes)\n * ```\n */\nexport async function isUnstaged(\n pathname: string,\n options?: GitDiffOptions | undefined,\n): Promise<boolean> {\n const files = await getUnstagedFiles({\n __proto__: null,\n ...options,\n absolute: false,\n })\n // Resolve pathname to handle symlinks before computing relative path.\n const resolvedPathname = getFs().realpathSync(pathname)\n const baseCwd = options?.cwd ? getFs().realpathSync(options['cwd']) : getCwd()\n const relativePath = normalizePath(path.relative(baseCwd, resolvedPathname))\n return files.includes(relativePath)\n}\n\n/**\n * Check if a file or directory has unstaged changes.\n *\n * Synchronous version of `isUnstaged()`. Checks if the given pathname has\n * modifications that are not yet staged for commit (changes not added with\n * `git add`). Does NOT include:\n * - Staged changes (already added with `git add`)\n * - Untracked files (new files not in git)\n *\n * For directories, returns `true` if ANY file within the directory has\n * unstaged changes.\n *\n * Symlinks in the pathname and cwd are automatically resolved using\n * `fs.realpathSync()` before comparison.\n *\n * @param pathname - File or directory path to check.\n * @param options - Options for the git diff check.\n * @returns `true` if path has unstaged changes, `false` otherwise.\n *\n * @example\n * ```typescript\n * // Check if file has unstaged changes\n * const unstaged = isUnstagedSync('src/foo.ts')\n * // => true\n *\n * // After staging the file\n * spawnSync('git', ['add', 'src/foo.ts'])\n * const unstaged = isUnstagedSync('src/foo.ts')\n * // => false\n *\n * // Check directory\n * const unstaged = isUnstagedSync('src/')\n * // => true (if any file in src/ has unstaged changes)\n * ```\n */\nexport function isUnstagedSync(\n pathname: string,\n options?: GitDiffOptions | undefined,\n): boolean {\n const files = getUnstagedFilesSync({\n __proto__: null,\n ...options,\n absolute: false,\n })\n // Resolve pathname to handle symlinks before computing relative path.\n const resolvedPathname = getFs().realpathSync(pathname)\n const baseCwd = options?.cwd ? getFs().realpathSync(options['cwd']) : getCwd()\n const relativePath = normalizePath(path.relative(baseCwd, resolvedPathname))\n return files.includes(relativePath)\n}\n\n/**\n * Check if a file or directory is staged for commit.\n *\n * Checks if the given pathname has changes staged with `git add` that will\n * be included in the next commit. Does NOT include:\n * - Unstaged modifications (changes not added with `git add`)\n * - Untracked files (new files not in git)\n *\n * For directories, returns `true` if ANY file within the directory is staged.\n *\n * Symlinks in the pathname and cwd are automatically resolved using\n * `fs.realpathSync()` before comparison.\n *\n * @param pathname - File or directory path to check.\n * @param options - Options for the git diff check.\n * @returns Promise resolving to `true` if path is staged, `false` otherwise.\n *\n * @example\n * ```typescript\n * // Check if file is staged\n * const staged = await isStaged('src/foo.ts')\n * // => false\n *\n * // Stage the file\n * await spawn('git', ['add', 'src/foo.ts'])\n * const staged = await isStaged('src/foo.ts')\n * // => true\n *\n * // Check directory\n * const staged = await isStaged('src/')\n * // => true (if any file in src/ is staged)\n * ```\n */\nexport async function isStaged(\n pathname: string,\n options?: GitDiffOptions | undefined,\n): Promise<boolean> {\n const files = await getStagedFiles({\n __proto__: null,\n ...options,\n absolute: false,\n })\n // Resolve pathname to handle symlinks before computing relative path.\n const resolvedPathname = getFs().realpathSync(pathname)\n const baseCwd = options?.cwd ? getFs().realpathSync(options['cwd']) : getCwd()\n const relativePath = normalizePath(path.relative(baseCwd, resolvedPathname))\n return files.includes(relativePath)\n}\n\n/**\n * Check if a file or directory is staged for commit.\n *\n * Synchronous version of `isStaged()`. Checks if the given pathname has\n * changes staged with `git add` that will be included in the next commit.\n * Does NOT include:\n * - Unstaged modifications (changes not added with `git add`)\n * - Untracked files (new files not in git)\n *\n * For directories, returns `true` if ANY file within the directory is staged.\n *\n * Symlinks in the pathname and cwd are automatically resolved using\n * `fs.realpathSync()` before comparison.\n *\n * @param pathname - File or directory path to check.\n * @param options - Options for the git diff check.\n * @returns `true` if path is staged, `false` otherwise.\n *\n * @example\n * ```typescript\n * // Check if file is staged\n * const staged = isStagedSync('src/foo.ts')\n * // => false\n *\n * // Stage the file\n * spawnSync('git', ['add', 'src/foo.ts'])\n * const staged = isStagedSync('src/foo.ts')\n * // => true\n *\n * // Check directory\n * const staged = isStagedSync('src/')\n * // => true (if any file in src/ is staged)\n * ```\n */\nexport function isStagedSync(\n pathname: string,\n options?: GitDiffOptions | undefined,\n): boolean {\n const files = getStagedFilesSync({\n __proto__: null,\n ...options,\n absolute: false,\n })\n // Resolve pathname to handle symlinks before computing relative path.\n const resolvedPathname = getFs().realpathSync(pathname)\n const baseCwd = options?.cwd ? getFs().realpathSync(options['cwd']) : getCwd()\n const relativePath = normalizePath(path.relative(baseCwd, resolvedPathname))\n return files.includes(relativePath)\n}\n"],
5
- "mappings": ";6iBAAA,IAAAA,GAAA,GAAAC,EAAAD,GAAA,iBAAAE,EAAA,oBAAAC,EAAA,wBAAAC,EAAA,mBAAAC,EAAA,uBAAAC,EAAA,qBAAAC,EAAA,yBAAAC,EAAA,cAAAC,EAAA,kBAAAC,EAAA,aAAAC,GAAA,iBAAAC,GAAA,eAAAC,EAAA,mBAAAC,KAAA,eAAAC,EAAAf,IAAA,IAAAgB,EAAiB,wBAEjBC,EAAsB,+BACtBC,EAAwB,mBACxBC,EAA+B,mBAC/BC,EAA8B,kBAC9BC,EAAiC,mBACjCC,EAA0B,qBAqH1B,MAAMC,EAAe,IAAI,IAEzB,IAAIC,EAgBJ,SAASC,GAAQ,CACf,OAAID,IAAQ,SAGVA,EAAoB,QAAQ,SAAS,GAEhCA,CACT,CAEA,IAAIE,EAgBJ,SAASC,GAAU,CACjB,OAAID,IAAU,SACZA,EAAsB,QAAQ,WAAW,GAEpCA,CACT,CAiBA,SAASE,GAAqB,CAC5B,MAAO,KACT,CAkBA,SAASC,GAAiB,CACxB,OAAOJ,EAAM,EAAE,aAAa,QAAQ,IAAI,CAAC,CAC3C,CAgBA,SAASK,EAAoBC,EAA4C,CACvE,MAAMC,EAAcD,EAAMN,EAAM,EAAE,aAAaM,CAAG,EAAIF,EAAO,EAC7D,MAAO,CACL,IAAK,CACHD,EAAW,EACX,CAAC,SAAU,aAAa,EACxB,CACE,IAAKI,EACL,MAAO,OACT,CACF,EACA,SAAU,CACRJ,EAAW,EACX,CAAC,OAAQ,aAAa,E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K,SAASmB,EAASD,CAAgB,CAAC,EAC3E,OAAON,EAAM,SAASQ,CAAY,CACpC,CAqCO,SAAStD,GACdmD,EACA9B,EACS,CACT,MAAMyB,EAAQpD,EAAqB,CACjC,UAAW,KACX,GAAG2B,EACH,SAAU,EACZ,CAAC,EAEK+B,EAAmBzC,EAAM,EAAE,aAAawC,CAAQ,EAChDE,EAAUhC,GAAS,IAAMV,EAAM,EAAE,aAAaU,EAAQ,GAAM,EAAIN,EAAO,EACvEuC,KAAe,iBAAc,EAAApB,QAAK,SAASmB,EAASD,CAAgB,CAAC,EAC3E,OAAON,EAAM,SAASQ,CAAY,CACpC,CAmCA,eAAsBzD,GACpBsD,EACA9B,EACkB,CAClB,MAAMyB,EAAQ,MAAMvD,EAAe,CACjC,UAAW,KACX,GAAG8B,EACH,SAAU,EACZ,CAAC,EAEK+B,EAAmBzC,EAAM,EAAE,aAAawC,CAAQ,EAChDE,EAAUhC,GAAS,IAAMV,EAAM,EAAE,aAAaU,EAAQ,GAAM,EAAIN,EAAO,EACvEuC,KAAe,iBAAc,EAAApB,QAAK,SAASmB,EAASD,CAAgB,CAAC,EAC3E,OAAON,EAAM,SAASQ,CAAY,CACpC,CAoCO,SAASxD,GACdqD,EACA9B,EACS,CACT,MAAMyB,EAAQtD,EAAmB,CAC/B,UAAW,KACX,GAAG6B,EACH,SAAU,EACZ,CAAC,EAEK+B,EAAmBzC,EAAM,EAAE,aAAawC,CAAQ,EAChDE,EAAUhC,GAAS,IAAMV,EAAM,EAAE,aAAaU,EAAQ,GAAM,EAAIN,EAAO,EACvEuC,KAAe,iBAAc,EAAApB,QAAK,SAASmB,EAASD,CAAgB,CAAC,EAC3E,OAAON,EAAM,SAASQ,CAAY,CACpC",
6
- "names": ["git_exports", "__export", "findGitRoot", "getChangedFiles", "getChangedFilesSync", "getStagedFiles", "getStagedFilesSync", "getUnstagedFiles", "getUnstagedFilesSync", "isChanged", "isChangedSync", "isStaged", "isStagedSync", "isUnstaged", "isUnstagedSync", "__toCommonJS", "import_node_path", "import_platform", "import_debug", "import_globs", "import_path", "import_spawn", "import_strings", "gitDiffCache", "_fs", "getFs", "_path", "getPath", "getGitPath", "getCwd", "getGitDiffSpawnArgs", "cwd", "resolvedCwd", "innerDiff", "args", "options", "cache", "parseOptions", "cacheKey", "result", "spawnResult", "stdout", "spawnCwd", "parseGitDiffStdout", "e", "innerDiffSync", "startPath", "fs", "path", "currentPath", "gitPath", "parentPath", "defaultRoot", "absolute", "cwdOption", "porcelain", "matcherOptions", "rootPath", "rawFiles", "line", "files", "relPath", "matcher", "filtered", "filepath", "pathname", "resolvedPathname", "baseCwd", "relativePath"]
4
+ "sourcesContent": ["import path from 'path'\n\nimport { WIN32 } from '#constants/platform'\nimport { debugNs } from './debug'\nimport { getGlobMatcher } from './globs'\nimport { normalizePath } from './path'\nimport { spawn, spawnSync } from './spawn'\nimport { stripAnsi } from './strings'\n\n/**\n * Options for git diff operations.\n *\n * Controls how git diff results are processed and returned.\n *\n * @example\n * ```typescript\n * // Get absolute file paths\n * const files = await getChangedFiles({ absolute: true })\n * // => ['/path/to/repo/src/file.ts']\n *\n * // Get relative paths with caching disabled\n * const files = await getChangedFiles({ cache: false })\n * // => ['src/file.ts']\n *\n * // Get files from specific directory\n * const files = await getChangedFiles({ cwd: '/path/to/repo/src' })\n * ```\n */\nexport interface GitDiffOptions {\n /**\n * Return absolute file paths instead of relative paths.\n *\n * @default false\n */\n absolute?: boolean | undefined\n /**\n * Cache git diff results to avoid repeated git subprocess calls.\n *\n * Caching is keyed by the git command and options used, so different\n * option combinations maintain separate cache entries.\n *\n * @default true\n */\n cache?: boolean | undefined\n /**\n * Working directory for git operations.\n *\n * Git operations will be run from this directory, and returned paths\n * will be relative to the git repository root. Symlinks are resolved\n * using `fs.realpathSync()`.\n *\n * @default process.cwd()\n */\n cwd?: string | undefined\n /**\n * Parse git porcelain format output (status codes like `M`, `A`, `??`).\n *\n * When `true`, strips the two-character status code and space from the\n * beginning of each line. Automatically enabled for `getChangedFiles()`.\n *\n * @default false\n */\n porcelain?: boolean | undefined\n /**\n * Return results as a `Set` instead of an array.\n *\n * @default false\n */\n asSet?: boolean | undefined\n /**\n * Additional options passed to glob matcher.\n *\n * Supports options like `dot`, `ignore`, `nocase` for filtering results.\n */\n [key: string]: unknown\n}\n\n/**\n * Options for filtering packages by git changes.\n *\n * Used to determine which packages in a monorepo have changed files.\n *\n * @example\n * ```typescript\n * // Filter packages with changes\n * const changed = filterPackagesByChanges(packages)\n *\n * // Force include all packages\n * const all = filterPackagesByChanges(packages, { force: true })\n *\n * // Use custom package key\n * const changed = filterPackagesByChanges(\n * packages,\n * { packageKey: 'directory' }\n * )\n * ```\n */\nexport interface FilterPackagesByChangesOptions {\n /**\n * Force include all packages regardless of changes.\n *\n * @default false\n */\n force?: boolean | undefined\n /**\n * Key to access package path in package objects.\n *\n * @default 'path'\n */\n packageKey?: string | undefined\n /**\n * Additional options for filtering.\n */\n [key: string]: unknown\n}\n\ntype SpawnArgs = [string, string[], Record<string, unknown>]\n\ninterface GitDiffSpawnArgs {\n all: SpawnArgs\n unstaged: SpawnArgs\n staged: SpawnArgs\n}\n\nconst gitDiffCache = new Map<string, string[]>()\n\nlet _fs: typeof import('fs') | undefined\n/**\n * Lazily load the `fs` module to avoid Webpack errors.\n *\n * Uses non-`node:` prefixed require internally to prevent Webpack from\n * attempting to bundle Node.js built-in modules.\n *\n * @returns The Node.js `fs` module.\n *\n * @example\n * ```typescript\n * const fs = getFs()\n * const exists = fs.existsSync('/path/to/file')\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction getFs() {\n if (_fs === undefined) {\n // Use non-'node:' prefixed require to avoid Webpack errors.\n\n _fs = /*@__PURE__*/ require('node:fs')\n }\n return _fs as typeof import('fs')\n}\n\nlet _path: typeof import('path') | undefined\n/**\n * Lazily load the `path` module to avoid Webpack errors.\n *\n * Uses non-`node:` prefixed require internally to prevent Webpack from\n * attempting to bundle Node.js built-in modules.\n *\n * @returns The Node.js `path` module.\n *\n * @example\n * ```typescript\n * const path = getPath()\n * const joined = path.join('/foo', 'bar')\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction getPath() {\n if (_path === undefined) {\n _path = /*@__PURE__*/ require('node:path')\n }\n return _path as typeof import('path')\n}\n\n/**\n * Get the git executable path.\n *\n * Currently always returns `'git'`, relying on the system PATH to resolve\n * the git binary location. This may be extended in the future to support\n * custom git paths.\n *\n * @returns The git executable name or path.\n *\n * @example\n * ```typescript\n * const git = getGitPath()\n * // => 'git'\n * ```\n */\nfunction getGitPath(): string {\n return 'git'\n}\n\n/**\n * Get the current working directory for git operations.\n *\n * Returns the real path to handle symlinks correctly. This is important\n * because symlinked directories like `/tmp -> /private/tmp` can cause\n * path mismatches when comparing git output.\n *\n * @returns The resolved real path of `process.cwd()`.\n *\n * @example\n * ```typescript\n * const cwd = getCwd()\n * // In /tmp (symlink to /private/tmp):\n * // => '/private/tmp'\n * ```\n */\nfunction getCwd(): string {\n return getFs().realpathSync(process.cwd())\n}\n\n/**\n * Get spawn arguments for different git diff operations.\n *\n * Prepares argument arrays for `spawn()`/`spawnSync()` calls that retrieve:\n * - `all`: All changed files (staged, unstaged, untracked) via `git status --porcelain`\n * - `unstaged`: Unstaged modifications via `git diff --name-only`\n * - `staged`: Staged changes via `git diff --cached --name-only`\n *\n * Automatically resolves symlinks in the provided `cwd` and enables shell\n * mode on Windows for proper command execution.\n *\n * @param cwd - Working directory for git operations, defaults to `process.cwd()`.\n * @returns Object containing spawn arguments for all, unstaged, and staged operations.\n */\nfunction getGitDiffSpawnArgs(cwd?: string | undefined): GitDiffSpawnArgs {\n const resolvedCwd = cwd ? getFs().realpathSync(cwd) : getCwd()\n return {\n all: [\n getGitPath(),\n ['status', '--porcelain'],\n {\n cwd: resolvedCwd,\n shell: WIN32,\n },\n ],\n unstaged: [\n getGitPath(),\n ['diff', '--name-only'],\n {\n cwd: resolvedCwd,\n },\n ],\n staged: [\n getGitPath(),\n ['diff', '--cached', '--name-only'],\n {\n cwd: resolvedCwd,\n shell: WIN32,\n },\n ],\n }\n}\n\n/**\n * Execute git diff command asynchronously and parse results.\n *\n * Internal helper for async git operations. Handles caching, command execution,\n * and result parsing. Returns empty array on git command failure.\n *\n * @param args - Spawn arguments tuple `[command, args, options]`.\n * @param options - Git diff options for caching and parsing.\n * @returns Promise resolving to array of file paths.\n */\nasync function innerDiff(\n args: SpawnArgs,\n options?: GitDiffOptions | undefined,\n): Promise<string[]> {\n const { cache = true, ...parseOptions } = { __proto__: null, ...options }\n const cacheKey = cache ? JSON.stringify({ args, parseOptions }) : undefined\n if (cache && cacheKey) {\n const result = gitDiffCache.get(cacheKey)\n if (result) {\n return result\n }\n }\n let result: string[]\n try {\n // Use stdioString: false to get raw Buffer, then convert ourselves to preserve exact output.\n const spawnResult = await spawn(args[0], args[1], {\n ...args[2],\n stdioString: false,\n })\n const stdout = Buffer.isBuffer(spawnResult.stdout)\n ? spawnResult.stdout.toString('utf8')\n : String(spawnResult.stdout)\n // Extract spawn cwd from args to pass to parser\n const spawnCwd =\n typeof args[2]['cwd'] === 'string' ? args[2]['cwd'] : undefined\n result = parseGitDiffStdout(stdout, parseOptions, spawnCwd)\n } catch (e) {\n // Git command failed. This is expected if:\n // - Not in a git repository\n // - Git is not installed\n // - Permission issues accessing .git directory\n // Log warning in debug mode for troubleshooting.\n debugNs(\n 'git',\n `Git command failed (${args[0]} ${args[1].join(' ')}): ${(e as Error).message}`,\n )\n return []\n }\n if (cache && cacheKey) {\n gitDiffCache.set(cacheKey, result)\n }\n return result\n}\n\n/**\n * Execute git diff command synchronously and parse results.\n *\n * Internal helper for sync git operations. Handles caching, command execution,\n * and result parsing. Returns empty array on git command failure.\n *\n * @param args - Spawn arguments tuple `[command, args, options]`.\n * @param options - Git diff options for caching and parsing.\n * @returns Array of file paths.\n */\nfunction innerDiffSync(\n args: SpawnArgs,\n options?: GitDiffOptions | undefined,\n): string[] {\n const { cache = true, ...parseOptions } = { __proto__: null, ...options }\n const cacheKey = cache ? JSON.stringify({ args, parseOptions }) : undefined\n if (cache && cacheKey) {\n const result = gitDiffCache.get(cacheKey)\n if (result) {\n return result\n }\n }\n let result: string[]\n try {\n // Use stdioString: false to get raw Buffer, then convert ourselves to preserve exact output.\n const spawnResult = spawnSync(args[0], args[1], {\n ...args[2],\n stdioString: false,\n })\n const stdout = Buffer.isBuffer(spawnResult.stdout)\n ? spawnResult.stdout.toString('utf8')\n : String(spawnResult.stdout)\n // Extract spawn cwd from args to pass to parser\n const spawnCwd =\n typeof args[2]['cwd'] === 'string' ? args[2]['cwd'] : undefined\n result = parseGitDiffStdout(stdout, parseOptions, spawnCwd)\n } catch (e) {\n // Git command failed. This is expected if:\n // - Not in a git repository\n // - Git is not installed\n // - Permission issues accessing .git directory\n // Log warning in debug mode for troubleshooting.\n debugNs(\n 'git',\n `Git command failed (${args[0]} ${args[1].join(' ')}): ${(e as Error).message}`,\n )\n return []\n }\n if (cache && cacheKey) {\n gitDiffCache.set(cacheKey, result)\n }\n return result\n}\n\n/**\n * Find git repository root by walking up from the given directory.\n *\n * Searches for a `.git` directory or file by traversing parent directories\n * upward until found or filesystem root is reached. Returns the original path\n * if no git repository is found.\n *\n * This function is exported primarily for testing purposes.\n *\n * @param startPath - Directory path to start searching from.\n * @returns Git repository root path, or `startPath` if not found.\n *\n * @example\n * ```typescript\n * const root = findGitRoot('/path/to/repo/src/subdir')\n * // => '/path/to/repo'\n *\n * const notFound = findGitRoot('/not/a/repo')\n * // => '/not/a/repo'\n * ```\n */\nexport function findGitRoot(startPath: string): string {\n const fs = getFs()\n const path = getPath()\n let currentPath = startPath\n // Walk up the directory tree looking for .git\n while (true) {\n try {\n const gitPath = path.join(currentPath, '.git')\n if (fs.existsSync(gitPath)) {\n return currentPath\n }\n } catch {\n // Ignore errors and continue walking up\n }\n const parentPath = path.dirname(currentPath)\n // Stop if we've reached the root or can't go up anymore\n if (parentPath === currentPath) {\n // Return original path if no .git found\n return startPath\n }\n currentPath = parentPath\n }\n}\n\n/**\n * Parse git diff stdout output into file path array.\n *\n * Internal helper that processes raw git command output by:\n * 1. Finding git repository root from spawn cwd\n * 2. Stripping ANSI codes and splitting into lines\n * 3. Parsing porcelain format status codes if requested\n * 4. Normalizing and optionally making paths absolute\n * 5. Filtering paths based on cwd and glob options\n *\n * Git always returns paths relative to the repository root, regardless of\n * where the command was executed. This function handles the path resolution\n * correctly by finding the repo root and adjusting paths accordingly.\n *\n * @param stdout - Raw stdout from git command.\n * @param options - Git diff options for path processing.\n * @param spawnCwd - Working directory where git command was executed.\n * @returns Array of processed file paths.\n */\nfunction parseGitDiffStdout(\n stdout: string,\n options?: GitDiffOptions | undefined,\n spawnCwd?: string | undefined,\n): string[] {\n // Find git repo root from spawnCwd. Git always returns paths relative to the repo root,\n // not the cwd where it was run. So we need to find the repo root to correctly parse paths.\n const defaultRoot = spawnCwd ? findGitRoot(spawnCwd) : getCwd()\n const {\n absolute = false,\n cwd: cwdOption = defaultRoot,\n porcelain = false,\n ...matcherOptions\n } = { __proto__: null, ...options }\n // Resolve cwd to handle symlinks.\n const cwd =\n cwdOption === defaultRoot ? defaultRoot : getFs().realpathSync(cwdOption)\n const rootPath = defaultRoot\n // Split into lines without trimming to preserve leading spaces in porcelain format.\n let rawFiles = stdout\n ? stripAnsi(stdout)\n .split('\\n')\n .map(line => line.trimEnd())\n .filter(line => line)\n : []\n // Parse porcelain format: strip status codes.\n // Git status --porcelain format is: XY filename\n // where X and Y are single characters and there's a space before the filename.\n if (porcelain) {\n rawFiles = rawFiles.map(line => {\n // Status is first 2 chars, then space, then filename.\n return line.length > 3 ? line.substring(3) : line\n })\n }\n const files = absolute\n ? rawFiles.map(relPath => normalizePath(path.join(rootPath, relPath)))\n : rawFiles.map(relPath => normalizePath(relPath))\n if (cwd === rootPath) {\n return files\n }\n const relPath = normalizePath(path.relative(rootPath, cwd))\n const matcher = getGlobMatcher([`${relPath}/**`], {\n ...(matcherOptions as {\n dot?: boolean\n ignore?: string[]\n nocase?: boolean\n }),\n absolute,\n cwd: rootPath,\n } as {\n absolute?: boolean\n cwd?: string\n dot?: boolean\n ignore?: string[]\n nocase?: boolean\n })\n const filtered: string[] = []\n for (const filepath of files) {\n if (matcher(filepath)) {\n filtered.push(filepath)\n }\n }\n return filtered\n}\n\n/**\n * Get all changed files including staged, unstaged, and untracked files.\n *\n * Uses `git status --porcelain` which returns the full working tree status\n * with status codes:\n * - `M` - Modified\n * - `A` - Added\n * - `D` - Deleted\n * - `??` - Untracked\n * - `R` - Renamed\n * - `C` - Copied\n *\n * This is the most comprehensive check - captures everything that differs\n * from the last commit, including:\n * - Files modified and staged with `git add`\n * - Files modified but not staged\n * - New files not yet tracked by git\n *\n * Status codes are automatically stripped from the output.\n *\n * @param options - Options controlling path format and filtering.\n * @returns Promise resolving to array of changed file paths.\n *\n * @example\n * ```typescript\n * // Get all changed files as relative paths\n * const files = await getChangedFiles()\n * // => ['src/foo.ts', 'src/bar.ts', 'newfile.ts']\n *\n * // Get absolute paths\n * const files = await getChangedFiles({ absolute: true })\n * // => ['/path/to/repo/src/foo.ts', ...]\n *\n * // Get changed files in specific directory\n * const files = await getChangedFiles({ cwd: '/path/to/repo/src' })\n * // => ['foo.ts', 'bar.ts']\n * ```\n */\nexport async function getChangedFiles(\n options?: GitDiffOptions | undefined,\n): Promise<string[]> {\n const args = getGitDiffSpawnArgs(options?.cwd).all\n return await innerDiff(args, {\n __proto__: null,\n ...options,\n porcelain: true,\n })\n}\n\n/**\n * Get all changed files including staged, unstaged, and untracked files.\n *\n * Synchronous version of `getChangedFiles()`. Uses `git status --porcelain`\n * which returns the full working tree status with status codes:\n * - `M` - Modified\n * - `A` - Added\n * - `D` - Deleted\n * - `??` - Untracked\n * - `R` - Renamed\n * - `C` - Copied\n *\n * This is the most comprehensive check - captures everything that differs\n * from the last commit, including:\n * - Files modified and staged with `git add`\n * - Files modified but not staged\n * - New files not yet tracked by git\n *\n * Status codes are automatically stripped from the output.\n *\n * @param options - Options controlling path format and filtering.\n * @returns Array of changed file paths.\n *\n * @example\n * ```typescript\n * // Get all changed files as relative paths\n * const files = getChangedFilesSync()\n * // => ['src/foo.ts', 'src/bar.ts', 'newfile.ts']\n *\n * // Get absolute paths\n * const files = getChangedFilesSync({ absolute: true })\n * // => ['/path/to/repo/src/foo.ts', ...]\n *\n * // Get changed files in specific directory\n * const files = getChangedFilesSync({ cwd: '/path/to/repo/src' })\n * // => ['foo.ts', 'bar.ts']\n * ```\n */\nexport function getChangedFilesSync(\n options?: GitDiffOptions | undefined,\n): string[] {\n const args = getGitDiffSpawnArgs(options?.cwd).all\n return innerDiffSync(args, {\n __proto__: null,\n ...options,\n porcelain: true,\n })\n}\n\n/**\n * Get unstaged modified files (changes not yet staged for commit).\n *\n * Uses `git diff --name-only` which returns only unstaged modifications\n * to tracked files. Does NOT include:\n * - Untracked files (new files not added to git)\n * - Staged changes (files added with `git add`)\n *\n * This is a focused check for uncommitted changes to existing tracked files.\n * Useful for detecting work-in-progress modifications before staging.\n *\n * @param options - Options controlling path format and filtering.\n * @returns Promise resolving to array of unstaged file paths.\n *\n * @example\n * ```typescript\n * // Get unstaged files\n * const files = await getUnstagedFiles()\n * // => ['src/foo.ts', 'src/bar.ts']\n *\n * // After staging some files\n * await spawn('git', ['add', 'src/foo.ts'])\n * const files = await getUnstagedFiles()\n * // => ['src/bar.ts'] (foo.ts no longer included)\n *\n * // Get absolute paths\n * const files = await getUnstagedFiles({ absolute: true })\n * // => ['/path/to/repo/src/bar.ts']\n * ```\n */\nexport async function getUnstagedFiles(\n options?: GitDiffOptions | undefined,\n): Promise<string[]> {\n const args = getGitDiffSpawnArgs(options?.cwd).unstaged\n return await innerDiff(args, options)\n}\n\n/**\n * Get unstaged modified files (changes not yet staged for commit).\n *\n * Synchronous version of `getUnstagedFiles()`. Uses `git diff --name-only`\n * which returns only unstaged modifications to tracked files. Does NOT include:\n * - Untracked files (new files not added to git)\n * - Staged changes (files added with `git add`)\n *\n * This is a focused check for uncommitted changes to existing tracked files.\n * Useful for detecting work-in-progress modifications before staging.\n *\n * @param options - Options controlling path format and filtering.\n * @returns Array of unstaged file paths.\n *\n * @example\n * ```typescript\n * // Get unstaged files\n * const files = getUnstagedFilesSync()\n * // => ['src/foo.ts', 'src/bar.ts']\n *\n * // After staging some files\n * spawnSync('git', ['add', 'src/foo.ts'])\n * const files = getUnstagedFilesSync()\n * // => ['src/bar.ts'] (foo.ts no longer included)\n *\n * // Get absolute paths\n * const files = getUnstagedFilesSync({ absolute: true })\n * // => ['/path/to/repo/src/bar.ts']\n * ```\n */\nexport function getUnstagedFilesSync(\n options?: GitDiffOptions | undefined,\n): string[] {\n const args = getGitDiffSpawnArgs(options?.cwd).unstaged\n return innerDiffSync(args, options)\n}\n\n/**\n * Get staged files ready for commit (changes added with `git add`).\n *\n * Uses `git diff --cached --name-only` which returns only staged changes.\n * Does NOT include:\n * - Unstaged modifications (changes not added with `git add`)\n * - Untracked files (new files not added to git)\n *\n * This is a focused check for what will be included in the next commit.\n * Useful for validating changes before committing or running pre-commit hooks.\n *\n * @param options - Options controlling path format and filtering.\n * @returns Promise resolving to array of staged file paths.\n *\n * @example\n * ```typescript\n * // Get currently staged files\n * const files = await getStagedFiles()\n * // => ['src/foo.ts']\n *\n * // Stage more files\n * await spawn('git', ['add', 'src/bar.ts'])\n * const files = await getStagedFiles()\n * // => ['src/foo.ts', 'src/bar.ts']\n *\n * // Get absolute paths\n * const files = await getStagedFiles({ absolute: true })\n * // => ['/path/to/repo/src/foo.ts', ...]\n * ```\n */\nexport async function getStagedFiles(\n options?: GitDiffOptions | undefined,\n): Promise<string[]> {\n const args = getGitDiffSpawnArgs(options?.cwd).staged\n return await innerDiff(args, options)\n}\n\n/**\n * Get staged files ready for commit (changes added with `git add`).\n *\n * Synchronous version of `getStagedFiles()`. Uses `git diff --cached --name-only`\n * which returns only staged changes. Does NOT include:\n * - Unstaged modifications (changes not added with `git add`)\n * - Untracked files (new files not added to git)\n *\n * This is a focused check for what will be included in the next commit.\n * Useful for validating changes before committing or running pre-commit hooks.\n *\n * @param options - Options controlling path format and filtering.\n * @returns Array of staged file paths.\n *\n * @example\n * ```typescript\n * // Get currently staged files\n * const files = getStagedFilesSync()\n * // => ['src/foo.ts']\n *\n * // Stage more files\n * spawnSync('git', ['add', 'src/bar.ts'])\n * const files = getStagedFilesSync()\n * // => ['src/foo.ts', 'src/bar.ts']\n *\n * // Get absolute paths\n * const files = getStagedFilesSync({ absolute: true })\n * // => ['/path/to/repo/src/foo.ts', ...]\n * ```\n */\nexport function getStagedFilesSync(\n options?: GitDiffOptions | undefined,\n): string[] {\n const args = getGitDiffSpawnArgs(options?.cwd).staged\n return innerDiffSync(args, options)\n}\n\n/**\n * Check if a file or directory has any git changes.\n *\n * Checks if the given pathname has any changes including:\n * - Staged modifications (added with `git add`)\n * - Unstaged modifications (not yet staged)\n * - Untracked status (new file/directory not in git)\n *\n * For directories, returns `true` if ANY file within the directory has changes.\n *\n * Symlinks in the pathname and cwd are automatically resolved using\n * `fs.realpathSync()` before comparison.\n *\n * @param pathname - File or directory path to check.\n * @param options - Options for the git status check.\n * @returns Promise resolving to `true` if path has any changes, `false` otherwise.\n *\n * @example\n * ```typescript\n * // Check if file is changed\n * const changed = await isChanged('src/foo.ts')\n * // => true\n *\n * // Check if directory has any changes\n * const changed = await isChanged('src/')\n * // => true (if any file in src/ is changed)\n *\n * // Check from different cwd\n * const changed = await isChanged(\n * '/path/to/repo/src/foo.ts',\n * { cwd: '/path/to/repo' }\n * )\n * ```\n */\nexport async function isChanged(\n pathname: string,\n options?: GitDiffOptions | undefined,\n): Promise<boolean> {\n const files = await getChangedFiles({\n __proto__: null,\n ...options,\n absolute: false,\n })\n // Resolve pathname to handle symlinks before computing relative path.\n const resolvedPathname = getFs().realpathSync(pathname)\n const baseCwd = options?.cwd ? getFs().realpathSync(options['cwd']) : getCwd()\n const relativePath = normalizePath(path.relative(baseCwd, resolvedPathname))\n return files.includes(relativePath)\n}\n\n/**\n * Check if a file or directory has any git changes.\n *\n * Synchronous version of `isChanged()`. Checks if the given pathname has\n * any changes including:\n * - Staged modifications (added with `git add`)\n * - Unstaged modifications (not yet staged)\n * - Untracked status (new file/directory not in git)\n *\n * For directories, returns `true` if ANY file within the directory has changes.\n *\n * Symlinks in the pathname and cwd are automatically resolved using\n * `fs.realpathSync()` before comparison.\n *\n * @param pathname - File or directory path to check.\n * @param options - Options for the git status check.\n * @returns `true` if path has any changes, `false` otherwise.\n *\n * @example\n * ```typescript\n * // Check if file is changed\n * const changed = isChangedSync('src/foo.ts')\n * // => true\n *\n * // Check if directory has any changes\n * const changed = isChangedSync('src/')\n * // => true (if any file in src/ is changed)\n *\n * // Check from different cwd\n * const changed = isChangedSync(\n * '/path/to/repo/src/foo.ts',\n * { cwd: '/path/to/repo' }\n * )\n * ```\n */\nexport function isChangedSync(\n pathname: string,\n options?: GitDiffOptions | undefined,\n): boolean {\n const files = getChangedFilesSync({\n __proto__: null,\n ...options,\n absolute: false,\n })\n // Resolve pathname to handle symlinks before computing relative path.\n const resolvedPathname = getFs().realpathSync(pathname)\n const baseCwd = options?.cwd ? getFs().realpathSync(options['cwd']) : getCwd()\n const relativePath = normalizePath(path.relative(baseCwd, resolvedPathname))\n return files.includes(relativePath)\n}\n\n/**\n * Check if a file or directory has unstaged changes.\n *\n * Checks if the given pathname has modifications that are not yet staged\n * for commit (changes not added with `git add`). Does NOT include:\n * - Staged changes (already added with `git add`)\n * - Untracked files (new files not in git)\n *\n * For directories, returns `true` if ANY file within the directory has\n * unstaged changes.\n *\n * Symlinks in the pathname and cwd are automatically resolved using\n * `fs.realpathSync()` before comparison.\n *\n * @param pathname - File or directory path to check.\n * @param options - Options for the git diff check.\n * @returns Promise resolving to `true` if path has unstaged changes, `false` otherwise.\n *\n * @example\n * ```typescript\n * // Check if file has unstaged changes\n * const unstaged = await isUnstaged('src/foo.ts')\n * // => true\n *\n * // After staging the file\n * await spawn('git', ['add', 'src/foo.ts'])\n * const unstaged = await isUnstaged('src/foo.ts')\n * // => false\n *\n * // Check directory\n * const unstaged = await isUnstaged('src/')\n * // => true (if any file in src/ has unstaged changes)\n * ```\n */\nexport async function isUnstaged(\n pathname: string,\n options?: GitDiffOptions | undefined,\n): Promise<boolean> {\n const files = await getUnstagedFiles({\n __proto__: null,\n ...options,\n absolute: false,\n })\n // Resolve pathname to handle symlinks before computing relative path.\n const resolvedPathname = getFs().realpathSync(pathname)\n const baseCwd = options?.cwd ? getFs().realpathSync(options['cwd']) : getCwd()\n const relativePath = normalizePath(path.relative(baseCwd, resolvedPathname))\n return files.includes(relativePath)\n}\n\n/**\n * Check if a file or directory has unstaged changes.\n *\n * Synchronous version of `isUnstaged()`. Checks if the given pathname has\n * modifications that are not yet staged for commit (changes not added with\n * `git add`). Does NOT include:\n * - Staged changes (already added with `git add`)\n * - Untracked files (new files not in git)\n *\n * For directories, returns `true` if ANY file within the directory has\n * unstaged changes.\n *\n * Symlinks in the pathname and cwd are automatically resolved using\n * `fs.realpathSync()` before comparison.\n *\n * @param pathname - File or directory path to check.\n * @param options - Options for the git diff check.\n * @returns `true` if path has unstaged changes, `false` otherwise.\n *\n * @example\n * ```typescript\n * // Check if file has unstaged changes\n * const unstaged = isUnstagedSync('src/foo.ts')\n * // => true\n *\n * // After staging the file\n * spawnSync('git', ['add', 'src/foo.ts'])\n * const unstaged = isUnstagedSync('src/foo.ts')\n * // => false\n *\n * // Check directory\n * const unstaged = isUnstagedSync('src/')\n * // => true (if any file in src/ has unstaged changes)\n * ```\n */\nexport function isUnstagedSync(\n pathname: string,\n options?: GitDiffOptions | undefined,\n): boolean {\n const files = getUnstagedFilesSync({\n __proto__: null,\n ...options,\n absolute: false,\n })\n // Resolve pathname to handle symlinks before computing relative path.\n const resolvedPathname = getFs().realpathSync(pathname)\n const baseCwd = options?.cwd ? getFs().realpathSync(options['cwd']) : getCwd()\n const relativePath = normalizePath(path.relative(baseCwd, resolvedPathname))\n return files.includes(relativePath)\n}\n\n/**\n * Check if a file or directory is staged for commit.\n *\n * Checks if the given pathname has changes staged with `git add` that will\n * be included in the next commit. Does NOT include:\n * - Unstaged modifications (changes not added with `git add`)\n * - Untracked files (new files not in git)\n *\n * For directories, returns `true` if ANY file within the directory is staged.\n *\n * Symlinks in the pathname and cwd are automatically resolved using\n * `fs.realpathSync()` before comparison.\n *\n * @param pathname - File or directory path to check.\n * @param options - Options for the git diff check.\n * @returns Promise resolving to `true` if path is staged, `false` otherwise.\n *\n * @example\n * ```typescript\n * // Check if file is staged\n * const staged = await isStaged('src/foo.ts')\n * // => false\n *\n * // Stage the file\n * await spawn('git', ['add', 'src/foo.ts'])\n * const staged = await isStaged('src/foo.ts')\n * // => true\n *\n * // Check directory\n * const staged = await isStaged('src/')\n * // => true (if any file in src/ is staged)\n * ```\n */\nexport async function isStaged(\n pathname: string,\n options?: GitDiffOptions | undefined,\n): Promise<boolean> {\n const files = await getStagedFiles({\n __proto__: null,\n ...options,\n absolute: false,\n })\n // Resolve pathname to handle symlinks before computing relative path.\n const resolvedPathname = getFs().realpathSync(pathname)\n const baseCwd = options?.cwd ? getFs().realpathSync(options['cwd']) : getCwd()\n const relativePath = normalizePath(path.relative(baseCwd, resolvedPathname))\n return files.includes(relativePath)\n}\n\n/**\n * Check if a file or directory is staged for commit.\n *\n * Synchronous version of `isStaged()`. Checks if the given pathname has\n * changes staged with `git add` that will be included in the next commit.\n * Does NOT include:\n * - Unstaged modifications (changes not added with `git add`)\n * - Untracked files (new files not in git)\n *\n * For directories, returns `true` if ANY file within the directory is staged.\n *\n * Symlinks in the pathname and cwd are automatically resolved using\n * `fs.realpathSync()` before comparison.\n *\n * @param pathname - File or directory path to check.\n * @param options - Options for the git diff check.\n * @returns `true` if path is staged, `false` otherwise.\n *\n * @example\n * ```typescript\n * // Check if file is staged\n * const staged = isStagedSync('src/foo.ts')\n * // => false\n *\n * // Stage the file\n * spawnSync('git', ['add', 'src/foo.ts'])\n * const staged = isStagedSync('src/foo.ts')\n * // => true\n *\n * // Check directory\n * const staged = isStagedSync('src/')\n * // => true (if any file in src/ is staged)\n * ```\n */\nexport function isStagedSync(\n pathname: string,\n options?: GitDiffOptions | undefined,\n): boolean {\n const files = getStagedFilesSync({\n __proto__: null,\n ...options,\n absolute: false,\n })\n // Resolve pathname to handle symlinks before computing relative path.\n const resolvedPathname = getFs().realpathSync(pathname)\n const baseCwd = options?.cwd ? getFs().realpathSync(options['cwd']) : getCwd()\n const relativePath = normalizePath(path.relative(baseCwd, resolvedPathname))\n return files.includes(relativePath)\n}\n"],
5
+ "mappings": ";6iBAAA,IAAAA,GAAA,GAAAC,EAAAD,GAAA,iBAAAE,EAAA,oBAAAC,EAAA,wBAAAC,EAAA,mBAAAC,EAAA,uBAAAC,EAAA,qBAAAC,EAAA,yBAAAC,EAAA,cAAAC,EAAA,kBAAAC,EAAA,aAAAC,GAAA,iBAAAC,GAAA,eAAAC,EAAA,mBAAAC,KAAA,eAAAC,EAAAf,IAAA,IAAAgB,EAAiB,mBAEjBC,EAAsB,+BACtBC,EAAwB,mBACxBC,EAA+B,mBAC/BH,EAA8B,kBAC9BI,EAAiC,mBACjCC,EAA0B,qBAqH1B,MAAMC,EAAe,IAAI,IAEzB,IAAIC,EAgBJ,SAASC,GAAQ,CACf,OAAID,IAAQ,SAGVA,EAAoB,QAAQ,SAAS,GAEhCA,CACT,CAEA,IAAIE,EAgBJ,SAASC,GAAU,CACjB,OAAID,IAAU,SACZA,EAAsB,QAAQ,WAAW,GAEpCA,CACT,CAiBA,SAASE,GAAqB,CAC5B,MAAO,KACT,CAkBA,SAASC,GAAiB,CACxB,OAAOJ,EAAM,EAAE,aAAa,QAAQ,IAAI,CAAC,CAC3C,CAgBA,SAASK,EAAoBC,EAA4C,CACvE,MAAMC,EAAcD,EAAMN,EAAM,EAAE,aAAaM,CAAG,EAAIF,EAAO,EAC7D,MAAO,CACL,IAAK,CACHD,EAAW,EACX,CAAC,SAAU,aAAa,EACxB,CACE,IAAKI,EACL,MAAO,OACT,CACF,EACA,SAAU,CACRJ,EAAW,EACX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Ae,iBAAc,EAAApB,QAAK,SAASmB,EAASD,CAAgB,CAAC,EAC3E,OAAON,EAAM,SAASQ,CAAY,CACpC,CAqCO,SAASrD,GACdkD,EACA9B,EACS,CACT,MAAMyB,EAAQnD,EAAqB,CACjC,UAAW,KACX,GAAG0B,EACH,SAAU,EACZ,CAAC,EAEK+B,EAAmBzC,EAAM,EAAE,aAAawC,CAAQ,EAChDE,EAAUhC,GAAS,IAAMV,EAAM,EAAE,aAAaU,EAAQ,GAAM,EAAIN,EAAO,EACvEuC,KAAe,iBAAc,EAAApB,QAAK,SAASmB,EAASD,CAAgB,CAAC,EAC3E,OAAON,EAAM,SAASQ,CAAY,CACpC,CAmCA,eAAsBxD,GACpBqD,EACA9B,EACkB,CAClB,MAAMyB,EAAQ,MAAMtD,EAAe,CACjC,UAAW,KACX,GAAG6B,EACH,SAAU,EACZ,CAAC,EAEK+B,EAAmBzC,EAAM,EAAE,aAAawC,CAAQ,EAChDE,EAAUhC,GAAS,IAAMV,EAAM,EAAE,aAAaU,EAAQ,GAAM,EAAIN,EAAO,EACvEuC,KAAe,iBAAc,EAAApB,QAAK,SAASmB,EAASD,CAAgB,CAAC,EAC3E,OAAON,EAAM,SAASQ,CAAY,CACpC,CAoCO,SAASvD,GACdoD,EACA9B,EACS,CACT,MAAMyB,EAAQrD,EAAmB,CAC/B,UAAW,KACX,GAAG4B,EACH,SAAU,EACZ,CAAC,EAEK+B,EAAmBzC,EAAM,EAAE,aAAawC,CAAQ,EAChDE,EAAUhC,GAAS,IAAMV,EAAM,EAAE,aAAaU,EAAQ,GAAM,EAAIN,EAAO,EACvEuC,KAAe,iBAAc,EAAApB,QAAK,SAASmB,EAASD,CAAgB,CAAC,EAC3E,OAAON,EAAM,SAASQ,CAAY,CACpC",
6
+ "names": ["git_exports", "__export", "findGitRoot", "getChangedFiles", "getChangedFilesSync", "getStagedFiles", "getStagedFilesSync", "getUnstagedFiles", "getUnstagedFilesSync", "isChanged", "isChangedSync", "isStaged", "isStagedSync", "isUnstaged", "isUnstagedSync", "__toCommonJS", "import_path", "import_platform", "import_debug", "import_globs", "import_spawn", "import_strings", "gitDiffCache", "_fs", "getFs", "_path", "getPath", "getGitPath", "getCwd", "getGitDiffSpawnArgs", "cwd", "resolvedCwd", "innerDiff", "args", "options", "cache", "parseOptions", "cacheKey", "result", "spawnResult", "stdout", "spawnCwd", "parseGitDiffStdout", "e", "innerDiffSync", "startPath", "fs", "path", "currentPath", "gitPath", "parentPath", "defaultRoot", "absolute", "cwdOption", "porcelain", "matcherOptions", "rootPath", "rawFiles", "line", "files", "relPath", "matcher", "filtered", "filepath", "pathname", "resolvedPathname", "baseCwd", "relativePath"]
7
7
  }
@@ -1,5 +1,5 @@
1
1
  /* Socket Lib - Built with esbuild */
2
- var T=Object.defineProperty;var q=Object.getOwnPropertyDescriptor;var _=Object.getOwnPropertyNames;var N=Object.prototype.hasOwnProperty;var S=(o,r)=>{for(var t in r)T(o,t,{get:r[t],enumerable:!0})},P=(o,r,t,d)=>{if(r&&typeof r=="object"||typeof r=="function")for(let i of _(r))!N.call(o,i)&&i!==t&&T(o,i,{get:()=>r[i],enumerable:!(d=q(r,i))||d.enumerable});return o};var U=o=>P(T({},"__esModule",{value:!0}),o);var G={};S(G,{httpDownload:()=>$,httpGetJson:()=>M,httpGetText:()=>v,httpRequest:()=>O});module.exports=U(G);var b=require("node:fs");let R,H;function k(){return R===void 0&&(R=require("node:http")),R}function x(){return H===void 0&&(H=require("node:https")),H}async function O(o,r){const{body:t,followRedirects:d=!0,headers:i={},maxRedirects:m=5,method:y="GET",retries:a=0,retryDelay:u=1e3,timeout:h=3e4}={__proto__:null,...r};let f;for(let w=0;w<=a;w++)try{return await C(o,{body:t,followRedirects:d,headers:i,maxRedirects:m,method:y,timeout:h})}catch(p){if(f=p,w===a)break;const E=u*2**w;await new Promise(c=>setTimeout(c,E))}throw f||new Error("Request failed after retries")}async function C(o,r){const{body:t,followRedirects:d=!0,headers:i={},maxRedirects:m=5,method:y="GET",timeout:a=3e4}={__proto__:null,...r};return await new Promise((u,h)=>{const f=new URL(o),p=f.protocol==="https:"?x():k(),E={headers:{"User-Agent":"socket-registry/1.0",...i},hostname:f.hostname,method:y,path:f.pathname+f.search,port:f.port,timeout:a},c=p.request(E,n=>{if(d&&n.statusCode&&n.statusCode>=300&&n.statusCode<400&&n.headers.location){if(m<=0){h(new Error(`Too many redirects (exceeded maximum: ${m})`));return}const e=n.headers.location.startsWith("http")?n.headers.location:new URL(n.headers.location,o).toString();u(C(e,{body:t,followRedirects:d,headers:i,maxRedirects:m-1,method:y,timeout:a}));return}const s=[];n.on("data",e=>{s.push(e)}),n.on("end",()=>{const e=Buffer.concat(s),l=n.statusCode!==void 0&&n.statusCode>=200&&n.statusCode<300,g={arrayBuffer(){return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)},body:e,headers:n.headers,json(){return JSON.parse(e.toString("utf8"))},ok:l,status:n.statusCode||0,statusText:n.statusMessage||"",text(){return e.toString("utf8")}};u(g)})});c.on("error",n=>{const s=n.code;let e=`HTTP request failed for ${o}: ${n.message}
2
+ var T=Object.defineProperty;var q=Object.getOwnPropertyDescriptor;var _=Object.getOwnPropertyNames;var N=Object.prototype.hasOwnProperty;var S=(o,r)=>{for(var t in r)T(o,t,{get:r[t],enumerable:!0})},P=(o,r,t,d)=>{if(r&&typeof r=="object"||typeof r=="function")for(let i of _(r))!N.call(o,i)&&i!==t&&T(o,i,{get:()=>r[i],enumerable:!(d=q(r,i))||d.enumerable});return o};var U=o=>P(T({},"__esModule",{value:!0}),o);var G={};S(G,{httpDownload:()=>$,httpGetJson:()=>M,httpGetText:()=>v,httpRequest:()=>O});module.exports=U(G);var b=require("fs");let R,H;function k(){return R===void 0&&(R=require("node:http")),R}function x(){return H===void 0&&(H=require("node:https")),H}async function O(o,r){const{body:t,followRedirects:d=!0,headers:i={},maxRedirects:m=5,method:y="GET",retries:a=0,retryDelay:u=1e3,timeout:h=3e4}={__proto__:null,...r};let f;for(let w=0;w<=a;w++)try{return await C(o,{body:t,followRedirects:d,headers:i,maxRedirects:m,method:y,timeout:h})}catch(p){if(f=p,w===a)break;const E=u*2**w;await new Promise(c=>setTimeout(c,E))}throw f||new Error("Request failed after retries")}async function C(o,r){const{body:t,followRedirects:d=!0,headers:i={},maxRedirects:m=5,method:y="GET",timeout:a=3e4}={__proto__:null,...r};return await new Promise((u,h)=>{const f=new URL(o),p=f.protocol==="https:"?x():k(),E={headers:{"User-Agent":"socket-registry/1.0",...i},hostname:f.hostname,method:y,path:f.pathname+f.search,port:f.port,timeout:a},c=p.request(E,n=>{if(d&&n.statusCode&&n.statusCode>=300&&n.statusCode<400&&n.headers.location){if(m<=0){h(new Error(`Too many redirects (exceeded maximum: ${m})`));return}const e=n.headers.location.startsWith("http")?n.headers.location:new URL(n.headers.location,o).toString();u(C(e,{body:t,followRedirects:d,headers:i,maxRedirects:m-1,method:y,timeout:a}));return}const s=[];n.on("data",e=>{s.push(e)}),n.on("end",()=>{const e=Buffer.concat(s),l=n.statusCode!==void 0&&n.statusCode>=200&&n.statusCode<300,g={arrayBuffer(){return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)},body:e,headers:n.headers,json(){return JSON.parse(e.toString("utf8"))},ok:l,status:n.statusCode||0,statusText:n.statusMessage||"",text(){return e.toString("utf8")}};u(g)})});c.on("error",n=>{const s=n.code;let e=`HTTP request failed for ${o}: ${n.message}
3
3
  `;s==="ENOTFOUND"?e+="DNS lookup failed. Check the hostname and your network connection.":s==="ECONNREFUSED"?e+="Connection refused. Verify the server is running and accessible.":s==="ETIMEDOUT"?e+="Request timed out. Check your network or increase the timeout value.":s==="ECONNRESET"?e+="Connection reset. The server may have closed the connection unexpectedly.":e+="Check your network connection and verify the URL is correct.",h(new Error(e,{cause:n}))}),c.on("timeout",()=>{c.destroy(),h(new Error(`Request timed out after ${a}ms`))}),t&&c.write(t),c.end()})}async function $(o,r,t){const{headers:d={},onProgress:i,retries:m=0,retryDelay:y=1e3,timeout:a=12e4}={__proto__:null,...t};let u;for(let h=0;h<=m;h++)try{return await B(o,r,{headers:d,onProgress:i,timeout:a})}catch(f){if(u=f,h===m)break;const w=y*2**h;await new Promise(p=>setTimeout(p,w))}throw u||new Error("Download failed after retries")}async function B(o,r,t){const{headers:d={},onProgress:i,timeout:m=12e4}={__proto__:null,...t};return await new Promise((y,a)=>{const u=new URL(o),f=u.protocol==="https:"?x():k(),w={headers:{"User-Agent":"socket-registry/1.0",...d},hostname:u.hostname,method:"GET",path:u.pathname+u.search,port:u.port,timeout:m};let p,E=!1;const c=()=>{!E&&p&&(E=!0,p.close())},n=f.request(w,s=>{if(!s.statusCode||s.statusCode<200||s.statusCode>=300){c(),a(new Error(`Download failed: HTTP ${s.statusCode} ${s.statusMessage}`));return}const e=Number.parseInt(s.headers["content-length"]||"0",10);let l=0;p=(0,b.createWriteStream)(r),p.on("error",g=>{c();const D=new Error(`Failed to write file: ${g.message}`,{cause:g});a(D)}),s.on("data",g=>{l+=g.length,i&&e>0&&i(l,e)}),s.on("end",()=>{p?.close(()=>{E=!0,y({path:r,size:l})})}),s.on("error",g=>{c(),a(g)}),s.pipe(p)});n.on("error",s=>{c();const e=s.code;let l=`HTTP download failed for ${o}: ${s.message}
4
4
  `;e==="ENOTFOUND"?l+="DNS lookup failed. Check the hostname and your network connection.":e==="ECONNREFUSED"?l+="Connection refused. Verify the server is running and accessible.":e==="ETIMEDOUT"?l+="Request timed out. Check your network or increase the timeout value.":e==="ECONNRESET"?l+="Connection reset. The server may have closed the connection unexpectedly.":l+="Check your network connection and verify the URL is correct.",a(new Error(l,{cause:s}))}),n.on("timeout",()=>{n.destroy(),c(),a(new Error(`Download timed out after ${m}ms`))}),n.end()})}async function M(o,r){const t=await O(o,{...r,method:"GET"});if(!t.ok)throw new Error(`HTTP ${t.status}: ${t.statusText}`);try{return t.json()}catch(d){throw new Error("Failed to parse JSON response",{cause:d})}}async function v(o,r){const t=await O(o,{...r,method:"GET"});if(!t.ok)throw new Error(`HTTP ${t.status}: ${t.statusText}`);return t.text()}0&&(module.exports={httpDownload,httpGetJson,httpGetText,httpRequest});
5
5
  //# sourceMappingURL=http-request.js.map