getLatestCLIVersionFromGit static method

Future<String?> getLatestCLIVersionFromGit()

Get the latest CLI version from Git (fallback if no releases)

Implementation

static Future<String?> getLatestCLIVersionFromGit() async {
  try {
    // Get from main branch directly (more reliable than API)
    final response = await http.get(
      Uri.parse('https://raw.githubusercontent.com/victorsdd01/vgv_cli/main/pubspec.yaml'),
    ).timeout(const Duration(seconds: 10));

    if (response.statusCode == 200) {
      final content = response.body;
      final versionMatch = RegExp(r'version:\s*(\d+\.\d+\.\d+)').firstMatch(content);
      if (versionMatch != null) {
        return versionMatch.group(1)!;
      }
    }
  } catch (e) {
    // Silently fail
  }

  return null;
}