mirror of
https://github.com/flutter/packages.git
synced 2025-08-06 17:28:42 +08:00
[flutter_plugin_tools] Improve 'repository' check (#4244)
Ensures that the full relative path in the 'repository' link is correct, not just the last segment. This ensure that path-level errors (e.g., linking to the group directory rather than the package itself for app-facing packages) are caught. Also fixes the errors that this improved check catches, including several cases where a previously unfederated package wasn't fixed when it was moved to a subdirectory.
This commit is contained in:
@ -98,7 +98,7 @@ class PubspecCheckCommand extends PackageLoopingCommand {
|
||||
|
||||
if (pubspec.publishTo != 'none') {
|
||||
final List<String> repositoryErrors =
|
||||
_checkForRepositoryLinkErrors(pubspec, packageName: package.basename);
|
||||
_checkForRepositoryLinkErrors(pubspec, package: package);
|
||||
if (repositoryErrors.isNotEmpty) {
|
||||
for (final String error in repositoryErrors) {
|
||||
printError('$indentation$error');
|
||||
@ -154,14 +154,18 @@ class PubspecCheckCommand extends PackageLoopingCommand {
|
||||
|
||||
List<String> _checkForRepositoryLinkErrors(
|
||||
Pubspec pubspec, {
|
||||
required String packageName,
|
||||
required Directory package,
|
||||
}) {
|
||||
final List<String> errorMessages = <String>[];
|
||||
if (pubspec.repository == null) {
|
||||
errorMessages.add('Missing "repository"');
|
||||
} else if (!pubspec.repository!.path.endsWith(packageName)) {
|
||||
errorMessages
|
||||
.add('The "repository" link should end with the package name.');
|
||||
} else {
|
||||
final String relativePackagePath =
|
||||
path.relative(package.path, from: packagesDir.parent.path);
|
||||
if (!pubspec.repository!.path.endsWith(relativePackagePath)) {
|
||||
errorMessages
|
||||
.add('The "repository" link should end with the package path.');
|
||||
}
|
||||
}
|
||||
|
||||
if (pubspec.homepage != null) {
|
||||
|
Reference in New Issue
Block a user