| 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 import 'dart:async'; | 5 import 'dart:async'; |
| 6 | 6 |
| 7 import 'package:http/http.dart' as http; | 7 import 'package:http/http.dart' as http; |
| 8 | 8 |
| 9 import '../command.dart'; | 9 import '../command.dart'; |
| 10 import '../exit_codes.dart' as exit_codes; | 10 import '../exit_codes.dart' as exit_codes; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 | 49 |
| 50 LishCommand() { | 50 LishCommand() { |
| 51 argParser.addFlag('dry-run', abbr: 'n', negatable: false, | 51 argParser.addFlag('dry-run', abbr: 'n', negatable: false, |
| 52 help: 'Validate but do not publish the package.'); | 52 help: 'Validate but do not publish the package.'); |
| 53 argParser.addFlag('force', abbr: 'f', negatable: false, | 53 argParser.addFlag('force', abbr: 'f', negatable: false, |
| 54 help: 'Publish without confirmation if there are no errors.'); | 54 help: 'Publish without confirmation if there are no errors.'); |
| 55 argParser.addOption('server', defaultsTo: cache.sources.hosted.defaultUrl, | 55 argParser.addOption('server', defaultsTo: cache.sources.hosted.defaultUrl, |
| 56 help: 'The package server to which to upload this package.'); | 56 help: 'The package server to which to upload this package.'); |
| 57 } | 57 } |
| 58 | 58 |
| 59 Future _publish(packageBytes) async { | 59 Future _publish(List<int> packageBytes) async { |
| 60 var cloudStorageUrl; | 60 var cloudStorageUrl; |
| 61 try { | 61 try { |
| 62 await oauth2.withClient(cache, (client) { | 62 await oauth2.withClient(cache, (client) { |
| 63 return log.progress('Uploading', () async { | 63 return log.progress('Uploading', () async { |
| 64 // TODO(nweiz): Cloud Storage can provide an XML-formatted error. We | 64 // TODO(nweiz): Cloud Storage can provide an XML-formatted error. We |
| 65 // should report that error and exit. | 65 // should report that error and exit. |
| 66 var newUri = server.resolve("/api/packages/versions/new"); | 66 var newUri = server.resolve("/api/packages/versions/new"); |
| 67 var response = await client.get(newUri, headers: PUB_API_HEADERS); | 67 var response = await client.get(newUri, headers: PUB_API_HEADERS); |
| 68 var parameters = parseJsonResponse(response); | 68 var parameters = parseJsonResponse(response); |
| 69 | 69 |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 } | 179 } |
| 180 | 180 |
| 181 var confirmed = await confirm(message); | 181 var confirmed = await confirm(message); |
| 182 if (!confirmed) { | 182 if (!confirmed) { |
| 183 log.error("Package upload canceled."); | 183 log.error("Package upload canceled."); |
| 184 return false; | 184 return false; |
| 185 } | 185 } |
| 186 return true; | 186 return true; |
| 187 } | 187 } |
| 188 } | 188 } |
| OLD | NEW |