-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[eas-cli] Use expo-updates runtime version CLI to generate runtime ve…
…rsions
- Loading branch information
Showing
5 changed files
with
52 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
packages/eas-cli/src/project/resolveRuntimeVersionAsync.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { ExpoConfig } from '@expo/config'; | ||
import { Updates } from '@expo/config-plugins'; | ||
|
||
import { ModuleNotFoundError, expoUpdatesCommandAsync } from '../utils/expoUpdatesCli'; | ||
|
||
export async function resolveRuntimeVersionAsync({ | ||
exp, | ||
platform, | ||
projectDir, | ||
}: { | ||
exp: ExpoConfig; | ||
platform: 'ios' | 'android'; | ||
projectDir: string; | ||
}): Promise<string | null> { | ||
try { | ||
const runtimeJSONString = await expoUpdatesCommandAsync(projectDir, [ | ||
'runtimeversion:resolve', | ||
'--platform', | ||
platform, | ||
]); | ||
const runtimeVersion = JSON.parse(runtimeJSONString).runtimeVersion; | ||
return runtimeVersion ?? null; | ||
} catch (e: any) { | ||
// if expo-updates is not installed, there's no need for a runtime version in the build | ||
if (e instanceof ModuleNotFoundError) { | ||
return null; | ||
} | ||
|
||
// fall back to the previous behavior (using the @expo/config-plugins eas-cli dependency rather | ||
// than the versioned @expo/config-plugins dependency in the project) | ||
return await Updates.getRuntimeVersionNullableAsync(projectDir, exp, platform); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters