Fix line-wrapping in flutter create error message. (#150325)

This commit is contained in:
Ian Hickson 2024-09-26 10:04:03 -07:00 committed by GitHub
parent a0e75cd309
commit 20bc0a9cb8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 18 additions and 13 deletions

View File

@ -857,16 +857,15 @@ String? potentialValidPackageName(String name){
String? _validateProjectName(String projectName) { String? _validateProjectName(String projectName) {
if (!isValidPackageName(projectName)) { if (!isValidPackageName(projectName)) {
final String? potentialValidName = potentialValidPackageName(projectName); final String? potentialValidName = potentialValidPackageName(projectName);
return '"$projectName" is not a valid Dart package name.'
return <String>[ '${ potentialValidName != null ? ' Try "$potentialValidName" instead.' : '' }\n'
'"$projectName" is not a valid Dart package name.', '\n'
'\n\n', 'The name should consist of lowercase words separated by underscores, "like_this". '
'The name should be all lowercase, with underscores to separate words, "just_like_this".', 'Use only basic Latin letters and Arabic digits: [a-z0-9_], and '
'Use only basic Latin letters and Arabic digits: [a-z0-9_].', 'ensure the name is a valid Dart identifier '
"Also, make sure the name is a valid Dart identifier—that it doesn't start with digits and isn't a reserved word.\n", '(i.e. it does not start with a digit and is not a reserved word).\n'
'See https://dart.dev/tools/pub/pubspec#name for more information.', '\n'
if (potentialValidName != null) '\nTry "$potentialValidName" instead.', 'See https://dart.dev/tools/pub/pubspec#name for more information.';
].join();
} }
if (_packageDependencies.contains(projectName)) { if (_packageDependencies.contains(projectName)) {
return "Invalid project name: '$projectName' - this will conflict with Flutter " return "Invalid project name: '$projectName' - this will conflict with Flutter "

View File

@ -838,9 +838,15 @@ void main() {
<String>['--no-pub', '--template=plugin', '--project-name', 'xyz-xyz', '--platforms', 'android,ios',], <String>['--no-pub', '--template=plugin', '--project-name', 'xyz-xyz', '--platforms', 'android,ios',],
<String>[], <String>[],
), ),
allOf( throwsToolExit(message:
throwsToolExit(message: '"xyz-xyz" is not a valid Dart package name.'), '"xyz-xyz" is not a valid Dart package name. Try "xyz_xyz" instead.\n'
throwsToolExit(message: 'Try "xyz_xyz" instead.'), '\n'
'The name should consist of lowercase words separated by underscores, '
'"like_this". Use only basic Latin letters and Arabic digits: [a-z0-9_], '
'and ensure the name is a valid Dart identifier (i.e. it does not start '
'with a digit and is not a reserved word).\n'
'\n'
'See https://dart.dev/tools/pub/pubspec#name for more information.'
), ),
); );
}); });