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,19 +1,13 @@
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
- const _ = require("lodash");
5
5
  const { marked } = require("marked");
6
- const ora = require("ora");
7
6
  const TerminalRenderer = require("marked-terminal");
8
7
  const checkMinRequiredVersion_1 = require("../checkMinRequiredVersion");
9
8
  const command_1 = require("../command");
10
9
  const error_1 = require("../error");
11
- const billingMigrationHelper_1 = require("../extensions/billingMigrationHelper");
12
- const checkProjectBilling_1 = require("../extensions/checkProjectBilling");
13
- const cloudbilling_1 = require("../gcp/cloudbilling");
14
10
  const extensionsApi = require("../extensions/extensionsApi");
15
- const secretsUtils = require("../extensions/secretsUtils");
16
- const provisioningHelper = require("../extensions/provisioningHelper");
17
11
  const extensionsHelper_1 = require("../extensions/extensionsHelper");
18
12
  const paramHelper = require("../extensions/paramHelper");
19
13
  const updateHelper_1 = require("../extensions/updateHelper");
@@ -27,7 +21,7 @@ const askUserForEventsConfig = require("../extensions/askUserForEventsConfig");
27
21
  marked.setOptions({
28
22
  renderer: new TerminalRenderer(),
29
23
  });
30
- exports.default = new command_1.Command("ext:update <extensionInstanceId> [updateSource]")
24
+ exports.command = new command_1.Command("ext:update <extensionInstanceId> [updateSource]")
31
25
  .description(previews_1.previews.extdev
32
26
  ? "update an existing extension instance to the latest version or from a local or URL source"
33
27
  : "update an existing extension instance to the latest version")
@@ -38,228 +32,76 @@ exports.default = new command_1.Command("ext:update <extensionInstanceId> [updat
38
32
  .before(extensionsHelper_1.ensureExtensionsApiEnabled)
39
33
  .before(checkMinRequiredVersion_1.checkMinRequiredVersion, "extMinVersion")
40
34
  .before(extensionsHelper_1.diagnoseAndFixProject)
35
+ .option("--local", "deprecated")
41
36
  .withForce()
42
- .option("--params <paramsFile>", "name of params variables file with .env format.")
43
- .option("--local", "save the update to firebase.json rather than directly update an existing Extension instance on a Firebase project")
44
37
  .action(async (instanceId, updateSource, options) => {
45
- var _a, _b;
38
+ const projectId = (0, projectUtils_1.getProjectId)(options);
39
+ const config = manifest.loadConfig(options);
46
40
  if (options.local) {
47
- const projectId = (0, projectUtils_1.getProjectId)(options);
48
- const config = manifest.loadConfig(options);
49
- const oldRefOrPath = manifest.getInstanceTarget(instanceId, config);
50
- if ((0, extensionsHelper_1.isLocalPath)(oldRefOrPath)) {
51
- throw new error_1.FirebaseError(`Updating an extension with local source is not neccessary. ` +
52
- `Rerun "firebase deploy" or restart the emulator after making changes to your local extension source. ` +
53
- `If you've edited the extension param spec, you can edit an extension instance's params ` +
54
- `interactively by running "firebase ext:configure --local {instance-id}"`);
55
- }
56
- const oldRef = manifest.getInstanceRef(instanceId, config);
57
- const oldExtensionVersion = await extensionsApi.getExtensionVersion(refs.toExtensionVersionRef(oldRef));
58
- updateSource = (0, updateHelper_1.inferUpdateSource)(updateSource, refs.toExtensionRef(oldRef));
59
- const newSourceOrigin = (0, extensionsHelper_1.getSourceOrigin)(updateSource);
60
- if (![extensionsHelper_1.SourceOrigin.PUBLISHED_EXTENSION, extensionsHelper_1.SourceOrigin.PUBLISHED_EXTENSION_VERSION].includes(newSourceOrigin)) {
61
- throw new error_1.FirebaseError(`Only updating to a published extension version is allowed`);
62
- }
63
- const newExtensionVersion = await extensionsApi.getExtensionVersion(updateSource);
64
- if (oldExtensionVersion.ref === newExtensionVersion.ref) {
65
- utils.logLabeledBullet(extensionsHelper_1.logPrefix, `${clc.bold(instanceId)} is already up to date. Its version is ${clc.bold(newExtensionVersion.ref)}.`);
66
- return;
67
- }
68
- utils.logLabeledBullet(extensionsHelper_1.logPrefix, `Updating ${clc.bold(instanceId)} from version ${clc.bold(oldExtensionVersion.ref)} to version ${clc.bold(newExtensionVersion.ref)}.`);
69
- if (!(await (0, extensionsHelper_1.confirm)({
70
- nonInteractive: options.nonInteractive,
71
- force: options.force,
72
- default: false,
73
- }))) {
74
- utils.logLabeledBullet(extensionsHelper_1.logPrefix, "Update aborted.");
75
- return;
76
- }
77
- const oldParamValues = manifest.readInstanceParam({
78
- instanceId,
79
- projectDir: config.projectDir,
80
- });
81
- const newParamBindingOptions = await paramHelper.getParamsForUpdate({
82
- spec: oldExtensionVersion.spec,
83
- newSpec: newExtensionVersion.spec,
84
- currentParams: oldParamValues,
85
- projectId,
86
- paramsEnvPath: ((_a = options.params) !== null && _a !== void 0 ? _a : ""),
87
- nonInteractive: options.nonInteractive,
88
- instanceId,
89
- });
90
- const eventsConfig = newExtensionVersion.spec.events
91
- ? await askUserForEventsConfig.askForEventsConfig(newExtensionVersion.spec.events, "${param:PROJECT_ID}", instanceId)
92
- : undefined;
93
- if (eventsConfig) {
94
- newParamBindingOptions.EVENTARC_CHANNEL = { baseValue: eventsConfig.channel };
95
- newParamBindingOptions.ALLOWED_EVENT_TYPES = {
96
- baseValue: eventsConfig.allowedEventTypes.join(","),
97
- };
98
- }
99
- await manifest.writeToManifest([
100
- {
101
- instanceId,
102
- ref: refs.parse(newExtensionVersion.ref),
103
- params: newParamBindingOptions,
104
- extensionSpec: newExtensionVersion.spec,
105
- extensionVersion: newExtensionVersion,
106
- },
107
- ], config, {
108
- nonInteractive: options.nonInteractive,
109
- force: true,
110
- });
111
- manifest.showPreviewWarning();
112
- return;
41
+ 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.");
113
42
  }
114
- const spinner = ora(`Updating ${clc.bold(instanceId)}. This usually takes 3 to 5 minutes...`);
115
- try {
116
- const projectId = (0, projectUtils_1.needProjectId)(options);
117
- const existingInstance = await extensionsApi.getInstance(projectId, instanceId);
118
- const existingSpec = existingInstance.config.source.spec;
119
- if (existingInstance.config.source.state === "DELETED") {
120
- throw new error_1.FirebaseError(`Instance '${clc.bold(instanceId)}' cannot be updated anymore because the underlying extension was unpublished from Firebase's registry of extensions. Going forward, you will only be able to re-configure or uninstall this instance.`);
121
- }
122
- const existingParams = existingInstance.config.params;
123
- const existingSource = existingInstance.config.source.name;
124
- if (existingInstance.config.extensionRef) {
125
- updateSource = (0, updateHelper_1.inferUpdateSource)(updateSource, existingInstance.config.extensionRef);
126
- }
127
- let newSourceName;
128
- const existingSourceOrigin = await (0, updateHelper_1.getExistingSourceOrigin)(projectId, instanceId, existingSpec.name, existingSource);
129
- const newSourceOrigin = (0, extensionsHelper_1.getSourceOrigin)(updateSource);
130
- const validUpdate = isValidUpdate(existingSourceOrigin, newSourceOrigin);
131
- if (!validUpdate) {
132
- throw new error_1.FirebaseError(`Cannot update from a(n) ${existingSourceOrigin} to a(n) ${newSourceOrigin}. Please provide a new source that is a(n) ${existingSourceOrigin} and try again.`);
133
- }
134
- switch (newSourceOrigin) {
135
- case extensionsHelper_1.SourceOrigin.LOCAL:
136
- if (previews_1.previews.extdev) {
137
- newSourceName = await (0, updateHelper_1.updateFromLocalSource)(projectId, instanceId, updateSource, existingSpec);
138
- break;
139
- }
140
- case extensionsHelper_1.SourceOrigin.URL:
141
- if (previews_1.previews.extdev) {
142
- newSourceName = await (0, updateHelper_1.updateFromUrlSource)(projectId, instanceId, updateSource, existingSpec);
143
- break;
144
- }
145
- case extensionsHelper_1.SourceOrigin.PUBLISHED_EXTENSION_VERSION:
146
- newSourceName = await (0, updateHelper_1.updateToVersionFromPublisherSource)(projectId, instanceId, updateSource, existingSpec);
147
- break;
148
- case extensionsHelper_1.SourceOrigin.PUBLISHED_EXTENSION:
149
- newSourceName = await (0, updateHelper_1.updateFromPublisherSource)(projectId, instanceId, updateSource, existingSpec);
150
- break;
151
- default:
152
- throw new error_1.FirebaseError(`Unknown source '${clc.bold(updateSource)}.'`);
153
- }
154
- if (!(await (0, extensionsHelper_1.confirm)({
155
- nonInteractive: options.nonInteractive,
156
- force: options.force,
157
- default: true,
158
- }))) {
159
- throw new error_1.FirebaseError(`Update cancelled.`);
160
- }
161
- const newSource = await extensionsApi.getSource(newSourceName);
162
- const newSpec = newSource.spec;
163
- if (![extensionsHelper_1.SourceOrigin.LOCAL, extensionsHelper_1.SourceOrigin.URL].includes(newSourceOrigin) &&
164
- existingSpec.version === newSpec.version) {
165
- utils.logLabeledBullet(extensionsHelper_1.logPrefix, `${clc.bold(instanceId)} is already up to date. Its version is ${clc.bold(existingSpec.version)}.`);
166
- const retry = await (0, extensionsHelper_1.confirm)({
167
- nonInteractive: options.nonInteractive,
168
- force: options.force,
169
- default: false,
170
- });
171
- if (!retry) {
172
- utils.logLabeledBullet(extensionsHelper_1.logPrefix, "Update aborted.");
173
- return;
174
- }
175
- }
176
- await (0, updateHelper_1.displayChanges)({
177
- spec: existingSpec,
178
- newSpec: newSpec,
179
- nonInteractive: options.nonInteractive,
180
- force: options.force,
181
- });
182
- await provisioningHelper.checkProductsProvisioned(projectId, newSpec);
183
- const usesSecrets = secretsUtils.usesSecrets(newSpec);
184
- if (newSpec.billingRequired || usesSecrets) {
185
- const enabled = await (0, cloudbilling_1.checkBillingEnabled)(projectId);
186
- (0, billingMigrationHelper_1.displayNode10UpdateBillingNotice)(existingSpec, newSpec);
187
- if (!(await (0, extensionsHelper_1.confirm)({
188
- nonInteractive: options.nonInteractive,
189
- force: options.force,
190
- default: true,
191
- }))) {
192
- throw new error_1.FirebaseError("Update cancelled.");
193
- }
194
- if (!enabled) {
195
- if (!options.nonInteractive) {
196
- await (0, checkProjectBilling_1.enableBilling)(projectId);
197
- }
198
- else {
199
- throw new error_1.FirebaseError("The extension requires your project to be upgraded to the Blaze plan. " +
200
- "To run this command in non-interactive mode, first upgrade your project: " +
201
- marked(`https://console.cloud.google.com/billing/linkedaccount?project=${projectId}`));
202
- }
203
- }
204
- if (usesSecrets) {
205
- await secretsUtils.ensureSecretManagerApiEnabled(options);
206
- }
207
- }
208
- const oldParamValues = Object.assign({}, existingParams);
209
- const newParamBindings = await paramHelper.getParamsForUpdate({
210
- spec: existingSpec,
211
- newSpec,
212
- currentParams: existingParams,
213
- projectId,
214
- paramsEnvPath: ((_b = options.params) !== null && _b !== void 0 ? _b : ""),
215
- nonInteractive: options.nonInteractive,
216
- instanceId,
217
- });
218
- const eventsConfig = newSpec.events
219
- ? await askUserForEventsConfig.askForEventsConfig(newSpec.events, projectId, instanceId)
220
- : undefined;
221
- const newParams = paramHelper.getBaseParamBindings(newParamBindings);
222
- spinner.start();
223
- const updateOptions = {
224
- projectId,
225
- instanceId,
226
- canEmitEvents: eventsConfig ? true : false,
227
- eventarcChannel: eventsConfig === null || eventsConfig === void 0 ? void 0 : eventsConfig.channel,
228
- allowedEventTypes: eventsConfig === null || eventsConfig === void 0 ? void 0 : eventsConfig.allowedEventTypes,
229
- };
230
- if (newSourceName.includes("publisher")) {
231
- updateOptions.extRef = refs.toExtensionVersionRef(refs.parse(newSourceName));
232
- }
233
- else {
234
- updateOptions.source = newSource;
235
- }
236
- if (!_.isEqual(newParams, oldParamValues)) {
237
- updateOptions.params = newParams;
238
- }
239
- await (0, updateHelper_1.update)(updateOptions);
240
- spinner.stop();
241
- utils.logLabeledSuccess(extensionsHelper_1.logPrefix, `successfully updated ${clc.bold(instanceId)}.`);
242
- utils.logLabeledBullet(extensionsHelper_1.logPrefix, marked(`You can view your updated instance in the Firebase console: ${utils.consoleUrl(projectId, `/extensions/instances/${instanceId}?tab=usage`)}`));
243
- manifest.showDeprecationWarning();
43
+ const oldRefOrPath = manifest.getInstanceTarget(instanceId, config);
44
+ if ((0, extensionsHelper_1.isLocalPath)(oldRefOrPath)) {
45
+ throw new error_1.FirebaseError(`Updating an extension with local source is not neccessary. ` +
46
+ `Rerun "firebase deploy" or restart the emulator after making changes to your local extension source. ` +
47
+ `If you've edited the extension param spec, you can edit an extension instance's params ` +
48
+ `interactively by running "firebase ext:configure --local {instance-id}"`);
244
49
  }
245
- catch (err) {
246
- if (spinner.isSpinning) {
247
- spinner.fail();
248
- }
249
- if (!(err instanceof error_1.FirebaseError)) {
250
- throw new error_1.FirebaseError(`Error occurred while updating the instance: ${err.message}`, {
251
- original: err,
252
- });
253
- }
254
- throw err;
50
+ const oldRef = manifest.getInstanceRef(instanceId, config);
51
+ const oldExtensionVersion = await extensionsApi.getExtensionVersion(refs.toExtensionVersionRef(oldRef));
52
+ updateSource = (0, updateHelper_1.inferUpdateSource)(updateSource, refs.toExtensionRef(oldRef));
53
+ const newSourceOrigin = (0, extensionsHelper_1.getSourceOrigin)(updateSource);
54
+ if (![extensionsHelper_1.SourceOrigin.PUBLISHED_EXTENSION, extensionsHelper_1.SourceOrigin.PUBLISHED_EXTENSION_VERSION].includes(newSourceOrigin)) {
55
+ throw new error_1.FirebaseError(`Only updating to a published extension version is allowed`);
255
56
  }
256
- });
257
- function isValidUpdate(existingSourceOrigin, newSourceOrigin) {
258
- if (existingSourceOrigin === extensionsHelper_1.SourceOrigin.PUBLISHED_EXTENSION) {
259
- return [extensionsHelper_1.SourceOrigin.PUBLISHED_EXTENSION, extensionsHelper_1.SourceOrigin.PUBLISHED_EXTENSION_VERSION].includes(newSourceOrigin);
57
+ const newExtensionVersion = await extensionsApi.getExtensionVersion(updateSource);
58
+ if (oldExtensionVersion.ref === newExtensionVersion.ref) {
59
+ utils.logLabeledBullet(extensionsHelper_1.logPrefix, `${clc.bold(instanceId)} is already up to date. Its version is ${clc.bold(newExtensionVersion.ref)}.`);
60
+ return;
61
+ }
62
+ utils.logLabeledBullet(extensionsHelper_1.logPrefix, `Updating ${clc.bold(instanceId)} from version ${clc.bold(oldExtensionVersion.ref)} to version ${clc.bold(newExtensionVersion.ref)}.`);
63
+ if (!(await (0, extensionsHelper_1.confirm)({
64
+ nonInteractive: options.nonInteractive,
65
+ force: options.force,
66
+ default: false,
67
+ }))) {
68
+ utils.logLabeledBullet(extensionsHelper_1.logPrefix, "Update aborted.");
69
+ return;
260
70
  }
261
- else if (existingSourceOrigin === extensionsHelper_1.SourceOrigin.LOCAL) {
262
- return [extensionsHelper_1.SourceOrigin.LOCAL, extensionsHelper_1.SourceOrigin.URL].includes(newSourceOrigin);
71
+ const oldParamValues = manifest.readInstanceParam({
72
+ instanceId,
73
+ projectDir: config.projectDir,
74
+ });
75
+ const newParamBindingOptions = await paramHelper.getParamsForUpdate({
76
+ spec: oldExtensionVersion.spec,
77
+ newSpec: newExtensionVersion.spec,
78
+ currentParams: oldParamValues,
79
+ projectId,
80
+ paramsEnvPath: "",
81
+ nonInteractive: options.nonInteractive,
82
+ instanceId,
83
+ });
84
+ const eventsConfig = newExtensionVersion.spec.events
85
+ ? await askUserForEventsConfig.askForEventsConfig(newExtensionVersion.spec.events, "${param:PROJECT_ID}", instanceId)
86
+ : undefined;
87
+ if (eventsConfig) {
88
+ newParamBindingOptions.EVENTARC_CHANNEL = { baseValue: eventsConfig.channel };
89
+ newParamBindingOptions.ALLOWED_EVENT_TYPES = {
90
+ baseValue: eventsConfig.allowedEventTypes.join(","),
91
+ };
263
92
  }
264
- return false;
265
- }
93
+ await manifest.writeToManifest([
94
+ {
95
+ instanceId,
96
+ ref: refs.parse(newExtensionVersion.ref),
97
+ params: newParamBindingOptions,
98
+ extensionSpec: newExtensionVersion.spec,
99
+ extensionVersion: newExtensionVersion,
100
+ },
101
+ ], config, {
102
+ nonInteractive: options.nonInteractive,
103
+ force: true,
104
+ });
105
+ manifest.showPostDeprecationNotice();
106
+ return;
107
+ });
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.command = void 0;
3
4
  const _ = require("lodash");
4
5
  const clc = require("cli-color");
5
6
  const checkMinRequiredVersion_1 = require("../checkMinRequiredVersion");
@@ -10,7 +11,7 @@ const listExtensions_1 = require("../extensions/listExtensions");
10
11
  const requirePermissions_1 = require("../requirePermissions");
11
12
  const logger_1 = require("../logger");
12
13
  const utils = require("../utils");
13
- module.exports = new command_1.Command("ext")
14
+ exports.command = new command_1.Command("ext")
14
15
  .description("display information on how to use ext commands and extensions installed to your project")
15
16
  .before(checkMinRequiredVersion_1.checkMinRequiredVersion, "extMinVersion")
16
17
  .action(async (options) => {
@@ -1,5 +1,6 @@
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 command_1 = require("../command");
5
6
  const types_1 = require("../emulator/types");
@@ -45,7 +46,7 @@ function getConfirmationMessage(deleteOp, options) {
45
46
  clc.cyan(options.project) +
46
47
  ". Are you sure?");
47
48
  }
48
- module.exports = new command_1.Command("firestore:delete [path]")
49
+ exports.command = new command_1.Command("firestore:delete [path]")
49
50
  .description("Delete data from Cloud Firestore.")
50
51
  .option("-r, --recursive", "Recursive. Delete all documents and subcollections at and under the " +
51
52
  "specified level. May not be passed along with --shallow.")
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.command = void 0;
3
4
  const command_1 = require("../command");
4
5
  const clc = require("cli-color");
5
6
  const fsi = require("../firestore/indexes");
@@ -7,7 +8,7 @@ const logger_1 = require("../logger");
7
8
  const requirePermissions_1 = require("../requirePermissions");
8
9
  const types_1 = require("../emulator/types");
9
10
  const commandUtils_1 = require("../emulator/commandUtils");
10
- module.exports = new command_1.Command("firestore:indexes")
11
+ exports.command = new command_1.Command("firestore:indexes")
11
12
  .description("List indexes in your project's Cloud Firestore database.")
12
13
  .option("--pretty", "Pretty print. When not specified the indexes are printed in the " +
13
14
  "JSON specification format.")
@@ -1,5 +1,6 @@
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 command_1 = require("../command");
5
6
  const error_1 = require("../error");
@@ -7,9 +8,9 @@ const logger_1 = require("../logger");
7
8
  const projectUtils_1 = require("../projectUtils");
8
9
  const requirePermissions_1 = require("../requirePermissions");
9
10
  const functionsConfig = require("../functionsConfig");
10
- const functionsConfigClone = require("../functionsConfigClone");
11
+ const functionsConfigClone_1 = require("../functionsConfigClone");
11
12
  const utils = require("../utils");
12
- exports.default = new command_1.Command("functions:config:clone")
13
+ exports.command = new command_1.Command("functions:config:clone")
13
14
  .description("clone environment config from another project")
14
15
  .option("--from <projectId>", "the project from which to clone configuration")
15
16
  .option("--only <keys>", "a comma-separated list of keys to clone")
@@ -46,7 +47,7 @@ exports.default = new command_1.Command("functions:config:clone")
46
47
  else if (options.except) {
47
48
  except = options.except.split(",");
48
49
  }
49
- await functionsConfigClone(options.from, projectId, only, except);
50
+ await (0, functionsConfigClone_1.functionsConfigClone)(options.from, projectId, only, except);
50
51
  utils.logSuccess(`Cloned functions config from ${clc.bold(options.from)} into ${clc.bold(projectId)}`);
51
52
  logger_1.logger.info(`\nPlease deploy your functions for the change to take effect by running ${clc.bold("firebase deploy --only functions")}\n`);
52
53
  });
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.command = void 0;
3
4
  const path = require("path");
4
5
  const clc = require("cli-color");
5
6
  const requireInteractive_1 = require("../requireInteractive");
@@ -69,7 +70,7 @@ function fromEntries(itr) {
69
70
  }
70
71
  return obj;
71
72
  }
72
- exports.default = new command_1.Command("functions:config:export")
73
+ exports.command = new command_1.Command("functions:config:export")
73
74
  .description("Export environment config as environment variables in dotenv format")
74
75
  .before(requirePermissions_1.requirePermissions, [
75
76
  "runtimeconfig.configs.list",
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.command = void 0;
3
4
  const lodash_1 = require("lodash");
4
5
  const path_1 = require("path");
5
6
  const command_1 = require("../command");
@@ -18,7 +19,7 @@ async function materialize(projectId, path) {
18
19
  const query = parts.join(".");
19
20
  return query ? (0, lodash_1.get)(result, query) : result;
20
21
  }
21
- exports.default = new command_1.Command("functions:config:get [path]")
22
+ exports.command = new command_1.Command("functions:config:get [path]")
22
23
  .description("fetch environment config stored at the given path")
23
24
  .before(requirePermissions_1.requirePermissions, [
24
25
  "runtimeconfig.configs.list",
@@ -1,5 +1,6 @@
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 command_1 = require("../command");
5
6
  const error_1 = require("../error");
@@ -8,7 +9,7 @@ const projectUtils_1 = require("../projectUtils");
8
9
  const requirePermissions_1 = require("../requirePermissions");
9
10
  const functionsConfig = require("../functionsConfig");
10
11
  const utils = require("../utils");
11
- exports.default = new command_1.Command("functions:config:set [values...]")
12
+ exports.command = new command_1.Command("functions:config:set [values...]")
12
13
  .description("set environment config with key=value syntax")
13
14
  .before(requirePermissions_1.requirePermissions, [
14
15
  "runtimeconfig.configs.list",
@@ -1,5 +1,6 @@
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 command_1 = require("../command");
5
6
  const logger_1 = require("../logger");
@@ -9,7 +10,7 @@ const functionsConfig = require("../functionsConfig");
9
10
  const runtimeconfig = require("../gcp/runtimeconfig");
10
11
  const utils = require("../utils");
11
12
  const error_1 = require("../error");
12
- exports.default = new command_1.Command("functions:config:unset [keys...]")
13
+ exports.command = new command_1.Command("functions:config:unset [keys...]")
13
14
  .description("unset environment config at the specified path(s)")
14
15
  .before(requirePermissions_1.requirePermissions, [
15
16
  "runtimeconfig.configs.list",
@@ -1,5 +1,6 @@
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 functionsConfig = require("../functionsConfig");
5
6
  const command_1 = require("../command");
@@ -17,7 +18,7 @@ const fabricator = require("../deploy/functions/release/fabricator");
17
18
  const executor = require("../deploy/functions/release/executor");
18
19
  const reporter = require("../deploy/functions/release/reporter");
19
20
  const containerCleaner = require("../deploy/functions/containerCleaner");
20
- exports.default = new command_1.Command("functions:delete [filters...]")
21
+ exports.command = new command_1.Command("functions:delete [filters...]")
21
22
  .description("delete one or more Cloud Functions by name or group name.")
22
23
  .option("--region <region>", "Specify region of the function to be deleted. " +
23
24
  "If omitted, functions from all regions whose names match the filters will be deleted. ")
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.command = void 0;
3
4
  const command_1 = require("../command");
4
5
  const projectUtils_1 = require("../projectUtils");
5
6
  const containerCleaner_1 = require("../deploy/functions/containerCleaner");
@@ -14,7 +15,7 @@ function getConfirmationMessage(paths) {
14
15
  message += "\nAre you sure?\n";
15
16
  return message;
16
17
  }
17
- exports.default = new command_1.Command("functions:deletegcfartifacts")
18
+ exports.command = new command_1.Command("functions:deletegcfartifacts")
18
19
  .description("Deletes all artifacts created by Google Cloud Functions on Google Container Registry.")
19
20
  .option("--regions <regions>", "Specify regions of artifacts to be deleted. " +
20
21
  "If omitted, artifacts from all regions will be deleted. " +
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.command = void 0;
3
4
  const command_1 = require("../command");
4
5
  const error_1 = require("../error");
5
6
  const projectUtils_1 = require("../projectUtils");
@@ -7,7 +8,7 @@ const requirePermissions_1 = require("../requirePermissions");
7
8
  const backend = require("../deploy/functions/backend");
8
9
  const logger_1 = require("../logger");
9
10
  const Table = require("cli-table");
10
- exports.default = new command_1.Command("functions:list")
11
+ exports.command = new command_1.Command("functions:list")
11
12
  .description("list all deployed functions in your Firebase project")
12
13
  .before(requirePermissions_1.requirePermissions, ["cloudfunctions.functions.list"])
13
14
  .action(async (options) => {
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.command = void 0;
3
4
  const opn = require("open");
4
5
  const qs = require("querystring");
5
6
  const command_1 = require("../command");
@@ -8,7 +9,7 @@ const cloudlogging = require("../gcp/cloudlogging");
8
9
  const functionsLog = require("../functions/functionslog");
9
10
  const projectUtils_1 = require("../projectUtils");
10
11
  const requirePermissions_1 = require("../requirePermissions");
11
- module.exports = new command_1.Command("functions:log")
12
+ exports.command = new command_1.Command("functions:log")
12
13
  .description("read logs from deployed functions")
13
14
  .option("--only <function_names>", 'only show logs of specified, comma-seperated functions (e.g. "funcA,funcB")')
14
15
  .option("-n, --lines <num_lines>", "specify number of log lines to fetch")
@@ -1,10 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.command = void 0;
3
4
  const command_1 = require("../command");
4
5
  const logger_1 = require("../logger");
5
6
  const projectUtils_1 = require("../projectUtils");
6
7
  const secretManager_1 = require("../gcp/secretManager");
7
- exports.default = new command_1.Command("functions:secrets:access <KEY>[@version]")
8
+ exports.command = new command_1.Command("functions:secrets:access <KEY>[@version]")
8
9
  .description("Access secret value given secret and its version. Defaults to accessing the latest version.")
9
10
  .action(async (key, options) => {
10
11
  const projectId = (0, projectUtils_1.needProjectId)(options);
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.command = void 0;
3
4
  const command_1 = require("../command");
4
5
  const projectUtils_1 = require("../projectUtils");
5
6
  const secretManager_1 = require("../gcp/secretManager");
@@ -7,7 +8,7 @@ const prompt_1 = require("../prompt");
7
8
  const utils_1 = require("../utils");
8
9
  const secrets = require("../functions/secrets");
9
10
  const backend = require("../deploy/functions/backend");
10
- exports.default = new command_1.Command("functions:secrets:destroy <KEY>[@version]")
11
+ exports.command = new command_1.Command("functions:secrets:destroy <KEY>[@version]")
11
12
  .description("Destroy a secret. Defaults to destroying the latest version.")
12
13
  .withForce("Destroys a secret without confirmation.")
13
14
  .action(async (key, options) => {
@@ -1,11 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.command = void 0;
3
4
  const Table = require("cli-table");
4
5
  const command_1 = require("../command");
5
6
  const logger_1 = require("../logger");
6
7
  const projectUtils_1 = require("../projectUtils");
7
8
  const secretManager_1 = require("../gcp/secretManager");
8
- exports.default = new command_1.Command("functions:secrets:get <KEY>")
9
+ exports.command = new command_1.Command("functions:secrets:get <KEY>")
9
10
  .description("Get metadata for secret and its versions")
10
11
  .action(async (key, options) => {
11
12
  const projectId = (0, projectUtils_1.needProjectId)(options);
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.command = void 0;
3
4
  const backend = require("../deploy/functions/backend");
4
5
  const command_1 = require("../command");
5
6
  const projectUtils_1 = require("../projectUtils");
@@ -9,7 +10,7 @@ const deploymentTool_1 = require("../deploymentTool");
9
10
  const utils_1 = require("../utils");
10
11
  const prompt_1 = require("../prompt");
11
12
  const secretManager_1 = require("../gcp/secretManager");
12
- exports.default = new command_1.Command("functions:secrets:prune")
13
+ exports.command = new command_1.Command("functions:secrets:prune")
13
14
  .withForce("Destroys unused secrets without prompt")
14
15
  .description("Destroys unused secrets")
15
16
  .before(requirePermissions_1.requirePermissions, [
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.command = void 0;
3
4
  const tty = require("tty");
4
5
  const fs = require("fs");
5
6
  const clc = require("cli-color");
@@ -12,7 +13,7 @@ const projectUtils_1 = require("../projectUtils");
12
13
  const secretManager_1 = require("../gcp/secretManager");
13
14
  const secrets = require("../functions/secrets");
14
15
  const backend = require("../deploy/functions/backend");
15
- exports.default = new command_1.Command("functions:secrets:set <KEY>")
16
+ exports.command = new command_1.Command("functions:secrets:set <KEY>")
16
17
  .description("Create or update a secret for use in Cloud Functions for Firebase.")
17
18
  .withForce("Automatically updates functions to use the new secret.")
18
19
  .before(requirePermissions_1.requirePermissions, [
@@ -1,13 +1,15 @@
1
1
  "use strict";
2
- var { Command } = require("../command");
3
- var { requirePermissions } = require("../requirePermissions");
4
- var { actionFunction } = require("../functionsShellCommandAction");
5
- var { requireConfig } = require("../requireConfig");
6
- var commandUtils = require("../emulator/commandUtils");
7
- module.exports = new Command("functions:shell")
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.command = void 0;
4
+ const command_1 = require("../command");
5
+ const requirePermissions_1 = require("../requirePermissions");
6
+ const functionsShellCommandAction_1 = require("../functionsShellCommandAction");
7
+ const requireConfig_1 = require("../requireConfig");
8
+ const commandUtils_1 = require("../emulator/commandUtils");
9
+ exports.command = new command_1.Command("functions:shell")
8
10
  .description("launch full Node shell with emulated functions")
9
11
  .option("-p, --port <port>", "the port on which to emulate functions")
10
- .option(commandUtils.FLAG_INSPECT_FUNCTIONS, commandUtils.DESC_INSPECT_FUNCTIONS)
11
- .before(requireConfig)
12
- .before(requirePermissions)
13
- .action(actionFunction);
12
+ .option(commandUtils_1.FLAG_INSPECT_FUNCTIONS, commandUtils_1.DESC_INSPECT_FUNCTIONS)
13
+ .before(requireConfig_1.requireConfig)
14
+ .before(requirePermissions_1.requirePermissions)
15
+ .action(functionsShellCommandAction_1.actionFunction);