start method
Presents the interactive prompts and returns the resolved WizardConfig.
Implementation
WizardConfig start() {
_printBanner();
final targetPath = _prompt(
'π Enter the target path to migrate',
defaultValue: 'lib',
);
final detectedLibs = _detectLibraries(targetPath);
if (detectedLibs.isNotEmpty) {
print('\n\x1B[33mπ Detected state management libraries:\x1B[0m');
for (final lib in detectedLibs) {
print(' β’ $lib');
}
final proceed = _promptYesNo(
'\nProceed with migrating these to Riverpod?',
defaultYes: true,
);
if (!proceed) {
print('\x1B[31mMigration cancelled.\x1B[0m');
exit(0);
}
} else {
print(
'\n\x1B[90m (No known state management libraries detected in pubspec.yaml)\x1B[0m',
);
}
print('\n\x1B[1mWhich migration mode would you like to use?\x1B[0m');
print(
' \x1B[36m1.\x1B[0m safe β Analyze only, inject TODO comments',
);
print(
' \x1B[36m2.\x1B[0m assisted β Generate Riverpod files alongside old code',
);
print(
' \x1B[36m3.\x1B[0m aggressive β Fully rewrite and replace legacy code',
);
final modeChoice = _prompt('Select mode (1β3)', defaultValue: '3');
final mode = _mapMode(modeChoice);
print('');
final dryRun = _promptYesNo(
'ποΈ Preview changes without writing files (dry run)?',
);
final cleanImports = _promptYesNo(
'π§Ή Auto-clean unused Provider imports after migration?',
defaultYes: true,
);
final generateReport = _promptYesNo(
'π Generate a migration_report.json audit file?',
defaultYes: true,
);
final visualize = _promptYesNo(
'πΊοΈ Generate a provider dependency graph (Mermaid format)?',
);
final useAi = _promptYesNo(
'π€ Enable AI-assisted logic refactoring (requires local LLM)?',
);
final config = WizardConfig(
targetPath: targetPath,
mode: mode,
useAi: useAi,
dryRun: dryRun,
cleanImports: cleanImports,
generateReport: generateReport,
visualize: visualize,
);
_saveConfig(config);
return config;
}