| 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 pub.entrypoint; | 5 library pub.entrypoint; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:io'; | 8 import 'dart:io'; |
| 9 | 9 |
| 10 import 'package:package_config/packages_file.dart' as packages_file; | 10 import 'package:package_config/packages_file.dart' as packages_file; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 final SystemCache cache; | 49 final SystemCache cache; |
| 50 | 50 |
| 51 /// Whether to create and symlink a "packages" directory containing links to | 51 /// Whether to create and symlink a "packages" directory containing links to |
| 52 /// the installed packages. | 52 /// the installed packages. |
| 53 final bool _packageSymlinks; | 53 final bool _packageSymlinks; |
| 54 | 54 |
| 55 /// Whether this entrypoint is in memory only, as opposed to representing a | 55 /// Whether this entrypoint is in memory only, as opposed to representing a |
| 56 /// real directory on disk. | 56 /// real directory on disk. |
| 57 final bool _inMemory; | 57 final bool _inMemory; |
| 58 | 58 |
| 59 /// Whether this is an entrypoint for a globally-activated package. |
| 60 final bool isGlobal; |
| 61 |
| 59 /// The lockfile for the entrypoint. | 62 /// The lockfile for the entrypoint. |
| 60 /// | 63 /// |
| 61 /// If not provided to the entrypoint, it will be loaded lazily from disk. | 64 /// If not provided to the entrypoint, it will be loaded lazily from disk. |
| 62 LockFile get lockFile { | 65 LockFile get lockFile { |
| 63 if (_lockFile != null) return _lockFile; | 66 if (_lockFile != null) return _lockFile; |
| 64 | 67 |
| 65 if (!fileExists(lockFilePath)) { | 68 if (!fileExists(lockFilePath)) { |
| 66 _lockFile = new LockFile.empty(cache.sources); | 69 _lockFile = new LockFile.empty(cache.sources); |
| 67 } else { | 70 } else { |
| 68 _lockFile = new LockFile.load(lockFilePath, cache.sources); | 71 _lockFile = new LockFile.load(lockFilePath, cache.sources); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 String get pubspecPath => root.path('pubspec.yaml'); | 107 String get pubspecPath => root.path('pubspec.yaml'); |
| 105 | 108 |
| 106 /// The path to the entrypoint package's lockfile. | 109 /// The path to the entrypoint package's lockfile. |
| 107 String get lockFilePath => root.path('pubspec.lock'); | 110 String get lockFilePath => root.path('pubspec.lock'); |
| 108 | 111 |
| 109 /// Loads the entrypoint from a package at [rootDir]. | 112 /// Loads the entrypoint from a package at [rootDir]. |
| 110 /// | 113 /// |
| 111 /// If [packageSymlinks] is `true`, this will create a "packages" directory | 114 /// If [packageSymlinks] is `true`, this will create a "packages" directory |
| 112 /// with symlinks to the installed packages. This directory will be symlinked | 115 /// with symlinks to the installed packages. This directory will be symlinked |
| 113 /// into any directory that might contain an entrypoint. | 116 /// into any directory that might contain an entrypoint. |
| 114 Entrypoint(String rootDir, SystemCache cache, {bool packageSymlinks: true}) | 117 Entrypoint(String rootDir, SystemCache cache, {bool packageSymlinks: true, |
| 118 this.isGlobal: false}) |
| 115 : root = new Package.load(null, rootDir, cache.sources), | 119 : root = new Package.load(null, rootDir, cache.sources), |
| 116 cache = cache, | 120 cache = cache, |
| 117 _packageSymlinks = packageSymlinks, | 121 _packageSymlinks = packageSymlinks, |
| 118 _inMemory = false; | 122 _inMemory = false; |
| 119 | 123 |
| 120 /// Creates an entrypoint given package and lockfile objects. | 124 /// Creates an entrypoint given package and lockfile objects. |
| 121 Entrypoint.inMemory(this.root, this._lockFile, this.cache) | 125 Entrypoint.inMemory(this.root, this._lockFile, this.cache, |
| 126 {this.isGlobal: false}) |
| 122 : _packageSymlinks = false, | 127 : _packageSymlinks = false, |
| 123 _inMemory = true; | 128 _inMemory = true; |
| 124 | 129 |
| 125 /// Creates an entrypoint given a package and a [solveResult], from which the | 130 /// Creates an entrypoint given a package and a [solveResult], from which the |
| 126 /// package graph and lockfile will be computed. | 131 /// package graph and lockfile will be computed. |
| 127 Entrypoint.fromSolveResult(this.root, this.cache, SolveResult solveResult) | 132 Entrypoint.fromSolveResult(this.root, this.cache, SolveResult solveResult, |
| 133 {this.isGlobal: false}) |
| 128 : _packageSymlinks = false, | 134 : _packageSymlinks = false, |
| 129 _inMemory = true { | 135 _inMemory = true { |
| 130 _packageGraph = new PackageGraph.fromSolveResult(this, solveResult); | 136 _packageGraph = new PackageGraph.fromSolveResult(this, solveResult); |
| 131 _lockFile = _packageGraph.lockFile; | 137 _lockFile = _packageGraph.lockFile; |
| 132 } | 138 } |
| 133 | 139 |
| 134 /// Gets all dependencies of the [root] package. | 140 /// Gets all dependencies of the [root] package. |
| 135 /// | 141 /// |
| 136 /// Performs version resolution according to [SolveType]. | 142 /// Performs version resolution according to [SolveType]. |
| 137 /// | 143 /// |
| (...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 601 /// If [packageSymlinks] is true, creates a symlink to the "packages" | 607 /// If [packageSymlinks] is true, creates a symlink to the "packages" |
| 602 /// directory in [dir]. | 608 /// directory in [dir]. |
| 603 /// | 609 /// |
| 604 /// Otherwise, deletes a "packages" directories in [dir] if one exists. | 610 /// Otherwise, deletes a "packages" directories in [dir] if one exists. |
| 605 void _linkOrDeleteSecondaryPackageDir(String dir) { | 611 void _linkOrDeleteSecondaryPackageDir(String dir) { |
| 606 var symlink = p.join(dir, 'packages'); | 612 var symlink = p.join(dir, 'packages'); |
| 607 if (entryExists(symlink)) deleteEntry(symlink); | 613 if (entryExists(symlink)) deleteEntry(symlink); |
| 608 if (_packageSymlinks) createSymlink(packagesDir, symlink, relative: true); | 614 if (_packageSymlinks) createSymlink(packagesDir, symlink, relative: true); |
| 609 } | 615 } |
| 610 } | 616 } |
| OLD | NEW |