mirror of
https://github.com/expo/eas-cli.git
synced 2026-11-23 16:00:26 -10:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ab76641dcb |
No files matched your search
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'eas-cli': minor
|
||||
---
|
||||
|
||||
Show the display name, slug and icon in `eas project:info`, and describe how `eas project:icon:set` processes the image.
|
||||
@@ -227,6 +227,9 @@
|
||||
"project": {
|
||||
"description": "manage project"
|
||||
},
|
||||
"project:icon": {
|
||||
"description": "manage the project icon displayed on the EAS dashboard"
|
||||
},
|
||||
"release": {
|
||||
"description": "manage update releases"
|
||||
},
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
import { getMockOclifConfig } from '../../../__tests__/commands/utils';
|
||||
import { ExpoGraphqlClient } from '../../../commandUtils/context/contextUtils/createGraphqlClient';
|
||||
import { AppQuery } from '../../../graphql/queries/AppQuery';
|
||||
import Log from '../../../log';
|
||||
import ProjectInfo from '../info';
|
||||
|
||||
jest.mock('../../../graphql/queries/AppQuery');
|
||||
jest.mock('../../../log');
|
||||
|
||||
const projectId = 'test-project-id';
|
||||
|
||||
async function runAndGetOutputAsync(): Promise<string> {
|
||||
const command = new ProjectInfo([], getMockOclifConfig());
|
||||
// @ts-expect-error getContextAsync is protected
|
||||
jest.spyOn(command, 'getContextAsync').mockResolvedValue({
|
||||
projectId,
|
||||
loggedIn: { graphqlClient: {} as ExpoGraphqlClient },
|
||||
});
|
||||
await command.runAsync();
|
||||
return jest.mocked(Log.log).mock.calls.flat().join('\n');
|
||||
}
|
||||
|
||||
describe(ProjectInfo, () => {
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
jest.mocked(AppQuery.byIdAsync).mockResolvedValue({
|
||||
id: projectId,
|
||||
name: 'My App',
|
||||
fullName: '@jester/my-app',
|
||||
slug: 'my-app',
|
||||
} as any);
|
||||
});
|
||||
|
||||
it('prints the display name, slug and icon URL', async () => {
|
||||
jest
|
||||
.mocked(AppQuery.byIdProfileImageUrlAsync)
|
||||
.mockResolvedValue('https://example.com/icon.png');
|
||||
|
||||
const output = await runAndGetOutputAsync();
|
||||
|
||||
expect(output).toMatch(/fullName.* @jester\/my-app/);
|
||||
expect(output).toMatch(/name.* My App/);
|
||||
expect(output).toMatch(/slug.* my-app/);
|
||||
expect(output).toMatch(/icon.* https:\/\/example\.com\/icon\.png/);
|
||||
expect(output).toMatch(/ID.* test-project-id/);
|
||||
});
|
||||
|
||||
it('prints "not set" when the project has no icon', async () => {
|
||||
jest.mocked(AppQuery.byIdProfileImageUrlAsync).mockResolvedValue(null);
|
||||
|
||||
expect(await runAndGetOutputAsync()).toMatch(/icon.* not set/);
|
||||
});
|
||||
});
|
||||
@@ -14,13 +14,14 @@ import {
|
||||
} from '../../../project/projectIcon';
|
||||
|
||||
export default class ProjectIconSet extends EasCommand {
|
||||
static override description = 'set the project icon displayed on the EAS dashboard';
|
||||
static override description =
|
||||
'set the project icon displayed on the EAS dashboard (requires the Admin role)';
|
||||
|
||||
static override args = {
|
||||
path: Args.string({
|
||||
required: true,
|
||||
description:
|
||||
'Path to the icon image (PNG or JPEG, at most 10 MB). Non-square images are center-cropped to a square.',
|
||||
'Path to the icon image (PNG or JPEG, at most 10 MB). The image is resized to a 1024x1024 PNG, and a non-square image is center-cropped.',
|
||||
}),
|
||||
};
|
||||
|
||||
|
||||
@@ -1,38 +1,8 @@
|
||||
import gql from 'graphql-tag';
|
||||
|
||||
import EasCommand from '../../commandUtils/EasCommand';
|
||||
import { ExpoGraphqlClient } from '../../commandUtils/context/contextUtils/createGraphqlClient';
|
||||
import { withErrorHandlingAsync } from '../../graphql/client';
|
||||
import { AppInfoQuery, AppInfoQueryVariables } from '../../graphql/generated';
|
||||
import { AppQuery } from '../../graphql/queries/AppQuery';
|
||||
import Log from '../../log';
|
||||
import formatFields from '../../utils/formatFields';
|
||||
|
||||
async function projectInfoByIdAsync(
|
||||
graphqlClient: ExpoGraphqlClient,
|
||||
appId: string
|
||||
): Promise<AppInfoQuery> {
|
||||
const data = await withErrorHandlingAsync(
|
||||
graphqlClient
|
||||
.query<AppInfoQuery, AppInfoQueryVariables>(
|
||||
gql`
|
||||
query AppInfo($appId: String!) {
|
||||
app {
|
||||
byId(appId: $appId) {
|
||||
id
|
||||
fullName
|
||||
}
|
||||
}
|
||||
}
|
||||
`,
|
||||
{ appId },
|
||||
{ additionalTypenames: ['App'] }
|
||||
)
|
||||
.toPromise()
|
||||
);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
export default class ProjectInfo extends EasCommand {
|
||||
static override description = 'information about the current project';
|
||||
|
||||
@@ -49,15 +19,18 @@ export default class ProjectInfo extends EasCommand {
|
||||
nonInteractive: true,
|
||||
});
|
||||
|
||||
const { app } = await projectInfoByIdAsync(graphqlClient, projectId);
|
||||
if (!app) {
|
||||
throw new Error(`Could not find project with id: ${projectId}`);
|
||||
}
|
||||
const [app, iconUrl] = await Promise.all([
|
||||
AppQuery.byIdAsync(graphqlClient, projectId),
|
||||
AppQuery.byIdProfileImageUrlAsync(graphqlClient, projectId),
|
||||
]);
|
||||
|
||||
Log.addNewLineIfNone();
|
||||
Log.log(
|
||||
formatFields([
|
||||
{ label: 'fullName', value: app.byId.fullName },
|
||||
{ label: 'fullName', value: app.fullName },
|
||||
{ label: 'name', value: app.name },
|
||||
{ label: 'slug', value: app.slug },
|
||||
{ label: 'icon', value: iconUrl ?? 'not set' },
|
||||
{ label: 'ID', value: projectId },
|
||||
])
|
||||
);
|
||||
|
||||
-7
@@ -14976,13 +14976,6 @@ export type ResumeUpdateChannelMutationVariables = Exact<{
|
||||
|
||||
export type ResumeUpdateChannelMutation = { __typename?: 'RootMutation', updateChannel: { __typename?: 'UpdateChannelMutation', resumeUpdateChannel: { __typename?: 'UpdateChannel', id: string, name: string, branchMapping: string, isProtected: boolean } } };
|
||||
|
||||
export type AppInfoQueryVariables = Exact<{
|
||||
appId: Scalars['String']['input'];
|
||||
}>;
|
||||
|
||||
|
||||
export type AppInfoQuery = { __typename?: 'RootQuery', app: { __typename?: 'AppQuery', byId: { __typename?: 'App', id: string, fullName: string } } };
|
||||
|
||||
export type CreateAndroidAppBuildCredentialsMutationVariables = Exact<{
|
||||
androidAppBuildCredentialsInput: AndroidAppBuildCredentialsInput;
|
||||
androidAppCredentialsId: Scalars['ID']['input'];
|
||||
|
||||
Reference in new issue
Block a user