@visulima/package 5.0.0-alpha.9 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,13 +1,13 @@
1
- export { default as PackageNotFoundError } from "./error/package-not-found-error.d.ts";
2
- export type { LockFileEntry, LockFileIntegrity, LockFileIntegrityAlgorithm, LockFileParseResult, LockFileType } from "./lockfile.d.ts";
3
- export { decodeSriIntegrity, parseBunLockFile, parseLockFile, parseLockFileContent, parseLockFileSync, parseNpmLockFile, parsePnpmLockFile, parseYarnLockFile, } from "./lockfile.d.ts";
4
- export type { RootMonorepo, Strategy } from "./monorepo.d.ts";
5
- export { findMonorepoRoot, findMonorepoRootSync } from "./monorepo.d.ts";
6
- export { findPackageRoot, findPackageRootSync } from "./package.d.ts";
7
- export type { FindPackageJsonCache, NormalizedReadResult } from "./package-json.d.ts";
8
- export { ensurePackages, findPackageJson, findPackageJsonSync, getPackageJsonProperty, hasPackageJsonAnyDependency, hasPackageJsonProperty, parsePackageJson, parsePackageJsonSync, writePackageJson, writePackageJsonSync, } from "./package-json.d.ts";
9
- export type { PackageManager, PackageManagerResult } from "./package-manager.d.ts";
10
- export { findLockFile, findLockFileSync, findPackageManager, findPackageManagerSync, generateMissingPackagesInstallMessage, getPackageManagerVersion, identifyInitiatingPackageManager, } from "./package-manager.d.ts";
11
- export type { PnpmCatalog, PnpmCatalogs } from "./pnpm.d.ts";
12
- export { isPackageInWorkspace, readPnpmCatalogs, readPnpmCatalogsSync, resolveCatalogReference, resolveCatalogReferences, resolveDependenciesCatalogReferences, } from "./pnpm.d.ts";
13
- export type { EnsurePackagesOptions, NormalizedPackageJson, PackageJson } from "./types.d.ts";
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, c as clearPackageJsonCache, e as ensurePackages, f as findPackageJson, b as findPackageJsonSync, g as getPackageJsonProperty, h as hasPackageJsonAnyDependency, d as hasPackageJsonProperty, p as parsePackageJson, i as parsePackageJsonSync, w as writePackageJson, j as writePackageJsonSync } from "./packem_shared/package-json.d-BHWsl_Em.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/index.js CHANGED
@@ -1,7 +1 @@
1
- export { default as PackageNotFoundError } from './packem_shared/PackageNotFoundError-C0ltLzw7.js';
2
- export { decodeSriIntegrity, parseBunLockFile, parseLockFile, parseLockFileContent, parseLockFileSync, parseNpmLockFile, parsePnpmLockFile, parseYarnLockFile } from './lockfile.js';
3
- export { findMonorepoRoot, findMonorepoRootSync } from './monorepo.js';
4
- export { findPackageRoot, findPackageRootSync } from './package.js';
5
- export { ensurePackages, findPackageJson, findPackageJsonSync, getPackageJsonProperty, hasPackageJsonAnyDependency, hasPackageJsonProperty, parsePackageJson, parsePackageJsonSync, writePackageJson, writePackageJsonSync } from './package-json.js';
6
- export { findLockFile, findLockFileSync, findPackageManager, findPackageManagerSync, generateMissingPackagesInstallMessage, getPackageManagerVersion, identifyInitiatingPackageManager } from './package-manager.js';
7
- export { isPackageInWorkspace, readPnpmCatalogs, readPnpmCatalogsSync, resolveCatalogReference, resolveCatalogReferences, resolveDependenciesCatalogReferences } from './pnpm.js';
1
+ import{default as o}from"./packem_shared/PackageNotFoundError-Bi41exhP.js";import{decodeSriIntegrity as r,parseBunLockFile as c,parseLockFile as s,parseLockFileContent as g,parseLockFileSync as i,parseNpmLockFile as t,parsePnpmLockFile as k,parseYarnLockFile as p}from"./lockfile.js";import{findMonorepoRoot as f,findMonorepoRootSync as l}from"./monorepo.js";import{findPackageRoot as y,findPackageRootSync as m}from"./package.js";import{clearPackageJsonCache as J,ensurePackages as S,findPackageJson as L,findPackageJsonSync as M,getPackageJsonProperty as x,hasPackageJsonAnyDependency as C,hasPackageJsonProperty as R,parsePackageJson as u,parsePackageJsonSync as I,writePackageJson as h,writePackageJsonSync as v}from"./package-json.js";import{findLockFile as D,findLockFileSync as N,findPackageManager as A,findPackageManagerSync as B,generateMissingPackagesInstallMessage as E,getPackageManagerVersion as V,identifyInitiatingPackageManager as W}from"./package-manager.js";import{isPackageInWorkspace as b,readPnpmCatalogs as j,readPnpmCatalogsSync as q,resolveCatalogReference as z,resolveCatalogReferences as G,resolveDependenciesCatalogReferences as H}from"./pnpm.js";export{o as PackageNotFoundError,J as clearPackageJsonCache,r as decodeSriIntegrity,S as ensurePackages,D as findLockFile,N as findLockFileSync,f as findMonorepoRoot,l as findMonorepoRootSync,L as findPackageJson,M as findPackageJsonSync,A as findPackageManager,B as findPackageManagerSync,y as findPackageRoot,m as findPackageRootSync,E as generateMissingPackagesInstallMessage,x as getPackageJsonProperty,V as getPackageManagerVersion,C as hasPackageJsonAnyDependency,R as hasPackageJsonProperty,W as identifyInitiatingPackageManager,b as isPackageInWorkspace,c as parseBunLockFile,s as parseLockFile,g as parseLockFileContent,i as parseLockFileSync,t as parseNpmLockFile,u as parsePackageJson,I as parsePackageJsonSync,k as parsePnpmLockFile,p as parseYarnLockFile,j as readPnpmCatalogs,q as readPnpmCatalogsSync,z as resolveCatalogReference,G as resolveCatalogReferences,H as resolveDependenciesCatalogReferences,h as writePackageJson,v as writePackageJsonSync};
@@ -1,113 +1,120 @@
1
- /** Lockfiles the parser recognises. Legacy binary `bun.lockb` is unsupported. */
2
- export type LockFileType = "bun" | "npm" | "pnpm" | "yarn";
1
+ /**
2
+ * Lockfiles the parser recognises. Both the modern text `bun.lock` and the
3
+ * legacy binary `bun.lockb` map to the `bun` type, but only `bun.lock`
4
+ * content is parseable — `bun.lockb` is a binary format and yields no entries.
5
+ */
6
+ type LockFileType = "bun" | "npm" | "pnpm" | "yarn";
3
7
  /** SRI algorithms the parser can decode into hex. */
4
- export type LockFileIntegrityAlgorithm = "sha256" | "sha384" | "sha512";
8
+ type LockFileIntegrityAlgorithm = "sha256" | "sha384" | "sha512";
5
9
  /** Decoded integrity digest: algorithm + lowercase hex string. */
6
- export interface LockFileIntegrity {
7
- algorithm: LockFileIntegrityAlgorithm;
8
- hex: string;
10
+ interface LockFileIntegrity {
11
+ algorithm: LockFileIntegrityAlgorithm;
12
+ hex: string;
9
13
  }
10
14
  /** A single resolved package extracted from a lockfile. */
11
- export 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;
15
+ interface LockFileEntry {
16
+ /**
17
+ * Declared runtime dependencies — `name → specifier[]` map. Values
18
+ * are arrays so pnpm v9+ peer-context variants (the same dep name
19
+ * resolved to different versions under different peer contexts)
20
+ * can all be preserved. npm, yarn v1, bun, and pnpm v6-v8 always
21
+ * produce single-element arrays; pnpm v9+ may produce multi-element
22
+ * arrays for peer-context-sensitive deps.
23
+ *
24
+ * Specifiers are whatever the lockfile recorded — a range
25
+ * (`^1.0.0`) for npm / yarn / bun, or an already-resolved exact
26
+ * version for pnpm. Callers resolve each specifier against
27
+ * {@link LockFileEntry.version} values elsewhere in the lockfile
28
+ * when they need a concrete edge.
29
+ */
30
+ dependencies?: Record<string, string[]>;
31
+ /** Decoded SRI digest, if the lockfile recorded one. */
32
+ integrity?: LockFileIntegrity;
33
+ /** Package name — `lodash` or `@scope/name`. */
34
+ name: string;
35
+ /** Declared optional dependencies, same shape as `dependencies`. */
36
+ optionalDependencies?: Record<string, string[]>;
37
+ /** Declared peer dependencies, same shape as `dependencies`. */
38
+ peerDependencies?: Record<string, string[]>;
39
+ /** Resolved exact version — e.g. `4.17.21`. */
40
+ version: string;
37
41
  }
38
42
  /** Result of locating + parsing a lockfile on disk. */
39
- export interface LockFileParseResult {
40
- entries: LockFileEntry[];
41
- /** Absolute path of the lockfile that was parsed. */
42
- path: string;
43
- type: LockFileType;
43
+ interface LockFileParseResult {
44
+ entries: LockFileEntry[];
45
+ /** Absolute path of the lockfile that was parsed. */
46
+ path: string;
47
+ type: LockFileType;
44
48
  }
45
49
  /**
46
- * Decodes a Subresource Integrity string (`sha512-&lt;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-&lt;base64>`.
50
- * @returns Decoded algorithm + hex digest, or `undefined` when the
51
- * input can't be parsed.
52
- */
53
- export declare const decodeSriIntegrity: (sri: string) => LockFileIntegrity | undefined;
50
+ * Decodes a Subresource Integrity string (`sha512-&lt;base64>`) into a
51
+ * `{ algorithm, hex }` pair. Returns `undefined` if the string is
52
+ * malformed, oversized, or uses an unsupported algorithm.
53
+ * @param sri Full SRI string, e.g. `sha512-&lt;base64>`.
54
+ * @returns Decoded algorithm + hex digest, or `undefined` when the
55
+ * input can't be parsed.
56
+ */
57
+ declare const decodeSriIntegrity: (sri: string) => LockFileIntegrity | undefined;
54
58
  /**
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
- export declare const parseNpmLockFile: (content: string) => LockFileEntry[];
59
+ * Parses `package-lock.json` (npm v2 / v3 format).
60
+ * @param content Raw JSON text of the lockfile.
61
+ * @returns One {@link LockFileEntry} per distinct `name@version`.
62
+ */
63
+ declare const parseNpmLockFile: (content: string) => LockFileEntry[];
60
64
  /**
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
- export declare const parsePnpmLockFile: (content: string) => LockFileEntry[];
65
+ * Parses `pnpm-lock.yaml`. Regex-based; works for lockfile v6 through
66
+ * v9. v9 moves concrete resolved dependency versions out of `packages:`
67
+ * and into `snapshots:`; this parser reads both sections and unions
68
+ * their dep-maps onto the final entry.
69
+ * @param content Raw YAML text of the lockfile.
70
+ * @returns One {@link LockFileEntry} per distinct `name@version`.
71
+ */
72
+ declare const parsePnpmLockFile: (content: string) => LockFileEntry[];
69
73
  /**
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
- export declare const parseYarnLockFile: (content: string) => LockFileEntry[];
74
+ * Parses `yarn.lock` for Yarn Classic (v1) and Berry (v2+). Berry's
75
+ * XXH64 `checksum:` is not a cryptographic hash and is intentionally
76
+ * dropped; only v1's SRI `integrity:` flows through to
77
+ * {@link LockFileEntry.integrity}.
78
+ * @param content Raw text of the lockfile.
79
+ * @returns One {@link LockFileEntry} per distinct `name@version`.
80
+ */
81
+ declare const parseYarnLockFile: (content: string) => LockFileEntry[];
78
82
  /**
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
- export declare const parseBunLockFile: (content: string) => LockFileEntry[];
83
+ * Parses `bun.lock` (Bun v1.1+, JSON-ish with trailing commas). The
84
+ * legacy binary `bun.lockb` format is recognised by {@link inferLockFileType}
85
+ * but cannot be decoded here — feeding its binary contents in returns an
86
+ * empty array (the `JSON.parse` fails and is swallowed).
87
+ *
88
+ * Attribution: format + tuple layout verified against lockparse
89
+ * (https://github.com/43081j/lockparse, MIT).
90
+ * @param content Raw text of the lockfile.
91
+ * @returns One {@link LockFileEntry} per distinct `name@version`.
92
+ */
93
+ declare const parseBunLockFile: (content: string) => LockFileEntry[];
88
94
  /**
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
- export declare const parseLockFileContent: (content: string, type: LockFileType) => LockFileEntry[];
95
+ * Parses raw lockfile content of the given type. Returns an empty
96
+ * array if the content is malformed or doesn't contain any package
97
+ * entries.
98
+ * @param content Raw text of the lockfile.
99
+ * @param type Which parser to dispatch to.
100
+ * @returns One {@link LockFileEntry} per distinct `name@version`.
101
+ */
102
+ declare const parseLockFileContent: (content: string, type: LockFileType) => LockFileEntry[];
97
103
  /**
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
- export declare const parseLockFile: (cwd?: URL | string) => Promise<LockFileParseResult>;
104
+ * Walks up from `cwd`, locates the nearest supported lockfile, reads
105
+ * it, and returns the parsed entries alongside the lockfile type and
106
+ * absolute path.
107
+ * @param cwd Directory to start the search from. Defaults to
108
+ * `process.cwd()` (delegated to `findUp`).
109
+ * @returns The parsed result, keyed by the discovered lockfile path.
110
+ * @throws If no supported lockfile can be found above `cwd`.
111
+ */
112
+ declare const parseLockFile: (cwd?: URL | string) => Promise<LockFileParseResult>;
107
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
- export declare const parseLockFileSync: (cwd?: URL | string) => LockFileParseResult;
114
+ * Synchronous counterpart to {@link parseLockFile}.
115
+ * @param cwd Directory to start the search from.
116
+ * @returns The parsed result, keyed by the discovered lockfile path.
117
+ * @throws If no supported lockfile can be found above `cwd`.
118
+ */
119
+ declare const parseLockFileSync: (cwd?: URL | string) => LockFileParseResult;
120
+ export { LockFileEntry, LockFileIntegrity, LockFileIntegrityAlgorithm, LockFileParseResult, LockFileType, decodeSriIntegrity, parseBunLockFile, parseLockFile, parseLockFileContent, parseLockFileSync, parseNpmLockFile, parsePnpmLockFile, parseYarnLockFile };