firebase-tools 11.0.0 → 11.2.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/accountExporter.js +11 -4
- package/lib/accountImporter.js +93 -95
- package/lib/api.js +77 -218
- package/lib/apiv2.js +5 -4
- package/lib/appdistribution/client.js +23 -34
- package/lib/auth.js +72 -52
- package/lib/bin/firebase.js +42 -47
- package/lib/checkValidTargetFilters.js +36 -25
- package/lib/commands/appdistribution-distribute.js +2 -1
- package/lib/commands/appdistribution-testers-add.js +2 -1
- package/lib/commands/appdistribution-testers-remove.js +2 -1
- package/lib/commands/apps-android-sha-create.js +2 -1
- package/lib/commands/apps-android-sha-delete.js +2 -1
- package/lib/commands/apps-android-sha-list.js +2 -1
- package/lib/commands/apps-create.js +2 -1
- package/lib/commands/apps-list.js +2 -1
- package/lib/commands/apps-sdkconfig.js +2 -1
- package/lib/commands/auth-export.js +2 -1
- package/lib/commands/auth-import.js +7 -10
- package/lib/commands/crashlytics-symbols-upload.js +2 -1
- package/lib/commands/database-get.js +4 -3
- package/lib/commands/database-instances-create.js +2 -1
- package/lib/commands/database-instances-list.js +3 -3
- package/lib/commands/database-profile.js +4 -4
- package/lib/commands/database-push.js +4 -4
- package/lib/commands/database-remove.js +3 -3
- package/lib/commands/database-rules-canary.js +2 -1
- package/lib/commands/database-rules-get.js +2 -1
- package/lib/commands/database-rules-list.js +2 -1
- package/lib/commands/database-rules-release.js +2 -1
- package/lib/commands/database-rules-stage.js +2 -1
- package/lib/commands/database-set.js +3 -3
- package/lib/commands/database-settings-get.js +2 -1
- package/lib/commands/database-settings-set.js +2 -1
- package/lib/commands/database-update.js +2 -1
- package/lib/commands/deploy.js +26 -25
- package/lib/commands/emulators-exec.js +2 -1
- package/lib/commands/emulators-export.js +2 -1
- package/lib/commands/emulators-start.js +2 -1
- package/lib/commands/experimental-functions-shell.js +10 -8
- package/lib/commands/ext-configure.js +6 -1
- package/lib/commands/ext-dev-deprecate.js +2 -1
- package/lib/commands/ext-dev-emulators-exec.js +3 -2
- package/lib/commands/ext-dev-emulators-start.js +3 -2
- package/lib/commands/ext-dev-extension-delete.js +2 -1
- package/lib/commands/ext-dev-init.js +2 -1
- package/lib/commands/ext-dev-list.js +8 -8
- package/lib/commands/ext-dev-publish.js +2 -1
- package/lib/commands/ext-dev-register.js +2 -1
- package/lib/commands/ext-dev-undeprecate.js +2 -1
- package/lib/commands/ext-dev-unpublish.js +2 -1
- package/lib/commands/ext-dev-usage.js +2 -1
- package/lib/commands/ext-export.js +2 -1
- package/lib/commands/ext-info.js +14 -14
- package/lib/commands/ext-install.js +6 -1
- package/lib/commands/ext-list.js +2 -1
- package/lib/commands/ext-sources-create.js +2 -1
- package/lib/commands/ext-uninstall.js +7 -1
- package/lib/commands/ext-update.js +6 -1
- package/lib/commands/ext.js +4 -4
- package/lib/commands/firestore-delete.js +2 -1
- package/lib/commands/firestore-indexes-list.js +2 -1
- package/lib/commands/functions-config-clone.js +4 -3
- package/lib/commands/functions-config-export.js +2 -1
- package/lib/commands/functions-config-get.js +2 -1
- package/lib/commands/functions-config-set.js +2 -1
- package/lib/commands/functions-config-unset.js +2 -1
- package/lib/commands/functions-delete.js +3 -8
- package/lib/commands/functions-deletegcfartifacts.js +2 -1
- package/lib/commands/functions-list.js +2 -1
- package/lib/commands/functions-log.js +2 -1
- package/lib/commands/functions-secrets-access.js +2 -1
- package/lib/commands/functions-secrets-destroy.js +2 -1
- package/lib/commands/functions-secrets-get.js +2 -1
- package/lib/commands/functions-secrets-prune.js +2 -1
- package/lib/commands/functions-secrets-set.js +2 -1
- package/lib/commands/functions-shell.js +12 -10
- package/lib/commands/help.js +2 -1
- package/lib/commands/hosting-channel-create.js +2 -1
- package/lib/commands/hosting-channel-delete.js +2 -1
- package/lib/commands/hosting-channel-deploy.js +2 -1
- package/lib/commands/hosting-channel-list.js +2 -1
- package/lib/commands/hosting-channel-open.js +2 -1
- package/lib/commands/hosting-clone.js +2 -1
- package/lib/commands/hosting-disable.js +2 -1
- package/lib/commands/hosting-sites-create.js +2 -1
- package/lib/commands/hosting-sites-delete.js +2 -1
- package/lib/commands/hosting-sites-get.js +2 -1
- package/lib/commands/hosting-sites-list.js +2 -1
- package/lib/commands/index.js +23 -13
- package/lib/commands/init.js +47 -43
- package/lib/commands/login-add.js +2 -1
- package/lib/commands/login-ci.js +2 -1
- package/lib/commands/login-list.js +2 -1
- package/lib/commands/login-use.js +2 -1
- package/lib/commands/login.js +2 -1
- package/lib/commands/logout.js +2 -1
- package/lib/commands/open.js +7 -7
- package/lib/commands/projects-addfirebase.js +2 -1
- package/lib/commands/projects-create.js +2 -1
- package/lib/commands/projects-list.js +2 -1
- package/lib/commands/remoteconfig-get.js +2 -1
- package/lib/commands/remoteconfig-rollback.js +2 -1
- package/lib/commands/remoteconfig-versions-list.js +2 -1
- package/lib/commands/serve.js +30 -30
- package/lib/commands/setup-emulators-database.js +2 -1
- package/lib/commands/setup-emulators-firestore.js +2 -1
- package/lib/commands/setup-emulators-pubsub.js +2 -1
- package/lib/commands/setup-emulators-storage.js +2 -1
- package/lib/commands/setup-emulators-ui.js +2 -1
- package/lib/commands/target-apply.js +2 -1
- package/lib/commands/target-clear.js +2 -1
- package/lib/commands/target-remove.js +2 -1
- package/lib/commands/target.js +2 -1
- package/lib/commands/use.js +54 -53
- package/lib/config.js +7 -6
- package/lib/deploy/database/deploy.js +3 -2
- package/lib/deploy/database/index.js +8 -5
- package/lib/deploy/database/prepare.js +22 -20
- package/lib/deploy/database/release.js +12 -9
- package/lib/deploy/extensions/secrets.js +3 -3
- package/lib/deploy/firestore/prepare.js +2 -2
- package/lib/deploy/functions/build.js +33 -20
- package/lib/deploy/functions/ensure.js +1 -11
- package/lib/deploy/functions/prepare.js +3 -13
- package/lib/deploy/functions/prepareFunctionsUpload.js +2 -3
- package/lib/deploy/functions/release/fabricator.js +0 -1
- package/lib/deploy/functions/release/index.js +1 -5
- package/lib/deploy/functions/runtimes/discovery/index.js +18 -3
- package/lib/deploy/functions/runtimes/discovery/v1alpha1.js +188 -54
- package/lib/deploy/functions/runtimes/golang/index.js +2 -22
- package/lib/deploy/functions/runtimes/node/index.js +3 -7
- package/lib/deploy/functions/runtimes/node/parseTriggers.js +15 -3
- package/lib/deploy/functions/services/database.js +14 -0
- package/lib/deploy/functions/services/index.js +14 -0
- package/lib/deploy/index.js +3 -3
- package/lib/deploy/lifecycleHooks.js +27 -27
- package/lib/deploy/remoteconfig/functions.js +18 -14
- package/lib/deploy/remoteconfig/prepare.js +2 -2
- package/lib/deploy/storage/prepare.js +1 -1
- package/lib/emulator/auth/apiSpec.js +14 -46
- package/lib/emulator/auth/index.js +1 -1
- package/lib/emulator/auth/operations.js +342 -93
- package/lib/emulator/auth/server.js +2 -2
- package/lib/emulator/auth/state.js +34 -32
- package/lib/emulator/commandUtils.js +1 -1
- package/lib/emulator/constants.js +1 -1
- package/lib/emulator/controller.js +7 -6
- package/lib/emulator/databaseEmulator.js +11 -9
- package/lib/emulator/download.js +1 -1
- package/lib/emulator/events/types.js +2 -3
- package/lib/emulator/firestoreEmulator.js +12 -14
- package/lib/emulator/functionsEmulator.js +65 -77
- package/lib/emulator/functionsEmulatorRuntime.js +7 -7
- package/lib/emulator/hostingEmulator.js +1 -1
- package/lib/emulator/hub.js +1 -1
- package/lib/emulator/hubClient.js +11 -22
- package/lib/emulator/hubExport.js +26 -16
- package/lib/emulator/loggingEmulator.js +1 -1
- package/lib/emulator/pubsubEmulator.js +1 -1
- package/lib/emulator/storage/crc.js +4 -4
- package/lib/emulator/storage/index.js +1 -1
- package/lib/emulator/types.js +1 -1
- package/lib/errorOut.js +2 -2
- package/lib/extensions/askUserForConsent.js +1 -2
- package/lib/extensions/askUserForParam.js +15 -18
- package/lib/extensions/emulator/optionsHelper.js +4 -4
- package/lib/extensions/extensionsApi.js +1 -22
- package/lib/extensions/extensionsHelper.js +6 -6
- package/lib/extensions/listExtensions.js +9 -10
- package/lib/extensions/manifest.js +2 -2
- package/lib/extensions/resolveSource.js +11 -7
- package/lib/extensions/secretsUtils.js +3 -3
- package/lib/extensions/types.js +24 -0
- package/lib/extensions/updateHelper.js +1 -1
- package/lib/extensions/utils.js +1 -2
- package/lib/extensions/warnings.js +3 -3
- package/lib/firestore/checkDatabaseType.js +4 -5
- package/lib/firestore/encodeFirestoreValue.js +11 -8
- package/lib/firestore/indexes.js +17 -34
- package/lib/fsAsync.js +3 -3
- package/lib/functions/events/v2.js +7 -1
- package/lib/functionsConfig.js +17 -14
- package/lib/functionsConfigClone.js +46 -46
- package/lib/gcp/cloudfunctions.js +2 -15
- package/lib/gcp/cloudfunctionsv2.js +17 -2
- package/lib/gcp/iam.js +1 -1
- package/lib/gcp/index.js +10 -10
- package/lib/gcp/rules.js +1 -1
- package/lib/gcp/runtimeconfig.js +45 -47
- package/lib/gcp/storage.js +2 -4
- package/lib/hosting/cloudRunProxy.js +19 -15
- package/lib/hosting/proxy.js +1 -1
- package/lib/index.js +29 -28
- package/lib/init/features/database.js +11 -5
- package/lib/init/features/functions/index.js +1 -1
- package/lib/init/features/functions/javascript.js +23 -20
- package/lib/init/features/functions/npm-dependencies.js +17 -14
- package/lib/init/features/functions/typescript.js +27 -24
- package/lib/init/features/hosting/github.js +6 -5
- package/lib/init/features/hosting/index.js +2 -2
- package/lib/loadCJSON.js +9 -6
- package/lib/localFunction.js +4 -4
- package/lib/logError.js +15 -12
- package/lib/management/apps.js +47 -43
- package/lib/management/database.js +33 -31
- package/lib/management/projects.js +13 -7
- package/lib/parseBoltRules.js +15 -14
- package/lib/previews.js +1 -1
- package/lib/profileReport.js +504 -512
- package/lib/profiler.js +4 -4
- package/lib/prompt.js +1 -2
- package/lib/rc.js +1 -1
- package/lib/requireAuth.js +0 -1
- package/lib/responseToError.js +8 -5
- package/lib/rtdb.js +31 -29
- package/lib/rulesDeploy.js +2 -2
- package/lib/scopes.js +9 -9
- package/lib/serve/index.js +4 -5
- package/lib/utils.js +30 -6
- package/npm-shrinkwrap.json +877 -279
- package/package.json +19 -16
- package/standalone/package.json +1 -1
package/lib/profiler.js
CHANGED
|
@@ -9,8 +9,8 @@ const abort_controller_1 = require("abort-controller");
|
|
|
9
9
|
const apiv2_1 = require("./apiv2");
|
|
10
10
|
const api_1 = require("./database/api");
|
|
11
11
|
const logger_1 = require("./logger");
|
|
12
|
-
const
|
|
13
|
-
const
|
|
12
|
+
const profileReport_1 = require("./profileReport");
|
|
13
|
+
const responseToError_1 = require("./responseToError");
|
|
14
14
|
const utils = require("./utils");
|
|
15
15
|
tmp.setGracefulCleanup();
|
|
16
16
|
async function profiler(options) {
|
|
@@ -38,7 +38,7 @@ async function profiler(options) {
|
|
|
38
38
|
isInput: !!options.input,
|
|
39
39
|
collapse: options.collapse,
|
|
40
40
|
};
|
|
41
|
-
const report = new ProfileReport(dataFile, outStream, reportOptions);
|
|
41
|
+
const report = new profileReport_1.ProfileReport(dataFile, outStream, reportOptions);
|
|
42
42
|
return report.generate();
|
|
43
43
|
};
|
|
44
44
|
if (options.input) {
|
|
@@ -56,7 +56,7 @@ async function profiler(options) {
|
|
|
56
56
|
signal: controller.signal,
|
|
57
57
|
});
|
|
58
58
|
if (res.response.status >= 400) {
|
|
59
|
-
throw responseToError(res.response, await res.response.text());
|
|
59
|
+
throw (0, responseToError_1.responseToError)(res.response, await res.response.text());
|
|
60
60
|
}
|
|
61
61
|
if (!options.duration) {
|
|
62
62
|
spinner.start();
|
package/lib/prompt.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.promptOnce = exports.prompt = void 0;
|
|
4
4
|
const inquirer = require("inquirer");
|
|
5
|
-
const _ = require("lodash");
|
|
6
5
|
const error_1 = require("./error");
|
|
7
6
|
async function prompt(options, questions) {
|
|
8
7
|
const prompts = [];
|
|
@@ -12,7 +11,7 @@ async function prompt(options, questions) {
|
|
|
12
11
|
}
|
|
13
12
|
}
|
|
14
13
|
if (prompts.length && options.nonInteractive) {
|
|
15
|
-
const missingOptions =
|
|
14
|
+
const missingOptions = Array.from(new Set(prompts.map((p) => p.name))).join(", ");
|
|
16
15
|
throw new error_1.FirebaseError(`Missing required options (${missingOptions}) while running in non-interactive mode`, {
|
|
17
16
|
children: prompts,
|
|
18
17
|
});
|
package/lib/rc.js
CHANGED
|
@@ -93,7 +93,7 @@ class RC {
|
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
const existing = this.target(project, type, targetName);
|
|
96
|
-
const list =
|
|
96
|
+
const list = Array.from(new Set(existing.concat(resources))).sort();
|
|
97
97
|
this.set(["targets", project, type, targetName], list);
|
|
98
98
|
this.save();
|
|
99
99
|
return changed;
|
package/lib/requireAuth.js
CHANGED
|
@@ -22,7 +22,6 @@ function getAuthClient(config) {
|
|
|
22
22
|
async function autoAuth(options, authScopes) {
|
|
23
23
|
const client = getAuthClient({ scopes: authScopes, projectId: options.project });
|
|
24
24
|
const token = await client.getAccessToken();
|
|
25
|
-
api.setAccessToken(token);
|
|
26
25
|
token !== null ? apiv2.setAccessToken(token) : false;
|
|
27
26
|
}
|
|
28
27
|
async function requireAuth(options) {
|
package/lib/responseToError.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.responseToError = void 0;
|
|
2
4
|
const _ = require("lodash");
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
+
const error_1 = require("./error");
|
|
6
|
+
function responseToError(response, body) {
|
|
5
7
|
if (response.statusCode < 400) {
|
|
6
|
-
return
|
|
8
|
+
return;
|
|
7
9
|
}
|
|
8
10
|
if (typeof body === "string") {
|
|
9
11
|
if (response.statusCode === 404) {
|
|
@@ -44,7 +46,7 @@ module.exports = function (response, body) {
|
|
|
44
46
|
exitCode = 1;
|
|
45
47
|
}
|
|
46
48
|
_.unset(response, "request.headers");
|
|
47
|
-
return new FirebaseError(message, {
|
|
49
|
+
return new error_1.FirebaseError(message, {
|
|
48
50
|
context: {
|
|
49
51
|
body: body,
|
|
50
52
|
response: response,
|
|
@@ -52,4 +54,5 @@ module.exports = function (response, body) {
|
|
|
52
54
|
exit: exitCode,
|
|
53
55
|
status: response.statusCode,
|
|
54
56
|
});
|
|
55
|
-
}
|
|
57
|
+
}
|
|
58
|
+
exports.responseToError = responseToError;
|
package/lib/rtdb.js
CHANGED
|
@@ -1,33 +1,35 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.updateRules = void 0;
|
|
4
|
+
const apiv2_1 = require("./apiv2");
|
|
5
|
+
const database_1 = require("./management/database");
|
|
6
|
+
const error_1 = require("./error");
|
|
7
|
+
const api_1 = require("./database/api");
|
|
8
|
+
const utils = require("./utils");
|
|
9
|
+
async function updateRules(projectId, instance, src, options = {}) {
|
|
10
|
+
const queryParams = {};
|
|
10
11
|
if (options.dryRun) {
|
|
11
|
-
|
|
12
|
+
queryParams.dryRun = "true";
|
|
12
13
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
if (response.status === 400) {
|
|
27
|
-
throw new FirebaseError("Syntax error in database rules:\n\n" + JSON.parse(response.body).error);
|
|
28
|
-
}
|
|
29
|
-
else if (response.status > 400) {
|
|
30
|
-
throw new FirebaseError("Unexpected error while deploying database rules.", { exit: 2 });
|
|
31
|
-
}
|
|
14
|
+
const downstreamOptions = { instance: instance, project: projectId };
|
|
15
|
+
await (0, database_1.populateInstanceDetails)(downstreamOptions);
|
|
16
|
+
if (!downstreamOptions.instanceDetails) {
|
|
17
|
+
throw new error_1.FirebaseError(`Could not get instance details`, { exit: 2 });
|
|
18
|
+
}
|
|
19
|
+
const origin = utils.getDatabaseUrl((0, api_1.realtimeOriginOrCustomUrl)(downstreamOptions.instanceDetails.databaseUrl), instance, "");
|
|
20
|
+
const client = new apiv2_1.Client({ urlPrefix: origin });
|
|
21
|
+
const response = await client.request({
|
|
22
|
+
method: "PUT",
|
|
23
|
+
path: ".settings/rules.json",
|
|
24
|
+
queryParams,
|
|
25
|
+
body: src,
|
|
26
|
+
resolveOnHTTPError: true,
|
|
32
27
|
});
|
|
33
|
-
|
|
28
|
+
if (response.status === 400) {
|
|
29
|
+
throw new error_1.FirebaseError(`Syntax error in database rules:\n\n${response.body.error}`);
|
|
30
|
+
}
|
|
31
|
+
else if (response.status > 400) {
|
|
32
|
+
throw new error_1.FirebaseError("Unexpected error while deploying database rules.", { exit: 2 });
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
exports.updateRules = updateRules;
|
package/lib/rulesDeploy.js
CHANGED
|
@@ -91,8 +91,8 @@ class RulesDeploy {
|
|
|
91
91
|
}, this.options);
|
|
92
92
|
if (confirm) {
|
|
93
93
|
const releases = await gcp.rules.listAllReleases(this.options.project);
|
|
94
|
-
const unreleased =
|
|
95
|
-
return
|
|
94
|
+
const unreleased = history.filter((ruleset) => {
|
|
95
|
+
return !releases.find((release) => release.rulesetName === ruleset.name);
|
|
96
96
|
});
|
|
97
97
|
const entriesToDelete = unreleased.reverse().slice(0, RULESETS_TO_GC);
|
|
98
98
|
for (const entry of entriesToDelete) {
|
package/lib/scopes.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CLOUD_PUBSUB = exports.CLOUD_STORAGE = exports.CLOUD_PLATFORM = exports.FIREBASE_PLATFORM = exports.CLOUD_PROJECTS_READONLY = exports.EMAIL = exports.OPENID = void 0;
|
|
4
|
+
exports.OPENID = "openid";
|
|
5
|
+
exports.EMAIL = "email";
|
|
6
|
+
exports.CLOUD_PROJECTS_READONLY = "https://www.googleapis.com/auth/cloudplatformprojects.readonly";
|
|
7
|
+
exports.FIREBASE_PLATFORM = "https://www.googleapis.com/auth/firebase";
|
|
8
|
+
exports.CLOUD_PLATFORM = "https://www.googleapis.com/auth/cloud-platform";
|
|
9
|
+
exports.CLOUD_STORAGE = "https://www.googleapis.com/auth/devstorage.read_write";
|
|
10
|
+
exports.CLOUD_PUBSUB = "https://www.googleapis.com/auth/pubsub";
|
package/lib/serve/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.serve = void 0;
|
|
4
|
-
const _ = require("lodash");
|
|
5
4
|
const logger_1 = require("../logger");
|
|
6
5
|
const frameworks_1 = require("../frameworks");
|
|
7
6
|
const previews_1 = require("../previews");
|
|
@@ -11,23 +10,23 @@ const TARGETS = {
|
|
|
11
10
|
functions: new FunctionsServer(),
|
|
12
11
|
};
|
|
13
12
|
async function serve(options) {
|
|
14
|
-
const targetNames = options.targets;
|
|
13
|
+
const targetNames = options.targets || [];
|
|
15
14
|
options.port = parseInt(options.port, 10);
|
|
16
15
|
if (previews_1.previews.frameworkawareness &&
|
|
17
16
|
targetNames.includes("hosting") &&
|
|
18
17
|
[].concat(options.config.get("hosting")).some((it) => it.source)) {
|
|
19
18
|
await (0, frameworks_1.prepareFrameworks)(targetNames, options, options);
|
|
20
19
|
}
|
|
21
|
-
await Promise.all(
|
|
20
|
+
await Promise.all(targetNames.map((targetName) => {
|
|
22
21
|
return TARGETS[targetName].start(options);
|
|
23
22
|
}));
|
|
24
|
-
await Promise.all(
|
|
23
|
+
await Promise.all(targetNames.map((targetName) => {
|
|
25
24
|
return TARGETS[targetName].connect();
|
|
26
25
|
}));
|
|
27
26
|
await new Promise((resolve) => {
|
|
28
27
|
process.on("SIGINT", () => {
|
|
29
28
|
logger_1.logger.info("Shutting down...");
|
|
30
|
-
|
|
29
|
+
Promise.all(targetNames.map((targetName) => {
|
|
31
30
|
return TARGETS[targetName].stop(options);
|
|
32
31
|
}))
|
|
33
32
|
.then(resolve)
|
package/lib/utils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
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.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
6
|
const clc = require("cli-color");
|
|
@@ -28,7 +28,7 @@ exports.consoleUrl = consoleUrl;
|
|
|
28
28
|
function getInheritedOption(options, key) {
|
|
29
29
|
let target = options;
|
|
30
30
|
while (target) {
|
|
31
|
-
if (
|
|
31
|
+
if (target[key] !== undefined) {
|
|
32
32
|
return target[key];
|
|
33
33
|
}
|
|
34
34
|
target = target.parent;
|
|
@@ -184,13 +184,13 @@ function makeActiveProject(projectDir, newActive) {
|
|
|
184
184
|
}
|
|
185
185
|
exports.makeActiveProject = makeActiveProject;
|
|
186
186
|
function endpoint(parts) {
|
|
187
|
-
return `/${
|
|
187
|
+
return `/${parts.join("/")}`;
|
|
188
188
|
}
|
|
189
189
|
exports.endpoint = endpoint;
|
|
190
190
|
function getFunctionsEventProvider(eventType) {
|
|
191
191
|
const parts = eventType.split("/");
|
|
192
192
|
if (parts.length > 1) {
|
|
193
|
-
const provider =
|
|
193
|
+
const provider = last(parts[1].split("."));
|
|
194
194
|
return _.capitalize(provider);
|
|
195
195
|
}
|
|
196
196
|
if (eventType.match(/google.pubsub/)) {
|
|
@@ -218,7 +218,7 @@ function getFunctionsEventProvider(eventType) {
|
|
|
218
218
|
}
|
|
219
219
|
exports.getFunctionsEventProvider = getFunctionsEventProvider;
|
|
220
220
|
function promiseAllSettled(promises) {
|
|
221
|
-
const wrappedPromises =
|
|
221
|
+
const wrappedPromises = promises.map(async (p) => {
|
|
222
222
|
try {
|
|
223
223
|
const val = await Promise.resolve(p);
|
|
224
224
|
return { state: "fulfilled", value: val };
|
|
@@ -250,7 +250,7 @@ async function promiseWhile(action, check, interval = 2500) {
|
|
|
250
250
|
exports.promiseWhile = promiseWhile;
|
|
251
251
|
async function promiseProps(obj) {
|
|
252
252
|
const resultObj = {};
|
|
253
|
-
const promises =
|
|
253
|
+
const promises = Object.keys(obj).map(async (key) => {
|
|
254
254
|
const r = await Promise.resolve(obj[key]);
|
|
255
255
|
resultObj[key] = r;
|
|
256
256
|
});
|
|
@@ -435,3 +435,27 @@ function cloneDeep(obj) {
|
|
|
435
435
|
return cloneObject(obj);
|
|
436
436
|
}
|
|
437
437
|
exports.cloneDeep = cloneDeep;
|
|
438
|
+
function last(arr) {
|
|
439
|
+
if (!Array.isArray(arr)) {
|
|
440
|
+
return;
|
|
441
|
+
}
|
|
442
|
+
return arr[arr.length - 1];
|
|
443
|
+
}
|
|
444
|
+
exports.last = last;
|
|
445
|
+
function debounce(fn, delay, { leading } = {}) {
|
|
446
|
+
let timer;
|
|
447
|
+
return (...args) => {
|
|
448
|
+
if (!timer && leading) {
|
|
449
|
+
fn(...args);
|
|
450
|
+
}
|
|
451
|
+
clearTimeout(timer);
|
|
452
|
+
timer = setTimeout(() => fn(...args), delay);
|
|
453
|
+
};
|
|
454
|
+
}
|
|
455
|
+
exports.debounce = debounce;
|
|
456
|
+
function randomInt(min, max) {
|
|
457
|
+
min = Math.floor(min);
|
|
458
|
+
max = Math.ceil(max) + 1;
|
|
459
|
+
return Math.floor(Math.random() * (max - min) + min);
|
|
460
|
+
}
|
|
461
|
+
exports.randomInt = randomInt;
|