checkForUpdate method

Future<void> checkForUpdate()

Implementation

Future<void> checkForUpdate() async {
  final (needsUpdate, latestVersion) = await updateCommand.needsUpdate();

  if (needsUpdate) {
    const changelog =
        'https://github.com/mrgnhnt96/barreler/blob/main/CHANGELOG.md';

    final package = cyan.wrap('barreler');
    final currentVersion = red.wrap(packageVersion);
    final updateToVersion = green.wrap(latestVersion);
    final updateCommand = yellow.wrap('barreler update');
    final changelogLink = darkGray.wrap(changelog);

    final message = '''
┌─────────────────────────────────────────────────────────────────────────┐
│ New update for $package is available!                                   │
│ You are using $currentVersion, the latest is $updateToVersion.                               │
│ Run `$updateCommand` to update to the latest version.                  │
│ Changelog: $changelogLink │
└─────────────────────────────────────────────────────────────────────────┘
''';

    logger.write(message);
  }
}