firebase-tools 10.9.2 → 11.1.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 (181) hide show
  1. package/README.md +15 -9
  2. package/lib/accountImporter.js +92 -93
  3. package/lib/api.js +77 -218
  4. package/lib/apiv2.js +5 -4
  5. package/lib/appdistribution/client.js +16 -25
  6. package/lib/auth.js +69 -47
  7. package/lib/bin/firebase.js +42 -47
  8. package/lib/checkValidTargetFilters.js +13 -12
  9. package/lib/commands/appdistribution-distribute.js +2 -1
  10. package/lib/commands/appdistribution-testers-add.js +2 -1
  11. package/lib/commands/appdistribution-testers-remove.js +2 -1
  12. package/lib/commands/apps-android-sha-create.js +2 -1
  13. package/lib/commands/apps-android-sha-delete.js +2 -1
  14. package/lib/commands/apps-android-sha-list.js +2 -1
  15. package/lib/commands/apps-create.js +2 -1
  16. package/lib/commands/apps-list.js +2 -1
  17. package/lib/commands/apps-sdkconfig.js +8 -3
  18. package/lib/commands/auth-export.js +2 -1
  19. package/lib/commands/auth-import.js +7 -10
  20. package/lib/commands/crashlytics-symbols-upload.js +2 -1
  21. package/lib/commands/database-get.js +4 -3
  22. package/lib/commands/database-instances-create.js +2 -1
  23. package/lib/commands/database-instances-list.js +3 -3
  24. package/lib/commands/database-profile.js +2 -1
  25. package/lib/commands/database-push.js +2 -1
  26. package/lib/commands/database-remove.js +2 -1
  27. package/lib/commands/database-rules-canary.js +2 -1
  28. package/lib/commands/database-rules-get.js +2 -1
  29. package/lib/commands/database-rules-list.js +2 -1
  30. package/lib/commands/database-rules-release.js +2 -1
  31. package/lib/commands/database-rules-stage.js +2 -1
  32. package/lib/commands/database-set.js +2 -1
  33. package/lib/commands/database-settings-get.js +2 -1
  34. package/lib/commands/database-settings-set.js +2 -1
  35. package/lib/commands/database-update.js +2 -1
  36. package/lib/commands/deploy.js +23 -21
  37. package/lib/commands/emulators-exec.js +2 -1
  38. package/lib/commands/emulators-export.js +2 -1
  39. package/lib/commands/emulators-start.js +2 -1
  40. package/lib/commands/experimental-functions-shell.js +10 -8
  41. package/lib/commands/ext-configure.js +56 -120
  42. package/lib/commands/ext-dev-deprecate.js +2 -1
  43. package/lib/commands/ext-dev-emulators-exec.js +13 -7
  44. package/lib/commands/ext-dev-emulators-start.js +12 -27
  45. package/lib/commands/ext-dev-extension-delete.js +2 -1
  46. package/lib/commands/ext-dev-init.js +2 -1
  47. package/lib/commands/ext-dev-list.js +2 -1
  48. package/lib/commands/ext-dev-publish.js +2 -1
  49. package/lib/commands/ext-dev-register.js +2 -1
  50. package/lib/commands/ext-dev-undeprecate.js +2 -1
  51. package/lib/commands/ext-dev-unpublish.js +2 -1
  52. package/lib/commands/ext-dev-usage.js +2 -1
  53. package/lib/commands/ext-export.js +2 -1
  54. package/lib/commands/ext-info.js +2 -1
  55. package/lib/commands/ext-install.js +14 -198
  56. package/lib/commands/ext-list.js +2 -1
  57. package/lib/commands/ext-sources-create.js +2 -1
  58. package/lib/commands/ext-uninstall.js +9 -92
  59. package/lib/commands/ext-update.js +67 -225
  60. package/lib/commands/ext.js +2 -1
  61. package/lib/commands/firestore-delete.js +2 -1
  62. package/lib/commands/firestore-indexes-list.js +2 -1
  63. package/lib/commands/functions-config-clone.js +4 -3
  64. package/lib/commands/functions-config-export.js +2 -1
  65. package/lib/commands/functions-config-get.js +2 -1
  66. package/lib/commands/functions-config-set.js +2 -1
  67. package/lib/commands/functions-config-unset.js +2 -1
  68. package/lib/commands/functions-delete.js +2 -1
  69. package/lib/commands/functions-deletegcfartifacts.js +2 -1
  70. package/lib/commands/functions-list.js +2 -1
  71. package/lib/commands/functions-log.js +2 -1
  72. package/lib/commands/functions-secrets-access.js +2 -1
  73. package/lib/commands/functions-secrets-destroy.js +2 -1
  74. package/lib/commands/functions-secrets-get.js +2 -1
  75. package/lib/commands/functions-secrets-prune.js +2 -1
  76. package/lib/commands/functions-secrets-set.js +2 -1
  77. package/lib/commands/functions-shell.js +12 -10
  78. package/lib/commands/help.js +2 -1
  79. package/lib/commands/hosting-channel-create.js +2 -1
  80. package/lib/commands/hosting-channel-delete.js +2 -1
  81. package/lib/commands/hosting-channel-deploy.js +2 -1
  82. package/lib/commands/hosting-channel-list.js +2 -1
  83. package/lib/commands/hosting-channel-open.js +2 -1
  84. package/lib/commands/hosting-clone.js +2 -1
  85. package/lib/commands/hosting-disable.js +2 -1
  86. package/lib/commands/hosting-sites-create.js +2 -1
  87. package/lib/commands/hosting-sites-delete.js +2 -1
  88. package/lib/commands/hosting-sites-get.js +2 -1
  89. package/lib/commands/hosting-sites-list.js +2 -1
  90. package/lib/commands/index.js +23 -13
  91. package/lib/commands/init.js +47 -43
  92. package/lib/commands/login-add.js +2 -1
  93. package/lib/commands/login-ci.js +2 -1
  94. package/lib/commands/login-list.js +2 -1
  95. package/lib/commands/login-use.js +2 -1
  96. package/lib/commands/login.js +2 -1
  97. package/lib/commands/logout.js +2 -1
  98. package/lib/commands/open.js +2 -1
  99. package/lib/commands/projects-addfirebase.js +2 -1
  100. package/lib/commands/projects-create.js +2 -1
  101. package/lib/commands/projects-list.js +2 -1
  102. package/lib/commands/remoteconfig-get.js +2 -1
  103. package/lib/commands/remoteconfig-rollback.js +2 -1
  104. package/lib/commands/remoteconfig-versions-list.js +2 -1
  105. package/lib/commands/serve.js +29 -27
  106. package/lib/commands/setup-emulators-database.js +2 -1
  107. package/lib/commands/setup-emulators-firestore.js +2 -1
  108. package/lib/commands/setup-emulators-pubsub.js +2 -1
  109. package/lib/commands/setup-emulators-storage.js +2 -1
  110. package/lib/commands/setup-emulators-ui.js +2 -1
  111. package/lib/commands/target-apply.js +2 -1
  112. package/lib/commands/target-clear.js +2 -1
  113. package/lib/commands/target-remove.js +2 -1
  114. package/lib/commands/target.js +2 -1
  115. package/lib/commands/use.js +54 -52
  116. package/lib/config.js +3 -3
  117. package/lib/deploy/database/deploy.js +3 -2
  118. package/lib/deploy/database/index.js +8 -5
  119. package/lib/deploy/database/prepare.js +22 -19
  120. package/lib/deploy/database/release.js +12 -9
  121. package/lib/deploy/firestore/prepare.js +2 -2
  122. package/lib/deploy/functions/build.js +32 -20
  123. package/lib/deploy/functions/runtimes/discovery/v1alpha1.js +187 -54
  124. package/lib/deploy/functions/runtimes/node/parseTriggers.js +14 -2
  125. package/lib/deploy/functions/services/database.js +14 -0
  126. package/lib/deploy/functions/services/index.js +14 -0
  127. package/lib/deploy/index.js +3 -3
  128. package/lib/deploy/lifecycleHooks.js +23 -20
  129. package/lib/deploy/remoteconfig/functions.js +18 -14
  130. package/lib/deploy/remoteconfig/prepare.js +2 -2
  131. package/lib/emulator/auth/apiSpec.js +14 -46
  132. package/lib/emulator/auth/operations.js +6 -29
  133. package/lib/emulator/auth/state.js +2 -25
  134. package/lib/emulator/commandUtils.js +1 -1
  135. package/lib/emulator/controller.js +3 -3
  136. package/lib/emulator/databaseEmulator.js +9 -7
  137. package/lib/emulator/downloadableEmulators.js +6 -6
  138. package/lib/emulator/extensionsEmulator.js +7 -3
  139. package/lib/emulator/firestoreEmulator.js +10 -12
  140. package/lib/emulator/functionsEmulator.js +39 -42
  141. package/lib/emulator/hubClient.js +11 -22
  142. package/lib/emulator/hubExport.js +26 -16
  143. package/lib/emulator/portUtils.js +2 -0
  144. package/lib/emulator/storage/crc.js +3 -0
  145. package/lib/emulator/storage/rules/runtime.js +1 -1
  146. package/lib/errorOut.js +2 -2
  147. package/lib/extensions/extensionsHelper.js +4 -5
  148. package/lib/extensions/manifest.js +5 -11
  149. package/lib/firebaseConfigValidate.js +1 -1
  150. package/lib/firestore/checkDatabaseType.js +4 -5
  151. package/lib/firestore/indexes.js +17 -34
  152. package/lib/functions/events/v2.js +7 -1
  153. package/lib/functionsConfigClone.js +43 -41
  154. package/lib/gcp/cloudfunctionsv2.js +17 -2
  155. package/lib/gcp/iam.js +1 -1
  156. package/lib/gcp/index.js +10 -10
  157. package/lib/gcp/runtimeconfig.js +45 -47
  158. package/lib/gcp/storage.js +2 -4
  159. package/lib/hosting/cloudRunProxy.js +19 -15
  160. package/lib/index.js +29 -28
  161. package/lib/init/features/database.js +11 -5
  162. package/lib/init/features/functions/index.js +1 -1
  163. package/lib/init/features/functions/javascript.js +23 -20
  164. package/lib/init/features/functions/npm-dependencies.js +17 -14
  165. package/lib/init/features/functions/typescript.js +27 -24
  166. package/lib/init/features/hosting/github.js +5 -4
  167. package/lib/loadCJSON.js +9 -6
  168. package/lib/logError.js +15 -12
  169. package/lib/management/apps.js +47 -43
  170. package/lib/management/database.js +33 -31
  171. package/lib/management/projects.js +13 -7
  172. package/lib/parseBoltRules.js +15 -14
  173. package/lib/profileReport.js +503 -511
  174. package/lib/profiler.js +4 -4
  175. package/lib/requireAuth.js +0 -1
  176. package/lib/responseToError.js +8 -5
  177. package/lib/rtdb.js +31 -29
  178. package/lib/scopes.js +9 -9
  179. package/npm-shrinkwrap.json +1485 -670
  180. package/package.json +21 -22
  181. package/standalone/package.json +1 -1
@@ -1,55 +1,45 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.command = void 0;
3
4
  const clc = require("cli-color");
4
5
  const { marked } = require("marked");
5
- const ora = require("ora");
6
6
  const TerminalRenderer = require("marked-terminal");
7
- const askUserForConsent = require("../extensions/askUserForConsent");
8
7
  const displayExtensionInfo_1 = require("../extensions/displayExtensionInfo");
9
8
  const askUserForEventsConfig = require("../extensions/askUserForEventsConfig");
10
- const billingMigrationHelper_1 = require("../extensions/billingMigrationHelper");
11
- const checkProjectBilling_1 = require("../extensions/checkProjectBilling");
12
- const cloudbilling_1 = require("../gcp/cloudbilling");
13
9
  const checkMinRequiredVersion_1 = require("../checkMinRequiredVersion");
14
10
  const command_1 = require("../command");
15
11
  const error_1 = require("../error");
16
12
  const projectUtils_1 = require("../projectUtils");
17
13
  const extensionsApi = require("../extensions/extensionsApi");
18
- const secretsUtils = require("../extensions/secretsUtils");
19
- const provisioningHelper = require("../extensions/provisioningHelper");
20
14
  const refs = require("../extensions/refs");
21
15
  const warnings_1 = require("../extensions/warnings");
22
16
  const paramHelper = require("../extensions/paramHelper");
23
17
  const extensionsHelper_1 = require("../extensions/extensionsHelper");
24
- const updateHelper_1 = require("../extensions/updateHelper");
25
18
  const utils_1 = require("../extensions/utils");
26
19
  const requirePermissions_1 = require("../requirePermissions");
27
20
  const utils = require("../utils");
28
21
  const track_1 = require("../track");
29
- const logger_1 = require("../logger");
30
22
  const previews_1 = require("../previews");
31
23
  const manifest = require("../extensions/manifest");
32
- const paramHelper_1 = require("../extensions/paramHelper");
33
24
  marked.setOptions({
34
25
  renderer: new TerminalRenderer(),
35
26
  });
36
- exports.default = new command_1.Command("ext:install [extensionName]")
27
+ exports.command = new command_1.Command("ext:install [extensionName]")
37
28
  .description("install an official extension if [extensionName] or [extensionName@version] is provided; " +
38
29
  (previews_1.previews.extdev
39
30
  ? "install a local extension if [localPathOrUrl] or [url#root] is provided; install a published extension (not authored by Firebase) if [publisherId/extensionId] is provided "
40
31
  : "") +
41
32
  "or run with `-i` to see all available extensions.")
33
+ .option("--local", "deprecated")
42
34
  .withForce()
43
- .option("--params <paramsFile>", "name of params variables file with .env format.")
44
- .option("--local", "save to firebase.json rather than directly install to a Firebase project")
45
35
  .before(requirePermissions_1.requirePermissions, ["firebaseextensions.instances.create"])
46
36
  .before(extensionsHelper_1.ensureExtensionsApiEnabled)
47
37
  .before(checkMinRequiredVersion_1.checkMinRequiredVersion, "extMinVersion")
48
38
  .before(extensionsHelper_1.diagnoseAndFixProject)
49
39
  .action(async (extensionName, options) => {
50
- var _a, _b;
40
+ var _a;
51
41
  const projectId = (0, projectUtils_1.getProjectId)(options);
52
- const paramsEnvPath = ((_a = options.params) !== null && _a !== void 0 ? _a : "");
42
+ const paramsEnvPath = "";
53
43
  let learnMore = false;
54
44
  if (!extensionName) {
55
45
  if (options.interactive) {
@@ -67,6 +57,9 @@ exports.default = new command_1.Command("ext:install [extensionName]")
67
57
  if ((0, extensionsHelper_1.isUrlPath)(extensionName)) {
68
58
  throw new error_1.FirebaseError(`Installing with a source url is no longer supported in the CLI. Please use Firebase Console instead.`);
69
59
  }
60
+ if (options.local) {
61
+ utils.logLabeledWarning(extensionsHelper_1.logPrefix, "As of firebase-tools@11.0.0, the `--local` flag is no longer required, as it is the default behavior.");
62
+ }
70
63
  if ((0, extensionsHelper_1.isLocalPath)(extensionName)) {
71
64
  source = await (0, extensionsHelper_1.createSourceFromLocation)((0, projectUtils_1.needProjectId)({ projectId }), extensionName);
72
65
  (0, displayExtensionInfo_1.displayExtInfo)(extensionName, "", source.spec);
@@ -74,7 +67,7 @@ exports.default = new command_1.Command("ext:install [extensionName]")
74
67
  }
75
68
  else {
76
69
  void (0, track_1.track)("Extension Install", "Install by Extension Ref", options.interactive ? 1 : 0);
77
- extensionName = (0, extensionsHelper_1.canonicalizeRefInput)(extensionName);
70
+ extensionName = await (0, extensionsHelper_1.canonicalizeRefInput)(extensionName);
78
71
  extensionVersion = await extensionsApi.getExtensionVersion(extensionName);
79
72
  await infoExtensionVersion({
80
73
  extensionName,
@@ -91,7 +84,7 @@ exports.default = new command_1.Command("ext:install [extensionName]")
91
84
  if (!source && !extensionVersion) {
92
85
  throw new error_1.FirebaseError("Could not find a source. Please specify a valid source to continue.");
93
86
  }
94
- const spec = (_b = source === null || source === void 0 ? void 0 : source.spec) !== null && _b !== void 0 ? _b : extensionVersion === null || extensionVersion === void 0 ? void 0 : extensionVersion.spec;
87
+ const spec = (_a = source === null || source === void 0 ? void 0 : source.spec) !== null && _a !== void 0 ? _a : extensionVersion === null || extensionVersion === void 0 ? void 0 : extensionVersion.spec;
95
88
  if (!spec) {
96
89
  throw new error_1.FirebaseError(`Could not find the extension.yaml for extension '${clc.bold(extensionName)}'. Please make sure this is a valid extension and try again.`);
97
90
  }
@@ -100,31 +93,10 @@ exports.default = new command_1.Command("ext:install [extensionName]")
100
93
  `${spec.description}\n` +
101
94
  `View details: https://firebase.google.com/products/extensions/${spec.name}\n`);
102
95
  }
103
- if (options.local) {
104
- try {
105
- return installToManifest({
106
- paramsEnvPath,
107
- projectId,
108
- extensionName,
109
- source,
110
- extVersion: extensionVersion,
111
- nonInteractive: options.nonInteractive,
112
- force: options.force,
113
- });
114
- }
115
- catch (err) {
116
- if (!(err instanceof error_1.FirebaseError)) {
117
- throw new error_1.FirebaseError(`Error occurred saving the extension to manifest: ${err.message}`, {
118
- original: err,
119
- });
120
- }
121
- throw err;
122
- }
123
- }
124
96
  try {
125
- return installExtension({
97
+ return installToManifest({
126
98
  paramsEnvPath,
127
- projectId: projectId,
99
+ projectId,
128
100
  extensionName,
129
101
  source,
130
102
  extVersion: extensionVersion,
@@ -134,7 +106,7 @@ exports.default = new command_1.Command("ext:install [extensionName]")
134
106
  }
135
107
  catch (err) {
136
108
  if (!(err instanceof error_1.FirebaseError)) {
137
- throw new error_1.FirebaseError(`Error occurred installing the extension: ${err.message}`, {
109
+ throw new error_1.FirebaseError(`Error occurred saving the extension to manifest: ${err.message}`, {
138
110
  original: err,
139
111
  });
140
112
  }
@@ -186,161 +158,5 @@ async function installToManifest(options) {
186
158
  extensionSpec: spec,
187
159
  },
188
160
  ], config, { nonInteractive, force: force !== null && force !== void 0 ? force : false });
189
- manifest.showPreviewWarning();
190
- }
191
- async function installExtension(options) {
192
- const { extensionName, source, extVersion, paramsEnvPath, nonInteractive, force } = options;
193
- const projectId = (0, projectUtils_1.needProjectId)({ projectId: options.projectId });
194
- const spec = (source === null || source === void 0 ? void 0 : source.spec) || (extVersion === null || extVersion === void 0 ? void 0 : extVersion.spec);
195
- if (!spec) {
196
- throw new error_1.FirebaseError(`Could not find the extension.yaml for ${extensionName}. Please make sure this is a valid extension and try again.`);
197
- }
198
- const spinner = ora();
199
- try {
200
- await provisioningHelper.checkProductsProvisioned(projectId, spec);
201
- const usesSecrets = secretsUtils.usesSecrets(spec);
202
- if (spec.billingRequired || usesSecrets) {
203
- const enabled = await (0, cloudbilling_1.checkBillingEnabled)(projectId);
204
- if (!enabled && nonInteractive) {
205
- throw new error_1.FirebaseError(`This extension requires the Blaze plan, but project ${projectId} is not on the Blaze plan. ` +
206
- marked("Please visit https://console.cloud.google.com/billing/linkedaccount?project=${projectId} to upgrade your project."));
207
- }
208
- else if (!enabled) {
209
- await (0, billingMigrationHelper_1.displayNode10CreateBillingNotice)(spec, false);
210
- await (0, checkProjectBilling_1.enableBilling)(projectId);
211
- }
212
- else {
213
- await (0, billingMigrationHelper_1.displayNode10CreateBillingNotice)(spec, !nonInteractive);
214
- }
215
- }
216
- const apis = spec.apis || [];
217
- if (usesSecrets) {
218
- apis.push({
219
- apiName: "secretmanager.googleapis.com",
220
- reason: `To access and manage secrets which are used by this extension. By using this product you agree to the terms and conditions of the following license: https://console.cloud.google.com/tos?id=cloud&project=${projectId}`,
221
- });
222
- }
223
- if (spec.events && spec.events.length > 0) {
224
- apis.push({
225
- apiName: "eventarc.googleapis.com",
226
- reason: `When events are enabled, the Eventarc API is required to provision an event channel and publish events.`,
227
- });
228
- }
229
- if (apis.length) {
230
- askUserForConsent.displayApis(spec.displayName || spec.name, projectId, apis);
231
- const consented = await (0, extensionsHelper_1.confirm)({ nonInteractive, force, default: true });
232
- if (!consented) {
233
- throw new error_1.FirebaseError("Without explicit consent for the APIs listed, we cannot deploy this extension.");
234
- }
235
- }
236
- if (usesSecrets) {
237
- await secretsUtils.ensureSecretManagerApiEnabled(options);
238
- }
239
- const roles = spec.roles ? spec.roles.map((role) => role.role) : [];
240
- if (roles.length) {
241
- await askUserForConsent.displayRoles(spec.displayName || spec.name, projectId, roles);
242
- const consented = await (0, extensionsHelper_1.confirm)({ nonInteractive, force, default: true });
243
- if (!consented) {
244
- throw new error_1.FirebaseError("Without explicit consent for the roles listed, we cannot deploy this extension.");
245
- }
246
- }
247
- let instanceId = spec.name;
248
- let choice;
249
- const anotherInstanceExists = await (0, extensionsHelper_1.instanceIdExists)(projectId, instanceId);
250
- if (anotherInstanceExists) {
251
- if (!nonInteractive) {
252
- choice = await (0, extensionsHelper_1.promptForRepeatInstance)(projectId, spec.name);
253
- }
254
- else if (nonInteractive && force) {
255
- choice = "updateExisting";
256
- }
257
- else {
258
- throw new error_1.FirebaseError(`An extension with the ID '${clc.bold(extensionName)}' already exists in the project '${clc.bold(projectId)}'.` +
259
- ` To update or reconfigure this instance instead, rerun this command with the --force flag.`);
260
- }
261
- }
262
- else {
263
- choice = "installNew";
264
- }
265
- let paramBindingOptions;
266
- let paramBindings;
267
- let eventsConfig;
268
- switch (choice) {
269
- case "installNew":
270
- instanceId = await (0, extensionsHelper_1.promptForValidInstanceId)(`${instanceId}-${(0, utils_1.getRandomString)(4)}`);
271
- paramBindingOptions = await paramHelper.getParams({
272
- projectId,
273
- paramSpecs: spec.params,
274
- nonInteractive,
275
- paramsEnvPath,
276
- instanceId,
277
- });
278
- eventsConfig = spec.events
279
- ? await askUserForEventsConfig.askForEventsConfig(spec.events, projectId, instanceId)
280
- : undefined;
281
- paramBindings = (0, paramHelper_1.getBaseParamBindings)(paramBindingOptions);
282
- spinner.text = "Installing your extension instance. This usually takes 3 to 5 minutes...";
283
- spinner.start();
284
- await extensionsApi.createInstance({
285
- projectId,
286
- instanceId,
287
- extensionSource: source,
288
- extensionVersionRef: extVersion === null || extVersion === void 0 ? void 0 : extVersion.ref,
289
- params: paramBindings,
290
- allowedEventTypes: eventsConfig === null || eventsConfig === void 0 ? void 0 : eventsConfig.allowedEventTypes,
291
- eventarcChannel: eventsConfig === null || eventsConfig === void 0 ? void 0 : eventsConfig.channel,
292
- });
293
- spinner.stop();
294
- utils.logLabeledSuccess(extensionsHelper_1.logPrefix, `Successfully installed your instance of ${clc.bold(spec.displayName || spec.name)}! ` +
295
- `Its Instance ID is ${clc.bold(instanceId)}.`);
296
- break;
297
- case "updateExisting":
298
- paramBindingOptions = await paramHelper.getParams({
299
- projectId,
300
- paramSpecs: spec.params,
301
- nonInteractive,
302
- paramsEnvPath,
303
- instanceId,
304
- });
305
- eventsConfig = spec.events
306
- ? await askUserForEventsConfig.askForEventsConfig(spec.events, projectId, instanceId)
307
- : undefined;
308
- paramBindings = (0, paramHelper_1.getBaseParamBindings)(paramBindingOptions);
309
- spinner.text = "Updating your extension instance. This usually takes 3 to 5 minutes...";
310
- spinner.start();
311
- const updateOptions = {
312
- projectId,
313
- instanceId,
314
- source,
315
- canEmitEvents: eventsConfig ? true : false,
316
- eventarcChannel: eventsConfig === null || eventsConfig === void 0 ? void 0 : eventsConfig.channel,
317
- allowedEventTypes: eventsConfig === null || eventsConfig === void 0 ? void 0 : eventsConfig.allowedEventTypes,
318
- extRef: extVersion === null || extVersion === void 0 ? void 0 : extVersion.ref,
319
- params: paramBindings,
320
- };
321
- await (0, updateHelper_1.update)(updateOptions);
322
- spinner.stop();
323
- utils.logLabeledSuccess(extensionsHelper_1.logPrefix, `Successfully updated your instance of ${clc.bold(spec.displayName || spec.name)}! ` +
324
- `Its Instance ID is ${clc.bold(instanceId)}.`);
325
- break;
326
- case "cancel":
327
- return;
328
- }
329
- utils.logLabeledBullet(extensionsHelper_1.logPrefix, marked("Go to the Firebase console to view instructions for using your extension, " +
330
- `which may include some required post-installation tasks: ${utils.consoleUrl(projectId, `/extensions/instances/${instanceId}?tab=usage`)}`));
331
- logger_1.logger.info(marked("You can run `firebase ext` to view available Firebase Extensions commands, " +
332
- "including those to update, reconfigure, or delete your installed extension."));
333
- manifest.showDeprecationWarning();
334
- }
335
- catch (err) {
336
- if (spinner.isSpinning) {
337
- spinner.fail();
338
- }
339
- if (err instanceof error_1.FirebaseError) {
340
- throw err;
341
- }
342
- throw new error_1.FirebaseError(`Error occurred installing extension: ${err.message}`, {
343
- original: err,
344
- });
345
- }
161
+ manifest.showPostDeprecationNotice();
346
162
  }
@@ -1,12 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.command = void 0;
3
4
  const checkMinRequiredVersion_1 = require("../checkMinRequiredVersion");
4
5
  const command_1 = require("../command");
5
6
  const projectUtils_1 = require("../projectUtils");
6
7
  const listExtensions_1 = require("../extensions/listExtensions");
7
8
  const extensionsHelper_1 = require("../extensions/extensionsHelper");
8
9
  const requirePermissions_1 = require("../requirePermissions");
9
- module.exports = new command_1.Command("ext:list")
10
+ exports.command = new command_1.Command("ext:list")
10
11
  .description("list all the extensions that are installed in your Firebase project")
11
12
  .before(requirePermissions_1.requirePermissions, ["firebaseextensions.instances.list"])
12
13
  .before(extensionsHelper_1.ensureExtensionsApiEnabled)
@@ -1,12 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.command = void 0;
3
4
  const checkMinRequiredVersion_1 = require("../checkMinRequiredVersion");
4
5
  const command_1 = require("../command");
5
6
  const projectUtils_1 = require("../projectUtils");
6
7
  const logger_1 = require("../logger");
7
8
  const extensionsHelper_1 = require("../extensions/extensionsHelper");
8
9
  const requirePermissions_1 = require("../requirePermissions");
9
- exports.default = new command_1.Command("ext:sources:create <sourceLocation>")
10
+ exports.command = new command_1.Command("ext:sources:create <sourceLocation>")
10
11
  .description(`create a extension source from sourceLocation`)
11
12
  .help("sourceLocation can be a local directory containing an extension, or URL pointing to a zipped extension. " +
12
13
  'If using a URL, you can specify a root folder for the extension by adding "#<extensionRoot>". ' +
@@ -1,113 +1,30 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const _ = require("lodash");
4
- const clc = require("cli-color");
5
- const ora = require("ora");
3
+ exports.command = void 0;
6
4
  const { marked } = require("marked");
7
5
  const TerminalRenderer = require("marked-terminal");
8
6
  const checkMinRequiredVersion_1 = require("../checkMinRequiredVersion");
9
7
  const command_1 = require("../command");
10
- const error_1 = require("../error");
11
- const projectUtils_1 = require("../projectUtils");
12
- const extensionsApi = require("../extensions/extensionsApi");
13
- const secretsUtils = require("../extensions/secretsUtils");
14
8
  const extensionsHelper_1 = require("../extensions/extensionsHelper");
15
- const prompt_1 = require("../prompt");
16
9
  const requirePermissions_1 = require("../requirePermissions");
17
- const utils = require("../utils");
18
- const logger_1 = require("../logger");
10
+ const utils_1 = require("../utils");
19
11
  const manifest = require("../extensions/manifest");
20
12
  marked.setOptions({
21
13
  renderer: new TerminalRenderer(),
22
14
  });
23
- exports.default = new command_1.Command("ext:uninstall <extensionInstanceId>")
15
+ exports.command = new command_1.Command("ext:uninstall <extensionInstanceId>")
24
16
  .description("uninstall an extension that is installed in your Firebase project by instance ID")
17
+ .option("--local", "deprecated")
25
18
  .withForce()
26
- .option("--local", "remove from firebase.json rather than directly uninstall from a Firebase project")
27
19
  .before(requirePermissions_1.requirePermissions, ["firebaseextensions.instances.delete"])
28
20
  .before(extensionsHelper_1.ensureExtensionsApiEnabled)
29
21
  .before(checkMinRequiredVersion_1.checkMinRequiredVersion, "extMinVersion")
30
22
  .before(extensionsHelper_1.diagnoseAndFixProject)
31
- .action(async (instanceId, options) => {
23
+ .action((instanceId, options) => {
32
24
  if (options.local) {
33
- const config = manifest.loadConfig(options);
34
- manifest.removeFromManifest(instanceId, config);
35
- manifest.showPreviewWarning();
36
- return;
25
+ (0, utils_1.logLabeledWarning)(extensionsHelper_1.logPrefix, "As of firebase-tools@11.0.0, the `--local` flag is no longer required, as it is the default behavior.");
37
26
  }
38
- const projectId = (0, projectUtils_1.needProjectId)(options);
39
- let instance;
40
- try {
41
- instance = await extensionsApi.getInstance(projectId, instanceId);
42
- }
43
- catch (err) {
44
- if (err.status === 404) {
45
- return utils.reject(`No extension instance ${instanceId} in project ${projectId}.`, {
46
- exit: 1,
47
- });
48
- }
49
- throw err;
50
- }
51
- if (_.get(instance, "config.source.spec.name") === "pubsub-stream-bigquery") {
52
- return consoleUninstallOnly(projectId, instanceId);
53
- }
54
- if (!options.force) {
55
- const serviceAccountMessage = `Uninstalling deletes the service account used by this extension instance:\n${clc.bold(instance.serviceAccountEmail)}\n\n`;
56
- const managedSecrets = await secretsUtils.getManagedSecrets(instance);
57
- const resourcesMessage = _.get(instance, "config.source.spec.resources", []).length
58
- ? "Uninstalling deletes all extension resources created for this extension instance:\n" +
59
- instance.config.source.spec.resources
60
- .map((resource) => clc.bold(`- ${extensionsHelper_1.resourceTypeToNiceName[resource.type] || resource.type}: ${resource.name} \n`))
61
- .join("") +
62
- managedSecrets
63
- .map(secretsUtils.prettySecretName)
64
- .map((s) => clc.bold(`- Secret: ${s}\n`))
65
- .join("") +
66
- "\n"
67
- : "";
68
- const artifactsMessage = `The following ${clc.bold("will not")} be deleted:\n` +
69
- "Any artifacts (for example, stored images) created by this extension instance.\n" +
70
- "Any other project resources with which this extension instance interacted.\n";
71
- const extensionDeletionMessage = `Here's what will happen when you uninstall ${clc.bold(instanceId)} from project ${clc.bold(projectId)}. Be aware that this cannot be undone.\n\n` +
72
- `${serviceAccountMessage}` +
73
- `${resourcesMessage}` +
74
- `${artifactsMessage}`;
75
- logger_1.logger.info(extensionDeletionMessage);
76
- const confirmedExtensionDeletion = await (0, prompt_1.promptOnce)({
77
- type: "confirm",
78
- default: true,
79
- message: "Are you sure that you wish to uninstall this extension?",
80
- });
81
- if (!confirmedExtensionDeletion) {
82
- return utils.reject("Command aborted.", { exit: 1 });
83
- }
84
- }
85
- const spinner = ora(` ${clc.green.bold(extensionsHelper_1.logPrefix)}: uninstalling ${clc.bold(instanceId)}. This usually takes 1 to 2 minutes...`);
86
- spinner.start();
87
- try {
88
- spinner.info();
89
- spinner.text = ` ${clc.green.bold(extensionsHelper_1.logPrefix)}: deleting your extension instance's resources.`;
90
- spinner.start();
91
- await extensionsApi.deleteInstance(projectId, instanceId);
92
- spinner.succeed(` ${clc.green.bold(extensionsHelper_1.logPrefix)}: deleted your extension instance's resources.`);
93
- }
94
- catch (err) {
95
- if (spinner.isSpinning) {
96
- spinner.fail();
97
- }
98
- if (err instanceof error_1.FirebaseError) {
99
- throw err;
100
- }
101
- return utils.reject(`Error occurred uninstalling extension ${instanceId}`, { original: err });
102
- }
103
- utils.logLabeledSuccess(extensionsHelper_1.logPrefix, `uninstalled ${clc.bold(instanceId)}`);
104
- manifest.showDeprecationWarning();
27
+ const config = manifest.loadConfig(options);
28
+ manifest.removeFromManifest(instanceId, config);
29
+ manifest.showPostDeprecationNotice();
105
30
  });
106
- function consoleUninstallOnly(projectId, instanceId) {
107
- const instanceURL = `https://console.firebase.google.com/project/${projectId}/extensions/instances/${instanceId}`;
108
- const consoleUninstall = "This extension has additional uninstall checks that are not currently supported by the CLI, and can only be uninstalled through the Firebase Console. " +
109
- `Please visit **[${instanceURL}](${instanceURL})** to uninstall this extension.`;
110
- logger_1.logger.info("\n");
111
- utils.logLabeledWarning(extensionsHelper_1.logPrefix, marked(consoleUninstall));
112
- return Promise.resolve();
113
- }