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

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

Issue 11472016: Revert "Add logging system to pub and sprinkle some logging in." (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 | « utils/pub/curl_client.dart ('k') | utils/pub/git.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 entrypoint; 5 library entrypoint;
6 6
7 import 'io.dart'; 7 import 'io.dart';
8 import 'lock_file.dart'; 8 import 'lock_file.dart';
9 import 'log.dart' as log;
10 import 'package.dart'; 9 import 'package.dart';
11 import 'root_source.dart'; 10 import 'root_source.dart';
12 import 'system_cache.dart'; 11 import 'system_cache.dart';
13 import 'version.dart'; 12 import 'version.dart';
14 import 'version_solver.dart'; 13 import 'version_solver.dart';
15 import 'utils.dart'; 14 import 'utils.dart';
16 15
17 /** 16 /**
18 * Pub operates over a directed graph of dependencies that starts at a root 17 * Pub operates over a directed graph of dependencies that starts at a root
19 * "entrypoint" package. This is typically the package where the current 18 * "entrypoint" package. This is typically the package where the current
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 var pendingOrCompleted = _installs[id]; 80 var pendingOrCompleted = _installs[id];
82 if (pendingOrCompleted != null) return pendingOrCompleted; 81 if (pendingOrCompleted != null) return pendingOrCompleted;
83 82
84 var packageDir = join(path, id.name); 83 var packageDir = join(path, id.name);
85 var future = ensureDir(dirname(packageDir)).chain((_) { 84 var future = ensureDir(dirname(packageDir)).chain((_) {
86 return exists(packageDir); 85 return exists(packageDir);
87 }).chain((exists) { 86 }).chain((exists) {
88 if (!exists) return new Future.immediate(null); 87 if (!exists) return new Future.immediate(null);
89 // TODO(nweiz): figure out when to actually delete the directory, and when 88 // TODO(nweiz): figure out when to actually delete the directory, and when
90 // we can just re-use the existing symlink. 89 // we can just re-use the existing symlink.
91 log.fine("Deleting package directory for ${id.name} before install.");
92 return deleteDir(packageDir); 90 return deleteDir(packageDir);
93 }).chain((_) { 91 }).chain((_) {
94 if (id.source.shouldCache) { 92 if (id.source.shouldCache) {
95 return cache.install(id).chain( 93 return cache.install(id).chain(
96 (pkg) => createPackageSymlink(id.name, pkg.dir, packageDir)); 94 (pkg) => createPackageSymlink(id.name, pkg.dir, packageDir));
97 } else { 95 } else {
98 return id.source.install(id, packageDir).transform((found) { 96 return id.source.install(id, packageDir).transform((found) {
99 if (found) return null; 97 if (found) return null;
100 // TODO(nweiz): More robust error-handling. 98 // TODO(nweiz): More robust error-handling.
101 throw 'Package ${id.name} not found in source "${id.source.name}".'; 99 throw 'Package ${id.name} not found in source "${id.source.name}".';
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 /** 160 /**
163 * Loads the list of concrete package versions from the `pubspec.lock`, if it 161 * Loads the list of concrete package versions from the `pubspec.lock`, if it
164 * exists. If it doesn't, this completes to an empty [LockFile]. 162 * exists. If it doesn't, this completes to an empty [LockFile].
165 * 163 *
166 * If there's an error reading the `pubspec.lock` file, this will print a 164 * If there's an error reading the `pubspec.lock` file, this will print a
167 * warning message and act as though the file doesn't exist. 165 * warning message and act as though the file doesn't exist.
168 */ 166 */
169 Future<LockFile> _loadLockFile() { 167 Future<LockFile> _loadLockFile() {
170 var completer = new Completer<LockFile>(); 168 var completer = new Completer<LockFile>();
171 var lockFilePath = join(root.dir, 'pubspec.lock'); 169 var lockFilePath = join(root.dir, 'pubspec.lock');
172
173 log.fine("Loading lockfile.");
174 var future = readTextFile(lockFilePath); 170 var future = readTextFile(lockFilePath);
175 171
176 future.handleException((_) { 172 future.handleException((_) {
177 // If we failed to load the lockfile but it does exist, something's 173 // If we failed to load the lockfile but it does exist, something's
178 // probably wrong and we should notify the user. 174 // probably wrong and we should notify the user.
179 fileExists(lockFilePath).transform((exists) { 175 fileExists(lockFilePath).transform((exists) {
180 if (!exists) return; 176 if (!exists) return;
181 log.error("Error reading pubspec.lock: ${future.exception}"); 177 printError("Error reading pubspec.lock: ${future.exception}");
182 }).then((_) { 178 }).then((_) {
183 log.fine("No lock file at $lockFilePath, creating empty one.");
184 completer.complete(new LockFile.empty()); 179 completer.complete(new LockFile.empty());
185 }); 180 });
186 181
187 return true; 182 return true;
188 }); 183 });
189 184
190 future.then((text) => 185 future.then((text) =>
191 completer.complete(new LockFile.parse(text, cache.sources))); 186 completer.complete(new LockFile.parse(text, cache.sources)));
192 return completer.future; 187 return completer.future;
193 } 188 }
194 189
195 /** 190 /**
196 * Saves a list of concrete package versions to the `pubspec.lock` file. 191 * Saves a list of concrete package versions to the `pubspec.lock` file.
197 */ 192 */
198 Future _saveLockFile(List<PackageId> packageIds) { 193 Future _saveLockFile(List<PackageId> packageIds) {
199 var lockFile = new LockFile.empty(); 194 var lockFile = new LockFile.empty();
200 for (var id in packageIds) { 195 for (var id in packageIds) {
201 if (id.source is! RootSource) lockFile.packages[id.name] = id; 196 if (id.source is! RootSource) lockFile.packages[id.name] = id;
202 } 197 }
203 198
204 var lockFilePath = join(root.dir, 'pubspec.lock'); 199 return writeTextFile(join(root.dir, 'pubspec.lock'), lockFile.serialize());
205 log.fine("Saving lockfile.");
206 return writeTextFile(lockFilePath, lockFile.serialize());
207 } 200 }
208 201
209 /** 202 /**
210 * Installs a self-referential symlink in the `packages` directory that will 203 * Installs a self-referential symlink in the `packages` directory that will
211 * allow a package to import its own files using `package:`. 204 * allow a package to import its own files using `package:`.
212 */ 205 */
213 Future _installSelfReference(_) { 206 Future _installSelfReference(_) {
214 var linkPath = join(path, root.name); 207 var linkPath = join(path, root.name);
215 return exists(linkPath).chain((exists) { 208 return exists(linkPath).chain((exists) {
216 // Create the symlink if it doesn't exist. 209 // Create the symlink if it doesn't exist.
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 * Creates a symlink to the `packages` directory in [dir] if none exists. 279 * Creates a symlink to the `packages` directory in [dir] if none exists.
287 */ 280 */
288 Future _linkSecondaryPackageDir(String dir) { 281 Future _linkSecondaryPackageDir(String dir) {
289 var to = join(dir, 'packages'); 282 var to = join(dir, 'packages');
290 return exists(to).chain((exists) { 283 return exists(to).chain((exists) {
291 if (exists) return new Future.immediate(null); 284 if (exists) return new Future.immediate(null);
292 return createSymlink(path, to); 285 return createSymlink(path, to);
293 }); 286 });
294 } 287 }
295 } 288 }
OLDNEW
« no previous file with comments | « utils/pub/curl_client.dart ('k') | utils/pub/git.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698