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

Side by Side Diff: utils/pub/command_lish.dart

Issue 11528020: Fix issue 7215 by relativising a path before checking its components. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | utils/pub/io.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 library command_lish; 5 library command_lish;
6 6
7 import 'dart:io'; 7 import 'dart:io';
8 import 'dart:json'; 8 import 'dart:json';
9 import 'dart:uri'; 9 import 'dart:uri';
10 10
11 import '../../pkg/args/lib/args.dart'; 11 import '../../pkg/args/lib/args.dart';
12 import '../../pkg/http/lib/http.dart' as http; 12 import '../../pkg/http/lib/http.dart' as http;
13 import 'git.dart' as git; 13 import 'git.dart' as git;
14 import 'io.dart'; 14 import 'io.dart';
15 import 'log.dart' as log; 15 import 'log.dart' as log;
16 import 'oauth2.dart' as oauth2; 16 import 'oauth2.dart' as oauth2;
17 import 'pub.dart'; 17 import 'pub.dart';
18 import 'validator.dart'; 18 import 'validator.dart';
19 19
20 // TODO(nweiz): Make "publish" the primary name for this command. See issue
21 // 6949.
22 /// Handles the `lish` and `publish` pub commands. 20 /// Handles the `lish` and `publish` pub commands.
23 class LishCommand extends PubCommand { 21 class LishCommand extends PubCommand {
24 final description = "Publish the current package to pub.dartlang.org."; 22 final description = "Publish the current package to pub.dartlang.org.";
25 final usage = "pub publish [options]"; 23 final usage = "pub publish [options]";
26 final aliases = const ["lish", "lush"]; 24 final aliases = const ["lish", "lush"];
27 25
28 ArgParser get commandParser { 26 ArgParser get commandParser {
29 var parser = new ArgParser(); 27 var parser = new ArgParser();
30 parser.addOption('server', defaultsTo: 'https://pub.dartlang.org', 28 parser.addOption('server', defaultsTo: 'https://pub.dartlang.org',
31 help: 'The package server to which to upload this package'); 29 help: 'The package server to which to upload this package');
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 135
138 return listDir(rootDir, recursive: true).chain((entries) { 136 return listDir(rootDir, recursive: true).chain((entries) {
139 return Futures.wait(entries.map((entry) { 137 return Futures.wait(entries.map((entry) {
140 return fileExists(entry).transform((isFile) => isFile ? entry : null); 138 return fileExists(entry).transform((isFile) => isFile ? entry : null);
141 })); 139 }));
142 }); 140 });
143 }).transform((files) => files.filter((file) { 141 }).transform((files) => files.filter((file) {
144 if (file == null || _BLACKLISTED_FILES.contains(basename(file))) { 142 if (file == null || _BLACKLISTED_FILES.contains(basename(file))) {
145 return false; 143 return false;
146 } 144 }
147 // TODO(nweiz): Since `file` is absolute, this will break if the package 145 return !splitPath(relativeTo(file, rootDir))
148 // itself is in a directory named "packages" (issue 7215). 146 .some(_BLACKLISTED_DIRECTORIES.contains);
149 return !splitPath(file).some(_BLACKLISTED_DIRECTORIES.contains);
150 })); 147 }));
151 } 148 }
152 149
153 /// Parses a response body, assuming it's JSON-formatted. Throws a 150 /// Parses a response body, assuming it's JSON-formatted. Throws a
154 /// user-friendly error if the response body is invalid JSON, or if it's not a 151 /// user-friendly error if the response body is invalid JSON, or if it's not a
155 /// map. 152 /// map.
156 Map _parseJson(http.Response response) { 153 Map _parseJson(http.Response response) {
157 var value; 154 var value;
158 try { 155 try {
159 value = JSON.parse(response.body); 156 value = JSON.parse(response.body);
(...skipping 29 matching lines...) Expand all
189 var s = warnings.length == 1 ? '' : 's'; 186 var s = warnings.length == 1 ? '' : 's';
190 stdout.writeString("Package has ${warnings.length} warning$s. Upload " 187 stdout.writeString("Package has ${warnings.length} warning$s. Upload "
191 "anyway (y/n)? "); 188 "anyway (y/n)? ");
192 return readLine().transform((line) { 189 return readLine().transform((line) {
193 if (new RegExp(r"^[yY]").hasMatch(line)) return; 190 if (new RegExp(r"^[yY]").hasMatch(line)) return;
194 throw "Package upload canceled."; 191 throw "Package upload canceled.";
195 }); 192 });
196 }); 193 });
197 } 194 }
198 } 195 }
OLDNEW
« no previous file with comments | « no previous file | utils/pub/io.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698