Skip to content

Commit 9d3749d

Browse files
committed
chore(pnpm-tools): Added summary logging and reduced general CLI noise
1 parent 8e54226 commit 9d3749d

4 files changed

Lines changed: 109 additions & 69 deletions

File tree

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/pnpm-tools/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@
9595
"@storm-software/config-tools": "workspace:*",
9696
"@storm-software/npm-tools": "workspace:*",
9797
"@storm-software/package-constants": "workspace:*",
98+
"chalk": "catalog:",
9899
"commander": "catalog:",
99100
"defu": "catalog:",
100101
"prettier": "catalog:",

packages/pnpm-tools/src/cli/index.ts

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@ import {
66
writeDebug,
77
writeFatal,
88
writeInfo,
9+
writeSuccess,
910
writeTrace,
1011
writeWarning
1112
} from "@storm-software/config-tools";
1213
import { INTERNAL_PACKAGES } from "@storm-software/package-constants/internal-packages";
14+
import { bold, green, red } from "chalk";
1315
import { Command } from "commander";
1416
import packageJson from "../../package.json" with { type: "json" };
1517
import {
@@ -81,7 +83,10 @@ export function createProgram(config: StormWorkspaceConfig) {
8183
"--pnpm-plugin",
8284
"Whether to upgrade the Storm Software pnpm plugin."
8385
)
84-
.option("--all", "Whether to update all packages.")
86+
.option(
87+
"--all",
88+
"Whether to update all packages (with the exception of the pnpm plugin)."
89+
)
8590
.action(updateAction);
8691

8792
return program;
@@ -114,7 +119,7 @@ async function updateAction(
114119
all,
115120
internal = all,
116121
nx = all,
117-
pnpmPlugin = all,
122+
pnpmPlugin,
118123
prefix = "^"
119124
} = options || {};
120125

@@ -128,8 +133,14 @@ async function updateAction(
128133

129134
pkgs = pkgs.filter(Boolean).map(pkg => pkg.trim().replaceAll("*", ""));
130135

136+
let changed: {
137+
packageName: string;
138+
previous: string;
139+
current: string;
140+
}[] = [];
141+
131142
if (pkgs.length > 0) {
132-
writeInfo(
143+
writeDebug(
133144
`${brandIcon(_config)} Preparing to update the package version for ${pkgs.join(
134145
", "
135146
)}.`,
@@ -143,6 +154,8 @@ async function updateAction(
143154
);
144155
}
145156

157+
const originalCatalog = { ...catalog };
158+
146159
await Promise.all(
147160
pkgs.map(async pkg => {
148161
const matchedPackages = Object.keys(catalog).filter(p =>
@@ -182,6 +195,16 @@ async function updateAction(
182195
})
183196
);
184197

198+
changed = Object.keys(catalog)
199+
.filter(
200+
packageName => originalCatalog[packageName] !== catalog[packageName]
201+
)
202+
.map(packageName => ({
203+
packageName,
204+
previous: originalCatalog[packageName] || "unknown",
205+
current: catalog[packageName] || "unknown"
206+
}));
207+
185208
if (packagesUpdated) {
186209
writeDebug(
187210
"Finalizing changes to the pnpm workspace's catalog dependencies",
@@ -248,6 +271,19 @@ async function updateAction(
248271
proc.stdout?.on("data", data => {
249272
console.log(data.toString());
250273
});
274+
275+
writeSuccess(
276+
`${brandIcon(_config)} Successfully updated the version for the following package(s):
277+
${changed
278+
.map(
279+
pkg =>
280+
`- ${bold(pkg.packageName)}: ${bold(red(pkg.previous))} -> ${bold(
281+
green(pkg.current)
282+
)}`
283+
)
284+
.join("\n")}`,
285+
_config
286+
);
251287
}
252288
} catch (error) {
253289
writeFatal(

0 commit comments

Comments
 (0)