GSI - Employe Self Service Mobile
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.

53 lines
2.4 KiB

2 months ago
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.command = void 0;
  4. const colorette_1 = require("colorette");
  5. const utils_1 = require("../utils");
  6. const command_1 = require("../command");
  7. const api_1 = require("../hosting/api");
  8. const prompt_1 = require("../prompt");
  9. const error_1 = require("../error");
  10. const requirePermissions_1 = require("../requirePermissions");
  11. const projectUtils_1 = require("../projectUtils");
  12. const logger_1 = require("../logger");
  13. const LOG_TAG = "hosting:sites";
  14. exports.command = new command_1.Command("hosting:sites:create [siteId]")
  15. .description("create a Firebase Hosting site")
  16. .option("--app <appId>", "specify an existing Firebase Web App ID")
  17. .before(requirePermissions_1.requirePermissions, ["firebasehosting.sites.update"])
  18. .action(async (siteId, options) => {
  19. const projectId = (0, projectUtils_1.needProjectId)(options);
  20. const appId = options.app;
  21. if (!siteId) {
  22. if (options.nonInteractive) {
  23. throw new error_1.FirebaseError(`"siteId" argument must be provided in a non-interactive environment`);
  24. }
  25. siteId = await (0, prompt_1.promptOnce)({
  26. type: "input",
  27. message: "Please provide an unique, URL-friendly id for the site (<id>.web.app):",
  28. validate: (s) => s.length > 0,
  29. });
  30. }
  31. if (!siteId) {
  32. throw new error_1.FirebaseError(`"siteId" must not be empty`);
  33. }
  34. let site;
  35. try {
  36. site = await (0, api_1.createSite)(projectId, siteId, appId);
  37. }
  38. catch (e) {
  39. if (e.status === 409) {
  40. throw new error_1.FirebaseError(`Site ${(0, colorette_1.bold)(siteId)} already exists in project ${(0, colorette_1.bold)(projectId)}.`, { original: e });
  41. }
  42. throw e;
  43. }
  44. logger_1.logger.info();
  45. (0, utils_1.logLabeledSuccess)(LOG_TAG, `Site ${(0, colorette_1.bold)(siteId)} has been created in project ${(0, colorette_1.bold)(projectId)}.`);
  46. if (appId) {
  47. (0, utils_1.logLabeledSuccess)(LOG_TAG, `Site ${(0, colorette_1.bold)(siteId)} has been linked to web app ${(0, colorette_1.bold)(appId)}`);
  48. }
  49. (0, utils_1.logLabeledSuccess)(LOG_TAG, `Site URL: ${site.defaultUrl}`);
  50. logger_1.logger.info();
  51. logger_1.logger.info(`To deploy to this site, follow the guide at https://firebase.google.com/docs/hosting/multisites.`);
  52. return site;
  53. });