firebase-tools 13.22.0 → 13.22.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.
package/lib/auth.js CHANGED
@@ -21,6 +21,7 @@ const crypto_1 = require("crypto");
21
21
  const track_1 = require("./track");
22
22
  const api_1 = require("./api");
23
23
  const templates_1 = require("./templates");
24
+ const requireAuth_1 = require("./requireAuth");
24
25
  portfinder.setBasePort(9005);
25
26
  function getGlobalDefaultAccount() {
26
27
  const user = configstore_1.configstore.get("user");
@@ -530,7 +531,18 @@ async function getAccessToken(refreshToken, authScopes) {
530
531
  if (haveValidTokens(refreshToken, authScopes) && lastAccessToken) {
531
532
  return lastAccessToken;
532
533
  }
533
- return refreshTokens(refreshToken, authScopes);
534
+ if (refreshToken) {
535
+ return refreshTokens(refreshToken, authScopes);
536
+ }
537
+ else {
538
+ try {
539
+ return (0, requireAuth_1.refreshAuth)();
540
+ }
541
+ catch (err) {
542
+ logger_1.logger.debug(`Unable to refresh token: ${err}`);
543
+ }
544
+ throw new error_1.FirebaseError("Unable to getAccessToken");
545
+ }
534
546
  }
535
547
  exports.getAccessToken = getAccessToken;
536
548
  async function logout(refreshToken) {
@@ -8,7 +8,7 @@ const spawn = require("cross-spawn");
8
8
  const downloadUtils = require("../downloadUtils");
9
9
  const error_1 = require("../error");
10
10
  const logger_1 = require("../logger");
11
- const rimraf = require("rimraf");
11
+ const node_fs_1 = require("node:fs");
12
12
  const utils = require("../utils");
13
13
  const JAR_CACHE_DIR = process.env.FIREBASE_CRASHLYTICS_BUILDTOOLS_PATH ||
14
14
  path.join(os.homedir(), ".cache", "firebase", "crashlytics", "buildtools");
@@ -26,7 +26,7 @@ async function fetchBuildtoolsJar() {
26
26
  }
27
27
  if (fs.existsSync(JAR_CACHE_DIR)) {
28
28
  logger_1.logger.debug(`Deleting Jar cache at ${JAR_CACHE_DIR} because the CLI was run with a newer Jar version`);
29
- rimraf.sync(JAR_CACHE_DIR);
29
+ (0, node_fs_1.rmSync)(JAR_CACHE_DIR, { recursive: true });
30
30
  }
31
31
  utils.logBullet("Downloading crashlytics-buildtools.jar to " + jarPath);
32
32
  utils.logBullet("For open source licenses used by this command, look in the META-INF directory in the buildtools.jar file");
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.detectFromPort = exports.detectFromYaml = exports.yamlToBuild = exports.readFileAsync = void 0;
3
+ exports.detectFromPort = exports.detectFromYaml = exports.yamlToBuild = exports.getFunctionDiscoveryTimeout = exports.readFileAsync = void 0;
4
4
  const node_fetch_1 = require("node-fetch");
5
5
  const fs = require("fs");
6
6
  const path = require("path");
@@ -12,6 +12,10 @@ const v1alpha1 = require("./v1alpha1");
12
12
  const error_1 = require("../../../../error");
13
13
  exports.readFileAsync = (0, util_1.promisify)(fs.readFile);
14
14
  const TIMEOUT_OVERRIDE_ENV_VAR = "FUNCTIONS_DISCOVERY_TIMEOUT";
15
+ function getFunctionDiscoveryTimeout() {
16
+ return +(process.env[TIMEOUT_OVERRIDE_ENV_VAR] || 0) * 1000;
17
+ }
18
+ exports.getFunctionDiscoveryTimeout = getFunctionDiscoveryTimeout;
15
19
  function yamlToBuild(yaml, project, region, runtime) {
16
20
  try {
17
21
  if (!yaml.specVersion) {
@@ -51,7 +55,7 @@ async function detectFromPort(port, project, runtime, timeout = 10000) {
51
55
  const timedOut = new Promise((resolve, reject) => {
52
56
  setTimeout(() => {
53
57
  reject(new error_1.FirebaseError("User code failed to load. Cannot determine backend specification"));
54
- }, +(process.env[TIMEOUT_OVERRIDE_ENV_VAR] || 0) * 1000 || timeout);
58
+ }, getFunctionDiscoveryTimeout() || timeout);
55
59
  });
56
60
  while (true) {
57
61
  try {
@@ -9,8 +9,9 @@ class AppHostingEmulator {
9
9
  this.args = args;
10
10
  }
11
11
  async start() {
12
- utils_1.logger.logLabeled("INFO", types_1.Emulators.APPHOSTING, "starting apphosting emulator");
13
- const { hostname, port } = await (0, serve_1.start)();
12
+ const { hostname, port } = await (0, serve_1.start)({
13
+ startCommand: this.args.startCommandOverride,
14
+ });
14
15
  this.args.options.host = hostname;
15
16
  this.args.options.port = port;
16
17
  }
@@ -7,21 +7,30 @@ const utils_1 = require("./utils");
7
7
  const constants_1 = require("../constants");
8
8
  const spawn_1 = require("../../init/spawn");
9
9
  const config_1 = require("./config");
10
- async function start() {
10
+ const utils_2 = require("./utils");
11
+ const types_1 = require("../types");
12
+ async function start(options) {
11
13
  const hostname = constants_1.DEFAULT_HOST;
12
14
  let port = constants_1.DEFAULT_PORTS.apphosting;
13
15
  while (!(await availablePort(hostname, port))) {
14
16
  port += 1;
15
17
  }
16
- serve(port);
18
+ serve(port, options === null || options === void 0 ? void 0 : options.startCommand);
17
19
  return { hostname, port };
18
20
  }
19
21
  exports.start = start;
20
- async function serve(port) {
22
+ async function serve(port, startCommand) {
21
23
  const rootDir = process.cwd();
22
- const packageManager = await (0, utils_1.discoverPackageManager)(rootDir);
23
24
  const apphostingLocalConfig = await (0, config_1.getLocalAppHostingConfiguration)(rootDir);
24
- await (0, spawn_1.wrapSpawn)(packageManager, ["run", "dev"], rootDir, Object.assign(Object.assign({}, apphostingLocalConfig.environmentVariables), { PORT: port }));
25
+ const environmentVariablesToInject = Object.assign(Object.assign({}, apphostingLocalConfig.environmentVariables), { PORT: port.toString() });
26
+ if (startCommand) {
27
+ utils_2.logger.logLabeled("BULLET", types_1.Emulators.APPHOSTING, `running custom start command: '${startCommand}'`);
28
+ await (0, spawn_1.spawnWithCommandString)(startCommand, rootDir, environmentVariablesToInject);
29
+ return;
30
+ }
31
+ const packageManager = await (0, utils_1.discoverPackageManager)(rootDir);
32
+ utils_2.logger.logLabeled("BULLET", types_1.Emulators.APPHOSTING, `starting app with: '${packageManager} run dev'`);
33
+ await (0, spawn_1.wrapSpawn)(packageManager, ["run", "dev"], rootDir, environmentVariablesToInject);
25
34
  }
26
35
  function availablePort(host, port) {
27
36
  return (0, portUtils_1.checkListenable)({
@@ -166,7 +166,7 @@ function findExportMetadata(importPath) {
166
166
  }
167
167
  }
168
168
  async function startAll(options, showUI = true, runningTestScript = false) {
169
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
169
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
170
170
  const targets = filterEmulatorTargets(options);
171
171
  options.targets = targets;
172
172
  const singleProjectModeEnabled = ((_a = options.config.src.emulators) === null || _a === void 0 ? void 0 : _a.singleProjectMode) === undefined ||
@@ -208,9 +208,18 @@ async function startAll(options, showUI = true, runningTestScript = false) {
208
208
  const emulatableBackends = [];
209
209
  let extensionEmulator = undefined;
210
210
  if (shouldStart(options, types_1.Emulators.EXTENSIONS)) {
211
- const projectNumber = isDemoProject
212
- ? constants_1.Constants.FAKE_PROJECT_NUMBER
213
- : await (0, projectUtils_1.needProjectNumber)(options);
211
+ let projectNumber = constants_1.Constants.FAKE_PROJECT_NUMBER;
212
+ if (!isDemoProject) {
213
+ try {
214
+ projectNumber = await (0, projectUtils_1.needProjectNumber)(options);
215
+ }
216
+ catch (err) {
217
+ emulatorLogger_1.EmulatorLogger.forEmulator(types_1.Emulators.EXTENSIONS).logLabeled("ERROR", types_1.Emulators.EXTENSIONS, `Unable to look up project number for ${options.project}.\n` +
218
+ " If this is a real project, ensure that you are logged in and have access to it.\n" +
219
+ " If this is a fake project, please use a project ID starting with 'demo-' to skip production calls.\n" +
220
+ " Continuing with a fake project number - secrets and other features that require production access may behave unexpectedly.");
221
+ }
222
+ }
214
223
  const aliases = (0, projectUtils_1.getAliases)(options, projectId);
215
224
  extensionEmulator = new extensionsEmulator_1.ExtensionsEmulator({
216
225
  options,
@@ -592,11 +601,13 @@ async function startAll(options, showUI = true, runningTestScript = false) {
592
601
  await startEmulator(hostingEmulator);
593
602
  }
594
603
  if (experiments.isEnabled("emulatorapphosting")) {
604
+ const apphostingConfig = (_l = options.config.src.emulators) === null || _l === void 0 ? void 0 : _l[types_1.Emulators.APPHOSTING];
595
605
  if (listenForEmulator.apphosting) {
596
606
  const apphostingAddr = legacyGetFirstAddr(types_1.Emulators.APPHOSTING);
597
607
  const apphostingEmulator = new apphosting_1.AppHostingEmulator({
598
608
  host: apphostingAddr.host,
599
609
  port: apphostingAddr.port,
610
+ startCommandOverride: apphostingConfig === null || apphostingConfig === void 0 ? void 0 : apphostingConfig.startCommandOverride,
600
611
  options,
601
612
  });
602
613
  await startEmulator(apphostingEmulator);
@@ -48,20 +48,20 @@ const EMULATOR_UPDATE_DETAILS = {
48
48
  },
49
49
  dataconnect: process.platform === "darwin"
50
50
  ? {
51
- version: "1.5.0",
52
- expectedSize: 25215744,
53
- expectedChecksum: "670ad771cf36b07c52a71f580df89994",
51
+ version: "1.5.1",
52
+ expectedSize: 25289472,
53
+ expectedChecksum: "92c425072db66c7e2cfa40b703ed807b",
54
54
  }
55
55
  : process.platform === "win32"
56
56
  ? {
57
- version: "1.5.0",
58
- expectedSize: 25643520,
59
- expectedChecksum: "b565e4609f08eb2299b7bec7e0cac0dc",
57
+ version: "1.5.1",
58
+ expectedSize: 25720320,
59
+ expectedChecksum: "2a5c654770233b740980d5f98f24be73",
60
60
  }
61
61
  : {
62
- version: "1.5.0",
63
- expectedSize: 25129112,
64
- expectedChecksum: "9a08671b89f557d096c075f6a5ac87db",
62
+ version: "1.5.1",
63
+ expectedSize: 25202840,
64
+ expectedChecksum: "f95156cbcac237268791638ea0eb10e7",
65
65
  },
66
66
  };
67
67
  exports.DownloadDetails = {
@@ -256,11 +256,13 @@ class FunctionsEmulator {
256
256
  }
257
257
  async start() {
258
258
  const credentialEnv = await this.getCredentialsEnvironment();
259
+ console.log("got creds env");
259
260
  for (const e of this.staticBackends) {
260
261
  e.env = Object.assign(Object.assign({}, credentialEnv), e.env);
261
262
  }
262
263
  if (Object.keys(this.adminSdkConfig || {}).length <= 1) {
263
264
  const adminSdkConfig = await (0, adminSdkConfig_1.getProjectAdminSdkConfigOrCached)(this.args.projectId);
265
+ console.log("got admin sdk");
264
266
  if (adminSdkConfig) {
265
267
  this.adminSdkConfig = adminSdkConfig;
266
268
  }
@@ -7,6 +7,7 @@ const types_1 = require("./types");
7
7
  const events_1 = require("events");
8
8
  const emulatorLogger_1 = require("./emulatorLogger");
9
9
  const error_1 = require("../error");
10
+ const discovery_1 = require("../deploy/functions/runtimes/discovery");
10
11
  var RuntimeWorkerState;
11
12
  (function (RuntimeWorkerState) {
12
13
  RuntimeWorkerState["CREATED"] = "CREATED";
@@ -187,7 +188,7 @@ class RuntimeWorker {
187
188
  const timeout = new Promise((resolve, reject) => {
188
189
  setTimeout(() => {
189
190
  reject(new error_1.FirebaseError("Failed to load function."));
190
- }, 30000);
191
+ }, (0, discovery_1.getFunctionDiscoveryTimeout)() || 30000);
191
192
  });
192
193
  while (true) {
193
194
  try {
@@ -11,7 +11,7 @@ const registry_1 = require("./registry");
11
11
  const error_1 = require("../error");
12
12
  const hub_1 = require("./hub");
13
13
  const downloadableEmulators_1 = require("./downloadableEmulators");
14
- const rimraf = require("rimraf");
14
+ const node_fs_1 = require("node:fs");
15
15
  const track_1 = require("../track");
16
16
  class HubExport {
17
17
  constructor(projectId, options) {
@@ -25,7 +25,14 @@ class HubExport {
25
25
  if (!fs.existsSync(metadataPath)) {
26
26
  return undefined;
27
27
  }
28
- return JSON.parse(fs.readFileSync(metadataPath, "utf8").toString());
28
+ let mdString = "";
29
+ try {
30
+ mdString = fs.readFileSync(metadataPath, "utf8").toString();
31
+ return JSON.parse(mdString);
32
+ }
33
+ catch (err) {
34
+ throw new error_1.FirebaseError(`Unable to parse metadata file ${metadataPath}: ${mdString}`);
35
+ }
29
36
  }
30
37
  async exportAll() {
31
38
  const toExport = types_1.ALL_EMULATORS.filter(shouldExport);
@@ -74,7 +81,7 @@ class HubExport {
74
81
  const metadataPath = path.join(this.tmpDir, HubExport.METADATA_FILE_NAME);
75
82
  fs.writeFileSync(metadataPath, JSON.stringify(metadata, undefined, 2));
76
83
  logger_1.logger.debug(`hubExport: swapping ${this.tmpDir} with ${this.exportPath}`);
77
- rimraf.sync(this.exportPath);
84
+ (0, node_fs_1.rmSync)(this.exportPath, { recursive: true });
78
85
  fse.moveSync(this.tmpDir, this.exportPath);
79
86
  }
80
87
  async exportFirestore(metadata) {
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Persistence = void 0;
4
4
  const fs_1 = require("fs");
5
- const rimraf_1 = require("rimraf");
5
+ const promises_1 = require("node:fs/promises");
6
6
  const fs = require("fs");
7
7
  const fse = require("fs-extra");
8
8
  const path = require("path");
@@ -57,7 +57,7 @@ class Persistence {
57
57
  this._diskPathMap.delete(fileName);
58
58
  }
59
59
  async deleteAll() {
60
- await (0, rimraf_1.rimraf)(this._dirPath);
60
+ await (0, promises_1.rm)(this._dirPath, { recursive: true });
61
61
  this._diskPathMap = new Map();
62
62
  return;
63
63
  }
@@ -98,9 +98,18 @@ async function getFirebaseProjectParams(projectId, emulatorMode = false) {
98
98
  const body = emulatorMode
99
99
  ? await (0, adminSdkConfig_1.getProjectAdminSdkConfigOrCached)(projectId)
100
100
  : await (0, functionsConfig_1.getFirebaseConfig)({ project: projectId });
101
- const projectNumber = emulatorMode && constants_1.Constants.isDemoProject(projectId)
102
- ? constants_1.Constants.FAKE_PROJECT_NUMBER
103
- : await (0, getProjectNumber_1.getProjectNumber)({ projectId });
101
+ let projectNumber = constants_1.Constants.FAKE_PROJECT_NUMBER;
102
+ if (!constants_1.Constants.isDemoProject(projectId)) {
103
+ try {
104
+ projectNumber = await (0, getProjectNumber_1.getProjectNumber)({ projectId });
105
+ }
106
+ catch (err) {
107
+ (0, utils_2.logLabeledError)("extensions", `Unable to look up project number for ${projectId}.\n` +
108
+ " If this is a real project, ensure that you are logged in and have access to it.\n" +
109
+ " If this is a fake project, please use a project ID starting with 'demo-' to skip production calls.\n" +
110
+ " Continuing with a fake project number - secrets and other features that require production access may behave unexpectedly.");
111
+ }
112
+ }
104
113
  const databaseURL = (_a = body === null || body === void 0 ? void 0 : body.databaseURL) !== null && _a !== void 0 ? _a : `https://${projectId}.firebaseio.com`;
105
114
  const storageBucket = (_b = body === null || body === void 0 ? void 0 : body.storageBucket) !== null && _b !== void 0 ? _b : `${projectId}.appspot.com`;
106
115
  const FIREBASE_CONFIG = JSON.stringify({
@@ -18,7 +18,7 @@ exports.MAILING_LIST_URL = "https://goo.gle/41enW5X";
18
18
  const DEFAULT_FIREBASE_FRAMEWORKS_VERSION = "^0.11.0";
19
19
  exports.FIREBASE_FRAMEWORKS_VERSION = (experiments.isEnabled("internaltesting") && process.env.FIREBASE_FRAMEWORKS_VERSION) ||
20
20
  DEFAULT_FIREBASE_FRAMEWORKS_VERSION;
21
- exports.FIREBASE_FUNCTIONS_VERSION = "^4.5.0";
21
+ exports.FIREBASE_FUNCTIONS_VERSION = "^6.0.1";
22
22
  exports.FIREBASE_ADMIN_VERSION = "^11.11.1";
23
23
  exports.SHARP_VERSION = "^0.32 || ^0.33";
24
24
  exports.NODE_VERSION = parseInt(process.versions.node, 10);
@@ -4,8 +4,6 @@ exports.ɵcodegenPublicDirectory = exports.build = exports.init = exports.discov
4
4
  const cross_spawn_1 = require("cross-spawn");
5
5
  const fs_extra_1 = require("fs-extra");
6
6
  const path_1 = require("path");
7
- const yaml = require("yaml");
8
- const promises_1 = require("fs/promises");
9
7
  const error_1 = require("../../error");
10
8
  const utils_1 = require("./utils");
11
9
  const constants_1 = require("./constants");
@@ -18,8 +16,7 @@ async function discover(dir) {
18
16
  return;
19
17
  if (!(await (0, fs_extra_1.pathExists)((0, path_1.join)(dir, "web"))))
20
18
  return;
21
- const pubSpecBuffer = await (0, promises_1.readFile)((0, path_1.join)(dir, "pubspec.yaml"));
22
- const pubSpec = yaml.parse(pubSpecBuffer.toString());
19
+ const pubSpec = await (0, utils_1.getPubSpec)(dir);
23
20
  const usingFlutter = (_a = pubSpec.dependencies) === null || _a === void 0 ? void 0 : _a.flutter;
24
21
  if (!usingFlutter)
25
22
  return;
@@ -44,9 +41,12 @@ function init(setup, config) {
44
41
  return Promise.resolve();
45
42
  }
46
43
  exports.init = init;
47
- function build(cwd) {
44
+ async function build(cwd) {
48
45
  (0, utils_1.assertFlutterCliExists)();
49
- const build = (0, cross_spawn_1.sync)("flutter", ["build", "web"], { cwd, stdio: "inherit" });
46
+ const pubSpec = await (0, utils_1.getPubSpec)(cwd);
47
+ const otherArgs = (0, utils_1.getAdditionalBuildArgs)(pubSpec);
48
+ const buildArgs = ["build", "web", ...otherArgs].filter(Boolean);
49
+ const build = (0, cross_spawn_1.sync)("flutter", buildArgs, { cwd, stdio: "inherit" });
50
50
  if (build.status !== 0)
51
51
  throw new error_1.FirebaseError("Unable to build your Flutter app");
52
52
  return Promise.resolve({ wantsBackend: false });
@@ -1,11 +1,44 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.assertFlutterCliExists = void 0;
3
+ exports.getPubSpec = exports.getAdditionalBuildArgs = exports.assertFlutterCliExists = void 0;
4
4
  const cross_spawn_1 = require("cross-spawn");
5
5
  const error_1 = require("../../error");
6
+ const promises_1 = require("fs/promises");
7
+ const fs_extra_1 = require("fs-extra");
8
+ const path_1 = require("path");
9
+ const yaml = require("yaml");
6
10
  function assertFlutterCliExists() {
7
11
  const process = (0, cross_spawn_1.sync)("flutter", ["--version"], { stdio: "ignore" });
8
12
  if (process.status !== 0)
9
13
  throw new error_1.FirebaseError("Flutter CLI not found, follow the instructions here https://docs.flutter.dev/get-started/install before trying again.");
10
14
  }
11
15
  exports.assertFlutterCliExists = assertFlutterCliExists;
16
+ function getAdditionalBuildArgs(pubSpec) {
17
+ const treeShakePackages = [
18
+ "material_icons_named",
19
+ "material_symbols_icons",
20
+ "material_design_icons_flutter",
21
+ "flutter_iconpicker",
22
+ "font_awesome_flutter",
23
+ "ionicons_named",
24
+ ];
25
+ const hasTreeShakePackage = treeShakePackages.some((pkg) => { var _a; return (_a = pubSpec.dependencies) === null || _a === void 0 ? void 0 : _a[pkg]; });
26
+ const treeShakeFlags = hasTreeShakePackage ? ["--no-tree-shake-icons"] : [];
27
+ return [...treeShakeFlags];
28
+ }
29
+ exports.getAdditionalBuildArgs = getAdditionalBuildArgs;
30
+ async function getPubSpec(dir) {
31
+ if (!(await (0, fs_extra_1.pathExists)((0, path_1.join)(dir, "pubspec.yaml"))))
32
+ return {};
33
+ if (!(await (0, fs_extra_1.pathExists)((0, path_1.join)(dir, "web"))))
34
+ return {};
35
+ try {
36
+ const pubSpecBuffer = await (0, promises_1.readFile)((0, path_1.join)(dir, "pubspec.yaml"));
37
+ return yaml.parse(pubSpecBuffer.toString());
38
+ }
39
+ catch (error) {
40
+ console.info("Failed to read pubspec.yaml");
41
+ return {};
42
+ }
43
+ }
44
+ exports.getPubSpec = getPubSpec;
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.doSetup = void 0;
4
4
  const clc = require("colorette");
5
- const rimraf_1 = require("rimraf");
5
+ const node_fs_1 = require("node:fs");
6
6
  const path_1 = require("path");
7
7
  const apiv2_1 = require("../../../apiv2");
8
8
  const github_1 = require("./github");
@@ -116,7 +116,7 @@ async function doSetup(setup, config, options) {
116
116
  choices,
117
117
  }, setup.hosting);
118
118
  if (discoveredFramework)
119
- (0, rimraf_1.sync)(setup.hosting.source);
119
+ (0, node_fs_1.rmSync)(setup.hosting.source, { recursive: true });
120
120
  await frameworks_1.WebFrameworks[setup.hosting.whichFramework].init(setup, config);
121
121
  }
122
122
  await (0, prompt_1.promptOnce)({
package/lib/init/spawn.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.wrapSpawn = void 0;
3
+ exports.spawnWithCommandString = exports.wrapSpawn = void 0;
4
4
  const spawn = require("cross-spawn");
5
5
  const logger_1 = require("../logger");
6
6
  function wrapSpawn(cmd, args, projectDir, environmentVariables) {
@@ -22,3 +22,23 @@ function wrapSpawn(cmd, args, projectDir, environmentVariables) {
22
22
  });
23
23
  }
24
24
  exports.wrapSpawn = wrapSpawn;
25
+ function spawnWithCommandString(cmd, projectDir, environmentVariables) {
26
+ return new Promise((resolve, reject) => {
27
+ const installer = spawn(cmd, {
28
+ cwd: projectDir,
29
+ stdio: "inherit",
30
+ shell: true,
31
+ env: Object.assign(Object.assign({}, process.env), environmentVariables),
32
+ });
33
+ installer.on("error", (err) => {
34
+ logger_1.logger.log("DEBUG", err.stack);
35
+ });
36
+ installer.on("close", (code) => {
37
+ if (code === 0) {
38
+ return resolve();
39
+ }
40
+ return reject();
41
+ });
42
+ });
43
+ }
44
+ exports.spawnWithCommandString = spawnWithCommandString;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.requireAuth = void 0;
3
+ exports.requireAuth = exports.refreshAuth = void 0;
4
4
  const google_auth_library_1 = require("google-auth-library");
5
5
  const clc = require("colorette");
6
6
  const api = require("./api");
@@ -12,6 +12,7 @@ const scopes = require("./scopes");
12
12
  const auth_1 = require("./auth");
13
13
  const AUTH_ERROR_MESSAGE = `Command requires authentication, please run ${clc.bold("firebase login")}`;
14
14
  let authClient;
15
+ let lastOptions;
15
16
  function getAuthClient(config) {
16
17
  if (authClient) {
17
18
  return authClient;
@@ -46,7 +47,16 @@ async function autoAuth(options, authScopes) {
46
47
  }
47
48
  return clientEmail;
48
49
  }
50
+ async function refreshAuth() {
51
+ if (!lastOptions) {
52
+ throw new error_1.FirebaseError("Unable to refresh auth: not yet authenticated.");
53
+ }
54
+ await requireAuth(lastOptions);
55
+ return lastOptions.tokens;
56
+ }
57
+ exports.refreshAuth = refreshAuth;
49
58
  async function requireAuth(options) {
59
+ lastOptions = options;
50
60
  api.setScopes([scopes.CLOUD_PLATFORM, scopes.FIREBASE_PLATFORM]);
51
61
  options.authScopes = api.getScopes();
52
62
  const tokens = options.tokens;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "firebase-tools",
3
- "version": "13.22.0",
3
+ "version": "13.22.1",
4
4
  "description": "Command-Line Interface for Firebase",
5
5
  "main": "./lib/index.js",
6
6
  "bin": {
@@ -110,7 +110,6 @@
110
110
  "progress": "^2.0.3",
111
111
  "proxy-agent": "^6.3.0",
112
112
  "retry": "^0.13.1",
113
- "rimraf": "^5.0.0",
114
113
  "semver": "^7.5.2",
115
114
  "sql-formatter": "^15.3.0",
116
115
  "stream-chain": "^2.2.4",
@@ -365,6 +365,9 @@
365
365
  },
366
366
  "port": {
367
367
  "type": "number"
368
+ },
369
+ "startCommandOverride": {
370
+ "type": "string"
368
371
  }
369
372
  },
370
373
  "type": "object"
@@ -3,8 +3,8 @@
3
3
  "description": "Greet the world",
4
4
  "main": "index.js",
5
5
  "dependencies": {
6
- "firebase-admin": "^12.1.0",
7
- "firebase-functions": "^5.0.0"
6
+ "firebase-admin": "^12.6.0",
7
+ "firebase-functions": "^6.0.1"
8
8
  },
9
9
  "devDependencies": {
10
10
  "eslint": "^8.15.1",
@@ -3,8 +3,8 @@
3
3
  "description": "Greet the world",
4
4
  "main": "index.js",
5
5
  "dependencies": {
6
- "firebase-admin": "^12.1.0",
7
- "firebase-functions": "^5.0.0"
6
+ "firebase-admin": "^12.6.0",
7
+ "firebase-functions": "^6.0.1"
8
8
  },
9
9
  "devDependencies": {
10
10
  "axios": "^1.3.2",
@@ -10,8 +10,8 @@
10
10
  },
11
11
  "main": "lib/index.js",
12
12
  "dependencies": {
13
- "firebase-admin": "^12.1.0",
14
- "firebase-functions": "^5.0.0"
13
+ "firebase-admin": "^12.6.0",
14
+ "firebase-functions": "^6.0.1"
15
15
  },
16
16
  "devDependencies": {
17
17
  "@types/chai": "^4.3.4",
@@ -8,8 +8,8 @@
8
8
  },
9
9
  "main": "lib/index.js",
10
10
  "dependencies": {
11
- "firebase-admin": "^12.1.0",
12
- "firebase-functions": "^5.0.0"
11
+ "firebase-admin": "^12.6.0",
12
+ "firebase-functions": "^6.0.1"
13
13
  },
14
14
  "devDependencies": {
15
15
  "@types/chai": "^4.3.4",
@@ -14,8 +14,8 @@
14
14
  },
15
15
  "main": "index.js",
16
16
  "dependencies": {
17
- "firebase-admin": "^12.1.0",
18
- "firebase-functions": "^5.0.0"
17
+ "firebase-admin": "^12.6.0",
18
+ "firebase-functions": "^6.0.1"
19
19
  },
20
20
  "devDependencies": {
21
21
  "eslint": "^8.15.0",
@@ -13,8 +13,8 @@
13
13
  },
14
14
  "main": "index.js",
15
15
  "dependencies": {
16
- "firebase-admin": "^12.1.0",
17
- "firebase-functions": "^5.0.0"
16
+ "firebase-admin": "^12.6.0",
17
+ "firebase-functions": "^6.0.1"
18
18
  },
19
19
  "devDependencies": {
20
20
  "firebase-functions-test": "^3.1.0"
@@ -15,8 +15,8 @@
15
15
  },
16
16
  "main": "lib/index.js",
17
17
  "dependencies": {
18
- "firebase-admin": "^12.1.0",
19
- "firebase-functions": "^5.0.0"
18
+ "firebase-admin": "^12.6.0",
19
+ "firebase-functions": "^6.0.1"
20
20
  },
21
21
  "devDependencies": {
22
22
  "@typescript-eslint/eslint-plugin": "^5.12.0",
@@ -14,8 +14,8 @@
14
14
  },
15
15
  "main": "lib/index.js",
16
16
  "dependencies": {
17
- "firebase-admin": "^12.1.0",
18
- "firebase-functions": "^5.0.0"
17
+ "firebase-admin": "^12.6.0",
18
+ "firebase-functions": "^6.0.1"
19
19
  },
20
20
  "devDependencies": {
21
21
  "typescript": "^4.9.0",