@visulima/package 1.8.1 → 1.8.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 (66) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/chunk-5UU4RIJA.js +11 -0
  3. package/dist/chunk-5UU4RIJA.js.map +1 -0
  4. package/dist/chunk-BGVUNBLL.js +12 -0
  5. package/dist/chunk-BGVUNBLL.js.map +1 -0
  6. package/dist/chunk-BHDWBI3F.cjs +22 -0
  7. package/dist/chunk-BHDWBI3F.cjs.map +1 -0
  8. package/dist/chunk-C36BYRSZ.cjs +19 -0
  9. package/dist/chunk-C36BYRSZ.cjs.map +1 -0
  10. package/dist/chunk-EY5KVLRL.js +10 -0
  11. package/dist/chunk-EY5KVLRL.js.map +1 -0
  12. package/dist/chunk-HGV2BL7M.js +12 -0
  13. package/dist/chunk-HGV2BL7M.js.map +1 -0
  14. package/dist/chunk-I3EKI236.cjs +13 -0
  15. package/dist/chunk-I3EKI236.cjs.map +1 -0
  16. package/dist/chunk-J5ERILYG.cjs +9 -0
  17. package/dist/chunk-J5ERILYG.cjs.map +1 -0
  18. package/dist/chunk-KMWIKANF.js +7 -0
  19. package/dist/chunk-KMWIKANF.js.map +1 -0
  20. package/dist/chunk-RETLQXQB.cjs +13 -0
  21. package/dist/chunk-RETLQXQB.cjs.map +1 -0
  22. package/dist/chunk-W3Z24XII.js +14 -0
  23. package/dist/chunk-W3Z24XII.js.map +1 -0
  24. package/dist/chunk-W7A6C74U.cjs +27 -0
  25. package/dist/chunk-W7A6C74U.cjs.map +1 -0
  26. package/dist/error.cjs +5 -5
  27. package/dist/error.js +3 -3
  28. package/dist/index.cjs +54 -103
  29. package/dist/index.cjs.map +1 -1
  30. package/dist/index.js +10 -59
  31. package/dist/index.js.map +1 -1
  32. package/dist/monorepo.cjs +5 -5
  33. package/dist/monorepo.js +3 -3
  34. package/dist/package-json.cjs +11 -11
  35. package/dist/package-json.js +1 -1
  36. package/dist/package-manager.cjs +14 -14
  37. package/dist/package-manager.js +2 -2
  38. package/dist/package.cjs +7 -7
  39. package/dist/package.js +3 -3
  40. package/dist/tsconfig.cjs +15 -15
  41. package/dist/tsconfig.js +1 -1
  42. package/package.json +8 -8
  43. package/dist/chunk-5VO6NTKJ.js +0 -361
  44. package/dist/chunk-5VO6NTKJ.js.map +0 -1
  45. package/dist/chunk-7IOK6YPW.cjs +0 -52
  46. package/dist/chunk-7IOK6YPW.cjs.map +0 -1
  47. package/dist/chunk-CVVFWSMT.cjs +0 -65
  48. package/dist/chunk-CVVFWSMT.cjs.map +0 -1
  49. package/dist/chunk-E2PKJX3Q.js +0 -54
  50. package/dist/chunk-E2PKJX3Q.js.map +0 -1
  51. package/dist/chunk-EYMR7Z2I.js +0 -62
  52. package/dist/chunk-EYMR7Z2I.js.map +0 -1
  53. package/dist/chunk-G3SI24AJ.cjs +0 -88
  54. package/dist/chunk-G3SI24AJ.cjs.map +0 -1
  55. package/dist/chunk-IIYQBLPC.js +0 -119
  56. package/dist/chunk-IIYQBLPC.js.map +0 -1
  57. package/dist/chunk-IK5YSYLX.cjs +0 -126
  58. package/dist/chunk-IK5YSYLX.cjs.map +0 -1
  59. package/dist/chunk-UZ2FN6C5.js +0 -78
  60. package/dist/chunk-UZ2FN6C5.js.map +0 -1
  61. package/dist/chunk-WXFZK4G3.cjs +0 -374
  62. package/dist/chunk-WXFZK4G3.cjs.map +0 -1
  63. package/dist/chunk-YLCN7EVV.js +0 -50
  64. package/dist/chunk-YLCN7EVV.js.map +0 -1
  65. package/dist/chunk-YOQXHFU3.cjs +0 -56
  66. package/dist/chunk-YOQXHFU3.cjs.map +0 -1
@@ -1,78 +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 normalizeData from 'normalize-package-data';
6
- import { join } from 'pathe';
7
-
8
- // src/package-json.ts
9
- var PackageJsonFileCache = /* @__PURE__ */ new Map();
10
- var findPackageJson = async (cwd, options = {}) => {
11
- const filePath = await findUp("package.json", {
12
- ...cwd && { cwd },
13
- type: "file"
14
- });
15
- if (!filePath) {
16
- throw new NotFoundError("No such file or directory, for package.json found.");
17
- }
18
- const cache = options.cache && typeof options.cache !== "boolean" ? options.cache : PackageJsonFileCache;
19
- if (options.cache && cache.has(filePath)) {
20
- return cache.get(filePath);
21
- }
22
- const packageJson = await readJson(filePath);
23
- normalizeData(packageJson);
24
- const output = {
25
- packageJson,
26
- path: filePath
27
- };
28
- cache.set(filePath, output);
29
- return output;
30
- };
31
- var findPackageJsonSync = (cwd, options = {}) => {
32
- const filePath = findUpSync("package.json", {
33
- ...cwd && { cwd },
34
- type: "file"
35
- });
36
- if (!filePath) {
37
- throw new NotFoundError("No such file or directory, for package.json found.");
38
- }
39
- const cache = options.cache && typeof options.cache !== "boolean" ? options.cache : PackageJsonFileCache;
40
- if (options.cache && cache.has(filePath)) {
41
- return cache.get(filePath);
42
- }
43
- const packageJson = readJsonSync(filePath);
44
- normalizeData(packageJson);
45
- const output = {
46
- packageJson,
47
- path: filePath
48
- };
49
- cache.set(filePath, output);
50
- return output;
51
- };
52
- var writePackageJson = async (data, options = {}) => {
53
- const { cwd, ...writeOptions } = options;
54
- const directory = toPath(options.cwd ?? process.cwd());
55
- await writeJson(join(directory, "package.json"), data, writeOptions);
56
- };
57
- var writePackageJsonSync = (data, options = {}) => {
58
- const { cwd, ...writeOptions } = options;
59
- const directory = toPath(options.cwd ?? process.cwd());
60
- writeJsonSync(join(directory, "package.json"), data, writeOptions);
61
- };
62
- var parsePackageJson = (packageFile) => {
63
- const isObject = packageFile !== null && typeof packageFile === "object" && !Array.isArray(packageFile);
64
- const isString = typeof packageFile === "string";
65
- if (!isObject && !isString) {
66
- throw new TypeError("`packageFile` should be either an `object` or a `string`.");
67
- }
68
- const json = isObject ? structuredClone(packageFile) : (
69
- // eslint-disable-next-line security/detect-non-literal-fs-filename
70
- existsSync(packageFile) ? readJsonSync(packageFile) : parseJson(packageFile)
71
- );
72
- normalizeData(json);
73
- return json;
74
- };
75
-
76
- export { findPackageJson, findPackageJsonSync, parsePackageJson, writePackageJson, writePackageJsonSync };
77
- //# sourceMappingURL=out.js.map
78
- //# sourceMappingURL=chunk-UZ2FN6C5.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/package-json.ts"],"names":[],"mappings":";AAAA,SAAS,kBAAkB;AAG3B,SAAS,QAAQ,YAAY,UAAU,cAAc,WAAW,qBAAqB;AACrF,SAAS,qBAAqB;AAC9B,SAAS,WAAW,cAAc;AAElC,OAAO,mBAAmB;AAC1B,SAAS,YAAY;AASrB,IAAM,uBAAuB,oBAAI,IAAkC;AAe5D,IAAM,kBAAkB,OAAO,KAAoB,UAAuB,CAAC,MAAqC;AACnH,QAAM,WAAW,MAAM,OAAO,gBAAgB;AAAA,IAC1C,GAAI,OAAO,EAAE,IAAI;AAAA,IACjB,MAAM;AAAA,EACV,CAAC;AAED,MAAI,CAAC,UAAU;AACX,UAAM,IAAI,cAAc,oDAAoD;AAAA,EAChF;AAEA,QAAM,QAAQ,QAAQ,SAAS,OAAO,QAAQ,UAAU,YAAY,QAAQ,QAAQ;AAEpF,MAAI,QAAQ,SAAS,MAAM,IAAI,QAAQ,GAAG;AACtC,WAAO,MAAM,IAAI,QAAQ;AAAA,EAC7B;AAEA,QAAM,cAAc,MAAM,SAAS,QAAQ;AAE3C,gBAAc,WAAoB;AAElC,QAAM,SAAS;AAAA,IACX;AAAA,IACA,MAAM;AAAA,EACV;AAEA,QAAM,IAAI,UAAU,MAAM;AAE1B,SAAO;AACX;AAEO,IAAM,sBAAsB,CAAC,KAAoB,UAAuB,CAAC,MAA4B;AACxG,QAAM,WAAW,WAAW,gBAAgB;AAAA,IACxC,GAAI,OAAO,EAAE,IAAI;AAAA,IACjB,MAAM;AAAA,EACV,CAAC;AAED,MAA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onOptions } from \"@visulima/fs\";\nimport { findUp, findUpSync, readJson, readJsonSync, writeJson, writeJsonSync } from \"@visulima/fs\";\nimport { NotFoundError } from \"@visulima/fs/error\";\nimport { parseJson, toPath } from \"@visulima/fs/utils\";\nimport type { Input } from \"normalize-package-data\";\nimport normalizeData from \"normalize-package-data\";\nimport { join } from \"pathe\";\nimport type { JsonObject } from \"type-fest\";\n\nimport type { Cache, NormalizedPackageJson, PackageJson } from \"./types\";\n\ntype ReadOptions = {\n cache?: Cache<NormalizedReadResult> | boolean;\n};\n\nconst PackageJsonFileCache = new Map<string, NormalizedReadResult>();\n\nexport type NormalizedReadResult = {\n packageJson: NormalizedPackageJson;\n path: string;\n};\n\n/**\n * An asynchronous function to find the package.json file in the specified directory or its parent directories.\n *\n * @param cwd - The current working directory.\n * @returns A `Promise` that resolves to an object containing the parsed package.json data and the file path.\n * The type of the returned promise is `Promise<NormalizedReadResult>`.\n * @throws An `Error` if the package.json file cannot be found.\n */\nexport const findPackageJson = async (cwd?: URL | string, options: ReadOptions = {}): Promise<NormalizedReadResult> => {\n const filePath = await findUp(\"package.json\", {\n ...(cwd && { cwd }),\n type: \"file\",\n });\n\n if (!filePath) {\n throw new NotFoundError(\"No such file or directory, for package.json found.\");\n }\n\n const cache = options.cache && typeof options.cache !== \"boolean\" ? options.cache : PackageJsonFileCache;\n\n if (options.cache && cache.has(filePath)) {\n return cache.get(filePath) as NormalizedReadResult;\n }\n\n const packageJson = await readJson(filePath);\n\n normalizeData(packageJson as Input);\n\n const output = {\n packageJson: packageJson as NormalizedPackageJson,\n path: filePath,\n };\n\n cache.set(filePath, output);\n\n return output;\n};\n\nexport const findPackageJsonSync = (cwd?: URL | string, options: ReadOptions = {}): NormalizedReadResult => {\n const filePath = findUpSync(\"package.json\", {\n ...(cwd && { cwd }),\n type: \"file\",\n });\n\n if (!filePath) {\n throw new NotFoundError(\"No such file or directory, for package.json found.\");\n }\n\n const cache = options.cache && typeof options.cache !== \"boolean\" ? options.cache : PackageJsonFileCache;\n\n if (options.cache && cache.has(filePath)) {\n return cache.get(filePath) as NormalizedReadResult;\n }\n\n const packageJson = readJsonSync(filePath);\n\n normalizeData(packageJson as Input);\n\n const output = {\n packageJson: packageJson as NormalizedPackageJson,\n path: filePath,\n };\n\n cache.set(filePath, output);\n\n return output;\n};\n\n/**\n * An asynchronous function to write the package.json file with the given data.\n *\n * @param data - The package.json data to write. The data is an intersection type of `PackageJson` and a record where keys are `string` and values can be any type.\n * @param options - Optional. The options for writing the package.json. If not provided, an empty object will be used `{}`.\n * This is an intersection type of `WriteJsonOptions` and a record with an optional `cwd` key which type is `Options[\"cwd\"]`.\n * `cwd` represents the current working directory. If not specified, the default working directory will be used.\n * @returns A `Promise` that resolves once the package.json file has been written. The type of the returned promise is `Promise<void>`.\n */\n\nexport const writePackageJson = async <T = PackageJson>(data: T, options: WriteJsonOptions & { cwd?: URL | string } = {}): Promise<void> => {\n const { cwd, ...writeOptions } = options;\n const directory = toPath(options.cwd ?? process.cwd());\n\n await writeJson(join(directory, \"package.json\"), data, writeOptions);\n};\n\nexport const writePackageJsonSync = <T = PackageJson>(data: T, options: WriteJsonOptions & { cwd?: URL | string } = {}): void => {\n const { cwd, ...writeOptions } = options;\n const directory = toPath(options.cwd ?? process.cwd());\n\n writeJsonSync(join(directory, \"package.json\"), data, writeOptions);\n};\n\nexport const parsePackageJson = (packageFile: JsonObject | string): NormalizedPackageJson => {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n const isObject = packageFile !== null && typeof packageFile === \"object\" && !Array.isArray(packageFile);\n const isString = typeof packageFile === \"string\";\n\n if (!isObject && !isString) {\n throw new TypeError(\"`packageFile` should be either an `object` or a `string`.\");\n }\n\n const json = isObject\n ? structuredClone(packageFile)\n : // eslint-disable-next-line security/detect-non-literal-fs-filename\n existsSync(packageFile as string)\n ? readJsonSync(packageFile as string)\n : parseJson(packageFile as string);\n\n normalizeData(json as Input);\n\n return json as NormalizedPackageJson;\n};\n"]}
@@ -1,374 +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 jsoncParser = require('jsonc-parser');
8
- var fs$1 = require('fs');
9
- var Module = 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 Module__default = /*#__PURE__*/_interopDefault(Module);
16
-
17
- // src/tsconfig.ts
18
- var readJsonc = (jsonPath) => jsoncParser.parse(fs.readFileSync(jsonPath));
19
- var getPnpApi = () => {
20
- const { findPnpApi } = Module__default.default;
21
- return findPnpApi?.(process.cwd());
22
- };
23
- var resolveFromPackageJsonPath = (packageJsonPath, subpath, ignoreExports, cache) => {
24
- const cacheKey = `resolveFromPackageJsonPath:${packageJsonPath}:${subpath}:${ignoreExports}`;
25
- if (cache?.has(cacheKey)) {
26
- return cache.get(cacheKey);
27
- }
28
- const packageJson = readJsonc(packageJsonPath);
29
- if (!packageJson) {
30
- return void 0;
31
- }
32
- let resolvedPath = subpath || "tsconfig.json";
33
- if (!ignoreExports && packageJson.exports) {
34
- try {
35
- const [resolvedExport] = resolvePkgMaps.resolveExports(packageJson.exports, subpath, ["require", "types"]);
36
- resolvedPath = resolvedExport;
37
- } catch {
38
- return false;
39
- }
40
- } else if (!subpath && packageJson.tsconfig) {
41
- resolvedPath = packageJson.tsconfig;
42
- }
43
- resolvedPath = path.join(packageJsonPath, "..", resolvedPath);
44
- cache?.set(cacheKey, resolvedPath);
45
- return resolvedPath;
46
- };
47
- var PACKAGE_JSON = "package.json";
48
- var TS_CONFIG_JSON = "tsconfig.json";
49
- var resolveExtendsPath = (requestedPath, directoryPath, cache) => {
50
- let filePath = requestedPath;
51
- if (requestedPath === "..") {
52
- filePath = path.join(filePath, TS_CONFIG_JSON);
53
- }
54
- if (requestedPath.startsWith(".")) {
55
- filePath = path.resolve(directoryPath, filePath);
56
- }
57
- if (path.isAbsolute(filePath)) {
58
- if (fs$1.existsSync(filePath)) {
59
- if (fs$1.statSync(filePath).isFile()) {
60
- return filePath;
61
- }
62
- } else if (!filePath.endsWith(".json")) {
63
- const jsonPath = `${filePath}.json`;
64
- if (fs$1.existsSync(jsonPath)) {
65
- return jsonPath;
66
- }
67
- }
68
- return void 0;
69
- }
70
- const [orgOrName, ...remaining] = requestedPath.split("/");
71
- const packageName = orgOrName.startsWith("@") ? `${orgOrName}/${remaining.shift()}` : orgOrName;
72
- const subpath = remaining.join("/");
73
- const pnpApi = getPnpApi();
74
- if (pnpApi) {
75
- const { resolveRequest: resolveWithPnp } = pnpApi;
76
- try {
77
- if (packageName === requestedPath) {
78
- const packageJsonPath2 = resolveWithPnp(path.join(packageName, PACKAGE_JSON), directoryPath);
79
- if (packageJsonPath2) {
80
- const resolvedPath = resolveFromPackageJsonPath(packageJsonPath2, subpath, false, cache);
81
- if (resolvedPath && fs$1.existsSync(resolvedPath)) {
82
- return resolvedPath;
83
- }
84
- }
85
- } else {
86
- let resolved;
87
- try {
88
- resolved = resolveWithPnp(requestedPath, directoryPath, { extensions: [".json"] });
89
- } catch {
90
- resolved = resolveWithPnp(path.join(requestedPath, TS_CONFIG_JSON), directoryPath);
91
- }
92
- if (resolved) {
93
- return resolved;
94
- }
95
- }
96
- } catch {
97
- }
98
- }
99
- const packagePath = fs.findUpSync(
100
- (directory) => {
101
- const path$1 = path.join(directory, "node_modules", packageName);
102
- if (fs$1.existsSync(path$1)) {
103
- return path.join("node_modules", packageName);
104
- }
105
- return void 0;
106
- },
107
- {
108
- cwd: directoryPath,
109
- type: "directory"
110
- }
111
- );
112
- if (!packagePath || !fs$1.statSync(packagePath).isDirectory()) {
113
- return void 0;
114
- }
115
- const packageJsonPath = path.join(packagePath, PACKAGE_JSON);
116
- if (fs$1.existsSync(packageJsonPath)) {
117
- const resolvedPath = resolveFromPackageJsonPath(packageJsonPath, subpath, false, cache);
118
- if (resolvedPath === false) {
119
- return void 0;
120
- }
121
- if (resolvedPath && fs$1.existsSync(resolvedPath) && fs$1.statSync(resolvedPath).isFile()) {
122
- return resolvedPath;
123
- }
124
- }
125
- const fullPackagePath = path.join(packagePath, subpath);
126
- const jsonExtension = fullPackagePath.endsWith(".json");
127
- if (!jsonExtension) {
128
- const fullPackagePathWithJson = `${fullPackagePath}.json`;
129
- if (fs$1.existsSync(fullPackagePathWithJson)) {
130
- return fullPackagePathWithJson;
131
- }
132
- }
133
- if (!fs$1.existsSync(fullPackagePath)) {
134
- return void 0;
135
- }
136
- if (fs$1.statSync(fullPackagePath).isDirectory()) {
137
- const fullPackageJsonPath = path.join(fullPackagePath, PACKAGE_JSON);
138
- if (fs$1.existsSync(fullPackageJsonPath)) {
139
- const resolvedPath = resolveFromPackageJsonPath(fullPackageJsonPath, "", true, cache);
140
- if (resolvedPath && fs$1.existsSync(resolvedPath)) {
141
- return resolvedPath;
142
- }
143
- }
144
- const tsconfigPath = path.join(fullPackagePath, TS_CONFIG_JSON);
145
- if (fs$1.existsSync(tsconfigPath)) {
146
- return tsconfigPath;
147
- }
148
- } else if (jsonExtension) {
149
- return fullPackagePath;
150
- }
151
- return void 0;
152
- };
153
- var resolve_extends_path_default = resolveExtendsPath;
154
-
155
- // src/read-tsconfig.ts
156
- var readJsonc2 = (jsonPath) => jsoncParser.parse(fs.readFileSync(jsonPath));
157
- var normalizePath = (path) => pathe.toNamespacedPath(/^\.{1,2}(?:\/.*)?$/.test(path) ? path : `./${path}`);
158
- var resolveExtends = (extendsPath, fromDirectoryPath, circularExtendsTracker, options) => {
159
- const resolvedExtendsPath = resolve_extends_path_default(extendsPath, fromDirectoryPath);
160
- if (!resolvedExtendsPath) {
161
- throw new error.NotFoundError(`No such file or directory, for '${extendsPath}' found.`);
162
- }
163
- if (circularExtendsTracker.has(resolvedExtendsPath)) {
164
- throw new Error(`Circularity detected while resolving configuration: ${resolvedExtendsPath}`);
165
- }
166
- circularExtendsTracker.add(resolvedExtendsPath);
167
- const extendsDirectoryPath = pathe.dirname(resolvedExtendsPath);
168
- const extendsConfig = internalParseTsConfig(resolvedExtendsPath, options, circularExtendsTracker);
169
- delete extendsConfig.references;
170
- const { compilerOptions } = extendsConfig;
171
- if (compilerOptions) {
172
- const resolvePaths = ["baseUrl", "outDir"];
173
- for (const property of resolvePaths) {
174
- const unresolvedPath = compilerOptions[property];
175
- if (unresolvedPath) {
176
- compilerOptions[property] = pathe.relative(fromDirectoryPath, pathe.join(extendsDirectoryPath, unresolvedPath)).replaceAll("\\", "/") || "./";
177
- }
178
- }
179
- }
180
- if (extendsConfig.files) {
181
- extendsConfig.files = extendsConfig.files.map((file) => pathe.relative(fromDirectoryPath, pathe.join(extendsDirectoryPath, file)));
182
- }
183
- if (extendsConfig.include) {
184
- extendsConfig.include = extendsConfig.include.map((file) => pathe.relative(fromDirectoryPath, pathe.join(extendsDirectoryPath, file)));
185
- }
186
- if (extendsConfig.exclude) {
187
- extendsConfig.exclude = extendsConfig.exclude.map((file) => pathe.relative(fromDirectoryPath, pathe.join(extendsDirectoryPath, file)));
188
- }
189
- return extendsConfig;
190
- };
191
- var internalParseTsConfig = (tsconfigPath, options, circularExtendsTracker = /* @__PURE__ */ new Set()) => {
192
- let config;
193
- try {
194
- config = readJsonc2(tsconfigPath) || {};
195
- } catch {
196
- throw new Error(`Cannot resolve tsconfig at path: ${tsconfigPath}`);
197
- }
198
- if (typeof config !== "object") {
199
- throw new SyntaxError(`Failed to parse tsconfig at: ${tsconfigPath}`);
200
- }
201
- const directoryPath = pathe.dirname(tsconfigPath);
202
- if (config.compilerOptions) {
203
- const { compilerOptions } = config;
204
- if (compilerOptions.paths && !compilerOptions.baseUrl) {
205
- compilerOptions[implicitBaseUrlSymbol] = directoryPath;
206
- }
207
- }
208
- if (config.extends) {
209
- const extendsPathList = Array.isArray(config.extends) ? config.extends : [config.extends];
210
- delete config.extends;
211
- for (const extendsPath of extendsPathList.reverse()) {
212
- const extendsConfig = resolveExtends(extendsPath, directoryPath, new Set(circularExtendsTracker), options);
213
- const merged = {
214
- ...extendsConfig,
215
- ...config,
216
- compilerOptions: {
217
- ...extendsConfig.compilerOptions,
218
- ...config.compilerOptions
219
- }
220
- };
221
- if (extendsConfig.watchOptions) {
222
- merged.watchOptions = {
223
- ...extendsConfig.watchOptions,
224
- ...config.watchOptions
225
- };
226
- }
227
- config = merged;
228
- }
229
- }
230
- if (config.compilerOptions) {
231
- const { compilerOptions } = config;
232
- const normalizedPaths = ["baseUrl", "rootDir"];
233
- for (const property of normalizedPaths) {
234
- const unresolvedPath = compilerOptions[property];
235
- if (unresolvedPath) {
236
- const resolvedBaseUrl = pathe.resolve(directoryPath, unresolvedPath);
237
- const relativeBaseUrl = pathe.relative(directoryPath, resolvedBaseUrl);
238
- compilerOptions[property] = normalizePath(relativeBaseUrl);
239
- }
240
- }
241
- const { outDir } = compilerOptions;
242
- if (outDir) {
243
- if (!Array.isArray(config.exclude)) {
244
- config.exclude = [];
245
- }
246
- if (!config.exclude.includes(outDir)) {
247
- config.exclude.push(outDir);
248
- }
249
- compilerOptions.outDir = normalizePath(outDir);
250
- }
251
- if (options?.tscCompatible && compilerOptions.module === "node16") {
252
- compilerOptions.allowSyntheticDefaultImports = compilerOptions.allowSyntheticDefaultImports ?? true;
253
- compilerOptions.esModuleInterop = compilerOptions.esModuleInterop ?? true;
254
- compilerOptions.moduleDetection = compilerOptions.moduleDetection ?? "force";
255
- compilerOptions.moduleResolution = compilerOptions.moduleResolution ?? "node16";
256
- compilerOptions.target = compilerOptions.target ?? "es2022";
257
- compilerOptions.useDefineForClassFields = compilerOptions.useDefineForClassFields ?? true;
258
- }
259
- if (options?.tscCompatible && compilerOptions.strict) {
260
- compilerOptions.noImplicitAny = compilerOptions.noImplicitAny ?? true;
261
- compilerOptions.noImplicitThis = compilerOptions.noImplicitThis ?? true;
262
- compilerOptions.strictNullChecks = compilerOptions.strictNullChecks ?? true;
263
- compilerOptions.strictFunctionTypes = compilerOptions.strictFunctionTypes ?? true;
264
- compilerOptions.strictBindCallApply = compilerOptions.strictBindCallApply ?? true;
265
- compilerOptions.strictPropertyInitialization = compilerOptions.strictPropertyInitialization ?? true;
266
- compilerOptions.alwaysStrict = compilerOptions.alwaysStrict ?? true;
267
- compilerOptions.useUnknownInCatchVariables = compilerOptions.useUnknownInCatchVariables ?? true;
268
- }
269
- if (options?.tscCompatible && compilerOptions.isolatedModules) {
270
- compilerOptions.preserveConstEnums = compilerOptions.preserveConstEnums ?? true;
271
- }
272
- if (options?.tscCompatible && compilerOptions.esModuleInterop) {
273
- compilerOptions.allowSyntheticDefaultImports = compilerOptions.allowSyntheticDefaultImports ?? true;
274
- }
275
- if (options?.tscCompatible && compilerOptions.target === "esnext") {
276
- compilerOptions.useDefineForClassFields = compilerOptions.useDefineForClassFields ?? true;
277
- }
278
- } else {
279
- config.compilerOptions = {};
280
- }
281
- if (config.files) {
282
- config.files = config.files.map((element) => normalizePath(element));
283
- }
284
- if (config.include) {
285
- config.include = config.include.map((element) => pathe.normalize(element));
286
- }
287
- if (config.watchOptions) {
288
- const { watchOptions } = config;
289
- if (watchOptions.excludeDirectories) {
290
- watchOptions.excludeDirectories = watchOptions.excludeDirectories.map((excludePath) => pathe.resolve(directoryPath, excludePath));
291
- }
292
- }
293
- return config;
294
- };
295
- var implicitBaseUrlSymbol = Symbol("implicitBaseUrl");
296
- var readTsConfig = (tsconfigPath, options) => internalParseTsConfig(tsconfigPath, options);
297
-
298
- // src/tsconfig.ts
299
- var TsConfigFileCache = /* @__PURE__ */ new Map();
300
- var findTsConfig = async (cwd, options = {}) => {
301
- const configFileName = options.configFileName ?? "tsconfig.json";
302
- let filePath = await fs.findUp(configFileName, {
303
- ...cwd && { cwd },
304
- type: "file"
305
- });
306
- if (!filePath) {
307
- filePath = await fs.findUp("jsconfig.json", {
308
- ...cwd && { cwd },
309
- type: "file"
310
- });
311
- }
312
- if (!filePath) {
313
- throw new error.NotFoundError(`No such file or directory, for ${configFileName} or jsconfig.json found.`);
314
- }
315
- const cache = options.cache && typeof options.cache !== "boolean" ? options.cache : TsConfigFileCache;
316
- if (options.cache && cache.has(filePath)) {
317
- return cache.get(filePath);
318
- }
319
- const output = {
320
- config: readTsConfig(filePath),
321
- path: filePath
322
- };
323
- if (options.cache) {
324
- cache.set(filePath, output);
325
- }
326
- return output;
327
- };
328
- var findTSConfig = findTsConfig;
329
- var findTsConfigSync = (cwd, options = {}) => {
330
- const configFileName = options.configFileName ?? "tsconfig.json";
331
- let filePath = fs.findUpSync(configFileName, {
332
- ...cwd && { cwd },
333
- type: "file"
334
- });
335
- if (!filePath) {
336
- filePath = fs.findUpSync("jsconfig.json", {
337
- ...cwd && { cwd },
338
- type: "file"
339
- });
340
- }
341
- if (!filePath) {
342
- throw new error.NotFoundError(`No such file or directory, for ${configFileName} or jsconfig.json found.`);
343
- }
344
- const cache = options.cache && typeof options.cache !== "boolean" ? options.cache : TsConfigFileCache;
345
- if (options.cache && cache.has(filePath)) {
346
- return cache.get(filePath);
347
- }
348
- const output = {
349
- config: readTsConfig(filePath),
350
- path: filePath
351
- };
352
- if (options.cache) {
353
- cache.set(filePath, output);
354
- }
355
- return output;
356
- };
357
- var findTSConfigSync = findTsConfigSync;
358
- var writeTsConfig = async (data, options = {}) => {
359
- const { cwd, ...writeOptions } = options;
360
- const directory = utils.toPath(options.cwd ?? process.cwd());
361
- await fs.writeJson(pathe.join(directory, "tsconfig.json"), data, writeOptions);
362
- };
363
- var writeTSConfig = writeTsConfig;
364
-
365
- exports.findTSConfig = findTSConfig;
366
- exports.findTSConfigSync = findTSConfigSync;
367
- exports.findTsConfig = findTsConfig;
368
- exports.findTsConfigSync = findTsConfigSync;
369
- exports.implicitBaseUrlSymbol = implicitBaseUrlSymbol;
370
- exports.readTsConfig = readTsConfig;
371
- exports.writeTSConfig = writeTSConfig;
372
- exports.writeTsConfig = writeTsConfig;
373
- //# sourceMappingURL=out.js.map
374
- //# sourceMappingURL=chunk-WXFZK4G3.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/tsconfig.ts","../src/read-tsconfig.ts","../src/utils/resolve-extends-path.ts"],"names":["findUpSync","NotFoundError","join","readFileSync","parse","resolve","packageJsonPath","readJsonc"],"mappings":";AACA,SAAS,QAAQ,cAAAA,aAAY,iBAAiB;AAC9C,SAAS,iBAAAC,sBAAqB;AAC9B,SAAS,cAAc;AACvB,SAAS,QAAAC,aAAY;;;ACErB,SAAS,gBAAAC,qBAAoB;AAC7B,SAAS,qBAAqB;AAC9B,SAAS,SAAAC,cAAa;AACtB,SAAS,SAAS,QAAAF,OAAM,WAAW,UAAU,WAAAG,UAAS,wBAAwB;;;ACH9E,SAAS,YAAY,gBAAgB;AACrC,OAAO,YAAY;AACnB,SAAS,YAAY,MAAM,eAAe;AAE1C,SAAS,YAAY,oBAAoB;AACzC,SAAS,aAAa;AAEtB,SAAS,sBAAsB;AAK/B,IAAM,YAAY,CAAC,aAAqB,MAAM,aAAa,QAAQ,CAAW;AAE9E,IAAM,YAAY,MAAM;AACpB,QAAM,EAAE,WAAW,IAAI;AAGvB,SAAO,aAAa,QAAQ,IAAI,CAAC;AACrC;AAEA,IAAM,6BAA6B,CAAC,iBAAyB,SAAiB,eAAyB,UAA0B;AAC7H,QAAM,WAAW,8BAA8B,eAAe,IAAI,OAAO,IAAI,aAAa;AAE1F,MAAI,OAAO,IAAI,QAAQ,GAAG;AACtB,WAAO,MAAM,IAAI,QAAQ;AAAA,EAC7B;AAEA,QAAM,cAAc,UAAU,eAAe;AAE7C,MAAI,CAAC,aAAa;AACd,WAAO;AAAA,EACX;AAEA,MAAI,eAAe,WAAW;AAE9B,MAAI,CAAC,iBAAkB,YAA4B,SAAS;AACxD,QAAI;AACA,YAAM,CAAC,cAAc,IAAI,eAAgB,YAA4B,SAA2B,SAAS,CAAC,WAAW,OAAO,CAAC;AAE7H,qBAAe;AAAA,IACnB,QAAQ;AAEJ,aAAO;AAAA,IACX;AAAA,EACJ,WAAW,CAAC,WAAY,YAA4B,UAAU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M,IAAI,QAAQ;AAAA,EAC7B;AAEA,QAAM,SAAS;AAAA,IACX,QAAQ,aAAa,QAAQ;AAAA,IAC7B,MAAM;AAAA,EACV;AAEA,MAAI,QAAQ,OAAO;AACf,UAAM,IAAI,UAAU,MAAM;AAAA,EAC9B;AAEA,SAAO;AACX;AAGO,IAAM,mBAAmB;AAWzB,IAAM,gBAAgB,OAAO,MAAoB,UAAqD,CAAC,MAAqB;AAC/H,QAAM,EAAE,KAAK,GAAG,aAAa,IAAI;AAEjC,QAAM,YAAY,OAAO,QAAQ,OAAO,QAAQ,IAAI,CAAC;AAErD,QAAM,UAAUC,MAAK,WAAW,eAAe,GAAG,MAAM,YAAY;AACxE;AAGO,IAAM,gBAAgB","sourcesContent":["import type { WriteJsonOptions } from \"@visulima/fs\";\nimport { findUp, findUpSync, writeJson } from \"@visulima/fs\";\nimport { NotFoundError } from \"@visulima/fs/error\";\nimport { toPath } from \"@visulima/fs/utils\";\nimport { join } from \"pathe\";\nimport type { TsConfigJson } from \"type-fest\";\n\nimport { readTsConfig } from \"./read-tsconfig\";\nimport type { TsConfigJsonResolved } from \"./types\";\n\ntype Options = {\n cache?: Map<string, TsConfigJsonResolved> | boolean;\n configFileName?: string;\n};\n\nconst TsConfigFileCache = new Map<string, TsConfigResult>();\n\nexport type TsConfigResult = {\n config: TsConfigJsonResolved;\n path: string;\n};\n\n/**\n * An asynchronous function that retrieves the TSConfig by searching for the \"tsconfig.json\" first,\n * second attempt is to look for the \"jsconfig.json\" file from a given current working directory.\n *\n * @param cwd - Optional. The current working directory from which to search for the \"tsconfig.json\" file.\n * The type of `cwd` is `string`.\n * @returns A `Promise` that resolves to the TSConfig result object.\n * The return type of the function is `Promise<TsConfigResult>`.\n * @throws An `Error` when the \"tsconfig.json\" file is not found.\n */\nexport const findTsConfig = async (cwd?: URL | string, options: Options = {}): Promise<TsConfigResult> => {\n const configFileName = options.configFileName ?? \"tsconfig.json\";\n\n let filePath = await findUp(configFileName, {\n ...(cwd && { cwd }),\n type: \"file\",\n });\n\n if (!filePath) {\n filePath = await findUp(\"jsconfig.json\", {\n ...(cwd && { cwd }),\n type: \"file\",\n });\n }\n\n if (!filePath) {\n throw new NotFoundError(`No such file or directory, for ${configFileName} or jsconfig.json found.`);\n }\n\n const cache = options.cache && typeof options.cache !== \"boolean\" ? options.cache : TsConfigFileCache;\n\n if (options.cache && cache.has(filePath)) {\n return cache.get(filePath) as TsConfigResult;\n }\n\n const output = {\n config: readTsConfig(filePath),\n path: filePath,\n };\n\n if (options.cache) {\n cache.set(filePath, output);\n }\n\n return output;\n};\n\n// @deprecate Please use `findTsConfig` instead.\nexport const findTSConfig = findTsConfig;\n\nexport const findTsConfigSync = (cwd?: URL | string, options: Options = {}): TsConfigResult => {\n const configFileName = options.configFileName ?? \"tsconfig.json\";\n\n let filePath = findUpSync(configFileName, {\n ...(cwd && { cwd }),\n type: \"file\",\n });\n\n if (!filePath) {\n filePath = findUpSync(\"jsconfig.json\", {\n ...(cwd && { cwd }),\n type: \"file\",\n });\n }\n\n if (!filePath) {\n throw new NotFoundError(`No such file or directory, for ${configFileName} or jsconfig.json found.`);\n }\n\n const cache = options.cache && typeof options.cache !== \"boolean\" ? options.cache : TsConfigFileCache;\n\n if (options.cache && cache.has(filePath)) {\n return cache.get(filePath) as TsConfigResult;\n }\n\n const output = {\n config: readTsConfig(filePath),\n path: filePath,\n };\n\n if (options.cache) {\n cache.set(filePath, output);\n }\n\n return output;\n};\n\n// @deprecate Please use `findTsConfigSync` instead.\nexport const findTSConfigSync = findTsConfigSync;\n\n/**\n * An asynchronous function that writes the provided TypeScript configuration object to a tsconfig.json file.\n *\n * @param tsConfig - The TypeScript configuration object to write. The type of `tsConfig` is `TsConfigJson`.\n * @param options - Optional. The write options and the current working directory. The type of `options` is an\n * intersection type of `WriteOptions` and a Record type with an optional `cwd` key of type `string`.\n * @returns A `Promise` that resolves when the tsconfig.json file has been written.\n * The return type of function is `Promise<void>`.\n */\nexport const writeTsConfig = async (data: TsConfigJson, options: WriteJsonOptions & { cwd?: URL | string } = {}): Promise<void> => {\n const { cwd, ...writeOptions } = options;\n\n const directory = toPath(options.cwd ?? process.cwd());\n\n await writeJson(join(directory, \"tsconfig.json\"), data, writeOptions);\n};\n\n// @deprecate Please use `writeTsconfig` instead.\nexport const writeTSConfig = writeTsConfig;\n// eslint-disable-next-line import/no-unused-modules\nexport { implicitBaseUrlSymbol } from \"./read-tsconfig\";\n","/**\n * A modified version of `readTsconfig` from `https://github.com/privatenumber/get-tsconfig/blob/develop/src/parse-tsconfig/index.ts`\n *\n * MIT License\n * Copyright (c) Hiroki Osame <hiroki.osame@gmail.com>\n */\nimport { readFileSync } from \"@visulima/fs\";\nimport { NotFoundError } from \"@visulima/fs/error\";\nimport { parse } from \"jsonc-parser\";\nimport { dirname, join, normalize, relative, resolve, toNamespacedPath } from \"pathe\";\nimport type { TsConfigJson } from \"type-fest\";\n\nimport type { TsConfigJsonResolved } from \"./types\";\nimport resolveExtendsPath from \"./utils/resolve-extends-path\";\n\ntype Options = {\n tscCompatible?: boolean;\n};\n\nconst readJsonc = (jsonPath: string) => parse(readFileSync(jsonPath) as string) as unknown;\n// eslint-disable-next-line security/detect-unsafe-regex\nconst normalizePath = (path: string): string => toNamespacedPath(/^\\.{1,2}(?:\\/.*)?$/.test(path) ? path : `./${path}`);\n\nconst resolveExtends = (extendsPath: string, fromDirectoryPath: string, circularExtendsTracker: Set<string>, options?: Options) => {\n const resolvedExtendsPath = resolveExtendsPath(extendsPath, fromDirectoryPath);\n\n if (!resolvedExtendsPath) {\n throw new NotFoundError(`No such file or directory, for '${extendsPath}' found.`);\n }\n\n if (circularExtendsTracker.has(resolvedExtendsPath)) {\n throw new Error(`Circularity detected while resolving configuration: ${resolvedExtendsPath}`);\n }\n\n circularExtendsTracker.add(resolvedExtendsPath);\n\n const extendsDirectoryPath = dirname(resolvedExtendsPath);\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n const extendsConfig = internalParseTsConfig(resolvedExtendsPath, options, circularExtendsTracker);\n\n delete extendsConfig.references;\n\n const { compilerOptions } = extendsConfig;\n\n if (compilerOptions) {\n const resolvePaths = [\"baseUrl\", \"outDir\"] as const;\n\n // eslint-disable-next-line no-loops/no-loops,no-restricted-syntax\n for (const property of resolvePaths) {\n // eslint-disable-next-line security/detect-object-injection\n const unresolvedPath = compilerOptions[property];\n\n if (unresolvedPath) {\n // eslint-disable-next-line security/detect-object-injection\n compilerOptions[property] = relative(fromDirectoryPath, join(extendsDirectoryPath, unresolvedPath)).replaceAll(\"\\\\\", \"/\") || \"./\";\n }\n }\n }\n\n if (extendsConfig.files) {\n extendsConfig.files = extendsConfig.files.map((file) => relative(fromDirectoryPath, join(extendsDirectoryPath, file)));\n }\n\n if (extendsConfig.include) {\n extendsConfig.include = extendsConfig.include.map((file) => relative(fromDirectoryPath, join(extendsDirectoryPath, file)));\n }\n\n if (extendsConfig.exclude) {\n extendsConfig.exclude = extendsConfig.exclude.map((file) => relative(fromDirectoryPath, join(extendsDirectoryPath, file)));\n }\n\n return extendsConfig;\n};\n\n// eslint-disable-next-line sonarjs/cognitive-complexity\nconst internalParseTsConfig = (tsconfigPath: string, options?: Options, circularExtendsTracker = new Set<string>()): TsConfigJsonResolved => {\n /**\n * Decided not to cache the TsConfigJsonResolved object because it's\n * mutable.\n *\n * Note how `resolveExtends` can call `readTsconfig` rescursively\n * and actually mutates the object. It can also be mutated in\n * user-land.\n *\n * By only caching fs results, we can avoid serving mutated objects\n */\n let config: TsConfigJson;\n\n try {\n config = readJsonc(tsconfigPath) || {};\n } catch {\n throw new Error(`Cannot resolve tsconfig at path: ${tsconfigPath}`);\n }\n\n if (typeof config !== \"object\") {\n throw new SyntaxError(`Failed to parse tsconfig at: ${tsconfigPath}`);\n }\n\n const directoryPath = dirname(tsconfigPath);\n\n if (config.compilerOptions) {\n const { compilerOptions } = config;\n if (compilerOptions.paths && !compilerOptions.baseUrl) {\n type WithImplicitBaseUrl = TsConfigJson.CompilerOptions & {\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n [implicitBaseUrlSymbol]: string;\n };\n // eslint-disable-next-line security/detect-object-injection,@typescript-eslint/no-use-before-define\n (compilerOptions as WithImplicitBaseUrl)[implicitBaseUrlSymbol] = directoryPath;\n }\n }\n\n if (config.extends) {\n const extendsPathList = Array.isArray(config.extends) ? config.extends : [config.extends];\n\n delete config.extends;\n\n // eslint-disable-next-line no-loops/no-loops,no-restricted-syntax,etc/no-assign-mutated-array\n for (const extendsPath of extendsPathList.reverse()) {\n const extendsConfig = resolveExtends(extendsPath, directoryPath, new Set(circularExtendsTracker), options);\n const merged = {\n ...extendsConfig,\n ...config,\n\n compilerOptions: {\n ...extendsConfig.compilerOptions,\n ...config.compilerOptions,\n },\n };\n\n if (extendsConfig.watchOptions) {\n merged.watchOptions = {\n ...extendsConfig.watchOptions,\n ...config.watchOptions,\n };\n }\n\n config = merged;\n }\n }\n\n if (config.compilerOptions) {\n const { compilerOptions } = config;\n const normalizedPaths = [\"baseUrl\", \"rootDir\"] as const;\n\n // eslint-disable-next-line no-loops/no-loops,no-restricted-syntax\n for (const property of normalizedPaths) {\n // eslint-disable-next-line security/detect-object-injection\n const unresolvedPath = compilerOptions[property];\n\n if (unresolvedPath) {\n const resolvedBaseUrl = resolve(directoryPath, unresolvedPath);\n const relativeBaseUrl = relative(directoryPath, resolvedBaseUrl);\n\n // eslint-disable-next-line security/detect-object-injection\n compilerOptions[property] = normalizePath(relativeBaseUrl);\n }\n }\n\n const { outDir } = compilerOptions;\n\n if (outDir) {\n if (!Array.isArray(config.exclude)) {\n config.exclude = [];\n }\n\n if (!config.exclude.includes(outDir)) {\n config.exclude.push(outDir);\n }\n\n compilerOptions.outDir = normalizePath(outDir);\n }\n\n if (options?.tscCompatible && compilerOptions.module === \"node16\") {\n compilerOptions.allowSyntheticDefaultImports = compilerOptions.allowSyntheticDefaultImports ?? true;\n compilerOptions.esModuleInterop = compilerOptions.esModuleInterop ?? true;\n compilerOptions.moduleDetection = compilerOptions.moduleDetection ?? \"force\";\n compilerOptions.moduleResolution = compilerOptions.moduleResolution ?? \"node16\";\n compilerOptions.target = compilerOptions.target ?? \"es2022\";\n compilerOptions.useDefineForClassFields = compilerOptions.useDefineForClassFields ?? true;\n }\n\n if (options?.tscCompatible && compilerOptions.strict) {\n compilerOptions.noImplicitAny = compilerOptions.noImplicitAny ?? true;\n compilerOptions.noImplicitThis = compilerOptions.noImplicitThis ?? true;\n compilerOptions.strictNullChecks = compilerOptions.strictNullChecks ?? true;\n compilerOptions.strictFunctionTypes = compilerOptions.strictFunctionTypes ?? true;\n compilerOptions.strictBindCallApply = compilerOptions.strictBindCallApply ?? true;\n compilerOptions.strictPropertyInitialization = compilerOptions.strictPropertyInitialization ?? true;\n compilerOptions.alwaysStrict = compilerOptions.alwaysStrict ?? true;\n compilerOptions.useUnknownInCatchVariables = compilerOptions.useUnknownInCatchVariables ?? true;\n }\n\n if (options?.tscCompatible && compilerOptions.isolatedModules) {\n compilerOptions.preserveConstEnums = compilerOptions.preserveConstEnums ?? true;\n }\n\n if (options?.tscCompatible && compilerOptions.esModuleInterop) {\n compilerOptions.allowSyntheticDefaultImports = compilerOptions.allowSyntheticDefaultImports ?? true;\n }\n\n if (options?.tscCompatible && compilerOptions.target === \"esnext\") {\n compilerOptions.useDefineForClassFields = compilerOptions.useDefineForClassFields ?? true;\n }\n } else {\n config.compilerOptions = {};\n }\n\n if (config.files) {\n config.files = config.files.map((element) => normalizePath(element));\n }\n\n if (config.include) {\n config.include = config.include.map((element) => normalize(element));\n }\n\n if (config.watchOptions) {\n const { watchOptions } = config;\n\n if (watchOptions.excludeDirectories) {\n watchOptions.excludeDirectories = watchOptions.excludeDirectories.map((excludePath) => resolve(directoryPath, excludePath));\n }\n }\n\n return config;\n};\n\nexport const implicitBaseUrlSymbol = Symbol(\"implicitBaseUrl\");\nexport const readTsConfig = (tsconfigPath: string, options?: Options): TsConfigJsonResolved => internalParseTsConfig(tsconfigPath, options);\n","/**\n * A modified version of `resolveExtendsPath` from `https://github.com/privatenumber/get-tsconfig/blob/develop/src/parse-tsconfig/resolve-extends-path.ts`\n *\n * MIT License\n * Copyright (c) Hiroki Osame <hiroki.osame@gmail.com>\n */\nimport { existsSync, statSync } from \"node:fs\";\nimport Module from \"node:module\";\nimport { isAbsolute, join, resolve } from \"node:path\";\n\nimport { findUpSync, readFileSync } from \"@visulima/fs\";\nimport { parse } from \"jsonc-parser\";\nimport type { PathConditions } from \"resolve-pkg-maps\";\nimport { resolveExports } from \"resolve-pkg-maps\";\nimport type { PackageJson } from \"type-fest\";\n\nimport type { Cache } from \"../types\";\n\nconst readJsonc = (jsonPath: string) => parse(readFileSync(jsonPath) as string) as unknown;\n\nconst getPnpApi = () => {\n const { findPnpApi } = Module;\n\n // https://yarnpkg.com/advanced/pnpapi/#requirepnpapi\n return findPnpApi?.(process.cwd());\n};\n\nconst resolveFromPackageJsonPath = (packageJsonPath: string, subpath: string, ignoreExports?: boolean, cache?: Cache<string>) => {\n const cacheKey = `resolveFromPackageJsonPath:${packageJsonPath}:${subpath}:${ignoreExports}`;\n\n if (cache?.has(cacheKey)) {\n return cache.get(cacheKey);\n }\n\n const packageJson = readJsonc(packageJsonPath);\n\n if (!packageJson) {\n return undefined;\n }\n\n let resolvedPath = subpath || \"tsconfig.json\";\n\n if (!ignoreExports && (packageJson as PackageJson).exports) {\n try {\n const [resolvedExport] = resolveExports((packageJson as PackageJson).exports as PathConditions, subpath, [\"require\", \"types\"]);\n\n resolvedPath = resolvedExport as string;\n } catch {\n // Block\n return false;\n }\n } else if (!subpath && (packageJson as PackageJson).tsconfig) {\n resolvedPath = (packageJson as PackageJson).tsconfig as string;\n }\n\n resolvedPath = join(packageJsonPath, \"..\", resolvedPath);\n\n cache?.set(cacheKey, resolvedPath);\n\n return resolvedPath;\n};\n\nconst PACKAGE_JSON = \"package.json\";\nconst TS_CONFIG_JSON = \"tsconfig.json\";\n\n// eslint-disable-next-line sonarjs/cognitive-complexity\nconst resolveExtendsPath = (requestedPath: string, directoryPath: string, cache?: Cache<string>): string | undefined => {\n let filePath = requestedPath;\n\n if (requestedPath === \"..\") {\n filePath = join(filePath, TS_CONFIG_JSON);\n }\n\n if (requestedPath.startsWith(\".\")) {\n filePath = resolve(directoryPath, filePath);\n }\n\n if (isAbsolute(filePath)) {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (existsSync(filePath)) {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (statSync(filePath).isFile()) {\n return filePath;\n }\n } else if (!filePath.endsWith(\".json\")) {\n const jsonPath = `${filePath}.json`;\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (existsSync(jsonPath)) {\n return jsonPath;\n }\n }\n\n return undefined;\n }\n\n const [orgOrName, ...remaining] = requestedPath.split(\"/\");\n const packageName = ((orgOrName as string).startsWith(\"@\") ? `${orgOrName}/${remaining.shift()}` : orgOrName) as string;\n const subpath = remaining.join(\"/\");\n\n const pnpApi = getPnpApi();\n\n if (pnpApi) {\n const { resolveRequest: resolveWithPnp } = pnpApi;\n\n try {\n if (packageName === requestedPath) {\n const packageJsonPath = resolveWithPnp(join(packageName, PACKAGE_JSON), directoryPath);\n\n if (packageJsonPath) {\n const resolvedPath = resolveFromPackageJsonPath(packageJsonPath, subpath, false, cache);\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (resolvedPath && existsSync(resolvedPath)) {\n return resolvedPath;\n }\n }\n } else {\n let resolved: string | null;\n\n try {\n resolved = resolveWithPnp(requestedPath, directoryPath, { extensions: [\".json\"] });\n } catch {\n resolved = resolveWithPnp(join(requestedPath, TS_CONFIG_JSON), directoryPath);\n }\n\n if (resolved) {\n return resolved;\n }\n }\n } catch {\n /* empty */\n }\n }\n\n const packagePath = findUpSync(\n (directory) => {\n const path = join(directory, \"node_modules\", packageName);\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (existsSync(path)) {\n return join(\"node_modules\", packageName);\n }\n\n return undefined;\n },\n {\n cwd: directoryPath,\n type: \"directory\",\n },\n );\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (!packagePath || !statSync(packagePath).isDirectory()) {\n return undefined;\n }\n\n const packageJsonPath = join(packagePath, PACKAGE_JSON);\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (existsSync(packageJsonPath)) {\n const resolvedPath = resolveFromPackageJsonPath(packageJsonPath, subpath, false, cache);\n\n // Blocked\n if (resolvedPath === false) {\n return undefined;\n }\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (resolvedPath && existsSync(resolvedPath) && statSync(resolvedPath).isFile()) {\n return resolvedPath;\n }\n }\n\n const fullPackagePath = join(packagePath, subpath);\n const jsonExtension = fullPackagePath.endsWith(\".json\");\n\n if (!jsonExtension) {\n const fullPackagePathWithJson = `${fullPackagePath}.json`;\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (existsSync(fullPackagePathWithJson)) {\n return fullPackagePathWithJson;\n }\n }\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (!existsSync(fullPackagePath)) {\n return undefined;\n }\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (statSync(fullPackagePath).isDirectory()) {\n const fullPackageJsonPath = join(fullPackagePath, PACKAGE_JSON);\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (existsSync(fullPackageJsonPath)) {\n const resolvedPath = resolveFromPackageJsonPath(fullPackageJsonPath, \"\", true, cache);\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (resolvedPath && existsSync(resolvedPath)) {\n return resolvedPath;\n }\n }\n\n const tsconfigPath = join(fullPackagePath, TS_CONFIG_JSON);\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (existsSync(tsconfigPath)) {\n return tsconfigPath;\n }\n } else if (jsonExtension) {\n return fullPackagePath;\n }\n\n return undefined;\n};\n\nexport default resolveExtendsPath;\n"]}
@@ -1,50 +0,0 @@
1
- import { findPackageManagerSync } from './chunk-IIYQBLPC.js';
2
-
3
- // src/error/package-not-found-error.ts
4
- var PackageNotFoundError = class extends Error {
5
- /**
6
- * @param {string} packageName - The name of the package that was not found.
7
- * @param {string} packageManager - The package manager used to install the package.
8
- */
9
- constructor(packageName, packageManager) {
10
- if (typeof packageName === "string") {
11
- packageName = [packageName];
12
- }
13
- if (packageName.length === 0) {
14
- super("Package was not found.");
15
- return;
16
- }
17
- if (packageManager === void 0) {
18
- try {
19
- const foundManager = findPackageManagerSync();
20
- packageManager = foundManager.packageManager;
21
- } catch {
22
- }
23
- }
24
- if (packageManager === void 0) {
25
- packageManager = "npm";
26
- }
27
- super(`Package '${packageName.join(" ")}' was not found. Please install it using '${packageManager} install ${packageName.join(" ")}'`);
28
- }
29
- // eslint-disable-next-line class-methods-use-this,@typescript-eslint/class-literal-property-style
30
- get code() {
31
- return "PACKAGE_NOT_FOUND";
32
- }
33
- // eslint-disable-next-line class-methods-use-this,@typescript-eslint/explicit-module-boundary-types
34
- set code(_name) {
35
- throw new Error("Cannot overwrite code PACKAGE_NOT_FOUND");
36
- }
37
- // eslint-disable-next-line class-methods-use-this,@typescript-eslint/class-literal-property-style
38
- get name() {
39
- return "PackageNotFoundError";
40
- }
41
- // eslint-disable-next-line class-methods-use-this,@typescript-eslint/explicit-module-boundary-types
42
- set name(_name) {
43
- throw new Error("Cannot overwrite name of PackageNotFoundError");
44
- }
45
- };
46
- var package_not_found_error_default = PackageNotFoundError;
47
-
48
- export { package_not_found_error_default };
49
- //# sourceMappingURL=out.js.map
50
- //# sourceMappingURL=chunk-YLCN7EVV.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/error/package-not-found-error.ts"],"names":[],"mappings":";;;;;AAKA,IAAM,uBAAN,cAAmC,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA,EAK9B,YAAY,aAAgC,gBAAyB;AACxE,QAAI,OAAO,gBAAgB,UAAU;AAEjC,oBAAc,CAAC,WAAW;AAAA,IAC9B;AAEA,QAAI,YAAY,WAAW,GAAG;AAC1B,YAAM,wBAAwB;AAC9B;AAAA,IACJ;AAEA,QAAI,mBAAmB,QAAW;AAC9B,UAAI;AACA,cAAM,eAAe,uBAAuB;AAG5C,yBAAiB,aAAa;AAAA,MAClC,QAAQ;AAAA,MAER;AAAA,IACJ;AAEA,QAAI,mBAAmB,QAAW;AAE9B,uBAAiB;AAAA,IACrB;AAEA,UAAM,YAAY,YAAY,KAAK,GAAG,CAAC,6CAA6C,cAAc,YAAY,YAAY,KAAK,GAAG,CAAC,GAAG;AAAA,EAC1I;AAAA;AAAA,EAGA,IAAW,OAAe;AACtB,WAAO;AAAA,EACX;AAAA;AAAA,EAGA,IAAW,KAAK,OAAO;AACnB,UAAM,IAAI,MAAM,yCAAyC;AAAA,EAC7D;AAAA;AAAA,EAGA,IAAoB,OAAe;AAC/B,WAAO;AAAA,EACX;AAAA;AAAA,EAGA,IAAoB,KAAK,OAAO;AAC5B,UAAM,IAAI,MAAM,+CAA+C;AAAA,EACnE;AACJ;AAEA,IAAO,kCAAQ","sourcesContent":["import { findPackageManagerSync } from \"../package-manager\";\n\n/**\n * Error thrown when a package was not found.\n */\nclass PackageNotFoundError extends Error {\n /**\n * @param {string} packageName - The name of the package that was not found.\n * @param {string} packageManager - The package manager used to install the package.\n */\n public constructor(packageName: string[] | string, packageManager?: string) {\n if (typeof packageName === \"string\") {\n // eslint-disable-next-line no-param-reassign\n packageName = [packageName];\n }\n\n if (packageName.length === 0) {\n super(\"Package was not found.\");\n return;\n }\n\n if (packageManager === undefined) {\n try {\n const foundManager = findPackageManagerSync();\n\n // eslint-disable-next-line no-param-reassign\n packageManager = foundManager.packageManager;\n } catch {\n // Empty\n }\n }\n\n if (packageManager === undefined) {\n // eslint-disable-next-line no-param-reassign\n packageManager = \"npm\";\n }\n\n super(`Package '${packageName.join(\" \")}' was not found. Please install it using '${packageManager} install ${packageName.join(\" \")}'`);\n }\n\n // eslint-disable-next-line class-methods-use-this,@typescript-eslint/class-literal-property-style\n public get code(): string {\n return \"PACKAGE_NOT_FOUND\";\n }\n\n // eslint-disable-next-line class-methods-use-this,@typescript-eslint/explicit-module-boundary-types\n public set code(_name) {\n throw new Error(\"Cannot overwrite code PACKAGE_NOT_FOUND\");\n }\n\n // eslint-disable-next-line class-methods-use-this,@typescript-eslint/class-literal-property-style\n public override get name(): string {\n return \"PackageNotFoundError\";\n }\n\n // eslint-disable-next-line class-methods-use-this,@typescript-eslint/explicit-module-boundary-types\n public override set name(_name) {\n throw new Error(\"Cannot overwrite name of PackageNotFoundError\");\n }\n}\n\nexport default PackageNotFoundError;\n"]}
@@ -1,56 +0,0 @@
1
- 'use strict';
2
-
3
- var chunkIK5YSYLX_cjs = require('./chunk-IK5YSYLX.cjs');
4
- var fs$1 = require('fs');
5
- var fs = require('@visulima/fs');
6
- var error = require('@visulima/fs/error');
7
- var pathe = require('pathe');
8
-
9
- var findMonorepoRoot = async (cwd) => {
10
- const workspaceFilePath = await fs.findUp(["lerna.json", "turbo.json"], {
11
- type: "file",
12
- ...cwd && { cwd }
13
- });
14
- if (workspaceFilePath?.endsWith("lerna.json")) {
15
- const lerna = await fs.readJson(workspaceFilePath);
16
- if (lerna.useWorkspaces || lerna.packages) {
17
- return {
18
- path: pathe.dirname(workspaceFilePath),
19
- strategy: "lerna"
20
- };
21
- }
22
- }
23
- const isTurbo = workspaceFilePath?.endsWith("turbo.json");
24
- try {
25
- const { packageManager, path } = await chunkIK5YSYLX_cjs.findPackageManager(cwd);
26
- if (["npm", "yarn"].includes(packageManager)) {
27
- const packageJsonFilePath = pathe.join(path, "package.json");
28
- if (fs$1.existsSync(packageJsonFilePath)) {
29
- const packageJson = fs$1.readFileSync(pathe.join(path, "package.json"), "utf8");
30
- if (packageJson.includes("workspaces")) {
31
- return {
32
- path,
33
- strategy: isTurbo ? "turbo" : packageManager
34
- };
35
- }
36
- }
37
- } else if (packageManager === "pnpm") {
38
- const pnpmWorkspacesFilePath = pathe.join(path, "pnpm-workspace.yaml");
39
- if (fs$1.existsSync(pnpmWorkspacesFilePath)) {
40
- return {
41
- path,
42
- strategy: isTurbo ? "turbo" : "pnpm"
43
- };
44
- }
45
- }
46
- } catch (error$1) {
47
- if (!(error$1 instanceof error.NotFoundError)) {
48
- throw error$1;
49
- }
50
- }
51
- throw new Error(`No monorepo root could be found upwards from the directory ${cwd} using lerna, yarn, pnpm, or npm as indicators.`);
52
- };
53
-
54
- exports.findMonorepoRoot = findMonorepoRoot;
55
- //# sourceMappingURL=out.js.map
56
- //# sourceMappingURL=chunk-YOQXHFU3.cjs.map