Skip to content

Commit aff1b8f

Browse files
committed
Print message to view Firestore database in console after creation or restore
1 parent fa659a7 commit aff1b8f

File tree

4 files changed

+15
-0
lines changed

4 files changed

+15
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Add Firebase console link after creating or restoring a Firestore database (#6949)

src/commands/firestore-databases-create.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ export const command = new Command("firestore:databases:create <database>")
8585
"the new database. By default, created databases will have closed rules that\n" +
8686
"block any incoming third-party traffic.",
8787
);
88+
logger.info(
89+
`Your database may be viewed at ${printer.firebaseConsoleDatabaseUrl(options.project, database)}`,
90+
);
8891
}
8992

9093
return databaseResp;

src/commands/firestore-databases-restore.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ export const command = new Command("firestore:databases:restore")
5353
"the new database. By default, created databases will have closed rules that\n" +
5454
"block any incoming third-party traffic.",
5555
);
56+
logger.info(
57+
`Once the restore is complete, your database may be viewed at ${printer.firebaseConsoleDatabaseUrl(options.project, databaseId)}`,
58+
);
5659
}
5760

5861
return databaseResp;

src/firestore/pretty-print.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import * as sort from "./api-sort";
55
import * as types from "./api-types";
66
import { logger } from "../logger";
77
import * as util from "./util";
8+
import { consoleUrl } from "../utils";
89
import { Backup, BackupSchedule } from "../gcp/firestore";
910

1011
export class PrettyPrint {
@@ -274,6 +275,13 @@ export class PrettyPrint {
274275
return clc.yellow(typeof database === "string" ? database : database.name);
275276
}
276277

278+
/**
279+
* Get a URL to view a given Firestore database in the Firebase console
280+
*/
281+
firebaseConsoleDatabaseUrl(project: string, databaseId: string): string {
282+
return consoleUrl(project, `/firestore/databases/${databaseId}/data`);
283+
}
284+
277285
/**
278286
* Get a colored, pretty-printed representation of a field
279287
*/

0 commit comments

Comments
 (0)