firebase-tools-with-isolate 13.11.2 → 13.15.0-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 (110) 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 +7 -1
  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 +55 -8
  35. package/lib/dataconnect/fileUtils.js +30 -7
  36. package/lib/dataconnect/filters.js +12 -1
  37. package/lib/dataconnect/load.js +9 -7
  38. package/lib/dataconnect/schemaMigration.js +21 -0
  39. package/lib/dataconnect/types.js +8 -1
  40. package/lib/deploy/dataconnect/prepare.js +16 -2
  41. package/lib/deploy/functions/build.js +10 -1
  42. package/lib/emulator/adminSdkConfig.test.js +16 -0
  43. package/lib/emulator/constants.js +1 -0
  44. package/lib/emulator/controller.js +3 -9
  45. package/lib/emulator/dataconnectEmulator.js +122 -18
  46. package/lib/emulator/downloadableEmulators.js +21 -22
  47. package/lib/emulator/eventarcEmulator.js +68 -18
  48. package/lib/emulator/functionsEmulator.js +89 -0
  49. package/lib/emulator/functionsEmulatorShared.js +4 -0
  50. package/lib/emulator/hub.js +1 -1
  51. package/lib/emulator/portUtils.js +9 -0
  52. package/lib/emulator/pubsubEmulator.js +1 -1
  53. package/lib/emulator/registry.js +1 -1
  54. package/lib/emulator/storage/apis/shared.js +2 -1
  55. package/lib/emulator/storage/persistence.js +5 -13
  56. package/lib/emulator/storage/rfc.js +9 -0
  57. package/lib/emulator/storage/rules/config.js +4 -2
  58. package/lib/experiments.js +8 -3
  59. package/lib/extensions/askUserForParam.js +1 -1
  60. package/lib/extensions/change-log.js +2 -4
  61. package/lib/extensions/displayExtensionInfo.js +0 -5
  62. package/lib/extensions/extensionsHelper.js +5 -7
  63. package/lib/extensions/provisioningHelper.js +1 -1
  64. package/lib/extensions/updateHelper.js +1 -2
  65. package/lib/extensions/warnings.js +2 -7
  66. package/lib/firestore/api-sort.test.js +74 -0
  67. package/lib/firestore/api.js +8 -7
  68. package/lib/firestore/backupUtils.test.js +18 -0
  69. package/lib/firestore/pretty-print.js +21 -1
  70. package/lib/firestore/pretty-print.test.js +61 -0
  71. package/lib/firestore/util.test.js +42 -0
  72. package/lib/frameworks/angular/utils.js +13 -5
  73. package/lib/frameworks/compose/discover/mockFileSystem.js +36 -0
  74. package/lib/frameworks/index.js +2 -6
  75. package/lib/frameworks/next/utils.js +2 -8
  76. package/lib/frameworks/nuxt/index.js +3 -3
  77. package/lib/functions/events/v2.js +2 -1
  78. package/lib/gcp/cloudsql/cloudsqladmin.js +6 -1
  79. package/lib/gcp/devConnect.js +36 -1
  80. package/lib/hosting/implicitInit.js +2 -2
  81. package/lib/init/features/dataconnect/index.js +97 -31
  82. package/lib/init/features/dataconnect/sdk.js +131 -0
  83. package/lib/init/features/firestore/indexes.js +2 -2
  84. package/lib/init/features/firestore/rules.js +2 -2
  85. package/lib/init/features/functions/javascript.js +6 -8
  86. package/lib/init/features/functions/python.js +4 -6
  87. package/lib/init/features/functions/typescript.js +8 -10
  88. package/lib/init/features/hosting/github.js +43 -21
  89. package/lib/init/features/hosting/index.js +3 -3
  90. package/lib/init/features/index.js +3 -1
  91. package/lib/init/features/storage.js +2 -2
  92. package/lib/init/index.js +1 -0
  93. package/lib/listFiles.js +1 -1
  94. package/lib/management/apps.js +2 -2
  95. package/lib/rc.js +1 -0
  96. package/lib/requireAuth.js +8 -3
  97. package/lib/rulesDeploy.js +14 -12
  98. package/lib/templates.js +23 -0
  99. package/lib/utils.js +2 -2
  100. package/package.json +25 -24
  101. package/schema/connector-yaml.json +36 -4
  102. package/schema/dataconnect-yaml.json +4 -0
  103. package/schema/firebase-config.json +0 -8
  104. package/templates/_gitignore +3 -0
  105. package/templates/init/dataconnect/connector.yaml +11 -0
  106. package/templates/init/dataconnect/dataconnect.yaml +2 -1
  107. package/templates/init/dataconnect/mutations.gql +19 -14
  108. package/templates/init/dataconnect/queries.gql +28 -23
  109. package/templates/init/dataconnect/schema.gql +1 -1
  110. package/lib/extensions/billingMigrationHelper.js +0 -61
@@ -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");
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.initAction = exports.command = void 0;
4
4
  const clc = require("colorette");
5
- const fs = require("fs");
6
5
  const os = require("os");
7
6
  const path = require("path");
8
7
  const command_1 = require("../command");
@@ -15,10 +14,10 @@ const requireAuth_1 = require("../requireAuth");
15
14
  const fsutils = require("../fsutils");
16
15
  const utils = require("../utils");
17
16
  const experiments_1 = require("../experiments");
17
+ const templates_1 = require("../templates");
18
18
  const homeDir = os.homedir();
19
- const TEMPLATE_ROOT = path.resolve(__dirname, "../../templates/");
20
- const BANNER_TEXT = fs.readFileSync(path.join(TEMPLATE_ROOT, "banner.txt"), "utf8");
21
- const GITIGNORE_TEMPLATE = fs.readFileSync(path.join(TEMPLATE_ROOT, "_gitignore"), "utf8");
19
+ const BANNER_TEXT = (0, templates_1.readTemplateSync)("banner.txt");
20
+ const GITIGNORE_TEMPLATE = (0, templates_1.readTemplateSync)("_gitignore");
22
21
  function isOutside(from, to) {
23
22
  return !!/^\.\./.exec(path.relative(from, to));
24
23
  }
@@ -47,6 +46,7 @@ const choices = [
47
46
  value: "hosting:github",
48
47
  name: "Hosting: Set up GitHub Action deploys",
49
48
  checked: false,
49
+ hidden: true,
50
50
  },
51
51
  {
52
52
  value: "storage",
@@ -68,6 +68,17 @@ const choices = [
68
68
  name: "Extensions: Set up an empty Extensions manifest",
69
69
  checked: false,
70
70
  },
71
+ {
72
+ value: "dataconnect",
73
+ name: "Data Connect: Set up a Firebase Data Connect service",
74
+ checked: false,
75
+ },
76
+ {
77
+ value: "dataconnect:sdk",
78
+ name: "Data Connect: Set up a generated SDK for your Firebase Data Connect service",
79
+ checked: false,
80
+ hidden: true,
81
+ },
71
82
  ];
72
83
  if ((0, experiments_1.isEnabled)("genkit")) {
73
84
  choices.push({
@@ -76,13 +87,6 @@ if ((0, experiments_1.isEnabled)("genkit")) {
76
87
  checked: false,
77
88
  });
78
89
  }
79
- if ((0, experiments_1.isEnabled)("dataconnect")) {
80
- choices.push({
81
- value: "dataconnect",
82
- name: "Data Connect: Set up a Firebase Data Connect service.",
83
- checked: false,
84
- });
85
- }
86
90
  const featureNames = choices.map((choice) => choice.value);
87
91
  const DESCRIPTION = `Interactively configure the current directory as a Firebase project or initialize new features in an already configured Firebase project directory.
88
92
 
@@ -163,7 +167,7 @@ function initAction(feature, options) {
163
167
  name: "features",
164
168
  message: "Which Firebase features do you want to set up for this directory? " +
165
169
  "Press Space to select features, then Enter to confirm your choices.",
166
- choices: choices,
170
+ choices: choices.filter((c) => !c.hidden),
167
171
  },
168
172
  ]);
169
173
  })
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.command = void 0;
4
- const _ = require("lodash");
5
4
  const clc = require("colorette");
6
5
  const command_1 = require("../command");
7
6
  const logger_1 = require("../logger");
@@ -40,7 +39,7 @@ exports.command = new command_1.Command("login")
40
39
  }
41
40
  }
42
41
  const useLocalhost = (0, utils_1.isCloudEnvironment)() ? false : options.localhost;
43
- const result = await auth.loginGoogle(useLocalhost, _.get(user, "email"));
42
+ const result = await auth.loginGoogle(useLocalhost, user?.email);
44
43
  configstore_1.configstore.set("user", result.user);
45
44
  configstore_1.configstore.set("tokens", result.tokens);
46
45
  configstore_1.configstore.set("loginScopes", result.scopes);
@@ -2,11 +2,30 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.command = void 0;
4
4
  const command_1 = require("../command");
5
- const download_1 = require("../emulator/download");
6
5
  const types_1 = require("../emulator/types");
6
+ const emulators_1 = require("../init/features/emulators");
7
+ const prompt_1 = require("../prompt");
8
+ const logger_1 = require("../logger");
9
+ const downloadableEmulators_1 = require("../emulator/downloadableEmulators");
7
10
  const NAME = types_1.Emulators.DATACONNECT;
8
11
  exports.command = new command_1.Command(`setup:emulators:${NAME}`)
9
12
  .description(`downloads the ${NAME} emulator`)
10
- .action(() => {
11
- return (0, download_1.downloadEmulator)(NAME);
13
+ .action(async (options) => {
14
+ await (0, downloadableEmulators_1.downloadIfNecessary)(NAME);
15
+ if (!options.config) {
16
+ logger_1.logger.info("Not currently in a Firebase project directory. Run this command from a project directory to configure the Data Connect emulator.");
17
+ return;
18
+ }
19
+ if (!options.nonInteractive) {
20
+ const dataconnectEmulatorConfig = options.rc.getDataconnect();
21
+ const defaultConnectionString = dataconnectEmulatorConfig?.postgres?.localConnectionString ?? emulators_1.DEFAULT_POSTGRES_CONNECTION;
22
+ const localConnectionString = await (0, prompt_1.promptOnce)({
23
+ type: "input",
24
+ name: "localConnectionString",
25
+ message: `What is the connection string of the local Postgres instance you would like to use with the Data Connect emulator?`,
26
+ default: defaultConnectionString,
27
+ });
28
+ options.rc.setDataconnect(localConnectionString);
29
+ }
30
+ logger_1.logger.info("Setup complete!");
12
31
  });
package/lib/config.js CHANGED
@@ -53,6 +53,11 @@ class Config {
53
53
  }
54
54
  }
55
55
  }
56
+ if (this._src.dataconnect?.location ||
57
+ (Array.isArray(this._src.dataconnect) && this._src.dataconnect.some((c) => c?.location))) {
58
+ utils.logLabeledWarning("dataconnect", "'location' has been moved from 'firebase.json' to 'dataconnect.yaml'. " +
59
+ "Please remove 'dataconnect.location' from 'firebase.json' and add it as top level field to 'dataconnect.yaml' instead ");
60
+ }
56
61
  }
57
62
  materialize(target) {
58
63
  const val = _.get(this._src, target);
@@ -12,7 +12,7 @@ const rimraf = require("rimraf");
12
12
  const utils = require("../utils");
13
13
  const JAR_CACHE_DIR = process.env.FIREBASE_CRASHLYTICS_BUILDTOOLS_PATH ||
14
14
  path.join(os.homedir(), ".cache", "firebase", "crashlytics", "buildtools");
15
- const JAR_VERSION = "3.0.0";
15
+ const JAR_VERSION = "3.0.2";
16
16
  const JAR_URL = `https://dl.google.com/android/maven2/com/google/firebase/firebase-crashlytics-buildtools/${JAR_VERSION}/firebase-crashlytics-buildtools-${JAR_VERSION}.jar`;
17
17
  async function fetchBuildtoolsJar() {
18
18
  if (process.env.CRASHLYTICS_LOCAL_JAR) {