firebase-tools 10.2.0 → 10.3.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 (139) hide show
  1. package/lib/apiv2.js +3 -0
  2. package/lib/appdistribution/options-parser-util.js +1 -1
  3. package/lib/auth.js +3 -3
  4. package/lib/command.js +1 -1
  5. package/lib/commands/apps-android-sha-create.js +2 -2
  6. package/lib/commands/apps-sdkconfig.js +1 -1
  7. package/lib/commands/auth-import.js +1 -1
  8. package/lib/commands/database-rules-list.js +2 -2
  9. package/lib/commands/emulators-start.js +1 -1
  10. package/lib/commands/ext-configure.js +58 -4
  11. package/lib/commands/ext-dev-init.js +49 -49
  12. package/lib/commands/ext-export.js +7 -2
  13. package/lib/commands/ext-install.js +163 -104
  14. package/lib/commands/ext-uninstall.js +17 -8
  15. package/lib/commands/ext-update.js +64 -11
  16. package/lib/commands/functions-config-clone.js +1 -1
  17. package/lib/commands/functions-config-export.js +1 -1
  18. package/lib/commands/hosting-clone.js +3 -3
  19. package/lib/commands/remoteconfig-get.js +1 -1
  20. package/lib/config.js +6 -3
  21. package/lib/deploy/extensions/deploymentSummary.js +3 -3
  22. package/lib/deploy/extensions/planner.js +7 -6
  23. package/lib/deploy/extensions/tasks.js +1 -1
  24. package/lib/deploy/functions/backend.js +21 -5
  25. package/lib/deploy/functions/checkIam.js +5 -5
  26. package/lib/deploy/functions/containerCleaner.js +3 -3
  27. package/lib/deploy/functions/ensure.js +3 -3
  28. package/lib/deploy/functions/functionsDeployHelper.js +2 -2
  29. package/lib/deploy/functions/prepare.js +5 -3
  30. package/lib/deploy/functions/pricing.js +1 -1
  31. package/lib/deploy/functions/prompts.js +2 -2
  32. package/lib/deploy/functions/release/fabricator.js +7 -7
  33. package/lib/deploy/functions/release/index.js +1 -1
  34. package/lib/deploy/functions/release/planner.js +43 -26
  35. package/lib/deploy/functions/release/reporter.js +3 -0
  36. package/lib/deploy/functions/runtimes/discovery/index.js +6 -6
  37. package/lib/deploy/functions/runtimes/discovery/parsing.js +1 -1
  38. package/lib/deploy/functions/runtimes/discovery/v1alpha1.js +22 -12
  39. package/lib/deploy/functions/runtimes/golang/index.js +2 -2
  40. package/lib/deploy/functions/runtimes/node/index.js +53 -0
  41. package/lib/deploy/functions/runtimes/node/parseRuntimeAndValidateSDK.js +2 -2
  42. package/lib/deploy/functions/runtimes/node/parseTriggers.js +52 -15
  43. package/lib/deploy/functions/runtimes/node/versioning.js +2 -2
  44. package/lib/deploy/functions/services/firebaseAlerts.js +30 -0
  45. package/lib/deploy/functions/services/index.js +9 -1
  46. package/lib/deploy/functions/services/storage.js +10 -4
  47. package/lib/deploy/functions/triggerRegionHelper.js +1 -1
  48. package/lib/deploy/functions/validate.js +3 -3
  49. package/lib/deploy/hosting/client.js +9 -0
  50. package/lib/deploy/hosting/convertConfig.js +6 -0
  51. package/lib/deploy/hosting/deploy.js +2 -2
  52. package/lib/deploy/hosting/hashcache.js +21 -19
  53. package/lib/deploy/hosting/index.js +5 -5
  54. package/lib/deploy/hosting/prepare.js +25 -25
  55. package/lib/deploy/hosting/release.js +21 -24
  56. package/lib/deploy/hosting/uploader.js +5 -5
  57. package/lib/deploy/remoteconfig/functions.js +2 -2
  58. package/lib/emulator/auth/cloudFunctions.js +1 -1
  59. package/lib/emulator/auth/operations.js +1 -1
  60. package/lib/emulator/commandUtils.js +5 -1
  61. package/lib/emulator/constants.js +4 -0
  62. package/lib/emulator/controller.js +54 -24
  63. package/lib/emulator/download.js +18 -1
  64. package/lib/emulator/downloadableEmulators.js +30 -13
  65. package/lib/emulator/emulatorLogger.js +12 -1
  66. package/lib/emulator/extensions/validation.js +70 -0
  67. package/lib/emulator/extensionsEmulator.js +175 -0
  68. package/lib/emulator/functionsEmulator.js +106 -44
  69. package/lib/emulator/functionsEmulatorRuntime.js +44 -36
  70. package/lib/emulator/functionsEmulatorShared.js +17 -10
  71. package/lib/emulator/functionsEmulatorShell.js +1 -1
  72. package/lib/emulator/functionsEmulatorUtils.js +4 -4
  73. package/lib/emulator/functionsRuntimeWorker.js +2 -2
  74. package/lib/emulator/hub.js +4 -3
  75. package/lib/emulator/loggingEmulator.js +1 -1
  76. package/lib/emulator/pubsubEmulator.js +1 -1
  77. package/lib/emulator/registry.js +10 -2
  78. package/lib/emulator/storage/apis/firebase.js +314 -332
  79. package/lib/emulator/storage/apis/gcloud.js +241 -121
  80. package/lib/emulator/storage/crc.js +5 -1
  81. package/lib/emulator/storage/errors.js +9 -0
  82. package/lib/emulator/storage/files.js +159 -300
  83. package/lib/emulator/storage/index.js +27 -73
  84. package/lib/emulator/storage/metadata.js +65 -51
  85. package/lib/emulator/storage/multipart.js +62 -0
  86. package/lib/emulator/storage/persistence.js +78 -0
  87. package/lib/emulator/storage/rules/config.js +33 -0
  88. package/lib/emulator/storage/rules/manager.js +81 -0
  89. package/lib/emulator/storage/rules/runtime.js +8 -7
  90. package/lib/emulator/storage/rules/utils.js +48 -0
  91. package/lib/emulator/storage/server.js +2 -2
  92. package/lib/emulator/storage/upload.js +106 -0
  93. package/lib/emulator/types.js +3 -0
  94. package/lib/ensureApiEnabled.js +5 -1
  95. package/lib/error.js +1 -1
  96. package/lib/extensions/askUserForParam.js +1 -1
  97. package/lib/extensions/changelog.js +3 -1
  98. package/lib/extensions/checkProjectBilling.js +1 -1
  99. package/lib/extensions/displayExtensionInfo.js +1 -1
  100. package/lib/extensions/emulator/optionsHelper.js +56 -8
  101. package/lib/extensions/emulator/specHelper.js +10 -23
  102. package/lib/extensions/export.js +1 -51
  103. package/lib/extensions/extensionsApi.js +1 -1
  104. package/lib/extensions/extensionsHelper.js +32 -19
  105. package/lib/extensions/listExtensions.js +2 -0
  106. package/lib/extensions/manifest.js +144 -0
  107. package/lib/extensions/metricsUtils.js +4 -4
  108. package/lib/extensions/paramHelper.js +9 -8
  109. package/lib/extensions/refs.js +1 -1
  110. package/lib/extensions/secretsUtils.js +3 -3
  111. package/lib/functional.js +1 -1
  112. package/lib/functions/env.js +6 -7
  113. package/lib/functions/events/v2.js +11 -0
  114. package/lib/gcp/cloudfunctions.js +42 -11
  115. package/lib/gcp/cloudfunctionsv2.js +48 -17
  116. package/lib/gcp/cloudtasks.js +1 -1
  117. package/lib/gcp/docker.js +2 -2
  118. package/lib/gcp/resourceManager.js +4 -4
  119. package/lib/gcp/run.js +2 -2
  120. package/lib/gcp/storage.js +1 -0
  121. package/lib/hosting/api.js +1 -1
  122. package/lib/hosting/functionsProxy.js +15 -5
  123. package/lib/hosting/proxy.js +2 -2
  124. package/lib/init/features/account.js +1 -1
  125. package/lib/management/database.js +1 -1
  126. package/lib/previews.js +1 -1
  127. package/lib/responseToError.js +16 -7
  128. package/lib/serve/functions.js +2 -1
  129. package/lib/serve/hosting.js +1 -1
  130. package/lib/utils.js +15 -2
  131. package/npm-shrinkwrap.json +904 -412
  132. package/package.json +3 -3
  133. package/schema/firebase-config.json +32 -0
  134. package/templates/init/functions/javascript/package.lint.json +3 -3
  135. package/templates/init/functions/javascript/package.nolint.json +2 -2
  136. package/templates/init/functions/typescript/package.lint.json +7 -7
  137. package/templates/init/functions/typescript/package.nolint.json +3 -3
  138. package/lib/deploy/extensions/params.js +0 -39
  139. package/lib/deploy/functions/eventTypes.js +0 -10
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.downloadEmulator = void 0;
3
+ exports.downloadExtensionVersion = exports.downloadEmulator = void 0;
4
4
  const crypto = require("crypto");
5
5
  const fs = require("fs-extra");
6
6
  const path = require("path");
@@ -32,6 +32,23 @@ async function downloadEmulator(name) {
32
32
  removeOldFiles(name, emulator);
33
33
  }
34
34
  exports.downloadEmulator = downloadEmulator;
35
+ async function downloadExtensionVersion(extensionVersionRef, sourceDownloadUri, targetDir) {
36
+ const emulatorLogger = emulatorLogger_1.EmulatorLogger.forExtension({ ref: extensionVersionRef });
37
+ emulatorLogger.logLabeled("BULLET", "extensions", `Starting download for ${extensionVersionRef} source code...`);
38
+ try {
39
+ fs.mkdirSync(targetDir);
40
+ }
41
+ catch (err) {
42
+ emulatorLogger.logLabeled("BULLET", "extensions", `cache directory for ${extensionVersionRef} already exists...`);
43
+ }
44
+ emulatorLogger.logLabeled("BULLET", "extensions", `downloading ${sourceDownloadUri}...`);
45
+ const sourceCodeZip = await downloadUtils.downloadToTmp(sourceDownloadUri);
46
+ await unzip(sourceCodeZip, targetDir);
47
+ fs.chmodSync(targetDir, 0o755);
48
+ emulatorLogger.logLabeled("BULLET", "extensions", `Downloaded to ${targetDir}...`);
49
+ await new Promise((resolve) => setTimeout(resolve, 1000));
50
+ }
51
+ exports.downloadExtensionVersion = downloadExtensionVersion;
35
52
  function unzip(zipPath, unzipDir) {
36
53
  return new Promise((resolve, reject) => {
37
54
  fs.createReadStream(zipPath)
@@ -13,6 +13,7 @@ const path = require("path");
13
13
  const os = require("os");
14
14
  const registry_1 = require("./registry");
15
15
  const download_1 = require("../emulator/download");
16
+ const previews_1 = require("../previews");
16
17
  const EMULATOR_INSTANCE_KILL_TIMEOUT = 4000;
17
18
  const CACHE_DIR = process.env.FIREBASE_EMULATORS_PATH || path.join(os.homedir(), ".cache", "firebase", "emulators");
18
19
  exports.DownloadDetails = {
@@ -49,19 +50,35 @@ exports.DownloadDetails = {
49
50
  namePrefix: "cloud-storage-rules-emulator",
50
51
  },
51
52
  },
52
- ui: {
53
- version: "1.6.4",
54
- downloadPath: path.join(CACHE_DIR, "ui-v1.6.4.zip"),
55
- unzipDir: path.join(CACHE_DIR, "ui-v1.6.4"),
56
- binaryPath: path.join(CACHE_DIR, "ui-v1.6.4", "server.bundle.js"),
57
- opts: {
58
- cacheDir: CACHE_DIR,
59
- remoteUrl: "https://storage.googleapis.com/firebase-preview-drop/emulator/ui-v1.6.4.zip",
60
- expectedSize: 3757300,
61
- expectedChecksum: "20d4ee71e4ff7527b1843b6a8636142e",
62
- namePrefix: "ui",
53
+ ui: previews_1.previews.emulatoruisnapshot
54
+ ? {
55
+ version: "SNAPSHOT",
56
+ downloadPath: path.join(CACHE_DIR, "ui-vSNAPSHOT.zip"),
57
+ unzipDir: path.join(CACHE_DIR, "ui-vSNAPSHOT"),
58
+ binaryPath: path.join(CACHE_DIR, "ui-vSNAPSHOT", "server.bundle.js"),
59
+ opts: {
60
+ cacheDir: CACHE_DIR,
61
+ remoteUrl: "https://storage.googleapis.com/firebase-preview-drop/emulator/ui-vSNAPSHOT.zip",
62
+ expectedSize: -1,
63
+ expectedChecksum: "",
64
+ skipCache: true,
65
+ skipChecksumAndSize: true,
66
+ namePrefix: "ui",
67
+ },
68
+ }
69
+ : {
70
+ version: "1.6.5",
71
+ downloadPath: path.join(CACHE_DIR, "ui-v1.6.5.zip"),
72
+ unzipDir: path.join(CACHE_DIR, "ui-v1.6.5"),
73
+ binaryPath: path.join(CACHE_DIR, "ui-v1.6.5", "server.bundle.js"),
74
+ opts: {
75
+ cacheDir: CACHE_DIR,
76
+ remoteUrl: "https://storage.googleapis.com/firebase-preview-drop/emulator/ui-v1.6.5.zip",
77
+ expectedSize: 3816994,
78
+ expectedChecksum: "92dfff4b2ef8ab616e8a60cc93e0a00b",
79
+ namePrefix: "ui",
80
+ },
63
81
  },
64
- },
65
82
  pubsub: {
66
83
  downloadPath: path.join(CACHE_DIR, "pubsub-emulator-0.1.0.zip"),
67
84
  version: "0.1.0",
@@ -131,8 +148,8 @@ const Commands = {
131
148
  storage: {
132
149
  binary: "java",
133
150
  args: [
134
- "-jar",
135
151
  "-Duser.language=en",
152
+ "-jar",
136
153
  getExecPath(types_1.Emulators.STORAGE),
137
154
  "serve",
138
155
  ],
@@ -34,7 +34,7 @@ class EmulatorLogger {
34
34
  },
35
35
  });
36
36
  }
37
- static forFunction(functionName) {
37
+ static forFunction(functionName, extensionLogInfo) {
38
38
  return new EmulatorLogger({
39
39
  metadata: {
40
40
  emulator: {
@@ -43,6 +43,17 @@ class EmulatorLogger {
43
43
  function: {
44
44
  name: functionName,
45
45
  },
46
+ extension: extensionLogInfo,
47
+ },
48
+ });
49
+ }
50
+ static forExtension(extensionLogInfo) {
51
+ return new EmulatorLogger({
52
+ metadata: {
53
+ emulator: {
54
+ name: "extensions",
55
+ },
56
+ extension: extensionLogInfo,
46
57
  },
47
58
  });
48
59
  }
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.checkForUnemulatedTriggerTypes = exports.getUnemulatedAPIs = void 0;
4
+ const planner = require("../../deploy/extensions/planner");
5
+ const controller_1 = require("../controller");
6
+ const constants_1 = require("../constants");
7
+ const ensureApiEnabled_1 = require("../../ensureApiEnabled");
8
+ const functionsEmulatorShared_1 = require("../functionsEmulatorShared");
9
+ const types_1 = require("../types");
10
+ const EMULATED_APIS = [
11
+ "storage-component.googleapis.com",
12
+ "firestore.googleapis.com",
13
+ "pubsub.googleapis.com",
14
+ "identitytoolkit.googleapis.com",
15
+ ];
16
+ async function getUnemulatedAPIs(projectId, instances) {
17
+ var _a;
18
+ const unemulatedAPIs = {};
19
+ for (const i of instances) {
20
+ const extensionVersion = await planner.getExtensionVersion(i);
21
+ for (const api of (_a = extensionVersion.spec.apis) !== null && _a !== void 0 ? _a : []) {
22
+ if (!EMULATED_APIS.includes(api.apiName)) {
23
+ if (unemulatedAPIs[api.apiName]) {
24
+ unemulatedAPIs[api.apiName].instanceIds.push(i.instanceId);
25
+ }
26
+ else {
27
+ const enabled = !constants_1.Constants.isDemoProject(projectId) &&
28
+ (await (0, ensureApiEnabled_1.check)(projectId, api.apiName, "extensions", true));
29
+ unemulatedAPIs[api.apiName] = {
30
+ apiName: api.apiName,
31
+ instanceIds: [i.instanceId],
32
+ enabled,
33
+ };
34
+ }
35
+ }
36
+ }
37
+ }
38
+ return Object.values(unemulatedAPIs);
39
+ }
40
+ exports.getUnemulatedAPIs = getUnemulatedAPIs;
41
+ function checkForUnemulatedTriggerTypes(backend, options) {
42
+ var _a;
43
+ const triggers = (_a = backend.predefinedTriggers) !== null && _a !== void 0 ? _a : [];
44
+ const unemulatedTriggers = triggers
45
+ .filter((definition) => {
46
+ if (definition.httpsTrigger) {
47
+ return false;
48
+ }
49
+ if (definition.eventTrigger) {
50
+ const service = (0, functionsEmulatorShared_1.getFunctionService)(definition);
51
+ switch (service) {
52
+ case constants_1.Constants.SERVICE_FIRESTORE:
53
+ return !(0, controller_1.shouldStart)(options, types_1.Emulators.FIRESTORE);
54
+ case constants_1.Constants.SERVICE_REALTIME_DATABASE:
55
+ return !(0, controller_1.shouldStart)(options, types_1.Emulators.DATABASE);
56
+ case constants_1.Constants.SERVICE_PUBSUB:
57
+ return !(0, controller_1.shouldStart)(options, types_1.Emulators.PUBSUB);
58
+ case constants_1.Constants.SERVICE_AUTH:
59
+ return !(0, controller_1.shouldStart)(options, types_1.Emulators.AUTH);
60
+ case constants_1.Constants.SERVICE_STORAGE:
61
+ return !(0, controller_1.shouldStart)(options, types_1.Emulators.STORAGE);
62
+ default:
63
+ return true;
64
+ }
65
+ }
66
+ })
67
+ .map((definition) => constants_1.Constants.getServiceName((0, functionsEmulatorShared_1.getFunctionService)(definition)));
68
+ return [...new Set(unemulatedTriggers)];
69
+ }
70
+ exports.checkForUnemulatedTriggerTypes = checkForUnemulatedTriggerTypes;
@@ -0,0 +1,175 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ExtensionsEmulator = void 0;
4
+ const fs = require("fs-extra");
5
+ const os = require("os");
6
+ const path = require("path");
7
+ const clc = require("cli-color");
8
+ const Table = require("cli-table");
9
+ const child_process_1 = require("child_process");
10
+ const planner = require("../deploy/extensions/planner");
11
+ const error_1 = require("../error");
12
+ const refs_1 = require("../extensions/refs");
13
+ const download_1 = require("./download");
14
+ const optionsHelper_1 = require("../extensions/emulator/optionsHelper");
15
+ const emulatorLogger_1 = require("./emulatorLogger");
16
+ const types_1 = require("./types");
17
+ const validation_1 = require("./extensions/validation");
18
+ const ensureApiEnabled_1 = require("../ensureApiEnabled");
19
+ const shortenUrl_1 = require("../shortenUrl");
20
+ const constants_1 = require("./constants");
21
+ class ExtensionsEmulator {
22
+ constructor(args) {
23
+ this.want = [];
24
+ this.logger = emulatorLogger_1.EmulatorLogger.forEmulator(types_1.Emulators.EXTENSIONS);
25
+ this.pendingDownloads = new Map();
26
+ this.args = args;
27
+ }
28
+ async readManifest() {
29
+ var _a;
30
+ this.want = await planner.want({
31
+ projectId: this.args.projectId,
32
+ projectNumber: this.args.projectNumber,
33
+ aliases: (_a = this.args.aliases) !== null && _a !== void 0 ? _a : [],
34
+ projectDir: this.args.projectDir,
35
+ extensions: this.args.extensions,
36
+ emulatorMode: true,
37
+ });
38
+ }
39
+ async ensureSourceCode(instance) {
40
+ if (!instance.ref) {
41
+ throw new error_1.FirebaseError(`No ref found for ${instance.instanceId}. Emulating local extensions is not yet supported.`);
42
+ }
43
+ const ref = (0, refs_1.toExtensionVersionRef)(instance.ref);
44
+ const cacheDir = process.env.FIREBASE_EXTENSIONS_CACHE_PATH ||
45
+ path.join(os.homedir(), ".cache", "firebase", "extensions");
46
+ const sourceCodePath = path.join(cacheDir, ref);
47
+ if (this.pendingDownloads.get(ref)) {
48
+ await this.pendingDownloads.get(ref);
49
+ }
50
+ if (!this.hasValidSource({ path: sourceCodePath, extRef: ref })) {
51
+ const promise = this.downloadSource(instance, ref, sourceCodePath);
52
+ this.pendingDownloads.set(ref, promise);
53
+ await promise;
54
+ }
55
+ return sourceCodePath;
56
+ }
57
+ async downloadSource(instance, ref, sourceCodePath) {
58
+ const extensionVersion = await planner.getExtensionVersion(instance);
59
+ await (0, download_1.downloadExtensionVersion)(ref, extensionVersion.sourceDownloadUri, sourceCodePath);
60
+ this.installAndBuildSourceCode(sourceCodePath);
61
+ }
62
+ hasValidSource(args) {
63
+ const requiredFiles = [
64
+ "./extension.yaml",
65
+ "./functions/package.json",
66
+ "./functions/node_modules",
67
+ ];
68
+ for (const requiredFile of requiredFiles) {
69
+ const f = path.join(args.path, requiredFile);
70
+ if (!fs.existsSync(f)) {
71
+ emulatorLogger_1.EmulatorLogger.forExtension({ ref: args.extRef }).logLabeled("BULLET", "extensions", `Detected invalid source code for ${args.extRef}, expected to find ${f}`);
72
+ return false;
73
+ }
74
+ }
75
+ return true;
76
+ }
77
+ installAndBuildSourceCode(sourceCodePath) {
78
+ const npmInstall = (0, child_process_1.spawnSync)("npm", ["--prefix", `/${sourceCodePath}/functions/`, "install"], {
79
+ encoding: "utf8",
80
+ });
81
+ if (npmInstall.error) {
82
+ throw npmInstall.error;
83
+ }
84
+ const npmRunGCPBuild = (0, child_process_1.spawnSync)("npm", ["--prefix", `/${sourceCodePath}/functions/`, "run", "gcp-build"], { encoding: "utf8" });
85
+ if (npmRunGCPBuild.error) {
86
+ throw npmRunGCPBuild.error;
87
+ }
88
+ }
89
+ async getExtensionBackends() {
90
+ await this.readManifest();
91
+ await this.checkAndWarnAPIs(this.want);
92
+ return Promise.all(this.want.map((i) => {
93
+ return this.toEmulatableBackend(i);
94
+ }));
95
+ }
96
+ async toEmulatableBackend(instance) {
97
+ const extensionDir = await this.ensureSourceCode(instance);
98
+ const functionsDir = path.join(extensionDir, "functions");
99
+ const env = Object.assign(this.autoPopulatedParams(instance), instance.params);
100
+ const { extensionTriggers, nodeMajorVersion, nonSecretEnv, secretEnvVariables } = await (0, optionsHelper_1.getExtensionFunctionInfo)(extensionDir, instance.instanceId, env);
101
+ const extension = await planner.getExtension(instance);
102
+ const extensionVersion = await planner.getExtensionVersion(instance);
103
+ return {
104
+ functionsDir,
105
+ env: nonSecretEnv,
106
+ secretEnv: secretEnvVariables,
107
+ predefinedTriggers: extensionTriggers,
108
+ nodeMajorVersion: nodeMajorVersion,
109
+ extensionInstanceId: instance.instanceId,
110
+ extension,
111
+ extensionVersion,
112
+ };
113
+ }
114
+ autoPopulatedParams(instance) {
115
+ const projectId = this.args.projectId;
116
+ return {
117
+ PROJECT_ID: projectId !== null && projectId !== void 0 ? projectId : "",
118
+ EXT_INSTANCE_ID: instance.instanceId,
119
+ DATABASE_INSTANCE: projectId !== null && projectId !== void 0 ? projectId : "",
120
+ DATABASE_URL: `https://${projectId}.firebaseio.com`,
121
+ STORAGE_BUCKET: `${projectId}.appspot.com`,
122
+ };
123
+ }
124
+ async checkAndWarnAPIs(instances) {
125
+ const apisToWarn = await (0, validation_1.getUnemulatedAPIs)(this.args.projectId, instances);
126
+ if (apisToWarn.length) {
127
+ const table = new Table({
128
+ head: [
129
+ "API Name",
130
+ "Instances using this API",
131
+ `Enabled on ${this.args.projectId}`,
132
+ `Enable this API`,
133
+ ],
134
+ style: { head: ["yellow"] },
135
+ });
136
+ for (const apiToWarn of apisToWarn) {
137
+ const enablementUri = await (0, shortenUrl_1.shortenUrl)((0, ensureApiEnabled_1.enableApiURI)(this.args.projectId, apiToWarn.apiName));
138
+ table.push([
139
+ apiToWarn.apiName,
140
+ apiToWarn.instanceIds,
141
+ apiToWarn.enabled ? "Yes" : "No",
142
+ apiToWarn.enabled ? "" : clc.bold.underline(enablementUri),
143
+ ]);
144
+ }
145
+ if (constants_1.Constants.isDemoProject(this.args.projectId)) {
146
+ this.logger.logLabeled("WARN", "Extensions", "The following Extensions make calls to Google Cloud APIs that do not have Emulators. " +
147
+ `${clc.bold(this.args.projectId)} is a demo project, so these Extensions may not work as expected.\n` +
148
+ table.toString());
149
+ }
150
+ else {
151
+ this.logger.logLabeled("WARN", "Extensions", "The following Extensions make calls to Google Cloud APIs that do not have Emulators. " +
152
+ `These calls will go to production Google Cloud APIs which may have real effects on ${clc.bold(this.args.projectId)}.\n` +
153
+ table.toString());
154
+ }
155
+ }
156
+ }
157
+ filterUnemulatedTriggers(options, backends) {
158
+ let foundUnemulatedTrigger = false;
159
+ const filteredBackends = backends.filter((backend) => {
160
+ const unemulatedServices = (0, validation_1.checkForUnemulatedTriggerTypes)(backend, options);
161
+ if (unemulatedServices.length) {
162
+ foundUnemulatedTrigger = true;
163
+ const msg = ` ignored becuase it includes ${unemulatedServices.join(", ")} triggered functions, and the ${unemulatedServices.join(", ")} emulator does not exist or is not running.`;
164
+ this.logger.logLabeled("WARN", `extensions[${backend.extensionInstanceId}]`, msg);
165
+ }
166
+ return unemulatedServices.length === 0;
167
+ });
168
+ if (foundUnemulatedTrigger) {
169
+ const msg = "No Cloud Functions for these instances will be emulated, because partially emulating an Extension can lead to unexpected behavior. ";
170
+ this.logger.log("WARN", msg);
171
+ }
172
+ return filteredBackends;
173
+ }
174
+ }
175
+ exports.ExtensionsEmulator = ExtensionsEmulator;