UNPKG

eas-cli

Version:
74 lines (73 loc) 3.12 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); 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 EasCommand_1 = tslib_1.__importDefault(require("../../commandUtils/EasCommand")); const log_1 = tslib_1.__importDefault(require("../../log")); const resolve_1 = require("../../metadata/config/resolve"); const errors_1 = require("../../metadata/errors"); const json_1 = require("../../utils/json"); const profiles_1 = require("../../utils/profiles"); class MetadataLint extends EasCommand_1.default { static description = 'validate the local store configuration'; static flags = { json: core_1.Flags.boolean({ description: 'Enable JSON output, non-JSON messages will be printed to stderr', default: false, }), profile: core_1.Flags.string({ description: 'Name of the submit profile from eas.json. Defaults to "production" if defined in eas.json.', }), }; static contextDefinition = { // The metadata lint command is created to integrate in other dev tooling, like vscode-expo. // These integrations might spam this command, so we avoid communicating with our services here. // Note that this is an exception and you should normally use `ProjectConfig` instead. ...this.ContextOptions.ProjectDir, }; async runAsync() { const { flags } = await this.parse(MetadataLint); const { projectDir } = await this.getContextAsync(MetadataLint, { nonInteractive: true, }); if (flags.json) { (0, json_1.enableJsonOutput)(); } else { log_1.default.warn('EAS Metadata is in beta and subject to breaking changes.'); } const submitProfiles = await (0, profiles_1.getProfilesAsync)({ type: 'submit', easJsonAccessor: eas_json_1.EasJsonAccessor.fromProjectPath(projectDir), platforms: [eas_build_job_1.Platform.IOS], profileName: flags.profile, projectDir, }); if (submitProfiles.length !== 1) { throw new Error('Metadata only supports iOS and a single submit profile.'); } const submitProfile = submitProfiles[0].profile; try { await (0, resolve_1.loadConfigAsync)({ projectDir, profile: submitProfile }); if (flags.json) { (0, json_1.printJsonOnlyOutput)([]); return; } log_1.default.log('✅ Store configuration is valid.'); } catch (error) { if (!(error instanceof errors_1.MetadataValidationError)) { throw error; } if (flags.json) { (0, json_1.printJsonOnlyOutput)(error.errors); return; } (0, errors_1.logMetadataValidationError)(error); log_1.default.addNewLineIfNone(); } } } exports.default = MetadataLint;