-
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.
Revert "Revert "[eas-cli] Use expo-updates runtime version CLI to gen…
- Loading branch information
Showing
6 changed files
with
93 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
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
44 changes: 44 additions & 0 deletions
44
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,44 @@ | ||
import { ExpoConfig } from '@expo/config'; | ||
import { Updates } from '@expo/config-plugins'; | ||
|
||
import Log from '../log'; | ||
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 resolvedRuntimeVersionJSONResult = await expoUpdatesCommandAsync(projectDir, [ | ||
'runtimeversion:resolve', | ||
'--platform', | ||
platform, | ||
]); | ||
const runtimeVersionResult = JSON.parse(resolvedRuntimeVersionJSONResult); | ||
if (runtimeVersionResult.fingerprintSources) { | ||
Log.debug(`Resolved fingeprint runtime version for platform "${platform}". Sources:`); | ||
Log.debug(runtimeVersionResult.fingerprintSources); | ||
} | ||
return runtimeVersionResult.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