Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improves "emulators:start" logs #2219

Merged
merged 17 commits into from
May 14, 2020
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
- Adds new API commands that handle list/create/delete operations on the Android SHA certificate hashes `apps:android:sha:list`, `apps:android:sha:create`, and `apps:android:sha:delete`.
- Fixes an issue where the CLI did not assume admin privileges when performing Firestore / RTDB emulator operations.
- Fixes an issue where the functions and hosting emulators would crash when not properly initialized (#2112).
- Improves logs when running `emulators:start`.
44 changes: 44 additions & 0 deletions src/commands/emulators-start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ import { Command } from "../command";
import * as controller from "../emulator/controller";
import * as commandUtils from "../emulator/commandUtils";
import * as utils from "../utils";
import * as logger from "../logger";
import { EmulatorRegistry } from "../emulator/registry";
import { Emulators, EMULATORS_SUPPORTED_BY_GUI } from "../emulator/types";
const Table = require("cli-table");

module.exports = new Command("emulators:start")
.before(commandUtils.beforeEmulatorCommand)
Expand All @@ -18,6 +22,46 @@ module.exports = new Command("emulators:start")
}

utils.logLabeledSuccess("emulators", "All emulators started, it is now safe to connect.");
const table = new Table({
head: ["Emulator", "Host:Port", "View in Browser"],
abeisgoat marked this conversation as resolved.
Show resolved Hide resolved
style: {
head: ["yellow"],
},
});

const guiInfo = EmulatorRegistry.getInfo(Emulators.GUI);
table.push(
...controller
.filterEmulatorTargets(options)
.map((emulator) => {
const info = EmulatorRegistry.getInfo(emulator);
const emulatorName = emulator.slice(0, 1).toUpperCase() + emulator.slice(1);
const isSupportedByGUI = EMULATORS_SUPPORTED_BY_GUI.includes(emulator);

if (!info) {
return [emulatorName, "Failed to initialize (see above)", ""];
}

return [
emulatorName,
`${info?.host}:${info?.port}`,
isSupportedByGUI && guiInfo ? `http://${guiInfo.host}:${guiInfo.port}/${emulator}` : "",
];
})
.filter((v) => v)
);

logger.info(`${table.toString()}

You can also view status and logs of the emulators by pointing your browser to http://${
guiInfo?.host
}:${guiInfo?.port}/.

Issues? Report them at https://github.com/firebase/firebase-tools/issues and attach log files named *-debug.log in current directory.
`);

// Add this line above once connect page is implemented
// It is now safe to connect your app. Instructions: http://${guiInfo?.host}:${guiInfo?.port}/connect

// Hang until explicitly killed
await new Promise((res, rej) => {
Expand Down