UNPKG

eas-cli

Version:

EAS command line tool

39 lines (38 loc) 1.77 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SelectBuildProfileFromEasJson = void 0; const tslib_1 = require("tslib"); const eas_json_1 = require("@expo/eas-json"); const log_1 = tslib_1.__importDefault(require("../../log")); const prompts_1 = require("../../prompts"); class SelectBuildProfileFromEasJson { platform; easJsonAccessor; constructor(projectDir, platform) { this.platform = platform; this.easJsonAccessor = eas_json_1.EasJsonAccessor.fromProjectPath(projectDir); } async runAsync() { const profileName = await this.getProfileNameFromEasConfigAsync(); const easConfig = await eas_json_1.EasJsonUtils.getBuildProfileAsync(this.easJsonAccessor, this.platform, profileName); log_1.default.succeed(`Using build profile: ${profileName}`); return easConfig; } async getProfileNameFromEasConfigAsync() { const buildProfileNames = await eas_json_1.EasJsonUtils.getBuildProfileNamesAsync(this.easJsonAccessor); if (buildProfileNames.length === 0) { throw new Error('You need at least one iOS build profile declared in eas.json. Go to https://docs.expo.dev/build/eas-json/ for more details'); } else if (buildProfileNames.length === 1) { return buildProfileNames[0]; } const { profileName } = await (0, prompts_1.promptAsync)({ type: 'select', name: 'profileName', message: 'Which build profile do you want to configure?', choices: buildProfileNames.map(profileName => ({ value: profileName, title: profileName })), }); return profileName; } } exports.SelectBuildProfileFromEasJson = SelectBuildProfileFromEasJson;