@visulima/package 4.1.7 → 5.0.0-alpha.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,38 @@
1
+ ## @visulima/package [5.0.0-alpha.2](https://github.com/visulima/visulima/compare/@visulima/package@5.0.0-alpha.1...@visulima/package@5.0.0-alpha.2) (2025-12-11)
2
+
3
+ ### Bug Fixes
4
+
5
+ * update package OG images across multiple packages ([f08e4dd](https://github.com/visulima/visulima/commit/f08e4dd2b105ccb29c8412020a9c2be36d6c1e9e))
6
+
7
+
8
+ ### Dependencies
9
+
10
+ * **@visulima/fs:** upgraded to 5.0.0-alpha.2
11
+ * **@visulima/path:** upgraded to 3.0.0-alpha.3
12
+
13
+ ## @visulima/package [5.0.0-alpha.1](https://github.com/visulima/visulima/compare/@visulima/package@4.1.7...@visulima/package@5.0.0-alpha.1) (2025-12-07)
14
+
15
+ ### ⚠ BREAKING CHANGES
16
+
17
+ * change min node version to 22.13
18
+
19
+ ### Bug Fixes
20
+
21
+ * add new package image, fixed readme rendering on npm, fixed building of packages ([b790ba2](https://github.com/visulima/visulima/commit/b790ba253ea07fef83528fd822a678facf021b5f))
22
+ * update Node.js engine version requirement to >=22.13 in multiple package.json files for improved compatibility ([b828e9a](https://github.com/visulima/visulima/commit/b828e9aeaebfc798eecddccd90e6ec7560c6d36a))
23
+
24
+ ### Miscellaneous Chores
25
+
26
+ * moved all packages into groups ([0615e9d](https://github.com/visulima/visulima/commit/0615e9d14a8a886e11da529ce150cf31ca973c10))
27
+ * update @anolilab/semantic-release-pnpm and @anolilab/semantic-release-preset to versions 3.2.2 and 12.1.2 across multiple package.json files for improved compatibility ([3921626](https://github.com/visulima/visulima/commit/3921626141fe5da398749bf0ba675f1596f18afb))
28
+ * update dependencies across multiple packages to improve compatibility and performance, including upgrading `@anolilab/semantic-release-pnpm` and `@anolilab/semantic-release-preset` to versions 3.2.0 and 12.1.0 respectively, and updating `react`, `react-dom`, and `next` versions to 19.2.1 and 16.0.7 in various package.json files ([aee8fcd](https://github.com/visulima/visulima/commit/aee8fcd796ae9b8d055903260e7150996ea9f53d))
29
+ * upgrade `vitest` version to 4.0.15 in multiple package.json files and update lockfile for improved compatibility; adjust test cases for ESM package support in tooling tests ([0fba407](https://github.com/visulima/visulima/commit/0fba407e08283ba8c1c9488f99ca1f9ff676c4cf))
30
+
31
+
32
+ ### Dependencies
33
+
34
+ * **@visulima/fs:** upgraded to 5.0.0-alpha.1
35
+
1
36
  ## @visulima/package [4.1.7](https://github.com/visulima/visulima/compare/@visulima/package@4.1.6...@visulima/package@4.1.7) (2025-11-19)
2
37
 
3
38
  ### Miscellaneous Chores
package/README.md CHANGED
@@ -1,24 +1,24 @@
1
- <div align="center">
2
- <h3>Visulima package</h3>
3
- <p>
4
- 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 and caching.
1
+ <!-- START_PACKAGE_OG_IMAGE_PLACEHOLDER -->
5
2
 
6
- Built on top of
3
+ <a href="https://www.anolilab.com/open-source" align="center">
7
4
 
8
- [@visulima/fs](https://github.com/visulima/visulima/tree/main/packages/fs),
9
- [@visulima/path](https://github.com/visulima/visulima/tree/main/packages/path),
10
- [normalize-package-data](https://github.com/npm/normalize-package-data),
11
- [pathe](https://github.com/unjs/pathe), and
12
- [type-fest](https://github.com/sindresorhus/type-fest)
5
+ <img src="__assets__/package-og.svg" alt="package" />
13
6
 
14
- </p>
15
- </div>
7
+ </a>
8
+
9
+ <h3 align="center">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.</h3>
10
+
11
+ <!-- END_PACKAGE_OG_IMAGE_PLACEHOLDER -->
16
12
 
17
13
  <br />
18
14
 
19
15
  <div align="center">
20
16
 
21
- [![typescript-image]][typescript-url] [![npm-image]][npm-url] [![license-image]][license-url]
17
+ [![typescript-image][typescript-badge]][typescript-url]
18
+ [![mit licence][license-badge]][license]
19
+ [![npm downloads][npm-downloads-badge]][npm-downloads]
20
+ [![Chat][chat-badge]][chat]
21
+ [![PRs Welcome][prs-welcome-badge]][prs-welcome]
22
22
 
23
23
  </div>
24
24
 
@@ -357,14 +357,23 @@ If you would like to help take a look at the [list of issues](https://github.com
357
357
 
358
358
  - [read-pkg](https://github.com/sindresorhus/read-pkg) - Read a package.json file.
359
359
 
360
+ ## Made with ❤️ at Anolilab
361
+
362
+ This is an open source project and will always remain free to use. If you think it's cool, please star it 🌟. [Anolilab](https://www.anolilab.com/open-source) is a Development and AI Studio. Contact us at [hello@anolilab.com](mailto:hello@anolilab.com) if you need any help with these technologies or just want to say hi!
363
+
360
364
  ## License
361
365
 
362
- The visulima package is open-sourced software licensed under the [MIT][license-url]
366
+ The visulima package is open-sourced software licensed under the [MIT][license]
363
367
 
364
- [typescript-image]: https://img.shields.io/badge/Typescript-294E80.svg?style=for-the-badge&logo=typescript
368
+ <!-- badges -->
365
369
 
366
- [typescript-url]: https://www.typescriptlang.org/ "TypeScript" "typescript"
367
- [license-image]: https://img.shields.io/npm/l/@visulima/package?color=blueviolet&style=for-the-badge
368
- [license-url]: LICENSE.md "license"
369
- [npm-image]: https://img.shields.io/npm/v/@visulima/package/latest.svg?style=for-the-badge&logo=npm
370
- [npm-url]: https://www.npmjs.com/package/@visulima/package/v/latest "npm"
370
+ [license-badge]: https://img.shields.io/npm/l/@visulima/package?style=for-the-badge
371
+ [license]: https://github.com/visulima/visulima/blob/main/LICENSE
372
+ [npm-downloads-badge]: https://img.shields.io/npm/dm/@visulima/package?style=for-the-badge
373
+ [npm-downloads]: https://www.npmjs.com/package/@visulima/package
374
+ [prs-welcome-badge]: https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=for-the-badge
375
+ [prs-welcome]: https://github.com/visulima/visulima/blob/main/.github/CONTRIBUTING.md
376
+ [chat-badge]: https://img.shields.io/discord/932323359193186354.svg?style=for-the-badge
377
+ [chat]: https://discord.gg/TtFJY8xkFK
378
+ [typescript-badge]: https://img.shields.io/badge/Typescript-294E80.svg?style=for-the-badge&logo=typescript
379
+ [typescript-url]: https://www.typescriptlang.org/
@@ -1,3 +1,4 @@
1
- var q=Object.defineProperty;var f=(e,n)=>q(e,"name",{value:n,configurable:!0});import{createRequire as z}from"node:module";import{installPackage as V}from"@antfu/install-pkg";import G from"@inquirer/confirm";import{readJsonSync as U,readFileSync as X,findUp as H,findUpSync as L,writeJson as Q,writeJsonSync as Z,readJson as ee,readFile as ne}from"@visulima/fs";import{NotFoundError as J}from"@visulima/fs/error";import{parseJson as A,toPath as j}from"@visulima/fs/utils";import{readYamlSync as re,readYaml as te}from"@visulima/fs/yaml";import{join as S}from"@visulima/path";import N from"json5";import oe from"normalize-package-data";import{readPnpmCatalogsSync as I,resolveCatalogReferences as P,readPnpmCatalogs as T}from"./pnpm.js";const B=z(import.meta.url),y=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,K=f(e=>{if(typeof y<"u"&&y.versions&&y.versions.node){const[n,t]=y.versions.node.split(".").map(Number);if(n>22||n===22&&t>=3||n===20&&t>=16)return y.getBuiltinModule(e)}return B(e)},"__cjs_getBuiltinModule"),{existsSync:x}=K("node:fs");var se=Object.defineProperty,l=f((e,n)=>se(e,"name",{value:n,configurable:!0}),"f");const h=l(e=>{const n=typeof e;return e!==null&&(n==="object"||n==="function")},"isObject"),ae=l(e=>{if(!h(e))return!1;for(const n in e)if(Object.hasOwn(e,n))return!1;return!0},"isEmptyObject"),_=new Set(["__proto__","prototype","constructor"]),F=1e6,ie=l(e=>e>="0"&&e<="9","isDigit");function m(e){if(e==="0")return!0;if(/^[1-9]\d*$/.test(e)){const n=Number.parseInt(e,10);return n<=Number.MAX_SAFE_INTEGER&&n<=F}return!1}f(m,"p");l(m,"shouldCoerceToNumber");function b(e,n){return _.has(e)?!1:(e&&m(e)?n.push(Number.parseInt(e,10)):n.push(e),!0)}f(b,"y");l(b,"processSegment");function D(e){if(typeof e!="string")throw new TypeError(`Expected a string, got ${typeof e}`);const n=[];let t="",r="start",o=!1,s=0;for(const a of e){if(s++,o){t+=a,o=!1;continue}if(a==="\\"){if(r==="index")throw new Error(`Invalid character '${a}' in an index at position ${s}`);if(r==="indexEnd")throw new Error(`Invalid character '${a}' after an index at position ${s}`);o=!0,r=r==="start"?"property":r;continue}switch(a){case".":{if(r==="index")throw new Error(`Invalid character '${a}' in an index at position ${s}`);if(r==="indexEnd"){r="property";break}if(!b(t,n))return[];t="",r="property";break}case"[":{if(r==="index")throw new Error(`Invalid character '${a}' in an index at position ${s}`);if(r==="indexEnd"){r="index";break}if(r==="property"||r==="start"){if((t||r==="property")&&!b(t,n))return[];t=""}r="index";break}case"]":{if(r==="index"){if(t==="")t=(n.pop()||"")+"[]",r="property";else{const i=Number.parseInt(t,10);!Number.isNaN(i)&&Number.isFinite(i)&&i>=0&&i<=Number.MAX_SAFE_INTEGER&&i<=F&&t===String(i)?n.push(i):n.push(t),t="",r="indexEnd"}break}if(r==="indexEnd")throw new Error(`Invalid character '${a}' after an index at position ${s}`);t+=a;break}default:{if(r==="index"&&!ie(a))throw new Error(`Invalid character '${a}' in an index at position ${s}`);if(r==="indexEnd")throw new Error(`Invalid character '${a}' after an index at position ${s}`);r==="start"&&(r="property"),t+=a}}}switch(o&&(t+="\\"),r){case"property":{if(!b(t,n))return[];break}case"index":throw new Error("Index was not closed");case"start":{n.push("");break}}return n}f(D,"parsePath");l(D,"parsePath");function w(e){if(typeof e=="string")return D(e);if(Array.isArray(e)){const n=[];for(const[t,r]of e.entries()){if(typeof r!="string"&&typeof r!="number")throw new TypeError(`Expected a string or number for path segment at index ${t}, got ${typeof r}`);if(typeof r=="number"&&!Number.isFinite(r))throw new TypeError(`Path segment at index ${t} must be a finite number, got ${r}`);if(_.has(r))return[];typeof r=="string"&&m(r)?n.push(Number.parseInt(r,10)):n.push(r)}return n}return[]}f(w,"d");l(w,"normalizePath");function d(e,n,t){if(!h(e)||typeof n!="string"&&!Array.isArray(n))return t===void 0?e:t;const r=w(n);if(r.length===0)return t;for(let o=0;o<r.length;o++){const s=r[o];if(e=e[s],e==null){if(o!==r.length-1)return t;break}}return e===void 0?t:e}f(d,"getProperty");l(d,"getProperty");function C(e,n,t){if(!h(e)||typeof n!="string"&&!Array.isArray(n))return e;const r=e,o=w(n);if(o.length===0)return e;for(let s=0;s<o.length;s++){const a=o[s];if(s===o.length-1)e[a]=t;else if(!h(e[a])){const i=typeof o[s+1]=="number";e[a]=i?[]:{}}e=e[a]}return r}f(C,"setProperty");l(C,"setProperty");function ce(e,n){if(!h(e)||typeof n!="string"&&!Array.isArray(n))return!1;const t=w(n);if(t.length===0)return!1;for(let r=0;r<t.length;r++){const o=t[r];if(r===t.length-1)return Object.hasOwn(e,o)?(delete e[o],!0):!1;if(e=e[o],!h(e))return!1}}f(ce,"deleteProperty");l(ce,"deleteProperty");function g(e,n){if(!h(e)||typeof n!="string"&&!Array.isArray(n))return!1;const t=w(n);if(t.length===0)return!1;for(const r of t){if(!h(e)||!(r in e))return!1;e=e[r]}return!0}f(g,"hasProperty");l(g,"hasProperty");function $(e){if(typeof e!="string")throw new TypeError(`Expected a string, got ${typeof e}`);return e.replaceAll(/[\\.[]/g,String.raw`\$&`)}f($,"escapePath");l($,"escapePath");function O(e){const n=Object.entries(e);return Array.isArray(e)?n.map(([t,r])=>[m(t)?Number.parseInt(t,10):t,r]):n}f(O,"m$1");l(O,"normalizeEntries");function W(e,n={}){if(!Array.isArray(e))throw new TypeError(`Expected an array, got ${typeof e}`);const{preferDotForIndices:t=!1}=n,r=[];for(const[o,s]of e.entries()){if(typeof s!="string"&&typeof s!="number")throw new TypeError(`Expected a string or number for path segment at index ${o}, got ${typeof s}`);if(typeof s=="number")if(!Number.isInteger(s)||s<0){const a=$(String(s));r.push(o===0?a:`.${a}`)}else t&&o>0?r.push(`.${s}`):r.push(`[${s}]`);else if(typeof s=="string")if(s==="")o===0||r.push(".");else if(m(s)){const a=Number.parseInt(s,10);t&&o>0?r.push(`.${a}`):r.push(`[${a}]`)}else{const a=$(s);r.push(o===0?a:`.${a}`)}}return r.join("")}f(W,"stringifyPath");l(W,"stringifyPath");function*v(e,n=[],t=new Set){if(!h(e)||ae(e)){n.length>0&&(yield W(n));return}if(!t.has(e)){t.add(e);for(const[r,o]of O(e))n.push(r),yield*v(o,n,t),n.pop();t.delete(e)}}f(v,"x");l(v,"deepKeysIterator");function fe(e){return[...v(e)]}f(fe,"deepKeys");l(fe,"deepKeys");function pe(e){const n={};if(!h(e))return n;for(const[t,r]of Object.entries(e))C(n,t,r);return n}f(pe,"unflatten");l(pe,"unflatten");const le=typeof process.stdout<"u"&&!process.versions.deno&&!globalThis.window;var ue=Object.defineProperty,p=f((e,n)=>ue(e,"name",{value:n,configurable:!0}),"l");const k=new Map,M=new Map;class he extends Error{static{f(this,"F")}static{p(this,"PackageJsonValidationError")}constructor(n){super(`The following warnings were encountered while normalizing package data:
2
- - ${n.join(`
3
- - `)}`),this.name="PackageJsonValidationError"}}const E=p((e,n,t=[])=>{const r=[];if(oe(e,o=>{r.push(o)},n),n&&r.length>0){const o=r.filter(s=>!t.some(a=>a instanceof RegExp?a.test(s):a===s));if(o.length>0)throw new he(o)}return e},"normalizeInput"),de=p(async e=>await te(e),"parseYamlFile"),ge=p(e=>re(e),"parseYamlFileSync"),ye=p(async e=>{const n=await ne(e);return N.parse(n)},"parseJson5File"),me=p(e=>{const n=X(e);return N.parse(n)},"parseJson5FileSync"),R=p(async(e,n)=>n?.yaml!==!1&&(e.endsWith(".yaml")||e.endsWith(".yml"))?de(e):n?.json5!==!1&&e.endsWith(".json5")?ye(e):ee(e),"parsePackageFile"),Y=p((e,n)=>n?.yaml!==!1&&(e.endsWith(".yaml")||e.endsWith(".yml"))?ge(e):n?.json5!==!1&&e.endsWith(".json5")?me(e):U(e),"parsePackageFileSync"),Ne=p(async(e,n={})=>{const t={type:"file"};e&&(t.cwd=e);const r=["package.json"];n.yaml!==!1&&r.push("package.yaml","package.yml"),n.json5!==!1&&r.push("package.json5");let o;for await(const c of r)if(o=await H(c,t),o)break;if(!o)throw new J(`No such file or directory, for ${r.join(", ").replace(/, ([^,]*)$/," or $1")} found.`);const s=n.cache&&typeof n.cache!="boolean"?n.cache:M;if(n.cache&&s.has(o))return s.get(o);const a=await R(o,n);if(n.resolveCatalogs){const c=await T(o);c&&P(a,c)}E(a,n.strict??!1,n.ignoreWarnings);const i={packageJson:a,path:o};return n.cache&&s.set(o,i),i},"findPackageJson"),Ie=p((e,n={})=>{const t={type:"file"};e&&(t.cwd=e);const r=["package.json"];n.yaml!==!1&&r.push("package.yaml","package.yml"),n.json5!==!1&&r.push("package.json5");let o;for(const c of r)if(o=L(c,t),o)break;if(!o)throw new J(`No such file or directory, for ${r.join(", ").replace(/, ([^,]*)$/," or $1")} found.`);const s=n.cache&&typeof n.cache!="boolean"?n.cache:M;if(n.cache&&s.has(o))return s.get(o);const a=Y(o,n);if(n.resolveCatalogs){const c=I(o);c&&P(a,c)}E(a,n.strict??!1,n.ignoreWarnings);const i={packageJson:a,path:o};return n.cache&&s.set(o,i),i},"findPackageJsonSync"),Te=p(async(e,n={})=>{const{cwd:t,...r}=n,o=j(n.cwd??process.cwd());await Q(S(o,"package.json"),e,r)},"writePackageJson"),_e=p((e,n={})=>{const{cwd:t,...r}=n,o=j(n.cwd??process.cwd());Z(S(o,"package.json"),e,r)},"writePackageJsonSync"),Fe=p((e,n)=>{const t=e!==null&&typeof e=="object"&&!Array.isArray(e);if(!t&&typeof e!="string")throw new TypeError("`packageFile` should be either an `object` or a `string`.");let r,o=!1,s;if(t)r=structuredClone(e);else if(x(e)){s=e;const i=n?.cache&&typeof n.cache!="boolean"?n.cache:k;if(n?.cache&&i.has(s))return i.get(s);r=Y(s,n),o=!0}else r=A(e);if(n?.resolveCatalogs)if(o){const i=I(e);i&&P(r,i)}else throw new Error("The 'resolveCatalogs' option can only be used on a file path.");E(r,n?.strict??!1,n?.ignoreWarnings);const a=r;return o&&s&&n?.cache&&(n.cache&&typeof n.cache!="boolean"?n.cache:k).set(s,a),a},"parsePackageJsonSync"),De=p(async(e,n)=>{const t=e!==null&&typeof e=="object"&&!Array.isArray(e);if(!t&&typeof e!="string")throw new TypeError("`packageFile` should be either an `object` or a `string`.");let r,o=!1,s;if(t)r=structuredClone(e);else if(x(e)){s=e;const i=n?.cache&&typeof n.cache!="boolean"?n.cache:k;if(n?.cache&&i.has(s))return i.get(s);r=await R(s,n),o=!0}else r=A(e);if(n?.resolveCatalogs)if(o){const i=await T(e);i&&P(r,i)}else throw new Error("The 'resolveCatalogs' option can only be used on a file path.");E(r,n?.strict??!1,n?.ignoreWarnings);const a=r;return o&&s&&n?.cache&&(n.cache&&typeof n.cache!="boolean"?n.cache:k).set(s,a),a},"parsePackageJson"),Ce=p((e,n,t)=>d(e,n,t),"getPackageJsonProperty"),Oe=p((e,n)=>g(e,n),"hasPackageJsonProperty"),We=p((e,n,t)=>{const r=d(e,"dependencies",{}),o=d(e,"devDependencies",{}),s=d(e,"peerDependencies",{}),a={...r,...o,...t?.peerDeps===!1?{}:s};for(const i of n)if(g(a,i))return!0;return!1},"hasPackageJsonAnyDependency"),Me=p(async(e,n,t="dependencies",r={})=>{const o=d(e,"dependencies",{}),s=d(e,"devDependencies",{}),a=d(e,"peerDependencies",{}),i=[],c={deps:!0,devDeps:!0,peerDeps:!1,...r};for(const u of n)c.deps&&g(o,u)||c.devDeps&&g(s,u)||c.peerDeps&&g(a,u)||i.push(u);if(i.length!==0){if(process.env.CI||le&&!process.stdout?.isTTY){const u=`Skipping package installation for [${n.join(", ")}] because the process is not interactive.`;if(r.throwOnWarn)throw new Error(u);r.logger?.warn?r.logger.warn(u):console.warn(u);return}if(typeof c.confirm?.message=="function"&&(c.confirm.message=c.confirm.message(i)),c.confirm?.message===void 0){const u=`${i.length===1?"Package is":"Packages are"} required for this config: ${i.join(", ")}. Do you want to install them?`;c.confirm===void 0?c.confirm={message:u}:c.confirm.message=u}await G(c.confirm)&&await V(i,{...c.installPackage,cwd:c.cwd?j(c.cwd):void 0,dev:t==="devDependencies"})}},"ensurePackages");export{Me as ensurePackages,Ne as findPackageJson,Ie as findPackageJsonSync,Ce as getPackageJsonProperty,We as hasPackageJsonAnyDependency,Oe as hasPackageJsonProperty,De as parsePackageJson,Fe as parsePackageJsonSync,Te as writePackageJson,_e as writePackageJsonSync};
1
+ var K=Object.defineProperty;var f=(e,r)=>K(e,"name",{value:r,configurable:!0});import{createRequire as V}from"node:module";import{installPackage as X}from"@antfu/install-pkg";import{readJsonSync as L,readFileSync as H,findUp as Q,findUpSync as Z,writeJson as ee,writeJsonSync as re,readJson as ne,readFile as te}from"@visulima/fs";import{NotFoundError as I}from"@visulima/fs/error";import{parseJson as T,toPath as A}from"@visulima/fs/utils";import{readYamlSync as oe,readYaml as se}from"@visulima/fs/yaml";import{join as _}from"@visulima/path";import F from"json5";import ae from"normalize-package-data";import{readPnpmCatalogsSync as D,resolveCatalogReferences as E,readPnpmCatalogs as C}from"./pnpm.js";const U=V(import.meta.url),w=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,J=f(e=>{if(typeof w<"u"&&w.versions&&w.versions.node){const[r,t]=w.versions.node.split(".").map(Number);if(r>22||r===22&&t>=3||r===20&&t>=16)return w.getBuiltinModule(e)}return U(e)},"__cjs_getBuiltinModule"),{existsSync:N}=J("node:fs"),{createInterface:ie}=J("node:readline"),{styleText:g}=J("node:util");var ce=Object.defineProperty,l=f((e,r)=>ce(e,"name",{value:r,configurable:!0}),"f");const h=l(e=>{const r=typeof e;return e!==null&&(r==="object"||r==="function")},"isObject"),fe=l(e=>{if(!h(e))return!1;for(const r in e)if(Object.hasOwn(e,r))return!1;return!0},"isEmptyObject"),O=new Set(["__proto__","prototype","constructor"]),W=1e6,pe=l(e=>e>="0"&&e<="9","isDigit");function b(e){if(e==="0")return!0;if(/^[1-9]\d*$/.test(e)){const r=Number.parseInt(e,10);return r<=Number.MAX_SAFE_INTEGER&&r<=W}return!1}f(b,"p$1");l(b,"shouldCoerceToNumber");function k(e,r){return O.has(e)?!1:(e&&b(e)?r.push(Number.parseInt(e,10)):r.push(e),!0)}f(k,"y");l(k,"processSegment");function B(e){if(typeof e!="string")throw new TypeError(`Expected a string, got ${typeof e}`);const r=[];let t="",n="start",o=!1,s=0;for(const a of e){if(s++,o){t+=a,o=!1;continue}if(a==="\\"){if(n==="index")throw new Error(`Invalid character '${a}' in an index at position ${s}`);if(n==="indexEnd")throw new Error(`Invalid character '${a}' after an index at position ${s}`);o=!0,n=n==="start"?"property":n;continue}switch(a){case".":{if(n==="index")throw new Error(`Invalid character '${a}' in an index at position ${s}`);if(n==="indexEnd"){n="property";break}if(!k(t,r))return[];t="",n="property";break}case"[":{if(n==="index")throw new Error(`Invalid character '${a}' in an index at position ${s}`);if(n==="indexEnd"){n="index";break}if(n==="property"||n==="start"){if((t||n==="property")&&!k(t,r))return[];t=""}n="index";break}case"]":{if(n==="index"){if(t==="")t=(r.pop()||"")+"[]",n="property";else{const i=Number.parseInt(t,10);!Number.isNaN(i)&&Number.isFinite(i)&&i>=0&&i<=Number.MAX_SAFE_INTEGER&&i<=W&&t===String(i)?r.push(i):r.push(t),t="",n="indexEnd"}break}if(n==="indexEnd")throw new Error(`Invalid character '${a}' after an index at position ${s}`);t+=a;break}default:{if(n==="index"&&!pe(a))throw new Error(`Invalid character '${a}' in an index at position ${s}`);if(n==="indexEnd")throw new Error(`Invalid character '${a}' after an index at position ${s}`);n==="start"&&(n="property"),t+=a}}}switch(o&&(t+="\\"),n){case"property":{if(!k(t,r))return[];break}case"index":throw new Error("Index was not closed");case"start":{r.push("");break}}return r}f(B,"parsePath");l(B,"parsePath");function $(e){if(typeof e=="string")return B(e);if(Array.isArray(e)){const r=[];for(const[t,n]of e.entries()){if(typeof n!="string"&&typeof n!="number")throw new TypeError(`Expected a string or number for path segment at index ${t}, got ${typeof n}`);if(typeof n=="number"&&!Number.isFinite(n))throw new TypeError(`Path segment at index ${t} must be a finite number, got ${n}`);if(O.has(n))return[];typeof n=="string"&&b(n)?r.push(Number.parseInt(n,10)):r.push(n)}return r}return[]}f($,"d");l($,"normalizePath");function d(e,r,t){if(!h(e)||typeof r!="string"&&!Array.isArray(r))return t===void 0?e:t;const n=$(r);if(n.length===0)return t;for(let o=0;o<n.length;o++){const s=n[o];if(e=e[s],e==null){if(o!==n.length-1)return t;break}}return e===void 0?t:e}f(d,"getProperty");l(d,"getProperty");function M(e,r,t){if(!h(e)||typeof r!="string"&&!Array.isArray(r))return e;const n=e,o=$(r);if(o.length===0)return e;for(let s=0;s<o.length;s++){const a=o[s];if(s===o.length-1)e[a]=t;else if(!h(e[a])){const i=typeof o[s+1]=="number";e[a]=i?[]:{}}e=e[a]}return n}f(M,"setProperty");l(M,"setProperty");function le(e,r){if(!h(e)||typeof r!="string"&&!Array.isArray(r))return!1;const t=$(r);if(t.length===0)return!1;for(let n=0;n<t.length;n++){const o=t[n];if(n===t.length-1)return Object.hasOwn(e,o)?(delete e[o],!0):!1;if(e=e[o],!h(e))return!1}}f(le,"deleteProperty");l(le,"deleteProperty");function y(e,r){if(!h(e)||typeof r!="string"&&!Array.isArray(r))return!1;const t=$(r);if(t.length===0)return!1;for(const n of t){if(!h(e)||!(n in e))return!1;e=e[n]}return!0}f(y,"hasProperty");l(y,"hasProperty");function x(e){if(typeof e!="string")throw new TypeError(`Expected a string, got ${typeof e}`);return e.replaceAll(/[\\.[]/g,String.raw`\$&`)}f(x,"escapePath");l(x,"escapePath");function R(e){const r=Object.entries(e);return Array.isArray(e)?r.map(([t,n])=>[b(t)?Number.parseInt(t,10):t,n]):r}f(R,"m$2");l(R,"normalizeEntries");function Y(e,r={}){if(!Array.isArray(e))throw new TypeError(`Expected an array, got ${typeof e}`);const{preferDotForIndices:t=!1}=r,n=[];for(const[o,s]of e.entries()){if(typeof s!="string"&&typeof s!="number")throw new TypeError(`Expected a string or number for path segment at index ${o}, got ${typeof s}`);if(typeof s=="number")if(!Number.isInteger(s)||s<0){const a=x(String(s));n.push(o===0?a:`.${a}`)}else t&&o>0?n.push(`.${s}`):n.push(`[${s}]`);else if(typeof s=="string")if(s==="")o===0||n.push(".");else if(b(s)){const a=Number.parseInt(s,10);t&&o>0?n.push(`.${a}`):n.push(`[${a}]`)}else{const a=x(s);n.push(o===0?a:`.${a}`)}}return n.join("")}f(Y,"stringifyPath");l(Y,"stringifyPath");function*S(e,r=[],t=new Set){if(!h(e)||fe(e)){r.length>0&&(yield Y(r));return}if(!t.has(e)){t.add(e);for(const[n,o]of R(e))r.push(n),yield*S(o,r,t),r.pop();t.delete(e)}}f(S,"x");l(S,"deepKeysIterator");function ue(e){return[...S(e)]}f(ue,"deepKeys");l(ue,"deepKeys");function ge(e){const r={};if(!h(e))return r;for(const[t,n]of Object.entries(e))M(r,t,n);return r}f(ge,"unflatten");l(ge,"unflatten");var he=Object.defineProperty,j=f((e,r)=>he(e,"name",{value:r,configurable:!0}),"i");const de=j(async e=>{const{default:r=!1,message:t,transformer:n}=e,o=j(a=>{const i=g(["cyan","bold"],"?"),c=g(["bold"],a),u=r?`${g(["greenBright"],"Y")}${g(["gray"],"/n")}`:`y/${g(["yellowBright"],"N")}`;return`${i} ${c} ${g(["gray"],`(${u})`)}`},"formatMessage"),s=j(a=>n?n(a):a?g(["greenBright"],"Yes"):g(["yellowBright"],"No"),"formatAnswer");return new Promise(a=>{const i=ie({input:process.stdin,output:process.stdout}),c=o(t);i.question(c,u=>{i.close();const m=u.trim().toLowerCase();if(m===""){a(r);return}if(m==="y"||m==="yes"){console.log(`${g(["greenBright"],"✓")} ${s(!0)}`),a(!0);return}if(m==="n"||m==="no"){console.log(`${g(["yellowBright"],"✗")} ${s(!1)}`),a(!1);return}console.log(`${g(["gray"],"→")} ${s(r)}`),a(r)}),i.on("SIGINT",()=>{i.close(),console.log(`
2
+ ${g(["gray"],"→")} ${s(r)}`),a(r)})})},"confirm"),ye=typeof process.stdout<"u"&&!process.versions.deno&&!globalThis.window;var me=Object.defineProperty,p=f((e,r)=>me(e,"name",{value:r,configurable:!0}),"l");const P=new Map,q=new Map;class we extends Error{static{f(this,"F")}static{p(this,"PackageJsonValidationError")}constructor(r){super(`The following warnings were encountered while normalizing package data:
3
+ - ${r.join(`
4
+ - `)}`),this.name="PackageJsonValidationError"}}const v=p((e,r,t=[])=>{const n=[];if(ae(e,o=>{n.push(o)},r),r&&n.length>0){const o=n.filter(s=>!t.some(a=>a instanceof RegExp?a.test(s):a===s));if(o.length>0)throw new we(o)}return e},"normalizeInput"),be=p(async e=>await se(e),"parseYamlFile"),$e=p(e=>oe(e),"parseYamlFileSync"),ke=p(async e=>{const r=await te(e);return F.parse(r)},"parseJson5File"),Pe=p(e=>{const r=H(e);return F.parse(r)},"parseJson5FileSync"),z=p(async(e,r)=>r?.yaml!==!1&&(e.endsWith(".yaml")||e.endsWith(".yml"))?be(e):r?.json5!==!1&&e.endsWith(".json5")?ke(e):ne(e),"parsePackageFile"),G=p((e,r)=>r?.yaml!==!1&&(e.endsWith(".yaml")||e.endsWith(".yml"))?$e(e):r?.json5!==!1&&e.endsWith(".json5")?Pe(e):L(e),"parsePackageFileSync"),Fe=p(async(e,r={})=>{const t={type:"file"};e&&(t.cwd=e);const n=["package.json"];r.yaml!==!1&&n.push("package.yaml","package.yml"),r.json5!==!1&&n.push("package.json5");let o;for await(const c of n)if(o=await Q(c,t),o)break;if(!o)throw new I(`No such file or directory, for ${n.join(", ").replace(/, ([^,]*)$/," or $1")} found.`);const s=r.cache&&typeof r.cache!="boolean"?r.cache:q;if(r.cache&&s.has(o))return s.get(o);const a=await z(o,r);if(r.resolveCatalogs){const c=await C(o);c&&E(a,c)}v(a,r.strict??!1,r.ignoreWarnings);const i={packageJson:a,path:o};return r.cache&&s.set(o,i),i},"findPackageJson"),De=p((e,r={})=>{const t={type:"file"};e&&(t.cwd=e);const n=["package.json"];r.yaml!==!1&&n.push("package.yaml","package.yml"),r.json5!==!1&&n.push("package.json5");let o;for(const c of n)if(o=Z(c,t),o)break;if(!o)throw new I(`No such file or directory, for ${n.join(", ").replace(/, ([^,]*)$/," or $1")} found.`);const s=r.cache&&typeof r.cache!="boolean"?r.cache:q;if(r.cache&&s.has(o))return s.get(o);const a=G(o,r);if(r.resolveCatalogs){const c=D(o);c&&E(a,c)}v(a,r.strict??!1,r.ignoreWarnings);const i={packageJson:a,path:o};return r.cache&&s.set(o,i),i},"findPackageJsonSync"),Ce=p(async(e,r={})=>{const{cwd:t,...n}=r,o=A(t??process.cwd());await ee(_(o,"package.json"),e,n)},"writePackageJson"),Oe=p((e,r={})=>{const{cwd:t,...n}=r,o=A(t??process.cwd());re(_(o,"package.json"),e,n)},"writePackageJsonSync"),We=p((e,r)=>{const t=e!==null&&typeof e=="object"&&!Array.isArray(e);if(!t&&typeof e!="string")throw new TypeError("`packageFile` should be either an `object` or a `string`.");let n,o=!1,s;if(t)n=structuredClone(e);else if(N(e)){s=e;const i=r?.cache&&typeof r.cache!="boolean"?r.cache:P;if(r?.cache&&i.has(s))return i.get(s);n=G(s,r),o=!0}else n=T(e);if(r?.resolveCatalogs)if(o){const i=D(e);i&&E(n,i)}else throw new Error("The 'resolveCatalogs' option can only be used on a file path.");v(n,r?.strict??!1,r?.ignoreWarnings);const a=n;return o&&s&&r?.cache&&(r.cache&&typeof r.cache!="boolean"?r.cache:P).set(s,a),a},"parsePackageJsonSync"),Be=p(async(e,r)=>{const t=e!==null&&typeof e=="object"&&!Array.isArray(e);if(!t&&typeof e!="string")throw new TypeError("`packageFile` should be either an `object` or a `string`.");let n,o=!1,s;if(t)n=structuredClone(e);else if(N(e)){s=e;const i=r?.cache&&typeof r.cache!="boolean"?r.cache:P;if(r?.cache&&i.has(s))return i.get(s);n=await z(s,r),o=!0}else n=T(e);if(r?.resolveCatalogs)if(o){const i=await C(e);i&&E(n,i)}else throw new Error("The 'resolveCatalogs' option can only be used on a file path.");v(n,r?.strict??!1,r?.ignoreWarnings);const a=n;return o&&s&&r?.cache&&(r.cache&&typeof r.cache!="boolean"?r.cache:P).set(s,a),a},"parsePackageJson"),Me=p((e,r,t)=>d(e,r,t),"getPackageJsonProperty"),Re=p((e,r)=>y(e,r),"hasPackageJsonProperty"),Ye=p((e,r,t)=>{const n=d(e,"dependencies",{}),o=d(e,"devDependencies",{}),s=d(e,"peerDependencies",{}),a={...n,...o,...t?.peerDeps===!1?{}:s};for(const i of r)if(y(a,i))return!0;return!1},"hasPackageJsonAnyDependency"),qe=p(async(e,r,t="dependencies",n={})=>{const o=d(e,"dependencies",{}),s=d(e,"devDependencies",{}),a=d(e,"peerDependencies",{}),i=[],c={deps:!0,devDeps:!0,peerDeps:!1,...n};for(const u of r)c.deps&&y(o,u)||c.devDeps&&y(s,u)||c.peerDeps&&y(a,u)||i.push(u);if(i.length!==0){if(process.env.CI||ye&&!process.stdout?.isTTY){const u=`Skipping package installation for [${r.join(", ")}] because the process is not interactive.`;if(n.throwOnWarn)throw new Error(u);n.logger?.warn?n.logger.warn(u):console.warn(u);return}if(typeof c.confirm?.message=="function"&&(c.confirm.message=c.confirm.message(i)),c.confirm?.message===void 0){const u=`${i.length===1?"Package is":"Packages are"} required for this config: ${i.join(", ")}. Do you want to install them?`;c.confirm===void 0?c.confirm={message:u}:c.confirm.message=u}await de(c.confirm)&&await X(i,{...c.installPackage,cwd:c.cwd?A(c.cwd):void 0,dev:t==="devDependencies"})}},"ensurePackages");export{qe as ensurePackages,Fe as findPackageJson,De as findPackageJsonSync,Me as getPackageJsonProperty,Ye as hasPackageJsonAnyDependency,Re as hasPackageJsonProperty,Be as parsePackageJson,We as parsePackageJsonSync,Ce as writePackageJson,Oe as writePackageJsonSync};
@@ -0,0 +1,11 @@
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visulima/package",
3
- "version": "4.1.7",
3
+ "version": "5.0.0-alpha.2",
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",
@@ -39,7 +39,7 @@
39
39
  "repository": {
40
40
  "type": "git",
41
41
  "url": "git+https://github.com/visulima/visulima.git",
42
- "directory": "packages/package"
42
+ "directory": "packages/tooling/package"
43
43
  },
44
44
  "funding": [
45
45
  {
@@ -97,15 +97,15 @@
97
97
  ],
98
98
  "dependencies": {
99
99
  "@antfu/install-pkg": "^1.1.0",
100
- "@inquirer/confirm": "^5.1.21",
101
- "@visulima/fs": "4.1.0",
102
- "@visulima/path": "2.0.5",
100
+ "@visulima/fs": "5.0.0-alpha.2",
101
+ "@visulima/path": "3.0.0-alpha.3",
103
102
  "json5": "^2.2.3",
104
103
  "normalize-package-data": "^8.0.0",
105
- "yaml": "^2.8.1"
104
+ "type-fest": "^5.3.0",
105
+ "yaml": "^2.8.2"
106
106
  },
107
107
  "engines": {
108
- "node": ">=20.19 <=25.x"
108
+ "node": ">=22.13 <=25.x"
109
109
  },
110
110
  "os": [
111
111
  "darwin",