Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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'; |
| 11 import '../path_source.dart'; | |
| 11 import '../http.dart'; | 12 import '../http.dart'; |
| 12 import '../package.dart'; | 13 import '../package.dart'; |
| 13 import '../utils.dart'; | 14 import '../utils.dart'; |
| 14 import '../validator.dart'; | 15 import '../validator.dart'; |
| 15 import '../version.dart'; | 16 import '../version.dart'; |
| 16 | 17 |
| 17 /// A validator that validates a package's dependencies. | 18 /// A validator that validates a package's dependencies. |
| 18 class DependencyValidator extends Validator { | 19 class DependencyValidator extends Validator { |
| 19 DependencyValidator(Entrypoint entrypoint) | 20 DependencyValidator(Entrypoint entrypoint) |
| 20 : super(entrypoint); | 21 : super(entrypoint); |
| 21 | 22 |
| 22 Future validate() { | 23 Future validate() { |
| 23 return Future.forEach(entrypoint.root.pubspec.dependencies, (dependency) { | 24 return Futures.forEach(entrypoint.root.pubspec.dependencies, (dependency) { |
| 25 if (dependency.source is PathSource){ | |
| 26 errors.add('"${dependency.name}" dependancy package must be defined ' | |
| 27 'using "hosted" or "git" source.'); | |
| 28 return new Future.immediate(null); | |
| 29 } | |
|
Bob Nystrom
2013/01/17 19:15:10
Let's reuse the _warnAboutSource method here since
Sam E
2013/01/20 04:16:57
I don't think this is going to work. The logic is
| |
| 24 if (dependency.source is! HostedSource) { | 30 if (dependency.source is! HostedSource) { |
| 25 return _warnAboutSource(dependency); | 31 return _warnAboutSource(dependency); |
| 26 } | 32 } |
| 27 | 33 |
| 28 if (dependency.name == entrypoint.root.name) { | 34 if (dependency.name == entrypoint.root.name) { |
| 29 warnings.add('You don\'t need to explicitly depend on your own ' | 35 warnings.add('You don\'t need to explicitly depend on your own ' |
| 30 'package.\n' | 36 'package.\n' |
| 31 'Pub enables "package:${entrypoint.root.name}" imports ' | 37 'Pub enables "package:${entrypoint.root.name}" imports ' |
| 32 'implicitly.'); | 38 'implicitly.'); |
| 33 return new Future.immediate(null); | 39 return new Future.immediate(null); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 92 } | 98 } |
| 93 | 99 |
| 94 /// Returns the suggested version constraint for a dependency that was tested | 100 /// Returns the suggested version constraint for a dependency that was tested |
| 95 /// against [version]. | 101 /// against [version]. |
| 96 String _constraintForVersion(Version version) { | 102 String _constraintForVersion(Version version) { |
| 97 if (version.major != 0) return '">=$version <${version.major + 1}.0.0"'; | 103 if (version.major != 0) return '">=$version <${version.major + 1}.0.0"'; |
| 98 return '">=$version <${version.major}.${version.minor}.' | 104 return '">=$version <${version.major}.${version.minor}.' |
| 99 '${version.patch + 1}"'; | 105 '${version.patch + 1}"'; |
| 100 } | 106 } |
| 101 } | 107 } |
| OLD | NEW |