diff --git a/CHANGELOG.md b/CHANGELOG.md index 4f195298d7..89302d23df 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/packages/eas-cli/src/commands/worker/deploy.ts b/packages/eas-cli/src/commands/worker/deploy.ts index 35bd247747..3d3f9b24b6 100644 --- a/packages/eas-cli/src/commands/worker/deploy.ts +++ b/packages/eas-cli/src/commands/worker/deploy.ts @@ -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'; @@ -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, }) ); @@ -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, }) ); diff --git a/packages/eas-cli/src/worker/utils/logs.ts b/packages/eas-cli/src/worker/utils/logs.ts index 67e3ced846..69116b1f23 100644 --- a/packages/eas-cli/src/worker/utils/logs.ts +++ b/packages/eas-cli/src/worker/utils/logs.ts @@ -22,7 +22,7 @@ type WorkerDeploymentData = { /** The actual deployment information */ deployment: Pick; /** 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; }; @@ -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 }); @@ -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, + }, }; }