run method

  1. @override
Future<void> run()
override

Runs this command.

The return value is wrapped in a Future if necessary and returned by CommandRunner.runCommand.

Implementation

@override
Future<void> run() async {
  final projectDir = findNitroProjectRoot();
  if (projectDir == null) {
    stderr.writeln('❌ No Nitro project found in . or its subdirectories (must have nitro dependency in pubspec.yaml).');
    exit(1);
  }

  // Change working directory so that doctor checks (File('ios'), etc) work correctly.
  Directory.current = projectDir;

  if (projectDir.path != Directory.current.path) {
    stdout.writeln('  \x1B[90m📂 Found project in: ${projectDir.path}\x1B[0m');
  }

  final result = performChecks();

  await runApp(DoctorView(
    pluginName: result.pluginName,
    sections: result.sections,
    errors: result.errors,
    warnings: result.warnings,
  ));

  // Print persistent one-liner after TUI exits
  if (result.errors == 0 && result.warnings == 0) {
    stdout.writeln('  \x1B[1;32m✨ ${result.pluginName} — all checks passed\x1B[0m');
  } else if (result.errors > 0) {
    stdout.writeln('  \x1B[1;31m✘  ${result.pluginName} — ${result.errors} error(s)'
        '${result.warnings > 0 ? ", ${result.warnings}" : ""}\x1B[0m');
  } else {
    stdout.writeln('  \x1B[1;33m⚠  ${result.pluginName} — ${result.warnings} warning(s)\x1B[0m');
  }
  stdout.writeln('');

  exit(result.errors > 0 ? 1 : 0);
}