firebase-tools-with-isolate 15.30.2 → 15.31.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.
@@ -17,8 +17,8 @@ const semver_1 = require("semver");
17
17
  const clc = require("colorette");
18
18
  const stream_chain_1 = require("stream-chain");
19
19
  const stream_json_1 = require("stream-json");
20
- const Pick_1 = require("stream-json/filters/Pick");
21
- const StreamObject_1 = require("stream-json/streamers/StreamObject");
20
+ const pick_js_1 = require("stream-json/filters/pick.js");
21
+ const stream_object_js_1 = require("stream-json/streamers/stream-object.js");
22
22
  const fsutils_1 = require("../../fsutils");
23
23
  const prompt_1 = require("../../prompt");
24
24
  const error_1 = require("../../error");
@@ -404,8 +404,8 @@ async function ɵcodegenFunctionsDirectory(sourceDir, destDir, target, context)
404
404
  const pipeline = (0, stream_chain_1.chain)([
405
405
  npmLs.stdout,
406
406
  (0, stream_json_1.parser)({ packValues: false, packKeys: true, streamValues: false }),
407
- (0, Pick_1.pick)({ filter: "dependencies" }),
408
- (0, StreamObject_1.streamObject)(),
407
+ (0, pick_js_1.pick)({ filter: "dependencies" }),
408
+ (0, stream_object_js_1.streamObject)(),
409
409
  ({ key, value }) => [
410
410
  key,
411
411
  ...(0, utils_2.allDependencyNames)(value),
@@ -649,10 +649,10 @@ async function promptAndWriteKitParams(options) {
649
649
  userEnvs: typedUserEnvs,
650
650
  codebase: options.instanceId,
651
651
  nonInteractive: options.nonInteractive,
652
- force: options.force,
653
652
  });
654
653
  functionsEnv.writeResolvedParams(resolvedEnvs, userEnvs, userEnvOpt);
655
- if (experiments.isEnabled("secretEnvParams")) {
654
+ if (experiments.isEnabled("secretEnvParams") &&
655
+ experiments.isEnabled("writeDefaultSecretBindings")) {
656
656
  functionsEnv.writeResolvedSecretRefs(resolvedSecretRefs, secretRefs, userEnvOpt);
657
657
  }
658
658
  }
@@ -827,7 +827,6 @@ async function addKitInstanceOrConfigureProject(options) {
827
827
  absSourcePath,
828
828
  instanceId,
829
829
  nonInteractive: options.nonInteractive,
830
- force: options.force,
831
830
  params: discoveredBuild.params,
832
831
  });
833
832
  }
@@ -999,7 +998,6 @@ async function installKitOrInstance(options) {
999
998
  absSourcePath,
1000
999
  instanceId,
1001
1000
  nonInteractive: options.nonInteractive,
1002
- force: options.force,
1003
1001
  params: discoveredBuild.params,
1004
1002
  });
1005
1003
  }
@@ -3,10 +3,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DEFAULT_VENV_DIR = void 0;
4
4
  exports.virtualEnvCmd = virtualEnvCmd;
5
5
  exports.runWithVirtualEnv = runWithVirtualEnv;
6
+ exports.killProcessTree = killProcessTree;
7
+ exports.trackVirtualEnvChild = trackVirtualEnvChild;
8
+ exports.untrackVirtualEnvChild = untrackVirtualEnvChild;
9
+ const os = require("os");
6
10
  const path = require("path");
7
11
  const cross_spawn_1 = require("cross-spawn");
12
+ const cp = require("child_process");
8
13
  const logger_1 = require("../logger");
9
14
  const utils_1 = require("../utils");
15
+ const error_1 = require("../error");
10
16
  exports.DEFAULT_VENV_DIR = "venv";
11
17
  function virtualEnvCmd(cwd, venvDir) {
12
18
  const activateScriptPath = utils_1.IS_WINDOWS ? ["Scripts", "activate.bat"] : ["bin", "activate"];
@@ -28,3 +34,79 @@ function runWithVirtualEnv(commandAndArgs, cwd, envs, spawnOpts = {}, venvDir =
28
34
  env: { ...process.env, ...envs },
29
35
  });
30
36
  }
37
+ function killProcessTree(pid) {
38
+ if (!pid || pid <= 0) {
39
+ return;
40
+ }
41
+ if (utils_1.IS_WINDOWS) {
42
+ const result = cp.spawnSync("taskkill", ["/pid", pid.toString(), "/T", "/F"]);
43
+ if (result.error || result.status !== 0) {
44
+ logger_1.logger.debug(`taskkill on pid ${pid} exited with ${String(result.status)}: ` +
45
+ `${result.error?.message ?? result.stderr?.toString().trim() ?? ""}`);
46
+ }
47
+ return;
48
+ }
49
+ try {
50
+ process.kill(-pid, "SIGKILL");
51
+ }
52
+ catch (e) {
53
+ logger_1.logger.debug(`Failed to kill process group ${pid}: ${(0, error_1.getErrMsg)(e)}`);
54
+ }
55
+ }
56
+ const CLEANUP_SIGNALS = ["SIGINT", "SIGTERM", "SIGHUP", "SIGQUIT"];
57
+ const trackedChildren = new Set();
58
+ const signalHandlers = new Map();
59
+ function reRaise(signal) {
60
+ try {
61
+ process.kill(process.pid, signal);
62
+ }
63
+ catch (e) {
64
+ logger_1.logger.debug(`Could not re-raise ${signal}, exiting instead: ${(0, error_1.getErrMsg)(e)}`);
65
+ process.exit(128 + (os.constants.signals[signal] ?? 0));
66
+ }
67
+ }
68
+ function killAllTrackedChildren() {
69
+ for (const child of trackedChildren) {
70
+ if (child.pid && child.exitCode === null && child.signalCode === null) {
71
+ killProcessTree(child.pid);
72
+ }
73
+ }
74
+ trackedChildren.clear();
75
+ }
76
+ function removeCleanupHandlers() {
77
+ if (!signalHandlers.size) {
78
+ return;
79
+ }
80
+ process.removeListener("exit", killAllTrackedChildren);
81
+ for (const [signal, handler] of signalHandlers) {
82
+ process.removeListener(signal, handler);
83
+ }
84
+ signalHandlers.clear();
85
+ }
86
+ function addCleanupHandlers() {
87
+ if (signalHandlers.size) {
88
+ return;
89
+ }
90
+ process.on("exit", killAllTrackedChildren);
91
+ for (const signal of CLEANUP_SIGNALS) {
92
+ const handler = () => {
93
+ killAllTrackedChildren();
94
+ removeCleanupHandlers();
95
+ if (process.listenerCount(signal) === 0) {
96
+ reRaise(signal);
97
+ }
98
+ };
99
+ signalHandlers.set(signal, handler);
100
+ process.on(signal, handler);
101
+ }
102
+ }
103
+ function trackVirtualEnvChild(child) {
104
+ trackedChildren.add(child);
105
+ addCleanupHandlers();
106
+ }
107
+ function untrackVirtualEnvChild(child) {
108
+ trackedChildren.delete(child);
109
+ if (!trackedChildren.size) {
110
+ removeCleanupHandlers();
111
+ }
112
+ }
@@ -257,6 +257,17 @@ async function createCloudProject(projectId, options) {
257
257
  }
258
258
  }
259
259
  }
260
+ function isTosNotAcceptedError(err) {
261
+ if (!(err instanceof error_1.FirebaseError) || !err.context) {
262
+ return false;
263
+ }
264
+ const context = err.context;
265
+ const details = context.body?.error?.details;
266
+ if (!Array.isArray(details)) {
267
+ return false;
268
+ }
269
+ return details.some((d) => typeof d?.detail === "string" && d.detail.includes("Firebase Tos Not Accepted"));
270
+ }
260
271
  async function addFirebaseToCloudProject(projectId) {
261
272
  try {
262
273
  const response = await firebaseAPIClient.request({
@@ -274,6 +285,9 @@ async function addFirebaseToCloudProject(projectId) {
274
285
  }
275
286
  catch (err) {
276
287
  logger_1.logger.debug(err.message);
288
+ if (isTosNotAcceptedError(err)) {
289
+ throw new error_1.FirebaseError(`Failed to add Firebase to Google Cloud Platform project ${clc.bold(projectId)} because your account has not accepted the Firebase Terms of Service. Please accept the Terms of Service in the Firebase console at ${api.consoleOrigin()} and try again.`, { exit: 2, original: err });
290
+ }
277
291
  throw new error_1.FirebaseError("Failed to add Firebase to Google Cloud Platform project. See firebase-debug.log for more info.", { exit: 2, original: err });
278
292
  }
279
293
  }