diff --git a/CHANGELOG.md b/CHANGELOG.md index 1f1e6fc391..573d1cf367 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/packages/eas-cli/src/commandUtils/flags.ts b/packages/eas-cli/src/commandUtils/flags.ts index bc108e1550..4e39763d86 100644 --- a/packages/eas-cli/src/commandUtils/flags.ts +++ b/packages/eas-cli/src/commandUtils/flags.ts @@ -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, }), diff --git a/packages/eas-cli/src/commands/update/__tests__/index.test.ts b/packages/eas-cli/src/commands/update/__tests__/index.test.ts index dd03a19b82..b0acbc394a 100644 --- a/packages/eas-cli/src/commands/update/__tests__/index.test.ts +++ b/packages/eas-cli/src/commands/update/__tests__/index.test.ts @@ -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']; diff --git a/packages/eas-cli/src/commands/update/configure.ts b/packages/eas-cli/src/commands/update/configure.ts index 8b86d4f036..3a617c892b 100644 --- a/packages/eas-cli/src/commands/update/configure.ts +++ b/packages/eas-cli/src/commands/update/configure.ts @@ -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'; @@ -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.' ); diff --git a/packages/eas-cli/src/commands/update/index.ts b/packages/eas-cli/src/commands/update/index.ts index a3deda1632..e61da9b9b7 100644 --- a/packages/eas-cli/src/commands/update/index.ts +++ b/packages/eas-cli/src/commands/update/index.ts @@ -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 { @@ -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); diff --git a/packages/eas-cli/src/update/utils.ts b/packages/eas-cli/src/update/utils.ts index 98f804aab0..cf66498eb8 100644 --- a/packages/eas-cli/src/update/utils.ts +++ b/packages/eas-cli/src/update/utils.ts @@ -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 { @@ -357,3 +359,20 @@ export const updatePublishPlatformToAppPlatform: Record