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

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

Issue 14297021: Move pub into sdk/lib/_internal. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Disallow package: imports of pub. Created 7 years, 8 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/name.dart ('k') | utils/pub/validator/size.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 library pubspec_field_validator;
6
7 import 'dart:async';
8
9 import '../entrypoint.dart';
10 import '../system_cache.dart';
11 import '../validator.dart';
12 import '../version.dart';
13
14 /// A validator that checks that the pubspec has valid "author" and "homepage"
15 /// fields.
16 class PubspecFieldValidator extends Validator {
17 PubspecFieldValidator(Entrypoint entrypoint)
18 : super(entrypoint);
19
20 Future validate() {
21 // The types of all fields are validated when the pubspec is parsed.
22 var pubspec = entrypoint.root.pubspec;
23 var author = pubspec.fields['author'];
24 var authors = pubspec.fields['authors'];
25 if (author == null && authors == null) {
26 errors.add('Your pubspec.yaml must have an "author" or "authors" field.');
27 } else {
28 if (authors == null) authors = [author];
29
30 var hasName = new RegExp(r"^ *[^< ]");
31 var hasEmail = new RegExp(r"<[^>]+> *$");
32 for (var authorName in authors) {
33 if (!hasName.hasMatch(authorName)) {
34 warnings.add('Author "$authorName" in pubspec.yaml should have a '
35 'name.');
36 }
37 if (!hasEmail.hasMatch(authorName)) {
38 warnings.add('Author "$authorName" in pubspec.yaml should have an '
39 'email address\n(e.g. "name <email>").');
40 }
41 }
42 }
43
44 var homepage = pubspec.fields['homepage'];
45 if (homepage == null) {
46 errors.add('Your pubspec.yaml is missing a "homepage" field.');
47 }
48
49 var description = pubspec.fields['description'];
50 if (description == null) {
51 errors.add('Your pubspec.yaml is missing a "description" field.');
52 }
53
54 var version = pubspec.fields['version'];
55 if (version == null) {
56 errors.add('Your pubspec.yaml is missing a "version" field.');
57 }
58
59 return new Future.value();
60 }
61 }
OLDNEW
« no previous file with comments | « utils/pub/validator/name.dart ('k') | utils/pub/validator/size.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698