@storm-software/pnpm-tools 0.5.5 → 0.5.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,36 @@
2
2
 
3
3
  # Changelog for Storm Ops - Pnpm Tools
4
4
 
5
+ ## [0.5.6](https://github.com/storm-software/storm-ops/releases/tag/pnpm-tools%400.5.6) (2025-09-22)
6
+
7
+ ### Bug Fixes
8
+
9
+ - **pnpm-tools:** Resolve issue with multiple applied prefixes
10
+ ([2c081b8bc](https://github.com/storm-software/storm-ops/commit/2c081b8bc))
11
+
12
+ ### Miscellaneous
13
+
14
+ - **monorepo:** Update workspace package links
15
+ ([43374a8da](https://github.com/storm-software/storm-ops/commit/43374a8da))
16
+
17
+ ### Updated Dependencies
18
+
19
+ - Updated config-tools to 1.187.8
20
+ - Updated npm-tools to 0.4.13
21
+ - Updated config to 1.133.4
22
+
23
+ ## [0.5.5](https://github.com/storm-software/storm-ops/releases/tag/pnpm-tools%400.5.5) (2025-09-22)
24
+
25
+ ### Miscellaneous
26
+
27
+ - **monorepo:** Update workspace package links
28
+ ([09ad356e8](https://github.com/storm-software/storm-ops/commit/09ad356e8))
29
+
30
+ ### Updated Dependencies
31
+
32
+ - Updated config-tools to 1.187.7
33
+ - Updated npm-tools to 0.4.12
34
+
5
35
  ## [0.5.4](https://github.com/storm-software/storm-ops/releases/tag/pnpm-tools%400.5.4) (2025-09-21)
6
36
 
7
37
  ### Miscellaneous
package/README.md CHANGED
@@ -21,7 +21,7 @@ This package is part of the <b>⚡Storm-Ops</b> monorepo. The Storm-Ops packages
21
21
 
22
22
  <h3 align="center">💻 Visit <a href="https://stormsoftware.com" target="_blank">stormsoftware.com</a> to stay up to date with this developer</h3><br />
23
23
 
24
- [![Version](https://img.shields.io/badge/version-0.5.3-1fb2a6.svg?style=for-the-badge&color=1fb2a6)](https://prettier.io/)&nbsp;[![Nx](https://img.shields.io/badge/Nx-17.0.2-lightgrey?style=for-the-badge&logo=nx&logoWidth=20&&color=1fb2a6)](http://nx.dev/)&nbsp;[![NextJs](https://img.shields.io/badge/Next.js-14.0.2-lightgrey?style=for-the-badge&logo=nextdotjs&logoWidth=20&color=1fb2a6)](https://nextjs.org/)&nbsp;[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg?style=for-the-badge&logo=commitlint&color=1fb2a6)](http://commitizen.github.io/cz-cli/)&nbsp;![Semantic-Release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=for-the-badge&color=1fb2a6)&nbsp;[![documented with Fumadocs](https://img.shields.io/badge/documented_with-fumadocs-success.svg?style=for-the-badge&logo=readthedocs&color=1fb2a6)](https://fumadocs.vercel.app/)&nbsp;![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/storm-software/storm-ops/cr.yml?style=for-the-badge&logo=github-actions&color=1fb2a6)
24
+ [![Version](https://img.shields.io/badge/version-0.5.5-1fb2a6.svg?style=for-the-badge&color=1fb2a6)](https://prettier.io/)&nbsp;[![Nx](https://img.shields.io/badge/Nx-17.0.2-lightgrey?style=for-the-badge&logo=nx&logoWidth=20&&color=1fb2a6)](http://nx.dev/)&nbsp;[![NextJs](https://img.shields.io/badge/Next.js-14.0.2-lightgrey?style=for-the-badge&logo=nextdotjs&logoWidth=20&color=1fb2a6)](https://nextjs.org/)&nbsp;[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg?style=for-the-badge&logo=commitlint&color=1fb2a6)](http://commitizen.github.io/cz-cli/)&nbsp;![Semantic-Release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=for-the-badge&color=1fb2a6)&nbsp;[![documented with Fumadocs](https://img.shields.io/badge/documented_with-fumadocs-success.svg?style=for-the-badge&logo=readthedocs&color=1fb2a6)](https://fumadocs.vercel.app/)&nbsp;![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/storm-software/storm-ops/cr.yml?style=for-the-badge&logo=github-actions&color=1fb2a6)
25
25
 
26
26
  <!-- prettier-ignore-start -->
27
27
  <!-- markdownlint-disable -->
package/bin/pnpm.cjs CHANGED
@@ -96,33 +96,19 @@ async function setCatalog(catalog, workspaceRoot = (0, import_find_workspace_roo
96
96
  );
97
97
  await writePnpmWorkspaceFile(pnpmWorkspaceFile, workspaceRoot);
98
98
  }
99
- async function upgradeCatalogPackage(packageName, options = {}) {
99
+ async function upgradeCatalog(catalog, packageName, options = {}) {
100
100
  const {
101
101
  tag = import_constants.DEFAULT_NPM_TAG,
102
102
  prefix = "^",
103
- throwIfMissingInCatalog = false,
104
103
  workspaceRoot = (0, import_find_workspace_root2.findWorkspaceRoot)()
105
104
  } = options;
106
105
  const workspaceConfig = await (0, import_get_config.getWorkspaceConfig)(true, { workspaceRoot });
107
- const catalog = await getCatalog(workspaceRoot);
108
- if (!catalog) {
109
- throw new Error("No catalog found");
110
- }
111
- if (throwIfMissingInCatalog === true && !catalog[packageName]) {
112
- throw new Error(
113
- `Package "${packageName}" not found in catalog: ${JSON.stringify(
114
- catalog,
115
- null,
116
- 2
117
- )}`
118
- );
119
- }
120
106
  (0, import_console.writeTrace)(
121
107
  `Upgrading catalog entry for package "${packageName}" with tag "${tag}"`,
122
108
  workspaceConfig
123
109
  );
124
110
  const origVersion = await (0, import_get_version.getVersion)(packageName, tag);
125
- const version = `${prefix || ""}${origVersion.replace(/^[\^~><=*]+/, "")}`;
111
+ const version = `${prefix || ""}${origVersion.replace(/^[\^~><=*]+/g, "")}`;
126
112
  if (version === catalog[packageName]) {
127
113
  (0, import_console.writeTrace)(
128
114
  `The version for package "${packageName}" is already up to date in the catalog: ${version}`,
@@ -130,18 +116,18 @@ async function upgradeCatalogPackage(packageName, options = {}) {
130
116
  );
131
117
  } else if (!(0, import_semver.valid)((0, import_semver.coerce)(catalog[packageName])) || (0, import_semver.coerce)(catalog[packageName]) && (0, import_semver.coerce)(version) && // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
132
118
  (0, import_semver.gt)((0, import_semver.coerce)(version), (0, import_semver.coerce)(catalog[packageName]))) {
133
- catalog[packageName] = `${prefix || ""}${version}`;
119
+ catalog[packageName] = `${prefix || ""}${version.replace(/^[\^~><=*]+/g, "")}`;
134
120
  (0, import_console.writeDebug)(
135
- `Writing version ${version} to catalog for "${packageName}" package`,
121
+ `Writing version ${catalog[packageName]} to catalog for "${packageName}" package`,
136
122
  workspaceConfig
137
123
  );
138
- await setCatalog(catalog, workspaceRoot);
139
124
  } else {
140
125
  (0, import_console.writeWarning)(
141
126
  `The current version "${catalog[packageName]}" for package "${packageName}" is greater than or equal to the version "${version}" fetched from the npm registry with tag "${tag}". No update performed.`,
142
127
  workspaceConfig
143
128
  );
144
129
  }
130
+ return catalog;
145
131
  }
146
132
 
147
133
  // src/cli/index.ts
@@ -192,7 +178,7 @@ async function updateAction(packageNames, {
192
178
  `\u26A1 Preparing to update the package version for ${packages.join(", ")}.`,
193
179
  _config
194
180
  );
195
- const catalog = await getCatalog();
181
+ let catalog = await getCatalog();
196
182
  if (!catalog) {
197
183
  throw new Error(
198
184
  "No catalog found in the pnpm-workspace.yaml file of the current workspace."
@@ -207,22 +193,26 @@ async function updateAction(packageNames, {
207
193
  `No packages found in the catalog matching the name/pattern "${pkg}".`
208
194
  );
209
195
  }
210
- (0, import_config_tools2.writeDebug)(
196
+ (0, import_config_tools2.writeTrace)(
211
197
  `Found ${matchedPackages.length} matching packages in the catalog file:
212
198
 
213
199
  - ${matchedPackages.map((p) => `${p} (${catalog[p] || "unknown"})`).join("\n- ")}`,
214
200
  _config
215
201
  );
216
- await Promise.all(
217
- matchedPackages.map(
218
- (p) => upgradeCatalogPackage(p, {
219
- tag,
220
- throwIfMissingInCatalog: true,
221
- prefix
222
- })
223
- )
224
- );
202
+ for (const matchedPackage of matchedPackages) {
203
+ (0, import_config_tools2.writeTrace)(`- Upgrading ${matchedPackage}...`, _config);
204
+ catalog = await upgradeCatalog(catalog, matchedPackage, {
205
+ tag,
206
+ prefix,
207
+ workspaceRoot: _config.workspaceRoot
208
+ });
209
+ }
225
210
  }
211
+ (0, import_config_tools2.writeDebug)(
212
+ "Finalizing changes to the pnpm workspace's catalog dependencies",
213
+ _config
214
+ );
215
+ await setCatalog(catalog, _config.workspaceRoot);
226
216
  if (install) {
227
217
  (0, import_config_tools2.writeTrace)(
228
218
  "Running `pnpm install --no-frozen-lockfile` to update local dependency versions",
package/bin/pnpm.js CHANGED
@@ -111,33 +111,19 @@ async function setCatalog(catalog, workspaceRoot = findWorkspaceRoot2(process.cw
111
111
  );
112
112
  await writePnpmWorkspaceFile(pnpmWorkspaceFile, workspaceRoot);
113
113
  }
114
- async function upgradeCatalogPackage(packageName, options = {}) {
114
+ async function upgradeCatalog(catalog, packageName, options = {}) {
115
115
  const {
116
116
  tag = DEFAULT_NPM_TAG,
117
117
  prefix = "^",
118
- throwIfMissingInCatalog = false,
119
118
  workspaceRoot = findWorkspaceRoot2()
120
119
  } = options;
121
120
  const workspaceConfig = await getWorkspaceConfig2(true, { workspaceRoot });
122
- const catalog = await getCatalog(workspaceRoot);
123
- if (!catalog) {
124
- throw new Error("No catalog found");
125
- }
126
- if (throwIfMissingInCatalog === true && !catalog[packageName]) {
127
- throw new Error(
128
- `Package "${packageName}" not found in catalog: ${JSON.stringify(
129
- catalog,
130
- null,
131
- 2
132
- )}`
133
- );
134
- }
135
121
  writeTrace2(
136
122
  `Upgrading catalog entry for package "${packageName}" with tag "${tag}"`,
137
123
  workspaceConfig
138
124
  );
139
125
  const origVersion = await getVersion(packageName, tag);
140
- const version = `${prefix || ""}${origVersion.replace(/^[\^~><=*]+/, "")}`;
126
+ const version = `${prefix || ""}${origVersion.replace(/^[\^~><=*]+/g, "")}`;
141
127
  if (version === catalog[packageName]) {
142
128
  writeTrace2(
143
129
  `The version for package "${packageName}" is already up to date in the catalog: ${version}`,
@@ -145,18 +131,18 @@ async function upgradeCatalogPackage(packageName, options = {}) {
145
131
  );
146
132
  } else if (!valid(coerce(catalog[packageName])) || coerce(catalog[packageName]) && coerce(version) && // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
147
133
  gt(coerce(version), coerce(catalog[packageName]))) {
148
- catalog[packageName] = `${prefix || ""}${version}`;
134
+ catalog[packageName] = `${prefix || ""}${version.replace(/^[\^~><=*]+/g, "")}`;
149
135
  writeDebug(
150
- `Writing version ${version} to catalog for "${packageName}" package`,
136
+ `Writing version ${catalog[packageName]} to catalog for "${packageName}" package`,
151
137
  workspaceConfig
152
138
  );
153
- await setCatalog(catalog, workspaceRoot);
154
139
  } else {
155
140
  writeWarning(
156
141
  `The current version "${catalog[packageName]}" for package "${packageName}" is greater than or equal to the version "${version}" fetched from the npm registry with tag "${tag}". No update performed.`,
157
142
  workspaceConfig
158
143
  );
159
144
  }
145
+ return catalog;
160
146
  }
161
147
 
162
148
  // src/cli/index.ts
@@ -207,7 +193,7 @@ async function updateAction(packageNames, {
207
193
  `\u26A1 Preparing to update the package version for ${packages.join(", ")}.`,
208
194
  _config
209
195
  );
210
- const catalog = await getCatalog();
196
+ let catalog = await getCatalog();
211
197
  if (!catalog) {
212
198
  throw new Error(
213
199
  "No catalog found in the pnpm-workspace.yaml file of the current workspace."
@@ -222,22 +208,26 @@ async function updateAction(packageNames, {
222
208
  `No packages found in the catalog matching the name/pattern "${pkg}".`
223
209
  );
224
210
  }
225
- writeDebug2(
211
+ writeTrace3(
226
212
  `Found ${matchedPackages.length} matching packages in the catalog file:
227
213
 
228
214
  - ${matchedPackages.map((p) => `${p} (${catalog[p] || "unknown"})`).join("\n- ")}`,
229
215
  _config
230
216
  );
231
- await Promise.all(
232
- matchedPackages.map(
233
- (p) => upgradeCatalogPackage(p, {
234
- tag,
235
- throwIfMissingInCatalog: true,
236
- prefix
237
- })
238
- )
239
- );
217
+ for (const matchedPackage of matchedPackages) {
218
+ writeTrace3(`- Upgrading ${matchedPackage}...`, _config);
219
+ catalog = await upgradeCatalog(catalog, matchedPackage, {
220
+ tag,
221
+ prefix,
222
+ workspaceRoot: _config.workspaceRoot
223
+ });
224
+ }
240
225
  }
226
+ writeDebug2(
227
+ "Finalizing changes to the pnpm workspace's catalog dependencies",
228
+ _config
229
+ );
230
+ await setCatalog(catalog, _config.workspaceRoot);
241
231
  if (install) {
242
232
  writeTrace3(
243
233
  "Running `pnpm install --no-frozen-lockfile` to update local dependency versions",
@@ -0,0 +1,2 @@
1
+ import {e,h as h$1,i,f,c,b,a}from'./chunk-JGJEVC4U.js';import {exec}from'node:child_process';import {valid,coerce,gt}from'semver';var E="latest";var u=E;async function h(){return new Promise((r,t)=>{exec("npm config get registry",(e,n,s)=>e?t(e):s?t(s):r(n.trim()));})}async function $(r,t=u,e={}){let{registry:n=await h()}=e;return new Promise((s,p)=>{exec(`npm view ${r} version --registry=${n} --tag=${t}`,(i,o,g)=>i?p(i):g?p(g):s(o.trim()));})}async function M(r=e(process.cwd())){let t=await h$1(r);if(!t)throw new Error("No pnpm-workspace.yaml file found");if(t?.catalog)return Object.fromEntries(Object.entries(t.catalog).map(([e,n])=>[e,n.replaceAll('"',"").replaceAll("'","")]));console.warn(`No catalog found in pnpm-workspace.yaml file located in workspace root: ${r}
2
+ File content: ${JSON.stringify(t,null,2)}`);}async function C(r=e(process.cwd())){let t=await M(r);if(!t)throw new Error("No catalog entries found in pnpm-workspace.yaml file");return t}async function v(r,t=e(process.cwd())){let e=await h$1(t);if(!e)throw new Error("No pnpm-workspace.yaml file found");e.catalog=Object.fromEntries(Object.entries(r).map(([n,s])=>[n,s.replaceAll('"',"").replaceAll("'","")])),await i(e,t);}async function Z(r,t,e$1={}){let{tag:n=u,prefix:s="^",workspaceRoot:p=e()}=e$1,i=await f(true,{workspaceRoot:p});c(`Upgrading catalog entry for package "${t}" with tag "${n}"`,i);let o=await $(t,n),g=`${s||""}${o.replace(/^[\^~><=*]+/g,"")}`;return g===r[t]?c(`The version for package "${t}" is already up to date in the catalog: ${g}`,i):!valid(coerce(r[t]))||coerce(r[t])&&coerce(g)&&gt(coerce(g),coerce(r[t]))?(r[t]=`${s||""}${g.replace(/^[\^~><=*]+/g,"")}`,b(`Writing version ${r[t]} to catalog for "${t}" package`,i)):a(`The current version "${r[t]}" for package "${t}" is greater than or equal to the version "${g}" fetched from the npm registry with tag "${n}". No update performed.`,i),r}async function rr(r,t={}){let{tag:e$1=u,prefix:n="^",throwIfMissingInCatalog:s=false,workspaceRoot:p=e()}=t,i=await f(true,{workspaceRoot:p}),o=await C(p);if(!o)throw new Error("No catalog found");if(s===true&&!o[r])throw new Error(`Package "${r}" not found in catalog: ${JSON.stringify(o,null,2)}`);c(`Upgrading catalog entry for package "${r}" with tag "${e$1}"`,i);let g=await $(r,e$1),c$1=`${n||""}${g.replace(/^[\^~><=*]+/g,"")}`;c$1===o[r]?c(`The version for package "${r}" is already up to date in the catalog: ${c$1}`,i):!valid(coerce(o[r]))||coerce(o[r])&&coerce(c$1)&&gt(coerce(c$1),coerce(o[r]))?(o[r]=`${n||""}${c$1.replace(/^[\^~><=*]+/g,"")}`,b(`Writing version ${o[r]} to catalog for "${r}" package`,i),await v(o,p)):a(`The current version "${o[r]}" for package "${r}" is greater than or equal to the version "${c$1}" fetched from the npm registry with tag "${e$1}". No update performed.`,i);}export{M as a,C as b,v as c,Z as d,rr as e};
@@ -1 +1 @@
1
- import {b}from'./chunk-U7UAWKHA.js';import {e,d}from'./chunk-JGJEVC4U.js';import {readCachedProjectGraph,createProjectGraphAsync}from'@nx/devkit';import {existsSync}from'node:fs';import {readFile,writeFile}from'node:fs/promises';import {format}from'prettier';async function $(c=process.cwd(),i=e(c)){let l=d(c,"package.json"),m=await readFile(l,"utf8");if(!m)throw new Error("No package.json file found in package root: "+c);let p=await b(i),r=JSON.parse(m),g=d(i,"pnpm-workspace.yaml");if(!existsSync(g))return console.warn(`No \`pnpm-workspace.yaml\` file found in workspace root (searching in: ${g}). Skipping pnpm catalog read for now.`),r;if(!p){console.warn("No pnpm catalog found. Skipping dependencies replacement for now.");return}for(let a of ["dependencies","devDependencies","peerDependencies"]){let o=r[a];if(o){for(let e of Object.keys(o))if(o[e]==="catalog:"){if(!p)throw new Error(`Dependency ${e} is marked as \`catalog:\`, but no catalog exists in the workspace root's \`pnpm-workspace.yaml\` file.`);let t=p[e];if(!t)throw new Error("Missing pnpm catalog version for "+e);o[e]=t;}else if(o[e].startsWith("catalog:"))throw new Error("multiple named catalogs not supported")}}let n;try{n=readCachedProjectGraph();}catch{await createProjectGraphAsync(),n=readCachedProjectGraph();}let d$1={};n&&await Promise.all(Object.keys(n.nodes).map(async a=>{let o=n.nodes[a];if(o?.data.root){let e=d(i,o.data.root,"package.json");if(existsSync(e)){let t=await readFile(e,"utf8"),f=JSON.parse(t);f.private!==true&&(d$1[f.name]=f.version);}}}));for(let a of ["dependencies","devDependencies","peerDependencies"]){let o=r[a];if(o){for(let e of Object.keys(o))if(o[e].startsWith("workspace:"))if(d$1[e])o[e]=`^${d$1[e]}`;else throw new Error(`Workspace dependency ${e} not found in workspace packages.`)}}return writeFile(l,await format(JSON.stringify(r),{parser:"json",proseWrap:"always",trailingComma:"none",tabWidth:2,semi:true,singleQuote:false,quoteProps:"as-needed",insertPragma:false,bracketSameLine:true,printWidth:80,bracketSpacing:true,arrowParens:"avoid",endOfLine:"lf",plugins:["prettier-plugin-pkg"]}))}export{$ as a};
1
+ import {b}from'./chunk-EWC64ZZT.js';import {e,d}from'./chunk-JGJEVC4U.js';import {readCachedProjectGraph,createProjectGraphAsync}from'@nx/devkit';import {existsSync}from'node:fs';import {readFile,writeFile}from'node:fs/promises';import {format}from'prettier';async function $(c=process.cwd(),i=e(c)){let l=d(c,"package.json"),m=await readFile(l,"utf8");if(!m)throw new Error("No package.json file found in package root: "+c);let p=await b(i),r=JSON.parse(m),g=d(i,"pnpm-workspace.yaml");if(!existsSync(g))return console.warn(`No \`pnpm-workspace.yaml\` file found in workspace root (searching in: ${g}). Skipping pnpm catalog read for now.`),r;if(!p){console.warn("No pnpm catalog found. Skipping dependencies replacement for now.");return}for(let a of ["dependencies","devDependencies","peerDependencies"]){let o=r[a];if(o){for(let e of Object.keys(o))if(o[e]==="catalog:"){if(!p)throw new Error(`Dependency ${e} is marked as \`catalog:\`, but no catalog exists in the workspace root's \`pnpm-workspace.yaml\` file.`);let t=p[e];if(!t)throw new Error("Missing pnpm catalog version for "+e);o[e]=t;}else if(o[e].startsWith("catalog:"))throw new Error("multiple named catalogs not supported")}}let n;try{n=readCachedProjectGraph();}catch{await createProjectGraphAsync(),n=readCachedProjectGraph();}let d$1={};n&&await Promise.all(Object.keys(n.nodes).map(async a=>{let o=n.nodes[a];if(o?.data.root){let e=d(i,o.data.root,"package.json");if(existsSync(e)){let t=await readFile(e,"utf8"),f=JSON.parse(t);f.private!==true&&(d$1[f.name]=f.version);}}}));for(let a of ["dependencies","devDependencies","peerDependencies"]){let o=r[a];if(o){for(let e of Object.keys(o))if(o[e].startsWith("workspace:"))if(d$1[e])o[e]=`^${d$1[e]}`;else throw new Error(`Workspace dependency ${e} not found in workspace packages.`)}}return writeFile(l,await format(JSON.stringify(r),{parser:"json",proseWrap:"always",trailingComma:"none",tabWidth:2,semi:true,singleQuote:false,quoteProps:"as-needed",insertPragma:false,bracketSameLine:true,printWidth:80,bracketSpacing:true,arrowParens:"avoid",endOfLine:"lf",plugins:["prettier-plugin-pkg"]}))}export{$ as a};
@@ -1 +1 @@
1
- 'use strict';var chunkNM3PKH5T_cjs=require('./chunk-NM3PKH5T.cjs'),chunkXDFF7DBD_cjs=require('./chunk-XDFF7DBD.cjs'),devkit=require('@nx/devkit'),fs=require('fs'),promises=require('fs/promises'),prettier=require('prettier');async function C(c=process.cwd(),i=chunkXDFF7DBD_cjs.e(c)){let l=chunkXDFF7DBD_cjs.d(c,"package.json"),m=await promises.readFile(l,"utf8");if(!m)throw new Error("No package.json file found in package root: "+c);let p=await chunkNM3PKH5T_cjs.b(i),r=JSON.parse(m),g=chunkXDFF7DBD_cjs.d(i,"pnpm-workspace.yaml");if(!fs.existsSync(g))return console.warn(`No \`pnpm-workspace.yaml\` file found in workspace root (searching in: ${g}). Skipping pnpm catalog read for now.`),r;if(!p){console.warn("No pnpm catalog found. Skipping dependencies replacement for now.");return}for(let a of ["dependencies","devDependencies","peerDependencies"]){let o=r[a];if(o){for(let e of Object.keys(o))if(o[e]==="catalog:"){if(!p)throw new Error(`Dependency ${e} is marked as \`catalog:\`, but no catalog exists in the workspace root's \`pnpm-workspace.yaml\` file.`);let t=p[e];if(!t)throw new Error("Missing pnpm catalog version for "+e);o[e]=t;}else if(o[e].startsWith("catalog:"))throw new Error("multiple named catalogs not supported")}}let n;try{n=devkit.readCachedProjectGraph();}catch{await devkit.createProjectGraphAsync(),n=devkit.readCachedProjectGraph();}let d={};n&&await Promise.all(Object.keys(n.nodes).map(async a=>{let o=n.nodes[a];if(o?.data.root){let e=chunkXDFF7DBD_cjs.d(i,o.data.root,"package.json");if(fs.existsSync(e)){let t=await promises.readFile(e,"utf8"),f=JSON.parse(t);f.private!==true&&(d[f.name]=f.version);}}}));for(let a of ["dependencies","devDependencies","peerDependencies"]){let o=r[a];if(o){for(let e of Object.keys(o))if(o[e].startsWith("workspace:"))if(d[e])o[e]=`^${d[e]}`;else throw new Error(`Workspace dependency ${e} not found in workspace packages.`)}}return promises.writeFile(l,await prettier.format(JSON.stringify(r),{parser:"json",proseWrap:"always",trailingComma:"none",tabWidth:2,semi:true,singleQuote:false,quoteProps:"as-needed",insertPragma:false,bracketSameLine:true,printWidth:80,bracketSpacing:true,arrowParens:"avoid",endOfLine:"lf",plugins:["prettier-plugin-pkg"]}))}exports.a=C;
1
+ 'use strict';var chunkQHK5XUKM_cjs=require('./chunk-QHK5XUKM.cjs'),chunkXDFF7DBD_cjs=require('./chunk-XDFF7DBD.cjs'),devkit=require('@nx/devkit'),fs=require('fs'),promises=require('fs/promises'),prettier=require('prettier');async function C(c=process.cwd(),i=chunkXDFF7DBD_cjs.e(c)){let l=chunkXDFF7DBD_cjs.d(c,"package.json"),m=await promises.readFile(l,"utf8");if(!m)throw new Error("No package.json file found in package root: "+c);let p=await chunkQHK5XUKM_cjs.b(i),r=JSON.parse(m),g=chunkXDFF7DBD_cjs.d(i,"pnpm-workspace.yaml");if(!fs.existsSync(g))return console.warn(`No \`pnpm-workspace.yaml\` file found in workspace root (searching in: ${g}). Skipping pnpm catalog read for now.`),r;if(!p){console.warn("No pnpm catalog found. Skipping dependencies replacement for now.");return}for(let a of ["dependencies","devDependencies","peerDependencies"]){let o=r[a];if(o){for(let e of Object.keys(o))if(o[e]==="catalog:"){if(!p)throw new Error(`Dependency ${e} is marked as \`catalog:\`, but no catalog exists in the workspace root's \`pnpm-workspace.yaml\` file.`);let t=p[e];if(!t)throw new Error("Missing pnpm catalog version for "+e);o[e]=t;}else if(o[e].startsWith("catalog:"))throw new Error("multiple named catalogs not supported")}}let n;try{n=devkit.readCachedProjectGraph();}catch{await devkit.createProjectGraphAsync(),n=devkit.readCachedProjectGraph();}let d={};n&&await Promise.all(Object.keys(n.nodes).map(async a=>{let o=n.nodes[a];if(o?.data.root){let e=chunkXDFF7DBD_cjs.d(i,o.data.root,"package.json");if(fs.existsSync(e)){let t=await promises.readFile(e,"utf8"),f=JSON.parse(t);f.private!==true&&(d[f.name]=f.version);}}}));for(let a of ["dependencies","devDependencies","peerDependencies"]){let o=r[a];if(o){for(let e of Object.keys(o))if(o[e].startsWith("workspace:"))if(d[e])o[e]=`^${d[e]}`;else throw new Error(`Workspace dependency ${e} not found in workspace packages.`)}}return promises.writeFile(l,await prettier.format(JSON.stringify(r),{parser:"json",proseWrap:"always",trailingComma:"none",tabWidth:2,semi:true,singleQuote:false,quoteProps:"as-needed",insertPragma:false,bracketSameLine:true,printWidth:80,bracketSpacing:true,arrowParens:"avoid",endOfLine:"lf",plugins:["prettier-plugin-pkg"]}))}exports.a=C;
@@ -0,0 +1,2 @@
1
+ 'use strict';var chunkXDFF7DBD_cjs=require('./chunk-XDFF7DBD.cjs'),child_process=require('child_process'),semver=require('semver');var _="latest";var u=_;async function E(){return new Promise((r,t)=>{child_process.exec("npm config get registry",(e,n,s)=>e?t(e):s?t(s):r(n.trim()));})}async function R(r,t=u,e={}){let{registry:n=await E()}=e;return new Promise((s,p)=>{child_process.exec(`npm view ${r} version --registry=${n} --tag=${t}`,(i,o,g)=>i?p(i):g?p(g):s(o.trim()));})}async function G(r=chunkXDFF7DBD_cjs.e(process.cwd())){let t=await chunkXDFF7DBD_cjs.h(r);if(!t)throw new Error("No pnpm-workspace.yaml file found");if(t?.catalog)return Object.fromEntries(Object.entries(t.catalog).map(([e,n])=>[e,n.replaceAll('"',"").replaceAll("'","")]));console.warn(`No catalog found in pnpm-workspace.yaml file located in workspace root: ${r}
2
+ File content: ${JSON.stringify(t,null,2)}`);}async function M(r=chunkXDFF7DBD_cjs.e(process.cwd())){let t=await G(r);if(!t)throw new Error("No catalog entries found in pnpm-workspace.yaml file");return t}async function C(r,t=chunkXDFF7DBD_cjs.e(process.cwd())){let e=await chunkXDFF7DBD_cjs.h(t);if(!e)throw new Error("No pnpm-workspace.yaml file found");e.catalog=Object.fromEntries(Object.entries(r).map(([n,s])=>[n,s.replaceAll('"',"").replaceAll("'","")])),await chunkXDFF7DBD_cjs.i(e,t);}async function Q(r,t,e={}){let{tag:n=u,prefix:s="^",workspaceRoot:p=chunkXDFF7DBD_cjs.e()}=e,i=await chunkXDFF7DBD_cjs.f(true,{workspaceRoot:p});chunkXDFF7DBD_cjs.c(`Upgrading catalog entry for package "${t}" with tag "${n}"`,i);let o=await R(t,n),g=`${s||""}${o.replace(/^[\^~><=*]+/g,"")}`;return g===r[t]?chunkXDFF7DBD_cjs.c(`The version for package "${t}" is already up to date in the catalog: ${g}`,i):!semver.valid(semver.coerce(r[t]))||semver.coerce(r[t])&&semver.coerce(g)&&semver.gt(semver.coerce(g),semver.coerce(r[t]))?(r[t]=`${s||""}${g.replace(/^[\^~><=*]+/g,"")}`,chunkXDFF7DBD_cjs.b(`Writing version ${r[t]} to catalog for "${t}" package`,i)):chunkXDFF7DBD_cjs.a(`The current version "${r[t]}" for package "${t}" is greater than or equal to the version "${g}" fetched from the npm registry with tag "${n}". No update performed.`,i),r}async function Z(r,t={}){let{tag:e=u,prefix:n="^",throwIfMissingInCatalog:s=false,workspaceRoot:p=chunkXDFF7DBD_cjs.e()}=t,i=await chunkXDFF7DBD_cjs.f(true,{workspaceRoot:p}),o=await M(p);if(!o)throw new Error("No catalog found");if(s===true&&!o[r])throw new Error(`Package "${r}" not found in catalog: ${JSON.stringify(o,null,2)}`);chunkXDFF7DBD_cjs.c(`Upgrading catalog entry for package "${r}" with tag "${e}"`,i);let g=await R(r,e),c=`${n||""}${g.replace(/^[\^~><=*]+/g,"")}`;c===o[r]?chunkXDFF7DBD_cjs.c(`The version for package "${r}" is already up to date in the catalog: ${c}`,i):!semver.valid(semver.coerce(o[r]))||semver.coerce(o[r])&&semver.coerce(c)&&semver.gt(semver.coerce(c),semver.coerce(o[r]))?(o[r]=`${n||""}${c.replace(/^[\^~><=*]+/g,"")}`,chunkXDFF7DBD_cjs.b(`Writing version ${o[r]} to catalog for "${r}" package`,i),await C(o,p)):chunkXDFF7DBD_cjs.a(`The current version "${o[r]}" for package "${r}" is greater than or equal to the version "${c}" fetched from the npm registry with tag "${e}". No update performed.`,i);}exports.a=G;exports.b=M;exports.c=C;exports.d=Q;exports.e=Z;
@@ -1 +1 @@
1
- 'use strict';var chunkNM3PKH5T_cjs=require('../chunk-NM3PKH5T.cjs');require('../chunk-XDFF7DBD.cjs');Object.defineProperty(exports,"getCatalog",{enumerable:true,get:function(){return chunkNM3PKH5T_cjs.b}});Object.defineProperty(exports,"getCatalogSafe",{enumerable:true,get:function(){return chunkNM3PKH5T_cjs.a}});Object.defineProperty(exports,"setCatalog",{enumerable:true,get:function(){return chunkNM3PKH5T_cjs.c}});Object.defineProperty(exports,"upgradeCatalogPackage",{enumerable:true,get:function(){return chunkNM3PKH5T_cjs.d}});
1
+ 'use strict';var chunkQHK5XUKM_cjs=require('../chunk-QHK5XUKM.cjs');require('../chunk-XDFF7DBD.cjs');Object.defineProperty(exports,"getCatalog",{enumerable:true,get:function(){return chunkQHK5XUKM_cjs.b}});Object.defineProperty(exports,"getCatalogSafe",{enumerable:true,get:function(){return chunkQHK5XUKM_cjs.a}});Object.defineProperty(exports,"saveCatalog",{enumerable:true,get:function(){return chunkQHK5XUKM_cjs.e}});Object.defineProperty(exports,"setCatalog",{enumerable:true,get:function(){return chunkQHK5XUKM_cjs.c}});Object.defineProperty(exports,"upgradeCatalog",{enumerable:true,get:function(){return chunkQHK5XUKM_cjs.d}});
@@ -52,6 +52,15 @@ interface UpgradeCatalogPackageOptions {
52
52
  */
53
53
  prefix?: "^" | "~" | ">" | "<" | ">=" | "<=" | "*";
54
54
  }
55
+ /**
56
+ * Upgrade a package in the pnpm catalog.
57
+ *
58
+ * @param catalog - The pnpm catalog to update.
59
+ * @param packageName - The name of the package to upgrade.
60
+ * @param options - Options for upgrading the package.
61
+ * @returns The updated catalog.
62
+ */
63
+ declare function upgradeCatalog(catalog: Record<string, string>, packageName: string, options?: UpgradeCatalogPackageOptions): Promise<Record<string, string>>;
55
64
  /**
56
65
  * Update package.json dependencies currently using `catalog:` or `workspace:*` to use the pnpm catalog dependencies actual versions and the local workspace versions respectively.
57
66
  *
@@ -60,6 +69,6 @@ interface UpgradeCatalogPackageOptions {
60
69
  * @returns A promise that resolves when the package.json file has been updated.
61
70
  * @throws Will throw an error if no package.json file is found in the package root, or if a dependency is marked as `catalog:` but no catalog exists.
62
71
  */
63
- declare function upgradeCatalogPackage(packageName: string, options?: UpgradeCatalogPackageOptions): Promise<void>;
72
+ declare function saveCatalog(packageName: string, options?: UpgradeCatalogPackageOptions): Promise<void>;
64
73
 
65
- export { type UpgradeCatalogPackageOptions, getCatalog, getCatalogSafe, setCatalog, upgradeCatalogPackage };
74
+ export { type UpgradeCatalogPackageOptions, getCatalog, getCatalogSafe, saveCatalog, setCatalog, upgradeCatalog };
@@ -52,6 +52,15 @@ interface UpgradeCatalogPackageOptions {
52
52
  */
53
53
  prefix?: "^" | "~" | ">" | "<" | ">=" | "<=" | "*";
54
54
  }
55
+ /**
56
+ * Upgrade a package in the pnpm catalog.
57
+ *
58
+ * @param catalog - The pnpm catalog to update.
59
+ * @param packageName - The name of the package to upgrade.
60
+ * @param options - Options for upgrading the package.
61
+ * @returns The updated catalog.
62
+ */
63
+ declare function upgradeCatalog(catalog: Record<string, string>, packageName: string, options?: UpgradeCatalogPackageOptions): Promise<Record<string, string>>;
55
64
  /**
56
65
  * Update package.json dependencies currently using `catalog:` or `workspace:*` to use the pnpm catalog dependencies actual versions and the local workspace versions respectively.
57
66
  *
@@ -60,6 +69,6 @@ interface UpgradeCatalogPackageOptions {
60
69
  * @returns A promise that resolves when the package.json file has been updated.
61
70
  * @throws Will throw an error if no package.json file is found in the package root, or if a dependency is marked as `catalog:` but no catalog exists.
62
71
  */
63
- declare function upgradeCatalogPackage(packageName: string, options?: UpgradeCatalogPackageOptions): Promise<void>;
72
+ declare function saveCatalog(packageName: string, options?: UpgradeCatalogPackageOptions): Promise<void>;
64
73
 
65
- export { type UpgradeCatalogPackageOptions, getCatalog, getCatalogSafe, setCatalog, upgradeCatalogPackage };
74
+ export { type UpgradeCatalogPackageOptions, getCatalog, getCatalogSafe, saveCatalog, setCatalog, upgradeCatalog };
@@ -1 +1 @@
1
- export{b as getCatalog,a as getCatalogSafe,c as setCatalog,d as upgradeCatalogPackage}from'../chunk-U7UAWKHA.js';import'../chunk-JGJEVC4U.js';
1
+ export{b as getCatalog,a as getCatalogSafe,e as saveCatalog,c as setCatalog,d as upgradeCatalog}from'../chunk-EWC64ZZT.js';import'../chunk-JGJEVC4U.js';
@@ -1 +1 @@
1
- 'use strict';require('../chunk-QNTSKZUU.cjs');var chunkEOY4SFRO_cjs=require('../chunk-EOY4SFRO.cjs'),chunkNM3PKH5T_cjs=require('../chunk-NM3PKH5T.cjs'),chunkXDFF7DBD_cjs=require('../chunk-XDFF7DBD.cjs');Object.defineProperty(exports,"replaceDepsAliases",{enumerable:true,get:function(){return chunkEOY4SFRO_cjs.a}});Object.defineProperty(exports,"getCatalog",{enumerable:true,get:function(){return chunkNM3PKH5T_cjs.b}});Object.defineProperty(exports,"getCatalogSafe",{enumerable:true,get:function(){return chunkNM3PKH5T_cjs.a}});Object.defineProperty(exports,"setCatalog",{enumerable:true,get:function(){return chunkNM3PKH5T_cjs.c}});Object.defineProperty(exports,"upgradeCatalogPackage",{enumerable:true,get:function(){return chunkNM3PKH5T_cjs.d}});Object.defineProperty(exports,"getPnpmWorkspaceFilePath",{enumerable:true,get:function(){return chunkXDFF7DBD_cjs.g}});Object.defineProperty(exports,"readPnpmWorkspaceFile",{enumerable:true,get:function(){return chunkXDFF7DBD_cjs.h}});Object.defineProperty(exports,"writePnpmWorkspaceFile",{enumerable:true,get:function(){return chunkXDFF7DBD_cjs.i}});
1
+ 'use strict';require('../chunk-QNTSKZUU.cjs');var chunkNR4Q3RAB_cjs=require('../chunk-NR4Q3RAB.cjs'),chunkQHK5XUKM_cjs=require('../chunk-QHK5XUKM.cjs'),chunkXDFF7DBD_cjs=require('../chunk-XDFF7DBD.cjs');Object.defineProperty(exports,"replaceDepsAliases",{enumerable:true,get:function(){return chunkNR4Q3RAB_cjs.a}});Object.defineProperty(exports,"getCatalog",{enumerable:true,get:function(){return chunkQHK5XUKM_cjs.b}});Object.defineProperty(exports,"getCatalogSafe",{enumerable:true,get:function(){return chunkQHK5XUKM_cjs.a}});Object.defineProperty(exports,"saveCatalog",{enumerable:true,get:function(){return chunkQHK5XUKM_cjs.e}});Object.defineProperty(exports,"setCatalog",{enumerable:true,get:function(){return chunkQHK5XUKM_cjs.c}});Object.defineProperty(exports,"upgradeCatalog",{enumerable:true,get:function(){return chunkQHK5XUKM_cjs.d}});Object.defineProperty(exports,"getPnpmWorkspaceFilePath",{enumerable:true,get:function(){return chunkXDFF7DBD_cjs.g}});Object.defineProperty(exports,"readPnpmWorkspaceFile",{enumerable:true,get:function(){return chunkXDFF7DBD_cjs.h}});Object.defineProperty(exports,"writePnpmWorkspaceFile",{enumerable:true,get:function(){return chunkXDFF7DBD_cjs.i}});
@@ -1,4 +1,4 @@
1
- export { UpgradeCatalogPackageOptions, getCatalog, getCatalogSafe, setCatalog, upgradeCatalogPackage } from './catalog.cjs';
1
+ export { UpgradeCatalogPackageOptions, getCatalog, getCatalogSafe, saveCatalog, setCatalog, upgradeCatalog } from './catalog.cjs';
2
2
  export { getPnpmWorkspaceFilePath, readPnpmWorkspaceFile, writePnpmWorkspaceFile } from './pnpm-workspace.cjs';
3
3
  export { replaceDepsAliases } from './replace-deps-aliases.cjs';
4
4
  import '../types.cjs';
@@ -1,4 +1,4 @@
1
- export { UpgradeCatalogPackageOptions, getCatalog, getCatalogSafe, setCatalog, upgradeCatalogPackage } from './catalog.js';
1
+ export { UpgradeCatalogPackageOptions, getCatalog, getCatalogSafe, saveCatalog, setCatalog, upgradeCatalog } from './catalog.js';
2
2
  export { getPnpmWorkspaceFilePath, readPnpmWorkspaceFile, writePnpmWorkspaceFile } from './pnpm-workspace.js';
3
3
  export { replaceDepsAliases } from './replace-deps-aliases.js';
4
4
  import '../types.js';
@@ -1 +1 @@
1
- import'../chunk-GV6YH6UO.js';export{a as replaceDepsAliases}from'../chunk-E7QLQFQS.js';export{b as getCatalog,a as getCatalogSafe,c as setCatalog,d as upgradeCatalogPackage}from'../chunk-U7UAWKHA.js';export{g as getPnpmWorkspaceFilePath,h as readPnpmWorkspaceFile,i as writePnpmWorkspaceFile}from'../chunk-JGJEVC4U.js';
1
+ import'../chunk-GV6YH6UO.js';export{a as replaceDepsAliases}from'../chunk-FCOQR6F7.js';export{b as getCatalog,a as getCatalogSafe,e as saveCatalog,c as setCatalog,d as upgradeCatalog}from'../chunk-EWC64ZZT.js';export{g as getPnpmWorkspaceFilePath,h as readPnpmWorkspaceFile,i as writePnpmWorkspaceFile}from'../chunk-JGJEVC4U.js';
@@ -1 +1 @@
1
- 'use strict';var chunkEOY4SFRO_cjs=require('../chunk-EOY4SFRO.cjs');require('../chunk-NM3PKH5T.cjs'),require('../chunk-XDFF7DBD.cjs');Object.defineProperty(exports,"replaceDepsAliases",{enumerable:true,get:function(){return chunkEOY4SFRO_cjs.a}});
1
+ 'use strict';var chunkNR4Q3RAB_cjs=require('../chunk-NR4Q3RAB.cjs');require('../chunk-QHK5XUKM.cjs'),require('../chunk-XDFF7DBD.cjs');Object.defineProperty(exports,"replaceDepsAliases",{enumerable:true,get:function(){return chunkNR4Q3RAB_cjs.a}});
@@ -1 +1 @@
1
- export{a as replaceDepsAliases}from'../chunk-E7QLQFQS.js';import'../chunk-U7UAWKHA.js';import'../chunk-JGJEVC4U.js';
1
+ export{a as replaceDepsAliases}from'../chunk-FCOQR6F7.js';import'../chunk-EWC64ZZT.js';import'../chunk-JGJEVC4U.js';
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- 'use strict';require('./chunk-SFZRYJZ2.cjs'),require('./chunk-QNTSKZUU.cjs');var chunkEOY4SFRO_cjs=require('./chunk-EOY4SFRO.cjs'),chunkNM3PKH5T_cjs=require('./chunk-NM3PKH5T.cjs'),chunkXDFF7DBD_cjs=require('./chunk-XDFF7DBD.cjs');Object.defineProperty(exports,"replaceDepsAliases",{enumerable:true,get:function(){return chunkEOY4SFRO_cjs.a}});Object.defineProperty(exports,"getCatalog",{enumerable:true,get:function(){return chunkNM3PKH5T_cjs.b}});Object.defineProperty(exports,"getCatalogSafe",{enumerable:true,get:function(){return chunkNM3PKH5T_cjs.a}});Object.defineProperty(exports,"setCatalog",{enumerable:true,get:function(){return chunkNM3PKH5T_cjs.c}});Object.defineProperty(exports,"upgradeCatalogPackage",{enumerable:true,get:function(){return chunkNM3PKH5T_cjs.d}});Object.defineProperty(exports,"getPnpmWorkspaceFilePath",{enumerable:true,get:function(){return chunkXDFF7DBD_cjs.g}});Object.defineProperty(exports,"readPnpmWorkspaceFile",{enumerable:true,get:function(){return chunkXDFF7DBD_cjs.h}});Object.defineProperty(exports,"writePnpmWorkspaceFile",{enumerable:true,get:function(){return chunkXDFF7DBD_cjs.i}});
1
+ 'use strict';require('./chunk-SFZRYJZ2.cjs'),require('./chunk-QNTSKZUU.cjs');var chunkNR4Q3RAB_cjs=require('./chunk-NR4Q3RAB.cjs'),chunkQHK5XUKM_cjs=require('./chunk-QHK5XUKM.cjs'),chunkXDFF7DBD_cjs=require('./chunk-XDFF7DBD.cjs');Object.defineProperty(exports,"replaceDepsAliases",{enumerable:true,get:function(){return chunkNR4Q3RAB_cjs.a}});Object.defineProperty(exports,"getCatalog",{enumerable:true,get:function(){return chunkQHK5XUKM_cjs.b}});Object.defineProperty(exports,"getCatalogSafe",{enumerable:true,get:function(){return chunkQHK5XUKM_cjs.a}});Object.defineProperty(exports,"saveCatalog",{enumerable:true,get:function(){return chunkQHK5XUKM_cjs.e}});Object.defineProperty(exports,"setCatalog",{enumerable:true,get:function(){return chunkQHK5XUKM_cjs.c}});Object.defineProperty(exports,"upgradeCatalog",{enumerable:true,get:function(){return chunkQHK5XUKM_cjs.d}});Object.defineProperty(exports,"getPnpmWorkspaceFilePath",{enumerable:true,get:function(){return chunkXDFF7DBD_cjs.g}});Object.defineProperty(exports,"readPnpmWorkspaceFile",{enumerable:true,get:function(){return chunkXDFF7DBD_cjs.h}});Object.defineProperty(exports,"writePnpmWorkspaceFile",{enumerable:true,get:function(){return chunkXDFF7DBD_cjs.i}});
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- export { UpgradeCatalogPackageOptions, getCatalog, getCatalogSafe, setCatalog, upgradeCatalogPackage } from './helpers/catalog.cjs';
1
+ export { UpgradeCatalogPackageOptions, getCatalog, getCatalogSafe, saveCatalog, setCatalog, upgradeCatalog } from './helpers/catalog.cjs';
2
2
  export { getPnpmWorkspaceFilePath, readPnpmWorkspaceFile, writePnpmWorkspaceFile } from './helpers/pnpm-workspace.cjs';
3
3
  export { replaceDepsAliases } from './helpers/replace-deps-aliases.cjs';
4
4
  export { PnpmWorkspaceFile } from './types.cjs';
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { UpgradeCatalogPackageOptions, getCatalog, getCatalogSafe, setCatalog, upgradeCatalogPackage } from './helpers/catalog.js';
1
+ export { UpgradeCatalogPackageOptions, getCatalog, getCatalogSafe, saveCatalog, setCatalog, upgradeCatalog } from './helpers/catalog.js';
2
2
  export { getPnpmWorkspaceFilePath, readPnpmWorkspaceFile, writePnpmWorkspaceFile } from './helpers/pnpm-workspace.js';
3
3
  export { replaceDepsAliases } from './helpers/replace-deps-aliases.js';
4
4
  export { PnpmWorkspaceFile } from './types.js';
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import'./chunk-GGNOJ77I.js';import'./chunk-GV6YH6UO.js';export{a as replaceDepsAliases}from'./chunk-E7QLQFQS.js';export{b as getCatalog,a as getCatalogSafe,c as setCatalog,d as upgradeCatalogPackage}from'./chunk-U7UAWKHA.js';export{g as getPnpmWorkspaceFilePath,h as readPnpmWorkspaceFile,i as writePnpmWorkspaceFile}from'./chunk-JGJEVC4U.js';
1
+ import'./chunk-GGNOJ77I.js';import'./chunk-GV6YH6UO.js';export{a as replaceDepsAliases}from'./chunk-FCOQR6F7.js';export{b as getCatalog,a as getCatalogSafe,e as saveCatalog,c as setCatalog,d as upgradeCatalog}from'./chunk-EWC64ZZT.js';export{g as getPnpmWorkspaceFilePath,h as readPnpmWorkspaceFile,i as writePnpmWorkspaceFile}from'./chunk-JGJEVC4U.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storm-software/pnpm-tools",
3
- "version": "0.5.5",
3
+ "version": "0.5.7",
4
4
  "type": "module",
5
5
  "description": "A set of [pnpm](https://pnpm.io/) plugins and utilities for managing workspace packages/dependencies.",
6
6
  "repository": {
@@ -89,9 +89,9 @@
89
89
  "dependencies": {
90
90
  "@pnpm/plugin-better-defaults": "^0.2.1",
91
91
  "@pnpm/plugin-esm-node-path": "^0.1.2",
92
- "@storm-software/config": "^1.133.3",
93
- "@storm-software/config-tools": "^1.187.7",
94
- "@storm-software/npm-tools": "^0.4.12",
92
+ "@storm-software/config": "^1.133.4",
93
+ "@storm-software/config-tools": "^1.187.9",
94
+ "@storm-software/npm-tools": "^0.4.14",
95
95
  "commander": "^12.1.0",
96
96
  "defu": "6.1.4",
97
97
  "prettier": "^3.5.1",
@@ -105,5 +105,5 @@
105
105
  "tsup": "8.4.0"
106
106
  },
107
107
  "publishConfig": { "access": "public" },
108
- "gitHead": "a98883ba549e6a12ff4d6a2b15a22a65649c4600"
108
+ "gitHead": "0841267dc509f78180467408b62a1b9f5abd6c43"
109
109
  }
@@ -1,2 +0,0 @@
1
- 'use strict';var chunkXDFF7DBD_cjs=require('./chunk-XDFF7DBD.cjs'),child_process=require('child_process'),semver=require('semver');var E="latest";var l=E;async function d(){return new Promise((r,t)=>{child_process.exec("npm config get registry",(e,n,i)=>e?t(e):i?t(i):r(n.trim()));})}async function P(r,t=l,e={}){let{registry:n=await d()}=e;return new Promise((i,g)=>{child_process.exec(`npm view ${r} version --registry=${n} --tag=${t}`,(s,o,f)=>s?g(s):f?g(f):i(o.trim()));})}async function M(r=chunkXDFF7DBD_cjs.e(process.cwd())){let t=await chunkXDFF7DBD_cjs.h(r);if(!t)throw new Error("No pnpm-workspace.yaml file found");if(t?.catalog)return Object.fromEntries(Object.entries(t.catalog).map(([e,n])=>[e,n.replaceAll('"',"").replaceAll("'","")]));console.warn(`No catalog found in pnpm-workspace.yaml file located in workspace root: ${r}
2
- File content: ${JSON.stringify(t,null,2)}`);}async function $(r=chunkXDFF7DBD_cjs.e(process.cwd())){let t=await M(r);if(!t)throw new Error("No catalog entries found in pnpm-workspace.yaml file");return t}async function I(r,t=chunkXDFF7DBD_cjs.e(process.cwd())){let e=await chunkXDFF7DBD_cjs.h(t);if(!e)throw new Error("No pnpm-workspace.yaml file found");e.catalog=Object.fromEntries(Object.entries(r).map(([n,i])=>[n,i.replaceAll('"',"").replaceAll("'","")])),await chunkXDFF7DBD_cjs.i(e,t);}async function Q(r,t={}){let{tag:e=l,prefix:n="^",throwIfMissingInCatalog:i=false,workspaceRoot:g=chunkXDFF7DBD_cjs.e()}=t,s=await chunkXDFF7DBD_cjs.f(true,{workspaceRoot:g}),o=await $(g);if(!o)throw new Error("No catalog found");if(i===true&&!o[r])throw new Error(`Package "${r}" not found in catalog: ${JSON.stringify(o,null,2)}`);chunkXDFF7DBD_cjs.c(`Upgrading catalog entry for package "${r}" with tag "${e}"`,s);let f=await P(r,e),a=`${n||""}${f.replace(/^[\^~><=*]+/,"")}`;a===o[r]?chunkXDFF7DBD_cjs.c(`The version for package "${r}" is already up to date in the catalog: ${a}`,s):!semver.valid(semver.coerce(o[r]))||semver.coerce(o[r])&&semver.coerce(a)&&semver.gt(semver.coerce(a),semver.coerce(o[r]))?(o[r]=`${n||""}${a}`,chunkXDFF7DBD_cjs.b(`Writing version ${a} to catalog for "${r}" package`,s),await I(o,g)):chunkXDFF7DBD_cjs.a(`The current version "${o[r]}" for package "${r}" is greater than or equal to the version "${a}" fetched from the npm registry with tag "${e}". No update performed.`,s);}exports.a=M;exports.b=$;exports.c=I;exports.d=Q;
@@ -1,2 +0,0 @@
1
- import {e,h,i,f,c,b,a}from'./chunk-JGJEVC4U.js';import {exec}from'node:child_process';import {valid,coerce,gt}from'semver';var d="latest";var l=d;async function P(){return new Promise((r,t)=>{exec("npm config get registry",(e,n,i)=>e?t(e):i?t(i):r(n.trim()));})}async function A(r,t=l,e={}){let{registry:n=await P()}=e;return new Promise((i,g)=>{exec(`npm view ${r} version --registry=${n} --tag=${t}`,(s,o,f)=>s?g(s):f?g(f):i(o.trim()));})}async function $(r=e(process.cwd())){let t=await h(r);if(!t)throw new Error("No pnpm-workspace.yaml file found");if(t?.catalog)return Object.fromEntries(Object.entries(t.catalog).map(([e,n])=>[e,n.replaceAll('"',"").replaceAll("'","")]));console.warn(`No catalog found in pnpm-workspace.yaml file located in workspace root: ${r}
2
- File content: ${JSON.stringify(t,null,2)}`);}async function I(r=e(process.cwd())){let t=await $(r);if(!t)throw new Error("No catalog entries found in pnpm-workspace.yaml file");return t}async function O(r,t=e(process.cwd())){let e=await h(t);if(!e)throw new Error("No pnpm-workspace.yaml file found");e.catalog=Object.fromEntries(Object.entries(r).map(([n,i])=>[n,i.replaceAll('"',"").replaceAll("'","")])),await i(e,t);}async function Z(r,t={}){let{tag:e$1=l,prefix:n="^",throwIfMissingInCatalog:i=false,workspaceRoot:g=e()}=t,s=await f(true,{workspaceRoot:g}),o=await I(g);if(!o)throw new Error("No catalog found");if(i===true&&!o[r])throw new Error(`Package "${r}" not found in catalog: ${JSON.stringify(o,null,2)}`);c(`Upgrading catalog entry for package "${r}" with tag "${e$1}"`,s);let f$1=await A(r,e$1),a$1=`${n||""}${f$1.replace(/^[\^~><=*]+/,"")}`;a$1===o[r]?c(`The version for package "${r}" is already up to date in the catalog: ${a$1}`,s):!valid(coerce(o[r]))||coerce(o[r])&&coerce(a$1)&&gt(coerce(a$1),coerce(o[r]))?(o[r]=`${n||""}${a$1}`,b(`Writing version ${a$1} to catalog for "${r}" package`,s),await O(o,g)):a(`The current version "${o[r]}" for package "${r}" is greater than or equal to the version "${a$1}" fetched from the npm registry with tag "${e$1}". No update performed.`,s);}export{$ as a,I as b,O as c,Z as d};