@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 CHANGED
@@ -1,3 +1,5 @@
1
+ ## @visulima/package [5.0.13](https://github.com/visulima/visulima/compare/%40visulima%2Fpackage%405.0.12...%40visulima%2Fpackage%405.0.13) (2026-08-17)
2
+
1
3
  ## @visulima/package [5.0.12](https://github.com/visulima/visulima/compare/%40visulima%2Fpackage%405.0.11...%40visulima%2Fpackage%405.0.12) (2026-08-08)
2
4
 
3
5
 
package/LICENSE.md CHANGED
@@ -47,70 +47,135 @@ Repository: sindresorhus/dot-prop
47
47
  <!-- TYPE_DEPENDENCIES -->
48
48
 
49
49
  # Licenses of bundled types
50
-
51
50
  The published @visulima/package artifact additionally contains code with the following licenses:
52
- MIT
51
+ (MIT OR CC0-1.0)
53
52
 
54
53
  # Bundled types:
54
+ ## type-fest
55
+ License: (MIT OR CC0-1.0)
56
+ By: Sindre Sorhus
57
+ Repository: sindresorhus/type-fest
55
58
 
56
- ## @inquirer/core
57
-
58
- License: MIT
59
- By: Simon Boudrias
60
- Repository: https://github.com/SBoudrias/Inquirer.js.git
61
-
62
- > Copyright (c) 2025 Simon Boudrias
63
- >
64
- > Permission is hereby granted, free of charge, to any person
65
- > obtaining a copy of this software and associated documentation
66
- > files (the "Software"), to deal in the Software without
67
- > restriction, including without limitation the rights to use,
68
- > copy, modify, merge, publish, distribute, sublicense, and/or sell
69
- > copies of the Software, and to permit persons to whom the
70
- > Software is furnished to do so, subject to the following
71
- > conditions:
72
- >
73
- > The above copyright notice and this permission notice shall be
74
- > included in all copies or substantial portions of the Software.
75
- >
76
- > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
77
- > EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
78
- > OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
79
- > NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
80
- > HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
81
- > WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
82
- > FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
83
- > OTHER DEALINGS IN THE SOFTWARE.
84
-
85
- ---
86
-
87
- ## @inquirer/type
88
-
89
- License: MIT
90
- By: Simon Boudrias
91
- Repository: https://github.com/SBoudrias/Inquirer.js.git
92
-
93
- > Copyright (c) 2025 Simon Boudrias
94
- >
95
- > Permission is hereby granted, free of charge, to any person
96
- > obtaining a copy of this software and associated documentation
97
- > files (the "Software"), to deal in the Software without
98
- > restriction, including without limitation the rights to use,
99
- > copy, modify, merge, publish, distribute, sublicense, and/or sell
100
- > copies of the Software, and to permit persons to whom the
101
- > Software is furnished to do so, subject to the following
102
- > conditions:
103
- >
104
- > The above copyright notice and this permission notice shall be
105
- > included in all copies or substantial portions of the Software.
106
- >
107
- > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
108
- > EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
109
- > OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
110
- > NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
111
- > HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
112
- > WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
113
- > FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
114
- > OTHER DEALINGS IN THE SOFTWARE.
59
+ > Creative Commons Legal Code
60
+ >
61
+ > CC0 1.0 Universal
62
+ >
63
+ > CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
64
+ > LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
65
+ > ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
66
+ > INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
67
+ > REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
68
+ > PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
69
+ > THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
70
+ > HEREUNDER.
71
+ >
72
+ > Statement of Purpose
73
+ >
74
+ > The laws of most jurisdictions throughout the world automatically confer
75
+ > exclusive Copyright and Related Rights (defined below) upon the creator
76
+ > and subsequent owner(s) (each and all, an "owner") of an original work of
77
+ > authorship and/or a database (each, a "Work").
78
+ >
79
+ > Certain owners wish to permanently relinquish those rights to a Work for
80
+ > the purpose of contributing to a commons of creative, cultural and
81
+ > scientific works ("Commons") that the public can reliably and without fear
82
+ > of later claims of infringement build upon, modify, incorporate in other
83
+ > works, reuse and redistribute as freely as possible in any form whatsoever
84
+ > and for any purposes, including without limitation commercial purposes.
85
+ > These owners may contribute to the Commons to promote the ideal of a free
86
+ > culture and the further production of creative, cultural and scientific
87
+ > works, or to gain reputation or greater distribution for their Work in
88
+ > part through the use and efforts of others.
89
+ >
90
+ > For these and/or other purposes and motivations, and without any
91
+ > expectation of additional consideration or compensation, the person
92
+ > associating CC0 with a Work (the "Affirmer"), to the extent that he or she
93
+ > is an owner of Copyright and Related Rights in the Work, voluntarily
94
+ > elects to apply CC0 to the Work and publicly distribute the Work under its
95
+ > terms, with knowledge of his or her Copyright and Related Rights in the
96
+ > Work and the meaning and intended legal effect of CC0 on those rights.
97
+ >
98
+ > 1. Copyright and Related Rights. A Work made available under CC0 may be
99
+ > protected by copyright and related or neighboring rights ("Copyright and
100
+ > Related Rights"). Copyright and Related Rights include, but are not
101
+ > limited to, the following:
102
+ >
103
+ > i. the right to reproduce, adapt, distribute, perform, display,
104
+ > communicate, and translate a Work;
105
+ > ii. moral rights retained by the original author(s) and/or performer(s);
106
+ > iii. publicity and privacy rights pertaining to a person's image or
107
+ > likeness depicted in a Work;
108
+ > iv. rights protecting against unfair competition in regards to a Work,
109
+ > subject to the limitations in paragraph 4(a), below;
110
+ > v. rights protecting the extraction, dissemination, use and reuse of data
111
+ > in a Work;
112
+ > vi. database rights (such as those arising under Directive 96/9/EC of the
113
+ > European Parliament and of the Council of 11 March 1996 on the legal
114
+ > protection of databases, and under any national implementation
115
+ > thereof, including any amended or successor version of such
116
+ > directive); and
117
+ > vii. other similar, equivalent or corresponding rights throughout the
118
+ > world based on applicable law or treaty, and any national
119
+ > implementations thereof.
120
+ >
121
+ > 2. Waiver. To the greatest extent permitted by, but not in contravention
122
+ > of, applicable law, Affirmer hereby overtly, fully, permanently,
123
+ > irrevocably and unconditionally waives, abandons, and surrenders all of
124
+ > Affirmer's Copyright and Related Rights and associated claims and causes
125
+ > of action, whether now known or unknown (including existing as well as
126
+ > future claims and causes of action), in the Work (i) in all territories
127
+ > worldwide, (ii) for the maximum duration provided by applicable law or
128
+ > treaty (including future time extensions), (iii) in any current or future
129
+ > medium and for any number of copies, and (iv) for any purpose whatsoever,
130
+ > including without limitation commercial, advertising or promotional
131
+ > purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
132
+ > member of the public at large and to the detriment of Affirmer's heirs and
133
+ > successors, fully intending that such Waiver shall not be subject to
134
+ > revocation, rescission, cancellation, termination, or any other legal or
135
+ > equitable action to disrupt the quiet enjoyment of the Work by the public
136
+ > as contemplated by Affirmer's express Statement of Purpose.
137
+ >
138
+ > 3. Public License Fallback. Should any part of the Waiver for any reason
139
+ > be judged legally invalid or ineffective under applicable law, then the
140
+ > Waiver shall be preserved to the maximum extent permitted taking into
141
+ > account Affirmer's express Statement of Purpose. In addition, to the
142
+ > extent the Waiver is so judged Affirmer hereby grants to each affected
143
+ > person a royalty-free, non transferable, non sublicensable, non exclusive,
144
+ > irrevocable and unconditional license to exercise Affirmer's Copyright and
145
+ > Related Rights in the Work (i) in all territories worldwide, (ii) for the
146
+ > maximum duration provided by applicable law or treaty (including future
147
+ > time extensions), (iii) in any current or future medium and for any number
148
+ > of copies, and (iv) for any purpose whatsoever, including without
149
+ > limitation commercial, advertising or promotional purposes (the
150
+ > "License"). The License shall be deemed effective as of the date CC0 was
151
+ > applied by Affirmer to the Work. Should any part of the License for any
152
+ > reason be judged legally invalid or ineffective under applicable law, such
153
+ > partial invalidity or ineffectiveness shall not invalidate the remainder
154
+ > of the License, and in such case Affirmer hereby affirms that he or she
155
+ > will not (i) exercise any of his or her remaining Copyright and Related
156
+ > Rights in the Work or (ii) assert any associated claims and causes of
157
+ > action with respect to the Work, in either case contrary to Affirmer's
158
+ > express Statement of Purpose.
159
+ >
160
+ > 4. Limitations and Disclaimers.
161
+ >
162
+ > a. No trademark or patent rights held by Affirmer are waived, abandoned,
163
+ > surrendered, licensed or otherwise affected by this document.
164
+ > b. Affirmer offers the Work as-is and makes no representations or
165
+ > warranties of any kind concerning the Work, express, implied,
166
+ > statutory or otherwise, including without limitation warranties of
167
+ > title, merchantability, fitness for a particular purpose, non
168
+ > infringement, or the absence of latent or other defects, accuracy, or
169
+ > the present or absence of errors, whether or not discoverable, all to
170
+ > the greatest extent permissible under applicable law.
171
+ > c. Affirmer disclaims responsibility for clearing rights of other persons
172
+ > that may apply to the Work or any use thereof, including without
173
+ > limitation any person's Copyright and Related Rights in the Work.
174
+ > Further, Affirmer disclaims responsibility for obtaining any necessary
175
+ > consents, permissions or other rights required for any use of the
176
+ > Work.
177
+ > d. Affirmer understands and acknowledges that Creative Commons is not a
178
+ > party to this document and has no duty or obligation with respect to
179
+ > this CC0 or use of the Work.
115
180
 
116
181
  <!-- /TYPE_DEPENDENCIES -->
package/dist/error.js CHANGED
@@ -1 +1 @@
1
- import{default as a}from"./packem_shared/PackageNotFoundError-Bi41exhP.js";export{a as PackageNotFoundError};
1
+ import{default as a}from"./packem_shared/PackageNotFoundError-PwPSQ1F3.js";export{a as PackageNotFoundError};
package/dist/index.d.ts CHANGED
@@ -2,12 +2,10 @@ export { PackageNotFoundError } from "./error.js";
2
2
  export { type LockFileEntry, type LockFileIntegrity, type LockFileIntegrityAlgorithm, type LockFileParseResult, type LockFileType, decodeSriIntegrity, parseBunLockFile, parseLockFile, parseLockFileContent, parseLockFileSync, parseNpmLockFile, parsePnpmLockFile, parseYarnLockFile } from "./lockfile.js";
3
3
  export { type RootMonorepo, type Strategy, findMonorepoRoot, findMonorepoRootSync } from "./monorepo.js";
4
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-62php2nC.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-Ba7sjsO5.js";
6
6
  export { type PackageManager, type PackageManagerResult, findLockFile, findLockFileSync, findPackageManager, findPackageManagerSync, generateMissingPackagesInstallMessage, getPackageManagerVersion, identifyInitiatingPackageManager } from "./package-manager.js";
7
7
  export { type PnpmCatalog, type PnpmCatalogs, isPackageInWorkspace, readPnpmCatalogs, readPnpmCatalogsSync, resolveCatalogReference, resolveCatalogReferences, resolveDependenciesCatalogReferences } from "./pnpm.js";
8
8
  import '@visulima/fs';
9
- import 'type-fest';
10
9
  import '@antfu/install-pkg';
11
- import '@inquirer/core';
12
- import '@inquirer/type';
13
10
  import 'normalize-package-data';
11
+ import "./packem_shared/json-value.d-AIF0oxA6.js";
package/dist/index.js CHANGED
@@ -1 +1 @@
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
+ import{default as o}from"./packem_shared/PackageNotFoundError-PwPSQ1F3.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};
package/dist/lockfile.js CHANGED
@@ -1 +1 @@
1
- import{createRequire as E}from"node:module";import{findUp as N,findUpSync as U}from"@visulima/fs";import{L as q}from"./packem_shared/lockfile-candidates-B-i5hlDs.js";let A;const C=n=>(A??=E(import.meta.url))(n),g=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,_=n=>{if(typeof g<"u"&&g.versions&&g.versions.node){const[e,t]=g.versions.node.split(".").map(Number);if(e>22||e===22&&t>=3||e===20&&t>=16)return g.getBuiltinModule(n)}return C(n)},{readFileSync:I}=_("node:fs"),{readFile:R}=_("node:fs/promises"),B={sha256:"sha256",sha384:"sha384",sha512:"sha512"},M=1024,T=/^[A-Z0-9+/]+={0,2}$/i,b="node_modules/",m=/^['"]/,k=/['"]$/,P=/^[a-z][a-zA-Z0-9]*:\s*$/m,z=/resolution:\s*\{[^}]*integrity:\s*([^,}\s]+)/,J=/^["']?((?:@[^/@"']+\/)?[^@"'\n]+)@[^\n]+\n((?:[\t ][^\n]*(?:\n|$))+)/gm,K=/^\s+version:?\s+"?([^"\n]+)"?/m,Z=/^\s+integrity[\s:]+"?([^"\s]+)"?/m,w=n=>{if(n.length>M)return;const e=n.indexOf("-");if(e<=0)return;const t=B[n.slice(0,e).toLowerCase()];if(!t)return;const s=n.slice(e+1);if(T.test(s))try{const r=Buffer.from(s,"base64");return r.length===0?void 0:{algorithm:t,hex:r.toString("hex")}}catch{return}},v=(n,e,t)=>{const s=`${t.name}@${t.version}`;e.has(s)||(e.add(s),n.push(t))},u=(n,e,t)=>{t&&Object.keys(t).length>0&&(n[e]={...t})},h=n=>{if(!n)return;const e={};for(const[t,s]of Object.entries(n))e[t]=[s];return Object.keys(e).length>0?e:void 0},Y=n=>{const e=[],t=new Set;let s;try{s=JSON.parse(n)}catch{return e}if(!s.packages)return e;for(const[r,o]of Object.entries(s.packages)){if(!r||!o.version)continue;const p=r.lastIndexOf(b);if(p===-1)continue;const i=r.slice(p+b.length);if(i.length===0)continue;const c=i.split("/"),a=i.startsWith("@")?2:1;if(c.length!==a||c.some(f=>f.length===0))continue;const l=o.name??i;if(l.startsWith("."))continue;const d={name:l,version:o.version};if(o.integrity){const f=w(o.integrity);f&&(d.integrity=f)}u(d,"dependencies",h(o.dependencies)),u(d,"peerDependencies",h(o.peerDependencies)),u(d,"optionalDependencies",h(o.optionalDependencies)),v(e,t,d)}return e},O=n=>{let e=n.trim();e.startsWith("/")&&(e=e.slice(1)),e=e.replace(m,"").replace(k,"");const t=e.indexOf("(");t>0&&(e=e.slice(0,t));const s=e.lastIndexOf("@");if(s<=0)return;const r=e.slice(0,s),o=e.slice(s+1);if(!(!r||!o||o.startsWith("link:")||o.startsWith("workspace:")||o.startsWith("file:")))return{name:r,version:o}},$=(n,e)=>{const t=new RegExp(String.raw`^${e}:\s*$`,"m").exec(n);if(!t)return;const s=t.index+t[0].length,r=P.exec(n.slice(s));return n.slice(s,r?s+r.index:n.length)},G=n=>{const e=new Map,t=$(n,"snapshots");if(!t)return e;const s=/^ {2}(['"]?[^\s:][^:\n]*?['"]?):\s*\n((?: {4}[^\n]*\n?)+)/gm;let r;for(;(r=s.exec(t)??void 0)!==void 0;){const o=O(r[1]);if(!o)continue;const p=`${o.name}@${o.version}`,i=r[2],c=e.get(p)??{};for(const a of["dependencies","peerDependencies","optionalDependencies"]){const l=y(i,a);if(!l)continue;const d=c[a]??{};for(const[f,F]of Object.entries(l)){const x=d[f]??[];for(const j of F)x.includes(j)||x.push(j);d[f]=x}c[a]=d}e.set(p,c)}return e},H=n=>{const e=[],t=new Set,s=$(n,"packages");if(!s)return e;const r=G(n),o=/^ {2}(['"]?[^\s:][^:\n]*?['"]?):\s*\n((?: {4}[^\n]*\n?)+)/gm;let p;for(;(p=o.exec(s)??void 0)!==void 0;){const i=O(p[1]);if(!i)continue;const c=p[2],a=z.exec(c),l={name:i.name,version:i.version};if(a?.[1]){const f=w(a[1]);f&&(l.integrity=f)}const d=r.get(`${i.name}@${i.version}`);u(l,"dependencies",d?.dependencies??y(c,"dependencies")),u(l,"peerDependencies",d?.peerDependencies??y(c,"peerDependencies")),u(l,"optionalDependencies",d?.optionalDependencies??y(c,"optionalDependencies")),v(e,t,l)}return e},y=(n,e)=>{const t=new RegExp(String.raw`^ {4}${e}:\s*\n((?: {6,}[^\n]*\n?)+)`,"m").exec(n);if(!t?.[1])return;const s={},r=/^ {6}([^\s:]+):\s*([^\n]+)/gm;let o;for(;(o=r.exec(t[1])??void 0)!==void 0;){const p=o[1].replace(m,"").replace(k,"");let i=o[2].trim();i=i.replace(m,"").replace(k,"");const c=i.indexOf("(");if(c>0&&(i=i.slice(0,c).trim()),!p||!i)continue;const a=s[p]??[];a.includes(i)||a.push(i),s[p]=a}return Object.keys(s).length>0?s:void 0},Q=n=>{const e=[],t=new Set,s=J;s.lastIndex=0;let r;for(;(r=s.exec(n)??void 0)!==void 0;){const o=r[1].replace(m,"").replace(k,"");if(!o)continue;const p=r[2],i=K.exec(p);if(!i?.[1])continue;const c={name:o,version:i[1].trim()},a=Z.exec(p);if(a?.[1]){const l=w(a[1]);l&&(c.integrity=l)}u(c,"dependencies",D(p,"dependencies")),u(c,"peerDependencies",D(p,"peerDependencies")),u(c,"optionalDependencies",D(p,"optionalDependencies")),v(e,t,c)}return e},D=(n,e)=>{const t=new RegExp(String.raw`^ {2}${e}:\s*\n((?: {4,}[^\n]*\n?)+)`,"m").exec(n);if(!t?.[1])return;const s={},r=/^ {4}(['"]?[^\s:'"]+['"]?)\s*(?::\s*)?['"]([^'"\n]+)['"]/gm;let o;for(;(o=r.exec(t[1])??void 0)!==void 0;){const p=o[1].replace(m,"").replace(k,""),i=o[2];if(p&&i){const c=s[p]??[];c.includes(i)||c.push(i),s[p]=c}}return Object.keys(s).length>0?s:void 0},V=/,(?=\s*[}\]])/g,X=n=>{const e=[],t=new Set;let s;try{s=JSON.parse(n.replaceAll(V,""))}catch{return e}if(!s.packages)return e;for(const r of Object.values(s.packages)){const o=r[0];if(typeof o!="string")continue;const p=o.indexOf("@",1);if(p<=0)continue;const i=o.slice(0,p),c=o.slice(p+1);if(!i||!c||c.startsWith("workspace:")||c.startsWith("link:")||c.startsWith("file:"))continue;const a={name:i,version:c},l=r[3];if(typeof l=="string"&&l.length>0){const f=w(l);f&&(a.integrity=f)}const d=r[2];if(d&&typeof d=="object"&&!Array.isArray(d)){const f=d;u(a,"dependencies",h(f.dependencies)),u(a,"peerDependencies",h(f.peerDependencies)),u(a,"optionalDependencies",h(f.optionalDependencies))}v(e,t,a)}return e},S=n=>{if(n.endsWith("pnpm-lock.yaml"))return"pnpm";if(n.endsWith("package-lock.json")||n.endsWith("npm-shrinkwrap.json"))return"npm";if(n.endsWith("yarn.lock"))return"yarn";if(n.endsWith("bun.lockb")||n.endsWith("bun.lock"))return"bun"},W=(n,e)=>{switch(e){case"bun":return X(n);case"npm":return Y(n);case"pnpm":return H(n);case"yarn":return Q(n);default:return[]}},L=[...q],se=async n=>{const e=await N(L,{type:"file",...n&&{cwd:n}});if(!e)throw new Error("Could not find a supported lock file (pnpm-lock.yaml, package-lock.json, npm-shrinkwrap.json, yarn.lock, bun.lock)");const t=S(e);if(!t)throw new Error(`Unsupported lock file: ${e}`);const s=await R(e,"utf8");return{entries:W(s,t),path:e,type:t}},oe=n=>{const e=U(L,{type:"file",...n&&{cwd:n}});if(!e)throw new Error("Could not find a supported lock file (pnpm-lock.yaml, package-lock.json, npm-shrinkwrap.json, yarn.lock, bun.lock)");const t=S(e);if(!t)throw new Error(`Unsupported lock file: ${e}`);return{entries:W(I(e,"utf8"),t),path:e,type:t}};export{w as decodeSriIntegrity,X as parseBunLockFile,se as parseLockFile,W as parseLockFileContent,oe as parseLockFileSync,Y as parseNpmLockFile,H as parsePnpmLockFile,Q as parseYarnLockFile};
1
+ import{createRequire as N}from"node:module";import{findUp as F,findUpSync as W}from"@visulima/fs";import{L as P}from"./packem_shared/lockfile-candidates-B-i5hlDs.js";let A;const M=n=>(A??=N(import.meta.url))(n),h=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,b=n=>{if(typeof h<"u"&&h.versions&&h.versions.node){const[e,t]=h.versions.node.split(".").map(Number);if(e>22||e===22&&t>=3||e===20&&t>=16)return h.getBuiltinModule(n)}return M(n)},{readFileSync:T}=b("node:fs"),{readFile:$}=b("node:fs/promises"),C={sha256:"sha256",sha384:"sha384",sha512:"sha512"},U=1024,Y=/^[A-Z0-9+/]+={0,2}$/i,D="node_modules/",m=/^['"]/,y=/['"]$/,B=/^[a-z][a-zA-Z0-9]*:\s*$/m,G=/resolution:\s*\{[^}]*integrity:\s*([^,}\s]+)/,K=/^["']?((?:@[^/@"']+\/)?[^@"'\n]+)@[^\n]+\n((?:[\t ][^\n]*(?:\n|$))+)/gm,q=/^\s+version:?\s+"?([^"\n]+)"?/m,V=/^\s+integrity[\s:]+"?([^"\s]+)"?/m,v=n=>{if(n.length>U)return;const e=n.indexOf("-");if(e<=0)return;const t=C[n.slice(0,e).toLowerCase()];if(!t)return;const s=n.slice(e+1);if(Y.test(s))try{const o=Buffer.from(s,"base64");return o.length===0?void 0:{algorithm:t,hex:o.toString("hex")}}catch{return}},x=(n,e,t)=>{const s=`${t.name}@${t.version}`;e.has(s)||(e.add(s),n.push(t))},u=(n,e,t)=>{t&&Object.keys(t).length>0&&(n[e]={...t})},g=n=>{if(!n)return;const e={};for(const[t,s]of Object.entries(n))e[t]=[s];return Object.keys(e).length>0?e:void 0},X=n=>{const e=[],t=new Set;let s;try{s=JSON.parse(n)}catch{return e}if(!s.packages)return e;for(const[o,c]of Object.entries(s.packages)){if(!o||!c.version)continue;const r=o.lastIndexOf(D);if(r===-1)continue;const a=o.slice(r+D.length);if(a.length===0)continue;const i=a.split("/"),p=a.startsWith("@")?2:1;if(i.length!==p||i.some(f=>f.length===0))continue;const l=c.name??a;if(l.startsWith("."))continue;const d={name:l,version:c.version};if(c.integrity){const f=v(c.integrity);f&&(d.integrity=f)}u(d,"dependencies",g(c.dependencies)),u(d,"peerDependencies",g(c.peerDependencies)),u(d,"optionalDependencies",g(c.optionalDependencies)),x(e,t,d)}return e},I=n=>{let e=n.trim();e.startsWith("/")&&(e=e.slice(1)),e=e.replace(m,"").replace(y,"");const t=e.indexOf("(");t>0&&(e=e.slice(0,t));const s=e.lastIndexOf("@");if(s<=0)return;const o=e.slice(0,s),c=e.slice(s+1);if(!(!o||!c||c.startsWith("link:")||c.startsWith("workspace:")||c.startsWith("file:")))return{name:o,version:c}},O=(n,e)=>{const s=new RegExp(String.raw`^${e}:\s*$`,"m").exec(n);if(!s)return;const o=s.index+s[0].length,c=B.exec(n.slice(o));return n.slice(o,c?o+c.index:n.length)},H=n=>{const e=new Map,t=O(n,"snapshots");if(!t)return e;const s=/^ {2}(['"]?[^\s:][^:\n]*?['"]?):\s*\n((?: {4}[^\n]*\n?)+)/gm;let o;for(;(o=s.exec(t)??void 0)!==void 0;){const c=I(o[1]);if(!c)continue;const r=`${c.name}@${c.version}`,a=o[2],i=e.get(r)??{};for(const p of["dependencies","peerDependencies","optionalDependencies"]){const l=k(a,p);if(!l)continue;const d=i[p]??{};for(const[f,L]of Object.entries(l)){const E=d[f]??[];for(const w of L)E.includes(w)||E.push(w);d[f]=E}i[p]=d}e.set(r,i)}return e},z=n=>{const e=[],t=new Set,s=O(n,"packages");if(!s)return e;const o=H(n),c=/^ {2}(['"]?[^\s:][^:\n]*?['"]?):\s*\n((?: {4}[^\n]*\n?)+)/gm;let r;for(;(r=c.exec(s)??void 0)!==void 0;){const a=I(r[1]);if(!a)continue;const i=r[2],p=G.exec(i),l={name:a.name,version:a.version};if(p?.[1]){const f=v(p[1]);f&&(l.integrity=f)}const d=o.get(`${a.name}@${a.version}`);u(l,"dependencies",d?.dependencies??k(i,"dependencies")),u(l,"peerDependencies",d?.peerDependencies??k(i,"peerDependencies")),u(l,"optionalDependencies",d?.optionalDependencies??k(i,"optionalDependencies")),x(e,t,l)}return e},k=(n,e)=>{const s=new RegExp(String.raw`^ {4}${e}:\s*\n((?: {6,}[^\n]*\n?)+)`,"m").exec(n);if(!s?.[1])return;const o={},c=/^ {6}([^\s:]+):\s*([^\n]+)/gm;let r;for(;(r=c.exec(s[1])??void 0)!==void 0;){const a=r[1].replace(m,"").replace(y,"");let i=r[2].trim();i=i.replace(m,"").replace(y,"");const p=i.indexOf("(");if(p>0&&(i=i.slice(0,p).trim()),!a||!i)continue;const l=o[a]??[];l.includes(i)||l.push(i),o[a]=l}return Object.keys(o).length>0?o:void 0},J=n=>{const e=[],t=new Set,s=K;s.lastIndex=0;let o;for(;(o=s.exec(n)??void 0)!==void 0;){const c=o[1].replace(m,"").replace(y,"");if(!c)continue;const r=o[2],a=q.exec(r);if(!a?.[1])continue;const i={name:c,version:a[1].trim()},p=V.exec(r);if(p?.[1]){const l=v(p[1]);l&&(i.integrity=l)}u(i,"dependencies",_(r,"dependencies")),u(i,"peerDependencies",_(r,"peerDependencies")),u(i,"optionalDependencies",_(r,"optionalDependencies")),x(e,t,i)}return e},_=(n,e)=>{const s=new RegExp(String.raw`^ {2}${e}:\s*\n((?: {4,}[^\n]*\n?)+)`,"m").exec(n);if(!s?.[1])return;const o={},c=/^ {4}(['"]?[^\s:'"]+['"]?)\s*(?::\s*)?['"]([^'"\n]+)['"]/gm;let r;for(;(r=c.exec(s[1])??void 0)!==void 0;){const a=r[1].replace(m,"").replace(y,""),i=r[2];if(a&&i){const p=o[a]??[];p.includes(i)||p.push(i),o[a]=p}}return Object.keys(o).length>0?o:void 0},Q=/,(?=\s*[}\]])/g,Z=n=>{const e=[],t=new Set;let s;try{s=JSON.parse(n.replaceAll(Q,""))}catch{return e}if(!s.packages)return e;for(const o of Object.values(s.packages)){const c=o[0];if(typeof c!="string")continue;const r=c.indexOf("@",1);if(r<=0)continue;const a=c.slice(0,r),i=c.slice(r+1);if(!a||!i||i.startsWith("workspace:")||i.startsWith("link:")||i.startsWith("file:"))continue;const p={name:a,version:i},l=o[3];if(typeof l=="string"&&l.length>0){const f=v(l);f&&(p.integrity=f)}const d=o[2];if(d&&typeof d=="object"&&!Array.isArray(d)){const f=d;u(p,"dependencies",g(f.dependencies)),u(p,"peerDependencies",g(f.peerDependencies)),u(p,"optionalDependencies",g(f.optionalDependencies))}x(e,t,p)}return e},R=n=>{if(n.endsWith("pnpm-lock.yaml"))return"pnpm";if(n.endsWith("package-lock.json")||n.endsWith("npm-shrinkwrap.json"))return"npm";if(n.endsWith("yarn.lock"))return"yarn";if(n.endsWith("bun.lockb")||n.endsWith("bun.lock"))return"bun"},S=(n,e)=>{switch(e){case"bun":return Z(n);case"npm":return X(n);case"pnpm":return z(n);case"yarn":return J(n);default:return[]}},j=[...P],se=async n=>{const e=await F(j,{type:"file",...n&&{cwd:n}});if(!e)throw new Error("Could not find a supported lock file (pnpm-lock.yaml, package-lock.json, npm-shrinkwrap.json, yarn.lock, bun.lock)");const t=R(e);if(!t)throw new Error(`Unsupported lock file: ${e}`);const s=await $(e,"utf8");return{entries:S(s,t),path:e,type:t}},oe=n=>{const e=W(j,{type:"file",...n&&{cwd:n}});if(!e)throw new Error("Could not find a supported lock file (pnpm-lock.yaml, package-lock.json, npm-shrinkwrap.json, yarn.lock, bun.lock)");const t=R(e);if(!t)throw new Error(`Unsupported lock file: ${e}`);return{entries:S(T(e,"utf8"),t),path:e,type:t}};export{v as decodeSriIntegrity,Z as parseBunLockFile,se as parseLockFile,S as parseLockFileContent,oe as parseLockFileSync,X as parseNpmLockFile,z as parsePnpmLockFile,J as parseYarnLockFile};
package/dist/monorepo.js CHANGED
@@ -1 +1 @@
1
- import{createRequire as l}from"node:module";import{findUp as j,readJson as b,findUpSync as w,readJsonSync as k}from"@visulima/fs";import{NotFoundError as u}from"@visulima/fs/error";import{parseJson as _}from"@visulima/fs/utils";import{dirname as d,join as a}from"@visulima/path";import{findPackageManager as M,findPackageManagerSync as S}from"./package-manager.js";let m;const g=t=>(m??=l(import.meta.url))(t),c=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,h=t=>{if(typeof c<"u"&&c.versions&&c.versions.node){const[o,e]=c.versions.node.split(".").map(Number);if(o>22||o===22&&e>=3||o===20&&e>=16)return c.getBuiltinModule(t)}return g(t)},{existsSync:i,readFileSync:f}=h("node:fs"),y=t=>{let o;try{o=_(t)}catch{return!1}if(!o||typeof o!="object"||Array.isArray(o))return!1;const{workspaces:e}=o;return typeof e=="object"&&e!==null},E=async t=>{const o=await j(["lerna.json","turbo.json"],{type:"file",...t&&{cwd:t}});if(o?.endsWith("lerna.json")){const r=await b(o);if(r&&typeof r=="object"&&!Array.isArray(r)){const n=r;if(n.useWorkspaces||n.packages)return{path:d(o),strategy:"lerna"}}}const e=o?.endsWith("turbo.json");try{const{packageManager:r,path:n}=await M(t);if(["npm","yarn"].includes(r)){const s=a(n,"package.json");if(i(s)){const p=f(a(n,"package.json"),"utf8");if(y(p))return{path:n,strategy:e?"turbo":r}}}else if(r==="pnpm"){const s=a(n,"pnpm-workspace.yaml");if(i(s))return{path:n,strategy:e?"turbo":"pnpm"}}}catch(r){if(!(r instanceof u))throw r}throw new Error(`No monorepo root could be found upwards from the directory ${String(t??process.cwd())} using lerna, yarn, pnpm, or npm as indicators.`)},J=t=>{const o=w(["lerna.json","turbo.json"],{type:"file",...t&&{cwd:t}});if(o?.endsWith("lerna.json")){const r=k(o);if(r&&typeof r=="object"&&!Array.isArray(r)){const n=r;if(n.useWorkspaces||n.packages)return{path:d(o),strategy:"lerna"}}}const e=o?.endsWith("turbo.json");try{const{packageManager:r,path:n}=S(t);if(["npm","yarn"].includes(r)){const s=a(n,"package.json");if(i(s)){const p=f(a(n,"package.json"),"utf8");if(y(p))return{path:n,strategy:e?"turbo":r}}}else if(r==="pnpm"){const s=a(n,"pnpm-workspace.yaml");if(i(s))return{path:n,strategy:e?"turbo":"pnpm"}}}catch(r){if(!(r instanceof u))throw r}throw new Error(`No monorepo root could be found upwards from the directory ${String(t??process.cwd())} using lerna, yarn, pnpm, or npm as indicators.`)};export{E as findMonorepoRoot,J as findMonorepoRootSync};
1
+ import{createRequire as m}from"node:module";import{findUp as k,readJson as j,findUpSync as b,readJsonSync as _}from"@visulima/fs";import{NotFoundError as u}from"@visulima/fs/error";import{parseJson as w}from"@visulima/fs/utils";import{dirname as l,join as a}from"@visulima/path";import{findPackageManager as F,findPackageManagerSync as P}from"./package-manager.js";let d;const g=n=>(d??=m(import.meta.url))(n),i=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,h=n=>{if(typeof i<"u"&&i.versions&&i.versions.node){const[e,t]=i.versions.node.split(".").map(Number);if(e>22||e===22&&t>=3||e===20&&t>=16)return i.getBuiltinModule(n)}return g(n)},{existsSync:c,readFileSync:f}=h("node:fs"),y=n=>{let e;try{e=w(n)}catch{return!1}if(!e||typeof e!="object"||Array.isArray(e))return!1;const{workspaces:t}=e;return typeof t=="object"&&t!==null},T=async n=>{const e=await k(["lerna.json","turbo.json"],{type:"file",...n&&{cwd:n}});if(e?.endsWith("lerna.json")){const r=await j(e);if(r&&typeof r=="object"&&!Array.isArray(r)){const o=r;if(o.useWorkspaces||o.packages)return{path:l(e),strategy:"lerna"}}}const t=e?.endsWith("turbo.json");try{const{packageManager:r,path:o}=await F(n);if(["npm","yarn"].includes(r)){const s=a(o,"package.json");if(c(s)){const p=f(a(o,"package.json"),"utf8");if(y(p))return{path:o,strategy:t?"turbo":r}}}else if(r==="pnpm"){const s=a(o,"pnpm-workspace.yaml");if(c(s))return{path:o,strategy:t?"turbo":"pnpm"}}}catch(r){if(!(r instanceof u))throw r}throw new Error(`No monorepo root could be found upwards from the directory ${String(n??process.cwd())} using lerna, yarn, pnpm, or npm as indicators.`)},q=n=>{const e=b(["lerna.json","turbo.json"],{type:"file",...n&&{cwd:n}});if(e?.endsWith("lerna.json")){const r=_(e);if(r&&typeof r=="object"&&!Array.isArray(r)){const o=r;if(o.useWorkspaces||o.packages)return{path:l(e),strategy:"lerna"}}}const t=e?.endsWith("turbo.json");try{const{packageManager:r,path:o}=P(n);if(["npm","yarn"].includes(r)){const s=a(o,"package.json");if(c(s)){const p=f(a(o,"package.json"),"utf8");if(y(p))return{path:o,strategy:t?"turbo":r}}}else if(r==="pnpm"){const s=a(o,"pnpm-workspace.yaml");if(c(s))return{path:o,strategy:t?"turbo":"pnpm"}}}catch(r){if(!(r instanceof u))throw r}throw new Error(`No monorepo root could be found upwards from the directory ${String(n??process.cwd())} using lerna, yarn, pnpm, or npm as indicators.`)};export{T as findMonorepoRoot,q as findMonorepoRootSync};
@@ -1,7 +1,5 @@
1
1
  import '@visulima/fs';
2
- import 'type-fest';
3
- export { F as FindPackageJsonCache, a as NormalizedReadResult, 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-62php2nC.js";
2
+ export { F as FindPackageJsonCache, a as NormalizedReadResult, 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-Ba7sjsO5.js";
3
+ import "./packem_shared/json-value.d-AIF0oxA6.js";
4
4
  import '@antfu/install-pkg';
5
- import '@inquirer/core';
6
- import '@inquirer/type';
7
5
  import 'normalize-package-data';
@@ -1,4 +1,4 @@
1
- import{createRequire as B}from"node:module";import{installPackage as M}from"@antfu/install-pkg";import{findUp as Y,findUpSync as G,writeJson as X,writeJsonSync as z,readJson as U,readJsonSync as V,readFile as L,readFileSync as H}from"@visulima/fs";import{NotFoundError as v}from"@visulima/fs/error";import{toPath as j,parseJson as x}from"@visulima/fs/utils";import{readYaml as K,readYamlSync as Q}from"@visulima/fs/yaml";import{join as P}from"@visulima/path";import _ from"json5";import Z from"normalize-package-data";import{readPnpmCatalogs as S,resolveCatalogReferences as y,readPnpmCatalogsSync as N}from"./pnpm.js";let R;const q=r=>(R??=B(import.meta.url))(r),h=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,k=r=>{if(typeof h<"u"&&h.versions&&h.versions.node){const[e,o]=h.versions.node.split(".").map(Number);if(e>22||e===22&&o>=3||e===20&&o>=16)return h.getBuiltinModule(r)}return q(r)},{existsSync:E}=k("node:fs"),{createInterface:ee}=k("node:readline"),{styleText:l}=k("node:util"),b=r=>{const e=typeof r;return r!==null&&(e==="object"||e==="function")},I=new Set(["__proto__","prototype","constructor"]),J=1e6,re=r=>r>="0"&&r<="9";function T(r){if(r==="0")return!0;if(/^[1-9]\d*$/.test(r)){const e=Number.parseInt(r,10);return e<=Number.MAX_SAFE_INTEGER&&e<=J}return!1}function $(r,e){return I.has(r)?!1:(r&&T(r)?e.push(Number.parseInt(r,10)):e.push(r),!0)}function te(r){if(typeof r!="string")throw new TypeError(`Expected a string, got ${typeof r}`);const e=[];let o="",t="start",n=!1,s=0;for(const a of r){if(s++,n){o+=a,n=!1;continue}if(a==="\\"){if(t==="index")throw new Error(`Invalid character '${a}' in an index at position ${s}`);if(t==="indexEnd")throw new Error(`Invalid character '${a}' after an index at position ${s}`);n=!0,t=t==="start"?"property":t;continue}switch(a){case".":{if(t==="index")throw new Error(`Invalid character '${a}' in an index at position ${s}`);if(t==="indexEnd"){t="property";break}if(!$(o,e))return[];o="",t="property";break}case"[":{if(t==="index")throw new Error(`Invalid character '${a}' in an index at position ${s}`);if(t==="indexEnd"){t="index";break}if(t==="property"||t==="start"){if((o||t==="property")&&!$(o,e))return[];o=""}t="index";break}case"]":{if(t==="index"){if(o==="")o=(e.pop()||"")+"[]",t="property";else{const i=Number.parseInt(o,10);!Number.isNaN(i)&&Number.isFinite(i)&&i>=0&&i<=Number.MAX_SAFE_INTEGER&&i<=J&&o===String(i)?e.push(i):e.push(o),o="",t="indexEnd"}break}if(t==="indexEnd")throw new Error(`Invalid character '${a}' after an index at position ${s}`);o+=a;break}default:{if(t==="index"&&!re(a))throw new Error(`Invalid character '${a}' in an index at position ${s}`);if(t==="indexEnd")throw new Error(`Invalid character '${a}' after an index at position ${s}`);t==="start"&&(t="property"),o+=a}}}switch(n&&(o+="\\"),t){case"property":{if(!$(o,e))return[];break}case"index":throw new Error("Index was not closed");case"start":{e.push("");break}}return e}function C(r){if(typeof r=="string")return te(r);if(Array.isArray(r)){const e=[];for(const[o,t]of r.entries()){if(typeof t!="string"&&typeof t!="number")throw new TypeError(`Expected a string or number for path segment at index ${o}, got ${typeof t}`);if(typeof t=="number"&&!Number.isFinite(t))throw new TypeError(`Path segment at index ${o} must be a finite number, got ${t}`);if(I.has(t))return[];typeof t=="string"&&T(t)?e.push(Number.parseInt(t,10)):e.push(t)}return e}return[]}function p(r,e,o){if(!b(r)||typeof e!="string"&&!Array.isArray(e))return o===void 0?r:o;const t=C(e);if(t.length===0)return o;for(let n=0;n<t.length;n++){const s=t[n];if(r=r[s],r==null){if(n!==t.length-1)return o;break}}return r===void 0?o:r}function oe(r,e){if(!b(r)||typeof e!="string"&&!Array.isArray(e))return!1;const o=C(e);if(o.length===0)return!1;for(const t of o){if(!b(r)||!(t in r))return!1;r=r[t]}return!0}const ne=async r=>{const{default:e=!1,message:o,transformer:t}=r,n=a=>{const i=l(["cyan","bold"],"?"),c=l(["bold"],a),f=e?`${l(["greenBright"],"Y")}${l(["gray"],"/n")}`:`y/${l(["yellowBright"],"N")}`;return`${i} ${c} ${l(["gray"],`(${f})`)}`},s=a=>t?t(a):a?l(["greenBright"],"Yes"):l(["yellowBright"],"No");return new Promise(a=>{const i=ee({input:process.stdin,output:process.stdout}),c=n(o);i.question(c,f=>{i.close();const g=f.trim().toLowerCase();if(g===""){a(e);return}if(g==="y"||g==="yes"){console.log(`${l(["greenBright"],"✓")} ${s(!0)}`),a(!0);return}if(g==="n"||g==="no"){console.log(`${l(["yellowBright"],"✗")} ${s(!1)}`),a(!1);return}console.log(`${l(["gray"],"→")} ${s(e)}`),a(e)}),i.on("SIGINT",()=>{i.close(),console.log(`
2
- ${l(["gray"],"→")} ${s(!1)}`),a(!1)})})},se=typeof process.stdout<"u"&&!process.versions.deno&&!globalThis.window,A=/, ([^,]*)$/,u=new Map,m=new Map,d=(r,e={})=>{const o=e.strict&&e.ignoreWarnings?e.ignoreWarnings.map(String).toSorted((t,n)=>t.localeCompare(n)).join(","):"";return`${r}|s${String(e.strict?1:0)}|c${String(e.resolveCatalogs?1:0)}|j${String(e.json5===!1?0:1)}|y${String(e.yaml===!1?0:1)}|w${o}`},W=r=>r.trimStart().startsWith("{"),D=r=>{const e=`${r}|`;for(const o of[m,u])for(const t of o.keys())t.startsWith(e)&&o.delete(t)};class ae extends Error{constructor(e){super(`The following warnings were encountered while normalizing package data:
1
+ import{createRequire as M}from"node:module";import{installPackage as q}from"@antfu/install-pkg";import{findUp as z,findUpSync as K,writeJson as V,writeJsonSync as X,readJson as G,readJsonSync as U,readFile as F,readFileSync as L}from"@visulima/fs";import{NotFoundError as P}from"@visulima/fs/error";import{toPath as x,parseJson as k}from"@visulima/fs/utils";import{readYaml as H,readYamlSync as Q}from"@visulima/fs/yaml";import{join as j}from"@visulima/path";import v from"json5";import Z from"normalize-package-data";import{readPnpmCatalogs as N,resolveCatalogReferences as p,readPnpmCatalogsSync as _}from"./pnpm.js";let B;const Y=r=>(B??=M(import.meta.url))(r),y=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,E=r=>{if(typeof y<"u"&&y.versions&&y.versions.node){const[e,t]=y.versions.node.split(".").map(Number);if(e>22||e===22&&t>=3||e===20&&t>=16)return y.getBuiltinModule(r)}return Y(r)},{existsSync:S}=E("node:fs"),{createInterface:ee}=E("node:readline"),{styleText:d}=E("node:util"),b=r=>{const e=typeof r;return r!==null&&(e==="object"||e==="function")},A=new Set(["__proto__","prototype","constructor"]),C=1e6,re=r=>r>="0"&&r<="9";function D(r){if(r==="0")return!0;if(/^[1-9]\d*$/.test(r)){const e=Number.parseInt(r,10);return e<=Number.MAX_SAFE_INTEGER&&e<=C}return!1}function $(r,e){return A.has(r)?!1:(r&&D(r)?e.push(Number.parseInt(r,10)):e.push(r),!0)}function ne(r){if(typeof r!="string")throw new TypeError(`Expected a string, got ${typeof r}`);const e=[];let t="",n="start",s=!1,o=0;for(const a of r){if(o++,s){t+=a,s=!1;continue}if(a==="\\"){if(n==="index")throw new Error(`Invalid character '${a}' in an index at position ${o}`);if(n==="indexEnd")throw new Error(`Invalid character '${a}' after an index at position ${o}`);s=!0,n=n==="start"?"property":n;continue}switch(a){case".":{if(n==="index")throw new Error(`Invalid character '${a}' in an index at position ${o}`);if(n==="indexEnd"){n="property";break}if(!$(t,e))return[];t="",n="property";break}case"[":{if(n==="index")throw new Error(`Invalid character '${a}' in an index at position ${o}`);if(n==="indexEnd"){n="index";break}if(n==="property"||n==="start"){if((t||n==="property")&&!$(t,e))return[];t=""}n="index";break}case"]":{if(n==="index"){if(t==="")t=(e.pop()||"")+"[]",n="property";else{const i=Number.parseInt(t,10);!Number.isNaN(i)&&Number.isFinite(i)&&i>=0&&i<=Number.MAX_SAFE_INTEGER&&i<=C&&t===String(i)?e.push(i):e.push(t),t="",n="indexEnd"}break}if(n==="indexEnd")throw new Error(`Invalid character '${a}' after an index at position ${o}`);t+=a;break}default:{if(n==="index"&&!re(a))throw new Error(`Invalid character '${a}' in an index at position ${o}`);if(n==="indexEnd")throw new Error(`Invalid character '${a}' after an index at position ${o}`);n==="start"&&(n="property"),t+=a}}}switch(s&&(t+="\\"),n){case"property":{if(!$(t,e))return[];break}case"index":throw new Error("Index was not closed");case"start":{e.push("");break}}return e}function I(r){if(typeof r=="string")return ne(r);if(Array.isArray(r)){const e=[];for(const[t,n]of r.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(A.has(n))return[];typeof n=="string"&&D(n)?e.push(Number.parseInt(n,10)):e.push(n)}return e}return[]}function u(r,e,t){if(!b(r)||typeof e!="string"&&!Array.isArray(e))return t===void 0?r:t;const n=I(e);if(n.length===0)return t;for(let s=0;s<n.length;s++){const o=n[s];if(r=r[o],r==null){if(s!==n.length-1)return t;break}}return r===void 0?t:r}function te(r,e){if(!b(r)||typeof e!="string"&&!Array.isArray(e))return!1;const t=I(e);if(t.length===0)return!1;for(const n of t){if(!b(r)||!(n in r))return!1;r=r[n]}return!0}const se=async r=>{const{default:e=!1,message:t,transformer:n}=r,s=a=>{const i=d(["cyan","bold"],"?"),c=d(["bold"],a),l=e?`${d(["greenBright"],"Y")}${d(["gray"],"/n")}`:`y/${d(["yellowBright"],"N")}`;return`${i} ${c} ${d(["gray"],`(${l})`)}`},o=a=>n?n(a):a?d(["greenBright"],"Yes"):d(["yellowBright"],"No");return new Promise(a=>{const i=ee({input:process.stdin,output:process.stdout}),c=s(t);i.question(c,l=>{i.close();const f=l.trim().toLowerCase();if(f===""){a(e);return}if(f==="y"||f==="yes"){console.log(`${d(["greenBright"],"✓")} ${o(!0)}`),a(!0);return}if(f==="n"||f==="no"){console.log(`${d(["yellowBright"],"✗")} ${o(!1)}`),a(!1);return}console.log(`${d(["gray"],"→")} ${o(e)}`),a(e)}),i.on("SIGINT",()=>{i.close(),console.log(`
2
+ ${d(["gray"],"→")} ${o(!1)}`),a(!1)})})},ae=typeof process.stdout<"u"&&!process.versions.deno&&!globalThis.window,J=/, ([^,]*)$/,g=new Map,m=new Map,h=(r,e={})=>{const t=e.strict&&e.ignoreWarnings?e.ignoreWarnings.map(String).toSorted((n,s)=>n.localeCompare(s)).join(","):"";return`${r}|s${String(e.strict?1:0)}|c${String(e.resolveCatalogs?1:0)}|j${String(e.json5===!1?0:1)}|y${String(e.yaml===!1?0:1)}|w${t}`},T=r=>r.trimStart().startsWith("{"),W=r=>{const e=`${r}|`;for(const t of[m,g])for(const n of t.keys())n.startsWith(e)&&t.delete(n)};class oe extends Error{constructor(e){super(`The following warnings were encountered while normalizing package data:
3
3
  - ${e.join(`
4
- - `)}`),this.name="PackageJsonValidationError"}}const w=(r,e,o=[])=>{const t=[];if(Z(r,n=>{t.push(n)},e),e&&t.length>0){const n=t.filter(s=>!o.some(a=>a instanceof RegExp?a.test(s):a===s));if(n.length>0)throw new ae(n)}return r},ie=async r=>await K(r),ce=r=>Q(r),fe=async r=>{const e=await L(r);return _.parse(e)},le=r=>{const e=H(r);return _.parse(e)},F=async(r,e)=>e?.yaml!==!1&&(r.endsWith(".yaml")||r.endsWith(".yml"))?ie(r):e?.json5!==!1&&r.endsWith(".json5")?fe(r):U(r),O=(r,e)=>e?.yaml!==!1&&(r.endsWith(".yaml")||r.endsWith(".yml"))?ce(r):e?.json5!==!1&&r.endsWith(".json5")?le(r):V(r),ke=async(r,e={})=>{const o={type:"file"};r&&(o.cwd=r);const t=["package.json"];e.yaml!==!1&&t.push("package.yaml","package.yml"),e.json5!==!1&&t.push("package.json5");const n=await Y(t,o);if(!n)throw new v(`No such file or directory, for ${t.join(", ").replace(A," or $1")} found.`);const s=e.cache&&typeof e.cache!="boolean"?e.cache:m,a=d(n,e);if(e.cache&&s.has(a))return s.get(a);const i=await F(n,e);if(e.resolveCatalogs){const f=await S(n);f&&y(i,f)}w(i,e.strict??!1,e.ignoreWarnings);const c={packageJson:i,path:n};return e.cache&&s.set(a,c),c},je=(r,e={})=>{const o={type:"file"};r&&(o.cwd=r);const t=["package.json"];e.yaml!==!1&&t.push("package.yaml","package.yml"),e.json5!==!1&&t.push("package.json5");const n=G(t,o);if(!n)throw new v(`No such file or directory, for ${t.join(", ").replace(A," or $1")} found.`);const s=e.cache&&typeof e.cache!="boolean"?e.cache:m,a=d(n,e);if(e.cache&&s.has(a))return s.get(a);const i=O(n,e);if(e.resolveCatalogs){const f=N(n);f&&y(i,f)}w(i,e.strict??!1,e.ignoreWarnings);const c={packageJson:i,path:n};return e.cache&&s.set(a,c),c},Ee=async(r,e={})=>{const{cwd:o,...t}=e,n=j(o??process.cwd()),s=P(n,"package.json");await X(s,r,t),D(s)},ve=(r,e={})=>{const{cwd:o,...t}=e,n=j(o??process.cwd()),s=P(n,"package.json");z(s,r,t),D(s)},xe=()=>{m.clear(),u.clear()},Pe=(r,e)=>{const o=typeof r=="object"&&!Array.isArray(r);if(!o&&typeof r!="string")throw new TypeError("`packageFile` should be either an `object` or a `string`.");let t,n=!1,s;if(o)t=structuredClone(r);else if(!W(r)&&E(r)){s=r;const i=e?.cache&&typeof e.cache!="boolean"?e.cache:u,c=d(s,e);if(e?.cache&&i.has(c))return i.get(c);t=O(s,e),n=!0}else t=x(r);if(e?.resolveCatalogs)if(n){const i=N(r);i&&y(t,i)}else throw new Error("The 'resolveCatalogs' option can only be used on a file path.");w(t,e?.strict??!1,e?.ignoreWarnings);const a=t;return n&&e?.cache&&(typeof e.cache=="boolean"?u:e.cache).set(d(s,e),a),a},_e=async(r,e)=>{const o=typeof r=="object"&&!Array.isArray(r);if(!o&&typeof r!="string")throw new TypeError("`packageFile` should be either an `object` or a `string`.");let t,n=!1,s;if(o)t=structuredClone(r);else if(!W(r)&&E(r)){s=r;const i=e?.cache&&typeof e.cache!="boolean"?e.cache:u,c=d(s,e);if(e?.cache&&i.has(c))return i.get(c);t=await F(s,e),n=!0}else t=x(r);if(e?.resolveCatalogs)if(n){const i=await S(r);i&&y(t,i)}else throw new Error("The 'resolveCatalogs' option can only be used on a file path.");w(t,e?.strict??!1,e?.ignoreWarnings);const a=t;return n&&e?.cache&&(typeof e.cache=="boolean"?u:e.cache).set(d(s,e),a),a},Se=(r,e,o)=>p(r,e,o),Ne=(r,e)=>oe(r,e),Ie=(r,e,o)=>{const t=p(r,"dependencies",{}),n=p(r,"devDependencies",{}),s=p(r,"peerDependencies",{}),a={...t,...n,...o?.peerDeps===!1?{}:s};for(const i of e)if(Object.hasOwn(a,i))return!0;return!1},Je=async(r,e,o="dependencies",t={})=>{const n=p(r,"dependencies",{}),s=p(r,"devDependencies",{}),a=p(r,"peerDependencies",{}),i=[],c={deps:!0,devDeps:!0,peerDeps:!1,...t,...t.confirm?{confirm:{...t.confirm}}:{}};for(const f of e)c.deps&&Object.hasOwn(n??{},f)||c.devDeps&&Object.hasOwn(s??{},f)||c.peerDeps&&Object.hasOwn(a??{},f)||i.push(f);if(i.length!==0){if(process.env.CI||se&&!process.stdout.isTTY){const f=`Skipping package installation for [${e.join(", ")}] because the process is not interactive.`;if(t.throwOnWarn)throw new Error(f);t.logger?.warn?t.logger.warn(f):console.warn(f);return}if(typeof c.confirm?.message=="function"&&(c.confirm.message=c.confirm.message(i)),c.confirm?.message===void 0){const f=`${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:f}:c.confirm.message=f}await ne(c.confirm)&&await M(i,{...c.installPackage,cwd:c.cwd?j(c.cwd):void 0,dev:o==="devDependencies"})}};export{xe as clearPackageJsonCache,Je as ensurePackages,ke as findPackageJson,je as findPackageJsonSync,Se as getPackageJsonProperty,Ie as hasPackageJsonAnyDependency,Ne as hasPackageJsonProperty,_e as parsePackageJson,Pe as parsePackageJsonSync,Ee as writePackageJson,ve as writePackageJsonSync};
4
+ - `)}`),this.name="PackageJsonValidationError"}}const w=(r,e,t=[])=>{const n=[];if(Z(r,s=>{n.push(s)},e),e&&n.length>0){const s=n.filter(o=>!t.some(a=>a instanceof RegExp?a.test(o):a===o));if(s.length>0)throw new oe(s)}return r},ce=async r=>await H(r),ie=r=>Q(r),fe=async r=>{const e=await F(r);return v.parse(e)},le=r=>{const e=L(r);return v.parse(e)},O=async(r,e)=>e?.yaml!==!1&&(r.endsWith(".yaml")||r.endsWith(".yml"))?ce(r):e?.json5!==!1&&r.endsWith(".json5")?fe(r):G(r),R=(r,e)=>e?.yaml!==!1&&(r.endsWith(".yaml")||r.endsWith(".yml"))?ie(r):e?.json5!==!1&&r.endsWith(".json5")?le(r):U(r),Ee=async(r,e={})=>{const t={type:"file"};r&&(t.cwd=r);const n=["package.json"];e.yaml!==!1&&n.push("package.yaml","package.yml"),e.json5!==!1&&n.push("package.json5");const s=await z(n,t);if(!s)throw new P(`No such file or directory, for ${n.join(", ").replace(J," or $1")} found.`);const o=e.cache&&typeof e.cache!="boolean"?e.cache:m,a=h(s,e);if(e.cache&&o.has(a))return o.get(a);const i=await O(s,e);if(e.resolveCatalogs){const l=await N(s);l&&p(i,l)}w(i,e.strict??!1,e.ignoreWarnings);const c={packageJson:i,path:s};return e.cache&&o.set(a,c),c},xe=(r,e={})=>{const t={type:"file"};r&&(t.cwd=r);const n=["package.json"];e.yaml!==!1&&n.push("package.yaml","package.yml"),e.json5!==!1&&n.push("package.json5");const s=K(n,t);if(!s)throw new P(`No such file or directory, for ${n.join(", ").replace(J," or $1")} found.`);const o=e.cache&&typeof e.cache!="boolean"?e.cache:m,a=h(s,e);if(e.cache&&o.has(a))return o.get(a);const i=R(s,e);if(e.resolveCatalogs){const l=_(s);l&&p(i,l)}w(i,e.strict??!1,e.ignoreWarnings);const c={packageJson:i,path:s};return e.cache&&o.set(a,c),c},Se=async(r,e={})=>{const{cwd:t,...n}=e,s=x(t??process.cwd()),o=j(s,"package.json");await V(o,r,n),W(o)},Pe=(r,e={})=>{const{cwd:t,...n}=e,s=x(t??process.cwd()),o=j(s,"package.json");X(o,r,n),W(o)},ke=()=>{m.clear(),g.clear()},je=(r,e)=>{const t=typeof r=="object"&&!Array.isArray(r);if(!t&&!(typeof r=="string"))throw new TypeError("`packageFile` should be either an `object` or a `string`.");let s,o=!1,a;if(t)s=structuredClone(r);else if(!T(r)&&S(r)){a=r;const c=e?.cache&&typeof e.cache!="boolean"?e.cache:g,l=h(a,e);if(e?.cache&&c.has(l))return c.get(l);s=R(a,e),o=!0}else s=k(r);if(e?.resolveCatalogs)if(o){const c=_(r);c&&p(s,c)}else throw new Error("The 'resolveCatalogs' option can only be used on a file path.");w(s,e?.strict??!1,e?.ignoreWarnings);const i=s;return o&&e?.cache&&(typeof e.cache=="boolean"?g:e.cache).set(h(a,e),i),i},ve=async(r,e)=>{const t=typeof r=="object"&&!Array.isArray(r);if(!t&&!(typeof r=="string"))throw new TypeError("`packageFile` should be either an `object` or a `string`.");let s,o=!1,a;if(t)s=structuredClone(r);else if(!T(r)&&S(r)){a=r;const c=e?.cache&&typeof e.cache!="boolean"?e.cache:g,l=h(a,e);if(e?.cache&&c.has(l))return c.get(l);s=await O(a,e),o=!0}else s=k(r);if(e?.resolveCatalogs)if(o){const c=await N(r);c&&p(s,c)}else throw new Error("The 'resolveCatalogs' option can only be used on a file path.");w(s,e?.strict??!1,e?.ignoreWarnings);const i=s;return o&&e?.cache&&(typeof e.cache=="boolean"?g:e.cache).set(h(a,e),i),i},Ne=(r,e,t)=>u(r,e,t),_e=(r,e)=>te(r,e),Ae=(r,e,t)=>{const n=u(r,"dependencies",{}),s=u(r,"devDependencies",{}),o=u(r,"peerDependencies",{}),a={...n,...s,...t?.peerDeps===!1?{}:o};for(const i of e)if(Object.hasOwn(a,i))return!0;return!1},Ce=async(r,e,t="dependencies",n={})=>{const s=u(r,"dependencies",{}),o=u(r,"devDependencies",{}),a=u(r,"peerDependencies",{}),i=[],c={deps:!0,devDeps:!0,peerDeps:!1,...n,...n.confirm?{confirm:{...n.confirm}}:{}};for(const f of e)c.deps&&Object.hasOwn(s??{},f)||c.devDeps&&Object.hasOwn(o??{},f)||c.peerDeps&&Object.hasOwn(a??{},f)||i.push(f);if(i.length===0)return;if(process.env.CI||ae&&!process.stdout.isTTY){const f=`Skipping package installation for [${e.join(", ")}] because the process is not interactive.`;if(n.throwOnWarn)throw new Error(f);n.logger?.warn?n.logger.warn(f):console.warn(f);return}if(typeof c.confirm?.message=="function"&&(c.confirm.message=c.confirm.message(i)),c.confirm?.message===void 0){const f=`${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:f}:c.confirm.message=f}await se(c.confirm)&&await q(i,{...c.installPackage,cwd:c.cwd?x(c.cwd):void 0,dev:t==="devDependencies"})};export{ke as clearPackageJsonCache,Ce as ensurePackages,Ee as findPackageJson,xe as findPackageJsonSync,Ne as getPackageJsonProperty,Ae as hasPackageJsonAnyDependency,_e as hasPackageJsonProperty,ve as parsePackageJson,je as parsePackageJsonSync,Se as writePackageJson,Pe as writePackageJsonSync};
@@ -1,4 +1,4 @@
1
- import{createRequire as b}from"node:module";import{findUp as h,findUpSync as k}from"@visulima/fs";import{NotFoundError as f}from"@visulima/fs/error";import{parseJson as W}from"@visulima/fs/utils";import{join as p,dirname as s}from"@visulima/path";import{L as P}from"./packem_shared/lockfile-candidates-B-i5hlDs.js";let $;const E=e=>($??=b(import.meta.url))(e),o=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,m=e=>{if(typeof o<"u"&&o.versions&&o.versions.node){const[n,a]=o.versions.node.split(".").map(Number);if(n>22||n===22&&a>=3||n===20&&a>=16)return o.getBuiltinModule(e)}return E(e)},{execFileSync:S}=m("node:child_process"),{existsSync:l,readFileSync:x}=m("node:fs"),g=[...P],u=new Set(["bun","npm","pnpm","yarn"]),w=e=>{const n=W(x(e,"utf8"));return typeof n?.packageManager=="string"?n.packageManager:void 0},y=e=>{let n;if(g.forEach(r=>{!n&&l(p(e,r))&&(n=p(e,r))}),n)return n;const a=p(e,"package.json");if(l(a)&&w(a)!==void 0)return a},_=e=>{if(!e)throw new f("Could not find a package manager");if(e.endsWith("package.json")){const n=w(e);if(n){const a=["npm","yarn","pnpm","bun"].find(r=>n.startsWith(r));if(a)return{packageManager:a,path:s(e)}}}if(e.endsWith("yarn.lock"))return{packageManager:"yarn",path:s(e)};if(e.endsWith("package-lock.json")||e.endsWith("npm-shrinkwrap.json"))return{packageManager:"npm",path:s(e)};if(e.endsWith("pnpm-lock.yaml"))return{packageManager:"pnpm",path:s(e)};if(e.endsWith("bun.lock")||e.endsWith("bun.lockb"))return{packageManager:"bun",path:s(e)};throw new f("Could not find a package manager")},q=async e=>{const n=await h(g,{type:"file",...e&&{cwd:e}});if(!n)throw new Error("Could not find lock file");return n},D=e=>{const n=k(g,{type:"file",...e&&{cwd:e}});if(!n)throw new Error("Could not find lock file");return n},U=async e=>{const n=await h(y,{...e&&{cwd:e}});return _(n)},O=e=>{const n=k(y,{...e&&{cwd:e}});return _(n)},R=e=>{if(!u.has(e))throw new Error(`Unsupported package manager "${e}". Expected one of: ${[...u].join(", ")}.`);return S(e,["--version"]).toString("utf8").trim()},A=()=>{if(!process.env.npm_config_user_agent)return;const e=process.env.npm_config_user_agent.split(" ")[0],n=e.lastIndexOf("/"),a=e.slice(0,Math.max(0,n));return{name:a==="npminstall"?"cnpm":a,version:e.slice(Math.max(0,n+1))}},B=(e,n,a)=>{const r=n.length===1?"":"s",d=a.packageManagers??["npm","pnpm","yarn"];if(d.length===0)throw new Error("No package managers provided, please provide at least one package manager");if(n.length===0)throw new Error("No missing packages provided, please provide at least one missing package");let c=`
1
+ import{createRequire as E}from"node:module";import{findUp as k,findUpSync as h}from"@visulima/fs";import{NotFoundError as f}from"@visulima/fs/error";import{parseJson as N}from"@visulima/fs/utils";import{join as g,dirname as c}from"@visulima/path";import{L as W}from"./packem_shared/lockfile-candidates-B-i5hlDs.js";let b;const P=e=>(b??=E(import.meta.url))(e),o=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,u=e=>{if(typeof o<"u"&&o.versions&&o.versions.node){const[n,a]=o.versions.node.split(".").map(Number);if(n>22||n===22&&a>=3||n===20&&a>=16)return o.getBuiltinModule(e)}return P(e)},{execFileSync:S}=u("node:child_process"),{existsSync:m,readFileSync:$}=u("node:fs"),l=[...W],d=new Set(["bun","npm","pnpm","yarn"]),M=e=>{const n=N($(e,"utf8"));return typeof n?.packageManager=="string"?n.packageManager:void 0},_=e=>{let n;if(l.forEach(r=>{!n&&m(g(e,r))&&(n=g(e,r))}),n)return n;const a=g(e,"package.json");if(m(a)&&M(a)!==void 0)return a},w=e=>{if(!e)throw new f("Could not find a package manager");if(e.endsWith("package.json")){const n=M(e);if(n){const r=["npm","yarn","pnpm","bun"].find(i=>n.startsWith(i));if(r)return{packageManager:r,path:c(e)}}}if(e.endsWith("yarn.lock"))return{packageManager:"yarn",path:c(e)};if(e.endsWith("package-lock.json")||e.endsWith("npm-shrinkwrap.json"))return{packageManager:"npm",path:c(e)};if(e.endsWith("pnpm-lock.yaml"))return{packageManager:"pnpm",path:c(e)};if(e.endsWith("bun.lock")||e.endsWith("bun.lockb"))return{packageManager:"bun",path:c(e)};throw new f("Could not find a package manager")},U=async e=>{const n=await k(l,{type:"file",...e&&{cwd:e}});if(!n)throw new Error("Could not find lock file");return n},q=e=>{const n=h(l,{type:"file",...e&&{cwd:e}});if(!n)throw new Error("Could not find lock file");return n},D=async e=>{const n=await k(_,{...e&&{cwd:e}});return w(n)},O=e=>{const n=h(_,{...e&&{cwd:e}});return w(n)},R=e=>{if(!d.has(e))throw new Error(`Unsupported package manager "${e}". Expected one of: ${[...d].join(", ")}.`);return S(e,["--version"]).toString("utf8").trim()},K=()=>{if(!process.env.npm_config_user_agent)return;const e=process.env.npm_config_user_agent.split(" ")[0],n=e.lastIndexOf("/"),a=e.slice(0,Math.max(0,n));return{name:a==="npminstall"?"cnpm":a,version:e.slice(Math.max(0,n+1))}},B=(e,n,a)=>{const r=n.length===1?"":"s",i=a.packageManagers??["npm","pnpm","yarn"];if(i.length===0)throw new Error("No package managers provided, please provide at least one package manager");if(n.length===0)throw new Error("No missing packages provided, please provide at least one missing package");let p=`
2
2
  ${a.preMessage??""}
3
3
  ${e} could not find the following package${r}
4
4
 
@@ -6,8 +6,8 @@ ${e} could not find the following package${r}
6
6
  `)}
7
7
 
8
8
  To install the missing package${r}, please run the following command:
9
- `;const M=t=>t.lastIndexOf("@")>0?t:`${t}@latest`,v=d.map(t=>{const i=n.map(j=>M(j)).join(" ");switch(t){case"bun":return` bun add ${i} -D`;case"npm":return` npm install ${i} --save-dev`;case"pnpm":return` pnpm add ${i} -D`;case"yarn":return` yarn add ${i} --dev`;default:throw new Error("Unknown package manager")}});return c+=v.join(`
9
+ `;const y=t=>t.lastIndexOf("@")>0?t:`${t}@latest`,v=i.map(t=>{const s=n.map(j=>y(j)).join(" ");switch(t){case"bun":return` bun add ${s} -D`;case"npm":return` npm install ${s} --save-dev`;case"pnpm":return` pnpm add ${s} -D`;case"yarn":return` yarn add ${s} --dev`;default:throw new Error("Unknown package manager")}});return p+=v.join(`
10
10
 
11
11
  or
12
12
 
13
- `),a.postMessage&&(c+=a.postMessage),c};export{q as findLockFile,D as findLockFileSync,U as findPackageManager,O as findPackageManagerSync,B as generateMissingPackagesInstallMessage,R as getPackageManagerVersion,A as identifyInitiatingPackageManager};
13
+ `),a.postMessage&&(p+=a.postMessage),p};export{U as findLockFile,q as findLockFileSync,D as findPackageManager,O as findPackageManagerSync,B as generateMissingPackagesInstallMessage,R as getPackageManagerVersion,K as identifyInitiatingPackageManager};
package/dist/package.js CHANGED
@@ -1 +1 @@
1
- import{createRequire as d}from"node:module";import{findUp as c,findUpSync as s,readJsonSync as g}from"@visulima/fs";import{dirname as r,join as a}from"@visulima/path";import{findLockFile as m,findLockFileSync as _}from"./package-manager.js";let u;const p=e=>(u??=d(import.meta.url))(e),i=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,l=e=>{if(typeof i<"u"&&i.versions&&i.versions.node){const[t,o]=i.versions.node.split(".").map(Number);if(t>22||t===22&&o>=3||t===20&&o>=16)return i.getBuiltinModule(e)}return p(e)},{existsSync:y}=l("node:fs"),f=e=>{if(y(a(e,"package.json"))){const t=g(a(e,"package.json"));if(t.name&&t.private!==!0)return"package.json"}},R=async e=>{try{const n=await m(e);return r(n)}catch{}const t=await c(".git/config",{...e&&{cwd:e},type:"file"});if(t)return r(r(t));const o=await c(f,{...e&&{cwd:e},type:"file"});if(o)return r(o);throw new Error("Could not find root directory")},S=e=>{try{const n=_(e);return r(n)}catch{}const t=s(".git/config",{...e&&{cwd:e},type:"file"});if(t)return r(r(t));const o=s(f,{...e&&{cwd:e},type:"file"});if(o)return r(o);throw new Error("Could not find root directory")};export{R as findPackageRoot,S as findPackageRootSync};
1
+ import{createRequire as l}from"node:module";import{findUp as s,findUpSync as c,readJsonSync as y}from"@visulima/fs";import{dirname as n,join as a}from"@visulima/path";import{findLockFile as m,findLockFileSync as _}from"./package-manager.js";let p;const u=e=>(p??=l(import.meta.url))(e),r=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,g=e=>{if(typeof r<"u"&&r.versions&&r.versions.node){const[o,t]=r.versions.node.split(".").map(Number);if(o>22||o===22&&t>=3||o===20&&t>=16)return r.getBuiltinModule(e)}return u(e)},{existsSync:d}=g("node:fs"),f=e=>{if(d(a(e,"package.json"))){const o=y(a(e,"package.json"));if(o.name&&o.private!==!0)return"package.json"}},P=async e=>{try{const i=await m(e);return n(i)}catch{}const o=await s(".git/config",{...e&&{cwd:e},type:"file"});if(o)return n(n(o));const t=await s(f,{...e&&{cwd:e},type:"file"});if(t)return n(t);throw new Error("Could not find root directory")},R=e=>{try{const i=_(e);return n(i)}catch{}const o=c(".git/config",{...e&&{cwd:e},type:"file"});if(o)return n(n(o));const t=c(f,{...e&&{cwd:e},type:"file"});if(t)return n(t);throw new Error("Could not find root directory")};export{P as findPackageRoot,R as findPackageRootSync};
@@ -0,0 +1 @@
1
+ import{findPackageManagerSync as n}from"../package-manager.js";class i extends Error{constructor(r,o){if(typeof r=="string"&&(r=[r]),r.length===0){super("Package was not found.");return}if(o===void 0)try{o=n().packageManager}catch{}o??="npm",super(`Package '${r.join(" ")}' was not found. Please install it using '${o} install ${r.join(" ")}'`)}get code(){return"PACKAGE_NOT_FOUND"}set code(r){throw new Error("Cannot overwrite code PACKAGE_NOT_FOUND")}get name(){return"PackageNotFoundError"}set name(r){throw new Error("Cannot overwrite name of PackageNotFoundError")}}export{i as default};
@@ -0,0 +1,29 @@
1
+ /**
2
+ Matches a JSON object.
3
+
4
+ This type can be useful to enforce some input to be JSON-compatible or as a super-type to be extended from. Don't use this as a direct return type as the user would have to double-cast it: `jsonObject as unknown as CustomResponse`. Instead, you could extend your CustomResponse type from it to ensure your type only uses JSON-compatible types: `interface CustomResponse extends JsonObject { … }`.
5
+
6
+ @category JSON
7
+ */
8
+ type JsonObject = { [Key in string]: JsonValue; };
9
+ /**
10
+ Matches a JSON array.
11
+
12
+ @category JSON
13
+ */
14
+ type JsonArray = JsonValue[] | readonly JsonValue[];
15
+ /**
16
+ Matches any valid JSON primitive value.
17
+
18
+ @category JSON
19
+ */
20
+ type JsonPrimitive = string | number | boolean | null;
21
+ /**
22
+ Matches any valid JSON value.
23
+
24
+ @see `Jsonify` if you need to transform a type to one that is assignable to `JsonValue`.
25
+
26
+ @category JSON
27
+ */
28
+ type JsonValue = JsonPrimitive | JsonObject | JsonArray;
29
+ export { JsonObject as J, JsonValue as a };