firebase-tools 11.5.0 → 11.6.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/command.js +33 -7
- package/lib/commands/emulators-exec.js +4 -1
- package/lib/commands/emulators-export.js +5 -2
- package/lib/commands/emulators-start.js +23 -17
- package/lib/commands/ext-dev-publish.js +3 -0
- package/lib/commands/login.js +2 -2
- package/lib/emulator/auth/index.js +7 -2
- package/lib/emulator/auth/operations.js +10 -10
- package/lib/emulator/commandUtils.js +32 -15
- package/lib/emulator/constants.js +14 -6
- package/lib/emulator/controller.js +54 -17
- package/lib/emulator/downloadableEmulators.js +7 -7
- package/lib/emulator/eventarcEmulator.js +148 -0
- package/lib/emulator/extensionsEmulator.js +3 -1
- package/lib/emulator/functionsEmulator.js +44 -4
- 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/registry.js +1 -0
- package/lib/emulator/storage/files.js +14 -2
- package/lib/emulator/storage/rules/runtime.js +2 -2
- package/lib/emulator/storage/server.js +2 -1
- package/lib/emulator/storage/upload.js +1 -0
- package/lib/emulator/types.js +3 -0
- package/lib/emulator/ui.js +7 -2
- package/lib/extensions/extensionsApi.js +2 -1
- package/lib/extensions/extensionsHelper.js +29 -1
- package/lib/serve/index.js +15 -0
- package/lib/track.js +119 -3
- package/lib/utils.js +14 -1
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/schema/firebase-config.json +12 -0
- package/templates/extensions/CHANGELOG.md +1 -7
package/lib/command.js
CHANGED
|
@@ -70,22 +70,39 @@ class Command {
|
|
|
70
70
|
this.positionalArgs = cmd._args;
|
|
71
71
|
cmd.action((...args) => {
|
|
72
72
|
const runner = this.runner();
|
|
73
|
-
const start =
|
|
73
|
+
const start = process.uptime();
|
|
74
74
|
const options = (0, lodash_1.last)(args);
|
|
75
75
|
if (args.length - 1 > cmd._args.length) {
|
|
76
76
|
client.errorOut(new error_1.FirebaseError(`Too many arguments. Run ${clc.bold("firebase help " + this.name)} for usage instructions`, { exit: 1 }));
|
|
77
77
|
return;
|
|
78
78
|
}
|
|
79
|
+
const isEmulator = this.name.includes("emulator") || this.name === "serve";
|
|
80
|
+
if (isEmulator) {
|
|
81
|
+
void (0, track_1.trackEmulator)("command_start", { command_name: this.name });
|
|
82
|
+
}
|
|
79
83
|
runner(...args)
|
|
80
|
-
.then((result) => {
|
|
84
|
+
.then(async (result) => {
|
|
81
85
|
if ((0, utils_1.getInheritedOption)(options, "json")) {
|
|
82
86
|
console.log(JSON.stringify({
|
|
83
87
|
status: "success",
|
|
84
88
|
result: result,
|
|
85
89
|
}, null, 2));
|
|
86
90
|
}
|
|
87
|
-
const duration =
|
|
88
|
-
|
|
91
|
+
const duration = Math.floor((process.uptime() - start) * 1000);
|
|
92
|
+
const trackSuccess = (0, track_1.track)(this.name, "success", duration);
|
|
93
|
+
if (!isEmulator) {
|
|
94
|
+
await (0, utils_1.withTimeout)(5000, trackSuccess);
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
await (0, utils_1.withTimeout)(5000, Promise.all([
|
|
98
|
+
trackSuccess,
|
|
99
|
+
(0, track_1.trackEmulator)("command_success", {
|
|
100
|
+
command_name: this.name,
|
|
101
|
+
duration,
|
|
102
|
+
}),
|
|
103
|
+
]));
|
|
104
|
+
}
|
|
105
|
+
process.exit();
|
|
89
106
|
})
|
|
90
107
|
.catch(async (err) => {
|
|
91
108
|
if ((0, utils_1.getInheritedOption)(options, "json")) {
|
|
@@ -94,9 +111,18 @@ class Command {
|
|
|
94
111
|
error: err.message,
|
|
95
112
|
}, null, 2));
|
|
96
113
|
}
|
|
97
|
-
const duration =
|
|
98
|
-
|
|
99
|
-
|
|
114
|
+
const duration = Math.floor((process.uptime() - start) * 1000);
|
|
115
|
+
await (0, utils_1.withTimeout)(5000, Promise.all([
|
|
116
|
+
(0, track_1.track)(this.name, "error", duration),
|
|
117
|
+
(0, track_1.track)(err.exit === 1 ? "Error (User)" : "Error (Unexpected)", "", duration),
|
|
118
|
+
isEmulator
|
|
119
|
+
? (0, track_1.trackEmulator)("command_error", {
|
|
120
|
+
command_name: this.name,
|
|
121
|
+
duration,
|
|
122
|
+
error_type: err.exit === 1 ? "user" : "unexpected",
|
|
123
|
+
})
|
|
124
|
+
: Promise.resolve(),
|
|
125
|
+
]));
|
|
100
126
|
client.errorOut(err);
|
|
101
127
|
});
|
|
102
128
|
});
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.command = void 0;
|
|
4
4
|
const command_1 = require("../command");
|
|
5
5
|
const commandUtils = require("../emulator/commandUtils");
|
|
6
|
+
const commandUtils_1 = require("../emulator/commandUtils");
|
|
6
7
|
exports.command = new command_1.Command("emulators:exec <script>")
|
|
7
8
|
.before(commandUtils.setExportOnExitOptions)
|
|
8
9
|
.before(commandUtils.beforeEmulatorCommand)
|
|
@@ -12,4 +13,6 @@ exports.command = new command_1.Command("emulators:exec <script>")
|
|
|
12
13
|
.option(commandUtils.FLAG_IMPORT, commandUtils.DESC_IMPORT)
|
|
13
14
|
.option(commandUtils.FLAG_EXPORT_ON_EXIT, commandUtils.DESC_EXPORT_ON_EXIT)
|
|
14
15
|
.option(commandUtils.FLAG_UI, commandUtils.DESC_UI)
|
|
15
|
-
.action(
|
|
16
|
+
.action((script, options) => {
|
|
17
|
+
return Promise.race([(0, commandUtils_1.shutdownWhenKilled)(options), (0, commandUtils_1.emulatorExec)(script, options)]);
|
|
18
|
+
});
|
|
@@ -4,8 +4,11 @@ exports.command = void 0;
|
|
|
4
4
|
const command_1 = require("../command");
|
|
5
5
|
const controller = require("../emulator/controller");
|
|
6
6
|
const commandUtils = require("../emulator/commandUtils");
|
|
7
|
-
|
|
7
|
+
const COMMAND_NAME = "emulators:export";
|
|
8
|
+
exports.command = new command_1.Command(`${COMMAND_NAME} <path>`)
|
|
8
9
|
.description("export data from running emulators")
|
|
9
10
|
.withForce("overwrite any export data in the target directory")
|
|
10
11
|
.option(commandUtils.FLAG_ONLY, commandUtils.DESC_ONLY)
|
|
11
|
-
.action(
|
|
12
|
+
.action((exportPath, options) => {
|
|
13
|
+
return controller.exportEmulatorData(exportPath, options, COMMAND_NAME);
|
|
14
|
+
});
|
|
@@ -22,16 +22,28 @@ exports.command = new command_1.Command("emulators:start")
|
|
|
22
22
|
.option(commandUtils.FLAG_INSPECT_FUNCTIONS, commandUtils.DESC_INSPECT_FUNCTIONS)
|
|
23
23
|
.option(commandUtils.FLAG_IMPORT, commandUtils.DESC_IMPORT)
|
|
24
24
|
.option(commandUtils.FLAG_EXPORT_ON_EXIT, commandUtils.DESC_EXPORT_ON_EXIT)
|
|
25
|
-
.action(
|
|
25
|
+
.action((options) => {
|
|
26
26
|
const killSignalPromise = commandUtils.shutdownWhenKilled(options);
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
(
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
27
|
+
return Promise.race([
|
|
28
|
+
killSignalPromise,
|
|
29
|
+
(async () => {
|
|
30
|
+
let deprecationNotices;
|
|
31
|
+
try {
|
|
32
|
+
({ deprecationNotices } = await controller.startAll(options));
|
|
33
|
+
}
|
|
34
|
+
catch (e) {
|
|
35
|
+
await controller.cleanShutdown();
|
|
36
|
+
throw e;
|
|
37
|
+
}
|
|
38
|
+
printEmulatorOverview(options);
|
|
39
|
+
for (const notice of deprecationNotices) {
|
|
40
|
+
(0, utils_1.logLabeledWarning)("emulators", notice, "warn");
|
|
41
|
+
}
|
|
42
|
+
return killSignalPromise;
|
|
43
|
+
})(),
|
|
44
|
+
]);
|
|
45
|
+
});
|
|
46
|
+
function printEmulatorOverview(options) {
|
|
35
47
|
const reservedPorts = [];
|
|
36
48
|
for (const internalEmulator of [types_1.Emulators.LOGGING]) {
|
|
37
49
|
const info = registry_1.EmulatorRegistry.getInfo(internalEmulator);
|
|
@@ -71,9 +83,7 @@ exports.command = new command_1.Command("emulators:start")
|
|
|
71
83
|
return [
|
|
72
84
|
emulatorName,
|
|
73
85
|
registry_1.EmulatorRegistry.getInfoHostString(info),
|
|
74
|
-
isSupportedByUi && uiInfo
|
|
75
|
-
? stylizeLink(`${uiUrl}/${emulator}`)
|
|
76
|
-
: clc.blackBright("n/a"),
|
|
86
|
+
isSupportedByUi && uiInfo ? stylizeLink(`${uiUrl}/${emulator}`) : clc.blackBright("n/a"),
|
|
77
87
|
];
|
|
78
88
|
})
|
|
79
89
|
.map((col) => col.slice(0, head.length))
|
|
@@ -93,8 +103,4 @@ ${clc.blackBright(" Other reserved ports:")} ${reservedPortsString}
|
|
|
93
103
|
${extensionsTable}
|
|
94
104
|
Issues? Report them at ${stylizeLink("https://github.com/firebase/firebase-tools/issues")} and attach the *-debug.log files.
|
|
95
105
|
`);
|
|
96
|
-
|
|
97
|
-
(0, utils_1.logLabeledWarning)("emulators", notice, "warn");
|
|
98
|
-
}
|
|
99
|
-
await killSignalPromise;
|
|
100
|
-
});
|
|
106
|
+
}
|
|
@@ -17,12 +17,14 @@ marked.setOptions({
|
|
|
17
17
|
});
|
|
18
18
|
exports.command = new command_1.Command("ext:dev:publish <extensionRef>")
|
|
19
19
|
.description(`publish a new version of an extension`)
|
|
20
|
+
.option(`-s, --stage <stage>`, `release stage (supports "rc", "alpha", "beta", and "stable")`)
|
|
20
21
|
.withForce()
|
|
21
22
|
.help("if you have not previously published a version of this extension, this will " +
|
|
22
23
|
"create the extension. If you have previously published a version of this extension, this version must " +
|
|
23
24
|
"be greater than previous versions.")
|
|
24
25
|
.before(requireAuth_1.requireAuth)
|
|
25
26
|
.action(async (extensionRef, options) => {
|
|
27
|
+
var _a;
|
|
26
28
|
const { publisherId, extensionId, version } = refs.parse(extensionRef);
|
|
27
29
|
if (version) {
|
|
28
30
|
throw new error_1.FirebaseError(`The input extension reference must be of the format ${clc.bold("<publisherId>/<extensionId>")}. Version should not be supplied and will be inferred directly from extension.yaml. Please increment the version in extension.yaml if you would like to bump/specify a version.`);
|
|
@@ -37,6 +39,7 @@ exports.command = new command_1.Command("ext:dev:publish <extensionRef>")
|
|
|
37
39
|
rootDirectory: extensionYamlDirectory,
|
|
38
40
|
nonInteractive: options.nonInteractive,
|
|
39
41
|
force: options.force,
|
|
42
|
+
stage: (_a = options.stage) !== null && _a !== void 0 ? _a : "stable",
|
|
40
43
|
});
|
|
41
44
|
if (res) {
|
|
42
45
|
utils.logLabeledBullet(extensionsHelper_1.logPrefix, marked(`[Install Link](${(0, publishHelpers_1.consoleInstallLink)(res.ref)})`));
|
package/lib/commands/login.js
CHANGED
|
@@ -28,11 +28,11 @@ exports.command = new command_1.Command("login")
|
|
|
28
28
|
return user;
|
|
29
29
|
}
|
|
30
30
|
if (!options.reauth) {
|
|
31
|
-
utils.logBullet("Firebase optionally collects CLI usage and error reporting information to help improve our products. Data is collected in accordance with Google's privacy policy (https://policies.google.com/privacy) and is not used to identify you.\n");
|
|
31
|
+
utils.logBullet("Firebase optionally collects CLI and Emulator Suite usage and error reporting information to help improve our products. Data is collected in accordance with Google's privacy policy (https://policies.google.com/privacy) and is not used to identify you.\n");
|
|
32
32
|
const collectUsage = await (0, prompt_1.promptOnce)({
|
|
33
33
|
type: "confirm",
|
|
34
34
|
name: "collectUsage",
|
|
35
|
-
message: "Allow Firebase to collect CLI usage and error reporting information?",
|
|
35
|
+
message: "Allow Firebase to collect CLI and Emulator Suite usage and error reporting information?",
|
|
36
36
|
});
|
|
37
37
|
configstore_1.configstore.set("usage", collectUsage);
|
|
38
38
|
if (collectUsage) {
|
|
@@ -10,6 +10,7 @@ const emulatorLogger_1 = require("../emulatorLogger");
|
|
|
10
10
|
const types_1 = require("../types");
|
|
11
11
|
const server_1 = require("./server");
|
|
12
12
|
const error_1 = require("../../error");
|
|
13
|
+
const track_1 = require("../../track");
|
|
13
14
|
class AuthEmulator {
|
|
14
15
|
constructor(args) {
|
|
15
16
|
this.args = args;
|
|
@@ -37,8 +38,12 @@ class AuthEmulator {
|
|
|
37
38
|
getName() {
|
|
38
39
|
return types_1.Emulators.AUTH;
|
|
39
40
|
}
|
|
40
|
-
async importData(authExportDir, projectId) {
|
|
41
|
-
|
|
41
|
+
async importData(authExportDir, projectId, options) {
|
|
42
|
+
void (0, track_1.trackEmulator)("emulator_import", {
|
|
43
|
+
initiated_by: options.initiatedBy,
|
|
44
|
+
emulator_name: types_1.Emulators.AUTH,
|
|
45
|
+
});
|
|
46
|
+
const logger = emulatorLogger_1.EmulatorLogger.forEmulator(types_1.Emulators.AUTH);
|
|
42
47
|
const { host, port } = this.getInfo();
|
|
43
48
|
const configPath = path.join(authExportDir, "config.json");
|
|
44
49
|
const configStat = await stat(configPath);
|
|
@@ -340,7 +340,7 @@ function batchCreate(state, reqBody) {
|
|
|
340
340
|
}
|
|
341
341
|
fields.emailVerified = !!userInfo.emailVerified;
|
|
342
342
|
fields.disabled = !!userInfo.disabled;
|
|
343
|
-
if (userInfo.mfaInfo) {
|
|
343
|
+
if (userInfo.mfaInfo && userInfo.mfaInfo.length > 0) {
|
|
344
344
|
fields.mfaInfo = [];
|
|
345
345
|
(0, errors_1.assert)(fields.email, "Second factor account requires email to be presented.");
|
|
346
346
|
(0, errors_1.assert)(fields.emailVerified, "Second factor account requires email to be verified.");
|
|
@@ -1716,14 +1716,14 @@ function fakeFetchUserInfoFromIdp(providerId, claims, samlResponse) {
|
|
|
1716
1716
|
switch (providerId) {
|
|
1717
1717
|
case "google.com": {
|
|
1718
1718
|
federatedId = `https://accounts.google.com/${rawId}`;
|
|
1719
|
-
let
|
|
1719
|
+
let grantedScopes = "openid https://www.googleapis.com/auth/userinfo.profile";
|
|
1720
1720
|
if (email) {
|
|
1721
|
-
|
|
1721
|
+
grantedScopes += " https://www.googleapis.com/auth/userinfo.email";
|
|
1722
1722
|
}
|
|
1723
1723
|
response.firstName = claims.given_name;
|
|
1724
1724
|
response.lastName = claims.family_name;
|
|
1725
1725
|
response.rawUserInfo = JSON.stringify({
|
|
1726
|
-
granted_scopes,
|
|
1726
|
+
granted_scopes: grantedScopes,
|
|
1727
1727
|
id: rawId,
|
|
1728
1728
|
name: displayName,
|
|
1729
1729
|
given_name: claims.given_name,
|
|
@@ -2064,7 +2064,7 @@ function generateBlockingFunctionJwt(state, event, url, timeoutMs, user, options
|
|
|
2064
2064
|
jwt.tenant_id = state.tenantId;
|
|
2065
2065
|
jwt.user_record.tenant_id = state.tenantId;
|
|
2066
2066
|
}
|
|
2067
|
-
const
|
|
2067
|
+
const providerData = [];
|
|
2068
2068
|
if (user.providerUserInfo) {
|
|
2069
2069
|
for (const providerUserInfo of user.providerUserInfo) {
|
|
2070
2070
|
const provider = {
|
|
@@ -2075,12 +2075,12 @@ function generateBlockingFunctionJwt(state, event, url, timeoutMs, user, options
|
|
|
2075
2075
|
uid: providerUserInfo.rawId,
|
|
2076
2076
|
phone_number: providerUserInfo.phoneNumber,
|
|
2077
2077
|
};
|
|
2078
|
-
|
|
2078
|
+
providerData.push(provider);
|
|
2079
2079
|
}
|
|
2080
2080
|
}
|
|
2081
|
-
jwt.user_record.provider_data =
|
|
2081
|
+
jwt.user_record.provider_data = providerData;
|
|
2082
2082
|
if (user.mfaInfo) {
|
|
2083
|
-
const
|
|
2083
|
+
const enrolledFactors = [];
|
|
2084
2084
|
for (const mfaEnrollment of user.mfaInfo) {
|
|
2085
2085
|
if (!mfaEnrollment.mfaEnrollmentId) {
|
|
2086
2086
|
continue;
|
|
@@ -2092,10 +2092,10 @@ function generateBlockingFunctionJwt(state, event, url, timeoutMs, user, options
|
|
|
2092
2092
|
phone_number: mfaEnrollment.phoneInfo,
|
|
2093
2093
|
factor_id: state_1.PROVIDER_PHONE,
|
|
2094
2094
|
};
|
|
2095
|
-
|
|
2095
|
+
enrolledFactors.push(enrolledFactor);
|
|
2096
2096
|
}
|
|
2097
2097
|
jwt.user_record.multi_factor = {
|
|
2098
|
-
enrolled_factors,
|
|
2098
|
+
enrolled_factors: enrolledFactors,
|
|
2099
2099
|
};
|
|
2100
2100
|
}
|
|
2101
2101
|
if (user.lastLoginAt || user.createdAt) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.JAVA_DEPRECATION_WARNING = exports.
|
|
3
|
+
exports.JAVA_DEPRECATION_WARNING = exports.MIN_SUPPORTED_JAVA_MAJOR_VERSION = exports.checkJavaMajorVersion = exports.emulatorExec = exports.shutdownWhenKilled = exports.setExportOnExitOptions = exports.parseInspectionPort = exports.beforeEmulatorCommand = exports.warnEmulatorNotSupported = exports.printNoticeIfEmulated = exports.DESC_TEST_PARAMS = exports.FLAG_TEST_PARAMS = exports.DESC_TEST_CONFIG = exports.FLAG_TEST_CONFIG = exports.DESC_UI = exports.FLAG_UI = exports.EXPORT_ON_EXIT_CWD_DANGER = exports.EXPORT_ON_EXIT_USAGE_ERROR = exports.DESC_EXPORT_ON_EXIT = exports.FLAG_EXPORT_ON_EXIT = exports.FLAG_EXPORT_ON_EXIT_NAME = exports.DESC_IMPORT = exports.FLAG_IMPORT = exports.DESC_INSPECT_FUNCTIONS = exports.FLAG_INSPECT_FUNCTIONS = exports.DESC_ONLY = exports.FLAG_ONLY = void 0;
|
|
4
4
|
const clc = require("colorette");
|
|
5
5
|
const childProcess = require("child_process");
|
|
6
6
|
const controller = require("../emulator/controller");
|
|
@@ -20,6 +20,7 @@ const prompt_1 = require("../prompt");
|
|
|
20
20
|
const controller_1 = require("./controller");
|
|
21
21
|
const fsutils = require("../fsutils");
|
|
22
22
|
const Table = require("cli-table");
|
|
23
|
+
const track_1 = require("../track");
|
|
23
24
|
exports.FLAG_ONLY = "--only <emulators>";
|
|
24
25
|
exports.DESC_ONLY = "only specific emulators. " +
|
|
25
26
|
"This is a comma separated list of emulator names. " +
|
|
@@ -43,7 +44,14 @@ exports.FLAG_TEST_CONFIG = "--test-config <firebase.json file>";
|
|
|
43
44
|
exports.DESC_TEST_CONFIG = "A firebase.json style file. Used to configure the Firestore and Realtime Database emulators.";
|
|
44
45
|
exports.FLAG_TEST_PARAMS = "--test-params <params.env file>";
|
|
45
46
|
exports.DESC_TEST_PARAMS = "A .env file containing test param values for your emulated extension.";
|
|
46
|
-
const DEFAULT_CONFIG = new config_1.Config({
|
|
47
|
+
const DEFAULT_CONFIG = new config_1.Config({
|
|
48
|
+
eventarc: {},
|
|
49
|
+
database: {},
|
|
50
|
+
firestore: {},
|
|
51
|
+
functions: {},
|
|
52
|
+
hosting: {},
|
|
53
|
+
emulators: { auth: {}, pubsub: {} },
|
|
54
|
+
}, {});
|
|
47
55
|
function printNoticeIfEmulated(options, emulator) {
|
|
48
56
|
if (emulator !== types_1.Emulators.DATABASE && emulator !== types_1.Emulators.FIRESTORE) {
|
|
49
57
|
return;
|
|
@@ -201,14 +209,10 @@ function shutdownWhenKilled(options) {
|
|
|
201
209
|
["SIGINT", "SIGTERM", "SIGHUP", "SIGQUIT"].forEach((signal) => {
|
|
202
210
|
process.on(signal, processKillSignal(signal, res, rej, options));
|
|
203
211
|
});
|
|
204
|
-
})
|
|
205
|
-
.then(() => {
|
|
206
|
-
process.exit(0);
|
|
207
|
-
})
|
|
208
|
-
.catch((e) => {
|
|
212
|
+
}).catch((e) => {
|
|
209
213
|
logger_1.logger.debug(e);
|
|
210
214
|
utils.logLabeledWarning("emulators", "emulators failed to shut down cleanly, see firebase-debug.log for details.");
|
|
211
|
-
|
|
215
|
+
throw e;
|
|
212
216
|
});
|
|
213
217
|
}
|
|
214
218
|
exports.shutdownWhenKilled = shutdownWhenKilled;
|
|
@@ -247,6 +251,12 @@ async function runScript(script, extraEnv) {
|
|
|
247
251
|
const address = registry_1.EmulatorRegistry.getInfoHostString(info);
|
|
248
252
|
env[constants_1.Constants.FIREBASE_EMULATOR_HUB] = address;
|
|
249
253
|
}
|
|
254
|
+
const eventarcInstance = registry_1.EmulatorRegistry.get(types_1.Emulators.EVENTARC);
|
|
255
|
+
if (eventarcInstance) {
|
|
256
|
+
const info = eventarcInstance.getInfo();
|
|
257
|
+
const address = registry_1.EmulatorRegistry.getInfoHostString(info);
|
|
258
|
+
env[constants_1.Constants.CLOUD_EVENTARC_EMULATOR_HOST] = address;
|
|
259
|
+
}
|
|
250
260
|
const proc = childProcess.spawn(script, {
|
|
251
261
|
stdio: ["inherit", "inherit", "inherit"],
|
|
252
262
|
shell: true,
|
|
@@ -280,12 +290,15 @@ async function runScript(script, extraEnv) {
|
|
|
280
290
|
});
|
|
281
291
|
}
|
|
282
292
|
async function emulatorExec(script, options) {
|
|
283
|
-
shutdownWhenKilled(options);
|
|
284
293
|
const projectId = (0, projectUtils_1.getProjectId)(options);
|
|
285
294
|
const extraEnv = {};
|
|
286
295
|
if (projectId) {
|
|
287
296
|
extraEnv.GCLOUD_PROJECT = projectId;
|
|
288
297
|
}
|
|
298
|
+
const session = (0, track_1.emulatorSession)();
|
|
299
|
+
if (session && session.debugMode) {
|
|
300
|
+
extraEnv[constants_1.Constants.FIREBASE_GA_SESSION] = JSON.stringify(session);
|
|
301
|
+
}
|
|
289
302
|
let exitCode = 0;
|
|
290
303
|
let deprecationNotices;
|
|
291
304
|
try {
|
|
@@ -308,9 +321,8 @@ async function emulatorExec(script, options) {
|
|
|
308
321
|
}
|
|
309
322
|
exports.emulatorExec = emulatorExec;
|
|
310
323
|
const JAVA_VERSION_REGEX = /version "([1-9][0-9]*)/;
|
|
311
|
-
const MIN_SUPPORTED_JAVA_MAJOR_VERSION = 11;
|
|
312
324
|
const JAVA_HINT = "Please make sure Java is installed and on your system PATH.";
|
|
313
|
-
async function
|
|
325
|
+
async function checkJavaMajorVersion() {
|
|
314
326
|
return new Promise((resolve, reject) => {
|
|
315
327
|
var _a, _b;
|
|
316
328
|
let child;
|
|
@@ -351,25 +363,30 @@ async function checkJavaSupported() {
|
|
|
351
363
|
}
|
|
352
364
|
});
|
|
353
365
|
}).then((output) => {
|
|
366
|
+
let versionInt = -1;
|
|
354
367
|
const match = output.match(JAVA_VERSION_REGEX);
|
|
355
368
|
if (match) {
|
|
356
369
|
const version = match[1];
|
|
357
|
-
|
|
370
|
+
versionInt = parseInt(version, 10);
|
|
358
371
|
if (!versionInt) {
|
|
359
372
|
utils.logLabeledWarning("emulators", `Failed to parse Java version. Got "${match[0]}".`, "warn");
|
|
360
373
|
}
|
|
361
374
|
else {
|
|
362
375
|
logger_1.logger.debug(`Parsed Java major version: ${versionInt}`);
|
|
363
|
-
return versionInt >= MIN_SUPPORTED_JAVA_MAJOR_VERSION;
|
|
364
376
|
}
|
|
365
377
|
}
|
|
366
378
|
else {
|
|
367
379
|
logger_1.logger.debug("java -version outputs:", output);
|
|
368
380
|
logger_1.logger.warn(`Failed to parse Java version.`);
|
|
369
381
|
}
|
|
370
|
-
|
|
382
|
+
const session = (0, track_1.emulatorSession)();
|
|
383
|
+
if (session) {
|
|
384
|
+
session.javaMajorVersion = versionInt;
|
|
385
|
+
}
|
|
386
|
+
return versionInt;
|
|
371
387
|
});
|
|
372
388
|
}
|
|
373
|
-
exports.
|
|
389
|
+
exports.checkJavaMajorVersion = checkJavaMajorVersion;
|
|
390
|
+
exports.MIN_SUPPORTED_JAVA_MAJOR_VERSION = 11;
|
|
374
391
|
exports.JAVA_DEPRECATION_WARNING = "firebase-tools no longer supports Java version before 11. " +
|
|
375
392
|
"Please upgrade to Java version 11 or above to continue using the emulators.";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Constants = exports.EMULATOR_DESCRIPTION = exports.FIND_AVAILBLE_PORT_BY_DEFAULT = void 0;
|
|
3
|
+
exports.Constants = exports.DEFAULT_HOST = exports.EMULATOR_DESCRIPTION = exports.FIND_AVAILBLE_PORT_BY_DEFAULT = exports.DEFAULT_PORTS = void 0;
|
|
4
4
|
const url = require("url");
|
|
5
|
-
|
|
5
|
+
exports.DEFAULT_PORTS = {
|
|
6
6
|
ui: 4000,
|
|
7
7
|
hub: 4400,
|
|
8
8
|
logging: 4500,
|
|
@@ -14,6 +14,7 @@ const DEFAULT_PORTS = {
|
|
|
14
14
|
database: 9000,
|
|
15
15
|
auth: 9099,
|
|
16
16
|
storage: 9199,
|
|
17
|
+
eventarc: 9299,
|
|
17
18
|
};
|
|
18
19
|
exports.FIND_AVAILBLE_PORT_BY_DEFAULT = {
|
|
19
20
|
ui: true,
|
|
@@ -27,6 +28,7 @@ exports.FIND_AVAILBLE_PORT_BY_DEFAULT = {
|
|
|
27
28
|
auth: false,
|
|
28
29
|
storage: false,
|
|
29
30
|
extensions: false,
|
|
31
|
+
eventarc: false,
|
|
30
32
|
};
|
|
31
33
|
exports.EMULATOR_DESCRIPTION = {
|
|
32
34
|
ui: "Emulator UI",
|
|
@@ -40,8 +42,9 @@ exports.EMULATOR_DESCRIPTION = {
|
|
|
40
42
|
auth: "Authentication Emulator",
|
|
41
43
|
storage: "Storage Emulator",
|
|
42
44
|
extensions: "Extensions Emulator",
|
|
45
|
+
eventarc: "Eventarc Emulator",
|
|
43
46
|
};
|
|
44
|
-
|
|
47
|
+
exports.DEFAULT_HOST = "localhost";
|
|
45
48
|
class Constants {
|
|
46
49
|
static getServiceName(service) {
|
|
47
50
|
switch (service) {
|
|
@@ -63,15 +66,17 @@ class Constants {
|
|
|
63
66
|
return "storage";
|
|
64
67
|
case this.SERVICE_TEST_LAB:
|
|
65
68
|
return "test lab";
|
|
69
|
+
case this.SERVICE_EVENTARC:
|
|
70
|
+
return "eventarc";
|
|
66
71
|
default:
|
|
67
72
|
return service;
|
|
68
73
|
}
|
|
69
74
|
}
|
|
70
75
|
static getDefaultHost() {
|
|
71
|
-
return DEFAULT_HOST;
|
|
76
|
+
return exports.DEFAULT_HOST;
|
|
72
77
|
}
|
|
73
78
|
static getDefaultPort(emulator) {
|
|
74
|
-
return DEFAULT_PORTS[emulator];
|
|
79
|
+
return exports.DEFAULT_PORTS[emulator];
|
|
75
80
|
}
|
|
76
81
|
static description(name) {
|
|
77
82
|
return exports.EMULATOR_DESCRIPTION[name];
|
|
@@ -82,7 +87,7 @@ class Constants {
|
|
|
82
87
|
normalized = `http://${normalized}`;
|
|
83
88
|
}
|
|
84
89
|
const u = url.parse(normalized);
|
|
85
|
-
return u.hostname || DEFAULT_HOST;
|
|
90
|
+
return u.hostname || exports.DEFAULT_HOST;
|
|
86
91
|
}
|
|
87
92
|
static isDemoProject(projectId) {
|
|
88
93
|
return !!projectId && projectId.startsWith(this.FAKE_PROJECT_ID_PREFIX);
|
|
@@ -97,10 +102,13 @@ Constants.FIREBASE_DATABASE_EMULATOR_HOST = "FIREBASE_DATABASE_EMULATOR_HOST";
|
|
|
97
102
|
Constants.FIREBASE_AUTH_EMULATOR_HOST = "FIREBASE_AUTH_EMULATOR_HOST";
|
|
98
103
|
Constants.FIREBASE_STORAGE_EMULATOR_HOST = "FIREBASE_STORAGE_EMULATOR_HOST";
|
|
99
104
|
Constants.CLOUD_STORAGE_EMULATOR_HOST = "STORAGE_EMULATOR_HOST";
|
|
105
|
+
Constants.CLOUD_EVENTARC_EMULATOR_HOST = "CLOUD_EVENTARC_EMULATOR_HOST";
|
|
100
106
|
Constants.FIREBASE_EMULATOR_HUB = "FIREBASE_EMULATOR_HUB";
|
|
107
|
+
Constants.FIREBASE_GA_SESSION = "FIREBASE_GA_SESSION";
|
|
101
108
|
Constants.SERVICE_FIRESTORE = "firestore.googleapis.com";
|
|
102
109
|
Constants.SERVICE_REALTIME_DATABASE = "firebaseio.com";
|
|
103
110
|
Constants.SERVICE_PUBSUB = "pubsub.googleapis.com";
|
|
111
|
+
Constants.SERVICE_EVENTARC = "eventarc.googleapis.com";
|
|
104
112
|
Constants.SERVICE_ANALYTICS = "app-measurement.com";
|
|
105
113
|
Constants.SERVICE_AUTH = "firebaseauth.googleapis.com";
|
|
106
114
|
Constants.SERVICE_CRASHLYTICS = "fabric.io";
|