enginePath property

String get enginePath

Resolves the path to the engine binary.

Implementation

String get enginePath {
  // 1. Check ~/.flutter_blueprint/bin/
  final home = Platform.environment['HOME'] ?? Platform.environment['USERPROFILE'] ?? '';
  final homeBin = p.join(home, '.flutter_blueprint', 'bin', _binaryName);
  if (File(homeBin).existsSync()) return homeBin;

  // 2. Check PATH via `which`/`where`
  final whichResult = Process.runSync(
    Platform.isWindows ? 'where' : 'which',
    [_binaryName],
  );
  if (whichResult.exitCode == 0) {
    return (whichResult.stdout as String).trim().split('\n').first.trim();
  }

  // 3. Check next to this script (for development)
  final scriptDir = p.dirname(Platform.script.toFilePath());
  final localBin = p.join(scriptDir, '..', 'engine', _binaryName);
  if (File(localBin).existsSync()) return p.normalize(localBin);

  throw StateError(
    'Engine binary "$_binaryName" not found.\n'
    'Run `flutter_blueprint upgrade` to download it, or build it manually:\n'
    '  cd engine && go build -o $_binaryName ./cmd/engine',
  );
}