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

Unified Diff: lib/src/package_locations.dart

Issue 1282083002: Generate the package spec from the lockfile. (Closed) Base URL: git@github.com:dart-lang/pub.git@master
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
« lib/src/lock_file.dart ('K') | « lib/src/lock_file.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/package_locations.dart
diff --git a/lib/src/package_locations.dart b/lib/src/package_locations.dart
deleted file mode 100644
index 78ebb1865c8d263dca997ba80385cfa556af92ba..0000000000000000000000000000000000000000
--- a/lib/src/package_locations.dart
+++ /dev/null
@@ -1,61 +0,0 @@
-// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-/// Keeps track of locations of packages, and can create a `.packages` file.
-// TODO(lrn): Also move packages/ directory management to this library.
-library pub.package_locations;
-
-import 'package:package_config/packages_file.dart' as packages_file;
-import 'package:path/path.dart' as p;
-
-import 'package_graph.dart';
-import 'io.dart';
-import 'utils.dart' show ordered;
-
-/// Creates a `.packages` file with the locations of the packages in [graph].
-///
-/// The file is written to [path], which defaults to the root directory of the
-/// entrypoint of [graph].
-///
-/// If the file already exists, it is deleted before the new content is written.
-void writePackagesMap(PackageGraph graph, [String path]) {
- path ??= graph.entrypoint.root.path(".packages");
- var content = _createPackagesMap(graph);
- writeTextFile(path, content);
-}
-
-/// Template for header text put into `.packages` file.
-///
-/// Contains the literal string `$now` which should be replaced by a timestamp.
-const _headerText = r"""
-Generate by pub on $now.
-This file contains a map from Dart package names to Dart package locations.
-Dart tools, including the Dart VM and Dart analyzer, rely on the content.
-AUTO GENERATED - DO NOT EDIT
-""";
-
-/// Returns the contents of the `.packages` file created from a package graph.
-///
-/// The paths in the generated `.packages` file are always absolute URIs.
-String _createPackagesMap(PackageGraph packageGraph) {
- var header = _headerText.replaceFirst(r"$now", new DateTime.now().toString());
-
- var packages = packageGraph.packages;
- var uriMap = {};
- for (var packageName in ordered(packages.keys)) {
- var package = packages[packageName];
-
- // This indicates an in-memory package, which is presumably a fake
- // entrypoint we created for something like "pub global activate". We don't
- // need to import from it anyway, so we can just not add it to the map.
- if (package.dir == null) continue;
-
- var location = package.path("lib");
- uriMap[packageName] = p.toUri(location);
- }
-
- var text = new StringBuffer();
- packages_file.write(text, uriMap, comment: header);
- return text.toString();
-}
« lib/src/lock_file.dart ('K') | « lib/src/lock_file.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698