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 {
if (!clientsDir.existsSync()) {
throw BuildException(
'`clients` directory not found at "${clientsDir.path}"',
fix:
'Run "udara_cli setup --clients default" to initialize client directories.',
);
}
final clients = await listClientNames();
final asJson = argResults!['json'] as bool;
Logger.jsonMode = argResults!['json'] as bool;
if (asJson) {
await _printJson(clients);
return;
}
if (clients.isEmpty) {
Logger.warning('No client directories found in "${clientsDir.path}".');
Logger.info(
'Run "udara_cli setup --clients <name>" to create your first client.');
return;
}
final config = ConfigService(projectDir);
Logger.phase('Available Clients (${clients.length})');
final width = clients.map((c) => c.length).reduce((a, b) => a > b ? a : b);
for (final client in clients) {
final envFile = File(p.join(clientsDir.path, client, '.env'));
final hasTest =
File(p.join(clientsDir.path, client, '.env_test')).existsSync();
if (!envFile.existsSync()) {
Logger.warning('${client.padRight(width)} (no .env file)');
continue;
}
final env = await config.parseEnvFile(envFile);
final appName = env['APP_NAME_PROD'] ?? '(no APP_NAME_PROD)';
final bundleId = env['BUNDLE_ID'] ?? '(no BUNDLE_ID)';
final testTag = hasTest ? ' [+test]' : '';
Logger.info('• ${client.padRight(width)} $appName · $bundleId$testTag');
}
Logger.info('');
Logger.info('Build one with: udara_cli build --client <name>');
}