firebase-tools 15.25.0 → 15.26.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 (52) hide show
  1. package/lib/ailogic/templates.js +124 -0
  2. package/lib/api.js +6 -2
  3. package/lib/appcheck/api.js +33 -0
  4. package/lib/appcheck/prompts.js +2 -2
  5. package/lib/appcheck/services.js +135 -0
  6. package/lib/auth.js +33 -15
  7. package/lib/checkValidTargetFilters.js +1 -0
  8. package/lib/command.js +4 -1
  9. package/lib/commands/ailogic-templates-delete.js +53 -0
  10. package/lib/commands/ailogic-templates-get.js +33 -0
  11. package/lib/commands/ailogic-templates-list.js +49 -0
  12. package/lib/commands/ailogic-templates-lock.js +30 -0
  13. package/lib/commands/ailogic-templates-unlock.js +30 -0
  14. package/lib/commands/appcheck-debugtokens-delete.js +1 -1
  15. package/lib/commands/appcheck-debugtokens-list.js +1 -1
  16. package/lib/commands/appcheck-services-get.js +40 -0
  17. package/lib/commands/appcheck-services-list.js +52 -0
  18. package/lib/commands/appcheck-services-set.js +90 -0
  19. package/lib/commands/crashlytics-onboard-web.js +56 -0
  20. package/lib/commands/deploy.js +3 -0
  21. package/lib/commands/firestore-locations.js +3 -1
  22. package/lib/commands/index.js +14 -0
  23. package/lib/commands/login.js +53 -6
  24. package/lib/config.js +1 -0
  25. package/lib/crashlytics/firebasetelemetry.js +36 -0
  26. package/lib/crashlytics/onboarding.js +41 -0
  27. package/lib/crashlytics/sourcemap.js +102 -12
  28. package/lib/deploy/ailogic/index.js +19 -0
  29. package/lib/deploy/ailogic/prepare.js +78 -0
  30. package/lib/deploy/ailogic/release.js +60 -0
  31. package/lib/deploy/functions/build.js +1 -1
  32. package/lib/deploy/functions/functionsDeployHelper.js +18 -12
  33. package/lib/deploy/functions/prepare.js +16 -3
  34. package/lib/deploy/functions/release/executor.js +51 -8
  35. package/lib/deploy/functions/release/fabricator.js +34 -5
  36. package/lib/deploy/index.js +9 -0
  37. package/lib/emulator/controller.js +34 -15
  38. package/lib/emulator/downloadableEmulatorInfo.json +24 -24
  39. package/lib/experiments.js +13 -0
  40. package/lib/extensions/checkProjectBilling.js +3 -73
  41. package/lib/functions/projectConfig.js +98 -12
  42. package/lib/gcp/ailogic.js +70 -1
  43. package/lib/gcp/cloudbilling.js +74 -0
  44. package/lib/gcp/cloudlogging.js +54 -0
  45. package/lib/management/apps.js +1 -2
  46. package/lib/prompt.js +10 -1
  47. package/lib/requirePermissions.js +1 -1
  48. package/lib/serve/functions.js +25 -7
  49. package/lib/tsconfig.compile.tsbuildinfo +1 -1
  50. package/lib/tsconfig.publish.tsbuildinfo +1 -1
  51. package/package.json +1 -1
  52. package/schema/firebase-config.json +132 -0
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.listEntries = listEntries;
4
+ exports.createOrUpdateLogBucket = createOrUpdateLogBucket;
5
+ exports.createOrUpdateLogSink = createOrUpdateLogSink;
4
6
  const api_1 = require("../api");
5
7
  const apiv2_1 = require("../apiv2");
6
8
  const error_1 = require("../error");
@@ -29,3 +31,55 @@ async function listEntries(projectId, filter, pageSize, order, pageToken) {
29
31
  });
30
32
  }
31
33
  }
34
+ async function createOrUpdateLogBucket(projectId, bucketId, location = "global", analyticsEnabled = true) {
35
+ const client = new apiv2_1.Client({ urlPrefix: (0, api_1.cloudloggingOrigin)(), apiVersion: API_VERSION });
36
+ const path = `/projects/${projectId}/locations/${location}/buckets`;
37
+ try {
38
+ const res = await client.post(`${path}?bucketId=${bucketId}`, { analyticsEnabled });
39
+ return res.body;
40
+ }
41
+ catch (err) {
42
+ if (err.status === 409) {
43
+ try {
44
+ const patchRes = await client.patch(`${path}/${bucketId}?updateMask=analyticsEnabled`, { analyticsEnabled });
45
+ return patchRes.body;
46
+ }
47
+ catch (patchErr) {
48
+ const msg = patchErr.message || JSON.stringify(patchErr.body) || patchErr;
49
+ throw new error_1.FirebaseError(`Failed to patch log bucket ${bucketId} (status ${patchErr.status}): ${msg}`, { original: patchErr });
50
+ }
51
+ }
52
+ const msg = err.message || JSON.stringify(err.body) || err;
53
+ if (typeof msg === "string" && msg.toLowerCase().includes("billing account")) {
54
+ throw new error_1.FirebaseError(`Creating a Cloud Logging bucket requires a valid linked billing account (Blaze plan). Please attach a billing account to project ${projectId} and try again.`, { original: err });
55
+ }
56
+ throw new error_1.FirebaseError(`Failed to create or update log bucket ${bucketId} (status ${err.status}): ${msg}`, { original: err });
57
+ }
58
+ }
59
+ async function createOrUpdateLogSink(projectId, sinkName, destination, filter) {
60
+ const client = new apiv2_1.Client({ urlPrefix: (0, api_1.cloudloggingOrigin)(), apiVersion: API_VERSION });
61
+ const path = `/projects/${projectId}/sinks`;
62
+ const body = {
63
+ name: sinkName,
64
+ destination,
65
+ filter,
66
+ };
67
+ try {
68
+ const res = await client.post(path, body);
69
+ return res.body;
70
+ }
71
+ catch (err) {
72
+ if (err.status === 409) {
73
+ try {
74
+ const putRes = await client.put(`${path}/${sinkName}`, body);
75
+ return putRes.body;
76
+ }
77
+ catch (putErr) {
78
+ const msg = putErr.message || JSON.stringify(putErr.body) || putErr;
79
+ throw new error_1.FirebaseError(`Failed to update log sink ${sinkName} (status ${putErr.status}): ${msg}`, { original: putErr });
80
+ }
81
+ }
82
+ const msg = err.message || JSON.stringify(err.body) || err;
83
+ throw new error_1.FirebaseError(`Failed to create or update log sink ${sinkName} (status ${err.status}): ${msg}`, { original: err });
84
+ }
85
+ }
@@ -547,8 +547,7 @@ async function findIntelligentPathForIOS(appDir, options) {
547
547
  return outputPath;
548
548
  }
549
549
  async function findIntelligentPathForAndroid(appDir, options) {
550
- const paths = appDir.split("/");
551
- if (paths[0] === "app") {
550
+ if (path.basename(appDir) === "app") {
552
551
  return appDir;
553
552
  }
554
553
  else {
package/lib/prompt.js CHANGED
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Separator = void 0;
4
+ exports.setNonInteractive = setNonInteractive;
5
+ exports.isNonInteractive = isNonInteractive;
4
6
  exports.guard = guard;
5
7
  exports.input = input;
6
8
  exports.confirm = confirm;
@@ -13,8 +15,15 @@ const inquirer = require("@inquirer/prompts");
13
15
  const error_1 = require("./error");
14
16
  var prompts_1 = require("@inquirer/prompts");
15
17
  Object.defineProperty(exports, "Separator", { enumerable: true, get: function () { return prompts_1.Separator; } });
18
+ let globalNonInteractive = false;
19
+ function setNonInteractive(value) {
20
+ globalNonInteractive = value;
21
+ }
22
+ function isNonInteractive() {
23
+ return globalNonInteractive;
24
+ }
16
25
  function guard(opts) {
17
- if (!opts.nonInteractive) {
26
+ if (!opts.nonInteractive && !isNonInteractive()) {
18
27
  return { shouldReturn: false, value: undefined };
19
28
  }
20
29
  if (typeof opts.default !== "undefined") {
@@ -9,12 +9,12 @@ const error_1 = require("./error");
9
9
  const iam_1 = require("./gcp/iam");
10
10
  const BASE_PERMISSIONS = ["firebase.projects.get"];
11
11
  async function requirePermissions(options, permissions = []) {
12
+ await (0, requireAuth_1.requireAuth)(options);
12
13
  const projectId = (0, projectUtils_1.getProjectId)(options);
13
14
  if (!projectId) {
14
15
  return;
15
16
  }
16
17
  const requiredPermissions = BASE_PERMISSIONS.concat(permissions).sort();
17
- await (0, requireAuth_1.requireAuth)(options);
18
18
  logger_1.logger.debug(`[iam] checking project ${projectId} for permissions ${JSON.stringify(requiredPermissions)}`);
19
19
  try {
20
20
  const iamResult = await (0, iam_1.testIamPermissions)(projectId, requiredPermissions);
@@ -23,13 +23,31 @@ class FunctionsServer {
23
23
  for (const cfg of config) {
24
24
  const localCfg = projectConfig.requireLocal(cfg, "Remote sources are not supported in the Functions emulator.");
25
25
  const functionsDir = path.join(options.config.projectDir, localCfg.source);
26
- backends.push({
27
- functionsDir,
28
- codebase: localCfg.codebase,
29
- runtime: localCfg.runtime,
30
- env: {},
31
- secretEnv: [],
32
- });
26
+ if (projectConfig.isKitConfig(localCfg)) {
27
+ for (const [instanceId, configDir] of Object.entries(localCfg.instances)) {
28
+ backends.push({
29
+ functionsDir,
30
+ codebase: instanceId,
31
+ prefix: projectConfig.addKitPrefix(instanceId),
32
+ configDir: path.join(options.config.projectDir, configDir),
33
+ runtime: localCfg.runtime,
34
+ env: {},
35
+ secretEnv: [],
36
+ });
37
+ }
38
+ }
39
+ else {
40
+ backends.push({
41
+ functionsDir,
42
+ codebase: localCfg.codebase,
43
+ ...(localCfg.configDir
44
+ ? { configDir: path.join(options.config.projectDir, localCfg.configDir) }
45
+ : {}),
46
+ runtime: localCfg.runtime,
47
+ env: {},
48
+ secretEnv: [],
49
+ });
50
+ }
33
51
  }
34
52
  this.backends = backends;
35
53
  const account = (0, auth_1.getProjectDefaultAccount)(options.config.projectDir);