eas-cli
Version:
EAS command line tool
82 lines (81 loc) • 3.93 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.RegistrationMethod = void 0;
const tslib_1 = require("tslib");
const chalk_1 = tslib_1.__importDefault(require("chalk"));
const currentMachineMethod_1 = require("./currentMachineMethod");
const developerPortalMethod_1 = require("./developerPortalMethod");
const inputMethod_1 = require("./inputMethod");
const registrationUrlMethod_1 = require("./registrationUrlMethod");
const log_1 = tslib_1.__importDefault(require("../../../log"));
const prompts_1 = require("../../../prompts");
var RegistrationMethod;
(function (RegistrationMethod) {
RegistrationMethod[RegistrationMethod["WEBSITE"] = 0] = "WEBSITE";
RegistrationMethod[RegistrationMethod["INPUT"] = 1] = "INPUT";
RegistrationMethod[RegistrationMethod["DEVELOPER_PORTAL"] = 2] = "DEVELOPER_PORTAL";
RegistrationMethod[RegistrationMethod["CURRENT_MACHINE"] = 3] = "CURRENT_MACHINE";
RegistrationMethod[RegistrationMethod["EXIT"] = 4] = "EXIT";
})(RegistrationMethod || (exports.RegistrationMethod = RegistrationMethod = {}));
class DeviceCreateAction {
graphqlClient;
appStoreApi;
account;
appleTeam;
constructor(graphqlClient, appStoreApi, account, appleTeam) {
this.graphqlClient = graphqlClient;
this.appStoreApi = appStoreApi;
this.account = account;
this.appleTeam = appleTeam;
}
async runAsync() {
const method = await this.askForRegistrationMethodAsync();
if (method === RegistrationMethod.WEBSITE) {
await (0, registrationUrlMethod_1.runRegistrationUrlMethodAsync)(this.graphqlClient, this.account.id, this.appleTeam);
}
else if (method === RegistrationMethod.DEVELOPER_PORTAL) {
await (0, developerPortalMethod_1.runDeveloperPortalMethodAsync)(this.graphqlClient, this.appStoreApi, this.account, this.appleTeam);
}
else if (method === RegistrationMethod.INPUT) {
await (0, inputMethod_1.runInputMethodAsync)(this.graphqlClient, this.account.id, this.appleTeam);
}
else if (method === RegistrationMethod.CURRENT_MACHINE) {
await (0, currentMachineMethod_1.runCurrentMachineMethodAsync)(this.graphqlClient, this.account.id, this.appleTeam);
}
else if (method === RegistrationMethod.EXIT) {
log_1.default.log('Bye!');
process.exit(0);
}
return method;
}
async askForRegistrationMethodAsync() {
const { method } = await (0, prompts_1.promptAsync)({
type: 'select',
name: 'method',
message: `How would you like to register your devices?`,
choices: [
{
title: `${chalk_1.default.bold('Website')} - generates a registration URL to be opened on your devices`,
value: RegistrationMethod.WEBSITE,
},
{
title: `${chalk_1.default.bold('Developer Portal')} - import devices already registered on Apple Developer Portal`,
value: RegistrationMethod.DEVELOPER_PORTAL,
},
{
title: `${chalk_1.default.bold('Input')} - allows you to type in UDIDs (advanced option)`,
value: RegistrationMethod.INPUT,
},
{
title: `${chalk_1.default.bold('Current Machine')} - automatically sets the provisioning UDID of the current Apple Silicon machine`,
value: RegistrationMethod.CURRENT_MACHINE,
},
{ title: chalk_1.default.bold('Exit'), value: RegistrationMethod.EXIT },
],
validate: (val) => Object.values(RegistrationMethod).includes(val),
initial: RegistrationMethod.WEBSITE,
});
return method;
}
}
exports.default = DeviceCreateAction;
;