firebase-tools-with-isolate 13.26.0 → 13.29.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 (61) hide show
  1. package/lib/appdistribution/client.js +2 -1
  2. package/lib/appdistribution/options-parser-util.js +5 -5
  3. package/lib/apphosting/config.js +86 -1
  4. package/lib/apphosting/secrets/index.js +1 -39
  5. package/lib/apphosting/yaml.js +3 -0
  6. package/lib/auth.js +13 -3
  7. package/lib/bin/firebase.js +4 -3
  8. package/lib/commands/appdistribution-distribute.js +55 -31
  9. package/lib/commands/apphosting-config-export.js +3 -26
  10. package/lib/commands/firestore-indexes-list.js +4 -2
  11. package/lib/commands/index.js +4 -6
  12. package/lib/dataconnect/fileUtils.js +3 -0
  13. package/lib/dataconnect/schemaMigration.js +10 -16
  14. package/lib/dataconnect/types.js +1 -1
  15. package/lib/deploy/extensions/tasks.js +2 -2
  16. package/lib/deploy/functions/backend.js +1 -3
  17. package/lib/deploy/functions/build.js +3 -1
  18. package/lib/deploy/functions/prepare.js +23 -20
  19. package/lib/deploy/functions/prepareFunctionsUpload.js +15 -16
  20. package/lib/deploy/functions/release/fabricator.js +1 -1
  21. package/lib/deploy/functions/release/planner.js +4 -4
  22. package/lib/deploy/functions/runtimes/discovery/v1alpha1.js +4 -0
  23. package/lib/deploy/functions/runtimes/supported/types.js +1 -1
  24. package/lib/emulator/apphosting/developmentServer.js +32 -0
  25. package/lib/emulator/apphosting/index.js +5 -4
  26. package/lib/emulator/apphosting/serve.js +7 -7
  27. package/lib/emulator/auth/operations.js +8 -5
  28. package/lib/emulator/commandUtils.js +2 -1
  29. package/lib/emulator/controller.js +46 -18
  30. package/lib/emulator/dataconnect/pgliteServer.js +76 -19
  31. package/lib/emulator/dataconnectEmulator.js +43 -2
  32. package/lib/emulator/downloadableEmulators.js +21 -10
  33. package/lib/emulator/eventarcEmulator.js +1 -0
  34. package/lib/emulator/hub.js +16 -0
  35. package/lib/emulator/hubExport.js +23 -0
  36. package/lib/emulator/initEmulators.js +63 -0
  37. package/lib/emulator/types.js +2 -2
  38. package/lib/error.js +11 -1
  39. package/lib/experiments.js +0 -6
  40. package/lib/extensions/localHelper.js +2 -2
  41. package/lib/extensions/runtimes/node.js +16 -15
  42. package/lib/extensions/types.js +6 -9
  43. package/lib/functions/events/v2.js +7 -3
  44. package/lib/gcp/cloudfunctionsv2.js +7 -0
  45. package/lib/init/features/dataconnect/index.js +8 -5
  46. package/lib/init/features/emulators.js +11 -0
  47. package/lib/init/features/genkit/index.js +13 -5
  48. package/lib/init/spawn.js +37 -7
  49. package/lib/management/projects.js +23 -1
  50. package/lib/requireAuth.js +2 -1
  51. package/lib/utils.js +16 -1
  52. package/package.json +7 -3
  53. package/schema/firebase-config.json +6 -0
  54. package/templates/init/dataconnect/dataconnect.yaml +1 -0
  55. package/templates/init/functions/javascript/package.lint.json +1 -1
  56. package/templates/init/functions/javascript/package.nolint.json +1 -1
  57. package/templates/init/functions/typescript/package.lint.json +1 -1
  58. package/templates/init/functions/typescript/package.nolint.json +1 -1
  59. package/templates/init/functions/typescript/tsconfig.json +3 -1
  60. package/lib/emulator/apphosting/utils.js +0 -18
  61. package/templates/init/dataconnect/dataconnect-fdccompatiblemode.yaml +0 -12
@@ -230,7 +230,7 @@ class AppDistributionClient {
230
230
  }
231
231
  utils.logSuccess(`Testers removed from group successfully`);
232
232
  }
233
- async createReleaseTest(releaseName, devices, loginCredential) {
233
+ async createReleaseTest(releaseName, devices, loginCredential, testCaseName) {
234
234
  try {
235
235
  const response = await this.appDistroV1AlphaClient.request({
236
236
  method: "POST",
@@ -238,6 +238,7 @@ class AppDistributionClient {
238
238
  body: {
239
239
  deviceExecutions: devices.map(types_1.mapDeviceToExecution),
240
240
  loginCredential,
241
+ testCase: testCaseName,
241
242
  },
242
243
  });
243
244
  return response.body;
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getLoginCredential = exports.getTestDevices = exports.getAppName = exports.getProjectName = exports.ensureFileExists = exports.getEmails = exports.getTestersOrGroups = void 0;
3
+ exports.getLoginCredential = exports.parseTestDevices = exports.getAppName = exports.getProjectName = exports.ensureFileExists = exports.getEmails = exports.parseIntoStringArray = void 0;
4
4
  const fs = require("fs-extra");
5
5
  const error_1 = require("../error");
6
6
  const projectUtils_1 = require("../projectUtils");
7
- function getTestersOrGroups(value, file) {
7
+ function parseIntoStringArray(value, file) {
8
8
  if (!value && file) {
9
9
  ensureFileExists(file);
10
10
  value = fs.readFileSync(file, "utf8");
@@ -14,7 +14,7 @@ function getTestersOrGroups(value, file) {
14
14
  }
15
15
  return [];
16
16
  }
17
- exports.getTestersOrGroups = getTestersOrGroups;
17
+ exports.parseIntoStringArray = parseIntoStringArray;
18
18
  function getEmails(emails, file) {
19
19
  if (emails.length === 0) {
20
20
  ensureFileExists(file);
@@ -49,7 +49,7 @@ function getAppName(options) {
49
49
  return `projects/${appId.split(":")[1]}/apps/${appId}`;
50
50
  }
51
51
  exports.getAppName = getAppName;
52
- function getTestDevices(value, file) {
52
+ function parseTestDevices(value, file) {
53
53
  if (!value && file) {
54
54
  ensureFileExists(file);
55
55
  value = fs.readFileSync(file, "utf8");
@@ -63,7 +63,7 @@ function getTestDevices(value, file) {
63
63
  .filter((entry) => !!entry)
64
64
  .map((str) => parseTestDevice(str));
65
65
  }
66
- exports.getTestDevices = getTestDevices;
66
+ exports.parseTestDevices = parseTestDevices;
67
67
  function parseTestDevice(testDeviceString) {
68
68
  const entries = testDeviceString.split(",");
69
69
  const allowedKeys = new Set(["model", "version", "orientation", "locale"]);
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.loadConfigForEnvironment = exports.maybeAddSecretToYaml = exports.upsertEnv = exports.findEnv = exports.store = exports.load = exports.listAppHostingFilesInPath = exports.discoverBackendRoot = exports.APPHOSTING_YAML_FILE_REGEX = exports.APPHOSTING_LOCAL_YAML_FILE = exports.APPHOSTING_BASE_YAML_FILE = void 0;
3
+ exports.loadConfigToExportSecrets = exports.loadConfigForEnvironment = exports.exportConfig = exports.maybeAddSecretToYaml = exports.upsertEnv = exports.findEnv = exports.store = exports.load = exports.listAppHostingFilesInPath = exports.discoverBackendRoot = exports.APPHOSTING_YAML_FILE_REGEX = exports.APPHOSTING_LOCAL_YAML_FILE = exports.APPHOSTING_BASE_YAML_FILE = void 0;
4
4
  const path_1 = require("path");
5
5
  const fs_1 = require("fs");
6
6
  const yaml = require("yaml");
@@ -8,9 +8,17 @@ const fs = require("../fsutils");
8
8
  const prompt = require("../prompt");
9
9
  const dialogs = require("./secrets/dialogs");
10
10
  const yaml_1 = require("./yaml");
11
+ const error_1 = require("../error");
12
+ const utils_1 = require("./utils");
13
+ const secrets_1 = require("./secrets");
14
+ const logger_1 = require("../logger");
15
+ const utils_2 = require("../utils");
16
+ const projects_1 = require("../management/projects");
11
17
  exports.APPHOSTING_BASE_YAML_FILE = "apphosting.yaml";
12
18
  exports.APPHOSTING_LOCAL_YAML_FILE = "apphosting.local.yaml";
13
19
  exports.APPHOSTING_YAML_FILE_REGEX = /^apphosting(\.[a-z0-9_]+)?\.yaml$/;
20
+ const SECRET_CONFIG = "Secret";
21
+ const EXPORTABLE_CONFIG = [SECRET_CONFIG];
14
22
  function discoverBackendRoot(cwd) {
15
23
  let dir = cwd;
16
24
  while (!fs.fileExistsSync((0, path_1.resolve)(dir, exports.APPHOSTING_BASE_YAML_FILE))) {
@@ -108,6 +116,49 @@ async function maybeAddSecretToYaml(secretName) {
108
116
  dynamicDispatch.store(path, projectYaml);
109
117
  }
110
118
  exports.maybeAddSecretToYaml = maybeAddSecretToYaml;
119
+ async function exportConfig(cwd, projectRoot, backendRoot, projectId, userGivenConfigFile) {
120
+ const choices = await prompt.prompt({}, [
121
+ {
122
+ type: "checkbox",
123
+ name: "configurations",
124
+ message: "What configs would you like to export?",
125
+ choices: EXPORTABLE_CONFIG,
126
+ },
127
+ ]);
128
+ if (!choices.configurations.includes(SECRET_CONFIG)) {
129
+ logger_1.logger.info("No configs selected to export");
130
+ return;
131
+ }
132
+ if (!projectId) {
133
+ const project = await (0, projects_1.getOrPromptProject)({});
134
+ projectId = project.projectId;
135
+ }
136
+ let localAppHostingConfig = yaml_1.AppHostingYamlConfig.empty();
137
+ const localAppHostingConfigPath = (0, path_1.resolve)(backendRoot, exports.APPHOSTING_LOCAL_YAML_FILE);
138
+ if (fs.fileExistsSync(localAppHostingConfigPath)) {
139
+ localAppHostingConfig = await yaml_1.AppHostingYamlConfig.loadFromFile(localAppHostingConfigPath);
140
+ }
141
+ const configToExport = await loadConfigToExportSecrets(cwd, userGivenConfigFile);
142
+ const secretsToExport = configToExport.secrets;
143
+ if (!secretsToExport) {
144
+ logger_1.logger.info("No secrets found to export in the chosen App Hosting config files");
145
+ return;
146
+ }
147
+ const secretMaterial = await (0, secrets_1.fetchSecrets)(projectId, secretsToExport);
148
+ for (const [key, value] of secretMaterial) {
149
+ localAppHostingConfig.addEnvironmentVariable({
150
+ variable: key,
151
+ value: value,
152
+ availability: ["RUNTIME"],
153
+ });
154
+ }
155
+ localAppHostingConfig.clearSecrets();
156
+ localAppHostingConfig.upsertFile(localAppHostingConfigPath);
157
+ logger_1.logger.info(`Wrote secrets as environment variables to ${exports.APPHOSTING_LOCAL_YAML_FILE}.`);
158
+ (0, utils_2.updateOrCreateGitignore)(projectRoot, [exports.APPHOSTING_LOCAL_YAML_FILE]);
159
+ logger_1.logger.info(`${exports.APPHOSTING_LOCAL_YAML_FILE} has been automatically added to your .gitignore.`);
160
+ }
161
+ exports.exportConfig = exportConfig;
111
162
  async function loadConfigForEnvironment(envYamlPath, baseYamlPath) {
112
163
  const envYamlConfig = await yaml_1.AppHostingYamlConfig.loadFromFile(envYamlPath);
113
164
  if (baseYamlPath) {
@@ -118,3 +169,37 @@ async function loadConfigForEnvironment(envYamlPath, baseYamlPath) {
118
169
  return envYamlConfig;
119
170
  }
120
171
  exports.loadConfigForEnvironment = loadConfigForEnvironment;
172
+ async function loadConfigToExportSecrets(cwd, userGivenConfigFile) {
173
+ if (userGivenConfigFile && !exports.APPHOSTING_YAML_FILE_REGEX.test(userGivenConfigFile)) {
174
+ throw new error_1.FirebaseError("Invalid apphosting yaml config file provided. File must be in format: 'apphosting.yaml' or 'apphosting.<environment>.yaml'");
175
+ }
176
+ const allConfigs = getValidConfigs(cwd);
177
+ let userGivenConfigFilePath;
178
+ if (userGivenConfigFile) {
179
+ if (!allConfigs.has(userGivenConfigFile)) {
180
+ throw new error_1.FirebaseError(`The provided app hosting config file "${userGivenConfigFile}" does not exist`);
181
+ }
182
+ userGivenConfigFilePath = allConfigs.get(userGivenConfigFile);
183
+ }
184
+ else {
185
+ userGivenConfigFilePath = await (0, utils_1.promptForAppHostingYaml)(allConfigs, "Which environment would you like to export secrets from Secret Manager for?");
186
+ }
187
+ if (userGivenConfigFile === exports.APPHOSTING_BASE_YAML_FILE) {
188
+ return yaml_1.AppHostingYamlConfig.loadFromFile(allConfigs.get(exports.APPHOSTING_BASE_YAML_FILE));
189
+ }
190
+ const baseFilePath = allConfigs.get(exports.APPHOSTING_BASE_YAML_FILE);
191
+ return await loadConfigForEnvironment(userGivenConfigFilePath, baseFilePath);
192
+ }
193
+ exports.loadConfigToExportSecrets = loadConfigToExportSecrets;
194
+ function getValidConfigs(cwd) {
195
+ const appHostingConfigPaths = listAppHostingFilesInPath(cwd).filter((path) => !path.endsWith(exports.APPHOSTING_LOCAL_YAML_FILE));
196
+ if (appHostingConfigPaths.length === 0) {
197
+ throw new error_1.FirebaseError("No apphosting.*.yaml configs found");
198
+ }
199
+ const fileNameToPathMap = new Map();
200
+ for (const path of appHostingConfigPaths) {
201
+ const fileName = (0, path_1.basename)(path);
202
+ fileNameToPathMap.set(fileName, path);
203
+ }
204
+ return fileNameToPathMap;
205
+ }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getSecretNameParts = exports.loadConfigToExport = exports.fetchSecrets = exports.upsertSecret = exports.grantSecretAccess = exports.serviceAccountsForBackend = exports.toMulti = void 0;
3
+ exports.getSecretNameParts = exports.fetchSecrets = exports.upsertSecret = exports.grantSecretAccess = exports.serviceAccountsForBackend = exports.toMulti = void 0;
4
4
  const error_1 = require("../../error");
5
5
  const gcsm = require("../../gcp/secretManager");
6
6
  const gcb = require("../../gcp/cloudbuild");
@@ -10,10 +10,6 @@ const secretManager_1 = require("../../gcp/secretManager");
10
10
  const secretManager_2 = require("../../gcp/secretManager");
11
11
  const utils = require("../../utils");
12
12
  const prompt = require("../../prompt");
13
- const path_1 = require("path");
14
- const config_1 = require("../config");
15
- const utils_1 = require("../utils");
16
- const yaml_1 = require("../yaml");
17
13
  function toMulti(accounts) {
18
14
  const m = {
19
15
  buildServiceAccounts: [accounts.buildServiceAccount],
@@ -124,40 +120,6 @@ async function fetchSecrets(projectId, secrets) {
124
120
  return secretsKeyValuePairs;
125
121
  }
126
122
  exports.fetchSecrets = fetchSecrets;
127
- async function loadConfigToExport(cwd, userGivenConfigFile) {
128
- if (userGivenConfigFile && !config_1.APPHOSTING_YAML_FILE_REGEX.test(userGivenConfigFile)) {
129
- throw new error_1.FirebaseError("Invalid apphosting yaml config file provided. File must be in format: 'apphosting.yaml' or 'apphosting.<environment>.yaml'");
130
- }
131
- const allConfigs = getValidConfigs(cwd);
132
- let userGivenConfigFilePath;
133
- if (userGivenConfigFile) {
134
- if (!allConfigs.has(userGivenConfigFile)) {
135
- throw new error_1.FirebaseError(`The provided app hosting config file "${userGivenConfigFile}" does not exist`);
136
- }
137
- userGivenConfigFilePath = allConfigs.get(userGivenConfigFile);
138
- }
139
- else {
140
- userGivenConfigFilePath = await (0, utils_1.promptForAppHostingYaml)(allConfigs, "Which environment would you like to export secrets from Secret Manager for?");
141
- }
142
- if (userGivenConfigFile === config_1.APPHOSTING_BASE_YAML_FILE) {
143
- return yaml_1.AppHostingYamlConfig.loadFromFile(allConfigs.get(config_1.APPHOSTING_BASE_YAML_FILE));
144
- }
145
- const baseFilePath = allConfigs.get(config_1.APPHOSTING_BASE_YAML_FILE);
146
- return await (0, config_1.loadConfigForEnvironment)(userGivenConfigFilePath, baseFilePath);
147
- }
148
- exports.loadConfigToExport = loadConfigToExport;
149
- function getValidConfigs(cwd) {
150
- const appHostingConfigPaths = (0, config_1.listAppHostingFilesInPath)(cwd).filter((path) => !path.endsWith(config_1.APPHOSTING_LOCAL_YAML_FILE));
151
- if (appHostingConfigPaths.length === 0) {
152
- throw new error_1.FirebaseError("No apphosting.*.yaml configs found");
153
- }
154
- const fileNameToPathMap = new Map();
155
- for (const path of appHostingConfigPaths) {
156
- const fileName = (0, path_1.basename)(path);
157
- fileNameToPathMap.set(fileName, path);
158
- }
159
- return fileNameToPathMap;
160
- }
161
123
  function getSecretNameParts(secret) {
162
124
  let [name, version] = secret.split("@");
163
125
  if (!version) {
@@ -42,6 +42,9 @@ class AppHostingYamlConfig {
42
42
  addSecret(secret) {
43
43
  this._secrets.set(secret.variable, secret);
44
44
  }
45
+ clearSecrets() {
46
+ this._secrets.clear();
47
+ }
45
48
  merge(other) {
46
49
  for (const [key, value] of other._environmentVariables) {
47
50
  this._environmentVariables.set(key, value);
package/lib/auth.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.addAdditionalAccount = exports.logout = exports.getAccessToken = exports.haveValidTokens = exports.loggedIn = exports.findAccountByEmail = exports.loginGithub = exports.loginGoogle = exports.setGlobalDefaultAccount = exports.setProjectAccount = exports.loginAdditionalAccount = exports.selectAccount = exports.setRefreshToken = exports.setActiveAccount = exports.getAllAccounts = exports.getAdditionalAccounts = exports.getProjectDefaultAccount = exports.getGlobalDefaultAccount = void 0;
3
+ exports.addAdditionalAccount = exports.logout = exports.getAccessToken = exports.haveValidTokens = exports.isExpired = exports.loggedIn = exports.findAccountByEmail = exports.loginGithub = exports.loginGoogle = exports.setGlobalDefaultAccount = exports.setProjectAccount = exports.loginAdditionalAccount = exports.selectAccount = exports.setRefreshToken = exports.setActiveAccount = exports.getAllAccounts = exports.getAdditionalAccounts = exports.getProjectDefaultAccount = exports.getGlobalDefaultAccount = void 0;
4
4
  const clc = require("colorette");
5
5
  const FormData = require("form-data");
6
6
  const http = require("http");
@@ -400,6 +400,16 @@ function loggedIn() {
400
400
  return !!lastAccessToken;
401
401
  }
402
402
  exports.loggedIn = loggedIn;
403
+ function isExpired(tokens) {
404
+ const hasExpiration = (p) => !!p.expires_at;
405
+ if (hasExpiration(tokens)) {
406
+ return !(tokens && tokens.expires_at && tokens.expires_at > Date.now());
407
+ }
408
+ else {
409
+ return !tokens;
410
+ }
411
+ }
412
+ exports.isExpired = isExpired;
403
413
  function haveValidTokens(refreshToken, authScopes) {
404
414
  if (!lastAccessToken?.access_token) {
405
415
  const tokens = configstore_1.configstore.get("tokens");
@@ -411,8 +421,8 @@ function haveValidTokens(refreshToken, authScopes) {
411
421
  const oldScopesJSON = JSON.stringify(lastAccessToken?.scopes?.sort() || []);
412
422
  const newScopesJSON = JSON.stringify(authScopes.sort());
413
423
  const hasSameScopes = oldScopesJSON === newScopesJSON;
414
- const isExpired = (lastAccessToken?.expires_at || 0) < Date.now() + FIFTEEN_MINUTES_IN_MS;
415
- const valid = hasTokens && hasSameScopes && !isExpired;
424
+ const expired = (lastAccessToken?.expires_at || 0) < Date.now() + FIFTEEN_MINUTES_IN_MS;
425
+ const valid = hasTokens && hasSameScopes && !expired;
416
426
  if (hasTokens) {
417
427
  logger_1.logger.debug(`Checked if tokens are valid: ${valid}, expires at: ${lastAccessToken?.expires_at}`);
418
428
  }
@@ -26,7 +26,7 @@ const client = require("..");
26
26
  const fsutils = require("../fsutils");
27
27
  const utils = require("../utils");
28
28
  const winston = require("winston");
29
- let args = process.argv.slice(2);
29
+ const args = process.argv.slice(2);
30
30
  let cmd;
31
31
  function findAvailableLogFile() {
32
32
  const candidates = ["firebase-debug.log"];
@@ -126,9 +126,10 @@ process.on("uncaughtException", (err) => {
126
126
  (0, errorOut_1.errorOut)(err);
127
127
  });
128
128
  if (!(0, handlePreviewToggles_1.handlePreviewToggles)(args)) {
129
- cmd = client.cli.parse(process.argv);
130
- args = args.filter((arg) => !arg.includes("-"));
131
129
  if (!args.length) {
132
130
  client.cli.help();
133
131
  }
132
+ else {
133
+ cmd = client.cli.parse(process.argv);
134
+ }
134
135
  }
@@ -23,14 +23,14 @@ function getReleaseNotes(releaseNotes, releaseNotesFile) {
23
23
  return "";
24
24
  }
25
25
  exports.command = new command_1.Command("appdistribution:distribute <release-binary-file>")
26
- .description("upload a release binary")
26
+ .description("upload a release binary and optionally distribute it to testers and run automated tests")
27
27
  .option("--app <app_id>", "the app id of your Firebase app")
28
28
  .option("--release-notes <string>", "release notes to include")
29
29
  .option("--release-notes-file <file>", "path to file with release notes")
30
- .option("--testers <string>", "a comma separated list of tester emails to distribute to")
31
- .option("--testers-file <file>", "path to file with a comma separated list of tester emails to distribute to")
32
- .option("--groups <string>", "a comma separated list of group aliases to distribute to")
33
- .option("--groups-file <file>", "path to file with a comma separated list of group aliases to distribute to")
30
+ .option("--testers <string>", "a comma-separated list of tester emails to distribute to")
31
+ .option("--testers-file <file>", "path to file with a comma- or newline-separated list of tester emails to distribute to")
32
+ .option("--groups <string>", "a comma-separated list of group aliases to distribute to")
33
+ .option("--groups-file <file>", "path to file with a comma- or newline-separated list of group aliases to distribute to")
34
34
  .option("--test-devices <string>", "semicolon-separated list of devices to run automated tests on, in the format 'model=<model-id>,version=<os-version-id>,locale=<locale>,orientation=<orientation>'. Run 'gcloud firebase test android|ios models list' to see available devices. Note: This feature is in beta.")
35
35
  .option("--test-devices-file <string>", "path to file containing a list of semicolon- or newline-separated devices to run automated tests on, in the format 'model=<model-id>,version=<os-version-id>,locale=<locale>,orientation=<orientation>'. Run 'gcloud firebase test android|ios models list' to see available devices. Note: This feature is in beta.")
36
36
  .option("--test-username <string>", "username for automatic login")
@@ -39,14 +39,20 @@ exports.command = new command_1.Command("appdistribution:distribute <release-bin
39
39
  .option("--test-username-resource <string>", "resource name for the username field for automatic login")
40
40
  .option("--test-password-resource <string>", "resource name for the password field for automatic login")
41
41
  .option("--test-non-blocking", "run automated tests without waiting for them to complete. Visit the Firebase console for the test results.")
42
+ .option("--test-case-ids <string>", "a comma-separated list of test case IDs.")
43
+ .option("--test-case-ids-file <file>", "path to file with a comma- or newline-separated list of test case IDs.")
42
44
  .before(requireAuth_1.requireAuth)
43
45
  .action(async (file, options) => {
44
46
  const appName = (0, options_parser_util_1.getAppName)(options);
45
47
  const distribution = new distribution_1.Distribution(file);
46
48
  const releaseNotes = getReleaseNotes(options.releaseNotes, options.releaseNotesFile);
47
- const testers = (0, options_parser_util_1.getTestersOrGroups)(options.testers, options.testersFile);
48
- const groups = (0, options_parser_util_1.getTestersOrGroups)(options.groups, options.groupsFile);
49
- const testDevices = (0, options_parser_util_1.getTestDevices)(options.testDevices, options.testDevicesFile);
49
+ const testers = (0, options_parser_util_1.parseIntoStringArray)(options.testers, options.testersFile);
50
+ const groups = (0, options_parser_util_1.parseIntoStringArray)(options.groups, options.groupsFile);
51
+ const testCases = (0, options_parser_util_1.parseIntoStringArray)(options.testCaseIds, options.testCaseIdsFile);
52
+ const testDevices = (0, options_parser_util_1.parseTestDevices)(options.testDevices, options.testDevicesFile);
53
+ if (testCases.length && (options.testUsernameResource || options.testPasswordResource)) {
54
+ throw new error_1.FirebaseError("Password and username resource names are not supported for the AI testing agent.");
55
+ }
50
56
  const loginCredential = (0, options_parser_util_1.getLoginCredential)({
51
57
  username: options.testUsername,
52
58
  password: options.testPassword,
@@ -137,39 +143,57 @@ exports.command = new command_1.Command("appdistribution:distribute <release-bin
137
143
  }
138
144
  await requests.updateReleaseNotes(releaseName, releaseNotes);
139
145
  await requests.distribute(releaseName, testers, groups);
140
- if (testDevices?.length) {
141
- utils.logBullet("starting automated tests (note: this feature is in beta)");
142
- const releaseTest = await requests.createReleaseTest(releaseName, testDevices, loginCredential);
143
- utils.logSuccess(`Release test created successfully`);
146
+ if (testDevices.length) {
147
+ utils.logBullet("starting automated test (note: this feature is in beta)");
148
+ const releaseTestPromises = [];
149
+ if (!testCases.length) {
150
+ releaseTestPromises.push(requests.createReleaseTest(releaseName, testDevices, loginCredential));
151
+ }
152
+ else {
153
+ for (const testCaseId of testCases) {
154
+ releaseTestPromises.push(requests.createReleaseTest(releaseName, testDevices, loginCredential, `${appName}/testCases/${testCaseId}`));
155
+ }
156
+ }
157
+ const releaseTests = await Promise.all(releaseTestPromises);
158
+ utils.logSuccess(`${releaseTests.length} release test(s) started successfully`);
144
159
  if (!options.testNonBlocking) {
145
- await awaitTestResults(releaseTest.name, requests);
160
+ await awaitTestResults(releaseTests, requests);
146
161
  }
147
162
  }
148
163
  });
149
- async function awaitTestResults(releaseTestName, requests) {
164
+ async function awaitTestResults(releaseTests, requests) {
165
+ const releaseTestNames = new Set(releaseTests.map((rt) => rt.name));
150
166
  for (let i = 0; i < TEST_MAX_POLLING_RETRIES; i++) {
151
- utils.logBullet("the automated tests results are pending");
167
+ utils.logBullet(`${releaseTestNames.size} automated test results are pending...`);
152
168
  await delay(TEST_POLLING_INTERVAL_MILLIS);
153
- const releaseTest = await requests.getReleaseTest(releaseTestName);
154
- if (releaseTest.deviceExecutions.every((e) => e.state === "PASSED")) {
155
- utils.logSuccess("automated test(s) passed!");
156
- return;
157
- }
158
- for (const execution of releaseTest.deviceExecutions) {
159
- switch (execution.state) {
160
- case "PASSED":
161
- case "IN_PROGRESS":
169
+ for (const releaseTestName of releaseTestNames) {
170
+ const releaseTest = await requests.getReleaseTest(releaseTestName);
171
+ if (releaseTest.deviceExecutions.every((e) => e.state === "PASSED")) {
172
+ releaseTestNames.delete(releaseTestName);
173
+ if (releaseTestNames.size === 0) {
174
+ utils.logSuccess("Automated test(s) passed!");
175
+ return;
176
+ }
177
+ else {
162
178
  continue;
163
- case "FAILED":
164
- throw new error_1.FirebaseError(`Automated test failed for ${deviceToString(execution.device)}: ${execution.failedReason}`, { exit: 1 });
165
- case "INCONCLUSIVE":
166
- throw new error_1.FirebaseError(`Automated test inconclusive for ${deviceToString(execution.device)}: ${execution.inconclusiveReason}`, { exit: 1 });
167
- default:
168
- throw new error_1.FirebaseError(`Unsupported automated test state for ${deviceToString(execution.device)}: ${execution.state}`, { exit: 1 });
179
+ }
180
+ }
181
+ for (const execution of releaseTest.deviceExecutions) {
182
+ switch (execution.state) {
183
+ case "PASSED":
184
+ case "IN_PROGRESS":
185
+ continue;
186
+ case "FAILED":
187
+ throw new error_1.FirebaseError(`Automated test failed for ${deviceToString(execution.device)}: ${execution.failedReason}`, { exit: 1 });
188
+ case "INCONCLUSIVE":
189
+ throw new error_1.FirebaseError(`Automated test inconclusive for ${deviceToString(execution.device)}: ${execution.inconclusiveReason}`, { exit: 1 });
190
+ default:
191
+ throw new error_1.FirebaseError(`Unsupported automated test state for ${deviceToString(execution.device)}: ${execution.state}`, { exit: 1 });
192
+ }
169
193
  }
170
194
  }
171
195
  }
172
- throw new error_1.FirebaseError("It took longer than expected to process your test, please try again.", {
196
+ throw new error_1.FirebaseError("It took longer than expected to run your test(s), please try again.", {
173
197
  exit: 1,
174
198
  });
175
199
  }
@@ -2,17 +2,13 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.command = void 0;
4
4
  const command_1 = require("../command");
5
- const logger_1 = require("../logger");
6
5
  const projectUtils_1 = require("../projectUtils");
7
6
  const requireAuth_1 = require("../requireAuth");
8
7
  const secretManager = require("../gcp/secretManager");
9
8
  const requirePermissions_1 = require("../requirePermissions");
10
9
  const config_1 = require("../apphosting/config");
11
- const secrets_1 = require("../apphosting/secrets");
12
- const path_1 = require("path");
13
- const fs = require("../fsutils");
14
- const yaml_1 = require("../apphosting/yaml");
15
10
  const error_1 = require("../error");
11
+ const detectProjectRoot_1 = require("../detectProjectRoot");
16
12
  exports.command = new command_1.Command("apphosting:config:export")
17
13
  .description("Export App Hosting configurations such as secrets into an apphosting.local.yaml file")
18
14
  .option("-s, --secrets <apphosting.yaml or apphosting.<environment>.yaml file to export secrets from>", "This command combines the base apphosting.yaml with the specified environment-specific file (e.g., apphosting.staging.yaml). If keys conflict, the environment-specific file takes precedence.")
@@ -23,29 +19,10 @@ exports.command = new command_1.Command("apphosting:config:export")
23
19
  const projectId = (0, projectUtils_1.needProjectId)(options);
24
20
  const environmentConfigFile = options.secrets;
25
21
  const cwd = process.cwd();
26
- let localAppHostingConfig = yaml_1.AppHostingYamlConfig.empty();
27
22
  const backendRoot = (0, config_1.discoverBackendRoot)(cwd);
28
23
  if (!backendRoot) {
29
24
  throw new error_1.FirebaseError("Missing apphosting.yaml: This command requires an apphosting.yaml configuration file. Please run 'firebase init apphosting' and try again.");
30
25
  }
31
- const localAppHostingConfigPath = (0, path_1.resolve)(backendRoot, config_1.APPHOSTING_LOCAL_YAML_FILE);
32
- if (fs.fileExistsSync(localAppHostingConfigPath)) {
33
- localAppHostingConfig = await yaml_1.AppHostingYamlConfig.loadFromFile(localAppHostingConfigPath);
34
- }
35
- const configToExport = await (0, secrets_1.loadConfigToExport)(cwd, environmentConfigFile);
36
- const secretsToExport = configToExport.secrets;
37
- if (!secretsToExport) {
38
- logger_1.logger.warn("No secrets found to export in the chosen App Hosting config files");
39
- return;
40
- }
41
- const secretMaterial = await (0, secrets_1.fetchSecrets)(projectId, secretsToExport);
42
- for (const [key, value] of secretMaterial) {
43
- localAppHostingConfig.addEnvironmentVariable({
44
- variable: key,
45
- value: value,
46
- availability: ["RUNTIME"],
47
- });
48
- }
49
- localAppHostingConfig.upsertFile(localAppHostingConfigPath);
50
- logger_1.logger.info(`Wrote secrets as environment variables to ${config_1.APPHOSTING_LOCAL_YAML_FILE}.`);
26
+ const projectRoot = (0, detectProjectRoot_1.detectProjectRoot)({}) ?? backendRoot;
27
+ await (0, config_1.exportConfig)(cwd, projectRoot, backendRoot, projectId, environmentConfigFile);
51
28
  });
@@ -9,6 +9,7 @@ const requirePermissions_1 = require("../requirePermissions");
9
9
  const types_1 = require("../emulator/types");
10
10
  const commandUtils_1 = require("../emulator/commandUtils");
11
11
  const pretty_print_1 = require("../firestore/pretty-print");
12
+ const projectUtils_1 = require("../projectUtils");
12
13
  exports.command = new command_1.Command("firestore:indexes")
13
14
  .description("List indexes in your project's Cloud Firestore database.")
14
15
  .option("--pretty", "Pretty print. When not specified the indexes are printed in the " +
@@ -20,8 +21,9 @@ exports.command = new command_1.Command("firestore:indexes")
20
21
  const indexApi = new fsi.FirestoreApi();
21
22
  const printer = new pretty_print_1.PrettyPrint();
22
23
  const databaseId = options.database ?? "(default)";
23
- const indexes = await indexApi.listIndexes(options.project, databaseId);
24
- const fieldOverrides = await indexApi.listFieldOverrides(options.project, databaseId);
24
+ const projectId = (0, projectUtils_1.needProjectId)(options);
25
+ const indexes = await indexApi.listIndexes(projectId, databaseId);
26
+ const fieldOverrides = await indexApi.listFieldOverrides(projectId, databaseId);
25
27
  const indexSpec = indexApi.makeIndexSpec(indexes, fieldOverrides);
26
28
  if (options.pretty) {
27
29
  logger_1.logger.info(clc.bold(clc.white("Compound Indexes")));
@@ -172,20 +172,18 @@ function load(client) {
172
172
  client.apphosting.secrets.grantaccess = loadCommand("apphosting-secrets-grantaccess");
173
173
  client.apphosting.secrets.describe = loadCommand("apphosting-secrets-describe");
174
174
  client.apphosting.secrets.access = loadCommand("apphosting-secrets-access");
175
+ client.apphosting.rollouts = {};
176
+ client.apphosting.rollouts.create = loadCommand("apphosting-rollouts-create");
177
+ client.apphosting.config = {};
178
+ client.apphosting.config.export = loadCommand("apphosting-config-export");
175
179
  if (experiments.isEnabled("internaltesting")) {
176
180
  client.apphosting.builds = {};
177
181
  client.apphosting.builds.get = loadCommand("apphosting-builds-get");
178
182
  client.apphosting.builds.create = loadCommand("apphosting-builds-create");
179
183
  client.apphosting.repos = {};
180
184
  client.apphosting.repos.create = loadCommand("apphosting-repos-create");
181
- client.apphosting.rollouts = {};
182
- client.apphosting.rollouts.create = loadCommand("apphosting-rollouts-create");
183
185
  client.apphosting.rollouts.list = loadCommand("apphosting-rollouts-list");
184
186
  }
185
- if (experiments.isEnabled("emulatorapphosting")) {
186
- client.apphosting.config = {};
187
- client.apphosting.config.export = loadCommand("apphosting-config-export");
188
- }
189
187
  }
190
188
  client.login = loadCommand("login");
191
189
  client.login.add = loadCommand("login-add");
@@ -53,6 +53,9 @@ function validateConnectorYaml(unvalidated) {
53
53
  return unvalidated;
54
54
  }
55
55
  async function readGQLFiles(sourceDir) {
56
+ if (!fs.existsSync(sourceDir)) {
57
+ return [];
58
+ }
56
59
  const files = await fs.readdir(sourceDir);
57
60
  return files
58
61
  .filter((f) => f.endsWith(".gql") || f.endsWith(".graphql"))
@@ -13,18 +13,15 @@ const prompt_1 = require("../prompt");
13
13
  const logger_1 = require("../logger");
14
14
  const error_1 = require("../error");
15
15
  const utils_1 = require("../utils");
16
- const experiments = require("../experiments");
17
16
  const errors = require("./errors");
18
17
  async function diffSchema(schema, schemaValidation) {
19
18
  const { serviceName, instanceName, databaseId } = getIdentifiers(schema);
20
19
  await ensureServiceIsConnectedToCloudSql(serviceName, instanceName, databaseId, false);
21
20
  let diffs = [];
22
- let validationMode = experiments.isEnabled("fdccompatiblemode")
23
- ? schemaValidation ?? "COMPATIBLE"
24
- : "STRICT";
21
+ let validationMode = schemaValidation ?? "COMPATIBLE";
25
22
  setSchemaValidationMode(schema, validationMode);
26
23
  try {
27
- if (!schemaValidation && experiments.isEnabled("fdccompatiblemode")) {
24
+ if (!schemaValidation) {
28
25
  (0, utils_1.logLabeledBullet)("dataconnect", `generating required schema changes...`);
29
26
  }
30
27
  await (0, client_1.upsertSchema)(schema, true);
@@ -52,7 +49,7 @@ async function diffSchema(schema, schemaValidation) {
52
49
  diffs = incompatible.diffs;
53
50
  }
54
51
  }
55
- if (experiments.isEnabled("fdccompatiblemode") && !schemaValidation) {
52
+ if (!schemaValidation) {
56
53
  validationMode = "STRICT";
57
54
  setSchemaValidationMode(schema, validationMode);
58
55
  try {
@@ -89,9 +86,7 @@ async function migrateSchema(args) {
89
86
  const { serviceName, instanceId, instanceName, databaseId } = getIdentifiers(schema);
90
87
  await ensureServiceIsConnectedToCloudSql(serviceName, instanceName, databaseId, true);
91
88
  let diffs = [];
92
- let validationMode = experiments.isEnabled("fdccompatiblemode")
93
- ? schemaValidation ?? "COMPATIBLE"
94
- : "STRICT";
89
+ let validationMode = schemaValidation ?? "COMPATIBLE";
95
90
  setSchemaValidationMode(schema, validationMode);
96
91
  try {
97
92
  await (0, client_1.upsertSchema)(schema, validateOnly);
@@ -124,7 +119,7 @@ async function migrateSchema(args) {
124
119
  await (0, client_1.upsertSchema)(schema, validateOnly);
125
120
  }
126
121
  }
127
- if (experiments.isEnabled("fdccompatiblemode") && !schemaValidation) {
122
+ if (!schemaValidation) {
128
123
  validationMode = "STRICT";
129
124
  setSchemaValidationMode(schema, validationMode);
130
125
  try {
@@ -185,11 +180,9 @@ function diffsEqual(x, y) {
185
180
  return true;
186
181
  }
187
182
  function setSchemaValidationMode(schema, schemaValidation) {
188
- if (experiments.isEnabled("fdccompatiblemode")) {
189
- const postgresDatasource = schema.datasources.find((d) => d.postgresql);
190
- if (postgresDatasource?.postgresql) {
191
- postgresDatasource.postgresql.schemaValidation = schemaValidation;
192
- }
183
+ const postgresDatasource = schema.datasources.find((d) => d.postgresql);
184
+ if (postgresDatasource?.postgresql) {
185
+ postgresDatasource.postgresql.schemaValidation = schemaValidation;
193
186
  }
194
187
  }
195
188
  function getIdentifiers(schema) {
@@ -354,6 +347,7 @@ async function ensureServiceIsConnectedToCloudSql(serviceName, instanceId, datab
354
347
  {
355
348
  postgresql: {
356
349
  database: databaseId,
350
+ schemaValidation: "NONE",
357
351
  cloudSql: {
358
352
  instance: instanceId,
359
353
  },
@@ -370,7 +364,7 @@ async function ensureServiceIsConnectedToCloudSql(serviceName, instanceId, datab
370
364
  if (postgresql?.database !== databaseId) {
371
365
  (0, utils_1.logLabeledWarning)("dataconnect", `Switching connected Postgres database from ${postgresql?.database} to ${databaseId}`);
372
366
  }
373
- if (!postgresql || postgresql.schemaValidation === "STRICT") {
367
+ if (!postgresql || postgresql.schemaValidation !== "NONE") {
374
368
  return;
375
369
  }
376
370
  postgresql.schemaValidation = "STRICT";
@@ -16,7 +16,7 @@ var Platform;
16
16
  Platform["MULTIPLE"] = "MULTIPLE";
17
17
  })(Platform = exports.Platform || (exports.Platform = {}));
18
18
  function toDatasource(projectId, locationId, ds) {
19
- if (ds.postgresql) {
19
+ if (ds?.postgresql) {
20
20
  return {
21
21
  postgresql: {
22
22
  database: ds.postgresql.database,