firebase-tools 11.0.1 → 11.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/accountImporter.js +92 -93
- package/lib/api.js +77 -218
- package/lib/apiv2.js +5 -4
- package/lib/auth.js +69 -47
- package/lib/bin/firebase.js +42 -47
- package/lib/checkValidTargetFilters.js +13 -12
- 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 +2 -1
- package/lib/commands/database-push.js +2 -1
- package/lib/commands/database-remove.js +2 -1
- 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 +2 -1
- 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 +23 -21
- 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 +2 -1
- package/lib/commands/ext-dev-emulators-start.js +2 -1
- 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 +2 -1
- 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 +2 -1
- 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 +2 -1
- 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 +2 -1
- 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 +2 -1
- 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 +29 -27
- 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 -52
- package/lib/config.js +3 -3
- package/lib/deploy/database/deploy.js +3 -2
- package/lib/deploy/database/index.js +8 -5
- package/lib/deploy/database/prepare.js +22 -19
- package/lib/deploy/database/release.js +12 -9
- package/lib/deploy/firestore/prepare.js +2 -2
- package/lib/deploy/functions/build.js +32 -20
- package/lib/deploy/functions/runtimes/discovery/v1alpha1.js +187 -54
- package/lib/deploy/functions/runtimes/node/parseTriggers.js +14 -2
- 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 +23 -20
- package/lib/deploy/remoteconfig/prepare.js +2 -2
- package/lib/emulator/auth/apiSpec.js +14 -46
- package/lib/emulator/auth/operations.js +6 -29
- package/lib/emulator/auth/state.js +2 -25
- package/lib/emulator/controller.js +1 -1
- package/lib/emulator/databaseEmulator.js +2 -2
- package/lib/errorOut.js +2 -2
- package/lib/functions/events/v2.js +7 -1
- package/lib/functionsConfigClone.js +43 -41
- package/lib/gcp/cloudfunctionsv2.js +17 -2
- package/lib/gcp/iam.js +1 -1
- package/lib/gcp/index.js +10 -10
- package/lib/gcp/runtimeconfig.js +45 -47
- 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 +5 -4
- package/lib/loadCJSON.js +9 -6
- package/lib/logError.js +15 -12
- package/lib/parseBoltRules.js +15 -14
- package/lib/profileReport.js +503 -511
- package/lib/profiler.js +4 -4
- package/lib/requireAuth.js +0 -1
- package/lib/responseToError.js +8 -5
- package/lib/scopes.js +9 -9
- package/npm-shrinkwrap.json +537 -193
- package/package.json +8 -6
package/lib/commands/use.js
CHANGED
|
@@ -1,43 +1,45 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.command = void 0;
|
|
4
|
+
const _ = require("lodash");
|
|
5
|
+
const clc = require("cli-color");
|
|
6
|
+
const command_1 = require("../command");
|
|
7
|
+
const projects_1 = require("../management/projects");
|
|
8
|
+
const logger_1 = require("../logger");
|
|
9
|
+
const prompt_1 = require("../prompt");
|
|
10
|
+
const requireAuth_1 = require("../requireAuth");
|
|
11
|
+
const command_2 = require("../command");
|
|
12
|
+
const utils = require("../utils");
|
|
13
|
+
function listAliases(options) {
|
|
12
14
|
if (options.rc.hasProjects) {
|
|
13
|
-
logger.info("Project aliases for", clc.bold(options.projectRoot) + ":");
|
|
14
|
-
logger.info();
|
|
15
|
-
_.forEach(options.rc.projects,
|
|
16
|
-
|
|
15
|
+
logger_1.logger.info("Project aliases for", clc.bold(options.projectRoot) + ":");
|
|
16
|
+
logger_1.logger.info();
|
|
17
|
+
_.forEach(options.rc.projects, (projectId, alias) => {
|
|
18
|
+
const listing = alias + " (" + projectId + ")";
|
|
17
19
|
if (options.project === projectId || options.projectAlias === alias) {
|
|
18
|
-
logger.info(clc.cyan.bold("* " + listing));
|
|
20
|
+
logger_1.logger.info(clc.cyan.bold("* " + listing));
|
|
19
21
|
}
|
|
20
22
|
else {
|
|
21
|
-
logger.info(" " + listing);
|
|
23
|
+
logger_1.logger.info(" " + listing);
|
|
22
24
|
}
|
|
23
25
|
});
|
|
24
|
-
logger.info();
|
|
26
|
+
logger_1.logger.info();
|
|
25
27
|
}
|
|
26
|
-
logger.info("Run", clc.bold("firebase use --add"), "to define a new project alias.");
|
|
27
|
-
}
|
|
28
|
-
|
|
28
|
+
logger_1.logger.info("Run", clc.bold("firebase use --add"), "to define a new project alias.");
|
|
29
|
+
}
|
|
30
|
+
function verifyMessage(name) {
|
|
29
31
|
return "please verify project " + clc.bold(name) + " exists and you have access.";
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
+
}
|
|
33
|
+
exports.command = new command_1.Command("use [alias_or_project_id]")
|
|
32
34
|
.description("set an active Firebase project for your working directory")
|
|
33
35
|
.option("--add", "create a new project alias interactively")
|
|
34
36
|
.option("--alias <name>", "create a new alias for the provided project id")
|
|
35
37
|
.option("--unalias <name>", "remove an already created project alias")
|
|
36
38
|
.option("--clear", "clear the active project selection")
|
|
37
|
-
.before(requireAuth)
|
|
38
|
-
.action(
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
.before(requireAuth_1.requireAuth)
|
|
40
|
+
.action((newActive, options) => {
|
|
41
|
+
let aliasOpt;
|
|
42
|
+
const i = process.argv.indexOf("--alias");
|
|
41
43
|
if (i >= 0 && process.argv.length > i + 1) {
|
|
42
44
|
aliasOpt = process.argv[i + 1];
|
|
43
45
|
}
|
|
@@ -48,11 +50,11 @@ module.exports = new Command("use [alias_or_project_id]")
|
|
|
48
50
|
" to start a project directory in the current folder.");
|
|
49
51
|
}
|
|
50
52
|
if (newActive) {
|
|
51
|
-
|
|
53
|
+
let project;
|
|
52
54
|
const hasAlias = options.rc.hasProjectAlias(newActive);
|
|
53
55
|
const resolvedProject = options.rc.resolveAlias(newActive);
|
|
54
|
-
validateProjectId(resolvedProject);
|
|
55
|
-
return getFirebaseProject(resolvedProject)
|
|
56
|
+
(0, command_2.validateProjectId)(resolvedProject);
|
|
57
|
+
return (0, projects_1.getFirebaseProject)(resolvedProject)
|
|
56
58
|
.then((foundProject) => {
|
|
57
59
|
project = foundProject;
|
|
58
60
|
})
|
|
@@ -65,18 +67,18 @@ module.exports = new Command("use [alias_or_project_id]")
|
|
|
65
67
|
return utils.reject("Cannot create alias " + clc.bold(aliasOpt) + ", " + verifyMessage(newActive));
|
|
66
68
|
}
|
|
67
69
|
options.rc.addProjectAlias(aliasOpt, newActive);
|
|
68
|
-
logger.info("Created alias", clc.bold(aliasOpt), "for", resolvedProject + ".");
|
|
70
|
+
logger_1.logger.info("Created alias", clc.bold(aliasOpt), "for", resolvedProject + ".");
|
|
69
71
|
}
|
|
70
72
|
if (hasAlias) {
|
|
71
73
|
if (!project) {
|
|
72
74
|
return utils.reject("Unable to use alias " + clc.bold(newActive) + ", " + verifyMessage(resolvedProject));
|
|
73
75
|
}
|
|
74
76
|
utils.makeActiveProject(options.projectRoot, newActive);
|
|
75
|
-
logger.info("Now using alias", clc.bold(newActive), "(" + resolvedProject + ")");
|
|
77
|
+
logger_1.logger.info("Now using alias", clc.bold(newActive), "(" + resolvedProject + ")");
|
|
76
78
|
}
|
|
77
79
|
else if (project) {
|
|
78
80
|
utils.makeActiveProject(options.projectRoot, newActive);
|
|
79
|
-
logger.info("Now using project", clc.bold(newActive));
|
|
81
|
+
logger_1.logger.info("Now using project", clc.bold(newActive));
|
|
80
82
|
}
|
|
81
83
|
else {
|
|
82
84
|
return utils.reject("Invalid project selection, " + verifyMessage(newActive));
|
|
@@ -86,8 +88,8 @@ module.exports = new Command("use [alias_or_project_id]")
|
|
|
86
88
|
else if (options.unalias) {
|
|
87
89
|
if (options.rc.hasProjectAlias(options.unalias)) {
|
|
88
90
|
options.rc.removeProjectAlias(options.unalias);
|
|
89
|
-
logger.info("Removed alias", clc.bold(options.unalias));
|
|
90
|
-
logger.info();
|
|
91
|
+
logger_1.logger.info("Removed alias", clc.bold(options.unalias));
|
|
92
|
+
logger_1.logger.info();
|
|
91
93
|
listAliases(options);
|
|
92
94
|
}
|
|
93
95
|
}
|
|
@@ -99,9 +101,9 @@ module.exports = new Command("use [alias_or_project_id]")
|
|
|
99
101
|
clc.bold("firebase use <project_id> --alias <alias>") +
|
|
100
102
|
" instead.");
|
|
101
103
|
}
|
|
102
|
-
return listFirebaseProjects().then(
|
|
103
|
-
|
|
104
|
-
return prompt(results, [
|
|
104
|
+
return (0, projects_1.listFirebaseProjects)().then((projects) => {
|
|
105
|
+
const results = {};
|
|
106
|
+
return (0, prompt_1.prompt)(results, [
|
|
105
107
|
{
|
|
106
108
|
type: "list",
|
|
107
109
|
name: "project",
|
|
@@ -112,49 +114,49 @@ module.exports = new Command("use [alias_or_project_id]")
|
|
|
112
114
|
type: "input",
|
|
113
115
|
name: "alias",
|
|
114
116
|
message: "What alias do you want to use for this project? (e.g. staging)",
|
|
115
|
-
validate:
|
|
117
|
+
validate: (input) => {
|
|
116
118
|
return input && input.length > 0;
|
|
117
119
|
},
|
|
118
120
|
},
|
|
119
|
-
]).then(
|
|
121
|
+
]).then(() => {
|
|
120
122
|
options.rc.addProjectAlias(results.alias, results.project);
|
|
121
123
|
utils.makeActiveProject(options.projectRoot, results.alias);
|
|
122
|
-
logger.info();
|
|
123
|
-
logger.info("Created alias", clc.bold(results.alias), "for", results.project + ".");
|
|
124
|
-
logger.info("Now using alias", clc.bold(results.alias) + " (" + results.project + ")");
|
|
124
|
+
logger_1.logger.info();
|
|
125
|
+
logger_1.logger.info("Created alias", clc.bold(results.alias), "for", results.project + ".");
|
|
126
|
+
logger_1.logger.info("Now using alias", clc.bold(results.alias) + " (" + results.project + ")");
|
|
125
127
|
});
|
|
126
128
|
});
|
|
127
129
|
}
|
|
128
130
|
else if (options.clear) {
|
|
129
|
-
utils.makeActiveProject(options.projectRoot,
|
|
131
|
+
utils.makeActiveProject(options.projectRoot, undefined);
|
|
130
132
|
options.projectAlias = null;
|
|
131
133
|
options.project = null;
|
|
132
|
-
logger.info("Cleared active project.");
|
|
133
|
-
logger.info();
|
|
134
|
+
logger_1.logger.info("Cleared active project.");
|
|
135
|
+
logger_1.logger.info();
|
|
134
136
|
listAliases(options);
|
|
135
137
|
}
|
|
136
138
|
else {
|
|
137
139
|
if (options.nonInteractive || !process.stdout.isTTY) {
|
|
138
140
|
if (options.project) {
|
|
139
|
-
logger.info(options.project);
|
|
141
|
+
logger_1.logger.info(options.project);
|
|
140
142
|
return options.project;
|
|
141
143
|
}
|
|
142
|
-
return utils.reject("No active project"
|
|
144
|
+
return utils.reject("No active project");
|
|
143
145
|
}
|
|
144
146
|
if (options.projectAlias) {
|
|
145
|
-
logger.info("Active Project:", clc.bold.cyan(options.projectAlias + " (" + options.project + ")"));
|
|
147
|
+
logger_1.logger.info("Active Project:", clc.bold.cyan(options.projectAlias + " (" + options.project + ")"));
|
|
146
148
|
}
|
|
147
149
|
else if (options.project) {
|
|
148
|
-
logger.info("Active Project:", clc.bold.cyan(options.project));
|
|
150
|
+
logger_1.logger.info("Active Project:", clc.bold.cyan(options.project));
|
|
149
151
|
}
|
|
150
152
|
else {
|
|
151
|
-
|
|
153
|
+
let msg = "No project is currently active";
|
|
152
154
|
if (options.rc.hasProjects) {
|
|
153
155
|
msg += ", and no aliases have been created.";
|
|
154
156
|
}
|
|
155
|
-
logger.info(msg + ".");
|
|
157
|
+
logger_1.logger.info(msg + ".");
|
|
156
158
|
}
|
|
157
|
-
logger.info();
|
|
159
|
+
logger_1.logger.info();
|
|
158
160
|
listAliases(options);
|
|
159
161
|
return options.project;
|
|
160
162
|
}
|
package/lib/config.js
CHANGED
|
@@ -14,7 +14,7 @@ const projectPath_1 = require("./projectPath");
|
|
|
14
14
|
const utils = require("./utils");
|
|
15
15
|
const firebaseConfigValidate_1 = require("./firebaseConfigValidate");
|
|
16
16
|
const logger_1 = require("./logger");
|
|
17
|
-
const
|
|
17
|
+
const loadCJSON_1 = require("./loadCJSON");
|
|
18
18
|
const parseBoltRules = require("./parseBoltRules");
|
|
19
19
|
class Config {
|
|
20
20
|
constructor(src, options = {}) {
|
|
@@ -95,7 +95,7 @@ class Config {
|
|
|
95
95
|
throw e;
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
|
-
return loadCJSON(fullPath);
|
|
98
|
+
return (0, loadCJSON_1.loadCJSON)(fullPath);
|
|
99
99
|
case ".bolt":
|
|
100
100
|
if (target === "database") {
|
|
101
101
|
this.notes.databaseRules = "bolt";
|
|
@@ -125,7 +125,7 @@ class Config {
|
|
|
125
125
|
}
|
|
126
126
|
return outPath;
|
|
127
127
|
}
|
|
128
|
-
readProjectFile(p, options) {
|
|
128
|
+
readProjectFile(p, options = {}) {
|
|
129
129
|
options = options || {};
|
|
130
130
|
try {
|
|
131
131
|
const content = fs.readFileSync(this.path(p), "utf8");
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.release = exports.deploy = exports.prepare = void 0;
|
|
4
|
+
var prepare_1 = require("./prepare");
|
|
5
|
+
Object.defineProperty(exports, "prepare", { enumerable: true, get: function () { return prepare_1.prepare; } });
|
|
6
|
+
var deploy_1 = require("./deploy");
|
|
7
|
+
Object.defineProperty(exports, "deploy", { enumerable: true, get: function () { return deploy_1.deploy; } });
|
|
8
|
+
var release_1 = require("./release");
|
|
9
|
+
Object.defineProperty(exports, "release", { enumerable: true, get: function () { return release_1.release; } });
|
|
@@ -1,37 +1,39 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.prepare = void 0;
|
|
4
|
+
const _ = require("lodash");
|
|
5
|
+
const clc = require("cli-color");
|
|
6
|
+
const path = require("path");
|
|
7
|
+
const error_1 = require("../../error");
|
|
8
|
+
const parseBoltRules_1 = require("../../parseBoltRules");
|
|
9
|
+
const rtdb = require("../../rtdb");
|
|
10
|
+
const utils = require("../../utils");
|
|
9
11
|
const dbRulesConfig = require("../../database/rulesConfig");
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
function prepare(context, options) {
|
|
13
|
+
const rulesConfig = dbRulesConfig.getRulesConfig(context.projectId, options);
|
|
14
|
+
const next = Promise.resolve();
|
|
13
15
|
if (!rulesConfig || rulesConfig.length === 0) {
|
|
14
16
|
return next;
|
|
15
17
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
rulesConfig.forEach(
|
|
18
|
+
const ruleFiles = {};
|
|
19
|
+
const deploys = [];
|
|
20
|
+
rulesConfig.forEach((ruleConfig) => {
|
|
19
21
|
if (!ruleConfig.rules) {
|
|
20
22
|
return;
|
|
21
23
|
}
|
|
22
24
|
ruleFiles[ruleConfig.rules] = null;
|
|
23
25
|
deploys.push(ruleConfig);
|
|
24
26
|
});
|
|
25
|
-
_.forEach(ruleFiles,
|
|
27
|
+
_.forEach(ruleFiles, (v, file) => {
|
|
26
28
|
switch (path.extname(file)) {
|
|
27
29
|
case ".json":
|
|
28
30
|
ruleFiles[file] = options.config.readProjectFile(file);
|
|
29
31
|
break;
|
|
30
32
|
case ".bolt":
|
|
31
|
-
ruleFiles[file] = parseBoltRules(file);
|
|
33
|
+
ruleFiles[file] = (0, parseBoltRules_1.parseBoltRules)(file);
|
|
32
34
|
break;
|
|
33
35
|
default:
|
|
34
|
-
throw new FirebaseError("Unexpected rules format " + path.extname(file));
|
|
36
|
+
throw new error_1.FirebaseError("Unexpected rules format " + path.extname(file));
|
|
35
37
|
}
|
|
36
38
|
});
|
|
37
39
|
context.database = {
|
|
@@ -39,14 +41,15 @@ module.exports = function (context, options) {
|
|
|
39
41
|
ruleFiles: ruleFiles,
|
|
40
42
|
};
|
|
41
43
|
utils.logBullet(clc.bold.cyan("database: ") + "checking rules syntax...");
|
|
42
|
-
return Promise.all(deploys.map(
|
|
44
|
+
return Promise.all(deploys.map((deploy) => {
|
|
43
45
|
return rtdb
|
|
44
46
|
.updateRules(context.projectId, deploy.instance, ruleFiles[deploy.rules], { dryRun: true })
|
|
45
|
-
.then(
|
|
47
|
+
.then(() => {
|
|
46
48
|
utils.logSuccess(clc.bold.green("database: ") +
|
|
47
49
|
"rules syntax for database " +
|
|
48
50
|
clc.bold(deploy.instance) +
|
|
49
51
|
" is valid");
|
|
50
52
|
});
|
|
51
53
|
}));
|
|
52
|
-
}
|
|
54
|
+
}
|
|
55
|
+
exports.prepare = prepare;
|
|
@@ -1,27 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.release = void 0;
|
|
4
|
+
const clc = require("cli-color");
|
|
5
|
+
const rtdb = require("../../rtdb");
|
|
6
|
+
const utils = require("../../utils");
|
|
7
|
+
function release(context) {
|
|
6
8
|
if (!context.projectId ||
|
|
7
9
|
!context.database ||
|
|
8
10
|
!context.database.deploys ||
|
|
9
11
|
!context.database.ruleFiles) {
|
|
10
12
|
return Promise.resolve();
|
|
11
13
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
+
const deploys = context.database.deploys;
|
|
15
|
+
const ruleFiles = context.database.ruleFiles;
|
|
14
16
|
utils.logBullet(clc.bold.cyan("database: ") + "releasing rules...");
|
|
15
|
-
return Promise.all(deploys.map(
|
|
17
|
+
return Promise.all(deploys.map((deploy) => {
|
|
16
18
|
return rtdb
|
|
17
19
|
.updateRules(context.projectId, deploy.instance, ruleFiles[deploy.rules], {
|
|
18
20
|
dryRun: false,
|
|
19
21
|
})
|
|
20
|
-
.then(
|
|
22
|
+
.then(() => {
|
|
21
23
|
utils.logSuccess(clc.bold.green("database: ") +
|
|
22
24
|
"rules for database " +
|
|
23
25
|
clc.bold(deploy.instance) +
|
|
24
26
|
" released successfully");
|
|
25
27
|
});
|
|
26
28
|
}));
|
|
27
|
-
}
|
|
29
|
+
}
|
|
30
|
+
exports.release = release;
|
|
@@ -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,45 @@ 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
|
-
if (
|
|
96
|
-
bkEndpoint.serviceAccountEmail =
|
|
96
|
+
if (bdEndpoint.serviceAccount) {
|
|
97
|
+
bkEndpoint.serviceAccountEmail = bdEndpoint.serviceAccount;
|
|
97
98
|
}
|
|
98
99
|
bkEndpoints.push(bkEndpoint);
|
|
99
100
|
}
|
|
@@ -116,7 +117,7 @@ function discoverTrigger(endpoint) {
|
|
|
116
117
|
trigger = { callableTrigger: {} };
|
|
117
118
|
}
|
|
118
119
|
else if ("blockingTrigger" in endpoint) {
|
|
119
|
-
|
|
120
|
+
trigger = { blockingTrigger: endpoint.blockingTrigger };
|
|
120
121
|
}
|
|
121
122
|
else if ("eventTrigger" in endpoint) {
|
|
122
123
|
const bkEventFilters = {};
|
|
@@ -143,7 +144,18 @@ function discoverTrigger(endpoint) {
|
|
|
143
144
|
schedule: resolveString(endpoint.scheduleTrigger.schedule),
|
|
144
145
|
timeZone: resolveString(endpoint.scheduleTrigger.timeZone),
|
|
145
146
|
};
|
|
146
|
-
|
|
147
|
+
const bkRetry = {};
|
|
148
|
+
if (endpoint.scheduleTrigger.retryConfig.maxBackoffSeconds) {
|
|
149
|
+
bkRetry.maxBackoffDuration = proto.durationFromSeconds(resolveInt(endpoint.scheduleTrigger.retryConfig.maxBackoffSeconds));
|
|
150
|
+
}
|
|
151
|
+
if (endpoint.scheduleTrigger.retryConfig.minBackoffSeconds) {
|
|
152
|
+
bkRetry.minBackoffDuration = proto.durationFromSeconds(resolveInt(endpoint.scheduleTrigger.retryConfig.minBackoffSeconds));
|
|
153
|
+
}
|
|
154
|
+
if (endpoint.scheduleTrigger.retryConfig.maxRetrySeconds) {
|
|
155
|
+
bkRetry.maxRetryDuration = proto.durationFromSeconds(resolveInt(endpoint.scheduleTrigger.retryConfig.maxRetrySeconds));
|
|
156
|
+
}
|
|
157
|
+
proto.copyIfPresent(bkRetry, endpoint.scheduleTrigger.retryConfig, "retryCount", "maxDoublings");
|
|
158
|
+
bkSchedule.retryConfig = bkRetry;
|
|
147
159
|
trigger = { scheduleTrigger: bkSchedule };
|
|
148
160
|
}
|
|
149
161
|
else if ("taskQueueTrigger" in endpoint) {
|