Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
D
dart.googlesource.com-pub
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
fuchsia-mirror
dart.googlesource.com-pub
Commits
69be47ed
Commit
69be47ed
authored
7 years ago
by
Bob Nystrom
Committed by
GitHub
7 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Allow publishing packages with SDK dependencies on Flutter. (#1562)
Fix #1560.
parent
f81cb51c
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/src/validator/dependency.dart
+18
-1
18 additions, 1 deletion
lib/src/validator/dependency.dart
test/validator/dependency_test.dart
+18
-0
18 additions, 0 deletions
test/validator/dependency_test.dart
with
36 additions
and
1 deletion
lib/src/validator/dependency.dart
+
18
−
1
View file @
69be47ed
...
...
@@ -12,6 +12,7 @@ import '../log.dart' as log;
import
'../package.dart'
;
import
'../source/hosted.dart'
;
import
'../source/path.dart'
;
import
'../source/sdk.dart'
;
import
'../validator.dart'
;
/// The range of all pub versions that don't support `^` version constraints.
...
...
@@ -41,7 +42,9 @@ class DependencyValidator extends Validator {
for
(
var
dependency
in
entrypoint
.
root
.
pubspec
.
dependencies
)
{
var
constraint
=
dependency
.
constraint
;
if
(
dependency
.
source
is
!
HostedSource
)
{
if
(
dependency
.
name
==
"flutter"
)
{
_warnAboutFlutterSdk
(
dependency
);
}
else
if
(
dependency
.
source
is
!
HostedSource
)
{
await
_warnAboutSource
(
dependency
);
}
else
if
(
constraint
.
isAny
)
{
_warnAboutNoConstraint
(
dependency
);
...
...
@@ -65,6 +68,20 @@ class DependencyValidator extends Validator {
}
}
/// Warn about improper dependencies on Flutter.
void
_warnAboutFlutterSdk
(
PackageDep
dep
)
{
if
(
dep
.
source
is
SdkSource
)
return
;
errors
.
add
(
'Don
\'
t depend on "
${dep.name}
" from the
${dep.source}
'
'source. Use the SDK source instead. For example:
\n
'
'
\n
'
'dependencies:
\n
'
'
${dep.name}
:
\n
'
' sdk:
${dep.constraint}
\n
'
'
\n
'
'The Flutter SDK is downloaded and managed outside of pub.'
);
}
/// Warn that dependencies should use the hosted source.
Future
_warnAboutSource
(
PackageDep
dep
)
async
{
List
<
Version
>
versions
;
...
...
This diff is collapsed.
Click to expand it.
test/validator/dependency_test.dart
+
18
−
0
View file @
69be47ed
...
...
@@ -72,6 +72,16 @@ main() {
])
.
create
();
expectNoValidationError
(
dependency
);
});
integration
(
'depends on Flutter from an SDK source'
,
()
{
d
.
dir
(
appPath
,
[
d
.
libPubspec
(
"test_pkg"
,
"1.0.0"
,
deps:
{
"flutter"
:
{
"sdk"
:
">=1.2.3 <2.0.0"
}
})
])
.
create
();
expectNoValidationError
(
dependency
);
});
});
group
(
'should consider a package invalid if it'
,
()
{
...
...
@@ -418,5 +428,13 @@ main() {
expectDependencyValidationError
(
' foo: ">=1.2.3 <2.0.0"'
);
});
});
integration
(
'depends on Flutter from a non-SDK source'
,
()
{
d
.
dir
(
appPath
,
[
d
.
libPubspec
(
"test_pkg"
,
"1.0.0"
,
deps:
{
"flutter"
:
">=1.2.3 <2.0.0"
})
])
.
create
();
expectDependencyValidationError
(
'sdk: >=1.2.3 <2.0.0'
);
});
});
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment