register.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.RegisterCommand = void 0;
  4. const color_1 = require("../../lib/color");
  5. const command_1 = require("../../lib/command");
  6. const errors_1 = require("../../lib/errors");
  7. const executor_1 = require("../../lib/executor");
  8. class RegisterCommand extends command_1.Command {
  9. async getMetadata() {
  10. return {
  11. name: 'register',
  12. type: 'project',
  13. groups: ["paid" /* MetadataGroup.PAID */],
  14. summary: 'Register your Product Key with this app',
  15. options: [
  16. {
  17. name: 'app-id',
  18. summary: 'The Ionic App ID',
  19. spec: {
  20. value: 'id',
  21. },
  22. },
  23. {
  24. name: 'key',
  25. summary: 'The Product Key',
  26. },
  27. ],
  28. };
  29. }
  30. async run(inputs, options, runinfo) {
  31. if (!this.project) {
  32. throw new errors_1.FatalException(`Cannot run ${(0, color_1.input)('ionic enterprise register')} outside a project directory.`);
  33. }
  34. const appId = options['app-id'] ? String(options['app-id']) : undefined;
  35. const key = options['key'] ? String(options['key']) : undefined;
  36. const extra = ['--'];
  37. if (key) {
  38. extra.push('--key', key);
  39. }
  40. if (appId) {
  41. extra.push('--app-id', appId);
  42. }
  43. await (0, executor_1.runCommand)(runinfo, ['integrations', 'enable', 'enterprise', ...extra.length > 1 ? extra : []]);
  44. }
  45. }
  46. exports.RegisterCommand = RegisterCommand;