diff --git a/CHANGELOG.md b/CHANGELOG.md index 2ddf79b9f3..8e1d873776 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ This is the log of notable changes to EAS CLI and related packages. ### ๐ŸŽ‰ New features +- Allow undefined update message for EAS Update publishing when no VCS. ([#2148](https://github.com/expo/eas-cli/pull/2148) by [@wschurman](https://github.com/wschurman)) + ### ๐Ÿ› Bug fixes ### ๐Ÿงน Chores diff --git a/packages/eas-cli/src/commands/update/index.ts b/packages/eas-cli/src/commands/update/index.ts index 222085e6b8..14b570783b 100644 --- a/packages/eas-cli/src/commands/update/index.ts +++ b/packages/eas-cli/src/commands/update/index.ts @@ -515,7 +515,7 @@ export default class UpdatePublish extends EasCommand { ? [{ label: 'Android update ID', value: newAndroidUpdate.id }] : []), ...(newIosUpdate ? [{ label: 'iOS update ID', value: newIosUpdate.id }] : []), - { label: 'Message', value: updateMessage }, + { label: 'Message', value: updateMessage ?? '' }, ...(gitCommitHash ? [ { diff --git a/packages/eas-cli/src/commands/update/roll-back-to-embedded.ts b/packages/eas-cli/src/commands/update/roll-back-to-embedded.ts index da721e5c21..1d03b06257 100644 --- a/packages/eas-cli/src/commands/update/roll-back-to-embedded.ts +++ b/packages/eas-cli/src/commands/update/roll-back-to-embedded.ts @@ -270,7 +270,7 @@ export default class UpdateRollBackToEmbedded extends EasCommand { ? [{ label: 'Android update ID', value: newAndroidUpdate.id }] : []), ...(newIosUpdate ? [{ label: 'iOS update ID', value: newIosUpdate.id }] : []), - { label: 'Message', value: updateMessage }, + { label: 'Message', value: updateMessage ?? '' }, ...(gitCommitHash ? [ { @@ -300,7 +300,7 @@ export default class UpdateRollBackToEmbedded extends EasCommand { graphqlClient: ExpoGraphqlClient; isGitWorkingTreeDirty: boolean | undefined; gitCommitHash: string | undefined; - updateMessage: string; + updateMessage: string | undefined; branchId: string; codeSigningInfo: CodeSigningInfo | undefined; runtimeVersions: { platform: string; runtimeVersion: string }[]; diff --git a/packages/eas-cli/src/project/publish.ts b/packages/eas-cli/src/project/publish.ts index ad53ea0598..a0d3d31533 100644 --- a/packages/eas-cli/src/project/publish.ts +++ b/packages/eas-cli/src/project/publish.ts @@ -631,32 +631,38 @@ export async function getUpdateMessageForCommandAsync( nonInteractive: boolean; jsonFlag: boolean; } -): Promise { +): Promise { let updateMessage = updateMessageArg; if (!updateMessageArg && autoFlag) { updateMessage = (await vcsClient.getLastCommitMessageAsync())?.trim(); } if (!updateMessage) { - if (nonInteractive) { - throw new Error('Must supply --message or use --auto when in non-interactive mode'); + if (nonInteractive || jsonFlag) { + if (vcsClient.canGetLastCommitMessage()) { + throw new Error( + 'Must supply --message or use --auto when in non-interactive mode and VCS is available' + ); + } + return undefined; } - const validationMessage = 'publish message may not be empty.'; - if (jsonFlag) { - throw new Error(validationMessage); - } const { updateMessageLocal } = await promptAsync({ type: 'text', name: 'updateMessageLocal', message: `Provide an update message:`, initial: (await vcsClient.getLastCommitMessageAsync())?.trim(), - validate: (value: any) => (value ? true : validationMessage), }); + if (!updateMessageLocal) { + return undefined; + } + updateMessage = updateMessageLocal; } - assert(updateMessage, 'Update message must be specified.'); + if (!updateMessage) { + return undefined; + } const truncatedMessage = truncateUpdateMessage(updateMessage, 1024); if (truncatedMessage !== updateMessage) { diff --git a/packages/eas-cli/src/vcs/clients/git.ts b/packages/eas-cli/src/vcs/clients/git.ts index 46c5f4d567..1b67a28b2d 100644 --- a/packages/eas-cli/src/vcs/clients/git.ts +++ b/packages/eas-cli/src/vcs/clients/git.ts @@ -217,6 +217,10 @@ export default class GitClient extends Client { return false; } } + + public override canGetLastCommitMessage(): boolean { + return true; + } } async function ensureGitConfiguredAsync({ diff --git a/packages/eas-cli/src/vcs/clients/noVcs.ts b/packages/eas-cli/src/vcs/clients/noVcs.ts index e1adb9b95e..b8ebee7593 100644 --- a/packages/eas-cli/src/vcs/clients/noVcs.ts +++ b/packages/eas-cli/src/vcs/clients/noVcs.ts @@ -16,4 +16,8 @@ export default class NoVcsClient extends Client { await ignore.initIgnoreAsync(); return ignore.ignores(filePath); } + + public override canGetLastCommitMessage(): boolean { + return true; + } } diff --git a/packages/eas-cli/src/vcs/vcs.ts b/packages/eas-cli/src/vcs/vcs.ts index 2720c4101b..72101c8050 100644 --- a/packages/eas-cli/src/vcs/vcs.ts +++ b/packages/eas-cli/src/vcs/vcs.ts @@ -78,4 +78,10 @@ export abstract class Client { public async isFileIgnoredAsync(_filePath: string): Promise { return false; } + + /** + * Whether this VCS client can get the last commit message. + * Used for EAS Update - implementation can be false for noVcs client. + */ + public abstract canGetLastCommitMessage(): boolean; }