Skip to content

Commit 9f1e952

Browse files
authored
Don't allow package features to be published (yet) (#1755)
This will allow users to play with package features locally without putting them into the package ecosystem.
1 parent 9cfea80 commit 9f1e952

File tree

2 files changed

+29
-142
lines changed

2 files changed

+29
-142
lines changed

lib/src/validator/dependency.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@ final _firstCaretVersion = new Version.parse("1.8.0-dev.3.0");
2222
/// The first Dart SDK version that supported Git path dependencies.
2323
final _firstGitPathVersion = new Version.parse("2.0.0-dev.1.0");
2424

25-
/// The first Dart SDK version that supported package features.
26-
final _firstFeatureVersion = new Version.parse("2.0.0-dev.1.0");
27-
2825
/// A validator that validates a package's dependencies.
2926
class DependencyValidator extends Validator {
3027
/// Whether any dependency has a caret constraint.
@@ -52,8 +49,11 @@ class DependencyValidator extends Validator {
5249
}
5350

5451
if (_hasFeatures) {
55-
validateSdkConstraint(_firstFeatureVersion,
56-
"Older versions of pub don't support package features.");
52+
// TODO(nweiz): Allow packages with features to be published when we have
53+
// analyzer support for telling the user that a given import requires a
54+
// given feature. When we do this, verify that packages with features have
55+
// an SDK constraint that's at least >=2.0.0-dev.11.0.
56+
errors.add("Packages with package features may not be published yet.");
5757
}
5858
}
5959

test/validator/dependency_test.dart

Lines changed: 24 additions & 137 deletions
Original file line numberDiff line numberDiff line change
@@ -74,54 +74,6 @@ main() {
7474
expectNoValidationError(dependency);
7575
});
7676

77-
test('depends on a feature with an appropriate SDK constraint', () async {
78-
await d.dir(appPath, [
79-
d.libPubspec("test_pkg", "1.0.0",
80-
deps: {
81-
"foo": {
82-
"version": "^1.2.3",
83-
"features": {"stuff": true}
84-
}
85-
},
86-
sdk: ">=2.0.0 <3.0.0")
87-
]).create();
88-
expectNoValidationError(dependency);
89-
});
90-
91-
test('declares a feature with an appropriate SDK constraint', () async {
92-
await d.dir(appPath, [
93-
d.pubspec({
94-
"name": "test_pkg",
95-
"version": "1.0.0",
96-
"features": {
97-
"stuff": {
98-
"dependencies": {"foo": "^1.0.0"}
99-
}
100-
},
101-
"environment": {"sdk": ">=2.0.0 <3.0.0"}
102-
})
103-
]).create();
104-
expectNoValidationError(dependency);
105-
});
106-
107-
test('declares a default-off feature with an appropriate SDK constraint',
108-
() async {
109-
await d.dir(appPath, [
110-
d.pubspec({
111-
"name": "test_pkg",
112-
"version": "1.0.0",
113-
"features": {
114-
"stuff": {
115-
"default": false,
116-
"dependencies": {"foo": "^1.0.0"}
117-
}
118-
},
119-
"environment": {"sdk": ">=2.0.0 <3.0.0"}
120-
})
121-
]).create();
122-
expectNoValidationError(dependency);
123-
});
124-
12577
test('has a git path dependency with an appropriate SDK constraint',
12678
() async {
12779
await d.dir(appPath, [
@@ -534,100 +486,35 @@ main() {
534486
});
535487
});
536488

537-
group('has a feature dependency', () {
538-
test('without an SDK constraint', () async {
539-
await d.dir(appPath, [
540-
d.libPubspec("test_pkg", "1.0.0", deps: {
541-
"foo": {
542-
"version": "^1.2.3",
543-
"features": {"stuff": true}
544-
}
545-
})
546-
]).create();
547-
548-
expectDependencyValidationError(' sdk: ">=2.0.0 <3.0.0"');
549-
});
550-
551-
test('with a too-broad SDK constraint', () async {
552-
await d.dir(appPath, [
553-
d.libPubspec("test_pkg", "1.0.0",
554-
deps: {
555-
"foo": {
556-
"version": "^1.2.3",
557-
"features": {"stuff": true}
558-
}
559-
},
560-
sdk: ">=1.24.0 <3.0.0")
561-
]).create();
489+
test('has a feature dependency', () async {
490+
await d.dir(appPath, [
491+
d.libPubspec("test_pkg", "1.0.0", deps: {
492+
"foo": {
493+
"version": "^1.2.3",
494+
"features": {"stuff": true}
495+
}
496+
})
497+
]).create();
562498

563-
expectDependencyValidationError(' sdk: ">=2.0.0 <3.0.0"');
564-
});
499+
expectDependencyValidationError(
500+
"Packages with package features may not be published yet.");
565501
});
566502

567-
group('declares a feature', () {
568-
test('without an constraint', () async {
569-
await d.dir(appPath, [
570-
d.pubspec({
571-
"name": "test_pkg",
572-
"version": "1.0.0",
573-
"features": {
574-
"stuff": {
575-
"dependencies": {"foo": "^1.0.0"}
576-
}
503+
test('declares a feature', () async {
504+
await d.dir(appPath, [
505+
d.pubspec({
506+
"name": "test_pkg",
507+
"version": "1.0.0",
508+
"features": {
509+
"stuff": {
510+
"dependencies": {"foo": "^1.0.0"}
577511
}
578-
})
579-
]).create();
580-
expectDependencyValidationError(' sdk: ">=2.0.0 <3.0.0"');
581-
});
582-
583-
test('with a too-broad SDK constraint', () async {
584-
await d.dir(appPath, [
585-
d.pubspec({
586-
"name": "test_pkg",
587-
"version": "1.0.0",
588-
"features": {
589-
"stuff": {
590-
"dependencies": {"foo": "^1.0.0"}
591-
}
592-
},
593-
"environment": {"sdk": ">=1.24.0 <3.0.0"}
594-
})
595-
]).create();
596-
expectDependencyValidationError(' sdk: ">=2.0.0 <3.0.0"');
597-
});
598-
599-
test('with an explicit default and a too-broad SDK constraint', () async {
600-
await d.dir(appPath, [
601-
d.pubspec({
602-
"name": "test_pkg",
603-
"version": "1.0.0",
604-
"features": {
605-
"stuff": {
606-
"default": true,
607-
"dependencies": {"foo": "^1.0.0"}
608-
}
609-
},
610-
"environment": {"sdk": ">=1.24.0 <3.0.0"}
611-
})
612-
]).create();
613-
expectDependencyValidationError(' sdk: ">=2.0.0 <3.0.0"');
614-
});
512+
}
513+
})
514+
]).create();
615515

616-
test('with an invalid dependency', () async {
617-
await d.dir(appPath, [
618-
d.pubspec({
619-
"name": "test_pkg",
620-
"version": "1.0.0",
621-
"features": {
622-
"stuff": {
623-
"dependencies": {"foo": "1.2.3"}
624-
}
625-
},
626-
"environment": {"sdk": ">=2.0.0 <3.0.0"}
627-
})
628-
]).create();
629-
expectDependencyValidationWarning(' foo: ^1.2.3');
630-
});
516+
expectDependencyValidationError(
517+
"Packages with package features may not be published yet.");
631518
});
632519

633520
test('depends on Flutter from a non-SDK source', () async {

0 commit comments

Comments
 (0)