firebase-tools 11.0.1 → 11.2.1
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 +11 -4
- package/lib/accountImporter.js +93 -95
- package/lib/api.js +77 -218
- package/lib/apiv2.js +5 -4
- package/lib/appdistribution/client.js +7 -9
- package/lib/auth.js +72 -52
- package/lib/bin/firebase.js +42 -47
- package/lib/checkValidTargetFilters.js +36 -25
- package/lib/commands/appdistribution-distribute.js +2 -1
- package/lib/commands/appdistribution-testers-add.js +2 -1
- package/lib/commands/appdistribution-testers-remove.js +2 -1
- package/lib/commands/apps-android-sha-create.js +2 -1
- package/lib/commands/apps-android-sha-delete.js +2 -1
- package/lib/commands/apps-android-sha-list.js +2 -1
- package/lib/commands/apps-create.js +2 -1
- package/lib/commands/apps-list.js +2 -1
- package/lib/commands/apps-sdkconfig.js +2 -1
- package/lib/commands/auth-export.js +2 -1
- package/lib/commands/auth-import.js +7 -10
- package/lib/commands/crashlytics-symbols-upload.js +2 -1
- package/lib/commands/database-get.js +4 -3
- package/lib/commands/database-instances-create.js +2 -1
- package/lib/commands/database-instances-list.js +3 -3
- package/lib/commands/database-profile.js +4 -4
- package/lib/commands/database-push.js +4 -4
- package/lib/commands/database-remove.js +3 -3
- package/lib/commands/database-rules-canary.js +2 -1
- package/lib/commands/database-rules-get.js +2 -1
- package/lib/commands/database-rules-list.js +2 -1
- package/lib/commands/database-rules-release.js +2 -1
- package/lib/commands/database-rules-stage.js +2 -1
- package/lib/commands/database-set.js +3 -3
- package/lib/commands/database-settings-get.js +2 -1
- package/lib/commands/database-settings-set.js +2 -1
- package/lib/commands/database-update.js +2 -1
- package/lib/commands/deploy.js +26 -25
- package/lib/commands/emulators-exec.js +2 -1
- package/lib/commands/emulators-export.js +2 -1
- package/lib/commands/emulators-start.js +2 -1
- package/lib/commands/experimental-functions-shell.js +10 -8
- package/lib/commands/ext-configure.js +2 -1
- package/lib/commands/ext-dev-deprecate.js +2 -1
- package/lib/commands/ext-dev-emulators-exec.js +3 -2
- package/lib/commands/ext-dev-emulators-start.js +3 -2
- package/lib/commands/ext-dev-extension-delete.js +2 -1
- package/lib/commands/ext-dev-init.js +2 -1
- package/lib/commands/ext-dev-list.js +8 -8
- package/lib/commands/ext-dev-publish.js +2 -1
- package/lib/commands/ext-dev-register.js +2 -1
- package/lib/commands/ext-dev-undeprecate.js +2 -1
- package/lib/commands/ext-dev-unpublish.js +2 -1
- package/lib/commands/ext-dev-usage.js +2 -1
- package/lib/commands/ext-export.js +2 -1
- package/lib/commands/ext-info.js +14 -14
- package/lib/commands/ext-install.js +2 -1
- package/lib/commands/ext-list.js +2 -1
- package/lib/commands/ext-sources-create.js +2 -1
- package/lib/commands/ext-uninstall.js +2 -1
- package/lib/commands/ext-update.js +2 -1
- package/lib/commands/ext.js +4 -4
- package/lib/commands/firestore-delete.js +2 -1
- package/lib/commands/firestore-indexes-list.js +2 -1
- package/lib/commands/functions-config-clone.js +4 -3
- package/lib/commands/functions-config-export.js +2 -1
- package/lib/commands/functions-config-get.js +2 -1
- package/lib/commands/functions-config-set.js +2 -1
- package/lib/commands/functions-config-unset.js +2 -1
- package/lib/commands/functions-delete.js +3 -8
- package/lib/commands/functions-deletegcfartifacts.js +2 -1
- package/lib/commands/functions-list.js +2 -1
- package/lib/commands/functions-log.js +2 -1
- package/lib/commands/functions-secrets-access.js +2 -1
- package/lib/commands/functions-secrets-destroy.js +2 -1
- package/lib/commands/functions-secrets-get.js +2 -1
- package/lib/commands/functions-secrets-prune.js +2 -1
- package/lib/commands/functions-secrets-set.js +2 -1
- package/lib/commands/functions-shell.js +12 -10
- package/lib/commands/help.js +2 -1
- package/lib/commands/hosting-channel-create.js +2 -1
- package/lib/commands/hosting-channel-delete.js +2 -1
- package/lib/commands/hosting-channel-deploy.js +2 -1
- package/lib/commands/hosting-channel-list.js +2 -1
- package/lib/commands/hosting-channel-open.js +2 -1
- package/lib/commands/hosting-clone.js +2 -1
- package/lib/commands/hosting-disable.js +2 -1
- package/lib/commands/hosting-sites-create.js +2 -1
- package/lib/commands/hosting-sites-delete.js +2 -1
- package/lib/commands/hosting-sites-get.js +2 -1
- package/lib/commands/hosting-sites-list.js +2 -1
- package/lib/commands/index.js +23 -13
- package/lib/commands/init.js +47 -43
- package/lib/commands/login-add.js +2 -1
- package/lib/commands/login-ci.js +2 -1
- package/lib/commands/login-list.js +2 -1
- package/lib/commands/login-use.js +2 -1
- package/lib/commands/login.js +2 -1
- package/lib/commands/logout.js +2 -1
- package/lib/commands/open.js +7 -7
- package/lib/commands/projects-addfirebase.js +2 -1
- package/lib/commands/projects-create.js +2 -1
- package/lib/commands/projects-list.js +2 -1
- package/lib/commands/remoteconfig-get.js +2 -1
- package/lib/commands/remoteconfig-rollback.js +2 -1
- package/lib/commands/remoteconfig-versions-list.js +2 -1
- package/lib/commands/serve.js +30 -30
- package/lib/commands/setup-emulators-database.js +2 -1
- package/lib/commands/setup-emulators-firestore.js +2 -1
- package/lib/commands/setup-emulators-pubsub.js +2 -1
- package/lib/commands/setup-emulators-storage.js +2 -1
- package/lib/commands/setup-emulators-ui.js +2 -1
- package/lib/commands/target-apply.js +2 -1
- package/lib/commands/target-clear.js +2 -1
- package/lib/commands/target-remove.js +2 -1
- package/lib/commands/target.js +2 -1
- package/lib/commands/use.js +54 -53
- package/lib/config.js +7 -6
- package/lib/deploy/database/deploy.js +3 -2
- package/lib/deploy/database/index.js +8 -5
- package/lib/deploy/database/prepare.js +22 -20
- package/lib/deploy/database/release.js +12 -9
- package/lib/deploy/extensions/secrets.js +3 -3
- package/lib/deploy/firestore/prepare.js +2 -2
- package/lib/deploy/functions/build.js +33 -20
- package/lib/deploy/functions/ensure.js +1 -11
- package/lib/deploy/functions/prepare.js +3 -13
- package/lib/deploy/functions/prepareFunctionsUpload.js +2 -3
- package/lib/deploy/functions/release/fabricator.js +0 -1
- package/lib/deploy/functions/release/index.js +1 -5
- package/lib/deploy/functions/runtimes/discovery/index.js +18 -3
- package/lib/deploy/functions/runtimes/discovery/v1alpha1.js +188 -54
- package/lib/deploy/functions/runtimes/golang/index.js +2 -22
- package/lib/deploy/functions/runtimes/node/index.js +3 -7
- package/lib/deploy/functions/runtimes/node/parseTriggers.js +16 -4
- package/lib/deploy/functions/services/database.js +14 -0
- package/lib/deploy/functions/services/index.js +14 -0
- package/lib/deploy/index.js +3 -3
- package/lib/deploy/lifecycleHooks.js +27 -27
- package/lib/deploy/remoteconfig/prepare.js +2 -2
- package/lib/deploy/storage/prepare.js +1 -1
- package/lib/emulator/auth/apiSpec.js +14 -46
- package/lib/emulator/auth/index.js +1 -1
- package/lib/emulator/auth/operations.js +342 -93
- package/lib/emulator/auth/server.js +2 -2
- package/lib/emulator/auth/state.js +34 -32
- package/lib/emulator/commandUtils.js +1 -1
- package/lib/emulator/constants.js +1 -1
- package/lib/emulator/controller.js +7 -6
- package/lib/emulator/databaseEmulator.js +4 -4
- package/lib/emulator/download.js +1 -1
- package/lib/emulator/downloadableEmulators.js +5 -5
- package/lib/emulator/events/types.js +2 -3
- package/lib/emulator/firestoreEmulator.js +2 -2
- package/lib/emulator/functionsEmulator.js +31 -45
- package/lib/emulator/functionsEmulatorRuntime.js +12 -16
- package/lib/emulator/functionsEmulatorShared.js +7 -5
- package/lib/emulator/functionsRuntimeWorker.js +0 -6
- package/lib/emulator/hostingEmulator.js +1 -1
- package/lib/emulator/hub.js +1 -1
- package/lib/emulator/loggingEmulator.js +1 -1
- package/lib/emulator/pubsubEmulator.js +1 -1
- package/lib/emulator/storage/crc.js +4 -4
- package/lib/emulator/storage/index.js +1 -1
- package/lib/emulator/types.js +1 -1
- package/lib/errorOut.js +2 -2
- package/lib/extensions/askUserForConsent.js +1 -2
- package/lib/extensions/askUserForParam.js +15 -18
- package/lib/extensions/emulator/optionsHelper.js +4 -4
- package/lib/extensions/extensionsApi.js +1 -22
- package/lib/extensions/extensionsHelper.js +6 -6
- package/lib/extensions/listExtensions.js +9 -10
- package/lib/extensions/manifest.js +2 -2
- package/lib/extensions/resolveSource.js +11 -7
- package/lib/extensions/secretsUtils.js +3 -3
- package/lib/extensions/types.js +24 -0
- package/lib/extensions/updateHelper.js +1 -1
- package/lib/extensions/utils.js +1 -2
- package/lib/extensions/warnings.js +3 -3
- package/lib/firestore/encodeFirestoreValue.js +11 -8
- package/lib/fsAsync.js +3 -3
- package/lib/functions/events/v2.js +7 -1
- package/lib/functionsConfig.js +17 -14
- package/lib/functionsConfigClone.js +46 -46
- package/lib/gcp/cloudfunctions.js +2 -15
- package/lib/gcp/cloudfunctionsv2.js +17 -2
- package/lib/gcp/iam.js +1 -1
- package/lib/gcp/index.js +10 -10
- package/lib/gcp/rules.js +1 -1
- package/lib/gcp/runtimeconfig.js +45 -47
- package/lib/hosting/proxy.js +1 -1
- package/lib/index.js +29 -28
- package/lib/init/features/database.js +10 -2
- package/lib/init/features/functions/index.js +1 -1
- package/lib/init/features/functions/javascript.js +23 -20
- package/lib/init/features/functions/npm-dependencies.js +17 -14
- package/lib/init/features/functions/typescript.js +27 -24
- package/lib/init/features/hosting/github.js +6 -5
- package/lib/init/features/hosting/index.js +2 -2
- package/lib/loadCJSON.js +9 -6
- package/lib/localFunction.js +4 -4
- package/lib/logError.js +15 -12
- package/lib/parseBoltRules.js +15 -14
- package/lib/previews.js +1 -1
- package/lib/profileReport.js +504 -512
- package/lib/profiler.js +4 -4
- package/lib/prompt.js +1 -2
- package/lib/rc.js +1 -1
- package/lib/requireAuth.js +0 -1
- package/lib/responseToError.js +8 -5
- package/lib/rulesDeploy.js +2 -2
- package/lib/scopes.js +9 -9
- package/lib/serve/index.js +4 -5
- package/lib/utils.js +30 -6
- package/npm-shrinkwrap.json +537 -193
- package/package.json +17 -14
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const _ = require("lodash");
|
|
4
4
|
const clc = require("cli-color");
|
|
5
|
-
const
|
|
5
|
+
const loadCJSON_1 = require("../../loadCJSON");
|
|
6
6
|
const rulesDeploy_1 = require("../../rulesDeploy");
|
|
7
7
|
const utils = require("../../utils");
|
|
8
8
|
async function prepareRules(context, options) {
|
|
@@ -22,7 +22,7 @@ function prepareIndexes(context, options) {
|
|
|
22
22
|
}
|
|
23
23
|
const indexesFileName = options.config.src.firestore.indexes;
|
|
24
24
|
const indexesPath = options.config.path(indexesFileName);
|
|
25
|
-
const parsedSrc = loadCJSON(indexesPath);
|
|
25
|
+
const parsedSrc = (0, loadCJSON_1.loadCJSON)(indexesPath);
|
|
26
26
|
utils.logBullet(`${clc.bold.cyan("firestore:")} reading indexes from ${clc.bold(indexesFileName)}...`);
|
|
27
27
|
context.firestore = context.firestore || {};
|
|
28
28
|
context.firestore.indexes = {
|
|
@@ -56,44 +56,46 @@ function resolveBackend(build, userEnvs) {
|
|
|
56
56
|
if (!userEnvs.hasOwnProperty(expectedEnv)) {
|
|
57
57
|
throw new error_1.FirebaseError("Build specified parameter " +
|
|
58
58
|
expectedEnv +
|
|
59
|
-
" but it was not present in the user dotenv files");
|
|
59
|
+
" but it was not present in the user dotenv files or Cloud Secret Manager");
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
const bkEndpoints = [];
|
|
63
63
|
for (const endpointId of Object.keys(build.endpoints)) {
|
|
64
|
-
const
|
|
65
|
-
let regions =
|
|
64
|
+
const bdEndpoint = build.endpoints[endpointId];
|
|
65
|
+
let regions = bdEndpoint.region;
|
|
66
66
|
if (typeof regions === "undefined") {
|
|
67
67
|
regions = [api.functionsDefaultRegion];
|
|
68
68
|
}
|
|
69
69
|
for (const region of regions) {
|
|
70
|
-
const trigger = discoverTrigger(
|
|
71
|
-
if (typeof
|
|
70
|
+
const trigger = discoverTrigger(bdEndpoint);
|
|
71
|
+
if (typeof bdEndpoint.platform === "undefined") {
|
|
72
72
|
throw new error_1.FirebaseError("platform can't be undefined");
|
|
73
73
|
}
|
|
74
|
-
if (!isMemoryOption(
|
|
74
|
+
if (!isMemoryOption(bdEndpoint.availableMemoryMb)) {
|
|
75
75
|
throw new error_1.FirebaseError("available memory must be a supported value, if present");
|
|
76
76
|
}
|
|
77
77
|
let timeout;
|
|
78
|
-
if (
|
|
79
|
-
timeout = resolveInt(
|
|
78
|
+
if (bdEndpoint.timeoutSeconds) {
|
|
79
|
+
timeout = resolveInt(bdEndpoint.timeoutSeconds);
|
|
80
80
|
}
|
|
81
81
|
else {
|
|
82
82
|
timeout = 60;
|
|
83
83
|
}
|
|
84
|
-
const bkEndpoint = Object.assign({ id: endpointId, project:
|
|
85
|
-
proto.renameIfPresent(bkEndpoint,
|
|
86
|
-
proto.renameIfPresent(bkEndpoint,
|
|
87
|
-
proto.renameIfPresent(bkEndpoint,
|
|
88
|
-
proto.copyIfPresent(bkEndpoint,
|
|
89
|
-
|
|
84
|
+
const bkEndpoint = Object.assign({ id: endpointId, project: bdEndpoint.project, region: region, entryPoint: bdEndpoint.entryPoint, platform: bdEndpoint.platform, runtime: bdEndpoint.runtime, timeoutSeconds: timeout }, trigger);
|
|
85
|
+
proto.renameIfPresent(bkEndpoint, bdEndpoint, "maxInstances", "maxInstances", resolveInt);
|
|
86
|
+
proto.renameIfPresent(bkEndpoint, bdEndpoint, "minInstances", "minInstances", resolveInt);
|
|
87
|
+
proto.renameIfPresent(bkEndpoint, bdEndpoint, "concurrency", "concurrency", resolveInt);
|
|
88
|
+
proto.copyIfPresent(bkEndpoint, bdEndpoint, "ingressSettings", "availableMemoryMb", "environmentVariables", "labels");
|
|
89
|
+
proto.copyIfPresent(bkEndpoint, bdEndpoint, "secretEnvironmentVariables");
|
|
90
|
+
if (bdEndpoint.vpc) {
|
|
90
91
|
bkEndpoint.vpc = {
|
|
91
|
-
connector: resolveString(
|
|
92
|
+
connector: resolveString(bdEndpoint.vpc.connector).replace("$REGION", region),
|
|
92
93
|
};
|
|
93
|
-
proto.copyIfPresent(bkEndpoint.vpc,
|
|
94
|
+
proto.copyIfPresent(bkEndpoint.vpc, bdEndpoint.vpc, "egressSettings");
|
|
94
95
|
}
|
|
95
|
-
|
|
96
|
-
|
|
96
|
+
proto.renameIfPresent(bkEndpoint, bdEndpoint, "serviceAccountEmail", "serviceAccount");
|
|
97
|
+
if ("serviceAccountEmail" in bkEndpoint && !bdEndpoint.serviceAccount) {
|
|
98
|
+
delete bkEndpoint.serviceAccountEmail;
|
|
97
99
|
}
|
|
98
100
|
bkEndpoints.push(bkEndpoint);
|
|
99
101
|
}
|
|
@@ -116,7 +118,7 @@ function discoverTrigger(endpoint) {
|
|
|
116
118
|
trigger = { callableTrigger: {} };
|
|
117
119
|
}
|
|
118
120
|
else if ("blockingTrigger" in endpoint) {
|
|
119
|
-
|
|
121
|
+
trigger = { blockingTrigger: endpoint.blockingTrigger };
|
|
120
122
|
}
|
|
121
123
|
else if ("eventTrigger" in endpoint) {
|
|
122
124
|
const bkEventFilters = {};
|
|
@@ -143,7 +145,18 @@ function discoverTrigger(endpoint) {
|
|
|
143
145
|
schedule: resolveString(endpoint.scheduleTrigger.schedule),
|
|
144
146
|
timeZone: resolveString(endpoint.scheduleTrigger.timeZone),
|
|
145
147
|
};
|
|
146
|
-
|
|
148
|
+
const bkRetry = {};
|
|
149
|
+
if (endpoint.scheduleTrigger.retryConfig.maxBackoffSeconds) {
|
|
150
|
+
bkRetry.maxBackoffDuration = proto.durationFromSeconds(resolveInt(endpoint.scheduleTrigger.retryConfig.maxBackoffSeconds));
|
|
151
|
+
}
|
|
152
|
+
if (endpoint.scheduleTrigger.retryConfig.minBackoffSeconds) {
|
|
153
|
+
bkRetry.minBackoffDuration = proto.durationFromSeconds(resolveInt(endpoint.scheduleTrigger.retryConfig.minBackoffSeconds));
|
|
154
|
+
}
|
|
155
|
+
if (endpoint.scheduleTrigger.retryConfig.maxRetrySeconds) {
|
|
156
|
+
bkRetry.maxRetryDuration = proto.durationFromSeconds(resolveInt(endpoint.scheduleTrigger.retryConfig.maxRetrySeconds));
|
|
157
|
+
}
|
|
158
|
+
proto.copyIfPresent(bkRetry, endpoint.scheduleTrigger.retryConfig, "retryCount", "maxDoublings");
|
|
159
|
+
bkSchedule.retryConfig = bkRetry;
|
|
147
160
|
trigger = { scheduleTrigger: bkSchedule };
|
|
148
161
|
}
|
|
149
162
|
else if ("taskQueueTrigger" in endpoint) {
|
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.secretAccess = exports.
|
|
3
|
+
exports.secretAccess = exports.cloudBuildEnabled = exports.defaultServiceAccount = void 0;
|
|
4
4
|
const clc = require("cli-color");
|
|
5
5
|
const ensureApiEnabled_1 = require("../../ensureApiEnabled");
|
|
6
6
|
const error_1 = require("../../error");
|
|
7
7
|
const utils_1 = require("../../utils");
|
|
8
8
|
const secretManager_1 = require("../../gcp/secretManager");
|
|
9
|
-
const previews_1 = require("../../previews");
|
|
10
9
|
const projects_1 = require("../../management/projects");
|
|
11
10
|
const functional_1 = require("../../functional");
|
|
12
11
|
const track_1 = require("../../track");
|
|
13
12
|
const backend = require("./backend");
|
|
14
|
-
const ensureApiEnabled = require("../../ensureApiEnabled");
|
|
15
13
|
const FAQ_URL = "https://firebase.google.com/support/faq#functions-runtime";
|
|
16
14
|
const CLOUD_BUILD_API = "cloudbuild.googleapis.com";
|
|
17
15
|
async function defaultServiceAccount(e) {
|
|
@@ -66,14 +64,6 @@ async function cloudBuildEnabled(projectId) {
|
|
|
66
64
|
}
|
|
67
65
|
}
|
|
68
66
|
exports.cloudBuildEnabled = cloudBuildEnabled;
|
|
69
|
-
async function maybeEnableAR(projectId) {
|
|
70
|
-
if (!previews_1.previews.artifactregistry) {
|
|
71
|
-
return ensureApiEnabled.check(projectId, "artifactregistry.googleapis.com", "functions", true);
|
|
72
|
-
}
|
|
73
|
-
await ensureApiEnabled.ensure(projectId, "artifactregistry.googleapis.com", "functions");
|
|
74
|
-
return true;
|
|
75
|
-
}
|
|
76
|
-
exports.maybeEnableAR = maybeEnableAR;
|
|
77
67
|
async function secretsToServiceAccounts(b) {
|
|
78
68
|
const secretsToSa = {};
|
|
79
69
|
for (const e of backend.allEndpoints(b)) {
|
|
@@ -21,7 +21,6 @@ const triggerRegionHelper_1 = require("./triggerRegionHelper");
|
|
|
21
21
|
const checkIam_1 = require("./checkIam");
|
|
22
22
|
const error_1 = require("../../error");
|
|
23
23
|
const projectConfig_1 = require("../../functions/projectConfig");
|
|
24
|
-
const previews_1 = require("../../previews");
|
|
25
24
|
const v1_1 = require("../../functions/events/v1");
|
|
26
25
|
const serviceusage_1 = require("../../gcp/serviceusage");
|
|
27
26
|
function hasUserConfig(config) {
|
|
@@ -40,9 +39,8 @@ async function prepare(context, options, payload) {
|
|
|
40
39
|
ensureApiEnabled.ensure(projectId, "cloudfunctions.googleapis.com", "functions"),
|
|
41
40
|
ensureApiEnabled.check(projectId, "runtimeconfig.googleapis.com", "runtimeconfig", true),
|
|
42
41
|
ensure.cloudBuildEnabled(projectId),
|
|
43
|
-
ensure
|
|
42
|
+
ensureApiEnabled.ensure(projectId, "artifactregistry.googleapis.com", "artifactregistry"),
|
|
44
43
|
]);
|
|
45
|
-
context.artifactRegistryEnabled = checkAPIsEnabled[3];
|
|
46
44
|
const firebaseConfig = await functionsConfig.getFirebaseConfig(options);
|
|
47
45
|
context.firebaseConfig = firebaseConfig;
|
|
48
46
|
let runtimeConfig = { firebase: firebaseConfig };
|
|
@@ -79,15 +77,8 @@ async function prepare(context, options, payload) {
|
|
|
79
77
|
};
|
|
80
78
|
const userEnvs = functionsEnv.loadUserEnvs(userEnvOpt);
|
|
81
79
|
const envs = Object.assign(Object.assign({}, userEnvs), firebaseEnvs);
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
const wantBuild = await runtimeDelegate.discoverBuild(runtimeConfig, firebaseEnvs);
|
|
85
|
-
wantBackend = build.resolveBackend(wantBuild, userEnvs);
|
|
86
|
-
}
|
|
87
|
-
else {
|
|
88
|
-
logger_1.logger.debug(`Analyzing ${runtimeDelegate.name} backend spec`);
|
|
89
|
-
wantBackend = await runtimeDelegate.discoverSpec(runtimeConfig, firebaseEnvs);
|
|
90
|
-
}
|
|
80
|
+
const wantBuild = await runtimeDelegate.discoverBuild(runtimeConfig, firebaseEnvs);
|
|
81
|
+
const wantBackend = build.resolveBackend(wantBuild, userEnvs);
|
|
91
82
|
wantBackend.environmentVariables = envs;
|
|
92
83
|
for (const endpoint of backend.allEndpoints(wantBackend)) {
|
|
93
84
|
endpoint.environmentVariables = wantBackend.environmentVariables;
|
|
@@ -145,7 +136,6 @@ async function prepare(context, options, payload) {
|
|
|
145
136
|
}));
|
|
146
137
|
if (backend.someEndpoint(wantBackend, (e) => e.platform === "gcfv2")) {
|
|
147
138
|
const V2_APIS = [
|
|
148
|
-
"artifactregistry.googleapis.com",
|
|
149
139
|
"run.googleapis.com",
|
|
150
140
|
"eventarc.googleapis.com",
|
|
151
141
|
"pubsub.googleapis.com",
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.prepareFunctionsUpload = exports.getFunctionsConfig = void 0;
|
|
4
|
-
const _ = require("lodash");
|
|
5
4
|
const archiver = require("archiver");
|
|
6
5
|
const clc = require("cli-color");
|
|
7
6
|
const filesize = require("filesize");
|
|
@@ -54,12 +53,12 @@ async function packageSource(sourceDir, config, runtimeConfig) {
|
|
|
54
53
|
ignore.push("firebase-debug.log", "firebase-debug.*.log", CONFIG_DEST_FILE);
|
|
55
54
|
try {
|
|
56
55
|
const files = await fsAsync.readdirRecursive({ path: sourceDir, ignore: ignore });
|
|
57
|
-
|
|
56
|
+
for (const file of files) {
|
|
58
57
|
archive.file(file.name, {
|
|
59
58
|
name: path.relative(sourceDir, file.name),
|
|
60
59
|
mode: file.mode,
|
|
61
60
|
});
|
|
62
|
-
}
|
|
61
|
+
}
|
|
63
62
|
if (typeof runtimeConfig !== "undefined") {
|
|
64
63
|
archive.append(JSON.stringify(runtimeConfig, null, 2), {
|
|
65
64
|
name: CONFIG_DEST_FILE,
|
|
@@ -36,7 +36,6 @@ const gcfV2PollerOptions = {
|
|
|
36
36
|
masterTimeout: 25 * 60 * 1000,
|
|
37
37
|
maxBackoff: 10000,
|
|
38
38
|
};
|
|
39
|
-
const DEFAULT_GCFV2_CONCURRENCY = 80;
|
|
40
39
|
const rethrowAs = (endpoint, op) => (err) => {
|
|
41
40
|
logger_1.logger.error(err.message);
|
|
42
41
|
throw new reporter.DeploymentError(endpoint, op, err);
|
|
@@ -63,11 +63,7 @@ async function release(context, options, payload) {
|
|
|
63
63
|
const deletedEndpoints = Object.values(plan)
|
|
64
64
|
.map((r) => r.endpointsToDelete)
|
|
65
65
|
.reduce(functional_1.reduceFlat, []);
|
|
66
|
-
|
|
67
|
-
if (!context.artifactRegistryEnabled) {
|
|
68
|
-
opts.ar = new containerCleaner.NoopArtifactRegistryCleaner();
|
|
69
|
-
}
|
|
70
|
-
await containerCleaner.cleanupBuildImages(haveEndpoints, deletedEndpoints, opts);
|
|
66
|
+
await containerCleaner.cleanupBuildImages(haveEndpoints, deletedEndpoints);
|
|
71
67
|
const allErrors = summary.results.filter((r) => r.error).map((r) => r.error);
|
|
72
68
|
if (allErrors.length) {
|
|
73
69
|
const opts = allErrors.length === 1 ? { original: allErrors[0] } : { children: allErrors };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.detectFromPort = exports.detectFromYaml = exports.yamlToBackend = exports.readFileAsync = void 0;
|
|
3
|
+
exports.detectFromPort = exports.detectFromYaml = exports.yamlToBuild = exports.yamlToBackend = exports.readFileAsync = void 0;
|
|
4
4
|
const node_fetch_1 = require("node-fetch");
|
|
5
5
|
const fs = require("fs");
|
|
6
6
|
const path = require("path");
|
|
@@ -26,6 +26,21 @@ function yamlToBackend(yaml, project, region, runtime) {
|
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
exports.yamlToBackend = yamlToBackend;
|
|
29
|
+
function yamlToBuild(yaml, project, region, runtime) {
|
|
30
|
+
try {
|
|
31
|
+
if (!yaml.specVersion) {
|
|
32
|
+
throw new error_1.FirebaseError("Expect manifest yaml to specify a version number");
|
|
33
|
+
}
|
|
34
|
+
if (yaml.specVersion === "v1alpha1") {
|
|
35
|
+
return v1alpha1.buildFromV1Alpha1(yaml, project, region, runtime);
|
|
36
|
+
}
|
|
37
|
+
throw new error_1.FirebaseError("It seems you are using a newer SDK than this version of the CLI can handle. Please update your CLI with `npm install -g firebase-tools`");
|
|
38
|
+
}
|
|
39
|
+
catch (err) {
|
|
40
|
+
throw new error_1.FirebaseError("Failed to parse build specification", { children: [err] });
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.yamlToBuild = yamlToBuild;
|
|
29
44
|
async function detectFromYaml(directory, project, runtime) {
|
|
30
45
|
let text;
|
|
31
46
|
try {
|
|
@@ -42,7 +57,7 @@ async function detectFromYaml(directory, project, runtime) {
|
|
|
42
57
|
}
|
|
43
58
|
logger_1.logger.debug("Found functions.yaml. Got spec:", text);
|
|
44
59
|
const parsed = yaml.load(text);
|
|
45
|
-
return
|
|
60
|
+
return yamlToBuild(parsed, project, api.functionsDefaultRegion, runtime);
|
|
46
61
|
}
|
|
47
62
|
exports.detectFromYaml = detectFromYaml;
|
|
48
63
|
async function detectFromPort(port, project, runtime, timeout = 30000) {
|
|
@@ -74,6 +89,6 @@ async function detectFromPort(port, project, runtime, timeout = 30000) {
|
|
|
74
89
|
logger_1.logger.debug("Failed to parse functions.yaml", err);
|
|
75
90
|
throw new error_1.FirebaseError(`Failed to load function definition from source: ${text}`);
|
|
76
91
|
}
|
|
77
|
-
return
|
|
92
|
+
return yamlToBuild(parsed, project, api.functionsDefaultRegion, runtime);
|
|
78
93
|
}
|
|
79
94
|
exports.detectFromPort = detectFromPort;
|
|
@@ -1,7 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
2
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.backendFromV1Alpha1 = void 0;
|
|
14
|
+
exports.backendFromV1Alpha1 = exports.buildFromV1Alpha1 = void 0;
|
|
4
15
|
const backend = require("../../backend");
|
|
16
|
+
const build = require("../../build");
|
|
5
17
|
const proto_1 = require("../../../../gcp/proto");
|
|
6
18
|
const parsing_1 = require("./parsing");
|
|
7
19
|
const error_1 = require("../../../../error");
|
|
@@ -11,6 +23,25 @@ const CHANNEL_NAME_REGEX = new RegExp("(projects\\/" +
|
|
|
11
23
|
"(?<location>[A-Za-z\\d\\-_]+)\\/" +
|
|
12
24
|
"channels\\/" +
|
|
13
25
|
"(?<channel>[A-Za-z\\d\\-_]+)");
|
|
26
|
+
function buildFromV1Alpha1(yaml, project, region, runtime) {
|
|
27
|
+
const manifest = JSON.parse(JSON.stringify(yaml));
|
|
28
|
+
(0, parsing_1.requireKeys)("", manifest, "endpoints");
|
|
29
|
+
(0, parsing_1.assertKeyTypes)("", manifest, {
|
|
30
|
+
specVersion: "string",
|
|
31
|
+
requiredAPIs: "array",
|
|
32
|
+
endpoints: "object",
|
|
33
|
+
});
|
|
34
|
+
const bd = build.empty();
|
|
35
|
+
bd.requiredAPIs = parseRequiredAPIs(manifest);
|
|
36
|
+
for (const id of Object.keys(manifest.endpoints)) {
|
|
37
|
+
const me = manifest.endpoints[id];
|
|
38
|
+
assertManifestEndpoint(me, id);
|
|
39
|
+
const be = parseEndpointForBuild(id, me, project, region, runtime);
|
|
40
|
+
bd.endpoints[id] = be;
|
|
41
|
+
}
|
|
42
|
+
return bd;
|
|
43
|
+
}
|
|
44
|
+
exports.buildFromV1Alpha1 = buildFromV1Alpha1;
|
|
14
45
|
function backendFromV1Alpha1(yaml, project, region, runtime) {
|
|
15
46
|
const manifest = JSON.parse(JSON.stringify(yaml));
|
|
16
47
|
const bkend = backend.empty();
|
|
@@ -42,10 +73,8 @@ function parseRequiredAPIs(manifest) {
|
|
|
42
73
|
}
|
|
43
74
|
return requiredAPIs;
|
|
44
75
|
}
|
|
45
|
-
function
|
|
46
|
-
const allParsed = [];
|
|
76
|
+
function assertManifestEndpoint(ep, id) {
|
|
47
77
|
const prefix = `endpoints[${id}]`;
|
|
48
|
-
const ep = manifest.endpoints[id];
|
|
49
78
|
(0, parsing_1.assertKeyTypes)(prefix, ep, {
|
|
50
79
|
region: "array",
|
|
51
80
|
platform: (platform) => backend.AllFunctionsPlatforms.includes(platform),
|
|
@@ -101,19 +130,164 @@ function parseEndpoints(manifest, id, project, defaultRegion, runtime) {
|
|
|
101
130
|
if (triggerCount > 1) {
|
|
102
131
|
throw new error_1.FirebaseError("Multiple triggers defined for endpoint" + id);
|
|
103
132
|
}
|
|
133
|
+
if (backend.isEventTriggered(ep)) {
|
|
134
|
+
(0, parsing_1.requireKeys)(prefix + ".eventTrigger", ep.eventTrigger, "eventType", "eventFilters");
|
|
135
|
+
(0, parsing_1.assertKeyTypes)(prefix + ".eventTrigger", ep.eventTrigger, {
|
|
136
|
+
eventFilters: "object",
|
|
137
|
+
eventFilterPathPatterns: "object",
|
|
138
|
+
eventType: "string",
|
|
139
|
+
retry: "boolean",
|
|
140
|
+
region: "string",
|
|
141
|
+
serviceAccountEmail: "string",
|
|
142
|
+
channel: "string",
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
else if (backend.isHttpsTriggered(ep)) {
|
|
146
|
+
(0, parsing_1.assertKeyTypes)(prefix + ".httpsTrigger", ep.httpsTrigger, {
|
|
147
|
+
invoker: "array",
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
else if (backend.isCallableTriggered(ep)) {
|
|
151
|
+
}
|
|
152
|
+
else if (backend.isScheduleTriggered(ep)) {
|
|
153
|
+
(0, parsing_1.assertKeyTypes)(prefix + ".scheduleTrigger", ep.scheduleTrigger, {
|
|
154
|
+
schedule: "string",
|
|
155
|
+
timeZone: "string",
|
|
156
|
+
retryConfig: "object",
|
|
157
|
+
});
|
|
158
|
+
(0, parsing_1.assertKeyTypes)(prefix + ".scheduleTrigger.retryConfig", ep.scheduleTrigger.retryConfig, {
|
|
159
|
+
retryCount: "number",
|
|
160
|
+
maxDoublings: "number",
|
|
161
|
+
minBackoffDuration: "string",
|
|
162
|
+
maxBackoffDuration: "string",
|
|
163
|
+
maxRetryDuration: "string",
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
else if (backend.isTaskQueueTriggered(ep)) {
|
|
167
|
+
(0, parsing_1.assertKeyTypes)(prefix + ".taskQueueTrigger", ep.taskQueueTrigger, {
|
|
168
|
+
rateLimits: "object",
|
|
169
|
+
retryConfig: "object",
|
|
170
|
+
invoker: "array",
|
|
171
|
+
});
|
|
172
|
+
if (ep.taskQueueTrigger.rateLimits) {
|
|
173
|
+
(0, parsing_1.assertKeyTypes)(prefix + ".taskQueueTrigger.rateLimits", ep.taskQueueTrigger.rateLimits, {
|
|
174
|
+
maxConcurrentDispatches: "number",
|
|
175
|
+
maxDispatchesPerSecond: "number",
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
if (ep.taskQueueTrigger.retryConfig) {
|
|
179
|
+
(0, parsing_1.assertKeyTypes)(prefix + ".taskQueueTrigger.retryConfig", ep.taskQueueTrigger.retryConfig, {
|
|
180
|
+
maxAttempts: "number",
|
|
181
|
+
maxRetrySeconds: "number",
|
|
182
|
+
minBackoffSeconds: "number",
|
|
183
|
+
maxBackoffSeconds: "number",
|
|
184
|
+
maxDoublings: "number",
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
else if (backend.isBlockingTriggered(ep)) {
|
|
189
|
+
(0, parsing_1.requireKeys)(prefix + ".blockingTrigger", ep.blockingTrigger, "eventType");
|
|
190
|
+
(0, parsing_1.assertKeyTypes)(prefix + ".blockingTrigger", ep.blockingTrigger, {
|
|
191
|
+
eventType: "string",
|
|
192
|
+
options: "object",
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
else {
|
|
196
|
+
throw new error_1.FirebaseError(`Do not recognize trigger type for endpoint ${id}. Try upgrading ` +
|
|
197
|
+
"firebase-tools with npm install -g firebase-tools@latest");
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
function parseEndpointForBuild(id, ep, project, defaultRegion, runtime) {
|
|
201
|
+
let triggered;
|
|
202
|
+
if (backend.isEventTriggered(ep)) {
|
|
203
|
+
const newTrigger = __rest(ep.eventTrigger, []);
|
|
204
|
+
delete newTrigger.serviceAccountEmail;
|
|
205
|
+
triggered = { eventTrigger: newTrigger };
|
|
206
|
+
triggered.eventTrigger.serviceAccount = ep.eventTrigger.serviceAccountEmail;
|
|
207
|
+
(0, proto_1.renameIfPresent)(triggered.eventTrigger, ep.eventTrigger, "channel", "channel", (c) => resolveChannelName(project, c, defaultRegion));
|
|
208
|
+
for (const [k, v] of Object.entries(triggered.eventTrigger.eventFilters)) {
|
|
209
|
+
if (k === "topic" && !v.startsWith("projects/")) {
|
|
210
|
+
triggered.eventTrigger.eventFilters[k] = `projects/${project}/topics/${v}`;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
else if (backend.isHttpsTriggered(ep)) {
|
|
215
|
+
triggered = { httpsTrigger: {} };
|
|
216
|
+
(0, proto_1.copyIfPresent)(triggered.httpsTrigger, ep.httpsTrigger, "invoker");
|
|
217
|
+
}
|
|
218
|
+
else if (backend.isCallableTriggered(ep)) {
|
|
219
|
+
triggered = { callableTrigger: {} };
|
|
220
|
+
}
|
|
221
|
+
else if (backend.isScheduleTriggered(ep)) {
|
|
222
|
+
const st = {
|
|
223
|
+
schedule: ep.scheduleTrigger.schedule || "",
|
|
224
|
+
timeZone: ep.scheduleTrigger.timeZone || "",
|
|
225
|
+
retryConfig: {},
|
|
226
|
+
};
|
|
227
|
+
if (ep.scheduleTrigger.retryConfig) {
|
|
228
|
+
st.retryConfig = {
|
|
229
|
+
retryCount: ep.scheduleTrigger.retryConfig.retryCount,
|
|
230
|
+
maxDoublings: ep.scheduleTrigger.retryConfig.maxDoublings,
|
|
231
|
+
};
|
|
232
|
+
if (ep.scheduleTrigger.retryConfig.maxRetryDuration) {
|
|
233
|
+
st.retryConfig.maxRetrySeconds = (0, proto_1.secondsFromDuration)(ep.scheduleTrigger.retryConfig.maxRetryDuration);
|
|
234
|
+
}
|
|
235
|
+
if (ep.scheduleTrigger.retryConfig.maxBackoffDuration) {
|
|
236
|
+
st.retryConfig.maxBackoffSeconds = (0, proto_1.secondsFromDuration)(ep.scheduleTrigger.retryConfig.maxBackoffDuration);
|
|
237
|
+
}
|
|
238
|
+
if (ep.scheduleTrigger.retryConfig.minBackoffDuration) {
|
|
239
|
+
st.retryConfig.minBackoffSeconds = (0, proto_1.secondsFromDuration)(ep.scheduleTrigger.retryConfig.minBackoffDuration);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
triggered = { scheduleTrigger: st };
|
|
243
|
+
}
|
|
244
|
+
else if (backend.isTaskQueueTriggered(ep)) {
|
|
245
|
+
const tq = {
|
|
246
|
+
invoker: ep.taskQueueTrigger.invoker,
|
|
247
|
+
rateLimits: ep.taskQueueTrigger.rateLimits,
|
|
248
|
+
};
|
|
249
|
+
if (ep.taskQueueTrigger.retryConfig) {
|
|
250
|
+
tq.retryConfig = {
|
|
251
|
+
maxRetryDurationSeconds: ep.taskQueueTrigger.retryConfig.maxRetrySeconds,
|
|
252
|
+
maxBackoffSeconds: ep.taskQueueTrigger.retryConfig.maxBackoffSeconds,
|
|
253
|
+
minBackoffSeconds: ep.taskQueueTrigger.retryConfig.minBackoffSeconds,
|
|
254
|
+
maxDoublings: ep.taskQueueTrigger.retryConfig.maxDoublings,
|
|
255
|
+
maxAttempts: ep.taskQueueTrigger.retryConfig.maxAttempts,
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
triggered = { taskQueueTrigger: tq };
|
|
259
|
+
}
|
|
260
|
+
else if (backend.isBlockingTriggered(ep)) {
|
|
261
|
+
triggered = { blockingTrigger: ep.blockingTrigger };
|
|
262
|
+
}
|
|
263
|
+
else {
|
|
264
|
+
throw new error_1.FirebaseError(`Do not recognize trigger type for endpoint ${id}. Try upgrading ` +
|
|
265
|
+
"firebase-tools with npm install -g firebase-tools@latest");
|
|
266
|
+
}
|
|
267
|
+
const parsed = Object.assign({ platform: ep.platform || "gcfv2", region: ep.region || [defaultRegion], project,
|
|
268
|
+
runtime, entryPoint: ep.entryPoint, serviceAccount: ep.serviceAccountEmail || null }, triggered);
|
|
269
|
+
(0, proto_1.copyIfPresent)(parsed, ep, "availableMemoryMb", "maxInstances", "minInstances", "concurrency", "timeoutSeconds", "vpc", "labels", "ingressSettings", "environmentVariables");
|
|
270
|
+
(0, proto_1.renameIfPresent)(parsed, ep, "secretEnvironmentVariables", "secretEnvironmentVariables", (senvs) => {
|
|
271
|
+
const secretEnvironmentVariables = [];
|
|
272
|
+
for (const { key, secret } of senvs) {
|
|
273
|
+
secretEnvironmentVariables.push({
|
|
274
|
+
key,
|
|
275
|
+
secret: secret || key,
|
|
276
|
+
projectId: project,
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
return secretEnvironmentVariables;
|
|
280
|
+
});
|
|
281
|
+
return parsed;
|
|
282
|
+
}
|
|
283
|
+
function parseEndpoints(manifest, id, project, defaultRegion, runtime) {
|
|
284
|
+
const allParsed = [];
|
|
285
|
+
const prefix = `endpoints[${id}]`;
|
|
286
|
+
const ep = manifest.endpoints[id];
|
|
287
|
+
assertManifestEndpoint(ep, prefix);
|
|
104
288
|
for (const region of ep.region || [defaultRegion]) {
|
|
105
289
|
let triggered;
|
|
106
290
|
if (backend.isEventTriggered(ep)) {
|
|
107
|
-
(0, parsing_1.requireKeys)(prefix + ".eventTrigger", ep.eventTrigger, "eventType", "eventFilters");
|
|
108
|
-
(0, parsing_1.assertKeyTypes)(prefix + ".eventTrigger", ep.eventTrigger, {
|
|
109
|
-
eventFilters: "object",
|
|
110
|
-
eventFilterPathPatterns: "object",
|
|
111
|
-
eventType: "string",
|
|
112
|
-
retry: "boolean",
|
|
113
|
-
region: "string",
|
|
114
|
-
serviceAccountEmail: "string",
|
|
115
|
-
channel: "string",
|
|
116
|
-
});
|
|
117
291
|
triggered = { eventTrigger: ep.eventTrigger };
|
|
118
292
|
(0, proto_1.renameIfPresent)(triggered.eventTrigger, ep.eventTrigger, "channel", "channel", (c) => resolveChannelName(project, c, defaultRegion));
|
|
119
293
|
for (const [k, v] of Object.entries(triggered.eventTrigger.eventFilters)) {
|
|
@@ -123,9 +297,6 @@ function parseEndpoints(manifest, id, project, defaultRegion, runtime) {
|
|
|
123
297
|
}
|
|
124
298
|
}
|
|
125
299
|
else if (backend.isHttpsTriggered(ep)) {
|
|
126
|
-
(0, parsing_1.assertKeyTypes)(prefix + ".httpsTrigger", ep.httpsTrigger, {
|
|
127
|
-
invoker: "array",
|
|
128
|
-
});
|
|
129
300
|
triggered = { httpsTrigger: {} };
|
|
130
301
|
(0, proto_1.copyIfPresent)(triggered.httpsTrigger, ep.httpsTrigger, "invoker");
|
|
131
302
|
}
|
|
@@ -133,49 +304,12 @@ function parseEndpoints(manifest, id, project, defaultRegion, runtime) {
|
|
|
133
304
|
triggered = { callableTrigger: {} };
|
|
134
305
|
}
|
|
135
306
|
else if (backend.isScheduleTriggered(ep)) {
|
|
136
|
-
(0, parsing_1.assertKeyTypes)(prefix + ".scheduleTrigger", ep.scheduleTrigger, {
|
|
137
|
-
schedule: "string",
|
|
138
|
-
timeZone: "string",
|
|
139
|
-
retryConfig: "object",
|
|
140
|
-
});
|
|
141
|
-
(0, parsing_1.assertKeyTypes)(prefix + ".scheduleTrigger.retryConfig", ep.scheduleTrigger.retryConfig, {
|
|
142
|
-
retryCount: "number",
|
|
143
|
-
maxDoublings: "number",
|
|
144
|
-
minBackoffDuration: "string",
|
|
145
|
-
maxBackoffDuration: "string",
|
|
146
|
-
maxRetryDuration: "string",
|
|
147
|
-
});
|
|
148
307
|
triggered = { scheduleTrigger: ep.scheduleTrigger };
|
|
149
308
|
}
|
|
150
309
|
else if (backend.isTaskQueueTriggered(ep)) {
|
|
151
|
-
(0, parsing_1.assertKeyTypes)(prefix + ".taskQueueTrigger", ep.taskQueueTrigger, {
|
|
152
|
-
rateLimits: "object",
|
|
153
|
-
retryConfig: "object",
|
|
154
|
-
invoker: "array",
|
|
155
|
-
});
|
|
156
|
-
if (ep.taskQueueTrigger.rateLimits) {
|
|
157
|
-
(0, parsing_1.assertKeyTypes)(prefix + ".taskQueueTrigger.rateLimits", ep.taskQueueTrigger.rateLimits, {
|
|
158
|
-
maxConcurrentDispatches: "number",
|
|
159
|
-
maxDispatchesPerSecond: "number",
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
if (ep.taskQueueTrigger.retryConfig) {
|
|
163
|
-
(0, parsing_1.assertKeyTypes)(prefix + ".taskQueueTrigger.retryConfig", ep.taskQueueTrigger.retryConfig, {
|
|
164
|
-
maxAttempts: "number",
|
|
165
|
-
maxRetrySeconds: "number",
|
|
166
|
-
minBackoffSeconds: "number",
|
|
167
|
-
maxBackoffSeconds: "number",
|
|
168
|
-
maxDoublings: "number",
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
310
|
triggered = { taskQueueTrigger: ep.taskQueueTrigger };
|
|
172
311
|
}
|
|
173
312
|
else if (backend.isBlockingTriggered(ep)) {
|
|
174
|
-
(0, parsing_1.requireKeys)(prefix + ".blockingTrigger", ep.blockingTrigger, "eventType");
|
|
175
|
-
(0, parsing_1.assertKeyTypes)(prefix + ".blockingTrigger", ep.blockingTrigger, {
|
|
176
|
-
eventType: "string",
|
|
177
|
-
options: "object",
|
|
178
|
-
});
|
|
179
313
|
triggered = { blockingTrigger: ep.blockingTrigger };
|
|
180
314
|
}
|
|
181
315
|
else {
|
|
@@ -5,11 +5,9 @@ const util_1 = require("util");
|
|
|
5
5
|
const node_fetch_1 = require("node-fetch");
|
|
6
6
|
const fs = require("fs");
|
|
7
7
|
const path = require("path");
|
|
8
|
-
const portfinder = require("portfinder");
|
|
9
8
|
const spawn = require("cross-spawn");
|
|
10
9
|
const error_1 = require("../../../../error");
|
|
11
10
|
const logger_1 = require("../../../../logger");
|
|
12
|
-
const discovery = require("../discovery");
|
|
13
11
|
const gomod = require("./gomod");
|
|
14
12
|
const VERSION_TO_RUNTIME = {
|
|
15
13
|
"1.13": "go113",
|
|
@@ -105,26 +103,8 @@ class Delegate {
|
|
|
105
103
|
return p;
|
|
106
104
|
});
|
|
107
105
|
}
|
|
108
|
-
async discoverBuild(
|
|
109
|
-
return { requiredAPIs: [], endpoints: {}, params: [] };
|
|
110
|
-
}
|
|
111
|
-
async discoverSpec(configValues, envs) {
|
|
112
|
-
let discovered = await discovery.detectFromYaml(this.sourceDir, this.projectId, this.runtime);
|
|
113
|
-
if (!discovered) {
|
|
114
|
-
const getPort = (0, util_1.promisify)(portfinder.getPort);
|
|
115
|
-
const port = await getPort();
|
|
116
|
-
portfinder.basePort = port + 1;
|
|
117
|
-
const adminPort = await getPort();
|
|
118
|
-
const kill = await this.serve(port, adminPort, envs);
|
|
119
|
-
try {
|
|
120
|
-
discovered = await discovery.detectFromPort(adminPort, this.projectId, this.runtime);
|
|
121
|
-
}
|
|
122
|
-
finally {
|
|
123
|
-
await kill();
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
discovered.environmentVariables = envs;
|
|
127
|
-
return discovered;
|
|
106
|
+
async discoverBuild() {
|
|
107
|
+
return Promise.resolve({ requiredAPIs: [], endpoints: {}, params: [] });
|
|
128
108
|
}
|
|
129
109
|
}
|
|
130
110
|
exports.Delegate = Delegate;
|
|
@@ -85,15 +85,15 @@ class Delegate {
|
|
|
85
85
|
return p;
|
|
86
86
|
});
|
|
87
87
|
}
|
|
88
|
-
async
|
|
88
|
+
async discoverBuild(config, env) {
|
|
89
89
|
if (!semver.valid(this.sdkVersion)) {
|
|
90
90
|
logger_1.logger.debug(`Could not parse firebase-functions version '${this.sdkVersion}' into semver. Falling back to parseTriggers.`);
|
|
91
|
-
return parseTriggers.
|
|
91
|
+
return parseTriggers.discoverBuild(this.projectId, this.sourceDir, this.runtime, config, env);
|
|
92
92
|
}
|
|
93
93
|
if (semver.lt(this.sdkVersion, MIN_FUNCTIONS_SDK_VERSION)) {
|
|
94
94
|
(0, utils_1.logLabeledWarning)("functions", `You are using an old version of firebase-functions SDK (${this.sdkVersion}). ` +
|
|
95
95
|
`Please update firebase-functions SDK to >=${MIN_FUNCTIONS_SDK_VERSION}`);
|
|
96
|
-
return parseTriggers.
|
|
96
|
+
return parseTriggers.discoverBuild(this.projectId, this.sourceDir, this.runtime, config, env);
|
|
97
97
|
}
|
|
98
98
|
let discovered = await discovery.detectFromYaml(this.sourceDir, this.projectId, this.runtime);
|
|
99
99
|
if (!discovered) {
|
|
@@ -107,11 +107,7 @@ class Delegate {
|
|
|
107
107
|
await kill();
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
|
-
discovered.environmentVariables = env;
|
|
111
110
|
return discovered;
|
|
112
111
|
}
|
|
113
|
-
async discoverBuild(config, env) {
|
|
114
|
-
return parseTriggers.discoverBuild(this.projectId, this.sourceDir, this.runtime, config, env);
|
|
115
|
-
}
|
|
116
112
|
}
|
|
117
113
|
exports.Delegate = Delegate;
|