Skip to content
Draft
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ This is the log of notable changes to EAS CLI and related packages.

### 🎉 New features

- [eas-cli] Add `eas update:embedded:list` command. ([@gwdp](https://github.com/gwdp))
- [build-tools] Auto-upload embedded bundle after build when `EAS_UPDATE_EXPERIMENTAL_UPLOAD_EMBEDDED_BUNDLE` is set. ([#3767](https://github.com/expo/eas-cli/pull/3767) by [@gwdp](https://github.com/gwdp))

### 🐛 Bug fixes
Expand Down
145 changes: 145 additions & 0 deletions packages/eas-cli/src/commands/update/embedded/__tests__/list.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
import { getMockOclifConfig } from '../../../../__tests__/commands/utils';
import { ExpoGraphqlClient } from '../../../../commandUtils/context/contextUtils/createGraphqlClient';
import { AppPlatform } from '../../../../graphql/generated';
import {
EmbeddedUpdateFragment,
EmbeddedUpdateQuery,
} from '../../../../graphql/queries/EmbeddedUpdateQuery';
import Log from '../../../../log';
import * as json from '../../../../utils/json';
import UpdateEmbeddedList from '../list';

jest.mock('../../../../graphql/queries/EmbeddedUpdateQuery', () => ({
EmbeddedUpdateQuery: { viewPaginatedAsync: jest.fn() },
}));
jest.mock('../../../../log');
jest.mock('../../../../utils/json');

const mockPaginated = jest.mocked(EmbeddedUpdateQuery.viewPaginatedAsync);
const mockLogLog = jest.mocked(Log.log);
const mockEnableJsonOutput = jest.mocked(json.enableJsonOutput);
const mockPrintJson = jest.mocked(json.printJsonOnlyOutput);

const MOCK_CONTEXT = {
projectId: 'project-123',
loggedIn: { graphqlClient: {} as ExpoGraphqlClient },
};

const ROW_A: EmbeddedUpdateFragment = {
id: 'aaaaaaaa-1111-4000-8000-000000000001',
platform: AppPlatform.Ios,
runtimeVersion: '1.0.0',
channel: 'production',
createdAt: '2026-05-29T00:00:00Z',
};
const ROW_B: EmbeddedUpdateFragment = {
id: 'bbbbbbbb-2222-4000-8000-000000000002',
platform: AppPlatform.Android,
runtimeVersion: '1.0.1',
channel: 'preview',
createdAt: '2026-05-30T00:00:00Z',
};

function emptyConnection(): {
edges: { cursor: string; node: EmbeddedUpdateFragment }[];
pageInfo: {
hasNextPage: boolean;
hasPreviousPage: boolean;
startCursor: string | null;
endCursor: string | null;
};
} {
return {
edges: [],
pageInfo: { hasNextPage: false, hasPreviousPage: false, startCursor: null, endCursor: null },
};
}

describe(UpdateEmbeddedList, () => {
const mockConfig = getMockOclifConfig();

beforeEach(() => {
jest.clearAllMocks();
});

function createCommand(argv: string[]): UpdateEmbeddedList {
const command = new UpdateEmbeddedList(argv, mockConfig);
// @ts-expect-error getContextAsync is protected
jest.spyOn(command, 'getContextAsync').mockResolvedValue(MOCK_CONTEXT);
return command;
}

it('prints each row when results exist', async () => {
mockPaginated.mockResolvedValue({
edges: [
{ cursor: 'c1', node: ROW_A },
{ cursor: 'c2', node: ROW_B },
],
pageInfo: { hasNextPage: false, hasPreviousPage: false, startCursor: 'c1', endCursor: 'c2' },
});
await createCommand([]).run();

expect(mockPaginated).toHaveBeenCalledWith(MOCK_CONTEXT.loggedIn.graphqlClient, {
appId: MOCK_CONTEXT.projectId,
filter: undefined,
first: 25,
after: undefined,
});
// Two rows printed (formatted multi-line, one Log.log per row)
expect(mockLogLog.mock.calls.some(c => String(c[0]).includes(ROW_A.id))).toBe(true);
expect(mockLogLog.mock.calls.some(c => String(c[0]).includes(ROW_B.id))).toBe(true);
});

it('prints empty message when no results', async () => {
mockPaginated.mockResolvedValue(emptyConnection());
await createCommand([]).run();
expect(mockLogLog).toHaveBeenCalledWith('No embedded updates found.');
});

it('--json prints connection payload and skips formatted output', async () => {
mockPaginated.mockResolvedValue({
edges: [{ cursor: 'c1', node: ROW_A }],
pageInfo: { hasNextPage: false, hasPreviousPage: false, startCursor: 'c1', endCursor: 'c1' },
});
await createCommand(['--json', '--non-interactive']).run();

expect(mockEnableJsonOutput).toHaveBeenCalled();
expect(mockPrintJson).toHaveBeenCalledWith({
embeddedUpdates: [ROW_A],
pageInfo: { hasNextPage: false, hasPreviousPage: false, startCursor: 'c1', endCursor: 'c1' },
});
// No formatted Log.log of the row
expect(mockLogLog.mock.calls.every(c => !String(c[0]).includes(ROW_A.id))).toBe(true);
});

it('passes filter when flags supplied', async () => {
mockPaginated.mockResolvedValue(emptyConnection());
await createCommand([
'--platform',
'ios',
'--runtime-version',
'1.2.0',
'--channel',
'preview',
]).run();

expect(mockPaginated).toHaveBeenCalledWith(MOCK_CONTEXT.loggedIn.graphqlClient, {
appId: MOCK_CONTEXT.projectId,
filter: { platform: AppPlatform.Ios, runtimeVersion: '1.2.0', channel: 'preview' },
first: 25,
after: undefined,
});
});

it('shows next-page hint when hasNextPage', async () => {
mockPaginated.mockResolvedValue({
edges: [{ cursor: 'c1', node: ROW_A }],
pageInfo: { hasNextPage: true, hasPreviousPage: false, startCursor: 'c1', endCursor: 'c1' },
});
await createCommand([]).run();

expect(
mockLogLog.mock.calls.some(c => String(c[0]).includes('--after-cursor c1'))
).toBe(true);
});
});
120 changes: 120 additions & 0 deletions packages/eas-cli/src/commands/update/embedded/list.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
import { Platform } from '@expo/eas-build-job';
import { Flags } from '@oclif/core';

import EasCommand from '../../../commandUtils/EasCommand';
import {
EasNonInteractiveAndJsonFlags,
resolveNonInteractiveAndJsonFlags,
} from '../../../commandUtils/flags';
import { getLimitFlagWithCustomValues } from '../../../commandUtils/pagination';
import { AppPlatform } from '../../../graphql/generated';
import {
EmbeddedUpdateFragment,
EmbeddedUpdateQuery,
} from '../../../graphql/queries/EmbeddedUpdateQuery';
import { toAppPlatform } from '../../../graphql/types/AppPlatform';
import Log from '../../../log';
import formatFields from '../../../utils/formatFields';
import { enableJsonOutput, printJsonOnlyOutput } from '../../../utils/json';

const DEFAULT_LIMIT = 25;
const MAX_LIMIT = 50;

export default class UpdateEmbeddedList extends EasCommand {
static override description = 'list embedded updates registered with EAS Update for this project';

static override flags = {
platform: Flags.option({
char: 'p',
description: 'Filter by platform',
options: [Platform.IOS, Platform.ANDROID] as const,
})(),
'runtime-version': Flags.string({
description: 'Filter by runtime version',
}),
channel: Flags.string({
description: 'Filter by channel name',
}),
limit: getLimitFlagWithCustomValues({ defaultTo: DEFAULT_LIMIT, limit: MAX_LIMIT }),
'after-cursor': Flags.string({
description: 'Return items after this cursor (for pagination)',
}),
...EasNonInteractiveAndJsonFlags,
};

static override contextDefinition = {
...this.ContextOptions.ProjectId,
...this.ContextOptions.LoggedIn,
};

async runAsync(): Promise<void> {
const { flags } = await this.parse(UpdateEmbeddedList);
const { json: jsonFlag, nonInteractive } = resolveNonInteractiveAndJsonFlags(flags);

const {
projectId,
loggedIn: { graphqlClient },
} = await this.getContextAsync(UpdateEmbeddedList, { nonInteractive });

if (jsonFlag) {
enableJsonOutput();
}

const platform: AppPlatform | undefined = flags.platform
? toAppPlatform(flags.platform as Platform)
: undefined;
const filter =
(platform ?? flags['runtime-version'] ?? flags.channel)
? {
platform,
runtimeVersion: flags['runtime-version'],
channel: flags.channel,
}
: undefined;

const limit = flags.limit ?? DEFAULT_LIMIT;
const connection = await EmbeddedUpdateQuery.viewPaginatedAsync(graphqlClient, {
appId: projectId,
filter,
first: limit,
after: flags['after-cursor'],
});

const embeddedUpdates = connection.edges.map(e => e.node);

if (jsonFlag) {
printJsonOnlyOutput({
embeddedUpdates,
pageInfo: connection.pageInfo,
});
return;
}

if (embeddedUpdates.length === 0) {
Log.log('No embedded updates found.');
return;
}

for (const embeddedUpdate of embeddedUpdates) {
Log.log(formatEmbeddedUpdateRow(embeddedUpdate));
Log.addNewLineIfNone();
}

if (connection.pageInfo.hasNextPage && connection.pageInfo.endCursor) {
Log.log(
`Showing ${embeddedUpdates.length} result${embeddedUpdates.length === 1 ? '' : 's'}. ` +
`For the next page, run with --after-cursor ${connection.pageInfo.endCursor}`
);
}
}
}

function formatEmbeddedUpdateRow(embeddedUpdate: EmbeddedUpdateFragment): string {
return formatFields([
{ label: 'ID', value: embeddedUpdate.id },
{ label: 'Platform', value: embeddedUpdate.platform.toLowerCase() },
{ label: 'Runtime version', value: embeddedUpdate.runtimeVersion },
{ label: 'Channel', value: embeddedUpdate.channel },
{ label: 'Created at', value: new Date(embeddedUpdate.createdAt).toLocaleString() },
]);
}
Loading
Loading