Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(618)

Unified Diff: utils/pub/command_lish.dart

Issue 12226077: add --preview flag to publish command (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | utils/tests/pub/pub_lish_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: utils/pub/command_lish.dart
===================================================================
--- utils/pub/command_lish.dart (revision 18383)
+++ utils/pub/command_lish.dart (working copy)
@@ -32,6 +32,8 @@
var parser = new ArgParser();
// TODO(nweiz): Use HostedSource.defaultUrl as the default value once we use
// dart:io for HTTPS requests.
+ parser.addFlag('dry-run', abbr: 'n', negatable: false,
+ help: 'Validate but do not publish the package');
parser.addOption('server', defaultsTo: 'https://pub.dartlang.org',
help: 'The package server to which to upload this package');
return parser;
@@ -100,9 +102,11 @@
// Validate the package.
return _validate(packageBytesFuture.then((bytes) => bytes.length))
- .then((_) => packageBytesFuture).then(_publish);
+ .then((isValid) {
+ if (isValid) return packageBytesFuture.then(_publish);
+ });
}
-
+
/// The basenames of files that are automatically excluded from archives.
final _BLACKLISTED_FILES = const ['pubspec.lock'];
@@ -146,18 +150,25 @@
}
/// Validates the package. Throws an exception if it's invalid.
- Future _validate(Future<int> packageSize) {
+ Future<bool> _validate(Future<int> packageSize) {
return Validator.runAll(entrypoint, packageSize).then((pair) {
var errors = pair.first;
var warnings = pair.last;
if (!errors.isEmpty) {
- throw "Sorry, your package is missing "
+ log.error("Sorry, your package is missing "
"${(errors.length > 1) ? 'some requirements' : 'a requirement'} "
"and can't be published yet.\nFor more information, see: "
- "http://pub.dartlang.org/doc/pub-lish.html.\n";
+ "http://pub.dartlang.org/doc/pub-lish.html.\n");
+ return false;
}
+ if (commandOptions['dry-run']){
+ var s = warnings.length == 1 ? '' : 's';
+ log.warning("Package has ${warnings.length} warning$s.");
+ return false;
+ }
+
var message = 'Looks great! Are you ready to upload your package';
if (!warnings.isEmpty) {
@@ -166,7 +177,11 @@
}
return confirm(message).then((confirmed) {
- if (!confirmed) throw "Package upload canceled.";
+ if (!confirmed) {
+ log.error("Package upload canceled.");
+ return false;
+ }
+ return true;
});
});
}
« no previous file with comments | « no previous file | utils/tests/pub/pub_lish_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698