Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ This is the log of notable changes to EAS CLI and related packages.

### 🛠 Breaking changes

- Require --environment flag for update commands when SDK >= 55. ([#3398](https://github.com/expo/eas-cli/pull/3398) by [@douglowder](https://github.com/douglowder))

### 🎉 New features

### 🐛 Bug fixes
Expand Down
2 changes: 1 addition & 1 deletion packages/eas-cli/src/commandUtils/flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export const EasJsonOnlyFlag = {
export const EasUpdateEnvironmentFlag = {
environment: Flags.string({
description:
'Environment to use for the server-side defined EAS environment variables during command execution, e.g. "production", "preview", "development"',
'Environment to use for the server-side defined EAS environment variables during command execution, e.g. "production", "preview", "development". Required for projects using Expo SDK 55 or greater.',
required: false,
default: undefined,
}),
Expand Down
61 changes: 61 additions & 0 deletions packages/eas-cli/src/commands/update/__tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,67 @@ describe(UpdatePublish.name, () => {
expect(PublishMutation.publishUpdateGroupAsync).toHaveBeenCalled();
});

it('errors when SDK >= 55 and --environment is not provided', async () => {
const flags = ['--non-interactive', '--branch=branch123', '--message=abc'];

mockTestProject({ expoConfig: { sdkVersion: '55.0.0' } });

await expect(new UpdatePublish(flags, commandOptions).run()).rejects.toThrow(
'--environment flag is required for projects using Expo SDK 55 or greater'
);
});

it('does not error when SDK >= 55 and --environment is provided', async () => {
const flags = [
'--non-interactive',
'--branch=branch123',
'--message=abc',
'--environment=production',
];

mockTestProject({ expoConfig: { sdkVersion: '55.0.0' } });
const { platforms, runtimeVersion } = mockTestExport();

jest.mocked(ensureBranchExistsAsync).mockResolvedValue({
branch: {
id: 'branch123',
name: 'wat',
},
createdBranch: false,
});

jest
.mocked(PublishMutation.publishUpdateGroupAsync)
.mockResolvedValue(platforms.map(platform => ({ ...updateStub, platform, runtimeVersion })));

await new UpdatePublish(flags, commandOptions).run();

expect(PublishMutation.publishUpdateGroupAsync).toHaveBeenCalled();
});

it('does not error when SDK < 55 and --environment is not provided', async () => {
const flags = ['--non-interactive', '--branch=branch123', '--message=abc'];

mockTestProject({ expoConfig: { sdkVersion: '54.0.0' } });
const { platforms, runtimeVersion } = mockTestExport();

jest.mocked(ensureBranchExistsAsync).mockResolvedValue({
branch: {
id: 'branch123',
name: 'wat',
},
createdBranch: false,
});

jest
.mocked(PublishMutation.publishUpdateGroupAsync)
.mockResolvedValue(platforms.map(platform => ({ ...updateStub, platform, runtimeVersion })));

await new UpdatePublish(flags, commandOptions).run();

expect(PublishMutation.publishUpdateGroupAsync).toHaveBeenCalled();
});

it('creates a new update with the public expo config', async () => {
const flags = ['--non-interactive', '--branch=branch123', '--message=abc'];

Expand Down
6 changes: 6 additions & 0 deletions packages/eas-cli/src/commands/update/configure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
ensureEASUpdateIsConfiguredAsync,
ensureEASUpdateIsConfiguredInEasJsonAsync,
} from '../../update/configure';
import { assertEnvironmentFlagForSdk55OrGreater } from '../../update/utils';

export default class UpdateConfigure extends EasCommand {
static override description = 'configure the project to support EAS Update';
Expand Down Expand Up @@ -42,6 +43,11 @@ export default class UpdateConfigure extends EasCommand {
withServerSideEnvironment: flags['environment'] ?? null,
});

assertEnvironmentFlagForSdk55OrGreater({
sdkVersion: exp.sdkVersion,
environment: flags['environment'],
});

Log.log(
'💡 The following process will configure your project to use EAS Update. These changes only apply to your local project files and you can safely revert them at any time.'
);
Expand Down
6 changes: 6 additions & 0 deletions packages/eas-cli/src/commands/update/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { ensureRepoIsCleanAsync } from '../../build/utils/repository';
import { getUpdateGroupUrl } from '../../build/utils/url';
import EasCommand from '../../commandUtils/EasCommand';
import { EasNonInteractiveAndJsonFlags, EasUpdateEnvironmentFlag } from '../../commandUtils/flags';
import { assertEnvironmentFlagForSdk55OrGreater } from '../../update/utils';
import { getPaginatedQueryOptions } from '../../commandUtils/pagination';
import fetch from '../../fetch';
import {
Expand Down Expand Up @@ -249,6 +250,11 @@ export default class UpdatePublish extends EasCommand {
projectDir,
} = await getDynamicPublicProjectConfigAsync();

assertEnvironmentFlagForSdk55OrGreater({
sdkVersion: expPossiblyWithoutEasUpdateConfigured.sdkVersion,
environment,
});

await maybeWarnAboutEasOutagesAsync(graphqlClient, [StatuspageServiceName.EasUpdate]);

const easJsonAccessor = EasJsonAccessor.fromProjectPath(projectDir);
Expand Down
19 changes: 19 additions & 0 deletions packages/eas-cli/src/update/utils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { ExpoConfig } from '@expo/config';
import { Errors } from '@oclif/core';
import { format } from '@expo/timeago.js';
import chalk from 'chalk';
import dateFormat from 'dateformat';
import semver from 'semver';

import { ExpoGraphqlClient } from '../commandUtils/context/contextUtils/createGraphqlClient';
import {
Expand Down Expand Up @@ -357,3 +359,20 @@ export const updatePublishPlatformToAppPlatform: Record<UpdatePublishPlatform, A
android: AppPlatform.Android,
ios: AppPlatform.Ios,
};

export function assertEnvironmentFlagForSdk55OrGreater({
sdkVersion,
environment,
}: {
sdkVersion: string | undefined;
environment: string | undefined;
}): void {
if (process.env.EAS_BUILD) {
return;
}
if (sdkVersion && semver.gte(sdkVersion, '55.0.0') && !environment) {
Errors.error('--environment flag is required for projects using Expo SDK 55 or greater', {
exit: 1,
});
}
}