getLatestVersion function
Get the latest version, either from direct version string or channel lookup.
Implementation
Future<String> getLatestVersion(String channelOrVersion) async {
// Direct version — match internal format too
if (RegExp(r'^v?\d+\.\d+\.\d+(-\S+)?$').hasMatch(channelOrVersion)) {
final normalized = channelOrVersion.startsWith('v')
? channelOrVersion.substring(1)
: channelOrVersion;
// 99.99.x is reserved for CI smoke-test fixtures
if (RegExp(r'^99\.99\.').hasMatch(normalized)) {
throw Exception(
'Version $normalized is not available for installation. Use \'stable\' or \'latest\'.',
);
}
return normalized;
}
// ReleaseChannel validation
if (channelOrVersion != 'stable' && channelOrVersion != 'latest') {
throw Exception(
'Invalid channel: $channelOrVersion. Use \'stable\' or \'latest\'',
);
}
// Use GCS for downloads
return getLatestVersionFromBinaryRepo(
channel: channelOrVersion,
baseUrl: gcsBucketUrl,
);
}