@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
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import { WriteJsonOptions } from '@visulima/fs';
|
|
2
|
+
import { PackageJson as PackageJson$1, Paths, JsonObject } from 'type-fest';
|
|
3
|
+
import { InstallPackageOptions } from '@antfu/install-pkg';
|
|
4
|
+
import { Package } from 'normalize-package-data';
|
|
5
|
+
|
|
6
|
+
type Prettify<T> = {
|
|
7
|
+
[K in keyof T]: T[K];
|
|
8
|
+
} & {};
|
|
9
|
+
type PartialDeep<T> = T extends object ? {
|
|
10
|
+
[P in keyof T]?: PartialDeep<T[P]>;
|
|
11
|
+
} : T;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Union type representing the possible statuses of a prompt.
|
|
15
|
+
*
|
|
16
|
+
* - `'loading'`: The prompt is currently loading.
|
|
17
|
+
* - `'idle'`: The prompt is loaded and currently waiting for the user to
|
|
18
|
+
* submit an answer.
|
|
19
|
+
* - `'done'`: The user has submitted an answer and the prompt is finished.
|
|
20
|
+
* - `string`: Any other string: The prompt is in a custom state.
|
|
21
|
+
*/
|
|
22
|
+
type Status = 'loading' | 'idle' | 'done' | (string & {});
|
|
23
|
+
type DefaultTheme = {
|
|
24
|
+
/**
|
|
25
|
+
* Prefix to prepend to the message. If a function is provided, it will be
|
|
26
|
+
* called with the current status of the prompt, and the return value will be
|
|
27
|
+
* used as the prefix.
|
|
28
|
+
*
|
|
29
|
+
* @remarks
|
|
30
|
+
* If `status === 'loading'`, this property is ignored and the spinner (styled
|
|
31
|
+
* by the `spinner` property) will be displayed instead.
|
|
32
|
+
*
|
|
33
|
+
* @defaultValue
|
|
34
|
+
* ```ts
|
|
35
|
+
* // import colors from 'yoctocolors-cjs';
|
|
36
|
+
* (status) => status === 'done' ? colors.green('✔') : colors.blue('?')
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
prefix: string | Prettify<Omit<Record<Status, string>, 'loading'>>;
|
|
40
|
+
/**
|
|
41
|
+
* Configuration for the spinner that is displayed when the prompt is in the
|
|
42
|
+
* `'loading'` state.
|
|
43
|
+
*
|
|
44
|
+
* We recommend the use of {@link https://github.com/sindresorhus/cli-spinners|cli-spinners} for a list of available spinners.
|
|
45
|
+
*/
|
|
46
|
+
spinner: {
|
|
47
|
+
/**
|
|
48
|
+
* The time interval between frames, in milliseconds.
|
|
49
|
+
*
|
|
50
|
+
* @defaultValue
|
|
51
|
+
* ```ts
|
|
52
|
+
* 80
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
interval: number;
|
|
56
|
+
/**
|
|
57
|
+
* A list of frames to show for the spinner.
|
|
58
|
+
*
|
|
59
|
+
* @defaultValue
|
|
60
|
+
* ```ts
|
|
61
|
+
* ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏']
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
frames: string[];
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Object containing functions to style different parts of the prompt.
|
|
68
|
+
*/
|
|
69
|
+
style: {
|
|
70
|
+
/**
|
|
71
|
+
* Style to apply to the user's answer once it has been submitted.
|
|
72
|
+
*
|
|
73
|
+
* @param text - The user's answer.
|
|
74
|
+
* @returns The styled answer.
|
|
75
|
+
*
|
|
76
|
+
* @defaultValue
|
|
77
|
+
* ```ts
|
|
78
|
+
* // import colors from 'yoctocolors-cjs';
|
|
79
|
+
* (text) => colors.cyan(text)
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
answer: (text: string) => string;
|
|
83
|
+
/**
|
|
84
|
+
* Style to apply to the message displayed to the user.
|
|
85
|
+
*
|
|
86
|
+
* @param text - The message to style.
|
|
87
|
+
* @param status - The current status of the prompt.
|
|
88
|
+
* @returns The styled message.
|
|
89
|
+
*
|
|
90
|
+
* @defaultValue
|
|
91
|
+
* ```ts
|
|
92
|
+
* // import colors from 'yoctocolors-cjs';
|
|
93
|
+
* (text, status) => colors.bold(text)
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
message: (text: string, status: Status) => string;
|
|
97
|
+
/**
|
|
98
|
+
* Style to apply to error messages.
|
|
99
|
+
*
|
|
100
|
+
* @param text - The error message.
|
|
101
|
+
* @returns The styled error message.
|
|
102
|
+
*
|
|
103
|
+
* @defaultValue
|
|
104
|
+
* ```ts
|
|
105
|
+
* // import colors from 'yoctocolors-cjs';
|
|
106
|
+
* (text) => colors.red(`> ${text}`)
|
|
107
|
+
* ```
|
|
108
|
+
*/
|
|
109
|
+
error: (text: string) => string;
|
|
110
|
+
/**
|
|
111
|
+
* Style to apply to the default answer when one is provided.
|
|
112
|
+
*
|
|
113
|
+
* @param text - The default answer.
|
|
114
|
+
* @returns The styled default answer.
|
|
115
|
+
*
|
|
116
|
+
* @defaultValue
|
|
117
|
+
* ```ts
|
|
118
|
+
* // import colors from 'yoctocolors-cjs';
|
|
119
|
+
* (text) => colors.dim(`(${text})`)
|
|
120
|
+
* ```
|
|
121
|
+
*/
|
|
122
|
+
defaultAnswer: (text: string) => string;
|
|
123
|
+
/**
|
|
124
|
+
* Style to apply to help text.
|
|
125
|
+
*
|
|
126
|
+
* @param text - The help text.
|
|
127
|
+
* @returns The styled help text.
|
|
128
|
+
*
|
|
129
|
+
* @defaultValue
|
|
130
|
+
* ```ts
|
|
131
|
+
* // import colors from 'yoctocolors-cjs';
|
|
132
|
+
* (text) => colors.dim(text)
|
|
133
|
+
* ```
|
|
134
|
+
*/
|
|
135
|
+
help: (text: string) => string;
|
|
136
|
+
/**
|
|
137
|
+
* Style to apply to highlighted text.
|
|
138
|
+
*
|
|
139
|
+
* @param text - The text to highlight.
|
|
140
|
+
* @returns The highlighted text.
|
|
141
|
+
*
|
|
142
|
+
* @defaultValue
|
|
143
|
+
* ```ts
|
|
144
|
+
* // import colors from 'yoctocolors-cjs';
|
|
145
|
+
* (text) => colors.cyan(text)
|
|
146
|
+
* ```
|
|
147
|
+
*/
|
|
148
|
+
highlight: (text: string) => string;
|
|
149
|
+
/**
|
|
150
|
+
* Style to apply to keyboard keys referred to in help texts.
|
|
151
|
+
*
|
|
152
|
+
* @param text - The key to style.
|
|
153
|
+
* @returns The styled key.
|
|
154
|
+
*
|
|
155
|
+
* @defaultValue
|
|
156
|
+
* ```ts
|
|
157
|
+
* // import colors from 'yoctocolors-cjs';
|
|
158
|
+
* (text) => colors.cyan(colors.bold(`<${text}>`))
|
|
159
|
+
* ```
|
|
160
|
+
*/
|
|
161
|
+
key: (text: string) => string;
|
|
162
|
+
};
|
|
163
|
+
};
|
|
164
|
+
type Theme<Extension extends object = object> = Prettify<Extension & DefaultTheme>;
|
|
165
|
+
|
|
166
|
+
type NormalizedPackageJson = Package & PackageJson;
|
|
167
|
+
type PackageJson = PackageJson$1;
|
|
168
|
+
type Cache<T = any> = Map<string, T>;
|
|
169
|
+
type EnsurePackagesOptions = {
|
|
170
|
+
confirm?: {
|
|
171
|
+
default?: boolean;
|
|
172
|
+
message: string | ((packages: string[]) => string);
|
|
173
|
+
theme?: PartialDeep<Theme>;
|
|
174
|
+
transformer?: (value: boolean) => string;
|
|
175
|
+
};
|
|
176
|
+
cwd?: URL | string;
|
|
177
|
+
deps?: boolean;
|
|
178
|
+
devDeps?: boolean;
|
|
179
|
+
installPackage?: Omit<InstallPackageOptions, "cwd" | "dev">;
|
|
180
|
+
logger?: {
|
|
181
|
+
warn: (message: string) => void;
|
|
182
|
+
};
|
|
183
|
+
peerDeps?: boolean;
|
|
184
|
+
throwOnWarn?: boolean;
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
type ReadOptions = {
|
|
188
|
+
cache?: FindPackageJsonCache | boolean;
|
|
189
|
+
ignoreWarnings?: (RegExp | string)[];
|
|
190
|
+
json5?: boolean;
|
|
191
|
+
resolveCatalogs?: boolean;
|
|
192
|
+
strict?: boolean;
|
|
193
|
+
yaml?: boolean;
|
|
194
|
+
};
|
|
195
|
+
type FindPackageJsonCache = Cache<NormalizedReadResult>;
|
|
196
|
+
type NormalizedReadResult = {
|
|
197
|
+
packageJson: NormalizedPackageJson;
|
|
198
|
+
path: string;
|
|
199
|
+
};
|
|
200
|
+
declare const findPackageJson: (cwd?: URL | string, options?: ReadOptions) => Promise<NormalizedReadResult>;
|
|
201
|
+
declare const findPackageJsonSync: (cwd?: URL | string, options?: ReadOptions) => NormalizedReadResult;
|
|
202
|
+
declare const writePackageJson: <T = PackageJson>(data: T, options?: WriteJsonOptions & {
|
|
203
|
+
cwd?: URL | string;
|
|
204
|
+
}) => Promise<void>;
|
|
205
|
+
declare const writePackageJsonSync: <T = PackageJson>(data: T, options?: WriteJsonOptions & {
|
|
206
|
+
cwd?: URL | string;
|
|
207
|
+
}) => void;
|
|
208
|
+
declare const parsePackageJsonSync: (packageFile: JsonObject | string, options?: {
|
|
209
|
+
cache?: Cache<NormalizedPackageJson> | boolean;
|
|
210
|
+
ignoreWarnings?: (RegExp | string)[];
|
|
211
|
+
json5?: boolean;
|
|
212
|
+
resolveCatalogs?: boolean;
|
|
213
|
+
strict?: boolean;
|
|
214
|
+
yaml?: boolean;
|
|
215
|
+
}) => NormalizedPackageJson;
|
|
216
|
+
declare const parsePackageJson: (packageFile: JsonObject | string, options?: {
|
|
217
|
+
cache?: Cache<NormalizedPackageJson> | boolean;
|
|
218
|
+
ignoreWarnings?: (RegExp | string)[];
|
|
219
|
+
json5?: boolean;
|
|
220
|
+
resolveCatalogs?: boolean;
|
|
221
|
+
strict?: boolean;
|
|
222
|
+
yaml?: boolean;
|
|
223
|
+
}) => Promise<NormalizedPackageJson>;
|
|
224
|
+
declare const getPackageJsonProperty: <T = unknown>(packageJson: NormalizedPackageJson, property: Paths<NormalizedPackageJson>, defaultValue?: T) => T;
|
|
225
|
+
declare const hasPackageJsonProperty: (packageJson: NormalizedPackageJson, property: Paths<NormalizedPackageJson>) => boolean;
|
|
226
|
+
declare const hasPackageJsonAnyDependency: (packageJson: NormalizedPackageJson, arguments_: string[], options?: {
|
|
227
|
+
peerDeps?: boolean;
|
|
228
|
+
}) => boolean;
|
|
229
|
+
declare const ensurePackages: (packageJson: NormalizedPackageJson, packages: string[], installKey?: "dependencies" | "devDependencies", options?: EnsurePackagesOptions) => Promise<void>;
|
|
230
|
+
|
|
231
|
+
export { findPackageJsonSync as a, hasPackageJsonProperty as b, parsePackageJsonSync as c, writePackageJsonSync as d, ensurePackages as e, findPackageJson as f, getPackageJsonProperty as g, hasPackageJsonAnyDependency as h, parsePackageJson as p, writePackageJson as w };
|
|
232
|
+
export type { EnsurePackagesOptions as E, FindPackageJsonCache as F, NormalizedReadResult as N, PackageJson as P, NormalizedPackageJson as i };
|
package/dist/pnpm.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { JsonObject } from 'type-fest';
|
|
2
2
|
|
|
3
3
|
type PnpmCatalog = Record<string, string>;
|
|
4
4
|
type PnpmCatalogs = {
|
|
@@ -12,4 +12,5 @@ declare const resolveCatalogReference: (packageName: string, versionSpec: string
|
|
|
12
12
|
declare const resolveDependenciesCatalogReferences: (dependencies: Record<string, string>, catalogs: PnpmCatalogs) => void;
|
|
13
13
|
declare const resolveCatalogReferences: (packageJson: JsonObject, catalogs: PnpmCatalogs) => void;
|
|
14
14
|
|
|
15
|
-
export {
|
|
15
|
+
export { isPackageInWorkspace, readPnpmCatalogs, readPnpmCatalogsSync, resolveCatalogReference, resolveCatalogReferences, resolveDependenciesCatalogReferences };
|
|
16
|
+
export type { PnpmCatalog, PnpmCatalogs };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@visulima/package",
|
|
3
|
-
"version": "4.0
|
|
4
|
-
"description": "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.",
|
|
3
|
+
"version": "4.1.0",
|
|
4
|
+
"description": "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.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"anolilab",
|
|
7
7
|
"find",
|
|
@@ -14,6 +14,8 @@
|
|
|
14
14
|
"package-json",
|
|
15
15
|
"package-manager",
|
|
16
16
|
"package.json",
|
|
17
|
+
"package.yaml",
|
|
18
|
+
"package.json5",
|
|
17
19
|
"packages",
|
|
18
20
|
"pkg-dir",
|
|
19
21
|
"pkg-manager",
|
|
@@ -26,6 +28,8 @@
|
|
|
26
28
|
"bun",
|
|
27
29
|
"npm",
|
|
28
30
|
"yarn",
|
|
31
|
+
"yaml",
|
|
32
|
+
"json5",
|
|
29
33
|
"visulima"
|
|
30
34
|
],
|
|
31
35
|
"homepage": "https://www.visulima.com/docs/package/package",
|
|
@@ -92,12 +96,14 @@
|
|
|
92
96
|
"LICENSE.md"
|
|
93
97
|
],
|
|
94
98
|
"dependencies": {
|
|
95
|
-
"yaml": "^2.8.1",
|
|
96
99
|
"@antfu/install-pkg": "^1.1.0",
|
|
97
|
-
"@inquirer/confirm": "^5.1.
|
|
98
|
-
"@visulima/fs": "
|
|
99
|
-
"@visulima/path": "
|
|
100
|
-
"
|
|
100
|
+
"@inquirer/confirm": "^5.1.19",
|
|
101
|
+
"@visulima/fs": "4.0.0",
|
|
102
|
+
"@visulima/path": "2.0.0",
|
|
103
|
+
"json5": "^2.2.3",
|
|
104
|
+
"normalize-package-data": "^8.0.0",
|
|
105
|
+
"type-fest": "^5.1.0",
|
|
106
|
+
"yaml": "^2.8.1"
|
|
101
107
|
},
|
|
102
108
|
"engines": {
|
|
103
109
|
"node": ">=20.19 <=24.*"
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
Matches a JSON object.
|
|
3
|
-
|
|
4
|
-
This type can be useful to enforce some input to be JSON-compatible or as a super-type to be extended from. Don't use this as a direct return type as the user would have to double-cast it: `jsonObject as unknown as CustomResponse`. Instead, you could extend your CustomResponse type from it to ensure your type only uses JSON-compatible types: `interface CustomResponse extends JsonObject { … }`.
|
|
5
|
-
|
|
6
|
-
@category JSON
|
|
7
|
-
*/
|
|
8
|
-
type JsonObject = {[Key in string]: JsonValue} & {[Key in string]?: JsonValue | undefined};
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
Matches a JSON array.
|
|
12
|
-
|
|
13
|
-
@category JSON
|
|
14
|
-
*/
|
|
15
|
-
type JsonArray = JsonValue[] | readonly JsonValue[];
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
Matches any valid JSON primitive value.
|
|
19
|
-
|
|
20
|
-
@category JSON
|
|
21
|
-
*/
|
|
22
|
-
type JsonPrimitive = string | number | boolean | null;
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
Matches any valid JSON value.
|
|
26
|
-
|
|
27
|
-
@see `Jsonify` if you need to transform a type to one that is assignable to `JsonValue`.
|
|
28
|
-
|
|
29
|
-
@category JSON
|
|
30
|
-
*/
|
|
31
|
-
type JsonValue = JsonPrimitive | JsonObject | JsonArray;
|
|
32
|
-
|
|
33
|
-
export type { JsonObject as J, JsonValue as a };
|