OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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.sdk_constraint; | |
6 | |
7 import 'dart:async'; | 5 import 'dart:async'; |
8 | 6 |
9 import '../entrypoint.dart'; | 7 import '../entrypoint.dart'; |
10 import '../validator.dart'; | 8 import '../validator.dart'; |
11 | 9 |
12 /// A validator that validates that a package's SDK constraint doesn't use the | 10 /// A validator that validates that a package's SDK constraint doesn't use the |
13 /// "^" syntax. | 11 /// "^" syntax. |
14 class SdkConstraintValidator extends Validator { | 12 class SdkConstraintValidator extends Validator { |
15 SdkConstraintValidator(Entrypoint entrypoint) | 13 SdkConstraintValidator(Entrypoint entrypoint) |
16 : super(entrypoint); | 14 : super(entrypoint); |
17 | 15 |
18 Future validate() async { | 16 Future validate() async { |
19 var constraint = entrypoint.root.pubspec.environment.sdkVersion; | 17 var constraint = entrypoint.root.pubspec.environment.sdkVersion; |
20 if (!constraint.toString().startsWith("^")) return; | 18 if (!constraint.toString().startsWith("^")) return; |
21 | 19 |
22 errors.add( | 20 errors.add( |
23 "^ version constraints aren't allowed for SDK constraints since " | 21 "^ version constraints aren't allowed for SDK constraints since " |
24 "older versions of pub don't support them.\n" | 22 "older versions of pub don't support them.\n" |
25 "Expand it manually instead:\n" | 23 "Expand it manually instead:\n" |
26 "\n" | 24 "\n" |
27 "environment:\n" | 25 "environment:\n" |
28 " sdk: \">=${constraint.min} <${constraint.max}\""); | 26 " sdk: \">=${constraint.min} <${constraint.max}\""); |
29 } | 27 } |
30 } | 28 } |
OLD | NEW |