mirror of
https://github.com/expo/eas-cli.git
synced 2026-11-13 20:28:08 -10:00
Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
377c7a9ebb | ||
|
|
ef3edcc787 |
No files matched your search
@@ -18,6 +18,7 @@ This is the log of notable changes to EAS CLI and related packages.
|
||||
- Remove "bare"-specific **eas.json** template. ([#2179](https://github.com/expo/eas-cli/pull/2179) by [@sjchmiela](https://github.com/sjchmiela))
|
||||
- Prompt users if they want to continue if EAS CLI fails to provision the devices. ([#2181](https://github.com/expo/eas-cli/pull/2181) by [@szdziedzic](https://github.com/szdziedzic))
|
||||
- Update `eas-cli` and `@expo/eas-json` dependencies. ([#2176](https://github.com/expo/eas-cli/pull/2176) by [@szdziedzic](https://github.com/szdziedzic))
|
||||
- Prompt user to map channel on update if unmapped. ([#2185](https://github.com/expo/eas-cli/pull/2185) by [@quinlanj](https://github.com/quinlanj))
|
||||
|
||||
## [6.0.0](https://github.com/expo/eas-cli/releases/tag/v6.0.0) - 2024-01-12
|
||||
|
||||
|
||||
@@ -293,7 +293,12 @@ async function askUpdatesFromChannelNameAsync(
|
||||
nonInteractive,
|
||||
}: { projectId: string; channelName: string; json: boolean; nonInteractive: boolean }
|
||||
): Promise<UpdateToRepublish[]> {
|
||||
const branchName = await getBranchNameFromChannelNameAsync(graphqlClient, projectId, channelName);
|
||||
const branchName = await getBranchNameFromChannelNameAsync(
|
||||
graphqlClient,
|
||||
projectId,
|
||||
channelName,
|
||||
{ json, nonInteractive, offset: 0 }
|
||||
);
|
||||
|
||||
return await askUpdatesFromBranchNameAsync(graphqlClient, {
|
||||
projectId,
|
||||
|
||||
@@ -575,7 +575,12 @@ export async function getBranchNameForCommandAsync({
|
||||
}
|
||||
|
||||
if (channelNameArg) {
|
||||
return await getBranchNameFromChannelNameAsync(graphqlClient, projectId, channelNameArg);
|
||||
return await getBranchNameFromChannelNameAsync(
|
||||
graphqlClient,
|
||||
projectId,
|
||||
channelNameArg,
|
||||
paginatedQueryOptions
|
||||
);
|
||||
}
|
||||
|
||||
if (branchNameArg) {
|
||||
|
||||
@@ -1,13 +1,22 @@
|
||||
import { instance, mock } from 'ts-mockito';
|
||||
|
||||
import { selectBranchOnAppAsync } from '../../branch/queries';
|
||||
import { ExpoGraphqlClient } from '../../commandUtils/context/contextUtils/createGraphqlClient';
|
||||
import { updateChannelBranchMappingAsync } from '../../commands/channel/edit';
|
||||
import { App, Runtime, UpdateBranch, UpdateChannel, UpdateInsights } from '../../graphql/generated';
|
||||
import { ChannelQuery } from '../../graphql/queries/ChannelQuery';
|
||||
import { getBranchNameFromChannelNameAsync } from '../getBranchNameFromChannelNameAsync';
|
||||
|
||||
jest.mock('../../graphql/queries/ChannelQuery');
|
||||
jest.mock('../../graphql/queries/BranchQuery');
|
||||
jest.mock('../../branch/queries');
|
||||
jest.mock('../../commands/channel/edit');
|
||||
|
||||
const defaultPaginatedQueryOptions = {
|
||||
json: false,
|
||||
nonInteractive: false,
|
||||
offset: 0,
|
||||
};
|
||||
describe(getBranchNameFromChannelNameAsync, () => {
|
||||
beforeEach(() => {
|
||||
jest.resetAllMocks();
|
||||
@@ -26,13 +35,14 @@ describe(getBranchNameFromChannelNameAsync, () => {
|
||||
const result = await getBranchNameFromChannelNameAsync(
|
||||
graphqlClient,
|
||||
'test-project-id',
|
||||
'channel-name'
|
||||
'channel-name',
|
||||
defaultPaginatedQueryOptions
|
||||
);
|
||||
|
||||
expect(result).toBe('test-branch-name');
|
||||
});
|
||||
|
||||
test('errors when no branch is connected to channel', async () => {
|
||||
test('prompts user to select a branch if no branch is connected to channel', async () => {
|
||||
const graphqlClient = instance(mock<ExpoGraphqlClient>());
|
||||
jest.mocked(ChannelQuery.viewUpdateChannelAsync).mockImplementationOnce(
|
||||
async () =>
|
||||
@@ -41,11 +51,24 @@ describe(getBranchNameFromChannelNameAsync, () => {
|
||||
}) as any
|
||||
);
|
||||
|
||||
expect(
|
||||
getBranchNameFromChannelNameAsync(graphqlClient, 'test-project-id', 'test-channel-name')
|
||||
).rejects.toThrow(
|
||||
"Channel has no branches associated with it. Run 'eas channel:edit' to map a branch"
|
||||
jest
|
||||
.mocked(selectBranchOnAppAsync)
|
||||
.mockImplementationOnce(async () => mockUpdateBranches(['test-branch-name'])[0] as any);
|
||||
jest.mocked(updateChannelBranchMappingAsync).mockImplementationOnce(
|
||||
async () =>
|
||||
mockUpdateChannel({
|
||||
channelName: 'test-channel-name',
|
||||
branchNames: ['test-branch-name'],
|
||||
}) as any
|
||||
);
|
||||
|
||||
const result = await getBranchNameFromChannelNameAsync(
|
||||
graphqlClient,
|
||||
'test-project-id',
|
||||
'test-channel-name',
|
||||
defaultPaginatedQueryOptions
|
||||
);
|
||||
expect(result).toBe('test-branch-name');
|
||||
});
|
||||
|
||||
test('errors when more than one branch is connected to channel', async () => {
|
||||
@@ -59,7 +82,12 @@ describe(getBranchNameFromChannelNameAsync, () => {
|
||||
);
|
||||
|
||||
expect(
|
||||
getBranchNameFromChannelNameAsync(graphqlClient, 'test-project-id', 'test-channel-name')
|
||||
getBranchNameFromChannelNameAsync(
|
||||
graphqlClient,
|
||||
'test-project-id',
|
||||
'test-channel-name',
|
||||
defaultPaginatedQueryOptions
|
||||
)
|
||||
).rejects.toThrow(
|
||||
"Channel has multiple branches associated with it. Instead, use '--branch' instead of '--channel'"
|
||||
);
|
||||
@@ -78,7 +106,8 @@ describe(getBranchNameFromChannelNameAsync, () => {
|
||||
const result = await getBranchNameFromChannelNameAsync(
|
||||
graphqlClient,
|
||||
'test-project-id',
|
||||
'test-channel-name'
|
||||
'test-channel-name',
|
||||
defaultPaginatedQueryOptions
|
||||
);
|
||||
|
||||
expect(result).toBe('test-branch-name');
|
||||
|
||||
@@ -1,13 +1,18 @@
|
||||
import { ensureBranchExistsAsync } from '../branch/queries';
|
||||
import { ensureBranchExistsAsync, selectBranchOnAppAsync } from '../branch/queries';
|
||||
import { getAlwaysTrueBranchMapping } from '../channel/branch-mapping';
|
||||
import { ChannelNotFoundError } from '../channel/errors';
|
||||
import { createChannelOnAppAsync } from '../channel/queries';
|
||||
import { ExpoGraphqlClient } from '../commandUtils/context/contextUtils/createGraphqlClient';
|
||||
import { PaginatedQueryOptions } from '../commandUtils/pagination';
|
||||
import { updateChannelBranchMappingAsync } from '../commands/channel/edit';
|
||||
import { ChannelQuery } from '../graphql/queries/ChannelQuery';
|
||||
import Log from '../log';
|
||||
|
||||
export async function getBranchNameFromChannelNameAsync(
|
||||
graphqlClient: ExpoGraphqlClient,
|
||||
projectId: string,
|
||||
channelName: string
|
||||
channelName: string,
|
||||
paginatedQueryOptions: PaginatedQueryOptions
|
||||
): Promise<string> {
|
||||
let branchName;
|
||||
|
||||
@@ -20,9 +25,19 @@ export async function getBranchNameFromChannelNameAsync(
|
||||
if (channel.updateBranches.length === 1) {
|
||||
branchName = channel.updateBranches[0].name;
|
||||
} else if (channel.updateBranches.length === 0) {
|
||||
throw new Error(
|
||||
"Channel has no branches associated with it. Run 'eas channel:edit' to map a branch"
|
||||
);
|
||||
Log.log('Channel has no branches associated with it.');
|
||||
const branch = await selectBranchOnAppAsync(graphqlClient, {
|
||||
projectId,
|
||||
promptTitle: `Which branch would you like ${channel.name} to point at?`,
|
||||
displayTextForListItem: updateBranch => ({ title: updateBranch.name }),
|
||||
paginatedQueryOptions,
|
||||
});
|
||||
|
||||
await updateChannelBranchMappingAsync(graphqlClient, {
|
||||
channelId: channel.id,
|
||||
branchMapping: JSON.stringify(getAlwaysTrueBranchMapping(branch.id)),
|
||||
});
|
||||
return branch.name;
|
||||
} else {
|
||||
throw new Error(
|
||||
`Channel has multiple branches associated with it. Instead, use '--branch' instead of '--channel'`
|
||||
|
||||
Reference in new issue
Block a user