Skip to content
This repository has been archived by the owner on Jan 18, 2024. It is now read-only.

Commit

Permalink
[expo-cli] EAS Build deprecation info (#2639)
Browse files Browse the repository at this point in the history
* [expo-cli] deprecation info

* update CHANGELOG.md

* review feedback
  • Loading branch information
wkozyra95 authored Sep 15, 2020
1 parent 41f8d0a commit 0809d99
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ This is the log of notable changes to Expo CLI and related packages.

### 🎉 New features

- [expo-cli] EAS Build: Improve errors and wanrings when deprecating API [#2639](https://github.com/expo/expo-cli/pull/2639)

### 🐛 Bug fixes

## [Wed, 9 Sep 2020 13:28:10 -0700](https://github.com/expo/expo-cli/commit/7b9b00b12095ce6ea5c02c03f793fcc6bf0f55a7)
Expand Down
8 changes: 6 additions & 2 deletions packages/expo-cli/src/commands/eas-build/build/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import {
ensureGitStatusIsCleanAsync,
makeProjectTarballAsync,
} from '../utils/git';
import { printBuildResults, printLogsUrls } from '../utils/misc';
import { printBuildResults, printDeprecationWarnings, printLogsUrls } from '../utils/misc';
import AndroidBuilder from './builders/AndroidBuilder';
import iOSBuilder from './builders/iOSBuilder';
import { collectMetadata } from './metadata';
Expand Down Expand Up @@ -205,17 +205,21 @@ async function startBuildAsync<T extends Platform>(
log(`Starting ${platformDisplayNames[job.platform]} build`);

try {
const { buildId } = await client.postAsync(`projects/${projectId}/builds`, {
const { buildId, deprecationInfo } = await client.postAsync(`projects/${projectId}/builds`, {
job,
metadata,
} as any);
printDeprecationWarnings(deprecationInfo);
Analytics.logEvent(AnalyticsEvent.BUILD_REQUEST_SUCCESS, builder.ctx.trackingCtx.properties);
return buildId;
} catch (error) {
Analytics.logEvent(AnalyticsEvent.BUILD_REQUEST_FAIL, {
...builder.ctx.trackingCtx,
reason: error.message,
});
if (error.code === 'TURTLE_DEPRECATED_JOB_FORMAT') {
log.error('EAS Build API changed, upgrade to latest expo-cli');
}
throw error;
}
} finally {
Expand Down
27 changes: 26 additions & 1 deletion packages/expo-cli/src/commands/eas-build/utils/misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ import * as UrlUtils from '../../utils/url';
import { platformDisplayNames } from '../constants';
import { Build } from '../types';

export interface DeprecationInfo {
type: 'user-facing' | 'internal';
message: string;
}

async function printLogsUrls(
accountName: string,
builds: { platform: 'android' | 'ios'; buildId: string }[]
Expand Down Expand Up @@ -46,4 +51,24 @@ async function printBuildResults(builds: (Build | null)[]): Promise<void> {
}
}

export { printLogsUrls, printBuildResults };
function printDeprecationWarnings(deprecationInfo?: DeprecationInfo): void {
if (!deprecationInfo) {
return;
}
if (deprecationInfo.type === 'internal') {
log.warn('This command is using API that soon will be deprecated, please update expo-cli.');
log.warn("Changes won't affect your project confiuration.");
log.warn(deprecationInfo.message);
} else if (deprecationInfo.type === 'user-facing') {
log.warn('This command is using API that soon will be deprecated, please update expo-cli.');
log.warn(
'There might be some changes necessary to your project configuration, latest expo-cli will provide more specific error messages.'
);
log.warn(deprecationInfo.message);
} else {
log.warn('An unexpected warning was encountered. Please report it as a bug:');
log.warn(deprecationInfo);
}
}

export { printLogsUrls, printBuildResults, printDeprecationWarnings };

0 comments on commit 0809d99

Please sign in to comment.