| 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.lish; | 5 library pub.command.lish; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:http/http.dart' as http; | 9 import 'package:http/http.dart' as http; |
| 10 | 10 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 throw error; | 90 throw error; |
| 91 } | 91 } |
| 92 }); | 92 }); |
| 93 } | 93 } |
| 94 | 94 |
| 95 Future onRun() { | 95 Future onRun() { |
| 96 if (force && dryRun) { | 96 if (force && dryRun) { |
| 97 usageError('Cannot use both --force and --dry-run.'); | 97 usageError('Cannot use both --force and --dry-run.'); |
| 98 } | 98 } |
| 99 | 99 |
| 100 var packageBytesFuture = entrypoint.packageFiles().then((files) { | 100 var files = entrypoint.packageFiles(); |
| 101 log.fine('Archiving and publishing ${entrypoint.root}.'); | 101 log.fine('Archiving and publishing ${entrypoint.root}.'); |
| 102 | 102 |
| 103 // Show the package contents so the user can verify they look OK. | 103 // Show the package contents so the user can verify they look OK. |
| 104 var package = entrypoint.root; | 104 var package = entrypoint.root; |
| 105 log.message( | 105 log.message( |
| 106 'Publishing ${package.name} ${package.version} to $server:\n' | 106 'Publishing ${package.name} ${package.version} to $server:\n' |
| 107 '${tree.fromFiles(files, baseDir: entrypoint.root.dir)}'); | 107 '${tree.fromFiles(files, baseDir: entrypoint.root.dir)}'); |
| 108 | 108 |
| 109 return createTarGz(files, baseDir: entrypoint.root.dir); | 109 var packageBytesFuture = createTarGz(files, baseDir: entrypoint.root.dir) |
| 110 }).then((stream) => stream.toBytes()); | 110 .toBytes(); |
| 111 | 111 |
| 112 // Validate the package. | 112 // Validate the package. |
| 113 return _validate(packageBytesFuture.then((bytes) => bytes.length)) | 113 return _validate(packageBytesFuture.then((bytes) => bytes.length)) |
| 114 .then((isValid) { | 114 .then((isValid) { |
| 115 if (isValid) return packageBytesFuture.then(_publish); | 115 if (isValid) return packageBytesFuture.then(_publish); |
| 116 }); | 116 }); |
| 117 } | 117 } |
| 118 | 118 |
| 119 /// Returns the value associated with [key] in [map]. Throws a user-friendly | 119 /// Returns the value associated with [key] in [map]. Throws a user-friendly |
| 120 /// error if [map] doens't contain [key]. | 120 /// error if [map] doens't contain [key]. |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 return confirm(message).then((confirmed) { | 156 return confirm(message).then((confirmed) { |
| 157 if (!confirmed) { | 157 if (!confirmed) { |
| 158 log.error("Package upload canceled."); | 158 log.error("Package upload canceled."); |
| 159 return false; | 159 return false; |
| 160 } | 160 } |
| 161 return true; | 161 return true; |
| 162 }); | 162 }); |
| 163 }); | 163 }); |
| 164 } | 164 } |
| 165 } | 165 } |
| OLD | NEW |