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,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");
|
|
@@ -58,14 +58,14 @@ module.exports = new command_1.Command("ext:dev:usage <publisherId>")
|
|
|
58
58
|
}
|
|
59
59
|
const profile = await (0, extensionsApi_1.getPublisherProfile)("-", publisherId);
|
|
60
60
|
const projectNumber = (0, extensionsHelper_1.getPublisherProjectFromName)(profile.name);
|
|
61
|
-
const
|
|
62
|
-
|
|
61
|
+
const past45d = new Date();
|
|
62
|
+
past45d.setDate(past45d.getDate() - 45);
|
|
63
63
|
const query = {
|
|
64
64
|
filter: `metric.type="firebaseextensions.googleapis.com/extension/version/active_instances" ` +
|
|
65
65
|
`resource.type="firebaseextensions.googleapis.com/ExtensionVersion" ` +
|
|
66
66
|
`resource.labels.extension="${extensionName}"`,
|
|
67
67
|
"interval.endTime": new Date().toJSON(),
|
|
68
|
-
"interval.startTime":
|
|
68
|
+
"interval.startTime": past45d.toJSON(),
|
|
69
69
|
view: cloudmonitoring_1.TimeSeriesView.FULL,
|
|
70
70
|
"aggregation.alignmentPeriod": (60 * 60 * 24).toString() + "s",
|
|
71
71
|
"aggregation.perSeriesAligner": cloudmonitoring_1.Aligner.ALIGN_MAX,
|
|
@@ -95,15 +95,10 @@ module.exports = new command_1.Command("ext:dev:usage <publisherId>")
|
|
|
95
95
|
});
|
|
96
96
|
utils.logLabeledBullet(extensionsHelper_1.logPrefix, `showing usage stats for ${clc.bold(extensionName)}:`);
|
|
97
97
|
logger_1.logger.info(table.toString());
|
|
98
|
-
const link = await buildCloudMonitoringLink({
|
|
99
|
-
projectNumber: projectNumber,
|
|
100
|
-
extensionName,
|
|
101
|
-
});
|
|
102
98
|
utils.logLabeledBullet(extensionsHelper_1.logPrefix, `How to read this table:`);
|
|
103
99
|
logger_1.logger.info(`* Due to privacy considerations, numbers are reported as ranges.`);
|
|
104
100
|
logger_1.logger.info(`* In the absence of significant changes, we will render a '-' symbol.`);
|
|
105
101
|
logger_1.logger.info(`* You will need more than 10 installs over a period of more than 28 days to render sufficient data.`);
|
|
106
|
-
logger_1.logger.info(`For more detail, visit: ${link}`);
|
|
107
102
|
});
|
|
108
103
|
async function buildCloudMonitoringLink(args) {
|
|
109
104
|
const pageState = {
|
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
|
});
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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 requirePermissions_1 = require("../requirePermissions");
|
|
7
|
+
const projectUtils_1 = require("../projectUtils");
|
|
8
|
+
const functionsConfig = require("../functionsConfig");
|
|
9
|
+
const runtimeconfig = require("../gcp/runtimeconfig");
|
|
10
|
+
const utils = require("../utils");
|
|
11
|
+
const error_1 = require("../error");
|
|
12
|
+
exports.default = new command_1.Command("functions:config:unset [keys...]")
|
|
12
13
|
.description("unset environment config at the specified path(s)")
|
|
13
|
-
.before(requirePermissions, [
|
|
14
|
+
.before(requirePermissions_1.requirePermissions, [
|
|
14
15
|
"runtimeconfig.configs.list",
|
|
15
16
|
"runtimeconfig.configs.create",
|
|
16
17
|
"runtimeconfig.configs.get",
|
|
@@ -23,21 +24,18 @@ module.exports = new Command("functions:config:unset [keys...]")
|
|
|
23
24
|
"runtimeconfig.variables.delete",
|
|
24
25
|
])
|
|
25
26
|
.before(functionsConfig.ensureApi)
|
|
26
|
-
.action(
|
|
27
|
+
.action(async (args, options) => {
|
|
27
28
|
if (!args.length) {
|
|
28
|
-
|
|
29
|
+
throw new error_1.FirebaseError("Must supply at least one key");
|
|
29
30
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
32
|
+
const parsed = functionsConfig.parseUnsetArgs(args);
|
|
33
|
+
await Promise.all(parsed.map((item) => {
|
|
33
34
|
if (item.varId === "") {
|
|
34
35
|
return runtimeconfig.configs.delete(projectId, item.configId);
|
|
35
36
|
}
|
|
36
37
|
return runtimeconfig.variables.delete(projectId, item.configId, item.varId);
|
|
37
|
-
}))
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
clc.bold("firebase deploy --only functions") +
|
|
41
|
-
"\n");
|
|
42
|
-
});
|
|
38
|
+
}));
|
|
39
|
+
utils.logSuccess("Environment updated.");
|
|
40
|
+
logger_1.logger.info(`\nPlease deploy your functions for the change to take effect by running ${clc.bold("firebase deploy --only functions")}\n`);
|
|
43
41
|
});
|
package/lib/commands/help.js
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
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 utils = require("../utils");
|
|
7
|
+
exports.default = new command_1.Command("help [command]")
|
|
7
8
|
.description("display help information")
|
|
8
9
|
.action(function (commandName) {
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
const client = this.client;
|
|
11
|
+
const cmd = client.getCommand(commandName);
|
|
11
12
|
if (cmd) {
|
|
12
13
|
cmd.outputHelp();
|
|
13
14
|
}
|
|
14
15
|
else if (commandName) {
|
|
15
|
-
logger.warn();
|
|
16
|
+
logger_1.logger.warn();
|
|
16
17
|
utils.logWarning(clc.bold(commandName) + " is not a valid command. See below for valid commands");
|
|
17
18
|
client.cli.outputHelp();
|
|
18
19
|
}
|
|
19
20
|
else {
|
|
20
21
|
client.cli.outputHelp();
|
|
21
|
-
logger.info();
|
|
22
|
-
logger.info(" To get help with a specific command, type", clc.bold("firebase help [command_name]"));
|
|
23
|
-
logger.info();
|
|
22
|
+
logger_1.logger.info();
|
|
23
|
+
logger_1.logger.info(" To get help with a specific command, type", clc.bold("firebase help [command_name]"));
|
|
24
|
+
logger_1.logger.info();
|
|
24
25
|
}
|
|
25
|
-
return Promise.resolve();
|
|
26
26
|
});
|
|
@@ -11,7 +11,7 @@ const requirePermissions_1 = require("../requirePermissions");
|
|
|
11
11
|
const projectUtils_1 = require("../projectUtils");
|
|
12
12
|
const logger_1 = require("../logger");
|
|
13
13
|
const requireConfig = require("../requireConfig");
|
|
14
|
-
const marked = require("marked");
|
|
14
|
+
const { marked } = require("marked");
|
|
15
15
|
const requireHostingSite_1 = require("../requireHostingSite");
|
|
16
16
|
const LOG_TAG = "hosting:channel";
|
|
17
17
|
exports.default = new command_1.Command("hosting:channel:create [channelId]")
|