firebase-tools 10.9.1 → 11.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/README.md +15 -9
  2. package/lib/appdistribution/client.js +16 -25
  3. package/lib/commands/apps-sdkconfig.js +6 -2
  4. package/lib/commands/ext-configure.js +54 -119
  5. package/lib/commands/ext-dev-emulators-exec.js +11 -6
  6. package/lib/commands/ext-dev-emulators-start.js +10 -26
  7. package/lib/commands/ext-install.js +12 -197
  8. package/lib/commands/ext-uninstall.js +7 -91
  9. package/lib/commands/ext-update.js +65 -224
  10. package/lib/deploy/functions/runtimes/discovery/v1alpha1.js +8 -9
  11. package/lib/deploy/remoteconfig/functions.js +18 -14
  12. package/lib/emulator/commandUtils.js +1 -1
  13. package/lib/emulator/controller.js +2 -2
  14. package/lib/emulator/databaseEmulator.js +7 -5
  15. package/lib/emulator/downloadableEmulators.js +6 -6
  16. package/lib/emulator/extensionsEmulator.js +7 -3
  17. package/lib/emulator/firestoreEmulator.js +10 -12
  18. package/lib/emulator/functionsEmulator.js +39 -42
  19. package/lib/emulator/hubClient.js +11 -22
  20. package/lib/emulator/hubExport.js +26 -16
  21. package/lib/emulator/portUtils.js +2 -0
  22. package/lib/emulator/storage/crc.js +3 -0
  23. package/lib/emulator/storage/rules/runtime.js +1 -1
  24. package/lib/extensions/extensionsHelper.js +4 -5
  25. package/lib/extensions/manifest.js +5 -11
  26. package/lib/firebaseConfigValidate.js +1 -1
  27. package/lib/firestore/checkDatabaseType.js +4 -5
  28. package/lib/firestore/indexes.js +17 -34
  29. package/lib/gcp/storage.js +2 -4
  30. package/lib/hosting/cloudRunProxy.js +19 -15
  31. package/lib/init/features/database.js +3 -5
  32. package/lib/management/apps.js +47 -43
  33. package/lib/management/database.js +33 -31
  34. package/lib/management/projects.js +13 -7
  35. package/lib/rtdb.js +31 -29
  36. package/npm-shrinkwrap.json +982 -511
  37. package/package.json +16 -19
  38. package/standalone/package.json +1 -1
@@ -1,19 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const clc = require("cli-color");
4
- const _ = require("lodash");
5
4
  const { marked } = require("marked");
6
- const ora = require("ora");
7
5
  const TerminalRenderer = require("marked-terminal");
8
6
  const checkMinRequiredVersion_1 = require("../checkMinRequiredVersion");
9
7
  const command_1 = require("../command");
10
8
  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
9
  const extensionsApi = require("../extensions/extensionsApi");
15
- const secretsUtils = require("../extensions/secretsUtils");
16
- const provisioningHelper = require("../extensions/provisioningHelper");
17
10
  const extensionsHelper_1 = require("../extensions/extensionsHelper");
18
11
  const paramHelper = require("../extensions/paramHelper");
19
12
  const updateHelper_1 = require("../extensions/updateHelper");
@@ -38,228 +31,76 @@ exports.default = new command_1.Command("ext:update <extensionInstanceId> [updat
38
31
  .before(extensionsHelper_1.ensureExtensionsApiEnabled)
39
32
  .before(checkMinRequiredVersion_1.checkMinRequiredVersion, "extMinVersion")
40
33
  .before(extensionsHelper_1.diagnoseAndFixProject)
34
+ .option("--local", "deprecated")
41
35
  .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
36
  .action(async (instanceId, updateSource, options) => {
45
- var _a, _b;
37
+ const projectId = (0, projectUtils_1.getProjectId)(options);
38
+ const config = manifest.loadConfig(options);
46
39
  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;
40
+ 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
41
  }
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();
42
+ const oldRefOrPath = manifest.getInstanceTarget(instanceId, config);
43
+ if ((0, extensionsHelper_1.isLocalPath)(oldRefOrPath)) {
44
+ throw new error_1.FirebaseError(`Updating an extension with local source is not neccessary. ` +
45
+ `Rerun "firebase deploy" or restart the emulator after making changes to your local extension source. ` +
46
+ `If you've edited the extension param spec, you can edit an extension instance's params ` +
47
+ `interactively by running "firebase ext:configure --local {instance-id}"`);
244
48
  }
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;
49
+ const oldRef = manifest.getInstanceRef(instanceId, config);
50
+ const oldExtensionVersion = await extensionsApi.getExtensionVersion(refs.toExtensionVersionRef(oldRef));
51
+ updateSource = (0, updateHelper_1.inferUpdateSource)(updateSource, refs.toExtensionRef(oldRef));
52
+ const newSourceOrigin = (0, extensionsHelper_1.getSourceOrigin)(updateSource);
53
+ if (![extensionsHelper_1.SourceOrigin.PUBLISHED_EXTENSION, extensionsHelper_1.SourceOrigin.PUBLISHED_EXTENSION_VERSION].includes(newSourceOrigin)) {
54
+ throw new error_1.FirebaseError(`Only updating to a published extension version is allowed`);
255
55
  }
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);
56
+ const newExtensionVersion = await extensionsApi.getExtensionVersion(updateSource);
57
+ if (oldExtensionVersion.ref === newExtensionVersion.ref) {
58
+ utils.logLabeledBullet(extensionsHelper_1.logPrefix, `${clc.bold(instanceId)} is already up to date. Its version is ${clc.bold(newExtensionVersion.ref)}.`);
59
+ return;
60
+ }
61
+ utils.logLabeledBullet(extensionsHelper_1.logPrefix, `Updating ${clc.bold(instanceId)} from version ${clc.bold(oldExtensionVersion.ref)} to version ${clc.bold(newExtensionVersion.ref)}.`);
62
+ if (!(await (0, extensionsHelper_1.confirm)({
63
+ nonInteractive: options.nonInteractive,
64
+ force: options.force,
65
+ default: false,
66
+ }))) {
67
+ utils.logLabeledBullet(extensionsHelper_1.logPrefix, "Update aborted.");
68
+ return;
260
69
  }
261
- else if (existingSourceOrigin === extensionsHelper_1.SourceOrigin.LOCAL) {
262
- return [extensionsHelper_1.SourceOrigin.LOCAL, extensionsHelper_1.SourceOrigin.URL].includes(newSourceOrigin);
70
+ const oldParamValues = manifest.readInstanceParam({
71
+ instanceId,
72
+ projectDir: config.projectDir,
73
+ });
74
+ const newParamBindingOptions = await paramHelper.getParamsForUpdate({
75
+ spec: oldExtensionVersion.spec,
76
+ newSpec: newExtensionVersion.spec,
77
+ currentParams: oldParamValues,
78
+ projectId,
79
+ paramsEnvPath: "",
80
+ nonInteractive: options.nonInteractive,
81
+ instanceId,
82
+ });
83
+ const eventsConfig = newExtensionVersion.spec.events
84
+ ? await askUserForEventsConfig.askForEventsConfig(newExtensionVersion.spec.events, "${param:PROJECT_ID}", instanceId)
85
+ : undefined;
86
+ if (eventsConfig) {
87
+ newParamBindingOptions.EVENTARC_CHANNEL = { baseValue: eventsConfig.channel };
88
+ newParamBindingOptions.ALLOWED_EVENT_TYPES = {
89
+ baseValue: eventsConfig.allowedEventTypes.join(","),
90
+ };
263
91
  }
264
- return false;
265
- }
92
+ await manifest.writeToManifest([
93
+ {
94
+ instanceId,
95
+ ref: refs.parse(newExtensionVersion.ref),
96
+ params: newParamBindingOptions,
97
+ extensionSpec: newExtensionVersion.spec,
98
+ extensionVersion: newExtensionVersion,
99
+ },
100
+ ], config, {
101
+ nonInteractive: options.nonInteractive,
102
+ force: true,
103
+ });
104
+ manifest.showPostDeprecationNotice();
105
+ return;
106
+ });
@@ -189,16 +189,15 @@ function parseEndpoints(manifest, id, project, defaultRegion, runtime) {
189
189
  runtime, entryPoint: ep.entryPoint }, triggered);
190
190
  (0, proto_1.copyIfPresent)(parsed, ep, "availableMemoryMb", "maxInstances", "minInstances", "concurrency", "serviceAccountEmail", "timeoutSeconds", "vpc", "labels", "ingressSettings", "environmentVariables", "cpu");
191
191
  (0, proto_1.renameIfPresent)(parsed, ep, "secretEnvironmentVariables", "secretEnvironmentVariables", (senvs) => {
192
- if (senvs && senvs.length > 0) {
193
- ep.secretEnvironmentVariables = [];
194
- for (const { key, secret } of senvs) {
195
- ep.secretEnvironmentVariables.push({
196
- key,
197
- secret: secret || key,
198
- projectId: project,
199
- });
200
- }
192
+ const secretEnvironmentVariables = [];
193
+ for (const { key, secret } of senvs) {
194
+ secretEnvironmentVariables.push({
195
+ key,
196
+ secret: secret || key,
197
+ projectId: project,
198
+ });
201
199
  }
200
+ return secretEnvironmentVariables;
202
201
  });
203
202
  allParsed.push(parsed);
204
203
  }
@@ -1,21 +1,25 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.publishTemplate = exports.deployTemplate = exports.validateInputRemoteConfigTemplate = exports.getEtag = void 0;
4
+ const api_1 = require("../../api");
5
+ const apiv2_1 = require("../../apiv2");
4
6
  const error_1 = require("../../error");
5
- const api = require("../../api");
6
7
  const TIMEOUT = 30000;
8
+ const client = new apiv2_1.Client({ urlPrefix: api_1.remoteConfigApiOrigin, apiVersion: "v1" });
7
9
  async function getEtag(projectNumber, versionNumber) {
8
- let reqPath = `/v1/projects/${projectNumber}/remoteConfig`;
10
+ const reqPath = `/projects/${projectNumber}/remoteConfig`;
11
+ const queryParams = {};
9
12
  if (versionNumber) {
10
- reqPath = reqPath + "?versionNumber=" + versionNumber;
13
+ queryParams.versionNumber = versionNumber;
11
14
  }
12
- const response = await api.request("GET", reqPath, {
13
- auth: true,
14
- origin: api.remoteConfigApiOrigin,
15
- timeout: TIMEOUT,
15
+ const response = await client.request({
16
+ method: "GET",
17
+ path: reqPath,
18
+ queryParams,
16
19
  headers: { "Accept-Encoding": "gzip" },
20
+ timeout: TIMEOUT,
17
21
  });
18
- return response.response.headers.etag;
22
+ return response.response.headers.get("etag") || "";
19
23
  }
20
24
  exports.getEtag = getEtag;
21
25
  function validateInputRemoteConfigTemplate(template) {
@@ -33,20 +37,20 @@ function validateInputRemoteConfigTemplate(template) {
33
37
  }
34
38
  exports.validateInputRemoteConfigTemplate = validateInputRemoteConfigTemplate;
35
39
  async function deployTemplate(projectNumber, template, etag, options) {
36
- const reqPath = `/v1/projects/${projectNumber}/remoteConfig`;
40
+ const reqPath = `/projects/${projectNumber}/remoteConfig`;
37
41
  if (options === null || options === void 0 ? void 0 : options.force) {
38
42
  etag = "*";
39
43
  }
40
- const response = await api.request("PUT", reqPath, {
41
- auth: true,
42
- origin: api.remoteConfigApiOrigin,
43
- timeout: TIMEOUT,
44
+ const response = await client.request({
45
+ method: "PUT",
46
+ path: reqPath,
44
47
  headers: { "If-Match": etag },
45
- data: {
48
+ body: {
46
49
  conditions: template.conditions,
47
50
  parameters: template.parameters,
48
51
  parameterGroups: template.parameterGroups,
49
52
  },
53
+ timeout: TIMEOUT,
50
54
  });
51
55
  return response.body;
52
56
  }
@@ -371,5 +371,5 @@ async function checkJavaSupported() {
371
371
  });
372
372
  }
373
373
  exports.checkJavaSupported = checkJavaSupported;
374
- exports.JAVA_DEPRECATION_WARNING = "Support for Java version <= 10 will be dropped soon in firebase-tools@11. " +
374
+ exports.JAVA_DEPRECATION_WARNING = "firebase-tools no longer supports Java version before 11. " +
375
375
  "Please upgrade to Java version 11 or above to continue using the emulators.";
@@ -219,8 +219,8 @@ async function startAll(options, showUI = true) {
219
219
  const deprecationNotices = [];
220
220
  if (targets.some(downloadableEmulators_1.requiresJava)) {
221
221
  if (!(await commandUtils.checkJavaSupported())) {
222
- utils.logLabeledWarning("emulators", commandUtils_1.JAVA_DEPRECATION_WARNING, "warn");
223
- deprecationNotices.push(commandUtils_1.JAVA_DEPRECATION_WARNING);
222
+ utils.logLabeledError("emulators", commandUtils_1.JAVA_DEPRECATION_WARNING, "warn");
223
+ throw new error_1.FirebaseError(commandUtils_1.JAVA_DEPRECATION_WARNING);
224
224
  }
225
225
  }
226
226
  const hubLogger = emulatorLogger_1.EmulatorLogger.forEmulator(types_1.Emulators.HUB);
@@ -6,7 +6,6 @@ const clc = require("cli-color");
6
6
  const fs = require("fs");
7
7
  const path = require("path");
8
8
  const http = require("http");
9
- const api = require("../api");
10
9
  const downloadableEmulators = require("./downloadableEmulators");
11
10
  const types_1 = require("../emulator/types");
12
11
  const constants_1 = require("./constants");
@@ -14,6 +13,7 @@ const registry_1 = require("./registry");
14
13
  const emulatorLogger_1 = require("./emulatorLogger");
15
14
  const error_1 = require("../error");
16
15
  const parseBoltRules = require("../parseBoltRules");
16
+ const apiv2_1 = require("../apiv2");
17
17
  class DatabaseEmulator {
18
18
  constructor(args) {
19
19
  this.args = args;
@@ -129,11 +129,13 @@ class DatabaseEmulator {
129
129
  : fs.readFileSync(rulesPath, "utf8");
130
130
  const info = this.getInfo();
131
131
  try {
132
- await api.request("PUT", `/.settings/rules.json?ns=${instance}`, {
133
- origin: `http://${registry_1.EmulatorRegistry.getInfoHostString(info)}`,
132
+ const client = new apiv2_1.Client({
133
+ urlPrefix: `http://${registry_1.EmulatorRegistry.getInfoHostString(info)}`,
134
+ auth: false,
135
+ });
136
+ await client.put(`/.settings/rules.json`, content, {
134
137
  headers: { Authorization: "Bearer owner" },
135
- data: content,
136
- json: false,
138
+ queryParams: { ns: instance },
137
139
  });
138
140
  }
139
141
  catch (e) {
@@ -18,13 +18,13 @@ const EMULATOR_INSTANCE_KILL_TIMEOUT = 4000;
18
18
  const CACHE_DIR = process.env.FIREBASE_EMULATORS_PATH || path.join(os.homedir(), ".cache", "firebase", "emulators");
19
19
  exports.DownloadDetails = {
20
20
  database: {
21
- downloadPath: path.join(CACHE_DIR, "firebase-database-emulator-v4.7.3.jar"),
22
- version: "4.7.3",
21
+ downloadPath: path.join(CACHE_DIR, "firebase-database-emulator-v4.8.0.jar"),
22
+ version: "4.8.0",
23
23
  opts: {
24
24
  cacheDir: CACHE_DIR,
25
- remoteUrl: "https://storage.googleapis.com/firebase-preview-drop/emulator/firebase-database-emulator-v4.7.3.jar",
26
- expectedSize: 28862098,
27
- expectedChecksum: "8f696f24ee89c937a789498a0c0e4899",
25
+ remoteUrl: "https://storage.googleapis.com/firebase-preview-drop/emulator/firebase-database-emulator-v4.8.0.jar",
26
+ expectedSize: 33676395,
27
+ expectedChecksum: "e5ae0085d9c88ed14b0bd9c25fe62916",
28
28
  namePrefix: "firebase-database-emulator",
29
29
  },
30
30
  },
@@ -164,7 +164,7 @@ const Commands = {
164
164
  },
165
165
  ui: {
166
166
  binary: "node",
167
- args: [getExecPath(types_1.Emulators.UI)],
167
+ args: ["--dns-result-order=ipv4first", getExecPath(types_1.Emulators.UI)],
168
168
  optionalArgs: [],
169
169
  joinArgs: false,
170
170
  },
@@ -6,7 +6,7 @@ const os = require("os");
6
6
  const path = require("path");
7
7
  const clc = require("cli-color");
8
8
  const Table = require("cli-table");
9
- const child_process_1 = require("child_process");
9
+ const spawn = require("cross-spawn");
10
10
  const planner = require("../deploy/extensions/planner");
11
11
  const error_1 = require("../error");
12
12
  const refs_1 = require("../extensions/refs");
@@ -110,16 +110,20 @@ class ExtensionsEmulator {
110
110
  return true;
111
111
  }
112
112
  installAndBuildSourceCode(sourceCodePath) {
113
- const npmInstall = (0, child_process_1.spawnSync)("npm", ["--prefix", `/${sourceCodePath}/functions/`, "install"], {
113
+ this.logger.logLabeled("DEBUG", "Extensions", `Running "npm install" for ${sourceCodePath}`);
114
+ const npmInstall = spawn.sync("npm", ["--prefix", `/${sourceCodePath}/functions/`, "install"], {
114
115
  encoding: "utf8",
115
116
  });
116
117
  if (npmInstall.error) {
117
118
  throw npmInstall.error;
118
119
  }
119
- const npmRunGCPBuild = (0, child_process_1.spawnSync)("npm", ["--prefix", `/${sourceCodePath}/functions/`, "run", "gcp-build"], { encoding: "utf8" });
120
+ this.logger.logLabeled("DEBUG", "Extensions", `Finished "npm install" for ${sourceCodePath}`);
121
+ this.logger.logLabeled("DEBUG", "Extensions", `Running "npm run gcp-build" for ${sourceCodePath}`);
122
+ const npmRunGCPBuild = spawn.sync("npm", ["--prefix", `/${sourceCodePath}/functions/`, "run", "gcp-build"], { encoding: "utf8" });
120
123
  if (npmRunGCPBuild.error) {
121
124
  throw npmRunGCPBuild.error;
122
125
  }
126
+ this.logger.logLabeled("DEBUG", "Extensions", `Finished "npm run gcp-build" for ${sourceCodePath}`);
123
127
  }
124
128
  async getExtensionBackends() {
125
129
  await this.readManifest();
@@ -5,12 +5,12 @@ const chokidar = require("chokidar");
5
5
  const fs = require("fs");
6
6
  const clc = require("cli-color");
7
7
  const path = require("path");
8
- const api = require("../api");
9
8
  const utils = require("../utils");
10
9
  const downloadableEmulators = require("./downloadableEmulators");
11
10
  const types_1 = require("../emulator/types");
12
11
  const registry_1 = require("./registry");
13
12
  const constants_1 = require("./constants");
13
+ const apiv2_1 = require("../apiv2");
14
14
  class FirestoreEmulator {
15
15
  constructor(args) {
16
16
  this.args = args;
@@ -65,7 +65,7 @@ class FirestoreEmulator {
65
65
  getName() {
66
66
  return types_1.Emulators.FIRESTORE;
67
67
  }
68
- updateRules(content) {
68
+ async updateRules(content) {
69
69
  const projectId = this.args.projectId;
70
70
  const info = this.getInfo();
71
71
  const body = {
@@ -79,17 +79,15 @@ class FirestoreEmulator {
79
79
  ],
80
80
  },
81
81
  };
82
- return api
83
- .request("PUT", `/emulator/v1/projects/${projectId}:securityRules`, {
84
- origin: `http://${registry_1.EmulatorRegistry.getInfoHostString(info)}`,
85
- data: body,
86
- })
87
- .then((res) => {
88
- if (res.body && res.body.issues) {
89
- return res.body.issues;
90
- }
91
- return [];
82
+ const client = new apiv2_1.Client({
83
+ urlPrefix: `http://${registry_1.EmulatorRegistry.getInfoHostString(info)}`,
84
+ auth: false,
92
85
  });
86
+ const res = await client.put(`/emulator/v1/projects/${projectId}:securityRules`, body);
87
+ if (res.body && Array.isArray(res.body.issues)) {
88
+ return res.body.issues;
89
+ }
90
+ return [];
93
91
  }
94
92
  prettyPrintRulesIssue(filePath, issue) {
95
93
  const relativePath = path.relative(process.cwd(), filePath);