firebase-tools 10.0.0 → 10.1.2
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 +2 -2
- package/lib/appdistribution/client.js +1 -1
- package/lib/appdistribution/options-parser-util.js +1 -1
- 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 +145 -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/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 +6 -4
- 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 +27 -21
- package/lib/deploy/functions/prompts.js +5 -5
- package/lib/deploy/functions/release/executor.js +4 -1
- package/lib/deploy/functions/release/fabricator.js +5 -5
- 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 +4 -3
- package/lib/deploy/hosting/deploy.js +7 -7
- 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 +10 -9
- package/lib/emulator/emulatorLogger.js +1 -1
- package/lib/emulator/functionsEmulator.js +107 -74
- 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 +69 -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/cloudmonitoring.js +74 -0
- package/lib/gcp/cloudscheduler.js +1 -1
- package/lib/gcp/iam.js +2 -2
- package/lib/gcp/resourceManager.js +2 -2
- package/lib/gcp/rules.js +18 -41
- package/lib/gcp/secretManager.js +3 -2
- 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 +24095 -0
- package/package.json +33 -30
- package/templates/init/hosting/index.html +1 -1
- package/CHANGELOG.md +0 -5
- package/lib/commands/functions-config-legacy.js +0 -45
- package/lib/prepareFirebaseRules.js +0 -58
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()
|