@visulima/tsconfig 1.0.0

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/dist/index.mjs ADDED
@@ -0,0 +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};
package/package.json ADDED
@@ -0,0 +1,138 @@
1
+ {
2
+ "name": "@visulima/tsconfig",
3
+ "version": "1.0.0",
4
+ "description": "Find and/or parse the tsconfig.json file from a directory path.",
5
+ "keywords": [
6
+ "anolilab",
7
+ "visulima",
8
+ "ts-config",
9
+ "get-tsconfig",
10
+ "read-tsconfig",
11
+ "tsconfig",
12
+ "tsconfig.json"
13
+ ],
14
+ "homepage": "https://visulima.com/packages/tsconfig",
15
+ "bugs": {
16
+ "url": "https://github.com/visulima/visulima/issues"
17
+ },
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git+https://github.com/visulima/visulima.git",
21
+ "directory": "packages/tsconfig"
22
+ },
23
+ "funding": [
24
+ {
25
+ "type": "github",
26
+ "url": "https://github.com/sponsors/prisis"
27
+ },
28
+ {
29
+ "type": "consulting",
30
+ "url": "https://anolilab.com/support"
31
+ }
32
+ ],
33
+ "license": "MIT",
34
+ "author": {
35
+ "name": "Daniel Bannert",
36
+ "email": "d.bannert@anolilab.de"
37
+ },
38
+ "sideEffects": false,
39
+ "type": "module",
40
+ "exports": {
41
+ ".": {
42
+ "require": {
43
+ "types": "./dist/index.d.cts",
44
+ "default": "./dist/index.cjs"
45
+ },
46
+ "import": {
47
+ "types": "./dist/index.d.mts",
48
+ "default": "./dist/index.mjs"
49
+ }
50
+ },
51
+ "./package.json": "./package.json"
52
+ },
53
+ "main": "dist/index.cjs",
54
+ "module": "dist/index.mjs",
55
+ "browser": "./dist/index.mjs",
56
+ "types": "dist/index.d.ts",
57
+ "files": [
58
+ "dist",
59
+ "README.md",
60
+ "CHANGELOG.md"
61
+ ],
62
+ "dependencies": {
63
+ "@visulima/fs": "2.1.7",
64
+ "@visulima/path": "1.0.2",
65
+ "jsonc-parser": "^3.2.1",
66
+ "resolve-pkg-maps": "^1.0.0"
67
+ },
68
+ "devDependencies": {
69
+ "@anolilab/eslint-config": "^15.0.3",
70
+ "@anolilab/prettier-config": "^5.0.14",
71
+ "@anolilab/semantic-release-pnpm": "1.1.0",
72
+ "@anolilab/semantic-release-preset": "^8.1.0",
73
+ "@babel/core": "^7.24.3",
74
+ "@rushstack/eslint-plugin-security": "^0.8.1",
75
+ "@secretlint/secretlint-rule-preset-recommend": "^8.1.2",
76
+ "@total-typescript/ts-reset": "^0.5.1",
77
+ "@types/node": "18.18.14",
78
+ "@visulima/packem": "^1.0.0-alpha.41",
79
+ "@vitest/coverage-v8": "^1.4.0",
80
+ "@vitest/ui": "^1.4.0",
81
+ "conventional-changelog-conventionalcommits": "8.0.0",
82
+ "cross-env": "^7.0.3",
83
+ "esbuild": "^0.21.4",
84
+ "eslint": "^8.57.0",
85
+ "strip-ansi": "^7.1.0",
86
+ "eslint-plugin-deprecation": "^2.0.0",
87
+ "eslint-plugin-etc": "^2.0.3",
88
+ "eslint-plugin-import": "npm:eslint-plugin-i@^2.29.1",
89
+ "eslint-plugin-mdx": "^3.1.5",
90
+ "eslint-plugin-vitest": "^0.4.1",
91
+ "eslint-plugin-vitest-globals": "^1.5.0",
92
+ "execa": "^9.2.0",
93
+ "prettier": "^3.2.5",
94
+ "rimraf": "^5.0.5",
95
+ "secretlint": "8.1.2",
96
+ "semantic-release": "^23.0.5",
97
+ "tempy": "^3.1.0",
98
+ "type-fest": "^4.20.1",
99
+ "typescript": "^5.4.3",
100
+ "vitest": "^1.4.0"
101
+ },
102
+ "engines": {
103
+ "node": ">=18.* <=22.*"
104
+ },
105
+ "publishConfig": {
106
+ "access": "public",
107
+ "provenance": true
108
+ },
109
+ "anolilab": {
110
+ "eslint-config": {
111
+ "plugin": {
112
+ "tsdoc": false,
113
+ "etc": false
114
+ },
115
+ "warn_on_unsupported_typescript_version": false,
116
+ "info_on_disabling_jsx_react_rule": false,
117
+ "info_on_disabling_prettier_conflict_rule": false,
118
+ "info_on_disabling_jsonc_sort_keys_rule": false,
119
+ "info_on_disabling_etc_no_deprecated": false
120
+ }
121
+ },
122
+ "scripts": {
123
+ "build": "cross-env NODE_ENV=development packem build",
124
+ "build:prod": "cross-env NODE_ENV=production packem build",
125
+ "clean": "rimraf node_modules dist .eslintcache",
126
+ "dev": "pnpm run build --watch",
127
+ "lint:eslint": "eslint . --ext js,cjs,mjs,jsx,ts,tsx,json,yaml,yml,md,mdx --max-warnings=0 --config .eslintrc.cjs",
128
+ "lint:eslint:fix": "eslint . --ext js,cjs,mjs,jsx,ts,tsx,json,yaml,yml,md,mdx --max-warnings=0 --config .eslintrc.cjs --fix",
129
+ "lint:package-json": "publint --strict",
130
+ "lint:prettier": "prettier --config=.prettierrc.cjs --check .",
131
+ "lint:prettier:fix": "prettier --config=.prettierrc.cjs --write .",
132
+ "lint:types": "tsc --noEmit",
133
+ "test": "vitest run",
134
+ "test:coverage": "vitest run --coverage",
135
+ "test:ui": "vitest --ui --coverage.enabled=true",
136
+ "test:watch": "vitest"
137
+ }
138
+ }