firebase-tools 14.1.0 → 14.2.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.
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.command = void 0;
4
4
  const command_1 = require("../command");
5
5
  const projectUtils_1 = require("../projectUtils");
6
+ const requireAuth_1 = require("../requireAuth");
6
7
  const requireInteractive_1 = require("../requireInteractive");
7
8
  const backend_1 = require("../apphosting/backend");
8
9
  const apphosting_1 = require("../gcp/apphosting");
@@ -12,6 +13,7 @@ exports.command = new command_1.Command("apphosting:backends:create")
12
13
  .description("create a Firebase App Hosting backend")
13
14
  .option("-a, --app <webAppId>", "specify an existing Firebase web app's ID to associate your App Hosting backend with")
14
15
  .option("-s, --service-account <serviceAccount>", "specify the service account used to run the server", "")
16
+ .before(requireAuth_1.requireAuth)
15
17
  .before(apphosting_1.ensureApiEnabled)
16
18
  .before(requireInteractive_1.default)
17
19
  .before((0, requireTosAcceptance_1.requireTosAcceptance)(firedata_1.APPHOSTING_TOS_ID))
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.command = void 0;
4
4
  const command_1 = require("../command");
5
5
  const projectUtils_1 = require("../projectUtils");
6
+ const requireAuth_1 = require("../requireAuth");
6
7
  const error_1 = require("../error");
7
8
  const prompt_1 = require("../prompt");
8
9
  const utils = require("../utils");
@@ -13,6 +14,7 @@ const ora = require("ora");
13
14
  exports.command = new command_1.Command("apphosting:backends:delete <backend>")
14
15
  .description("delete a Firebase App Hosting backend")
15
16
  .withForce()
17
+ .before(requireAuth_1.requireAuth)
16
18
  .before(apphosting.ensureApiEnabled)
17
19
  .action(async (backendId, options) => {
18
20
  const projectId = (0, projectUtils_1.needProjectId)(options);
@@ -3,12 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.command = void 0;
4
4
  const command_1 = require("../command");
5
5
  const projectUtils_1 = require("../projectUtils");
6
+ const requireAuth_1 = require("../requireAuth");
6
7
  const error_1 = require("../error");
7
8
  const utils_1 = require("../utils");
8
9
  const apphosting = require("../gcp/apphosting");
9
10
  const apphosting_backends_list_1 = require("./apphosting-backends-list");
10
11
  exports.command = new command_1.Command("apphosting:backends:get <backend>")
11
12
  .description("print info about a Firebase App Hosting backend")
13
+ .before(requireAuth_1.requireAuth)
12
14
  .before(apphosting.ensureApiEnabled)
13
15
  .action(async (backend, options) => {
14
16
  const projectId = (0, projectUtils_1.needProjectId)(options);
@@ -6,11 +6,13 @@ const utils_1 = require("../utils");
6
6
  const error_1 = require("../error");
7
7
  const logger_1 = require("../logger");
8
8
  const projectUtils_1 = require("../projectUtils");
9
+ const requireAuth_1 = require("../requireAuth");
9
10
  const apphosting = require("../gcp/apphosting");
10
11
  const Table = require("cli-table3");
11
12
  const TABLE_HEAD = ["Backend", "Repository", "URL", "Primary Region", "Updated Date"];
12
13
  exports.command = new command_1.Command("apphosting:backends:list")
13
14
  .description("list Firebase App Hosting backends")
15
+ .before(requireAuth_1.requireAuth)
14
16
  .before(apphosting.ensureApiEnabled)
15
17
  .action(async (options) => {
16
18
  var _a;
@@ -5,12 +5,14 @@ const apphosting = require("../gcp/apphosting");
5
5
  const logger_1 = require("../logger");
6
6
  const command_1 = require("../command");
7
7
  const projectUtils_1 = require("../projectUtils");
8
+ const requireAuth_1 = require("../requireAuth");
8
9
  const utils_1 = require("../utils");
9
10
  exports.command = new command_1.Command("apphosting:builds:create <backendId>")
10
11
  .description("create a build for an App Hosting backend")
11
12
  .option("-l, --location <location>", "specify the region of the backend")
12
13
  .option("-i, --id <buildId>", "id of the build (defaults to autogenerating a random id)", "")
13
14
  .option("-b, --branch <branch>", "repository branch to deploy (defaults to 'main')", "main")
15
+ .before(requireAuth_1.requireAuth)
14
16
  .before(apphosting.ensureApiEnabled)
15
17
  .action(async (backendId, options) => {
16
18
  var _a, _b;
@@ -5,10 +5,12 @@ const apphosting = require("../gcp/apphosting");
5
5
  const logger_1 = require("../logger");
6
6
  const command_1 = require("../command");
7
7
  const projectUtils_1 = require("../projectUtils");
8
+ const requireAuth_1 = require("../requireAuth");
8
9
  const utils_1 = require("../utils");
9
10
  exports.command = new command_1.Command("apphosting:builds:get <backendId> <buildId>")
10
11
  .description("get a build for an App Hosting backend")
11
12
  .option("-l, --location <location>", "specify the region of the backend")
13
+ .before(requireAuth_1.requireAuth)
12
14
  .before(apphosting.ensureApiEnabled)
13
15
  .action(async (backendId, buildId, options) => {
14
16
  var _a;
@@ -4,6 +4,7 @@ exports.command = void 0;
4
4
  const apphosting = require("../gcp/apphosting");
5
5
  const command_1 = require("../command");
6
6
  const projectUtils_1 = require("../projectUtils");
7
+ const requireAuth_1 = require("../requireAuth");
7
8
  const error_1 = require("../error");
8
9
  const rollout_1 = require("../apphosting/rollout");
9
10
  exports.command = new command_1.Command("apphosting:rollouts:create <backendId>")
@@ -11,6 +12,7 @@ exports.command = new command_1.Command("apphosting:rollouts:create <backendId>"
11
12
  .option("-b, --git-branch <gitBranch>", "repository branch to deploy (mutually exclusive with -g)")
12
13
  .option("-g, --git-commit <gitCommit>", "git commit to deploy (mutually exclusive with -b)")
13
14
  .withForce("Skip confirmation before creating rollout")
15
+ .before(requireAuth_1.requireAuth)
14
16
  .before(apphosting.ensureApiEnabled)
15
17
  .action(async (backendId, options) => {
16
18
  const projectId = (0, projectUtils_1.needProjectId)(options);
@@ -5,10 +5,12 @@ const apphosting = require("../gcp/apphosting");
5
5
  const logger_1 = require("../logger");
6
6
  const command_1 = require("../command");
7
7
  const projectUtils_1 = require("../projectUtils");
8
+ const requireAuth_1 = require("../requireAuth");
8
9
  const utils_1 = require("../utils");
9
10
  exports.command = new command_1.Command("apphosting:rollouts:list <backendId>")
10
11
  .description("list rollouts of an App Hosting backend")
11
12
  .option("-l, --location <location>", "region of the rollouts (defaults to listing rollouts from all regions)")
13
+ .before(requireAuth_1.requireAuth)
12
14
  .before(apphosting.ensureApiEnabled)
13
15
  .action(async (backendId, options) => {
14
16
  var _a;
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.handleBuildErrors = exports.build = void 0;
4
4
  const dataconnectEmulator_1 = require("../emulator/dataconnectEmulator");
5
5
  const error_1 = require("../error");
6
- const experiments = require("../experiments");
7
6
  const prompt_1 = require("../prompt");
8
7
  const utils = require("../utils");
9
8
  const graphqlError_1 = require("./graphqlError");
@@ -12,14 +11,7 @@ async function build(options, configDir, dryRun) {
12
11
  var _a, _b;
13
12
  const account = (0, auth_1.getProjectDefaultAccount)(options.projectRoot);
14
13
  const args = { configDir, account };
15
- if (experiments.isEnabled("fdcconnectorevolution") && options.projectId) {
16
- const flags = process.env["DATA_CONNECT_PREVIEW"];
17
- if (flags) {
18
- process.env["DATA_CONNECT_PREVIEW"] = flags + ",conn_evolution";
19
- }
20
- else {
21
- process.env["DATA_CONNECT_PREVIEW"] = "conn_evolution";
22
- }
14
+ if (options.projectId) {
23
15
  args.projectId = options.projectId;
24
16
  }
25
17
  const buildResult = await dataconnectEmulator_1.DataConnectEmulator.build(args);
@@ -1,16 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.upgradeInstructions = exports.printFreeTrialUnavailable = exports.isFreeTrialError = exports.getFreeTrialInstanceId = exports.checkFreeTrialInstanceUsed = exports.freeTrialTermsLink = void 0;
4
+ const clc = require("colorette");
4
5
  const cloudmonitoring_1 = require("../gcp/cloudmonitoring");
5
6
  const cloudsqladmin_1 = require("../gcp/cloudsql/cloudsqladmin");
6
7
  const utils = require("../utils");
7
- const clc = require("colorette");
8
8
  function freeTrialTermsLink() {
9
9
  return "https://firebase.google.com/pricing";
10
10
  }
11
11
  exports.freeTrialTermsLink = freeTrialTermsLink;
12
12
  const FREE_TRIAL_METRIC = "sqladmin.googleapis.com/fdc_lifetime_free_trial_per_project";
13
13
  async function checkFreeTrialInstanceUsed(projectId) {
14
+ utils.logLabeledBullet("dataconnect", "Checking Cloud SQL no cost trial eligibility...");
14
15
  const past7d = new Date();
15
16
  past7d.setDate(past7d.getDate() - 7);
16
17
  const query = {
@@ -20,12 +21,17 @@ async function checkFreeTrialInstanceUsed(projectId) {
20
21
  };
21
22
  try {
22
23
  const ts = await (0, cloudmonitoring_1.queryTimeSeries)(query, projectId);
24
+ let used = true;
23
25
  if (ts.length) {
24
- return ts[0].points.some((p) => p.value.int64Value);
26
+ used = ts[0].points.some((p) => p.value.int64Value);
27
+ }
28
+ if (used) {
29
+ utils.logLabeledWarning("dataconnect", "CloudSQL no cost trial has already been used on this project.");
25
30
  }
26
- return true;
31
+ return used;
27
32
  }
28
33
  catch (err) {
34
+ utils.logLabeledSuccess("dataconnect", "CloudSQL no cost trial available!");
29
35
  return false;
30
36
  }
31
37
  }
@@ -8,10 +8,9 @@ const utils_1 = require("../utils");
8
8
  const logger_1 = require("../logger");
9
9
  const GOOGLE_ML_INTEGRATION_ROLE = "roles/aiplatform.user";
10
10
  const freeTrial_1 = require("./freeTrial");
11
- const error_1 = require("../error");
12
11
  async function provisionCloudSql(args) {
13
12
  let connectionName = "";
14
- const { projectId, locationId, instanceId, databaseId, configYamlPath, enableGoogleMlIntegration, waitForCreation, silent, dryRun, } = args;
13
+ const { projectId, location, instanceId, databaseId, enableGoogleMlIntegration, waitForCreation, silent, dryRun, } = args;
15
14
  try {
16
15
  const existingInstance = await cloudSqlAdminClient.getInstance(projectId, instanceId);
17
16
  silent || utils.logLabeledBullet("dataconnect", `Found existing instance ${instanceId}.`);
@@ -35,31 +34,31 @@ async function provisionCloudSql(args) {
35
34
  }
36
35
  cmekWarning();
37
36
  const cta = dryRun ? "It will be created on your next deploy" : "Creating it now.";
37
+ const freeTrialUsed = await (0, freeTrial_1.checkFreeTrialInstanceUsed)(projectId);
38
38
  silent ||
39
- utils.logLabeledBullet("dataconnect", `CloudSQL instance '${instanceId}' not found.` +
40
- cta +
41
- `\nThis instance is provided under the terms of the Data Connect no-cost trial ${(0, freeTrial_1.freeTrialTermsLink)()}` +
42
- `\nMonitor the progress at ${cloudSqlAdminClient.instanceConsoleLink(projectId, instanceId)}`);
39
+ utils.logLabeledBullet("dataconnect", `CloudSQL instance '${instanceId}' not found.` + cta + freeTrialUsed
40
+ ? ""
41
+ : `\nThis instance is provided under the terms of the Data Connect no-cost trial ${(0, freeTrial_1.freeTrialTermsLink)()}` +
42
+ dryRun
43
+ ? `\nMonitor the progress at ${cloudSqlAdminClient.instanceConsoleLink(projectId, instanceId)}`
44
+ : "");
43
45
  if (!dryRun) {
44
- try {
45
- const newInstance = await (0, utils_1.promiseWithSpinner)(() => cloudSqlAdminClient.createInstance(projectId, locationId, instanceId, enableGoogleMlIntegration, waitForCreation), "Creating your instance...");
46
- if (newInstance) {
47
- silent || utils.logLabeledBullet("dataconnect", "Instance created");
48
- connectionName = (newInstance === null || newInstance === void 0 ? void 0 : newInstance.connectionName) || "";
49
- }
50
- else {
51
- silent ||
52
- utils.logLabeledBullet("dataconnect", "Cloud SQL instance creation started - it should be ready shortly. Database and users will be created on your next deploy.");
53
- return connectionName;
54
- }
46
+ const newInstance = await (0, utils_1.promiseWithSpinner)(() => cloudSqlAdminClient.createInstance({
47
+ projectId,
48
+ location,
49
+ instanceId,
50
+ enableGoogleMlIntegration,
51
+ waitForCreation,
52
+ freeTrial: !freeTrialUsed,
53
+ }), "Creating your instance...");
54
+ if (newInstance) {
55
+ silent || utils.logLabeledBullet("dataconnect", "Instance created");
56
+ connectionName = (newInstance === null || newInstance === void 0 ? void 0 : newInstance.connectionName) || "";
55
57
  }
56
- catch (err) {
57
- if (await (0, freeTrial_1.isFreeTrialError)(err, projectId)) {
58
- const freeTrialInstanceId = await (0, freeTrial_1.getFreeTrialInstanceId)(projectId);
59
- (0, freeTrial_1.printFreeTrialUnavailable)(projectId, configYamlPath, freeTrialInstanceId);
60
- throw new error_1.FirebaseError("No-cost Cloud SQL trial has already been used on this project.");
61
- }
62
- throw err;
58
+ else {
59
+ silent ||
60
+ utils.logLabeledBullet("dataconnect", "Cloud SQL instance creation started - it should be ready shortly. Database and users will be created on your next deploy.");
61
+ return connectionName;
63
62
  }
64
63
  }
65
64
  }
@@ -114,7 +113,7 @@ function getUpdateReason(instance, requireGoogleMlIntegration) {
114
113
  }
115
114
  exports.getUpdateReason = getUpdateReason;
116
115
  function cmekWarning() {
117
- const message = "The no-cost Cloud SQL trial instance does not support customer managed encryption keys.\n" +
116
+ const message = "Cloud SQL instances created via the Firebase CLI do not support customer managed encryption keys.\n" +
118
117
  "If you'd like to use a CMEK to encrypt your data, first create a CMEK encrypted instance (https://cloud.google.com/sql/docs/postgres/configure-cmek#createcmekinstance).\n" +
119
118
  "Then, edit your `dataconnect.yaml` file to use the encrypted instance and redeploy.";
120
119
  utils.logLabeledWarning("dataconnect", message);
@@ -8,7 +8,6 @@ const provisionCloudSql_1 = require("../../dataconnect/provisionCloudSql");
8
8
  const names_1 = require("../../dataconnect/names");
9
9
  const api_1 = require("../../api");
10
10
  const ensureApiEnabled = require("../../ensureApiEnabled");
11
- const node_path_1 = require("node:path");
12
11
  const prompt_1 = require("../../prompt");
13
12
  async function default_1(context, options) {
14
13
  const projectId = (0, projectUtils_1.needProjectId)(options);
@@ -64,10 +63,9 @@ async function default_1(context, options) {
64
63
  const enableGoogleMlIntegration = (0, types_1.requiresVector)(s.deploymentMetadata);
65
64
  return (0, provisionCloudSql_1.provisionCloudSql)({
66
65
  projectId,
67
- locationId: (0, names_1.parseServiceName)(s.serviceName).location,
66
+ location: (0, names_1.parseServiceName)(s.serviceName).location,
68
67
  instanceId,
69
68
  databaseId,
70
- configYamlPath: (0, node_path_1.join)(s.sourceDirectory, "dataconnect.yaml"),
71
69
  enableGoogleMlIntegration,
72
70
  waitForCreation: true,
73
71
  });
@@ -17,7 +17,6 @@ const names_1 = require("../../dataconnect/names");
17
17
  const error_1 = require("../../error");
18
18
  const types_1 = require("../../dataconnect/types");
19
19
  const schemaMigration_1 = require("../../dataconnect/schemaMigration");
20
- const node_path_1 = require("node:path");
21
20
  const freeTrial_1 = require("../../dataconnect/freeTrial");
22
21
  async function default_1(context, options) {
23
22
  var _a;
@@ -73,10 +72,9 @@ async function default_1(context, options) {
73
72
  const enableGoogleMlIntegration = (0, types_1.requiresVector)(s.deploymentMetadata);
74
73
  return (0, provisionCloudSql_1.provisionCloudSql)({
75
74
  projectId,
76
- locationId: (0, names_1.parseServiceName)(s.serviceName).location,
75
+ location: (0, names_1.parseServiceName)(s.serviceName).location,
77
76
  instanceId,
78
77
  databaseId,
79
- configYamlPath: (0, node_path_1.join)(s.sourceDirectory, "dataconnect.yaml"),
80
78
  enableGoogleMlIntegration,
81
79
  waitForCreation: true,
82
80
  dryRun: options.dryRun,
@@ -123,8 +123,8 @@ async function setupArtifactCleanupPolicies(options, projectId, locations) {
123
123
  `${locationsWithErrors.join(", ")}.` +
124
124
  "This could result in a small monthly bill as container images accumulate over time.");
125
125
  throw new error_1.FirebaseError(`Functions successfully deployed but could not set up cleanup policy in ` +
126
- `${locationsWithErrors.length > 1 ? "regions" : "region"} ${locationsWithErrors.join(", ")}.` +
127
- `Pass the --force option to automatically set up a cleanup policy or` +
126
+ `${locationsWithErrors.length > 1 ? "regions" : "region"} ${locationsWithErrors.join(", ")}. ` +
127
+ `Pass the --force option to automatically set up a cleanup policy or ` +
128
128
  "run 'firebase functions:artifacts:setpolicy' to set up a cleanup policy to automatically delete old images.");
129
129
  }
130
130
  }
@@ -48,20 +48,20 @@ const EMULATOR_UPDATE_DETAILS = {
48
48
  },
49
49
  dataconnect: process.platform === "darwin"
50
50
  ? {
51
- version: "2.1.0",
52
- expectedSize: 26440448,
53
- expectedChecksum: "92f70b6815e1f9e46facc241728b7255",
51
+ version: "2.3.1",
52
+ expectedSize: 27271936,
53
+ expectedChecksum: "5ffcfe584c5af818477a00eb6450dd66",
54
54
  }
55
55
  : process.platform === "win32"
56
56
  ? {
57
- version: "2.1.0",
58
- expectedSize: 26884096,
59
- expectedChecksum: "14964736145cc67764574a01e193b997",
57
+ version: "2.3.1",
58
+ expectedSize: 27729408,
59
+ expectedChecksum: "b71f1686724e8e051810b3a2e14c6d08",
60
60
  }
61
61
  : {
62
- version: "2.1.0",
63
- expectedSize: 26357912,
64
- expectedChecksum: "0afb18767e56be16331be2b2b6d09ea1",
62
+ version: "2.3.1",
63
+ expectedSize: 27185304,
64
+ expectedChecksum: "54c40731f4563073404591ef1ffcdc20",
65
65
  },
66
66
  };
67
67
  exports.DownloadDetails = {
@@ -1,11 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getCredentialsEnvironment = exports.setEnvVarsForEmulators = void 0;
3
+ exports.maybeUsePortForwarding = exports.getCredentialsEnvironment = exports.setEnvVarsForEmulators = void 0;
4
4
  const constants_1 = require("./constants");
5
5
  const types_1 = require("./types");
6
6
  const functionsEmulatorShared_1 = require("./functionsEmulatorShared");
7
7
  const defaultCredentials_1 = require("../defaultCredentials");
8
8
  function setEnvVarsForEmulators(env, emulators) {
9
+ maybeUsePortForwarding(emulators);
9
10
  for (const emu of emulators) {
10
11
  const host = (0, functionsEmulatorShared_1.formatHost)(emu);
11
12
  switch (emu.name) {
@@ -59,3 +60,29 @@ async function getCredentialsEnvironment(account, logger, logLabel, silent = fal
59
60
  return credentialEnv;
60
61
  }
61
62
  exports.getCredentialsEnvironment = getCredentialsEnvironment;
63
+ function maybeUsePortForwarding(emulatorInfos) {
64
+ var _a;
65
+ const portForwardingHost = process.env.WEB_HOST;
66
+ if (portForwardingHost) {
67
+ for (const info of emulatorInfos) {
68
+ if (info.host.includes(portForwardingHost)) {
69
+ continue;
70
+ }
71
+ const url = `${info.port}-${portForwardingHost}`;
72
+ info.host = url;
73
+ info.listen = (_a = info.listen) === null || _a === void 0 ? void 0 : _a.map((l) => {
74
+ l.address = url;
75
+ l.port = 443;
76
+ return l;
77
+ });
78
+ info.port = 443;
79
+ const fsInfo = info;
80
+ if (fsInfo.webSocketPort) {
81
+ fsInfo.webSocketHost = `${fsInfo.webSocketPort}-${portForwardingHost}`;
82
+ fsInfo.webSocketPort = 443;
83
+ }
84
+ }
85
+ }
86
+ return emulatorInfos;
87
+ }
88
+ exports.maybeUsePortForwarding = maybeUsePortForwarding;
@@ -20,6 +20,7 @@ const validation_1 = require("./extensions/validation");
20
20
  const registry_1 = require("./registry");
21
21
  const types_1 = require("./types");
22
22
  const common_1 = require("../extensions/runtimes/common");
23
+ const paramHelper_1 = require("../extensions/paramHelper");
23
24
  class ExtensionsEmulator {
24
25
  constructor(args) {
25
26
  this.want = [];
@@ -170,7 +171,8 @@ class ExtensionsEmulator {
170
171
  async toEmulatableBackend(instance) {
171
172
  const extensionDir = await this.ensureSourceCode(instance);
172
173
  const functionsDir = path.join(extensionDir, "functions");
173
- const env = Object.assign(this.autoPopulatedParams(instance), instance.params);
174
+ const params = (0, paramHelper_1.populateDefaultParams)(instance.params, await planner.getExtensionSpec(instance));
175
+ const env = Object.assign(this.autoPopulatedParams(instance), params);
174
176
  const { extensionTriggers, runtime, nonSecretEnv, secretEnvVariables } = await (0, optionsHelper_1.getExtensionFunctionInfo)(instance, env);
175
177
  const emulatableBackend = {
176
178
  functionsDir,
@@ -912,6 +912,7 @@ class FunctionsEmulator {
912
912
  if (this.args.remoteEmulators) {
913
913
  emulatorInfos = emulatorInfos.concat(Object.values(this.args.remoteEmulators));
914
914
  }
915
+ (0, env_1.maybeUsePortForwarding)(emulatorInfos);
915
916
  (0, env_1.setEnvVarsForEmulators)(envs, emulatorInfos);
916
917
  if (this.debugMode) {
917
918
  envs["FUNCTION_DEBUG_MODE"] = "true";
@@ -1082,10 +1083,9 @@ class FunctionsEmulator {
1082
1083
  return;
1083
1084
  }
1084
1085
  getEmulatorInfo(emulator) {
1085
- if (this.args.remoteEmulators) {
1086
- if (this.args.remoteEmulators[emulator]) {
1087
- return this.args.remoteEmulators[emulator];
1088
- }
1086
+ var _a;
1087
+ if ((_a = this.args.remoteEmulators) === null || _a === void 0 ? void 0 : _a[emulator]) {
1088
+ return this.args.remoteEmulators[emulator];
1089
1089
  }
1090
1090
  return registry_1.EmulatorRegistry.getInfo(emulator);
1091
1091
  }
@@ -12,6 +12,7 @@ const constants_1 = require("./constants");
12
12
  const track_1 = require("../track");
13
13
  const ExpressBasedEmulator_1 = require("./ExpressBasedEmulator");
14
14
  const experiments_1 = require("../experiments");
15
+ const env_1 = require("./env");
15
16
  class EmulatorUI extends ExpressBasedEmulator_1.ExpressBasedEmulator {
16
17
  constructor(args) {
17
18
  super({
@@ -35,13 +36,9 @@ class EmulatorUI extends ExpressBasedEmulator_1.ExpressBasedEmulator {
35
36
  const downloadDetails = downloadableEmulators.getDownloadDetails(types_1.Emulators.UI);
36
37
  const webDir = path.join(downloadDetails.unzipDir, "client");
37
38
  app.get("/api/config", this.jsonHandler(() => {
38
- const json = Object.assign({ projectId, experiments: [] }, hub.getRunningEmulatorsMapping());
39
- if (emulatorGaSession) {
40
- json.analytics = emulatorGaSession;
41
- }
42
- if (enabledExperiments) {
43
- json.experiments = enabledExperiments;
44
- }
39
+ const emulatorInfos = hub.getRunningEmulatorsMapping();
40
+ (0, env_1.maybeUsePortForwarding)(Object.values(emulatorInfos));
41
+ const json = Object.assign({ projectId, experiments: enabledExperiments !== null && enabledExperiments !== void 0 ? enabledExperiments : [], analytics: emulatorGaSession }, emulatorInfos);
45
42
  return Promise.resolve(json);
46
43
  }));
47
44
  app.use(express.static(webDir));
@@ -100,12 +100,6 @@ exports.ALL_EXPERIMENTS = experiments({
100
100
  default: false,
101
101
  public: true,
102
102
  },
103
- fdcconnectorevolution: {
104
- shortDescription: "Enable Data Connect connector evolution warnings.",
105
- fullDescription: "Enable Data Connect connector evolution warnings.",
106
- default: true,
107
- public: false,
108
- },
109
103
  });
110
104
  function isValidExperiment(name) {
111
105
  return Object.keys(exports.ALL_EXPERIMENTS).includes(name);
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isSystemParam = exports.readEnvFile = exports.promptForNewParams = exports.getParamsForUpdate = exports.getParams = exports.setNewDefaults = exports.buildBindingOptionsWithBaseValue = exports.getBaseParamBindings = void 0;
3
+ exports.populateDefaultParams = exports.isSystemParam = exports.readEnvFile = exports.promptForNewParams = exports.getParamsForUpdate = exports.getParams = exports.setNewDefaults = exports.buildBindingOptionsWithBaseValue = exports.getBaseParamBindings = void 0;
4
4
  const path = require("path");
5
5
  const clc = require("colorette");
6
6
  const fs = require("fs-extra");
@@ -138,3 +138,12 @@ function isSystemParam(paramName) {
138
138
  return regex.test(paramName);
139
139
  }
140
140
  exports.isSystemParam = isSystemParam;
141
+ function populateDefaultParams(params, spec) {
142
+ var _a;
143
+ const ret = Object.assign({}, params);
144
+ for (const p of spec.params) {
145
+ ret[p.param] = (_a = ret[p.param]) !== null && _a !== void 0 ? _a : p.default;
146
+ }
147
+ return ret;
148
+ }
149
+ exports.populateDefaultParams = populateDefaultParams;
@@ -93,6 +93,7 @@ async function setCleanupPolicy(repository, daysToKeep) {
93
93
  const update = {
94
94
  name: repository.name,
95
95
  cleanupPolicies: Object.assign(Object.assign({}, repository.cleanupPolicies), generateCleanupPolicy(daysToKeep)),
96
+ cleanupPolicyDryRun: false,
96
97
  labels,
97
98
  };
98
99
  await exports.updateRepository(update);
@@ -28,7 +28,7 @@ async function getRepository(repoPath) {
28
28
  }
29
29
  exports.getRepository = getRepository;
30
30
  async function updateRepository(repo) {
31
- const updateMask = proto.fieldMasks(repo, "cleanupPolicies", "labels");
31
+ const updateMask = proto.fieldMasks(repo, "cleanupPolicies", "cleanupPolicyDryRun", "labels");
32
32
  if (updateMask.length === 0) {
33
33
  const res = await client.get(repo.name);
34
34
  return res.body;
@@ -50,16 +50,16 @@ function instanceConsoleLink(projectId, instanceId) {
50
50
  return `https://console.cloud.google.com/sql/instances/${instanceId}/overview?project=${projectId}`;
51
51
  }
52
52
  exports.instanceConsoleLink = instanceConsoleLink;
53
- async function createInstance(projectId, location, instanceId, enableGoogleMlIntegration, waitForCreation) {
53
+ async function createInstance(args) {
54
54
  const databaseFlags = [{ name: "cloudsql.iam_authentication", value: "on" }];
55
- if (enableGoogleMlIntegration) {
55
+ if (args.enableGoogleMlIntegration) {
56
56
  databaseFlags.push({ name: "cloudsql.enable_google_ml_integration", value: "on" });
57
57
  }
58
58
  let op;
59
59
  try {
60
- op = await client.post(`projects/${projectId}/instances`, {
61
- name: instanceId,
62
- region: location,
60
+ op = await client.post(`projects/${args.projectId}/instances`, {
61
+ name: args.instanceId,
62
+ region: args.location,
63
63
  databaseVersion: "POSTGRES_15",
64
64
  settings: {
65
65
  tier: "db-f1-micro",
@@ -67,10 +67,10 @@ async function createInstance(projectId, location, instanceId, enableGoogleMlInt
67
67
  ipConfiguration: {
68
68
  authorizedNetworks: [],
69
69
  },
70
- enableGoogleMlIntegration,
70
+ enableGoogleMlIntegration: args.enableGoogleMlIntegration,
71
71
  databaseFlags,
72
72
  storageAutoResize: false,
73
- userLabels: { "firebase-data-connect": "ft" },
73
+ userLabels: { "firebase-data-connect": args.freeTrial ? "ft" : "nt" },
74
74
  insightsConfig: {
75
75
  queryInsightsEnabled: true,
76
76
  queryPlansPerMinute: 5,
@@ -80,13 +80,13 @@ async function createInstance(projectId, location, instanceId, enableGoogleMlInt
80
80
  });
81
81
  }
82
82
  catch (err) {
83
- handleAllowlistError(err, location);
83
+ handleAllowlistError(err, args.location);
84
84
  throw err;
85
85
  }
86
- if (!waitForCreation) {
86
+ if (!args.waitForCreation) {
87
87
  return;
88
88
  }
89
- const opName = `projects/${projectId}/operations/${op.body.name}`;
89
+ const opName = `projects/${args.projectId}/operations/${op.body.name}`;
90
90
  const pollRes = await operationPoller.pollOperation({
91
91
  apiOrigin: (0, api_1.cloudSQLAdminOrigin)(),
92
92
  apiVersion: API_VERSION,
@@ -83,12 +83,12 @@ async function askQuestions(setup, isBillingEnabled) {
83
83
  info.cloudSqlInstanceId === "" ||
84
84
  info.locationId === "" ||
85
85
  info.cloudSqlDatabase === "";
86
- const shouldConfigureBackend = isBillingEnabled && requiredConfigUnset
87
- ? await (0, prompt_1.confirm)({
86
+ const shouldConfigureBackend = isBillingEnabled &&
87
+ requiredConfigUnset &&
88
+ (await (0, prompt_1.confirm)({
88
89
  message: `Would you like to configure your backend resources now?`,
89
90
  default: true,
90
- })
91
- : false;
91
+ }));
92
92
  if (shouldConfigureBackend) {
93
93
  info = await promptForService(info);
94
94
  info = await promptForCloudSQL(setup, info);
@@ -115,10 +115,9 @@ async function actuate(setup, config, info) {
115
115
  if (setup.projectId && info.shouldProvisionCSQL) {
116
116
  await (0, provisionCloudSql_1.provisionCloudSql)({
117
117
  projectId: setup.projectId,
118
- locationId: info.locationId,
118
+ location: info.locationId,
119
119
  instanceId: info.cloudSqlInstanceId,
120
120
  databaseId: info.cloudSqlDatabase,
121
- configYamlPath: (0, path_1.join)(config.get("dataconnect.source"), "dataconnect.yaml"),
122
121
  enableGoogleMlIntegration: false,
123
122
  waitForCreation: false,
124
123
  });
@@ -269,6 +268,9 @@ async function promptForCloudSQL(setup, info) {
269
268
  if (!(await (0, freeTrial_1.checkFreeTrialInstanceUsed)(setup.projectId))) {
270
269
  choices.push({ name: "Create a new free trial instance", value: "", location: "" });
271
270
  }
271
+ else {
272
+ choices.push({ name: "Create a new CloudSQL instance", value: "", location: "" });
273
+ }
272
274
  info.cloudSqlInstanceId = await (0, prompt_1.promptOnce)({
273
275
  message: `Which CloudSQL instance would you like to use?`,
274
276
  type: "list",
@@ -15,32 +15,43 @@ const logger_1 = require("../../../logger");
15
15
  const error_1 = require("../../../error");
16
16
  const utils_1 = require("../../../utils");
17
17
  const UNKNOWN_VERSION_TOO_HIGH = "2.0.0";
18
+ const MIN_VERSION = "0.6.0";
18
19
  const LATEST_TEMPLATE = "1.0.0";
19
- async function getGenkitVersion() {
20
- let genkitVersion;
21
- let templateVersion = LATEST_TEMPLATE;
22
- let useInit = false;
23
- let stopInstall = false;
24
- if (process.env.GENKIT_DEV_VERSION && typeof process.env.GENKIT_DEV_VERSION === "string") {
25
- semver.parse(process.env.GENKIT_DEV_VERSION);
26
- genkitVersion = process.env.GENKIT_DEV_VERSION;
27
- }
28
- else {
29
- try {
30
- genkitVersion = await (0, spawn_1.spawnWithOutput)("npm", ["view", "genkit", "version"]);
20
+ async function getPackageVersion(packageName, envVariable) {
21
+ const envVal = process.env[envVariable];
22
+ if (envVal && typeof envVal === "string") {
23
+ if (semver.parse(envVal)) {
24
+ return envVal;
31
25
  }
32
- catch (err) {
33
- throw new error_1.FirebaseError("Unable to determine which genkit version to install.\n" +
34
- `npm Error: ${(0, error_1.getErrMsg)(err)}\n\n` +
35
- "For a possible workaround run\n npm view genkit version\n" +
36
- "and then set an environment variable:\n" +
37
- " export GENKIT_DEV_VERSION=<output from previous command>\n" +
38
- "and run `firebase init genkit` again");
26
+ else {
27
+ throw new error_1.FirebaseError(`Invalid version string '${envVal}' specified in ${envVariable}`);
28
+ }
29
+ }
30
+ try {
31
+ const output = await (0, spawn_1.spawnWithOutput)("npm", ["view", packageName, "version"]);
32
+ if (!output) {
33
+ throw new error_1.FirebaseError(`Unable to determine ${packageName} version to install`);
39
34
  }
35
+ return output;
40
36
  }
41
- if (!genkitVersion) {
42
- throw new error_1.FirebaseError("Unable to determine genkit version to install");
37
+ catch (err) {
38
+ throw new error_1.FirebaseError(`Unable to determine which version of ${packageName} to install.\n` +
39
+ `npm Error: ${(0, error_1.getErrMsg)(err)}\n\n` +
40
+ "For a possible workaround run\n npm view " +
41
+ packageName +
42
+ " version\n" +
43
+ "and then set an environment variable:\n" +
44
+ ` export ${envVariable}=<output from previous command>\n` +
45
+ "and run `firebase init genkit` again");
43
46
  }
47
+ }
48
+ async function getGenkitInfo() {
49
+ let templateVersion = LATEST_TEMPLATE;
50
+ let stopInstall = false;
51
+ const genkitVersion = await getPackageVersion("genkit", "GENKIT_DEV_VERSION");
52
+ const cliVersion = await getPackageVersion("genkit-cli", "GENKIT_CLI_DEV_VERSION");
53
+ const vertexVersion = await getPackageVersion("@genkit-ai/vertexai", "GENKIT_VERTEX_VERSION");
54
+ const googleAiVersion = await getPackageVersion("@genkit-ai/googleai", "GENKIT_GOOGLEAI_VERSION");
44
55
  if (semver.gte(genkitVersion, UNKNOWN_VERSION_TOO_HIGH)) {
45
56
  const continueInstall = await (0, prompt_1.confirm)({
46
57
  message: clc.yellow(`WARNING: The latest version of Genkit (${genkitVersion}) isn't supported by this\n` +
@@ -56,24 +67,32 @@ async function getGenkitVersion() {
56
67
  else if (semver.gte(genkitVersion, "1.0.0-rc.1")) {
57
68
  templateVersion = "1.0.0";
58
69
  }
59
- else if (semver.gte(genkitVersion, "0.6.0")) {
70
+ else if (semver.gte(genkitVersion, MIN_VERSION)) {
60
71
  templateVersion = "0.9.0";
61
72
  }
62
73
  else {
63
- templateVersion = "";
64
- useInit = true;
65
- }
66
- return { genkitVersion, templateVersion, useInit, stopInstall };
74
+ throw new error_1.FirebaseError(`The requested version of Genkit (${genkitVersion}) is no ` +
75
+ `longer supported. Please specify a newer version.`);
76
+ }
77
+ return {
78
+ genkitVersion,
79
+ cliVersion,
80
+ vertexVersion,
81
+ googleAiVersion,
82
+ templateVersion,
83
+ stopInstall,
84
+ };
67
85
  }
68
- function showStartMessage(config, command) {
86
+ function showStartMessage(setup, command) {
87
+ logger_1.logger.info();
69
88
  logger_1.logger.info("\nLogin to Google Cloud using:");
70
- logger_1.logger.info(clc.bold(clc.green(` gcloud auth application-default login --project ${config.options.project}\n`)));
89
+ logger_1.logger.info(clc.bold(clc.green(` gcloud auth application-default login --project ${setup.projectId || "your-project-id"}\n`)));
71
90
  logger_1.logger.info("Then start the Genkit developer experience by running:");
72
91
  logger_1.logger.info(clc.bold(clc.green(` ${command}`)));
73
92
  }
74
93
  async function doSetup(setup, config, options) {
75
94
  var _a;
76
- const genkitInfo = await getGenkitVersion();
95
+ const genkitInfo = await getGenkitInfo();
77
96
  if (genkitInfo.stopInstall) {
78
97
  (0, utils_1.logLabeledWarning)("genkit", "Stopped Genkit initialization");
79
98
  return;
@@ -108,31 +127,16 @@ async function doSetup(setup, config, options) {
108
127
  },
109
128
  ])).choice;
110
129
  try {
111
- (0, utils_1.logLabeledBullet)("genkit", `Installing Genkit CLI version ${genkitInfo.genkitVersion}`);
130
+ (0, utils_1.logLabeledBullet)("genkit", `Installing Genkit CLI version ${genkitInfo.cliVersion}`);
112
131
  if (installType === "globally") {
113
- if (genkitInfo.useInit) {
114
- await (0, spawn_1.wrapSpawn)("npm", ["install", "-g", `genkit@${genkitInfo.genkitVersion}`], projectDir);
115
- await (0, spawn_1.wrapSpawn)("genkit", ["init", "-p", "firebase"], projectDir);
116
- logger_1.logger.info("Start the Genkit developer experience by running:");
117
- logger_1.logger.info(` cd ${setup.functions.source} && genkit start`);
118
- }
119
- else {
120
- await (0, spawn_1.wrapSpawn)("npm", ["install", "-g", `genkit-cli@${genkitInfo.genkitVersion}`], projectDir);
121
- await genkitSetup(options, genkitInfo, projectDir);
122
- showStartMessage(config, `cd ${setup.functions.source} && npm run genkit:start`);
123
- }
132
+ await (0, spawn_1.wrapSpawn)("npm", ["install", "-g", `genkit-cli@${genkitInfo.cliVersion}`], projectDir);
133
+ await genkitSetup(options, genkitInfo, projectDir);
134
+ showStartMessage(setup, `cd ${setup.functions.source} && npm run genkit:start`);
124
135
  }
125
136
  else {
126
- if (genkitInfo.useInit) {
127
- await (0, spawn_1.wrapSpawn)("npm", ["install", `genkit@${genkitInfo.genkitVersion}`, "--save-dev"], projectDir);
128
- await (0, spawn_1.wrapSpawn)("npx", ["genkit", "init", "-p", "firebase"], projectDir);
129
- showStartMessage(config, `cd ${setup.functions.source} && npx genkit start`);
130
- }
131
- else {
132
- await (0, spawn_1.wrapSpawn)("npm", ["install", `genkit-cli@${genkitInfo.genkitVersion}`, "--save-dev"], projectDir);
133
- await genkitSetup(options, genkitInfo, projectDir);
134
- showStartMessage(config, `cd ${setup.functions.source} && npm run genkit:start`);
135
- }
137
+ await (0, spawn_1.wrapSpawn)("npm", ["install", `genkit-cli@${genkitInfo.cliVersion}`, "--save-dev"], projectDir);
138
+ await genkitSetup(options, genkitInfo, projectDir);
139
+ showStartMessage(setup, `cd ${setup.functions.source} && npm run genkit:start`);
136
140
  }
137
141
  }
138
142
  catch (err) {
@@ -151,17 +155,17 @@ async function ensureVertexApiEnabled(options) {
151
155
  return await (0, ensureApiEnabled_1.ensure)(projectId, VERTEX_AI_URL, "aiplatform", silently);
152
156
  }
153
157
  exports.ensureVertexApiEnabled = ensureVertexApiEnabled;
154
- function getModelOptions(genkitVersion) {
158
+ function getModelOptions(genkitInfo) {
155
159
  const modelOptions = {
156
160
  vertexai: {
157
161
  label: "Google Cloud Vertex AI",
158
162
  plugin: "@genkit-ai/vertexai",
159
- package: `@genkit-ai/vertexai@${genkitVersion}`,
163
+ package: `@genkit-ai/vertexai@${genkitInfo.vertexVersion}`,
160
164
  },
161
165
  googleai: {
162
166
  label: "Google AI",
163
167
  plugin: "@genkit-ai/googleai",
164
- package: `@genkit-ai/googleai@${genkitVersion}`,
168
+ package: `@genkit-ai/googleai@${genkitInfo.googleAiVersion}`,
165
169
  },
166
170
  none: { label: "None", plugin: undefined, package: undefined },
167
171
  };
@@ -208,7 +212,7 @@ function getBasePackages(genkitVersion) {
208
212
  const externalDevPackages = ["typescript", "tsx"];
209
213
  async function genkitSetup(options, genkitInfo, projectDir) {
210
214
  var _a, _b;
211
- const modelOptions = getModelOptions(genkitInfo.genkitVersion);
215
+ const modelOptions = getModelOptions(genkitInfo);
212
216
  const supportedModels = Object.keys(modelOptions);
213
217
  const answer = await inquirer.prompt([
214
218
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "firebase-tools",
3
- "version": "14.1.0",
3
+ "version": "14.2.1",
4
4
  "description": "Command-Line Interface for Firebase",
5
5
  "main": "./lib/index.js",
6
6
  "bin": {
@@ -1 +1,6 @@
1
- *.local
1
+ # Python bytecode
2
+ __pycache__/
3
+
4
+ # Python virtual environment
5
+ venv/
6
+ *.local