Skip to content

Commit ee957ce

Browse files
committed
refactor: address round 4 review comments
1. Remove isCommandOutput helper — inline instanceof check directly in handleYieldedValue. Reviewer: "Don't think we need this helper?" 2. Remove onPolling callback from DeviceFlowCallbacks in oauth.ts — reviewer: "We should also remove this from performDeviceFlow then?" The spinner in interactive-login.ts handles visual feedback now. 3. Convert 11 "yield new CommandOutput(..); return;" patterns to "return yield new CommandOutput(..)" one-liners across 9 files. Note: outputConfig remains optional — 3 commands (auth/token, cli/setup, init) legitimately don't define output configs.
1 parent b08a507 commit ee957ce

File tree

11 files changed

+14
-37
lines changed

11 files changed

+14
-37
lines changed

src/commands/api.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,7 +1210,6 @@ export const apiCommand = buildCommand({
12101210
throw new OutputError(response.body);
12111211
}
12121212

1213-
yield new CommandOutput(response.body);
1214-
return;
1213+
return yield new CommandOutput(response.body);
12151214
},
12161215
});

src/commands/auth/login.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,7 @@ export const loginCommand = buildCommand({
182182
// Non-fatal: user info is supplementary. Token remains stored and valid.
183183
}
184184

185-
yield new CommandOutput(result);
186-
return;
185+
return yield new CommandOutput(result);
187186
}
188187

189188
// OAuth device flow

src/commands/auth/refresh.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ Examples:
105105
: undefined,
106106
};
107107

108-
yield new CommandOutput(payload);
109-
return;
108+
return yield new CommandOutput(payload);
110109
},
111110
});

src/commands/auth/status.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,6 @@ export const statusCommand = buildCommand({
190190
verification: await verifyCredentials(),
191191
};
192192

193-
yield new CommandOutput(data);
194-
return;
193+
return yield new CommandOutput(data);
195194
},
196195
});

src/commands/auth/whoami.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ export const whoamiCommand = buildCommand({
6565
// Cache update failure is non-essential — user identity was already fetched.
6666
}
6767

68-
yield new CommandOutput(user);
69-
return;
68+
return yield new CommandOutput(user);
7069
},
7170
});

src/commands/cli/fix.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,6 @@ export const fixCommand = buildCommand({
735735
throw new OutputError(result);
736736
}
737737

738-
yield new CommandOutput(result);
739-
return;
738+
return yield new CommandOutput(result);
740739
},
741740
});

src/commands/cli/upgrade.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -494,8 +494,7 @@ export const upgradeCommand = buildCommand({
494494
flags,
495495
});
496496
if (resolved.kind === "done") {
497-
yield new CommandOutput(resolved.result);
498-
return;
497+
return yield new CommandOutput(resolved.result);
499498
}
500499

501500
const { target } = resolved;

src/commands/issue/plan.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,7 @@ export const planCommand = buildCommand({
225225
if (!flags.force) {
226226
const existingSolution = extractSolution(state);
227227
if (existingSolution) {
228-
yield new CommandOutput(buildPlanData(state));
229-
return;
228+
return yield new CommandOutput(buildPlanData(state));
230229
}
231230
}
232231

@@ -261,8 +260,7 @@ export const planCommand = buildCommand({
261260
throw new Error("Plan creation was cancelled.");
262261
}
263262

264-
yield new CommandOutput(buildPlanData(finalState));
265-
return;
263+
return yield new CommandOutput(buildPlanData(finalState));
266264
} catch (error) {
267265
// Handle API errors with friendly messages
268266
if (error instanceof ApiError) {

src/commands/project/create.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -405,8 +405,7 @@ export const createCommand = buildCommand({
405405
expectedSlug,
406406
dryRun: true,
407407
};
408-
yield new CommandOutput(result);
409-
return;
408+
return yield new CommandOutput(result);
410409
}
411410

412411
// Create the project
@@ -433,7 +432,6 @@ export const createCommand = buildCommand({
433432
expectedSlug,
434433
};
435434

436-
yield new CommandOutput(result);
437-
return;
435+
return yield new CommandOutput(result);
438436
},
439437
});

src/lib/command.ts

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -307,13 +307,9 @@ export function buildCommand<
307307

308308
const mergedParams = { ...existingParams, flags: mergedFlags };
309309

310-
function isCommandOutput(v: unknown): v is CommandOutput<unknown> {
311-
return v instanceof CommandOutput;
312-
}
313-
314310
/**
315-
* If the yielded value is a branded {@link CommandOutput}, render it via
316-
* the output config. Void/undefined/Error/non-branded values are ignored.
311+
* If the yielded value is a {@link CommandOutput}, render it via
312+
* the output config. Void/undefined/Error/other values are ignored.
317313
*/
318314
function handleYieldedValue(
319315
stdout: Writer,
@@ -322,13 +318,7 @@ export function buildCommand<
322318
// biome-ignore lint/suspicious/noExplicitAny: Renderer type mirrors erased OutputConfig<T>
323319
renderer?: HumanRenderer<any>
324320
): void {
325-
if (
326-
!(outputConfig && renderer) ||
327-
value === null ||
328-
value === undefined ||
329-
value instanceof Error ||
330-
!isCommandOutput(value)
331-
) {
321+
if (!(outputConfig && renderer && value instanceof CommandOutput)) {
332322
return;
333323
}
334324

0 commit comments

Comments
 (0)