@@ -7,8 +7,7 @@ import 'dart:convert';
7
7
import 'dart:io' ;
8
8
import 'dart:math' ;
9
9
10
- import 'package:collection/collection.dart'
11
- show IterableExtension, IterableNullableExtension;
10
+ import 'package:collection/collection.dart' show IterableExtension;
12
11
import 'package:path/path.dart' as path;
13
12
14
13
import '../command.dart' ;
@@ -69,12 +68,12 @@ class OutdatedCommand extends PubCommand {
69
68
valueHelp: 'PROPERTY' ,
70
69
allowed: ['outdated' , 'null-safety' ],
71
70
defaultsTo: 'outdated' ,
71
+ hide: true ,
72
72
);
73
73
74
74
argParser.addFlag (
75
75
'prereleases' ,
76
- help: 'Include prereleases in latest version.\n '
77
- '(defaults to on in --mode=null-safety).' ,
76
+ help: 'Include prereleases in latest version.' ,
78
77
);
79
78
80
79
// Preserve for backwards compatibility.
@@ -98,20 +97,19 @@ class OutdatedCommand extends PubCommand {
98
97
);
99
98
argParser.addFlag (
100
99
'transitive' ,
101
- help: 'Show transitive dependencies.\n '
102
- '(defaults to off in --mode=null-safety).' ,
100
+ help: 'Show transitive dependencies.' ,
103
101
);
104
102
argParser.addOption ('directory' ,
105
103
abbr: 'C' , help: 'Run this in the directory<dir>.' , valueHelp: 'dir' );
106
104
}
107
105
108
106
@override
109
107
Future <void > runProtected () async {
110
- final mode = < String , _Mode > {
111
- 'outdated' : _OutdatedMode (),
112
- ' null- safety' : _NullSafetyMode (cache, entrypoint,
113
- shouldShowSpinner : _shouldShowSpinner),
114
- }[argResults[ ' mode' ]] ! ;
108
+ if (argResults[ ' mode' ] == 'null-safety' ) {
109
+ dataError ( '''The `--mode=null-safety` option is no longer supported.
110
+ Consider using the Dart 2.19 sdk to migrate to null safety.''' );
111
+ }
112
+ final mode = _OutdatedMode () ;
115
113
116
114
final includeDevDependencies = argResults['dev-dependencies' ];
117
115
final includeDependencyOverrides = argResults['dependency-overrides' ];
@@ -288,11 +286,7 @@ class OutdatedCommand extends PubCommand {
288
286
}
289
287
290
288
bool get showTransitiveDependencies {
291
- if (argResults.wasParsed ('transitive' )) {
292
- return argResults['transitive' ];
293
- }
294
- // We default to hidding transitive dependencies in --mode=null-safety
295
- return argResults['mode' ] != 'null-safety' ;
289
+ return argResults['transitive' ];
296
290
}
297
291
298
292
late final bool prereleases = () {
@@ -306,7 +300,7 @@ class OutdatedCommand extends PubCommand {
306
300
if (argResults.wasParsed ('pre-releases' )) {
307
301
return argResults['pre-releases' ];
308
302
}
309
- return argResults[ 'mode' ] == 'null-safety' ;
303
+ return false ;
310
304
}();
311
305
312
306
/// Retrieves the pubspec of package [name] in [version] from [source] .
@@ -691,115 +685,6 @@ Showing outdated packages$directoryDescription.
691
685
}
692
686
}
693
687
694
- class _NullSafetyMode implements _Mode {
695
- final SystemCache cache;
696
- final Entrypoint entrypoint;
697
- final bool shouldShowSpinner;
698
-
699
- final _compliantEmoji = emoji ('✓' , '+' );
700
- final _notCompliantEmoji = emoji ('✗' , 'x' );
701
-
702
- _NullSafetyMode (this .cache, this .entrypoint,
703
- {required this .shouldShowSpinner});
704
-
705
- @override
706
- String explanation (String directoryDescription) => '''
707
- Showing dependencies$directoryDescription that are currently not opted in to null-safety.
708
- [${log .red (_notCompliantEmoji )}] indicates versions without null safety support.
709
- [${log .green (_compliantEmoji )}] indicates versions opting in to null safety.
710
- ''' ;
711
-
712
- @override
713
- String get foundNoBadText =>
714
- 'All your dependencies declare support for null-safety.' ;
715
-
716
- @override
717
- String get allGood => 'all support null safety.' ;
718
-
719
- @override
720
- String get noResolutionText =>
721
- '''No resolution was found. Try running `$topLevelProgram pub upgrade --null-safety --dry-run` to explore why.''' ;
722
-
723
- @override
724
- String get upgradeConstrained =>
725
- 'edit pubspec.yaml, or run `$topLevelProgram pub upgrade --null-safety`' ;
726
-
727
- @override
728
- String get allSafe => 'All dependencies opt in to null-safety.' ;
729
-
730
- @override
731
- Future <List <List <_MarkedVersionDetails >>> markVersionDetails (
732
- List <_PackageDetails > packages) async {
733
- final nullSafetyMap =
734
- await log.spinner ('Computing null safety support' , () async {
735
- /// Find all unique ids.
736
- final ids = {
737
- for (final packageDetails in packages) ...[
738
- packageDetails.current? ._id,
739
- packageDetails.upgradable? ._id,
740
- packageDetails.resolvable? ._id,
741
- packageDetails.latest? ._id,
742
- ]
743
- }.whereNotNull ();
744
-
745
- return Map .fromEntries (
746
- await Future .wait (
747
- ids.map (
748
- (id) async => MapEntry (id,
749
- (await cache.describe (id)).languageVersion.supportsNullSafety),
750
- ),
751
- ),
752
- );
753
- }, condition: shouldShowSpinner);
754
- return [
755
- for (final packageDetails in packages)
756
- [
757
- packageDetails.current,
758
- packageDetails.upgradable,
759
- packageDetails.resolvable,
760
- packageDetails.latest
761
- ].map (
762
- (versionDetails) {
763
- String Function (String )? color;
764
- String ? prefix;
765
- String ? suffix;
766
- MapEntry <String , Object >? jsonExplanation;
767
- var asDesired = false ;
768
- if (versionDetails != null ) {
769
- if (packageDetails.isDiscontinued &&
770
- identical (versionDetails, packageDetails.latest)) {
771
- suffix = ' (discontinued)' ;
772
- }
773
- if (nullSafetyMap[versionDetails._id]! ) {
774
- color = log.green;
775
- prefix = _compliantEmoji;
776
- jsonExplanation = MapEntry ('nullSafety' , true );
777
- asDesired = true ;
778
- } else {
779
- color = log.red;
780
- prefix = _notCompliantEmoji;
781
- jsonExplanation = MapEntry ('nullSafety' , false );
782
- }
783
- }
784
- return _MarkedVersionDetails (
785
- versionDetails,
786
- asDesired: asDesired,
787
- format: color,
788
- prefix: prefix,
789
- suffix: suffix,
790
- jsonExplanation: jsonExplanation,
791
- );
792
- },
793
- ).toList ()
794
- ];
795
- }
796
-
797
- @override
798
- Future <Pubspec > resolvablePubspec (Pubspec pubspec) async {
799
- return constrainedToAtLeastNullSafetyPubspec (pubspec, cache);
800
- }
801
- }
802
-
803
688
/// Details about a single version of a package.
804
689
class _VersionDetails {
805
690
final Pubspec _pubspec;
0 commit comments