Skip to content

Commit 1157731

Browse files
authored
Fix misleading typing for options.json. (#9275)
1 parent 9604c4b commit 1157731

39 files changed

+82
-173
lines changed

firebase-vscode/src/options.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ const defaultOptions: Readonly<VsCodeOptions> = {
2626
projectNumber: "",
2727
projectRoot: "",
2828
account: "",
29-
json: true,
3029
nonInteractive: true,
3130
interactive: false,
3231
debug: false,

src/checkValidTargetFilters.spec.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ const SAMPLE_OPTIONS: Options = {
1313
only: "",
1414
except: "",
1515
nonInteractive: false,
16-
json: false,
1716
interactive: false,
1817
debug: false,
1918
force: false,

src/command.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,7 @@ export class Command {
313313
}
314314

315315
if (getInheritedOption(options, "json")) {
316+
options.interactive = false;
316317
options.nonInteractive = true;
317318
} else if (!options.isMCP) {
318319
useConsoleLoggers();

src/commands/firestore-backups-delete.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,7 @@ export const command = new Command("firestore:backups:delete <backup>")
3434
throw new FirebaseError(`Failed to delete the backup ${backupName}`, { original: err });
3535
}
3636

37-
if (options.json) {
38-
logger.info(JSON.stringify(backup, undefined, 2));
39-
} else {
40-
logger.info(clc.bold(`Successfully deleted ${clc.yellow(backupName)}`));
41-
}
37+
logger.info(clc.bold(`Successfully deleted ${clc.yellow(backupName)}`));
4238

4339
return backup;
4440
});
Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,19 @@
11
import { Command } from "../command";
2-
import { logger } from "../logger";
32
import { requirePermissions } from "../requirePermissions";
43
import { Emulators } from "../emulator/types";
54
import { warnEmulatorNotSupported } from "../emulator/commandUtils";
6-
import { FirestoreOptions } from "../firestore/options";
75
import { Backup, getBackup } from "../gcp/firestore";
86
import { PrettyPrint } from "../firestore/pretty-print";
97

108
export const command = new Command("firestore:backups:get <backup>")
119
.description("get a Cloud Firestore database backup")
1210
.before(requirePermissions, ["datastore.backups.get"])
1311
.before(warnEmulatorNotSupported, Emulators.FIRESTORE)
14-
.action(async (backupName: string, options: FirestoreOptions) => {
12+
.action(async (backupName: string) => {
1513
const backup: Backup = await getBackup(backupName);
1614
const printer = new PrettyPrint();
1715

18-
if (options.json) {
19-
logger.info(JSON.stringify(backup, undefined, 2));
20-
} else {
21-
printer.prettyPrintBackup(backup);
22-
}
16+
printer.prettyPrintBackup(backup);
2317

2418
return backup;
2519
});

src/commands/firestore-backups-list.ts

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { Command } from "../command";
2-
import { logger } from "../logger";
32
import { requirePermissions } from "../requirePermissions";
43
import { Emulators } from "../emulator/types";
54
import { warnEmulatorNotSupported } from "../emulator/commandUtils";
@@ -23,17 +22,15 @@ export const command = new Command("firestore:backups:list")
2322
const listBackupsResponse: ListBackupsResponse = await listBackups(options.project, location);
2423
const backups: Backup[] = listBackupsResponse.backups || [];
2524

26-
if (options.json) {
27-
logger.info(JSON.stringify(listBackupsResponse, undefined, 2));
28-
} else {
29-
printer.prettyPrintBackups(backups);
30-
if (listBackupsResponse.unreachable && listBackupsResponse.unreachable.length > 0) {
31-
logWarning(
32-
"We were not able to reach the following locations: " +
33-
listBackupsResponse.unreachable.join(", "),
34-
);
35-
}
25+
printer.prettyPrintBackups(backups);
26+
if (listBackupsResponse.unreachable && listBackupsResponse.unreachable.length > 0) {
27+
logWarning(
28+
"We were not able to reach the following locations: " +
29+
listBackupsResponse.unreachable.join(", "),
30+
);
3631
}
3732

33+
// TODO: Consider returning listBackupResponse instead for --json. This will
34+
// be a breaking change but exposes .unreachable, not just .backups.
3835
return backups;
3936
});

src/commands/firestore-backups-schedules-create.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,9 @@ export const command = new Command("firestore:backups:schedules:create")
8181
weeklyRecurrence,
8282
);
8383

84-
if (options.json) {
85-
logger.info(JSON.stringify(backupSchedule, undefined, 2));
86-
} else {
87-
logger.info(
88-
clc.bold(`Successfully created ${printer.prettyBackupScheduleString(backupSchedule)}`),
89-
);
90-
}
84+
logger.info(
85+
clc.bold(`Successfully created ${printer.prettyBackupScheduleString(backupSchedule)}`),
86+
);
9187

9288
return backupSchedule;
9389
});

src/commands/firestore-backups-schedules-delete.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,7 @@ export const command = new Command("firestore:backups:schedules:delete <backupSc
3636
});
3737
}
3838

39-
if (options.json) {
40-
logger.info(JSON.stringify(backupSchedule, undefined, 2));
41-
} else {
42-
logger.info(clc.bold(`Successfully deleted ${clc.yellow(backupScheduleName)}`));
43-
}
39+
logger.info(clc.bold(`Successfully deleted ${clc.yellow(backupScheduleName)}`));
4440

4541
return backupSchedule;
4642
});

src/commands/firestore-backups-schedules-list.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { Command } from "../command";
2-
import { logger } from "../logger";
32
import { requirePermissions } from "../requirePermissions";
43
import { Emulators } from "../emulator/types";
54
import { warnEmulatorNotSupported } from "../emulator/commandUtils";
@@ -24,11 +23,7 @@ export const command = new Command("firestore:backups:schedules:list")
2423
databaseId,
2524
);
2625

27-
if (options.json) {
28-
logger.info(JSON.stringify(backupSchedules, undefined, 2));
29-
} else {
30-
printer.prettyPrintBackupSchedules(backupSchedules, databaseId);
31-
}
26+
printer.prettyPrintBackupSchedules(backupSchedules, databaseId);
3227

3328
return backupSchedules;
3429
});

src/commands/firestore-backups-schedules-update.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,9 @@ export const command = new Command("firestore:backups:schedules:update <backupSc
3030
retention,
3131
);
3232

33-
if (options.json) {
34-
logger.info(JSON.stringify(backupSchedule, undefined, 2));
35-
} else {
36-
logger.info(
37-
clc.bold(`Successfully updated ${printer.prettyBackupScheduleString(backupSchedule)}`),
38-
);
39-
}
33+
logger.info(
34+
clc.bold(`Successfully updated ${printer.prettyBackupScheduleString(backupSchedule)}`),
35+
);
4036

4137
return backupSchedule;
4238
});

0 commit comments

Comments
 (0)