Skip to content

Commit

Permalink
pub outdated: added clear message when no outdated packages. (#2898)
Browse files Browse the repository at this point in the history
  • Loading branch information
tusharojha authored Mar 12, 2021
1 parent 2246387 commit 79f3a8b
Show file tree
Hide file tree
Showing 3 changed files with 174 additions and 1 deletion.
14 changes: 13 additions & 1 deletion lib/src/command/outdated.dart
Original file line number Diff line number Diff line change
Expand Up @@ -573,10 +573,15 @@ Future<void> _outputHuman(
}
}

if (notAtResolvable == 0 && upgradable == 0 && rows.isNotEmpty) {
if (notAtResolvable == 0 &&
upgradable == 0 &&
rows.isNotEmpty &&
(directRows.isNotEmpty || devRows.isNotEmpty)) {
log.message(
"You are already using the newest resolvable versions listed in the 'Resolvable' column.\n"
"Newer versions, listed in 'Latest', may not be mutually compatible.");
} else if (directRows.isEmpty && devRows.isEmpty) {
log.message(mode.allSafe);
}
} else {
log.message('\nNo pubspec.lock found. There are no Current versions.\n'
Expand Down Expand Up @@ -608,6 +613,7 @@ abstract class Mode {
String get allGood;
String get noResolutionText;
String get upgradeConstrained;
String get allSafe;

Future<Pubspec> resolvablePubspec(Pubspec pubspec);
}
Expand All @@ -633,6 +639,9 @@ Showing outdated packages$directoryDescription.
String get upgradeConstrained =>
'edit pubspec.yaml, or run `$topLevelProgram pub upgrade --major-versions`';

@override
String get allSafe => 'all dependencies are up-to-date.';

@override
Future<List<List<_MarkedVersionDetails>>> markVersionDetails(
List<_PackageDetails> packages) async {
Expand Down Expand Up @@ -713,6 +722,9 @@ Showing dependencies$directoryDescription that are currently not opted in to nul
String get upgradeConstrained =>
'edit pubspec.yaml, or run `$topLevelProgram pub upgrade --null-safety`';

@override
String get allSafe => 'All dependencies opt in to null-safety.';

@override
Future<List<List<_MarkedVersionDetails>>> markVersionDetails(
List<_PackageDetails> packages) async {
Expand Down
121 changes: 121 additions & 0 deletions test/outdated/goldens/null_safety_already_migrated.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
$ pub outdated --json
{
"packages": []
}

$ pub outdated --no-color
Showing outdated packages.
[*] indicates versions that are not the latest available.

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.

Package Name Current Upgradable Resolvable Latest

direct dependencies:
foo 2.0.0 2.0.0 2.0.0 2.0.0

dev_dependencies:
bar 2.0.0 2.0.0 2.0.0 2.0.0

transitive dev_dependencies:
devTransitive 1.0.0 1.0.0 1.0.0 1.0.0
You are already using the newest resolvable versions listed in the 'Resolvable' column.
Newer versions, listed in 'Latest', may not be mutually compatible.

$ pub outdated --no-color --prereleases
Showing outdated packages.
[*] indicates versions that are not the latest available.

Found no outdated packages

$ pub outdated --no-color --no-dev-dependencies
Showing outdated packages.
[*] indicates versions that are not the latest available.

Found no outdated packages

$ pub outdated --no-color --no-dependency-overrides
Showing outdated packages.
[*] indicates versions that are not the latest available.

Found no outdated packages

$ pub outdated --no-color --mode=null-safety
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: all support null safety.

dev_dependencies: all support null safety.
All dependencies opt in to 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.

Package Name Current Upgradable Resolvable Latest

direct dependencies: all support null safety.

dev_dependencies: all support null safety.

transitive dev_dependencies:
devTransitive ✗1.0.0 ✗1.0.0 ✗1.0.0 ✗1.0.0
All dependencies opt in to 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.
[✓] indicates versions opting in to null safety.

Package Name Current Upgradable Resolvable Latest

direct dependencies: all support null safety.

dev_dependencies: all support null safety.
All dependencies opt in to null-safety.

$ pub outdated --json --mode=null-safety
{
"packages": [
{
"package": "devTransitive",
"current": {
"version": "1.0.0",
"nullSafety": false
},
"upgradable": {
"version": "1.0.0",
"nullSafety": false
},
"resolvable": {
"version": "1.0.0",
"nullSafety": false
},
"latest": {
"version": "1.0.0",
"nullSafety": false
}
}
]
}

$ pub outdated --json --no-dev-dependencies
{
"packages": []
}

40 changes: 40 additions & 0 deletions test/outdated/outdated_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,46 @@ Future<void> main() async {
environment: {'_PUB_TEST_SDK_VERSION': '2.13.0'});
});

test('null-safety already migrated', () async {
await servePackages((builder) => builder
..serve('foo', '1.0.0', pubspec: {
'environment': {'sdk': '>=2.9.0 < 3.0.0'}
})
..serve('foo', '2.0.0', pubspec: {
'environment': {'sdk': '>=2.12.0 < 3.0.0'}
})
..serve('bar', '1.0.0', pubspec: {
'environment': {'sdk': '>=2.9.0 < 3.0.0'}
})
..serve('bar', '2.0.0', deps: {
'devTransitive': '^1.0.0'
}, pubspec: {
'environment': {'sdk': '>=2.12.0 < 3.0.0'}
})
..serve('devTransitive', '1.0.0', pubspec: {
'environment': {'sdk': '>=2.9.0 < 3.0.0'}
}));

await d.dir(appPath, [
d.pubspec({
'name': 'app',
'version': '1.0.0',
'dependencies': {
'foo': '^2.0.0',
},
'dev_dependencies': {
'bar': '^2.0.0',
},
'environment': {'sdk': '>=2.12.0 < 3.0.0'},
}),
]).create();

await pubGet(environment: {'_PUB_TEST_SDK_VERSION': '2.13.0'});

await variations('null_safety_already_migrated',
environment: {'_PUB_TEST_SDK_VERSION': '2.13.0'});
});

test('overridden dependencies', () async {
ensureGit();
await servePackages(
Expand Down

0 comments on commit 79f3a8b

Please sign in to comment.