Index: sdk/lib/_internal/pub/lib/src/entrypoint.dart |
diff --git a/sdk/lib/_internal/pub/lib/src/entrypoint.dart b/sdk/lib/_internal/pub/lib/src/entrypoint.dart |
index aec7cf98a5fb935dfa8b2ee957cc5b7b90e4affb..317b1cb74cbf048086c5dae7cb70f27cffe64eb2 100644 |
--- a/sdk/lib/_internal/pub/lib/src/entrypoint.dart |
+++ b/sdk/lib/_internal/pub/lib/src/entrypoint.dart |
@@ -13,6 +13,7 @@ import 'io.dart'; |
import 'lock_file.dart'; |
import 'log.dart' as log; |
import 'package.dart'; |
+import 'package_graph.dart'; |
import 'system_cache.dart'; |
import 'utils.dart'; |
import 'solver/version_solver.dart'; |
@@ -186,6 +187,23 @@ class Entrypoint { |
return true; |
} |
+ /// Loads the package graph for the application and all of its transitive |
+ /// dependencies. |
+ Future<PackageGraph> loadPackageGraph() { |
+ return Future.wait(loadLockFile().packages.values.map((id) { |
+ var source = cache.sources[id.source]; |
+ return source.getDirectory(id) |
+ .then((dir) => new Package.load(id.name, dir, cache.sources)); |
+ })).then((packages) { |
+ var packageMap = <String, Package>{}; |
+ for (var package in packages) { |
+ packageMap[package.name] = package; |
+ } |
+ packageMap[root.name] = root; |
+ return new PackageGraph(this, packageMap); |
+ }); |
+ } |
+ |
/// Saves a list of concrete package versions to the `pubspec.lock` file. |
void _saveLockFile(List<PackageId> packageIds) { |
var lockFile = new LockFile.empty(); |