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

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

Issue 10854152: Allow `pub install` and `pub update` to update dependers. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Minor changes Created 8 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | utils/pub/version_solver.dart » ('j') | utils/pub/version_solver.dart » ('J')
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('package.dart'); 9 #import('package.dart');
10 #import('root_source.dart'); 10 #import('root_source.dart');
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 * package to its "package" directory, writing a new [LockFile]. Returns a 116 * package to its "package" directory, writing a new [LockFile]. Returns a
117 * [Future] that completes when all dependencies are installed. 117 * [Future] that completes when all dependencies are installed.
118 */ 118 */
119 Future updateAllDependencies() { 119 Future updateAllDependencies() {
120 return resolveVersions(cache.sources, root, new LockFile.empty()). 120 return resolveVersions(cache.sources, root, new LockFile.empty()).
121 chain(_installDependencies); 121 chain(_installDependencies);
122 } 122 }
123 123
124 /** 124 /**
125 * Installs the latest available versions of [dependencies], while leaving 125 * Installs the latest available versions of [dependencies], while leaving
126 * other dependencies as specified by the [LockFile]. Returns a [Future] that 126 * other dependencies as specified by the [LockFile] if possible. Returns a
127 * completes when all dependencies are installed. 127 * [Future] that completes when all dependencies are installed.
128 */ 128 */
129 Future updateDependencies(List<String> dependencies) { 129 Future updateDependencies(List<String> dependencies) {
130 return _loadLockFile().chain((lockFile) { 130 return _loadLockFile().chain((lockFile) {
131 var versionSolver = new VersionSolver(cache.sources, root, lockFile);
131 for (var dependency in dependencies) { 132 for (var dependency in dependencies) {
132 // TODO(nweiz): How do we want to detect and handle unknown 133 versionSolver.useBestVersion(dependency);
133 // dependencies here?
134 lockFile.packages.remove(dependency);
135 } 134 }
136 return resolveVersions(cache.sources, root, lockFile); 135 return versionSolver.solve();
137 }).chain(_installDependencies); 136 }).chain(_installDependencies);
138 } 137 }
139 138
140 /** 139 /**
141 * Installs all dependencies listed in [packageVersions] and writes a 140 * Installs all dependencies listed in [packageVersions] and writes a
142 * [LockFile]. 141 * [LockFile].
143 */ 142 */
144 Future _installDependencies(List<PackageId> packageVersions) { 143 Future _installDependencies(List<PackageId> packageVersions) {
145 return Futures.wait(packageVersions.map((id) { 144 return Futures.wait(packageVersions.map((id) {
146 if (id.source is RootSource) return new Future.immediate(id); 145 if (id.source is RootSource) return new Future.immediate(id);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 */ 182 */
184 Future _saveLockFile(List<PackageId> packageIds) { 183 Future _saveLockFile(List<PackageId> packageIds) {
185 var lockFile = new LockFile.empty(); 184 var lockFile = new LockFile.empty();
186 for (var id in packageIds) { 185 for (var id in packageIds) {
187 if (id.source is! RootSource) lockFile.packages[id.name] = id; 186 if (id.source is! RootSource) lockFile.packages[id.name] = id;
188 } 187 }
189 188
190 return writeTextFile(join(root.dir, 'pubspec.lock'), lockFile.serialize()); 189 return writeTextFile(join(root.dir, 'pubspec.lock'), lockFile.serialize());
191 } 190 }
192 } 191 }
OLDNEW
« no previous file with comments | « no previous file | utils/pub/version_solver.dart » ('j') | utils/pub/version_solver.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698