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

Side by Side Diff: utils/pub/validator/dependency.dart

Issue 12079112: Make a bunch of stuff in pub synchronous. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix after merge. Created 7 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « utils/pub/validator/compiled_dartdoc.dart ('k') | utils/pub/validator/directory.dart » ('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) 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 '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';
(...skipping 20 matching lines...) Expand all
31 'Pub enables "package:${entrypoint.root.name}" imports ' 31 'Pub enables "package:${entrypoint.root.name}" imports '
32 'implicitly.'); 32 'implicitly.');
33 return new Future.immediate(null); 33 return new Future.immediate(null);
34 } 34 }
35 35
36 if (dependency.constraint.isAny && 36 if (dependency.constraint.isAny &&
37 // TODO(nweiz): once we have development dependencies (issue 5358), we 37 // TODO(nweiz): once we have development dependencies (issue 5358), we
38 // should warn about unittest. Until then, it's reasonable not to put 38 // should warn about unittest. Until then, it's reasonable not to put
39 // a constraint on it. 39 // a constraint on it.
40 dependency.name != 'unittest') { 40 dependency.name != 'unittest') {
41 return _warnAboutConstraint(dependency); 41 _warnAboutConstraint(dependency);
42 } 42 }
43 43
44 return new Future.immediate(null); 44 return new Future.immediate(null);
45 }); 45 });
46 } 46 }
47 47
48 /// Warn that dependencies should use the hosted source. 48 /// Warn that dependencies should use the hosted source.
49 Future _warnAboutSource(PackageRef ref) { 49 Future _warnAboutSource(PackageRef ref) {
50 return entrypoint.cache.sources['hosted'] 50 return entrypoint.cache.sources['hosted']
51 .getVersions(ref.name, ref.name) 51 .getVersions(ref.name, ref.name)
(...skipping 15 matching lines...) Expand all
67 '\n' 67 '\n'
68 'dependencies:\n' 68 'dependencies:\n'
69 ' ${ref.name}: $constraint\n' 69 ' ${ref.name}: $constraint\n'
70 '\n' 70 '\n'
71 'Using the hosted source ensures that everyone can download your ' 71 'Using the hosted source ensures that everyone can download your '
72 'package\'s dependencies along with your package.'); 72 'package\'s dependencies along with your package.');
73 }); 73 });
74 } 74 }
75 75
76 /// Warn that dependencies should have version constraints. 76 /// Warn that dependencies should have version constraints.
77 Future _warnAboutConstraint(PackageRef ref) { 77 void _warnAboutConstraint(PackageRef ref) {
78 return entrypoint.loadLockFile().then((lockFile) { 78 var lockFile = entrypoint.loadLockFile();
79 var message = 'Your dependency on "${ref.name}" should have a version ' 79 var message = 'Your dependency on "${ref.name}" should have a version '
80 'constraint.'; 80 'constraint.';
81 var locked = lockFile.packages[ref.name]; 81 var locked = lockFile.packages[ref.name];
82 if (locked != null) { 82 if (locked != null) {
83 message = '$message For example:\n' 83 message = '$message For example:\n'
84 '\n' 84 '\n'
85 'dependencies:\n' 85 'dependencies:\n'
86 ' ${ref.name}: ${_constraintForVersion(locked.version)}\n'; 86 ' ${ref.name}: ${_constraintForVersion(locked.version)}\n';
87 } 87 }
88 warnings.add("$message\n" 88 warnings.add("$message\n"
89 "Without a constraint, you're promising to support all future " 89 "Without a constraint, you're promising to support all future "
90 "versions of ${ref.name}."); 90 "versions of ${ref.name}.");
91 });
92 } 91 }
93 92
94 /// Returns the suggested version constraint for a dependency that was tested 93 /// Returns the suggested version constraint for a dependency that was tested
95 /// against [version]. 94 /// against [version].
96 String _constraintForVersion(Version version) { 95 String _constraintForVersion(Version version) {
97 if (version.major != 0) return '">=$version <${version.major + 1}.0.0"'; 96 if (version.major != 0) return '">=$version <${version.major + 1}.0.0"';
98 return '">=$version <${version.major}.${version.minor}.' 97 return '">=$version <${version.major}.${version.minor}.'
99 '${version.patch + 1}"'; 98 '${version.patch + 1}"';
100 } 99 }
101 } 100 }
OLDNEW
« no previous file with comments | « utils/pub/validator/compiled_dartdoc.dart ('k') | utils/pub/validator/directory.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698