@visulima/package 5.0.0-alpha.11 → 5.0.0-alpha.13

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.
@@ -1,138 +1,7 @@
1
- import type { WriteJsonOptions } from "@visulima/fs";
2
- import type { JsonObject, Paths } from "type-fest";
3
- import type { Cache, EnsurePackagesOptions, NormalizedPackageJson, PackageJson } from "./types.d.ts";
4
- type ReadOptions = {
5
- cache?: FindPackageJsonCache | boolean;
6
- ignoreWarnings?: (RegExp | string)[];
7
- json5?: boolean;
8
- resolveCatalogs?: boolean;
9
- strict?: boolean;
10
- yaml?: boolean;
11
- };
12
- export type FindPackageJsonCache = Cache<NormalizedReadResult>;
13
- export type NormalizedReadResult = {
14
- packageJson: NormalizedPackageJson;
15
- path: string;
16
- };
17
- /**
18
- * An asynchronous function to find the package.json, package.yaml, or package.json5 file in the specified directory or its parent directories.
19
- * @param cwd The current working directory.
20
- * @param options Configuration options including yaml, json5, and resolveCatalogs flags.
21
- * @returns A `Promise` that resolves to an object containing the parsed package data and the file path.
22
- * The type of the returned promise is `Promise&lt;NormalizedReadResult>`.
23
- * @throws {Error} If no package file can be found or if strict mode is enabled and normalize warnings are thrown.
24
- */
25
- export declare const findPackageJson: (cwd?: URL | string, options?: ReadOptions) => Promise<NormalizedReadResult>;
26
- /**
27
- * A synchronous function to find the package.json, package.yaml, or package.json5 file in the specified directory or its parent directories.
28
- * @param cwd The current working directory.
29
- * @param options Configuration options including yaml, json5, and resolveCatalogs flags.
30
- * @returns An object containing the parsed package data and the file path.
31
- * @throws {Error} If no package file can be found or if strict mode is enabled and normalize warnings are thrown.
32
- */
33
- export declare const findPackageJsonSync: (cwd?: URL | string, options?: ReadOptions) => NormalizedReadResult;
34
- /**
35
- * An asynchronous function to write the package.json file with the given data.
36
- * @param data The package.json data to write. The data is an intersection type of `PackageJson` and a record where keys are `string` and values can be any type.
37
- * @param options Optional. The options for writing the package.json. If not provided, an empty object will be used `{}`.
38
- * This is an intersection type of `WriteJsonOptions` and a record with an optional `cwd` key which type is `Options["cwd"]`.
39
- * `cwd` represents the current working directory. If not specified, the default working directory will be used.
40
- * @returns A `Promise` that resolves once the package.json file has been written. The type of the returned promise is `Promise&lt;void>`.
41
- */
42
- export declare const writePackageJson: (data: PackageJson, options?: WriteJsonOptions & {
43
- cwd?: URL | string;
44
- }) => Promise<void>;
45
- export declare const writePackageJsonSync: (data: PackageJson, options?: WriteJsonOptions & {
46
- cwd?: URL | string;
47
- }) => void;
48
- /**
49
- * A synchronous function to parse the package.json, package.yaml, or package.json5 file/object/string and return normalize the data.
50
- * @param packageFile
51
- * @param options
52
- * @param options.cache Cache for parsed results (only applies to file paths)
53
- * @param options.ignoreWarnings List of warning messages or patterns to skip in strict mode
54
- * @param options.resolveCatalogs Whether to resolve pnpm catalog references
55
- * @param options.strict Whether to throw errors on normalization warnings
56
- * @param options.yaml Whether to enable package.yaml parsing (default: true)
57
- * @param options.json5 Whether to enable package.json5 parsing (default: true)
58
- * @returns
59
- * @throws {Error} If the packageFile parameter is not an object or a string or if strict mode is enabled and normalize warnings are thrown.
60
- */
61
- export declare const parsePackageJsonSync: (packageFile: JsonObject | string, options?: {
62
- cache?: Cache<NormalizedPackageJson> | boolean;
63
- ignoreWarnings?: (RegExp | string)[];
64
- json5?: boolean;
65
- resolveCatalogs?: boolean;
66
- strict?: boolean;
67
- yaml?: boolean;
68
- }) => NormalizedPackageJson;
69
- /**
70
- * An asynchronous function to parse the package.json, package.yaml, or package.json5 file/object/string and return normalize the data.
71
- * @param packageFile
72
- * @param options
73
- * @param options.cache Cache for parsed results (only applies to file paths)
74
- * @param options.ignoreWarnings List of warning messages or patterns to skip in strict mode
75
- * @param options.strict Whether to throw errors on normalization warnings
76
- * @param options.resolveCatalogs Whether to resolve pnpm catalog references
77
- * @param options.yaml Whether to enable package.yaml parsing (default: true)
78
- * @param options.json5 Whether to enable package.json5 parsing (default: true)
79
- * @returns
80
- * @throws {Error} If the packageFile parameter is not an object or a string or if strict mode is enabled and normalize warnings are thrown.
81
- */
82
- export declare const parsePackageJson: (packageFile: JsonObject | string, options?: {
83
- cache?: Cache<NormalizedPackageJson> | boolean;
84
- ignoreWarnings?: (RegExp | string)[];
85
- json5?: boolean;
86
- resolveCatalogs?: boolean;
87
- strict?: boolean;
88
- yaml?: boolean;
89
- }) => Promise<NormalizedPackageJson>;
90
- /**
91
- * An asynchronous function to get the value of a property from the package.json file.
92
- * @param packageJson
93
- * @param property
94
- * @param defaultValue
95
- * @returns
96
- */
97
- export declare const getPackageJsonProperty: <T = unknown>(packageJson: NormalizedPackageJson, property: Paths<NormalizedPackageJson>, defaultValue?: T) => T;
98
- /**
99
- * An asynchronous function to check if a property exists in the package.json file.
100
- * @param packageJson
101
- * @param property
102
- * @returns
103
- */
104
- export declare const hasPackageJsonProperty: (packageJson: NormalizedPackageJson, property: Paths<NormalizedPackageJson>) => boolean;
105
- /**
106
- * An asynchronous function to check if any of the specified dependencies exist in the package.json file.
107
- * @param packageJson
108
- * @param arguments_
109
- * @param options
110
- * @param options.peerDeps Whether to include peer dependencies
111
- * @returns
112
- */
113
- export declare const hasPackageJsonAnyDependency: (packageJson: NormalizedPackageJson, arguments_: string[], options?: {
114
- peerDeps?: boolean;
115
- }) => boolean;
116
- /**
117
- * An asynchronous function to ensure that the specified packages are installed in the package.json file.
118
- * If the packages are not installed, the user will be prompted to install them.
119
- * If the user agrees, the packages will be installed.
120
- * If the user declines, the function will return without installing the packages.
121
- * If the user does not respond, the function will return without installing the packages.
122
- * @param packageJson
123
- * @param packages
124
- * @param installKey
125
- * @param options
126
- * @param options.deps Whether to include regular dependencies
127
- * @param options.devDeps Whether to include development dependencies
128
- * @param options.peerDeps Whether to include peer dependencies
129
- * @param options.throwOnWarn Whether to throw an error when warnings are logged instead of just logging them
130
- * @param options.logger Whether to use a custom logger
131
- * @param options.confirm Whether to use a custom confirmation prompt
132
- * @param options.installPackage Whether to use a custom installation package
133
- * @param options.cwd Whether to use a custom current working directory
134
- * @param options.dev Whether to use a custom installation key
135
- * @returns
136
- */
137
- export declare const ensurePackages: (packageJson: NormalizedPackageJson, packages: string[], installKey?: "dependencies" | "devDependencies", options?: EnsurePackagesOptions) => Promise<void>;
138
- export {};
1
+ import '@visulima/fs';
2
+ import 'type-fest';
3
+ export { F as FindPackageJsonCache, a as NormalizedReadResult, 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";
4
+ import '@antfu/install-pkg';
5
+ import '@inquirer/core';
6
+ import '@inquirer/type';
7
+ import 'normalize-package-data';