run method
Runs this command.
The return value is wrapped in a Future if necessary and returned by
CommandRunner.runCommand.
Implementation
@override
Future<void> run() async {
print('Checking for latest engine release...\n');
final platform = _platform();
if (platform == null) {
stderr.writeln('Unsupported platform: ${Platform.operatingSystem}');
exit(1);
}
final downloadUrl =
'https://github.com/$_repoOwner/$_repoName/releases/latest/download/flutter_blueprint_engine-$platform';
final destDir = _installDir();
await Directory(destDir).create(recursive: true);
final binaryName = Platform.isWindows
? 'flutter_blueprint_engine.exe'
: 'flutter_blueprint_engine';
final destPath = p.join(destDir, binaryName);
print('Downloading from:\n $downloadUrl\n');
final response = await http.get(Uri.parse(downloadUrl));
if (response.statusCode != 200) {
stderr.writeln(
'Download failed (HTTP ${response.statusCode}).\n'
'Build manually:\n cd engine && go build -o flutter_blueprint_engine ./cmd/engine');
exit(1);
}
final file = File(destPath);
await file.writeAsBytes(response.bodyBytes);
if (!Platform.isWindows) {
await Process.run('chmod', ['+x', destPath]);
}
print('✓ Engine installed to: $destPath');
print('');
print('Add to your PATH:');
print(' export PATH="\$PATH:$destDir"');
print('');
print('Or add to your shell profile (~/.zshrc, ~/.bashrc):');
print(' echo \'export PATH="\$PATH:$destDir"\' >> ~/.zshrc');
}