@visulima/package 1.3.5 → 1.4.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 +20 -0
- package/README.md +22 -14
- package/dist/{chunk-EVIAOYPI.js → chunk-5ZQIFU6S.js} +3 -3
- package/dist/chunk-5ZQIFU6S.js.map +1 -0
- package/dist/chunk-BGBPBHAL.cjs +27 -0
- package/dist/chunk-BGBPBHAL.cjs.map +1 -0
- package/dist/chunk-F63DY4KL.js +15 -0
- package/dist/chunk-F63DY4KL.js.map +1 -0
- package/dist/{chunk-S35C7FTW.js → chunk-G767QS5X.js} +3 -3
- package/dist/chunk-G767QS5X.js.map +1 -0
- package/dist/chunk-L6J2NRQY.cjs +12 -0
- package/dist/chunk-L6J2NRQY.cjs.map +1 -0
- package/dist/chunk-TM6ZD56C.cjs +16 -0
- package/dist/chunk-TM6ZD56C.cjs.map +1 -0
- package/dist/chunk-TUN46UZB.js +12 -0
- package/dist/chunk-TUN46UZB.js.map +1 -0
- package/dist/chunk-VAMRQCZW.cjs +11 -0
- package/dist/chunk-VAMRQCZW.cjs.map +1 -0
- package/dist/chunk-VQCWTT2B.cjs +22 -0
- package/dist/chunk-VQCWTT2B.cjs.map +1 -0
- package/dist/{chunk-JUT7NLYV.js → chunk-XKKPPOYW.js} +3 -3
- package/dist/chunk-XKKPPOYW.js.map +1 -0
- package/dist/index.cjs +34 -18
- package/dist/index.d.cts +12 -4
- package/dist/index.d.ts +12 -4
- package/dist/index.js +5 -5
- package/dist/monorepo.cjs +4 -4
- package/dist/monorepo.js +3 -3
- package/dist/package-json.cjs +6 -6
- package/dist/package-json.d.cts +23 -3
- package/dist/package-json.d.ts +23 -3
- package/dist/package-json.js +1 -1
- package/dist/package-manager.cjs +6 -6
- package/dist/package-manager.js +2 -2
- package/dist/package.cjs +4 -4
- package/dist/package.js +3 -3
- package/dist/tsconfig.cjs +19 -3
- package/dist/tsconfig.d.cts +19 -4
- package/dist/tsconfig.d.ts +19 -4
- package/dist/tsconfig.js +1 -1
- package/dist/types-hoigZ9HA.d.cts +9 -0
- package/dist/types-hoigZ9HA.d.ts +9 -0
- package/package.json +18 -11
- package/dist/chunk-3BB7IH7P.cjs +0 -22
- package/dist/chunk-3BB7IH7P.cjs.map +0 -1
- package/dist/chunk-EVIAOYPI.js.map +0 -1
- package/dist/chunk-JUT7NLYV.js.map +0 -1
- package/dist/chunk-KG4KEP7W.cjs +0 -16
- package/dist/chunk-KG4KEP7W.cjs.map +0 -1
- package/dist/chunk-OIPHYJAS.js +0 -12
- package/dist/chunk-OIPHYJAS.js.map +0 -1
- package/dist/chunk-QNXGZOH4.js +0 -10
- package/dist/chunk-QNXGZOH4.js.map +0 -1
- package/dist/chunk-S35C7FTW.js.map +0 -1
- package/dist/chunk-WKLGTORJ.cjs +0 -12
- package/dist/chunk-WKLGTORJ.cjs.map +0 -1
- package/dist/chunk-WOH32CRU.cjs +0 -13
- package/dist/chunk-WOH32CRU.cjs.map +0 -1
- package/dist/chunk-X65BTKB7.cjs +0 -11
- package/dist/chunk-X65BTKB7.cjs.map +0 -1
- package/dist/package-json-MvdYC-nU.d.cts +0 -23
- package/dist/package-json-MvdYC-nU.d.ts +0 -23
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/monorepo.ts"],"names":["existsSync","readFileSync","findUp","readJson","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,WAAAC,EAAS,QAAAC,MAAY,QAsBvB,IAAMC,EAAmB,MAAOC,GAA8C,CACjF,IAAMC,EAAoB,MAAMN,EAAO,CAAC,aAAc,YAAY,EAAG,CACjE,KAAM,OACN,GAAIK,GAAO,CAAE,IAAAA,CAAI,CACrB,CAAC,EAED,GAAIC,GAAmB,SAAS,YAAY,EAAG,CAC3C,IAAMC,EAAQ,MAAMN,EAA2DK,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,GAAIZ,EAAWc,CAAmB,GAEVb,EAAaI,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,GAAIZ,EAAWe,CAAsB,EACjC,MAAO,CACH,KAAAH,EACA,SAAUF,EAAU,QAAU,MAClC,CAER,CAEJ,OAASM,EAAY,CAGjB,GAAI,CAACA,EAAM,QAAQ,SAAS,0BAA0B,EAClD,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 { dirname, join } from \"pathe\";\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 // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access\n if (!error.message.includes(\"Could not find lock file\")) {\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/index.cjs
CHANGED
|
@@ -1,64 +1,80 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
3
|
+
var chunkL6J2NRQY_cjs = require('./chunk-L6J2NRQY.cjs');
|
|
4
|
+
var chunkVAMRQCZW_cjs = require('./chunk-VAMRQCZW.cjs');
|
|
5
|
+
var chunkTM6ZD56C_cjs = require('./chunk-TM6ZD56C.cjs');
|
|
6
|
+
var chunkVQCWTT2B_cjs = require('./chunk-VQCWTT2B.cjs');
|
|
7
|
+
var chunkBGBPBHAL_cjs = require('./chunk-BGBPBHAL.cjs');
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
Object.defineProperty(exports, 'findMonorepoRoot', {
|
|
12
12
|
enumerable: true,
|
|
13
|
-
get: function () { return
|
|
13
|
+
get: function () { return chunkL6J2NRQY_cjs.a; }
|
|
14
14
|
});
|
|
15
15
|
Object.defineProperty(exports, 'findPackageRoot', {
|
|
16
16
|
enumerable: true,
|
|
17
|
-
get: function () { return
|
|
17
|
+
get: function () { return chunkVAMRQCZW_cjs.a; }
|
|
18
18
|
});
|
|
19
19
|
Object.defineProperty(exports, 'findLockFile', {
|
|
20
20
|
enumerable: true,
|
|
21
|
-
get: function () { return
|
|
21
|
+
get: function () { return chunkTM6ZD56C_cjs.a; }
|
|
22
22
|
});
|
|
23
23
|
Object.defineProperty(exports, 'findPackageManager', {
|
|
24
24
|
enumerable: true,
|
|
25
|
-
get: function () { return
|
|
25
|
+
get: function () { return chunkTM6ZD56C_cjs.b; }
|
|
26
26
|
});
|
|
27
27
|
Object.defineProperty(exports, 'getPackageManagerVersion', {
|
|
28
28
|
enumerable: true,
|
|
29
|
-
get: function () { return
|
|
29
|
+
get: function () { return chunkTM6ZD56C_cjs.c; }
|
|
30
30
|
});
|
|
31
31
|
Object.defineProperty(exports, 'identifyInitiatingPackageManager', {
|
|
32
32
|
enumerable: true,
|
|
33
|
-
get: function () { return
|
|
33
|
+
get: function () { return chunkTM6ZD56C_cjs.d; }
|
|
34
34
|
});
|
|
35
35
|
Object.defineProperty(exports, 'findPackageJson', {
|
|
36
36
|
enumerable: true,
|
|
37
|
-
get: function () { return
|
|
37
|
+
get: function () { return chunkVQCWTT2B_cjs.a; }
|
|
38
38
|
});
|
|
39
39
|
Object.defineProperty(exports, 'findPackageJsonSync', {
|
|
40
40
|
enumerable: true,
|
|
41
|
-
get: function () { return
|
|
41
|
+
get: function () { return chunkVQCWTT2B_cjs.b; }
|
|
42
42
|
});
|
|
43
43
|
Object.defineProperty(exports, 'parsePackageJson', {
|
|
44
44
|
enumerable: true,
|
|
45
|
-
get: function () { return
|
|
45
|
+
get: function () { return chunkVQCWTT2B_cjs.e; }
|
|
46
46
|
});
|
|
47
47
|
Object.defineProperty(exports, 'writePackageJson', {
|
|
48
48
|
enumerable: true,
|
|
49
|
-
get: function () { return
|
|
49
|
+
get: function () { return chunkVQCWTT2B_cjs.c; }
|
|
50
50
|
});
|
|
51
51
|
Object.defineProperty(exports, 'writePackageJsonSync', {
|
|
52
52
|
enumerable: true,
|
|
53
|
-
get: function () { return
|
|
53
|
+
get: function () { return chunkVQCWTT2B_cjs.d; }
|
|
54
54
|
});
|
|
55
55
|
Object.defineProperty(exports, 'findTSConfig', {
|
|
56
56
|
enumerable: true,
|
|
57
|
-
get: function () { return
|
|
57
|
+
get: function () { return chunkBGBPBHAL_cjs.c; }
|
|
58
|
+
});
|
|
59
|
+
Object.defineProperty(exports, 'findTSConfigSync', {
|
|
60
|
+
enumerable: true,
|
|
61
|
+
get: function () { return chunkBGBPBHAL_cjs.e; }
|
|
62
|
+
});
|
|
63
|
+
Object.defineProperty(exports, 'findTsConfig', {
|
|
64
|
+
enumerable: true,
|
|
65
|
+
get: function () { return chunkBGBPBHAL_cjs.b; }
|
|
66
|
+
});
|
|
67
|
+
Object.defineProperty(exports, 'findTsConfigSync', {
|
|
68
|
+
enumerable: true,
|
|
69
|
+
get: function () { return chunkBGBPBHAL_cjs.d; }
|
|
70
|
+
});
|
|
71
|
+
Object.defineProperty(exports, 'readTsConfig', {
|
|
72
|
+
enumerable: true,
|
|
73
|
+
get: function () { return chunkBGBPBHAL_cjs.a; }
|
|
58
74
|
});
|
|
59
75
|
Object.defineProperty(exports, 'writeTSConfig', {
|
|
60
76
|
enumerable: true,
|
|
61
|
-
get: function () { return
|
|
77
|
+
get: function () { return chunkBGBPBHAL_cjs.g; }
|
|
62
78
|
});
|
|
63
79
|
//# sourceMappingURL=out.js.map
|
|
64
80
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.d.cts
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
export { RootMonorepo, Strategy, findMonorepoRoot } from './monorepo.cjs';
|
|
2
2
|
export { findPackageRoot } from './package.cjs';
|
|
3
|
-
export {
|
|
3
|
+
export { NormalizedReadResult, findPackageJson, findPackageJsonSync, parsePackageJson, writePackageJson, writePackageJsonSync } from './package-json.cjs';
|
|
4
4
|
export { PackageManager, PackageManagerResult, findLockFile, findPackageManager, getPackageManagerVersion, identifyInitiatingPackageManager } from './package-manager.cjs';
|
|
5
|
-
|
|
6
|
-
export {
|
|
7
|
-
|
|
5
|
+
import { T as TsConfigJsonResolved } from './types-hoigZ9HA.cjs';
|
|
6
|
+
export { N as NormalizedPackageJson, P as PackageJson } from './types-hoigZ9HA.cjs';
|
|
7
|
+
export { TsConfigResult, findTSConfig, findTSConfigSync, findTsConfig, findTsConfigSync, writeTSConfig } from './tsconfig.cjs';
|
|
8
|
+
export { TsConfigJson } from 'type-fest';
|
|
8
9
|
import '@visulima/fs';
|
|
9
10
|
import 'normalize-package-data';
|
|
11
|
+
|
|
12
|
+
type Options = {
|
|
13
|
+
tscCompatible?: boolean;
|
|
14
|
+
};
|
|
15
|
+
declare const readTsConfig: (tsconfigPath: string, options?: Options) => TsConfigJsonResolved;
|
|
16
|
+
|
|
17
|
+
export { TsConfigJsonResolved, readTsConfig };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
export { RootMonorepo, Strategy, findMonorepoRoot } from './monorepo.js';
|
|
2
2
|
export { findPackageRoot } from './package.js';
|
|
3
|
-
export {
|
|
3
|
+
export { NormalizedReadResult, findPackageJson, findPackageJsonSync, parsePackageJson, writePackageJson, writePackageJsonSync } from './package-json.js';
|
|
4
4
|
export { PackageManager, PackageManagerResult, findLockFile, findPackageManager, getPackageManagerVersion, identifyInitiatingPackageManager } from './package-manager.js';
|
|
5
|
-
|
|
6
|
-
export {
|
|
7
|
-
|
|
5
|
+
import { T as TsConfigJsonResolved } from './types-hoigZ9HA.js';
|
|
6
|
+
export { N as NormalizedPackageJson, P as PackageJson } from './types-hoigZ9HA.js';
|
|
7
|
+
export { TsConfigResult, findTSConfig, findTSConfigSync, findTsConfig, findTsConfigSync, writeTSConfig } from './tsconfig.js';
|
|
8
|
+
export { TsConfigJson } from 'type-fest';
|
|
8
9
|
import '@visulima/fs';
|
|
9
10
|
import 'normalize-package-data';
|
|
11
|
+
|
|
12
|
+
type Options = {
|
|
13
|
+
tscCompatible?: boolean;
|
|
14
|
+
};
|
|
15
|
+
declare const readTsConfig: (tsconfigPath: string, options?: Options) => TsConfigJsonResolved;
|
|
16
|
+
|
|
17
|
+
export { TsConfigJsonResolved, readTsConfig };
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { a as findMonorepoRoot } from './chunk-
|
|
2
|
-
export { a as findPackageRoot } from './chunk-
|
|
3
|
-
export { a as findLockFile, b as findPackageManager, c as getPackageManagerVersion, d as identifyInitiatingPackageManager } from './chunk-
|
|
4
|
-
export { a as findPackageJson, b as findPackageJsonSync, e as parsePackageJson, c as writePackageJson, d as writePackageJsonSync } from './chunk-
|
|
5
|
-
export {
|
|
1
|
+
export { a as findMonorepoRoot } from './chunk-XKKPPOYW.js';
|
|
2
|
+
export { a as findPackageRoot } from './chunk-G767QS5X.js';
|
|
3
|
+
export { a as findLockFile, b as findPackageManager, c as getPackageManagerVersion, d as identifyInitiatingPackageManager } from './chunk-5ZQIFU6S.js';
|
|
4
|
+
export { a as findPackageJson, b as findPackageJsonSync, e as parsePackageJson, c as writePackageJson, d as writePackageJsonSync } from './chunk-TUN46UZB.js';
|
|
5
|
+
export { c as findTSConfig, e as findTSConfigSync, b as findTsConfig, d as findTsConfigSync, a as readTsConfig, g as writeTSConfig } from './chunk-F63DY4KL.js';
|
|
6
6
|
//# sourceMappingURL=out.js.map
|
|
7
7
|
//# sourceMappingURL=index.js.map
|
package/dist/monorepo.cjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('./chunk-
|
|
5
|
-
require('./chunk-
|
|
3
|
+
var chunkL6J2NRQY_cjs = require('./chunk-L6J2NRQY.cjs');
|
|
4
|
+
require('./chunk-TM6ZD56C.cjs');
|
|
5
|
+
require('./chunk-VQCWTT2B.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 chunkL6J2NRQY_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-
|
|
3
|
-
import './chunk-
|
|
1
|
+
export { a as findMonorepoRoot } from './chunk-XKKPPOYW.js';
|
|
2
|
+
import './chunk-5ZQIFU6S.js';
|
|
3
|
+
import './chunk-TUN46UZB.js';
|
|
4
4
|
//# sourceMappingURL=out.js.map
|
|
5
5
|
//# sourceMappingURL=monorepo.js.map
|
package/dist/package-json.cjs
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkVQCWTT2B_cjs = require('./chunk-VQCWTT2B.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
Object.defineProperty(exports, 'findPackageJson', {
|
|
8
8
|
enumerable: true,
|
|
9
|
-
get: function () { return
|
|
9
|
+
get: function () { return chunkVQCWTT2B_cjs.a; }
|
|
10
10
|
});
|
|
11
11
|
Object.defineProperty(exports, 'findPackageJsonSync', {
|
|
12
12
|
enumerable: true,
|
|
13
|
-
get: function () { return
|
|
13
|
+
get: function () { return chunkVQCWTT2B_cjs.b; }
|
|
14
14
|
});
|
|
15
15
|
Object.defineProperty(exports, 'parsePackageJson', {
|
|
16
16
|
enumerable: true,
|
|
17
|
-
get: function () { return
|
|
17
|
+
get: function () { return chunkVQCWTT2B_cjs.e; }
|
|
18
18
|
});
|
|
19
19
|
Object.defineProperty(exports, 'writePackageJson', {
|
|
20
20
|
enumerable: true,
|
|
21
|
-
get: function () { return
|
|
21
|
+
get: function () { return chunkVQCWTT2B_cjs.c; }
|
|
22
22
|
});
|
|
23
23
|
Object.defineProperty(exports, 'writePackageJsonSync', {
|
|
24
24
|
enumerable: true,
|
|
25
|
-
get: function () { return
|
|
25
|
+
get: function () { return chunkVQCWTT2B_cjs.d; }
|
|
26
26
|
});
|
|
27
27
|
//# sourceMappingURL=out.js.map
|
|
28
28
|
//# sourceMappingURL=package-json.cjs.map
|
package/dist/package-json.d.cts
CHANGED
|
@@ -1,4 +1,24 @@
|
|
|
1
|
-
import 'type-fest';
|
|
2
|
-
import '
|
|
3
|
-
|
|
1
|
+
import * as type_fest from 'type-fest';
|
|
2
|
+
import { JsonObject } from 'type-fest';
|
|
3
|
+
import { WriteJsonOptions } from '@visulima/fs';
|
|
4
|
+
import { N as NormalizedPackageJson, C as Cache } from './types-hoigZ9HA.cjs';
|
|
4
5
|
import 'normalize-package-data';
|
|
6
|
+
|
|
7
|
+
type ReadOptions = {
|
|
8
|
+
cache?: Cache<NormalizedReadResult> | boolean;
|
|
9
|
+
};
|
|
10
|
+
type NormalizedReadResult = {
|
|
11
|
+
packageJson: NormalizedPackageJson;
|
|
12
|
+
path: string;
|
|
13
|
+
};
|
|
14
|
+
declare const findPackageJson: (cwd?: URL | string, options?: ReadOptions) => Promise<NormalizedReadResult>;
|
|
15
|
+
declare const findPackageJsonSync: (cwd?: URL | string, options?: ReadOptions) => NormalizedReadResult;
|
|
16
|
+
declare const writePackageJson: <T = type_fest.PackageJson>(data: T, options?: WriteJsonOptions & {
|
|
17
|
+
cwd?: URL | string;
|
|
18
|
+
}) => Promise<void>;
|
|
19
|
+
declare const writePackageJsonSync: <T = type_fest.PackageJson>(data: T, options?: WriteJsonOptions & {
|
|
20
|
+
cwd?: URL | string;
|
|
21
|
+
}) => void;
|
|
22
|
+
declare const parsePackageJson: (packageFile: JsonObject | string) => NormalizedPackageJson;
|
|
23
|
+
|
|
24
|
+
export { type NormalizedReadResult, findPackageJson, findPackageJsonSync, parsePackageJson, writePackageJson, writePackageJsonSync };
|
package/dist/package-json.d.ts
CHANGED
|
@@ -1,4 +1,24 @@
|
|
|
1
|
-
import 'type-fest';
|
|
2
|
-
import '
|
|
3
|
-
|
|
1
|
+
import * as type_fest from 'type-fest';
|
|
2
|
+
import { JsonObject } from 'type-fest';
|
|
3
|
+
import { WriteJsonOptions } from '@visulima/fs';
|
|
4
|
+
import { N as NormalizedPackageJson, C as Cache } from './types-hoigZ9HA.js';
|
|
4
5
|
import 'normalize-package-data';
|
|
6
|
+
|
|
7
|
+
type ReadOptions = {
|
|
8
|
+
cache?: Cache<NormalizedReadResult> | boolean;
|
|
9
|
+
};
|
|
10
|
+
type NormalizedReadResult = {
|
|
11
|
+
packageJson: NormalizedPackageJson;
|
|
12
|
+
path: string;
|
|
13
|
+
};
|
|
14
|
+
declare const findPackageJson: (cwd?: URL | string, options?: ReadOptions) => Promise<NormalizedReadResult>;
|
|
15
|
+
declare const findPackageJsonSync: (cwd?: URL | string, options?: ReadOptions) => NormalizedReadResult;
|
|
16
|
+
declare const writePackageJson: <T = type_fest.PackageJson>(data: T, options?: WriteJsonOptions & {
|
|
17
|
+
cwd?: URL | string;
|
|
18
|
+
}) => Promise<void>;
|
|
19
|
+
declare const writePackageJsonSync: <T = type_fest.PackageJson>(data: T, options?: WriteJsonOptions & {
|
|
20
|
+
cwd?: URL | string;
|
|
21
|
+
}) => void;
|
|
22
|
+
declare const parsePackageJson: (packageFile: JsonObject | string) => NormalizedPackageJson;
|
|
23
|
+
|
|
24
|
+
export { type NormalizedReadResult, findPackageJson, findPackageJsonSync, parsePackageJson, writePackageJson, writePackageJsonSync };
|
package/dist/package-json.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { a as findPackageJson, b as findPackageJsonSync, e as parsePackageJson, c as writePackageJson, d as writePackageJsonSync } from './chunk-
|
|
1
|
+
export { a as findPackageJson, b as findPackageJsonSync, e as parsePackageJson, c as writePackageJson, d as writePackageJsonSync } from './chunk-TUN46UZB.js';
|
|
2
2
|
//# sourceMappingURL=out.js.map
|
|
3
3
|
//# sourceMappingURL=package-json.js.map
|
package/dist/package-manager.cjs
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('./chunk-
|
|
3
|
+
var chunkTM6ZD56C_cjs = require('./chunk-TM6ZD56C.cjs');
|
|
4
|
+
require('./chunk-VQCWTT2B.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 chunkTM6ZD56C_cjs.a; }
|
|
11
11
|
});
|
|
12
12
|
Object.defineProperty(exports, 'findPackageManager', {
|
|
13
13
|
enumerable: true,
|
|
14
|
-
get: function () { return
|
|
14
|
+
get: function () { return chunkTM6ZD56C_cjs.b; }
|
|
15
15
|
});
|
|
16
16
|
Object.defineProperty(exports, 'getPackageManagerVersion', {
|
|
17
17
|
enumerable: true,
|
|
18
|
-
get: function () { return
|
|
18
|
+
get: function () { return chunkTM6ZD56C_cjs.c; }
|
|
19
19
|
});
|
|
20
20
|
Object.defineProperty(exports, 'identifyInitiatingPackageManager', {
|
|
21
21
|
enumerable: true,
|
|
22
|
-
get: function () { return
|
|
22
|
+
get: function () { return chunkTM6ZD56C_cjs.d; }
|
|
23
23
|
});
|
|
24
24
|
//# sourceMappingURL=out.js.map
|
|
25
25
|
//# sourceMappingURL=package-manager.cjs.map
|
package/dist/package-manager.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { a as findLockFile, b as findPackageManager, c as getPackageManagerVersion, d as identifyInitiatingPackageManager } from './chunk-
|
|
2
|
-
import './chunk-
|
|
1
|
+
export { a as findLockFile, b as findPackageManager, c as getPackageManagerVersion, d as identifyInitiatingPackageManager } from './chunk-5ZQIFU6S.js';
|
|
2
|
+
import './chunk-TUN46UZB.js';
|
|
3
3
|
//# sourceMappingURL=out.js.map
|
|
4
4
|
//# sourceMappingURL=package-manager.js.map
|
package/dist/package.cjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('./chunk-
|
|
5
|
-
require('./chunk-
|
|
3
|
+
var chunkVAMRQCZW_cjs = require('./chunk-VAMRQCZW.cjs');
|
|
4
|
+
require('./chunk-TM6ZD56C.cjs');
|
|
5
|
+
require('./chunk-VQCWTT2B.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 chunkVAMRQCZW_cjs.a; }
|
|
12
12
|
});
|
|
13
13
|
//# sourceMappingURL=out.js.map
|
|
14
14
|
//# sourceMappingURL=package.cjs.map
|
package/dist/package.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { a as findPackageRoot } from './chunk-
|
|
2
|
-
import './chunk-
|
|
3
|
-
import './chunk-
|
|
1
|
+
export { a as findPackageRoot } from './chunk-G767QS5X.js';
|
|
2
|
+
import './chunk-5ZQIFU6S.js';
|
|
3
|
+
import './chunk-TUN46UZB.js';
|
|
4
4
|
//# sourceMappingURL=out.js.map
|
|
5
5
|
//# sourceMappingURL=package.js.map
|
package/dist/tsconfig.cjs
CHANGED
|
@@ -1,16 +1,32 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkBGBPBHAL_cjs = require('./chunk-BGBPBHAL.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 chunkBGBPBHAL_cjs.c; }
|
|
10
|
+
});
|
|
11
|
+
Object.defineProperty(exports, 'findTSConfigSync', {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function () { return chunkBGBPBHAL_cjs.e; }
|
|
14
|
+
});
|
|
15
|
+
Object.defineProperty(exports, 'findTsConfig', {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function () { return chunkBGBPBHAL_cjs.b; }
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports, 'findTsConfigSync', {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function () { return chunkBGBPBHAL_cjs.d; }
|
|
10
22
|
});
|
|
11
23
|
Object.defineProperty(exports, 'writeTSConfig', {
|
|
12
24
|
enumerable: true,
|
|
13
|
-
get: function () { return
|
|
25
|
+
get: function () { return chunkBGBPBHAL_cjs.g; }
|
|
26
|
+
});
|
|
27
|
+
Object.defineProperty(exports, 'writeTsConfig', {
|
|
28
|
+
enumerable: true,
|
|
29
|
+
get: function () { return chunkBGBPBHAL_cjs.f; }
|
|
14
30
|
});
|
|
15
31
|
//# sourceMappingURL=out.js.map
|
|
16
32
|
//# sourceMappingURL=tsconfig.cjs.map
|
package/dist/tsconfig.d.cts
CHANGED
|
@@ -1,10 +1,25 @@
|
|
|
1
1
|
import { WriteJsonOptions } from '@visulima/fs';
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import { TsConfigJson } from 'type-fest';
|
|
3
|
+
import { T as TsConfigJsonResolved } from './types-hoigZ9HA.cjs';
|
|
4
|
+
import 'normalize-package-data';
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
type Options = {
|
|
7
|
+
cache?: Map<string, TsConfigJsonResolved> | boolean;
|
|
8
|
+
configFileName?: string;
|
|
9
|
+
};
|
|
10
|
+
type TsConfigResult = {
|
|
11
|
+
config: TsConfigJsonResolved;
|
|
12
|
+
path: string;
|
|
13
|
+
};
|
|
14
|
+
declare const findTsConfig: (cwd?: URL | string, options?: Options) => Promise<TsConfigResult>;
|
|
15
|
+
declare const findTSConfig: (cwd?: URL | string, options?: Options) => Promise<TsConfigResult>;
|
|
16
|
+
declare const findTsConfigSync: (cwd?: URL | string, options?: Options) => TsConfigResult;
|
|
17
|
+
declare const findTSConfigSync: (cwd?: URL | string, options?: Options) => TsConfigResult;
|
|
18
|
+
declare const writeTsConfig: (data: TsConfigJson, options?: WriteJsonOptions & {
|
|
19
|
+
cwd?: URL | string;
|
|
20
|
+
}) => Promise<void>;
|
|
6
21
|
declare const writeTSConfig: (data: TsConfigJson, options?: WriteJsonOptions & {
|
|
7
22
|
cwd?: URL | string;
|
|
8
23
|
}) => Promise<void>;
|
|
9
24
|
|
|
10
|
-
export { findTSConfig, writeTSConfig };
|
|
25
|
+
export { type TsConfigResult, findTSConfig, findTSConfigSync, findTsConfig, findTsConfigSync, writeTSConfig, writeTsConfig };
|
package/dist/tsconfig.d.ts
CHANGED
|
@@ -1,10 +1,25 @@
|
|
|
1
1
|
import { WriteJsonOptions } from '@visulima/fs';
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import { TsConfigJson } from 'type-fest';
|
|
3
|
+
import { T as TsConfigJsonResolved } from './types-hoigZ9HA.js';
|
|
4
|
+
import 'normalize-package-data';
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
type Options = {
|
|
7
|
+
cache?: Map<string, TsConfigJsonResolved> | boolean;
|
|
8
|
+
configFileName?: string;
|
|
9
|
+
};
|
|
10
|
+
type TsConfigResult = {
|
|
11
|
+
config: TsConfigJsonResolved;
|
|
12
|
+
path: string;
|
|
13
|
+
};
|
|
14
|
+
declare const findTsConfig: (cwd?: URL | string, options?: Options) => Promise<TsConfigResult>;
|
|
15
|
+
declare const findTSConfig: (cwd?: URL | string, options?: Options) => Promise<TsConfigResult>;
|
|
16
|
+
declare const findTsConfigSync: (cwd?: URL | string, options?: Options) => TsConfigResult;
|
|
17
|
+
declare const findTSConfigSync: (cwd?: URL | string, options?: Options) => TsConfigResult;
|
|
18
|
+
declare const writeTsConfig: (data: TsConfigJson, options?: WriteJsonOptions & {
|
|
19
|
+
cwd?: URL | string;
|
|
20
|
+
}) => Promise<void>;
|
|
6
21
|
declare const writeTSConfig: (data: TsConfigJson, options?: WriteJsonOptions & {
|
|
7
22
|
cwd?: URL | string;
|
|
8
23
|
}) => Promise<void>;
|
|
9
24
|
|
|
10
|
-
export { findTSConfig, writeTSConfig };
|
|
25
|
+
export { type TsConfigResult, findTSConfig, findTSConfigSync, findTsConfig, findTsConfigSync, writeTSConfig, writeTsConfig };
|
package/dist/tsconfig.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { c as findTSConfig, e as findTSConfigSync, b as findTsConfig, d as findTsConfigSync, g as writeTSConfig, f as writeTsConfig } from './chunk-F63DY4KL.js';
|
|
2
2
|
//# sourceMappingURL=out.js.map
|
|
3
3
|
//# sourceMappingURL=tsconfig.js.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Package } from 'normalize-package-data';
|
|
2
|
+
import { PackageJson as PackageJson$1, Except, TsConfigJson } from 'type-fest';
|
|
3
|
+
|
|
4
|
+
type NormalizedPackageJson = Package & PackageJson;
|
|
5
|
+
type PackageJson = PackageJson$1;
|
|
6
|
+
type TsConfigJsonResolved = Except<TsConfigJson, "extends">;
|
|
7
|
+
type Cache<T = any> = Map<string, T>;
|
|
8
|
+
|
|
9
|
+
export type { Cache as C, NormalizedPackageJson as N, PackageJson as P, TsConfigJsonResolved as T };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Package } from 'normalize-package-data';
|
|
2
|
+
import { PackageJson as PackageJson$1, Except, TsConfigJson } from 'type-fest';
|
|
3
|
+
|
|
4
|
+
type NormalizedPackageJson = Package & PackageJson;
|
|
5
|
+
type PackageJson = PackageJson$1;
|
|
6
|
+
type TsConfigJsonResolved = Except<TsConfigJson, "extends">;
|
|
7
|
+
type Cache<T = any> = Map<string, T>;
|
|
8
|
+
|
|
9
|
+
export type { Cache as C, NormalizedPackageJson as N, PackageJson as P, TsConfigJsonResolved as T };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@visulima/package",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.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",
|
|
@@ -20,10 +20,12 @@
|
|
|
20
20
|
"tsconfig.json",
|
|
21
21
|
"packages",
|
|
22
22
|
"monorepo",
|
|
23
|
+
"mono-repo",
|
|
23
24
|
"pkg-manager",
|
|
24
25
|
"package-manager",
|
|
25
26
|
"find",
|
|
26
|
-
"root"
|
|
27
|
+
"root",
|
|
28
|
+
"visulima"
|
|
27
29
|
],
|
|
28
30
|
"homepage": "https://www.visulima.com/docs/package/package",
|
|
29
31
|
"repository": {
|
|
@@ -137,41 +139,43 @@
|
|
|
137
139
|
"test:watch": "vitest"
|
|
138
140
|
},
|
|
139
141
|
"dependencies": {
|
|
140
|
-
"@visulima/fs": "1.11.
|
|
141
|
-
"
|
|
142
|
+
"@visulima/fs": "1.11.1",
|
|
143
|
+
"jsonc-parser": "^3.2.1",
|
|
142
144
|
"normalize-package-data": "^6.0.0",
|
|
143
|
-
"
|
|
145
|
+
"pathe": "^1.1.2",
|
|
146
|
+
"resolve-pkg-maps": "^1.0.0",
|
|
147
|
+
"type-fest": "^4.13.1"
|
|
144
148
|
},
|
|
145
149
|
"devDependencies": {
|
|
146
150
|
"@anolilab/eslint-config": "^15.0.3",
|
|
147
151
|
"@anolilab/prettier-config": "^5.0.14",
|
|
148
152
|
"@anolilab/semantic-release-preset": "^8.0.3",
|
|
149
|
-
"@babel/core": "^7.24.
|
|
150
|
-
"@pnpm/exe": "^8.15.
|
|
153
|
+
"@babel/core": "^7.24.3",
|
|
154
|
+
"@pnpm/exe": "^8.15.5",
|
|
151
155
|
"@rushstack/eslint-plugin-security": "^0.8.1",
|
|
152
156
|
"@total-typescript/ts-reset": "^0.5.1",
|
|
153
157
|
"@types/node": "18.18.14",
|
|
154
158
|
"@vitest/coverage-v8": "^1.4.0",
|
|
155
159
|
"@vitest/ui": "^1.4.0",
|
|
156
|
-
"
|
|
160
|
+
"@yarnpkg/pnp": "4.0.2",
|
|
157
161
|
"cross-env": "^7.0.3",
|
|
158
162
|
"eslint": "^8.57.0",
|
|
159
163
|
"eslint-plugin-deprecation": "^2.0.0",
|
|
160
164
|
"eslint-plugin-etc": "^2.0.3",
|
|
161
165
|
"eslint-plugin-import": "npm:eslint-plugin-i@^2.29.1",
|
|
162
166
|
"eslint-plugin-mdx": "^3.1.5",
|
|
163
|
-
"eslint-plugin-tsdoc": "^0.2.17",
|
|
164
167
|
"eslint-plugin-vitest": "^0.3.26",
|
|
165
168
|
"eslint-plugin-vitest-globals": "^1.5.0",
|
|
166
169
|
"execa": "^8.0.1",
|
|
167
170
|
"npm": "^10.5.0",
|
|
168
171
|
"prettier": "^3.2.5",
|
|
169
172
|
"rimraf": "^5.0.5",
|
|
170
|
-
"semantic-release": "^23.0.
|
|
173
|
+
"semantic-release": "^23.0.5",
|
|
171
174
|
"sort-package-json": "^2.8.0",
|
|
175
|
+
"strip-ansi": "^7.1.0",
|
|
172
176
|
"tempy": "^3.1.0",
|
|
173
177
|
"tsup": "^8.0.2",
|
|
174
|
-
"typescript": "^5.4.
|
|
178
|
+
"typescript": "^5.4.3",
|
|
175
179
|
"vitest": "^1.4.0",
|
|
176
180
|
"which-pm-runs": "file:",
|
|
177
181
|
"yarn": "^1.22.22"
|
|
@@ -185,6 +189,9 @@
|
|
|
185
189
|
},
|
|
186
190
|
"anolilab": {
|
|
187
191
|
"eslint-config": {
|
|
192
|
+
"plugin": {
|
|
193
|
+
"tsdoc": false
|
|
194
|
+
},
|
|
188
195
|
"warn_on_unsupported_typescript_version": false,
|
|
189
196
|
"info_on_disabling_jsx_react_rule": false,
|
|
190
197
|
"info_on_disabling_prettier_conflict_rule": false,
|
package/dist/chunk-3BB7IH7P.cjs
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var fs$1 = require('fs');
|
|
4
|
-
var path = require('path');
|
|
5
|
-
var fs = require('@visulima/fs');
|
|
6
|
-
var error = require('@visulima/fs/error');
|
|
7
|
-
var utils = require('@visulima/fs/utils');
|
|
8
|
-
var a = require('normalize-package-data');
|
|
9
|
-
|
|
10
|
-
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
-
|
|
12
|
-
var a__default = /*#__PURE__*/_interopDefault(a);
|
|
13
|
-
|
|
14
|
-
var N=async o=>{let t=await fs.findUp("package.json",{...o&&{cwd:o},type:"file"});if(!t)throw new error.NotFoundError("Could not find package.json");let n=await fs.readJson(t);return a__default.default(n),{packageJson:n,path:t}},R=o=>{let t=fs.findUpSync("package.json",{...o&&{cwd:o},type:"file"});if(!t)throw new error.NotFoundError("Could not find package.json");let n=fs.readJsonSync(t);return a__default.default(n),{packageJson:n,path:t}},O=async(o,t={})=>{let{cwd:n,...s}=t,r=utils.toPath(t.cwd??process.cwd());await fs.writeJson(path.join(r,"package.json"),o,s);},S=(o,t={})=>{let{cwd:n,...s}=t,r=utils.toPath(t.cwd??process.cwd());fs.writeJsonSync(path.join(r,"package.json"),o,s);},x=o=>{let t=o!==null&&typeof o=="object"&&!Array.isArray(o);if(!t&&!(typeof o=="string"))throw new TypeError("`packageFile` should be either an `object` or a `string`.");let s=t?structuredClone(o):fs$1.existsSync(o)?fs.readJsonSync(o):utils.parseJson(o);return a__default.default(s),s};
|
|
15
|
-
|
|
16
|
-
exports.a = N;
|
|
17
|
-
exports.b = R;
|
|
18
|
-
exports.c = O;
|
|
19
|
-
exports.d = S;
|
|
20
|
-
exports.e = x;
|
|
21
|
-
//# sourceMappingURL=out.js.map
|
|
22
|
-
//# sourceMappingURL=chunk-3BB7IH7P.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/package-json.ts"],"names":["existsSync","join","findUp","findUpSync","readJson","readJsonSync","writeJson","writeJsonSync","NotFoundError","parseJson","toPath","normalizeData","findPackageJson","cwd","filePath","packageJson","findPackageJsonSync","writePackageJson","data","options","writeOptions","directory","writePackageJsonSync","parsePackageJson","packageFile","isObject","json"],"mappings":"AAAA,OAAS,cAAAA,MAAkB,KAC3B,OAAS,QAAAC,MAAY,OAGrB,OAAS,UAAAC,EAAQ,cAAAC,EAAY,YAAAC,EAAU,gBAAAC,EAAc,aAAAC,EAAW,iBAAAC,MAAqB,eACrF,OAAS,iBAAAC,MAAqB,qBAC9B,OAAS,aAAAC,EAAW,UAAAC,MAAc,qBAElC,OAAOC,MAAmB,yBAkBnB,IAAMC,EAAkB,MAAOC,GAAsD,CACxF,IAAMC,EAAW,MAAMZ,EAAO,eAAgB,CAC1C,GAAIW,GAAO,CAAE,IAAAA,CAAI,EACjB,KAAM,MACV,CAAC,EAED,GAAI,CAACC,EACD,MAAM,IAAIN,EAAc,6BAA6B,EAGzD,IAAMO,EAAc,MAAMX,EAASU,CAAQ,EAE3C,OAAAH,EAAcI,CAAoB,EAE3B,CACH,YAAaA,EACb,KAAMD,CACV,CACJ,EAEaE,EAAuBH,GAA6C,CAC7E,IAAMC,EAAWX,EAAW,eAAgB,CACxC,GAAIU,GAAO,CAAE,IAAAA,CAAI,EACjB,KAAM,MACV,CAAC,EAED,GAAI,CAACC,EACD,MAAM,IAAIN,EAAc,6BAA6B,EAGzD,IAAMO,EAAcV,EAAaS,CAAQ,EAEzC,OAAAH,EAAcI,CAAoB,EAE3B,CACH,YAAaA,EACb,KAAMD,CACV,CACJ,EAYaG,EAAmB,MAAwBC,EAASC,EAAqD,CAAC,IAAqB,CACxI,GAAM,CAAE,IAAAN,EAAK,GAAGO,CAAa,EAAID,EAC3BE,EAAYX,EAAOS,EAAQ,KAAO,QAAQ,IAAI,CAAC,EAErD,MAAMb,EAAUL,EAAKoB,EAAW,cAAc,EAAGH,EAAME,CAAY,CACvE,EAEaE,EAAuB,CAAkBJ,EAASC,EAAqD,CAAC,IAAY,CAC7H,GAAM,CAAE,IAAAN,EAAK,GAAGO,CAAa,EAAID,EAC3BE,EAAYX,EAAOS,EAAQ,KAAO,QAAQ,IAAI,CAAC,EAErDZ,EAAcN,EAAKoB,EAAW,cAAc,EAAGH,EAAME,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,EAE3BxB,EAAWwB,CAAqB,EAC9BnB,EAAamB,CAAqB,EAClCf,EAAUe,CAAqB,EAEvC,OAAAb,EAAce,CAAa,EAEpBA,CACX","sourcesContent":["import { existsSync } from \"node:fs\";\nimport { join } from \"node:path\";\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 type { Input } from \"normalize-package-data\";\nimport normalizeData from \"normalize-package-data\";\nimport type { JsonObject } from \"type-fest\";\n\nimport type { NormalizedPackageJson, PackageJson } from \"./types\";\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): Promise<NormalizedReadResult> => {\n const filePath = await findUp(\"package.json\", {\n ...(cwd && { cwd }),\n type: \"file\",\n });\n\n if (!filePath) {\n throw new NotFoundError(\"Could not find package.json\");\n }\n\n const packageJson = await readJson(filePath);\n\n normalizeData(packageJson as Input);\n\n return {\n packageJson: packageJson as NormalizedPackageJson,\n path: filePath,\n };\n};\n\nexport const findPackageJsonSync = (cwd?: URL | string): NormalizedReadResult => {\n const filePath = findUpSync(\"package.json\", {\n ...(cwd && { cwd }),\n type: \"file\",\n });\n\n if (!filePath) {\n throw new NotFoundError(\"Could not find package.json\");\n }\n\n const packageJson = readJsonSync(filePath);\n\n normalizeData(packageJson as Input);\n\n return {\n packageJson: packageJson as NormalizedPackageJson,\n path: filePath,\n };\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"]}
|