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

Side by Side Diff: utils/pub/source.dart

Issue 10340005: Add support for pub install. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review changes Created 8 years, 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « utils/pub/sdk_source.dart ('k') | utils/pub/system_cache.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 /**
6 * A source from which to install packages.
7 *
8 * Each source has many packages that it looks up using [PackageId]s. The source
9 * is responsible for installing these packages to the package cache.
10 */
11 class Source {
12 /**
13 * The default [Source] from which to fetch packages if no other [Source] is
14 * specified.
15 */
16 static Source defaultSource;
17
18 /**
19 * Looks up a source based on its name.
20 */
21 static Source fromName(String name) {
22 // TODO(nweiz): add a more principled way of registering sources here once
23 // we have more than one source. Especially important for plugins.
24 if (name == 'sdk') return defaultSource;
25 throw 'Unknown source "$name"';
26 }
27
28 /**
29 * The name of the source. Should be lower-case, suitable for use in a
30 * filename, and unique accross all sources.
31 */
32 abstract String get name();
33
34 /**
35 * Whether this source's packages should be cached in Pub's global cache
36 * directory.
37 *
38 * A source should be cached if it requires network access to retrieve
39 * packages. It doesn't need to be cached if all packages are available
40 * locally.
41 */
42 abstract bool get shouldCache();
43
44 /**
45 * Installs the package identified by [id] to [path]. Returns a [Future] that
46 * completes when the installation was finished. The [Future] should resolve
47 * to true if the package was found in the source and false if it wasn't. For
48 * all other error conditions, it should complete with an exception.
49 *
50 * If [shouldCache] is true, [path] will be a path to this source's
51 * subdirectory of the [PackageCache]'s cache directory. If [shouldCache] is
52 * false, [path] will be a path to the application's "packages" directory.
53 *
54 * [path] is guaranteed not to exist, and its parent directory is guaranteed
55 * to exist.
56 */
57 abstract Future<bool> install(PackageId id, String path);
58
59 /**
60 * Returns the name of the package identified by [id]. By default, this is
61 * just `id.fullName`, but some sources (e.g. Git) may have more complicated
62 * resolution logic.
63 *
64 * This method should be light-weight. It doesn't need to validate that the
65 * given package exists.
66 *
67 * The package name should be lower-case and suitable for use in a filename.
68 * It may contain forward slashes.
69 */
70 String packageName(PackageId id) => id.fullName;
71 }
OLDNEW
« no previous file with comments | « utils/pub/sdk_source.dart ('k') | utils/pub/system_cache.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698