firebase-tools 10.0.1 → 10.1.3
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/api.js +1 -0
- package/lib/apiv2.js +91 -48
- package/lib/appdistribution/client.js +1 -1
- package/lib/appdistribution/options-parser-util.js +1 -1
- package/lib/archiveDirectory.js +63 -73
- package/lib/auth.js +2 -2
- package/lib/bin/firebase.js +1 -1
- package/lib/command.js +26 -26
- package/lib/commands/appdistribution-distribute.js +4 -4
- package/lib/commands/appdistribution-testers-add.js +2 -2
- package/lib/commands/appdistribution-testers-remove.js +2 -2
- package/lib/commands/apps-android-sha-create.js +2 -2
- package/lib/commands/apps-android-sha-delete.js +2 -2
- package/lib/commands/apps-android-sha-list.js +2 -2
- package/lib/commands/apps-create.js +9 -9
- package/lib/commands/apps-list.js +3 -3
- package/lib/commands/apps-sdkconfig.js +8 -8
- package/lib/commands/auth-export.js +26 -25
- package/lib/commands/auth-import.js +88 -78
- package/lib/commands/database-get.js +1 -1
- package/lib/commands/database-instances-create.js +4 -4
- package/lib/commands/database-instances-list.js +4 -4
- package/lib/commands/database-profile.js +1 -1
- package/lib/commands/database-push.js +1 -1
- package/lib/commands/database-remove.js +2 -2
- package/lib/commands/database-set.js +2 -2
- package/lib/commands/database-settings-get.js +1 -1
- package/lib/commands/database-settings-set.js +1 -1
- package/lib/commands/database-update.js +2 -2
- package/lib/commands/ext-configure.js +3 -3
- package/lib/commands/ext-dev-deprecate.js +4 -4
- package/lib/commands/ext-dev-extension-delete.js +3 -3
- package/lib/commands/ext-dev-init.js +4 -4
- package/lib/commands/ext-dev-list.js +1 -1
- package/lib/commands/ext-dev-publish.js +4 -4
- package/lib/commands/ext-dev-register.js +6 -6
- package/lib/commands/ext-dev-undeprecate.js +4 -4
- package/lib/commands/ext-dev-unpublish.js +3 -3
- package/lib/commands/ext-dev-usage.js +140 -0
- package/lib/commands/ext-export.js +8 -8
- package/lib/commands/ext-info.js +5 -5
- package/lib/commands/ext-install.js +27 -23
- package/lib/commands/ext-list.js +2 -2
- package/lib/commands/ext-sources-create.js +2 -2
- package/lib/commands/ext-uninstall.js +4 -4
- package/lib/commands/ext-update.js +18 -18
- package/lib/commands/ext.js +3 -3
- package/lib/commands/firestore-delete.js +1 -1
- package/lib/commands/functions-config-clone.js +22 -23
- package/lib/commands/functions-config-export.js +11 -11
- 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/functions-delete.js +3 -3
- package/lib/commands/functions-deletegcfartifacts.js +4 -4
- package/lib/commands/functions-list.js +1 -1
- package/lib/commands/functions-log.js +1 -1
- package/lib/commands/help.js +12 -12
- package/lib/commands/hosting-channel-create.js +13 -13
- package/lib/commands/hosting-channel-delete.js +10 -10
- package/lib/commands/hosting-channel-deploy.js +18 -18
- package/lib/commands/hosting-channel-list.js +5 -5
- package/lib/commands/hosting-channel-open.js +9 -9
- package/lib/commands/hosting-clone.js +16 -16
- package/lib/commands/hosting-disable.js +1 -1
- package/lib/commands/hosting-sites-create.js +7 -7
- package/lib/commands/hosting-sites-delete.js +7 -7
- package/lib/commands/hosting-sites-get.js +2 -2
- package/lib/commands/hosting-sites-list.js +3 -3
- package/lib/commands/index.js +1 -0
- package/lib/commands/login-ci.js +10 -10
- package/lib/commands/login.js +2 -2
- package/lib/commands/logout.js +1 -1
- package/lib/commands/open.js +1 -1
- package/lib/commands/projects-addfirebase.js +2 -2
- package/lib/commands/projects-create.js +2 -2
- package/lib/commands/projects-list.js +1 -1
- package/lib/commands/remoteconfig-get.js +3 -3
- package/lib/commands/remoteconfig-rollback.js +3 -3
- package/lib/commands/remoteconfig-versions-list.js +7 -2
- 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 +4 -3
- 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/config.js +6 -6
- package/lib/database/api.js +2 -2
- package/lib/database/metadata.js +16 -24
- package/lib/defaultCredentials.js +3 -3
- package/lib/deploy/extensions/deploy.js +4 -4
- package/lib/deploy/extensions/deploymentSummary.js +5 -4
- package/lib/deploy/extensions/index.js +1 -0
- package/lib/deploy/extensions/params.js +1 -1
- package/lib/deploy/extensions/planner.js +3 -3
- package/lib/deploy/extensions/prepare.js +9 -9
- package/lib/deploy/extensions/release.js +1 -1
- package/lib/deploy/extensions/secrets.js +7 -7
- package/lib/deploy/extensions/validate.js +2 -2
- package/lib/deploy/functions/backend.js +9 -5
- package/lib/deploy/functions/checkIam.js +7 -7
- package/lib/deploy/functions/containerCleaner.js +3 -3
- package/lib/deploy/functions/deploy.js +4 -4
- package/lib/deploy/functions/ensureCloudBuildEnabled.js +3 -3
- package/lib/deploy/functions/index.js +1 -0
- package/lib/deploy/functions/prepare.js +29 -23
- package/lib/deploy/functions/prompts.js +5 -5
- package/lib/deploy/functions/release/executor.js +4 -1
- package/lib/deploy/functions/release/fabricator.js +9 -6
- package/lib/deploy/functions/release/index.js +2 -2
- package/lib/deploy/functions/release/planner.js +6 -6
- package/lib/deploy/functions/release/reporter.js +8 -4
- package/lib/deploy/functions/runtimes/discovery/index.js +2 -2
- package/lib/deploy/functions/runtimes/discovery/v1alpha1.js +14 -14
- package/lib/deploy/functions/runtimes/golang/index.js +11 -14
- package/lib/deploy/functions/runtimes/index.js +6 -10
- package/lib/deploy/functions/runtimes/node/index.js +6 -10
- package/lib/deploy/functions/runtimes/node/parseTriggers.js +3 -3
- package/lib/deploy/functions/runtimes/node/validate.js +2 -1
- package/lib/deploy/functions/services/storage.js +1 -1
- package/lib/deploy/functions/triggerRegionHelper.js +1 -1
- package/lib/deploy/functions/validate.js +32 -4
- package/lib/deploy/hosting/convertConfig.js +45 -24
- package/lib/deploy/hosting/deploy.js +7 -7
- package/lib/deploy/hosting/prepare.js +1 -1
- package/lib/deploy/hosting/uploader.js +1 -1
- package/lib/deploy/hosting/validate.js +3 -3
- package/lib/deploy/remoteconfig/prepare.js +3 -3
- package/lib/deploy/remoteconfig/release.js +3 -3
- package/lib/deploy/storage/deploy.js +1 -1
- package/lib/deploy/storage/release.js +2 -2
- package/lib/detectProjectRoot.js +5 -5
- package/lib/emulator/auth/apiSpec.js +13 -7
- package/lib/emulator/auth/handlers.js +3 -3
- package/lib/emulator/auth/index.js +1 -1
- package/lib/emulator/auth/operations.js +256 -248
- package/lib/emulator/auth/server.js +11 -8
- package/lib/emulator/auth/state.js +12 -12
- package/lib/emulator/commandUtils.js +5 -5
- package/lib/emulator/controller.js +16 -11
- package/lib/emulator/downloadableEmulators.js +5 -4
- package/lib/emulator/emulatorLogger.js +1 -1
- package/lib/emulator/functionsEmulator.js +110 -75
- package/lib/emulator/functionsEmulatorRuntime.js +36 -21
- package/lib/emulator/functionsEmulatorShell.js +3 -2
- package/lib/emulator/functionsRuntimeWorker.js +1 -1
- package/lib/emulator/hubExport.js +2 -2
- package/lib/emulator/storage/apis/firebase.js +2 -2
- package/lib/emulator/storage/apis/gcloud.js +2 -2
- package/lib/emulator/storage/cloudFunctions.js +1 -1
- package/lib/emulator/storage/files.js +14 -14
- package/lib/emulator/storage/index.js +2 -2
- package/lib/emulator/storage/metadata.js +7 -6
- package/lib/emulator/storage/rules/runtime.js +10 -9
- package/lib/emulator/storage/server.js +2 -2
- package/lib/ensureApiEnabled.js +7 -7
- package/lib/error.js +3 -3
- package/lib/extensions/askUserForConsent.js +3 -4
- package/lib/extensions/askUserForParam.js +11 -11
- package/lib/extensions/billingMigrationHelper.js +2 -2
- package/lib/extensions/changelog.js +4 -4
- package/lib/extensions/displayExtensionInfo.js +6 -6
- package/lib/extensions/emulator/optionsHelper.js +1 -1
- package/lib/extensions/emulator/specHelper.js +1 -1
- package/lib/extensions/emulator/triggerHelper.js +1 -1
- package/lib/extensions/export.js +6 -6
- package/lib/extensions/extensionsApi.js +68 -110
- package/lib/extensions/extensionsHelper.js +56 -43
- package/lib/extensions/listExtensions.js +1 -1
- package/lib/extensions/localHelper.js +1 -1
- package/lib/extensions/metricsTypeDef.js +2 -0
- package/lib/extensions/metricsUtils.js +98 -0
- package/lib/extensions/paramHelper.js +6 -6
- package/lib/extensions/provisioningHelper.js +13 -14
- package/lib/extensions/resolveSource.js +6 -6
- package/lib/extensions/secretsUtils.js +3 -3
- package/lib/extensions/updateHelper.js +10 -10
- package/lib/extensions/utils.js +1 -1
- package/lib/extensions/warnings.js +11 -10
- package/lib/fetchWebSetup.js +2 -2
- package/lib/filterTargets.js +2 -2
- package/lib/firestore/indexes.js +2 -2
- package/lib/fsAsync.js +3 -3
- package/lib/fsutils.js +2 -2
- package/lib/functional.js +2 -1
- package/lib/functions/env.js +1 -1
- package/lib/functions/runtimeConfigExport.js +4 -4
- package/lib/functionsConfig.js +7 -8
- package/lib/functionsShellCommandAction.js +4 -3
- 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 +77 -0
- package/lib/gcp/cloudscheduler.js +8 -19
- package/lib/gcp/firedata.js +5 -4
- package/lib/gcp/firestore.js +5 -5
- package/lib/gcp/iam.js +19 -34
- package/lib/gcp/resourceManager.js +10 -15
- package/lib/gcp/rules.js +18 -41
- package/lib/gcp/runtimeconfig.js +31 -53
- package/lib/gcp/secretManager.js +24 -45
- package/lib/gcp/storage.js +24 -29
- package/lib/getDefaultDatabaseInstance.js +1 -1
- package/lib/getDefaultHostingSite.js +1 -1
- package/lib/getProjectNumber.js +2 -2
- package/lib/handlePreviewToggles.js +5 -5
- package/lib/hosting/api.js +6 -6
- package/lib/hosting/cloudRunProxy.js +6 -6
- package/lib/hosting/functionsProxy.js +3 -3
- package/lib/hosting/implicitInit.js +2 -2
- package/lib/hosting/normalizedHostingConfigs.js +3 -3
- package/lib/hosting/proxy.js +2 -2
- package/lib/init/features/account.js +7 -7
- package/lib/init/features/database.js +9 -9
- package/lib/init/features/emulators.js +8 -8
- package/lib/init/features/firestore/index.js +3 -3
- package/lib/init/features/firestore/indexes.js +2 -2
- package/lib/init/features/firestore/rules.js +2 -2
- package/lib/init/features/functions/golang.js +4 -4
- package/lib/init/features/functions/index.js +4 -4
- package/lib/init/features/hosting/github.js +31 -31
- package/lib/init/features/project.js +8 -8
- package/lib/init/features/remoteconfig.js +2 -2
- package/lib/init/features/storage.js +2 -2
- package/lib/listFiles.js +1 -1
- package/lib/management/apps.js +3 -3
- package/lib/management/projects.js +6 -6
- package/lib/previews.js +2 -2
- package/lib/profiler.js +1 -1
- package/lib/projectPath.js +1 -1
- package/lib/projectUtils.js +2 -2
- package/lib/prompt.js +0 -1
- package/lib/rc.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/lib/requireAuth.js +2 -2
- package/lib/requireDatabaseInstance.js +1 -1
- package/lib/requireHostingSite.js +1 -1
- package/lib/requirePermissions.js +4 -4
- package/lib/rulesDeploy.js +2 -2
- package/lib/serve/functions.js +14 -7
- package/lib/serve/hosting.js +7 -7
- package/lib/utils.js +3 -2
- package/npm-shrinkwrap.json +24090 -0
- package/package.json +36 -31
- package/schema/firebase-config.json +387 -12
- package/lib/commands/functions-config-legacy.js +0 -45
- package/lib/prepareFirebaseRules.js +0 -58
|
@@ -9,17 +9,17 @@ const functionsEmulator_1 = require("../emulator/functionsEmulator");
|
|
|
9
9
|
function default_1(options) {
|
|
10
10
|
return (rewrite) => {
|
|
11
11
|
return new Promise((resolve) => {
|
|
12
|
-
const projectId = projectUtils_1.needProjectId(options);
|
|
12
|
+
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
13
13
|
let url = `https://us-central1-${projectId}.cloudfunctions.net/${rewrite.function}`;
|
|
14
14
|
let destLabel = "live";
|
|
15
|
-
if (lodash_1.includes(options.targets, "functions")) {
|
|
15
|
+
if ((0, lodash_1.includes)(options.targets, "functions")) {
|
|
16
16
|
destLabel = "local";
|
|
17
17
|
const functionsEmu = registry_1.EmulatorRegistry.get(types_1.Emulators.FUNCTIONS);
|
|
18
18
|
if (functionsEmu) {
|
|
19
19
|
url = functionsEmulator_1.FunctionsEmulator.getHttpFunctionUrl(functionsEmu.getInfo().host, functionsEmu.getInfo().port, projectId, rewrite.function, "us-central1");
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
|
-
resolve(proxy_1.proxyRequestHandler(url, `${destLabel} Function ${rewrite.function}`));
|
|
22
|
+
resolve((0, proxy_1.proxyRequestHandler)(url, `${destLabel} Function ${rewrite.function}`));
|
|
23
23
|
});
|
|
24
24
|
};
|
|
25
25
|
}
|
|
@@ -13,7 +13,7 @@ const INIT_TEMPLATE = fs.readFileSync(__dirname + "/../../templates/hosting/init
|
|
|
13
13
|
async function implicitInit(options) {
|
|
14
14
|
let config;
|
|
15
15
|
try {
|
|
16
|
-
config = await fetchWebSetup_1.fetchWebSetup(options);
|
|
16
|
+
config = await (0, fetchWebSetup_1.fetchWebSetup)(options);
|
|
17
17
|
}
|
|
18
18
|
catch (e) {
|
|
19
19
|
logger_1.logger.debug("fetchWebSetup error: " + e);
|
|
@@ -23,7 +23,7 @@ async function implicitInit(options) {
|
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
if (!config) {
|
|
26
|
-
config = fetchWebSetup_1.getCachedWebSetup(options);
|
|
26
|
+
config = (0, fetchWebSetup_1.getCachedWebSetup)(options);
|
|
27
27
|
if (config) {
|
|
28
28
|
utils.logLabeledWarning("hosting", "Using web app configuration from cache.");
|
|
29
29
|
}
|
|
@@ -34,7 +34,7 @@ function filterOnly(configs, onlyString) {
|
|
|
34
34
|
filteredConfigs.push(configsByTarget.get(onlyTarget));
|
|
35
35
|
}
|
|
36
36
|
else {
|
|
37
|
-
throw new error_1.FirebaseError(`Hosting site or target ${cli_color_1.bold(onlyTarget)} not detected in firebase.json`);
|
|
37
|
+
throw new error_1.FirebaseError(`Hosting site or target ${(0, cli_color_1.bold)(onlyTarget)} not detected in firebase.json`);
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
return filteredConfigs;
|
|
@@ -57,7 +57,7 @@ function filterExcept(configs, exceptOption) {
|
|
|
57
57
|
return filteredConfigs;
|
|
58
58
|
}
|
|
59
59
|
function normalizedHostingConfigs(cmdOptions, options = {}) {
|
|
60
|
-
let configs = lodash_1.cloneDeep(cmdOptions.config.get("hosting"));
|
|
60
|
+
let configs = (0, lodash_1.cloneDeep)(cmdOptions.config.get("hosting"));
|
|
61
61
|
if (!configs) {
|
|
62
62
|
return [];
|
|
63
63
|
}
|
|
@@ -79,7 +79,7 @@ function normalizedHostingConfigs(cmdOptions, options = {}) {
|
|
|
79
79
|
if (cfg.target) {
|
|
80
80
|
const matchingTargets = cmdOptions.rc.requireTarget(cmdOptions.project, "hosting", cfg.target);
|
|
81
81
|
if (matchingTargets.length > 1) {
|
|
82
|
-
throw new error_1.FirebaseError(`Hosting target ${cli_color_1.bold(cfg.target)} is linked to multiple sites, ` +
|
|
82
|
+
throw new error_1.FirebaseError(`Hosting target ${(0, cli_color_1.bold)(cfg.target)} is linked to multiple sites, ` +
|
|
83
83
|
`but only one is permitted. ` +
|
|
84
84
|
`To clear, run:\n\n firebase target:clear hosting ${cfg.target}`);
|
|
85
85
|
}
|
package/lib/hosting/proxy.js
CHANGED
|
@@ -16,11 +16,11 @@ function makeVary(vary = "") {
|
|
|
16
16
|
const varies = vary.split(/, ?/).map((v) => {
|
|
17
17
|
return v
|
|
18
18
|
.split("-")
|
|
19
|
-
.map((part) => lodash_1.capitalize(part))
|
|
19
|
+
.map((part) => (0, lodash_1.capitalize)(part))
|
|
20
20
|
.join("-");
|
|
21
21
|
});
|
|
22
22
|
REQUIRED_VARY_VALUES.forEach((requiredVary) => {
|
|
23
|
-
if (!lodash_1.includes(varies, requiredVary)) {
|
|
23
|
+
if (!(0, lodash_1.includes)(varies, requiredVary)) {
|
|
24
24
|
varies.push(requiredVary);
|
|
25
25
|
}
|
|
26
26
|
});
|
|
@@ -10,7 +10,7 @@ async function promptForAccount() {
|
|
|
10
10
|
logger_1.logger.info();
|
|
11
11
|
logger_1.logger.info(`Which account do you want to use for this project? Choose an account or add a new one now`);
|
|
12
12
|
logger_1.logger.info();
|
|
13
|
-
const allAccounts = auth_1.getAllAccounts();
|
|
13
|
+
const allAccounts = (0, auth_1.getAllAccounts)();
|
|
14
14
|
const choices = allAccounts.map((a) => {
|
|
15
15
|
return {
|
|
16
16
|
name: a.user.email,
|
|
@@ -21,27 +21,27 @@ async function promptForAccount() {
|
|
|
21
21
|
name: "(add a new account)",
|
|
22
22
|
value: "__add__",
|
|
23
23
|
});
|
|
24
|
-
const emailChoice = await prompt_1.promptOnce({
|
|
24
|
+
const emailChoice = await (0, prompt_1.promptOnce)({
|
|
25
25
|
type: "list",
|
|
26
26
|
name: "email",
|
|
27
27
|
message: "Please select an option:",
|
|
28
28
|
choices,
|
|
29
29
|
});
|
|
30
30
|
if (emailChoice == "__add__") {
|
|
31
|
-
const newAccount = await auth_1.loginAdditionalAccount(true);
|
|
31
|
+
const newAccount = await (0, auth_1.loginAdditionalAccount)(true);
|
|
32
32
|
if (!newAccount) {
|
|
33
33
|
throw new error_1.FirebaseError("Failed to add new account", { exit: 1 });
|
|
34
34
|
}
|
|
35
35
|
return newAccount;
|
|
36
36
|
}
|
|
37
37
|
else {
|
|
38
|
-
return auth_1.findAccountByEmail(emailChoice);
|
|
38
|
+
return (0, auth_1.findAccountByEmail)(emailChoice);
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
async function doSetup(setup, config, options) {
|
|
42
42
|
let account;
|
|
43
43
|
if (options.account) {
|
|
44
|
-
account = auth_1.findAccountByEmail(options.account);
|
|
44
|
+
account = (0, auth_1.findAccountByEmail)(options.account);
|
|
45
45
|
if (!account) {
|
|
46
46
|
throw new error_1.FirebaseError(`Invalid account ${options.account}`, { exit: 1 });
|
|
47
47
|
}
|
|
@@ -52,9 +52,9 @@ async function doSetup(setup, config, options) {
|
|
|
52
52
|
if (!account) {
|
|
53
53
|
throw new error_1.FirebaseError(`No account selected, have you run "firebase login"?`, { exit: 1 });
|
|
54
54
|
}
|
|
55
|
-
auth_1.setActiveAccount(options, account);
|
|
55
|
+
(0, auth_1.setActiveAccount)(options, account);
|
|
56
56
|
if (config.projectDir) {
|
|
57
|
-
auth_1.setProjectAccount(config.projectDir, account.user.email);
|
|
57
|
+
(0, auth_1.setProjectAccount)(config.projectDir, account.user.email);
|
|
58
58
|
}
|
|
59
59
|
logger_1.logger.info();
|
|
60
60
|
utils.logSuccess(`Using account: ${account.user.email}`);
|
|
@@ -30,7 +30,7 @@ function writeDBRules(rules, logMessagePrefix, filename, config) {
|
|
|
30
30
|
logger_1.logger.info(clc.bold("firebase deploy") + ".");
|
|
31
31
|
}
|
|
32
32
|
async function createDefaultDatabaseInstance(project) {
|
|
33
|
-
const selectedLocation = await prompt_1.promptOnce({
|
|
33
|
+
const selectedLocation = await (0, prompt_1.promptOnce)({
|
|
34
34
|
type: "list",
|
|
35
35
|
message: "Please choose the location for your default Realtime Database instance:",
|
|
36
36
|
choices: [
|
|
@@ -40,7 +40,7 @@ async function createDefaultDatabaseInstance(project) {
|
|
|
40
40
|
],
|
|
41
41
|
});
|
|
42
42
|
let instanceName = `${project}-default-rtdb`;
|
|
43
|
-
const checkOutput = await database_1.checkInstanceNameAvailable(project, instanceName, database_1.DatabaseInstanceType.DEFAULT_DATABASE, selectedLocation);
|
|
43
|
+
const checkOutput = await (0, database_1.checkInstanceNameAvailable)(project, instanceName, database_1.DatabaseInstanceType.DEFAULT_DATABASE, selectedLocation);
|
|
44
44
|
if (!checkOutput.available) {
|
|
45
45
|
if (!checkOutput.suggestedIds || checkOutput.suggestedIds.length === 0) {
|
|
46
46
|
logger_1.logger.debug(`No instance names were suggested instead of conventional instance name: ${instanceName}`);
|
|
@@ -51,7 +51,7 @@ async function createDefaultDatabaseInstance(project) {
|
|
|
51
51
|
}
|
|
52
52
|
const spinner = ora(`Creating your default Realtime Database instance: ${instanceName}`).start();
|
|
53
53
|
try {
|
|
54
|
-
const createdInstance = await database_1.createInstance(project, instanceName, selectedLocation, database_1.DatabaseInstanceType.DEFAULT_DATABASE);
|
|
54
|
+
const createdInstance = await (0, database_1.createInstance)(project, instanceName, selectedLocation, database_1.DatabaseInstanceType.DEFAULT_DATABASE);
|
|
55
55
|
spinner.succeed();
|
|
56
56
|
return createdInstance;
|
|
57
57
|
}
|
|
@@ -64,15 +64,15 @@ async function doSetup(setup, config) {
|
|
|
64
64
|
setup.config = setup.config || {};
|
|
65
65
|
let instanceDetails;
|
|
66
66
|
if (setup.projectId) {
|
|
67
|
-
await ensureApiEnabled_1.ensure(setup.projectId, "firebasedatabase.googleapis.com", "database", false);
|
|
67
|
+
await (0, ensureApiEnabled_1.ensure)(setup.projectId, "firebasedatabase.googleapis.com", "database", false);
|
|
68
68
|
logger_1.logger.info();
|
|
69
69
|
setup.instance =
|
|
70
|
-
setup.instance || (await getDefaultDatabaseInstance_1.getDefaultDatabaseInstance({ project: setup.projectId }));
|
|
70
|
+
setup.instance || (await (0, getDefaultDatabaseInstance_1.getDefaultDatabaseInstance)({ project: setup.projectId }));
|
|
71
71
|
if (setup.instance !== "") {
|
|
72
|
-
instanceDetails = await database_1.getDatabaseInstanceDetails(setup.projectId, setup.instance);
|
|
72
|
+
instanceDetails = await (0, database_1.getDatabaseInstanceDetails)(setup.projectId, setup.instance);
|
|
73
73
|
}
|
|
74
74
|
else {
|
|
75
|
-
const confirm = await prompt_1.promptOnce({
|
|
75
|
+
const confirm = await (0, prompt_1.promptOnce)({
|
|
76
76
|
type: "confirm",
|
|
77
77
|
name: "confirm",
|
|
78
78
|
default: true,
|
|
@@ -88,7 +88,7 @@ async function doSetup(setup, config) {
|
|
|
88
88
|
logger_1.logger.info("Firebase Realtime Database Security Rules allow you to define how your data should be");
|
|
89
89
|
logger_1.logger.info("structured and when your data can be read from and written to.");
|
|
90
90
|
logger_1.logger.info();
|
|
91
|
-
await prompt_1.prompt(setup.config.database, [
|
|
91
|
+
await (0, prompt_1.prompt)(setup.config.database, [
|
|
92
92
|
{
|
|
93
93
|
type: "input",
|
|
94
94
|
name: "rules",
|
|
@@ -106,7 +106,7 @@ async function doSetup(setup, config) {
|
|
|
106
106
|
? `the Realtime Database Security Rules for ${clc.bold(instanceDetails.name)} from the Firebase console`
|
|
107
107
|
: "default rules";
|
|
108
108
|
const msg = `File ${clc.bold(filename)} already exists. Do you want to overwrite it with ${rulesDescription}?`;
|
|
109
|
-
writeRules = await prompt_1.promptOnce({
|
|
109
|
+
writeRules = await (0, prompt_1.promptOnce)({
|
|
110
110
|
type: "confirm",
|
|
111
111
|
message: msg,
|
|
112
112
|
default: false,
|
|
@@ -17,7 +17,7 @@ async function doSetup(setup, config) {
|
|
|
17
17
|
};
|
|
18
18
|
});
|
|
19
19
|
const selections = {};
|
|
20
|
-
await prompt_1.prompt(selections, [
|
|
20
|
+
await (0, prompt_1.prompt)(selections, [
|
|
21
21
|
{
|
|
22
22
|
type: "checkbox",
|
|
23
23
|
name: "emulators",
|
|
@@ -37,7 +37,7 @@ async function doSetup(setup, config) {
|
|
|
37
37
|
utils.logBullet(`Port for ${selected} already configured: ${clc.cyan(currentPort)}`);
|
|
38
38
|
}
|
|
39
39
|
else {
|
|
40
|
-
await prompt_1.prompt(setup.config.emulators[selected], [
|
|
40
|
+
await (0, prompt_1.prompt)(setup.config.emulators[selected], [
|
|
41
41
|
{
|
|
42
42
|
type: "number",
|
|
43
43
|
name: "port",
|
|
@@ -56,7 +56,7 @@ async function doSetup(setup, config) {
|
|
|
56
56
|
else {
|
|
57
57
|
const ui = setup.config.emulators.ui || {};
|
|
58
58
|
setup.config.emulators.ui = ui;
|
|
59
|
-
await prompt_1.prompt(ui, [
|
|
59
|
+
await (0, prompt_1.prompt)(ui, [
|
|
60
60
|
{
|
|
61
61
|
name: "enabled",
|
|
62
62
|
type: "confirm",
|
|
@@ -65,7 +65,7 @@ async function doSetup(setup, config) {
|
|
|
65
65
|
},
|
|
66
66
|
]);
|
|
67
67
|
if (ui.enabled) {
|
|
68
|
-
await prompt_1.prompt(ui, [
|
|
68
|
+
await (0, prompt_1.prompt)(ui, [
|
|
69
69
|
{
|
|
70
70
|
type: "input",
|
|
71
71
|
name: "port",
|
|
@@ -76,7 +76,7 @@ async function doSetup(setup, config) {
|
|
|
76
76
|
ui.port = isNaN(portNum) ? undefined : portNum;
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
|
-
await prompt_1.prompt(selections, [
|
|
79
|
+
await (0, prompt_1.prompt)(selections, [
|
|
80
80
|
{
|
|
81
81
|
name: "download",
|
|
82
82
|
type: "confirm",
|
|
@@ -87,12 +87,12 @@ async function doSetup(setup, config) {
|
|
|
87
87
|
}
|
|
88
88
|
if (selections.download) {
|
|
89
89
|
for (const selected of selections.emulators) {
|
|
90
|
-
if (types_1.isDownloadableEmulator(selected)) {
|
|
91
|
-
await downloadableEmulators_1.downloadIfNecessary(selected);
|
|
90
|
+
if ((0, types_1.isDownloadableEmulator)(selected)) {
|
|
91
|
+
await (0, downloadableEmulators_1.downloadIfNecessary)(selected);
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
94
|
if (_.get(setup, "config.emulators.ui.enabled")) {
|
|
95
|
-
downloadableEmulators_1.downloadIfNecessary(types_1.Emulators.UI);
|
|
95
|
+
(0, downloadableEmulators_1.downloadIfNecessary)(types_1.Emulators.UI);
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
}
|
|
@@ -16,7 +16,7 @@ async function checkProjectSetup(setup, config, options) {
|
|
|
16
16
|
if (!isFirestoreEnabled) {
|
|
17
17
|
throw firestoreUnusedError;
|
|
18
18
|
}
|
|
19
|
-
const dbType = await checkDatabaseType_1.checkDatabaseType(setup.projectId);
|
|
19
|
+
const dbType = await (0, checkDatabaseType_1.checkDatabaseType)(setup.projectId);
|
|
20
20
|
logger_1.logger.debug(`database_type: ${dbType}`);
|
|
21
21
|
if (!dbType) {
|
|
22
22
|
throw firestoreUnusedError;
|
|
@@ -24,8 +24,8 @@ async function checkProjectSetup(setup, config, options) {
|
|
|
24
24
|
else if (dbType !== "CLOUD_FIRESTORE") {
|
|
25
25
|
throw new error_1.FirebaseError(`It looks like this project is using Cloud Datastore or Cloud Firestore in Datastore mode. The Firebase CLI can only manage projects using Cloud Firestore in Native mode. For more information, visit https://cloud.google.com/datastore/docs/firestore-or-datastore`, { exit: 1 });
|
|
26
26
|
}
|
|
27
|
-
ensureCloudResourceLocation_1.ensureLocationSet(setup.projectLocation, "Cloud Firestore");
|
|
28
|
-
await requirePermissions_1.requirePermissions(Object.assign(Object.assign({}, options), { project: setup.projectId }));
|
|
27
|
+
(0, ensureCloudResourceLocation_1.ensureLocationSet)(setup.projectLocation, "Cloud Firestore");
|
|
28
|
+
await (0, requirePermissions_1.requirePermissions)(Object.assign(Object.assign({}, options), { project: setup.projectId }));
|
|
29
29
|
}
|
|
30
30
|
async function doSetup(setup, config, options) {
|
|
31
31
|
if (setup.projectId) {
|
|
@@ -17,7 +17,7 @@ function initIndexes(setup, config) {
|
|
|
17
17
|
logger_1.logger.info("set. You can keep index definitions in your project directory");
|
|
18
18
|
logger_1.logger.info("and publish them with " + clc.bold("firebase deploy") + ".");
|
|
19
19
|
logger_1.logger.info();
|
|
20
|
-
return prompt_1.prompt(setup.config.firestore, [
|
|
20
|
+
return (0, prompt_1.prompt)(setup.config.firestore, [
|
|
21
21
|
{
|
|
22
22
|
type: "input",
|
|
23
23
|
name: "indexes",
|
|
@@ -32,7 +32,7 @@ function initIndexes(setup, config) {
|
|
|
32
32
|
clc.bold(filename) +
|
|
33
33
|
" already exists." +
|
|
34
34
|
" Do you want to overwrite it with the Firestore Indexes from the Firebase Console?";
|
|
35
|
-
return prompt_1.promptOnce({
|
|
35
|
+
return (0, prompt_1.promptOnce)({
|
|
36
36
|
type: "confirm",
|
|
37
37
|
message: msg,
|
|
38
38
|
default: false,
|
|
@@ -16,7 +16,7 @@ function initRules(setup, config) {
|
|
|
16
16
|
logger_1.logger.info("requests. You can keep these rules in your project directory");
|
|
17
17
|
logger_1.logger.info("and publish them with " + clc.bold("firebase deploy") + ".");
|
|
18
18
|
logger_1.logger.info();
|
|
19
|
-
return prompt_1.prompt(setup.config.firestore, [
|
|
19
|
+
return (0, prompt_1.prompt)(setup.config.firestore, [
|
|
20
20
|
{
|
|
21
21
|
type: "input",
|
|
22
22
|
name: "rules",
|
|
@@ -31,7 +31,7 @@ function initRules(setup, config) {
|
|
|
31
31
|
clc.bold(filename) +
|
|
32
32
|
" already exists." +
|
|
33
33
|
" Do you want to overwrite it with the Firestore Rules from the Firebase Console?";
|
|
34
|
-
return prompt_1.promptOnce({
|
|
34
|
+
return (0, prompt_1.promptOnce)({
|
|
35
35
|
type: "confirm",
|
|
36
36
|
message: msg,
|
|
37
37
|
default: false,
|
|
@@ -23,8 +23,8 @@ async function init(setup, config) {
|
|
|
23
23
|
}
|
|
24
24
|
async function writeModFile(config) {
|
|
25
25
|
const modPath = config.path("functions/go.mod");
|
|
26
|
-
if (await util_1.promisify(fs.exists)(modPath)) {
|
|
27
|
-
const shoudlWriteModFile = await prompt_1.promptOnce({
|
|
26
|
+
if (await (0, util_1.promisify)(fs.exists)(modPath)) {
|
|
27
|
+
const shoudlWriteModFile = await (0, prompt_1.promptOnce)({
|
|
28
28
|
type: "confirm",
|
|
29
29
|
message: "File " + clc.underline("functions/go.mod") + " already exists. Overwrite?",
|
|
30
30
|
default: false,
|
|
@@ -32,9 +32,9 @@ async function writeModFile(config) {
|
|
|
32
32
|
if (!shoudlWriteModFile) {
|
|
33
33
|
return;
|
|
34
34
|
}
|
|
35
|
-
await util_1.promisify(fs.unlink)(modPath);
|
|
35
|
+
await (0, util_1.promisify)(fs.unlink)(modPath);
|
|
36
36
|
}
|
|
37
|
-
const modName = await prompt_1.promptOnce({
|
|
37
|
+
const modName = await (0, prompt_1.promptOnce)({
|
|
38
38
|
type: "input",
|
|
39
39
|
message: "What would you like to name your module?",
|
|
40
40
|
default: "acme.com/functions",
|
|
@@ -15,10 +15,10 @@ module.exports = async function (setup, config, options) {
|
|
|
15
15
|
setup.functions = {};
|
|
16
16
|
const projectId = (_b = (_a = setup === null || setup === void 0 ? void 0 : setup.rcfile) === null || _a === void 0 ? void 0 : _a.projects) === null || _b === void 0 ? void 0 : _b.default;
|
|
17
17
|
if (projectId) {
|
|
18
|
-
await requirePermissions_1.requirePermissions(Object.assign(Object.assign({}, options), { project: projectId }));
|
|
18
|
+
await (0, requirePermissions_1.requirePermissions)(Object.assign(Object.assign({}, options), { project: projectId }));
|
|
19
19
|
await Promise.all([
|
|
20
|
-
ensureApiEnabled_1.ensure(projectId, "cloudfunctions.googleapis.com", "unused", true),
|
|
21
|
-
ensureApiEnabled_1.ensure(projectId, "runtimeconfig.googleapis.com", "unused", true),
|
|
20
|
+
(0, ensureApiEnabled_1.ensure)(projectId, "cloudfunctions.googleapis.com", "unused", true),
|
|
21
|
+
(0, ensureApiEnabled_1.ensure)(projectId, "runtimeconfig.googleapis.com", "unused", true),
|
|
22
22
|
]);
|
|
23
23
|
}
|
|
24
24
|
const choices = [
|
|
@@ -37,7 +37,7 @@ module.exports = async function (setup, config, options) {
|
|
|
37
37
|
value: "golang",
|
|
38
38
|
});
|
|
39
39
|
}
|
|
40
|
-
const language = await prompt_1.promptOnce({
|
|
40
|
+
const language = await (0, prompt_1.promptOnce)({
|
|
41
41
|
type: "list",
|
|
42
42
|
message: "What language would you like to use to write Cloud Functions?",
|
|
43
43
|
default: "javascript",
|
|
@@ -29,10 +29,10 @@ const HOSTING_GITHUB_ACTION_NAME = "FirebaseExtended/action-hosting-deploy@v0";
|
|
|
29
29
|
const githubApiClient = new apiv2_1.Client({ urlPrefix: api_1.githubApiOrigin, auth: false });
|
|
30
30
|
async function initGitHub(setup, config, options) {
|
|
31
31
|
if (!setup.projectId) {
|
|
32
|
-
return utils_1.reject("Could not determine Project ID, can't set up GitHub workflow.", { exit: 1 });
|
|
32
|
+
return (0, utils_1.reject)("Could not determine Project ID, can't set up GitHub workflow.", { exit: 1 });
|
|
33
33
|
}
|
|
34
34
|
if (!setup.config.hosting) {
|
|
35
|
-
return utils_1.reject(`Didn't find a Hosting config in firebase.json. Run ${cli_color_1.bold("firebase init hosting")} instead.`);
|
|
35
|
+
return (0, utils_1.reject)(`Didn't find a Hosting config in firebase.json. Run ${(0, cli_color_1.bold)("firebase init hosting")} instead.`);
|
|
36
36
|
}
|
|
37
37
|
logger_1.logger.info();
|
|
38
38
|
const gitRoot = getGitFolderPath();
|
|
@@ -41,12 +41,12 @@ async function initGitHub(setup, config, options) {
|
|
|
41
41
|
WORKFLOW_DIR = `${GITHUB_DIR}/workflows`;
|
|
42
42
|
YML_FULL_PATH_PULL_REQUEST = `${WORKFLOW_DIR}/${YML_PULL_REQUEST_FILENAME}`;
|
|
43
43
|
YML_FULL_PATH_MERGE = `${WORKFLOW_DIR}/${YML_MERGE_FILENAME}`;
|
|
44
|
-
utils_1.logBullet("Authorizing with GitHub to upload your service account to a GitHub repository's secrets store.");
|
|
44
|
+
(0, utils_1.logBullet)("Authorizing with GitHub to upload your service account to a GitHub repository's secrets store.");
|
|
45
45
|
const ghAccessToken = await signInWithGitHub();
|
|
46
46
|
const userDetails = await getGitHubUserDetails(ghAccessToken);
|
|
47
47
|
const ghUserName = userDetails.login;
|
|
48
48
|
logger_1.logger.info();
|
|
49
|
-
utils_1.logSuccess(`Success! Logged into GitHub as ${cli_color_1.bold(ghUserName)}`);
|
|
49
|
+
(0, utils_1.logSuccess)(`Success! Logged into GitHub as ${(0, cli_color_1.bold)(ghUserName)}`);
|
|
50
50
|
logger_1.logger.info();
|
|
51
51
|
const { repo, key, keyId } = await promptForRepo(setup, ghAccessToken);
|
|
52
52
|
const { default_branch: defaultBranch, id: repoId } = await getRepoDetails(repo, ghAccessToken);
|
|
@@ -56,17 +56,17 @@ async function initGitHub(setup, config, options) {
|
|
|
56
56
|
const serviceAccountName = `github-action-${repoId}`;
|
|
57
57
|
const serviceAccountJSON = await createServiceAccountAndKeyWithRetry(setup, repo, serviceAccountName);
|
|
58
58
|
logger_1.logger.info();
|
|
59
|
-
utils_1.logSuccess(`Created service account ${cli_color_1.bold(serviceAccountName)} with Firebase Hosting admin permissions.`);
|
|
60
|
-
const spinnerSecrets = ora
|
|
59
|
+
(0, utils_1.logSuccess)(`Created service account ${(0, cli_color_1.bold)(serviceAccountName)} with Firebase Hosting admin permissions.`);
|
|
60
|
+
const spinnerSecrets = ora(`Uploading service account secrets to repository: ${repo}`);
|
|
61
61
|
spinnerSecrets.start();
|
|
62
62
|
const encryptedServiceAccountJSON = encryptServiceAccountJSON(serviceAccountJSON, key);
|
|
63
63
|
await uploadSecretToGitHub(repo, ghAccessToken, encryptedServiceAccountJSON, keyId, githubSecretName);
|
|
64
64
|
spinnerSecrets.stop();
|
|
65
|
-
utils_1.logSuccess(`Uploaded service account JSON to GitHub as secret ${cli_color_1.bold(githubSecretName)}.`);
|
|
66
|
-
utils_1.logBullet(`You can manage your secrets at https://github.com/${repo}/settings/secrets.`);
|
|
65
|
+
(0, utils_1.logSuccess)(`Uploaded service account JSON to GitHub as secret ${(0, cli_color_1.bold)(githubSecretName)}.`);
|
|
66
|
+
(0, utils_1.logBullet)(`You can manage your secrets at https://github.com/${repo}/settings/secrets.`);
|
|
67
67
|
logger_1.logger.info();
|
|
68
68
|
if (setup.config.hosting.predeploy) {
|
|
69
|
-
utils_1.logBullet(`You have a predeploy script configured in firebase.json.`);
|
|
69
|
+
(0, utils_1.logBullet)(`You have a predeploy script configured in firebase.json.`);
|
|
70
70
|
}
|
|
71
71
|
const { script } = await promptForBuildScript();
|
|
72
72
|
const ymlDeployDoc = loadYMLDeploy();
|
|
@@ -81,7 +81,7 @@ async function initGitHub(setup, config, options) {
|
|
|
81
81
|
if (shouldWriteYMLHostingFile) {
|
|
82
82
|
writeChannelActionYMLFile(YML_FULL_PATH_PULL_REQUEST, githubSecretName, setup.projectId, script);
|
|
83
83
|
logger_1.logger.info();
|
|
84
|
-
utils_1.logSuccess(`Created workflow file ${cli_color_1.bold(YML_FULL_PATH_PULL_REQUEST)}`);
|
|
84
|
+
(0, utils_1.logSuccess)(`Created workflow file ${(0, cli_color_1.bold)(YML_FULL_PATH_PULL_REQUEST)}`);
|
|
85
85
|
}
|
|
86
86
|
const { setupDeploys, branch } = await promptToSetupDeploys(ymlDeployDoc.branch || defaultBranch);
|
|
87
87
|
if (setupDeploys) {
|
|
@@ -102,13 +102,13 @@ async function initGitHub(setup, config, options) {
|
|
|
102
102
|
if (shouldWriteYMLDeployFile) {
|
|
103
103
|
writeDeployToProdActionYMLFile(YML_FULL_PATH_MERGE, branch, githubSecretName, setup.projectId, script);
|
|
104
104
|
logger_1.logger.info();
|
|
105
|
-
utils_1.logSuccess(`Created workflow file ${cli_color_1.bold(YML_FULL_PATH_MERGE)}`);
|
|
105
|
+
(0, utils_1.logSuccess)(`Created workflow file ${(0, cli_color_1.bold)(YML_FULL_PATH_MERGE)}`);
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
108
|
logger_1.logger.info();
|
|
109
|
-
utils_1.logLabeledBullet("Action required", `Visit this URL to revoke authorization for the Firebase CLI GitHub OAuth App:`);
|
|
109
|
+
(0, utils_1.logLabeledBullet)("Action required", `Visit this URL to revoke authorization for the Firebase CLI GitHub OAuth App:`);
|
|
110
110
|
logger_1.logger.info(cli_color_1.bold.underline(`https://github.com/settings/connections/applications/${api_1.githubClientId}`));
|
|
111
|
-
utils_1.logLabeledBullet("Action required", `Push any new workflow file(s) to your repo`);
|
|
111
|
+
(0, utils_1.logLabeledBullet)("Action required", `Push any new workflow file(s) to your repo`);
|
|
112
112
|
}
|
|
113
113
|
exports.initGitHub = initGitHub;
|
|
114
114
|
function getGitFolderPath() {
|
|
@@ -117,12 +117,12 @@ function getGitFolderPath() {
|
|
|
117
117
|
while (!fs.existsSync(path.resolve(projectRootDir, ".git"))) {
|
|
118
118
|
const parentDir = path.dirname(projectRootDir);
|
|
119
119
|
if (parentDir === projectRootDir) {
|
|
120
|
-
utils_1.logBullet(`Didn't detect a .git folder. Assuming ${commandDir} is the project root.`);
|
|
120
|
+
(0, utils_1.logBullet)(`Didn't detect a .git folder. Assuming ${commandDir} is the project root.`);
|
|
121
121
|
return commandDir;
|
|
122
122
|
}
|
|
123
123
|
projectRootDir = parentDir;
|
|
124
124
|
}
|
|
125
|
-
utils_1.logBullet(`Detected a .git folder at ${projectRootDir}`);
|
|
125
|
+
(0, utils_1.logBullet)(`Detected a .git folder at ${projectRootDir}`);
|
|
126
126
|
return projectRootDir;
|
|
127
127
|
}
|
|
128
128
|
function defaultGithubRepo() {
|
|
@@ -147,10 +147,10 @@ function loadYMLDeploy() {
|
|
|
147
147
|
}
|
|
148
148
|
}
|
|
149
149
|
function loadYML(ymlPath) {
|
|
150
|
-
return js_yaml_1.safeLoad(fs.readFileSync(ymlPath, "utf8"));
|
|
150
|
+
return (0, js_yaml_1.safeLoad)(fs.readFileSync(ymlPath, "utf8"));
|
|
151
151
|
}
|
|
152
152
|
function mkdirNotExists(dir) {
|
|
153
|
-
if (!fsutils_1.dirExistsSync(dir)) {
|
|
153
|
+
if (!(0, fsutils_1.dirExistsSync)(dir)) {
|
|
154
154
|
fs.mkdirSync(dir);
|
|
155
155
|
}
|
|
156
156
|
}
|
|
@@ -231,7 +231,7 @@ async function uploadSecretToGitHub(repo, ghAccessToken, encryptedServiceAccount
|
|
|
231
231
|
async function promptForRepo(options, ghAccessToken) {
|
|
232
232
|
let key = "";
|
|
233
233
|
let keyId = "";
|
|
234
|
-
const { repo } = await prompt_1.prompt(options, [
|
|
234
|
+
const { repo } = await (0, prompt_1.prompt)(options, [
|
|
235
235
|
{
|
|
236
236
|
type: "input",
|
|
237
237
|
name: "repo",
|
|
@@ -250,9 +250,9 @@ async function promptForRepo(options, ghAccessToken) {
|
|
|
250
250
|
if (e.status === 403) {
|
|
251
251
|
logger_1.logger.info();
|
|
252
252
|
logger_1.logger.info();
|
|
253
|
-
utils_1.logWarning("The provided authorization cannot be used with this repository. If this repository is in an organization, did you remember to grant access?", "error");
|
|
253
|
+
(0, utils_1.logWarning)("The provided authorization cannot be used with this repository. If this repository is in an organization, did you remember to grant access?", "error");
|
|
254
254
|
logger_1.logger.info();
|
|
255
|
-
utils_1.logLabeledBullet("Action required", `Visit this URL to ensure access has been granted to the appropriate organization(s) for the Firebase CLI GitHub OAuth App:`);
|
|
255
|
+
(0, utils_1.logLabeledBullet)("Action required", `Visit this URL to ensure access has been granted to the appropriate organization(s) for the Firebase CLI GitHub OAuth App:`);
|
|
256
256
|
logger_1.logger.info(cli_color_1.bold.underline(`https://github.com/settings/connections/applications/${api_1.githubClientId}`));
|
|
257
257
|
logger_1.logger.info();
|
|
258
258
|
}
|
|
@@ -265,7 +265,7 @@ async function promptForRepo(options, ghAccessToken) {
|
|
|
265
265
|
return { repo, key, keyId };
|
|
266
266
|
}
|
|
267
267
|
async function promptForBuildScript() {
|
|
268
|
-
const { shouldSetupScript } = await prompt_1.prompt({}, [
|
|
268
|
+
const { shouldSetupScript } = await (0, prompt_1.prompt)({}, [
|
|
269
269
|
{
|
|
270
270
|
type: "confirm",
|
|
271
271
|
name: "shouldSetupScript",
|
|
@@ -276,7 +276,7 @@ async function promptForBuildScript() {
|
|
|
276
276
|
if (!shouldSetupScript) {
|
|
277
277
|
return { script: undefined };
|
|
278
278
|
}
|
|
279
|
-
const { script } = await prompt_1.prompt({}, [
|
|
279
|
+
const { script } = await (0, prompt_1.prompt)({}, [
|
|
280
280
|
{
|
|
281
281
|
type: "input",
|
|
282
282
|
name: "script",
|
|
@@ -287,7 +287,7 @@ async function promptForBuildScript() {
|
|
|
287
287
|
return { script };
|
|
288
288
|
}
|
|
289
289
|
async function promptToSetupDeploys(defaultBranch) {
|
|
290
|
-
const { setupDeploys } = await prompt_1.prompt({}, [
|
|
290
|
+
const { setupDeploys } = await (0, prompt_1.prompt)({}, [
|
|
291
291
|
{
|
|
292
292
|
type: "confirm",
|
|
293
293
|
name: "setupDeploys",
|
|
@@ -298,7 +298,7 @@ async function promptToSetupDeploys(defaultBranch) {
|
|
|
298
298
|
if (!setupDeploys) {
|
|
299
299
|
return { setupDeploys };
|
|
300
300
|
}
|
|
301
|
-
const { branch } = await prompt_1.prompt({}, [
|
|
301
|
+
const { branch } = await (0, prompt_1.prompt)({}, [
|
|
302
302
|
{
|
|
303
303
|
type: "input",
|
|
304
304
|
name: "branch",
|
|
@@ -309,7 +309,7 @@ async function promptToSetupDeploys(defaultBranch) {
|
|
|
309
309
|
return { branch, setupDeploys };
|
|
310
310
|
}
|
|
311
311
|
async function promptForWriteYMLFile({ message }) {
|
|
312
|
-
return await prompt_1.prompt({}, [
|
|
312
|
+
return await (0, prompt_1.prompt)({}, [
|
|
313
313
|
{
|
|
314
314
|
type: "confirm",
|
|
315
315
|
name: "overwrite",
|
|
@@ -331,10 +331,10 @@ async function getRepoDetails(repo, ghAccessToken) {
|
|
|
331
331
|
return body;
|
|
332
332
|
}
|
|
333
333
|
async function signInWithGitHub() {
|
|
334
|
-
return await auth_1.loginGithub();
|
|
334
|
+
return await (0, auth_1.loginGithub)();
|
|
335
335
|
}
|
|
336
336
|
async function createServiceAccountAndKeyWithRetry(options, repo, accountId) {
|
|
337
|
-
const spinnerServiceAccount = ora
|
|
337
|
+
const spinnerServiceAccount = ora("Retrieving a service account.");
|
|
338
338
|
spinnerServiceAccount.start();
|
|
339
339
|
try {
|
|
340
340
|
const serviceAccountJSON = await createServiceAccountAndKey(options, repo, accountId);
|
|
@@ -347,7 +347,7 @@ async function createServiceAccountAndKeyWithRetry(options, repo, accountId) {
|
|
|
347
347
|
throw e;
|
|
348
348
|
}
|
|
349
349
|
spinnerServiceAccount.start();
|
|
350
|
-
await iam_1.deleteServiceAccount(options.projectId, `${accountId}@${options.projectId}.iam.gserviceaccount.com`);
|
|
350
|
+
await (0, iam_1.deleteServiceAccount)(options.projectId, `${accountId}@${options.projectId}.iam.gserviceaccount.com`);
|
|
351
351
|
const serviceAccountJSON = await createServiceAccountAndKey(options, repo, accountId);
|
|
352
352
|
spinnerServiceAccount.stop();
|
|
353
353
|
return serviceAccountJSON;
|
|
@@ -355,7 +355,7 @@ async function createServiceAccountAndKeyWithRetry(options, repo, accountId) {
|
|
|
355
355
|
}
|
|
356
356
|
async function createServiceAccountAndKey(options, repo, accountId) {
|
|
357
357
|
try {
|
|
358
|
-
await iam_1.createServiceAccount(options.projectId, accountId, `A service account with permission to deploy to Firebase Hosting for the GitHub repository ${repo}`, `GitHub Actions (${repo})`);
|
|
358
|
+
await (0, iam_1.createServiceAccount)(options.projectId, accountId, `A service account with permission to deploy to Firebase Hosting for the GitHub repository ${repo}`, `GitHub Actions (${repo})`);
|
|
359
359
|
}
|
|
360
360
|
catch (e) {
|
|
361
361
|
if (!e.message.includes("409")) {
|
|
@@ -368,8 +368,8 @@ async function createServiceAccountAndKey(options, repo, accountId) {
|
|
|
368
368
|
resourceManager_1.firebaseRoles.hostingAdmin,
|
|
369
369
|
resourceManager_1.firebaseRoles.runViewer,
|
|
370
370
|
];
|
|
371
|
-
await resourceManager_1.addServiceAccountToRoles(options.projectId, accountId, requiredRoles);
|
|
372
|
-
const serviceAccountKey = await iam_1.createServiceAccountKey(options.projectId, accountId);
|
|
371
|
+
await (0, resourceManager_1.addServiceAccountToRoles)(options.projectId, accountId, requiredRoles);
|
|
372
|
+
const serviceAccountKey = await (0, iam_1.createServiceAccountKey)(options.projectId, accountId);
|
|
373
373
|
const buf = Buffer.from(serviceAccountKey.privateKeyData, "base64");
|
|
374
374
|
const serviceAccountJSON = buf.toString();
|
|
375
375
|
return serviceAccountJSON;
|
|
@@ -25,20 +25,20 @@ async function promptAndCreateNewProject() {
|
|
|
25
25
|
utils.logBullet("If you want to create a project in a Google Cloud organization or folder, please use " +
|
|
26
26
|
`"firebase projects:create" instead, and return to this command when you've created the project.`);
|
|
27
27
|
const promptAnswer = {};
|
|
28
|
-
await prompt_1.prompt(promptAnswer, projects_1.PROJECTS_CREATE_QUESTIONS);
|
|
28
|
+
await (0, prompt_1.prompt)(promptAnswer, projects_1.PROJECTS_CREATE_QUESTIONS);
|
|
29
29
|
if (!promptAnswer.projectId) {
|
|
30
30
|
throw new error_1.FirebaseError("Project ID cannot be empty");
|
|
31
31
|
}
|
|
32
|
-
return await projects_1.createFirebaseProjectAndLog(promptAnswer.projectId, {
|
|
32
|
+
return await (0, projects_1.createFirebaseProjectAndLog)(promptAnswer.projectId, {
|
|
33
33
|
displayName: promptAnswer.displayName,
|
|
34
34
|
});
|
|
35
35
|
}
|
|
36
36
|
async function promptAndAddFirebaseToCloudProject() {
|
|
37
|
-
const projectId = await projects_1.promptAvailableProjectId();
|
|
37
|
+
const projectId = await (0, projects_1.promptAvailableProjectId)();
|
|
38
38
|
if (!projectId) {
|
|
39
39
|
throw new error_1.FirebaseError("Project ID cannot be empty");
|
|
40
40
|
}
|
|
41
|
-
return await projects_1.addFirebaseToCloudProjectAndLog(projectId);
|
|
41
|
+
return await (0, projects_1.addFirebaseToCloudProjectAndLog)(projectId);
|
|
42
42
|
}
|
|
43
43
|
async function projectChoicePrompt(options) {
|
|
44
44
|
const choices = [
|
|
@@ -47,7 +47,7 @@ async function projectChoicePrompt(options) {
|
|
|
47
47
|
{ name: OPTION_ADD_FIREBASE, value: OPTION_ADD_FIREBASE },
|
|
48
48
|
{ name: OPTION_NO_PROJECT, value: OPTION_NO_PROJECT },
|
|
49
49
|
];
|
|
50
|
-
const projectSetupOption = await prompt_1.promptOnce({
|
|
50
|
+
const projectSetupOption = await (0, prompt_1.promptOnce)({
|
|
51
51
|
type: "list",
|
|
52
52
|
name: "id",
|
|
53
53
|
message: "Please select an option:",
|
|
@@ -55,7 +55,7 @@ async function projectChoicePrompt(options) {
|
|
|
55
55
|
});
|
|
56
56
|
switch (projectSetupOption) {
|
|
57
57
|
case OPTION_USE_PROJECT:
|
|
58
|
-
return projects_1.getOrPromptProject(options);
|
|
58
|
+
return (0, projects_1.getOrPromptProject)(options);
|
|
59
59
|
case OPTION_NEW_PROJECT:
|
|
60
60
|
return promptAndCreateNewProject();
|
|
61
61
|
case OPTION_ADD_FIREBASE:
|
|
@@ -74,7 +74,7 @@ async function doSetup(setup, config, options) {
|
|
|
74
74
|
const projectFromRcFile = _.get(setup.rcfile, "projects.default");
|
|
75
75
|
if (projectFromRcFile && !options.project) {
|
|
76
76
|
utils.logBullet(`.firebaserc already has a default project, using ${projectFromRcFile}.`);
|
|
77
|
-
const rcProject = await projects_1.getFirebaseProject(projectFromRcFile);
|
|
77
|
+
const rcProject = await (0, projects_1.getFirebaseProject)(projectFromRcFile);
|
|
78
78
|
setup.projectId = rcProject.projectId;
|
|
79
79
|
setup.projectLocation = _.get(rcProject, "resources.locationId");
|
|
80
80
|
return;
|
|
@@ -82,7 +82,7 @@ async function doSetup(setup, config, options) {
|
|
|
82
82
|
let projectMetaData;
|
|
83
83
|
if (options.project) {
|
|
84
84
|
logger_1.logger.debug(`Using project from CLI flag: ${options.project}`);
|
|
85
|
-
projectMetaData = await projects_1.getFirebaseProject(options.project);
|
|
85
|
+
projectMetaData = await (0, projects_1.getFirebaseProject)(options.project);
|
|
86
86
|
}
|
|
87
87
|
else {
|
|
88
88
|
projectMetaData = await projectChoicePrompt(options);
|