Skip to content

Commit

Permalink
[eas-cli] Update download and upload metadata methods to new ctx
Browse files Browse the repository at this point in the history
  • Loading branch information
byCedric committed Jun 3, 2022
1 parent 3ee9d72 commit 19c7263
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
14 changes: 6 additions & 8 deletions packages/eas-cli/src/metadata/download.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,28 @@ import { subscribeTelemetry } from './utils/telemetry';
* Generate a local store configuration from the stores.
* Note, only App Store is supported at this time.
*/
export async function downloadMetadataAsync(metadataContext: MetadataContext): Promise<string> {
const filePath = path.resolve(metadataContext.projectDir, metadataContext.metadataFile);
export async function downloadMetadataAsync(metadataCtx: MetadataContext): Promise<string> {
const filePath = path.resolve(metadataCtx.projectDir, metadataCtx.metadataPath);
const fileExists = await fs.pathExists(filePath);

if (fileExists && metadataContext.nonInteractive) {
throw new MetadataValidationError(`Store configuration already exists at "${filePath}"`);
} else if (fileExists) {
if (fileExists) {
const overwrite = await confirmAsync({
message: `Do you want to overwrite the existing store configuration "${metadataContext.metadataFile}"?`,
message: `Do you want to overwrite the existing store configuration "${metadataCtx.metadataPath}"?`,
});
if (!overwrite) {
throw new MetadataValidationError(`Store configuration already exists at "${filePath}"`);
}
}

const { app, auth } = await ensureMetadataAppStoreAuthenticatedAsync(metadataContext);
const { app, auth } = await ensureMetadataAppStoreAuthenticatedAsync(metadataCtx);
const { unsubscribeTelemetry, executionId } = subscribeTelemetry(
MetadataEvent.APPLE_METADATA_DOWNLOAD,
{ app, auth }
);

const errors: Error[] = [];
const config = createAppleWriter();
const tasks = createAppleTasks(metadataContext);
const tasks = createAppleTasks(metadataCtx);
const taskCtx = { app };

for (const task of tasks) {
Expand Down
8 changes: 4 additions & 4 deletions packages/eas-cli/src/metadata/upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ import { subscribeTelemetry } from './utils/telemetry';
* Sync a local store configuration with the stores.
* Note, only App Store is supported at this time.
*/
export async function uploadMetadataAsync(metadataContext: MetadataContext): Promise<void> {
const filePath = path.resolve(metadataContext.projectDir, metadataContext.metadataFile);
export async function uploadMetadataAsync(metadataCtx: MetadataContext): Promise<void> {
const filePath = path.resolve(metadataCtx.projectDir, metadataCtx.metadataPath);
if (!(await fs.pathExists(filePath))) {
throw new MetadataValidationError(`Store configuration file not found "${filePath}"`);
}

const { app, auth } = await ensureMetadataAppStoreAuthenticatedAsync(metadataContext);
const { app, auth } = await ensureMetadataAppStoreAuthenticatedAsync(metadataCtx);
const { unsubscribeTelemetry, executionId } = subscribeTelemetry(
MetadataEvent.APPLE_METADATA_UPLOAD,
{ app, auth }
Expand All @@ -33,7 +33,7 @@ export async function uploadMetadataAsync(metadataContext: MetadataContext): Pro

const errors: Error[] = [];
const config = createAppleReader(fileData);
const tasks = createAppleTasks(metadataContext);
const tasks = createAppleTasks(metadataCtx);
const taskCtx = { app };

for (const task of tasks) {
Expand Down

0 comments on commit 19c7263

Please sign in to comment.