@visulima/package 5.0.0-alpha.10 → 5.0.0-alpha.12
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 +25 -0
- package/dist/error.d.ts +15 -1
- package/dist/index.d.ts +13 -13
- package/dist/lockfile.d.ts +98 -97
- package/dist/lockfile.js +1 -4
- package/dist/monorepo.d.ts +23 -22
- package/dist/package-json.d.ts +7 -138
- package/dist/package-manager.d.ts +62 -61
- package/dist/package.d.ts +11 -10
- package/dist/packem_shared/package-json.d-R9WIRfmM.d.ts +173 -0
- package/dist/pnpm.d.ts +12 -11
- package/package.json +12 -13
- package/dist/error/package-not-found-error.d.ts +0 -15
- package/dist/types.d.ts +0 -37
- package/dist/utils/confirm.d.ts +0 -11
- package/dist/utils/is-node.d.ts +0 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,28 @@
|
|
|
1
|
+
## @visulima/package [5.0.0-alpha.12](https://github.com/visulima/visulima/compare/@visulima/package@5.0.0-alpha.11...@visulima/package@5.0.0-alpha.12) (2026-05-04)
|
|
2
|
+
|
|
3
|
+
### Miscellaneous Chores
|
|
4
|
+
|
|
5
|
+
* **package:** upgrade packem to 2.0.0-alpha.76 ([b2ef62b](https://github.com/visulima/visulima/commit/b2ef62b72a84545cb025a250cbe7e3e36b34330d))
|
|
6
|
+
* re-sort workspace package.json files via vis sort-package-json ([f625696](https://github.com/visulima/visulima/commit/f625696cfac974325774b3243e1a83c3d23acbd7))
|
|
7
|
+
* simplify pnpm-workspace packages list ([7cab221](https://github.com/visulima/visulima/commit/7cab221163632d9b7aa044a6f88c49083103a869))
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Dependencies
|
|
11
|
+
|
|
12
|
+
* **@visulima/fs:** upgraded to 5.0.0-alpha.13
|
|
13
|
+
|
|
14
|
+
## @visulima/package [5.0.0-alpha.11](https://github.com/visulima/visulima/compare/@visulima/package@5.0.0-alpha.10...@visulima/package@5.0.0-alpha.11) (2026-04-22)
|
|
15
|
+
|
|
16
|
+
### Bug Fixes
|
|
17
|
+
|
|
18
|
+
* Remove JSR configuration generation script and generated jsr.json files ([#616](https://github.com/visulima/visulima/issues/616)) ([533744b](https://github.com/visulima/visulima/commit/533744b103b74896941db5b727173e617a27a63b))
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### Dependencies
|
|
22
|
+
|
|
23
|
+
* **@visulima/fs:** upgraded to 5.0.0-alpha.12
|
|
24
|
+
* **@visulima/path:** upgraded to 3.0.0-alpha.10
|
|
25
|
+
|
|
1
26
|
## @visulima/package [5.0.0-alpha.10](https://github.com/visulima/visulima/compare/@visulima/package@5.0.0-alpha.9...@visulima/package@5.0.0-alpha.10) (2026-04-21)
|
|
2
27
|
|
|
3
28
|
### Miscellaneous Chores
|
package/dist/error.d.ts
CHANGED
|
@@ -1 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Error thrown when a package was not found.
|
|
3
|
+
*/
|
|
4
|
+
declare class PackageNotFoundError extends Error {
|
|
5
|
+
/**
|
|
6
|
+
* @param packageName The name of the package that was not found.
|
|
7
|
+
* @param packageManager The package manager used to install the package.
|
|
8
|
+
*/
|
|
9
|
+
constructor(packageName: string[] | string, packageManager?: string);
|
|
10
|
+
get code(): string;
|
|
11
|
+
set code(_name: string);
|
|
12
|
+
override get name(): string;
|
|
13
|
+
override set name(_name: string);
|
|
14
|
+
}
|
|
15
|
+
export { PackageNotFoundError };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export type
|
|
3
|
-
export {
|
|
4
|
-
export
|
|
5
|
-
export {
|
|
6
|
-
export {
|
|
7
|
-
export type
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
export { PackageNotFoundError } from "./error.js";
|
|
2
|
+
export { type LockFileEntry, type LockFileIntegrity, type LockFileIntegrityAlgorithm, type LockFileParseResult, type LockFileType, decodeSriIntegrity, parseBunLockFile, parseLockFile, parseLockFileContent, parseLockFileSync, parseNpmLockFile, parsePnpmLockFile, parseYarnLockFile } from "./lockfile.js";
|
|
3
|
+
export { type RootMonorepo, type Strategy, findMonorepoRoot, findMonorepoRootSync } from "./monorepo.js";
|
|
4
|
+
export { findPackageRoot, findPackageRootSync } from "./package.js";
|
|
5
|
+
export { type E as EnsurePackagesOptions, type F as FindPackageJsonCache, type N as NormalizedPackageJson, type a as NormalizedReadResult, type P as PackageJson, e as ensurePackages, f as findPackageJson, b as findPackageJsonSync, g as getPackageJsonProperty, h as hasPackageJsonAnyDependency, c as hasPackageJsonProperty, p as parsePackageJson, d as parsePackageJsonSync, w as writePackageJson, i as writePackageJsonSync } from "./packem_shared/package-json.d-R9WIRfmM.js";
|
|
6
|
+
export { type PackageManager, type PackageManagerResult, findLockFile, findLockFileSync, findPackageManager, findPackageManagerSync, generateMissingPackagesInstallMessage, getPackageManagerVersion, identifyInitiatingPackageManager } from "./package-manager.js";
|
|
7
|
+
export { type PnpmCatalog, type PnpmCatalogs, isPackageInWorkspace, readPnpmCatalogs, readPnpmCatalogsSync, resolveCatalogReference, resolveCatalogReferences, resolveDependenciesCatalogReferences } from "./pnpm.js";
|
|
8
|
+
import '@visulima/fs';
|
|
9
|
+
import 'type-fest';
|
|
10
|
+
import '@antfu/install-pkg';
|
|
11
|
+
import '@inquirer/core';
|
|
12
|
+
import '@inquirer/type';
|
|
13
|
+
import 'normalize-package-data';
|
package/dist/lockfile.d.ts
CHANGED
|
@@ -1,113 +1,114 @@
|
|
|
1
1
|
/** Lockfiles the parser recognises. Legacy binary `bun.lockb` is unsupported. */
|
|
2
|
-
|
|
2
|
+
type LockFileType = "bun" | "npm" | "pnpm" | "yarn";
|
|
3
3
|
/** SRI algorithms the parser can decode into hex. */
|
|
4
|
-
|
|
4
|
+
type LockFileIntegrityAlgorithm = "sha256" | "sha384" | "sha512";
|
|
5
5
|
/** Decoded integrity digest: algorithm + lowercase hex string. */
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
interface LockFileIntegrity {
|
|
7
|
+
algorithm: LockFileIntegrityAlgorithm;
|
|
8
|
+
hex: string;
|
|
9
9
|
}
|
|
10
10
|
/** A single resolved package extracted from a lockfile. */
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
11
|
+
interface LockFileEntry {
|
|
12
|
+
/**
|
|
13
|
+
* Declared runtime dependencies — `name → specifier[]` map. Values
|
|
14
|
+
* are arrays so pnpm v9+ peer-context variants (the same dep name
|
|
15
|
+
* resolved to different versions under different peer contexts)
|
|
16
|
+
* can all be preserved. npm, yarn v1, bun, and pnpm v6-v8 always
|
|
17
|
+
* produce single-element arrays; pnpm v9+ may produce multi-element
|
|
18
|
+
* arrays for peer-context-sensitive deps.
|
|
19
|
+
*
|
|
20
|
+
* Specifiers are whatever the lockfile recorded — a range
|
|
21
|
+
* (`^1.0.0`) for npm / yarn / bun, or an already-resolved exact
|
|
22
|
+
* version for pnpm. Callers resolve each specifier against
|
|
23
|
+
* {@link LockFileEntry.version} values elsewhere in the lockfile
|
|
24
|
+
* when they need a concrete edge.
|
|
25
|
+
*/
|
|
26
|
+
dependencies?: Record<string, string[]>;
|
|
27
|
+
/** Decoded SRI digest, if the lockfile recorded one. */
|
|
28
|
+
integrity?: LockFileIntegrity;
|
|
29
|
+
/** Package name — `lodash` or `@scope/name`. */
|
|
30
|
+
name: string;
|
|
31
|
+
/** Declared optional dependencies, same shape as `dependencies`. */
|
|
32
|
+
optionalDependencies?: Record<string, string[]>;
|
|
33
|
+
/** Declared peer dependencies, same shape as `dependencies`. */
|
|
34
|
+
peerDependencies?: Record<string, string[]>;
|
|
35
|
+
/** Resolved exact version — e.g. `4.17.21`. */
|
|
36
|
+
version: string;
|
|
37
37
|
}
|
|
38
38
|
/** Result of locating + parsing a lockfile on disk. */
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
39
|
+
interface LockFileParseResult {
|
|
40
|
+
entries: LockFileEntry[];
|
|
41
|
+
/** Absolute path of the lockfile that was parsed. */
|
|
42
|
+
path: string;
|
|
43
|
+
type: LockFileType;
|
|
44
44
|
}
|
|
45
45
|
/**
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
46
|
+
* Decodes a Subresource Integrity string (`sha512-<base64>`) into a
|
|
47
|
+
* `{ algorithm, hex }` pair. Returns `undefined` if the string is
|
|
48
|
+
* malformed, oversized, or uses an unsupported algorithm.
|
|
49
|
+
* @param sri Full SRI string, e.g. `sha512-<base64>`.
|
|
50
|
+
* @returns Decoded algorithm + hex digest, or `undefined` when the
|
|
51
|
+
* input can't be parsed.
|
|
52
|
+
*/
|
|
53
|
+
declare const decodeSriIntegrity: (sri: string) => LockFileIntegrity | undefined;
|
|
54
54
|
/**
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
55
|
+
* Parses `package-lock.json` (npm v2 / v3 format).
|
|
56
|
+
* @param content Raw JSON text of the lockfile.
|
|
57
|
+
* @returns One {@link LockFileEntry} per distinct `name@version`.
|
|
58
|
+
*/
|
|
59
|
+
declare const parseNpmLockFile: (content: string) => LockFileEntry[];
|
|
60
60
|
/**
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
61
|
+
* Parses `pnpm-lock.yaml`. Regex-based; works for lockfile v6 through
|
|
62
|
+
* v9. v9 moves concrete resolved dependency versions out of `packages:`
|
|
63
|
+
* and into `snapshots:`; this parser reads both sections and unions
|
|
64
|
+
* their dep-maps onto the final entry.
|
|
65
|
+
* @param content Raw YAML text of the lockfile.
|
|
66
|
+
* @returns One {@link LockFileEntry} per distinct `name@version`.
|
|
67
|
+
*/
|
|
68
|
+
declare const parsePnpmLockFile: (content: string) => LockFileEntry[];
|
|
69
69
|
/**
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
70
|
+
* Parses `yarn.lock` for Yarn Classic (v1) and Berry (v2+). Berry's
|
|
71
|
+
* XXH64 `checksum:` is not a cryptographic hash and is intentionally
|
|
72
|
+
* dropped; only v1's SRI `integrity:` flows through to
|
|
73
|
+
* {@link LockFileEntry.integrity}.
|
|
74
|
+
* @param content Raw text of the lockfile.
|
|
75
|
+
* @returns One {@link LockFileEntry} per distinct `name@version`.
|
|
76
|
+
*/
|
|
77
|
+
declare const parseYarnLockFile: (content: string) => LockFileEntry[];
|
|
78
78
|
/**
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
79
|
+
* Parses `bun.lock` (Bun v1.1+, JSON-ish with trailing commas). The
|
|
80
|
+
* binary `bun.lockb` format is not supported.
|
|
81
|
+
*
|
|
82
|
+
* Attribution: format + tuple layout verified against lockparse
|
|
83
|
+
* (https://github.com/43081j/lockparse, MIT).
|
|
84
|
+
* @param content Raw text of the lockfile.
|
|
85
|
+
* @returns One {@link LockFileEntry} per distinct `name@version`.
|
|
86
|
+
*/
|
|
87
|
+
declare const parseBunLockFile: (content: string) => LockFileEntry[];
|
|
88
88
|
/**
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
89
|
+
* Parses raw lockfile content of the given type. Returns an empty
|
|
90
|
+
* array if the content is malformed or doesn't contain any package
|
|
91
|
+
* entries.
|
|
92
|
+
* @param content Raw text of the lockfile.
|
|
93
|
+
* @param type Which parser to dispatch to.
|
|
94
|
+
* @returns One {@link LockFileEntry} per distinct `name@version`.
|
|
95
|
+
*/
|
|
96
|
+
declare const parseLockFileContent: (content: string, type: LockFileType) => LockFileEntry[];
|
|
97
97
|
/**
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
98
|
+
* Walks up from `cwd`, locates the nearest supported lockfile, reads
|
|
99
|
+
* it, and returns the parsed entries alongside the lockfile type and
|
|
100
|
+
* absolute path.
|
|
101
|
+
* @param cwd Directory to start the search from. Defaults to
|
|
102
|
+
* `process.cwd()` (delegated to `findUp`).
|
|
103
|
+
* @returns The parsed result, keyed by the discovered lockfile path.
|
|
104
|
+
* @throws If no supported lockfile can be found above `cwd`.
|
|
105
|
+
*/
|
|
106
|
+
declare const parseLockFile: (cwd?: URL | string) => Promise<LockFileParseResult>;
|
|
107
107
|
/**
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
108
|
+
* Synchronous counterpart to {@link parseLockFile}.
|
|
109
|
+
* @param cwd Directory to start the search from.
|
|
110
|
+
* @returns The parsed result, keyed by the discovered lockfile path.
|
|
111
|
+
* @throws If no supported lockfile can be found above `cwd`.
|
|
112
|
+
*/
|
|
113
|
+
declare const parseLockFileSync: (cwd?: URL | string) => LockFileParseResult;
|
|
114
|
+
export { LockFileEntry, LockFileIntegrity, LockFileIntegrityAlgorithm, LockFileParseResult, LockFileType, decodeSriIntegrity, parseBunLockFile, parseLockFile, parseLockFileContent, parseLockFileSync, parseNpmLockFile, parsePnpmLockFile, parseYarnLockFile };
|
package/dist/lockfile.js
CHANGED
|
@@ -37,10 +37,7 @@ const QUOTE_PREFIX = /^['"]/;
|
|
|
37
37
|
const QUOTE_SUFFIX = /['"]$/;
|
|
38
38
|
const PNPM_SECTION_HEADER = /^[a-z][a-zA-Z0-9]*:\s*$/m;
|
|
39
39
|
const PNPM_INTEGRITY = /resolution:\s*\{[^}]*integrity:\s*([^,}\s]+)/;
|
|
40
|
-
const YARN_BLOCK = (
|
|
41
|
-
// eslint-disable-next-line sonarjs/slow-regex, sonarjs/regex-complexity, regexp/no-super-linear-backtracking
|
|
42
|
-
/^["']?((?:@[^/@"']+\/)?[^@"'\n]+)@[^"'\n]+["']?:?[\t\v\f\r \u00A0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]*\n((?:[\t ][^\n]*\n?)+)/gm
|
|
43
|
-
);
|
|
40
|
+
const YARN_BLOCK = /^["']?((?:@[^/@"']+\/)?[^@"'\n]+)@[^"'\n]+["']?:?[\t\v\f\r \u00A0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]*\n((?:[\t ][^\n]*\n?)+)/gm;
|
|
44
41
|
const YARN_VERSION = /^\s+version:?\s+"?([^"\n]+)"?/m;
|
|
45
42
|
const YARN_INTEGRITY = /^\s+integrity[\s:]+"?([^"\s]+)"?/m;
|
|
46
43
|
const decodeSriIntegrity = (sri) => {
|
package/dist/monorepo.d.ts
CHANGED
|
@@ -1,25 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
type Strategy = "lerna" | "npm" | "pnpm" | "turbo" | "yarn";
|
|
2
|
+
interface RootMonorepo<T extends Strategy = Strategy> {
|
|
3
|
+
path: string;
|
|
4
|
+
strategy: T;
|
|
5
5
|
}
|
|
6
6
|
/**
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
+
declare const findMonorepoRoot: (cwd?: URL | string) => Promise<RootMonorepo>;
|
|
16
16
|
/**
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
+
declare const findMonorepoRootSync: (cwd?: URL | string) => RootMonorepo;
|
|
26
|
+
export { RootMonorepo, Strategy, findMonorepoRoot, findMonorepoRootSync };
|
package/dist/package-json.d.ts
CHANGED
|
@@ -1,138 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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: (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';
|
|
@@ -1,70 +1,71 @@
|
|
|
1
1
|
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
+
declare const findLockFile: (cwd?: URL | string) => Promise<string>;
|
|
10
|
+
declare const findLockFileSync: (cwd?: URL | string) => string;
|
|
11
|
+
type PackageManager = "bun" | "npm" | "pnpm" | "yarn";
|
|
12
|
+
type PackageManagerResult = {
|
|
13
|
+
packageManager: PackageManager;
|
|
14
|
+
path: string;
|
|
15
15
|
};
|
|
16
16
|
/**
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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
|
+
declare const findPackageManager: (cwd?: URL | string) => Promise<PackageManagerResult>;
|
|
27
27
|
/**
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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
|
+
declare const findPackageManagerSync: (cwd?: URL | string) => PackageManagerResult;
|
|
38
38
|
/**
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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
|
+
declare const getPackageManagerVersion: (name: string) => string;
|
|
44
44
|
/**
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
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 An object containing the name and version of the package manager,
|
|
49
|
+
* or undefined if the package manager information cannot be determined.
|
|
50
|
+
*/
|
|
51
|
+
declare const identifyInitiatingPackageManager: () => {
|
|
52
|
+
name: PackageManager | "cnpm";
|
|
53
|
+
version: string;
|
|
54
54
|
} | undefined;
|
|
55
55
|
/**
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
56
|
+
* Function that generates a message to install missing packages.
|
|
57
|
+
* @param packageName The name of the package that requires the missing packages.
|
|
58
|
+
* @param missingPackages An array of missing package names.
|
|
59
|
+
* @param options An object containing optional parameters:
|
|
60
|
+
* @param options.packageManagers An array of package managers to include in the message. Defaults to \["npm", "pnpm", "yarn"\].
|
|
61
|
+
* @param options.postMessage A string to append to the end of the message.
|
|
62
|
+
* @param options.preMessage A string to prepend to the beginning of the message.
|
|
63
|
+
* @returns A string message with instructions to install the missing packages using the specified package managers.
|
|
64
|
+
* @throws An `Error` if no package managers are provided in the options.
|
|
65
|
+
*/
|
|
66
|
+
declare const generateMissingPackagesInstallMessage: (packageName: string, missingPackages: string[], options: {
|
|
67
|
+
packageManagers?: PackageManager[];
|
|
68
|
+
postMessage?: string;
|
|
69
|
+
preMessage?: string;
|
|
70
70
|
}) => string;
|
|
71
|
+
export { PackageManager, PackageManagerResult, findLockFile, findLockFileSync, findPackageManager, findPackageManagerSync, generateMissingPackagesInstallMessage, getPackageManagerVersion, identifyInitiatingPackageManager };
|
package/dist/package.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
+
declare const findPackageRoot: (cwd?: URL | string) => Promise<string>;
|
|
11
|
+
declare const findPackageRootSync: (cwd?: URL | string) => string;
|
|
12
|
+
export { findPackageRoot, findPackageRootSync };
|
|
@@ -0,0 +1,173 @@
|
|
|
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 { Theme } from '@inquirer/core';
|
|
5
|
+
import { PartialDeep } from '@inquirer/type';
|
|
6
|
+
import { Package } from 'normalize-package-data';
|
|
7
|
+
type NormalizedPackageJson = Package & PackageJson;
|
|
8
|
+
type PackageJson = PackageJson$1;
|
|
9
|
+
type Cache<T = unknown> = Map<string, T>;
|
|
10
|
+
type EnsurePackagesOptions = {
|
|
11
|
+
/** Configuration for user confirmation prompts when installing packages */
|
|
12
|
+
confirm?: {
|
|
13
|
+
/** Default value for the confirmation prompt */
|
|
14
|
+
default?: boolean;
|
|
15
|
+
/** Message to display in the confirmation prompt, or a function that receives packages array */
|
|
16
|
+
message: string | ((packages: string[]) => string);
|
|
17
|
+
/** Theme configuration for the prompt interface */
|
|
18
|
+
theme?: PartialDeep<Theme>;
|
|
19
|
+
/** Function to transform the boolean value for display */
|
|
20
|
+
transformer?: (value: boolean) => string;
|
|
21
|
+
};
|
|
22
|
+
/** Current working directory for package operations */
|
|
23
|
+
cwd?: URL | string;
|
|
24
|
+
/** Whether to include regular dependencies in the operation */
|
|
25
|
+
deps?: boolean;
|
|
26
|
+
/** Whether to include development dependencies in the operation */
|
|
27
|
+
devDeps?: boolean;
|
|
28
|
+
/** Additional options for package installation (excluding cwd and dev which are handled separately) */
|
|
29
|
+
installPackage?: Omit<InstallPackageOptions, "cwd" | "dev">;
|
|
30
|
+
/** Custom logger interface for warning messages */
|
|
31
|
+
logger?: {
|
|
32
|
+
warn: (message: string) => void;
|
|
33
|
+
};
|
|
34
|
+
/** Whether to include peer dependencies in the operation */
|
|
35
|
+
peerDeps?: boolean;
|
|
36
|
+
/** Whether to throw an error when warnings are logged instead of just logging them */
|
|
37
|
+
throwOnWarn?: boolean;
|
|
38
|
+
};
|
|
39
|
+
type ReadOptions = {
|
|
40
|
+
cache?: FindPackageJsonCache | boolean;
|
|
41
|
+
ignoreWarnings?: (RegExp | string)[];
|
|
42
|
+
json5?: boolean;
|
|
43
|
+
resolveCatalogs?: boolean;
|
|
44
|
+
strict?: boolean;
|
|
45
|
+
yaml?: boolean;
|
|
46
|
+
};
|
|
47
|
+
type FindPackageJsonCache = Cache<NormalizedReadResult>;
|
|
48
|
+
type NormalizedReadResult = {
|
|
49
|
+
packageJson: NormalizedPackageJson;
|
|
50
|
+
path: string;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* An asynchronous function to find the package.json, package.yaml, or package.json5 file in the specified directory or its parent directories.
|
|
54
|
+
* @param cwd The current working directory.
|
|
55
|
+
* @param options Configuration options including yaml, json5, and resolveCatalogs flags.
|
|
56
|
+
* @returns A `Promise` that resolves to an object containing the parsed package data and the file path.
|
|
57
|
+
* The type of the returned promise is `Promise<NormalizedReadResult>`.
|
|
58
|
+
* @throws {Error} If no package file can be found or if strict mode is enabled and normalize warnings are thrown.
|
|
59
|
+
*/
|
|
60
|
+
declare const findPackageJson: (cwd?: URL | string, options?: ReadOptions) => Promise<NormalizedReadResult>;
|
|
61
|
+
/**
|
|
62
|
+
* A synchronous function to find the package.json, package.yaml, or package.json5 file in the specified directory or its parent directories.
|
|
63
|
+
* @param cwd The current working directory.
|
|
64
|
+
* @param options Configuration options including yaml, json5, and resolveCatalogs flags.
|
|
65
|
+
* @returns An object containing the parsed package data and the file path.
|
|
66
|
+
* @throws {Error} If no package file can be found or if strict mode is enabled and normalize warnings are thrown.
|
|
67
|
+
*/
|
|
68
|
+
declare const findPackageJsonSync: (cwd?: URL | string, options?: ReadOptions) => NormalizedReadResult;
|
|
69
|
+
/**
|
|
70
|
+
* An asynchronous function to write the package.json file with the given data.
|
|
71
|
+
* @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.
|
|
72
|
+
* @param options Optional. The options for writing the package.json. If not provided, an empty object will be used `{}`.
|
|
73
|
+
* This is an intersection type of `WriteJsonOptions` and a record with an optional `cwd` key which type is `Options["cwd"]`.
|
|
74
|
+
* `cwd` represents the current working directory. If not specified, the default working directory will be used.
|
|
75
|
+
* @returns A `Promise` that resolves once the package.json file has been written. The type of the returned promise is `Promise<void>`.
|
|
76
|
+
*/
|
|
77
|
+
declare const writePackageJson: (data: PackageJson, options?: WriteJsonOptions & {
|
|
78
|
+
cwd?: URL | string;
|
|
79
|
+
}) => Promise<void>;
|
|
80
|
+
declare const writePackageJsonSync: (data: PackageJson, options?: WriteJsonOptions & {
|
|
81
|
+
cwd?: URL | string;
|
|
82
|
+
}) => void;
|
|
83
|
+
/**
|
|
84
|
+
* A synchronous function to parse the package.json, package.yaml, or package.json5 file/object/string and return normalize the data.
|
|
85
|
+
* @param packageFile
|
|
86
|
+
* @param options
|
|
87
|
+
* @param options.cache Cache for parsed results (only applies to file paths)
|
|
88
|
+
* @param options.ignoreWarnings List of warning messages or patterns to skip in strict mode
|
|
89
|
+
* @param options.resolveCatalogs Whether to resolve pnpm catalog references
|
|
90
|
+
* @param options.strict Whether to throw errors on normalization warnings
|
|
91
|
+
* @param options.yaml Whether to enable package.yaml parsing (default: true)
|
|
92
|
+
* @param options.json5 Whether to enable package.json5 parsing (default: true)
|
|
93
|
+
* @returns
|
|
94
|
+
* @throws {Error} If the packageFile parameter is not an object or a string or if strict mode is enabled and normalize warnings are thrown.
|
|
95
|
+
*/
|
|
96
|
+
declare const parsePackageJsonSync: (packageFile: JsonObject | string, options?: {
|
|
97
|
+
cache?: Cache<NormalizedPackageJson> | boolean;
|
|
98
|
+
ignoreWarnings?: (RegExp | string)[];
|
|
99
|
+
json5?: boolean;
|
|
100
|
+
resolveCatalogs?: boolean;
|
|
101
|
+
strict?: boolean;
|
|
102
|
+
yaml?: boolean;
|
|
103
|
+
}) => NormalizedPackageJson;
|
|
104
|
+
/**
|
|
105
|
+
* An asynchronous function to parse the package.json, package.yaml, or package.json5 file/object/string and return normalize the data.
|
|
106
|
+
* @param packageFile
|
|
107
|
+
* @param options
|
|
108
|
+
* @param options.cache Cache for parsed results (only applies to file paths)
|
|
109
|
+
* @param options.ignoreWarnings List of warning messages or patterns to skip in strict mode
|
|
110
|
+
* @param options.strict Whether to throw errors on normalization warnings
|
|
111
|
+
* @param options.resolveCatalogs Whether to resolve pnpm catalog references
|
|
112
|
+
* @param options.yaml Whether to enable package.yaml parsing (default: true)
|
|
113
|
+
* @param options.json5 Whether to enable package.json5 parsing (default: true)
|
|
114
|
+
* @returns
|
|
115
|
+
* @throws {Error} If the packageFile parameter is not an object or a string or if strict mode is enabled and normalize warnings are thrown.
|
|
116
|
+
*/
|
|
117
|
+
declare const parsePackageJson: (packageFile: JsonObject | string, options?: {
|
|
118
|
+
cache?: Cache<NormalizedPackageJson> | boolean;
|
|
119
|
+
ignoreWarnings?: (RegExp | string)[];
|
|
120
|
+
json5?: boolean;
|
|
121
|
+
resolveCatalogs?: boolean;
|
|
122
|
+
strict?: boolean;
|
|
123
|
+
yaml?: boolean;
|
|
124
|
+
}) => Promise<NormalizedPackageJson>;
|
|
125
|
+
/**
|
|
126
|
+
* An asynchronous function to get the value of a property from the package.json file.
|
|
127
|
+
* @param packageJson
|
|
128
|
+
* @param property
|
|
129
|
+
* @param defaultValue
|
|
130
|
+
* @returns
|
|
131
|
+
*/
|
|
132
|
+
declare const getPackageJsonProperty: <T = unknown>(packageJson: NormalizedPackageJson, property: Paths<NormalizedPackageJson>, defaultValue?: T) => T;
|
|
133
|
+
/**
|
|
134
|
+
* An asynchronous function to check if a property exists in the package.json file.
|
|
135
|
+
* @param packageJson
|
|
136
|
+
* @param property
|
|
137
|
+
* @returns
|
|
138
|
+
*/
|
|
139
|
+
declare const hasPackageJsonProperty: (packageJson: NormalizedPackageJson, property: Paths<NormalizedPackageJson>) => boolean;
|
|
140
|
+
/**
|
|
141
|
+
* An asynchronous function to check if any of the specified dependencies exist in the package.json file.
|
|
142
|
+
* @param packageJson
|
|
143
|
+
* @param arguments_
|
|
144
|
+
* @param options
|
|
145
|
+
* @param options.peerDeps Whether to include peer dependencies
|
|
146
|
+
* @returns
|
|
147
|
+
*/
|
|
148
|
+
declare const hasPackageJsonAnyDependency: (packageJson: NormalizedPackageJson, arguments_: string[], options?: {
|
|
149
|
+
peerDeps?: boolean;
|
|
150
|
+
}) => boolean;
|
|
151
|
+
/**
|
|
152
|
+
* An asynchronous function to ensure that the specified packages are installed in the package.json file.
|
|
153
|
+
* If the packages are not installed, the user will be prompted to install them.
|
|
154
|
+
* If the user agrees, the packages will be installed.
|
|
155
|
+
* If the user declines, the function will return without installing the packages.
|
|
156
|
+
* If the user does not respond, the function will return without installing the packages.
|
|
157
|
+
* @param packageJson
|
|
158
|
+
* @param packages
|
|
159
|
+
* @param installKey
|
|
160
|
+
* @param options
|
|
161
|
+
* @param options.deps Whether to include regular dependencies
|
|
162
|
+
* @param options.devDeps Whether to include development dependencies
|
|
163
|
+
* @param options.peerDeps Whether to include peer dependencies
|
|
164
|
+
* @param options.throwOnWarn Whether to throw an error when warnings are logged instead of just logging them
|
|
165
|
+
* @param options.logger Whether to use a custom logger
|
|
166
|
+
* @param options.confirm Whether to use a custom confirmation prompt
|
|
167
|
+
* @param options.installPackage Whether to use a custom installation package
|
|
168
|
+
* @param options.cwd Whether to use a custom current working directory
|
|
169
|
+
* @param options.dev Whether to use a custom installation key
|
|
170
|
+
* @returns
|
|
171
|
+
*/
|
|
172
|
+
declare const ensurePackages: (packageJson: NormalizedPackageJson, packages: string[], installKey?: "dependencies" | "devDependencies", options?: EnsurePackagesOptions) => Promise<void>;
|
|
173
|
+
export { EnsurePackagesOptions as E, FindPackageJsonCache as F, NormalizedPackageJson as N, PackageJson as P, NormalizedReadResult as a, findPackageJsonSync as b, hasPackageJsonProperty as c, parsePackageJsonSync as d, ensurePackages as e, findPackageJson as f, getPackageJsonProperty as g, hasPackageJsonAnyDependency as h, writePackageJsonSync as i, parsePackageJson as p, writePackageJson as w };
|
package/dist/pnpm.d.ts
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { JsonObject } from 'type-fest';
|
|
2
|
+
type PnpmCatalog = Record<string, string>;
|
|
3
|
+
type PnpmCatalogs = {
|
|
4
|
+
catalog?: PnpmCatalog;
|
|
5
|
+
catalogs?: Record<string, PnpmCatalog>;
|
|
6
6
|
};
|
|
7
7
|
/** Checks if a package directory is included in the workspace packages configuration. */
|
|
8
|
-
|
|
8
|
+
declare const isPackageInWorkspace: (workspacePath: string, packagePath: string, workspacePackages: string[]) => boolean;
|
|
9
9
|
/** Reads, parses, and resolves catalogs from a pnpm-workspace file found by walking up the directory tree. */
|
|
10
|
-
|
|
10
|
+
declare const readPnpmCatalogs: (packagePath: string) => Promise<PnpmCatalogs | undefined>;
|
|
11
11
|
/** Reads, parses, and resolves catalogs from a pnpm-workspace file found by walking up the directory tree (synchronous). */
|
|
12
|
-
|
|
12
|
+
declare const readPnpmCatalogsSync: (packagePath: string) => PnpmCatalogs | undefined;
|
|
13
13
|
/** Resolves a single catalog reference to its actual version. */
|
|
14
|
-
|
|
14
|
+
declare const resolveCatalogReference: (packageName: string, versionSpec: string, catalogs: PnpmCatalogs) => string | undefined;
|
|
15
15
|
/** Resolves catalog references in a single dependency object. */
|
|
16
|
-
|
|
16
|
+
declare const resolveDependenciesCatalogReferences: (dependencies: Record<string, string>, catalogs: PnpmCatalogs) => void;
|
|
17
17
|
/** Resolves catalog references in package.json dependencies using the provided catalogs. */
|
|
18
|
-
|
|
18
|
+
declare const resolveCatalogReferences: (packageJson: JsonObject, catalogs: PnpmCatalogs) => void;
|
|
19
|
+
export { PnpmCatalog, PnpmCatalogs, isPackageInWorkspace, readPnpmCatalogs, readPnpmCatalogsSync, resolveCatalogReference, resolveCatalogReferences, resolveDependenciesCatalogReferences };
|
package/package.json
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@visulima/package",
|
|
3
|
-
"version": "5.0.0-alpha.
|
|
3
|
+
"version": "5.0.0-alpha.12",
|
|
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",
|
|
7
|
+
"bun",
|
|
7
8
|
"find",
|
|
8
9
|
"find-monorepo-root",
|
|
9
|
-
"find-up-pkg",
|
|
10
10
|
"find-package-manager",
|
|
11
|
+
"find-up-pkg",
|
|
12
|
+
"json5",
|
|
11
13
|
"mono-repo",
|
|
12
14
|
"monorepo",
|
|
15
|
+
"npm",
|
|
13
16
|
"package",
|
|
14
17
|
"package-json",
|
|
15
18
|
"package-manager",
|
|
16
19
|
"package.json",
|
|
17
|
-
"package.yaml",
|
|
18
20
|
"package.json5",
|
|
21
|
+
"package.yaml",
|
|
19
22
|
"packages",
|
|
20
23
|
"pkg-dir",
|
|
21
24
|
"pkg-manager",
|
|
22
25
|
"pkg-types",
|
|
23
26
|
"pkg-up",
|
|
27
|
+
"pnpm",
|
|
24
28
|
"read-pkg",
|
|
25
29
|
"read-pkg-up",
|
|
26
30
|
"root",
|
|
27
|
-
"
|
|
28
|
-
"bun",
|
|
29
|
-
"npm",
|
|
30
|
-
"yarn",
|
|
31
|
+
"visulima",
|
|
31
32
|
"yaml",
|
|
32
|
-
"
|
|
33
|
-
"visulima"
|
|
33
|
+
"yarn"
|
|
34
34
|
],
|
|
35
35
|
"homepage": "https://visulima.com/packages/package/",
|
|
36
36
|
"bugs": {
|
|
@@ -101,12 +101,11 @@
|
|
|
101
101
|
],
|
|
102
102
|
"dependencies": {
|
|
103
103
|
"@antfu/install-pkg": "^1.1.0",
|
|
104
|
-
"@visulima/fs": "5.0.0-alpha.
|
|
105
|
-
"@visulima/path": "3.0.0-alpha.
|
|
104
|
+
"@visulima/fs": "5.0.0-alpha.13",
|
|
105
|
+
"@visulima/path": "3.0.0-alpha.10",
|
|
106
106
|
"json5": "^2.2.3",
|
|
107
107
|
"normalize-package-data": "^8.0.0",
|
|
108
|
-
"
|
|
109
|
-
"yaml": "2.8.3"
|
|
108
|
+
"yaml": "2.8.4"
|
|
110
109
|
},
|
|
111
110
|
"engines": {
|
|
112
111
|
"node": "^22.14.0 || >=24.10.0"
|
|
@@ -1,15 +0,0 @@
|
|
|
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/types.d.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
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 = unknown> = 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/dist/utils/confirm.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { EnsurePackagesOptions } from "../types.d.ts";
|
|
2
|
-
type ConfirmOptions = EnsurePackagesOptions["confirm"] & {
|
|
3
|
-
message: string;
|
|
4
|
-
};
|
|
5
|
-
/**
|
|
6
|
-
* Creates a styled confirmation prompt using readline.
|
|
7
|
-
* @param options Configuration options for the confirmation prompt
|
|
8
|
-
* @returns A promise that resolves to true if confirmed, false otherwise
|
|
9
|
-
*/
|
|
10
|
-
declare const confirm: (options: ConfirmOptions) => Promise<boolean>;
|
|
11
|
-
export default confirm;
|
package/dist/utils/is-node.d.ts
DELETED