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][eas-update] Allow undefined update message #2148

Merged
merged 2 commits into from
Jan 4, 2024
Merged
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 @@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/eas-cli/src/commands/update/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
? [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
? [
{
Expand Down Expand Up @@ -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 }[];
Expand Down
24 changes: 15 additions & 9 deletions packages/eas-cli/src/project/publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -631,32 +631,38 @@ export async function getUpdateMessageForCommandAsync(
nonInteractive: boolean;
jsonFlag: boolean;
}
): Promise<string> {
): Promise<string | undefined> {
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) {
Expand Down
4 changes: 4 additions & 0 deletions packages/eas-cli/src/vcs/clients/git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,10 @@ export default class GitClient extends Client {
return false;
}
}

public override canGetLastCommitMessage(): boolean {
return true;
}
}

async function ensureGitConfiguredAsync({
Expand Down
4 changes: 4 additions & 0 deletions packages/eas-cli/src/vcs/clients/noVcs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,8 @@ export default class NoVcsClient extends Client {
await ignore.initIgnoreAsync();
return ignore.ignores(filePath);
}

public override canGetLastCommitMessage(): boolean {
return true;
}
}
6 changes: 6 additions & 0 deletions packages/eas-cli/src/vcs/vcs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,10 @@ export abstract class Client {
public async isFileIgnoredAsync(_filePath: string): Promise<boolean> {
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;
}
Loading