firebase-tools-with-isolate 13.9.0 → 13.11.2

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 (35) hide show
  1. package/lib/commands/dataconnect-sdk-generate.js +15 -9
  2. package/lib/commands/dataconnect-services-list.js +1 -7
  3. package/lib/commands/dataconnect-sql-migrate.js +0 -1
  4. package/lib/crashlytics/buildToolsJarHelper.js +2 -1
  5. package/lib/dataconnect/build.js +1 -9
  6. package/lib/dataconnect/client.js +14 -22
  7. package/lib/dataconnect/errors.js +17 -9
  8. package/lib/dataconnect/graphqlError.js +6 -3
  9. package/lib/dataconnect/names.js +21 -1
  10. package/lib/dataconnect/provisionCloudSql.js +37 -20
  11. package/lib/dataconnect/schemaMigration.js +98 -66
  12. package/lib/deploy/dataconnect/deploy.js +1 -0
  13. package/lib/deploy/dataconnect/release.js +0 -1
  14. package/lib/deploy/functions/prepare.js +1 -1
  15. package/lib/deploy/functions/runtimes/discovery/index.js +2 -1
  16. package/lib/deploy/functions/runtimes/supported/types.js +6 -0
  17. package/lib/emulator/controller.js +4 -3
  18. package/lib/emulator/dataconnectEmulator.js +69 -27
  19. package/lib/emulator/download.js +4 -0
  20. package/lib/emulator/downloadableEmulators.js +51 -24
  21. package/lib/emulator/portUtils.js +11 -2
  22. package/lib/emulator/storage/rules/runtime.js +1 -1
  23. package/lib/frameworks/angular/utils.js +8 -3
  24. package/lib/frameworks/next/utils.js +0 -1
  25. package/lib/gcp/cloudsql/cloudsqladmin.js +15 -2
  26. package/lib/gcp/cloudsql/connect.js +6 -6
  27. package/lib/init/features/dataconnect/index.js +171 -109
  28. package/lib/rc.js +1 -3
  29. package/lib/requireAuth.js +3 -0
  30. package/lib/track.js +29 -2
  31. package/package.json +3 -3
  32. package/schema/firebase-config.json +2 -0
  33. package/templates/init/dataconnect/dataconnect.yaml +1 -1
  34. package/templates/init/dataconnect/mutations.gql +1 -1
  35. package/templates/init/dataconnect/queries.gql +6 -6
@@ -290,7 +290,7 @@ async function loadCodebases(config, options, firebaseConfig, runtimeConfig, fil
290
290
  const firebaseJsonRuntime = codebaseConfig.runtime;
291
291
  if (firebaseJsonRuntime && !supported.isRuntime(firebaseJsonRuntime)) {
292
292
  throw new error_1.FirebaseError(`Functions codebase ${codebase} has invalid runtime ` +
293
- `${firebaseJsonRuntime} specified in firebase.json. Valid values are: ` +
293
+ `${firebaseJsonRuntime} specified in firebase.json. Valid values are: \n` +
294
294
  Object.keys(supported.RUNTIMES)
295
295
  .map((s) => `- ${s}`)
296
296
  .join("\n"));
@@ -11,6 +11,7 @@ const api = require("../../.../../../../api");
11
11
  const v1alpha1 = require("./v1alpha1");
12
12
  const error_1 = require("../../../../error");
13
13
  exports.readFileAsync = (0, util_1.promisify)(fs.readFile);
14
+ const TIMEOUT_OVERRIDE_ENV_VAR = "FUNCTIONS_DISCOVERY_TIMEOUT";
14
15
  function yamlToBuild(yaml, project, region, runtime) {
15
16
  try {
16
17
  if (!yaml.specVersion) {
@@ -50,7 +51,7 @@ async function detectFromPort(port, project, runtime, timeout = 10000) {
50
51
  const timedOut = new Promise((resolve, reject) => {
51
52
  setTimeout(() => {
52
53
  reject(new error_1.FirebaseError("User code failed to load. Cannot determine backend specification"));
53
- }, timeout);
54
+ }, +(process.env[TIMEOUT_OVERRIDE_ENV_VAR] || 0) * 1000 || timeout);
54
55
  });
55
56
  while (true) {
56
57
  try {
@@ -53,6 +53,12 @@ exports.RUNTIMES = runtimes({
53
53
  deprecationDate: "2026-04-30",
54
54
  decommissionDate: "2026-10-31",
55
55
  },
56
+ nodejs22: {
57
+ friendly: "Node.js 22",
58
+ status: "beta",
59
+ deprecationDate: "2027-04-30",
60
+ decommissionDate: "2027-10-31",
61
+ },
56
62
  python310: {
57
63
  friendly: "Python 3.10",
58
64
  status: "GA",
@@ -522,7 +522,6 @@ async function startAll(options, showUI = true, runningTestScript = false) {
522
522
  await startEmulator(pubsubEmulator);
523
523
  }
524
524
  if (listenForEmulator.dataconnect) {
525
- const dataConnectAddr = legacyGetFirstAddr(types_1.Emulators.DATACONNECT);
526
525
  const config = (0, fileUtils_1.readFirebaseJson)(options.config);
527
526
  if (!config.length) {
528
527
  throw new error_1.FirebaseError("No Data Connect service found in firebase.json");
@@ -536,8 +535,7 @@ async function startAll(options, showUI = true, runningTestScript = false) {
536
535
  configDir = path.resolve(path.join(cwd), configDir);
537
536
  }
538
537
  const dataConnectEmulator = new dataconnectEmulator_1.DataConnectEmulator({
539
- host: dataConnectAddr.host,
540
- port: dataConnectAddr.port,
538
+ listen: listenForEmulator.dataconnect,
541
539
  projectId,
542
540
  auto_download: true,
543
541
  configDir,
@@ -545,6 +543,9 @@ async function startAll(options, showUI = true, runningTestScript = false) {
545
543
  rc: options.rc,
546
544
  });
547
545
  await startEmulator(dataConnectEmulator);
546
+ if (!utils.isVSCodeExtension()) {
547
+ await dataConnectEmulator.connectToPostgres();
548
+ }
548
549
  }
549
550
  if (listenForEmulator.storage) {
550
551
  const storageAddr = legacyGetFirstAddr(types_1.Emulators.STORAGE);
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DataConnectEmulator = void 0;
3
+ exports.DataConnectEmulatorClient = exports.DataConnectEmulator = void 0;
4
4
  const childProcess = require("child_process");
5
5
  const api_1 = require("../api");
6
6
  const constants_1 = require("./constants");
@@ -9,30 +9,33 @@ const types_1 = require("./types");
9
9
  const error_1 = require("../error");
10
10
  const emulatorLogger_1 = require("./emulatorLogger");
11
11
  const types_2 = require("../dataconnect/types");
12
- const grpcDefaultPort = 9510;
12
+ const portUtils_1 = require("./portUtils");
13
+ const registry_1 = require("./registry");
13
14
  class DataConnectEmulator {
14
15
  constructor(args) {
15
16
  this.args = args;
16
17
  this.logger = emulatorLogger_1.EmulatorLogger.forEmulator(types_1.Emulators.DATACONNECT);
18
+ this.emulatorClient = new DataConnectEmulatorClient();
17
19
  }
18
20
  async start() {
19
- const port = this.args.port || constants_1.Constants.getDefaultPort(types_1.Emulators.DATACONNECT);
20
- this.logger.log("DEBUG", `Using Postgres connection string: ${this.getLocalConectionString()}`);
21
- const info = await this.build();
22
- if ((0, types_2.requiresVector)(info.metadata)) {
23
- if (constants_1.Constants.isDemoProject(this.args.projectId)) {
24
- this.logger.logLabeled("WARN", "Data Connect", "Detected a 'demo-' project, but vector embeddings require a real project. Operations that use vector_embed will fail.");
25
- }
26
- else {
27
- this.logger.logLabeled("WARN", "Data Connect", "Operations that use vector_embed will make calls to production Vertex AI");
21
+ try {
22
+ const info = await DataConnectEmulator.build({ configDir: this.args.configDir });
23
+ if ((0, types_2.requiresVector)(info.metadata)) {
24
+ if (constants_1.Constants.isDemoProject(this.args.projectId)) {
25
+ this.logger.logLabeled("WARN", "Data Connect", "Detected a 'demo-' project, but vector embeddings require a real project. Operations that use vector_embed will fail.");
26
+ }
27
+ else {
28
+ this.logger.logLabeled("WARN", "Data Connect", "Operations that use vector_embed will make calls to production Vertex AI");
29
+ }
28
30
  }
29
31
  }
32
+ catch (err) {
33
+ this.logger.log("DEBUG", `'fdc build' failed with error: ${err.message}`);
34
+ }
30
35
  return (0, downloadableEmulators_1.start)(types_1.Emulators.DATACONNECT, {
31
- ...this.args,
32
- http_port: port,
33
- grpc_port: grpcDefaultPort,
36
+ auto_download: this.args.auto_download,
37
+ listen: (0, portUtils_1.listenSpecsToString)(this.args.listen),
34
38
  config_dir: this.args.configDir,
35
- local_connection_string: this.getLocalConectionString(),
36
39
  project_id: this.args.projectId,
37
40
  service_location: this.args.locationId,
38
41
  });
@@ -44,12 +47,11 @@ class DataConnectEmulator {
44
47
  return (0, downloadableEmulators_1.stop)(types_1.Emulators.DATACONNECT);
45
48
  }
46
49
  getInfo() {
47
- const host = this.args.host || constants_1.Constants.getDefaultHost();
48
- const port = this.args.port || constants_1.Constants.getDefaultPort(types_1.Emulators.DATACONNECT);
49
50
  return {
50
51
  name: this.getName(),
51
- host,
52
- port,
52
+ listen: this.args.listen,
53
+ host: this.args.listen[0].address,
54
+ port: this.args.listen[0].port,
53
55
  pid: (0, downloadableEmulators_1.getPID)(types_1.Emulators.DATACONNECT),
54
56
  timeout: 10000,
55
57
  };
@@ -57,26 +59,36 @@ class DataConnectEmulator {
57
59
  getName() {
58
60
  return types_1.Emulators.DATACONNECT;
59
61
  }
60
- async generate(connectorId) {
62
+ static async generate(args) {
61
63
  const commandInfo = await (0, downloadableEmulators_1.downloadIfNecessary)(types_1.Emulators.DATACONNECT);
62
64
  const cmd = [
63
65
  "generate",
64
- `--service_location=${this.args.locationId}`,
65
- `--config_dir=${this.args.configDir}`,
66
- `--connector_id=${connectorId}`,
66
+ `--service_location=${args.locationId}`,
67
+ `--config_dir=${args.configDir}`,
68
+ `--connector_id=${args.connectorId}`,
67
69
  ];
68
70
  const res = childProcess.spawnSync(commandInfo.binary, cmd, { encoding: "utf-8" });
69
71
  if (res.error) {
70
- throw new error_1.FirebaseError(`Error starting up Data Connect emulator: ${res.error}`);
72
+ throw new error_1.FirebaseError(`Error starting up Data Connect generate: ${res.error.message}`, {
73
+ original: res.error,
74
+ });
71
75
  }
72
76
  return res.stdout;
73
77
  }
74
- async build() {
78
+ static async build(args) {
75
79
  const commandInfo = await (0, downloadableEmulators_1.downloadIfNecessary)(types_1.Emulators.DATACONNECT);
76
- const cmd = ["build", `--config_dir=${this.args.configDir}`];
80
+ const cmd = ["build", `--config_dir=${args.configDir}`];
77
81
  const res = childProcess.spawnSync(commandInfo.binary, cmd, { encoding: "utf-8" });
82
+ if (res.error) {
83
+ throw new error_1.FirebaseError(`Error starting up Data Connect build: ${res.error.message}`, {
84
+ original: res.error,
85
+ });
86
+ }
87
+ if (res.status !== 0) {
88
+ throw new error_1.FirebaseError(`Unable to build your Data Connect schema and connectors (exit code ${res.status}): ${res.stderr}`);
89
+ }
78
90
  if (res.stderr) {
79
- throw new error_1.FirebaseError(`Unable to build your Data Connect schema and connectors: ${res.stderr}`);
91
+ emulatorLogger_1.EmulatorLogger.forEmulator(types_1.Emulators.DATACONNECT).log("DEBUG", res.stderr);
80
92
  }
81
93
  try {
82
94
  return JSON.parse(res.stdout);
@@ -91,5 +103,35 @@ class DataConnectEmulator {
91
103
  }
92
104
  return this.args.rc.getDataconnect()?.postgres?.localConnectionString;
93
105
  }
106
+ async connectToPostgres(localConnectionString, database, serviceId) {
107
+ const connectionString = localConnectionString ?? this.getLocalConectionString();
108
+ if (!connectionString) {
109
+ this.logger.log("DEBUG", "No Postgres connection string found, not connecting to Postgres");
110
+ return false;
111
+ }
112
+ await this.emulatorClient.configureEmulator({ connectionString, database, serviceId });
113
+ return true;
114
+ }
94
115
  }
95
116
  exports.DataConnectEmulator = DataConnectEmulator;
117
+ class DataConnectEmulatorClient {
118
+ constructor() {
119
+ this.client = undefined;
120
+ }
121
+ async configureEmulator(body) {
122
+ if (!this.client) {
123
+ this.client = registry_1.EmulatorRegistry.client(types_1.Emulators.DATACONNECT);
124
+ }
125
+ try {
126
+ const res = await this.client.post("emulator/configure", body);
127
+ return res;
128
+ }
129
+ catch (err) {
130
+ if (err.status === 500) {
131
+ throw new error_1.FirebaseError(`Data Connect emulator: ${err.context.body.message}`);
132
+ }
133
+ throw err;
134
+ }
135
+ }
136
+ }
137
+ exports.DataConnectEmulatorClient = DataConnectEmulatorClient;
@@ -13,6 +13,10 @@ const downloadUtils = require("../downloadUtils");
13
13
  tmp.setGracefulCleanup();
14
14
  async function downloadEmulator(name) {
15
15
  const emulator = downloadableEmulators.getDownloadDetails(name);
16
+ if (emulator.localOnly) {
17
+ emulatorLogger_1.EmulatorLogger.forEmulator(name).logLabeled("WARN", name, `Env variable override detected, skipping download. Using ${emulator} emulator at ${emulator.binaryPath}`);
18
+ return;
19
+ }
16
20
  emulatorLogger_1.EmulatorLogger.forEmulator(name).logLabeled("BULLET", name, `downloading ${path.basename(emulator.downloadPath)}...`);
17
21
  fs.ensureDirSync(emulator.opts.cacheDir);
18
22
  const tmpfile = await downloadUtils.downloadToTmp(emulator.opts.remoteUrl, !!emulator.opts.auth);
@@ -23,9 +23,9 @@ const EMULATOR_UPDATE_DETAILS = {
23
23
  expectedChecksum: "2fd771101c0e1f7898c04c9204f2ce63",
24
24
  },
25
25
  firestore: {
26
- version: "1.19.6",
27
- expectedSize: 66349770,
28
- expectedChecksum: "2eaabbe3cdb4867df585b7ec5505bad7",
26
+ version: "1.19.7",
27
+ expectedSize: 66438992,
28
+ expectedChecksum: "aec233bea95c5cfab03881574ec16d6c",
29
29
  },
30
30
  storage: {
31
31
  version: "1.1.3",
@@ -35,26 +35,32 @@ const EMULATOR_UPDATE_DETAILS = {
35
35
  ui: experiments.isEnabled("emulatoruisnapshot")
36
36
  ? { version: "SNAPSHOT", expectedSize: -1, expectedChecksum: "" }
37
37
  : {
38
- version: "1.11.8",
39
- expectedSize: 3523907,
40
- expectedChecksum: "49f6dc1911dda9d10df62a6c09aaf9a0",
38
+ version: "1.12.1",
39
+ expectedSize: 3498269,
40
+ expectedChecksum: "a7f4398a00e5ca22abdcd78dc3877d00",
41
41
  },
42
42
  pubsub: {
43
- version: "0.8.2",
44
- expectedSize: 65611398,
45
- expectedChecksum: "70bb840321423e6ae621a3ae2f314903",
43
+ version: "0.8.14",
44
+ expectedSize: 66786933,
45
+ expectedChecksum: "a9025b3e53fdeafd2969ccb3ba1e1d38",
46
46
  },
47
47
  dataconnect: process.platform === "darwin"
48
48
  ? {
49
- version: "1.1.17",
50
- expectedSize: 25602224,
51
- expectedChecksum: "1f9e3dd040a0ac4d1cb4d9dde4a3c0b0",
49
+ version: "1.2.0",
50
+ expectedSize: 23954240,
51
+ expectedChecksum: "0f250761959519bb5a28fed76ceab2cb",
52
52
  }
53
- : {
54
- version: "1.1.17",
55
- expectedSize: 23036912,
56
- expectedChecksum: "a0ec0517108f842ed06fea14fe7c7e56",
57
- },
53
+ : process.platform === "win32"
54
+ ? {
55
+ version: "1.2.0",
56
+ expectedSize: 24360960,
57
+ expectedChecksum: "168ce32c742e1d26037c52bdbb7d871c",
58
+ }
59
+ : {
60
+ version: "1.2.0",
61
+ expectedSize: 23970052,
62
+ expectedChecksum: "2ca17e4009a9ebae0f7c983bafff2ee6",
63
+ },
58
64
  };
59
65
  exports.DownloadDetails = {
60
66
  database: {
@@ -119,14 +125,16 @@ exports.DownloadDetails = {
119
125
  },
120
126
  },
121
127
  dataconnect: {
122
- downloadPath: path.join(CACHE_DIR, `dataconnect-emulator-${EMULATOR_UPDATE_DETAILS.dataconnect.version}`),
128
+ downloadPath: path.join(CACHE_DIR, `dataconnect-emulator-${EMULATOR_UPDATE_DETAILS.dataconnect.version}${process.platform === "win32" ? ".exe" : ""}`),
123
129
  version: EMULATOR_UPDATE_DETAILS.dataconnect.version,
124
- binaryPath: path.join(CACHE_DIR, `dataconnect-emulator-${EMULATOR_UPDATE_DETAILS.dataconnect.version}`),
130
+ binaryPath: path.join(CACHE_DIR, `dataconnect-emulator-${EMULATOR_UPDATE_DETAILS.dataconnect.version}${process.platform === "win32" ? ".exe" : ""}`),
125
131
  opts: {
126
132
  cacheDir: CACHE_DIR,
127
133
  remoteUrl: process.platform === "darwin"
128
134
  ? `https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-macos-v${EMULATOR_UPDATE_DETAILS.dataconnect.version}`
129
- : `https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-linux-v${EMULATOR_UPDATE_DETAILS.dataconnect.version}`,
135
+ : process.platform === "win32"
136
+ ? `https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-windows-v${EMULATOR_UPDATE_DETAILS.dataconnect.version}`
137
+ : `https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-linux-v${EMULATOR_UPDATE_DETAILS.dataconnect.version}`,
130
138
  expectedSize: EMULATOR_UPDATE_DETAILS.dataconnect.expectedSize,
131
139
  expectedChecksum: EMULATOR_UPDATE_DETAILS.dataconnect.expectedChecksum,
132
140
  skipChecksumAndSize: false,
@@ -232,9 +240,18 @@ const Commands = {
232
240
  dataconnect: {
233
241
  binary: getExecPath(types_1.Emulators.DATACONNECT),
234
242
  args: ["dev"],
235
- optionalArgs: ["http_port", "grpc_port", "config_dir", "local_connection_string", "project_id"],
243
+ optionalArgs: [
244
+ "listen",
245
+ "config_dir",
246
+ "project_id",
247
+ "service_location",
248
+ "disable_sdk_generation",
249
+ "resolvers_emulator",
250
+ "vertex_location",
251
+ "rpc_retry_count",
252
+ ],
236
253
  joinArgs: true,
237
- shell: true,
254
+ shell: false,
238
255
  },
239
256
  };
240
257
  function getExecPath(name) {
@@ -365,7 +382,17 @@ async function _runBinary(emulator, command, extraEnv) {
365
382
  });
366
383
  }
367
384
  function getDownloadDetails(emulator) {
368
- return exports.DownloadDetails[emulator];
385
+ const details = exports.DownloadDetails[emulator];
386
+ const pathOverride = process.env[`${emulator.toUpperCase()}_EMULATOR_BINARY_PATH`];
387
+ if (pathOverride) {
388
+ const logger = emulatorLogger_1.EmulatorLogger.forEmulator(emulator);
389
+ logger.logLabeled("WARN", emulator, `Env variable override detected. Using ${emulator} emulator at ${pathOverride}`);
390
+ details.downloadPath = pathOverride;
391
+ details.binaryPath = pathOverride;
392
+ details.localOnly = true;
393
+ fs.chmodSync(pathOverride, 0o755);
394
+ }
395
+ return details;
369
396
  }
370
397
  exports.getDownloadDetails = getDownloadDetails;
371
398
  function get(emulator) {
@@ -409,7 +436,7 @@ async function downloadIfNecessary(targetName) {
409
436
  }
410
437
  exports.downloadIfNecessary = downloadIfNecessary;
411
438
  async function start(targetName, args, extraEnv = {}) {
412
- const downloadDetails = exports.DownloadDetails[targetName];
439
+ const downloadDetails = getDownloadDetails(targetName);
413
440
  const emulator = get(targetName);
414
441
  const hasEmulator = fs.existsSync(getExecPath(targetName));
415
442
  const logger = emulatorLogger_1.EmulatorLogger.forEmulator(targetName);
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resolveHostAndAssignPorts = exports.waitForPortUsed = exports.checkListenable = void 0;
3
+ exports.listenSpecsToString = exports.resolveHostAndAssignPorts = exports.waitForPortUsed = exports.checkListenable = void 0;
4
4
  const clc = require("colorette");
5
5
  const tcpport = require("tcp-port-used");
6
6
  const node_net_1 = require("node:net");
@@ -146,7 +146,7 @@ const EMULATOR_CAN_LISTEN_ON_PRIMARY_ONLY = {
146
146
  firestore: true,
147
147
  "firestore.websocket": true,
148
148
  pubsub: true,
149
- dataconnect: true,
149
+ dataconnect: false,
150
150
  hub: false,
151
151
  ui: false,
152
152
  auth: true,
@@ -321,3 +321,12 @@ function listenSpec(lookup, port) {
321
321
  port: port,
322
322
  };
323
323
  }
324
+ function listenSpecsToString(specs) {
325
+ return specs
326
+ .map((spec) => {
327
+ const host = spec.family === "IPv4" ? spec.address : `[${spec.address}]`;
328
+ return `${host}:${spec.port}`;
329
+ })
330
+ .join(",");
331
+ }
332
+ exports.listenSpecsToString = listenSpecsToString;
@@ -73,7 +73,7 @@ class StorageRulesRuntime {
73
73
  if (this.alive) {
74
74
  return;
75
75
  }
76
- const downloadDetails = downloadableEmulators_1.DownloadDetails[types_2.Emulators.STORAGE];
76
+ const downloadDetails = (0, downloadableEmulators_1.getDownloadDetails)(types_2.Emulators.STORAGE);
77
77
  const hasEmulator = fs.existsSync(downloadDetails.downloadPath);
78
78
  if (!hasEmulator) {
79
79
  if (autoDownload) {
@@ -309,6 +309,8 @@ async function getContext(dir, targetOrConfiguration) {
309
309
  continue;
310
310
  if (target === buildTarget && builder === "@angular-devkit/build-angular:application")
311
311
  continue;
312
+ if (target === buildTarget && builder === "@angular-devkit/build-angular:browser")
313
+ continue;
312
314
  if (target === browserTarget && builder === "@angular-devkit/build-angular:browser-esbuild")
313
315
  continue;
314
316
  if (target === browserTarget && builder === "@angular-devkit/build-angular:browser")
@@ -363,10 +365,13 @@ async function getBrowserConfig(sourceDir, configuration) {
363
365
  if (!buildOrBrowserTarget) {
364
366
  throw new assert_1.AssertionError({ message: "expected build or browser target defined" });
365
367
  }
366
- const { locales, defaultLocale } = await localesForTarget(sourceDir, architectHost, buildOrBrowserTarget, workspaceProject);
367
- const targetOptions = await architectHost.getOptionsForTarget(buildOrBrowserTarget);
368
+ const [{ locales, defaultLocale }, targetOptions, builderName] = await Promise.all([
369
+ localesForTarget(sourceDir, architectHost, buildOrBrowserTarget, workspaceProject),
370
+ architectHost.getOptionsForTarget(buildOrBrowserTarget),
371
+ architectHost.getBuilderNameForTarget(buildOrBrowserTarget),
372
+ ]);
368
373
  (0, utils_2.assertIsString)(targetOptions?.outputPath);
369
- const outputPath = (0, path_1.join)(targetOptions.outputPath, buildTarget ? "browser" : "");
374
+ const outputPath = (0, path_1.join)(targetOptions.outputPath, buildTarget && builderName === "@angular-devkit/build-angular:application" ? "browser" : "");
370
375
  return { locales, baseHref, outputPath, defaultLocale };
371
376
  }
372
377
  exports.getBrowserConfig = getBrowserConfig;
@@ -234,7 +234,6 @@ async function getProductionDistDirFiles(sourceDir, distDir) {
234
234
  cwd: (0, path_1.join)(sourceDir, distDir),
235
235
  nodir: true,
236
236
  absolute: false,
237
- realpath: utils_2.IS_WINDOWS,
238
237
  }, (err, matches) => {
239
238
  if (err)
240
239
  reject(err);
@@ -1,9 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.listUsers = exports.deleteUser = exports.getUser = exports.createUser = exports.createDatabase = exports.getDatabase = exports.listDatabases = exports.updateInstanceForDataConnect = exports.createInstance = exports.getInstance = exports.listInstances = void 0;
3
+ exports.listUsers = exports.deleteUser = exports.getUser = exports.createUser = exports.createDatabase = exports.getDatabase = exports.listDatabases = exports.updateInstanceForDataConnect = exports.createInstance = exports.instanceConsoleLink = exports.getInstance = exports.listInstances = void 0;
4
4
  const apiv2_1 = require("../../apiv2");
5
5
  const api_1 = require("../../api");
6
6
  const operationPoller = require("../../operation-poller");
7
+ const error_1 = require("../../error");
7
8
  const API_VERSION = "v1";
8
9
  const client = new apiv2_1.Client({
9
10
  urlPrefix: (0, api_1.cloudSQLAdminOrigin)(),
@@ -17,10 +18,17 @@ async function listInstances(projectId) {
17
18
  exports.listInstances = listInstances;
18
19
  async function getInstance(projectId, instanceId) {
19
20
  const res = await client.get(`projects/${projectId}/instances/${instanceId}`);
21
+ if (res.body.state === "FAILED") {
22
+ throw new error_1.FirebaseError(`Cloud SQL instance ${instanceId} is in a failed state.\nGo to ${instanceConsoleLink(projectId, instanceId)} to repair or delete it.`);
23
+ }
20
24
  return res.body;
21
25
  }
22
26
  exports.getInstance = getInstance;
23
- async function createInstance(projectId, location, instanceId, enableGoogleMlIntegration) {
27
+ function instanceConsoleLink(projectId, instanceId) {
28
+ return `https://console.cloud.google.com/sql/instances/${instanceId}/overview?project=${projectId}`;
29
+ }
30
+ exports.instanceConsoleLink = instanceConsoleLink;
31
+ async function createInstance(projectId, location, instanceId, enableGoogleMlIntegration, waitForCreation) {
24
32
  const databaseFlags = [{ name: "cloudsql.iam_authentication", value: "on" }];
25
33
  if (enableGoogleMlIntegration) {
26
34
  databaseFlags.push({ name: "cloudsql.enable_google_ml_integration", value: "on" });
@@ -41,9 +49,14 @@ async function createInstance(projectId, location, instanceId, enableGoogleMlInt
41
49
  userLabels: { "firebase-data-connect": "ft" },
42
50
  insightsConfig: {
43
51
  queryInsightsEnabled: true,
52
+ queryPlansPerMinute: 5,
53
+ queryStringLength: 1024,
44
54
  },
45
55
  },
46
56
  });
57
+ if (!waitForCreation) {
58
+ return;
59
+ }
47
60
  const opName = `projects/${projectId}/operations/${op.body.name}`;
48
61
  const pollRes = await operationPoller.pollOperation({
49
62
  apiOrigin: (0, api_1.cloudSQLAdminOrigin)(),
@@ -16,7 +16,7 @@ async function execute(sqlStatements, opts) {
16
16
  const user = await cloudSqlAdminClient.getUser(opts.projectId, opts.instanceId, opts.username);
17
17
  const connectionName = instance.connectionName;
18
18
  if (!connectionName) {
19
- throw new error_1.FirebaseError(`Could not get instance conection string for ${opts.instanceId}:${opts.databaseId}`);
19
+ throw new error_1.FirebaseError(`Could not get instance connection string for ${opts.instanceId}:${opts.databaseId}`);
20
20
  }
21
21
  let connector;
22
22
  let pool;
@@ -34,7 +34,6 @@ async function execute(sqlStatements, opts) {
34
34
  ...clientOpts,
35
35
  user: opts.username,
36
36
  database: opts.databaseId,
37
- max: 1,
38
37
  });
39
38
  break;
40
39
  }
@@ -49,7 +48,6 @@ async function execute(sqlStatements, opts) {
49
48
  ...clientOpts,
50
49
  user: opts.username,
51
50
  database: opts.databaseId,
52
- max: 1,
53
51
  });
54
52
  break;
55
53
  }
@@ -69,20 +67,22 @@ async function execute(sqlStatements, opts) {
69
67
  user: opts.username,
70
68
  password: opts.password,
71
69
  database: opts.databaseId,
72
- max: 1,
73
70
  });
74
71
  break;
75
72
  }
76
73
  }
74
+ const conn = await pool.connect();
75
+ logFn(`Logged in as ${opts.username}`);
77
76
  for (const s of sqlStatements) {
78
- logFn(`Executing: '${s}' as ${opts.username}`);
77
+ logFn(`Executing: '${s}'`);
79
78
  try {
80
- await pool.query(s);
79
+ await conn.query(s);
81
80
  }
82
81
  catch (err) {
83
82
  throw new error_1.FirebaseError(`Error executing ${err}`);
84
83
  }
85
84
  }
85
+ conn.release();
86
86
  await pool.end();
87
87
  connector.close();
88
88
  }