mirror of
https://github.com/flutter/packages.git
synced 2025-08-06 17:28:42 +08:00
Require authors file (#4367)
Adds a check to `publish-check` that there is an AUTHORS file present, since our license refers to "The Flutter Authors", so we want to have a file distributed with each package that says who the AUTHORS are (vs. just having a top-level repo AUTHORS file, which is not part of package distribution). Adds AUTHORS files to packages that have been created since the earlier one-time fix that added them, but didn't add a check to prevent future issues. Also updates the publish-check failure tests to include checks for specific output so that we know that they are failing for the reasons the test is expecting, bringing them up to current repo standards for failure tests. Fixes https://github.com/flutter/flutter/issues/89680
This commit is contained in:
@ -77,10 +77,17 @@ class PublishCheckCommand extends PackageLoopingCommand {
|
||||
|
||||
@override
|
||||
Future<PackageResult> runForPackage(RepositoryPackage package) async {
|
||||
final _PublishCheckResult? result = await _passesPublishCheck(package);
|
||||
_PublishCheckResult? result = await _passesPublishCheck(package);
|
||||
if (result == null) {
|
||||
return PackageResult.skip('Package is marked as unpublishable.');
|
||||
}
|
||||
if (!_passesAuthorsCheck(package)) {
|
||||
_printImportantStatusMessage(
|
||||
'No AUTHORS file found. Packages must include an AUTHORS file.',
|
||||
isError: true);
|
||||
result = _PublishCheckResult.error;
|
||||
}
|
||||
|
||||
if (result.index > _overallResult.index) {
|
||||
_overallResult = result;
|
||||
}
|
||||
@ -189,7 +196,7 @@ class PublishCheckCommand extends PackageLoopingCommand {
|
||||
final String packageName = package.directory.basename;
|
||||
final Pubspec? pubspec = _tryParsePubspec(package);
|
||||
if (pubspec == null) {
|
||||
print('no pubspec');
|
||||
print('No valid pubspec found.');
|
||||
return _PublishCheckResult.error;
|
||||
} else if (pubspec.publishTo == 'none') {
|
||||
return null;
|
||||
@ -239,6 +246,16 @@ HTTP response: ${pubVersionFinderResponse.httpResponse.body}
|
||||
}
|
||||
}
|
||||
|
||||
bool _passesAuthorsCheck(RepositoryPackage package) {
|
||||
final List<String> pathComponents =
|
||||
package.directory.fileSystem.path.split(package.directory.path);
|
||||
if (pathComponents.contains('third_party')) {
|
||||
// Third-party packages aren't required to have an AUTHORS file.
|
||||
return true;
|
||||
}
|
||||
return package.directory.childFile('AUTHORS').existsSync();
|
||||
}
|
||||
|
||||
void _printImportantStatusMessage(String message, {required bool isError}) {
|
||||
final String statusMessage = '${isError ? 'ERROR' : 'SUCCESS'}: $message';
|
||||
if (getBoolArg(_machineFlag)) {
|
||||
|
Reference in New Issue
Block a user