diff --git a/CHANGELOG.md b/CHANGELOG.md index 81d8a4740a..621b5a67b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,8 @@ This is the log of notable changes to EAS CLI and related packages. ### ๐Ÿ› Bug fixes +- Fix display of errors when expo-updates CLI command fails. ([#2324](https://github.com/expo/eas-cli/pull/2324) by [@wschurman](https://github.com/wschurman)) + ### ๐Ÿงน Chores ## [7.8.1](https://github.com/expo/eas-cli/releases/tag/v7.8.1) - 2024-04-11 diff --git a/packages/eas-cli/src/project/publish.ts b/packages/eas-cli/src/project/publish.ts index 7ee420a175..66c2ba7dd2 100644 --- a/packages/eas-cli/src/project/publish.ts +++ b/packages/eas-cli/src/project/publish.ts @@ -723,16 +723,21 @@ async function getRuntimeVersionForPlatformAsync({ if (await isModernExpoUpdatesCLIWithRuntimeVersionCommandSupportedAsync(projectDir)) { try { + Log.debug('Using expo-updates runtimeversion:resolve CLI for runtime version resolution'); + + const extraArgs = Log.isDebug ? ['--debug'] : []; + const resolvedRuntimeVersionJSONResult = await expoUpdatesCommandAsync(projectDir, [ 'runtimeversion:resolve', '--platform', platform, + ...extraArgs, ]); const runtimeVersionResult = JSON.parse(resolvedRuntimeVersionJSONResult); - if (runtimeVersionResult.fingerprintSources) { - Log.debug(`Resolved fingeprint runtime version for platform "${platform}". Sources:`); - Log.debug(runtimeVersionResult.fingerprintSources); - } + + Log.debug('runtimeversion:resolve output:'); + Log.debug(resolvedRuntimeVersionJSONResult); + return nullthrows( runtimeVersionResult.runtimeVersion, `Unable to determine runtime version for ${ diff --git a/packages/eas-cli/src/project/resolveRuntimeVersionAsync.ts b/packages/eas-cli/src/project/resolveRuntimeVersionAsync.ts index aee00637c4..c65c02adbe 100644 --- a/packages/eas-cli/src/project/resolveRuntimeVersionAsync.ts +++ b/packages/eas-cli/src/project/resolveRuntimeVersionAsync.ts @@ -24,16 +24,21 @@ export async function resolveRuntimeVersionAsync({ } try { + Log.debug('Using expo-updates runtimeversion:resolve CLI for runtime version resolution'); + + const extraArgs = Log.isDebug ? ['--debug'] : []; + const resolvedRuntimeVersionJSONResult = await expoUpdatesCommandAsync(projectDir, [ 'runtimeversion:resolve', '--platform', platform, + ...extraArgs, ]); const runtimeVersionResult = JSON.parse(resolvedRuntimeVersionJSONResult); - if (runtimeVersionResult.fingerprintSources) { - Log.debug(`Resolved fingeprint runtime version for platform "${platform}". Sources:`); - Log.debug(runtimeVersionResult.fingerprintSources); - } + + Log.debug('runtimeversion:resolve output:'); + Log.debug(resolvedRuntimeVersionJSONResult); + return runtimeVersionResult.runtimeVersion ?? null; } catch (e: any) { // if expo-updates is not installed, there's no need for a runtime version in the build diff --git a/packages/eas-cli/src/utils/expoUpdatesCli.ts b/packages/eas-cli/src/utils/expoUpdatesCli.ts index 784d21a39b..7ee75b36ea 100644 --- a/packages/eas-cli/src/utils/expoUpdatesCli.ts +++ b/packages/eas-cli/src/utils/expoUpdatesCli.ts @@ -5,6 +5,7 @@ import { link } from '../log'; export class ExpoUpdatesCLIModuleNotFoundError extends Error {} export class ExpoUpdatesCLIInvalidCommandError extends Error {} +export class ExpoUpdatesCLICommandFailedError extends Error {} export async function expoUpdatesCommandAsync(projectDir: string, args: string[]): Promise { let expoUpdatesCli; @@ -24,13 +25,18 @@ export async function expoUpdatesCommandAsync(projectDir: string, args: string[] } try { - return (await spawnAsync(expoUpdatesCli, args)).stdout; + return (await spawnAsync(expoUpdatesCli, args, { stdio: 'pipe' })).stdout; } catch (e: any) { - if (e.stderr && typeof e.stderr === 'string' && e.stderr.includes('Invalid command')) { - throw new ExpoUpdatesCLIInvalidCommandError( - `The command specified by ${args} was not valid in the \`expo-updates\` CLI.` - ); + if (e.stderr && typeof e.stderr === 'string') { + if (e.stderr.includes('Invalid command')) { + throw new ExpoUpdatesCLIInvalidCommandError( + `The command specified by ${args} was not valid in the \`expo-updates\` CLI.` + ); + } else { + throw new ExpoUpdatesCLICommandFailedError(e.stderr); + } } + throw e; } }