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.

47 lines
2.7 KiB

2 months ago
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.command = void 0;
  4. const clc = require("colorette");
  5. const { marked } = require("marked");
  6. const command_1 = require("../command");
  7. const extensionsApi_1 = require("../extensions/extensionsApi");
  8. const projectUtils_1 = require("../projectUtils");
  9. const prompt_1 = require("../prompt");
  10. const extensionsHelper_1 = require("../extensions/extensionsHelper");
  11. const askUserForConsent_1 = require("../extensions/askUserForConsent");
  12. const requirePermissions_1 = require("../requirePermissions");
  13. const error_1 = require("../error");
  14. const utils = require("../utils");
  15. exports.command = new command_1.Command("ext:dev:register")
  16. .description("register a publisher ID; run this before publishing your first extension.")
  17. .before(requirePermissions_1.requirePermissions, ["firebaseextensions.sources.create"])
  18. .before(extensionsHelper_1.ensureExtensionsApiEnabled)
  19. .action(async (options) => {
  20. await (0, askUserForConsent_1.promptForPublisherTOS)();
  21. const projectId = (0, projectUtils_1.needProjectId)(options);
  22. const msg = "What would you like to register as your publisher ID? " +
  23. "This value identifies you in Firebase's registry of extensions as the author of your extensions. " +
  24. "Examples: my-company-name, MyGitHubUsername.\n\n" +
  25. "You can only do this once for each project.";
  26. const publisherId = await (0, prompt_1.promptOnce)({
  27. name: "publisherId",
  28. type: "input",
  29. message: msg,
  30. default: projectId,
  31. });
  32. try {
  33. await (0, extensionsApi_1.registerPublisherProfile)(projectId, publisherId);
  34. }
  35. catch (err) {
  36. if (err.status === 409) {
  37. const error = `Couldn't register the publisher ID '${clc.bold(publisherId)}' to the project '${clc.bold(projectId)}'.` +
  38. " This can happen for either of two reasons:\n\n" +
  39. ` - Publisher ID '${clc.bold(publisherId)}' is registered to another project\n` +
  40. ` - Project '${clc.bold(projectId)}' already has a publisher ID\n\n` +
  41. ` Try again with a unique publisher ID or a new project. If your business’s name has been registered to another project, contact Firebase support ${marked("(https://firebase.google.com/support/troubleshooter/contact).")}`;
  42. throw new error_1.FirebaseError(error, { exit: 1 });
  43. }
  44. throw new error_1.FirebaseError(`Failed to register publisher ID ${clc.bold(publisherId)} for project ${clc.bold(projectId)}: ${err.message}`);
  45. }
  46. return utils.logLabeledSuccess(extensionsHelper_1.logPrefix, `Publisher ID '${clc.bold(publisherId)}' has been registered to project ${clc.bold(projectId)}`);
  47. });