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

refactor(eas-cli): simplify the output of eas deploy --json #2596

Merged
merged 4 commits into from
Sep 24, 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 @@ -12,6 +12,8 @@ This is the log of notable changes to EAS CLI and related packages.

### 🧹 Chores

- Simplify the output of `eas deploy --json`. ([#2596](https://github.com/expo/eas-cli/pull/2596) by [@byCedric](https://github.com/byCedric))

## [12.5.0](https://github.com/expo/eas-cli/releases/tag/v12.5.0) - 2024-09-23

### 🎉 New features
Expand Down
9 changes: 3 additions & 6 deletions packages/eas-cli/src/commands/worker/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ import * as path from 'node:path';

import EasCommand from '../../commandUtils/EasCommand';
import { EASEnvironmentFlag, EasNonInteractiveAndJsonFlags } from '../../commandUtils/flags';
import {
EnvironmentVariableEnvironment,
WorkerDeploymentAliasFragment,
} from '../../graphql/generated';
import { EnvironmentVariableEnvironment } from '../../graphql/generated';
import Log from '../../log';
import { ora } from '../../ora';
import { enableJsonOutput, printJsonOnlyOutput } from '../../utils/json';
Expand Down Expand Up @@ -311,7 +308,7 @@ export default class WorkerDeploy extends EasCommand {
deploymentIdentifier: deployResult.id,
url: getDeploymentUrlFromFullName(deployResult.fullName),
},
aliases: [deploymentAlias].filter(Boolean) as WorkerDeploymentAliasFragment[],
aliases: [deploymentAlias],
production: deploymentProdAlias,
})
);
Expand All @@ -328,7 +325,7 @@ export default class WorkerDeploy extends EasCommand {
deploymentIdentifier: deployResult.id,
url: getDeploymentUrlFromFullName(deployResult.fullName),
},
aliases: [deploymentAlias].filter(Boolean) as WorkerDeploymentAliasFragment[],
aliases: [deploymentAlias],
production: deploymentProdAlias,
})
);
Expand Down
54 changes: 28 additions & 26 deletions packages/eas-cli/src/worker/utils/logs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type WorkerDeploymentData = {
/** The actual deployment information */
deployment: Pick<WorkerDeploymentFragment, 'deploymentIdentifier' | 'url'>;
/** All modified aliases of the deployment, if any */
aliases?: WorkerDeploymentAliasFragment[];
aliases?: (WorkerDeploymentAliasFragment | null)[];
/** The production promoting alias of the deployment, if any */
production?: WorkerDeploymentAliasFragment | null;
};
Expand All @@ -34,7 +34,10 @@ export function formatWorkerDeploymentTable(data: WorkerDeploymentData): string
];

if (data.aliases?.length) {
fields.push({ label: 'Alias URL', value: data.aliases[0].url });
const alias = data.aliases.filter(Boolean)[0];
if (alias) {
fields.push({ label: 'Alias URL', value: alias.url });
}
}
if (data.production) {
fields.push({ label: 'Production URL', value: data.production.url });
Expand All @@ -49,34 +52,33 @@ export function formatWorkerDeploymentTable(data: WorkerDeploymentData): string
type WorkerDeploymentOutput = {
/** The absolute URL to the dashboard on `expo.dev` */
dashboardUrl: string;
/** The deployment information */
deployment: {
identifier: string;
url: string;
aliases?: { id: string; name: string; url: string }[];
production?: { id: string; url: string };
};
/** The deployment identifier */
identifier: string;
/** The deployment URL */
url: string;
/** Custom aliases, if assigned */
aliases?: { id: string; url: string; name: string }[];
/** The production alias, if assigned */
production?: { id: string; url: string };
};

export function formatWorkerDeploymentJson(data: WorkerDeploymentData): WorkerDeploymentOutput {
const aliases = !data.aliases
? []
: (data.aliases.filter(Boolean) as WorkerDeploymentAliasFragment[]);

return {
dashboardUrl: getDashboardUrl(data.projectId),
deployment: {
identifier: data.deployment.deploymentIdentifier,
url: data.deployment.url,
aliases: !data.aliases?.length
? undefined
: data.aliases.map(alias => ({
id: alias.id,
name: alias.aliasName,
url: alias.url,
})),
production: !data.production
? undefined
: {
id: data.production.id,
url: data.production.url,
},
},
identifier: data.deployment.deploymentIdentifier,
url: data.deployment.url,
aliases: !aliases.length
? undefined
: aliases.map(alias => ({ id: alias.id, url: alias.url, name: alias.aliasName })),
production: !data.production
? undefined
: {
id: data.production.id,
url: data.production.url,
},
};
}
Loading