-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Expand file tree
/
Copy pathdependabot_check_command.dart
More file actions
64 lines (47 loc) · 1.76 KB
/
dependabot_check_command.dart
File metadata and controls
64 lines (47 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// Copyright 2013 The Flutter Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:file/file.dart';
import 'common/package_looping_command.dart';
import 'common/repository_package.dart';
import 'validators/dependabot_validator.dart';
/// A command to verify Dependabot configuration coverage of packages.
class DependabotCheckCommand extends PackageLoopingCommand {
/// Creates Dependabot check command instance.
DependabotCheckCommand(super.packagesDir, {super.gitDir});
late Directory _repoRoot;
// The set of directories covered by the repo's Dependabot configuration.
late DependabotCoverage _coverage;
@override
final String name = 'dependabot-check';
@override
List<String> get aliases => <String>['check-dependabot'];
@override
final String description =
'Checks that all packages have Dependabot coverage.';
@override
final PackageLoopingType packageLoopingType =
PackageLoopingType.includeAllSubpackages;
@override
final bool hasLongOutput = false;
@override
Future<void> initializeRun() async {
_repoRoot = packagesDir.fileSystem.directory((await gitDir).path);
_coverage = DependabotValidator.loadConfig(repoRoot: _repoRoot);
}
@override
Future<PackageResult> runForPackage(RepositoryPackage package) async {
final validator = DependabotValidator(
coverage: _coverage,
path: path,
repoRoot: _repoRoot,
indentation: indentation,
);
final errors = <String>[];
errors.addAll(validator.validateDependabotCoverage(package));
// TODO(stuartmorgan): Add other ecosystem checks here as more are enabled.
return errors.isEmpty
? PackageResult.success()
: PackageResult.fail(errors);
}
}