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

Side by Side Diff: utils/pub/hosted_source.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/git_source.dart ('k') | utils/pub/io.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 hosted_source; 5 library hosted_source;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:io' as io; 8 import 'dart:io' as io;
9 import 'dart:json' as json; 9 import 'dart:json' as json;
10 import 'dart:uri'; 10 import 'dart:uri';
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 } 49 }
50 50
51 /// Downloads and parses the pubspec for a specific version of a package that 51 /// Downloads and parses the pubspec for a specific version of a package that
52 /// is available from the site. 52 /// is available from the site.
53 Future<Pubspec> describe(PackageId id) { 53 Future<Pubspec> describe(PackageId id) {
54 var parsed = _parseDescription(id.description); 54 var parsed = _parseDescription(id.description);
55 var fullUrl = "${parsed.last}/packages/${parsed.first}/versions/" 55 var fullUrl = "${parsed.last}/packages/${parsed.first}/versions/"
56 "${id.version}.yaml"; 56 "${id.version}.yaml";
57 57
58 return httpClient.read(fullUrl).then((yaml) { 58 return httpClient.read(fullUrl).then((yaml) {
59 return new Pubspec.parse(null, yaml, systemCache.sources); 59 return new Pubspec.parse(yaml, systemCache.sources);
60 }).catchError((ex) { 60 }).catchError((ex) {
61 _throwFriendlyError(ex, id, parsed.last); 61 _throwFriendlyError(ex, id, parsed.last);
62 }); 62 });
63 } 63 }
64 64
65 /// Downloads a package from the site and unpacks it. 65 /// Downloads a package from the site and unpacks it.
66 Future<bool> install(PackageId id, String destPath) { 66 Future<bool> install(PackageId id, String destPath) {
67 return defer(() { 67 return defer(() {
68 var parsedDescription = _parseDescription(id.description); 68 var parsedDescription = _parseDescription(id.description);
69 var name = parsedDescription.first; 69 var name = parsedDescription.first;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 String packageName(description) => _parseDescription(description).first; 107 String packageName(description) => _parseDescription(description).first;
108 108
109 bool descriptionsEqual(description1, description2) => 109 bool descriptionsEqual(description1, description2) =>
110 _parseDescription(description1) == _parseDescription(description2); 110 _parseDescription(description1) == _parseDescription(description2);
111 111
112 /// Ensures that [description] is a valid hosted package description. 112 /// Ensures that [description] is a valid hosted package description.
113 /// 113 ///
114 /// There are two valid formats. A plain string refers to a package with the 114 /// There are two valid formats. A plain string refers to a package with the
115 /// given name from the default host, while a map with keys "name" and "url" 115 /// given name from the default host, while a map with keys "name" and "url"
116 /// refers to a package with the given name from the host at the given URL. 116 /// refers to a package with the given name from the host at the given URL.
117 dynamic parseDescription(String containingPath, description, 117 void validateDescription(description, {bool fromLockFile: false}) {
118 {bool fromLockFile: false}) {
119 _parseDescription(description); 118 _parseDescription(description);
120 return description;
121 } 119 }
122 120
123 /// When an error occurs trying to read something about [package] from [url], 121 /// When an error occurs trying to read something about [package] from [url],
124 /// this tries to translate into a more user friendly error message. Always 122 /// this tries to translate into a more user friendly error message. Always
125 /// throws an error, either the original one or a better one. 123 /// throws an error, either the original one or a better one.
126 void _throwFriendlyError(AsyncError asyncError, package, url) { 124 void _throwFriendlyError(AsyncError asyncError, package, url) {
127 if (asyncError.error is PubHttpException && 125 if (asyncError.error is PubHttpException &&
128 asyncError.error.response.statusCode == 404) { 126 asyncError.error.response.statusCode == 404) {
129 throw 'Could not find package "$package" at $url.'; 127 throw 'Could not find package "$package" at $url.';
130 } 128 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 161
164 var name = description["name"]; 162 var name = description["name"];
165 if (name is! String) { 163 if (name is! String) {
166 throw new FormatException("The 'name' key must have a string value."); 164 throw new FormatException("The 'name' key must have a string value.");
167 } 165 }
168 166
169 var url = description.containsKey("url") ? description["url"] : defaultUrl; 167 var url = description.containsKey("url") ? description["url"] : defaultUrl;
170 return new Pair<String, String>(name, url); 168 return new Pair<String, String>(name, url);
171 } 169 }
172 } 170 }
OLDNEW
« no previous file with comments | « utils/pub/git_source.dart ('k') | utils/pub/io.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698