scaffoldProject function
Generates all necessary files for a new Cardinal project.
Implementation
Future<void> scaffoldProject(String projectName) async {
final functionName = 'run${projectName.pascalCase}';
final dataRunner = {
'projectName': projectName.snakeCase,
'functionName': functionName,
};
// 1. cardinal.yaml
await generateFile(
rootPath: projectName,
templateContent: CARDINAL_YAML_TPL,
relativePath: 'cardinal.yaml',
data: {},
);
// 2. pubspec.yaml
await generateFile(
rootPath: projectName,
templateContent: PUBSPEC_YAML_TPL,
relativePath: 'pubspec.yaml',
data: {'projectName': projectName.snakeCase},
);
// 3. bin/$projectName.dart (Entrypoint)
await generateFile(
rootPath: projectName,
templateContent: ENTRYPOINT_DART_TPL,
relativePath: 'bin/${projectName.snakeCase}.dart',
data: dataRunner,
);
// 4. lib/$projectName.dart (App Runner Logic)
await generateFile(
rootPath: projectName,
templateContent: APP_DART_TPL,
relativePath: 'lib/${projectName.snakeCase}.dart',
data: dataRunner,
);
// 5. lib/commands/hello_command.dart (Example Command)
await generateFile(
rootPath: projectName,
templateContent: COMMAND_DART_TPL,
relativePath: 'lib/commands/hello_command.dart',
data: {'commandName': 'hello', 'commandClassName': 'HelloCommand'},
);
// 6. test/projectName_test.dart
await generateFile(
rootPath: projectName,
templateContent: TEST_DART_TPL,
relativePath: 'test/${projectName.snakeCase}_test.dart',
data: {},
);
}