run method
Runs the generation pipeline using the selected plugins.
Implementation
Future<void> run(ProjectContext context) async {
Logger.header('GENERATION PIPELINE STARTING');
Logger.detail('Project Name', context.projectName);
Logger.detail('Output Path', context.projectPath);
Logger.detail('Architecture', context.architecture.label);
Logger.detail('State Management', context.stateManagement.label);
Logger.detail('Routing', context.routing.label);
Logger.detail('UI Theme', context.theme.label);
Logger.detail('Primary Color', context.primaryColor);
Logger.detail('Dark Mode', context.darkMode ? 'Enabled' : 'Disabled');
if (context.packages.isNotEmpty) {
Logger.detail('Selected Packages', context.packages.join(', '));
}
// Filter plugins that should execute for this specific ProjectContext
final activePlugins = _registeredPlugins.where((plugin) {
return _isPluginEnabled(plugin.id, context);
}).toList();
// Sort active plugins so they run in a deterministic, logical order:
// 1. base
// 2. architecture
// 3. packages/libraries (networking, storage, utilities)
// 4. state management
// 5. routing
// 6. styling / theme
// 7. post_process (pub get, build_runner)
activePlugins.sort((a, b) => _getExecutionOrder(a.id).compareTo(_getExecutionOrder(b.id)));
Logger.info('\nExecuting ${activePlugins.length} active plugins:');
for (int i = 0; i < activePlugins.length; i++) {
final plugin = activePlugins[i];
final stepNum = i + 1;
Logger.step('[$stepNum/${activePlugins.length}] Running plugin: ${plugin.id}...');
try {
await plugin.generate(context);
Logger.success('Plugin ${plugin.id} completed successfully.');
} catch (e) {
Logger.error('Plugin ${plugin.id} failed during execution.');
if (e is CliException) {
rethrow;
} else {
throw CliException('Unexpected error in plugin ${plugin.id}', e);
}
}
}
Logger.header('PROJECT GENERATION COMPLETE');
}