| 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_uploader; | 5 library command_uploader; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:io'; | 8 import 'dart:io'; |
| 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/path/lib/path.dart' as path; | 12 import '../../pkg/path/lib/path.dart' as path; |
| 13 import 'entrypoint.dart'; | 13 import 'entrypoint.dart'; |
| 14 import 'exit_codes.dart' as exit_codes; | 14 import 'exit_codes.dart' as exit_codes; |
| 15 import 'http.dart'; | 15 import 'http.dart'; |
| 16 import 'io.dart'; | 16 import 'io.dart'; |
| 17 import 'log.dart' as log; | 17 import 'log.dart' as log; |
| 18 import 'oauth2.dart' as oauth2; | 18 import 'oauth2.dart' as oauth2; |
| 19 import 'pub.dart'; | 19 import 'pub.dart'; |
| 20 import 'utils.dart'; |
| 20 | 21 |
| 21 /// Handles the `uploader` pub command. | 22 /// Handles the `uploader` pub command. |
| 22 class UploaderCommand extends PubCommand { | 23 class UploaderCommand extends PubCommand { |
| 23 final description = "Manage uploaders for a package on pub.dartlang.org."; | 24 final description = "Manage uploaders for a package on pub.dartlang.org."; |
| 24 final usage = "pub uploader [options] {add/remove} <email>"; | 25 final usage = "pub uploader [options] {add/remove} <email>"; |
| 25 final requiresEntrypoint = false; | 26 final requiresEntrypoint = false; |
| 26 | 27 |
| 27 ArgParser get commandParser { | 28 ArgParser get commandParser { |
| 28 var parser = new ArgParser(); | 29 var parser = new ArgParser(); |
| 29 // TODO(nweiz): Use HostedSource.defaultUrl as the default value once we use | 30 // TODO(nweiz): Use HostedSource.defaultUrl as the default value once we use |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 if (command == 'add') { | 69 if (command == 'add') { |
| 69 var url = server.resolve("/packages/${encodeUriComponent(package)}" | 70 var url = server.resolve("/packages/${encodeUriComponent(package)}" |
| 70 "/uploaders.json"); | 71 "/uploaders.json"); |
| 71 return client.post(url, fields: {"email": uploader}); | 72 return client.post(url, fields: {"email": uploader}); |
| 72 } else { // command == 'remove' | 73 } else { // command == 'remove' |
| 73 var url = server.resolve("/packages/${encodeUriComponent(package)}" | 74 var url = server.resolve("/packages/${encodeUriComponent(package)}" |
| 74 "/uploaders/${encodeUriComponent(uploader)}.json"); | 75 "/uploaders/${encodeUriComponent(uploader)}.json"); |
| 75 return client.delete(url); | 76 return client.delete(url); |
| 76 } | 77 } |
| 77 }); | 78 }); |
| 78 }).then(handleJsonSuccess).catchError((e) { | 79 }).then(handleJsonSuccess).catchError((asyncError) { |
| 79 if (e is! PubHttpException) throw e; | 80 var e = getRealError(asyncError); |
| 81 if (e is! PubHttpException) throw asyncError; |
| 80 handleJsonError(e.response); | 82 handleJsonError(e.response); |
| 81 }); | 83 }); |
| 82 } | 84 } |
| 83 } | 85 } |
| OLD | NEW |