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 pub.validator.dependency; | 5 library pub.validator.dependency; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 | 8 |
| 9 import 'package:pub_semver/pub_semver.dart'; |
| 10 |
9 import '../entrypoint.dart'; | 11 import '../entrypoint.dart'; |
10 import '../log.dart' as log; | 12 import '../log.dart' as log; |
11 import '../package.dart'; | 13 import '../package.dart'; |
12 import '../validator.dart'; | 14 import '../validator.dart'; |
13 import '../version.dart'; | |
14 | 15 |
15 /// A validator that validates a package's dependencies. | 16 /// A validator that validates a package's dependencies. |
16 class DependencyValidator extends Validator { | 17 class DependencyValidator extends Validator { |
17 DependencyValidator(Entrypoint entrypoint) | 18 DependencyValidator(Entrypoint entrypoint) |
18 : super(entrypoint); | 19 : super(entrypoint); |
19 | 20 |
20 Future validate() { | 21 Future validate() { |
21 return Future.forEach(entrypoint.root.pubspec.dependencies, (dependency) { | 22 return Future.forEach(entrypoint.root.pubspec.dependencies, (dependency) { |
22 if (dependency.source != "hosted") { | 23 if (dependency.source != "hosted") { |
23 return _warnAboutSource(dependency); | 24 return _warnAboutSource(dependency); |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 String _constraintForVersion(Version version) => | 145 String _constraintForVersion(Version version) => |
145 '">=$version ${_upperBoundForVersion(version)}"'; | 146 '">=$version ${_upperBoundForVersion(version)}"'; |
146 | 147 |
147 /// Returns the suggested upper bound for a dependency that was tested against | 148 /// Returns the suggested upper bound for a dependency that was tested against |
148 /// [version]. | 149 /// [version]. |
149 String _upperBoundForVersion(Version version) { | 150 String _upperBoundForVersion(Version version) { |
150 if (version.major != 0) return '<${version.major + 1}.0.0'; | 151 if (version.major != 0) return '<${version.major + 1}.0.0'; |
151 return '<${version.major}.${version.minor + 1}.0'; | 152 return '<${version.major}.${version.minor + 1}.0'; |
152 } | 153 } |
153 } | 154 } |
OLD | NEW |