firebase-tools 10.1.0 → 10.1.4
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/apiv2.js +91 -48
- package/lib/archiveDirectory.js +63 -73
- package/lib/bin/firebase.js +1 -1
- package/lib/commands/auth-export.js +26 -25
- package/lib/commands/auth-import.js +88 -78
- package/lib/commands/ext-configure.js +1 -1
- package/lib/commands/ext-dev-init.js +1 -1
- package/lib/commands/ext-dev-publish.js +1 -1
- package/lib/commands/ext-dev-register.js +1 -1
- package/lib/commands/ext-dev-usage.js +3 -8
- package/lib/commands/ext-info.js +1 -1
- package/lib/commands/ext-install.js +1 -1
- package/lib/commands/ext-uninstall.js +1 -1
- package/lib/commands/ext-update.js +1 -1
- package/lib/commands/functions-config-clone.js +22 -23
- 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/help.js +12 -12
- package/lib/commands/hosting-channel-create.js +1 -1
- package/lib/commands/hosting-channel-delete.js +2 -2
- package/lib/commands/hosting-channel-deploy.js +1 -1
- package/lib/commands/hosting-clone.js +1 -1
- package/lib/commands/login-ci.js +10 -10
- package/lib/commands/remoteconfig-versions-list.js +6 -1
- 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 +3 -2
- 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/database/metadata.js +16 -24
- package/lib/defaultCredentials.js +3 -3
- package/lib/deploy/functions/backend.js +3 -1
- package/lib/deploy/functions/prepare.js +17 -11
- package/lib/deploy/functions/release/fabricator.js +4 -1
- package/lib/deploy/functions/runtimes/golang/index.js +6 -9
- package/lib/deploy/functions/runtimes/index.js +6 -10
- package/lib/deploy/functions/runtimes/node/index.js +5 -9
- package/lib/deploy/functions/runtimes/node/validate.js +2 -1
- package/lib/deploy/functions/validate.js +32 -4
- package/lib/deploy/hosting/convertConfig.js +45 -24
- package/lib/deploy/hosting/prepare.js +1 -1
- package/lib/emulator/auth/widget_ui.js +1 -1
- package/lib/emulator/downloadableEmulators.js +3 -2
- package/lib/emulator/functionsEmulator.js +9 -1
- package/lib/emulator/functionsEmulatorRuntime.js +4 -4
- package/lib/emulator/storage/apis/gcloud.js +2 -2
- package/lib/emulator/storage/files.js +8 -3
- package/lib/emulator/storage/rules/runtime.js +5 -4
- package/lib/extensions/askUserForConsent.js +1 -1
- package/lib/extensions/askUserForParam.js +1 -1
- package/lib/extensions/billingMigrationHelper.js +1 -1
- package/lib/extensions/changelog.js +1 -1
- package/lib/extensions/displayExtensionInfo.js +1 -1
- package/lib/extensions/extensionsApi.js +57 -112
- package/lib/extensions/extensionsHelper.js +19 -15
- package/lib/extensions/provisioningHelper.js +7 -10
- package/lib/extensions/resolveSource.js +5 -5
- package/lib/extensions/updateHelper.js +1 -1
- package/lib/extensions/warnings.js +1 -1
- package/lib/functionsConfig.js +4 -5
- 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 +8 -5
- package/lib/gcp/cloudscheduler.js +7 -18
- package/lib/gcp/firedata.js +5 -4
- package/lib/gcp/firestore.js +5 -5
- package/lib/gcp/iam.js +18 -33
- package/lib/gcp/resourceManager.js +8 -13
- package/lib/gcp/rules.js +18 -41
- package/lib/gcp/runtimeconfig.js +31 -53
- package/lib/gcp/secretManager.js +21 -43
- package/lib/gcp/storage.js +25 -29
- package/lib/projectUtils.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/npm-shrinkwrap.json +1439 -2295
- package/package.json +16 -11
- package/schema/firebase-config.json +387 -12
- package/standalone/firepit.js +4 -4
- package/templates/init/hosting/index.html +1 -1
- package/lib/commands/functions-config-legacy.js +0 -45
- package/lib/prepareFirebaseRules.js +0 -58
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const cli_color_1 = require("cli-color");
|
|
4
|
-
const
|
|
4
|
+
const { marked } = require("marked");
|
|
5
5
|
const command_1 = require("../command");
|
|
6
6
|
const utils_1 = require("../utils");
|
|
7
7
|
const api_1 = require("../hosting/api");
|
|
@@ -38,7 +38,7 @@ exports.default = new command_1.Command("hosting:channel:delete <channelId>")
|
|
|
38
38
|
await (0, api_1.removeAuthDomain)(projectId, channel.url);
|
|
39
39
|
}
|
|
40
40
|
catch (e) {
|
|
41
|
-
(0, utils_1.logLabeledWarning)("hosting:channel", (
|
|
41
|
+
(0, utils_1.logLabeledWarning)("hosting:channel", marked(`Unable to remove channel domain from Firebase Auth. Visit the Firebase Console at ${(0, utils_1.consoleUrl)(projectId, "/authentication/providers")}`));
|
|
42
42
|
logger_1.logger.debug("[hosting] unable to remove auth domain", e);
|
|
43
43
|
}
|
|
44
44
|
}
|
|
@@ -12,7 +12,7 @@ const logger_1 = require("../logger");
|
|
|
12
12
|
const requireConfig = require("../requireConfig");
|
|
13
13
|
const expireUtils_1 = require("../hosting/expireUtils");
|
|
14
14
|
const utils_1 = require("../utils");
|
|
15
|
-
const marked = require("marked");
|
|
15
|
+
const { marked } = require("marked");
|
|
16
16
|
const requireHostingSite_1 = require("../requireHostingSite");
|
|
17
17
|
const LOG_TAG = "hosting:channel";
|
|
18
18
|
exports.default = new command_1.Command("hosting:channel:deploy [channelId]")
|
|
@@ -7,7 +7,7 @@ const error_1 = require("../error");
|
|
|
7
7
|
const api_1 = require("../hosting/api");
|
|
8
8
|
const utils = require("../utils");
|
|
9
9
|
const requireAuth_1 = require("../requireAuth");
|
|
10
|
-
const marked = require("marked");
|
|
10
|
+
const { marked } = require("marked");
|
|
11
11
|
const logger_1 = require("../logger");
|
|
12
12
|
exports.default = new command_1.Command("hosting:clone <source> <targetChannel>")
|
|
13
13
|
.description("clone a version from one site to another")
|
package/lib/commands/login-ci.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const clc = require("cli-color");
|
|
4
|
+
const command_1 = require("../command");
|
|
5
|
+
const error_1 = require("../error");
|
|
6
|
+
const logger_1 = require("../logger");
|
|
7
|
+
const auth = require("../auth");
|
|
8
|
+
const utils = require("../utils");
|
|
9
|
+
exports.default = new command_1.Command("login:ci")
|
|
8
10
|
.description("generate an access token for use in non-interactive environments")
|
|
9
11
|
.option("--no-localhost", "copy and paste a code instead of starting a local server for authentication")
|
|
10
12
|
.action(async (options) => {
|
|
11
13
|
if (options.nonInteractive) {
|
|
12
|
-
|
|
13
|
-
exit: 1,
|
|
14
|
-
});
|
|
14
|
+
throw new error_1.FirebaseError("Cannot run login:ci in non-interactive mode.");
|
|
15
15
|
}
|
|
16
16
|
const userCredentials = await auth.loginGoogle(options.localhost);
|
|
17
|
-
logger.info();
|
|
17
|
+
logger_1.logger.info();
|
|
18
18
|
utils.logSuccess("Success! Use this token to login on a CI server:\n\n" +
|
|
19
19
|
clc.bold(userCredentials.tokens.refresh_token) +
|
|
20
20
|
'\n\nExample: firebase deploy --token "$FIREBASE_TOKEN"\n');
|
|
@@ -6,11 +6,16 @@ const command_1 = require("../command");
|
|
|
6
6
|
const projectUtils_1 = require("../projectUtils");
|
|
7
7
|
const requireAuth_1 = require("../requireAuth");
|
|
8
8
|
const requirePermissions_1 = require("../requirePermissions");
|
|
9
|
+
const utils_1 = require("../utils");
|
|
9
10
|
const Table = require("cli-table");
|
|
10
11
|
const tableHead = ["Update User", "Version Number", "Update Time"];
|
|
11
12
|
function pushTableContents(table, version) {
|
|
12
13
|
var _a;
|
|
13
|
-
return table.push([
|
|
14
|
+
return table.push([
|
|
15
|
+
(_a = version.updateUser) === null || _a === void 0 ? void 0 : _a.email,
|
|
16
|
+
version.versionNumber,
|
|
17
|
+
version.updateTime ? (0, utils_1.datetimeString)(new Date(version.updateTime)) : "",
|
|
18
|
+
]);
|
|
14
19
|
}
|
|
15
20
|
module.exports = new command_1.Command("remoteconfig:versions:list")
|
|
16
21
|
.description("get a list of Remote Config template versions that have been published for a Firebase project")
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const command_1 = require("../command");
|
|
4
|
+
const download_1 = require("../emulator/download");
|
|
5
|
+
const types_1 = require("../emulator/types");
|
|
6
|
+
const NAME = types_1.Emulators.DATABASE;
|
|
7
|
+
exports.default = new command_1.Command(`setup:emulators:${NAME}`)
|
|
7
8
|
.description(`downloads the ${NAME} emulator`)
|
|
8
|
-
.action((
|
|
9
|
-
return downloadEmulator(NAME);
|
|
9
|
+
.action(() => {
|
|
10
|
+
return (0, download_1.downloadEmulator)(NAME);
|
|
10
11
|
});
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const command_1 = require("../command");
|
|
4
|
+
const download_1 = require("../emulator/download");
|
|
5
|
+
const types_1 = require("../emulator/types");
|
|
6
|
+
const NAME = types_1.Emulators.FIRESTORE;
|
|
7
|
+
exports.default = new command_1.Command(`setup:emulators:${NAME}`)
|
|
7
8
|
.description(`downloads the ${NAME} emulator`)
|
|
8
|
-
.action((
|
|
9
|
-
return downloadEmulator(NAME);
|
|
9
|
+
.action(() => {
|
|
10
|
+
return (0, download_1.downloadEmulator)(NAME);
|
|
10
11
|
});
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const command_1 = require("../command");
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
|
|
4
|
+
const download_1 = require("../emulator/download");
|
|
5
|
+
const types_1 = require("../emulator/types");
|
|
6
|
+
const EMULATOR_NAME = types_1.Emulators.PUBSUB;
|
|
7
|
+
exports.default = new command_1.Command(`setup:emulators:${EMULATOR_NAME}`)
|
|
7
8
|
.description(`downloads the ${EMULATOR_NAME} emulator`)
|
|
8
9
|
.action(() => {
|
|
9
|
-
return downloadEmulator(EMULATOR_NAME);
|
|
10
|
+
return (0, download_1.downloadEmulator)(EMULATOR_NAME);
|
|
10
11
|
});
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const command_1 = require("../command");
|
|
4
4
|
const download_1 = require("../emulator/download");
|
|
5
|
-
const
|
|
6
|
-
|
|
5
|
+
const types_1 = require("../emulator/types");
|
|
6
|
+
const EMULATOR_NAME = types_1.Emulators.STORAGE;
|
|
7
|
+
exports.default = new command_1.Command(`setup:emulators:${EMULATOR_NAME}`)
|
|
7
8
|
.description(`downloads the ${EMULATOR_NAME} emulator`)
|
|
8
9
|
.action(() => {
|
|
9
10
|
return (0, download_1.downloadEmulator)(EMULATOR_NAME);
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const command_1 = require("../command");
|
|
4
|
+
const download_1 = require("../emulator/download");
|
|
5
|
+
const types_1 = require("../emulator/types");
|
|
6
|
+
const NAME = types_1.Emulators.UI;
|
|
7
|
+
exports.default = new command_1.Command(`setup:emulators:${NAME}`)
|
|
7
8
|
.description(`downloads the ${NAME} emulator`)
|
|
8
|
-
.action((
|
|
9
|
-
return downloadEmulator(NAME);
|
|
9
|
+
.action(() => {
|
|
10
|
+
return (0, download_1.downloadEmulator)(NAME);
|
|
10
11
|
});
|
|
@@ -1,22 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const clc = require("cli-color");
|
|
4
|
+
const command_1 = require("../command");
|
|
5
|
+
const logger_1 = require("../logger");
|
|
6
|
+
const requireConfig = require("../requireConfig");
|
|
7
|
+
const utils = require("../utils");
|
|
8
|
+
const error_1 = require("../error");
|
|
9
|
+
exports.default = new command_1.Command("target:apply <type> <name> <resources...>")
|
|
9
10
|
.description("apply a deploy target to a resource")
|
|
10
11
|
.before(requireConfig)
|
|
11
|
-
.action(
|
|
12
|
+
.action((type, name, resources, options) => {
|
|
12
13
|
if (!options.project) {
|
|
13
|
-
|
|
14
|
+
throw new error_1.FirebaseError(`Must have an active project to set deploy targets. Try ${clc.bold("firebase use --add")}`);
|
|
14
15
|
}
|
|
15
|
-
|
|
16
|
-
utils.logSuccess(
|
|
17
|
-
|
|
18
|
-
utils.logWarning(
|
|
19
|
-
}
|
|
20
|
-
logger.info();
|
|
21
|
-
logger.info(
|
|
16
|
+
const changes = options.rc.applyTarget(options.project, type, name, resources);
|
|
17
|
+
utils.logSuccess(`Applied ${type} target ${clc.bold(name)} to ${clc.bold(resources.join(", "))}`);
|
|
18
|
+
for (const change of changes) {
|
|
19
|
+
utils.logWarning(`Previous target ${clc.bold(change.target)} removed from ${clc.bold(change.resource)}`);
|
|
20
|
+
}
|
|
21
|
+
logger_1.logger.info();
|
|
22
|
+
logger_1.logger.info(`Updated: ${name} (${options.rc.target(options.project, type, name).join(",")})`);
|
|
22
23
|
});
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const clc = require("cli-color");
|
|
4
|
+
const command_1 = require("../command");
|
|
5
|
+
const requireConfig = require("../requireConfig");
|
|
6
|
+
const utils = require("../utils");
|
|
7
|
+
exports.default = new command_1.Command("target:clear <type> <target>")
|
|
7
8
|
.description("clear all resources from a named resource target")
|
|
8
9
|
.before(requireConfig)
|
|
9
|
-
.action(
|
|
10
|
-
|
|
10
|
+
.action((type, name, options) => {
|
|
11
|
+
const existed = options.rc.clearTarget(options.project, type, name);
|
|
11
12
|
if (existed) {
|
|
12
|
-
utils.logSuccess(
|
|
13
|
+
utils.logSuccess(`Cleared ${type} target ${clc.bold(name)}`);
|
|
13
14
|
}
|
|
14
15
|
else {
|
|
15
|
-
utils.logWarning(
|
|
16
|
+
utils.logWarning(`No action taken. No ${type} target found named ${clc.bold(name)}`);
|
|
16
17
|
}
|
|
17
|
-
return
|
|
18
|
+
return existed;
|
|
18
19
|
});
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const clc = require("cli-color");
|
|
4
|
+
const command_1 = require("../command");
|
|
5
|
+
const requireConfig = require("../requireConfig");
|
|
6
|
+
const utils = require("../utils");
|
|
7
|
+
exports.default = new command_1.Command("target:remove <type> <resource>")
|
|
7
8
|
.description("remove a resource target")
|
|
8
9
|
.before(requireConfig)
|
|
9
|
-
.action(
|
|
10
|
-
|
|
10
|
+
.action((type, resource, options) => {
|
|
11
|
+
const name = options.rc.removeTarget(options.project, type, resource);
|
|
11
12
|
if (name) {
|
|
12
|
-
utils.logSuccess(
|
|
13
|
+
utils.logSuccess(`Removed ${type} target ${clc.bold(name)} from ${clc.bold(resource)}`);
|
|
13
14
|
}
|
|
14
15
|
else {
|
|
15
|
-
utils.logWarning(
|
|
16
|
+
utils.logWarning(`No action taken. No target found for ${type} resource ${clc.bold(resource)}`);
|
|
16
17
|
}
|
|
17
18
|
return Promise.resolve(name);
|
|
18
19
|
});
|
package/lib/commands/target.js
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
function
|
|
9
|
-
logger.info(clc.cyan("[ " + type + " ]"));
|
|
10
|
-
|
|
11
|
-
logger.info(name, "(" + (resources || []).join(",") + ")");
|
|
12
|
-
}
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const clc = require("cli-color");
|
|
4
|
+
const command_1 = require("../command");
|
|
5
|
+
const logger_1 = require("../logger");
|
|
6
|
+
const requireConfig = require("../requireConfig");
|
|
7
|
+
const utils = require("../utils");
|
|
8
|
+
function logTargets(type, targets) {
|
|
9
|
+
logger_1.logger.info(clc.cyan("[ " + type + " ]"));
|
|
10
|
+
for (const [name, resources] of Object.entries(targets)) {
|
|
11
|
+
logger_1.logger.info(name, "(" + (resources || []).join(",") + ")");
|
|
12
|
+
}
|
|
13
13
|
}
|
|
14
|
-
|
|
14
|
+
exports.default = new command_1.Command("target [type]")
|
|
15
15
|
.description("display configured deploy targets for the current project")
|
|
16
16
|
.before(requireConfig)
|
|
17
|
-
.action(
|
|
17
|
+
.action((type, options) => {
|
|
18
18
|
if (!options.project) {
|
|
19
19
|
return utils.reject("No active project, cannot list deploy targets.");
|
|
20
20
|
}
|
|
21
|
-
logger.info("Resource targets for", clc.bold(options.project) + ":");
|
|
22
|
-
logger.info();
|
|
21
|
+
logger_1.logger.info("Resource targets for", clc.bold(options.project) + ":");
|
|
22
|
+
logger_1.logger.info();
|
|
23
23
|
if (type) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
return
|
|
24
|
+
const targets = options.rc.targets(options.project, type);
|
|
25
|
+
logTargets(type, targets);
|
|
26
|
+
return targets;
|
|
27
27
|
}
|
|
28
28
|
const allTargets = options.rc.allTargets(options.project);
|
|
29
29
|
for (const [targetType, targetName] of Object.entries(allTargets)) {
|
|
30
|
-
|
|
30
|
+
logTargets(targetType, targetName);
|
|
31
31
|
}
|
|
32
|
-
return
|
|
32
|
+
return allTargets;
|
|
33
33
|
});
|
package/lib/database/metadata.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.setRulesetLabels = exports.createRuleset = exports.getRulesetLabels = exports.getRuleset = exports.listAllRulesets = void 0;
|
|
4
|
-
const
|
|
4
|
+
const api_1 = require("../api");
|
|
5
|
+
const apiv2_1 = require("../apiv2");
|
|
5
6
|
const logger_1 = require("../logger");
|
|
6
7
|
const utils = require("../utils");
|
|
7
8
|
function handleErrorResponse(response) {
|
|
@@ -13,12 +14,9 @@ function handleErrorResponse(response) {
|
|
|
13
14
|
code: 2,
|
|
14
15
|
});
|
|
15
16
|
}
|
|
17
|
+
const apiClient = new apiv2_1.Client({ urlPrefix: api_1.rtdbMetadataOrigin });
|
|
16
18
|
async function listAllRulesets(databaseName) {
|
|
17
|
-
const response = await
|
|
18
|
-
auth: true,
|
|
19
|
-
origin: api.rtdbMetadataOrigin,
|
|
20
|
-
json: true,
|
|
21
|
-
});
|
|
19
|
+
const response = await apiClient.get(`/namespaces/${databaseName}/rulesets`, { resolveOnHTTPError: true });
|
|
22
20
|
if (response.status === 200) {
|
|
23
21
|
return response.body.rulesets;
|
|
24
22
|
}
|
|
@@ -26,11 +24,7 @@ async function listAllRulesets(databaseName) {
|
|
|
26
24
|
}
|
|
27
25
|
exports.listAllRulesets = listAllRulesets;
|
|
28
26
|
async function getRuleset(databaseName, rulesetId) {
|
|
29
|
-
const response = await
|
|
30
|
-
auth: true,
|
|
31
|
-
origin: api.rtdbMetadataOrigin,
|
|
32
|
-
json: true,
|
|
33
|
-
});
|
|
27
|
+
const response = await apiClient.get(`/namespaces/${databaseName}/rulesets/${rulesetId}`, { resolveOnHTTPError: true });
|
|
34
28
|
if (response.status === 200) {
|
|
35
29
|
return response.body;
|
|
36
30
|
}
|
|
@@ -38,9 +32,8 @@ async function getRuleset(databaseName, rulesetId) {
|
|
|
38
32
|
}
|
|
39
33
|
exports.getRuleset = getRuleset;
|
|
40
34
|
async function getRulesetLabels(databaseName) {
|
|
41
|
-
const response = await
|
|
42
|
-
|
|
43
|
-
origin: api.rtdbMetadataOrigin,
|
|
35
|
+
const response = await apiClient.get(`/namespaces/${databaseName}/ruleset_labels`, {
|
|
36
|
+
resolveOnHTTPError: true,
|
|
44
37
|
});
|
|
45
38
|
if (response.status === 200) {
|
|
46
39
|
return response.body;
|
|
@@ -49,23 +42,22 @@ async function getRulesetLabels(databaseName) {
|
|
|
49
42
|
}
|
|
50
43
|
exports.getRulesetLabels = getRulesetLabels;
|
|
51
44
|
async function createRuleset(databaseName, source) {
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
origin: utils.addSubdomain(api.realtimeOrigin, databaseName),
|
|
55
|
-
json: false,
|
|
56
|
-
data: source,
|
|
45
|
+
const localApiClient = new apiv2_1.Client({
|
|
46
|
+
urlPrefix: utils.addSubdomain(api_1.realtimeOrigin, databaseName),
|
|
57
47
|
});
|
|
48
|
+
const response = await localApiClient.post(`/.settings/rulesets.json`, source, { resolveOnHTTPError: true });
|
|
58
49
|
if (response.status === 200) {
|
|
59
|
-
return
|
|
50
|
+
return response.body.id;
|
|
60
51
|
}
|
|
61
52
|
return handleErrorResponse(response);
|
|
62
53
|
}
|
|
63
54
|
exports.createRuleset = createRuleset;
|
|
64
55
|
async function setRulesetLabels(databaseName, labels) {
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
56
|
+
const localApiClient = new apiv2_1.Client({
|
|
57
|
+
urlPrefix: utils.addSubdomain(api_1.realtimeOrigin, databaseName),
|
|
58
|
+
});
|
|
59
|
+
const response = await localApiClient.put(`/.settings/ruleset_labels.json`, labels, {
|
|
60
|
+
resolveOnHTTPError: true,
|
|
69
61
|
});
|
|
70
62
|
if (response.status === 200) {
|
|
71
63
|
return response.body;
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.clearCredentials = exports.getCredentialPathAsync = void 0;
|
|
4
4
|
const fs = require("fs");
|
|
5
5
|
const path = require("path");
|
|
6
|
-
const
|
|
6
|
+
const api_1 = require("./api");
|
|
7
7
|
const logger_1 = require("./logger");
|
|
8
8
|
async function getCredentialPathAsync(account) {
|
|
9
9
|
const filePath = credFilePath(account.user);
|
|
@@ -43,8 +43,8 @@ exports.clearCredentials = clearCredentials;
|
|
|
43
43
|
function getCredential(tokens) {
|
|
44
44
|
if (tokens.refresh_token) {
|
|
45
45
|
return {
|
|
46
|
-
client_id:
|
|
47
|
-
client_secret:
|
|
46
|
+
client_id: api_1.clientId,
|
|
47
|
+
client_secret: api_1.clientSecret,
|
|
48
48
|
refresh_token: tokens.refresh_token,
|
|
49
49
|
type: "authorized_user",
|
|
50
50
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.compareFunctions = exports.missingEndpoint = exports.hasEndpoint = exports.regionalEndpoints = exports.matchingBackend = exports.someEndpoint = exports.allEndpoints = exports.checkAvailability = exports.existingBackend = exports.scheduleIdForFunction = exports.functionName = exports.isEmptyBackend = exports.of = exports.empty = exports.isTaskQueueTriggered = exports.isScheduleTriggered = exports.isEventTriggered = exports.isHttpsTriggered = exports.SCHEDULED_FUNCTION_LABEL = exports.memoryOptionDisplayName = exports.endpointTriggerType = void 0;
|
|
3
|
+
exports.compareFunctions = exports.missingEndpoint = exports.hasEndpoint = exports.regionalEndpoints = exports.matchingBackend = exports.someEndpoint = exports.allEndpoints = exports.checkAvailability = exports.existingBackend = exports.scheduleIdForFunction = exports.functionName = exports.isEmptyBackend = exports.of = exports.empty = exports.isTaskQueueTriggered = exports.isScheduleTriggered = exports.isEventTriggered = exports.isHttpsTriggered = exports.SCHEDULED_FUNCTION_LABEL = exports.MIN_MEMORY_FOR_CONCURRENCY = exports.DEFAULT_MEMORY = exports.memoryOptionDisplayName = exports.endpointTriggerType = void 0;
|
|
4
4
|
const gcf = require("../../gcp/cloudfunctions");
|
|
5
5
|
const gcfV2 = require("../../gcp/cloudfunctionsv2");
|
|
6
6
|
const utils = require("../../utils");
|
|
@@ -36,6 +36,8 @@ function memoryOptionDisplayName(option) {
|
|
|
36
36
|
}[option];
|
|
37
37
|
}
|
|
38
38
|
exports.memoryOptionDisplayName = memoryOptionDisplayName;
|
|
39
|
+
exports.DEFAULT_MEMORY = 256;
|
|
40
|
+
exports.MIN_MEMORY_FOR_CONCURRENCY = 2048;
|
|
39
41
|
exports.SCHEDULED_FUNCTION_LABEL = Object.freeze({ deployment: "firebase-schedule" });
|
|
40
42
|
function isHttpsTriggered(triggered) {
|
|
41
43
|
return {}.hasOwnProperty.call(triggered, "httpsTrigger");
|
|
@@ -16,10 +16,10 @@ const projectUtils_1 = require("../../projectUtils");
|
|
|
16
16
|
const track_1 = require("../../track");
|
|
17
17
|
const runtimes = require("./runtimes");
|
|
18
18
|
const validate = require("./validate");
|
|
19
|
-
const utils = require("../../utils");
|
|
20
19
|
const logger_1 = require("../../logger");
|
|
21
20
|
const triggerRegionHelper_1 = require("./triggerRegionHelper");
|
|
22
21
|
const checkIam_1 = require("./checkIam");
|
|
22
|
+
const error_1 = require("../../error");
|
|
23
23
|
function hasUserConfig(config) {
|
|
24
24
|
return Object.keys(config).length > 1;
|
|
25
25
|
}
|
|
@@ -27,22 +27,30 @@ function hasDotenv(opts) {
|
|
|
27
27
|
return previews_1.previews.dotenv && functionsEnv.hasUserEnvs(opts);
|
|
28
28
|
}
|
|
29
29
|
async function maybeEnableAR(projectId) {
|
|
30
|
-
if (previews_1.previews.artifactregistry) {
|
|
30
|
+
if (!previews_1.previews.artifactregistry) {
|
|
31
31
|
return ensureApiEnabled.check(projectId, "artifactregistry.googleapis.com", "functions", true);
|
|
32
32
|
}
|
|
33
33
|
await ensureApiEnabled.ensure(projectId, "artifactregistry.googleapis.com", "functions");
|
|
34
34
|
return true;
|
|
35
35
|
}
|
|
36
36
|
async function prepare(context, options, payload) {
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
38
|
+
const sourceDirName = options.config.get("functions.source");
|
|
39
|
+
if (!sourceDirName) {
|
|
40
|
+
throw new error_1.FirebaseError(`No functions code detected at default location (./functions), and no functions.source defined in firebase.json`);
|
|
39
41
|
}
|
|
40
|
-
const
|
|
42
|
+
const sourceDir = options.config.path(sourceDirName);
|
|
43
|
+
const delegateContext = {
|
|
44
|
+
projectId,
|
|
45
|
+
sourceDir,
|
|
46
|
+
projectDir: options.config.projectDir,
|
|
47
|
+
runtime: options.config.get("functions.runtime") || "",
|
|
48
|
+
};
|
|
49
|
+
const runtimeDelegate = await runtimes.getRuntimeDelegate(delegateContext);
|
|
41
50
|
logger_1.logger.debug(`Validating ${runtimeDelegate.name} source`);
|
|
42
51
|
await runtimeDelegate.validate();
|
|
43
52
|
logger_1.logger.debug(`Building ${runtimeDelegate.name} source`);
|
|
44
53
|
await runtimeDelegate.build();
|
|
45
|
-
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
46
54
|
const checkAPIsEnabled = await Promise.all([
|
|
47
55
|
ensureApiEnabled.ensure(projectId, "cloudfunctions.googleapis.com", "functions"),
|
|
48
56
|
ensureApiEnabled.check(projectId, "runtimeconfig.googleapis.com", "runtimeconfig", true),
|
|
@@ -54,11 +62,9 @@ async function prepare(context, options, payload) {
|
|
|
54
62
|
const firebaseConfig = await functionsConfig.getFirebaseConfig(options);
|
|
55
63
|
context.firebaseConfig = firebaseConfig;
|
|
56
64
|
const runtimeConfig = await (0, prepareFunctionsUpload_1.getFunctionsConfig)(context);
|
|
57
|
-
utils.assertDefined(options.config.src.functions.source, "Error: 'functions.source' is not defined");
|
|
58
|
-
const source = options.config.src.functions.source;
|
|
59
65
|
const firebaseEnvs = functionsEnv.loadFirebaseEnvs(firebaseConfig, projectId);
|
|
60
66
|
const userEnvOpt = {
|
|
61
|
-
functionsSource:
|
|
67
|
+
functionsSource: sourceDir,
|
|
62
68
|
projectId: projectId,
|
|
63
69
|
projectAlias: options.projectAlias,
|
|
64
70
|
};
|
|
@@ -92,7 +98,7 @@ async function prepare(context, options, payload) {
|
|
|
92
98
|
if (backend.someEndpoint(wantBackend, () => true)) {
|
|
93
99
|
(0, utils_1.logBullet)(clc.cyan.bold("functions:") +
|
|
94
100
|
" preparing " +
|
|
95
|
-
clc.bold(
|
|
101
|
+
clc.bold(sourceDirName) +
|
|
96
102
|
" directory for uploading...");
|
|
97
103
|
}
|
|
98
104
|
if (backend.someEndpoint(wantBackend, (e) => e.platform === "gcfv1")) {
|
|
@@ -107,7 +113,7 @@ async function prepare(context, options, payload) {
|
|
|
107
113
|
await Promise.all(Object.values(wantBackend.requiredAPIs).map((api) => {
|
|
108
114
|
return ensureApiEnabled.ensure(projectId, api, "functions", false);
|
|
109
115
|
}));
|
|
110
|
-
validate.
|
|
116
|
+
validate.endpointsAreValid(wantBackend);
|
|
111
117
|
context.filters = (0, functionsDeployHelper_1.getFilterGroups)(options);
|
|
112
118
|
const matchingBackend = backend.matchingBackend(wantBackend, (endpoint) => {
|
|
113
119
|
return (0, functionsDeployHelper_1.functionMatchesAnyGroup)(endpoint, context.filters);
|
|
@@ -242,7 +242,10 @@ class Fabricator {
|
|
|
242
242
|
.catch(rethrowAs(endpoint, "set invoker"));
|
|
243
243
|
}
|
|
244
244
|
}
|
|
245
|
-
|
|
245
|
+
const mem = endpoint.availableMemoryMb || backend.DEFAULT_MEMORY;
|
|
246
|
+
if (mem >= backend.MIN_MEMORY_FOR_CONCURRENCY && endpoint.concurrency != 1) {
|
|
247
|
+
await this.setConcurrency(endpoint, serviceName, endpoint.concurrency || DEFAULT_GCFV2_CONCURRENCY);
|
|
248
|
+
}
|
|
246
249
|
}
|
|
247
250
|
async updateV1Function(endpoint, scraper) {
|
|
248
251
|
var _a;
|
|
@@ -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,11 +18,8 @@ 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 = (0, 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
25
|
const modBuffer = await (0, util_1.promisify)(fs.readFile)(goModPath);
|
|
@@ -33,7 +29,7 @@ async function tryCreateDelegate(context, options) {
|
|
|
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 {
|
|
@@ -86,12 +82,13 @@ class Delegate {
|
|
|
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 () => {
|