@visulima/package 1.8.1 → 1.8.3

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 (89) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/LICENSE.md +17 -0
  3. package/dist/error.cjs +1 -14
  4. package/dist/error.d.mts +9 -0
  5. package/dist/error.mjs +1 -0
  6. package/dist/index.cjs +1 -156
  7. package/dist/index.d.cts +2 -3
  8. package/dist/index.d.mts +18 -0
  9. package/dist/index.d.ts +2 -3
  10. package/dist/index.mjs +1 -0
  11. package/dist/monorepo.cjs +1 -14
  12. package/dist/monorepo.d.mts +8 -0
  13. package/dist/monorepo.mjs +1 -0
  14. package/dist/package-json.cjs +1 -28
  15. package/dist/package-json.d.cts +3 -5
  16. package/dist/package-json.d.mts +22 -0
  17. package/dist/package-json.d.ts +3 -5
  18. package/dist/package-json.mjs +1 -0
  19. package/dist/package-manager.cjs +1 -33
  20. package/dist/package-manager.d.mts +16 -0
  21. package/dist/package-manager.mjs +1 -0
  22. package/dist/package.cjs +1 -18
  23. package/dist/package.d.mts +4 -0
  24. package/dist/package.mjs +1 -0
  25. package/dist/shared/package.DipMHw9r.cjs +1 -0
  26. package/dist/shared/package.DvbNGF15.mjs +1 -0
  27. package/dist/shared/package.SZmjOQBM.d.cts +2076 -0
  28. package/dist/shared/package.SZmjOQBM.d.mts +2076 -0
  29. package/dist/shared/package.SZmjOQBM.d.ts +2076 -0
  30. package/dist/shared/package.Xn4v2Y_g.cjs +1 -0
  31. package/dist/shared/package.zhGeUcxO.mjs +1 -0
  32. package/dist/tsconfig/index.cjs +1 -0
  33. package/dist/tsconfig/index.d.cts +34 -0
  34. package/dist/tsconfig/index.d.mts +34 -0
  35. package/dist/tsconfig/index.d.ts +34 -0
  36. package/dist/tsconfig/index.mjs +1 -0
  37. package/package.json +32 -40
  38. package/dist/chunk-5VO6NTKJ.js +0 -361
  39. package/dist/chunk-5VO6NTKJ.js.map +0 -1
  40. package/dist/chunk-7IOK6YPW.cjs +0 -52
  41. package/dist/chunk-7IOK6YPW.cjs.map +0 -1
  42. package/dist/chunk-CVVFWSMT.cjs +0 -65
  43. package/dist/chunk-CVVFWSMT.cjs.map +0 -1
  44. package/dist/chunk-E2PKJX3Q.js +0 -54
  45. package/dist/chunk-E2PKJX3Q.js.map +0 -1
  46. package/dist/chunk-EYMR7Z2I.js +0 -62
  47. package/dist/chunk-EYMR7Z2I.js.map +0 -1
  48. package/dist/chunk-G3SI24AJ.cjs +0 -88
  49. package/dist/chunk-G3SI24AJ.cjs.map +0 -1
  50. package/dist/chunk-IIYQBLPC.js +0 -119
  51. package/dist/chunk-IIYQBLPC.js.map +0 -1
  52. package/dist/chunk-IK5YSYLX.cjs +0 -126
  53. package/dist/chunk-IK5YSYLX.cjs.map +0 -1
  54. package/dist/chunk-UZ2FN6C5.js +0 -78
  55. package/dist/chunk-UZ2FN6C5.js.map +0 -1
  56. package/dist/chunk-WXFZK4G3.cjs +0 -374
  57. package/dist/chunk-WXFZK4G3.cjs.map +0 -1
  58. package/dist/chunk-YLCN7EVV.js +0 -50
  59. package/dist/chunk-YLCN7EVV.js.map +0 -1
  60. package/dist/chunk-YOQXHFU3.cjs +0 -56
  61. package/dist/chunk-YOQXHFU3.cjs.map +0 -1
  62. package/dist/error.cjs.map +0 -1
  63. package/dist/error.js +0 -5
  64. package/dist/error.js.map +0 -1
  65. package/dist/index.cjs.map +0 -1
  66. package/dist/index.js +0 -66
  67. package/dist/index.js.map +0 -1
  68. package/dist/monorepo.cjs.map +0 -1
  69. package/dist/monorepo.js +0 -5
  70. package/dist/monorepo.js.map +0 -1
  71. package/dist/package-json.cjs.map +0 -1
  72. package/dist/package-json.js +0 -3
  73. package/dist/package-json.js.map +0 -1
  74. package/dist/package-manager.cjs.map +0 -1
  75. package/dist/package-manager.js +0 -4
  76. package/dist/package-manager.js.map +0 -1
  77. package/dist/package.cjs.map +0 -1
  78. package/dist/package.js +0 -5
  79. package/dist/package.js.map +0 -1
  80. package/dist/tsconfig-G-HInwrt.d.ts +0 -30
  81. package/dist/tsconfig-d4zwQgCH.d.cts +0 -30
  82. package/dist/tsconfig.cjs +0 -36
  83. package/dist/tsconfig.cjs.map +0 -1
  84. package/dist/tsconfig.d.cts +0 -5
  85. package/dist/tsconfig.d.ts +0 -5
  86. package/dist/tsconfig.js +0 -3
  87. package/dist/tsconfig.js.map +0 -1
  88. package/dist/types-hoigZ9HA.d.cts +0 -9
  89. package/dist/types-hoigZ9HA.d.ts +0 -9
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/tsconfig.ts","../src/read-tsconfig.ts","../src/utils/resolve-extends-path.ts"],"names":["findUpSync","NotFoundError","join","readFileSync","parse","resolve","packageJsonPath","readJsonc"],"mappings":";AACA,SAAS,QAAQ,cAAAA,aAAY,iBAAiB;AAC9C,SAAS,iBAAAC,sBAAqB;AAC9B,SAAS,cAAc;AACvB,SAAS,QAAAC,aAAY;;;ACErB,SAAS,gBAAAC,qBAAoB;AAC7B,SAAS,qBAAqB;AAC9B,SAAS,SAAAC,cAAa;AACtB,SAAS,SAAS,QAAAF,OAAM,WAAW,UAAU,WAAAG,UAAS,wBAAwB;;;ACH9E,SAAS,YAAY,gBAAgB;AACrC,OAAO,YAAY;AACnB,SAAS,YAAY,MAAM,eAAe;AAE1C,SAAS,YAAY,oBAAoB;AACzC,SAAS,aAAa;AAEtB,SAAS,sBAAsB;AAK/B,IAAM,YAAY,CAAC,aAAqB,MAAM,aAAa,QAAQ,CAAW;AAE9E,IAAM,YAAY,MAAM;AACpB,QAAM,EAAE,WAAW,IAAI;AAGvB,SAAO,aAAa,QAAQ,IAAI,CAAC;AACrC;AAEA,IAAM,6BAA6B,CAAC,iBAAyB,SAAiB,eAAyB,UAA0B;AAC7H,QAAM,WAAW,8BAA8B,eAAe,IAAI,OAAO,IAAI,aAAa;AAE1F,MAAI,OAAO,IAAI,QAAQ,GAAG;AACtB,WAAO,MAAM,IAAI,QAAQ;AAAA,EAC7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UAAU;AACX,eAAWA,YAAW,iBAAiB;AAAA,MACnC,GAAI,OAAO,EAAE,IAAI;AAAA,MACjB,MAAM;AAAA,IACV,CAAC;AAAA,EACL;AAEA,MAAI,CAAC,UAAU;AACX,UAAM,IAAIC,eAAc,kCAAkC,cAAc,0BAA0B;AAAA,EACtG;AAEA,QAAM,QAAQ,QAAQ,SAAS,OAAO,QAAQ,UAAU,YAAY,QAAQ,QAAQ;AAEpF,MAAI,QAAQ,SAAS,MAAM,IAAI,QAAQ,GAAG;AACtC,WAAO,MAAM,IAAI,QAAQ;AAAA,EAC7B;AAEA,QAAM,SAAS;AAAA,IACX,QAAQ,aAAa,QAAQ;AAAA,IAC7B,MAAM;AAAA,EACV;AAEA,MAAI,QAAQ,OAAO;AACf,UAAM,IAAI,UAAU,MAAM;AAAA,EAC9B;AAEA,SAAO;AACX;AAGO,IAAM,mBAAmB;AAWzB,IAAM,gBAAgB,OAAO,MAAoB,UAAqD,CAAC,MAAqB;AAC/H,QAAM,EAAE,KAAK,GAAG,aAAa,IAAI;AAEjC,QAAM,YAAY,OAAO,QAAQ,OAAO,QAAQ,IAAI,CAAC;AAErD,QAAM,UAAUC,MAAK,WAAW,eAAe,GAAG,MAAM,YAAY;AACxE;AAGO,IAAM,gBAAgB","sourcesContent":["import type { WriteJsonOptions } from \"@visulima/fs\";\nimport { findUp, findUpSync, writeJson } from \"@visulima/fs\";\nimport { NotFoundError } from \"@visulima/fs/error\";\nimport { toPath } from \"@visulima/fs/utils\";\nimport { join } from \"pathe\";\nimport type { TsConfigJson } from \"type-fest\";\n\nimport { readTsConfig } from \"./read-tsconfig\";\nimport type { TsConfigJsonResolved } from \"./types\";\n\ntype Options = {\n cache?: Map<string, TsConfigJsonResolved> | boolean;\n configFileName?: string;\n};\n\nconst TsConfigFileCache = new Map<string, TsConfigResult>();\n\nexport type TsConfigResult = {\n config: TsConfigJsonResolved;\n path: string;\n};\n\n/**\n * An asynchronous function that retrieves the TSConfig by searching for the \"tsconfig.json\" first,\n * second attempt is to look for the \"jsconfig.json\" file from a given current working directory.\n *\n * @param cwd - Optional. The current working directory from which to search for the \"tsconfig.json\" file.\n * The type of `cwd` is `string`.\n * @returns A `Promise` that resolves to the TSConfig result object.\n * The return type of the function is `Promise<TsConfigResult>`.\n * @throws An `Error` when the \"tsconfig.json\" file is not found.\n */\nexport const findTsConfig = async (cwd?: URL | string, options: Options = {}): Promise<TsConfigResult> => {\n const configFileName = options.configFileName ?? \"tsconfig.json\";\n\n let filePath = await findUp(configFileName, {\n ...(cwd && { cwd }),\n type: \"file\",\n });\n\n if (!filePath) {\n filePath = await findUp(\"jsconfig.json\", {\n ...(cwd && { cwd }),\n type: \"file\",\n });\n }\n\n if (!filePath) {\n throw new NotFoundError(`No such file or directory, for ${configFileName} or jsconfig.json found.`);\n }\n\n const cache = options.cache && typeof options.cache !== \"boolean\" ? options.cache : TsConfigFileCache;\n\n if (options.cache && cache.has(filePath)) {\n return cache.get(filePath) as TsConfigResult;\n }\n\n const output = {\n config: readTsConfig(filePath),\n path: filePath,\n };\n\n if (options.cache) {\n cache.set(filePath, output);\n }\n\n return output;\n};\n\n// @deprecate Please use `findTsConfig` instead.\nexport const findTSConfig = findTsConfig;\n\nexport const findTsConfigSync = (cwd?: URL | string, options: Options = {}): TsConfigResult => {\n const configFileName = options.configFileName ?? \"tsconfig.json\";\n\n let filePath = findUpSync(configFileName, {\n ...(cwd && { cwd }),\n type: \"file\",\n });\n\n if (!filePath) {\n filePath = findUpSync(\"jsconfig.json\", {\n ...(cwd && { cwd }),\n type: \"file\",\n });\n }\n\n if (!filePath) {\n throw new NotFoundError(`No such file or directory, for ${configFileName} or jsconfig.json found.`);\n }\n\n const cache = options.cache && typeof options.cache !== \"boolean\" ? options.cache : TsConfigFileCache;\n\n if (options.cache && cache.has(filePath)) {\n return cache.get(filePath) as TsConfigResult;\n }\n\n const output = {\n config: readTsConfig(filePath),\n path: filePath,\n };\n\n if (options.cache) {\n cache.set(filePath, output);\n }\n\n return output;\n};\n\n// @deprecate Please use `findTsConfigSync` instead.\nexport const findTSConfigSync = findTsConfigSync;\n\n/**\n * An asynchronous function that writes the provided TypeScript configuration object to a tsconfig.json file.\n *\n * @param tsConfig - The TypeScript configuration object to write. The type of `tsConfig` is `TsConfigJson`.\n * @param options - Optional. The write options and the current working directory. The type of `options` is an\n * intersection type of `WriteOptions` and a Record type with an optional `cwd` key of type `string`.\n * @returns A `Promise` that resolves when the tsconfig.json file has been written.\n * The return type of function is `Promise<void>`.\n */\nexport const writeTsConfig = async (data: TsConfigJson, options: WriteJsonOptions & { cwd?: URL | string } = {}): Promise<void> => {\n const { cwd, ...writeOptions } = options;\n\n const directory = toPath(options.cwd ?? process.cwd());\n\n await writeJson(join(directory, \"tsconfig.json\"), data, writeOptions);\n};\n\n// @deprecate Please use `writeTsconfig` instead.\nexport const writeTSConfig = writeTsConfig;\n// eslint-disable-next-line import/no-unused-modules\nexport { implicitBaseUrlSymbol } from \"./read-tsconfig\";\n","/**\n * A modified version of `readTsconfig` from `https://github.com/privatenumber/get-tsconfig/blob/develop/src/parse-tsconfig/index.ts`\n *\n * MIT License\n * Copyright (c) Hiroki Osame <hiroki.osame@gmail.com>\n */\nimport { readFileSync } from \"@visulima/fs\";\nimport { NotFoundError } from \"@visulima/fs/error\";\nimport { parse } from \"jsonc-parser\";\nimport { dirname, join, normalize, relative, resolve, toNamespacedPath } from \"pathe\";\nimport type { TsConfigJson } from \"type-fest\";\n\nimport type { TsConfigJsonResolved } from \"./types\";\nimport resolveExtendsPath from \"./utils/resolve-extends-path\";\n\ntype Options = {\n tscCompatible?: boolean;\n};\n\nconst readJsonc = (jsonPath: string) => parse(readFileSync(jsonPath) as string) as unknown;\n// eslint-disable-next-line security/detect-unsafe-regex\nconst normalizePath = (path: string): string => toNamespacedPath(/^\\.{1,2}(?:\\/.*)?$/.test(path) ? path : `./${path}`);\n\nconst resolveExtends = (extendsPath: string, fromDirectoryPath: string, circularExtendsTracker: Set<string>, options?: Options) => {\n const resolvedExtendsPath = resolveExtendsPath(extendsPath, fromDirectoryPath);\n\n if (!resolvedExtendsPath) {\n throw new NotFoundError(`No such file or directory, for '${extendsPath}' found.`);\n }\n\n if (circularExtendsTracker.has(resolvedExtendsPath)) {\n throw new Error(`Circularity detected while resolving configuration: ${resolvedExtendsPath}`);\n }\n\n circularExtendsTracker.add(resolvedExtendsPath);\n\n const extendsDirectoryPath = dirname(resolvedExtendsPath);\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n const extendsConfig = internalParseTsConfig(resolvedExtendsPath, options, circularExtendsTracker);\n\n delete extendsConfig.references;\n\n const { compilerOptions } = extendsConfig;\n\n if (compilerOptions) {\n const resolvePaths = [\"baseUrl\", \"outDir\"] as const;\n\n // eslint-disable-next-line no-loops/no-loops,no-restricted-syntax\n for (const property of resolvePaths) {\n // eslint-disable-next-line security/detect-object-injection\n const unresolvedPath = compilerOptions[property];\n\n if (unresolvedPath) {\n // eslint-disable-next-line security/detect-object-injection\n compilerOptions[property] = relative(fromDirectoryPath, join(extendsDirectoryPath, unresolvedPath)).replaceAll(\"\\\\\", \"/\") || \"./\";\n }\n }\n }\n\n if (extendsConfig.files) {\n extendsConfig.files = extendsConfig.files.map((file) => relative(fromDirectoryPath, join(extendsDirectoryPath, file)));\n }\n\n if (extendsConfig.include) {\n extendsConfig.include = extendsConfig.include.map((file) => relative(fromDirectoryPath, join(extendsDirectoryPath, file)));\n }\n\n if (extendsConfig.exclude) {\n extendsConfig.exclude = extendsConfig.exclude.map((file) => relative(fromDirectoryPath, join(extendsDirectoryPath, file)));\n }\n\n return extendsConfig;\n};\n\n// eslint-disable-next-line sonarjs/cognitive-complexity\nconst internalParseTsConfig = (tsconfigPath: string, options?: Options, circularExtendsTracker = new Set<string>()): TsConfigJsonResolved => {\n /**\n * Decided not to cache the TsConfigJsonResolved object because it's\n * mutable.\n *\n * Note how `resolveExtends` can call `readTsconfig` rescursively\n * and actually mutates the object. It can also be mutated in\n * user-land.\n *\n * By only caching fs results, we can avoid serving mutated objects\n */\n let config: TsConfigJson;\n\n try {\n config = readJsonc(tsconfigPath) || {};\n } catch {\n throw new Error(`Cannot resolve tsconfig at path: ${tsconfigPath}`);\n }\n\n if (typeof config !== \"object\") {\n throw new SyntaxError(`Failed to parse tsconfig at: ${tsconfigPath}`);\n }\n\n const directoryPath = dirname(tsconfigPath);\n\n if (config.compilerOptions) {\n const { compilerOptions } = config;\n if (compilerOptions.paths && !compilerOptions.baseUrl) {\n type WithImplicitBaseUrl = TsConfigJson.CompilerOptions & {\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n [implicitBaseUrlSymbol]: string;\n };\n // eslint-disable-next-line security/detect-object-injection,@typescript-eslint/no-use-before-define\n (compilerOptions as WithImplicitBaseUrl)[implicitBaseUrlSymbol] = directoryPath;\n }\n }\n\n if (config.extends) {\n const extendsPathList = Array.isArray(config.extends) ? config.extends : [config.extends];\n\n delete config.extends;\n\n // eslint-disable-next-line no-loops/no-loops,no-restricted-syntax,etc/no-assign-mutated-array\n for (const extendsPath of extendsPathList.reverse()) {\n const extendsConfig = resolveExtends(extendsPath, directoryPath, new Set(circularExtendsTracker), options);\n const merged = {\n ...extendsConfig,\n ...config,\n\n compilerOptions: {\n ...extendsConfig.compilerOptions,\n ...config.compilerOptions,\n },\n };\n\n if (extendsConfig.watchOptions) {\n merged.watchOptions = {\n ...extendsConfig.watchOptions,\n ...config.watchOptions,\n };\n }\n\n config = merged;\n }\n }\n\n if (config.compilerOptions) {\n const { compilerOptions } = config;\n const normalizedPaths = [\"baseUrl\", \"rootDir\"] as const;\n\n // eslint-disable-next-line no-loops/no-loops,no-restricted-syntax\n for (const property of normalizedPaths) {\n // eslint-disable-next-line security/detect-object-injection\n const unresolvedPath = compilerOptions[property];\n\n if (unresolvedPath) {\n const resolvedBaseUrl = resolve(directoryPath, unresolvedPath);\n const relativeBaseUrl = relative(directoryPath, resolvedBaseUrl);\n\n // eslint-disable-next-line security/detect-object-injection\n compilerOptions[property] = normalizePath(relativeBaseUrl);\n }\n }\n\n const { outDir } = compilerOptions;\n\n if (outDir) {\n if (!Array.isArray(config.exclude)) {\n config.exclude = [];\n }\n\n if (!config.exclude.includes(outDir)) {\n config.exclude.push(outDir);\n }\n\n compilerOptions.outDir = normalizePath(outDir);\n }\n\n if (options?.tscCompatible && compilerOptions.module === \"node16\") {\n compilerOptions.allowSyntheticDefaultImports = compilerOptions.allowSyntheticDefaultImports ?? true;\n compilerOptions.esModuleInterop = compilerOptions.esModuleInterop ?? true;\n compilerOptions.moduleDetection = compilerOptions.moduleDetection ?? \"force\";\n compilerOptions.moduleResolution = compilerOptions.moduleResolution ?? \"node16\";\n compilerOptions.target = compilerOptions.target ?? \"es2022\";\n compilerOptions.useDefineForClassFields = compilerOptions.useDefineForClassFields ?? true;\n }\n\n if (options?.tscCompatible && compilerOptions.strict) {\n compilerOptions.noImplicitAny = compilerOptions.noImplicitAny ?? true;\n compilerOptions.noImplicitThis = compilerOptions.noImplicitThis ?? true;\n compilerOptions.strictNullChecks = compilerOptions.strictNullChecks ?? true;\n compilerOptions.strictFunctionTypes = compilerOptions.strictFunctionTypes ?? true;\n compilerOptions.strictBindCallApply = compilerOptions.strictBindCallApply ?? true;\n compilerOptions.strictPropertyInitialization = compilerOptions.strictPropertyInitialization ?? true;\n compilerOptions.alwaysStrict = compilerOptions.alwaysStrict ?? true;\n compilerOptions.useUnknownInCatchVariables = compilerOptions.useUnknownInCatchVariables ?? true;\n }\n\n if (options?.tscCompatible && compilerOptions.isolatedModules) {\n compilerOptions.preserveConstEnums = compilerOptions.preserveConstEnums ?? true;\n }\n\n if (options?.tscCompatible && compilerOptions.esModuleInterop) {\n compilerOptions.allowSyntheticDefaultImports = compilerOptions.allowSyntheticDefaultImports ?? true;\n }\n\n if (options?.tscCompatible && compilerOptions.target === \"esnext\") {\n compilerOptions.useDefineForClassFields = compilerOptions.useDefineForClassFields ?? true;\n }\n } else {\n config.compilerOptions = {};\n }\n\n if (config.files) {\n config.files = config.files.map((element) => normalizePath(element));\n }\n\n if (config.include) {\n config.include = config.include.map((element) => normalize(element));\n }\n\n if (config.watchOptions) {\n const { watchOptions } = config;\n\n if (watchOptions.excludeDirectories) {\n watchOptions.excludeDirectories = watchOptions.excludeDirectories.map((excludePath) => resolve(directoryPath, excludePath));\n }\n }\n\n return config;\n};\n\nexport const implicitBaseUrlSymbol = Symbol(\"implicitBaseUrl\");\nexport const readTsConfig = (tsconfigPath: string, options?: Options): TsConfigJsonResolved => internalParseTsConfig(tsconfigPath, options);\n","/**\n * A modified version of `resolveExtendsPath` from `https://github.com/privatenumber/get-tsconfig/blob/develop/src/parse-tsconfig/resolve-extends-path.ts`\n *\n * MIT License\n * Copyright (c) Hiroki Osame <hiroki.osame@gmail.com>\n */\nimport { existsSync, statSync } from \"node:fs\";\nimport Module from \"node:module\";\nimport { isAbsolute, join, resolve } from \"node:path\";\n\nimport { findUpSync, readFileSync } from \"@visulima/fs\";\nimport { parse } from \"jsonc-parser\";\nimport type { PathConditions } from \"resolve-pkg-maps\";\nimport { resolveExports } from \"resolve-pkg-maps\";\nimport type { PackageJson } from \"type-fest\";\n\nimport type { Cache } from \"../types\";\n\nconst readJsonc = (jsonPath: string) => parse(readFileSync(jsonPath) as string) as unknown;\n\nconst getPnpApi = () => {\n const { findPnpApi } = Module;\n\n // https://yarnpkg.com/advanced/pnpapi/#requirepnpapi\n return findPnpApi?.(process.cwd());\n};\n\nconst resolveFromPackageJsonPath = (packageJsonPath: string, subpath: string, ignoreExports?: boolean, cache?: Cache<string>) => {\n const cacheKey = `resolveFromPackageJsonPath:${packageJsonPath}:${subpath}:${ignoreExports}`;\n\n if (cache?.has(cacheKey)) {\n return cache.get(cacheKey);\n }\n\n const packageJson = readJsonc(packageJsonPath);\n\n if (!packageJson) {\n return undefined;\n }\n\n let resolvedPath = subpath || \"tsconfig.json\";\n\n if (!ignoreExports && (packageJson as PackageJson).exports) {\n try {\n const [resolvedExport] = resolveExports((packageJson as PackageJson).exports as PathConditions, subpath, [\"require\", \"types\"]);\n\n resolvedPath = resolvedExport as string;\n } catch {\n // Block\n return false;\n }\n } else if (!subpath && (packageJson as PackageJson).tsconfig) {\n resolvedPath = (packageJson as PackageJson).tsconfig as string;\n }\n\n resolvedPath = join(packageJsonPath, \"..\", resolvedPath);\n\n cache?.set(cacheKey, resolvedPath);\n\n return resolvedPath;\n};\n\nconst PACKAGE_JSON = \"package.json\";\nconst TS_CONFIG_JSON = \"tsconfig.json\";\n\n// eslint-disable-next-line sonarjs/cognitive-complexity\nconst resolveExtendsPath = (requestedPath: string, directoryPath: string, cache?: Cache<string>): string | undefined => {\n let filePath = requestedPath;\n\n if (requestedPath === \"..\") {\n filePath = join(filePath, TS_CONFIG_JSON);\n }\n\n if (requestedPath.startsWith(\".\")) {\n filePath = resolve(directoryPath, filePath);\n }\n\n if (isAbsolute(filePath)) {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (existsSync(filePath)) {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (statSync(filePath).isFile()) {\n return filePath;\n }\n } else if (!filePath.endsWith(\".json\")) {\n const jsonPath = `${filePath}.json`;\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (existsSync(jsonPath)) {\n return jsonPath;\n }\n }\n\n return undefined;\n }\n\n const [orgOrName, ...remaining] = requestedPath.split(\"/\");\n const packageName = ((orgOrName as string).startsWith(\"@\") ? `${orgOrName}/${remaining.shift()}` : orgOrName) as string;\n const subpath = remaining.join(\"/\");\n\n const pnpApi = getPnpApi();\n\n if (pnpApi) {\n const { resolveRequest: resolveWithPnp } = pnpApi;\n\n try {\n if (packageName === requestedPath) {\n const packageJsonPath = resolveWithPnp(join(packageName, PACKAGE_JSON), directoryPath);\n\n if (packageJsonPath) {\n const resolvedPath = resolveFromPackageJsonPath(packageJsonPath, subpath, false, cache);\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (resolvedPath && existsSync(resolvedPath)) {\n return resolvedPath;\n }\n }\n } else {\n let resolved: string | null;\n\n try {\n resolved = resolveWithPnp(requestedPath, directoryPath, { extensions: [\".json\"] });\n } catch {\n resolved = resolveWithPnp(join(requestedPath, TS_CONFIG_JSON), directoryPath);\n }\n\n if (resolved) {\n return resolved;\n }\n }\n } catch {\n /* empty */\n }\n }\n\n const packagePath = findUpSync(\n (directory) => {\n const path = join(directory, \"node_modules\", packageName);\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (existsSync(path)) {\n return join(\"node_modules\", packageName);\n }\n\n return undefined;\n },\n {\n cwd: directoryPath,\n type: \"directory\",\n },\n );\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (!packagePath || !statSync(packagePath).isDirectory()) {\n return undefined;\n }\n\n const packageJsonPath = join(packagePath, PACKAGE_JSON);\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (existsSync(packageJsonPath)) {\n const resolvedPath = resolveFromPackageJsonPath(packageJsonPath, subpath, false, cache);\n\n // Blocked\n if (resolvedPath === false) {\n return undefined;\n }\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (resolvedPath && existsSync(resolvedPath) && statSync(resolvedPath).isFile()) {\n return resolvedPath;\n }\n }\n\n const fullPackagePath = join(packagePath, subpath);\n const jsonExtension = fullPackagePath.endsWith(\".json\");\n\n if (!jsonExtension) {\n const fullPackagePathWithJson = `${fullPackagePath}.json`;\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (existsSync(fullPackagePathWithJson)) {\n return fullPackagePathWithJson;\n }\n }\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (!existsSync(fullPackagePath)) {\n return undefined;\n }\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (statSync(fullPackagePath).isDirectory()) {\n const fullPackageJsonPath = join(fullPackagePath, PACKAGE_JSON);\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (existsSync(fullPackageJsonPath)) {\n const resolvedPath = resolveFromPackageJsonPath(fullPackageJsonPath, \"\", true, cache);\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (resolvedPath && existsSync(resolvedPath)) {\n return resolvedPath;\n }\n }\n\n const tsconfigPath = join(fullPackagePath, TS_CONFIG_JSON);\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (existsSync(tsconfigPath)) {\n return tsconfigPath;\n }\n } else if (jsonExtension) {\n return fullPackagePath;\n }\n\n return undefined;\n};\n\nexport default resolveExtendsPath;\n"]}
@@ -1,52 +0,0 @@
1
- 'use strict';
2
-
3
- var chunkIK5YSYLX_cjs = require('./chunk-IK5YSYLX.cjs');
4
-
5
- // src/error/package-not-found-error.ts
6
- var PackageNotFoundError = class extends Error {
7
- /**
8
- * @param {string} packageName - The name of the package that was not found.
9
- * @param {string} packageManager - The package manager used to install the package.
10
- */
11
- constructor(packageName, packageManager) {
12
- if (typeof packageName === "string") {
13
- packageName = [packageName];
14
- }
15
- if (packageName.length === 0) {
16
- super("Package was not found.");
17
- return;
18
- }
19
- if (packageManager === void 0) {
20
- try {
21
- const foundManager = chunkIK5YSYLX_cjs.findPackageManagerSync();
22
- packageManager = foundManager.packageManager;
23
- } catch {
24
- }
25
- }
26
- if (packageManager === void 0) {
27
- packageManager = "npm";
28
- }
29
- super(`Package '${packageName.join(" ")}' was not found. Please install it using '${packageManager} install ${packageName.join(" ")}'`);
30
- }
31
- // eslint-disable-next-line class-methods-use-this,@typescript-eslint/class-literal-property-style
32
- get code() {
33
- return "PACKAGE_NOT_FOUND";
34
- }
35
- // eslint-disable-next-line class-methods-use-this,@typescript-eslint/explicit-module-boundary-types
36
- set code(_name) {
37
- throw new Error("Cannot overwrite code PACKAGE_NOT_FOUND");
38
- }
39
- // eslint-disable-next-line class-methods-use-this,@typescript-eslint/class-literal-property-style
40
- get name() {
41
- return "PackageNotFoundError";
42
- }
43
- // eslint-disable-next-line class-methods-use-this,@typescript-eslint/explicit-module-boundary-types
44
- set name(_name) {
45
- throw new Error("Cannot overwrite name of PackageNotFoundError");
46
- }
47
- };
48
- var package_not_found_error_default = PackageNotFoundError;
49
-
50
- exports.package_not_found_error_default = package_not_found_error_default;
51
- //# sourceMappingURL=out.js.map
52
- //# sourceMappingURL=chunk-7IOK6YPW.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/error/package-not-found-error.ts"],"names":[],"mappings":";;;;;AAKA,IAAM,uBAAN,cAAmC,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA,EAK9B,YAAY,aAAgC,gBAAyB;AACxE,QAAI,OAAO,gBAAgB,UAAU;AAEjC,oBAAc,CAAC,WAAW;AAAA,IAC9B;AAEA,QAAI,YAAY,WAAW,GAAG;AAC1B,YAAM,wBAAwB;AAC9B;AAAA,IACJ;AAEA,QAAI,mBAAmB,QAAW;AAC9B,UAAI;AACA,cAAM,eAAe,uBAAuB;AAG5C,yBAAiB,aAAa;AAAA,MAClC,QAAQ;AAAA,MAER;AAAA,IACJ;AAEA,QAAI,mBAAmB,QAAW;AAE9B,uBAAiB;AAAA,IACrB;AAEA,UAAM,YAAY,YAAY,KAAK,GAAG,CAAC,6CAA6C,cAAc,YAAY,YAAY,KAAK,GAAG,CAAC,GAAG;AAAA,EAC1I;AAAA;AAAA,EAGA,IAAW,OAAe;AACtB,WAAO;AAAA,EACX;AAAA;AAAA,EAGA,IAAW,KAAK,OAAO;AACnB,UAAM,IAAI,MAAM,yCAAyC;AAAA,EAC7D;AAAA;AAAA,EAGA,IAAoB,OAAe;AAC/B,WAAO;AAAA,EACX;AAAA;AAAA,EAGA,IAAoB,KAAK,OAAO;AAC5B,UAAM,IAAI,MAAM,+CAA+C;AAAA,EACnE;AACJ;AAEA,IAAO,kCAAQ","sourcesContent":["import { findPackageManagerSync } from \"../package-manager\";\n\n/**\n * Error thrown when a package was not found.\n */\nclass PackageNotFoundError extends Error {\n /**\n * @param {string} packageName - The name of the package that was not found.\n * @param {string} packageManager - The package manager used to install the package.\n */\n public constructor(packageName: string[] | string, packageManager?: string) {\n if (typeof packageName === \"string\") {\n // eslint-disable-next-line no-param-reassign\n packageName = [packageName];\n }\n\n if (packageName.length === 0) {\n super(\"Package was not found.\");\n return;\n }\n\n if (packageManager === undefined) {\n try {\n const foundManager = findPackageManagerSync();\n\n // eslint-disable-next-line no-param-reassign\n packageManager = foundManager.packageManager;\n } catch {\n // Empty\n }\n }\n\n if (packageManager === undefined) {\n // eslint-disable-next-line no-param-reassign\n packageManager = \"npm\";\n }\n\n super(`Package '${packageName.join(\" \")}' was not found. Please install it using '${packageManager} install ${packageName.join(\" \")}'`);\n }\n\n // eslint-disable-next-line class-methods-use-this,@typescript-eslint/class-literal-property-style\n public get code(): string {\n return \"PACKAGE_NOT_FOUND\";\n }\n\n // eslint-disable-next-line class-methods-use-this,@typescript-eslint/explicit-module-boundary-types\n public set code(_name) {\n throw new Error(\"Cannot overwrite code PACKAGE_NOT_FOUND\");\n }\n\n // eslint-disable-next-line class-methods-use-this,@typescript-eslint/class-literal-property-style\n public override get name(): string {\n return \"PackageNotFoundError\";\n }\n\n // eslint-disable-next-line class-methods-use-this,@typescript-eslint/explicit-module-boundary-types\n public override set name(_name) {\n throw new Error(\"Cannot overwrite name of PackageNotFoundError\");\n }\n}\n\nexport default PackageNotFoundError;\n"]}
@@ -1,65 +0,0 @@
1
- 'use strict';
2
-
3
- var chunkIK5YSYLX_cjs = require('./chunk-IK5YSYLX.cjs');
4
- var fs$1 = require('fs');
5
- var fs = require('@visulima/fs');
6
- var pathe = require('pathe');
7
-
8
- var packageJsonMatcher = (directory) => {
9
- if (fs$1.existsSync(pathe.join(directory, "package.json"))) {
10
- const packageJson = fs.readJsonSync(pathe.join(directory, "package.json"));
11
- if (packageJson.name && packageJson.private !== true) {
12
- return "package.json";
13
- }
14
- }
15
- return void 0;
16
- };
17
- var findPackageRoot = async (cwd) => {
18
- try {
19
- const lockFile = await chunkIK5YSYLX_cjs.findLockFile(cwd);
20
- return pathe.dirname(lockFile);
21
- } catch {
22
- }
23
- const gitConfig = await fs.findUp(".git/config", {
24
- ...cwd && { cwd },
25
- type: "file"
26
- });
27
- if (gitConfig) {
28
- return pathe.dirname(pathe.dirname(gitConfig));
29
- }
30
- const filePath = await fs.findUp(packageJsonMatcher, {
31
- ...cwd && { cwd },
32
- type: "file"
33
- });
34
- if (filePath) {
35
- return pathe.dirname(filePath);
36
- }
37
- throw new Error("Could not find root directory");
38
- };
39
- var findPackageRootSync = (cwd) => {
40
- try {
41
- const lockFile = chunkIK5YSYLX_cjs.findLockFileSync(cwd);
42
- return pathe.dirname(lockFile);
43
- } catch {
44
- }
45
- const gitConfig = fs.findUpSync(".git/config", {
46
- ...cwd && { cwd },
47
- type: "file"
48
- });
49
- if (gitConfig) {
50
- return pathe.dirname(pathe.dirname(gitConfig));
51
- }
52
- const filePath = fs.findUpSync(packageJsonMatcher, {
53
- ...cwd && { cwd },
54
- type: "file"
55
- });
56
- if (filePath) {
57
- return pathe.dirname(filePath);
58
- }
59
- throw new Error("Could not find root directory");
60
- };
61
-
62
- exports.findPackageRoot = findPackageRoot;
63
- exports.findPackageRootSync = findPackageRootSync;
64
- //# sourceMappingURL=out.js.map
65
- //# sourceMappingURL=chunk-CVVFWSMT.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/package.ts"],"names":[],"mappings":";;;;;;AAAA,SAAS,kBAAkB;AAE3B,SAAS,QAAQ,YAAY,oBAAoB;AACjD,SAAS,SAAS,YAAY;AAK9B,IAAM,qBAAqB,CAAC,cAAsB;AAE9C,MAAI,WAAW,KAAK,WAAW,cAAc,CAAC,GAAG;AAC7C,UAAM,cAAc,aAA0B,KAAK,WAAW,cAAc,CAAC;AAE7E,QAAI,YAAY,QAAQ,YAAY,YAAY,MAAM;AAClD,aAAO;AAAA,IACX;AAAA,EACJ;AAEA,SAAO;AACX;AAaO,IAAM,kBAAkB,OAAO,QAAwC;AAC1E,MAAI;AACA,UAAM,WAAW,MAAM,aAAa,GAAG;AAEvC,WAAO,QAAQ,QAAQ;AAAA,EAC3B,QAAQ;AAAA,EAER;AAEA,QAAM,YAAY,MAAM,OAAO,eAAe;AAAA,IAC1C,GAAI,OAAO,EAAE,IAAI;AAAA,IACjB,MAAM;AAAA,EACV,CAAC;AAED,MAAI,WAAW;AACX,WAAO,QAAQ,QAAQ,SAAS,CAAC;AAAA,EACrC;AAEA,QAAM,WAAW,MAAM,OAAO,oBAAoB;AAAA,IAC9C,GAAI,OAAO,EAAE,IAAI;AAAA,IACjB,MAAM;AAAA,EACV,CAAC;AAED,MAAI,UAAU;AACV,WAAO,QAAQ,QAAQ;AAAA,EAC3B;AAEA,QAAM,IAAI,MAAM,+BAA+B;AACnD;AAEO,IAAM,sBAAsB,CAAC,QAA+B;AAC/D,MAAI;AACA,UAAM,WAAW,iBAAiB,GAAG;AAErC,WAAO,QAAQ,QAAQ;AAAA,EAC3B,QAAQ;AAAA,EAER;AAEA,QAAM,YAAY,WAAW,eAAe;AAAA,IACxC,GAAI,OAAO,EAAE,IAAI;AAAA,IACjB,MAAM;AAAA,EACV,CAAC;AAED,MAAI,WAAW;AACX,WAAO,QAAQ,QAAQ,SAAS,CAAC;AAAA,EACrC;AAEA,QAAM,WAAW,WAAW,oBAAoB;AAAA,IAC5C,GAAI,OAAO,EAAE,IAAI;AAAA,IACjB,MAAM;AAAA,EACV,CAAC;AAED,MAAI,UAAU;AACV,WAAO,QAAQ,QAAQ;AAAA,EAC3B;AAEA,QAAM,IAAI,MAAM,+BAA+B;AACnD","sourcesContent":["import { existsSync } from \"node:fs\";\n\nimport { findUp, findUpSync, readJsonSync } from \"@visulima/fs\";\nimport { dirname, join } from \"pathe\";\n\nimport { findLockFile, findLockFileSync } from \"./package-manager\";\nimport type { PackageJson } from \"./types\";\n\nconst packageJsonMatcher = (directory: string) => {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (existsSync(join(directory, \"package.json\"))) {\n const packageJson = readJsonSync<PackageJson>(join(directory, \"package.json\"));\n\n if (packageJson.name && packageJson.private !== true) {\n return \"package.json\";\n }\n }\n\n return undefined;\n};\n\n/**\n * An asynchronous function that finds the root directory of a project based on certain lookup criteria.\n *\n * @param cwd - Optional. The current working directory to start the search from. The type of `cwd` is `string`.\n * @returns A `Promise` that resolves to the path of the root directory. The type of the returned promise is `Promise<string>`.\n * @throws An `Error` if the root directory could not be found.\n *\n * @example\n * const rootDirectory = await findPackageRoot();\n * console.log(rootDirectory); // '/path/to/project'\n */\nexport const findPackageRoot = async (cwd?: URL | string): Promise<string> => {\n try {\n const lockFile = await findLockFile(cwd);\n\n return dirname(lockFile);\n } catch {\n /* empty */\n }\n\n const gitConfig = await findUp(\".git/config\", {\n ...(cwd && { cwd }),\n type: \"file\",\n });\n\n if (gitConfig) {\n return dirname(dirname(gitConfig));\n }\n\n const filePath = await findUp(packageJsonMatcher, {\n ...(cwd && { cwd }),\n type: \"file\",\n });\n\n if (filePath) {\n return dirname(filePath);\n }\n\n throw new Error(\"Could not find root directory\");\n};\n\nexport const findPackageRootSync = (cwd?: URL | string): string => {\n try {\n const lockFile = findLockFileSync(cwd);\n\n return dirname(lockFile);\n } catch {\n /* empty */\n }\n\n const gitConfig = findUpSync(\".git/config\", {\n ...(cwd && { cwd }),\n type: \"file\",\n });\n\n if (gitConfig) {\n return dirname(dirname(gitConfig));\n }\n\n const filePath = findUpSync(packageJsonMatcher, {\n ...(cwd && { cwd }),\n type: \"file\",\n });\n\n if (filePath) {\n return dirname(filePath);\n }\n\n throw new Error(\"Could not find root directory\");\n};\n"]}
@@ -1,54 +0,0 @@
1
- import { findPackageManager } from './chunk-IIYQBLPC.js';
2
- import { existsSync, readFileSync } from 'node:fs';
3
- import { findUp, readJson } from '@visulima/fs';
4
- import { NotFoundError } from '@visulima/fs/error';
5
- import { dirname, join } from 'pathe';
6
-
7
- var findMonorepoRoot = async (cwd) => {
8
- const workspaceFilePath = await findUp(["lerna.json", "turbo.json"], {
9
- type: "file",
10
- ...cwd && { cwd }
11
- });
12
- if (workspaceFilePath?.endsWith("lerna.json")) {
13
- const lerna = await readJson(workspaceFilePath);
14
- if (lerna.useWorkspaces || lerna.packages) {
15
- return {
16
- path: dirname(workspaceFilePath),
17
- strategy: "lerna"
18
- };
19
- }
20
- }
21
- const isTurbo = workspaceFilePath?.endsWith("turbo.json");
22
- try {
23
- const { packageManager, path } = await findPackageManager(cwd);
24
- if (["npm", "yarn"].includes(packageManager)) {
25
- const packageJsonFilePath = join(path, "package.json");
26
- if (existsSync(packageJsonFilePath)) {
27
- const packageJson = readFileSync(join(path, "package.json"), "utf8");
28
- if (packageJson.includes("workspaces")) {
29
- return {
30
- path,
31
- strategy: isTurbo ? "turbo" : packageManager
32
- };
33
- }
34
- }
35
- } else if (packageManager === "pnpm") {
36
- const pnpmWorkspacesFilePath = join(path, "pnpm-workspace.yaml");
37
- if (existsSync(pnpmWorkspacesFilePath)) {
38
- return {
39
- path,
40
- strategy: isTurbo ? "turbo" : "pnpm"
41
- };
42
- }
43
- }
44
- } catch (error) {
45
- if (!(error instanceof NotFoundError)) {
46
- throw error;
47
- }
48
- }
49
- throw new Error(`No monorepo root could be found upwards from the directory ${cwd} using lerna, yarn, pnpm, or npm as indicators.`);
50
- };
51
-
52
- export { findMonorepoRoot };
53
- //# sourceMappingURL=out.js.map
54
- //# sourceMappingURL=chunk-E2PKJX3Q.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/monorepo.ts"],"names":[],"mappings":";;;;;AAAA,SAAS,YAAY,oBAAoB;AAEzC,SAAS,QAAQ,gBAAgB;AACjC,SAAS,qBAAqB;AAC9B,SAAS,SAAS,YAAY;AAsBvB,IAAM,mBAAmB,OAAO,QAA8C;AACjF,QAAM,oBAAoB,MAAM,OAAO,CAAC,cAAc,YAAY,GAAG;AAAA,IACjE,MAAM;AAAA,IACN,GAAI,OAAO,EAAE,IAAI;AAAA,EACrB,CAAC;AAED,MAAI,mBAAmB,SAAS,YAAY,GAAG;AAC3C,UAAM,QAAQ,MAAM,SAA2D,iBAAiB;AAEhG,QAAI,MAAM,iBAAiB,MAAM,UAAU;AACvC,aAAO;AAAA,QACH,MAAM,QAAQ,iBAAiB;AAAA,QAC/B,UAAU;AAAA,MACd;AAAA,IACJ;AAAA,EACJ;AAEA,QAAM,UAAU,mBAAmB,SAAS,YAAY;AAExD,MAAI;AACA,UAAM,EAAE,gBAAgB,KAAK,IAAI,MAAM,mBAAmB,GAAG;AAE7D,QAAI,CAAC,OAAO,MAAM,EAAE,SAAS,cAAc,GAAG;AAC1C,YAAM,sBAAsB,KAAK,MAAM,cAAc;AAGrD,UAAI,WAAW,mBAAmB,GAAG;AAEjC,cAAM,cAAc,aAAa,KAAK,MAAM,cAAc,GAAG,MAAM;AAEnE,YAAI,YAAY,SAAS,YAAY,GAAG;AACpC,iBAAO;AAAA,YACH;AAAA,YACA,UAAU,UAAU,UAAW;AAAA,UACnC;AAAA,QACJ;AAAA,MACJ;AAAA,IACJ,WAAW,mBAAmB,QAAQ;AAClC,YAAM,yBAAyB,KAAK,MAAM,qBAAqB;AAG/D,UAAI,WAAW,sBAAsB,GAAG;AACpC,eAAO;AAAA,UACH;AAAA,UACA,UAAU,UAAU,UAAU;AAAA,QAClC;AAAA,MACJ;AAAA,IACJ;AAAA,EAEJ,SAAS,OAAY;AAEjB,QAAI,EAAE,iBAAiB,gBAAgB;AACnC,YAAM;AAAA,IACV;AAAA,EACJ;AAEA,QAAM,IAAI,MAAM,8DAA8D,GAAa,iDAAiD;AAChJ","sourcesContent":["import { existsSync, readFileSync } from \"node:fs\";\n\nimport { findUp, readJson } from \"@visulima/fs\";\nimport { NotFoundError } from \"@visulima/fs/error\";\nimport { dirname, join } from \"pathe\";\n\nimport { findPackageManager } from \"./package-manager\";\n\nexport type Strategy = \"lerna\" | \"npm\" | \"pnpm\" | \"turbo\" | \"yarn\";\n\nexport interface RootMonorepo<T extends Strategy = Strategy> {\n path: string;\n strategy: T;\n}\n\n/**\n * An asynchronous function to find the root directory path and strategy for a monorepo based on\n * the given current working directory (cwd).\n *\n * @param cwd - The current working directory. The type of `cwd` is part of an `Options` type, specifically `Options[\"cwd\"]`.\n * Default is undefined.\n * @returns A `Promise` that resolves to the root directory path and strategy for the monorepo.\n * The type of the returned promise is `Promise<RootMonorepo>`.\n * @throws An `Error` if no monorepo root can be found using lerna, yarn, pnpm, or npm as indicators.\n */\n// eslint-disable-next-line sonarjs/cognitive-complexity\nexport const findMonorepoRoot = async (cwd?: URL | string): Promise<RootMonorepo> => {\n const workspaceFilePath = await findUp([\"lerna.json\", \"turbo.json\"], {\n type: \"file\",\n ...(cwd && { cwd }),\n });\n\n if (workspaceFilePath?.endsWith(\"lerna.json\")) {\n const lerna = await readJson<{ packages?: string[]; useWorkspaces?: boolean }>(workspaceFilePath);\n\n if (lerna.useWorkspaces || lerna.packages) {\n return {\n path: dirname(workspaceFilePath),\n strategy: \"lerna\",\n };\n }\n }\n\n const isTurbo = workspaceFilePath?.endsWith(\"turbo.json\");\n\n try {\n const { packageManager, path } = await findPackageManager(cwd);\n\n if ([\"npm\", \"yarn\"].includes(packageManager)) {\n const packageJsonFilePath = join(path, \"package.json\");\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (existsSync(packageJsonFilePath)) {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n const packageJson = readFileSync(join(path, \"package.json\"), \"utf8\");\n\n if (packageJson.includes(\"workspaces\")) {\n return {\n path,\n strategy: isTurbo ? \"turbo\" : (packageManager as \"npm\" | \"yarn\"),\n };\n }\n }\n } else if (packageManager === \"pnpm\") {\n const pnpmWorkspacesFilePath = join(path, \"pnpm-workspace.yaml\");\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (existsSync(pnpmWorkspacesFilePath)) {\n return {\n path,\n strategy: isTurbo ? \"turbo\" : \"pnpm\",\n };\n }\n }\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n // Skip this error to show the error message from the next block\n if (!(error instanceof NotFoundError)) {\n throw error;\n }\n }\n\n throw new Error(`No monorepo root could be found upwards from the directory ${cwd as string} using lerna, yarn, pnpm, or npm as indicators.`);\n};\n"]}
@@ -1,62 +0,0 @@
1
- import { findLockFile, findLockFileSync } from './chunk-IIYQBLPC.js';
2
- import { existsSync } from 'node:fs';
3
- import { findUp, findUpSync, readJsonSync } from '@visulima/fs';
4
- import { dirname, join } from 'pathe';
5
-
6
- var packageJsonMatcher = (directory) => {
7
- if (existsSync(join(directory, "package.json"))) {
8
- const packageJson = readJsonSync(join(directory, "package.json"));
9
- if (packageJson.name && packageJson.private !== true) {
10
- return "package.json";
11
- }
12
- }
13
- return void 0;
14
- };
15
- var findPackageRoot = async (cwd) => {
16
- try {
17
- const lockFile = await findLockFile(cwd);
18
- return dirname(lockFile);
19
- } catch {
20
- }
21
- const gitConfig = await findUp(".git/config", {
22
- ...cwd && { cwd },
23
- type: "file"
24
- });
25
- if (gitConfig) {
26
- return dirname(dirname(gitConfig));
27
- }
28
- const filePath = await findUp(packageJsonMatcher, {
29
- ...cwd && { cwd },
30
- type: "file"
31
- });
32
- if (filePath) {
33
- return dirname(filePath);
34
- }
35
- throw new Error("Could not find root directory");
36
- };
37
- var findPackageRootSync = (cwd) => {
38
- try {
39
- const lockFile = findLockFileSync(cwd);
40
- return dirname(lockFile);
41
- } catch {
42
- }
43
- const gitConfig = findUpSync(".git/config", {
44
- ...cwd && { cwd },
45
- type: "file"
46
- });
47
- if (gitConfig) {
48
- return dirname(dirname(gitConfig));
49
- }
50
- const filePath = findUpSync(packageJsonMatcher, {
51
- ...cwd && { cwd },
52
- type: "file"
53
- });
54
- if (filePath) {
55
- return dirname(filePath);
56
- }
57
- throw new Error("Could not find root directory");
58
- };
59
-
60
- export { findPackageRoot, findPackageRootSync };
61
- //# sourceMappingURL=out.js.map
62
- //# sourceMappingURL=chunk-EYMR7Z2I.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/package.ts"],"names":[],"mappings":";;;;;;AAAA,SAAS,kBAAkB;AAE3B,SAAS,QAAQ,YAAY,oBAAoB;AACjD,SAAS,SAAS,YAAY;AAK9B,IAAM,q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AACnD","sourcesContent":["import { existsSync } from \"node:fs\";\n\nimport { findUp, findUpSync, readJsonSync } from \"@visulima/fs\";\nimport { dirname, join } from \"pathe\";\n\nimport { findLockFile, findLockFileSync } from \"./package-manager\";\nimport type { PackageJson } from \"./types\";\n\nconst packageJsonMatcher = (directory: string) => {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (existsSync(join(directory, \"package.json\"))) {\n const packageJson = readJsonSync<PackageJson>(join(directory, \"package.json\"));\n\n if (packageJson.name && packageJson.private !== true) {\n return \"package.json\";\n }\n }\n\n return undefined;\n};\n\n/**\n * An asynchronous function that finds the root directory of a project based on certain lookup criteria.\n *\n * @param cwd - Optional. The current working directory to start the search from. The type of `cwd` is `string`.\n * @returns A `Promise` that resolves to the path of the root directory. The type of the returned promise is `Promise<string>`.\n * @throws An `Error` if the root directory could not be found.\n *\n * @example\n * const rootDirectory = await findPackageRoot();\n * console.log(rootDirectory); // '/path/to/project'\n */\nexport const findPackageRoot = async (cwd?: URL | string): Promise<string> => {\n try {\n const lockFile = await findLockFile(cwd);\n\n return dirname(lockFile);\n } catch {\n /* empty */\n }\n\n const gitConfig = await findUp(\".git/config\", {\n ...(cwd && { cwd }),\n type: \"file\",\n });\n\n if (gitConfig) {\n return dirname(dirname(gitConfig));\n }\n\n const filePath = await findUp(packageJsonMatcher, {\n ...(cwd && { cwd }),\n type: \"file\",\n });\n\n if (filePath) {\n return dirname(filePath);\n }\n\n throw new Error(\"Could not find root directory\");\n};\n\nexport const findPackageRootSync = (cwd?: URL | string): string => {\n try {\n const lockFile = findLockFileSync(cwd);\n\n return dirname(lockFile);\n } catch {\n /* empty */\n }\n\n const gitConfig = findUpSync(\".git/config\", {\n ...(cwd && { cwd }),\n type: \"file\",\n });\n\n if (gitConfig) {\n return dirname(dirname(gitConfig));\n }\n\n const filePath = findUpSync(packageJsonMatcher, {\n ...(cwd && { cwd }),\n type: \"file\",\n });\n\n if (filePath) {\n return dirname(filePath);\n }\n\n throw new Error(\"Could not find root directory\");\n};\n"]}
@@ -1,88 +0,0 @@
1
- 'use strict';
2
-
3
- var fs$1 = require('fs');
4
- var fs = require('@visulima/fs');
5
- var error = require('@visulima/fs/error');
6
- var utils = require('@visulima/fs/utils');
7
- var normalizeData = require('normalize-package-data');
8
- var pathe = require('pathe');
9
-
10
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
11
-
12
- var normalizeData__default = /*#__PURE__*/_interopDefault(normalizeData);
13
-
14
- // src/package-json.ts
15
- var PackageJsonFileCache = /* @__PURE__ */ new Map();
16
- var findPackageJson = async (cwd, options = {}) => {
17
- const filePath = await fs.findUp("package.json", {
18
- ...cwd && { cwd },
19
- type: "file"
20
- });
21
- if (!filePath) {
22
- throw new error.NotFoundError("No such file or directory, for package.json found.");
23
- }
24
- const cache = options.cache && typeof options.cache !== "boolean" ? options.cache : PackageJsonFileCache;
25
- if (options.cache && cache.has(filePath)) {
26
- return cache.get(filePath);
27
- }
28
- const packageJson = await fs.readJson(filePath);
29
- normalizeData__default.default(packageJson);
30
- const output = {
31
- packageJson,
32
- path: filePath
33
- };
34
- cache.set(filePath, output);
35
- return output;
36
- };
37
- var findPackageJsonSync = (cwd, options = {}) => {
38
- const filePath = fs.findUpSync("package.json", {
39
- ...cwd && { cwd },
40
- type: "file"
41
- });
42
- if (!filePath) {
43
- throw new error.NotFoundError("No such file or directory, for package.json found.");
44
- }
45
- const cache = options.cache && typeof options.cache !== "boolean" ? options.cache : PackageJsonFileCache;
46
- if (options.cache && cache.has(filePath)) {
47
- return cache.get(filePath);
48
- }
49
- const packageJson = fs.readJsonSync(filePath);
50
- normalizeData__default.default(packageJson);
51
- const output = {
52
- packageJson,
53
- path: filePath
54
- };
55
- cache.set(filePath, output);
56
- return output;
57
- };
58
- var writePackageJson = async (data, options = {}) => {
59
- const { cwd, ...writeOptions } = options;
60
- const directory = utils.toPath(options.cwd ?? process.cwd());
61
- await fs.writeJson(pathe.join(directory, "package.json"), data, writeOptions);
62
- };
63
- var writePackageJsonSync = (data, options = {}) => {
64
- const { cwd, ...writeOptions } = options;
65
- const directory = utils.toPath(options.cwd ?? process.cwd());
66
- fs.writeJsonSync(pathe.join(directory, "package.json"), data, writeOptions);
67
- };
68
- var parsePackageJson = (packageFile) => {
69
- const isObject = packageFile !== null && typeof packageFile === "object" && !Array.isArray(packageFile);
70
- const isString = typeof packageFile === "string";
71
- if (!isObject && !isString) {
72
- throw new TypeError("`packageFile` should be either an `object` or a `string`.");
73
- }
74
- const json = isObject ? structuredClone(packageFile) : (
75
- // eslint-disable-next-line security/detect-non-literal-fs-filename
76
- fs$1.existsSync(packageFile) ? fs.readJsonSync(packageFile) : utils.parseJson(packageFile)
77
- );
78
- normalizeData__default.default(json);
79
- return json;
80
- };
81
-
82
- exports.findPackageJson = findPackageJson;
83
- exports.findPackageJsonSync = findPackageJsonSync;
84
- exports.parsePackageJson = parsePackageJson;
85
- exports.writePackageJson = writePackageJson;
86
- exports.writePackageJsonSync = writePackageJsonSync;
87
- //# sourceMappingURL=out.js.map
88
- //# sourceMappingURL=chunk-G3SI24AJ.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/package-json.ts"],"names":[],"mappings":";AAAA,SAAS,kBAAkB;AAG3B,SAAS,QAAQ,YAAY,UAAU,cAAc,WAAW,qBAAqB;AACrF,SAAS,qBAAqB;AAC9B,SAAS,WAAW,cAAc;AAElC,OAAO,mBAAmB;AAC1B,SAAS,YAAY;AASrB,IAAM,uBAAuB,oBAAI,IAAkC;AAe5D,IAAM,kBAAkB,OAAO,KAAoB,UAAuB,CAAC,MAAqC;AACnH,QAAM,WAAW,MAAM,OAAO,gBAAgB;AAAA,IAC1C,GAAI,OAAO,EAAE,IAAI;AAAA,IACjB,MAAM;AAAA,EACV,CAAC;AAED,MAAI,CAAC,UAAU;AACX,UAAM,IAAI,cAAc,oDAAoD;AAAA,EAChF;AAEA,QAAM,QAAQ,QAAQ,SAAS,OAAO,QAAQ,UAAU,YAAY,QAAQ,QAAQ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AAEO,IAAM,mBAAmB,CAAC,gBAA4D;AAEzF,QAAM,WAAW,gBAAgB,QAAQ,OAAO,gBAAgB,YAAY,CAAC,MAAM,QAAQ,WAAW;AACtG,QAAM,WAAW,OAAO,gBAAgB;AAExC,MAAI,CAAC,YAAY,CAAC,UAAU;AACxB,UAAM,IAAI,UAAU,2DAA2D;AAAA,EACnF;AAEA,QAAM,OAAO,WACP,gBAAgB,WAAW;AAAA;AAAA,IAE3B,WAAW,WAAqB,IAC9B,aAAa,WAAqB,IAClC,UAAU,WAAqB;AAAA;AAEvC,gBAAc,IAAa;AAE3B,SAAO;AACX","sourcesContent":["import { existsSync } from \"node:fs\";\n\nimport type { WriteJsonOptions } from \"@visulima/fs\";\nimport { findUp, findUpSync, readJson, readJsonSync, writeJson, writeJsonSync } from \"@visulima/fs\";\nimport { NotFoundError } from \"@visulima/fs/error\";\nimport { parseJson, toPath } from \"@visulima/fs/utils\";\nimport type { Input } from \"normalize-package-data\";\nimport normalizeData from \"normalize-package-data\";\nimport { join } from \"pathe\";\nimport type { JsonObject } from \"type-fest\";\n\nimport type { Cache, NormalizedPackageJson, PackageJson } from \"./types\";\n\ntype ReadOptions = {\n cache?: Cache<NormalizedReadResult> | boolean;\n};\n\nconst PackageJsonFileCache = new Map<string, NormalizedReadResult>();\n\nexport type NormalizedReadResult = {\n packageJson: NormalizedPackageJson;\n path: string;\n};\n\n/**\n * An asynchronous function to find the package.json file in the specified directory or its parent directories.\n *\n * @param cwd - The current working directory.\n * @returns A `Promise` that resolves to an object containing the parsed package.json data and the file path.\n * The type of the returned promise is `Promise<NormalizedReadResult>`.\n * @throws An `Error` if the package.json file cannot be found.\n */\nexport const findPackageJson = async (cwd?: URL | string, options: ReadOptions = {}): Promise<NormalizedReadResult> => {\n const filePath = await findUp(\"package.json\", {\n ...(cwd && { cwd }),\n type: \"file\",\n });\n\n if (!filePath) {\n throw new NotFoundError(\"No such file or directory, for package.json found.\");\n }\n\n const cache = options.cache && typeof options.cache !== \"boolean\" ? options.cache : PackageJsonFileCache;\n\n if (options.cache && cache.has(filePath)) {\n return cache.get(filePath) as NormalizedReadResult;\n }\n\n const packageJson = await readJson(filePath);\n\n normalizeData(packageJson as Input);\n\n const output = {\n packageJson: packageJson as NormalizedPackageJson,\n path: filePath,\n };\n\n cache.set(filePath, output);\n\n return output;\n};\n\nexport const findPackageJsonSync = (cwd?: URL | string, options: ReadOptions = {}): NormalizedReadResult => {\n const filePath = findUpSync(\"package.json\", {\n ...(cwd && { cwd }),\n type: \"file\",\n });\n\n if (!filePath) {\n throw new NotFoundError(\"No such file or directory, for package.json found.\");\n }\n\n const cache = options.cache && typeof options.cache !== \"boolean\" ? options.cache : PackageJsonFileCache;\n\n if (options.cache && cache.has(filePath)) {\n return cache.get(filePath) as NormalizedReadResult;\n }\n\n const packageJson = readJsonSync(filePath);\n\n normalizeData(packageJson as Input);\n\n const output = {\n packageJson: packageJson as NormalizedPackageJson,\n path: filePath,\n };\n\n cache.set(filePath, output);\n\n return output;\n};\n\n/**\n * An asynchronous function to write the package.json file with the given data.\n *\n * @param data - The package.json data to write. The data is an intersection type of `PackageJson` and a record where keys are `string` and values can be any type.\n * @param options - Optional. The options for writing the package.json. If not provided, an empty object will be used `{}`.\n * This is an intersection type of `WriteJsonOptions` and a record with an optional `cwd` key which type is `Options[\"cwd\"]`.\n * `cwd` represents the current working directory. If not specified, the default working directory will be used.\n * @returns A `Promise` that resolves once the package.json file has been written. The type of the returned promise is `Promise<void>`.\n */\n\nexport const writePackageJson = async <T = PackageJson>(data: T, options: WriteJsonOptions & { cwd?: URL | string } = {}): Promise<void> => {\n const { cwd, ...writeOptions } = options;\n const directory = toPath(options.cwd ?? process.cwd());\n\n await writeJson(join(directory, \"package.json\"), data, writeOptions);\n};\n\nexport const writePackageJsonSync = <T = PackageJson>(data: T, options: WriteJsonOptions & { cwd?: URL | string } = {}): void => {\n const { cwd, ...writeOptions } = options;\n const directory = toPath(options.cwd ?? process.cwd());\n\n writeJsonSync(join(directory, \"package.json\"), data, writeOptions);\n};\n\nexport const parsePackageJson = (packageFile: JsonObject | string): NormalizedPackageJson => {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n const isObject = packageFile !== null && typeof packageFile === \"object\" && !Array.isArray(packageFile);\n const isString = typeof packageFile === \"string\";\n\n if (!isObject && !isString) {\n throw new TypeError(\"`packageFile` should be either an `object` or a `string`.\");\n }\n\n const json = isObject\n ? structuredClone(packageFile)\n : // eslint-disable-next-line security/detect-non-literal-fs-filename\n existsSync(packageFile as string)\n ? readJsonSync(packageFile as string)\n : parseJson(packageFile as string);\n\n normalizeData(json as Input);\n\n return json as NormalizedPackageJson;\n};\n"]}
@@ -1,119 +0,0 @@
1
- import { parsePackageJson } from './chunk-UZ2FN6C5.js';
2
- import { execSync } from 'node:child_process';
3
- import { existsSync, readFileSync } from 'node:fs';
4
- import { findUp, findUpSync } from '@visulima/fs';
5
- import { NotFoundError } from '@visulima/fs/error';
6
- import { join, dirname } from 'pathe';
7
-
8
- var lockFileNames = ["yarn.lock", "package-lock.json", "pnpm-lock.yaml", "npm-shrinkwrap.json", "bun.lockb"];
9
- var packageMangerFindUpMatcher = (directory) => {
10
- let lockFile;
11
- lockFileNames.forEach((lockFileName) => {
12
- if (!lockFile && existsSync(join(directory, lockFileName))) {
13
- lockFile = join(directory, lockFileName);
14
- }
15
- });
16
- if (lockFile) {
17
- return lockFile;
18
- }
19
- const packageJsonFilePath = join(directory, "package.json");
20
- if (existsSync(packageJsonFilePath)) {
21
- const packageJson = parsePackageJson(readFileSync(packageJsonFilePath, "utf8"));
22
- if (packageJson.packageManager !== void 0) {
23
- return packageJsonFilePath;
24
- }
25
- }
26
- return void 0;
27
- };
28
- var findPackageManagerOnFile = (foundFile) => {
29
- if (!foundFile) {
30
- throw new NotFoundError("Could not find a package manager");
31
- }
32
- if (foundFile.endsWith("package.json")) {
33
- const packageJson = parsePackageJson(foundFile);
34
- if (packageJson.packageManager) {
35
- const packageManagerNames = ["npm", "yarn", "pnpm", "bun"];
36
- const foundPackageManager = packageManagerNames.find((prefix) => packageJson.packageManager.startsWith(prefix));
37
- if (foundPackageManager) {
38
- return {
39
- packageManager: foundPackageManager,
40
- path: dirname(foundFile)
41
- };
42
- }
43
- }
44
- }
45
- if (foundFile.endsWith("yarn.lock")) {
46
- return {
47
- packageManager: "yarn",
48
- path: dirname(foundFile)
49
- };
50
- }
51
- if (foundFile.endsWith("package-lock.json") || foundFile.endsWith("npm-shrinkwrap.json")) {
52
- return {
53
- packageManager: "npm",
54
- path: dirname(foundFile)
55
- };
56
- }
57
- if (foundFile.endsWith("pnpm-lock.yaml")) {
58
- return {
59
- packageManager: "pnpm",
60
- path: dirname(foundFile)
61
- };
62
- }
63
- if (foundFile.endsWith("bun.lockb")) {
64
- return {
65
- packageManager: "bun",
66
- path: dirname(foundFile)
67
- };
68
- }
69
- throw new NotFoundError("Could not find a package manager");
70
- };
71
- var findLockFile = async (cwd) => {
72
- const filePath = await findUp(lockFileNames, {
73
- type: "file",
74
- ...cwd && { cwd }
75
- });
76
- if (!filePath) {
77
- throw new Error("Could not find lock file");
78
- }
79
- return filePath;
80
- };
81
- var findLockFileSync = (cwd) => {
82
- const filePath = findUpSync(lockFileNames, {
83
- type: "file",
84
- ...cwd && { cwd }
85
- });
86
- if (!filePath) {
87
- throw new Error("Could not find lock file");
88
- }
89
- return filePath;
90
- };
91
- var findPackageManager = async (cwd) => {
92
- const foundFile = await findUp(packageMangerFindUpMatcher, {
93
- ...cwd && { cwd }
94
- });
95
- return findPackageManagerOnFile(foundFile);
96
- };
97
- var findPackageManagerSync = (cwd) => {
98
- const foundFile = findUpSync(packageMangerFindUpMatcher, {
99
- ...cwd && { cwd }
100
- });
101
- return findPackageManagerOnFile(foundFile);
102
- };
103
- var getPackageManagerVersion = (name) => execSync(`${name} --version`).toString("utf8").trim();
104
- var identifyInitiatingPackageManager = async () => {
105
- if (!process.env.npm_config_user_agent) {
106
- return void 0;
107
- }
108
- const pmSpec = process.env.npm_config_user_agent.split(" ")[0];
109
- const separatorPos = pmSpec.lastIndexOf("/");
110
- const name = pmSpec.slice(0, Math.max(0, separatorPos));
111
- return {
112
- name: name === "npminstall" ? "cnpm" : name,
113
- version: pmSpec.slice(Math.max(0, separatorPos + 1))
114
- };
115
- };
116
-
117
- export { findLockFile, findLockFileSync, findPackageManager, findPackageManagerSync, getPackageManagerVersion, identifyInitiatingPackageManager };
118
- //# sourceMappingURL=out.js.map
119
- //# sourceMappingURL=chunk-IIYQBLPC.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/package-manager.ts"],"names":[],"mappings":";;;;;AAAA,SAAS,gBAAgB;AACzB,SAAS,YAAY,oBAAoB;AAEzC,SAAS,QAAQ,kBAAkB;AACnC,SAAS,qBAAqB;AAC9B,SAAS,SAAS,YAAY;AAI9B,IAAM,gBAAgB,CAAC,aAAa,qBAAqB,kBAAkB,uBAAuB,WAAW;AAE7G,IAAM,6BAA6B,CAAC,cAAsB;AACtD,MAAI;AAEJ,gBAAc,QAAQ,CAAC,iBAAiB;AAEpC,QAAI,CAAC,YAAY,WAAW,KAAK,WAAW,YAAY,CAAC,GAAG;AACxD,iBAAW,KAAK,WAAW,YAAY;AAAA,IAC3C;AAAA,EACJ,CAAC;AAED,MAAI,UAAU;AACV,WAAO;AAAA,EACX;AAEA,QAAM,sBAAsB,KAAK,WAAW,cAAc;AAE1D,MAAI,WAAW,mBAAmB,GAAG;AAEjC,UAAM,cAAc,iBAAiB,aAAa,qBAAqB,MAAM,CAAC;AAE9E,QAAI,YAAY,mBAAmB,QAAW;AAC1C,aAAO;AAAA,IACX;AAAA,EACJ;AAEA,SAAO;AACX;AAEA,IAAM,2BAA2B,CAAC,cAAwD;AACtF,MAAI,CAAC,WAAW;AACZ,UAAM,IAAI,cAAc,kCAAkC;AAAA,EAC9D;AAEA,MAAI,UAAU,SAAS,cAAc,GAAG;AACpC,UAAM,cAAc,iBAAiB,SAAS;AAE9C,QAAI,YAAY,gBAAgB;AAC5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0BAA0B;AAAA,EAC9C;AAEA,SAAO;AACX;AAoBO,IAAM,qBAAqB,OAAO,QAAsD;AAC3F,QAAM,YAAY,MAAM,OAAO,4BAA4B;AAAA,IACvD,GAAI,OAAO,EAAE,IAAI;AAAA,EACrB,CAAC;AAED,SAAO,yBAAyB,SAAS;AAC7C;AAcO,IAAM,yBAAyB,CAAC,QAA6C;AAChF,QAAM,YAAY,WAAW,4BAA4B;AAAA,IACrD,GAAI,OAAO,EAAE,IAAI;AAAA,EACrB,CAAC;AAED,SAAO,yBAAyB,SAAS;AAC7C;AAQO,IAAM,2BAA2B,CAAC,SAAyB,SAAS,GAAG,IAAI,YAAY,EAAE,SAAS,MAAM,EAAE,KAAK;AAW/G,IAAM,mCAAmC,YAM3C;AACD,MAAI,CAAC,QAAQ,IAAI,uBAAuB;AACpC,WAAO;AAAA,EACX;AAEA,QAAM,SAAS,QAAQ,IAAI,sBAAsB,MAAM,GAAG,EAAE,CAAC;AAC7D,QAAM,eAAe,OAAO,YAAY,GAAG;AAC3C,QAAM,OAAO,OAAO,MAAM,GAAG,KAAK,IAAI,GAAG,YAAY,CAAC;AAEtD,SAAO;AAAA,IACH,MAAM,SAAS,eAAe,SAAU;AAAA,IACxC,SAAS,OAAO,MAAM,KAAK,IAAI,GAAG,eAAe,CAAC,CAAC;AAAA,EACvD;AACJ","sourcesContent":["import { execSync } from \"node:child_process\";\nimport { existsSync, readFileSync } from \"node:fs\";\n\nimport { findUp, findUpSync } from \"@visulima/fs\";\nimport { NotFoundError } from \"@visulima/fs/error\";\nimport { dirname, join } from \"pathe\";\n\nimport { parsePackageJson } from \"./package-json\";\n\nconst lockFileNames = [\"yarn.lock\", \"package-lock.json\", \"pnpm-lock.yaml\", \"npm-shrinkwrap.json\", \"bun.lockb\"];\n\nconst packageMangerFindUpMatcher = (directory: string) => {\n let lockFile: string | undefined;\n\n lockFileNames.forEach((lockFileName) => {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (!lockFile && existsSync(join(directory, lockFileName))) {\n lockFile = join(directory, lockFileName);\n }\n });\n\n if (lockFile) {\n return lockFile;\n }\n\n const packageJsonFilePath = join(directory, \"package.json\");\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (existsSync(packageJsonFilePath)) {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n const packageJson = parsePackageJson(readFileSync(packageJsonFilePath, \"utf8\"));\n\n if (packageJson.packageManager !== undefined) {\n return packageJsonFilePath;\n }\n }\n\n return undefined;\n};\n\nconst findPackageManagerOnFile = (foundFile: string | undefined): PackageManagerResult => {\n if (!foundFile) {\n throw new NotFoundError(\"Could not find a package manager\");\n }\n\n if (foundFile.endsWith(\"package.json\")) {\n const packageJson = parsePackageJson(foundFile);\n\n if (packageJson.packageManager) {\n const packageManagerNames = [\"npm\", \"yarn\", \"pnpm\", \"bun\"] as const;\n const foundPackageManager = packageManagerNames.find((prefix) => (packageJson.packageManager as string).startsWith(prefix));\n\n if (foundPackageManager) {\n return {\n packageManager: foundPackageManager,\n path: dirname(foundFile),\n };\n }\n }\n }\n\n if (foundFile.endsWith(\"yarn.lock\")) {\n return {\n packageManager: \"yarn\",\n path: dirname(foundFile),\n };\n }\n\n if (foundFile.endsWith(\"package-lock.json\") || foundFile.endsWith(\"npm-shrinkwrap.json\")) {\n return {\n packageManager: \"npm\",\n path: dirname(foundFile),\n };\n }\n\n if (foundFile.endsWith(\"pnpm-lock.yaml\")) {\n return {\n packageManager: \"pnpm\",\n path: dirname(foundFile),\n };\n }\n\n if (foundFile.endsWith(\"bun.lockb\")) {\n return {\n packageManager: \"bun\",\n path: dirname(foundFile),\n };\n }\n\n throw new NotFoundError(\"Could not find a package manager\");\n};\n\n/**\n * An asynchronous function that finds a lock file in the specified directory or any of its parent directories.\n *\n * @param cwd - Optional. The directory path to start the search from. The type of `cwd` is part of an `Options` type,\n * specifically `URL | string`. Defaults to the current working directory.\n * @returns A `Promise` that resolves with the path of the found lock file.\n * The type of the returned promise is `Promise<string>`.\n * @throws An `Error` if no lock file is found.\n */\nexport const findLockFile = async (cwd?: URL | string): Promise<string> => {\n const filePath = await findUp(lockFileNames, {\n type: \"file\",\n ...(cwd && { cwd }),\n });\n\n if (!filePath) {\n throw new Error(\"Could not find lock file\");\n }\n\n return filePath;\n};\n\nexport const findLockFileSync = (cwd?: URL | string): string => {\n const filePath = findUpSync(lockFileNames, {\n type: \"file\",\n ...(cwd && { cwd }),\n });\n\n if (!filePath) {\n throw new Error(\"Could not find lock file\");\n }\n\n return filePath;\n};\n\nexport type PackageManager = \"bun\" | \"npm\" | \"pnpm\" | \"yarn\";\n\nexport type PackageManagerResult = {\n packageManager: PackageManager;\n path: string;\n};\n\n/**\n * An asynchronous function that finds the package manager used in a project based on the presence of lock files\n * or package.json configuration. If found, it returns the package manager and the path to the lock file or package.json.\n * Throws an error if no lock file or package.json is found.\n *\n * @param cwd - Optional. The current working directory to start the search from. The type of `cwd` is part of an `Options`\n * type, specifically `URL | string`.\n * @returns A `Promise` that resolves to an object containing the package manager and path.\n * The return type of the function is `Promise<PackageManagerResult>`.\n * @throws An `Error` if no lock file or package.json is found.\n */\nexport const findPackageManager = async (cwd?: URL | string): Promise<PackageManagerResult> => {\n const foundFile = await findUp(packageMangerFindUpMatcher, {\n ...(cwd && { cwd }),\n });\n\n return findPackageManagerOnFile(foundFile);\n};\n\n/**\n * An function that finds the package manager used in a project based on the presence of lock files\n * or package.json configuration. If found, it returns the package manager and the path to the lock file or package.json.\n * Throws an error if no lock file or package.json is found.\n *\n * @param cwd - Optional. The current working directory to start the search from. The type of `cwd` is part of an `Options`\n * type, specifically `URL | string`.\n * @returns A `Promise` that resolves to an object containing the package manager and path.\n * The return type of the function is `Promise<PackageManagerResult>`.\n * @throws An `Error` if no lock file or package.json is found.\n */\n\nexport const findPackageManagerSync = (cwd?: URL | string): PackageManagerResult => {\n const foundFile = findUpSync(packageMangerFindUpMatcher, {\n ...(cwd && { cwd }),\n });\n\n return findPackageManagerOnFile(foundFile);\n};\n\n/**\n * Function that retrieves the version of the specified package manager.\n *\n * @param name - The name of the package manager. The type of `name` is `string`.\n * @returns The version of the package manager. The return type of the function is `string`.\n */\nexport const getPackageManagerVersion = (name: string): string => execSync(`${name} --version`).toString(\"utf8\").trim();\n\n/**\n * An asynchronous function that detects what package manager executes the process.\n *\n * Supports npm, pnpm, Yarn, cnpm, and bun. And also any other package manager that sets the npm_config_user_agent env variable.\n *\n * @returns A `Promise` that resolves to an object containing the name and version of the package manager,\n * or undefined if the package manager information cannot be determined. The return type of the function\n * is `Promise<{ name: PackageManager | \"cnpm\"; version: string } | undefined>`.\n */\nexport const identifyInitiatingPackageManager = async (): Promise<\n | {\n name: PackageManager | \"cnpm\";\n version: string;\n }\n | undefined\n> => {\n if (!process.env.npm_config_user_agent) {\n return undefined;\n }\n\n const pmSpec = process.env.npm_config_user_agent.split(\" \")[0] as string;\n const separatorPos = pmSpec.lastIndexOf(\"/\");\n const name = pmSpec.slice(0, Math.max(0, separatorPos));\n\n return {\n name: name === \"npminstall\" ? \"cnpm\" : (name as PackageManager),\n version: pmSpec.slice(Math.max(0, separatorPos + 1)),\n };\n};\n"]}