setup method
Sets up the project using the provided config and template.
Returns whether the project setup process completed successfully.
Implementation
Future<bool> setup({
required InitConfig config,
required TemplateDefinition template,
}) async {
final setup = template.setup;
if (setup.modules.isEmpty && setup.features.isEmpty && !setup.bootstrap.enabled) {
LoggerService.warning(
'No project setup configuration found for template '
'"${template.name}".',
);
return false;
}
final pubspec = PubspecService();
await _prepareProject(
config: config,
);
await _collectTemplateRequirements(
template: template,
pubspec: pubspec,
);
final moduleRequiresBuildRunner = await _installModules(
config: config,
template: template,
modules: setup.modules,
pubspec: pubspec,
);
// Synchronize all collected template and module dependencies once.
await pubspec.save();
final featuresGenerated = await _generateFeatures(
config: config,
template: template,
features: setup.features,
);
await const ProjectBootstrapService().bootstrap(
config: config,
template: template,
);
await FlutterService(config).postGenerate(
buildRunner: template.requirements.buildRunner || moduleRequiresBuildRunner || featuresGenerated,
);
return true;
}