@visulima/package 4.0.0 → 4.0.2
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
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
## @visulima/package [4.0.2](https://github.com/visulima/visulima/compare/@visulima/package@4.0.1...@visulima/package@4.0.2) (2025-10-02)
|
|
2
|
+
|
|
3
|
+
### Bug Fixes
|
|
4
|
+
|
|
5
|
+
* enhance package JSON parsing with error handling for resolveCatalogs option ([c921937](https://github.com/visulima/visulima/commit/c9219378c6f561d35bb2dc9d6754356b4e46de77))
|
|
6
|
+
|
|
7
|
+
## @visulima/package [4.0.1](https://github.com/visulima/visulima/compare/@visulima/package@4.0.0...@visulima/package@4.0.1) (2025-10-02)
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **package:** export additional pnpm types and functions ([f623d28](https://github.com/visulima/visulima/commit/f623d28b74d9e559995759646e51c1020b407d64))
|
|
12
|
+
|
|
1
13
|
## @visulima/package [4.0.0](https://github.com/visulima/visulima/compare/@visulima/package@3.6.1...@visulima/package@4.0.0) (2025-10-02)
|
|
2
14
|
|
|
3
15
|
### ⚠ BREAKING CHANGES
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
export { PackageNotFoundError } from './error.js';
|
|
2
2
|
export { RootMonorepo, Strategy, findMonorepoRoot, findMonorepoRootSync } from './monorepo.js';
|
|
3
3
|
export { findPackageRoot, findPackageRootSync } from './package.js';
|
|
4
|
-
export { E as EnsurePackagesOptions, F as FindPackageJsonCache,
|
|
4
|
+
export { E as EnsurePackagesOptions, F as FindPackageJsonCache, i as NormalizedPackageJson, N as NormalizedReadResult, P as PackageJson, e as ensurePackages, f as findPackageJson, a as findPackageJsonSync, g as getPackageJsonProperty, h as hasPackageJsonAnyDependency, b as hasPackageJsonProperty, p as parsePackageJson, c as parsePackageJsonSync, w as writePackageJson, d as writePackageJsonSync } from './packem_shared/package-json-t7TSgmrQ.js';
|
|
5
5
|
export { PackageManager, PackageManagerResult, findLockFile, findLockFileSync, findPackageManager, findPackageManagerSync, generateMissingPackagesInstallMessage, getPackageManagerVersion, identifyInitiatingPackageManager } from './package-manager.js';
|
|
6
|
+
export { PnpmCatalog, PnpmCatalogs, isPackageInWorkspace, readPnpmCatalogs, readPnpmCatalogsSync, resolveCatalogReference, resolveCatalogReferences, resolveDependenciesCatalogReferences } from './pnpm.js';
|
|
6
7
|
import '@visulima/fs';
|
|
7
8
|
import './packem_shared/json-value.d-DU4PzU4Z.js';
|
|
8
9
|
import '@antfu/install-pkg';
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{default as n}from"./packem_shared/PackageNotFoundError-BictYTIA.js";import{findMonorepoRoot as r,findMonorepoRootSync as
|
|
1
|
+
import{default as n}from"./packem_shared/PackageNotFoundError-BictYTIA.js";import{findMonorepoRoot as r,findMonorepoRootSync as c}from"./monorepo.js";import{findPackageRoot as s,findPackageRootSync as t}from"./package.js";import{ensurePackages as P,findPackageJson as k,findPackageJsonSync as f,getPackageJsonProperty as d,hasPackageJsonAnyDependency as p,hasPackageJsonProperty as l,parsePackageJson as y,parsePackageJsonSync as J,writePackageJson as m,writePackageJsonSync as M}from"./package-json.js";import{findLockFile as R,findLockFileSync as x,findPackageManager as C,findPackageManagerSync as u,generateMissingPackagesInstallMessage as v,getPackageManagerVersion as F,identifyInitiatingPackageManager as I}from"./package-manager.js";import{isPackageInWorkspace as w,readPnpmCatalogs as D,readPnpmCatalogsSync as L,resolveCatalogReference as A,resolveCatalogReferences as E,resolveDependenciesCatalogReferences as N}from"./pnpm.js";export{n as PackageNotFoundError,P as ensurePackages,R as findLockFile,x as findLockFileSync,r as findMonorepoRoot,c as findMonorepoRootSync,k as findPackageJson,f as findPackageJsonSync,C as findPackageManager,u as findPackageManagerSync,s as findPackageRoot,t as findPackageRootSync,v as generateMissingPackagesInstallMessage,d as getPackageJsonProperty,F as getPackageManagerVersion,p as hasPackageJsonAnyDependency,l as hasPackageJsonProperty,I as identifyInitiatingPackageManager,w as isPackageInWorkspace,y as parsePackageJson,J as parsePackageJsonSync,D as readPnpmCatalogs,L as readPnpmCatalogsSync,A as resolveCatalogReference,E as resolveCatalogReferences,N as resolveDependenciesCatalogReferences,m as writePackageJson,M as writePackageJsonSync};
|
package/dist/package-json.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import '@visulima/fs';
|
|
2
2
|
import './packem_shared/json-value.d-DU4PzU4Z.js';
|
|
3
|
-
export { F as FindPackageJsonCache, N as NormalizedReadResult, e as ensurePackages, f as findPackageJson, a as findPackageJsonSync, g as getPackageJsonProperty, h as hasPackageJsonAnyDependency, b as hasPackageJsonProperty, p as parsePackageJson,
|
|
3
|
+
export { F as FindPackageJsonCache, N as NormalizedReadResult, e as ensurePackages, f as findPackageJson, a as findPackageJsonSync, g as getPackageJsonProperty, h as hasPackageJsonAnyDependency, b as hasPackageJsonProperty, p as parsePackageJson, c as parsePackageJsonSync, w as writePackageJson, d as writePackageJsonSync } from './packem_shared/package-json-t7TSgmrQ.js';
|
|
4
4
|
import '@antfu/install-pkg';
|
|
5
5
|
import 'normalize-package-data';
|
package/dist/package-json.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var
|
|
2
|
-
- ${
|
|
3
|
-
- `)}`),this.name="PackageJsonValidationError"}}const
|
|
1
|
+
var W=Object.defineProperty;var i=(e,t)=>W(e,"name",{value:t,configurable:!0});import{installPackage as K}from"@antfu/install-pkg";import R from"@inquirer/confirm";import{readJsonSync as I,findUp as q,readJson as S,findUpSync as F,writeJson as M,writeJsonSync as V}from"@visulima/fs";import{NotFoundError as A}from"@visulima/fs/error";import{parseJson as D,toPath as b}from"@visulima/fs/utils";import{join as C}from"@visulima/path";import{readPnpmCatalogsSync as U,resolveCatalogReferences as N,readPnpmCatalogs as Y}from"./pnpm.js";const z=globalThis.process.getBuiltinModule("module").createRequire(import.meta.url),{existsSync:j}=globalThis.process.getBuiltinModule("node:fs"),B=z("normalize-package-data");var G=Object.defineProperty,f=i((e,t)=>G(e,"name",{value:t,configurable:!0}),"f$1");const u=f(e=>{const t=typeof e;return e!==null&&(t==="object"||t==="function")},"isObject"),H=f(e=>u(e)&&Object.keys(e).length===0,"isEmptyObject"),P=new Set(["__proto__","prototype","constructor"]),L=new Set("0123456789");function v(e){return typeof e=="string"&&/^\d+$/.test(e)&&Number.parseInt(e,10)>=0&&(e==="0"||!e.startsWith("0"))}i(v,"h");f(v,"isValidArrayIndex");function y(e,t,r){return r>0&&typeof e=="string"&&Array.isArray(t)&&v(e)?Number.parseInt(e,10):e}i(y,"u");f(y,"normalizeKey");function w(e){const t=[];let r="",n="start",o=!1;for(const s of e)switch(s){case"\\":{if(n==="index")throw new Error("Invalid character in an index");if(n==="indexEnd")throw new Error("Invalid character after an index");o&&(r+=s),n="property",o=!o;break}case".":{if(n==="index")throw new Error("Invalid character in an index");if(n==="indexEnd"){n="property";break}if(o){o=!1,r+=s;break}if(P.has(r))return[];t.push(r),r="",n="property";break}case"[":{if(n==="index")throw new Error("Invalid character in an index");if(n==="indexEnd"){n="index";break}if(o){o=!1,r+=s;break}if(n==="property"){if(P.has(r))return[];t.push(r),r=""}n="index";break}case"]":{if(n==="index"){t.push(Number.parseInt(r,10)),r="",n="indexEnd";break}if(n==="indexEnd")throw new Error("Invalid character after an index")}default:{if(n==="index"&&!L.has(s))throw new Error("Invalid character in an index");if(n==="indexEnd")throw new Error("Invalid character after an index");n==="start"&&(n="property"),o&&(o=!1,r+="\\"),r+=s}}switch(o&&(r+="\\"),n){case"property":{if(P.has(r))return[];t.push(r);break}case"index":throw new Error("Index was not closed");case"start":{t.push("");break}}return t}i(w,"l");f(w,"getPathSegments");function m(e,t){if(!Array.isArray(e)||typeof t=="number")return!1;const r=Number.parseInt(t,10);return Number.isInteger(r)&&String(r)===t}i(m,"c$1");f(m,"isStringIndex");function x(e,t){if(m(e,t))throw new Error("Cannot use string index")}i(x,"x");f(x,"assertNotStringIndex");function g(e,t,r){if(!u(e)||typeof t!="string")return r===void 0?e:r;const n=w(t);if(n.length===0)return r;for(let o=0;o<n.length;o++){const s=n[o],a=y(s,e,o);if(a===s&&m(e,s)?e=o===n.length-1?void 0:null:e=e[a],e==null){if(o!==n.length-1)return r;break}}return e===void 0?r:e}i(g,"getProperty");f(g,"getProperty");function T(e,t,r){if(!u(e)||typeof t!="string")return e;const n=e,o=w(t);for(let s=0;s<o.length;s++){const a=o[s],p=y(a,e,s);if(p===a&&x(e,a),s===o.length-1)e[p]=r;else if(!u(e[p])){const c=o[s+1],l=typeof c=="number"||typeof c=="string"&&v(c);e[p]=l?[]:{}}e=e[p]}return n}i(T,"setProperty");f(T,"setProperty");function Q(e,t){if(!u(e)||typeof t!="string")return!1;const r=w(t);for(let n=0;n<r.length;n++){const o=r[n],s=y(o,e,n);if(s===o&&x(e,o),n===r.length-1)return Object.hasOwn(e,s)?(delete e[s],!0):!1;if(e=e[s],!u(e))return!1}}i(Q,"deleteProperty");f(Q,"deleteProperty");function h(e,t){if(!u(e)||typeof t!="string")return!1;const r=w(t);if(r.length===0)return!1;for(const[n,o]of r.entries()){const s=y(o,e,n),a=s===o&&m(e,o);if(!u(e)||!(s in e)||a)return!1;e=e[s]}return!0}i(h,"hasProperty");f(h,"hasProperty");function O(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replaceAll(/[\\.[]/g,String.raw`\$&`)}i(O,"escapePath");f(O,"escapePath");function E(e){const t=Object.entries(e);return Array.isArray(e)?t.map(([r,n])=>[Number(r),n]):t}i(E,"g");f(E,"entries");function _(e){let t="";for(let[r,n]of E(e))typeof n=="number"?t+=`[${n}]`:(n=O(n),t+=r===0?n:`.${n}`);return t}i(_,"A");f(_,"stringifyPath");function*J(e,t=[]){if(!u(e)||H(e)){t.length>0&&(yield _(t));return}for(const[r,n]of E(e))yield*J(n,[...t,r])}i(J,"w");f(J,"deepKeysIterator");function X(e){return[...J(e)]}i(X,"deepKeys");f(X,"deepKeys");function Z(e){const t={};if(!u(e))return t;for(const[r,n]of Object.entries(e))T(t,r,n);return t}i(Z,"unflatten");f(Z,"unflatten");const ee=typeof process.stdout<"u"&&!process.versions.deno&&!globalThis.window;var te=Object.defineProperty,d=i((e,t)=>te(e,"name",{value:t,configurable:!0}),"c");const $=new Map;class ne extends Error{static{i(this,"S")}static{d(this,"PackageJsonValidationError")}constructor(t){super(`The following warnings were encountered while normalizing package data:
|
|
2
|
+
- ${t.join(`
|
|
3
|
+
- `)}`),this.name="PackageJsonValidationError"}}const k=d((e,t,r=[])=>{const n=[];if(B(e,o=>{n.push(o)},t),t&&n.length>0){const o=n.filter(s=>!r.some(a=>a instanceof RegExp?a.test(s):a===s));if(o.length>0)throw new ne(o)}return e},"normalizeInput"),le=d(async(e,t={})=>{const r={type:"file"};e&&(r.cwd=e);const n=await q("package.json",r);if(!n)throw new A("No such file or directory, for package.json found.");const o=t.cache&&typeof t.cache!="boolean"?t.cache:$;if(t.cache&&o.has(n))return o.get(n);const s=await S(n);k(s,t.strict??!1,t.ignoreWarnings);const a={packageJson:s,path:n};return o.set(n,a),a},"findPackageJson"),de=d((e,t={})=>{const r={type:"file"};e&&(r.cwd=e);const n=F("package.json",r);if(!n)throw new A("No such file or directory, for package.json found.");const o=t.cache&&typeof t.cache!="boolean"?t.cache:$;if(t.cache&&o.has(n))return o.get(n);const s=I(n);k(s,t.strict??!1,t.ignoreWarnings);const a={packageJson:s,path:n};return o.set(n,a),a},"findPackageJsonSync"),ue=d(async(e,t={})=>{const{cwd:r,...n}=t,o=b(t.cwd??process.cwd());await M(C(o,"package.json"),e,n)},"writePackageJson"),ge=d((e,t={})=>{const{cwd:r,...n}=t,o=b(t.cwd??process.cwd());V(C(o,"package.json"),e,n)},"writePackageJsonSync"),he=d((e,t)=>{const r=e!==null&&typeof e=="object"&&!Array.isArray(e);if(!r&&typeof e!="string")throw new TypeError("`packageFile` should be either an `object` or a `string`.");let n,o=!1;if(r?n=structuredClone(e):j(e)?(n=I(e),o=!0):n=D(e),t?.resolveCatalogs)if(o){const s=U(e);s&&N(n,s)}else throw new Error("The 'resolveCatalogs' option can only be used on a file path.");return k(n,t?.strict??!1,t?.ignoreWarnings),n},"parsePackageJsonSync"),ye=d(async(e,t)=>{const r=e!==null&&typeof e=="object"&&!Array.isArray(e);if(!r&&typeof e!="string")throw new TypeError("`packageFile` should be either an `object` or a `string`.");let n,o=!1;if(r?n=structuredClone(e):j(e)?(n=await S(e),o=!0):n=D(e),t?.resolveCatalogs)if(o){const s=await Y(e);s&&N(n,s)}else throw new Error("The 'resolveCatalogs' option can only be used on a file path.");return k(n,t?.strict??!1,t?.ignoreWarnings),n},"parsePackageJson"),we=d((e,t,r)=>g(e,t,r),"getPackageJsonProperty"),me=d((e,t)=>h(e,t),"hasPackageJsonProperty"),ke=d((e,t,r)=>{const n=g(e,"dependencies",{}),o=g(e,"devDependencies",{}),s=g(e,"peerDependencies",{}),a={...n,...o,...r?.peerDeps===!1?{}:s};for(const p of t)if(h(a,p))return!0;return!1},"hasPackageJsonAnyDependency"),Pe=d(async(e,t,r="dependencies",n={})=>{const o=g(e,"dependencies",{}),s=g(e,"devDependencies",{}),a=g(e,"peerDependencies",{}),p=[],c={deps:!0,devDeps:!0,peerDeps:!1,...n};for(const l of t)c.deps&&h(o,l)||c.devDeps&&h(s,l)||c.peerDeps&&h(a,l)||p.push(l);if(p.length!==0){if(process.env.CI||ee&&!process.stdout?.isTTY){const l=`Skipping package installation for [${t.join(", ")}] because the process is not interactive.`;if(n.throwOnWarn)throw new Error(l);n.logger?.warn?n.logger.warn(l):console.warn(l);return}if(typeof c.confirm?.message=="function"&&(c.confirm.message=c.confirm.message(p)),c.confirm?.message===void 0){const l=`${p.length===1?"Package is":"Packages are"} required for this config: ${p.join(", ")}. Do you want to install them?`;c.confirm===void 0?c.confirm={message:l}:c.confirm.message=l}await R(c.confirm)&&await K(p,{...c.installPackage,cwd:c.cwd?b(c.cwd):void 0,dev:r==="devDependencies"})}},"ensurePackages");export{Pe as ensurePackages,le as findPackageJson,de as findPackageJsonSync,we as getPackageJsonProperty,ke as hasPackageJsonAnyDependency,me as hasPackageJsonProperty,ye as parsePackageJson,he as parsePackageJsonSync,ue as writePackageJson,ge as writePackageJsonSync};
|
|
@@ -2748,4 +2748,4 @@ declare const hasPackageJsonAnyDependency: (packageJson: NormalizedPackageJson,
|
|
|
2748
2748
|
}) => boolean;
|
|
2749
2749
|
declare const ensurePackages: (packageJson: NormalizedPackageJson, packages: string[], installKey?: "dependencies" | "devDependencies", options?: EnsurePackagesOptions) => Promise<void>;
|
|
2750
2750
|
|
|
2751
|
-
export { type EnsurePackagesOptions as E, type FindPackageJsonCache as F, type NormalizedReadResult as N, type PackageJson as P, findPackageJsonSync as a, hasPackageJsonProperty as b,
|
|
2751
|
+
export { type EnsurePackagesOptions as E, type FindPackageJsonCache as F, type NormalizedReadResult as N, type PackageJson as P, findPackageJsonSync as a, hasPackageJsonProperty as b, parsePackageJsonSync as c, writePackageJsonSync as d, ensurePackages as e, findPackageJson as f, getPackageJsonProperty as g, hasPackageJsonAnyDependency as h, type NormalizedPackageJson as i, parsePackageJson as p, writePackageJson as w };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@visulima/package",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.2",
|
|
4
4
|
"description": "A comprehensive package management utility that helps you find root directories, monorepos, package managers, and parse package.json files with advanced features like catalog resolution.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"anolilab",
|