firebase-tools 12.8.0 → 12.8.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.
@@ -18,30 +18,37 @@ exports.command = new command_1.Command("firestore:databases:update <database>")
18
18
  .before(commandUtils_1.warnEmulatorNotSupported, types_1.Emulators.FIRESTORE)
19
19
  .action(async (database, options) => {
20
20
  const api = new fsi.FirestoreApi();
21
- if (!options.type && !options.deleteProtection && !options.pointInTimeRecovery) {
21
+ if (!options.deleteProtection && !options.pointInTimeRecovery) {
22
22
  logger_1.logger.error("Missing properties to update. See firebase firestore:databases:update --help for more info.");
23
23
  return;
24
24
  }
25
- const type = types.DatabaseType.FIRESTORE_NATIVE;
26
25
  if (options.deleteProtection &&
27
26
  options.deleteProtection !== types.DatabaseDeleteProtectionStateOption.ENABLED &&
28
27
  options.deleteProtection !== types.DatabaseDeleteProtectionStateOption.DISABLED) {
29
28
  logger_1.logger.error("Invalid value for flag --delete-protection. See firebase firestore:databases:update --help for more info.");
30
29
  return;
31
30
  }
32
- const deleteProtectionState = options.deleteProtection === types.DatabaseDeleteProtectionStateOption.ENABLED
33
- ? types.DatabaseDeleteProtectionState.ENABLED
34
- : types.DatabaseDeleteProtectionState.DISABLED;
31
+ let deleteProtectionState;
32
+ if (options.deleteProtection === types.DatabaseDeleteProtectionStateOption.ENABLED) {
33
+ deleteProtectionState = types.DatabaseDeleteProtectionState.ENABLED;
34
+ }
35
+ else if (options.deleteProtection === types.DatabaseDeleteProtectionStateOption.DISABLED) {
36
+ deleteProtectionState = types.DatabaseDeleteProtectionState.DISABLED;
37
+ }
35
38
  if (options.pointInTimeRecovery &&
36
39
  options.pointInTimeRecovery !== types.PointInTimeRecoveryEnablementOption.ENABLED &&
37
40
  options.pointInTimeRecovery !== types.PointInTimeRecoveryEnablementOption.DISABLED) {
38
41
  logger_1.logger.error("Invalid value for flag --point-in-time-recovery. See firebase firestore:databases:update --help for more info.");
39
42
  return;
40
43
  }
41
- const pointInTimeRecoveryEnablement = options.pointInTimeRecovery === types.PointInTimeRecoveryEnablementOption.ENABLED
42
- ? types.PointInTimeRecoveryEnablement.ENABLED
43
- : types.PointInTimeRecoveryEnablement.DISABLED;
44
- const databaseResp = await api.updateDatabase(options.project, database, type, deleteProtectionState, pointInTimeRecoveryEnablement);
44
+ let pointInTimeRecoveryEnablement;
45
+ if (options.pointInTimeRecovery === types.PointInTimeRecoveryEnablementOption.ENABLED) {
46
+ pointInTimeRecoveryEnablement = types.PointInTimeRecoveryEnablement.ENABLED;
47
+ }
48
+ else if (options.pointInTimeRecovery === types.PointInTimeRecoveryEnablementOption.DISABLED) {
49
+ pointInTimeRecoveryEnablement = types.PointInTimeRecoveryEnablement.DISABLED;
50
+ }
51
+ const databaseResp = await api.updateDatabase(options.project, database, deleteProtectionState, pointInTimeRecoveryEnablement);
45
52
  if (options.json) {
46
53
  logger_1.logger.info(JSON.stringify(databaseResp, undefined, 2));
47
54
  }
@@ -5,8 +5,8 @@ const command_1 = require("../command");
5
5
  const projectUtils_1 = require("../projectUtils");
6
6
  const requireInteractive_1 = require("../requireInteractive");
7
7
  const frameworks_1 = require("../init/features/frameworks");
8
- exports.command = new command_1.Command("stacks:create")
9
- .description("Create a stack in a Firebase project")
8
+ exports.command = new command_1.Command("backends:create")
9
+ .description("Create a backend in a Firebase project")
10
10
  .before(requireInteractive_1.default)
11
11
  .action(async (options) => {
12
12
  const projectId = (0, projectUtils_1.needProjectId)(options);
@@ -7,32 +7,32 @@ const error_1 = require("../error");
7
7
  const gcp = require("../gcp/frameworks");
8
8
  const prompt_1 = require("../prompt");
9
9
  const utils = require("../utils");
10
- exports.command = new command_1.Command("stacks:delete")
11
- .description("Delete a stack from a Firebase project")
10
+ exports.command = new command_1.Command("backends:delete")
11
+ .description("Delete a backend from a Firebase project")
12
12
  .option("-l, --location <location>", "App Backend location", "us-central1")
13
- .option("-s, --stackId <stackId>", "Stack Id", "")
13
+ .option("-s, --backendId <backendId>", "Backend Id", "")
14
14
  .withForce()
15
15
  .action(async (options) => {
16
16
  const projectId = (0, projectUtils_1.needProjectId)(options);
17
17
  const location = options.location;
18
- const stackId = options.stackId;
19
- if (!stackId) {
20
- throw new error_1.FirebaseError("Stack id can't be empty.");
18
+ const backendId = options.backendId;
19
+ if (!backendId) {
20
+ throw new error_1.FirebaseError("Backend id can't be empty.");
21
21
  }
22
22
  const confirmDeletion = await (0, prompt_1.promptOnce)({
23
23
  type: "confirm",
24
24
  name: "force",
25
25
  default: false,
26
- message: "You are about to delete the Stack with id: " + stackId + "\n Are you sure?",
26
+ message: "You are about to delete the backend with id: " + backendId + "\n Are you sure?",
27
27
  }, options);
28
28
  if (!confirmDeletion) {
29
29
  throw new error_1.FirebaseError("Deletion aborted.");
30
30
  }
31
31
  try {
32
- await gcp.deleteStack(projectId, location, stackId);
33
- utils.logSuccess(`Successfully deleted the stack: ${stackId}`);
32
+ await gcp.deleteBackend(projectId, location, backendId);
33
+ utils.logSuccess(`Successfully deleted the backend: ${backendId}`);
34
34
  }
35
35
  catch (err) {
36
- throw new error_1.FirebaseError(`Failed to delete stack: ${stackId}. Please check the parameters you have provided.`, { original: err });
36
+ throw new error_1.FirebaseError(`Failed to delete backend: ${backendId}. Please check the parameters you have provided.`, { original: err });
37
37
  }
38
38
  });
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.command = void 0;
4
+ const command_1 = require("../command");
5
+ const projectUtils_1 = require("../projectUtils");
6
+ const gcp = require("../gcp/frameworks");
7
+ const error_1 = require("../error");
8
+ const logger_1 = require("../logger");
9
+ const Table = require("cli-table");
10
+ exports.command = new command_1.Command("backends:get")
11
+ .description("Get backend details of a Firebase project")
12
+ .option("-l, --location <location>", "App Backend location", "us-central1")
13
+ .option("--s, --backendId <backendId>", "Backend Id", "")
14
+ .action(async (options) => {
15
+ const projectId = (0, projectUtils_1.needProjectId)(options);
16
+ const location = options.location;
17
+ const backendId = options.backendId;
18
+ if (!backendId) {
19
+ throw new error_1.FirebaseError("Backend id can't be empty.");
20
+ }
21
+ let backend;
22
+ try {
23
+ backend = await gcp.getBackend(projectId, location, backendId);
24
+ const table = new Table({
25
+ head: ["Backend Id", "Repository Name", "URL", "Location", "Created Date", "Updated Date"],
26
+ style: { head: ["green"] },
27
+ });
28
+ table.push([
29
+ backend.name,
30
+ backend.codebase.repository,
31
+ backend.uri,
32
+ backend.createTime,
33
+ backend.updateTime,
34
+ ]);
35
+ logger_1.logger.info(table.toString());
36
+ }
37
+ catch (err) {
38
+ throw new error_1.FirebaseError(`Failed to get backend: ${backendId}. Please check the parameters you have provided.`, { original: err });
39
+ }
40
+ return backend;
41
+ });
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.command = void 0;
4
+ const command_1 = require("../command");
5
+ const projectUtils_1 = require("../projectUtils");
6
+ const gcp = require("../gcp/frameworks");
7
+ const error_1 = require("../error");
8
+ const logger_1 = require("../logger");
9
+ const colorette_1 = require("colorette");
10
+ const Table = require("cli-table");
11
+ exports.command = new command_1.Command("backends:list")
12
+ .description("List backends of a Firebase project.")
13
+ .option("-l, --location <location>", "App Backend location", "us-central1")
14
+ .action(async (options) => {
15
+ const projectId = (0, projectUtils_1.needProjectId)(options);
16
+ const location = options.location;
17
+ const table = new Table({
18
+ head: ["Backend Id", "Repository Name", "URL", "Location", "Created Date", "Updated Date"],
19
+ style: { head: ["green"] },
20
+ });
21
+ let backendsList;
22
+ try {
23
+ backendsList = await gcp.listBackends(projectId, location);
24
+ for (const backend of backendsList.backends) {
25
+ const entry = [
26
+ backend.name,
27
+ backend.codebase.repository,
28
+ backend.uri,
29
+ backend.createTime,
30
+ backend.updateTime,
31
+ ];
32
+ table.push(entry);
33
+ }
34
+ logger_1.logger.info(`Backends for project ${(0, colorette_1.bold)(projectId)}`);
35
+ logger_1.logger.info(table.toString());
36
+ }
37
+ catch (err) {
38
+ throw new error_1.FirebaseError(`Unable to list backends present in project: ${projectId}. Please check the parameters you have provided.`, { original: err });
39
+ }
40
+ return backendsList;
41
+ });
@@ -147,11 +147,11 @@ function load(client) {
147
147
  }
148
148
  if (experiments.isEnabled("internalframeworks")) {
149
149
  client.frameworks = {};
150
- client.frameworks.stacks = {};
151
- client.frameworks.stacks.list = loadCommand("frameworks-stacks-list");
152
- client.frameworks.stacks.create = loadCommand("frameworks-stacks-create");
153
- client.frameworks.stacks.create = loadCommand("frameworks-stacks-get");
154
- client.frameworks.stacks.create = loadCommand("frameworks-stacks-delete");
150
+ client.frameworks.backends = {};
151
+ client.frameworks.backends.list = loadCommand("frameworks-backends-list");
152
+ client.frameworks.backends.create = loadCommand("frameworks-backends-create");
153
+ client.frameworks.backends.get = loadCommand("frameworks-backends-get");
154
+ client.frameworks.backends.delete = loadCommand("frameworks-backends-delete");
155
155
  }
156
156
  client.login = loadCommand("login");
157
157
  client.login.add = loadCommand("login-add");
@@ -485,10 +485,9 @@ class FirestoreApi {
485
485
  }
486
486
  return database;
487
487
  }
488
- async updateDatabase(project, databaseId, type, deleteProtectionState, pointInTimeRecoveryEnablement) {
488
+ async updateDatabase(project, databaseId, deleteProtectionState, pointInTimeRecoveryEnablement) {
489
489
  const url = `/projects/${project}/databases/${databaseId}`;
490
490
  const payload = {
491
- type,
492
491
  deleteProtectionState,
493
492
  pointInTimeRecoveryEnablement,
494
493
  };
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createBuild = exports.deleteStack = exports.listStack = exports.getStack = exports.createStack = exports.API_VERSION = void 0;
3
+ exports.createBuild = exports.deleteBackend = exports.listBackends = exports.getBackend = exports.createStack = exports.API_VERSION = void 0;
4
4
  const apiv2_1 = require("../apiv2");
5
5
  const api_1 = require("../api");
6
6
  exports.API_VERSION = "v1alpha";
@@ -14,24 +14,24 @@ async function createStack(projectId, location, stackReqBoby, backendId) {
14
14
  return res.body;
15
15
  }
16
16
  exports.createStack = createStack;
17
- async function getStack(projectId, location, stackId) {
18
- const name = `projects/${projectId}/locations/${location}/backends/${stackId}`;
17
+ async function getBackend(projectId, location, backendId) {
18
+ const name = `projects/${projectId}/locations/${location}/backends/${backendId}`;
19
19
  const res = await client.get(name);
20
20
  return res.body;
21
21
  }
22
- exports.getStack = getStack;
23
- async function listStack(projectId, location) {
22
+ exports.getBackend = getBackend;
23
+ async function listBackends(projectId, location) {
24
24
  const name = `projects/${projectId}/locations/${location}/backends`;
25
25
  const res = await client.get(name);
26
26
  return res.body;
27
27
  }
28
- exports.listStack = listStack;
29
- async function deleteStack(projectId, location, stackId) {
30
- const name = `projects/${projectId}/locations/${location}/backends/${stackId}`;
28
+ exports.listBackends = listBackends;
29
+ async function deleteBackend(projectId, location, backendId) {
30
+ const name = `projects/${projectId}/locations/${location}/backends/${backendId}`;
31
31
  const res = await client.delete(name);
32
32
  return res.body;
33
33
  }
34
- exports.deleteStack = deleteStack;
34
+ exports.deleteBackend = deleteBackend;
35
35
  async function createBuild(projectId, location, stackId, buildInput) {
36
36
  const buildId = buildInput.name;
37
37
  const res = await client.post(`projects/${projectId}/locations/${location}/backends/${stackId}/builds`, buildInput, { queryParams: { buildId } });
@@ -82,7 +82,7 @@ async function getOrCreateStack(projectId, setup) {
82
82
  }
83
83
  exports.getOrCreateStack = getOrCreateStack;
84
84
  async function getExistingStack(projectId, setup, location) {
85
- let stack = await gcp.getStack(projectId, location, setup.frameworks.serviceName);
85
+ let stack = await gcp.getBackend(projectId, location, setup.frameworks.serviceName);
86
86
  while (stack) {
87
87
  setup.frameworks.serviceName = undefined;
88
88
  await (0, prompt_1.promptOnce)({
@@ -101,7 +101,7 @@ async function getExistingStack(projectId, setup, location) {
101
101
  default: "acme-inc-web",
102
102
  message: "Please enter a new service name [1-30 characters]",
103
103
  }, setup.frameworks);
104
- stack = await gcp.getStack(projectId, location, setup.frameworks.serviceName);
104
+ stack = await gcp.getBackend(projectId, location, setup.frameworks.serviceName);
105
105
  setup.frameworks.existingStack = undefined;
106
106
  }
107
107
  return stack;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "firebase-tools",
3
- "version": "12.8.0",
3
+ "version": "12.8.1",
4
4
  "description": "Command-Line Interface for Firebase",
5
5
  "main": "./lib/index.js",
6
6
  "bin": {
@@ -1,29 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.command = void 0;
4
- const command_1 = require("../command");
5
- const projectUtils_1 = require("../projectUtils");
6
- const gcp = require("../gcp/frameworks");
7
- const error_1 = require("../error");
8
- const logger_1 = require("../logger");
9
- exports.command = new command_1.Command("stacks:get")
10
- .description("Get stack details of a Firebase project")
11
- .option("-l, --location <location>", "App Backend location", "us-central1")
12
- .option("--s, --stackId <stackId>", "Stack Id", "")
13
- .action(async (options) => {
14
- const projectId = (0, projectUtils_1.needProjectId)(options);
15
- const location = options.location;
16
- const stackId = options.stackId;
17
- if (!stackId) {
18
- throw new error_1.FirebaseError("Stack id can't be empty.");
19
- }
20
- let stack;
21
- try {
22
- stack = await gcp.getStack(projectId, location, stackId);
23
- logger_1.logger.info(stack);
24
- }
25
- catch (err) {
26
- throw new error_1.FirebaseError(`Failed to get stack: ${stackId}. Please check the parameters you have provided.`, { original: err });
27
- }
28
- return stack;
29
- });
@@ -1,24 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.command = void 0;
4
- const command_1 = require("../command");
5
- const projectUtils_1 = require("../projectUtils");
6
- const gcp = require("../gcp/frameworks");
7
- const error_1 = require("../error");
8
- const logger_1 = require("../logger");
9
- exports.command = new command_1.Command("stacks:list")
10
- .description("List stacks of a Firebase project.")
11
- .option("-l, --location <location>", "App Backend location", "us-central1")
12
- .action(async (options) => {
13
- const projectId = (0, projectUtils_1.needProjectId)(options);
14
- const location = options.location;
15
- let stacks;
16
- try {
17
- stacks = await gcp.listStack(projectId, location);
18
- logger_1.logger.info(stacks);
19
- }
20
- catch (err) {
21
- throw new error_1.FirebaseError(`Unable to list stacks present in project: ${projectId}. Please check the parameters you have provided.`, { original: err });
22
- }
23
- return stacks;
24
- });