Skip to content

Commit

Permalink
use expo cli
Browse files Browse the repository at this point in the history
  • Loading branch information
szdziedzic committed Oct 14, 2024
1 parent c4c096a commit 9cd41f7
Show file tree
Hide file tree
Showing 15 changed files with 118 additions and 114 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { findProjectDirAndVerifyProjectSetupAsync } from './contextUtils/findPro
import { getProjectIdAsync } from './contextUtils/getProjectIdAsync';
import {
ExpoConfigOptions,
getPrivateExpoConfig,
getPublicExpoConfig,
getPrivateExpoConfigAsync,
getPublicExpoConfigAsync,
} from '../../project/expoConfig';

export type DynamicConfigContextFn = (options?: ExpoConfigOptions) => Promise<{
Expand All @@ -22,12 +22,12 @@ export class DynamicPublicProjectConfigContextField extends ContextField<Dynamic
}: ContextOptions): Promise<DynamicConfigContextFn> {
const projectDir = await findProjectDirAndVerifyProjectSetupAsync();
return async (options?: ExpoConfigOptions) => {
const expBefore = getPublicExpoConfig(projectDir, options);
const expBefore = await getPublicExpoConfigAsync(projectDir, options);
const projectId = await getProjectIdAsync(sessionManager, expBefore, {
nonInteractive,
env: options?.env,
});
const exp = getPublicExpoConfig(projectDir, options);
const exp = await getPublicExpoConfigAsync(projectDir, options);
return {
exp,
projectDir,
Expand All @@ -44,12 +44,12 @@ export class DynamicPrivateProjectConfigContextField extends ContextField<Dynami
}: ContextOptions): Promise<DynamicConfigContextFn> {
const projectDir = await findProjectDirAndVerifyProjectSetupAsync();
return async (options?: ExpoConfigOptions) => {
const expBefore = getPrivateExpoConfig(projectDir, options);
const expBefore = await getPrivateExpoConfigAsync(projectDir, options);
const projectId = await getProjectIdAsync(sessionManager, expBefore, {
nonInteractive,
env: options?.env,
});
const exp = getPrivateExpoConfig(projectDir, options);
const exp = await getPrivateExpoConfigAsync(projectDir, options);
return {
exp,
projectDir,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { InvalidEasJsonError } from '@expo/eas-json/build/errors';
import ContextField, { ContextOptions } from './ContextField';
import { findProjectDirAndVerifyProjectSetupAsync } from './contextUtils/findProjectDirAndVerifyProjectSetupAsync';
import { getProjectIdAsync } from './contextUtils/getProjectIdAsync';
import { getPrivateExpoConfig } from '../../project/expoConfig';
import { getPrivateExpoConfigAsync } from '../../project/expoConfig';

export class OptionalPrivateProjectConfigContextField extends ContextField<
| {
Expand Down Expand Up @@ -35,11 +35,11 @@ export class OptionalPrivateProjectConfigContextField extends ContextField<
return undefined;
}

const expBefore = getPrivateExpoConfig(projectDir);
const expBefore = await getPrivateExpoConfigAsync(projectDir);
const projectId = await getProjectIdAsync(sessionManager, expBefore, {
nonInteractive,
});
const exp = getPrivateExpoConfig(projectDir);
const exp = await getPrivateExpoConfigAsync(projectDir);
return {
exp,
projectDir,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ExpoConfig } from '@expo/config';
import ContextField, { ContextOptions } from './ContextField';
import { findProjectDirAndVerifyProjectSetupAsync } from './contextUtils/findProjectDirAndVerifyProjectSetupAsync';
import { getProjectIdAsync } from './contextUtils/getProjectIdAsync';
import { getPrivateExpoConfig } from '../../project/expoConfig';
import { getPrivateExpoConfigAsync } from '../../project/expoConfig';

export class PrivateProjectConfigContextField extends ContextField<{
projectId: string;
Expand All @@ -16,11 +16,11 @@ export class PrivateProjectConfigContextField extends ContextField<{
projectDir: string;
}> {
const projectDir = await findProjectDirAndVerifyProjectSetupAsync();
const expBefore = getPrivateExpoConfig(projectDir);
const expBefore = await getPrivateExpoConfigAsync(projectDir);
const projectId = await getProjectIdAsync(sessionManager, expBefore, {
nonInteractive,
});
const exp = getPrivateExpoConfig(projectDir);
const exp = await getPrivateExpoConfigAsync(projectDir);

return {
projectId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ import { findProjectRootAsync } from './findProjectDirAndVerifyProjectSetupAsync
import { AppQuery } from '../../../graphql/queries/AppQuery';
import Log, { learnMore } from '../../../log';
import { ora } from '../../../ora';
import { createOrModifyExpoConfigAsync, getPrivateExpoConfig } from '../../../project/expoConfig';
import {
createOrModifyExpoConfigAsync,
getPrivateExpoConfigAsync,
} from '../../../project/expoConfig';
import { fetchOrCreateProjectIDForWriteToConfigWithConfirmationAsync } from '../../../project/fetchOrCreateProjectIDForWriteToConfigWithConfirmationAsync';
import { toAppPrivacy } from '../../../project/projectUtils';
import SessionManager from '../../../user/SessionManager';
Expand All @@ -25,7 +28,7 @@ export async function saveProjectIdToAppConfigAsync(
options: { env?: Env } = {}
): Promise<void> {
// NOTE(cedric): we disable plugins to avoid writing plugin-generated content to `expo.extra`
const exp = getPrivateExpoConfig(projectDir, { skipPlugins: true, ...options });
const exp = await getPrivateExpoConfigAsync(projectDir, { skipPlugins: true, ...options });
const result = await createOrModifyExpoConfigAsync(
projectDir,
{
Expand Down
8 changes: 4 additions & 4 deletions packages/eas-cli/src/commands/project/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { AppMutation } from '../../graphql/mutations/AppMutation';
import { AppQuery } from '../../graphql/queries/AppQuery';
import Log, { link } from '../../log';
import { ora } from '../../ora';
import { createOrModifyExpoConfigAsync, getPrivateExpoConfig } from '../../project/expoConfig';
import { createOrModifyExpoConfigAsync, getPrivateExpoConfigAsync } from '../../project/expoConfig';
import { findProjectIdByAccountNameAndSlugNullableAsync } from '../../project/fetchOrCreateProjectIDForWriteToConfigWithConfirmationAsync';
import { toAppPrivacy } from '../../project/projectUtils';
import { Choice, confirmAsync, promptAsync } from '../../prompts';
Expand Down Expand Up @@ -106,7 +106,7 @@ export default class ProjectInit extends EasCommand {
projectDir: string,
{ force, nonInteractive }: InitializeMethodOptions
): Promise<void> {
const exp = getPrivateExpoConfig(projectDir);
const exp = await getPrivateExpoConfigAsync(projectDir);
const appForProjectId = await AppQuery.byIdAsync(graphqlClient, projectId);
const correctOwner = appForProjectId.ownerAccount.name;
const correctSlug = appForProjectId.slug;
Expand Down Expand Up @@ -161,7 +161,7 @@ export default class ProjectInit extends EasCommand {
projectDir: string,
{ force, nonInteractive }: InitializeMethodOptions
): Promise<void> {
const exp = getPrivateExpoConfig(projectDir);
const exp = await getPrivateExpoConfigAsync(projectDir);
const existingProjectId = exp.extra?.eas?.projectId;

if (projectId === existingProjectId) {
Expand Down Expand Up @@ -218,7 +218,7 @@ export default class ProjectInit extends EasCommand {
projectDir: string,
{ force, nonInteractive }: InitializeMethodOptions
): Promise<string> {
const exp = getPrivateExpoConfig(projectDir);
const exp = await getPrivateExpoConfigAsync(projectDir);
const existingProjectId = exp.extra?.eas?.projectId;

if (existingProjectId) {
Expand Down
6 changes: 3 additions & 3 deletions packages/eas-cli/src/commands/project/onboarding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {
import { installDependenciesAsync } from '../../onboarding/installDependencies';
import { runCommandAsync } from '../../onboarding/runCommand';
import { RequestedPlatform } from '../../platform';
import { ExpoConfigOptions, getPrivateExpoConfig } from '../../project/expoConfig';
import { ExpoConfigOptions, getPrivateExpoConfigAsync } from '../../project/expoConfig';
import { promptAsync } from '../../prompts';
import { Actor } from '../../user/User';
import { easCliVersion } from '../../utils/easCli';
Expand Down Expand Up @@ -339,7 +339,7 @@ async function getPrivateExpoConfigWithProjectIdAsync({
actor: Actor;
options?: ExpoConfigOptions;
}): Promise<CredentialsContextProjectInfo> {
const expBefore = getPrivateExpoConfig(projectDir, options);
const expBefore = await getPrivateExpoConfigAsync(projectDir, options);
const projectId = await validateOrSetProjectIdAsync({
exp: expBefore,
graphqlClient,
Expand All @@ -349,7 +349,7 @@ async function getPrivateExpoConfigWithProjectIdAsync({
},
cwd: projectDir,
});
const exp = getPrivateExpoConfig(projectDir, options);
const exp = await getPrivateExpoConfigAsync(projectDir, options);
return {
exp,
projectId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,14 @@ export async function getAppLookupParamsFromContextAsync(
ctx: CredentialsContext,
gradleContext?: GradleBuildContext
): Promise<AppLookupParams> {
ctx.ensureProjectContext();
const projectName = ctx.exp.slug;
const projectId = ctx.projectId;
const exp = await ctx.getExpoConfigAsync();
const projectName = exp.slug;
const projectId = await ctx.getProjectIdAsync();
const account = await getOwnerAccountForProjectIdAsync(ctx.graphqlClient, projectId);

const androidApplicationIdentifier = await getApplicationIdAsync(
ctx.projectDir,
ctx.exp,
exp,
ctx.vcsClient,
gradleContext
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class CreateKeystore {
throw new Error(`New keystore cannot be created in non-interactive mode.`);
}

const projectId = ctx.projectId;
const projectId = await ctx.getProjectIdAsync();
const keystore = await this.provideOrGenerateAsync(ctx.graphqlClient, ctx.analytics, projectId);
const keystoreFragment = await ctx.android.createKeystoreAsync(
ctx.graphqlClient,
Expand Down
14 changes: 7 additions & 7 deletions packages/eas-cli/src/credentials/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { AuthenticationMode } from './ios/appstore/authenticateTypes';
import { Analytics } from '../analytics/AnalyticsManager';
import { ExpoGraphqlClient } from '../commandUtils/context/contextUtils/createGraphqlClient';
import Log from '../log';
import { getPrivateExpoConfig } from '../project/expoConfig';
import { getPrivateExpoConfigAsync } from '../project/expoConfig';
import { confirmAsync } from '../prompts';
import { Actor } from '../user/User';
import { Client } from '../vcs/vcs';
Expand Down Expand Up @@ -67,22 +67,22 @@ export class CredentialsContext {
return !!this.projectInfo;
}

get exp(): ExpoConfig {
this.ensureProjectContext();
public async getExpoConfigAsync(): Promise<ExpoConfig> {
await this.ensureProjectContextAsync();
return this.projectInfo!.exp;
}

get projectId(): string {
this.ensureProjectContext();
public async getProjectIdAsync(): Promise<string> {
await this.ensureProjectContextAsync();
return this.projectInfo!.projectId;
}

public ensureProjectContext(): void {
public async ensureProjectContextAsync(): Promise<void> {
if (this.hasProjectContext) {
return;
}
// trigger getConfig error
getPrivateExpoConfig(this.options.projectDir);
await getPrivateExpoConfigAsync(this.options.projectDir);
}

async bestEffortAppStoreAuthenticateAsync(): Promise<void> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ export async function assignBuildCredentialsAsync(
}

export async function getAppFromContextAsync(ctx: CredentialsContext): Promise<App> {
ctx.ensureProjectContext();
const projectName = ctx.exp.slug;
const projectId = ctx.projectId;
const exp = await ctx.getExpoConfigAsync();
const projectName = exp.slug;
const projectId = await ctx.getProjectIdAsync();
const account = await getOwnerAccountForProjectIdAsync(ctx.graphqlClient, projectId);
return {
account,
Expand Down
9 changes: 5 additions & 4 deletions packages/eas-cli/src/credentials/manager/ManageIos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export class ManageIos {
};

const account = ctx.hasProjectContext
? await getAccountForProjectAsync(ctx.projectId)
? await getAccountForProjectAsync(await ctx.getProjectIdAsync())
: ensureActorHasPrimaryAccount(ctx.user);

let app = null;
Expand Down Expand Up @@ -195,18 +195,19 @@ export class ManageIos {
}> {
assert(ctx.hasProjectContext, 'createProjectContextAsync: must have project context.');

const app = { account, projectName: ctx.exp.slug };
const exp = await ctx.getExpoConfigAsync();
const app = { account, projectName: exp.slug };
const xcodeBuildContext = await resolveXcodeBuildContextAsync(
{
projectDir: ctx.projectDir,
nonInteractive: ctx.nonInteractive,
exp: ctx.exp,
exp,
vcsClient: ctx.vcsClient,
},
buildProfile
);
const targets = await resolveTargetsAsync({
exp: ctx.exp,
exp,
projectDir: ctx.projectDir,
xcodeBuildContext,
env: buildProfile.env,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export class SetUpIosBuildCredentials extends ManageIos {
};

const account = ctx.hasProjectContext
? await getAccountForProjectAsync(ctx.projectId)
? await getAccountForProjectAsync(await ctx.getProjectIdAsync())
: ensureActorHasPrimaryAccount(ctx.user);

let app = null;
Expand Down
Loading

0 comments on commit 9cd41f7

Please sign in to comment.