feat(api): enhance public APK endpoint to return semantic version from OTA bundle
The PublicLatestAPK endpoint now reads the expoConfig.json from the OTA bundle to extract the actual semantic version (expo.version) instead of returning the runtimeVersion as the version name. Falls back to runtimeVersion if expoConfig.json is not available.
This commit is contained in:
@@ -88,6 +88,28 @@ func (s *UpdateService) GetLatestAPK() (*model.APKInfo, error) {
|
||||
return s.store.GetLatestAPK()
|
||||
}
|
||||
|
||||
// GetAPKVersionName 返回 APK 对应 runtimeVersion 的 OTA bundle 中的语义版本号。
|
||||
// 读取路径:<root>/<runtimeVersion>/android/expoConfig.json -> expo.version
|
||||
// 若 OTA bundle 尚未发布或 expoConfig.json 缺失,返回空字符串(调用方应兜底)。
|
||||
func (s *UpdateService) GetAPKVersionName(runtimeVersion string) string {
|
||||
releasePath, err := s.store.LatestReleasePath(runtimeVersion, "android")
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
cfg, err := s.store.ReadExpoConfig(releasePath)
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
expo, ok := cfg["expo"].(map[string]any)
|
||||
if !ok {
|
||||
return ""
|
||||
}
|
||||
if v, ok := expo["version"].(string); ok {
|
||||
return v
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (s *UpdateService) BuildManifestResponse(req ManifestRequest) (ManifestResponse, error) {
|
||||
releasePath, err := s.store.LatestReleasePath(req.RuntimeVersion, req.Platform)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user