-
Notifications
You must be signed in to change notification settings - Fork 76
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
82 additions
and
48 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
39 changes: 39 additions & 0 deletions
39
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,39 @@ | ||
import { ExpoConfig } from '@expo/config'; | ||
import { Updates } from '@expo/config-plugins'; | ||
|
||
import { | ||
ExpoUpdatesCLIInvalidCommandError, | ||
ExpoUpdatesCLIModuleNotFoundError, | ||
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 ExpoUpdatesCLIModuleNotFoundError) { | ||
return null; | ||
} else if (e instanceof ExpoUpdatesCLIInvalidCommandError) { | ||
// 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); | ||
} | ||
|
||
throw e; | ||
} | ||
} |
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