No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ui.js 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.EmulatorUI = void 0;
  4. const types_1 = require("./types");
  5. const downloadableEmulators = require("./downloadableEmulators");
  6. const registry_1 = require("./registry");
  7. const error_1 = require("../error");
  8. const constants_1 = require("./constants");
  9. const track_1 = require("../track");
  10. const ExpressBasedEmulator_1 = require("./ExpressBasedEmulator");
  11. class EmulatorUI {
  12. constructor(args) {
  13. this.args = args;
  14. }
  15. start() {
  16. if (!registry_1.EmulatorRegistry.isRunning(types_1.Emulators.HUB)) {
  17. throw new error_1.FirebaseError(`Cannot start ${constants_1.Constants.description(types_1.Emulators.UI)} without ${constants_1.Constants.description(types_1.Emulators.HUB)}!`);
  18. }
  19. const { auto_download: autoDownload, projectId } = this.args;
  20. const env = {
  21. LISTEN: JSON.stringify(ExpressBasedEmulator_1.ExpressBasedEmulator.listenOptionsFromSpecs(this.args.listen)),
  22. GCLOUD_PROJECT: projectId,
  23. [constants_1.Constants.FIREBASE_EMULATOR_HUB]: registry_1.EmulatorRegistry.url(types_1.Emulators.HUB).host,
  24. };
  25. const session = (0, track_1.emulatorSession)();
  26. if (session) {
  27. env[constants_1.Constants.FIREBASE_GA_SESSION] = JSON.stringify(session);
  28. }
  29. return downloadableEmulators.start(types_1.Emulators.UI, { auto_download: autoDownload }, env);
  30. }
  31. connect() {
  32. return Promise.resolve();
  33. }
  34. stop() {
  35. return downloadableEmulators.stop(types_1.Emulators.UI);
  36. }
  37. getInfo() {
  38. return {
  39. name: this.getName(),
  40. host: this.args.listen[0].address,
  41. port: this.args.listen[0].port,
  42. pid: downloadableEmulators.getPID(types_1.Emulators.UI),
  43. };
  44. }
  45. getName() {
  46. return types_1.Emulators.UI;
  47. }
  48. }
  49. exports.EmulatorUI = EmulatorUI;