@visulima/package 1.6.0 → 1.6.2

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 (36) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/{chunk-VGU7UU4D.js → chunk-44SW4DFI.js} +1 -1
  3. package/dist/{chunk-VGU7UU4D.js.map → chunk-44SW4DFI.js.map} +1 -1
  4. package/dist/{chunk-AQMSM3GI.cjs → chunk-5YG33J5B.cjs} +3 -3
  5. package/dist/{chunk-OQ2PTROP.js → chunk-CMEGXNWH.js} +1 -1
  6. package/dist/{chunk-OQ2PTROP.js.map → chunk-CMEGXNWH.js.map} +1 -1
  7. package/dist/{chunk-3DGUP62F.cjs → chunk-DNYCFU7L.cjs} +3 -3
  8. package/dist/{chunk-3NJM5HV7.js → chunk-GMIFPTPB.js} +2 -2
  9. package/dist/{chunk-75DR5C7M.js → chunk-I3QTPGJY.js} +2 -2
  10. package/dist/{chunk-VH54OLZU.cjs → chunk-KSXRMTAQ.cjs} +1 -1
  11. package/dist/{chunk-VH54OLZU.cjs.map → chunk-KSXRMTAQ.cjs.map} +1 -1
  12. package/dist/{chunk-4K7XWYTT.cjs → chunk-OVKFHJQE.cjs} +1 -1
  13. package/dist/{chunk-4K7XWYTT.cjs.map → chunk-OVKFHJQE.cjs.map} +1 -1
  14. package/dist/{chunk-6N3YSMA2.cjs → chunk-WOLHGXXJ.cjs} +3 -3
  15. package/dist/{chunk-6WZZWBWV.js → chunk-ZDLZRGSC.js} +2 -2
  16. package/dist/error.cjs +3 -3
  17. package/dist/error.js +2 -2
  18. package/dist/index.cjs +22 -22
  19. package/dist/index.cjs.map +1 -1
  20. package/dist/index.js +6 -6
  21. package/dist/index.js.map +1 -1
  22. package/dist/monorepo.cjs +3 -3
  23. package/dist/monorepo.js +2 -2
  24. package/dist/package-manager.cjs +7 -7
  25. package/dist/package-manager.js +1 -1
  26. package/dist/package.cjs +4 -4
  27. package/dist/package.js +2 -2
  28. package/dist/tsconfig.cjs +7 -7
  29. package/dist/tsconfig.js +1 -1
  30. package/package.json +9 -9
  31. /package/dist/{chunk-AQMSM3GI.cjs.map → chunk-5YG33J5B.cjs.map} +0 -0
  32. /package/dist/{chunk-3DGUP62F.cjs.map → chunk-DNYCFU7L.cjs.map} +0 -0
  33. /package/dist/{chunk-3NJM5HV7.js.map → chunk-GMIFPTPB.js.map} +0 -0
  34. /package/dist/{chunk-75DR5C7M.js.map → chunk-I3QTPGJY.js.map} +0 -0
  35. /package/dist/{chunk-6N3YSMA2.cjs.map → chunk-WOLHGXXJ.cjs.map} +0 -0
  36. /package/dist/{chunk-6WZZWBWV.js.map → chunk-ZDLZRGSC.js.map} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,3 +1,24 @@
1
+ ## @visulima/package [1.6.2](https://github.com/visulima/visulima/compare/@visulima/package@1.6.1...@visulima/package@1.6.2) (2024-04-05)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * updated type-fest and dev deps ([d7f648d](https://github.com/visulima/visulima/commit/d7f648debdb10eeeb4b8942c45b2e6f6ead560e2))
7
+
8
+
9
+
10
+ ### Dependencies
11
+
12
+ * **@visulima/fs:** upgraded to 2.0.5
13
+
14
+ ## @visulima/package [1.6.1](https://github.com/visulima/visulima/compare/@visulima/package@1.6.0...@visulima/package@1.6.1) (2024-04-02)
15
+
16
+
17
+
18
+ ### Dependencies
19
+
20
+ * **@visulima/fs:** upgraded to 2.0.4
21
+
1
22
  ## @visulima/package [1.6.0](https://github.com/visulima/visulima/compare/@visulima/package@1.5.3...@visulima/package@1.6.0) (2024-04-02)
2
23
 
3
24
 
@@ -9,4 +9,4 @@ var o=["yarn.lock","package-lock.json","pnpm-lock.yaml","npm-shrinkwrap.json","b
9
9
 
10
10
  export { b as a, j as b, U as c, W as d, L as e, _ as f };
11
11
  //# sourceMappingURL=out.js.map
12
- //# sourceMappingURL=chunk-VGU7UU4D.js.map
12
+ //# sourceMappingURL=chunk-44SW4DFI.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/package-manager.ts"],"names":["execSync","existsSync","readFileSync","findUp","findUpSync","NotFoundError","dirname","join","lockFileNames","packageMangerFindUpMatcher","directory","lockFile","lockFileName","packageJsonFilePath","parsePackageJson","findPackageManagerOnFile","foundFile","packageJson","foundPackageManager","prefix","findLockFile","cwd","filePath","findLockFileSync","findPackageManager","findPackageManagerSync","getPackageManagerVersion","name","identifyInitiatingPackageManager","pmSpec","separatorPos"],"mappings":"wCAAA,OAAS,YAAAA,MAAgB,qBACzB,OAAS,cAAAC,EAAY,gBAAAC,MAAoB,UAEzC,OAAS,UAAAC,EAAQ,cAAAC,MAAkB,eACnC,OAAS,iBAAAC,MAAqB,qBAC9B,OAAS,WAAAC,EAAS,QAAAC,MAAY,QAI9B,IAAMC,EAAgB,CAAC,YAAa,oBAAqB,iBAAkB,sBAAuB,WAAW,EAEvGC,EAA8BC,GAAsB,CACtD,IAAIC,EASJ,GAPAH,EAAc,QAASI,GAAiB,CAEhC,CAACD,GAAYV,EAAWM,EAAKG,EAAWE,CAAY,CAAC,IACrDD,EAAWJ,EAAKG,EAAWE,CAAY,EAE/C,CAAC,EAEGD,EACA,OAAOA,EAGX,IAAME,EAAsBN,EAAKG,EAAW,cAAc,EAE1D,GAAIT,EAAWY,CAAmB,GAEVC,EAAiBZ,EAAaW,EAAqB,MAAM,CAAC,EAE9D,iBAAmB,OAC/B,OAAOA,CAKnB,EAEME,EAA4BC,GAAwD,CACtF,GAAI,CAACA,EACD,MAAM,IAAIX,EAAc,kCAAkC,EAG9D,GAAIW,EAAU,SAAS,cAAc,EAAG,CACpC,IAAMC,EAAcH,EAAiBE,CAAS,EAE9C,GAAIC,EAAY,eAAgB,CAE5B,IAAMC,EADsB,CAAC,MAAO,OAAQ,OAAQ,KAAK,EACT,KAAMC,GAAYF,EAAY,eAA0B,WAAWE,CAAM,CAAC,EAE1H,GAAID,EACA,MAAO,CACH,eAAgBA,EAChB,KAAMZ,EAAQU,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AAmC,SAM3C,CACD,GAAI,CAAC,QAAQ,IAAI,sBACb,OAGJ,IAAMC,EAAS,QAAQ,IAAI,sBAAyB,MAAM,GAAG,EAAE,CAAC,EAC1DC,EAAeD,EAAO,YAAY,GAAG,EACrCF,EAAOE,EAAO,MAAM,EAAG,KAAK,IAAI,EAAGC,CAAY,CAAC,EAEtD,MAAO,CACH,KAAMH,IAAS,aAAe,OAAUA,EACxC,QAASE,EAAO,MAAM,KAAK,IAAI,EAAGC,EAAe,CAAC,CAAC,CACvD,CACJ","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"]}
1
+ {"version":3,"sources":["../src/package-manager.ts"],"names":["execSync","existsSync","readFileSync","findUp","findUpSync","NotFoundError","dirname","join","lockFileNames","packageMangerFindUpMatcher","directory","lockFile","lockFileName","packageJsonFilePath","parsePackageJson","findPackageManagerOnFile","foundFile","packageJson","foundPackageManager","prefix","findLockFile","cwd","filePath","findLockFileSync","findPackageManager","findPackageManagerSync","getPackageManagerVersion","name","identifyInitiatingPackageManager","pmSpec","separatorPos"],"mappings":"wCAAA,OAAS,YAAAA,MAAgB,qBACzB,OAAS,cAAAC,EAAY,gBAAAC,MAAoB,UAEzC,OAAS,UAAAC,EAAQ,cAAAC,MAAkB,eACnC,OAAS,iBAAAC,MAAqB,qBAC9B,OAAS,WAAAC,EAAS,QAAAC,MAAY,QAI9B,IAAMC,EAAgB,CAAC,YAAa,oBAAqB,iBAAkB,sBAAuB,WAAW,EAEvGC,EAA8BC,GAAsB,CACtD,IAAIC,EASJ,GAPAH,EAAc,QAASI,GAAiB,CAEhC,CAACD,GAAYV,EAAWM,EAAKG,EAAWE,CAAY,CAAC,IACrDD,EAAWJ,EAAKG,EAAWE,CAAY,EAE/C,CAAC,EAEGD,EACA,OAAOA,EAGX,IAAME,EAAsBN,EAAKG,EAAW,cAAc,EAE1D,GAAIT,EAAWY,CAAmB,GAEVC,EAAiBZ,EAAaW,EAAqB,MAAM,CAAC,EAE9D,iBAAmB,OAC/B,OAAOA,CAKnB,EAEME,EAA4BC,GAAwD,CACtF,GAAI,CAACA,EACD,MAAM,IAAIX,EAAc,kCAAkC,EAG9D,GAAIW,EAAU,SAAS,cAAc,EAAG,CACpC,IAAMC,EAAcH,EAAiBE,CAA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YZ,EAAWK,EAA4B,CACrD,GAAIY,GAAO,CAAE,IAAAA,CAAI,CACrB,CAAC,EAED,OAAON,EAAyBC,CAAS,CAC7C,EAQaU,EAA4BC,GAAyB3B,EAAS,GAAG2B,CAAI,YAAY,EAAE,SAAS,MAAM,EAAE,KAAK,EAWzGC,EAAmC,SAM3C,CACD,GAAI,CAAC,QAAQ,IAAI,sBACb,OAGJ,IAAMC,EAAS,QAAQ,IAAI,sBAAsB,MAAM,GAAG,EAAE,CAAC,EACvDC,EAAeD,EAAO,YAAY,GAAG,EACrCF,EAAOE,EAAO,MAAM,EAAG,KAAK,IAAI,EAAGC,CAAY,CAAC,EAEtD,MAAO,CACH,KAAMH,IAAS,aAAe,OAAUA,EACxC,QAASE,EAAO,MAAM,KAAK,IAAI,EAAGC,EAAe,CAAC,CAAC,CACvD,CACJ","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"]}
@@ -1,13 +1,13 @@
1
1
  'use strict';
2
2
 
3
- var chunkVH54OLZU_cjs = require('./chunk-VH54OLZU.cjs');
3
+ var chunkKSXRMTAQ_cjs = require('./chunk-KSXRMTAQ.cjs');
4
4
  var fs$1 = require('fs');
5
5
  var fs = require('@visulima/fs');
6
6
  var pathe = require('pathe');
7
7
 
8
- var g=t=>{if(fs$1.existsSync(pathe.join(t,"package.json"))){let n=fs.readJsonSync(pathe.join(t,"package.json"));if(n.name&&n.private!==!0)return "package.json"}},h=async t=>{try{let i=await chunkVH54OLZU_cjs.a(t);return pathe.dirname(i)}catch{}let n=await fs.findUp(".git/config",{...t&&{cwd:t},type:"file"});if(n)return pathe.dirname(pathe.dirname(n));let r=await fs.findUp(g,{...t&&{cwd:t},type:"file"});if(r)return pathe.dirname(r);throw new Error("Could not find root directory")},P=t=>{try{let i=chunkVH54OLZU_cjs.b(t);return pathe.dirname(i)}catch{}let n=fs.findUpSync(".git/config",{...t&&{cwd:t},type:"file"});if(n)return pathe.dirname(pathe.dirname(n));let r=fs.findUpSync(g,{...t&&{cwd:t},type:"file"});if(r)return pathe.dirname(r);throw new Error("Could not find root directory")};
8
+ var g=t=>{if(fs$1.existsSync(pathe.join(t,"package.json"))){let n=fs.readJsonSync(pathe.join(t,"package.json"));if(n.name&&n.private!==!0)return "package.json"}},h=async t=>{try{let i=await chunkKSXRMTAQ_cjs.a(t);return pathe.dirname(i)}catch{}let n=await fs.findUp(".git/config",{...t&&{cwd:t},type:"file"});if(n)return pathe.dirname(pathe.dirname(n));let r=await fs.findUp(g,{...t&&{cwd:t},type:"file"});if(r)return pathe.dirname(r);throw new Error("Could not find root directory")},P=t=>{try{let i=chunkKSXRMTAQ_cjs.b(t);return pathe.dirname(i)}catch{}let n=fs.findUpSync(".git/config",{...t&&{cwd:t},type:"file"});if(n)return pathe.dirname(pathe.dirname(n));let r=fs.findUpSync(g,{...t&&{cwd:t},type:"file"});if(r)return pathe.dirname(r);throw new Error("Could not find root directory")};
9
9
 
10
10
  exports.a = h;
11
11
  exports.b = P;
12
12
  //# sourceMappingURL=out.js.map
13
- //# sourceMappingURL=chunk-AQMSM3GI.cjs.map
13
+ //# sourceMappingURL=chunk-5YG33J5B.cjs.map
@@ -12,4 +12,4 @@ var _=s=>parse(readFileSync(s)),L=()=>{let{findPnpApi:s}=A;return s?.(process.cw
12
12
 
13
13
  export { J as a, ie as b, be as c, re as d, ke as e, ce as f, Ie as g };
14
14
  //# sourceMappingURL=out.js.map
15
- //# sourceMappingURL=chunk-OQ2PTROP.js.map
15
+ //# sourceMappingURL=chunk-CMEGXNWH.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/tsconfig.ts","../src/read-tsconfig.ts","../src/utils/resolve-extends-path.ts"],"names":["findUp","findUpSync","writeJson","NotFoundError","toPath","join","realpathSync","readFileSync","parse","dirname","normalize","relative","resolve","toNamespacedPath","existsSync","statSync","Module","isAbsolute","resolveExports","readJsonc","jsonPath","getPnpApi","findPnpApi","resolveFromPackageJsonPath","packageJsonPath","subpath","ignoreExports","cache","cacheKey","packageJson","resolvedPath","resolvedExport","PACKAGE_JSON","TS_CONFIG_JSON","resolveExtendsPath","requestedPath","directoryPath","filePath","orgOrName","remaining","packageName","pnpApi","resolveWithPnp","resolved","packagePath","directory","path","fullPackagePath","jsonExtension","fullPackagePathWithJson","fullPackageJsonPath","tsconfigPath","resolve_extends_path_default","implicitBaseUrlSymbol","normalizePath","resolveExtends","extendsPath","fromDirectoryPath","circularExtendsTracker","options","resolvedExtendsPath","extendsDirectoryPath","extendsConfig","internalParseTsConfig","compilerOptions","resolvePaths","property","unresolvedPath","file","realTsconfigPath","config","extendsPathList","merged","normalizedPaths","resolvedBaseUrl","relativeBaseUrl","outDir","element","watchOptions","excludePath","readTsConfig","read_tsconfig_default","TsConfigFileCache","findTsConfig","cwd","configFileName","output","findTSConfig","findTsConfigSync","findTSConfigSync","writeTsConfig","data","writeOptions","writeTSConfig"],"mappings":"AACA,OAAS,UAAAA,EAAQ,cAAAC,EAAY,aAAAC,OAAiB,eAC9C,OAAS,iBAAAC,MAAqB,qBAC9B,OAAS,UAAAC,OAAc,qBACvB,OAAS,QAAAC,OAAY,QCErB,OAAS,gBAAAC,MAAoB,UAE7B,OAAS,gBAAAC,MAAoB,eAC7B,OAAS,iBAAAJ,MAAqB,qBAC9B,OAAS,SAAAK,MAAa,eACtB,OAAS,WAAAC,EAAS,QAAAJ,EAAM,aAAAK,EAAW,YAAAC,EAAU,WAAAC,EAAS,oBAAAC,MAAwB,QCL9E,OAAS,cAAAC,EAAY,YAAAC,MAAgB,UACrC,OAAOC,MAAY,cACnB,OAAS,cAAAC,EAAY,QAAAZ,EAAM,WAAAO,MAAe,YAE1C,OAAS,cAAAX,EAAY,gBAAAM,MAAoB,eACzC,OAAS,SAAAC,MAAa,eAEtB,OAAS,kBAAAU,MAAsB,mBAK/B,IAAMC,EAAaC,GAAqBZ,EAAMD,EAAaa,CAAQ,CAAW,EAExEC,EAAY,IAAM,CACpB,GAAM,CAAE,WAAAC,CAAW,EAAIN,EAGvB,OAAOM,IAAa,QAAQ,IAAI,CAAC,CACrC,EAEMC,EAA6B,CAACC,EAAyBC,EAAiBC,EAAyBC,IAA0B,CAC7H,IAAMC,EAAW,8BAA8BJ,CAAe,IAAIC,CAAO,IAAIC,CAAa,GAE1F,GAAIC,GAAO,IAAI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X,OAAQL,EAAa5C,CAAQ,EAC7B,KAAMA,CACV,EAEA,OAAIsB,EAAQ,OACRhC,EAAM,IAAIU,EAAUiD,CAAM,EAGvBA,CACX,EAGaC,GAAeJ,GAEfK,GAAmB,CAACJ,EAAoBzB,EAAmB,CAAC,IAAsB,CAC3F,IAAM0B,EAAiB1B,EAAQ,gBAAkB,gBAE7CtB,EAAWpC,EAAWoF,EAAgB,CACtC,GAAID,GAAO,CAAE,IAAAA,CAAI,EACjB,KAAM,MACV,CAAC,EASD,GAPK/C,IACDA,EAAWpC,EAAW,gBAAiB,CACnC,GAAImF,GAAO,CAAE,IAAAA,CAAI,EACjB,KAAM,MACV,CAAC,GAGD,CAAC/C,EACD,MAAM,IAAIlC,EAAc,kCAAkCkF,CAAc,0BAA0B,EAGtG,IAAM1D,EAAQgC,EAAQ,OAAS,OAAOA,EAAQ,OAAU,UAAYA,EAAQ,MAAQuB,EAEpF,GAAIvB,EAAQ,OAAShC,EAAM,IAAIU,CAAQ,EACnC,OAAOV,EAAM,IAAIU,CAAQ,EAG7B,IAAMiD,EAAS,CACX,OAAQL,EAAa5C,CAAQ,EAC7B,KAAMA,CACV,EAEA,OAAIsB,EAAQ,OACRhC,EAAM,IAAIU,EAAUiD,CAAM,EAGvBA,CACX,EAGaG,GAAmBD,GAWnBE,GAAgB,MAAOC,EAAoBhC,EAAqD,CAAC,IAAqB,CAC/H,GAAM,CAAE,IAAAyB,EAAK,GAAGQ,CAAa,EAAIjC,EAE3Bd,EAAYzC,GAAOuD,EAAQ,KAAO,QAAQ,IAAI,CAAC,EAErD,MAAMzD,GAAUG,GAAKwC,EAAW,eAAe,EAAG8C,EAAMC,CAAY,CACxE,EAGaC,GAAgBH","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","/**\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 { realpathSync } from \"node:fs\";\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 implicitBaseUrlSymbol = Symbol(\"implicitBaseUrl\");\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 let realTsconfigPath: string;\n\n try {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n realTsconfigPath = realpathSync(tsconfigPath) as string;\n } catch {\n throw new Error(`Cannot resolve tsconfig at path: ${tsconfigPath}`);\n }\n\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 = readJsonc(realTsconfigPath) || {};\n\n if (typeof config !== \"object\") {\n throw new SyntaxError(`Failed to parse tsconfig at: ${tsconfigPath}`);\n }\n\n const directoryPath = dirname(realTsconfigPath);\n\n if (config.compilerOptions) {\n const { compilerOptions } = config;\n if (compilerOptions.paths && !compilerOptions.baseUrl) {\n type WithImplicitBaseUrl = TsConfigJson.CompilerOptions & {\n [implicitBaseUrlSymbol]: string;\n };\n // eslint-disable-next-line security/detect-object-injection\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\nconst readTsConfig = (tsconfigPath: string, options?: Options): TsConfigJsonResolved => internalParseTsConfig(tsconfigPath, options);\n\nexport default readTsConfig;\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
+ {"version":3,"sources":["../src/tsconfig.ts","../src/read-tsconfig.ts","../src/utils/resolve-extends-path.ts"],"names":["findUp","findUpSync","writeJson","NotFoundError","toPath","join","realpathSync","readFileSync","parse","dirname","normalize","relative","resolve","toNamespacedPath","existsSync","statSync","Module","isAbsolute","resolveExports","readJsonc","jsonPath","getPnpApi","findPnpApi","resolveFromPackageJsonPath","packageJsonPath","subpath","ignoreExports","cache","cacheKey","packageJson","resolvedPath","resolvedExport","PACKAGE_JSON","TS_CONFIG_JSON","resolveExtendsPath","requestedPath","directoryPath","filePath","orgOrName","remaining","packageName","pnpApi","resolveWithPnp","resolved","packagePath","directory","path","fullPackagePath","jsonExtension","fullPackagePathWithJson","fullPackageJsonPath","tsconfigPath","resolve_extends_path_default","implicitBaseUrlSymbol","normalizePath","resolveExtends","extendsPath","fromDirectoryPath","circularExtendsTracker","options","resolvedExtendsPath","extendsDirectoryPath","extendsConfig","internalParseTsConfig","compilerOptions","resolvePaths","property","unresolvedPath","file","realTsconfigPath","config","extendsPathList","merged","normalizedPaths","resolvedBaseUrl","relativeBaseUrl","outDir","element","watchOptions","excludePath","readTsConfig","read_tsconfig_default","TsConfigFileCache","findTsConfig","cwd","configFileName","output","findTSConfig","findTsConfigSync","findTSConfigSync","writeTsConfig","data","writeOptions","writeTSConfig"],"mappings":"AACA,OAAS,UAAAA,EAAQ,cAAAC,EAAY,aAAAC,OAAiB,eAC9C,OAAS,iBAAAC,MAAqB,qBAC9B,OAAS,UAAAC,OAAc,qBACvB,OAAS,QAAAC,OAAY,QCErB,OAAS,gBAAAC,MAAoB,UAE7B,OAAS,gBAAAC,MAAoB,eAC7B,OAAS,iBAAAJ,MAAqB,qBAC9B,OAAS,SAAAK,MAAa,eACtB,OAAS,WAAAC,EAAS,QAAAJ,EAAM,aAAAK,EAAW,YAAAC,EAAU,WAAAC,EAAS,oBAAAC,MAAwB,QCL9E,OAAS,cAAAC,EAAY,YAAAC,MAAgB,UACrC,OAAOC,MAAY,cACnB,OAAS,cAAAC,EAAY,QAAAZ,EAAM,WAAAO,MAAe,YAE1C,OAAS,cAAAX,EAAY,gBAAAM,MAAoB,eACzC,OAAS,SAAAC,MAAa,eAEtB,OAAS,kBAAAU,MAAsB,mBAK/B,IAAMC,EAAaC,GAAqBZ,EAAMD,EAAaa,CAAQ,CAAW,EAExEC,EAAY,IAAM,CACpB,GAAM,CAAE,WAAAC,CAAW,EAAIN,EAGvB,OAAOM,IAAa,QAAQ,IAAI,CAAC,CACrC,EAEMC,EAA6B,CAACC,EAAyBC,EAAiBC,EAAyBC,IAA0B,CAC7H,IAAMC,EAAW,8BAA8BJ,CAAe,IAAIC,CAAO,IAAIC,CAAa,GAE1F,GAAIC,GAAO,IAAIC,CAAQ,EACnB,OAAOD,EAAM,IAAIC,CAAQ,EAG7B,IAAMC,EAAcV,EAAUK,CAAe,EAE7C,GAAI,CAACK,EACD,OAGJ,IAAIC,EAAeL,GAAW,gBAE9B,GAAI,CAACC,GAAkBG,EAA4B,QAC/C,GAAI,CACA,GAAM,CAACE,CAAc,EAAIb,EAAgBW,EA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B,gBAE7CtB,EAAWpC,EAAWoF,EAAgB,CACtC,GAAID,GAAO,CAAE,IAAAA,CAAI,EACjB,KAAM,MACV,CAAC,EASD,GAPK/C,IACDA,EAAWpC,EAAW,gBAAiB,CACnC,GAAImF,GAAO,CAAE,IAAAA,CAAI,EACjB,KAAM,MACV,CAAC,GAGD,CAAC/C,EACD,MAAM,IAAIlC,EAAc,kCAAkCkF,CAAc,0BAA0B,EAGtG,IAAM1D,EAAQgC,EAAQ,OAAS,OAAOA,EAAQ,OAAU,UAAYA,EAAQ,MAAQuB,EAEpF,GAAIvB,EAAQ,OAAShC,EAAM,IAAIU,CAAQ,EACnC,OAAOV,EAAM,IAAIU,CAAQ,EAG7B,IAAMiD,EAAS,CACX,OAAQL,EAAa5C,CAAQ,EAC7B,KAAMA,CACV,EAEA,OAAIsB,EAAQ,OACRhC,EAAM,IAAIU,EAAUiD,CAAM,EAGvBA,CACX,EAGaG,GAAmBD,GAWnBE,GAAgB,MAAOC,EAAoBhC,EAAqD,CAAC,IAAqB,CAC/H,GAAM,CAAE,IAAAyB,EAAK,GAAGQ,CAAa,EAAIjC,EAE3Bd,EAAYzC,GAAOuD,EAAQ,KAAO,QAAQ,IAAI,CAAC,EAErD,MAAMzD,GAAUG,GAAKwC,EAAW,eAAe,EAAG8C,EAAMC,CAAY,CACxE,EAGaC,GAAgBH","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","/**\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 { realpathSync } from \"node:fs\";\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 implicitBaseUrlSymbol = Symbol(\"implicitBaseUrl\");\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 let realTsconfigPath: string;\n\n try {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n realTsconfigPath = realpathSync(tsconfigPath) as string;\n } catch {\n throw new Error(`Cannot resolve tsconfig at path: ${tsconfigPath}`);\n }\n\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 = readJsonc(realTsconfigPath) || {};\n\n if (typeof config !== \"object\") {\n throw new SyntaxError(`Failed to parse tsconfig at: ${tsconfigPath}`);\n }\n\n const directoryPath = dirname(realTsconfigPath);\n\n if (config.compilerOptions) {\n const { compilerOptions } = config;\n if (compilerOptions.paths && !compilerOptions.baseUrl) {\n type WithImplicitBaseUrl = TsConfigJson.CompilerOptions & {\n [implicitBaseUrlSymbol]: string;\n };\n // eslint-disable-next-line security/detect-object-injection\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\nconst readTsConfig = (tsconfigPath: string, options?: Options): TsConfigJsonResolved => internalParseTsConfig(tsconfigPath, options);\n\nexport default readTsConfig;\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,9 +1,9 @@
1
1
  'use strict';
2
2
 
3
- var chunkVH54OLZU_cjs = require('./chunk-VH54OLZU.cjs');
3
+ var chunkKSXRMTAQ_cjs = require('./chunk-KSXRMTAQ.cjs');
4
4
 
5
- var t=class extends Error{constructor(n,r){if(typeof n=="string"&&(n=[n]),n.length===0){super("Package was not found.");return}if(r===void 0)try{r=chunkVH54OLZU_cjs.d().packageManager;}catch{}r===void 0&&(r="npm"),super(`Package '${n.join(" ")}' was not found. Please install it using '${r} install ${n.join(" ")}'`);}get code(){return "PACKAGE_NOT_FOUND"}set code(n){throw new Error("Cannot overwrite code PACKAGE_NOT_FOUND")}get name(){return "PackageNotFoundError"}set name(n){throw new Error("Cannot overwrite name of PackageNotFoundError")}},d=t;
5
+ var t=class extends Error{constructor(n,r){if(typeof n=="string"&&(n=[n]),n.length===0){super("Package was not found.");return}if(r===void 0)try{r=chunkKSXRMTAQ_cjs.d().packageManager;}catch{}r===void 0&&(r="npm"),super(`Package '${n.join(" ")}' was not found. Please install it using '${r} install ${n.join(" ")}'`);}get code(){return "PACKAGE_NOT_FOUND"}set code(n){throw new Error("Cannot overwrite code PACKAGE_NOT_FOUND")}get name(){return "PackageNotFoundError"}set name(n){throw new Error("Cannot overwrite name of PackageNotFoundError")}},d=t;
6
6
 
7
7
  exports.a = d;
8
8
  //# sourceMappingURL=out.js.map
9
- //# sourceMappingURL=chunk-3DGUP62F.cjs.map
9
+ //# sourceMappingURL=chunk-DNYCFU7L.cjs.map
@@ -1,4 +1,4 @@
1
- import { c } from './chunk-VGU7UU4D.js';
1
+ import { c } from './chunk-44SW4DFI.js';
2
2
  import { existsSync, readFileSync } from 'node:fs';
3
3
  import { findUp, readJson } from '@visulima/fs';
4
4
  import { NotFoundError } from '@visulima/fs/error';
@@ -8,4 +8,4 @@ var x=async n=>{let a=await findUp(["lerna.json","turbo.json"],{type:"file",...n
8
8
 
9
9
  export { x as a };
10
10
  //# sourceMappingURL=out.js.map
11
- //# sourceMappingURL=chunk-3NJM5HV7.js.map
11
+ //# sourceMappingURL=chunk-GMIFPTPB.js.map
@@ -1,4 +1,4 @@
1
- import { a, b } from './chunk-VGU7UU4D.js';
1
+ import { a, b } from './chunk-44SW4DFI.js';
2
2
  import { existsSync } from 'node:fs';
3
3
  import { findUp, findUpSync, readJsonSync } from '@visulima/fs';
4
4
  import { dirname, join } from 'pathe';
@@ -7,4 +7,4 @@ var g=t=>{if(existsSync(join(t,"package.json"))){let n=readJsonSync(join(t,"pack
7
7
 
8
8
  export { P as a, J as b };
9
9
  //# sourceMappingURL=out.js.map
10
- //# sourceMappingURL=chunk-75DR5C7M.js.map
10
+ //# sourceMappingURL=chunk-I3QTPGJY.js.map
@@ -16,4 +16,4 @@ exports.d = U;
16
16
  exports.e = W;
17
17
  exports.f = L;
18
18
  //# sourceMappingURL=out.js.map
19
- //# sourceMappingURL=chunk-VH54OLZU.cjs.map
19
+ //# sourceMappingURL=chunk-KSXRMTAQ.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/package-manager.ts"],"names":["execSync","existsSync","readFileSync","findUp","findUpSync","NotFoundError","dirname","join","lockFileNames","packageMangerFindUpMatcher","directory","lockFile","lockFileName","packageJsonFilePath","parsePackageJson","findPackageManagerOnFile","foundFile","packageJson","foundPackageManager","prefix","findLockFile","cwd","filePath","findLockFileSync","findPackageManager","findPackageManagerSync","getPackageManagerVersion","name","identifyInitiatingPackageManager","pmSpec","separatorPos"],"mappings":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CAAC,CAAC,CACvD,CACJ","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"]}
1
+ {"version":3,"sources":["../src/package-manager.ts"],"names":["execSync","existsSync","readFileSync","findUp","findUpSync","NotFoundError","dirname","join","lockFileNames","packageMangerFindUpMatcher","directory","lockFile","lockFileName","packageJsonFilePath","parsePackageJson","findPackageManagerOnFile","foundFile","packageJson","foundPackageManager","prefix","findLockFile","cwd","filePath","findLockFileSync","findPackageManager","findPackageManagerSync","getPackageManagerVersion","name","identifyInitiatingPackageManager","pmSpec","separatorPos"],"mappings":"yCAAA,OAAS,YAAAA,MAAgB,gBACzB,OAAS,cAAAC,EAAY,gBAAAC,MAAoB,KAEzC,OAAS,UAAAC,EAAQ,cAAAC,MAAkB,eACnC,OAAS,iBAAAC,MAAqB,qBAC9B,OAAS,WAAAC,EAAS,QAAAC,MAAY,QAI9B,IAAMC,EAAgB,CAAC,YAAa,oBAAqB,iBAAkB,sBAAuB,WAAW,EAEvGC,EAA8BC,GAAsB,CACtD,IAAIC,EASJ,GAPAH,EAAc,QAASI,GAAiB,CAEhC,CAACD,GAAYV,EAAWM,EAAKG,EAAWE,CAAY,CAAC,IACrDD,EAAWJ,EAAKG,EAAWE,CAAY,EAE/C,CAAC,EAEGD,EACA,OAAOA,EAGX,IAAME,EAAsBN,EAAKG,EAAW,cAAc,EAE1D,GAAIT,EAAWY,CAAmB,GAEVC,EAAiBZ,EAAaW,EAAqB,MAAM,CAAC,EAE9D,iBAAmB,OAC/B,OAAOA,CAKnB,EAEME,EAA4BC,GAAwD,CACtF,GAAI,CAACA,EACD,MAAM,IAAIX,EAAc,kCAAkC,EAG9D,GAAIW,EAAU,SAAS,cAAc,EAAG,CACpC,IAAMC,EAAcH,EAAiBE,CAAS,EAE9C,GAAIC,EAAY,eAAgB,CAE5B,IAAMC,EADsB,CAAC,MAAO,OAAQ,OAAQ,KAAK,EACT,KAAMC,GAAYF,EAAY,eAA0B,WAAWE,CAAM,CAAC,EAE1H,GAAID,EACA,MAAO,CACH,eAAgBA,EAChB,KAAMZ,EAAQU,CAAS,CAC3B,CAER,CACJ,CAEA,GAAIA,EAAU,SAAS,WAAW,EAC9B,MAAO,CACH,eAAgB,OAChB,KAAMV,EAAQU,CAAS,CAC3B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C,EACvDC,EAAeD,EAAO,YAAY,GAAG,EACrCF,EAAOE,EAAO,MAAM,EAAG,KAAK,IAAI,EAAGC,CAAY,CAAC,EAEtD,MAAO,CACH,KAAMH,IAAS,aAAe,OAAUA,EACxC,QAASE,EAAO,MAAM,KAAK,IAAI,EAAGC,EAAe,CAAC,CAAC,CACvD,CACJ","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"]}
@@ -24,4 +24,4 @@ exports.e = be;
24
24
  exports.f = re;
25
25
  exports.g = ke;
26
26
  //# sourceMappingURL=out.js.map
27
- //# sourceMappingURL=chunk-4K7XWYTT.cjs.map
27
+ //# sourceMappingURL=chunk-OVKFHJQE.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/tsconfig.ts","../src/read-tsconfig.ts","../src/utils/resolve-extends-path.ts"],"names":["findUp","findUpSync","writeJson","NotFoundError","toPath","join","realpathSync","readFileSync","parse","dirname","normalize","relative","resolve","toNamespacedPath","existsSync","statSync","Module","isAbsolute","resolveExports","readJsonc","jsonPath","getPnpApi","findPnpApi","resolveFromPackageJsonPath","packageJsonPath","subpath","ignoreExports","cache","cacheKey","packageJson","resolvedPath","resolvedExport","PACKAGE_JSON","TS_CONFIG_JSON","resolveExtendsPath","requestedPath","directoryPath","filePath","orgOrName","remaining","packageName","pnpApi","resolveWithPnp","resolved","packagePath","directory","path","fullPackagePath","jsonExtension","fullPackagePathWithJson","fullPackageJsonPath","tsconfigPath","resolve_extends_path_default","implicitBaseUrlSymbol","normalizePath","resolveExtends","extendsPath","fromDirectoryPath","circularExtendsTracker","options","resolvedExtendsPath","extendsDirectoryPath","extendsConfig","internalParseTsConfig","compilerOptions","resolvePaths","property","unresolvedPath","file","realTsconfigPath","config","extendsPathList","merged","normalizedPaths","resolvedBaseUrl","relativeBaseUrl","outDir","element","watchOptions","excludePath","readTsConfig","read_tsconfig_default","TsConfigFileCache","findTsConfig","cwd","configFileName","output","findTSConfig","findTsConfigSync","findTSConfigSync","writeTsConfig","data","writeOptions","writeTSConfig"],"mappings":"AACA,OAAS,UAAAA,EAAQ,cAAAC,EAAY,aAAAC,OAAiB,eAC9C,OAAS,iBAAAC,MAAqB,qBAC9B,OAAS,UAAAC,OAAc,qBACvB,OAAS,QAAAC,OAAY,QCErB,OA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,OAAS,OAAOA,EAAQ,OAAU,UAAYA,EAAQ,MAAQuB,EAEpF,GAAIvB,EAAQ,OAAShC,EAAM,IAAIU,CAAQ,EACnC,OAAOV,EAAM,IAAIU,CAAQ,EAG7B,IAAMiD,EAAS,CACX,OAAQL,EAAa5C,CAAQ,EAC7B,KAAMA,CACV,EAEA,OAAIsB,EAAQ,OACRhC,EAAM,IAAIU,EAAUiD,CAAM,EAGvBA,CACX,EAGaG,GAAmBD,GAWnBE,GAAgB,MAAOC,EAAoBhC,EAAqD,CAAC,IAAqB,CAC/H,GAAM,CAAE,IAAAyB,EAAK,GAAGQ,CAAa,EAAIjC,EAE3Bd,EAAYzC,GAAOuD,EAAQ,KAAO,QAAQ,IAAI,CAAC,EAErD,MAAMzD,GAAUG,GAAKwC,EAAW,eAAe,EAAG8C,EAAMC,CAAY,CACxE,EAGaC,GAAgBH","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","/**\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 { realpathSync } from \"node:fs\";\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 implicitBaseUrlSymbol = Symbol(\"implicitBaseUrl\");\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 let realTsconfigPath: string;\n\n try {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n realTsconfigPath = realpathSync(tsconfigPath) as string;\n } catch {\n throw new Error(`Cannot resolve tsconfig at path: ${tsconfigPath}`);\n }\n\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 = readJsonc(realTsconfigPath) || {};\n\n if (typeof config !== \"object\") {\n throw new SyntaxError(`Failed to parse tsconfig at: ${tsconfigPath}`);\n }\n\n const directoryPath = dirname(realTsconfigPath);\n\n if (config.compilerOptions) {\n const { compilerOptions } = config;\n if (compilerOptions.paths && !compilerOptions.baseUrl) {\n type WithImplicitBaseUrl = TsConfigJson.CompilerOptions & {\n [implicitBaseUrlSymbol]: string;\n };\n // eslint-disable-next-line security/detect-object-injection\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\nconst readTsConfig = (tsconfigPath: string, options?: Options): TsConfigJsonResolved => internalParseTsConfig(tsconfigPath, options);\n\nexport default readTsConfig;\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
+ {"version":3,"sources":["../src/tsconfig.ts","../src/read-tsconfig.ts","../src/utils/resolve-extends-path.ts"],"names":["findUp","findUpSync","writeJson","NotFoundError","toPath","join","realpathSync","readFileSync","parse","dirname","normalize","relative","resolve","toNamespacedPath","existsSync","statSync","Module","isAbsolute","resolveExports","readJsonc","jsonPath","getPnpApi","findPnpApi","resolveFromPackageJsonPath","packageJsonPath","subpath","ignoreExports","cache","cacheKey","packageJson","resolvedPath","resolvedExport","PACKAGE_JSON","TS_CONFIG_JSON","resolveExtendsPath","requestedPath","directoryPath","filePath","orgOrName","remaining","packageName","pnpApi","resolveWithPnp","resolved","packagePath","directory","path","fullPackagePath","jsonExtension","fullPackagePathWithJson","fullPackageJsonPath","tsconfigPath","resolve_extends_path_default","implicitBaseUrlSymbol","normalizePath","resolveExtends","extendsPath","fromDirectoryPath","circularExtendsTracker","options","resolvedExtendsPath","extendsDirectoryPath","extendsConfig","internalParseTsConfig","compilerOptions","resolvePaths","property","unresolvedPath","file","realTsconfigPath","config","extendsPathList","merged","normalizedPaths","resolvedBaseUrl","relativeBaseUrl","outDir","element","watchOptions","excludePath","readTsConfig","read_tsconfig_default","TsConfigFileCache","findTsConfig","cwd","configFileName","output","findTSConfig","findTsConfigSync","findTSConfigSync","writeTsConfig","data","writeOptions","writeTSConfig"],"mappings":"AACA,OAAS,UAAAA,EAAQ,cAAAC,EAAY,aAAAC,OAAiB,eAC9C,OAAS,iBAAAC,MAAqB,qBAC9B,OAAS,UAAAC,OAAc,qBACvB,OAAS,QAAAC,OAAY,QCErB,OAAS,gBAAAC,MAAoB,KAE7B,OAAS,gBAAAC,MAAoB,eAC7B,OAAS,iBAAAJ,MAAqB,qBAC9B,OAAS,SAAAK,MAAa,eACtB,OAAS,WAAAC,EAAS,QAAAJ,EAAM,aAAAK,EAAW,YAAAC,EAAU,WAAAC,EAAS,oBAAAC,MAAwB,QCL9E,OAAS,cAAAC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AQ,OACRhC,EAAM,IAAIU,EAAUiD,CAAM,EAGvBA,CACX,EAGaG,GAAmBD,GAWnBE,GAAgB,MAAOC,EAAoBhC,EAAqD,CAAC,IAAqB,CAC/H,GAAM,CAAE,IAAAyB,EAAK,GAAGQ,CAAa,EAAIjC,EAE3Bd,EAAYzC,GAAOuD,EAAQ,KAAO,QAAQ,IAAI,CAAC,EAErD,MAAMzD,GAAUG,GAAKwC,EAAW,eAAe,EAAG8C,EAAMC,CAAY,CACxE,EAGaC,GAAgBH","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","/**\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 { realpathSync } from \"node:fs\";\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 implicitBaseUrlSymbol = Symbol(\"implicitBaseUrl\");\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 let realTsconfigPath: string;\n\n try {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n realTsconfigPath = realpathSync(tsconfigPath) as string;\n } catch {\n throw new Error(`Cannot resolve tsconfig at path: ${tsconfigPath}`);\n }\n\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 = readJsonc(realTsconfigPath) || {};\n\n if (typeof config !== \"object\") {\n throw new SyntaxError(`Failed to parse tsconfig at: ${tsconfigPath}`);\n }\n\n const directoryPath = dirname(realTsconfigPath);\n\n if (config.compilerOptions) {\n const { compilerOptions } = config;\n if (compilerOptions.paths && !compilerOptions.baseUrl) {\n type WithImplicitBaseUrl = TsConfigJson.CompilerOptions & {\n [implicitBaseUrlSymbol]: string;\n };\n // eslint-disable-next-line security/detect-object-injection\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\nconst readTsConfig = (tsconfigPath: string, options?: Options): TsConfigJsonResolved => internalParseTsConfig(tsconfigPath, options);\n\nexport default readTsConfig;\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,13 +1,13 @@
1
1
  'use strict';
2
2
 
3
- var chunkVH54OLZU_cjs = require('./chunk-VH54OLZU.cjs');
3
+ var chunkKSXRMTAQ_cjs = require('./chunk-KSXRMTAQ.cjs');
4
4
  var fs$1 = require('fs');
5
5
  var fs = require('@visulima/fs');
6
6
  var error = require('@visulima/fs/error');
7
7
  var pathe = require('pathe');
8
8
 
9
- var w=async n=>{let a=await fs.findUp(["lerna.json","turbo.json"],{type:"file",...n&&{cwd:n}});if(a?.endsWith("lerna.json")){let o=await fs.readJson(a);if(o.useWorkspaces||o.packages)return {path:pathe.dirname(a),strategy:"lerna"}}let s=a?.endsWith("turbo.json");try{let{packageManager:o,path:r}=await chunkVH54OLZU_cjs.c(n);if(["npm","yarn"].includes(o)){let t=pathe.join(r,"package.json");if(fs$1.existsSync(t)&&fs$1.readFileSync(pathe.join(r,"package.json"),"utf8").includes("workspaces"))return {path:r,strategy:s?"turbo":o}}else if(o==="pnpm"){let t=pathe.join(r,"pnpm-workspace.yaml");if(fs$1.existsSync(t))return {path:r,strategy:s?"turbo":"pnpm"}}}catch(o){if(!(o instanceof error.NotFoundError))throw o}throw new Error(`No monorepo root could be found upwards from the directory ${n} using lerna, yarn, pnpm, or npm as indicators.`)};
9
+ var w=async n=>{let a=await fs.findUp(["lerna.json","turbo.json"],{type:"file",...n&&{cwd:n}});if(a?.endsWith("lerna.json")){let o=await fs.readJson(a);if(o.useWorkspaces||o.packages)return {path:pathe.dirname(a),strategy:"lerna"}}let s=a?.endsWith("turbo.json");try{let{packageManager:o,path:r}=await chunkKSXRMTAQ_cjs.c(n);if(["npm","yarn"].includes(o)){let t=pathe.join(r,"package.json");if(fs$1.existsSync(t)&&fs$1.readFileSync(pathe.join(r,"package.json"),"utf8").includes("workspaces"))return {path:r,strategy:s?"turbo":o}}else if(o==="pnpm"){let t=pathe.join(r,"pnpm-workspace.yaml");if(fs$1.existsSync(t))return {path:r,strategy:s?"turbo":"pnpm"}}}catch(o){if(!(o instanceof error.NotFoundError))throw o}throw new Error(`No monorepo root could be found upwards from the directory ${n} using lerna, yarn, pnpm, or npm as indicators.`)};
10
10
 
11
11
  exports.a = w;
12
12
  //# sourceMappingURL=out.js.map
13
- //# sourceMappingURL=chunk-6N3YSMA2.cjs.map
13
+ //# sourceMappingURL=chunk-WOLHGXXJ.cjs.map
@@ -1,7 +1,7 @@
1
- import { d } from './chunk-VGU7UU4D.js';
1
+ import { d } from './chunk-44SW4DFI.js';
2
2
 
3
3
  var t=class extends Error{constructor(n,r){if(typeof n=="string"&&(n=[n]),n.length===0){super("Package was not found.");return}if(r===void 0)try{r=d().packageManager;}catch{}r===void 0&&(r="npm"),super(`Package '${n.join(" ")}' was not found. Please install it using '${r} install ${n.join(" ")}'`);}get code(){return "PACKAGE_NOT_FOUND"}set code(n){throw new Error("Cannot overwrite code PACKAGE_NOT_FOUND")}get name(){return "PackageNotFoundError"}set name(n){throw new Error("Cannot overwrite name of PackageNotFoundError")}},f=t;
4
4
 
5
5
  export { f as a };
6
6
  //# sourceMappingURL=out.js.map
7
- //# sourceMappingURL=chunk-6WZZWBWV.js.map
7
+ //# sourceMappingURL=chunk-ZDLZRGSC.js.map
package/dist/error.cjs CHANGED
@@ -1,14 +1,14 @@
1
1
  'use strict';
2
2
 
3
- var chunk3DGUP62F_cjs = require('./chunk-3DGUP62F.cjs');
4
- require('./chunk-VH54OLZU.cjs');
3
+ var chunkDNYCFU7L_cjs = require('./chunk-DNYCFU7L.cjs');
4
+ require('./chunk-KSXRMTAQ.cjs');
5
5
  require('./chunk-6KT7465D.cjs');
6
6
 
7
7
 
8
8
 
9
9
  Object.defineProperty(exports, 'PackageNotFoundError', {
10
10
  enumerable: true,
11
- get: function () { return chunk3DGUP62F_cjs.a; }
11
+ get: function () { return chunkDNYCFU7L_cjs.a; }
12
12
  });
13
13
  //# sourceMappingURL=out.js.map
14
14
  //# sourceMappingURL=error.cjs.map
package/dist/error.js CHANGED
@@ -1,5 +1,5 @@
1
- export { a as PackageNotFoundError } from './chunk-6WZZWBWV.js';
2
- import './chunk-VGU7UU4D.js';
1
+ export { a as PackageNotFoundError } from './chunk-ZDLZRGSC.js';
2
+ import './chunk-44SW4DFI.js';
3
3
  import './chunk-U4YVB3GU.js';
4
4
  //# sourceMappingURL=out.js.map
5
5
  //# sourceMappingURL=error.js.map
package/dist/index.cjs CHANGED
@@ -1,57 +1,57 @@
1
1
  'use strict';
2
2
 
3
- var chunk3DGUP62F_cjs = require('./chunk-3DGUP62F.cjs');
4
- var chunk6N3YSMA2_cjs = require('./chunk-6N3YSMA2.cjs');
5
- var chunkAQMSM3GI_cjs = require('./chunk-AQMSM3GI.cjs');
6
- var chunkVH54OLZU_cjs = require('./chunk-VH54OLZU.cjs');
3
+ var chunkDNYCFU7L_cjs = require('./chunk-DNYCFU7L.cjs');
4
+ var chunkWOLHGXXJ_cjs = require('./chunk-WOLHGXXJ.cjs');
5
+ var chunk5YG33J5B_cjs = require('./chunk-5YG33J5B.cjs');
6
+ var chunkKSXRMTAQ_cjs = require('./chunk-KSXRMTAQ.cjs');
7
7
  var chunk6KT7465D_cjs = require('./chunk-6KT7465D.cjs');
8
- var chunk4K7XWYTT_cjs = require('./chunk-4K7XWYTT.cjs');
8
+ var chunkOVKFHJQE_cjs = require('./chunk-OVKFHJQE.cjs');
9
9
  var fs = require('fs');
10
10
  var process = require('process');
11
11
  var fs$1 = require('@visulima/fs');
12
12
  var pathe = require('pathe');
13
13
 
14
- var d=(r,e)=>(e?.create&&fs$1.ensureDirSync(r),r),F=async(r,e)=>{if(process.env.CACHE_DIR&&!["0","1","false","true"].includes(process.env.CACHE_DIR))return d(pathe.join(process.env.CACHE_DIR,r),e);let s=await chunkAQMSM3GI_cjs.a(e?.cwd??process.cwd());if(!s)return;let o=pathe.join(s,"node_modules"),t=pathe.join(o,".cache"),i=pathe.join(t,r);if(!(fs.existsSync(i)&&!await fs$1.isAccessible(i,fs$1.W_OK))&&!(fs.existsSync(t)&&!await fs$1.isAccessible(t,fs$1.W_OK))&&!(fs.existsSync(o)&&!await fs$1.isAccessible(o,fs$1.W_OK)))return d(i,e)},L=(r,e)=>{if(process.env.CACHE_DIR&&!["0","1","false","true"].includes(process.env.CACHE_DIR))return d(pathe.join(process.env.CACHE_DIR,r),e);let s=chunkAQMSM3GI_cjs.b(e?.cwd??process.cwd());if(!s)return;let o=pathe.join(s,"node_modules"),t=pathe.join(o,".cache"),i=pathe.join(t,r);if(!(fs.existsSync(i)&&!fs$1.isAccessibleSync(i,fs$1.W_OK))&&!(fs.existsSync(t)&&!fs$1.isAccessibleSync(t,fs$1.W_OK))&&!(fs.existsSync(o)&&!fs$1.isAccessibleSync(o,fs$1.W_OK)))return d(i,e)};
14
+ var d=(r,e)=>(e?.create&&fs$1.ensureDirSync(r),r),F=async(r,e)=>{if(process.env.CACHE_DIR&&!["0","1","false","true"].includes(process.env.CACHE_DIR))return d(pathe.join(process.env.CACHE_DIR,r),e);let s=await chunk5YG33J5B_cjs.a(e?.cwd??process.cwd());if(!s)return;let o=pathe.join(s,"node_modules"),t=pathe.join(o,".cache"),i=pathe.join(t,r);if(!(fs.existsSync(i)&&!await fs$1.isAccessible(i,fs$1.W_OK))&&!(fs.existsSync(t)&&!await fs$1.isAccessible(t,fs$1.W_OK))&&!(fs.existsSync(o)&&!await fs$1.isAccessible(o,fs$1.W_OK)))return d(i,e)},L=(r,e)=>{if(process.env.CACHE_DIR&&!["0","1","false","true"].includes(process.env.CACHE_DIR))return d(pathe.join(process.env.CACHE_DIR,r),e);let s=chunk5YG33J5B_cjs.b(e?.cwd??process.cwd());if(!s)return;let o=pathe.join(s,"node_modules"),t=pathe.join(o,".cache"),i=pathe.join(t,r);if(!(fs.existsSync(i)&&!fs$1.isAccessibleSync(i,fs$1.W_OK))&&!(fs.existsSync(t)&&!fs$1.isAccessibleSync(t,fs$1.W_OK))&&!(fs.existsSync(o)&&!fs$1.isAccessibleSync(o,fs$1.W_OK)))return d(i,e)};
15
15
 
16
16
  Object.defineProperty(exports, 'PackageNotFoundError', {
17
17
  enumerable: true,
18
- get: function () { return chunk3DGUP62F_cjs.a; }
18
+ get: function () { return chunkDNYCFU7L_cjs.a; }
19
19
  });
20
20
  Object.defineProperty(exports, 'findMonorepoRoot', {
21
21
  enumerable: true,
22
- get: function () { return chunk6N3YSMA2_cjs.a; }
22
+ get: function () { return chunkWOLHGXXJ_cjs.a; }
23
23
  });
24
24
  Object.defineProperty(exports, 'findPackageRoot', {
25
25
  enumerable: true,
26
- get: function () { return chunkAQMSM3GI_cjs.a; }
26
+ get: function () { return chunk5YG33J5B_cjs.a; }
27
27
  });
28
28
  Object.defineProperty(exports, 'findPackageRootSync', {
29
29
  enumerable: true,
30
- get: function () { return chunkAQMSM3GI_cjs.b; }
30
+ get: function () { return chunk5YG33J5B_cjs.b; }
31
31
  });
32
32
  Object.defineProperty(exports, 'findLockFile', {
33
33
  enumerable: true,
34
- get: function () { return chunkVH54OLZU_cjs.a; }
34
+ get: function () { return chunkKSXRMTAQ_cjs.a; }
35
35
  });
36
36
  Object.defineProperty(exports, 'findLockFileSync', {
37
37
  enumerable: true,
38
- get: function () { return chunkVH54OLZU_cjs.b; }
38
+ get: function () { return chunkKSXRMTAQ_cjs.b; }
39
39
  });
40
40
  Object.defineProperty(exports, 'findPackageManager', {
41
41
  enumerable: true,
42
- get: function () { return chunkVH54OLZU_cjs.c; }
42
+ get: function () { return chunkKSXRMTAQ_cjs.c; }
43
43
  });
44
44
  Object.defineProperty(exports, 'findPackageManagerSync', {
45
45
  enumerable: true,
46
- get: function () { return chunkVH54OLZU_cjs.d; }
46
+ get: function () { return chunkKSXRMTAQ_cjs.d; }
47
47
  });
48
48
  Object.defineProperty(exports, 'getPackageManagerVersion', {
49
49
  enumerable: true,
50
- get: function () { return chunkVH54OLZU_cjs.e; }
50
+ get: function () { return chunkKSXRMTAQ_cjs.e; }
51
51
  });
52
52
  Object.defineProperty(exports, 'identifyInitiatingPackageManager', {
53
53
  enumerable: true,
54
- get: function () { return chunkVH54OLZU_cjs.f; }
54
+ get: function () { return chunkKSXRMTAQ_cjs.f; }
55
55
  });
56
56
  Object.defineProperty(exports, 'findPackageJson', {
57
57
  enumerable: true,
@@ -75,27 +75,27 @@ Object.defineProperty(exports, 'writePackageJsonSync', {
75
75
  });
76
76
  Object.defineProperty(exports, 'findTSConfig', {
77
77
  enumerable: true,
78
- get: function () { return chunk4K7XWYTT_cjs.c; }
78
+ get: function () { return chunkOVKFHJQE_cjs.c; }
79
79
  });
80
80
  Object.defineProperty(exports, 'findTSConfigSync', {
81
81
  enumerable: true,
82
- get: function () { return chunk4K7XWYTT_cjs.e; }
82
+ get: function () { return chunkOVKFHJQE_cjs.e; }
83
83
  });
84
84
  Object.defineProperty(exports, 'findTsConfig', {
85
85
  enumerable: true,
86
- get: function () { return chunk4K7XWYTT_cjs.b; }
86
+ get: function () { return chunkOVKFHJQE_cjs.b; }
87
87
  });
88
88
  Object.defineProperty(exports, 'findTsConfigSync', {
89
89
  enumerable: true,
90
- get: function () { return chunk4K7XWYTT_cjs.d; }
90
+ get: function () { return chunkOVKFHJQE_cjs.d; }
91
91
  });
92
92
  Object.defineProperty(exports, 'readTsConfig', {
93
93
  enumerable: true,
94
- get: function () { return chunk4K7XWYTT_cjs.a; }
94
+ get: function () { return chunkOVKFHJQE_cjs.a; }
95
95
  });
96
96
  Object.defineProperty(exports, 'writeTSConfig', {
97
97
  enumerable: true,
98
- get: function () { return chunk4K7XWYTT_cjs.g; }
98
+ get: function () { return chunkOVKFHJQE_cjs.g; }
99
99
  });
100
100
  exports.findCacheDirectory = F;
101
101
  exports.findCacheDirectorySync = L;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/find-cache-dir.ts"],"names":["existsSync","cwd","env","ensureDirSync","isAccessible","isAccessibleSync","W_OK","join","useDirectory","directory","options","findCacheDirectory","name","rootDirectory","findPackageRoot","nodeModulesDirectory","cacheDirectory","cacheNameDirectory","findCacheDirectorySync","findPackageRootSync"],"mappings":"+VACA,OAAS,cAAAA,MAAkB,KAC3B,OAAS,OAAAC,EAAK,OAAAC,MAAW,UAEzB,OAAS,iBAAAC,EAAe,gBAAAC,EAAc,oBAAAC,EAAkB,QAAAC,MAAY,eACpE,OAAS,QAAAC,MAAY,QASrB,IAAMC,EAAe,CAACC,EAAmBC,KACjCA,GAAS,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K,CAACV,EAAiBU,EAAsBT,CAAI,GAIpF,OAAOE,EAAaS,EAAoBP,CAAO,CACnD","sourcesContent":["// eslint-disable-next-line unicorn/prevent-abbreviations\nimport { existsSync } from \"node:fs\";\nimport { cwd, env } from \"node:process\";\n\nimport { ensureDirSync, isAccessible, isAccessibleSync, W_OK } from \"@visulima/fs\";\nimport { join } from \"pathe\";\n\nimport { findPackageRoot, findPackageRootSync } from \"./package\";\n\ntype Options = {\n create?: boolean;\n cwd?: URL | string;\n};\n\nconst useDirectory = (directory: string, options?: Options): string => {\n if (options?.create) {\n ensureDirSync(directory);\n }\n\n return directory;\n};\n\nexport const findCacheDirectory = async (name: string, options?: Options): Promise<string | undefined> => {\n if (env[\"CACHE_DIR\"] && ![\"0\", \"1\", \"false\", \"true\"].includes(env[\"CACHE_DIR\"])) {\n return useDirectory(join(env[\"CACHE_DIR\"], name), options);\n }\n\n const rootDirectory = await findPackageRoot(options?.cwd ?? cwd());\n\n if (!rootDirectory) {\n return undefined;\n }\n\n const nodeModulesDirectory = join(rootDirectory, \"node_modules\");\n const cacheDirectory = join(nodeModulesDirectory, \".cache\");\n const cacheNameDirectory = join(cacheDirectory, name);\n\n // If node_modules/.cache/${name} exists: If it is writeable, return node_modules/.cache/${name}, otherwise return undefined\n // Otherwise, if node_modules/.cache exists: If it is writeable, return node_modules/.cache/${name}, otherwise return undefined\n // Otherwise: If node_modules is writeable, return node_modules/.cache/${name}, otherwise return undefined\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (existsSync(cacheNameDirectory) && !(await isAccessible(cacheNameDirectory, W_OK))) {\n return undefined;\n }\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (existsSync(cacheDirectory) && !(await isAccessible(cacheDirectory, W_OK))) {\n return undefined;\n }\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (existsSync(nodeModulesDirectory) && !(await isAccessible(nodeModulesDirectory, W_OK))) {\n return undefined;\n }\n\n return useDirectory(cacheNameDirectory, options);\n};\n\nexport const findCacheDirectorySync = (name: string, options?: Options): string | undefined => {\n if (env[\"CACHE_DIR\"] && ![\"0\", \"1\", \"false\", \"true\"].includes(env[\"CACHE_DIR\"])) {\n return useDirectory(join(env[\"CACHE_DIR\"], name), options);\n }\n\n const rootDirectory = findPackageRootSync(options?.cwd ?? cwd());\n\n if (!rootDirectory) {\n return undefined;\n }\n\n const nodeModulesDirectory = join(rootDirectory, \"node_modules\");\n const cacheDirectory = join(nodeModulesDirectory, \".cache\");\n const cacheNameDirectory = join(cacheDirectory, name);\n\n // If node_modules/.cache/${name} exists: If it is writeable, return node_modules/.cache/${name}, otherwise return undefined\n // Otherwise, if node_modules/.cache exists: If it is writeable, return node_modules/.cache/${name}, otherwise return undefined\n // Otherwise: If node_modules is writeable, return node_modules/.cache/${name}, otherwise return undefined\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (existsSync(cacheNameDirectory) && !isAccessibleSync(cacheNameDirectory, W_OK)) {\n return undefined;\n }\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (existsSync(cacheDirectory) && !isAccessibleSync(cacheDirectory, W_OK)) {\n return undefined;\n }\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (existsSync(nodeModulesDirectory) && !isAccessibleSync(nodeModulesDirectory, W_OK)) {\n return undefined;\n }\n\n return useDirectory(cacheNameDirectory, options);\n};\n"]}
1
+ {"version":3,"sources":["../src/find-cache-dir.ts"],"names":["existsSync","cwd","env","ensureDirSync","isAccessible","isAccessibleSync","W_OK","join","useDirectory","directory","options","findCacheDirectory","name","rootDirectory","findPackageRoot","nodeModulesDirectory","cacheDirectory","cacheNameDirectory","findCacheDirectorySync","findPackageRootSync"],"mappings":"+VACA,OAAS,cAAAA,MAAkB,KAC3B,OAAS,OAAAC,EAAK,OAAAC,MAAW,UAEzB,OAAS,iBAAAC,EAAe,gBAAAC,EAAc,oBAAAC,EAAkB,QAAAC,MAAY,eACpE,OAAS,QAAAC,MAAY,QASrB,IAAM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AKpE,EAAAN,EAAWe,CAAoB,GAAK,CAACV,EAAiBU,EAAsBT,CAAI,GAIpF,OAAOE,EAAaS,EAAoBP,CAAO,CACnD","sourcesContent":["// eslint-disable-next-line unicorn/prevent-abbreviations\nimport { existsSync } from \"node:fs\";\nimport { cwd, env } from \"node:process\";\n\nimport { ensureDirSync, isAccessible, isAccessibleSync, W_OK } from \"@visulima/fs\";\nimport { join } from \"pathe\";\n\nimport { findPackageRoot, findPackageRootSync } from \"./package\";\n\ntype Options = {\n create?: boolean;\n cwd?: URL | string;\n};\n\nconst useDirectory = (directory: string, options?: Options): string => {\n if (options?.create) {\n ensureDirSync(directory);\n }\n\n return directory;\n};\n\nexport const findCacheDirectory = async (name: string, options?: Options): Promise<string | undefined> => {\n if (env.CACHE_DIR && ![\"0\", \"1\", \"false\", \"true\"].includes(env.CACHE_DIR)) {\n return useDirectory(join(env.CACHE_DIR, name), options);\n }\n\n const rootDirectory = await findPackageRoot(options?.cwd ?? cwd());\n\n if (!rootDirectory) {\n return undefined;\n }\n\n const nodeModulesDirectory = join(rootDirectory, \"node_modules\");\n const cacheDirectory = join(nodeModulesDirectory, \".cache\");\n const cacheNameDirectory = join(cacheDirectory, name);\n\n // If node_modules/.cache/${name} exists: If it is writeable, return node_modules/.cache/${name}, otherwise return undefined\n // Otherwise, if node_modules/.cache exists: If it is writeable, return node_modules/.cache/${name}, otherwise return undefined\n // Otherwise: If node_modules is writeable, return node_modules/.cache/${name}, otherwise return undefined\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (existsSync(cacheNameDirectory) && !(await isAccessible(cacheNameDirectory, W_OK))) {\n return undefined;\n }\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (existsSync(cacheDirectory) && !(await isAccessible(cacheDirectory, W_OK))) {\n return undefined;\n }\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (existsSync(nodeModulesDirectory) && !(await isAccessible(nodeModulesDirectory, W_OK))) {\n return undefined;\n }\n\n return useDirectory(cacheNameDirectory, options);\n};\n\nexport const findCacheDirectorySync = (name: string, options?: Options): string | undefined => {\n if (env.CACHE_DIR && ![\"0\", \"1\", \"false\", \"true\"].includes(env.CACHE_DIR)) {\n return useDirectory(join(env.CACHE_DIR, name), options);\n }\n\n const rootDirectory = findPackageRootSync(options?.cwd ?? cwd());\n\n if (!rootDirectory) {\n return undefined;\n }\n\n const nodeModulesDirectory = join(rootDirectory, \"node_modules\");\n const cacheDirectory = join(nodeModulesDirectory, \".cache\");\n const cacheNameDirectory = join(cacheDirectory, name);\n\n // If node_modules/.cache/${name} exists: If it is writeable, return node_modules/.cache/${name}, otherwise return undefined\n // Otherwise, if node_modules/.cache exists: If it is writeable, return node_modules/.cache/${name}, otherwise return undefined\n // Otherwise: If node_modules is writeable, return node_modules/.cache/${name}, otherwise return undefined\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (existsSync(cacheNameDirectory) && !isAccessibleSync(cacheNameDirectory, W_OK)) {\n return undefined;\n }\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (existsSync(cacheDirectory) && !isAccessibleSync(cacheDirectory, W_OK)) {\n return undefined;\n }\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (existsSync(nodeModulesDirectory) && !isAccessibleSync(nodeModulesDirectory, W_OK)) {\n return undefined;\n }\n\n return useDirectory(cacheNameDirectory, options);\n};\n"]}
package/dist/index.js CHANGED
@@ -1,10 +1,10 @@
1
- export { a as PackageNotFoundError } from './chunk-6WZZWBWV.js';
2
- export { a as findMonorepoRoot } from './chunk-3NJM5HV7.js';
3
- import { a, b } from './chunk-75DR5C7M.js';
4
- export { a as findPackageRoot, b as findPackageRootSync } from './chunk-75DR5C7M.js';
5
- export { a as findLockFile, b as findLockFileSync, c as findPackageManager, d as findPackageManagerSync, e as getPackageManagerVersion, f as identifyInitiatingPackageManager } from './chunk-VGU7UU4D.js';
1
+ export { a as PackageNotFoundError } from './chunk-ZDLZRGSC.js';
2
+ export { a as findMonorepoRoot } from './chunk-GMIFPTPB.js';
3
+ import { a, b } from './chunk-I3QTPGJY.js';
4
+ export { a as findPackageRoot, b as findPackageRootSync } from './chunk-I3QTPGJY.js';
5
+ export { a as findLockFile, b as findLockFileSync, c as findPackageManager, d as findPackageManagerSync, e as getPackageManagerVersion, f as identifyInitiatingPackageManager } from './chunk-44SW4DFI.js';
6
6
  export { a as findPackageJson, b as findPackageJsonSync, e as parsePackageJson, c as writePackageJson, d as writePackageJsonSync } from './chunk-U4YVB3GU.js';
7
- export { c as findTSConfig, e as findTSConfigSync, b as findTsConfig, d as findTsConfigSync, a as readTsConfig, g as writeTSConfig } from './chunk-OQ2PTROP.js';
7
+ export { c as findTSConfig, e as findTSConfigSync, b as findTsConfig, d as findTsConfigSync, a as readTsConfig, g as writeTSConfig } from './chunk-CMEGXNWH.js';
8
8
  import { existsSync } from 'node:fs';
9
9
  import { env, cwd } from 'node:process';
10
10
  import { isAccessible, W_OK, isAccessibleSync, ensureDirSync } from '@visulima/fs';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/find-cache-dir.ts"],"names":["existsSync","cwd","env","ensureDirSync","isAccessible","isAccessibleSync","W_OK","join","useDirectory","directory","options","findCacheDirectory","name","rootDirectory","findPackageRoot","nodeModulesDirectory","cacheDirectory","cacheNameDirectory","findCacheDirectorySync","findPackageRootSync"],"mappings":"yVACA,OAAS,cAAAA,MAAkB,UAC3B,OAAS,OAAAC,EAAK,OAAAC,MAAW,eAEzB,OAAS,iBAAAC,EAAe,gBAAAC,EAAc,oBAAAC,EAAkB,QAAAC,MAAY,eACpE,OAAS,QAAAC,MAAY,QASrB,IAAMC,EAAe,CAACC,EAAmBC,KACjCA,GAAS,QACTP,EAAcM,CAAS,EAGpBA,GAGEE,EAAqB,MAAOC,EAAcF,IAAmD,CACtG,GAAIR,EAAI,WAAgB,CAAC,CAAC,IAAK,IAAK,QAAS,MAAM,EAAE,SAASA,EAAI,SAAY,EAC1E,OAAOM,EAA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ensureDirSync, isAccessible, isAccessibleSync, W_OK } from \"@visulima/fs\";\nimport { join } from \"pathe\";\n\nimport { findPackageRoot, findPackageRootSync } from \"./package\";\n\ntype Options = {\n create?: boolean;\n cwd?: URL | string;\n};\n\nconst useDirectory = (directory: string, options?: Options): string => {\n if (options?.create) {\n ensureDirSync(directory);\n }\n\n return directory;\n};\n\nexport const findCacheDirectory = async (name: string, options?: Options): Promise<string | undefined> => {\n if (env[\"CACHE_DIR\"] && ![\"0\", \"1\", \"false\", \"true\"].includes(env[\"CACHE_DIR\"])) {\n return useDirectory(join(env[\"CACHE_DIR\"], name), options);\n }\n\n const rootDirectory = await findPackageRoot(options?.cwd ?? cwd());\n\n if (!rootDirectory) {\n return undefined;\n }\n\n const nodeModulesDirectory = join(rootDirectory, \"node_modules\");\n const cacheDirectory = join(nodeModulesDirectory, \".cache\");\n const cacheNameDirectory = join(cacheDirectory, name);\n\n // If node_modules/.cache/${name} exists: If it is writeable, return node_modules/.cache/${name}, otherwise return undefined\n // Otherwise, if node_modules/.cache exists: If it is writeable, return node_modules/.cache/${name}, otherwise return undefined\n // Otherwise: If node_modules is writeable, return node_modules/.cache/${name}, otherwise return undefined\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (existsSync(cacheNameDirectory) && !(await isAccessible(cacheNameDirectory, W_OK))) {\n return undefined;\n }\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (existsSync(cacheDirectory) && !(await isAccessible(cacheDirectory, W_OK))) {\n return undefined;\n }\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (existsSync(nodeModulesDirectory) && !(await isAccessible(nodeModulesDirectory, W_OK))) {\n return undefined;\n }\n\n return useDirectory(cacheNameDirectory, options);\n};\n\nexport const findCacheDirectorySync = (name: string, options?: Options): string | undefined => {\n if (env[\"CACHE_DIR\"] && ![\"0\", \"1\", \"false\", \"true\"].includes(env[\"CACHE_DIR\"])) {\n return useDirectory(join(env[\"CACHE_DIR\"], name), options);\n }\n\n const rootDirectory = findPackageRootSync(options?.cwd ?? cwd());\n\n if (!rootDirectory) {\n return undefined;\n }\n\n const nodeModulesDirectory = join(rootDirectory, \"node_modules\");\n const cacheDirectory = join(nodeModulesDirectory, \".cache\");\n const cacheNameDirectory = join(cacheDirectory, name);\n\n // If node_modules/.cache/${name} exists: If it is writeable, return node_modules/.cache/${name}, otherwise return undefined\n // Otherwise, if node_modules/.cache exists: If it is writeable, return node_modules/.cache/${name}, otherwise return undefined\n // Otherwise: If node_modules is writeable, return node_modules/.cache/${name}, otherwise return undefined\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (existsSync(cacheNameDirectory) && !isAccessibleSync(cacheNameDirectory, W_OK)) {\n return undefined;\n }\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (existsSync(cacheDirectory) && !isAccessibleSync(cacheDirectory, W_OK)) {\n return undefined;\n }\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (existsSync(nodeModulesDirectory) && !isAccessibleSync(nodeModulesDirectory, W_OK)) {\n return undefined;\n }\n\n return useDirectory(cacheNameDirectory, options);\n};\n"]}
1
+ {"version":3,"sources":["../src/find-cache-dir.ts"],"names":["existsSync","cwd","env","ensureDirSync","isAccessible","isAccessibleSync","W_OK","join","useDirectory","directory","options","findCacheDirectory","name","rootDirectory","findPackageRoot","nodeModulesDirectory","cacheDirectory","cacheNameDirectory","findCacheDirectorySync","findPackageRootSync"],"mappings":"yVACA,OAAS,cAAAA,MAAkB,UAC3B,OAAS,OAAAC,EAAK,OAAAC,MAAW,eAEzB,OAAS,iBAAAC,EAAe,gBAAAC,EAAc,oBAAAC,EAAkB,QAAAC,MAAY,eACpE,OAAS,QAAAC,MAAY,QASrB,IAAMC,EAAe,CAACC,EAAmBC,KACjCA,GAAS,QACTP,EAAcM,CAAS,EAGpBA,GAGEE,EAAqB,MAAOC,EAAcF,IAAmD,CACtG,GAAIR,EAAI,WAAa,CAAC,CAAC,IAAK,IAAK,QAAS,MAAM,EAAE,S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nimport { cwd, env } from \"node:process\";\n\nimport { ensureDirSync, isAccessible, isAccessibleSync, W_OK } from \"@visulima/fs\";\nimport { join } from \"pathe\";\n\nimport { findPackageRoot, findPackageRootSync } from \"./package\";\n\ntype Options = {\n create?: boolean;\n cwd?: URL | string;\n};\n\nconst useDirectory = (directory: string, options?: Options): string => {\n if (options?.create) {\n ensureDirSync(directory);\n }\n\n return directory;\n};\n\nexport const findCacheDirectory = async (name: string, options?: Options): Promise<string | undefined> => {\n if (env.CACHE_DIR && ![\"0\", \"1\", \"false\", \"true\"].includes(env.CACHE_DIR)) {\n return useDirectory(join(env.CACHE_DIR, name), options);\n }\n\n const rootDirectory = await findPackageRoot(options?.cwd ?? cwd());\n\n if (!rootDirectory) {\n return undefined;\n }\n\n const nodeModulesDirectory = join(rootDirectory, \"node_modules\");\n const cacheDirectory = join(nodeModulesDirectory, \".cache\");\n const cacheNameDirectory = join(cacheDirectory, name);\n\n // If node_modules/.cache/${name} exists: If it is writeable, return node_modules/.cache/${name}, otherwise return undefined\n // Otherwise, if node_modules/.cache exists: If it is writeable, return node_modules/.cache/${name}, otherwise return undefined\n // Otherwise: If node_modules is writeable, return node_modules/.cache/${name}, otherwise return undefined\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (existsSync(cacheNameDirectory) && !(await isAccessible(cacheNameDirectory, W_OK))) {\n return undefined;\n }\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (existsSync(cacheDirectory) && !(await isAccessible(cacheDirectory, W_OK))) {\n return undefined;\n }\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (existsSync(nodeModulesDirectory) && !(await isAccessible(nodeModulesDirectory, W_OK))) {\n return undefined;\n }\n\n return useDirectory(cacheNameDirectory, options);\n};\n\nexport const findCacheDirectorySync = (name: string, options?: Options): string | undefined => {\n if (env.CACHE_DIR && ![\"0\", \"1\", \"false\", \"true\"].includes(env.CACHE_DIR)) {\n return useDirectory(join(env.CACHE_DIR, name), options);\n }\n\n const rootDirectory = findPackageRootSync(options?.cwd ?? cwd());\n\n if (!rootDirectory) {\n return undefined;\n }\n\n const nodeModulesDirectory = join(rootDirectory, \"node_modules\");\n const cacheDirectory = join(nodeModulesDirectory, \".cache\");\n const cacheNameDirectory = join(cacheDirectory, name);\n\n // If node_modules/.cache/${name} exists: If it is writeable, return node_modules/.cache/${name}, otherwise return undefined\n // Otherwise, if node_modules/.cache exists: If it is writeable, return node_modules/.cache/${name}, otherwise return undefined\n // Otherwise: If node_modules is writeable, return node_modules/.cache/${name}, otherwise return undefined\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (existsSync(cacheNameDirectory) && !isAccessibleSync(cacheNameDirectory, W_OK)) {\n return undefined;\n }\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (existsSync(cacheDirectory) && !isAccessibleSync(cacheDirectory, W_OK)) {\n return undefined;\n }\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (existsSync(nodeModulesDirectory) && !isAccessibleSync(nodeModulesDirectory, W_OK)) {\n return undefined;\n }\n\n return useDirectory(cacheNameDirectory, options);\n};\n"]}
package/dist/monorepo.cjs CHANGED
@@ -1,14 +1,14 @@
1
1
  'use strict';
2
2
 
3
- var chunk6N3YSMA2_cjs = require('./chunk-6N3YSMA2.cjs');
4
- require('./chunk-VH54OLZU.cjs');
3
+ var chunkWOLHGXXJ_cjs = require('./chunk-WOLHGXXJ.cjs');
4
+ require('./chunk-KSXRMTAQ.cjs');
5
5
  require('./chunk-6KT7465D.cjs');
6
6
 
7
7
 
8
8
 
9
9
  Object.defineProperty(exports, 'findMonorepoRoot', {
10
10
  enumerable: true,
11
- get: function () { return chunk6N3YSMA2_cjs.a; }
11
+ get: function () { return chunkWOLHGXXJ_cjs.a; }
12
12
  });
13
13
  //# sourceMappingURL=out.js.map
14
14
  //# sourceMappingURL=monorepo.cjs.map
package/dist/monorepo.js CHANGED
@@ -1,5 +1,5 @@
1
- export { a as findMonorepoRoot } from './chunk-3NJM5HV7.js';
2
- import './chunk-VGU7UU4D.js';
1
+ export { a as findMonorepoRoot } from './chunk-GMIFPTPB.js';
2
+ import './chunk-44SW4DFI.js';
3
3
  import './chunk-U4YVB3GU.js';
4
4
  //# sourceMappingURL=out.js.map
5
5
  //# sourceMappingURL=monorepo.js.map
@@ -1,33 +1,33 @@
1
1
  'use strict';
2
2
 
3
- var chunkVH54OLZU_cjs = require('./chunk-VH54OLZU.cjs');
3
+ var chunkKSXRMTAQ_cjs = require('./chunk-KSXRMTAQ.cjs');
4
4
  require('./chunk-6KT7465D.cjs');
5
5
 
6
6
 
7
7
 
8
8
  Object.defineProperty(exports, 'findLockFile', {
9
9
  enumerable: true,
10
- get: function () { return chunkVH54OLZU_cjs.a; }
10
+ get: function () { return chunkKSXRMTAQ_cjs.a; }
11
11
  });
12
12
  Object.defineProperty(exports, 'findLockFileSync', {
13
13
  enumerable: true,
14
- get: function () { return chunkVH54OLZU_cjs.b; }
14
+ get: function () { return chunkKSXRMTAQ_cjs.b; }
15
15
  });
16
16
  Object.defineProperty(exports, 'findPackageManager', {
17
17
  enumerable: true,
18
- get: function () { return chunkVH54OLZU_cjs.c; }
18
+ get: function () { return chunkKSXRMTAQ_cjs.c; }
19
19
  });
20
20
  Object.defineProperty(exports, 'findPackageManagerSync', {
21
21
  enumerable: true,
22
- get: function () { return chunkVH54OLZU_cjs.d; }
22
+ get: function () { return chunkKSXRMTAQ_cjs.d; }
23
23
  });
24
24
  Object.defineProperty(exports, 'getPackageManagerVersion', {
25
25
  enumerable: true,
26
- get: function () { return chunkVH54OLZU_cjs.e; }
26
+ get: function () { return chunkKSXRMTAQ_cjs.e; }
27
27
  });
28
28
  Object.defineProperty(exports, 'identifyInitiatingPackageManager', {
29
29
  enumerable: true,
30
- get: function () { return chunkVH54OLZU_cjs.f; }
30
+ get: function () { return chunkKSXRMTAQ_cjs.f; }
31
31
  });
32
32
  //# sourceMappingURL=out.js.map
33
33
  //# sourceMappingURL=package-manager.cjs.map
@@ -1,4 +1,4 @@
1
- export { a as findLockFile, b as findLockFileSync, c as findPackageManager, d as findPackageManagerSync, e as getPackageManagerVersion, f as identifyInitiatingPackageManager } from './chunk-VGU7UU4D.js';
1
+ export { a as findLockFile, b as findLockFileSync, c as findPackageManager, d as findPackageManagerSync, e as getPackageManagerVersion, f as identifyInitiatingPackageManager } from './chunk-44SW4DFI.js';
2
2
  import './chunk-U4YVB3GU.js';
3
3
  //# sourceMappingURL=out.js.map
4
4
  //# sourceMappingURL=package-manager.js.map
package/dist/package.cjs CHANGED
@@ -1,18 +1,18 @@
1
1
  'use strict';
2
2
 
3
- var chunkAQMSM3GI_cjs = require('./chunk-AQMSM3GI.cjs');
4
- require('./chunk-VH54OLZU.cjs');
3
+ var chunk5YG33J5B_cjs = require('./chunk-5YG33J5B.cjs');
4
+ require('./chunk-KSXRMTAQ.cjs');
5
5
  require('./chunk-6KT7465D.cjs');
6
6
 
7
7
 
8
8
 
9
9
  Object.defineProperty(exports, 'findPackageRoot', {
10
10
  enumerable: true,
11
- get: function () { return chunkAQMSM3GI_cjs.a; }
11
+ get: function () { return chunk5YG33J5B_cjs.a; }
12
12
  });
13
13
  Object.defineProperty(exports, 'findPackageRootSync', {
14
14
  enumerable: true,
15
- get: function () { return chunkAQMSM3GI_cjs.b; }
15
+ get: function () { return chunk5YG33J5B_cjs.b; }
16
16
  });
17
17
  //# sourceMappingURL=out.js.map
18
18
  //# sourceMappingURL=package.cjs.map
package/dist/package.js CHANGED
@@ -1,5 +1,5 @@
1
- export { a as findPackageRoot, b as findPackageRootSync } from './chunk-75DR5C7M.js';
2
- import './chunk-VGU7UU4D.js';
1
+ export { a as findPackageRoot, b as findPackageRootSync } from './chunk-I3QTPGJY.js';
2
+ import './chunk-44SW4DFI.js';
3
3
  import './chunk-U4YVB3GU.js';
4
4
  //# sourceMappingURL=out.js.map
5
5
  //# sourceMappingURL=package.js.map
package/dist/tsconfig.cjs CHANGED
@@ -1,32 +1,32 @@
1
1
  'use strict';
2
2
 
3
- var chunk4K7XWYTT_cjs = require('./chunk-4K7XWYTT.cjs');
3
+ var chunkOVKFHJQE_cjs = require('./chunk-OVKFHJQE.cjs');
4
4
 
5
5
 
6
6
 
7
7
  Object.defineProperty(exports, 'findTSConfig', {
8
8
  enumerable: true,
9
- get: function () { return chunk4K7XWYTT_cjs.c; }
9
+ get: function () { return chunkOVKFHJQE_cjs.c; }
10
10
  });
11
11
  Object.defineProperty(exports, 'findTSConfigSync', {
12
12
  enumerable: true,
13
- get: function () { return chunk4K7XWYTT_cjs.e; }
13
+ get: function () { return chunkOVKFHJQE_cjs.e; }
14
14
  });
15
15
  Object.defineProperty(exports, 'findTsConfig', {
16
16
  enumerable: true,
17
- get: function () { return chunk4K7XWYTT_cjs.b; }
17
+ get: function () { return chunkOVKFHJQE_cjs.b; }
18
18
  });
19
19
  Object.defineProperty(exports, 'findTsConfigSync', {
20
20
  enumerable: true,
21
- get: function () { return chunk4K7XWYTT_cjs.d; }
21
+ get: function () { return chunkOVKFHJQE_cjs.d; }
22
22
  });
23
23
  Object.defineProperty(exports, 'writeTSConfig', {
24
24
  enumerable: true,
25
- get: function () { return chunk4K7XWYTT_cjs.g; }
25
+ get: function () { return chunkOVKFHJQE_cjs.g; }
26
26
  });
27
27
  Object.defineProperty(exports, 'writeTsConfig', {
28
28
  enumerable: true,
29
- get: function () { return chunk4K7XWYTT_cjs.f; }
29
+ get: function () { return chunkOVKFHJQE_cjs.f; }
30
30
  });
31
31
  //# sourceMappingURL=out.js.map
32
32
  //# sourceMappingURL=tsconfig.cjs.map
package/dist/tsconfig.js CHANGED
@@ -1,3 +1,3 @@
1
- export { c as findTSConfig, e as findTSConfigSync, b as findTsConfig, d as findTsConfigSync, g as writeTSConfig, f as writeTsConfig } from './chunk-OQ2PTROP.js';
1
+ export { c as findTSConfig, e as findTSConfigSync, b as findTsConfig, d as findTsConfigSync, g as writeTSConfig, f as writeTsConfig } from './chunk-CMEGXNWH.js';
2
2
  //# sourceMappingURL=out.js.map
3
3
  //# sourceMappingURL=tsconfig.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visulima/package",
3
- "version": "1.6.0",
3
+ "version": "1.6.2",
4
4
  "description": "One Package to rule them all, finds your root-dir, monorepo, package manager or tsconfig.json",
5
5
  "keywords": [
6
6
  "anolilab",
@@ -153,19 +153,19 @@
153
153
  "test:watch": "vitest"
154
154
  },
155
155
  "dependencies": {
156
- "@visulima/fs": "2.0.3",
156
+ "@visulima/fs": "2.0.5",
157
157
  "jsonc-parser": "^3.2.1",
158
158
  "normalize-package-data": "^6.0.0",
159
159
  "pathe": "^1.1.2",
160
160
  "resolve-pkg-maps": "^1.0.0",
161
- "type-fest": "^4.14.0"
161
+ "type-fest": "^4.15.0"
162
162
  },
163
163
  "devDependencies": {
164
164
  "@anolilab/eslint-config": "^15.0.3",
165
165
  "@anolilab/prettier-config": "^5.0.14",
166
166
  "@anolilab/semantic-release-preset": "^8.0.3",
167
- "@babel/core": "^7.24.3",
168
- "@pnpm/exe": "^8.15.5",
167
+ "@babel/core": "^7.24.4",
168
+ "@pnpm/exe": "^8.15.6",
169
169
  "@rushstack/eslint-plugin-security": "^0.8.1",
170
170
  "@total-typescript/ts-reset": "^0.5.1",
171
171
  "@types/node": "18.18.14",
@@ -178,18 +178,18 @@
178
178
  "eslint-plugin-etc": "^2.0.3",
179
179
  "eslint-plugin-import": "npm:eslint-plugin-i@^2.29.1",
180
180
  "eslint-plugin-mdx": "^3.1.5",
181
- "eslint-plugin-vitest": "^0.4.0",
181
+ "eslint-plugin-vitest": "^0.4.1",
182
182
  "eslint-plugin-vitest-globals": "^1.5.0",
183
183
  "execa": "^8.0.1",
184
- "npm": "^10.5.0",
184
+ "npm": "^10.5.1",
185
185
  "prettier": "^3.2.5",
186
186
  "rimraf": "^5.0.5",
187
- "semantic-release": "^23.0.6",
187
+ "semantic-release": "^23.0.7",
188
188
  "sort-package-json": "^2.10.0",
189
189
  "strip-ansi": "^7.1.0",
190
190
  "tempy": "^3.1.0",
191
191
  "tsup": "^8.0.2",
192
- "typescript": "^5.4.3",
192
+ "typescript": "^5.4.4",
193
193
  "vitest": "^1.4.0",
194
194
  "which-pm-runs": "file:",
195
195
  "yarn": "^1.22.22"