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

Unified Diff: sdk/lib/_internal/pub/lib/src/pubspec.dart

Issue 417043005: Add publishTo to pubspec and use it in pub lish. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Revise. Created 6 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
Index: sdk/lib/_internal/pub/lib/src/pubspec.dart
diff --git a/sdk/lib/_internal/pub/lib/src/pubspec.dart b/sdk/lib/_internal/pub/lib/src/pubspec.dart
index 883a77c961c8c7344b6a119b251b9364a09c53d4..e9ea59669a88fb5b7d53774b912a4e28da38e3da 100644
--- a/sdk/lib/_internal/pub/lib/src/pubspec.dart
+++ b/sdk/lib/_internal/pub/lib/src/pubspec.dart
@@ -209,6 +209,41 @@ class Pubspec {
}
PubspecEnvironment _environment;
+ /// The URL of the server that the package should default to being published
+ /// to, "none" if the package should not be published, or `null` if it should
+ /// be published to the default server.
+ ///
+ /// If this does return a URL string, it will be a valid parseable URL.
+ String get publishTo {
+ if (_parsedPublishTo) return _publishTo;
+
+ var publishTo = fields['publishTo'];
+ if (publishTo != null) {
+ var span = fields.nodes['publishTo'].span;
+
+ if (publishTo is! String) {
+ _error('"publishTo" field must be a string.', span);
+ }
+
+ // It must be "none" or a valid URL.
+ if (publishTo != "none") {
+ _wrapFormatException('"publishTo" field', span,
+ () => Uri.parse(publishTo));
+ }
+ }
+
+ _parsedPublishTo = true;
+ _publishTo = publishTo;
+ return _publishTo;
+ }
+ bool _parsedPublishTo = false;
+ String _publishTo;
+
+ /// Whether the package is private and cannot be published.
+ ///
+ /// This is specified in the pubspec by setting "publishTo" to "none".
+ bool get isPrivate => publishTo == "none";
+
/// Whether or not the pubspec has no contents.
bool get isEmpty =>
name == null && version == Version.none && dependencies.isEmpty;
@@ -304,6 +339,7 @@ class Pubspec {
_getError(() => this.devDependencies);
_getError(() => this.transformers);
_getError(() => this.environment);
+ _getError(() => this.publishTo);
return errors;
}
« no previous file with comments | « sdk/lib/_internal/pub/lib/src/command/lish.dart ('k') | sdk/lib/_internal/pub/test/lish/does_not_publish_if_private_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698