@visulima/package 1.10.3 → 2.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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@visulima/package",
3
- "version": "1.10.3",
4
- "description": "One Package to rule them all, finds your root-dir, monorepo, package manager or tsconfig.json",
3
+ "version": "2.0.0",
4
+ "description": "One Package to rule them all, finds your root-dir, monorepo, or package manager.",
5
5
  "keywords": [
6
6
  "anolilab",
7
7
  "find",
@@ -11,7 +11,6 @@
11
11
  "find-monorepo-root",
12
12
  "find-up-pkg",
13
13
  "find-package-manager",
14
- "get-tsconfig",
15
14
  "mono-repo",
16
15
  "monorepo",
17
16
  "package",
@@ -25,10 +24,7 @@
25
24
  "pkg-up",
26
25
  "read-pkg",
27
26
  "read-pkg-up",
28
- "read-tsconfig",
29
27
  "root",
30
- "tsconfig",
31
- "tsconfig.json",
32
28
  "visulima"
33
29
  ],
34
30
  "homepage": "https://www.visulima.com/docs/package/package",
@@ -115,16 +111,6 @@
115
111
  "default": "./dist/package-manager.mjs"
116
112
  }
117
113
  },
118
- "./tsconfig": {
119
- "require": {
120
- "types": "./dist/tsconfig/index.d.cts",
121
- "default": "./dist/tsconfig/index.cjs"
122
- },
123
- "import": {
124
- "types": "./dist/tsconfig/index.d.mts",
125
- "default": "./dist/tsconfig/index.mjs"
126
- }
127
- },
128
114
  "./error": {
129
115
  "require": {
130
116
  "types": "./dist/error.d.cts",
@@ -149,9 +135,7 @@
149
135
  "dependencies": {
150
136
  "@visulima/fs": "2.1.7",
151
137
  "@visulima/path": "1.0.2",
152
- "jsonc-parser": "^3.2.1",
153
- "normalize-package-data": "^6.0.1",
154
- "resolve-pkg-maps": "^1.0.0"
138
+ "normalize-package-data": "^6.0.1"
155
139
  },
156
140
  "devDependencies": {
157
141
  "@anolilab/eslint-config": "^15.0.3",
@@ -183,7 +167,6 @@
183
167
  "prettier": "^3.3.2",
184
168
  "rimraf": "^5.0.7",
185
169
  "semantic-release": "24.0.0",
186
- "strip-ansi": "^7.1.0",
187
170
  "tempy": "^3.1.0",
188
171
  "type-fest": "^4.20.1",
189
172
  "typescript": "^5.4.5",
@@ -1 +0,0 @@
1
- var B=Object.defineProperty;var w=(o,n)=>B(o,"name",{value:n,configurable:!0});import{readFileSync as I,findUpSync as O,findUp as $,writeJson as W,writeJsonSync as R}from"@visulima/fs";import{NotFoundError as T}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(I(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[a]=H(e.exports,n,["require","types"]);i=a}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,a=e.join("/"),l=Q();if(l){const{resolveRequest:c}=l;try{if(i===o){const p=c(f(i,b),n);if(p){const y=x(p,a,!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,a,!1,r);if(c===!1)return;if(c&&u(c)&&j(c).isFile())return c}const m=f(d,a),P=m.endsWith(".json");if(!P){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(P)return m}},"resolveExtendsPath");var Y=Object.defineProperty,C=w((o,n)=>Y(o,"name",{value:n,configurable:!0}),"c");const Z=C(o=>E(I(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 T(`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:a}=i;if(a){const l=["baseUrl","outDir"];for(const d of l){const h=a[d];h&&(a[d]=g(n,f(e,h)).replaceAll("\\","/")||"./")}}return i.files&&(i.files=i.files.map(l=>g(n,f(e,l)))),i.include&&(i.include=i.include.map(l=>g(n,f(e,l)))),i.exclude&&(i.exclude=i.exclude.map(l=>g(n,f(e,l)))),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 a=ee(i,s,new Set(r),n),l={...a,...t,compilerOptions:{...a.compilerOptions,...t.compilerOptions}};a.watchOptions&&(l.watchOptions={...a.watchOptions,...t.watchOptions}),t=l}}if(t.compilerOptions){const{compilerOptions:e}=t,i=["baseUrl","rootDir"];for(const l of i){const d=e[l];if(d){const h=D(s,d),m=g(s,h);e[l]=F(m)}}const{outDir:a}=e;a&&(Array.isArray(t.exclude)||(t.exclude=[]),t.exclude.includes(a)||t.exclude.push(a),e.outDir=F(a)),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,ne=J(async(o,n={})=>{const r=n.configFileName??"tsconfig.json";let t=await $(r,{...o&&{cwd:o},type:"file"});if(t||(t=await $("jsconfig.json",{...o&&{cwd:o},type:"file"})),!t)throw new T(`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"),ye=ne,se=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 T(`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"),we=se;var ie=Object.defineProperty,z=w((o,n)=>ie(o,"name",{value:n,configurable:!0}),"n");const re=z(async(o,n={})=>{const{cwd:r,...t}=n,s=N(n.cwd??process.cwd());await W(f(s,"tsconfig.json"),o,t)},"writeTsConfig"),ge=re,Ce=z((o,n={})=>{const{cwd:r,...t}=n,s=N(n.cwd??process.cwd());R(f(s,"tsconfig.json"),o,t)},"writeTsConfigSync");export{ne as a,se as b,re as c,Ce as d,we as e,ye as f,te as i,k as r,ge as w};
@@ -1 +0,0 @@
1
- "use strict";var J=Object.defineProperty;var w=(n,i)=>J(n,"name",{value:i,configurable:!0});const h=require("@visulima/fs"),T=require("@visulima/fs/error"),r=require("@visulima/path"),O=require("jsonc-parser"),u=require("node:fs"),_=require("node:module"),M=require("resolve-pkg-maps"),P=require("@visulima/fs/utils"),B=w(n=>n&&typeof n=="object"&&"default"in n?n.default:n,"_interopDefaultCompat"),z=B(_);var W=Object.defineProperty,j=w((n,i)=>W(n,"name",{value:i,configurable:!0}),"d");const R=j(n=>O.parse(h.readFileSync(n)),"readJsonc"),V=j(()=>{const{findPnpApi:n}=z;return n?.(process.cwd())},"getPnpApi"),C=j((n,i,c,t)=>{const s=`resolveFromPackageJsonPath:${n}:${i}:${c}`;if(t?.has(s))return t.get(s);const e=R(n);if(!e)return;let o=i||"tsconfig.json";if(!c&&e.exports)try{const[a]=M.resolveExports(e.exports,i,["require","types"]);o=a}catch{return!1}else!i&&e.tsconfig&&(o=e.tsconfig);return o=r.join(n,"..",o),t?.set(s,o),o},"resolveFromPackageJsonPath"),x="package.json",v="tsconfig.json",G=j((n,i,c)=>{let t=n;if(n===".."&&(t=r.join(t,v)),n.startsWith(".")&&(t=r.resolve(i,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[s,...e]=n.split("/"),o=s.startsWith("@")?`${s}/${e.shift()}`:s,a=e.join("/"),f=V();if(f){const{resolveRequest:l}=f;try{if(o===n){const d=l(r.join(o,x),i);if(d){const m=C(d,a,!1,c);if(m&&u.existsSync(m))return m}}else{let d;try{d=l(n,i,{extensions:[".json"]})}catch{d=l(r.join(n,v),i)}if(d)return d}}catch{}}const p=h.findUpSync(l=>{const d=r.join(l,"node_modules",o);if(u.existsSync(d))return r.join("node_modules",o)},{cwd:i,type:"directory"});if(!p||!u.statSync(p).isDirectory())return;const g=r.join(p,x);if(u.existsSync(g)){const l=C(g,a,!1,c);if(l===!1)return;if(l&&u.existsSync(l)&&u.statSync(l).isFile())return l}const y=r.join(p,a),D=y.endsWith(".json");if(!D){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 m=C(l,"",!0,c);if(m&&u.existsSync(m))return m}const d=r.join(y,v);if(u.existsSync(d))return d}else if(D)return y}},"resolveExtendsPath");var H=Object.defineProperty,S=w((n,i)=>H(n,"name",{value:i,configurable:!0}),"c");const K=S(n=>O.parse(h.readFileSync(n)),"readJsonc"),b=S(n=>r.toNamespacedPath(/^\.{1,2}(?:\/.*)?$/.test(n)?n:`./${n}`),"normalizePath"),L=S((n,i,c,t)=>{const s=G(n,i);if(!s)throw new T.NotFoundError(`No such file or directory, for '${n}' found.`);if(c.has(s))throw new Error(`Circularity detected while resolving configuration: ${s}`);c.add(s);const e=r.dirname(s),o=$(s,t,c);delete o.references;const{compilerOptions:a}=o;if(a){const f=["baseUrl","outDir"];for(const p of f){const g=a[p];g&&(a[p]=r.relative(i,r.join(e,g)).replaceAll("\\","/")||"./")}}return o.files&&(o.files=o.files.map(f=>r.relative(i,r.join(e,f)))),o.include&&(o.include=o.include.map(f=>r.relative(i,r.join(e,f)))),o.exclude&&(o.exclude=o.exclude.map(f=>r.relative(i,r.join(e,f)))),o},"resolveExtends"),$=S((n,i,c=new Set)=>{let t;try{t=K(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 s=r.dirname(n);if(t.compilerOptions){const{compilerOptions:e}=t;e.paths&&!e.baseUrl&&(e[I]=s)}if(t.extends){const e=Array.isArray(t.extends)?t.extends:[t.extends];delete t.extends;for(const o of e.reverse()){const a=L(o,s,new Set(c),i),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,o=["baseUrl","rootDir"];for(const f of o){const p=e[f];if(p){const g=r.resolve(s,p),y=r.relative(s,g);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)),i?.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),i?.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),i?.tscCompatible&&e.isolatedModules&&(e.preserveConstEnums=e.preserveConstEnums??!0),i?.tscCompatible&&e.esModuleInterop&&(e.allowSyntheticDefaultImports=e.allowSyntheticDefaultImports??!0),i?.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(o=>r.resolve(s,o)))}return t},"internalParseTsConfig"),I=Symbol("implicitBaseUrl"),F=S((n,i)=>$(n,i),"readTsConfig");var Q=Object.defineProperty,U=w((n,i)=>Q(n,"name",{value:i,configurable:!0}),"s");const A=new Map,E=U(async(n,i={})=>{const c=i.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 T.NotFoundError(`No such file or directory, for ${c} or jsconfig.json found.`);const s=i.cache&&typeof i.cache!="boolean"?i.cache:A;if(i.cache&&s.has(t))return s.get(t);const e={config:F(t),path:t};return i.cache&&s.set(t,e),e},"findTsConfig"),X=E,N=U((n,i={})=>{const c=i.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 T.NotFoundError(`No such file or directory, for ${c} or jsconfig.json found.`);const s=i.cache&&typeof i.cache!="boolean"?i.cache:A;if(i.cache&&s.has(t))return s.get(t);const e={config:F(t),path:t};return i.cache&&s.set(t,e),e},"findTsConfigSync"),Y=N;var Z=Object.defineProperty,q=w((n,i)=>Z(n,"name",{value:i,configurable:!0}),"n");const k=q(async(n,i={})=>{const{cwd:c,...t}=i,s=P.toPath(i.cwd??process.cwd());await h.writeJson(r.join(s,"tsconfig.json"),n,t)},"writeTsConfig"),ee=k,te=q((n,i={})=>{const{cwd:c,...t}=i,s=P.toPath(i.cwd??process.cwd());h.writeJsonSync(r.join(s,"tsconfig.json"),n,t)},"writeTsConfigSync");exports.findTSConfig=X;exports.findTSConfigSync=Y;exports.findTsConfig=E;exports.findTsConfigSync=N;exports.implicitBaseUrlSymbol=I;exports.readTsConfig=F;exports.writeTSConfig=ee;exports.writeTsConfig=k;exports.writeTsConfigSync=te;