Skip to content

armgit / ruflo

Public Imported from GitHub
0

🌊 The original agent harness. Deploy intelligent multi-player swarms, coordinate autonomous workflows, and build conversational AI systems. Features adaptive memory, self-learning intelligence, federation, vector RAG integration, and native Claude Code / Codex / Hermes and many more Integrated

fix(update): honor --dry-run in update all (#4398)

nk-batman21ac9f8b879e5d
diff --git a/v3/@claude-flow/cli/__tests__/update-all-dry-run.test.ts b/v3/@claude-flow/cli/__tests__/update-all-dry-run.test.ts
new file mode 100644
index 0000000000..59650aee45
--- /dev/null
+++ b/v3/@claude-flow/cli/__tests__/update-all-dry-run.test.ts
@@ -0,0 +1,55 @@
+import { afterEach, describe, expect, it, vi } from 'vitest';
+
+const mocks = vi.hoisted(() => ({
+ executeMultipleUpdates: vi.fn(async (..._args: unknown[]) => []),
+}));
+
+vi.mock('../src/output.js', () => ({
+ output: {
+ writeln: vi.fn(), printInfo: vi.fn(), printSuccess: vi.fn(), printError: vi.fn(),
+ highlight: (text: string) => text, success: (text: string) => text, error: (text: string) => text,
+ },
+}));
+vi.mock('../src/update/checker.js', () => ({
+ DEFAULT_CONFIG: { autoUpdate: { patch: true, minor: false, major: false }, priority: {}, exclude: [] },
+ checkForUpdates: async () => ({
+ results: [{
+ package: '@claude-flow/cli', currentVersion: '3.0.0', latestVersion: '3.1.0',
+ updateType: 'minor', shouldAutoUpdate: false, priority: 'high',
+ }],
+ skipped: false,
+ }),
+ checkSinglePackage: vi.fn(),
+ getInstalledVersion: () => '3.0.0',
+}));
+vi.mock('../src/update/executor.js', () => ({
+ executeMultipleUpdates: mocks.executeMultipleUpdates,
+ executeUpdate: vi.fn(), rollbackUpdate: vi.fn(), getUpdateHistory: vi.fn(), clearHistory: vi.fn(),
+}));
+
+import { CommandParser } from '../src/parser.js';
+import updateCommand from '../src/commands/update.js';
+
+afterEach(() => {
+ vi.clearAllMocks();
+});
+
+async function runAll(flags: string[]): Promise<unknown> {
+ const parser = new CommandParser();
+ parser.registerCommand(updateCommand);
+ const parsed = parser.parse(['update', 'all', ...flags]);
+ const all = updateCommand.subcommands!.find((command) => command.name === 'all')!;
+ await all.action!({ args: [], flags: parsed.flags, cwd: process.cwd(), interactive: false });
+ expect(mocks.executeMultipleUpdates).toHaveBeenCalledTimes(1);
+ return mocks.executeMultipleUpdates.mock.calls[0][2];
+}
+
+describe('update all --dry-run through the real command parser', () => {
+ it('runs the updates as a dry run', async () => {
+ expect(await runAll(['--dry-run'])).toBe(true);
+ });
+
+ it('still installs without the flag', async () => {
+ expect(await runAll([])).toBeFalsy();
+ });
+});
diff --git a/v3/@claude-flow/cli/src/commands/update.ts b/v3/@claude-flow/cli/src/commands/update.ts
index 4271e136b5..8b110581b4 100644
--- a/v3/@claude-flow/cli/src/commands/update.ts
+++ b/v3/@claude-flow/cli/src/commands/update.ts
@@ -140,6 +140,8 @@ const allCommand: Command = {
],
async action(ctx: CommandContext): Promise<CommandResult> {
const { flags } = ctx;
+ // The parser stores `--dry-run` as `dryRun`.
+ const dryRun = flags.dryRun === true || flags['dry-run'] === true;
process.env.CLAUDE_FLOW_FORCE_UPDATE = 'true';
try {
@@ -175,19 +177,19 @@ const allCommand: Command = {
const updateResults = await executeMultipleUpdates(
results,
installedPackages,
- flags['dry-run'] as boolean
+ dryRun
);
const successful = updateResults.filter((r) => r.success);
const failed = updateResults.filter((r) => !r.success);
output.writeln();
- output.writeln(output.highlight(flags['dry-run'] ? '═══ Dry Run - Would Update ═══' : '═══ Update Results ═══'));
+ output.writeln(output.highlight(dryRun ? '═══ Dry Run - Would Update ═══' : '═══ Update Results ═══'));
output.writeln();
if (successful.length > 0) {
output.printSuccess(
- `${successful.length} package(s) ${flags['dry-run'] ? 'would be ' : ''}updated:`
+ `${successful.length} package(s) ${dryRun ? 'would be ' : ''}updated:`
);
for (const r of successful) {
output.writeln(` ${output.success('βœ“')} ${r.package}@${r.version}`);