| 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('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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 return _loadLockFile() | 109 return _loadLockFile() |
| 110 .chain((lockFile) => resolveVersions(cache.sources, root, lockFile)) | 110 .chain((lockFile) => resolveVersions(cache.sources, root, lockFile)) |
| 111 .chain(_installDependencies); | 111 .chain(_installDependencies); |
| 112 } | 112 } |
| 113 | 113 |
| 114 /** | 114 /** |
| 115 * Installs the latest available versions of all dependencies of the [root] | 115 * Installs the latest available versions of all dependencies of the [root] |
| 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 updateDependencies() { | 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 |
| 126 * other dependencies as specified by the [LockFile]. Returns a [Future] that |
| 127 * completes when all dependencies are installed. |
| 128 */ |
| 129 Future updateDependencies(List<String> dependencies) { |
| 130 return _loadLockFile().chain((lockFile) { |
| 131 for (var dependency in dependencies) { |
| 132 // TODO(nweiz): How do we want to detect and handle unknown |
| 133 // dependencies here? |
| 134 lockFile.packages.remove(dependency); |
| 135 } |
| 136 return resolveVersions(cache.sources, root, lockFile); |
| 137 }).chain(_installDependencies); |
| 138 } |
| 139 |
| 140 /** |
| 125 * Installs all dependencies listed in [packageVersions] and writes a | 141 * Installs all dependencies listed in [packageVersions] and writes a |
| 126 * [LockFile]. | 142 * [LockFile]. |
| 127 */ | 143 */ |
| 128 Future _installDependencies(List<PackageId> packageVersions) { | 144 Future _installDependencies(List<PackageId> packageVersions) { |
| 129 return Futures.wait(packageVersions.map((id) { | 145 return Futures.wait(packageVersions.map((id) { |
| 130 if (id.source is RootSource) return new Future.immediate(id); | 146 if (id.source is RootSource) return new Future.immediate(id); |
| 131 return install(id); | 147 return install(id); |
| 132 })).chain(_saveLockFile); | 148 })).chain(_saveLockFile); |
| 133 } | 149 } |
| 134 | 150 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 */ | 183 */ |
| 168 Future _saveLockFile(List<PackageId> packageIds) { | 184 Future _saveLockFile(List<PackageId> packageIds) { |
| 169 var lockFile = new LockFile.empty(); | 185 var lockFile = new LockFile.empty(); |
| 170 for (var id in packageIds) { | 186 for (var id in packageIds) { |
| 171 if (id.source is! RootSource) lockFile.packages[id.name] = id; | 187 if (id.source is! RootSource) lockFile.packages[id.name] = id; |
| 172 } | 188 } |
| 173 | 189 |
| 174 return writeTextFile(join(root.dir, 'pubspec.lock'), lockFile.serialize()); | 190 return writeTextFile(join(root.dir, 'pubspec.lock'), lockFile.serialize()); |
| 175 } | 191 } |
| 176 } | 192 } |
| OLD | NEW |