firebase-tools 15.30.1 → 15.30.3-main.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.
- package/lib/commands/ext-migrate.js +1 -1
- package/lib/deploy/functions/build.js +44 -13
- package/lib/deploy/functions/params.js +40 -84
- package/lib/deploy/functions/prepare.js +7 -4
- package/lib/deploy/functions/runtimes/python/index.js +48 -17
- package/lib/emulator/auth/cloudFunctions.js +40 -5
- package/lib/emulator/downloadableEmulatorInfo.json +24 -24
- package/lib/emulator/functionsEmulator.js +13 -4
- package/lib/emulator/functionsEmulatorShared.js +14 -3
- package/lib/experiments.js +6 -1
- package/lib/extensions/export.js +21 -11
- package/lib/extensions/replacements.json +15 -22
- package/lib/fsutils.js +20 -2
- package/lib/functions/kits/install.js +143 -78
- package/lib/functions/python.js +82 -0
- package/lib/management/projects.js +14 -0
- package/lib/prompt.js +4 -0
- package/lib/tsconfig.compile.tsbuildinfo +1 -1
- package/lib/tsconfig.publish.tsbuildinfo +1 -1
- package/package.json +1 -1
package/lib/functions/python.js
CHANGED
|
@@ -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
|
}
|
package/lib/prompt.js
CHANGED
|
@@ -82,8 +82,12 @@ async function select(opts) {
|
|
|
82
82
|
if (shouldReturn) {
|
|
83
83
|
return value;
|
|
84
84
|
}
|
|
85
|
+
const instructions = typeof opts.instructions === "string"
|
|
86
|
+
? { navigation: opts.instructions, pager: opts.instructions }
|
|
87
|
+
: opts.instructions;
|
|
85
88
|
return inquirer.select({
|
|
86
89
|
...opts,
|
|
90
|
+
instructions,
|
|
87
91
|
loop: false,
|
|
88
92
|
});
|
|
89
93
|
}
|