checkForUpdates static method

Future<void> checkForUpdates({
  1. bool showCurrentVersion = false,
})

Checks if a new version is available and prints a message.

Implementation

static Future<void> checkForUpdates({bool showCurrentVersion = false}) async {
  final latest = await _getLatestVersion();
  final current = ProjectUtils.getPackageVersion;
  if (latest == null) return;

  if (isNewerVersion(latest, current)) {
    ConsoleLog.line();
    ConsoleLog.title('''
A new version of ${ProjectUtils.getPackageName} is available: $latest
 (you have $current).\n
 Update using: dart pub global activate ${ProjectUtils.getPackageName}
''');
    ConsoleLog.line();
  } else if (showCurrentVersion) {
    ConsoleLog.step('Dartgenx ${ProjectUtils.getPackageVersion}');
  }
}