OLD | NEW |
1 library pub.validator.dependency; | 1 library pub.validator.dependency; |
2 import 'dart:async'; | 2 import 'dart:async'; |
| 3 import 'package:pub_semver/pub_semver.dart'; |
3 import '../entrypoint.dart'; | 4 import '../entrypoint.dart'; |
4 import '../log.dart' as log; | 5 import '../log.dart' as log; |
5 import '../package.dart'; | 6 import '../package.dart'; |
6 import '../validator.dart'; | 7 import '../validator.dart'; |
7 import '../version.dart'; | |
8 class DependencyValidator extends Validator { | 8 class DependencyValidator extends Validator { |
9 DependencyValidator(Entrypoint entrypoint) : super(entrypoint); | 9 DependencyValidator(Entrypoint entrypoint) : super(entrypoint); |
10 Future validate() { | 10 Future validate() { |
11 return Future.forEach(entrypoint.root.pubspec.dependencies, (dependency) { | 11 return Future.forEach(entrypoint.root.pubspec.dependencies, (dependency) { |
12 if (dependency.source != "hosted") { | 12 if (dependency.source != "hosted") { |
13 return _warnAboutSource(dependency); | 13 return _warnAboutSource(dependency); |
14 } | 14 } |
15 if (dependency.constraint.isAny) { | 15 if (dependency.constraint.isAny) { |
16 _warnAboutNoConstraint(dependency); | 16 _warnAboutNoConstraint(dependency); |
17 } else if (dependency.constraint is Version) { | 17 } else if (dependency.constraint is Version) { |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 'Without an upper bound, you\'re promising to support ' | 101 'Without an upper bound, you\'re promising to support ' |
102 '${log.bold("all")} future versions of ${dep.name}.'); | 102 '${log.bold("all")} future versions of ${dep.name}.'); |
103 } | 103 } |
104 String _constraintForVersion(Version version) => | 104 String _constraintForVersion(Version version) => |
105 '">=$version ${_upperBoundForVersion(version)}"'; | 105 '">=$version ${_upperBoundForVersion(version)}"'; |
106 String _upperBoundForVersion(Version version) { | 106 String _upperBoundForVersion(Version version) { |
107 if (version.major != 0) return '<${version.major + 1}.0.0'; | 107 if (version.major != 0) return '<${version.major + 1}.0.0'; |
108 return '<${version.major}.${version.minor + 1}.0'; | 108 return '<${version.major}.${version.minor + 1}.0'; |
109 } | 109 } |
110 } | 110 } |
OLD | NEW |