@visulima/package 1.8.2 → 1.8.3
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 +7 -0
- package/LICENSE.md +17 -0
- package/dist/error.cjs +1 -14
- package/dist/error.d.mts +9 -0
- package/dist/error.mjs +1 -0
- package/dist/index.cjs +1 -107
- package/dist/index.d.cts +2 -3
- package/dist/index.d.mts +18 -0
- package/dist/index.d.ts +2 -3
- package/dist/index.mjs +1 -0
- package/dist/monorepo.cjs +1 -14
- package/dist/monorepo.d.mts +8 -0
- package/dist/monorepo.mjs +1 -0
- package/dist/package-json.cjs +1 -28
- package/dist/package-json.d.cts +3 -5
- package/dist/package-json.d.mts +22 -0
- package/dist/package-json.d.ts +3 -5
- package/dist/package-json.mjs +1 -0
- package/dist/package-manager.cjs +1 -33
- package/dist/package-manager.d.mts +16 -0
- package/dist/package-manager.mjs +1 -0
- package/dist/package.cjs +1 -18
- package/dist/package.d.mts +4 -0
- package/dist/package.mjs +1 -0
- package/dist/shared/package.DipMHw9r.cjs +1 -0
- package/dist/shared/package.DvbNGF15.mjs +1 -0
- package/dist/shared/package.SZmjOQBM.d.cts +2076 -0
- package/dist/shared/package.SZmjOQBM.d.mts +2076 -0
- package/dist/shared/package.SZmjOQBM.d.ts +2076 -0
- package/dist/shared/package.Xn4v2Y_g.cjs +1 -0
- package/dist/shared/package.zhGeUcxO.mjs +1 -0
- package/dist/tsconfig/index.cjs +1 -0
- package/dist/tsconfig/index.d.cts +34 -0
- package/dist/tsconfig/index.d.mts +34 -0
- package/dist/tsconfig/index.d.ts +34 -0
- package/dist/tsconfig/index.mjs +1 -0
- package/package.json +25 -33
- package/dist/chunk-5UU4RIJA.js +0 -11
- package/dist/chunk-5UU4RIJA.js.map +0 -1
- package/dist/chunk-BGVUNBLL.js +0 -12
- package/dist/chunk-BGVUNBLL.js.map +0 -1
- package/dist/chunk-BHDWBI3F.cjs +0 -22
- package/dist/chunk-BHDWBI3F.cjs.map +0 -1
- package/dist/chunk-C36BYRSZ.cjs +0 -19
- package/dist/chunk-C36BYRSZ.cjs.map +0 -1
- package/dist/chunk-EY5KVLRL.js +0 -10
- package/dist/chunk-EY5KVLRL.js.map +0 -1
- package/dist/chunk-HGV2BL7M.js +0 -12
- package/dist/chunk-HGV2BL7M.js.map +0 -1
- package/dist/chunk-I3EKI236.cjs +0 -13
- package/dist/chunk-I3EKI236.cjs.map +0 -1
- package/dist/chunk-J5ERILYG.cjs +0 -9
- package/dist/chunk-J5ERILYG.cjs.map +0 -1
- package/dist/chunk-KMWIKANF.js +0 -7
- package/dist/chunk-KMWIKANF.js.map +0 -1
- package/dist/chunk-RETLQXQB.cjs +0 -13
- package/dist/chunk-RETLQXQB.cjs.map +0 -1
- package/dist/chunk-W3Z24XII.js +0 -14
- package/dist/chunk-W3Z24XII.js.map +0 -1
- package/dist/chunk-W7A6C74U.cjs +0 -27
- package/dist/chunk-W7A6C74U.cjs.map +0 -1
- package/dist/error.cjs.map +0 -1
- package/dist/error.js +0 -5
- package/dist/error.js.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.js +0 -17
- package/dist/index.js.map +0 -1
- package/dist/monorepo.cjs.map +0 -1
- package/dist/monorepo.js +0 -5
- package/dist/monorepo.js.map +0 -1
- package/dist/package-json.cjs.map +0 -1
- package/dist/package-json.js +0 -3
- package/dist/package-json.js.map +0 -1
- package/dist/package-manager.cjs.map +0 -1
- package/dist/package-manager.js +0 -4
- package/dist/package-manager.js.map +0 -1
- package/dist/package.cjs.map +0 -1
- package/dist/package.js +0 -5
- package/dist/package.js.map +0 -1
- package/dist/tsconfig-G-HInwrt.d.ts +0 -30
- package/dist/tsconfig-d4zwQgCH.d.cts +0 -30
- package/dist/tsconfig.cjs +0 -36
- package/dist/tsconfig.cjs.map +0 -1
- package/dist/tsconfig.d.cts +0 -5
- package/dist/tsconfig.d.ts +0 -5
- package/dist/tsconfig.js +0 -3
- package/dist/tsconfig.js.map +0 -1
- package/dist/types-hoigZ9HA.d.cts +0 -9
- package/dist/types-hoigZ9HA.d.ts +0 -9
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var o=Object.defineProperty;var t=(a,e)=>o(a,"name",{value:e,configurable:!0});const n=require("../package-manager.cjs");var c=Object.defineProperty,s=t((a,e)=>c(a,"name",{value:e,configurable:!0}),"t");class i extends Error{static{t(this,"u")}static{s(this,"PackageNotFoundError")}constructor(e,r){if(typeof e=="string"&&(e=[e]),e.length===0){super("Package was not found.");return}if(r===void 0)try{r=n.findPackageManagerSync().packageManager}catch{}r===void 0&&(r="npm"),super(`Package '${e.join(" ")}' was not found. Please install it using '${r} install ${e.join(" ")}'`)}get code(){return"PACKAGE_NOT_FOUND"}set code(e){throw new Error("Cannot overwrite code PACKAGE_NOT_FOUND")}get name(){return"PackageNotFoundError"}set name(e){throw new Error("Cannot overwrite name of PackageNotFoundError")}}const u=i;exports.u=u;
|
|
@@ -0,0 +1 @@
|
|
|
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,we as b,se as c,re as d,Ce as e,ye as f,te as i,k as r,ge as w};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const i=require("../shared/package.DipMHw9r.cjs");exports.findTSConfig=i.findTSConfig;exports.findTSConfigSync=i.findTSConfigSync;exports.findTsConfig=i.findTsConfig;exports.findTsConfigSync=i.findTsConfigSync;exports.implicitBaseUrlSymbol=i.implicitBaseUrlSymbol;exports.readTsConfig=i.readTsConfig;exports.writeTSConfig=i.writeTSConfig;exports.writeTsConfig=i.writeTsConfig;exports.writeTsConfigSync=i.writeTsConfigSync;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { T as TsConfigJsonResolved, a as TsConfigJson } from '../shared/package.SZmjOQBM.cjs';
|
|
2
|
+
import { WriteJsonOptions } from '@visulima/fs';
|
|
3
|
+
import 'normalize-package-data';
|
|
4
|
+
|
|
5
|
+
type Options$1 = {
|
|
6
|
+
cache?: Map<string, TsConfigJsonResolved> | boolean;
|
|
7
|
+
configFileName?: string;
|
|
8
|
+
};
|
|
9
|
+
type TsConfigResult = {
|
|
10
|
+
config: TsConfigJsonResolved;
|
|
11
|
+
path: string;
|
|
12
|
+
};
|
|
13
|
+
declare const findTsConfig: (cwd?: URL | string, options?: Options$1) => Promise<TsConfigResult>;
|
|
14
|
+
declare const findTSConfig: (cwd?: URL | string, options?: Options$1) => Promise<TsConfigResult>;
|
|
15
|
+
declare const findTsConfigSync: (cwd?: URL | string, options?: Options$1) => TsConfigResult;
|
|
16
|
+
declare const findTSConfigSync: (cwd?: URL | string, options?: Options$1) => TsConfigResult;
|
|
17
|
+
|
|
18
|
+
type Options = {
|
|
19
|
+
tscCompatible?: boolean;
|
|
20
|
+
};
|
|
21
|
+
declare const implicitBaseUrlSymbol: unique symbol;
|
|
22
|
+
declare const readTsConfig: (tsconfigPath: string, options?: Options) => TsConfigJsonResolved;
|
|
23
|
+
|
|
24
|
+
declare const writeTsConfig: (tsConfig: TsConfigJson, options?: WriteJsonOptions & {
|
|
25
|
+
cwd?: URL | string;
|
|
26
|
+
}) => Promise<void>;
|
|
27
|
+
declare const writeTSConfig: (tsConfig: TsConfigJson, options?: WriteJsonOptions & {
|
|
28
|
+
cwd?: URL | string;
|
|
29
|
+
}) => Promise<void>;
|
|
30
|
+
declare const writeTsConfigSync: (tsConfig: TsConfigJson, options?: WriteJsonOptions & {
|
|
31
|
+
cwd?: URL | string;
|
|
32
|
+
}) => void;
|
|
33
|
+
|
|
34
|
+
export { type TsConfigResult, findTSConfig, findTSConfigSync, findTsConfig, findTsConfigSync, implicitBaseUrlSymbol, readTsConfig, writeTSConfig, writeTsConfig, writeTsConfigSync };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { T as TsConfigJsonResolved, a as TsConfigJson } from '../shared/package.SZmjOQBM.mjs';
|
|
2
|
+
import { WriteJsonOptions } from '@visulima/fs';
|
|
3
|
+
import 'normalize-package-data';
|
|
4
|
+
|
|
5
|
+
type Options$1 = {
|
|
6
|
+
cache?: Map<string, TsConfigJsonResolved> | boolean;
|
|
7
|
+
configFileName?: string;
|
|
8
|
+
};
|
|
9
|
+
type TsConfigResult = {
|
|
10
|
+
config: TsConfigJsonResolved;
|
|
11
|
+
path: string;
|
|
12
|
+
};
|
|
13
|
+
declare const findTsConfig: (cwd?: URL | string, options?: Options$1) => Promise<TsConfigResult>;
|
|
14
|
+
declare const findTSConfig: (cwd?: URL | string, options?: Options$1) => Promise<TsConfigResult>;
|
|
15
|
+
declare const findTsConfigSync: (cwd?: URL | string, options?: Options$1) => TsConfigResult;
|
|
16
|
+
declare const findTSConfigSync: (cwd?: URL | string, options?: Options$1) => TsConfigResult;
|
|
17
|
+
|
|
18
|
+
type Options = {
|
|
19
|
+
tscCompatible?: boolean;
|
|
20
|
+
};
|
|
21
|
+
declare const implicitBaseUrlSymbol: unique symbol;
|
|
22
|
+
declare const readTsConfig: (tsconfigPath: string, options?: Options) => TsConfigJsonResolved;
|
|
23
|
+
|
|
24
|
+
declare const writeTsConfig: (tsConfig: TsConfigJson, options?: WriteJsonOptions & {
|
|
25
|
+
cwd?: URL | string;
|
|
26
|
+
}) => Promise<void>;
|
|
27
|
+
declare const writeTSConfig: (tsConfig: TsConfigJson, options?: WriteJsonOptions & {
|
|
28
|
+
cwd?: URL | string;
|
|
29
|
+
}) => Promise<void>;
|
|
30
|
+
declare const writeTsConfigSync: (tsConfig: TsConfigJson, options?: WriteJsonOptions & {
|
|
31
|
+
cwd?: URL | string;
|
|
32
|
+
}) => void;
|
|
33
|
+
|
|
34
|
+
export { type TsConfigResult, findTSConfig, findTSConfigSync, findTsConfig, findTsConfigSync, implicitBaseUrlSymbol, readTsConfig, writeTSConfig, writeTsConfig, writeTsConfigSync };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { T as TsConfigJsonResolved, a as TsConfigJson } from '../shared/package.SZmjOQBM.js';
|
|
2
|
+
import { WriteJsonOptions } from '@visulima/fs';
|
|
3
|
+
import 'normalize-package-data';
|
|
4
|
+
|
|
5
|
+
type Options$1 = {
|
|
6
|
+
cache?: Map<string, TsConfigJsonResolved> | boolean;
|
|
7
|
+
configFileName?: string;
|
|
8
|
+
};
|
|
9
|
+
type TsConfigResult = {
|
|
10
|
+
config: TsConfigJsonResolved;
|
|
11
|
+
path: string;
|
|
12
|
+
};
|
|
13
|
+
declare const findTsConfig: (cwd?: URL | string, options?: Options$1) => Promise<TsConfigResult>;
|
|
14
|
+
declare const findTSConfig: (cwd?: URL | string, options?: Options$1) => Promise<TsConfigResult>;
|
|
15
|
+
declare const findTsConfigSync: (cwd?: URL | string, options?: Options$1) => TsConfigResult;
|
|
16
|
+
declare const findTSConfigSync: (cwd?: URL | string, options?: Options$1) => TsConfigResult;
|
|
17
|
+
|
|
18
|
+
type Options = {
|
|
19
|
+
tscCompatible?: boolean;
|
|
20
|
+
};
|
|
21
|
+
declare const implicitBaseUrlSymbol: unique symbol;
|
|
22
|
+
declare const readTsConfig: (tsconfigPath: string, options?: Options) => TsConfigJsonResolved;
|
|
23
|
+
|
|
24
|
+
declare const writeTsConfig: (tsConfig: TsConfigJson, options?: WriteJsonOptions & {
|
|
25
|
+
cwd?: URL | string;
|
|
26
|
+
}) => Promise<void>;
|
|
27
|
+
declare const writeTSConfig: (tsConfig: TsConfigJson, options?: WriteJsonOptions & {
|
|
28
|
+
cwd?: URL | string;
|
|
29
|
+
}) => Promise<void>;
|
|
30
|
+
declare const writeTsConfigSync: (tsConfig: TsConfigJson, options?: WriteJsonOptions & {
|
|
31
|
+
cwd?: URL | string;
|
|
32
|
+
}) => void;
|
|
33
|
+
|
|
34
|
+
export { type TsConfigResult, findTSConfig, findTSConfigSync, findTsConfig, findTsConfigSync, implicitBaseUrlSymbol, readTsConfig, writeTSConfig, writeTsConfig, writeTsConfigSync };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{f as s,b as f,a,c as o,i as g,r,w as C,d as T,e}from"../shared/package.zhGeUcxO.mjs";export{s as findTSConfig,f as findTSConfigSync,a as findTsConfig,o as findTsConfigSync,g as implicitBaseUrlSymbol,r as readTsConfig,C as writeTSConfig,T as writeTsConfig,e as writeTsConfigSync};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@visulima/package",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.3",
|
|
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",
|
|
@@ -61,8 +61,8 @@
|
|
|
61
61
|
"default": "./dist/index.cjs"
|
|
62
62
|
},
|
|
63
63
|
"import": {
|
|
64
|
-
"types": "./dist/index.d.
|
|
65
|
-
"default": "./dist/index.
|
|
64
|
+
"types": "./dist/index.d.mts",
|
|
65
|
+
"default": "./dist/index.mjs"
|
|
66
66
|
}
|
|
67
67
|
},
|
|
68
68
|
"./monorepo": {
|
|
@@ -71,8 +71,8 @@
|
|
|
71
71
|
"default": "./dist/monorepo.cjs"
|
|
72
72
|
},
|
|
73
73
|
"import": {
|
|
74
|
-
"types": "./dist/monorepo.d.
|
|
75
|
-
"default": "./dist/monorepo.
|
|
74
|
+
"types": "./dist/monorepo.d.mts",
|
|
75
|
+
"default": "./dist/monorepo.mjs"
|
|
76
76
|
}
|
|
77
77
|
},
|
|
78
78
|
"./package": {
|
|
@@ -81,8 +81,8 @@
|
|
|
81
81
|
"default": "./dist/package.cjs"
|
|
82
82
|
},
|
|
83
83
|
"import": {
|
|
84
|
-
"types": "./dist/package.d.
|
|
85
|
-
"default": "./dist/package.
|
|
84
|
+
"types": "./dist/package.d.mts",
|
|
85
|
+
"default": "./dist/package.mjs"
|
|
86
86
|
}
|
|
87
87
|
},
|
|
88
88
|
"./package-json": {
|
|
@@ -91,8 +91,8 @@
|
|
|
91
91
|
"default": "./dist/package-json.cjs"
|
|
92
92
|
},
|
|
93
93
|
"import": {
|
|
94
|
-
"types": "./dist/package-json.d.
|
|
95
|
-
"default": "./dist/package-json.
|
|
94
|
+
"types": "./dist/package-json.d.mts",
|
|
95
|
+
"default": "./dist/package-json.mjs"
|
|
96
96
|
}
|
|
97
97
|
},
|
|
98
98
|
"./package-manager": {
|
|
@@ -101,18 +101,18 @@
|
|
|
101
101
|
"default": "./dist/package-manager.cjs"
|
|
102
102
|
},
|
|
103
103
|
"import": {
|
|
104
|
-
"types": "./dist/package-manager.d.
|
|
105
|
-
"default": "./dist/package-manager.
|
|
104
|
+
"types": "./dist/package-manager.d.mts",
|
|
105
|
+
"default": "./dist/package-manager.mjs"
|
|
106
106
|
}
|
|
107
107
|
},
|
|
108
108
|
"./tsconfig": {
|
|
109
109
|
"require": {
|
|
110
|
-
"types": "./dist/tsconfig.d.cts",
|
|
111
|
-
"default": "./dist/tsconfig.cjs"
|
|
110
|
+
"types": "./dist/tsconfig/index.d.cts",
|
|
111
|
+
"default": "./dist/tsconfig/index.cjs"
|
|
112
112
|
},
|
|
113
113
|
"import": {
|
|
114
|
-
"types": "./dist/tsconfig.d.
|
|
115
|
-
"default": "./dist/tsconfig.
|
|
114
|
+
"types": "./dist/tsconfig/index.d.mts",
|
|
115
|
+
"default": "./dist/tsconfig/index.mjs"
|
|
116
116
|
}
|
|
117
117
|
},
|
|
118
118
|
"./error": {
|
|
@@ -121,14 +121,14 @@
|
|
|
121
121
|
"default": "./dist/error.cjs"
|
|
122
122
|
},
|
|
123
123
|
"import": {
|
|
124
|
-
"types": "./dist/error.d.
|
|
125
|
-
"default": "./dist/error.
|
|
124
|
+
"types": "./dist/error.d.mts",
|
|
125
|
+
"default": "./dist/error.mjs"
|
|
126
126
|
}
|
|
127
127
|
},
|
|
128
128
|
"./package.json": "./package.json"
|
|
129
129
|
},
|
|
130
130
|
"main": "dist/index.cjs",
|
|
131
|
-
"module": "dist/index.
|
|
131
|
+
"module": "dist/index.mjs",
|
|
132
132
|
"types": "dist/index.d.ts",
|
|
133
133
|
"files": [
|
|
134
134
|
"dist/**",
|
|
@@ -141,10 +141,10 @@
|
|
|
141
141
|
"@visulima/path": "1.0.1",
|
|
142
142
|
"jsonc-parser": "^3.2.1",
|
|
143
143
|
"normalize-package-data": "^6.0.1",
|
|
144
|
-
"resolve-pkg-maps": "^1.0.0"
|
|
145
|
-
"type-fest": "^4.18.2"
|
|
144
|
+
"resolve-pkg-maps": "^1.0.0"
|
|
146
145
|
},
|
|
147
146
|
"devDependencies": {
|
|
147
|
+
"type-fest": "^4.18.2",
|
|
148
148
|
"@anolilab/eslint-config": "^15.0.3",
|
|
149
149
|
"@anolilab/prettier-config": "^5.0.14",
|
|
150
150
|
"@anolilab/semantic-release-pnpm": "^1.1.0",
|
|
@@ -173,7 +173,8 @@
|
|
|
173
173
|
"semantic-release": "^23.1.1",
|
|
174
174
|
"strip-ansi": "^7.1.0",
|
|
175
175
|
"tempy": "^3.1.0",
|
|
176
|
-
"
|
|
176
|
+
"@visulima/packem": "^1.0.0-alpha.20",
|
|
177
|
+
"esbuild": "^0.21.4",
|
|
177
178
|
"typescript": "^5.4.5",
|
|
178
179
|
"vitest": "^1.6.0",
|
|
179
180
|
"which-pm-runs": "file:",
|
|
@@ -203,20 +204,11 @@
|
|
|
203
204
|
"info_on_disabling_etc_no_deprecated": false
|
|
204
205
|
}
|
|
205
206
|
},
|
|
206
|
-
"sources": [
|
|
207
|
-
"src/error.ts",
|
|
208
|
-
"src/index.ts",
|
|
209
|
-
"src/monorepo.ts",
|
|
210
|
-
"src/package.ts",
|
|
211
|
-
"src/package-json.ts",
|
|
212
|
-
"src/package-manager.ts",
|
|
213
|
-
"src/tsconfig.ts"
|
|
214
|
-
],
|
|
215
207
|
"scripts": {
|
|
216
|
-
"build": "cross-env NODE_ENV=development
|
|
217
|
-
"build:prod": "cross-env NODE_ENV=production
|
|
208
|
+
"build": "cross-env NODE_ENV=development packem build",
|
|
209
|
+
"build:prod": "cross-env NODE_ENV=production packem build",
|
|
218
210
|
"clean": "rimraf node_modules dist .eslintcache",
|
|
219
|
-
"dev": "
|
|
211
|
+
"dev": "cross-env NODE_ENV=development packem build --watch",
|
|
220
212
|
"lint:eslint": "eslint . --ext js,cjs,mjs,jsx,ts,tsx,json,yaml,yml,md,mdx --max-warnings=0 --config .eslintrc.cjs",
|
|
221
213
|
"lint:eslint:fix": "pnpm run lint:eslint --fix",
|
|
222
214
|
"lint:package-json": "publint --strict",
|
package/dist/chunk-5UU4RIJA.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { c } from './chunk-BGVUNBLL.js';
|
|
2
|
-
import { existsSync, readFileSync } from 'node:fs';
|
|
3
|
-
import { findUp, readJson } from '@visulima/fs';
|
|
4
|
-
import { NotFoundError } from '@visulima/fs/error';
|
|
5
|
-
import { dirname, join } from '@visulima/path';
|
|
6
|
-
|
|
7
|
-
var x=async n=>{let a=await findUp(["lerna.json","turbo.json"],{type:"file",...n&&{cwd:n}});if(a?.endsWith("lerna.json")){let o=await readJson(a);if(o.useWorkspaces||o.packages)return {path:dirname(a),strategy:"lerna"}}let s=a?.endsWith("turbo.json");try{let{packageManager:o,path:r}=await c(n);if(["npm","yarn"].includes(o)){let t=join(r,"package.json");if(existsSync(t)&&readFileSync(join(r,"package.json"),"utf8").includes("workspaces"))return {path:r,strategy:s?"turbo":o}}else if(o==="pnpm"){let t=join(r,"pnpm-workspace.yaml");if(existsSync(t))return {path:r,strategy:s?"turbo":"pnpm"}}}catch(o){if(!(o instanceof NotFoundError))throw o}throw new Error(`No monorepo root could be found upwards from the directory ${n} using lerna, yarn, pnpm, or npm as indicators.`)};
|
|
8
|
-
|
|
9
|
-
export { x as a };
|
|
10
|
-
//# sourceMappingURL=out.js.map
|
|
11
|
-
//# sourceMappingURL=chunk-5UU4RIJA.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/monorepo.ts"],"names":["existsSync","readFileSync","findUp","readJson","NotFoundError","dirname","join","findMonorepoRoot","cwd","workspaceFilePath","lerna","isTurbo","packageManager","path","findPackageManager","packageJsonFilePath","pnpmWorkspacesFilePath","error"],"mappings":"wCAAA,OAAS,cAAAA,EAAY,gBAAAC,MAAoB,UAEzC,OAAS,UAAAC,EAAQ,YAAAC,MAAgB,eACjC,OAAS,iBAAAC,MAAqB,qBAC9B,OAAS,WAAAC,EAAS,QAAAC,MAAY,iBAsBvB,IAAMC,EAAmB,MAAOC,GAA8C,CACjF,IAAMC,EAAoB,MAAMP,EAAO,CAAC,aAAc,YAAY,EAAG,CACjE,KAAM,OACN,GAAIM,GAAO,CAAE,IAAAA,CAAI,CACrB,CAAC,EAED,GAAIC,GAAmB,SAAS,YAAY,EAAG,CAC3C,IAAMC,EAAQ,MAAMP,EAA2DM,CAAiB,EAEhG,GAAIC,EAAM,eAAiBA,EAAM,SAC7B,MAAO,CACH,KAAML,EAAQI,CAAiB,EAC/B,SAAU,OACd,CAER,CAEA,IAAME,EAAUF,GAAmB,SAAS,YAAY,EAExD,GAAI,CACA,GAAM,CAAE,eAAAG,EAAgB,KAAAC,CAAK,EAAI,MAAMC,EAAmBN,CAAG,EAE7D,GAAI,CAAC,MAAO,MAAM,EAAE,SAASI,CAAc,EAAG,CAC1C,IAAMG,EAAsBT,EAAKO,EAAM,cAAc,EAGrD,GAAIb,EAAWe,CAAmB,GAEVd,EAAaK,EAAKO,EAAM,cAAc,EAAG,MAAM,EAEnD,SAAS,YAAY,EACjC,MAAO,CACH,KAAAA,EACA,SAAUF,EAAU,QAAWC,CACnC,CAGZ,SAAWA,IAAmB,OAAQ,CAClC,IAAMI,EAAyBV,EAAKO,EAAM,qBAAqB,EAG/D,GAAIb,EAAWgB,CAAsB,EACjC,MAAO,CACH,KAAAH,EACA,SAAUF,EAAU,QAAU,MAClC,CAER,CAEJ,OAASM,EAAY,CAEjB,GAAI,EAAEA,aAAiBb,GACnB,MAAMa,CAEd,CAEA,MAAM,IAAI,MAAM,8DAA8DT,CAAa,iDAAiD,CAChJ","sourcesContent":["import { existsSync, readFileSync } from \"node:fs\";\n\nimport { findUp, readJson } from \"@visulima/fs\";\nimport { NotFoundError } from \"@visulima/fs/error\";\nimport { dirname, join } from \"@visulima/path\";\n\nimport { findPackageManager } from \"./package-manager\";\n\nexport type Strategy = \"lerna\" | \"npm\" | \"pnpm\" | \"turbo\" | \"yarn\";\n\nexport interface RootMonorepo<T extends Strategy = Strategy> {\n path: string;\n strategy: T;\n}\n\n/**\n * An asynchronous function to find the root directory path and strategy for a monorepo based on\n * the given current working directory (cwd).\n *\n * @param cwd - The current working directory. The type of `cwd` is part of an `Options` type, specifically `Options[\"cwd\"]`.\n * Default is undefined.\n * @returns A `Promise` that resolves to the root directory path and strategy for the monorepo.\n * The type of the returned promise is `Promise<RootMonorepo>`.\n * @throws An `Error` if no monorepo root can be found using lerna, yarn, pnpm, or npm as indicators.\n */\n// eslint-disable-next-line sonarjs/cognitive-complexity\nexport const findMonorepoRoot = async (cwd?: URL | string): Promise<RootMonorepo> => {\n const workspaceFilePath = await findUp([\"lerna.json\", \"turbo.json\"], {\n type: \"file\",\n ...(cwd && { cwd }),\n });\n\n if (workspaceFilePath?.endsWith(\"lerna.json\")) {\n const lerna = await readJson<{ packages?: string[]; useWorkspaces?: boolean }>(workspaceFilePath);\n\n if (lerna.useWorkspaces || lerna.packages) {\n return {\n path: dirname(workspaceFilePath),\n strategy: \"lerna\",\n };\n }\n }\n\n const isTurbo = workspaceFilePath?.endsWith(\"turbo.json\");\n\n try {\n const { packageManager, path } = await findPackageManager(cwd);\n\n if ([\"npm\", \"yarn\"].includes(packageManager)) {\n const packageJsonFilePath = join(path, \"package.json\");\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (existsSync(packageJsonFilePath)) {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n const packageJson = readFileSync(join(path, \"package.json\"), \"utf8\");\n\n if (packageJson.includes(\"workspaces\")) {\n return {\n path,\n strategy: isTurbo ? \"turbo\" : (packageManager as \"npm\" | \"yarn\"),\n };\n }\n }\n } else if (packageManager === \"pnpm\") {\n const pnpmWorkspacesFilePath = join(path, \"pnpm-workspace.yaml\");\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (existsSync(pnpmWorkspacesFilePath)) {\n return {\n path,\n strategy: isTurbo ? \"turbo\" : \"pnpm\",\n };\n }\n }\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n // Skip this error to show the error message from the next block\n if (!(error instanceof NotFoundError)) {\n throw error;\n }\n }\n\n throw new Error(`No monorepo root could be found upwards from the directory ${cwd as string} using lerna, yarn, pnpm, or npm as indicators.`);\n};\n"]}
|
package/dist/chunk-BGVUNBLL.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { e } from './chunk-HGV2BL7M.js';
|
|
2
|
-
import { execSync } from 'node:child_process';
|
|
3
|
-
import { existsSync, readFileSync } from 'node:fs';
|
|
4
|
-
import { findUp, findUpSync } from '@visulima/fs';
|
|
5
|
-
import { NotFoundError } from '@visulima/fs/error';
|
|
6
|
-
import { join, dirname } from '@visulima/path';
|
|
7
|
-
|
|
8
|
-
var o=["yarn.lock","package-lock.json","pnpm-lock.yaml","npm-shrinkwrap.json","bun.lockb"],m=a=>{let n;if(o.forEach(r=>{!n&&existsSync(join(a,r))&&(n=join(a,r));}),n)return n;let e$1=join(a,"package.json");if(existsSync(e$1)&&e(readFileSync(e$1,"utf8")).packageManager!==void 0)return e$1},f=a=>{if(!a)throw new NotFoundError("Could not find a package manager");if(a.endsWith("package.json")){let n=e(a);if(n.packageManager){let r=["npm","yarn","pnpm","bun"].find(l=>n.packageManager.startsWith(l));if(r)return {packageManager:r,path:dirname(a)}}}if(a.endsWith("yarn.lock"))return {packageManager:"yarn",path:dirname(a)};if(a.endsWith("package-lock.json")||a.endsWith("npm-shrinkwrap.json"))return {packageManager:"npm",path:dirname(a)};if(a.endsWith("pnpm-lock.yaml"))return {packageManager:"pnpm",path:dirname(a)};if(a.endsWith("bun.lockb"))return {packageManager:"bun",path:dirname(a)};throw new NotFoundError("Could not find a package manager")},b=async a=>{let n=await findUp(o,{type:"file",...a&&{cwd:a}});if(!n)throw new Error("Could not find lock file");return n},j=a=>{let n=findUpSync(o,{type:"file",...a&&{cwd:a}});if(!n)throw new Error("Could not find lock file");return n},U=async a=>{let n=await findUp(m,{...a&&{cwd:a}});return f(n)},W=a=>{let n=findUpSync(m,{...a&&{cwd:a}});return f(n)},L=a=>execSync(`${a} --version`).toString("utf8").trim(),_=async()=>{if(!process.env.npm_config_user_agent)return;let a=process.env.npm_config_user_agent.split(" ")[0],n=a.lastIndexOf("/"),e=a.slice(0,Math.max(0,n));return {name:e==="npminstall"?"cnpm":e,version:a.slice(Math.max(0,n+1))}};
|
|
9
|
-
|
|
10
|
-
export { b as a, j as b, U as c, W as d, L as e, _ as f };
|
|
11
|
-
//# sourceMappingURL=out.js.map
|
|
12
|
-
//# sourceMappingURL=chunk-BGVUNBLL.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/package-manager.ts"],"names":["execSync","existsSync","readFileSync","findUp","findUpSync","NotFoundError","dirname","join","lockFileNames","packageMangerFindUpMatcher","directory","lockFile","lockFileName","packageJsonFilePath","parsePackageJson","findPackageManagerOnFile","foundFile","packageJson","foundPackageManager","prefix","findLockFile","cwd","filePath","findLockFileSync","findPackageManager","findPackageManagerSync","getPackageManagerVersion","name","identifyInitiatingPackageManager","pmSpec","separatorPos"],"mappings":"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","sourcesContent":["import { execSync } from \"node:child_process\";\nimport { existsSync, readFileSync } from \"node:fs\";\n\nimport { findUp, findUpSync } from \"@visulima/fs\";\nimport { NotFoundError } from \"@visulima/fs/error\";\nimport { dirname, join } from \"@visulima/path\";\n\nimport { parsePackageJson } from \"./package-json\";\n\nconst lockFileNames = [\"yarn.lock\", \"package-lock.json\", \"pnpm-lock.yaml\", \"npm-shrinkwrap.json\", \"bun.lockb\"];\n\nconst packageMangerFindUpMatcher = (directory: string) => {\n let lockFile: string | undefined;\n\n lockFileNames.forEach((lockFileName) => {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (!lockFile && existsSync(join(directory, lockFileName))) {\n lockFile = join(directory, lockFileName);\n }\n });\n\n if (lockFile) {\n return lockFile;\n }\n\n const packageJsonFilePath = join(directory, \"package.json\");\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (existsSync(packageJsonFilePath)) {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n const packageJson = parsePackageJson(readFileSync(packageJsonFilePath, \"utf8\"));\n\n if (packageJson.packageManager !== undefined) {\n return packageJsonFilePath;\n }\n }\n\n return undefined;\n};\n\nconst findPackageManagerOnFile = (foundFile: string | undefined): PackageManagerResult => {\n if (!foundFile) {\n throw new NotFoundError(\"Could not find a package manager\");\n }\n\n if (foundFile.endsWith(\"package.json\")) {\n const packageJson = parsePackageJson(foundFile);\n\n if (packageJson.packageManager) {\n const packageManagerNames = [\"npm\", \"yarn\", \"pnpm\", \"bun\"] as const;\n const foundPackageManager = packageManagerNames.find((prefix) => (packageJson.packageManager as string).startsWith(prefix));\n\n if (foundPackageManager) {\n return {\n packageManager: foundPackageManager,\n path: dirname(foundFile),\n };\n }\n }\n }\n\n if (foundFile.endsWith(\"yarn.lock\")) {\n return {\n packageManager: \"yarn\",\n path: dirname(foundFile),\n };\n }\n\n if (foundFile.endsWith(\"package-lock.json\") || foundFile.endsWith(\"npm-shrinkwrap.json\")) {\n return {\n packageManager: \"npm\",\n path: dirname(foundFile),\n };\n }\n\n if (foundFile.endsWith(\"pnpm-lock.yaml\")) {\n return {\n packageManager: \"pnpm\",\n path: dirname(foundFile),\n };\n }\n\n if (foundFile.endsWith(\"bun.lockb\")) {\n return {\n packageManager: \"bun\",\n path: dirname(foundFile),\n };\n }\n\n throw new NotFoundError(\"Could not find a package manager\");\n};\n\n/**\n * An asynchronous function that finds a lock file in the specified directory or any of its parent directories.\n *\n * @param cwd - Optional. The directory path to start the search from. The type of `cwd` is part of an `Options` type,\n * specifically `URL | string`. Defaults to the current working directory.\n * @returns A `Promise` that resolves with the path of the found lock file.\n * The type of the returned promise is `Promise<string>`.\n * @throws An `Error` if no lock file is found.\n */\nexport const findLockFile = async (cwd?: URL | string): Promise<string> => {\n const filePath = await findUp(lockFileNames, {\n type: \"file\",\n ...(cwd && { cwd }),\n });\n\n if (!filePath) {\n throw new Error(\"Could not find lock file\");\n }\n\n return filePath;\n};\n\nexport const findLockFileSync = (cwd?: URL | string): string => {\n const filePath = findUpSync(lockFileNames, {\n type: \"file\",\n ...(cwd && { cwd }),\n });\n\n if (!filePath) {\n throw new Error(\"Could not find lock file\");\n }\n\n return filePath;\n};\n\nexport type PackageManager = \"bun\" | \"npm\" | \"pnpm\" | \"yarn\";\n\nexport type PackageManagerResult = {\n packageManager: PackageManager;\n path: string;\n};\n\n/**\n * An asynchronous function that finds the package manager used in a project based on the presence of lock files\n * or package.json configuration. If found, it returns the package manager and the path to the lock file or package.json.\n * Throws an error if no lock file or package.json is found.\n *\n * @param cwd - Optional. The current working directory to start the search from. The type of `cwd` is part of an `Options`\n * type, specifically `URL | string`.\n * @returns A `Promise` that resolves to an object containing the package manager and path.\n * The return type of the function is `Promise<PackageManagerResult>`.\n * @throws An `Error` if no lock file or package.json is found.\n */\nexport const findPackageManager = async (cwd?: URL | string): Promise<PackageManagerResult> => {\n const foundFile = await findUp(packageMangerFindUpMatcher, {\n ...(cwd && { cwd }),\n });\n\n return findPackageManagerOnFile(foundFile);\n};\n\n/**\n * An function that finds the package manager used in a project based on the presence of lock files\n * or package.json configuration. If found, it returns the package manager and the path to the lock file or package.json.\n * Throws an error if no lock file or package.json is found.\n *\n * @param cwd - Optional. The current working directory to start the search from. The type of `cwd` is part of an `Options`\n * type, specifically `URL | string`.\n * @returns A `Promise` that resolves to an object containing the package manager and path.\n * The return type of the function is `Promise<PackageManagerResult>`.\n * @throws An `Error` if no lock file or package.json is found.\n */\n\nexport const findPackageManagerSync = (cwd?: URL | string): PackageManagerResult => {\n const foundFile = findUpSync(packageMangerFindUpMatcher, {\n ...(cwd && { cwd }),\n });\n\n return findPackageManagerOnFile(foundFile);\n};\n\n/**\n * Function that retrieves the version of the specified package manager.\n *\n * @param name - The name of the package manager. The type of `name` is `string`.\n * @returns The version of the package manager. The return type of the function is `string`.\n */\nexport const getPackageManagerVersion = (name: string): string => execSync(`${name} --version`).toString(\"utf8\").trim();\n\n/**\n * An asynchronous function that detects what package manager executes the process.\n *\n * Supports npm, pnpm, Yarn, cnpm, and bun. And also any other package manager that sets the npm_config_user_agent env variable.\n *\n * @returns A `Promise` that resolves to an object containing the name and version of the package manager,\n * or undefined if the package manager information cannot be determined. The return type of the function\n * is `Promise<{ name: PackageManager | \"cnpm\"; version: string } | undefined>`.\n */\nexport const identifyInitiatingPackageManager = async (): Promise<\n | {\n name: PackageManager | \"cnpm\";\n version: string;\n }\n | undefined\n> => {\n if (!process.env.npm_config_user_agent) {\n return undefined;\n }\n\n const pmSpec = process.env.npm_config_user_agent.split(\" \")[0] as string;\n const separatorPos = pmSpec.lastIndexOf(\"/\");\n const name = pmSpec.slice(0, Math.max(0, separatorPos));\n\n return {\n name: name === \"npminstall\" ? \"cnpm\" : (name as PackageManager),\n version: pmSpec.slice(Math.max(0, separatorPos + 1)),\n };\n};\n"]}
|
package/dist/chunk-BHDWBI3F.cjs
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var fs$1 = require('fs');
|
|
4
|
-
var fs = require('@visulima/fs');
|
|
5
|
-
var error = require('@visulima/fs/error');
|
|
6
|
-
var utils = require('@visulima/fs/utils');
|
|
7
|
-
var path = require('@visulima/path');
|
|
8
|
-
var n = require('normalize-package-data');
|
|
9
|
-
|
|
10
|
-
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
-
|
|
12
|
-
var n__default = /*#__PURE__*/_interopDefault(n);
|
|
13
|
-
|
|
14
|
-
var m=new Map,O=async(e,o={})=>{let t=await fs.findUp("package.json",{...e&&{cwd:e},type:"file"});if(!t)throw new error.NotFoundError("No such file or directory, for package.json found.");let a=o.cache&&typeof o.cache!="boolean"?o.cache:m;if(o.cache&&a.has(t))return a.get(t);let s=await fs.readJson(t);n__default.default(s);let r={packageJson:s,path:t};return a.set(t,r),r},b=(e,o={})=>{let t=fs.findUpSync("package.json",{...e&&{cwd:e},type:"file"});if(!t)throw new error.NotFoundError("No such file or directory, for package.json found.");let a=o.cache&&typeof o.cache!="boolean"?o.cache:m;if(o.cache&&a.has(t))return a.get(t);let s=fs.readJsonSync(t);n__default.default(s);let r={packageJson:s,path:t};return a.set(t,r),r},S=async(e,o={})=>{let{cwd:t,...a}=o,s=utils.toPath(o.cwd??process.cwd());await fs.writeJson(path.join(s,"package.json"),e,a);},x=(e,o={})=>{let{cwd:t,...a}=o,s=utils.toPath(o.cwd??process.cwd());fs.writeJsonSync(path.join(s,"package.json"),e,a);},U=e=>{let o=e!==null&&typeof e=="object"&&!Array.isArray(e);if(!o&&!(typeof e=="string"))throw new TypeError("`packageFile` should be either an `object` or a `string`.");let a=o?structuredClone(e):fs$1.existsSync(e)?fs.readJsonSync(e):utils.parseJson(e);return n__default.default(a),a};
|
|
15
|
-
|
|
16
|
-
exports.a = O;
|
|
17
|
-
exports.b = b;
|
|
18
|
-
exports.c = S;
|
|
19
|
-
exports.d = x;
|
|
20
|
-
exports.e = U;
|
|
21
|
-
//# sourceMappingURL=out.js.map
|
|
22
|
-
//# sourceMappingURL=chunk-BHDWBI3F.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/package-json.ts"],"names":["existsSync","findUp","findUpSync","readJson","readJsonSync","writeJson","writeJsonSync","NotFoundError","parseJson","toPath","join","normalizeData","PackageJsonFileCache","findPackageJson","cwd","options","filePath","cache","packageJson","output","findPackageJsonSync","writePackageJson","data","writeOptions","directory","writePackageJsonSync","parsePackageJson","packageFile","isObject","json"],"mappings":"AAAA,OAAS,cAAAA,MAAkB,KAG3B,OAAS,UAAAC,EAAQ,cAAAC,EAAY,YAAAC,EAAU,gBAAAC,EAAc,aAAAC,EAAW,iBAAAC,MAAqB,eACrF,OAAS,iBAAAC,MAAqB,qBAC9B,OAAS,aAAAC,EAAW,UAAAC,MAAc,qBAClC,OAAS,QAAAC,MAAY,iBAErB,OAAOC,MAAmB,yBAS1B,IAAMC,EAAuB,IAAI,IAepBC,EAAkB,MAAOC,EAAoBC,EAAuB,CAAC,IAAqC,CACnH,IAAMC,EAAW,MAAMf,EAAO,eAAgB,CAC1C,GAAIa,GAAO,CAAE,IAAAA,CAAI,EACjB,KAAM,MACV,CAAC,EAED,GAAI,CAACE,EACD,MAAM,IAAIT,EAAc,oDAAoD,EAGhF,IAAMU,EAAQF,EAAQ,OAAS,OAAOA,EAAQ,OAAU,UAAYA,EAAQ,MAAQH,EAEpF,GAAIG,EAAQ,OAASE,EAAM,IAAID,CAAQ,EACnC,OAAOC,EAAM,IAAID,CAAQ,EAG7B,IAAME,EAAc,MAAMf,EAASa,CAAQ,EAE3CL,EAAcO,CAAoB,EAElC,IAAMC,EAAS,CACX,YAAaD,EACb,KAAMF,CACV,EAEA,OAAAC,EAAM,IAAID,EAAUG,CAAM,EAEnBA,CACX,EAEaC,EAAsB,CAACN,EAAoBC,EAAuB,CAAC,IAA4B,CACxG,IAAMC,EAAWd,EAAW,eAAgB,CACxC,GAAIY,GAAO,CAAE,IAAAA,CAAI,EACjB,KAAM,MACV,CAAC,EAED,GAAI,CAACE,EACD,MAAM,IAAIT,EAAc,oDAAoD,EAGhF,IAAMU,EAAQF,EAAQ,OAAS,OAAOA,EAAQ,OAAU,UAAYA,EAAQ,MAAQH,EAEpF,GAAIG,EAAQ,OAASE,EAAM,IAAID,CAAQ,EACnC,OAAOC,EAAM,IAAID,CAAQ,EAG7B,IAAME,EAAcd,EAAaY,CAAQ,EAEzCL,EAAcO,CAAoB,EAElC,IAAMC,EAAS,CACX,YAAaD,EACb,KAAMF,CACV,EAEA,OAAAC,EAAM,IAAID,EAAUG,CAAM,EAEnBA,CACX,EAYaE,EAAmB,MAAwBC,EAASP,EAAqD,CAAC,IAAqB,CACxI,GAAM,CAAE,IAAAD,EAAK,GAAGS,CAAa,EAAIR,EAC3BS,EAAYf,EAAOM,EAAQ,KAAO,QAAQ,IAAI,CAAC,EAErD,MAAMV,EAAUK,EAAKc,EAAW,cAAc,EAAGF,EAAMC,CAAY,CACvE,EAEaE,EAAuB,CAAkBH,EAASP,EAAqD,CAAC,IAAY,CAC7H,GAAM,CAAE,IAAAD,EAAK,GAAGS,CAAa,EAAIR,EAC3BS,EAAYf,EAAOM,EAAQ,KAAO,QAAQ,IAAI,CAAC,EAErDT,EAAcI,EAAKc,EAAW,cAAc,EAAGF,EAAMC,CAAY,CACrE,EAEaG,EAAoBC,GAA4D,CAEzF,IAAMC,EAAWD,IAAgB,MAAQ,OAAOA,GAAgB,UAAY,CAAC,MAAM,QAAQA,CAAW,EAGtG,GAAI,CAACC,GAAY,EAFA,OAAOD,GAAgB,UAGpC,MAAM,IAAI,UAAU,2DAA2D,EAGnF,IAAME,EAAOD,EACP,gBAAgBD,CAAW,EAE3B3B,EAAW2B,CAAqB,EAC9BvB,EAAauB,CAAqB,EAClCnB,EAAUmB,CAAqB,EAEvC,OAAAhB,EAAckB,CAAa,EAEpBA,CACX","sourcesContent":["import { existsSync } from \"node:fs\";\n\nimport type { WriteJsonOptions } from \"@visulima/fs\";\nimport { findUp, findUpSync, readJson, readJsonSync, writeJson, writeJsonSync } from \"@visulima/fs\";\nimport { NotFoundError } from \"@visulima/fs/error\";\nimport { parseJson, toPath } from \"@visulima/fs/utils\";\nimport { join } from \"@visulima/path\";\nimport type { Input } from \"normalize-package-data\";\nimport normalizeData from \"normalize-package-data\";\nimport type { JsonObject } from \"type-fest\";\n\nimport type { Cache, NormalizedPackageJson, PackageJson } from \"./types\";\n\ntype ReadOptions = {\n cache?: Cache<NormalizedReadResult> | boolean;\n};\n\nconst PackageJsonFileCache = new Map<string, NormalizedReadResult>();\n\nexport type NormalizedReadResult = {\n packageJson: NormalizedPackageJson;\n path: string;\n};\n\n/**\n * An asynchronous function to find the package.json file in the specified directory or its parent directories.\n *\n * @param cwd - The current working directory.\n * @returns A `Promise` that resolves to an object containing the parsed package.json data and the file path.\n * The type of the returned promise is `Promise<NormalizedReadResult>`.\n * @throws An `Error` if the package.json file cannot be found.\n */\nexport const findPackageJson = async (cwd?: URL | string, options: ReadOptions = {}): Promise<NormalizedReadResult> => {\n const filePath = await findUp(\"package.json\", {\n ...(cwd && { cwd }),\n type: \"file\",\n });\n\n if (!filePath) {\n throw new NotFoundError(\"No such file or directory, for package.json found.\");\n }\n\n const cache = options.cache && typeof options.cache !== \"boolean\" ? options.cache : PackageJsonFileCache;\n\n if (options.cache && cache.has(filePath)) {\n return cache.get(filePath) as NormalizedReadResult;\n }\n\n const packageJson = await readJson(filePath);\n\n normalizeData(packageJson as Input);\n\n const output = {\n packageJson: packageJson as NormalizedPackageJson,\n path: filePath,\n };\n\n cache.set(filePath, output);\n\n return output;\n};\n\nexport const findPackageJsonSync = (cwd?: URL | string, options: ReadOptions = {}): NormalizedReadResult => {\n const filePath = findUpSync(\"package.json\", {\n ...(cwd && { cwd }),\n type: \"file\",\n });\n\n if (!filePath) {\n throw new NotFoundError(\"No such file or directory, for package.json found.\");\n }\n\n const cache = options.cache && typeof options.cache !== \"boolean\" ? options.cache : PackageJsonFileCache;\n\n if (options.cache && cache.has(filePath)) {\n return cache.get(filePath) as NormalizedReadResult;\n }\n\n const packageJson = readJsonSync(filePath);\n\n normalizeData(packageJson as Input);\n\n const output = {\n packageJson: packageJson as NormalizedPackageJson,\n path: filePath,\n };\n\n cache.set(filePath, output);\n\n return output;\n};\n\n/**\n * An asynchronous function to write the package.json file with the given data.\n *\n * @param data - The package.json data to write. The data is an intersection type of `PackageJson` and a record where keys are `string` and values can be any type.\n * @param options - Optional. The options for writing the package.json. If not provided, an empty object will be used `{}`.\n * This is an intersection type of `WriteJsonOptions` and a record with an optional `cwd` key which type is `Options[\"cwd\"]`.\n * `cwd` represents the current working directory. If not specified, the default working directory will be used.\n * @returns A `Promise` that resolves once the package.json file has been written. The type of the returned promise is `Promise<void>`.\n */\n\nexport const writePackageJson = async <T = PackageJson>(data: T, options: WriteJsonOptions & { cwd?: URL | string } = {}): Promise<void> => {\n const { cwd, ...writeOptions } = options;\n const directory = toPath(options.cwd ?? process.cwd());\n\n await writeJson(join(directory, \"package.json\"), data, writeOptions);\n};\n\nexport const writePackageJsonSync = <T = PackageJson>(data: T, options: WriteJsonOptions & { cwd?: URL | string } = {}): void => {\n const { cwd, ...writeOptions } = options;\n const directory = toPath(options.cwd ?? process.cwd());\n\n writeJsonSync(join(directory, \"package.json\"), data, writeOptions);\n};\n\nexport const parsePackageJson = (packageFile: JsonObject | string): NormalizedPackageJson => {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n const isObject = packageFile !== null && typeof packageFile === \"object\" && !Array.isArray(packageFile);\n const isString = typeof packageFile === \"string\";\n\n if (!isObject && !isString) {\n throw new TypeError(\"`packageFile` should be either an `object` or a `string`.\");\n }\n\n const json = isObject\n ? structuredClone(packageFile)\n : // eslint-disable-next-line security/detect-non-literal-fs-filename\n existsSync(packageFile as string)\n ? readJsonSync(packageFile as string)\n : parseJson(packageFile as string);\n\n normalizeData(json as Input);\n\n return json as NormalizedPackageJson;\n};\n"]}
|
package/dist/chunk-C36BYRSZ.cjs
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var chunkBHDWBI3F_cjs = require('./chunk-BHDWBI3F.cjs');
|
|
4
|
-
var child_process = require('child_process');
|
|
5
|
-
var fs$1 = require('fs');
|
|
6
|
-
var fs = require('@visulima/fs');
|
|
7
|
-
var error = require('@visulima/fs/error');
|
|
8
|
-
var path = require('@visulima/path');
|
|
9
|
-
|
|
10
|
-
var o=["yarn.lock","package-lock.json","pnpm-lock.yaml","npm-shrinkwrap.json","bun.lockb"],m=a=>{let n;if(o.forEach(r=>{!n&&fs$1.existsSync(path.join(a,r))&&(n=path.join(a,r));}),n)return n;let e=path.join(a,"package.json");if(fs$1.existsSync(e)&&chunkBHDWBI3F_cjs.e(fs$1.readFileSync(e,"utf8")).packageManager!==void 0)return e},f=a=>{if(!a)throw new error.NotFoundError("Could not find a package manager");if(a.endsWith("package.json")){let n=chunkBHDWBI3F_cjs.e(a);if(n.packageManager){let r=["npm","yarn","pnpm","bun"].find(l=>n.packageManager.startsWith(l));if(r)return {packageManager:r,path:path.dirname(a)}}}if(a.endsWith("yarn.lock"))return {packageManager:"yarn",path:path.dirname(a)};if(a.endsWith("package-lock.json")||a.endsWith("npm-shrinkwrap.json"))return {packageManager:"npm",path:path.dirname(a)};if(a.endsWith("pnpm-lock.yaml"))return {packageManager:"pnpm",path:path.dirname(a)};if(a.endsWith("bun.lockb"))return {packageManager:"bun",path:path.dirname(a)};throw new error.NotFoundError("Could not find a package manager")},S=async a=>{let n=await fs.findUp(o,{type:"file",...a&&{cwd:a}});if(!n)throw new Error("Could not find lock file");return n},b=a=>{let n=fs.findUpSync(o,{type:"file",...a&&{cwd:a}});if(!n)throw new Error("Could not find lock file");return n},j=async a=>{let n=await fs.findUp(m,{...a&&{cwd:a}});return f(n)},U=a=>{let n=fs.findUpSync(m,{...a&&{cwd:a}});return f(n)},W=a=>child_process.execSync(`${a} --version`).toString("utf8").trim(),L=async()=>{if(!process.env.npm_config_user_agent)return;let a=process.env.npm_config_user_agent.split(" ")[0],n=a.lastIndexOf("/"),e=a.slice(0,Math.max(0,n));return {name:e==="npminstall"?"cnpm":e,version:a.slice(Math.max(0,n+1))}};
|
|
11
|
-
|
|
12
|
-
exports.a = S;
|
|
13
|
-
exports.b = b;
|
|
14
|
-
exports.c = j;
|
|
15
|
-
exports.d = U;
|
|
16
|
-
exports.e = W;
|
|
17
|
-
exports.f = L;
|
|
18
|
-
//# sourceMappingURL=out.js.map
|
|
19
|
-
//# sourceMappingURL=chunk-C36BYRSZ.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/package-manager.ts"],"names":["execSync","existsSync","readFileSync","findUp","findUpSync","NotFoundError","dirname","join","lockFileNames","packageMangerFindUpMatcher","directory","lockFile","lockFileName","packageJsonFilePath","parsePackageJson","findPackageManagerOnFile","foundFile","packageJson","foundPackageManager","prefix","findLockFile","cwd","filePath","findLockFileSync","findPackageManager","findPackageManagerSync","getPackageManagerVersion","name","identifyInitiatingPackageManager","pmSpec","separatorPos"],"mappings":"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","sourcesContent":["import { execSync } from \"node:child_process\";\nimport { existsSync, readFileSync } from \"node:fs\";\n\nimport { findUp, findUpSync } from \"@visulima/fs\";\nimport { NotFoundError } from \"@visulima/fs/error\";\nimport { dirname, join } from \"@visulima/path\";\n\nimport { parsePackageJson } from \"./package-json\";\n\nconst lockFileNames = [\"yarn.lock\", \"package-lock.json\", \"pnpm-lock.yaml\", \"npm-shrinkwrap.json\", \"bun.lockb\"];\n\nconst packageMangerFindUpMatcher = (directory: string) => {\n let lockFile: string | undefined;\n\n lockFileNames.forEach((lockFileName) => {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (!lockFile && existsSync(join(directory, lockFileName))) {\n lockFile = join(directory, lockFileName);\n }\n });\n\n if (lockFile) {\n return lockFile;\n }\n\n const packageJsonFilePath = join(directory, \"package.json\");\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (existsSync(packageJsonFilePath)) {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n const packageJson = parsePackageJson(readFileSync(packageJsonFilePath, \"utf8\"));\n\n if (packageJson.packageManager !== undefined) {\n return packageJsonFilePath;\n }\n }\n\n return undefined;\n};\n\nconst findPackageManagerOnFile = (foundFile: string | undefined): PackageManagerResult => {\n if (!foundFile) {\n throw new NotFoundError(\"Could not find a package manager\");\n }\n\n if (foundFile.endsWith(\"package.json\")) {\n const packageJson = parsePackageJson(foundFile);\n\n if (packageJson.packageManager) {\n const packageManagerNames = [\"npm\", \"yarn\", \"pnpm\", \"bun\"] as const;\n const foundPackageManager = packageManagerNames.find((prefix) => (packageJson.packageManager as string).startsWith(prefix));\n\n if (foundPackageManager) {\n return {\n packageManager: foundPackageManager,\n path: dirname(foundFile),\n };\n }\n }\n }\n\n if (foundFile.endsWith(\"yarn.lock\")) {\n return {\n packageManager: \"yarn\",\n path: dirname(foundFile),\n };\n }\n\n if (foundFile.endsWith(\"package-lock.json\") || foundFile.endsWith(\"npm-shrinkwrap.json\")) {\n return {\n packageManager: \"npm\",\n path: dirname(foundFile),\n };\n }\n\n if (foundFile.endsWith(\"pnpm-lock.yaml\")) {\n return {\n packageManager: \"pnpm\",\n path: dirname(foundFile),\n };\n }\n\n if (foundFile.endsWith(\"bun.lockb\")) {\n return {\n packageManager: \"bun\",\n path: dirname(foundFile),\n };\n }\n\n throw new NotFoundError(\"Could not find a package manager\");\n};\n\n/**\n * An asynchronous function that finds a lock file in the specified directory or any of its parent directories.\n *\n * @param cwd - Optional. The directory path to start the search from. The type of `cwd` is part of an `Options` type,\n * specifically `URL | string`. Defaults to the current working directory.\n * @returns A `Promise` that resolves with the path of the found lock file.\n * The type of the returned promise is `Promise<string>`.\n * @throws An `Error` if no lock file is found.\n */\nexport const findLockFile = async (cwd?: URL | string): Promise<string> => {\n const filePath = await findUp(lockFileNames, {\n type: \"file\",\n ...(cwd && { cwd }),\n });\n\n if (!filePath) {\n throw new Error(\"Could not find lock file\");\n }\n\n return filePath;\n};\n\nexport const findLockFileSync = (cwd?: URL | string): string => {\n const filePath = findUpSync(lockFileNames, {\n type: \"file\",\n ...(cwd && { cwd }),\n });\n\n if (!filePath) {\n throw new Error(\"Could not find lock file\");\n }\n\n return filePath;\n};\n\nexport type PackageManager = \"bun\" | \"npm\" | \"pnpm\" | \"yarn\";\n\nexport type PackageManagerResult = {\n packageManager: PackageManager;\n path: string;\n};\n\n/**\n * An asynchronous function that finds the package manager used in a project based on the presence of lock files\n * or package.json configuration. If found, it returns the package manager and the path to the lock file or package.json.\n * Throws an error if no lock file or package.json is found.\n *\n * @param cwd - Optional. The current working directory to start the search from. The type of `cwd` is part of an `Options`\n * type, specifically `URL | string`.\n * @returns A `Promise` that resolves to an object containing the package manager and path.\n * The return type of the function is `Promise<PackageManagerResult>`.\n * @throws An `Error` if no lock file or package.json is found.\n */\nexport const findPackageManager = async (cwd?: URL | string): Promise<PackageManagerResult> => {\n const foundFile = await findUp(packageMangerFindUpMatcher, {\n ...(cwd && { cwd }),\n });\n\n return findPackageManagerOnFile(foundFile);\n};\n\n/**\n * An function that finds the package manager used in a project based on the presence of lock files\n * or package.json configuration. If found, it returns the package manager and the path to the lock file or package.json.\n * Throws an error if no lock file or package.json is found.\n *\n * @param cwd - Optional. The current working directory to start the search from. The type of `cwd` is part of an `Options`\n * type, specifically `URL | string`.\n * @returns A `Promise` that resolves to an object containing the package manager and path.\n * The return type of the function is `Promise<PackageManagerResult>`.\n * @throws An `Error` if no lock file or package.json is found.\n */\n\nexport const findPackageManagerSync = (cwd?: URL | string): PackageManagerResult => {\n const foundFile = findUpSync(packageMangerFindUpMatcher, {\n ...(cwd && { cwd }),\n });\n\n return findPackageManagerOnFile(foundFile);\n};\n\n/**\n * Function that retrieves the version of the specified package manager.\n *\n * @param name - The name of the package manager. The type of `name` is `string`.\n * @returns The version of the package manager. The return type of the function is `string`.\n */\nexport const getPackageManagerVersion = (name: string): string => execSync(`${name} --version`).toString(\"utf8\").trim();\n\n/**\n * An asynchronous function that detects what package manager executes the process.\n *\n * Supports npm, pnpm, Yarn, cnpm, and bun. And also any other package manager that sets the npm_config_user_agent env variable.\n *\n * @returns A `Promise` that resolves to an object containing the name and version of the package manager,\n * or undefined if the package manager information cannot be determined. The return type of the function\n * is `Promise<{ name: PackageManager | \"cnpm\"; version: string } | undefined>`.\n */\nexport const identifyInitiatingPackageManager = async (): Promise<\n | {\n name: PackageManager | \"cnpm\";\n version: string;\n }\n | undefined\n> => {\n if (!process.env.npm_config_user_agent) {\n return undefined;\n }\n\n const pmSpec = process.env.npm_config_user_agent.split(\" \")[0] as string;\n const separatorPos = pmSpec.lastIndexOf(\"/\");\n const name = pmSpec.slice(0, Math.max(0, separatorPos));\n\n return {\n name: name === \"npminstall\" ? \"cnpm\" : (name as PackageManager),\n version: pmSpec.slice(Math.max(0, separatorPos + 1)),\n };\n};\n"]}
|
package/dist/chunk-EY5KVLRL.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { a, b } from './chunk-BGVUNBLL.js';
|
|
2
|
-
import { existsSync } from 'node:fs';
|
|
3
|
-
import { findUp, findUpSync, readJsonSync } from '@visulima/fs';
|
|
4
|
-
import { dirname, join } from '@visulima/path';
|
|
5
|
-
|
|
6
|
-
var g=t=>{if(existsSync(join(t,"package.json"))){let n=readJsonSync(join(t,"package.json"));if(n.name&&n.private!==!0)return "package.json"}},P=async t=>{try{let i=await a(t);return dirname(i)}catch{}let n=await findUp(".git/config",{...t&&{cwd:t},type:"file"});if(n)return dirname(dirname(n));let r=await findUp(g,{...t&&{cwd:t},type:"file"});if(r)return dirname(r);throw new Error("Could not find root directory")},J=t=>{try{let i=b(t);return dirname(i)}catch{}let n=findUpSync(".git/config",{...t&&{cwd:t},type:"file"});if(n)return dirname(dirname(n));let r=findUpSync(g,{...t&&{cwd:t},type:"file"});if(r)return dirname(r);throw new Error("Could not find root directory")};
|
|
7
|
-
|
|
8
|
-
export { P as a, J as b };
|
|
9
|
-
//# sourceMappingURL=out.js.map
|
|
10
|
-
//# sourceMappingURL=chunk-EY5KVLRL.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/package.ts"],"names":["existsSync","findUp","findUpSync","readJsonSync","dirname","join","packageJsonMatcher","directory","packageJson","findPackageRoot","cwd","lockFile","findLockFile","gitConfig","filePath","findPackageRootSync","findLockFileSync"],"mappings":"+CAAA,OAAS,cAAAA,MAAkB,UAE3B,OAAS,UAAAC,EAAQ,cAAAC,EAAY,gBAAAC,MAAoB,eACjD,OAAS,WAAAC,EAAS,QAAAC,MAAY,iBAK9B,IAAMC,EAAsBC,GAAsB,CAE9C,GAAIP,EAAWK,EAAKE,EAAW,cAAc,CAAC,EAAG,CAC7C,IAAMC,EAAcL,EAA0BE,EAAKE,EAAW,cAAc,CAAC,EAE7E,GAAIC,EAAY,MAAQA,EAAY,UAAY,GAC5C,MAAO,cAEf,CAGJ,EAaaC,EAAkB,MAAOC,GAAwC,CAC1E,GAAI,CACA,IAAMC,EAAW,MAAMC,EAAaF,CAAG,EAEvC,OAAON,EAAQO,CAAQ,CAC3B,MAAQ,CAER,CAEA,IAAME,EAAY,MAAMZ,EAAO,cAAe,CAC1C,GAAIS,GAAO,CAAE,IAAAA,CAAI,EACjB,KAAM,MACV,CAAC,EAED,GAAIG,EACA,OAAOT,EAAQA,EAAQS,CAAS,CAAC,EAGrC,IAAMC,EAAW,MAAMb,EAAOK,EAAoB,CAC9C,GAAII,GAAO,CAAE,IAAAA,CAAI,EACjB,KAAM,MACV,CAAC,EAED,GAAII,EACA,OAAOV,EAAQU,CAAQ,EAG3B,MAAM,IAAI,MAAM,+BAA+B,CACnD,EAEaC,EAAuBL,GAA+B,CAC/D,GAAI,CACA,IAAMC,EAAWK,EAAiBN,CAAG,EAErC,OAAON,EAAQO,CAAQ,CAC3B,MAAQ,CAER,CAEA,IAAME,EAAYX,EAAW,cAAe,CACxC,GAAIQ,GAAO,CAAE,IAAAA,CAAI,EACjB,KAAM,MACV,CAAC,EAED,GAAIG,EACA,OAAOT,EAAQA,EAAQS,CAAS,CAAC,EAGrC,IAAMC,EAAWZ,EAAWI,EAAoB,CAC5C,GAAII,GAAO,CAAE,IAAAA,CAAI,EACjB,KAAM,MACV,CAAC,EAED,GAAII,EACA,OAAOV,EAAQU,CAAQ,EAG3B,MAAM,IAAI,MAAM,+BAA+B,CACnD","sourcesContent":["import { existsSync } from \"node:fs\";\n\nimport { findUp, findUpSync, readJsonSync } from \"@visulima/fs\";\nimport { dirname, join } from \"@visulima/path\";\n\nimport { findLockFile, findLockFileSync } from \"./package-manager\";\nimport type { PackageJson } from \"./types\";\n\nconst packageJsonMatcher = (directory: string) => {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (existsSync(join(directory, \"package.json\"))) {\n const packageJson = readJsonSync<PackageJson>(join(directory, \"package.json\"));\n\n if (packageJson.name && packageJson.private !== true) {\n return \"package.json\";\n }\n }\n\n return undefined;\n};\n\n/**\n * An asynchronous function that finds the root directory of a project based on certain lookup criteria.\n *\n * @param cwd - Optional. The current working directory to start the search from. The type of `cwd` is `string`.\n * @returns A `Promise` that resolves to the path of the root directory. The type of the returned promise is `Promise<string>`.\n * @throws An `Error` if the root directory could not be found.\n *\n * @example\n * const rootDirectory = await findPackageRoot();\n * console.log(rootDirectory); // '/path/to/project'\n */\nexport const findPackageRoot = async (cwd?: URL | string): Promise<string> => {\n try {\n const lockFile = await findLockFile(cwd);\n\n return dirname(lockFile);\n } catch {\n /* empty */\n }\n\n const gitConfig = await findUp(\".git/config\", {\n ...(cwd && { cwd }),\n type: \"file\",\n });\n\n if (gitConfig) {\n return dirname(dirname(gitConfig));\n }\n\n const filePath = await findUp(packageJsonMatcher, {\n ...(cwd && { cwd }),\n type: \"file\",\n });\n\n if (filePath) {\n return dirname(filePath);\n }\n\n throw new Error(\"Could not find root directory\");\n};\n\nexport const findPackageRootSync = (cwd?: URL | string): string => {\n try {\n const lockFile = findLockFileSync(cwd);\n\n return dirname(lockFile);\n } catch {\n /* empty */\n }\n\n const gitConfig = findUpSync(\".git/config\", {\n ...(cwd && { cwd }),\n type: \"file\",\n });\n\n if (gitConfig) {\n return dirname(dirname(gitConfig));\n }\n\n const filePath = findUpSync(packageJsonMatcher, {\n ...(cwd && { cwd }),\n type: \"file\",\n });\n\n if (filePath) {\n return dirname(filePath);\n }\n\n throw new Error(\"Could not find root directory\");\n};\n"]}
|
package/dist/chunk-HGV2BL7M.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { existsSync } from 'node:fs';
|
|
2
|
-
import { findUp, readJson, findUpSync, readJsonSync, writeJson, writeJsonSync } from '@visulima/fs';
|
|
3
|
-
import { NotFoundError } from '@visulima/fs/error';
|
|
4
|
-
import { toPath, parseJson } from '@visulima/fs/utils';
|
|
5
|
-
import { join } from '@visulima/path';
|
|
6
|
-
import n from 'normalize-package-data';
|
|
7
|
-
|
|
8
|
-
var m=new Map,b=async(e,o={})=>{let t=await findUp("package.json",{...e&&{cwd:e},type:"file"});if(!t)throw new NotFoundError("No such file or directory, for package.json found.");let a=o.cache&&typeof o.cache!="boolean"?o.cache:m;if(o.cache&&a.has(t))return a.get(t);let s=await readJson(t);n(s);let r={packageJson:s,path:t};return a.set(t,r),r},S=(e,o={})=>{let t=findUpSync("package.json",{...e&&{cwd:e},type:"file"});if(!t)throw new NotFoundError("No such file or directory, for package.json found.");let a=o.cache&&typeof o.cache!="boolean"?o.cache:m;if(o.cache&&a.has(t))return a.get(t);let s=readJsonSync(t);n(s);let r={packageJson:s,path:t};return a.set(t,r),r},x=async(e,o={})=>{let{cwd:t,...a}=o,s=toPath(o.cwd??process.cwd());await writeJson(join(s,"package.json"),e,a);},U=(e,o={})=>{let{cwd:t,...a}=o,s=toPath(o.cwd??process.cwd());writeJsonSync(join(s,"package.json"),e,a);},T=e=>{let o=e!==null&&typeof e=="object"&&!Array.isArray(e);if(!o&&!(typeof e=="string"))throw new TypeError("`packageFile` should be either an `object` or a `string`.");let a=o?structuredClone(e):existsSync(e)?readJsonSync(e):parseJson(e);return n(a),a};
|
|
9
|
-
|
|
10
|
-
export { b as a, S as b, x as c, U as d, T as e };
|
|
11
|
-
//# sourceMappingURL=out.js.map
|
|
12
|
-
//# sourceMappingURL=chunk-HGV2BL7M.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/package-json.ts"],"names":["existsSync","findUp","findUpSync","readJson","readJsonSync","writeJson","writeJsonSync","NotFoundError","parseJson","toPath","join","normalizeData","PackageJsonFileCache","findPackageJson","cwd","options","filePath","cache","packageJson","output","findPackageJsonSync","writePackageJson","data","writeOptions","directory","writePackageJsonSync","parsePackageJson","packageFile","isObject","json"],"mappings":"AAAA,OAAS,cAAAA,MAAkB,UAG3B,OAAS,UAAAC,EAAQ,cAAAC,EAAY,YAAAC,EAAU,gBAAAC,EAAc,aAAAC,EAAW,iBAAAC,MAAqB,eACrF,OAAS,iBAAAC,MAAqB,qBAC9B,OAAS,aAAAC,EAAW,UAAAC,MAAc,qBAClC,OAAS,QAAAC,MAAY,iBAErB,OAAOC,MAAmB,yBAS1B,IAAMC,EAAuB,IAAI,IAepBC,EAAkB,MAAOC,EAAoBC,EAAuB,CAAC,IAAqC,CACnH,IAAMC,EAAW,MAAMf,EAAO,eAAgB,CAC1C,GAAIa,GAAO,CAAE,IAAAA,CAAI,EACjB,KAAM,MACV,CAAC,EAED,GAAI,CAACE,EACD,MAAM,IAAIT,EAAc,oDAAoD,EAGhF,IAAMU,EAAQF,EAAQ,OAAS,OAAOA,EAAQ,OAAU,UAAYA,EAAQ,MAAQH,EAEpF,GAAIG,EAAQ,OAASE,EAAM,IAAID,CAAQ,EACnC,OAAOC,EAAM,IAAID,CAAQ,EAG7B,IAAME,EAAc,MAAMf,EAASa,CAAQ,EAE3CL,EAAcO,CAAoB,EAElC,IAAMC,EAAS,CACX,YAAaD,EACb,KAAMF,CACV,EAEA,OAAAC,EAAM,IAAID,EAAUG,CAAM,EAEnBA,CACX,EAEaC,EAAsB,CAACN,EAAoBC,EAAuB,CAAC,IAA4B,CACxG,IAAMC,EAAWd,EAAW,eAAgB,CACxC,GAAIY,GAAO,CAAE,IAAAA,CAAI,EACjB,KAAM,MACV,CAAC,EAED,GAAI,CAACE,EACD,MAAM,IAAIT,EAAc,oDAAoD,EAGhF,IAAMU,EAAQF,EAAQ,OAAS,OAAOA,EAAQ,OAAU,UAAYA,EAAQ,MAAQH,EAEpF,GAAIG,EAAQ,OAASE,EAAM,IAAID,CAAQ,EACnC,OAAOC,EAAM,IAAID,CAAQ,EAG7B,IAAME,EAAcd,EAAaY,CAAQ,EAEzCL,EAAcO,CAAoB,EAElC,IAAMC,EAAS,CACX,YAAaD,EACb,KAAMF,CACV,EAEA,OAAAC,EAAM,IAAID,EAAUG,CAAM,EAEnBA,CACX,EAYaE,EAAmB,MAAwBC,EAASP,EAAqD,CAAC,IAAqB,CACxI,GAAM,CAAE,IAAAD,EAAK,GAAGS,CAAa,EAAIR,EAC3BS,EAAYf,EAAOM,EAAQ,KAAO,QAAQ,IAAI,CAAC,EAErD,MAAMV,EAAUK,EAAKc,EAAW,cAAc,EAAGF,EAAMC,CAAY,CACvE,EAEaE,EAAuB,CAAkBH,EAASP,EAAqD,CAAC,IAAY,CAC7H,GAAM,CAAE,IAAAD,EAAK,GAAGS,CAAa,EAAIR,EAC3BS,EAAYf,EAAOM,EAAQ,KAAO,QAAQ,IAAI,CAAC,EAErDT,EAAcI,EAAKc,EAAW,cAAc,EAAGF,EAAMC,CAAY,CACrE,EAEaG,EAAoBC,GAA4D,CAEzF,IAAMC,EAAWD,IAAgB,MAAQ,OAAOA,GAAgB,UAAY,CAAC,MAAM,QAAQA,CAAW,EAGtG,GAAI,CAACC,GAAY,EAFA,OAAOD,GAAgB,UAGpC,MAAM,IAAI,UAAU,2DAA2D,EAGnF,IAAME,EAAOD,EACP,gBAAgBD,CAAW,EAE3B3B,EAAW2B,CAAqB,EAC9BvB,EAAauB,CAAqB,EAClCnB,EAAUmB,CAAqB,EAEvC,OAAAhB,EAAckB,CAAa,EAEpBA,CACX","sourcesContent":["import { existsSync } from \"node:fs\";\n\nimport type { WriteJsonOptions } from \"@visulima/fs\";\nimport { findUp, findUpSync, readJson, readJsonSync, writeJson, writeJsonSync } from \"@visulima/fs\";\nimport { NotFoundError } from \"@visulima/fs/error\";\nimport { parseJson, toPath } from \"@visulima/fs/utils\";\nimport { join } from \"@visulima/path\";\nimport type { Input } from \"normalize-package-data\";\nimport normalizeData from \"normalize-package-data\";\nimport type { JsonObject } from \"type-fest\";\n\nimport type { Cache, NormalizedPackageJson, PackageJson } from \"./types\";\n\ntype ReadOptions = {\n cache?: Cache<NormalizedReadResult> | boolean;\n};\n\nconst PackageJsonFileCache = new Map<string, NormalizedReadResult>();\n\nexport type NormalizedReadResult = {\n packageJson: NormalizedPackageJson;\n path: string;\n};\n\n/**\n * An asynchronous function to find the package.json file in the specified directory or its parent directories.\n *\n * @param cwd - The current working directory.\n * @returns A `Promise` that resolves to an object containing the parsed package.json data and the file path.\n * The type of the returned promise is `Promise<NormalizedReadResult>`.\n * @throws An `Error` if the package.json file cannot be found.\n */\nexport const findPackageJson = async (cwd?: URL | string, options: ReadOptions = {}): Promise<NormalizedReadResult> => {\n const filePath = await findUp(\"package.json\", {\n ...(cwd && { cwd }),\n type: \"file\",\n });\n\n if (!filePath) {\n throw new NotFoundError(\"No such file or directory, for package.json found.\");\n }\n\n const cache = options.cache && typeof options.cache !== \"boolean\" ? options.cache : PackageJsonFileCache;\n\n if (options.cache && cache.has(filePath)) {\n return cache.get(filePath) as NormalizedReadResult;\n }\n\n const packageJson = await readJson(filePath);\n\n normalizeData(packageJson as Input);\n\n const output = {\n packageJson: packageJson as NormalizedPackageJson,\n path: filePath,\n };\n\n cache.set(filePath, output);\n\n return output;\n};\n\nexport const findPackageJsonSync = (cwd?: URL | string, options: ReadOptions = {}): NormalizedReadResult => {\n const filePath = findUpSync(\"package.json\", {\n ...(cwd && { cwd }),\n type: \"file\",\n });\n\n if (!filePath) {\n throw new NotFoundError(\"No such file or directory, for package.json found.\");\n }\n\n const cache = options.cache && typeof options.cache !== \"boolean\" ? options.cache : PackageJsonFileCache;\n\n if (options.cache && cache.has(filePath)) {\n return cache.get(filePath) as NormalizedReadResult;\n }\n\n const packageJson = readJsonSync(filePath);\n\n normalizeData(packageJson as Input);\n\n const output = {\n packageJson: packageJson as NormalizedPackageJson,\n path: filePath,\n };\n\n cache.set(filePath, output);\n\n return output;\n};\n\n/**\n * An asynchronous function to write the package.json file with the given data.\n *\n * @param data - The package.json data to write. The data is an intersection type of `PackageJson` and a record where keys are `string` and values can be any type.\n * @param options - Optional. The options for writing the package.json. If not provided, an empty object will be used `{}`.\n * This is an intersection type of `WriteJsonOptions` and a record with an optional `cwd` key which type is `Options[\"cwd\"]`.\n * `cwd` represents the current working directory. If not specified, the default working directory will be used.\n * @returns A `Promise` that resolves once the package.json file has been written. The type of the returned promise is `Promise<void>`.\n */\n\nexport const writePackageJson = async <T = PackageJson>(data: T, options: WriteJsonOptions & { cwd?: URL | string } = {}): Promise<void> => {\n const { cwd, ...writeOptions } = options;\n const directory = toPath(options.cwd ?? process.cwd());\n\n await writeJson(join(directory, \"package.json\"), data, writeOptions);\n};\n\nexport const writePackageJsonSync = <T = PackageJson>(data: T, options: WriteJsonOptions & { cwd?: URL | string } = {}): void => {\n const { cwd, ...writeOptions } = options;\n const directory = toPath(options.cwd ?? process.cwd());\n\n writeJsonSync(join(directory, \"package.json\"), data, writeOptions);\n};\n\nexport const parsePackageJson = (packageFile: JsonObject | string): NormalizedPackageJson => {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n const isObject = packageFile !== null && typeof packageFile === \"object\" && !Array.isArray(packageFile);\n const isString = typeof packageFile === \"string\";\n\n if (!isObject && !isString) {\n throw new TypeError(\"`packageFile` should be either an `object` or a `string`.\");\n }\n\n const json = isObject\n ? structuredClone(packageFile)\n : // eslint-disable-next-line security/detect-non-literal-fs-filename\n existsSync(packageFile as string)\n ? readJsonSync(packageFile as string)\n : parseJson(packageFile as string);\n\n normalizeData(json as Input);\n\n return json as NormalizedPackageJson;\n};\n"]}
|
package/dist/chunk-I3EKI236.cjs
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var chunkC36BYRSZ_cjs = require('./chunk-C36BYRSZ.cjs');
|
|
4
|
-
var fs$1 = require('fs');
|
|
5
|
-
var fs = require('@visulima/fs');
|
|
6
|
-
var path = require('@visulima/path');
|
|
7
|
-
|
|
8
|
-
var g=t=>{if(fs$1.existsSync(path.join(t,"package.json"))){let n=fs.readJsonSync(path.join(t,"package.json"));if(n.name&&n.private!==!0)return "package.json"}},h=async t=>{try{let i=await chunkC36BYRSZ_cjs.a(t);return path.dirname(i)}catch{}let n=await fs.findUp(".git/config",{...t&&{cwd:t},type:"file"});if(n)return path.dirname(path.dirname(n));let r=await fs.findUp(g,{...t&&{cwd:t},type:"file"});if(r)return path.dirname(r);throw new Error("Could not find root directory")},P=t=>{try{let i=chunkC36BYRSZ_cjs.b(t);return path.dirname(i)}catch{}let n=fs.findUpSync(".git/config",{...t&&{cwd:t},type:"file"});if(n)return path.dirname(path.dirname(n));let r=fs.findUpSync(g,{...t&&{cwd:t},type:"file"});if(r)return path.dirname(r);throw new Error("Could not find root directory")};
|
|
9
|
-
|
|
10
|
-
exports.a = h;
|
|
11
|
-
exports.b = P;
|
|
12
|
-
//# sourceMappingURL=out.js.map
|
|
13
|
-
//# sourceMappingURL=chunk-I3EKI236.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/package.ts"],"names":["existsSync","findUp","findUpSync","readJsonSync","dirname","join","packageJsonMatcher","directory","packageJson","findPackageRoot","cwd","lockFile","findLockFile","gitConfig","filePath","findPackageRootSync","findLockFileSync"],"mappings":"gDAAA,OAAS,cAAAA,MAAkB,KAE3B,OAAS,UAAAC,EAAQ,cAAAC,EAAY,gBAAAC,MAAoB,eACjD,OAAS,WAAAC,EAAS,QAAAC,MAAY,iBAK9B,IAAMC,EAAsBC,GAAsB,CAE9C,GAAIP,EAAWK,EAAKE,EAAW,cAAc,CAAC,EAAG,CAC7C,IAAMC,EAAcL,EAA0BE,EAAKE,EAAW,cAAc,CAAC,EAE7E,GAAIC,EAAY,MAAQA,EAAY,UAAY,GAC5C,MAAO,cAEf,CAGJ,EAaaC,EAAkB,MAAOC,GAAwC,CAC1E,GAAI,CACA,IAAMC,EAAW,MAAMC,EAAaF,CAAG,EAEvC,OAAON,EAAQO,CAAQ,CAC3B,MAAQ,CAER,CAEA,IAAME,EAAY,MAAMZ,EAAO,cAAe,CAC1C,GAAIS,GAAO,CAAE,IAAAA,CAAI,EACjB,KAAM,MACV,CAAC,EAED,GAAIG,EACA,OAAOT,EAAQA,EAAQS,CAAS,CAAC,EAGrC,IAAMC,EAAW,MAAMb,EAAOK,EAAoB,CAC9C,GAAII,GAAO,CAAE,IAAAA,CAAI,EACjB,KAAM,MACV,CAAC,EAED,GAAII,EACA,OAAOV,EAAQU,CAAQ,EAG3B,MAAM,IAAI,MAAM,+BAA+B,CACnD,EAEaC,EAAuBL,GAA+B,CAC/D,GAAI,CACA,IAAMC,EAAWK,EAAiBN,CAAG,EAErC,OAAON,EAAQO,CAAQ,CAC3B,MAAQ,CAER,CAEA,IAAME,EAAYX,EAAW,cAAe,CACxC,GAAIQ,GAAO,CAAE,IAAAA,CAAI,EACjB,KAAM,MACV,CAAC,EAED,GAAIG,EACA,OAAOT,EAAQA,EAAQS,CAAS,CAAC,EAGrC,IAAMC,EAAWZ,EAAWI,EAAoB,CAC5C,GAAII,GAAO,CAAE,IAAAA,CAAI,EACjB,KAAM,MACV,CAAC,EAED,GAAII,EACA,OAAOV,EAAQU,CAAQ,EAG3B,MAAM,IAAI,MAAM,+BAA+B,CACnD","sourcesContent":["import { existsSync } from \"node:fs\";\n\nimport { findUp, findUpSync, readJsonSync } from \"@visulima/fs\";\nimport { dirname, join } from \"@visulima/path\";\n\nimport { findLockFile, findLockFileSync } from \"./package-manager\";\nimport type { PackageJson } from \"./types\";\n\nconst packageJsonMatcher = (directory: string) => {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (existsSync(join(directory, \"package.json\"))) {\n const packageJson = readJsonSync<PackageJson>(join(directory, \"package.json\"));\n\n if (packageJson.name && packageJson.private !== true) {\n return \"package.json\";\n }\n }\n\n return undefined;\n};\n\n/**\n * An asynchronous function that finds the root directory of a project based on certain lookup criteria.\n *\n * @param cwd - Optional. The current working directory to start the search from. The type of `cwd` is `string`.\n * @returns A `Promise` that resolves to the path of the root directory. The type of the returned promise is `Promise<string>`.\n * @throws An `Error` if the root directory could not be found.\n *\n * @example\n * const rootDirectory = await findPackageRoot();\n * console.log(rootDirectory); // '/path/to/project'\n */\nexport const findPackageRoot = async (cwd?: URL | string): Promise<string> => {\n try {\n const lockFile = await findLockFile(cwd);\n\n return dirname(lockFile);\n } catch {\n /* empty */\n }\n\n const gitConfig = await findUp(\".git/config\", {\n ...(cwd && { cwd }),\n type: \"file\",\n });\n\n if (gitConfig) {\n return dirname(dirname(gitConfig));\n }\n\n const filePath = await findUp(packageJsonMatcher, {\n ...(cwd && { cwd }),\n type: \"file\",\n });\n\n if (filePath) {\n return dirname(filePath);\n }\n\n throw new Error(\"Could not find root directory\");\n};\n\nexport const findPackageRootSync = (cwd?: URL | string): string => {\n try {\n const lockFile = findLockFileSync(cwd);\n\n return dirname(lockFile);\n } catch {\n /* empty */\n }\n\n const gitConfig = findUpSync(\".git/config\", {\n ...(cwd && { cwd }),\n type: \"file\",\n });\n\n if (gitConfig) {\n return dirname(dirname(gitConfig));\n }\n\n const filePath = findUpSync(packageJsonMatcher, {\n ...(cwd && { cwd }),\n type: \"file\",\n });\n\n if (filePath) {\n return dirname(filePath);\n }\n\n throw new Error(\"Could not find root directory\");\n};\n"]}
|
package/dist/chunk-J5ERILYG.cjs
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var chunkC36BYRSZ_cjs = require('./chunk-C36BYRSZ.cjs');
|
|
4
|
-
|
|
5
|
-
var t=class extends Error{constructor(n,r){if(typeof n=="string"&&(n=[n]),n.length===0){super("Package was not found.");return}if(r===void 0)try{r=chunkC36BYRSZ_cjs.d().packageManager;}catch{}r===void 0&&(r="npm"),super(`Package '${n.join(" ")}' was not found. Please install it using '${r} install ${n.join(" ")}'`);}get code(){return "PACKAGE_NOT_FOUND"}set code(n){throw new Error("Cannot overwrite code PACKAGE_NOT_FOUND")}get name(){return "PackageNotFoundError"}set name(n){throw new Error("Cannot overwrite name of PackageNotFoundError")}},d=t;
|
|
6
|
-
|
|
7
|
-
exports.a = d;
|
|
8
|
-
//# sourceMappingURL=out.js.map
|
|
9
|
-
//# sourceMappingURL=chunk-J5ERILYG.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/error/package-not-found-error.ts"],"names":["PackageNotFoundError","packageName","packageManager","findPackageManagerSync","_name","package_not_found_error_default"],"mappings":"yCAKA,IAAMA,EAAN,cAAmC,KAAM,CAK9B,YAAYC,EAAgCC,EAAyB,CAMxE,GALI,OAAOD,GAAgB,WAEvBA,EAAc,CAACA,CAAW,GAG1BA,EAAY,SAAW,EAAG,CAC1B,MAAM,wBAAwB,EAC9B,MACJ,CAEA,GAAIC,IAAmB,OACnB,GAAI,CAIAA,EAHqBC,EAAuB,EAGd,cAClC,MAAQ,CAER,CAGAD,IAAmB,SAEnBA,EAAiB,OAGrB,MAAM,YAAYD,EAAY,KAAK,GAAG,CAAC,6CAA6CC,CAAc,YAAYD,EAAY,KAAK,GAAG,CAAC,GAAG,CAC1I,CAGA,IAAW,MAAe,CACtB,MAAO,mBACX,CAGA,IAAW,KAAKG,EAAO,CACnB,MAAM,IAAI,MAAM,yCAAyC,CAC7D,CAGA,IAAoB,MAAe,CAC/B,MAAO,sBACX,CAGA,IAAoB,KAAKA,EAAO,CAC5B,MAAM,IAAI,MAAM,+CAA+C,CACnE,CACJ,EAEOC,EAAQL","sourcesContent":["import { findPackageManagerSync } from \"../package-manager\";\n\n/**\n * Error thrown when a package was not found.\n */\nclass PackageNotFoundError extends Error {\n /**\n * @param {string} packageName - The name of the package that was not found.\n * @param {string} packageManager - The package manager used to install the package.\n */\n public constructor(packageName: string[] | string, packageManager?: string) {\n if (typeof packageName === \"string\") {\n // eslint-disable-next-line no-param-reassign\n packageName = [packageName];\n }\n\n if (packageName.length === 0) {\n super(\"Package was not found.\");\n return;\n }\n\n if (packageManager === undefined) {\n try {\n const foundManager = findPackageManagerSync();\n\n // eslint-disable-next-line no-param-reassign\n packageManager = foundManager.packageManager;\n } catch {\n // Empty\n }\n }\n\n if (packageManager === undefined) {\n // eslint-disable-next-line no-param-reassign\n packageManager = \"npm\";\n }\n\n super(`Package '${packageName.join(\" \")}' was not found. Please install it using '${packageManager} install ${packageName.join(\" \")}'`);\n }\n\n // eslint-disable-next-line class-methods-use-this,@typescript-eslint/class-literal-property-style\n public get code(): string {\n return \"PACKAGE_NOT_FOUND\";\n }\n\n // eslint-disable-next-line class-methods-use-this,@typescript-eslint/explicit-module-boundary-types\n public set code(_name) {\n throw new Error(\"Cannot overwrite code PACKAGE_NOT_FOUND\");\n }\n\n // eslint-disable-next-line class-methods-use-this,@typescript-eslint/class-literal-property-style\n public override get name(): string {\n return \"PackageNotFoundError\";\n }\n\n // eslint-disable-next-line class-methods-use-this,@typescript-eslint/explicit-module-boundary-types\n public override set name(_name) {\n throw new Error(\"Cannot overwrite name of PackageNotFoundError\");\n }\n}\n\nexport default PackageNotFoundError;\n"]}
|
package/dist/chunk-KMWIKANF.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { d } from './chunk-BGVUNBLL.js';
|
|
2
|
-
|
|
3
|
-
var t=class extends Error{constructor(n,r){if(typeof n=="string"&&(n=[n]),n.length===0){super("Package was not found.");return}if(r===void 0)try{r=d().packageManager;}catch{}r===void 0&&(r="npm"),super(`Package '${n.join(" ")}' was not found. Please install it using '${r} install ${n.join(" ")}'`);}get code(){return "PACKAGE_NOT_FOUND"}set code(n){throw new Error("Cannot overwrite code PACKAGE_NOT_FOUND")}get name(){return "PackageNotFoundError"}set name(n){throw new Error("Cannot overwrite name of PackageNotFoundError")}},f=t;
|
|
4
|
-
|
|
5
|
-
export { f as a };
|
|
6
|
-
//# sourceMappingURL=out.js.map
|
|
7
|
-
//# sourceMappingURL=chunk-KMWIKANF.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/error/package-not-found-error.ts"],"names":["PackageNotFoundError","packageName","packageManager","findPackageManagerSync","_name","package_not_found_error_default"],"mappings":"wCAKA,IAAMA,EAAN,cAAmC,KAAM,CAK9B,YAAYC,EAAgCC,EAAyB,CAMxE,GALI,OAAOD,GAAgB,WAEvBA,EAAc,CAACA,CAAW,GAG1BA,EAAY,SAAW,EAAG,CAC1B,MAAM,wBAAwB,EAC9B,MACJ,CAEA,GAAIC,IAAmB,OACnB,GAAI,CAIAA,EAHqBC,EAAuB,EAGd,cAClC,MAAQ,CAER,CAGAD,IAAmB,SAEnBA,EAAiB,OAGrB,MAAM,YAAYD,EAAY,KAAK,GAAG,CAAC,6CAA6CC,CAAc,YAAYD,EAAY,KAAK,GAAG,CAAC,GAAG,CAC1I,CAGA,IAAW,MAAe,CACtB,MAAO,mBACX,CAGA,IAAW,KAAKG,EAAO,CACnB,MAAM,IAAI,MAAM,yCAAyC,CAC7D,CAGA,IAAoB,MAAe,CAC/B,MAAO,sBACX,CAGA,IAAoB,KAAKA,EAAO,CAC5B,MAAM,IAAI,MAAM,+CAA+C,CACnE,CACJ,EAEOC,EAAQL","sourcesContent":["import { findPackageManagerSync } from \"../package-manager\";\n\n/**\n * Error thrown when a package was not found.\n */\nclass PackageNotFoundError extends Error {\n /**\n * @param {string} packageName - The name of the package that was not found.\n * @param {string} packageManager - The package manager used to install the package.\n */\n public constructor(packageName: string[] | string, packageManager?: string) {\n if (typeof packageName === \"string\") {\n // eslint-disable-next-line no-param-reassign\n packageName = [packageName];\n }\n\n if (packageName.length === 0) {\n super(\"Package was not found.\");\n return;\n }\n\n if (packageManager === undefined) {\n try {\n const foundManager = findPackageManagerSync();\n\n // eslint-disable-next-line no-param-reassign\n packageManager = foundManager.packageManager;\n } catch {\n // Empty\n }\n }\n\n if (packageManager === undefined) {\n // eslint-disable-next-line no-param-reassign\n packageManager = \"npm\";\n }\n\n super(`Package '${packageName.join(\" \")}' was not found. Please install it using '${packageManager} install ${packageName.join(\" \")}'`);\n }\n\n // eslint-disable-next-line class-methods-use-this,@typescript-eslint/class-literal-property-style\n public get code(): string {\n return \"PACKAGE_NOT_FOUND\";\n }\n\n // eslint-disable-next-line class-methods-use-this,@typescript-eslint/explicit-module-boundary-types\n public set code(_name) {\n throw new Error(\"Cannot overwrite code PACKAGE_NOT_FOUND\");\n }\n\n // eslint-disable-next-line class-methods-use-this,@typescript-eslint/class-literal-property-style\n public override get name(): string {\n return \"PackageNotFoundError\";\n }\n\n // eslint-disable-next-line class-methods-use-this,@typescript-eslint/explicit-module-boundary-types\n public override set name(_name) {\n throw new Error(\"Cannot overwrite name of PackageNotFoundError\");\n }\n}\n\nexport default PackageNotFoundError;\n"]}
|
package/dist/chunk-RETLQXQB.cjs
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var chunkC36BYRSZ_cjs = require('./chunk-C36BYRSZ.cjs');
|
|
4
|
-
var fs$1 = require('fs');
|
|
5
|
-
var fs = require('@visulima/fs');
|
|
6
|
-
var error = require('@visulima/fs/error');
|
|
7
|
-
var path = require('@visulima/path');
|
|
8
|
-
|
|
9
|
-
var w=async n=>{let a=await fs.findUp(["lerna.json","turbo.json"],{type:"file",...n&&{cwd:n}});if(a?.endsWith("lerna.json")){let o=await fs.readJson(a);if(o.useWorkspaces||o.packages)return {path:path.dirname(a),strategy:"lerna"}}let s=a?.endsWith("turbo.json");try{let{packageManager:o,path:r}=await chunkC36BYRSZ_cjs.c(n);if(["npm","yarn"].includes(o)){let t=path.join(r,"package.json");if(fs$1.existsSync(t)&&fs$1.readFileSync(path.join(r,"package.json"),"utf8").includes("workspaces"))return {path:r,strategy:s?"turbo":o}}else if(o==="pnpm"){let t=path.join(r,"pnpm-workspace.yaml");if(fs$1.existsSync(t))return {path:r,strategy:s?"turbo":"pnpm"}}}catch(o){if(!(o instanceof error.NotFoundError))throw o}throw new Error(`No monorepo root could be found upwards from the directory ${n} using lerna, yarn, pnpm, or npm as indicators.`)};
|
|
10
|
-
|
|
11
|
-
exports.a = w;
|
|
12
|
-
//# sourceMappingURL=out.js.map
|
|
13
|
-
//# sourceMappingURL=chunk-RETLQXQB.cjs.map
|