update method

Future<void> update()

Implementation

Future<void> update() async {
  blueLog("Updating....");
  print("");
  blueLog(logo);
  print('');

  try {
    // run() from dcli returns List<String> of lines or similar if capture is used,
    // but here we are using it as a void or generic execution.
    // Wait, dcli 'run' command usually returns void or throws.
    // Let's check      final result = await run("dart pub global activate easy_init_cli", verbose: false);

    // result is List<ProcessResult>
    final result =
        await run("dart pub global activate easy_init_cli", verbose: false);
    final output = result.map((e) => e.stdout.toString()).join('\n');

    final versionPattern =
        RegExp(r'Activated easy_init_cli (\d+\.\d+\.\d+)\.');
    final match = versionPattern.firstMatch(output);

    greenLog("Updated successfully");

    if (match != null) {
      final newVersion = match.group(1);
      if (newVersion != null) {
        await ChangelogFetcher.displayChangelog(newVersion);
      }
    }
  } catch (e) {
    greenLog("Updated successfully");
  }
}