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) {
if (!isValidPackageName(projectName)) {
final String? potentialValidName = potentialValidPackageName(projectName);
return <String>[
'"$projectName" is not a valid Dart package name.',
'\n\n',
'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_].',
"Also, make sure the name is a valid Dart identifier—that it doesn't start with digits and isn't a reserved word.\n",
'See https://dart.dev/tools/pub/pubspec#name for more information.',
if (potentialValidName != null) '\nTry "$potentialValidName" instead.',
].join();
return '"$projectName" is not a valid Dart package name.'
'${ potentialValidName != null ? ' Try "$potentialValidName" instead.' : '' }\n'
'\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.';
}
if (_packageDependencies.contains(projectName)) {
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>[],
),
allOf(
throwsToolExit(message: '"xyz-xyz" is not a valid Dart package name.'),
throwsToolExit(message: 'Try "xyz_xyz" instead.'),
throwsToolExit(message:
'"xyz-xyz" is not a valid Dart package name. Try "xyz_xyz" instead.\n'
'\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.'
),
);
});