firebase-tools 10.1.1 → 10.1.2
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/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-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/defaultCredentials.js +3 -3
- package/lib/deploy/functions/runtimes/golang/index.js +2 -1
- package/lib/emulator/downloadableEmulators.js +3 -2
- package/lib/emulator/functionsEmulator.js +6 -0
- package/lib/emulator/functionsEmulatorRuntime.js +4 -4
- 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 +58 -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/rules.js +18 -41
- 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 +1225 -2019
- package/package.json +12 -9
- package/lib/commands/functions-config-legacy.js +0 -45
- package/lib/prepareFirebaseRules.js +0 -58
package/lib/accountExporter.js
CHANGED
|
@@ -2,9 +2,13 @@
|
|
|
2
2
|
var os = require("os");
|
|
3
3
|
var path = require("path");
|
|
4
4
|
var _ = require("lodash");
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
const { Client } = require("./apiv2");
|
|
6
|
+
const { googleOrigin } = require("./api");
|
|
7
7
|
var { FirebaseError } = require("./error");
|
|
8
|
+
var utils = require("./utils");
|
|
9
|
+
const apiClient = new Client({
|
|
10
|
+
urlPrefix: googleOrigin,
|
|
11
|
+
});
|
|
8
12
|
var EXPORTED_JSON_KEYS = [
|
|
9
13
|
"localId",
|
|
10
14
|
"email",
|
|
@@ -149,12 +153,9 @@ var serialExportUsers = function (projectId, options) {
|
|
|
149
153
|
if (!options.timeoutRetryCount) {
|
|
150
154
|
options.timeoutRetryCount = 0;
|
|
151
155
|
}
|
|
152
|
-
return
|
|
153
|
-
.
|
|
154
|
-
|
|
155
|
-
json: true,
|
|
156
|
-
data: postBody,
|
|
157
|
-
origin: api.googleOrigin,
|
|
156
|
+
return apiClient
|
|
157
|
+
.post("/identitytoolkit/v3/relyingparty/downloadAccount", postBody, {
|
|
158
|
+
skipLog: { resBody: true },
|
|
158
159
|
})
|
|
159
160
|
.then(function (ret) {
|
|
160
161
|
options.timeoutRetryCount = 0;
|
package/lib/accountImporter.js
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var clc = require("cli-color");
|
|
3
3
|
var _ = require("lodash");
|
|
4
|
-
|
|
4
|
+
const { Client } = require("./apiv2");
|
|
5
|
+
const { googleOrigin } = require("./api");
|
|
5
6
|
const { logger } = require("./logger");
|
|
6
|
-
var utils = require("./utils");
|
|
7
7
|
var { FirebaseError } = require("./error");
|
|
8
|
+
var utils = require("./utils");
|
|
9
|
+
const apiClient = new Client({
|
|
10
|
+
urlPrefix: googleOrigin,
|
|
11
|
+
});
|
|
8
12
|
var ALLOWED_JSON_KEYS = [
|
|
9
13
|
"localId",
|
|
10
14
|
"email",
|
|
@@ -266,12 +270,10 @@ var validateUserJson = function (userJson) {
|
|
|
266
270
|
};
|
|
267
271
|
var _sendRequest = function (projectId, userList, hashOptions) {
|
|
268
272
|
logger.info("Starting importing " + userList.length + " account(s).");
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
data: _genUploadAccountPostBody(projectId, userList, hashOptions),
|
|
274
|
-
origin: api.googleOrigin,
|
|
273
|
+
const postData = _genUploadAccountPostBody(projectId, userList, hashOptions);
|
|
274
|
+
return apiClient
|
|
275
|
+
.post("/identitytoolkit/v3/relyingparty/uploadAccount", postData, {
|
|
276
|
+
skipLog: { body: true },
|
|
275
277
|
})
|
|
276
278
|
.then(function (ret) {
|
|
277
279
|
if (ret.body.error) {
|
package/lib/bin/firebase.js
CHANGED
|
@@ -15,7 +15,7 @@ if (!semver.satisfies(nodeVersion, pkg.engines.node)) {
|
|
|
15
15
|
const updateNotifier = require("update-notifier")({ pkg: pkg });
|
|
16
16
|
const clc = require("cli-color");
|
|
17
17
|
const TerminalRenderer = require("marked-terminal");
|
|
18
|
-
const marked = require("marked");
|
|
18
|
+
const marked = require("marked").marked;
|
|
19
19
|
marked.setOptions({
|
|
20
20
|
renderer: new TerminalRenderer(),
|
|
21
21
|
});
|
|
@@ -1,39 +1,40 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
module.exports = new Command("auth:export [dataFile]")
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const clc = require("cli-color");
|
|
4
|
+
const fs = require("fs");
|
|
5
|
+
const os = require("os");
|
|
6
|
+
const command_1 = require("../command");
|
|
7
|
+
const logger_1 = require("../logger");
|
|
8
|
+
const projectUtils_1 = require("../projectUtils");
|
|
9
|
+
const requirePermissions_1 = require("../requirePermissions");
|
|
10
|
+
const accountExporter_1 = require("../accountExporter");
|
|
11
|
+
const MAX_BATCH_SIZE = 1000;
|
|
12
|
+
exports.default = new command_1.Command("auth:export [dataFile]")
|
|
14
13
|
.description("Export accounts from your Firebase project into a data file")
|
|
15
|
-
.option("--format <format>", "Format of exported data (csv, json). Ignored if
|
|
16
|
-
.before(requirePermissions, ["firebaseauth.users.get"])
|
|
17
|
-
.action(
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
.option("--format <format>", "Format of exported data (csv, json). Ignored if <dataFile> has format extension.")
|
|
15
|
+
.before(requirePermissions_1.requirePermissions, ["firebaseauth.users.get"])
|
|
16
|
+
.action((dataFile, options) => {
|
|
17
|
+
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
18
|
+
const checkRes = (0, accountExporter_1.validateOptions)(options, dataFile);
|
|
20
19
|
if (!checkRes.format) {
|
|
21
20
|
return checkRes;
|
|
22
21
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
if (exportOptions.format === "json") {
|
|
22
|
+
const writeStream = fs.createWriteStream(dataFile);
|
|
23
|
+
if (checkRes.format === "json") {
|
|
26
24
|
writeStream.write('{"users": [' + os.EOL);
|
|
27
25
|
}
|
|
28
|
-
exportOptions
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
26
|
+
const exportOptions = {
|
|
27
|
+
format: checkRes.format,
|
|
28
|
+
writeStream,
|
|
29
|
+
batchSize: MAX_BATCH_SIZE,
|
|
30
|
+
};
|
|
31
|
+
logger_1.logger.info("Exporting accounts to " + clc.bold(dataFile));
|
|
32
|
+
return (0, accountExporter_1.serialExportUsers)(projectId, exportOptions).then(() => {
|
|
32
33
|
if (exportOptions.format === "json") {
|
|
33
34
|
writeStream.write("]}");
|
|
34
35
|
}
|
|
35
36
|
writeStream.end();
|
|
36
|
-
return new Promise(
|
|
37
|
+
return new Promise((resolve, reject) => {
|
|
37
38
|
writeStream.on("finish", resolve);
|
|
38
39
|
writeStream.on("close", resolve);
|
|
39
40
|
writeStream.on("error", reject);
|
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const csv_parse_1 = require("csv-parse");
|
|
4
|
+
const Chain = require("stream-chain");
|
|
5
|
+
const clc = require("cli-color");
|
|
6
|
+
const fs = require("fs-extra");
|
|
7
|
+
const Pick = require("stream-json/filters/Pick");
|
|
8
|
+
const StreamArray = require("stream-json/streamers/StreamArray");
|
|
9
|
+
const command_1 = require("../command");
|
|
10
|
+
const error_1 = require("../error");
|
|
11
|
+
const logger_1 = require("../logger");
|
|
12
|
+
const projectUtils_1 = require("../projectUtils");
|
|
13
|
+
const requirePermissions_1 = require("../requirePermissions");
|
|
14
|
+
const accountImporter = require("../accountImporter");
|
|
15
|
+
const MAX_BATCH_SIZE = 1000;
|
|
16
|
+
const validateOptions = accountImporter.validateOptions;
|
|
17
|
+
const validateUserJson = accountImporter.validateUserJson;
|
|
18
|
+
const transArrayToUser = accountImporter.transArrayToUser;
|
|
19
|
+
const serialImportUsers = accountImporter.serialImportUsers;
|
|
20
|
+
module.exports = new command_1.Command("auth:import [dataFile]")
|
|
19
21
|
.description("import users into your Firebase project from a data file(.csv or .json)")
|
|
20
22
|
.option("--hash-algo <hashAlgo>", "specify the hash algorithm used in password for these accounts")
|
|
21
23
|
.option("--hash-key <hashKey>", "specify the key used in hash algorithm")
|
|
@@ -27,81 +29,89 @@ module.exports = new Command("auth:import [dataFile]")
|
|
|
27
29
|
.option("--dk-len <dkLen>", "specify derived key length for standard scrypt.")
|
|
28
30
|
.option("--hash-input-order <hashInputOrder>", "specify the order of password and salt. Possible values are SALT_FIRST and PASSWORD_FIRST. " +
|
|
29
31
|
"MD5, SHA1, SHA256, SHA512, HMAC_MD5, HMAC_SHA1, HMAC_SHA256, HMAC_SHA512 support this flag.")
|
|
30
|
-
.before(requirePermissions, ["firebaseauth.users.create", "firebaseauth.users.update"])
|
|
31
|
-
.action(
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
.before(requirePermissions_1.requirePermissions, ["firebaseauth.users.create", "firebaseauth.users.update"])
|
|
33
|
+
.action(async (dataFile, options) => {
|
|
34
|
+
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
35
|
+
const checkRes = validateOptions(options);
|
|
34
36
|
if (!checkRes.valid) {
|
|
35
37
|
return checkRes;
|
|
36
38
|
}
|
|
37
|
-
|
|
38
|
-
if (!
|
|
39
|
-
|
|
39
|
+
const hashOptions = checkRes;
|
|
40
|
+
if (!dataFile.endsWith(".csv") && !dataFile.endsWith(".json")) {
|
|
41
|
+
throw new error_1.FirebaseError("Data file must end with .csv or .json");
|
|
40
42
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
logger.info(
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
parser =
|
|
43
|
+
const stats = await fs.stat(dataFile);
|
|
44
|
+
const fileSizeInBytes = stats.size;
|
|
45
|
+
logger_1.logger.info(`Processing ${clc.bold(dataFile)} (${fileSizeInBytes} bytes)`);
|
|
46
|
+
const batches = [];
|
|
47
|
+
let currentBatch = [];
|
|
48
|
+
let counter = 0;
|
|
49
|
+
let userListArr = [];
|
|
50
|
+
const inStream = fs.createReadStream(dataFile);
|
|
51
|
+
if (dataFile.endsWith(".csv")) {
|
|
52
|
+
userListArr = await new Promise((resolve, reject) => {
|
|
53
|
+
const parser = (0, csv_parse_1.parse)();
|
|
52
54
|
parser
|
|
53
|
-
.on("
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
55
|
+
.on("readable", () => {
|
|
56
|
+
let record = [];
|
|
57
|
+
while ((record = parser.read()) !== null) {
|
|
58
|
+
counter++;
|
|
59
|
+
const trimmed = record.map((s) => {
|
|
60
|
+
const str = s.trim().replace(/^["|'](.*)["|']$/, "$1");
|
|
61
|
+
return str === "" ? undefined : str;
|
|
62
|
+
});
|
|
63
|
+
const user = transArrayToUser(trimmed);
|
|
64
|
+
const err = user.error;
|
|
65
|
+
if (err) {
|
|
66
|
+
return reject(new error_1.FirebaseError(`Line ${counter} (${record.join(",")}) has invalid data format: ${err}`));
|
|
67
|
+
}
|
|
68
|
+
currentBatch.push(user);
|
|
69
|
+
if (currentBatch.length === MAX_BATCH_SIZE) {
|
|
70
|
+
batches.push(currentBatch);
|
|
71
|
+
currentBatch = [];
|
|
72
|
+
}
|
|
66
73
|
}
|
|
67
74
|
})
|
|
68
|
-
.on("end",
|
|
75
|
+
.on("end", () => {
|
|
69
76
|
if (currentBatch.length) {
|
|
70
77
|
batches.push(currentBatch);
|
|
71
78
|
}
|
|
72
|
-
|
|
79
|
+
resolve(batches);
|
|
73
80
|
});
|
|
74
81
|
inStream.pipe(parser);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
userListArr = await new Promise((resolve, reject) => {
|
|
86
|
+
const pipeline = new Chain([
|
|
87
|
+
Pick.withParser({ filter: /^users$/ }),
|
|
88
|
+
StreamArray.streamArray(),
|
|
89
|
+
({ value }) => {
|
|
90
|
+
counter++;
|
|
91
|
+
const user = validateUserJson(value);
|
|
92
|
+
const err = user.error;
|
|
93
|
+
if (err) {
|
|
94
|
+
throw new error_1.FirebaseError(`Validation Error: ${err}`);
|
|
95
|
+
}
|
|
96
|
+
currentBatch.push(user);
|
|
97
|
+
if (currentBatch.length === MAX_BATCH_SIZE) {
|
|
98
|
+
batches.push(currentBatch);
|
|
99
|
+
currentBatch = [];
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
]);
|
|
103
|
+
pipeline.once("error", reject);
|
|
104
|
+
pipeline.on("finish", () => {
|
|
92
105
|
if (currentBatch.length) {
|
|
93
106
|
batches.push(currentBatch);
|
|
94
107
|
}
|
|
95
|
-
|
|
108
|
+
resolve(batches);
|
|
96
109
|
});
|
|
97
|
-
inStream.pipe(
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}, function (error) {
|
|
105
|
-
return utils.reject(error, { exit: 1 });
|
|
106
|
-
});
|
|
110
|
+
inStream.pipe(pipeline);
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
logger_1.logger.debug(`Preparing to import ${counter} user records in ${userListArr.length} batches.`);
|
|
114
|
+
if (userListArr.length) {
|
|
115
|
+
return serialImportUsers(projectId, hashOptions, userListArr, 0);
|
|
116
|
+
}
|
|
107
117
|
});
|
|
@@ -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 marked = require("marked");
|
|
5
|
+
const { marked } = require("marked");
|
|
6
6
|
const ora = require("ora");
|
|
7
7
|
const TerminalRenderer = require("marked-terminal");
|
|
8
8
|
const checkMinRequiredVersion_1 = require("../checkMinRequiredVersion");
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const fs = require("fs");
|
|
4
4
|
const path = require("path");
|
|
5
|
-
const marked = require("marked");
|
|
5
|
+
const { marked } = require("marked");
|
|
6
6
|
const TerminalRenderer = require("marked-terminal");
|
|
7
7
|
const checkMinRequiredVersion_1 = require("../checkMinRequiredVersion");
|
|
8
8
|
const command_1 = require("../command");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const clc = require("cli-color");
|
|
4
|
-
const marked = require("marked");
|
|
4
|
+
const { marked } = require("marked");
|
|
5
5
|
const TerminalRenderer = require("marked-terminal");
|
|
6
6
|
const command_1 = require("../command");
|
|
7
7
|
const extensionsHelper_1 = require("../extensions/extensionsHelper");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const clc = require("cli-color");
|
|
4
|
-
const marked = require("marked");
|
|
4
|
+
const { marked } = require("marked");
|
|
5
5
|
const command_1 = require("../command");
|
|
6
6
|
const extensionsApi_1 = require("../extensions/extensionsApi");
|
|
7
7
|
const projectUtils_1 = require("../projectUtils");
|
package/lib/commands/ext-info.js
CHANGED
|
@@ -10,7 +10,7 @@ const localHelper_1 = require("../extensions/localHelper");
|
|
|
10
10
|
const logger_1 = require("../logger");
|
|
11
11
|
const requirePermissions_1 = require("../requirePermissions");
|
|
12
12
|
const utils = require("../utils");
|
|
13
|
-
const marked = require("marked");
|
|
13
|
+
const { marked } = require("marked");
|
|
14
14
|
const TerminalRenderer = require("marked-terminal");
|
|
15
15
|
const FUNCTION_TYPE_REGEX = /\..+\.function/;
|
|
16
16
|
exports.default = new command_1.Command("ext:info <extensionName>")
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const clc = require("cli-color");
|
|
4
|
-
const marked = require("marked");
|
|
4
|
+
const { marked } = require("marked");
|
|
5
5
|
const ora = require("ora");
|
|
6
6
|
const TerminalRenderer = require("marked-terminal");
|
|
7
7
|
const askUserForConsent = require("../extensions/askUserForConsent");
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const _ = require("lodash");
|
|
4
4
|
const clc = require("cli-color");
|
|
5
5
|
const ora = require("ora");
|
|
6
|
-
const marked = require("marked");
|
|
6
|
+
const { marked } = require("marked");
|
|
7
7
|
const TerminalRenderer = require("marked-terminal");
|
|
8
8
|
const checkMinRequiredVersion_1 = require("../checkMinRequiredVersion");
|
|
9
9
|
const command_1 = require("../command");
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const clc = require("cli-color");
|
|
4
4
|
const _ = require("lodash");
|
|
5
|
-
const marked = require("marked");
|
|
5
|
+
const { marked } = require("marked");
|
|
6
6
|
const ora = require("ora");
|
|
7
7
|
const TerminalRenderer = require("marked-terminal");
|
|
8
8
|
const checkMinRequiredVersion_1 = require("../checkMinRequiredVersion");
|
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
|
|
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 projectUtils_1 = require("../projectUtils");
|
|
8
|
+
const requirePermissions_1 = require("../requirePermissions");
|
|
9
|
+
const functionsConfig = require("../functionsConfig");
|
|
10
|
+
const functionsConfigClone = require("../functionsConfigClone");
|
|
11
|
+
const utils = require("../utils");
|
|
12
|
+
exports.default = new command_1.Command("functions:config:clone")
|
|
11
13
|
.description("clone environment config from another project")
|
|
12
14
|
.option("--from <projectId>", "the project from which to clone configuration")
|
|
13
15
|
.option("--only <keys>", "a comma-separated list of keys to clone")
|
|
14
16
|
.option("--except <keys>", "a comma-separated list of keys to not clone")
|
|
15
|
-
.before(requirePermissions, [
|
|
17
|
+
.before(requirePermissions_1.requirePermissions, [
|
|
16
18
|
"runtimeconfig.configs.list",
|
|
17
19
|
"runtimeconfig.configs.create",
|
|
18
20
|
"runtimeconfig.configs.get",
|
|
@@ -25,29 +27,26 @@ module.exports = new Command("functions:config:clone")
|
|
|
25
27
|
"runtimeconfig.variables.delete",
|
|
26
28
|
])
|
|
27
29
|
.before(functionsConfig.ensureApi)
|
|
28
|
-
.action(
|
|
29
|
-
|
|
30
|
+
.action(async (options) => {
|
|
31
|
+
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
30
32
|
if (!options.from) {
|
|
31
|
-
|
|
33
|
+
throw new error_1.FirebaseError(`Must specify a source project in ${clc.bold("--from <projectId>")} option.`);
|
|
32
34
|
}
|
|
33
35
|
else if (options.from === projectId) {
|
|
34
|
-
|
|
36
|
+
throw new error_1.FirebaseError("From project and destination can't be the same project.");
|
|
35
37
|
}
|
|
36
38
|
else if (options.only && options.except) {
|
|
37
|
-
|
|
39
|
+
throw new error_1.FirebaseError("Cannot use both --only and --except at the same time.");
|
|
38
40
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
+
let only = [];
|
|
42
|
+
let except = [];
|
|
41
43
|
if (options.only) {
|
|
42
44
|
only = options.only.split(",");
|
|
43
45
|
}
|
|
44
46
|
else if (options.except) {
|
|
45
47
|
except = options.except.split(",");
|
|
46
48
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
clc.bold("firebase deploy --only functions") +
|
|
51
|
-
"\n");
|
|
52
|
-
});
|
|
49
|
+
await functionsConfigClone(options.from, projectId, only, except);
|
|
50
|
+
utils.logSuccess(`Cloned functions config from ${clc.bold(options.from)} into ${clc.bold(projectId)}`);
|
|
51
|
+
logger_1.logger.info(`\nPlease deploy your functions for the change to take effect by running ${clc.bold("firebase deploy --only functions")}\n`);
|
|
53
52
|
});
|
|
@@ -1,34 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const lodash_1 = require("lodash");
|
|
4
|
+
const path_1 = require("path");
|
|
5
|
+
const command_1 = require("../command");
|
|
6
|
+
const logger_1 = require("../logger");
|
|
7
|
+
const projectUtils_1 = require("../projectUtils");
|
|
8
|
+
const requirePermissions_1 = require("../requirePermissions");
|
|
9
|
+
const functionsConfig = require("../functionsConfig");
|
|
10
|
+
async function materialize(projectId, path) {
|
|
11
|
+
if (path === undefined) {
|
|
10
12
|
return functionsConfig.materializeAll(projectId);
|
|
11
13
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
});
|
|
14
|
+
const parts = path.split(".");
|
|
15
|
+
const configId = parts[0];
|
|
16
|
+
const configName = (0, path_1.join)("projects", projectId, "configs", configId);
|
|
17
|
+
const result = await functionsConfig.materializeConfig(configName, {});
|
|
18
|
+
const query = parts.join(".");
|
|
19
|
+
return query ? (0, lodash_1.get)(result, query) : result;
|
|
19
20
|
}
|
|
20
|
-
|
|
21
|
+
exports.default = new command_1.Command("functions:config:get [path]")
|
|
21
22
|
.description("fetch environment config stored at the given path")
|
|
22
|
-
.before(requirePermissions, [
|
|
23
|
+
.before(requirePermissions_1.requirePermissions, [
|
|
23
24
|
"runtimeconfig.configs.list",
|
|
24
25
|
"runtimeconfig.configs.get",
|
|
25
26
|
"runtimeconfig.variables.list",
|
|
26
27
|
"runtimeconfig.variables.get",
|
|
27
28
|
])
|
|
28
29
|
.before(functionsConfig.ensureApi)
|
|
29
|
-
.action(
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
});
|
|
30
|
+
.action(async (path, options) => {
|
|
31
|
+
const result = await materialize((0, projectUtils_1.needProjectId)(options), path);
|
|
32
|
+
logger_1.logger.info(JSON.stringify(result, null, 2));
|
|
33
|
+
return result;
|
|
34
34
|
});
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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 projectUtils_1 = require("../projectUtils");
|
|
8
|
+
const requirePermissions_1 = require("../requirePermissions");
|
|
9
|
+
const functionsConfig = require("../functionsConfig");
|
|
10
|
+
const utils = require("../utils");
|
|
11
|
+
exports.default = new command_1.Command("functions:config:set [values...]")
|
|
10
12
|
.description("set environment config with key=value syntax")
|
|
11
|
-
.before(requirePermissions, [
|
|
13
|
+
.before(requirePermissions_1.requirePermissions, [
|
|
12
14
|
"runtimeconfig.configs.list",
|
|
13
15
|
"runtimeconfig.configs.create",
|
|
14
16
|
"runtimeconfig.configs.get",
|
|
@@ -21,20 +23,20 @@ module.exports = new Command("functions:config:set [values...]")
|
|
|
21
23
|
"runtimeconfig.variables.delete",
|
|
22
24
|
])
|
|
23
25
|
.before(functionsConfig.ensureApi)
|
|
24
|
-
.action(
|
|
26
|
+
.action(async (args, options) => {
|
|
25
27
|
if (!args.length) {
|
|
26
|
-
|
|
28
|
+
throw new error_1.FirebaseError(`Must supply at least one key/value pair, e.g. ${clc.bold('app.name="My App"')}`);
|
|
27
29
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
31
|
+
const parsed = functionsConfig.parseSetArgs(args);
|
|
32
|
+
const promises = [];
|
|
33
|
+
for (const item of parsed) {
|
|
34
|
+
if (item.val === undefined) {
|
|
35
|
+
throw new error_1.FirebaseError(`Unexpected undefined value for varId "${item.varId}`, { exit: 2 });
|
|
36
|
+
}
|
|
32
37
|
promises.push(functionsConfig.setVariablesRecursive(projectId, item.configId, item.varId, item.val));
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
clc.bold("firebase deploy --only functions") +
|
|
38
|
-
"\n");
|
|
39
|
-
});
|
|
38
|
+
}
|
|
39
|
+
await Promise.all(promises);
|
|
40
|
+
utils.logSuccess("Functions config updated.");
|
|
41
|
+
logger_1.logger.info(`\nPlease deploy your functions for the change to take effect by running ${clc.bold("firebase deploy --only functions")}\n`);
|
|
40
42
|
});
|