Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[eas-cli] Add explicit workflow arg to expo-update CLI calls #2340

Merged
merged 3 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
[eas-cli] Add explicit workflow arg to expo-update CLI calls
  • Loading branch information
wschurman committed Apr 24, 2024
commit f0d9f40bb6ac62a48232e4a7072a042c348dca16
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export async function syncProjectConfigurationAsync({
if (workflow === Workflow.GENERIC) {
await cleanUpOldEasBuildGradleScriptAsync(projectDir);
if (isExpoUpdatesInstalled(projectDir)) {
await syncUpdatesConfigurationAsync(projectDir, exp);
await syncUpdatesConfigurationAsync(projectDir, exp, workflow);
}
await bumpVersionAsync({ projectDir, exp, bumpStrategy: versionBumpStrategy });
} else {
Expand Down
2 changes: 1 addition & 1 deletion packages/eas-cli/src/build/ios/syncProjectConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export async function syncProjectConfigurationAsync({

if (workflow === Workflow.GENERIC) {
if (isExpoUpdatesInstalled(projectDir)) {
await syncUpdatesConfigurationAsync(vcsClient, projectDir, exp);
await syncUpdatesConfigurationAsync(vcsClient, projectDir, exp, workflow);
}
await bumpVersionAsync({ projectDir, exp, bumpStrategy: versionBumpStrategy, targets });
} else {
Expand Down
4 changes: 2 additions & 2 deletions packages/eas-cli/src/commands/build/configure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,14 @@ export default class BuildConfigure extends EasCommand {
if ([RequestedPlatform.Android, RequestedPlatform.All].includes(platform)) {
const workflow = await resolveWorkflowAsync(projectDir, Platform.ANDROID, vcsClient);
if (workflow === Workflow.GENERIC) {
await syncAndroidUpdatesConfigurationAsync(projectDir, exp);
await syncAndroidUpdatesConfigurationAsync(projectDir, exp, workflow);
}
}

if ([RequestedPlatform.Ios, RequestedPlatform.All].includes(platform)) {
const workflow = await resolveWorkflowAsync(projectDir, Platform.IOS, vcsClient);
if (workflow === Workflow.GENERIC) {
await syncIosUpdatesConfigurationAsync(vcsClient, projectDir, exp);
await syncIosUpdatesConfigurationAsync(vcsClient, projectDir, exp, workflow);
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions packages/eas-cli/src/commands/channel/rollout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ export default class ChannelRollout extends EasCommand {

static override contextDefinition = {
...this.ContextOptions.ProjectConfig,
...this.ContextOptions.Vcs,
...this.ContextOptions.LoggedIn,
};

Expand All @@ -133,6 +134,7 @@ export default class ChannelRollout extends EasCommand {
const argsAndFlags = this.sanitizeArgsAndFlags({ ...flags, ...args });
const {
privateProjectConfig: { exp, projectId, projectDir },
vcsClient,
loggedIn: { graphqlClient },
} = await this.getContextAsync(ChannelRollout, {
nonInteractive: argsAndFlags.nonInteractive,
Expand All @@ -146,6 +148,7 @@ export default class ChannelRollout extends EasCommand {
nonInteractive: argsAndFlags.nonInteractive,
graphqlClient,
app,
vcsClient,
};
if (argsAndFlags.nonInteractive) {
await new NonInteractiveRollout(argsAndFlags).runAsync(ctx);
Expand Down
8 changes: 7 additions & 1 deletion packages/eas-cli/src/commands/update/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Platform as PublishPlatform } from '@expo/config';
import { Workflow } from '@expo/eas-build-job';
import { Errors, Flags } from '@oclif/core';
import chalk from 'chalk';
import nullthrows from 'nullthrows';
Expand Down Expand Up @@ -40,6 +41,7 @@ import {
resolveInputDirectoryAsync,
uploadAssetsAsync,
} from '../../project/publish';
import { resolveWorkflowPerPlatformAsync } from '../../project/workflow';
import { ensureEASUpdateIsConfiguredAsync } from '../../update/configure';
import { getUpdateJsonInfosForUpdates } from '../../update/utils';
import {
Expand Down Expand Up @@ -359,11 +361,15 @@ export default class UpdatePublish extends EasCommand {
throw e;
}

const workflows = await resolveWorkflowPerPlatformAsync(projectDir, vcsClient);
const runtimeVersions = await getRuntimeVersionObjectAsync({
exp,
platforms: realizedPlatforms,
projectDir,
vcsClient,
workflows: {
...workflows,
web: Workflow.UNKNOWN,
},
});
const runtimeToPlatformMapping =
getRuntimeToPlatformMappingFromRuntimeVersions(runtimeVersions);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Platform as PublishPlatform } from '@expo/config';
import { Workflow } from '@expo/eas-build-job';
import { Errors, Flags } from '@oclif/core';
import chalk from 'chalk';
import nullthrows from 'nullthrows';
Expand Down Expand Up @@ -33,6 +34,7 @@ import {
getRuntimeVersionObjectAsync,
getUpdateMessageForCommandAsync,
} from '../../project/publish';
import { resolveWorkflowPerPlatformAsync } from '../../project/workflow';
import { ensureEASUpdateIsConfiguredAsync } from '../../update/configure';
import { getUpdateJsonInfosForUpdates } from '../../update/utils';
import {
Expand Down Expand Up @@ -201,11 +203,15 @@ export default class UpdateRollBackToEmbedded extends EasCommand {
const gitCommitHash = await vcsClient.getCommitHashAsync();
const isGitWorkingTreeDirty = await vcsClient.hasUncommittedChangesAsync();

const workflows = await resolveWorkflowPerPlatformAsync(projectDir, vcsClient);
const runtimeVersions = await getRuntimeVersionObjectAsync({
exp,
platforms: realizedPlatforms,
projectDir,
vcsClient,
workflows: {
...workflows,
web: Workflow.UNKNOWN,
},
});

let newUpdates: UpdatePublishMutation['updateBranch']['publishUpdateGroups'];
Expand Down
2 changes: 2 additions & 0 deletions packages/eas-cli/src/eas-update/utils.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { ExpoConfig } from '@expo/config-types';

import { ExpoGraphqlClient } from '../commandUtils/context/contextUtils/createGraphqlClient';
import { Client } from '../vcs/vcs';

export type EASUpdateContext = {
graphqlClient: ExpoGraphqlClient;
nonInteractive: boolean;
app: { exp: ExpoConfig; projectId: string; projectDir: string };
vcsClient: Client;
};

export interface EASUpdateAction<T = any> {
Expand Down
20 changes: 8 additions & 12 deletions packages/eas-cli/src/project/publish.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ExpoConfig, Platform } from '@expo/config';
import { Updates } from '@expo/config-plugins';
import { Platform as EASBuildJobPlatform, Workflow } from '@expo/eas-build-job';
import { Workflow } from '@expo/eas-build-job';
import JsonFile from '@expo/json-file';
import assert from 'assert';
import chalk from 'chalk';
Expand All @@ -13,7 +13,6 @@ import path from 'path';
import promiseLimit from 'promise-limit';

import { isModernExpoUpdatesCLIWithRuntimeVersionCommandSupportedAsync } from './projectUtils';
import { resolveWorkflowAsync } from './workflow';
import { selectBranchOnAppAsync } from '../branch/queries';
import { getDefaultBranchNameAsync } from '../branch/utils';
import { ExpoGraphqlClient } from '../commandUtils/context/contextUtils/createGraphqlClient';
Expand Down Expand Up @@ -683,13 +682,13 @@ export function getRequestedPlatform(
export async function getRuntimeVersionObjectAsync({
exp,
platforms,
workflows,
projectDir,
vcsClient,
}: {
exp: ExpoConfig;
platforms: Platform[];
workflows: Record<Platform, Workflow>;
projectDir: string;
vcsClient: Client;
}): Promise<{ platform: string; runtimeVersion: string }[]> {
return await Promise.all(
platforms.map(async platform => {
Expand All @@ -698,8 +697,8 @@ export async function getRuntimeVersionObjectAsync({
runtimeVersion: await getRuntimeVersionForPlatformAsync({
exp,
platform,
workflow: workflows[platform],
projectDir,
vcsClient,
}),
};
})
Expand All @@ -709,13 +708,13 @@ export async function getRuntimeVersionObjectAsync({
async function getRuntimeVersionForPlatformAsync({
exp,
platform,
workflow,
projectDir,
vcsClient,
}: {
exp: ExpoConfig;
platform: Platform;
workflow: Workflow;
projectDir: string;
vcsClient: Client;
}): Promise<string> {
if (platform === 'web') {
return 'UNVERSIONED';
Expand All @@ -731,6 +730,8 @@ async function getRuntimeVersionForPlatformAsync({
'runtimeversion:resolve',
'--platform',
platform,
'--workflow',
workflow,
...extraArgs,
]);
const runtimeVersionResult = JSON.parse(resolvedRuntimeVersionJSONResult);
Expand All @@ -755,11 +756,6 @@ async function getRuntimeVersionForPlatformAsync({

const runtimeVersion = exp[platform]?.runtimeVersion ?? exp.runtimeVersion;
if (typeof runtimeVersion === 'object') {
const workflow = await resolveWorkflowAsync(
projectDir,
platform as EASBuildJobPlatform,
vcsClient
);
if (workflow !== Workflow.MANAGED) {
throw new Error(
`You're currently using the bare workflow, where runtime version policies are not supported. You must set your runtime version manually. For example, define your runtime version as "1.0.0", not {"policy": "appVersion"} in your app config. ${learnMore(
Expand Down
5 changes: 5 additions & 0 deletions packages/eas-cli/src/project/resolveRuntimeVersionAsync.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ExpoConfig } from '@expo/config';
import { Updates } from '@expo/config-plugins';
import { Workflow } from '@expo/eas-build-job';

import { isModernExpoUpdatesCLIWithRuntimeVersionCommandSupportedAsync } from './projectUtils';
import Log from '../log';
Expand All @@ -11,10 +12,12 @@ import {
export async function resolveRuntimeVersionAsync({
exp,
platform,
workflow,
projectDir,
}: {
exp: ExpoConfig;
platform: 'ios' | 'android';
workflow: Workflow;
projectDir: string;
}): Promise<string | null> {
if (!(await isModernExpoUpdatesCLIWithRuntimeVersionCommandSupportedAsync(projectDir))) {
Expand All @@ -32,6 +35,8 @@ export async function resolveRuntimeVersionAsync({
'runtimeversion:resolve',
'--platform',
platform,
'--workflow',
workflow,
...extraArgs,
]);
const runtimeVersionResult = JSON.parse(resolvedRuntimeVersionJSONResult);
Expand Down
9 changes: 8 additions & 1 deletion packages/eas-cli/src/rollout/actions/CreateRollout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
import { UpdateQuery } from '../../graphql/queries/UpdateQuery';
import Log from '../../log';
import { resolveRuntimeVersionAsync } from '../../project/resolveRuntimeVersionAsync';
import { resolveWorkflowPerPlatformAsync } from '../../project/workflow';
import { confirmAsync, promptAsync } from '../../prompts';
import { truthy } from '../../utils/expodash/filter';
import {
Expand Down Expand Up @@ -272,10 +273,16 @@ export class CreateRollout implements EASUpdateAction<UpdateChannelBasicInfoFrag

async selectRuntimeVersionFromProjectConfigAsync(ctx: EASUpdateContext): Promise<string> {
const platforms: ('ios' | 'android')[] = ['ios', 'android'];
const workflows = await resolveWorkflowPerPlatformAsync(ctx.app.projectDir, ctx.vcsClient);
const runtimes = (
await Promise.all(
platforms.map(platform =>
resolveRuntimeVersionAsync({ projectDir: ctx.app.projectDir, exp: ctx.app.exp, platform })
resolveRuntimeVersionAsync({
projectDir: ctx.app.projectDir,
exp: ctx.app.exp,
platform,
workflow: workflows[platform],
})
)
)
).filter(truthy);
Expand Down
6 changes: 5 additions & 1 deletion packages/eas-cli/src/update/android/UpdatesModule.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ExpoConfig } from '@expo/config';
import { AndroidConfig, AndroidManifest, XML } from '@expo/config-plugins';
import { Workflow } from '@expo/eas-build-job';

import { RequestedPlatform } from '../../platform';
import { isModernExpoUpdatesCLIWithRuntimeVersionCommandSupportedAsync } from '../../project/projectUtils';
Expand All @@ -11,7 +12,8 @@ import { ensureValidVersions } from '../utils';
*/
export async function syncUpdatesConfigurationAsync(
projectDir: string,
exp: ExpoConfig
exp: ExpoConfig,
workflow: Workflow
): Promise<void> {
ensureValidVersions(exp, RequestedPlatform.Android);

Expand All @@ -20,6 +22,8 @@ export async function syncUpdatesConfigurationAsync(
'configuration:syncnative',
'--platform',
'android',
'--workflow',
workflow,
]);
return;
}
Expand Down
4 changes: 2 additions & 2 deletions packages/eas-cli/src/update/configure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,12 +272,12 @@ async function ensureEASUpdateIsConfiguredNativelyAsync(
}
): Promise<void> {
if (['all', 'android'].includes(platform) && workflows.android === Workflow.GENERIC) {
await syncAndroidUpdatesConfigurationAsync(projectDir, exp);
await syncAndroidUpdatesConfigurationAsync(projectDir, exp, workflows.android);
Log.withTick(`Configured ${chalk.bold('AndroidManifest.xml')} for EAS Update`);
}

if (['all', 'ios'].includes(platform) && workflows.ios === Workflow.GENERIC) {
await syncIosUpdatesConfigurationAsync(vcsClient, projectDir, exp);
await syncIosUpdatesConfigurationAsync(vcsClient, projectDir, exp, workflows.ios);
Log.withTick(`Configured ${chalk.bold('Expo.plist')} for EAS Update`);
}
}
Expand Down
12 changes: 10 additions & 2 deletions packages/eas-cli/src/update/ios/UpdatesModule.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ExpoConfig } from '@expo/config';
import { IOSConfig } from '@expo/config-plugins';
import { Workflow } from '@expo/eas-build-job';

import { RequestedPlatform } from '../../platform';
import { isModernExpoUpdatesCLIWithRuntimeVersionCommandSupportedAsync } from '../../project/projectUtils';
Expand All @@ -11,12 +12,19 @@ import { ensureValidVersions } from '../utils';
export async function syncUpdatesConfigurationAsync(
vcsClient: Client,
projectDir: string,
exp: ExpoConfig
exp: ExpoConfig,
workflow: Workflow
): Promise<void> {
ensureValidVersions(exp, RequestedPlatform.Ios);

if (await isModernExpoUpdatesCLIWithRuntimeVersionCommandSupportedAsync(projectDir)) {
await expoUpdatesCommandAsync(projectDir, ['configuration:syncnative', '--platform', 'ios']);
await expoUpdatesCommandAsync(projectDir, [
'configuration:syncnative',
'--platform',
'ios',
'--workflow',
workflow,
]);
return;
}

Expand Down
Loading