mirror of
https://github.com/expo/eas-cli.git
synced 2026-11-14 10:08:06 -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))
|
- 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))
|
- 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))
|
- 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
|
## [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,
|
nonInteractive,
|
||||||
}: { projectId: string; channelName: string; json: boolean; nonInteractive: boolean }
|
}: { projectId: string; channelName: string; json: boolean; nonInteractive: boolean }
|
||||||
): Promise<UpdateToRepublish[]> {
|
): Promise<UpdateToRepublish[]> {
|
||||||
const branchName = await getBranchNameFromChannelNameAsync(graphqlClient, projectId, channelName);
|
const branchName = await getBranchNameFromChannelNameAsync(
|
||||||
|
graphqlClient,
|
||||||
|
projectId,
|
||||||
|
channelName,
|
||||||
|
{ json, nonInteractive, offset: 0 }
|
||||||
|
);
|
||||||
|
|
||||||
return await askUpdatesFromBranchNameAsync(graphqlClient, {
|
return await askUpdatesFromBranchNameAsync(graphqlClient, {
|
||||||
projectId,
|
projectId,
|
||||||
|
|||||||
@@ -575,7 +575,12 @@ export async function getBranchNameForCommandAsync({
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (channelNameArg) {
|
if (channelNameArg) {
|
||||||
return await getBranchNameFromChannelNameAsync(graphqlClient, projectId, channelNameArg);
|
return await getBranchNameFromChannelNameAsync(
|
||||||
|
graphqlClient,
|
||||||
|
projectId,
|
||||||
|
channelNameArg,
|
||||||
|
paginatedQueryOptions
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (branchNameArg) {
|
if (branchNameArg) {
|
||||||
|
|||||||
@@ -1,13 +1,22 @@
|
|||||||
import { instance, mock } from 'ts-mockito';
|
import { instance, mock } from 'ts-mockito';
|
||||||
|
|
||||||
|
import { selectBranchOnAppAsync } from '../../branch/queries';
|
||||||
import { ExpoGraphqlClient } from '../../commandUtils/context/contextUtils/createGraphqlClient';
|
import { ExpoGraphqlClient } from '../../commandUtils/context/contextUtils/createGraphqlClient';
|
||||||
|
import { updateChannelBranchMappingAsync } from '../../commands/channel/edit';
|
||||||
import { App, Runtime, UpdateBranch, UpdateChannel, UpdateInsights } from '../../graphql/generated';
|
import { App, Runtime, UpdateBranch, UpdateChannel, UpdateInsights } from '../../graphql/generated';
|
||||||
import { ChannelQuery } from '../../graphql/queries/ChannelQuery';
|
import { ChannelQuery } from '../../graphql/queries/ChannelQuery';
|
||||||
import { getBranchNameFromChannelNameAsync } from '../getBranchNameFromChannelNameAsync';
|
import { getBranchNameFromChannelNameAsync } from '../getBranchNameFromChannelNameAsync';
|
||||||
|
|
||||||
jest.mock('../../graphql/queries/ChannelQuery');
|
jest.mock('../../graphql/queries/ChannelQuery');
|
||||||
jest.mock('../../graphql/queries/BranchQuery');
|
jest.mock('../../graphql/queries/BranchQuery');
|
||||||
|
jest.mock('../../branch/queries');
|
||||||
|
jest.mock('../../commands/channel/edit');
|
||||||
|
|
||||||
|
const defaultPaginatedQueryOptions = {
|
||||||
|
json: false,
|
||||||
|
nonInteractive: false,
|
||||||
|
offset: 0,
|
||||||
|
};
|
||||||
describe(getBranchNameFromChannelNameAsync, () => {
|
describe(getBranchNameFromChannelNameAsync, () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
jest.resetAllMocks();
|
jest.resetAllMocks();
|
||||||
@@ -26,13 +35,14 @@ describe(getBranchNameFromChannelNameAsync, () => {
|
|||||||
const result = await getBranchNameFromChannelNameAsync(
|
const result = await getBranchNameFromChannelNameAsync(
|
||||||
graphqlClient,
|
graphqlClient,
|
||||||
'test-project-id',
|
'test-project-id',
|
||||||
'channel-name'
|
'channel-name',
|
||||||
|
defaultPaginatedQueryOptions
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(result).toBe('test-branch-name');
|
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>());
|
const graphqlClient = instance(mock<ExpoGraphqlClient>());
|
||||||
jest.mocked(ChannelQuery.viewUpdateChannelAsync).mockImplementationOnce(
|
jest.mocked(ChannelQuery.viewUpdateChannelAsync).mockImplementationOnce(
|
||||||
async () =>
|
async () =>
|
||||||
@@ -41,11 +51,24 @@ describe(getBranchNameFromChannelNameAsync, () => {
|
|||||||
}) as any
|
}) as any
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(
|
jest
|
||||||
getBranchNameFromChannelNameAsync(graphqlClient, 'test-project-id', 'test-channel-name')
|
.mocked(selectBranchOnAppAsync)
|
||||||
).rejects.toThrow(
|
.mockImplementationOnce(async () => mockUpdateBranches(['test-branch-name'])[0] as any);
|
||||||
"Channel has no branches associated with it. Run 'eas channel:edit' to map a branch"
|
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 () => {
|
test('errors when more than one branch is connected to channel', async () => {
|
||||||
@@ -59,7 +82,12 @@ describe(getBranchNameFromChannelNameAsync, () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
getBranchNameFromChannelNameAsync(graphqlClient, 'test-project-id', 'test-channel-name')
|
getBranchNameFromChannelNameAsync(
|
||||||
|
graphqlClient,
|
||||||
|
'test-project-id',
|
||||||
|
'test-channel-name',
|
||||||
|
defaultPaginatedQueryOptions
|
||||||
|
)
|
||||||
).rejects.toThrow(
|
).rejects.toThrow(
|
||||||
"Channel has multiple branches associated with it. Instead, use '--branch' instead of '--channel'"
|
"Channel has multiple branches associated with it. Instead, use '--branch' instead of '--channel'"
|
||||||
);
|
);
|
||||||
@@ -78,7 +106,8 @@ describe(getBranchNameFromChannelNameAsync, () => {
|
|||||||
const result = await getBranchNameFromChannelNameAsync(
|
const result = await getBranchNameFromChannelNameAsync(
|
||||||
graphqlClient,
|
graphqlClient,
|
||||||
'test-project-id',
|
'test-project-id',
|
||||||
'test-channel-name'
|
'test-channel-name',
|
||||||
|
defaultPaginatedQueryOptions
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(result).toBe('test-branch-name');
|
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 { ChannelNotFoundError } from '../channel/errors';
|
||||||
import { createChannelOnAppAsync } from '../channel/queries';
|
import { createChannelOnAppAsync } from '../channel/queries';
|
||||||
import { ExpoGraphqlClient } from '../commandUtils/context/contextUtils/createGraphqlClient';
|
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 { ChannelQuery } from '../graphql/queries/ChannelQuery';
|
||||||
|
import Log from '../log';
|
||||||
|
|
||||||
export async function getBranchNameFromChannelNameAsync(
|
export async function getBranchNameFromChannelNameAsync(
|
||||||
graphqlClient: ExpoGraphqlClient,
|
graphqlClient: ExpoGraphqlClient,
|
||||||
projectId: string,
|
projectId: string,
|
||||||
channelName: string
|
channelName: string,
|
||||||
|
paginatedQueryOptions: PaginatedQueryOptions
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
let branchName;
|
let branchName;
|
||||||
|
|
||||||
@@ -20,9 +25,19 @@ export async function getBranchNameFromChannelNameAsync(
|
|||||||
if (channel.updateBranches.length === 1) {
|
if (channel.updateBranches.length === 1) {
|
||||||
branchName = channel.updateBranches[0].name;
|
branchName = channel.updateBranches[0].name;
|
||||||
} else if (channel.updateBranches.length === 0) {
|
} else if (channel.updateBranches.length === 0) {
|
||||||
throw new Error(
|
Log.log('Channel has no branches associated with it.');
|
||||||
"Channel has no branches associated with it. Run 'eas channel:edit' to map a branch"
|
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 {
|
} else {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Channel has multiple branches associated with it. Instead, use '--branch' instead of '--channel'`
|
`Channel has multiple branches associated with it. Instead, use '--branch' instead of '--channel'`
|
||||||
|
|||||||
Reference in new issue
Block a user