firebase-tools-with-isolate 13.0.2 → 13.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -2
- package/lib/appdistribution/client.js +36 -28
- package/lib/appdistribution/options-parser-util.js +80 -1
- package/lib/appdistribution/types.js +31 -0
- package/lib/auth.js +11 -2
- package/lib/commands/appdistribution-distribute.js +70 -10
- package/lib/commands/apphosting-backends-create.js +6 -3
- package/lib/commands/apphosting-backends-delete.js +3 -5
- package/lib/commands/apphosting-backends-get.js +2 -2
- package/lib/commands/apphosting-backends-list.js +21 -37
- package/lib/commands/apphosting-builds-create.js +8 -8
- package/lib/commands/apphosting-builds-get.js +2 -2
- package/lib/commands/apphosting-rollouts-create.js +5 -5
- package/lib/commands/apphosting-rollouts-list.js +6 -3
- package/lib/commands/firestore-backups-delete.js +44 -0
- package/lib/commands/firestore-backups-get.js +25 -0
- package/lib/commands/firestore-backups-list.js +33 -0
- package/lib/commands/firestore-backups-schedules-create.js +67 -0
- package/lib/commands/firestore-backups-schedules-delete.js +46 -0
- package/lib/commands/firestore-backups-schedules-list.js +27 -0
- package/lib/commands/firestore-backups-schedules-update.js +33 -0
- package/lib/commands/firestore-databases-create.js +4 -2
- package/lib/commands/firestore-databases-delete.js +4 -2
- package/lib/commands/firestore-databases-get.js +3 -1
- package/lib/commands/firestore-databases-list.js +3 -1
- package/lib/commands/firestore-databases-restore.js +42 -0
- package/lib/commands/firestore-databases-update.js +4 -2
- package/lib/commands/firestore-indexes-list.js +5 -3
- package/lib/commands/firestore-locations.js +3 -1
- package/lib/commands/functions-config-export.js +4 -2
- package/lib/commands/index.js +11 -1
- package/lib/commands/init.js +3 -3
- package/lib/commands/use.js +4 -1
- package/lib/deploy/functions/runtimes/index.js +2 -0
- package/lib/deploy/functions/runtimes/python/index.js +4 -1
- package/lib/deploy/functions/services/firestore.js +1 -1
- package/lib/deploy/hosting/convertConfig.js +5 -0
- package/lib/deploy/hosting/prepare.js +2 -1
- package/lib/emulator/auth/handlers.js +1 -1
- package/lib/emulator/auth/operations.js +42 -13
- package/lib/emulator/auth/state.js +14 -0
- package/lib/emulator/downloadableEmulators.js +3 -3
- package/lib/emulator/storage/metadata.js +1 -1
- package/lib/emulator/storage/rules/runtime.js +1 -1
- package/lib/experiments.js +2 -2
- package/lib/firestore/api-sort.js +23 -1
- package/lib/firestore/api-types.js +6 -1
- package/lib/firestore/api.js +18 -115
- package/lib/firestore/backupUtils.js +30 -0
- package/lib/firestore/delete.js +3 -3
- package/lib/firestore/pretty-print.js +184 -0
- package/lib/frameworks/angular/index.js +2 -2
- package/lib/frameworks/angular/utils.js +14 -10
- package/lib/frameworks/astro/index.js +1 -2
- package/lib/frameworks/flutter/index.js +1 -1
- package/lib/frameworks/index.js +2 -3
- package/lib/frameworks/next/index.js +5 -3
- package/lib/frameworks/nuxt/index.js +2 -2
- package/lib/frameworks/nuxt2/index.js +1 -2
- package/lib/frameworks/sveltekit/index.js +2 -2
- package/lib/frameworks/utils.js +11 -2
- package/lib/frameworks/vite/index.js +8 -4
- package/lib/functions/env.js +2 -0
- package/lib/gcp/apphosting.js +103 -17
- package/lib/gcp/cloudbuild.js +7 -2
- package/lib/gcp/cloudfunctionsv2.js +2 -4
- package/lib/gcp/firestore.js +89 -6
- package/lib/hosting/api.js +3 -9
- package/lib/hosting/options.js +2 -1
- package/lib/init/features/apphosting/index.js +150 -68
- package/lib/init/features/apphosting/repo.js +80 -32
- package/lib/init/features/hosting/github.js +6 -1
- package/lib/metaprogramming.js +3 -0
- package/lib/prompt.js +1 -0
- package/lib/utils.js +1 -12
- package/package.json +15 -10
|
@@ -5,16 +5,16 @@ const apphosting = require("../gcp/apphosting");
|
|
|
5
5
|
const logger_1 = require("../logger");
|
|
6
6
|
const command_1 = require("../command");
|
|
7
7
|
const projectUtils_1 = require("../projectUtils");
|
|
8
|
-
const utils_1 = require("../utils");
|
|
9
8
|
exports.command = new command_1.Command("apphosting:rollouts:create <backendId> <buildId>")
|
|
10
|
-
.description("
|
|
11
|
-
.option("-l, --location <location>", "
|
|
12
|
-
.option("-i, --id <rolloutId>", "
|
|
9
|
+
.description("create a rollout using a build for an App Hosting backend")
|
|
10
|
+
.option("-l, --location <location>", "specify the region of the backend", "us-central1")
|
|
11
|
+
.option("-i, --id <rolloutId>", "id of the rollout (defaults to autogenerating a random id)", "")
|
|
13
12
|
.before(apphosting.ensureApiEnabled)
|
|
14
13
|
.action(async (backendId, buildId, options) => {
|
|
15
14
|
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
16
15
|
const location = options.location;
|
|
17
|
-
const rolloutId = options.buildId ||
|
|
16
|
+
const rolloutId = options.buildId ||
|
|
17
|
+
(await apphosting.getNextRolloutId(projectId, location, backendId));
|
|
18
18
|
const build = `projects/${projectId}/backends/${backendId}/builds/${buildId}`;
|
|
19
19
|
const op = await apphosting.createRollout(projectId, location, backendId, rolloutId, {
|
|
20
20
|
build,
|
|
@@ -6,13 +6,16 @@ const logger_1 = require("../logger");
|
|
|
6
6
|
const command_1 = require("../command");
|
|
7
7
|
const projectUtils_1 = require("../projectUtils");
|
|
8
8
|
exports.command = new command_1.Command("apphosting:rollouts:list <backendId>")
|
|
9
|
-
.description("
|
|
10
|
-
.option("-l, --location <location>", "
|
|
9
|
+
.description("list rollouts of an App Hosting backend")
|
|
10
|
+
.option("-l, --location <location>", "region of the rollouts (defaults to listing rollouts from all regions)", "-")
|
|
11
11
|
.before(apphosting.ensureApiEnabled)
|
|
12
12
|
.action(async (backendId, options) => {
|
|
13
13
|
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
14
14
|
const location = options.location;
|
|
15
15
|
const rollouts = await apphosting.listRollouts(projectId, location, backendId);
|
|
16
|
-
|
|
16
|
+
if (rollouts.unreachable) {
|
|
17
|
+
logger_1.logger.error(`WARNING: the following locations were unreachable: ${rollouts.unreachable.join(", ")}`);
|
|
18
|
+
}
|
|
19
|
+
logger_1.logger.info(JSON.stringify(rollouts.rollouts, null, 2));
|
|
17
20
|
return rollouts;
|
|
18
21
|
});
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.command = void 0;
|
|
4
|
+
const command_1 = require("../command");
|
|
5
|
+
const firestore_1 = require("../gcp/firestore");
|
|
6
|
+
const prompt_1 = require("../prompt");
|
|
7
|
+
const clc = require("colorette");
|
|
8
|
+
const logger_1 = require("../logger");
|
|
9
|
+
const requirePermissions_1 = require("../requirePermissions");
|
|
10
|
+
const types_1 = require("../emulator/types");
|
|
11
|
+
const commandUtils_1 = require("../emulator/commandUtils");
|
|
12
|
+
const error_1 = require("../error");
|
|
13
|
+
exports.command = new command_1.Command("firestore:backups:delete <backup>")
|
|
14
|
+
.description("Delete a backup under your Cloud Firestore database.")
|
|
15
|
+
.option("--force", "Attempt to delete backup without prompting for confirmation.")
|
|
16
|
+
.before(requirePermissions_1.requirePermissions, ["datastore.backups.delete"])
|
|
17
|
+
.before(commandUtils_1.warnEmulatorNotSupported, types_1.Emulators.FIRESTORE)
|
|
18
|
+
.action(async (backupName, options) => {
|
|
19
|
+
const backup = await (0, firestore_1.getBackup)(backupName);
|
|
20
|
+
if (!options.force) {
|
|
21
|
+
const confirmMessage = `You are about to delete ${backupName}. Do you wish to continue?`;
|
|
22
|
+
const consent = await (0, prompt_1.promptOnce)({
|
|
23
|
+
type: "confirm",
|
|
24
|
+
message: confirmMessage,
|
|
25
|
+
default: false,
|
|
26
|
+
});
|
|
27
|
+
if (!consent) {
|
|
28
|
+
throw new error_1.FirebaseError("Delete backup canceled.");
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
try {
|
|
32
|
+
await (0, firestore_1.deleteBackup)(backupName);
|
|
33
|
+
}
|
|
34
|
+
catch (err) {
|
|
35
|
+
throw new error_1.FirebaseError(`Failed to delete the backup ${backupName}`, { original: err });
|
|
36
|
+
}
|
|
37
|
+
if (options.json) {
|
|
38
|
+
logger_1.logger.info(JSON.stringify(backup, undefined, 2));
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
logger_1.logger.info(clc.bold(`Successfully deleted ${clc.yellow(backupName)}`));
|
|
42
|
+
}
|
|
43
|
+
return backup;
|
|
44
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.command = void 0;
|
|
4
|
+
const command_1 = require("../command");
|
|
5
|
+
const logger_1 = require("../logger");
|
|
6
|
+
const requirePermissions_1 = require("../requirePermissions");
|
|
7
|
+
const types_1 = require("../emulator/types");
|
|
8
|
+
const commandUtils_1 = require("../emulator/commandUtils");
|
|
9
|
+
const firestore_1 = require("../gcp/firestore");
|
|
10
|
+
const pretty_print_1 = require("../firestore/pretty-print");
|
|
11
|
+
exports.command = new command_1.Command("firestore:backups:get <backup>")
|
|
12
|
+
.description("Get a Cloud Firestore database backup.")
|
|
13
|
+
.before(requirePermissions_1.requirePermissions, ["datastore.backups.get"])
|
|
14
|
+
.before(commandUtils_1.warnEmulatorNotSupported, types_1.Emulators.FIRESTORE)
|
|
15
|
+
.action(async (backupName, options) => {
|
|
16
|
+
const backup = await (0, firestore_1.getBackup)(backupName);
|
|
17
|
+
const printer = new pretty_print_1.PrettyPrint();
|
|
18
|
+
if (options.json) {
|
|
19
|
+
logger_1.logger.info(JSON.stringify(backup, undefined, 2));
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
printer.prettyPrintBackup(backup);
|
|
23
|
+
}
|
|
24
|
+
return backup;
|
|
25
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.command = void 0;
|
|
4
|
+
const command_1 = require("../command");
|
|
5
|
+
const logger_1 = require("../logger");
|
|
6
|
+
const requirePermissions_1 = require("../requirePermissions");
|
|
7
|
+
const types_1 = require("../emulator/types");
|
|
8
|
+
const commandUtils_1 = require("../emulator/commandUtils");
|
|
9
|
+
const firestore_1 = require("../gcp/firestore");
|
|
10
|
+
const utils_1 = require("../utils");
|
|
11
|
+
const pretty_print_1 = require("../firestore/pretty-print");
|
|
12
|
+
exports.command = new command_1.Command("firestore:backups:list")
|
|
13
|
+
.description("List all Cloud Firestore backups in a given location")
|
|
14
|
+
.option("-l, --location <locationId>", "Location to search for backups, for example 'nam5'. Run 'firebase firestore:locations' to get a list of eligible locations. Defaults to all locations.")
|
|
15
|
+
.before(requirePermissions_1.requirePermissions, ["datastore.backups.list"])
|
|
16
|
+
.before(commandUtils_1.warnEmulatorNotSupported, types_1.Emulators.FIRESTORE)
|
|
17
|
+
.action(async (options) => {
|
|
18
|
+
const printer = new pretty_print_1.PrettyPrint();
|
|
19
|
+
const location = options.location ?? "-";
|
|
20
|
+
const listBackupsResponse = await (0, firestore_1.listBackups)(options.project, location);
|
|
21
|
+
const backups = listBackupsResponse.backups || [];
|
|
22
|
+
if (options.json) {
|
|
23
|
+
logger_1.logger.info(JSON.stringify(listBackupsResponse, undefined, 2));
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
printer.prettyPrintBackups(backups);
|
|
27
|
+
if (listBackupsResponse.unreachable && listBackupsResponse.unreachable.length > 0) {
|
|
28
|
+
(0, utils_1.logWarning)("We were not able to reach the following locations: " +
|
|
29
|
+
listBackupsResponse.unreachable.join(", "));
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return backups;
|
|
33
|
+
});
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.command = void 0;
|
|
4
|
+
const clc = require("colorette");
|
|
5
|
+
const command_1 = require("../command");
|
|
6
|
+
const backupUtils_1 = require("../firestore/backupUtils");
|
|
7
|
+
const firestore_1 = require("../gcp/firestore");
|
|
8
|
+
const types = require("../firestore/api-types");
|
|
9
|
+
const logger_1 = require("../logger");
|
|
10
|
+
const requirePermissions_1 = require("../requirePermissions");
|
|
11
|
+
const types_1 = require("../emulator/types");
|
|
12
|
+
const commandUtils_1 = require("../emulator/commandUtils");
|
|
13
|
+
const pretty_print_1 = require("../firestore/pretty-print");
|
|
14
|
+
exports.command = new command_1.Command("firestore:backups:schedules:create")
|
|
15
|
+
.description("Create a backup schedule under your Cloud Firestore database.")
|
|
16
|
+
.option("-db, --database <databaseId>", "Database under which you want to create a schedule. Defaults to the (default) database")
|
|
17
|
+
.option("-rt, --retention <duration>", "duration string (e.g. 12h or 30d) for backup retention")
|
|
18
|
+
.option("-rc, --recurrence <recurrence>", "Recurrence settings; either DAILY or WEEKLY")
|
|
19
|
+
.option("-dw, --day-of-week <dayOfWeek>", "On which day of the week to perform backups; one of MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, or SUNDAY")
|
|
20
|
+
.before(requirePermissions_1.requirePermissions, ["datastore.backupSchedules.create"])
|
|
21
|
+
.before(commandUtils_1.warnEmulatorNotSupported, types_1.Emulators.FIRESTORE)
|
|
22
|
+
.action(async (options) => {
|
|
23
|
+
const printer = new pretty_print_1.PrettyPrint();
|
|
24
|
+
const databaseId = options.database || "(default)";
|
|
25
|
+
if (!options.retention) {
|
|
26
|
+
logger_1.logger.error("Missing required flag --retention. See firebase firestore:backups:schedules:create --help for more info");
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const retention = (0, backupUtils_1.calculateRetention)(options.retention);
|
|
30
|
+
if (!options.recurrence) {
|
|
31
|
+
logger_1.logger.error("Missing required flag --recurrence. See firebase firestore:backups:schedules:create --help for more info");
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
const recurrenceType = options.recurrence;
|
|
35
|
+
if (recurrenceType !== types.RecurrenceType.DAILY &&
|
|
36
|
+
recurrenceType !== types.RecurrenceType.WEEKLY) {
|
|
37
|
+
logger_1.logger.error("Invalid value for flag --recurrence. See firebase firestore:backups:schedules:create --help for more info");
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
let dailyRecurrence;
|
|
41
|
+
let weeklyRecurrence;
|
|
42
|
+
if (options.recurrence === types.RecurrenceType.DAILY) {
|
|
43
|
+
dailyRecurrence = {};
|
|
44
|
+
if (options.dayOfWeek) {
|
|
45
|
+
logger_1.logger.error("--day-of-week should not be provided if --recurrence is DAILY");
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
else if (options.recurrence === types.RecurrenceType.WEEKLY) {
|
|
50
|
+
if (!options.dayOfWeek) {
|
|
51
|
+
logger_1.logger.error("If --recurrence is WEEKLY, --day-of-week must be provided. See firebase firestore:backups:schedules:create --help for more info");
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const day = options.dayOfWeek;
|
|
55
|
+
weeklyRecurrence = {
|
|
56
|
+
day,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
const backupSchedule = await (0, firestore_1.createBackupSchedule)(options.project, databaseId, retention, dailyRecurrence, weeklyRecurrence);
|
|
60
|
+
if (options.json) {
|
|
61
|
+
logger_1.logger.info(JSON.stringify(backupSchedule, undefined, 2));
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
logger_1.logger.info(clc.bold(`Successfully created ${printer.prettyBackupScheduleString(backupSchedule)}`));
|
|
65
|
+
}
|
|
66
|
+
return backupSchedule;
|
|
67
|
+
});
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.command = void 0;
|
|
4
|
+
const command_1 = require("../command");
|
|
5
|
+
const firestore_1 = require("../gcp/firestore");
|
|
6
|
+
const prompt_1 = require("../prompt");
|
|
7
|
+
const clc = require("colorette");
|
|
8
|
+
const logger_1 = require("../logger");
|
|
9
|
+
const requirePermissions_1 = require("../requirePermissions");
|
|
10
|
+
const types_1 = require("../emulator/types");
|
|
11
|
+
const commandUtils_1 = require("../emulator/commandUtils");
|
|
12
|
+
const error_1 = require("../error");
|
|
13
|
+
exports.command = new command_1.Command("firestore:backups:schedules:delete <backupSchedule>")
|
|
14
|
+
.description("Delete a backup schedule under your Cloud Firestore database.")
|
|
15
|
+
.option("--force", "Attempt to delete backup schedule without prompting for confirmation.")
|
|
16
|
+
.before(requirePermissions_1.requirePermissions, ["datastore.backupSchedules.delete"])
|
|
17
|
+
.before(commandUtils_1.warnEmulatorNotSupported, types_1.Emulators.FIRESTORE)
|
|
18
|
+
.action(async (backupScheduleName, options) => {
|
|
19
|
+
const backupSchedule = await (0, firestore_1.getBackupSchedule)(backupScheduleName);
|
|
20
|
+
if (!options.force) {
|
|
21
|
+
const confirmMessage = `You are about to delete ${backupScheduleName}. Do you wish to continue?`;
|
|
22
|
+
const consent = await (0, prompt_1.promptOnce)({
|
|
23
|
+
type: "confirm",
|
|
24
|
+
message: confirmMessage,
|
|
25
|
+
default: false,
|
|
26
|
+
});
|
|
27
|
+
if (!consent) {
|
|
28
|
+
throw new error_1.FirebaseError("Delete backup schedule canceled.");
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
try {
|
|
32
|
+
await (0, firestore_1.deleteBackupSchedule)(backupScheduleName);
|
|
33
|
+
}
|
|
34
|
+
catch (err) {
|
|
35
|
+
throw new error_1.FirebaseError(`Failed to delete the backup schedule ${backupScheduleName}`, {
|
|
36
|
+
original: err,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
if (options.json) {
|
|
40
|
+
logger_1.logger.info(JSON.stringify(backupSchedule, undefined, 2));
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
logger_1.logger.info(clc.bold(`Successfully deleted ${clc.yellow(backupScheduleName)}`));
|
|
44
|
+
}
|
|
45
|
+
return backupSchedule;
|
|
46
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.command = void 0;
|
|
4
|
+
const command_1 = require("../command");
|
|
5
|
+
const logger_1 = require("../logger");
|
|
6
|
+
const requirePermissions_1 = require("../requirePermissions");
|
|
7
|
+
const types_1 = require("../emulator/types");
|
|
8
|
+
const commandUtils_1 = require("../emulator/commandUtils");
|
|
9
|
+
const firestore_1 = require("../gcp/firestore");
|
|
10
|
+
const pretty_print_1 = require("../firestore/pretty-print");
|
|
11
|
+
exports.command = new command_1.Command("firestore:backups:schedules:list")
|
|
12
|
+
.description("List backup schedules under your Cloud Firestore database.")
|
|
13
|
+
.option("-db, --database <databaseId>", "Database whose schedules you wish to list. Defaults to the (default) database.")
|
|
14
|
+
.before(requirePermissions_1.requirePermissions, ["datastore.backupSchedules.list"])
|
|
15
|
+
.before(commandUtils_1.warnEmulatorNotSupported, types_1.Emulators.FIRESTORE)
|
|
16
|
+
.action(async (options) => {
|
|
17
|
+
const printer = new pretty_print_1.PrettyPrint();
|
|
18
|
+
const databaseId = options.database ?? "(default)";
|
|
19
|
+
const backupSchedules = await (0, firestore_1.listBackupSchedules)(options.project, databaseId);
|
|
20
|
+
if (options.json) {
|
|
21
|
+
logger_1.logger.info(JSON.stringify(backupSchedules, undefined, 2));
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
printer.prettyPrintBackupSchedules(backupSchedules, databaseId);
|
|
25
|
+
}
|
|
26
|
+
return backupSchedules;
|
|
27
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.command = void 0;
|
|
4
|
+
const clc = require("colorette");
|
|
5
|
+
const command_1 = require("../command");
|
|
6
|
+
const backupUtils_1 = require("../firestore/backupUtils");
|
|
7
|
+
const firestore_1 = require("../gcp/firestore");
|
|
8
|
+
const logger_1 = require("../logger");
|
|
9
|
+
const requirePermissions_1 = require("../requirePermissions");
|
|
10
|
+
const types_1 = require("../emulator/types");
|
|
11
|
+
const commandUtils_1 = require("../emulator/commandUtils");
|
|
12
|
+
const pretty_print_1 = require("../firestore/pretty-print");
|
|
13
|
+
exports.command = new command_1.Command("firestore:backups:schedules:update <backupSchedule>")
|
|
14
|
+
.description("Update a backup schedule under your Cloud Firestore database.")
|
|
15
|
+
.option("-rt, --retention <duration>", "duration string (e.g. 12h or 30d) for backup retention")
|
|
16
|
+
.before(requirePermissions_1.requirePermissions, ["datastore.backupSchedules.update"])
|
|
17
|
+
.before(commandUtils_1.warnEmulatorNotSupported, types_1.Emulators.FIRESTORE)
|
|
18
|
+
.action(async (backupScheduleName, options) => {
|
|
19
|
+
const printer = new pretty_print_1.PrettyPrint();
|
|
20
|
+
if (!options.retention) {
|
|
21
|
+
logger_1.logger.error("Missing required flag --retention. See firebase firestore:backups:schedules:update --help for more info");
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
const retention = (0, backupUtils_1.calculateRetention)(options.retention);
|
|
25
|
+
const backupSchedule = await (0, firestore_1.updateBackupSchedule)(backupScheduleName, retention);
|
|
26
|
+
if (options.json) {
|
|
27
|
+
logger_1.logger.info(JSON.stringify(backupSchedule, undefined, 2));
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
logger_1.logger.info(clc.bold(`Successfully updated ${printer.prettyBackupScheduleString(backupSchedule)}`));
|
|
31
|
+
}
|
|
32
|
+
return backupSchedule;
|
|
33
|
+
});
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.command = void 0;
|
|
4
|
-
const command_1 = require("../command");
|
|
5
4
|
const clc = require("colorette");
|
|
5
|
+
const command_1 = require("../command");
|
|
6
6
|
const fsi = require("../firestore/api");
|
|
7
7
|
const types = require("../firestore/api-types");
|
|
8
8
|
const logger_1 = require("../logger");
|
|
9
9
|
const requirePermissions_1 = require("../requirePermissions");
|
|
10
10
|
const types_1 = require("../emulator/types");
|
|
11
11
|
const commandUtils_1 = require("../emulator/commandUtils");
|
|
12
|
+
const pretty_print_1 = require("../firestore/pretty-print");
|
|
12
13
|
exports.command = new command_1.Command("firestore:databases:create <database>")
|
|
13
14
|
.description("Create a database in your Firebase project.")
|
|
14
15
|
.option("--location <locationId>", "Region to create database, for example 'nam5'. Run 'firebase firestore:locations' to get a list of eligible locations. (required)")
|
|
@@ -18,6 +19,7 @@ exports.command = new command_1.Command("firestore:databases:create <database>")
|
|
|
18
19
|
.before(commandUtils_1.warnEmulatorNotSupported, types_1.Emulators.FIRESTORE)
|
|
19
20
|
.action(async (database, options) => {
|
|
20
21
|
const api = new fsi.FirestoreApi();
|
|
22
|
+
const printer = new pretty_print_1.PrettyPrint();
|
|
21
23
|
if (!options.location) {
|
|
22
24
|
logger_1.logger.error("Missing required flag --location. See firebase firestore:databases:create --help for more info.");
|
|
23
25
|
return;
|
|
@@ -46,7 +48,7 @@ exports.command = new command_1.Command("firestore:databases:create <database>")
|
|
|
46
48
|
logger_1.logger.info(JSON.stringify(databaseResp, undefined, 2));
|
|
47
49
|
}
|
|
48
50
|
else {
|
|
49
|
-
logger_1.logger.info(clc.bold(`Successfully created ${
|
|
51
|
+
logger_1.logger.info(clc.bold(`Successfully created ${printer.prettyDatabaseString(databaseResp)}`));
|
|
50
52
|
logger_1.logger.info("Please be sure to configure Firebase rules in your Firebase config file for\n" +
|
|
51
53
|
"the new database. By default, created databases will have closed rules that\n" +
|
|
52
54
|
"block any incoming third-party traffic.");
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.command = void 0;
|
|
4
|
-
const command_1 = require("../command");
|
|
5
4
|
const clc = require("colorette");
|
|
5
|
+
const command_1 = require("../command");
|
|
6
6
|
const fsi = require("../firestore/api");
|
|
7
7
|
const prompt_1 = require("../prompt");
|
|
8
8
|
const logger_1 = require("../logger");
|
|
@@ -10,6 +10,7 @@ const requirePermissions_1 = require("../requirePermissions");
|
|
|
10
10
|
const types_1 = require("../emulator/types");
|
|
11
11
|
const commandUtils_1 = require("../emulator/commandUtils");
|
|
12
12
|
const error_1 = require("../error");
|
|
13
|
+
const pretty_print_1 = require("../firestore/pretty-print");
|
|
13
14
|
exports.command = new command_1.Command("firestore:databases:delete <database>")
|
|
14
15
|
.description("Delete a database in your Cloud Firestore project. Database delete protection state must be disabled. To do so, use the update command: firebase firestore:databases:update <database> --delete-protection DISABLED")
|
|
15
16
|
.option("--force", "Attempt to delete database without prompting for confirmation.")
|
|
@@ -17,6 +18,7 @@ exports.command = new command_1.Command("firestore:databases:delete <database>")
|
|
|
17
18
|
.before(commandUtils_1.warnEmulatorNotSupported, types_1.Emulators.FIRESTORE)
|
|
18
19
|
.action(async (database, options) => {
|
|
19
20
|
const api = new fsi.FirestoreApi();
|
|
21
|
+
const printer = new pretty_print_1.PrettyPrint();
|
|
20
22
|
if (!options.force) {
|
|
21
23
|
const confirmMessage = `You are about to delete projects/${options.project}/databases/${database}. Do you wish to continue?`;
|
|
22
24
|
const consent = await (0, prompt_1.promptOnce)({
|
|
@@ -33,7 +35,7 @@ exports.command = new command_1.Command("firestore:databases:delete <database>")
|
|
|
33
35
|
logger_1.logger.info(JSON.stringify(databaseResp, undefined, 2));
|
|
34
36
|
}
|
|
35
37
|
else {
|
|
36
|
-
logger_1.logger.info(clc.bold(`Successfully deleted ${
|
|
38
|
+
logger_1.logger.info(clc.bold(`Successfully deleted ${printer.prettyDatabaseString(databaseResp)}`));
|
|
37
39
|
}
|
|
38
40
|
return databaseResp;
|
|
39
41
|
});
|
|
@@ -7,19 +7,21 @@ const logger_1 = require("../logger");
|
|
|
7
7
|
const requirePermissions_1 = require("../requirePermissions");
|
|
8
8
|
const types_1 = require("../emulator/types");
|
|
9
9
|
const commandUtils_1 = require("../emulator/commandUtils");
|
|
10
|
+
const pretty_print_1 = require("../firestore/pretty-print");
|
|
10
11
|
exports.command = new command_1.Command("firestore:databases:get [database]")
|
|
11
12
|
.description("Get database in your Cloud Firestore project.")
|
|
12
13
|
.before(requirePermissions_1.requirePermissions, ["datastore.databases.get"])
|
|
13
14
|
.before(commandUtils_1.warnEmulatorNotSupported, types_1.Emulators.FIRESTORE)
|
|
14
15
|
.action(async (database, options) => {
|
|
15
16
|
const api = new fsi.FirestoreApi();
|
|
17
|
+
const printer = new pretty_print_1.PrettyPrint();
|
|
16
18
|
const databaseId = database || "(default)";
|
|
17
19
|
const databaseResp = await api.getDatabase(options.project, databaseId);
|
|
18
20
|
if (options.json) {
|
|
19
21
|
logger_1.logger.info(JSON.stringify(databaseResp, undefined, 2));
|
|
20
22
|
}
|
|
21
23
|
else {
|
|
22
|
-
|
|
24
|
+
printer.prettyPrintDatabase(databaseResp);
|
|
23
25
|
}
|
|
24
26
|
return databaseResp;
|
|
25
27
|
});
|
|
@@ -7,18 +7,20 @@ const logger_1 = require("../logger");
|
|
|
7
7
|
const requirePermissions_1 = require("../requirePermissions");
|
|
8
8
|
const types_1 = require("../emulator/types");
|
|
9
9
|
const commandUtils_1 = require("../emulator/commandUtils");
|
|
10
|
+
const pretty_print_1 = require("../firestore/pretty-print");
|
|
10
11
|
exports.command = new command_1.Command("firestore:databases:list")
|
|
11
12
|
.description("List databases in your Cloud Firestore project.")
|
|
12
13
|
.before(requirePermissions_1.requirePermissions, ["datastore.databases.list"])
|
|
13
14
|
.before(commandUtils_1.warnEmulatorNotSupported, types_1.Emulators.FIRESTORE)
|
|
14
15
|
.action(async (options) => {
|
|
15
16
|
const api = new fsi.FirestoreApi();
|
|
17
|
+
const printer = new pretty_print_1.PrettyPrint();
|
|
16
18
|
const databases = await api.listDatabases(options.project);
|
|
17
19
|
if (options.json) {
|
|
18
20
|
logger_1.logger.info(JSON.stringify(databases, undefined, 2));
|
|
19
21
|
}
|
|
20
22
|
else {
|
|
21
|
-
|
|
23
|
+
printer.prettyPrintDatabases(databases);
|
|
22
24
|
}
|
|
23
25
|
return databases;
|
|
24
26
|
});
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.command = void 0;
|
|
4
|
+
const clc = require("colorette");
|
|
5
|
+
const command_1 = require("../command");
|
|
6
|
+
const fsi = require("../firestore/api");
|
|
7
|
+
const logger_1 = require("../logger");
|
|
8
|
+
const requirePermissions_1 = require("../requirePermissions");
|
|
9
|
+
const types_1 = require("../emulator/types");
|
|
10
|
+
const commandUtils_1 = require("../emulator/commandUtils");
|
|
11
|
+
const pretty_print_1 = require("../firestore/pretty-print");
|
|
12
|
+
exports.command = new command_1.Command("firestore:databases:restore")
|
|
13
|
+
.description("Restore a Firestore database in your Firebase project.")
|
|
14
|
+
.option("-d, --database <databaseID>", "ID of the database to restore into")
|
|
15
|
+
.option("-b, --backup <backup>", "Backup from which to restore")
|
|
16
|
+
.before(requirePermissions_1.requirePermissions, ["datastore.backups.restoreDatabase"])
|
|
17
|
+
.before(commandUtils_1.warnEmulatorNotSupported, types_1.Emulators.FIRESTORE)
|
|
18
|
+
.action(async (options) => {
|
|
19
|
+
const api = new fsi.FirestoreApi();
|
|
20
|
+
const printer = new pretty_print_1.PrettyPrint();
|
|
21
|
+
if (!options.database) {
|
|
22
|
+
logger_1.logger.error("Missing required flag --database. See firebase firestore:databases:restore --help for more info");
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const databaseId = options.database;
|
|
26
|
+
if (!options.backup) {
|
|
27
|
+
logger_1.logger.error("Missing required flag --backup. See firebase firestore:databases:restore --help for more info");
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
const backupName = options.backup;
|
|
31
|
+
const databaseResp = await api.restoreDatabase(options.project, databaseId, backupName);
|
|
32
|
+
if (options.json) {
|
|
33
|
+
logger_1.logger.info(JSON.stringify(databaseResp, undefined, 2));
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
logger_1.logger.info(clc.bold(`Successfully initiated restore of ${printer.prettyDatabaseString(databaseResp)}`));
|
|
37
|
+
logger_1.logger.info("Please be sure to configure Firebase rules in your Firebase config file for\n" +
|
|
38
|
+
"the new database. By default, created databases will have closed rules that\n" +
|
|
39
|
+
"block any incoming third-party traffic.");
|
|
40
|
+
}
|
|
41
|
+
return databaseResp;
|
|
42
|
+
});
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.command = void 0;
|
|
4
|
-
const command_1 = require("../command");
|
|
5
4
|
const clc = require("colorette");
|
|
5
|
+
const command_1 = require("../command");
|
|
6
6
|
const fsi = require("../firestore/api");
|
|
7
7
|
const types = require("../firestore/api-types");
|
|
8
8
|
const logger_1 = require("../logger");
|
|
9
9
|
const requirePermissions_1 = require("../requirePermissions");
|
|
10
10
|
const types_1 = require("../emulator/types");
|
|
11
11
|
const commandUtils_1 = require("../emulator/commandUtils");
|
|
12
|
+
const pretty_print_1 = require("../firestore/pretty-print");
|
|
12
13
|
exports.command = new command_1.Command("firestore:databases:update <database>")
|
|
13
14
|
.description("Update a database in your Firebase project. Must specify at least one property to update.")
|
|
14
15
|
.option("--json", "Prints raw json response of the create API call if specified")
|
|
@@ -18,6 +19,7 @@ exports.command = new command_1.Command("firestore:databases:update <database>")
|
|
|
18
19
|
.before(commandUtils_1.warnEmulatorNotSupported, types_1.Emulators.FIRESTORE)
|
|
19
20
|
.action(async (database, options) => {
|
|
20
21
|
const api = new fsi.FirestoreApi();
|
|
22
|
+
const printer = new pretty_print_1.PrettyPrint();
|
|
21
23
|
if (!options.deleteProtection && !options.pointInTimeRecovery) {
|
|
22
24
|
logger_1.logger.error("Missing properties to update. See firebase firestore:databases:update --help for more info.");
|
|
23
25
|
return;
|
|
@@ -53,7 +55,7 @@ exports.command = new command_1.Command("firestore:databases:update <database>")
|
|
|
53
55
|
logger_1.logger.info(JSON.stringify(databaseResp, undefined, 2));
|
|
54
56
|
}
|
|
55
57
|
else {
|
|
56
|
-
logger_1.logger.info(clc.bold(`Successfully updated ${
|
|
58
|
+
logger_1.logger.info(clc.bold(`Successfully updated ${printer.prettyDatabaseString(databaseResp)}`));
|
|
57
59
|
}
|
|
58
60
|
return databaseResp;
|
|
59
61
|
});
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.command = void 0;
|
|
4
|
-
const command_1 = require("../command");
|
|
5
4
|
const clc = require("colorette");
|
|
5
|
+
const command_1 = require("../command");
|
|
6
6
|
const fsi = require("../firestore/api");
|
|
7
7
|
const logger_1 = require("../logger");
|
|
8
8
|
const requirePermissions_1 = require("../requirePermissions");
|
|
9
9
|
const types_1 = require("../emulator/types");
|
|
10
10
|
const commandUtils_1 = require("../emulator/commandUtils");
|
|
11
|
+
const pretty_print_1 = require("../firestore/pretty-print");
|
|
11
12
|
exports.command = new command_1.Command("firestore:indexes")
|
|
12
13
|
.description("List indexes in your project's Cloud Firestore database.")
|
|
13
14
|
.option("--pretty", "Pretty print. When not specified the indexes are printed in the " +
|
|
@@ -17,17 +18,18 @@ exports.command = new command_1.Command("firestore:indexes")
|
|
|
17
18
|
.before(commandUtils_1.warnEmulatorNotSupported, types_1.Emulators.FIRESTORE)
|
|
18
19
|
.action(async (options) => {
|
|
19
20
|
const indexApi = new fsi.FirestoreApi();
|
|
21
|
+
const printer = new pretty_print_1.PrettyPrint();
|
|
20
22
|
const databaseId = options.database ?? "(default)";
|
|
21
23
|
const indexes = await indexApi.listIndexes(options.project, databaseId);
|
|
22
24
|
const fieldOverrides = await indexApi.listFieldOverrides(options.project, databaseId);
|
|
23
25
|
const indexSpec = indexApi.makeIndexSpec(indexes, fieldOverrides);
|
|
24
26
|
if (options.pretty) {
|
|
25
27
|
logger_1.logger.info(clc.bold(clc.white("Compound Indexes")));
|
|
26
|
-
|
|
28
|
+
printer.prettyPrintIndexes(indexes);
|
|
27
29
|
if (fieldOverrides) {
|
|
28
30
|
logger_1.logger.info();
|
|
29
31
|
logger_1.logger.info(clc.bold(clc.white("Field Overrides")));
|
|
30
|
-
|
|
32
|
+
printer.printFieldOverrides(fieldOverrides);
|
|
31
33
|
}
|
|
32
34
|
}
|
|
33
35
|
else {
|
|
@@ -7,18 +7,20 @@ const logger_1 = require("../logger");
|
|
|
7
7
|
const requirePermissions_1 = require("../requirePermissions");
|
|
8
8
|
const types_1 = require("../emulator/types");
|
|
9
9
|
const commandUtils_1 = require("../emulator/commandUtils");
|
|
10
|
+
const pretty_print_1 = require("../firestore/pretty-print");
|
|
10
11
|
exports.command = new command_1.Command("firestore:locations")
|
|
11
12
|
.description("List possible locations for your Cloud Firestore project.")
|
|
12
13
|
.before(requirePermissions_1.requirePermissions, ["datastore.locations.list"])
|
|
13
14
|
.before(commandUtils_1.warnEmulatorNotSupported, types_1.Emulators.FIRESTORE)
|
|
14
15
|
.action(async (options) => {
|
|
15
16
|
const api = new fsi.FirestoreApi();
|
|
17
|
+
const printer = new pretty_print_1.PrettyPrint();
|
|
16
18
|
const locations = await api.locations(options.project);
|
|
17
19
|
if (options.json) {
|
|
18
20
|
logger_1.logger.info(JSON.stringify(locations, undefined, 2));
|
|
19
21
|
}
|
|
20
22
|
else {
|
|
21
|
-
|
|
23
|
+
printer.prettyPrintLocations(locations);
|
|
22
24
|
}
|
|
23
25
|
return locations;
|
|
24
26
|
});
|
|
@@ -110,8 +110,10 @@ exports.command = new command_1.Command("functions:config:export")
|
|
|
110
110
|
const dotEnvs = pInfos.map((pInfo) => configExport.toDotenvFormat(pInfo.envs, header));
|
|
111
111
|
const filenames = pInfos.map(configExport.generateDotenvFilename);
|
|
112
112
|
const filesToWrite = fromEntries((0, functional_1.zip)(filenames, dotEnvs));
|
|
113
|
-
filesToWrite[".env.local"] =
|
|
114
|
-
|
|
113
|
+
filesToWrite[".env.local"] =
|
|
114
|
+
`${header}\n# .env.local file contains environment variables for the Functions Emulator.\n`;
|
|
115
|
+
filesToWrite[".env"] =
|
|
116
|
+
`${header}# .env file contains environment variables that applies to all projects.\n`;
|
|
115
117
|
for (const [filename, content] of Object.entries(filesToWrite)) {
|
|
116
118
|
await options.config.askWriteProjectFile(path.join(functionsDir, filename), content);
|
|
117
119
|
}
|
package/lib/commands/index.js
CHANGED
|
@@ -101,6 +101,16 @@ function load(client) {
|
|
|
101
101
|
client.firestore.databases.create = loadCommand("firestore-databases-create");
|
|
102
102
|
client.firestore.databases.update = loadCommand("firestore-databases-update");
|
|
103
103
|
client.firestore.databases.delete = loadCommand("firestore-databases-delete");
|
|
104
|
+
client.firestore.databases.restore = loadCommand("firestore-databases-restore");
|
|
105
|
+
client.firestore.backups = {};
|
|
106
|
+
client.firestore.backups.schedules = {};
|
|
107
|
+
client.firestore.backups.list = loadCommand("firestore-backups-list");
|
|
108
|
+
client.firestore.backups.get = loadCommand("firestore-backups-get");
|
|
109
|
+
client.firestore.backups.delete = loadCommand("firestore-backups-delete");
|
|
110
|
+
client.firestore.backups.schedules.list = loadCommand("firestore-backups-schedules-list");
|
|
111
|
+
client.firestore.backups.schedules.create = loadCommand("firestore-backups-schedules-create");
|
|
112
|
+
client.firestore.backups.schedules.update = loadCommand("firestore-backups-schedules-update");
|
|
113
|
+
client.firestore.backups.schedules.delete = loadCommand("firestore-backups-schedules-delete");
|
|
104
114
|
client.functions = {};
|
|
105
115
|
client.functions.config = {};
|
|
106
116
|
client.functions.config.clone = loadCommand("functions-config-clone");
|
|
@@ -144,7 +154,7 @@ function load(client) {
|
|
|
144
154
|
client.internaltesting.functions = {};
|
|
145
155
|
client.internaltesting.functions.discover = loadCommand("internaltesting-functions-discover");
|
|
146
156
|
}
|
|
147
|
-
if (experiments.isEnabled("
|
|
157
|
+
if (experiments.isEnabled("apphosting")) {
|
|
148
158
|
client.apphosting = {};
|
|
149
159
|
client.apphosting.backends = {};
|
|
150
160
|
client.apphosting.backends.list = loadCommand("apphosting-backends-list");
|
package/lib/commands/init.js
CHANGED
|
@@ -69,10 +69,10 @@ const choices = [
|
|
|
69
69
|
checked: false,
|
|
70
70
|
},
|
|
71
71
|
];
|
|
72
|
-
if ((0, experiments_1.isEnabled)("
|
|
72
|
+
if ((0, experiments_1.isEnabled)("apphosting")) {
|
|
73
73
|
choices.push({
|
|
74
|
-
value: "
|
|
75
|
-
name: "
|
|
74
|
+
value: "apphosting",
|
|
75
|
+
name: "App Hosting: Get started with App Hosting projects.",
|
|
76
76
|
checked: false,
|
|
77
77
|
});
|
|
78
78
|
}
|