Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(311)

Side by Side Diff: lib/src/validator/sdk_constraint.dart

Issue 2184303002: Make pub strong-mode clean. (Closed) Base URL: git@github.com:dart-lang/pub.git@master
Patch Set: Code review changes Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « lib/src/validator/dependency.dart ('k') | pubspec.yaml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 import 'dart:async'; 5 import 'dart:async';
6 6
7 import 'package:pub_semver/pub_semver.dart'; 7 import 'package:pub_semver/pub_semver.dart';
8 8
9 import '../entrypoint.dart'; 9 import '../entrypoint.dart';
10 import '../validator.dart'; 10 import '../validator.dart';
11 11
12 /// The range of all Dart SDK versions that don't support Flutter SDK 12 /// The range of all Dart SDK versions that don't support Flutter SDK
13 /// constraints. 13 /// constraints.
14 final _preFlutterSupport = new VersionConstraint.parse("<1.19.0"); 14 final _preFlutterSupport = new VersionConstraint.parse("<1.19.0");
15 15
16 /// A validator that validates that a package's SDK constraint doesn't use the 16 /// A validator that validates that a package's SDK constraint doesn't use the
17 /// "^" syntax. 17 /// "^" syntax.
18 class SdkConstraintValidator extends Validator { 18 class SdkConstraintValidator extends Validator {
19 SdkConstraintValidator(Entrypoint entrypoint) 19 SdkConstraintValidator(Entrypoint entrypoint)
20 : super(entrypoint); 20 : super(entrypoint);
21 21
22 Future validate() async { 22 Future validate() async {
23 var dartConstraint = entrypoint.root.pubspec.dartSdkConstraint; 23 var dartConstraint = entrypoint.root.pubspec.dartSdkConstraint;
24 if (dartConstraint.toString().startsWith("^")) { 24 if (dartConstraint is VersionRange &&
25 dartConstraint.toString().startsWith("^")) {
25 errors.add( 26 errors.add(
26 "^ version constraints aren't allowed for SDK constraints since " 27 "^ version constraints aren't allowed for SDK constraints since "
27 "older versions of pub don't support them.\n" 28 "older versions of pub don't support them.\n"
28 "Expand it manually instead:\n" 29 "Expand it manually instead:\n"
29 "\n" 30 "\n"
30 "environment:\n" 31 "environment:\n"
31 " sdk: \">=${dartConstraint.min} <${dartConstraint.max}\""); 32 " sdk: \">=${dartConstraint.min} <${dartConstraint.max}\"");
32 } 33 }
33 34
34 if (entrypoint.root.pubspec.flutterSdkConstraint != null && 35 if (entrypoint.root.pubspec.flutterSdkConstraint != null &&
35 dartConstraint.allowsAny(_preFlutterSupport)) { 36 dartConstraint.allowsAny(_preFlutterSupport)) {
36 var newDartConstraint = dartConstraint.difference(_preFlutterSupport); 37 var newDartConstraint = dartConstraint.difference(_preFlutterSupport);
37 if (newDartConstraint.isEmpty || 38 if (newDartConstraint.isEmpty ||
38 newDartConstraint == 39 newDartConstraint ==
39 VersionConstraint.any.difference(_preFlutterSupport)) { 40 VersionConstraint.any.difference(_preFlutterSupport)) {
40 newDartConstraint = new VersionConstraint.parse("<2.0.0") 41 newDartConstraint = new VersionConstraint.parse("<2.0.0")
41 .difference(_preFlutterSupport); 42 .difference(_preFlutterSupport);
42 } 43 }
43 44
44 errors.add( 45 errors.add(
45 "Older versions of pub don't support Flutter SDK constraints.\n" 46 "Older versions of pub don't support Flutter SDK constraints.\n"
46 "Make sure your SDK constraint excludes those old versions:\n" 47 "Make sure your SDK constraint excludes those old versions:\n"
47 "\n" 48 "\n"
48 "environment:\n" 49 "environment:\n"
49 " sdk: \"$newDartConstraint\""); 50 " sdk: \"$newDartConstraint\"");
50 } 51 }
51 } 52 }
52 } 53 }
OLDNEW
« no previous file with comments | « lib/src/validator/dependency.dart ('k') | pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698