firebase-tools 13.26.0 → 13.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) 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 +4 -26
  10. package/lib/commands/firestore-indexes-list.js +4 -2
  11. package/lib/commands/index.js +4 -6
  12. package/lib/dataconnect/schemaMigration.js +8 -15
  13. package/lib/dataconnect/types.js +1 -1
  14. package/lib/deploy/extensions/tasks.js +2 -2
  15. package/lib/deploy/functions/release/fabricator.js +3 -3
  16. package/lib/emulator/apphosting/developmentServer.js +32 -0
  17. package/lib/emulator/apphosting/index.js +5 -4
  18. package/lib/emulator/apphosting/serve.js +8 -7
  19. package/lib/emulator/auth/operations.js +8 -5
  20. package/lib/emulator/commandUtils.js +2 -1
  21. package/lib/emulator/controller.js +31 -18
  22. package/lib/emulator/dataconnect/pgliteServer.js +51 -18
  23. package/lib/emulator/dataconnectEmulator.js +36 -2
  24. package/lib/emulator/downloadableEmulators.js +23 -10
  25. package/lib/emulator/eventarcEmulator.js +1 -0
  26. package/lib/emulator/hub.js +16 -0
  27. package/lib/emulator/hubExport.js +23 -0
  28. package/lib/emulator/initEmulators.js +64 -0
  29. package/lib/emulator/types.js +2 -2
  30. package/lib/error.js +9 -1
  31. package/lib/experiments.js +0 -6
  32. package/lib/extensions/localHelper.js +2 -2
  33. package/lib/extensions/runtimes/node.js +16 -15
  34. package/lib/extensions/types.js +6 -9
  35. package/lib/gcp/cloudfunctionsv2.js +1 -0
  36. package/lib/init/features/dataconnect/index.js +4 -5
  37. package/lib/init/features/emulators.js +8 -0
  38. package/lib/init/features/genkit/index.js +13 -5
  39. package/lib/init/spawn.js +38 -7
  40. package/lib/requireAuth.js +2 -1
  41. package/lib/utils.js +16 -1
  42. package/package.json +3 -2
  43. package/schema/firebase-config.json +6 -0
  44. package/templates/init/dataconnect/dataconnect.yaml +1 -0
  45. package/lib/emulator/apphosting/utils.js +0 -18
  46. package/templates/init/dataconnect/dataconnect-fdccompatiblemode.yaml +0 -12
package/lib/error.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isBillingError = exports.getError = exports.getErrStatus = exports.getErrMsg = exports.FirebaseError = void 0;
3
+ exports.isBillingError = exports.getError = exports.getErrStatus = exports.isObject = exports.getErrStack = exports.getErrMsg = exports.FirebaseError = void 0;
4
4
  const lodash_1 = require("lodash");
5
5
  const DEFAULT_CHILDREN = [];
6
6
  const DEFAULT_EXIT = 1;
@@ -31,9 +31,17 @@ function getErrMsg(err, defaultMsg) {
31
31
  return JSON.stringify(err);
32
32
  }
33
33
  exports.getErrMsg = getErrMsg;
34
+ function getErrStack(err) {
35
+ if (err instanceof Error) {
36
+ return err.stack || err.message;
37
+ }
38
+ return getErrMsg(err);
39
+ }
40
+ exports.getErrStack = getErrStack;
34
41
  function isObject(value) {
35
42
  return typeof value === "object" && value !== null;
36
43
  }
44
+ exports.isObject = isObject;
37
45
  function getErrStatus(err, defaultStatus) {
38
46
  if (isObject(err) && err.status && typeof err.status === "number") {
39
47
  return err.status;
@@ -106,12 +106,6 @@ exports.ALL_EXPERIMENTS = experiments({
106
106
  default: true,
107
107
  public: false,
108
108
  },
109
- fdccompatiblemode: {
110
- shortDescription: "Enable Data Connect schema migrations in Compatible Mode",
111
- fullDescription: "Enable Data Connect schema migrations in Compatible Mode",
112
- default: true,
113
- public: false,
114
- },
115
109
  });
116
110
  function isValidExperiment(name) {
117
111
  return Object.keys(exports.ALL_EXPERIMENTS).includes(name);
@@ -38,9 +38,9 @@ function fixLifecycleEvents(lifecycleEvents) {
38
38
  stageUnspecified: "STAGE_UNSPECIFIED",
39
39
  };
40
40
  const arrayLifecycle = [];
41
- if ((0, types_1.isObject)(lifecycleEvents)) {
41
+ if ((0, error_1.isObject)(lifecycleEvents)) {
42
42
  for (const [key, val] of Object.entries(lifecycleEvents)) {
43
- if ((0, types_1.isObject)(val) &&
43
+ if ((0, error_1.isObject)(val) &&
44
44
  typeof val.function === "string" &&
45
45
  typeof val.processingMessage === "string") {
46
46
  arrayLifecycle.push({
@@ -2,9 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.writeSDK = exports.TYPESCRIPT_VERSION = exports.FIREBASE_FUNCTIONS_VERSION = exports.SDK_GENERATION_VERSION = void 0;
4
4
  const path = require("path");
5
- const child_process_1 = require("child_process");
6
5
  const marked_terminal_1 = require("marked-terminal");
7
6
  const marked_1 = require("marked");
7
+ const error_1 = require("../../error");
8
8
  const types_1 = require("../types");
9
9
  const prompt_1 = require("../../prompt");
10
10
  const secretsUtils = require("../secretsUtils");
@@ -12,7 +12,8 @@ const utils_1 = require("../../utils");
12
12
  const common_1 = require("./common");
13
13
  const askUserForEventsConfig_1 = require("../askUserForEventsConfig");
14
14
  const extensionsHelper_1 = require("../extensionsHelper");
15
- const error_1 = require("../../error");
15
+ const error_2 = require("../../error");
16
+ const spawn_1 = require("../../init/spawn");
16
17
  marked_1.marked.use((0, marked_terminal_1.markedTerminal)());
17
18
  exports.SDK_GENERATION_VERSION = "1.0.0";
18
19
  exports.FIREBASE_FUNCTIONS_VERSION = ">=5.1.0";
@@ -91,8 +92,8 @@ function addPeerDependency(pkgJson, dependency, version) {
91
92
  if (!pkgJson.peerDependencies) {
92
93
  pkgJson.peerDependencies = {};
93
94
  }
94
- if (!(0, types_1.isObject)(pkgJson.peerDependencies)) {
95
- throw new error_1.FirebaseError("Internal error generating peer dependencies.");
95
+ if (!(0, error_1.isObject)(pkgJson.peerDependencies)) {
96
+ throw new error_2.FirebaseError("Internal error generating peer dependencies.");
96
97
  }
97
98
  pkgJson.peerDependencies[dependency] = version;
98
99
  }
@@ -118,7 +119,7 @@ async function writeSDK(extensionRef, localPath, spec, options) {
118
119
  }
119
120
  }
120
121
  if (!dirPath) {
121
- throw new error_1.FirebaseError("Invalid extension definition. Must have either extensionRef or localPath");
122
+ throw new error_2.FirebaseError("Invalid extension definition. Must have either extensionRef or localPath");
122
123
  }
123
124
  const packageName = makePackageName(extensionRef, spec.name);
124
125
  const pkgJson = {
@@ -292,7 +293,7 @@ async function writeSDK(extensionRef, localPath, spec, options) {
292
293
  sdkLines.push(` ${sysParam.param}${opt}: string;`);
293
294
  break;
294
295
  default:
295
- throw new error_1.FirebaseError(`Error: Unknown systemParam type: ${sysParam.type || "undefined"}.`);
296
+ throw new error_2.FirebaseError(`Error: Unknown systemParam type: ${sysParam.type || "undefined"}.`);
296
297
  }
297
298
  sdkLines.push("");
298
299
  }
@@ -347,19 +348,19 @@ async function writeSDK(extensionRef, localPath, spec, options) {
347
348
  await (0, common_1.writeFile)(`${dirPath}/tsconfig.json`, JSON.stringify(tsconfigJson, null, 2), options);
348
349
  (0, utils_1.logLabeledBullet)("extensions", `running 'npm --prefix ${shortDirPath} install'`);
349
350
  try {
350
- (0, child_process_1.execFileSync)("npm", ["--prefix", dirPath, "install"]);
351
+ await (0, spawn_1.spawnWithOutput)("npm", ["--prefix", dirPath, "install"]);
351
352
  }
352
353
  catch (err) {
353
- const errMsg = (0, error_1.getErrMsg)(err, "unknown error");
354
- throw new error_1.FirebaseError(`Error during npm install in ${shortDirPath}: ${errMsg}`);
354
+ const errMsg = (0, error_2.getErrMsg)(err, "unknown error");
355
+ throw new error_2.FirebaseError(`Error during npm install in ${shortDirPath}: ${errMsg}`);
355
356
  }
356
357
  (0, utils_1.logLabeledBullet)("extensions", `running 'npm --prefix ${shortDirPath} run build'`);
357
358
  try {
358
- (0, child_process_1.execFileSync)("npm", ["--prefix", dirPath, "run", "build"]);
359
+ await (0, spawn_1.spawnWithOutput)("npm", ["--prefix", dirPath, "run", "build"]);
359
360
  }
360
361
  catch (err) {
361
- const errMsg = (0, error_1.getErrMsg)(err, "unknown error");
362
- throw new error_1.FirebaseError(`Error during npm run build in ${shortDirPath}: ${errMsg}`);
362
+ const errMsg = (0, error_2.getErrMsg)(err, "unknown error");
363
+ throw new error_2.FirebaseError(`Error during npm run build in ${shortDirPath}: ${errMsg}`);
363
364
  }
364
365
  const codebaseDir = (0, common_1.getCodebaseDir)(options);
365
366
  const shortCodebaseDir = codebaseDir.replace(process.cwd(), ".");
@@ -372,11 +373,11 @@ async function writeSDK(extensionRef, localPath, spec, options) {
372
373
  })) {
373
374
  (0, utils_1.logLabeledBullet)("extensions", `running 'npm --prefix ${shortCodebaseDir} install --save ${shortDirPath}'`);
374
375
  try {
375
- (0, child_process_1.execFileSync)("npm", ["--prefix", codebaseDir, "install", "--save", dirPath]);
376
+ await (0, spawn_1.spawnWithOutput)("npm", ["--prefix", codebaseDir, "install", "--save", dirPath]);
376
377
  }
377
378
  catch (err) {
378
- const errMsg = (0, error_1.getErrMsg)(err, "unknown error");
379
- throw new error_1.FirebaseError(`Error during npm install in ${codebaseDir}: ${errMsg}`);
379
+ const errMsg = (0, error_2.getErrMsg)(err, "unknown error");
380
+ throw new error_2.FirebaseError(`Error during npm install in ${codebaseDir}: ${errMsg}`);
380
381
  }
381
382
  }
382
383
  else {
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isExtensionSpec = exports.isResource = exports.isParam = exports.isObject = exports.ParamType = exports.FUNCTIONS_V2_RESOURCE_TYPE = exports.FUNCTIONS_RESOURCE_TYPE = exports.isExtensionInstance = exports.Visibility = exports.RegistryLaunchStage = void 0;
3
+ exports.isExtensionSpec = exports.isResource = exports.isParam = exports.ParamType = exports.FUNCTIONS_V2_RESOURCE_TYPE = exports.FUNCTIONS_RESOURCE_TYPE = exports.isExtensionInstance = exports.Visibility = exports.RegistryLaunchStage = void 0;
4
+ const error_1 = require("../error");
4
5
  var RegistryLaunchStage;
5
6
  (function (RegistryLaunchStage) {
6
7
  RegistryLaunchStage["EXPERIMENTAL"] = "EXPERIMENTAL";
@@ -23,7 +24,7 @@ const extensionInstanceState = [
23
24
  "PAUSED",
24
25
  ];
25
26
  const isExtensionInstance = (value) => {
26
- if (!isObject(value) || typeof value.name !== "string") {
27
+ if (!(0, error_1.isObject)(value) || typeof value.name !== "string") {
27
28
  return false;
28
29
  }
29
30
  return true;
@@ -40,20 +41,16 @@ var ParamType;
40
41
  ParamType["SELECT_RESOURCE"] = "SELECT_RESOURCE";
41
42
  ParamType["SECRET"] = "SECRET";
42
43
  })(ParamType = exports.ParamType || (exports.ParamType = {}));
43
- function isObject(value) {
44
- return typeof value === "object" && value !== null;
45
- }
46
- exports.isObject = isObject;
47
44
  const isParam = (param) => {
48
- return (isObject(param) && typeof param["param"] === "string" && typeof param["label"] === "string");
45
+ return ((0, error_1.isObject)(param) && typeof param["param"] === "string" && typeof param["label"] === "string");
49
46
  };
50
47
  exports.isParam = isParam;
51
48
  const isResource = (res) => {
52
- return isObject(res) && typeof res["name"] === "string";
49
+ return (0, error_1.isObject)(res) && typeof res["name"] === "string";
53
50
  };
54
51
  exports.isResource = isResource;
55
52
  const isExtensionSpec = (spec) => {
56
- if (!isObject(spec) || typeof spec.name !== "string" || typeof spec.version !== "string") {
53
+ if (!(0, error_1.isObject)(spec) || typeof spec.name !== "string" || typeof spec.version !== "string") {
57
54
  return false;
58
55
  }
59
56
  if (spec.resources && Array.isArray(spec.resources)) {
@@ -381,6 +381,7 @@ function endpointFromFunction(gcfFunction) {
381
381
  endpoint.runServiceId = utils.last(serviceName.split("/"));
382
382
  }
383
383
  }
384
+ proto.renameIfPresent(endpoint, gcfFunction, "uri", "url");
384
385
  endpoint.codebase = ((_e = gcfFunction.labels) === null || _e === void 0 ? void 0 : _e[constants_1.CODEBASE_LABEL]) || projectConfig.DEFAULT_CODEBASE;
385
386
  if ((_f = gcfFunction.labels) === null || _f === void 0 ? void 0 : _f[constants_1.HASH_LABEL]) {
386
387
  endpoint.hash = gcfFunction.labels[constants_1.HASH_LABEL];
@@ -8,7 +8,6 @@ const provisionCloudSql_1 = require("../../../dataconnect/provisionCloudSql");
8
8
  const freeTrial_1 = require("../../../dataconnect/freeTrial");
9
9
  const cloudsql = require("../../../gcp/cloudsql/cloudsqladmin");
10
10
  const ensureApis_1 = require("../../../dataconnect/ensureApis");
11
- const experiments = require("../../../experiments");
12
11
  const client_1 = require("../../../dataconnect/client");
13
12
  const types_1 = require("../../../dataconnect/types");
14
13
  const names_1 = require("../../../dataconnect/names");
@@ -19,7 +18,6 @@ const cloudbilling_1 = require("../../../gcp/cloudbilling");
19
18
  const sdk = require("./sdk");
20
19
  const fileUtils_1 = require("../../../dataconnect/fileUtils");
21
20
  const DATACONNECT_YAML_TEMPLATE = (0, templates_1.readTemplateSync)("init/dataconnect/dataconnect.yaml");
22
- const DATACONNECT_YAML_COMPAT_EXPERIMENT_TEMPLATE = (0, templates_1.readTemplateSync)("init/dataconnect/dataconnect-fdccompatiblemode.yaml");
23
21
  const CONNECTOR_YAML_TEMPLATE = (0, templates_1.readTemplateSync)("init/dataconnect/connector.yaml");
24
22
  const SCHEMA_TEMPLATE = (0, templates_1.readTemplateSync)("init/dataconnect/schema.gql");
25
23
  const QUERIES_TEMPLATE = (0, templates_1.readTemplateSync)("init/dataconnect/queries.gql");
@@ -50,6 +48,9 @@ async function doSetup(setup, config) {
50
48
  isBillingEnabled ? await (0, ensureApis_1.ensureApis)(setup.projectId) : await (0, ensureApis_1.ensureSparkApis)(setup.projectId);
51
49
  }
52
50
  const info = await askQuestions(setup, isBillingEnabled);
51
+ const dir = config.get("dataconnect.source", "dataconnect");
52
+ const dataDir = config.get("emulators.dataconnect.dataDir", `${dir}/.dataconnect/pgliteData`);
53
+ config.set("emulators.dataconnect.dataDir", dataDir);
53
54
  await actuate(setup, config, info);
54
55
  const cwdPlatformGuess = await (0, fileUtils_1.getPlatformFromFolder)(process.cwd());
55
56
  if (cwdPlatformGuess !== types_1.Platform.NONE) {
@@ -156,9 +157,7 @@ function subDataconnectYamlValues(replacementValues) {
156
157
  connectorDirs: "__connectorDirs__",
157
158
  locationId: "__location__",
158
159
  };
159
- let replaced = experiments.isEnabled("fdccompatiblemode")
160
- ? DATACONNECT_YAML_COMPAT_EXPERIMENT_TEMPLATE
161
- : DATACONNECT_YAML_TEMPLATE;
160
+ let replaced = DATACONNECT_YAML_TEMPLATE;
162
161
  for (const [k, v] of Object.entries(replacementValues)) {
163
162
  replaced = replaced.replace(replacements[k], JSON.stringify(v));
164
163
  }
@@ -7,6 +7,7 @@ const prompt_1 = require("../../prompt");
7
7
  const types_1 = require("../../emulator/types");
8
8
  const constants_1 = require("../../emulator/constants");
9
9
  const downloadableEmulators_1 = require("../../emulator/downloadableEmulators");
10
+ const initEmulators_1 = require("../../emulator/initEmulators");
10
11
  async function doSetup(setup, config) {
11
12
  var _a, _b, _c;
12
13
  const choices = types_1.ALL_SERVICE_EMULATORS.map((e) => {
@@ -46,6 +47,13 @@ async function doSetup(setup, config) {
46
47
  },
47
48
  ]);
48
49
  }
50
+ const additionalInitFn = initEmulators_1.AdditionalInitFns[selected];
51
+ if (additionalInitFn) {
52
+ const additionalOptions = await additionalInitFn(config);
53
+ if (additionalOptions) {
54
+ setup.config.emulators[selected] = Object.assign(Object.assign({}, setup.config.emulators[selected]), additionalOptions);
55
+ }
56
+ }
49
57
  }
50
58
  if (selections.emulators.length) {
51
59
  const uiDesc = constants_1.Constants.description(types_1.Emulators.UI);
@@ -6,7 +6,6 @@ const inquirer = require("inquirer");
6
6
  const path = require("path");
7
7
  const semver = require("semver");
8
8
  const clc = require("colorette");
9
- const child_process_1 = require("child_process");
10
9
  const functions_1 = require("../functions");
11
10
  const prompt_1 = require("../../../prompt");
12
11
  const spawn_1 = require("../../spawn");
@@ -15,7 +14,6 @@ const ensureApiEnabled_1 = require("../../../ensureApiEnabled");
15
14
  const logger_1 = require("../../../logger");
16
15
  const error_1 = require("../../../error");
17
16
  const utils_1 = require("../../../utils");
18
- const types_1 = require("../../../extensions/types");
19
17
  async function getGenkitVersion() {
20
18
  let genkitVersion;
21
19
  let templateVersion = "0.9.0";
@@ -26,7 +24,17 @@ async function getGenkitVersion() {
26
24
  genkitVersion = process.env.GENKIT_DEV_VERSION;
27
25
  }
28
26
  else {
29
- genkitVersion = (0, child_process_1.execFileSync)("npm", ["view", "genkit", "version"]).toString();
27
+ try {
28
+ genkitVersion = await (0, spawn_1.spawnWithOutput)("npm", ["view", "genkit", "version"]);
29
+ }
30
+ catch (err) {
31
+ throw new error_1.FirebaseError("Unable to determine which genkit version to install.\n" +
32
+ `npm Error: ${(0, error_1.getErrMsg)(err)}\n\n` +
33
+ "For a possible workaround run\n npm view genkit version\n" +
34
+ "and then set an environment variable:\n" +
35
+ " export GENKIT_DEV_VERSION=<output from previous command>\n" +
36
+ "and run `firebase init genkit` again");
37
+ }
30
38
  }
31
39
  if (!genkitVersion) {
32
40
  throw new error_1.FirebaseError("Unable to determine genkit version to install");
@@ -236,7 +244,7 @@ async function genkitSetup(options, genkitInfo, projectDir) {
236
244
  }
237
245
  exports.genkitSetup = genkitSetup;
238
246
  const isTsConfig = (value) => {
239
- if (!(0, types_1.isObject)(value) || (value.compilerOptions && !(0, types_1.isObject)(value.compilerOptions))) {
247
+ if (!(0, error_1.isObject)(value) || (value.compilerOptions && !(0, error_1.isObject)(value.compilerOptions))) {
240
248
  return false;
241
249
  }
242
250
  return true;
@@ -339,7 +347,7 @@ function generateSampleFile(modelPlugin, configPlugins, projectDir, templateVers
339
347
  }
340
348
  }
341
349
  const isPackageJson = (value) => {
342
- if (!(0, types_1.isObject)(value) || (value.scripts && !(0, types_1.isObject)(value.scripts))) {
350
+ if (!(0, error_1.isObject)(value) || (value.scripts && !(0, error_1.isObject)(value.scripts))) {
343
351
  return false;
344
352
  }
345
353
  return true;
package/lib/init/spawn.js CHANGED
@@ -1,27 +1,58 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.spawnWithCommandString = exports.wrapSpawn = void 0;
3
+ exports.spawnWithCommandString = exports.spawnWithOutput = exports.wrapSpawn = void 0;
4
4
  const spawn = require("cross-spawn");
5
5
  const logger_1 = require("../logger");
6
- function wrapSpawn(cmd, args, projectDir, environmentVariables) {
6
+ const error_1 = require("../error");
7
+ function wrapSpawn(cmd, args, projectDir) {
7
8
  return new Promise((resolve, reject) => {
8
9
  const installer = spawn(cmd, args, {
9
10
  cwd: projectDir,
10
11
  stdio: "inherit",
11
- env: Object.assign(Object.assign({}, process.env), environmentVariables),
12
+ env: Object.assign({}, process.env),
12
13
  });
13
14
  installer.on("error", (err) => {
14
- logger_1.logger.debug(err.stack);
15
+ logger_1.logger.debug((0, error_1.getErrStack)(err));
15
16
  });
16
17
  installer.on("close", (code) => {
17
18
  if (code === 0) {
18
19
  return resolve();
19
20
  }
20
- return reject();
21
+ return reject(new Error(`Error: spawn(${cmd}, [${args.join(", ")}]) \n exited with code: ${code || "null"}`));
21
22
  });
22
23
  });
23
24
  }
24
25
  exports.wrapSpawn = wrapSpawn;
26
+ function spawnWithOutput(cmd, args) {
27
+ return new Promise((resolve, reject) => {
28
+ var _a, _b;
29
+ const child = spawn(cmd, args);
30
+ let output = "";
31
+ (_a = child.stdout) === null || _a === void 0 ? void 0 : _a.on("data", (data) => {
32
+ if ((0, error_1.isObject)(data) && data.toString) {
33
+ output += data.toString();
34
+ }
35
+ else {
36
+ output += JSON.stringify(data);
37
+ }
38
+ });
39
+ (_b = child.stderr) === null || _b === void 0 ? void 0 : _b.on("data", (data) => {
40
+ logger_1.logger.debug(`Error: spawn(${cmd}, ${args.join(", ")})\n Stderr:\n${JSON.stringify(data)}\n`);
41
+ });
42
+ child.on("error", (err) => {
43
+ logger_1.logger.debug((0, error_1.getErrStack)(err));
44
+ });
45
+ child.on("close", (code) => {
46
+ if (code === 0) {
47
+ resolve(output);
48
+ }
49
+ else {
50
+ reject(new Error(`Error: spawn(${cmd}, [${args.join(", ")}]) \n exited with code: ${code || "null"}`));
51
+ }
52
+ });
53
+ });
54
+ }
55
+ exports.spawnWithOutput = spawnWithOutput;
25
56
  function spawnWithCommandString(cmd, projectDir, environmentVariables) {
26
57
  return new Promise((resolve, reject) => {
27
58
  const installer = spawn(cmd, {
@@ -31,13 +62,13 @@ function spawnWithCommandString(cmd, projectDir, environmentVariables) {
31
62
  env: Object.assign(Object.assign({}, process.env), environmentVariables),
32
63
  });
33
64
  installer.on("error", (err) => {
34
- logger_1.logger.log("DEBUG", err.stack);
65
+ logger_1.logger.log("DEBUG", (0, error_1.getErrStack)(err));
35
66
  });
36
67
  installer.on("close", (code) => {
37
68
  if (code === 0) {
38
69
  return resolve();
39
70
  }
40
- return reject();
71
+ return reject(new Error(`Error: spawn(${cmd}) \n exited with code: ${code || "null"}`));
41
72
  });
42
73
  });
43
74
  }
@@ -25,6 +25,7 @@ async function autoAuth(options, authScopes) {
25
25
  const client = getAuthClient({ scopes: authScopes, projectId: options.project });
26
26
  const token = await client.getAccessToken();
27
27
  token !== null ? apiv2.setAccessToken(token) : false;
28
+ logger_1.logger.debug(`Running auto auth`);
28
29
  let clientEmail;
29
30
  try {
30
31
  const credentials = await client.getCredentials();
@@ -72,7 +73,7 @@ async function requireAuth(options) {
72
73
  utils.logWarning("Authenticating with `FIREBASE_TOKEN` is deprecated and will be removed in a future major version of `firebase-tools`. " +
73
74
  "Instead, use a service account key with `GOOGLE_APPLICATION_CREDENTIALS`: https://cloud.google.com/docs/authentication/getting-started");
74
75
  }
75
- else if (user) {
76
+ else if (user && (!(0, auth_1.isExpired)(tokens) || (tokens === null || tokens === void 0 ? void 0 : tokens.refresh_token))) {
76
77
  logger_1.logger.debug(`> authorizing via signed-in user (${user.email})`);
77
78
  }
78
79
  else {
package/lib/utils.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.openInBrowser = exports.connectableHostname = exports.randomInt = exports.debounce = exports.last = exports.cloneDeep = exports.groupBy = exports.assertIsStringOrUndefined = exports.assertIsNumber = exports.assertIsString = exports.thirtyDaysFromNow = exports.isRunningInWSL = exports.isCloudEnvironment = exports.datetimeString = exports.createDestroyer = exports.sleep = exports.promiseWithSpinner = exports.setupLoggers = exports.tryParse = exports.tryStringify = exports.promiseProps = exports.withTimeout = exports.promiseWhile = exports.promiseAllSettled = exports.getFunctionsEventProvider = exports.endpoint = exports.makeActiveProject = exports.streamToString = exports.stringToStream = exports.explainStdin = exports.allSettled = exports.reject = exports.logLabeledError = exports.logLabeledWarning = exports.logWarning = exports.logLabeledBullet = exports.logBullet = exports.logLabeledSuccess = exports.logSuccess = exports.addSubdomain = exports.addDatabaseNamespace = exports.getDatabaseViewDataUrl = exports.getDatabaseUrl = exports.envOverride = exports.setVSCodeEnvVars = exports.getInheritedOption = exports.consoleUrl = exports.vscodeEnvVars = exports.envOverrides = exports.IS_WINDOWS = void 0;
4
- exports.readSecretValue = exports.generateId = exports.wrappedSafeLoad = exports.readFileFromDirectory = exports.getHostnameFromUrl = exports.openInBrowserPopup = void 0;
4
+ exports.updateOrCreateGitignore = exports.readSecretValue = exports.generateId = exports.wrappedSafeLoad = exports.readFileFromDirectory = exports.getHostnameFromUrl = exports.openInBrowserPopup = void 0;
5
5
  const fs = require("fs-extra");
6
6
  const tty = require("tty");
7
7
  const path = require("node:path");
@@ -597,3 +597,18 @@ function readSecretValue(prompt, dataFile) {
597
597
  }
598
598
  }
599
599
  exports.readSecretValue = readSecretValue;
600
+ function updateOrCreateGitignore(dirPath, entries) {
601
+ const gitignorePath = path.join(dirPath, ".gitignore");
602
+ if (!fs.existsSync(gitignorePath)) {
603
+ fs.writeFileSync(gitignorePath, entries.join("\n"));
604
+ return;
605
+ }
606
+ let content = fs.readFileSync(gitignorePath, "utf-8");
607
+ for (const entry of entries) {
608
+ if (!content.includes(entry)) {
609
+ content += `\n${entry}\n`;
610
+ }
611
+ }
612
+ fs.writeFileSync(gitignorePath, content);
613
+ }
614
+ exports.updateOrCreateGitignore = updateOrCreateGitignore;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "firebase-tools",
3
- "version": "13.26.0",
3
+ "version": "13.28.0",
4
4
  "description": "Command-Line Interface for Firebase",
5
5
  "main": "./lib/index.js",
6
6
  "bin": {
@@ -91,6 +91,7 @@
91
91
  "google-auth-library": "^9.11.0",
92
92
  "inquirer": "^8.2.6",
93
93
  "inquirer-autocomplete-prompt": "^2.0.1",
94
+ "js-yaml": "^3.14.1",
94
95
  "jsonwebtoken": "^9.0.0",
95
96
  "leven": "^3.1.0",
96
97
  "libsodium-wrappers": "^0.7.10",
@@ -114,7 +115,7 @@
114
115
  "sql-formatter": "^15.3.0",
115
116
  "stream-chain": "^2.2.4",
116
117
  "stream-json": "^1.7.3",
117
- "superstatic": "^9.0.3",
118
+ "superstatic": "^9.1.0",
118
119
  "tar": "^6.1.11",
119
120
  "tcp-port-used": "^1.0.2",
120
121
  "tmp": "^0.2.3",
@@ -369,6 +369,9 @@
369
369
  "rootDirectory": {
370
370
  "type": "string"
371
371
  },
372
+ "startCommand": {
373
+ "type": "string"
374
+ },
372
375
  "startCommandOverride": {
373
376
  "type": "string"
374
377
  }
@@ -402,6 +405,9 @@
402
405
  "dataconnect": {
403
406
  "additionalProperties": false,
404
407
  "properties": {
408
+ "dataDir": {
409
+ "type": "string"
410
+ },
405
411
  "host": {
406
412
  "type": "string"
407
413
  },
@@ -8,4 +8,5 @@ schema:
8
8
  database: __cloudSqlDatabase__
9
9
  cloudSql:
10
10
  instanceId: __cloudSqlInstanceId__
11
+ # schemaValidation: "COMPATIBLE"
11
12
  connectorDirs: __connectorDirs__
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.discoverPackageManager = exports.logger = void 0;
4
- const fs_extra_1 = require("fs-extra");
5
- const path_1 = require("path");
6
- const emulatorLogger_1 = require("../emulatorLogger");
7
- const types_1 = require("../types");
8
- exports.logger = emulatorLogger_1.EmulatorLogger.forEmulator(types_1.Emulators.APPHOSTING);
9
- async function discoverPackageManager(rootdir) {
10
- if (await (0, fs_extra_1.pathExists)((0, path_1.join)(rootdir, "pnpm-lock.yaml"))) {
11
- return "pnpm";
12
- }
13
- if (await (0, fs_extra_1.pathExists)((0, path_1.join)(rootdir, "yarn.lock"))) {
14
- return "yarn";
15
- }
16
- return "npm";
17
- }
18
- exports.discoverPackageManager = discoverPackageManager;
@@ -1,12 +0,0 @@
1
- specVersion: "v1beta"
2
- serviceId: __serviceId__
3
- location: __location__
4
- schema:
5
- source: "./schema"
6
- datasource:
7
- postgresql:
8
- database: __cloudSqlDatabase__
9
- cloudSql:
10
- instanceId: __cloudSqlInstanceId__
11
- # schemaValidation: "COMPATIBLE"
12
- connectorDirs: __connectorDirs__