firebase-tools 11.26.0 → 11.27.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/deploy/functions/backend.js +1 -5
- package/lib/deploy/functions/release/fabricator.js +16 -6
- package/lib/frameworks/astro/index.js +76 -0
- package/lib/frameworks/astro/utils.js +22 -0
- package/lib/frameworks/nuxt/index.js +34 -14
- package/lib/frameworks/nuxt/utils.js +11 -1
- package/lib/frameworks/nuxt2/index.js +3 -9
- package/lib/gcp/cloudfunctions.js +3 -0
- package/lib/gcp/cloudfunctionsv2.js +39 -26
- package/npm-shrinkwrap.json +14 -14
- package/package.json +1 -1
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.compareFunctions = exports.missingEndpoint = exports.hasEndpoint = exports.regionalEndpoints = exports.matchingBackend = exports.findEndpoint = exports.someEndpoint = exports.allEndpoints = exports.checkAvailability = exports.existingBackend = exports.scheduleIdForFunction = exports.functionName = exports.isEmptyBackend = exports.merge = exports.of = exports.empty = exports.isBlockingTriggered = exports.isTaskQueueTriggered = exports.isScheduleTriggered = exports.isEventTriggered = exports.isCallableTriggered = exports.isHttpsTriggered = exports.AllFunctionsPlatforms = exports.secretVersionName = exports.SCHEDULED_FUNCTION_LABEL = exports.MIN_CPU_FOR_CONCURRENCY = exports.DEFAULT_MEMORY = exports.DEFAULT_CONCURRENCY = exports.memoryToGen2Cpu = exports.memoryToGen1Cpu = exports.memoryOptionDisplayName = exports.isValidMemoryOption = exports.AllIngressSettings = exports.AllVpcEgressSettings = exports.endpointTriggerType = void 0;
|
|
4
4
|
const gcf = require("../../gcp/cloudfunctions");
|
|
5
5
|
const gcfV2 = require("../../gcp/cloudfunctionsv2");
|
|
6
|
-
const run = require("../../gcp/run");
|
|
7
6
|
const utils = require("../../utils");
|
|
8
7
|
const error_1 = require("../../error");
|
|
9
8
|
const functional_1 = require("../../functional");
|
|
@@ -195,11 +194,8 @@ async function loadExistingBackend(ctx) {
|
|
|
195
194
|
let gcfV2Results;
|
|
196
195
|
try {
|
|
197
196
|
gcfV2Results = await gcfV2.listAllFunctions(ctx.projectId);
|
|
198
|
-
const
|
|
199
|
-
for (const [apiFunction, runService] of (0, functional_1.zip)(gcfV2Results.functions, runResults)) {
|
|
197
|
+
for (const apiFunction of gcfV2Results.functions) {
|
|
200
198
|
const endpoint = gcfV2.endpointFromFunction(apiFunction);
|
|
201
|
-
endpoint.concurrency = runService.spec.template.spec.containerConcurrency || 1;
|
|
202
|
-
endpoint.cpu = +runService.spec.template.spec.containers[0].resources.limits.cpu;
|
|
203
199
|
ctx.existingBackend.endpoints[endpoint.region] =
|
|
204
200
|
ctx.existingBackend.endpoints[endpoint.region] || {};
|
|
205
201
|
ctx.existingBackend.endpoints[endpoint.region][endpoint.id] = endpoint;
|
|
@@ -219,7 +219,7 @@ class Fabricator {
|
|
|
219
219
|
}
|
|
220
220
|
}
|
|
221
221
|
async createV2Function(endpoint) {
|
|
222
|
-
var _a, _b, _c;
|
|
222
|
+
var _a, _b, _c, _d, _e;
|
|
223
223
|
const storage = (_a = this.sources[endpoint.codebase]) === null || _a === void 0 ? void 0 : _a.storage;
|
|
224
224
|
if (!storage) {
|
|
225
225
|
logger_1.logger.debug("Precondition failed. Cannot create a GCFv2 function without storage");
|
|
@@ -274,8 +274,13 @@ class Fabricator {
|
|
|
274
274
|
return await poller.pollOperation(Object.assign(Object.assign({}, gcfV2PollerOptions), { pollerName: `create-${endpoint.codebase}-${endpoint.region}-${endpoint.id}`, operationResourceName: op.name }));
|
|
275
275
|
})
|
|
276
276
|
.catch(rethrowAs(endpoint, "create"));
|
|
277
|
-
endpoint.uri = resultFunction.serviceConfig.uri;
|
|
278
|
-
const serviceName = resultFunction.serviceConfig.service;
|
|
277
|
+
endpoint.uri = (_d = resultFunction.serviceConfig) === null || _d === void 0 ? void 0 : _d.uri;
|
|
278
|
+
const serviceName = (_e = resultFunction.serviceConfig) === null || _e === void 0 ? void 0 : _e.service;
|
|
279
|
+
if (!serviceName) {
|
|
280
|
+
logger_1.logger.debug("Result function unexpectedly didn't have a service name.");
|
|
281
|
+
utils.logLabeledWarning("functions", "Updated function is not associated with a service. This deployment is in an unexpected state - please re-deploy your functions.");
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
279
284
|
if (backend.isHttpsTriggered(endpoint)) {
|
|
280
285
|
const invoker = endpoint.httpsTrigger.invoker || ["public"];
|
|
281
286
|
if (!invoker.includes("private")) {
|
|
@@ -346,7 +351,7 @@ class Fabricator {
|
|
|
346
351
|
}
|
|
347
352
|
}
|
|
348
353
|
async updateV2Function(endpoint) {
|
|
349
|
-
var _a, _b;
|
|
354
|
+
var _a, _b, _c, _d;
|
|
350
355
|
const storage = (_a = this.sources[endpoint.codebase]) === null || _a === void 0 ? void 0 : _a.storage;
|
|
351
356
|
if (!storage) {
|
|
352
357
|
logger_1.logger.debug("Precondition failed. Cannot update a GCFv2 function without storage");
|
|
@@ -362,8 +367,13 @@ class Fabricator {
|
|
|
362
367
|
return await poller.pollOperation(Object.assign(Object.assign({}, gcfV2PollerOptions), { pollerName: `update-${endpoint.codebase}-${endpoint.region}-${endpoint.id}`, operationResourceName: op.name }));
|
|
363
368
|
})
|
|
364
369
|
.catch(rethrowAs(endpoint, "update"));
|
|
365
|
-
endpoint.uri = resultFunction.serviceConfig.uri;
|
|
366
|
-
const serviceName = resultFunction.serviceConfig.service;
|
|
370
|
+
endpoint.uri = (_c = resultFunction.serviceConfig) === null || _c === void 0 ? void 0 : _c.uri;
|
|
371
|
+
const serviceName = (_d = resultFunction.serviceConfig) === null || _d === void 0 ? void 0 : _d.service;
|
|
372
|
+
if (!serviceName) {
|
|
373
|
+
logger_1.logger.debug("Result function unexpectedly didn't have a service name.");
|
|
374
|
+
utils.logLabeledWarning("functions", "Updated function is not associated with a service. This deployment is in an unexpected state - please re-deploy your functions.");
|
|
375
|
+
return;
|
|
376
|
+
}
|
|
367
377
|
let invoker;
|
|
368
378
|
if (backend.isHttpsTriggered(endpoint)) {
|
|
369
379
|
invoker = endpoint.httpsTrigger.invoker === null ? ["public"] : endpoint.httpsTrigger.invoker;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getDevModeHandle = exports.ɵcodegenFunctionsDirectory = exports.ɵcodegenPublicDirectory = exports.build = exports.discover = exports.type = exports.support = exports.name = void 0;
|
|
4
|
+
const cross_spawn_1 = require("cross-spawn");
|
|
5
|
+
const fs_extra_1 = require("fs-extra");
|
|
6
|
+
const path_1 = require("path");
|
|
7
|
+
const __1 = require("..");
|
|
8
|
+
const error_1 = require("../../error");
|
|
9
|
+
const utils_1 = require("../utils");
|
|
10
|
+
const utils_2 = require("./utils");
|
|
11
|
+
exports.name = "Astro";
|
|
12
|
+
exports.support = "experimental";
|
|
13
|
+
exports.type = 2;
|
|
14
|
+
function getAstroVersion(cwd) {
|
|
15
|
+
var _a;
|
|
16
|
+
return (_a = (0, __1.findDependency)("astro", { cwd, depth: 0, omitDev: false })) === null || _a === void 0 ? void 0 : _a.version;
|
|
17
|
+
}
|
|
18
|
+
async function discover(dir) {
|
|
19
|
+
if (!(0, fs_extra_1.existsSync)((0, path_1.join)(dir, "package.json")))
|
|
20
|
+
return;
|
|
21
|
+
if (!getAstroVersion(dir))
|
|
22
|
+
return;
|
|
23
|
+
const { output, publicDir: publicDirectory } = await (0, utils_2.getConfig)(dir);
|
|
24
|
+
return {
|
|
25
|
+
mayWantBackend: output === "server",
|
|
26
|
+
publicDirectory,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
exports.discover = discover;
|
|
30
|
+
const DEFAULT_BUILD_SCRIPT = ["astro build"];
|
|
31
|
+
async function build(cwd) {
|
|
32
|
+
const cli = (0, __1.getNodeModuleBin)("astro", cwd);
|
|
33
|
+
await (0, utils_1.warnIfCustomBuildScript)(cwd, exports.name, DEFAULT_BUILD_SCRIPT);
|
|
34
|
+
const { output, adapter } = await (0, utils_2.getConfig)(cwd);
|
|
35
|
+
if (output === "server" && (adapter === null || adapter === void 0 ? void 0 : adapter.name) !== "@astrojs/node") {
|
|
36
|
+
throw new error_1.FirebaseError("Deploying an Astro application with SSR on Firebase Hosting requires the @astrojs/node adapter.");
|
|
37
|
+
}
|
|
38
|
+
const build = (0, cross_spawn_1.sync)(cli, ["build"], { cwd, stdio: "inherit" });
|
|
39
|
+
if (build.status)
|
|
40
|
+
throw new error_1.FirebaseError("Unable to build your Astro app");
|
|
41
|
+
return { wantsBackend: output === "server" };
|
|
42
|
+
}
|
|
43
|
+
exports.build = build;
|
|
44
|
+
async function ɵcodegenPublicDirectory(root, dest) {
|
|
45
|
+
const { outDir, output } = await (0, utils_2.getConfig)(root);
|
|
46
|
+
const assetPath = (0, path_1.join)(root, outDir, output === "server" ? "client" : "");
|
|
47
|
+
await (0, fs_extra_1.copy)(assetPath, dest);
|
|
48
|
+
}
|
|
49
|
+
exports.ɵcodegenPublicDirectory = ɵcodegenPublicDirectory;
|
|
50
|
+
async function ɵcodegenFunctionsDirectory(sourceDir, destDir) {
|
|
51
|
+
const { outDir } = await (0, utils_2.getConfig)(sourceDir);
|
|
52
|
+
const packageJson = await (0, utils_1.readJSON)((0, path_1.join)(sourceDir, "package.json"));
|
|
53
|
+
await (0, fs_extra_1.copy)((0, path_1.join)(sourceDir, outDir, "server"), (0, path_1.join)(destDir));
|
|
54
|
+
return {
|
|
55
|
+
packageJson,
|
|
56
|
+
bootstrapScript: (0, utils_2.getBootstrapScript)(),
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
exports.ɵcodegenFunctionsDirectory = ɵcodegenFunctionsDirectory;
|
|
60
|
+
async function getDevModeHandle(cwd) {
|
|
61
|
+
const host = new Promise((resolve) => {
|
|
62
|
+
const cli = (0, __1.getNodeModuleBin)("astro", cwd);
|
|
63
|
+
const serve = (0, cross_spawn_1.spawn)(cli, ["dev"], { cwd });
|
|
64
|
+
serve.stdout.on("data", (data) => {
|
|
65
|
+
process.stdout.write(data);
|
|
66
|
+
const match = data.toString().match(/(http:\/\/.+:\d+)/);
|
|
67
|
+
if (match)
|
|
68
|
+
resolve(match[1]);
|
|
69
|
+
});
|
|
70
|
+
serve.stderr.on("data", (data) => {
|
|
71
|
+
process.stderr.write(data);
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
return (0, utils_1.simpleProxy)(await host);
|
|
75
|
+
}
|
|
76
|
+
exports.getDevModeHandle = getDevModeHandle;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getConfig = exports.getBootstrapScript = void 0;
|
|
4
|
+
const path_1 = require("path");
|
|
5
|
+
const { dynamicImport } = require(true && "../../dynamicImport");
|
|
6
|
+
function getBootstrapScript() {
|
|
7
|
+
return `const entry = import('./entry.mjs');\nexport const handle = async (req, res) => (await entry).handler(req, res)`;
|
|
8
|
+
}
|
|
9
|
+
exports.getBootstrapScript = getBootstrapScript;
|
|
10
|
+
async function getConfig(cwd) {
|
|
11
|
+
const astroDirectory = (0, path_1.dirname)(require.resolve("astro/package.json", { paths: [cwd] }));
|
|
12
|
+
const { openConfig } = await dynamicImport((0, path_1.join)(astroDirectory, "dist", "core", "config", "config.js"));
|
|
13
|
+
const logging = undefined;
|
|
14
|
+
const { astroConfig: config } = await openConfig({ cmd: "build", cwd, logging });
|
|
15
|
+
return {
|
|
16
|
+
outDir: (0, path_1.relative)(cwd, config.outDir.pathname),
|
|
17
|
+
publicDir: (0, path_1.relative)(cwd, config.publicDir.pathname),
|
|
18
|
+
output: config.output,
|
|
19
|
+
adapter: config.adapter,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
exports.getConfig = getConfig;
|
|
@@ -1,32 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ɵcodegenFunctionsDirectory = exports.ɵcodegenPublicDirectory = exports.build = exports.discover = exports.type = exports.support = exports.name = void 0;
|
|
3
|
+
exports.getConfig = exports.getDevModeHandle = exports.ɵcodegenFunctionsDirectory = exports.ɵcodegenPublicDirectory = exports.build = exports.discover = exports.type = exports.support = exports.name = void 0;
|
|
4
4
|
const fs_extra_1 = require("fs-extra");
|
|
5
5
|
const promises_1 = require("fs/promises");
|
|
6
6
|
const path_1 = require("path");
|
|
7
7
|
const semver_1 = require("semver");
|
|
8
|
+
const cross_spawn_1 = require("cross-spawn");
|
|
8
9
|
const __1 = require("..");
|
|
9
10
|
const utils_1 = require("../utils");
|
|
11
|
+
const utils_2 = require("./utils");
|
|
10
12
|
exports.name = "Nuxt";
|
|
11
13
|
exports.support = "experimental";
|
|
12
14
|
exports.type = 4;
|
|
13
|
-
const
|
|
14
|
-
const DEFAULT_BUILD_SCRIPT = ["nuxt build"];
|
|
15
|
+
const utils_3 = require("./utils");
|
|
16
|
+
const DEFAULT_BUILD_SCRIPT = ["nuxt build", "nuxi build"];
|
|
15
17
|
async function discover(dir) {
|
|
16
18
|
if (!(await (0, fs_extra_1.pathExists)((0, path_1.join)(dir, "package.json"))))
|
|
17
19
|
return;
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const version = nuxtDependency === null || nuxtDependency === void 0 ? void 0 : nuxtDependency.version;
|
|
24
|
-
const anyConfigFileExists = await (0, utils_2.nuxtConfigFilesExist)(dir);
|
|
25
|
-
if (!anyConfigFileExists && !nuxtDependency)
|
|
20
|
+
const anyConfigFileExists = await (0, utils_3.nuxtConfigFilesExist)(dir);
|
|
21
|
+
const nuxtVersion = (0, utils_2.getNuxtVersion)(dir);
|
|
22
|
+
if (!anyConfigFileExists && !nuxtVersion)
|
|
23
|
+
return;
|
|
24
|
+
if (nuxtVersion && (0, semver_1.lt)(nuxtVersion, "3.0.0-0"))
|
|
26
25
|
return;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
return;
|
|
26
|
+
const { dir: { public: publicDirectory }, } = await getConfig(dir);
|
|
27
|
+
return { publicDirectory, mayWantBackend: true };
|
|
30
28
|
}
|
|
31
29
|
exports.discover = discover;
|
|
32
30
|
async function build(root) {
|
|
@@ -60,3 +58,25 @@ async function ɵcodegenFunctionsDirectory(sourceDir, destDir) {
|
|
|
60
58
|
return { packageJson: Object.assign(Object.assign({}, packageJson), outputPackageJson), frameworksEntry: "nuxt3" };
|
|
61
59
|
}
|
|
62
60
|
exports.ɵcodegenFunctionsDirectory = ɵcodegenFunctionsDirectory;
|
|
61
|
+
async function getDevModeHandle(cwd) {
|
|
62
|
+
const host = new Promise((resolve) => {
|
|
63
|
+
const cli = (0, __1.getNodeModuleBin)("nuxt", cwd);
|
|
64
|
+
const serve = (0, cross_spawn_1.spawn)(cli, ["dev"], { cwd: cwd });
|
|
65
|
+
serve.stdout.on("data", (data) => {
|
|
66
|
+
process.stdout.write(data);
|
|
67
|
+
const match = data.toString().match(/(http:\/\/.+:\d+)/);
|
|
68
|
+
if (match)
|
|
69
|
+
resolve(match[1]);
|
|
70
|
+
});
|
|
71
|
+
serve.stderr.on("data", (data) => {
|
|
72
|
+
process.stderr.write(data);
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
return (0, utils_1.simpleProxy)(await host);
|
|
76
|
+
}
|
|
77
|
+
exports.getDevModeHandle = getDevModeHandle;
|
|
78
|
+
async function getConfig(dir) {
|
|
79
|
+
const { loadNuxtConfig } = await (0, __1.relativeRequire)(dir, "@nuxt/kit");
|
|
80
|
+
return await loadNuxtConfig(dir);
|
|
81
|
+
}
|
|
82
|
+
exports.getConfig = getConfig;
|
|
@@ -1,8 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.nuxtConfigFilesExist = void 0;
|
|
3
|
+
exports.nuxtConfigFilesExist = exports.getNuxtVersion = void 0;
|
|
4
4
|
const fs_extra_1 = require("fs-extra");
|
|
5
5
|
const path_1 = require("path");
|
|
6
|
+
const __1 = require("..");
|
|
7
|
+
function getNuxtVersion(cwd) {
|
|
8
|
+
var _a;
|
|
9
|
+
return (_a = (0, __1.findDependency)("nuxt", {
|
|
10
|
+
cwd,
|
|
11
|
+
depth: 0,
|
|
12
|
+
omitDev: false,
|
|
13
|
+
})) === null || _a === void 0 ? void 0 : _a.version;
|
|
14
|
+
}
|
|
15
|
+
exports.getNuxtVersion = getNuxtVersion;
|
|
6
16
|
async function nuxtConfigFilesExist(dir) {
|
|
7
17
|
const configFilesExist = await Promise.all([
|
|
8
18
|
(0, fs_extra_1.pathExists)((0, path_1.join)(dir, "nuxt.config.js")),
|
|
@@ -13,18 +13,12 @@ exports.type = 2;
|
|
|
13
13
|
async function discover(dir) {
|
|
14
14
|
if (!(await (0, fs_extra_1.pathExists)((0, path_1.join)(dir, "package.json"))))
|
|
15
15
|
return;
|
|
16
|
-
const
|
|
17
|
-
cwd: dir,
|
|
18
|
-
depth: 0,
|
|
19
|
-
omitDev: false,
|
|
20
|
-
});
|
|
21
|
-
const version = nuxtDependency === null || nuxtDependency === void 0 ? void 0 : nuxtDependency.version;
|
|
16
|
+
const nuxtVersion = (0, utils_1.getNuxtVersion)(dir);
|
|
22
17
|
const anyConfigFileExists = await (0, utils_1.nuxtConfigFilesExist)(dir);
|
|
23
|
-
if (!anyConfigFileExists && !
|
|
18
|
+
if (!anyConfigFileExists && !nuxtVersion)
|
|
24
19
|
return;
|
|
25
|
-
if (
|
|
20
|
+
if (nuxtVersion && (0, semver_1.lt)(nuxtVersion, "3.0.0-0"))
|
|
26
21
|
return { mayWantBackend: true };
|
|
27
|
-
return;
|
|
28
22
|
}
|
|
29
23
|
exports.discover = discover;
|
|
30
24
|
async function getNuxtApp(cwd) {
|
|
@@ -44,6 +44,7 @@ exports.generateUploadUrl = generateUploadUrl;
|
|
|
44
44
|
async function createFunction(cloudFunction) {
|
|
45
45
|
const apiPath = cloudFunction.name.substring(0, cloudFunction.name.lastIndexOf("/"));
|
|
46
46
|
const endpoint = `/${apiPath}`;
|
|
47
|
+
cloudFunction.buildEnvironmentVariables = Object.assign(Object.assign({}, cloudFunction.buildEnvironmentVariables), { GOOGLE_NODE_RUN_SCRIPTS: "" });
|
|
47
48
|
try {
|
|
48
49
|
const res = await client.post(endpoint, cloudFunction);
|
|
49
50
|
return {
|
|
@@ -131,6 +132,8 @@ exports.setInvokerUpdate = setInvokerUpdate;
|
|
|
131
132
|
async function updateFunction(cloudFunction) {
|
|
132
133
|
const endpoint = `/${cloudFunction.name}`;
|
|
133
134
|
const fieldMasks = proto.fieldMasks(cloudFunction, "labels", "environmentVariables", "secretEnvironmentVariables");
|
|
135
|
+
cloudFunction.buildEnvironmentVariables = Object.assign(Object.assign({}, cloudFunction.buildEnvironmentVariables), { GOOGLE_NODE_RUN_SCRIPTS: "" });
|
|
136
|
+
fieldMasks.push("buildEnvironmentVariables");
|
|
134
137
|
try {
|
|
135
138
|
const res = await client.patch(endpoint, cloudFunction, {
|
|
136
139
|
queryParams: {
|
|
@@ -80,6 +80,7 @@ exports.generateUploadUrl = generateUploadUrl;
|
|
|
80
80
|
async function createFunction(cloudFunction) {
|
|
81
81
|
const components = cloudFunction.name.split("/");
|
|
82
82
|
const functionId = components.splice(-1, 1)[0];
|
|
83
|
+
cloudFunction.buildConfig.environmentVariables = Object.assign(Object.assign({}, cloudFunction.buildConfig.environmentVariables), { GOOGLE_NODE_RUN_SCRIPTS: "" });
|
|
83
84
|
try {
|
|
84
85
|
const res = await client.post(components.join("/"), cloudFunction, { queryParams: { functionId } });
|
|
85
86
|
return res.body;
|
|
@@ -133,6 +134,8 @@ async function listFunctionsInternal(projectId, region) {
|
|
|
133
134
|
}
|
|
134
135
|
async function updateFunction(cloudFunction) {
|
|
135
136
|
const fieldMasks = proto.fieldMasks(cloudFunction, "labels", "serviceConfig.environmentVariables", "serviceConfig.secretEnvironmentVariables");
|
|
137
|
+
cloudFunction.buildConfig.environmentVariables = Object.assign(Object.assign({}, cloudFunction.buildConfig.environmentVariables), { GOOGLE_NODE_RUN_SCRIPTS: "" });
|
|
138
|
+
fieldMasks.push("buildConfig.buildEnvironmentVariables");
|
|
136
139
|
try {
|
|
137
140
|
const queryParams = {
|
|
138
141
|
updateMask: fieldMasks.join(","),
|
|
@@ -322,39 +325,49 @@ function endpointFromFunction(gcfFunction) {
|
|
|
322
325
|
}
|
|
323
326
|
const endpoint = Object.assign(Object.assign({ platform: "gcfv2", id,
|
|
324
327
|
project,
|
|
325
|
-
region }, trigger), { entryPoint: gcfFunction.buildConfig.entryPoint, runtime: gcfFunction.buildConfig.runtime
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
328
|
+
region }, trigger), { entryPoint: gcfFunction.buildConfig.entryPoint, runtime: gcfFunction.buildConfig.runtime });
|
|
329
|
+
if (gcfFunction.serviceConfig) {
|
|
330
|
+
proto.copyIfPresent(endpoint, gcfFunction.serviceConfig, "ingressSettings", "environmentVariables", "secretEnvironmentVariables", "timeoutSeconds", "uri");
|
|
331
|
+
proto.renameIfPresent(endpoint, gcfFunction.serviceConfig, "serviceAccount", "serviceAccountEmail");
|
|
332
|
+
proto.convertIfPresent(endpoint, gcfFunction.serviceConfig, "availableMemoryMb", "availableMemory", (prod) => {
|
|
333
|
+
if (prod === null) {
|
|
334
|
+
logger_1.logger.debug("Prod should always return a valid memory amount");
|
|
335
|
+
return prod;
|
|
336
|
+
}
|
|
337
|
+
const mem = mebibytes(prod);
|
|
338
|
+
if (!backend.isValidMemoryOption(mem)) {
|
|
339
|
+
logger_1.logger.warn("Converting a function to an endpoint with an invalid memory option", mem);
|
|
340
|
+
}
|
|
341
|
+
return mem;
|
|
342
|
+
});
|
|
343
|
+
proto.convertIfPresent(endpoint, gcfFunction.serviceConfig, "cpu", "availableCpu", (cpu) => {
|
|
344
|
+
let cpuVal = Number(cpu);
|
|
345
|
+
if (Number.isNaN(cpuVal)) {
|
|
346
|
+
cpuVal = null;
|
|
347
|
+
}
|
|
348
|
+
return cpuVal;
|
|
349
|
+
});
|
|
350
|
+
proto.renameIfPresent(endpoint, gcfFunction.serviceConfig, "minInstances", "minInstanceCount");
|
|
351
|
+
proto.renameIfPresent(endpoint, gcfFunction.serviceConfig, "maxInstances", "maxInstanceCount");
|
|
352
|
+
proto.renameIfPresent(endpoint, gcfFunction.serviceConfig, "concurrency", "maxInstanceRequestConcurrency");
|
|
353
|
+
proto.copyIfPresent(endpoint, gcfFunction, "labels");
|
|
354
|
+
if (gcfFunction.serviceConfig.vpcConnector) {
|
|
355
|
+
endpoint.vpc = { connector: gcfFunction.serviceConfig.vpcConnector };
|
|
356
|
+
proto.renameIfPresent(endpoint.vpc, gcfFunction.serviceConfig, "egressSettings", "vpcConnectorEgressSettings");
|
|
332
357
|
}
|
|
333
|
-
const
|
|
334
|
-
if (!
|
|
335
|
-
logger_1.logger.
|
|
358
|
+
const serviceName = gcfFunction.serviceConfig.service;
|
|
359
|
+
if (!serviceName) {
|
|
360
|
+
logger_1.logger.debug("Got a v2 function without a service name." +
|
|
361
|
+
"Maybe we've migrated to using the v2 API everywhere and missed this code");
|
|
362
|
+
}
|
|
363
|
+
else {
|
|
364
|
+
endpoint.runServiceId = utils.last(serviceName.split("/"));
|
|
336
365
|
}
|
|
337
|
-
return mem;
|
|
338
|
-
});
|
|
339
|
-
proto.renameIfPresent(endpoint, gcfFunction.serviceConfig, "minInstances", "minInstanceCount");
|
|
340
|
-
proto.renameIfPresent(endpoint, gcfFunction.serviceConfig, "maxInstances", "maxInstanceCount");
|
|
341
|
-
proto.copyIfPresent(endpoint, gcfFunction, "labels");
|
|
342
|
-
if (gcfFunction.serviceConfig.vpcConnector) {
|
|
343
|
-
endpoint.vpc = { connector: gcfFunction.serviceConfig.vpcConnector };
|
|
344
|
-
proto.renameIfPresent(endpoint.vpc, gcfFunction.serviceConfig, "egressSettings", "vpcConnectorEgressSettings");
|
|
345
366
|
}
|
|
346
367
|
endpoint.codebase = ((_e = gcfFunction.labels) === null || _e === void 0 ? void 0 : _e[constants_1.CODEBASE_LABEL]) || projectConfig.DEFAULT_CODEBASE;
|
|
347
368
|
if ((_f = gcfFunction.labels) === null || _f === void 0 ? void 0 : _f[constants_1.HASH_LABEL]) {
|
|
348
369
|
endpoint.hash = gcfFunction.labels[constants_1.HASH_LABEL];
|
|
349
370
|
}
|
|
350
|
-
const serviceName = gcfFunction.serviceConfig.service;
|
|
351
|
-
if (!serviceName) {
|
|
352
|
-
logger_1.logger.debug("Got a v2 function without a service name." +
|
|
353
|
-
"Maybe we've migrated to using the v2 API everywhere and missed this code");
|
|
354
|
-
}
|
|
355
|
-
else {
|
|
356
|
-
endpoint.runServiceId = utils.last(serviceName.split("/"));
|
|
357
|
-
}
|
|
358
371
|
return endpoint;
|
|
359
372
|
}
|
|
360
373
|
exports.endpointFromFunction = endpointFromFunction;
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "firebase-tools",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.27.0",
|
|
4
4
|
"lockfileVersion": 2,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "firebase-tools",
|
|
9
|
-
"version": "11.
|
|
9
|
+
"version": "11.27.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@google-cloud/pubsub": "^3.0.1",
|
|
@@ -90,9 +90,9 @@
|
|
|
90
90
|
}
|
|
91
91
|
},
|
|
92
92
|
"node_modules/@babel/parser": {
|
|
93
|
-
"version": "7.
|
|
94
|
-
"resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.
|
|
95
|
-
"integrity": "sha512-
|
|
93
|
+
"version": "7.21.4",
|
|
94
|
+
"resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.21.4.tgz",
|
|
95
|
+
"integrity": "sha512-alVJj7k7zIxqBZ7BTRhz0IqJFxW1VJbm6N8JbcYhQ186df9ZBPbZBmWSqAMXwHGsCJdYks7z/voa3ibiS5bCIw==",
|
|
96
96
|
"bin": {
|
|
97
97
|
"parser": "bin/babel-parser.js"
|
|
98
98
|
},
|
|
@@ -547,9 +547,9 @@
|
|
|
547
547
|
}
|
|
548
548
|
},
|
|
549
549
|
"node_modules/acorn": {
|
|
550
|
-
"version": "8.8.
|
|
551
|
-
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.
|
|
552
|
-
"integrity": "sha512-
|
|
550
|
+
"version": "8.8.2",
|
|
551
|
+
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.2.tgz",
|
|
552
|
+
"integrity": "sha512-xjIYgE8HBrkpd/sJqOGNspf8uHG+NOHGOw6a/Urj8taM2EXfdNAH2oFcPeIFfsv3+kz/mJrS5VuMqbNLjCa2vw==",
|
|
553
553
|
"bin": {
|
|
554
554
|
"acorn": "bin/acorn"
|
|
555
555
|
},
|
|
@@ -7173,9 +7173,9 @@
|
|
|
7173
7173
|
}
|
|
7174
7174
|
},
|
|
7175
7175
|
"@babel/parser": {
|
|
7176
|
-
"version": "7.
|
|
7177
|
-
"resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.
|
|
7178
|
-
"integrity": "sha512-
|
|
7176
|
+
"version": "7.21.4",
|
|
7177
|
+
"resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.21.4.tgz",
|
|
7178
|
+
"integrity": "sha512-alVJj7k7zIxqBZ7BTRhz0IqJFxW1VJbm6N8JbcYhQ186df9ZBPbZBmWSqAMXwHGsCJdYks7z/voa3ibiS5bCIw=="
|
|
7179
7179
|
},
|
|
7180
7180
|
"@colors/colors": {
|
|
7181
7181
|
"version": "1.5.0",
|
|
@@ -7546,9 +7546,9 @@
|
|
|
7546
7546
|
}
|
|
7547
7547
|
},
|
|
7548
7548
|
"acorn": {
|
|
7549
|
-
"version": "8.8.
|
|
7550
|
-
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.
|
|
7551
|
-
"integrity": "sha512-
|
|
7549
|
+
"version": "8.8.2",
|
|
7550
|
+
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.2.tgz",
|
|
7551
|
+
"integrity": "sha512-xjIYgE8HBrkpd/sJqOGNspf8uHG+NOHGOw6a/Urj8taM2EXfdNAH2oFcPeIFfsv3+kz/mJrS5VuMqbNLjCa2vw=="
|
|
7552
7552
|
},
|
|
7553
7553
|
"acorn-jsx": {
|
|
7554
7554
|
"version": "5.3.2",
|