@visulima/package 4.0.1 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +29 -0
- package/LICENSE.md +1 -130
- package/README.md +98 -4
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/monorepo.d.ts +2 -1
- package/dist/monorepo.js +1 -1
- package/dist/package-json.d.ts +2 -2
- package/dist/package-json.js +2 -2
- package/dist/package-manager.d.ts +2 -1
- package/dist/package-manager.js +5 -5
- package/dist/package.js +1 -1
- package/dist/packem_shared/package-json-CiMqtMwD.d.ts +232 -0
- package/dist/pnpm.d.ts +3 -2
- package/package.json +13 -7
- package/dist/packem_shared/json-value.d-DU4PzU4Z.d.ts +0 -33
- package/dist/packem_shared/package-json-k3TJ_oy7.d.ts +0 -2751
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,32 @@
|
|
|
1
|
+
## @visulima/package [4.1.0](https://github.com/visulima/visulima/compare/@visulima/package@4.0.2...@visulima/package@4.1.0) (2025-10-15)
|
|
2
|
+
|
|
3
|
+
### Features
|
|
4
|
+
|
|
5
|
+
* Support pnpm package yaml and json5 ([#531](https://github.com/visulima/visulima/issues/531)) ([3b6591c](https://github.com/visulima/visulima/commit/3b6591c400be2ee435929f34f2560dac06b7cd3d))
|
|
6
|
+
|
|
7
|
+
### Bug Fixes
|
|
8
|
+
|
|
9
|
+
* update @visulima/packem to 2.0.0-alpha.30 across multiple packages for improved compatibility ([27b346e](https://github.com/visulima/visulima/commit/27b346eaa1c0fb0e420d9a9824482028307f4249))
|
|
10
|
+
* update LICENSE.md and package.json dependencies ([cea0533](https://github.com/visulima/visulima/commit/cea0533dda1161c2280a823d2ecaefb814818535))
|
|
11
|
+
|
|
12
|
+
### Miscellaneous Chores
|
|
13
|
+
|
|
14
|
+
* update linting commands and dependencies in package.json ([6a479b0](https://github.com/visulima/visulima/commit/6a479b04251d2bdde39ace13548b067b86d00c86))
|
|
15
|
+
* update package dependencies across multiple packages for improved compatibility and performance ([9567591](https://github.com/visulima/visulima/commit/9567591c415da3002f3a4fe08f8caf7ce01ca5f7))
|
|
16
|
+
* update type-fest dependency and adjust package configurations ([e8a1d89](https://github.com/visulima/visulima/commit/e8a1d8969f5e15f9323b1ca2a4bcff1beb8446fb))
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
### Dependencies
|
|
20
|
+
|
|
21
|
+
* **@visulima/fs:** upgraded to 4.0.0
|
|
22
|
+
* **@visulima/path:** upgraded to 2.0.0
|
|
23
|
+
|
|
24
|
+
## @visulima/package [4.0.2](https://github.com/visulima/visulima/compare/@visulima/package@4.0.1...@visulima/package@4.0.2) (2025-10-02)
|
|
25
|
+
|
|
26
|
+
### Bug Fixes
|
|
27
|
+
|
|
28
|
+
* enhance package JSON parsing with error handling for resolveCatalogs option ([c921937](https://github.com/visulima/visulima/commit/c9219378c6f561d35bb2dc9d6754356b4e46de77))
|
|
29
|
+
|
|
1
30
|
## @visulima/package [4.0.1](https://github.com/visulima/visulima/compare/@visulima/package@4.0.0...@visulima/package@4.0.1) (2025-10-02)
|
|
2
31
|
|
|
3
32
|
### Bug Fixes
|
package/LICENSE.md
CHANGED
|
@@ -48,7 +48,7 @@ Repository: sindresorhus/dot-prop
|
|
|
48
48
|
|
|
49
49
|
# Licenses of bundled types
|
|
50
50
|
The published @visulima/package artifact additionally contains code with the following licenses:
|
|
51
|
-
MIT
|
|
51
|
+
MIT
|
|
52
52
|
|
|
53
53
|
# Bundled types:
|
|
54
54
|
## @inquirer/core
|
|
@@ -109,133 +109,4 @@ Repository: https://github.com/SBoudrias/Inquirer.js.git
|
|
|
109
109
|
> FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
110
110
|
> OTHER DEALINGS IN THE SOFTWARE.
|
|
111
111
|
|
|
112
|
-
---------------------------------------
|
|
113
|
-
|
|
114
|
-
## type-fest
|
|
115
|
-
License: (MIT OR CC0-1.0)
|
|
116
|
-
By: Sindre Sorhus
|
|
117
|
-
Repository: sindresorhus/type-fest
|
|
118
|
-
|
|
119
|
-
> Creative Commons Legal Code
|
|
120
|
-
>
|
|
121
|
-
> CC0 1.0 Universal
|
|
122
|
-
>
|
|
123
|
-
> CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
|
|
124
|
-
> LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
|
|
125
|
-
> ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
|
|
126
|
-
> INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
|
|
127
|
-
> REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
|
|
128
|
-
> PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
|
|
129
|
-
> THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
|
|
130
|
-
> HEREUNDER.
|
|
131
|
-
>
|
|
132
|
-
> Statement of Purpose
|
|
133
|
-
>
|
|
134
|
-
> The laws of most jurisdictions throughout the world automatically confer
|
|
135
|
-
> exclusive Copyright and Related Rights (defined below) upon the creator
|
|
136
|
-
> and subsequent owner(s) (each and all, an "owner") of an original work of
|
|
137
|
-
> authorship and/or a database (each, a "Work").
|
|
138
|
-
>
|
|
139
|
-
> Certain owners wish to permanently relinquish those rights to a Work for
|
|
140
|
-
> the purpose of contributing to a commons of creative, cultural and
|
|
141
|
-
> scientific works ("Commons") that the public can reliably and without fear
|
|
142
|
-
> of later claims of infringement build upon, modify, incorporate in other
|
|
143
|
-
> works, reuse and redistribute as freely as possible in any form whatsoever
|
|
144
|
-
> and for any purposes, including without limitation commercial purposes.
|
|
145
|
-
> These owners may contribute to the Commons to promote the ideal of a free
|
|
146
|
-
> culture and the further production of creative, cultural and scientific
|
|
147
|
-
> works, or to gain reputation or greater distribution for their Work in
|
|
148
|
-
> part through the use and efforts of others.
|
|
149
|
-
>
|
|
150
|
-
> For these and/or other purposes and motivations, and without any
|
|
151
|
-
> expectation of additional consideration or compensation, the person
|
|
152
|
-
> associating CC0 with a Work (the "Affirmer"), to the extent that he or she
|
|
153
|
-
> is an owner of Copyright and Related Rights in the Work, voluntarily
|
|
154
|
-
> elects to apply CC0 to the Work and publicly distribute the Work under its
|
|
155
|
-
> terms, with knowledge of his or her Copyright and Related Rights in the
|
|
156
|
-
> Work and the meaning and intended legal effect of CC0 on those rights.
|
|
157
|
-
>
|
|
158
|
-
> 1. Copyright and Related Rights. A Work made available under CC0 may be
|
|
159
|
-
> protected by copyright and related or neighboring rights ("Copyright and
|
|
160
|
-
> Related Rights"). Copyright and Related Rights include, but are not
|
|
161
|
-
> limited to, the following:
|
|
162
|
-
>
|
|
163
|
-
> i. the right to reproduce, adapt, distribute, perform, display,
|
|
164
|
-
> communicate, and translate a Work;
|
|
165
|
-
> ii. moral rights retained by the original author(s) and/or performer(s);
|
|
166
|
-
> iii. publicity and privacy rights pertaining to a person's image or
|
|
167
|
-
> likeness depicted in a Work;
|
|
168
|
-
> iv. rights protecting against unfair competition in regards to a Work,
|
|
169
|
-
> subject to the limitations in paragraph 4(a), below;
|
|
170
|
-
> v. rights protecting the extraction, dissemination, use and reuse of data
|
|
171
|
-
> in a Work;
|
|
172
|
-
> vi. database rights (such as those arising under Directive 96/9/EC of the
|
|
173
|
-
> European Parliament and of the Council of 11 March 1996 on the legal
|
|
174
|
-
> protection of databases, and under any national implementation
|
|
175
|
-
> thereof, including any amended or successor version of such
|
|
176
|
-
> directive); and
|
|
177
|
-
> vii. other similar, equivalent or corresponding rights throughout the
|
|
178
|
-
> world based on applicable law or treaty, and any national
|
|
179
|
-
> implementations thereof.
|
|
180
|
-
>
|
|
181
|
-
> 2. Waiver. To the greatest extent permitted by, but not in contravention
|
|
182
|
-
> of, applicable law, Affirmer hereby overtly, fully, permanently,
|
|
183
|
-
> irrevocably and unconditionally waives, abandons, and surrenders all of
|
|
184
|
-
> Affirmer's Copyright and Related Rights and associated claims and causes
|
|
185
|
-
> of action, whether now known or unknown (including existing as well as
|
|
186
|
-
> future claims and causes of action), in the Work (i) in all territories
|
|
187
|
-
> worldwide, (ii) for the maximum duration provided by applicable law or
|
|
188
|
-
> treaty (including future time extensions), (iii) in any current or future
|
|
189
|
-
> medium and for any number of copies, and (iv) for any purpose whatsoever,
|
|
190
|
-
> including without limitation commercial, advertising or promotional
|
|
191
|
-
> purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
|
|
192
|
-
> member of the public at large and to the detriment of Affirmer's heirs and
|
|
193
|
-
> successors, fully intending that such Waiver shall not be subject to
|
|
194
|
-
> revocation, rescission, cancellation, termination, or any other legal or
|
|
195
|
-
> equitable action to disrupt the quiet enjoyment of the Work by the public
|
|
196
|
-
> as contemplated by Affirmer's express Statement of Purpose.
|
|
197
|
-
>
|
|
198
|
-
> 3. Public License Fallback. Should any part of the Waiver for any reason
|
|
199
|
-
> be judged legally invalid or ineffective under applicable law, then the
|
|
200
|
-
> Waiver shall be preserved to the maximum extent permitted taking into
|
|
201
|
-
> account Affirmer's express Statement of Purpose. In addition, to the
|
|
202
|
-
> extent the Waiver is so judged Affirmer hereby grants to each affected
|
|
203
|
-
> person a royalty-free, non transferable, non sublicensable, non exclusive,
|
|
204
|
-
> irrevocable and unconditional license to exercise Affirmer's Copyright and
|
|
205
|
-
> Related Rights in the Work (i) in all territories worldwide, (ii) for the
|
|
206
|
-
> maximum duration provided by applicable law or treaty (including future
|
|
207
|
-
> time extensions), (iii) in any current or future medium and for any number
|
|
208
|
-
> of copies, and (iv) for any purpose whatsoever, including without
|
|
209
|
-
> limitation commercial, advertising or promotional purposes (the
|
|
210
|
-
> "License"). The License shall be deemed effective as of the date CC0 was
|
|
211
|
-
> applied by Affirmer to the Work. Should any part of the License for any
|
|
212
|
-
> reason be judged legally invalid or ineffective under applicable law, such
|
|
213
|
-
> partial invalidity or ineffectiveness shall not invalidate the remainder
|
|
214
|
-
> of the License, and in such case Affirmer hereby affirms that he or she
|
|
215
|
-
> will not (i) exercise any of his or her remaining Copyright and Related
|
|
216
|
-
> Rights in the Work or (ii) assert any associated claims and causes of
|
|
217
|
-
> action with respect to the Work, in either case contrary to Affirmer's
|
|
218
|
-
> express Statement of Purpose.
|
|
219
|
-
>
|
|
220
|
-
> 4. Limitations and Disclaimers.
|
|
221
|
-
>
|
|
222
|
-
> a. No trademark or patent rights held by Affirmer are waived, abandoned,
|
|
223
|
-
> surrendered, licensed or otherwise affected by this document.
|
|
224
|
-
> b. Affirmer offers the Work as-is and makes no representations or
|
|
225
|
-
> warranties of any kind concerning the Work, express, implied,
|
|
226
|
-
> statutory or otherwise, including without limitation warranties of
|
|
227
|
-
> title, merchantability, fitness for a particular purpose, non
|
|
228
|
-
> infringement, or the absence of latent or other defects, accuracy, or
|
|
229
|
-
> the present or absence of errors, whether or not discoverable, all to
|
|
230
|
-
> the greatest extent permissible under applicable law.
|
|
231
|
-
> c. Affirmer disclaims responsibility for clearing rights of other persons
|
|
232
|
-
> that may apply to the Work or any use thereof, including without
|
|
233
|
-
> limitation any person's Copyright and Related Rights in the Work.
|
|
234
|
-
> Further, Affirmer disclaims responsibility for obtaining any necessary
|
|
235
|
-
> consents, permissions or other rights required for any use of the
|
|
236
|
-
> Work.
|
|
237
|
-
> d. Affirmer understands and acknowledges that Creative Commons is not a
|
|
238
|
-
> party to this document and has no duty or obligation with respect to
|
|
239
|
-
> this CC0 or use of the Work.
|
|
240
|
-
|
|
241
112
|
<!-- /TYPE_DEPENDENCIES -->
|
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<div align="center">
|
|
2
2
|
<h3>Visulima package</h3>
|
|
3
3
|
<p>
|
|
4
|
-
A comprehensive package management utility that helps you find root directories, monorepos, package managers, and parse package.json files with advanced features like catalog resolution.
|
|
4
|
+
A comprehensive package management utility that helps you find root directories, monorepos, package managers, and parse package.json, package.yaml, and package.json5 files with advanced features like catalog resolution and caching.
|
|
5
5
|
|
|
6
6
|
Built on top of
|
|
7
7
|
|
|
@@ -85,15 +85,41 @@ const result = await findPackageRoot();
|
|
|
85
85
|
|
|
86
86
|
#### findPackageJson
|
|
87
87
|
|
|
88
|
-
Finds and parses a package.json file, searching parent directories if needed.
|
|
88
|
+
Finds and parses a package.json, package.yaml, or package.json5 file, searching parent directories if needed.
|
|
89
89
|
|
|
90
90
|
```typescript
|
|
91
91
|
import { findPackageJson } from "@visulima/package";
|
|
92
92
|
|
|
93
|
+
// Basic usage - searches for package.json, package.yaml, and package.json5
|
|
93
94
|
const result = await findPackageJson();
|
|
94
95
|
// => { packageJson: { name: 'my-package', ... }, path: '/path/to/package.json' }
|
|
96
|
+
|
|
97
|
+
// With options to enable/disable specific formats and features
|
|
98
|
+
const result = await findPackageJson("/path/to/project", {
|
|
99
|
+
yaml: true, // Enable package.yaml support (default: true)
|
|
100
|
+
json5: true, // Enable package.json5 support (default: true)
|
|
101
|
+
resolveCatalogs: true, // Resolve pnpm catalog references (default: false)
|
|
102
|
+
cache: true, // Enable caching of parsed results (default: false)
|
|
103
|
+
});
|
|
95
104
|
```
|
|
96
105
|
|
|
106
|
+
**File Search Priority**: The function searches for files in the following order:
|
|
107
|
+
|
|
108
|
+
1. `package.json` (highest priority)
|
|
109
|
+
2. `package.yaml`
|
|
110
|
+
3. `package.json5` (lowest priority)
|
|
111
|
+
|
|
112
|
+
**Supported Formats**:
|
|
113
|
+
|
|
114
|
+
- **package.json**: Standard JSON format
|
|
115
|
+
- **package.yaml**: YAML format (introduced in pnpm/pnpm#1799)
|
|
116
|
+
- **package.json5**: JSON5 format with comments and trailing commas support
|
|
117
|
+
|
|
118
|
+
**Additional Options**:
|
|
119
|
+
|
|
120
|
+
- **resolveCatalogs**: Resolve pnpm catalog references to actual versions (requires pnpm workspace)
|
|
121
|
+
- **cache**: Cache parsed results to improve performance on repeated calls
|
|
122
|
+
|
|
97
123
|
### Package Manager Detection
|
|
98
124
|
|
|
99
125
|
#### findPackageManager
|
|
@@ -133,27 +159,95 @@ const version = await getPackageManagerVersion("pnpm");
|
|
|
133
159
|
|
|
134
160
|
#### parsePackageJson
|
|
135
161
|
|
|
136
|
-
Parses and normalizes package.json data with optional catalog resolution support.
|
|
162
|
+
Parses and normalizes package.json, package.yaml, or package.json5 data with optional catalog resolution support.
|
|
137
163
|
|
|
138
164
|
```typescript
|
|
139
165
|
import { parsePackageJson } from "@visulima/package";
|
|
140
166
|
|
|
141
|
-
// Basic parsing
|
|
167
|
+
// Basic parsing - automatically detects format by file extension
|
|
142
168
|
const packageJson = await parsePackageJson("./package.json");
|
|
169
|
+
const packageYaml = await parsePackageJson("./package.yaml");
|
|
170
|
+
const packageJson5 = await parsePackageJson("./package.json5");
|
|
143
171
|
|
|
144
172
|
// With catalog resolution (pnpm workspaces only)
|
|
145
173
|
const packageJson = await parsePackageJson("./package.json", {
|
|
146
174
|
resolveCatalogs: true,
|
|
147
175
|
});
|
|
148
176
|
|
|
177
|
+
// With format control and caching options
|
|
178
|
+
const packageJson = await parsePackageJson("./package.yaml", {
|
|
179
|
+
yaml: true, // Enable package.yaml support (default: true)
|
|
180
|
+
json5: false, // Disable package.json5 support (default: true)
|
|
181
|
+
resolveCatalogs: true, // Resolve pnpm catalog references (default: false)
|
|
182
|
+
cache: true, // Enable caching for file-based parsing (default: false)
|
|
183
|
+
});
|
|
184
|
+
|
|
149
185
|
// Synchronous version
|
|
150
186
|
import { parsePackageJsonSync } from "@visulima/package";
|
|
151
187
|
|
|
152
188
|
const packageJson = parsePackageJsonSync("./package.json", {
|
|
153
189
|
resolveCatalogs: true,
|
|
190
|
+
cache: true, // Enable caching for file-based parsing (default: false)
|
|
154
191
|
});
|
|
155
192
|
```
|
|
156
193
|
|
|
194
|
+
**Supported File Formats**:
|
|
195
|
+
|
|
196
|
+
- **package.json**: Standard JSON format
|
|
197
|
+
- **package.yaml**: YAML format with support for comments and more readable syntax
|
|
198
|
+
- **package.json5**: JSON5 format with support for comments, trailing commas, and unquoted keys
|
|
199
|
+
|
|
200
|
+
**Format Detection**: The function automatically detects the file format based on the file extension:
|
|
201
|
+
|
|
202
|
+
- `.json` → JSON parsing
|
|
203
|
+
- `.yaml` or `.yml` → YAML parsing
|
|
204
|
+
- `.json5` → JSON5 parsing
|
|
205
|
+
|
|
206
|
+
**Caching**: When `cache: true` is set, the function uses a global cache to store parsed results for file-based inputs only (not for object or JSON string inputs). This can improve performance when parsing the same file multiple times.
|
|
207
|
+
|
|
208
|
+
```typescript
|
|
209
|
+
// File-based caching with global cache
|
|
210
|
+
const result1 = await parsePackageJson("./package.json", { cache: true }); // Parses and caches
|
|
211
|
+
const result2 = await parsePackageJson("./package.json", { cache: true }); // Returns cached result
|
|
212
|
+
|
|
213
|
+
// Custom cache instance
|
|
214
|
+
const myCache = new Map();
|
|
215
|
+
const result3 = await parsePackageJson("./package.json", { cache: myCache }); // Uses custom cache
|
|
216
|
+
|
|
217
|
+
// Objects and strings are never cached
|
|
218
|
+
const result4 = await parsePackageJson({ name: "test" }, { cache: true }); // Always parsed fresh
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
**Example File Formats**:
|
|
222
|
+
|
|
223
|
+
```yaml
|
|
224
|
+
# package.yaml
|
|
225
|
+
name: my-package
|
|
226
|
+
version: 1.0.0
|
|
227
|
+
dependencies:
|
|
228
|
+
react: ^18.0.0
|
|
229
|
+
typescript: ^5.0.0
|
|
230
|
+
scripts:
|
|
231
|
+
build: "tsc"
|
|
232
|
+
test: "vitest"
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
```json5
|
|
236
|
+
// package.json5
|
|
237
|
+
{
|
|
238
|
+
name: "my-package",
|
|
239
|
+
version: "1.0.0",
|
|
240
|
+
dependencies: {
|
|
241
|
+
react: "^18.0.0",
|
|
242
|
+
typescript: "^5.0.0",
|
|
243
|
+
},
|
|
244
|
+
scripts: {
|
|
245
|
+
build: "tsc",
|
|
246
|
+
test: "vitest",
|
|
247
|
+
},
|
|
248
|
+
}
|
|
249
|
+
```
|
|
250
|
+
|
|
157
251
|
**Catalog Resolution**: When `resolveCatalogs: true` is set, the function will:
|
|
158
252
|
|
|
159
253
|
1. Search for `pnpm-workspace.yaml` in parent directories
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export { PackageNotFoundError } from './error.js';
|
|
2
2
|
export { RootMonorepo, Strategy, findMonorepoRoot, findMonorepoRootSync } from './monorepo.js';
|
|
3
3
|
export { findPackageRoot, findPackageRootSync } from './package.js';
|
|
4
|
-
export { E as EnsurePackagesOptions, F as FindPackageJsonCache,
|
|
4
|
+
export { E as EnsurePackagesOptions, F as FindPackageJsonCache, i as NormalizedPackageJson, N as NormalizedReadResult, P as PackageJson, e as ensurePackages, f as findPackageJson, a as findPackageJsonSync, g as getPackageJsonProperty, h as hasPackageJsonAnyDependency, b as hasPackageJsonProperty, p as parsePackageJson, c as parsePackageJsonSync, w as writePackageJson, d as writePackageJsonSync } from './packem_shared/package-json-CiMqtMwD.js';
|
|
5
5
|
export { PackageManager, PackageManagerResult, findLockFile, findLockFileSync, findPackageManager, findPackageManagerSync, generateMissingPackagesInstallMessage, getPackageManagerVersion, identifyInitiatingPackageManager } from './package-manager.js';
|
|
6
6
|
export { PnpmCatalog, PnpmCatalogs, isPackageInWorkspace, readPnpmCatalogs, readPnpmCatalogsSync, resolveCatalogReference, resolveCatalogReferences, resolveDependenciesCatalogReferences } from './pnpm.js';
|
|
7
7
|
import '@visulima/fs';
|
|
8
|
-
import '
|
|
8
|
+
import 'type-fest';
|
|
9
9
|
import '@antfu/install-pkg';
|
|
10
10
|
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
|
|
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};
|
package/dist/monorepo.d.ts
CHANGED
|
@@ -6,4 +6,5 @@ interface RootMonorepo<T extends Strategy = Strategy> {
|
|
|
6
6
|
declare const findMonorepoRoot: (cwd?: URL | string) => Promise<RootMonorepo>;
|
|
7
7
|
declare const findMonorepoRootSync: (cwd?: URL | string) => RootMonorepo;
|
|
8
8
|
|
|
9
|
-
export {
|
|
9
|
+
export { findMonorepoRoot, findMonorepoRootSync };
|
|
10
|
+
export type { RootMonorepo, Strategy };
|
package/dist/monorepo.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
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};
|
package/dist/package-json.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import '@visulima/fs';
|
|
2
|
-
import '
|
|
3
|
-
export { F as FindPackageJsonCache, N as NormalizedReadResult, e as ensurePackages, f as findPackageJson, a as findPackageJsonSync, g as getPackageJsonProperty, h as hasPackageJsonAnyDependency, b as hasPackageJsonProperty, p as parsePackageJson,
|
|
2
|
+
import 'type-fest';
|
|
3
|
+
export { F as FindPackageJsonCache, N as NormalizedReadResult, e as ensurePackages, f as findPackageJson, a as findPackageJsonSync, g as getPackageJsonProperty, h as hasPackageJsonAnyDependency, b as hasPackageJsonProperty, p as parsePackageJson, c as parsePackageJsonSync, w as writePackageJson, d as writePackageJsonSync } from './packem_shared/package-json-CiMqtMwD.js';
|
|
4
4
|
import '@antfu/install-pkg';
|
|
5
5
|
import 'normalize-package-data';
|
package/dist/package-json.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var
|
|
1
|
+
var q=Object.defineProperty;var f=(e,n)=>q(e,"name",{value:n,configurable:!0});import{createRequire as B}from"node:module";import{installPackage as V}from"@antfu/install-pkg";import G from"@inquirer/confirm";import{readJsonSync as U,readFileSync as X,findUp as H,findUpSync as L,writeJson as Q,writeJsonSync as Z,readJson as ee,readFile as ne}from"@visulima/fs";import{NotFoundError as A}from"@visulima/fs/error";import{parseJson as S,toPath as v}from"@visulima/fs/utils";import{readYamlSync as te,readYaml as re}from"@visulima/fs/yaml";import{join as N}from"@visulima/path";import{readPnpmCatalogsSync as T,resolveCatalogReferences as P,readPnpmCatalogs as _}from"./pnpm.js";const j=B(import.meta.url),y=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,K=f(e=>{if(typeof y<"u"&&y.versions&&y.versions.node){const[n,r]=y.versions.node.split(".").map(Number);if(n>22||n===22&&r>=3||n===20&&r>=16)return y.getBuiltinModule(e)}return j(e)},"__cjs_getBuiltinModule"),{existsSync:J}=K("node:fs"),I=j("json5"),oe=j("normalize-package-data");var se=Object.defineProperty,l=f((e,n)=>se(e,"name",{value:n,configurable:!0}),"f");const h=l(e=>{const n=typeof e;return e!==null&&(n==="object"||n==="function")},"isObject"),ae=l(e=>{if(!h(e))return!1;for(const n in e)if(Object.hasOwn(e,n))return!1;return!0},"isEmptyObject"),F=new Set(["__proto__","prototype","constructor"]),D=1e6,ie=l(e=>e>="0"&&e<="9","isDigit");function m(e){if(e==="0")return!0;if(/^[1-9]\d*$/.test(e)){const n=Number.parseInt(e,10);return n<=Number.MAX_SAFE_INTEGER&&n<=D}return!1}f(m,"p");l(m,"shouldCoerceToNumber");function b(e,n){return F.has(e)?!1:(e&&m(e)?n.push(Number.parseInt(e,10)):n.push(e),!0)}f(b,"y");l(b,"processSegment");function C(e){if(typeof e!="string")throw new TypeError(`Expected a string, got ${typeof e}`);const n=[];let r="",t="start",o=!1,s=0;for(const a of e){if(s++,o){r+=a,o=!1;continue}if(a==="\\"){if(t==="index")throw new Error(`Invalid character '${a}' in an index at position ${s}`);if(t==="indexEnd")throw new Error(`Invalid character '${a}' after an index at position ${s}`);o=!0,t=t==="start"?"property":t;continue}switch(a){case".":{if(t==="index")throw new Error(`Invalid character '${a}' in an index at position ${s}`);if(t==="indexEnd"){t="property";break}if(!b(r,n))return[];r="",t="property";break}case"[":{if(t==="index")throw new Error(`Invalid character '${a}' in an index at position ${s}`);if(t==="indexEnd"){t="index";break}if(t==="property"||t==="start"){if((r||t==="property")&&!b(r,n))return[];r=""}t="index";break}case"]":{if(t==="index"){if(r==="")r=(n.pop()||"")+"[]",t="property";else{const i=Number.parseInt(r,10);!Number.isNaN(i)&&Number.isFinite(i)&&i>=0&&i<=Number.MAX_SAFE_INTEGER&&i<=D&&r===String(i)?n.push(i):n.push(r),r="",t="indexEnd"}break}if(t==="indexEnd")throw new Error(`Invalid character '${a}' after an index at position ${s}`);r+=a;break}default:{if(t==="index"&&!ie(a))throw new Error(`Invalid character '${a}' in an index at position ${s}`);if(t==="indexEnd")throw new Error(`Invalid character '${a}' after an index at position ${s}`);t==="start"&&(t="property"),r+=a}}}switch(o&&(r+="\\"),t){case"property":{if(!b(r,n))return[];break}case"index":throw new Error("Index was not closed");case"start":{n.push("");break}}return n}f(C,"parsePath");l(C,"parsePath");function w(e){if(typeof e=="string")return C(e);if(Array.isArray(e)){const n=[];for(const[r,t]of e.entries()){if(typeof t!="string"&&typeof t!="number")throw new TypeError(`Expected a string or number for path segment at index ${r}, got ${typeof t}`);if(typeof t=="number"&&!Number.isFinite(t))throw new TypeError(`Path segment at index ${r} must be a finite number, got ${t}`);if(F.has(t))return[];typeof t=="string"&&m(t)?n.push(Number.parseInt(t,10)):n.push(t)}return n}return[]}f(w,"d");l(w,"normalizePath");function d(e,n,r){if(!h(e)||typeof n!="string"&&!Array.isArray(n))return r===void 0?e:r;const t=w(n);if(t.length===0)return r;for(let o=0;o<t.length;o++){const s=t[o];if(e=e[s],e==null){if(o!==t.length-1)return r;break}}return e===void 0?r:e}f(d,"getProperty");l(d,"getProperty");function O(e,n,r){if(!h(e)||typeof n!="string"&&!Array.isArray(n))return e;const t=e,o=w(n);if(o.length===0)return e;for(let s=0;s<o.length;s++){const a=o[s];if(s===o.length-1)e[a]=r;else if(!h(e[a])){const i=typeof o[s+1]=="number";e[a]=i?[]:{}}e=e[a]}return t}f(O,"setProperty");l(O,"setProperty");function ce(e,n){if(!h(e)||typeof n!="string"&&!Array.isArray(n))return!1;const r=w(n);if(r.length===0)return!1;for(let t=0;t<r.length;t++){const o=r[t];if(t===r.length-1)return Object.hasOwn(e,o)?(delete e[o],!0):!1;if(e=e[o],!h(e))return!1}}f(ce,"deleteProperty");l(ce,"deleteProperty");function g(e,n){if(!h(e)||typeof n!="string"&&!Array.isArray(n))return!1;const r=w(n);if(r.length===0)return!1;for(const t of r){if(!h(e)||!(t in e))return!1;e=e[t]}return!0}f(g,"hasProperty");l(g,"hasProperty");function $(e){if(typeof e!="string")throw new TypeError(`Expected a string, got ${typeof e}`);return e.replaceAll(/[\\.[]/g,String.raw`\$&`)}f($,"escapePath");l($,"escapePath");function W(e){const n=Object.entries(e);return Array.isArray(e)?n.map(([r,t])=>[m(r)?Number.parseInt(r,10):r,t]):n}f(W,"m$1");l(W,"normalizeEntries");function M(e,n={}){if(!Array.isArray(e))throw new TypeError(`Expected an array, got ${typeof e}`);const{preferDotForIndices:r=!1}=n,t=[];for(const[o,s]of e.entries()){if(typeof s!="string"&&typeof s!="number")throw new TypeError(`Expected a string or number for path segment at index ${o}, got ${typeof s}`);if(typeof s=="number")if(!Number.isInteger(s)||s<0){const a=$(String(s));t.push(o===0?a:`.${a}`)}else r&&o>0?t.push(`.${s}`):t.push(`[${s}]`);else if(typeof s=="string")if(s==="")o===0||t.push(".");else if(m(s)){const a=Number.parseInt(s,10);r&&o>0?t.push(`.${a}`):t.push(`[${a}]`)}else{const a=$(s);t.push(o===0?a:`.${a}`)}}return t.join("")}f(M,"stringifyPath");l(M,"stringifyPath");function*x(e,n=[],r=new Set){if(!h(e)||ae(e)){n.length>0&&(yield M(n));return}if(!r.has(e)){r.add(e);for(const[t,o]of W(e))n.push(t),yield*x(o,n,r),n.pop();r.delete(e)}}f(x,"x");l(x,"deepKeysIterator");function fe(e){return[...x(e)]}f(fe,"deepKeys");l(fe,"deepKeys");function pe(e){const n={};if(!h(e))return n;for(const[r,t]of Object.entries(e))O(n,r,t);return n}f(pe,"unflatten");l(pe,"unflatten");const le=typeof process.stdout<"u"&&!process.versions.deno&&!globalThis.window;var ue=Object.defineProperty,p=f((e,n)=>ue(e,"name",{value:n,configurable:!0}),"l");const k=new Map,R=new Map;class he extends Error{static{f(this,"F")}static{p(this,"PackageJsonValidationError")}constructor(n){super(`The following warnings were encountered while normalizing package data:
|
|
2
2
|
- ${n.join(`
|
|
3
|
-
- `)}`),this.name="PackageJsonValidationError"}}const
|
|
3
|
+
- `)}`),this.name="PackageJsonValidationError"}}const E=p((e,n,r=[])=>{const t=[];if(oe(e,o=>{t.push(o)},n),n&&t.length>0){const o=t.filter(s=>!r.some(a=>a instanceof RegExp?a.test(s):a===s));if(o.length>0)throw new he(o)}return e},"normalizeInput"),de=p(async e=>await re(e),"parseYamlFile"),ge=p(e=>te(e),"parseYamlFileSync"),ye=p(async e=>{const n=await ne(e);return I.parse(n)},"parseJson5File"),me=p(e=>{const n=X(e);return I.parse(n)},"parseJson5FileSync"),z=p(async(e,n)=>n?.yaml!==!1&&(e.endsWith(".yaml")||e.endsWith(".yml"))?de(e):n?.json5!==!1&&e.endsWith(".json5")?ye(e):ee(e),"parsePackageFile"),Y=p((e,n)=>n?.yaml!==!1&&(e.endsWith(".yaml")||e.endsWith(".yml"))?ge(e):n?.json5!==!1&&e.endsWith(".json5")?me(e):U(e),"parsePackageFileSync"),Ae=p(async(e,n={})=>{const r={type:"file"};e&&(r.cwd=e);const t=["package.json"];n.yaml!==!1&&t.push("package.yaml","package.yml"),n.json5!==!1&&t.push("package.json5");let o;for await(const c of t)if(o=await H(c,r),o)break;if(!o)throw new A(`No such file or directory, for ${t.join(", ").replace(/, ([^,]*)$/," or $1")} found.`);const s=n.cache&&typeof n.cache!="boolean"?n.cache:R;if(n.cache&&s.has(o))return s.get(o);const a=await z(o,n);if(n.resolveCatalogs){const c=await _(o);c&&P(a,c)}E(a,n.strict??!1,n.ignoreWarnings);const i={packageJson:a,path:o};return n.cache&&s.set(o,i),i},"findPackageJson"),Se=p((e,n={})=>{const r={type:"file"};e&&(r.cwd=e);const t=["package.json"];n.yaml!==!1&&t.push("package.yaml","package.yml"),n.json5!==!1&&t.push("package.json5");let o;for(const c of t)if(o=L(c,r),o)break;if(!o)throw new A(`No such file or directory, for ${t.join(", ").replace(/, ([^,]*)$/," or $1")} found.`);const s=n.cache&&typeof n.cache!="boolean"?n.cache:R;if(n.cache&&s.has(o))return s.get(o);const a=Y(o,n);if(n.resolveCatalogs){const c=T(o);c&&P(a,c)}E(a,n.strict??!1,n.ignoreWarnings);const i={packageJson:a,path:o};return n.cache&&s.set(o,i),i},"findPackageJsonSync"),Ne=p(async(e,n={})=>{const{cwd:r,...t}=n,o=v(n.cwd??process.cwd());await Q(N(o,"package.json"),e,t)},"writePackageJson"),Ie=p((e,n={})=>{const{cwd:r,...t}=n,o=v(n.cwd??process.cwd());Z(N(o,"package.json"),e,t)},"writePackageJsonSync"),Te=p((e,n)=>{const r=e!==null&&typeof e=="object"&&!Array.isArray(e);if(!r&&typeof e!="string")throw new TypeError("`packageFile` should be either an `object` or a `string`.");let t,o=!1,s;if(r)t=structuredClone(e);else if(J(e)){s=e;const i=n?.cache&&typeof n.cache!="boolean"?n.cache:k;if(n?.cache&&i.has(s))return i.get(s);t=Y(s,n),o=!0}else t=S(e);if(n?.resolveCatalogs)if(o){const i=T(e);i&&P(t,i)}else throw new Error("The 'resolveCatalogs' option can only be used on a file path.");E(t,n?.strict??!1,n?.ignoreWarnings);const a=t;return o&&s&&n?.cache&&(n.cache&&typeof n.cache!="boolean"?n.cache:k).set(s,a),a},"parsePackageJsonSync"),_e=p(async(e,n)=>{const r=e!==null&&typeof e=="object"&&!Array.isArray(e);if(!r&&typeof e!="string")throw new TypeError("`packageFile` should be either an `object` or a `string`.");let t,o=!1,s;if(r)t=structuredClone(e);else if(J(e)){s=e;const i=n?.cache&&typeof n.cache!="boolean"?n.cache:k;if(n?.cache&&i.has(s))return i.get(s);t=await z(s,n),o=!0}else t=S(e);if(n?.resolveCatalogs)if(o){const i=await _(e);i&&P(t,i)}else throw new Error("The 'resolveCatalogs' option can only be used on a file path.");E(t,n?.strict??!1,n?.ignoreWarnings);const a=t;return o&&s&&n?.cache&&(n.cache&&typeof n.cache!="boolean"?n.cache:k).set(s,a),a},"parsePackageJson"),Fe=p((e,n,r)=>d(e,n,r),"getPackageJsonProperty"),De=p((e,n)=>g(e,n),"hasPackageJsonProperty"),Ce=p((e,n,r)=>{const t=d(e,"dependencies",{}),o=d(e,"devDependencies",{}),s=d(e,"peerDependencies",{}),a={...t,...o,...r?.peerDeps===!1?{}:s};for(const i of n)if(g(a,i))return!0;return!1},"hasPackageJsonAnyDependency"),Oe=p(async(e,n,r="dependencies",t={})=>{const o=d(e,"dependencies",{}),s=d(e,"devDependencies",{}),a=d(e,"peerDependencies",{}),i=[],c={deps:!0,devDeps:!0,peerDeps:!1,...t};for(const u of n)c.deps&&g(o,u)||c.devDeps&&g(s,u)||c.peerDeps&&g(a,u)||i.push(u);if(i.length!==0){if(process.env.CI||le&&!process.stdout?.isTTY){const u=`Skipping package installation for [${n.join(", ")}] because the process is not interactive.`;if(t.throwOnWarn)throw new Error(u);t.logger?.warn?t.logger.warn(u):console.warn(u);return}if(typeof c.confirm?.message=="function"&&(c.confirm.message=c.confirm.message(i)),c.confirm?.message===void 0){const u=`${i.length===1?"Package is":"Packages are"} required for this config: ${i.join(", ")}. Do you want to install them?`;c.confirm===void 0?c.confirm={message:u}:c.confirm.message=u}await G(c.confirm)&&await V(i,{...c.installPackage,cwd:c.cwd?v(c.cwd):void 0,dev:r==="devDependencies"})}},"ensurePackages");export{Oe as ensurePackages,Ae as findPackageJson,Se as findPackageJsonSync,Fe as getPackageJsonProperty,Ce as hasPackageJsonAnyDependency,De as hasPackageJsonProperty,_e as parsePackageJson,Te as parsePackageJsonSync,Ne as writePackageJson,Ie as writePackageJsonSync};
|
|
@@ -18,4 +18,5 @@ declare const generateMissingPackagesInstallMessage: (packageName: string, missi
|
|
|
18
18
|
preMessage?: string;
|
|
19
19
|
}) => string;
|
|
20
20
|
|
|
21
|
-
export {
|
|
21
|
+
export { findLockFile, findLockFileSync, findPackageManager, findPackageManagerSync, generateMissingPackagesInstallMessage, getPackageManagerVersion, identifyInitiatingPackageManager };
|
|
22
|
+
export type { PackageManager, PackageManagerResult };
|
package/dist/package-manager.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
var
|
|
2
|
-
${
|
|
1
|
+
var v=Object.defineProperty;var d=(n,e)=>v(n,"name",{value:e,configurable:!0});import{createRequire as _}from"node:module";import{findUpSync as m,findUp as h}from"@visulima/fs";import{NotFoundError as p}from"@visulima/fs/error";import{join as l,dirname as t}from"@visulima/path";import{parsePackageJsonSync as M,parsePackageJson as $}from"./package-json.js";const P=_(import.meta.url),s=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,u=d(n=>{if(typeof s<"u"&&s.versions&&s.versions.node){const[e,a]=s.versions.node.split(".").map(Number);if(e>22||e===22&&a>=3||e===20&&a>=16)return s.getBuiltinModule(n)}return P(n)},"__cjs_getBuiltinModule"),{execSync:W}=u("node:child_process"),{existsSync:k,readFileSync:S}=u("node:fs");var F=Object.defineProperty,r=d((n,e)=>F(n,"name",{value:e,configurable:!0}),"t");const f=["yarn.lock","package-lock.json","pnpm-lock.yaml","npm-shrinkwrap.json","bun.lockb"],y=r(n=>{let e;if(f.forEach(i=>{!e&&k(l(n,i))&&(e=l(n,i))}),e)return e;const a=l(n,"package.json");if(k(a)&&M(S(a,"utf8")).packageManager!==void 0)return a},"packageMangerFindUpMatcher"),E=r(async n=>{if(!n)throw new p("Could not find a package manager");if(n.endsWith("package.json")){const e=await $(n);if(e.packageManager){const a=["npm","yarn","pnpm","bun"].find(i=>e.packageManager.startsWith(i));if(a)return{packageManager:a,path:t(n)}}}if(n.endsWith("yarn.lock"))return{packageManager:"yarn",path:t(n)};if(n.endsWith("package-lock.json")||n.endsWith("npm-shrinkwrap.json"))return{packageManager:"npm",path:t(n)};if(n.endsWith("pnpm-lock.yaml"))return{packageManager:"pnpm",path:t(n)};if(n.endsWith("bun.lockb"))return{packageManager:"bun",path:t(n)};throw new p("Could not find a package manager")},"findPackageManagerOnFile"),x=r(n=>{if(!n)throw new p("Could not find a package manager");if(n.endsWith("package.json")){const e=M(n);if(e.packageManager){const a=["npm","yarn","pnpm","bun"].find(i=>e.packageManager.startsWith(i));if(a)return{packageManager:a,path:t(n)}}}if(n.endsWith("yarn.lock"))return{packageManager:"yarn",path:t(n)};if(n.endsWith("package-lock.json")||n.endsWith("npm-shrinkwrap.json"))return{packageManager:"npm",path:t(n)};if(n.endsWith("pnpm-lock.yaml"))return{packageManager:"pnpm",path:t(n)};if(n.endsWith("bun.lockb"))return{packageManager:"bun",path:t(n)};throw new p("Could not find a package manager")},"findPackageManagerOnFileSync"),U=r(async n=>{const e=await h(f,{type:"file",...n&&{cwd:n}});if(!e)throw new Error("Could not find lock file");return e},"findLockFile"),q=r(n=>{const e=m(f,{type:"file",...n&&{cwd:n}});if(!e)throw new Error("Could not find lock file");return e},"findLockFileSync"),B=r(async n=>{const e=await h(y,{...n&&{cwd:n}});return E(e)},"findPackageManager"),D=r(n=>{const e=m(y,{...n&&{cwd:n}});return x(e)},"findPackageManagerSync"),J=r(n=>W(`${n} --version`).toString("utf8").trim(),"getPackageManagerVersion"),R=r(async()=>{if(!process.env.npm_config_user_agent)return;const n=process.env.npm_config_user_agent.split(" ")[0],e=n.lastIndexOf("/"),a=n.slice(0,Math.max(0,e));return{name:a==="npminstall"?"cnpm":a,version:n.slice(Math.max(0,e+1))}},"identifyInitiatingPackageManager"),V=r((n,e,a)=>{const i=e.length===1?"":"s";if(a.packageManagers===void 0&&(a.packageManagers=["npm","pnpm","yarn"]),a.packageManagers.length===0)throw new Error("No package managers provided, please provide at least one package manager");if(e.length===0)throw new Error("No missing packages provided, please provide at least one missing package");let g=`
|
|
2
|
+
${a.preMessage??""}
|
|
3
3
|
${n} could not find the following package${i}
|
|
4
4
|
|
|
5
|
-
${
|
|
5
|
+
${e.join(`
|
|
6
6
|
`)}
|
|
7
7
|
|
|
8
8
|
To install the missing package${i}, please run the following command:
|
|
9
|
-
`;const
|
|
9
|
+
`;const w=r(o=>o.split("@").includes("@")?o:`${o}@latest`,"atLatest"),j=a.packageManagers.map(o=>{const c=e.map(b=>w(b)).join(" ");switch(o){case"bun":return` bun add ${c} -D`;case"npm":return` npm install ${c} --save-dev`;case"pnpm":return` pnpm add ${c} -D`;case"yarn":return` yarn add ${c} --dev`;default:throw new Error("Unknown package manager")}});return g+=j.join(`
|
|
10
10
|
|
|
11
11
|
or
|
|
12
12
|
|
|
13
|
-
`),
|
|
13
|
+
`),a.postMessage&&(g+=a.postMessage),g},"generateMissingPackagesInstallMessage");export{U as findLockFile,q as findLockFileSync,B as findPackageManager,D as findPackageManagerSync,V as generateMissingPackagesInstallMessage,J as getPackageManagerVersion,R as identifyInitiatingPackageManager};
|
package/dist/package.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var u=Object.defineProperty;var c=(e,o)=>u(e,"name",{value:o,configurable:!0});import{createRequire as l}from"node:module";import{findUp as a,findUpSync as f,readJsonSync as _}from"@visulima/fs";import{dirname as r,join as d}from"@visulima/path";import{findLockFile as w,findLockFileSync as j}from"./package-manager.js";const g=l(import.meta.url),t=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,y=c(e=>{if(typeof t<"u"&&t.versions&&t.versions.node){const[o,n]=t.versions.node.split(".").map(Number);if(o>22||o===22&&n>=3||o===20&&n>=16)return t.getBuiltinModule(e)}return g(e)},"__cjs_getBuiltinModule"),{existsSync:m}=y("node:fs");var k=Object.defineProperty,s=c((e,o)=>k(e,"name",{value:o,configurable:!0}),"i");const p=s(e=>{if(m(d(e,"package.json"))){const o=_(d(e,"package.json"));if(o.name&&o.private!==!0)return"package.json"}},"packageJsonMatcher"),S=s(async e=>{try{const i=await w(e);return r(i)}catch{}const o=await a(".git/config",{...e&&{cwd:e},type:"file"});if(o)return r(r(o));const n=await a(p,{...e&&{cwd:e},type:"file"});if(n)return r(n);throw new Error("Could not find root directory")},"findPackageRoot"),q=s(e=>{try{const i=j(e);return r(i)}catch{}const o=f(".git/config",{...e&&{cwd:e},type:"file"});if(o)return r(r(o));const n=f(p,{...e&&{cwd:e},type:"file"});if(n)return r(n);throw new Error("Could not find root directory")},"findPackageRootSync");export{S as findPackageRoot,q as findPackageRootSync};
|