firebase-tools 11.0.1 → 11.2.1
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 +11 -4
- package/lib/accountImporter.js +93 -95
- package/lib/api.js +77 -218
- package/lib/apiv2.js +5 -4
- package/lib/appdistribution/client.js +7 -9
- package/lib/auth.js +72 -52
- package/lib/bin/firebase.js +42 -47
- package/lib/checkValidTargetFilters.js +36 -25
- 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 +4 -4
- package/lib/commands/database-push.js +4 -4
- package/lib/commands/database-remove.js +3 -3
- 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 +3 -3
- 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 +26 -25
- 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 +3 -2
- package/lib/commands/ext-dev-emulators-start.js +3 -2
- 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 +8 -8
- 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 +14 -14
- 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 +4 -4
- 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 +3 -8
- 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 +7 -7
- 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 +30 -30
- 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 -53
- package/lib/config.js +7 -6
- package/lib/deploy/database/deploy.js +3 -2
- package/lib/deploy/database/index.js +8 -5
- package/lib/deploy/database/prepare.js +22 -20
- package/lib/deploy/database/release.js +12 -9
- package/lib/deploy/extensions/secrets.js +3 -3
- package/lib/deploy/firestore/prepare.js +2 -2
- package/lib/deploy/functions/build.js +33 -20
- package/lib/deploy/functions/ensure.js +1 -11
- package/lib/deploy/functions/prepare.js +3 -13
- package/lib/deploy/functions/prepareFunctionsUpload.js +2 -3
- package/lib/deploy/functions/release/fabricator.js +0 -1
- package/lib/deploy/functions/release/index.js +1 -5
- package/lib/deploy/functions/runtimes/discovery/index.js +18 -3
- package/lib/deploy/functions/runtimes/discovery/v1alpha1.js +188 -54
- package/lib/deploy/functions/runtimes/golang/index.js +2 -22
- package/lib/deploy/functions/runtimes/node/index.js +3 -7
- package/lib/deploy/functions/runtimes/node/parseTriggers.js +16 -4
- 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 +27 -27
- package/lib/deploy/remoteconfig/prepare.js +2 -2
- package/lib/deploy/storage/prepare.js +1 -1
- package/lib/emulator/auth/apiSpec.js +14 -46
- package/lib/emulator/auth/index.js +1 -1
- package/lib/emulator/auth/operations.js +342 -93
- package/lib/emulator/auth/server.js +2 -2
- package/lib/emulator/auth/state.js +34 -32
- package/lib/emulator/commandUtils.js +1 -1
- package/lib/emulator/constants.js +1 -1
- package/lib/emulator/controller.js +7 -6
- package/lib/emulator/databaseEmulator.js +4 -4
- package/lib/emulator/download.js +1 -1
- package/lib/emulator/downloadableEmulators.js +5 -5
- package/lib/emulator/events/types.js +2 -3
- package/lib/emulator/firestoreEmulator.js +2 -2
- package/lib/emulator/functionsEmulator.js +31 -45
- package/lib/emulator/functionsEmulatorRuntime.js +12 -16
- package/lib/emulator/functionsEmulatorShared.js +7 -5
- package/lib/emulator/functionsRuntimeWorker.js +0 -6
- package/lib/emulator/hostingEmulator.js +1 -1
- package/lib/emulator/hub.js +1 -1
- package/lib/emulator/loggingEmulator.js +1 -1
- package/lib/emulator/pubsubEmulator.js +1 -1
- package/lib/emulator/storage/crc.js +4 -4
- package/lib/emulator/storage/index.js +1 -1
- package/lib/emulator/types.js +1 -1
- package/lib/errorOut.js +2 -2
- package/lib/extensions/askUserForConsent.js +1 -2
- package/lib/extensions/askUserForParam.js +15 -18
- package/lib/extensions/emulator/optionsHelper.js +4 -4
- package/lib/extensions/extensionsApi.js +1 -22
- package/lib/extensions/extensionsHelper.js +6 -6
- package/lib/extensions/listExtensions.js +9 -10
- package/lib/extensions/manifest.js +2 -2
- package/lib/extensions/resolveSource.js +11 -7
- package/lib/extensions/secretsUtils.js +3 -3
- package/lib/extensions/types.js +24 -0
- package/lib/extensions/updateHelper.js +1 -1
- package/lib/extensions/utils.js +1 -2
- package/lib/extensions/warnings.js +3 -3
- package/lib/firestore/encodeFirestoreValue.js +11 -8
- package/lib/fsAsync.js +3 -3
- package/lib/functions/events/v2.js +7 -1
- package/lib/functionsConfig.js +17 -14
- package/lib/functionsConfigClone.js +46 -46
- package/lib/gcp/cloudfunctions.js +2 -15
- package/lib/gcp/cloudfunctionsv2.js +17 -2
- package/lib/gcp/iam.js +1 -1
- package/lib/gcp/index.js +10 -10
- package/lib/gcp/rules.js +1 -1
- package/lib/gcp/runtimeconfig.js +45 -47
- package/lib/hosting/proxy.js +1 -1
- 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 +6 -5
- package/lib/init/features/hosting/index.js +2 -2
- package/lib/loadCJSON.js +9 -6
- package/lib/localFunction.js +4 -4
- package/lib/logError.js +15 -12
- package/lib/parseBoltRules.js +15 -14
- package/lib/previews.js +1 -1
- package/lib/profileReport.js +504 -512
- package/lib/profiler.js +4 -4
- package/lib/prompt.js +1 -2
- package/lib/rc.js +1 -1
- package/lib/requireAuth.js +0 -1
- package/lib/responseToError.js +8 -5
- package/lib/rulesDeploy.js +2 -2
- package/lib/scopes.js +9 -9
- package/lib/serve/index.js +4 -5
- package/lib/utils.js +30 -6
- package/npm-shrinkwrap.json +537 -193
- package/package.json +17 -14
package/lib/commands/serve.js
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.command = void 0;
|
|
4
|
+
const clc = require("cli-color");
|
|
5
|
+
const command_1 = require("../command");
|
|
6
|
+
const logger_1 = require("../logger");
|
|
7
|
+
const utils = require("../utils");
|
|
8
|
+
const requirePermissions_1 = require("../requirePermissions");
|
|
9
|
+
const requireConfig_1 = require("../requireConfig");
|
|
10
|
+
const index_1 = require("../serve/index");
|
|
11
|
+
const filterTargets_1 = require("../filterTargets");
|
|
12
|
+
const projectUtils_1 = require("../projectUtils");
|
|
13
|
+
const error_1 = require("../error");
|
|
14
|
+
const VALID_TARGETS = ["hosting", "functions"];
|
|
15
|
+
const REQUIRES_AUTH = ["hosting", "functions"];
|
|
16
|
+
const ALL_TARGETS = Array.from(new Set(["database", "firestore", ...VALID_TARGETS]));
|
|
17
|
+
function filterOnly(list, only = "") {
|
|
17
18
|
if (!only) {
|
|
18
19
|
return [];
|
|
19
20
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
module.exports = new Command("serve")
|
|
21
|
+
const targets = only.split(",").map((o) => o.split(":")[0]);
|
|
22
|
+
return targets.filter((t) => list.includes(t));
|
|
23
|
+
}
|
|
24
|
+
exports.command = new command_1.Command("serve")
|
|
25
25
|
.description("start a local server for your static assets")
|
|
26
26
|
.option("-p, --port <port>", "the port on which to listen (default: 5000)", 5000)
|
|
27
27
|
.option("-o, --host <host>", "the host on which to listen (default: localhost)", "localhost")
|
|
@@ -33,28 +33,28 @@ module.exports = new Command("serve")
|
|
|
33
33
|
filterOnly(REQUIRES_AUTH, options.only).length === 0) {
|
|
34
34
|
return Promise.resolve();
|
|
35
35
|
}
|
|
36
|
-
return requireConfig(options)
|
|
37
|
-
.then(() => requirePermissions(options))
|
|
38
|
-
.then(() => needProjectNumber(options));
|
|
36
|
+
return (0, requireConfig_1.requireConfig)(options)
|
|
37
|
+
.then(() => (0, requirePermissions_1.requirePermissions)(options))
|
|
38
|
+
.then(() => (0, projectUtils_1.needProjectNumber)(options));
|
|
39
39
|
})
|
|
40
40
|
.action((options) => {
|
|
41
41
|
options.targets = filterOnly(ALL_TARGETS, options.only);
|
|
42
42
|
if (options.targets.includes("database") || options.targets.includes("firestore")) {
|
|
43
|
-
throw new FirebaseError(`Please use ${clc.bold("firebase emulators:start")} to start the Realtime Database or Cloud Firestore emulators. ${clc.bold("firebase serve")} only supports Hosting and Cloud Functions.`);
|
|
43
|
+
throw new error_1.FirebaseError(`Please use ${clc.bold("firebase emulators:start")} to start the Realtime Database or Cloud Firestore emulators. ${clc.bold("firebase serve")} only supports Hosting and Cloud Functions.`);
|
|
44
44
|
}
|
|
45
45
|
options.targets = filterOnly(VALID_TARGETS, options.only);
|
|
46
46
|
if (options.targets.length > 0) {
|
|
47
|
-
return serve(options);
|
|
47
|
+
return (0, index_1.serve)(options);
|
|
48
48
|
}
|
|
49
49
|
if (options.config) {
|
|
50
|
-
logger.info();
|
|
51
|
-
logger.info(clc.bold(clc.white("===") + " Serving from '" + options.config.projectDir + "'..."));
|
|
52
|
-
logger.info();
|
|
50
|
+
logger_1.logger.info();
|
|
51
|
+
logger_1.logger.info(clc.bold(clc.white("===") + " Serving from '" + options.config.projectDir + "'..."));
|
|
52
|
+
logger_1.logger.info();
|
|
53
53
|
}
|
|
54
54
|
else {
|
|
55
55
|
utils.logWarning("No Firebase project directory detected. Serving static content from " +
|
|
56
56
|
clc.bold(options.cwd || process.cwd()));
|
|
57
57
|
}
|
|
58
|
-
options.targets = filterTargets(options, VALID_TARGETS);
|
|
59
|
-
return serve(options);
|
|
58
|
+
options.targets = (0, filterTargets_1.filterTargets)(options, VALID_TARGETS);
|
|
59
|
+
return (0, index_1.serve)(options);
|
|
60
60
|
});
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.command = void 0;
|
|
3
4
|
const command_1 = require("../command");
|
|
4
5
|
const download_1 = require("../emulator/download");
|
|
5
6
|
const types_1 = require("../emulator/types");
|
|
6
7
|
const NAME = types_1.Emulators.DATABASE;
|
|
7
|
-
exports.
|
|
8
|
+
exports.command = new command_1.Command(`setup:emulators:${NAME}`)
|
|
8
9
|
.description(`downloads the ${NAME} emulator`)
|
|
9
10
|
.action(() => {
|
|
10
11
|
return (0, download_1.downloadEmulator)(NAME);
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.command = void 0;
|
|
3
4
|
const command_1 = require("../command");
|
|
4
5
|
const download_1 = require("../emulator/download");
|
|
5
6
|
const types_1 = require("../emulator/types");
|
|
6
7
|
const NAME = types_1.Emulators.FIRESTORE;
|
|
7
|
-
exports.
|
|
8
|
+
exports.command = new command_1.Command(`setup:emulators:${NAME}`)
|
|
8
9
|
.description(`downloads the ${NAME} emulator`)
|
|
9
10
|
.action(() => {
|
|
10
11
|
return (0, download_1.downloadEmulator)(NAME);
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.command = void 0;
|
|
3
4
|
const command_1 = require("../command");
|
|
4
5
|
const download_1 = require("../emulator/download");
|
|
5
6
|
const types_1 = require("../emulator/types");
|
|
6
7
|
const EMULATOR_NAME = types_1.Emulators.PUBSUB;
|
|
7
|
-
exports.
|
|
8
|
+
exports.command = new command_1.Command(`setup:emulators:${EMULATOR_NAME}`)
|
|
8
9
|
.description(`downloads the ${EMULATOR_NAME} emulator`)
|
|
9
10
|
.action(() => {
|
|
10
11
|
return (0, download_1.downloadEmulator)(EMULATOR_NAME);
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.command = void 0;
|
|
3
4
|
const command_1 = require("../command");
|
|
4
5
|
const download_1 = require("../emulator/download");
|
|
5
6
|
const types_1 = require("../emulator/types");
|
|
6
7
|
const EMULATOR_NAME = types_1.Emulators.STORAGE;
|
|
7
|
-
exports.
|
|
8
|
+
exports.command = new command_1.Command(`setup:emulators:${EMULATOR_NAME}`)
|
|
8
9
|
.description(`downloads the ${EMULATOR_NAME} emulator`)
|
|
9
10
|
.action(() => {
|
|
10
11
|
return (0, download_1.downloadEmulator)(EMULATOR_NAME);
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.command = void 0;
|
|
3
4
|
const command_1 = require("../command");
|
|
4
5
|
const download_1 = require("../emulator/download");
|
|
5
6
|
const types_1 = require("../emulator/types");
|
|
6
7
|
const NAME = types_1.Emulators.UI;
|
|
7
|
-
exports.
|
|
8
|
+
exports.command = new command_1.Command(`setup:emulators:${NAME}`)
|
|
8
9
|
.description(`downloads the ${NAME} emulator`)
|
|
9
10
|
.action(() => {
|
|
10
11
|
return (0, download_1.downloadEmulator)(NAME);
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.command = void 0;
|
|
3
4
|
const clc = require("cli-color");
|
|
4
5
|
const command_1 = require("../command");
|
|
5
6
|
const logger_1 = require("../logger");
|
|
6
7
|
const requireConfig_1 = require("../requireConfig");
|
|
7
8
|
const utils = require("../utils");
|
|
8
9
|
const error_1 = require("../error");
|
|
9
|
-
exports.
|
|
10
|
+
exports.command = new command_1.Command("target:apply <type> <name> <resources...>")
|
|
10
11
|
.description("apply a deploy target to a resource")
|
|
11
12
|
.before(requireConfig_1.requireConfig)
|
|
12
13
|
.action((type, name, resources, options) => {
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.command = void 0;
|
|
3
4
|
const clc = require("cli-color");
|
|
4
5
|
const command_1 = require("../command");
|
|
5
6
|
const requireConfig_1 = require("../requireConfig");
|
|
6
7
|
const utils = require("../utils");
|
|
7
|
-
exports.
|
|
8
|
+
exports.command = new command_1.Command("target:clear <type> <target>")
|
|
8
9
|
.description("clear all resources from a named resource target")
|
|
9
10
|
.before(requireConfig_1.requireConfig)
|
|
10
11
|
.action((type, name, options) => {
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.command = void 0;
|
|
3
4
|
const clc = require("cli-color");
|
|
4
5
|
const command_1 = require("../command");
|
|
5
6
|
const requireConfig_1 = require("../requireConfig");
|
|
6
7
|
const utils = require("../utils");
|
|
7
|
-
exports.
|
|
8
|
+
exports.command = new command_1.Command("target:remove <type> <resource>")
|
|
8
9
|
.description("remove a resource target")
|
|
9
10
|
.before(requireConfig_1.requireConfig)
|
|
10
11
|
.action((type, resource, options) => {
|
package/lib/commands/target.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.command = void 0;
|
|
3
4
|
const clc = require("cli-color");
|
|
4
5
|
const command_1 = require("../command");
|
|
5
6
|
const logger_1 = require("../logger");
|
|
@@ -11,7 +12,7 @@ function logTargets(type, targets) {
|
|
|
11
12
|
logger_1.logger.info(name, "(" + (resources || []).join(",") + ")");
|
|
12
13
|
}
|
|
13
14
|
}
|
|
14
|
-
exports.
|
|
15
|
+
exports.command = new command_1.Command("target [type]")
|
|
15
16
|
.description("display configured deploy targets for the current project")
|
|
16
17
|
.before(requireConfig_1.requireConfig)
|
|
17
18
|
.action((type, options) => {
|
package/lib/commands/use.js
CHANGED
|
@@ -1,43 +1,44 @@
|
|
|
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 clc = require("cli-color");
|
|
5
|
+
const command_1 = require("../command");
|
|
6
|
+
const projects_1 = require("../management/projects");
|
|
7
|
+
const logger_1 = require("../logger");
|
|
8
|
+
const prompt_1 = require("../prompt");
|
|
9
|
+
const requireAuth_1 = require("../requireAuth");
|
|
10
|
+
const command_2 = require("../command");
|
|
11
|
+
const utils = require("../utils");
|
|
12
|
+
function listAliases(options) {
|
|
12
13
|
if (options.rc.hasProjects) {
|
|
13
|
-
logger.info("Project aliases for", clc.bold(options.projectRoot) + ":");
|
|
14
|
-
logger.info();
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
logger_1.logger.info("Project aliases for", clc.bold(options.projectRoot) + ":");
|
|
15
|
+
logger_1.logger.info();
|
|
16
|
+
for (const [alias, projectId] of Object.entries(options.rc.projects)) {
|
|
17
|
+
const listing = alias + " (" + projectId + ")";
|
|
17
18
|
if (options.project === projectId || options.projectAlias === alias) {
|
|
18
|
-
logger.info(clc.cyan.bold("* " + listing));
|
|
19
|
+
logger_1.logger.info(clc.cyan.bold("* " + listing));
|
|
19
20
|
}
|
|
20
21
|
else {
|
|
21
|
-
logger.info(" " + listing);
|
|
22
|
+
logger_1.logger.info(" " + listing);
|
|
22
23
|
}
|
|
23
|
-
}
|
|
24
|
-
logger.info();
|
|
24
|
+
}
|
|
25
|
+
logger_1.logger.info();
|
|
25
26
|
}
|
|
26
|
-
logger.info("Run", clc.bold("firebase use --add"), "to define a new project alias.");
|
|
27
|
-
}
|
|
28
|
-
|
|
27
|
+
logger_1.logger.info("Run", clc.bold("firebase use --add"), "to define a new project alias.");
|
|
28
|
+
}
|
|
29
|
+
function verifyMessage(name) {
|
|
29
30
|
return "please verify project " + clc.bold(name) + " exists and you have access.";
|
|
30
|
-
}
|
|
31
|
-
|
|
31
|
+
}
|
|
32
|
+
exports.command = new command_1.Command("use [alias_or_project_id]")
|
|
32
33
|
.description("set an active Firebase project for your working directory")
|
|
33
34
|
.option("--add", "create a new project alias interactively")
|
|
34
35
|
.option("--alias <name>", "create a new alias for the provided project id")
|
|
35
36
|
.option("--unalias <name>", "remove an already created project alias")
|
|
36
37
|
.option("--clear", "clear the active project selection")
|
|
37
|
-
.before(requireAuth)
|
|
38
|
-
.action(
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
.before(requireAuth_1.requireAuth)
|
|
39
|
+
.action((newActive, options) => {
|
|
40
|
+
let aliasOpt;
|
|
41
|
+
const i = process.argv.indexOf("--alias");
|
|
41
42
|
if (i >= 0 && process.argv.length > i + 1) {
|
|
42
43
|
aliasOpt = process.argv[i + 1];
|
|
43
44
|
}
|
|
@@ -48,11 +49,11 @@ module.exports = new Command("use [alias_or_project_id]")
|
|
|
48
49
|
" to start a project directory in the current folder.");
|
|
49
50
|
}
|
|
50
51
|
if (newActive) {
|
|
51
|
-
|
|
52
|
+
let project;
|
|
52
53
|
const hasAlias = options.rc.hasProjectAlias(newActive);
|
|
53
54
|
const resolvedProject = options.rc.resolveAlias(newActive);
|
|
54
|
-
validateProjectId(resolvedProject);
|
|
55
|
-
return getFirebaseProject(resolvedProject)
|
|
55
|
+
(0, command_2.validateProjectId)(resolvedProject);
|
|
56
|
+
return (0, projects_1.getFirebaseProject)(resolvedProject)
|
|
56
57
|
.then((foundProject) => {
|
|
57
58
|
project = foundProject;
|
|
58
59
|
})
|
|
@@ -65,18 +66,18 @@ module.exports = new Command("use [alias_or_project_id]")
|
|
|
65
66
|
return utils.reject("Cannot create alias " + clc.bold(aliasOpt) + ", " + verifyMessage(newActive));
|
|
66
67
|
}
|
|
67
68
|
options.rc.addProjectAlias(aliasOpt, newActive);
|
|
68
|
-
logger.info("Created alias", clc.bold(aliasOpt), "for", resolvedProject + ".");
|
|
69
|
+
logger_1.logger.info("Created alias", clc.bold(aliasOpt), "for", resolvedProject + ".");
|
|
69
70
|
}
|
|
70
71
|
if (hasAlias) {
|
|
71
72
|
if (!project) {
|
|
72
73
|
return utils.reject("Unable to use alias " + clc.bold(newActive) + ", " + verifyMessage(resolvedProject));
|
|
73
74
|
}
|
|
74
75
|
utils.makeActiveProject(options.projectRoot, newActive);
|
|
75
|
-
logger.info("Now using alias", clc.bold(newActive), "(" + resolvedProject + ")");
|
|
76
|
+
logger_1.logger.info("Now using alias", clc.bold(newActive), "(" + resolvedProject + ")");
|
|
76
77
|
}
|
|
77
78
|
else if (project) {
|
|
78
79
|
utils.makeActiveProject(options.projectRoot, newActive);
|
|
79
|
-
logger.info("Now using project", clc.bold(newActive));
|
|
80
|
+
logger_1.logger.info("Now using project", clc.bold(newActive));
|
|
80
81
|
}
|
|
81
82
|
else {
|
|
82
83
|
return utils.reject("Invalid project selection, " + verifyMessage(newActive));
|
|
@@ -86,8 +87,8 @@ module.exports = new Command("use [alias_or_project_id]")
|
|
|
86
87
|
else if (options.unalias) {
|
|
87
88
|
if (options.rc.hasProjectAlias(options.unalias)) {
|
|
88
89
|
options.rc.removeProjectAlias(options.unalias);
|
|
89
|
-
logger.info("Removed alias", clc.bold(options.unalias));
|
|
90
|
-
logger.info();
|
|
90
|
+
logger_1.logger.info("Removed alias", clc.bold(options.unalias));
|
|
91
|
+
logger_1.logger.info();
|
|
91
92
|
listAliases(options);
|
|
92
93
|
}
|
|
93
94
|
}
|
|
@@ -99,9 +100,9 @@ module.exports = new Command("use [alias_or_project_id]")
|
|
|
99
100
|
clc.bold("firebase use <project_id> --alias <alias>") +
|
|
100
101
|
" instead.");
|
|
101
102
|
}
|
|
102
|
-
return listFirebaseProjects().then(
|
|
103
|
-
|
|
104
|
-
return prompt(results, [
|
|
103
|
+
return (0, projects_1.listFirebaseProjects)().then((projects) => {
|
|
104
|
+
const results = {};
|
|
105
|
+
return (0, prompt_1.prompt)(results, [
|
|
105
106
|
{
|
|
106
107
|
type: "list",
|
|
107
108
|
name: "project",
|
|
@@ -112,49 +113,49 @@ module.exports = new Command("use [alias_or_project_id]")
|
|
|
112
113
|
type: "input",
|
|
113
114
|
name: "alias",
|
|
114
115
|
message: "What alias do you want to use for this project? (e.g. staging)",
|
|
115
|
-
validate:
|
|
116
|
+
validate: (input) => {
|
|
116
117
|
return input && input.length > 0;
|
|
117
118
|
},
|
|
118
119
|
},
|
|
119
|
-
]).then(
|
|
120
|
+
]).then(() => {
|
|
120
121
|
options.rc.addProjectAlias(results.alias, results.project);
|
|
121
122
|
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 + ")");
|
|
123
|
+
logger_1.logger.info();
|
|
124
|
+
logger_1.logger.info("Created alias", clc.bold(results.alias), "for", results.project + ".");
|
|
125
|
+
logger_1.logger.info("Now using alias", clc.bold(results.alias) + " (" + results.project + ")");
|
|
125
126
|
});
|
|
126
127
|
});
|
|
127
128
|
}
|
|
128
129
|
else if (options.clear) {
|
|
129
|
-
utils.makeActiveProject(options.projectRoot,
|
|
130
|
+
utils.makeActiveProject(options.projectRoot, undefined);
|
|
130
131
|
options.projectAlias = null;
|
|
131
132
|
options.project = null;
|
|
132
|
-
logger.info("Cleared active project.");
|
|
133
|
-
logger.info();
|
|
133
|
+
logger_1.logger.info("Cleared active project.");
|
|
134
|
+
logger_1.logger.info();
|
|
134
135
|
listAliases(options);
|
|
135
136
|
}
|
|
136
137
|
else {
|
|
137
138
|
if (options.nonInteractive || !process.stdout.isTTY) {
|
|
138
139
|
if (options.project) {
|
|
139
|
-
logger.info(options.project);
|
|
140
|
+
logger_1.logger.info(options.project);
|
|
140
141
|
return options.project;
|
|
141
142
|
}
|
|
142
|
-
return utils.reject("No active project"
|
|
143
|
+
return utils.reject("No active project");
|
|
143
144
|
}
|
|
144
145
|
if (options.projectAlias) {
|
|
145
|
-
logger.info("Active Project:", clc.bold.cyan(options.projectAlias + " (" + options.project + ")"));
|
|
146
|
+
logger_1.logger.info("Active Project:", clc.bold.cyan(options.projectAlias + " (" + options.project + ")"));
|
|
146
147
|
}
|
|
147
148
|
else if (options.project) {
|
|
148
|
-
logger.info("Active Project:", clc.bold.cyan(options.project));
|
|
149
|
+
logger_1.logger.info("Active Project:", clc.bold.cyan(options.project));
|
|
149
150
|
}
|
|
150
151
|
else {
|
|
151
|
-
|
|
152
|
+
let msg = "No project is currently active";
|
|
152
153
|
if (options.rc.hasProjects) {
|
|
153
154
|
msg += ", and no aliases have been created.";
|
|
154
155
|
}
|
|
155
|
-
logger.info(msg + ".");
|
|
156
|
+
logger_1.logger.info(msg + ".");
|
|
156
157
|
}
|
|
157
|
-
logger.info();
|
|
158
|
+
logger_1.logger.info();
|
|
158
159
|
listAliases(options);
|
|
159
160
|
return options.project;
|
|
160
161
|
}
|
package/lib/config.js
CHANGED
|
@@ -14,10 +14,11 @@ 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 = {}) {
|
|
21
|
+
var _a;
|
|
21
22
|
this.data = {};
|
|
22
23
|
this.defaults = {};
|
|
23
24
|
this.notes = {};
|
|
@@ -31,8 +32,8 @@ class Config {
|
|
|
31
32
|
clc.bold("firebase use --add") +
|
|
32
33
|
" instead");
|
|
33
34
|
}
|
|
34
|
-
if (
|
|
35
|
-
|
|
35
|
+
if ((_a = this._src) === null || _a === void 0 ? void 0 : _a.rules) {
|
|
36
|
+
this._src.database = Object.assign(Object.assign({}, this._src.database), { rules: this._src.rules });
|
|
36
37
|
}
|
|
37
38
|
Config.MATERIALIZE_TARGETS.forEach((target) => {
|
|
38
39
|
if (_.get(this._src, target)) {
|
|
@@ -58,7 +59,7 @@ class Config {
|
|
|
58
59
|
let out = this.parseFile(target, val);
|
|
59
60
|
const segments = target.split(".");
|
|
60
61
|
const lastSegment = segments[segments.length - 1];
|
|
61
|
-
if (Object.keys(out).length === 1 &&
|
|
62
|
+
if (Object.keys(out).length === 1 && out[lastSegment]) {
|
|
62
63
|
out = out[lastSegment];
|
|
63
64
|
}
|
|
64
65
|
return out;
|
|
@@ -95,7 +96,7 @@ class Config {
|
|
|
95
96
|
throw e;
|
|
96
97
|
}
|
|
97
98
|
}
|
|
98
|
-
return loadCJSON(fullPath);
|
|
99
|
+
return (0, loadCJSON_1.loadCJSON)(fullPath);
|
|
99
100
|
case ".bolt":
|
|
100
101
|
if (target === "database") {
|
|
101
102
|
this.notes.databaseRules = "bolt";
|
|
@@ -125,7 +126,7 @@ class Config {
|
|
|
125
126
|
}
|
|
126
127
|
return outPath;
|
|
127
128
|
}
|
|
128
|
-
readProjectFile(p, options) {
|
|
129
|
+
readProjectFile(p, options = {}) {
|
|
129
130
|
options = options || {};
|
|
130
131
|
try {
|
|
131
132
|
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,52 +1,54 @@
|
|
|
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 clc = require("cli-color");
|
|
5
|
+
const path = require("path");
|
|
6
|
+
const error_1 = require("../../error");
|
|
7
|
+
const parseBoltRules_1 = require("../../parseBoltRules");
|
|
8
|
+
const rtdb = require("../../rtdb");
|
|
9
|
+
const utils = require("../../utils");
|
|
9
10
|
const dbRulesConfig = require("../../database/rulesConfig");
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
function prepare(context, options) {
|
|
12
|
+
const rulesConfig = dbRulesConfig.getRulesConfig(context.projectId, options);
|
|
13
|
+
const next = Promise.resolve();
|
|
13
14
|
if (!rulesConfig || rulesConfig.length === 0) {
|
|
14
15
|
return next;
|
|
15
16
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
rulesConfig.forEach(
|
|
17
|
+
const ruleFiles = {};
|
|
18
|
+
const deploys = [];
|
|
19
|
+
rulesConfig.forEach((ruleConfig) => {
|
|
19
20
|
if (!ruleConfig.rules) {
|
|
20
21
|
return;
|
|
21
22
|
}
|
|
22
23
|
ruleFiles[ruleConfig.rules] = null;
|
|
23
24
|
deploys.push(ruleConfig);
|
|
24
25
|
});
|
|
25
|
-
|
|
26
|
+
for (const file of Object.keys(ruleFiles)) {
|
|
26
27
|
switch (path.extname(file)) {
|
|
27
28
|
case ".json":
|
|
28
29
|
ruleFiles[file] = options.config.readProjectFile(file);
|
|
29
30
|
break;
|
|
30
31
|
case ".bolt":
|
|
31
|
-
ruleFiles[file] = parseBoltRules(file);
|
|
32
|
+
ruleFiles[file] = (0, parseBoltRules_1.parseBoltRules)(file);
|
|
32
33
|
break;
|
|
33
34
|
default:
|
|
34
|
-
throw new FirebaseError("Unexpected rules format " + path.extname(file));
|
|
35
|
+
throw new error_1.FirebaseError("Unexpected rules format " + path.extname(file));
|
|
35
36
|
}
|
|
36
|
-
}
|
|
37
|
+
}
|
|
37
38
|
context.database = {
|
|
38
39
|
deploys: deploys,
|
|
39
40
|
ruleFiles: ruleFiles,
|
|
40
41
|
};
|
|
41
42
|
utils.logBullet(clc.bold.cyan("database: ") + "checking rules syntax...");
|
|
42
|
-
return Promise.all(deploys.map(
|
|
43
|
+
return Promise.all(deploys.map((deploy) => {
|
|
43
44
|
return rtdb
|
|
44
45
|
.updateRules(context.projectId, deploy.instance, ruleFiles[deploy.rules], { dryRun: true })
|
|
45
|
-
.then(
|
|
46
|
+
.then(() => {
|
|
46
47
|
utils.logSuccess(clc.bold.green("database: ") +
|
|
47
48
|
"rules syntax for database " +
|
|
48
49
|
clc.bold(deploy.instance) +
|
|
49
50
|
" is valid");
|
|
50
51
|
});
|
|
51
52
|
}));
|
|
52
|
-
}
|
|
53
|
+
}
|
|
54
|
+
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;
|
|
@@ -6,7 +6,7 @@ const secretUtils = require("../../extensions/secretsUtils");
|
|
|
6
6
|
const secretManager = require("../../gcp/secretManager");
|
|
7
7
|
const planner_1 = require("./planner");
|
|
8
8
|
const askUserForParam_1 = require("../../extensions/askUserForParam");
|
|
9
|
-
const
|
|
9
|
+
const types_1 = require("../../extensions/types");
|
|
10
10
|
const error_1 = require("../../error");
|
|
11
11
|
const logger_1 = require("../../logger");
|
|
12
12
|
const utils_1 = require("../../utils");
|
|
@@ -34,7 +34,7 @@ async function checkSpecForSecrets(i) {
|
|
|
34
34
|
}
|
|
35
35
|
exports.checkSpecForSecrets = checkSpecForSecrets;
|
|
36
36
|
const secretsInSpec = (spec) => {
|
|
37
|
-
return spec.params.filter((p) => p.type ===
|
|
37
|
+
return spec.params.filter((p) => p.type === types_1.ParamType.SECRET);
|
|
38
38
|
};
|
|
39
39
|
async function handleSecretsCreateInstance(i, nonInteractive) {
|
|
40
40
|
const extensionVersion = await (0, planner_1.getExtensionVersion)(i);
|
|
@@ -49,7 +49,7 @@ async function handleSecretsUpdateInstance(i, prevSpec, nonInteractive) {
|
|
|
49
49
|
const secretParams = secretsInSpec(extensionVersion.spec);
|
|
50
50
|
for (const s of secretParams) {
|
|
51
51
|
const prevParam = prevExtensionVersion.spec.params.find((p) => p.param === s.param);
|
|
52
|
-
if ((prevParam === null || prevParam === void 0 ? void 0 : prevParam.type) ===
|
|
52
|
+
if ((prevParam === null || prevParam === void 0 ? void 0 : prevParam.type) === types_1.ParamType.SECRET && prevSpec.params[prevParam === null || prevParam === void 0 ? void 0 : prevParam.param]) {
|
|
53
53
|
await handleSecretParamForUpdate(s, i, prevSpec.params[prevParam === null || prevParam === void 0 ? void 0 : prevParam.param], nonInteractive);
|
|
54
54
|
}
|
|
55
55
|
else {
|