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
|
@@ -6,7 +6,7 @@ const fsutils = require("../../fsutils");
|
|
|
6
6
|
const clc = require("cli-color");
|
|
7
7
|
async function doSetup(setup, config) {
|
|
8
8
|
setup.config.remoteconfig = {};
|
|
9
|
-
const jsonFilePath = await prompt_1.promptOnce({
|
|
9
|
+
const jsonFilePath = await (0, prompt_1.promptOnce)({
|
|
10
10
|
type: "input",
|
|
11
11
|
name: "template",
|
|
12
12
|
message: "What file should be used for your Remote Config template?",
|
|
@@ -17,7 +17,7 @@ async function doSetup(setup, config) {
|
|
|
17
17
|
clc.bold(jsonFilePath) +
|
|
18
18
|
" already exists." +
|
|
19
19
|
" Do you want to overwrite the existing Remote Config template?";
|
|
20
|
-
const overwrite = await prompt_1.promptOnce({
|
|
20
|
+
const overwrite = await (0, prompt_1.promptOnce)({
|
|
21
21
|
type: "confirm",
|
|
22
22
|
message: msg,
|
|
23
23
|
default: false,
|
|
@@ -9,13 +9,13 @@ const ensureCloudResourceLocation_1 = require("../../ensureCloudResourceLocation
|
|
|
9
9
|
const RULES_TEMPLATE = fs.readFileSync(__dirname + "/../../../templates/init/storage/storage.rules", "utf8");
|
|
10
10
|
async function doSetup(setup, config) {
|
|
11
11
|
setup.config.storage = {};
|
|
12
|
-
ensureCloudResourceLocation_1.ensureLocationSet(setup.projectLocation, "Cloud Storage");
|
|
12
|
+
(0, ensureCloudResourceLocation_1.ensureLocationSet)(setup.projectLocation, "Cloud Storage");
|
|
13
13
|
logger_1.logger.info();
|
|
14
14
|
logger_1.logger.info("Firebase Storage Security Rules allow you to define how and when to allow");
|
|
15
15
|
logger_1.logger.info("uploads and downloads. You can keep these rules in your project directory");
|
|
16
16
|
logger_1.logger.info("and publish them with " + clc.bold("firebase deploy") + ".");
|
|
17
17
|
logger_1.logger.info();
|
|
18
|
-
const storageRulesFile = await prompt_1.promptOnce({
|
|
18
|
+
const storageRulesFile = await (0, prompt_1.promptOnce)({
|
|
19
19
|
type: "input",
|
|
20
20
|
name: "rules",
|
|
21
21
|
message: "What file should be used for Storage Rules?",
|
package/lib/listFiles.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.listFiles = void 0;
|
|
4
4
|
const glob_1 = require("glob");
|
|
5
5
|
function listFiles(cwd, ignore = []) {
|
|
6
|
-
return glob_1.sync("**/*", {
|
|
6
|
+
return (0, glob_1.sync)("**/*", {
|
|
7
7
|
cwd,
|
|
8
8
|
dot: true,
|
|
9
9
|
follow: true,
|
package/lib/management/apps.js
CHANGED
|
@@ -47,7 +47,7 @@ async function createIosApp(projectId, options) {
|
|
|
47
47
|
timeout: CREATE_APP_API_REQUEST_TIMEOUT_MILLIS,
|
|
48
48
|
data: options,
|
|
49
49
|
});
|
|
50
|
-
const appData = await operation_poller_1.pollOperation({
|
|
50
|
+
const appData = await (0, operation_poller_1.pollOperation)({
|
|
51
51
|
pollerName: "Create iOS app Poller",
|
|
52
52
|
apiOrigin: api.firebaseApiOrigin,
|
|
53
53
|
apiVersion: "v1beta1",
|
|
@@ -69,7 +69,7 @@ async function createAndroidApp(projectId, options) {
|
|
|
69
69
|
timeout: CREATE_APP_API_REQUEST_TIMEOUT_MILLIS,
|
|
70
70
|
data: options,
|
|
71
71
|
});
|
|
72
|
-
const appData = await operation_poller_1.pollOperation({
|
|
72
|
+
const appData = await (0, operation_poller_1.pollOperation)({
|
|
73
73
|
pollerName: "Create Android app Poller",
|
|
74
74
|
apiOrigin: api.firebaseApiOrigin,
|
|
75
75
|
apiVersion: "v1beta1",
|
|
@@ -94,7 +94,7 @@ async function createWebApp(projectId, options) {
|
|
|
94
94
|
timeout: CREATE_APP_API_REQUEST_TIMEOUT_MILLIS,
|
|
95
95
|
data: options,
|
|
96
96
|
});
|
|
97
|
-
const appData = await operation_poller_1.pollOperation({
|
|
97
|
+
const appData = await (0, operation_poller_1.pollOperation)({
|
|
98
98
|
pollerName: "Create Web app Poller",
|
|
99
99
|
apiOrigin: api.firebaseApiOrigin,
|
|
100
100
|
apiVersion: "v1beta1",
|
|
@@ -103,7 +103,7 @@ async function selectProjectInteractively(pageSize = MAXIMUM_PROMPT_LIST) {
|
|
|
103
103
|
return selectProjectFromList(projects);
|
|
104
104
|
}
|
|
105
105
|
async function selectProjectByPrompting() {
|
|
106
|
-
const projectId = await prompt_1.promptOnce({
|
|
106
|
+
const projectId = await (0, prompt_1.promptOnce)({
|
|
107
107
|
type: "input",
|
|
108
108
|
message: "Please input the project ID you would like to use:",
|
|
109
109
|
});
|
|
@@ -123,7 +123,7 @@ async function selectProjectFromList(projects = []) {
|
|
|
123
123
|
utils.logBullet(`Don't want to scroll through all your projects? If you know your project ID, ` +
|
|
124
124
|
`you can initialize it directly using ${clc.bold("firebase init --project <project_id>")}.\n`);
|
|
125
125
|
}
|
|
126
|
-
const projectId = await prompt_1.promptOnce({
|
|
126
|
+
const projectId = await (0, prompt_1.promptOnce)({
|
|
127
127
|
type: "list",
|
|
128
128
|
name: "id",
|
|
129
129
|
message: "Select a default Firebase project for this directory:",
|
|
@@ -145,7 +145,7 @@ async function promptAvailableProjectId() {
|
|
|
145
145
|
throw new error_1.FirebaseError("There are no available Google Cloud projects to add Firebase services.");
|
|
146
146
|
}
|
|
147
147
|
if (nextPageToken) {
|
|
148
|
-
return await prompt_1.promptOnce({
|
|
148
|
+
return await (0, prompt_1.promptOnce)({
|
|
149
149
|
type: "input",
|
|
150
150
|
message: "Please input the ID of the Google Cloud Project you would like to add Firebase:",
|
|
151
151
|
});
|
|
@@ -161,7 +161,7 @@ async function promptAvailableProjectId() {
|
|
|
161
161
|
};
|
|
162
162
|
});
|
|
163
163
|
choices = _.orderBy(choices, ["name"], ["asc"]);
|
|
164
|
-
return await prompt_1.promptOnce({
|
|
164
|
+
return await (0, prompt_1.promptOnce)({
|
|
165
165
|
type: "list",
|
|
166
166
|
name: "id",
|
|
167
167
|
message: "Select the Google Cloud Platform project you would like to add Firebase:",
|
|
@@ -178,7 +178,7 @@ async function createCloudProject(projectId, options) {
|
|
|
178
178
|
timeout: CREATE_PROJECT_API_REQUEST_TIMEOUT_MILLIS,
|
|
179
179
|
data: { projectId, name: options.displayName || projectId, parent: options.parentResource },
|
|
180
180
|
});
|
|
181
|
-
const projectInfo = await operation_poller_1.pollOperation({
|
|
181
|
+
const projectInfo = await (0, operation_poller_1.pollOperation)({
|
|
182
182
|
pollerName: "Project Creation Poller",
|
|
183
183
|
apiOrigin: api.resourceManagerOrigin,
|
|
184
184
|
apiVersion: "v1",
|
|
@@ -209,7 +209,7 @@ async function addFirebaseToCloudProject(projectId) {
|
|
|
209
209
|
origin: api.firebaseApiOrigin,
|
|
210
210
|
timeout: CREATE_PROJECT_API_REQUEST_TIMEOUT_MILLIS,
|
|
211
211
|
});
|
|
212
|
-
const projectInfo = await operation_poller_1.pollOperation({
|
|
212
|
+
const projectInfo = await (0, operation_poller_1.pollOperation)({
|
|
213
213
|
pollerName: "Add Firebase Poller",
|
|
214
214
|
apiOrigin: api.firebaseApiOrigin,
|
|
215
215
|
apiVersion: "v1beta1",
|
package/lib/previews.js
CHANGED
|
@@ -6,8 +6,8 @@ const configstore_1 = require("./configstore");
|
|
|
6
6
|
exports.previews = Object.assign({ rtdbrules: false, ext: false, extdev: false, rtdbmanagement: false, functionsv2: false, golang: false, deletegcfartifacts: false, dotenv: false, artifactregistry: false }, configstore_1.configstore.get("previews"));
|
|
7
7
|
if (process.env.FIREBASE_CLI_PREVIEWS) {
|
|
8
8
|
process.env.FIREBASE_CLI_PREVIEWS.split(",").forEach((feature) => {
|
|
9
|
-
if (lodash_1.has(exports.previews, feature)) {
|
|
10
|
-
lodash_1.set(exports.previews, feature, true);
|
|
9
|
+
if ((0, lodash_1.has)(exports.previews, feature)) {
|
|
10
|
+
(0, lodash_1.set)(exports.previews, feature, true);
|
|
11
11
|
}
|
|
12
12
|
});
|
|
13
13
|
}
|
package/lib/profiler.js
CHANGED
|
@@ -14,7 +14,7 @@ const responseToError = require("./responseToError");
|
|
|
14
14
|
const utils = require("./utils");
|
|
15
15
|
tmp.setGracefulCleanup();
|
|
16
16
|
async function profiler(options) {
|
|
17
|
-
const origin = api_1.realtimeOriginOrEmulatorOrCustomUrl(options.instanceDetails.databaseUrl);
|
|
17
|
+
const origin = (0, api_1.realtimeOriginOrEmulatorOrCustomUrl)(options.instanceDetails.databaseUrl);
|
|
18
18
|
const url = new URL(utils.getDatabaseUrl(origin, options.instance, "/.settings/profile.json?"));
|
|
19
19
|
const rl = readline.createInterface({ input: process.stdin });
|
|
20
20
|
const fileOut = !!options.output;
|
package/lib/projectPath.js
CHANGED
|
@@ -5,7 +5,7 @@ const path = require("path");
|
|
|
5
5
|
const detectProjectRoot_1 = require("./detectProjectRoot");
|
|
6
6
|
const error_1 = require("./error");
|
|
7
7
|
function resolveProjectPath(options, filePath) {
|
|
8
|
-
const projectRoot = detectProjectRoot_1.detectProjectRoot(options);
|
|
8
|
+
const projectRoot = (0, detectProjectRoot_1.detectProjectRoot)(options);
|
|
9
9
|
if (!projectRoot) {
|
|
10
10
|
throw new error_1.FirebaseError("Expected to be in a project directory, but none was found.", {
|
|
11
11
|
exit: 2,
|
package/lib/projectUtils.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getAliases = exports.needProjectNumber = exports.needProjectId = exports.getProjectId = void 0;
|
|
4
4
|
const projects_1 = require("./management/projects");
|
|
5
5
|
const clc = require("cli-color");
|
|
6
|
-
const marked = require("marked");
|
|
6
|
+
const { marked } = require("marked");
|
|
7
7
|
const { FirebaseError } = require("./error");
|
|
8
8
|
function getProjectId({ projectId, project, }) {
|
|
9
9
|
return projectId || project;
|
|
@@ -43,7 +43,7 @@ async function needProjectNumber(options) {
|
|
|
43
43
|
return options.projectNumber;
|
|
44
44
|
}
|
|
45
45
|
const projectId = needProjectId(options);
|
|
46
|
-
const metadata = await projects_1.getFirebaseProject(projectId);
|
|
46
|
+
const metadata = await (0, projects_1.getFirebaseProject)(projectId);
|
|
47
47
|
options.projectNumber = metadata.projectNumber;
|
|
48
48
|
return options.projectNumber;
|
|
49
49
|
}
|
package/lib/prompt.js
CHANGED
|
@@ -15,7 +15,6 @@ async function prompt(options, questions) {
|
|
|
15
15
|
const missingOptions = _.uniq(_.map(prompts, "name")).join(", ");
|
|
16
16
|
throw new error_1.FirebaseError(`Missing required options (${missingOptions}) while running in non-interactive mode`, {
|
|
17
17
|
children: prompts,
|
|
18
|
-
exit: 1,
|
|
19
18
|
});
|
|
20
19
|
}
|
|
21
20
|
const answers = await inquirer.prompt(prompts);
|
package/lib/rc.js
CHANGED
|
@@ -17,7 +17,7 @@ const TARGET_TYPES = {
|
|
|
17
17
|
};
|
|
18
18
|
function loadRC(options) {
|
|
19
19
|
const cwd = options.cwd || process.cwd();
|
|
20
|
-
const dir = detectProjectRoot_1.detectProjectRoot(options);
|
|
20
|
+
const dir = (0, detectProjectRoot_1.detectProjectRoot)(options);
|
|
21
21
|
const potential = path.resolve(dir || cwd, "./.firebaserc");
|
|
22
22
|
return RC.loadFile(potential);
|
|
23
23
|
}
|
package/lib/remoteconfig/get.js
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getTemplate = exports.parseTemplateForTable = void 0;
|
|
4
|
-
const
|
|
4
|
+
const api_1 = require("../api");
|
|
5
|
+
const apiv2_1 = require("../apiv2");
|
|
5
6
|
const logger_1 = require("../logger");
|
|
6
7
|
const error_1 = require("../error");
|
|
7
8
|
const TIMEOUT = 30000;
|
|
8
9
|
const MAX_DISPLAY_ITEMS = 50;
|
|
10
|
+
const apiClient = new apiv2_1.Client({
|
|
11
|
+
urlPrefix: api_1.remoteConfigApiOrigin,
|
|
12
|
+
apiVersion: "v1",
|
|
13
|
+
});
|
|
9
14
|
function parseTemplateForTable(templateItems) {
|
|
10
15
|
let outputStr = "";
|
|
11
16
|
let counter = 0;
|
|
@@ -24,20 +29,21 @@ function parseTemplateForTable(templateItems) {
|
|
|
24
29
|
exports.parseTemplateForTable = parseTemplateForTable;
|
|
25
30
|
async function getTemplate(projectId, versionNumber) {
|
|
26
31
|
try {
|
|
27
|
-
|
|
32
|
+
const params = new URLSearchParams();
|
|
28
33
|
if (versionNumber) {
|
|
29
|
-
|
|
34
|
+
params.set("versionNumber", versionNumber);
|
|
30
35
|
}
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
36
|
+
const res = await apiClient.request({
|
|
37
|
+
method: "GET",
|
|
38
|
+
path: `/projects/${projectId}/remoteConfig`,
|
|
39
|
+
queryParams: params,
|
|
34
40
|
timeout: TIMEOUT,
|
|
35
41
|
});
|
|
36
|
-
return
|
|
42
|
+
return res.body;
|
|
37
43
|
}
|
|
38
44
|
catch (err) {
|
|
39
45
|
logger_1.logger.debug(err.message);
|
|
40
|
-
throw new error_1.FirebaseError(`Failed to get Firebase Remote Config template for project ${projectId}. `, {
|
|
46
|
+
throw new error_1.FirebaseError(`Failed to get Firebase Remote Config template for project ${projectId}. `, { original: err });
|
|
41
47
|
}
|
|
42
48
|
}
|
|
43
49
|
exports.getTemplate = getTemplate;
|
|
@@ -1,15 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.rollbackTemplate = void 0;
|
|
4
|
-
const
|
|
4
|
+
const api_1 = require("../api");
|
|
5
|
+
const apiv2_1 = require("../apiv2");
|
|
6
|
+
const apiClient = new apiv2_1.Client({
|
|
7
|
+
urlPrefix: api_1.remoteConfigApiOrigin,
|
|
8
|
+
apiVersion: "v1",
|
|
9
|
+
});
|
|
5
10
|
const TIMEOUT = 30000;
|
|
6
11
|
async function rollbackTemplate(projectId, versionNumber) {
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
12
|
+
const params = new URLSearchParams();
|
|
13
|
+
params.set("versionNumber", `${versionNumber}`);
|
|
14
|
+
const res = await apiClient.request({
|
|
15
|
+
method: "POST",
|
|
16
|
+
path: `/projects/${projectId}/remoteConfig:rollback`,
|
|
17
|
+
queryParams: params,
|
|
11
18
|
timeout: TIMEOUT,
|
|
12
19
|
});
|
|
13
|
-
return
|
|
20
|
+
return res.body;
|
|
14
21
|
}
|
|
15
22
|
exports.rollbackTemplate = rollbackTemplate;
|
|
@@ -1,27 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getVersions = void 0;
|
|
4
|
-
const
|
|
4
|
+
const api_1 = require("../api");
|
|
5
|
+
const apiv2_1 = require("../apiv2");
|
|
5
6
|
const error_1 = require("../error");
|
|
6
7
|
const logger_1 = require("../logger");
|
|
8
|
+
const apiClient = new apiv2_1.Client({
|
|
9
|
+
urlPrefix: api_1.remoteConfigApiOrigin,
|
|
10
|
+
apiVersion: "v1",
|
|
11
|
+
});
|
|
7
12
|
const TIMEOUT = 30000;
|
|
8
13
|
async function getVersions(projectId, maxResults = 10) {
|
|
9
14
|
maxResults = maxResults || 300;
|
|
10
15
|
try {
|
|
11
|
-
|
|
16
|
+
const params = new URLSearchParams();
|
|
12
17
|
if (maxResults) {
|
|
13
|
-
|
|
18
|
+
params.set("pageSize", `${maxResults}`);
|
|
14
19
|
}
|
|
15
|
-
const response = await
|
|
16
|
-
|
|
17
|
-
|
|
20
|
+
const response = await apiClient.request({
|
|
21
|
+
method: "GET",
|
|
22
|
+
path: `/projects/${projectId}/remoteConfig:listVersions`,
|
|
23
|
+
queryParams: params,
|
|
18
24
|
timeout: TIMEOUT,
|
|
19
25
|
});
|
|
20
26
|
return response.body;
|
|
21
27
|
}
|
|
22
28
|
catch (err) {
|
|
23
29
|
logger_1.logger.debug(err.message);
|
|
24
|
-
throw new error_1.FirebaseError(`Failed to get Remote Config template versions for Firebase project ${projectId}. `, {
|
|
30
|
+
throw new error_1.FirebaseError(`Failed to get Remote Config template versions for Firebase project ${projectId}. `, { original: err });
|
|
25
31
|
}
|
|
26
32
|
}
|
|
27
33
|
exports.getVersions = getVersions;
|
package/lib/requireAuth.js
CHANGED
|
@@ -50,12 +50,12 @@ async function requireAuth(options) {
|
|
|
50
50
|
}
|
|
51
51
|
tokenOpt = tokenOpt || process.env.FIREBASE_TOKEN;
|
|
52
52
|
if (tokenOpt) {
|
|
53
|
-
auth_1.setRefreshToken(tokenOpt);
|
|
53
|
+
(0, auth_1.setRefreshToken)(tokenOpt);
|
|
54
54
|
return;
|
|
55
55
|
}
|
|
56
56
|
if (!user || !tokens) {
|
|
57
57
|
throw new error_1.FirebaseError(AUTH_ERROR_MESSAGE);
|
|
58
58
|
}
|
|
59
|
-
auth_1.setActiveAccount(options, { user, tokens });
|
|
59
|
+
(0, auth_1.setActiveAccount)(options, { user, tokens });
|
|
60
60
|
}
|
|
61
61
|
exports.requireAuth = requireAuth;
|
|
@@ -11,7 +11,7 @@ async function requireDatabaseInstance(options) {
|
|
|
11
11
|
}
|
|
12
12
|
let instance;
|
|
13
13
|
try {
|
|
14
|
-
instance = await getDefaultDatabaseInstance_1.getDefaultDatabaseInstance(options);
|
|
14
|
+
instance = await (0, getDefaultDatabaseInstance_1.getDefaultDatabaseInstance)(options);
|
|
15
15
|
}
|
|
16
16
|
catch (err) {
|
|
17
17
|
throw new error_1.FirebaseError(`Failed to get details for project: ${options.project}.`, {
|
|
@@ -6,7 +6,7 @@ async function requireHostingSite(options) {
|
|
|
6
6
|
if (options.site) {
|
|
7
7
|
return Promise.resolve();
|
|
8
8
|
}
|
|
9
|
-
const site = await getDefaultHostingSite_1.getDefaultHostingSite(options);
|
|
9
|
+
const site = await (0, getDefaultHostingSite_1.getDefaultHostingSite)(options);
|
|
10
10
|
options.site = site;
|
|
11
11
|
}
|
|
12
12
|
exports.requireHostingSite = requireHostingSite;
|
|
@@ -9,14 +9,14 @@ const error_1 = require("./error");
|
|
|
9
9
|
const iam_1 = require("./gcp/iam");
|
|
10
10
|
const BASE_PERMISSIONS = ["firebase.projects.get"];
|
|
11
11
|
async function requirePermissions(options, permissions = []) {
|
|
12
|
-
const projectId = projectUtils_1.needProjectId(options);
|
|
12
|
+
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
13
13
|
const requiredPermissions = BASE_PERMISSIONS.concat(permissions).sort();
|
|
14
|
-
await requireAuth_1.requireAuth(options);
|
|
14
|
+
await (0, requireAuth_1.requireAuth)(options);
|
|
15
15
|
logger_1.logger.debug(`[iam] checking project ${projectId} for permissions ${JSON.stringify(requiredPermissions)}`);
|
|
16
16
|
try {
|
|
17
|
-
const iamResult = await iam_1.testIamPermissions(projectId, requiredPermissions);
|
|
17
|
+
const iamResult = await (0, iam_1.testIamPermissions)(projectId, requiredPermissions);
|
|
18
18
|
if (!iamResult.passed) {
|
|
19
|
-
throw new error_1.FirebaseError(`Authorization failed. This account is missing the following required permissions on project ${cli_color_1.bold(projectId)}:\n\n ${iamResult.missing.join("\n ")}`);
|
|
19
|
+
throw new error_1.FirebaseError(`Authorization failed. This account is missing the following required permissions on project ${(0, cli_color_1.bold)(projectId)}:\n\n ${iamResult.missing.join("\n ")}`);
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
catch (err) {
|
package/lib/rulesDeploy.js
CHANGED
|
@@ -56,7 +56,7 @@ class RulesDeploy {
|
|
|
56
56
|
}
|
|
57
57
|
async createRulesets(service) {
|
|
58
58
|
const createdRulesetNames = [];
|
|
59
|
-
const { latestName: latestRulesetName, latestContent: latestRulesetContent
|
|
59
|
+
const { latestName: latestRulesetName, latestContent: latestRulesetContent } = await this.getCurrentRules(service);
|
|
60
60
|
const newRulesetsByFilename = new Map();
|
|
61
61
|
for (const filename of Object.keys(this.rulesFiles)) {
|
|
62
62
|
const files = this.rulesFiles[filename];
|
|
@@ -83,7 +83,7 @@ class RulesDeploy {
|
|
|
83
83
|
" quota exceeded error while uploading rules");
|
|
84
84
|
const history = await gcp.rules.listAllRulesets(this.options.project);
|
|
85
85
|
if (history.length > RULESET_COUNT_LIMIT) {
|
|
86
|
-
const confirm = await prompt_1.promptOnce({
|
|
86
|
+
const confirm = await (0, prompt_1.promptOnce)({
|
|
87
87
|
type: "confirm",
|
|
88
88
|
name: "force",
|
|
89
89
|
message: `You have ${history.length} rules, do you want to delete the oldest ${RULESETS_TO_GC} to free up space?`,
|
package/lib/serve/functions.js
CHANGED
|
@@ -11,23 +11,26 @@ const utils = require("../utils");
|
|
|
11
11
|
class FunctionsServer {
|
|
12
12
|
constructor() {
|
|
13
13
|
this.emulatorServer = undefined;
|
|
14
|
+
this.backend = undefined;
|
|
14
15
|
}
|
|
15
16
|
assertServer() {
|
|
16
|
-
if (!this.emulatorServer) {
|
|
17
|
+
if (!this.emulatorServer || !this.backend) {
|
|
17
18
|
throw new Error("Must call start() before calling any other operation!");
|
|
18
19
|
}
|
|
19
20
|
}
|
|
20
21
|
async start(options, partialArgs) {
|
|
21
|
-
const projectId = projectUtils_1.needProjectId(options);
|
|
22
|
+
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
22
23
|
utils.assertDefined(options.config.src.functions);
|
|
23
24
|
utils.assertDefined(options.config.src.functions.source, "Error: 'functions.source' is not defined");
|
|
24
25
|
const functionsDir = path.join(options.config.projectDir, options.config.src.functions.source);
|
|
25
|
-
const account = auth_1.getProjectDefaultAccount(options.config.projectDir);
|
|
26
|
-
const nodeMajorVersion = functionsEmulatorUtils_1.parseRuntimeVersion(options.config.get("functions.runtime"));
|
|
27
|
-
|
|
26
|
+
const account = (0, auth_1.getProjectDefaultAccount)(options.config.projectDir);
|
|
27
|
+
const nodeMajorVersion = (0, functionsEmulatorUtils_1.parseRuntimeVersion)(options.config.get("functions.runtime"));
|
|
28
|
+
this.backend = {
|
|
28
29
|
functionsDir,
|
|
29
|
-
|
|
30
|
-
nodeMajorVersion
|
|
30
|
+
env: {},
|
|
31
|
+
nodeMajorVersion,
|
|
32
|
+
};
|
|
33
|
+
const args = Object.assign({ projectId, emulatableBackends: [this.backend], account }, partialArgs);
|
|
31
34
|
if (options.host) {
|
|
32
35
|
utils.assertIsStringOrUndefined(options.host);
|
|
33
36
|
args.host = options.host;
|
|
@@ -55,6 +58,10 @@ class FunctionsServer {
|
|
|
55
58
|
this.assertServer();
|
|
56
59
|
await this.emulatorServer.stop();
|
|
57
60
|
}
|
|
61
|
+
getBackend() {
|
|
62
|
+
this.assertServer();
|
|
63
|
+
return this.backend;
|
|
64
|
+
}
|
|
58
65
|
get() {
|
|
59
66
|
this.assertServer();
|
|
60
67
|
return this.emulatorServer.get();
|
package/lib/serve/hosting.js
CHANGED
|
@@ -20,7 +20,7 @@ let attempts = 0;
|
|
|
20
20
|
let destroyServer = undefined;
|
|
21
21
|
const logger = emulatorLogger_1.EmulatorLogger.forEmulator(types_1.Emulators.HOSTING);
|
|
22
22
|
function startServer(options, config, port, init) {
|
|
23
|
-
const firebaseMiddleware = initMiddleware_1.initMiddleware(init);
|
|
23
|
+
const firebaseMiddleware = (0, initMiddleware_1.initMiddleware)(init);
|
|
24
24
|
const morganStream = new stream_1.Writable();
|
|
25
25
|
morganStream._write = (chunk, encoding, callback) => {
|
|
26
26
|
if (chunk instanceof Buffer) {
|
|
@@ -36,7 +36,7 @@ function startServer(options, config, port, init) {
|
|
|
36
36
|
port: port,
|
|
37
37
|
host: options.host,
|
|
38
38
|
config: config,
|
|
39
|
-
cwd: detectProjectRoot_1.detectProjectRoot(options),
|
|
39
|
+
cwd: (0, detectProjectRoot_1.detectProjectRoot)(options),
|
|
40
40
|
stack: "strict",
|
|
41
41
|
before: {
|
|
42
42
|
files: (req, res, next) => {
|
|
@@ -46,8 +46,8 @@ function startServer(options, config, port, init) {
|
|
|
46
46
|
},
|
|
47
47
|
},
|
|
48
48
|
rewriters: {
|
|
49
|
-
function: functionsProxy_1.default(options),
|
|
50
|
-
run: cloudRunProxy_1.default(options),
|
|
49
|
+
function: (0, functionsProxy_1.default)(options),
|
|
50
|
+
run: (0, cloudRunProxy_1.default)(options),
|
|
51
51
|
},
|
|
52
52
|
}).listen(() => {
|
|
53
53
|
const siteName = config.target || config.site;
|
|
@@ -57,7 +57,7 @@ function startServer(options, config, port, init) {
|
|
|
57
57
|
}
|
|
58
58
|
logger.logLabeled("SUCCESS", label, "Local server: " + clc.underline(clc.bold("http://" + options.host + ":" + port)));
|
|
59
59
|
});
|
|
60
|
-
destroyServer = utils_1.createDestroyer(server);
|
|
60
|
+
destroyServer = (0, utils_1.createDestroyer)(server);
|
|
61
61
|
server.on("error", (err) => {
|
|
62
62
|
if (err.code === "EADDRINUSE") {
|
|
63
63
|
const message = "Port " + options.port + " is not available.";
|
|
@@ -83,8 +83,8 @@ function stop() {
|
|
|
83
83
|
}
|
|
84
84
|
exports.stop = stop;
|
|
85
85
|
async function start(options) {
|
|
86
|
-
const init = await implicitInit_1.implicitInit(options);
|
|
87
|
-
const configs = normalizedHostingConfigs_1.normalizedHostingConfigs(options);
|
|
86
|
+
const init = await (0, implicitInit_1.implicitInit)(options);
|
|
87
|
+
const configs = (0, normalizedHostingConfigs_1.normalizedHostingConfigs)(options);
|
|
88
88
|
for (let i = 0; i < configs.length; i++) {
|
|
89
89
|
const port = i === 0 ? options.port : options.port + 4 + i;
|
|
90
90
|
startServer(options, configs[i], port, init);
|
package/lib/utils.js
CHANGED
|
@@ -333,9 +333,10 @@ function createDestroyer(server) {
|
|
|
333
333
|
}
|
|
334
334
|
exports.createDestroyer = createDestroyer;
|
|
335
335
|
function datetimeString(d) {
|
|
336
|
-
const day = `${d.getFullYear()}-${(d.getMonth() + 1)
|
|
336
|
+
const day = `${d.getFullYear()}-${(d.getMonth() + 1).toString().padStart(2, "0")}-${d
|
|
337
|
+
.getDate()
|
|
337
338
|
.toString()
|
|
338
|
-
.padStart(2, "0")}
|
|
339
|
+
.padStart(2, "0")}`;
|
|
339
340
|
const time = `${d.getHours().toString().padStart(2, "0")}:${d
|
|
340
341
|
.getMinutes()
|
|
341
342
|
.toString()
|