Chromium Code Reviews| 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:async'; | 7 import 'dart:async'; |
| 8 import 'dart:io'; | 8 import 'dart:io'; |
| 9 import 'dart:json'; | 9 import 'dart:json'; |
| 10 import 'dart:uri'; | 10 import 'dart:uri'; |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 25 /// Handles the `lish` and `publish` pub commands. | 25 /// Handles the `lish` and `publish` pub commands. |
| 26 class LishCommand extends PubCommand { | 26 class LishCommand extends PubCommand { |
| 27 final description = "Publish the current package to pub.dartlang.org."; | 27 final description = "Publish the current package to pub.dartlang.org."; |
| 28 final usage = "pub publish [options]"; | 28 final usage = "pub publish [options]"; |
| 29 final aliases = const ["lish", "lush"]; | 29 final aliases = const ["lish", "lush"]; |
| 30 | 30 |
| 31 ArgParser get commandParser { | 31 ArgParser get commandParser { |
| 32 var parser = new ArgParser(); | 32 var parser = new ArgParser(); |
| 33 // TODO(nweiz): Use HostedSource.defaultUrl as the default value once we use | 33 // TODO(nweiz): Use HostedSource.defaultUrl as the default value once we use |
| 34 // dart:io for HTTPS requests. | 34 // dart:io for HTTPS requests. |
| 35 parser.addFlag('dry-run', abbr: 'n', negatable: false, | |
| 36 help: 'Preview publishing the package'); | |
| 35 parser.addOption('server', defaultsTo: 'https://pub.dartlang.org', | 37 parser.addOption('server', defaultsTo: 'https://pub.dartlang.org', |
| 36 help: 'The package server to which to upload this package'); | 38 help: 'The package server to which to upload this package'); |
| 37 return parser; | 39 return parser; |
| 38 } | 40 } |
| 39 | 41 |
| 40 /// The URL of the server to which to upload the package. | 42 /// The URL of the server to which to upload the package. |
| 41 Uri get server => Uri.parse(commandOptions['server']); | 43 Uri get server => Uri.parse(commandOptions['server']); |
| 42 | 44 |
| 43 Future _publish(packageBytes) { | 45 Future _publish(packageBytes) { |
| 44 var cloudStorageUrl; | 46 var cloudStorageUrl; |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 151 var errors = pair.first; | 153 var errors = pair.first; |
| 152 var warnings = pair.last; | 154 var warnings = pair.last; |
| 153 | 155 |
| 154 if (!errors.isEmpty) { | 156 if (!errors.isEmpty) { |
| 155 throw "Sorry, your package is missing " | 157 throw "Sorry, your package is missing " |
| 156 "${(errors.length > 1) ? 'some requirements' : 'a requirement'} " | 158 "${(errors.length > 1) ? 'some requirements' : 'a requirement'} " |
| 157 "and can't be published yet.\nFor more information, see: " | 159 "and can't be published yet.\nFor more information, see: " |
| 158 "http://pub.dartlang.org/doc/pub-lish.html.\n"; | 160 "http://pub.dartlang.org/doc/pub-lish.html.\n"; |
| 159 } | 161 } |
| 160 | 162 |
| 163 if (commandOptions['dry-run']){ | |
| 164 var s = warnings.length == 1 ? '' : 's'; | |
| 165 log.warning("Package has ${warnings.length} warning$s."); | |
| 166 exit(0); | |
|
Bob Nystrom
2013/02/11 18:44:37
We're trying to move away from explicitly calling
keertip
2013/02/11 23:57:31
Done.
| |
| 167 } | |
| 168 | |
| 161 var message = 'Looks great! Are you ready to upload your package'; | 169 var message = 'Looks great! Are you ready to upload your package'; |
| 162 | 170 |
| 163 if (!warnings.isEmpty) { | 171 if (!warnings.isEmpty) { |
| 164 var s = warnings.length == 1 ? '' : 's'; | 172 var s = warnings.length == 1 ? '' : 's'; |
| 165 message = "Package has ${warnings.length} warning$s. Upload anyway"; | 173 message = "Package has ${warnings.length} warning$s. Upload anyway"; |
| 166 } | 174 } |
| 167 | 175 |
| 168 return confirm(message).then((confirmed) { | 176 return confirm(message).then((confirmed) { |
| 169 if (!confirmed) throw "Package upload canceled."; | 177 if (!confirmed) throw "Package upload canceled."; |
| 170 }); | 178 }); |
| 171 }); | 179 }); |
| 172 } | 180 } |
| 173 } | 181 } |
| OLD | NEW |