OLD | NEW |
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 | 17 |
18 // TODO(nweiz): Make "publish" the primary name for this command. See issue | 18 // TODO(nweiz): Make "publish" the primary name for this command. See issue |
19 // 6949. | 19 // 6949. |
20 /// Handles the `lish` and `publish` pub commands. | 20 /// Handles the `lish` and `publish` pub commands. |
21 class LishCommand extends PubCommand { | 21 class LishCommand extends PubCommand { |
22 final description = "publish the current package to pub.dartlang.org"; | 22 final description = "publish the current package to pub.dartlang.org"; |
23 final usage = "pub publish [options]"; | 23 final usage = "pub publish [options]"; |
24 final aliases = const ["lish", "lush"]; | 24 final aliases = const ["lish", "lush"]; |
25 | 25 |
26 ArgParser get commandParser { | 26 ArgParser get commandParser { |
27 var parser = new ArgParser(); | 27 var parser = new ArgParser(); |
28 parser.addOption('server', defaultsTo: 'http://pub.dartlang.org', | 28 parser.addOption('server', defaultsTo: 'https://pub.dartlang.org', |
29 help: 'The package server to which to upload this package'); | 29 help: 'The package server to which to upload this package'); |
30 return parser; | 30 return parser; |
31 } | 31 } |
32 | 32 |
33 /// The URL of the server to which to upload the package. | 33 /// The URL of the server to which to upload the package. |
34 Uri get server => new Uri.fromString(commandOptions['server']); | 34 Uri get server => new Uri.fromString(commandOptions['server']); |
35 | 35 |
36 Future onRun() { | 36 Future onRun() { |
37 var cloudStorageUrl; | 37 var cloudStorageUrl; |
38 return oauth2.withClient(cache, (client) { | 38 return oauth2.withClient(cache, (client) { |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 _expectField(Map map, String key, http.Response response) { | 168 _expectField(Map map, String key, http.Response response) { |
169 if (map.containsKey(key)) return map[key]; | 169 if (map.containsKey(key)) return map[key]; |
170 _invalidServerResponse(response); | 170 _invalidServerResponse(response); |
171 } | 171 } |
172 | 172 |
173 /// Throws an error describing an invalid response from the server. | 173 /// Throws an error describing an invalid response from the server. |
174 void _invalidServerResponse(http.Response response) { | 174 void _invalidServerResponse(http.Response response) { |
175 throw 'Invalid server response:\n${response.body}'; | 175 throw 'Invalid server response:\n${response.body}'; |
176 } | 176 } |
177 } | 177 } |
OLD | NEW |