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

Side by Side Diff: utils/pub/lock_file.dart

Issue 12280019: Revert "Support relative paths in path dependencies." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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/io.dart ('k') | utils/pub/path_source.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 lock_file; 5 library lock_file;
6 6
7 import 'dart:json' as json; 7 import 'dart:json' as json;
8 import 'io.dart';
9 import 'package.dart'; 8 import 'package.dart';
10 import 'source_registry.dart'; 9 import 'source_registry.dart';
11 import 'utils.dart'; 10 import 'utils.dart';
12 import 'version.dart'; 11 import 'version.dart';
13 import '../../pkg/yaml/lib/yaml.dart'; 12 import '../../pkg/yaml/lib/yaml.dart';
14 13
15 /// A parsed and validated `pubspec.lock` file. 14 /// A parsed and validated `pubspec.lock` file.
16 class LockFile { 15 class LockFile {
17 /// The packages this lockfile pins. 16 /// The packages this lockfile pins.
18 Map<String, PackageId> packages; 17 Map<String, PackageId> packages;
19 18
20 LockFile._(this.packages); 19 LockFile._(this.packages);
21 20
22 LockFile.empty() 21 LockFile.empty()
23 : packages = <String, PackageId>{}; 22 : packages = <String, PackageId>{};
24 23
25 /// Loads a lockfile from [filePath]. 24 /// Parses the lockfile whose text is [contents].
26 factory LockFile.load(String filePath, SourceRegistry sources) {
27 return LockFile._parse(filePath, readTextFile(filePath), sources);
28 }
29
30 /// Parses a lockfile whose text is [contents].
31 factory LockFile.parse(String contents, SourceRegistry sources) { 25 factory LockFile.parse(String contents, SourceRegistry sources) {
32 return LockFile._parse(null, contents, sources);
33 }
34
35 /// Parses the lockfile whose text is [contents].
36 static LockFile _parse(String filePath, String contents,
37 SourceRegistry sources) {
38 var packages = <String, PackageId>{}; 26 var packages = <String, PackageId>{};
39 27
40 if (contents.trim() == '') return new LockFile.empty(); 28 if (contents.trim() == '') return new LockFile.empty();
41 var parsed = loadYaml(contents); 29 var parsed = loadYaml(contents);
42 30
43 if (parsed.containsKey('packages')) { 31 if (parsed.containsKey('packages')) {
44 var packageEntries = parsed['packages']; 32 var packageEntries = parsed['packages'];
45 33
46 packageEntries.forEach((name, spec) { 34 packageEntries.forEach((name, spec) {
47 // Parse the version. 35 // Parse the version.
(...skipping 11 matching lines...) Expand all
59 throw new FormatException( 47 throw new FormatException(
60 'Could not find a source named $sourceName.'); 48 'Could not find a source named $sourceName.');
61 } 49 }
62 var source = sources[sourceName]; 50 var source = sources[sourceName];
63 51
64 // Parse the description. 52 // Parse the description.
65 if (!spec.containsKey('description')) { 53 if (!spec.containsKey('description')) {
66 throw new FormatException('Package $name is missing a description.'); 54 throw new FormatException('Package $name is missing a description.');
67 } 55 }
68 var description = spec['description']; 56 var description = spec['description'];
69 description = source.parseDescription(filePath, description, 57 source.validateDescription(description, fromLockFile: true);
70 fromLockFile: true);
71 58
72 var id = new PackageId(name, source, version, description); 59 var id = new PackageId(name, source, version, description);
73 60
74 // Validate the name. 61 // Validate the name.
75 if (name != id.name) { 62 if (name != id.name) {
76 throw new FormatException( 63 throw new FormatException(
77 "Package name $name doesn't match ${id.name}."); 64 "Package name $name doesn't match ${id.name}.");
78 } 65 }
79 66
80 packages[name] = id; 67 packages[name] = id;
(...skipping 15 matching lines...) Expand all
96 }); 83 });
97 84
98 // TODO(nweiz): Serialize using the YAML library once it supports 85 // TODO(nweiz): Serialize using the YAML library once it supports
99 // serialization. For now, we use JSON, since it's a subset of YAML anyway. 86 // serialization. For now, we use JSON, since it's a subset of YAML anyway.
100 return ''' 87 return '''
101 # Generated by pub. See: http://pub.dartlang.org/doc/glossary.html#lockf ile 88 # Generated by pub. See: http://pub.dartlang.org/doc/glossary.html#lockf ile
102 ${json.stringify({'packages': packagesObj})} 89 ${json.stringify({'packages': packagesObj})}
103 '''; 90 ''';
104 } 91 }
105 } 92 }
OLDNEW
« no previous file with comments | « utils/pub/io.dart ('k') | utils/pub/path_source.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698