diff --git a/lib/src/commands/create/create_app_command.dart b/lib/src/commands/create/create_app_command.dart index 7c170ca..8c46ba4 100644 --- a/lib/src/commands/create/create_app_command.dart +++ b/lib/src/commands/create/create_app_command.dart @@ -2,6 +2,7 @@ import 'dart:async'; import 'dart:io'; import 'package:args/command_runner.dart'; +import 'package:recase/recase.dart'; import 'package:stacked_cli/src/constants/command_constants.dart'; import 'package:stacked_cli/src/constants/config_constants.dart'; import 'package:stacked_cli/src/constants/message_constants.dart'; @@ -80,10 +81,26 @@ class CreateAppCommand extends Command { configFilePath: argResults![ksConfigPath], ); - final workingDirectory = argResults!.rest.first; - final appName = workingDirectory.split('/').last; final templateType = argResults![ksTemplateType]; + // appName validation and recasing + final List workingDirectoryList = + argResults!.rest.first.split('/'); + final String originalAppName = workingDirectoryList.removeLast(); + final String appName = ReCase(originalAppName).snakeCase; + if (originalAppName != appName) { + _log.info( + message: + '$originalAppName is not snake_case as required by dart, did you mean $appName? [Y/N]'); + String input; + do { + input = stdin.readLineSync()?.toUpperCase().trim() ?? ''; + } while (!(input == 'Y' || input == 'N')); + input == 'N' ? throw 'error: project name not snake_case' : {}; + } + workingDirectoryList.add(appName); + final workingDirectory = workingDirectoryList.join('/'); + _processService.formattingLineLength = argResults![ksLineLength]; await _processService.runCreateApp( name: workingDirectory,