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

Side by Side Diff: lib/src/command/lish.dart

Issue 2044253003: Refactor Source and SourceRegistry. (Closed) Base URL: git@github.com:dart-lang/pub.git@master
Patch Set: Rename LiveSource to BoundSource. Created 4 years, 6 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 unified diff | Download patch
« no previous file with comments | « lib/src/command/cache_repair.dart ('k') | lib/src/command/list_package_dirs.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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;
11 import '../ascii_tree.dart' as tree; 11 import '../ascii_tree.dart' as tree;
12 import '../http.dart'; 12 import '../http.dart';
13 import '../io.dart'; 13 import '../io.dart';
14 import '../log.dart' as log; 14 import '../log.dart' as log;
15 import '../oauth2.dart' as oauth2; 15 import '../oauth2.dart' as oauth2;
16 import '../source/hosted.dart';
17 import '../utils.dart'; 16 import '../utils.dart';
18 import '../validator.dart'; 17 import '../validator.dart';
19 18
20 /// Handles the `lish` and `publish` pub commands. 19 /// Handles the `lish` and `publish` pub commands.
21 class LishCommand extends PubCommand { 20 class LishCommand extends PubCommand {
22 String get name => "publish"; 21 String get name => "publish";
23 String get description => "Publish the current package to pub.dartlang.org."; 22 String get description => "Publish the current package to pub.dartlang.org.";
24 String get invocation => "pub publish [options]"; 23 String get invocation => "pub publish [options]";
25 String get docUrl => "http://dartlang.org/tools/pub/cmd/pub-lish.html"; 24 String get docUrl => "http://dartlang.org/tools/pub/cmd/pub-lish.html";
26 List<String> get aliases => const ["lish", "lush"]; 25 List<String> get aliases => const ["lish", "lush"];
27 bool get takesArguments => false; 26 bool get takesArguments => false;
28 27
29 /// The URL of the server to which to upload the package. 28 /// The URL of the server to which to upload the package.
30 Uri get server { 29 Uri get server {
31 // An explicit argument takes precedence. 30 // An explicit argument takes precedence.
32 if (argResults.wasParsed('server')) { 31 if (argResults.wasParsed('server')) {
33 return Uri.parse(argResults['server']); 32 return Uri.parse(argResults['server']);
34 } 33 }
35 34
36 // Otherwise, use the one specified in the pubspec. 35 // Otherwise, use the one specified in the pubspec.
37 if (entrypoint.root.pubspec.publishTo != null) { 36 if (entrypoint.root.pubspec.publishTo != null) {
38 return Uri.parse(entrypoint.root.pubspec.publishTo); 37 return Uri.parse(entrypoint.root.pubspec.publishTo);
39 } 38 }
40 39
41 // Otherwise, use the default. 40 // Otherwise, use the default.
42 return Uri.parse(HostedSource.defaultUrl); 41 return Uri.parse(cache.sources.hosted.defaultUrl);
43 } 42 }
44 43
45 /// Whether the publish is just a preview. 44 /// Whether the publish is just a preview.
46 bool get dryRun => argResults['dry-run']; 45 bool get dryRun => argResults['dry-run'];
47 46
48 /// Whether the publish requires confirmation. 47 /// Whether the publish requires confirmation.
49 bool get force => argResults['force']; 48 bool get force => argResults['force'];
50 49
51 LishCommand() { 50 LishCommand() {
52 argParser.addFlag('dry-run', abbr: 'n', negatable: false, 51 argParser.addFlag('dry-run', abbr: 'n', negatable: false,
53 help: 'Validate but do not publish the package.'); 52 help: 'Validate but do not publish the package.');
54 argParser.addFlag('force', abbr: 'f', negatable: false, 53 argParser.addFlag('force', abbr: 'f', negatable: false,
55 help: 'Publish without confirmation if there are no errors.'); 54 help: 'Publish without confirmation if there are no errors.');
56 argParser.addOption('server', defaultsTo: HostedSource.defaultUrl, 55 argParser.addOption('server', defaultsTo: cache.sources.hosted.defaultUrl,
57 help: 'The package server to which to upload this package.'); 56 help: 'The package server to which to upload this package.');
58 } 57 }
59 58
60 Future _publish(packageBytes) async { 59 Future _publish(packageBytes) async {
61 var cloudStorageUrl; 60 var cloudStorageUrl;
62 try { 61 try {
63 await oauth2.withClient(cache, (client) { 62 await oauth2.withClient(cache, (client) {
64 return log.progress('Uploading', () async { 63 return log.progress('Uploading', () async {
65 // TODO(nweiz): Cloud Storage can provide an XML-formatted error. We 64 // TODO(nweiz): Cloud Storage can provide an XML-formatted error. We
66 // should report that error and exit. 65 // should report that error and exit.
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 } 179 }
181 180
182 var confirmed = await confirm(message); 181 var confirmed = await confirm(message);
183 if (!confirmed) { 182 if (!confirmed) {
184 log.error("Package upload canceled."); 183 log.error("Package upload canceled.");
185 return false; 184 return false;
186 } 185 }
187 return true; 186 return true;
188 } 187 }
189 } 188 }
OLDNEW
« no previous file with comments | « lib/src/command/cache_repair.dart ('k') | lib/src/command/list_package_dirs.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698