mirror of
https://github.com/expo/eas-cli.git
synced 2026-11-15 17:31:46 -10:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f16e87c0a7 |
No files matched your search
@@ -0,0 +1,23 @@
|
|||||||
|
import { JSONValue } from '@expo/json-file';
|
||||||
|
|
||||||
|
export class ApiV2Error extends Error {
|
||||||
|
override readonly name = 'ApiV2Error';
|
||||||
|
readonly expoApiV2ErrorCode: string;
|
||||||
|
readonly expoApiV2ErrorDetails?: JSONValue;
|
||||||
|
readonly expoApiV2ErrorServerStack?: string;
|
||||||
|
readonly expoApiV2ErrorMetadata?: object;
|
||||||
|
|
||||||
|
constructor(response: {
|
||||||
|
message: string;
|
||||||
|
code: string;
|
||||||
|
stack?: string;
|
||||||
|
details?: JSONValue;
|
||||||
|
metadata?: object;
|
||||||
|
}) {
|
||||||
|
super(response.message);
|
||||||
|
this.expoApiV2ErrorCode = response.code;
|
||||||
|
this.expoApiV2ErrorDetails = response.details;
|
||||||
|
this.expoApiV2ErrorServerStack = response.stack;
|
||||||
|
this.expoApiV2ErrorMetadata = response.metadata;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,9 +1,10 @@
|
|||||||
import assert from 'assert';
|
import assert from 'assert';
|
||||||
import nock from 'nock';
|
import nock from 'nock';
|
||||||
|
|
||||||
import { ApiV2Error, api, getExpoApiBaseUrl } from '../api';
|
import { ApiV2Error } from '../ApiV2Error';
|
||||||
|
import { ApiV2Client, getExpoApiBaseUrl } from '../api';
|
||||||
|
|
||||||
describe('apiClient', () => {
|
describe(ApiV2Client, () => {
|
||||||
it('converts Expo APIv2 error to ApiV2Error', async () => {
|
it('converts Expo APIv2 error to ApiV2Error', async () => {
|
||||||
nock(getExpoApiBaseUrl())
|
nock(getExpoApiBaseUrl())
|
||||||
.post('/v2/test')
|
.post('/v2/test')
|
||||||
@@ -21,7 +22,9 @@ describe('apiClient', () => {
|
|||||||
|
|
||||||
let error: Error | null = null;
|
let error: Error | null = null;
|
||||||
try {
|
try {
|
||||||
await api.postAsync('test', { body: {} });
|
await new ApiV2Client({ accessToken: null, sessionSecret: null }).postAsync('test', {
|
||||||
|
body: {},
|
||||||
|
});
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
error = e;
|
error = e;
|
||||||
}
|
}
|
||||||
@@ -41,7 +44,9 @@ describe('apiClient', () => {
|
|||||||
|
|
||||||
let error: Error | null = null;
|
let error: Error | null = null;
|
||||||
try {
|
try {
|
||||||
await api.postAsync('test', { body: {} });
|
await new ApiV2Client({ accessToken: null, sessionSecret: null }).postAsync('test', {
|
||||||
|
body: {},
|
||||||
|
});
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
error = e;
|
error = e;
|
||||||
}
|
}
|
||||||
|
|||||||
+59
-74
@@ -1,93 +1,78 @@
|
|||||||
import { JSONValue } from '@expo/json-file';
|
import { JSONValue } from '@expo/json-file';
|
||||||
|
|
||||||
|
import { ApiV2Error } from './ApiV2Error';
|
||||||
import fetch, { RequestError, RequestInit } from './fetch';
|
import fetch, { RequestError, RequestInit } from './fetch';
|
||||||
import { getAccessToken, getSessionSecret } from './user/sessionStorage';
|
|
||||||
|
|
||||||
export class ApiV2Error extends Error {
|
|
||||||
override readonly name = 'ApiV2Error';
|
|
||||||
readonly expoApiV2ErrorCode: string;
|
|
||||||
readonly expoApiV2ErrorDetails?: JSONValue;
|
|
||||||
readonly expoApiV2ErrorServerStack?: string;
|
|
||||||
readonly expoApiV2ErrorMetadata?: object;
|
|
||||||
|
|
||||||
constructor(response: {
|
|
||||||
message: string;
|
|
||||||
code: string;
|
|
||||||
stack?: string;
|
|
||||||
details?: JSONValue;
|
|
||||||
metadata?: object;
|
|
||||||
}) {
|
|
||||||
super(response.message);
|
|
||||||
this.expoApiV2ErrorCode = response.code;
|
|
||||||
this.expoApiV2ErrorDetails = response.details;
|
|
||||||
this.expoApiV2ErrorServerStack = response.stack;
|
|
||||||
this.expoApiV2ErrorMetadata = response.metadata;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
interface RequestOptions {
|
interface RequestOptions {
|
||||||
body: JSONValue;
|
body: JSONValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const api = {
|
export class ApiV2Client {
|
||||||
async putAsync(path: string, options: RequestOptions): Promise<any> {
|
constructor(
|
||||||
return await requestAsync(path, { method: 'PUT', body: JSON.stringify(options.body) });
|
private readonly authInfo: {
|
||||||
},
|
accessToken: string | null;
|
||||||
|
sessionSecret: string | null;
|
||||||
|
}
|
||||||
|
) {}
|
||||||
|
|
||||||
async postAsync(path: string, options: RequestOptions): Promise<any> {
|
public async putAsync(path: string, options: RequestOptions): Promise<any> {
|
||||||
return await requestAsync(path, { method: 'POST', body: JSON.stringify(options.body) });
|
return await this.requestAsync(path, { method: 'PUT', body: JSON.stringify(options.body) });
|
||||||
},
|
|
||||||
|
|
||||||
async deleteAsync(path: string): Promise<any> {
|
|
||||||
return await requestAsync(path, { method: 'DELETE' });
|
|
||||||
},
|
|
||||||
|
|
||||||
async getAsync(path: string): Promise<any> {
|
|
||||||
return await requestAsync(path, { method: 'GET' });
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
async function requestAsync(path: string, options: RequestInit): Promise<any> {
|
|
||||||
try {
|
|
||||||
const response = await fetch(`${getExpoApiBaseUrl()}/v2/${path}`, {
|
|
||||||
...options,
|
|
||||||
headers: {
|
|
||||||
'Content-Type': 'application/json',
|
|
||||||
...getAuthHeaders(),
|
|
||||||
},
|
|
||||||
});
|
|
||||||
return await response.json();
|
|
||||||
} catch (err) {
|
|
||||||
await handleApiErrorAsync(err);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
async function handleApiErrorAsync(err: any): Promise<void> {
|
public async postAsync(path: string, options: RequestOptions): Promise<any> {
|
||||||
if (err instanceof RequestError) {
|
return await this.requestAsync(path, { method: 'POST', body: JSON.stringify(options.body) });
|
||||||
let result: { [key: string]: any };
|
}
|
||||||
|
|
||||||
|
public async deleteAsync(path: string): Promise<any> {
|
||||||
|
return await this.requestAsync(path, { method: 'DELETE' });
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getAsync(path: string): Promise<any> {
|
||||||
|
return await this.requestAsync(path, { method: 'GET' });
|
||||||
|
}
|
||||||
|
|
||||||
|
private getAuthHeaders(): Record<string, string> {
|
||||||
|
const token = this.authInfo.accessToken;
|
||||||
|
if (token) {
|
||||||
|
return { authorization: `Bearer ${token}` };
|
||||||
|
}
|
||||||
|
const sessionSecret = this.authInfo.sessionSecret;
|
||||||
|
if (sessionSecret) {
|
||||||
|
return { 'expo-session': sessionSecret };
|
||||||
|
}
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
private async requestAsync(path: string, options: RequestInit): Promise<any> {
|
||||||
try {
|
try {
|
||||||
result = (await err.response.json()) as { [key: string]: any };
|
const response = await fetch(`${getExpoApiBaseUrl()}/v2/${path}`, {
|
||||||
} catch {
|
...options,
|
||||||
throw new Error(`Malformed api response: ${await err.response.text()}`);
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
...this.getAuthHeaders(),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
return await response.json();
|
||||||
|
} catch (err) {
|
||||||
|
await ApiV2Client.handleApiErrorAsync(err);
|
||||||
}
|
}
|
||||||
if (result.errors?.length) {
|
|
||||||
throw new ApiV2Error(result.errors[0]);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
throw err;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
function getAuthHeaders(): Record<string, string> {
|
private static async handleApiErrorAsync(err: any): Promise<void> {
|
||||||
const token = getAccessToken();
|
if (err instanceof RequestError) {
|
||||||
if (token) {
|
let result: { [key: string]: any };
|
||||||
return { authorization: `Bearer ${token}` };
|
try {
|
||||||
|
result = (await err.response.json()) as { [key: string]: any };
|
||||||
|
} catch {
|
||||||
|
throw new Error(`Malformed api response: ${await err.response.text()}`);
|
||||||
|
}
|
||||||
|
if (result.errors?.length) {
|
||||||
|
throw new ApiV2Error(result.errors[0]);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
const sessionSecret = getSessionSecret();
|
|
||||||
if (sessionSecret) {
|
|
||||||
return { 'expo-session': sessionSecret };
|
|
||||||
}
|
|
||||||
return {};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getExpoApiBaseUrl(): string {
|
export function getExpoApiBaseUrl(): string {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import chalk from 'chalk';
|
import chalk from 'chalk';
|
||||||
import CliTable from 'cli-table3';
|
import CliTable from 'cli-table3';
|
||||||
|
|
||||||
|
import { ExpoGraphqlClient } from '../commandUtils/context/contextUtils/createGraphqlClient';
|
||||||
import { PaginatedQueryOptions } from '../commandUtils/pagination';
|
import { PaginatedQueryOptions } from '../commandUtils/pagination';
|
||||||
import { UpdateBranchFragment } from '../graphql/generated';
|
import { UpdateBranchFragment } from '../graphql/generated';
|
||||||
import { BranchQuery } from '../graphql/queries/BranchQuery';
|
import { BranchQuery } from '../graphql/queries/BranchQuery';
|
||||||
@@ -14,17 +15,20 @@ import {
|
|||||||
|
|
||||||
export const BRANCHES_LIMIT = 50;
|
export const BRANCHES_LIMIT = 50;
|
||||||
|
|
||||||
export async function selectBranchOnAppAsync({
|
export async function selectBranchOnAppAsync(
|
||||||
projectId,
|
graphqlClient: ExpoGraphqlClient,
|
||||||
promptTitle,
|
{
|
||||||
displayTextForListItem,
|
projectId,
|
||||||
paginatedQueryOptions,
|
promptTitle,
|
||||||
}: {
|
displayTextForListItem,
|
||||||
projectId: string;
|
paginatedQueryOptions,
|
||||||
displayTextForListItem: (queryItem: UpdateBranchFragment) => string;
|
}: {
|
||||||
promptTitle: string;
|
projectId: string;
|
||||||
paginatedQueryOptions: PaginatedQueryOptions;
|
displayTextForListItem: (queryItem: UpdateBranchFragment) => string;
|
||||||
}): Promise<UpdateBranchFragment> {
|
promptTitle: string;
|
||||||
|
paginatedQueryOptions: PaginatedQueryOptions;
|
||||||
|
}
|
||||||
|
): Promise<UpdateBranchFragment> {
|
||||||
if (paginatedQueryOptions.nonInteractive) {
|
if (paginatedQueryOptions.nonInteractive) {
|
||||||
throw new Error('Unable to select a branch in non-interactive mode.');
|
throw new Error('Unable to select a branch in non-interactive mode.');
|
||||||
}
|
}
|
||||||
@@ -32,7 +36,8 @@ export async function selectBranchOnAppAsync({
|
|||||||
const selectedBranch = await paginatedQueryWithSelectPromptAsync({
|
const selectedBranch = await paginatedQueryWithSelectPromptAsync({
|
||||||
limit: paginatedQueryOptions.limit ?? BRANCHES_LIMIT,
|
limit: paginatedQueryOptions.limit ?? BRANCHES_LIMIT,
|
||||||
offset: paginatedQueryOptions.offset,
|
offset: paginatedQueryOptions.offset,
|
||||||
queryToPerform: (limit, offset) => queryBranchesOnProjectAsync(limit, offset, projectId),
|
queryToPerform: (limit, offset) =>
|
||||||
|
queryBranchesOnProjectAsync(graphqlClient, limit, offset, projectId),
|
||||||
promptOptions: {
|
promptOptions: {
|
||||||
title: promptTitle,
|
title: promptTitle,
|
||||||
getIdentifierForQueryItem: updateBranchFragment => updateBranchFragment.id,
|
getIdentifierForQueryItem: updateBranchFragment => updateBranchFragment.id,
|
||||||
@@ -45,15 +50,19 @@ export async function selectBranchOnAppAsync({
|
|||||||
return selectedBranch;
|
return selectedBranch;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function listAndRenderBranchesOnAppAsync({
|
export async function listAndRenderBranchesOnAppAsync(
|
||||||
projectId,
|
graphqlClient: ExpoGraphqlClient,
|
||||||
paginatedQueryOptions,
|
{
|
||||||
}: {
|
projectId,
|
||||||
projectId: string;
|
paginatedQueryOptions,
|
||||||
paginatedQueryOptions: PaginatedQueryOptions;
|
}: {
|
||||||
}): Promise<void> {
|
projectId: string;
|
||||||
|
paginatedQueryOptions: PaginatedQueryOptions;
|
||||||
|
}
|
||||||
|
): Promise<void> {
|
||||||
if (paginatedQueryOptions.nonInteractive) {
|
if (paginatedQueryOptions.nonInteractive) {
|
||||||
const branches = await queryBranchesOnProjectAsync(
|
const branches = await queryBranchesOnProjectAsync(
|
||||||
|
graphqlClient,
|
||||||
paginatedQueryOptions.limit ?? BRANCHES_LIMIT,
|
paginatedQueryOptions.limit ?? BRANCHES_LIMIT,
|
||||||
paginatedQueryOptions.offset,
|
paginatedQueryOptions.offset,
|
||||||
projectId
|
projectId
|
||||||
@@ -63,7 +72,8 @@ export async function listAndRenderBranchesOnAppAsync({
|
|||||||
await paginatedQueryWithConfirmPromptAsync({
|
await paginatedQueryWithConfirmPromptAsync({
|
||||||
limit: paginatedQueryOptions.limit ?? BRANCHES_LIMIT,
|
limit: paginatedQueryOptions.limit ?? BRANCHES_LIMIT,
|
||||||
offset: paginatedQueryOptions.offset,
|
offset: paginatedQueryOptions.offset,
|
||||||
queryToPerform: (limit, offset) => queryBranchesOnProjectAsync(limit, offset, projectId),
|
queryToPerform: (limit, offset) =>
|
||||||
|
queryBranchesOnProjectAsync(graphqlClient, limit, offset, projectId),
|
||||||
promptOptions: {
|
promptOptions: {
|
||||||
title: 'Load more branches?',
|
title: 'Load more branches?',
|
||||||
renderListItems: branches => renderPageOfBranches(branches, paginatedQueryOptions),
|
renderListItems: branches => renderPageOfBranches(branches, paginatedQueryOptions),
|
||||||
@@ -73,11 +83,12 @@ export async function listAndRenderBranchesOnAppAsync({
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function queryBranchesOnProjectAsync(
|
async function queryBranchesOnProjectAsync(
|
||||||
|
graphqlClient: ExpoGraphqlClient,
|
||||||
limit: number,
|
limit: number,
|
||||||
offset: number,
|
offset: number,
|
||||||
projectId: string
|
projectId: string
|
||||||
): Promise<UpdateBranchFragment[]> {
|
): Promise<UpdateBranchFragment[]> {
|
||||||
return await BranchQuery.listBranchesOnAppAsync({
|
return await BranchQuery.listBranchesOnAppAsync(graphqlClient, {
|
||||||
appId: projectId,
|
appId: projectId,
|
||||||
limit,
|
limit,
|
||||||
offset,
|
offset,
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
|
import { instance, mock } from 'ts-mockito';
|
||||||
import { v4 as uuid } from 'uuid';
|
import { v4 as uuid } from 'uuid';
|
||||||
|
|
||||||
|
import { ExpoGraphqlClient } from '../../commandUtils/context/contextUtils/createGraphqlClient';
|
||||||
import { selectBuildToCancelAsync } from '../../commands/build/cancel';
|
import { selectBuildToCancelAsync } from '../../commands/build/cancel';
|
||||||
import { AppPlatform, BuildFragment, BuildPriority, BuildStatus } from '../../graphql/generated';
|
import { AppPlatform, BuildFragment, BuildPriority, BuildStatus } from '../../graphql/generated';
|
||||||
import { BuildQuery } from '../../graphql/queries/BuildQuery';
|
import { BuildQuery } from '../../graphql/queries/BuildQuery';
|
||||||
@@ -44,13 +46,17 @@ describe(selectBuildToCancelAsync.name, () => {
|
|||||||
|
|
||||||
it('does not return build id when confirmation is rejected', async () => {
|
it('does not return build id when confirmation is rejected', async () => {
|
||||||
jest.mocked(confirmAsync).mockResolvedValueOnce(false);
|
jest.mocked(confirmAsync).mockResolvedValueOnce(false);
|
||||||
expect(selectBuildToCancelAsync(projectId, 'blah')).resolves.toEqual(null);
|
const graphqlClient = instance(mock<ExpoGraphqlClient>());
|
||||||
|
expect(selectBuildToCancelAsync(graphqlClient, projectId, 'blah')).resolves.toEqual(null);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns build id when confirmation is confirmed', async () => {
|
it('returns build id when confirmation is confirmed', async () => {
|
||||||
jest.mocked(selectAsync).mockResolvedValueOnce(selectedBuildId);
|
jest.mocked(selectAsync).mockResolvedValueOnce(selectedBuildId);
|
||||||
jest.mocked(confirmAsync).mockResolvedValueOnce(true);
|
jest.mocked(confirmAsync).mockResolvedValueOnce(true);
|
||||||
expect(selectBuildToCancelAsync(projectId, 'blah')).resolves.toEqual(selectedBuildId);
|
const graphqlClient = instance(mock<ExpoGraphqlClient>());
|
||||||
|
expect(selectBuildToCancelAsync(graphqlClient, projectId, 'blah')).resolves.toEqual(
|
||||||
|
selectedBuildId
|
||||||
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { AppVersionSource } from '@expo/eas-json';
|
|||||||
import chalk from 'chalk';
|
import chalk from 'chalk';
|
||||||
import nullthrows from 'nullthrows';
|
import nullthrows from 'nullthrows';
|
||||||
|
|
||||||
|
import { ExpoGraphqlClient } from '../../commandUtils/context/contextUtils/createGraphqlClient';
|
||||||
import AndroidCredentialsProvider, {
|
import AndroidCredentialsProvider, {
|
||||||
AndroidCredentials,
|
AndroidCredentials,
|
||||||
} from '../../credentials/android/AndroidCredentialsProvider';
|
} from '../../credentials/android/AndroidCredentialsProvider';
|
||||||
@@ -63,7 +64,7 @@ This means that it will most likely produce an AAB and you will not be able to i
|
|||||||
const applicationId = await getApplicationIdAsync(ctx.projectDir, ctx.exp, gradleContext);
|
const applicationId = await getApplicationIdAsync(ctx.projectDir, ctx.exp, gradleContext);
|
||||||
const versionCodeOverride =
|
const versionCodeOverride =
|
||||||
ctx.easJsonCliConfig?.appVersionSource === AppVersionSource.REMOTE
|
ctx.easJsonCliConfig?.appVersionSource === AppVersionSource.REMOTE
|
||||||
? await resolveRemoteVersionCodeAsync({
|
? await resolveRemoteVersionCodeAsync(ctx.graphqlClient, {
|
||||||
projectDir: ctx.projectDir,
|
projectDir: ctx.projectDir,
|
||||||
projectId: ctx.projectId,
|
projectId: ctx.projectId,
|
||||||
exp: ctx.exp,
|
exp: ctx.exp,
|
||||||
@@ -84,7 +85,7 @@ export async function prepareAndroidBuildAsync(
|
|||||||
return await ensureAndroidCredentialsAsync(ctx);
|
return await ensureAndroidCredentialsAsync(ctx);
|
||||||
},
|
},
|
||||||
syncProjectConfigurationAsync: async () => {
|
syncProjectConfigurationAsync: async () => {
|
||||||
await syncProjectConfigurationAsync({
|
await syncProjectConfigurationAsync(ctx.graphqlClient, {
|
||||||
projectDir: ctx.projectDir,
|
projectDir: ctx.projectDir,
|
||||||
exp: ctx.exp,
|
exp: ctx.exp,
|
||||||
localAutoIncrement:
|
localAutoIncrement:
|
||||||
@@ -101,6 +102,7 @@ export async function prepareAndroidBuildAsync(
|
|||||||
return await prepareJobAsync(ctx, jobData);
|
return await prepareJobAsync(ctx, jobData);
|
||||||
},
|
},
|
||||||
sendBuildRequestAsync: async (
|
sendBuildRequestAsync: async (
|
||||||
|
graphqlClient: ExpoGraphqlClient,
|
||||||
appId: string,
|
appId: string,
|
||||||
job: Android.Job,
|
job: Android.Job,
|
||||||
metadata: Metadata,
|
metadata: Metadata,
|
||||||
@@ -108,7 +110,7 @@ export async function prepareAndroidBuildAsync(
|
|||||||
): Promise<BuildResult> => {
|
): Promise<BuildResult> => {
|
||||||
const graphqlMetadata = transformMetadata(metadata);
|
const graphqlMetadata = transformMetadata(metadata);
|
||||||
const graphqlJob = transformJob(job);
|
const graphqlJob = transformJob(job);
|
||||||
return await BuildMutation.createAndroidBuildAsync({
|
return await BuildMutation.createAndroidBuildAsync(graphqlClient, {
|
||||||
appId,
|
appId,
|
||||||
job: graphqlJob,
|
job: graphqlJob,
|
||||||
metadata: graphqlMetadata,
|
metadata: graphqlMetadata,
|
||||||
|
|||||||
@@ -6,30 +6,34 @@ import chalk from 'chalk';
|
|||||||
import fs from 'fs-extra';
|
import fs from 'fs-extra';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
|
||||||
|
import { ExpoGraphqlClient } from '../../commandUtils/context/contextUtils/createGraphqlClient';
|
||||||
import Log from '../../log';
|
import Log from '../../log';
|
||||||
import { isExpoUpdatesInstalled } from '../../project/projectUtils';
|
import { isExpoUpdatesInstalled } from '../../project/projectUtils';
|
||||||
import { resolveWorkflowAsync } from '../../project/workflow';
|
import { resolveWorkflowAsync } from '../../project/workflow';
|
||||||
import { syncUpdatesConfigurationAsync } from '../../update/android/UpdatesModule';
|
import { syncUpdatesConfigurationAsync } from '../../update/android/UpdatesModule';
|
||||||
import { BumpStrategy, bumpVersionAsync, bumpVersionInAppJsonAsync } from './version';
|
import { BumpStrategy, bumpVersionAsync, bumpVersionInAppJsonAsync } from './version';
|
||||||
|
|
||||||
export async function syncProjectConfigurationAsync({
|
export async function syncProjectConfigurationAsync(
|
||||||
projectDir,
|
graphqlClient: ExpoGraphqlClient,
|
||||||
exp,
|
{
|
||||||
localAutoIncrement,
|
projectDir,
|
||||||
projectId,
|
exp,
|
||||||
}: {
|
localAutoIncrement,
|
||||||
projectDir: string;
|
projectId,
|
||||||
exp: ExpoConfig;
|
}: {
|
||||||
localAutoIncrement?: AndroidVersionAutoIncrement;
|
projectDir: string;
|
||||||
projectId: string;
|
exp: ExpoConfig;
|
||||||
}): Promise<void> {
|
localAutoIncrement?: AndroidVersionAutoIncrement;
|
||||||
|
projectId: string;
|
||||||
|
}
|
||||||
|
): Promise<void> {
|
||||||
const workflow = await resolveWorkflowAsync(projectDir, Platform.ANDROID);
|
const workflow = await resolveWorkflowAsync(projectDir, Platform.ANDROID);
|
||||||
const versionBumpStrategy = resolveVersionBumpStrategy(localAutoIncrement ?? false);
|
const versionBumpStrategy = resolveVersionBumpStrategy(localAutoIncrement ?? false);
|
||||||
|
|
||||||
if (workflow === Workflow.GENERIC) {
|
if (workflow === Workflow.GENERIC) {
|
||||||
await cleanUpOldEasBuildGradleScriptAsync(projectDir);
|
await cleanUpOldEasBuildGradleScriptAsync(projectDir);
|
||||||
if (isExpoUpdatesInstalled(projectDir)) {
|
if (isExpoUpdatesInstalled(projectDir)) {
|
||||||
await syncUpdatesConfigurationAsync(projectDir, exp, projectId);
|
await syncUpdatesConfigurationAsync(graphqlClient, projectDir, exp, projectId);
|
||||||
}
|
}
|
||||||
await bumpVersionAsync({ projectDir, exp, bumpStrategy: versionBumpStrategy });
|
await bumpVersionAsync({ projectDir, exp, bumpStrategy: versionBumpStrategy });
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import { BuildProfile } from '@expo/eas-json';
|
|||||||
import chalk from 'chalk';
|
import chalk from 'chalk';
|
||||||
import fs from 'fs-extra';
|
import fs from 'fs-extra';
|
||||||
|
|
||||||
|
import { ExpoGraphqlClient } from '../../commandUtils/context/contextUtils/createGraphqlClient';
|
||||||
import { AppPlatform } from '../../graphql/generated';
|
import { AppPlatform } from '../../graphql/generated';
|
||||||
import { AppVersionMutation } from '../../graphql/mutations/AppVersionMutation';
|
import { AppVersionMutation } from '../../graphql/mutations/AppVersionMutation';
|
||||||
import { AppVersionQuery } from '../../graphql/queries/AppVersionQuery';
|
import { AppVersionQuery } from '../../graphql/queries/AppVersionQuery';
|
||||||
@@ -174,20 +175,24 @@ async function writeBuildGradleAsync({
|
|||||||
* Returns buildNumber that will be used for the next build. If current build profile
|
* Returns buildNumber that will be used for the next build. If current build profile
|
||||||
* has an 'autoIncrement' option set, it increments the version on server.
|
* has an 'autoIncrement' option set, it increments the version on server.
|
||||||
*/
|
*/
|
||||||
export async function resolveRemoteVersionCodeAsync({
|
export async function resolveRemoteVersionCodeAsync(
|
||||||
projectDir,
|
graphqlClient: ExpoGraphqlClient,
|
||||||
projectId,
|
{
|
||||||
exp,
|
projectDir,
|
||||||
applicationId,
|
projectId,
|
||||||
buildProfile,
|
exp,
|
||||||
}: {
|
applicationId,
|
||||||
projectDir: string;
|
buildProfile,
|
||||||
projectId: string;
|
}: {
|
||||||
exp: ExpoConfig;
|
projectDir: string;
|
||||||
applicationId: string;
|
projectId: string;
|
||||||
buildProfile: BuildProfile<Platform.ANDROID>;
|
exp: ExpoConfig;
|
||||||
}): Promise<string> {
|
applicationId: string;
|
||||||
|
buildProfile: BuildProfile<Platform.ANDROID>;
|
||||||
|
}
|
||||||
|
): Promise<string> {
|
||||||
const remoteVersions = await AppVersionQuery.latestVersionAsync(
|
const remoteVersions = await AppVersionQuery.latestVersionAsync(
|
||||||
|
graphqlClient,
|
||||||
projectId,
|
projectId,
|
||||||
AppPlatform.Android,
|
AppPlatform.Android,
|
||||||
applicationId
|
applicationId
|
||||||
@@ -217,7 +222,7 @@ export async function resolveRemoteVersionCodeAsync({
|
|||||||
`Initializing versionCode with ${chalk.bold(currentBuildVersion)}.`
|
`Initializing versionCode with ${chalk.bold(currentBuildVersion)}.`
|
||||||
).start();
|
).start();
|
||||||
try {
|
try {
|
||||||
await AppVersionMutation.createAppVersionAsync({
|
await AppVersionMutation.createAppVersionAsync(graphqlClient, {
|
||||||
appId: projectId,
|
appId: projectId,
|
||||||
platform: AppPlatform.Android,
|
platform: AppPlatform.Android,
|
||||||
applicationIdentifier: applicationId,
|
applicationIdentifier: applicationId,
|
||||||
@@ -239,7 +244,7 @@ export async function resolveRemoteVersionCodeAsync({
|
|||||||
)}.`
|
)}.`
|
||||||
).start();
|
).start();
|
||||||
try {
|
try {
|
||||||
await AppVersionMutation.createAppVersionAsync({
|
await AppVersionMutation.createAppVersionAsync(graphqlClient, {
|
||||||
appId: projectId,
|
appId: projectId,
|
||||||
platform: AppPlatform.Android,
|
platform: AppPlatform.Android,
|
||||||
applicationIdentifier: applicationId,
|
applicationIdentifier: applicationId,
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import nullthrows from 'nullthrows';
|
|||||||
import { withAnalyticsAsync } from '../analytics/common';
|
import { withAnalyticsAsync } from '../analytics/common';
|
||||||
import { BuildEvent } from '../analytics/events';
|
import { BuildEvent } from '../analytics/events';
|
||||||
import { getExpoWebsiteBaseUrl } from '../api';
|
import { getExpoWebsiteBaseUrl } from '../api';
|
||||||
|
import { ExpoGraphqlClient } from '../commandUtils/context/contextUtils/createGraphqlClient';
|
||||||
import {
|
import {
|
||||||
AppPlatform,
|
AppPlatform,
|
||||||
BuildFragment,
|
BuildFragment,
|
||||||
@@ -55,6 +56,7 @@ interface Builder<TPlatform extends Platform, Credentials, TJob extends Job> {
|
|||||||
syncProjectConfigurationAsync(ctx: BuildContext<TPlatform>): Promise<void>;
|
syncProjectConfigurationAsync(ctx: BuildContext<TPlatform>): Promise<void>;
|
||||||
prepareJobAsync(ctx: BuildContext<TPlatform>, jobData: JobData<Credentials>): Promise<Job>;
|
prepareJobAsync(ctx: BuildContext<TPlatform>, jobData: JobData<Credentials>): Promise<Job>;
|
||||||
sendBuildRequestAsync(
|
sendBuildRequestAsync(
|
||||||
|
graphqlClient: ExpoGraphqlClient,
|
||||||
appId: string,
|
appId: string,
|
||||||
job: TJob,
|
job: TJob,
|
||||||
metadata: Metadata,
|
metadata: Metadata,
|
||||||
@@ -213,6 +215,7 @@ async function uploadProjectAsync<TPlatform extends Platform>(
|
|||||||
projectTarballPath = projectTarball.path;
|
projectTarballPath = projectTarball.path;
|
||||||
|
|
||||||
const { bucketKey } = await uploadFileAtPathToS3Async(
|
const { bucketKey } = await uploadFileAtPathToS3Async(
|
||||||
|
ctx.graphqlClient,
|
||||||
UploadSessionType.EasBuildProjectSources,
|
UploadSessionType.EasBuildProjectSources,
|
||||||
projectTarball.path,
|
projectTarball.path,
|
||||||
createProgressTracker({
|
createProgressTracker({
|
||||||
@@ -254,6 +257,7 @@ async function sendBuildRequestAsync<TPlatform extends Platform, Credentials, TJ
|
|||||||
}
|
}
|
||||||
|
|
||||||
const { build, deprecationInfo } = await builder.sendBuildRequestAsync(
|
const { build, deprecationInfo } = await builder.sendBuildRequestAsync(
|
||||||
|
ctx.graphqlClient,
|
||||||
ctx.projectId,
|
ctx.projectId,
|
||||||
job,
|
job,
|
||||||
metadata,
|
metadata,
|
||||||
@@ -275,6 +279,7 @@ async function sendBuildRequestAsync<TPlatform extends Platform, Credentials, TJ
|
|||||||
type MaybeBuildFragment = BuildFragment | null;
|
type MaybeBuildFragment = BuildFragment | null;
|
||||||
|
|
||||||
export async function waitForBuildEndAsync(
|
export async function waitForBuildEndAsync(
|
||||||
|
graphqlClient: ExpoGraphqlClient,
|
||||||
{ buildIds, accountName }: { buildIds: string[]; accountName: string },
|
{ buildIds, accountName }: { buildIds: string[]; accountName: string },
|
||||||
{ intervalSec = 10 } = {}
|
{ intervalSec = 10 } = {}
|
||||||
): Promise<MaybeBuildFragment[]> {
|
): Promise<MaybeBuildFragment[]> {
|
||||||
@@ -289,7 +294,7 @@ export async function waitForBuildEndAsync(
|
|||||||
spinner = ora('Waiting for builds to complete. You can press Ctrl+C to exit.').start();
|
spinner = ora('Waiting for builds to complete. You can press Ctrl+C to exit.').start();
|
||||||
}
|
}
|
||||||
while (true) {
|
while (true) {
|
||||||
const builds = await getBuildsSafelyAsync(buildIds);
|
const builds = await getBuildsSafelyAsync(graphqlClient, buildIds);
|
||||||
const { refetch } =
|
const { refetch } =
|
||||||
builds.length === 1
|
builds.length === 1
|
||||||
? await handleSingleBuildProgressAsync({ build: builds[0], accountName }, { spinner })
|
? await handleSingleBuildProgressAsync({ build: builds[0], accountName }, { spinner })
|
||||||
@@ -301,10 +306,13 @@ export async function waitForBuildEndAsync(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getBuildsSafelyAsync(buildIds: string[]): Promise<MaybeBuildFragment[]> {
|
async function getBuildsSafelyAsync(
|
||||||
|
graphqlClient: ExpoGraphqlClient,
|
||||||
|
buildIds: string[]
|
||||||
|
): Promise<MaybeBuildFragment[]> {
|
||||||
const promises = buildIds.map(async buildId => {
|
const promises = buildIds.map(async buildId => {
|
||||||
try {
|
try {
|
||||||
return await BuildQuery.byIdAsync(buildId, { useCache: false });
|
return await BuildQuery.byIdAsync(graphqlClient, buildId, { useCache: false });
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
Log.debug('Failed to fetch the build status', err);
|
Log.debug('Failed to fetch the build status', err);
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { Platform, Workflow } from '@expo/eas-build-job';
|
|||||||
import { BuildProfile, EasJson } from '@expo/eas-json';
|
import { BuildProfile, EasJson } from '@expo/eas-json';
|
||||||
|
|
||||||
import { TrackingContext } from '../analytics/common';
|
import { TrackingContext } from '../analytics/common';
|
||||||
|
import { ExpoGraphqlClient } from '../commandUtils/context/contextUtils/createGraphqlClient';
|
||||||
import { CredentialsContext } from '../credentials/context';
|
import { CredentialsContext } from '../credentials/context';
|
||||||
import { Target } from '../credentials/ios/types';
|
import { Target } from '../credentials/ios/types';
|
||||||
import { BuildResourceClass } from '../graphql/generated';
|
import { BuildResourceClass } from '../graphql/generated';
|
||||||
@@ -47,6 +48,7 @@ export interface BuildContext<T extends Platform> {
|
|||||||
message?: string;
|
message?: string;
|
||||||
trackingCtx: TrackingContext;
|
trackingCtx: TrackingContext;
|
||||||
user: Actor;
|
user: Actor;
|
||||||
|
graphqlClient: ExpoGraphqlClient;
|
||||||
workflow: Workflow;
|
workflow: Workflow;
|
||||||
android: T extends Platform.ANDROID ? AndroidBuildContext : undefined;
|
android: T extends Platform.ANDROID ? AndroidBuildContext : undefined;
|
||||||
ios: T extends Platform.IOS ? IosBuildContext : undefined;
|
ios: T extends Platform.IOS ? IosBuildContext : undefined;
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import { v4 as uuidv4 } from 'uuid';
|
|||||||
import { TrackingContext } from '../analytics/common';
|
import { TrackingContext } from '../analytics/common';
|
||||||
import { Analytics, BuildEvent } from '../analytics/events';
|
import { Analytics, BuildEvent } from '../analytics/events';
|
||||||
import { DynamicConfigContextFn } from '../commandUtils/context/DynamicProjectConfigContextField';
|
import { DynamicConfigContextFn } from '../commandUtils/context/DynamicProjectConfigContextField';
|
||||||
|
import { ExpoGraphqlClient } from '../commandUtils/context/contextUtils/createGraphqlClient';
|
||||||
import { CredentialsContext } from '../credentials/context';
|
import { CredentialsContext } from '../credentials/context';
|
||||||
import { BuildResourceClass } from '../graphql/generated';
|
import { BuildResourceClass } from '../graphql/generated';
|
||||||
import { getOwnerAccountForProjectIdAsync } from '../project/projectUtils';
|
import { getOwnerAccountForProjectIdAsync } from '../project/projectUtils';
|
||||||
@@ -31,6 +32,7 @@ export async function createBuildContextAsync<T extends Platform>({
|
|||||||
resourceClass,
|
resourceClass,
|
||||||
message,
|
message,
|
||||||
actor,
|
actor,
|
||||||
|
graphqlClient,
|
||||||
getDynamicProjectConfigAsync,
|
getDynamicProjectConfigAsync,
|
||||||
}: {
|
}: {
|
||||||
buildProfileName: string;
|
buildProfileName: string;
|
||||||
@@ -45,12 +47,13 @@ export async function createBuildContextAsync<T extends Platform>({
|
|||||||
resourceClass: BuildResourceClass;
|
resourceClass: BuildResourceClass;
|
||||||
message?: string;
|
message?: string;
|
||||||
actor: Actor;
|
actor: Actor;
|
||||||
|
graphqlClient: ExpoGraphqlClient;
|
||||||
getDynamicProjectConfigAsync: DynamicConfigContextFn;
|
getDynamicProjectConfigAsync: DynamicConfigContextFn;
|
||||||
}): Promise<BuildContext<T>> {
|
}): Promise<BuildContext<T>> {
|
||||||
const { exp, projectId } = await getDynamicProjectConfigAsync({ env: buildProfile.env });
|
const { exp, projectId } = await getDynamicProjectConfigAsync({ env: buildProfile.env });
|
||||||
|
|
||||||
const projectName = exp.slug;
|
const projectName = exp.slug;
|
||||||
const account = await getOwnerAccountForProjectIdAsync(projectId);
|
const account = await getOwnerAccountForProjectIdAsync(graphqlClient, projectId);
|
||||||
const workflow = await resolveWorkflowAsync(projectDir, platform);
|
const workflow = await resolveWorkflowAsync(projectDir, platform);
|
||||||
const accountId = account.id;
|
const accountId = account.id;
|
||||||
const runFromCI = getenv.boolish('CI', false);
|
const runFromCI = getenv.boolish('CI', false);
|
||||||
@@ -60,6 +63,7 @@ export async function createBuildContextAsync<T extends Platform>({
|
|||||||
nonInteractive,
|
nonInteractive,
|
||||||
projectDir,
|
projectDir,
|
||||||
user: actor,
|
user: actor,
|
||||||
|
graphqlClient,
|
||||||
env: buildProfile.env,
|
env: buildProfile.env,
|
||||||
easJsonCliConfig,
|
easJsonCliConfig,
|
||||||
});
|
});
|
||||||
@@ -99,6 +103,7 @@ export async function createBuildContextAsync<T extends Platform>({
|
|||||||
projectName,
|
projectName,
|
||||||
trackingCtx,
|
trackingCtx,
|
||||||
user: actor,
|
user: actor,
|
||||||
|
graphqlClient,
|
||||||
workflow,
|
workflow,
|
||||||
message,
|
message,
|
||||||
runFromCI,
|
runFromCI,
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { Ios, Job, Metadata, Platform, Workflow } from '@expo/eas-build-job';
|
import { Ios, Job, Metadata, Platform, Workflow } from '@expo/eas-build-job';
|
||||||
import { AppVersionSource } from '@expo/eas-json';
|
import { AppVersionSource } from '@expo/eas-json';
|
||||||
|
|
||||||
|
import { ExpoGraphqlClient } from '../../commandUtils/context/contextUtils/createGraphqlClient';
|
||||||
import { IosCredentials } from '../../credentials/ios/types';
|
import { IosCredentials } from '../../credentials/ios/types';
|
||||||
import { BuildParamsInput } from '../../graphql/generated';
|
import { BuildParamsInput } from '../../graphql/generated';
|
||||||
import { BuildMutation, BuildResult } from '../../graphql/mutations/BuildMutation';
|
import { BuildMutation, BuildResult } from '../../graphql/mutations/BuildMutation';
|
||||||
@@ -46,7 +47,7 @@ export async function createIosContextAsync(
|
|||||||
const applicationTarget = findApplicationTarget(targets);
|
const applicationTarget = findApplicationTarget(targets);
|
||||||
const buildNumberOverride =
|
const buildNumberOverride =
|
||||||
ctx.easJsonCliConfig?.appVersionSource === AppVersionSource.REMOTE
|
ctx.easJsonCliConfig?.appVersionSource === AppVersionSource.REMOTE
|
||||||
? await resolveRemoteBuildNumberAsync({
|
? await resolveRemoteBuildNumberAsync(ctx.graphqlClient, {
|
||||||
projectDir: ctx.projectDir,
|
projectDir: ctx.projectDir,
|
||||||
projectId: ctx.projectId,
|
projectId: ctx.projectId,
|
||||||
exp: ctx.exp,
|
exp: ctx.exp,
|
||||||
@@ -72,7 +73,7 @@ export async function prepareIosBuildAsync(
|
|||||||
return ensureIosCredentialsAsync(ctx, ctx.ios.targets);
|
return ensureIosCredentialsAsync(ctx, ctx.ios.targets);
|
||||||
},
|
},
|
||||||
syncProjectConfigurationAsync: async () => {
|
syncProjectConfigurationAsync: async () => {
|
||||||
await syncProjectConfigurationAsync({
|
await syncProjectConfigurationAsync(ctx.graphqlClient, {
|
||||||
projectDir: ctx.projectDir,
|
projectDir: ctx.projectDir,
|
||||||
exp: ctx.exp,
|
exp: ctx.exp,
|
||||||
targets: ctx.ios.targets,
|
targets: ctx.ios.targets,
|
||||||
@@ -93,6 +94,7 @@ export async function prepareIosBuildAsync(
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
sendBuildRequestAsync: async (
|
sendBuildRequestAsync: async (
|
||||||
|
graphqlClient: ExpoGraphqlClient,
|
||||||
appId: string,
|
appId: string,
|
||||||
job: Ios.Job,
|
job: Ios.Job,
|
||||||
metadata: Metadata,
|
metadata: Metadata,
|
||||||
@@ -100,7 +102,7 @@ export async function prepareIosBuildAsync(
|
|||||||
): Promise<BuildResult> => {
|
): Promise<BuildResult> => {
|
||||||
const graphqlMetadata = transformMetadata(metadata);
|
const graphqlMetadata = transformMetadata(metadata);
|
||||||
const graphqlJob = transformJob(job);
|
const graphqlJob = transformJob(job);
|
||||||
return await BuildMutation.createIosBuildAsync({
|
return await BuildMutation.createIosBuildAsync(graphqlClient, {
|
||||||
appId,
|
appId,
|
||||||
job: graphqlJob,
|
job: graphqlJob,
|
||||||
metadata: graphqlMetadata,
|
metadata: graphqlMetadata,
|
||||||
|
|||||||
@@ -2,31 +2,35 @@ import { ExpoConfig } from '@expo/config';
|
|||||||
import { Platform, Workflow } from '@expo/eas-build-job';
|
import { Platform, Workflow } from '@expo/eas-build-job';
|
||||||
import { IosVersionAutoIncrement } from '@expo/eas-json';
|
import { IosVersionAutoIncrement } from '@expo/eas-json';
|
||||||
|
|
||||||
|
import { ExpoGraphqlClient } from '../../commandUtils/context/contextUtils/createGraphqlClient';
|
||||||
import { Target } from '../../credentials/ios/types';
|
import { Target } from '../../credentials/ios/types';
|
||||||
import { isExpoUpdatesInstalled } from '../../project/projectUtils';
|
import { isExpoUpdatesInstalled } from '../../project/projectUtils';
|
||||||
import { resolveWorkflowAsync } from '../../project/workflow';
|
import { resolveWorkflowAsync } from '../../project/workflow';
|
||||||
import { syncUpdatesConfigurationAsync } from '../../update/ios/UpdatesModule';
|
import { syncUpdatesConfigurationAsync } from '../../update/ios/UpdatesModule';
|
||||||
import { BumpStrategy, bumpVersionAsync, bumpVersionInAppJsonAsync } from './version';
|
import { BumpStrategy, bumpVersionAsync, bumpVersionInAppJsonAsync } from './version';
|
||||||
|
|
||||||
export async function syncProjectConfigurationAsync({
|
export async function syncProjectConfigurationAsync(
|
||||||
projectDir,
|
graphqlClient: ExpoGraphqlClient,
|
||||||
exp,
|
{
|
||||||
targets,
|
projectDir,
|
||||||
localAutoIncrement,
|
exp,
|
||||||
projectId,
|
targets,
|
||||||
}: {
|
localAutoIncrement,
|
||||||
projectDir: string;
|
projectId,
|
||||||
exp: ExpoConfig;
|
}: {
|
||||||
targets: Target[];
|
projectDir: string;
|
||||||
localAutoIncrement?: IosVersionAutoIncrement;
|
exp: ExpoConfig;
|
||||||
projectId: string;
|
targets: Target[];
|
||||||
}): Promise<void> {
|
localAutoIncrement?: IosVersionAutoIncrement;
|
||||||
|
projectId: string;
|
||||||
|
}
|
||||||
|
): Promise<void> {
|
||||||
const workflow = await resolveWorkflowAsync(projectDir, Platform.IOS);
|
const workflow = await resolveWorkflowAsync(projectDir, Platform.IOS);
|
||||||
const versionBumpStrategy = resolveVersionBumpStrategy(localAutoIncrement ?? false);
|
const versionBumpStrategy = resolveVersionBumpStrategy(localAutoIncrement ?? false);
|
||||||
|
|
||||||
if (workflow === Workflow.GENERIC) {
|
if (workflow === Workflow.GENERIC) {
|
||||||
if (isExpoUpdatesInstalled(projectDir)) {
|
if (isExpoUpdatesInstalled(projectDir)) {
|
||||||
await syncUpdatesConfigurationAsync(projectDir, exp, projectId);
|
await syncUpdatesConfigurationAsync(graphqlClient, projectDir, exp, projectId);
|
||||||
}
|
}
|
||||||
await bumpVersionAsync({ projectDir, exp, bumpStrategy: versionBumpStrategy, targets });
|
await bumpVersionAsync({ projectDir, exp, bumpStrategy: versionBumpStrategy, targets });
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import chalk from 'chalk';
|
|||||||
import path from 'path';
|
import path from 'path';
|
||||||
import type { XCBuildConfiguration } from 'xcode';
|
import type { XCBuildConfiguration } from 'xcode';
|
||||||
|
|
||||||
|
import { ExpoGraphqlClient } from '../../commandUtils/context/contextUtils/createGraphqlClient';
|
||||||
import { Target } from '../../credentials/ios/types';
|
import { Target } from '../../credentials/ios/types';
|
||||||
import { AppPlatform } from '../../graphql/generated';
|
import { AppPlatform } from '../../graphql/generated';
|
||||||
import { AppVersionMutation } from '../../graphql/mutations/AppVersionMutation';
|
import { AppVersionMutation } from '../../graphql/mutations/AppVersionMutation';
|
||||||
@@ -255,20 +256,24 @@ export function evaluateTemplateString(
|
|||||||
* Returns buildNumber that will be used for the next build. If current build profile
|
* Returns buildNumber that will be used for the next build. If current build profile
|
||||||
* has an 'autoIncrement' option set, it increments the version on server.
|
* has an 'autoIncrement' option set, it increments the version on server.
|
||||||
*/
|
*/
|
||||||
export async function resolveRemoteBuildNumberAsync({
|
export async function resolveRemoteBuildNumberAsync(
|
||||||
projectDir,
|
graphqlClient: ExpoGraphqlClient,
|
||||||
projectId,
|
{
|
||||||
exp,
|
projectDir,
|
||||||
applicationTarget,
|
projectId,
|
||||||
buildProfile,
|
exp,
|
||||||
}: {
|
applicationTarget,
|
||||||
projectDir: string;
|
buildProfile,
|
||||||
projectId: string;
|
}: {
|
||||||
exp: ExpoConfig;
|
projectDir: string;
|
||||||
applicationTarget: Target;
|
projectId: string;
|
||||||
buildProfile: BuildProfile<Platform.IOS>;
|
exp: ExpoConfig;
|
||||||
}): Promise<string> {
|
applicationTarget: Target;
|
||||||
|
buildProfile: BuildProfile<Platform.IOS>;
|
||||||
|
}
|
||||||
|
): Promise<string> {
|
||||||
const remoteVersions = await AppVersionQuery.latestVersionAsync(
|
const remoteVersions = await AppVersionQuery.latestVersionAsync(
|
||||||
|
graphqlClient,
|
||||||
projectId,
|
projectId,
|
||||||
AppPlatform.Ios,
|
AppPlatform.Ios,
|
||||||
applicationTarget.bundleIdentifier
|
applicationTarget.bundleIdentifier
|
||||||
@@ -307,7 +312,7 @@ export async function resolveRemoteBuildNumberAsync({
|
|||||||
`Initializing buildNumber with ${chalk.bold(currentBuildVersion)}.`
|
`Initializing buildNumber with ${chalk.bold(currentBuildVersion)}.`
|
||||||
).start();
|
).start();
|
||||||
try {
|
try {
|
||||||
await AppVersionMutation.createAppVersionAsync({
|
await AppVersionMutation.createAppVersionAsync(graphqlClient, {
|
||||||
appId: projectId,
|
appId: projectId,
|
||||||
platform: AppPlatform.Ios,
|
platform: AppPlatform.Ios,
|
||||||
applicationIdentifier: applicationTarget.bundleIdentifier,
|
applicationIdentifier: applicationTarget.bundleIdentifier,
|
||||||
@@ -329,7 +334,7 @@ export async function resolveRemoteBuildNumberAsync({
|
|||||||
)}.`
|
)}.`
|
||||||
).start();
|
).start();
|
||||||
try {
|
try {
|
||||||
await AppVersionMutation.createAppVersionAsync({
|
await AppVersionMutation.createAppVersionAsync(graphqlClient, {
|
||||||
appId: projectId,
|
appId: projectId,
|
||||||
platform: AppPlatform.Ios,
|
platform: AppPlatform.Ios,
|
||||||
applicationIdentifier: applicationTarget.bundleIdentifier,
|
applicationIdentifier: applicationTarget.bundleIdentifier,
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import chalk from 'chalk';
|
import chalk from 'chalk';
|
||||||
|
|
||||||
|
import { ExpoGraphqlClient } from '../commandUtils/context/contextUtils/createGraphqlClient';
|
||||||
import { PaginatedQueryOptions } from '../commandUtils/pagination';
|
import { PaginatedQueryOptions } from '../commandUtils/pagination';
|
||||||
import { BuildFilter, BuildFragment } from '../graphql/generated';
|
import { BuildFilter, BuildFragment } from '../graphql/generated';
|
||||||
import { BuildQuery } from '../graphql/queries/BuildQuery';
|
import { BuildQuery } from '../graphql/queries/BuildQuery';
|
||||||
@@ -10,19 +11,22 @@ import { formatGraphQLBuild } from './utils/formatBuild';
|
|||||||
|
|
||||||
export const BUILDS_LIMIT = 50;
|
export const BUILDS_LIMIT = 50;
|
||||||
|
|
||||||
export async function listAndRenderBuildsOnAppAsync({
|
export async function listAndRenderBuildsOnAppAsync(
|
||||||
projectId,
|
graphqlClient: ExpoGraphqlClient,
|
||||||
projectDisplayName,
|
{
|
||||||
filter,
|
projectId,
|
||||||
paginatedQueryOptions,
|
projectDisplayName,
|
||||||
}: {
|
filter,
|
||||||
projectId: string;
|
paginatedQueryOptions,
|
||||||
projectDisplayName: string;
|
}: {
|
||||||
filter?: BuildFilter;
|
projectId: string;
|
||||||
paginatedQueryOptions: PaginatedQueryOptions;
|
projectDisplayName: string;
|
||||||
}): Promise<void> {
|
filter?: BuildFilter;
|
||||||
|
paginatedQueryOptions: PaginatedQueryOptions;
|
||||||
|
}
|
||||||
|
): Promise<void> {
|
||||||
if (paginatedQueryOptions.nonInteractive) {
|
if (paginatedQueryOptions.nonInteractive) {
|
||||||
const builds = await BuildQuery.viewBuildsOnAppAsync({
|
const builds = await BuildQuery.viewBuildsOnAppAsync(graphqlClient, {
|
||||||
appId: projectId,
|
appId: projectId,
|
||||||
limit: paginatedQueryOptions.limit ?? BUILDS_LIMIT,
|
limit: paginatedQueryOptions.limit ?? BUILDS_LIMIT,
|
||||||
offset: paginatedQueryOptions.offset,
|
offset: paginatedQueryOptions.offset,
|
||||||
@@ -34,7 +38,7 @@ export async function listAndRenderBuildsOnAppAsync({
|
|||||||
limit: paginatedQueryOptions.limit ?? BUILDS_LIMIT,
|
limit: paginatedQueryOptions.limit ?? BUILDS_LIMIT,
|
||||||
offset: paginatedQueryOptions.offset,
|
offset: paginatedQueryOptions.offset,
|
||||||
queryToPerform: (limit, offset) =>
|
queryToPerform: (limit, offset) =>
|
||||||
BuildQuery.viewBuildsOnAppAsync({
|
BuildQuery.viewBuildsOnAppAsync(graphqlClient, {
|
||||||
appId: projectId,
|
appId: projectId,
|
||||||
limit,
|
limit,
|
||||||
offset,
|
offset,
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import chalk from 'chalk';
|
|||||||
import nullthrows from 'nullthrows';
|
import nullthrows from 'nullthrows';
|
||||||
|
|
||||||
import { DynamicConfigContextFn } from '../commandUtils/context/DynamicProjectConfigContextField';
|
import { DynamicConfigContextFn } from '../commandUtils/context/DynamicProjectConfigContextField';
|
||||||
|
import { ExpoGraphqlClient } from '../commandUtils/context/contextUtils/createGraphqlClient';
|
||||||
import {
|
import {
|
||||||
AppPlatform,
|
AppPlatform,
|
||||||
BuildFragment,
|
BuildFragment,
|
||||||
@@ -114,6 +115,7 @@ function resolveResourceClass(
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function runBuildAndSubmitAsync(
|
export async function runBuildAndSubmitAsync(
|
||||||
|
graphqlClient: ExpoGraphqlClient,
|
||||||
projectDir: string,
|
projectDir: string,
|
||||||
flags: BuildFlags,
|
flags: BuildFlags,
|
||||||
actor: Actor,
|
actor: Actor,
|
||||||
@@ -166,6 +168,7 @@ export async function runBuildAndSubmitAsync(
|
|||||||
),
|
),
|
||||||
easJsonCliConfig,
|
easJsonCliConfig,
|
||||||
actor,
|
actor,
|
||||||
|
graphqlClient,
|
||||||
getDynamicProjectConfigAsync,
|
getDynamicProjectConfigAsync,
|
||||||
});
|
});
|
||||||
if (maybeBuild) {
|
if (maybeBuild) {
|
||||||
@@ -205,7 +208,10 @@ export async function runBuildAndSubmitAsync(
|
|||||||
submitProfile,
|
submitProfile,
|
||||||
nonInteractive: flags.nonInteractive,
|
nonInteractive: flags.nonInteractive,
|
||||||
});
|
});
|
||||||
startedBuild.build = await BuildQuery.withSubmissionsByIdAsync(startedBuild.build.id);
|
startedBuild.build = await BuildQuery.withSubmissionsByIdAsync(
|
||||||
|
graphqlClient,
|
||||||
|
startedBuild.build.id
|
||||||
|
);
|
||||||
submissions.push(submission);
|
submissions.push(submission);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -222,7 +228,7 @@ export async function runBuildAndSubmitAsync(
|
|||||||
}
|
}
|
||||||
|
|
||||||
const { accountName } = Object.values(buildCtxByPlatform)[0];
|
const { accountName } = Object.values(buildCtxByPlatform)[0];
|
||||||
const builds = await waitForBuildEndAsync({
|
const builds = await waitForBuildEndAsync(graphqlClient, {
|
||||||
buildIds: startedBuilds.map(({ build }) => build.id),
|
buildIds: startedBuilds.map(({ build }) => build.id),
|
||||||
accountName,
|
accountName,
|
||||||
});
|
});
|
||||||
@@ -239,13 +245,16 @@ export async function runBuildAndSubmitAsync(
|
|||||||
}
|
}
|
||||||
exitWithNonZeroCodeIfSomeBuildsFailed(builds);
|
exitWithNonZeroCodeIfSomeBuildsFailed(builds);
|
||||||
} else {
|
} else {
|
||||||
const completedSubmissions = await waitForSubmissionsToCompleteAsync(submissions);
|
const completedSubmissions = await waitForSubmissionsToCompleteAsync(
|
||||||
|
graphqlClient,
|
||||||
|
submissions
|
||||||
|
);
|
||||||
if (flags.json) {
|
if (flags.json) {
|
||||||
printJsonOnlyOutput(
|
printJsonOnlyOutput(
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
builds
|
builds
|
||||||
.filter((i): i is BuildWithSubmissionsFragment => !!i)
|
.filter((i): i is BuildWithSubmissionsFragment => !!i)
|
||||||
.map(build => BuildQuery.withSubmissionsByIdAsync(build.id))
|
.map(build => BuildQuery.withSubmissionsByIdAsync(graphqlClient, build.id))
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -261,6 +270,7 @@ async function prepareAndStartBuildAsync({
|
|||||||
resourceClass,
|
resourceClass,
|
||||||
easJsonCliConfig,
|
easJsonCliConfig,
|
||||||
actor,
|
actor,
|
||||||
|
graphqlClient,
|
||||||
getDynamicProjectConfigAsync,
|
getDynamicProjectConfigAsync,
|
||||||
}: {
|
}: {
|
||||||
projectDir: string;
|
projectDir: string;
|
||||||
@@ -270,6 +280,7 @@ async function prepareAndStartBuildAsync({
|
|||||||
resourceClass: BuildResourceClass;
|
resourceClass: BuildResourceClass;
|
||||||
easJsonCliConfig: EasJson['cli'];
|
easJsonCliConfig: EasJson['cli'];
|
||||||
actor: Actor;
|
actor: Actor;
|
||||||
|
graphqlClient: ExpoGraphqlClient;
|
||||||
getDynamicProjectConfigAsync: DynamicConfigContextFn;
|
getDynamicProjectConfigAsync: DynamicConfigContextFn;
|
||||||
}): Promise<{ build: BuildFragment | undefined; buildCtx: BuildContext<Platform> }> {
|
}): Promise<{ build: BuildFragment | undefined; buildCtx: BuildContext<Platform> }> {
|
||||||
const buildCtx = await createBuildContextAsync({
|
const buildCtx = await createBuildContextAsync({
|
||||||
@@ -285,6 +296,7 @@ async function prepareAndStartBuildAsync({
|
|||||||
easJsonCliConfig,
|
easJsonCliConfig,
|
||||||
message: flags.message,
|
message: flags.message,
|
||||||
actor,
|
actor,
|
||||||
|
graphqlClient,
|
||||||
getDynamicProjectConfigAsync,
|
getDynamicProjectConfigAsync,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -365,6 +377,7 @@ async function prepareAndStartSubmissionAsync({
|
|||||||
credentialsCtx: buildCtx.credentialsCtx,
|
credentialsCtx: buildCtx.credentialsCtx,
|
||||||
applicationIdentifier: buildCtx.android?.applicationId ?? buildCtx.ios?.bundleIdentifier,
|
applicationIdentifier: buildCtx.android?.applicationId ?? buildCtx.ios?.bundleIdentifier,
|
||||||
actor: buildCtx.user,
|
actor: buildCtx.user,
|
||||||
|
graphqlClient: buildCtx.graphqlClient,
|
||||||
projectId: buildCtx.projectId,
|
projectId: buildCtx.projectId,
|
||||||
exp: buildCtx.exp,
|
exp: buildCtx.exp,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import chalk from 'chalk';
|
import chalk from 'chalk';
|
||||||
|
|
||||||
|
import { ExpoGraphqlClient } from '../commandUtils/context/contextUtils/createGraphqlClient';
|
||||||
import { PaginatedQueryOptions } from '../commandUtils/pagination';
|
import { PaginatedQueryOptions } from '../commandUtils/pagination';
|
||||||
import {
|
import {
|
||||||
ViewBranchesOnUpdateChannelQueryVariables,
|
ViewBranchesOnUpdateChannelQueryVariables,
|
||||||
@@ -18,15 +19,18 @@ import { logChannelDetails } from './utils';
|
|||||||
|
|
||||||
export const CHANNELS_LIMIT = 25;
|
export const CHANNELS_LIMIT = 25;
|
||||||
|
|
||||||
export async function selectChannelOnAppAsync({
|
export async function selectChannelOnAppAsync(
|
||||||
projectId,
|
graphqlClient: ExpoGraphqlClient,
|
||||||
selectionPromptTitle,
|
{
|
||||||
paginatedQueryOptions,
|
projectId,
|
||||||
}: {
|
selectionPromptTitle,
|
||||||
projectId: string;
|
paginatedQueryOptions,
|
||||||
selectionPromptTitle: string;
|
}: {
|
||||||
paginatedQueryOptions: PaginatedQueryOptions;
|
projectId: string;
|
||||||
}): Promise<UpdateChannelObject> {
|
selectionPromptTitle: string;
|
||||||
|
paginatedQueryOptions: PaginatedQueryOptions;
|
||||||
|
}
|
||||||
|
): Promise<UpdateChannelObject> {
|
||||||
if (paginatedQueryOptions.nonInteractive) {
|
if (paginatedQueryOptions.nonInteractive) {
|
||||||
throw new Error('Unable to select a channel in non-interactive mode.');
|
throw new Error('Unable to select a channel in non-interactive mode.');
|
||||||
}
|
}
|
||||||
@@ -34,7 +38,8 @@ export async function selectChannelOnAppAsync({
|
|||||||
const updateChannel = await paginatedQueryWithSelectPromptAsync({
|
const updateChannel = await paginatedQueryWithSelectPromptAsync({
|
||||||
limit: paginatedQueryOptions.limit ?? CHANNELS_LIMIT,
|
limit: paginatedQueryOptions.limit ?? CHANNELS_LIMIT,
|
||||||
offset: paginatedQueryOptions.offset,
|
offset: paginatedQueryOptions.offset,
|
||||||
queryToPerform: (limit, offset) => queryChannelsOnAppAsync({ appId: projectId, limit, offset }),
|
queryToPerform: (limit, offset) =>
|
||||||
|
queryChannelsOnAppAsync(graphqlClient, { appId: projectId, limit, offset }),
|
||||||
promptOptions: {
|
promptOptions: {
|
||||||
title: selectionPromptTitle,
|
title: selectionPromptTitle,
|
||||||
createDisplayTextForSelectionPromptListItem: updateChannel => updateChannel.name,
|
createDisplayTextForSelectionPromptListItem: updateChannel => updateChannel.name,
|
||||||
@@ -48,15 +53,18 @@ export async function selectChannelOnAppAsync({
|
|||||||
return updateChannel;
|
return updateChannel;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function listAndRenderChannelsOnAppAsync({
|
export async function listAndRenderChannelsOnAppAsync(
|
||||||
projectId,
|
graphqlClient: ExpoGraphqlClient,
|
||||||
paginatedQueryOptions,
|
{
|
||||||
}: {
|
projectId,
|
||||||
projectId: string;
|
paginatedQueryOptions,
|
||||||
paginatedQueryOptions: PaginatedQueryOptions;
|
}: {
|
||||||
}): Promise<void> {
|
projectId: string;
|
||||||
|
paginatedQueryOptions: PaginatedQueryOptions;
|
||||||
|
}
|
||||||
|
): Promise<void> {
|
||||||
if (paginatedQueryOptions.nonInteractive) {
|
if (paginatedQueryOptions.nonInteractive) {
|
||||||
const channels = await queryChannelsOnAppAsync({
|
const channels = await queryChannelsOnAppAsync(graphqlClient, {
|
||||||
appId: projectId,
|
appId: projectId,
|
||||||
limit: paginatedQueryOptions.limit ?? CHANNELS_LIMIT,
|
limit: paginatedQueryOptions.limit ?? CHANNELS_LIMIT,
|
||||||
offset: paginatedQueryOptions.offset,
|
offset: paginatedQueryOptions.offset,
|
||||||
@@ -67,7 +75,7 @@ export async function listAndRenderChannelsOnAppAsync({
|
|||||||
limit: paginatedQueryOptions.limit ?? CHANNELS_LIMIT,
|
limit: paginatedQueryOptions.limit ?? CHANNELS_LIMIT,
|
||||||
offset: paginatedQueryOptions.offset,
|
offset: paginatedQueryOptions.offset,
|
||||||
queryToPerform: (limit, offset) =>
|
queryToPerform: (limit, offset) =>
|
||||||
queryChannelsOnAppAsync({ limit, offset, appId: projectId }),
|
queryChannelsOnAppAsync(graphqlClient, { limit, offset, appId: projectId }),
|
||||||
promptOptions: {
|
promptOptions: {
|
||||||
title: 'Load more channels?',
|
title: 'Load more channels?',
|
||||||
renderListItems: channels => renderPageOfChannels(channels, paginatedQueryOptions),
|
renderListItems: channels => renderPageOfChannels(channels, paginatedQueryOptions),
|
||||||
@@ -76,20 +84,23 @@ export async function listAndRenderChannelsOnAppAsync({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function listAndRenderBranchesAndUpdatesOnChannelAsync({
|
export async function listAndRenderBranchesAndUpdatesOnChannelAsync(
|
||||||
projectId: appId,
|
graphqlClient: ExpoGraphqlClient,
|
||||||
channelName,
|
{
|
||||||
paginatedQueryOptions,
|
projectId: appId,
|
||||||
}: {
|
channelName,
|
||||||
projectId: string;
|
paginatedQueryOptions,
|
||||||
channelName: string;
|
}: {
|
||||||
paginatedQueryOptions: PaginatedQueryOptions;
|
projectId: string;
|
||||||
}): Promise<void> {
|
channelName: string;
|
||||||
const channel = await ChannelQuery.viewUpdateChannelAsync({ appId, channelName });
|
paginatedQueryOptions: PaginatedQueryOptions;
|
||||||
|
}
|
||||||
|
): Promise<void> {
|
||||||
|
const channel = await ChannelQuery.viewUpdateChannelAsync(graphqlClient, { appId, channelName });
|
||||||
renderChannelHeaderContent({ channelName: channel.name, channelId: channel.id });
|
renderChannelHeaderContent({ channelName: channel.name, channelId: channel.id });
|
||||||
|
|
||||||
if (paginatedQueryOptions.nonInteractive) {
|
if (paginatedQueryOptions.nonInteractive) {
|
||||||
const branches = await queryBranchesAndUpdateGroupsOnChannelAsync({
|
const branches = await queryBranchesAndUpdateGroupsOnChannelAsync(graphqlClient, {
|
||||||
appId,
|
appId,
|
||||||
channelName,
|
channelName,
|
||||||
offset: paginatedQueryOptions.offset,
|
offset: paginatedQueryOptions.offset,
|
||||||
@@ -101,7 +112,7 @@ export async function listAndRenderBranchesAndUpdatesOnChannelAsync({
|
|||||||
limit: paginatedQueryOptions.limit ?? CHANNELS_LIMIT,
|
limit: paginatedQueryOptions.limit ?? CHANNELS_LIMIT,
|
||||||
offset: paginatedQueryOptions.offset,
|
offset: paginatedQueryOptions.offset,
|
||||||
queryToPerform: (limit, offset) =>
|
queryToPerform: (limit, offset) =>
|
||||||
queryBranchesAndUpdateGroupsOnChannelAsync({
|
queryBranchesAndUpdateGroupsOnChannelAsync(graphqlClient, {
|
||||||
channelName,
|
channelName,
|
||||||
appId,
|
appId,
|
||||||
offset,
|
offset,
|
||||||
@@ -116,12 +127,11 @@ export async function listAndRenderBranchesAndUpdatesOnChannelAsync({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function queryChannelsOnAppAsync({
|
async function queryChannelsOnAppAsync(
|
||||||
appId,
|
graphqlClient: ExpoGraphqlClient,
|
||||||
offset,
|
{ appId, offset, limit }: ViewUpdateChannelsOnAppQueryVariables
|
||||||
limit,
|
): Promise<UpdateChannelObject[]> {
|
||||||
}: ViewUpdateChannelsOnAppQueryVariables): Promise<UpdateChannelObject[]> {
|
return await ChannelQuery.viewUpdateChannelsOnAppAsync(graphqlClient, {
|
||||||
return await ChannelQuery.viewUpdateChannelsOnAppAsync({
|
|
||||||
appId,
|
appId,
|
||||||
offset,
|
offset,
|
||||||
limit,
|
limit,
|
||||||
@@ -129,9 +139,10 @@ async function queryChannelsOnAppAsync({
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function queryBranchesAndUpdateGroupsOnChannelAsync(
|
async function queryBranchesAndUpdateGroupsOnChannelAsync(
|
||||||
|
graphqlClient: ExpoGraphqlClient,
|
||||||
args: ViewBranchesOnUpdateChannelQueryVariables
|
args: ViewBranchesOnUpdateChannelQueryVariables
|
||||||
): Promise<UpdateBranchOnChannelObject[]> {
|
): Promise<UpdateBranchOnChannelObject[]> {
|
||||||
return await BranchQuery.listBranchesOnChannelAsync(args);
|
return await BranchQuery.listBranchesOnChannelAsync(graphqlClient, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderPageOfChannels(
|
function renderPageOfChannels(
|
||||||
|
|||||||
@@ -6,13 +6,15 @@ import {
|
|||||||
initAsync as initAnalyticsAsync,
|
initAsync as initAnalyticsAsync,
|
||||||
logEvent,
|
logEvent,
|
||||||
} from '../analytics/rudderstackClient';
|
} from '../analytics/rudderstackClient';
|
||||||
import { getUserAsync } from '../user/User';
|
import SessionManager from '../user/SessionManager';
|
||||||
import ActorContextField from './context/ActorContextField';
|
|
||||||
import ContextField from './context/ContextField';
|
import ContextField from './context/ContextField';
|
||||||
import { DynamicProjectConfigContextField } from './context/DynamicProjectConfigContextField';
|
import { DynamicProjectConfigContextField } from './context/DynamicProjectConfigContextField';
|
||||||
|
import LoggedInContextField from './context/LoggedInContextField';
|
||||||
|
import MaybeLoggedInContextField from './context/MaybeLoggedInContextField';
|
||||||
import { OptionalProjectConfigContextField } from './context/OptionalProjectConfigContextField';
|
import { OptionalProjectConfigContextField } from './context/OptionalProjectConfigContextField';
|
||||||
import ProjectConfigContextField from './context/ProjectConfigContextField';
|
import ProjectConfigContextField from './context/ProjectConfigContextField';
|
||||||
import ProjectDirContextField from './context/ProjectDirContextField';
|
import ProjectDirContextField from './context/ProjectDirContextField';
|
||||||
|
import SessionManagementContextField from './context/SessionManagementContextField';
|
||||||
|
|
||||||
type ContextInput<
|
type ContextInput<
|
||||||
T extends {
|
T extends {
|
||||||
@@ -33,10 +35,24 @@ type ContextOutput<
|
|||||||
export default abstract class EasCommand extends Command {
|
export default abstract class EasCommand extends Command {
|
||||||
protected static readonly ContextOptions = {
|
protected static readonly ContextOptions = {
|
||||||
/**
|
/**
|
||||||
* Require this command to be run when logged-in. Returns the logged-in actor in the context.
|
* Require this command to be run when logged-in. Returns the logged-in actor and a logged-in
|
||||||
|
* graphql client in the context.
|
||||||
*/
|
*/
|
||||||
LoggedIn: {
|
LoggedIn: {
|
||||||
actor: new ActorContextField(),
|
loggedIn: new LoggedInContextField(),
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* Do not require this command to be run when logged-in, but if it is get the logged-in actor and a
|
||||||
|
* maybe-logged-in graphql client.
|
||||||
|
*/
|
||||||
|
MaybeLoggedIn: {
|
||||||
|
maybeLoggedIn: new MaybeLoggedInContextField(),
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* Specify this context requirement if the command needs to mutate the user session.
|
||||||
|
*/
|
||||||
|
SessionManagment: {
|
||||||
|
sessionManager: new SessionManagementContextField(),
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* Require the project to be identified and registered on server if this command is being
|
* Require the project to be identified and registered on server if this command is being
|
||||||
@@ -92,13 +108,25 @@ export default abstract class EasCommand extends Command {
|
|||||||
|
|
||||||
const contextValuePairs = await Promise.all(
|
const contextValuePairs = await Promise.all(
|
||||||
Object.keys(contextDefinition).map(async contextKey => {
|
Object.keys(contextDefinition).map(async contextKey => {
|
||||||
return [contextKey, await contextDefinition[contextKey].getValueAsync({ nonInteractive })];
|
return [
|
||||||
|
contextKey,
|
||||||
|
await contextDefinition[contextKey].getValueAsync({
|
||||||
|
nonInteractive,
|
||||||
|
sessionManager: this.sessionManager,
|
||||||
|
}),
|
||||||
|
];
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
return Object.fromEntries(contextValuePairs);
|
return Object.fromEntries(contextValuePairs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The user session manager. Responsible for coordinating all user session related state.
|
||||||
|
* If needed in a subclass, SessionManager ContextOption.
|
||||||
|
*/
|
||||||
|
private readonly sessionManager = new SessionManager();
|
||||||
|
|
||||||
protected abstract runAsync(): Promise<any>;
|
protected abstract runAsync(): Promise<any>;
|
||||||
|
|
||||||
// eslint-disable-next-line async-protect/async-suffix
|
// eslint-disable-next-line async-protect/async-suffix
|
||||||
@@ -106,7 +134,8 @@ export default abstract class EasCommand extends Command {
|
|||||||
await initAnalyticsAsync();
|
await initAnalyticsAsync();
|
||||||
|
|
||||||
// this is needed for logEvent call below as it identifies the user in the analytics system
|
// this is needed for logEvent call below as it identifies the user in the analytics system
|
||||||
await getUserAsync();
|
await this.sessionManager.getUserAsync();
|
||||||
|
|
||||||
logEvent(AnalyticsEvent.ACTION, {
|
logEvent(AnalyticsEvent.ACTION, {
|
||||||
// id is assigned by oclif in constructor based on the filepath:
|
// id is assigned by oclif in constructor based on the filepath:
|
||||||
// commands/submit === submit, commands/build/list === build:list
|
// commands/submit === submit, commands/build/list === build:list
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import { flushAsync, initAsync, logEvent } from '../../analytics/rudderstackClient';
|
import { flushAsync, initAsync, logEvent } from '../../analytics/rudderstackClient';
|
||||||
import { jester as mockJester } from '../../credentials/__tests__/fixtures-constants';
|
import SessionManager from '../../user/SessionManager';
|
||||||
import { getUserAsync } from '../../user/User';
|
|
||||||
import EasCommand from '../EasCommand';
|
import EasCommand from '../EasCommand';
|
||||||
|
|
||||||
jest.mock('../../user/User');
|
jest.mock('../../user/User');
|
||||||
|
jest.mock('../../user/SessionManager');
|
||||||
jest.mock('../../analytics/rudderstackClient', () => {
|
jest.mock('../../analytics/rudderstackClient', () => {
|
||||||
const { AnalyticsEvent } = jest.requireActual('../../analytics/rudderstackClient');
|
const { AnalyticsEvent } = jest.requireActual('../../analytics/rudderstackClient');
|
||||||
return {
|
return {
|
||||||
@@ -26,10 +26,6 @@ afterAll(() => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
jest
|
|
||||||
.mocked(getUserAsync)
|
|
||||||
.mockReset()
|
|
||||||
.mockImplementation(async () => mockJester);
|
|
||||||
jest.mocked(initAsync).mockReset();
|
jest.mocked(initAsync).mockReset();
|
||||||
jest.mocked(flushAsync).mockReset();
|
jest.mocked(flushAsync).mockReset();
|
||||||
jest.mocked(logEvent).mockReset();
|
jest.mocked(logEvent).mockReset();
|
||||||
@@ -57,7 +53,8 @@ describe(EasCommand.name, () => {
|
|||||||
const TestEasCommand = createTestEasCommand();
|
const TestEasCommand = createTestEasCommand();
|
||||||
await TestEasCommand.run();
|
await TestEasCommand.run();
|
||||||
|
|
||||||
expect(jest.mocked(getUserAsync)).toBeCalledTimes(1);
|
const sessionManagerSpy = jest.spyOn(SessionManager.prototype, 'getUserAsync');
|
||||||
|
expect(sessionManagerSpy).toBeCalledTimes(1);
|
||||||
}, 15_000);
|
}, 15_000);
|
||||||
|
|
||||||
it('initializes analytics', async () => {
|
it('initializes analytics', async () => {
|
||||||
|
|||||||
@@ -1,9 +0,0 @@
|
|||||||
import { Actor } from '../../user/User';
|
|
||||||
import ContextField, { ContextOptions } from './ContextField';
|
|
||||||
import { ensureLoggedInAsync } from './contextUtils/ensureLoggedInAsync';
|
|
||||||
|
|
||||||
export default class ActorContextField extends ContextField<Actor> {
|
|
||||||
async getValueAsync({ nonInteractive }: ContextOptions): Promise<Actor> {
|
|
||||||
return await ensureLoggedInAsync({ nonInteractive });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,4 +1,7 @@
|
|||||||
|
import SessionManager from '../../user/SessionManager';
|
||||||
|
|
||||||
export interface ContextOptions {
|
export interface ContextOptions {
|
||||||
|
sessionManager: SessionManager;
|
||||||
nonInteractive: boolean;
|
nonInteractive: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,11 +12,14 @@ export type DynamicConfigContextFn = (options?: ExpoConfigOptions) => Promise<{
|
|||||||
}>;
|
}>;
|
||||||
|
|
||||||
export class DynamicProjectConfigContextField extends ContextField<DynamicConfigContextFn> {
|
export class DynamicProjectConfigContextField extends ContextField<DynamicConfigContextFn> {
|
||||||
async getValueAsync({ nonInteractive }: ContextOptions): Promise<DynamicConfigContextFn> {
|
async getValueAsync({
|
||||||
|
nonInteractive,
|
||||||
|
sessionManager,
|
||||||
|
}: ContextOptions): Promise<DynamicConfigContextFn> {
|
||||||
return async (options?: ExpoConfigOptions) => {
|
return async (options?: ExpoConfigOptions) => {
|
||||||
const projectDir = await findProjectDirAndVerifyProjectSetupAsync();
|
const projectDir = await findProjectDirAndVerifyProjectSetupAsync();
|
||||||
const expBefore = getExpoConfig(projectDir, options);
|
const expBefore = getExpoConfig(projectDir, options);
|
||||||
const projectId = await getProjectIdAsync(expBefore, {
|
const projectId = await getProjectIdAsync(sessionManager, expBefore, {
|
||||||
nonInteractive,
|
nonInteractive,
|
||||||
env: options?.env,
|
env: options?.env,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
import { Actor } from '../../user/User';
|
||||||
|
import ContextField, { ContextOptions } from './ContextField';
|
||||||
|
import { ExpoGraphqlClient, createGraphqlClient } from './contextUtils/createGraphqlClient';
|
||||||
|
|
||||||
|
export default class LoggedInContextField extends ContextField<{
|
||||||
|
actor: Actor;
|
||||||
|
graphqlClient: ExpoGraphqlClient;
|
||||||
|
}> {
|
||||||
|
async getValueAsync({ nonInteractive, sessionManager }: ContextOptions): Promise<{
|
||||||
|
actor: Actor;
|
||||||
|
graphqlClient: ExpoGraphqlClient;
|
||||||
|
}> {
|
||||||
|
const { actor, authenticationInfo } = await sessionManager.ensureLoggedInAsync({
|
||||||
|
nonInteractive,
|
||||||
|
});
|
||||||
|
|
||||||
|
const graphqlClient = createGraphqlClient(authenticationInfo);
|
||||||
|
return { actor, graphqlClient };
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
import { Actor } from '../../user/User';
|
||||||
|
import ContextField, { ContextOptions } from './ContextField';
|
||||||
|
import { ExpoGraphqlClient, createGraphqlClient } from './contextUtils/createGraphqlClient';
|
||||||
|
|
||||||
|
export default class MaybeLoggedInContextField extends ContextField<{
|
||||||
|
actor: Actor | null;
|
||||||
|
graphqlClient: ExpoGraphqlClient;
|
||||||
|
}> {
|
||||||
|
async getValueAsync({ sessionManager }: ContextOptions): Promise<{
|
||||||
|
actor: Actor | null;
|
||||||
|
graphqlClient: ExpoGraphqlClient;
|
||||||
|
}> {
|
||||||
|
const authenticationInfo = {
|
||||||
|
accessToken: sessionManager.getAccessToken(),
|
||||||
|
sessionSecret: sessionManager.getSessionSecret(),
|
||||||
|
};
|
||||||
|
|
||||||
|
const graphqlClient = createGraphqlClient(authenticationInfo);
|
||||||
|
const actor = await sessionManager.getUserAsync();
|
||||||
|
|
||||||
|
return { actor: actor ?? null, graphqlClient };
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -14,7 +14,7 @@ export class OptionalProjectConfigContextField extends ContextField<
|
|||||||
}
|
}
|
||||||
| undefined
|
| undefined
|
||||||
> {
|
> {
|
||||||
async getValueAsync({ nonInteractive }: ContextOptions): Promise<
|
async getValueAsync({ nonInteractive, sessionManager }: ContextOptions): Promise<
|
||||||
| {
|
| {
|
||||||
projectId: string;
|
projectId: string;
|
||||||
exp: ExpoConfig;
|
exp: ExpoConfig;
|
||||||
@@ -36,7 +36,7 @@ export class OptionalProjectConfigContextField extends ContextField<
|
|||||||
}
|
}
|
||||||
|
|
||||||
const expBefore = getExpoConfig(projectDir);
|
const expBefore = getExpoConfig(projectDir);
|
||||||
const projectId = await getProjectIdAsync(expBefore, {
|
const projectId = await getProjectIdAsync(sessionManager, expBefore, {
|
||||||
nonInteractive,
|
nonInteractive,
|
||||||
});
|
});
|
||||||
const exp = getExpoConfig(projectDir);
|
const exp = getExpoConfig(projectDir);
|
||||||
|
|||||||
@@ -10,14 +10,14 @@ export default class ProjectConfigContextField extends ContextField<{
|
|||||||
exp: ExpoConfig;
|
exp: ExpoConfig;
|
||||||
projectDir: string;
|
projectDir: string;
|
||||||
}> {
|
}> {
|
||||||
async getValueAsync({ nonInteractive }: ContextOptions): Promise<{
|
async getValueAsync({ nonInteractive, sessionManager }: ContextOptions): Promise<{
|
||||||
projectId: string;
|
projectId: string;
|
||||||
exp: ExpoConfig;
|
exp: ExpoConfig;
|
||||||
projectDir: string;
|
projectDir: string;
|
||||||
}> {
|
}> {
|
||||||
const projectDir = await findProjectDirAndVerifyProjectSetupAsync();
|
const projectDir = await findProjectDirAndVerifyProjectSetupAsync();
|
||||||
const expBefore = getExpoConfig(projectDir);
|
const expBefore = getExpoConfig(projectDir);
|
||||||
const projectId = await getProjectIdAsync(expBefore, {
|
const projectId = await getProjectIdAsync(sessionManager, expBefore, {
|
||||||
nonInteractive,
|
nonInteractive,
|
||||||
});
|
});
|
||||||
const exp = getExpoConfig(projectDir);
|
const exp = getExpoConfig(projectDir);
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
import SessionManager from '../../user/SessionManager';
|
||||||
|
import ContextField, { ContextOptions } from './ContextField';
|
||||||
|
|
||||||
|
export default class SessionManagementContextField extends ContextField<SessionManager> {
|
||||||
|
async getValueAsync({ sessionManager }: ContextOptions): Promise<SessionManager> {
|
||||||
|
return sessionManager;
|
||||||
|
}
|
||||||
|
}
|
||||||
-74
@@ -1,74 +0,0 @@
|
|||||||
import { ApiV2Error } from '../../../../api';
|
|
||||||
import { promptAsync } from '../../../../prompts';
|
|
||||||
import { loginAsync } from '../../../../user/User';
|
|
||||||
import {
|
|
||||||
UserSecondFactorDeviceMethod,
|
|
||||||
retryUsernamePasswordAuthWithOTPAsync,
|
|
||||||
} from '../../../../user/otp';
|
|
||||||
import { showLoginPromptAsync } from '../../contextUtils/ensureLoggedInAsync';
|
|
||||||
|
|
||||||
jest.mock('../../../../prompts');
|
|
||||||
jest.mock('../../../../api', () => ({
|
|
||||||
ApiV2Error: jest.requireActual('../../../../api').ApiV2Error,
|
|
||||||
getExpoApiBaseUrl: jest.fn(),
|
|
||||||
}));
|
|
||||||
|
|
||||||
jest.mock('../../../../user/otp');
|
|
||||||
jest.mock('../../../../user/User', () => ({
|
|
||||||
loginAsync: jest.fn(),
|
|
||||||
}));
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
jest.mocked(promptAsync).mockReset();
|
|
||||||
jest.mocked(promptAsync).mockImplementation(async () => {
|
|
||||||
throw new Error('Should not be called');
|
|
||||||
});
|
|
||||||
|
|
||||||
jest.mocked(loginAsync).mockReset();
|
|
||||||
});
|
|
||||||
|
|
||||||
describe(showLoginPromptAsync, () => {
|
|
||||||
it('prompts for OTP when 2FA is enabled', async () => {
|
|
||||||
jest
|
|
||||||
.mocked(promptAsync)
|
|
||||||
.mockImplementationOnce(async () => ({ username: 'hello', password: 'world' }))
|
|
||||||
.mockImplementationOnce(async () => ({ otp: '123456' }))
|
|
||||||
.mockImplementation(async () => {
|
|
||||||
throw new Error("shouldn't happen");
|
|
||||||
});
|
|
||||||
jest
|
|
||||||
.mocked(loginAsync)
|
|
||||||
.mockImplementationOnce(async () => {
|
|
||||||
throw new ApiV2Error({
|
|
||||||
message: 'An OTP is required',
|
|
||||||
code: 'ONE_TIME_PASSWORD_REQUIRED',
|
|
||||||
metadata: {
|
|
||||||
secondFactorDevices: [
|
|
||||||
{
|
|
||||||
id: 'p0',
|
|
||||||
is_primary: true,
|
|
||||||
method: UserSecondFactorDeviceMethod.SMS,
|
|
||||||
sms_phone_number: 'testphone',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
smsAutomaticallySent: true,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
})
|
|
||||||
.mockImplementation(async () => {});
|
|
||||||
|
|
||||||
await showLoginPromptAsync();
|
|
||||||
|
|
||||||
expect(retryUsernamePasswordAuthWithOTPAsync).toHaveBeenCalledWith('hello', 'world', {
|
|
||||||
secondFactorDevices: [
|
|
||||||
{
|
|
||||||
id: 'p0',
|
|
||||||
is_primary: true,
|
|
||||||
method: UserSecondFactorDeviceMethod.SMS,
|
|
||||||
sms_phone_number: 'testphone',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
smsAutomaticallySent: true,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
+32
-21
@@ -1,11 +1,12 @@
|
|||||||
import { getConfig, modifyConfigAsync } from '@expo/config';
|
import { getConfig, modifyConfigAsync } from '@expo/config';
|
||||||
import { vol } from 'memfs';
|
import { vol } from 'memfs';
|
||||||
|
import { anything, instance, mock, when } from 'ts-mockito';
|
||||||
|
|
||||||
import { Role } from '../../../../graphql/generated';
|
import { Role } from '../../../../graphql/generated';
|
||||||
import { AppQuery } from '../../../../graphql/queries/AppQuery';
|
import { AppQuery } from '../../../../graphql/queries/AppQuery';
|
||||||
import { learnMore } from '../../../../log';
|
import { learnMore } from '../../../../log';
|
||||||
import { fetchOrCreateProjectIDForWriteToConfigWithConfirmationAsync } from '../../../../project/fetchOrCreateProjectIDForWriteToConfigWithConfirmationAsync';
|
import { fetchOrCreateProjectIDForWriteToConfigWithConfirmationAsync } from '../../../../project/fetchOrCreateProjectIDForWriteToConfigWithConfirmationAsync';
|
||||||
import { ensureLoggedInAsync } from '../../contextUtils/ensureLoggedInAsync';
|
import SessionManager from '../../../../user/SessionManager';
|
||||||
import { findProjectRootAsync } from '../findProjectDirAndVerifyProjectSetupAsync';
|
import { findProjectRootAsync } from '../findProjectDirAndVerifyProjectSetupAsync';
|
||||||
import { getProjectIdAsync } from '../getProjectIdAsync';
|
import { getProjectIdAsync } from '../getProjectIdAsync';
|
||||||
|
|
||||||
@@ -13,7 +14,6 @@ jest.mock('@expo/config');
|
|||||||
jest.mock('fs');
|
jest.mock('fs');
|
||||||
|
|
||||||
jest.mock('../../../../graphql/queries/AppQuery');
|
jest.mock('../../../../graphql/queries/AppQuery');
|
||||||
jest.mock('../../contextUtils/ensureLoggedInAsync');
|
|
||||||
jest.mock('../../contextUtils/findProjectDirAndVerifyProjectSetupAsync');
|
jest.mock('../../contextUtils/findProjectDirAndVerifyProjectSetupAsync');
|
||||||
jest.mock('../../../../user/User');
|
jest.mock('../../../../user/User');
|
||||||
jest.mock('../../../../ora', () => ({
|
jest.mock('../../../../ora', () => ({
|
||||||
@@ -24,30 +24,37 @@ jest.mock('../../../../ora', () => ({
|
|||||||
jest.mock('../../../../project/fetchOrCreateProjectIDForWriteToConfigWithConfirmationAsync');
|
jest.mock('../../../../project/fetchOrCreateProjectIDForWriteToConfigWithConfirmationAsync');
|
||||||
|
|
||||||
describe(getProjectIdAsync, () => {
|
describe(getProjectIdAsync, () => {
|
||||||
|
let sessionManager: SessionManager;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
jest.mocked(ensureLoggedInAsync).mockResolvedValue({
|
const sessionManagerMock = mock<SessionManager>();
|
||||||
__typename: 'User',
|
when(sessionManagerMock.ensureLoggedInAsync(anything())).thenResolve({
|
||||||
id: 'user_id',
|
actor: {
|
||||||
username: 'notnotbrent',
|
__typename: 'User',
|
||||||
primaryAccount: {
|
id: 'user_id',
|
||||||
id: 'account_id_1',
|
username: 'notnotbrent',
|
||||||
name: 'notnotbrent',
|
primaryAccount: {
|
||||||
users: [{ role: Role.Owner, actor: { id: 'user_id' } }],
|
|
||||||
},
|
|
||||||
accounts: [
|
|
||||||
{
|
|
||||||
id: 'account_id_1',
|
id: 'account_id_1',
|
||||||
name: 'notnotbrent',
|
name: 'notnotbrent',
|
||||||
users: [{ role: Role.Owner, actor: { id: 'user_id' } }],
|
users: [{ role: Role.Owner, actor: { id: 'user_id' } }],
|
||||||
},
|
},
|
||||||
{
|
accounts: [
|
||||||
id: 'account_id_2',
|
{
|
||||||
name: 'dominik',
|
id: 'account_id_1',
|
||||||
users: [{ role: Role.ViewOnly, actor: { id: 'user_id' } }],
|
name: 'notnotbrent',
|
||||||
},
|
users: [{ role: Role.Owner, actor: { id: 'user_id' } }],
|
||||||
],
|
},
|
||||||
isExpoAdmin: false,
|
{
|
||||||
|
id: 'account_id_2',
|
||||||
|
name: 'dominik',
|
||||||
|
users: [{ role: Role.ViewOnly, actor: { id: 'user_id' } }],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
isExpoAdmin: false,
|
||||||
|
},
|
||||||
|
authenticationInfo: { accessToken: 'fake', sessionSecret: null },
|
||||||
});
|
});
|
||||||
|
sessionManager = instance(sessionManagerMock);
|
||||||
|
|
||||||
vol.fromJSON(
|
vol.fromJSON(
|
||||||
{
|
{
|
||||||
@@ -74,6 +81,7 @@ describe(getProjectIdAsync, () => {
|
|||||||
|
|
||||||
await expect(
|
await expect(
|
||||||
getProjectIdAsync(
|
getProjectIdAsync(
|
||||||
|
sessionManager,
|
||||||
{ name: 'test', slug: 'test', extra: { eas: { projectId: '1234' } } },
|
{ name: 'test', slug: 'test', extra: { eas: { projectId: '1234' } } },
|
||||||
{ nonInteractive: false }
|
{ nonInteractive: false }
|
||||||
)
|
)
|
||||||
@@ -93,6 +101,7 @@ describe(getProjectIdAsync, () => {
|
|||||||
|
|
||||||
await expect(
|
await expect(
|
||||||
getProjectIdAsync(
|
getProjectIdAsync(
|
||||||
|
sessionManager,
|
||||||
{ name: 'test', slug: 'test', owner: 'wat', extra: { eas: { projectId: '1234' } } },
|
{ name: 'test', slug: 'test', owner: 'wat', extra: { eas: { projectId: '1234' } } },
|
||||||
{ nonInteractive: false }
|
{ nonInteractive: false }
|
||||||
)
|
)
|
||||||
@@ -116,6 +125,7 @@ describe(getProjectIdAsync, () => {
|
|||||||
|
|
||||||
await expect(
|
await expect(
|
||||||
getProjectIdAsync(
|
getProjectIdAsync(
|
||||||
|
sessionManager,
|
||||||
{ name: 'test', slug: 'wat', extra: { eas: { projectId: '1234' } } },
|
{ name: 'test', slug: 'wat', extra: { eas: { projectId: '1234' } } },
|
||||||
{ nonInteractive: false }
|
{ nonInteractive: false }
|
||||||
)
|
)
|
||||||
@@ -137,6 +147,7 @@ describe(getProjectIdAsync, () => {
|
|||||||
.mockImplementation(async () => '2345');
|
.mockImplementation(async () => '2345');
|
||||||
|
|
||||||
const projectId = await getProjectIdAsync(
|
const projectId = await getProjectIdAsync(
|
||||||
|
sessionManager,
|
||||||
{ name: 'test', slug: 'test' },
|
{ name: 'test', slug: 'test' },
|
||||||
{
|
{
|
||||||
nonInteractive: false,
|
nonInteractive: false,
|
||||||
@@ -162,7 +173,7 @@ describe(getProjectIdAsync, () => {
|
|||||||
.mockImplementation(async () => '4567');
|
.mockImplementation(async () => '4567');
|
||||||
|
|
||||||
await expect(
|
await expect(
|
||||||
getProjectIdAsync({ name: 'test', slug: 'test' }, { nonInteractive: false })
|
getProjectIdAsync(sessionManager, { name: 'test', slug: 'test' }, { nonInteractive: false })
|
||||||
).rejects.toThrow();
|
).rejects.toThrow();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
import {
|
||||||
|
Client,
|
||||||
|
OperationContext,
|
||||||
|
OperationResult,
|
||||||
|
PromisifiedSource,
|
||||||
|
TypedDocumentNode,
|
||||||
|
cacheExchange,
|
||||||
|
createClient as createUrqlClient,
|
||||||
|
dedupExchange,
|
||||||
|
fetchExchange,
|
||||||
|
} from '@urql/core';
|
||||||
|
import { retryExchange } from '@urql/exchange-retry';
|
||||||
|
import { DocumentNode } from 'graphql';
|
||||||
|
import fetch from 'node-fetch';
|
||||||
|
|
||||||
|
import { getExpoApiBaseUrl } from '../../../api';
|
||||||
|
import { httpsProxyAgent } from '../../../fetch';
|
||||||
|
|
||||||
|
export interface ExpoGraphqlClient extends Client {
|
||||||
|
query<Data = any, Variables extends object = object>(
|
||||||
|
query: DocumentNode | TypedDocumentNode<Data, Variables> | string,
|
||||||
|
variables: Variables | undefined,
|
||||||
|
context: Partial<OperationContext> & { additionalTypenames: string[] }
|
||||||
|
): PromisifiedSource<OperationResult<Data, Variables>>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function createGraphqlClient(authInfo: {
|
||||||
|
accessToken: string | null;
|
||||||
|
sessionSecret: string | null;
|
||||||
|
}): ExpoGraphqlClient {
|
||||||
|
return createUrqlClient({
|
||||||
|
url: getExpoApiBaseUrl() + '/graphql',
|
||||||
|
exchanges: [
|
||||||
|
dedupExchange,
|
||||||
|
cacheExchange,
|
||||||
|
retryExchange({
|
||||||
|
maxDelayMs: 4000,
|
||||||
|
retryIf: (err, operation) => {
|
||||||
|
return !!(
|
||||||
|
err &&
|
||||||
|
!operation.context.noRetry &&
|
||||||
|
(err.networkError || err.graphQLErrors.some(e => e?.extensions?.isTransient))
|
||||||
|
);
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
fetchExchange,
|
||||||
|
],
|
||||||
|
// @ts-expect-error Type 'typeof fetch' is not assignable to type '(input: RequestInfo, init?: RequestInit | undefined) => Promise<Response>'.
|
||||||
|
fetch,
|
||||||
|
fetchOptions: (): RequestInit => {
|
||||||
|
const headers: Record<string, string> = {};
|
||||||
|
if (authInfo.accessToken) {
|
||||||
|
headers.authorization = `Bearer ${authInfo.accessToken}`;
|
||||||
|
} else if (authInfo.sessionSecret) {
|
||||||
|
headers['expo-session'] = authInfo.sessionSecret;
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
...(httpsProxyAgent ? { agent: httpsProxyAgent } : {}),
|
||||||
|
headers,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
}) as ExpoGraphqlClient;
|
||||||
|
}
|
||||||
@@ -1,91 +0,0 @@
|
|||||||
import { Errors } from '@oclif/core';
|
|
||||||
import chalk from 'chalk';
|
|
||||||
import nullthrows from 'nullthrows';
|
|
||||||
|
|
||||||
import { ApiV2Error } from '../../../api';
|
|
||||||
import Log, { learnMore } from '../../../log';
|
|
||||||
import { promptAsync } from '../../../prompts';
|
|
||||||
import { Actor, getUserAsync, loginAsync } from '../../../user/User';
|
|
||||||
import { retryUsernamePasswordAuthWithOTPAsync } from '../../../user/otp';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Ensure that there is a logged-in actor. Show a login prompt if not.
|
|
||||||
*
|
|
||||||
* @param nonInteractive whether the log-in prompt if logged-out should be interactive
|
|
||||||
* @returns logged-in Actor
|
|
||||||
*
|
|
||||||
* @deprecated Should not be used outside of context functions.
|
|
||||||
*/
|
|
||||||
export async function ensureLoggedInAsync({
|
|
||||||
nonInteractive,
|
|
||||||
}: {
|
|
||||||
nonInteractive: boolean;
|
|
||||||
}): Promise<Actor> {
|
|
||||||
let user: Actor | undefined;
|
|
||||||
try {
|
|
||||||
user = await getUserAsync();
|
|
||||||
} catch {}
|
|
||||||
|
|
||||||
if (!user) {
|
|
||||||
Log.warn('An Expo user account is required to proceed.');
|
|
||||||
await showLoginPromptAsync({ nonInteractive, printNewLine: true });
|
|
||||||
user = await getUserAsync();
|
|
||||||
}
|
|
||||||
|
|
||||||
return nullthrows(user);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Prompt the user to log in.
|
|
||||||
*
|
|
||||||
* @deprecated Should not be used outside of context functions, except in the AccountLogin command.
|
|
||||||
*/
|
|
||||||
export async function showLoginPromptAsync({
|
|
||||||
nonInteractive = false,
|
|
||||||
printNewLine = false,
|
|
||||||
} = {}): Promise<void> {
|
|
||||||
if (nonInteractive) {
|
|
||||||
Errors.error(
|
|
||||||
`Either log in with ${chalk.bold('eas login')} or set the ${chalk.bold(
|
|
||||||
'EXPO_TOKEN'
|
|
||||||
)} environment variable if you're using EAS CLI on CI (${learnMore(
|
|
||||||
'https://docs.expo.dev/accounts/programmatic-access/',
|
|
||||||
{ dim: false }
|
|
||||||
)})`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (printNewLine) {
|
|
||||||
Log.newLine();
|
|
||||||
}
|
|
||||||
|
|
||||||
Log.log('Log in to EAS');
|
|
||||||
|
|
||||||
const { username, password } = await promptAsync([
|
|
||||||
{
|
|
||||||
type: 'text',
|
|
||||||
name: 'username',
|
|
||||||
message: 'Email or username',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'password',
|
|
||||||
name: 'password',
|
|
||||||
message: 'Password',
|
|
||||||
},
|
|
||||||
]);
|
|
||||||
try {
|
|
||||||
await loginAsync({
|
|
||||||
username,
|
|
||||||
password,
|
|
||||||
});
|
|
||||||
} catch (e) {
|
|
||||||
if (e instanceof ApiV2Error && e.expoApiV2ErrorCode === 'ONE_TIME_PASSWORD_REQUIRED') {
|
|
||||||
await retryUsernamePasswordAuthWithOTPAsync(
|
|
||||||
username,
|
|
||||||
password,
|
|
||||||
e.expoApiV2ErrorMetadata as any
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -9,8 +9,9 @@ import { ora } from '../../../ora';
|
|||||||
import { getExpoConfig } from '../../../project/expoConfig';
|
import { getExpoConfig } from '../../../project/expoConfig';
|
||||||
import { fetchOrCreateProjectIDForWriteToConfigWithConfirmationAsync } from '../../../project/fetchOrCreateProjectIDForWriteToConfigWithConfirmationAsync';
|
import { fetchOrCreateProjectIDForWriteToConfigWithConfirmationAsync } from '../../../project/fetchOrCreateProjectIDForWriteToConfigWithConfirmationAsync';
|
||||||
import { toAppPrivacy } from '../../../project/projectUtils';
|
import { toAppPrivacy } from '../../../project/projectUtils';
|
||||||
|
import SessionManager from '../../../user/SessionManager';
|
||||||
import { Actor } from '../../../user/User';
|
import { Actor } from '../../../user/User';
|
||||||
import { ensureLoggedInAsync } from './ensureLoggedInAsync';
|
import { createGraphqlClient } from './createGraphqlClient';
|
||||||
import { findProjectRootAsync } from './findProjectDirAndVerifyProjectSetupAsync';
|
import { findProjectRootAsync } from './findProjectDirAndVerifyProjectSetupAsync';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -70,13 +71,22 @@ export async function saveProjectIdToAppConfigAsync(
|
|||||||
* @deprecated Should not be used outside of context functions.
|
* @deprecated Should not be used outside of context functions.
|
||||||
*/
|
*/
|
||||||
export async function getProjectIdAsync(
|
export async function getProjectIdAsync(
|
||||||
|
sessionManager: SessionManager,
|
||||||
exp: ExpoConfig,
|
exp: ExpoConfig,
|
||||||
options: { env?: Env; nonInteractive: boolean }
|
options: { env?: Env; nonInteractive: boolean }
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
|
// all codepaths in this function require a logged-in user with access to the owning account
|
||||||
|
// since they either query the app via graphql or create it, which includes getting info about
|
||||||
|
// the owner
|
||||||
|
const { actor, authenticationInfo } = await sessionManager.ensureLoggedInAsync({
|
||||||
|
nonInteractive: options.nonInteractive,
|
||||||
|
});
|
||||||
|
const graphqlClient = createGraphqlClient(authenticationInfo);
|
||||||
|
|
||||||
const localProjectId = exp.extra?.eas?.projectId;
|
const localProjectId = exp.extra?.eas?.projectId;
|
||||||
if (localProjectId) {
|
if (localProjectId) {
|
||||||
// check that the local project ID matches account and slug
|
// check that the local project ID matches account and slug
|
||||||
const appForProjectId = await AppQuery.byIdAsync(localProjectId);
|
const appForProjectId = await AppQuery.byIdAsync(graphqlClient, localProjectId);
|
||||||
if (exp.owner && exp.owner !== appForProjectId.ownerAccount.name) {
|
if (exp.owner && exp.owner !== appForProjectId.ownerAccount.name) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Project config: Project identified by "extra.eas.projectId" (${
|
`Project config: Project identified by "extra.eas.projectId" (${
|
||||||
@@ -121,10 +131,8 @@ export async function getProjectIdAsync(
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const actor = await ensureLoggedInAsync({
|
|
||||||
nonInteractive: options.nonInteractive,
|
|
||||||
});
|
|
||||||
const projectId = await fetchOrCreateProjectIDForWriteToConfigWithConfirmationAsync(
|
const projectId = await fetchOrCreateProjectIDForWriteToConfigWithConfirmationAsync(
|
||||||
|
graphqlClient,
|
||||||
{
|
{
|
||||||
accountName: getAccountNameForEASProjectSync(exp, actor),
|
accountName: getAccountNameForEASProjectSync(exp, actor),
|
||||||
projectName: exp.slug,
|
projectName: exp.slug,
|
||||||
|
|||||||
@@ -1,13 +1,17 @@
|
|||||||
import EasCommand from '../../commandUtils/EasCommand';
|
import EasCommand from '../../commandUtils/EasCommand';
|
||||||
import { showLoginPromptAsync } from '../../commandUtils/context/contextUtils/ensureLoggedInAsync';
|
|
||||||
import Log from '../../log';
|
import Log from '../../log';
|
||||||
|
|
||||||
export default class AccountLogin extends EasCommand {
|
export default class AccountLogin extends EasCommand {
|
||||||
static override description = 'log in with your Expo account';
|
static override description = 'log in with your Expo account';
|
||||||
static override aliases = ['login'];
|
static override aliases = ['login'];
|
||||||
|
|
||||||
|
static override contextDefinition = {
|
||||||
|
...this.ContextOptions.SessionManagment,
|
||||||
|
};
|
||||||
|
|
||||||
async runAsync(): Promise<void> {
|
async runAsync(): Promise<void> {
|
||||||
await showLoginPromptAsync();
|
const { sessionManager } = await this.getContextAsync(AccountLogin, { nonInteractive: false });
|
||||||
|
await sessionManager.showLoginPromptAsync();
|
||||||
Log.log('Logged in');
|
Log.log('Logged in');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,13 +1,17 @@
|
|||||||
import EasCommand from '../../commandUtils/EasCommand';
|
import EasCommand from '../../commandUtils/EasCommand';
|
||||||
import Log from '../../log';
|
import Log from '../../log';
|
||||||
import { logoutAsync } from '../../user/User';
|
|
||||||
|
|
||||||
export default class AccountLogout extends EasCommand {
|
export default class AccountLogout extends EasCommand {
|
||||||
static override description = 'log out';
|
static override description = 'log out';
|
||||||
static override aliases = ['logout'];
|
static override aliases = ['logout'];
|
||||||
|
|
||||||
|
static override contextDefinition = {
|
||||||
|
...this.ContextOptions.SessionManagment,
|
||||||
|
};
|
||||||
|
|
||||||
async runAsync(): Promise<void> {
|
async runAsync(): Promise<void> {
|
||||||
await logoutAsync();
|
const { sessionManager } = await this.getContextAsync(AccountLogout, { nonInteractive: false });
|
||||||
|
await sessionManager.logoutAsync();
|
||||||
Log.log('Logged out');
|
Log.log('Logged out');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2,16 +2,22 @@ import chalk from 'chalk';
|
|||||||
|
|
||||||
import EasCommand from '../../commandUtils/EasCommand';
|
import EasCommand from '../../commandUtils/EasCommand';
|
||||||
import Log from '../../log';
|
import Log from '../../log';
|
||||||
import { getActorDisplayName, getUserAsync } from '../../user/User';
|
import { getActorDisplayName } from '../../user/User';
|
||||||
|
|
||||||
export default class AccountView extends EasCommand {
|
export default class AccountView extends EasCommand {
|
||||||
static override description = 'show the username you are logged in as';
|
static override description = 'show the username you are logged in as';
|
||||||
static override aliases = ['whoami'];
|
static override aliases = ['whoami'];
|
||||||
|
|
||||||
|
static override contextDefinition = {
|
||||||
|
...this.ContextOptions.MaybeLoggedIn,
|
||||||
|
};
|
||||||
|
|
||||||
async runAsync(): Promise<void> {
|
async runAsync(): Promise<void> {
|
||||||
const user = await getUserAsync();
|
const {
|
||||||
if (user) {
|
maybeLoggedIn: { actor },
|
||||||
Log.log(chalk.green(getActorDisplayName(user)));
|
} = await this.getContextAsync(AccountView, { nonInteractive: true });
|
||||||
|
if (actor) {
|
||||||
|
Log.log(chalk.green(getActorDisplayName(actor)));
|
||||||
} else {
|
} else {
|
||||||
Log.warn('Not logged in');
|
Log.warn('Not logged in');
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
|
|||||||
@@ -3,8 +3,9 @@ import gql from 'graphql-tag';
|
|||||||
|
|
||||||
import { getDefaultBranchNameAsync } from '../../branch/utils';
|
import { getDefaultBranchNameAsync } from '../../branch/utils';
|
||||||
import EasCommand from '../../commandUtils/EasCommand';
|
import EasCommand from '../../commandUtils/EasCommand';
|
||||||
|
import { ExpoGraphqlClient } from '../../commandUtils/context/contextUtils/createGraphqlClient';
|
||||||
import { EasNonInteractiveAndJsonFlags } from '../../commandUtils/flags';
|
import { EasNonInteractiveAndJsonFlags } from '../../commandUtils/flags';
|
||||||
import { graphqlClient, withErrorHandlingAsync } from '../../graphql/client';
|
import { withErrorHandlingAsync } from '../../graphql/client';
|
||||||
import {
|
import {
|
||||||
CreateUpdateBranchForAppMutation,
|
CreateUpdateBranchForAppMutation,
|
||||||
CreateUpdateBranchForAppMutationVariables,
|
CreateUpdateBranchForAppMutationVariables,
|
||||||
@@ -15,10 +16,10 @@ import { getDisplayNameForProjectIdAsync } from '../../project/projectUtils';
|
|||||||
import { promptAsync } from '../../prompts';
|
import { promptAsync } from '../../prompts';
|
||||||
import { enableJsonOutput, printJsonOnlyOutput } from '../../utils/json';
|
import { enableJsonOutput, printJsonOnlyOutput } from '../../utils/json';
|
||||||
|
|
||||||
export async function createUpdateBranchOnAppAsync({
|
export async function createUpdateBranchOnAppAsync(
|
||||||
appId,
|
graphqlClient: ExpoGraphqlClient,
|
||||||
name,
|
{ appId, name }: CreateUpdateBranchForAppMutationVariables
|
||||||
}: CreateUpdateBranchForAppMutationVariables): Promise<Pick<UpdateBranch, 'id' | 'name'>> {
|
): Promise<Pick<UpdateBranch, 'id' | 'name'>> {
|
||||||
const result = await withErrorHandlingAsync(
|
const result = await withErrorHandlingAsync(
|
||||||
graphqlClient
|
graphqlClient
|
||||||
.mutation<CreateUpdateBranchForAppMutation, CreateUpdateBranchForAppMutationVariables>(
|
.mutation<CreateUpdateBranchForAppMutation, CreateUpdateBranchForAppMutationVariables>(
|
||||||
@@ -63,6 +64,7 @@ export default class BranchCreate extends EasCommand {
|
|||||||
|
|
||||||
static override contextDefinition = {
|
static override contextDefinition = {
|
||||||
...this.ContextOptions.ProjectConfig,
|
...this.ContextOptions.ProjectConfig,
|
||||||
|
...this.ContextOptions.LoggedIn,
|
||||||
};
|
};
|
||||||
|
|
||||||
async runAsync(): Promise<void> {
|
async runAsync(): Promise<void> {
|
||||||
@@ -72,6 +74,7 @@ export default class BranchCreate extends EasCommand {
|
|||||||
} = await this.parse(BranchCreate);
|
} = await this.parse(BranchCreate);
|
||||||
const {
|
const {
|
||||||
projectConfig: { projectId },
|
projectConfig: { projectId },
|
||||||
|
loggedIn: { graphqlClient },
|
||||||
} = await this.getContextAsync(BranchCreate, {
|
} = await this.getContextAsync(BranchCreate, {
|
||||||
nonInteractive,
|
nonInteractive,
|
||||||
});
|
});
|
||||||
@@ -80,7 +83,7 @@ export default class BranchCreate extends EasCommand {
|
|||||||
enableJsonOutput();
|
enableJsonOutput();
|
||||||
}
|
}
|
||||||
|
|
||||||
const projectDisplayName = await getDisplayNameForProjectIdAsync(projectId);
|
const projectDisplayName = await getDisplayNameForProjectIdAsync(graphqlClient, projectId);
|
||||||
|
|
||||||
if (!name) {
|
if (!name) {
|
||||||
const validationMessage = 'Branch name may not be empty.';
|
const validationMessage = 'Branch name may not be empty.';
|
||||||
@@ -96,7 +99,7 @@ export default class BranchCreate extends EasCommand {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
const newBranch = await createUpdateBranchOnAppAsync({ appId: projectId, name });
|
const newBranch = await createUpdateBranchOnAppAsync(graphqlClient, { appId: projectId, name });
|
||||||
|
|
||||||
if (jsonFlag) {
|
if (jsonFlag) {
|
||||||
printJsonOnlyOutput(newBranch);
|
printJsonOnlyOutput(newBranch);
|
||||||
|
|||||||
@@ -3,9 +3,10 @@ import gql from 'graphql-tag';
|
|||||||
|
|
||||||
import { selectBranchOnAppAsync } from '../../branch/queries';
|
import { selectBranchOnAppAsync } from '../../branch/queries';
|
||||||
import EasCommand from '../../commandUtils/EasCommand';
|
import EasCommand from '../../commandUtils/EasCommand';
|
||||||
|
import { ExpoGraphqlClient } from '../../commandUtils/context/contextUtils/createGraphqlClient';
|
||||||
import { EasNonInteractiveAndJsonFlags } from '../../commandUtils/flags';
|
import { EasNonInteractiveAndJsonFlags } from '../../commandUtils/flags';
|
||||||
import { getPaginatedQueryOptions } from '../../commandUtils/pagination';
|
import { getPaginatedQueryOptions } from '../../commandUtils/pagination';
|
||||||
import { graphqlClient, withErrorHandlingAsync } from '../../graphql/client';
|
import { withErrorHandlingAsync } from '../../graphql/client';
|
||||||
import {
|
import {
|
||||||
DeleteUpdateBranchMutation,
|
DeleteUpdateBranchMutation,
|
||||||
DeleteUpdateBranchMutationVariables,
|
DeleteUpdateBranchMutationVariables,
|
||||||
@@ -18,10 +19,10 @@ import { getDisplayNameForProjectIdAsync } from '../../project/projectUtils';
|
|||||||
import { toggleConfirmAsync } from '../../prompts';
|
import { toggleConfirmAsync } from '../../prompts';
|
||||||
import { enableJsonOutput, printJsonOnlyOutput } from '../../utils/json';
|
import { enableJsonOutput, printJsonOnlyOutput } from '../../utils/json';
|
||||||
|
|
||||||
async function getBranchInfoAsync({
|
async function getBranchInfoAsync(
|
||||||
appId,
|
graphqlClient: ExpoGraphqlClient,
|
||||||
name,
|
{ appId, name }: GetBranchInfoQueryVariables
|
||||||
}: GetBranchInfoQueryVariables): Promise<GetBranchInfoQuery> {
|
): Promise<GetBranchInfoQuery> {
|
||||||
const data = await withErrorHandlingAsync(
|
const data = await withErrorHandlingAsync(
|
||||||
graphqlClient
|
graphqlClient
|
||||||
.query<GetBranchInfoQuery, GetBranchInfoQueryVariables>(
|
.query<GetBranchInfoQuery, GetBranchInfoQueryVariables>(
|
||||||
@@ -49,9 +50,10 @@ async function getBranchInfoAsync({
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function deleteBranchOnAppAsync({
|
async function deleteBranchOnAppAsync(
|
||||||
branchId,
|
graphqlClient: ExpoGraphqlClient,
|
||||||
}: DeleteUpdateBranchMutationVariables): Promise<DeleteUpdateBranchResult> {
|
{ branchId }: DeleteUpdateBranchMutationVariables
|
||||||
|
): Promise<DeleteUpdateBranchResult> {
|
||||||
const data = await withErrorHandlingAsync(
|
const data = await withErrorHandlingAsync(
|
||||||
graphqlClient
|
graphqlClient
|
||||||
.mutation<DeleteUpdateBranchMutation, DeleteUpdateBranchMutationVariables>(
|
.mutation<DeleteUpdateBranchMutation, DeleteUpdateBranchMutationVariables>(
|
||||||
@@ -78,6 +80,7 @@ export default class BranchDelete extends EasCommand {
|
|||||||
|
|
||||||
static override contextDefinition = {
|
static override contextDefinition = {
|
||||||
...this.ContextOptions.ProjectConfig,
|
...this.ContextOptions.ProjectConfig,
|
||||||
|
...this.ContextOptions.LoggedIn,
|
||||||
};
|
};
|
||||||
|
|
||||||
static override args = [
|
static override args = [
|
||||||
@@ -106,15 +109,16 @@ export default class BranchDelete extends EasCommand {
|
|||||||
|
|
||||||
const {
|
const {
|
||||||
projectConfig: { projectId },
|
projectConfig: { projectId },
|
||||||
|
loggedIn: { graphqlClient },
|
||||||
} = await this.getContextAsync(BranchDelete, { nonInteractive });
|
} = await this.getContextAsync(BranchDelete, { nonInteractive });
|
||||||
const projectDisplayName = await getDisplayNameForProjectIdAsync(projectId);
|
const projectDisplayName = await getDisplayNameForProjectIdAsync(graphqlClient, projectId);
|
||||||
|
|
||||||
if (!branchName) {
|
if (!branchName) {
|
||||||
const validationMessage = 'branch name may not be empty.';
|
const validationMessage = 'branch name may not be empty.';
|
||||||
if (nonInteractive) {
|
if (nonInteractive) {
|
||||||
throw new Error(validationMessage);
|
throw new Error(validationMessage);
|
||||||
}
|
}
|
||||||
({ name: branchName } = await selectBranchOnAppAsync({
|
({ name: branchName } = await selectBranchOnAppAsync(graphqlClient, {
|
||||||
projectId,
|
projectId,
|
||||||
displayTextForListItem: updateBranch => updateBranch.name,
|
displayTextForListItem: updateBranch => updateBranch.name,
|
||||||
promptTitle: 'Which branch would you like to delete?',
|
promptTitle: 'Which branch would you like to delete?',
|
||||||
@@ -122,7 +126,7 @@ export default class BranchDelete extends EasCommand {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
const data = await getBranchInfoAsync({ appId: projectId, name: branchName });
|
const data = await getBranchInfoAsync(graphqlClient, { appId: projectId, name: branchName });
|
||||||
const branchId = data.app?.byId.updateBranchByName?.id;
|
const branchId = data.app?.byId.updateBranchByName?.id;
|
||||||
if (!branchId) {
|
if (!branchId) {
|
||||||
throw new Error(`Could not find branch ${branchName} on ${projectDisplayName}`);
|
throw new Error(`Could not find branch ${branchName} on ${projectDisplayName}`);
|
||||||
@@ -142,7 +146,7 @@ export default class BranchDelete extends EasCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const deletionResult = await deleteBranchOnAppAsync({
|
const deletionResult = await deleteBranchOnAppAsync(graphqlClient, {
|
||||||
branchId,
|
branchId,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -14,12 +14,14 @@ export default class BranchList extends EasCommand {
|
|||||||
|
|
||||||
static override contextDefinition = {
|
static override contextDefinition = {
|
||||||
...this.ContextOptions.ProjectConfig,
|
...this.ContextOptions.ProjectConfig,
|
||||||
|
...this.ContextOptions.LoggedIn,
|
||||||
};
|
};
|
||||||
|
|
||||||
async runAsync(): Promise<void> {
|
async runAsync(): Promise<void> {
|
||||||
const { flags } = await this.parse(BranchList);
|
const { flags } = await this.parse(BranchList);
|
||||||
const {
|
const {
|
||||||
projectConfig: { projectId },
|
projectConfig: { projectId },
|
||||||
|
loggedIn: { graphqlClient },
|
||||||
} = await this.getContextAsync(BranchList, {
|
} = await this.getContextAsync(BranchList, {
|
||||||
nonInteractive: flags['non-interactive'],
|
nonInteractive: flags['non-interactive'],
|
||||||
});
|
});
|
||||||
@@ -29,6 +31,6 @@ export default class BranchList extends EasCommand {
|
|||||||
enableJsonOutput();
|
enableJsonOutput();
|
||||||
}
|
}
|
||||||
|
|
||||||
await listAndRenderBranchesOnAppAsync({ projectId, paginatedQueryOptions });
|
await listAndRenderBranchesOnAppAsync(graphqlClient, { projectId, paginatedQueryOptions });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3,8 +3,9 @@ import chalk from 'chalk';
|
|||||||
import gql from 'graphql-tag';
|
import gql from 'graphql-tag';
|
||||||
|
|
||||||
import EasCommand from '../../commandUtils/EasCommand';
|
import EasCommand from '../../commandUtils/EasCommand';
|
||||||
|
import { ExpoGraphqlClient } from '../../commandUtils/context/contextUtils/createGraphqlClient';
|
||||||
import { EasNonInteractiveAndJsonFlags } from '../../commandUtils/flags';
|
import { EasNonInteractiveAndJsonFlags } from '../../commandUtils/flags';
|
||||||
import { graphqlClient, withErrorHandlingAsync } from '../../graphql/client';
|
import { withErrorHandlingAsync } from '../../graphql/client';
|
||||||
import {
|
import {
|
||||||
EditUpdateBranchInput,
|
EditUpdateBranchInput,
|
||||||
EditUpdateBranchMutation,
|
EditUpdateBranchMutation,
|
||||||
@@ -16,11 +17,10 @@ import { getDisplayNameForProjectIdAsync } from '../../project/projectUtils';
|
|||||||
import { promptAsync } from '../../prompts';
|
import { promptAsync } from '../../prompts';
|
||||||
import { enableJsonOutput, printJsonOnlyOutput } from '../../utils/json';
|
import { enableJsonOutput, printJsonOnlyOutput } from '../../utils/json';
|
||||||
|
|
||||||
async function renameUpdateBranchOnAppAsync({
|
async function renameUpdateBranchOnAppAsync(
|
||||||
appId,
|
graphqlClient: ExpoGraphqlClient,
|
||||||
name,
|
{ appId, name, newName }: EditUpdateBranchInput
|
||||||
newName,
|
): Promise<Pick<UpdateBranch, 'id' | 'name'>> {
|
||||||
}: EditUpdateBranchInput): Promise<Pick<UpdateBranch, 'id' | 'name'>> {
|
|
||||||
const data = await withErrorHandlingAsync(
|
const data = await withErrorHandlingAsync(
|
||||||
graphqlClient
|
graphqlClient
|
||||||
.mutation<EditUpdateBranchMutation, EditUpdateBranchMutationVariables>(
|
.mutation<EditUpdateBranchMutation, EditUpdateBranchMutationVariables>(
|
||||||
@@ -64,6 +64,7 @@ export default class BranchRename extends EasCommand {
|
|||||||
|
|
||||||
static override contextDefinition = {
|
static override contextDefinition = {
|
||||||
...this.ContextOptions.ProjectConfig,
|
...this.ContextOptions.ProjectConfig,
|
||||||
|
...this.ContextOptions.LoggedIn,
|
||||||
};
|
};
|
||||||
|
|
||||||
async runAsync(): Promise<void> {
|
async runAsync(): Promise<void> {
|
||||||
@@ -72,6 +73,7 @@ export default class BranchRename extends EasCommand {
|
|||||||
} = await this.parse(BranchRename);
|
} = await this.parse(BranchRename);
|
||||||
const {
|
const {
|
||||||
projectConfig: { projectId },
|
projectConfig: { projectId },
|
||||||
|
loggedIn: { graphqlClient },
|
||||||
} = await this.getContextAsync(BranchRename, {
|
} = await this.getContextAsync(BranchRename, {
|
||||||
nonInteractive,
|
nonInteractive,
|
||||||
});
|
});
|
||||||
@@ -79,7 +81,7 @@ export default class BranchRename extends EasCommand {
|
|||||||
enableJsonOutput();
|
enableJsonOutput();
|
||||||
}
|
}
|
||||||
|
|
||||||
const projectDisplayName = await getDisplayNameForProjectIdAsync(projectId);
|
const projectDisplayName = await getDisplayNameForProjectIdAsync(graphqlClient, projectId);
|
||||||
|
|
||||||
if (!currentName) {
|
if (!currentName) {
|
||||||
const validationMessage = 'current name may not be empty.';
|
const validationMessage = 'current name may not be empty.';
|
||||||
@@ -107,7 +109,7 @@ export default class BranchRename extends EasCommand {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
const editedBranch = await renameUpdateBranchOnAppAsync({
|
const editedBranch = await renameUpdateBranchOnAppAsync(graphqlClient, {
|
||||||
appId: projectId,
|
appId: projectId,
|
||||||
name: currentName!,
|
name: currentName!,
|
||||||
newName: newName!,
|
newName: newName!,
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ export default class BranchView extends EasCommand {
|
|||||||
|
|
||||||
static override contextDefinition = {
|
static override contextDefinition = {
|
||||||
...this.ContextOptions.ProjectConfig,
|
...this.ContextOptions.ProjectConfig,
|
||||||
|
...this.ContextOptions.LoggedIn,
|
||||||
};
|
};
|
||||||
|
|
||||||
async runAsync(): Promise<void> {
|
async runAsync(): Promise<void> {
|
||||||
@@ -38,6 +39,7 @@ export default class BranchView extends EasCommand {
|
|||||||
const { 'non-interactive': nonInteractive } = flags;
|
const { 'non-interactive': nonInteractive } = flags;
|
||||||
const {
|
const {
|
||||||
projectConfig: { projectId },
|
projectConfig: { projectId },
|
||||||
|
loggedIn: { graphqlClient },
|
||||||
} = await this.getContextAsync(BranchView, {
|
} = await this.getContextAsync(BranchView, {
|
||||||
nonInteractive,
|
nonInteractive,
|
||||||
});
|
});
|
||||||
@@ -52,7 +54,7 @@ export default class BranchView extends EasCommand {
|
|||||||
throw new Error('Branch name may not be empty.');
|
throw new Error('Branch name may not be empty.');
|
||||||
}
|
}
|
||||||
|
|
||||||
({ name: branchName } = await selectBranchOnAppAsync({
|
({ name: branchName } = await selectBranchOnAppAsync(graphqlClient, {
|
||||||
projectId,
|
projectId,
|
||||||
promptTitle: 'Which branch would you like to view?',
|
promptTitle: 'Which branch would you like to view?',
|
||||||
displayTextForListItem: updateBranch => updateBranch.name,
|
displayTextForListItem: updateBranch => updateBranch.name,
|
||||||
@@ -65,7 +67,7 @@ export default class BranchView extends EasCommand {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
await listAndRenderUpdateGroupsOnBranchAsync({
|
await listAndRenderUpdateGroupsOnBranchAsync(graphqlClient, {
|
||||||
projectId,
|
projectId,
|
||||||
branchName,
|
branchName,
|
||||||
paginatedQueryOptions,
|
paginatedQueryOptions,
|
||||||
|
|||||||
@@ -2,8 +2,9 @@ import chalk from 'chalk';
|
|||||||
import gql from 'graphql-tag';
|
import gql from 'graphql-tag';
|
||||||
|
|
||||||
import EasCommand from '../../commandUtils/EasCommand';
|
import EasCommand from '../../commandUtils/EasCommand';
|
||||||
|
import { ExpoGraphqlClient } from '../../commandUtils/context/contextUtils/createGraphqlClient';
|
||||||
import { EASNonInteractiveFlag } from '../../commandUtils/flags';
|
import { EASNonInteractiveFlag } from '../../commandUtils/flags';
|
||||||
import { graphqlClient, withErrorHandlingAsync } from '../../graphql/client';
|
import { withErrorHandlingAsync } from '../../graphql/client';
|
||||||
import {
|
import {
|
||||||
Build,
|
Build,
|
||||||
BuildStatus,
|
BuildStatus,
|
||||||
@@ -17,7 +18,10 @@ import { appPlatformEmojis } from '../../platform';
|
|||||||
import { getDisplayNameForProjectIdAsync } from '../../project/projectUtils';
|
import { getDisplayNameForProjectIdAsync } from '../../project/projectUtils';
|
||||||
import { confirmAsync, selectAsync } from '../../prompts';
|
import { confirmAsync, selectAsync } from '../../prompts';
|
||||||
|
|
||||||
async function cancelBuildAsync(buildId: string): Promise<Pick<Build, 'id' | 'status'>> {
|
async function cancelBuildAsync(
|
||||||
|
graphqlClient: ExpoGraphqlClient,
|
||||||
|
buildId: string
|
||||||
|
): Promise<Pick<Build, 'id' | 'status'>> {
|
||||||
const data = await withErrorHandlingAsync(
|
const data = await withErrorHandlingAsync(
|
||||||
graphqlClient
|
graphqlClient
|
||||||
.mutation<CancelBuildMutation, CancelBuildMutationVariables>(
|
.mutation<CancelBuildMutation, CancelBuildMutationVariables>(
|
||||||
@@ -56,6 +60,7 @@ function formatUnfinishedBuild(
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function selectBuildToCancelAsync(
|
export async function selectBuildToCancelAsync(
|
||||||
|
graphqlClient: ExpoGraphqlClient,
|
||||||
projectId: string,
|
projectId: string,
|
||||||
projectDisplayName: string
|
projectDisplayName: string
|
||||||
): Promise<string | null> {
|
): Promise<string | null> {
|
||||||
@@ -64,19 +69,19 @@ export async function selectBuildToCancelAsync(
|
|||||||
let builds;
|
let builds;
|
||||||
try {
|
try {
|
||||||
const [newBuilds, inQueueBuilds, inProgressBuilds] = await Promise.all([
|
const [newBuilds, inQueueBuilds, inProgressBuilds] = await Promise.all([
|
||||||
BuildQuery.viewBuildsOnAppAsync({
|
BuildQuery.viewBuildsOnAppAsync(graphqlClient, {
|
||||||
appId: projectId,
|
appId: projectId,
|
||||||
offset: 0,
|
offset: 0,
|
||||||
limit: 10,
|
limit: 10,
|
||||||
filter: { status: BuildStatus.New },
|
filter: { status: BuildStatus.New },
|
||||||
}),
|
}),
|
||||||
BuildQuery.viewBuildsOnAppAsync({
|
BuildQuery.viewBuildsOnAppAsync(graphqlClient, {
|
||||||
appId: projectId,
|
appId: projectId,
|
||||||
offset: 0,
|
offset: 0,
|
||||||
limit: 10,
|
limit: 10,
|
||||||
filter: { status: BuildStatus.InQueue },
|
filter: { status: BuildStatus.InQueue },
|
||||||
}),
|
}),
|
||||||
BuildQuery.viewBuildsOnAppAsync({
|
BuildQuery.viewBuildsOnAppAsync(graphqlClient, {
|
||||||
appId: projectId,
|
appId: projectId,
|
||||||
offset: 0,
|
offset: 0,
|
||||||
limit: 10,
|
limit: 10,
|
||||||
@@ -111,9 +116,12 @@ export async function selectBuildToCancelAsync(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function ensureBuildExistsAsync(buildId: string): Promise<void> {
|
async function ensureBuildExistsAsync(
|
||||||
|
graphqlClient: ExpoGraphqlClient,
|
||||||
|
buildId: string
|
||||||
|
): Promise<void> {
|
||||||
try {
|
try {
|
||||||
await BuildQuery.byIdAsync(buildId);
|
await BuildQuery.byIdAsync(graphqlClient, buildId);
|
||||||
} catch {
|
} catch {
|
||||||
throw new Error(`Couldn't find a build matching the id ${buildId}`);
|
throw new Error(`Couldn't find a build matching the id ${buildId}`);
|
||||||
}
|
}
|
||||||
@@ -130,6 +138,7 @@ export default class BuildCancel extends EasCommand {
|
|||||||
|
|
||||||
static override contextDefinition = {
|
static override contextDefinition = {
|
||||||
...this.ContextOptions.ProjectConfig,
|
...this.ContextOptions.ProjectConfig,
|
||||||
|
...this.ContextOptions.LoggedIn,
|
||||||
};
|
};
|
||||||
|
|
||||||
async runAsync(): Promise<void> {
|
async runAsync(): Promise<void> {
|
||||||
@@ -139,14 +148,15 @@ export default class BuildCancel extends EasCommand {
|
|||||||
} = await this.parse(BuildCancel);
|
} = await this.parse(BuildCancel);
|
||||||
const {
|
const {
|
||||||
projectConfig: { projectId },
|
projectConfig: { projectId },
|
||||||
|
loggedIn: { graphqlClient },
|
||||||
} = await this.getContextAsync(BuildCancel, {
|
} = await this.getContextAsync(BuildCancel, {
|
||||||
nonInteractive,
|
nonInteractive,
|
||||||
});
|
});
|
||||||
|
|
||||||
const displayName = await getDisplayNameForProjectIdAsync(projectId);
|
const displayName = await getDisplayNameForProjectIdAsync(graphqlClient, projectId);
|
||||||
|
|
||||||
if (buildIdFromArg) {
|
if (buildIdFromArg) {
|
||||||
await ensureBuildExistsAsync(buildIdFromArg);
|
await ensureBuildExistsAsync(graphqlClient, buildIdFromArg);
|
||||||
}
|
}
|
||||||
|
|
||||||
let buildId: string | null = buildIdFromArg;
|
let buildId: string | null = buildIdFromArg;
|
||||||
@@ -155,7 +165,7 @@ export default class BuildCancel extends EasCommand {
|
|||||||
throw new Error('BUILD_ID must not be empty in non-interactive mode');
|
throw new Error('BUILD_ID must not be empty in non-interactive mode');
|
||||||
}
|
}
|
||||||
|
|
||||||
buildId = await selectBuildToCancelAsync(projectId, displayName);
|
buildId = await selectBuildToCancelAsync(graphqlClient, projectId, displayName);
|
||||||
if (!buildId) {
|
if (!buildId) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -163,7 +173,7 @@ export default class BuildCancel extends EasCommand {
|
|||||||
|
|
||||||
const spinner = ora().start('Canceling the build…');
|
const spinner = ora().start('Canceling the build…');
|
||||||
try {
|
try {
|
||||||
const { status } = await cancelBuildAsync(buildId);
|
const { status } = await cancelBuildAsync(graphqlClient, buildId);
|
||||||
if (status === BuildStatus.Canceled) {
|
if (status === BuildStatus.Canceled) {
|
||||||
spinner.succeed('Build canceled');
|
spinner.succeed('Build canceled');
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -27,12 +27,14 @@ export default class BuildConfigure extends EasCommand {
|
|||||||
|
|
||||||
static override contextDefinition = {
|
static override contextDefinition = {
|
||||||
...this.ContextOptions.ProjectConfig,
|
...this.ContextOptions.ProjectConfig,
|
||||||
|
...this.ContextOptions.LoggedIn,
|
||||||
};
|
};
|
||||||
|
|
||||||
async runAsync(): Promise<void> {
|
async runAsync(): Promise<void> {
|
||||||
const { flags } = await this.parse(BuildConfigure);
|
const { flags } = await this.parse(BuildConfigure);
|
||||||
const {
|
const {
|
||||||
projectConfig: { exp, projectId, projectDir },
|
projectConfig: { exp, projectId, projectDir },
|
||||||
|
loggedIn: { graphqlClient },
|
||||||
} = await this.getContextAsync(BuildConfigure, {
|
} = await this.getContextAsync(BuildConfigure, {
|
||||||
nonInteractive: false,
|
nonInteractive: false,
|
||||||
});
|
});
|
||||||
@@ -65,14 +67,14 @@ export default class BuildConfigure extends EasCommand {
|
|||||||
if ([RequestedPlatform.Android, RequestedPlatform.All].includes(platform)) {
|
if ([RequestedPlatform.Android, RequestedPlatform.All].includes(platform)) {
|
||||||
const workflow = await resolveWorkflowAsync(projectDir, Platform.ANDROID);
|
const workflow = await resolveWorkflowAsync(projectDir, Platform.ANDROID);
|
||||||
if (workflow === Workflow.GENERIC) {
|
if (workflow === Workflow.GENERIC) {
|
||||||
await syncAndroidUpdatesConfigurationAsync(projectDir, exp, projectId);
|
await syncAndroidUpdatesConfigurationAsync(graphqlClient, projectDir, exp, projectId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ([RequestedPlatform.Ios, RequestedPlatform.All].includes(platform)) {
|
if ([RequestedPlatform.Ios, RequestedPlatform.All].includes(platform)) {
|
||||||
const workflow = await resolveWorkflowAsync(projectDir, Platform.IOS);
|
const workflow = await resolveWorkflowAsync(projectDir, Platform.IOS);
|
||||||
if (workflow === Workflow.GENERIC) {
|
if (workflow === Workflow.GENERIC) {
|
||||||
await syncIosUpdatesConfigurationAsync(projectDir, exp, projectId);
|
await syncIosUpdatesConfigurationAsync(graphqlClient, projectDir, exp, projectId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -110,7 +110,11 @@ export default class Build extends EasCommand {
|
|||||||
}
|
}
|
||||||
const flags = this.sanitizeFlags(rawFlags);
|
const flags = this.sanitizeFlags(rawFlags);
|
||||||
|
|
||||||
const { actor, getDynamicProjectConfigAsync, projectDir } = await this.getContextAsync(Build, {
|
const {
|
||||||
|
loggedIn: { actor, graphqlClient },
|
||||||
|
getDynamicProjectConfigAsync,
|
||||||
|
projectDir,
|
||||||
|
} = await this.getContextAsync(Build, {
|
||||||
nonInteractive: flags.nonInteractive,
|
nonInteractive: flags.nonInteractive,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -118,6 +122,7 @@ export default class Build extends EasCommand {
|
|||||||
|
|
||||||
if (!flags.localBuildOptions.enable) {
|
if (!flags.localBuildOptions.enable) {
|
||||||
await maybeWarnAboutEasOutagesAsync(
|
await maybeWarnAboutEasOutagesAsync(
|
||||||
|
graphqlClient,
|
||||||
flags.autoSubmit
|
flags.autoSubmit
|
||||||
? [StatuspageServiceName.EasBuild, StatuspageServiceName.EasSubmit]
|
? [StatuspageServiceName.EasBuild, StatuspageServiceName.EasSubmit]
|
||||||
: [StatuspageServiceName.EasBuild]
|
: [StatuspageServiceName.EasBuild]
|
||||||
@@ -127,6 +132,7 @@ export default class Build extends EasCommand {
|
|||||||
const flagsWithPlatform = await this.ensurePlatformSelectedAsync(flags);
|
const flagsWithPlatform = await this.ensurePlatformSelectedAsync(flags);
|
||||||
|
|
||||||
await runBuildAndSubmitAsync(
|
await runBuildAndSubmitAsync(
|
||||||
|
graphqlClient,
|
||||||
projectDir,
|
projectDir,
|
||||||
flagsWithPlatform,
|
flagsWithPlatform,
|
||||||
actor,
|
actor,
|
||||||
|
|||||||
@@ -69,12 +69,13 @@ export default class BuildInspect extends EasCommand {
|
|||||||
|
|
||||||
async runAsync(): Promise<void> {
|
async runAsync(): Promise<void> {
|
||||||
const { flags } = await this.parse(BuildInspect);
|
const { flags } = await this.parse(BuildInspect);
|
||||||
const { actor, getDynamicProjectConfigAsync, projectDir } = await this.getContextAsync(
|
const {
|
||||||
BuildInspect,
|
loggedIn: { actor, graphqlClient },
|
||||||
{
|
getDynamicProjectConfigAsync,
|
||||||
nonInteractive: false,
|
projectDir,
|
||||||
}
|
} = await this.getContextAsync(BuildInspect, {
|
||||||
);
|
nonInteractive: false,
|
||||||
|
});
|
||||||
|
|
||||||
const outputDirectory = path.resolve(process.cwd(), flags.output);
|
const outputDirectory = path.resolve(process.cwd(), flags.output);
|
||||||
const tmpWorkingdir = path.join(getTmpDirectory(), uuidv4());
|
const tmpWorkingdir = path.join(getTmpDirectory(), uuidv4());
|
||||||
@@ -95,6 +96,7 @@ export default class BuildInspect extends EasCommand {
|
|||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
await runBuildAndSubmitAsync(
|
await runBuildAndSubmitAsync(
|
||||||
|
graphqlClient,
|
||||||
projectDir,
|
projectDir,
|
||||||
{
|
{
|
||||||
nonInteractive: false,
|
nonInteractive: false,
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ export default class BuildList extends EasCommand {
|
|||||||
|
|
||||||
static override contextDefinition = {
|
static override contextDefinition = {
|
||||||
...this.ContextOptions.ProjectConfig,
|
...this.ContextOptions.ProjectConfig,
|
||||||
|
...this.ContextOptions.LoggedIn,
|
||||||
};
|
};
|
||||||
|
|
||||||
async runAsync(): Promise<void> {
|
async runAsync(): Promise<void> {
|
||||||
@@ -71,6 +72,7 @@ export default class BuildList extends EasCommand {
|
|||||||
} = flags;
|
} = flags;
|
||||||
const {
|
const {
|
||||||
projectConfig: { projectId },
|
projectConfig: { projectId },
|
||||||
|
loggedIn: { graphqlClient },
|
||||||
} = await this.getContextAsync(BuildList, {
|
} = await this.getContextAsync(BuildList, {
|
||||||
nonInteractive,
|
nonInteractive,
|
||||||
});
|
});
|
||||||
@@ -81,9 +83,9 @@ export default class BuildList extends EasCommand {
|
|||||||
const platform = toAppPlatform(requestedPlatform);
|
const platform = toAppPlatform(requestedPlatform);
|
||||||
const graphqlBuildStatus = toGraphQLBuildStatus(buildStatus);
|
const graphqlBuildStatus = toGraphQLBuildStatus(buildStatus);
|
||||||
const graphqlBuildDistribution = toGraphQLBuildDistribution(buildDistribution);
|
const graphqlBuildDistribution = toGraphQLBuildDistribution(buildDistribution);
|
||||||
const displayName = await getDisplayNameForProjectIdAsync(projectId);
|
const displayName = await getDisplayNameForProjectIdAsync(graphqlClient, projectId);
|
||||||
|
|
||||||
await listAndRenderBuildsOnAppAsync({
|
await listAndRenderBuildsOnAppAsync(graphqlClient, {
|
||||||
projectId,
|
projectId,
|
||||||
projectDisplayName: displayName,
|
projectDisplayName: displayName,
|
||||||
filter: {
|
filter: {
|
||||||
|
|||||||
@@ -45,12 +45,13 @@ export default class BuildVersionSetView extends EasCommand {
|
|||||||
|
|
||||||
public async runAsync(): Promise<void> {
|
public async runAsync(): Promise<void> {
|
||||||
const { flags } = await this.parse(BuildVersionSetView);
|
const { flags } = await this.parse(BuildVersionSetView);
|
||||||
const { actor, getDynamicProjectConfigAsync, projectDir } = await this.getContextAsync(
|
const {
|
||||||
BuildVersionSetView,
|
loggedIn: { actor, graphqlClient },
|
||||||
{
|
getDynamicProjectConfigAsync,
|
||||||
nonInteractive: false,
|
projectDir,
|
||||||
}
|
} = await this.getContextAsync(BuildVersionSetView, {
|
||||||
);
|
nonInteractive: false,
|
||||||
|
});
|
||||||
|
|
||||||
const platform = await selectPlatformAsync(flags.platform);
|
const platform = await selectPlatformAsync(flags.platform);
|
||||||
const easJsonAccessor = new EasJsonAccessor(projectDir);
|
const easJsonAccessor = new EasJsonAccessor(projectDir);
|
||||||
@@ -62,7 +63,7 @@ export default class BuildVersionSetView extends EasCommand {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const { exp, projectId } = await getDynamicProjectConfigAsync({ env: profile.env });
|
const { exp, projectId } = await getDynamicProjectConfigAsync({ env: profile.env });
|
||||||
const displayName = await getDisplayNameForProjectIdAsync(projectId);
|
const displayName = await getDisplayNameForProjectIdAsync(graphqlClient, projectId);
|
||||||
|
|
||||||
validateAppConfigForRemoteVersionSource(exp, platform);
|
validateAppConfigForRemoteVersionSource(exp, platform);
|
||||||
|
|
||||||
@@ -74,6 +75,7 @@ export default class BuildVersionSetView extends EasCommand {
|
|||||||
actor
|
actor
|
||||||
);
|
);
|
||||||
const remoteVersions = await AppVersionQuery.latestVersionAsync(
|
const remoteVersions = await AppVersionQuery.latestVersionAsync(
|
||||||
|
graphqlClient,
|
||||||
projectId,
|
projectId,
|
||||||
toAppPlatform(platform),
|
toAppPlatform(platform),
|
||||||
applicationIdentifier
|
applicationIdentifier
|
||||||
@@ -104,7 +106,7 @@ export default class BuildVersionSetView extends EasCommand {
|
|||||||
? value => isValidVersionCode(value) || `Invalid value: ${VERSION_CODE_REQUIREMENTS}.`
|
? value => isValidVersionCode(value) || `Invalid value: ${VERSION_CODE_REQUIREMENTS}.`
|
||||||
: value => isValidBuildNumber(value) || `Invalid value: ${BUILD_NUMBER_REQUIREMENTS}.`,
|
: value => isValidBuildNumber(value) || `Invalid value: ${BUILD_NUMBER_REQUIREMENTS}.`,
|
||||||
});
|
});
|
||||||
await AppVersionMutation.createAppVersionAsync({
|
await AppVersionMutation.createAppVersionAsync(graphqlClient, {
|
||||||
appId: projectId,
|
appId: projectId,
|
||||||
platform: toAppPlatform(platform),
|
platform: toAppPlatform(platform),
|
||||||
applicationIdentifier,
|
applicationIdentifier,
|
||||||
|
|||||||
@@ -62,12 +62,13 @@ export default class BuildVersionSyncView extends EasCommand {
|
|||||||
|
|
||||||
public async runAsync(): Promise<void> {
|
public async runAsync(): Promise<void> {
|
||||||
const { flags } = await this.parse(BuildVersionSyncView);
|
const { flags } = await this.parse(BuildVersionSyncView);
|
||||||
const { actor, getDynamicProjectConfigAsync, projectDir } = await this.getContextAsync(
|
const {
|
||||||
BuildVersionSyncView,
|
loggedIn: { actor, graphqlClient },
|
||||||
{
|
getDynamicProjectConfigAsync,
|
||||||
nonInteractive: true,
|
projectDir,
|
||||||
}
|
} = await this.getContextAsync(BuildVersionSyncView, {
|
||||||
);
|
nonInteractive: true,
|
||||||
|
});
|
||||||
|
|
||||||
const requestedPlatform = await selectRequestedPlatformAsync(flags.platform);
|
const requestedPlatform = await selectRequestedPlatformAsync(flags.platform);
|
||||||
const easJsonAccessor = new EasJsonAccessor(projectDir);
|
const easJsonAccessor = new EasJsonAccessor(projectDir);
|
||||||
@@ -96,6 +97,7 @@ export default class BuildVersionSyncView extends EasCommand {
|
|||||||
actor
|
actor
|
||||||
);
|
);
|
||||||
const remoteVersions = await AppVersionQuery.latestVersionAsync(
|
const remoteVersions = await AppVersionQuery.latestVersionAsync(
|
||||||
|
graphqlClient,
|
||||||
projectId,
|
projectId,
|
||||||
toAppPlatform(profileInfo.platform),
|
toAppPlatform(profileInfo.platform),
|
||||||
applicationIdentifier
|
applicationIdentifier
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ export default class BuildView extends EasCommand {
|
|||||||
|
|
||||||
static override contextDefinition = {
|
static override contextDefinition = {
|
||||||
...this.ContextOptions.ProjectConfig,
|
...this.ContextOptions.ProjectConfig,
|
||||||
|
...this.ContextOptions.LoggedIn,
|
||||||
};
|
};
|
||||||
|
|
||||||
async runAsync(): Promise<void> {
|
async runAsync(): Promise<void> {
|
||||||
@@ -28,6 +29,7 @@ export default class BuildView extends EasCommand {
|
|||||||
} = await this.parse(BuildView);
|
} = await this.parse(BuildView);
|
||||||
const {
|
const {
|
||||||
projectConfig: { projectId },
|
projectConfig: { projectId },
|
||||||
|
loggedIn: { graphqlClient },
|
||||||
} = await this.getContextAsync(BuildView, {
|
} = await this.getContextAsync(BuildView, {
|
||||||
nonInteractive: true,
|
nonInteractive: true,
|
||||||
});
|
});
|
||||||
@@ -35,7 +37,7 @@ export default class BuildView extends EasCommand {
|
|||||||
enableJsonOutput();
|
enableJsonOutput();
|
||||||
}
|
}
|
||||||
|
|
||||||
const displayName = await getDisplayNameForProjectIdAsync(projectId);
|
const displayName = await getDisplayNameForProjectIdAsync(graphqlClient, projectId);
|
||||||
|
|
||||||
const spinner = ora().start('Fetching the build…');
|
const spinner = ora().start('Fetching the build…');
|
||||||
|
|
||||||
@@ -43,9 +45,9 @@ export default class BuildView extends EasCommand {
|
|||||||
let build: BuildFragment;
|
let build: BuildFragment;
|
||||||
|
|
||||||
if (buildId) {
|
if (buildId) {
|
||||||
build = await BuildQuery.byIdAsync(buildId);
|
build = await BuildQuery.byIdAsync(graphqlClient, buildId);
|
||||||
} else {
|
} else {
|
||||||
const builds = await BuildQuery.viewBuildsOnAppAsync({
|
const builds = await BuildQuery.viewBuildsOnAppAsync(graphqlClient, {
|
||||||
appId: projectId,
|
appId: projectId,
|
||||||
offset: 0,
|
offset: 0,
|
||||||
limit: 1,
|
limit: 1,
|
||||||
|
|||||||
@@ -3,8 +3,9 @@ import gql from 'graphql-tag';
|
|||||||
|
|
||||||
import { BranchNotFoundError } from '../../branch/utils';
|
import { BranchNotFoundError } from '../../branch/utils';
|
||||||
import EasCommand from '../../commandUtils/EasCommand';
|
import EasCommand from '../../commandUtils/EasCommand';
|
||||||
|
import { ExpoGraphqlClient } from '../../commandUtils/context/contextUtils/createGraphqlClient';
|
||||||
import { EasNonInteractiveAndJsonFlags } from '../../commandUtils/flags';
|
import { EasNonInteractiveAndJsonFlags } from '../../commandUtils/flags';
|
||||||
import { graphqlClient, withErrorHandlingAsync } from '../../graphql/client';
|
import { withErrorHandlingAsync } from '../../graphql/client';
|
||||||
import {
|
import {
|
||||||
CreateUpdateChannelOnAppMutation,
|
CreateUpdateChannelOnAppMutation,
|
||||||
CreateUpdateChannelOnAppMutationVariables,
|
CreateUpdateChannelOnAppMutationVariables,
|
||||||
@@ -17,15 +18,18 @@ import formatFields from '../../utils/formatFields';
|
|||||||
import { enableJsonOutput, printJsonOnlyOutput } from '../../utils/json';
|
import { enableJsonOutput, printJsonOnlyOutput } from '../../utils/json';
|
||||||
import { createUpdateBranchOnAppAsync } from '../branch/create';
|
import { createUpdateBranchOnAppAsync } from '../branch/create';
|
||||||
|
|
||||||
export async function createUpdateChannelOnAppAsync({
|
export async function createUpdateChannelOnAppAsync(
|
||||||
appId,
|
graphqlClient: ExpoGraphqlClient,
|
||||||
channelName,
|
{
|
||||||
branchId,
|
appId,
|
||||||
}: {
|
channelName,
|
||||||
appId: string;
|
branchId,
|
||||||
channelName: string;
|
}: {
|
||||||
branchId: string;
|
appId: string;
|
||||||
}): Promise<CreateUpdateChannelOnAppMutation> {
|
channelName: string;
|
||||||
|
branchId: string;
|
||||||
|
}
|
||||||
|
): Promise<CreateUpdateChannelOnAppMutation> {
|
||||||
// Point the new channel at a branch with its same name.
|
// Point the new channel at a branch with its same name.
|
||||||
const branchMapping = JSON.stringify({
|
const branchMapping = JSON.stringify({
|
||||||
data: [{ branchId, branchMappingLogic: 'true' }],
|
data: [{ branchId, branchMappingLogic: 'true' }],
|
||||||
@@ -72,6 +76,7 @@ export default class ChannelCreate extends EasCommand {
|
|||||||
|
|
||||||
static override contextDefinition = {
|
static override contextDefinition = {
|
||||||
...this.ContextOptions.ProjectConfig,
|
...this.ContextOptions.ProjectConfig,
|
||||||
|
...this.ContextOptions.LoggedIn,
|
||||||
};
|
};
|
||||||
|
|
||||||
async runAsync(): Promise<void> {
|
async runAsync(): Promise<void> {
|
||||||
@@ -81,6 +86,7 @@ export default class ChannelCreate extends EasCommand {
|
|||||||
} = await this.parse(ChannelCreate);
|
} = await this.parse(ChannelCreate);
|
||||||
const {
|
const {
|
||||||
projectConfig: { projectId },
|
projectConfig: { projectId },
|
||||||
|
loggedIn: { graphqlClient },
|
||||||
} = await this.getContextAsync(ChannelCreate, {
|
} = await this.getContextAsync(ChannelCreate, {
|
||||||
nonInteractive,
|
nonInteractive,
|
||||||
});
|
});
|
||||||
@@ -105,7 +111,7 @@ export default class ChannelCreate extends EasCommand {
|
|||||||
let branchMessage: string;
|
let branchMessage: string;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const branch = await BranchQuery.getBranchByNameAsync({
|
const branch = await BranchQuery.getBranchByNameAsync(graphqlClient, {
|
||||||
appId: projectId,
|
appId: projectId,
|
||||||
name: channelName,
|
name: channelName,
|
||||||
});
|
});
|
||||||
@@ -113,7 +119,7 @@ export default class ChannelCreate extends EasCommand {
|
|||||||
branchMessage = `We found a branch with the same name`;
|
branchMessage = `We found a branch with the same name`;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error instanceof BranchNotFoundError) {
|
if (error instanceof BranchNotFoundError) {
|
||||||
const newBranch = await createUpdateBranchOnAppAsync({
|
const newBranch = await createUpdateBranchOnAppAsync(graphqlClient, {
|
||||||
appId: projectId,
|
appId: projectId,
|
||||||
name: channelName,
|
name: channelName,
|
||||||
});
|
});
|
||||||
@@ -126,7 +132,7 @@ export default class ChannelCreate extends EasCommand {
|
|||||||
|
|
||||||
const {
|
const {
|
||||||
updateChannel: { createUpdateChannelForApp: newChannel },
|
updateChannel: { createUpdateChannelForApp: newChannel },
|
||||||
} = await createUpdateChannelOnAppAsync({
|
} = await createUpdateChannelOnAppAsync(graphqlClient, {
|
||||||
appId: projectId,
|
appId: projectId,
|
||||||
channelName,
|
channelName,
|
||||||
branchId,
|
branchId,
|
||||||
@@ -144,7 +150,7 @@ export default class ChannelCreate extends EasCommand {
|
|||||||
Log.addNewLineIfNone();
|
Log.addNewLineIfNone();
|
||||||
Log.withTick(
|
Log.withTick(
|
||||||
`Created a new channel on project ${chalk.bold(
|
`Created a new channel on project ${chalk.bold(
|
||||||
await getDisplayNameForProjectIdAsync(projectId)
|
await getDisplayNameForProjectIdAsync(graphqlClient, projectId)
|
||||||
)}`
|
)}`
|
||||||
);
|
);
|
||||||
Log.log(
|
Log.log(
|
||||||
|
|||||||
@@ -2,8 +2,9 @@ import gql from 'graphql-tag';
|
|||||||
|
|
||||||
import { selectChannelOnAppAsync } from '../../channel/queries';
|
import { selectChannelOnAppAsync } from '../../channel/queries';
|
||||||
import EasCommand from '../../commandUtils/EasCommand';
|
import EasCommand from '../../commandUtils/EasCommand';
|
||||||
|
import { ExpoGraphqlClient } from '../../commandUtils/context/contextUtils/createGraphqlClient';
|
||||||
import { EasNonInteractiveAndJsonFlags } from '../../commandUtils/flags';
|
import { EasNonInteractiveAndJsonFlags } from '../../commandUtils/flags';
|
||||||
import { graphqlClient, withErrorHandlingAsync } from '../../graphql/client';
|
import { withErrorHandlingAsync } from '../../graphql/client';
|
||||||
import {
|
import {
|
||||||
DeleteUpdateChannelMutation,
|
DeleteUpdateChannelMutation,
|
||||||
DeleteUpdateChannelMutationVariables,
|
DeleteUpdateChannelMutationVariables,
|
||||||
@@ -31,6 +32,7 @@ export default class ChannelDelete extends EasCommand {
|
|||||||
|
|
||||||
static override contextDefinition = {
|
static override contextDefinition = {
|
||||||
...this.ContextOptions.ProjectConfig,
|
...this.ContextOptions.ProjectConfig,
|
||||||
|
...this.ContextOptions.LoggedIn,
|
||||||
};
|
};
|
||||||
|
|
||||||
async runAsync(): Promise<void> {
|
async runAsync(): Promise<void> {
|
||||||
@@ -40,6 +42,7 @@ export default class ChannelDelete extends EasCommand {
|
|||||||
} = await this.parse(ChannelDelete);
|
} = await this.parse(ChannelDelete);
|
||||||
const {
|
const {
|
||||||
projectConfig: { projectId },
|
projectConfig: { projectId },
|
||||||
|
loggedIn: { graphqlClient },
|
||||||
} = await this.getContextAsync(ChannelDelete, {
|
} = await this.getContextAsync(ChannelDelete, {
|
||||||
nonInteractive,
|
nonInteractive,
|
||||||
});
|
});
|
||||||
@@ -49,7 +52,7 @@ export default class ChannelDelete extends EasCommand {
|
|||||||
|
|
||||||
let channelId, channelName;
|
let channelId, channelName;
|
||||||
if (nameArg) {
|
if (nameArg) {
|
||||||
const { id, name } = await ChannelQuery.viewUpdateChannelAsync({
|
const { id, name } = await ChannelQuery.viewUpdateChannelAsync(graphqlClient, {
|
||||||
appId: projectId,
|
appId: projectId,
|
||||||
channelName: nameArg,
|
channelName: nameArg,
|
||||||
});
|
});
|
||||||
@@ -59,7 +62,7 @@ export default class ChannelDelete extends EasCommand {
|
|||||||
if (nonInteractive) {
|
if (nonInteractive) {
|
||||||
throw new Error('Channel name must be set when running in non-interactive mode');
|
throw new Error('Channel name must be set when running in non-interactive mode');
|
||||||
}
|
}
|
||||||
const { id, name } = await selectChannelOnAppAsync({
|
const { id, name } = await selectChannelOnAppAsync(graphqlClient, {
|
||||||
projectId,
|
projectId,
|
||||||
selectionPromptTitle: 'Select a channel to delete',
|
selectionPromptTitle: 'Select a channel to delete',
|
||||||
paginatedQueryOptions: {
|
paginatedQueryOptions: {
|
||||||
@@ -85,7 +88,7 @@ export default class ChannelDelete extends EasCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const deletionResult = await deleteChannelOnAppAsync({
|
const deletionResult = await deleteChannelOnAppAsync(graphqlClient, {
|
||||||
channelId,
|
channelId,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -97,9 +100,10 @@ export default class ChannelDelete extends EasCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function deleteChannelOnAppAsync({
|
async function deleteChannelOnAppAsync(
|
||||||
channelId,
|
graphqlClient: ExpoGraphqlClient,
|
||||||
}: DeleteUpdateChannelMutationVariables): Promise<DeleteUpdateChannelResult> {
|
{ channelId }: DeleteUpdateChannelMutationVariables
|
||||||
|
): Promise<DeleteUpdateChannelResult> {
|
||||||
const data = await withErrorHandlingAsync(
|
const data = await withErrorHandlingAsync(
|
||||||
graphqlClient
|
graphqlClient
|
||||||
.mutation<DeleteUpdateChannelMutation, DeleteUpdateChannelMutationVariables>(
|
.mutation<DeleteUpdateChannelMutation, DeleteUpdateChannelMutationVariables>(
|
||||||
|
|||||||
@@ -5,8 +5,9 @@ import gql from 'graphql-tag';
|
|||||||
import { selectBranchOnAppAsync } from '../../branch/queries';
|
import { selectBranchOnAppAsync } from '../../branch/queries';
|
||||||
import { selectChannelOnAppAsync } from '../../channel/queries';
|
import { selectChannelOnAppAsync } from '../../channel/queries';
|
||||||
import EasCommand from '../../commandUtils/EasCommand';
|
import EasCommand from '../../commandUtils/EasCommand';
|
||||||
|
import { ExpoGraphqlClient } from '../../commandUtils/context/contextUtils/createGraphqlClient';
|
||||||
import { EasNonInteractiveAndJsonFlags } from '../../commandUtils/flags';
|
import { EasNonInteractiveAndJsonFlags } from '../../commandUtils/flags';
|
||||||
import { graphqlClient, withErrorHandlingAsync } from '../../graphql/client';
|
import { withErrorHandlingAsync } from '../../graphql/client';
|
||||||
import {
|
import {
|
||||||
UpdateChannelBranchMappingMutation,
|
UpdateChannelBranchMappingMutation,
|
||||||
UpdateChannelBranchMappingMutationVariables,
|
UpdateChannelBranchMappingMutationVariables,
|
||||||
@@ -16,12 +17,10 @@ import { ChannelQuery } from '../../graphql/queries/ChannelQuery';
|
|||||||
import Log from '../../log';
|
import Log from '../../log';
|
||||||
import { enableJsonOutput, printJsonOnlyOutput } from '../../utils/json';
|
import { enableJsonOutput, printJsonOnlyOutput } from '../../utils/json';
|
||||||
|
|
||||||
export async function updateChannelBranchMappingAsync({
|
export async function updateChannelBranchMappingAsync(
|
||||||
channelId,
|
graphqlClient: ExpoGraphqlClient,
|
||||||
branchMapping,
|
{ channelId, branchMapping }: UpdateChannelBranchMappingMutationVariables
|
||||||
}: UpdateChannelBranchMappingMutationVariables): Promise<
|
): Promise<UpdateChannelBranchMappingMutation['updateChannel']['editUpdateChannel']> {
|
||||||
UpdateChannelBranchMappingMutation['updateChannel']['editUpdateChannel']
|
|
||||||
> {
|
|
||||||
const data = await withErrorHandlingAsync(
|
const data = await withErrorHandlingAsync(
|
||||||
graphqlClient
|
graphqlClient
|
||||||
.mutation<UpdateChannelBranchMappingMutation, UpdateChannelBranchMappingMutationVariables>(
|
.mutation<UpdateChannelBranchMappingMutation, UpdateChannelBranchMappingMutationVariables>(
|
||||||
@@ -67,6 +66,7 @@ export default class ChannelEdit extends EasCommand {
|
|||||||
|
|
||||||
static override contextDefinition = {
|
static override contextDefinition = {
|
||||||
...this.ContextOptions.ProjectConfig,
|
...this.ContextOptions.ProjectConfig,
|
||||||
|
...this.ContextOptions.LoggedIn,
|
||||||
};
|
};
|
||||||
|
|
||||||
async runAsync(): Promise<void> {
|
async runAsync(): Promise<void> {
|
||||||
@@ -76,6 +76,7 @@ export default class ChannelEdit extends EasCommand {
|
|||||||
} = await this.parse(ChannelEdit);
|
} = await this.parse(ChannelEdit);
|
||||||
const {
|
const {
|
||||||
projectConfig: { projectId },
|
projectConfig: { projectId },
|
||||||
|
loggedIn: { graphqlClient },
|
||||||
} = await this.getContextAsync(ChannelEdit, {
|
} = await this.getContextAsync(ChannelEdit, {
|
||||||
nonInteractive,
|
nonInteractive,
|
||||||
});
|
});
|
||||||
@@ -84,8 +85,11 @@ export default class ChannelEdit extends EasCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const existingChannel = args.name
|
const existingChannel = args.name
|
||||||
? await ChannelQuery.viewUpdateChannelAsync({ appId: projectId, channelName: args.name })
|
? await ChannelQuery.viewUpdateChannelAsync(graphqlClient, {
|
||||||
: await selectChannelOnAppAsync({
|
appId: projectId,
|
||||||
|
channelName: args.name,
|
||||||
|
})
|
||||||
|
: await selectChannelOnAppAsync(graphqlClient, {
|
||||||
projectId,
|
projectId,
|
||||||
selectionPromptTitle: 'Select a channel to edit',
|
selectionPromptTitle: 'Select a channel to edit',
|
||||||
paginatedQueryOptions: { json, nonInteractive, offset: 0 },
|
paginatedQueryOptions: { json, nonInteractive, offset: 0 },
|
||||||
@@ -96,11 +100,11 @@ export default class ChannelEdit extends EasCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const branch = branchFlag
|
const branch = branchFlag
|
||||||
? await BranchQuery.getBranchByNameAsync({
|
? await BranchQuery.getBranchByNameAsync(graphqlClient, {
|
||||||
appId: projectId,
|
appId: projectId,
|
||||||
name: branchFlag,
|
name: branchFlag,
|
||||||
})
|
})
|
||||||
: await selectBranchOnAppAsync({
|
: await selectBranchOnAppAsync(graphqlClient, {
|
||||||
projectId,
|
projectId,
|
||||||
promptTitle: `Which branch would you like ${existingChannel.name} to point at?`,
|
promptTitle: `Which branch would you like ${existingChannel.name} to point at?`,
|
||||||
displayTextForListItem: updateBranch => updateBranch.name,
|
displayTextForListItem: updateBranch => updateBranch.name,
|
||||||
@@ -111,7 +115,7 @@ export default class ChannelEdit extends EasCommand {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const channel = await updateChannelBranchMappingAsync({
|
const channel = await updateChannelBranchMappingAsync(graphqlClient, {
|
||||||
channelId: existingChannel.id,
|
channelId: existingChannel.id,
|
||||||
// todo: move branch mapping logic to utility
|
// todo: move branch mapping logic to utility
|
||||||
branchMapping: JSON.stringify({
|
branchMapping: JSON.stringify({
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ export default class ChannelList extends EasCommand {
|
|||||||
|
|
||||||
static override contextDefinition = {
|
static override contextDefinition = {
|
||||||
...this.ContextOptions.ProjectConfig,
|
...this.ContextOptions.ProjectConfig,
|
||||||
|
...this.ContextOptions.LoggedIn,
|
||||||
};
|
};
|
||||||
|
|
||||||
async runAsync(): Promise<void> {
|
async runAsync(): Promise<void> {
|
||||||
@@ -27,6 +28,7 @@ export default class ChannelList extends EasCommand {
|
|||||||
const { json: jsonFlag, 'non-interactive': nonInteractive } = flags;
|
const { json: jsonFlag, 'non-interactive': nonInteractive } = flags;
|
||||||
const {
|
const {
|
||||||
projectConfig: { projectId },
|
projectConfig: { projectId },
|
||||||
|
loggedIn: { graphqlClient },
|
||||||
} = await this.getContextAsync(ChannelList, {
|
} = await this.getContextAsync(ChannelList, {
|
||||||
nonInteractive,
|
nonInteractive,
|
||||||
});
|
});
|
||||||
@@ -34,7 +36,7 @@ export default class ChannelList extends EasCommand {
|
|||||||
enableJsonOutput();
|
enableJsonOutput();
|
||||||
}
|
}
|
||||||
|
|
||||||
await listAndRenderChannelsOnAppAsync({
|
await listAndRenderChannelsOnAppAsync(graphqlClient, {
|
||||||
projectId,
|
projectId,
|
||||||
paginatedQueryOptions,
|
paginatedQueryOptions,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import chalk from 'chalk';
|
|||||||
|
|
||||||
import { BranchMapping, getBranchMapping } from '../../channel/utils';
|
import { BranchMapping, getBranchMapping } from '../../channel/utils';
|
||||||
import EasCommand from '../../commandUtils/EasCommand';
|
import EasCommand from '../../commandUtils/EasCommand';
|
||||||
|
import { ExpoGraphqlClient } from '../../commandUtils/context/contextUtils/createGraphqlClient';
|
||||||
import { EasNonInteractiveAndJsonFlags } from '../../commandUtils/flags';
|
import { EasNonInteractiveAndJsonFlags } from '../../commandUtils/flags';
|
||||||
import { UpdateBranch } from '../../graphql/generated';
|
import { UpdateBranch } from '../../graphql/generated';
|
||||||
import { BranchQuery } from '../../graphql/queries/BranchQuery';
|
import { BranchQuery } from '../../graphql/queries/BranchQuery';
|
||||||
@@ -54,25 +55,28 @@ function getRolloutInfo(channel: UpdateChannelByNameObject): {
|
|||||||
return { newBranch, oldBranch, currentPercent };
|
return { newBranch, oldBranch, currentPercent };
|
||||||
}
|
}
|
||||||
|
|
||||||
async function startRolloutAsync({
|
async function startRolloutAsync(
|
||||||
channelName,
|
graphqlClient: ExpoGraphqlClient,
|
||||||
branchName,
|
{
|
||||||
percent,
|
channelName,
|
||||||
projectId,
|
branchName,
|
||||||
displayName,
|
percent,
|
||||||
currentBranchMapping,
|
projectId,
|
||||||
channel,
|
displayName,
|
||||||
nonInteractive,
|
currentBranchMapping,
|
||||||
}: {
|
channel,
|
||||||
channelName?: string;
|
nonInteractive,
|
||||||
branchName: string;
|
}: {
|
||||||
percent?: number;
|
channelName?: string;
|
||||||
projectId: string;
|
branchName: string;
|
||||||
displayName: string;
|
percent?: number;
|
||||||
currentBranchMapping: BranchMapping;
|
projectId: string;
|
||||||
channel: UpdateChannelByNameObject;
|
displayName: string;
|
||||||
nonInteractive: boolean;
|
currentBranchMapping: BranchMapping;
|
||||||
}): Promise<{
|
channel: UpdateChannelByNameObject;
|
||||||
|
nonInteractive: boolean;
|
||||||
|
}
|
||||||
|
): Promise<{
|
||||||
newChannelInfo: {
|
newChannelInfo: {
|
||||||
id: string;
|
id: string;
|
||||||
name: string;
|
name: string;
|
||||||
@@ -80,7 +84,7 @@ async function startRolloutAsync({
|
|||||||
};
|
};
|
||||||
logMessage: string;
|
logMessage: string;
|
||||||
}> {
|
}> {
|
||||||
const branch = await BranchQuery.getBranchByNameAsync({
|
const branch = await BranchQuery.getBranchByNameAsync(graphqlClient, {
|
||||||
appId: projectId,
|
appId: projectId,
|
||||||
name: branchName,
|
name: branchName,
|
||||||
});
|
});
|
||||||
@@ -116,7 +120,7 @@ async function startRolloutAsync({
|
|||||||
currentBranchMapping.data[0],
|
currentBranchMapping.data[0],
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
const newChannelInfo = await updateChannelBranchMappingAsync({
|
const newChannelInfo = await updateChannelBranchMappingAsync(graphqlClient, {
|
||||||
channelId: channel.id,
|
channelId: channel.id,
|
||||||
branchMapping: JSON.stringify(newBranchMapping),
|
branchMapping: JSON.stringify(newBranchMapping),
|
||||||
});
|
});
|
||||||
@@ -139,19 +143,22 @@ async function startRolloutAsync({
|
|||||||
return { newChannelInfo, logMessage };
|
return { newChannelInfo, logMessage };
|
||||||
}
|
}
|
||||||
|
|
||||||
async function editRolloutAsync({
|
async function editRolloutAsync(
|
||||||
channelName,
|
graphqlClient: ExpoGraphqlClient,
|
||||||
percent,
|
{
|
||||||
nonInteractive,
|
channelName,
|
||||||
currentBranchMapping,
|
percent,
|
||||||
channel,
|
nonInteractive,
|
||||||
}: {
|
currentBranchMapping,
|
||||||
channelName?: string;
|
channel,
|
||||||
percent?: number;
|
}: {
|
||||||
nonInteractive: boolean;
|
channelName?: string;
|
||||||
currentBranchMapping: BranchMapping;
|
percent?: number;
|
||||||
channel: UpdateChannelByNameObject;
|
nonInteractive: boolean;
|
||||||
}): Promise<{
|
currentBranchMapping: BranchMapping;
|
||||||
|
channel: UpdateChannelByNameObject;
|
||||||
|
}
|
||||||
|
): Promise<{
|
||||||
newChannelInfo: {
|
newChannelInfo: {
|
||||||
id: string;
|
id: string;
|
||||||
name: string;
|
name: string;
|
||||||
@@ -178,7 +185,7 @@ async function editRolloutAsync({
|
|||||||
const newBranchMapping = { ...currentBranchMapping };
|
const newBranchMapping = { ...currentBranchMapping };
|
||||||
newBranchMapping.data[0].branchMappingLogic.operand = percent / 100;
|
newBranchMapping.data[0].branchMappingLogic.operand = percent / 100;
|
||||||
|
|
||||||
const newChannelInfo = await updateChannelBranchMappingAsync({
|
const newChannelInfo = await updateChannelBranchMappingAsync(graphqlClient, {
|
||||||
channelId: channel.id,
|
channelId: channel.id,
|
||||||
branchMapping: JSON.stringify(newBranchMapping),
|
branchMapping: JSON.stringify(newBranchMapping),
|
||||||
});
|
});
|
||||||
@@ -194,19 +201,22 @@ async function editRolloutAsync({
|
|||||||
return { newChannelInfo, logMessage };
|
return { newChannelInfo, logMessage };
|
||||||
}
|
}
|
||||||
|
|
||||||
async function endRolloutAsync({
|
async function endRolloutAsync(
|
||||||
channelName,
|
graphqlClient: ExpoGraphqlClient,
|
||||||
branchName,
|
{
|
||||||
nonInteractive,
|
channelName,
|
||||||
projectId,
|
branchName,
|
||||||
channel,
|
nonInteractive,
|
||||||
}: {
|
projectId,
|
||||||
channelName?: string;
|
channel,
|
||||||
branchName?: string;
|
}: {
|
||||||
nonInteractive: boolean;
|
channelName?: string;
|
||||||
projectId: string;
|
branchName?: string;
|
||||||
channel: UpdateChannelByNameObject;
|
nonInteractive: boolean;
|
||||||
}): Promise<{
|
projectId: string;
|
||||||
|
channel: UpdateChannelByNameObject;
|
||||||
|
}
|
||||||
|
): Promise<{
|
||||||
newChannelInfo: {
|
newChannelInfo: {
|
||||||
id: string;
|
id: string;
|
||||||
name: string;
|
name: string;
|
||||||
@@ -219,7 +229,7 @@ async function endRolloutAsync({
|
|||||||
|
|
||||||
let endOnNewBranch;
|
let endOnNewBranch;
|
||||||
if (branchName) {
|
if (branchName) {
|
||||||
const branch = await BranchQuery.getBranchByNameAsync({
|
const branch = await BranchQuery.getBranchByNameAsync(graphqlClient, {
|
||||||
appId: projectId,
|
appId: projectId,
|
||||||
name: branchName,
|
name: branchName,
|
||||||
});
|
});
|
||||||
@@ -270,7 +280,7 @@ async function endRolloutAsync({
|
|||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
const newChannelInfo = await updateChannelBranchMappingAsync({
|
const newChannelInfo = await updateChannelBranchMappingAsync(graphqlClient, {
|
||||||
channelId: channel.id,
|
channelId: channel.id,
|
||||||
branchMapping: JSON.stringify(newBranchMapping),
|
branchMapping: JSON.stringify(newBranchMapping),
|
||||||
});
|
});
|
||||||
@@ -313,6 +323,7 @@ export default class ChannelRollout extends EasCommand {
|
|||||||
|
|
||||||
static override contextDefinition = {
|
static override contextDefinition = {
|
||||||
...this.ContextOptions.ProjectConfig,
|
...this.ContextOptions.ProjectConfig,
|
||||||
|
...this.ContextOptions.LoggedIn,
|
||||||
};
|
};
|
||||||
|
|
||||||
async runAsync(): Promise<void> {
|
async runAsync(): Promise<void> {
|
||||||
@@ -328,6 +339,7 @@ export default class ChannelRollout extends EasCommand {
|
|||||||
} = await this.parse(ChannelRollout);
|
} = await this.parse(ChannelRollout);
|
||||||
const {
|
const {
|
||||||
projectConfig: { projectId },
|
projectConfig: { projectId },
|
||||||
|
loggedIn: { graphqlClient },
|
||||||
} = await this.getContextAsync(ChannelRollout, {
|
} = await this.getContextAsync(ChannelRollout, {
|
||||||
nonInteractive,
|
nonInteractive,
|
||||||
});
|
});
|
||||||
@@ -335,9 +347,9 @@ export default class ChannelRollout extends EasCommand {
|
|||||||
enableJsonOutput();
|
enableJsonOutput();
|
||||||
}
|
}
|
||||||
|
|
||||||
const projectDisplayName = await getDisplayNameForProjectIdAsync(projectId);
|
const projectDisplayName = await getDisplayNameForProjectIdAsync(graphqlClient, projectId);
|
||||||
|
|
||||||
const channel = await ChannelQuery.viewUpdateChannelAsync({
|
const channel = await ChannelQuery.viewUpdateChannelAsync(graphqlClient, {
|
||||||
appId: projectId,
|
appId: projectId,
|
||||||
channelName: channelName!,
|
channelName: channelName!,
|
||||||
});
|
});
|
||||||
@@ -382,7 +394,7 @@ export default class ChannelRollout extends EasCommand {
|
|||||||
logMessage: string;
|
logMessage: string;
|
||||||
};
|
};
|
||||||
if (!isRollout) {
|
if (!isRollout) {
|
||||||
rolloutMutationResult = await startRolloutAsync({
|
rolloutMutationResult = await startRolloutAsync(graphqlClient, {
|
||||||
channelName,
|
channelName,
|
||||||
branchName: branchName ?? (await promptForBranchNameAsync(channelName, nonInteractive)),
|
branchName: branchName ?? (await promptForBranchNameAsync(channelName, nonInteractive)),
|
||||||
percent,
|
percent,
|
||||||
@@ -393,7 +405,7 @@ export default class ChannelRollout extends EasCommand {
|
|||||||
channel,
|
channel,
|
||||||
});
|
});
|
||||||
} else if (endFlag) {
|
} else if (endFlag) {
|
||||||
rolloutMutationResult = await endRolloutAsync({
|
rolloutMutationResult = await endRolloutAsync(graphqlClient, {
|
||||||
channelName,
|
channelName,
|
||||||
branchName,
|
branchName,
|
||||||
nonInteractive,
|
nonInteractive,
|
||||||
@@ -401,7 +413,7 @@ export default class ChannelRollout extends EasCommand {
|
|||||||
channel,
|
channel,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
rolloutMutationResult = await editRolloutAsync({
|
rolloutMutationResult = await editRolloutAsync(graphqlClient, {
|
||||||
channelName,
|
channelName,
|
||||||
percent,
|
percent,
|
||||||
nonInteractive,
|
nonInteractive,
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ export default class ChannelView extends EasCommand {
|
|||||||
|
|
||||||
static override contextDefinition = {
|
static override contextDefinition = {
|
||||||
...this.ContextOptions.ProjectConfig,
|
...this.ContextOptions.ProjectConfig,
|
||||||
|
...this.ContextOptions.LoggedIn,
|
||||||
};
|
};
|
||||||
|
|
||||||
async runAsync(): Promise<void> {
|
async runAsync(): Promise<void> {
|
||||||
@@ -38,6 +39,7 @@ export default class ChannelView extends EasCommand {
|
|||||||
const { json: jsonFlag, 'non-interactive': nonInteractive } = flags;
|
const { json: jsonFlag, 'non-interactive': nonInteractive } = flags;
|
||||||
const {
|
const {
|
||||||
projectConfig: { projectId },
|
projectConfig: { projectId },
|
||||||
|
loggedIn: { graphqlClient },
|
||||||
} = await this.getContextAsync(ChannelView, {
|
} = await this.getContextAsync(ChannelView, {
|
||||||
nonInteractive,
|
nonInteractive,
|
||||||
});
|
});
|
||||||
@@ -50,7 +52,7 @@ export default class ChannelView extends EasCommand {
|
|||||||
if (nonInteractive) {
|
if (nonInteractive) {
|
||||||
throw new Error(validationMessage);
|
throw new Error(validationMessage);
|
||||||
}
|
}
|
||||||
const selectedUpdateChannel = await selectChannelOnAppAsync({
|
const selectedUpdateChannel = await selectChannelOnAppAsync(graphqlClient, {
|
||||||
projectId,
|
projectId,
|
||||||
selectionPromptTitle: 'Select a channel to view',
|
selectionPromptTitle: 'Select a channel to view',
|
||||||
paginatedQueryOptions: {
|
paginatedQueryOptions: {
|
||||||
@@ -63,7 +65,7 @@ export default class ChannelView extends EasCommand {
|
|||||||
assert(channelName, `A channel must be selected.`);
|
assert(channelName, `A channel must be selected.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
await listAndRenderBranchesAndUpdatesOnChannelAsync({
|
await listAndRenderBranchesAndUpdatesOnChannelAsync(graphqlClient, {
|
||||||
projectId,
|
projectId,
|
||||||
channelName,
|
channelName,
|
||||||
paginatedQueryOptions,
|
paginatedQueryOptions,
|
||||||
|
|||||||
@@ -17,10 +17,18 @@ export default class Credentials extends EasCommand {
|
|||||||
|
|
||||||
async runAsync(): Promise<void> {
|
async runAsync(): Promise<void> {
|
||||||
const { flags } = await this.parse(Credentials);
|
const { flags } = await this.parse(Credentials);
|
||||||
const { actor, projectConfig } = await this.getContextAsync(Credentials, {
|
const {
|
||||||
|
loggedIn: { actor, graphqlClient },
|
||||||
|
projectConfig,
|
||||||
|
} = await this.getContextAsync(Credentials, {
|
||||||
nonInteractive: false,
|
nonInteractive: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
await new SelectPlatform(actor, projectConfig ?? null, flags.platform).runAsync();
|
await new SelectPlatform(
|
||||||
|
actor,
|
||||||
|
graphqlClient,
|
||||||
|
projectConfig ?? null,
|
||||||
|
flags.platform
|
||||||
|
).runAsync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -13,13 +13,17 @@ export default class DeviceCreate extends EasCommand {
|
|||||||
|
|
||||||
async runAsync(): Promise<void> {
|
async runAsync(): Promise<void> {
|
||||||
// this command is interactive by design
|
// this command is interactive by design
|
||||||
const { actor, projectConfig } = await this.getContextAsync(DeviceCreate, {
|
const {
|
||||||
|
loggedIn: { actor, graphqlClient },
|
||||||
|
projectConfig,
|
||||||
|
} = await this.getContextAsync(DeviceCreate, {
|
||||||
nonInteractive: false,
|
nonInteractive: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
const ctx = await createContextAsync({
|
const ctx = await createContextAsync({
|
||||||
appStore: new AppStoreApi(),
|
appStore: new AppStoreApi(),
|
||||||
user: actor,
|
user: actor,
|
||||||
|
graphqlClient,
|
||||||
projectId: projectConfig?.projectId,
|
projectId: projectConfig?.projectId,
|
||||||
});
|
});
|
||||||
const manager = new DeviceManager(ctx);
|
const manager = new DeviceManager(ctx);
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { Flags } from '@oclif/core';
|
|||||||
import assert from 'assert';
|
import assert from 'assert';
|
||||||
|
|
||||||
import EasCommand from '../../commandUtils/EasCommand';
|
import EasCommand from '../../commandUtils/EasCommand';
|
||||||
|
import { ExpoGraphqlClient } from '../../commandUtils/context/contextUtils/createGraphqlClient';
|
||||||
import { EasNonInteractiveAndJsonFlags } from '../../commandUtils/flags';
|
import { EasNonInteractiveAndJsonFlags } from '../../commandUtils/flags';
|
||||||
import { PaginatedQueryOptions, getPaginatedQueryOptions } from '../../commandUtils/pagination';
|
import { PaginatedQueryOptions, getPaginatedQueryOptions } from '../../commandUtils/pagination';
|
||||||
import { AppleDeviceMutation } from '../../credentials/ios/api/graphql/mutations/AppleDeviceMutation';
|
import { AppleDeviceMutation } from '../../credentials/ios/api/graphql/mutations/AppleDeviceMutation';
|
||||||
@@ -34,6 +35,7 @@ export default class DeviceDelete extends EasCommand {
|
|||||||
|
|
||||||
static override contextDefinition = {
|
static override contextDefinition = {
|
||||||
...this.ContextOptions.ProjectConfig,
|
...this.ContextOptions.ProjectConfig,
|
||||||
|
...this.ContextOptions.LoggedIn,
|
||||||
};
|
};
|
||||||
|
|
||||||
async runAsync(): Promise<void> {
|
async runAsync(): Promise<void> {
|
||||||
@@ -42,10 +44,11 @@ export default class DeviceDelete extends EasCommand {
|
|||||||
let { 'apple-team-id': appleTeamIdentifier, udid } = flags;
|
let { 'apple-team-id': appleTeamIdentifier, udid } = flags;
|
||||||
const {
|
const {
|
||||||
projectConfig: { projectId },
|
projectConfig: { projectId },
|
||||||
|
loggedIn: { graphqlClient },
|
||||||
} = await this.getContextAsync(DeviceDelete, {
|
} = await this.getContextAsync(DeviceDelete, {
|
||||||
nonInteractive: paginatedQueryOptions.nonInteractive,
|
nonInteractive: paginatedQueryOptions.nonInteractive,
|
||||||
});
|
});
|
||||||
const account = await getOwnerAccountForProjectIdAsync(projectId);
|
const account = await getOwnerAccountForProjectIdAsync(graphqlClient, projectId);
|
||||||
let appleTeamName;
|
let appleTeamName;
|
||||||
|
|
||||||
if (paginatedQueryOptions.json) {
|
if (paginatedQueryOptions.json) {
|
||||||
@@ -53,7 +56,7 @@ export default class DeviceDelete extends EasCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!appleTeamIdentifier) {
|
if (!appleTeamIdentifier) {
|
||||||
const appleTeam = await selectAppleTeamOnAccountAsync({
|
const appleTeam = await selectAppleTeamOnAccountAsync(graphqlClient, {
|
||||||
accountName: account.name,
|
accountName: account.name,
|
||||||
selectionPromptTitle: `What Apple team would you like to list devices for?`,
|
selectionPromptTitle: `What Apple team would you like to list devices for?`,
|
||||||
paginatedQueryOptions,
|
paginatedQueryOptions,
|
||||||
@@ -65,8 +68,8 @@ export default class DeviceDelete extends EasCommand {
|
|||||||
assert(appleTeamIdentifier, 'No team identifier is specified');
|
assert(appleTeamIdentifier, 'No team identifier is specified');
|
||||||
|
|
||||||
const chosenDevice = udid
|
const chosenDevice = udid
|
||||||
? await AppleDeviceQuery.getByDeviceIdentifierAsync(account.name, udid)
|
? await AppleDeviceQuery.getByDeviceIdentifierAsync(graphqlClient, account.name, udid)
|
||||||
: await selectAppleDeviceOnAppleTeamAsync({
|
: await selectAppleDeviceOnAppleTeamAsync(graphqlClient, {
|
||||||
accountName: account.name,
|
accountName: account.name,
|
||||||
appleTeamIdentifier,
|
appleTeamIdentifier,
|
||||||
selectionPromptTitle: `Which device would you like to disable?`,
|
selectionPromptTitle: `Which device would you like to disable?`,
|
||||||
@@ -79,7 +82,7 @@ export default class DeviceDelete extends EasCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.removeDeviceFromExpoAsync(chosenDevice);
|
await this.removeDeviceFromExpoAsync(graphqlClient, chosenDevice);
|
||||||
|
|
||||||
if (await this.shouldDisableDeviceOnAppleAsync(paginatedQueryOptions)) {
|
if (await this.shouldDisableDeviceOnAppleAsync(paginatedQueryOptions)) {
|
||||||
await this.disableDeviceOnAppleAsync(chosenDevice, appleTeamIdentifier);
|
await this.disableDeviceOnAppleAsync(chosenDevice, appleTeamIdentifier);
|
||||||
@@ -135,11 +138,12 @@ export default class DeviceDelete extends EasCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async removeDeviceFromExpoAsync(
|
async removeDeviceFromExpoAsync(
|
||||||
|
graphqlClient: ExpoGraphqlClient,
|
||||||
chosenDevice: AppleDevice | AppleDeviceQueryResult
|
chosenDevice: AppleDevice | AppleDeviceQueryResult
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const removalSpinner = ora(`Removing Apple device on Expo`).start();
|
const removalSpinner = ora(`Removing Apple device on Expo`).start();
|
||||||
try {
|
try {
|
||||||
await AppleDeviceMutation.deleteAppleDeviceAsync(chosenDevice.id);
|
await AppleDeviceMutation.deleteAppleDeviceAsync(graphqlClient, chosenDevice.id);
|
||||||
removalSpinner.succeed('Removed Apple device from Expo');
|
removalSpinner.succeed('Removed Apple device from Expo');
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
removalSpinner.fail();
|
removalSpinner.fail();
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ export default class BuildList extends EasCommand {
|
|||||||
|
|
||||||
static override contextDefinition = {
|
static override contextDefinition = {
|
||||||
...this.ContextOptions.ProjectConfig,
|
...this.ContextOptions.ProjectConfig,
|
||||||
|
...this.ContextOptions.LoggedIn,
|
||||||
};
|
};
|
||||||
|
|
||||||
async runAsync(): Promise<void> {
|
async runAsync(): Promise<void> {
|
||||||
@@ -29,6 +30,7 @@ export default class BuildList extends EasCommand {
|
|||||||
const paginatedQueryOptions = getPaginatedQueryOptions(flags);
|
const paginatedQueryOptions = getPaginatedQueryOptions(flags);
|
||||||
const {
|
const {
|
||||||
projectConfig: { projectId },
|
projectConfig: { projectId },
|
||||||
|
loggedIn: { graphqlClient },
|
||||||
} = await this.getContextAsync(BuildList, {
|
} = await this.getContextAsync(BuildList, {
|
||||||
nonInteractive: paginatedQueryOptions.nonInteractive,
|
nonInteractive: paginatedQueryOptions.nonInteractive,
|
||||||
});
|
});
|
||||||
@@ -38,11 +40,11 @@ export default class BuildList extends EasCommand {
|
|||||||
enableJsonOutput();
|
enableJsonOutput();
|
||||||
}
|
}
|
||||||
|
|
||||||
const account = await getOwnerAccountForProjectIdAsync(projectId);
|
const account = await getOwnerAccountForProjectIdAsync(graphqlClient, projectId);
|
||||||
|
|
||||||
// if they don't provide a team id, fetch devices on their account
|
// if they don't provide a team id, fetch devices on their account
|
||||||
if (!appleTeamIdentifier) {
|
if (!appleTeamIdentifier) {
|
||||||
const selectedAppleTeam = await selectAppleTeamOnAccountAsync({
|
const selectedAppleTeam = await selectAppleTeamOnAccountAsync(graphqlClient, {
|
||||||
accountName: account.name,
|
accountName: account.name,
|
||||||
paginatedQueryOptions: {
|
paginatedQueryOptions: {
|
||||||
...paginatedQueryOptions,
|
...paginatedQueryOptions,
|
||||||
@@ -56,7 +58,7 @@ export default class BuildList extends EasCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
assert(appleTeamIdentifier, 'No team identifier is specified');
|
assert(appleTeamIdentifier, 'No team identifier is specified');
|
||||||
await listAndRenderAppleDevicesOnAppleTeamAsync({
|
await listAndRenderAppleDevicesOnAppleTeamAsync(graphqlClient, {
|
||||||
accountName: account.name,
|
accountName: account.name,
|
||||||
appleTeam: {
|
appleTeam: {
|
||||||
appleTeamIdentifier,
|
appleTeamIdentifier,
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ export default class DeviceView extends EasCommand {
|
|||||||
|
|
||||||
static override contextDefinition = {
|
static override contextDefinition = {
|
||||||
...this.ContextOptions.ProjectConfig,
|
...this.ContextOptions.ProjectConfig,
|
||||||
|
...this.ContextOptions.LoggedIn,
|
||||||
};
|
};
|
||||||
|
|
||||||
async runAsync(): Promise<void> {
|
async runAsync(): Promise<void> {
|
||||||
@@ -32,15 +33,20 @@ If you are not sure what is the UDID of the device you are looking for, run:
|
|||||||
}
|
}
|
||||||
const {
|
const {
|
||||||
projectConfig: { projectId },
|
projectConfig: { projectId },
|
||||||
|
loggedIn: { graphqlClient },
|
||||||
} = await this.getContextAsync(DeviceView, {
|
} = await this.getContextAsync(DeviceView, {
|
||||||
nonInteractive: true,
|
nonInteractive: true,
|
||||||
});
|
});
|
||||||
const account = await getOwnerAccountForProjectIdAsync(projectId);
|
const account = await getOwnerAccountForProjectIdAsync(graphqlClient, projectId);
|
||||||
|
|
||||||
const spinner = ora().start(`Fetching device details for ${UDID}…`);
|
const spinner = ora().start(`Fetching device details for ${UDID}…`);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const device = await AppleDeviceQuery.getByDeviceIdentifierAsync(account.name, UDID);
|
const device = await AppleDeviceQuery.getByDeviceIdentifierAsync(
|
||||||
|
graphqlClient,
|
||||||
|
account.name,
|
||||||
|
UDID
|
||||||
|
);
|
||||||
|
|
||||||
if (device) {
|
if (device) {
|
||||||
spinner.succeed('Fetched device details');
|
spinner.succeed('Fetched device details');
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ export default class MetadataPull extends EasCommand {
|
|||||||
|
|
||||||
const { flags } = await this.parse(MetadataPull);
|
const { flags } = await this.parse(MetadataPull);
|
||||||
const {
|
const {
|
||||||
actor,
|
loggedIn: { actor, graphqlClient },
|
||||||
projectConfig: { exp, projectId, projectDir },
|
projectConfig: { exp, projectId, projectDir },
|
||||||
} = await this.getContextAsync(MetadataPull, {
|
} = await this.getContextAsync(MetadataPull, {
|
||||||
nonInteractive: false,
|
nonInteractive: false,
|
||||||
@@ -44,6 +44,7 @@ export default class MetadataPull extends EasCommand {
|
|||||||
projectInfo: { exp, projectId },
|
projectInfo: { exp, projectId },
|
||||||
projectDir,
|
projectDir,
|
||||||
user: actor,
|
user: actor,
|
||||||
|
graphqlClient,
|
||||||
nonInteractive: false,
|
nonInteractive: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ export default class MetadataPush extends EasCommand {
|
|||||||
|
|
||||||
const { flags } = await this.parse(MetadataPush);
|
const { flags } = await this.parse(MetadataPush);
|
||||||
const {
|
const {
|
||||||
actor,
|
loggedIn: { actor, graphqlClient },
|
||||||
projectConfig: { exp, projectId, projectDir },
|
projectConfig: { exp, projectId, projectDir },
|
||||||
} = await this.getContextAsync(MetadataPush, {
|
} = await this.getContextAsync(MetadataPush, {
|
||||||
nonInteractive: false,
|
nonInteractive: false,
|
||||||
@@ -42,6 +42,7 @@ export default class MetadataPush extends EasCommand {
|
|||||||
projectInfo: { exp, projectId },
|
projectInfo: { exp, projectId },
|
||||||
projectDir,
|
projectDir,
|
||||||
user: actor,
|
user: actor,
|
||||||
|
graphqlClient,
|
||||||
nonInteractive: false,
|
nonInteractive: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -10,17 +10,19 @@ export default class Open extends EasCommand {
|
|||||||
|
|
||||||
static override contextDefinition = {
|
static override contextDefinition = {
|
||||||
...this.ContextOptions.ProjectConfig,
|
...this.ContextOptions.ProjectConfig,
|
||||||
|
...this.ContextOptions.LoggedIn,
|
||||||
};
|
};
|
||||||
|
|
||||||
async runAsync(): Promise<void> {
|
async runAsync(): Promise<void> {
|
||||||
// this command is interactive by nature (only really run by humans in a terminal)
|
// this command is interactive by nature (only really run by humans in a terminal)
|
||||||
const {
|
const {
|
||||||
projectConfig: { projectId, exp },
|
projectConfig: { projectId, exp },
|
||||||
|
loggedIn: { graphqlClient },
|
||||||
} = await this.getContextAsync(Open, {
|
} = await this.getContextAsync(Open, {
|
||||||
nonInteractive: false,
|
nonInteractive: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
const account = await getOwnerAccountForProjectIdAsync(projectId);
|
const account = await getOwnerAccountForProjectIdAsync(graphqlClient, projectId);
|
||||||
|
|
||||||
const projectName = exp.slug;
|
const projectName = exp.slug;
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
import { AppJSONConfig, PackageJSONConfig, getConfig } from '@expo/config';
|
import { AppJSONConfig, PackageJSONConfig, getConfig } from '@expo/config';
|
||||||
import chalk from 'chalk';
|
import chalk from 'chalk';
|
||||||
import { vol } from 'memfs';
|
import { vol } from 'memfs';
|
||||||
|
import { instance, mock } from 'ts-mockito';
|
||||||
|
|
||||||
import ActorContextField from '../../../commandUtils/context/ActorContextField';
|
import LoggedInContextField from '../../../commandUtils/context/LoggedInContextField';
|
||||||
import ProjectDirContextField from '../../../commandUtils/context/ProjectDirContextField';
|
import ProjectDirContextField from '../../../commandUtils/context/ProjectDirContextField';
|
||||||
|
import { ExpoGraphqlClient } from '../../../commandUtils/context/contextUtils/createGraphqlClient';
|
||||||
import { saveProjectIdToAppConfigAsync } from '../../../commandUtils/context/contextUtils/getProjectIdAsync';
|
import { saveProjectIdToAppConfigAsync } from '../../../commandUtils/context/contextUtils/getProjectIdAsync';
|
||||||
import { jester } from '../../../credentials/__tests__/fixtures-constants';
|
import { jester } from '../../../credentials/__tests__/fixtures-constants';
|
||||||
import { AppMutation } from '../../../graphql/mutations/AppMutation';
|
import { AppMutation } from '../../../graphql/mutations/AppMutation';
|
||||||
@@ -71,10 +73,13 @@ function mockTestProject(options: {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const mockManifest = { exp: appJSON.expo };
|
const mockManifest = { exp: appJSON.expo };
|
||||||
|
const graphqlClient = instance(mock<ExpoGraphqlClient>());
|
||||||
|
|
||||||
jest.mocked(getConfig).mockReturnValue(mockManifest as any);
|
jest.mocked(getConfig).mockReturnValue(mockManifest as any);
|
||||||
jest.spyOn(ProjectDirContextField.prototype, 'getValueAsync').mockResolvedValue('/test-project');
|
jest.spyOn(ProjectDirContextField.prototype, 'getValueAsync').mockResolvedValue('/test-project');
|
||||||
jest.spyOn(ActorContextField.prototype, 'getValueAsync').mockResolvedValue(jester);
|
jest
|
||||||
|
.spyOn(LoggedInContextField.prototype, 'getValueAsync')
|
||||||
|
.mockResolvedValue({ actor: jester, graphqlClient });
|
||||||
}
|
}
|
||||||
|
|
||||||
const commandOptions = { root: '/test-project' } as any;
|
const commandOptions = { root: '/test-project' } as any;
|
||||||
|
|||||||
@@ -1,12 +1,16 @@
|
|||||||
import gql from 'graphql-tag';
|
import gql from 'graphql-tag';
|
||||||
|
|
||||||
import EasCommand from '../../commandUtils/EasCommand';
|
import EasCommand from '../../commandUtils/EasCommand';
|
||||||
import { graphqlClient, withErrorHandlingAsync } from '../../graphql/client';
|
import { ExpoGraphqlClient } from '../../commandUtils/context/contextUtils/createGraphqlClient';
|
||||||
|
import { withErrorHandlingAsync } from '../../graphql/client';
|
||||||
import { AppInfoQuery, AppInfoQueryVariables } from '../../graphql/generated';
|
import { AppInfoQuery, AppInfoQueryVariables } from '../../graphql/generated';
|
||||||
import Log from '../../log';
|
import Log from '../../log';
|
||||||
import formatFields from '../../utils/formatFields';
|
import formatFields from '../../utils/formatFields';
|
||||||
|
|
||||||
async function projectInfoByIdAsync(appId: string): Promise<AppInfoQuery> {
|
async function projectInfoByIdAsync(
|
||||||
|
graphqlClient: ExpoGraphqlClient,
|
||||||
|
appId: string
|
||||||
|
): Promise<AppInfoQuery> {
|
||||||
const data = await withErrorHandlingAsync(
|
const data = await withErrorHandlingAsync(
|
||||||
graphqlClient
|
graphqlClient
|
||||||
.query<AppInfoQuery, AppInfoQueryVariables>(
|
.query<AppInfoQuery, AppInfoQueryVariables>(
|
||||||
@@ -34,16 +38,18 @@ export default class ProjectInfo extends EasCommand {
|
|||||||
|
|
||||||
static override contextDefinition = {
|
static override contextDefinition = {
|
||||||
...this.ContextOptions.ProjectConfig,
|
...this.ContextOptions.ProjectConfig,
|
||||||
|
...this.ContextOptions.LoggedIn,
|
||||||
};
|
};
|
||||||
|
|
||||||
async runAsync(): Promise<void> {
|
async runAsync(): Promise<void> {
|
||||||
const {
|
const {
|
||||||
projectConfig: { projectId },
|
projectConfig: { projectId },
|
||||||
|
loggedIn: { graphqlClient },
|
||||||
} = await this.getContextAsync(ProjectInfo, {
|
} = await this.getContextAsync(ProjectInfo, {
|
||||||
nonInteractive: true,
|
nonInteractive: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
const { app } = await projectInfoByIdAsync(projectId);
|
const { app } = await projectInfoByIdAsync(graphqlClient, projectId);
|
||||||
if (!app) {
|
if (!app) {
|
||||||
throw new Error(`Could not find project with id: ${projectId}`);
|
throw new Error(`Could not find project with id: ${projectId}`);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import terminalLink from 'terminal-link';
|
|||||||
|
|
||||||
import { getProjectDashboardUrl } from '../../build/utils/url';
|
import { getProjectDashboardUrl } from '../../build/utils/url';
|
||||||
import EasCommand from '../../commandUtils/EasCommand';
|
import EasCommand from '../../commandUtils/EasCommand';
|
||||||
|
import { ExpoGraphqlClient } from '../../commandUtils/context/contextUtils/createGraphqlClient';
|
||||||
import { saveProjectIdToAppConfigAsync } from '../../commandUtils/context/contextUtils/getProjectIdAsync';
|
import { saveProjectIdToAppConfigAsync } from '../../commandUtils/context/contextUtils/getProjectIdAsync';
|
||||||
import { AppPrivacy, Role } from '../../graphql/generated';
|
import { AppPrivacy, Role } from '../../graphql/generated';
|
||||||
import { AppMutation } from '../../graphql/mutations/AppMutation';
|
import { AppMutation } from '../../graphql/mutations/AppMutation';
|
||||||
@@ -100,6 +101,7 @@ export default class ProjectInit extends EasCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static async initializeWithInteractiveSelectionAsync(
|
private static async initializeWithInteractiveSelectionAsync(
|
||||||
|
graphqlClient: ExpoGraphqlClient,
|
||||||
actor: Actor,
|
actor: Actor,
|
||||||
projectDir: string
|
projectDir: string
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
@@ -159,6 +161,7 @@ export default class ProjectInit extends EasCommand {
|
|||||||
const projectName = exp.slug;
|
const projectName = exp.slug;
|
||||||
const projectFullName = `@${accountName}/${projectName}`;
|
const projectFullName = `@${accountName}/${projectName}`;
|
||||||
const existingProjectIdOnServer = await findProjectIdByAccountNameAndSlugNullableAsync(
|
const existingProjectIdOnServer = await findProjectIdByAccountNameAndSlugNullableAsync(
|
||||||
|
graphqlClient,
|
||||||
accountName,
|
accountName,
|
||||||
projectName
|
projectName
|
||||||
);
|
);
|
||||||
@@ -200,7 +203,7 @@ export default class ProjectInit extends EasCommand {
|
|||||||
const spinner = ora(`Creating ${chalk.bold(projectFullName)}`).start();
|
const spinner = ora(`Creating ${chalk.bold(projectFullName)}`).start();
|
||||||
let createdProjectId: string;
|
let createdProjectId: string;
|
||||||
try {
|
try {
|
||||||
createdProjectId = await AppMutation.createAppAsync({
|
createdProjectId = await AppMutation.createAppAsync(graphqlClient, {
|
||||||
accountId: account.id,
|
accountId: account.id,
|
||||||
projectName,
|
projectName,
|
||||||
privacy: toAppPrivacy(exp.privacy) ?? AppPrivacy.Public,
|
privacy: toAppPrivacy(exp.privacy) ?? AppPrivacy.Public,
|
||||||
@@ -218,12 +221,15 @@ export default class ProjectInit extends EasCommand {
|
|||||||
const {
|
const {
|
||||||
flags: { id, force, 'non-interactive': nonInteractive },
|
flags: { id, force, 'non-interactive': nonInteractive },
|
||||||
} = await this.parse(ProjectInit);
|
} = await this.parse(ProjectInit);
|
||||||
const { actor, projectDir } = await this.getContextAsync(ProjectInit, { nonInteractive });
|
const {
|
||||||
|
loggedIn: { actor, graphqlClient },
|
||||||
|
projectDir,
|
||||||
|
} = await this.getContextAsync(ProjectInit, { nonInteractive });
|
||||||
|
|
||||||
if (id) {
|
if (id) {
|
||||||
await ProjectInit.initializeWithExplicitIDAsync(id, projectDir, { force, nonInteractive });
|
await ProjectInit.initializeWithExplicitIDAsync(id, projectDir, { force, nonInteractive });
|
||||||
} else {
|
} else {
|
||||||
await ProjectInit.initializeWithInteractiveSelectionAsync(actor, projectDir);
|
await ProjectInit.initializeWithInteractiveSelectionAsync(graphqlClient, actor, projectDir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -51,6 +51,7 @@ export default class EnvironmentSecretCreate extends EasCommand {
|
|||||||
|
|
||||||
static override contextDefinition = {
|
static override contextDefinition = {
|
||||||
...this.ContextOptions.ProjectConfig,
|
...this.ContextOptions.ProjectConfig,
|
||||||
|
...this.ContextOptions.LoggedIn,
|
||||||
};
|
};
|
||||||
|
|
||||||
async runAsync(): Promise<void> {
|
async runAsync(): Promise<void> {
|
||||||
@@ -66,12 +67,13 @@ export default class EnvironmentSecretCreate extends EasCommand {
|
|||||||
} = await this.parse(EnvironmentSecretCreate);
|
} = await this.parse(EnvironmentSecretCreate);
|
||||||
const {
|
const {
|
||||||
projectConfig: { projectId },
|
projectConfig: { projectId },
|
||||||
|
loggedIn: { graphqlClient },
|
||||||
} = await this.getContextAsync(EnvironmentSecretCreate, {
|
} = await this.getContextAsync(EnvironmentSecretCreate, {
|
||||||
nonInteractive,
|
nonInteractive,
|
||||||
});
|
});
|
||||||
|
|
||||||
const projectDisplayName = await getDisplayNameForProjectIdAsync(projectId);
|
const projectDisplayName = await getDisplayNameForProjectIdAsync(graphqlClient, projectId);
|
||||||
const ownerAccount = await getOwnerAccountForProjectIdAsync(projectId);
|
const ownerAccount = await getOwnerAccountForProjectIdAsync(graphqlClient, projectId);
|
||||||
|
|
||||||
if (!scope) {
|
if (!scope) {
|
||||||
const validationMessage = 'Secret scope may not be empty.';
|
const validationMessage = 'Secret scope may not be empty.';
|
||||||
@@ -178,12 +180,13 @@ export default class EnvironmentSecretCreate extends EasCommand {
|
|||||||
if (scope === EnvironmentSecretScope.PROJECT) {
|
if (scope === EnvironmentSecretScope.PROJECT) {
|
||||||
if (force) {
|
if (force) {
|
||||||
const { appSecrets: existingSecrets } = await EnvironmentSecretsQuery.byAppIdAsync(
|
const { appSecrets: existingSecrets } = await EnvironmentSecretsQuery.byAppIdAsync(
|
||||||
|
graphqlClient,
|
||||||
projectId
|
projectId
|
||||||
);
|
);
|
||||||
const existingSecret = existingSecrets.find(secret => secret.name === name);
|
const existingSecret = existingSecrets.find(secret => secret.name === name);
|
||||||
|
|
||||||
if (existingSecret) {
|
if (existingSecret) {
|
||||||
await EnvironmentSecretMutation.deleteAsync(existingSecret.id);
|
await EnvironmentSecretMutation.deleteAsync(graphqlClient, existingSecret.id);
|
||||||
Log.withTick(
|
Log.withTick(
|
||||||
`Deleting existing secret ${chalk.bold(name)} on project ${chalk.bold(
|
`Deleting existing secret ${chalk.bold(name)} on project ${chalk.bold(
|
||||||
projectDisplayName
|
projectDisplayName
|
||||||
@@ -193,6 +196,7 @@ export default class EnvironmentSecretCreate extends EasCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const secret = await EnvironmentSecretMutation.createForAppAsync(
|
const secret = await EnvironmentSecretMutation.createForAppAsync(
|
||||||
|
graphqlClient,
|
||||||
{ name, value: secretValue, type: SecretTypeToEnvironmentSecretType[secretType] },
|
{ name, value: secretValue, type: SecretTypeToEnvironmentSecretType[secretType] },
|
||||||
projectId
|
projectId
|
||||||
);
|
);
|
||||||
@@ -218,12 +222,13 @@ export default class EnvironmentSecretCreate extends EasCommand {
|
|||||||
} else if (scope === EnvironmentSecretScope.ACCOUNT) {
|
} else if (scope === EnvironmentSecretScope.ACCOUNT) {
|
||||||
if (force) {
|
if (force) {
|
||||||
const { accountSecrets: existingSecrets } = await EnvironmentSecretsQuery.byAppIdAsync(
|
const { accountSecrets: existingSecrets } = await EnvironmentSecretsQuery.byAppIdAsync(
|
||||||
|
graphqlClient,
|
||||||
projectId
|
projectId
|
||||||
);
|
);
|
||||||
const existingSecret = existingSecrets.find(secret => secret.name === name);
|
const existingSecret = existingSecrets.find(secret => secret.name === name);
|
||||||
|
|
||||||
if (existingSecret) {
|
if (existingSecret) {
|
||||||
await EnvironmentSecretMutation.deleteAsync(existingSecret.id);
|
await EnvironmentSecretMutation.deleteAsync(graphqlClient, existingSecret.id);
|
||||||
|
|
||||||
Log.withTick(
|
Log.withTick(
|
||||||
`Deleting existing secret ${chalk.bold(name)} on account ${chalk.bold(
|
`Deleting existing secret ${chalk.bold(name)} on account ${chalk.bold(
|
||||||
@@ -234,6 +239,7 @@ export default class EnvironmentSecretCreate extends EasCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const secret = await EnvironmentSecretMutation.createForAccountAsync(
|
const secret = await EnvironmentSecretMutation.createForAccountAsync(
|
||||||
|
graphqlClient,
|
||||||
{ name, value: secretValue, type: SecretTypeToEnvironmentSecretType[secretType] },
|
{ name, value: secretValue, type: SecretTypeToEnvironmentSecretType[secretType] },
|
||||||
ownerAccount.id
|
ownerAccount.id
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ export default class EnvironmentSecretDelete extends EasCommand {
|
|||||||
|
|
||||||
static override contextDefinition = {
|
static override contextDefinition = {
|
||||||
...this.ContextOptions.ProjectConfig,
|
...this.ContextOptions.ProjectConfig,
|
||||||
|
...this.ContextOptions.LoggedIn,
|
||||||
};
|
};
|
||||||
|
|
||||||
async runAsync(): Promise<void> {
|
async runAsync(): Promise<void> {
|
||||||
@@ -31,6 +32,7 @@ export default class EnvironmentSecretDelete extends EasCommand {
|
|||||||
} = await this.parse(EnvironmentSecretDelete);
|
} = await this.parse(EnvironmentSecretDelete);
|
||||||
const {
|
const {
|
||||||
projectConfig: { projectId },
|
projectConfig: { projectId },
|
||||||
|
loggedIn: { graphqlClient },
|
||||||
} = await this.getContextAsync(EnvironmentSecretDelete, {
|
} = await this.getContextAsync(EnvironmentSecretDelete, {
|
||||||
nonInteractive,
|
nonInteractive,
|
||||||
});
|
});
|
||||||
@@ -42,7 +44,7 @@ export default class EnvironmentSecretDelete extends EasCommand {
|
|||||||
throw new Error(validationMessage);
|
throw new Error(validationMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
const secrets = await EnvironmentSecretsQuery.allAsync(projectId);
|
const secrets = await EnvironmentSecretsQuery.allAsync(graphqlClient, projectId);
|
||||||
({ secret } = await promptAsync({
|
({ secret } = await promptAsync({
|
||||||
type: 'autocomplete',
|
type: 'autocomplete',
|
||||||
name: 'secret',
|
name: 'secret',
|
||||||
@@ -83,7 +85,7 @@ export default class EnvironmentSecretDelete extends EasCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await EnvironmentSecretMutation.deleteAsync(id);
|
await EnvironmentSecretMutation.deleteAsync(graphqlClient, id);
|
||||||
|
|
||||||
Log.withTick(`️Deleted secret${secret?.name ? ` "${secret?.name}"` : ''} with id "${id}".`);
|
Log.withTick(`️Deleted secret${secret?.name ? ` "${secret?.name}"` : ''} with id "${id}".`);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,16 +12,18 @@ export default class EnvironmentSecretList extends EasCommand {
|
|||||||
|
|
||||||
static override contextDefinition = {
|
static override contextDefinition = {
|
||||||
...this.ContextOptions.ProjectConfig,
|
...this.ContextOptions.ProjectConfig,
|
||||||
|
...this.ContextOptions.LoggedIn,
|
||||||
};
|
};
|
||||||
|
|
||||||
async runAsync(): Promise<void> {
|
async runAsync(): Promise<void> {
|
||||||
const {
|
const {
|
||||||
projectConfig: { projectId },
|
projectConfig: { projectId },
|
||||||
|
loggedIn: { graphqlClient },
|
||||||
} = await this.getContextAsync(EnvironmentSecretList, {
|
} = await this.getContextAsync(EnvironmentSecretList, {
|
||||||
nonInteractive: true,
|
nonInteractive: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
const secrets = await EnvironmentSecretsQuery.allAsync(projectId);
|
const secrets = await EnvironmentSecretsQuery.allAsync(graphqlClient, projectId);
|
||||||
|
|
||||||
const table = new Table({
|
const table = new Table({
|
||||||
head: ['Name', 'Type', 'Scope', 'ID', 'Updated at'],
|
head: ['Name', 'Type', 'Scope', 'ID', 'Updated at'],
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ export default class Submit extends EasCommand {
|
|||||||
async runAsync(): Promise<void> {
|
async runAsync(): Promise<void> {
|
||||||
const { flags: rawFlags } = await this.parse(Submit);
|
const { flags: rawFlags } = await this.parse(Submit);
|
||||||
const {
|
const {
|
||||||
actor,
|
loggedIn: { actor, graphqlClient },
|
||||||
projectConfig: { exp, projectId, projectDir },
|
projectConfig: { exp, projectId, projectDir },
|
||||||
} = await this.getContextAsync(Submit, {
|
} = await this.getContextAsync(Submit, {
|
||||||
nonInteractive: false,
|
nonInteractive: false,
|
||||||
@@ -106,7 +106,7 @@ export default class Submit extends EasCommand {
|
|||||||
|
|
||||||
const flags = this.sanitizeFlags(rawFlags);
|
const flags = this.sanitizeFlags(rawFlags);
|
||||||
|
|
||||||
await maybeWarnAboutEasOutagesAsync([StatuspageServiceName.EasSubmit]);
|
await maybeWarnAboutEasOutagesAsync(graphqlClient, [StatuspageServiceName.EasSubmit]);
|
||||||
|
|
||||||
const flagsWithPlatform = await this.ensurePlatformSelectedAsync(flags);
|
const flagsWithPlatform = await this.ensurePlatformSelectedAsync(flags);
|
||||||
|
|
||||||
@@ -128,6 +128,7 @@ export default class Submit extends EasCommand {
|
|||||||
archiveFlags: flagsWithPlatform.archiveFlags,
|
archiveFlags: flagsWithPlatform.archiveFlags,
|
||||||
nonInteractive: flagsWithPlatform.nonInteractive,
|
nonInteractive: flagsWithPlatform.nonInteractive,
|
||||||
actor,
|
actor,
|
||||||
|
graphqlClient,
|
||||||
exp,
|
exp,
|
||||||
projectId,
|
projectId,
|
||||||
});
|
});
|
||||||
@@ -150,7 +151,7 @@ export default class Submit extends EasCommand {
|
|||||||
printSubmissionDetailsUrls(submissions);
|
printSubmissionDetailsUrls(submissions);
|
||||||
|
|
||||||
if (flagsWithPlatform.wait) {
|
if (flagsWithPlatform.wait) {
|
||||||
const completedSubmissions = await waitToCompleteAsync(submissions, {
|
const completedSubmissions = await waitToCompleteAsync(graphqlClient, submissions, {
|
||||||
verbose: flagsWithPlatform.verbose,
|
verbose: flagsWithPlatform.verbose,
|
||||||
});
|
});
|
||||||
exitWithNonZeroCodeIfSomeSubmissionsDidntFinish(completedSubmissions);
|
exitWithNonZeroCodeIfSomeSubmissionsDidntFinish(completedSubmissions);
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ export default class UpdateConfigure extends EasCommand {
|
|||||||
|
|
||||||
static override contextDefinition = {
|
static override contextDefinition = {
|
||||||
...this.ContextOptions.ProjectConfig,
|
...this.ContextOptions.ProjectConfig,
|
||||||
|
...this.ContextOptions.LoggedIn,
|
||||||
};
|
};
|
||||||
|
|
||||||
async runAsync(): Promise<void> {
|
async runAsync(): Promise<void> {
|
||||||
@@ -43,6 +44,7 @@ export default class UpdateConfigure extends EasCommand {
|
|||||||
const { flags } = await this.parse(UpdateConfigure);
|
const { flags } = await this.parse(UpdateConfigure);
|
||||||
const {
|
const {
|
||||||
projectConfig: { projectId, exp, projectDir },
|
projectConfig: { projectId, exp, projectDir },
|
||||||
|
loggedIn: { graphqlClient },
|
||||||
} = await this.getContextAsync(UpdateConfigure, {
|
} = await this.getContextAsync(UpdateConfigure, {
|
||||||
nonInteractive: true,
|
nonInteractive: true,
|
||||||
});
|
});
|
||||||
@@ -74,14 +76,14 @@ export default class UpdateConfigure extends EasCommand {
|
|||||||
[RequestedPlatform.Android, RequestedPlatform.All].includes(platform) &&
|
[RequestedPlatform.Android, RequestedPlatform.All].includes(platform) &&
|
||||||
androidWorkflow === Workflow.GENERIC
|
androidWorkflow === Workflow.GENERIC
|
||||||
) {
|
) {
|
||||||
await syncAndroidUpdatesConfigurationAsync(projectDir, updatedExp, projectId);
|
await syncAndroidUpdatesConfigurationAsync(graphqlClient, projectDir, updatedExp, projectId);
|
||||||
Log.withTick(`Configured ${chalk.bold('AndroidManifest.xml')} for EAS Update`);
|
Log.withTick(`Configured ${chalk.bold('AndroidManifest.xml')} for EAS Update`);
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
[RequestedPlatform.Ios, RequestedPlatform.All].includes(platform) &&
|
[RequestedPlatform.Ios, RequestedPlatform.All].includes(platform) &&
|
||||||
iosWorkflow === Workflow.GENERIC
|
iosWorkflow === Workflow.GENERIC
|
||||||
) {
|
) {
|
||||||
await syncIosUpdatesConfigurationAsync(projectDir, updatedExp, projectId);
|
await syncIosUpdatesConfigurationAsync(graphqlClient, projectDir, updatedExp, projectId);
|
||||||
Log.withTick(`Configured ${chalk.bold('Expo.plist')} for EAS Update`);
|
Log.withTick(`Configured ${chalk.bold('Expo.plist')} for EAS Update`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,8 +2,9 @@ import chalk from 'chalk';
|
|||||||
import gql from 'graphql-tag';
|
import gql from 'graphql-tag';
|
||||||
|
|
||||||
import EasCommand from '../../commandUtils/EasCommand';
|
import EasCommand from '../../commandUtils/EasCommand';
|
||||||
|
import { ExpoGraphqlClient } from '../../commandUtils/context/contextUtils/createGraphqlClient';
|
||||||
import { EasNonInteractiveAndJsonFlags } from '../../commandUtils/flags';
|
import { EasNonInteractiveAndJsonFlags } from '../../commandUtils/flags';
|
||||||
import { graphqlClient, withErrorHandlingAsync } from '../../graphql/client';
|
import { withErrorHandlingAsync } from '../../graphql/client';
|
||||||
import {
|
import {
|
||||||
DeleteUpdateGroupMutation,
|
DeleteUpdateGroupMutation,
|
||||||
UpdateMutationDeleteUpdateGroupArgs,
|
UpdateMutationDeleteUpdateGroupArgs,
|
||||||
@@ -12,11 +13,14 @@ import Log from '../../log';
|
|||||||
import { confirmAsync } from '../../prompts';
|
import { confirmAsync } from '../../prompts';
|
||||||
import { enableJsonOutput, printJsonOnlyOutput } from '../../utils/json';
|
import { enableJsonOutput, printJsonOnlyOutput } from '../../utils/json';
|
||||||
|
|
||||||
async function deleteUpdateGroupAsync({
|
async function deleteUpdateGroupAsync(
|
||||||
group,
|
graphqlClient: ExpoGraphqlClient,
|
||||||
}: {
|
{
|
||||||
group: string;
|
group,
|
||||||
}): Promise<DeleteUpdateGroupMutation> {
|
}: {
|
||||||
|
group: string;
|
||||||
|
}
|
||||||
|
): Promise<DeleteUpdateGroupMutation> {
|
||||||
return await withErrorHandlingAsync(
|
return await withErrorHandlingAsync(
|
||||||
graphqlClient
|
graphqlClient
|
||||||
.mutation<DeleteUpdateGroupMutation, UpdateMutationDeleteUpdateGroupArgs>(
|
.mutation<DeleteUpdateGroupMutation, UpdateMutationDeleteUpdateGroupArgs>(
|
||||||
@@ -50,12 +54,20 @@ export default class UpdateDelete extends EasCommand {
|
|||||||
...EasNonInteractiveAndJsonFlags,
|
...EasNonInteractiveAndJsonFlags,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static override contextDefinition = {
|
||||||
|
...this.ContextOptions.LoggedIn,
|
||||||
|
};
|
||||||
|
|
||||||
async runAsync(): Promise<void> {
|
async runAsync(): Promise<void> {
|
||||||
const {
|
const {
|
||||||
args: { groupId: group },
|
args: { groupId: group },
|
||||||
flags: { json: jsonFlag, 'non-interactive': nonInteractive },
|
flags: { json: jsonFlag, 'non-interactive': nonInteractive },
|
||||||
} = await this.parse(UpdateDelete);
|
} = await this.parse(UpdateDelete);
|
||||||
|
|
||||||
|
const {
|
||||||
|
loggedIn: { graphqlClient },
|
||||||
|
} = await this.getContextAsync(UpdateDelete, { nonInteractive });
|
||||||
|
|
||||||
if (jsonFlag) {
|
if (jsonFlag) {
|
||||||
enableJsonOutput();
|
enableJsonOutput();
|
||||||
}
|
}
|
||||||
@@ -78,7 +90,7 @@ export default class UpdateDelete extends EasCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await deleteUpdateGroupAsync({ group });
|
await deleteUpdateGroupAsync(graphqlClient, { group });
|
||||||
|
|
||||||
if (jsonFlag) {
|
if (jsonFlag) {
|
||||||
printJsonOnlyOutput({ group });
|
printJsonOnlyOutput({ group });
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import { selectBranchOnAppAsync } from '../../branch/queries';
|
|||||||
import { BranchNotFoundError, getDefaultBranchNameAsync } from '../../branch/utils';
|
import { BranchNotFoundError, getDefaultBranchNameAsync } from '../../branch/utils';
|
||||||
import { getUpdateGroupUrl } from '../../build/utils/url';
|
import { getUpdateGroupUrl } from '../../build/utils/url';
|
||||||
import EasCommand from '../../commandUtils/EasCommand';
|
import EasCommand from '../../commandUtils/EasCommand';
|
||||||
|
import { ExpoGraphqlClient } from '../../commandUtils/context/contextUtils/createGraphqlClient';
|
||||||
import { EasNonInteractiveAndJsonFlags } from '../../commandUtils/flags';
|
import { EasNonInteractiveAndJsonFlags } from '../../commandUtils/flags';
|
||||||
import { getPaginatedQueryOptions } from '../../commandUtils/pagination';
|
import { getPaginatedQueryOptions } from '../../commandUtils/pagination';
|
||||||
import fetch from '../../fetch';
|
import fetch from '../../fetch';
|
||||||
@@ -60,17 +61,20 @@ import { createUpdateChannelOnAppAsync } from '../channel/create';
|
|||||||
export const defaultPublishPlatforms: PublishPlatform[] = ['android', 'ios'];
|
export const defaultPublishPlatforms: PublishPlatform[] = ['android', 'ios'];
|
||||||
export type PublishPlatformFlag = PublishPlatform | 'all';
|
export type PublishPlatformFlag = PublishPlatform | 'all';
|
||||||
|
|
||||||
async function ensureChannelExistsAsync({
|
async function ensureChannelExistsAsync(
|
||||||
appId,
|
graphqlClient: ExpoGraphqlClient,
|
||||||
branchId,
|
{
|
||||||
channelName,
|
appId,
|
||||||
}: {
|
branchId,
|
||||||
appId: string;
|
channelName,
|
||||||
branchId: string;
|
}: {
|
||||||
channelName: string;
|
appId: string;
|
||||||
}): Promise<void> {
|
branchId: string;
|
||||||
|
channelName: string;
|
||||||
|
}
|
||||||
|
): Promise<void> {
|
||||||
try {
|
try {
|
||||||
await createUpdateChannelOnAppAsync({
|
await createUpdateChannelOnAppAsync(graphqlClient, {
|
||||||
appId,
|
appId,
|
||||||
channelName,
|
channelName,
|
||||||
branchId,
|
branchId,
|
||||||
@@ -88,26 +92,29 @@ async function ensureChannelExistsAsync({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function ensureBranchExistsAsync({
|
export async function ensureBranchExistsAsync(
|
||||||
appId,
|
graphqlClient: ExpoGraphqlClient,
|
||||||
name: branchName,
|
{ appId, name: branchName }: ViewBranchQueryVariables
|
||||||
}: ViewBranchQueryVariables): Promise<{
|
): Promise<{
|
||||||
branchId: string;
|
branchId: string;
|
||||||
}> {
|
}> {
|
||||||
try {
|
try {
|
||||||
const updateBranch = await BranchQuery.getBranchByNameAsync({
|
const updateBranch = await BranchQuery.getBranchByNameAsync(graphqlClient, {
|
||||||
appId,
|
appId,
|
||||||
name: branchName,
|
name: branchName,
|
||||||
});
|
});
|
||||||
|
|
||||||
const { id } = updateBranch;
|
const { id } = updateBranch;
|
||||||
await ensureChannelExistsAsync({ appId, branchId: id, channelName: branchName });
|
await ensureChannelExistsAsync(graphqlClient, { appId, branchId: id, channelName: branchName });
|
||||||
return { branchId: id };
|
return { branchId: id };
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error instanceof BranchNotFoundError) {
|
if (error instanceof BranchNotFoundError) {
|
||||||
const newUpdateBranch = await createUpdateBranchOnAppAsync({ appId, name: branchName });
|
const newUpdateBranch = await createUpdateBranchOnAppAsync(graphqlClient, {
|
||||||
|
appId,
|
||||||
|
name: branchName,
|
||||||
|
});
|
||||||
Log.withTick(`Created branch: ${chalk.bold(branchName)}`);
|
Log.withTick(`Created branch: ${chalk.bold(branchName)}`);
|
||||||
await ensureChannelExistsAsync({
|
await ensureChannelExistsAsync(graphqlClient, {
|
||||||
appId,
|
appId,
|
||||||
branchId: newUpdateBranch.id,
|
branchId: newUpdateBranch.id,
|
||||||
channelName: branchName,
|
channelName: branchName,
|
||||||
@@ -168,6 +175,7 @@ export default class UpdatePublish extends EasCommand {
|
|||||||
|
|
||||||
static override contextDefinition = {
|
static override contextDefinition = {
|
||||||
...this.ContextOptions.DynamicProjectConfig,
|
...this.ContextOptions.DynamicProjectConfig,
|
||||||
|
...this.ContextOptions.LoggedIn,
|
||||||
};
|
};
|
||||||
|
|
||||||
async runAsync(): Promise<void> {
|
async runAsync(): Promise<void> {
|
||||||
@@ -186,7 +194,10 @@ export default class UpdatePublish extends EasCommand {
|
|||||||
'non-interactive': nonInteractive,
|
'non-interactive': nonInteractive,
|
||||||
json: jsonFlag,
|
json: jsonFlag,
|
||||||
} = flags;
|
} = flags;
|
||||||
const { getDynamicProjectConfigAsync } = await this.getContextAsync(UpdatePublish, {
|
const {
|
||||||
|
getDynamicProjectConfigAsync,
|
||||||
|
loggedIn: { graphqlClient },
|
||||||
|
} = await this.getContextAsync(UpdatePublish, {
|
||||||
nonInteractive,
|
nonInteractive,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -206,7 +217,7 @@ export default class UpdatePublish extends EasCommand {
|
|||||||
isPublicConfig: false,
|
isPublicConfig: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
await maybeWarnAboutEasOutagesAsync([StatuspageServiceName.EasUpdate]);
|
await maybeWarnAboutEasOutagesAsync(graphqlClient, [StatuspageServiceName.EasUpdate]);
|
||||||
|
|
||||||
const codeSigningInfo = await getCodeSigningInfoAsync(expPrivate, privateKeyPath);
|
const codeSigningInfo = await getCodeSigningInfoAsync(expPrivate, privateKeyPath);
|
||||||
|
|
||||||
@@ -246,7 +257,7 @@ export default class UpdatePublish extends EasCommand {
|
|||||||
throw new Error('Must supply --branch or use --auto when in non-interactive mode');
|
throw new Error('Must supply --branch or use --auto when in non-interactive mode');
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
const branch = await selectBranchOnAppAsync({
|
const branch = await selectBranchOnAppAsync(graphqlClient, {
|
||||||
projectId,
|
projectId,
|
||||||
promptTitle: `Which branch would you like to ${
|
promptTitle: `Which branch would you like to ${
|
||||||
republish ? 'republish' : 'publish'
|
republish ? 'republish' : 'publish'
|
||||||
@@ -286,14 +297,16 @@ export default class UpdatePublish extends EasCommand {
|
|||||||
'group' | 'message' | 'runtimeVersion' | 'manifestFragment' | 'platform'
|
'group' | 'message' | 'runtimeVersion' | 'manifestFragment' | 'platform'
|
||||||
>[];
|
>[];
|
||||||
if (group) {
|
if (group) {
|
||||||
const updatesByGroup = await UpdateQuery.viewUpdateGroupAsync({ groupId: group });
|
const updatesByGroup = await UpdateQuery.viewUpdateGroupAsync(graphqlClient, {
|
||||||
|
groupId: group,
|
||||||
|
});
|
||||||
updatesToRepublish = updatesByGroup;
|
updatesToRepublish = updatesByGroup;
|
||||||
} else {
|
} else {
|
||||||
if (nonInteractive) {
|
if (nonInteractive) {
|
||||||
throw new Error('Must supply --group when in non-interactive mode');
|
throw new Error('Must supply --group when in non-interactive mode');
|
||||||
}
|
}
|
||||||
|
|
||||||
updatesToRepublish = await selectUpdateGroupOnBranchAsync({
|
updatesToRepublish = await selectUpdateGroupOnBranchAsync(graphqlClient, {
|
||||||
projectId,
|
projectId,
|
||||||
branchName,
|
branchName,
|
||||||
paginatedQueryOptions,
|
paginatedQueryOptions,
|
||||||
@@ -393,6 +406,7 @@ export default class UpdatePublish extends EasCommand {
|
|||||||
const platforms = platformFlag === 'all' ? defaultPublishPlatforms : [platformFlag];
|
const platforms = platformFlag === 'all' ? defaultPublishPlatforms : [platformFlag];
|
||||||
const assets = await collectAssetsAsync({ inputDir: inputDir!, platforms });
|
const assets = await collectAssetsAsync({ inputDir: inputDir!, platforms });
|
||||||
const uploadResults = await uploadAssetsAsync(
|
const uploadResults = await uploadAssetsAsync(
|
||||||
|
graphqlClient,
|
||||||
assets,
|
assets,
|
||||||
projectId,
|
projectId,
|
||||||
(totalAssets, missingAssets) => {
|
(totalAssets, missingAssets) => {
|
||||||
@@ -423,7 +437,7 @@ export default class UpdatePublish extends EasCommand {
|
|||||||
.map(pair => pair[0]);
|
.map(pair => pair[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
const { branchId } = await ensureBranchExistsAsync({
|
const { branchId } = await ensureBranchExistsAsync(graphqlClient, {
|
||||||
appId: projectId,
|
appId: projectId,
|
||||||
name: branchName,
|
name: branchName,
|
||||||
});
|
});
|
||||||
@@ -455,7 +469,7 @@ export default class UpdatePublish extends EasCommand {
|
|||||||
let newUpdates: UpdatePublishMutation['updateBranch']['publishUpdateGroups'];
|
let newUpdates: UpdatePublishMutation['updateBranch']['publishUpdateGroups'];
|
||||||
const publishSpinner = ora('Publishing...').start();
|
const publishSpinner = ora('Publishing...').start();
|
||||||
try {
|
try {
|
||||||
newUpdates = await PublishMutation.publishUpdateGroupAsync(updateGroups);
|
newUpdates = await PublishMutation.publishUpdateGroupAsync(graphqlClient, updateGroups);
|
||||||
|
|
||||||
if (codeSigningInfo) {
|
if (codeSigningInfo) {
|
||||||
Log.log('🔒 Signing updates');
|
Log.log('🔒 Signing updates');
|
||||||
@@ -488,7 +502,7 @@ export default class UpdatePublish extends EasCommand {
|
|||||||
|
|
||||||
const manifestSignature = signManifestBody(manifestBody, codeSigningInfo);
|
const manifestSignature = signManifestBody(manifestBody, codeSigningInfo);
|
||||||
|
|
||||||
await PublishMutation.setCodeSigningInfoAsync(newUpdate.id, {
|
await PublishMutation.setCodeSigningInfoAsync(graphqlClient, newUpdate.id, {
|
||||||
alg: codeSigningInfo.codeSigningMetadata.alg,
|
alg: codeSigningInfo.codeSigningMetadata.alg,
|
||||||
keyid: codeSigningInfo.codeSigningMetadata.keyid,
|
keyid: codeSigningInfo.codeSigningMetadata.keyid,
|
||||||
sig: manifestSignature,
|
sig: manifestSignature,
|
||||||
@@ -531,7 +545,7 @@ export default class UpdatePublish extends EasCommand {
|
|||||||
const updateGroupId = newUpdatesForRuntimeVersion[0].group;
|
const updateGroupId = newUpdatesForRuntimeVersion[0].group;
|
||||||
|
|
||||||
const projectName = exp.slug;
|
const projectName = exp.slug;
|
||||||
const accountName = (await getOwnerAccountForProjectIdAsync(projectId)).name;
|
const accountName = (await getOwnerAccountForProjectIdAsync(graphqlClient, projectId)).name;
|
||||||
const updateGroupUrl = getUpdateGroupUrl(accountName, projectName, updateGroupId);
|
const updateGroupUrl = getUpdateGroupUrl(accountName, projectName, updateGroupId);
|
||||||
const updateGroupLink = link(updateGroupUrl, { dim: false });
|
const updateGroupLink = link(updateGroupUrl, { dim: false });
|
||||||
|
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ export default class UpdateList extends EasCommand {
|
|||||||
|
|
||||||
static override contextDefinition = {
|
static override contextDefinition = {
|
||||||
...this.ContextOptions.ProjectConfig,
|
...this.ContextOptions.ProjectConfig,
|
||||||
|
...this.ContextOptions.LoggedIn,
|
||||||
};
|
};
|
||||||
|
|
||||||
async runAsync(): Promise<void> {
|
async runAsync(): Promise<void> {
|
||||||
@@ -41,6 +42,7 @@ export default class UpdateList extends EasCommand {
|
|||||||
const { branch: branchFlag, all, json: jsonFlag, 'non-interactive': nonInteractive } = flags;
|
const { branch: branchFlag, all, json: jsonFlag, 'non-interactive': nonInteractive } = flags;
|
||||||
const {
|
const {
|
||||||
projectConfig: { projectId },
|
projectConfig: { projectId },
|
||||||
|
loggedIn: { graphqlClient },
|
||||||
} = await this.getContextAsync(UpdateList, {
|
} = await this.getContextAsync(UpdateList, {
|
||||||
nonInteractive,
|
nonInteractive,
|
||||||
});
|
});
|
||||||
@@ -51,10 +53,10 @@ export default class UpdateList extends EasCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (all) {
|
if (all) {
|
||||||
listAndRenderUpdateGroupsOnAppAsync({ projectId, paginatedQueryOptions });
|
listAndRenderUpdateGroupsOnAppAsync(graphqlClient, { projectId, paginatedQueryOptions });
|
||||||
} else {
|
} else {
|
||||||
if (branchFlag) {
|
if (branchFlag) {
|
||||||
listAndRenderUpdateGroupsOnBranchAsync({
|
listAndRenderUpdateGroupsOnBranchAsync(graphqlClient, {
|
||||||
projectId,
|
projectId,
|
||||||
branchName: branchFlag,
|
branchName: branchFlag,
|
||||||
paginatedQueryOptions,
|
paginatedQueryOptions,
|
||||||
@@ -65,7 +67,7 @@ export default class UpdateList extends EasCommand {
|
|||||||
throw new Error(validationMessage);
|
throw new Error(validationMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
const selectedBranch = await selectBranchOnAppAsync({
|
const selectedBranch = await selectBranchOnAppAsync(graphqlClient, {
|
||||||
projectId,
|
projectId,
|
||||||
promptTitle: 'Which branch would you like to view?',
|
promptTitle: 'Which branch would you like to view?',
|
||||||
displayTextForListItem: updateBranch => updateBranch.name,
|
displayTextForListItem: updateBranch => updateBranch.name,
|
||||||
@@ -77,7 +79,7 @@ export default class UpdateList extends EasCommand {
|
|||||||
offset: 0,
|
offset: 0,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
listAndRenderUpdateGroupsOnBranchAsync({
|
listAndRenderUpdateGroupsOnBranchAsync(graphqlClient, {
|
||||||
projectId,
|
projectId,
|
||||||
branchName: selectedBranch.name,
|
branchName: selectedBranch.name,
|
||||||
paginatedQueryOptions,
|
paginatedQueryOptions,
|
||||||
|
|||||||
@@ -24,16 +24,25 @@ export default class UpdateView extends EasCommand {
|
|||||||
...EasJsonOnlyFlag,
|
...EasJsonOnlyFlag,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static override contextDefinition = {
|
||||||
|
...this.ContextOptions.LoggedIn,
|
||||||
|
};
|
||||||
|
|
||||||
async runAsync(): Promise<void> {
|
async runAsync(): Promise<void> {
|
||||||
const {
|
const {
|
||||||
args: { groupId },
|
args: { groupId },
|
||||||
flags: { json: jsonFlag },
|
flags: { json: jsonFlag },
|
||||||
} = await this.parse(UpdateView);
|
} = await this.parse(UpdateView);
|
||||||
|
|
||||||
|
const {
|
||||||
|
loggedIn: { graphqlClient },
|
||||||
|
} = await this.getContextAsync(UpdateView, { nonInteractive: true });
|
||||||
|
|
||||||
if (jsonFlag) {
|
if (jsonFlag) {
|
||||||
enableJsonOutput();
|
enableJsonOutput();
|
||||||
}
|
}
|
||||||
|
|
||||||
const updatesByGroup = await UpdateQuery.viewUpdateGroupAsync({ groupId });
|
const updatesByGroup = await UpdateQuery.viewUpdateGroupAsync(graphqlClient, { groupId });
|
||||||
const [updateGroupDescription] = getUpdateGroupDescriptions([updatesByGroup]);
|
const [updateGroupDescription] = getUpdateGroupDescriptions([updatesByGroup]);
|
||||||
|
|
||||||
if (jsonFlag) {
|
if (jsonFlag) {
|
||||||
|
|||||||
@@ -27,12 +27,14 @@ export default class WebhookCreate extends EasCommand {
|
|||||||
|
|
||||||
static override contextDefinition = {
|
static override contextDefinition = {
|
||||||
...this.ContextOptions.ProjectConfig,
|
...this.ContextOptions.ProjectConfig,
|
||||||
|
...this.ContextOptions.LoggedIn,
|
||||||
};
|
};
|
||||||
|
|
||||||
async runAsync(): Promise<void> {
|
async runAsync(): Promise<void> {
|
||||||
const { flags } = await this.parse(WebhookCreate);
|
const { flags } = await this.parse(WebhookCreate);
|
||||||
const {
|
const {
|
||||||
projectConfig: { projectId },
|
projectConfig: { projectId },
|
||||||
|
loggedIn: { graphqlClient },
|
||||||
} = await this.getContextAsync(WebhookCreate, {
|
} = await this.getContextAsync(WebhookCreate, {
|
||||||
nonInteractive: flags['non-interactive'],
|
nonInteractive: flags['non-interactive'],
|
||||||
});
|
});
|
||||||
@@ -40,7 +42,7 @@ export default class WebhookCreate extends EasCommand {
|
|||||||
|
|
||||||
const spinner = ora('Creating a webhook').start();
|
const spinner = ora('Creating a webhook').start();
|
||||||
try {
|
try {
|
||||||
await WebhookMutation.createWebhookAsync(projectId, webhookInputParams);
|
await WebhookMutation.createWebhookAsync(graphqlClient, projectId, webhookInputParams);
|
||||||
spinner.succeed('Successfully created a webhook');
|
spinner.succeed('Successfully created a webhook');
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
spinner.fail('Failed to create a webhook');
|
spinner.fail('Failed to create a webhook');
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import chalk from 'chalk';
|
|||||||
import nullthrows from 'nullthrows';
|
import nullthrows from 'nullthrows';
|
||||||
|
|
||||||
import EasCommand from '../../commandUtils/EasCommand';
|
import EasCommand from '../../commandUtils/EasCommand';
|
||||||
|
import { ExpoGraphqlClient } from '../../commandUtils/context/contextUtils/createGraphqlClient';
|
||||||
import { EASNonInteractiveFlag } from '../../commandUtils/flags';
|
import { EASNonInteractiveFlag } from '../../commandUtils/flags';
|
||||||
import { WebhookFragment } from '../../graphql/generated';
|
import { WebhookFragment } from '../../graphql/generated';
|
||||||
import { WebhookMutation } from '../../graphql/mutations/WebhookMutation';
|
import { WebhookMutation } from '../../graphql/mutations/WebhookMutation';
|
||||||
@@ -29,6 +30,7 @@ export default class WebhookDelete extends EasCommand {
|
|||||||
|
|
||||||
static override contextDefinition = {
|
static override contextDefinition = {
|
||||||
...this.ContextOptions.ProjectConfig,
|
...this.ContextOptions.ProjectConfig,
|
||||||
|
...this.ContextOptions.LoggedIn,
|
||||||
};
|
};
|
||||||
|
|
||||||
async runAsync(): Promise<void> {
|
async runAsync(): Promise<void> {
|
||||||
@@ -38,14 +40,15 @@ export default class WebhookDelete extends EasCommand {
|
|||||||
} = await this.parse(WebhookDelete);
|
} = await this.parse(WebhookDelete);
|
||||||
const {
|
const {
|
||||||
projectConfig: { projectId },
|
projectConfig: { projectId },
|
||||||
|
loggedIn: { graphqlClient },
|
||||||
} = await this.getContextAsync(WebhookDelete, {
|
} = await this.getContextAsync(WebhookDelete, {
|
||||||
nonInteractive,
|
nonInteractive,
|
||||||
});
|
});
|
||||||
|
|
||||||
let webhook: WebhookFragment | undefined =
|
let webhook: WebhookFragment | undefined =
|
||||||
webhookId && (await WebhookQuery.byIdAsync(webhookId));
|
webhookId && (await WebhookQuery.byIdAsync(graphqlClient, webhookId));
|
||||||
if (!webhookId) {
|
if (!webhookId) {
|
||||||
const webhooks = await fetchWebhooksByAppIdAsync(projectId);
|
const webhooks = await fetchWebhooksByAppIdAsync(graphqlClient, projectId);
|
||||||
if (webhooks.length === 0) {
|
if (webhooks.length === 0) {
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
@@ -86,7 +89,7 @@ export default class WebhookDelete extends EasCommand {
|
|||||||
|
|
||||||
const spinner = ora('Deleting the webhook').start();
|
const spinner = ora('Deleting the webhook').start();
|
||||||
try {
|
try {
|
||||||
await WebhookMutation.deleteWebhookAsync(webhookId);
|
await WebhookMutation.deleteWebhookAsync(graphqlClient, webhookId);
|
||||||
spinner.succeed('Successfully deleted the webhook');
|
spinner.succeed('Successfully deleted the webhook');
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
spinner.fail('Failed to delete the webhook');
|
spinner.fail('Failed to delete the webhook');
|
||||||
@@ -95,10 +98,13 @@ export default class WebhookDelete extends EasCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchWebhooksByAppIdAsync(appId: string): Promise<WebhookFragment[]> {
|
async function fetchWebhooksByAppIdAsync(
|
||||||
|
graphqlClient: ExpoGraphqlClient,
|
||||||
|
appId: string
|
||||||
|
): Promise<WebhookFragment[]> {
|
||||||
const spinner = ora('Fetching webhooks').start();
|
const spinner = ora('Fetching webhooks').start();
|
||||||
try {
|
try {
|
||||||
const webhooks = await WebhookQuery.byAppIdAsync(appId);
|
const webhooks = await WebhookQuery.byAppIdAsync(graphqlClient, appId);
|
||||||
if (webhooks.length === 0) {
|
if (webhooks.length === 0) {
|
||||||
spinner.fail('There are no webhooks on the project');
|
spinner.fail('There are no webhooks on the project');
|
||||||
return [];
|
return [];
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ export default class WebhookList extends EasCommand {
|
|||||||
|
|
||||||
static override contextDefinition = {
|
static override contextDefinition = {
|
||||||
...this.ContextOptions.ProjectConfig,
|
...this.ContextOptions.ProjectConfig,
|
||||||
|
...this.ContextOptions.LoggedIn,
|
||||||
};
|
};
|
||||||
|
|
||||||
async runAsync(): Promise<void> {
|
async runAsync(): Promise<void> {
|
||||||
@@ -29,15 +30,20 @@ export default class WebhookList extends EasCommand {
|
|||||||
} = await this.parse(WebhookList);
|
} = await this.parse(WebhookList);
|
||||||
const {
|
const {
|
||||||
projectConfig: { projectId },
|
projectConfig: { projectId },
|
||||||
|
loggedIn: { graphqlClient },
|
||||||
} = await this.getContextAsync(WebhookList, {
|
} = await this.getContextAsync(WebhookList, {
|
||||||
nonInteractive: true,
|
nonInteractive: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
const projectDisplayName = await getDisplayNameForProjectIdAsync(projectId);
|
const projectDisplayName = await getDisplayNameForProjectIdAsync(graphqlClient, projectId);
|
||||||
|
|
||||||
const spinner = ora(`Fetching the list of webhook on project ${projectDisplayName}`).start();
|
const spinner = ora(`Fetching the list of webhook on project ${projectDisplayName}`).start();
|
||||||
try {
|
try {
|
||||||
const webhooks = await WebhookQuery.byAppIdAsync(projectId, event && { event });
|
const webhooks = await WebhookQuery.byAppIdAsync(
|
||||||
|
graphqlClient,
|
||||||
|
projectId,
|
||||||
|
event && { event }
|
||||||
|
);
|
||||||
if (webhooks.length === 0) {
|
if (webhooks.length === 0) {
|
||||||
spinner.fail(`There are no webhooks on project ${projectDisplayName}`);
|
spinner.fail(`There are no webhooks on project ${projectDisplayName}`);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -31,12 +31,19 @@ export default class WebhookUpdate extends EasCommand {
|
|||||||
...EASNonInteractiveFlag,
|
...EASNonInteractiveFlag,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static override contextDefinition = {
|
||||||
|
...this.ContextOptions.LoggedIn,
|
||||||
|
};
|
||||||
|
|
||||||
async runAsync(): Promise<void> {
|
async runAsync(): Promise<void> {
|
||||||
const { flags } = await this.parse(WebhookUpdate);
|
const { flags } = await this.parse(WebhookUpdate);
|
||||||
|
const {
|
||||||
|
loggedIn: { graphqlClient },
|
||||||
|
} = await this.getContextAsync(WebhookUpdate, { nonInteractive: flags['non-interactive'] });
|
||||||
|
|
||||||
const webhookId = flags.id;
|
const webhookId = flags.id;
|
||||||
|
|
||||||
const webhook = await WebhookQuery.byIdAsync(webhookId);
|
const webhook = await WebhookQuery.byIdAsync(graphqlClient, webhookId);
|
||||||
const webhookInputParams = await prepareInputParamsAsync(
|
const webhookInputParams = await prepareInputParamsAsync(
|
||||||
pick(flags, ['event', 'url', 'secret', 'non-interactive']),
|
pick(flags, ['event', 'url', 'secret', 'non-interactive']),
|
||||||
webhook
|
webhook
|
||||||
@@ -44,7 +51,7 @@ export default class WebhookUpdate extends EasCommand {
|
|||||||
|
|
||||||
const spinner = ora('Updating a webhook').start();
|
const spinner = ora('Updating a webhook').start();
|
||||||
try {
|
try {
|
||||||
await WebhookMutation.updateWebhookAsync(webhookId, webhookInputParams);
|
await WebhookMutation.updateWebhookAsync(graphqlClient, webhookId, webhookInputParams);
|
||||||
spinner.succeed('Successfully updated a webhook');
|
spinner.succeed('Successfully updated a webhook');
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
spinner.fail('Failed to update a webhook');
|
spinner.fail('Failed to update a webhook');
|
||||||
|
|||||||
@@ -15,14 +15,20 @@ export default class WebhookView extends EasCommand {
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
static override contextDefinition = { ...this.ContextOptions.LoggedIn };
|
||||||
|
|
||||||
async runAsync(): Promise<void> {
|
async runAsync(): Promise<void> {
|
||||||
const {
|
const {
|
||||||
args: { ID: webhookId },
|
args: { ID: webhookId },
|
||||||
} = await this.parse(WebhookView);
|
} = await this.parse(WebhookView);
|
||||||
|
|
||||||
|
const {
|
||||||
|
loggedIn: { graphqlClient },
|
||||||
|
} = await this.getContextAsync(WebhookView, { nonInteractive: true });
|
||||||
|
|
||||||
const spinner = ora(`Fetching the webhook details for ID ${webhookId}`).start();
|
const spinner = ora(`Fetching the webhook details for ID ${webhookId}`).start();
|
||||||
try {
|
try {
|
||||||
const webhook = await WebhookQuery.byIdAsync(webhookId);
|
const webhook = await WebhookQuery.byIdAsync(graphqlClient, webhookId);
|
||||||
spinner.succeed(`Found the webhook details`);
|
spinner.succeed(`Found the webhook details`);
|
||||||
Log.log(`\n${formatWebhook(webhook)}`);
|
Log.log(`\n${formatWebhook(webhook)}`);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
@@ -14,8 +14,12 @@ export class AssignFcm {
|
|||||||
fcm: AndroidFcmFragment
|
fcm: AndroidFcmFragment
|
||||||
): Promise<CommonAndroidAppCredentialsFragment> {
|
): Promise<CommonAndroidAppCredentialsFragment> {
|
||||||
const appCredentials =
|
const appCredentials =
|
||||||
await ctx.android.createOrGetExistingAndroidAppCredentialsWithBuildCredentialsAsync(this.app);
|
await ctx.android.createOrGetExistingAndroidAppCredentialsWithBuildCredentialsAsync(
|
||||||
|
ctx.graphqlClient,
|
||||||
|
this.app
|
||||||
|
);
|
||||||
const updatedAppCredentials = await ctx.android.updateAndroidAppCredentialsAsync(
|
const updatedAppCredentials = await ctx.android.updateAndroidAppCredentialsAsync(
|
||||||
|
ctx.graphqlClient,
|
||||||
appCredentials,
|
appCredentials,
|
||||||
{
|
{
|
||||||
androidFcmId: fcm.id,
|
androidFcmId: fcm.id,
|
||||||
|
|||||||
@@ -14,8 +14,12 @@ export class AssignGoogleServiceAccountKey {
|
|||||||
googleServiceAccountKey: GoogleServiceAccountKeyFragment
|
googleServiceAccountKey: GoogleServiceAccountKeyFragment
|
||||||
): Promise<CommonAndroidAppCredentialsFragment> {
|
): Promise<CommonAndroidAppCredentialsFragment> {
|
||||||
const appCredentials =
|
const appCredentials =
|
||||||
await ctx.android.createOrGetExistingAndroidAppCredentialsWithBuildCredentialsAsync(this.app);
|
await ctx.android.createOrGetExistingAndroidAppCredentialsWithBuildCredentialsAsync(
|
||||||
|
ctx.graphqlClient,
|
||||||
|
this.app
|
||||||
|
);
|
||||||
const updatedAppCredentials = await ctx.android.updateAndroidAppCredentialsAsync(
|
const updatedAppCredentials = await ctx.android.updateAndroidAppCredentialsAsync(
|
||||||
|
ctx.graphqlClient,
|
||||||
appCredentials,
|
appCredentials,
|
||||||
{
|
{
|
||||||
googleServiceAccountKeyForSubmissionsId: googleServiceAccountKey.id,
|
googleServiceAccountKeyForSubmissionsId: googleServiceAccountKey.id,
|
||||||
|
|||||||
@@ -21,13 +21,16 @@ export async function canCopyLegacyCredentialsAsync(
|
|||||||
ctx: CredentialsContext,
|
ctx: CredentialsContext,
|
||||||
app: AppLookupParams
|
app: AppLookupParams
|
||||||
): Promise<boolean> {
|
): Promise<boolean> {
|
||||||
const appCredentials = await ctx.android.getAndroidAppCredentialsWithCommonFieldsAsync(app);
|
const appCredentials = await ctx.android.getAndroidAppCredentialsWithCommonFieldsAsync(
|
||||||
|
ctx.graphqlClient,
|
||||||
|
app
|
||||||
|
);
|
||||||
if (appCredentials) {
|
if (appCredentials) {
|
||||||
return false; // modern credentials already exist
|
return false; // modern credentials already exist
|
||||||
}
|
}
|
||||||
|
|
||||||
const legacyAppCredentials =
|
const legacyAppCredentials =
|
||||||
await ctx.android.getLegacyAndroidAppCredentialsWithCommonFieldsAsync(app);
|
await ctx.android.getLegacyAndroidAppCredentialsWithCommonFieldsAsync(ctx.graphqlClient, app);
|
||||||
return !!legacyAppCredentials; // user has some legacy credentials
|
return !!legacyAppCredentials; // user has some legacy credentials
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,30 +47,37 @@ export async function promptUserAndCopyLegacyCredentialsAsync(
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const legacyAppCredentials =
|
const legacyAppCredentials =
|
||||||
await ctx.android.getLegacyAndroidAppCredentialsWithCommonFieldsAsync(app);
|
await ctx.android.getLegacyAndroidAppCredentialsWithCommonFieldsAsync(ctx.graphqlClient, app);
|
||||||
if (!legacyAppCredentials) {
|
if (!legacyAppCredentials) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const appCredentials =
|
const appCredentials =
|
||||||
await ctx.android.createOrGetExistingAndroidAppCredentialsWithBuildCredentialsAsync(app);
|
await ctx.android.createOrGetExistingAndroidAppCredentialsWithBuildCredentialsAsync(
|
||||||
|
ctx.graphqlClient,
|
||||||
|
app
|
||||||
|
);
|
||||||
const legacyFcm = legacyAppCredentials.androidFcm;
|
const legacyFcm = legacyAppCredentials.androidFcm;
|
||||||
if (legacyFcm) {
|
if (legacyFcm) {
|
||||||
const clonedFcm = await ctx.android.createFcmAsync(
|
const clonedFcm = await ctx.android.createFcmAsync(
|
||||||
|
ctx.graphqlClient,
|
||||||
app.account,
|
app.account,
|
||||||
legacyFcm.credential,
|
legacyFcm.credential,
|
||||||
legacyFcm.version
|
legacyFcm.version
|
||||||
);
|
);
|
||||||
await ctx.android.updateAndroidAppCredentialsAsync(appCredentials, {
|
await ctx.android.updateAndroidAppCredentialsAsync(ctx.graphqlClient, appCredentials, {
|
||||||
androidFcmId: clonedFcm.id,
|
androidFcmId: clonedFcm.id,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const legacyBuildCredentials = await ctx.android.getLegacyAndroidAppBuildCredentialsAsync(app);
|
const legacyBuildCredentials = await ctx.android.getLegacyAndroidAppBuildCredentialsAsync(
|
||||||
|
ctx.graphqlClient,
|
||||||
|
app
|
||||||
|
);
|
||||||
const legacyKeystore = legacyBuildCredentials?.androidKeystore ?? null;
|
const legacyKeystore = legacyBuildCredentials?.androidKeystore ?? null;
|
||||||
|
|
||||||
if (legacyKeystore) {
|
if (legacyKeystore) {
|
||||||
const clonedKeystore = await ctx.android.createKeystoreAsync(app.account, {
|
const clonedKeystore = await ctx.android.createKeystoreAsync(ctx.graphqlClient, app.account, {
|
||||||
keystore: legacyKeystore.keystore,
|
keystore: legacyKeystore.keystore,
|
||||||
keystorePassword: legacyKeystore.keystorePassword,
|
keystorePassword: legacyKeystore.keystorePassword,
|
||||||
keyAlias: legacyKeystore.keyAlias,
|
keyAlias: legacyKeystore.keyAlias,
|
||||||
@@ -93,7 +103,7 @@ export async function getAppLookupParamsFromContextAsync(
|
|||||||
ctx.ensureProjectContext();
|
ctx.ensureProjectContext();
|
||||||
const projectName = ctx.exp.slug;
|
const projectName = ctx.exp.slug;
|
||||||
const projectId = ctx.projectId;
|
const projectId = ctx.projectId;
|
||||||
const account = await getOwnerAccountForProjectIdAsync(projectId);
|
const account = await getOwnerAccountForProjectIdAsync(ctx.graphqlClient, projectId);
|
||||||
|
|
||||||
const androidApplicationIdentifier = await getApplicationIdAsync(
|
const androidApplicationIdentifier = await getApplicationIdAsync(
|
||||||
ctx.projectDir,
|
ctx.projectDir,
|
||||||
@@ -125,18 +135,23 @@ export async function createOrUpdateDefaultAndroidAppBuildCredentialsAsync(
|
|||||||
'createOrUpdateDefaultAndroidAppBuildCredentialsAsync must be run in interactive mode'
|
'createOrUpdateDefaultAndroidAppBuildCredentialsAsync must be run in interactive mode'
|
||||||
);
|
);
|
||||||
const existingDefaultBuildCredentials =
|
const existingDefaultBuildCredentials =
|
||||||
await ctx.android.getDefaultAndroidAppBuildCredentialsAsync(appLookupParams);
|
await ctx.android.getDefaultAndroidAppBuildCredentialsAsync(ctx.graphqlClient, appLookupParams);
|
||||||
if (existingDefaultBuildCredentials) {
|
if (existingDefaultBuildCredentials) {
|
||||||
return await ctx.android.updateAndroidAppBuildCredentialsAsync(
|
return await ctx.android.updateAndroidAppBuildCredentialsAsync(
|
||||||
|
ctx.graphqlClient,
|
||||||
existingDefaultBuildCredentials,
|
existingDefaultBuildCredentials,
|
||||||
{ androidKeystoreId }
|
{ androidKeystoreId }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return await ctx.android.createAndroidAppBuildCredentialsAsync(appLookupParams, {
|
return await ctx.android.createAndroidAppBuildCredentialsAsync(
|
||||||
name: generateRandomName(),
|
ctx.graphqlClient,
|
||||||
isDefault: true,
|
appLookupParams,
|
||||||
androidKeystoreId,
|
{
|
||||||
});
|
name: generateRandomName(),
|
||||||
|
isDefault: true,
|
||||||
|
androidKeystoreId,
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function promptForNameAsync(): Promise<string> {
|
export async function promptForNameAsync(): Promise<string> {
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ export class CreateFcm {
|
|||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
const fcmFragment = await ctx.android.createFcmAsync(
|
const fcmFragment = await ctx.android.createFcmAsync(
|
||||||
|
ctx.graphqlClient,
|
||||||
this.account,
|
this.account,
|
||||||
fcmApiKey,
|
fcmApiKey,
|
||||||
AndroidFcmVersion.Legacy
|
AndroidFcmVersion.Legacy
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ export class CreateGoogleServiceAccountKey {
|
|||||||
}
|
}
|
||||||
const jsonKeyObject = await this.provideAsync(ctx);
|
const jsonKeyObject = await this.provideAsync(ctx);
|
||||||
const gsaKeyFragment = await ctx.android.createGoogleServiceAccountKeyAsync(
|
const gsaKeyFragment = await ctx.android.createGoogleServiceAccountKeyAsync(
|
||||||
|
ctx.graphqlClient,
|
||||||
this.account,
|
this.account,
|
||||||
jsonKeyObject
|
jsonKeyObject
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { ExpoGraphqlClient } from '../../../commandUtils/context/contextUtils/createGraphqlClient';
|
||||||
import { AccountFragment, AndroidKeystoreFragment } from '../../../graphql/generated';
|
import { AccountFragment, AndroidKeystoreFragment } from '../../../graphql/generated';
|
||||||
import Log from '../../../log';
|
import Log from '../../../log';
|
||||||
import { CredentialsContext } from '../../context';
|
import { CredentialsContext } from '../../context';
|
||||||
@@ -15,19 +16,26 @@ export class CreateKeystore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const projectId = ctx.projectId;
|
const projectId = ctx.projectId;
|
||||||
const keystore = await this.provideOrGenerateAsync(projectId);
|
const keystore = await this.provideOrGenerateAsync(ctx.graphqlClient, projectId);
|
||||||
const keystoreFragment = await ctx.android.createKeystoreAsync(this.account, keystore);
|
const keystoreFragment = await ctx.android.createKeystoreAsync(
|
||||||
|
ctx.graphqlClient,
|
||||||
|
this.account,
|
||||||
|
keystore
|
||||||
|
);
|
||||||
Log.succeed('Created keystore');
|
Log.succeed('Created keystore');
|
||||||
return keystoreFragment;
|
return keystoreFragment;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async provideOrGenerateAsync(projectId: string): Promise<KeystoreWithType> {
|
private async provideOrGenerateAsync(
|
||||||
|
graphqlClient: ExpoGraphqlClient,
|
||||||
|
projectId: string
|
||||||
|
): Promise<KeystoreWithType> {
|
||||||
const providedKeystore = await askForUserProvidedAsync(keystoreSchema);
|
const providedKeystore = await askForUserProvidedAsync(keystoreSchema);
|
||||||
if (providedKeystore) {
|
if (providedKeystore) {
|
||||||
const providedKeystoreWithType = getKeystoreWithType(providedKeystore);
|
const providedKeystoreWithType = getKeystoreWithType(providedKeystore);
|
||||||
validateKeystore(providedKeystoreWithType);
|
validateKeystore(providedKeystoreWithType);
|
||||||
return providedKeystoreWithType;
|
return providedKeystoreWithType;
|
||||||
}
|
}
|
||||||
return await generateRandomKeystoreAsync(projectId);
|
return await generateRandomKeystoreAsync(graphqlClient, projectId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -13,6 +13,7 @@ export class RemoveFcm {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
const appCredentials = await ctx.android.getAndroidAppCredentialsWithCommonFieldsAsync(
|
const appCredentials = await ctx.android.getAndroidAppCredentialsWithCommonFieldsAsync(
|
||||||
|
ctx.graphqlClient,
|
||||||
this.app
|
this.app
|
||||||
);
|
);
|
||||||
const fcm = appCredentials?.androidFcm;
|
const fcm = appCredentials?.androidFcm;
|
||||||
@@ -33,7 +34,7 @@ export class RemoveFcm {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await ctx.android.deleteFcmAsync(fcm);
|
await ctx.android.deleteFcmAsync(ctx.graphqlClient, fcm);
|
||||||
Log.succeed('FCM API Key removed');
|
Log.succeed('FCM API Key removed');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -15,6 +15,7 @@ export class SelectAndRemoveGoogleServiceAccountKey {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const gsaKeyFragments = await ctx.android.getGoogleServiceAccountKeysForAccountAsync(
|
const gsaKeyFragments = await ctx.android.getGoogleServiceAccountKeysForAccountAsync(
|
||||||
|
ctx.graphqlClient,
|
||||||
this.account
|
this.account
|
||||||
);
|
);
|
||||||
if (gsaKeyFragments.length === 0) {
|
if (gsaKeyFragments.length === 0) {
|
||||||
@@ -47,6 +48,9 @@ export class RemoveGoogleServiceAccountKey {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Log.log('Removing Google Service Account Key.');
|
Log.log('Removing Google Service Account Key.');
|
||||||
await ctx.android.deleteGoogleServiceAccountKeyAsync(this.googleServiceAccountKey);
|
await ctx.android.deleteGoogleServiceAccountKeyAsync(
|
||||||
|
ctx.graphqlClient,
|
||||||
|
this.googleServiceAccountKey
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -37,7 +37,7 @@ export class RemoveKeystore {
|
|||||||
}
|
}
|
||||||
await new BackupKeystore(this.app).runAsync(ctx, buildCredentials);
|
await new BackupKeystore(this.app).runAsync(ctx, buildCredentials);
|
||||||
|
|
||||||
await ctx.android.deleteKeystoreAsync(keystore);
|
await ctx.android.deleteKeystoreAsync(ctx.graphqlClient, keystore);
|
||||||
Log.succeed('Keystore removed');
|
Log.succeed('Keystore removed');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -68,9 +68,14 @@ export class SetUpBuildCredentials {
|
|||||||
keystore: AndroidKeystoreFragment;
|
keystore: AndroidKeystoreFragment;
|
||||||
}): Promise<AndroidAppBuildCredentialsFragment> {
|
}): Promise<AndroidAppBuildCredentialsFragment> {
|
||||||
if (name) {
|
if (name) {
|
||||||
return await ctx.android.createOrUpdateAndroidAppBuildCredentialsByNameAsync(app, name, {
|
return await ctx.android.createOrUpdateAndroidAppBuildCredentialsByNameAsync(
|
||||||
androidKeystoreId: keystore.id,
|
ctx.graphqlClient,
|
||||||
});
|
app,
|
||||||
|
name,
|
||||||
|
{
|
||||||
|
androidKeystoreId: keystore.id,
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return await createOrUpdateDefaultAndroidAppBuildCredentialsAsync(ctx, app, {
|
return await createOrUpdateDefaultAndroidAppBuildCredentialsAsync(ctx, app, {
|
||||||
androidKeystoreId: keystore.id,
|
androidKeystoreId: keystore.id,
|
||||||
@@ -91,6 +96,7 @@ export class SetUpBuildCredentials {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const defaultBuildCredentials = await ctx.android.getDefaultAndroidAppBuildCredentialsAsync(
|
const defaultBuildCredentials = await ctx.android.getDefaultAndroidAppBuildCredentialsAsync(
|
||||||
|
ctx.graphqlClient,
|
||||||
app
|
app
|
||||||
);
|
);
|
||||||
const defaultKeystore = defaultBuildCredentials?.androidKeystore ?? null;
|
const defaultKeystore = defaultBuildCredentials?.androidKeystore ?? null;
|
||||||
@@ -113,6 +119,7 @@ export class SetUpBuildCredentials {
|
|||||||
name: string;
|
name: string;
|
||||||
}): Promise<AndroidAppBuildCredentialsFragment | null> {
|
}): Promise<AndroidAppBuildCredentialsFragment | null> {
|
||||||
const maybeBuildCredentials = await ctx.android.getAndroidAppBuildCredentialsByNameAsync(
|
const maybeBuildCredentials = await ctx.android.getAndroidAppBuildCredentialsByNameAsync(
|
||||||
|
ctx.graphqlClient,
|
||||||
app,
|
app,
|
||||||
name
|
name
|
||||||
);
|
);
|
||||||
|
|||||||
+10
-4
@@ -62,6 +62,7 @@ export class SetUpBuildCredentialsFromCredentialsJson {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
const keystoreFragment = await ctx.android.createKeystoreAsync(
|
const keystoreFragment = await ctx.android.createKeystoreAsync(
|
||||||
|
ctx.graphqlClient,
|
||||||
this.app.account,
|
this.app.account,
|
||||||
providedKeystoreWithType
|
providedKeystoreWithType
|
||||||
);
|
);
|
||||||
@@ -70,12 +71,17 @@ export class SetUpBuildCredentialsFromCredentialsJson {
|
|||||||
selectBuildCredentialsResult.resultType ===
|
selectBuildCredentialsResult.resultType ===
|
||||||
SelectAndroidBuildCredentialsResultType.CREATE_REQUEST
|
SelectAndroidBuildCredentialsResultType.CREATE_REQUEST
|
||||||
) {
|
) {
|
||||||
buildCredentials = await ctx.android.createAndroidAppBuildCredentialsAsync(this.app, {
|
buildCredentials = await ctx.android.createAndroidAppBuildCredentialsAsync(
|
||||||
...selectBuildCredentialsResult.result,
|
ctx.graphqlClient,
|
||||||
androidKeystoreId: keystoreFragment.id,
|
this.app,
|
||||||
});
|
{
|
||||||
|
...selectBuildCredentialsResult.result,
|
||||||
|
androidKeystoreId: keystoreFragment.id,
|
||||||
|
}
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
buildCredentials = await ctx.android.updateAndroidAppBuildCredentialsAsync(
|
buildCredentials = await ctx.android.updateAndroidAppBuildCredentialsAsync(
|
||||||
|
ctx.graphqlClient,
|
||||||
selectBuildCredentialsResult.result,
|
selectBuildCredentialsResult.result,
|
||||||
{
|
{
|
||||||
androidKeystoreId: keystoreFragment.id,
|
androidKeystoreId: keystoreFragment.id,
|
||||||
|
|||||||
@@ -21,7 +21,10 @@ export class SetUpGoogleServiceAccountKey {
|
|||||||
if (isKeySetup) {
|
if (isKeySetup) {
|
||||||
Log.succeed('Google Service Account Key already set up.');
|
Log.succeed('Google Service Account Key already set up.');
|
||||||
return nullthrows(
|
return nullthrows(
|
||||||
await ctx.android.getAndroidAppCredentialsWithCommonFieldsAsync(this.app),
|
await ctx.android.getAndroidAppCredentialsWithCommonFieldsAsync(
|
||||||
|
ctx.graphqlClient,
|
||||||
|
this.app
|
||||||
|
),
|
||||||
'androidAppCredentials cannot be null if google service account key is already set up'
|
'androidAppCredentials cannot be null if google service account key is already set up'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -32,6 +35,7 @@ export class SetUpGoogleServiceAccountKey {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const keysForAccount = await ctx.android.getGoogleServiceAccountKeysForAccountAsync(
|
const keysForAccount = await ctx.android.getGoogleServiceAccountKeysForAccountAsync(
|
||||||
|
ctx.graphqlClient,
|
||||||
this.app.account
|
this.app.account
|
||||||
);
|
);
|
||||||
let googleServiceAccountKey = null;
|
let googleServiceAccountKey = null;
|
||||||
@@ -47,6 +51,7 @@ export class SetUpGoogleServiceAccountKey {
|
|||||||
|
|
||||||
private async isGoogleServiceAccountKeySetupAsync(ctx: CredentialsContext): Promise<boolean> {
|
private async isGoogleServiceAccountKeySetupAsync(ctx: CredentialsContext): Promise<boolean> {
|
||||||
const appCredentials = await ctx.android.getAndroidAppCredentialsWithCommonFieldsAsync(
|
const appCredentials = await ctx.android.getAndroidAppCredentialsWithCommonFieldsAsync(
|
||||||
|
ctx.graphqlClient,
|
||||||
this.app
|
this.app
|
||||||
);
|
);
|
||||||
return !!appCredentials?.googleServiceAccountKeyForSubmissions;
|
return !!appCredentials?.googleServiceAccountKeyForSubmissions;
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ export class UseExistingGoogleServiceAccountKey {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
const gsaKeyFragments = await ctx.android.getGoogleServiceAccountKeysForAccountAsync(
|
const gsaKeyFragments = await ctx.android.getGoogleServiceAccountKeysForAccountAsync(
|
||||||
|
ctx.graphqlClient,
|
||||||
this.account
|
this.account
|
||||||
);
|
);
|
||||||
if (gsaKeyFragments.length === 0) {
|
if (gsaKeyFragments.length === 0) {
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ describe('CreateKeystore', () => {
|
|||||||
|
|
||||||
// expect keystore to be created on expo servers
|
// expect keystore to be created on expo servers
|
||||||
expect(ctx.android.createKeystoreAsync).toHaveBeenCalledWith(
|
expect(ctx.android.createKeystoreAsync).toHaveBeenCalledWith(
|
||||||
|
ctx.graphqlClient,
|
||||||
appLookupParams.account,
|
appLookupParams.account,
|
||||||
expect.objectContaining(testKeystore)
|
expect.objectContaining(testKeystore)
|
||||||
);
|
);
|
||||||
|
|||||||
+22
-14
@@ -72,13 +72,17 @@ describe(SetUpBuildCredentialsFromCredentialsJson, () => {
|
|||||||
|
|
||||||
// expect keystore to be created with credentials.json content
|
// expect keystore to be created with credentials.json content
|
||||||
expect(ctx.android.createKeystoreAsync).toHaveBeenCalledTimes(1);
|
expect(ctx.android.createKeystoreAsync).toHaveBeenCalledTimes(1);
|
||||||
expect(ctx.android.createKeystoreAsync).toBeCalledWith(appLookupParams.account, {
|
expect(ctx.android.createKeystoreAsync).toBeCalledWith(
|
||||||
keystorePassword: testJksAndroidKeystoreFragment.keystorePassword,
|
ctx.graphqlClient,
|
||||||
keyAlias: testJksAndroidKeystoreFragment.keyAlias,
|
appLookupParams.account,
|
||||||
keyPassword: testJksAndroidKeystoreFragment.keyPassword,
|
{
|
||||||
keystore: Buffer.from('some-binary-content').toString('base64'),
|
keystorePassword: testJksAndroidKeystoreFragment.keystorePassword,
|
||||||
type: AndroidKeystoreType.Unknown,
|
keyAlias: testJksAndroidKeystoreFragment.keyAlias,
|
||||||
});
|
keyPassword: testJksAndroidKeystoreFragment.keyPassword,
|
||||||
|
keystore: Buffer.from('some-binary-content').toString('base64'),
|
||||||
|
type: AndroidKeystoreType.Unknown,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
// expect new build credentials to be created
|
// expect new build credentials to be created
|
||||||
expect(ctx.android.createAndroidAppBuildCredentialsAsync).toHaveBeenCalledTimes(1);
|
expect(ctx.android.createAndroidAppBuildCredentialsAsync).toHaveBeenCalledTimes(1);
|
||||||
@@ -122,13 +126,17 @@ describe(SetUpBuildCredentialsFromCredentialsJson, () => {
|
|||||||
|
|
||||||
// expect keystore to be created with credentials.json content
|
// expect keystore to be created with credentials.json content
|
||||||
expect(ctx.android.createKeystoreAsync).toHaveBeenCalledTimes(1);
|
expect(ctx.android.createKeystoreAsync).toHaveBeenCalledTimes(1);
|
||||||
expect(ctx.android.createKeystoreAsync).toBeCalledWith(appLookupParams.account, {
|
expect(ctx.android.createKeystoreAsync).toBeCalledWith(
|
||||||
keystorePassword: testJksAndroidKeystoreFragment.keystorePassword,
|
ctx.graphqlClient,
|
||||||
keyAlias: testJksAndroidKeystoreFragment.keyAlias,
|
appLookupParams.account,
|
||||||
keyPassword: testJksAndroidKeystoreFragment.keyPassword,
|
{
|
||||||
keystore: Buffer.from('some-binary-content').toString('base64'),
|
keystorePassword: testJksAndroidKeystoreFragment.keystorePassword,
|
||||||
type: AndroidKeystoreType.Unknown,
|
keyAlias: testJksAndroidKeystoreFragment.keyAlias,
|
||||||
});
|
keyPassword: testJksAndroidKeystoreFragment.keyPassword,
|
||||||
|
keystore: Buffer.from('some-binary-content').toString('base64'),
|
||||||
|
type: AndroidKeystoreType.Unknown,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
// expect existing build credentials to be updated
|
// expect existing build credentials to be updated
|
||||||
expect(ctx.android.updateAndroidAppBuildCredentialsAsync).toHaveBeenCalledTimes(1);
|
expect(ctx.android.updateAndroidAppBuildCredentialsAsync).toHaveBeenCalledTimes(1);
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { ExpoGraphqlClient } from '../../../commandUtils/context/contextUtils/createGraphqlClient';
|
||||||
import {
|
import {
|
||||||
AccountFragment,
|
AccountFragment,
|
||||||
AndroidAppBuildCredentialsFragment,
|
AndroidAppBuildCredentialsFragment,
|
||||||
@@ -25,11 +26,13 @@ export interface AppLookupParams {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function getAndroidAppCredentialsWithCommonFieldsAsync(
|
export async function getAndroidAppCredentialsWithCommonFieldsAsync(
|
||||||
|
graphqlClient: ExpoGraphqlClient,
|
||||||
appLookupParams: AppLookupParams
|
appLookupParams: AppLookupParams
|
||||||
): Promise<CommonAndroidAppCredentialsFragment | null> {
|
): Promise<CommonAndroidAppCredentialsFragment | null> {
|
||||||
const { androidApplicationIdentifier } = appLookupParams;
|
const { androidApplicationIdentifier } = appLookupParams;
|
||||||
const projectFullName = formatProjectFullName(appLookupParams);
|
const projectFullName = formatProjectFullName(appLookupParams);
|
||||||
return await AndroidAppCredentialsQuery.withCommonFieldsByApplicationIdentifierAsync(
|
return await AndroidAppCredentialsQuery.withCommonFieldsByApplicationIdentifierAsync(
|
||||||
|
graphqlClient,
|
||||||
projectFullName,
|
projectFullName,
|
||||||
{
|
{
|
||||||
androidApplicationIdentifier,
|
androidApplicationIdentifier,
|
||||||
@@ -39,18 +42,24 @@ export async function getAndroidAppCredentialsWithCommonFieldsAsync(
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function getAndroidAppBuildCredentialsListAsync(
|
export async function getAndroidAppBuildCredentialsListAsync(
|
||||||
|
graphqlClient: ExpoGraphqlClient,
|
||||||
appLookupParams: AppLookupParams
|
appLookupParams: AppLookupParams
|
||||||
): Promise<AndroidAppBuildCredentialsFragment[]> {
|
): Promise<AndroidAppBuildCredentialsFragment[]> {
|
||||||
const appCredentials = await getAndroidAppCredentialsWithCommonFieldsAsync(appLookupParams);
|
const appCredentials = await getAndroidAppCredentialsWithCommonFieldsAsync(
|
||||||
|
graphqlClient,
|
||||||
|
appLookupParams
|
||||||
|
);
|
||||||
return appCredentials?.androidAppBuildCredentialsList ?? [];
|
return appCredentials?.androidAppBuildCredentialsList ?? [];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* There is at most one set of legacy android app credentials associated with an Expo App */
|
/* There is at most one set of legacy android app credentials associated with an Expo App */
|
||||||
export async function getLegacyAndroidAppCredentialsWithCommonFieldsAsync(
|
export async function getLegacyAndroidAppCredentialsWithCommonFieldsAsync(
|
||||||
|
graphqlClient: ExpoGraphqlClient,
|
||||||
appLookupParams: AppLookupParams
|
appLookupParams: AppLookupParams
|
||||||
): Promise<CommonAndroidAppCredentialsFragment | null> {
|
): Promise<CommonAndroidAppCredentialsFragment | null> {
|
||||||
const projectFullName = formatProjectFullName(appLookupParams);
|
const projectFullName = formatProjectFullName(appLookupParams);
|
||||||
return await AndroidAppCredentialsQuery.withCommonFieldsByApplicationIdentifierAsync(
|
return await AndroidAppCredentialsQuery.withCommonFieldsByApplicationIdentifierAsync(
|
||||||
|
graphqlClient,
|
||||||
projectFullName,
|
projectFullName,
|
||||||
{
|
{
|
||||||
legacyOnly: true,
|
legacyOnly: true,
|
||||||
@@ -60,25 +69,30 @@ export async function getLegacyAndroidAppCredentialsWithCommonFieldsAsync(
|
|||||||
|
|
||||||
/* There is at most one set of legacy android app build credentials associated with an Expo App */
|
/* There is at most one set of legacy android app build credentials associated with an Expo App */
|
||||||
export async function getLegacyAndroidAppBuildCredentialsAsync(
|
export async function getLegacyAndroidAppBuildCredentialsAsync(
|
||||||
|
graphqlClient: ExpoGraphqlClient,
|
||||||
appLookupParams: AppLookupParams
|
appLookupParams: AppLookupParams
|
||||||
): Promise<AndroidAppBuildCredentialsFragment | null> {
|
): Promise<AndroidAppBuildCredentialsFragment | null> {
|
||||||
const legacyAppCredentials = await getLegacyAndroidAppCredentialsWithCommonFieldsAsync(
|
const legacyAppCredentials = await getLegacyAndroidAppCredentialsWithCommonFieldsAsync(
|
||||||
|
graphqlClient,
|
||||||
appLookupParams
|
appLookupParams
|
||||||
);
|
);
|
||||||
return legacyAppCredentials?.androidAppBuildCredentialsList[0] ?? null;
|
return legacyAppCredentials?.androidAppBuildCredentialsList[0] ?? null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function createOrGetExistingAndroidAppCredentialsWithBuildCredentialsAsync(
|
export async function createOrGetExistingAndroidAppCredentialsWithBuildCredentialsAsync(
|
||||||
|
graphqlClient: ExpoGraphqlClient,
|
||||||
appLookupParams: AppLookupParams
|
appLookupParams: AppLookupParams
|
||||||
): Promise<CommonAndroidAppCredentialsFragment> {
|
): Promise<CommonAndroidAppCredentialsFragment> {
|
||||||
const maybeAndroidAppCredentials = await getAndroidAppCredentialsWithCommonFieldsAsync(
|
const maybeAndroidAppCredentials = await getAndroidAppCredentialsWithCommonFieldsAsync(
|
||||||
|
graphqlClient,
|
||||||
appLookupParams
|
appLookupParams
|
||||||
);
|
);
|
||||||
if (maybeAndroidAppCredentials) {
|
if (maybeAndroidAppCredentials) {
|
||||||
return maybeAndroidAppCredentials;
|
return maybeAndroidAppCredentials;
|
||||||
} else {
|
} else {
|
||||||
const app = await getAppAsync(appLookupParams);
|
const app = await getAppAsync(graphqlClient, appLookupParams);
|
||||||
return await AndroidAppCredentialsMutation.createAndroidAppCredentialsAsync(
|
return await AndroidAppCredentialsMutation.createAndroidAppCredentialsAsync(
|
||||||
|
graphqlClient,
|
||||||
{},
|
{},
|
||||||
app.id,
|
app.id,
|
||||||
appLookupParams.androidApplicationIdentifier
|
appLookupParams.androidApplicationIdentifier
|
||||||
@@ -87,6 +101,7 @@ export async function createOrGetExistingAndroidAppCredentialsWithBuildCredentia
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function updateAndroidAppCredentialsAsync(
|
export async function updateAndroidAppCredentialsAsync(
|
||||||
|
graphqlClient: ExpoGraphqlClient,
|
||||||
appCredentials: CommonAndroidAppCredentialsFragment,
|
appCredentials: CommonAndroidAppCredentialsFragment,
|
||||||
{
|
{
|
||||||
androidFcmId,
|
androidFcmId,
|
||||||
@@ -99,6 +114,7 @@ export async function updateAndroidAppCredentialsAsync(
|
|||||||
let updatedAppCredentials = appCredentials;
|
let updatedAppCredentials = appCredentials;
|
||||||
if (androidFcmId) {
|
if (androidFcmId) {
|
||||||
updatedAppCredentials = await AndroidAppCredentialsMutation.setFcmKeyAsync(
|
updatedAppCredentials = await AndroidAppCredentialsMutation.setFcmKeyAsync(
|
||||||
|
graphqlClient,
|
||||||
appCredentials.id,
|
appCredentials.id,
|
||||||
androidFcmId
|
androidFcmId
|
||||||
);
|
);
|
||||||
@@ -106,6 +122,7 @@ export async function updateAndroidAppCredentialsAsync(
|
|||||||
if (googleServiceAccountKeyForSubmissionsId) {
|
if (googleServiceAccountKeyForSubmissionsId) {
|
||||||
updatedAppCredentials =
|
updatedAppCredentials =
|
||||||
await AndroidAppCredentialsMutation.setGoogleServiceAccountKeyForSubmissionsAsync(
|
await AndroidAppCredentialsMutation.setGoogleServiceAccountKeyForSubmissionsAsync(
|
||||||
|
graphqlClient,
|
||||||
appCredentials.id,
|
appCredentials.id,
|
||||||
googleServiceAccountKeyForSubmissionsId
|
googleServiceAccountKeyForSubmissionsId
|
||||||
);
|
);
|
||||||
@@ -114,6 +131,7 @@ export async function updateAndroidAppCredentialsAsync(
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function updateAndroidAppBuildCredentialsAsync(
|
export async function updateAndroidAppBuildCredentialsAsync(
|
||||||
|
graphqlClient: ExpoGraphqlClient,
|
||||||
buildCredentials: AndroidAppBuildCredentialsFragment,
|
buildCredentials: AndroidAppBuildCredentialsFragment,
|
||||||
{
|
{
|
||||||
androidKeystoreId,
|
androidKeystoreId,
|
||||||
@@ -122,12 +140,14 @@ export async function updateAndroidAppBuildCredentialsAsync(
|
|||||||
}
|
}
|
||||||
): Promise<AndroidAppBuildCredentialsFragment> {
|
): Promise<AndroidAppBuildCredentialsFragment> {
|
||||||
return await AndroidAppBuildCredentialsMutation.setKeystoreAsync(
|
return await AndroidAppBuildCredentialsMutation.setKeystoreAsync(
|
||||||
|
graphqlClient,
|
||||||
buildCredentials.id,
|
buildCredentials.id,
|
||||||
androidKeystoreId
|
androidKeystoreId
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function createAndroidAppBuildCredentialsAsync(
|
export async function createAndroidAppBuildCredentialsAsync(
|
||||||
|
graphqlClient: ExpoGraphqlClient,
|
||||||
appLookupParams: AppLookupParams,
|
appLookupParams: AppLookupParams,
|
||||||
{
|
{
|
||||||
name,
|
name,
|
||||||
@@ -140,7 +160,10 @@ export async function createAndroidAppBuildCredentialsAsync(
|
|||||||
}
|
}
|
||||||
): Promise<AndroidAppBuildCredentialsFragment> {
|
): Promise<AndroidAppBuildCredentialsFragment> {
|
||||||
const androidAppCredentials =
|
const androidAppCredentials =
|
||||||
await createOrGetExistingAndroidAppCredentialsWithBuildCredentialsAsync(appLookupParams);
|
await createOrGetExistingAndroidAppCredentialsWithBuildCredentialsAsync(
|
||||||
|
graphqlClient,
|
||||||
|
appLookupParams
|
||||||
|
);
|
||||||
const buildCredentialsList = androidAppCredentials.androidAppBuildCredentialsList;
|
const buildCredentialsList = androidAppCredentials.androidAppBuildCredentialsList;
|
||||||
const existingDefaultBuildCredentials =
|
const existingDefaultBuildCredentials =
|
||||||
buildCredentialsList.find(buildCredentials => buildCredentials.isDefault) ?? null;
|
buildCredentialsList.find(buildCredentials => buildCredentials.isDefault) ?? null;
|
||||||
@@ -151,6 +174,7 @@ export async function createAndroidAppBuildCredentialsAsync(
|
|||||||
}
|
}
|
||||||
|
|
||||||
return await AndroidAppBuildCredentialsMutation.createAndroidAppBuildCredentialsAsync(
|
return await AndroidAppBuildCredentialsMutation.createAndroidAppBuildCredentialsAsync(
|
||||||
|
graphqlClient,
|
||||||
{
|
{
|
||||||
name,
|
name,
|
||||||
isDefault,
|
isDefault,
|
||||||
@@ -161,21 +185,30 @@ export async function createAndroidAppBuildCredentialsAsync(
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function getDefaultAndroidAppBuildCredentialsAsync(
|
export async function getDefaultAndroidAppBuildCredentialsAsync(
|
||||||
|
graphqlClient: ExpoGraphqlClient,
|
||||||
appLookupParams: AppLookupParams
|
appLookupParams: AppLookupParams
|
||||||
): Promise<AndroidAppBuildCredentialsFragment | null> {
|
): Promise<AndroidAppBuildCredentialsFragment | null> {
|
||||||
const buildCredentialsList = await getAndroidAppBuildCredentialsListAsync(appLookupParams);
|
const buildCredentialsList = await getAndroidAppBuildCredentialsListAsync(
|
||||||
|
graphqlClient,
|
||||||
|
appLookupParams
|
||||||
|
);
|
||||||
return buildCredentialsList.find(buildCredentials => buildCredentials.isDefault) ?? null;
|
return buildCredentialsList.find(buildCredentials => buildCredentials.isDefault) ?? null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getAndroidAppBuildCredentialsByNameAsync(
|
export async function getAndroidAppBuildCredentialsByNameAsync(
|
||||||
|
graphqlClient: ExpoGraphqlClient,
|
||||||
appLookupParams: AppLookupParams,
|
appLookupParams: AppLookupParams,
|
||||||
name: string
|
name: string
|
||||||
): Promise<AndroidAppBuildCredentialsFragment | null> {
|
): Promise<AndroidAppBuildCredentialsFragment | null> {
|
||||||
const buildCredentialsList = await getAndroidAppBuildCredentialsListAsync(appLookupParams);
|
const buildCredentialsList = await getAndroidAppBuildCredentialsListAsync(
|
||||||
|
graphqlClient,
|
||||||
|
appLookupParams
|
||||||
|
);
|
||||||
return buildCredentialsList.find(buildCredentials => buildCredentials.name === name) ?? null;
|
return buildCredentialsList.find(buildCredentials => buildCredentials.name === name) ?? null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function createOrUpdateAndroidAppBuildCredentialsByNameAsync(
|
export async function createOrUpdateAndroidAppBuildCredentialsByNameAsync(
|
||||||
|
graphqlClient: ExpoGraphqlClient,
|
||||||
appLookupParams: AppLookupParams,
|
appLookupParams: AppLookupParams,
|
||||||
name: string,
|
name: string,
|
||||||
{
|
{
|
||||||
@@ -185,18 +218,24 @@ export async function createOrUpdateAndroidAppBuildCredentialsByNameAsync(
|
|||||||
}
|
}
|
||||||
): Promise<AndroidAppBuildCredentialsFragment> {
|
): Promise<AndroidAppBuildCredentialsFragment> {
|
||||||
const existingBuildCredentialsWithName = await getAndroidAppBuildCredentialsByNameAsync(
|
const existingBuildCredentialsWithName = await getAndroidAppBuildCredentialsByNameAsync(
|
||||||
|
graphqlClient,
|
||||||
appLookupParams,
|
appLookupParams,
|
||||||
name
|
name
|
||||||
);
|
);
|
||||||
if (existingBuildCredentialsWithName) {
|
if (existingBuildCredentialsWithName) {
|
||||||
return await updateAndroidAppBuildCredentialsAsync(existingBuildCredentialsWithName, {
|
return await updateAndroidAppBuildCredentialsAsync(
|
||||||
androidKeystoreId,
|
graphqlClient,
|
||||||
});
|
existingBuildCredentialsWithName,
|
||||||
|
{
|
||||||
|
androidKeystoreId,
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
const defaultBuildCredentialsExist = !!(await getDefaultAndroidAppBuildCredentialsAsync(
|
const defaultBuildCredentialsExist = !!(await getDefaultAndroidAppBuildCredentialsAsync(
|
||||||
|
graphqlClient,
|
||||||
appLookupParams
|
appLookupParams
|
||||||
));
|
));
|
||||||
return await createAndroidAppBuildCredentialsAsync(appLookupParams, {
|
return await createAndroidAppBuildCredentialsAsync(graphqlClient, appLookupParams, {
|
||||||
name,
|
name,
|
||||||
isDefault: !defaultBuildCredentialsExist, // make default if none exist
|
isDefault: !defaultBuildCredentialsExist, // make default if none exist
|
||||||
androidKeystoreId,
|
androidKeystoreId,
|
||||||
@@ -208,10 +247,12 @@ export async function createOrUpdateDefaultIosAppBuildCredentialsAsync(): Promis
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function createKeystoreAsync(
|
export async function createKeystoreAsync(
|
||||||
|
graphqlClient: ExpoGraphqlClient,
|
||||||
account: AccountFragment,
|
account: AccountFragment,
|
||||||
keystore: KeystoreWithType
|
keystore: KeystoreWithType
|
||||||
): Promise<AndroidKeystoreFragment> {
|
): Promise<AndroidKeystoreFragment> {
|
||||||
return await AndroidKeystoreMutation.createAndroidKeystoreAsync(
|
return await AndroidKeystoreMutation.createAndroidKeystoreAsync(
|
||||||
|
graphqlClient,
|
||||||
{
|
{
|
||||||
base64EncodedKeystore: keystore.keystore,
|
base64EncodedKeystore: keystore.keystore,
|
||||||
keystorePassword: keystore.keystorePassword,
|
keystorePassword: keystore.keystorePassword,
|
||||||
@@ -223,52 +264,68 @@ export async function createKeystoreAsync(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function deleteKeystoreAsync(keystore: AndroidKeystoreFragment): Promise<void> {
|
export async function deleteKeystoreAsync(
|
||||||
return await AndroidKeystoreMutation.deleteAndroidKeystoreAsync(keystore.id);
|
graphqlClient: ExpoGraphqlClient,
|
||||||
|
keystore: AndroidKeystoreFragment
|
||||||
|
): Promise<void> {
|
||||||
|
return await AndroidKeystoreMutation.deleteAndroidKeystoreAsync(graphqlClient, keystore.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function createFcmAsync(
|
export async function createFcmAsync(
|
||||||
|
graphqlClient: ExpoGraphqlClient,
|
||||||
account: AccountFragment,
|
account: AccountFragment,
|
||||||
fcmApiKey: string,
|
fcmApiKey: string,
|
||||||
version: AndroidFcmVersion
|
version: AndroidFcmVersion
|
||||||
): Promise<AndroidFcmFragment> {
|
): Promise<AndroidFcmFragment> {
|
||||||
return await AndroidFcmMutation.createAndroidFcmAsync(
|
return await AndroidFcmMutation.createAndroidFcmAsync(
|
||||||
|
graphqlClient,
|
||||||
{ credential: fcmApiKey, version },
|
{ credential: fcmApiKey, version },
|
||||||
account.id
|
account.id
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function deleteFcmAsync(fcm: AndroidFcmFragment): Promise<void> {
|
export async function deleteFcmAsync(
|
||||||
return await AndroidFcmMutation.deleteAndroidFcmAsync(fcm.id);
|
graphqlClient: ExpoGraphqlClient,
|
||||||
|
fcm: AndroidFcmFragment
|
||||||
|
): Promise<void> {
|
||||||
|
return await AndroidFcmMutation.deleteAndroidFcmAsync(graphqlClient, fcm.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function createGoogleServiceAccountKeyAsync(
|
export async function createGoogleServiceAccountKeyAsync(
|
||||||
|
graphqlClient: ExpoGraphqlClient,
|
||||||
account: AccountFragment,
|
account: AccountFragment,
|
||||||
jsonKey: GoogleServiceAccountKey
|
jsonKey: GoogleServiceAccountKey
|
||||||
): Promise<GoogleServiceAccountKeyFragment> {
|
): Promise<GoogleServiceAccountKeyFragment> {
|
||||||
return await GoogleServiceAccountKeyMutation.createGoogleServiceAccountKeyAsync(
|
return await GoogleServiceAccountKeyMutation.createGoogleServiceAccountKeyAsync(
|
||||||
|
graphqlClient,
|
||||||
{ jsonKey },
|
{ jsonKey },
|
||||||
account.id
|
account.id
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function deleteGoogleServiceAccountKeyAsync(
|
export async function deleteGoogleServiceAccountKeyAsync(
|
||||||
|
graphqlClient: ExpoGraphqlClient,
|
||||||
googleServiceAccountKey: GoogleServiceAccountKeyFragment
|
googleServiceAccountKey: GoogleServiceAccountKeyFragment
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
return await GoogleServiceAccountKeyMutation.deleteGoogleServiceAccountKeyAsync(
|
return await GoogleServiceAccountKeyMutation.deleteGoogleServiceAccountKeyAsync(
|
||||||
|
graphqlClient,
|
||||||
googleServiceAccountKey.id
|
googleServiceAccountKey.id
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getGoogleServiceAccountKeysForAccountAsync(
|
export async function getGoogleServiceAccountKeysForAccountAsync(
|
||||||
|
graphqlClient: ExpoGraphqlClient,
|
||||||
account: AccountFragment
|
account: AccountFragment
|
||||||
): Promise<GoogleServiceAccountKeyFragment[]> {
|
): Promise<GoogleServiceAccountKeyFragment[]> {
|
||||||
return await GoogleServiceAccountKeyQuery.getAllForAccountAsync(account.name);
|
return await GoogleServiceAccountKeyQuery.getAllForAccountAsync(graphqlClient, account.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getAppAsync(appLookupParams: AppLookupParams): Promise<AppFragment> {
|
async function getAppAsync(
|
||||||
|
graphqlClient: ExpoGraphqlClient,
|
||||||
|
appLookupParams: AppLookupParams
|
||||||
|
): Promise<AppFragment> {
|
||||||
const projectFullName = formatProjectFullName(appLookupParams);
|
const projectFullName = formatProjectFullName(appLookupParams);
|
||||||
return await AppQuery.byFullNameAsync(projectFullName);
|
return await AppQuery.byFullNameAsync(graphqlClient, projectFullName);
|
||||||
}
|
}
|
||||||
|
|
||||||
export const formatProjectFullName = ({ account, projectName }: AppLookupParams): string =>
|
export const formatProjectFullName = ({ account, projectName }: AppLookupParams): string =>
|
||||||
|
|||||||
+4
-1
@@ -2,7 +2,8 @@ import assert from 'assert';
|
|||||||
import { print } from 'graphql';
|
import { print } from 'graphql';
|
||||||
import gql from 'graphql-tag';
|
import gql from 'graphql-tag';
|
||||||
|
|
||||||
import { graphqlClient, withErrorHandlingAsync } from '../../../../../graphql/client';
|
import { ExpoGraphqlClient } from '../../../../../commandUtils/context/contextUtils/createGraphqlClient';
|
||||||
|
import { withErrorHandlingAsync } from '../../../../../graphql/client';
|
||||||
import {
|
import {
|
||||||
AndroidAppBuildCredentialsFragment,
|
AndroidAppBuildCredentialsFragment,
|
||||||
AndroidAppBuildCredentialsInput,
|
AndroidAppBuildCredentialsInput,
|
||||||
@@ -17,6 +18,7 @@ export type AndroidAppBuildCredentialsMetadataInput = Omit<
|
|||||||
>;
|
>;
|
||||||
export const AndroidAppBuildCredentialsMutation = {
|
export const AndroidAppBuildCredentialsMutation = {
|
||||||
async createAndroidAppBuildCredentialsAsync(
|
async createAndroidAppBuildCredentialsAsync(
|
||||||
|
graphqlClient: ExpoGraphqlClient,
|
||||||
androidAppBuildCredentialsInput: AndroidAppBuildCredentialsInput,
|
androidAppBuildCredentialsInput: AndroidAppBuildCredentialsInput,
|
||||||
androidAppCredentialsId: string
|
androidAppCredentialsId: string
|
||||||
): Promise<AndroidAppBuildCredentialsFragment> {
|
): Promise<AndroidAppBuildCredentialsFragment> {
|
||||||
@@ -54,6 +56,7 @@ export const AndroidAppBuildCredentialsMutation = {
|
|||||||
return data.androidAppBuildCredentials.createAndroidAppBuildCredentials;
|
return data.androidAppBuildCredentials.createAndroidAppBuildCredentials;
|
||||||
},
|
},
|
||||||
async setKeystoreAsync(
|
async setKeystoreAsync(
|
||||||
|
graphqlClient: ExpoGraphqlClient,
|
||||||
androidAppBuildCredentialsId: string,
|
androidAppBuildCredentialsId: string,
|
||||||
keystoreId: string
|
keystoreId: string
|
||||||
): Promise<AndroidAppBuildCredentialsFragment> {
|
): Promise<AndroidAppBuildCredentialsFragment> {
|
||||||
|
|||||||
+5
-1
@@ -2,7 +2,8 @@ import assert from 'assert';
|
|||||||
import { print } from 'graphql';
|
import { print } from 'graphql';
|
||||||
import gql from 'graphql-tag';
|
import gql from 'graphql-tag';
|
||||||
|
|
||||||
import { graphqlClient, withErrorHandlingAsync } from '../../../../../graphql/client';
|
import { ExpoGraphqlClient } from '../../../../../commandUtils/context/contextUtils/createGraphqlClient';
|
||||||
|
import { withErrorHandlingAsync } from '../../../../../graphql/client';
|
||||||
import {
|
import {
|
||||||
CommonAndroidAppCredentialsFragment,
|
CommonAndroidAppCredentialsFragment,
|
||||||
CreateAndroidAppCredentialsMutation,
|
CreateAndroidAppCredentialsMutation,
|
||||||
@@ -13,6 +14,7 @@ import { CommonAndroidAppCredentialsFragmentNode } from '../../../../../graphql/
|
|||||||
|
|
||||||
export const AndroidAppCredentialsMutation = {
|
export const AndroidAppCredentialsMutation = {
|
||||||
async createAndroidAppCredentialsAsync(
|
async createAndroidAppCredentialsAsync(
|
||||||
|
graphqlClient: ExpoGraphqlClient,
|
||||||
androidAppCredentialsInput: {
|
androidAppCredentialsInput: {
|
||||||
fcmId?: string;
|
fcmId?: string;
|
||||||
},
|
},
|
||||||
@@ -56,6 +58,7 @@ export const AndroidAppCredentialsMutation = {
|
|||||||
return data.androidAppCredentials.createAndroidAppCredentials;
|
return data.androidAppCredentials.createAndroidAppCredentials;
|
||||||
},
|
},
|
||||||
async setFcmKeyAsync(
|
async setFcmKeyAsync(
|
||||||
|
graphqlClient: ExpoGraphqlClient,
|
||||||
androidAppCredentialsId: string,
|
androidAppCredentialsId: string,
|
||||||
fcmId: string
|
fcmId: string
|
||||||
): Promise<CommonAndroidAppCredentialsFragment> {
|
): Promise<CommonAndroidAppCredentialsFragment> {
|
||||||
@@ -84,6 +87,7 @@ export const AndroidAppCredentialsMutation = {
|
|||||||
return data.androidAppCredentials.setFcm;
|
return data.androidAppCredentials.setFcm;
|
||||||
},
|
},
|
||||||
async setGoogleServiceAccountKeyForSubmissionsAsync(
|
async setGoogleServiceAccountKeyForSubmissionsAsync(
|
||||||
|
graphqlClient: ExpoGraphqlClient,
|
||||||
androidAppCredentialsId: string,
|
androidAppCredentialsId: string,
|
||||||
googleServiceAccountKeyId: string
|
googleServiceAccountKeyId: string
|
||||||
): Promise<CommonAndroidAppCredentialsFragment> {
|
): Promise<CommonAndroidAppCredentialsFragment> {
|
||||||
|
|||||||
+7
-2
@@ -2,7 +2,8 @@ import assert from 'assert';
|
|||||||
import { print } from 'graphql';
|
import { print } from 'graphql';
|
||||||
import gql from 'graphql-tag';
|
import gql from 'graphql-tag';
|
||||||
|
|
||||||
import { graphqlClient, withErrorHandlingAsync } from '../../../../../graphql/client';
|
import { ExpoGraphqlClient } from '../../../../../commandUtils/context/contextUtils/createGraphqlClient';
|
||||||
|
import { withErrorHandlingAsync } from '../../../../../graphql/client';
|
||||||
import {
|
import {
|
||||||
AndroidFcmFragment,
|
AndroidFcmFragment,
|
||||||
AndroidFcmInput,
|
AndroidFcmInput,
|
||||||
@@ -13,6 +14,7 @@ import { AndroidFcmFragmentNode } from '../../../../../graphql/types/credentials
|
|||||||
|
|
||||||
export const AndroidFcmMutation = {
|
export const AndroidFcmMutation = {
|
||||||
async createAndroidFcmAsync(
|
async createAndroidFcmAsync(
|
||||||
|
graphqlClient: ExpoGraphqlClient,
|
||||||
androidFcmInput: AndroidFcmInput,
|
androidFcmInput: AndroidFcmInput,
|
||||||
accountId: string
|
accountId: string
|
||||||
): Promise<AndroidFcmFragment> {
|
): Promise<AndroidFcmFragment> {
|
||||||
@@ -43,7 +45,10 @@ export const AndroidFcmMutation = {
|
|||||||
);
|
);
|
||||||
return data.androidFcm.createAndroidFcm;
|
return data.androidFcm.createAndroidFcm;
|
||||||
},
|
},
|
||||||
async deleteAndroidFcmAsync(androidFcmId: string): Promise<void> {
|
async deleteAndroidFcmAsync(
|
||||||
|
graphqlClient: ExpoGraphqlClient,
|
||||||
|
androidFcmId: string
|
||||||
|
): Promise<void> {
|
||||||
await withErrorHandlingAsync(
|
await withErrorHandlingAsync(
|
||||||
graphqlClient
|
graphqlClient
|
||||||
.mutation<DeleteAndroidFcmMutation>(
|
.mutation<DeleteAndroidFcmMutation>(
|
||||||
|
|||||||
+7
-2
@@ -2,7 +2,8 @@ import assert from 'assert';
|
|||||||
import { print } from 'graphql';
|
import { print } from 'graphql';
|
||||||
import gql from 'graphql-tag';
|
import gql from 'graphql-tag';
|
||||||
|
|
||||||
import { graphqlClient, withErrorHandlingAsync } from '../../../../../graphql/client';
|
import { ExpoGraphqlClient } from '../../../../../commandUtils/context/contextUtils/createGraphqlClient';
|
||||||
|
import { withErrorHandlingAsync } from '../../../../../graphql/client';
|
||||||
import {
|
import {
|
||||||
AndroidKeystoreFragment,
|
AndroidKeystoreFragment,
|
||||||
AndroidKeystoreInput,
|
AndroidKeystoreInput,
|
||||||
@@ -13,6 +14,7 @@ import { AndroidKeystoreFragmentNode } from '../../../../../graphql/types/creden
|
|||||||
|
|
||||||
export const AndroidKeystoreMutation = {
|
export const AndroidKeystoreMutation = {
|
||||||
async createAndroidKeystoreAsync(
|
async createAndroidKeystoreAsync(
|
||||||
|
graphqlClient: ExpoGraphqlClient,
|
||||||
androidKeystoreInput: AndroidKeystoreInput,
|
androidKeystoreInput: AndroidKeystoreInput,
|
||||||
accountId: string
|
accountId: string
|
||||||
): Promise<AndroidKeystoreFragment> {
|
): Promise<AndroidKeystoreFragment> {
|
||||||
@@ -49,7 +51,10 @@ export const AndroidKeystoreMutation = {
|
|||||||
);
|
);
|
||||||
return data.androidKeystore.createAndroidKeystore;
|
return data.androidKeystore.createAndroidKeystore;
|
||||||
},
|
},
|
||||||
async deleteAndroidKeystoreAsync(androidKeystoreId: string): Promise<void> {
|
async deleteAndroidKeystoreAsync(
|
||||||
|
graphqlClient: ExpoGraphqlClient,
|
||||||
|
androidKeystoreId: string
|
||||||
|
): Promise<void> {
|
||||||
await withErrorHandlingAsync(
|
await withErrorHandlingAsync(
|
||||||
graphqlClient
|
graphqlClient
|
||||||
.mutation<DeleteAndroidKeystoreMutation>(
|
.mutation<DeleteAndroidKeystoreMutation>(
|
||||||
|
|||||||
+7
-2
@@ -2,7 +2,8 @@ import assert from 'assert';
|
|||||||
import { print } from 'graphql';
|
import { print } from 'graphql';
|
||||||
import gql from 'graphql-tag';
|
import gql from 'graphql-tag';
|
||||||
|
|
||||||
import { graphqlClient, withErrorHandlingAsync } from '../../../../../graphql/client';
|
import { ExpoGraphqlClient } from '../../../../../commandUtils/context/contextUtils/createGraphqlClient';
|
||||||
|
import { withErrorHandlingAsync } from '../../../../../graphql/client';
|
||||||
import {
|
import {
|
||||||
CreateGoogleServiceAccountKeyMutation,
|
CreateGoogleServiceAccountKeyMutation,
|
||||||
DeleteGoogleServiceAccountKeyMutation,
|
DeleteGoogleServiceAccountKeyMutation,
|
||||||
@@ -13,6 +14,7 @@ import { GoogleServiceAccountKeyFragmentNode } from '../../../../../graphql/type
|
|||||||
|
|
||||||
export const GoogleServiceAccountKeyMutation = {
|
export const GoogleServiceAccountKeyMutation = {
|
||||||
async createGoogleServiceAccountKeyAsync(
|
async createGoogleServiceAccountKeyAsync(
|
||||||
|
graphqlClient: ExpoGraphqlClient,
|
||||||
googleServiceAccountKeyInput: GoogleServiceAccountKeyInput,
|
googleServiceAccountKeyInput: GoogleServiceAccountKeyInput,
|
||||||
accountId: string
|
accountId: string
|
||||||
): Promise<GoogleServiceAccountKeyFragment> {
|
): Promise<GoogleServiceAccountKeyFragment> {
|
||||||
@@ -49,7 +51,10 @@ export const GoogleServiceAccountKeyMutation = {
|
|||||||
);
|
);
|
||||||
return data.googleServiceAccountKey.createGoogleServiceAccountKey;
|
return data.googleServiceAccountKey.createGoogleServiceAccountKey;
|
||||||
},
|
},
|
||||||
async deleteGoogleServiceAccountKeyAsync(googleServiceAccountKeyId: string): Promise<void> {
|
async deleteGoogleServiceAccountKeyAsync(
|
||||||
|
graphqlClient: ExpoGraphqlClient,
|
||||||
|
googleServiceAccountKeyId: string
|
||||||
|
): Promise<void> {
|
||||||
await withErrorHandlingAsync(
|
await withErrorHandlingAsync(
|
||||||
graphqlClient
|
graphqlClient
|
||||||
.mutation<DeleteGoogleServiceAccountKeyMutation>(
|
.mutation<DeleteGoogleServiceAccountKeyMutation>(
|
||||||
|
|||||||
Loaded 100 of 220 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user