firebase-tools 11.6.0 → 11.7.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/crashlytics-mappingfile-generateid.js +26 -0
- package/lib/commands/crashlytics-mappingfile-upload.js +46 -0
- package/lib/commands/crashlytics-symbols-upload.js +18 -87
- package/lib/commands/functions-delete.js +2 -0
- package/lib/commands/functions-secrets-get.js +2 -0
- package/lib/commands/index.js +3 -0
- package/lib/crashlytics/buildToolsJarHelper.js +51 -0
- package/lib/deploy/functions/backend.js +4 -4
- package/lib/deploy/functions/build.js +75 -8
- package/lib/deploy/functions/checkIam.js +6 -5
- package/lib/deploy/functions/params.js +15 -15
- package/lib/deploy/functions/release/fabricator.js +22 -5
- package/lib/deploy/functions/release/index.js +2 -0
- package/lib/deploy/functions/runtimes/discovery/index.js +1 -16
- package/lib/deploy/functions/runtimes/discovery/parsing.js +16 -0
- package/lib/deploy/functions/runtimes/discovery/v1alpha1.js +59 -131
- package/lib/deploy/functions/runtimes/node/parseTriggers.js +1 -1
- package/lib/emulator/constants.js +1 -1
- package/lib/emulator/controller.js +6 -11
- package/lib/emulator/functionsEmulatorRuntime.js +12 -23
- package/lib/emulator/storage/apis/firebase.js +13 -11
- package/lib/emulator/storage/multipart.js +2 -2
- package/lib/functions/env.js +9 -9
- package/lib/gcp/cloudscheduler.js +32 -15
- package/lib/track.js +3 -0
- package/npm-shrinkwrap.json +511 -2
- package/package.json +2 -1
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.command = void 0;
|
|
4
|
+
const command_1 = require("../command");
|
|
5
|
+
const utils = require("../utils");
|
|
6
|
+
const buildToolsJarHelper_1 = require("../crashlytics/buildToolsJarHelper");
|
|
7
|
+
const error_1 = require("../error");
|
|
8
|
+
exports.command = new command_1.Command("crashlytics:mappingfile:generateid")
|
|
9
|
+
.description("generate a mapping file id and write it to an Android resource file, which will be built into the app")
|
|
10
|
+
.option("--resource-file <resourceFile>", "path to the Android resource XML file that will be created or updated.")
|
|
11
|
+
.action(async (options) => {
|
|
12
|
+
const debug = !!options.debug;
|
|
13
|
+
const resourceFilePath = options.resourceFile;
|
|
14
|
+
if (!resourceFilePath) {
|
|
15
|
+
throw new error_1.FirebaseError("set --resource-file <resourceFile> to an Android resource file path, e.g. app/src/main/res/values/crashlytics.xml");
|
|
16
|
+
}
|
|
17
|
+
const jarFile = await (0, buildToolsJarHelper_1.fetchBuildtoolsJar)();
|
|
18
|
+
const jarOptions = { resourceFilePath };
|
|
19
|
+
utils.logBullet(`Updating resource file: ${resourceFilePath}`);
|
|
20
|
+
const generateIdArgs = buildArgs(jarOptions);
|
|
21
|
+
(0, buildToolsJarHelper_1.runBuildtoolsCommand)(jarFile, generateIdArgs, debug);
|
|
22
|
+
utils.logBullet("Successfully updated mapping file id");
|
|
23
|
+
});
|
|
24
|
+
function buildArgs(options) {
|
|
25
|
+
return ["-injectMappingFileIdIntoResource", options.resourceFilePath, "-verbose"];
|
|
26
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.command = void 0;
|
|
4
|
+
const command_1 = require("../command");
|
|
5
|
+
const error_1 = require("../error");
|
|
6
|
+
const utils = require("../utils");
|
|
7
|
+
const buildToolsJarHelper_1 = require("../crashlytics/buildToolsJarHelper");
|
|
8
|
+
exports.command = new command_1.Command("crashlytics:mappingfile:upload <mappingFile>")
|
|
9
|
+
.description("upload a ProGuard/R8-compatible mapping file to deobfuscate stack traces")
|
|
10
|
+
.option("--app <appID>", "the app id of your Firebase app")
|
|
11
|
+
.option("--resource-file <resourceFile>", "path to the Android resource XML file that includes the mapping file id")
|
|
12
|
+
.action(async (mappingFile, options) => {
|
|
13
|
+
const app = getGoogleAppID(options);
|
|
14
|
+
const debug = !!options.debug;
|
|
15
|
+
if (!mappingFile) {
|
|
16
|
+
throw new error_1.FirebaseError("set `--mapping-file <mappingFile>` to a valid mapping file path, e.g. app/build/outputs/mapping.txt");
|
|
17
|
+
}
|
|
18
|
+
const mappingFilePath = mappingFile;
|
|
19
|
+
const resourceFilePath = options.resourceFile;
|
|
20
|
+
if (!resourceFilePath) {
|
|
21
|
+
throw new error_1.FirebaseError("set --resource-file <resourceFile> to a valid Android resource file path, e.g. app/main/res/values/strings.xml");
|
|
22
|
+
}
|
|
23
|
+
const jarFile = await (0, buildToolsJarHelper_1.fetchBuildtoolsJar)();
|
|
24
|
+
const jarOptions = { app, mappingFilePath, resourceFilePath };
|
|
25
|
+
utils.logBullet(`Uploading mapping file: ${mappingFilePath}`);
|
|
26
|
+
const uploadArgs = buildArgs(jarOptions);
|
|
27
|
+
(0, buildToolsJarHelper_1.runBuildtoolsCommand)(jarFile, uploadArgs, debug);
|
|
28
|
+
utils.logBullet("Successfully uploaded mapping file");
|
|
29
|
+
});
|
|
30
|
+
function getGoogleAppID(options) {
|
|
31
|
+
if (!options.app) {
|
|
32
|
+
throw new error_1.FirebaseError("set --app <appId> to a valid Firebase application id, e.g. 1:00000000:android:0000000");
|
|
33
|
+
}
|
|
34
|
+
return options.app;
|
|
35
|
+
}
|
|
36
|
+
function buildArgs(options) {
|
|
37
|
+
return [
|
|
38
|
+
"-uploadMappingFile",
|
|
39
|
+
options.mappingFilePath,
|
|
40
|
+
"-resourceFile",
|
|
41
|
+
options.resourceFilePath,
|
|
42
|
+
"-googleAppId",
|
|
43
|
+
options.app,
|
|
44
|
+
"-verbose",
|
|
45
|
+
];
|
|
46
|
+
}
|
|
@@ -1,44 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.command = void 0;
|
|
4
|
-
const fs = require("fs-extra");
|
|
5
4
|
const os = require("os");
|
|
6
5
|
const path = require("path");
|
|
7
|
-
const spawn = require("cross-spawn");
|
|
8
6
|
const uuid = require("uuid");
|
|
9
7
|
const command_1 = require("../command");
|
|
10
|
-
const downloadUtils = require("../downloadUtils");
|
|
11
8
|
const error_1 = require("../error");
|
|
12
|
-
const logger_1 = require("../logger");
|
|
13
|
-
const rimraf = require("rimraf");
|
|
14
9
|
const utils = require("../utils");
|
|
10
|
+
const buildToolsJarHelper_1 = require("../crashlytics/buildToolsJarHelper");
|
|
15
11
|
var SymbolGenerator;
|
|
16
12
|
(function (SymbolGenerator) {
|
|
17
13
|
SymbolGenerator["breakpad"] = "breakpad";
|
|
18
14
|
SymbolGenerator["csym"] = "csym";
|
|
19
15
|
})(SymbolGenerator || (SymbolGenerator = {}));
|
|
20
16
|
const SYMBOL_CACHE_ROOT_DIR = process.env.FIREBASE_CRASHLYTICS_CACHE_PATH || os.tmpdir();
|
|
21
|
-
const JAR_CACHE_DIR = process.env.FIREBASE_CRASHLYTICS_BUILDTOOLS_PATH ||
|
|
22
|
-
path.join(os.homedir(), ".cache", "firebase", "crashlytics", "buildtools");
|
|
23
|
-
const JAR_VERSION = "2.8.0";
|
|
24
|
-
const JAR_URL = `https://dl.google.com/android/maven2/com/google/firebase/firebase-crashlytics-buildtools/${JAR_VERSION}/firebase-crashlytics-buildtools-${JAR_VERSION}.jar`;
|
|
25
17
|
exports.command = new command_1.Command("crashlytics:symbols:upload <symbolFiles...>")
|
|
26
|
-
.description("
|
|
18
|
+
.description("upload symbols for native code, to symbolicate stack traces")
|
|
27
19
|
.option("--app <appID>", "the app id of your Firebase app")
|
|
28
|
-
.option("--generator [breakpad|csym]", "the symbol generator being used,
|
|
20
|
+
.option("--generator [breakpad|csym]", "the symbol generator being used, default is breakpad")
|
|
29
21
|
.option("--dry-run", "generate symbols without uploading them")
|
|
30
|
-
.option("--debug", "print debug output and logging from the underlying uploader tool")
|
|
31
22
|
.action(async (symbolFiles, options) => {
|
|
32
|
-
const app = getGoogleAppID(options)
|
|
23
|
+
const app = getGoogleAppID(options);
|
|
33
24
|
const generator = getSymbolGenerator(options);
|
|
34
25
|
const dryRun = !!options.dryRun;
|
|
35
26
|
const debug = !!options.debug;
|
|
36
|
-
|
|
37
|
-
if (process.env.LOCAL_JAR) {
|
|
38
|
-
jarFile = process.env.LOCAL_JAR;
|
|
39
|
-
}
|
|
27
|
+
const jarFile = await (0, buildToolsJarHelper_1.fetchBuildtoolsJar)();
|
|
40
28
|
const jarOptions = {
|
|
41
|
-
jarFile,
|
|
42
29
|
app,
|
|
43
30
|
generator,
|
|
44
31
|
cachePath: path.join(SYMBOL_CACHE_ROOT_DIR, `crashlytics-${uuid.v4()}`, "nativeSymbols", app.replace(/:/g, "-"), generator),
|
|
@@ -48,32 +35,22 @@ exports.command = new command_1.Command("crashlytics:symbols:upload <symbolFiles
|
|
|
48
35
|
for (const symbolFile of symbolFiles) {
|
|
49
36
|
utils.logBullet(`Generating symbols for ${symbolFile}`);
|
|
50
37
|
const generateArgs = buildArgs(Object.assign(Object.assign({}, jarOptions), { symbolFile }));
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
else {
|
|
56
|
-
utils.logBullet(`Generated symbols for ${symbolFile}`);
|
|
57
|
-
utils.logBullet(`Output Path: ${jarOptions.cachePath}`);
|
|
58
|
-
}
|
|
38
|
+
(0, buildToolsJarHelper_1.runBuildtoolsCommand)(jarFile, generateArgs, debug);
|
|
39
|
+
utils.logBullet(`Generated symbols for ${symbolFile}`);
|
|
40
|
+
utils.logBullet(`Output Path: ${jarOptions.cachePath}`);
|
|
59
41
|
}
|
|
60
42
|
if (dryRun) {
|
|
61
43
|
utils.logBullet("Skipping upload because --dry-run was passed");
|
|
62
44
|
return;
|
|
63
45
|
}
|
|
64
|
-
utils.logBullet(`Uploading all generated symbols
|
|
46
|
+
utils.logBullet(`Uploading all generated symbols...`);
|
|
65
47
|
const uploadArgs = buildArgs(Object.assign(Object.assign({}, jarOptions), { generate: false }));
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
utils.logBullet(output);
|
|
69
|
-
}
|
|
70
|
-
else {
|
|
71
|
-
utils.logBullet("Successfully uploaded all symbols");
|
|
72
|
-
}
|
|
48
|
+
(0, buildToolsJarHelper_1.runBuildtoolsCommand)(jarFile, uploadArgs, debug);
|
|
49
|
+
utils.logBullet("Successfully uploaded all symbols");
|
|
73
50
|
});
|
|
74
51
|
function getGoogleAppID(options) {
|
|
75
52
|
if (!options.app) {
|
|
76
|
-
throw new error_1.FirebaseError("set
|
|
53
|
+
throw new error_1.FirebaseError("set --app <appId> to a valid Firebase application id, e.g. 1:00000000:android:0000000");
|
|
77
54
|
}
|
|
78
55
|
return options.app;
|
|
79
56
|
}
|
|
@@ -86,62 +63,16 @@ function getSymbolGenerator(options) {
|
|
|
86
63
|
}
|
|
87
64
|
return options.generator;
|
|
88
65
|
}
|
|
89
|
-
async function downloadBuiltoolsJar() {
|
|
90
|
-
const jarPath = path.join(JAR_CACHE_DIR, `crashlytics-buildtools-${JAR_VERSION}.jar`);
|
|
91
|
-
if (fs.existsSync(jarPath)) {
|
|
92
|
-
logger_1.logger.debug(`Buildtools Jar already downloaded at ${jarPath}`);
|
|
93
|
-
return jarPath;
|
|
94
|
-
}
|
|
95
|
-
if (fs.existsSync(JAR_CACHE_DIR)) {
|
|
96
|
-
logger_1.logger.debug(`Deleting Jar cache at ${JAR_CACHE_DIR} because the CLI was run with a newer Jar version`);
|
|
97
|
-
rimraf.sync(JAR_CACHE_DIR);
|
|
98
|
-
}
|
|
99
|
-
utils.logBullet("Downloading buildtools.jar to " + jarPath);
|
|
100
|
-
utils.logBullet("For open source licenses used by this command, look in the META-INF directory in the buildtools.jar file");
|
|
101
|
-
const tmpfile = await downloadUtils.downloadToTmp(JAR_URL);
|
|
102
|
-
fs.mkdirSync(JAR_CACHE_DIR, { recursive: true });
|
|
103
|
-
fs.copySync(tmpfile, jarPath);
|
|
104
|
-
return jarPath;
|
|
105
|
-
}
|
|
106
66
|
function buildArgs(options) {
|
|
107
67
|
const baseArgs = [
|
|
108
|
-
"-
|
|
109
|
-
options.
|
|
110
|
-
|
|
111
|
-
|
|
68
|
+
"-symbolGenerator",
|
|
69
|
+
options.generator,
|
|
70
|
+
"-symbolFileCacheDir",
|
|
71
|
+
options.cachePath,
|
|
112
72
|
"-verbose",
|
|
113
73
|
];
|
|
114
74
|
if (options.generate) {
|
|
115
|
-
return baseArgs.concat(["-generateNativeSymbols",
|
|
116
|
-
}
|
|
117
|
-
return baseArgs.concat([
|
|
118
|
-
"-uploadNativeSymbols",
|
|
119
|
-
`-googleAppId=${options.app}`,
|
|
120
|
-
]);
|
|
121
|
-
}
|
|
122
|
-
function runJar(args, debug) {
|
|
123
|
-
var _a, _b, _c;
|
|
124
|
-
const outputs = spawn.sync("java", args, {
|
|
125
|
-
stdio: debug ? "inherit" : "pipe",
|
|
126
|
-
});
|
|
127
|
-
if (outputs.status || 0 > 0) {
|
|
128
|
-
if (!debug) {
|
|
129
|
-
utils.logWarning(((_a = outputs.stdout) === null || _a === void 0 ? void 0 : _a.toString()) || "An unknown error occurred");
|
|
130
|
-
}
|
|
131
|
-
throw new error_1.FirebaseError("Failed to upload symbols");
|
|
132
|
-
}
|
|
133
|
-
if (!debug) {
|
|
134
|
-
let logRegex = /(Generated symbol file.*$)/m;
|
|
135
|
-
let matched = (((_b = outputs.stdout) === null || _b === void 0 ? void 0 : _b.toString()) || "").match(logRegex);
|
|
136
|
-
if (matched) {
|
|
137
|
-
return matched[1];
|
|
138
|
-
}
|
|
139
|
-
logRegex = /(Crashlytics symbol file uploaded successfully.*$)/m;
|
|
140
|
-
matched = (((_c = outputs.stdout) === null || _c === void 0 ? void 0 : _c.toString()) || "").match(logRegex);
|
|
141
|
-
if (matched) {
|
|
142
|
-
return matched[1];
|
|
143
|
-
}
|
|
144
|
-
return "";
|
|
75
|
+
return baseArgs.concat(["-generateNativeSymbols", "-unstrippedLibrary", options.symbolFile]);
|
|
145
76
|
}
|
|
146
|
-
return "";
|
|
77
|
+
return baseArgs.concat(["-uploadNativeSymbols", "-googleAppId", options.app]);
|
|
147
78
|
}
|
|
@@ -17,6 +17,7 @@ const fabricator = require("../deploy/functions/release/fabricator");
|
|
|
17
17
|
const executor = require("../deploy/functions/release/executor");
|
|
18
18
|
const reporter = require("../deploy/functions/release/reporter");
|
|
19
19
|
const containerCleaner = require("../deploy/functions/containerCleaner");
|
|
20
|
+
const getProjectNumber_1 = require("../getProjectNumber");
|
|
20
21
|
exports.command = new command_1.Command("functions:delete [filters...]")
|
|
21
22
|
.description("delete one or more Cloud Functions by name or group name.")
|
|
22
23
|
.option("--region <region>", "Specify region of the function to be deleted. " +
|
|
@@ -78,6 +79,7 @@ exports.command = new command_1.Command("functions:delete [filters...]")
|
|
|
78
79
|
appEngineLocation,
|
|
79
80
|
executor: new executor.QueueExecutor({}),
|
|
80
81
|
sources: {},
|
|
82
|
+
projectNumber: options.projectNumber || (await (0, getProjectNumber_1.getProjectNumber)({ projectId: context.projectId })),
|
|
81
83
|
});
|
|
82
84
|
const summary = await fab.applyPlan(plan);
|
|
83
85
|
await reporter.logAndTrackDeployStats(summary);
|
|
@@ -6,8 +6,10 @@ const command_1 = require("../command");
|
|
|
6
6
|
const logger_1 = require("../logger");
|
|
7
7
|
const projectUtils_1 = require("../projectUtils");
|
|
8
8
|
const secretManager_1 = require("../gcp/secretManager");
|
|
9
|
+
const requirePermissions_1 = require("../requirePermissions");
|
|
9
10
|
exports.command = new command_1.Command("functions:secrets:get <KEY>")
|
|
10
11
|
.description("Get metadata for secret and its versions")
|
|
12
|
+
.before(requirePermissions_1.requirePermissions, ["secretmanager.secrets.get"])
|
|
11
13
|
.action(async (key, options) => {
|
|
12
14
|
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
13
15
|
const versions = await (0, secretManager_1.listSecretVersions)(projectId, key);
|
package/lib/commands/index.js
CHANGED
|
@@ -34,6 +34,9 @@ function load(client) {
|
|
|
34
34
|
client.crashlytics = {};
|
|
35
35
|
client.crashlytics.symbols = {};
|
|
36
36
|
client.crashlytics.symbols.upload = loadCommand("crashlytics-symbols-upload");
|
|
37
|
+
client.crashlytics.mappingfile = {};
|
|
38
|
+
client.crashlytics.mappingfile.generateid = loadCommand("crashlytics-mappingfile-generateid");
|
|
39
|
+
client.crashlytics.mappingfile.upload = loadCommand("crashlytics-mappingfile-upload");
|
|
37
40
|
client.database = {};
|
|
38
41
|
client.database.get = loadCommand("database-get");
|
|
39
42
|
client.database.instances = {};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.runBuildtoolsCommand = exports.fetchBuildtoolsJar = void 0;
|
|
4
|
+
const fs = require("fs-extra");
|
|
5
|
+
const os = require("os");
|
|
6
|
+
const path = require("path");
|
|
7
|
+
const spawn = require("cross-spawn");
|
|
8
|
+
const downloadUtils = require("../downloadUtils");
|
|
9
|
+
const error_1 = require("../error");
|
|
10
|
+
const logger_1 = require("../logger");
|
|
11
|
+
const rimraf = require("rimraf");
|
|
12
|
+
const utils = require("../utils");
|
|
13
|
+
const JAR_CACHE_DIR = process.env.FIREBASE_CRASHLYTICS_BUILDTOOLS_PATH ||
|
|
14
|
+
path.join(os.homedir(), ".cache", "firebase", "crashlytics", "buildtools");
|
|
15
|
+
const JAR_VERSION = "2.9.1";
|
|
16
|
+
const JAR_URL = `https://dl.google.com/android/maven2/com/google/firebase/firebase-crashlytics-buildtools/${JAR_VERSION}/firebase-crashlytics-buildtools-${JAR_VERSION}.jar`;
|
|
17
|
+
async function fetchBuildtoolsJar() {
|
|
18
|
+
if (process.env.CRASHLYTICS_LOCAL_JAR) {
|
|
19
|
+
return process.env.CRASHLYTICS_LOCAL_JAR;
|
|
20
|
+
}
|
|
21
|
+
const jarPath = path.join(JAR_CACHE_DIR, `crashlytics-buildtools-${JAR_VERSION}.jar`);
|
|
22
|
+
if (fs.existsSync(jarPath)) {
|
|
23
|
+
logger_1.logger.debug(`Buildtools Jar already downloaded at ${jarPath}`);
|
|
24
|
+
return jarPath;
|
|
25
|
+
}
|
|
26
|
+
if (fs.existsSync(JAR_CACHE_DIR)) {
|
|
27
|
+
logger_1.logger.debug(`Deleting Jar cache at ${JAR_CACHE_DIR} because the CLI was run with a newer Jar version`);
|
|
28
|
+
rimraf.sync(JAR_CACHE_DIR);
|
|
29
|
+
}
|
|
30
|
+
utils.logBullet("Downloading crashlytics-buildtools.jar to " + jarPath);
|
|
31
|
+
utils.logBullet("For open source licenses used by this command, look in the META-INF directory in the buildtools.jar file");
|
|
32
|
+
const tmpfile = await downloadUtils.downloadToTmp(JAR_URL);
|
|
33
|
+
fs.mkdirSync(JAR_CACHE_DIR, { recursive: true });
|
|
34
|
+
fs.copySync(tmpfile, jarPath);
|
|
35
|
+
return jarPath;
|
|
36
|
+
}
|
|
37
|
+
exports.fetchBuildtoolsJar = fetchBuildtoolsJar;
|
|
38
|
+
function runBuildtoolsCommand(jarFile, args, debug) {
|
|
39
|
+
var _a;
|
|
40
|
+
const fullArgs = ["-jar", jarFile, ...args, "-clientName", "firebase-cli;crashlytics-buildtools"];
|
|
41
|
+
const outputs = spawn.sync("java", fullArgs, {
|
|
42
|
+
stdio: debug ? "inherit" : "pipe",
|
|
43
|
+
});
|
|
44
|
+
if (outputs.status !== 0) {
|
|
45
|
+
if (!debug) {
|
|
46
|
+
utils.logWarning(((_a = outputs.stdout) === null || _a === void 0 ? void 0 : _a.toString()) || "An unknown error occurred");
|
|
47
|
+
}
|
|
48
|
+
throw new error_1.FirebaseError(`java command failed with args: ${fullArgs}`);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
exports.runBuildtoolsCommand = runBuildtoolsCommand;
|
|
@@ -65,8 +65,8 @@ function memoryToGen1Cpu(memory) {
|
|
|
65
65
|
2048: 1,
|
|
66
66
|
4096: 2,
|
|
67
67
|
8192: 2,
|
|
68
|
-
16384:
|
|
69
|
-
32768:
|
|
68
|
+
16384: 4,
|
|
69
|
+
32768: 8,
|
|
70
70
|
}[memory];
|
|
71
71
|
}
|
|
72
72
|
exports.memoryToGen1Cpu = memoryToGen1Cpu;
|
|
@@ -79,8 +79,8 @@ function memoryToGen2Cpu(memory) {
|
|
|
79
79
|
2048: 1,
|
|
80
80
|
4096: 2,
|
|
81
81
|
8192: 2,
|
|
82
|
-
16384:
|
|
83
|
-
32768:
|
|
82
|
+
16384: 4,
|
|
83
|
+
32768: 8,
|
|
84
84
|
}[memory];
|
|
85
85
|
}
|
|
86
86
|
exports.memoryToGen2Cpu = memoryToGen2Cpu;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.toBackend = exports.resolveBackend = exports.of = exports.empty = void 0;
|
|
3
|
+
exports.toBackend = exports.resolveBackend = exports.AllIngressSettings = exports.AllVpcEgressSettings = exports.AllFunctionsPlatforms = exports.isValidMemoryOption = exports.isBlockingTriggered = exports.isTaskQueueTriggered = exports.isScheduleTriggered = exports.isEventTriggered = exports.isCallableTriggered = exports.isHttpsTriggered = exports.of = exports.empty = void 0;
|
|
4
4
|
const backend = require("./backend");
|
|
5
5
|
const proto = require("../../gcp/proto");
|
|
6
6
|
const api = require("../../.../../api");
|
|
@@ -8,6 +8,7 @@ const params = require("./params");
|
|
|
8
8
|
const previews_1 = require("../../previews");
|
|
9
9
|
const error_1 = require("../../error");
|
|
10
10
|
const functional_1 = require("../../functional");
|
|
11
|
+
const env_1 = require("../../functions/env");
|
|
11
12
|
const logger_1 = require("../../logger");
|
|
12
13
|
function empty() {
|
|
13
14
|
return {
|
|
@@ -23,15 +24,79 @@ function of(endpoints) {
|
|
|
23
24
|
return build;
|
|
24
25
|
}
|
|
25
26
|
exports.of = of;
|
|
27
|
+
function isHttpsTriggered(triggered) {
|
|
28
|
+
return {}.hasOwnProperty.call(triggered, "httpsTrigger");
|
|
29
|
+
}
|
|
30
|
+
exports.isHttpsTriggered = isHttpsTriggered;
|
|
31
|
+
function isCallableTriggered(triggered) {
|
|
32
|
+
return {}.hasOwnProperty.call(triggered, "callableTrigger");
|
|
33
|
+
}
|
|
34
|
+
exports.isCallableTriggered = isCallableTriggered;
|
|
35
|
+
function isEventTriggered(triggered) {
|
|
36
|
+
return {}.hasOwnProperty.call(triggered, "eventTrigger");
|
|
37
|
+
}
|
|
38
|
+
exports.isEventTriggered = isEventTriggered;
|
|
39
|
+
function isScheduleTriggered(triggered) {
|
|
40
|
+
return {}.hasOwnProperty.call(triggered, "scheduleTrigger");
|
|
41
|
+
}
|
|
42
|
+
exports.isScheduleTriggered = isScheduleTriggered;
|
|
43
|
+
function isTaskQueueTriggered(triggered) {
|
|
44
|
+
return {}.hasOwnProperty.call(triggered, "taskQueueTrigger");
|
|
45
|
+
}
|
|
46
|
+
exports.isTaskQueueTriggered = isTaskQueueTriggered;
|
|
47
|
+
function isBlockingTriggered(triggered) {
|
|
48
|
+
return {}.hasOwnProperty.call(triggered, "blockingTrigger");
|
|
49
|
+
}
|
|
50
|
+
exports.isBlockingTriggered = isBlockingTriggered;
|
|
51
|
+
const allMemoryOptions = [128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768];
|
|
52
|
+
function isValidMemoryOption(mem) {
|
|
53
|
+
return allMemoryOptions.includes(mem);
|
|
54
|
+
}
|
|
55
|
+
exports.isValidMemoryOption = isValidMemoryOption;
|
|
56
|
+
exports.AllFunctionsPlatforms = ["gcfv1", "gcfv2"];
|
|
57
|
+
exports.AllVpcEgressSettings = ["PRIVATE_RANGES_ONLY", "ALL_TRAFFIC"];
|
|
58
|
+
exports.AllIngressSettings = [
|
|
59
|
+
"ALLOW_ALL",
|
|
60
|
+
"ALLOW_INTERNAL_ONLY",
|
|
61
|
+
"ALLOW_INTERNAL_AND_GCLB",
|
|
62
|
+
];
|
|
26
63
|
async function resolveBackend(build, userEnvOpt, userEnvs) {
|
|
64
|
+
var _a;
|
|
27
65
|
const projectId = userEnvOpt.projectId;
|
|
28
66
|
let paramValues = {};
|
|
29
67
|
if (previews_1.previews.functionsparams) {
|
|
30
|
-
paramValues = await params.resolveParams(build.params, projectId, userEnvs);
|
|
68
|
+
paramValues = await params.resolveParams(build.params, projectId, envWithTypes(userEnvs));
|
|
69
|
+
const toWrite = {};
|
|
70
|
+
for (const paramName of Object.keys(paramValues)) {
|
|
71
|
+
if (userEnvs.hasOwnProperty(paramName)) {
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
toWrite[paramName] = ((_a = paramValues[paramName]) === null || _a === void 0 ? void 0 : _a.toString()) || "";
|
|
75
|
+
}
|
|
76
|
+
(0, env_1.writeUserEnvs)(toWrite, userEnvOpt);
|
|
31
77
|
}
|
|
32
78
|
return toBackend(build, paramValues);
|
|
33
79
|
}
|
|
34
80
|
exports.resolveBackend = resolveBackend;
|
|
81
|
+
function envWithTypes(rawEnvs) {
|
|
82
|
+
const out = {};
|
|
83
|
+
for (const envName of Object.keys(rawEnvs)) {
|
|
84
|
+
const value = rawEnvs[envName];
|
|
85
|
+
if (!isNaN(+value) && isFinite(+value) && !value.includes("e")) {
|
|
86
|
+
out[envName] = +value;
|
|
87
|
+
}
|
|
88
|
+
else if (value === "true") {
|
|
89
|
+
out[envName] = true;
|
|
90
|
+
}
|
|
91
|
+
else if (value === "false") {
|
|
92
|
+
out[envName] = false;
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
out[envName] = value;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return out;
|
|
99
|
+
}
|
|
35
100
|
class Resolver {
|
|
36
101
|
constructor(paramValues) {
|
|
37
102
|
this.paramValues = paramValues;
|
|
@@ -127,7 +192,7 @@ function toBackend(build, paramValues) {
|
|
|
127
192
|
}
|
|
128
193
|
exports.toBackend = toBackend;
|
|
129
194
|
function discoverTrigger(endpoint, region, r) {
|
|
130
|
-
if (
|
|
195
|
+
if (isHttpsTriggered(endpoint)) {
|
|
131
196
|
const httpsTrigger = {};
|
|
132
197
|
if (endpoint.httpsTrigger.invoker === null) {
|
|
133
198
|
httpsTrigger.invoker = null;
|
|
@@ -137,13 +202,13 @@ function discoverTrigger(endpoint, region, r) {
|
|
|
137
202
|
}
|
|
138
203
|
return { httpsTrigger };
|
|
139
204
|
}
|
|
140
|
-
else if (
|
|
205
|
+
else if (isCallableTriggered(endpoint)) {
|
|
141
206
|
return { callableTrigger: {} };
|
|
142
207
|
}
|
|
143
|
-
else if (
|
|
208
|
+
else if (isBlockingTriggered(endpoint)) {
|
|
144
209
|
return { blockingTrigger: endpoint.blockingTrigger };
|
|
145
210
|
}
|
|
146
|
-
else if (
|
|
211
|
+
else if (isEventTriggered(endpoint)) {
|
|
147
212
|
const eventTrigger = {
|
|
148
213
|
eventType: endpoint.eventTrigger.eventType,
|
|
149
214
|
retry: r.resolveBoolean(endpoint.eventTrigger.retry) || false,
|
|
@@ -157,11 +222,13 @@ function discoverTrigger(endpoint, region, r) {
|
|
|
157
222
|
r.resolveStrings(eventTrigger, endpoint.eventTrigger, "serviceAccount", "region", "channel");
|
|
158
223
|
return { eventTrigger };
|
|
159
224
|
}
|
|
160
|
-
else if (
|
|
225
|
+
else if (isScheduleTriggered(endpoint)) {
|
|
161
226
|
const bkSchedule = {
|
|
162
227
|
schedule: r.resolveString(endpoint.scheduleTrigger.schedule),
|
|
163
|
-
timeZone: r.resolveString(endpoint.scheduleTrigger.timeZone),
|
|
164
228
|
};
|
|
229
|
+
if (endpoint.scheduleTrigger.timeZone !== undefined) {
|
|
230
|
+
bkSchedule.timeZone = r.resolveString(endpoint.scheduleTrigger.timeZone);
|
|
231
|
+
}
|
|
165
232
|
if (endpoint.scheduleTrigger.retryConfig) {
|
|
166
233
|
const bkRetry = {};
|
|
167
234
|
r.resolveInts(bkRetry, endpoint.scheduleTrigger.retryConfig, "maxBackoffSeconds", "minBackoffSeconds", "maxRetrySeconds", "retryCount", "maxDoublings");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ensureServiceAgentRoles = exports.mergeBindings = exports.obtainDefaultComputeServiceAgentBindings = exports.obtainPubSubServiceAgentBindings = exports.checkHttpIam = exports.checkServiceAccountIam = exports.EVENTARC_EVENT_RECEIVER_ROLE = exports.RUN_INVOKER_ROLE = exports.SERVICE_ACCOUNT_TOKEN_CREATOR_ROLE = void 0;
|
|
3
|
+
exports.ensureServiceAgentRoles = exports.mergeBindings = exports.obtainDefaultComputeServiceAgentBindings = exports.obtainPubSubServiceAgentBindings = exports.getDefaultComputeServiceAgent = exports.checkHttpIam = exports.checkServiceAccountIam = exports.EVENTARC_EVENT_RECEIVER_ROLE = exports.RUN_INVOKER_ROLE = exports.SERVICE_ACCOUNT_TOKEN_CREATOR_ROLE = void 0;
|
|
4
4
|
const colorette_1 = require("colorette");
|
|
5
5
|
const logger_1 = require("../../logger");
|
|
6
6
|
const functionsDeployHelper_1 = require("./functionsDeployHelper");
|
|
@@ -68,11 +68,12 @@ async function checkHttpIam(context, options, payload) {
|
|
|
68
68
|
}
|
|
69
69
|
exports.checkHttpIam = checkHttpIam;
|
|
70
70
|
function getPubsubServiceAgent(projectNumber) {
|
|
71
|
-
return `
|
|
71
|
+
return `service-${projectNumber}@gcp-sa-pubsub.iam.gserviceaccount.com`;
|
|
72
72
|
}
|
|
73
73
|
function getDefaultComputeServiceAgent(projectNumber) {
|
|
74
|
-
return
|
|
74
|
+
return `${projectNumber}-compute@developer.gserviceaccount.com`;
|
|
75
75
|
}
|
|
76
|
+
exports.getDefaultComputeServiceAgent = getDefaultComputeServiceAgent;
|
|
76
77
|
function reduceEventsToServices(services, endpoint) {
|
|
77
78
|
const service = (0, services_1.serviceForEndpoint)(endpoint);
|
|
78
79
|
if (service.requiredProjectBindings && !services.find((s) => s.name === service.name)) {
|
|
@@ -83,13 +84,13 @@ function reduceEventsToServices(services, endpoint) {
|
|
|
83
84
|
function obtainPubSubServiceAgentBindings(projectNumber) {
|
|
84
85
|
const serviceAccountTokenCreatorBinding = {
|
|
85
86
|
role: exports.SERVICE_ACCOUNT_TOKEN_CREATOR_ROLE,
|
|
86
|
-
members: [getPubsubServiceAgent(projectNumber)],
|
|
87
|
+
members: [`serviceAccount:${getPubsubServiceAgent(projectNumber)}`],
|
|
87
88
|
};
|
|
88
89
|
return [serviceAccountTokenCreatorBinding];
|
|
89
90
|
}
|
|
90
91
|
exports.obtainPubSubServiceAgentBindings = obtainPubSubServiceAgentBindings;
|
|
91
92
|
function obtainDefaultComputeServiceAgentBindings(projectNumber) {
|
|
92
|
-
const defaultComputeServiceAgent = getDefaultComputeServiceAgent(projectNumber)
|
|
93
|
+
const defaultComputeServiceAgent = `serviceAccount:${getDefaultComputeServiceAgent(projectNumber)}`;
|
|
93
94
|
const runInvokerBinding = {
|
|
94
95
|
role: exports.RUN_INVOKER_ROLE,
|
|
95
96
|
members: [defaultComputeServiceAgent],
|
|
@@ -21,7 +21,7 @@ function resolveInt(from, paramValues) {
|
|
|
21
21
|
if (typeof from === "number") {
|
|
22
22
|
return from;
|
|
23
23
|
}
|
|
24
|
-
const match =
|
|
24
|
+
const match = /{{ params\.(\w+) }}/.exec(from);
|
|
25
25
|
if (!match) {
|
|
26
26
|
throw new error_1.FirebaseError("CEL evaluation of expression '" + from + "' not yet supported");
|
|
27
27
|
}
|
|
@@ -105,17 +105,17 @@ function canSatisfyParam(param, value) {
|
|
|
105
105
|
async function resolveParams(params, projectId, userEnvs) {
|
|
106
106
|
const paramValues = {};
|
|
107
107
|
const [provided, outstanding] = (0, functional_1.partition)(params, (param) => {
|
|
108
|
-
return {}.hasOwnProperty.call(userEnvs, param.
|
|
108
|
+
return {}.hasOwnProperty.call(userEnvs, param.name);
|
|
109
109
|
});
|
|
110
110
|
for (const param of provided) {
|
|
111
|
-
if (!canSatisfyParam(param, userEnvs[param.
|
|
111
|
+
if (!canSatisfyParam(param, userEnvs[param.name])) {
|
|
112
112
|
throw new error_1.FirebaseError("Parameter " +
|
|
113
|
-
param.
|
|
113
|
+
param.name +
|
|
114
114
|
" resolved to value from dotenv files " +
|
|
115
|
-
userEnvs[param.
|
|
115
|
+
userEnvs[param.name] +
|
|
116
116
|
" of wrong type");
|
|
117
117
|
}
|
|
118
|
-
paramValues[param.
|
|
118
|
+
paramValues[param.name] = userEnvs[param.name];
|
|
119
119
|
}
|
|
120
120
|
for (const param of outstanding) {
|
|
121
121
|
let paramDefault = param.default;
|
|
@@ -123,9 +123,9 @@ async function resolveParams(params, projectId, userEnvs) {
|
|
|
123
123
|
paramDefault = resolveDefaultCEL(param.type, paramDefault, paramValues);
|
|
124
124
|
}
|
|
125
125
|
if (paramDefault && !canSatisfyParam(param, paramDefault)) {
|
|
126
|
-
throw new error_1.FirebaseError("Parameter " + param.
|
|
126
|
+
throw new error_1.FirebaseError("Parameter " + param.name + " has default value " + paramDefault + " of wrong type");
|
|
127
127
|
}
|
|
128
|
-
paramValues[param.
|
|
128
|
+
paramValues[param.name] = await promptParam(param, paramDefault);
|
|
129
129
|
}
|
|
130
130
|
return paramValues;
|
|
131
131
|
}
|
|
@@ -146,15 +146,15 @@ async function promptStringParam(param, resolvedDefault) {
|
|
|
146
146
|
}
|
|
147
147
|
switch (param.input.type) {
|
|
148
148
|
case "select":
|
|
149
|
-
throw new error_1.FirebaseError("Build specified string parameter " + param.
|
|
149
|
+
throw new error_1.FirebaseError("Build specified string parameter " + param.name + " with unsupported input type 'select'");
|
|
150
150
|
case "text":
|
|
151
151
|
default:
|
|
152
|
-
let prompt = `Enter a value for ${param.label || param.
|
|
152
|
+
let prompt = `Enter a value for ${param.label || param.name}:`;
|
|
153
153
|
if (param.description) {
|
|
154
154
|
prompt += ` \n(${param.description})`;
|
|
155
155
|
}
|
|
156
156
|
return await (0, prompt_1.promptOnce)({
|
|
157
|
-
name: param.
|
|
157
|
+
name: param.name,
|
|
158
158
|
type: "input",
|
|
159
159
|
default: resolvedDefault,
|
|
160
160
|
message: prompt,
|
|
@@ -168,17 +168,17 @@ async function promptIntParam(param, resolvedDefault) {
|
|
|
168
168
|
}
|
|
169
169
|
switch (param.input.type) {
|
|
170
170
|
case "select":
|
|
171
|
-
throw new error_1.FirebaseError("Build specified int parameter " + param.
|
|
171
|
+
throw new error_1.FirebaseError("Build specified int parameter " + param.name + " with unsupported input type 'select'");
|
|
172
172
|
case "text":
|
|
173
173
|
default:
|
|
174
|
-
let prompt = `Enter a value for ${param.label || param.
|
|
174
|
+
let prompt = `Enter a value for ${param.label || param.name}:`;
|
|
175
175
|
if (param.description) {
|
|
176
176
|
prompt += ` \n(${param.description})`;
|
|
177
177
|
}
|
|
178
178
|
let res;
|
|
179
179
|
while (true) {
|
|
180
180
|
res = await (0, prompt_1.promptOnce)({
|
|
181
|
-
name: param.
|
|
181
|
+
name: param.name,
|
|
182
182
|
type: "number",
|
|
183
183
|
default: resolvedDefault,
|
|
184
184
|
message: prompt,
|
|
@@ -186,7 +186,7 @@ async function promptIntParam(param, resolvedDefault) {
|
|
|
186
186
|
if (Number.isInteger(res)) {
|
|
187
187
|
return res;
|
|
188
188
|
}
|
|
189
|
-
logger_1.logger.error(`${param.label || param.
|
|
189
|
+
logger_1.logger.error(`${param.label || param.name} must be an integer; retrying...`);
|
|
190
190
|
}
|
|
191
191
|
}
|
|
192
192
|
}
|