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

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

Issue 11434118: Add validation infrastructure for "pub lish". (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix a chain/transform bug Created 8 years 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 | « no previous file | utils/pub/pubspec.dart » ('j') | utils/pub/validator.dart » ('J')
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 command_lish; 5 library command_lish;
6 6
7 import 'dart:io'; 7 import 'dart:io';
8 import 'dart:json'; 8 import 'dart:json';
9 import 'dart:uri'; 9 import 'dart:uri';
10 10
11 import '../../pkg/args/lib/args.dart'; 11 import '../../pkg/args/lib/args.dart';
12 import '../../pkg/http/lib/http.dart' as http; 12 import '../../pkg/http/lib/http.dart' as http;
13 import 'pub.dart'; 13 import 'pub.dart';
14 import 'io.dart'; 14 import 'io.dart';
15 import 'git.dart' as git; 15 import 'git.dart' as git;
16 import 'oauth2.dart' as oauth2; 16 import 'oauth2.dart' as oauth2;
17 import 'validator.dart';
17 18
18 // TODO(nweiz): Make "publish" the primary name for this command. See issue 19 // TODO(nweiz): Make "publish" the primary name for this command. See issue
19 // 6949. 20 // 6949.
20 /// Handles the `lish` and `publish` pub commands. 21 /// Handles the `lish` and `publish` pub commands.
21 class LishCommand extends PubCommand { 22 class LishCommand extends PubCommand {
22 final description = "publish the current package to pub.dartlang.org"; 23 final description = "publish the current package to pub.dartlang.org";
23 final usage = "pub publish [options]"; 24 final usage = "pub publish [options]";
24 final aliases = const ["lish", "lush"]; 25 final aliases = const ["lish", "lush"];
25 26
26 ArgParser get commandParser { 27 ArgParser get commandParser {
(...skipping 17 matching lines...) Expand all
44 // (contingent on issue 6813 and 6275). We should have the user 45 // (contingent on issue 6813 and 6275). We should have the user
45 // re-authorize the client, then restart the command. We should also do 46 // re-authorize the client, then restart the command. We should also do
46 // this in case of an ExpirationException. See issue 6950. 47 // this in case of an ExpirationException. See issue 6950.
47 // 48 //
48 // * Cloud Storage can provide an XML-formatted error. We should report 49 // * Cloud Storage can provide an XML-formatted error. We should report
49 // that error and exit. 50 // that error and exit.
50 return Futures.wait([ 51 return Futures.wait([
51 client.get(server.resolve("/packages/versions/new.json")), 52 client.get(server.resolve("/packages/versions/new.json")),
52 _filesToPublish.transform((files) { 53 _filesToPublish.transform((files) {
53 return createTarGz(files, baseDir: entrypoint.root.dir); 54 return createTarGz(files, baseDir: entrypoint.root.dir);
54 }).chain(consumeInputStream) 55 }).chain(consumeInputStream),
56 Validator.runAll(cache, entrypoint)
55 ]).chain((results) { 57 ]).chain((results) {
56 var response = results[0]; 58 var response = results[0];
57 var packageBytes = results[1]; 59 var packageBytes = results[1];
58 var parameters = _parseJson(response); 60 var parameters = _parseJson(response);
59 61
60 var url = _expectField(parameters, 'url', response); 62 var url = _expectField(parameters, 'url', response);
61 if (url is! String) _invalidServerResponse(response); 63 if (url is! String) _invalidServerResponse(response);
62 cloudStorageUrl = new Uri.fromString(url); 64 cloudStorageUrl = new Uri.fromString(url);
63 var request = new http.MultipartRequest('POST', cloudStorageUrl); 65 var request = new http.MultipartRequest('POST', cloudStorageUrl);
64 66
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 _expectField(Map map, String key, http.Response response) { 170 _expectField(Map map, String key, http.Response response) {
169 if (map.containsKey(key)) return map[key]; 171 if (map.containsKey(key)) return map[key];
170 _invalidServerResponse(response); 172 _invalidServerResponse(response);
171 } 173 }
172 174
173 /// Throws an error describing an invalid response from the server. 175 /// Throws an error describing an invalid response from the server.
174 void _invalidServerResponse(http.Response response) { 176 void _invalidServerResponse(http.Response response) {
175 throw 'Invalid server response:\n${response.body}'; 177 throw 'Invalid server response:\n${response.body}';
176 } 178 }
177 } 179 }
OLDNEW
« no previous file with comments | « no previous file | utils/pub/pubspec.dart » ('j') | utils/pub/validator.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698