firebase-tools 15.32.0 → 15.32.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.
@@ -575,7 +575,7 @@ async function main() {
575
575
  }
576
576
  switch (FUNCTION_SIGNATURE) {
577
577
  case "event":
578
- case "cloudevent":
578
+ case "cloudevent": {
579
579
  let reqBody;
580
580
  const rawBody = req.rawBody;
581
581
  if (types_2.EventUtils.isBinaryCloudEvent(req)) {
@@ -588,6 +588,7 @@ async function main() {
588
588
  await processBackground(trigger, reqBody, FUNCTION_SIGNATURE);
589
589
  res.send({ status: "acknowledged" });
590
590
  break;
591
+ }
591
592
  case "http":
592
593
  await runHTTPS(trigger, [req, res]);
593
594
  }
@@ -206,6 +206,11 @@ exports.ALL_EXPERIMENTS = experiments({
206
206
  default: false,
207
207
  public: true,
208
208
  },
209
+ crashlyticsWebAlerts: {
210
+ shortDescription: "Enable configuring Crashlytics email alerts during web app onboarding.",
211
+ default: false,
212
+ public: false,
213
+ },
209
214
  secretEnvParams: {
210
215
  shortDescription: "Enable reading the backing resource binding for a Functions secret param from .env",
211
216
  default: true,
@@ -12,6 +12,9 @@ const planner_1 = require("../deploy/extensions/planner");
12
12
  const error_1 = require("../error");
13
13
  const logger_1 = require("../logger");
14
14
  const utils = require("../utils");
15
+ const replacementRegistry_1 = require("./replacementRegistry");
16
+ const manifest = require("./manifest");
17
+ const refs = require("./refs");
15
18
  const toListEntry = (i) => {
16
19
  const idAndRef = (0, deploymentSummary_1.humanReadable)(i);
17
20
  const sourceCodeLink = `\n\t[Source Code](${i.extensionVersion?.buildSourceUri ?? i.extensionVersion?.sourceDownloadUri})`;
@@ -43,6 +46,7 @@ function outOfBandChangesWarning(instanceIds, isDynamic) {
43
46
  `\nIf you proceed with this deployment, those changes will be overwritten.${extra}`);
44
47
  }
45
48
  const FAQ_URL = "https://firebase.google.com/docs/extensions/faq-and-troubleshooting";
49
+ const BANNER_BORDER = "=".repeat(80);
46
50
  const WARN_BEFORE_COMMANDS = new Set([
47
51
  "ext:install",
48
52
  "ext:configure",
@@ -56,7 +60,7 @@ const WARN_STRONGLY_BEFORE_COMMANDS = new Set([
56
60
  "ext:dev:usage",
57
61
  "ext:dev:undeprecate",
58
62
  ]);
59
- const WARN_AFTER_COMMANDS = new Set(["ext:list", "ext:info"]);
63
+ const WARN_AFTER_COMMANDS = new Set(["ext:list", "ext:info", "ext:export"]);
60
64
  function isSilenced(options) {
61
65
  const opts = options;
62
66
  if (opts?.json ||
@@ -77,7 +81,23 @@ function isSilenced(options) {
77
81
  }
78
82
  return false;
79
83
  }
80
- function showDeprecationWarningBefore(commandName, options) {
84
+ function resolveExtensionRef(commandName, options, args = []) {
85
+ const firstArg = typeof args[0] === "string" ? args[0] : undefined;
86
+ if (!firstArg || (0, extensionsHelper_1.isLocalPath)(firstArg)) {
87
+ return undefined;
88
+ }
89
+ try {
90
+ const ref = commandName === "ext:configure" || commandName === "ext:update"
91
+ ? manifest.getInstanceRef(firstArg, manifest.loadConfig(options))
92
+ : refs.parse(firstArg);
93
+ return refs.toExtensionRef(ref);
94
+ }
95
+ catch (err) {
96
+ logger_1.logger.debug(`Could not resolve extension ref for deprecation warning: ${String(err)}`);
97
+ return undefined;
98
+ }
99
+ }
100
+ async function showDeprecationWarningBefore(commandName, options, args = []) {
81
101
  if (commandName === "ext:dev:register") {
82
102
  throw new error_1.FirebaseError(`ext:dev:register is disabled. Registering new publisher profile IDs is no longer supported.\n` +
83
103
  `The Firebase Extensions service will shut down on March 31, 2027.\n` +
@@ -87,18 +107,39 @@ function showDeprecationWarningBefore(commandName, options) {
87
107
  return;
88
108
  }
89
109
  if (WARN_BEFORE_COMMANDS.has(commandName)) {
90
- logger_1.logger.warn(clc.yellow(`⚠ Firebase Extensions will shut down on March 31, 2027. You will not be able to install or edit extensions after this date. Learn more: ${FAQ_URL}`));
110
+ let actionLine = "We recommend migrating active instances to function kits.";
111
+ const ref = resolveExtensionRef(commandName, options, args);
112
+ if (ref) {
113
+ try {
114
+ const registry = await (0, replacementRegistry_1.getReplacementsRegistry)();
115
+ const npmPackage = (0, replacementRegistry_1.getReplacementPackageName)(ref, registry);
116
+ if (npmPackage) {
117
+ actionLine = `Recommended replacement: ${npmPackage}`;
118
+ }
119
+ }
120
+ catch (err) {
121
+ logger_1.logger.debug(`Failed to resolve replacement info for warning: ${String(err)}`);
122
+ }
123
+ }
124
+ logger_1.logger.warn(clc.yellow(`${BANNER_BORDER}\n` +
125
+ `⚠ Firebase Extensions will shut down on March 31, 2027.\n` +
126
+ `${actionLine}\n` +
127
+ `Learn more & view migration steps: ${FAQ_URL}\n` +
128
+ `${BANNER_BORDER}`));
91
129
  }
92
130
  else if (WARN_STRONGLY_BEFORE_COMMANDS.has(commandName)) {
93
- logger_1.logger.warn(clc.yellow(`================================================================================\n` +
131
+ logger_1.logger.warn(clc.yellow(`${BANNER_BORDER}\n` +
94
132
  `⚠ Notice for Publishers: Firebase Extensions will shut down on March 31, 2027.\n` +
95
- `Learn more: ${FAQ_URL}\n` +
96
- `================================================================================`));
133
+ `Learn more & view migration steps: ${FAQ_URL}\n` +
134
+ `${BANNER_BORDER}`));
97
135
  }
98
136
  }
99
137
  function showDeprecationWarningAfter(commandName, options) {
100
138
  if (isSilenced(options) || !WARN_AFTER_COMMANDS.has(commandName)) {
101
139
  return;
102
140
  }
103
- logger_1.logger.warn(clc.yellow(`⚠ Notice: Firebase Extensions will shut down on March 31, 2027. Learn more: ${FAQ_URL}`));
141
+ if (commandName === "ext:export" && options.mode === "functions") {
142
+ return;
143
+ }
144
+ logger_1.logger.warn(clc.yellow(`⚠ Notice: Firebase Extensions will shut down on March 31, 2027. Learn more & view migration steps: ${FAQ_URL}`));
104
145
  }
@@ -16,7 +16,6 @@ const url_1 = require("url");
16
16
  const semver_1 = require("semver");
17
17
  const clc = require("colorette");
18
18
  const fsutils_1 = require("../../fsutils");
19
- const streamJson_1 = require("../../streamJson");
20
19
  const prompt_1 = require("../../prompt");
21
20
  const error_1 = require("../../error");
22
21
  const utils_1 = require("../utils");
@@ -392,28 +391,7 @@ async function ɵcodegenFunctionsDirectory(sourceDir, destDir, target, context)
392
391
  if (!esbuild) {
393
392
  throw new error_1.FirebaseError(`Failed to load esbuild from path: ${esbuildPath}`);
394
393
  }
395
- const { chain, parser, pick, streamObject } = await (0, streamJson_1.loadStreamJson)();
396
- const productionDeps = await new Promise((resolve) => {
397
- const dependencies = [];
398
- const npmLs = (0, cross_spawn_1.spawn)("npm", ["ls", "--omit=dev", "--all", "--json=true"], {
399
- cwd: sourceDir,
400
- timeout: constants_1.NPM_COMMAND_TIMEOUT_MILLIES,
401
- });
402
- const pipeline = chain([
403
- npmLs.stdout,
404
- parser({ packValues: false, packKeys: true, streamValues: false }),
405
- pick({ filter: "dependencies" }),
406
- streamObject(),
407
- ({ key, value }) => [
408
- key,
409
- ...(0, utils_2.allDependencyNames)(value),
410
- ],
411
- ]);
412
- pipeline.on("data", (it) => dependencies.push(it));
413
- pipeline.on("end", () => {
414
- resolve([...new Set(dependencies)]);
415
- });
416
- });
394
+ const productionDeps = await (0, utils_2.getProductionDependencyNames)(sourceDir);
417
395
  const esbuildArgs = {
418
396
  entryPoints: [(0, path_1.join)(sourceDir, configFile)],
419
397
  outfile: (0, path_1.join)(destDir, configFile),
@@ -18,6 +18,7 @@ exports.isUsingNextImageInServerComponent = isUsingNextImageInServerComponent;
18
18
  exports.isUsingNextImageInClientComponent = isUsingNextImageInClientComponent;
19
19
  exports.isUsingAppDirectory = isUsingAppDirectory;
20
20
  exports.allDependencyNames = allDependencyNames;
21
+ exports.getProductionDependencyNames = getProductionDependencyNames;
21
22
  exports.getMiddlewareMatcherRegexes = getMiddlewareMatcherRegexes;
22
23
  exports.getNonStaticRoutes = getNonStaticRoutes;
23
24
  exports.getNonStaticServerComponents = getNonStaticServerComponents;
@@ -43,6 +44,9 @@ const utils_1 = require("../utils");
43
44
  const constants_1 = require("./constants");
44
45
  const fsutils_1 = require("../../fsutils");
45
46
  const utils_2 = require("../../utils");
47
+ const cross_spawn_1 = require("cross-spawn");
48
+ const streamJson_1 = require("../../streamJson");
49
+ const constants_2 = require("../constants");
46
50
  const child_process_1 = require("child_process");
47
51
  const error_1 = require("../../error");
48
52
  exports.I18N_SOURCE = /\/:nextInternalLocale(\([^\)]+\))?/;
@@ -175,6 +179,30 @@ function allDependencyNames(mod) {
175
179
  const dependencyNames = Object.keys(mod.dependencies).reduce((acc, it) => [...acc, it, ...allDependencyNames(mod.dependencies[it])], []);
176
180
  return dependencyNames;
177
181
  }
182
+ async function getProductionDependencyNames(sourceDir) {
183
+ const { chain, many, parser, pick, streamObject } = await (0, streamJson_1.loadStreamJson)();
184
+ return new Promise((resolve, reject) => {
185
+ const dependencies = [];
186
+ const npmLs = (0, cross_spawn_1.spawn)("npm", ["ls", "--omit=dev", "--all", "--json=true"], {
187
+ cwd: sourceDir,
188
+ timeout: constants_2.NPM_COMMAND_TIMEOUT_MILLIES,
189
+ });
190
+ npmLs.on("error", reject);
191
+ if (!npmLs.stdout) {
192
+ return reject(new error_1.FirebaseError("Failed to capture npm ls output"));
193
+ }
194
+ const pipeline = chain([
195
+ npmLs.stdout,
196
+ parser({ packValues: false, packKeys: true, streamValues: false }),
197
+ pick({ filter: "dependencies" }),
198
+ streamObject(),
199
+ ({ key, value }) => many([key, ...allDependencyNames(value)]),
200
+ ]);
201
+ pipeline.on("data", (it) => dependencies.push(it));
202
+ pipeline.on("error", reject);
203
+ pipeline.on("end", () => resolve([...new Set(dependencies)]));
204
+ });
205
+ }
178
206
  function getMiddlewareMatcherRegexes(middlewareManifest, functionsConfigManifest) {
179
207
  const middlewareObjectValues = Object.values(middlewareManifest.middleware);
180
208
  const middlewareMatchers = [];
@@ -2,6 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ValueType = exports.Reducer = exports.MetricKind = exports.Aligner = exports.TimeSeriesView = exports.CLOUD_MONITORING_VERSION = void 0;
4
4
  exports.queryTimeSeries = queryTimeSeries;
5
+ exports.listNotificationChannels = listNotificationChannels;
6
+ exports.createNotificationChannel = createNotificationChannel;
7
+ exports.getAlertPolicy = getAlertPolicy;
8
+ exports.updateAlertPolicy = updateAlertPolicy;
5
9
  const api_1 = require("../api");
6
10
  const apiv2_1 = require("../apiv2");
7
11
  const error_1 = require("../error");
@@ -63,15 +67,88 @@ async function queryTimeSeries(query, project) {
63
67
  urlPrefix: (0, api_1.cloudMonitoringOrigin)(),
64
68
  apiVersion: exports.CLOUD_MONITORING_VERSION,
65
69
  });
70
+ const queryParams = {};
71
+ for (const [key, value] of Object.entries(query)) {
72
+ if (typeof value === "string" || typeof value === "number") {
73
+ queryParams[key] = value;
74
+ }
75
+ }
66
76
  try {
67
77
  const res = await client.get(`/projects/${project}/timeSeries/`, {
68
- queryParams: query,
78
+ queryParams,
69
79
  });
70
80
  return res.body.timeSeries;
71
81
  }
72
82
  catch (err) {
73
- throw new error_1.FirebaseError(`Failed to get Cloud Monitoring metric: ${err}`, {
74
- status: err.status,
83
+ throw new error_1.FirebaseError(`Failed to get Cloud Monitoring metric: ${(0, error_1.getErrMsg)(err)}`, {
84
+ status: (0, error_1.getErrStatus)(err),
85
+ original: (0, error_1.getError)(err),
86
+ });
87
+ }
88
+ }
89
+ async function listNotificationChannels(project, filter) {
90
+ const client = new apiv2_1.Client({
91
+ urlPrefix: (0, api_1.cloudMonitoringOrigin)(),
92
+ apiVersion: exports.CLOUD_MONITORING_VERSION,
93
+ });
94
+ try {
95
+ const res = await client.get(`/projects/${project}/notificationChannels`, filter ? { queryParams: { filter } } : {});
96
+ return res.body?.notificationChannels ?? [];
97
+ }
98
+ catch (err) {
99
+ throw new error_1.FirebaseError(`Failed to list Cloud Monitoring notification channels: ${(0, error_1.getErrMsg)(err)}`, {
100
+ status: (0, error_1.getErrStatus)(err),
101
+ original: (0, error_1.getError)(err),
102
+ });
103
+ }
104
+ }
105
+ async function createNotificationChannel(project, channel) {
106
+ const client = new apiv2_1.Client({
107
+ urlPrefix: (0, api_1.cloudMonitoringOrigin)(),
108
+ apiVersion: exports.CLOUD_MONITORING_VERSION,
109
+ });
110
+ try {
111
+ const res = await client.post(`/projects/${project}/notificationChannels`, channel);
112
+ return res.body;
113
+ }
114
+ catch (err) {
115
+ throw new error_1.FirebaseError(`Failed to create Cloud Monitoring notification channel: ${(0, error_1.getErrMsg)(err)}`, {
116
+ status: (0, error_1.getErrStatus)(err),
117
+ original: (0, error_1.getError)(err),
118
+ });
119
+ }
120
+ }
121
+ async function getAlertPolicy(name) {
122
+ const client = new apiv2_1.Client({
123
+ urlPrefix: (0, api_1.cloudMonitoringOrigin)(),
124
+ apiVersion: exports.CLOUD_MONITORING_VERSION,
125
+ });
126
+ const path = name.startsWith("/") ? name : `/${name}`;
127
+ try {
128
+ const res = await client.get(path);
129
+ return res.body;
130
+ }
131
+ catch (err) {
132
+ throw new error_1.FirebaseError(`Failed to get Cloud Monitoring alert policy ${name}: ${(0, error_1.getErrMsg)(err)}`, {
133
+ status: (0, error_1.getErrStatus)(err),
134
+ original: (0, error_1.getError)(err),
135
+ });
136
+ }
137
+ }
138
+ async function updateAlertPolicy(policy, updateMask) {
139
+ const client = new apiv2_1.Client({
140
+ urlPrefix: (0, api_1.cloudMonitoringOrigin)(),
141
+ apiVersion: exports.CLOUD_MONITORING_VERSION,
142
+ });
143
+ const path = policy.name.startsWith("/") ? policy.name : `/${policy.name}`;
144
+ try {
145
+ const res = await client.patch(path, policy, updateMask ? { queryParams: { updateMask } } : {});
146
+ return res.body;
147
+ }
148
+ catch (err) {
149
+ throw new error_1.FirebaseError(`Failed to update Cloud Monitoring alert policy ${policy.name}: ${(0, error_1.getErrMsg)(err)}`, {
150
+ status: (0, error_1.getErrStatus)(err),
151
+ original: (0, error_1.getError)(err),
75
152
  });
76
153
  }
77
154
  }
@@ -108,7 +108,7 @@ async function setEnqueuer(name, invoker, assumeEmpty = false) {
108
108
  const invokerMembers = proto.getInvokerMembers(invoker, project);
109
109
  while (true) {
110
110
  const policy = {
111
- bindings: existing.bindings.filter((binding) => binding.role !== ENQUEUER_ROLE),
111
+ bindings: (existing.bindings || []).filter((binding) => binding.role !== ENQUEUER_ROLE),
112
112
  etag: existing.etag,
113
113
  version: existing.version,
114
114
  };
@@ -30,7 +30,7 @@ async function askQuestions(setup, config, options) {
30
30
  case "nuxt2":
31
31
  case "express":
32
32
  case "svelekit":
33
- case "sveltekit":
33
+ case "sveltekit": {
34
34
  logger_1.logger.info();
35
35
  const useAppHosting = await (0, prompt_1.confirm)({
36
36
  message: `Detected a ${frameworkName} codebase with SSR features. We can't guarantee that ` +
@@ -47,7 +47,8 @@ async function askQuestions(setup, config, options) {
47
47
  return;
48
48
  }
49
49
  break;
50
- default:
50
+ }
51
+ default: {
51
52
  logger_1.logger.info();
52
53
  logger_1.logger.info(`Detected a ${frameworkName} codebase with SSR features. We can't guarantee that ` +
53
54
  `this site will work on Firebase Hosting, which is optimized for static sites. Another ` +
@@ -62,6 +63,7 @@ async function askQuestions(setup, config, options) {
62
63
  throw new error_1.FirebaseError("Hosting initialization cancelled.", { exit: 1 });
63
64
  }
64
65
  break;
66
+ }
65
67
  }
66
68
  }
67
69
  setup.featureInfo = setup.featureInfo || {};
@@ -169,14 +169,16 @@ async function sdkInit(appPlatform, options) {
169
169
  }
170
170
  async function getSdkOutputPath(appDir, platform, config) {
171
171
  switch (platform) {
172
- case AppPlatform.ANDROID:
172
+ case AppPlatform.ANDROID: {
173
173
  const androidPath = await findIntelligentPathForAndroid(appDir, config);
174
174
  return path.join(androidPath, "google-services.json");
175
+ }
175
176
  case AppPlatform.WEB:
176
177
  return path.join(appDir, "firebase-js-config.json");
177
- case AppPlatform.IOS:
178
+ case AppPlatform.IOS: {
178
179
  const iosPath = await findIntelligentPathForIOS(appDir, config);
179
180
  return path.join(iosPath, "GoogleService-Info.plist");
181
+ }
180
182
  }
181
183
  throw new error_1.FirebaseError("Platform " + platform.toString() + " is not supported yet.");
182
184
  }
package/lib/scopes.js CHANGED
@@ -1,11 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CLOUD_PUBSUB = exports.CLOUD_STORAGE = exports.CLOUD_PLATFORM = exports.FIREBASE_PLATFORM = exports.CLOUD_PROJECTS_READONLY = exports.USERINFO_EMAIL = exports.EMAIL = exports.OPENID = void 0;
3
+ exports.CLOUD_PLATFORM = exports.FIREBASE_PLATFORM = exports.CLOUD_PROJECTS_READONLY = exports.USERINFO_EMAIL = exports.EMAIL = exports.OPENID = void 0;
4
4
  exports.OPENID = "openid";
5
5
  exports.EMAIL = "email";
6
6
  exports.USERINFO_EMAIL = "https://www.googleapis.com/auth/userinfo.email";
7
7
  exports.CLOUD_PROJECTS_READONLY = "https://www.googleapis.com/auth/cloudplatformprojects.readonly";
8
8
  exports.FIREBASE_PLATFORM = "https://www.googleapis.com/auth/firebase";
9
9
  exports.CLOUD_PLATFORM = "https://www.googleapis.com/auth/cloud-platform";
10
- exports.CLOUD_STORAGE = "https://www.googleapis.com/auth/devstorage.read_write";
11
- exports.CLOUD_PUBSUB = "https://www.googleapis.com/auth/pubsub";
package/lib/streamJson.js CHANGED
@@ -21,6 +21,7 @@ function loadStreamJson() {
21
21
  ]);
22
22
  return {
23
23
  chain: streamChain.chain,
24
+ many: streamChain.many,
24
25
  parser: streamJson.parser,
25
26
  pick: pick.pick,
26
27
  filter: filter.filter,