Skip to content

Commit

Permalink
Split out directDependencies and devDependencies in pub deps (#4383)
Browse files Browse the repository at this point in the history
  • Loading branch information
sigurdm authored Sep 25, 2024
1 parent 1892c46 commit 23e3d4f
Show file tree
Hide file tree
Showing 11 changed files with 196 additions and 22 deletions.
12 changes: 11 additions & 1 deletion lib/src/command/deps.dart
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,17 @@ class DepsCommand extends PubCommand {
'version': currentPackage.version.toString(),
'kind': kind,
'source': source,
'dependencies': next,
// This field is kept for backwards compatibility with dart 3.5 and
// before. Clients should opt to consume directDependencies and
// devDependencies separately instead.
'dependencies': (isRoot
? currentPackage.dependencies
: currentPackage.immediateDependencies)
.keys
.toList(),
'directDependencies': currentPackage.dependencies.keys.toList(),
if (isRoot)
'devDependencies': currentPackage.devDependencies.keys.toList(),
});
toVisit.addAll(next);
}
Expand Down
47 changes: 40 additions & 7 deletions test/deps_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -158,17 +158,24 @@ void main() {
"dependencies": [
"normal",
"overridden",
"from_path",
"unittest",
"override_only"
"from_path"
],
"directDependencies": [
"normal",
"overridden",
"from_path"
],
"devDependencies": [
"unittest"
]
},
{
"name": "override_only",
"version": "1.2.3",
"kind": "transitive",
"source": "hosted",
"dependencies": []
"dependencies": [],
"directDependencies": []
},
{
"name": "unittest",
Expand All @@ -178,14 +185,19 @@ void main() {
"dependencies": [
"shared",
"dev_only"
],
"directDependencies": [
"shared",
"dev_only"
]
},
{
"name": "dev_only",
"version": "1.2.3",
"kind": "transitive",
"source": "hosted",
"dependencies": []
"dependencies": [],
"directDependencies": []
},
{
"name": "shared",
Expand All @@ -194,6 +206,9 @@ void main() {
"source": "hosted",
"dependencies": [
"other"
],
"directDependencies": [
"other"
]
},
{
Expand All @@ -203,21 +218,26 @@ void main() {
"source": "hosted",
"dependencies": [
"myapp"
],
"directDependencies": [
"myapp"
]
},
{
"name": "from_path",
"version": "1.2.3",
"kind": "direct",
"source": "path",
"dependencies": []
"dependencies": [],
"directDependencies": []
},
{
"name": "overridden",
"version": "2.0.0",
"kind": "direct",
"source": "hosted",
"dependencies": []
"dependencies": [],
"directDependencies": []
},
{
"name": "normal",
Expand All @@ -227,6 +247,10 @@ void main() {
"dependencies": [
"transitive",
"circular_a"
],
"directDependencies": [
"transitive",
"circular_a"
]
},
{
Expand All @@ -236,6 +260,9 @@ void main() {
"source": "hosted",
"dependencies": [
"circular_b"
],
"directDependencies": [
"circular_b"
]
},
{
Expand All @@ -245,6 +272,9 @@ void main() {
"source": "hosted",
"dependencies": [
"circular_a"
],
"directDependencies": [
"circular_a"
]
},
{
Expand All @@ -254,6 +284,9 @@ void main() {
"source": "hosted",
"dependencies": [
"shared"
],
"directDependencies": [
"shared"
]
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,28 @@ $ pub deps --json
"dependencies": [
"foo",
"bar"
]
],
"directDependencies": [
"foo",
"bar"
],
"devDependencies": []
},
{
"name": "bar",
"version": "1.0.0",
"kind": "direct",
"source": "path",
"dependencies": []
"dependencies": [],
"directDependencies": []
},
{
"name": "foo",
"version": "1.0.0",
"kind": "direct",
"source": "path",
"dependencies": []
"dependencies": [],
"directDependencies": []
}
],
"sdks": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ $ pub deps --json
"version": "0.0.0",
"kind": "root",
"source": "root",
"dependencies": [
"dependencies": [],
"directDependencies": [],
"devDependencies": [
"foo"
]
},
Expand All @@ -43,7 +45,8 @@ $ pub deps --json
"version": "1.0.0",
"kind": "dev",
"source": "path",
"dependencies": []
"dependencies": [],
"directDependencies": []
}
],
"sdks": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ $ pub deps --json
"version": "0.0.0",
"kind": "root",
"source": "root",
"dependencies": []
"dependencies": [],
"directDependencies": [],
"devDependencies": []
}
],
"sdks": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,19 @@ $ pub deps --json
"source": "root",
"dependencies": [
"foo"
]
],
"directDependencies": [
"foo"
],
"devDependencies": []
},
{
"name": "foo",
"version": "1.0.0",
"kind": "direct",
"source": "path",
"dependencies": []
"dependencies": [],
"directDependencies": []
}
],
"sdks": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ $ pub deps --json
"source": "root",
"dependencies": [
"foo"
]
],
"directDependencies": [
"foo"
],
"devDependencies": []
},
{
"name": "foo",
Expand All @@ -49,14 +53,18 @@ $ pub deps --json
"source": "path",
"dependencies": [
"baz"
],
"directDependencies": [
"baz"
]
},
{
"name": "baz",
"version": "1.0.0",
"kind": "transitive",
"source": "path",
"dependencies": []
"dependencies": [],
"directDependencies": []
}
],
"sdks": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,19 @@ $ pub deps --json
"source": "root",
"dependencies": [
"foo"
]
],
"directDependencies": [
"foo"
],
"devDependencies": []
},
{
"name": "foo",
"version": "2.0.0",
"kind": "direct",
"source": "path",
"dependencies": []
"dependencies": [],
"directDependencies": []
}
],
"sdks": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ $ pub deps --json
"version": "0.0.0",
"kind": "root",
"source": "root",
"dependencies": []
"dependencies": [],
"directDependencies": [],
"devDependencies": []
}
],
"sdks": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ $ pub deps --json
"version": "0.0.0",
"kind": "root",
"source": "root",
"dependencies": []
"dependencies": [],
"directDependencies": [],
"devDependencies": []
}
],
"sdks": [
Expand Down
Loading

0 comments on commit 23e3d4f

Please sign in to comment.