copyServiceAccountKey method
Copy service account key to server
Implementation
Future<void> copyServiceAccountKey() async {
if (!config.createServer) return;
if (config.serviceAccountKeyPath == null) {
warn('No service account key path provided');
return;
}
final File sourceFile = File(config.serviceAccountKeyPath!);
if (!sourceFile.existsSync()) {
error('Service account key not found: ${config.serviceAccountKeyPath}');
return;
}
info('Copying service account key...');
final String destPath = p.join(serverPath, 'service-account.json');
await sourceFile.copy(destPath);
// Add to gitignore
final File gitignore = File(p.join(serverPath, '.gitignore'));
if (gitignore.existsSync()) {
String content = await gitignore.readAsString();
if (!content.contains('*.json')) {
content += '\n# Service account keys\n*.json\n';
await gitignore.writeAsString(content);
}
}
success('Service account key copied');
}