@visulima/package 5.0.0-alpha.6 → 5.0.0-alpha.7
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 +22 -0
- package/dist/error.js +1 -1
- package/dist/index.js +1 -1
- package/dist/package-json.d.ts +2 -2
- package/dist/package-json.js +11 -10
- package/dist/package-manager.d.ts +4 -5
- package/dist/package-manager.js +6 -51
- package/dist/packem_shared/{PackageNotFoundError-CJmAqa_k.js → PackageNotFoundError-C0ltLzw7.js} +1 -3
- package/dist/types.d.ts +1 -1
- package/package.json +3 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,25 @@
|
|
|
1
|
+
## @visulima/package [5.0.0-alpha.7](https://github.com/visulima/visulima/compare/@visulima/package@5.0.0-alpha.6...@visulima/package@5.0.0-alpha.7) (2026-04-08)
|
|
2
|
+
|
|
3
|
+
### Bug Fixes
|
|
4
|
+
|
|
5
|
+
* **package:** properly fix eslint errors in code ([56b1547](https://github.com/visulima/visulima/commit/56b15474d6edd8f33fb46cca81fa34d600df2023))
|
|
6
|
+
* **package:** remove remaining eslint suppressions with proper code fixes ([69efa7a](https://github.com/visulima/visulima/commit/69efa7a9c67977c491a1ec8eaded733478ed29a1))
|
|
7
|
+
* **package:** resolve eslint errors ([1ec4728](https://github.com/visulima/visulima/commit/1ec47286cfcec55ea50c51d51f198b119dd22e71))
|
|
8
|
+
* resolve failing tests across multiple packages ([2b4b6f0](https://github.com/visulima/visulima/commit/2b4b6f04169b60fdc4cf77b293015436a272c0fb))
|
|
9
|
+
|
|
10
|
+
### Miscellaneous Chores
|
|
11
|
+
|
|
12
|
+
* **package:** add tsconfig.eslint.json for type-aware linting ([0355fea](https://github.com/visulima/visulima/commit/0355fea301fb7a8571da25bebd108830bc23ed04))
|
|
13
|
+
* **package:** apply prettier formatting ([ebb5bd1](https://github.com/visulima/visulima/commit/ebb5bd12c6b7d49811c68ea96bf62ce7e2a7d42d))
|
|
14
|
+
* **package:** migrate .prettierrc.cjs to prettier.config.js ([2b84ef0](https://github.com/visulima/visulima/commit/2b84ef0db67467e1360b2f1e6f9b6e96bf3dbbb0))
|
|
15
|
+
* **tooling:** remove empty dependency objects from package.json ([dc52a23](https://github.com/visulima/visulima/commit/dc52a23bc1e2d36f4ec71ca67506bf6861a02929))
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Dependencies
|
|
19
|
+
|
|
20
|
+
* **@visulima/fs:** upgraded to 5.0.0-alpha.7
|
|
21
|
+
* **@visulima/path:** upgraded to 3.0.0-alpha.8
|
|
22
|
+
|
|
1
23
|
## @visulima/package [5.0.0-alpha.6](https://github.com/visulima/visulima/compare/@visulima/package@5.0.0-alpha.5...@visulima/package@5.0.0-alpha.6) (2026-03-26)
|
|
2
24
|
|
|
3
25
|
### Features
|
package/dist/error.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { default as PackageNotFoundError } from './packem_shared/PackageNotFoundError-
|
|
1
|
+
export { default as PackageNotFoundError } from './packem_shared/PackageNotFoundError-C0ltLzw7.js';
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { default as PackageNotFoundError } from './packem_shared/PackageNotFoundError-
|
|
1
|
+
export { default as PackageNotFoundError } from './packem_shared/PackageNotFoundError-C0ltLzw7.js';
|
|
2
2
|
export { findMonorepoRoot, findMonorepoRootSync } from './monorepo.js';
|
|
3
3
|
export { findPackageRoot, findPackageRootSync } from './package.js';
|
|
4
4
|
export { ensurePackages, findPackageJson, findPackageJsonSync, getPackageJsonProperty, hasPackageJsonAnyDependency, hasPackageJsonProperty, parsePackageJson, parsePackageJsonSync, writePackageJson, writePackageJsonSync } from './package-json.js';
|
package/dist/package-json.d.ts
CHANGED
|
@@ -39,10 +39,10 @@ export declare const findPackageJsonSync: (cwd?: URL | string, options?: ReadOpt
|
|
|
39
39
|
* `cwd` represents the current working directory. If not specified, the default working directory will be used.
|
|
40
40
|
* @returns A `Promise` that resolves once the package.json file has been written. The type of the returned promise is `Promise<void>`.
|
|
41
41
|
*/
|
|
42
|
-
export declare const writePackageJson:
|
|
42
|
+
export declare const writePackageJson: (data: PackageJson, options?: WriteJsonOptions & {
|
|
43
43
|
cwd?: URL | string;
|
|
44
44
|
}) => Promise<void>;
|
|
45
|
-
export declare const writePackageJsonSync:
|
|
45
|
+
export declare const writePackageJsonSync: (data: PackageJson, options?: WriteJsonOptions & {
|
|
46
46
|
cwd?: URL | string;
|
|
47
47
|
}) => void;
|
|
48
48
|
/**
|
package/dist/package-json.js
CHANGED
|
@@ -301,6 +301,7 @@ ${styleText(["gray"], "→")} ${formatAnswer(defaultValue)}`);
|
|
|
301
301
|
|
|
302
302
|
const isNode = typeof process.stdout < "u" && !process.versions.deno && !globalThis.window;
|
|
303
303
|
|
|
304
|
+
const LAST_SEPARATOR_REGEX = /, ([^,]*)$/;
|
|
304
305
|
const PackageJsonParseCache = /* @__PURE__ */ new Map();
|
|
305
306
|
const PackageJsonFileCache = /* @__PURE__ */ new Map();
|
|
306
307
|
class PackageJsonValidationError extends Error {
|
|
@@ -383,14 +384,14 @@ const findPackageJson = async (cwd, options = {}) => {
|
|
|
383
384
|
searchPatterns.push("package.json5");
|
|
384
385
|
}
|
|
385
386
|
let filePath;
|
|
386
|
-
for
|
|
387
|
+
for (const pattern of searchPatterns) {
|
|
387
388
|
filePath = await findUp(pattern, findUpConfig);
|
|
388
389
|
if (filePath) {
|
|
389
390
|
break;
|
|
390
391
|
}
|
|
391
392
|
}
|
|
392
393
|
if (!filePath) {
|
|
393
|
-
throw new NotFoundError(`No such file or directory, for ${searchPatterns.join(", ").replace(
|
|
394
|
+
throw new NotFoundError(`No such file or directory, for ${searchPatterns.join(", ").replace(LAST_SEPARATOR_REGEX, " or $1")} found.`);
|
|
394
395
|
}
|
|
395
396
|
const cache = options.cache && typeof options.cache !== "boolean" ? options.cache : PackageJsonFileCache;
|
|
396
397
|
if (options.cache && cache.has(filePath)) {
|
|
@@ -435,7 +436,7 @@ const findPackageJsonSync = (cwd, options = {}) => {
|
|
|
435
436
|
}
|
|
436
437
|
}
|
|
437
438
|
if (!filePath) {
|
|
438
|
-
throw new NotFoundError(`No such file or directory, for ${searchPatterns.join(", ").replace(
|
|
439
|
+
throw new NotFoundError(`No such file or directory, for ${searchPatterns.join(", ").replace(LAST_SEPARATOR_REGEX, " or $1")} found.`);
|
|
439
440
|
}
|
|
440
441
|
const cache = options.cache && typeof options.cache !== "boolean" ? options.cache : PackageJsonFileCache;
|
|
441
442
|
if (options.cache && cache.has(filePath)) {
|
|
@@ -469,7 +470,7 @@ const writePackageJsonSync = (data, options = {}) => {
|
|
|
469
470
|
writeJsonSync(join(directory, "package.json"), data, writeOptions);
|
|
470
471
|
};
|
|
471
472
|
const parsePackageJsonSync = (packageFile, options) => {
|
|
472
|
-
const isObject =
|
|
473
|
+
const isObject = typeof packageFile === "object" && !Array.isArray(packageFile);
|
|
473
474
|
const isString = typeof packageFile === "string";
|
|
474
475
|
if (!isObject && !isString) {
|
|
475
476
|
throw new TypeError("`packageFile` should be either an `object` or a `string`.");
|
|
@@ -502,14 +503,14 @@ const parsePackageJsonSync = (packageFile, options) => {
|
|
|
502
503
|
}
|
|
503
504
|
normalizeInput(json, options?.strict ?? false, options?.ignoreWarnings);
|
|
504
505
|
const result = json;
|
|
505
|
-
if (isFile &&
|
|
506
|
-
const cache =
|
|
506
|
+
if (isFile && options?.cache) {
|
|
507
|
+
const cache = typeof options.cache === "boolean" ? PackageJsonParseCache : options.cache;
|
|
507
508
|
cache.set(filePath, result);
|
|
508
509
|
}
|
|
509
510
|
return result;
|
|
510
511
|
};
|
|
511
512
|
const parsePackageJson = async (packageFile, options) => {
|
|
512
|
-
const isObject =
|
|
513
|
+
const isObject = typeof packageFile === "object" && !Array.isArray(packageFile);
|
|
513
514
|
const isString = typeof packageFile === "string";
|
|
514
515
|
if (!isObject && !isString) {
|
|
515
516
|
throw new TypeError("`packageFile` should be either an `object` or a `string`.");
|
|
@@ -542,8 +543,8 @@ const parsePackageJson = async (packageFile, options) => {
|
|
|
542
543
|
}
|
|
543
544
|
normalizeInput(json, options?.strict ?? false, options?.ignoreWarnings);
|
|
544
545
|
const result = json;
|
|
545
|
-
if (isFile &&
|
|
546
|
-
const cache =
|
|
546
|
+
if (isFile && options?.cache) {
|
|
547
|
+
const cache = typeof options.cache === "boolean" ? PackageJsonParseCache : options.cache;
|
|
547
548
|
cache.set(filePath, result);
|
|
548
549
|
}
|
|
549
550
|
return result;
|
|
@@ -582,7 +583,7 @@ const ensurePackages = async (packageJson, packages, installKey = "dependencies"
|
|
|
582
583
|
if (nonExistingPackages.length === 0) {
|
|
583
584
|
return;
|
|
584
585
|
}
|
|
585
|
-
if (process.env.CI || isNode && !process.stdout
|
|
586
|
+
if (process.env.CI || isNode && !process.stdout.isTTY) {
|
|
586
587
|
const message = `Skipping package installation for [${packages.join(", ")}] because the process is not interactive.`;
|
|
587
588
|
if (options.throwOnWarn) {
|
|
588
589
|
throw new Error(message);
|
|
@@ -45,14 +45,13 @@ export declare const getPackageManagerVersion: (name: string) => string;
|
|
|
45
45
|
* An asynchronous function that detects what package manager executes the process.
|
|
46
46
|
*
|
|
47
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
|
|
49
|
-
* or undefined if the package manager information cannot be determined.
|
|
50
|
-
* is `Promise<{ name: PackageManager | "cnpm"; version: string } | undefined>`.
|
|
48
|
+
* @returns An object containing the name and version of the package manager,
|
|
49
|
+
* or undefined if the package manager information cannot be determined.
|
|
51
50
|
*/
|
|
52
|
-
export declare const identifyInitiatingPackageManager: () =>
|
|
51
|
+
export declare const identifyInitiatingPackageManager: () => {
|
|
53
52
|
name: PackageManager | "cnpm";
|
|
54
53
|
version: string;
|
|
55
|
-
} | undefined
|
|
54
|
+
} | undefined;
|
|
56
55
|
/**
|
|
57
56
|
* Function that generates a message to install missing packages.
|
|
58
57
|
* @param packageName The name of the package that requires the missing packages.
|
package/dist/package-manager.js
CHANGED
|
@@ -27,7 +27,7 @@ const {
|
|
|
27
27
|
import { findUp, findUpSync } from '@visulima/fs';
|
|
28
28
|
import { NotFoundError } from '@visulima/fs/error';
|
|
29
29
|
import { join, dirname } from '@visulima/path';
|
|
30
|
-
import { parsePackageJsonSync
|
|
30
|
+
import { parsePackageJsonSync } from './package-json.js';
|
|
31
31
|
|
|
32
32
|
const lockFileNames = ["yarn.lock", "package-lock.json", "pnpm-lock.yaml", "npm-shrinkwrap.json", "bun.lockb"];
|
|
33
33
|
const packageMangerFindUpMatcher = (directory) => {
|
|
@@ -49,50 +49,7 @@ const packageMangerFindUpMatcher = (directory) => {
|
|
|
49
49
|
}
|
|
50
50
|
return void 0;
|
|
51
51
|
};
|
|
52
|
-
const
|
|
53
|
-
if (!foundFile) {
|
|
54
|
-
throw new NotFoundError("Could not find a package manager");
|
|
55
|
-
}
|
|
56
|
-
if (foundFile.endsWith("package.json")) {
|
|
57
|
-
const packageJson = await parsePackageJson(foundFile);
|
|
58
|
-
if (packageJson.packageManager) {
|
|
59
|
-
const packageManagerNames = ["npm", "yarn", "pnpm", "bun"];
|
|
60
|
-
const foundPackageManager = packageManagerNames.find((prefix) => packageJson.packageManager.startsWith(prefix));
|
|
61
|
-
if (foundPackageManager) {
|
|
62
|
-
return {
|
|
63
|
-
packageManager: foundPackageManager,
|
|
64
|
-
path: dirname(foundFile)
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
if (foundFile.endsWith("yarn.lock")) {
|
|
70
|
-
return {
|
|
71
|
-
packageManager: "yarn",
|
|
72
|
-
path: dirname(foundFile)
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
if (foundFile.endsWith("package-lock.json") || foundFile.endsWith("npm-shrinkwrap.json")) {
|
|
76
|
-
return {
|
|
77
|
-
packageManager: "npm",
|
|
78
|
-
path: dirname(foundFile)
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
if (foundFile.endsWith("pnpm-lock.yaml")) {
|
|
82
|
-
return {
|
|
83
|
-
packageManager: "pnpm",
|
|
84
|
-
path: dirname(foundFile)
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
if (foundFile.endsWith("bun.lockb")) {
|
|
88
|
-
return {
|
|
89
|
-
packageManager: "bun",
|
|
90
|
-
path: dirname(foundFile)
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
throw new NotFoundError("Could not find a package manager");
|
|
94
|
-
};
|
|
95
|
-
const findPackageManagerOnFileSync = (foundFile) => {
|
|
52
|
+
const resolvePackageManagerFromFile = (foundFile) => {
|
|
96
53
|
if (!foundFile) {
|
|
97
54
|
throw new NotFoundError("Could not find a package manager");
|
|
98
55
|
}
|
|
@@ -159,16 +116,16 @@ const findPackageManager = async (cwd) => {
|
|
|
159
116
|
const foundFile = await findUp(packageMangerFindUpMatcher, {
|
|
160
117
|
...cwd && { cwd }
|
|
161
118
|
});
|
|
162
|
-
return
|
|
119
|
+
return resolvePackageManagerFromFile(foundFile);
|
|
163
120
|
};
|
|
164
121
|
const findPackageManagerSync = (cwd) => {
|
|
165
122
|
const foundFile = findUpSync(packageMangerFindUpMatcher, {
|
|
166
123
|
...cwd && { cwd }
|
|
167
124
|
});
|
|
168
|
-
return
|
|
125
|
+
return resolvePackageManagerFromFile(foundFile);
|
|
169
126
|
};
|
|
170
127
|
const getPackageManagerVersion = (name) => execSync(`${name} --version`).toString("utf8").trim();
|
|
171
|
-
const identifyInitiatingPackageManager =
|
|
128
|
+
const identifyInitiatingPackageManager = () => {
|
|
172
129
|
if (!process.env.npm_config_user_agent) {
|
|
173
130
|
return void 0;
|
|
174
131
|
}
|
|
@@ -182,9 +139,7 @@ const identifyInitiatingPackageManager = async () => {
|
|
|
182
139
|
};
|
|
183
140
|
const generateMissingPackagesInstallMessage = (packageName, missingPackages, options) => {
|
|
184
141
|
const s = missingPackages.length === 1 ? "" : "s";
|
|
185
|
-
|
|
186
|
-
options.packageManagers = ["npm", "pnpm", "yarn"];
|
|
187
|
-
}
|
|
142
|
+
options.packageManagers ??= ["npm", "pnpm", "yarn"];
|
|
188
143
|
if (options.packageManagers.length === 0) {
|
|
189
144
|
throw new Error("No package managers provided, please provide at least one package manager");
|
|
190
145
|
}
|
package/dist/packem_shared/{PackageNotFoundError-CJmAqa_k.js → PackageNotFoundError-C0ltLzw7.js}
RENAMED
|
@@ -20,9 +20,7 @@ class PackageNotFoundError extends Error {
|
|
|
20
20
|
} catch {
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
|
-
|
|
24
|
-
packageManager = "npm";
|
|
25
|
-
}
|
|
23
|
+
packageManager ??= "npm";
|
|
26
24
|
super(`Package '${packageName.join(" ")}' was not found. Please install it using '${packageManager} install ${packageName.join(" ")}'`);
|
|
27
25
|
}
|
|
28
26
|
// eslint-disable-next-line class-methods-use-this
|
package/dist/types.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import type { Package as normalizePackage } from "normalize-package-data";
|
|
|
5
5
|
import type { PackageJson as typeFestPackageJson } from "type-fest";
|
|
6
6
|
export type NormalizedPackageJson = normalizePackage & PackageJson;
|
|
7
7
|
export type PackageJson = typeFestPackageJson;
|
|
8
|
-
export type Cache<T =
|
|
8
|
+
export type Cache<T = unknown> = Map<string, T>;
|
|
9
9
|
export type EnsurePackagesOptions = {
|
|
10
10
|
/** Configuration for user confirmation prompts when installing packages */
|
|
11
11
|
confirm?: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@visulima/package",
|
|
3
|
-
"version": "5.0.0-alpha.
|
|
3
|
+
"version": "5.0.0-alpha.7",
|
|
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,15 +97,13 @@
|
|
|
97
97
|
],
|
|
98
98
|
"dependencies": {
|
|
99
99
|
"@antfu/install-pkg": "^1.1.0",
|
|
100
|
-
"@visulima/fs": "5.0.0-alpha.
|
|
101
|
-
"@visulima/path": "3.0.0-alpha.
|
|
100
|
+
"@visulima/fs": "5.0.0-alpha.7",
|
|
101
|
+
"@visulima/path": "3.0.0-alpha.8",
|
|
102
102
|
"json5": "^2.2.3",
|
|
103
103
|
"normalize-package-data": "^8.0.0",
|
|
104
104
|
"type-fest": "5.5.0",
|
|
105
105
|
"yaml": "2.8.3"
|
|
106
106
|
},
|
|
107
|
-
"peerDependencies": {},
|
|
108
|
-
"optionalDependencies": {},
|
|
109
107
|
"engines": {
|
|
110
108
|
"node": ">=22.13 <=25.x"
|
|
111
109
|
},
|