Added a dart pub outdated --transitive option (#2731)
diff --git a/lib/src/command/outdated.dart b/lib/src/command/outdated.dart
index 4925e82..55eed77 100644
--- a/lib/src/command/outdated.dart
+++ b/lib/src/command/outdated.dart
@@ -55,6 +55,12 @@
help: 'Take dev dependencies into account.',
);
+ argParser.addFlag(
+ 'transitive',
+ help: 'Show transitive dependencies.\n'
+ '(defaults to off in --mode=null-safety).',
+ );
+
argParser.addFlag('json',
help: 'Output the results using a json format.', negatable: false);
@@ -68,7 +74,7 @@
argParser.addFlag('prereleases',
help: 'Include prereleases in latest version.\n'
- '(Defaults to on in --mode=null-safety).');
+ '(defaults to on in --mode=null-safety).');
// Preserve for backwards compatibility.
argParser.addFlag('pre-releases',
@@ -227,10 +233,19 @@
lockFileExists: fileExists(entrypoint.lockFilePath),
hasDirectDependencies: rootPubspec.dependencies.isNotEmpty,
hasDevDependencies: rootPubspec.devDependencies.isNotEmpty,
+ showTransitiveDependencies: showTransitiveDependencies,
);
}
}
+ bool get showTransitiveDependencies {
+ if (argResults.wasParsed('transitive')) {
+ return argResults['transitive'];
+ }
+ // We default to hidding transitive dependencies in --mode=null-safety
+ return argResults['mode'] != 'null-safety';
+ }
+
bool _prereleases;
bool get prereleases => _prereleases ??= () {
@@ -387,6 +402,7 @@
@required bool lockFileExists,
@required bool hasDirectDependencies,
@required bool hasDevDependencies,
+ @required bool showTransitiveDependencies,
}) async {
final explanation = mode.explanation;
if (explanation != null) {
@@ -440,13 +456,15 @@
],
...devRows,
],
- if (transitiveRows.isNotEmpty)
- [_format('\ntransitive dependencies:', log.bold)],
- ...transitiveRows,
- if (includeDevDependencies) ...[
- if (devTransitiveRows.isNotEmpty)
- [_format('\ntransitive dev_dependencies:', log.bold)],
- ...devTransitiveRows,
+ if (showTransitiveDependencies) ...[
+ if (transitiveRows.isNotEmpty)
+ [_format('\ntransitive dependencies:', log.bold)],
+ ...transitiveRows,
+ if (includeDevDependencies) ...[
+ if (devTransitiveRows.isNotEmpty)
+ [_format('\ntransitive dev_dependencies:', log.bold)],
+ ...devTransitiveRows,
+ ],
],
];
@@ -476,14 +494,22 @@
.where((row) =>
row.current != null &&
row.upgradable != null &&
- row.current != row.upgradable)
+ row.current != row.upgradable &&
+ // Include transitive only, if we show them
+ (showTransitiveDependencies ||
+ hasKind(_DependencyKind.direct)(row) ||
+ hasKind(_DependencyKind.dev)(row)))
.length;
var notAtResolvable = rows
.where((row) =>
(row.current != null || !lockFileExists) &&
row.resolvable != null &&
- row.upgradable != row.resolvable)
+ row.upgradable != row.resolvable &&
+ // Include transitive only, if we show them
+ (showTransitiveDependencies ||
+ hasKind(_DependencyKind.direct)(row) ||
+ hasKind(_DependencyKind.dev)(row)))
.length;
if (lockFileExists) {
diff --git a/test/outdated/goldens/circular_dependencies.txt b/test/outdated/goldens/circular_dependencies.txt
index 8eca3b0..7f7be45 100644
--- a/test/outdated/goldens/circular_dependencies.txt
+++ b/test/outdated/goldens/circular_dependencies.txt
@@ -31,6 +31,18 @@
1 upgradable dependency is locked (in pubspec.lock) to an older version.
To update it, use `pub upgrade`.
+$ pub outdated --no-color --no-transitive
+Showing outdated packages.
+[*] indicates versions that are not the latest available.
+
+Package Name Current Upgradable Resolvable Latest
+
+direct dependencies:
+foo *1.2.3 1.3.0 1.3.0 1.3.0
+
+1 upgradable dependency is locked (in pubspec.lock) to an older version.
+To update it, use `pub upgrade`.
+
$ pub outdated --no-color --up-to-date
Showing outdated packages.
[*] indicates versions that are not the latest available.
@@ -92,6 +104,19 @@
1 upgradable dependency is locked (in pubspec.lock) to an older version.
To update it, use `pub upgrade`.
+$ pub outdated --no-color --mode=null-safety --transitive
+Showing dependencies that are currently not opted in to null-safety.
+[✗] indicates versions without null safety support.
+[✓] indicates versions opting in to null safety.
+
+Package Name Current Upgradable Resolvable Latest
+
+direct dependencies:
+foo ✗1.2.3 ✗1.3.0 ✗1.3.0 ✗1.3.0
+
+1 upgradable dependency is locked (in pubspec.lock) to an older version.
+To update it, use `pub upgrade`.
+
$ pub outdated --no-color --mode=null-safety --no-prereleases
Showing dependencies that are currently not opted in to null-safety.
[✗] indicates versions without null safety support.
diff --git a/test/outdated/goldens/dependency_overrides.txt b/test/outdated/goldens/dependency_overrides.txt
index b751abf..82a807f 100644
--- a/test/outdated/goldens/dependency_overrides.txt
+++ b/test/outdated/goldens/dependency_overrides.txt
@@ -73,6 +73,21 @@
A resolution compatible with the Latest versions doesn't exist, as they are not
mutually compatible.
+$ pub outdated --no-color --no-transitive
+Showing outdated packages.
+[*] indicates versions that are not the latest available.
+
+Package Name Current Upgradable Resolvable Latest
+
+direct dependencies:
+bar *1.0.1 (overridden) *1.0.1 (overridden) *1.0.1 (overridden) 2.0.0
+baz *2.0.0 (overridden) *2.0.0 (overridden) *2.0.0 (overridden) 2.0.0
+foo *1.0.1 (overridden) *1.0.1 (overridden) *1.0.1 (overridden) 2.0.0
+
+Current dependencies are constrained to versions listed in Resolvable.
+A resolution compatible with the Latest versions doesn't exist, as they are not
+mutually compatible.
+
$ pub outdated --no-color --up-to-date
Showing outdated packages.
[*] indicates versions that are not the latest available.
@@ -151,6 +166,22 @@
A resolution compatible with the Latest versions doesn't exist, as they are not
mutually compatible.
+$ pub outdated --no-color --mode=null-safety --transitive
+Showing dependencies that are currently not opted in to null-safety.
+[✗] indicates versions without null safety support.
+[✓] indicates versions opting in to null safety.
+
+Package Name Current Upgradable Resolvable Latest
+
+direct dependencies:
+bar ✗1.0.1 (overridden) ✗1.0.1 (overridden) ✗1.0.1 (overridden) ✗2.0.0
+baz ✗2.0.0 (overridden) ✗2.0.0 (overridden) ✗2.0.0 (overridden) ✗2.0.0
+foo ✗1.0.1 (overridden) ✗1.0.1 (overridden) ✗1.0.1 (overridden) ✗2.0.0
+
+Current dependencies are constrained to versions listed in Resolvable.
+A resolution compatible with the Latest versions doesn't exist, as they are not
+mutually compatible.
+
$ pub outdated --no-color --mode=null-safety --no-prereleases
Showing dependencies that are currently not opted in to null-safety.
[✗] indicates versions without null safety support.
diff --git a/test/outdated/goldens/dependency_overrides_no_solution.txt b/test/outdated/goldens/dependency_overrides_no_solution.txt
index 30e1270..c62e74f 100644
--- a/test/outdated/goldens/dependency_overrides_no_solution.txt
+++ b/test/outdated/goldens/dependency_overrides_no_solution.txt
@@ -54,6 +54,20 @@
A resolution compatible with the Latest versions doesn't exist, as they are not
mutually compatible.
+$ pub outdated --no-color --no-transitive
+Showing outdated packages.
+[*] indicates versions that are not the latest available.
+
+Package Name Current Upgradable Resolvable Latest
+
+direct dependencies:
+bar *1.0.0 (overridden) *1.0.0 (overridden) *1.0.0 (overridden) 2.0.0
+foo *1.0.0 (overridden) *1.0.0 (overridden) *1.0.0 (overridden) 2.0.0
+
+Current dependencies are constrained to versions listed in Resolvable.
+A resolution compatible with the Latest versions doesn't exist, as they are not
+mutually compatible.
+
$ pub outdated --no-color --up-to-date
Showing outdated packages.
[*] indicates versions that are not the latest available.
@@ -125,6 +139,21 @@
A resolution compatible with the Latest versions doesn't exist, as they are not
mutually compatible.
+$ pub outdated --no-color --mode=null-safety --transitive
+Showing dependencies that are currently not opted in to null-safety.
+[✗] indicates versions without null safety support.
+[✓] indicates versions opting in to null safety.
+
+Package Name Current Upgradable Resolvable Latest
+
+direct dependencies:
+bar ✗1.0.0 (overridden) ✗1.0.0 (overridden) ✗1.0.0 (overridden) ✗2.0.0
+foo ✗1.0.0 (overridden) ✗1.0.0 (overridden) ✗1.0.0 (overridden) ✗2.0.0
+
+Current dependencies are constrained to versions listed in Resolvable.
+A resolution compatible with the Latest versions doesn't exist, as they are not
+mutually compatible.
+
$ pub outdated --no-color --mode=null-safety --no-prereleases
Showing dependencies that are currently not opted in to null-safety.
[✗] indicates versions without null safety support.
diff --git a/test/outdated/goldens/helptext.txt b/test/outdated/goldens/helptext.txt
index e73ae08..f440ddd 100644
--- a/test/outdated/goldens/helptext.txt
+++ b/test/outdated/goldens/helptext.txt
@@ -10,13 +10,15 @@
(defaults to on)
--[no-]dev-dependencies Take dev dependencies into account.
(defaults to on)
+ --[no-]transitive Show transitive dependencies.
+ (defaults to off in --mode=null-safety).
--json Output the results using a json format.
--mode=<PROPERTY> Highlight versions with PROPERTY.
Only packages currently missing that PROPERTY
will be included unless --show-all.
[outdated (default), null-safety]
--[no-]prereleases Include prereleases in latest version.
- (Defaults to on in --mode=null-safety).
+ (defaults to on in --mode=null-safety).
--[no-]show-all Include dependencies that are already
fullfilling --mode.
diff --git a/test/outdated/goldens/mutually_incompatible.txt b/test/outdated/goldens/mutually_incompatible.txt
index 5ea9b73..a6109b5 100644
--- a/test/outdated/goldens/mutually_incompatible.txt
+++ b/test/outdated/goldens/mutually_incompatible.txt
@@ -48,6 +48,20 @@
A resolution compatible with the Latest versions doesn't exist, as they are not
mutually compatible.
+$ pub outdated --no-color --no-transitive
+Showing outdated packages.
+[*] indicates versions that are not the latest available.
+
+Package Name Current Upgradable Resolvable Latest
+
+direct dependencies:
+bar *1.0.0 *1.0.0 *1.0.0 2.0.0
+foo *1.0.0 *1.0.0 *1.0.0 2.0.0
+
+Current dependencies are constrained to versions listed in Resolvable.
+A resolution compatible with the Latest versions doesn't exist, as they are not
+mutually compatible.
+
$ pub outdated --no-color --up-to-date
Showing outdated packages.
[*] indicates versions that are not the latest available.
@@ -119,6 +133,21 @@
A resolution compatible with the Latest versions doesn't exist, as they are not
mutually compatible.
+$ pub outdated --no-color --mode=null-safety --transitive
+Showing dependencies that are currently not opted in to null-safety.
+[✗] indicates versions without null safety support.
+[✓] indicates versions opting in to null safety.
+
+Package Name Current Upgradable Resolvable Latest
+
+direct dependencies:
+bar ✗1.0.0 ✗1.0.0 ✗1.0.0 ✗2.0.0
+foo ✗1.0.0 ✗1.0.0 ✗1.0.0 ✗2.0.0
+
+Current dependencies are constrained to versions listed in Resolvable.
+A resolution compatible with the Latest versions doesn't exist, as they are not
+mutually compatible.
+
$ pub outdated --no-color --mode=null-safety --no-prereleases
Showing dependencies that are currently not opted in to null-safety.
[✗] indicates versions without null safety support.
diff --git a/test/outdated/goldens/newer_versions.txt b/test/outdated/goldens/newer_versions.txt
index e916ff6..2f36e62 100644
--- a/test/outdated/goldens/newer_versions.txt
+++ b/test/outdated/goldens/newer_versions.txt
@@ -110,6 +110,24 @@
3 dependencies are constrained to versions that are older than a resolvable version.
To update these dependencies, edit pubspec.yaml.
+$ pub outdated --no-color --no-transitive
+Showing outdated packages.
+[*] indicates versions that are not the latest available.
+
+Package Name Current Upgradable Resolvable Latest
+
+direct dependencies:
+foo *1.2.3 *1.3.0 *2.0.0 3.0.0
+
+dev_dependencies:
+builder *1.2.3 *1.3.0 2.0.0 2.0.0
+
+2 upgradable dependencies are locked (in pubspec.lock) to older versions.
+To update these dependencies, use `pub upgrade`.
+
+2 dependencies are constrained to versions that are older than a resolvable version.
+To update these dependencies, edit pubspec.yaml.
+
$ pub outdated --no-color --up-to-date
Showing outdated packages.
[*] indicates versions that are not the latest available.
@@ -223,6 +241,27 @@
dev_dependencies:
builder ✗1.2.3 ✗1.3.0 ✗2.0.0 ✗3.0.0-alpha
+2 upgradable dependencies are locked (in pubspec.lock) to older versions.
+To update these dependencies, use `pub upgrade`.
+
+2 dependencies are constrained to versions that are older than a resolvable version.
+To update these dependencies, edit pubspec.yaml.
+
+$ pub outdated --no-color --mode=null-safety --transitive
+Showing dependencies that are currently not opted in to null-safety.
+[✗] indicates versions without null safety support.
+[✓] indicates versions opting in to null safety.
+
+Package Name Current Upgradable Resolvable Latest
+
+direct dependencies:
+bar ✗1.0.0 ✗1.0.0 ✗1.0.0 ✗1.0.0
+foo ✗1.2.3 ✗1.3.0 ✗2.0.0 ✗3.0.0
+local_package ✗0.0.1 ✗0.0.1 ✗0.0.1 ✗0.0.1
+
+dev_dependencies:
+builder ✗1.2.3 ✗1.3.0 ✗2.0.0 ✗3.0.0-alpha
+
transitive dependencies:
transitive ✗1.2.3 ✗1.3.0 ✗1.3.0 ✗2.0.0
transitive2 - - ✗1.0.0 ✗1.0.0
@@ -252,18 +291,10 @@
dev_dependencies:
builder ✗1.2.3 ✗1.3.0 ✗2.0.0 ✗2.0.0
-transitive dependencies:
-transitive ✗1.2.3 ✗1.3.0 ✗1.3.0 ✗2.0.0
-transitive2 - - ✗1.0.0 ✗1.0.0
-
-transitive dev_dependencies:
-dev_trans ✗1.0.0 - ✗1.0.0 ✗2.0.0
-transitive3 - - ✗1.0.0 ✗1.0.0
-
-3 upgradable dependencies are locked (in pubspec.lock) to older versions.
+2 upgradable dependencies are locked (in pubspec.lock) to older versions.
To update these dependencies, use `pub upgrade`.
-3 dependencies are constrained to versions that are older than a resolvable version.
+2 dependencies are constrained to versions that are older than a resolvable version.
To update these dependencies, edit pubspec.yaml.
$ pub outdated --json --mode=null-safety
diff --git a/test/outdated/goldens/no_dependencies.txt b/test/outdated/goldens/no_dependencies.txt
index 50d0e92..672c124 100644
--- a/test/outdated/goldens/no_dependencies.txt
+++ b/test/outdated/goldens/no_dependencies.txt
@@ -9,6 +9,12 @@
Found no outdated packages
+$ pub outdated --no-color --no-transitive
+Showing outdated packages.
+[*] indicates versions that are not the latest available.
+
+Found no outdated packages
+
$ pub outdated --no-color --up-to-date
Showing outdated packages.
[*] indicates versions that are not the latest available.
@@ -40,6 +46,13 @@
All your dependencies declare support for null-safety.
+$ pub outdated --no-color --mode=null-safety --transitive
+Showing dependencies that are currently not opted in to null-safety.
+[✗] indicates versions without null safety support.
+[✓] indicates versions opting in to null safety.
+
+All your dependencies declare support for null-safety.
+
$ pub outdated --no-color --mode=null-safety --no-prereleases
Showing dependencies that are currently not opted in to null-safety.
[✗] indicates versions without null safety support.
diff --git a/test/outdated/goldens/no_lockfile.txt b/test/outdated/goldens/no_lockfile.txt
index 24c4581..0a05606 100644
--- a/test/outdated/goldens/no_lockfile.txt
+++ b/test/outdated/goldens/no_lockfile.txt
@@ -46,6 +46,22 @@
1 dependency is constrained to a version that is older than a resolvable version.
To update it, edit pubspec.yaml.
+$ pub outdated --no-color --no-transitive
+Showing outdated packages.
+[*] indicates versions that are not the latest available.
+
+Package Name Current Upgradable Resolvable Latest
+
+direct dependencies:
+bar - *1.2.3 2.0.0 2.0.0
+foo - 1.2.3 1.2.3 1.2.3
+
+No pubspec.lock found. There are no Current versions.
+Run `pub get` to create a pubspec.lock with versions matching your pubspec.yaml.
+
+1 dependency is constrained to a version that is older than a resolvable version.
+To update it, edit pubspec.yaml.
+
$ pub outdated --no-color --up-to-date
Showing outdated packages.
[*] indicates versions that are not the latest available.
@@ -127,6 +143,23 @@
1 dependency is constrained to a version that is older than a resolvable version.
To update it, edit pubspec.yaml.
+$ pub outdated --no-color --mode=null-safety --transitive
+Showing dependencies that are currently not opted in to null-safety.
+[✗] indicates versions without null safety support.
+[✓] indicates versions opting in to null safety.
+
+Package Name Current Upgradable Resolvable Latest
+
+direct dependencies:
+bar - ✗1.2.3 ✗2.0.0 ✗2.0.0
+foo - ✗1.2.3 ✗1.2.3 ✗1.2.3
+
+No pubspec.lock found. There are no Current versions.
+Run `pub get` to create a pubspec.lock with versions matching your pubspec.yaml.
+
+1 dependency is constrained to a version that is older than a resolvable version.
+To update it, edit pubspec.yaml.
+
$ pub outdated --no-color --mode=null-safety --no-prereleases
Showing dependencies that are currently not opted in to null-safety.
[✗] indicates versions without null safety support.
diff --git a/test/outdated/goldens/null_safety.txt b/test/outdated/goldens/null_safety.txt
index cb4a969..212cc22 100644
--- a/test/outdated/goldens/null_safety.txt
+++ b/test/outdated/goldens/null_safety.txt
@@ -111,6 +111,23 @@
5 dependencies are constrained to versions that are older than a resolvable version.
To update these dependencies, edit pubspec.yaml.
+$ pub outdated --no-color --no-transitive
+Showing outdated packages.
+[*] indicates versions that are not the latest available.
+
+Package Name Current Upgradable Resolvable Latest
+
+direct dependencies:
+bar *1.0.0 *1.0.0 *1.0.0 2.0.0
+fails_analysis *1.0.0 *1.0.0 2.0.0 2.0.0
+fails_analysis_in_dependency *1.0.0 *1.0.0 2.0.0 2.0.0
+file_in_dependency_opts_out *1.0.0 *1.0.0 2.0.0 2.0.0
+file_opts_out *1.0.0 *1.0.0 2.0.0 2.0.0
+foo *1.0.0 *1.0.0 2.0.0 2.0.0
+
+5 dependencies are constrained to versions that are older than a resolvable version.
+To update these dependencies, edit pubspec.yaml.
+
$ pub outdated --no-color --up-to-date
Showing outdated packages.
[*] indicates versions that are not the latest available.
@@ -193,6 +210,20 @@
1 dependency is constrained to a version that is older than a resolvable version.
To update it, edit pubspec.yaml.
+$ pub outdated --no-color --mode=null-safety --transitive
+Showing dependencies that are currently not opted in to null-safety.
+[✗] indicates versions without null safety support.
+[✓] indicates versions opting in to null safety.
+
+Package Name Current Upgradable Resolvable Latest
+
+direct dependencies:
+bar ✗1.0.0 ✗1.0.0 ✗1.0.0 ✓2.0.0
+foo ✗1.0.0 ✗1.0.0 ✓2.0.0 ✓2.0.0
+
+1 dependency is constrained to a version that is older than a resolvable version.
+To update it, edit pubspec.yaml.
+
$ pub outdated --no-color --mode=null-safety --no-prereleases
Showing dependencies that are currently not opted in to null-safety.
[✗] indicates versions without null safety support.
diff --git a/test/outdated/goldens/prereleases.txt b/test/outdated/goldens/prereleases.txt
index 9f8faf5..1dddd78 100644
--- a/test/outdated/goldens/prereleases.txt
+++ b/test/outdated/goldens/prereleases.txt
@@ -47,6 +47,19 @@
2 dependencies are constrained to versions that are older than a resolvable version.
To update these dependencies, edit pubspec.yaml.
+$ pub outdated --no-color --no-transitive
+Showing outdated packages.
+[*] indicates versions that are not the latest available.
+
+Package Name Current Upgradable Resolvable Latest
+
+direct dependencies:
+foo *1.0.0-dev.1 *1.0.0-dev.1 1.0.0-dev.2 1.0.0-dev.2
+mop *0.10.0-dev *0.10.0-dev 0.10.0 0.10.0
+
+2 dependencies are constrained to versions that are older than a resolvable version.
+To update these dependencies, edit pubspec.yaml.
+
$ pub outdated --no-color --up-to-date
Showing outdated packages.
[*] indicates versions that are not the latest available.
@@ -116,6 +129,21 @@
2 dependencies are constrained to versions that are older than a resolvable version.
To update these dependencies, edit pubspec.yaml.
+$ pub outdated --no-color --mode=null-safety --transitive
+Showing dependencies that are currently not opted in to null-safety.
+[✗] indicates versions without null safety support.
+[✓] indicates versions opting in to null safety.
+
+Package Name Current Upgradable Resolvable Latest
+
+direct dependencies:
+bar ✗0.9.0 ✗0.9.0 ✗0.9.0 ✗1.0.0-dev.2
+foo ✗1.0.0-dev.1 ✗1.0.0-dev.1 ✗1.0.0-dev.2 ✗1.0.0-dev.2
+mop ✗0.10.0-dev ✗0.10.0-dev ✗0.10.0 ✗1.0.0-dev
+
+2 dependencies are constrained to versions that are older than a resolvable version.
+To update these dependencies, edit pubspec.yaml.
+
$ pub outdated --no-color --mode=null-safety --no-prereleases
Showing dependencies that are currently not opted in to null-safety.
[✗] indicates versions without null safety support.
diff --git a/test/outdated/outdated_test.dart b/test/outdated/outdated_test.dart
index 64a2f99..f9e6c93 100644
--- a/test/outdated/outdated_test.dart
+++ b/test/outdated/outdated_test.dart
@@ -36,11 +36,13 @@
for (final args in [
['--json'],
['--no-color'],
+ ['--no-color', '--no-transitive'],
['--no-color', '--up-to-date'],
['--no-color', '--prereleases'],
['--no-color', '--no-dev-dependencies'],
['--no-color', '--no-dependency-overrides'],
['--no-color', '--mode=null-safety'],
+ ['--no-color', '--mode=null-safety', '--transitive'],
['--no-color', '--mode=null-safety', '--no-prereleases'],
['--json', '--mode=null-safety'],
['--json', '--no-dev-dependencies'],