Skip to content

Commit

Permalink
[build-tools] pass env vars to expo updates CLI (#388)
Browse files Browse the repository at this point in the history
  • Loading branch information
szdziedzic authored May 1, 2024
1 parent a9ef233 commit 7c7cb6f
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/build-tools/src/builders/android.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ async function buildAsync(ctx: BuildContext<Android.Job>): Promise<void> {
appConfig: ctx.appConfig,
platform: ctx.job.platform,
workflow: ctx.job.type,
env: ctx.env,
});
}
);
Expand Down
1 change: 1 addition & 0 deletions packages/build-tools/src/builders/ios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ async function buildAsync(ctx: BuildContext<Ios.Job>): Promise<void> {
appConfig: ctx.appConfig,
platform: ctx.job.platform,
workflow: ctx.job.type,
env: ctx.env,
});
}
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export function calculateEASUpdateRuntimeVersionFunction(ctx: CustomBuildContext
appConfig,
platform: inputs.platform.value as Platform,
workflow: inputs.workflow.value as Workflow,
env,
});
if (resolvedRuntimeVersion) {
outputs.resolved_eas_update_runtime_version.set(resolvedRuntimeVersion);
Expand Down
4 changes: 4 additions & 0 deletions packages/build-tools/src/utils/expoUpdates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Platform, Job, BuildJob, Workflow } from '@expo/eas-build-job';
import semver from 'semver';
import { ExpoConfig } from '@expo/config';
import { bunyan } from '@expo/logger';
import { BuildStepEnv } from '@expo/steps';

import {
androidSetRuntimeVersionNativelyAsync,
Expand Down Expand Up @@ -217,12 +218,14 @@ export async function resolveRuntimeVersionForExpoUpdatesIfConfiguredAsync({
platform,
workflow,
logger,
env,
}: {
cwd: string;
appConfig: ExpoConfig;
platform: Platform;
workflow: Workflow;
logger: bunyan;
env: BuildStepEnv;
}): Promise<string | null> {
const expoUpdatesPackageVersion = await getExpoUpdatesPackageVersionIfInstalledAsync(cwd, logger);
if (expoUpdatesPackageVersion === null) {
Expand All @@ -236,6 +239,7 @@ export async function resolveRuntimeVersionForExpoUpdatesIfConfiguredAsync({
workflow,
logger,
expoUpdatesPackageVersion,
env,
});

logger.info(`Resolved runtime version: ${resolvedRuntimeVersion}`);
Expand Down
4 changes: 3 additions & 1 deletion packages/build-tools/src/utils/expoUpdatesCli.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import resolveFrom, { silent as silentResolveFrom } from 'resolve-from';
import spawnAsync from '@expo/turtle-spawn';
import { bunyan } from '@expo/logger';
import { BuildStepEnv } from '@expo/steps';

export class ExpoUpdatesCLIModuleNotFoundError extends Error {}
export class ExpoUpdatesCLIInvalidCommandError extends Error {}
Expand All @@ -9,7 +10,7 @@ export class ExpoUpdatesCLICommandFailedError extends Error {}
export async function expoUpdatesCommandAsync(
projectDir: string,
args: string[],
{ logger }: { logger: bunyan }
{ logger, env }: { logger: bunyan; env: BuildStepEnv }
): Promise<string> {
let expoUpdatesCli;
try {
Expand All @@ -30,6 +31,7 @@ export async function expoUpdatesCommandAsync(
stdio: 'pipe',
cwd: projectDir,
logger,
env,
});
return spawnResult.stdout;
} catch (e: any) {
Expand Down
4 changes: 4 additions & 0 deletions packages/build-tools/src/utils/resolveRuntimeVersionAsync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { ExpoConfig } from '@expo/config';
import { Updates } from '@expo/config-plugins';
import { bunyan } from '@expo/logger';
import { Workflow } from '@expo/eas-build-job';
import { BuildStepEnv } from '@expo/steps';

import { ExpoUpdatesCLIModuleNotFoundError, expoUpdatesCommandAsync } from './expoUpdatesCli';
import { isModernExpoUpdatesCLIWithRuntimeVersionCommandSupported } from './expoUpdates';
Expand All @@ -13,13 +14,15 @@ export async function resolveRuntimeVersionAsync({
projectDir,
logger,
expoUpdatesPackageVersion,
env,
}: {
exp: ExpoConfig;
platform: 'ios' | 'android';
workflow: Workflow;
projectDir: string;
logger: bunyan;
expoUpdatesPackageVersion: string;
env: BuildStepEnv;
}): Promise<string | null> {
if (!isModernExpoUpdatesCLIWithRuntimeVersionCommandSupported(expoUpdatesPackageVersion)) {
logger.debug('Using expo-updates config plugin for runtime version resolution');
Expand All @@ -38,6 +41,7 @@ export async function resolveRuntimeVersionAsync({
['runtimeversion:resolve', '--platform', platform, '--workflow', workflow, ...extraArgs],
{
logger,
env,
}
);
const runtimeVersionResult = JSON.parse(resolvedRuntimeVersionJSONResult);
Expand Down

0 comments on commit 7c7cb6f

Please sign in to comment.