firebase-tools 11.4.2 → 11.7.0
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/accountImporter.js +1 -1
- package/lib/auth.js +3 -4
- package/lib/bin/firebase.js +4 -4
- package/lib/command.js +35 -10
- package/lib/commands/apps-android-sha-create.js +1 -1
- package/lib/commands/apps-android-sha-delete.js +1 -1
- package/lib/commands/apps-create.js +1 -1
- package/lib/commands/apps-list.js +1 -1
- package/lib/commands/auth-export.js +1 -1
- package/lib/commands/auth-import.js +1 -1
- package/lib/commands/crashlytics-mappingfile-generateid.js +26 -0
- package/lib/commands/crashlytics-mappingfile-upload.js +46 -0
- package/lib/commands/crashlytics-symbols-upload.js +18 -87
- package/lib/commands/database-instances-list.js +1 -1
- package/lib/commands/database-push.js +1 -1
- package/lib/commands/database-remove.js +1 -1
- package/lib/commands/database-set.js +1 -1
- package/lib/commands/database-update.js +1 -1
- package/lib/commands/emulators-exec.js +4 -1
- package/lib/commands/emulators-export.js +5 -2
- package/lib/commands/emulators-start.js +24 -18
- package/lib/commands/ext-dev-deprecate.js +1 -1
- package/lib/commands/ext-dev-emulators-exec.js +1 -1
- package/lib/commands/ext-dev-emulators-start.js +1 -1
- package/lib/commands/ext-dev-extension-delete.js +1 -1
- package/lib/commands/ext-dev-list.js +1 -1
- package/lib/commands/ext-dev-publish.js +4 -1
- package/lib/commands/ext-dev-register.js +1 -1
- package/lib/commands/ext-dev-undeprecate.js +1 -1
- package/lib/commands/ext-dev-unpublish.js +1 -1
- package/lib/commands/ext-dev-usage.js +1 -1
- package/lib/commands/ext-info.js +1 -1
- package/lib/commands/ext-install.js +2 -2
- package/lib/commands/ext-update.js +1 -1
- package/lib/commands/ext.js +1 -1
- package/lib/commands/firestore-delete.js +2 -2
- package/lib/commands/firestore-indexes-list.js +3 -3
- package/lib/commands/functions-config-clone.js +1 -1
- package/lib/commands/functions-config-export.js +1 -1
- package/lib/commands/functions-config-set.js +1 -1
- package/lib/commands/functions-config-unset.js +1 -1
- package/lib/commands/functions-delete.js +3 -1
- package/lib/commands/functions-secrets-get.js +2 -0
- package/lib/commands/functions-secrets-set.js +1 -1
- package/lib/commands/help.js +1 -1
- package/lib/commands/hosting-channel-create.js +5 -5
- package/lib/commands/hosting-channel-delete.js +3 -3
- package/lib/commands/hosting-channel-deploy.js +6 -6
- package/lib/commands/hosting-channel-list.js +2 -2
- package/lib/commands/hosting-channel-open.js +2 -2
- package/lib/commands/hosting-clone.js +8 -8
- package/lib/commands/hosting-disable.js +1 -1
- package/lib/commands/hosting-sites-create.js +4 -4
- package/lib/commands/hosting-sites-delete.js +4 -4
- package/lib/commands/hosting-sites-list.js +2 -2
- package/lib/commands/index.js +3 -0
- package/lib/commands/init.js +5 -5
- package/lib/commands/login-add.js +1 -1
- package/lib/commands/login-ci.js +2 -2
- package/lib/commands/login-list.js +1 -1
- package/lib/commands/login-use.js +1 -1
- package/lib/commands/login.js +3 -3
- package/lib/commands/logout.js +1 -1
- package/lib/commands/open.js +3 -3
- package/lib/commands/projects-list.js +2 -2
- package/lib/commands/serve.js +1 -1
- package/lib/commands/target-apply.js +1 -1
- package/lib/commands/target-clear.js +1 -1
- package/lib/commands/target-remove.js +1 -1
- package/lib/commands/target.js +1 -1
- package/lib/commands/use.js +7 -7
- package/lib/config.js +1 -1
- package/lib/crashlytics/buildToolsJarHelper.js +51 -0
- package/lib/deploy/database/prepare.js +3 -3
- package/lib/deploy/database/release.js +3 -3
- package/lib/deploy/extensions/deploymentSummary.js +1 -1
- package/lib/deploy/extensions/errors.js +1 -1
- package/lib/deploy/extensions/secrets.js +1 -1
- package/lib/deploy/extensions/tasks.js +2 -2
- package/lib/deploy/firestore/deploy.js +2 -2
- package/lib/deploy/firestore/prepare.js +2 -2
- package/lib/deploy/functions/backend.js +4 -4
- package/lib/deploy/functions/build.js +78 -8
- package/lib/deploy/functions/checkIam.js +9 -8
- package/lib/deploy/functions/containerCleaner.js +2 -2
- package/lib/deploy/functions/deploy.js +2 -2
- package/lib/deploy/functions/ensure.js +1 -1
- package/lib/deploy/functions/params.js +15 -15
- package/lib/deploy/functions/prepare.js +1 -1
- package/lib/deploy/functions/prepareFunctionsUpload.js +2 -2
- package/lib/deploy/functions/prompts.js +1 -1
- package/lib/deploy/functions/release/fabricator.js +24 -7
- package/lib/deploy/functions/release/index.js +3 -1
- package/lib/deploy/functions/release/reporter.js +1 -1
- package/lib/deploy/functions/runtimes/discovery/index.js +1 -16
- package/lib/deploy/functions/runtimes/discovery/parsing.js +16 -0
- package/lib/deploy/functions/runtimes/discovery/v1alpha1.js +59 -131
- package/lib/deploy/functions/runtimes/node/parseRuntimeAndValidateSDK.js +1 -1
- package/lib/deploy/functions/runtimes/node/parseTriggers.js +2 -6
- package/lib/deploy/functions/runtimes/node/versioning.js +4 -4
- package/lib/deploy/functions/validate.js +1 -1
- package/lib/deploy/hosting/deploy.js +10 -9
- package/lib/deploy/hosting/uploader.js +2 -2
- package/lib/deploy/hosting/validate.js +2 -2
- package/lib/deploy/index.js +7 -7
- package/lib/deploy/lifecycleHooks.js +5 -2
- package/lib/deploy/storage/prepare.js +5 -3
- package/lib/deploy/storage/release.js +7 -6
- package/lib/emulator/auth/index.js +7 -2
- package/lib/emulator/auth/operations.js +10 -10
- package/lib/emulator/commandUtils.js +33 -16
- package/lib/emulator/constants.js +14 -6
- package/lib/emulator/controller.js +50 -18
- package/lib/emulator/databaseEmulator.js +1 -1
- package/lib/emulator/downloadableEmulators.js +8 -8
- package/lib/emulator/emulatorLogger.js +1 -1
- package/lib/emulator/eventarcEmulator.js +148 -0
- package/lib/emulator/extensionsEmulator.js +5 -3
- package/lib/emulator/firestoreEmulator.js +1 -1
- package/lib/emulator/functionsEmulator.js +66 -14
- package/lib/emulator/functionsEmulatorRuntime.js +12 -23
- package/lib/emulator/functionsEmulatorShared.js +6 -1
- package/lib/emulator/hub.js +7 -3
- package/lib/emulator/hubClient.js +2 -2
- package/lib/emulator/hubExport.js +22 -2
- package/lib/emulator/loggingEmulator.js +2 -2
- package/lib/emulator/registry.js +1 -0
- package/lib/emulator/storage/apis/firebase.js +26 -12
- package/lib/emulator/storage/apis/gcloud.js +15 -8
- package/lib/emulator/storage/files.js +21 -4
- package/lib/emulator/storage/multipart.js +6 -5
- package/lib/emulator/storage/rules/runtime.js +3 -3
- package/lib/emulator/storage/rules/utils.js +4 -2
- package/lib/emulator/storage/server.js +2 -1
- package/lib/emulator/storage/upload.js +1 -0
- package/lib/emulator/types.js +4 -0
- package/lib/emulator/ui.js +7 -2
- package/lib/ensureApiEnabled.js +7 -7
- package/lib/extensions/askUserForConsent.js +1 -1
- package/lib/extensions/askUserForEventsConfig.js +1 -1
- package/lib/extensions/askUserForParam.js +1 -1
- package/lib/extensions/changelog.js +2 -2
- package/lib/extensions/checkProjectBilling.js +2 -2
- package/lib/extensions/displayExtensionInfo.js +1 -1
- package/lib/extensions/extensionsApi.js +3 -2
- package/lib/extensions/extensionsHelper.js +30 -2
- package/lib/extensions/listExtensions.js +1 -1
- package/lib/extensions/manifest.js +1 -1
- package/lib/extensions/metricsUtils.js +1 -1
- package/lib/extensions/paramHelper.js +1 -1
- package/lib/extensions/updateHelper.js +2 -2
- package/lib/extensions/warnings.js +2 -2
- package/lib/fetchMOTD.js +1 -1
- package/lib/firestore/delete.js +1 -1
- package/lib/firestore/indexes.js +2 -2
- package/lib/firestore/validator.js +1 -1
- package/lib/functions/env.js +11 -11
- package/lib/functions/runtimeConfigExport.js +1 -1
- package/lib/functionsConfig.js +1 -1
- package/lib/functionsConfigClone.js +1 -1
- package/lib/functionsShellCommandAction.js +1 -1
- package/lib/gcp/cloudfunctions.js +3 -3
- package/lib/gcp/cloudfunctionsv2.js +5 -5
- package/lib/gcp/cloudscheduler.js +63 -22
- package/lib/gcp/cloudtasks.js +17 -1
- package/lib/gcp/serviceusage.js +2 -2
- package/lib/handlePreviewToggles.js +4 -4
- package/lib/hosting/implicitInit.js +1 -1
- package/lib/hosting/normalizedHostingConfigs.js +3 -3
- package/lib/index.js +2 -2
- package/lib/init/features/database.js +1 -1
- package/lib/init/features/emulators.js +1 -1
- package/lib/init/features/firestore/index.js +2 -2
- package/lib/init/features/firestore/indexes.js +1 -1
- package/lib/init/features/firestore/rules.js +1 -1
- package/lib/init/features/functions/golang.js +1 -1
- package/lib/init/features/functions/index.js +8 -1
- package/lib/init/features/hosting/github.js +9 -9
- package/lib/init/features/hosting/index.js +1 -1
- package/lib/init/features/project.js +1 -1
- package/lib/init/features/remoteconfig.js +1 -1
- package/lib/init/features/storage.js +1 -1
- package/lib/init/index.js +1 -1
- package/lib/logError.js +3 -3
- package/lib/management/projects.js +1 -1
- package/lib/parseBoltRules.js +1 -1
- package/lib/profileReport.js +2 -2
- package/lib/projectUtils.js +1 -1
- package/lib/rc.js +1 -1
- package/lib/requireAuth.js +1 -1
- package/lib/requireDatabaseInstance.js +2 -2
- package/lib/requirePermissions.js +2 -2
- package/lib/rulesDeploy.js +11 -12
- package/lib/serve/hosting.js +2 -1
- package/lib/serve/index.js +15 -0
- package/lib/track.js +122 -3
- package/lib/utils.js +24 -11
- package/npm-shrinkwrap.json +523 -294
- package/package.json +6 -4
- package/schema/firebase-config.json +12 -0
- package/templates/extensions/CHANGELOG.md +1 -7
- package/templates/hosting/init.js +6 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.doSetup = void 0;
|
|
4
|
-
const clc = require("
|
|
4
|
+
const clc = require("colorette");
|
|
5
5
|
const fs = require("fs");
|
|
6
6
|
const apiv2_1 = require("../../../apiv2");
|
|
7
7
|
const github_1 = require("./github");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.doSetup = void 0;
|
|
4
|
-
const clc = require("
|
|
4
|
+
const clc = require("colorette");
|
|
5
5
|
const _ = require("lodash");
|
|
6
6
|
const error_1 = require("../../error");
|
|
7
7
|
const projects_1 = require("../../management/projects");
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.doSetup = void 0;
|
|
4
4
|
const prompt_1 = require("../../prompt");
|
|
5
5
|
const fsutils = require("../../fsutils");
|
|
6
|
-
const clc = require("
|
|
6
|
+
const clc = require("colorette");
|
|
7
7
|
async function doSetup(setup, config) {
|
|
8
8
|
setup.config.remoteconfig = {};
|
|
9
9
|
const jsonFilePath = await (0, prompt_1.promptOnce)({
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.doSetup = void 0;
|
|
4
|
-
const clc = require("
|
|
4
|
+
const clc = require("colorette");
|
|
5
5
|
const fs = require("fs");
|
|
6
6
|
const logger_1 = require("../../logger");
|
|
7
7
|
const prompt_1 = require("../../prompt");
|
package/lib/init/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.init = void 0;
|
|
4
4
|
const lodash_1 = require("lodash");
|
|
5
|
-
const clc = require("
|
|
5
|
+
const clc = require("colorette");
|
|
6
6
|
const error_1 = require("../error");
|
|
7
7
|
const logger_1 = require("../logger");
|
|
8
8
|
const features = require("./features");
|
package/lib/logError.js
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.logError = void 0;
|
|
4
4
|
const logger_1 = require("./logger");
|
|
5
|
-
const clc = require("
|
|
5
|
+
const clc = require("colorette");
|
|
6
6
|
function logError(error) {
|
|
7
7
|
if (error.children && error.children.length) {
|
|
8
|
-
logger_1.logger.error(clc.bold.red("Error:"), clc.underline(error.message) + ":");
|
|
8
|
+
logger_1.logger.error(clc.bold(clc.red("Error:")), clc.underline(error.message) + ":");
|
|
9
9
|
error.children.forEach((child) => {
|
|
10
10
|
let out = "- ";
|
|
11
11
|
if (child.name) {
|
|
@@ -20,7 +20,7 @@ function logError(error) {
|
|
|
20
20
|
logger_1.logger.debug(error.original.stack);
|
|
21
21
|
}
|
|
22
22
|
logger_1.logger.error();
|
|
23
|
-
logger_1.logger.error(clc.bold.red("Error:"), error.message);
|
|
23
|
+
logger_1.logger.error(clc.bold(clc.red("Error:")), error.message);
|
|
24
24
|
}
|
|
25
25
|
if (error.context) {
|
|
26
26
|
logger_1.logger.debug("Error Context:", JSON.stringify(error.context, undefined, 2));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getFirebaseProject = exports.listFirebaseProjects = exports.getAvailableCloudProjectPage = exports.getFirebaseProjectPage = exports.addFirebaseToCloudProject = exports.createCloudProject = exports.promptAvailableProjectId = exports.getOrPromptProject = exports.addFirebaseToCloudProjectAndLog = exports.createFirebaseProjectAndLog = exports.PROJECTS_CREATE_QUESTIONS = exports.ProjectParentResourceType = void 0;
|
|
4
|
-
const clc = require("
|
|
4
|
+
const clc = require("colorette");
|
|
5
5
|
const ora = require("ora");
|
|
6
6
|
const apiv2_1 = require("../apiv2");
|
|
7
7
|
const error_1 = require("../error");
|
package/lib/parseBoltRules.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.parseBoltRules = void 0;
|
|
4
4
|
const fs = require("fs");
|
|
5
5
|
const spawn = require("cross-spawn");
|
|
6
|
-
const clc = require("
|
|
6
|
+
const clc = require("colorette");
|
|
7
7
|
const _ = require("lodash");
|
|
8
8
|
const error_1 = require("./error");
|
|
9
9
|
function parseBoltRules(filename) {
|
package/lib/profileReport.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ProfileReport = exports.extractReadableIndex = exports.formatBytes = exports.formatNumber = exports.pathString = exports.extractJSON = void 0;
|
|
4
|
-
const clc = require("
|
|
4
|
+
const clc = require("colorette");
|
|
5
5
|
const Table = require("cli-table");
|
|
6
6
|
const fs = require("fs");
|
|
7
7
|
const _ = require("lodash");
|
|
@@ -515,7 +515,7 @@ class ProfileReport {
|
|
|
515
515
|
write(title + "\n");
|
|
516
516
|
}
|
|
517
517
|
else {
|
|
518
|
-
write(clc.bold.yellow(title) + "\n");
|
|
518
|
+
write(clc.bold(clc.yellow(title)) + "\n");
|
|
519
519
|
}
|
|
520
520
|
};
|
|
521
521
|
const writeTable = (title, table) => {
|
package/lib/projectUtils.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
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
|
-
const clc = require("
|
|
5
|
+
const clc = require("colorette");
|
|
6
6
|
const { marked } = require("marked");
|
|
7
7
|
const { FirebaseError } = require("./error");
|
|
8
8
|
function getProjectId({ projectId, project, }) {
|
package/lib/rc.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RC = exports.loadRC = void 0;
|
|
4
4
|
const _ = require("lodash");
|
|
5
|
-
const clc = require("
|
|
5
|
+
const clc = require("colorette");
|
|
6
6
|
const cjson = require("cjson");
|
|
7
7
|
const fs = require("fs");
|
|
8
8
|
const path = require("path");
|
package/lib/requireAuth.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.requireAuth = void 0;
|
|
4
4
|
const google_auth_library_1 = require("google-auth-library");
|
|
5
|
-
const clc = require("
|
|
5
|
+
const clc = require("colorette");
|
|
6
6
|
const api = require("./api");
|
|
7
7
|
const apiv2 = require("./apiv2");
|
|
8
8
|
const error_1 = require("./error");
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.requireDatabaseInstance = exports.MISSING_DEFAULT_INSTANCE_ERROR_MESSAGE = void 0;
|
|
4
|
-
const clc = require("
|
|
4
|
+
const clc = require("colorette");
|
|
5
5
|
const error_1 = require("./error");
|
|
6
6
|
const getDefaultDatabaseInstance_1 = require("./getDefaultDatabaseInstance");
|
|
7
|
-
exports.MISSING_DEFAULT_INSTANCE_ERROR_MESSAGE = `It looks like you haven't created a Realtime Database instance in this project before. Please run ${clc.bold.underline("firebase init database")} to create your default Realtime Database instance.`;
|
|
7
|
+
exports.MISSING_DEFAULT_INSTANCE_ERROR_MESSAGE = `It looks like you haven't created a Realtime Database instance in this project before. Please run ${clc.bold(clc.underline("firebase init database"))} to create your default Realtime Database instance.`;
|
|
8
8
|
async function requireDatabaseInstance(options) {
|
|
9
9
|
if (options.instance) {
|
|
10
10
|
return;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.requirePermissions = void 0;
|
|
4
|
-
const
|
|
4
|
+
const colorette_1 = require("colorette");
|
|
5
5
|
const projectUtils_1 = require("./projectUtils");
|
|
6
6
|
const requireAuth_1 = require("./requireAuth");
|
|
7
7
|
const logger_1 = require("./logger");
|
|
@@ -19,7 +19,7 @@ async function requirePermissions(options, permissions = []) {
|
|
|
19
19
|
try {
|
|
20
20
|
const iamResult = await (0, iam_1.testIamPermissions)(projectId, requiredPermissions);
|
|
21
21
|
if (!iamResult.passed) {
|
|
22
|
-
throw new error_1.FirebaseError(`Authorization failed. This account is missing the following required permissions on project ${(0,
|
|
22
|
+
throw new error_1.FirebaseError(`Authorization failed. This account is missing the following required permissions on project ${(0, colorette_1.bold)(projectId)}:\n\n ${iamResult.missing.join("\n ")}`);
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
catch (err) {
|
package/lib/rulesDeploy.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RulesDeploy = exports.RulesetServiceType = void 0;
|
|
4
4
|
const _ = require("lodash");
|
|
5
|
-
const
|
|
5
|
+
const colorette_1 = require("colorette");
|
|
6
6
|
const fs = require("fs-extra");
|
|
7
7
|
const gcp = require("./gcp");
|
|
8
8
|
const logger_1 = require("./logger");
|
|
@@ -42,7 +42,7 @@ class RulesDeploy {
|
|
|
42
42
|
}
|
|
43
43
|
catch (e) {
|
|
44
44
|
logger_1.logger.debug("[rules read error]", e.stack);
|
|
45
|
-
throw new error_1.FirebaseError(
|
|
45
|
+
throw new error_1.FirebaseError(`Error reading rules file ${(0, colorette_1.bold)(path)}`);
|
|
46
46
|
}
|
|
47
47
|
this.rulesFiles[path] = [{ name: path, content: src }];
|
|
48
48
|
}
|
|
@@ -80,7 +80,7 @@ class RulesDeploy {
|
|
|
80
80
|
}, this.options);
|
|
81
81
|
if (addRole) {
|
|
82
82
|
await (0, resourceManager_1.addServiceAccountToRoles)(projectNumber, saEmail, [CROSS_SERVICE_RULES_ROLE], true);
|
|
83
|
-
utils.
|
|
83
|
+
utils.logLabeledBullet(RulesetType[this.type], "updated service account for cross-service rules...");
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
86
|
catch (e) {
|
|
@@ -95,14 +95,14 @@ class RulesDeploy {
|
|
|
95
95
|
const newRulesetsByFilename = new Map();
|
|
96
96
|
for (const [filename, files] of Object.entries(this.rulesFiles)) {
|
|
97
97
|
if (latestRulesetName && _.isEqual(files, latestRulesetContent)) {
|
|
98
|
-
utils.
|
|
98
|
+
utils.logLabeledBullet(RulesetType[this.type], `latest version of ${(0, colorette_1.bold)(filename)} already up to date, skipping upload...`);
|
|
99
99
|
this.rulesetNames[filename] = latestRulesetName;
|
|
100
100
|
continue;
|
|
101
101
|
}
|
|
102
102
|
if (previews_1.previews.crossservicerules && service === RulesetServiceType.FIREBASE_STORAGE) {
|
|
103
103
|
await this.checkStorageRulesIamPermissions((_a = files[0]) === null || _a === void 0 ? void 0 : _a.content);
|
|
104
104
|
}
|
|
105
|
-
utils.
|
|
105
|
+
utils.logLabeledBullet(RulesetType[this.type], `uploading rules ${(0, colorette_1.bold)(filename)}...`);
|
|
106
106
|
newRulesetsByFilename.set(filename, gcp.rules.createRuleset(this.options.project, files));
|
|
107
107
|
}
|
|
108
108
|
try {
|
|
@@ -116,8 +116,7 @@ class RulesDeploy {
|
|
|
116
116
|
if (err.status !== QUOTA_EXCEEDED_STATUS_CODE) {
|
|
117
117
|
throw err;
|
|
118
118
|
}
|
|
119
|
-
utils.
|
|
120
|
-
" quota exceeded error while uploading rules");
|
|
119
|
+
utils.logLabeledBullet(RulesetType[this.type], "quota exceeded error while uploading rules");
|
|
121
120
|
const history = await gcp.rules.listAllRulesets(this.options.project);
|
|
122
121
|
if (history.length > RULESET_COUNT_LIMIT) {
|
|
123
122
|
const confirm = await (0, prompt_1.promptOnce)({
|
|
@@ -136,7 +135,7 @@ class RulesDeploy {
|
|
|
136
135
|
await gcp.rules.deleteRuleset(this.options.project, gcp.rules.getRulesetId(entry));
|
|
137
136
|
logger_1.logger.debug(`[rules] Deleted ${entry.name}`);
|
|
138
137
|
}
|
|
139
|
-
utils.
|
|
138
|
+
utils.logLabeledWarning(RulesetType[this.type], "retrying rules upload");
|
|
140
139
|
return this.createRulesets(service);
|
|
141
140
|
}
|
|
142
141
|
}
|
|
@@ -150,10 +149,10 @@ class RulesDeploy {
|
|
|
150
149
|
await gcp.rules.updateOrCreateRelease(this.options.project, this.rulesetNames[filename], resourceName === RulesetServiceType.FIREBASE_STORAGE
|
|
151
150
|
? `${resourceName}/${subResourceName}`
|
|
152
151
|
: resourceName);
|
|
153
|
-
utils.
|
|
152
|
+
utils.logLabeledSuccess(RulesetType[this.type], `released rules ${(0, colorette_1.bold)(filename)} to ${(0, colorette_1.bold)(resourceName)}`);
|
|
154
153
|
}
|
|
155
154
|
async compileRuleset(filename, files) {
|
|
156
|
-
utils.
|
|
155
|
+
utils.logLabeledBullet(this.type, `checking ${(0, colorette_1.bold)(filename)} for compilation errors...`);
|
|
157
156
|
const response = await gcp.rules.testRuleset(this.options.project, files);
|
|
158
157
|
if (_.get(response, "body.issues", []).length) {
|
|
159
158
|
const warnings = [];
|
|
@@ -174,11 +173,11 @@ class RulesDeploy {
|
|
|
174
173
|
}
|
|
175
174
|
if (errors.length > 0) {
|
|
176
175
|
const add = errors.length === 1 ? "" : "s";
|
|
177
|
-
const message = `Compilation error${add} in ${
|
|
176
|
+
const message = `Compilation error${add} in ${(0, colorette_1.bold)(filename)}:\n${errors.join("\n")}`;
|
|
178
177
|
throw new error_1.FirebaseError(message, { exit: 1 });
|
|
179
178
|
}
|
|
180
179
|
}
|
|
181
|
-
utils.
|
|
180
|
+
utils.logLabeledSuccess(this.type, `rules file ${(0, colorette_1.bold)(filename)} compiled successfully`);
|
|
182
181
|
}
|
|
183
182
|
}
|
|
184
183
|
exports.RulesDeploy = RulesDeploy;
|
package/lib/serve/hosting.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.connect = exports.start = exports.stop = void 0;
|
|
4
|
-
const clc = require("
|
|
4
|
+
const clc = require("colorette");
|
|
5
5
|
const superstatic = require("superstatic").server;
|
|
6
6
|
const morgan = require("morgan");
|
|
7
7
|
const detectProjectRoot_1 = require("../detectProjectRoot");
|
|
@@ -60,6 +60,7 @@ function startServer(options, config, port, init) {
|
|
|
60
60
|
port: port,
|
|
61
61
|
host: options.host,
|
|
62
62
|
config: config,
|
|
63
|
+
compression: true,
|
|
63
64
|
cwd: (0, detectProjectRoot_1.detectProjectRoot)(options),
|
|
64
65
|
stack: "strict",
|
|
65
66
|
before: {
|
package/lib/serve/index.js
CHANGED
|
@@ -4,6 +4,9 @@ exports.serve = void 0;
|
|
|
4
4
|
const logger_1 = require("../logger");
|
|
5
5
|
const frameworks_1 = require("../frameworks");
|
|
6
6
|
const previews_1 = require("../previews");
|
|
7
|
+
const track_1 = require("../track");
|
|
8
|
+
const projectUtils_1 = require("../projectUtils");
|
|
9
|
+
const constants_1 = require("../emulator/constants");
|
|
7
10
|
const { FunctionsServer } = require("./functions");
|
|
8
11
|
const TARGETS = {
|
|
9
12
|
hosting: require("./hosting"),
|
|
@@ -17,12 +20,24 @@ async function serve(options) {
|
|
|
17
20
|
[].concat(options.config.get("hosting")).some((it) => it.source)) {
|
|
18
21
|
await (0, frameworks_1.prepareFrameworks)(targetNames, options, options);
|
|
19
22
|
}
|
|
23
|
+
const isDemoProject = constants_1.Constants.isDemoProject((0, projectUtils_1.getProjectId)(options) || "");
|
|
24
|
+
targetNames.forEach((targetName) => {
|
|
25
|
+
void (0, track_1.trackEmulator)("emulator_run", {
|
|
26
|
+
emulator_name: targetName,
|
|
27
|
+
is_demo_project: String(isDemoProject),
|
|
28
|
+
});
|
|
29
|
+
});
|
|
20
30
|
await Promise.all(targetNames.map((targetName) => {
|
|
21
31
|
return TARGETS[targetName].start(options);
|
|
22
32
|
}));
|
|
23
33
|
await Promise.all(targetNames.map((targetName) => {
|
|
24
34
|
return TARGETS[targetName].connect();
|
|
25
35
|
}));
|
|
36
|
+
void (0, track_1.trackEmulator)("emulators_started", {
|
|
37
|
+
count: targetNames.length,
|
|
38
|
+
count_all: targetNames.length,
|
|
39
|
+
is_demo_project: String(isDemoProject),
|
|
40
|
+
});
|
|
26
41
|
await new Promise((resolve) => {
|
|
27
42
|
process.on("SIGINT", () => {
|
|
28
43
|
logger_1.logger.info("Shutting down...");
|
package/lib/track.js
CHANGED
|
@@ -1,16 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.track = void 0;
|
|
3
|
+
exports.emulatorSession = exports.trackEmulator = exports.track = exports.usageEnabled = exports.EMULATOR_GA4_MEASUREMENT_ID = void 0;
|
|
4
|
+
const node_fetch_1 = require("node-fetch");
|
|
4
5
|
const ua = require("universal-analytics");
|
|
5
6
|
const uuid_1 = require("uuid");
|
|
7
|
+
const auth_1 = require("./auth");
|
|
6
8
|
const configstore_1 = require("./configstore");
|
|
9
|
+
const logger_1 = require("./logger");
|
|
7
10
|
const pkg = require("../package.json");
|
|
11
|
+
exports.EMULATOR_GA4_MEASUREMENT_ID = process.env.FIREBASE_EMULATOR_GA4_MEASUREMENT_ID || "G-KYP2JMPFC0";
|
|
12
|
+
function usageEnabled() {
|
|
13
|
+
return !!configstore_1.configstore.get("usage");
|
|
14
|
+
}
|
|
15
|
+
exports.usageEnabled = usageEnabled;
|
|
16
|
+
const FIREBASE_ANALYTICS_UA = process.env.FIREBASE_ANALYTICS_UA || "UA-29174744-3";
|
|
8
17
|
let anonId = configstore_1.configstore.get("analytics-uuid");
|
|
9
18
|
if (!anonId) {
|
|
10
19
|
anonId = (0, uuid_1.v4)();
|
|
11
20
|
configstore_1.configstore.set("analytics-uuid", anonId);
|
|
12
21
|
}
|
|
13
|
-
const visitor = ua(
|
|
22
|
+
const visitor = ua(FIREBASE_ANALYTICS_UA, anonId, {
|
|
14
23
|
strictCidFormat: false,
|
|
15
24
|
https: true,
|
|
16
25
|
});
|
|
@@ -19,7 +28,7 @@ visitor.set("cd2", process.version);
|
|
|
19
28
|
visitor.set("cd3", process.env.FIREPIT_VERSION || "none");
|
|
20
29
|
function track(action, label, duration = 0) {
|
|
21
30
|
return new Promise((resolve) => {
|
|
22
|
-
if (configstore_1.configstore.get("tokens") &&
|
|
31
|
+
if (configstore_1.configstore.get("tokens") && usageEnabled()) {
|
|
23
32
|
visitor.event("Firebase CLI " + pkg.version, action, label, duration).send(() => {
|
|
24
33
|
resolve();
|
|
25
34
|
});
|
|
@@ -30,3 +39,113 @@ function track(action, label, duration = 0) {
|
|
|
30
39
|
});
|
|
31
40
|
}
|
|
32
41
|
exports.track = track;
|
|
42
|
+
const EMULATOR_GA4_API_SECRET = process.env.FIREBASE_EMULATOR_GA4_API_SECRET || "2V_zBYc4TdeoppzDaIu0zw";
|
|
43
|
+
const EMULATOR_GA4_USER_PROPS = {
|
|
44
|
+
node_platform: {
|
|
45
|
+
value: process.platform,
|
|
46
|
+
},
|
|
47
|
+
node_version: {
|
|
48
|
+
value: process.version,
|
|
49
|
+
},
|
|
50
|
+
firebase_tools_version: {
|
|
51
|
+
value: pkg.version,
|
|
52
|
+
},
|
|
53
|
+
firepit_version: {
|
|
54
|
+
value: process.env.FIREPIT_VERSION || "none",
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
async function trackEmulator(eventName, params) {
|
|
58
|
+
const session = emulatorSession();
|
|
59
|
+
if (!session) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
const oldTotalEngagementSeconds = session.totalEngagementSeconds;
|
|
63
|
+
session.totalEngagementSeconds = process.uptime();
|
|
64
|
+
session.commandName = (params === null || params === void 0 ? void 0 : params.command_name) || session.commandName;
|
|
65
|
+
const search = `?api_secret=${EMULATOR_GA4_API_SECRET}&measurement_id=${session.measurementId}`;
|
|
66
|
+
const validate = session.validateOnly ? "debug/" : "";
|
|
67
|
+
const url = `https://www.google-analytics.com/${validate}mp/collect${search}`;
|
|
68
|
+
const body = {
|
|
69
|
+
timestamp_micros: `${Date.now()}000`,
|
|
70
|
+
client_id: session.clientId,
|
|
71
|
+
user_properties: Object.assign(Object.assign({}, EMULATOR_GA4_USER_PROPS), { java_major_version: session.javaMajorVersion
|
|
72
|
+
? { value: session.javaMajorVersion }
|
|
73
|
+
: undefined }),
|
|
74
|
+
validationBehavior: session.validateOnly ? "ENFORCE_RECOMMENDATIONS" : undefined,
|
|
75
|
+
events: [
|
|
76
|
+
{
|
|
77
|
+
name: eventName,
|
|
78
|
+
params: Object.assign({ session_id: session.sessionId, engagement_time_msec: (session.totalEngagementSeconds - oldTotalEngagementSeconds)
|
|
79
|
+
.toFixed(3)
|
|
80
|
+
.replace(".", "")
|
|
81
|
+
.replace(/^0+/, ""), debug_mode: session.debugMode ? true : undefined, command_name: session.commandName }, params),
|
|
82
|
+
},
|
|
83
|
+
],
|
|
84
|
+
};
|
|
85
|
+
if (session.validateOnly) {
|
|
86
|
+
logger_1.logger.info(`Sending Analytics for event ${eventName}`, params, body);
|
|
87
|
+
}
|
|
88
|
+
try {
|
|
89
|
+
const response = await (0, node_fetch_1.default)(url, {
|
|
90
|
+
method: "POST",
|
|
91
|
+
headers: {
|
|
92
|
+
"content-type": "application/json;charset=UTF-8",
|
|
93
|
+
},
|
|
94
|
+
body: JSON.stringify(body),
|
|
95
|
+
});
|
|
96
|
+
if (session.validateOnly) {
|
|
97
|
+
if (!response.ok) {
|
|
98
|
+
logger_1.logger.warn(`Analytics validation HTTP error: ${response.status}`);
|
|
99
|
+
}
|
|
100
|
+
const respBody = await response.text();
|
|
101
|
+
logger_1.logger.info(`Analytics validation result: ${respBody}`);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
catch (e) {
|
|
105
|
+
if (session.validateOnly) {
|
|
106
|
+
throw e;
|
|
107
|
+
}
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
exports.trackEmulator = trackEmulator;
|
|
112
|
+
function emulatorSession() {
|
|
113
|
+
const validateOnly = !!process.env.FIREBASE_CLI_MP_VALIDATE;
|
|
114
|
+
if (!usageEnabled()) {
|
|
115
|
+
if (validateOnly) {
|
|
116
|
+
logger_1.logger.warn("Google Analytics is DISABLED. To enable, (re)login and opt in to collection.");
|
|
117
|
+
}
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
if (!currentEmulatorSession) {
|
|
121
|
+
let clientId = configstore_1.configstore.get("emulator-analytics-clientId");
|
|
122
|
+
if (!clientId) {
|
|
123
|
+
clientId = (0, uuid_1.v4)();
|
|
124
|
+
configstore_1.configstore.set("emulator-analytics-clientId", clientId);
|
|
125
|
+
}
|
|
126
|
+
currentEmulatorSession = {
|
|
127
|
+
measurementId: exports.EMULATOR_GA4_MEASUREMENT_ID,
|
|
128
|
+
clientId,
|
|
129
|
+
sessionId: (Math.random() * Number.MAX_SAFE_INTEGER).toFixed(0),
|
|
130
|
+
totalEngagementSeconds: 0,
|
|
131
|
+
debugMode: isDebugMode(),
|
|
132
|
+
validateOnly,
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
return currentEmulatorSession;
|
|
136
|
+
}
|
|
137
|
+
exports.emulatorSession = emulatorSession;
|
|
138
|
+
let currentEmulatorSession = undefined;
|
|
139
|
+
function isDebugMode() {
|
|
140
|
+
const account = (0, auth_1.getGlobalDefaultAccount)();
|
|
141
|
+
if (account === null || account === void 0 ? void 0 : account.user.email.endsWith("@google.com")) {
|
|
142
|
+
try {
|
|
143
|
+
require("../tsconfig.json");
|
|
144
|
+
logger_1.logger.info(`Using Google Analytics in DEBUG mode. Emulators (+ UI) events will be shown in GA Debug View only.`);
|
|
145
|
+
return true;
|
|
146
|
+
}
|
|
147
|
+
catch (_a) {
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return false;
|
|
151
|
+
}
|
package/lib/utils.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.randomInt = exports.debounce = exports.last = exports.cloneDeep = exports.groupBy = exports.assertIsStringOrUndefined = exports.assertIsNumber = exports.assertIsString = exports.assertDefined = exports.thirtyDaysFromNow = exports.isRunningInWSL = exports.isCloudEnvironment = exports.datetimeString = exports.createDestroyer = exports.promiseWithSpinner = exports.setupLoggers = exports.tryParse = exports.tryStringify = exports.promiseProps = exports.promiseWhile = exports.promiseAllSettled = exports.getFunctionsEventProvider = exports.endpoint = exports.makeActiveProject = exports.streamToString = exports.stringToStream = exports.explainStdin = exports.allSettled = exports.reject = exports.logLabeledError = exports.logLabeledWarning = exports.logWarning = exports.logLabeledBullet = exports.logBullet = exports.logLabeledSuccess = exports.logSuccess = exports.addSubdomain = exports.addDatabaseNamespace = exports.getDatabaseViewDataUrl = exports.getDatabaseUrl = exports.envOverride = exports.getInheritedOption = exports.consoleUrl = exports.envOverrides = void 0;
|
|
3
|
+
exports.randomInt = exports.debounce = exports.last = exports.cloneDeep = exports.groupBy = exports.assertIsStringOrUndefined = exports.assertIsNumber = exports.assertIsString = exports.assertDefined = exports.thirtyDaysFromNow = exports.isRunningInWSL = exports.isCloudEnvironment = exports.datetimeString = exports.createDestroyer = exports.promiseWithSpinner = exports.setupLoggers = exports.tryParse = exports.tryStringify = exports.promiseProps = exports.withTimeout = exports.promiseWhile = exports.promiseAllSettled = exports.getFunctionsEventProvider = exports.endpoint = exports.makeActiveProject = exports.streamToString = exports.stringToStream = exports.explainStdin = exports.allSettled = exports.reject = exports.logLabeledError = exports.logLabeledWarning = exports.logWarning = exports.logLabeledBullet = exports.logBullet = exports.logLabeledSuccess = exports.logSuccess = exports.addSubdomain = exports.addDatabaseNamespace = exports.getDatabaseViewDataUrl = exports.getDatabaseUrl = exports.envOverride = exports.getInheritedOption = exports.consoleUrl = exports.envOverrides = void 0;
|
|
4
4
|
const _ = require("lodash");
|
|
5
5
|
const url = require("url");
|
|
6
|
-
const clc = require("
|
|
6
|
+
const clc = require("colorette");
|
|
7
7
|
const ora = require("ora");
|
|
8
8
|
const process = require("process");
|
|
9
9
|
const stream_1 = require("stream");
|
|
10
10
|
const winston = require("winston");
|
|
11
11
|
const triple_beam_1 = require("triple-beam");
|
|
12
12
|
const assert_1 = require("assert");
|
|
13
|
-
const
|
|
13
|
+
const stripAnsi = require("strip-ansi");
|
|
14
14
|
const configstore_1 = require("./configstore");
|
|
15
15
|
const error_1 = require("./error");
|
|
16
16
|
const logger_1 = require("./logger");
|
|
@@ -82,31 +82,31 @@ function addSubdomain(origin, subdomain) {
|
|
|
82
82
|
}
|
|
83
83
|
exports.addSubdomain = addSubdomain;
|
|
84
84
|
function logSuccess(message, type = "info", data = undefined) {
|
|
85
|
-
logger_1.logger[type](clc.green.bold(`${SUCCESS_CHAR} `), message, data);
|
|
85
|
+
logger_1.logger[type](clc.green(clc.bold(`${SUCCESS_CHAR} `)), message, data);
|
|
86
86
|
}
|
|
87
87
|
exports.logSuccess = logSuccess;
|
|
88
88
|
function logLabeledSuccess(label, message, type = "info", data = undefined) {
|
|
89
|
-
logger_1.logger[type](clc.green.bold(`${SUCCESS_CHAR} ${label}:`), message, data);
|
|
89
|
+
logger_1.logger[type](clc.green(clc.bold(`${SUCCESS_CHAR} ${label}:`)), message, data);
|
|
90
90
|
}
|
|
91
91
|
exports.logLabeledSuccess = logLabeledSuccess;
|
|
92
92
|
function logBullet(message, type = "info", data = undefined) {
|
|
93
|
-
logger_1.logger[type](clc.cyan.bold("i "), message, data);
|
|
93
|
+
logger_1.logger[type](clc.cyan(clc.bold("i ")), message, data);
|
|
94
94
|
}
|
|
95
95
|
exports.logBullet = logBullet;
|
|
96
96
|
function logLabeledBullet(label, message, type = "info", data = undefined) {
|
|
97
|
-
logger_1.logger[type](clc.cyan.bold(`i ${label}:`), message, data);
|
|
97
|
+
logger_1.logger[type](clc.cyan(clc.bold(`i ${label}:`)), message, data);
|
|
98
98
|
}
|
|
99
99
|
exports.logLabeledBullet = logLabeledBullet;
|
|
100
100
|
function logWarning(message, type = "warn", data = undefined) {
|
|
101
|
-
logger_1.logger[type](clc.yellow.bold(`${WARNING_CHAR} `), message, data);
|
|
101
|
+
logger_1.logger[type](clc.yellow(clc.bold(`${WARNING_CHAR} `)), message, data);
|
|
102
102
|
}
|
|
103
103
|
exports.logWarning = logWarning;
|
|
104
104
|
function logLabeledWarning(label, message, type = "warn", data = undefined) {
|
|
105
|
-
logger_1.logger[type](clc.yellow.bold(`${WARNING_CHAR} ${label}:`), message, data);
|
|
105
|
+
logger_1.logger[type](clc.yellow(clc.bold(`${WARNING_CHAR} ${label}:`)), message, data);
|
|
106
106
|
}
|
|
107
107
|
exports.logLabeledWarning = logLabeledWarning;
|
|
108
108
|
function logLabeledError(label, message, type = "error", data = undefined) {
|
|
109
|
-
logger_1.logger[type](clc.red.bold(`${ERROR_CHAR} ${label}:`), message, data);
|
|
109
|
+
logger_1.logger[type](clc.red(clc.bold(`${ERROR_CHAR} ${label}:`)), message, data);
|
|
110
110
|
}
|
|
111
111
|
exports.logLabeledError = logLabeledError;
|
|
112
112
|
function reject(message, options) {
|
|
@@ -248,6 +248,19 @@ async function promiseWhile(action, check, interval = 2500) {
|
|
|
248
248
|
});
|
|
249
249
|
}
|
|
250
250
|
exports.promiseWhile = promiseWhile;
|
|
251
|
+
function withTimeout(timeoutMs, promise) {
|
|
252
|
+
return new Promise((resolve, reject) => {
|
|
253
|
+
const timeout = setTimeout(() => reject(new Error("Timed out.")), timeoutMs);
|
|
254
|
+
promise.then((value) => {
|
|
255
|
+
clearTimeout(timeout);
|
|
256
|
+
resolve(value);
|
|
257
|
+
}, (err) => {
|
|
258
|
+
clearTimeout(timeout);
|
|
259
|
+
reject(err);
|
|
260
|
+
});
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
exports.withTimeout = withTimeout;
|
|
251
264
|
async function promiseProps(obj) {
|
|
252
265
|
const resultObj = {};
|
|
253
266
|
const promises = Object.keys(obj).map(async (key) => {
|
|
@@ -287,7 +300,7 @@ function setupLoggers() {
|
|
|
287
300
|
level: "debug",
|
|
288
301
|
format: winston.format.printf((info) => {
|
|
289
302
|
const segments = [info.message, ...(info[triple_beam_1.SPLAT] || [])].map(tryStringify);
|
|
290
|
-
return `${
|
|
303
|
+
return `${stripAnsi(segments.join(" "))}`;
|
|
291
304
|
}),
|
|
292
305
|
}));
|
|
293
306
|
}
|