Skip to content

Commit

Permalink
[eas-cli] Upgrade packages from the expo/expo repo
Browse files Browse the repository at this point in the history
  • Loading branch information
wschurman committed Jan 4, 2024
1 parent 2dab784 commit 92adc6d
Show file tree
Hide file tree
Showing 18 changed files with 135 additions and 181 deletions.
8 changes: 4 additions & 4 deletions packages/eas-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
"dependencies": {
"@expo/apple-utils": "1.3.2",
"@expo/code-signing-certificates": "0.0.5",
"@expo/config": "8.1.2",
"@expo/config-plugins": "7.2.4",
"@expo/config-types": "49.0.0",
"@expo/config": "8.5.2",
"@expo/config-plugins": "7.8.2",
"@expo/config-types": "50.0.0",
"@expo/eas-build-job": "1.0.50",
"@expo/eas-json": "5.9.3",
"@expo/json-file": "8.2.37",
Expand All @@ -23,7 +23,7 @@
"@expo/plist": "0.0.20",
"@expo/plugin-help": "5.1.23",
"@expo/plugin-warn-if-update-available": "2.5.1",
"@expo/prebuild-config": "6.2.5",
"@expo/prebuild-config": "6.7.2",
"@expo/results": "1.0.0",
"@expo/rudder-sdk-node": "1.1.1",
"@expo/spawn-async": "1.7.0",
Expand Down
8 changes: 6 additions & 2 deletions packages/eas-cli/src/build/android/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,9 @@ export async function resolveRemoteVersionCodeAsync(
applicationIdentifier: applicationId,
storeVersion: localVersions.appVersion ?? exp.version ?? '1.0.0',
buildVersion: currentBuildVersion,
runtimeVersion: Updates.getRuntimeVersionNullable(exp, Platform.ANDROID) ?? undefined,
runtimeVersion:
(await Updates.getRuntimeVersionNullableAsync(projectDir, exp, Platform.ANDROID)) ??
undefined,
});
spinner.succeed(`Initialized versionCode with ${chalk.bold(currentBuildVersion)}.`);
} catch (err) {
Expand All @@ -254,7 +256,9 @@ export async function resolveRemoteVersionCodeAsync(
applicationIdentifier: applicationId,
storeVersion: localVersions.appVersion ?? exp.version ?? '1.0.0',
buildVersion: String(nextBuildVersion),
runtimeVersion: Updates.getRuntimeVersionNullable(exp, Platform.ANDROID) ?? undefined,
runtimeVersion:
(await Updates.getRuntimeVersionNullableAsync(projectDir, exp, Platform.ANDROID)) ??
undefined,
});
spinner.succeed(
`Incremented versionCode from ${chalk.bold(currentBuildVersion)} to ${chalk.bold(
Expand Down
8 changes: 6 additions & 2 deletions packages/eas-cli/src/build/ios/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,9 @@ export async function resolveRemoteBuildNumberAsync(
applicationIdentifier: applicationTarget.bundleIdentifier,
storeVersion: localShortVersion ?? '1.0.0',
buildVersion: currentBuildVersion,
runtimeVersion: Updates.getRuntimeVersionNullable(exp, Platform.IOS) ?? undefined,
runtimeVersion:
(await Updates.getRuntimeVersionNullableAsync(projectDir, exp, Platform.IOS)) ??
undefined,
});
spinner.succeed(`Initialized buildNumber with ${chalk.bold(currentBuildVersion)}.`);
} catch (err) {
Expand All @@ -364,7 +366,9 @@ export async function resolveRemoteBuildNumberAsync(
applicationIdentifier: applicationTarget.bundleIdentifier,
storeVersion: localShortVersion ?? '1.0.0',
buildVersion: nextBuildVersion,
runtimeVersion: Updates.getRuntimeVersionNullable(exp, Platform.IOS) ?? undefined,
runtimeVersion:
(await Updates.getRuntimeVersionNullableAsync(projectDir, exp, Platform.IOS)) ??
undefined,
});
spinner.succeed(
`Incremented buildNumber from ${chalk.bold(currentBuildVersion)} to ${chalk.bold(
Expand Down
4 changes: 3 additions & 1 deletion packages/eas-cli/src/build/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ export async function collectMetadataAsync<T extends Platform>(
workflow: ctx.workflow,
credentialsSource: ctx.buildProfile.credentialsSource,
sdkVersion: ctx.exp.sdkVersion,
runtimeVersion: Updates.getRuntimeVersionNullable(ctx.exp, ctx.platform) ?? undefined,
runtimeVersion:
(await Updates.getRuntimeVersionNullableAsync(ctx.projectDir, ctx.exp, ctx.platform)) ??
undefined,
reactNativeVersion: await getReactNativeVersionAsync(ctx.projectDir),
...channelOrReleaseChannel,
distribution,
Expand Down
11 changes: 1 addition & 10 deletions packages/eas-cli/src/commands/build/configure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@ import { isExpoUpdatesInstalled, isUsingEASUpdate } from '../../project/projectU
import { resolveWorkflowAsync } from '../../project/workflow';
import { promptAsync } from '../../prompts';
import { syncUpdatesConfigurationAsync as syncAndroidUpdatesConfigurationAsync } from '../../update/android/UpdatesModule';
import {
ensureEASUpdateIsConfiguredInEasJsonAsync,
ensureUseClassicUpdatesIsRemovedAsync,
} from '../../update/configure';
import { ensureEASUpdateIsConfiguredInEasJsonAsync } from '../../update/configure';
import { syncUpdatesConfigurationAsync as syncIosUpdatesConfigurationAsync } from '../../update/ios/UpdatesModule';

export default class BuildConfigure extends EasCommand {
Expand Down Expand Up @@ -70,12 +67,6 @@ export default class BuildConfigure extends EasCommand {
vcsClient,
});
if (didCreateEasJson && isUsingEASUpdate(exp, projectId)) {
if (exp.updates?.useClassicUpdates) {
// NOTE: this method modifies the Expo config; be sure to use this function's return value
// if the config object is used later in the future
await ensureUseClassicUpdatesIsRemovedAsync({ exp, projectDir });
}

await ensureEASUpdateIsConfiguredInEasJsonAsync(projectDir);
}

Expand Down
5 changes: 3 additions & 2 deletions packages/eas-cli/src/commands/build/version/set.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getRuntimeVersionNullable } from '@expo/config-plugins/build/utils/Updates';
import { getRuntimeVersionNullableAsync } from '@expo/config-plugins/build/utils/Updates';
import { Platform } from '@expo/eas-build-job';
import { EasJsonAccessor, EasJsonUtils } from '@expo/eas-json';
import { Flags } from '@oclif/core';
Expand Down Expand Up @@ -116,7 +116,8 @@ export default class BuildVersionSetView extends EasCommand {
applicationIdentifier,
storeVersion: exp.version ?? '1.0.0',
buildVersion: String(version),
runtimeVersion: getRuntimeVersionNullable(exp, platform) ?? undefined,
runtimeVersion:
(await getRuntimeVersionNullableAsync(projectDir, exp, platform)) ?? undefined,
});
}
}
Expand Down
5 changes: 2 additions & 3 deletions packages/eas-cli/src/commands/channel/rollout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export default class ChannelRollout extends EasCommand {
const { args, flags } = await this.parse(ChannelRollout);
const argsAndFlags = this.sanitizeArgsAndFlags({ ...flags, ...args });
const {
privateProjectConfig: { exp, projectId },
privateProjectConfig: { exp, projectId, projectDir },
loggedIn: { graphqlClient },
} = await this.getContextAsync(ChannelRollout, {
nonInteractive: argsAndFlags.nonInteractive,
Expand All @@ -141,9 +141,8 @@ export default class ChannelRollout extends EasCommand {
enableJsonOutput();
}

const app = { projectId, exp };
const app = { projectId, exp, projectDir };
const ctx = {
projectId,
nonInteractive: argsAndFlags.nonInteractive,
graphqlClient,
app,
Expand Down
30 changes: 0 additions & 30 deletions packages/eas-cli/src/commands/update/__tests__/configure.test.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ function mockTestExport({
uniqueUploadedAssetPaths: [],
});

jest.mocked(Updates.getRuntimeVersion).mockReturnValue(runtimeVersion);
jest.mocked(Updates.getRuntimeVersionAsync).mockResolvedValue(runtimeVersion);

return { inputDir: exportDir, platforms, runtimeVersion };
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ describe(UpdateRollBackToEmbedded.name, () => {
mockTestProject();
const platforms = ['android', 'ios'];
const runtimeVersion = 'exposdk:47.0.0';
jest.mocked(Updates.getRuntimeVersion).mockReturnValue(runtimeVersion);
jest.mocked(Updates.getRuntimeVersionAsync).mockResolvedValue(runtimeVersion);

jest.mocked(ensureBranchExistsAsync).mockResolvedValue({
branchId: 'branch123',
Expand All @@ -106,7 +106,7 @@ describe(UpdateRollBackToEmbedded.name, () => {
const { projectId } = mockTestProject();
const platforms = ['android', 'ios'];
const runtimeVersion = 'exposdk:47.0.0';
jest.mocked(Updates.getRuntimeVersion).mockReturnValue(runtimeVersion);
jest.mocked(Updates.getRuntimeVersionAsync).mockResolvedValue(runtimeVersion);

jest.mocked(getBranchNameFromChannelNameAsync).mockResolvedValue('branchFromChannel');
jest.mocked(ensureBranchExistsAsync).mockResolvedValue({
Expand Down Expand Up @@ -154,7 +154,7 @@ describe(UpdateRollBackToEmbedded.name, () => {

const platforms = ['ios'];
const runtimeVersion = 'exposdk:47.0.0';
jest.mocked(Updates.getRuntimeVersion).mockReturnValue(runtimeVersion);
jest.mocked(Updates.getRuntimeVersionAsync).mockResolvedValue(runtimeVersion);

// Mock an existing branch, so we don't create a new one
jest.mocked(ensureBranchExistsAsync).mockResolvedValue({
Expand Down
2 changes: 1 addition & 1 deletion packages/eas-cli/src/eas-update/__tests__/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ export function createCtxMock(options: { nonInteractive?: boolean } = {}): EASUp
return {
graphqlClient: jest.fn() as any,
nonInteractive: options.nonInteractive ?? false,
app: { exp: testAppJson, projectId: 'test-project-id' },
app: { exp: testAppJson, projectId: 'test-project-id', projectDir: '/' },
};
}
2 changes: 1 addition & 1 deletion packages/eas-cli/src/eas-update/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ExpoGraphqlClient } from '../commandUtils/context/contextUtils/createGr
export type EASUpdateContext = {
graphqlClient: ExpoGraphqlClient;
nonInteractive: boolean;
app: { exp: ExpoConfig; projectId: string };
app: { exp: ExpoConfig; projectId: string; projectDir: string };
};

export interface EASUpdateAction<T = any> {
Expand Down
30 changes: 16 additions & 14 deletions packages/eas-cli/src/project/publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -711,20 +711,22 @@ export async function getRuntimeVersionObjectAsync(
}
}

return [...new Set(platforms)].map(platform => {
if (platform === 'web') {
return { platform: 'web', runtimeVersion: 'UNVERSIONED' };
}
return {
platform,
runtimeVersion: nullthrows(
Updates.getRuntimeVersion(exp, platform),
`Unable to determine runtime version for ${
requestedPlatformDisplayNames[platform]
}. ${learnMore('https://docs.expo.dev/eas-update/runtime-versions/')}`
),
};
});
return await Promise.all(
[...new Set(platforms)].map(async platform => {
if (platform === 'web') {
return { platform: 'web', runtimeVersion: 'UNVERSIONED' };
}
return {
platform,
runtimeVersion: nullthrows(
await Updates.getRuntimeVersionAsync(projectDir, exp, platform),
`Unable to determine runtime version for ${
requestedPlatformDisplayNames[platform]
}. ${learnMore('https://docs.expo.dev/eas-update/runtime-versions/')}`
),
};
})
);
}

export function getRuntimeToPlatformMappingFromRuntimeVersions(
Expand Down
10 changes: 7 additions & 3 deletions packages/eas-cli/src/rollout/actions/CreateRollout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,9 +272,13 @@ export class CreateRollout implements EASUpdateAction<UpdateChannelBasicInfoFrag

async selectRuntimeVersionFromProjectConfigAsync(ctx: EASUpdateContext): Promise<string> {
const platforms: ('ios' | 'android')[] = ['ios', 'android'];
const runtimes = platforms
.map(platform => Updates.getRuntimeVersion(ctx.app.exp, platform))
.filter(truthy);
const runtimes = (
await Promise.all(
platforms.map(platform =>
Updates.getRuntimeVersionAsync(ctx.app.projectDir, ctx.app.exp, platform)
)
)
).filter(truthy);
const dedupedRuntimes = [...new Set(runtimes)];

if (dedupedRuntimes.length === 0) {
Expand Down
18 changes: 9 additions & 9 deletions packages/eas-cli/src/update/android/UpdatesModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { AndroidConfig, AndroidManifest, XML } from '@expo/config-plugins';

import { ExpoGraphqlClient } from '../../commandUtils/context/contextUtils/createGraphqlClient';
import { RequestedPlatform } from '../../platform';
import { getOwnerAccountForProjectIdAsync } from '../../project/projectUtils';
import { ensureValidVersions } from '../utils';

/**
Expand All @@ -16,16 +15,14 @@ export async function syncUpdatesConfigurationAsync(
projectId: string
): Promise<void> {
ensureValidVersions(exp, RequestedPlatform.Android);
const accountName = (await getOwnerAccountForProjectIdAsync(graphqlClient, projectId)).name;

// sync AndroidManifest.xml
const androidManifestPath = await AndroidConfig.Paths.getAndroidManifestAsync(projectDir);
const androidManifest = await getAndroidManifestAsync(projectDir);
const updatedAndroidManifest = AndroidConfig.Updates.setUpdatesConfig(
const updatedAndroidManifest = await AndroidConfig.Updates.setUpdatesConfigAsync(
projectDir,
exp,
androidManifest,
accountName
androidManifest
);
await AndroidConfig.Manifest.writeAndroidManifestAsync(
androidManifestPath,
Expand All @@ -37,10 +34,13 @@ export async function syncUpdatesConfigurationAsync(
const stringsResourceXML = await AndroidConfig.Resources.readResourcesXMLAsync({
path: stringsJSONPath,
});
const updatedStringsResourceXML = AndroidConfig.Updates.applyRuntimeVersionFromConfig(
exp,
stringsResourceXML
);

const updatedStringsResourceXML =
await AndroidConfig.Updates.applyRuntimeVersionFromConfigForProjectRootAsync(
projectDir,
exp,
stringsResourceXML
);
await XML.writeXMLAsync({ path: stringsJSONPath, xml: updatedStringsResourceXML });
}

Expand Down
Loading

0 comments on commit 92adc6d

Please sign in to comment.