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] Improved service account display in submission summary #674

Merged
merged 1 commit into from
Oct 8, 2021
Merged
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
54 changes: 40 additions & 14 deletions packages/eas-cli/src/submit/android/AndroidSubmitter.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Platform } from '@expo/eas-build-job';
import chalk from 'chalk';

import {
AndroidSubmissionConfigInput,
Expand All @@ -7,6 +8,7 @@ import {
SubmissionFragment,
} from '../../graphql/generated';
import { SubmissionMutation } from '../../graphql/mutations/SubmissionMutation';
import formatFields from '../../utils/formatFields';
import { Archive, ArchiveSource, getArchiveAsync } from '../ArchiveSource';
import BaseSubmitter, { SubmissionInput } from '../BaseSubmitter';
import {
Expand Down Expand Up @@ -108,11 +110,6 @@ export default class AndroidSubmitter extends BaseSubmitter<
{ archive, androidPackage, serviceAccountKeyResult }: ResolvedSourceOptions
): SummaryData {
const { projectId, track, releaseStatus, changesNotSentForReview } = options;
const {
email: serviceAccountEmail,
path: serviceAccountKeyPath,
source: serviceAccountKeySource,
} = serviceAccountKeyResult.summary;

// structuring order affects table rows order
return {
Expand All @@ -121,9 +118,7 @@ export default class AndroidSubmitter extends BaseSubmitter<
track,
changesNotSentForReview: changesNotSentForReview ?? undefined,
releaseStatus: releaseStatus ?? undefined,
serviceAccountEmail,
serviceAccountKeySource,
...(serviceAccountKeyPath ? { serviceAccountKeyPath } : {}),
formattedServiceAccount: formatServiceAccountSummary(serviceAccountKeyResult),
...formatArchiveSourceSummary(archive),
};
}
Expand All @@ -132,11 +127,9 @@ export default class AndroidSubmitter extends BaseSubmitter<
type SummaryData = {
androidPackage: string;
changesNotSentForReview?: boolean;
formattedServiceAccount: string;
projectId: string;
releaseStatus?: SubmissionAndroidReleaseStatus;
serviceAccountKeySource: string;
serviceAccountKeyPath?: string;
serviceAccountEmail: string;
track: SubmissionAndroidTrack;
} & ArchiveSourceSummaryFields;

Expand All @@ -146,10 +139,43 @@ const SummaryHumanReadableKeys: Record<keyof SummaryData, string> = {
archiveUrl: 'Download URL',
changesNotSentForReview: 'Changes not sent for a review',
formattedBuild: 'Build',
formattedServiceAccount: 'Google Service Account Key',
projectId: 'Project ID',
releaseStatus: 'Release status',
serviceAccountKeySource: 'Google Service Key Source',
serviceAccountKeyPath: 'Google Service Key Path',
serviceAccountEmail: 'Google Service Account',
track: 'Release track',
};

function formatServiceAccountSummary({ summary }: ServiceAccountKeyResult): string {
const {
email: serviceAccountEmail,
path: serviceAccountKeyPath,
source: serviceAccountKeySource,
} = summary;

const fields = [
{
label: 'Key Source',
value: serviceAccountKeySource,
},
{
label: 'Key Path',
value: serviceAccountKeyPath,
},
{
label: 'Account E-mail',
value: serviceAccountEmail,
},
];

const filteredFields = fields.filter(({ value }) => value !== undefined && value !== null) as {
label: string;
value: string;
}[];

return (
'\n' +
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use template string.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tried that, but IMO the code becomes less readable:

  return `\n${formatFields(filteredFields, {
    labelFormat: label => `    ${chalk.dim(label)}:`,
  })}`;

formatFields(filteredFields, {
labelFormat: label => ` ${chalk.dim(label)}:`,
})
);
}