| Index: lib/src/entrypoint.dart
|
| diff --git a/lib/src/entrypoint.dart b/lib/src/entrypoint.dart
|
| index 360a6ca5d0c44eba2cf382b05ae2fb5f640d4f45..cc58a3e3ed214e8278c9390c7a4091a890eb2c0c 100644
|
| --- a/lib/src/entrypoint.dart
|
| +++ b/lib/src/entrypoint.dart
|
| @@ -12,6 +12,7 @@ import 'package:pub_semver/pub_semver.dart';
|
|
|
| import 'barback/asset_environment.dart';
|
| import 'exceptions.dart';
|
| +import 'flutter.dart' as flutter;
|
| import 'io.dart';
|
| import 'lock_file.dart';
|
| import 'log.dart' as log;
|
| @@ -24,8 +25,26 @@ import 'source/unknown.dart';
|
| import 'system_cache.dart';
|
| import 'utils.dart';
|
|
|
| -/// A RegExp to match the SDK constraint in a lock file.
|
| -final _sdkConstraint = new RegExp(r'^sdk: "?([^"]*)"?$', multiLine: true);
|
| +/// A RegExp to match the Dart SDK constraint in a lock file.
|
| +///
|
| +/// This matches both the old-style constraint:
|
| +///
|
| +/// ```yaml
|
| +/// sdk: ">=1.2.3 <2.0.0"
|
| +/// ```
|
| +///
|
| +/// and the new-style constraint:
|
| +///
|
| +/// ```yaml
|
| +/// sdks:
|
| +/// dart: ">=1.2.3 <2.0.0"
|
| +/// ```
|
| +final _dartSdkConstraint =
|
| + new RegExp(r'^( dart|sdk): "?([^"]*)"?$', multiLine: true);
|
| +
|
| +/// A RegExp to match the Flutter SDK constraint in a lock file.
|
| +final _flutterSdkConstraint =
|
| + new RegExp(r'^ flutter: "?([^"]*)"?$', multiLine: true);
|
|
|
| /// The context surrounding the root package pub is operating on.
|
| ///
|
| @@ -489,14 +508,29 @@ class Entrypoint {
|
| touch(packagesFile);
|
| }
|
|
|
| - var sdkConstraint = _sdkConstraint.firstMatch(lockFileText);
|
| - if (sdkConstraint != null) {
|
| - var parsedConstraint = new VersionConstraint.parse(sdkConstraint[1]);
|
| + var dartSdkConstraint = _dartSdkConstraint.firstMatch(lockFileText);
|
| + if (dartSdkConstraint != null) {
|
| + var parsedConstraint = new VersionConstraint.parse(dartSdkConstraint[2]);
|
| if (!parsedConstraint.allows(sdk.version)) {
|
| dataError("Dart ${sdk.version} is incompatible with your dependencies' "
|
| "SDK constraints. Please run \"pub get\" again.");
|
| }
|
| }
|
| +
|
| + // Don't complain if there's a Flutter constraint but Flutter is
|
| + // unavailable. Flutter being unavailable just means that we aren't running
|
| + // from within the `flutter` executable, and we want users to be able to
|
| + // `pub run` non-Flutter tools even in a Flutter app.
|
| + var flutterSdkConstraint = _flutterSdkConstraint.firstMatch(lockFileText);
|
| + if (flutterSdkConstraint != null && flutter.isAvailable) {
|
| + var parsedConstraint = new VersionConstraint.parse(
|
| + flutterSdkConstraint[1]);
|
| +
|
| + if (!parsedConstraint.allows(flutter.version)) {
|
| + dataError("Flutter ${flutter.version} is incompatible with your "
|
| + "dependencies' SDK constraints. Please run \"pub get\" again.");
|
| + }
|
| + }
|
| }
|
|
|
| /// Determines whether or not the lockfile is out of date with respect to the
|
|
|