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.

prepare.js 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.prepare = void 0;
  4. const error_1 = require("../../error");
  5. const api = require("../../hosting/api");
  6. const config = require("../../hosting/config");
  7. const deploymentTool = require("../../deploymentTool");
  8. const functional_1 = require("../../functional");
  9. const track_1 = require("../../track");
  10. async function prepare(context, options) {
  11. if (options.public) {
  12. if (Array.isArray(options.config.get("hosting"))) {
  13. throw new error_1.FirebaseError("Cannot specify --public option with multi-site configuration.");
  14. }
  15. options.config.set("hosting.public", options.public);
  16. }
  17. const configs = config.hostingConfig(options);
  18. if (configs.length === 0) {
  19. return Promise.resolve();
  20. }
  21. const versions = await Promise.all(configs.map(async (config) => {
  22. const labels = Object.assign({}, deploymentTool.labels());
  23. if (config.webFramework) {
  24. labels["firebase-web-framework"] = config.webFramework;
  25. }
  26. const version = {
  27. status: "CREATED",
  28. labels,
  29. };
  30. const [, versionName] = await Promise.all([
  31. (0, track_1.track)("hosting_deploy", config.webFramework || "classic"),
  32. api.createVersion(config.site, version),
  33. ]);
  34. return versionName;
  35. }));
  36. context.hosting = {
  37. deploys: [],
  38. };
  39. for (const [config, version] of configs.map((0, functional_1.zipIn)(versions))) {
  40. context.hosting.deploys.push({ config, version });
  41. }
  42. }
  43. exports.prepare = prepare;