@visulima/package 5.0.12 → 5.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/LICENSE.md +126 -61
- package/dist/error.js +1 -1
- package/dist/index.d.ts +2 -4
- package/dist/index.js +1 -1
- package/dist/lockfile.js +1 -1
- package/dist/monorepo.js +1 -1
- package/dist/package-json.d.ts +2 -4
- package/dist/package-json.js +3 -3
- package/dist/package-manager.js +3 -3
- package/dist/package.js +1 -1
- package/dist/packem_shared/PackageNotFoundError-PwPSQ1F3.js +1 -0
- package/dist/packem_shared/json-value.d-AIF0oxA6.d.ts +29 -0
- package/dist/packem_shared/package-json.d-Ba7sjsO5.d.ts +2856 -0
- package/dist/pnpm.d.ts +1 -1
- package/dist/pnpm.js +1 -1
- package/package.json +23 -23
- package/dist/packem_shared/PackageNotFoundError-Bi41exhP.js +0 -1
- package/dist/packem_shared/package-json.d-62php2nC.d.ts +0 -186
package/dist/pnpm.d.ts
CHANGED
package/dist/pnpm.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{findUp as
|
|
1
|
+
import{findUp as g,findUpSync as d}from"@visulima/fs";import{readYaml as y,readYamlSync as m}from"@visulima/fs/yaml";import{dirname as i,relative as u}from"@visulima/path";const p=(t,a,e)=>{const c=i(t),o=i(a),l=o===c?".":u(c,o);return e.some(f=>{const r=f.startsWith("./")?f.slice(2):f,s=l.startsWith("./")?l.slice(2):l;if(r==="."&&s===".")return!0;if(r.endsWith("/**")){const n=r.slice(0,-3);return s===n||s.startsWith(`${n}/`)}if(r.endsWith("/*")){const n=r.slice(0,-2);return n===""?s!=="."&&!s.includes("/"):s.startsWith(`${n}/`)||s===n}return s===r||s.startsWith(`${r}/`)})},b=async t=>{const a=await g("pnpm-workspace.yaml",{cwd:i(t),type:"file"});if(!a)return;const e=await y(a),c=Array.isArray(e.packages)?e.packages:[];if(!p(a,t,c))return;const o={};return e.catalog&&typeof e.catalog=="object"&&(o.catalog=e.catalog),e.catalogs&&typeof e.catalogs=="object"&&(o.catalogs=e.catalogs),Object.keys(o).length>0?o:void 0},j=t=>{const a=d("pnpm-workspace.yaml",{cwd:i(t),type:"file"});if(!a)return;const e=m(a),c=Array.isArray(e.packages)?e.packages:[];if(!p(a,t,c))return;const o={};return e.catalog&&typeof e.catalog=="object"&&(o.catalog=e.catalog),e.catalogs&&typeof e.catalogs=="object"&&(o.catalogs=e.catalogs),Object.keys(o).length>0?o:void 0},k=(t,a,e)=>{if(a==="catalog:")return e.catalog?.[t];if(a.startsWith("catalog:")){const c=a.slice(8);return e.catalogs?.[c]?.[t]}},v=(t,a)=>{for(const[e,c]of Object.entries(t)){if(typeof c!="string")continue;const o=k(e,c,a);o&&(t[e]=o)}},D=(t,a)=>{const e=["dependencies","devDependencies","peerDependencies","optionalDependencies"];for(const c of e){if(!t[c]||typeof t[c]!="object")continue;const o=t[c];v(o,a)}};export{p as isPackageInWorkspace,b as readPnpmCatalogs,j as readPnpmCatalogsSync,k as resolveCatalogReference,D as resolveCatalogReferences,v as resolveDependenciesCatalogReferences};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@visulima/package",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.13",
|
|
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",
|
|
@@ -34,11 +34,6 @@
|
|
|
34
34
|
],
|
|
35
35
|
"homepage": "https://visulima.com/packages/package/",
|
|
36
36
|
"bugs": "https://github.com/visulima/visulima/issues",
|
|
37
|
-
"license": "MIT",
|
|
38
|
-
"author": {
|
|
39
|
-
"name": "Daniel Bannert",
|
|
40
|
-
"email": "d.bannert@anolilab.de"
|
|
41
|
-
},
|
|
42
37
|
"repository": {
|
|
43
38
|
"type": "git",
|
|
44
39
|
"url": "git+https://github.com/visulima/visulima.git",
|
|
@@ -54,20 +49,13 @@
|
|
|
54
49
|
"url": "https://anolilab.com/support"
|
|
55
50
|
}
|
|
56
51
|
],
|
|
57
|
-
"
|
|
58
|
-
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
|
|
62
|
-
"MIGRATION-GUIDE.md"
|
|
63
|
-
],
|
|
64
|
-
"os": [
|
|
65
|
-
"darwin",
|
|
66
|
-
"linux",
|
|
67
|
-
"win32"
|
|
68
|
-
],
|
|
69
|
-
"type": "module",
|
|
52
|
+
"license": "MIT",
|
|
53
|
+
"author": {
|
|
54
|
+
"name": "Daniel Bannert",
|
|
55
|
+
"email": "d.bannert@anolilab.de"
|
|
56
|
+
},
|
|
70
57
|
"sideEffects": false,
|
|
58
|
+
"type": "module",
|
|
71
59
|
"exports": {
|
|
72
60
|
".": {
|
|
73
61
|
"types": "./dist/index.d.ts",
|
|
@@ -103,10 +91,13 @@
|
|
|
103
91
|
},
|
|
104
92
|
"./package.json": "./package.json"
|
|
105
93
|
},
|
|
106
|
-
"
|
|
107
|
-
"
|
|
108
|
-
"
|
|
109
|
-
|
|
94
|
+
"files": [
|
|
95
|
+
"dist/**",
|
|
96
|
+
"README.md",
|
|
97
|
+
"CHANGELOG.md",
|
|
98
|
+
"LICENSE.md",
|
|
99
|
+
"MIGRATION-GUIDE.md"
|
|
100
|
+
],
|
|
110
101
|
"dependencies": {
|
|
111
102
|
"@antfu/install-pkg": "^1.1.0",
|
|
112
103
|
"@visulima/fs": "6.0.0",
|
|
@@ -117,5 +108,14 @@
|
|
|
117
108
|
},
|
|
118
109
|
"engines": {
|
|
119
110
|
"node": "^22.14.0 || >=24.10.0"
|
|
111
|
+
},
|
|
112
|
+
"os": [
|
|
113
|
+
"darwin",
|
|
114
|
+
"linux",
|
|
115
|
+
"win32"
|
|
116
|
+
],
|
|
117
|
+
"publishConfig": {
|
|
118
|
+
"access": "public",
|
|
119
|
+
"provenance": true
|
|
120
120
|
}
|
|
121
121
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{findPackageManagerSync as o}from"../package-manager.js";class n extends Error{constructor(e,r){if(typeof e=="string"&&(e=[e]),e.length===0){super("Package was not found.");return}if(r===void 0)try{r=o().packageManager}catch{}r??="npm",super(`Package '${e.join(" ")}' was not found. Please install it using '${r} install ${e.join(" ")}'`)}get code(){return"PACKAGE_NOT_FOUND"}set code(e){throw new Error("Cannot overwrite code PACKAGE_NOT_FOUND")}get name(){return"PackageNotFoundError"}set name(e){throw new Error("Cannot overwrite name of PackageNotFoundError")}}export{n as default};
|
|
@@ -1,186 +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 { 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
|
-
/**
|
|
18
|
-
* Theme configuration for the prompt interface.
|
|
19
|
-
* @deprecated Not implemented — the readline-based prompt ignores this option and uses
|
|
20
|
-
* fixed styling. It will be removed in a future major release.
|
|
21
|
-
*/
|
|
22
|
-
theme?: PartialDeep<Theme>;
|
|
23
|
-
/** Function to transform the boolean value for display */
|
|
24
|
-
transformer?: (value: boolean) => string;
|
|
25
|
-
};
|
|
26
|
-
/** Current working directory for package operations */
|
|
27
|
-
cwd?: URL | string;
|
|
28
|
-
/** Whether to include regular dependencies in the operation */
|
|
29
|
-
deps?: boolean;
|
|
30
|
-
/** Whether to include development dependencies in the operation */
|
|
31
|
-
devDeps?: boolean;
|
|
32
|
-
/** Additional options for package installation (excluding cwd and dev which are handled separately) */
|
|
33
|
-
installPackage?: Omit<InstallPackageOptions, "cwd" | "dev">;
|
|
34
|
-
/** Custom logger interface for warning messages */
|
|
35
|
-
logger?: {
|
|
36
|
-
warn: (message: string) => void;
|
|
37
|
-
};
|
|
38
|
-
/** Whether to include peer dependencies in the operation */
|
|
39
|
-
peerDeps?: boolean;
|
|
40
|
-
/** Whether to throw an error when warnings are logged instead of just logging them */
|
|
41
|
-
throwOnWarn?: boolean;
|
|
42
|
-
};
|
|
43
|
-
type ReadOptions = {
|
|
44
|
-
cache?: FindPackageJsonCache | boolean;
|
|
45
|
-
ignoreWarnings?: (RegExp | string)[];
|
|
46
|
-
json5?: boolean;
|
|
47
|
-
resolveCatalogs?: boolean;
|
|
48
|
-
strict?: boolean;
|
|
49
|
-
yaml?: boolean;
|
|
50
|
-
};
|
|
51
|
-
type FindPackageJsonCache = Cache<NormalizedReadResult>;
|
|
52
|
-
type NormalizedReadResult = {
|
|
53
|
-
packageJson: NormalizedPackageJson;
|
|
54
|
-
path: string;
|
|
55
|
-
};
|
|
56
|
-
/**
|
|
57
|
-
* An asynchronous function to find the package.json, package.yaml, or package.json5 file in the specified directory or its parent directories.
|
|
58
|
-
* @param cwd The current working directory.
|
|
59
|
-
* @param options Configuration options including yaml, json5, and resolveCatalogs flags.
|
|
60
|
-
* @returns A `Promise` that resolves to an object containing the parsed package data and the file path.
|
|
61
|
-
* The type of the returned promise is `Promise<NormalizedReadResult>`.
|
|
62
|
-
* @throws {Error} If no package file can be found or if strict mode is enabled and normalize warnings are thrown.
|
|
63
|
-
*/
|
|
64
|
-
declare const findPackageJson: (cwd?: URL | string, options?: ReadOptions) => Promise<NormalizedReadResult>;
|
|
65
|
-
/**
|
|
66
|
-
* A synchronous function to find the package.json, package.yaml, or package.json5 file in the specified directory or its parent directories.
|
|
67
|
-
* @param cwd The current working directory.
|
|
68
|
-
* @param options Configuration options including yaml, json5, and resolveCatalogs flags.
|
|
69
|
-
* @returns An object containing the parsed package data and the file path.
|
|
70
|
-
* @throws {Error} If no package file can be found or if strict mode is enabled and normalize warnings are thrown.
|
|
71
|
-
*/
|
|
72
|
-
declare const findPackageJsonSync: (cwd?: URL | string, options?: ReadOptions) => NormalizedReadResult;
|
|
73
|
-
/**
|
|
74
|
-
* An asynchronous function to write the package.json file with the given data.
|
|
75
|
-
* @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.
|
|
76
|
-
* @param options Optional. The options for writing the package.json. If not provided, an empty object will be used `{}`.
|
|
77
|
-
* This is an intersection type of `WriteJsonOptions` and a record with an optional `cwd` key which type is `Options["cwd"]`.
|
|
78
|
-
* `cwd` represents the current working directory. If not specified, the default working directory will be used.
|
|
79
|
-
* @returns A `Promise` that resolves once the package.json file has been written. The type of the returned promise is `Promise<void>`.
|
|
80
|
-
*/
|
|
81
|
-
declare const writePackageJson: (data: PackageJson, options?: WriteJsonOptions & {
|
|
82
|
-
cwd?: URL | string;
|
|
83
|
-
}) => Promise<void>;
|
|
84
|
-
declare const writePackageJsonSync: (data: PackageJson, options?: WriteJsonOptions & {
|
|
85
|
-
cwd?: URL | string;
|
|
86
|
-
}) => void;
|
|
87
|
-
/**
|
|
88
|
-
* Clears the module-level package.json file and parse caches.
|
|
89
|
-
*
|
|
90
|
-
* The caches populated by `findPackageJson[Sync]` / `parsePackageJson[Sync]` when
|
|
91
|
-
* `cache: true` (and no custom cache is supplied) never expire on their own. Call this
|
|
92
|
-
* to drop all cached reads — for example in long-running processes or tests that mutate
|
|
93
|
-
* package files out of band.
|
|
94
|
-
*/
|
|
95
|
-
declare const clearPackageJsonCache: () => void;
|
|
96
|
-
/**
|
|
97
|
-
* A synchronous function to parse the package.json, package.yaml, or package.json5 file/object/string and return normalize the data.
|
|
98
|
-
* @param packageFile
|
|
99
|
-
* @param options
|
|
100
|
-
* @param options.cache Cache for parsed results (only applies to file paths)
|
|
101
|
-
* @param options.ignoreWarnings List of warning messages or patterns to skip in strict mode
|
|
102
|
-
* @param options.resolveCatalogs Whether to resolve pnpm catalog references
|
|
103
|
-
* @param options.strict Whether to throw errors on normalization warnings
|
|
104
|
-
* @param options.yaml Whether to enable package.yaml parsing (default: true)
|
|
105
|
-
* @param options.json5 Whether to enable package.json5 parsing (default: true)
|
|
106
|
-
* @returns
|
|
107
|
-
* @throws {Error} If the packageFile parameter is not an object or a string or if strict mode is enabled and normalize warnings are thrown.
|
|
108
|
-
*/
|
|
109
|
-
declare const parsePackageJsonSync: (packageFile: JsonObject | string, options?: {
|
|
110
|
-
cache?: Cache<NormalizedPackageJson> | boolean;
|
|
111
|
-
ignoreWarnings?: (RegExp | string)[];
|
|
112
|
-
json5?: boolean;
|
|
113
|
-
resolveCatalogs?: boolean;
|
|
114
|
-
strict?: boolean;
|
|
115
|
-
yaml?: boolean;
|
|
116
|
-
}) => NormalizedPackageJson;
|
|
117
|
-
/**
|
|
118
|
-
* An asynchronous function to parse the package.json, package.yaml, or package.json5 file/object/string and return normalize the data.
|
|
119
|
-
* @param packageFile
|
|
120
|
-
* @param options
|
|
121
|
-
* @param options.cache Cache for parsed results (only applies to file paths)
|
|
122
|
-
* @param options.ignoreWarnings List of warning messages or patterns to skip in strict mode
|
|
123
|
-
* @param options.strict Whether to throw errors on normalization warnings
|
|
124
|
-
* @param options.resolveCatalogs Whether to resolve pnpm catalog references
|
|
125
|
-
* @param options.yaml Whether to enable package.yaml parsing (default: true)
|
|
126
|
-
* @param options.json5 Whether to enable package.json5 parsing (default: true)
|
|
127
|
-
* @returns
|
|
128
|
-
* @throws {Error} If the packageFile parameter is not an object or a string or if strict mode is enabled and normalize warnings are thrown.
|
|
129
|
-
*/
|
|
130
|
-
declare const parsePackageJson: (packageFile: JsonObject | string, options?: {
|
|
131
|
-
cache?: Cache<NormalizedPackageJson> | boolean;
|
|
132
|
-
ignoreWarnings?: (RegExp | string)[];
|
|
133
|
-
json5?: boolean;
|
|
134
|
-
resolveCatalogs?: boolean;
|
|
135
|
-
strict?: boolean;
|
|
136
|
-
yaml?: boolean;
|
|
137
|
-
}) => Promise<NormalizedPackageJson>;
|
|
138
|
-
/**
|
|
139
|
-
* An asynchronous function to get the value of a property from the package.json file.
|
|
140
|
-
* @param packageJson
|
|
141
|
-
* @param property
|
|
142
|
-
* @param defaultValue
|
|
143
|
-
* @returns
|
|
144
|
-
*/
|
|
145
|
-
declare const getPackageJsonProperty: <T = unknown>(packageJson: NormalizedPackageJson, property: Paths<NormalizedPackageJson>, defaultValue?: T) => T;
|
|
146
|
-
/**
|
|
147
|
-
* An asynchronous function to check if a property exists in the package.json file.
|
|
148
|
-
* @param packageJson
|
|
149
|
-
* @param property
|
|
150
|
-
* @returns
|
|
151
|
-
*/
|
|
152
|
-
declare const hasPackageJsonProperty: (packageJson: NormalizedPackageJson, property: Paths<NormalizedPackageJson>) => boolean;
|
|
153
|
-
/**
|
|
154
|
-
* An asynchronous function to check if any of the specified dependencies exist in the package.json file.
|
|
155
|
-
* @param packageJson
|
|
156
|
-
* @param arguments_
|
|
157
|
-
* @param options
|
|
158
|
-
* @param options.peerDeps Whether to include peer dependencies
|
|
159
|
-
* @returns
|
|
160
|
-
*/
|
|
161
|
-
declare const hasPackageJsonAnyDependency: (packageJson: NormalizedPackageJson, arguments_: string[], options?: {
|
|
162
|
-
peerDeps?: boolean;
|
|
163
|
-
}) => boolean;
|
|
164
|
-
/**
|
|
165
|
-
* An asynchronous function to ensure that the specified packages are installed in the package.json file.
|
|
166
|
-
* If the packages are not installed, the user will be prompted to install them.
|
|
167
|
-
* If the user agrees, the packages will be installed.
|
|
168
|
-
* If the user declines, the function will return without installing the packages.
|
|
169
|
-
* If the user does not respond, the function will return without installing the packages.
|
|
170
|
-
* @param packageJson
|
|
171
|
-
* @param packages
|
|
172
|
-
* @param installKey
|
|
173
|
-
* @param options
|
|
174
|
-
* @param options.deps Whether to include regular dependencies
|
|
175
|
-
* @param options.devDeps Whether to include development dependencies
|
|
176
|
-
* @param options.peerDeps Whether to include peer dependencies
|
|
177
|
-
* @param options.throwOnWarn Whether to throw an error when warnings are logged instead of just logging them
|
|
178
|
-
* @param options.logger Whether to use a custom logger
|
|
179
|
-
* @param options.confirm Whether to use a custom confirmation prompt
|
|
180
|
-
* @param options.installPackage Whether to use a custom installation package
|
|
181
|
-
* @param options.cwd Whether to use a custom current working directory
|
|
182
|
-
* @param options.dev Whether to use a custom installation key
|
|
183
|
-
* @returns
|
|
184
|
-
*/
|
|
185
|
-
declare const ensurePackages: (packageJson: NormalizedPackageJson, packages: string[], installKey?: "dependencies" | "devDependencies", options?: EnsurePackagesOptions) => Promise<void>;
|
|
186
|
-
export { EnsurePackagesOptions as E, FindPackageJsonCache as F, NormalizedPackageJson as N, PackageJson as P, NormalizedReadResult as a, findPackageJsonSync as b, clearPackageJsonCache as c, hasPackageJsonProperty as d, ensurePackages as e, findPackageJson as f, getPackageJsonProperty as g, hasPackageJsonAnyDependency as h, parsePackageJsonSync as i, writePackageJsonSync as j, parsePackageJson as p, writePackageJson as w };
|