@visulima/package 1.5.3 → 1.6.1
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 +21 -0
- package/dist/chunk-44SW4DFI.js +12 -0
- package/dist/chunk-44SW4DFI.js.map +1 -0
- package/dist/{chunk-45ZLUVBF.cjs → chunk-5YG33J5B.cjs} +3 -3
- package/dist/{chunk-OQ2PTROP.js → chunk-CMEGXNWH.js} +1 -1
- package/dist/{chunk-OQ2PTROP.js.map → chunk-CMEGXNWH.js.map} +1 -1
- package/dist/chunk-DNYCFU7L.cjs +9 -0
- package/dist/chunk-DNYCFU7L.cjs.map +1 -0
- package/dist/{chunk-QYGSOB5F.js → chunk-GMIFPTPB.js} +2 -2
- package/dist/{chunk-BBGTIP2U.js → chunk-I3QTPGJY.js} +2 -2
- package/dist/chunk-KSXRMTAQ.cjs +19 -0
- package/dist/chunk-KSXRMTAQ.cjs.map +1 -0
- package/dist/{chunk-4K7XWYTT.cjs → chunk-OVKFHJQE.cjs} +1 -1
- package/dist/{chunk-4K7XWYTT.cjs.map → chunk-OVKFHJQE.cjs.map} +1 -1
- package/dist/{chunk-DCD4MOHC.cjs → chunk-WOLHGXXJ.cjs} +3 -3
- package/dist/chunk-ZDLZRGSC.js +7 -0
- package/dist/chunk-ZDLZRGSC.js.map +1 -0
- package/dist/error.cjs +14 -0
- package/dist/error.cjs.map +1 -0
- package/dist/error.d.cts +9 -0
- package/dist/error.d.ts +9 -0
- package/dist/error.js +5 -0
- package/dist/error.js.map +1 -0
- package/dist/index.cjs +30 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +8 -7
- package/dist/index.js.map +1 -1
- package/dist/monorepo.cjs +3 -3
- package/dist/monorepo.js +2 -2
- package/dist/package-manager.cjs +10 -6
- package/dist/package-manager.d.cts +2 -1
- package/dist/package-manager.d.ts +2 -1
- package/dist/package-manager.js +1 -1
- package/dist/package.cjs +4 -4
- package/dist/package.js +2 -2
- package/dist/tsconfig.cjs +7 -7
- package/dist/tsconfig.js +1 -1
- package/package.json +14 -2
- package/dist/chunk-IRDIZG2L.cjs +0 -18
- package/dist/chunk-IRDIZG2L.cjs.map +0 -1
- package/dist/chunk-SUN6RRMM.js +0 -12
- package/dist/chunk-SUN6RRMM.js.map +0 -1
- /package/dist/{chunk-45ZLUVBF.cjs.map → chunk-5YG33J5B.cjs.map} +0 -0
- /package/dist/{chunk-QYGSOB5F.js.map → chunk-GMIFPTPB.js.map} +0 -0
- /package/dist/{chunk-BBGTIP2U.js.map → chunk-I3QTPGJY.js.map} +0 -0
- /package/dist/{chunk-DCD4MOHC.cjs.map → chunk-WOLHGXXJ.cjs.map} +0 -0
package/dist/error.d.ts
ADDED
package/dist/error.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":""}
|
package/dist/index.cjs
CHANGED
|
@@ -1,48 +1,57 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
3
|
+
var chunkDNYCFU7L_cjs = require('./chunk-DNYCFU7L.cjs');
|
|
4
|
+
var chunkWOLHGXXJ_cjs = require('./chunk-WOLHGXXJ.cjs');
|
|
5
|
+
var chunk5YG33J5B_cjs = require('./chunk-5YG33J5B.cjs');
|
|
6
|
+
var chunkKSXRMTAQ_cjs = require('./chunk-KSXRMTAQ.cjs');
|
|
6
7
|
var chunk6KT7465D_cjs = require('./chunk-6KT7465D.cjs');
|
|
7
|
-
var
|
|
8
|
+
var chunkOVKFHJQE_cjs = require('./chunk-OVKFHJQE.cjs');
|
|
8
9
|
var fs = require('fs');
|
|
9
10
|
var process = require('process');
|
|
10
11
|
var fs$1 = require('@visulima/fs');
|
|
11
12
|
var pathe = require('pathe');
|
|
12
13
|
|
|
13
|
-
var d=(
|
|
14
|
+
var d=(r,e)=>(e?.create&&fs$1.ensureDirSync(r),r),F=async(r,e)=>{if(process.env.CACHE_DIR&&!["0","1","false","true"].includes(process.env.CACHE_DIR))return d(pathe.join(process.env.CACHE_DIR,r),e);let s=await chunk5YG33J5B_cjs.a(e?.cwd??process.cwd());if(!s)return;let o=pathe.join(s,"node_modules"),t=pathe.join(o,".cache"),i=pathe.join(t,r);if(!(fs.existsSync(i)&&!await fs$1.isAccessible(i,fs$1.W_OK))&&!(fs.existsSync(t)&&!await fs$1.isAccessible(t,fs$1.W_OK))&&!(fs.existsSync(o)&&!await fs$1.isAccessible(o,fs$1.W_OK)))return d(i,e)},L=(r,e)=>{if(process.env.CACHE_DIR&&!["0","1","false","true"].includes(process.env.CACHE_DIR))return d(pathe.join(process.env.CACHE_DIR,r),e);let s=chunk5YG33J5B_cjs.b(e?.cwd??process.cwd());if(!s)return;let o=pathe.join(s,"node_modules"),t=pathe.join(o,".cache"),i=pathe.join(t,r);if(!(fs.existsSync(i)&&!fs$1.isAccessibleSync(i,fs$1.W_OK))&&!(fs.existsSync(t)&&!fs$1.isAccessibleSync(t,fs$1.W_OK))&&!(fs.existsSync(o)&&!fs$1.isAccessibleSync(o,fs$1.W_OK)))return d(i,e)};
|
|
14
15
|
|
|
16
|
+
Object.defineProperty(exports, 'PackageNotFoundError', {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
get: function () { return chunkDNYCFU7L_cjs.a; }
|
|
19
|
+
});
|
|
15
20
|
Object.defineProperty(exports, 'findMonorepoRoot', {
|
|
16
21
|
enumerable: true,
|
|
17
|
-
get: function () { return
|
|
22
|
+
get: function () { return chunkWOLHGXXJ_cjs.a; }
|
|
18
23
|
});
|
|
19
24
|
Object.defineProperty(exports, 'findPackageRoot', {
|
|
20
25
|
enumerable: true,
|
|
21
|
-
get: function () { return
|
|
26
|
+
get: function () { return chunk5YG33J5B_cjs.a; }
|
|
22
27
|
});
|
|
23
28
|
Object.defineProperty(exports, 'findPackageRootSync', {
|
|
24
29
|
enumerable: true,
|
|
25
|
-
get: function () { return
|
|
30
|
+
get: function () { return chunk5YG33J5B_cjs.b; }
|
|
26
31
|
});
|
|
27
32
|
Object.defineProperty(exports, 'findLockFile', {
|
|
28
33
|
enumerable: true,
|
|
29
|
-
get: function () { return
|
|
34
|
+
get: function () { return chunkKSXRMTAQ_cjs.a; }
|
|
30
35
|
});
|
|
31
36
|
Object.defineProperty(exports, 'findLockFileSync', {
|
|
32
37
|
enumerable: true,
|
|
33
|
-
get: function () { return
|
|
38
|
+
get: function () { return chunkKSXRMTAQ_cjs.b; }
|
|
34
39
|
});
|
|
35
40
|
Object.defineProperty(exports, 'findPackageManager', {
|
|
36
41
|
enumerable: true,
|
|
37
|
-
get: function () { return
|
|
42
|
+
get: function () { return chunkKSXRMTAQ_cjs.c; }
|
|
43
|
+
});
|
|
44
|
+
Object.defineProperty(exports, 'findPackageManagerSync', {
|
|
45
|
+
enumerable: true,
|
|
46
|
+
get: function () { return chunkKSXRMTAQ_cjs.d; }
|
|
38
47
|
});
|
|
39
48
|
Object.defineProperty(exports, 'getPackageManagerVersion', {
|
|
40
49
|
enumerable: true,
|
|
41
|
-
get: function () { return
|
|
50
|
+
get: function () { return chunkKSXRMTAQ_cjs.e; }
|
|
42
51
|
});
|
|
43
52
|
Object.defineProperty(exports, 'identifyInitiatingPackageManager', {
|
|
44
53
|
enumerable: true,
|
|
45
|
-
get: function () { return
|
|
54
|
+
get: function () { return chunkKSXRMTAQ_cjs.f; }
|
|
46
55
|
});
|
|
47
56
|
Object.defineProperty(exports, 'findPackageJson', {
|
|
48
57
|
enumerable: true,
|
|
@@ -66,29 +75,29 @@ Object.defineProperty(exports, 'writePackageJsonSync', {
|
|
|
66
75
|
});
|
|
67
76
|
Object.defineProperty(exports, 'findTSConfig', {
|
|
68
77
|
enumerable: true,
|
|
69
|
-
get: function () { return
|
|
78
|
+
get: function () { return chunkOVKFHJQE_cjs.c; }
|
|
70
79
|
});
|
|
71
80
|
Object.defineProperty(exports, 'findTSConfigSync', {
|
|
72
81
|
enumerable: true,
|
|
73
|
-
get: function () { return
|
|
82
|
+
get: function () { return chunkOVKFHJQE_cjs.e; }
|
|
74
83
|
});
|
|
75
84
|
Object.defineProperty(exports, 'findTsConfig', {
|
|
76
85
|
enumerable: true,
|
|
77
|
-
get: function () { return
|
|
86
|
+
get: function () { return chunkOVKFHJQE_cjs.b; }
|
|
78
87
|
});
|
|
79
88
|
Object.defineProperty(exports, 'findTsConfigSync', {
|
|
80
89
|
enumerable: true,
|
|
81
|
-
get: function () { return
|
|
90
|
+
get: function () { return chunkOVKFHJQE_cjs.d; }
|
|
82
91
|
});
|
|
83
92
|
Object.defineProperty(exports, 'readTsConfig', {
|
|
84
93
|
enumerable: true,
|
|
85
|
-
get: function () { return
|
|
94
|
+
get: function () { return chunkOVKFHJQE_cjs.a; }
|
|
86
95
|
});
|
|
87
96
|
Object.defineProperty(exports, 'writeTSConfig', {
|
|
88
97
|
enumerable: true,
|
|
89
|
-
get: function () { return
|
|
98
|
+
get: function () { return chunkOVKFHJQE_cjs.g; }
|
|
90
99
|
});
|
|
91
|
-
exports.findCacheDirectory =
|
|
92
|
-
exports.findCacheDirectorySync =
|
|
100
|
+
exports.findCacheDirectory = F;
|
|
101
|
+
exports.findCacheDirectorySync = L;
|
|
93
102
|
//# sourceMappingURL=out.js.map
|
|
94
103
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/find-cache-dir.ts"],"names":["existsSync","cwd","env","ensureDirSync","isAccessible","isAccessibleSync","W_OK","join","useDirectory","directory","options","findCacheDirectory","name","rootDirectory","findPackageRoot","nodeModulesDirectory","cacheDirectory","cacheNameDirectory","findCacheDirectorySync","findPackageRootSync"],"mappings":"+
|
|
1
|
+
{"version":3,"sources":["../src/find-cache-dir.ts"],"names":["existsSync","cwd","env","ensureDirSync","isAccessible","isAccessibleSync","W_OK","join","useDirectory","directory","options","findCacheDirectory","name","rootDirectory","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,IAAME,EAAuBR,EAAKM,EAAe,cAAc,EACzDG,EAAiBT,EAAKQ,EAAsB,QAAQ,EACpDE,EAAqBV,EAAKS,EAAgBJ,CAAI,EAMpD,GAAI,EAAAZ,EAAWiB,CAAkB,GAAK,CAACZ,EAAiBY,EAAoBX,CAAI,IAK5E,EAAAN,EAAWgB,CAAc,GAAK,CAACX,EAAiBW,EAAgBV,CAAI,IAKpE,EAAAN,EAAWe,CAAoB,GAAK,CAACV,EAAiBU,EAAsBT,CAAI,GAIpF,OAAOE,EAAaS,EAAoBP,CAAO,CACnD","sourcesContent":["// eslint-disable-next-line unicorn/prevent-abbreviations\nimport { existsSync } from \"node:fs\";\nimport { cwd, env } from \"node:process\";\n\nimport { ensureDirSync, isAccessible, isAccessibleSync, W_OK } from \"@visulima/fs\";\nimport { join } from \"pathe\";\n\nimport { findPackageRoot, findPackageRootSync } from \"./package\";\n\ntype Options = {\n create?: boolean;\n cwd?: URL | string;\n};\n\nconst useDirectory = (directory: string, options?: Options): string => {\n if (options?.create) {\n ensureDirSync(directory);\n }\n\n return directory;\n};\n\nexport const findCacheDirectory = async (name: string, options?: Options): Promise<string | undefined> => {\n if (env.CACHE_DIR && ![\"0\", \"1\", \"false\", \"true\"].includes(env.CACHE_DIR)) {\n return useDirectory(join(env.CACHE_DIR, name), options);\n }\n\n const rootDirectory = await findPackageRoot(options?.cwd ?? cwd());\n\n if (!rootDirectory) {\n return undefined;\n }\n\n const nodeModulesDirectory = join(rootDirectory, \"node_modules\");\n const cacheDirectory = join(nodeModulesDirectory, \".cache\");\n const cacheNameDirectory = join(cacheDirectory, name);\n\n // If node_modules/.cache/${name} exists: If it is writeable, return node_modules/.cache/${name}, otherwise return undefined\n // Otherwise, if node_modules/.cache exists: If it is writeable, return node_modules/.cache/${name}, otherwise return undefined\n // Otherwise: If node_modules is writeable, return node_modules/.cache/${name}, otherwise return undefined\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (existsSync(cacheNameDirectory) && !(await isAccessible(cacheNameDirectory, W_OK))) {\n return undefined;\n }\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (existsSync(cacheDirectory) && !(await isAccessible(cacheDirectory, W_OK))) {\n return undefined;\n }\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (existsSync(nodeModulesDirectory) && !(await isAccessible(nodeModulesDirectory, W_OK))) {\n return undefined;\n }\n\n return useDirectory(cacheNameDirectory, options);\n};\n\nexport const findCacheDirectorySync = (name: string, options?: Options): string | undefined => {\n if (env.CACHE_DIR && ![\"0\", \"1\", \"false\", \"true\"].includes(env.CACHE_DIR)) {\n return useDirectory(join(env.CACHE_DIR, name), options);\n }\n\n const rootDirectory = findPackageRootSync(options?.cwd ?? cwd());\n\n if (!rootDirectory) {\n return undefined;\n }\n\n const nodeModulesDirectory = join(rootDirectory, \"node_modules\");\n const cacheDirectory = join(nodeModulesDirectory, \".cache\");\n const cacheNameDirectory = join(cacheDirectory, name);\n\n // If node_modules/.cache/${name} exists: If it is writeable, return node_modules/.cache/${name}, otherwise return undefined\n // Otherwise, if node_modules/.cache exists: If it is writeable, return node_modules/.cache/${name}, otherwise return undefined\n // Otherwise: If node_modules is writeable, return node_modules/.cache/${name}, otherwise return undefined\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (existsSync(cacheNameDirectory) && !isAccessibleSync(cacheNameDirectory, W_OK)) {\n return undefined;\n }\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (existsSync(cacheDirectory) && !isAccessibleSync(cacheDirectory, W_OK)) {\n return undefined;\n }\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (existsSync(nodeModulesDirectory) && !isAccessibleSync(nodeModulesDirectory, W_OK)) {\n return undefined;\n }\n\n return useDirectory(cacheNameDirectory, options);\n};\n"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
export { PackageNotFoundError } from './error.cjs';
|
|
1
2
|
export { RootMonorepo, Strategy, findMonorepoRoot } from './monorepo.cjs';
|
|
2
3
|
export { findPackageRoot, findPackageRootSync } from './package.cjs';
|
|
3
4
|
export { NormalizedReadResult, findPackageJson, findPackageJsonSync, parsePackageJson, writePackageJson, writePackageJsonSync } from './package-json.cjs';
|
|
4
|
-
export { PackageManager, PackageManagerResult, findLockFile, findLockFileSync, findPackageManager, getPackageManagerVersion, identifyInitiatingPackageManager } from './package-manager.cjs';
|
|
5
|
+
export { PackageManager, PackageManagerResult, findLockFile, findLockFileSync, findPackageManager, findPackageManagerSync, getPackageManagerVersion, identifyInitiatingPackageManager } from './package-manager.cjs';
|
|
5
6
|
import { T as TsConfigJsonResolved } from './types-hoigZ9HA.cjs';
|
|
6
7
|
export { N as NormalizedPackageJson, P as PackageJson } from './types-hoigZ9HA.cjs';
|
|
7
8
|
export { TsConfigResult, findTSConfig, findTSConfigSync, findTsConfig, findTsConfigSync, writeTSConfig } from './tsconfig.cjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
export { PackageNotFoundError } from './error.js';
|
|
1
2
|
export { RootMonorepo, Strategy, findMonorepoRoot } from './monorepo.js';
|
|
2
3
|
export { findPackageRoot, findPackageRootSync } from './package.js';
|
|
3
4
|
export { NormalizedReadResult, findPackageJson, findPackageJsonSync, parsePackageJson, writePackageJson, writePackageJsonSync } from './package-json.js';
|
|
4
|
-
export { PackageManager, PackageManagerResult, findLockFile, findLockFileSync, findPackageManager, getPackageManagerVersion, identifyInitiatingPackageManager } from './package-manager.js';
|
|
5
|
+
export { PackageManager, PackageManagerResult, findLockFile, findLockFileSync, findPackageManager, findPackageManagerSync, getPackageManagerVersion, identifyInitiatingPackageManager } from './package-manager.js';
|
|
5
6
|
import { T as TsConfigJsonResolved } from './types-hoigZ9HA.js';
|
|
6
7
|
export { N as NormalizedPackageJson, P as PackageJson } from './types-hoigZ9HA.js';
|
|
7
8
|
export { TsConfigResult, findTSConfig, findTSConfigSync, findTsConfig, findTsConfigSync, writeTSConfig } from './tsconfig.js';
|
package/dist/index.js
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
export { a as
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export { a as
|
|
1
|
+
export { a as PackageNotFoundError } from './chunk-ZDLZRGSC.js';
|
|
2
|
+
export { a as findMonorepoRoot } from './chunk-GMIFPTPB.js';
|
|
3
|
+
import { a, b } from './chunk-I3QTPGJY.js';
|
|
4
|
+
export { a as findPackageRoot, b as findPackageRootSync } from './chunk-I3QTPGJY.js';
|
|
5
|
+
export { a as findLockFile, b as findLockFileSync, c as findPackageManager, d as findPackageManagerSync, e as getPackageManagerVersion, f as identifyInitiatingPackageManager } from './chunk-44SW4DFI.js';
|
|
5
6
|
export { a as findPackageJson, b as findPackageJsonSync, e as parsePackageJson, c as writePackageJson, d as writePackageJsonSync } from './chunk-U4YVB3GU.js';
|
|
6
|
-
export { c as findTSConfig, e as findTSConfigSync, b as findTsConfig, d as findTsConfigSync, a as readTsConfig, g as writeTSConfig } from './chunk-
|
|
7
|
+
export { c as findTSConfig, e as findTSConfigSync, b as findTsConfig, d as findTsConfigSync, a as readTsConfig, g as writeTSConfig } from './chunk-CMEGXNWH.js';
|
|
7
8
|
import { existsSync } from 'node:fs';
|
|
8
9
|
import { env, cwd } from 'node:process';
|
|
9
10
|
import { isAccessible, W_OK, isAccessibleSync, ensureDirSync } from '@visulima/fs';
|
|
10
11
|
import { join } from 'pathe';
|
|
11
12
|
|
|
12
|
-
var d=(
|
|
13
|
+
var d=(r,e)=>(e?.create&&ensureDirSync(r),r),L=async(r,e)=>{if(env.CACHE_DIR&&!["0","1","false","true"].includes(env.CACHE_DIR))return d(join(env.CACHE_DIR,r),e);let s=await a(e?.cwd??cwd());if(!s)return;let o=join(s,"node_modules"),t=join(o,".cache"),i=join(t,r);if(!(existsSync(i)&&!await isAccessible(i,W_OK))&&!(existsSync(t)&&!await isAccessible(t,W_OK))&&!(existsSync(o)&&!await isAccessible(o,W_OK)))return d(i,e)},j=(r,e)=>{if(env.CACHE_DIR&&!["0","1","false","true"].includes(env.CACHE_DIR))return d(join(env.CACHE_DIR,r),e);let s=b(e?.cwd??cwd());if(!s)return;let o=join(s,"node_modules"),t=join(o,".cache"),i=join(t,r);if(!(existsSync(i)&&!isAccessibleSync(i,W_OK))&&!(existsSync(t)&&!isAccessibleSync(t,W_OK))&&!(existsSync(o)&&!isAccessibleSync(o,W_OK)))return d(i,e)};
|
|
13
14
|
|
|
14
|
-
export {
|
|
15
|
+
export { L as findCacheDirectory, j as findCacheDirectorySync };
|
|
15
16
|
//# sourceMappingURL=out.js.map
|
|
16
17
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/find-cache-dir.ts"],"names":["existsSync","cwd","env","ensureDirSync","isAccessible","isAccessibleSync","W_OK","join","useDirectory","directory","options","findCacheDirectory","name","rootDirectory","findPackageRoot","nodeModulesDirectory","cacheDirectory","cacheNameDirectory","findCacheDirectorySync","findPackageRootSync"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/find-cache-dir.ts"],"names":["existsSync","cwd","env","ensureDirSync","isAccessible","isAccessibleSync","W_OK","join","useDirectory","directory","options","findCacheDirectory","name","rootDirectory","findPackageRoot","nodeModulesDirectory","cacheDirectory","cacheNameDirectory","findCacheDirectorySync","findPackageRootSync"],"mappings":"yVACA,OAAS,cAAAA,MAAkB,UAC3B,OAAS,OAAAC,EAAK,OAAAC,MAAW,eAEzB,OAAS,iBAAAC,EAAe,gBAAAC,EAAc,oBAAAC,EAAkB,QAAAC,MAAY,eACpE,OAAS,QAAAC,MAAY,QASrB,IAAMC,EAAe,CAACC,EAAmBC,KACjCA,GAAS,QACTP,EAAcM,CAAS,EAGpBA,GAGEE,EAAqB,MAAOC,EAAcF,IAAmD,CACtG,GAAIR,EAAI,WAAa,CAAC,CAAC,IAAK,IAAK,QAAS,MAAM,EAAE,SAASA,EAAI,SAAS,EACp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";\n\nimport { ensureDirSync, isAccessible, isAccessibleSync, W_OK } from \"@visulima/fs\";\nimport { join } from \"pathe\";\n\nimport { findPackageRoot, findPackageRootSync } from \"./package\";\n\ntype Options = {\n create?: boolean;\n cwd?: URL | string;\n};\n\nconst useDirectory = (directory: string, options?: Options): string => {\n if (options?.create) {\n ensureDirSync(directory);\n }\n\n return directory;\n};\n\nexport const findCacheDirectory = async (name: string, options?: Options): Promise<string | undefined> => {\n if (env.CACHE_DIR && ![\"0\", \"1\", \"false\", \"true\"].includes(env.CACHE_DIR)) {\n return useDirectory(join(env.CACHE_DIR, name), options);\n }\n\n const rootDirectory = await findPackageRoot(options?.cwd ?? cwd());\n\n if (!rootDirectory) {\n return undefined;\n }\n\n const nodeModulesDirectory = join(rootDirectory, \"node_modules\");\n const cacheDirectory = join(nodeModulesDirectory, \".cache\");\n const cacheNameDirectory = join(cacheDirectory, name);\n\n // If node_modules/.cache/${name} exists: If it is writeable, return node_modules/.cache/${name}, otherwise return undefined\n // Otherwise, if node_modules/.cache exists: If it is writeable, return node_modules/.cache/${name}, otherwise return undefined\n // Otherwise: If node_modules is writeable, return node_modules/.cache/${name}, otherwise return undefined\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (existsSync(cacheNameDirectory) && !(await isAccessible(cacheNameDirectory, W_OK))) {\n return undefined;\n }\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (existsSync(cacheDirectory) && !(await isAccessible(cacheDirectory, W_OK))) {\n return undefined;\n }\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (existsSync(nodeModulesDirectory) && !(await isAccessible(nodeModulesDirectory, W_OK))) {\n return undefined;\n }\n\n return useDirectory(cacheNameDirectory, options);\n};\n\nexport const findCacheDirectorySync = (name: string, options?: Options): string | undefined => {\n if (env.CACHE_DIR && ![\"0\", \"1\", \"false\", \"true\"].includes(env.CACHE_DIR)) {\n return useDirectory(join(env.CACHE_DIR, name), options);\n }\n\n const rootDirectory = findPackageRootSync(options?.cwd ?? cwd());\n\n if (!rootDirectory) {\n return undefined;\n }\n\n const nodeModulesDirectory = join(rootDirectory, \"node_modules\");\n const cacheDirectory = join(nodeModulesDirectory, \".cache\");\n const cacheNameDirectory = join(cacheDirectory, name);\n\n // If node_modules/.cache/${name} exists: If it is writeable, return node_modules/.cache/${name}, otherwise return undefined\n // Otherwise, if node_modules/.cache exists: If it is writeable, return node_modules/.cache/${name}, otherwise return undefined\n // Otherwise: If node_modules is writeable, return node_modules/.cache/${name}, otherwise return undefined\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (existsSync(cacheNameDirectory) && !isAccessibleSync(cacheNameDirectory, W_OK)) {\n return undefined;\n }\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (existsSync(cacheDirectory) && !isAccessibleSync(cacheDirectory, W_OK)) {\n return undefined;\n }\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (existsSync(nodeModulesDirectory) && !isAccessibleSync(nodeModulesDirectory, W_OK)) {\n return undefined;\n }\n\n return useDirectory(cacheNameDirectory, options);\n};\n"]}
|
package/dist/monorepo.cjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('./chunk-
|
|
3
|
+
var chunkWOLHGXXJ_cjs = require('./chunk-WOLHGXXJ.cjs');
|
|
4
|
+
require('./chunk-KSXRMTAQ.cjs');
|
|
5
5
|
require('./chunk-6KT7465D.cjs');
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
Object.defineProperty(exports, 'findMonorepoRoot', {
|
|
10
10
|
enumerable: true,
|
|
11
|
-
get: function () { return
|
|
11
|
+
get: function () { return chunkWOLHGXXJ_cjs.a; }
|
|
12
12
|
});
|
|
13
13
|
//# sourceMappingURL=out.js.map
|
|
14
14
|
//# sourceMappingURL=monorepo.cjs.map
|
package/dist/monorepo.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { a as findMonorepoRoot } from './chunk-
|
|
2
|
-
import './chunk-
|
|
1
|
+
export { a as findMonorepoRoot } from './chunk-GMIFPTPB.js';
|
|
2
|
+
import './chunk-44SW4DFI.js';
|
|
3
3
|
import './chunk-U4YVB3GU.js';
|
|
4
4
|
//# sourceMappingURL=out.js.map
|
|
5
5
|
//# sourceMappingURL=monorepo.js.map
|
package/dist/package-manager.cjs
CHANGED
|
@@ -1,29 +1,33 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkKSXRMTAQ_cjs = require('./chunk-KSXRMTAQ.cjs');
|
|
4
4
|
require('./chunk-6KT7465D.cjs');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
Object.defineProperty(exports, 'findLockFile', {
|
|
9
9
|
enumerable: true,
|
|
10
|
-
get: function () { return
|
|
10
|
+
get: function () { return chunkKSXRMTAQ_cjs.a; }
|
|
11
11
|
});
|
|
12
12
|
Object.defineProperty(exports, 'findLockFileSync', {
|
|
13
13
|
enumerable: true,
|
|
14
|
-
get: function () { return
|
|
14
|
+
get: function () { return chunkKSXRMTAQ_cjs.b; }
|
|
15
15
|
});
|
|
16
16
|
Object.defineProperty(exports, 'findPackageManager', {
|
|
17
17
|
enumerable: true,
|
|
18
|
-
get: function () { return
|
|
18
|
+
get: function () { return chunkKSXRMTAQ_cjs.c; }
|
|
19
|
+
});
|
|
20
|
+
Object.defineProperty(exports, 'findPackageManagerSync', {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
get: function () { return chunkKSXRMTAQ_cjs.d; }
|
|
19
23
|
});
|
|
20
24
|
Object.defineProperty(exports, 'getPackageManagerVersion', {
|
|
21
25
|
enumerable: true,
|
|
22
|
-
get: function () { return
|
|
26
|
+
get: function () { return chunkKSXRMTAQ_cjs.e; }
|
|
23
27
|
});
|
|
24
28
|
Object.defineProperty(exports, 'identifyInitiatingPackageManager', {
|
|
25
29
|
enumerable: true,
|
|
26
|
-
get: function () { return
|
|
30
|
+
get: function () { return chunkKSXRMTAQ_cjs.f; }
|
|
27
31
|
});
|
|
28
32
|
//# sourceMappingURL=out.js.map
|
|
29
33
|
//# sourceMappingURL=package-manager.cjs.map
|
|
@@ -6,10 +6,11 @@ type PackageManagerResult = {
|
|
|
6
6
|
path: string;
|
|
7
7
|
};
|
|
8
8
|
declare const findPackageManager: (cwd?: URL | string) => Promise<PackageManagerResult>;
|
|
9
|
+
declare const findPackageManagerSync: (cwd?: URL | string) => PackageManagerResult;
|
|
9
10
|
declare const getPackageManagerVersion: (name: string) => string;
|
|
10
11
|
declare const identifyInitiatingPackageManager: () => Promise<{
|
|
11
12
|
name: PackageManager | "cnpm";
|
|
12
13
|
version: string;
|
|
13
14
|
} | undefined>;
|
|
14
15
|
|
|
15
|
-
export { type PackageManager, type PackageManagerResult, findLockFile, findLockFileSync, findPackageManager, getPackageManagerVersion, identifyInitiatingPackageManager };
|
|
16
|
+
export { type PackageManager, type PackageManagerResult, findLockFile, findLockFileSync, findPackageManager, findPackageManagerSync, getPackageManagerVersion, identifyInitiatingPackageManager };
|
|
@@ -6,10 +6,11 @@ type PackageManagerResult = {
|
|
|
6
6
|
path: string;
|
|
7
7
|
};
|
|
8
8
|
declare const findPackageManager: (cwd?: URL | string) => Promise<PackageManagerResult>;
|
|
9
|
+
declare const findPackageManagerSync: (cwd?: URL | string) => PackageManagerResult;
|
|
9
10
|
declare const getPackageManagerVersion: (name: string) => string;
|
|
10
11
|
declare const identifyInitiatingPackageManager: () => Promise<{
|
|
11
12
|
name: PackageManager | "cnpm";
|
|
12
13
|
version: string;
|
|
13
14
|
} | undefined>;
|
|
14
15
|
|
|
15
|
-
export { type PackageManager, type PackageManagerResult, findLockFile, findLockFileSync, findPackageManager, getPackageManagerVersion, identifyInitiatingPackageManager };
|
|
16
|
+
export { type PackageManager, type PackageManagerResult, findLockFile, findLockFileSync, findPackageManager, findPackageManagerSync, getPackageManagerVersion, identifyInitiatingPackageManager };
|
package/dist/package-manager.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { a as findLockFile, b as findLockFileSync, c as findPackageManager, d as
|
|
1
|
+
export { a as findLockFile, b as findLockFileSync, c as findPackageManager, d as findPackageManagerSync, e as getPackageManagerVersion, f as identifyInitiatingPackageManager } from './chunk-44SW4DFI.js';
|
|
2
2
|
import './chunk-U4YVB3GU.js';
|
|
3
3
|
//# sourceMappingURL=out.js.map
|
|
4
4
|
//# sourceMappingURL=package-manager.js.map
|
package/dist/package.cjs
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('./chunk-
|
|
3
|
+
var chunk5YG33J5B_cjs = require('./chunk-5YG33J5B.cjs');
|
|
4
|
+
require('./chunk-KSXRMTAQ.cjs');
|
|
5
5
|
require('./chunk-6KT7465D.cjs');
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
Object.defineProperty(exports, 'findPackageRoot', {
|
|
10
10
|
enumerable: true,
|
|
11
|
-
get: function () { return
|
|
11
|
+
get: function () { return chunk5YG33J5B_cjs.a; }
|
|
12
12
|
});
|
|
13
13
|
Object.defineProperty(exports, 'findPackageRootSync', {
|
|
14
14
|
enumerable: true,
|
|
15
|
-
get: function () { return
|
|
15
|
+
get: function () { return chunk5YG33J5B_cjs.b; }
|
|
16
16
|
});
|
|
17
17
|
//# sourceMappingURL=out.js.map
|
|
18
18
|
//# sourceMappingURL=package.cjs.map
|
package/dist/package.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { a as findPackageRoot, b as findPackageRootSync } from './chunk-
|
|
2
|
-
import './chunk-
|
|
1
|
+
export { a as findPackageRoot, b as findPackageRootSync } from './chunk-I3QTPGJY.js';
|
|
2
|
+
import './chunk-44SW4DFI.js';
|
|
3
3
|
import './chunk-U4YVB3GU.js';
|
|
4
4
|
//# sourceMappingURL=out.js.map
|
|
5
5
|
//# sourceMappingURL=package.js.map
|
package/dist/tsconfig.cjs
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkOVKFHJQE_cjs = require('./chunk-OVKFHJQE.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
Object.defineProperty(exports, 'findTSConfig', {
|
|
8
8
|
enumerable: true,
|
|
9
|
-
get: function () { return
|
|
9
|
+
get: function () { return chunkOVKFHJQE_cjs.c; }
|
|
10
10
|
});
|
|
11
11
|
Object.defineProperty(exports, 'findTSConfigSync', {
|
|
12
12
|
enumerable: true,
|
|
13
|
-
get: function () { return
|
|
13
|
+
get: function () { return chunkOVKFHJQE_cjs.e; }
|
|
14
14
|
});
|
|
15
15
|
Object.defineProperty(exports, 'findTsConfig', {
|
|
16
16
|
enumerable: true,
|
|
17
|
-
get: function () { return
|
|
17
|
+
get: function () { return chunkOVKFHJQE_cjs.b; }
|
|
18
18
|
});
|
|
19
19
|
Object.defineProperty(exports, 'findTsConfigSync', {
|
|
20
20
|
enumerable: true,
|
|
21
|
-
get: function () { return
|
|
21
|
+
get: function () { return chunkOVKFHJQE_cjs.d; }
|
|
22
22
|
});
|
|
23
23
|
Object.defineProperty(exports, 'writeTSConfig', {
|
|
24
24
|
enumerable: true,
|
|
25
|
-
get: function () { return
|
|
25
|
+
get: function () { return chunkOVKFHJQE_cjs.g; }
|
|
26
26
|
});
|
|
27
27
|
Object.defineProperty(exports, 'writeTsConfig', {
|
|
28
28
|
enumerable: true,
|
|
29
|
-
get: function () { return
|
|
29
|
+
get: function () { return chunkOVKFHJQE_cjs.f; }
|
|
30
30
|
});
|
|
31
31
|
//# sourceMappingURL=out.js.map
|
|
32
32
|
//# sourceMappingURL=tsconfig.cjs.map
|
package/dist/tsconfig.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { c as findTSConfig, e as findTSConfigSync, b as findTsConfig, d as findTsConfigSync, g as writeTSConfig, f as writeTsConfig } from './chunk-
|
|
1
|
+
export { c as findTSConfig, e as findTSConfigSync, b as findTsConfig, d as findTsConfigSync, g as writeTSConfig, f as writeTsConfig } from './chunk-CMEGXNWH.js';
|
|
2
2
|
//# sourceMappingURL=out.js.map
|
|
3
3
|
//# sourceMappingURL=tsconfig.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@visulima/package",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.1",
|
|
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",
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
"find-cache-directory",
|
|
11
11
|
"find-monorepo-root",
|
|
12
12
|
"find-up-pkg",
|
|
13
|
+
"find-package-manager",
|
|
13
14
|
"get-tsconfig",
|
|
14
15
|
"mono-repo",
|
|
15
16
|
"monorepo",
|
|
@@ -114,6 +115,16 @@
|
|
|
114
115
|
"default": "./dist/tsconfig.js"
|
|
115
116
|
}
|
|
116
117
|
},
|
|
118
|
+
"./error": {
|
|
119
|
+
"require": {
|
|
120
|
+
"types": "./dist/error.d.cts",
|
|
121
|
+
"default": "./dist/error.cjs"
|
|
122
|
+
},
|
|
123
|
+
"import": {
|
|
124
|
+
"types": "./dist/error.d.ts",
|
|
125
|
+
"default": "./dist/error.js"
|
|
126
|
+
}
|
|
127
|
+
},
|
|
117
128
|
"./package.json": "./package.json"
|
|
118
129
|
},
|
|
119
130
|
"main": "dist/index.cjs",
|
|
@@ -142,7 +153,7 @@
|
|
|
142
153
|
"test:watch": "vitest"
|
|
143
154
|
},
|
|
144
155
|
"dependencies": {
|
|
145
|
-
"@visulima/fs": "2.0.
|
|
156
|
+
"@visulima/fs": "2.0.4",
|
|
146
157
|
"jsonc-parser": "^3.2.1",
|
|
147
158
|
"normalize-package-data": "^6.0.0",
|
|
148
159
|
"pathe": "^1.1.2",
|
|
@@ -208,6 +219,7 @@
|
|
|
208
219
|
}
|
|
209
220
|
},
|
|
210
221
|
"sources": [
|
|
222
|
+
"src/error.ts",
|
|
211
223
|
"src/index.ts",
|
|
212
224
|
"src/monorepo.ts",
|
|
213
225
|
"src/package.ts",
|
package/dist/chunk-IRDIZG2L.cjs
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var chunk6KT7465D_cjs = require('./chunk-6KT7465D.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 pathe = require('pathe');
|
|
9
|
-
|
|
10
|
-
var g=["yarn.lock","package-lock.json","pnpm-lock.yaml","npm-shrinkwrap.json","bun.lockb"],b=async a=>{let n=await fs.findUp(g,{type:"file",...a&&{cwd:a}});if(!n)throw new Error("Could not find lock file");return n},j=a=>{let n=fs.findUpSync(g,{type:"file",...a&&{cwd:a}});if(!n)throw new Error("Could not find lock file");return n},F=async a=>{let n=await fs.findUp(e=>{let t;if(g.forEach(o=>{!t&&fs$1.existsSync(pathe.join(e,o))&&(t=pathe.join(e,o));}),t)return t;let r=pathe.join(e,"package.json");if(fs$1.existsSync(r)&&chunk6KT7465D_cjs.e(fs$1.readFileSync(r,"utf8")).packageManager!==void 0)return r},{...a&&{cwd:a}});if(!n)throw new error.NotFoundError("Could not find a package manager");if(n.endsWith("package.json")){let e=chunk6KT7465D_cjs.e(n);if(e.packageManager){let r=["npm","yarn","pnpm","bun"].find(o=>e.packageManager.startsWith(o));if(r)return {packageManager:r,path:pathe.dirname(n)}}}if(n.endsWith("yarn.lock"))return {packageManager:"yarn",path:pathe.dirname(n)};if(n.endsWith("package-lock.json")||n.endsWith("npm-shrinkwrap.json"))return {packageManager:"npm",path:pathe.dirname(n)};if(n.endsWith("pnpm-lock.yaml"))return {packageManager:"pnpm",path:pathe.dirname(n)};if(n.endsWith("bun.lockb"))return {packageManager:"bun",path:pathe.dirname(n)};throw new Error("Could not find a package manager")},S=a=>child_process.execSync(`${a} --version`).toString("utf8").trim(),W=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 = b;
|
|
13
|
-
exports.b = j;
|
|
14
|
-
exports.c = F;
|
|
15
|
-
exports.d = S;
|
|
16
|
-
exports.e = W;
|
|
17
|
-
//# sourceMappingURL=out.js.map
|
|
18
|
-
//# sourceMappingURL=chunk-IRDIZG2L.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/package-manager.ts"],"names":["execSync","existsSync","readFileSync","findUp","findUpSync","NotFoundError","dirname","join","lockFileNames","findLockFile","cwd","filePath","findLockFileSync","findPackageManager","foundFile","directory","lockFile","lockFileName","packageJsonFilePath","parsePackageJson","packageJson","foundPackageManager","prefix","getPackageManagerVersion","name","identifyInitiatingPackageManager","pmSpec","separatorPos"],"mappings":"yCAAA,OAAS,YAAAA,MAAgB,gBACzB,OAAS,cAAAC,EAAY,gBAAAC,MAAoB,KAEzC,OAAS,UAAAC,EAAQ,cAAAC,MAAkB,eACnC,OAAS,iBAAAC,MAAqB,qBAC9B,OAAS,WAAAC,EAAS,QAAAC,MAAY,QAI9B,IAAMC,EAAgB,CAAC,YAAa,oBAAqB,iBAAkB,sBAAuB,WAAW,EAWhGC,EAAe,MAAOC,GAAwC,CACvE,IAAMC,EAAW,MAAMR,EAAOK,EAAe,CACzC,KAAM,OACN,GAAIE,GAAO,CAAE,IAAAA,CAAI,CACrB,CAAC,EAED,GAAI,CAACC,EACD,MAAM,IAAI,MAAM,0BAA0B,EAG9C,OAAOA,CACX,EAEaC,EAAoBF,GAA+B,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R,EAAQQ,CAAS,CAC3B,EAGJ,GAAIA,EAAU,SAAS,WAAW,EAC9B,MAAO,CACH,eAAgB,MAChB,KAAMR,EAAQQ,CAAS,CAC3B,EAGJ,MAAM,IAAI,MAAM,kCAAkC,CACtD,EAQaS,EAA4BC,GAAyBxB,EAAS,GAAGwB,CAAI,YAAY,EAAE,SAAS,MAAM,EAAE,KAAK,EAWzGC,EAAmC,SAM3C,CACD,GAAI,CAAC,QAAQ,IAAI,sBACb,OAGJ,IAAMC,EAAS,QAAQ,IAAI,sBAAyB,MAAM,GAAG,EAAE,CAAC,EAC1DC,EAAeD,EAAO,YAAY,GAAG,EACrCF,EAAOE,EAAO,MAAM,EAAG,KAAK,IAAI,EAAGC,CAAY,CAAC,EAEtD,MAAO,CACH,KAAMH,IAAS,aAAe,OAAUA,EACxC,QAASE,EAAO,MAAM,KAAK,IAAI,EAAGC,EAAe,CAAC,CAAC,CACvD,CACJ","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 \"pathe\";\n\nimport { parsePackageJson } from \"./package-json\";\n\nconst lockFileNames = [\"yarn.lock\", \"package-lock.json\", \"pnpm-lock.yaml\", \"npm-shrinkwrap.json\", \"bun.lockb\"];\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 */\n// eslint-disable-next-line sonarjs/cognitive-complexity\nexport const findPackageManager = async (cwd?: URL | string): Promise<PackageManagerResult> => {\n const foundFile = await findUp(\n (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 {\n ...(cwd && { cwd }),\n },\n );\n\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 Error(\"Could not find a package manager\");\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-SUN6RRMM.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { e } from './chunk-U4YVB3GU.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 'pathe';
|
|
7
|
-
|
|
8
|
-
var g=["yarn.lock","package-lock.json","pnpm-lock.yaml","npm-shrinkwrap.json","bun.lockb"],j=async a=>{let n=await findUp(g,{type:"file",...a&&{cwd:a}});if(!n)throw new Error("Could not find lock file");return n},F=a=>{let n=findUpSync(g,{type:"file",...a&&{cwd:a}});if(!n)throw new Error("Could not find lock file");return n},S=async a=>{let n=await findUp(e$1=>{let t;if(g.forEach(o=>{!t&&existsSync(join(e$1,o))&&(t=join(e$1,o));}),t)return t;let r=join(e$1,"package.json");if(existsSync(r)&&e(readFileSync(r,"utf8")).packageManager!==void 0)return r},{...a&&{cwd:a}});if(!n)throw new NotFoundError("Could not find a package manager");if(n.endsWith("package.json")){let e$1=e(n);if(e$1.packageManager){let r=["npm","yarn","pnpm","bun"].find(o=>e$1.packageManager.startsWith(o));if(r)return {packageManager:r,path:dirname(n)}}}if(n.endsWith("yarn.lock"))return {packageManager:"yarn",path:dirname(n)};if(n.endsWith("package-lock.json")||n.endsWith("npm-shrinkwrap.json"))return {packageManager:"npm",path:dirname(n)};if(n.endsWith("pnpm-lock.yaml"))return {packageManager:"pnpm",path:dirname(n)};if(n.endsWith("bun.lockb"))return {packageManager:"bun",path:dirname(n)};throw new Error("Could not find a package manager")},W=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 { j as a, F as b, S as c, W as d, _ as e };
|
|
11
|
-
//# sourceMappingURL=out.js.map
|
|
12
|
-
//# sourceMappingURL=chunk-SUN6RRMM.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/package-manager.ts"],"names":["execSync","existsSync","readFileSync","findUp","findUpSync","NotFoundError","dirname","join","lockFileNames","findLockFile","cwd","filePath","findLockFileSync","findPackageManager","foundFile","directory","lockFile","lockFileName","packageJsonFilePath","parsePackageJson","packageJson","foundPackageManager","prefix","getPackageManagerVersion","name","identifyInitiatingPackageManager","pmSpec","separatorPos"],"mappings":"wCAAA,OAAS,YAAAA,MAAgB,qBACzB,OAAS,cAAAC,EAAY,gBAAAC,MAAoB,UAEzC,OAAS,UAAAC,EAAQ,cAAAC,MAAkB,eACnC,OAAS,iBAAAC,MAAqB,qBAC9B,OAAS,WAAAC,EAAS,QAAAC,MAAY,QAI9B,IAAMC,EAAgB,CAAC,YAAa,oBAAqB,iBAAkB,sBAAuB,WAAW,EAWhGC,EAAe,MAAOC,GAAwC,CACvE,IAAMC,EAAW,MAAMR,EAAOK,EAAe,CACzC,KAAM,OACN,GAAIE,GAAO,CAAE,IAAAA,CAAI,CACrB,CAAC,EAED,GAAI,CAACC,EACD,MAAM,IAAI,MAAM,0BAA0B,EAG9C,OAAOA,CACX,EAEaC,EAAoBF,GAA+B,CAC5D,IAAMC,EAAWP,EAAWI,EAAe,CACvC,KAAM,OACN,GAAIE,GAAO,CAAE,IAAAA,CAAI,CACrB,CAAC,EAED,GAAI,CAACC,EACD,MAAM,IAAI,MAAM,0BAA0B,EAG9C,OAAOA,CACX,EAqBaE,EAAqB,MAAOH,GAAsD,CAC3F,IAAMI,EAAY,MAAMX,EACnBY,GAAsB,CACnB,IAAIC,EASJ,GAPAR,EAAc,QAASS,GAAiB,CAEhC,CAACD,GAAYf,EAAWM,EAAKQ,EAAWE,CAAY,CAAC,IACrDD,EAAWT,EAAKQ,EAAWE,CAAY,EAE/C,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AAO,YAAY,GAAG,EACrCF,EAAOE,EAAO,MAAM,EAAG,KAAK,IAAI,EAAGC,CAAY,CAAC,EAEtD,MAAO,CACH,KAAMH,IAAS,aAAe,OAAUA,EACxC,QAASE,EAAO,MAAM,KAAK,IAAI,EAAGC,EAAe,CAAC,CAAC,CACvD,CACJ","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 \"pathe\";\n\nimport { parsePackageJson } from \"./package-json\";\n\nconst lockFileNames = [\"yarn.lock\", \"package-lock.json\", \"pnpm-lock.yaml\", \"npm-shrinkwrap.json\", \"bun.lockb\"];\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 */\n// eslint-disable-next-line sonarjs/cognitive-complexity\nexport const findPackageManager = async (cwd?: URL | string): Promise<PackageManagerResult> => {\n const foundFile = await findUp(\n (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 {\n ...(cwd && { cwd }),\n },\n );\n\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 Error(\"Could not find a package manager\");\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"]}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|