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 '../entrypoint.dart'; | 7 import '../entrypoint.dart'; |
8 import '../hosted_source.dart'; | 8 import '../hosted_source.dart'; |
9 import '../http.dart'; | 9 import '../http.dart'; |
10 import '../package.dart'; | 10 import '../package.dart'; |
(...skipping 13 matching lines...) Expand all Loading... | |
24 } | 24 } |
25 | 25 |
26 if (dependency.constraint.isAny && | 26 if (dependency.constraint.isAny && |
27 // TODO(nweiz): once we have development dependencies (issue 5358), we | 27 // TODO(nweiz): once we have development dependencies (issue 5358), we |
28 // should warn about unittest. Until then, it's reasonable not to put | 28 // should warn about unittest. Until then, it's reasonable not to put |
29 // a constraint on it. | 29 // a constraint on it. |
30 dependency.name != 'unittest') { | 30 dependency.name != 'unittest') { |
31 return _warnAboutConstraint(dependency); | 31 return _warnAboutConstraint(dependency); |
32 } | 32 } |
33 | 33 |
34 if (dependency.name == entrypoint.root.name) { | |
35 warnings.add('You don\'t need to explicitly depend on your own ' | |
36 'package.\n' | |
37 'Pub will make "package:${entrypoint.root.name}" imports work ' | |
38 'automatically.'); | |
Bob Nystrom
2013/01/03 20:52:45
I find the future tense here a bit confusing. How
nweiz
2013/01/03 21:08:12
Done.
| |
39 return; | |
40 } | |
41 | |
34 return new Future.immediate(null); | 42 return new Future.immediate(null); |
35 }); | 43 }); |
36 } | 44 } |
37 | 45 |
38 /// Warn that dependencies should use the hosted source. | 46 /// Warn that dependencies should use the hosted source. |
39 Future _warnAboutSource(PackageRef ref) { | 47 Future _warnAboutSource(PackageRef ref) { |
40 return entrypoint.cache.sources['hosted'] | 48 return entrypoint.cache.sources['hosted'] |
41 .getVersions(ref.name, ref.name) | 49 .getVersions(ref.name, ref.name) |
42 .transformException((e) => <Version>[]) | 50 .transformException((e) => <Version>[]) |
43 .transform((versions) { | 51 .transform((versions) { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
82 } | 90 } |
83 | 91 |
84 /// Returns the suggested version constraint for a dependency that was tested | 92 /// Returns the suggested version constraint for a dependency that was tested |
85 /// against [version]. | 93 /// against [version]. |
86 String _constraintForVersion(Version version) { | 94 String _constraintForVersion(Version version) { |
87 if (version.major != 0) return '">=$version <${version.major + 1}.0.0"'; | 95 if (version.major != 0) return '">=$version <${version.major + 1}.0.0"'; |
88 return '">=$version <${version.major}.${version.minor}.' | 96 return '">=$version <${version.major}.${version.minor}.' |
89 '${version.patch + 1}"'; | 97 '${version.patch + 1}"'; |
90 } | 98 } |
91 } | 99 } |
OLD | NEW |