Nav apraksta
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.serve = void 0;
  4. const logger_1 = require("../logger");
  5. const frameworks_1 = require("../frameworks");
  6. const experiments = require("../experiments");
  7. const track_1 = require("../track");
  8. const projectUtils_1 = require("../projectUtils");
  9. const constants_1 = require("../emulator/constants");
  10. const config = require("../hosting/config");
  11. const { FunctionsServer } = require("./functions");
  12. const TARGETS = {
  13. hosting: require("./hosting"),
  14. functions: new FunctionsServer(),
  15. };
  16. async function serve(options) {
  17. const targetNames = options.targets || [];
  18. options.port = parseInt(options.port, 10);
  19. if (targetNames.includes("hosting") && config.extract(options).some((it) => it.source)) {
  20. experiments.assertEnabled("webframeworks", "emulate a web framework");
  21. await (0, frameworks_1.prepareFrameworks)(targetNames, options, options);
  22. }
  23. const isDemoProject = constants_1.Constants.isDemoProject((0, projectUtils_1.getProjectId)(options) || "");
  24. targetNames.forEach((targetName) => {
  25. void (0, track_1.trackEmulator)("emulator_run", {
  26. emulator_name: targetName,
  27. is_demo_project: String(isDemoProject),
  28. });
  29. });
  30. await Promise.all(targetNames.map((targetName) => {
  31. return TARGETS[targetName].start(options);
  32. }));
  33. await Promise.all(targetNames.map((targetName) => {
  34. return TARGETS[targetName].connect();
  35. }));
  36. void (0, track_1.trackEmulator)("emulators_started", {
  37. count: targetNames.length,
  38. count_all: targetNames.length,
  39. is_demo_project: String(isDemoProject),
  40. });
  41. await new Promise((resolve) => {
  42. process.on("SIGINT", () => {
  43. logger_1.logger.info("Shutting down...");
  44. Promise.all(targetNames.map((targetName) => {
  45. return TARGETS[targetName].stop(options);
  46. }))
  47. .then(resolve)
  48. .catch(resolve);
  49. });
  50. });
  51. }
  52. exports.serve = serve;