@visulima/tsconfig 1.0.3 → 1.0.5

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,30 @@
1
+ ## @visulima/tsconfig [1.0.5](https://github.com/visulima/visulima/compare/@visulima/tsconfig@1.0.4...@visulima/tsconfig@1.0.5) (2024-07-21)
2
+
3
+ ### Bug Fixes
4
+
5
+ * resolve relative path extends in parent directory ([300a108](https://github.com/visulima/visulima/commit/300a1083217480103e6310b992c51c7d9c6085fa))
6
+
7
+ ### Styles
8
+
9
+ * cs fixes ([070c702](https://github.com/visulima/visulima/commit/070c7022724d9f51c6dd034fa498874c377374a1))
10
+ * cs fixes ([ee5ed6f](https://github.com/visulima/visulima/commit/ee5ed6f31bdabcfacdb0d1abd1eff2cc6207cefc))
11
+
12
+ ### Miscellaneous Chores
13
+
14
+ * added private true into fixture package.json files ([4a9494c](https://github.com/visulima/visulima/commit/4a9494c642fa98f224505a1d231b5af4e73d6c79))
15
+ * updated dev dependencies and sorted the package.json ([9571572](https://github.com/visulima/visulima/commit/95715725a8ed053ca24fd1405a55205c79342ecb))
16
+
17
+ ## @visulima/tsconfig [1.0.4](https://github.com/visulima/visulima/compare/@visulima/tsconfig@1.0.3...@visulima/tsconfig@1.0.4) (2024-07-02)
18
+
19
+ ### Miscellaneous Chores
20
+
21
+ * changed typescript version back to 5.4.5 ([55d28bb](https://github.com/visulima/visulima/commit/55d28bbdc103718d19f844034b38a0e8e5af798a))
22
+
23
+
24
+ ### Dependencies
25
+
26
+ * **@visulima/fs:** upgraded to 2.1.10
27
+
1
28
  ## @visulima/tsconfig [1.0.3](https://github.com/visulima/visulima/compare/@visulima/tsconfig@1.0.2...@visulima/tsconfig@1.0.3) (2024-07-02)
2
29
 
3
30
  ### Miscellaneous Chores
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var N=Object.defineProperty;var w=(n,s)=>N(n,"name",{value:s,configurable:!0});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("@visulima/fs"),F=require("@visulima/fs/error"),r=require("@visulima/path"),T=require("jsonc-parser"),u=require("node:fs"),q=require("node:module"),k=require("resolve-pkg-maps"),D=require("@visulima/fs/utils"),J=w(n=>n&&typeof n=="object"&&"default"in n?n.default:n,"_interopDefaultCompat"),M=J(q);var _=Object.defineProperty,S=w((n,s)=>_(n,"name",{value:s,configurable:!0}),"d");const B=S(n=>T.parse(h.readFileSync(n)),"readJsonc"),z=S(()=>{const{findPnpApi:n}=M;return n?.(process.cwd())},"getPnpApi"),C=S((n,s,c,t)=>{const o=`resolveFromPackageJsonPath:${n}:${s}:${c}`;if(t?.has(o))return t.get(o);const e=B(n);if(!e)return;let i=s||"tsconfig.json";if(!c&&e.exports)try{const[a]=k.resolveExports(e.exports,s,["require","types"]);i=a}catch{return!1}else!s&&e.tsconfig&&(i=e.tsconfig);return i=r.join(n,"..",i),t?.set(o,i),i},"resolveFromPackageJsonPath"),x="package.json",v="tsconfig.json",W=S((n,s,c)=>{let t=n;if(n===".."&&(t=r.join(t,v)),n.startsWith(".")&&(t=r.resolve(s,t)),r.isAbsolute(t)){if(u.existsSync(t)){if(u.statSync(t).isFile())return t}else if(!t.endsWith(".json")){const l=`${t}.json`;if(u.existsSync(l))return l}return}const[o,...e]=n.split("/"),i=o.startsWith("@")?`${o}/${e.shift()}`:o,a=e.join("/"),f=z();if(f){const{resolveRequest:l}=f;try{if(i===n){const d=l(r.join(i,x),s);if(d){const g=C(d,a,!1,c);if(g&&u.existsSync(g))return g}}else{let d;try{d=l(n,s,{extensions:[".json"]})}catch{d=l(r.join(n,v),s)}if(d)return d}}catch{}}const p=h.findUpSync(l=>{const d=r.join(l,"node_modules",i);if(u.existsSync(d))return r.join("node_modules",i)},{cwd:s,type:"directory"});if(!p||!u.statSync(p).isDirectory())return;const m=r.join(p,x);if(u.existsSync(m)){const l=C(m,a,!1,c);if(l===!1)return;if(l&&u.existsSync(l)&&u.statSync(l).isFile())return l}const y=r.join(p,a),P=y.endsWith(".json");if(!P){const l=`${y}.json`;if(u.existsSync(l))return l}if(u.existsSync(y)){if(u.statSync(y).isDirectory()){const l=r.join(y,x);if(u.existsSync(l)){const g=C(l,"",!0,c);if(g&&u.existsSync(g))return g}const d=r.join(y,v);if(u.existsSync(d))return d}else if(P)return y}},"resolveExtendsPath");var R=Object.defineProperty,j=w((n,s)=>R(n,"name",{value:s,configurable:!0}),"c");const V=j(n=>T.parse(h.readFileSync(n)),"readJsonc"),b=j(n=>r.toNamespacedPath(/^\.{1,2}(?:\/.*)?$/.test(n)?n:`./${n}`),"normalizePath"),G=j((n,s,c,t)=>{const o=W(n,s);if(!o)throw new F.NotFoundError(`No such file or directory, for '${n}' found.`);if(c.has(o))throw new Error(`Circularity detected while resolving configuration: ${o}`);c.add(o);const e=r.dirname(o),i=$(o,t,c);delete i.references;const{compilerOptions:a}=i;if(a){const f=["baseUrl","outDir"];for(const p of f){const m=a[p];m&&(a[p]=r.relative(s,r.join(e,m)).replaceAll("\\","/")||"./")}}return i.files&&(i.files=i.files.map(f=>r.relative(s,r.join(e,f)))),i.include&&(i.include=i.include.map(f=>r.relative(s,r.join(e,f)))),i.exclude&&(i.exclude=i.exclude.map(f=>r.relative(s,r.join(e,f)))),i},"resolveExtends"),$=j((n,s,c=new Set)=>{let t;try{t=V(n)||{}}catch{throw new Error(`Cannot resolve tsconfig at path: ${n}`)}if(typeof t!="object")throw new SyntaxError(`Failed to parse tsconfig at: ${n}`);const o=r.dirname(n);if(t.compilerOptions){const{compilerOptions:e}=t;e.paths&&!e.baseUrl&&(e[I]=o)}if(t.extends){const e=Array.isArray(t.extends)?t.extends:[t.extends];delete t.extends;for(const i of e.reverse()){const a=G(i,o,new Set(c),s),f={...a,...t,compilerOptions:{...a.compilerOptions,...t.compilerOptions}};a.watchOptions&&(f.watchOptions={...a.watchOptions,...t.watchOptions}),t=f}}if(t.compilerOptions){const{compilerOptions:e}=t,i=["baseUrl","rootDir"];for(const f of i){const p=e[f];if(p){const m=r.resolve(o,p),y=r.relative(o,m);e[f]=b(y)}}const{outDir:a}=e;a&&(Array.isArray(t.exclude)||(t.exclude=[]),t.exclude.includes(a)||t.exclude.push(a),e.outDir=b(a)),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=>b(e))),t.include&&(t.include=t.include.map(e=>r.normalize(e))),t.watchOptions){const{watchOptions:e}=t;e.excludeDirectories&&(e.excludeDirectories=e.excludeDirectories.map(i=>r.resolve(o,i)))}return t},"internalParseTsConfig"),I=Symbol("implicitBaseUrl"),O=j((n,s)=>$(n,s),"readTsConfig");var H=Object.defineProperty,U=w((n,s)=>H(n,"name",{value:s,configurable:!0}),"s");const A=new Map,K=U(async(n,s={})=>{const c=s.configFileName??"tsconfig.json";let t=await h.findUp(c,{...n&&{cwd:n},type:"file"});if(t||(t=await h.findUp("jsconfig.json",{...n&&{cwd:n},type:"file"})),!t)throw new F.NotFoundError(`No such file or directory, for ${c} or jsconfig.json found.`);const o=s.cache&&typeof s.cache!="boolean"?s.cache:A;if(s.cache&&o.has(t))return o.get(t);const e={config:O(t),path:t};return s.cache&&o.set(t,e),e},"findTsConfig"),L=U((n,s={})=>{const c=s.configFileName??"tsconfig.json";let t=h.findUpSync(c,{...n&&{cwd:n},type:"file"});if(t||(t=h.findUpSync("jsconfig.json",{...n&&{cwd:n},type:"file"})),!t)throw new F.NotFoundError(`No such file or directory, for ${c} or jsconfig.json found.`);const o=s.cache&&typeof s.cache!="boolean"?s.cache:A;if(s.cache&&o.has(t))return o.get(t);const e={config:O(t),path:t};return s.cache&&o.set(t,e),e},"findTsConfigSync");var Q=Object.defineProperty,E=w((n,s)=>Q(n,"name",{value:s,configurable:!0}),"r");const X=E(async(n,s={})=>{const{cwd:c,...t}=s,o=D.toPath(c??process.cwd());await h.writeJson(r.join(o,"tsconfig.json"),n,t)},"writeTsConfig"),Y=E((n,s={})=>{const{cwd:c,...t}=s,o=D.toPath(c??process.cwd());h.writeJsonSync(r.join(o,"tsconfig.json"),n,t)},"writeTsConfigSync");exports.findTsConfig=K;exports.findTsConfigSync=L;exports.implicitBaseUrlSymbol=I;exports.readTsConfig=O;exports.writeTsConfig=X;exports.writeTsConfigSync=Y;
1
+ "use strict";var N=Object.defineProperty;var g=(n,s)=>N(n,"name",{value:s,configurable:!0});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@visulima/fs"),x=require("@visulima/fs/error"),r=require("@visulima/path"),P=require("jsonc-parser"),j=require("node:fs"),q=require("node:module"),k=require("resolve-pkg-maps"),T=require("@visulima/fs/utils"),J=g(n=>n&&typeof n=="object"&&"default"in n?n.default:n,"_interopDefaultCompat"),M=J(q);var _=Object.defineProperty,S=g((n,s)=>_(n,"name",{value:s,configurable:!0}),"d");const B=S(n=>P.parse(a.readFileSync(n)),"readJsonc"),z=S(()=>{const{findPnpApi:n}=M;return n?.(process.cwd())},"getPnpApi"),b=S((n,s,c,t)=>{const i="resolveFromPackageJsonPath:"+n+":"+s+":"+(c?"yes":"no");if(t?.has(i))return t.get(i);const e=B(n);if(!e)return;let o=s||"tsconfig.json";if(!c&&e.exports)try{const[f]=k.resolveExports(e.exports,s,["require","types"]);o=f}catch{return!1}else!s&&e.tsconfig&&(o=e.tsconfig);return o=r.join(n,"..",o),t?.set(i,o),o},"resolveFromPackageJsonPath"),C="package.json",v="tsconfig.json",W=S((n,s,c)=>{let t=n;if(n===".."&&(t=r.join(t,v)),n.startsWith(".")&&(t=r.resolve(s,t)),r.isAbsolute(t)){if(a.isAccessibleSync(t)){if(j.statSync(t).isFile())return t}else if(!t.endsWith(".json")){const l=`${t}.json`;if(a.isAccessibleSync(l))return l}return}const[i,...e]=n.split("/"),o=i.startsWith("@")?i+"/"+e.shift():i,f=e.join("/"),u=z();if(u){const{resolveRequest:l}=u;try{if(o===n){const d=l(r.join(o,C),s);if(d){const m=b(d,f,!1,c);if(m&&a.isAccessibleSync(m))return m}}else{let d;try{d=l(n,s,{extensions:[".json"]})}catch{d=l(r.join(n,v),s)}if(d)return d}}catch{}}const p=a.findUpSync(l=>{const d=r.join(r.resolve(l),"node_modules",o);if(a.isAccessibleSync(d))return r.join("node_modules",o)},{cwd:s,type:"directory"});if(!p||!j.statSync(p).isDirectory())return;const h=r.join(p,C);if(a.isAccessibleSync(h)){const l=b(h,f,!1,c);if(l===!1)return;if(l&&a.isAccessibleSync(l)&&j.statSync(l).isFile())return l}const y=r.join(p,f),O=y.endsWith(".json");if(!O){const l=y+".json";if(a.isAccessibleSync(l))return l}if(a.isAccessibleSync(y)){if(j.statSync(y).isDirectory()){const l=r.join(y,C);if(a.isAccessibleSync(l)){const m=b(l,"",!0,c);if(m&&a.isAccessibleSync(m))return m}const d=r.join(y,v);if(a.isAccessibleSync(d))return d}else if(O)return y}},"resolveExtendsPath");var R=Object.defineProperty,w=g((n,s)=>R(n,"name",{value:s,configurable:!0}),"c");const V=w(n=>P.parse(a.readFileSync(n)),"readJsonc"),A=w(n=>r.toNamespacedPath(/^\.{1,2}(?:\/.*)?$/.test(n)?n:`./${n}`),"normalizePath"),G=w((n,s,c,t)=>{const i=W(n,s);if(!i)throw new x.NotFoundError(`No such file or directory, for '${n}' found.`);if(c.has(i))throw new Error(`Circularity detected while resolving configuration: ${i}`);c.add(i);const e=r.dirname(i),o=D(i,t,c);delete o.references;const{compilerOptions:f}=o;if(f){const u=["baseUrl","outDir"];for(const p of u){const h=f[p];h&&(f[p]=r.relative(s,r.join(e,h)).replaceAll("\\","/")||"./")}}return o.files&&(o.files=o.files.map(u=>r.relative(s,r.join(e,u)))),o.include&&(o.include=o.include.map(u=>r.relative(s,r.join(e,u)))),o.exclude&&(o.exclude=o.exclude.map(u=>r.relative(s,r.join(e,u)))),o},"resolveExtends"),D=w((n,s,c=new Set)=>{let t;try{t=V(n)||{}}catch{throw new Error(`Cannot resolve tsconfig at path: ${n}`)}if(typeof t!="object")throw new SyntaxError(`Failed to parse tsconfig at: ${n}`);const i=r.dirname(n);if(t.compilerOptions){const{compilerOptions:e}=t;e.paths&&!e.baseUrl&&(e[I]=i)}if(t.extends){const e=Array.isArray(t.extends)?t.extends:[t.extends];delete t.extends;for(const o of e.reverse()){const f=G(o,i,new Set(c),s),u={...f,...t,compilerOptions:{...f.compilerOptions,...t.compilerOptions}};f.watchOptions&&(u.watchOptions={...f.watchOptions,...t.watchOptions}),t=u}}if(t.compilerOptions){const{compilerOptions:e}=t,o=["baseUrl","rootDir"];for(const u of o){const p=e[u];if(p){const h=r.resolve(i,p),y=r.relative(i,h);e[u]=A(y)}}const{outDir:f}=e;f&&(Array.isArray(t.exclude)||(t.exclude=[]),t.exclude.includes(f)||t.exclude.push(f),e.outDir=A(f)),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=>A(e))),t.include&&(t.include=t.include.map(e=>r.normalize(e))),t.watchOptions){const{watchOptions:e}=t;e.excludeDirectories&&(e.excludeDirectories=e.excludeDirectories.map(o=>r.resolve(i,o)))}return t},"internalParseTsConfig"),I=Symbol("implicitBaseUrl"),F=w((n,s)=>D(n,s),"readTsConfig");var H=Object.defineProperty,U=g((n,s)=>H(n,"name",{value:s,configurable:!0}),"s");const E=new Map,K=U(async(n,s={})=>{const c=s.configFileName??"tsconfig.json";let t=await a.findUp(c,{...n&&{cwd:n},type:"file"});if(t||(t=await a.findUp("jsconfig.json",{...n&&{cwd:n},type:"file"})),!t)throw new x.NotFoundError(`No such file or directory, for ${c} or jsconfig.json found.`);const i=s.cache&&typeof s.cache!="boolean"?s.cache:E;if(s.cache&&i.has(t))return i.get(t);const e={config:F(t),path:t};return s.cache&&i.set(t,e),e},"findTsConfig"),L=U((n,s={})=>{const c=s.configFileName??"tsconfig.json";let t=a.findUpSync(c,{...n&&{cwd:n},type:"file"});if(t||(t=a.findUpSync("jsconfig.json",{...n&&{cwd:n},type:"file"})),!t)throw new x.NotFoundError(`No such file or directory, for ${c} or jsconfig.json found.`);const i=s.cache&&typeof s.cache!="boolean"?s.cache:E;if(s.cache&&i.has(t))return i.get(t);const e={config:F(t),path:t};return s.cache&&i.set(t,e),e},"findTsConfigSync");var Q=Object.defineProperty,$=g((n,s)=>Q(n,"name",{value:s,configurable:!0}),"r");const X=$(async(n,s={})=>{const{cwd:c,...t}=s,i=T.toPath(c??process.cwd());await a.writeJson(r.join(i,"tsconfig.json"),n,t)},"writeTsConfig"),Y=$((n,s={})=>{const{cwd:c,...t}=s,i=T.toPath(c??process.cwd());a.writeJsonSync(r.join(i,"tsconfig.json"),n,t)},"writeTsConfigSync");exports.findTsConfig=K;exports.findTsConfigSync=L;exports.implicitBaseUrlSymbol=I;exports.readTsConfig=F;exports.writeTsConfig=X;exports.writeTsConfigSync=Y;
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- var B=Object.defineProperty;var w=(o,n)=>B(o,"name",{value:n,configurable:!0});import{readFileSync as T,findUpSync as O,findUp as I,writeJson as W,writeJsonSync as R}from"@visulima/fs";import{NotFoundError as P}from"@visulima/fs/error";import{join as f,resolve as D,isAbsolute as _,toNamespacedPath as q,dirname as A,relative as g,normalize as V}from"@visulima/path";import{parse as E}from"jsonc-parser";import{existsSync as u,statSync as j}from"node:fs";import G from"node:module";import{resolveExports as H}from"resolve-pkg-maps";import{toPath as N}from"@visulima/fs/utils";var K=Object.defineProperty,v=w((o,n)=>K(o,"name",{value:n,configurable:!0}),"d");const L=v(o=>E(T(o)),"readJsonc"),Q=v(()=>{const{findPnpApi:o}=G;return o?.(process.cwd())},"getPnpApi"),x=v((o,n,r,t)=>{const s=`resolveFromPackageJsonPath:${o}:${n}:${r}`;if(t?.has(s))return t.get(s);const e=L(o);if(!e)return;let i=n||"tsconfig.json";if(!r&&e.exports)try{const[l]=H(e.exports,n,["require","types"]);i=l}catch{return!1}else!n&&e.tsconfig&&(i=e.tsconfig);return i=f(o,"..",i),t?.set(s,i),i},"resolveFromPackageJsonPath"),b="package.json",S="tsconfig.json",X=v((o,n,r)=>{let t=o;if(o===".."&&(t=f(t,S)),o.startsWith(".")&&(t=D(n,t)),_(t)){if(u(t)){if(j(t).isFile())return t}else if(!t.endsWith(".json")){const c=`${t}.json`;if(u(c))return c}return}const[s,...e]=o.split("/"),i=s.startsWith("@")?`${s}/${e.shift()}`:s,l=e.join("/"),a=Q();if(a){const{resolveRequest:c}=a;try{if(i===o){const p=c(f(i,b),n);if(p){const y=x(p,l,!1,r);if(y&&u(y))return y}}else{let p;try{p=c(o,n,{extensions:[".json"]})}catch{p=c(f(o,S),n)}if(p)return p}}catch{}}const d=O(c=>{const p=f(c,"node_modules",i);if(u(p))return f("node_modules",i)},{cwd:n,type:"directory"});if(!d||!j(d).isDirectory())return;const h=f(d,b);if(u(h)){const c=x(h,l,!1,r);if(c===!1)return;if(c&&u(c)&&j(c).isFile())return c}const m=f(d,l),$=m.endsWith(".json");if(!$){const c=`${m}.json`;if(u(c))return c}if(u(m)){if(j(m).isDirectory()){const c=f(m,b);if(u(c)){const y=x(c,"",!0,r);if(y&&u(y))return y}const p=f(m,S);if(u(p))return p}else if($)return m}},"resolveExtendsPath");var Y=Object.defineProperty,C=w((o,n)=>Y(o,"name",{value:n,configurable:!0}),"c");const Z=C(o=>E(T(o)),"readJsonc"),F=C(o=>q(/^\.{1,2}(?:\/.*)?$/.test(o)?o:`./${o}`),"normalizePath"),ee=C((o,n,r,t)=>{const s=X(o,n);if(!s)throw new P(`No such file or directory, for '${o}' found.`);if(r.has(s))throw new Error(`Circularity detected while resolving configuration: ${s}`);r.add(s);const e=A(s),i=U(s,t,r);delete i.references;const{compilerOptions:l}=i;if(l){const a=["baseUrl","outDir"];for(const d of a){const h=l[d];h&&(l[d]=g(n,f(e,h)).replaceAll("\\","/")||"./")}}return i.files&&(i.files=i.files.map(a=>g(n,f(e,a)))),i.include&&(i.include=i.include.map(a=>g(n,f(e,a)))),i.exclude&&(i.exclude=i.exclude.map(a=>g(n,f(e,a)))),i},"resolveExtends"),U=C((o,n,r=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}`);const s=A(o);if(t.compilerOptions){const{compilerOptions:e}=t;e.paths&&!e.baseUrl&&(e[te]=s)}if(t.extends){const e=Array.isArray(t.extends)?t.extends:[t.extends];delete t.extends;for(const i of e.reverse()){const l=ee(i,s,new Set(r),n),a={...l,...t,compilerOptions:{...l.compilerOptions,...t.compilerOptions}};l.watchOptions&&(a.watchOptions={...l.watchOptions,...t.watchOptions}),t=a}}if(t.compilerOptions){const{compilerOptions:e}=t,i=["baseUrl","rootDir"];for(const a of i){const d=e[a];if(d){const h=D(s,d),m=g(s,h);e[a]=F(m)}}const{outDir:l}=e;l&&(Array.isArray(t.exclude)||(t.exclude=[]),t.exclude.includes(l)||t.exclude.push(l),e.outDir=F(l)),n?.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),n?.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),n?.tscCompatible&&e.isolatedModules&&(e.preserveConstEnums=e.preserveConstEnums??!0),n?.tscCompatible&&e.esModuleInterop&&(e.allowSyntheticDefaultImports=e.allowSyntheticDefaultImports??!0),n?.tscCompatible&&e.target==="esnext"&&(e.useDefineForClassFields=e.useDefineForClassFields??!0)}else t.compilerOptions={};if(t.files&&(t.files=t.files.map(e=>F(e))),t.include&&(t.include=t.include.map(e=>V(e))),t.watchOptions){const{watchOptions:e}=t;e.excludeDirectories&&(e.excludeDirectories=e.excludeDirectories.map(i=>D(s,i)))}return t},"internalParseTsConfig"),te=Symbol("implicitBaseUrl"),k=C((o,n)=>U(o,n),"readTsConfig");var oe=Object.defineProperty,J=w((o,n)=>oe(o,"name",{value:n,configurable:!0}),"s");const M=new Map,de=J(async(o,n={})=>{const r=n.configFileName??"tsconfig.json";let t=await I(r,{...o&&{cwd:o},type:"file"});if(t||(t=await I("jsconfig.json",{...o&&{cwd:o},type:"file"})),!t)throw new P(`No such file or directory, for ${r} or jsconfig.json found.`);const s=n.cache&&typeof n.cache!="boolean"?n.cache:M;if(n.cache&&s.has(t))return s.get(t);const e={config:k(t),path:t};return n.cache&&s.set(t,e),e},"findTsConfig"),me=J((o,n={})=>{const r=n.configFileName??"tsconfig.json";let t=O(r,{...o&&{cwd:o},type:"file"});if(t||(t=O("jsconfig.json",{...o&&{cwd:o},type:"file"})),!t)throw new P(`No such file or directory, for ${r} or jsconfig.json found.`);const s=n.cache&&typeof n.cache!="boolean"?n.cache:M;if(n.cache&&s.has(t))return s.get(t);const e={config:k(t),path:t};return n.cache&&s.set(t,e),e},"findTsConfigSync");var ne=Object.defineProperty,z=w((o,n)=>ne(o,"name",{value:n,configurable:!0}),"r");const he=z(async(o,n={})=>{const{cwd:r,...t}=n,s=N(r??process.cwd());await W(f(s,"tsconfig.json"),o,t)},"writeTsConfig"),ye=z((o,n={})=>{const{cwd:r,...t}=n,s=N(r??process.cwd());R(f(s,"tsconfig.json"),o,t)},"writeTsConfigSync");export{de as findTsConfig,me as findTsConfigSync,te as implicitBaseUrlSymbol,k as readTsConfig,he as writeTsConfig,ye as writeTsConfigSync};
1
+ var B=Object.defineProperty;var w=(o,n)=>B(o,"name",{value:n,configurable:!0});import{readFileSync as A,isAccessibleSync as u,findUpSync as D,findUp as T,writeJson as W,writeJsonSync as R}from"@visulima/fs";import{NotFoundError as P}from"@visulima/fs/error";import{join as f,resolve as v,isAbsolute as q,toNamespacedPath as V,dirname as $,relative as g,normalize as _}from"@visulima/path";import{parse as E}from"jsonc-parser";import{statSync as j}from"node:fs";import G from"node:module";import{resolveExports as H}from"resolve-pkg-maps";import{toPath as N}from"@visulima/fs/utils";var K=Object.defineProperty,b=w((o,n)=>K(o,"name",{value:n,configurable:!0}),"d");const L=b(o=>E(A(o)),"readJsonc"),Q=b(()=>{const{findPnpApi:o}=G;return o?.(process.cwd())},"getPnpApi"),x=b((o,n,r,t)=>{const s="resolveFromPackageJsonPath:"+o+":"+n+":"+(r?"yes":"no");if(t?.has(s))return t.get(s);const e=L(o);if(!e)return;let i=n||"tsconfig.json";if(!r&&e.exports)try{const[l]=H(e.exports,n,["require","types"]);i=l}catch{return!1}else!n&&e.tsconfig&&(i=e.tsconfig);return i=f(o,"..",i),t?.set(s,i),i},"resolveFromPackageJsonPath"),S="package.json",F="tsconfig.json",X=b((o,n,r)=>{let t=o;if(o===".."&&(t=f(t,F)),o.startsWith(".")&&(t=v(n,t)),q(t)){if(u(t)){if(j(t).isFile())return t}else if(!t.endsWith(".json")){const c=`${t}.json`;if(u(c))return c}return}const[s,...e]=o.split("/"),i=s.startsWith("@")?s+"/"+e.shift():s,l=e.join("/"),a=Q();if(a){const{resolveRequest:c}=a;try{if(i===o){const p=c(f(i,S),n);if(p){const y=x(p,l,!1,r);if(y&&u(y))return y}}else{let p;try{p=c(o,n,{extensions:[".json"]})}catch{p=c(f(o,F),n)}if(p)return p}}catch{}}const d=D(c=>{const p=f(v(c),"node_modules",i);if(u(p))return f("node_modules",i)},{cwd:n,type:"directory"});if(!d||!j(d).isDirectory())return;const h=f(d,S);if(u(h)){const c=x(h,l,!1,r);if(c===!1)return;if(c&&u(c)&&j(c).isFile())return c}const m=f(d,l),I=m.endsWith(".json");if(!I){const c=m+".json";if(u(c))return c}if(u(m)){if(j(m).isDirectory()){const c=f(m,S);if(u(c)){const y=x(c,"",!0,r);if(y&&u(y))return y}const p=f(m,F);if(u(p))return p}else if(I)return m}},"resolveExtendsPath");var Y=Object.defineProperty,C=w((o,n)=>Y(o,"name",{value:n,configurable:!0}),"c");const Z=C(o=>E(A(o)),"readJsonc"),O=C(o=>V(/^\.{1,2}(?:\/.*)?$/.test(o)?o:`./${o}`),"normalizePath"),ee=C((o,n,r,t)=>{const s=X(o,n);if(!s)throw new P(`No such file or directory, for '${o}' found.`);if(r.has(s))throw new Error(`Circularity detected while resolving configuration: ${s}`);r.add(s);const e=$(s),i=U(s,t,r);delete i.references;const{compilerOptions:l}=i;if(l){const a=["baseUrl","outDir"];for(const d of a){const h=l[d];h&&(l[d]=g(n,f(e,h)).replaceAll("\\","/")||"./")}}return i.files&&(i.files=i.files.map(a=>g(n,f(e,a)))),i.include&&(i.include=i.include.map(a=>g(n,f(e,a)))),i.exclude&&(i.exclude=i.exclude.map(a=>g(n,f(e,a)))),i},"resolveExtends"),U=C((o,n,r=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}`);const s=$(o);if(t.compilerOptions){const{compilerOptions:e}=t;e.paths&&!e.baseUrl&&(e[te]=s)}if(t.extends){const e=Array.isArray(t.extends)?t.extends:[t.extends];delete t.extends;for(const i of e.reverse()){const l=ee(i,s,new Set(r),n),a={...l,...t,compilerOptions:{...l.compilerOptions,...t.compilerOptions}};l.watchOptions&&(a.watchOptions={...l.watchOptions,...t.watchOptions}),t=a}}if(t.compilerOptions){const{compilerOptions:e}=t,i=["baseUrl","rootDir"];for(const a of i){const d=e[a];if(d){const h=v(s,d),m=g(s,h);e[a]=O(m)}}const{outDir:l}=e;l&&(Array.isArray(t.exclude)||(t.exclude=[]),t.exclude.includes(l)||t.exclude.push(l),e.outDir=O(l)),n?.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),n?.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),n?.tscCompatible&&e.isolatedModules&&(e.preserveConstEnums=e.preserveConstEnums??!0),n?.tscCompatible&&e.esModuleInterop&&(e.allowSyntheticDefaultImports=e.allowSyntheticDefaultImports??!0),n?.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=>_(e))),t.watchOptions){const{watchOptions:e}=t;e.excludeDirectories&&(e.excludeDirectories=e.excludeDirectories.map(i=>v(s,i)))}return t},"internalParseTsConfig"),te=Symbol("implicitBaseUrl"),k=C((o,n)=>U(o,n),"readTsConfig");var oe=Object.defineProperty,J=w((o,n)=>oe(o,"name",{value:n,configurable:!0}),"s");const M=new Map,de=J(async(o,n={})=>{const r=n.configFileName??"tsconfig.json";let t=await T(r,{...o&&{cwd:o},type:"file"});if(t||(t=await T("jsconfig.json",{...o&&{cwd:o},type:"file"})),!t)throw new P(`No such file or directory, for ${r} or jsconfig.json found.`);const s=n.cache&&typeof n.cache!="boolean"?n.cache:M;if(n.cache&&s.has(t))return s.get(t);const e={config:k(t),path:t};return n.cache&&s.set(t,e),e},"findTsConfig"),me=J((o,n={})=>{const r=n.configFileName??"tsconfig.json";let t=D(r,{...o&&{cwd:o},type:"file"});if(t||(t=D("jsconfig.json",{...o&&{cwd:o},type:"file"})),!t)throw new P(`No such file or directory, for ${r} or jsconfig.json found.`);const s=n.cache&&typeof n.cache!="boolean"?n.cache:M;if(n.cache&&s.has(t))return s.get(t);const e={config:k(t),path:t};return n.cache&&s.set(t,e),e},"findTsConfigSync");var ne=Object.defineProperty,z=w((o,n)=>ne(o,"name",{value:n,configurable:!0}),"r");const he=z(async(o,n={})=>{const{cwd:r,...t}=n,s=N(r??process.cwd());await W(f(s,"tsconfig.json"),o,t)},"writeTsConfig"),ye=z((o,n={})=>{const{cwd:r,...t}=n,s=N(r??process.cwd());R(f(s,"tsconfig.json"),o,t)},"writeTsConfigSync");export{de as findTsConfig,me as findTsConfigSync,te as implicitBaseUrlSymbol,k as readTsConfig,he as writeTsConfig,ye as writeTsConfigSync};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visulima/tsconfig",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "Find and/or parse the tsconfig.json file from a directory path.",
5
5
  "keywords": [
6
6
  "anolilab",
@@ -60,7 +60,7 @@
60
60
  "CHANGELOG.md"
61
61
  ],
62
62
  "dependencies": {
63
- "@visulima/fs": "2.1.9",
63
+ "@visulima/fs": "2.1.10",
64
64
  "@visulima/path": "1.0.2",
65
65
  "jsonc-parser": "^3.3.1",
66
66
  "resolve-pkg-maps": "^1.0.0"
@@ -70,18 +70,18 @@
70
70
  "@anolilab/prettier-config": "^5.0.14",
71
71
  "@anolilab/semantic-release-pnpm": "1.1.3",
72
72
  "@anolilab/semantic-release-preset": "^9.0.0",
73
- "@babel/core": "^7.24.7",
73
+ "@babel/core": "^7.24.9",
74
74
  "@rushstack/eslint-plugin-security": "^0.8.1",
75
75
  "@secretlint/secretlint-rule-preset-recommend": "^8.2.4",
76
76
  "@total-typescript/ts-reset": "^0.5.1",
77
77
  "@types/node": "18.18.14",
78
- "@visulima/packem": "^1.0.0-alpha.41",
79
- "@vitest/coverage-v8": "^1.6.0",
80
- "@vitest/ui": "^1.6.0",
78
+ "@visulima/packem": "^1.0.0-alpha.49",
79
+ "@vitest/coverage-v8": "^2.0.3",
80
+ "@vitest/ui": "^2.0.3",
81
81
  "conventional-changelog-conventionalcommits": "8.0.0",
82
82
  "cross-env": "^7.0.3",
83
- "esbuild": "0.22.0",
84
- "eslint": "^8.57.0",
83
+ "esbuild": "0.23.0",
84
+ "eslint": "8.57.0",
85
85
  "eslint-plugin-deprecation": "^3.0.0",
86
86
  "eslint-plugin-etc": "^2.0.3",
87
87
  "eslint-plugin-import": "npm:eslint-plugin-i@^2.29.1",
@@ -89,15 +89,15 @@
89
89
  "eslint-plugin-vitest": "^0.4.1",
90
90
  "eslint-plugin-vitest-globals": "^1.5.0",
91
91
  "execa": "^9.3.0",
92
- "prettier": "^3.3.2",
93
- "rimraf": "^5.0.7",
92
+ "prettier": "^3.3.3",
93
+ "rimraf": "5.0.9",
94
94
  "secretlint": "8.2.4",
95
95
  "semantic-release": "^24.0.0",
96
96
  "strip-ansi": "^7.1.0",
97
97
  "tempy": "^3.1.0",
98
- "type-fest": "^4.20.1",
99
- "typescript": "^5.4.5",
100
- "vitest": "^1.6.0"
98
+ "type-fest": "^4.21.0",
99
+ "typescript": "5.4.5",
100
+ "vitest": "^2.0.3"
101
101
  },
102
102
  "engines": {
103
103
  "node": ">=18.* <=22.*"