@visulima/package 5.0.0-alpha.2 → 5.0.0-alpha.20

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 CHANGED
@@ -1,3 +1,254 @@
1
+ ## @visulima/package [5.0.0-alpha.20](https://github.com/visulima/visulima/compare/@visulima/package@5.0.0-alpha.19...@visulima/package@5.0.0-alpha.20) (2026-05-11)
2
+
3
+ ### ⚠ BREAKING CHANGES
4
+
5
+ * **vis:** vis sbom now emits CycloneDX 1.7. Downstream consumers
6
+ pinned to a 1.6 validator must upgrade.
7
+
8
+ Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
9
+
10
+ ### Features
11
+
12
+ * **vis:** bump sbom to cyclonedx 1.7 ([904075f](https://github.com/visulima/visulima/commit/904075fd9353e40b593d5a13f53307c584e31da7))
13
+
14
+
15
+ ### Dependencies
16
+
17
+ * **@visulima/fs:** upgraded to 5.0.0-alpha.21
18
+
19
+ ## @visulima/package [5.0.0-alpha.19](https://github.com/visulima/visulima/compare/@visulima/package@5.0.0-alpha.18...@visulima/package@5.0.0-alpha.19) (2026-05-11)
20
+
21
+
22
+ ### Dependencies
23
+
24
+ * **@visulima/fs:** upgraded to 5.0.0-alpha.20
25
+
26
+ ## @visulima/package [5.0.0-alpha.18](https://github.com/visulima/visulima/compare/@visulima/package@5.0.0-alpha.17...@visulima/package@5.0.0-alpha.18) (2026-05-10)
27
+
28
+
29
+ ### Dependencies
30
+
31
+ * **@visulima/fs:** upgraded to 5.0.0-alpha.19
32
+
33
+ ## @visulima/package [5.0.0-alpha.17](https://github.com/visulima/visulima/compare/@visulima/package@5.0.0-alpha.16...@visulima/package@5.0.0-alpha.17) (2026-05-10)
34
+
35
+ ### Code Refactoring
36
+
37
+ * replace execa with tinyexec ([56ec776](https://github.com/visulima/visulima/commit/56ec776908fe0c068c54542f3885cb29f061fea7))
38
+
39
+
40
+ ### Dependencies
41
+
42
+ * **@visulima/fs:** upgraded to 5.0.0-alpha.18
43
+
44
+ ## @visulima/package [5.0.0-alpha.16](https://github.com/visulima/visulima/compare/@visulima/package@5.0.0-alpha.15...@visulima/package@5.0.0-alpha.16) (2026-05-07)
45
+
46
+
47
+ ### Dependencies
48
+
49
+ * **@visulima/fs:** upgraded to 5.0.0-alpha.17
50
+
51
+ ## @visulima/package [5.0.0-alpha.15](https://github.com/visulima/visulima/compare/@visulima/package@5.0.0-alpha.14...@visulima/package@5.0.0-alpha.15) (2026-05-07)
52
+
53
+
54
+ ### Dependencies
55
+
56
+ * **@visulima/fs:** upgraded to 5.0.0-alpha.16
57
+
58
+ ## @visulima/package [5.0.0-alpha.14](https://github.com/visulima/visulima/compare/@visulima/package@5.0.0-alpha.13...@visulima/package@5.0.0-alpha.14) (2026-05-06)
59
+
60
+
61
+ ### Dependencies
62
+
63
+ * **@visulima/fs:** upgraded to 5.0.0-alpha.15
64
+
65
+ ## @visulima/package [5.0.0-alpha.13](https://github.com/visulima/visulima/compare/@visulima/package@5.0.0-alpha.12...@visulima/package@5.0.0-alpha.13) (2026-05-06)
66
+
67
+ ### Miscellaneous Chores
68
+
69
+ * **package:** apply prettier and eslint quote-style auto-fix ([0316bca](https://github.com/visulima/visulima/commit/0316bca0deca444ff12675bc760c7091ce243d31))
70
+ * **package:** housekeeping cleanup ([113978b](https://github.com/visulima/visulima/commit/113978b0babcfc7879514aec076f6e2d5e7afab0))
71
+
72
+
73
+ ### Dependencies
74
+
75
+ * **@visulima/fs:** upgraded to 5.0.0-alpha.14
76
+
77
+ ## @visulima/package [5.0.0-alpha.12](https://github.com/visulima/visulima/compare/@visulima/package@5.0.0-alpha.11...@visulima/package@5.0.0-alpha.12) (2026-05-04)
78
+
79
+ ### Miscellaneous Chores
80
+
81
+ * **package:** upgrade packem to 2.0.0-alpha.76 ([b2ef62b](https://github.com/visulima/visulima/commit/b2ef62b72a84545cb025a250cbe7e3e36b34330d))
82
+ * re-sort workspace package.json files via vis sort-package-json ([f625696](https://github.com/visulima/visulima/commit/f625696cfac974325774b3243e1a83c3d23acbd7))
83
+ * simplify pnpm-workspace packages list ([7cab221](https://github.com/visulima/visulima/commit/7cab221163632d9b7aa044a6f88c49083103a869))
84
+
85
+
86
+ ### Dependencies
87
+
88
+ * **@visulima/fs:** upgraded to 5.0.0-alpha.13
89
+
90
+ ## @visulima/package [5.0.0-alpha.11](https://github.com/visulima/visulima/compare/@visulima/package@5.0.0-alpha.10...@visulima/package@5.0.0-alpha.11) (2026-04-22)
91
+
92
+ ### Bug Fixes
93
+
94
+ * Remove JSR configuration generation script and generated jsr.json files ([#616](https://github.com/visulima/visulima/issues/616)) ([533744b](https://github.com/visulima/visulima/commit/533744b103b74896941db5b727173e617a27a63b))
95
+
96
+
97
+ ### Dependencies
98
+
99
+ * **@visulima/fs:** upgraded to 5.0.0-alpha.12
100
+ * **@visulima/path:** upgraded to 3.0.0-alpha.10
101
+
102
+ ## @visulima/package [5.0.0-alpha.10](https://github.com/visulima/visulima/compare/@visulima/package@5.0.0-alpha.9...@visulima/package@5.0.0-alpha.10) (2026-04-21)
103
+
104
+ ### Miscellaneous Chores
105
+
106
+ * jsr.json update and lock file ([73fce38](https://github.com/visulima/visulima/commit/73fce38c7cb4603f3fffb88609b1b18e2feb4937))
107
+
108
+
109
+ ### Dependencies
110
+
111
+ * **@visulima/fs:** upgraded to 5.0.0-alpha.11
112
+
113
+ ## @visulima/package [5.0.0-alpha.9](https://github.com/visulima/visulima/compare/@visulima/package@5.0.0-alpha.8...@visulima/package@5.0.0-alpha.9) (2026-04-21)
114
+
115
+ ### Miscellaneous Chores
116
+
117
+ * update the jsr.json ([864ab7e](https://github.com/visulima/visulima/commit/864ab7e71c4b5ae82f64792d1ae8debfea2c539b))
118
+
119
+
120
+ ### Dependencies
121
+
122
+ * **@visulima/fs:** upgraded to 5.0.0-alpha.10
123
+
124
+ ## @visulima/package [5.0.0-alpha.8](https://github.com/visulima/visulima/compare/@visulima/package@5.0.0-alpha.7...@visulima/package@5.0.0-alpha.8) (2026-04-21)
125
+
126
+ ### Features
127
+
128
+ * Add CycloneDX 1.6 SBOM generation with `vis sbom` command ([#611](https://github.com/visulima/visulima/issues/611)) ([1e95276](https://github.com/visulima/visulima/commit/1e9527630958722a0f0f7e79d18bb23b5a57e0df))
129
+ * **package:** add lockfile utilities ([12f9076](https://github.com/visulima/visulima/commit/12f9076ba1570bec2f2d43b58fcd31701634434e))
130
+
131
+ ### Bug Fixes
132
+
133
+ * **package:** hoist regexes, rewrite lockfile parser, resolve eslint issues ([585ed7f](https://github.com/visulima/visulima/commit/585ed7f16b3f42996bb030a8bae5f1f37a50c316))
134
+
135
+ ### Miscellaneous Chores
136
+
137
+ * **api-platform:** apply pending lint and source updates ([3fb0043](https://github.com/visulima/visulima/commit/3fb0043a4cf35f752ca89a09a077100ae0142da8))
138
+ * bump engines.node to ^22.14.0 || >=24.10.0 ([c3d0931](https://github.com/visulima/visulima/commit/c3d0931d1504e4f21ebf50ea680cfa7ce4ba15ce))
139
+ * fixed jsr.json ([5d85e51](https://github.com/visulima/visulima/commit/5d85e5179de38e284ec433b14d77c71a1619c8d6))
140
+ * **package:** apply formatter and lint fixes ([a0f4acf](https://github.com/visulima/visulima/commit/a0f4acfb15beb256edd3b62958b4e3db039757a9))
141
+ * **package:** apply pending changes ([919b214](https://github.com/visulima/visulima/commit/919b214f9659a5b4ff95ec8b35a70c10af3c4853))
142
+ * **package:** apply pending lint and source updates ([2fd1c04](https://github.com/visulima/visulima/commit/2fd1c044d9528500943368c01f9b24fd2280058c))
143
+ * **package:** enforce curly braces and apply lint fixes ([0df50ba](https://github.com/visulima/visulima/commit/0df50ba4f45bac67dabeb78ebfc3d555ba5aec56))
144
+
145
+
146
+ ### Dependencies
147
+
148
+ * **@visulima/fs:** upgraded to 5.0.0-alpha.9
149
+
150
+ ## @visulima/package [5.0.0-alpha.7](https://github.com/visulima/visulima/compare/@visulima/package@5.0.0-alpha.6...@visulima/package@5.0.0-alpha.7) (2026-04-08)
151
+
152
+ ### Bug Fixes
153
+
154
+ * **package:** properly fix eslint errors in code ([56b1547](https://github.com/visulima/visulima/commit/56b15474d6edd8f33fb46cca81fa34d600df2023))
155
+ * **package:** remove remaining eslint suppressions with proper code fixes ([69efa7a](https://github.com/visulima/visulima/commit/69efa7a9c67977c491a1ec8eaded733478ed29a1))
156
+ * **package:** resolve eslint errors ([1ec4728](https://github.com/visulima/visulima/commit/1ec47286cfcec55ea50c51d51f198b119dd22e71))
157
+ * resolve failing tests across multiple packages ([2b4b6f0](https://github.com/visulima/visulima/commit/2b4b6f04169b60fdc4cf77b293015436a272c0fb))
158
+
159
+ ### Miscellaneous Chores
160
+
161
+ * **package:** add tsconfig.eslint.json for type-aware linting ([0355fea](https://github.com/visulima/visulima/commit/0355fea301fb7a8571da25bebd108830bc23ed04))
162
+ * **package:** apply prettier formatting ([ebb5bd1](https://github.com/visulima/visulima/commit/ebb5bd12c6b7d49811c68ea96bf62ce7e2a7d42d))
163
+ * **package:** migrate .prettierrc.cjs to prettier.config.js ([2b84ef0](https://github.com/visulima/visulima/commit/2b84ef0db67467e1360b2f1e6f9b6e96bf3dbbb0))
164
+ * **tooling:** remove empty dependency objects from package.json ([dc52a23](https://github.com/visulima/visulima/commit/dc52a23bc1e2d36f4ec71ca67506bf6861a02929))
165
+
166
+
167
+ ### Dependencies
168
+
169
+ * **@visulima/fs:** upgraded to 5.0.0-alpha.7
170
+ * **@visulima/path:** upgraded to 3.0.0-alpha.8
171
+
172
+ ## @visulima/package [5.0.0-alpha.6](https://github.com/visulima/visulima/compare/@visulima/package@5.0.0-alpha.5...@visulima/package@5.0.0-alpha.6) (2026-03-26)
173
+
174
+ ### Features
175
+
176
+ * **web:** auto-generate packages page from workspace metadata ([623e520](https://github.com/visulima/visulima/commit/623e5207693a7fe720f5f2f179593a3654c880e3))
177
+
178
+ ### Miscellaneous Chores
179
+
180
+ * update homepage URLs to visulima.com/packages/ format ([be42968](https://github.com/visulima/visulima/commit/be42968129df85fb074224435e33135ff44cab91))
181
+
182
+
183
+ ### Dependencies
184
+
185
+ * **@visulima/fs:** upgraded to 5.0.0-alpha.6
186
+ * **@visulima/path:** upgraded to 3.0.0-alpha.7
187
+
188
+ ## @visulima/package [5.0.0-alpha.5](https://github.com/visulima/visulima/compare/@visulima/package@5.0.0-alpha.4...@visulima/package@5.0.0-alpha.5) (2026-03-26)
189
+
190
+ ### Bug Fixes
191
+
192
+ * **package:** use workspace:* for internal [@visulima](https://github.com/visulima) deps ([e409128](https://github.com/visulima/visulima/commit/e409128c02a6d801dd385ae845c1ab28ca5c09da))
193
+ * **web:** improve build setup with incremental stats caching and prod install ([fe33e75](https://github.com/visulima/visulima/commit/fe33e75827586779b4b3a0c6d57b39f889ee6207))
194
+
195
+ ### Miscellaneous Chores
196
+
197
+ * **package:** migrate deps to pnpm catalogs ([301fac4](https://github.com/visulima/visulima/commit/301fac41be88df7469155649467921a72ca740a6))
198
+ * **package:** update dependencies ([fb1a43d](https://github.com/visulima/visulima/commit/fb1a43de0fd345806d76aec660d48c627d576083))
199
+ * visulima website ([#591](https://github.com/visulima/visulima/issues/591)) ([59ab2e2](https://github.com/visulima/visulima/commit/59ab2e2befb03e51cd2088956f83d9b87de6d033))
200
+
201
+
202
+ ### Dependencies
203
+
204
+ * **@visulima/fs:** upgraded to 5.0.0-alpha.5
205
+ * **@visulima/path:** upgraded to 3.0.0-alpha.6
206
+
207
+ ## @visulima/package [5.0.0-alpha.4](https://github.com/visulima/visulima/compare/@visulima/package@5.0.0-alpha.3...@visulima/package@5.0.0-alpha.4) (2026-03-06)
208
+
209
+ ### Bug Fixes
210
+
211
+ * **package:** update packem to 2.0.0-alpha.54 ([e5b3249](https://github.com/visulima/visulima/commit/e5b3249026a425b7a42443f66a08f8f68c3d62e4))
212
+ * **package:** use intentionally malformed JSON in bad workspace fixture ([a6680e7](https://github.com/visulima/visulima/commit/a6680e7a97aeae643c26b69bc5eb6c64c28de278))
213
+
214
+ ### Documentation
215
+
216
+ * **humanizer,html,iso-locale,package,tsconfig:** add comprehensive Fumadocs documentation ([19781ce](https://github.com/visulima/visulima/commit/19781ce5d27605971a9f2fdf0a99863effd98091))
217
+
218
+ ### Miscellaneous Chores
219
+
220
+ * **package:** update dependencies ([d89cde6](https://github.com/visulima/visulima/commit/d89cde6792e9036d0690cfaf9b771e26b24faac8))
221
+ * **package:** update dependencies ([4b62cf8](https://github.com/visulima/visulima/commit/4b62cf85e6ef4deac4ef01c8a7e15bcf49ecbe80))
222
+ * **tooling:** update dependencies ([7f6f9d3](https://github.com/visulima/visulima/commit/7f6f9d3c41b170c53659ab34b79ceb23e4e9660a))
223
+ * update lock file maintenance ([d83e716](https://github.com/visulima/visulima/commit/d83e71697b75d24704185b66bb521a934d2db02d))
224
+ * year update ([47f4105](https://github.com/visulima/visulima/commit/47f410596ce7190cfea36a073db32e0cec50bbcd))
225
+
226
+ ### Tests
227
+
228
+ * **package:** fix broken JSON test fixture ([46141d6](https://github.com/visulima/visulima/commit/46141d6472d8de20512109200a12e79c48ddc33c))
229
+
230
+
231
+ ### Dependencies
232
+
233
+ * **@visulima/fs:** upgraded to 5.0.0-alpha.4
234
+ * **@visulima/path:** upgraded to 3.0.0-alpha.5
235
+
236
+ ## @visulima/package [5.0.0-alpha.3](https://github.com/visulima/visulima/compare/@visulima/package@5.0.0-alpha.2...@visulima/package@5.0.0-alpha.3) (2025-12-27)
237
+
238
+ ### Bug Fixes
239
+
240
+ * **package:** update package files ([586668e](https://github.com/visulima/visulima/commit/586668ee3a790163aca11ddc8f35b7bdfd740ac6))
241
+
242
+ ### Miscellaneous Chores
243
+
244
+ * fixed project.json names and schema path ([964722f](https://github.com/visulima/visulima/commit/964722f691db205c7edb9aa6db29e849a647500b))
245
+
246
+
247
+ ### Dependencies
248
+
249
+ * **@visulima/fs:** upgraded to 5.0.0-alpha.3
250
+ * **@visulima/path:** upgraded to 3.0.0-alpha.4
251
+
1
252
  ## @visulima/package [5.0.0-alpha.2](https://github.com/visulima/visulima/compare/@visulima/package@5.0.0-alpha.1...@visulima/package@5.0.0-alpha.2) (2025-12-11)
2
253
 
3
254
  ### Bug Fixes
package/LICENSE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2025 visulima
3
+ Copyright (c) 2026 visulima
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/dist/error.d.ts CHANGED
@@ -1 +1,15 @@
1
- export { default as PackageNotFoundError } from "./error/package-not-found-error.d.ts";
1
+ /**
2
+ * Error thrown when a package was not found.
3
+ */
4
+ declare class PackageNotFoundError extends Error {
5
+ /**
6
+ * @param packageName The name of the package that was not found.
7
+ * @param packageManager The package manager used to install the package.
8
+ */
9
+ constructor(packageName: string[] | string, packageManager?: string);
10
+ get code(): string;
11
+ set code(_name: string);
12
+ override get name(): string;
13
+ override set name(_name: string);
14
+ }
15
+ export { PackageNotFoundError };
package/dist/error.js CHANGED
@@ -1 +1 @@
1
- import{default as a}from"./packem_shared/PackageNotFoundError-BictYTIA.js";export{a as PackageNotFoundError};
1
+ import{default as a}from"./packem_shared/PackageNotFoundError--qHnCLzN.js";export{a as PackageNotFoundError};
package/dist/index.d.ts CHANGED
@@ -1,11 +1,13 @@
1
- export { default as PackageNotFoundError } from "./error/package-not-found-error.d.ts";
2
- export type { RootMonorepo, Strategy } from "./monorepo.d.ts";
3
- export { findMonorepoRoot, findMonorepoRootSync } from "./monorepo.d.ts";
4
- export { findPackageRoot, findPackageRootSync } from "./package.d.ts";
5
- export type { FindPackageJsonCache, NormalizedReadResult } from "./package-json.d.ts";
6
- export { ensurePackages, findPackageJson, findPackageJsonSync, getPackageJsonProperty, hasPackageJsonAnyDependency, hasPackageJsonProperty, parsePackageJson, parsePackageJsonSync, writePackageJson, writePackageJsonSync, } from "./package-json.d.ts";
7
- export type { PackageManager, PackageManagerResult } from "./package-manager.d.ts";
8
- export { findLockFile, findLockFileSync, findPackageManager, findPackageManagerSync, generateMissingPackagesInstallMessage, getPackageManagerVersion, identifyInitiatingPackageManager, } from "./package-manager.d.ts";
9
- export type { PnpmCatalog, PnpmCatalogs } from "./pnpm.d.ts";
10
- export { isPackageInWorkspace, readPnpmCatalogs, readPnpmCatalogsSync, resolveCatalogReference, resolveCatalogReferences, resolveDependenciesCatalogReferences, } from "./pnpm.d.ts";
11
- export type { EnsurePackagesOptions, NormalizedPackageJson, PackageJson } from "./types.d.ts";
1
+ export { PackageNotFoundError } from "./error.js";
2
+ export { type LockFileEntry, type LockFileIntegrity, type LockFileIntegrityAlgorithm, type LockFileParseResult, type LockFileType, decodeSriIntegrity, parseBunLockFile, parseLockFile, parseLockFileContent, parseLockFileSync, parseNpmLockFile, parsePnpmLockFile, parseYarnLockFile } from "./lockfile.js";
3
+ export { type RootMonorepo, type Strategy, findMonorepoRoot, findMonorepoRootSync } from "./monorepo.js";
4
+ export { findPackageRoot, findPackageRootSync } from "./package.js";
5
+ export { type E as EnsurePackagesOptions, type F as FindPackageJsonCache, type N as NormalizedPackageJson, type a as NormalizedReadResult, type P as PackageJson, e as ensurePackages, f as findPackageJson, b as findPackageJsonSync, g as getPackageJsonProperty, h as hasPackageJsonAnyDependency, c as hasPackageJsonProperty, p as parsePackageJson, d as parsePackageJsonSync, w as writePackageJson, i as writePackageJsonSync } from "./packem_shared/package-json.d-R9WIRfmM.js";
6
+ export { type PackageManager, type PackageManagerResult, findLockFile, findLockFileSync, findPackageManager, findPackageManagerSync, generateMissingPackagesInstallMessage, getPackageManagerVersion, identifyInitiatingPackageManager } from "./package-manager.js";
7
+ export { type PnpmCatalog, type PnpmCatalogs, isPackageInWorkspace, readPnpmCatalogs, readPnpmCatalogsSync, resolveCatalogReference, resolveCatalogReferences, resolveDependenciesCatalogReferences } from "./pnpm.js";
8
+ import '@visulima/fs';
9
+ import 'type-fest';
10
+ import '@antfu/install-pkg';
11
+ import '@inquirer/core';
12
+ import '@inquirer/type';
13
+ import 'normalize-package-data';
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{default as n}from"./packem_shared/PackageNotFoundError-BictYTIA.js";import{findMonorepoRoot as r,findMonorepoRootSync as c}from"./monorepo.js";import{findPackageRoot as s,findPackageRootSync as t}from"./package.js";import{ensurePackages as P,findPackageJson as k,findPackageJsonSync as f,getPackageJsonProperty as d,hasPackageJsonAnyDependency as p,hasPackageJsonProperty as l,parsePackageJson as y,parsePackageJsonSync as J,writePackageJson as m,writePackageJsonSync as M}from"./package-json.js";import{findLockFile as R,findLockFileSync as x,findPackageManager as C,findPackageManagerSync as u,generateMissingPackagesInstallMessage as v,getPackageManagerVersion as F,identifyInitiatingPackageManager as I}from"./package-manager.js";import{isPackageInWorkspace as w,readPnpmCatalogs as D,readPnpmCatalogsSync as L,resolveCatalogReference as A,resolveCatalogReferences as E,resolveDependenciesCatalogReferences as N}from"./pnpm.js";export{n as PackageNotFoundError,P as ensurePackages,R as findLockFile,x as findLockFileSync,r as findMonorepoRoot,c as findMonorepoRootSync,k as findPackageJson,f as findPackageJsonSync,C as findPackageManager,u as findPackageManagerSync,s as findPackageRoot,t as findPackageRootSync,v as generateMissingPackagesInstallMessage,d as getPackageJsonProperty,F as getPackageManagerVersion,p as hasPackageJsonAnyDependency,l as hasPackageJsonProperty,I as identifyInitiatingPackageManager,w as isPackageInWorkspace,y as parsePackageJson,J as parsePackageJsonSync,D as readPnpmCatalogs,L as readPnpmCatalogsSync,A as resolveCatalogReference,E as resolveCatalogReferences,N as resolveDependenciesCatalogReferences,m as writePackageJson,M as writePackageJsonSync};
1
+ import{default as o}from"./packem_shared/PackageNotFoundError--qHnCLzN.js";import{decodeSriIntegrity as r,parseBunLockFile as c,parseLockFile as s,parseLockFileContent as g,parseLockFileSync as i,parseNpmLockFile as t,parsePnpmLockFile as k,parseYarnLockFile as p}from"./lockfile.js";import{findMonorepoRoot as f,findMonorepoRootSync as l}from"./monorepo.js";import{findPackageRoot as y,findPackageRootSync as m}from"./package.js";import{ensurePackages as S,findPackageJson as J,findPackageJsonSync as L,getPackageJsonProperty as M,hasPackageJsonAnyDependency as x,hasPackageJsonProperty as R,parsePackageJson as C,parsePackageJsonSync as u,writePackageJson as I,writePackageJsonSync as v}from"./package-json.js";import{findLockFile as w,findLockFileSync as D,findPackageManager as N,findPackageManagerSync as A,generateMissingPackagesInstallMessage as B,getPackageManagerVersion as E,identifyInitiatingPackageManager as V}from"./package-manager.js";import{isPackageInWorkspace as Y,readPnpmCatalogs as b,readPnpmCatalogsSync as j,resolveCatalogReference as q,resolveCatalogReferences as z,resolveDependenciesCatalogReferences as G}from"./pnpm.js";export{o as PackageNotFoundError,r as decodeSriIntegrity,S as ensurePackages,w as findLockFile,D as findLockFileSync,f as findMonorepoRoot,l as findMonorepoRootSync,J as findPackageJson,L as findPackageJsonSync,N as findPackageManager,A as findPackageManagerSync,y as findPackageRoot,m as findPackageRootSync,B as generateMissingPackagesInstallMessage,M as getPackageJsonProperty,E as getPackageManagerVersion,x as hasPackageJsonAnyDependency,R as hasPackageJsonProperty,V as identifyInitiatingPackageManager,Y as isPackageInWorkspace,c as parseBunLockFile,s as parseLockFile,g as parseLockFileContent,i as parseLockFileSync,t as parseNpmLockFile,C as parsePackageJson,u as parsePackageJsonSync,k as parsePnpmLockFile,p as parseYarnLockFile,b as readPnpmCatalogs,j as readPnpmCatalogsSync,q as resolveCatalogReference,z as resolveCatalogReferences,G as resolveDependenciesCatalogReferences,I as writePackageJson,v as writePackageJsonSync};
@@ -0,0 +1,114 @@
1
+ /** Lockfiles the parser recognises. Legacy binary `bun.lockb` is unsupported. */
2
+ type LockFileType = "bun" | "npm" | "pnpm" | "yarn";
3
+ /** SRI algorithms the parser can decode into hex. */
4
+ type LockFileIntegrityAlgorithm = "sha256" | "sha384" | "sha512";
5
+ /** Decoded integrity digest: algorithm + lowercase hex string. */
6
+ interface LockFileIntegrity {
7
+ algorithm: LockFileIntegrityAlgorithm;
8
+ hex: string;
9
+ }
10
+ /** A single resolved package extracted from a lockfile. */
11
+ interface LockFileEntry {
12
+ /**
13
+ * Declared runtime dependencies — `name → specifier[]` map. Values
14
+ * are arrays so pnpm v9+ peer-context variants (the same dep name
15
+ * resolved to different versions under different peer contexts)
16
+ * can all be preserved. npm, yarn v1, bun, and pnpm v6-v8 always
17
+ * produce single-element arrays; pnpm v9+ may produce multi-element
18
+ * arrays for peer-context-sensitive deps.
19
+ *
20
+ * Specifiers are whatever the lockfile recorded — a range
21
+ * (`^1.0.0`) for npm / yarn / bun, or an already-resolved exact
22
+ * version for pnpm. Callers resolve each specifier against
23
+ * {@link LockFileEntry.version} values elsewhere in the lockfile
24
+ * when they need a concrete edge.
25
+ */
26
+ dependencies?: Record<string, string[]>;
27
+ /** Decoded SRI digest, if the lockfile recorded one. */
28
+ integrity?: LockFileIntegrity;
29
+ /** Package name — `lodash` or `@scope/name`. */
30
+ name: string;
31
+ /** Declared optional dependencies, same shape as `dependencies`. */
32
+ optionalDependencies?: Record<string, string[]>;
33
+ /** Declared peer dependencies, same shape as `dependencies`. */
34
+ peerDependencies?: Record<string, string[]>;
35
+ /** Resolved exact version — e.g. `4.17.21`. */
36
+ version: string;
37
+ }
38
+ /** Result of locating + parsing a lockfile on disk. */
39
+ interface LockFileParseResult {
40
+ entries: LockFileEntry[];
41
+ /** Absolute path of the lockfile that was parsed. */
42
+ path: string;
43
+ type: LockFileType;
44
+ }
45
+ /**
46
+ * Decodes a Subresource Integrity string (`sha512-&lt;base64>`) into a
47
+ * `{ algorithm, hex }` pair. Returns `undefined` if the string is
48
+ * malformed, oversized, or uses an unsupported algorithm.
49
+ * @param sri Full SRI string, e.g. `sha512-&lt;base64>`.
50
+ * @returns Decoded algorithm + hex digest, or `undefined` when the
51
+ * input can't be parsed.
52
+ */
53
+ declare const decodeSriIntegrity: (sri: string) => LockFileIntegrity | undefined;
54
+ /**
55
+ * Parses `package-lock.json` (npm v2 / v3 format).
56
+ * @param content Raw JSON text of the lockfile.
57
+ * @returns One {@link LockFileEntry} per distinct `name@version`.
58
+ */
59
+ declare const parseNpmLockFile: (content: string) => LockFileEntry[];
60
+ /**
61
+ * Parses `pnpm-lock.yaml`. Regex-based; works for lockfile v6 through
62
+ * v9. v9 moves concrete resolved dependency versions out of `packages:`
63
+ * and into `snapshots:`; this parser reads both sections and unions
64
+ * their dep-maps onto the final entry.
65
+ * @param content Raw YAML text of the lockfile.
66
+ * @returns One {@link LockFileEntry} per distinct `name@version`.
67
+ */
68
+ declare const parsePnpmLockFile: (content: string) => LockFileEntry[];
69
+ /**
70
+ * Parses `yarn.lock` for Yarn Classic (v1) and Berry (v2+). Berry's
71
+ * XXH64 `checksum:` is not a cryptographic hash and is intentionally
72
+ * dropped; only v1's SRI `integrity:` flows through to
73
+ * {@link LockFileEntry.integrity}.
74
+ * @param content Raw text of the lockfile.
75
+ * @returns One {@link LockFileEntry} per distinct `name@version`.
76
+ */
77
+ declare const parseYarnLockFile: (content: string) => LockFileEntry[];
78
+ /**
79
+ * Parses `bun.lock` (Bun v1.1+, JSON-ish with trailing commas). The
80
+ * binary `bun.lockb` format is not supported.
81
+ *
82
+ * Attribution: format + tuple layout verified against lockparse
83
+ * (https://github.com/43081j/lockparse, MIT).
84
+ * @param content Raw text of the lockfile.
85
+ * @returns One {@link LockFileEntry} per distinct `name@version`.
86
+ */
87
+ declare const parseBunLockFile: (content: string) => LockFileEntry[];
88
+ /**
89
+ * Parses raw lockfile content of the given type. Returns an empty
90
+ * array if the content is malformed or doesn't contain any package
91
+ * entries.
92
+ * @param content Raw text of the lockfile.
93
+ * @param type Which parser to dispatch to.
94
+ * @returns One {@link LockFileEntry} per distinct `name@version`.
95
+ */
96
+ declare const parseLockFileContent: (content: string, type: LockFileType) => LockFileEntry[];
97
+ /**
98
+ * Walks up from `cwd`, locates the nearest supported lockfile, reads
99
+ * it, and returns the parsed entries alongside the lockfile type and
100
+ * absolute path.
101
+ * @param cwd Directory to start the search from. Defaults to
102
+ * `process.cwd()` (delegated to `findUp`).
103
+ * @returns The parsed result, keyed by the discovered lockfile path.
104
+ * @throws If no supported lockfile can be found above `cwd`.
105
+ */
106
+ declare const parseLockFile: (cwd?: URL | string) => Promise<LockFileParseResult>;
107
+ /**
108
+ * Synchronous counterpart to {@link parseLockFile}.
109
+ * @param cwd Directory to start the search from.
110
+ * @returns The parsed result, keyed by the discovered lockfile path.
111
+ * @throws If no supported lockfile can be found above `cwd`.
112
+ */
113
+ declare const parseLockFileSync: (cwd?: URL | string) => LockFileParseResult;
114
+ export { LockFileEntry, LockFileIntegrity, LockFileIntegrityAlgorithm, LockFileParseResult, LockFileType, decodeSriIntegrity, parseBunLockFile, parseLockFile, parseLockFileContent, parseLockFileSync, parseNpmLockFile, parsePnpmLockFile, parseYarnLockFile };
@@ -0,0 +1 @@
1
+ var A=Object.defineProperty;var F=(n,e)=>A(n,"name",{value:e,configurable:!0});import{createRequire as M}from"node:module";import{findUp as N,findUpSync as R}from"@visulima/fs";const P=M(import.meta.url),k=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,S=F(n=>{if(typeof k<"u"&&k.versions&&k.versions.node){const[e,t]=k.versions.node.split(".").map(Number);if(e>22||e===22&&t>=3||e===20&&t>=16)return k.getBuiltinModule(n)}return P(n)},"__cjs_getBuiltinModule"),{readFileSync:B}=S("node:fs"),{readFile:C}=S("node:fs/promises");var T=Object.defineProperty,l=F((n,e)=>T(n,"name",{value:e,configurable:!0}),"g");const U={sha256:"sha256",sha384:"sha384",sha512:"sha512"},I=1024,q=/^[A-Z0-9+/]+={0,2}$/i,Y=/.*node_modules\/((?:@[^/]+\/)?[^/]+)$/,h=/^['"]/,y=/['"]$/,z=/^[a-z][a-zA-Z0-9]*:\s*$/m,J=/resolution:\s*\{[^}]*integrity:\s*([^,}\s]+)/,Z=/^["']?((?:@[^/@"']+\/)?[^@"'\n]+)@[^"'\n]+["']?:?[\t\v\f\r \u00A0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]*\n((?:[\t ][^\n]*\n?)+)/gm,K=/^\s+version:?\s+"?([^"\n]+)"?/m,G=/^\s+integrity[\s:]+"?([^"\s]+)"?/m,x=l(n=>{if(n.length>I)return;const e=n.indexOf("-");if(e<=0)return;const t=U[n.slice(0,e).toLowerCase()];if(!t)return;const s=n.slice(e+1);if(q.test(s))try{const c=Buffer.from(s,"base64");return c.length===0?void 0:{algorithm:t,hex:c.toString("hex")}}catch{return}},"decodeSriIntegrity"),w=l((n,e,t)=>{const s=`${t.name}@${t.version}`;e.has(s)||(e.add(s),n.push(t))},"pushUniqueEntry"),m=l((n,e,t)=>{t&&Object.keys(t).length>0&&(n[e]={...t})},"copyDepMap"),g=l(n=>{if(!n)return;const e={};for(const[t,s]of Object.entries(n))e[t]=[s];return Object.keys(e).length>0?e:void 0},"liftDepMap"),H=l(n=>{const e=[],t=new Set;let s;try{s=JSON.parse(n)}catch{return e}if(!s.packages)return e;for(const[c,o]of Object.entries(s.packages)){if(!c||!o.version)continue;const p=Y.exec(c);if(!p?.[1])continue;const i=o.name??p[1];if(i.startsWith("."))continue;const r={name:i,version:o.version};if(o.integrity){const a=x(o.integrity);a&&(r.integrity=a)}m(r,"dependencies",g(o.dependencies)),m(r,"peerDependencies",g(o.peerDependencies)),m(r,"optionalDependencies",g(o.optionalDependencies)),w(e,t,r)}return e},"parseNpmLockFile"),L=l(n=>{let e=n.trim();e.startsWith("/")&&(e=e.slice(1)),e=e.replace(h,"").replace(y,"");const t=e.indexOf("(");t>0&&(e=e.slice(0,t));const s=e.lastIndexOf("@");if(s<=0)return;const c=e.slice(0,s),o=e.slice(s+1);if(!(!c||!o||o.startsWith("link:")||o.startsWith("workspace:")||o.startsWith("file:")))return{name:c,version:o}},"splitPnpmPackageKey"),$=l((n,e)=>{const t=new RegExp(String.raw`^${e}:\s*$`,"m").exec(n);if(!t)return;const s=t.index+t[0].length,c=z.exec(n.slice(s));return n.slice(s,c?s+c.index:n.length)},"sliceTopLevelSection"),Q=l(n=>{const e=new Map,t=$(n,"snapshots");if(!t)return e;const s=/^ {2}(['"]?[^\s:][^:\n]*?['"]?):\s*\n((?: {4}[^\n]*\n?)+)/gm;let c;for(;(c=s.exec(t)??void 0)!==void 0;){const o=L(c[1]);if(!o)continue;const p=`${o.name}@${o.version}`,i=c[2],r=e.get(p)??{};for(const a of["dependencies","peerDependencies","optionalDependencies"]){const d=v(i,a);if(!d)continue;const u=r[a]??{};for(const[f,E]of Object.entries(d)){const D=u[f]??[];for(const j of E)D.includes(j)||D.push(j);u[f]=D}r[a]=u}e.set(p,r)}return e},"parsePnpmSnapshotEdges"),V=l(n=>{const e=[],t=new Set,s=$(n,"packages");if(!s)return e;const c=Q(n),o=/^ {2}(['"]?[^\s:][^:\n]*?['"]?):\s*\n((?: {4}[^\n]*\n?)+)/gm;let p;for(;(p=o.exec(s)??void 0)!==void 0;){const i=L(p[1]);if(!i)continue;const r=p[2],a=J.exec(r),d={name:i.name,version:i.version};if(a?.[1]){const f=x(a[1]);f&&(d.integrity=f)}const u=c.get(`${i.name}@${i.version}`);m(d,"dependencies",u?.dependencies??v(r,"dependencies")),m(d,"peerDependencies",u?.peerDependencies??v(r,"peerDependencies")),m(d,"optionalDependencies",u?.optionalDependencies??v(r,"optionalDependencies")),w(e,t,d)}return e},"parsePnpmLockFile"),v=l((n,e)=>{const t=new RegExp(String.raw`^ {4}${e}:\s*\n((?: {6,}[^\n]*\n?)+)`,"m").exec(n);if(!t?.[1])return;const s={},c=/^ {6}([^\s:]+):\s*([^\n]+)/gm;let o;for(;(o=c.exec(t[1])??void 0)!==void 0;){const p=o[1].replace(h,"").replace(y,"");let i=o[2].trim();i=i.replace(h,"").replace(y,"");const r=i.indexOf("(");if(r>0&&(i=i.slice(0,r).trim()),!p||!i)continue;const a=s[p]??[];a.includes(i)||a.push(i),s[p]=a}return Object.keys(s).length>0?s:void 0},"extractPnpmDependencyMap"),X=l(n=>{const e=[],t=new Set,s=Z;s.lastIndex=0;let c;for(;(c=s.exec(n)??void 0)!==void 0;){const o=c[1].replace(h,"").replace(y,"");if(!o)continue;const p=c[2],i=K.exec(p);if(!i?.[1])continue;const r={name:o,version:i[1].trim()},a=G.exec(p);if(a?.[1]){const d=x(a[1]);d&&(r.integrity=d)}m(r,"dependencies",b(p,"dependencies")),m(r,"peerDependencies",b(p,"peerDependencies")),m(r,"optionalDependencies",b(p,"optionalDependencies")),w(e,t,r)}return e},"parseYarnLockFile"),b=l((n,e)=>{const t=new RegExp(String.raw`^ {2}${e}:\s*\n((?: {4,}[^\n]*\n?)+)`,"m").exec(n);if(!t?.[1])return;const s={},c=/^ {4}(['"]?[^\s:'"]+['"]?)\s*(?::\s*)?['"]([^'"\n]+)['"]/gm;let o;for(;(o=c.exec(t[1])??void 0)!==void 0;){const p=o[1].replace(h,"").replace(y,""),i=o[2];if(p&&i){const r=s[p]??[];r.includes(i)||r.push(i),s[p]=r}}return Object.keys(s).length>0?s:void 0},"extractYarnDependencyMap"),ee=/,(?=\s*[}\]])/g,ne=l(n=>{const e=[],t=new Set;let s;try{s=JSON.parse(n.replaceAll(ee,""))}catch{return e}if(!s.packages)return e;for(const c of Object.values(s.packages)){const o=c[0];if(typeof o!="string")continue;const p=o.indexOf("@",1);if(p<=0)continue;const i=o.slice(0,p),r=o.slice(p+1);if(!i||!r||r.startsWith("workspace:")||r.startsWith("link:")||r.startsWith("file:"))continue;const a={name:i,version:r},d=c[3];if(typeof d=="string"&&d.length>0){const f=x(d);f&&(a.integrity=f)}const u=c[2];if(u&&typeof u=="object"&&!Array.isArray(u)){const f=u;m(a,"dependencies",g(f.dependencies)),m(a,"peerDependencies",g(f.peerDependencies)),m(a,"optionalDependencies",g(f.optionalDependencies))}w(e,t,a)}return e},"parseBunLockFile"),O=l(n=>{if(n.endsWith("pnpm-lock.yaml"))return"pnpm";if(n.endsWith("package-lock.json"))return"npm";if(n.endsWith("yarn.lock"))return"yarn";if(n.endsWith("bun.lock"))return"bun"},"inferLockFileType"),_=l((n,e)=>{switch(e){case"bun":return ne(n);case"npm":return H(n);case"pnpm":return V(n);case"yarn":return X(n);default:return[]}},"parseLockFileContent"),W=["pnpm-lock.yaml","package-lock.json","yarn.lock","bun.lock"],re=l(async n=>{const e=await N(W,{type:"file",...n&&{cwd:n}});if(!e)throw new Error("Could not find a supported lock file (pnpm-lock.yaml, package-lock.json, yarn.lock, bun.lock)");const t=O(e);if(!t)throw new Error(`Unsupported lock file: ${e}`);const s=await C(e,"utf8");return{entries:_(s,t),path:e,type:t}},"parseLockFile"),ce=l(n=>{const e=R(W,{type:"file",...n&&{cwd:n}});if(!e)throw new Error("Could not find a supported lock file (pnpm-lock.yaml, package-lock.json, yarn.lock, bun.lock)");const t=O(e);if(!t)throw new Error(`Unsupported lock file: ${e}`);return{entries:_(B(e,"utf8"),t),path:e,type:t}},"parseLockFileSync");export{x as decodeSriIntegrity,ne as parseBunLockFile,re as parseLockFile,_ as parseLockFileContent,ce as parseLockFileSync,H as parseNpmLockFile,V as parsePnpmLockFile,X as parseYarnLockFile};
@@ -1,25 +1,26 @@
1
- export type Strategy = "lerna" | "npm" | "pnpm" | "turbo" | "yarn";
2
- export interface RootMonorepo<T extends Strategy = Strategy> {
3
- path: string;
4
- strategy: T;
1
+ type Strategy = "lerna" | "npm" | "pnpm" | "turbo" | "yarn";
2
+ interface RootMonorepo<T extends Strategy = Strategy> {
3
+ path: string;
4
+ strategy: T;
5
5
  }
6
6
  /**
7
- * An asynchronous function to find the root directory path and strategy for a monorepo based on
8
- * the given current working directory (cwd).
9
- * @param cwd The current working directory. The type of `cwd` is part of an `Options` type, specifically `Options["cwd"]`.
10
- * Default is undefined.
11
- * @returns A `Promise` that resolves to the root directory path and strategy for the monorepo.
12
- * The type of the returned promise is `Promise&lt;RootMonorepo>`.
13
- * @throws An `Error` if no monorepo root can be found using lerna, yarn, pnpm, or npm as indicators.
14
- */
15
- export declare const findMonorepoRoot: (cwd?: URL | string) => Promise<RootMonorepo>;
7
+ * An asynchronous function to find the root directory path and strategy for a monorepo based on
8
+ * the given current working directory (cwd).
9
+ * @param cwd The current working directory. The type of `cwd` is part of an `Options` type, specifically `Options["cwd"]`.
10
+ * Default is undefined.
11
+ * @returns A `Promise` that resolves to the root directory path and strategy for the monorepo.
12
+ * The type of the returned promise is `Promise&lt;RootMonorepo>`.
13
+ * @throws An `Error` if no monorepo root can be found using lerna, yarn, pnpm, or npm as indicators.
14
+ */
15
+ declare const findMonorepoRoot: (cwd?: URL | string) => Promise<RootMonorepo>;
16
16
  /**
17
- * An function to find the root directory path and strategy for a monorepo based on
18
- * the given current working directory (cwd).
19
- * @param cwd The current working directory. The type of `cwd` is part of an `Options` type, specifically `Options["cwd"]`.
20
- * Default is undefined.
21
- * @returns A `Promise` that resolves to the root directory path and strategy for the monorepo.
22
- * The type of the returned promise is `Promise&lt;RootMonorepo>`.
23
- * @throws An `Error` if no monorepo root can be found using lerna, yarn, pnpm, or npm as indicators.
24
- */
25
- export declare const findMonorepoRootSync: (cwd?: URL | string) => RootMonorepo;
17
+ * An function to find the root directory path and strategy for a monorepo based on
18
+ * the given current working directory (cwd).
19
+ * @param cwd The current working directory. The type of `cwd` is part of an `Options` type, specifically `Options["cwd"]`.
20
+ * Default is undefined.
21
+ * @returns A `Promise` that resolves to the root directory path and strategy for the monorepo.
22
+ * The type of the returned promise is `Promise&lt;RootMonorepo>`.
23
+ * @throws An `Error` if no monorepo root can be found using lerna, yarn, pnpm, or npm as indicators.
24
+ */
25
+ declare const findMonorepoRootSync: (cwd?: URL | string) => RootMonorepo;
26
+ export { RootMonorepo, Strategy, findMonorepoRoot, findMonorepoRootSync };
package/dist/monorepo.js CHANGED
@@ -1 +1 @@
1
- var l=Object.defineProperty;var p=(r,e)=>l(r,"name",{value:e,configurable:!0});import{createRequire as y}from"node:module";import{findUp as j,readJson as w,findUpSync as b,readJsonSync as k}from"@visulima/fs";import{NotFoundError as u}from"@visulima/fs/error";import{dirname as d,join as a}from"@visulima/path";import{findPackageManager as _,findPackageManagerSync as M}from"./package-manager.js";const g=y(import.meta.url),i=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,h=p(r=>{if(typeof i<"u"&&i.versions&&i.versions.node){const[e,t]=i.versions.node.split(".").map(Number);if(e>22||e===22&&t>=3||e===20&&t>=16)return i.getBuiltinModule(r)}return g(r)},"__cjs_getBuiltinModule"),{existsSync:c,readFileSync:f}=h("node:fs");var S=Object.defineProperty,m=p((r,e)=>S(r,"name",{value:e,configurable:!0}),"i");const E=m(async r=>{const e=await j(["lerna.json","turbo.json"],{type:"file",...r&&{cwd:r}});if(e?.endsWith("lerna.json")){const o=await w(e);if(o.useWorkspaces||o.packages)return{path:d(e),strategy:"lerna"}}const t=e?.endsWith("turbo.json");try{const{packageManager:o,path:n}=await _(r);if(["npm","yarn"].includes(o)){const s=a(n,"package.json");if(c(s)&&f(a(n,"package.json"),"utf8").includes("workspaces"))return{path:n,strategy:t?"turbo":o}}else if(o==="pnpm"){const s=a(n,"pnpm-workspace.yaml");if(c(s))return{path:n,strategy:t?"turbo":"pnpm"}}}catch(o){if(!(o instanceof u))throw o}throw new Error(`No monorepo root could be found upwards from the directory ${r} using lerna, yarn, pnpm, or npm as indicators.`)},"findMonorepoRoot"),T=m(r=>{const e=b(["lerna.json","turbo.json"],{type:"file",...r&&{cwd:r}});if(e?.endsWith("lerna.json")){const o=k(e);if(o.useWorkspaces||o.packages)return{path:d(e),strategy:"lerna"}}const t=e?.endsWith("turbo.json");try{const{packageManager:o,path:n}=M(r);if(["npm","yarn"].includes(o)){const s=a(n,"package.json");if(c(s)&&f(a(n,"package.json"),"utf8").includes("workspaces"))return{path:n,strategy:t?"turbo":o}}else if(o==="pnpm"){const s=a(n,"pnpm-workspace.yaml");if(c(s))return{path:n,strategy:t?"turbo":"pnpm"}}}catch(o){if(!(o instanceof u))throw o}throw new Error(`No monorepo root could be found upwards from the directory ${r} using lerna, yarn, pnpm, or npm as indicators.`)},"findMonorepoRootSync");export{E as findMonorepoRoot,T as findMonorepoRootSync};
1
+ var l=Object.defineProperty;var p=(e,n)=>l(e,"name",{value:n,configurable:!0});import{createRequire as y}from"node:module";import{findUp as j,readJson as b,findUpSync as w,readJsonSync as k}from"@visulima/fs";import{NotFoundError as u}from"@visulima/fs/error";import{dirname as d,join as s}from"@visulima/path";import{findPackageManager as _,findPackageManagerSync as M}from"./package-manager.js";const g=y(import.meta.url),i=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,h=p(e=>{if(typeof i<"u"&&i.versions&&i.versions.node){const[n,t]=i.versions.node.split(".").map(Number);if(n>22||n===22&&t>=3||n===20&&t>=16)return i.getBuiltinModule(e)}return g(e)},"__cjs_getBuiltinModule"),{existsSync:c,readFileSync:f}=h("node:fs");var S=Object.defineProperty,m=p((e,n)=>S(e,"name",{value:n,configurable:!0}),"i");const E=m(async e=>{const n=await j(["lerna.json","turbo.json"],{type:"file",...e&&{cwd:e}});if(n?.endsWith("lerna.json")){const o=await b(n);if(o&&typeof o=="object"&&!Array.isArray(o)){const r=o;if(r.useWorkspaces||r.packages)return{path:d(n),strategy:"lerna"}}}const t=n?.endsWith("turbo.json");try{const{packageManager:o,path:r}=await _(e);if(["npm","yarn"].includes(o)){const a=s(r,"package.json");if(c(a)&&f(s(r,"package.json"),"utf8").includes("workspaces"))return{path:r,strategy:t?"turbo":o}}else if(o==="pnpm"){const a=s(r,"pnpm-workspace.yaml");if(c(a))return{path:r,strategy:t?"turbo":"pnpm"}}}catch(o){if(!(o instanceof u))throw o}throw new Error(`No monorepo root could be found upwards from the directory ${e} using lerna, yarn, pnpm, or npm as indicators.`)},"findMonorepoRoot"),T=m(e=>{const n=w(["lerna.json","turbo.json"],{type:"file",...e&&{cwd:e}});if(n?.endsWith("lerna.json")){const o=k(n);if(o.useWorkspaces||o.packages)return{path:d(n),strategy:"lerna"}}const t=n?.endsWith("turbo.json");try{const{packageManager:o,path:r}=M(e);if(["npm","yarn"].includes(o)){const a=s(r,"package.json");if(c(a)&&f(s(r,"package.json"),"utf8").includes("workspaces"))return{path:r,strategy:t?"turbo":o}}else if(o==="pnpm"){const a=s(r,"pnpm-workspace.yaml");if(c(a))return{path:r,strategy:t?"turbo":"pnpm"}}}catch(o){if(!(o instanceof u))throw o}throw new Error(`No monorepo root could be found upwards from the directory ${e} using lerna, yarn, pnpm, or npm as indicators.`)},"findMonorepoRootSync");export{E as findMonorepoRoot,T as findMonorepoRootSync};