@visulima/package 1.7.4 → 1.7.6

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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,18 @@
1
+ ## @visulima/package [1.7.6](https://github.com/visulima/visulima/compare/@visulima/package@1.7.5...@visulima/package@1.7.6) (2024-05-07)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **package:** symlinks shouldn't be resolved to a real path ([#394](https://github.com/visulima/visulima/issues/394)) ([c504321](https://github.com/visulima/visulima/commit/c504321a05de761eda2c310eaf2e9b272fa0832e))
7
+
8
+ ## @visulima/package [1.7.5](https://github.com/visulima/visulima/compare/@visulima/package@1.7.4...@visulima/package@1.7.5) (2024-05-06)
9
+
10
+
11
+
12
+ ### Dependencies
13
+
14
+ * **@visulima/fs:** upgraded to 2.1.0
15
+
1
16
  ## @visulima/package [1.7.4](https://github.com/visulima/visulima/compare/@visulima/package@1.7.3...@visulima/package@1.7.4) (2024-05-03)
2
17
 
3
18
 
@@ -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 { parse } from 'jsonc-parser';
6
+ import { existsSync, statSync } from 'node:fs';
7
+ import $ 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 L=o=>parse(readFileSync(o)),G=()=>{let{findPnpApi:o}=$;return o?.(process.cwd())},w=(o,s,c,t)=>{let n=`resolveFromPackageJsonPath:${o}:${s}:${c}`;if(t?.has(n))return t.get(n);let e=L(o);if(!e)return;let i=s||"tsconfig.json";if(!c&&e.exports)try{let[l]=resolveExports(e.exports,s,["require","types"]);i=l;}catch{return !1}else !s&&e.tsconfig&&(i=e.tsconfig);return i=join$1(o,"..",i),t?.set(n,i),i},v="package.json",P="tsconfig.json",K=(o,s,c)=>{let t=o;if(o===".."&&(t=join$1(t,P)),o.startsWith(".")&&(t=resolve$1(s,t)),isAbsolute(t)){if(existsSync(t)){if(statSync(t).isFile())return t}else if(!t.endsWith(".json")){let r=`${t}.json`;if(existsSync(r))return r}return}let[n,...e]=o.split("/"),i=n.startsWith("@")?`${n}/${e.shift()}`:n,l=e.join("/"),a=G();if(a){let{resolveRequest:r}=a;try{if(i===o){let f=r(join$1(i,v),s);if(f){let h=w(f,l,!1,c);if(h&&existsSync(h))return h}}else {let f;try{f=r(o,s,{extensions:[".json"]});}catch{f=r(join$1(o,P),s);}if(f)return f}}catch{}}let u=findUpSync(r=>{let f=join$1(r,"node_modules",i);if(existsSync(f))return join$1("node_modules",i)},{cwd:s,type:"directory"});if(!u||!statSync(u).isDirectory())return;let g=join$1(u,v);if(existsSync(g)){let r=w(g,l,!1,c);if(r===!1)return;if(r&&existsSync(r)&&statSync(r).isFile())return r}let m=join$1(u,l),J=m.endsWith(".json");if(!J){let r=`${m}.json`;if(existsSync(r))return r}if(existsSync(m)){if(statSync(m).isDirectory()){let r=join$1(m,v);if(existsSync(r)){let h=w(r,"",!0,c);if(h&&existsSync(h))return h}let f=join$1(m,P);if(existsSync(f))return f}else if(J)return m}},F=K;var Z=o=>parse(readFileSync(o)),O=o=>toNamespacedPath(/^\.{1,2}(?:\/.*)?$/.test(o)?o:`./${o}`),q=(o,s,c,t)=>{let n=F(o,s);if(!n)throw new NotFoundError(`No such file or directory, for '${o}' found.`);if(c.has(n))throw new Error(`Circularity detected while resolving configuration: ${n}`);c.add(n);let e=dirname(n),i=U(n,t,c);delete i.references;let{compilerOptions:l}=i;if(l){let a=["baseUrl","outDir"];for(let u of a){let g=l[u];g&&(l[u]=relative(s,join(e,g)).replaceAll("\\","/")||"./");}}return i.files&&(i.files=i.files.map(a=>relative(s,join(e,a)))),i.include&&(i.include=i.include.map(a=>relative(s,join(e,a)))),i.exclude&&(i.exclude=i.exclude.map(a=>relative(s,join(e,a)))),i},U=(o,s,c=new Set)=>{let t;try{t=Z(o)||{};}catch{throw new Error(`Cannot resolve tsconfig at path: ${o}`)}if(typeof t!="object")throw new SyntaxError(`Failed to parse tsconfig at: ${o}`);let n=dirname(o);if(t.compilerOptions){let{compilerOptions:e}=t;e.paths&&!e.baseUrl&&(e[I]=n);}if(t.extends){let e=Array.isArray(t.extends)?t.extends:[t.extends];delete t.extends;for(let i of e.reverse()){let l=q(i,n,new Set(c),s),a={...l,...t,compilerOptions:{...l.compilerOptions,...t.compilerOptions}};l.watchOptions&&(a.watchOptions={...l.watchOptions,...t.watchOptions}),t=a;}}if(t.compilerOptions){let{compilerOptions:e}=t,i=["baseUrl","rootDir"];for(let a of i){let u=e[a];if(u){let g=resolve(n,u),m=relative(n,g);e[a]=O(m);}}let{outDir:l}=e;l&&(Array.isArray(t.exclude)||(t.exclude=[]),t.exclude.includes(l)||t.exclude.push(l),e.outDir=O(l)),s?.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),s?.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),s?.tscCompatible&&e.isolatedModules&&(e.preserveConstEnums=e.preserveConstEnums??!0),s?.tscCompatible&&e.esModuleInterop&&(e.allowSyntheticDefaultImports=e.allowSyntheticDefaultImports??!0),s?.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(i=>resolve(n,i)));}return t},I=Symbol("implicitBaseUrl"),T=(o,s)=>U(o,s);var A=new Map,se=async(o,s={})=>{let c=s.configFileName??"tsconfig.json",t=await findUp(c,{...o&&{cwd:o},type:"file"});if(t||(t=await findUp("jsconfig.json",{...o&&{cwd:o},type:"file"})),!t)throw new NotFoundError(`No such file or directory, for ${c} or jsconfig.json found.`);let n=s.cache&&typeof s.cache!="boolean"?s.cache:A;if(s.cache&&n.has(t))return n.get(t);let e={config:T(t),path:t};return s.cache&&n.set(t,e),e},Se=se,ne=(o,s={})=>{let c=s.configFileName??"tsconfig.json",t=findUpSync(c,{...o&&{cwd:o},type:"file"});if(t||(t=findUpSync("jsconfig.json",{...o&&{cwd:o},type:"file"})),!t)throw new NotFoundError(`No such file or directory, for ${c} or jsconfig.json found.`);let n=s.cache&&typeof s.cache!="boolean"?s.cache:A;if(s.cache&&n.has(t))return n.get(t);let e={config:T(t),path:t};return s.cache&&n.set(t,e),e},je=ne,ie=async(o,s={})=>{let{cwd:c,...t}=s,n=toPath(s.cwd??process.cwd());await writeJson(join(n,"tsconfig.json"),o,t);},Fe=ie;
12
+
13
+ export { I as a, T as b, se as c, Se as d, ne as e, je as f, ie as g, Fe as h };
14
+ //# sourceMappingURL=out.js.map
15
+ //# sourceMappingURL=chunk-NKFQML4S.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","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","normalizePath","resolveExtends","extendsPath","fromDirectoryPath","circularExtendsTracker","options","resolvedExtendsPath","extendsDirectoryPath","extendsConfig","internalParseTsConfig","compilerOptions","resolvePaths","property","unresolvedPath","file","config","implicitBaseUrlSymbol","extendsPathList","merged","normalizedPaths","resolvedBaseUrl","relativeBaseUrl","outDir","element","watchOptions","excludePath","readTsConfig","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,eAC7B,OAAS,iBAAAH,MAAqB,qBAC9B,OAAS,SAAAI,MAAa,eACtB,OAAS,WAAAC,EAAS,QAAAH,EAAM,aAAAI,EAAW,YAAAC,EAAU,WAAAC,EAAS,oBAAAC,MAAwB,QCH9E,OAAS,cAAAC,EAAY,YAAAC,MAAgB,UACrC,OAAOC,MAAY,cACnB,OAAS,cAAAC,EAAY,QAAAX,EAAM,WAAAM,MAAe,YAE1C,OAAS,cAAAV,EAAY,gBAAAK,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,OAAO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\"@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"]}
@@ -0,0 +1,28 @@
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 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 _=o=>jsoncParser.parse(fs.readFileSync(o)),L=()=>{let{findPnpApi:o}=A__default.default;return o?.(process.cwd())},w=(o,s,c,t)=>{let n=`resolveFromPackageJsonPath:${o}:${s}:${c}`;if(t?.has(n))return t.get(n);let e=_(o);if(!e)return;let i=s||"tsconfig.json";if(!c&&e.exports)try{let[l]=resolvePkgMaps.resolveExports(e.exports,s,["require","types"]);i=l;}catch{return !1}else !s&&e.tsconfig&&(i=e.tsconfig);return i=path.join(o,"..",i),t?.set(n,i),i},v="package.json",P="tsconfig.json",G=(o,s,c)=>{let t=o;if(o===".."&&(t=path.join(t,P)),o.startsWith(".")&&(t=path.resolve(s,t)),path.isAbsolute(t)){if(fs$1.existsSync(t)){if(fs$1.statSync(t).isFile())return t}else if(!t.endsWith(".json")){let r=`${t}.json`;if(fs$1.existsSync(r))return r}return}let[n,...e]=o.split("/"),i=n.startsWith("@")?`${n}/${e.shift()}`:n,l=e.join("/"),a=L();if(a){let{resolveRequest:r}=a;try{if(i===o){let f=r(path.join(i,v),s);if(f){let h=w(f,l,!1,c);if(h&&fs$1.existsSync(h))return h}}else {let f;try{f=r(o,s,{extensions:[".json"]});}catch{f=r(path.join(o,P),s);}if(f)return f}}catch{}}let u=fs.findUpSync(r=>{let f=path.join(r,"node_modules",i);if(fs$1.existsSync(f))return path.join("node_modules",i)},{cwd:s,type:"directory"});if(!u||!fs$1.statSync(u).isDirectory())return;let g=path.join(u,v);if(fs$1.existsSync(g)){let r=w(g,l,!1,c);if(r===!1)return;if(r&&fs$1.existsSync(r)&&fs$1.statSync(r).isFile())return r}let m=path.join(u,l),J=m.endsWith(".json");if(!J){let r=`${m}.json`;if(fs$1.existsSync(r))return r}if(fs$1.existsSync(m)){if(fs$1.statSync(m).isDirectory()){let r=path.join(m,v);if(fs$1.existsSync(r)){let h=w(r,"",!0,c);if(h&&fs$1.existsSync(h))return h}let f=path.join(m,P);if(fs$1.existsSync(f))return f}else if(J)return m}},j=G;var Y=o=>jsoncParser.parse(fs.readFileSync(o)),O=o=>pathe.toNamespacedPath(/^\.{1,2}(?:\/.*)?$/.test(o)?o:`./${o}`),Z=(o,s,c,t)=>{let n=j(o,s);if(!n)throw new error.NotFoundError(`No such file or directory, for '${o}' found.`);if(c.has(n))throw new Error(`Circularity detected while resolving configuration: ${n}`);c.add(n);let e=pathe.dirname(n),i=k(n,t,c);delete i.references;let{compilerOptions:l}=i;if(l){let a=["baseUrl","outDir"];for(let u of a){let g=l[u];g&&(l[u]=pathe.relative(s,pathe.join(e,g)).replaceAll("\\","/")||"./");}}return i.files&&(i.files=i.files.map(a=>pathe.relative(s,pathe.join(e,a)))),i.include&&(i.include=i.include.map(a=>pathe.relative(s,pathe.join(e,a)))),i.exclude&&(i.exclude=i.exclude.map(a=>pathe.relative(s,pathe.join(e,a)))),i},k=(o,s,c=new Set)=>{let t;try{t=Y(o)||{};}catch{throw new Error(`Cannot resolve tsconfig at path: ${o}`)}if(typeof t!="object")throw new SyntaxError(`Failed to parse tsconfig at: ${o}`);let n=pathe.dirname(o);if(t.compilerOptions){let{compilerOptions:e}=t;e.paths&&!e.baseUrl&&(e[U]=n);}if(t.extends){let e=Array.isArray(t.extends)?t.extends:[t.extends];delete t.extends;for(let i of e.reverse()){let l=Z(i,n,new Set(c),s),a={...l,...t,compilerOptions:{...l.compilerOptions,...t.compilerOptions}};l.watchOptions&&(a.watchOptions={...l.watchOptions,...t.watchOptions}),t=a;}}if(t.compilerOptions){let{compilerOptions:e}=t,i=["baseUrl","rootDir"];for(let a of i){let u=e[a];if(u){let g=pathe.resolve(n,u),m=pathe.relative(n,g);e[a]=O(m);}}let{outDir:l}=e;l&&(Array.isArray(t.exclude)||(t.exclude=[]),t.exclude.includes(l)||t.exclude.push(l),e.outDir=O(l)),s?.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),s?.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),s?.tscCompatible&&e.isolatedModules&&(e.preserveConstEnums=e.preserveConstEnums??!0),s?.tscCompatible&&e.esModuleInterop&&(e.allowSyntheticDefaultImports=e.allowSyntheticDefaultImports??!0),s?.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(i=>pathe.resolve(n,i)));}return t},U=Symbol("implicitBaseUrl"),T=(o,s)=>k(o,s);var D=new Map,oe=async(o,s={})=>{let c=s.configFileName??"tsconfig.json",t=await fs.findUp(c,{...o&&{cwd:o},type:"file"});if(t||(t=await fs.findUp("jsconfig.json",{...o&&{cwd:o},type:"file"})),!t)throw new error.NotFoundError(`No such file or directory, for ${c} or jsconfig.json found.`);let n=s.cache&&typeof s.cache!="boolean"?s.cache:D;if(s.cache&&n.has(t))return n.get(t);let e={config:T(t),path:t};return s.cache&&n.set(t,e),e},Je=oe,se=(o,s={})=>{let c=s.configFileName??"tsconfig.json",t=fs.findUpSync(c,{...o&&{cwd:o},type:"file"});if(t||(t=fs.findUpSync("jsconfig.json",{...o&&{cwd:o},type:"file"})),!t)throw new error.NotFoundError(`No such file or directory, for ${c} or jsconfig.json found.`);let n=s.cache&&typeof s.cache!="boolean"?s.cache:D;if(s.cache&&n.has(t))return n.get(t);let e={config:T(t),path:t};return s.cache&&n.set(t,e),e},Se=se,ne=async(o,s={})=>{let{cwd:c,...t}=s,n=utils.toPath(s.cwd??process.cwd());await fs.writeJson(pathe.join(n,"tsconfig.json"),o,t);},je=ne;
18
+
19
+ exports.a = U;
20
+ exports.b = T;
21
+ exports.c = oe;
22
+ exports.d = Je;
23
+ exports.e = se;
24
+ exports.f = Se;
25
+ exports.g = ne;
26
+ exports.h = je;
27
+ //# sourceMappingURL=out.js.map
28
+ //# sourceMappingURL=chunk-PGLLS3ER.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","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","normalizePath","resolveExtends","extendsPath","fromDirectoryPath","circularExtendsTracker","options","resolvedExtendsPath","extendsDirectoryPath","extendsConfig","internalParseTsConfig","compilerOptions","resolvePaths","property","unresolvedPath","file","config","implicitBaseUrlSymbol","extendsPathList","merged","normalizedPaths","resolvedBaseUrl","relativeBaseUrl","outDir","element","watchOptions","excludePath","readTsConfig","TsConfigFileCache","findTsConfig","cwd","configFileName","output","findTSConfig","findTsConfigSync","findTSConfigSync","writeTsConfig","data","writeOptions","writeTSConfig"],"mappings":"AACA,OAAS,UAAAA,EAAQ,cAAAC,EAAY,aAAAC,MAAiB,eAC9C,OAAS,iBAAAC,MAAqB,qBAC9B,OAAS,UAAAC,OAAc,qBACvB,OAAS,QAAAC,OAAY,QCErB,OAAS,gBAAAC,MAAoB,eAC7B,OAAS,iBAAAH,MAAqB,qBAC9B,OAAS,SAAAI,MAAa,eACtB,OAAS,WAAAC,EAAS,QAAAH,EAAM,aAAAI,EAAW,YAAAC,EAAU,WAAAC,EAAS,oBAAAC,MAAwB,QCH9E,OAA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GAAmBD,GAWnBE,GAAgB,MAAOC,EAAoB/B,EAAqD,CAAC,IAAqB,CAC/H,GAAM,CAAE,IAAAwB,EAAK,GAAGQ,CAAa,EAAIhC,EAE3Bb,EAAYxC,GAAOqD,EAAQ,KAAO,QAAQ,IAAI,CAAC,EAErD,MAAMvD,EAAUG,GAAKuC,EAAW,eAAe,EAAG4C,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// 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"]}
package/dist/index.cjs CHANGED
@@ -5,7 +5,7 @@ var chunkWOLHGXXJ_cjs = require('./chunk-WOLHGXXJ.cjs');
5
5
  var chunk5YG33J5B_cjs = require('./chunk-5YG33J5B.cjs');
6
6
  var chunkKSXRMTAQ_cjs = require('./chunk-KSXRMTAQ.cjs');
7
7
  var chunk6KT7465D_cjs = require('./chunk-6KT7465D.cjs');
8
- var chunk3I7BDTA7_cjs = require('./chunk-3I7BDTA7.cjs');
8
+ var chunkPGLLS3ER_cjs = require('./chunk-PGLLS3ER.cjs');
9
9
  var fs = require('fs');
10
10
  var process = require('process');
11
11
  var fs$1 = require('@visulima/fs');
@@ -75,31 +75,31 @@ Object.defineProperty(exports, 'writePackageJsonSync', {
75
75
  });
76
76
  Object.defineProperty(exports, 'findTSConfig', {
77
77
  enumerable: true,
78
- get: function () { return chunk3I7BDTA7_cjs.d; }
78
+ get: function () { return chunkPGLLS3ER_cjs.d; }
79
79
  });
80
80
  Object.defineProperty(exports, 'findTSConfigSync', {
81
81
  enumerable: true,
82
- get: function () { return chunk3I7BDTA7_cjs.f; }
82
+ get: function () { return chunkPGLLS3ER_cjs.f; }
83
83
  });
84
84
  Object.defineProperty(exports, 'findTsConfig', {
85
85
  enumerable: true,
86
- get: function () { return chunk3I7BDTA7_cjs.c; }
86
+ get: function () { return chunkPGLLS3ER_cjs.c; }
87
87
  });
88
88
  Object.defineProperty(exports, 'findTsConfigSync', {
89
89
  enumerable: true,
90
- get: function () { return chunk3I7BDTA7_cjs.e; }
90
+ get: function () { return chunkPGLLS3ER_cjs.e; }
91
91
  });
92
92
  Object.defineProperty(exports, 'implicitBaseUrlSymbol', {
93
93
  enumerable: true,
94
- get: function () { return chunk3I7BDTA7_cjs.a; }
94
+ get: function () { return chunkPGLLS3ER_cjs.a; }
95
95
  });
96
96
  Object.defineProperty(exports, 'readTsConfig', {
97
97
  enumerable: true,
98
- get: function () { return chunk3I7BDTA7_cjs.b; }
98
+ get: function () { return chunkPGLLS3ER_cjs.b; }
99
99
  });
100
100
  Object.defineProperty(exports, 'writeTSConfig', {
101
101
  enumerable: true,
102
- get: function () { return chunk3I7BDTA7_cjs.h; }
102
+ get: function () { return chunkPGLLS3ER_cjs.h; }
103
103
  });
104
104
  exports.findCacheDirectory = L;
105
105
  exports.findCacheDirectorySync = j;
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@ import { a, b } from './chunk-I3QTPGJY.js';
4
4
  export { a as findPackageRoot, b as findPackageRootSync } from './chunk-I3QTPGJY.js';
5
5
  export { a as findLockFile, b as findLockFileSync, c as findPackageManager, d as findPackageManagerSync, e as getPackageManagerVersion, f as identifyInitiatingPackageManager } from './chunk-44SW4DFI.js';
6
6
  export { a as findPackageJson, b as findPackageJsonSync, e as parsePackageJson, c as writePackageJson, d as writePackageJsonSync } from './chunk-U4YVB3GU.js';
7
- export { d as findTSConfig, f as findTSConfigSync, c as findTsConfig, e as findTsConfigSync, a as implicitBaseUrlSymbol, b as readTsConfig, h as writeTSConfig } from './chunk-YUFKVE42.js';
7
+ export { d as findTSConfig, f as findTSConfigSync, c as findTsConfig, e as findTsConfigSync, a as implicitBaseUrlSymbol, b as readTsConfig, h as writeTSConfig } from './chunk-NKFQML4S.js';
8
8
  import { existsSync } from 'node:fs';
9
9
  import { env, cwd } from 'node:process';
10
10
  import { isAccessible, W_OK, isAccessibleSync, ensureDirSync } from '@visulima/fs';
package/dist/tsconfig.cjs CHANGED
@@ -1,36 +1,36 @@
1
1
  'use strict';
2
2
 
3
- var chunk3I7BDTA7_cjs = require('./chunk-3I7BDTA7.cjs');
3
+ var chunkPGLLS3ER_cjs = require('./chunk-PGLLS3ER.cjs');
4
4
 
5
5
 
6
6
 
7
7
  Object.defineProperty(exports, 'findTSConfig', {
8
8
  enumerable: true,
9
- get: function () { return chunk3I7BDTA7_cjs.d; }
9
+ get: function () { return chunkPGLLS3ER_cjs.d; }
10
10
  });
11
11
  Object.defineProperty(exports, 'findTSConfigSync', {
12
12
  enumerable: true,
13
- get: function () { return chunk3I7BDTA7_cjs.f; }
13
+ get: function () { return chunkPGLLS3ER_cjs.f; }
14
14
  });
15
15
  Object.defineProperty(exports, 'findTsConfig', {
16
16
  enumerable: true,
17
- get: function () { return chunk3I7BDTA7_cjs.c; }
17
+ get: function () { return chunkPGLLS3ER_cjs.c; }
18
18
  });
19
19
  Object.defineProperty(exports, 'findTsConfigSync', {
20
20
  enumerable: true,
21
- get: function () { return chunk3I7BDTA7_cjs.e; }
21
+ get: function () { return chunkPGLLS3ER_cjs.e; }
22
22
  });
23
23
  Object.defineProperty(exports, 'implicitBaseUrlSymbol', {
24
24
  enumerable: true,
25
- get: function () { return chunk3I7BDTA7_cjs.a; }
25
+ get: function () { return chunkPGLLS3ER_cjs.a; }
26
26
  });
27
27
  Object.defineProperty(exports, 'writeTSConfig', {
28
28
  enumerable: true,
29
- get: function () { return chunk3I7BDTA7_cjs.h; }
29
+ get: function () { return chunkPGLLS3ER_cjs.h; }
30
30
  });
31
31
  Object.defineProperty(exports, 'writeTsConfig', {
32
32
  enumerable: true,
33
- get: function () { return chunk3I7BDTA7_cjs.g; }
33
+ get: function () { return chunkPGLLS3ER_cjs.g; }
34
34
  });
35
35
  //# sourceMappingURL=out.js.map
36
36
  //# sourceMappingURL=tsconfig.cjs.map
package/dist/tsconfig.js CHANGED
@@ -1,3 +1,3 @@
1
- export { d as findTSConfig, f as findTSConfigSync, c as findTsConfig, e as findTsConfigSync, a as implicitBaseUrlSymbol, h as writeTSConfig, g as writeTsConfig } from './chunk-YUFKVE42.js';
1
+ export { d as findTSConfig, f as findTSConfigSync, c as findTsConfig, e as findTsConfigSync, a as implicitBaseUrlSymbol, h as writeTSConfig, g as writeTsConfig } from './chunk-NKFQML4S.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.7.4",
3
+ "version": "1.7.6",
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",
@@ -137,19 +137,19 @@
137
137
  "LICENSE.md"
138
138
  ],
139
139
  "dependencies": {
140
- "@visulima/fs": "2.0.9",
140
+ "@visulima/fs": "2.1.0",
141
141
  "jsonc-parser": "^3.2.1",
142
- "normalize-package-data": "^6.0.0",
142
+ "normalize-package-data": "^6.0.1",
143
143
  "pathe": "^1.1.2",
144
144
  "resolve-pkg-maps": "^1.0.0",
145
- "type-fest": "^4.18.1"
145
+ "type-fest": "^4.18.2"
146
146
  },
147
147
  "devDependencies": {
148
148
  "@anolilab/eslint-config": "^15.0.3",
149
149
  "@anolilab/prettier-config": "^5.0.14",
150
150
  "@anolilab/semantic-release-preset": "^8.0.3",
151
151
  "@babel/core": "^7.24.5",
152
- "@pnpm/exe": "^9.0.6",
152
+ "@pnpm/exe": "^9.1.0",
153
153
  "@rushstack/eslint-plugin-security": "^0.8.1",
154
154
  "@total-typescript/ts-reset": "^0.5.1",
155
155
  "@types/node": "18.18.14",
@@ -166,7 +166,7 @@
166
166
  "eslint-plugin-vitest": "^0.4.1",
167
167
  "eslint-plugin-vitest-globals": "^1.5.0",
168
168
  "execa": "^8.0.1",
169
- "npm": "^10.7.0",
169
+ "npm": "^9.9.3",
170
170
  "prettier": "^3.2.5",
171
171
  "rimraf": "^5.0.5",
172
172
  "semantic-release": "^23.0.8",
@@ -1,28 +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 _=s=>jsoncParser.parse(fs.readFileSync(s)),L=()=>{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=_(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",G=(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=L();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 d=path.join(f,a),C=d.endsWith(".json");if(!C){let c=`${d}.json`;if(fs$1.existsSync(c))return c}if(fs$1.existsSync(d)){if(fs$1.statSync(d).isDirectory()){let c=path.join(d,P);if(fs$1.existsSync(c)){let h=v(c,"",!0,l);if(h&&fs$1.existsSync(h))return h}let p=path.join(d,T);if(fs$1.existsSync(p))return p}else if(C)return d}},j=G;var 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[U]=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 d=pathe.resolve(i,g),C=pathe.relative(i,d);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},U=Symbol("implicitBaseUrl"),S=(s,o)=>k(s,o);var D=new Map,oe=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:D;if(o.cache&&t.has(n))return t.get(n);let i={config:S(n),path:n};return o.cache&&t.set(n,i),i},je=oe,ne=(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:D;if(o.cache&&t.has(n))return t.get(n);let i={config:S(n),path:n};return o.cache&&t.set(n,i),i},Fe=ne,ie=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);},be=ie;
18
-
19
- exports.a = U;
20
- exports.b = S;
21
- exports.c = oe;
22
- exports.d = je;
23
- exports.e = ne;
24
- exports.f = Fe;
25
- exports.g = ie;
26
- exports.h = be;
27
- //# sourceMappingURL=out.js.map
28
- //# sourceMappingURL=chunk-3I7BDTA7.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","normalizePath","resolveExtends","extendsPath","fromDirectoryPath","circularExtendsTracker","options","resolvedExtendsPath","extendsDirectoryPath","extendsConfig","internalParseTsConfig","compilerOptions","resolvePaths","property","unresolvedPath","file","realTsconfigPath","config","implicitBaseUrlSymbol","extendsPathList","merged","normalizedPaths","resolvedBaseUrl","relativeBaseUrl","outDir","element","watchOptions","excludePath","readTsConfig","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,MAA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AAQ,OACR/B,EAAM,IAAIU,EAAUgD,CAAM,EAGvBA,CACX,EAGaG,GAAmBD,GAWnBE,GAAgB,MAAOC,EAAoBhC,EAAqD,CAAC,IAAqB,CAC/H,GAAM,CAAE,IAAAyB,EAAK,GAAGQ,CAAa,EAAIjC,EAE3Bb,EAAYzC,GAAOsD,EAAQ,KAAO,QAAQ,IAAI,CAAC,EAErD,MAAMxD,GAAUG,GAAKwC,EAAW,eAAe,EAAG6C,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// 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 { 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 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 // 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,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 $ 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 L=s=>parse(readFileSync(s)),G=()=>{let{findPnpApi:s}=$;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=L(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",K=(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=G();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 d=join$1(f,a),C=d.endsWith(".json");if(!C){let c=`${d}.json`;if(existsSync(c))return c}if(existsSync(d)){if(statSync(d).isDirectory()){let c=join$1(d,P);if(existsSync(c)){let h=v(c,"",!0,l);if(h&&existsSync(h))return h}let p=join$1(d,T);if(existsSync(p))return p}else if(C)return d}},F=K;var 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=U(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},U=(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[I]=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 d=resolve(i,g),C=relative(i,d);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},I=Symbol("implicitBaseUrl"),S=(s,o)=>U(s,o);var A=new Map,ne=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:A;if(o.cache&&t.has(n))return t.get(n);let i={config:S(n),path:n};return o.cache&&t.set(n,i),i},Fe=ne,ie=(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:A;if(o.cache&&t.has(n))return t.get(n);let i={config:S(n),path:n};return o.cache&&t.set(n,i),i},be=ie,re=async(s,o={})=>{let{cwd:l,...n}=o,t=toPath(o.cwd??process.cwd());await writeJson(join(t,"tsconfig.json"),s,n);},ke=re;
12
-
13
- export { I as a, S as b, ne as c, Fe as d, ie as e, be as f, re as g, ke as h };
14
- //# sourceMappingURL=out.js.map
15
- //# sourceMappingURL=chunk-YUFKVE42.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","normalizePath","resolveExtends","extendsPath","fromDirectoryPath","circularExtendsTracker","options","resolvedExtendsPath","extendsDirectoryPath","extendsConfig","internalParseTsConfig","compilerOptions","resolvePaths","property","unresolvedPath","file","realTsconfigPath","config","implicitBaseUrlSymbol","extendsPathList","merged","normalizedPaths","resolvedBaseUrl","relativeBaseUrl","outDir","element","watchOptions","excludePath","readTsConfig","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,QAA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S,OAAOA,EAAQ,OAAU,UAAYA,EAAQ,MAAQuB,EAEpF,GAAIvB,EAAQ,OAAS/B,EAAM,IAAIU,CAAQ,EACnC,OAAOV,EAAM,IAAIU,CAAQ,EAG7B,IAAMgD,EAAS,CACX,OAAQL,EAAa3C,CAAQ,EAC7B,KAAMA,CACV,EAEA,OAAIqB,EAAQ,OACR/B,EAAM,IAAIU,EAAUgD,CAAM,EAGvBA,CACX,EAGaG,GAAmBD,GAWnBE,GAAgB,MAAOC,EAAoBhC,EAAqD,CAAC,IAAqB,CAC/H,GAAM,CAAE,IAAAyB,EAAK,GAAGQ,CAAa,EAAIjC,EAE3Bb,EAAYzC,GAAOsD,EAAQ,KAAO,QAAQ,IAAI,CAAC,EAErD,MAAMxD,GAAUG,GAAKwC,EAAW,eAAe,EAAG6C,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// 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 { 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 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 // 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"]}