performUpdateAndVerify method

Future<UpdateResult> performUpdateAndVerify()

Perform the update and verify the new version.

Implementation

Future<UpdateResult> performUpdateAndVerify() async {
  final updateResult = await performUpdate();
  if (!updateResult.success) return updateResult;

  // Verify by running zorphy_cli --version
  try {
    final verifyResult = await _runProcess('zorphy_cli', ['--version']);
    if (verifyResult.exitCode == 0) {
      final newVersion = verifyResult.stdout.toString().trim();
      return UpdateResult(
        success: true,
        newVersion: newVersion,
        message: 'Updated and verified. Running version: $newVersion',
      );
    } else {
      return UpdateResult(
        success: true,
        message:
            'Update applied but version verification failed. '
            'Run `zorphy_cli --version` to check manually.',
      );
    }
  } catch (e) {
    return UpdateResult(
      success: true,
      message:
          'Update applied but could not verify. '
          'Run `zorphy_cli --version` to check.',
    );
  }
}