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 pub.command.uploader; | 5 library pub.command.uploader; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 | 8 |
9 import 'package:path/path.dart' as path; | 9 import 'package:path/path.dart' as path; |
10 | 10 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 if (package != null) return package; | 62 if (package != null) return package; |
63 return new Entrypoint(path.current, cache).root.name; | 63 return new Entrypoint(path.current, cache).root.name; |
64 }).then((package) { | 64 }).then((package) { |
65 var uploader = rest[0]; | 65 var uploader = rest[0]; |
66 return oauth2.withClient(cache, (client) { | 66 return oauth2.withClient(cache, (client) { |
67 if (command == 'add') { | 67 if (command == 'add') { |
68 var url = server.resolve("/api/packages/" | 68 var url = server.resolve("/api/packages/" |
69 "${Uri.encodeComponent(package)}/uploaders"); | 69 "${Uri.encodeComponent(package)}/uploaders"); |
70 return client.post(url, | 70 return client.post(url, |
71 headers: PUB_API_HEADERS, | 71 headers: PUB_API_HEADERS, |
72 fields: {"email": uploader}); | 72 body: {"email": uploader}); |
73 } else { // command == 'remove' | 73 } else { // command == 'remove' |
74 var url = server.resolve("/api/packages/" | 74 var url = server.resolve("/api/packages/" |
75 "${Uri.encodeComponent(package)}/uploaders/" | 75 "${Uri.encodeComponent(package)}/uploaders/" |
76 "${Uri.encodeComponent(uploader)}"); | 76 "${Uri.encodeComponent(uploader)}"); |
77 return client.delete(url, headers: PUB_API_HEADERS); | 77 return client.delete(url, headers: PUB_API_HEADERS); |
78 } | 78 } |
79 }); | 79 }); |
80 }).then(handleJsonSuccess) | 80 }).then(handleJsonSuccess) |
81 .catchError((error) => handleJsonError(error.response), | 81 .catchError((error) => handleJsonError(error.response), |
82 test: (e) => e is PubHttpException); | 82 test: (e) => e is PubHttpException); |
83 } | 83 } |
84 } | 84 } |
OLD | NEW |