OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library validator; | 5 library validator; |
6 | 6 |
7 import 'entrypoint.dart'; | 7 import 'entrypoint.dart'; |
8 import 'log.dart' as log; | 8 import 'log.dart' as log; |
9 import 'io.dart'; | 9 import 'io.dart'; |
10 import 'system_cache.dart'; | 10 import 'system_cache.dart'; |
11 import 'utils.dart'; | 11 import 'utils.dart'; |
| 12 import 'validator/dependency.dart'; |
12 import 'validator/lib.dart'; | 13 import 'validator/lib.dart'; |
13 import 'validator/license.dart'; | 14 import 'validator/license.dart'; |
14 import 'validator/name.dart'; | 15 import 'validator/name.dart'; |
15 import 'validator/pubspec_field.dart'; | 16 import 'validator/pubspec_field.dart'; |
16 | 17 |
17 /// The base class for validators that check whether a package is fit for | 18 /// The base class for validators that check whether a package is fit for |
18 /// uploading. Each validator should override [errors], [warnings], or both to | 19 /// uploading. Each validator should override [errors], [warnings], or both to |
19 /// return lists of errors or warnings to display to the user. Errors will cause | 20 /// return lists of errors or warnings to display to the user. Errors will cause |
20 /// the package not to be uploaded; warnings will require the user to confirm | 21 /// the package not to be uploaded; warnings will require the user to confirm |
21 /// the upload. | 22 /// the upload. |
(...skipping 15 matching lines...) Expand all Loading... |
37 | 38 |
38 /// Run all validators on the [entrypoint] package and print their results. | 39 /// Run all validators on the [entrypoint] package and print their results. |
39 /// The future will complete with the error and warning messages, | 40 /// The future will complete with the error and warning messages, |
40 /// respectively. | 41 /// respectively. |
41 static Future<Pair<List<String>, List<String>>> runAll( | 42 static Future<Pair<List<String>, List<String>>> runAll( |
42 Entrypoint entrypoint) { | 43 Entrypoint entrypoint) { |
43 var validators = [ | 44 var validators = [ |
44 new LibValidator(entrypoint), | 45 new LibValidator(entrypoint), |
45 new LicenseValidator(entrypoint), | 46 new LicenseValidator(entrypoint), |
46 new NameValidator(entrypoint), | 47 new NameValidator(entrypoint), |
47 new PubspecFieldValidator(entrypoint) | 48 new PubspecFieldValidator(entrypoint), |
| 49 new DependencyValidator(entrypoint) |
48 ]; | 50 ]; |
49 | 51 |
50 // TODO(nweiz): The sleep 0 here forces us to go async. This works around | 52 // TODO(nweiz): The sleep 0 here forces us to go async. This works around |
51 // 3356, which causes a bug if all validators are (synchronously) using | 53 // 3356, which causes a bug if all validators are (synchronously) using |
52 // Future.immediate and an error is thrown before a handler is set up. | 54 // Future.immediate and an error is thrown before a handler is set up. |
53 return sleep(0).chain((_) { | 55 return sleep(0).chain((_) { |
54 return Futures.wait(validators.map((validator) => validator.validate())); | 56 return Futures.wait(validators.map((validator) => validator.validate())); |
55 }).transform((_) { | 57 }).transform((_) { |
56 var errors = flatten(validators.map((validator) => validator.errors)); | 58 var errors = flatten(validators.map((validator) => validator.errors)); |
57 var warnings = flatten(validators.map((validator) => validator.warnings)); | 59 var warnings = flatten(validators.map((validator) => validator.warnings)); |
(...skipping 11 matching lines...) Expand all Loading... |
69 for (var warning in warnings) { | 71 for (var warning in warnings) { |
70 log.warning("* ${Strings.join(warning.split('\n'), '\n ')}"); | 72 log.warning("* ${Strings.join(warning.split('\n'), '\n ')}"); |
71 } | 73 } |
72 log.warning(""); | 74 log.warning(""); |
73 } | 75 } |
74 | 76 |
75 return new Pair<List<String>, List<String>>(errors, warnings); | 77 return new Pair<List<String>, List<String>>(errors, warnings); |
76 }); | 78 }); |
77 } | 79 } |
78 } | 80 } |
OLD | NEW |