firebase-tools 10.0.1 → 10.1.3
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 +9 -8
- package/lib/accountImporter.js +10 -8
- package/lib/api.js +1 -0
- package/lib/apiv2.js +91 -48
- package/lib/appdistribution/client.js +1 -1
- package/lib/appdistribution/options-parser-util.js +1 -1
- package/lib/archiveDirectory.js +63 -73
- package/lib/auth.js +2 -2
- package/lib/bin/firebase.js +1 -1
- package/lib/command.js +26 -26
- package/lib/commands/appdistribution-distribute.js +4 -4
- package/lib/commands/appdistribution-testers-add.js +2 -2
- package/lib/commands/appdistribution-testers-remove.js +2 -2
- package/lib/commands/apps-android-sha-create.js +2 -2
- package/lib/commands/apps-android-sha-delete.js +2 -2
- package/lib/commands/apps-android-sha-list.js +2 -2
- package/lib/commands/apps-create.js +9 -9
- package/lib/commands/apps-list.js +3 -3
- package/lib/commands/apps-sdkconfig.js +8 -8
- package/lib/commands/auth-export.js +26 -25
- package/lib/commands/auth-import.js +88 -78
- package/lib/commands/database-get.js +1 -1
- package/lib/commands/database-instances-create.js +4 -4
- package/lib/commands/database-instances-list.js +4 -4
- package/lib/commands/database-profile.js +1 -1
- package/lib/commands/database-push.js +1 -1
- package/lib/commands/database-remove.js +2 -2
- package/lib/commands/database-set.js +2 -2
- package/lib/commands/database-settings-get.js +1 -1
- package/lib/commands/database-settings-set.js +1 -1
- package/lib/commands/database-update.js +2 -2
- package/lib/commands/ext-configure.js +3 -3
- package/lib/commands/ext-dev-deprecate.js +4 -4
- package/lib/commands/ext-dev-extension-delete.js +3 -3
- package/lib/commands/ext-dev-init.js +4 -4
- package/lib/commands/ext-dev-list.js +1 -1
- package/lib/commands/ext-dev-publish.js +4 -4
- package/lib/commands/ext-dev-register.js +6 -6
- package/lib/commands/ext-dev-undeprecate.js +4 -4
- package/lib/commands/ext-dev-unpublish.js +3 -3
- package/lib/commands/ext-dev-usage.js +140 -0
- package/lib/commands/ext-export.js +8 -8
- package/lib/commands/ext-info.js +5 -5
- package/lib/commands/ext-install.js +27 -23
- package/lib/commands/ext-list.js +2 -2
- package/lib/commands/ext-sources-create.js +2 -2
- package/lib/commands/ext-uninstall.js +4 -4
- package/lib/commands/ext-update.js +18 -18
- package/lib/commands/ext.js +3 -3
- package/lib/commands/firestore-delete.js +1 -1
- package/lib/commands/functions-config-clone.js +22 -23
- package/lib/commands/functions-config-export.js +11 -11
- package/lib/commands/functions-config-get.js +22 -22
- package/lib/commands/functions-config-set.js +24 -22
- package/lib/commands/functions-config-unset.js +20 -22
- package/lib/commands/functions-delete.js +3 -3
- package/lib/commands/functions-deletegcfartifacts.js +4 -4
- package/lib/commands/functions-list.js +1 -1
- package/lib/commands/functions-log.js +1 -1
- package/lib/commands/help.js +12 -12
- package/lib/commands/hosting-channel-create.js +13 -13
- package/lib/commands/hosting-channel-delete.js +10 -10
- package/lib/commands/hosting-channel-deploy.js +18 -18
- package/lib/commands/hosting-channel-list.js +5 -5
- package/lib/commands/hosting-channel-open.js +9 -9
- package/lib/commands/hosting-clone.js +16 -16
- package/lib/commands/hosting-disable.js +1 -1
- package/lib/commands/hosting-sites-create.js +7 -7
- package/lib/commands/hosting-sites-delete.js +7 -7
- package/lib/commands/hosting-sites-get.js +2 -2
- package/lib/commands/hosting-sites-list.js +3 -3
- package/lib/commands/index.js +1 -0
- package/lib/commands/login-ci.js +10 -10
- package/lib/commands/login.js +2 -2
- package/lib/commands/logout.js +1 -1
- package/lib/commands/open.js +1 -1
- package/lib/commands/projects-addfirebase.js +2 -2
- package/lib/commands/projects-create.js +2 -2
- package/lib/commands/projects-list.js +1 -1
- package/lib/commands/remoteconfig-get.js +3 -3
- package/lib/commands/remoteconfig-rollback.js +3 -3
- package/lib/commands/remoteconfig-versions-list.js +7 -2
- package/lib/commands/setup-emulators-database.js +8 -7
- package/lib/commands/setup-emulators-firestore.js +8 -7
- package/lib/commands/setup-emulators-pubsub.js +5 -4
- package/lib/commands/setup-emulators-storage.js +4 -3
- package/lib/commands/setup-emulators-ui.js +8 -7
- package/lib/commands/target-apply.js +17 -16
- package/lib/commands/target-clear.js +11 -10
- package/lib/commands/target-remove.js +10 -9
- package/lib/commands/target.js +20 -20
- package/lib/config.js +6 -6
- package/lib/database/api.js +2 -2
- package/lib/database/metadata.js +16 -24
- package/lib/defaultCredentials.js +3 -3
- package/lib/deploy/extensions/deploy.js +4 -4
- package/lib/deploy/extensions/deploymentSummary.js +5 -4
- package/lib/deploy/extensions/index.js +1 -0
- package/lib/deploy/extensions/params.js +1 -1
- package/lib/deploy/extensions/planner.js +3 -3
- package/lib/deploy/extensions/prepare.js +9 -9
- package/lib/deploy/extensions/release.js +1 -1
- package/lib/deploy/extensions/secrets.js +7 -7
- package/lib/deploy/extensions/validate.js +2 -2
- package/lib/deploy/functions/backend.js +9 -5
- package/lib/deploy/functions/checkIam.js +7 -7
- package/lib/deploy/functions/containerCleaner.js +3 -3
- package/lib/deploy/functions/deploy.js +4 -4
- package/lib/deploy/functions/ensureCloudBuildEnabled.js +3 -3
- package/lib/deploy/functions/index.js +1 -0
- package/lib/deploy/functions/prepare.js +29 -23
- package/lib/deploy/functions/prompts.js +5 -5
- package/lib/deploy/functions/release/executor.js +4 -1
- package/lib/deploy/functions/release/fabricator.js +9 -6
- package/lib/deploy/functions/release/index.js +2 -2
- package/lib/deploy/functions/release/planner.js +6 -6
- package/lib/deploy/functions/release/reporter.js +8 -4
- package/lib/deploy/functions/runtimes/discovery/index.js +2 -2
- package/lib/deploy/functions/runtimes/discovery/v1alpha1.js +14 -14
- package/lib/deploy/functions/runtimes/golang/index.js +11 -14
- package/lib/deploy/functions/runtimes/index.js +6 -10
- package/lib/deploy/functions/runtimes/node/index.js +6 -10
- package/lib/deploy/functions/runtimes/node/parseTriggers.js +3 -3
- package/lib/deploy/functions/runtimes/node/validate.js +2 -1
- package/lib/deploy/functions/services/storage.js +1 -1
- package/lib/deploy/functions/triggerRegionHelper.js +1 -1
- package/lib/deploy/functions/validate.js +32 -4
- package/lib/deploy/hosting/convertConfig.js +45 -24
- package/lib/deploy/hosting/deploy.js +7 -7
- package/lib/deploy/hosting/prepare.js +1 -1
- package/lib/deploy/hosting/uploader.js +1 -1
- package/lib/deploy/hosting/validate.js +3 -3
- package/lib/deploy/remoteconfig/prepare.js +3 -3
- package/lib/deploy/remoteconfig/release.js +3 -3
- package/lib/deploy/storage/deploy.js +1 -1
- package/lib/deploy/storage/release.js +2 -2
- package/lib/detectProjectRoot.js +5 -5
- package/lib/emulator/auth/apiSpec.js +13 -7
- package/lib/emulator/auth/handlers.js +3 -3
- package/lib/emulator/auth/index.js +1 -1
- package/lib/emulator/auth/operations.js +256 -248
- package/lib/emulator/auth/server.js +11 -8
- package/lib/emulator/auth/state.js +12 -12
- package/lib/emulator/commandUtils.js +5 -5
- package/lib/emulator/controller.js +16 -11
- package/lib/emulator/downloadableEmulators.js +5 -4
- package/lib/emulator/emulatorLogger.js +1 -1
- package/lib/emulator/functionsEmulator.js +110 -75
- package/lib/emulator/functionsEmulatorRuntime.js +36 -21
- package/lib/emulator/functionsEmulatorShell.js +3 -2
- package/lib/emulator/functionsRuntimeWorker.js +1 -1
- package/lib/emulator/hubExport.js +2 -2
- package/lib/emulator/storage/apis/firebase.js +2 -2
- package/lib/emulator/storage/apis/gcloud.js +2 -2
- package/lib/emulator/storage/cloudFunctions.js +1 -1
- package/lib/emulator/storage/files.js +14 -14
- package/lib/emulator/storage/index.js +2 -2
- package/lib/emulator/storage/metadata.js +7 -6
- package/lib/emulator/storage/rules/runtime.js +10 -9
- package/lib/emulator/storage/server.js +2 -2
- package/lib/ensureApiEnabled.js +7 -7
- package/lib/error.js +3 -3
- package/lib/extensions/askUserForConsent.js +3 -4
- package/lib/extensions/askUserForParam.js +11 -11
- package/lib/extensions/billingMigrationHelper.js +2 -2
- package/lib/extensions/changelog.js +4 -4
- package/lib/extensions/displayExtensionInfo.js +6 -6
- package/lib/extensions/emulator/optionsHelper.js +1 -1
- package/lib/extensions/emulator/specHelper.js +1 -1
- package/lib/extensions/emulator/triggerHelper.js +1 -1
- package/lib/extensions/export.js +6 -6
- package/lib/extensions/extensionsApi.js +68 -110
- package/lib/extensions/extensionsHelper.js +56 -43
- package/lib/extensions/listExtensions.js +1 -1
- package/lib/extensions/localHelper.js +1 -1
- package/lib/extensions/metricsTypeDef.js +2 -0
- package/lib/extensions/metricsUtils.js +98 -0
- package/lib/extensions/paramHelper.js +6 -6
- package/lib/extensions/provisioningHelper.js +13 -14
- package/lib/extensions/resolveSource.js +6 -6
- package/lib/extensions/secretsUtils.js +3 -3
- package/lib/extensions/updateHelper.js +10 -10
- package/lib/extensions/utils.js +1 -1
- package/lib/extensions/warnings.js +11 -10
- package/lib/fetchWebSetup.js +2 -2
- package/lib/filterTargets.js +2 -2
- package/lib/firestore/indexes.js +2 -2
- package/lib/fsAsync.js +3 -3
- package/lib/fsutils.js +2 -2
- package/lib/functional.js +2 -1
- package/lib/functions/env.js +1 -1
- package/lib/functions/runtimeConfigExport.js +4 -4
- package/lib/functionsConfig.js +7 -8
- package/lib/functionsShellCommandAction.js +4 -3
- package/lib/gcp/cloudbilling.js +8 -19
- package/lib/gcp/cloudfunctions.js +22 -46
- package/lib/gcp/cloudlogging.js +8 -11
- package/lib/gcp/cloudmonitoring.js +77 -0
- package/lib/gcp/cloudscheduler.js +8 -19
- package/lib/gcp/firedata.js +5 -4
- package/lib/gcp/firestore.js +5 -5
- package/lib/gcp/iam.js +19 -34
- package/lib/gcp/resourceManager.js +10 -15
- package/lib/gcp/rules.js +18 -41
- package/lib/gcp/runtimeconfig.js +31 -53
- package/lib/gcp/secretManager.js +24 -45
- package/lib/gcp/storage.js +24 -29
- package/lib/getDefaultDatabaseInstance.js +1 -1
- package/lib/getDefaultHostingSite.js +1 -1
- package/lib/getProjectNumber.js +2 -2
- package/lib/handlePreviewToggles.js +5 -5
- package/lib/hosting/api.js +6 -6
- package/lib/hosting/cloudRunProxy.js +6 -6
- package/lib/hosting/functionsProxy.js +3 -3
- package/lib/hosting/implicitInit.js +2 -2
- package/lib/hosting/normalizedHostingConfigs.js +3 -3
- package/lib/hosting/proxy.js +2 -2
- package/lib/init/features/account.js +7 -7
- package/lib/init/features/database.js +9 -9
- package/lib/init/features/emulators.js +8 -8
- package/lib/init/features/firestore/index.js +3 -3
- package/lib/init/features/firestore/indexes.js +2 -2
- package/lib/init/features/firestore/rules.js +2 -2
- package/lib/init/features/functions/golang.js +4 -4
- package/lib/init/features/functions/index.js +4 -4
- package/lib/init/features/hosting/github.js +31 -31
- package/lib/init/features/project.js +8 -8
- package/lib/init/features/remoteconfig.js +2 -2
- package/lib/init/features/storage.js +2 -2
- package/lib/listFiles.js +1 -1
- package/lib/management/apps.js +3 -3
- package/lib/management/projects.js +6 -6
- package/lib/previews.js +2 -2
- package/lib/profiler.js +1 -1
- package/lib/projectPath.js +1 -1
- package/lib/projectUtils.js +2 -2
- package/lib/prompt.js +0 -1
- package/lib/rc.js +1 -1
- package/lib/remoteconfig/get.js +14 -8
- package/lib/remoteconfig/rollback.js +13 -6
- package/lib/remoteconfig/versionslist.js +13 -7
- package/lib/requireAuth.js +2 -2
- package/lib/requireDatabaseInstance.js +1 -1
- package/lib/requireHostingSite.js +1 -1
- package/lib/requirePermissions.js +4 -4
- package/lib/rulesDeploy.js +2 -2
- package/lib/serve/functions.js +14 -7
- package/lib/serve/hosting.js +7 -7
- package/lib/utils.js +3 -2
- package/npm-shrinkwrap.json +24090 -0
- package/package.json +36 -31
- package/schema/firebase-config.json +387 -12
- package/lib/commands/functions-config-legacy.js +0 -45
- package/lib/prepareFirebaseRules.js +0 -58
|
@@ -85,7 +85,7 @@ function printErrors(summary) {
|
|
|
85
85
|
logger_1.logger.info("Functions deploy had errors with the following functions:" +
|
|
86
86
|
errored
|
|
87
87
|
.filter((r) => !(r.error instanceof AbortedDeploymentError))
|
|
88
|
-
.map((result) => `\n\t${functionsDeployHelper_1.getFunctionLabel(result.endpoint)}`)
|
|
88
|
+
.map((result) => `\n\t${(0, functionsDeployHelper_1.getFunctionLabel)(result.endpoint)}`)
|
|
89
89
|
.join(""));
|
|
90
90
|
printIamErrors(errored);
|
|
91
91
|
printQuotaErrors(errored);
|
|
@@ -99,7 +99,7 @@ function printIamErrors(results) {
|
|
|
99
99
|
}
|
|
100
100
|
logger_1.logger.info("");
|
|
101
101
|
logger_1.logger.info("Unable to set the invoker for the IAM policy on the following functions:" +
|
|
102
|
-
iamFailures.map((result) => `\n\t${functionsDeployHelper_1.getFunctionLabel(result.endpoint)}`).join(""));
|
|
102
|
+
iamFailures.map((result) => `\n\t${(0, functionsDeployHelper_1.getFunctionLabel)(result.endpoint)}`).join(""));
|
|
103
103
|
logger_1.logger.info("");
|
|
104
104
|
logger_1.logger.info("Some common causes of this:");
|
|
105
105
|
logger_1.logger.info("");
|
|
@@ -124,7 +124,11 @@ function printQuotaErrors(results) {
|
|
|
124
124
|
return false;
|
|
125
125
|
}
|
|
126
126
|
const original = r.error.original;
|
|
127
|
-
const code = (original === null || original === void 0 ? void 0 : original.status) ||
|
|
127
|
+
const code = (original === null || original === void 0 ? void 0 : original.status) ||
|
|
128
|
+
(original === null || original === void 0 ? void 0 : original.code) ||
|
|
129
|
+
((_b = (_a = original === null || original === void 0 ? void 0 : original.context) === null || _a === void 0 ? void 0 : _a.response) === null || _b === void 0 ? void 0 : _b.statusCode) ||
|
|
130
|
+
((_c = original === null || original === void 0 ? void 0 : original.original) === null || _c === void 0 ? void 0 : _c.code) ||
|
|
131
|
+
((_f = (_e = (_d = original === null || original === void 0 ? void 0 : original.original) === null || _d === void 0 ? void 0 : _d.context) === null || _e === void 0 ? void 0 : _e.response) === null || _f === void 0 ? void 0 : _f.statusCode);
|
|
128
132
|
return code === 429 || code === 409;
|
|
129
133
|
});
|
|
130
134
|
if (!hadQuotaError) {
|
|
@@ -145,7 +149,7 @@ function printAbortedErrors(results) {
|
|
|
145
149
|
logger_1.logger.info("");
|
|
146
150
|
logger_1.logger.info("Because there were errors creating or updating functions, the following " +
|
|
147
151
|
"functions were not deleted" +
|
|
148
|
-
aborted.map((result) => `\n\t${functionsDeployHelper_1.getFunctionLabel(result.endpoint)}`).join(""));
|
|
152
|
+
aborted.map((result) => `\n\t${(0, functionsDeployHelper_1.getFunctionLabel)(result.endpoint)}`).join(""));
|
|
149
153
|
logger_1.logger.info(`To delete these, use ${clc.bold("firebase functions:delete")}`);
|
|
150
154
|
}
|
|
151
155
|
exports.printAbortedErrors = printAbortedErrors;
|
|
@@ -10,7 +10,7 @@ const logger_1 = require("../../../../logger");
|
|
|
10
10
|
const api = require("../../.../../../../api");
|
|
11
11
|
const v1alpha1 = require("./v1alpha1");
|
|
12
12
|
const error_1 = require("../../../../error");
|
|
13
|
-
exports.readFileAsync = util_1.promisify(fs.readFile);
|
|
13
|
+
exports.readFileAsync = (0, util_1.promisify)(fs.readFile);
|
|
14
14
|
function yamlToBackend(yaml, project, region, runtime) {
|
|
15
15
|
try {
|
|
16
16
|
if (!yaml.specVersion) {
|
|
@@ -54,7 +54,7 @@ async function detectFromPort(port, project, runtime, timeout = 30000) {
|
|
|
54
54
|
});
|
|
55
55
|
while (true) {
|
|
56
56
|
try {
|
|
57
|
-
res = await Promise.race([node_fetch_1.default(`http://localhost:${port}/backend.yaml`), timedOut]);
|
|
57
|
+
res = await Promise.race([(0, node_fetch_1.default)(`http://localhost:${port}/backend.yaml`), timedOut]);
|
|
58
58
|
break;
|
|
59
59
|
}
|
|
60
60
|
catch (err) {
|
|
@@ -9,8 +9,8 @@ function backendFromV1Alpha1(yaml, project, region, runtime) {
|
|
|
9
9
|
const manifest = JSON.parse(JSON.stringify(yaml));
|
|
10
10
|
const bkend = backend.empty();
|
|
11
11
|
bkend.requiredAPIs = parseRequiredAPIs(manifest);
|
|
12
|
-
parsing_1.requireKeys("", manifest, "endpoints");
|
|
13
|
-
parsing_1.assertKeyTypes("", manifest, {
|
|
12
|
+
(0, parsing_1.requireKeys)("", manifest, "endpoints");
|
|
13
|
+
(0, parsing_1.assertKeyTypes)("", manifest, {
|
|
14
14
|
specVersion: "string",
|
|
15
15
|
requiredAPIs: "object",
|
|
16
16
|
endpoints: "object",
|
|
@@ -41,7 +41,7 @@ function parseEndpoints(manifest, id, project, defaultRegion, runtime) {
|
|
|
41
41
|
const allParsed = [];
|
|
42
42
|
const prefix = `endpoints[${id}]`;
|
|
43
43
|
const ep = manifest.endpoints[id];
|
|
44
|
-
parsing_1.assertKeyTypes(prefix, ep, {
|
|
44
|
+
(0, parsing_1.assertKeyTypes)(prefix, ep, {
|
|
45
45
|
region: "array",
|
|
46
46
|
platform: "string",
|
|
47
47
|
entryPoint: "string",
|
|
@@ -83,8 +83,8 @@ function parseEndpoints(manifest, id, project, defaultRegion, runtime) {
|
|
|
83
83
|
for (const region of ep.region || [defaultRegion]) {
|
|
84
84
|
let triggered;
|
|
85
85
|
if (backend.isEventTriggered(ep)) {
|
|
86
|
-
parsing_1.requireKeys(prefix + ".eventTrigger", ep.eventTrigger, "eventType", "eventFilters");
|
|
87
|
-
parsing_1.assertKeyTypes(prefix + ".eventTrigger", ep.eventTrigger, {
|
|
86
|
+
(0, parsing_1.requireKeys)(prefix + ".eventTrigger", ep.eventTrigger, "eventType", "eventFilters");
|
|
87
|
+
(0, parsing_1.assertKeyTypes)(prefix + ".eventTrigger", ep.eventTrigger, {
|
|
88
88
|
eventFilters: "object",
|
|
89
89
|
eventType: "string",
|
|
90
90
|
retry: "boolean",
|
|
@@ -94,19 +94,19 @@ function parseEndpoints(manifest, id, project, defaultRegion, runtime) {
|
|
|
94
94
|
triggered = { eventTrigger: ep.eventTrigger };
|
|
95
95
|
}
|
|
96
96
|
else if (backend.isHttpsTriggered(ep)) {
|
|
97
|
-
parsing_1.assertKeyTypes(prefix + ".httpsTrigger", ep.httpsTrigger, {
|
|
97
|
+
(0, parsing_1.assertKeyTypes)(prefix + ".httpsTrigger", ep.httpsTrigger, {
|
|
98
98
|
invoker: "array",
|
|
99
99
|
});
|
|
100
100
|
triggered = { httpsTrigger: {} };
|
|
101
|
-
proto_1.copyIfPresent(triggered.httpsTrigger, ep.httpsTrigger, "invoker");
|
|
101
|
+
(0, proto_1.copyIfPresent)(triggered.httpsTrigger, ep.httpsTrigger, "invoker");
|
|
102
102
|
}
|
|
103
103
|
else if (backend.isScheduleTriggered(ep)) {
|
|
104
|
-
parsing_1.assertKeyTypes(prefix + ".scheduleTrigger", ep.scheduleTrigger, {
|
|
104
|
+
(0, parsing_1.assertKeyTypes)(prefix + ".scheduleTrigger", ep.scheduleTrigger, {
|
|
105
105
|
schedule: "string",
|
|
106
106
|
timeZone: "string",
|
|
107
107
|
retryConfig: "object",
|
|
108
108
|
});
|
|
109
|
-
parsing_1.assertKeyTypes(prefix + ".scheduleTrigger.retryConfig", ep.scheduleTrigger.retryConfig, {
|
|
109
|
+
(0, parsing_1.assertKeyTypes)(prefix + ".scheduleTrigger.retryConfig", ep.scheduleTrigger.retryConfig, {
|
|
110
110
|
retryCount: "number",
|
|
111
111
|
maxDoublings: "number",
|
|
112
112
|
minBackoffDuration: "string",
|
|
@@ -116,20 +116,20 @@ function parseEndpoints(manifest, id, project, defaultRegion, runtime) {
|
|
|
116
116
|
triggered = { scheduleTrigger: ep.scheduleTrigger };
|
|
117
117
|
}
|
|
118
118
|
else if (backend.isTaskQueueTriggered(ep)) {
|
|
119
|
-
parsing_1.assertKeyTypes(prefix + ".taskQueueTrigger", ep.taskQueueTrigger, {
|
|
119
|
+
(0, parsing_1.assertKeyTypes)(prefix + ".taskQueueTrigger", ep.taskQueueTrigger, {
|
|
120
120
|
rateLimits: "object",
|
|
121
121
|
retryConfig: "object",
|
|
122
122
|
invoker: "array",
|
|
123
123
|
});
|
|
124
124
|
if (ep.taskQueueTrigger.rateLimits) {
|
|
125
|
-
parsing_1.assertKeyTypes(prefix + ".taskQueueTrigger.rateLimits", ep.taskQueueTrigger.rateLimits, {
|
|
125
|
+
(0, parsing_1.assertKeyTypes)(prefix + ".taskQueueTrigger.rateLimits", ep.taskQueueTrigger.rateLimits, {
|
|
126
126
|
maxBurstSize: "number",
|
|
127
127
|
maxConcurrentDispatches: "number",
|
|
128
128
|
maxDispatchesPerSecond: "number",
|
|
129
129
|
});
|
|
130
130
|
}
|
|
131
131
|
if (ep.taskQueueTrigger.retryConfig) {
|
|
132
|
-
parsing_1.assertKeyTypes(prefix + ".taskQueueTrigger.retryConfig", ep.taskQueueTrigger.retryConfig, {
|
|
132
|
+
(0, parsing_1.assertKeyTypes)(prefix + ".taskQueueTrigger.retryConfig", ep.taskQueueTrigger.retryConfig, {
|
|
133
133
|
maxAttempts: "number",
|
|
134
134
|
maxRetryDuration: "string",
|
|
135
135
|
minBackoff: "string",
|
|
@@ -143,12 +143,12 @@ function parseEndpoints(manifest, id, project, defaultRegion, runtime) {
|
|
|
143
143
|
throw new error_1.FirebaseError(`Do not recognize trigger type for endpoint ${id}. Try upgrading ` +
|
|
144
144
|
"firebase-tools with npm install -g firebase-tools@latest");
|
|
145
145
|
}
|
|
146
|
-
parsing_1.requireKeys(prefix, ep, "entryPoint");
|
|
146
|
+
(0, parsing_1.requireKeys)(prefix, ep, "entryPoint");
|
|
147
147
|
const parsed = Object.assign({ platform: ep.platform || "gcfv2", id,
|
|
148
148
|
region,
|
|
149
149
|
project,
|
|
150
150
|
runtime, entryPoint: ep.entryPoint }, triggered);
|
|
151
|
-
proto_1.copyIfPresent(parsed, ep, "availableMemoryMb", "maxInstances", "minInstances", "concurrency", "serviceAccountEmail", "timeout", "vpcConnector", "vpcConnectorEgressSettings", "labels", "ingressSettings", "environmentVariables");
|
|
151
|
+
(0, proto_1.copyIfPresent)(parsed, ep, "availableMemoryMb", "maxInstances", "minInstances", "concurrency", "serviceAccountEmail", "timeout", "vpcConnector", "vpcConnectorEgressSettings", "labels", "ingressSettings", "environmentVariables");
|
|
152
152
|
allParsed.push(parsed);
|
|
153
153
|
}
|
|
154
154
|
return allParsed;
|
|
@@ -10,7 +10,6 @@ const spawn = require("cross-spawn");
|
|
|
10
10
|
const error_1 = require("../../../../error");
|
|
11
11
|
const logger_1 = require("../../../../logger");
|
|
12
12
|
const discovery = require("../discovery");
|
|
13
|
-
const projectUtils_1 = require("../../../../projectUtils");
|
|
14
13
|
const gomod = require("./gomod");
|
|
15
14
|
const VERSION_TO_RUNTIME = {
|
|
16
15
|
"1.13": "go113",
|
|
@@ -19,21 +18,18 @@ exports.ADMIN_SDK = "firebase.google.com/go/v4";
|
|
|
19
18
|
exports.FUNCTIONS_SDK = "github.com/FirebaseExtended/firebase-functions-go";
|
|
20
19
|
exports.FUNCTIONS_CODEGEN = exports.FUNCTIONS_SDK + "/support/codegen";
|
|
21
20
|
exports.FUNCTIONS_RUNTIME = exports.FUNCTIONS_SDK + "/support/runtime";
|
|
22
|
-
async function tryCreateDelegate(context
|
|
23
|
-
const
|
|
24
|
-
const sourceDir = options.config.path(relativeSourceDir);
|
|
25
|
-
const goModPath = path.join(sourceDir, "go.mod");
|
|
26
|
-
const projectId = projectUtils_1.needProjectId(options);
|
|
21
|
+
async function tryCreateDelegate(context) {
|
|
22
|
+
const goModPath = path.join(context.sourceDir, "go.mod");
|
|
27
23
|
let module;
|
|
28
24
|
try {
|
|
29
|
-
const modBuffer = await util_1.promisify(fs.readFile)(goModPath);
|
|
25
|
+
const modBuffer = await (0, util_1.promisify)(fs.readFile)(goModPath);
|
|
30
26
|
module = gomod.parseModule(modBuffer.toString("utf8"));
|
|
31
27
|
}
|
|
32
28
|
catch (err) {
|
|
33
29
|
logger_1.logger.debug("Customer code is not Golang code (or they aren't using gomod)");
|
|
34
30
|
return;
|
|
35
31
|
}
|
|
36
|
-
let runtime =
|
|
32
|
+
let runtime = context.runtime;
|
|
37
33
|
if (!runtime) {
|
|
38
34
|
if (!module.version) {
|
|
39
35
|
throw new error_1.FirebaseError("Could not detect Golang version from go.mod");
|
|
@@ -43,7 +39,7 @@ async function tryCreateDelegate(context, options) {
|
|
|
43
39
|
}
|
|
44
40
|
runtime = VERSION_TO_RUNTIME[module.version];
|
|
45
41
|
}
|
|
46
|
-
return new Delegate(projectId, sourceDir, runtime, module);
|
|
42
|
+
return new Delegate(context.projectId, context.sourceDir, runtime, module);
|
|
47
43
|
}
|
|
48
44
|
exports.tryCreateDelegate = tryCreateDelegate;
|
|
49
45
|
class Delegate {
|
|
@@ -59,7 +55,7 @@ class Delegate {
|
|
|
59
55
|
}
|
|
60
56
|
async build() {
|
|
61
57
|
try {
|
|
62
|
-
await util_1.promisify(fs.mkdir)(path.join(this.sourceDir, "autogen"));
|
|
58
|
+
await (0, util_1.promisify)(fs.mkdir)(path.join(this.sourceDir, "autogen"));
|
|
63
59
|
}
|
|
64
60
|
catch (err) {
|
|
65
61
|
if ((err === null || err === void 0 ? void 0 : err.code) !== "EEXIST") {
|
|
@@ -80,18 +76,19 @@ class Delegate {
|
|
|
80
76
|
children: [new Error(genBinary.stderr.toString())],
|
|
81
77
|
});
|
|
82
78
|
}
|
|
83
|
-
await util_1.promisify(fs.writeFile)(path.join(this.sourceDir, "autogen", "main.go"), genBinary.stdout);
|
|
79
|
+
await (0, util_1.promisify)(fs.writeFile)(path.join(this.sourceDir, "autogen", "main.go"), genBinary.stdout);
|
|
84
80
|
}
|
|
85
81
|
watch() {
|
|
86
82
|
return Promise.resolve(() => Promise.resolve());
|
|
87
83
|
}
|
|
88
84
|
serve(port, adminPort, envs) {
|
|
85
|
+
var _a;
|
|
89
86
|
const childProcess = spawn("go", ["run", "./autogen"], {
|
|
90
87
|
env: Object.assign(Object.assign({}, envs), { PORT: port.toString(), ADMIN_PORT: adminPort.toString(), HOME: process.env.HOME, PATH: process.env.PATH, GOPATH: process.env.GOPATH }),
|
|
91
88
|
cwd: this.sourceDir,
|
|
92
89
|
stdio: ["ignore", "pipe", "inherit"],
|
|
93
90
|
});
|
|
94
|
-
childProcess.stdout.on("data", (chunk) => {
|
|
91
|
+
(_a = childProcess.stdout) === null || _a === void 0 ? void 0 : _a.on("data", (chunk) => {
|
|
95
92
|
logger_1.logger.debug(chunk.toString());
|
|
96
93
|
});
|
|
97
94
|
return Promise.resolve(async () => {
|
|
@@ -99,7 +96,7 @@ class Delegate {
|
|
|
99
96
|
childProcess.once("exit", resolve);
|
|
100
97
|
childProcess.once("error", reject);
|
|
101
98
|
});
|
|
102
|
-
await node_fetch_1.default(`http://localhost:${adminPort}/quitquitquit`);
|
|
99
|
+
await (0, node_fetch_1.default)(`http://localhost:${adminPort}/quitquitquit`);
|
|
103
100
|
setTimeout(() => {
|
|
104
101
|
if (!childProcess.killed) {
|
|
105
102
|
childProcess.kill("SIGKILL");
|
|
@@ -111,7 +108,7 @@ class Delegate {
|
|
|
111
108
|
async discoverSpec(configValues, envs) {
|
|
112
109
|
let discovered = await discovery.detectFromYaml(this.sourceDir, this.projectId, this.runtime);
|
|
113
110
|
if (!discovered) {
|
|
114
|
-
const getPort = util_1.promisify(portfinder.getPort);
|
|
111
|
+
const getPort = (0, util_1.promisify)(portfinder.getPort);
|
|
115
112
|
const port = await getPort();
|
|
116
113
|
portfinder.basePort = port + 1;
|
|
117
114
|
const adminPort = await getPort();
|
|
@@ -30,22 +30,18 @@ function getHumanFriendlyRuntimeName(runtime) {
|
|
|
30
30
|
}
|
|
31
31
|
exports.getHumanFriendlyRuntimeName = getHumanFriendlyRuntimeName;
|
|
32
32
|
const factories = [node.tryCreateDelegate, golang.tryCreateDelegate];
|
|
33
|
-
async function getRuntimeDelegate(context
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
throw new error_1.FirebaseError(`No functions code detected at default location (./functions), and no functions.source defined in firebase.json`);
|
|
37
|
-
}
|
|
38
|
-
validate.functionsDirectoryExists(options, sourceDirName);
|
|
39
|
-
const runtime = options.config.get("functions.runtime");
|
|
33
|
+
async function getRuntimeDelegate(context) {
|
|
34
|
+
const { projectDir, sourceDir, runtime } = context;
|
|
35
|
+
validate.functionsDirectoryExists(sourceDir, projectDir);
|
|
40
36
|
if (runtime && !isValidRuntime(runtime)) {
|
|
41
|
-
throw new error_1.FirebaseError(
|
|
37
|
+
throw new error_1.FirebaseError(`Cannot deploy function with runtime ${runtime}`);
|
|
42
38
|
}
|
|
43
39
|
for (const factory of factories) {
|
|
44
|
-
const delegate = await factory(context
|
|
40
|
+
const delegate = await factory(context);
|
|
45
41
|
if (delegate) {
|
|
46
42
|
return delegate;
|
|
47
43
|
}
|
|
48
44
|
}
|
|
49
|
-
throw new error_1.FirebaseError(`Could not detect language for functions at ${
|
|
45
|
+
throw new error_1.FirebaseError(`Could not detect language for functions at ${sourceDir}`);
|
|
50
46
|
}
|
|
51
47
|
exports.getRuntimeDelegate = getRuntimeDelegate;
|
|
@@ -6,26 +6,22 @@ const fs = require("fs");
|
|
|
6
6
|
const path = require("path");
|
|
7
7
|
const error_1 = require("../../../../error");
|
|
8
8
|
const parseRuntimeAndValidateSDK_1 = require("./parseRuntimeAndValidateSDK");
|
|
9
|
-
const projectUtils_1 = require("../../../../projectUtils");
|
|
10
|
-
const validate = require("./validate");
|
|
11
9
|
const logger_1 = require("../../../../logger");
|
|
10
|
+
const validate = require("./validate");
|
|
12
11
|
const versioning = require("./versioning");
|
|
13
12
|
const parseTriggers = require("./parseTriggers");
|
|
14
|
-
async function tryCreateDelegate(context
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
const packageJsonPath = path.join(sourceDir, "package.json");
|
|
18
|
-
if (!(await util_1.promisify(fs.exists)(packageJsonPath))) {
|
|
13
|
+
async function tryCreateDelegate(context) {
|
|
14
|
+
const packageJsonPath = path.join(context.sourceDir, "package.json");
|
|
15
|
+
if (!(await (0, util_1.promisify)(fs.exists)(packageJsonPath))) {
|
|
19
16
|
logger_1.logger.debug("Customer code is not Node");
|
|
20
17
|
return undefined;
|
|
21
18
|
}
|
|
22
|
-
|
|
23
|
-
runtime = parseRuntimeAndValidateSDK_1.getRuntimeChoice(sourceDir, runtime);
|
|
19
|
+
const runtime = (0, parseRuntimeAndValidateSDK_1.getRuntimeChoice)(context.sourceDir, context.runtime);
|
|
24
20
|
if (!runtime.startsWith("nodejs")) {
|
|
25
21
|
logger_1.logger.debug("Customer has a package.json but did not get a nodejs runtime. This should not happen");
|
|
26
22
|
throw new error_1.FirebaseError(`Unexpected runtime ${runtime}`);
|
|
27
23
|
}
|
|
28
|
-
return new Delegate(
|
|
24
|
+
return new Delegate(context.projectId, context.projectDir, context.sourceDir, runtime);
|
|
29
25
|
}
|
|
30
26
|
exports.tryCreateDelegate = tryCreateDelegate;
|
|
31
27
|
class Delegate {
|
|
@@ -25,7 +25,7 @@ function parseTriggers(projectId, sourceDir, configValues, envs) {
|
|
|
25
25
|
if (env.NODE_OPTIONS) {
|
|
26
26
|
env.NODE_OPTIONS = removeInspectOptions(env.NODE_OPTIONS.split(" ")).join(" ");
|
|
27
27
|
}
|
|
28
|
-
const parser = child_process_1.fork(TRIGGER_PARSER, [sourceDir], {
|
|
28
|
+
const parser = (0, child_process_1.fork)(TRIGGER_PARSER, [sourceDir], {
|
|
29
29
|
silent: true,
|
|
30
30
|
env: env,
|
|
31
31
|
execArgv: execArgv,
|
|
@@ -100,9 +100,9 @@ function addResourcesToBackend(projectId, runtime, annotation, want) {
|
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
102
|
const endpoint = Object.assign({ platform: annotation.platform || "gcfv1", id: annotation.name, region: region, project: projectId, entryPoint: annotation.entryPoint, runtime: runtime }, triggered);
|
|
103
|
-
if (annotation.vpcConnector) {
|
|
103
|
+
if (annotation.vpcConnector != null) {
|
|
104
104
|
let maybeId = annotation.vpcConnector;
|
|
105
|
-
if (!maybeId.includes("/")) {
|
|
105
|
+
if (maybeId && !maybeId.includes("/")) {
|
|
106
106
|
maybeId = `projects/${projectId}/locations/${region}/connectors/${maybeId}`;
|
|
107
107
|
}
|
|
108
108
|
endpoint.vpcConnector = maybeId;
|
|
@@ -9,7 +9,8 @@ const cjson = require("cjson");
|
|
|
9
9
|
function assertFunctionsSourcePresent(data, sourceDir, projectDir) {
|
|
10
10
|
const indexJsFile = path.join(sourceDir, data.main || "index.js");
|
|
11
11
|
if (!fsutils.fileExistsSync(indexJsFile)) {
|
|
12
|
-
const
|
|
12
|
+
const relativeMainPath = path.relative(projectDir, indexJsFile);
|
|
13
|
+
const msg = `${relativeMainPath} does not exist, can't deploy Cloud Functions`;
|
|
13
14
|
throw new error_1.FirebaseError(msg);
|
|
14
15
|
}
|
|
15
16
|
}
|
|
@@ -36,7 +36,7 @@ async function ensureStorageTriggerRegion(endpoint, eventTrigger) {
|
|
|
36
36
|
}
|
|
37
37
|
if (endpoint.region !== eventTrigger.region &&
|
|
38
38
|
eventTrigger.region !== "us-central1" &&
|
|
39
|
-
!location_1.regionInLocation(endpoint.region, eventTrigger.region)) {
|
|
39
|
+
!(0, location_1.regionInLocation)(endpoint.region, eventTrigger.region)) {
|
|
40
40
|
throw new error_1.FirebaseError(`A function in region ${endpoint.region} cannot listen to a bucket in region ${eventTrigger.region}`);
|
|
41
41
|
}
|
|
42
42
|
}
|
|
@@ -9,7 +9,7 @@ async function ensureTriggerRegions(want) {
|
|
|
9
9
|
if (ep.platform === "gcfv1" || !backend.isEventTriggered(ep)) {
|
|
10
10
|
continue;
|
|
11
11
|
}
|
|
12
|
-
regionLookups.push(services_1.serviceForEndpoint(ep).ensureTriggerRegion(ep, ep.eventTrigger));
|
|
12
|
+
regionLookups.push((0, services_1.serviceForEndpoint)(ep).ensureTriggerRegion(ep, ep.eventTrigger));
|
|
13
13
|
}
|
|
14
14
|
await Promise.all(regionLookups);
|
|
15
15
|
}
|
|
@@ -1,12 +1,40 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.functionIdsAreValid = exports.functionsDirectoryExists = void 0;
|
|
3
|
+
exports.functionIdsAreValid = exports.functionsDirectoryExists = exports.endpointsAreValid = void 0;
|
|
4
|
+
const path = require("path");
|
|
4
5
|
const clc = require("cli-color");
|
|
5
6
|
const error_1 = require("../../error");
|
|
6
7
|
const fsutils = require("../../fsutils");
|
|
7
|
-
const
|
|
8
|
-
function
|
|
9
|
-
|
|
8
|
+
const backend = require("./backend");
|
|
9
|
+
function endpointsAreValid(wantBackend) {
|
|
10
|
+
functionIdsAreValid(backend.allEndpoints(wantBackend));
|
|
11
|
+
const gcfV1WithConcurrency = backend
|
|
12
|
+
.allEndpoints(wantBackend)
|
|
13
|
+
.filter((endpoint) => (endpoint.concurrency || 1) != 1 && endpoint.platform == "gcfv1")
|
|
14
|
+
.map((endpoint) => endpoint.id);
|
|
15
|
+
if (gcfV1WithConcurrency.length) {
|
|
16
|
+
const msg = `Cannot set concurrency on the functions ${gcfV1WithConcurrency.join(",")} because they are GCF gen 1`;
|
|
17
|
+
throw new error_1.FirebaseError(msg);
|
|
18
|
+
}
|
|
19
|
+
const tooSmallForConcurrency = backend
|
|
20
|
+
.allEndpoints(wantBackend)
|
|
21
|
+
.filter((endpoint) => {
|
|
22
|
+
if ((endpoint.concurrency || 1) == 1) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
const mem = endpoint.availableMemoryMb || backend.DEFAULT_MEMORY;
|
|
26
|
+
return mem < backend.MIN_MEMORY_FOR_CONCURRENCY;
|
|
27
|
+
})
|
|
28
|
+
.map((endpoint) => endpoint.id);
|
|
29
|
+
if (tooSmallForConcurrency.length) {
|
|
30
|
+
const msg = `Cannot set concurency on the functions ${tooSmallForConcurrency.join(",")} because they have fewer than 2GB memory`;
|
|
31
|
+
throw new error_1.FirebaseError(msg);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.endpointsAreValid = endpointsAreValid;
|
|
35
|
+
function functionsDirectoryExists(sourceDir, projectDir) {
|
|
36
|
+
if (!fsutils.dirExistsSync(sourceDir)) {
|
|
37
|
+
const sourceDirName = path.relative(projectDir, sourceDir);
|
|
10
38
|
const msg = `could not deploy functions because the ${clc.bold('"' + sourceDirName + '"')} ` +
|
|
11
39
|
`directory was not found. Please create it or specify a different source directory in firebase.json`;
|
|
12
40
|
throw new error_1.FirebaseError(msg);
|
|
@@ -1,11 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.convertConfig = void 0;
|
|
4
|
+
const error_1 = require("../../error");
|
|
5
|
+
function has(obj, k) {
|
|
6
|
+
return obj[k] !== undefined;
|
|
7
|
+
}
|
|
4
8
|
function extractPattern(type, spec) {
|
|
5
|
-
|
|
6
|
-
|
|
9
|
+
let glob = "";
|
|
10
|
+
let regex = "";
|
|
11
|
+
if ("source" in spec) {
|
|
12
|
+
glob = spec.source;
|
|
13
|
+
}
|
|
14
|
+
if ("glob" in spec) {
|
|
15
|
+
glob = spec.glob;
|
|
16
|
+
}
|
|
17
|
+
if ("regex" in spec) {
|
|
18
|
+
regex = spec.regex;
|
|
19
|
+
}
|
|
7
20
|
if (glob && regex) {
|
|
8
|
-
throw new FirebaseError(
|
|
21
|
+
throw new error_1.FirebaseError(`Cannot specify a ${type} pattern with both a glob and regex.`);
|
|
9
22
|
}
|
|
10
23
|
else if (glob) {
|
|
11
24
|
return { glob: glob };
|
|
@@ -13,33 +26,38 @@ function extractPattern(type, spec) {
|
|
|
13
26
|
else if (regex) {
|
|
14
27
|
return { regex: regex };
|
|
15
28
|
}
|
|
16
|
-
throw new FirebaseError(
|
|
29
|
+
throw new error_1.FirebaseError(`Cannot specify a ${type} with no pattern (either a glob or regex required).`);
|
|
17
30
|
}
|
|
18
|
-
|
|
31
|
+
function convertConfig(config) {
|
|
32
|
+
if (Array.isArray(config)) {
|
|
33
|
+
throw new error_1.FirebaseError(`convertConfig should be given a single configuration, not an array.`, {
|
|
34
|
+
exit: 2,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
19
37
|
const out = {};
|
|
20
38
|
if (!config) {
|
|
21
39
|
return out;
|
|
22
40
|
}
|
|
23
|
-
if (
|
|
24
|
-
out.rewrites = config.rewrites.map(
|
|
41
|
+
if (Array.isArray(config.rewrites)) {
|
|
42
|
+
out.rewrites = config.rewrites.map((rewrite) => {
|
|
25
43
|
const vRewrite = extractPattern("rewrite", rewrite);
|
|
26
|
-
if (rewrite
|
|
44
|
+
if ("destination" in rewrite) {
|
|
27
45
|
vRewrite.path = rewrite.destination;
|
|
28
46
|
}
|
|
29
|
-
else if (rewrite
|
|
47
|
+
else if ("function" in rewrite) {
|
|
30
48
|
vRewrite.function = rewrite.function;
|
|
31
49
|
}
|
|
32
|
-
else if (rewrite
|
|
50
|
+
else if ("dynamicLinks" in rewrite) {
|
|
33
51
|
vRewrite.dynamicLinks = rewrite.dynamicLinks;
|
|
34
52
|
}
|
|
35
|
-
else if (rewrite
|
|
53
|
+
else if ("run" in rewrite) {
|
|
36
54
|
vRewrite.run = Object.assign({ region: "us-central1" }, rewrite.run);
|
|
37
55
|
}
|
|
38
56
|
return vRewrite;
|
|
39
57
|
});
|
|
40
58
|
}
|
|
41
|
-
if (
|
|
42
|
-
out.redirects = config.redirects.map(
|
|
59
|
+
if (Array.isArray(config.redirects)) {
|
|
60
|
+
out.redirects = config.redirects.map((redirect) => {
|
|
43
61
|
const vRedirect = extractPattern("redirect", redirect);
|
|
44
62
|
vRedirect.location = redirect.destination;
|
|
45
63
|
if (redirect.type) {
|
|
@@ -48,17 +66,19 @@ module.exports = function (config) {
|
|
|
48
66
|
return vRedirect;
|
|
49
67
|
});
|
|
50
68
|
}
|
|
51
|
-
if (
|
|
52
|
-
out.headers = config.headers.map(
|
|
69
|
+
if (Array.isArray(config.headers)) {
|
|
70
|
+
out.headers = config.headers.map((header) => {
|
|
53
71
|
const vHeader = extractPattern("header", header);
|
|
54
72
|
vHeader.headers = {};
|
|
55
|
-
(header.headers
|
|
56
|
-
|
|
57
|
-
|
|
73
|
+
if (Array.isArray(header.headers) && header.headers.length) {
|
|
74
|
+
header.headers.forEach((h) => {
|
|
75
|
+
vHeader.headers[h.key] = h.value;
|
|
76
|
+
});
|
|
77
|
+
}
|
|
58
78
|
return vHeader;
|
|
59
79
|
});
|
|
60
80
|
}
|
|
61
|
-
if (
|
|
81
|
+
if (has(config, "cleanUrls")) {
|
|
62
82
|
out.cleanUrls = config.cleanUrls;
|
|
63
83
|
}
|
|
64
84
|
if (config.trailingSlash === true) {
|
|
@@ -67,11 +87,12 @@ module.exports = function (config) {
|
|
|
67
87
|
else if (config.trailingSlash === false) {
|
|
68
88
|
out.trailingSlashBehavior = "REMOVE";
|
|
69
89
|
}
|
|
70
|
-
if (
|
|
90
|
+
if (has(config, "appAssociation")) {
|
|
71
91
|
out.appAssociation = config.appAssociation;
|
|
72
92
|
}
|
|
73
|
-
if (
|
|
93
|
+
if (has(config, "i18n")) {
|
|
74
94
|
out.i18n = config.i18n;
|
|
75
95
|
}
|
|
76
96
|
return out;
|
|
77
|
-
}
|
|
97
|
+
}
|
|
98
|
+
exports.convertConfig = convertConfig;
|
|
@@ -18,7 +18,7 @@ async function deploy(context, options) {
|
|
|
18
18
|
let spins = 0;
|
|
19
19
|
function updateSpinner(newMessage, debugging) {
|
|
20
20
|
if (debugging) {
|
|
21
|
-
utils_1.logLabeledBullet("hosting", newMessage);
|
|
21
|
+
(0, utils_1.logLabeledBullet)("hosting", newMessage);
|
|
22
22
|
}
|
|
23
23
|
else {
|
|
24
24
|
process.stdout.write(_ERASE_LINE + clc.move(-9999, 0));
|
|
@@ -33,20 +33,20 @@ async function deploy(context, options) {
|
|
|
33
33
|
return;
|
|
34
34
|
}
|
|
35
35
|
if (!((_a = deploy.config) === null || _a === void 0 ? void 0 : _a.public)) {
|
|
36
|
-
utils_1.logLabeledBullet(`hosting[${deploy.site}]`, 'no "public" directory to upload, continuing with release');
|
|
36
|
+
(0, utils_1.logLabeledBullet)(`hosting[${deploy.site}]`, 'no "public" directory to upload, continuing with release');
|
|
37
37
|
return runDeploys(deploys, debugging);
|
|
38
38
|
}
|
|
39
|
-
utils_1.logLabeledBullet("hosting[" + deploy.site + "]", "beginning deploy...");
|
|
39
|
+
(0, utils_1.logLabeledBullet)("hosting[" + deploy.site + "]", "beginning deploy...");
|
|
40
40
|
const t0 = Date.now();
|
|
41
41
|
const publicDir = options.config.path(deploy.config.public);
|
|
42
|
-
const files = listFiles_1.listFiles(publicDir, deploy.config.ignore);
|
|
43
|
-
utils_1.logLabeledBullet(`hosting[${deploy.site}]`, `found ${files.length} files in ${clc.bold(deploy.config.public)}`);
|
|
42
|
+
const files = (0, listFiles_1.listFiles)(publicDir, deploy.config.ignore);
|
|
43
|
+
(0, utils_1.logLabeledBullet)(`hosting[${deploy.site}]`, `found ${files.length} files in ${clc.bold(deploy.config.public)}`);
|
|
44
44
|
const uploader = new uploader_1.Uploader({
|
|
45
45
|
version: deploy.version,
|
|
46
46
|
files: files,
|
|
47
47
|
public: publicDir,
|
|
48
48
|
cwd: options.cwd,
|
|
49
|
-
projectRoot: detectProjectRoot_1.detectProjectRoot(options),
|
|
49
|
+
projectRoot: (0, detectProjectRoot_1.detectProjectRoot)(options),
|
|
50
50
|
});
|
|
51
51
|
const progressInterval = setInterval(() => updateSpinner(uploader.statusMessage(), debugging), debugging ? 2000 : 200);
|
|
52
52
|
try {
|
|
@@ -62,7 +62,7 @@ async function deploy(context, options) {
|
|
|
62
62
|
if (!debugging) {
|
|
63
63
|
process.stdout.write(_ERASE_LINE + clc.move(-9999, 0));
|
|
64
64
|
}
|
|
65
|
-
utils_1.logLabeledSuccess("hosting[" + deploy.site + "]", "file upload complete");
|
|
65
|
+
(0, utils_1.logLabeledSuccess)("hosting[" + deploy.site + "]", "file upload complete");
|
|
66
66
|
const dt = Date.now() - t0;
|
|
67
67
|
logger_1.logger.debug("[hosting] deploy completed after " + dt + "ms");
|
|
68
68
|
track("Hosting Deploy", "success", dt);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const _ = require("lodash");
|
|
3
3
|
const api = require("../../api");
|
|
4
|
-
const convertConfig = require("./convertConfig");
|
|
4
|
+
const { convertConfig } = require("./convertConfig");
|
|
5
5
|
const deploymentTool = require("../../deploymentTool");
|
|
6
6
|
const { FirebaseError } = require("../../error");
|
|
7
7
|
const { normalizedHostingConfigs } = require("../../hosting/normalizedHostingConfigs");
|
|
@@ -145,7 +145,7 @@ class Uploader {
|
|
|
145
145
|
this.hashMap[hash] = filePath;
|
|
146
146
|
this.pathMap[filePath] = hash;
|
|
147
147
|
this.populateBatch["/" + filePath] = hash;
|
|
148
|
-
const curBatchSize = lodash_1.size(this.populateBatch);
|
|
148
|
+
const curBatchSize = (0, lodash_1.size)(this.populateBatch);
|
|
149
149
|
if (curBatchSize > 0 && curBatchSize % this.populateBatchSize === 0) {
|
|
150
150
|
this.queuePopulate();
|
|
151
151
|
}
|
|
@@ -20,7 +20,7 @@ function validateDeploy(deploy, options) {
|
|
|
20
20
|
if (!hasPublicDir && !hasAnyDynamicRewrites && !hasAnyRedirects) {
|
|
21
21
|
throw new error_1.FirebaseError('Must supply a "public" directory or at least one rewrite or redirect in each "hosting" config.');
|
|
22
22
|
}
|
|
23
|
-
if (hasPublicDir && !fsutils_1.dirExistsSync(projectPath_1.resolveProjectPath(options, cfg.public))) {
|
|
23
|
+
if (hasPublicDir && !(0, fsutils_1.dirExistsSync)((0, projectPath_1.resolveProjectPath)(options, cfg.public))) {
|
|
24
24
|
throw new error_1.FirebaseError(`Specified "public" directory "${cfg.public}" does not exist, can't deploy hosting to site "${deploy.site}"`);
|
|
25
25
|
}
|
|
26
26
|
if (cfg.i18n) {
|
|
@@ -32,8 +32,8 @@ function validateDeploy(deploy, options) {
|
|
|
32
32
|
}
|
|
33
33
|
else {
|
|
34
34
|
const i18nPath = path.join(cfg.public, cfg.i18n.root);
|
|
35
|
-
if (!fsutils_1.dirExistsSync(projectPath_1.resolveProjectPath(options, i18nPath))) {
|
|
36
|
-
utils_1.logLabeledWarning("hosting", `Couldn't find specified i18n root directory ${clc.bold(cfg.i18n.root)} in public directory ${clc.bold(cfg.public)}.`);
|
|
35
|
+
if (!(0, fsutils_1.dirExistsSync)((0, projectPath_1.resolveProjectPath)(options, i18nPath))) {
|
|
36
|
+
(0, utils_1.logLabeledWarning)("hosting", `Couldn't find specified i18n root directory ${clc.bold(cfg.i18n.root)} in public directory ${clc.bold(cfg.public)}.`);
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
}
|
|
@@ -14,9 +14,9 @@ async function default_1(context, options) {
|
|
|
14
14
|
return;
|
|
15
15
|
}
|
|
16
16
|
const template = loadCJSON(filePath);
|
|
17
|
-
const projectNumber = await projectUtils_1.needProjectNumber(options);
|
|
18
|
-
template.etag = await functions_1.getEtag(projectNumber);
|
|
19
|
-
functions_2.validateInputRemoteConfigTemplate(template);
|
|
17
|
+
const projectNumber = await (0, projectUtils_1.needProjectNumber)(options);
|
|
18
|
+
template.etag = await (0, functions_1.getEtag)(projectNumber);
|
|
19
|
+
(0, functions_2.validateInputRemoteConfigTemplate)(template);
|
|
20
20
|
context.remoteconfigTemplate = template;
|
|
21
21
|
return;
|
|
22
22
|
}
|
|
@@ -7,8 +7,8 @@ async function default_1(context, options) {
|
|
|
7
7
|
return;
|
|
8
8
|
}
|
|
9
9
|
const template = context.remoteconfigTemplate;
|
|
10
|
-
const projectNumber = await projectUtils_1.needProjectNumber(options);
|
|
11
|
-
const etag = await functions_1.getEtag(projectNumber);
|
|
12
|
-
return functions_1.publishTemplate(projectNumber, template, etag, options);
|
|
10
|
+
const projectNumber = await (0, projectUtils_1.needProjectNumber)(options);
|
|
11
|
+
const etag = await (0, functions_1.getEtag)(projectNumber);
|
|
12
|
+
return (0, functions_1.publishTemplate)(projectNumber, template, etag, options);
|
|
13
13
|
}
|
|
14
14
|
exports.default = default_1;
|