eas-cli
Version:
EAS command line tool
64 lines (63 loc) • 2.58 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.runInputMethodAsync = void 0;
const tslib_1 = require("tslib");
const chalk_1 = tslib_1.__importDefault(require("chalk"));
const utils_1 = require("./utils");
const AppleDeviceMutation_1 = require("../../../credentials/ios/api/graphql/mutations/AppleDeviceMutation");
const log_1 = tslib_1.__importDefault(require("../../../log"));
const ora_1 = require("../../../ora");
const prompts_1 = require("../../../prompts");
async function runInputMethodAsync(graphqlClient, accountId, appleTeam) {
log_1.default.newLine();
log_1.default.log(chalk_1.default.yellow('This is an advanced option. Use at your own risk.'));
log_1.default.newLine();
let registerNextDevice = true;
while (registerNextDevice) {
await collectDataAndRegisterDeviceAsync(graphqlClient, { accountId, appleTeam });
log_1.default.newLine();
registerNextDevice = await (0, prompts_1.confirmAsync)({
message: 'Do you want to register another device?',
});
}
}
exports.runInputMethodAsync = runInputMethodAsync;
async function collectDataAndRegisterDeviceAsync(graphqlClient, { accountId, appleTeam, }) {
const { udid, deviceClass, name } = await collectDeviceDataAsync(appleTeam);
const spinner = (0, ora_1.ora)(`Registering Apple device on EAS`).start();
try {
await AppleDeviceMutation_1.AppleDeviceMutation.createAppleDeviceAsync(graphqlClient, {
appleTeamId: appleTeam.id,
identifier: udid,
name,
deviceClass: deviceClass ?? undefined,
}, accountId);
}
catch (err) {
spinner.fail();
throw err;
}
spinner.succeed();
}
async function collectDeviceDataAsync(appleTeam, initialValues = {}) {
const udid = await (0, utils_1.promptForUDIDAsync)(initialValues.udid);
const name = await (0, utils_1.promptForNameAsync)(initialValues.name);
const deviceClass = await (0, utils_1.promptForDeviceClassAsync)(initialValues.deviceClass);
const deviceData = {
udid,
name,
deviceClass,
};
(0, utils_1.printDeviceData)(deviceData, appleTeam);
const registrationConfirmed = await (0, prompts_1.confirmAsync)({
message: 'Is this what you want to register?',
});
if (!registrationConfirmed) {
log_1.default.log('No worries, just try again.');
log_1.default.newLine();
return await collectDeviceDataAsync(appleTeam, deviceData);
}
else {
return deviceData;
}
}
;