Remove features for migrating to null safety (#3713)
diff --git a/lib/src/command/outdated.dart b/lib/src/command/outdated.dart
index 5bad745..0ae3ab3 100644
--- a/lib/src/command/outdated.dart
+++ b/lib/src/command/outdated.dart
@@ -7,8 +7,7 @@
import 'dart:io';
import 'dart:math';
-import 'package:collection/collection.dart'
- show IterableExtension, IterableNullableExtension;
+import 'package:collection/collection.dart' show IterableExtension;
import 'package:path/path.dart' as path;
import '../command.dart';
@@ -69,12 +68,12 @@
valueHelp: 'PROPERTY',
allowed: ['outdated', 'null-safety'],
defaultsTo: 'outdated',
+ hide: true,
);
argParser.addFlag(
'prereleases',
- help: 'Include prereleases in latest version.\n'
- '(defaults to on in --mode=null-safety).',
+ help: 'Include prereleases in latest version.',
);
// Preserve for backwards compatibility.
@@ -98,8 +97,7 @@
);
argParser.addFlag(
'transitive',
- help: 'Show transitive dependencies.\n'
- '(defaults to off in --mode=null-safety).',
+ help: 'Show transitive dependencies.',
);
argParser.addOption('directory',
abbr: 'C', help: 'Run this in the directory<dir>.', valueHelp: 'dir');
@@ -107,11 +105,11 @@
@override
Future<void> runProtected() async {
- final mode = <String, _Mode>{
- 'outdated': _OutdatedMode(),
- 'null-safety': _NullSafetyMode(cache, entrypoint,
- shouldShowSpinner: _shouldShowSpinner),
- }[argResults['mode']]!;
+ if (argResults['mode'] == 'null-safety') {
+ dataError('''The `--mode=null-safety` option is no longer supported.
+Consider using the Dart 2.19 sdk to migrate to null safety.''');
+ }
+ final mode = _OutdatedMode();
final includeDevDependencies = argResults['dev-dependencies'];
final includeDependencyOverrides = argResults['dependency-overrides'];
@@ -288,11 +286,7 @@
}
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';
+ return argResults['transitive'];
}
late final bool prereleases = () {
@@ -306,7 +300,7 @@
if (argResults.wasParsed('pre-releases')) {
return argResults['pre-releases'];
}
- return argResults['mode'] == 'null-safety';
+ return false;
}();
/// Retrieves the pubspec of package [name] in [version] from [source].
@@ -691,115 +685,6 @@
}
}
-class _NullSafetyMode implements _Mode {
- final SystemCache cache;
- final Entrypoint entrypoint;
- final bool shouldShowSpinner;
-
- final _compliantEmoji = emoji('✓', '+');
- final _notCompliantEmoji = emoji('✗', 'x');
-
- _NullSafetyMode(this.cache, this.entrypoint,
- {required this.shouldShowSpinner});
-
- @override
- String explanation(String directoryDescription) => '''
-Showing dependencies$directoryDescription that are currently not opted in to null-safety.
-[${log.red(_notCompliantEmoji)}] indicates versions without null safety support.
-[${log.green(_compliantEmoji)}] indicates versions opting in to null safety.
-''';
-
- @override
- String get foundNoBadText =>
- 'All your dependencies declare support for null-safety.';
-
- @override
- String get allGood => 'all support null safety.';
-
- @override
- String get noResolutionText =>
- '''No resolution was found. Try running `$topLevelProgram pub upgrade --null-safety --dry-run` to explore why.''';
-
- @override
- 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 {
- final nullSafetyMap =
- await log.spinner('Computing null safety support', () async {
- /// Find all unique ids.
- final ids = {
- for (final packageDetails in packages) ...[
- packageDetails.current?._id,
- packageDetails.upgradable?._id,
- packageDetails.resolvable?._id,
- packageDetails.latest?._id,
- ]
- }.whereNotNull();
-
- return Map.fromEntries(
- await Future.wait(
- ids.map(
- (id) async => MapEntry(id,
- (await cache.describe(id)).languageVersion.supportsNullSafety),
- ),
- ),
- );
- }, condition: shouldShowSpinner);
- return [
- for (final packageDetails in packages)
- [
- packageDetails.current,
- packageDetails.upgradable,
- packageDetails.resolvable,
- packageDetails.latest
- ].map(
- (versionDetails) {
- String Function(String)? color;
- String? prefix;
- String? suffix;
- MapEntry<String, Object>? jsonExplanation;
- var asDesired = false;
- if (versionDetails != null) {
- if (packageDetails.isDiscontinued &&
- identical(versionDetails, packageDetails.latest)) {
- suffix = ' (discontinued)';
- }
- if (nullSafetyMap[versionDetails._id]!) {
- color = log.green;
- prefix = _compliantEmoji;
- jsonExplanation = MapEntry('nullSafety', true);
- asDesired = true;
- } else {
- color = log.red;
- prefix = _notCompliantEmoji;
- jsonExplanation = MapEntry('nullSafety', false);
- }
- }
- return _MarkedVersionDetails(
- versionDetails,
- asDesired: asDesired,
- format: color,
- prefix: prefix,
- suffix: suffix,
- jsonExplanation: jsonExplanation,
- );
- },
- ).toList()
- ];
- }
-
- @override
- Future<Pubspec> resolvablePubspec(Pubspec pubspec) async {
- return constrainedToAtLeastNullSafetyPubspec(pubspec, cache);
- }
-}
-
/// Details about a single version of a package.
class _VersionDetails {
final Pubspec _pubspec;
diff --git a/lib/src/command/upgrade.dart b/lib/src/command/upgrade.dart
index 1a80900..defa20b 100644
--- a/lib/src/command/upgrade.dart
+++ b/lib/src/command/upgrade.dart
@@ -11,16 +11,15 @@
import '../command.dart';
import '../command_runner.dart';
import '../entrypoint.dart';
-import '../exceptions.dart';
import '../io.dart';
import '../log.dart' as log;
-import '../null_safety_analysis.dart';
import '../package.dart';
import '../package_name.dart';
import '../pubspec.dart';
import '../pubspec_utils.dart';
import '../solver.dart';
import '../source/hosted.dart';
+import '../utils.dart';
/// Handles the `upgrade` pub command.
class UpgradeCommand extends PubCommand {
@@ -50,6 +49,7 @@
help: 'Precompile executables in immediate dependencies.');
argParser.addFlag('null-safety',
+ hide: true,
negatable: false,
help: 'Upgrade constraints in pubspec.yaml to null-safety versions');
argParser.addFlag('nullsafety', negatable: false, hide: true);
@@ -87,22 +87,16 @@
@override
Future<void> runProtected() async {
+ if (_upgradeNullSafety) {
+ dataError('''The `--null-safety` flag is no longer supported.
+Consider using the Dart 2.19 sdk to migrate to null safety.''');
+ }
if (argResults.wasParsed('packages-dir')) {
log.warning(log.yellow(
'The --packages-dir flag is no longer used and does nothing.'));
}
- if (_upgradeNullSafety && _upgradeMajorVersions) {
- usageException('--major-versions and --null-safety cannot be combined');
- }
-
- if (_upgradeNullSafety) {
- if (argResults['example'] && entrypoint.example != null) {
- log.warning(
- 'Running `upgrade --null-safety` only in `${entrypoint.root.dir}`. Run `$topLevelProgram pub upgrade --null-safety --directory example/` separately.');
- }
- await _runUpgradeNullSafety();
- } else if (_upgradeMajorVersions) {
+ if (_upgradeMajorVersions) {
if (argResults['example'] && entrypoint.example != null) {
log.warning(
'Running `upgrade --major-versions` only in `${entrypoint.root.dir}`. Run `$topLevelProgram pub upgrade --major-versions --directory example/` separately.');
@@ -136,7 +130,7 @@
///
/// This assumes that either `--major-versions` or `--null-safety` was passed.
List<String> _directDependenciesToUpgrade() {
- assert(_upgradeNullSafety || _upgradeMajorVersions);
+ assert(_upgradeMajorVersions);
final directDeps = [
...entrypoint.root.pubspec.dependencies.keys,
@@ -148,9 +142,6 @@
final notInDeps = toUpgrade.where((n) => !directDeps.contains(n));
if (toUpgrade.any(notInDeps.contains)) {
var modeFlag = '';
- if (_upgradeNullSafety) {
- modeFlag = '--null-safety';
- }
if (_upgradeMajorVersions) {
modeFlag = '--major-versions';
}
@@ -276,124 +267,6 @@
_showOfflineWarning();
}
- Future<void> _runUpgradeNullSafety() async {
- final toUpgrade = _directDependenciesToUpgrade();
-
- final nullsafetyPubspec = await _upgradeToNullSafetyConstraints(
- entrypoint.root.pubspec,
- toUpgrade,
- );
-
- /// Solve [nullsafetyPubspec] in-memory and consolidate the resolved
- /// versions of the packages into a map for quick searching.
- final resolvedPackages = <String, PackageId>{};
- final solveResult = await log.spinner('Resolving dependencies', () async {
- return await resolveVersions(
- SolveType.upgrade,
- cache,
- Package.inMemory(nullsafetyPubspec),
- );
- }, condition: _shouldShowSpinner);
- for (final resolvedPackage in solveResult.packages) {
- resolvedPackages[resolvedPackage.name] = resolvedPackage;
- }
-
- /// Changes to be made to `pubspec.yaml`.
- /// Mapping from original to changed value.
- final changes = <PackageRange, PackageRange>{};
- final declaredHostedDependencies = [
- ...entrypoint.root.pubspec.dependencies.values,
- ...entrypoint.root.pubspec.devDependencies.values,
- ].where((dep) => dep.source is HostedSource);
- for (final dep in declaredHostedDependencies) {
- final resolvedPackage = resolvedPackages[dep.name]!;
- if (!toUpgrade.contains(dep.name)) {
- // If we're not to upgrade this package, or it wasn't in the
- // resolution somehow, then we ignore it.
- continue;
- }
-
- final constraint = VersionConstraint.compatibleWith(
- resolvedPackage.version,
- );
- if (dep.constraint.allowsAll(constraint) &&
- constraint.allowsAll(dep.constraint)) {
- // If constraint allows the same as the existing constraint then
- // there is no need to make changes.
- continue;
- }
-
- changes[dep] = dep.toRef().withConstraint(constraint);
- }
-
- final newPubspecText = _updatePubspec(changes);
- if (_dryRun) {
- // Even if it is a dry run, run `acquireDependencies` so that the user
- // gets a report on changes.
- // TODO(jonasfj): Stop abusing Entrypoint.global for dry-run output
- await Entrypoint.inMemory(
- Package.inMemory(Pubspec.parse(newPubspecText, cache.sources)),
- cache,
- lockFile: entrypoint.lockFile,
- solveResult: solveResult,
- ).acquireDependencies(
- SolveType.upgrade,
- dryRun: true,
- precompile: _precompile,
- analytics: null,
- );
- } else {
- if (changes.isNotEmpty) {
- writeTextFile(entrypoint.pubspecPath, newPubspecText);
- }
- // TODO: Allow Entrypoint to be created with in-memory pubspec, so that
- // we can show the changes in --dry-run mode. For now we only show
- // the changes made to pubspec.yaml in dry-run mode.
- await Entrypoint(directory, cache).acquireDependencies(
- SolveType.upgrade,
- precompile: _precompile,
- analytics: analytics,
- );
- }
-
- _outputChangeSummary(changes);
-
- // Warn if not all dependencies were migrated to a null-safety compatible
- // version. This can happen because:
- // - `upgradeOnly` was given,
- // - root has SDK dependencies,
- // - root has git or path dependencies,
- // - root has dependency_overrides
- final nonMigratedDirectDeps = <String>[];
- final directDeps = [
- ...entrypoint.root.pubspec.dependencies.keys,
- ...entrypoint.root.pubspec.devDependencies.keys
- ];
- await Future.wait(directDeps.map((name) async {
- final resolvedPackage = resolvedPackages[name]!;
-
- final pubspec = await cache.describe(resolvedPackage);
- if (!pubspec.languageVersion.supportsNullSafety) {
- nonMigratedDirectDeps.add(name);
- }
- }));
- if (nonMigratedDirectDeps.isNotEmpty) {
- log.warning('''
-\nFollowing direct 'dependencies' and 'dev_dependencies' are not migrated to
-null-safety yet:
- - ${nonMigratedDirectDeps.join('\n - ')}
-
-You may have to:
- * Upgrade git and path dependencies manually,
- * Upgrade to a newer SDK for newer SDK dependencies,
- * Remove dependency_overrides, and/or,
- * Find other packages to use.
-''');
- }
-
- _showOfflineWarning();
- }
-
/// Updates `pubspec.yaml` with given [changes].
String _updatePubspec(
Map<PackageRange, PackageRange> changes,
@@ -448,80 +321,4 @@
'latest versions of your dependencies.');
}
}
-
- /// Returns new pubspec with the same dependencies as [original], but with:
- /// * the lower-bound of hosted package constraint set to first null-safety
- /// compatible version, and,
- /// * the upper-bound of hosted package constraints removed.
- ///
- /// Only changes listed in [upgradeOnly] will have their constraints touched.
- ///
- /// Throws [ApplicationException] if one of the dependencies does not have
- /// a null-safety compatible version.
- Future<Pubspec> _upgradeToNullSafetyConstraints(
- Pubspec original,
- List<String> upgradeOnly,
- ) async {
- ArgumentError.checkNotNull(original, 'original');
- ArgumentError.checkNotNull(upgradeOnly, 'upgradeOnly');
-
- final hasNoNullSafetyVersions = <String>{};
- final hasNullSafetyVersions = <String>{};
-
- Future<Iterable<PackageRange>> removeUpperConstraints(
- Iterable<PackageRange> dependencies,
- ) async =>
- await Future.wait(dependencies.map((dep) async {
- if (dep.source is! HostedSource) {
- return dep;
- }
- if (!upgradeOnly.contains(dep.name)) {
- return dep;
- }
-
- final packages = await cache.getVersions(dep.toRef());
- packages.sort((a, b) => a.version.compareTo(b.version));
-
- for (final package in packages) {
- final pubspec = await cache.describe(package);
- if (pubspec.languageVersion.supportsNullSafety) {
- hasNullSafetyVersions.add(dep.name);
- return dep.toRef().withConstraint(
- VersionRange(min: package.version, includeMin: true),
- );
- }
- }
-
- hasNoNullSafetyVersions.add(dep.name);
- // This value is never used. We will throw an exception because
- //`hasNonNullSafetyVersions` is not empty.
- return dep.toRef().withConstraint(VersionConstraint.empty);
- }));
-
- final deps = removeUpperConstraints(original.dependencies.values);
- final devDeps = removeUpperConstraints(original.devDependencies.values);
- await Future.wait([deps, devDeps]);
-
- if (hasNoNullSafetyVersions.isNotEmpty) {
- throw ApplicationException('''
-null-safety compatible versions do not exist for:
- - ${hasNoNullSafetyVersions.join('\n - ')}
-
-You can choose to upgrade only some dependencies to null-safety using:
- $topLevelProgram pub upgrade --nullsafety ${hasNullSafetyVersions.join(' ')}
-
-Warning: Using null-safety features before upgrading all dependencies is
-discouraged. For more details see: ${NullSafetyAnalysis.guideUrl}
-''');
- }
-
- return Pubspec(
- original.name,
- version: original.version,
- sdkConstraints: original.sdkConstraints,
- dependencies: await deps,
- devDependencies: await devDeps,
- dependencyOverrides: original.dependencyOverrides.values,
- );
- }
}
diff --git a/lib/src/null_safety_analysis.dart b/lib/src/null_safety_analysis.dart
deleted file mode 100644
index 284e845..0000000
--- a/lib/src/null_safety_analysis.dart
+++ /dev/null
@@ -1,262 +0,0 @@
-// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-import 'dart:async';
-
-import 'package:analyzer/dart/analysis/analysis_context_collection.dart';
-import 'package:analyzer/dart/analysis/results.dart';
-import 'package:analyzer/file_system/physical_file_system.dart';
-import 'package:cli_util/cli_util.dart';
-import 'package:path/path.dart' as path;
-import 'package:source_span/source_span.dart';
-import 'package:yaml/yaml.dart';
-
-import 'io.dart';
-import 'language_version.dart';
-import 'package.dart';
-import 'package_name.dart';
-import 'pubspec.dart';
-import 'solver.dart';
-import 'source.dart';
-import 'source/cached.dart';
-import 'system_cache.dart';
-
-enum NullSafetyCompliance {
- /// This package and all dependencies opted into null safety.
- compliant,
-
- /// This package opted into null safety, but some file or dependency is not
- /// opted in.
- mixed,
-
- /// This package did not opt-in to null safety yet.
- notCompliant,
-
- /// The resolution failed. Or some dart file in a dependency
- /// doesn't parse.
- analysisFailed,
-}
-
-class NullSafetyAnalysis {
- static const String guideUrl = 'https://dart.dev/null-safety/migration-guide';
- final SystemCache _systemCache;
-
- /// A cache of the analysis done for a single package-version, not taking
- /// dependencies into account. (Only the sdk constraint and no-files-opt-out).
- ///
- /// This allows us to reuse the analysis of the same package-version when
- /// used as a dependency from different packages.
- ///
- /// Furthermore by awaiting the Future stored here, we avoid race-conditions
- /// from downloading the same package-version into [_systemCache]
- /// simultaneously when doing concurrent analyses.
- final Map<PackageId, Future<NullSafetyAnalysisResult>>
- _packageInternallyGoodCache = {};
-
- NullSafetyAnalysis(SystemCache systemCache) : _systemCache = systemCache;
-
- /// Decides if package version [packageId] and all its non-dev
- /// dependencies (transitively) have a language version opting in to
- /// null-safety and no files in lib/ of these packages opt out to a
- /// pre-null-safety language version.
- ///
- /// This will do a full resolution of that package's import graph, and also
- /// download the package and all dependencies into [cache].
- ///
- /// To avoid race conditions on downloading to the cache, only one instance
- /// should be computing nullSafetyCompliance simultaneously with the same
- /// cache.
- ///
- /// If [packageId] is a relative path dependency [containingPath] must be
- /// provided with an absolute path to resolve it against.
- Future<NullSafetyAnalysisResult> nullSafetyCompliance(
- PackageId packageId,
- ) async {
- final description = packageId.description.description;
- final rootPubspec = await _systemCache.describe(packageId);
-
- // A space in the name prevents clashes with other package names.
- final fakeRootName = '${packageId.name} importer';
- final fakeRoot = Package.inMemory(Pubspec(fakeRootName,
- fields: {
- 'dependencies': {
- packageId.name: {
- packageId.source.name: description.serializeForPubspec(
- containingDir: null,
- languageVersion:
- LanguageVersion.firstVersionWithShorterHostedSyntax),
- 'version': packageId.version.toString(),
- }
- }
- },
- sources: _systemCache.sources,
- sdkConstraints: {'dart': rootPubspec.dartSdkConstraint}));
-
- final rootLanguageVersion = rootPubspec.languageVersion;
- if (!rootLanguageVersion.supportsNullSafety) {
- final span =
- _tryGetSpanFromYamlMap(rootPubspec.fields['environment'], 'sdk');
- final where = span == null
- ? 'in the sdk constraint in the enviroment key in pubspec.yaml.'
- : 'in pubspec.yaml: \n${span.highlight()}';
- return NullSafetyAnalysisResult(
- NullSafetyCompliance.notCompliant,
- 'Is not opting in to null safety $where',
- );
- }
-
- SolveResult result;
- try {
- result = await resolveVersions(
- SolveType.get,
- _systemCache,
- fakeRoot,
- );
- } on SolveFailure catch (e) {
- return NullSafetyAnalysisResult(NullSafetyCompliance.analysisFailed,
- 'Could not resolve constraints: $e');
- }
- return nullSafetyComplianceOfPackages(
- result.packages.where((id) => id.name != fakeRootName),
- Package(
- rootPubspec,
- _systemCache.getDirectory(packageId),
- ),
- );
- }
-
- /// Decides if all dependendencies (transitively) have a language version
- /// opting in to null safety, and no files in lib/ of these packages, nor the
- /// root package opt out to a pre-null-safety language version.
- ///
- /// [rootPubspec] is the pubspec of the root package.
- // TODO(sigurdm): make a source for the root package. Then we should not need
- // to pass this.
- ///
- /// This will download all dependencies into [cache].
- ///
- /// Assumes the root package is opted in.
- Future<NullSafetyAnalysisResult> nullSafetyComplianceOfPackages(
- Iterable<PackageId> packages,
- Package rootPackage,
- ) async {
- NullSafetyAnalysisResult? firstBadPackage;
- for (final dependencyId in packages) {
- final packageInternalAnalysis =
- await _packageInternallyGoodCache.putIfAbsent(dependencyId, () async {
- Pubspec pubspec;
- Source? source;
- String packageDir;
- if (dependencyId.isRoot) {
- pubspec = rootPackage.pubspec;
- packageDir = rootPackage.dir;
- } else {
- source = dependencyId.source;
- pubspec = await _systemCache.describe(dependencyId);
- packageDir = _systemCache.getDirectory(dependencyId);
- }
-
- if (!pubspec.languageVersion.supportsNullSafety) {
- final span =
- _tryGetSpanFromYamlMap(pubspec.fields['environment'], 'sdk');
- final where = span == null
- ? 'in the sdk constraint in the environment key in its pubspec.yaml.'
- : 'in its pubspec.yaml:\n${span.highlight()}';
- return NullSafetyAnalysisResult(
- NullSafetyCompliance.notCompliant,
- 'package:${dependencyId.name} is not opted into null safety $where',
- );
- }
-
- if (source is CachedSource) {
- // TODO(sigurdm): Consider using withDependencyType here.
- await source.downloadToSystemCache(dependencyId, _systemCache);
- }
-
- final libDir =
- path.absolute(path.normalize(path.join(packageDir, 'lib')));
- if (dirExists(libDir)) {
- var contextCollection = AnalysisContextCollection(
- includedPaths: [path.normalize(packageDir)],
- resourceProvider: PhysicalResourceProvider.INSTANCE,
- sdkPath: getSdkPath(),
- );
- var analysisContext = contextCollection.contexts.first;
- var analysisSession = analysisContext.currentSession;
-
- for (final file in listDir(libDir,
- recursive: true, includeDirs: false, includeHidden: true)) {
- if (file.endsWith('.dart')) {
- final fileUrl =
- 'package:${dependencyId.name}/${path.relative(file, from: libDir)}';
- final someUnitResult =
- analysisSession.getParsedUnit(path.normalize(file));
- ParsedUnitResult unitResult;
- if (someUnitResult is ParsedUnitResult) {
- unitResult = someUnitResult;
- } else {
- return NullSafetyAnalysisResult(
- NullSafetyCompliance.analysisFailed,
- 'Could not analyze $fileUrl.');
- }
- if (unitResult.errors.isNotEmpty) {
- return NullSafetyAnalysisResult(
- NullSafetyCompliance.analysisFailed,
- 'Could not analyze $fileUrl.');
- }
- if (unitResult.isPart) continue;
- final languageVersionToken = unitResult.unit.languageVersionToken;
- if (languageVersionToken == null) continue;
- final languageVersion = LanguageVersion.fromLanguageVersionToken(
- languageVersionToken);
- if (!languageVersion.supportsNullSafety) {
- final sourceFile =
- SourceFile.fromString(readTextFile(file), url: fileUrl);
- final span = sourceFile.span(languageVersionToken.offset,
- languageVersionToken.offset + languageVersionToken.length);
- return NullSafetyAnalysisResult(
- NullSafetyCompliance.notCompliant,
- '$fileUrl is opting out of null safety:\n${span.highlight()}');
- }
- }
- }
- }
- return NullSafetyAnalysisResult(NullSafetyCompliance.compliant, null);
- });
- if (packageInternalAnalysis.compliance ==
- NullSafetyCompliance.analysisFailed) {
- return packageInternalAnalysis;
- }
- if (packageInternalAnalysis.compliance ==
- NullSafetyCompliance.notCompliant) {
- firstBadPackage ??= packageInternalAnalysis;
- }
- }
-
- if (firstBadPackage == null) {
- return NullSafetyAnalysisResult(NullSafetyCompliance.compliant, null);
- }
- if (firstBadPackage.compliance == NullSafetyCompliance.analysisFailed) {
- return firstBadPackage;
- }
- return NullSafetyAnalysisResult(
- NullSafetyCompliance.mixed, firstBadPackage.reason);
- }
-}
-
-class NullSafetyAnalysisResult {
- final NullSafetyCompliance compliance;
-
- /// `null` if compliance == [NullSafetyCompliance.compliant].
- final String? reason;
-
- NullSafetyAnalysisResult(this.compliance, this.reason);
-}
-
-SourceSpan? _tryGetSpanFromYamlMap(Object? map, String key) {
- if (map is YamlMap) {
- return map.nodes[key]?.span;
- }
- return null;
-}
diff --git a/lib/src/pubspec_utils.dart b/lib/src/pubspec_utils.dart
index 71e30c4..f3e461a 100644
--- a/lib/src/pubspec_utils.dart
+++ b/lib/src/pubspec_utils.dart
@@ -2,14 +2,10 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-import 'dart:async';
-
import 'package:pub_semver/pub_semver.dart';
import 'package_name.dart';
import 'pubspec.dart';
-import 'source/hosted.dart';
-import 'system_cache.dart';
/// Returns a new [Pubspec] without [original]'s dev_dependencies.
Pubspec stripDevDependencies(Pubspec original) {
@@ -39,63 +35,6 @@
);
}
-Future<Pubspec> constrainedToAtLeastNullSafetyPubspec(
- Pubspec original, SystemCache cache) async {
- /// Get the first version of [package] opting in to null-safety.
- Future<VersionConstraint> constrainToFirstWithNullSafety(
- PackageRange packageRange) async {
- final ref = packageRange.toRef();
- final available = await cache.getVersions(ref);
- if (available.isEmpty) {
- return stripUpperBound(packageRange.constraint);
- }
-
- available.sort((x, y) => x.version.compareTo(y.version));
-
- for (final p in available) {
- final pubspec = await cache.describe(p);
- if (pubspec.languageVersion.supportsNullSafety) {
- return VersionRange(min: p.version, includeMin: true);
- }
- }
- return stripUpperBound(packageRange.constraint);
- }
-
- Future<List<PackageRange>> allConstrainedToAtLeastNullSafety(
- Map<String, PackageRange> constrained,
- ) async {
- final result = await Future.wait(constrained.keys.map((name) async {
- final packageRange = constrained[name]!;
- var unconstrainedRange = packageRange;
-
- /// We only need to remove the upper bound if it is a hosted package.
- if (packageRange.description is HostedDescription) {
- unconstrainedRange = PackageRange(
- packageRange.toRef(),
- await constrainToFirstWithNullSafety(packageRange),
- );
- }
- return unconstrainedRange;
- }));
-
- return result;
- }
-
- final constrainedLists = await Future.wait([
- allConstrainedToAtLeastNullSafety(original.dependencies),
- allConstrainedToAtLeastNullSafety(original.devDependencies),
- ]);
-
- return Pubspec(
- original.name,
- version: original.version,
- sdkConstraints: original.sdkConstraints,
- dependencies: constrainedLists[0],
- devDependencies: constrainedLists[1],
- dependencyOverrides: original.dependencyOverrides.values,
- );
-}
-
/// Returns new pubspec with the same dependencies as [original] but with the
/// upper bounds of the constraints removed.
///
diff --git a/lib/src/validator.dart b/lib/src/validator.dart
index a203f0c..b2d8fcb 100644
--- a/lib/src/validator.dart
+++ b/lib/src/validator.dart
@@ -26,7 +26,6 @@
import 'validator/leak_detection.dart';
import 'validator/license.dart';
import 'validator/name.dart';
-import 'validator/null_safety_mixed_mode.dart';
import 'validator/pubspec.dart';
import 'validator/pubspec_field.dart';
import 'validator/pubspec_typo.dart';
@@ -152,7 +151,6 @@
FlutterPluginFormatValidator(),
LanguageVersionValidator(),
RelativeVersionNumberingValidator(),
- NullSafetyMixedModeValidator(),
PubspecTypoValidator(),
LeakDetectionValidator(),
SizeValidator(),
diff --git a/lib/src/validator/null_safety_mixed_mode.dart b/lib/src/validator/null_safety_mixed_mode.dart
deleted file mode 100644
index b17e0e5..0000000
--- a/lib/src/validator/null_safety_mixed_mode.dart
+++ /dev/null
@@ -1,56 +0,0 @@
-// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-import 'dart:async';
-
-import 'package:path/path.dart' as p;
-
-import '../command_runner.dart';
-import '../null_safety_analysis.dart';
-import '../package_name.dart';
-import '../source/path.dart';
-import '../validator.dart';
-
-/// Gives a warning when publishing a new version, if this package opts into
-/// null safety, but any of the dependencies do not.
-class NullSafetyMixedModeValidator extends Validator {
- @override
- Future<void> validate() async {
- final pubspec = entrypoint.root.pubspec;
- final declaredLanguageVersion = pubspec.languageVersion;
- if (!declaredLanguageVersion.supportsNullSafety) {
- return;
- }
- final analysisResult =
- await NullSafetyAnalysis(entrypoint.cache).nullSafetyCompliance(
- PackageId(
- entrypoint.root.name,
- entrypoint.root.version,
- ResolvedPathDescription(
- PathDescription(p.absolute(entrypoint.root.dir), false),
- ),
- ),
- );
- if (analysisResult.compliance == NullSafetyCompliance.mixed) {
- warnings.add('''
-This package is opting into null-safety, but a dependency or file is not.
-
-${analysisResult.reason}
-
-Note that by publishing with non-migrated dependencies your package may be
-broken at any time if one of your dependencies migrates without a breaking
-change release.
-
-We highly recommend that you wait until all of your dependencies have been
-migrated before publishing.
-
-Run `$topLevelProgram pub outdated --mode=null-safety` for more information about the state
-of dependencies.
-
-See ${NullSafetyAnalysis.guideUrl}
-for more information about migrating.
-''');
- }
- }
-}
diff --git a/lib/src/validator/relative_version_numbering.dart b/lib/src/validator/relative_version_numbering.dart
index 1b99b79..9a5e214 100644
--- a/lib/src/validator/relative_version_numbering.dart
+++ b/lib/src/validator/relative_version_numbering.dart
@@ -7,7 +7,6 @@
import 'package:collection/collection.dart' show IterableExtension;
import '../exceptions.dart';
-import '../null_safety_analysis.dart';
import '../package_name.dart';
import '../validator.dart';
@@ -17,6 +16,9 @@
static const String semverUrl =
'https://dart.dev/tools/pub/versioning#semantic-versions';
+ static const String nullSafetyGuideUrl =
+ 'https://dart.dev/null-safety/migration-guide';
+
@override
Future<void> validate() async {
final hostedSource = entrypoint.cache.hosted;
@@ -43,7 +45,7 @@
hints.add(
'You\'re about to publish a package that opts into null safety.\n'
'The previous version (${previousVersion.version}) isn\'t opted in.\n'
- 'See ${NullSafetyAnalysis.guideUrl} for best practices.');
+ 'See $nullSafetyGuideUrl for best practices.');
} else if (!currentOptedIn && previousOptedIn) {
hints.add(
'You\'re about to publish a package that doesn\'t opt into null safety,\n'
diff --git a/test/outdated/outdated_test.dart b/test/outdated/outdated_test.dart
index 8e03ce0..0c88a9f 100644
--- a/test/outdated/outdated_test.dart
+++ b/test/outdated/outdated_test.dart
@@ -21,10 +21,6 @@
['outdated', '--no-color', '--prereleases'],
['outdated', '--no-color', '--no-dev-dependencies'],
['outdated', '--no-color', '--no-dependency-overrides'],
- ['outdated', '--no-color', '--mode=null-safety'],
- ['outdated', '--no-color', '--mode=null-safety', '--transitive'],
- ['outdated', '--no-color', '--mode=null-safety', '--no-prereleases'],
- ['outdated', '--json', '--mode=null-safety'],
['outdated', '--json', '--no-dev-dependencies'],
];
for (final args in commands) {
@@ -175,137 +171,6 @@
await ctx.runOutdatedTests();
});
- testWithGolden('null safety compliance', (ctx) async {
- await d.dir(appPath, [
- d.pubspec({
- 'name': 'app',
- 'version': '1.0.1',
- 'dependencies': {
- 'foo': '^1.0.0',
- 'bar': '^1.0.0',
- 'file_opts_out': '^1.0.0',
- 'fails_analysis': '^1.0.0',
- 'file_in_dependency_opts_out': '^1.0.0',
- 'fails_analysis_in_dependency': '^1.0.0',
- },
- 'environment': {'sdk': '>=2.12.0 < 3.0.0'},
- }),
- ]).create();
-
- await servePackages()
- ..serve('foo', '1.0.0', deps: {'bar': '^1.0.0'}, sdk: '>=2.9.0 < 4.0.0')
- ..serve('bar', '1.0.0', sdk: '>=2.9.0 < 4.0.0')
- ..serve(
- 'foo',
- '2.0.0-nullsafety.0',
- deps: {'bar': '^2.0.0'},
- sdk: '^2.12.0',
- )
- ..serve(
- 'foo',
- '2.0.0',
- deps: {'bar': '^1.0.0'},
- sdk: '^2.12.0',
- )
- ..serve('bar', '2.0.0', sdk: '^2.12.0')
- ..serve(
- 'file_opts_out',
- '1.0.0',
- contents: [
- d.dir('lib', [d.file('main.dart', '// @dart = 2.9\n')])
- ],
- sdk: '^2.12.0',
- )
- ..serve('file_opts_out', '2.0.0', sdk: '>=2.9.0 < 4.0.0')
- ..serve(
- 'fails_analysis',
- '1.0.0',
- contents: [
- d.dir('lib', [d.file('main.dart', 'syntax error\n')])
- ],
- sdk: '^2.12.0',
- )
- ..serve('fails_analysis', '2.0.0', sdk: '^2.12.0')
- ..serve(
- 'file_in_dependency_opts_out',
- '1.0.0',
- deps: {'file_opts_out': '^1.0.0'},
- sdk: '^2.12.0',
- )
- ..serve('file_in_dependency_opts_out', '2.0.0', sdk: '^2.12.0')
- ..serve(
- 'fails_analysis_in_dependency',
- '1.0.0',
- deps: {'fails_analysis': '^1.0.0'},
- sdk: '^2.12.0',
- )
- ..serve('fails_analysis_in_dependency', '2.0.0', sdk: '^2.12.0');
- await pubGet(environment: {'_PUB_TEST_SDK_VERSION': '2.13.0'});
-
- await ctx.runOutdatedTests(environment: {
- '_PUB_TEST_SDK_VERSION': '2.13.0',
- });
- });
-
- testWithGolden('null-safety no resolution', (ctx) async {
- await servePackages()
- ..serve('foo', '1.0.0', sdk: '>=2.9.0 < 4.0.0')
- ..serve(
- 'foo',
- '2.0.0-nullsafety.0',
- deps: {'bar': '^1.0.0'},
- )
- ..serve('bar', '1.0.0', pubspec: {
- 'environment': {'sdk': '>=2.9.0 < 4.0.0'}
- })
- ..serve(
- 'bar',
- '2.0.0-nullsafety.0',
- deps: {'foo': '^1.0.0'},
- );
-
- await d.dir(appPath, [
- d.pubspec({
- 'name': 'app',
- 'version': '1.0.0',
- 'dependencies': {
- 'foo': '^1.0.0',
- 'bar': '^1.0.0',
- }
- }),
- ]).create();
-
- await pubGet();
-
- await ctx.runOutdatedTests();
- });
-
- testWithGolden('null-safety already migrated', (ctx) async {
- await servePackages()
- ..serve('foo', '1.0.0', sdk: '>=2.9.0 < 4.0.0')
- ..serve('foo', '2.0.0')
- ..serve('bar', '1.0.0', sdk: '>=2.9.0 < 4.0.0')
- ..serve('bar', '2.0.0', deps: {'devTransitive': '^1.0.0'})
- ..serve('devTransitive', '1.0.0', sdk: '>=2.9.0 < 4.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',
- },
- }),
- ]).create();
-
- await pubGet();
-
- await ctx.runOutdatedTests();
- });
-
testWithGolden('overridden dependencies', (ctx) async {
ensureGit();
await servePackages()
diff --git a/test/testdata/goldens/help_test/pub outdated --help.txt b/test/testdata/goldens/help_test/pub outdated --help.txt
index d0f6bbe..cf411bb 100644
--- a/test/testdata/goldens/help_test/pub outdated --help.txt
+++ b/test/testdata/goldens/help_test/pub outdated --help.txt
@@ -11,16 +11,10 @@
--[no-]dev-dependencies Take dev dependencies into account.
(defaults to on)
--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).
--[no-]show-all Include dependencies that are already
fullfilling --mode.
--[no-]transitive Show transitive dependencies.
- (defaults to off in --mode=null-safety).
-C, --directory=<dir> Run this in the directory<dir>.
Run "pub help" to see global options.
diff --git a/test/testdata/goldens/help_test/pub upgrade --help.txt b/test/testdata/goldens/help_test/pub upgrade --help.txt
index d1a29b9..d33b3fd 100644
--- a/test/testdata/goldens/help_test/pub upgrade --help.txt
+++ b/test/testdata/goldens/help_test/pub upgrade --help.txt
@@ -10,8 +10,6 @@
-n, --dry-run Report what dependencies would change but don't change
any.
--[no-]precompile Precompile executables in immediate dependencies.
- --null-safety Upgrade constraints in pubspec.yaml to null-safety
- versions
--major-versions Upgrades packages to their latest resolvable versions,
and updates pubspec.yaml.
-C, --directory=<dir> Run this in the directory<dir>.
diff --git a/test/testdata/goldens/outdated/outdated_test/Handles SDK dependencies.txt b/test/testdata/goldens/outdated/outdated_test/Handles SDK dependencies.txt
index f2f0a22..2e675b7 100644
--- a/test/testdata/goldens/outdated/outdated_test/Handles SDK dependencies.txt
+++ b/test/testdata/goldens/outdated/outdated_test/Handles SDK dependencies.txt
@@ -129,114 +129,6 @@
-------------------------------- END OF OUTPUT ---------------------------------
## Section 7
-$ 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:
-foo ✗1.1.0 ✗1.1.0 ✓2.0.0 ✓2.0.0
-
-dev_dependencies:
-flutter_test ✗(sdk) ✗(sdk) ✗(sdk) ✗(sdk)
-
-1 dependency is constrained to a version that is older than a resolvable version.
-To update it, edit pubspec.yaml, or run `flutter pub upgrade --null-safety`.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 8
-$ 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.1.0 ✗1.1.0 ✓2.0.0 ✓2.0.0
-
-dev_dependencies:
-flutter_test ✗(sdk) ✗(sdk) ✗(sdk) ✗(sdk)
-
-1 dependency is constrained to a version that is older than a resolvable version.
-To update it, edit pubspec.yaml, or run `flutter pub upgrade --null-safety`.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 9
-$ 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:
-foo ✗1.1.0 ✗1.1.0 ✓2.0.0 ✓2.0.0
-
-dev_dependencies:
-flutter_test ✗(sdk) ✗(sdk) ✗(sdk) ✗(sdk)
-
-1 dependency is constrained to a version that is older than a resolvable version.
-To update it, edit pubspec.yaml, or run `flutter pub upgrade --null-safety`.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 10
-$ pub outdated --json --mode=null-safety
-{
- "packages": [
- {
- "package": "flutter_test",
- "kind": "dev",
- "isDiscontinued": false,
- "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
- }
- },
- {
- "package": "foo",
- "kind": "direct",
- "isDiscontinued": false,
- "current": {
- "version": "1.1.0",
- "nullSafety": false
- },
- "upgradable": {
- "version": "1.1.0",
- "nullSafety": false
- },
- "resolvable": {
- "version": "2.0.0",
- "nullSafety": true
- },
- "latest": {
- "version": "2.0.0",
- "nullSafety": true
- }
- }
- ]
-}
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 11
$ pub outdated --json --no-dev-dependencies
{
"packages": [
diff --git a/test/testdata/goldens/outdated/outdated_test/circular dependency on root.txt b/test/testdata/goldens/outdated/outdated_test/circular dependency on root.txt
index af8ad58..3b5c001 100644
--- a/test/testdata/goldens/outdated/outdated_test/circular dependency on root.txt
+++ b/test/testdata/goldens/outdated/outdated_test/circular dependency on root.txt
@@ -117,44 +117,6 @@
-------------------------------- END OF OUTPUT ---------------------------------
## Section 7
-$ 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.
-
-All your dependencies declare support for null-safety.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 8
-$ 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.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 9
-$ 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.
-
-All your dependencies declare support for null-safety.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 10
-$ pub outdated --json --mode=null-safety
-{
- "packages": []
-}
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 11
$ pub outdated --json --no-dev-dependencies
{
"packages": [
diff --git a/test/testdata/goldens/outdated/outdated_test/does not allow arguments - handles bad flags.txt b/test/testdata/goldens/outdated/outdated_test/does not allow arguments - handles bad flags.txt
index e9ae621..10fe350 100644
--- a/test/testdata/goldens/outdated/outdated_test/does not allow arguments - handles bad flags.txt
+++ b/test/testdata/goldens/outdated/outdated_test/does not allow arguments - handles bad flags.txt
@@ -11,16 +11,10 @@
[STDERR] --[no-]dev-dependencies Take dev dependencies into account.
[STDERR] (defaults to on)
[STDERR] --json Output the results using a json format.
-[STDERR] --mode=<PROPERTY> Highlight versions with PROPERTY.
-[STDERR] Only packages currently missing that PROPERTY
-[STDERR] will be included unless --show-all.
-[STDERR] [outdated (default), null-safety]
[STDERR] --[no-]prereleases Include prereleases in latest version.
-[STDERR] (defaults to on in --mode=null-safety).
[STDERR] --[no-]show-all Include dependencies that are already
[STDERR] fullfilling --mode.
[STDERR] --[no-]transitive Show transitive dependencies.
-[STDERR] (defaults to off in --mode=null-safety).
[STDERR] -C, --directory=<dir> Run this in the directory<dir>.
[STDERR]
[STDERR] Run "pub help" to see global options.
@@ -40,16 +34,10 @@
[STDERR] --[no-]dev-dependencies Take dev dependencies into account.
[STDERR] (defaults to on)
[STDERR] --json Output the results using a json format.
-[STDERR] --mode=<PROPERTY> Highlight versions with PROPERTY.
-[STDERR] Only packages currently missing that PROPERTY
-[STDERR] will be included unless --show-all.
-[STDERR] [outdated (default), null-safety]
[STDERR] --[no-]prereleases Include prereleases in latest version.
-[STDERR] (defaults to on in --mode=null-safety).
[STDERR] --[no-]show-all Include dependencies that are already
[STDERR] fullfilling --mode.
[STDERR] --[no-]transitive Show transitive dependencies.
-[STDERR] (defaults to off in --mode=null-safety).
[STDERR] -C, --directory=<dir> Run this in the directory<dir>.
[STDERR]
[STDERR] Run "pub help" to see global options.
diff --git a/test/testdata/goldens/outdated/outdated_test/latest version reported while locked on a prerelease can be a prerelease.txt b/test/testdata/goldens/outdated/outdated_test/latest version reported while locked on a prerelease can be a prerelease.txt
index 657222a..1bd3a68 100644
--- a/test/testdata/goldens/outdated/outdated_test/latest version reported while locked on a prerelease can be a prerelease.txt
+++ b/test/testdata/goldens/outdated/outdated_test/latest version reported while locked on a prerelease can be a prerelease.txt
@@ -142,44 +142,6 @@
-------------------------------- END OF OUTPUT ---------------------------------
## Section 7
-$ 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.
-
-All your dependencies declare support for null-safety.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 8
-$ 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.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 9
-$ 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.
-
-All your dependencies declare support for null-safety.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 10
-$ pub outdated --json --mode=null-safety
-{
- "packages": []
-}
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 11
$ pub outdated --json --no-dev-dependencies
{
"packages": [
diff --git a/test/testdata/goldens/outdated/outdated_test/mutually incompatible newer versions.txt b/test/testdata/goldens/outdated/outdated_test/mutually incompatible newer versions.txt
index 4e0b4ad..1d8d529 100644
--- a/test/testdata/goldens/outdated/outdated_test/mutually incompatible newer versions.txt
+++ b/test/testdata/goldens/outdated/outdated_test/mutually incompatible newer versions.txt
@@ -134,44 +134,6 @@
-------------------------------- END OF OUTPUT ---------------------------------
## Section 7
-$ 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.
-
-All your dependencies declare support for null-safety.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 8
-$ 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.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 9
-$ 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.
-
-All your dependencies declare support for null-safety.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 10
-$ pub outdated --json --mode=null-safety
-{
- "packages": []
-}
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 11
$ pub outdated --json --no-dev-dependencies
{
"packages": [
diff --git a/test/testdata/goldens/outdated/outdated_test/newer versions available.txt b/test/testdata/goldens/outdated/outdated_test/newer versions available.txt
index c5e17c1..7d91029 100644
--- a/test/testdata/goldens/outdated/outdated_test/newer versions available.txt
+++ b/test/testdata/goldens/outdated/outdated_test/newer versions available.txt
@@ -114,18 +114,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 `dart 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, or run `dart pub upgrade --major-versions`.
-------------------------------- END OF OUTPUT ---------------------------------
@@ -166,18 +158,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 `dart 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, or run `dart pub upgrade --major-versions`.
-------------------------------- END OF OUTPUT ---------------------------------
@@ -195,18 +179,10 @@
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
-
-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 `dart 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, or run `dart pub upgrade --major-versions`.
-------------------------------- END OF OUTPUT ---------------------------------
@@ -221,11 +197,8 @@
direct dependencies:
foo *1.2.3 *1.3.0 3.0.0 3.0.0
-transitive dependencies:
-transitive *1.2.3 2.0.0 2.0.0 2.0.0
-
-2 upgradable dependencies are locked (in pubspec.lock) to older versions.
-To update these dependencies, use `dart pub upgrade`.
+1 upgradable dependency is locked (in pubspec.lock) to an older version.
+To update it, use `dart pub upgrade`.
1 dependency is constrained to a version that is older than a resolvable version.
To update it, edit pubspec.yaml, or run `dart pub upgrade --major-versions`.
@@ -245,113 +218,15 @@
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 `dart 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, or run `dart pub upgrade --major-versions`.
-------------------------------- END OF OUTPUT ---------------------------------
## Section 7
-$ 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.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 8
-$ 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 dependencies:
-transitive2 - - ✓1.0.0 ✓1.0.0
-
-transitive dev_dependencies:
-transitive3 - - ✓1.0.0 ✓1.0.0
-All dependencies opt in to null-safety.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 9
-$ 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.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 10
-$ pub outdated --json --mode=null-safety
-{
- "packages": [
- {
- "package": "transitive2",
- "kind": "transitive",
- "isDiscontinued": false,
- "current": null,
- "upgradable": null,
- "resolvable": {
- "version": "1.0.0",
- "nullSafety": true
- },
- "latest": {
- "version": "1.0.0",
- "nullSafety": true
- }
- },
- {
- "package": "transitive3",
- "kind": "transitive",
- "isDiscontinued": false,
- "current": null,
- "upgradable": null,
- "resolvable": {
- "version": "1.0.0",
- "nullSafety": true
- },
- "latest": {
- "version": "1.0.0",
- "nullSafety": true
- }
- }
- ]
-}
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 11
$ pub outdated --json --no-dev-dependencies
{
"packages": [
diff --git a/test/testdata/goldens/outdated/outdated_test/no dependencies.txt b/test/testdata/goldens/outdated/outdated_test/no dependencies.txt
index d256d7f..c999804 100644
--- a/test/testdata/goldens/outdated/outdated_test/no dependencies.txt
+++ b/test/testdata/goldens/outdated/outdated_test/no dependencies.txt
@@ -63,44 +63,6 @@
-------------------------------- END OF OUTPUT ---------------------------------
## Section 7
-$ 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.
-
-All your dependencies declare support for null-safety.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 8
-$ 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.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 9
-$ 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.
-
-All your dependencies declare support for null-safety.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 10
-$ pub outdated --json --mode=null-safety
-{
- "packages": []
-}
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 11
$ pub outdated --json --no-dev-dependencies
{
"packages": []
diff --git a/test/testdata/goldens/outdated/outdated_test/no lockfile.txt b/test/testdata/goldens/outdated/outdated_test/no lockfile.txt
index f6b5f62..62f8c6c 100644
--- a/test/testdata/goldens/outdated/outdated_test/no lockfile.txt
+++ b/test/testdata/goldens/outdated/outdated_test/no lockfile.txt
@@ -154,111 +154,6 @@
-------------------------------- END OF OUTPUT ---------------------------------
## Section 7
-$ 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:
-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 `dart 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, or run `dart pub upgrade --null-safety`.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 8
-$ 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 `dart 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, or run `dart pub upgrade --null-safety`.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 9
-$ 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:
-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 `dart 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, or run `dart pub upgrade --null-safety`.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 10
-$ pub outdated --json --mode=null-safety
-{
- "packages": [
- {
- "package": "bar",
- "kind": "direct",
- "isDiscontinued": false,
- "current": null,
- "upgradable": {
- "version": "1.2.3",
- "nullSafety": true
- },
- "resolvable": {
- "version": "2.0.0",
- "nullSafety": true
- },
- "latest": {
- "version": "2.0.0",
- "nullSafety": true
- }
- },
- {
- "package": "foo",
- "kind": "direct",
- "isDiscontinued": false,
- "current": null,
- "upgradable": {
- "version": "1.2.3",
- "nullSafety": true
- },
- "resolvable": {
- "version": "1.2.3",
- "nullSafety": true
- },
- "latest": {
- "version": "1.2.3",
- "nullSafety": true
- }
- }
- ]
-}
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 11
$ pub outdated --json --no-dev-dependencies
{
"packages": [
diff --git a/test/testdata/goldens/outdated/outdated_test/null safety compliance.txt b/test/testdata/goldens/outdated/outdated_test/null safety compliance.txt
deleted file mode 100644
index aadad45..0000000
--- a/test/testdata/goldens/outdated/outdated_test/null safety compliance.txt
+++ /dev/null
@@ -1,444 +0,0 @@
-# GENERATED BY: test/outdated/outdated_test.dart
-
-## Section 0
-$ pub outdated --json
-{
- "packages": [
- {
- "package": "bar",
- "kind": "direct",
- "isDiscontinued": false,
- "current": {
- "version": "1.0.0"
- },
- "upgradable": {
- "version": "1.0.0"
- },
- "resolvable": {
- "version": "2.0.0"
- },
- "latest": {
- "version": "2.0.0"
- }
- },
- {
- "package": "fails_analysis",
- "kind": "direct",
- "isDiscontinued": false,
- "current": {
- "version": "1.0.0"
- },
- "upgradable": {
- "version": "1.0.0"
- },
- "resolvable": {
- "version": "2.0.0"
- },
- "latest": {
- "version": "2.0.0"
- }
- },
- {
- "package": "fails_analysis_in_dependency",
- "kind": "direct",
- "isDiscontinued": false,
- "current": {
- "version": "1.0.0"
- },
- "upgradable": {
- "version": "1.0.0"
- },
- "resolvable": {
- "version": "2.0.0"
- },
- "latest": {
- "version": "2.0.0"
- }
- },
- {
- "package": "file_in_dependency_opts_out",
- "kind": "direct",
- "isDiscontinued": false,
- "current": {
- "version": "1.0.0"
- },
- "upgradable": {
- "version": "1.0.0"
- },
- "resolvable": {
- "version": "2.0.0"
- },
- "latest": {
- "version": "2.0.0"
- }
- },
- {
- "package": "file_opts_out",
- "kind": "direct",
- "isDiscontinued": false,
- "current": {
- "version": "1.0.0"
- },
- "upgradable": {
- "version": "1.0.0"
- },
- "resolvable": {
- "version": "2.0.0"
- },
- "latest": {
- "version": "2.0.0"
- }
- },
- {
- "package": "foo",
- "kind": "direct",
- "isDiscontinued": false,
- "current": {
- "version": "1.0.0"
- },
- "upgradable": {
- "version": "1.0.0"
- },
- "resolvable": {
- "version": "2.0.0-nullsafety.0"
- },
- "latest": {
- "version": "2.0.0"
- }
- }
- ]
-}
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 1
-$ pub outdated --no-color
-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 2.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-nullsafety.0 2.0.0
-
-6 dependencies are constrained to versions that are older than a resolvable version.
-To update these dependencies, edit pubspec.yaml, or run `dart pub upgrade --major-versions`.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 2
-$ 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 2.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-nullsafety.0 2.0.0
-
-6 dependencies are constrained to versions that are older than a resolvable version.
-To update these dependencies, edit pubspec.yaml, or run `dart pub upgrade --major-versions`.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 3
-$ 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:
-bar *1.0.0 *1.0.0 2.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-nullsafety.0 2.0.0
-
-6 dependencies are constrained to versions that are older than a resolvable version.
-To update these dependencies, edit pubspec.yaml, or run `dart pub upgrade --major-versions`.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 4
-$ pub outdated --no-color --prereleases
-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 2.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-nullsafety.0 2.0.0
-
-6 dependencies are constrained to versions that are older than a resolvable version.
-To update these dependencies, edit pubspec.yaml, or run `dart pub upgrade --major-versions`.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 5
-$ pub outdated --no-color --no-dev-dependencies
-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 2.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-nullsafety.0 2.0.0
-
-6 dependencies are constrained to versions that are older than a resolvable version.
-To update these dependencies, edit pubspec.yaml, or run `dart pub upgrade --major-versions`.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 6
-$ pub outdated --no-color --no-dependency-overrides
-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 2.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-nullsafety.0 2.0.0
-
-6 dependencies are constrained to versions that are older than a resolvable version.
-To update these dependencies, edit pubspec.yaml, or run `dart pub upgrade --major-versions`.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 7
-$ 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:
-bar ✗1.0.0 ✗1.0.0 ✓2.0.0 ✓2.0.0
-foo ✗1.0.0 ✗1.0.0 ✓2.0.0-nullsafety.0 ✓2.0.0
-
-2 dependencies are constrained to versions that are older than a resolvable version.
-To update these dependencies, edit pubspec.yaml, or run `dart pub upgrade --null-safety`.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 8
-$ 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 ✓2.0.0 ✓2.0.0
-foo ✗1.0.0 ✗1.0.0 ✓2.0.0-nullsafety.0 ✓2.0.0
-
-2 dependencies are constrained to versions that are older than a resolvable version.
-To update these dependencies, edit pubspec.yaml, or run `dart pub upgrade --null-safety`.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 9
-$ 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:
-bar ✗1.0.0 ✗1.0.0 ✓2.0.0 ✓2.0.0
-foo ✗1.0.0 ✗1.0.0 ✓2.0.0-nullsafety.0 ✓2.0.0
-
-2 dependencies are constrained to versions that are older than a resolvable version.
-To update these dependencies, edit pubspec.yaml, or run `dart pub upgrade --null-safety`.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 10
-$ pub outdated --json --mode=null-safety
-{
- "packages": [
- {
- "package": "bar",
- "kind": "direct",
- "isDiscontinued": false,
- "current": {
- "version": "1.0.0",
- "nullSafety": false
- },
- "upgradable": {
- "version": "1.0.0",
- "nullSafety": false
- },
- "resolvable": {
- "version": "2.0.0",
- "nullSafety": true
- },
- "latest": {
- "version": "2.0.0",
- "nullSafety": true
- }
- },
- {
- "package": "foo",
- "kind": "direct",
- "isDiscontinued": false,
- "current": {
- "version": "1.0.0",
- "nullSafety": false
- },
- "upgradable": {
- "version": "1.0.0",
- "nullSafety": false
- },
- "resolvable": {
- "version": "2.0.0-nullsafety.0",
- "nullSafety": true
- },
- "latest": {
- "version": "2.0.0",
- "nullSafety": true
- }
- }
- ]
-}
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 11
-$ pub outdated --json --no-dev-dependencies
-{
- "packages": [
- {
- "package": "bar",
- "kind": "direct",
- "isDiscontinued": false,
- "current": {
- "version": "1.0.0"
- },
- "upgradable": {
- "version": "1.0.0"
- },
- "resolvable": {
- "version": "2.0.0"
- },
- "latest": {
- "version": "2.0.0"
- }
- },
- {
- "package": "fails_analysis",
- "kind": "direct",
- "isDiscontinued": false,
- "current": {
- "version": "1.0.0"
- },
- "upgradable": {
- "version": "1.0.0"
- },
- "resolvable": {
- "version": "2.0.0"
- },
- "latest": {
- "version": "2.0.0"
- }
- },
- {
- "package": "fails_analysis_in_dependency",
- "kind": "direct",
- "isDiscontinued": false,
- "current": {
- "version": "1.0.0"
- },
- "upgradable": {
- "version": "1.0.0"
- },
- "resolvable": {
- "version": "2.0.0"
- },
- "latest": {
- "version": "2.0.0"
- }
- },
- {
- "package": "file_in_dependency_opts_out",
- "kind": "direct",
- "isDiscontinued": false,
- "current": {
- "version": "1.0.0"
- },
- "upgradable": {
- "version": "1.0.0"
- },
- "resolvable": {
- "version": "2.0.0"
- },
- "latest": {
- "version": "2.0.0"
- }
- },
- {
- "package": "file_opts_out",
- "kind": "direct",
- "isDiscontinued": false,
- "current": {
- "version": "1.0.0"
- },
- "upgradable": {
- "version": "1.0.0"
- },
- "resolvable": {
- "version": "2.0.0"
- },
- "latest": {
- "version": "2.0.0"
- }
- },
- {
- "package": "foo",
- "kind": "direct",
- "isDiscontinued": false,
- "current": {
- "version": "1.0.0"
- },
- "upgradable": {
- "version": "1.0.0"
- },
- "resolvable": {
- "version": "2.0.0-nullsafety.0"
- },
- "latest": {
- "version": "2.0.0"
- }
- }
- ]
-}
-
diff --git a/test/testdata/goldens/outdated/outdated_test/null-safety already migrated.txt b/test/testdata/goldens/outdated/outdated_test/null-safety already migrated.txt
deleted file mode 100644
index f7116b2..0000000
--- a/test/testdata/goldens/outdated/outdated_test/null-safety already migrated.txt
+++ /dev/null
@@ -1,159 +0,0 @@
-# GENERATED BY: test/outdated/outdated_test.dart
-
-## Section 0
-$ pub outdated --json
-{
- "packages": []
-}
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 1
-$ pub outdated --no-color
-Showing outdated packages.
-[*] indicates versions that are not the latest available.
-
-Found no outdated packages
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 2
-$ pub outdated --no-color --no-transitive
-Showing outdated packages.
-[*] indicates versions that are not the latest available.
-
-Found no outdated packages
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 3
-$ 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.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 4
-$ pub outdated --no-color --prereleases
-Showing outdated packages.
-[*] indicates versions that are not the latest available.
-
-Found no outdated packages
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 5
-$ pub outdated --no-color --no-dev-dependencies
-Showing outdated packages.
-[*] indicates versions that are not the latest available.
-
-Found no outdated packages
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 6
-$ pub outdated --no-color --no-dependency-overrides
-Showing outdated packages.
-[*] indicates versions that are not the latest available.
-
-Found no outdated packages
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 7
-$ 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.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 8
-$ 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.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 9
-$ 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.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 10
-$ pub outdated --json --mode=null-safety
-{
- "packages": [
- {
- "package": "devTransitive",
- "kind": "transitive",
- "isDiscontinued": false,
- "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
- }
- }
- ]
-}
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 11
-$ pub outdated --json --no-dev-dependencies
-{
- "packages": []
-}
-
diff --git a/test/testdata/goldens/outdated/outdated_test/null-safety no resolution.txt b/test/testdata/goldens/outdated/outdated_test/null-safety no resolution.txt
deleted file mode 100644
index ccaa3bd..0000000
--- a/test/testdata/goldens/outdated/outdated_test/null-safety no resolution.txt
+++ /dev/null
@@ -1,172 +0,0 @@
-# GENERATED BY: test/outdated/outdated_test.dart
-
-## Section 0
-$ pub outdated --json
-{
- "packages": []
-}
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 1
-$ pub outdated --no-color
-Showing outdated packages.
-[*] indicates versions that are not the latest available.
-
-Found no outdated packages
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 2
-$ pub outdated --no-color --no-transitive
-Showing outdated packages.
-[*] indicates versions that are not the latest available.
-
-Found no outdated packages
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 3
-$ 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:
-bar 1.0.0 1.0.0 1.0.0 1.0.0
-foo 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.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 4
-$ pub outdated --no-color --prereleases
-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-nullsafety.0
-foo *1.0.0 *1.0.0 *1.0.0 2.0.0-nullsafety.0
-You are already using the newest resolvable versions listed in the 'Resolvable' column.
-Newer versions, listed in 'Latest', may not be mutually compatible.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 5
-$ pub outdated --no-color --no-dev-dependencies
-Showing outdated packages.
-[*] indicates versions that are not the latest available.
-
-Found no outdated packages
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 6
-$ pub outdated --no-color --no-dependency-overrides
-Showing outdated packages.
-[*] indicates versions that are not the latest available.
-
-Found no outdated packages
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 7
-$ 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:
-bar ✗1.0.0 ✗1.0.0 - ✓2.0.0-nullsafety.0
-foo ✗1.0.0 ✗1.0.0 - ✓2.0.0-nullsafety.0
-No resolution was found. Try running `dart pub upgrade --null-safety --dry-run` to explore why.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 8
-$ 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 - ✓2.0.0-nullsafety.0
-foo ✗1.0.0 ✗1.0.0 - ✓2.0.0-nullsafety.0
-No resolution was found. Try running `dart pub upgrade --null-safety --dry-run` to explore why.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 9
-$ 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:
-bar ✗1.0.0 ✗1.0.0 - ✗1.0.0
-foo ✗1.0.0 ✗1.0.0 - ✗1.0.0
-No resolution was found. Try running `dart pub upgrade --null-safety --dry-run` to explore why.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 10
-$ pub outdated --json --mode=null-safety
-{
- "packages": [
- {
- "package": "bar",
- "kind": "direct",
- "isDiscontinued": false,
- "current": {
- "version": "1.0.0",
- "nullSafety": false
- },
- "upgradable": {
- "version": "1.0.0",
- "nullSafety": false
- },
- "resolvable": null,
- "latest": {
- "version": "2.0.0-nullsafety.0",
- "nullSafety": true
- }
- },
- {
- "package": "foo",
- "kind": "direct",
- "isDiscontinued": false,
- "current": {
- "version": "1.0.0",
- "nullSafety": false
- },
- "upgradable": {
- "version": "1.0.0",
- "nullSafety": false
- },
- "resolvable": null,
- "latest": {
- "version": "2.0.0-nullsafety.0",
- "nullSafety": true
- }
- }
- ]
-}
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 11
-$ pub outdated --json --no-dev-dependencies
-{
- "packages": []
-}
-
diff --git a/test/testdata/goldens/outdated/outdated_test/overridden dependencies - no resolution.txt b/test/testdata/goldens/outdated/outdated_test/overridden dependencies - no resolution.txt
index 78d9b51..329641d 100644
--- a/test/testdata/goldens/outdated/outdated_test/overridden dependencies - no resolution.txt
+++ b/test/testdata/goldens/outdated/outdated_test/overridden dependencies - no resolution.txt
@@ -139,44 +139,6 @@
-------------------------------- END OF OUTPUT ---------------------------------
## Section 7
-$ 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.
-
-All your dependencies declare support for null-safety.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 8
-$ 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.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 9
-$ 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.
-
-All your dependencies declare support for null-safety.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 10
-$ pub outdated --json --mode=null-safety
-{
- "packages": []
-}
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 11
$ pub outdated --json --no-dev-dependencies
{
"packages": [
diff --git a/test/testdata/goldens/outdated/outdated_test/overridden dependencies.txt b/test/testdata/goldens/outdated/outdated_test/overridden dependencies.txt
index f32a4b0..54bf561 100644
--- a/test/testdata/goldens/outdated/outdated_test/overridden dependencies.txt
+++ b/test/testdata/goldens/outdated/outdated_test/overridden dependencies.txt
@@ -170,44 +170,6 @@
-------------------------------- END OF OUTPUT ---------------------------------
## Section 7
-$ 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.
-
-All your dependencies declare support for null-safety.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 8
-$ 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.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 9
-$ 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.
-
-All your dependencies declare support for null-safety.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 10
-$ pub outdated --json --mode=null-safety
-{
- "packages": []
-}
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 11
$ pub outdated --json --no-dev-dependencies
{
"packages": [
diff --git a/test/testdata/goldens/outdated/outdated_test/show discontinued.txt b/test/testdata/goldens/outdated/outdated_test/show discontinued.txt
index dc3ea84..10472a0 100644
--- a/test/testdata/goldens/outdated/outdated_test/show discontinued.txt
+++ b/test/testdata/goldens/outdated/outdated_test/show discontinued.txt
@@ -37,9 +37,6 @@
bar 1.0.0 1.0.0 1.0.0 1.0.0
baz 1.0.0 1.0.0 1.0.0 1.0.0 (discontinued)
foo 1.2.3 1.2.3 1.2.3 1.2.3 (discontinued)
-
-transitive dependencies:
-transitive 1.2.3 1.2.3 1.2.3 1.2.3
You are already using the newest resolvable versions listed in the 'Resolvable' column.
Newer versions, listed in 'Latest', may not be mutually compatible.
@@ -78,44 +75,6 @@
-------------------------------- END OF OUTPUT ---------------------------------
## Section 7
-$ 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.
-
-All your dependencies declare support for null-safety.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 8
-$ 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.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 9
-$ 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.
-
-All your dependencies declare support for null-safety.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 10
-$ pub outdated --json --mode=null-safety
-{
- "packages": []
-}
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 11
$ pub outdated --json --no-dev-dependencies
{
"packages": []
diff --git a/test/testdata/goldens/upgrade/example_warns_about_major_versions_test/pub upgrade --null-safety does not update null-safety of dependencies in example~.txt b/test/testdata/goldens/upgrade/example_warns_about_major_versions_test/pub upgrade --null-safety does not update null-safety of dependencies in example~.txt
index cabc0be..32970c8 100644
--- a/test/testdata/goldens/upgrade/example_warns_about_major_versions_test/pub upgrade --null-safety does not update null-safety of dependencies in example~.txt
+++ b/test/testdata/goldens/upgrade/example_warns_about_major_versions_test/pub upgrade --null-safety does not update null-safety of dependencies in example~.txt
@@ -2,27 +2,15 @@
## Section 0
$ pub upgrade --null-safety --example
-Resolving dependencies...
-+ bar 2.0.0
-Changed 1 dependency!
-
-Changed 1 constraint in pubspec.yaml:
- bar: ^1.0.0 -> ^2.0.0
-Resolving dependencies in ./example...
-Got dependencies in ./example.
-[STDERR] Running `upgrade --null-safety` only in `.`. Run `dart pub upgrade --null-safety --directory example/` separately.
+[STDERR] The `--null-safety` flag is no longer supported.
+[STDERR] Consider using the Dart 2.19 sdk to migrate to null safety.
+[EXIT CODE] 65
-------------------------------- END OF OUTPUT ---------------------------------
## Section 1
$ pub upgrade --null-safety --directory example
-Resolving dependencies in example...
-> bar 2.0.0 (was 1.0.0)
-> foo 2.0.0 (was 1.0.0)
- myapp 0.0.0 from path .
-Changed 2 dependencies in example!
-
-Changed 2 constraints in pubspec.yaml:
- foo: ^1.0.0 -> ^2.0.0
- bar: ^1.0.0 -> ^2.0.0
+[STDERR] The `--null-safety` flag is no longer supported.
+[STDERR] Consider using the Dart 2.19 sdk to migrate to null safety.
+[EXIT CODE] 65
diff --git a/test/upgrade/upgrade_null_safety_test.dart b/test/upgrade/upgrade_null_safety_test.dart
deleted file mode 100644
index ad210d8..0000000
--- a/test/upgrade/upgrade_null_safety_test.dart
+++ /dev/null
@@ -1,482 +0,0 @@
-// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-import 'package:test/test.dart';
-import '../descriptor.dart' as d;
-import '../test_pub.dart';
-
-void main() {
- group('pub upgrade --null-safety', () {
- setUp(() async {
- await servePackages()
- ..serve('foo', '1.0.0', pubspec: {
- 'environment': {'sdk': '>=2.10.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-nullsafety.0', pubspec: {
- 'environment': {'sdk': '>=2.12.0<3.0.0'},
- })
- ..serve('baz', '1.0.0', pubspec: {
- 'environment': {'sdk': '>=2.9.0<3.0.0'},
- })
- ..serve('has_conflict', '1.0.0', pubspec: {
- 'environment': {'sdk': '>=2.9.0<3.0.0'},
- })
- ..serve('has_conflict', '2.0.0', pubspec: {
- 'environment': {'sdk': '>=2.13.0<3.0.0'},
- });
- });
-
- test('upgrades to null-safety versions', () async {
- await d.dir(appPath, [
- d.pubspec({
- 'name': 'myapp',
- 'dependencies': {
- 'foo': '^1.0.0',
- },
- 'environment': {'sdk': '>=2.9.0<3.0.0'},
- }),
- ]).create();
-
- await pubGet(environment: {
- '_PUB_TEST_SDK_VERSION': '2.10.0',
- });
- await d.dir(appPath, [
- d.packageConfigFile([
- d.packageConfigEntry(
- name: 'foo',
- version: '1.0.0',
- languageVersion: '2.10',
- ),
- d.packageConfigEntry(
- name: 'myapp',
- languageVersion: '2.9',
- path: '.',
- ),
- ], generatorVersion: '2.10.0'),
- ]).validate();
-
- await pubUpgrade(
- args: ['--null-safety'],
- environment: {
- '_PUB_TEST_SDK_VERSION': '2.12.0',
- },
- output: allOf(
- contains('Changed 1 constraint in pubspec.yaml:'),
- contains('foo: ^1.0.0 -> ^2.0.0'),
- ),
- );
-
- await d.dir(appPath, [
- d.pubspec({
- 'name': 'myapp',
- 'dependencies': {
- 'foo': '^2.0.0',
- },
- 'environment': {'sdk': '>=2.9.0<3.0.0'},
- }),
- d.packageConfigFile([
- d.packageConfigEntry(
- name: 'foo',
- version: '2.0.0',
- languageVersion: '2.12',
- ),
- d.packageConfigEntry(
- name: 'myapp',
- languageVersion: '2.9',
- path: '.',
- ),
- ], generatorVersion: '2.12.0'),
- ]).validate();
- });
-
- test('upgrades to prereleases when required', () async {
- await d.dir(appPath, [
- d.pubspec({
- 'name': 'myapp',
- 'dependencies': {
- 'bar': '^1.0.0',
- },
- 'environment': {'sdk': '>=2.9.0<3.0.0'},
- }),
- ]).create();
-
- await pubGet(environment: {
- '_PUB_TEST_SDK_VERSION': '2.10.0',
- });
- await d.dir(appPath, [
- d.packageConfigFile([
- d.packageConfigEntry(
- name: 'bar',
- version: '1.0.0',
- languageVersion: '2.9',
- ),
- d.packageConfigEntry(
- name: 'myapp',
- languageVersion: '2.9',
- path: '.',
- ),
- ], generatorVersion: '2.10.0'),
- ]).validate();
-
- await pubUpgrade(
- args: ['--null-safety'],
- environment: {
- '_PUB_TEST_SDK_VERSION': '2.12.0',
- },
- output: allOf(
- contains('Changed 1 constraint in pubspec.yaml:'),
- contains('bar: ^1.0.0 -> ^2.0.0-nullsafety.0'),
- ),
- );
-
- await d.dir(appPath, [
- d.pubspec({
- 'name': 'myapp',
- 'dependencies': {
- 'bar': '^2.0.0-nullsafety.0',
- },
- 'environment': {'sdk': '>=2.9.0<3.0.0'},
- }),
- d.packageConfigFile([
- d.packageConfigEntry(
- name: 'bar',
- version: '2.0.0-nullsafety.0',
- languageVersion: '2.12',
- ),
- d.packageConfigEntry(
- name: 'myapp',
- languageVersion: '2.9',
- path: '.',
- ),
- ], generatorVersion: '2.12.0'),
- ]).validate();
- });
-
- test('upgrades multiple dependencies', () async {
- await d.dir(appPath, [
- d.pubspec({
- 'name': 'myapp',
- 'dependencies': {
- 'foo': '^1.0.0',
- 'bar': '^1.0.0',
- },
- 'environment': {'sdk': '>=2.9.0<3.0.0'},
- }),
- ]).create();
-
- await pubGet(environment: {
- '_PUB_TEST_SDK_VERSION': '2.10.0',
- });
-
- await pubUpgrade(
- args: ['--null-safety'],
- environment: {
- '_PUB_TEST_SDK_VERSION': '2.12.0',
- },
- output: allOf(
- contains('Changed 2 constraints in pubspec.yaml:'),
- contains('foo: ^1.0.0 -> ^2.0.0'),
- contains('bar: ^1.0.0 -> ^2.0.0-nullsafety.0'),
- ),
- );
-
- await d.dir(appPath, [
- d.pubspec({
- 'name': 'myapp',
- 'dependencies': {
- 'foo': '^2.0.0',
- 'bar': '^2.0.0-nullsafety.0',
- },
- 'environment': {'sdk': '>=2.9.0<3.0.0'},
- }),
- d.packageConfigFile([
- d.packageConfigEntry(
- name: 'foo',
- version: '2.0.0',
- languageVersion: '2.12',
- ),
- d.packageConfigEntry(
- name: 'bar',
- version: '2.0.0-nullsafety.0',
- languageVersion: '2.12',
- ),
- d.packageConfigEntry(
- name: 'myapp',
- languageVersion: '2.9',
- path: '.',
- ),
- ], generatorVersion: '2.12.0'),
- ]).validate();
- });
-
- test('--dry-run does not mutate pubspec.yaml', () async {
- await d.dir(appPath, [
- d.pubspec({
- 'name': 'myapp',
- 'dependencies': {
- 'foo': '^1.0.0',
- 'bar': '^1.0.0',
- },
- 'environment': {'sdk': '>=2.9.0<3.0.0'},
- }),
- ]).create();
-
- await pubGet(environment: {
- '_PUB_TEST_SDK_VERSION': '2.10.0',
- });
-
- final stateBeforeUpgrade = d.dir(appPath, [
- d.pubspec({
- 'name': 'myapp',
- 'dependencies': {
- 'foo': '^1.0.0',
- 'bar': '^1.0.0',
- },
- 'environment': {'sdk': '>=2.9.0<3.0.0'},
- }),
- d.packageConfigFile([
- d.packageConfigEntry(
- name: 'foo',
- version: '1.0.0',
- languageVersion: '2.10',
- ),
- d.packageConfigEntry(
- name: 'bar',
- version: '1.0.0',
- languageVersion: '2.9',
- ),
- d.packageConfigEntry(
- name: 'myapp',
- languageVersion: '2.9',
- path: '.',
- ),
- ], generatorVersion: '2.10.0'),
- ]);
- await stateBeforeUpgrade.validate();
-
- await pubUpgrade(
- args: ['--null-safety', '--dry-run'],
- environment: {
- '_PUB_TEST_SDK_VERSION': '2.12.0',
- },
- output: allOf(
- contains('Would change 2 constraints in pubspec.yaml:'),
- contains('foo: ^1.0.0 -> ^2.0.0'),
- contains('bar: ^1.0.0 -> ^2.0.0-nullsafety.0'),
- ),
- );
-
- await stateBeforeUpgrade.validate();
- });
-
- test('ignores path dependencies', () async {
- await d.dir('baz', [
- d.pubspec({
- 'name': 'baz',
- 'environment': {'sdk': '>=2.9.0<3.0.0'},
- }),
- ]).create();
-
- await d.dir(appPath, [
- d.pubspec({
- 'name': 'myapp',
- 'dependencies': {
- 'foo': '^1.0.0',
- 'bar': '^1.0.0',
- 'baz': {
- 'path': d.path('baz'),
- },
- },
- 'environment': {'sdk': '>=2.9.0<3.0.0'},
- }),
- ]).create();
-
- await pubGet(environment: {
- '_PUB_TEST_SDK_VERSION': '2.10.0',
- });
-
- await pubUpgrade(
- args: ['--null-safety'],
- environment: {
- '_PUB_TEST_SDK_VERSION': '2.12.0',
- },
- output: allOf(
- contains('Changed 2 constraints in pubspec.yaml:'),
- contains('foo: ^1.0.0 -> ^2.0.0'),
- contains('bar: ^1.0.0 -> ^2.0.0-nullsafety.0'),
- ),
- warning: allOf(
- contains('Following direct \'dependencies\' and'),
- contains('\'dev_dependencies\' are not migrated to'),
- contains('null-safety yet:'),
- contains(' - baz'),
- ),
- );
- });
-
- test('cannot upgrade without null-safety versions', () async {
- await d.dir(appPath, [
- d.pubspec({
- 'name': 'myapp',
- 'dependencies': {
- 'foo': '^1.0.0',
- 'bar': '^1.0.0',
- 'baz': '^1.0.0',
- },
- 'environment': {'sdk': '>=2.9.0<3.0.0'},
- }),
- ]).create();
-
- await pubUpgrade(
- args: ['--null-safety'],
- environment: {
- '_PUB_TEST_SDK_VERSION': '2.12.0',
- },
- error: allOf(
- contains('null-safety compatible versions do not exist for:'),
- contains(' - baz'),
- contains('You can choose to upgrade only some dependencies'),
- contains('dart pub upgrade --nullsafety'),
- contains('https://dart.dev/null-safety/migration-guide'),
- ),
- );
- });
-
- test('can upgrade partially', () async {
- await d.dir(appPath, [
- d.pubspec({
- 'name': 'myapp',
- 'dependencies': {
- 'foo': '^1.0.0',
- 'bar': '^1.0.0',
- 'baz': '^1.0.0',
- },
- 'environment': {'sdk': '>=2.9.0<3.0.0'},
- }),
- ]).create();
-
- await pubUpgrade(
- args: ['--null-safety', 'bar', 'foo'],
- environment: {
- '_PUB_TEST_SDK_VERSION': '2.12.0',
- },
- output: allOf(
- contains('Changed 2 constraints in pubspec.yaml:'),
- contains('foo: ^1.0.0 -> ^2.0.0'),
- contains('bar: ^1.0.0 -> ^2.0.0-nullsafety.0'),
- ),
- warning: allOf(
- contains('Following direct \'dependencies\' and'),
- contains('\'dev_dependencies\' are not migrated to'),
- contains('null-safety yet:'),
- contains(' - baz'),
- ),
- );
-
- await d.dir(appPath, [
- d.pubspec({
- 'name': 'myapp',
- 'dependencies': {
- 'foo': '^2.0.0',
- 'bar': '^2.0.0-nullsafety.0',
- 'baz': '^1.0.0',
- },
- 'environment': {'sdk': '>=2.9.0<3.0.0'},
- }),
- d.packageConfigFile([
- d.packageConfigEntry(
- name: 'foo',
- version: '2.0.0',
- languageVersion: '2.12',
- ),
- d.packageConfigEntry(
- name: 'bar',
- version: '2.0.0-nullsafety.0',
- languageVersion: '2.12',
- ),
- d.packageConfigEntry(
- name: 'baz',
- version: '1.0.0',
- languageVersion: '2.9',
- ),
- d.packageConfigEntry(
- name: 'myapp',
- languageVersion: '2.9',
- path: '.',
- ),
- ], generatorVersion: '2.12.0'),
- ]).validate();
- });
-
- test('can fail to solve', () async {
- await d.dir(appPath, [
- d.pubspec({
- 'name': 'myapp',
- 'dependencies': {
- 'foo': '^1.0.0',
- 'bar': '^1.0.0',
- // This causes a SDK constraint conflict when migrating to
- // null-safety
- 'has_conflict': '^1.0.0',
- },
- 'environment': {'sdk': '>=2.9.0<3.0.0'},
- }),
- ]).create();
-
- await pubGet(environment: {
- '_PUB_TEST_SDK_VERSION': '2.10.0',
- });
-
- await pubUpgrade(
- args: ['--null-safety'],
- environment: {
- '_PUB_TEST_SDK_VERSION': '2.12.0',
- },
- error: allOf(
- contains('Because myapp depends on has_conflict >=2.0.0 which'),
- contains('requires SDK version >=2.13.0 <4.0.0,'),
- contains('version solving failed.'),
- ),
- );
- });
-
- test('works in 2.14.0', () async {
- await d.dir(appPath, [
- d.pubspec({
- 'name': 'myapp',
- 'dependencies': {
- 'foo': '^1.0.0',
- 'bar': '^1.0.0',
- // This requires SDK >= 2.13.0
- 'has_conflict': '^1.0.0',
- },
- 'environment': {'sdk': '>=2.9.0<3.0.0'},
- }),
- ]).create();
-
- await pubGet(environment: {
- '_PUB_TEST_SDK_VERSION': '2.10.0',
- });
-
- await pubUpgrade(
- args: ['--null-safety'],
- environment: {
- '_PUB_TEST_SDK_VERSION': '2.14.0',
- },
- output: allOf(
- contains('Changed 3 constraints in pubspec.yaml:'),
- contains('foo: ^1.0.0 -> ^2.0.0'),
- contains('bar: ^1.0.0 -> ^2.0.0-nullsafety.0'),
- contains('has_conflict: ^1.0.0 -> ^2.0.0'),
- ),
- );
- });
- });
-}
diff --git a/test/validator/null_safety_mixed_mode_test.dart b/test/validator/null_safety_mixed_mode_test.dart
deleted file mode 100644
index d62d051..0000000
--- a/test/validator/null_safety_mixed_mode_test.dart
+++ /dev/null
@@ -1,154 +0,0 @@
-// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-import 'package:test/test.dart';
-
-import '../descriptor.dart' as d;
-import '../test_pub.dart';
-
-Future<void> expectValidation(error, int exitCode) async {
- await runPub(
- error: error,
- args: ['publish', '--dry-run'],
- environment: {'_PUB_TEST_SDK_VERSION': '2.12.0'},
- workingDirectory: d.path(appPath),
- exitCode: exitCode,
- );
-}
-
-Future<void> setup({
- required String sdkConstraint,
- Map dependencies = const {},
- Map devDependencies = const {},
- List<d.Descriptor> extraFiles = const [],
-}) async {
- await d.validPackage.create();
- await d.dir(appPath, [
- d.pubspec({
- 'name': 'test_pkg',
- 'description':
- 'A just long enough decription to fit the requirement of 60 characters',
- 'homepage': 'https://example.com/',
- 'version': '1.0.0',
- 'environment': {'sdk': sdkConstraint},
- 'dependencies': dependencies,
- 'dev_dependencies': devDependencies,
- }),
- ...extraFiles,
- ]).create();
-
- await pubGet(environment: {'_PUB_TEST_SDK_VERSION': '2.12.0'});
-}
-
-void main() {
- group('should consider a package valid if it', () {
- test('is not opting in to null-safety, but depends on package that is',
- () async {
- final server = await servePackages();
- server.serve(
- 'foo',
- '0.0.1',
- pubspec: {
- 'environment': {'sdk': '>=2.12.0<3.0.0'}
- },
- );
-
- await setup(
- sdkConstraint: '>=2.9.0 <3.0.0', dependencies: {'foo': '^0.0.1'});
- await expectValidation(contains('Package has 0 warnings.'), 0);
- });
- test('is opting in to null-safety and depends on package that is',
- () async {
- final server = await servePackages();
- server.serve(
- 'foo',
- '0.0.1',
- pubspec: {
- 'environment': {'sdk': '>=2.12.0<3.0.0'}
- },
- );
-
- await setup(
- sdkConstraint: '>=2.12.0 <3.0.0', dependencies: {'foo': '^0.0.1'});
- await expectValidation(contains('Package has 0 warnings.'), 0);
- });
-
- test('is opting in to null-safety has dev_dependency that is not',
- () async {
- final server = await servePackages();
- server.serve(
- 'foo',
- '0.0.1',
- pubspec: {
- 'environment': {'sdk': '>=2.9.0<3.0.0'}
- },
- );
-
- await setup(sdkConstraint: '>=2.12.0 <3.0.0', devDependencies: {
- 'foo': '^0.0.1',
- });
- await expectValidation(contains('Package has 0 warnings.'), 0);
- });
- });
-
- group('should consider a package invalid if it', () {
- test('is opting in to null-safety, but depends on package that is not',
- () async {
- final server = await servePackages();
- server.serve(
- 'foo',
- '0.0.1',
- pubspec: {
- 'environment': {'sdk': '>=2.9.0<3.0.0'}
- },
- );
-
- await setup(
- sdkConstraint: '>=2.12.0 <3.0.0', dependencies: {'foo': '^0.0.1'});
- await expectValidation(
- allOf(
- contains(
- 'package:foo is not opted into null safety in its pubspec.yaml:'),
- contains('Package has 1 warning.'),
- ),
- 65);
- });
-
- test('is opting in to null-safety, but has file opting out', () async {
- await setup(sdkConstraint: '>=2.12.0 <3.0.0', extraFiles: [
- d.dir('lib', [d.file('a.dart', '// @dart = 2.9\n')])
- ]);
- await expectValidation(
- allOf(
- contains('package:test_pkg/a.dart is opting out of null safety:'),
- contains('Package has 1 warning.'),
- ),
- 65);
- });
-
- test(
- 'is opting in to null-safety, but depends on package has file opting out',
- () async {
- final server = await servePackages();
- server.serve('foo', '0.0.1', pubspec: {
- 'environment': {'sdk': '>=2.12.0<3.0.0'}
- }, contents: [
- d.dir('lib', [
- d.file('foo.dart', '''
-// @dart = 2.9
- ''')
- ])
- ]);
-
- await setup(
- sdkConstraint: '>=2.12.0 <3.0.0', dependencies: {'foo': '^0.0.1'});
- await expectValidation(
- allOf(
- contains('package:foo/foo.dart is opting out of null safety:'),
- contains('Package has 1 warning.'),
- ),
- 65);
- });
- });
-}