@visulima/package 4.1.4 → 4.1.6
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 +30 -0
- package/LICENSE.md +5 -1
- package/dist/error/package-not-found-error.d.ts +15 -0
- package/dist/error.d.ts +1 -9
- package/dist/index.d.ts +11 -10
- package/dist/monorepo.d.ts +22 -7
- package/dist/package-json.d.ts +138 -5
- package/dist/package-manager.d.ts +61 -12
- package/dist/package.d.ts +11 -4
- package/dist/pnpm.d.ts +15 -13
- package/dist/types.d.ts +37 -0
- package/dist/utils/is-node.d.ts +2 -0
- package/package.json +4 -5
- package/dist/packem_shared/package-json-CiMqtMwD.d.ts +0 -232
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,33 @@
|
|
|
1
|
+
## @visulima/package [4.1.6](https://github.com/visulima/visulima/compare/@visulima/package@4.1.5...@visulima/package@4.1.6) (2025-11-13)
|
|
2
|
+
|
|
3
|
+
### Bug Fixes
|
|
4
|
+
|
|
5
|
+
* bump packem, to fix minified version of the code ([2a36ceb](https://github.com/visulima/visulima/commit/2a36ceb09251b0ca1178701a26547a871ed717a7))
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Dependencies
|
|
9
|
+
|
|
10
|
+
* **@visulima/fs:** upgraded to 4.0.6
|
|
11
|
+
* **@visulima/path:** upgraded to 2.0.5
|
|
12
|
+
|
|
13
|
+
## @visulima/package [4.1.5](https://github.com/visulima/visulima/compare/@visulima/package@4.1.4...@visulima/package@4.1.5) (2025-11-12)
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
* **deps:** update type-fest dependency across multiple packages ([93e13be](https://github.com/visulima/visulima/commit/93e13be5248207968a96303710db2a0604d16b9b))
|
|
18
|
+
* update package configurations and TypeScript definitions ([b59aa59](https://github.com/visulima/visulima/commit/b59aa59dac1508216b944f4b917fb4a7ab1f70a4))
|
|
19
|
+
|
|
20
|
+
### Miscellaneous Chores
|
|
21
|
+
|
|
22
|
+
* Add jsr file to all packages for release ([#565](https://github.com/visulima/visulima/issues/565)) ([ec91652](https://github.com/visulima/visulima/commit/ec91652b4e4112adf14ba152c1239a7703ba425a))
|
|
23
|
+
* update license files and clean up TypeScript definitions ([fe668cc](https://github.com/visulima/visulima/commit/fe668cc26de23591d4df54a0954455ebbe31b22d))
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
### Dependencies
|
|
27
|
+
|
|
28
|
+
* **@visulima/fs:** upgraded to 4.0.5
|
|
29
|
+
* **@visulima/path:** upgraded to 2.0.4
|
|
30
|
+
|
|
1
31
|
## @visulima/package [4.1.4](https://github.com/visulima/visulima/compare/@visulima/package@4.1.3...@visulima/package@4.1.4) (2025-11-07)
|
|
2
32
|
|
|
3
33
|
### Bug Fixes
|
package/LICENSE.md
CHANGED
|
@@ -47,11 +47,14 @@ Repository: sindresorhus/dot-prop
|
|
|
47
47
|
<!-- TYPE_DEPENDENCIES -->
|
|
48
48
|
|
|
49
49
|
# Licenses of bundled types
|
|
50
|
+
|
|
50
51
|
The published @visulima/package artifact additionally contains code with the following licenses:
|
|
51
52
|
MIT
|
|
52
53
|
|
|
53
54
|
# Bundled types:
|
|
55
|
+
|
|
54
56
|
## @inquirer/core
|
|
57
|
+
|
|
55
58
|
License: MIT
|
|
56
59
|
By: Simon Boudrias
|
|
57
60
|
Repository: https://github.com/SBoudrias/Inquirer.js.git
|
|
@@ -79,9 +82,10 @@ Repository: https://github.com/SBoudrias/Inquirer.js.git
|
|
|
79
82
|
> FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
80
83
|
> OTHER DEALINGS IN THE SOFTWARE.
|
|
81
84
|
|
|
82
|
-
|
|
85
|
+
---
|
|
83
86
|
|
|
84
87
|
## @inquirer/type
|
|
88
|
+
|
|
85
89
|
License: MIT
|
|
86
90
|
By: Simon Boudrias
|
|
87
91
|
Repository: https://github.com/SBoudrias/Inquirer.js.git
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
get name(): string;
|
|
13
|
+
set name(_name: string);
|
|
14
|
+
}
|
|
15
|
+
export default PackageNotFoundError;
|
package/dist/error.d.ts
CHANGED
|
@@ -1,9 +1 @@
|
|
|
1
|
-
|
|
2
|
-
constructor(packageName: string[] | string, packageManager?: string);
|
|
3
|
-
get code(): string;
|
|
4
|
-
set code(_name: string);
|
|
5
|
-
get name(): string;
|
|
6
|
-
set name(_name: string);
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export { PackageNotFoundError };
|
|
1
|
+
export { default as PackageNotFoundError } from "./error/package-not-found-error.d.ts";
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
export { PackageNotFoundError } from
|
|
2
|
-
export { RootMonorepo, Strategy
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
6
|
-
export {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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";
|
package/dist/monorepo.d.ts
CHANGED
|
@@ -1,10 +1,25 @@
|
|
|
1
|
-
type Strategy = "lerna" | "npm" | "pnpm" | "turbo" | "yarn";
|
|
2
|
-
interface RootMonorepo<T extends Strategy = Strategy> {
|
|
1
|
+
export type Strategy = "lerna" | "npm" | "pnpm" | "turbo" | "yarn";
|
|
2
|
+
export interface RootMonorepo<T extends Strategy = Strategy> {
|
|
3
3
|
path: string;
|
|
4
4
|
strategy: T;
|
|
5
5
|
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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<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>;
|
|
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<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;
|
package/dist/package-json.d.ts
CHANGED
|
@@ -1,5 +1,138 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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<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<void>`.
|
|
41
|
+
*/
|
|
42
|
+
export declare const writePackageJson: <T = PackageJson>(data: T, options?: WriteJsonOptions & {
|
|
43
|
+
cwd?: URL | string;
|
|
44
|
+
}) => Promise<void>;
|
|
45
|
+
export declare const writePackageJsonSync: <T = PackageJson>(data: T, 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,22 +1,71 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
type
|
|
4
|
-
|
|
1
|
+
/**
|
|
2
|
+
* An asynchronous function that finds a lock file in the specified directory or any of its parent directories.
|
|
3
|
+
* @param cwd Optional. The directory path to start the search from. The type of `cwd` is part of an `Options` type,
|
|
4
|
+
* specifically `URL | string`. Defaults to the current working directory.
|
|
5
|
+
* @returns A `Promise` that resolves with the path of the found lock file.
|
|
6
|
+
* The type of the returned promise is `Promise<string>`.
|
|
7
|
+
* @throws An `Error` if no lock file is found.
|
|
8
|
+
*/
|
|
9
|
+
export declare const findLockFile: (cwd?: URL | string) => Promise<string>;
|
|
10
|
+
export declare const findLockFileSync: (cwd?: URL | string) => string;
|
|
11
|
+
export type PackageManager = "bun" | "npm" | "pnpm" | "yarn";
|
|
12
|
+
export type PackageManagerResult = {
|
|
5
13
|
packageManager: PackageManager;
|
|
6
14
|
path: string;
|
|
7
15
|
};
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
16
|
+
/**
|
|
17
|
+
* An asynchronous function that finds the package manager used in a project based on the presence of lock files
|
|
18
|
+
* or package.json configuration. If found, it returns the package manager and the path to the lock file or package.json.
|
|
19
|
+
* Throws an error if no lock file or package.json is found.
|
|
20
|
+
* @param cwd Optional. The current working directory to start the search from. The type of `cwd` is part of an `Options`
|
|
21
|
+
* type, specifically `URL | string`.
|
|
22
|
+
* @returns A `Promise` that resolves to an object containing the package manager and path.
|
|
23
|
+
* The return type of the function is `Promise<PackageManagerResult>`.
|
|
24
|
+
* @throws An `Error` if no lock file or package.json is found.
|
|
25
|
+
*/
|
|
26
|
+
export declare const findPackageManager: (cwd?: URL | string) => Promise<PackageManagerResult>;
|
|
27
|
+
/**
|
|
28
|
+
* An function that finds the package manager used in a project based on the presence of lock files
|
|
29
|
+
* or package.json configuration. If found, it returns the package manager and the path to the lock file or package.json.
|
|
30
|
+
* Throws an error if no lock file or package.json is found.
|
|
31
|
+
* @param cwd Optional. The current working directory to start the search from. The type of `cwd` is part of an `Options`
|
|
32
|
+
* type, specifically `URL | string`.
|
|
33
|
+
* @returns A `Promise` that resolves to an object containing the package manager and path.
|
|
34
|
+
* The return type of the function is `Promise<PackageManagerResult>`.
|
|
35
|
+
* @throws An `Error` if no lock file or package.json is found.
|
|
36
|
+
*/
|
|
37
|
+
export declare const findPackageManagerSync: (cwd?: URL | string) => PackageManagerResult;
|
|
38
|
+
/**
|
|
39
|
+
* Function that retrieves the version of the specified package manager.
|
|
40
|
+
* @param name The name of the package manager. The type of `name` is `string`.
|
|
41
|
+
* @returns The version of the package manager. The return type of the function is `string`.
|
|
42
|
+
*/
|
|
43
|
+
export declare const getPackageManagerVersion: (name: string) => string;
|
|
44
|
+
/**
|
|
45
|
+
* An asynchronous function that detects what package manager executes the process.
|
|
46
|
+
*
|
|
47
|
+
* Supports npm, pnpm, Yarn, cnpm, and bun. And also any other package manager that sets the npm_config_user_agent env variable.
|
|
48
|
+
* @returns A `Promise` that resolves to an object containing the name and version of the package manager,
|
|
49
|
+
* or undefined if the package manager information cannot be determined. The return type of the function
|
|
50
|
+
* is `Promise<{ name: PackageManager | "cnpm"; version: string } | undefined>`.
|
|
51
|
+
*/
|
|
52
|
+
export declare const identifyInitiatingPackageManager: () => Promise<{
|
|
12
53
|
name: PackageManager | "cnpm";
|
|
13
54
|
version: string;
|
|
14
55
|
} | undefined>;
|
|
15
|
-
|
|
56
|
+
/**
|
|
57
|
+
* Function that generates a message to install missing packages.
|
|
58
|
+
* @param packageName The name of the package that requires the missing packages.
|
|
59
|
+
* @param missingPackages An array of missing package names.
|
|
60
|
+
* @param options An object containing optional parameters:
|
|
61
|
+
* @param options.packageManagers An array of package managers to include in the message. Defaults to \["npm", "pnpm", "yarn"\].
|
|
62
|
+
* @param options.postMessage A string to append to the end of the message.
|
|
63
|
+
* @param options.preMessage A string to prepend to the beginning of the message.
|
|
64
|
+
* @returns A string message with instructions to install the missing packages using the specified package managers.
|
|
65
|
+
* @throws An `Error` if no package managers are provided in the options.
|
|
66
|
+
*/
|
|
67
|
+
export declare const generateMissingPackagesInstallMessage: (packageName: string, missingPackages: string[], options: {
|
|
16
68
|
packageManagers?: PackageManager[];
|
|
17
69
|
postMessage?: string;
|
|
18
70
|
preMessage?: string;
|
|
19
71
|
}) => string;
|
|
20
|
-
|
|
21
|
-
export { findLockFile, findLockFileSync, findPackageManager, findPackageManagerSync, generateMissingPackagesInstallMessage, getPackageManagerVersion, identifyInitiatingPackageManager };
|
|
22
|
-
export type { PackageManager, PackageManagerResult };
|
package/dist/package.d.ts
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
/**
|
|
2
|
+
* An asynchronous function that finds the root directory of a project based on certain lookup criteria.
|
|
3
|
+
* @param cwd Optional. The current working directory to start the search from. The type of `cwd` is `string`.
|
|
4
|
+
* @returns A `Promise` that resolves to the path of the root directory. The type of the returned promise is `Promise<string>`.
|
|
5
|
+
* @throws An `Error` if the root directory could not be found.
|
|
6
|
+
* @example
|
|
7
|
+
* const rootDirectory = await findPackageRoot();
|
|
8
|
+
* console.log(rootDirectory); // '/path/to/project'
|
|
9
|
+
*/
|
|
10
|
+
export declare const findPackageRoot: (cwd?: URL | string) => Promise<string>;
|
|
11
|
+
export declare const findPackageRootSync: (cwd?: URL | string) => string;
|
package/dist/pnpm.d.ts
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
import { JsonObject } from
|
|
2
|
-
|
|
3
|
-
type
|
|
4
|
-
type PnpmCatalogs = {
|
|
1
|
+
import type { JsonObject } from "type-fest";
|
|
2
|
+
export type PnpmCatalog = Record<string, string>;
|
|
3
|
+
export type PnpmCatalogs = {
|
|
5
4
|
catalog?: PnpmCatalog;
|
|
6
5
|
catalogs?: Record<string, PnpmCatalog>;
|
|
7
6
|
};
|
|
8
|
-
|
|
9
|
-
declare const
|
|
10
|
-
|
|
11
|
-
declare const
|
|
12
|
-
|
|
13
|
-
declare const
|
|
14
|
-
|
|
15
|
-
export
|
|
16
|
-
|
|
7
|
+
/** Checks if a package directory is included in the workspace packages configuration. */
|
|
8
|
+
export declare const isPackageInWorkspace: (workspacePath: string, packagePath: string, workspacePackages: string[]) => boolean;
|
|
9
|
+
/** Reads, parses, and resolves catalogs from a pnpm-workspace file found by walking up the directory tree. */
|
|
10
|
+
export declare const readPnpmCatalogs: (packagePath: string) => Promise<PnpmCatalogs | undefined>;
|
|
11
|
+
/** Reads, parses, and resolves catalogs from a pnpm-workspace file found by walking up the directory tree (synchronous). */
|
|
12
|
+
export declare const readPnpmCatalogsSync: (packagePath: string) => PnpmCatalogs | undefined;
|
|
13
|
+
/** Resolves a single catalog reference to its actual version. */
|
|
14
|
+
export declare const resolveCatalogReference: (packageName: string, versionSpec: string, catalogs: PnpmCatalogs) => string | undefined;
|
|
15
|
+
/** Resolves catalog references in a single dependency object. */
|
|
16
|
+
export declare const resolveDependenciesCatalogReferences: (dependencies: Record<string, string>, catalogs: PnpmCatalogs) => void;
|
|
17
|
+
/** Resolves catalog references in package.json dependencies using the provided catalogs. */
|
|
18
|
+
export declare const resolveCatalogReferences: (packageJson: JsonObject, catalogs: PnpmCatalogs) => void;
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { InstallPackageOptions } from "@antfu/install-pkg";
|
|
2
|
+
import type { Theme } from "@inquirer/core";
|
|
3
|
+
import type { PartialDeep } from "@inquirer/type";
|
|
4
|
+
import type { Package as normalizePackage } from "normalize-package-data";
|
|
5
|
+
import type { PackageJson as typeFestPackageJson } from "type-fest";
|
|
6
|
+
export type NormalizedPackageJson = normalizePackage & PackageJson;
|
|
7
|
+
export type PackageJson = typeFestPackageJson;
|
|
8
|
+
export type Cache<T = any> = Map<string, T>;
|
|
9
|
+
export type EnsurePackagesOptions = {
|
|
10
|
+
/** Configuration for user confirmation prompts when installing packages */
|
|
11
|
+
confirm?: {
|
|
12
|
+
/** Default value for the confirmation prompt */
|
|
13
|
+
default?: boolean;
|
|
14
|
+
/** Message to display in the confirmation prompt, or a function that receives packages array */
|
|
15
|
+
message: string | ((packages: string[]) => string);
|
|
16
|
+
/** Theme configuration for the prompt interface */
|
|
17
|
+
theme?: PartialDeep<Theme>;
|
|
18
|
+
/** Function to transform the boolean value for display */
|
|
19
|
+
transformer?: (value: boolean) => string;
|
|
20
|
+
};
|
|
21
|
+
/** Current working directory for package operations */
|
|
22
|
+
cwd?: URL | string;
|
|
23
|
+
/** Whether to include regular dependencies in the operation */
|
|
24
|
+
deps?: boolean;
|
|
25
|
+
/** Whether to include development dependencies in the operation */
|
|
26
|
+
devDeps?: boolean;
|
|
27
|
+
/** Additional options for package installation (excluding cwd and dev which are handled separately) */
|
|
28
|
+
installPackage?: Omit<InstallPackageOptions, "cwd" | "dev">;
|
|
29
|
+
/** Custom logger interface for warning messages */
|
|
30
|
+
logger?: {
|
|
31
|
+
warn: (message: string) => void;
|
|
32
|
+
};
|
|
33
|
+
/** Whether to include peer dependencies in the operation */
|
|
34
|
+
peerDeps?: boolean;
|
|
35
|
+
/** Whether to throw an error when warnings are logged instead of just logging them */
|
|
36
|
+
throwOnWarn?: boolean;
|
|
37
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@visulima/package",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.6",
|
|
4
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",
|
|
@@ -97,12 +97,11 @@
|
|
|
97
97
|
],
|
|
98
98
|
"dependencies": {
|
|
99
99
|
"@antfu/install-pkg": "^1.1.0",
|
|
100
|
-
"@inquirer/confirm": "^5.1.
|
|
101
|
-
"@visulima/fs": "4.0.
|
|
102
|
-
"@visulima/path": "2.0.
|
|
100
|
+
"@inquirer/confirm": "^5.1.20",
|
|
101
|
+
"@visulima/fs": "4.0.6",
|
|
102
|
+
"@visulima/path": "2.0.5",
|
|
103
103
|
"json5": "^2.2.3",
|
|
104
104
|
"normalize-package-data": "^8.0.0",
|
|
105
|
-
"type-fest": "^5.2.0",
|
|
106
105
|
"yaml": "^2.8.1"
|
|
107
106
|
},
|
|
108
107
|
"engines": {
|
|
@@ -1,232 +0,0 @@
|
|
|
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 };
|