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 dependency_validator; | 5 library dependency_validator; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 | 8 |
9 import '../entrypoint.dart'; | 9 import '../entrypoint.dart'; |
10 import '../hosted_source.dart'; | 10 import '../hosted_source.dart'; |
(...skipping 16 matching lines...) Expand all Loading... | |
27 } | 27 } |
28 | 28 |
29 if (dependency.name == entrypoint.root.name) { | 29 if (dependency.name == entrypoint.root.name) { |
30 warnings.add('You don\'t need to explicitly depend on your own ' | 30 warnings.add('You don\'t need to explicitly depend on your own ' |
31 'package.\n' | 31 'package.\n' |
32 'Pub enables "package:${entrypoint.root.name}" imports ' | 32 'Pub enables "package:${entrypoint.root.name}" imports ' |
33 'implicitly.'); | 33 'implicitly.'); |
34 return new Future.immediate(null); | 34 return new Future.immediate(null); |
35 } | 35 } |
36 | 36 |
37 if (dependency.constraint.isAny && | 37 if (dependency.constraint.isAny) _warnAboutConstraint(dependency); |
38 // TODO(nweiz): once we have development dependencies (issue 5358), we | |
39 // should warn about unittest. Until then, it's reasonable not to put | |
40 // a constraint on it. | |
41 dependency.name != 'unittest') { | |
42 _warnAboutConstraint(dependency); | |
43 } | |
nweiz
2013/03/15 18:21:54
Should we maybe suggest that people use a dev depe
Bob Nystrom
2013/03/15 18:31:56
I think the fix for users here is pretty simple, s
| |
44 | 38 |
45 return new Future.immediate(null); | 39 return new Future.immediate(null); |
46 }); | 40 }); |
47 } | 41 } |
48 | 42 |
49 /// Warn that dependencies should use the hosted source. | 43 /// Warn that dependencies should use the hosted source. |
50 Future _warnAboutSource(PackageRef ref) { | 44 Future _warnAboutSource(PackageRef ref) { |
51 return entrypoint.cache.sources['hosted'] | 45 return entrypoint.cache.sources['hosted'] |
52 .getVersions(ref.name, ref.name) | 46 .getVersions(ref.name, ref.name) |
53 .catchError((e) => <Version>[]) | 47 .catchError((e) => <Version>[]) |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
98 } | 92 } |
99 | 93 |
100 /// Returns the suggested version constraint for a dependency that was tested | 94 /// Returns the suggested version constraint for a dependency that was tested |
101 /// against [version]. | 95 /// against [version]. |
102 String _constraintForVersion(Version version) { | 96 String _constraintForVersion(Version version) { |
103 if (version.major != 0) return '">=$version <${version.major + 1}.0.0"'; | 97 if (version.major != 0) return '">=$version <${version.major + 1}.0.0"'; |
104 return '">=$version <${version.major}.${version.minor}.' | 98 return '">=$version <${version.major}.${version.minor}.' |
105 '${version.patch + 1}"'; | 99 '${version.patch + 1}"'; |
106 } | 100 } |
107 } | 101 } |
OLD | NEW |