firebase-tools-with-isolate 12.9.1-4 → 12.9.1-5
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/accountExporter.js +1 -2
- package/lib/apiv2.js +5 -9
- package/lib/appdistribution/client.js +2 -3
- package/lib/auth.js +12 -15
- package/lib/command.js +1 -2
- package/lib/commands/crashlytics-symbols-upload.js +2 -2
- package/lib/commands/emulators-start.js +1 -2
- package/lib/commands/ext-configure.js +6 -4
- package/lib/commands/ext-dev-list.js +2 -3
- package/lib/commands/ext-export.js +1 -1
- package/lib/commands/ext-info.js +2 -3
- package/lib/commands/ext-install.js +5 -7
- package/lib/commands/firestore-indexes-list.js +1 -2
- package/lib/commands/frameworks-backends-delete.js +1 -2
- package/lib/commands/frameworks-backends-get.js +1 -2
- package/lib/commands/frameworks-backends-list.js +1 -2
- package/lib/commands/hosting-clone.js +2 -3
- package/lib/commands/init.js +1 -2
- package/lib/commands/logout.js +1 -1
- package/lib/commands/remoteconfig-get.js +1 -1
- package/lib/commands/remoteconfig-rollback.js +1 -2
- package/lib/commands/remoteconfig-versions-list.js +1 -2
- package/lib/config.js +2 -3
- package/lib/crashlytics/buildToolsJarHelper.js +1 -2
- package/lib/database/import.js +4 -4
- package/lib/deploy/extensions/deploy.js +6 -7
- package/lib/deploy/extensions/deploymentSummary.js +1 -2
- package/lib/deploy/extensions/planner.js +4 -5
- package/lib/deploy/extensions/prepare.js +6 -7
- package/lib/deploy/extensions/release.js +9 -10
- package/lib/deploy/extensions/secrets.js +6 -8
- package/lib/deploy/extensions/tasks.js +1 -2
- package/lib/deploy/firestore/deploy.js +2 -4
- package/lib/deploy/firestore/release.js +2 -3
- package/lib/deploy/functions/backend.js +17 -15
- package/lib/deploy/functions/build.js +9 -1
- package/lib/deploy/functions/cache/applyHash.js +2 -3
- package/lib/deploy/functions/containerCleaner.js +11 -3
- package/lib/deploy/functions/deploy.js +1 -2
- package/lib/deploy/functions/ensure.js +3 -5
- package/lib/deploy/functions/prepare.js +21 -18
- package/lib/deploy/functions/prepareFunctionsUpload.js +13 -7
- package/lib/deploy/functions/prompts.js +2 -4
- package/lib/deploy/functions/release/executor.js +5 -6
- package/lib/deploy/functions/release/fabricator.js +58 -30
- package/lib/deploy/functions/release/index.js +10 -7
- package/lib/deploy/functions/release/planner.js +2 -3
- package/lib/deploy/functions/release/reporter.js +11 -14
- package/lib/deploy/functions/release/sourceTokenScraper.js +4 -5
- package/lib/deploy/functions/runtimes/discovery/index.js +1 -1
- package/lib/deploy/functions/runtimes/discovery/v1alpha1.js +13 -8
- package/lib/deploy/functions/runtimes/node/index.js +11 -4
- package/lib/deploy/functions/runtimes/node/parseTriggers.js +23 -10
- package/lib/deploy/functions/runtimes/node/versioning.js +1 -2
- package/lib/deploy/functions/runtimes/python/index.js +8 -7
- package/lib/deploy/functions/services/auth.js +29 -22
- package/lib/deploy/functions/services/firestore.js +1 -2
- package/lib/deploy/functions/services/storage.js +1 -2
- package/lib/deploy/functions/validate.js +1 -2
- package/lib/deploy/hosting/convertConfig.js +36 -19
- package/lib/deploy/hosting/deploy.js +3 -5
- package/lib/deploy/hosting/prepare.js +10 -9
- package/lib/deploy/lifecycleHooks.js +2 -3
- package/lib/deploy/remoteconfig/functions.js +1 -1
- package/lib/deploy/remoteconfig/prepare.js +1 -2
- package/lib/deploy/remoteconfig/release.js +1 -1
- package/lib/deploymentTool.js +1 -2
- package/lib/emulator/auth/cloudFunctions.js +1 -1
- package/lib/emulator/auth/handlers.js +2 -2
- package/lib/emulator/auth/index.js +5 -5
- package/lib/emulator/auth/operations.js +165 -124
- package/lib/emulator/auth/server.js +29 -20
- package/lib/emulator/auth/state.js +21 -31
- package/lib/emulator/auth/utils.js +1 -1
- package/lib/emulator/commandUtils.js +9 -9
- package/lib/emulator/controller.js +16 -13
- package/lib/emulator/databaseEmulator.js +1 -2
- package/lib/emulator/downloadableEmulators.js +3 -4
- package/lib/emulator/emulatorLogger.js +18 -3
- package/lib/emulator/eventarcEmulator.js +2 -3
- package/lib/emulator/eventarcEmulatorUtils.js +2 -4
- package/lib/emulator/extensions/validation.js +2 -4
- package/lib/emulator/extensionsEmulator.js +6 -9
- package/lib/emulator/functionsEmulator.js +69 -37
- package/lib/emulator/functionsEmulatorRuntime.js +1 -1
- package/lib/emulator/functionsEmulatorShared.js +5 -7
- package/lib/emulator/functionsEmulatorShell.js +4 -6
- package/lib/emulator/functionsRuntimeWorker.js +17 -8
- package/lib/emulator/hub.js +9 -2
- package/lib/emulator/hubClient.js +1 -1
- package/lib/emulator/loggingEmulator.js +2 -2
- package/lib/emulator/registry.js +10 -4
- package/lib/emulator/storage/apis/firebase.js +15 -18
- package/lib/emulator/storage/apis/gcloud.js +5 -7
- package/lib/emulator/storage/files.js +18 -41
- package/lib/emulator/storage/metadata.js +8 -2
- package/lib/emulator/storage/rules/manager.js +2 -3
- package/lib/emulator/storage/rules/runtime.js +15 -13
- package/lib/emulator/storage/rules/utils.js +1 -1
- package/lib/emulator/storage/upload.js +1 -2
- package/lib/ensureApiEnabled.js +1 -2
- package/lib/error.js +3 -5
- package/lib/experiments.js +2 -4
- package/lib/extensions/askUserForEventsConfig.js +5 -6
- package/lib/extensions/askUserForParam.js +4 -5
- package/lib/extensions/displayExtensionInfo.js +20 -26
- package/lib/extensions/emulator/optionsHelper.js +2 -3
- package/lib/extensions/emulator/specHelper.js +9 -10
- package/lib/extensions/export.js +4 -5
- package/lib/extensions/extensionsApi.js +8 -13
- package/lib/extensions/extensionsHelper.js +15 -18
- package/lib/extensions/listExtensions.js +2 -3
- package/lib/extensions/manifest.js +2 -3
- package/lib/extensions/paramHelper.js +10 -5
- package/lib/extensions/provisioningHelper.js +12 -16
- package/lib/extensions/publisherApi.js +1 -2
- package/lib/extensions/resolveSource.js +1 -2
- package/lib/extensions/tos.js +8 -2
- package/lib/extensions/utils.js +2 -3
- package/lib/extensions/warnings.js +4 -5
- package/lib/frameworks/angular/index.js +5 -6
- package/lib/frameworks/angular/utils.js +10 -12
- package/lib/frameworks/astro/index.js +1 -1
- package/lib/frameworks/astro/utils.js +1 -2
- package/lib/frameworks/compose/discover/filesystem.js +1 -1
- package/lib/frameworks/compose/discover/runtime/node.js +8 -11
- package/lib/frameworks/compose/driver/docker.js +3 -5
- package/lib/frameworks/compose/driver/local.js +2 -3
- package/lib/frameworks/compose/index.js +4 -5
- package/lib/frameworks/express/index.js +2 -3
- package/lib/frameworks/flutter/index.js +1 -2
- package/lib/frameworks/index.js +16 -17
- package/lib/frameworks/next/index.js +21 -18
- package/lib/frameworks/next/utils.js +6 -3
- package/lib/frameworks/nuxt/index.js +1 -1
- package/lib/frameworks/nuxt/utils.js +2 -3
- package/lib/frameworks/nuxt2/index.js +1 -1
- package/lib/frameworks/sveltekit/index.js +2 -4
- package/lib/frameworks/utils.js +10 -7
- package/lib/functions/env.js +3 -4
- package/lib/functions/projectConfig.js +1 -1
- package/lib/functions/python.js +7 -1
- package/lib/functions/runtimeConfigExport.js +1 -2
- package/lib/functions/secrets.js +21 -6
- package/lib/functionsShellCommandAction.js +2 -3
- package/lib/gcp/cloudfunctions.js +47 -31
- package/lib/gcp/cloudfunctionsv2.js +59 -31
- package/lib/gcp/cloudscheduler.js +5 -5
- package/lib/gcp/cloudtasks.js +6 -5
- package/lib/gcp/docker.js +2 -4
- package/lib/gcp/run.js +12 -18
- package/lib/gcp/secretManager.js +25 -12
- package/lib/gcp/storage.js +5 -3
- package/lib/getDefaultDatabaseInstance.js +1 -2
- package/lib/getDefaultHostingSite.js +1 -2
- package/lib/hosting/api.js +1 -2
- package/lib/hosting/cloudRunProxy.js +1 -2
- package/lib/hosting/config.js +10 -9
- package/lib/hosting/proxy.js +1 -2
- package/lib/hosting/runTags.js +3 -6
- package/lib/init/features/extensions/index.js +2 -3
- package/lib/init/features/firestore/index.js +1 -1
- package/lib/init/features/frameworks/index.js +5 -1
- package/lib/init/features/frameworks/repo.js +11 -4
- package/lib/init/features/functions/index.js +2 -3
- package/lib/init/features/hosting/index.js +1 -2
- package/lib/init/index.js +1 -2
- package/lib/localFunction.js +13 -14
- package/lib/management/apps.js +1 -1
- package/lib/management/database.js +1 -2
- package/lib/projectUtils.js +1 -1
- package/lib/prompt.js +2 -4
- package/lib/rc.js +3 -5
- package/lib/requireConfig.js +4 -6
- package/lib/rulesDeploy.js +2 -3
- package/lib/serve/functions.js +8 -1
- package/lib/serve/hosting.js +1 -1
- package/lib/track.js +15 -6
- package/lib/unzip.js +2 -3
- package/lib/utils.js +2 -2
- package/package.json +2 -2
|
@@ -6,12 +6,11 @@ const refs = require("../../extensions/refs");
|
|
|
6
6
|
const humanReadable = (dep) => `${clc.bold(dep.instanceId)} (${dep.ref ? `${refs.toExtensionVersionRef(dep.ref)}` : `Installed from local source`})`;
|
|
7
7
|
exports.humanReadable = humanReadable;
|
|
8
8
|
const humanReadableUpdate = (from, to) => {
|
|
9
|
-
var _a;
|
|
10
9
|
if (from.ref &&
|
|
11
10
|
to.ref &&
|
|
12
11
|
from.ref.publisherId === to.ref.publisherId &&
|
|
13
12
|
from.ref.extensionId === to.ref.extensionId) {
|
|
14
|
-
return `\t${clc.bold(from.instanceId)} (${refs.toExtensionVersionRef(from.ref)} => ${
|
|
13
|
+
return `\t${clc.bold(from.instanceId)} (${refs.toExtensionVersionRef(from.ref)} => ${to.ref?.version})`;
|
|
15
14
|
}
|
|
16
15
|
else {
|
|
17
16
|
const fromRef = from.ref
|
|
@@ -51,11 +51,10 @@ exports.getExtensionSpec = getExtensionSpec;
|
|
|
51
51
|
async function have(projectId) {
|
|
52
52
|
const instances = await extensionsApi.listInstances(projectId);
|
|
53
53
|
return instances.map((i) => {
|
|
54
|
-
var _a;
|
|
55
54
|
const dep = {
|
|
56
55
|
instanceId: i.name.split("/").pop(),
|
|
57
56
|
params: i.config.params,
|
|
58
|
-
systemParams:
|
|
57
|
+
systemParams: i.config.systemParams ?? {},
|
|
59
58
|
allowedEventTypes: i.config.allowedEventTypes,
|
|
60
59
|
eventarcChannel: i.config.eventarcChannel,
|
|
61
60
|
etag: i.etag,
|
|
@@ -129,17 +128,17 @@ async function want(args) {
|
|
|
129
128
|
exports.want = want;
|
|
130
129
|
async function resolveVersion(ref, extension) {
|
|
131
130
|
const extensionRef = refs.toExtensionRef(ref);
|
|
132
|
-
if (!ref.version &&
|
|
131
|
+
if (!ref.version && extension?.latestApprovedVersion) {
|
|
133
132
|
return extension.latestApprovedVersion;
|
|
134
133
|
}
|
|
135
134
|
if (ref.version === "latest-approved") {
|
|
136
|
-
if (!
|
|
135
|
+
if (!extension?.latestApprovedVersion) {
|
|
137
136
|
throw new error_1.FirebaseError(`${extensionRef} has not been published to Extensions Hub (https://extensions.dev). To install it, you must specify the version you want to install.`);
|
|
138
137
|
}
|
|
139
138
|
return extension.latestApprovedVersion;
|
|
140
139
|
}
|
|
141
140
|
if (!ref.version || ref.version === "latest") {
|
|
142
|
-
if (!
|
|
141
|
+
if (!extension?.latestVersion) {
|
|
143
142
|
throw new error_1.FirebaseError(`${extensionRef} has no stable non-deprecated versions. If you wish to install a prerelease version, you must specify the version you want to install.`);
|
|
144
143
|
}
|
|
145
144
|
return extension.latestVersion;
|
|
@@ -17,7 +17,6 @@ const etags_1 = require("../../extensions/etags");
|
|
|
17
17
|
const v2FunctionHelper_1 = require("./v2FunctionHelper");
|
|
18
18
|
const tos_1 = require("../../extensions/tos");
|
|
19
19
|
async function prepare(context, options, payload) {
|
|
20
|
-
var _a, _b;
|
|
21
20
|
context.extensionsStartTime = Date.now();
|
|
22
21
|
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
23
22
|
const projectNumber = await (0, projectUtils_1.needProjectNumber)(options);
|
|
@@ -44,18 +43,18 @@ async function prepare(context, options, payload) {
|
|
|
44
43
|
throw new error_1.FirebaseError("Deployment cancelled");
|
|
45
44
|
}
|
|
46
45
|
}
|
|
47
|
-
const usingSecrets = await Promise.all(
|
|
46
|
+
const usingSecrets = await Promise.all(context.want?.map(secrets_1.checkSpecForSecrets));
|
|
48
47
|
if (usingSecrets.some((i) => i)) {
|
|
49
48
|
await (0, secretsUtils_1.ensureSecretManagerApiEnabled)(options);
|
|
50
49
|
}
|
|
51
|
-
const usingV2Functions = await Promise.all(
|
|
50
|
+
const usingV2Functions = await Promise.all(context.want?.map(v2FunctionHelper_1.checkSpecForV2Functions));
|
|
52
51
|
if (usingV2Functions) {
|
|
53
52
|
await (0, v2FunctionHelper_1.ensureNecessaryV2ApisAndRoles)(options);
|
|
54
53
|
}
|
|
55
|
-
payload.instancesToCreate = context.want.filter((i) =>
|
|
56
|
-
payload.instancesToConfigure = context.want.filter((i) =>
|
|
57
|
-
payload.instancesToUpdate = context.want.filter((i) =>
|
|
58
|
-
payload.instancesToDelete = context.have.filter((i) =>
|
|
54
|
+
payload.instancesToCreate = context.want.filter((i) => !context.have?.some(matchesInstanceId(i)));
|
|
55
|
+
payload.instancesToConfigure = context.want.filter((i) => context.have?.some(isConfigure(i)));
|
|
56
|
+
payload.instancesToUpdate = context.want.filter((i) => context.have?.some(isUpdate(i)));
|
|
57
|
+
payload.instancesToDelete = context.have.filter((i) => !context.want?.some(matchesInstanceId(i)));
|
|
59
58
|
if (await (0, warnings_1.displayWarningsForDeploy)(payload.instancesToCreate)) {
|
|
60
59
|
if (!(await prompt.confirm({
|
|
61
60
|
message: `Do you wish to continue deploying these extension instances?`,
|
|
@@ -10,7 +10,6 @@ const projectUtils_1 = require("../../projectUtils");
|
|
|
10
10
|
const etags_1 = require("../../extensions/etags");
|
|
11
11
|
const track_1 = require("../../track");
|
|
12
12
|
async function release(context, options, payload) {
|
|
13
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
14
13
|
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
15
14
|
const errorHandler = new errors_1.ErrorHandler();
|
|
16
15
|
const deploymentQueue = new queue_1.default({
|
|
@@ -18,19 +17,19 @@ async function release(context, options, payload) {
|
|
|
18
17
|
concurrency: 5,
|
|
19
18
|
handler: tasks.extensionsDeploymentHandler(errorHandler),
|
|
20
19
|
});
|
|
21
|
-
for (const creation of
|
|
20
|
+
for (const creation of payload.instancesToCreate ?? []) {
|
|
22
21
|
const task = tasks.createExtensionInstanceTask(projectId, creation);
|
|
23
22
|
void deploymentQueue.run(task);
|
|
24
23
|
}
|
|
25
|
-
for (const update of
|
|
24
|
+
for (const update of payload.instancesToUpdate ?? []) {
|
|
26
25
|
const task = tasks.updateExtensionInstanceTask(projectId, update);
|
|
27
26
|
void deploymentQueue.run(task);
|
|
28
27
|
}
|
|
29
|
-
for (const update of
|
|
28
|
+
for (const update of payload.instancesToConfigure ?? []) {
|
|
30
29
|
const task = tasks.configureExtensionInstanceTask(projectId, update);
|
|
31
30
|
void deploymentQueue.run(task);
|
|
32
31
|
}
|
|
33
|
-
for (const deletion of
|
|
32
|
+
for (const deletion of payload.instancesToDelete ?? []) {
|
|
34
33
|
const task = tasks.deleteExtensionInstanceTask(projectId, deletion);
|
|
35
34
|
void deploymentQueue.run(task);
|
|
36
35
|
}
|
|
@@ -40,11 +39,11 @@ async function release(context, options, payload) {
|
|
|
40
39
|
await deploymentPromise;
|
|
41
40
|
const duration = context.extensionsStartTime ? Date.now() - context.extensionsStartTime : 1;
|
|
42
41
|
await (0, track_1.trackGA4)("extensions_deploy", {
|
|
43
|
-
extension_instance_created:
|
|
44
|
-
extension_instance_updated:
|
|
45
|
-
extension_instance_configured:
|
|
46
|
-
extension_instance_deleted:
|
|
47
|
-
errors:
|
|
42
|
+
extension_instance_created: payload.instancesToCreate?.length ?? 0,
|
|
43
|
+
extension_instance_updated: payload.instancesToUpdate?.length ?? 0,
|
|
44
|
+
extension_instance_configured: payload.instancesToConfigure?.length ?? 0,
|
|
45
|
+
extension_instance_deleted: payload.instancesToDelete?.length ?? 0,
|
|
46
|
+
errors: errorHandler.errors.length ?? 0,
|
|
48
47
|
interactive: options.nonInteractive ? "false" : "true",
|
|
49
48
|
}, duration);
|
|
50
49
|
const newHave = await planner.have(projectId);
|
|
@@ -11,14 +11,13 @@ const error_1 = require("../../error");
|
|
|
11
11
|
const logger_1 = require("../../logger");
|
|
12
12
|
const utils_1 = require("../../utils");
|
|
13
13
|
async function handleSecretParams(payload, have, nonInteractive) {
|
|
14
|
-
|
|
15
|
-
for (const i of (_a = payload.instancesToCreate) !== null && _a !== void 0 ? _a : []) {
|
|
14
|
+
for (const i of payload.instancesToCreate ?? []) {
|
|
16
15
|
if (await checkSpecForSecrets(i)) {
|
|
17
16
|
(0, utils_1.logLabeledBullet)("extensions", `Verifying secret params for ${clc.bold(i.instanceId)}`);
|
|
18
17
|
await handleSecretsCreateInstance(i, nonInteractive);
|
|
19
18
|
}
|
|
20
19
|
}
|
|
21
|
-
const updates = [...(
|
|
20
|
+
const updates = [...(payload.instancesToUpdate ?? []), ...(payload.instancesToConfigure ?? [])];
|
|
22
21
|
for (const i of updates) {
|
|
23
22
|
if (await checkSpecForSecrets(i)) {
|
|
24
23
|
(0, utils_1.logLabeledBullet)("extensions", `Verifying secret params for ${clc.bold(i.instanceId)}`);
|
|
@@ -49,8 +48,8 @@ async function handleSecretsUpdateInstance(i, prevSpec, nonInteractive) {
|
|
|
49
48
|
const secretParams = secretsInSpec(extensionVersion.spec);
|
|
50
49
|
for (const s of secretParams) {
|
|
51
50
|
const prevParam = prevExtensionVersion.spec.params.find((p) => p.param === s.param);
|
|
52
|
-
if (
|
|
53
|
-
await handleSecretParamForUpdate(s, i, prevSpec.params[prevParam
|
|
51
|
+
if (prevParam?.type === types_1.ParamType.SECRET && prevSpec.params[prevParam?.param]) {
|
|
52
|
+
await handleSecretParamForUpdate(s, i, prevSpec.params[prevParam?.param], nonInteractive);
|
|
54
53
|
}
|
|
55
54
|
else {
|
|
56
55
|
await handleSecretParamForCreate(s, i, nonInteractive);
|
|
@@ -58,7 +57,6 @@ async function handleSecretsUpdateInstance(i, prevSpec, nonInteractive) {
|
|
|
58
57
|
}
|
|
59
58
|
}
|
|
60
59
|
async function handleSecretParamForCreate(secretParam, i, nonInteractive) {
|
|
61
|
-
var _a;
|
|
62
60
|
const providedValue = i.params[secretParam.param];
|
|
63
61
|
if (!providedValue) {
|
|
64
62
|
return;
|
|
@@ -83,8 +81,8 @@ async function handleSecretParamForCreate(secretParam, i, nonInteractive) {
|
|
|
83
81
|
`projects/${projectId}/secrets/${secretName} exists, but version ${version} does not. ` +
|
|
84
82
|
`See more information about this secret at ${secretManager.secretManagerConsoleUri(projectId)}`);
|
|
85
83
|
}
|
|
86
|
-
if (!!
|
|
87
|
-
!!
|
|
84
|
+
if (!!secretInfo?.secret?.labels &&
|
|
85
|
+
!!secretInfo?.secret.labels[secretUtils.SECRET_LABEL] &&
|
|
88
86
|
secretInfo.secret.labels[secretUtils.SECRET_LABEL] !== i.instanceId) {
|
|
89
87
|
throw new error_1.FirebaseError(`${clc.bold(i.instanceId)}: Found '${providedValue}' for secret param ${secretParam.param}. ` +
|
|
90
88
|
`projects/${projectId}/secrets/${secretName} is managed by a different extension instance (${secretInfo.secret.labels[secretUtils.SECRET_LABEL]}), so reusing it here can lead to unexpected behavior. ` +
|
|
@@ -10,7 +10,6 @@ const utils = require("../../utils");
|
|
|
10
10
|
const isRetryable = (err) => err.status === 429 || err.status === 409;
|
|
11
11
|
function extensionsDeploymentHandler(errorHandler) {
|
|
12
12
|
return async (task) => {
|
|
13
|
-
var _a, _b, _c, _d;
|
|
14
13
|
let result;
|
|
15
14
|
try {
|
|
16
15
|
result = await task.run();
|
|
@@ -19,7 +18,7 @@ function extensionsDeploymentHandler(errorHandler) {
|
|
|
19
18
|
if (isRetryable(err)) {
|
|
20
19
|
throw err;
|
|
21
20
|
}
|
|
22
|
-
errorHandler.record(task.spec.instanceId, task.type,
|
|
21
|
+
errorHandler.record(task.spec.instanceId, task.type, err.context?.body?.error?.message ?? err);
|
|
23
22
|
}
|
|
24
23
|
return result;
|
|
25
24
|
};
|
|
@@ -6,19 +6,17 @@ const logger_1 = require("../../logger");
|
|
|
6
6
|
const utils = require("../../utils");
|
|
7
7
|
const rulesDeploy_1 = require("../../rulesDeploy");
|
|
8
8
|
async function deployRules(context) {
|
|
9
|
-
|
|
10
|
-
const rulesDeploy = (_a = context === null || context === void 0 ? void 0 : context.firestore) === null || _a === void 0 ? void 0 : _a.rulesDeploy;
|
|
9
|
+
const rulesDeploy = context?.firestore?.rulesDeploy;
|
|
11
10
|
if (!context.firestoreRules || !rulesDeploy) {
|
|
12
11
|
return;
|
|
13
12
|
}
|
|
14
13
|
await rulesDeploy.createRulesets(rulesDeploy_1.RulesetServiceType.CLOUD_FIRESTORE);
|
|
15
14
|
}
|
|
16
15
|
async function deployIndexes(context, options) {
|
|
17
|
-
var _a;
|
|
18
16
|
if (!context.firestoreIndexes) {
|
|
19
17
|
return;
|
|
20
18
|
}
|
|
21
|
-
const indexesContext =
|
|
19
|
+
const indexesContext = context?.firestore?.indexes;
|
|
22
20
|
utils.logBullet(clc.bold(clc.cyan("firestore: ")) + "deploying indexes...");
|
|
23
21
|
const firestoreIndexes = new api_1.FirestoreApi();
|
|
24
22
|
await Promise.all(indexesContext.map(async (indexContext) => {
|
|
@@ -3,12 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const rulesDeploy_1 = require("../../rulesDeploy");
|
|
4
4
|
const logger_1 = require("../../logger");
|
|
5
5
|
async function default_1(context, options) {
|
|
6
|
-
|
|
7
|
-
const rulesDeploy = (_a = context === null || context === void 0 ? void 0 : context.firestore) === null || _a === void 0 ? void 0 : _a.rulesDeploy;
|
|
6
|
+
const rulesDeploy = context?.firestore?.rulesDeploy;
|
|
8
7
|
if (!context.firestoreRules || !rulesDeploy) {
|
|
9
8
|
return;
|
|
10
9
|
}
|
|
11
|
-
const rulesContext =
|
|
10
|
+
const rulesContext = context?.firestore?.rules;
|
|
12
11
|
await Promise.all(rulesContext.map(async (ruleContext) => {
|
|
13
12
|
const databaseId = ruleContext.databaseId;
|
|
14
13
|
const rulesFile = ruleContext.rulesFile;
|
|
@@ -88,8 +88,7 @@ exports.DEFAULT_MEMORY = 256;
|
|
|
88
88
|
exports.MIN_CPU_FOR_CONCURRENCY = 1;
|
|
89
89
|
exports.SCHEDULED_FUNCTION_LABEL = Object.freeze({ deployment: "firebase-schedule" });
|
|
90
90
|
function secretVersionName(s) {
|
|
91
|
-
|
|
92
|
-
return `projects/${s.projectId}/secrets/${s.secret}/versions/${(_a = s.version) !== null && _a !== void 0 ? _a : "latest"}`;
|
|
91
|
+
return `projects/${s.projectId}/secrets/${s.secret}/versions/${s.version ?? "latest"}`;
|
|
93
92
|
}
|
|
94
93
|
exports.secretVersionName = secretVersionName;
|
|
95
94
|
exports.AllFunctionsPlatforms = ["gcfv1", "gcfv2"];
|
|
@@ -126,7 +125,7 @@ function empty() {
|
|
|
126
125
|
}
|
|
127
126
|
exports.empty = empty;
|
|
128
127
|
function of(...endpoints) {
|
|
129
|
-
const bkend =
|
|
128
|
+
const bkend = { ...empty() };
|
|
130
129
|
for (const endpoint of endpoints) {
|
|
131
130
|
bkend.endpoints[endpoint.region] = bkend.endpoints[endpoint.region] || {};
|
|
132
131
|
if (bkend.endpoints[endpoint.region][endpoint.id]) {
|
|
@@ -148,7 +147,7 @@ function merge(...backends) {
|
|
|
148
147
|
}
|
|
149
148
|
apiToReasons[api] = reasons;
|
|
150
149
|
}
|
|
151
|
-
merged.environmentVariables =
|
|
150
|
+
merged.environmentVariables = { ...merged.environmentVariables, ...b.environmentVariables };
|
|
152
151
|
}
|
|
153
152
|
for (const [api, reasons] of Object.entries(apiToReasons)) {
|
|
154
153
|
merged.requiredAPIs.push({ api, reason: Array.from(reasons).join(" ") });
|
|
@@ -176,9 +175,10 @@ async function existingBackend(context, forceRefresh) {
|
|
|
176
175
|
}
|
|
177
176
|
exports.existingBackend = existingBackend;
|
|
178
177
|
async function loadExistingBackend(ctx) {
|
|
179
|
-
var _a;
|
|
180
178
|
ctx.loadedExistingBackend = true;
|
|
181
|
-
ctx.existingBackend =
|
|
179
|
+
ctx.existingBackend = {
|
|
180
|
+
...empty(),
|
|
181
|
+
};
|
|
182
182
|
ctx.unreachableRegions = {
|
|
183
183
|
gcfV1: [],
|
|
184
184
|
gcfV2: [],
|
|
@@ -203,14 +203,13 @@ async function loadExistingBackend(ctx) {
|
|
|
203
203
|
ctx.unreachableRegions.gcfV2 = gcfV2Results.unreachable;
|
|
204
204
|
}
|
|
205
205
|
catch (err) {
|
|
206
|
-
if (err.status === 404 &&
|
|
206
|
+
if (err.status === 404 && err.message?.toLowerCase().includes("method not found")) {
|
|
207
207
|
return;
|
|
208
208
|
}
|
|
209
209
|
throw err;
|
|
210
210
|
}
|
|
211
211
|
}
|
|
212
212
|
async function checkAvailability(context, want) {
|
|
213
|
-
var _a, _b, _c, _d;
|
|
214
213
|
if (!context.loadedExistingBackend) {
|
|
215
214
|
await loadExistingBackend(context);
|
|
216
215
|
}
|
|
@@ -224,24 +223,24 @@ async function checkAvailability(context, want) {
|
|
|
224
223
|
gcfV2Regions.add(ep.region);
|
|
225
224
|
}
|
|
226
225
|
}
|
|
227
|
-
const neededUnreachableV1 =
|
|
228
|
-
const neededUnreachableV2 =
|
|
229
|
-
if (neededUnreachableV1
|
|
226
|
+
const neededUnreachableV1 = context.unreachableRegions?.gcfV1.filter((region) => gcfV1Regions.has(region));
|
|
227
|
+
const neededUnreachableV2 = context.unreachableRegions?.gcfV2.filter((region) => gcfV2Regions.has(region));
|
|
228
|
+
if (neededUnreachableV1?.length) {
|
|
230
229
|
throw new error_1.FirebaseError("The following Cloud Functions regions are currently unreachable:\n\t" +
|
|
231
230
|
neededUnreachableV1.join("\n\t") +
|
|
232
231
|
"\nThis deployment contains functions in those regions. Please try again in a few minutes, or exclude these regions from your deployment.");
|
|
233
232
|
}
|
|
234
|
-
if (neededUnreachableV2
|
|
233
|
+
if (neededUnreachableV2?.length) {
|
|
235
234
|
throw new error_1.FirebaseError("The following Cloud Functions V2 regions are currently unreachable:\n\t" +
|
|
236
235
|
neededUnreachableV2.join("\n\t") +
|
|
237
236
|
"\nThis deployment contains functions in those regions. Please try again in a few minutes, or exclude these regions from your deployment.");
|
|
238
237
|
}
|
|
239
|
-
if (
|
|
238
|
+
if (context.unreachableRegions?.gcfV1.length) {
|
|
240
239
|
utils.logLabeledWarning("functions", "The following Cloud Functions regions are currently unreachable:\n" +
|
|
241
240
|
context.unreachableRegions.gcfV1.join("\n") +
|
|
242
241
|
"\nCloud Functions in these regions won't be deleted.");
|
|
243
242
|
}
|
|
244
|
-
if (
|
|
243
|
+
if (context.unreachableRegions?.gcfV2.length) {
|
|
245
244
|
utils.logLabeledWarning("functions", "The following Cloud Functions V2 regions are currently unreachable:\n" +
|
|
246
245
|
context.unreachableRegions.gcfV2.join("\n") +
|
|
247
246
|
"\nCloud Functions in these regions won't be deleted.");
|
|
@@ -272,7 +271,10 @@ function findEndpoint(backend, predicate) {
|
|
|
272
271
|
}
|
|
273
272
|
exports.findEndpoint = findEndpoint;
|
|
274
273
|
function matchingBackend(backend, predicate) {
|
|
275
|
-
const filtered =
|
|
274
|
+
const filtered = {
|
|
275
|
+
...backend,
|
|
276
|
+
endpoints: {},
|
|
277
|
+
};
|
|
276
278
|
for (const endpoint of allEndpoints(backend)) {
|
|
277
279
|
if (!predicate(endpoint)) {
|
|
278
280
|
continue;
|
|
@@ -198,7 +198,15 @@ function toBackend(build, paramValues) {
|
|
|
198
198
|
if (typeof bdEndpoint.platform === "undefined") {
|
|
199
199
|
throw new error_1.FirebaseError("platform can't be undefined");
|
|
200
200
|
}
|
|
201
|
-
const bkEndpoint =
|
|
201
|
+
const bkEndpoint = {
|
|
202
|
+
id: endpointId,
|
|
203
|
+
project: bdEndpoint.project,
|
|
204
|
+
region: region,
|
|
205
|
+
entryPoint: bdEndpoint.entryPoint,
|
|
206
|
+
platform: bdEndpoint.platform,
|
|
207
|
+
runtime: bdEndpoint.runtime,
|
|
208
|
+
...trigger,
|
|
209
|
+
};
|
|
202
210
|
proto.copyIfPresent(bkEndpoint, bdEndpoint, "environmentVariables", "labels", "secretEnvironmentVariables");
|
|
203
211
|
proto.convertIfPresent(bkEndpoint, bdEndpoint, "ingressSettings", (from) => {
|
|
204
212
|
if (from !== null && !backend.AllIngressSettings.includes(from)) {
|
|
@@ -4,11 +4,10 @@ exports.applyBackendHashToBackends = void 0;
|
|
|
4
4
|
const backend_1 = require("../backend");
|
|
5
5
|
const hash_1 = require("./hash");
|
|
6
6
|
function applyBackendHashToBackends(wantBackends, context) {
|
|
7
|
-
var _a;
|
|
8
7
|
for (const [codebase, wantBackend] of Object.entries(wantBackends)) {
|
|
9
|
-
const source =
|
|
8
|
+
const source = context?.sources?.[codebase];
|
|
10
9
|
const envHash = (0, hash_1.getEnvironmentVariablesHash)(wantBackend);
|
|
11
|
-
applyBackendHashToEndpoints(wantBackend, envHash, source
|
|
10
|
+
applyBackendHashToEndpoints(wantBackend, envHash, source?.functionsSourceV1Hash, source?.functionsSourceV2Hash);
|
|
12
11
|
}
|
|
13
12
|
}
|
|
14
13
|
exports.applyBackendHashToBackends = applyBackendHashToBackends;
|
|
@@ -104,14 +104,22 @@ class ArtifactRegistryCleaner {
|
|
|
104
104
|
if (op.done) {
|
|
105
105
|
return;
|
|
106
106
|
}
|
|
107
|
-
await poller.pollOperation(
|
|
107
|
+
await poller.pollOperation({
|
|
108
|
+
...ArtifactRegistryCleaner.POLLER_OPTIONS,
|
|
109
|
+
pollerName: `cleanup-${func.region}-${func.id}`,
|
|
110
|
+
operationResourceName: op.name,
|
|
111
|
+
});
|
|
108
112
|
}
|
|
109
113
|
async cleanupFunctionCache(func) {
|
|
110
114
|
const op = await artifactregistry.deletePackage(`${ArtifactRegistryCleaner.packagePath(func)}%2Fcache`);
|
|
111
115
|
if (op.done) {
|
|
112
116
|
return;
|
|
113
117
|
}
|
|
114
|
-
await poller.pollOperation(
|
|
118
|
+
await poller.pollOperation({
|
|
119
|
+
...ArtifactRegistryCleaner.POLLER_OPTIONS,
|
|
120
|
+
pollerName: `cleanup-cache-${func.region}-${func.id}`,
|
|
121
|
+
operationResourceName: op.name,
|
|
122
|
+
});
|
|
115
123
|
}
|
|
116
124
|
}
|
|
117
125
|
exports.ArtifactRegistryCleaner = ArtifactRegistryCleaner;
|
|
@@ -156,7 +164,7 @@ class ContainerRegistryCleaner {
|
|
|
156
164
|
await Promise.all(loadUuidTags);
|
|
157
165
|
const extractFunction = /^(.*)_version-\d+$/;
|
|
158
166
|
const entry = Object.entries(uuidTags).find(([, tags]) => {
|
|
159
|
-
return tags.find((tag) =>
|
|
167
|
+
return tags.find((tag) => extractFunction.exec(tag)?.[1] === func.id);
|
|
160
168
|
});
|
|
161
169
|
if (!entry) {
|
|
162
170
|
logger_1.logger.debug("Could not find image for function", backend.functionName(func));
|
|
@@ -44,8 +44,7 @@ async function uploadSourceV2(projectId, source, wantBackend) {
|
|
|
44
44
|
return res.storageSource;
|
|
45
45
|
}
|
|
46
46
|
async function uploadCodebase(context, codebase, wantBackend) {
|
|
47
|
-
|
|
48
|
-
const source = (_a = context.sources) === null || _a === void 0 ? void 0 : _a[codebase];
|
|
47
|
+
const source = context.sources?.[codebase];
|
|
49
48
|
if (!source || (!source.functionsSourceV1 && !source.functionsSourceV2)) {
|
|
50
49
|
return;
|
|
51
50
|
}
|
|
@@ -49,8 +49,7 @@ ${FAQ_URL}
|
|
|
49
49
|
`);
|
|
50
50
|
}
|
|
51
51
|
function isPermissionError(e) {
|
|
52
|
-
|
|
53
|
-
return ((_c = (_b = (_a = e.context) === null || _a === void 0 ? void 0 : _a.body) === null || _b === void 0 ? void 0 : _b.error) === null || _c === void 0 ? void 0 : _c.status) === "PERMISSION_DENIED";
|
|
52
|
+
return e.context?.body?.error?.status === "PERMISSION_DENIED";
|
|
54
53
|
}
|
|
55
54
|
async function cloudBuildEnabled(projectId) {
|
|
56
55
|
try {
|
|
@@ -80,7 +79,6 @@ async function secretsToServiceAccounts(b) {
|
|
|
80
79
|
return secretsToSa;
|
|
81
80
|
}
|
|
82
81
|
async function secretAccess(projectId, wantBackend, haveBackend) {
|
|
83
|
-
var _a, _b;
|
|
84
82
|
const ensureAccess = async (secret, serviceAccounts) => {
|
|
85
83
|
(0, utils_1.logLabeledBullet)("functions", `ensuring ${clc.bold(serviceAccounts.join(", "))} access to secret ${clc.bold(secret)}.`);
|
|
86
84
|
await (0, secretManager_1.ensureServiceAgentRole)({ name: secret, projectId }, serviceAccounts, "roles/secretmanager.secretAccessor");
|
|
@@ -90,9 +88,9 @@ async function secretAccess(projectId, wantBackend, haveBackend) {
|
|
|
90
88
|
const haveSecrets = await secretsToServiceAccounts(haveBackend);
|
|
91
89
|
for (const [secret, serviceAccounts] of Object.entries(haveSecrets)) {
|
|
92
90
|
for (const serviceAccount of serviceAccounts) {
|
|
93
|
-
|
|
91
|
+
wantSecrets[secret]?.delete(serviceAccount);
|
|
94
92
|
}
|
|
95
|
-
if (
|
|
93
|
+
if (wantSecrets[secret]?.size === 0) {
|
|
96
94
|
delete wantSecrets[secret];
|
|
97
95
|
}
|
|
98
96
|
}
|
|
@@ -27,7 +27,6 @@ const backend_1 = require("./backend");
|
|
|
27
27
|
const functional_1 = require("../../functional");
|
|
28
28
|
exports.EVENTARC_SOURCE_ENV = "EVENTARC_CLOUD_EVENT_SOURCE";
|
|
29
29
|
async function prepare(context, options, payload) {
|
|
30
|
-
var _a, _b;
|
|
31
30
|
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
32
31
|
const projectNumber = await (0, projectUtils_1.needProjectNumber)(options);
|
|
33
32
|
context.config = (0, projectConfig_1.normalizeAndValidate)(options.config.src.functions);
|
|
@@ -49,7 +48,7 @@ async function prepare(context, options, payload) {
|
|
|
49
48
|
context.firebaseConfig = firebaseConfig;
|
|
50
49
|
let runtimeConfig = { firebase: firebaseConfig };
|
|
51
50
|
if (checkAPIsEnabled[1]) {
|
|
52
|
-
runtimeConfig =
|
|
51
|
+
runtimeConfig = { ...runtimeConfig, ...(await (0, prepareFunctionsUpload_1.getFunctionsConfig)(projectId)) };
|
|
53
52
|
}
|
|
54
53
|
context.codebaseDeployEvents = {};
|
|
55
54
|
const wantBuilds = await loadCodebases(context.config, options, firebaseConfig, runtimeConfig, context.filters);
|
|
@@ -64,13 +63,13 @@ async function prepare(context, options, payload) {
|
|
|
64
63
|
projectAlias: options.projectAlias,
|
|
65
64
|
};
|
|
66
65
|
const userEnvs = functionsEnv.loadUserEnvs(userEnvOpt);
|
|
67
|
-
const envs =
|
|
66
|
+
const envs = { ...userEnvs, ...firebaseEnvs };
|
|
68
67
|
const { backend: wantBackend, envs: resolvedEnvs } = await build.resolveBackend(wantBuild, firebaseConfig, userEnvOpt, userEnvs, options.nonInteractive);
|
|
69
68
|
let hasEnvsFromParams = false;
|
|
70
69
|
wantBackend.environmentVariables = envs;
|
|
71
70
|
for (const envName of Object.keys(resolvedEnvs)) {
|
|
72
|
-
const isList =
|
|
73
|
-
const envValue =
|
|
71
|
+
const isList = resolvedEnvs[envName]?.legalList;
|
|
72
|
+
const envValue = resolvedEnvs[envName]?.toSDK();
|
|
74
73
|
if (envValue &&
|
|
75
74
|
!resolvedEnvs[envName].internal &&
|
|
76
75
|
(!Object.prototype.hasOwnProperty.call(wantBackend.environmentVariables, envName) || isList)) {
|
|
@@ -79,7 +78,7 @@ async function prepare(context, options, payload) {
|
|
|
79
78
|
}
|
|
80
79
|
}
|
|
81
80
|
for (const endpoint of backend.allEndpoints(wantBackend)) {
|
|
82
|
-
endpoint.environmentVariables =
|
|
81
|
+
endpoint.environmentVariables = { ...wantBackend.environmentVariables } || {};
|
|
83
82
|
let resource;
|
|
84
83
|
if (endpoint.platform === "gcfv1") {
|
|
85
84
|
resource = `projects/${endpoint.project}/locations/${endpoint.region}/functions/${endpoint.id}`;
|
|
@@ -128,13 +127,13 @@ async function prepare(context, options, payload) {
|
|
|
128
127
|
}
|
|
129
128
|
if (backend.someEndpoint(wantBackend, (e) => e.platform === "gcfv2")) {
|
|
130
129
|
const packagedSource = await (0, prepareFunctionsUpload_1.prepareFunctionsUpload)(sourceDir, config);
|
|
131
|
-
source.functionsSourceV2 = packagedSource
|
|
132
|
-
source.functionsSourceV2Hash = packagedSource
|
|
130
|
+
source.functionsSourceV2 = packagedSource?.pathToSource;
|
|
131
|
+
source.functionsSourceV2Hash = packagedSource?.hash;
|
|
133
132
|
}
|
|
134
133
|
if (backend.someEndpoint(wantBackend, (e) => e.platform === "gcfv1")) {
|
|
135
134
|
const packagedSource = await (0, prepareFunctionsUpload_1.prepareFunctionsUpload)(sourceDir, config, runtimeConfig);
|
|
136
|
-
source.functionsSourceV1 = packagedSource
|
|
137
|
-
source.functionsSourceV1Hash = packagedSource
|
|
135
|
+
source.functionsSourceV1 = packagedSource?.pathToSource;
|
|
136
|
+
source.functionsSourceV1Hash = packagedSource?.hash;
|
|
138
137
|
}
|
|
139
138
|
context.sources[codebase] = source;
|
|
140
139
|
}
|
|
@@ -187,14 +186,16 @@ async function prepare(context, options, payload) {
|
|
|
187
186
|
}
|
|
188
187
|
exports.prepare = prepare;
|
|
189
188
|
function inferDetailsFromExisting(want, have, usedDotenv) {
|
|
190
|
-
var _a;
|
|
191
189
|
for (const wantE of backend.allEndpoints(want)) {
|
|
192
|
-
const haveE =
|
|
190
|
+
const haveE = have.endpoints[wantE.region]?.[wantE.id];
|
|
193
191
|
if (!haveE) {
|
|
194
192
|
continue;
|
|
195
193
|
}
|
|
196
194
|
if (!usedDotenv) {
|
|
197
|
-
wantE.environmentVariables =
|
|
195
|
+
wantE.environmentVariables = {
|
|
196
|
+
...haveE.environmentVariables,
|
|
197
|
+
...wantE.environmentVariables,
|
|
198
|
+
};
|
|
198
199
|
}
|
|
199
200
|
if (typeof wantE.availableMemoryMb === "undefined" && haveE.availableMemoryMb) {
|
|
200
201
|
wantE.availableMemoryMb = haveE.availableMemoryMb;
|
|
@@ -229,7 +230,6 @@ function updateEndpointTargetedStatus(wantBackends, endpointFilters) {
|
|
|
229
230
|
}
|
|
230
231
|
exports.updateEndpointTargetedStatus = updateEndpointTargetedStatus;
|
|
231
232
|
function inferBlockingDetails(want) {
|
|
232
|
-
var _a, _b, _c;
|
|
233
233
|
const authBlockingEndpoints = backend
|
|
234
234
|
.allEndpoints(want)
|
|
235
235
|
.filter((ep) => backend.isBlockingTriggered(ep) &&
|
|
@@ -241,9 +241,9 @@ function inferBlockingDetails(want) {
|
|
|
241
241
|
let idToken = false;
|
|
242
242
|
let refreshToken = false;
|
|
243
243
|
for (const blockingEp of authBlockingEndpoints) {
|
|
244
|
-
accessToken || (accessToken = !!
|
|
245
|
-
idToken || (idToken = !!
|
|
246
|
-
refreshToken || (refreshToken = !!
|
|
244
|
+
accessToken || (accessToken = !!blockingEp.blockingTrigger.options?.accessToken);
|
|
245
|
+
idToken || (idToken = !!blockingEp.blockingTrigger.options?.idToken);
|
|
246
|
+
refreshToken || (refreshToken = !!blockingEp.blockingTrigger.options?.refreshToken);
|
|
247
247
|
}
|
|
248
248
|
for (const blockingEp of authBlockingEndpoints) {
|
|
249
249
|
if (!blockingEp.blockingTrigger.options) {
|
|
@@ -296,7 +296,10 @@ async function loadCodebases(config, options, firebaseConfig, runtimeConfig, fil
|
|
|
296
296
|
await runtimeDelegate.build();
|
|
297
297
|
const firebaseEnvs = functionsEnv.loadFirebaseEnvs(firebaseConfig, projectId);
|
|
298
298
|
(0, utils_1.logLabeledBullet)("functions", `Loading and analyzing source code for codebase ${codebase} to determine what to deploy`);
|
|
299
|
-
wantBuilds[codebase] = await runtimeDelegate.discoverBuild(runtimeConfig,
|
|
299
|
+
wantBuilds[codebase] = await runtimeDelegate.discoverBuild(runtimeConfig, {
|
|
300
|
+
...firebaseEnvs,
|
|
301
|
+
GOOGLE_CLOUD_QUOTA_PROJECT: projectId,
|
|
302
|
+
});
|
|
300
303
|
wantBuilds[codebase].runtime = codebaseConfig.runtime;
|
|
301
304
|
}
|
|
302
305
|
return wantBuilds;
|
|
@@ -15,13 +15,12 @@ const utils = require("../../utils");
|
|
|
15
15
|
const hash_1 = require("./cache/hash");
|
|
16
16
|
const CONFIG_DEST_FILE = ".runtimeconfig.json";
|
|
17
17
|
async function getFunctionsConfig(projectId) {
|
|
18
|
-
var _a, _b;
|
|
19
18
|
try {
|
|
20
19
|
return await functionsConfig.materializeAll(projectId);
|
|
21
20
|
}
|
|
22
21
|
catch (err) {
|
|
23
22
|
logger_1.logger.debug(err);
|
|
24
|
-
let errorCode =
|
|
23
|
+
let errorCode = err?.context?.response?.statusCode;
|
|
25
24
|
if (!errorCode) {
|
|
26
25
|
logger_1.logger.debug("Got unexpected error from Runtime Config; it has no status code:", err);
|
|
27
26
|
errorCode = 500;
|
|
@@ -92,12 +91,19 @@ async function packageSource(sourceDir, config, runtimeConfig) {
|
|
|
92
91
|
return { pathToSource: tmpFile, hash };
|
|
93
92
|
}
|
|
94
93
|
async function prepareFunctionsUpload(sourceDir, config, runtimeConfig) {
|
|
94
|
+
utils.logLabeledBullet("functions", `+++ Prepare functions for upload`);
|
|
95
95
|
if (config.isolate === true) {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
96
|
+
utils.logLabeledBullet("functions", `+++ Start isolating the current directory...`);
|
|
97
|
+
try {
|
|
98
|
+
const { isolate } = await Promise.resolve().then(() => require("isolate-package"));
|
|
99
|
+
const isolateDir = await isolate();
|
|
100
|
+
utils.logLabeledBullet("functions", `+++ Finished isolating at ${clc.bold(isolateDir)}`);
|
|
101
|
+
return packageSource(isolateDir, config, runtimeConfig);
|
|
102
|
+
}
|
|
103
|
+
catch (err) {
|
|
104
|
+
utils.logLabeledBullet("functions", `+++ Failed to isolate: ${err.message}`);
|
|
105
|
+
throw err;
|
|
106
|
+
}
|
|
101
107
|
}
|
|
102
108
|
else {
|
|
103
109
|
return packageSource(sourceDir, config, runtimeConfig);
|
|
@@ -17,8 +17,7 @@ async function promptForFailurePolicies(options, want, have) {
|
|
|
17
17
|
return;
|
|
18
18
|
}
|
|
19
19
|
const newRetryEndpoints = retryEndpoints.filter((endpoint) => {
|
|
20
|
-
|
|
21
|
-
const existing = (_a = have.endpoints[endpoint.region]) === null || _a === void 0 ? void 0 : _a[endpoint.id];
|
|
20
|
+
const existing = have.endpoints[endpoint.region]?.[endpoint.id];
|
|
22
21
|
return !(existing && backend.isEventTriggered(existing) && existing.eventTrigger.retry);
|
|
23
22
|
});
|
|
24
23
|
if (newRetryEndpoints.length === 0) {
|
|
@@ -90,12 +89,11 @@ async function promptForMinInstances(options, want, have) {
|
|
|
90
89
|
return;
|
|
91
90
|
}
|
|
92
91
|
const increasesCost = backend.someEndpoint(want, (wantE) => {
|
|
93
|
-
var _a;
|
|
94
92
|
if (!pricing.canCalculateMinInstanceCost(wantE)) {
|
|
95
93
|
return true;
|
|
96
94
|
}
|
|
97
95
|
const wantCost = pricing.monthlyMinInstanceCost([wantE]);
|
|
98
|
-
const haveE =
|
|
96
|
+
const haveE = have.endpoints[wantE.region]?.[wantE.id];
|
|
99
97
|
let haveCost;
|
|
100
98
|
if (!haveE) {
|
|
101
99
|
haveCost = 0;
|