@visulima/package 1.4.1 → 1.4.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 (42) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/{chunk-TM6ZD56C.cjs → chunk-3IWUMNBO.cjs} +3 -3
  3. package/dist/chunk-4I4DRNVT.cjs +22 -0
  4. package/dist/chunk-4I4DRNVT.cjs.map +1 -0
  5. package/dist/{chunk-5ZQIFU6S.js → chunk-6KVF4I2Q.js} +2 -2
  6. package/dist/chunk-GA54FVOU.js +12 -0
  7. package/dist/chunk-GA54FVOU.js.map +1 -0
  8. package/dist/{chunk-VAMRQCZW.cjs → chunk-GAZI4NM6.cjs} +3 -3
  9. package/dist/{chunk-G767QS5X.js → chunk-M4MWM246.js} +2 -2
  10. package/dist/{chunk-XKKPPOYW.js → chunk-PUY4M2BR.js} +2 -2
  11. package/dist/chunk-QPR3SJGT.js +15 -0
  12. package/dist/chunk-QPR3SJGT.js.map +1 -0
  13. package/dist/chunk-WL2BRLJZ.cjs +27 -0
  14. package/dist/chunk-WL2BRLJZ.cjs.map +1 -0
  15. package/dist/{chunk-L6J2NRQY.cjs → chunk-XMGJIRS7.cjs} +3 -3
  16. package/dist/index.cjs +22 -22
  17. package/dist/index.js +5 -5
  18. package/dist/monorepo.cjs +4 -4
  19. package/dist/monorepo.js +3 -3
  20. package/dist/package-json.cjs +6 -6
  21. package/dist/package-json.js +1 -1
  22. package/dist/package-manager.cjs +6 -6
  23. package/dist/package-manager.js +2 -2
  24. package/dist/package.cjs +4 -4
  25. package/dist/package.js +3 -3
  26. package/dist/tsconfig.cjs +7 -7
  27. package/dist/tsconfig.js +1 -1
  28. package/package.json +2 -2
  29. package/dist/chunk-BGBPBHAL.cjs +0 -27
  30. package/dist/chunk-BGBPBHAL.cjs.map +0 -1
  31. package/dist/chunk-F63DY4KL.js +0 -15
  32. package/dist/chunk-F63DY4KL.js.map +0 -1
  33. package/dist/chunk-TUN46UZB.js +0 -12
  34. package/dist/chunk-TUN46UZB.js.map +0 -1
  35. package/dist/chunk-VQCWTT2B.cjs +0 -22
  36. package/dist/chunk-VQCWTT2B.cjs.map +0 -1
  37. /package/dist/{chunk-TM6ZD56C.cjs.map → chunk-3IWUMNBO.cjs.map} +0 -0
  38. /package/dist/{chunk-5ZQIFU6S.js.map → chunk-6KVF4I2Q.js.map} +0 -0
  39. /package/dist/{chunk-VAMRQCZW.cjs.map → chunk-GAZI4NM6.cjs.map} +0 -0
  40. /package/dist/{chunk-G767QS5X.js.map → chunk-M4MWM246.js.map} +0 -0
  41. /package/dist/{chunk-XKKPPOYW.js.map → chunk-PUY4M2BR.js.map} +0 -0
  42. /package/dist/{chunk-L6J2NRQY.cjs.map → chunk-XMGJIRS7.cjs.map} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,3 +1,16 @@
1
+ ## @visulima/package [1.4.2](https://github.com/visulima/visulima/compare/@visulima/package@1.4.1...@visulima/package@1.4.2) (2024-03-23)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **package:** adjusted error message ([a9a38b6](https://github.com/visulima/visulima/commit/a9a38b602c56b87d2cef700d5d55e46e873f0ef6))
7
+
8
+
9
+
10
+ ### Dependencies
11
+
12
+ * **@visulima/fs:** upgraded to 2.0.0
13
+
1
14
  ## @visulima/package [1.4.1](https://github.com/visulima/visulima/compare/@visulima/package@1.4.0...@visulima/package@1.4.1) (2024-03-22)
2
15
 
3
16
 
@@ -1,16 +1,16 @@
1
1
  'use strict';
2
2
 
3
- var chunkVQCWTT2B_cjs = require('./chunk-VQCWTT2B.cjs');
3
+ var chunk4I4DRNVT_cjs = require('./chunk-4I4DRNVT.cjs');
4
4
  var child_process = require('child_process');
5
5
  var fs$1 = require('fs');
6
6
  var fs = require('@visulima/fs');
7
7
  var pathe = require('pathe');
8
8
 
9
- var f=["yarn.lock","package-lock.json","pnpm-lock.yaml","npm-shrinkwrap.json","bun.lockb"],y=async a=>{let n=await fs.findUp(f,{type:"file",...a&&{cwd:a}});if(!n)throw new Error("Could not find lock file");return n},x=async a=>{let n=await fs.findUp(e=>{let t;if(f.forEach(i=>{!t&&fs$1.existsSync(pathe.join(e,i))&&(t=pathe.join(e,i));}),t)return t;let r=pathe.join(e,"package.json");if(fs$1.existsSync(r)&&chunkVQCWTT2B_cjs.e(fs$1.readFileSync(r,"utf8")).packageManager!==void 0)return r},{...a&&{cwd:a}});if(!n)throw new Error("Could not find lock file");if(n.endsWith("package.json")){let e=chunkVQCWTT2B_cjs.e(n);if(e.packageManager){let r=["npm","yarn","pnpm","bun"].find(i=>e.packageManager.startsWith(i));if(r)return {packageManager:r,path:pathe.dirname(n)}}}if(n.endsWith("yarn.lock"))return {packageManager:"yarn",path:pathe.dirname(n)};if(n.endsWith("package-lock.json")||n.endsWith("npm-shrinkwrap.json"))return {packageManager:"npm",path:pathe.dirname(n)};if(n.endsWith("pnpm-lock.yaml"))return {packageManager:"pnpm",path:pathe.dirname(n)};if(n.endsWith("bun.lockb"))return {packageManager:"bun",path:pathe.dirname(n)};throw new Error("Could not find lock file")},w=a=>child_process.execSync(`${a} --version`).toString("utf8").trim(),b=async()=>{if(!process.env.npm_config_user_agent)return;let a=process.env.npm_config_user_agent.split(" ")[0],n=a.lastIndexOf("/"),e=a.slice(0,Math.max(0,n));return {name:e==="npminstall"?"cnpm":e,version:a.slice(Math.max(0,n+1))}};
9
+ var f=["yarn.lock","package-lock.json","pnpm-lock.yaml","npm-shrinkwrap.json","bun.lockb"],y=async a=>{let n=await fs.findUp(f,{type:"file",...a&&{cwd:a}});if(!n)throw new Error("Could not find lock file");return n},x=async a=>{let n=await fs.findUp(e=>{let t;if(f.forEach(i=>{!t&&fs$1.existsSync(pathe.join(e,i))&&(t=pathe.join(e,i));}),t)return t;let r=pathe.join(e,"package.json");if(fs$1.existsSync(r)&&chunk4I4DRNVT_cjs.e(fs$1.readFileSync(r,"utf8")).packageManager!==void 0)return r},{...a&&{cwd:a}});if(!n)throw new Error("Could not find lock file");if(n.endsWith("package.json")){let e=chunk4I4DRNVT_cjs.e(n);if(e.packageManager){let r=["npm","yarn","pnpm","bun"].find(i=>e.packageManager.startsWith(i));if(r)return {packageManager:r,path:pathe.dirname(n)}}}if(n.endsWith("yarn.lock"))return {packageManager:"yarn",path:pathe.dirname(n)};if(n.endsWith("package-lock.json")||n.endsWith("npm-shrinkwrap.json"))return {packageManager:"npm",path:pathe.dirname(n)};if(n.endsWith("pnpm-lock.yaml"))return {packageManager:"pnpm",path:pathe.dirname(n)};if(n.endsWith("bun.lockb"))return {packageManager:"bun",path:pathe.dirname(n)};throw new Error("Could not find lock file")},w=a=>child_process.execSync(`${a} --version`).toString("utf8").trim(),b=async()=>{if(!process.env.npm_config_user_agent)return;let a=process.env.npm_config_user_agent.split(" ")[0],n=a.lastIndexOf("/"),e=a.slice(0,Math.max(0,n));return {name:e==="npminstall"?"cnpm":e,version:a.slice(Math.max(0,n+1))}};
10
10
 
11
11
  exports.a = y;
12
12
  exports.b = x;
13
13
  exports.c = w;
14
14
  exports.d = b;
15
15
  //# sourceMappingURL=out.js.map
16
- //# sourceMappingURL=chunk-TM6ZD56C.cjs.map
16
+ //# sourceMappingURL=chunk-3IWUMNBO.cjs.map
@@ -0,0 +1,22 @@
1
+ 'use strict';
2
+
3
+ var fs$1 = require('fs');
4
+ var fs = require('@visulima/fs');
5
+ var error = require('@visulima/fs/error');
6
+ var utils = require('@visulima/fs/utils');
7
+ var n = require('normalize-package-data');
8
+ var pathe = require('pathe');
9
+
10
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
11
+
12
+ var n__default = /*#__PURE__*/_interopDefault(n);
13
+
14
+ var m=new Map,b=async(e,o={})=>{let t=await fs.findUp("package.json",{...e&&{cwd:e},type:"file"});if(!t)throw new error.NotFoundError("No such file or directory, for package.json found.");let a=o.cache&&typeof o.cache!="boolean"?o.cache:m;if(o.cache&&a.has(t))return a.get(t);let s=await fs.readJson(t);n__default.default(s);let r={packageJson:s,path:pathe.normalize(t)};return a.set(t,r),r},S=(e,o={})=>{let t=fs.findUpSync("package.json",{...e&&{cwd:e},type:"file"});if(!t)throw new error.NotFoundError("No such file or directory, for package.json found.");let a=o.cache&&typeof o.cache!="boolean"?o.cache:m;if(o.cache&&a.has(t))return a.get(t);let s=fs.readJsonSync(t);n__default.default(s);let r={packageJson:s,path:t};return a.set(t,r),r},x=async(e,o={})=>{let{cwd:t,...a}=o,s=utils.toPath(o.cwd??process.cwd());await fs.writeJson(pathe.join(s,"package.json"),e,a);},U=(e,o={})=>{let{cwd:t,...a}=o,s=utils.toPath(o.cwd??process.cwd());fs.writeJsonSync(pathe.join(s,"package.json"),e,a);},T=e=>{let o=e!==null&&typeof e=="object"&&!Array.isArray(e);if(!o&&!(typeof e=="string"))throw new TypeError("`packageFile` should be either an `object` or a `string`.");let a=o?structuredClone(e):fs$1.existsSync(e)?fs.readJsonSync(e):utils.parseJson(e);return n__default.default(a),a};
15
+
16
+ exports.a = b;
17
+ exports.b = S;
18
+ exports.c = x;
19
+ exports.d = U;
20
+ exports.e = T;
21
+ //# sourceMappingURL=out.js.map
22
+ //# sourceMappingURL=chunk-4I4DRNVT.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/package-json.ts"],"names":["existsSync","findUp","findUpSync","readJson","readJsonSync","writeJson","writeJsonSync","NotFoundError","parseJson","toPath","normalizeData","join","normalize","PackageJsonFileCache","findPackageJson","cwd","options","filePath","cache","packageJson","output","findPackageJsonSync","writePackageJson","data","writeOptions","directory","writePackageJsonSync","parsePackageJson","packageFile","isObject","json"],"mappings":"AAAA,OAAS,cAAAA,MAAkB,KAG3B,OAAS,UAAAC,EAAQ,cAAAC,EAAY,YAAAC,EAAU,gBAAAC,EAAc,aAAAC,EAAW,iBAAAC,MAAqB,eACrF,OAAS,iBAAAC,MAAqB,qBAC9B,OAAS,aAAAC,EAAW,UAAAC,MAAc,qBAElC,OAAOC,MAAmB,yBAC1B,OAAS,QAAAC,EAAM,a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,IAAI,CAAC,EAErD,MAAMX,EAAUM,EAAKc,EAAW,cAAc,EAAGF,EAAMC,CAAY,CACvE,EAEaE,EAAuB,CAAkBH,EAASP,EAAqD,CAAC,IAAY,CAC7H,GAAM,CAAE,IAAAD,EAAK,GAAGS,CAAa,EAAIR,EAC3BS,EAAYhB,EAAOO,EAAQ,KAAO,QAAQ,IAAI,CAAC,EAErDV,EAAcK,EAAKc,EAAW,cAAc,EAAGF,EAAMC,CAAY,CACrE,EAEaG,EAAoBC,GAA4D,CAEzF,IAAMC,EAAWD,IAAgB,MAAQ,OAAOA,GAAgB,UAAY,CAAC,MAAM,QAAQA,CAAW,EAGtG,GAAI,CAACC,GAAY,EAFA,OAAOD,GAAgB,UAGpC,MAAM,IAAI,UAAU,2DAA2D,EAGnF,IAAME,EAAOD,EACP,gBAAgBD,CAAW,EAE3B5B,EAAW4B,CAAqB,EAC9BxB,EAAawB,CAAqB,EAClCpB,EAAUoB,CAAqB,EAEvC,OAAAlB,EAAcoB,CAAa,EAEpBA,CACX","sourcesContent":["import { existsSync } from \"node:fs\";\n\nimport type { WriteJsonOptions } from \"@visulima/fs\";\nimport { findUp, findUpSync, readJson, readJsonSync, writeJson, writeJsonSync } from \"@visulima/fs\";\nimport { NotFoundError } from \"@visulima/fs/error\";\nimport { parseJson, toPath } from \"@visulima/fs/utils\";\nimport type { Input } from \"normalize-package-data\";\nimport normalizeData from \"normalize-package-data\";\nimport { join, normalize } from \"pathe\";\nimport type { JsonObject } from \"type-fest\";\n\nimport type { Cache, NormalizedPackageJson, PackageJson } from \"./types\";\n\ntype ReadOptions = {\n cache?: Cache<NormalizedReadResult> | boolean;\n};\n\nconst PackageJsonFileCache = new Map<string, NormalizedReadResult>();\n\nexport type NormalizedReadResult = {\n packageJson: NormalizedPackageJson;\n path: string;\n};\n\n/**\n * An asynchronous function to find the package.json file in the specified directory or its parent directories.\n *\n * @param cwd - The current working directory.\n * @returns A `Promise` that resolves to an object containing the parsed package.json data and the file path.\n * The type of the returned promise is `Promise<NormalizedReadResult>`.\n * @throws An `Error` if the package.json file cannot be found.\n */\nexport const findPackageJson = async (cwd?: URL | string, options: ReadOptions = {}): Promise<NormalizedReadResult> => {\n const filePath = await findUp(\"package.json\", {\n ...(cwd && { cwd }),\n type: \"file\",\n });\n\n if (!filePath) {\n throw new NotFoundError(\"No such file or directory, for package.json found.\");\n }\n\n const cache = options.cache && typeof options.cache !== \"boolean\" ? options.cache : PackageJsonFileCache;\n\n if (options.cache && cache.has(filePath)) {\n return cache.get(filePath) as NormalizedReadResult;\n }\n\n const packageJson = await readJson(filePath);\n\n normalizeData(packageJson as Input);\n\n const output = {\n packageJson: packageJson as NormalizedPackageJson,\n // @TODO Remove this after @visulima/fs use pathe\n path: normalize(filePath),\n };\n\n cache.set(filePath, output);\n\n return output;\n};\n\nexport const findPackageJsonSync = (cwd?: URL | string, options: ReadOptions = {}): NormalizedReadResult => {\n const filePath = findUpSync(\"package.json\", {\n ...(cwd && { cwd }),\n type: \"file\",\n });\n\n if (!filePath) {\n throw new NotFoundError(\"No such file or directory, for package.json found.\");\n }\n\n const cache = options.cache && typeof options.cache !== \"boolean\" ? options.cache : PackageJsonFileCache;\n\n if (options.cache && cache.has(filePath)) {\n return cache.get(filePath) as NormalizedReadResult;\n }\n\n const packageJson = readJsonSync(filePath);\n\n normalizeData(packageJson as Input);\n\n const output = {\n packageJson: packageJson as NormalizedPackageJson,\n path: filePath,\n };\n\n cache.set(filePath, output);\n\n return output;\n};\n\n/**\n * An asynchronous function to write the package.json file with the given data.\n *\n * @param data - The package.json data to write. The data is an intersection type of `PackageJson` and a record where keys are `string` and values can be any type.\n * @param options - Optional. The options for writing the package.json. If not provided, an empty object will be used `{}`.\n * This is an intersection type of `WriteJsonOptions` and a record with an optional `cwd` key which type is `Options[\"cwd\"]`.\n * `cwd` represents the current working directory. If not specified, the default working directory will be used.\n * @returns A `Promise` that resolves once the package.json file has been written. The type of the returned promise is `Promise<void>`.\n */\n\nexport const writePackageJson = async <T = PackageJson>(data: T, options: WriteJsonOptions & { cwd?: URL | string } = {}): Promise<void> => {\n const { cwd, ...writeOptions } = options;\n const directory = toPath(options.cwd ?? process.cwd());\n\n await writeJson(join(directory, \"package.json\"), data, writeOptions);\n};\n\nexport const writePackageJsonSync = <T = PackageJson>(data: T, options: WriteJsonOptions & { cwd?: URL | string } = {}): void => {\n const { cwd, ...writeOptions } = options;\n const directory = toPath(options.cwd ?? process.cwd());\n\n writeJsonSync(join(directory, \"package.json\"), data, writeOptions);\n};\n\nexport const parsePackageJson = (packageFile: JsonObject | string): NormalizedPackageJson => {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n const isObject = packageFile !== null && typeof packageFile === \"object\" && !Array.isArray(packageFile);\n const isString = typeof packageFile === \"string\";\n\n if (!isObject && !isString) {\n throw new TypeError(\"`packageFile` should be either an `object` or a `string`.\");\n }\n\n const json = isObject\n ? structuredClone(packageFile)\n : // eslint-disable-next-line security/detect-non-literal-fs-filename\n existsSync(packageFile as string)\n ? readJsonSync(packageFile as string)\n : parseJson(packageFile as string);\n\n normalizeData(json as Input);\n\n return json as NormalizedPackageJson;\n};\n"]}
@@ -1,4 +1,4 @@
1
- import { e } from './chunk-TUN46UZB.js';
1
+ import { e } from './chunk-GA54FVOU.js';
2
2
  import { execSync } from 'node:child_process';
3
3
  import { existsSync, readFileSync } from 'node:fs';
4
4
  import { findUp } from '@visulima/fs';
@@ -8,4 +8,4 @@ var f=["yarn.lock","package-lock.json","pnpm-lock.yaml","npm-shrinkwrap.json","b
8
8
 
9
9
  export { x as a, w as b, b as c, j as d };
10
10
  //# sourceMappingURL=out.js.map
11
- //# sourceMappingURL=chunk-5ZQIFU6S.js.map
11
+ //# sourceMappingURL=chunk-6KVF4I2Q.js.map
@@ -0,0 +1,12 @@
1
+ import { existsSync } from 'node:fs';
2
+ import { findUp, readJson, findUpSync, readJsonSync, writeJson, writeJsonSync } from '@visulima/fs';
3
+ import { NotFoundError } from '@visulima/fs/error';
4
+ import { toPath, parseJson } from '@visulima/fs/utils';
5
+ import n from 'normalize-package-data';
6
+ import { normalize, join } from 'pathe';
7
+
8
+ var m=new Map,S=async(e,o={})=>{let t=await findUp("package.json",{...e&&{cwd:e},type:"file"});if(!t)throw new NotFoundError("No such file or directory, for package.json found.");let a=o.cache&&typeof o.cache!="boolean"?o.cache:m;if(o.cache&&a.has(t))return a.get(t);let s=await readJson(t);n(s);let r={packageJson:s,path:normalize(t)};return a.set(t,r),r},x=(e,o={})=>{let t=findUpSync("package.json",{...e&&{cwd:e},type:"file"});if(!t)throw new NotFoundError("No such file or directory, for package.json found.");let a=o.cache&&typeof o.cache!="boolean"?o.cache:m;if(o.cache&&a.has(t))return a.get(t);let s=readJsonSync(t);n(s);let r={packageJson:s,path:t};return a.set(t,r),r},U=async(e,o={})=>{let{cwd:t,...a}=o,s=toPath(o.cwd??process.cwd());await writeJson(join(s,"package.json"),e,a);},T=(e,o={})=>{let{cwd:t,...a}=o,s=toPath(o.cwd??process.cwd());writeJsonSync(join(s,"package.json"),e,a);},C=e=>{let o=e!==null&&typeof e=="object"&&!Array.isArray(e);if(!o&&!(typeof e=="string"))throw new TypeError("`packageFile` should be either an `object` or a `string`.");let a=o?structuredClone(e):existsSync(e)?readJsonSync(e):parseJson(e);return n(a),a};
9
+
10
+ export { S as a, x as b, U as c, T as d, C as e };
11
+ //# sourceMappingURL=out.js.map
12
+ //# sourceMappingURL=chunk-GA54FVOU.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/package-json.ts"],"names":["existsSync","findUp","findUpSync","readJson","readJsonSync","writeJson","writeJsonSync","NotFoundError","parseJson","toPath","normalizeData","join","normalize","PackageJsonFileCache","findPackageJson","cwd","options","filePath","cache","packageJson","output","findPackageJsonSync","writePackageJson","data","writeOptions","directory","writePackageJsonSync","parsePackageJson","packageFile","isObject","json"],"mappings":"AAAA,OAAS,cAAAA,MAAkB,UAG3B,OAAS,UAAAC,EAAQ,cAAAC,EAAY,YAAAC,EA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UG,CAAM,EAEnBA,CACX,EAYaE,EAAmB,MAAwBC,EAASP,EAAqD,CAAC,IAAqB,CACxI,GAAM,CAAE,IAAAD,EAAK,GAAGS,CAAa,EAAIR,EAC3BS,EAAYhB,EAAOO,EAAQ,KAAO,QAAQ,IAAI,CAAC,EAErD,MAAMX,EAAUM,EAAKc,EAAW,cAAc,EAAGF,EAAMC,CAAY,CACvE,EAEaE,EAAuB,CAAkBH,EAASP,EAAqD,CAAC,IAAY,CAC7H,GAAM,CAAE,IAAAD,EAAK,GAAGS,CAAa,EAAIR,EAC3BS,EAAYhB,EAAOO,EAAQ,KAAO,QAAQ,IAAI,CAAC,EAErDV,EAAcK,EAAKc,EAAW,cAAc,EAAGF,EAAMC,CAAY,CACrE,EAEaG,EAAoBC,GAA4D,CAEzF,IAAMC,EAAWD,IAAgB,MAAQ,OAAOA,GAAgB,UAAY,CAAC,MAAM,QAAQA,CAAW,EAGtG,GAAI,CAACC,GAAY,EAFA,OAAOD,GAAgB,UAGpC,MAAM,IAAI,UAAU,2DAA2D,EAGnF,IAAME,EAAOD,EACP,gBAAgBD,CAAW,EAE3B5B,EAAW4B,CAAqB,EAC9BxB,EAAawB,CAAqB,EAClCpB,EAAUoB,CAAqB,EAEvC,OAAAlB,EAAcoB,CAAa,EAEpBA,CACX","sourcesContent":["import { existsSync } from \"node:fs\";\n\nimport type { WriteJsonOptions } from \"@visulima/fs\";\nimport { findUp, findUpSync, readJson, readJsonSync, writeJson, writeJsonSync } from \"@visulima/fs\";\nimport { NotFoundError } from \"@visulima/fs/error\";\nimport { parseJson, toPath } from \"@visulima/fs/utils\";\nimport type { Input } from \"normalize-package-data\";\nimport normalizeData from \"normalize-package-data\";\nimport { join, normalize } from \"pathe\";\nimport type { JsonObject } from \"type-fest\";\n\nimport type { Cache, NormalizedPackageJson, PackageJson } from \"./types\";\n\ntype ReadOptions = {\n cache?: Cache<NormalizedReadResult> | boolean;\n};\n\nconst PackageJsonFileCache = new Map<string, NormalizedReadResult>();\n\nexport type NormalizedReadResult = {\n packageJson: NormalizedPackageJson;\n path: string;\n};\n\n/**\n * An asynchronous function to find the package.json file in the specified directory or its parent directories.\n *\n * @param cwd - The current working directory.\n * @returns A `Promise` that resolves to an object containing the parsed package.json data and the file path.\n * The type of the returned promise is `Promise<NormalizedReadResult>`.\n * @throws An `Error` if the package.json file cannot be found.\n */\nexport const findPackageJson = async (cwd?: URL | string, options: ReadOptions = {}): Promise<NormalizedReadResult> => {\n const filePath = await findUp(\"package.json\", {\n ...(cwd && { cwd }),\n type: \"file\",\n });\n\n if (!filePath) {\n throw new NotFoundError(\"No such file or directory, for package.json found.\");\n }\n\n const cache = options.cache && typeof options.cache !== \"boolean\" ? options.cache : PackageJsonFileCache;\n\n if (options.cache && cache.has(filePath)) {\n return cache.get(filePath) as NormalizedReadResult;\n }\n\n const packageJson = await readJson(filePath);\n\n normalizeData(packageJson as Input);\n\n const output = {\n packageJson: packageJson as NormalizedPackageJson,\n // @TODO Remove this after @visulima/fs use pathe\n path: normalize(filePath),\n };\n\n cache.set(filePath, output);\n\n return output;\n};\n\nexport const findPackageJsonSync = (cwd?: URL | string, options: ReadOptions = {}): NormalizedReadResult => {\n const filePath = findUpSync(\"package.json\", {\n ...(cwd && { cwd }),\n type: \"file\",\n });\n\n if (!filePath) {\n throw new NotFoundError(\"No such file or directory, for package.json found.\");\n }\n\n const cache = options.cache && typeof options.cache !== \"boolean\" ? options.cache : PackageJsonFileCache;\n\n if (options.cache && cache.has(filePath)) {\n return cache.get(filePath) as NormalizedReadResult;\n }\n\n const packageJson = readJsonSync(filePath);\n\n normalizeData(packageJson as Input);\n\n const output = {\n packageJson: packageJson as NormalizedPackageJson,\n path: filePath,\n };\n\n cache.set(filePath, output);\n\n return output;\n};\n\n/**\n * An asynchronous function to write the package.json file with the given data.\n *\n * @param data - The package.json data to write. The data is an intersection type of `PackageJson` and a record where keys are `string` and values can be any type.\n * @param options - Optional. The options for writing the package.json. If not provided, an empty object will be used `{}`.\n * This is an intersection type of `WriteJsonOptions` and a record with an optional `cwd` key which type is `Options[\"cwd\"]`.\n * `cwd` represents the current working directory. If not specified, the default working directory will be used.\n * @returns A `Promise` that resolves once the package.json file has been written. The type of the returned promise is `Promise<void>`.\n */\n\nexport const writePackageJson = async <T = PackageJson>(data: T, options: WriteJsonOptions & { cwd?: URL | string } = {}): Promise<void> => {\n const { cwd, ...writeOptions } = options;\n const directory = toPath(options.cwd ?? process.cwd());\n\n await writeJson(join(directory, \"package.json\"), data, writeOptions);\n};\n\nexport const writePackageJsonSync = <T = PackageJson>(data: T, options: WriteJsonOptions & { cwd?: URL | string } = {}): void => {\n const { cwd, ...writeOptions } = options;\n const directory = toPath(options.cwd ?? process.cwd());\n\n writeJsonSync(join(directory, \"package.json\"), data, writeOptions);\n};\n\nexport const parsePackageJson = (packageFile: JsonObject | string): NormalizedPackageJson => {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n const isObject = packageFile !== null && typeof packageFile === \"object\" && !Array.isArray(packageFile);\n const isString = typeof packageFile === \"string\";\n\n if (!isObject && !isString) {\n throw new TypeError(\"`packageFile` should be either an `object` or a `string`.\");\n }\n\n const json = isObject\n ? structuredClone(packageFile)\n : // eslint-disable-next-line security/detect-non-literal-fs-filename\n existsSync(packageFile as string)\n ? readJsonSync(packageFile as string)\n : parseJson(packageFile as string);\n\n normalizeData(json as Input);\n\n return json as NormalizedPackageJson;\n};\n"]}
@@ -1,11 +1,11 @@
1
1
  'use strict';
2
2
 
3
- var chunkTM6ZD56C_cjs = require('./chunk-TM6ZD56C.cjs');
3
+ var chunk3IWUMNBO_cjs = require('./chunk-3IWUMNBO.cjs');
4
4
  var fs = require('@visulima/fs');
5
5
  var pathe = require('pathe');
6
6
 
7
- var m=async t=>{try{let a=await chunkTM6ZD56C_cjs.a(t);return pathe.dirname(a)}catch{}let o=await fs.findUp(".git/config",{...t&&{cwd:t},type:"file"});if(o)return pathe.dirname(pathe.dirname(o));let r=await fs.findUp("package.json",{...t&&{cwd:t},type:"file"});if(r)return pathe.dirname(r);throw new Error("Could not find root directory")};
7
+ var m=async t=>{try{let a=await chunk3IWUMNBO_cjs.a(t);return pathe.dirname(a)}catch{}let o=await fs.findUp(".git/config",{...t&&{cwd:t},type:"file"});if(o)return pathe.dirname(pathe.dirname(o));let r=await fs.findUp("package.json",{...t&&{cwd:t},type:"file"});if(r)return pathe.dirname(r);throw new Error("Could not find root directory")};
8
8
 
9
9
  exports.a = m;
10
10
  //# sourceMappingURL=out.js.map
11
- //# sourceMappingURL=chunk-VAMRQCZW.cjs.map
11
+ //# sourceMappingURL=chunk-GAZI4NM6.cjs.map
@@ -1,4 +1,4 @@
1
- import { a } from './chunk-5ZQIFU6S.js';
1
+ import { a } from './chunk-6KVF4I2Q.js';
2
2
  import { findUp } from '@visulima/fs';
3
3
  import { dirname } from 'pathe';
4
4
 
@@ -6,4 +6,4 @@ var p=async t=>{try{let a$1=await a(t);return dirname(a$1)}catch{}let o=await fi
6
6
 
7
7
  export { p as a };
8
8
  //# sourceMappingURL=out.js.map
9
- //# sourceMappingURL=chunk-G767QS5X.js.map
9
+ //# sourceMappingURL=chunk-M4MWM246.js.map
@@ -1,4 +1,4 @@
1
- import { b } from './chunk-5ZQIFU6S.js';
1
+ import { b } from './chunk-6KVF4I2Q.js';
2
2
  import { existsSync, readFileSync } from 'node:fs';
3
3
  import { findUp, readJson } from '@visulima/fs';
4
4
  import { dirname, join } from 'pathe';
@@ -7,4 +7,4 @@ var j=async e=>{let n=await findUp(["lerna.json","turbo.json"],{type:"file",...e
7
7
 
8
8
  export { j as a };
9
9
  //# sourceMappingURL=out.js.map
10
- //# sourceMappingURL=chunk-XKKPPOYW.js.map
10
+ //# sourceMappingURL=chunk-PUY4M2BR.js.map
@@ -0,0 +1,15 @@
1
+ import { findUp, findUpSync, writeJson, readFileSync } from '@visulima/fs';
2
+ import { NotFoundError } from '@visulima/fs/error';
3
+ import { toPath } from '@visulima/fs/utils';
4
+ import { join, dirname, resolve, relative, normalize, toNamespacedPath } from 'pathe';
5
+ import { realpathSync, existsSync, statSync } from 'node:fs';
6
+ import { parse } from 'jsonc-parser';
7
+ import A from 'node:module';
8
+ import { join as join$1, resolve as resolve$1, isAbsolute } from 'node:path';
9
+ import { resolveExports } from 'resolve-pkg-maps';
10
+
11
+ var _=s=>parse(readFileSync(s)),L=()=>{let{findPnpApi:s}=A;return s?.(process.cwd())},v=(s,o,l,n)=>{let t=`resolveFromPackageJsonPath:${s}:${o}:${l}`;if(n?.has(t))return n.get(t);let i=_(s);if(!i)return;let e=o||"tsconfig.json";if(!l&&i.exports)try{let[a]=resolveExports(i.exports,o,["require","types"]);e=a;}catch{return !1}else !o&&i.tsconfig&&(e=i.tsconfig);return e=join$1(s,"..",e),n?.set(t,e),e},P="package.json",T="tsconfig.json",G=(s,o,l)=>{let n=s;if(s===".."&&(n=join$1(n,T)),s.startsWith(".")&&(n=resolve$1(o,n)),isAbsolute(n)){if(existsSync(n)){if(statSync(n).isFile())return n}else if(!n.endsWith(".json")){let c=`${n}.json`;if(existsSync(c))return c}return}let[t,...i]=s.split("/"),e=t.startsWith("@")?`${t}/${i.shift()}`:t,a=i.join("/"),r=L();if(r){let{resolveRequest:c}=r;try{if(e===s){let p=c(join$1(e,P),o);if(p){let h=v(p,a,!1,l);if(h&&existsSync(h))return h}}else {let p;try{p=c(s,o,{extensions:[".json"]});}catch{p=c(join$1(s,T),o);}if(p)return p}}catch{}}let f=findUpSync(c=>{let p=join$1(c,"node_modules",e);if(existsSync(p))return join$1("node_modules",e)},{cwd:o,type:"directory"});if(!f||!statSync(f).isDirectory())return;let g=join$1(f,P);if(existsSync(g)){let c=v(g,a,!1,l);if(c===!1)return;if(c&&existsSync(c)&&statSync(c).isFile())return c}let m=join$1(f,a),C=m.endsWith(".json");if(!C){let c=`${m}.json`;if(existsSync(c))return c}if(existsSync(m)){if(statSync(m).isDirectory()){let c=join$1(m,P);if(existsSync(c)){let h=v(c,"",!0,l);if(h&&existsSync(h))return h}let p=join$1(m,T);if(existsSync(p))return p}else if(C)return m}},F=G;var Z=Symbol("implicitBaseUrl"),q=s=>parse(readFileSync(s)),O=s=>toNamespacedPath(/^\.{1,2}(?:\/.*)?$/.test(s)?s:`./${s}`),ee=(s,o,l,n)=>{let t=F(s,o);if(!t)throw new NotFoundError(`No such file or directory, for '${s}' found.`);if(l.has(t))throw new Error(`Circularity detected while resolving configuration: ${t}`);l.add(t);let i=dirname(t),e=I(t,n,l);delete e.references;let{compilerOptions:a}=e;if(a){let r=["baseUrl","outDir"];for(let f of r){let g=a[f];g&&(a[f]=relative(o,join(i,g)).replaceAll("\\","/")||"./");}}return e.files&&(e.files=e.files.map(r=>relative(o,join(i,r)))),e.include&&(e.include=e.include.map(r=>relative(o,join(i,r)))),e.exclude&&(e.exclude=e.exclude.map(r=>relative(o,join(i,r)))),e},I=(s,o,l=new Set)=>{let n;try{n=realpathSync(s);}catch{throw new Error(`Cannot resolve tsconfig at path: ${s}`)}let t=q(n)||{};if(typeof t!="object")throw new SyntaxError(`Failed to parse tsconfig at: ${s}`);let i=dirname(n);if(t.compilerOptions){let{compilerOptions:e}=t;e.paths&&!e.baseUrl&&(e[Z]=i);}if(t.extends){let e=Array.isArray(t.extends)?t.extends:[t.extends];delete t.extends;for(let a of e.reverse()){let r=ee(a,i,new Set(l),o),f={...r,...t,compilerOptions:{...r.compilerOptions,...t.compilerOptions}};r.watchOptions&&(f.watchOptions={...r.watchOptions,...t.watchOptions}),t=f;}}if(t.compilerOptions){let{compilerOptions:e}=t,a=["baseUrl","rootDir"];for(let f of a){let g=e[f];if(g){let m=resolve(i,g),C=relative(i,m);e[f]=O(C);}}let{outDir:r}=e;r&&(Array.isArray(t.exclude)||(t.exclude=[]),t.exclude.includes(r)||t.exclude.push(r),e.outDir=O(r)),o?.tscCompatible&&e.module==="node16"&&(e.allowSyntheticDefaultImports=e.allowSyntheticDefaultImports??!0,e.esModuleInterop=e.esModuleInterop??!0,e.moduleDetection=e.moduleDetection??"force",e.moduleResolution=e.moduleResolution??"node16",e.target=e.target??"es2022",e.useDefineForClassFields=e.useDefineForClassFields??!0),o?.tscCompatible&&e.strict&&(e.noImplicitAny=e.noImplicitAny??!0,e.noImplicitThis=e.noImplicitThis??!0,e.strictNullChecks=e.strictNullChecks??!0,e.strictFunctionTypes=e.strictFunctionTypes??!0,e.strictBindCallApply=e.strictBindCallApply??!0,e.strictPropertyInitialization=e.strictPropertyInitialization??!0,e.alwaysStrict=e.alwaysStrict??!0,e.useUnknownInCatchVariables=e.useUnknownInCatchVariables??!0),o?.tscCompatible&&e.isolatedModules&&(e.preserveConstEnums=e.preserveConstEnums??!0),o?.tscCompatible&&e.esModuleInterop&&(e.allowSyntheticDefaultImports=e.allowSyntheticDefaultImports??!0),o?.tscCompatible&&e.target==="esnext"&&(e.useDefineForClassFields=e.useDefineForClassFields??!0);}else t.compilerOptions={};if(t.files&&(t.files=t.files.map(e=>O(e))),t.include&&(t.include=t.include.map(e=>normalize(e))),t.watchOptions){let{watchOptions:e}=t;e.excludeDirectories&&(e.excludeDirectories=e.excludeDirectories.map(a=>resolve(i,a)));}return t},te=(s,o)=>I(s,o),J=te;var D=new Map,ie=async(s,o={})=>{let l=o.configFileName??"tsconfig.json",n=await findUp(l,{...s&&{cwd:s},type:"file"});if(n||(n=await findUp("jsconfig.json",{...s&&{cwd:s},type:"file"})),!n)throw new NotFoundError(`No such file or directory, for ${l} or jsconfig.json found.`);let t=o.cache&&typeof o.cache!="boolean"?o.cache:D;if(o.cache&&t.has(n))return t.get(n);let i={config:J(n),path:n};return o.cache&&t.set(n,i),i},be=ie,re=(s,o={})=>{let l=o.configFileName??"tsconfig.json",n=findUpSync(l,{...s&&{cwd:s},type:"file"});if(n||(n=findUpSync("jsconfig.json",{...s&&{cwd:s},type:"file"})),!n)throw new NotFoundError(`No such file or directory, for ${l} or jsconfig.json found.`);let t=o.cache&&typeof o.cache!="boolean"?o.cache:D;if(o.cache&&t.has(n))return t.get(n);let i={config:J(n),path:n};return o.cache&&t.set(n,i),i},ke=re,ce=async(s,o={})=>{let{cwd:l,...n}=o,t=toPath(o.cwd??process.cwd());await writeJson(join(t,"tsconfig.json"),s,n);},Ie=ce;
12
+
13
+ export { J as a, ie as b, be as c, re as d, ke as e, ce as f, Ie as g };
14
+ //# sourceMappingURL=out.js.map
15
+ //# sourceMappingURL=chunk-QPR3SJGT.js.map
@@ -0,0 +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,UAE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Q,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((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 cwd: directoryPath,\n type: \"directory\"\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"]}
@@ -0,0 +1,27 @@
1
+ 'use strict';
2
+
3
+ var fs = require('@visulima/fs');
4
+ var error = require('@visulima/fs/error');
5
+ var utils = require('@visulima/fs/utils');
6
+ var pathe = require('pathe');
7
+ var fs$1 = require('fs');
8
+ var jsoncParser = require('jsonc-parser');
9
+ var D = require('module');
10
+ var path = require('path');
11
+ var resolvePkgMaps = require('resolve-pkg-maps');
12
+
13
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
14
+
15
+ var D__default = /*#__PURE__*/_interopDefault(D);
16
+
17
+ var z=s=>jsoncParser.parse(fs.readFileSync(s)),_=()=>{let{findPnpApi:s}=D__default.default;return s?.(process.cwd())},v=(s,o,l,n)=>{let t=`resolveFromPackageJsonPath:${s}:${o}:${l}`;if(n?.has(t))return n.get(t);let i=z(s);if(!i)return;let e=o||"tsconfig.json";if(!l&&i.exports)try{let[a]=resolvePkgMaps.resolveExports(i.exports,o,["require","types"]);e=a;}catch{return !1}else !o&&i.tsconfig&&(e=i.tsconfig);return e=path.join(s,"..",e),n?.set(t,e),e},P="package.json",T="tsconfig.json",L=(s,o,l)=>{let n=s;if(s===".."&&(n=path.join(n,T)),s.startsWith(".")&&(n=path.resolve(o,n)),path.isAbsolute(n)){if(fs$1.existsSync(n)){if(fs$1.statSync(n).isFile())return n}else if(!n.endsWith(".json")){let c=`${n}.json`;if(fs$1.existsSync(c))return c}return}let[t,...i]=s.split("/"),e=t.startsWith("@")?`${t}/${i.shift()}`:t,a=i.join("/"),r=_();if(r){let{resolveRequest:c}=r;try{if(e===s){let p=c(path.join(e,P),o);if(p){let h=v(p,a,!1,l);if(h&&fs$1.existsSync(h))return h}}else {let p;try{p=c(s,o,{extensions:[".json"]});}catch{p=c(path.join(s,T),o);}if(p)return p}}catch{}}let f=fs.findUpSync(c=>{let p=path.join(c,"node_modules",e);if(fs$1.existsSync(p))return path.join("node_modules",e)},{cwd:o,type:"directory"});if(!f||!fs$1.statSync(f).isDirectory())return;let g=path.join(f,P);if(fs$1.existsSync(g)){let c=v(g,a,!1,l);if(c===!1)return;if(c&&fs$1.existsSync(c)&&fs$1.statSync(c).isFile())return c}let m=path.join(f,a),C=m.endsWith(".json");if(!C){let c=`${m}.json`;if(fs$1.existsSync(c))return c}if(fs$1.existsSync(m)){if(fs$1.statSync(m).isDirectory()){let c=path.join(m,P);if(fs$1.existsSync(c)){let h=v(c,"",!0,l);if(h&&fs$1.existsSync(h))return h}let p=path.join(m,T);if(fs$1.existsSync(p))return p}else if(C)return m}},j=L;var Y=Symbol("implicitBaseUrl"),Z=s=>jsoncParser.parse(fs.readFileSync(s)),O=s=>pathe.toNamespacedPath(/^\.{1,2}(?:\/.*)?$/.test(s)?s:`./${s}`),q=(s,o,l,n)=>{let t=j(s,o);if(!t)throw new error.NotFoundError(`No such file or directory, for '${s}' found.`);if(l.has(t))throw new Error(`Circularity detected while resolving configuration: ${t}`);l.add(t);let i=pathe.dirname(t),e=k(t,n,l);delete e.references;let{compilerOptions:a}=e;if(a){let r=["baseUrl","outDir"];for(let f of r){let g=a[f];g&&(a[f]=pathe.relative(o,pathe.join(i,g)).replaceAll("\\","/")||"./");}}return e.files&&(e.files=e.files.map(r=>pathe.relative(o,pathe.join(i,r)))),e.include&&(e.include=e.include.map(r=>pathe.relative(o,pathe.join(i,r)))),e.exclude&&(e.exclude=e.exclude.map(r=>pathe.relative(o,pathe.join(i,r)))),e},k=(s,o,l=new Set)=>{let n;try{n=fs$1.realpathSync(s);}catch{throw new Error(`Cannot resolve tsconfig at path: ${s}`)}let t=Z(n)||{};if(typeof t!="object")throw new SyntaxError(`Failed to parse tsconfig at: ${s}`);let i=pathe.dirname(n);if(t.compilerOptions){let{compilerOptions:e}=t;e.paths&&!e.baseUrl&&(e[Y]=i);}if(t.extends){let e=Array.isArray(t.extends)?t.extends:[t.extends];delete t.extends;for(let a of e.reverse()){let r=q(a,i,new Set(l),o),f={...r,...t,compilerOptions:{...r.compilerOptions,...t.compilerOptions}};r.watchOptions&&(f.watchOptions={...r.watchOptions,...t.watchOptions}),t=f;}}if(t.compilerOptions){let{compilerOptions:e}=t,a=["baseUrl","rootDir"];for(let f of a){let g=e[f];if(g){let m=pathe.resolve(i,g),C=pathe.relative(i,m);e[f]=O(C);}}let{outDir:r}=e;r&&(Array.isArray(t.exclude)||(t.exclude=[]),t.exclude.includes(r)||t.exclude.push(r),e.outDir=O(r)),o?.tscCompatible&&e.module==="node16"&&(e.allowSyntheticDefaultImports=e.allowSyntheticDefaultImports??!0,e.esModuleInterop=e.esModuleInterop??!0,e.moduleDetection=e.moduleDetection??"force",e.moduleResolution=e.moduleResolution??"node16",e.target=e.target??"es2022",e.useDefineForClassFields=e.useDefineForClassFields??!0),o?.tscCompatible&&e.strict&&(e.noImplicitAny=e.noImplicitAny??!0,e.noImplicitThis=e.noImplicitThis??!0,e.strictNullChecks=e.strictNullChecks??!0,e.strictFunctionTypes=e.strictFunctionTypes??!0,e.strictBindCallApply=e.strictBindCallApply??!0,e.strictPropertyInitialization=e.strictPropertyInitialization??!0,e.alwaysStrict=e.alwaysStrict??!0,e.useUnknownInCatchVariables=e.useUnknownInCatchVariables??!0),o?.tscCompatible&&e.isolatedModules&&(e.preserveConstEnums=e.preserveConstEnums??!0),o?.tscCompatible&&e.esModuleInterop&&(e.allowSyntheticDefaultImports=e.allowSyntheticDefaultImports??!0),o?.tscCompatible&&e.target==="esnext"&&(e.useDefineForClassFields=e.useDefineForClassFields??!0);}else t.compilerOptions={};if(t.files&&(t.files=t.files.map(e=>O(e))),t.include&&(t.include=t.include.map(e=>pathe.normalize(e))),t.watchOptions){let{watchOptions:e}=t;e.excludeDirectories&&(e.excludeDirectories=e.excludeDirectories.map(a=>pathe.resolve(i,a)));}return t},ee=(s,o)=>k(s,o),J=ee;var U=new Map,ne=async(s,o={})=>{let l=o.configFileName??"tsconfig.json",n=await fs.findUp(l,{...s&&{cwd:s},type:"file"});if(n||(n=await fs.findUp("jsconfig.json",{...s&&{cwd:s},type:"file"})),!n)throw new error.NotFoundError(`No such file or directory, for ${l} or jsconfig.json found.`);let t=o.cache&&typeof o.cache!="boolean"?o.cache:U;if(o.cache&&t.has(n))return t.get(n);let i={config:J(n),path:n};return o.cache&&t.set(n,i),i},Fe=ne,ie=(s,o={})=>{let l=o.configFileName??"tsconfig.json",n=fs.findUpSync(l,{...s&&{cwd:s},type:"file"});if(n||(n=fs.findUpSync("jsconfig.json",{...s&&{cwd:s},type:"file"})),!n)throw new error.NotFoundError(`No such file or directory, for ${l} or jsconfig.json found.`);let t=o.cache&&typeof o.cache!="boolean"?o.cache:U;if(o.cache&&t.has(n))return t.get(n);let i={config:J(n),path:n};return o.cache&&t.set(n,i),i},be=ie,re=async(s,o={})=>{let{cwd:l,...n}=o,t=utils.toPath(o.cwd??process.cwd());await fs.writeJson(pathe.join(t,"tsconfig.json"),s,n);},ke=re;
18
+
19
+ exports.a = J;
20
+ exports.b = ne;
21
+ exports.c = Fe;
22
+ exports.d = ie;
23
+ exports.e = be;
24
+ exports.f = re;
25
+ exports.g = ke;
26
+ //# sourceMappingURL=out.js.map
27
+ //# sourceMappingURL=chunk-WL2BRLJZ.cjs.map
@@ -0,0 +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,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,EAAY,YAAAC,MAAgB,KACrC,OAAOC,MAAY,SACnB,OAAS,cAAAC,EAAY,QAAAZ,EAAM,WAAAO,MAAe,OAE1C,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,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AEA,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((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 cwd: directoryPath,\n type: \"directory\"\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,12 +1,12 @@
1
1
  'use strict';
2
2
 
3
- var chunkTM6ZD56C_cjs = require('./chunk-TM6ZD56C.cjs');
3
+ var chunk3IWUMNBO_cjs = require('./chunk-3IWUMNBO.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 b=async e=>{let n=await fs.findUp(["lerna.json","turbo.json"],{type:"file",...e&&{cwd:e}});if(n?.endsWith("lerna.json")){let o=await fs.readJson(n);if(o.useWorkspaces||o.packages)return {path:pathe.dirname(n),strategy:"lerna"}}let s=n?.endsWith("turbo.json");try{let{packageManager:o,path:r}=await chunkTM6ZD56C_cjs.b(e);if(["npm","yarn"].includes(o)){let a=pathe.join(r,"package.json");if(fs$1.existsSync(a)&&fs$1.readFileSync(pathe.join(r,"package.json"),"utf8").includes("workspaces"))return {path:r,strategy:s?"turbo":o}}else if(o==="pnpm"){let a=pathe.join(r,"pnpm-workspace.yaml");if(fs$1.existsSync(a))return {path:r,strategy:s?"turbo":"pnpm"}}}catch(o){if(!o.message.includes("Could not find lock file"))throw o}throw new Error(`No monorepo root could be found upwards from the directory ${e} using lerna, yarn, pnpm, or npm as indicators.`)};
8
+ var b=async e=>{let n=await fs.findUp(["lerna.json","turbo.json"],{type:"file",...e&&{cwd:e}});if(n?.endsWith("lerna.json")){let o=await fs.readJson(n);if(o.useWorkspaces||o.packages)return {path:pathe.dirname(n),strategy:"lerna"}}let s=n?.endsWith("turbo.json");try{let{packageManager:o,path:r}=await chunk3IWUMNBO_cjs.b(e);if(["npm","yarn"].includes(o)){let a=pathe.join(r,"package.json");if(fs$1.existsSync(a)&&fs$1.readFileSync(pathe.join(r,"package.json"),"utf8").includes("workspaces"))return {path:r,strategy:s?"turbo":o}}else if(o==="pnpm"){let a=pathe.join(r,"pnpm-workspace.yaml");if(fs$1.existsSync(a))return {path:r,strategy:s?"turbo":"pnpm"}}}catch(o){if(!o.message.includes("Could not find lock file"))throw o}throw new Error(`No monorepo root could be found upwards from the directory ${e} using lerna, yarn, pnpm, or npm as indicators.`)};
9
9
 
10
10
  exports.a = b;
11
11
  //# sourceMappingURL=out.js.map
12
- //# sourceMappingURL=chunk-L6J2NRQY.cjs.map
12
+ //# sourceMappingURL=chunk-XMGJIRS7.cjs.map
package/dist/index.cjs CHANGED
@@ -1,80 +1,80 @@
1
1
  'use strict';
2
2
 
3
- var chunkL6J2NRQY_cjs = require('./chunk-L6J2NRQY.cjs');
4
- var chunkVAMRQCZW_cjs = require('./chunk-VAMRQCZW.cjs');
5
- var chunkTM6ZD56C_cjs = require('./chunk-TM6ZD56C.cjs');
6
- var chunkVQCWTT2B_cjs = require('./chunk-VQCWTT2B.cjs');
7
- var chunkBGBPBHAL_cjs = require('./chunk-BGBPBHAL.cjs');
3
+ var chunkXMGJIRS7_cjs = require('./chunk-XMGJIRS7.cjs');
4
+ var chunkGAZI4NM6_cjs = require('./chunk-GAZI4NM6.cjs');
5
+ var chunk3IWUMNBO_cjs = require('./chunk-3IWUMNBO.cjs');
6
+ var chunk4I4DRNVT_cjs = require('./chunk-4I4DRNVT.cjs');
7
+ var chunkWL2BRLJZ_cjs = require('./chunk-WL2BRLJZ.cjs');
8
8
 
9
9
 
10
10
 
11
11
  Object.defineProperty(exports, 'findMonorepoRoot', {
12
12
  enumerable: true,
13
- get: function () { return chunkL6J2NRQY_cjs.a; }
13
+ get: function () { return chunkXMGJIRS7_cjs.a; }
14
14
  });
15
15
  Object.defineProperty(exports, 'findPackageRoot', {
16
16
  enumerable: true,
17
- get: function () { return chunkVAMRQCZW_cjs.a; }
17
+ get: function () { return chunkGAZI4NM6_cjs.a; }
18
18
  });
19
19
  Object.defineProperty(exports, 'findLockFile', {
20
20
  enumerable: true,
21
- get: function () { return chunkTM6ZD56C_cjs.a; }
21
+ get: function () { return chunk3IWUMNBO_cjs.a; }
22
22
  });
23
23
  Object.defineProperty(exports, 'findPackageManager', {
24
24
  enumerable: true,
25
- get: function () { return chunkTM6ZD56C_cjs.b; }
25
+ get: function () { return chunk3IWUMNBO_cjs.b; }
26
26
  });
27
27
  Object.defineProperty(exports, 'getPackageManagerVersion', {
28
28
  enumerable: true,
29
- get: function () { return chunkTM6ZD56C_cjs.c; }
29
+ get: function () { return chunk3IWUMNBO_cjs.c; }
30
30
  });
31
31
  Object.defineProperty(exports, 'identifyInitiatingPackageManager', {
32
32
  enumerable: true,
33
- get: function () { return chunkTM6ZD56C_cjs.d; }
33
+ get: function () { return chunk3IWUMNBO_cjs.d; }
34
34
  });
35
35
  Object.defineProperty(exports, 'findPackageJson', {
36
36
  enumerable: true,
37
- get: function () { return chunkVQCWTT2B_cjs.a; }
37
+ get: function () { return chunk4I4DRNVT_cjs.a; }
38
38
  });
39
39
  Object.defineProperty(exports, 'findPackageJsonSync', {
40
40
  enumerable: true,
41
- get: function () { return chunkVQCWTT2B_cjs.b; }
41
+ get: function () { return chunk4I4DRNVT_cjs.b; }
42
42
  });
43
43
  Object.defineProperty(exports, 'parsePackageJson', {
44
44
  enumerable: true,
45
- get: function () { return chunkVQCWTT2B_cjs.e; }
45
+ get: function () { return chunk4I4DRNVT_cjs.e; }
46
46
  });
47
47
  Object.defineProperty(exports, 'writePackageJson', {
48
48
  enumerable: true,
49
- get: function () { return chunkVQCWTT2B_cjs.c; }
49
+ get: function () { return chunk4I4DRNVT_cjs.c; }
50
50
  });
51
51
  Object.defineProperty(exports, 'writePackageJsonSync', {
52
52
  enumerable: true,
53
- get: function () { return chunkVQCWTT2B_cjs.d; }
53
+ get: function () { return chunk4I4DRNVT_cjs.d; }
54
54
  });
55
55
  Object.defineProperty(exports, 'findTSConfig', {
56
56
  enumerable: true,
57
- get: function () { return chunkBGBPBHAL_cjs.c; }
57
+ get: function () { return chunkWL2BRLJZ_cjs.c; }
58
58
  });
59
59
  Object.defineProperty(exports, 'findTSConfigSync', {
60
60
  enumerable: true,
61
- get: function () { return chunkBGBPBHAL_cjs.e; }
61
+ get: function () { return chunkWL2BRLJZ_cjs.e; }
62
62
  });
63
63
  Object.defineProperty(exports, 'findTsConfig', {
64
64
  enumerable: true,
65
- get: function () { return chunkBGBPBHAL_cjs.b; }
65
+ get: function () { return chunkWL2BRLJZ_cjs.b; }
66
66
  });
67
67
  Object.defineProperty(exports, 'findTsConfigSync', {
68
68
  enumerable: true,
69
- get: function () { return chunkBGBPBHAL_cjs.d; }
69
+ get: function () { return chunkWL2BRLJZ_cjs.d; }
70
70
  });
71
71
  Object.defineProperty(exports, 'readTsConfig', {
72
72
  enumerable: true,
73
- get: function () { return chunkBGBPBHAL_cjs.a; }
73
+ get: function () { return chunkWL2BRLJZ_cjs.a; }
74
74
  });
75
75
  Object.defineProperty(exports, 'writeTSConfig', {
76
76
  enumerable: true,
77
- get: function () { return chunkBGBPBHAL_cjs.g; }
77
+ get: function () { return chunkWL2BRLJZ_cjs.g; }
78
78
  });
79
79
  //# sourceMappingURL=out.js.map
80
80
  //# sourceMappingURL=index.cjs.map
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
- export { a as findMonorepoRoot } from './chunk-XKKPPOYW.js';
2
- export { a as findPackageRoot } from './chunk-G767QS5X.js';
3
- export { a as findLockFile, b as findPackageManager, c as getPackageManagerVersion, d as identifyInitiatingPackageManager } from './chunk-5ZQIFU6S.js';
4
- export { a as findPackageJson, b as findPackageJsonSync, e as parsePackageJson, c as writePackageJson, d as writePackageJsonSync } from './chunk-TUN46UZB.js';
5
- export { c as findTSConfig, e as findTSConfigSync, b as findTsConfig, d as findTsConfigSync, a as readTsConfig, g as writeTSConfig } from './chunk-F63DY4KL.js';
1
+ export { a as findMonorepoRoot } from './chunk-PUY4M2BR.js';
2
+ export { a as findPackageRoot } from './chunk-M4MWM246.js';
3
+ export { a as findLockFile, b as findPackageManager, c as getPackageManagerVersion, d as identifyInitiatingPackageManager } from './chunk-6KVF4I2Q.js';
4
+ export { a as findPackageJson, b as findPackageJsonSync, e as parsePackageJson, c as writePackageJson, d as writePackageJsonSync } from './chunk-GA54FVOU.js';
5
+ export { c as findTSConfig, e as findTSConfigSync, b as findTsConfig, d as findTsConfigSync, a as readTsConfig, g as writeTSConfig } from './chunk-QPR3SJGT.js';
6
6
  //# sourceMappingURL=out.js.map
7
7
  //# sourceMappingURL=index.js.map
package/dist/monorepo.cjs CHANGED
@@ -1,14 +1,14 @@
1
1
  'use strict';
2
2
 
3
- var chunkL6J2NRQY_cjs = require('./chunk-L6J2NRQY.cjs');
4
- require('./chunk-TM6ZD56C.cjs');
5
- require('./chunk-VQCWTT2B.cjs');
3
+ var chunkXMGJIRS7_cjs = require('./chunk-XMGJIRS7.cjs');
4
+ require('./chunk-3IWUMNBO.cjs');
5
+ require('./chunk-4I4DRNVT.cjs');
6
6
 
7
7
 
8
8
 
9
9
  Object.defineProperty(exports, 'findMonorepoRoot', {
10
10
  enumerable: true,
11
- get: function () { return chunkL6J2NRQY_cjs.a; }
11
+ get: function () { return chunkXMGJIRS7_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-XKKPPOYW.js';
2
- import './chunk-5ZQIFU6S.js';
3
- import './chunk-TUN46UZB.js';
1
+ export { a as findMonorepoRoot } from './chunk-PUY4M2BR.js';
2
+ import './chunk-6KVF4I2Q.js';
3
+ import './chunk-GA54FVOU.js';
4
4
  //# sourceMappingURL=out.js.map
5
5
  //# sourceMappingURL=monorepo.js.map
@@ -1,28 +1,28 @@
1
1
  'use strict';
2
2
 
3
- var chunkVQCWTT2B_cjs = require('./chunk-VQCWTT2B.cjs');
3
+ var chunk4I4DRNVT_cjs = require('./chunk-4I4DRNVT.cjs');
4
4
 
5
5
 
6
6
 
7
7
  Object.defineProperty(exports, 'findPackageJson', {
8
8
  enumerable: true,
9
- get: function () { return chunkVQCWTT2B_cjs.a; }
9
+ get: function () { return chunk4I4DRNVT_cjs.a; }
10
10
  });
11
11
  Object.defineProperty(exports, 'findPackageJsonSync', {
12
12
  enumerable: true,
13
- get: function () { return chunkVQCWTT2B_cjs.b; }
13
+ get: function () { return chunk4I4DRNVT_cjs.b; }
14
14
  });
15
15
  Object.defineProperty(exports, 'parsePackageJson', {
16
16
  enumerable: true,
17
- get: function () { return chunkVQCWTT2B_cjs.e; }
17
+ get: function () { return chunk4I4DRNVT_cjs.e; }
18
18
  });
19
19
  Object.defineProperty(exports, 'writePackageJson', {
20
20
  enumerable: true,
21
- get: function () { return chunkVQCWTT2B_cjs.c; }
21
+ get: function () { return chunk4I4DRNVT_cjs.c; }
22
22
  });
23
23
  Object.defineProperty(exports, 'writePackageJsonSync', {
24
24
  enumerable: true,
25
- get: function () { return chunkVQCWTT2B_cjs.d; }
25
+ get: function () { return chunk4I4DRNVT_cjs.d; }
26
26
  });
27
27
  //# sourceMappingURL=out.js.map
28
28
  //# sourceMappingURL=package-json.cjs.map
@@ -1,3 +1,3 @@
1
- export { a as findPackageJson, b as findPackageJsonSync, e as parsePackageJson, c as writePackageJson, d as writePackageJsonSync } from './chunk-TUN46UZB.js';
1
+ export { a as findPackageJson, b as findPackageJsonSync, e as parsePackageJson, c as writePackageJson, d as writePackageJsonSync } from './chunk-GA54FVOU.js';
2
2
  //# sourceMappingURL=out.js.map
3
3
  //# sourceMappingURL=package-json.js.map
@@ -1,25 +1,25 @@
1
1
  'use strict';
2
2
 
3
- var chunkTM6ZD56C_cjs = require('./chunk-TM6ZD56C.cjs');
4
- require('./chunk-VQCWTT2B.cjs');
3
+ var chunk3IWUMNBO_cjs = require('./chunk-3IWUMNBO.cjs');
4
+ require('./chunk-4I4DRNVT.cjs');
5
5
 
6
6
 
7
7
 
8
8
  Object.defineProperty(exports, 'findLockFile', {
9
9
  enumerable: true,
10
- get: function () { return chunkTM6ZD56C_cjs.a; }
10
+ get: function () { return chunk3IWUMNBO_cjs.a; }
11
11
  });
12
12
  Object.defineProperty(exports, 'findPackageManager', {
13
13
  enumerable: true,
14
- get: function () { return chunkTM6ZD56C_cjs.b; }
14
+ get: function () { return chunk3IWUMNBO_cjs.b; }
15
15
  });
16
16
  Object.defineProperty(exports, 'getPackageManagerVersion', {
17
17
  enumerable: true,
18
- get: function () { return chunkTM6ZD56C_cjs.c; }
18
+ get: function () { return chunk3IWUMNBO_cjs.c; }
19
19
  });
20
20
  Object.defineProperty(exports, 'identifyInitiatingPackageManager', {
21
21
  enumerable: true,
22
- get: function () { return chunkTM6ZD56C_cjs.d; }
22
+ get: function () { return chunk3IWUMNBO_cjs.d; }
23
23
  });
24
24
  //# sourceMappingURL=out.js.map
25
25
  //# sourceMappingURL=package-manager.cjs.map
@@ -1,4 +1,4 @@
1
- export { a as findLockFile, b as findPackageManager, c as getPackageManagerVersion, d as identifyInitiatingPackageManager } from './chunk-5ZQIFU6S.js';
2
- import './chunk-TUN46UZB.js';
1
+ export { a as findLockFile, b as findPackageManager, c as getPackageManagerVersion, d as identifyInitiatingPackageManager } from './chunk-6KVF4I2Q.js';
2
+ import './chunk-GA54FVOU.js';
3
3
  //# sourceMappingURL=out.js.map
4
4
  //# sourceMappingURL=package-manager.js.map
package/dist/package.cjs CHANGED
@@ -1,14 +1,14 @@
1
1
  'use strict';
2
2
 
3
- var chunkVAMRQCZW_cjs = require('./chunk-VAMRQCZW.cjs');
4
- require('./chunk-TM6ZD56C.cjs');
5
- require('./chunk-VQCWTT2B.cjs');
3
+ var chunkGAZI4NM6_cjs = require('./chunk-GAZI4NM6.cjs');
4
+ require('./chunk-3IWUMNBO.cjs');
5
+ require('./chunk-4I4DRNVT.cjs');
6
6
 
7
7
 
8
8
 
9
9
  Object.defineProperty(exports, 'findPackageRoot', {
10
10
  enumerable: true,
11
- get: function () { return chunkVAMRQCZW_cjs.a; }
11
+ get: function () { return chunkGAZI4NM6_cjs.a; }
12
12
  });
13
13
  //# sourceMappingURL=out.js.map
14
14
  //# sourceMappingURL=package.cjs.map
package/dist/package.js CHANGED
@@ -1,5 +1,5 @@
1
- export { a as findPackageRoot } from './chunk-G767QS5X.js';
2
- import './chunk-5ZQIFU6S.js';
3
- import './chunk-TUN46UZB.js';
1
+ export { a as findPackageRoot } from './chunk-M4MWM246.js';
2
+ import './chunk-6KVF4I2Q.js';
3
+ import './chunk-GA54FVOU.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 chunkBGBPBHAL_cjs = require('./chunk-BGBPBHAL.cjs');
3
+ var chunkWL2BRLJZ_cjs = require('./chunk-WL2BRLJZ.cjs');
4
4
 
5
5
 
6
6
 
7
7
  Object.defineProperty(exports, 'findTSConfig', {
8
8
  enumerable: true,
9
- get: function () { return chunkBGBPBHAL_cjs.c; }
9
+ get: function () { return chunkWL2BRLJZ_cjs.c; }
10
10
  });
11
11
  Object.defineProperty(exports, 'findTSConfigSync', {
12
12
  enumerable: true,
13
- get: function () { return chunkBGBPBHAL_cjs.e; }
13
+ get: function () { return chunkWL2BRLJZ_cjs.e; }
14
14
  });
15
15
  Object.defineProperty(exports, 'findTsConfig', {
16
16
  enumerable: true,
17
- get: function () { return chunkBGBPBHAL_cjs.b; }
17
+ get: function () { return chunkWL2BRLJZ_cjs.b; }
18
18
  });
19
19
  Object.defineProperty(exports, 'findTsConfigSync', {
20
20
  enumerable: true,
21
- get: function () { return chunkBGBPBHAL_cjs.d; }
21
+ get: function () { return chunkWL2BRLJZ_cjs.d; }
22
22
  });
23
23
  Object.defineProperty(exports, 'writeTSConfig', {
24
24
  enumerable: true,
25
- get: function () { return chunkBGBPBHAL_cjs.g; }
25
+ get: function () { return chunkWL2BRLJZ_cjs.g; }
26
26
  });
27
27
  Object.defineProperty(exports, 'writeTsConfig', {
28
28
  enumerable: true,
29
- get: function () { return chunkBGBPBHAL_cjs.f; }
29
+ get: function () { return chunkWL2BRLJZ_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-F63DY4KL.js';
1
+ export { c as findTSConfig, e as findTSConfigSync, b as findTsConfig, d as findTsConfigSync, g as writeTSConfig, f as writeTsConfig } from './chunk-QPR3SJGT.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.4.1",
3
+ "version": "1.4.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",
@@ -139,7 +139,7 @@
139
139
  "test:watch": "vitest"
140
140
  },
141
141
  "dependencies": {
142
- "@visulima/fs": "1.11.1",
142
+ "@visulima/fs": "2.0.0",
143
143
  "jsonc-parser": "^3.2.1",
144
144
  "normalize-package-data": "^6.0.0",
145
145
  "pathe": "^1.1.2",
@@ -1,27 +0,0 @@
1
- 'use strict';
2
-
3
- var fs = require('@visulima/fs');
4
- var error = require('@visulima/fs/error');
5
- var utils = require('@visulima/fs/utils');
6
- var pathe = require('pathe');
7
- var fs$1 = require('fs');
8
- var jsoncParser = require('jsonc-parser');
9
- var A = require('module');
10
- var path = require('path');
11
- var resolvePkgMaps = require('resolve-pkg-maps');
12
-
13
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
14
-
15
- var A__default = /*#__PURE__*/_interopDefault(A);
16
-
17
- var z=s=>jsoncParser.parse(fs.readFileSync(s)),_=()=>{let{findPnpApi:s}=A__default.default;return s?.(process.cwd())},v=(s,o,l,n)=>{let t=`resolveFromPackageJsonPath:${s}:${o}:${l}`;if(n?.has(t))return n.get(t);let i=z(s);if(!i)return;let e=o||"tsconfig.json";if(!l&&i.exports)try{let[a]=resolvePkgMaps.resolveExports(i.exports,o,["require","types"]);e=a;}catch{return !1}else !o&&i.tsconfig&&(e=i.tsconfig);return e=path.join(s,"..",e),n?.set(t,e),e},P="package.json",T="tsconfig.json",L=(s,o,l)=>{let n=s;if(s===".."&&(n=path.join(n,T)),s.startsWith(".")&&(n=path.resolve(o,n)),path.isAbsolute(n)){if(fs$1.existsSync(n)){if(fs$1.statSync(n).isFile())return n}else if(!n.endsWith(".json")){let c=`${n}.json`;if(fs$1.existsSync(c))return c}return}let[t,...i]=s.split("/"),e=t.startsWith("@")?`${t}/${i.shift()}`:t,a=i.join("/"),r=_();if(r){let{resolveRequest:c}=r;try{if(e===s){let p=c(path.join(e,P),o);if(p){let h=v(p,a,!1,l);if(h&&fs$1.existsSync(h))return h}}else {let p;try{p=c(s,o,{extensions:[".json"]});}catch{p=c(path.join(s,T),o);}if(p)return p}}catch{}}let f=fs.findUpSync(c=>{let p=path.join(c,"node_modules",e);if(fs$1.existsSync(p))return path.join("node_modules",e)},{cwd:o,type:"directory"});if(!f||!fs$1.statSync(f).isDirectory())return;let g=path.join(f,P);if(fs$1.existsSync(g)){let c=v(g,a,!1,l);if(c===!1)return;if(c&&fs$1.existsSync(c)&&fs$1.statSync(c).isFile())return c}let m=path.join(f,a),C=m.endsWith(".json");if(!C){let c=`${m}.json`;if(fs$1.existsSync(c))return c}if(fs$1.existsSync(m)){if(fs$1.statSync(m).isDirectory()){let c=path.join(m,P);if(fs$1.existsSync(c)){let h=v(c,"",!0,l);if(h&&fs$1.existsSync(h))return h}let p=path.join(m,T);if(fs$1.existsSync(p))return p}else if(C)return m}},j=L;var Y=Symbol("implicitBaseUrl"),Z=s=>jsoncParser.parse(fs.readFileSync(s)),O=s=>pathe.toNamespacedPath(/^\.{1,2}(?:\/.*)?$/.test(s)?s:`./${s}`),q=(s,o,l,n)=>{let t=j(s,o);if(!t)throw new error.NotFoundError(`for '${s}' found.`);if(l.has(t))throw new Error(`Circularity detected while resolving configuration: ${t}`);l.add(t);let i=pathe.dirname(t),e=k(t,n,l);delete e.references;let{compilerOptions:a}=e;if(a){let r=["baseUrl","outDir"];for(let f of r){let g=a[f];g&&(a[f]=pathe.relative(o,pathe.join(i,g)).replaceAll("\\","/")||"./");}}return e.files&&(e.files=e.files.map(r=>pathe.relative(o,pathe.join(i,r)))),e.include&&(e.include=e.include.map(r=>pathe.relative(o,pathe.join(i,r)))),e.exclude&&(e.exclude=e.exclude.map(r=>pathe.relative(o,pathe.join(i,r)))),e},k=(s,o,l=new Set)=>{let n;try{n=fs$1.realpathSync(s);}catch{throw new Error(`Cannot resolve tsconfig at path: ${s}`)}let t=Z(n)||{};if(typeof t!="object")throw new SyntaxError(`Failed to parse tsconfig at: ${s}`);let i=pathe.dirname(n);if(t.compilerOptions){let{compilerOptions:e}=t;e.paths&&!e.baseUrl&&(e[Y]=i);}if(t.extends){let e=Array.isArray(t.extends)?t.extends:[t.extends];delete t.extends;for(let a of e.reverse()){let r=q(a,i,new Set(l),o),f={...r,...t,compilerOptions:{...r.compilerOptions,...t.compilerOptions}};r.watchOptions&&(f.watchOptions={...r.watchOptions,...t.watchOptions}),t=f;}}if(t.compilerOptions){let{compilerOptions:e}=t,a=["baseUrl","rootDir"];for(let f of a){let g=e[f];if(g){let m=pathe.resolve(i,g),C=pathe.relative(i,m);e[f]=O(C);}}let{outDir:r}=e;r&&(Array.isArray(t.exclude)||(t.exclude=[]),t.exclude.includes(r)||t.exclude.push(r),e.outDir=O(r)),o?.tscCompatible&&e.module==="node16"&&(e.allowSyntheticDefaultImports=e.allowSyntheticDefaultImports??!0,e.esModuleInterop=e.esModuleInterop??!0,e.moduleDetection=e.moduleDetection??"force",e.moduleResolution=e.moduleResolution??"node16",e.target=e.target??"es2022",e.useDefineForClassFields=e.useDefineForClassFields??!0),o?.tscCompatible&&e.strict&&(e.noImplicitAny=e.noImplicitAny??!0,e.noImplicitThis=e.noImplicitThis??!0,e.strictNullChecks=e.strictNullChecks??!0,e.strictFunctionTypes=e.strictFunctionTypes??!0,e.strictBindCallApply=e.strictBindCallApply??!0,e.strictPropertyInitialization=e.strictPropertyInitialization??!0,e.alwaysStrict=e.alwaysStrict??!0,e.useUnknownInCatchVariables=e.useUnknownInCatchVariables??!0),o?.tscCompatible&&e.isolatedModules&&(e.preserveConstEnums=e.preserveConstEnums??!0),o?.tscCompatible&&e.esModuleInterop&&(e.allowSyntheticDefaultImports=e.allowSyntheticDefaultImports??!0),o?.tscCompatible&&e.target==="esnext"&&(e.useDefineForClassFields=e.useDefineForClassFields??!0);}else t.compilerOptions={};if(t.files&&(t.files=t.files.map(e=>O(e))),t.include&&(t.include=t.include.map(e=>pathe.normalize(e))),t.watchOptions){let{watchOptions:e}=t;e.excludeDirectories&&(e.excludeDirectories=e.excludeDirectories.map(a=>pathe.resolve(i,a)));}return t},ee=(s,o)=>k(s,o),J=ee;var D=new Map,ne=async(s,o={})=>{let l=o.configFileName??"tsconfig.json",n=await fs.findUp(l,{...s&&{cwd:s},type:"file"});if(n||(n=await fs.findUp("jsconfig.json",{...s&&{cwd:s},type:"file"})),!n)throw new error.NotFoundError(`for ${l} or jsconfig.json found.`);let t=o.cache&&typeof o.cache!="boolean"?o.cache:D;if(o.cache&&t.has(n))return t.get(n);let i={config:J(n),path:n};return o.cache&&t.set(n,i),i},Fe=ne,ie=(s,o={})=>{let l=o.configFileName??"tsconfig.json",n=fs.findUpSync(l,{...s&&{cwd:s},type:"file"});if(n||(n=fs.findUpSync("jsconfig.json",{...s&&{cwd:s},type:"file"})),!n)throw new error.NotFoundError(`for ${l} or jsconfig.json found.`);let t=o.cache&&typeof o.cache!="boolean"?o.cache:D;if(o.cache&&t.has(n))return t.get(n);let i={config:J(n),path:n};return o.cache&&t.set(n,i),i},be=ie,re=async(s,o={})=>{let{cwd:l,...n}=o,t=utils.toPath(o.cwd??process.cwd());await fs.writeJson(pathe.join(t,"tsconfig.json"),s,n);},ke=re;
18
-
19
- exports.a = J;
20
- exports.b = ne;
21
- exports.c = Fe;
22
- exports.d = ie;
23
- exports.e = be;
24
- exports.f = re;
25
- exports.g = ke;
26
- //# sourceMappingURL=out.js.map
27
- //# sourceMappingURL=chunk-BGBPBHAL.cjs.map
@@ -1 +0,0 @@
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,EAAY,YAAAC,MAAgB,KACrC,OAAOC,MAAY,SACnB,OAAS,cAAAC,EAAY,QAAAZ,EAAM,WAAAO,MAAe,OAE1C,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,Q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,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,OAAOkF,CAAc,0BAA0B,EAG3E,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(`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(`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(`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((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 cwd: directoryPath,\n type: \"directory\"\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,15 +0,0 @@
1
- import { findUp, findUpSync, writeJson, readFileSync } from '@visulima/fs';
2
- import { NotFoundError } from '@visulima/fs/error';
3
- import { toPath } from '@visulima/fs/utils';
4
- import { join, dirname, resolve, relative, normalize, toNamespacedPath } from 'pathe';
5
- import { realpathSync, existsSync, statSync } from 'node:fs';
6
- import { parse } from 'jsonc-parser';
7
- import N from 'node:module';
8
- import { join as join$1, resolve as resolve$1, isAbsolute } from 'node:path';
9
- import { resolveExports } from 'resolve-pkg-maps';
10
-
11
- var _=s=>parse(readFileSync(s)),L=()=>{let{findPnpApi:s}=N;return s?.(process.cwd())},v=(s,o,l,n)=>{let t=`resolveFromPackageJsonPath:${s}:${o}:${l}`;if(n?.has(t))return n.get(t);let i=_(s);if(!i)return;let e=o||"tsconfig.json";if(!l&&i.exports)try{let[a]=resolveExports(i.exports,o,["require","types"]);e=a;}catch{return !1}else !o&&i.tsconfig&&(e=i.tsconfig);return e=join$1(s,"..",e),n?.set(t,e),e},P="package.json",T="tsconfig.json",G=(s,o,l)=>{let n=s;if(s===".."&&(n=join$1(n,T)),s.startsWith(".")&&(n=resolve$1(o,n)),isAbsolute(n)){if(existsSync(n)){if(statSync(n).isFile())return n}else if(!n.endsWith(".json")){let c=`${n}.json`;if(existsSync(c))return c}return}let[t,...i]=s.split("/"),e=t.startsWith("@")?`${t}/${i.shift()}`:t,a=i.join("/"),r=L();if(r){let{resolveRequest:c}=r;try{if(e===s){let p=c(join$1(e,P),o);if(p){let h=v(p,a,!1,l);if(h&&existsSync(h))return h}}else {let p;try{p=c(s,o,{extensions:[".json"]});}catch{p=c(join$1(s,T),o);}if(p)return p}}catch{}}let f=findUpSync(c=>{let p=join$1(c,"node_modules",e);if(existsSync(p))return join$1("node_modules",e)},{cwd:o,type:"directory"});if(!f||!statSync(f).isDirectory())return;let g=join$1(f,P);if(existsSync(g)){let c=v(g,a,!1,l);if(c===!1)return;if(c&&existsSync(c)&&statSync(c).isFile())return c}let m=join$1(f,a),C=m.endsWith(".json");if(!C){let c=`${m}.json`;if(existsSync(c))return c}if(existsSync(m)){if(statSync(m).isDirectory()){let c=join$1(m,P);if(existsSync(c)){let h=v(c,"",!0,l);if(h&&existsSync(h))return h}let p=join$1(m,T);if(existsSync(p))return p}else if(C)return m}},F=G;var Z=Symbol("implicitBaseUrl"),q=s=>parse(readFileSync(s)),O=s=>toNamespacedPath(/^\.{1,2}(?:\/.*)?$/.test(s)?s:`./${s}`),ee=(s,o,l,n)=>{let t=F(s,o);if(!t)throw new NotFoundError(`for '${s}' found.`);if(l.has(t))throw new Error(`Circularity detected while resolving configuration: ${t}`);l.add(t);let i=dirname(t),e=I(t,n,l);delete e.references;let{compilerOptions:a}=e;if(a){let r=["baseUrl","outDir"];for(let f of r){let g=a[f];g&&(a[f]=relative(o,join(i,g)).replaceAll("\\","/")||"./");}}return e.files&&(e.files=e.files.map(r=>relative(o,join(i,r)))),e.include&&(e.include=e.include.map(r=>relative(o,join(i,r)))),e.exclude&&(e.exclude=e.exclude.map(r=>relative(o,join(i,r)))),e},I=(s,o,l=new Set)=>{let n;try{n=realpathSync(s);}catch{throw new Error(`Cannot resolve tsconfig at path: ${s}`)}let t=q(n)||{};if(typeof t!="object")throw new SyntaxError(`Failed to parse tsconfig at: ${s}`);let i=dirname(n);if(t.compilerOptions){let{compilerOptions:e}=t;e.paths&&!e.baseUrl&&(e[Z]=i);}if(t.extends){let e=Array.isArray(t.extends)?t.extends:[t.extends];delete t.extends;for(let a of e.reverse()){let r=ee(a,i,new Set(l),o),f={...r,...t,compilerOptions:{...r.compilerOptions,...t.compilerOptions}};r.watchOptions&&(f.watchOptions={...r.watchOptions,...t.watchOptions}),t=f;}}if(t.compilerOptions){let{compilerOptions:e}=t,a=["baseUrl","rootDir"];for(let f of a){let g=e[f];if(g){let m=resolve(i,g),C=relative(i,m);e[f]=O(C);}}let{outDir:r}=e;r&&(Array.isArray(t.exclude)||(t.exclude=[]),t.exclude.includes(r)||t.exclude.push(r),e.outDir=O(r)),o?.tscCompatible&&e.module==="node16"&&(e.allowSyntheticDefaultImports=e.allowSyntheticDefaultImports??!0,e.esModuleInterop=e.esModuleInterop??!0,e.moduleDetection=e.moduleDetection??"force",e.moduleResolution=e.moduleResolution??"node16",e.target=e.target??"es2022",e.useDefineForClassFields=e.useDefineForClassFields??!0),o?.tscCompatible&&e.strict&&(e.noImplicitAny=e.noImplicitAny??!0,e.noImplicitThis=e.noImplicitThis??!0,e.strictNullChecks=e.strictNullChecks??!0,e.strictFunctionTypes=e.strictFunctionTypes??!0,e.strictBindCallApply=e.strictBindCallApply??!0,e.strictPropertyInitialization=e.strictPropertyInitialization??!0,e.alwaysStrict=e.alwaysStrict??!0,e.useUnknownInCatchVariables=e.useUnknownInCatchVariables??!0),o?.tscCompatible&&e.isolatedModules&&(e.preserveConstEnums=e.preserveConstEnums??!0),o?.tscCompatible&&e.esModuleInterop&&(e.allowSyntheticDefaultImports=e.allowSyntheticDefaultImports??!0),o?.tscCompatible&&e.target==="esnext"&&(e.useDefineForClassFields=e.useDefineForClassFields??!0);}else t.compilerOptions={};if(t.files&&(t.files=t.files.map(e=>O(e))),t.include&&(t.include=t.include.map(e=>normalize(e))),t.watchOptions){let{watchOptions:e}=t;e.excludeDirectories&&(e.excludeDirectories=e.excludeDirectories.map(a=>resolve(i,a)));}return t},te=(s,o)=>I(s,o),J=te;var A=new Map,ie=async(s,o={})=>{let l=o.configFileName??"tsconfig.json",n=await findUp(l,{...s&&{cwd:s},type:"file"});if(n||(n=await findUp("jsconfig.json",{...s&&{cwd:s},type:"file"})),!n)throw new NotFoundError(`for ${l} or jsconfig.json found.`);let t=o.cache&&typeof o.cache!="boolean"?o.cache:A;if(o.cache&&t.has(n))return t.get(n);let i={config:J(n),path:n};return o.cache&&t.set(n,i),i},be=ie,re=(s,o={})=>{let l=o.configFileName??"tsconfig.json",n=findUpSync(l,{...s&&{cwd:s},type:"file"});if(n||(n=findUpSync("jsconfig.json",{...s&&{cwd:s},type:"file"})),!n)throw new NotFoundError(`for ${l} or jsconfig.json found.`);let t=o.cache&&typeof o.cache!="boolean"?o.cache:A;if(o.cache&&t.has(n))return t.get(n);let i={config:J(n),path:n};return o.cache&&t.set(n,i),i},ke=re,ce=async(s,o={})=>{let{cwd:l,...n}=o,t=toPath(o.cwd??process.cwd());await writeJson(join(t,"tsconfig.json"),s,n);},Ie=ce;
12
-
13
- export { J as a, ie as b, be as c, re as d, ke as e, ce as f, Ie as g };
14
- //# sourceMappingURL=out.js.map
15
- //# sourceMappingURL=chunk-F63DY4KL.js.map
@@ -1 +0,0 @@
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,EAAU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hC,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,OAAOkF,CAAc,0BAA0B,EAG3E,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(`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(`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(`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((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 cwd: directoryPath,\n type: \"directory\"\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,12 +0,0 @@
1
- import { existsSync } from 'node:fs';
2
- import { findUp, readJson, findUpSync, readJsonSync, writeJson, writeJsonSync } from '@visulima/fs';
3
- import { NotFoundError } from '@visulima/fs/error';
4
- import { toPath, parseJson } from '@visulima/fs/utils';
5
- import r from 'normalize-package-data';
6
- import { normalize, join } from 'pathe';
7
-
8
- var m=new Map,S=async(e,o={})=>{let a=await findUp("package.json",{...e&&{cwd:e},type:"file"});if(!a)throw new NotFoundError("for package.json found.");let t=o.cache&&typeof o.cache!="boolean"?o.cache:m;if(o.cache&&t.has(a))return t.get(a);let s=await readJson(a);r(s);let n={packageJson:s,path:normalize(a)};return t.set(a,n),n},x=(e,o={})=>{let a=findUpSync("package.json",{...e&&{cwd:e},type:"file"});if(!a)throw new NotFoundError("for package.json found.");let t=o.cache&&typeof o.cache!="boolean"?o.cache:m;if(o.cache&&t.has(a))return t.get(a);let s=readJsonSync(a);r(s);let n={packageJson:s,path:a};return t.set(a,n),n},U=async(e,o={})=>{let{cwd:a,...t}=o,s=toPath(o.cwd??process.cwd());await writeJson(join(s,"package.json"),e,t);},T=(e,o={})=>{let{cwd:a,...t}=o,s=toPath(o.cwd??process.cwd());writeJsonSync(join(s,"package.json"),e,t);},C=e=>{let o=e!==null&&typeof e=="object"&&!Array.isArray(e);if(!o&&!(typeof e=="string"))throw new TypeError("`packageFile` should be either an `object` or a `string`.");let t=o?structuredClone(e):existsSync(e)?readJsonSync(e):parseJson(e);return r(t),t};
9
-
10
- export { S as a, x as b, U as c, T as d, C as e };
11
- //# sourceMappingURL=out.js.map
12
- //# sourceMappingURL=chunk-TUN46UZB.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/package-json.ts"],"names":["existsSync","findUp","findUpSync","readJson","readJsonSync","writeJson","writeJsonSync","NotFoundError","parseJson","toPath","normalizeData","join","normalize","PackageJsonFileCache","findPackageJson","cwd","options","filePath","cache","packageJson","output","findPackageJsonSync","writePackageJson","data","writeOptions","directory","writePackageJsonSync","parsePackageJson","packageFile","isObject","json"],"mappings":"AAAA,OAAS,cAAAA,MAAkB,UAG3B,OAAS,UAAAC,EAAQ,cAAAC,EAAY,YAAAC,EAAU,gBAAAC,EAAc,aAAAC,EAAW,iBAAAC,MAAqB,eACrF,OAAS,iBAAAC,MAAqB,qBAC9B,OAAS,aAAAC,EAAW,UAAAC,MAAc,qBAElC,OAAOC,MAAmB,yBAC1B,OAAS,QAAAC,EAAM,aAAAC,MAAiB,QAShC,IAAMC,EAAuB,IAAI,IAepBC,EAAkB,MAAOC,EAAoBC,EAAuB,CAAC,IAAqC,CACnH,IAAMC,EAAW,MAAMhB,EAAO,eAAgB,CAC1C,GAAIc,GAAO,CAAE,IAAAA,CAAI,EACjB,KAAM,MACV,CAAC,EAED,GAAI,CAACE,EACD,MAAM,IAAIV,EAAc,yBAAyB,EAGrD,IAAMW,EAAQF,EAAQ,OAAS,OAAOA,EAAQ,OAAU,UAAYA,EAAQ,MAAQH,EAEpF,GAAIG,EAAQ,OAASE,EAAM,IAAID,CAAQ,EACnC,OAAOC,EAAM,IAAID,CAAQ,EAG7B,IAAME,EAAc,MAAMhB,EAASc,CAAQ,EAE3CP,EAAcS,CAAoB,EAElC,IAAMC,EAAS,CACX,YAAaD,EAE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AOD,EACP,gBAAgBD,CAAW,EAE3B5B,EAAW4B,CAAqB,EAC9BxB,EAAawB,CAAqB,EAClCpB,EAAUoB,CAAqB,EAEvC,OAAAlB,EAAcoB,CAAa,EAEpBA,CACX","sourcesContent":["import { existsSync } from \"node:fs\";\n\nimport type { WriteJsonOptions } from \"@visulima/fs\";\nimport { findUp, findUpSync, readJson, readJsonSync, writeJson, writeJsonSync } from \"@visulima/fs\";\nimport { NotFoundError } from \"@visulima/fs/error\";\nimport { parseJson, toPath } from \"@visulima/fs/utils\";\nimport type { Input } from \"normalize-package-data\";\nimport normalizeData from \"normalize-package-data\";\nimport { join, normalize } from \"pathe\";\nimport type { JsonObject } from \"type-fest\";\n\nimport type { Cache, NormalizedPackageJson, PackageJson } from \"./types\";\n\ntype ReadOptions = {\n cache?: Cache<NormalizedReadResult> | boolean;\n};\n\nconst PackageJsonFileCache = new Map<string, NormalizedReadResult>();\n\nexport type NormalizedReadResult = {\n packageJson: NormalizedPackageJson;\n path: string;\n};\n\n/**\n * An asynchronous function to find the package.json file in the specified directory or its parent directories.\n *\n * @param cwd - The current working directory.\n * @returns A `Promise` that resolves to an object containing the parsed package.json data and the file path.\n * The type of the returned promise is `Promise<NormalizedReadResult>`.\n * @throws An `Error` if the package.json file cannot be found.\n */\nexport const findPackageJson = async (cwd?: URL | string, options: ReadOptions = {}): Promise<NormalizedReadResult> => {\n const filePath = await findUp(\"package.json\", {\n ...(cwd && { cwd }),\n type: \"file\",\n });\n\n if (!filePath) {\n throw new NotFoundError(\"for package.json found.\");\n }\n\n const cache = options.cache && typeof options.cache !== \"boolean\" ? options.cache : PackageJsonFileCache;\n\n if (options.cache && cache.has(filePath)) {\n return cache.get(filePath) as NormalizedReadResult;\n }\n\n const packageJson = await readJson(filePath);\n\n normalizeData(packageJson as Input);\n\n const output = {\n packageJson: packageJson as NormalizedPackageJson,\n // @TODO Remove this after @visulima/fs use pathe\n path: normalize(filePath),\n };\n\n cache.set(filePath, output);\n\n return output;\n};\n\nexport const findPackageJsonSync = (cwd?: URL | string, options: ReadOptions = {}): NormalizedReadResult => {\n const filePath = findUpSync(\"package.json\", {\n ...(cwd && { cwd }),\n type: \"file\",\n });\n\n if (!filePath) {\n throw new NotFoundError(\"for package.json found.\");\n }\n\n const cache = options.cache && typeof options.cache !== \"boolean\" ? options.cache : PackageJsonFileCache;\n\n if (options.cache && cache.has(filePath)) {\n return cache.get(filePath) as NormalizedReadResult;\n }\n\n const packageJson = readJsonSync(filePath);\n\n normalizeData(packageJson as Input);\n\n const output = {\n packageJson: packageJson as NormalizedPackageJson,\n path: filePath,\n };\n\n cache.set(filePath, output);\n\n return output;\n};\n\n/**\n * An asynchronous function to write the package.json file with the given data.\n *\n * @param data - The package.json data to write. The data is an intersection type of `PackageJson` and a record where keys are `string` and values can be any type.\n * @param options - Optional. The options for writing the package.json. If not provided, an empty object will be used `{}`.\n * This is an intersection type of `WriteJsonOptions` and a record with an optional `cwd` key which type is `Options[\"cwd\"]`.\n * `cwd` represents the current working directory. If not specified, the default working directory will be used.\n * @returns A `Promise` that resolves once the package.json file has been written. The type of the returned promise is `Promise<void>`.\n */\n\nexport const writePackageJson = async <T = PackageJson>(data: T, options: WriteJsonOptions & { cwd?: URL | string } = {}): Promise<void> => {\n const { cwd, ...writeOptions } = options;\n const directory = toPath(options.cwd ?? process.cwd());\n\n await writeJson(join(directory, \"package.json\"), data, writeOptions);\n};\n\nexport const writePackageJsonSync = <T = PackageJson>(data: T, options: WriteJsonOptions & { cwd?: URL | string } = {}): void => {\n const { cwd, ...writeOptions } = options;\n const directory = toPath(options.cwd ?? process.cwd());\n\n writeJsonSync(join(directory, \"package.json\"), data, writeOptions);\n};\n\nexport const parsePackageJson = (packageFile: JsonObject | string): NormalizedPackageJson => {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n const isObject = packageFile !== null && typeof packageFile === \"object\" && !Array.isArray(packageFile);\n const isString = typeof packageFile === \"string\";\n\n if (!isObject && !isString) {\n throw new TypeError(\"`packageFile` should be either an `object` or a `string`.\");\n }\n\n const json = isObject\n ? structuredClone(packageFile)\n : // eslint-disable-next-line security/detect-non-literal-fs-filename\n existsSync(packageFile as string)\n ? readJsonSync(packageFile as string)\n : parseJson(packageFile as string);\n\n normalizeData(json as Input);\n\n return json as NormalizedPackageJson;\n};\n"]}
@@ -1,22 +0,0 @@
1
- 'use strict';
2
-
3
- var fs$1 = require('fs');
4
- var fs = require('@visulima/fs');
5
- var error = require('@visulima/fs/error');
6
- var utils = require('@visulima/fs/utils');
7
- var r = require('normalize-package-data');
8
- var pathe = require('pathe');
9
-
10
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
11
-
12
- var r__default = /*#__PURE__*/_interopDefault(r);
13
-
14
- var m=new Map,b=async(e,o={})=>{let a=await fs.findUp("package.json",{...e&&{cwd:e},type:"file"});if(!a)throw new error.NotFoundError("for package.json found.");let t=o.cache&&typeof o.cache!="boolean"?o.cache:m;if(o.cache&&t.has(a))return t.get(a);let s=await fs.readJson(a);r__default.default(s);let n={packageJson:s,path:pathe.normalize(a)};return t.set(a,n),n},S=(e,o={})=>{let a=fs.findUpSync("package.json",{...e&&{cwd:e},type:"file"});if(!a)throw new error.NotFoundError("for package.json found.");let t=o.cache&&typeof o.cache!="boolean"?o.cache:m;if(o.cache&&t.has(a))return t.get(a);let s=fs.readJsonSync(a);r__default.default(s);let n={packageJson:s,path:a};return t.set(a,n),n},x=async(e,o={})=>{let{cwd:a,...t}=o,s=utils.toPath(o.cwd??process.cwd());await fs.writeJson(pathe.join(s,"package.json"),e,t);},U=(e,o={})=>{let{cwd:a,...t}=o,s=utils.toPath(o.cwd??process.cwd());fs.writeJsonSync(pathe.join(s,"package.json"),e,t);},T=e=>{let o=e!==null&&typeof e=="object"&&!Array.isArray(e);if(!o&&!(typeof e=="string"))throw new TypeError("`packageFile` should be either an `object` or a `string`.");let t=o?structuredClone(e):fs$1.existsSync(e)?fs.readJsonSync(e):utils.parseJson(e);return r__default.default(t),t};
15
-
16
- exports.a = b;
17
- exports.b = S;
18
- exports.c = x;
19
- exports.d = U;
20
- exports.e = T;
21
- //# sourceMappingURL=out.js.map
22
- //# sourceMappingURL=chunk-VQCWTT2B.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/package-json.ts"],"names":["existsSync","findUp","findUpSync","readJson","readJsonSync","writeJson","writeJsonSync","NotFoundError","parseJson","toPath","normalizeData","join","normalize","PackageJsonFileCache","findPackageJson","cwd","options","filePath","cache","packageJson","output","findPackageJsonSync","writePackageJson","data","writeOptions","directory","writePackageJsonSync","parsePackageJson","packageFile","isObject","json"],"mappings":"AAAA,OAAS,cAAAA,MAAkB,KAG3B,OAAS,UAAAC,EAAQ,cAAAC,EAAY,YAAAC,EAAU,gBAAAC,EAAc,aAAAC,EAAW,iBAAAC,MAAqB,eACrF,OAAS,iBAAAC,MAAqB,qBAC9B,OAAS,aAAAC,EAAW,UAAAC,MAAc,qBAElC,OAAOC,MAAmB,yBAC1B,OAAS,QAAAC,EAAM,aAAAC,MAAiB,QAShC,IAAMC,EAAuB,IAAI,IAepBC,EAAkB,MAAOC,EAAoBC,EAAuB,CAAC,IAAqC,CACnH,IAAMC,EAAW,MAAMhB,EAAO,eAAgB,CAC1C,GAAIc,GAAO,CAAE,IAAAA,CAAI,EACjB,KAAM,MACV,CAAC,EAED,GAAI,CAACE,EACD,MAAM,IAAIV,EAAc,yBAAyB,EAGrD,IAAMW,EAAQF,EAAQ,OAAS,OAAOA,EAAQ,OAAU,UAAYA,EAAQ,MAAQH,EAEpF,GAAIG,EAAQ,OAASE,EAAM,IAAID,CAAQ,EACnC,OAAOC,EAAM,IAAID,CAAQ,EAG7B,IAAME,EAAc,MAAMhB,EAASc,CAAQ,EAE3CP,EAAcS,CAAoB,EAElC,IAAMC,EAAS,CACX,YAAaD,EAEb,KAAMP,EAAUK,CAAQ,CAC5B,EAEA,OAAAC,EAAM,IAAID,EAAUG,CAAM,EAEnBA,CACX,EAEaC,EAAsB,CAACN,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C,OAAAlB,EAAcoB,CAAa,EAEpBA,CACX","sourcesContent":["import { existsSync } from \"node:fs\";\n\nimport type { WriteJsonOptions } from \"@visulima/fs\";\nimport { findUp, findUpSync, readJson, readJsonSync, writeJson, writeJsonSync } from \"@visulima/fs\";\nimport { NotFoundError } from \"@visulima/fs/error\";\nimport { parseJson, toPath } from \"@visulima/fs/utils\";\nimport type { Input } from \"normalize-package-data\";\nimport normalizeData from \"normalize-package-data\";\nimport { join, normalize } from \"pathe\";\nimport type { JsonObject } from \"type-fest\";\n\nimport type { Cache, NormalizedPackageJson, PackageJson } from \"./types\";\n\ntype ReadOptions = {\n cache?: Cache<NormalizedReadResult> | boolean;\n};\n\nconst PackageJsonFileCache = new Map<string, NormalizedReadResult>();\n\nexport type NormalizedReadResult = {\n packageJson: NormalizedPackageJson;\n path: string;\n};\n\n/**\n * An asynchronous function to find the package.json file in the specified directory or its parent directories.\n *\n * @param cwd - The current working directory.\n * @returns A `Promise` that resolves to an object containing the parsed package.json data and the file path.\n * The type of the returned promise is `Promise<NormalizedReadResult>`.\n * @throws An `Error` if the package.json file cannot be found.\n */\nexport const findPackageJson = async (cwd?: URL | string, options: ReadOptions = {}): Promise<NormalizedReadResult> => {\n const filePath = await findUp(\"package.json\", {\n ...(cwd && { cwd }),\n type: \"file\",\n });\n\n if (!filePath) {\n throw new NotFoundError(\"for package.json found.\");\n }\n\n const cache = options.cache && typeof options.cache !== \"boolean\" ? options.cache : PackageJsonFileCache;\n\n if (options.cache && cache.has(filePath)) {\n return cache.get(filePath) as NormalizedReadResult;\n }\n\n const packageJson = await readJson(filePath);\n\n normalizeData(packageJson as Input);\n\n const output = {\n packageJson: packageJson as NormalizedPackageJson,\n // @TODO Remove this after @visulima/fs use pathe\n path: normalize(filePath),\n };\n\n cache.set(filePath, output);\n\n return output;\n};\n\nexport const findPackageJsonSync = (cwd?: URL | string, options: ReadOptions = {}): NormalizedReadResult => {\n const filePath = findUpSync(\"package.json\", {\n ...(cwd && { cwd }),\n type: \"file\",\n });\n\n if (!filePath) {\n throw new NotFoundError(\"for package.json found.\");\n }\n\n const cache = options.cache && typeof options.cache !== \"boolean\" ? options.cache : PackageJsonFileCache;\n\n if (options.cache && cache.has(filePath)) {\n return cache.get(filePath) as NormalizedReadResult;\n }\n\n const packageJson = readJsonSync(filePath);\n\n normalizeData(packageJson as Input);\n\n const output = {\n packageJson: packageJson as NormalizedPackageJson,\n path: filePath,\n };\n\n cache.set(filePath, output);\n\n return output;\n};\n\n/**\n * An asynchronous function to write the package.json file with the given data.\n *\n * @param data - The package.json data to write. The data is an intersection type of `PackageJson` and a record where keys are `string` and values can be any type.\n * @param options - Optional. The options for writing the package.json. If not provided, an empty object will be used `{}`.\n * This is an intersection type of `WriteJsonOptions` and a record with an optional `cwd` key which type is `Options[\"cwd\"]`.\n * `cwd` represents the current working directory. If not specified, the default working directory will be used.\n * @returns A `Promise` that resolves once the package.json file has been written. The type of the returned promise is `Promise<void>`.\n */\n\nexport const writePackageJson = async <T = PackageJson>(data: T, options: WriteJsonOptions & { cwd?: URL | string } = {}): Promise<void> => {\n const { cwd, ...writeOptions } = options;\n const directory = toPath(options.cwd ?? process.cwd());\n\n await writeJson(join(directory, \"package.json\"), data, writeOptions);\n};\n\nexport const writePackageJsonSync = <T = PackageJson>(data: T, options: WriteJsonOptions & { cwd?: URL | string } = {}): void => {\n const { cwd, ...writeOptions } = options;\n const directory = toPath(options.cwd ?? process.cwd());\n\n writeJsonSync(join(directory, \"package.json\"), data, writeOptions);\n};\n\nexport const parsePackageJson = (packageFile: JsonObject | string): NormalizedPackageJson => {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n const isObject = packageFile !== null && typeof packageFile === \"object\" && !Array.isArray(packageFile);\n const isString = typeof packageFile === \"string\";\n\n if (!isObject && !isString) {\n throw new TypeError(\"`packageFile` should be either an `object` or a `string`.\");\n }\n\n const json = isObject\n ? structuredClone(packageFile)\n : // eslint-disable-next-line security/detect-non-literal-fs-filename\n existsSync(packageFile as string)\n ? readJsonSync(packageFile as string)\n : parseJson(packageFile as string);\n\n normalizeData(json as Input);\n\n return json as NormalizedPackageJson;\n};\n"]}