UNPKG

eas-cli

Version:
106 lines (105 loc) 5.09 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const config_1 = require("@expo/config"); const eas_build_job_1 = require("@expo/eas-build-job"); const eas_json_1 = require("@expo/eas-json"); const core_1 = require("@oclif/core"); const chalk_1 = tslib_1.__importDefault(require("chalk")); const evaluateConfigWithEnvVarsAsync_1 = require("../build/evaluateConfigWithEnvVarsAsync"); const EasCommand_1 = tslib_1.__importDefault(require("../commandUtils/EasCommand")); const flags_1 = require("../commandUtils/flags"); const AppPlatform_1 = require("../graphql/types/AppPlatform"); const log_1 = tslib_1.__importDefault(require("../log")); const platform_1 = require("../platform"); const prompts_1 = require("../prompts"); const json_1 = require("../utils/json"); class Config extends EasCommand_1.default { static description = 'display project configuration (app.json + eas.json)'; static flags = { platform: core_1.Flags.enum({ char: 'p', options: [eas_build_job_1.Platform.ANDROID, eas_build_job_1.Platform.IOS] }), profile: core_1.Flags.string({ char: 'e', description: 'Name of the build profile from eas.json. Defaults to "production" if defined in eas.json.', helpValue: 'PROFILE_NAME', }), // This option is used only on EAS Build worker to read build profile from eas.json. 'eas-json-only': core_1.Flags.boolean({ hidden: true, }), ...flags_1.EasNonInteractiveAndJsonFlags, }; static contextDefinition = { ...this.ContextOptions.DynamicProjectConfig, ...this.ContextOptions.ProjectDir, ...this.ContextOptions.DynamicLoggedIn, }; async runAsync() { const { flags } = await this.parse(Config); if (flags.json) { (0, json_1.enableJsonOutput)(); } const { platform: maybePlatform, profile: maybeProfile, 'non-interactive': nonInteractive, } = flags; const { getDynamicPublicProjectConfigAsync, projectDir, getDynamicLoggedInAsync } = await this.getContextAsync(Config, { nonInteractive, withServerSideEnvironment: null, }); const accessor = eas_json_1.EasJsonAccessor.fromProjectPath(projectDir); const profileName = maybeProfile ?? (await (0, prompts_1.selectAsync)('Select build profile', (await eas_json_1.EasJsonUtils.getBuildProfileNamesAsync(accessor)).map(profileName => ({ title: profileName, value: profileName, })))); const platform = maybePlatform ?? (await (0, prompts_1.selectAsync)('Select platform', [ { title: 'Android', value: eas_build_job_1.Platform.ANDROID, }, { title: 'iOS', value: eas_build_job_1.Platform.IOS, }, ])); const profile = await eas_json_1.EasJsonUtils.getBuildProfileAsync(accessor, platform, profileName); if (flags['eas-json-only']) { if (flags.json) { (0, json_1.printJsonOnlyOutput)({ buildProfile: profile }); } else { const appPlatform = (0, AppPlatform_1.toAppPlatform)(platform); const platformEmoji = platform_1.appPlatformEmojis[appPlatform]; log_1.default.log(`${platformEmoji} ${chalk_1.default.bold(`Build profile "${profileName}"`)}`); log_1.default.newLine(); log_1.default.log(JSON.stringify(profile, null, 2)); } } else { const { graphqlClient } = await getDynamicLoggedInAsync(); const { exp: appConfig } = await (0, evaluateConfigWithEnvVarsAsync_1.evaluateConfigWithEnvVarsAsync)({ buildProfile: profile, buildProfileName: profileName, graphqlClient, getProjectConfig: getDynamicPublicProjectConfigAsync, opts: { env: profile.env }, }); if (flags.json) { (0, json_1.printJsonOnlyOutput)({ buildProfile: profile, appConfig }); } else { log_1.default.addNewLineIfNone(); log_1.default.log(chalk_1.default.bold((0, config_1.getProjectConfigDescription)(projectDir))); log_1.default.newLine(); log_1.default.log(JSON.stringify(appConfig, null, 2)); log_1.default.newLine(); log_1.default.newLine(); const appPlatform = (0, AppPlatform_1.toAppPlatform)(platform); const platformEmoji = platform_1.appPlatformEmojis[appPlatform]; log_1.default.log(`${platformEmoji} ${chalk_1.default.bold(`Build profile "${profileName}"`)}`); log_1.default.newLine(); log_1.default.log(JSON.stringify(profile, null, 2)); } } } } exports.default = Config;