firebase-tools-with-isolate 13.11.2 → 13.16.0

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.
Files changed (134) hide show
  1. package/lib/api.js +4 -2
  2. package/lib/apphosting/githubConnections.js +125 -37
  3. package/lib/apphosting/index.js +3 -8
  4. package/lib/auth.js +14 -15
  5. package/lib/bin/firebase.js +7 -5
  6. package/lib/commands/dataconnect-sdk-generate.js +5 -9
  7. package/lib/commands/dataconnect-services-list.js +1 -1
  8. package/lib/commands/deploy.js +10 -2
  9. package/lib/commands/ext-configure.js +1 -6
  10. package/lib/commands/ext-dev-init.js +27 -30
  11. package/lib/commands/ext-dev-upload.js +4 -6
  12. package/lib/commands/ext-info.js +3 -5
  13. package/lib/commands/ext-install.js +0 -5
  14. package/lib/commands/ext-uninstall.js +0 -5
  15. package/lib/commands/ext-update.js +0 -5
  16. package/lib/commands/firestore-backups-schedules-create.js +11 -14
  17. package/lib/commands/firestore-backups-schedules-list.js +1 -1
  18. package/lib/commands/firestore-backups-schedules-update.js +4 -3
  19. package/lib/commands/firestore-databases-create.js +24 -7
  20. package/lib/commands/firestore-databases-restore.js +4 -4
  21. package/lib/commands/firestore-databases-update.js +5 -6
  22. package/lib/commands/functions-secrets-set.js +9 -6
  23. package/lib/commands/help.js +2 -0
  24. package/lib/commands/hosting-channel-create.js +1 -1
  25. package/lib/commands/hosting-channel-delete.js +1 -1
  26. package/lib/commands/hosting-channel-deploy.js +1 -1
  27. package/lib/commands/hosting-clone.js +1 -2
  28. package/lib/commands/index.js +9 -11
  29. package/lib/commands/init.js +16 -12
  30. package/lib/commands/login.js +1 -2
  31. package/lib/commands/setup-emulators-dataconnect.js +22 -3
  32. package/lib/config.js +5 -0
  33. package/lib/crashlytics/buildToolsJarHelper.js +1 -1
  34. package/lib/dataconnect/client.js +57 -9
  35. package/lib/dataconnect/fileUtils.js +71 -7
  36. package/lib/dataconnect/filters.js +12 -1
  37. package/lib/dataconnect/load.js +9 -7
  38. package/lib/dataconnect/provisionCloudSql.js +5 -1
  39. package/lib/dataconnect/schemaMigration.js +21 -0
  40. package/lib/dataconnect/types.js +8 -1
  41. package/lib/deploy/dataconnect/prepare.js +16 -2
  42. package/lib/deploy/extensions/planner.js +52 -1
  43. package/lib/deploy/extensions/prepare.js +98 -23
  44. package/lib/deploy/extensions/release.js +6 -0
  45. package/lib/deploy/functions/build.js +15 -6
  46. package/lib/deploy/functions/deploy.js +12 -12
  47. package/lib/deploy/functions/params.js +5 -3
  48. package/lib/deploy/functions/prepare.js +8 -1
  49. package/lib/deploy/functions/release/index.js +4 -0
  50. package/lib/deploy/functions/runtimes/discovery/parsing.js +1 -1
  51. package/lib/deploy/functions/runtimes/discovery/v1alpha1.js +46 -0
  52. package/lib/emulator/adminSdkConfig.test.js +16 -0
  53. package/lib/emulator/constants.js +8 -0
  54. package/lib/emulator/controller.js +14 -10
  55. package/lib/emulator/dataconnectEmulator.js +122 -18
  56. package/lib/emulator/downloadableEmulators.js +24 -25
  57. package/lib/emulator/env.js +3 -0
  58. package/lib/emulator/eventarcEmulator.js +68 -18
  59. package/lib/emulator/functionsEmulator.js +119 -1
  60. package/lib/emulator/functionsEmulatorShared.js +20 -0
  61. package/lib/emulator/hub.js +1 -1
  62. package/lib/emulator/portUtils.js +10 -0
  63. package/lib/emulator/pubsubEmulator.js +1 -1
  64. package/lib/emulator/registry.js +2 -1
  65. package/lib/emulator/storage/apis/shared.js +2 -1
  66. package/lib/emulator/storage/persistence.js +5 -13
  67. package/lib/emulator/storage/rfc.js +9 -0
  68. package/lib/emulator/storage/rules/config.js +4 -2
  69. package/lib/emulator/taskQueue.js +348 -0
  70. package/lib/emulator/tasksEmulator.js +237 -0
  71. package/lib/emulator/types.js +3 -0
  72. package/lib/experiments.js +8 -3
  73. package/lib/extensions/askUserForEventsConfig.js +18 -8
  74. package/lib/extensions/askUserForParam.js +3 -2
  75. package/lib/extensions/change-log.js +2 -4
  76. package/lib/extensions/displayExtensionInfo.js +5 -10
  77. package/lib/extensions/extensionsApi.js +1 -1
  78. package/lib/extensions/extensionsHelper.js +30 -10
  79. package/lib/extensions/localHelper.js +1 -1
  80. package/lib/extensions/provisioningHelper.js +1 -1
  81. package/lib/extensions/refs.js +26 -11
  82. package/lib/extensions/runtimes/common.js +75 -0
  83. package/lib/extensions/types.js +56 -1
  84. package/lib/extensions/updateHelper.js +1 -2
  85. package/lib/extensions/warnings.js +2 -7
  86. package/lib/firestore/api-sort.test.js +74 -0
  87. package/lib/firestore/api.js +8 -7
  88. package/lib/firestore/backupUtils.test.js +18 -0
  89. package/lib/firestore/pretty-print.js +21 -1
  90. package/lib/firestore/pretty-print.test.js +61 -0
  91. package/lib/firestore/util.test.js +42 -0
  92. package/lib/frameworks/angular/utils.js +13 -5
  93. package/lib/frameworks/compose/discover/mockFileSystem.js +36 -0
  94. package/lib/frameworks/constants.js +1 -1
  95. package/lib/frameworks/index.js +2 -6
  96. package/lib/frameworks/next/constants.js +1 -1
  97. package/lib/frameworks/next/index.js +35 -15
  98. package/lib/frameworks/next/utils.js +53 -9
  99. package/lib/frameworks/nuxt/index.js +3 -3
  100. package/lib/functions/events/v2.js +2 -1
  101. package/lib/gcp/cloudsql/cloudsqladmin.js +6 -1
  102. package/lib/gcp/devConnect.js +36 -1
  103. package/lib/hosting/implicitInit.js +2 -2
  104. package/lib/init/features/dataconnect/index.js +104 -32
  105. package/lib/init/features/dataconnect/sdk.js +147 -0
  106. package/lib/init/features/firestore/indexes.js +2 -2
  107. package/lib/init/features/firestore/rules.js +2 -2
  108. package/lib/init/features/functions/javascript.js +6 -8
  109. package/lib/init/features/functions/python.js +4 -6
  110. package/lib/init/features/functions/typescript.js +8 -10
  111. package/lib/init/features/hosting/github.js +43 -21
  112. package/lib/init/features/hosting/index.js +3 -3
  113. package/lib/init/features/index.js +3 -1
  114. package/lib/init/features/storage.js +2 -2
  115. package/lib/init/index.js +1 -0
  116. package/lib/listFiles.js +1 -1
  117. package/lib/management/apps.js +2 -2
  118. package/lib/prompt.js +22 -1
  119. package/lib/rc.js +1 -0
  120. package/lib/requireAuth.js +8 -3
  121. package/lib/rulesDeploy.js +14 -12
  122. package/lib/templates.js +23 -0
  123. package/lib/utils.js +2 -2
  124. package/package.json +25 -24
  125. package/schema/connector-yaml.json +36 -4
  126. package/schema/dataconnect-yaml.json +4 -0
  127. package/schema/firebase-config.json +12 -8
  128. package/templates/_gitignore +3 -0
  129. package/templates/init/dataconnect/connector.yaml +15 -2
  130. package/templates/init/dataconnect/dataconnect.yaml +5 -4
  131. package/templates/init/dataconnect/mutations.gql +45 -25
  132. package/templates/init/dataconnect/queries.gql +69 -36
  133. package/templates/init/dataconnect/schema.gql +38 -21
  134. package/lib/extensions/billingMigrationHelper.js +0 -61
@@ -1,10 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.command = void 0;
4
- const fs = require("fs");
5
- const path = require("path");
6
4
  const marked_1 = require("marked");
7
- const TerminalRenderer = require("marked-terminal");
5
+ const marked_terminal_1 = require("marked-terminal");
8
6
  const checkMinRequiredVersion_1 = require("../checkMinRequiredVersion");
9
7
  const command_1 = require("../command");
10
8
  const config_1 = require("../config");
@@ -12,19 +10,16 @@ const error_1 = require("../error");
12
10
  const prompt_1 = require("../prompt");
13
11
  const logger_1 = require("../logger");
14
12
  const npmDependencies = require("../init/features/functions/npm-dependencies");
15
- marked_1.marked.setOptions({
16
- renderer: new TerminalRenderer(),
17
- });
18
- const TEMPLATE_ROOT = path.resolve(__dirname, "../../templates/extensions/");
19
- const FUNCTIONS_ROOT = path.resolve(__dirname, "../../templates/init/functions/");
13
+ const templates_1 = require("../templates");
14
+ marked_1.marked.use((0, marked_terminal_1.markedTerminal)());
20
15
  function readCommonTemplates() {
21
16
  return {
22
- integrationTestFirebaseJsonTemplate: fs.readFileSync(path.join(TEMPLATE_ROOT, "integration-test.json"), "utf8"),
23
- integrationTestEnvTemplate: fs.readFileSync(path.join(TEMPLATE_ROOT, "integration-test.env"), "utf8"),
24
- extSpecTemplate: fs.readFileSync(path.join(TEMPLATE_ROOT, "extension.yaml"), "utf8"),
25
- preinstallTemplate: fs.readFileSync(path.join(TEMPLATE_ROOT, "PREINSTALL.md"), "utf8"),
26
- postinstallTemplate: fs.readFileSync(path.join(TEMPLATE_ROOT, "POSTINSTALL.md"), "utf8"),
27
- changelogTemplate: fs.readFileSync(path.join(TEMPLATE_ROOT, "CL-template.md"), "utf8"),
17
+ integrationTestFirebaseJsonTemplate: (0, templates_1.readTemplateSync)("extensions/integration-test.json"),
18
+ integrationTestEnvTemplate: (0, templates_1.readTemplateSync)("extensions/integration-test.env"),
19
+ extSpecTemplate: (0, templates_1.readTemplateSync)("extensions/extension.yaml"),
20
+ preinstallTemplate: (0, templates_1.readTemplateSync)("extensions/PREINSTALL.md"),
21
+ postinstallTemplate: (0, templates_1.readTemplateSync)("extensions/POSTINSTALL.md"),
22
+ changelogTemplate: (0, templates_1.readTemplateSync)("extensions/CL-template.md"),
28
23
  };
29
24
  }
30
25
  exports.command = new command_1.Command("ext:dev:init")
@@ -34,6 +29,7 @@ exports.command = new command_1.Command("ext:dev:init")
34
29
  const cwd = options.cwd || process.cwd();
35
30
  const config = new config_1.Config({}, { projectDir: cwd, cwd: cwd });
36
31
  try {
32
+ let welcome;
37
33
  const lang = await (0, prompt_1.promptOnce)({
38
34
  type: "list",
39
35
  name: "language",
@@ -53,10 +49,12 @@ exports.command = new command_1.Command("ext:dev:init")
53
49
  switch (lang) {
54
50
  case "javascript": {
55
51
  await javascriptSelected(config);
52
+ welcome = (0, templates_1.readTemplateSync)("extensions/javascript/WELCOME.md");
56
53
  break;
57
54
  }
58
55
  case "typescript": {
59
56
  await typescriptSelected(config);
57
+ welcome = (0, templates_1.readTemplateSync)("extensions/typescript/WELCOME.md");
60
58
  break;
61
59
  }
62
60
  default: {
@@ -64,7 +62,6 @@ exports.command = new command_1.Command("ext:dev:init")
64
62
  }
65
63
  }
66
64
  await npmDependencies.askInstallDependencies({ source: "functions" }, config);
67
- const welcome = fs.readFileSync(path.join(TEMPLATE_ROOT, lang, "WELCOME.md"), "utf8");
68
65
  return logger_1.logger.info("\n" + (0, marked_1.marked)(welcome));
69
66
  }
70
67
  catch (err) {
@@ -77,15 +74,15 @@ exports.command = new command_1.Command("ext:dev:init")
77
74
  }
78
75
  });
79
76
  async function typescriptSelected(config) {
80
- const packageLintingTemplate = fs.readFileSync(path.join(TEMPLATE_ROOT, "typescript", "package.lint.json"), "utf8");
81
- const packageNoLintingTemplate = fs.readFileSync(path.join(TEMPLATE_ROOT, "typescript", "package.nolint.json"), "utf8");
82
- const tsconfigTemplate = fs.readFileSync(path.join(TEMPLATE_ROOT, "typescript", "tsconfig.json"), "utf8");
83
- const tsconfigDevTemplate = fs.readFileSync(path.join(TEMPLATE_ROOT, "typescript", "tsconfig.dev.json"), "utf8");
84
- const indexTemplate = fs.readFileSync(path.join(TEMPLATE_ROOT, "typescript", "index.ts"), "utf8");
85
- const integrationTestTemplate = fs.readFileSync(path.join(TEMPLATE_ROOT, "typescript", "integration-test.ts"), "utf8");
86
- const gitignoreTemplate = fs.readFileSync(path.join(TEMPLATE_ROOT, "typescript", "_gitignore"), "utf8");
87
- const mocharcTemplate = fs.readFileSync(path.join(TEMPLATE_ROOT, "typescript", "_mocharc"), "utf8");
88
- const eslintTemplate = fs.readFileSync(path.join(FUNCTIONS_ROOT, "typescript", "_eslintrc"), "utf8");
77
+ const packageLintingTemplate = (0, templates_1.readTemplateSync)("extensions/typescript/package.lint.json");
78
+ const packageNoLintingTemplate = (0, templates_1.readTemplateSync)("extensions/typescript/package.nolint.json");
79
+ const tsconfigTemplate = (0, templates_1.readTemplateSync)("extensions/typescript/tsconfig.json");
80
+ const tsconfigDevTemplate = (0, templates_1.readTemplateSync)("extensions/typescript/tsconfig.dev.json");
81
+ const indexTemplate = (0, templates_1.readTemplateSync)("extensions/typescript/index.ts");
82
+ const integrationTestTemplate = (0, templates_1.readTemplateSync)("extensions/typescript/integration-test.ts");
83
+ const gitignoreTemplate = (0, templates_1.readTemplateSync)("extensions/typescript/_gitignore");
84
+ const mocharcTemplate = (0, templates_1.readTemplateSync)("extensions/typescript/_mocharc");
85
+ const eslintTemplate = (0, templates_1.readTemplateSync)("init/functions/typescript/_eslintrc");
89
86
  const lint = await (0, prompt_1.promptOnce)({
90
87
  name: "lint",
91
88
  type: "confirm",
@@ -116,12 +113,12 @@ async function typescriptSelected(config) {
116
113
  await config.askWriteProjectFile("functions/.gitignore", gitignoreTemplate);
117
114
  }
118
115
  async function javascriptSelected(config) {
119
- const indexTemplate = fs.readFileSync(path.join(TEMPLATE_ROOT, "javascript", "index.js"), "utf8");
120
- const integrationTestTemplate = fs.readFileSync(path.join(TEMPLATE_ROOT, "javascript", "integration-test.js"), "utf8");
121
- const packageLintingTemplate = fs.readFileSync(path.join(TEMPLATE_ROOT, "javascript", "package.lint.json"), "utf8");
122
- const packageNoLintingTemplate = fs.readFileSync(path.join(TEMPLATE_ROOT, "javascript", "package.nolint.json"), "utf8");
123
- const gitignoreTemplate = fs.readFileSync(path.join(TEMPLATE_ROOT, "javascript", "_gitignore"), "utf8");
124
- const eslintTemplate = fs.readFileSync(path.join(FUNCTIONS_ROOT, "javascript", "_eslintrc"), "utf8");
116
+ const indexTemplate = (0, templates_1.readTemplateSync)("extensions/javascript/index.js");
117
+ const integrationTestTemplate = (0, templates_1.readTemplateSync)("extensions/javascript/integration-test.js");
118
+ const packageLintingTemplate = (0, templates_1.readTemplateSync)("extensions/javascript/package.lint.json");
119
+ const packageNoLintingTemplate = (0, templates_1.readTemplateSync)("extensions/javascript/package.nolint.json");
120
+ const gitignoreTemplate = (0, templates_1.readTemplateSync)("extensions/javascript/_gitignore");
121
+ const eslintTemplate = (0, templates_1.readTemplateSync)("init/functions/javascript/_eslintrc");
125
122
  const lint = await (0, prompt_1.promptOnce)({
126
123
  name: "lint",
127
124
  type: "confirm",
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.uploadExtensionAction = exports.command = void 0;
4
4
  const clc = require("colorette");
5
5
  const marked_1 = require("marked");
6
- const TerminalRenderer = require("marked-terminal");
6
+ const marked_terminal_1 = require("marked-terminal");
7
7
  const command_1 = require("../command");
8
8
  const extensionsHelper_1 = require("../extensions/extensionsHelper");
9
9
  const refs = require("../extensions/refs");
@@ -16,9 +16,7 @@ const utils = require("../utils");
16
16
  const publisherApi_1 = require("../extensions/publisherApi");
17
17
  const extensionsHelper_2 = require("../extensions/extensionsHelper");
18
18
  const projects_1 = require("../management/projects");
19
- marked_1.marked.setOptions({
20
- renderer: new TerminalRenderer(),
21
- });
19
+ marked_1.marked.use((0, marked_terminal_1.markedTerminal)());
22
20
  exports.command = new command_1.Command("ext:dev:upload <extensionRef>")
23
21
  .description(`upload a new version of an extension`)
24
22
  .option(`-s, --stage <stage>`, `release stage (supports "alpha", "beta", "rc", and "stable")`)
@@ -79,9 +77,9 @@ async function uploadExtensionAction(extensionRef, options) {
79
77
  });
80
78
  }
81
79
  if (res) {
82
- utils.logLabeledBullet(extensionsHelper_1.logPrefix, (0, marked_1.marked)(`[Install Link](${(0, publishHelpers_1.consoleInstallLink)(res.ref)})`));
80
+ utils.logLabeledBullet(extensionsHelper_1.logPrefix, await (0, marked_1.marked)(`[Install Link](${(0, publishHelpers_1.consoleInstallLink)(res.ref)})`));
83
81
  const version = res.ref.split("@")[1];
84
- utils.logLabeledBullet(extensionsHelper_1.logPrefix, (0, marked_1.marked)(`[View in Console](${utils.consoleUrl(projectId, `/publisher/extensions/${extensionId}/v/${version}`)})`));
82
+ utils.logLabeledBullet(extensionsHelper_1.logPrefix, await (0, marked_1.marked)(`[View in Console](${utils.consoleUrl(projectId, `/publisher/extensions/${extensionId}/v/${version}`)})`));
85
83
  }
86
84
  return res;
87
85
  }
@@ -11,7 +11,7 @@ const logger_1 = require("../logger");
11
11
  const requirePermissions_1 = require("../requirePermissions");
12
12
  const utils = require("../utils");
13
13
  const marked_1 = require("marked");
14
- const TerminalRenderer = require("marked-terminal");
14
+ const marked_terminal_1 = require("marked-terminal");
15
15
  const FUNCTION_TYPE_REGEX = /\..+\.function/;
16
16
  exports.command = new command_1.Command("ext:info <extensionName>")
17
17
  .description("display information about an extension by name (extensionName@x.y.z for a specific version)")
@@ -107,10 +107,8 @@ exports.command = new command_1.Command("ext:info <extensionName>")
107
107
  logger_1.logger.info(lines.join("\n\n"));
108
108
  }
109
109
  else {
110
- marked_1.marked.setOptions({
111
- renderer: new TerminalRenderer(),
112
- });
113
- logger_1.logger.info((0, marked_1.marked)(lines.join("\n")));
110
+ marked_1.marked.use((0, marked_terminal_1.markedTerminal)());
111
+ logger_1.logger.info(await (0, marked_1.marked)(lines.join("\n")));
114
112
  utils.logLabeledBullet(extensionsHelper_1.logPrefix, `to install this extension, type ` +
115
113
  clc.bold(`firebase ext:install ${extensionName} --project=YOUR_PROJECT`));
116
114
  }
@@ -2,9 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.command = void 0;
4
4
  const clc = require("colorette");
5
- const marked_1 = require("marked");
6
5
  const semver = require("semver");
7
- const TerminalRenderer = require("marked-terminal");
8
6
  const displayExtensionInfo_1 = require("../extensions/displayExtensionInfo");
9
7
  const askUserForEventsConfig = require("../extensions/askUserForEventsConfig");
10
8
  const checkMinRequiredVersion_1 = require("../checkMinRequiredVersion");
@@ -25,9 +23,6 @@ const track_1 = require("../track");
25
23
  const prompt_1 = require("../prompt");
26
24
  const manifest = require("../extensions/manifest");
27
25
  const tos_1 = require("../extensions/tos");
28
- marked_1.marked.setOptions({
29
- renderer: new TerminalRenderer(),
30
- });
31
26
  exports.command = new command_1.Command("ext:install [extensionRef]")
32
27
  .description("add an uploaded extension to firebase.json if [publisherId/extensionId] is provided;" +
33
28
  "or, add a local extension if [localPath] is provided")
@@ -1,17 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.command = void 0;
4
- const marked_1 = require("marked");
5
- const TerminalRenderer = require("marked-terminal");
6
4
  const checkMinRequiredVersion_1 = require("../checkMinRequiredVersion");
7
5
  const command_1 = require("../command");
8
6
  const extensionsHelper_1 = require("../extensions/extensionsHelper");
9
7
  const requirePermissions_1 = require("../requirePermissions");
10
8
  const utils_1 = require("../utils");
11
9
  const manifest = require("../extensions/manifest");
12
- marked_1.marked.setOptions({
13
- renderer: new TerminalRenderer(),
14
- });
15
10
  exports.command = new command_1.Command("ext:uninstall <extensionInstanceId>")
16
11
  .description("uninstall an extension that is installed in your Firebase project by instance ID")
17
12
  .option("--local", "deprecated")
@@ -2,8 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.command = void 0;
4
4
  const clc = require("colorette");
5
- const marked_1 = require("marked");
6
- const TerminalRenderer = require("marked-terminal");
7
5
  const checkMinRequiredVersion_1 = require("../checkMinRequiredVersion");
8
6
  const command_1 = require("../command");
9
7
  const error_1 = require("../error");
@@ -20,9 +18,6 @@ const prompt_1 = require("../prompt");
20
18
  const manifest = require("../extensions/manifest");
21
19
  const askUserForEventsConfig = require("../extensions/askUserForEventsConfig");
22
20
  const tos_1 = require("../extensions/tos");
23
- marked_1.marked.setOptions({
24
- renderer: new TerminalRenderer(),
25
- });
26
21
  exports.command = new command_1.Command("ext:update <extensionInstanceId> [updateSource]")
27
22
  .description("update an existing extension instance to the latest version, or to a specific version if provided")
28
23
  .before(requirePermissions_1.requirePermissions, [
@@ -11,45 +11,42 @@ const requirePermissions_1 = require("../requirePermissions");
11
11
  const types_1 = require("../emulator/types");
12
12
  const commandUtils_1 = require("../emulator/commandUtils");
13
13
  const pretty_print_1 = require("../firestore/pretty-print");
14
+ const error_1 = require("../error");
14
15
  exports.command = new command_1.Command("firestore:backups:schedules:create")
15
16
  .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")
17
+ .option("-d, --database <databaseId>", "Database under which you want to create a schedule. Defaults to the (default) database")
18
+ .option("--retention <duration>", "duration string (e.g. 12h or 30d) for backup retention")
19
+ .option("--recurrence <recurrence>", "Recurrence settings; either DAILY or WEEKLY")
20
+ .option("--day-of-week <dayOfWeek>", "On which day of the week to perform backups; one of MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, or SUNDAY")
20
21
  .before(requirePermissions_1.requirePermissions, ["datastore.backupSchedules.create"])
21
22
  .before(commandUtils_1.warnEmulatorNotSupported, types_1.Emulators.FIRESTORE)
22
23
  .action(async (options) => {
23
24
  const printer = new pretty_print_1.PrettyPrint();
25
+ const helpCommandText = "See firebase firestore:backups:schedules:create --help for more info.";
24
26
  const databaseId = options.database || "(default)";
25
27
  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
+ throw new error_1.FirebaseError(`Missing required flag --retention. ${helpCommandText}`);
28
29
  }
29
30
  const retention = (0, backupUtils_1.calculateRetention)(options.retention);
30
31
  if (!options.recurrence) {
31
- logger_1.logger.error("Missing required flag --recurrence. See firebase firestore:backups:schedules:create --help for more info");
32
- return;
32
+ throw new error_1.FirebaseError(`Missing required flag --recurrence. ${helpCommandText}`);
33
33
  }
34
34
  const recurrenceType = options.recurrence;
35
35
  if (recurrenceType !== types.RecurrenceType.DAILY &&
36
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;
37
+ throw new error_1.FirebaseError(`Invalid value for flag --recurrence. ${helpCommandText}`);
39
38
  }
40
39
  let dailyRecurrence;
41
40
  let weeklyRecurrence;
42
41
  if (options.recurrence === types.RecurrenceType.DAILY) {
43
42
  dailyRecurrence = {};
44
43
  if (options.dayOfWeek) {
45
- logger_1.logger.error("--day-of-week should not be provided if --recurrence is DAILY");
46
- return;
44
+ throw new error_1.FirebaseError(`--day-of-week should not be provided if --recurrence is DAILY. ${helpCommandText}`);
47
45
  }
48
46
  }
49
47
  else if (options.recurrence === types.RecurrenceType.WEEKLY) {
50
48
  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;
49
+ throw new error_1.FirebaseError(`If --recurrence is WEEKLY, --day-of-week must be provided. ${helpCommandText}`);
53
50
  }
54
51
  const day = options.dayOfWeek;
55
52
  weeklyRecurrence = {
@@ -10,7 +10,7 @@ const firestore_1 = require("../gcp/firestore");
10
10
  const pretty_print_1 = require("../firestore/pretty-print");
11
11
  exports.command = new command_1.Command("firestore:backups:schedules:list")
12
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.")
13
+ .option("-d, --database <databaseId>", "Database whose schedules you wish to list. Defaults to the (default) database.")
14
14
  .before(requirePermissions_1.requirePermissions, ["datastore.backupSchedules.list"])
15
15
  .before(commandUtils_1.warnEmulatorNotSupported, types_1.Emulators.FIRESTORE)
16
16
  .action(async (options) => {
@@ -10,16 +10,17 @@ const requirePermissions_1 = require("../requirePermissions");
10
10
  const types_1 = require("../emulator/types");
11
11
  const commandUtils_1 = require("../emulator/commandUtils");
12
12
  const pretty_print_1 = require("../firestore/pretty-print");
13
+ const error_1 = require("../error");
13
14
  exports.command = new command_1.Command("firestore:backups:schedules:update <backupSchedule>")
14
15
  .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
+ .option("--retention <duration>", "duration string (e.g. 12h or 30d) for backup retention")
16
17
  .before(requirePermissions_1.requirePermissions, ["datastore.backupSchedules.update"])
17
18
  .before(commandUtils_1.warnEmulatorNotSupported, types_1.Emulators.FIRESTORE)
18
19
  .action(async (backupScheduleName, options) => {
19
20
  const printer = new pretty_print_1.PrettyPrint();
21
+ const helpCommandText = "See firebase firestore:backups:schedules:update --help for more info.";
20
22
  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
+ throw new error_1.FirebaseError(`Missing required flag --retention. ${helpCommandText}`);
23
24
  }
24
25
  const retention = (0, backupUtils_1.calculateRetention)(options.retention);
25
26
  const backupSchedule = await (0, firestore_1.updateBackupSchedule)(backupScheduleName, retention);
@@ -10,26 +10,29 @@ const requirePermissions_1 = require("../requirePermissions");
10
10
  const types_1 = require("../emulator/types");
11
11
  const commandUtils_1 = require("../emulator/commandUtils");
12
12
  const pretty_print_1 = require("../firestore/pretty-print");
13
+ const error_1 = require("../error");
13
14
  exports.command = new command_1.Command("firestore:databases:create <database>")
14
15
  .description("Create a database in your Firebase project.")
15
16
  .option("--location <locationId>", "Region to create database, for example 'nam5'. Run 'firebase firestore:locations' to get a list of eligible locations. (required)")
16
17
  .option("--delete-protection <deleteProtectionState>", "Whether or not to prevent deletion of database, for example 'ENABLED' or 'DISABLED'. Default is 'DISABLED'")
17
18
  .option("--point-in-time-recovery <enablement>", "Whether to enable the PITR feature on this database, for example 'ENABLED' or 'DISABLED'. Default is 'DISABLED'")
19
+ .option("-k, --kms-key-name <kmsKeyName>", "The resource ID of a Cloud KMS key. If set, the database created will be a " +
20
+ "Customer-managed Encryption Key (CMEK) database encrypted with this key. " +
21
+ "This feature is allowlist only in initial launch.")
18
22
  .before(requirePermissions_1.requirePermissions, ["datastore.databases.create"])
19
23
  .before(commandUtils_1.warnEmulatorNotSupported, types_1.Emulators.FIRESTORE)
20
24
  .action(async (database, options) => {
21
25
  const api = new fsi.FirestoreApi();
22
26
  const printer = new pretty_print_1.PrettyPrint();
27
+ const helpCommandText = "See firebase firestore:databases:create --help for more info.";
23
28
  if (!options.location) {
24
- logger_1.logger.error("Missing required flag --location. See firebase firestore:databases:create --help for more info.");
25
- return;
29
+ throw new error_1.FirebaseError(`Missing required flag --location. ${helpCommandText}`);
26
30
  }
27
31
  const type = types.DatabaseType.FIRESTORE_NATIVE;
28
32
  if (options.deleteProtection &&
29
33
  options.deleteProtection !== types.DatabaseDeleteProtectionStateOption.ENABLED &&
30
34
  options.deleteProtection !== types.DatabaseDeleteProtectionStateOption.DISABLED) {
31
- logger_1.logger.error("Invalid value for flag --delete-protection. See firebase firestore:databases:create --help for more info.");
32
- return;
35
+ throw new error_1.FirebaseError(`Invalid value for flag --delete-protection. ${helpCommandText}`);
33
36
  }
34
37
  const deleteProtectionState = options.deleteProtection === types.DatabaseDeleteProtectionStateOption.ENABLED
35
38
  ? types.DatabaseDeleteProtectionState.ENABLED
@@ -37,13 +40,27 @@ exports.command = new command_1.Command("firestore:databases:create <database>")
37
40
  if (options.pointInTimeRecovery &&
38
41
  options.pointInTimeRecovery !== types.PointInTimeRecoveryEnablementOption.ENABLED &&
39
42
  options.pointInTimeRecovery !== types.PointInTimeRecoveryEnablementOption.DISABLED) {
40
- logger_1.logger.error("Invalid value for flag --point-in-time-recovery. See firebase firestore:databases:create --help for more info.");
41
- return;
43
+ throw new error_1.FirebaseError(`Invalid value for flag --point-in-time-recovery. ${helpCommandText}`);
42
44
  }
43
45
  const pointInTimeRecoveryEnablement = options.pointInTimeRecovery === types.PointInTimeRecoveryEnablementOption.ENABLED
44
46
  ? types.PointInTimeRecoveryEnablement.ENABLED
45
47
  : types.PointInTimeRecoveryEnablement.DISABLED;
46
- const databaseResp = await api.createDatabase(options.project, database, options.location, type, deleteProtectionState, pointInTimeRecoveryEnablement);
48
+ let cmekConfig;
49
+ if (options.kmsKeyName) {
50
+ cmekConfig = {
51
+ kmsKeyName: options.kmsKeyName,
52
+ };
53
+ }
54
+ const createDatabaseReq = {
55
+ project: options.project,
56
+ databaseId: database,
57
+ locationId: options.location,
58
+ type,
59
+ deleteProtectionState,
60
+ pointInTimeRecoveryEnablement,
61
+ cmekConfig,
62
+ };
63
+ const databaseResp = await api.createDatabase(createDatabaseReq);
47
64
  if (options.json) {
48
65
  logger_1.logger.info(JSON.stringify(databaseResp, undefined, 2));
49
66
  }
@@ -9,6 +9,7 @@ const requirePermissions_1 = require("../requirePermissions");
9
9
  const types_1 = require("../emulator/types");
10
10
  const commandUtils_1 = require("../emulator/commandUtils");
11
11
  const pretty_print_1 = require("../firestore/pretty-print");
12
+ const error_1 = require("../error");
12
13
  exports.command = new command_1.Command("firestore:databases:restore")
13
14
  .description("Restore a Firestore database in your Firebase project.")
14
15
  .option("-d, --database <databaseID>", "ID of the database to restore into")
@@ -18,14 +19,13 @@ exports.command = new command_1.Command("firestore:databases:restore")
18
19
  .action(async (options) => {
19
20
  const api = new fsi.FirestoreApi();
20
21
  const printer = new pretty_print_1.PrettyPrint();
22
+ const helpCommandText = "See firebase firestore:databases:restore --help for more info.";
21
23
  if (!options.database) {
22
- logger_1.logger.error("Missing required flag --database. See firebase firestore:databases:restore --help for more info");
23
- return;
24
+ throw new error_1.FirebaseError(`Missing required flag --database. ${helpCommandText}`);
24
25
  }
25
26
  const databaseId = options.database;
26
27
  if (!options.backup) {
27
- logger_1.logger.error("Missing required flag --backup. See firebase firestore:databases:restore --help for more info");
28
- return;
28
+ throw new error_1.FirebaseError(`Missing required flag --backup. ${helpCommandText}`);
29
29
  }
30
30
  const backupName = options.backup;
31
31
  const databaseResp = await api.restoreDatabase(options.project, databaseId, backupName);
@@ -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 pretty_print_1 = require("../firestore/pretty-print");
13
+ const error_1 = require("../error");
13
14
  exports.command = new command_1.Command("firestore:databases:update <database>")
14
15
  .description("Update a database in your Firebase project. Must specify at least one property to update.")
15
16
  .option("--json", "Prints raw json response of the create API call if specified")
@@ -20,15 +21,14 @@ exports.command = new command_1.Command("firestore:databases:update <database>")
20
21
  .action(async (database, options) => {
21
22
  const api = new fsi.FirestoreApi();
22
23
  const printer = new pretty_print_1.PrettyPrint();
24
+ const helpCommandText = "See firebase firestore:databases:update --help for more info.";
23
25
  if (!options.deleteProtection && !options.pointInTimeRecovery) {
24
- logger_1.logger.error("Missing properties to update. See firebase firestore:databases:update --help for more info.");
25
- return;
26
+ throw new error_1.FirebaseError(`Missing properties to update. ${helpCommandText}`);
26
27
  }
27
28
  if (options.deleteProtection &&
28
29
  options.deleteProtection !== types.DatabaseDeleteProtectionStateOption.ENABLED &&
29
30
  options.deleteProtection !== types.DatabaseDeleteProtectionStateOption.DISABLED) {
30
- logger_1.logger.error("Invalid value for flag --delete-protection. See firebase firestore:databases:update --help for more info.");
31
- return;
31
+ throw new error_1.FirebaseError(`Invalid value for flag --delete-protection. ${helpCommandText}`);
32
32
  }
33
33
  let deleteProtectionState;
34
34
  if (options.deleteProtection === types.DatabaseDeleteProtectionStateOption.ENABLED) {
@@ -40,8 +40,7 @@ exports.command = new command_1.Command("firestore:databases:update <database>")
40
40
  if (options.pointInTimeRecovery &&
41
41
  options.pointInTimeRecovery !== types.PointInTimeRecoveryEnablementOption.ENABLED &&
42
42
  options.pointInTimeRecovery !== types.PointInTimeRecoveryEnablementOption.DISABLED) {
43
- logger_1.logger.error("Invalid value for flag --point-in-time-recovery. See firebase firestore:databases:update --help for more info.");
44
- return;
43
+ throw new error_1.FirebaseError(`Invalid value for flag --point-in-time-recovery. ${helpCommandText}`);
45
44
  }
46
45
  let pointInTimeRecoveryEnablement;
47
46
  if (options.pointInTimeRecovery === types.PointInTimeRecoveryEnablementOption.ENABLED) {
@@ -54,12 +54,15 @@ exports.command = new command_1.Command("functions:secrets:set <KEY>")
54
54
  (0, utils_1.logBullet)(`${endpointsToUpdate.length} functions are using stale version of secret ${secret.name}:\n\t` +
55
55
  endpointsToUpdate.map((e) => `${e.id}(${e.region})`).join("\n\t"));
56
56
  if (!options.force) {
57
- const confirm = await (0, prompt_1.promptOnce)({
58
- name: "redeploy",
59
- type: "confirm",
60
- default: true,
61
- message: `Do you want to re-deploy the functions and destroy the stale version of secret ${secret.name}?`,
62
- }, options);
57
+ let confirm = false;
58
+ if (!options.nonInteractive) {
59
+ confirm = await (0, prompt_1.promptOnce)({
60
+ name: "redeploy",
61
+ type: "confirm",
62
+ default: true,
63
+ message: `Do you want to re-deploy the functions and destroy the stale version of secret ${secret.name}?`,
64
+ }, options);
65
+ }
63
66
  if (!confirm) {
64
67
  (0, utils_1.logBullet)("Please deploy your functions for the change to take effect by running:\n\t" +
65
68
  clc.bold("firebase deploy --only functions"));
@@ -24,4 +24,6 @@ exports.command = new command_1.Command("help [command]")
24
24
  logger_1.logger.info(" To get help with a specific command, type", clc.bold("firebase help [command_name]"));
25
25
  logger_1.logger.info();
26
26
  }
27
+ logger_1.logger.info(" Privacy Policy: https://firebase.google.com/support/privacy");
28
+ logger_1.logger.info();
27
29
  });
@@ -65,7 +65,7 @@ exports.command = new command_1.Command("hosting:channel:create [channelId]")
65
65
  await (0, api_1.addAuthDomains)(projectId, [channel.url]);
66
66
  }
67
67
  catch (e) {
68
- (0, utils_1.logLabeledWarning)(LOG_TAG, (0, marked_1.marked)(`Unable to add channel domain to Firebase Auth. Visit the Firebase Console at ${(0, utils_1.consoleUrl)(projectId, "/authentication/providers")}`));
68
+ (0, utils_1.logLabeledWarning)(LOG_TAG, await (0, marked_1.marked)(`Unable to add channel domain to Firebase Auth. Visit the Firebase Console at ${(0, utils_1.consoleUrl)(projectId, "/authentication/providers")}`));
69
69
  logger_1.logger.debug("[hosting] unable to add auth domain", e);
70
70
  }
71
71
  logger_1.logger.info();
@@ -39,7 +39,7 @@ exports.command = new command_1.Command("hosting:channel:delete <channelId>")
39
39
  await (0, api_1.removeAuthDomain)(projectId, channel.url);
40
40
  }
41
41
  catch (e) {
42
- (0, utils_1.logLabeledWarning)("hosting:channel", (0, marked_1.marked)(`Unable to remove channel domain from Firebase Auth. Visit the Firebase Console at ${(0, utils_1.consoleUrl)(projectId, "/authentication/providers")}`));
42
+ (0, utils_1.logLabeledWarning)("hosting:channel", await (0, marked_1.marked)(`Unable to remove channel domain from Firebase Auth. Visit the Firebase Console at ${(0, utils_1.consoleUrl)(projectId, "/authentication/providers")}`));
43
43
  logger_1.logger.debug("[hosting] unable to remove auth domain", e);
44
44
  }
45
45
  }
@@ -133,7 +133,7 @@ async function syncAuthState(projectId, sites) {
133
133
  logger_1.logger.debug("[hosting] added auth domain for urls", urlNames);
134
134
  }
135
135
  catch (e) {
136
- (0, utils_1.logLabeledWarning)(LOG_TAG, (0, marked_1.marked)(`Unable to add channel domain to Firebase Auth. Visit the Firebase Console at ${(0, utils_1.consoleUrl)(projectId, "/authentication/providers")}`));
136
+ (0, utils_1.logLabeledWarning)(LOG_TAG, await (0, marked_1.marked)(`Unable to add channel domain to Firebase Auth. Visit the Firebase Console at ${(0, utils_1.consoleUrl)(projectId, "/authentication/providers")}`));
137
137
  logger_1.logger.debug("[hosting] unable to add auth domain", e);
138
138
  }
139
139
  try {
@@ -8,7 +8,6 @@ const error_1 = require("../error");
8
8
  const api_1 = require("../hosting/api");
9
9
  const utils = require("../utils");
10
10
  const requireAuth_1 = require("../requireAuth");
11
- const marked_1 = require("marked");
12
11
  const logger_1 = require("../logger");
13
12
  exports.command = new command_1.Command("hosting:clone <source> <targetChannel>")
14
13
  .description("clone a version from one site to another")
@@ -67,7 +66,7 @@ For example, to copy the content for a site \`my-site\` from a preview channel \
67
66
  await (0, api_1.addAuthDomains)(tProjectId, [tChannel.url]);
68
67
  }
69
68
  catch (e) {
70
- utils.logLabeledWarning("hosting:clone", (0, marked_1.marked)(`Unable to add channel domain to Firebase Auth. Visit the Firebase Console at ${utils.consoleUrl(targetSiteId, "/authentication/providers")}`));
69
+ utils.logLabeledWarning("hosting:clone", `Unable to add channel domain to Firebase Auth. Visit the Firebase Console at ${utils.consoleUrl(targetSiteId, "/authentication/providers")}`);
71
70
  logger_1.logger.debug("[hosting] unable to add auth domain", e);
72
71
  }
73
72
  }
@@ -200,17 +200,15 @@ function load(client) {
200
200
  client.setup.emulators.pubsub = loadCommand("setup-emulators-pubsub");
201
201
  client.setup.emulators.storage = loadCommand("setup-emulators-storage");
202
202
  client.setup.emulators.ui = loadCommand("setup-emulators-ui");
203
- if (experiments.isEnabled("dataconnect")) {
204
- client.dataconnect = {};
205
- client.setup.emulators.dataconnect = loadCommand("setup-emulators-dataconnect");
206
- client.dataconnect.services = {};
207
- client.dataconnect.services.list = loadCommand("dataconnect-services-list");
208
- client.dataconnect.sql = {};
209
- client.dataconnect.sql.diff = loadCommand("dataconnect-sql-diff");
210
- client.dataconnect.sql.migrate = loadCommand("dataconnect-sql-migrate");
211
- client.dataconnect.sdk = {};
212
- client.dataconnect.sdk.generate = loadCommand("dataconnect-sdk-generate");
213
- }
203
+ client.dataconnect = {};
204
+ client.setup.emulators.dataconnect = loadCommand("setup-emulators-dataconnect");
205
+ client.dataconnect.services = {};
206
+ client.dataconnect.services.list = loadCommand("dataconnect-services-list");
207
+ client.dataconnect.sql = {};
208
+ client.dataconnect.sql.diff = loadCommand("dataconnect-sql-diff");
209
+ client.dataconnect.sql.migrate = loadCommand("dataconnect-sql-migrate");
210
+ client.dataconnect.sdk = {};
211
+ client.dataconnect.sdk.generate = loadCommand("dataconnect-sdk-generate");
214
212
  client.target = loadCommand("target");
215
213
  client.target.apply = loadCommand("target-apply");
216
214
  client.target.clear = loadCommand("target-clear");