| 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('source'); | 5 #library('source'); |
| 6 | 6 |
| 7 #import('package.dart'); | 7 #import('package.dart'); |
| 8 #import('pubspec.dart'); |
| 9 #import('version.dart'); |
| 8 | 10 |
| 9 /** | 11 /** |
| 10 * A source from which to install packages. | 12 * A source from which to install packages. |
| 11 * | 13 * |
| 12 * Each source has many packages that it looks up using [PackageId]s. The source | 14 * Each source has many packages that it looks up using [PackageId]s. The source |
| 13 * is responsible for installing these packages to the package cache. | 15 * is responsible for installing these packages to the package cache. |
| 14 */ | 16 */ |
| 15 class Source { | 17 class Source { |
| 16 /** | 18 /** |
| 17 * The name of the source. Should be lower-case, suitable for use in a | 19 * The name of the source. Should be lower-case, suitable for use in a |
| 18 * filename, and unique accross all sources. | 20 * filename, and unique accross all sources. |
| 19 */ | 21 */ |
| 20 abstract String get name(); | 22 abstract String get name(); |
| 21 | 23 |
| 22 /** | 24 /** |
| 23 * Whether this source's packages should be cached in Pub's global cache | 25 * Whether this source's packages should be cached in Pub's global cache |
| 24 * directory. | 26 * directory. |
| 25 * | 27 * |
| 26 * A source should be cached if it requires network access to retrieve | 28 * A source should be cached if it requires network access to retrieve |
| 27 * packages. It doesn't need to be cached if all packages are available | 29 * packages. It doesn't need to be cached if all packages are available |
| 28 * locally. | 30 * locally. |
| 29 */ | 31 */ |
| 30 abstract bool get shouldCache(); | 32 abstract bool get shouldCache(); |
| 31 | 33 |
| 32 /** | 34 /** |
| 35 * Get the list of all versions that exist for package [name]. |
| 36 * |
| 37 * Note that this does *not* require the packages to be installed, which is |
| 38 * the point. This is used during version resolution to determine which |
| 39 * package versions are available to be installed (or already installed). |
| 40 */ |
| 41 Future<List<Version>> getVersions(String name) { |
| 42 // TODO(rnystrom): Do something better here. |
| 43 throw "Source $name doesn't support versioning."; |
| 44 } |
| 45 |
| 46 /** |
| 47 * Loads the (possibly remote) pubspec for the desired [version] of the named |
| 48 * [package]. This will be called for packages that have not yet been |
| 49 * installed during the version resolution process. |
| 50 */ |
| 51 Future<Pubspec> describe(String package, Version version) { |
| 52 // TODO(rnystrom): Figure out how non-default sources should handle this. |
| 53 throw "Source $name doesn't support versioning."; |
| 54 } |
| 55 |
| 56 /** |
| 33 * Installs the package identified by [id] to [path]. Returns a [Future] that | 57 * Installs the package identified by [id] to [path]. Returns a [Future] that |
| 34 * completes when the installation was finished. The [Future] should resolve | 58 * completes when the installation was finished. The [Future] should resolve |
| 35 * to true if the package was found in the source and false if it wasn't. For | 59 * to true if the package was found in the source and false if it wasn't. For |
| 36 * all other error conditions, it should complete with an exception. | 60 * all other error conditions, it should complete with an exception. |
| 37 * | 61 * |
| 38 * [path] is guaranteed not to exist, and its parent directory is guaranteed | 62 * [path] is guaranteed not to exist, and its parent directory is guaranteed |
| 39 * to exist. | 63 * to exist. |
| 40 */ | 64 */ |
| 41 abstract Future<bool> install(PackageId id, String path); | 65 abstract Future<bool> install(PackageId id, String path); |
| 42 | 66 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 62 /** | 86 /** |
| 63 * Returns a human-friendly name for the package identified by [id]. This | 87 * Returns a human-friendly name for the package identified by [id]. This |
| 64 * method should be light-weight. It doesn't need to validate that the given | 88 * method should be light-weight. It doesn't need to validate that the given |
| 65 * package exists. | 89 * package exists. |
| 66 * | 90 * |
| 67 * The package name should be lower-case and suitable for use in a filename. | 91 * The package name should be lower-case and suitable for use in a filename. |
| 68 * It may contain forward slashes. | 92 * It may contain forward slashes. |
| 69 */ | 93 */ |
| 70 String packageName(PackageId id) => id.description; | 94 String packageName(PackageId id) => id.description; |
| 71 } | 95 } |
| OLD | NEW |