UNPKG

eas-cli

Version:
75 lines (74 loc) 3.07 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.uploadMetadataAsync = void 0; const tslib_1 = require("tslib"); const tasks_1 = require("./apple/tasks"); const auth_1 = require("./auth"); const resolve_1 = require("./config/resolve"); const errors_1 = require("./errors"); const telemetry_1 = require("./utils/telemetry"); const AnalyticsManager_1 = require("../analytics/AnalyticsManager"); const log_1 = tslib_1.__importDefault(require("../log")); const prompts_1 = require("../prompts"); /** * Sync a local store configuration with the stores. * Note, only App Store is supported at this time. */ async function uploadMetadataAsync({ projectDir, profile, exp, analytics, credentialsCtx, }) { const storeConfig = await loadConfigWithValidationPromptAsync(projectDir, profile); const { app, auth } = await (0, auth_1.getAppStoreAuthAsync)({ exp, credentialsCtx, projectDir, profile, }); const { unsubscribeTelemetry, executionId } = (0, telemetry_1.subscribeTelemetry)(analytics, AnalyticsManager_1.MetadataEvent.APPLE_METADATA_UPLOAD, { app, auth }); log_1.default.addNewLineIfNone(); log_1.default.log('Uploading App Store configuration...'); const errors = []; const config = (0, resolve_1.createAppleReader)(storeConfig); const tasks = (0, tasks_1.createAppleTasks)({ // We need to resolve a different version as soon as possible. // This version is the parent model of all changes we are going to push. version: config.getVersion()?.versionString, }); const taskCtx = { app }; for (const task of tasks) { try { await task.prepareAsync({ context: taskCtx }); } catch (error) { errors.push(error); } } for (const task of tasks) { try { await task.uploadAsync({ config, context: taskCtx }); } catch (error) { errors.push(error); } } unsubscribeTelemetry(); if (errors.length > 0) { throw new errors_1.MetadataUploadError(errors, executionId); } return { appleLink: `https://appstoreconnect.apple.com/apps/${app.id}/appstore` }; } exports.uploadMetadataAsync = uploadMetadataAsync; async function loadConfigWithValidationPromptAsync(projectDir, profile) { try { return await (0, resolve_1.loadConfigAsync)({ projectDir, profile }); } catch (error) { if (error instanceof errors_1.MetadataValidationError) { (0, errors_1.logMetadataValidationError)(error); log_1.default.newLine(); log_1.default.warn('Without further updates, the current store configuration can fail to be synchronized with the App Store or pass App Store review.'); if (await (0, prompts_1.confirmAsync)({ message: 'Do you still want to push the store configuration?' })) { return await (0, resolve_1.loadConfigAsync)({ projectDir, profile, skipValidation: true }); } } throw error; } }