diff --git a/bricks/test_optimizer/hooks/lib/dart_identifier_generator.dart b/bricks/test_optimizer/hooks/lib/dart_identifier_generator.dart index 9ac5604bf..00792577c 100644 --- a/bricks/test_optimizer/hooks/lib/dart_identifier_generator.dart +++ b/bricks/test_optimizer/hooks/lib/dart_identifier_generator.dart @@ -7,9 +7,8 @@ /// {@endtemplate} class DartIdentifierGenerator { /// {@macro dart_identifier_generator} - DartIdentifierGenerator([ - this._chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', - ]) : _nextId = [0]; + new([this._chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ']) + : _nextId = [0]; final String _chars; final List _nextId; diff --git a/bricks/test_optimizer/hooks/pubspec.yaml b/bricks/test_optimizer/hooks/pubspec.yaml index 95d56302d..044aae9c9 100644 --- a/bricks/test_optimizer/hooks/pubspec.yaml +++ b/bricks/test_optimizer/hooks/pubspec.yaml @@ -13,4 +13,4 @@ dependencies: dev_dependencies: mocktail: ^1.0.0 test: ^1.25.0 - very_good_analysis: ^10.3.0 + very_good_analysis: ^11.0.0-rc.1 diff --git a/bricks/test_optimizer/hooks/test/pre_gen_test.dart b/bricks/test_optimizer/hooks/test/pre_gen_test.dart index 2e96591cf..67a2ccf19 100644 --- a/bricks/test_optimizer/hooks/test/pre_gen_test.dart +++ b/bricks/test_optimizer/hooks/test/pre_gen_test.dart @@ -6,7 +6,7 @@ import 'package:mocktail/mocktail.dart'; import 'package:path/path.dart' as path; import 'package:test/test.dart'; -class _MockLogger extends Mock implements Logger {} +class _MockLogger extends Mock implements Logger; class _FakeContext extends Fake implements HookContext { @override @@ -115,12 +115,10 @@ dependencies: File(path.join(testDir.path, 'test1_test.dart')).createSync(); File(path.join(testDir.path, 'test2_test.dart')).createSync(); File(path.join(testDir.path, 'no_test_here.dart')).createSync(); - File( - path.join(testDir.path, 'not_optimized_test.dart'), - ).writeAsStringSync(notOptimizedTestContent); - File( - path.join(testDir.path, 'another_not_optimized_test.dart'), - ).writeAsStringSync(anotherNotOptimizedTestContent); + File(path.join(testDir.path, 'not_optimized_test.dart')) + .writeAsStringSync(notOptimizedTestContent); + File(path.join(testDir.path, 'another_not_optimized_test.dart')) + .writeAsStringSync(anotherNotOptimizedTestContent); context.vars['package-root'] = tempDirectory.absolute.path; @@ -148,14 +146,8 @@ dependencies: ); final notOptimizedTests = context.vars['notOptimizedTests'] as List; - expect( - notOptimizedTests, - contains('not_optimized_test.dart'), - ); - expect( - notOptimizedTests, - contains('another_not_optimized_test.dart'), - ); + expect(notOptimizedTests, contains('not_optimized_test.dart')); + expect(notOptimizedTests, contains('another_not_optimized_test.dart')); }); }); diff --git a/e2e/helpers/command_helper.dart b/e2e/helpers/command_helper.dart index 8016e603b..ceb25ad3f 100644 --- a/e2e/helpers/command_helper.dart +++ b/e2e/helpers/command_helper.dart @@ -5,11 +5,11 @@ import 'package:mocktail/mocktail.dart'; import 'package:pub_updater/pub_updater.dart'; import 'package:very_good_cli/src/command_runner.dart'; -class _MockLogger extends Mock implements Logger {} +class _MockLogger extends Mock implements Logger; -class _MockProgress extends Mock implements Progress {} +class _MockProgress extends Mock implements Progress; -class _MockPubUpdater extends Mock implements PubUpdater {} +class _MockPubUpdater extends Mock implements PubUpdater; void Function() _overridePrint(void Function(List) fn) { return () { @@ -58,16 +58,9 @@ void Function() withRunner( currentVersion: any(named: 'currentVersion'), ), ).thenAnswer((_) => Future.value(true)); - when( - () => pubUpdater.getLatestVersion(any()), - ).thenAnswer((_) => Future.value('1.0.0')); + when(() => pubUpdater.getLatestVersion(any())) + .thenAnswer((_) => Future.value('1.0.0')); - await runnerFn( - commandRunner, - logger, - pubUpdater, - printLogs, - progressLogs, - ); + await runnerFn(commandRunner, logger, pubUpdater, printLogs, progressLogs); }); } diff --git a/e2e/pubspec.yaml b/e2e/pubspec.yaml index 40b3f55c2..9f3358211 100644 --- a/e2e/pubspec.yaml +++ b/e2e/pubspec.yaml @@ -13,6 +13,6 @@ dev_dependencies: pub_updater: ^0.5.0 test: ^1.25.0 universal_io: ^2.0.4 - very_good_analysis: ^10.3.0 + very_good_analysis: ^11.0.0-rc.1 very_good_cli: path: ../ diff --git a/e2e/test/commands/packages/check/licenses/unknown_licenses_test.dart b/e2e/test/commands/packages/check/licenses/unknown_licenses_test.dart index 9431f6f32..5c83e67cd 100644 --- a/e2e/test/commands/packages/check/licenses/unknown_licenses_test.dart +++ b/e2e/test/commands/packages/check/licenses/unknown_licenses_test.dart @@ -49,10 +49,7 @@ void main() { relativeProjectPath, ]); - expect( - result, - equals(ExitCode.success.code), - ); + expect(result, equals(ExitCode.success.code)); expect( progressLogs, diff --git a/e2e/test/commands/test/async_main/async_main_test.dart b/e2e/test/commands/test/async_main/async_main_test.dart index b29c30bf2..444cd89c8 100644 --- a/e2e/test/commands/test/async_main/async_main_test.dart +++ b/e2e/test/commands/test/async_main/async_main_test.dart @@ -22,11 +22,10 @@ void main() { await copyDirectory(fixture, tempDirectory); - await expectSuccessfulProcessResult( - 'flutter', - ['pub', 'get'], - workingDirectory: tempDirectory.path, - ); + await expectSuccessfulProcessResult('flutter', [ + 'pub', + 'get', + ], workingDirectory: tempDirectory.path); final cwd = Directory.current; Directory.current = tempDirectory; diff --git a/e2e/test/commands/test/compilation_error/compilation_error_test.dart b/e2e/test/commands/test/compilation_error/compilation_error_test.dart index 0c5b53b13..ebb7402d8 100644 --- a/e2e/test/commands/test/compilation_error/compilation_error_test.dart +++ b/e2e/test/commands/test/compilation_error/compilation_error_test.dart @@ -20,11 +20,10 @@ void main() { tempDirectory, ); - await expectSuccessfulProcessResult( - 'flutter', - ['pub', 'get'], - workingDirectory: tempDirectory.path, - ); + await expectSuccessfulProcessResult('flutter', [ + 'pub', + 'get', + ], workingDirectory: tempDirectory.path); final cwd = Directory.current; Directory.current = tempDirectory; @@ -34,9 +33,7 @@ void main() { expect(result, equals(ExitCode.unavailable.code)); verify( - () => logger.err( - any(that: contains('- test/.test_optimizer.dart')), - ), + () => logger.err(any(that: contains('- test/.test_optimizer.dart'))), ).called(1); }), ); diff --git a/e2e/test/commands/test/spaced_golden_file_name/spaced_golden_file_name_test.dart b/e2e/test/commands/test/spaced_golden_file_name/spaced_golden_file_name_test.dart index ee907f0c2..d8f7c4b98 100644 --- a/e2e/test/commands/test/spaced_golden_file_name/spaced_golden_file_name_test.dart +++ b/e2e/test/commands/test/spaced_golden_file_name/spaced_golden_file_name_test.dart @@ -18,17 +18,15 @@ void main() { tempDirectory, ); - await expectSuccessfulProcessResult( - 'flutter', - ['pub', 'get'], - workingDirectory: tempDirectory.path, - ); + await expectSuccessfulProcessResult('flutter', [ + 'pub', + 'get', + ], workingDirectory: tempDirectory.path); - await expectSuccessfulProcessResult( - 'flutter', - ['test', '--update-goldens'], - workingDirectory: tempDirectory.path, - ); + await expectSuccessfulProcessResult('flutter', [ + 'test', + '--update-goldens', + ], workingDirectory: tempDirectory.path); Directory.current = tempDirectory; final result = await commandRunner.run(['test']); diff --git a/e2e/test/commands/test/very_good_config/very_good_config_test.dart b/e2e/test/commands/test/very_good_config/very_good_config_test.dart index f4f0ba88a..ca54a49b0 100644 --- a/e2e/test/commands/test/very_good_config/very_good_config_test.dart +++ b/e2e/test/commands/test/very_good_config/very_good_config_test.dart @@ -73,12 +73,7 @@ void main() { addTearDown(() => Directory.current = cwd); await expectLater( - commandRunner.run([ - 'test', - '--coverage', - '--min-coverage', - '0', - ]), + commandRunner.run(['test', '--coverage', '--min-coverage', '0']), completion(equals(ExitCode.success.code)), ); }), diff --git a/lib/src/cli/cli.dart b/lib/src/cli/cli.dart index fc07e405b..6a4260a0b 100644 --- a/lib/src/cli/cli.dart +++ b/lib/src/cli/cli.dart @@ -65,7 +65,7 @@ abstract class ProcessOverrides { } class _ProcessOverridesScope extends ProcessOverrides { - _ProcessOverridesScope(this._runProcess); + new(this._runProcess); final ProcessOverrides? _previous = ProcessOverrides.current; final RunProcess? _runProcess; diff --git a/lib/src/cli/dart_cli.dart b/lib/src/cli/dart_cli.dart index b6ee3baa7..95f0bbba1 100644 --- a/lib/src/cli/dart_cli.dart +++ b/lib/src/cli/dart_cli.dart @@ -136,7 +136,7 @@ class Dart { void Function(String)? stderr, GeneratorBuilder buildGenerator = MasonGenerator.fromBundle, List? reportOn, - }) async { + }) { return TestCLIRunner.test( logger: logger, testType: TestRunType.dart, diff --git a/lib/src/cli/flutter_cli.dart b/lib/src/cli/flutter_cli.dart index 494d15015..26b9c93b0 100644 --- a/lib/src/cli/flutter_cli.dart +++ b/lib/src/cli/flutter_cli.dart @@ -43,7 +43,7 @@ abstract class ProcessSignalOverrides { } class _ProcessSignalOverridesScope extends ProcessSignalOverrides { - _ProcessSignalOverridesScope(Stream? mockSigintStream) { + new(Stream? mockSigintStream) { if (mockSigintStream != null) { _sigintStreamController = StreamController(); } @@ -56,7 +56,7 @@ class _ProcessSignalOverridesScope extends ProcessSignalOverrides { } /// Thrown when `flutter pub get` is executed without a `pubspec.yaml`. -class PubspecNotFound implements Exception {} +class PubspecNotFound implements Exception; /// {@template coverage_metrics} /// Aggregated coverage metrics computed from a list of LCOV records. @@ -64,17 +64,14 @@ class PubspecNotFound implements Exception {} class CoverageMetrics { /// {@macro coverage_metrics} @visibleForTesting - const CoverageMetrics({ + const new({ this.totalHits = 0, this.totalFound = 0, this.uncoveredLines = const {}, }); /// Generate coverage metrics from a list of lcov records. - factory CoverageMetrics.fromLcovRecords( - List records, { - String? excludeFromCoverage, - }) { + factory fromLcovRecords(List records, {String? excludeFromCoverage}) { final globs = []; if (excludeFromCoverage != null && excludeFromCoverage.isNotEmpty) { @@ -218,7 +215,7 @@ class Flutter { void Function(String)? stderr, GeneratorBuilder buildGenerator = MasonGenerator.fromBundle, List? reportOn, - }) async { + }) { return TestCLIRunner.test( logger: logger, testType: TestRunType.flutter, diff --git a/lib/src/cli/git_cli.dart b/lib/src/cli/git_cli.dart index 21f4d80cd..369d1001a 100644 --- a/lib/src/cli/git_cli.dart +++ b/lib/src/cli/git_cli.dart @@ -5,7 +5,7 @@ part of 'cli.dart'; /// {@endtemplate} class UnreachableGitDependency implements Exception { /// {@macro unreachable_git_dependency} - const UnreachableGitDependency({required this.remote}); + const new({required this.remote}); /// The associated git remote [Uri]. final Uri remote; diff --git a/lib/src/cli/templates/test_optimizer_bundle.dart b/lib/src/cli/templates/test_optimizer_bundle.dart index af7015c76..5a9a68acc 100644 --- a/lib/src/cli/templates/test_optimizer_bundle.dart +++ b/lib/src/cli/templates/test_optimizer_bundle.dart @@ -15,7 +15,7 @@ final testOptimizerBundle = MasonBundle.fromJson({ "hooks": [ { "path": "lib/dart_identifier_generator.dart", - "data": "Ly8vIHtAdGVtcGxhdGUgZGFydF9pZGVudGlmaWVyX2dlbmVyYXRvcn0KLy8vIEEgY2xhc3MgdGhhdCBnZW5lcmF0ZXMgdmFsaWQgRGFydCBpZGVudGlmaWVycy4KLy8vCi8vLyBTZWUgYWxzbzoKLy8vCi8vLyAqIFNlY3Rpb24gMTcuMzcgZnJvbSBbRGFydCBMYW5ndWFnZSBTcGVjaWZpY2F0aW9uXShodHRwczovL2RhcnQuZGV2L2d1aWRlcy9sYW5ndWFnZS9zcGVjaWZpY2F0aW9ucy9EYXJ0TGFuZ1NwZWMtdjIuMTAucGRmKQovLy8ge0BlbmR0ZW1wbGF0ZX0KY2xhc3MgRGFydElkZW50aWZpZXJHZW5lcmF0b3IgewogIC8vLyB7QG1hY3JvIGRhcnRfaWRlbnRpZmllcl9nZW5lcmF0b3J9CiAgRGFydElkZW50aWZpZXJHZW5lcmF0b3IoWwogICAgdGhpcy5fY2hhcnMgPSAnYWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXpBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWicsCiAgXSkgOiBfbmV4dElkID0gWzBdOwoKICBmaW5hbCBTdHJpbmcgX2NoYXJzOwogIGZpbmFsIExpc3Q8aW50PiBfbmV4dElkOwoKICAvLy8gR2VuZXJhdGUgdGhlIG5leHQgc2hvcnQgaWRlbnRp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bmFsIFN0cmluZyBfY2hhcnM7CiAgZmluYWwgTGlzdDxpbnQ+IF9uZXh0SWQ7CgogIC8vLyBHZW5lcmF0ZSB0aGUgbmV4dCBzaG9ydCBpZGVudGlmaWVyLgogIFN0cmluZyBuZXh0KCkgewogICAgZmluYWwgciA9IDxTdHJpbmc+WydfJywgZm9yIChmaW5hbCBjaGFyIGluIF9uZXh0SWQpIF9jaGFyc1tjaGFyXV07CiAgICBfaW5jcmVtZW50KCk7CiAgICByZXR1cm4gci5qb2luKCk7CiAgfQoKICB2b2lkIF9pbmNyZW1lbnQoKSB7CiAgICBmb3IgKHZhciBpID0gMDsgaSA8IF9uZXh0SWQubGVuZ3RoOyBpKyspIHsKICAgICAgZmluYWwgdmFsID0gKytfbmV4dElkW2ldOwogICAgICBpZiAodmFsID49IF9jaGFycy5sZW5ndGgpIHsKICAgICAgICBfbmV4dElkW2ldID0gMDsKICAgICAgfSBlbHNlIHsKICAgICAgICByZXR1cm47CiAgICAgIH0KICAgIH0KICAgIF9uZXh0SWQuYWRkKDApOwogIH0KfQo=", "type": "text", }, { @@ -30,7 +30,7 @@ final testOptimizerBundle = MasonBundle.fromJson({ }, { "path": "pubspec.yaml", - "data": "bmFtZTogaG9va3MKcHVibGlzaF90bzogbm9uZQoKZW52aXJvbm1lbnQ6CiAgc2RrOiBeMy4xMy4wCgpkZXBlbmRlbmNpZXM6CiAgbWFzb246IF4wLjEuMAogIHBhdGg6IF4xLjguMQoKIyBCZXdhcmU6IG9uIGhvb2tzLCBldmVuIGRldiBkZXBlbmRlbmNpZXMgaGF2ZSB0byBiZSBjb21wYXRpYmxlIHRvIGFsbCBkYXJ0IHZlcnNpb25zIGNvdmVyZWQgYnkKIyB0aGUgc2RrIGNvbnN0cmFpbnRzIGFib3ZlCmRldl9kZXBlbmRlbmNpZXM6CiAgbW9ja3RhaWw6IF4xLjAuMAogIHRlc3Q6IF4xLjI1LjAKICB2ZXJ5X2dvb2RfYW5hbHlzaXM6IF4xMC4zLjAK", + "data": "bmFtZTogaG9va3MKcHVibGlzaF90bzogbm9uZQoKZW52aXJvbm1lbnQ6CiAgc2RrOiBeMy4xMy4wCgpkZXBlbmRlbmNpZXM6CiAgbWFzb246IF4wLjEuMAogIHBhdGg6IF4xLjguMQoKIyBCZXdhcmU6IG9uIGhvb2tzLCBldmVuIGRldiBkZXBlbmRlbmNpZXMgaGF2ZSB0byBiZSBjb21wYXRpYmxlIHRvIGFsbCBkYXJ0IHZlcnNpb25zIGNvdmVyZWQgYnkKIyB0aGUgc2RrIGNvbnN0cmFpbnRzIGFib3ZlCmRldl9kZXBlbmRlbmNpZXM6CiAgbW9ja3RhaWw6IF4xLjAuMAogIHRlc3Q6IF4xLjI1LjAKICB2ZXJ5X2dvb2RfYW5hbHlzaXM6IF4xMS4wLjAtcmMuMQo=", "type": "text", }, { @@ -40,7 +40,7 @@ final testOptimizerBundle = MasonBundle.fromJson({ }, { "path": "test/pre_gen_test.dart", - "data": "aW1wb3J0ICdkYXJ0OmlvJzsKCmltcG9ydCAncGFja2FnZTpob29rcy9wcmVfZ2VuLmRhcnQnIGFzIHByZV9nZW47CmltcG9ydCAncGFja2FnZTptYXNvbi9tYXNvbi5kYXJ0JzsKaW1wb3J0ICdwYWNrYWdlOm1vY2t0YWlsL21vY2t0YWlsLmRhcnQnOwppbXBvcnQgJ3BhY2thZ2U6cGF0aC9wYXRoLmRhcnQnIGFzIHBhdGg7CmltcG9ydCAncGFja2FnZTp0ZXN0L3Rlc3QuZGFydCc7CgpjbGFzcyBfTW9ja0xvZ2dlciBleHRlbmRzIE1vY2sgaW1wbGVtZW50cyBMb2dnZXIge30KCmNsYXNzIF9GYWtlQ29udGV4dCBleHRlbmRzIEZha2UgaW1wbGVtZW50cyBIb29rQ29udGV4dCB7CiAgQG92ZXJyaWRlCiAgZmluYWwgbG9nZ2VyID0gX01vY2tMb2dnZXIoKTsKCiAgQG92ZXJyaWRlCiAgTWFwPFN0cmluZywgT2JqZWN0Pz4gdmFycyA9IHt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ucygndGVzdDJfdGVzdC5kYXJ0JykpOwogICAgICAgIGV4cGVjdChwYXRocywgaXNOb3QoY29udGFpbnMoJ25vX3Rlc3RfaGVyZS5kYXJ0JykpKTsKCiAgICAgICAgZXhwZWN0KAogICAgICAgICAgdGVzdHNNYXAudmFsdWVzLnRvU2V0KCkubGVuZ3RoLAogICAgICAgICAgZXF1YWxzKHRlc3RzLmxlbmd0aCksCiAgICAgICAgICByZWFzb246ICdBbGwgdGVzdHMgZmlsZXMgc2hvdWxkIGhhdmUgdW5pcXVlIGlkZW50aWZpZXJzJywKICAgICAgICApOwoKICAgICAgICBleHBlY3QoY29udGV4dC52YXJzWydpc0ZsdXR0ZXInXSwgZmFsc2UpOwogICAgICB9KTsKCiAgICAgIHRlc3QoJ3dpdGggcHJvcGVyIGlzRmx1dHRlciBpZGVudGlmaWNhdGlvbicsICgpIGFzeW5jIHsKICAgICAgICBGaWxlKHBhdGguam9pbih0ZW1wRGlyZWN0b3J5LnBhdGgsICdwdWJzcGVjLnlhbWwnKSkKICAgICAgICAgIC4uY3JlYXRlU3luYygpCiAgICAgICAgICAuLndyaXRlQXNTdHJpbmdTeW5jKCcnJwpkZXBlbmRlbmNpZXM6CiAgZmx1dHRlcjoKICAgIHNkazogZmx1dHRlcicnJyk7CgogICAgICAgIERpcmVjdG9yeShwYXRoLmpvaW4odGVtcERpcmVjdG9yeS5wYXRoLCAndGVzdCcpKS5jcmVhdGVTeW5jKCk7CgogICAgICAgIGNvbnRleHQudmFyc1sncGFja2FnZS1yb290J10gPSB0ZW1wRGlyZWN0b3J5LmFic29sdXRlLnBhdGg7CgogICAgICAgIGF3YWl0IHByZV9nZW4ucnVuKGNvbnRleHQpOwoKICAgICAgICBleHBlY3QoY29udGV4dC52YXJzWydpc0ZsdXR0ZXInXSwgdHJ1ZSk7CiAgICAgIH0pOwoKICAgICAgdGVzdCgnd2l0aCBwcm9wZXIgbm90IG9wdGltaXplZCB0ZXN0cyBpZGVudGlmaWNhdGlvbicsICgp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sIFN0cmluZz4+OwogICAgICAgIGZpbmFsIHRlc3RzTWFwID0gPFN0cmluZywgU3RyaW5nPnt9OwogICAgICAgIGZvciAoZmluYWwgdGVzdCBpbiB0ZXN0cykgewogICAgICAgICAgZmluYWwgcGF0aCA9IHRlc3RbJ3BhdGgnXSE7CiAgICAgICAgICBmaW5hbCBpZGVudGlmaWVyID0gdGVzdFsnaWRlbnRpZmllciddITsKICAgICAgICAgIHRlc3RzTWFwW3BhdGhdID0gaWRlbnRpZmllcjsKICAgICAgICB9CgogICAgICAgIGZpbmFsIHBhdGhzID0gdGVzdHNNYXAua2V5czsKICAgICAgICBleHBlY3QocGF0aHMsIGNvbnRhaW5zKCd0ZXN0MV90ZXN0LmRhcnQnKSk7CiAgICAgICAgZXhwZWN0KHBhdGhzLCBjb250YWlucygndGVzdDJfdGVzdC5kYXJ0JykpOwogICAgICAgIGV4cGVjdChwYXRocywgaXNOb3QoY29udGFpbnMoJ25vX3Rlc3RfaGVyZS5kYXJ0JykpKTsKICAgICAgICBleHBlY3QocGF0aHMsIGlzTm90KGNvbnRhaW5zKCdub3Rfb3B0aW1pemVkX3Rlc3QuZGFydCcpKSk7CiAgICAgICAgZXhwZWN0KHBhdGhzLCBpc05vdChjb250YWlucygnYW5vdGhlcl9ub3Rfb3B0aW1pemVkX3Rlc3QuZGFydCcpKSk7CgogICAgICAgIGV4cGVjdCgKICAgICAgICAgIHRlc3RzTWFwLnZhbHVlcy50b1NldCgpLmxlbmd0aCwKICAgICAgICAgIGVxdWFscyh0ZXN0cy5sZW5ndGgpLAogICAgICAgICAgcmVhc29uOiAnQWxsIHRlc3RzIGZpbGVzIHNob3VsZCBoYXZlIHVuaXF1ZSBpZGVudGlmaWVycycsCiAgICAgICAgKTsKICAgICAgICBmaW5hbCBub3RPcHRpbWl6ZWRUZXN0cyA9CiAgICAgICAgICAgIGNvbnRleHQudmFyc1snbm90T3B0aW1pemVkVGVzdHMnXSBhcyBMaXN0PFN0cmluZz47CiAgICAgICAgZXhwZWN0KAogICAgICAgICAgbm90T3B0aW1pemVkVGVzdHMsCiAgICAgICAgICBjb250YWlucygnbm90X29wdGltaXplZF90ZXN0LmRhcnQnKSwKICAgICAgICApOwogICAgICAgIGV4cGVjdCgKICAgICAgICAgIG5vdE9wdGltaXplZFRlc3RzLAogICAgICAgICAgY29udGFpbnMoJ2Fub3RoZXJfbm90X29wdGltaXplZF90ZXN0LmRhcnQnKSwKICAgICAgICApOwogICAgICB9KTsKICAgIH0pOwoKICAgIGdyb3VwKCdGYWlscycsICgpIHsKICAgICAgc2V0VXAoKCkgewogICAgICAgIHByZV9nZW4uZXhpdEZuID0gKGNvZGUpIHsKICAgICAgICAgIHRocm93IFByb2Nlc3NFeGNlcHRpb24oJ2V4aXQnLCBbY29kZS50b1N0cmluZygpXSk7CiAgICAgICAgfTsKICAgICAgfSk7CgogICAgICB0ZWFyRG93bigoKSB7CiAgICAgICAgcHJlX2dlbi5leGl0Rm4gPSBleGl0OwogICAgICB9KTsKCiAgICAgIHRlc3QoJ3doZW4gdGFyZ2V0IHRlc3QgZGlyIGRvZXMgbm90IGV4aXN0JywgKCkgYXN5bmMgewogICAgICAgIEZpbGUocGF0aC5qb2luKHRlbXBEaXJlY3RvcnkucGF0aCwgJ3B1YnNwZWMueWFtbCcpKS5jcmVhdGVTeW5jKCk7CgogICAgICAgIGZpbmFsIHRlc3REaXIgPSBEaXJlY3RvcnkocGF0aC5qb2luKHRlbXBEaXJlY3RvcnkucGF0aCwgJ3Rlc3QnKSk7CgogICAgICAgIGNvbnRleHQudmFyc1sncGFja2FnZS1yb290J10gPSB0ZW1wRGlyZWN0b3J5LmFic29sdXRlLnBhdGg7CgogICAgICAgIGF3YWl0IGV4cGVjdExhdGVyKAogICAgICAgICAgKCkgPT4gcHJlX2dlbi5ydW4oY29udGV4dCksCiAgICAgICAgICB0aHJvd3NBKAogICAgICAgICAgICBpc0E8UHJvY2Vzc0V4Y2VwdGlvbj4oKS5oYXZpbmcoCiAgICAgICAgIC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gICAgICgpID0+IHByZV9nZW4ucnVuKGNvbnRleHQpLAogICAgICAgICAgdGhyb3dzQSgKICAgICAgICAgICAgaXNBPFByb2Nlc3NFeGNlcHRpb24+KCkuaGF2aW5nKAogICAgICAgICAgICAgIChleCkgPT4gZXguYXJndW1lbnRzLmZpcnN0LAogICAgICAgICAgICAgICdlcnJvciBjb2RlJywKICAgICAgICAgICAgICBlcXVhbHMoJzEnKSwKICAgICAgICAgICAgKSwKICAgICAgICAgICksCiAgICAgICAgKTsKCiAgICAgICAgdmVyaWZ5KAogICAgICAgICAgKCkgPT4gY29udGV4dC5sb2dnZXIuZXJyKAogICAgICAgICAgICAnQ291bGQgbm90IGZpbmQgcHVic3BlYy55YW1sIGF0ICR7dGVzdERpci5wYXRofScsCiAgICAgICAgICApLAogICAgICAgICkuY2FsbGVkKDEpOwoKICAgICAgICBleHBlY3QoY29udGV4dC52YXJzWyd0ZXN0cyddLCBpc051bGwpOwogICAgICAgIGV4cGVjdChjb250ZXh0LnZhcnNbJ2lzRmx1dHRlciddLCBpc051bGwpOwogICAgICB9KTsKICAgIH0pOwoKICAgIGdyb3VwKCdza2lwVmVyeUdvb2RPcHRpbWl6YXRpb25SZWdFeHAgcmVnZXgnLCAoKSB7CiAgICAgIGZpbmFsIHJlZ2V4ID0gcHJlX2dlbi5za2lwVmVyeUdvb2RPcHRpbWl6YXRpb25SZWdFeHA7CiAgICAgIHRlc3QoJ21hdGNoZXMgc2luZ2xlLWxpbmUgdGFnJywgKCkgewogICAgICAgIGZpbmFsIGNvbnRlbnQgPSAiQFRhZ3MoWycke3ByZV9nZW4uc2tpcFZlcnlHb29kT3B0aW1pemF0aW9uVGFnfSddKSI7CiAgICAgICAgZXhwZWN0KHJlZ2V4Lmhhc01hdGNoKGNvbnRlbnQpLCBpc1RydWUpOwogICAgICB9KTsKCiAgICAgIHRlc3QoJ21hdGNoZXMgc2luZ2xlLWxpbmUgd2l0aCBtdWx0aXBsZSB0YWdzJywgKCkgewogICAgICAgIGZpbmFsIGNvbnRlbnQgPQogICAgICAgICAgICAiQFRhZ3MoWycke3ByZV9nZW4uc2tpcFZlcnlHb29kT3B0aW1pemF0aW9uVGFnfScsICdjaHJvbWUnXSkiOwogICAgICAgIGV4cGVjdChyZWdleC5oYXNNYXRjaChjb250ZW50KSwgaXNUcnVlKTsKICAgICAgfSk7CgogICAgICB0ZXN0KCdtYXRjaGVzIG11bHRpLWxpbmUgdGFnIGxpc3QnLCAoKSB7CiAgICAgICAgZmluYWwgY29udGVudCA9CiAgICAgICAgICAgICcnJwogICAgICBAVGFncyhbCiAgICAgICAgJyR7cHJlX2dlbi5za2lwVmVyeUdvb2RPcHRpbWl6YXRpb25UYWd9JywKICAgICAgICAnY2hyb21lJywKICAgICAgICAndGVzdCcsCiAgICAgIF0pCiAgICAgICcnJzsKICAgICAgICBleHBlY3QocmVnZXguaGFzTWF0Y2goY29udGVudCksIGlzVHJ1ZSk7CiAgICAgIH0pOwoKICAgICAgdGVzdCgnbWF0Y2hlcyBtdWx0aS1saW5lIHdoZXJlIHRhZyBpcyBub3QgdGhlIGZpcnN0JywgKCkgewogICAgICAgIGZpbmFsIGNvbnRlbnQgPQogICAgICAgICAgICAnJycKICAgICAgQFRhZ3MoWwogICAgICAgICdjaHJvbWUnLAogICAgICAgICcke3ByZV9nZW4uc2tpcFZlcnlHb29kT3B0aW1pemF0aW9uVGFnfScsCiAgICAgICAgJ3Rlc3QnLAogICAgICBdKQogICAgICAnJyc7CiAgICAgICAgZXhwZWN0KHJlZ2V4Lmhhc01hdGNoKGNvbnRlbnQpLCBpc1RydWUpOwogICAgICB9KTsKCiAgICAgIHRlc3QoJ2RvZXMgbm90IG1hdGNoIHdoZW4gdGFnIG1pc3NpbmcnLCAoKSB7CiAgICAgICAgY29uc3QgY29udGVudCA9ICJAVGFncyhbJ2Nocm9tZScsICd0ZXN0J10pIjsKICAgICAgICBleHBlY3QocmVnZXguaGFzTWF0Y2goY29udGVudCksIGlzRmFsc2UpOwogICAgICB9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DxTdHJpbmcsIFN0cmluZz4+OwogICAgICAgIGZpbmFsIHRlc3RzTWFwID0gPFN0cmluZywgU3RyaW5nPnt9OwogICAgICAgIGZvciAoZmluYWwgdGVzdCBpbiB0ZXN0cykgewogICAgICAgICAgZmluYWwgcGF0aCA9IHRlc3RbJ3BhdGgnXSE7CiAgICAgICAgICBmaW5hbCBpZGVudGlmaWVyID0gdGVzdFsnaWRlbnRpZmllciddITsKICAgICAgICAgIHRlc3RzTWFwW3BhdGhdID0gaWRlbnRpZmllcjsKICAgICAgICB9CgogICAgICAgIGZpbmFsIHBhdGhzID0gdGVzdHNNYXAua2V5czsKICAgICAgICBleHBlY3QocGF0aHMsIGNvbnRhaW5zKCd0ZXN0MV90ZXN0LmRhcnQnKSk7CiAgICAgICAgZXhwZWN0KHBhdGhzLCBjb250YWlucygndGVzdDJfdGVzdC5kYXJ0JykpOwogICAgICAgIGV4cGVjdChwYXRocywgaXNOb3QoY29udGFpbnMoJ25vX3Rlc3RfaGVyZS5kYXJ0JykpKTsKICAgICAgICBleHBlY3QocGF0aHMsIGlzTm90KGNvbnRhaW5zKCdub3Rfb3B0aW1pemVkX3Rlc3QuZGFydCcpKSk7CiAgICAgICAgZXhwZWN0KHBhdGhzLCBpc05vdChjb250YWlucygnYW5vdGhlcl9ub3Rfb3B0aW1pemVkX3Rlc3QuZGFydCcpKSk7CgogICAgICAgIGV4cGVjdCgKICAgICAgICAgIHRlc3RzTWFwLnZhbHVlcy50b1NldCgpLmxlbmd0aCwKICAgICAgICAgIGVxdWFscyh0ZXN0cy5sZW5ndGgpLAogICAgICAgICAgcmVhc29uOiAnQWxsIHRlc3RzIGZpbGVzIHNob3VsZCBoYXZlIHVuaXF1ZSBpZGVudGlmaWVycycsCiAgICAgICAgKTsKICAgICAgICBmaW5hbCBub3RPcHRpbWl6ZWRUZXN0cyA9CiAgICAgICAgICAgIGNvbnRleHQudmFyc1snbm90T3B0aW1pemVkVGVzdHMnXSBhcyBMaXN0PFN0cmluZz47CiAgICAgICAgZXhwZWN0KG5vdE9wdGltaXplZFRlc3RzLCBjb250YWlucygnbm90X29wdGltaXplZF90ZXN0LmRhcnQnKSk7CiAgICAgICAgZXhwZWN0KG5vdE9wdGltaXplZFRlc3RzLCBjb250YWlucygnYW5vdGhlcl9ub3Rfb3B0aW1pemVkX3Rlc3QuZGFydCcpKTsKICAgICAgfSk7CiAgICB9KTsKCiAgICBncm91cCgnRmFpbHMnLCAoKSB7CiAgICAgIHNldFVwKCgpIHsKICAgICAgICBwcmVfZ2VuLmV4aXRGbiA9IChjb2RlKSB7CiAgICAgICAgICB0aHJvdyBQcm9jZXNzRXhjZXB0aW9uKCdleGl0JywgW2NvZGUudG9TdHJpbmcoKV0pOwogICAgICAgIH07CiAgICAgIH0pOwoKICAgICAgdGVhckRvd24oKCkgewogICAgICAgIHByZV9nZW4uZXhpdEZuID0gZXhpdDsKICAgICAgfSk7CgogICAgICB0ZXN0KCd3aGVuIHRhcmdldCB0ZXN0IGRpciBkb2VzIG5vdCBleGlzdCcsICgpIGFzeW5jIHsKICAgICAgICBGaWxlKHBhdGguam9pbih0ZW1wRGlyZWN0b3J5LnBhdGgsICdwdWJzcGVjLnlhbWwnKSkuY3JlYXRlU3luYygpOwoKICAgICAgICBmaW5hbCB0ZXN0RGlyID0gRGlyZWN0b3J5KHBhdGguam9pbih0ZW1wRGlyZWN0b3J5LnBhdGgsICd0ZXN0JykpOwoKICAgICAgICBjb250ZXh0LnZhcnNbJ3BhY2thZ2Utcm9vdCddID0gdGVtcERpcmVjdG9yeS5hYnNvbHV0ZS5wYXRoOwoKICAgICAgICBhd2FpdCBleHBlY3RMYXRlcigKICAgICAgICAgICgpID0+IHByZV9nZW4ucnVuKGNvbnRleHQpLAogICAgICAgICAgdGhyb3dzQSgKICAgICAgICAgICAgaXNBPFByb2Nlc3NFeGNlcHRpb24+KCkuaGF2aW5nKAogICAgICAgICAgICAgIChleCkgPT4gZXguYXJndW1lbnRzLmZpcnN0LAogICAgICAgICAg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wKICAgICAgICAgIHRocm93c0EoCiAgICAgICAgICAgIGlzQTxQcm9jZXNzRXhjZXB0aW9uPigpLmhhdmluZygKICAgICAgICAgICAgICAoZXgpID0+IGV4LmFyZ3VtZW50cy5maXJzdCwKICAgICAgICAgICAgICAnZXJyb3IgY29kZScsCiAgICAgICAgICAgICAgZXF1YWxzKCcxJyksCiAgICAgICAgICAgICksCiAgICAgICAgICApLAogICAgICAgICk7CgogICAgICAgIHZlcmlmeSgKICAgICAgICAgICgpID0+IGNvbnRleHQubG9nZ2VyLmVycigKICAgICAgICAgICAgJ0NvdWxkIG5vdCBmaW5kIHB1YnNwZWMueWFtbCBhdCAke3Rlc3REaXIucGF0aH0nLAogICAgICAgICAgKSwKICAgICAgICApLmNhbGxlZCgxKTsKCiAgICAgICAgZXhwZWN0KGNvbnRleHQudmFyc1sndGVzdHMnXSwgaXNOdWxsKTsKICAgICAgICBleHBlY3QoY29udGV4dC52YXJzWydpc0ZsdXR0ZXInXSwgaXNOdWxsKTsKICAgICAgfSk7CiAgICB9KTsKCiAgICBncm91cCgnc2tpcFZlcnlHb29kT3B0aW1pemF0aW9uUmVnRXhwIHJlZ2V4JywgKCkgewogICAgICBmaW5hbCByZWdleCA9IHByZV9nZW4uc2tpcFZlcnlHb29kT3B0aW1pemF0aW9uUmVnRXhwOwogICAgICB0ZXN0KCdtYXRjaGVzIHNpbmdsZS1saW5lIHRhZycsICgpIHsKICAgICAgICBmaW5hbCBjb250ZW50ID0gIkBUYWdzKFsnJHtwcmVfZ2VuLnNraXBWZXJ5R29vZE9wdGltaXphdGlvblRhZ30nXSkiOwogICAgICAgIGV4cGVjdChyZWdleC5oYXNNYXRjaChjb250ZW50KSwgaXNUcnVlKTsKICAgICAgfSk7CgogICAgICB0ZXN0KCdtYXRjaGVzIHNpbmdsZS1saW5lIHdpdGggbXVsdGlwbGUgdGFncycsICgpIHsKICAgICAgICBmaW5hbCBjb250ZW50ID0KICAgICAgICAgICAgIkBUYWdzKFsnJHtwcmVfZ2VuLnNraXBWZXJ5R29vZE9wdGltaXphdGlvblRhZ30nLCAnY2hyb21lJ10pIjsKICAgICAgICBleHBlY3QocmVnZXguaGFzTWF0Y2goY29udGVudCksIGlzVHJ1ZSk7CiAgICAgIH0pOwoKICAgICAgdGVzdCgnbWF0Y2hlcyBtdWx0aS1saW5lIHRhZyBsaXN0JywgKCkgewogICAgICAgIGZpbmFsIGNvbnRlbnQgPQogICAgICAgICAgICAnJycKICAgICAgQFRhZ3MoWwogICAgICAgICcke3ByZV9nZW4uc2tpcFZlcnlHb29kT3B0aW1pemF0aW9uVGFnfScsCiAgICAgICAgJ2Nocm9tZScsCiAgICAgICAgJ3Rlc3QnLAogICAgICBdKQogICAgICAnJyc7CiAgICAgICAgZXhwZWN0KHJlZ2V4Lmhhc01hdGNoKGNvbnRlbnQpLCBpc1RydWUpOwogICAgICB9KTsKCiAgICAgIHRlc3QoJ21hdGNoZXMgbXVsdGktbGluZSB3aGVyZSB0YWcgaXMgbm90IHRoZSBmaXJzdCcsICgpIHsKICAgICAgICBmaW5hbCBjb250ZW50ID0KICAgICAgICAgICAgJycnCiAgICAgIEBUYWdzKFsKICAgICAgICAnY2hyb21lJywKICAgICAgICAnJHtwcmVfZ2VuLnNraXBWZXJ5R29vZE9wdGltaXphdGlvblRhZ30nLAogICAgICAgICd0ZXN0JywKICAgICAgXSkKICAgICAgJycnOwogICAgICAgIGV4cGVjdChyZWdleC5oYXNNYXRjaChjb250ZW50KSwgaXNUcnVlKTsKICAgICAgfSk7CgogICAgICB0ZXN0KCdkb2VzIG5vdCBtYXRjaCB3aGVuIHRhZyBtaXNzaW5nJywgKCkgewogICAgICAgIGNvbnN0IGNvbnRlbnQgPSAiQFRhZ3MoWydjaHJvbWUnLCAndGVzdCddKSI7CiAgICAgICAgZXhwZWN0KHJlZ2V4Lmhhc01hdGNoKGNvbnRlbnQpLCBpc0ZhbHNlKTsKICAgICAgfSk7CgogICAgICB0ZXN0KAogICAgICAgICdkb2VzIG5vdCBtYXRjaCBzdWJzdHJpbmcgb25seSAoZS5nLiBza2lwX3ZlcnlfZ29vZF9vcHRpbWl6YXRpb24sdGVzdCknLAogICAgICAgICgpIHsKICAgICAgICAgIGZpbmFsIGNvbnRlbnQgPQogICAgICAgICAgICAgICcnJwogICAgICBAVGFncyhbCiAgICAgICAgJyR7cHJlX2dlbi5za2lwVmVyeUdvb2RPcHRpbWl6YXRpb25UYWd9LHRlc3QnLAogICAgICAgICdjaHJvbWUnLAogICAgICBdKQogICAgICAnJyc7CiAgICAgICAgICBleHBlY3QoCiAgICAgICAgICAgIHJlZ2V4Lmhhc01hdGNoKGNvbnRlbnQpLAogICAgICAgICAgICBpc0ZhbHNlLAogICAgICAgICAgKTsgLy8gb25seSBleGFjdCB0YWcgc2hvdWxkIG1hdGNoCiAgICAgICAgfSwKICAgICAgKTsKICAgIH0pOwogIH0pOwp9Cg==", "type": "text", }, ], diff --git a/lib/src/cli/test_cli_runner.dart b/lib/src/cli/test_cli_runner.dart index 3d6c42c06..370cf0ede 100644 --- a/lib/src/cli/test_cli_runner.dart +++ b/lib/src/cli/test_cli_runner.dart @@ -44,7 +44,7 @@ typedef GeneratorBuilder = Future Function(MasonBundle); /// {@endtemplate} class MinCoverageNotMet implements Exception { /// {@macro coverage_not_met} - const MinCoverageNotMet(this.coverage, {this.uncoveredLines}); + const new(this.coverage, {this.uncoveredLines}); /// The measured coverage percentage (total hits / total found * 100). final double coverage; @@ -104,7 +104,7 @@ class TestCLIRunner { List? reportOn, bool checkIgnore = false, @visibleForTesting VeryGoodTestRunner? overrideTestRunner, - }) async { + }) { final initialCwd = cwd; final testRunner = @@ -162,7 +162,7 @@ class TestCLIRunner { final notOptimizedTests = vars['notOptimizedTests'] as List? ?? []; - return _overrideAnsiOutput( + return await _overrideAnsiOutput( forceAnsi, () => _testCommand( diff --git a/lib/src/command_runner.dart b/lib/src/command_runner.dart index 86d090b4f..85f8cf1e2 100644 --- a/lib/src/command_runner.dart +++ b/lib/src/command_runner.dart @@ -19,7 +19,7 @@ const packageName = 'very_good_cli'; /// {@endtemplate} class VeryGoodCommandRunner extends CompletionCommandRunner { /// {@macro very_good_command_runner} - VeryGoodCommandRunner({ + new({ Logger? logger, PubUpdater? pubUpdater, Map? environment, diff --git a/lib/src/commands/create/commands/app_ui_package.dart b/lib/src/commands/create/commands/app_ui_package.dart index ed927ad90..cab16c17a 100644 --- a/lib/src/commands/create/commands/app_ui_package.dart +++ b/lib/src/commands/create/commands/app_ui_package.dart @@ -6,10 +6,7 @@ import 'package:very_good_cli/src/commands/create/templates/templates.dart'; /// {@endtemplate} class CreateAppUiPackage extends CreateSubCommand with Publishable, Workspace { /// {@macro very_good_create_app_ui_package_command} - CreateAppUiPackage({ - required super.logger, - required super.generatorFromBundle, - }); + new({required super.logger, required super.generatorFromBundle}); @override String get name => 'app_ui_package'; diff --git a/lib/src/commands/create/commands/create_subcommand.dart b/lib/src/commands/create/commands/create_subcommand.dart index 9e8da3ea7..119ead66f 100644 --- a/lib/src/commands/create/commands/create_subcommand.dart +++ b/lib/src/commands/create/commands/create_subcommand.dart @@ -48,7 +48,7 @@ typedef MasonGeneratorFromBundle = Future Function(MasonBundle); /// [Workspace]. abstract class CreateSubCommand extends Command { /// {@macro create_subcommand} - CreateSubCommand({ + new({ required this.logger, @visibleForTesting required MasonGeneratorFromBundle? generatorFromBundle, }) : _generatorFromBundle = generatorFromBundle ?? MasonGenerator.fromBundle { @@ -353,9 +353,7 @@ mixin MultiTemplates on CreateSubCommand { final source = argResults.wasParsed('template') ? 'option "--template"' : 'the `create.template` key in `$veryGoodConfigFileName`'; - usageException( - '"$templateName" is not an allowed value for $source.', - ); + usageException('"$templateName" is not an allowed value for $source.'); }, ); } diff --git a/lib/src/commands/create/commands/dart_cli.dart b/lib/src/commands/create/commands/dart_cli.dart index 02f60d75b..32ec514b9 100644 --- a/lib/src/commands/create/commands/dart_cli.dart +++ b/lib/src/commands/create/commands/dart_cli.dart @@ -6,7 +6,7 @@ import 'package:very_good_cli/src/commands/create/templates/templates.dart'; /// {@endtemplate} class CreateDartCLI extends CreateSubCommand with Publishable, Workspace { /// {@macro very_good_create_dart_cli_command} - CreateDartCLI({required super.logger, required super.generatorFromBundle}) { + new({required super.logger, required super.generatorFromBundle}) { argParser.addOption( 'executable-name', help: 'The CLI executable name (defaults to the project name)', diff --git a/lib/src/commands/create/commands/dart_package.dart b/lib/src/commands/create/commands/dart_package.dart index a06499487..fc5b86f60 100644 --- a/lib/src/commands/create/commands/dart_package.dart +++ b/lib/src/commands/create/commands/dart_package.dart @@ -6,10 +6,7 @@ import 'package:very_good_cli/src/commands/create/templates/templates.dart'; /// {@endtemplate} class CreateDartPackage extends CreateSubCommand with Publishable, Workspace { /// {@macro very_good_create_dart_package_command} - CreateDartPackage({ - required super.logger, - required super.generatorFromBundle, - }); + new({required super.logger, required super.generatorFromBundle}); @override String get name => 'dart_package'; diff --git a/lib/src/commands/create/commands/docs_site.dart b/lib/src/commands/create/commands/docs_site.dart index 3a1e7b8aa..31b79a847 100644 --- a/lib/src/commands/create/commands/docs_site.dart +++ b/lib/src/commands/create/commands/docs_site.dart @@ -7,7 +7,7 @@ import 'package:very_good_cli/src/very_good_config/very_good_config.dart'; /// {@endtemplate} class CreateDocsSite extends CreateSubCommand with Publishable { /// {@macro very_good_create_docs_site} - CreateDocsSite({required super.logger, required super.generatorFromBundle}) { + new({required super.logger, required super.generatorFromBundle}) { argParser.addOption( 'org-name', help: 'The organization for this new project.', diff --git a/lib/src/commands/create/commands/flame_game.dart b/lib/src/commands/create/commands/flame_game.dart index e881913d6..d6731791a 100644 --- a/lib/src/commands/create/commands/flame_game.dart +++ b/lib/src/commands/create/commands/flame_game.dart @@ -7,7 +7,7 @@ import 'package:very_good_cli/src/commands/create/templates/templates.dart'; class CreateFlameGame extends CreateSubCommand with OrgName, Publishable, Workspace { /// {@macro very_good_create_flame_game_command} - CreateFlameGame({required super.logger, required super.generatorFromBundle}) { + new({required super.logger, required super.generatorFromBundle}) { argParser.addMultiOption( 'platforms', help: diff --git a/lib/src/commands/create/commands/flutter_app.dart b/lib/src/commands/create/commands/flutter_app.dart index 7819f46f3..226754f2f 100644 --- a/lib/src/commands/create/commands/flutter_app.dart +++ b/lib/src/commands/create/commands/flutter_app.dart @@ -7,10 +7,7 @@ import 'package:very_good_cli/src/commands/create/templates/templates.dart'; class CreateFlutterApp extends CreateSubCommand with OrgName, MultiTemplates, Publishable, Workspace { /// {@macro very_good_create_flutter_app_command} - CreateFlutterApp({ - required super.logger, - required super.generatorFromBundle, - }) { + new({required super.logger, required super.generatorFromBundle}) { argParser ..addOption( 'application-id', diff --git a/lib/src/commands/create/commands/flutter_package.dart b/lib/src/commands/create/commands/flutter_package.dart index b2342110c..2e65db1dd 100644 --- a/lib/src/commands/create/commands/flutter_package.dart +++ b/lib/src/commands/create/commands/flutter_package.dart @@ -7,10 +7,7 @@ import 'package:very_good_cli/src/commands/create/templates/templates.dart'; class CreateFlutterPackage extends CreateSubCommand with Publishable, Workspace { /// {@macro very_good_create_flutter_package_command} - CreateFlutterPackage({ - required super.logger, - required super.generatorFromBundle, - }); + new({required super.logger, required super.generatorFromBundle}); @override String get name => 'flutter_package'; diff --git a/lib/src/commands/create/commands/flutter_plugin.dart b/lib/src/commands/create/commands/flutter_plugin.dart index 39bef9b89..d60dc0522 100644 --- a/lib/src/commands/create/commands/flutter_plugin.dart +++ b/lib/src/commands/create/commands/flutter_plugin.dart @@ -7,10 +7,7 @@ import 'package:very_good_cli/src/commands/create/templates/templates.dart'; class CreateFlutterPlugin extends CreateSubCommand with Publishable, OrgName, Workspace { /// {@macro very_good_create_flutter_plugin_command} - CreateFlutterPlugin({ - required super.logger, - required super.generatorFromBundle, - }) { + new({required super.logger, required super.generatorFromBundle}) { argParser.addMultiOption( 'platforms', help: diff --git a/lib/src/commands/create/create.dart b/lib/src/commands/create/create.dart index 657e39edf..73d8ae08c 100644 --- a/lib/src/commands/create/create.dart +++ b/lib/src/commands/create/create.dart @@ -11,7 +11,7 @@ import 'package:very_good_cli/src/commands/create/commands/commands.dart'; /// - [CreateSubCommand] for the base class for all create subcommands. class CreateCommand extends Command { /// {@macro create_command} - CreateCommand({ + new({ required Logger logger, @visibleForTesting MasonGeneratorFromBundle? generatorFromBundle, }) { diff --git a/lib/src/commands/create/templates/post_generate_actions.dart b/lib/src/commands/create/templates/post_generate_actions.dart index f2614d94a..7cb394e4e 100644 --- a/lib/src/commands/create/templates/post_generate_actions.dart +++ b/lib/src/commands/create/templates/post_generate_actions.dart @@ -14,7 +14,11 @@ Future installDartPackages( final isDartInstalled = await Dart.installed(logger: logger); if (!isDartInstalled) return false; - return Dart.pubGet(cwd: outputDir.path, recursive: recursive, logger: logger); + return await Dart.pubGet( + cwd: outputDir.path, + recursive: recursive, + logger: logger, + ); } /// Runs `flutter pub get` in the [outputDir]. @@ -28,7 +32,7 @@ Future installFlutterPackages( final isFlutterInstalled = await Flutter.installed(logger: logger); if (!isFlutterInstalled) return false; - return Flutter.pubGet( + return await Flutter.pubGet( cwd: outputDir.path, recursive: recursive, logger: logger, diff --git a/lib/src/commands/create/templates/template.dart b/lib/src/commands/create/templates/template.dart index bf99c4306..48f5d9a02 100644 --- a/lib/src/commands/create/templates/template.dart +++ b/lib/src/commands/create/templates/template.dart @@ -8,11 +8,7 @@ import 'package:universal_io/io.dart'; /// {@endtemplate} abstract class Template { /// {@macro template} - const Template({ - required this.name, - required this.bundle, - required this.help, - }); + const new({required this.name, required this.bundle, required this.help}); /// The name associated with this template. final String name; diff --git a/lib/src/commands/create/templates/very_good_app_ui/very_good_app_ui_template.dart b/lib/src/commands/create/templates/very_good_app_ui/very_good_app_ui_template.dart index 9d88950a0..0851121c0 100644 --- a/lib/src/commands/create/templates/very_good_app_ui/very_good_app_ui_template.dart +++ b/lib/src/commands/create/templates/very_good_app_ui/very_good_app_ui_template.dart @@ -8,7 +8,7 @@ import 'package:very_good_cli/src/logger_extension.dart'; /// {@endtemplate} class AppUiTemplate extends Template { /// {@macro app_ui_template} - AppUiTemplate() + new() : super( name: 'app_ui', bundle: veryGoodAppUiBundle, diff --git a/lib/src/commands/create/templates/very_good_core/very_good_core_template.dart b/lib/src/commands/create/templates/very_good_core/very_good_core_template.dart index 5eca94fd0..70a27cb07 100644 --- a/lib/src/commands/create/templates/very_good_core/very_good_core_template.dart +++ b/lib/src/commands/create/templates/very_good_core/very_good_core_template.dart @@ -9,7 +9,7 @@ import 'package:very_good_cli/src/logger_extension.dart'; /// {@endtemplate} class VeryGoodCoreTemplate extends Template { /// {@macro very_good_core_template} - VeryGoodCoreTemplate() + new() : super( name: 'core', bundle: veryGoodCoreBundle, diff --git a/lib/src/commands/create/templates/very_good_dart_cli/very_good_dart_cli_template.dart b/lib/src/commands/create/templates/very_good_dart_cli/very_good_dart_cli_template.dart index dc66882bd..be0f01509 100644 --- a/lib/src/commands/create/templates/very_good_dart_cli/very_good_dart_cli_template.dart +++ b/lib/src/commands/create/templates/very_good_dart_cli/very_good_dart_cli_template.dart @@ -9,7 +9,7 @@ import 'package:very_good_cli/src/logger_extension.dart'; /// {@endtemplate} class VeryGoodDartCLITemplate extends Template { /// {@macro dart_cli_template} - VeryGoodDartCLITemplate() + new() : super( name: 'dart_cli', bundle: veryGoodDartCliBundle, diff --git a/lib/src/commands/create/templates/very_good_dart_package/very_good_dart_package_template.dart b/lib/src/commands/create/templates/very_good_dart_package/very_good_dart_package_template.dart index b56bb9fce..e0a2a9c21 100644 --- a/lib/src/commands/create/templates/very_good_dart_package/very_good_dart_package_template.dart +++ b/lib/src/commands/create/templates/very_good_dart_package/very_good_dart_package_template.dart @@ -8,7 +8,7 @@ import 'package:very_good_cli/src/logger_extension.dart'; /// {@endtemplate} class DartPkgTemplate extends Template { /// {@macro dart_pkg_template} - DartPkgTemplate() + new() : super( name: 'dart_pkg', bundle: veryGoodDartPackageBundle, diff --git a/lib/src/commands/create/templates/very_good_docs_site/very_good_docs_site_template.dart b/lib/src/commands/create/templates/very_good_docs_site/very_good_docs_site_template.dart index 416c226fb..50ab017cd 100644 --- a/lib/src/commands/create/templates/very_good_docs_site/very_good_docs_site_template.dart +++ b/lib/src/commands/create/templates/very_good_docs_site/very_good_docs_site_template.dart @@ -9,7 +9,7 @@ import 'package:very_good_cli/src/logger_extension.dart'; /// {@endtemplate} class VeryGoodDocsSiteTemplate extends Template { /// {@macro docs_site_template} - VeryGoodDocsSiteTemplate() + new() : super( name: 'docs_site', bundle: veryGoodDocsSiteBundle, diff --git a/lib/src/commands/create/templates/very_good_flame_game/very_good_flame_game_template.dart b/lib/src/commands/create/templates/very_good_flame_game/very_good_flame_game_template.dart index 1f17999a7..8d6dad988 100644 --- a/lib/src/commands/create/templates/very_good_flame_game/very_good_flame_game_template.dart +++ b/lib/src/commands/create/templates/very_good_flame_game/very_good_flame_game_template.dart @@ -9,7 +9,7 @@ import 'package:very_good_cli/src/logger_extension.dart'; /// {@endtemplate} class VeryGoodFlameGameTemplate extends Template { /// {@macro flame_game_template} - VeryGoodFlameGameTemplate() + new() : super( name: 'flame_game', bundle: veryGoodFlameGameBundle, diff --git a/lib/src/commands/create/templates/very_good_flutter_package/very_good_flutter_package_template.dart b/lib/src/commands/create/templates/very_good_flutter_package/very_good_flutter_package_template.dart index 709adeb6d..f89d1d925 100644 --- a/lib/src/commands/create/templates/very_good_flutter_package/very_good_flutter_package_template.dart +++ b/lib/src/commands/create/templates/very_good_flutter_package/very_good_flutter_package_template.dart @@ -8,7 +8,7 @@ import 'package:very_good_cli/src/logger_extension.dart'; /// {@endtemplate} class FlutterPkgTemplate extends Template { /// {@macro flutter_pkg_template} - FlutterPkgTemplate() + new() : super( name: 'flutter_pkg', bundle: veryGoodFlutterPackageBundle, diff --git a/lib/src/commands/create/templates/very_good_flutter_plugin/very_good_flutter_plugin_template.dart b/lib/src/commands/create/templates/very_good_flutter_plugin/very_good_flutter_plugin_template.dart index e98c7a3b1..a0e556747 100644 --- a/lib/src/commands/create/templates/very_good_flutter_plugin/very_good_flutter_plugin_template.dart +++ b/lib/src/commands/create/templates/very_good_flutter_plugin/very_good_flutter_plugin_template.dart @@ -8,7 +8,7 @@ import 'package:very_good_cli/src/logger_extension.dart'; /// {@endtemplate} class FlutterPluginTemplate extends Template { /// {@macro flutter_pkg_template} - FlutterPluginTemplate() + new() : super( name: 'flutter_plugin', bundle: veryGoodFlutterPluginBundle, diff --git a/lib/src/commands/dart/commands/dart_test_command.dart b/lib/src/commands/dart/commands/dart_test_command.dart index b5dabf9ae..8f22b4167 100644 --- a/lib/src/commands/dart/commands/dart_test_command.dart +++ b/lib/src/commands/dart/commands/dart_test_command.dart @@ -11,7 +11,7 @@ import 'package:very_good_cli/src/very_good_config/very_good_config.dart'; /// Options for configuring the Dart test command. class DartTestOptions { - DartTestOptions._({ + new _({ required this.concurrency, required this.collectCoverage, required this.minCoverage, @@ -36,7 +36,7 @@ class DartTestOptions { /// /// When [config] is provided, its values are used as defaults for any /// option that was not explicitly parsed on the command line. - factory DartTestOptions.parse( + factory parse( ArgResults argResults, { VeryGoodConfig config = VeryGoodConfig.empty, }) { @@ -211,7 +211,7 @@ typedef DartTestCommandCall = Future> Function({ /// {@endtemplate} class DartTestCommand extends Command { /// {@macro packages_command} - DartTestCommand({ + new({ required this._logger, DartTestCommandCall? dartTest, DartInstalledCommand? dartInstalled, diff --git a/lib/src/commands/dart/dart.dart b/lib/src/commands/dart/dart.dart index 3f75faf56..1fb0b51c6 100644 --- a/lib/src/commands/dart/dart.dart +++ b/lib/src/commands/dart/dart.dart @@ -7,7 +7,7 @@ import 'package:very_good_cli/src/commands/dart/commands/commands.dart'; /// {@endtemplate} class DartCommand extends Command { /// {@macro packages_command} - DartCommand({required Logger logger}) { + new({required Logger logger}) { addSubcommand(DartTestCommand(logger: logger)); } diff --git a/lib/src/commands/packages/commands/check/check.dart b/lib/src/commands/packages/commands/check/check.dart index 9c4877309..afca261a8 100644 --- a/lib/src/commands/packages/commands/check/check.dart +++ b/lib/src/commands/packages/commands/check/check.dart @@ -8,7 +8,7 @@ import 'package:very_good_cli/src/commands/packages/commands/check/commands/comm /// {@endtemplate} class PackagesCheckCommand extends Command { /// {@macro packages_check_command} - PackagesCheckCommand({Logger? logger}) { + new({Logger? logger}) { addSubcommand(PackagesCheckLicensesCommand(logger: logger)); } diff --git a/lib/src/commands/packages/commands/check/commands/licenses.dart b/lib/src/commands/packages/commands/check/commands/licenses.dart index 2e8d5f74b..7499512ae 100644 --- a/lib/src/commands/packages/commands/check/commands/licenses.dart +++ b/lib/src/commands/packages/commands/check/commands/licenses.dart @@ -78,7 +78,7 @@ typedef _BannedDependencyLicenseMap = Map>; /// Options for configuring the `very_good packages check licenses` command. class PackagesCheckLicensesOptions { - PackagesCheckLicensesOptions._({ + new _({ required this.ignoreRetrievalFailures, required this.dependencyTypes, required this.allowedLicenses, @@ -91,7 +91,7 @@ class PackagesCheckLicensesOptions { /// /// When [config] is provided, its values are used as defaults for any /// option that was not explicitly parsed on the command line. - factory PackagesCheckLicensesOptions.parse( + factory parse( ArgResults argResults, { VeryGoodConfig config = VeryGoodConfig.empty, }) { @@ -156,8 +156,7 @@ class PackagesCheckLicensesOptions { /// {@endtemplate} class PackagesCheckLicensesCommand extends Command { /// {@macro packages_check_licenses_command} - PackagesCheckLicensesCommand({Logger? logger}) - : _logger = logger ?? Logger() { + new({Logger? logger}) : _logger = logger ?? Logger() { argParser ..addFlag( 'ignore-retrieval-failures', diff --git a/lib/src/commands/packages/commands/get.dart b/lib/src/commands/packages/commands/get.dart index c44147e4c..a4e412659 100644 --- a/lib/src/commands/packages/commands/get.dart +++ b/lib/src/commands/packages/commands/get.dart @@ -9,13 +9,13 @@ import 'package:very_good_cli/src/very_good_config/very_good_config.dart'; /// Options for configuring the `very_good packages get` command. class PackagesGetOptions { - PackagesGetOptions._({required this.recursive, required this.ignore}); + new _({required this.recursive, required this.ignore}); /// Parses [ArgResults] into a [PackagesGetOptions] instance. /// /// When [config] is provided, its values are used as defaults for any /// option that was not explicitly parsed on the command line. - factory PackagesGetOptions.parse( + factory parse( ArgResults argResults, { VeryGoodConfig config = VeryGoodConfig.empty, }) { @@ -39,7 +39,7 @@ class PackagesGetOptions { /// {@endtemplate} class PackagesGetCommand extends Command { /// {@macro packages_get_command} - PackagesGetCommand({Logger? logger}) : _logger = logger ?? Logger() { + new({Logger? logger}) : _logger = logger ?? Logger() { argParser ..addFlag( 'recursive', diff --git a/lib/src/commands/packages/packages.dart b/lib/src/commands/packages/packages.dart index 7afeec600..a6de5c128 100644 --- a/lib/src/commands/packages/packages.dart +++ b/lib/src/commands/packages/packages.dart @@ -8,7 +8,7 @@ import 'package:very_good_cli/src/commands/packages/commands/commands.dart'; /// {@endtemplate} class PackagesCommand extends Command { /// {@macro packages_command} - PackagesCommand({Logger? logger}) { + new({Logger? logger}) { addSubcommand(PackagesGetCommand(logger: logger)); addSubcommand(PackagesCheckCommand(logger: logger)); } diff --git a/lib/src/commands/test/test.dart b/lib/src/commands/test/test.dart index ca565a4f9..2ddca8b39 100644 --- a/lib/src/commands/test/test.dart +++ b/lib/src/commands/test/test.dart @@ -11,7 +11,7 @@ import 'package:very_good_cli/src/very_good_config/very_good_config.dart'; /// Options for configuring the Flutter test command. class FlutterTestOptions { - FlutterTestOptions._({ + new _({ required this.concurrency, required this.collectCoverage, required this.minCoverage, @@ -40,7 +40,7 @@ class FlutterTestOptions { /// /// When [config] is provided, its values are used as defaults for any /// option that was not explicitly parsed on the command line. - factory FlutterTestOptions.parse( + factory parse( ArgResults argResults, { VeryGoodConfig config = VeryGoodConfig.empty, }) { @@ -251,7 +251,7 @@ typedef FlutterTestCommand = Future> Function({ /// {@endtemplate} class TestCommand extends Command { /// {@macro test_command} - TestCommand({ + new({ required this._logger, @visibleForTesting FlutterTestCommand? flutterTest, @visibleForTesting FlutterInstalledCommand? flutterInstalled, diff --git a/lib/src/commands/update.dart b/lib/src/commands/update.dart index 079bd3f7e..8c4d15a2b 100644 --- a/lib/src/commands/update.dart +++ b/lib/src/commands/update.dart @@ -11,7 +11,7 @@ import 'package:very_good_cli/src/version.dart'; /// {@endtemplate} class UpdateCommand extends Command { /// {@macro update_command} - UpdateCommand({required this._logger, PubUpdater? pubUpdater}) + new({required this._logger, PubUpdater? pubUpdater}) : _pubUpdater = pubUpdater ?? PubUpdater(); final Logger _logger; diff --git a/lib/src/mcp/mcp_command.dart b/lib/src/mcp/mcp_command.dart index 1f755981f..d80756637 100644 --- a/lib/src/mcp/mcp_command.dart +++ b/lib/src/mcp/mcp_command.dart @@ -26,7 +26,7 @@ StreamChannel _defaultChannelFactory() { /// {@endtemplate} class MCPCommand extends Command { /// {@macro mcp_command} - MCPCommand({ChannelFactory? channelFactory, ServerFactory? serverFactory}) + new({ChannelFactory? channelFactory, ServerFactory? serverFactory}) : _channelFactory = channelFactory ?? _defaultChannelFactory, _serverFactory = serverFactory ?? VeryGoodMCPServer.new; diff --git a/lib/src/mcp/mcp_server.dart b/lib/src/mcp/mcp_server.dart index 7b80a8125..3a95c46dd 100644 --- a/lib/src/mcp/mcp_server.dart +++ b/lib/src/mcp/mcp_server.dart @@ -40,7 +40,7 @@ VeryGoodCommandRunner defaultCommandRunnerBuilder({required Logger logger}) => /// {@endtemplate} final class VeryGoodMCPServer extends MCPServer with ToolsSupport { /// {@macro very_good_mcp_server} - VeryGoodMCPServer({ + new({ required StreamChannel channel, CommandRunnerBuilder? commandRunnerBuilder, }) : _commandRunnerBuilder = @@ -477,13 +477,13 @@ Only one value can be selected. return cliArgs; } - Future _handleCreate(CallToolRequest request) async { + Future _handleCreate(CallToolRequest request) { final args = request.arguments ?? {}; final cliArgs = _parseCreate(args); return _runToolCommand(cliArgs, toolName: 'create'); } - Future _handleTest(CallToolRequest request) async { + Future _handleTest(CallToolRequest request) { final args = request.arguments ?? {}; final cliArgs = _parseTest(args); return _runToolCommand( @@ -493,7 +493,7 @@ Only one value can be selected. ); } - Future _handlePackagesGet(CallToolRequest request) async { + Future _handlePackagesGet(CallToolRequest request) { final args = request.arguments ?? {}; final cliArgs = _parsePackagesGet(args); return _runToolCommand( @@ -503,7 +503,7 @@ Only one value can be selected. ); } - Future _handlePackagesCheck(CallToolRequest request) async { + Future _handlePackagesCheck(CallToolRequest request) { final args = request.arguments ?? {}; // Currently, 'packages check' only has 'licenses' as a subcommand @@ -511,15 +511,17 @@ Only one value can be selected. final checkLicenses = args['licenses'] as bool? ?? true; if (!checkLicenses) { - return CallToolResult( - content: [ - TextContent( - text: - 'No check specified. Currently only "licenses" check is ' - 'supported. Set licenses=true to run license checks.', - ), - ], - isError: true, + return Future.value( + CallToolResult( + content: [ + TextContent( + text: + 'No check specified. Currently only "licenses" check is ' + 'supported. Set licenses=true to run license checks.', + ), + ], + isError: true, + ), ); } @@ -639,7 +641,7 @@ Only one value can be selected. @visibleForTesting class CapturingStdout implements Stdout { /// Creates a [CapturingStdout] that appends all writes to [_buffer]. - CapturingStdout(this._buffer); + new(this._buffer); final StringBuffer _buffer; diff --git a/lib/src/pubspec/pubspec.dart b/lib/src/pubspec/pubspec.dart index 78150f7eb..22abbced5 100644 --- a/lib/src/pubspec/pubspec.dart +++ b/lib/src/pubspec/pubspec.dart @@ -48,12 +48,12 @@ enum PubspecDependencyType { /// * [Dart's dependency override documentation](https://dart.dev/tools/pub/dependencies#dependency-overrides) directOverridden._('direct overridden'); - const PubspecDependencyType._(this.value); + new _(this.value); /// Parses a [PubspecDependencyType] from its `pubspec.lock` textual form. /// /// Throws an [ArgumentError] if the string is not a valid dependency type. - factory PubspecDependencyType.parse(String value) { + factory parse(String value) { if (_valueMap.containsKey(value)) return _valueMap[value]!; throw ArgumentError.value( diff --git a/lib/src/pubspec_lock/pubspec_lock.dart b/lib/src/pubspec_lock/pubspec_lock.dart index 4f30d8c9a..d90c2eeea 100644 --- a/lib/src/pubspec_lock/pubspec_lock.dart +++ b/lib/src/pubspec_lock/pubspec_lock.dart @@ -17,14 +17,14 @@ import 'package:yaml/yaml.dart'; /// {@endtemplate} class PubspecLockParseException implements Exception { /// {@macro PubspecLockParseException} - const PubspecLockParseException(); + const new(); } /// {@template PubspecLock} /// A representation of a pubspec.lock file. /// {@endtemplate} class PubspecLock { - const PubspecLock._({required this.packages}); + const new _({required this.packages}); /// Parses a [PubspecLock] from a string. /// @@ -33,7 +33,7 @@ class PubspecLock { /// /// It throws a [PubspecLockParseException] if the string cannot be parsed /// as a [YamlMap]. - factory PubspecLock.fromString(String content) { + factory fromString(String content) { late final YamlMap yaml; try { yaml = loadYaml(content) as YamlMap; @@ -77,17 +77,14 @@ class PubspecLock { /// {@endtemplate} class PubspecLockPackage extends Equatable { /// {@macro PubspecLockDependency} - const PubspecLockPackage({ + const new({ required this.name, required this.type, required this.isPubHosted, }); /// Parses a [PubspecLockPackage] from a [YamlMap]. - factory PubspecLockPackage.fromYamlMap({ - required String name, - required YamlMap data, - }) { + factory fromYamlMap({required String name, required YamlMap data}) { final dependency = data['dependency'] as String; final dependencyType = PubspecDependencyType.parse(dependency); diff --git a/lib/src/very_good_config/very_good_config.dart b/lib/src/very_good_config/very_good_config.dart index 2bec605eb..b5363de69 100644 --- a/lib/src/very_good_config/very_good_config.dart +++ b/lib/src/very_good_config/very_good_config.dart @@ -46,7 +46,7 @@ extension ArgResultsResolver on ArgResults { /// {@endtemplate} class VeryGoodConfigParseException implements Exception { /// {@macro very_good_config_parse_exception} - const VeryGoodConfigParseException(this.message); + const new(this.message); /// A human readable description of the parse failure. final String message; @@ -71,7 +71,7 @@ class VeryGoodConfigParseException implements Exception { ) class VeryGoodConfig extends Equatable { /// {@macro very_good_config} - const VeryGoodConfig({ + const new({ this.test = const VeryGoodTestConfig(), this.create = const VeryGoodCreateConfig(), this.dart = const VeryGoodDartConfig(), @@ -79,7 +79,7 @@ class VeryGoodConfig extends Equatable { }); /// Creates a [VeryGoodConfig] from a decoded YAML/JSON [json] map. - factory VeryGoodConfig.fromJson(Map json) { + factory fromJson(Map json) { return _$VeryGoodConfigFromJson(json); } @@ -92,7 +92,7 @@ class VeryGoodConfig extends Equatable { /// /// Throws a [VeryGoodConfigParseException] if [content] is not a valid /// YAML map or if any known section is malformed. - factory VeryGoodConfig.fromString(String content, {Uri? sourceUrl}) { + factory fromString(String content, {Uri? sourceUrl}) { try { return checkedYamlDecode( content, @@ -123,9 +123,7 @@ class VeryGoodConfig extends Equatable { current = parent; } } on VeryGoodConfigParseException catch (e) { - logger.err( - 'Could not read `$veryGoodConfigFileName`.\n${e.message}', - ); + logger.err('Could not read `$veryGoodConfigFileName`.\n${e.message}'); return null; } } @@ -178,7 +176,7 @@ class VeryGoodConfig extends Equatable { ) class VeryGoodCreateConfig extends Equatable { /// {@macro very_good_create_config} - const VeryGoodCreateConfig({ + const new({ this.description, this.orgName, this.publishable, @@ -187,7 +185,7 @@ class VeryGoodCreateConfig extends Equatable { }); /// Creates a [VeryGoodCreateConfig] from a decoded YAML/JSON [json] map. - factory VeryGoodCreateConfig.fromJson(Map json) { + factory fromJson(Map json) { return _$VeryGoodCreateConfigFromJson(json); } @@ -232,7 +230,7 @@ class VeryGoodCreateConfig extends Equatable { ) class VeryGoodTestConfig extends Equatable { /// {@macro very_good_test_config} - const VeryGoodTestConfig({ + const new({ this.coverage, this.optimization, this.concurrency, @@ -255,7 +253,7 @@ class VeryGoodTestConfig extends Equatable { }); /// Creates a [VeryGoodTestConfig] from a decoded YAML/JSON [json] map. - factory VeryGoodTestConfig.fromJson(Map json) { + factory fromJson(Map json) { return _$VeryGoodTestConfigFromJson(json); } @@ -363,10 +361,10 @@ class VeryGoodTestConfig extends Equatable { ) class VeryGoodDartConfig extends Equatable { /// {@macro very_good_dart_config} - const VeryGoodDartConfig({this.test = const VeryGoodDartTestConfig()}); + const new({this.test = const VeryGoodDartTestConfig()}); /// Creates a [VeryGoodDartConfig] from a decoded YAML/JSON [json] map. - factory VeryGoodDartConfig.fromJson(Map json) { + factory fromJson(Map json) { return _$VeryGoodDartConfigFromJson(json); } @@ -392,7 +390,7 @@ class VeryGoodDartConfig extends Equatable { ) class VeryGoodDartTestConfig extends Equatable { /// {@macro very_good_dart_test_config} - const VeryGoodDartTestConfig({ + const new({ this.coverage, this.optimization, this.concurrency, @@ -411,7 +409,7 @@ class VeryGoodDartTestConfig extends Equatable { }); /// Creates a [VeryGoodDartTestConfig] from a decoded YAML/JSON [json] map. - factory VeryGoodDartTestConfig.fromJson(Map json) { + factory fromJson(Map json) { return _$VeryGoodDartTestConfigFromJson(json); } @@ -498,13 +496,13 @@ class VeryGoodDartTestConfig extends Equatable { ) class VeryGoodPackagesConfig extends Equatable { /// {@macro very_good_packages_config} - const VeryGoodPackagesConfig({ + const new({ this.get = const VeryGoodPackagesGetConfig(), this.check = const VeryGoodPackagesCheckConfig(), }); /// Creates a [VeryGoodPackagesConfig] from a decoded YAML/JSON [json] map. - factory VeryGoodPackagesConfig.fromJson(Map json) { + factory fromJson(Map json) { return _$VeryGoodPackagesConfigFromJson(json); } @@ -533,10 +531,10 @@ class VeryGoodPackagesConfig extends Equatable { ) class VeryGoodPackagesGetConfig extends Equatable { /// {@macro very_good_packages_get_config} - const VeryGoodPackagesGetConfig({this.recursive, this.ignore}); + const new({this.recursive, this.ignore}); /// Creates a [VeryGoodPackagesGetConfig] from a decoded YAML/JSON [json] map. - factory VeryGoodPackagesGetConfig.fromJson(Map json) { + factory fromJson(Map json) { return _$VeryGoodPackagesGetConfigFromJson(json); } @@ -564,13 +562,11 @@ class VeryGoodPackagesGetConfig extends Equatable { ) class VeryGoodPackagesCheckConfig extends Equatable { /// {@macro very_good_packages_check_config} - const VeryGoodPackagesCheckConfig({ - this.licenses = const VeryGoodPackagesCheckLicensesConfig(), - }); + const new({this.licenses = const VeryGoodPackagesCheckLicensesConfig()}); /// Creates a [VeryGoodPackagesCheckConfig] from a decoded YAML/JSON [json] /// map. - factory VeryGoodPackagesCheckConfig.fromJson(Map json) { + factory fromJson(Map json) { return _$VeryGoodPackagesCheckConfigFromJson(json); } @@ -596,7 +592,7 @@ class VeryGoodPackagesCheckConfig extends Equatable { ) class VeryGoodPackagesCheckLicensesConfig extends Equatable { /// {@macro very_good_packages_check_licenses_config} - const VeryGoodPackagesCheckLicensesConfig({ + const new({ this.ignoreRetrievalFailures, this.dependencyType, this.allowed, @@ -607,9 +603,7 @@ class VeryGoodPackagesCheckLicensesConfig extends Equatable { /// Creates a [VeryGoodPackagesCheckLicensesConfig] from a decoded YAML/JSON /// [json] map. - factory VeryGoodPackagesCheckLicensesConfig.fromJson( - Map json, - ) { + factory fromJson(Map json) { return _$VeryGoodPackagesCheckLicensesConfigFromJson(json); } diff --git a/pubspec.yaml b/pubspec.yaml index 3e0b59185..708c74399 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -41,7 +41,7 @@ dev_dependencies: json_serializable: ^6.8.0 mocktail: ^1.0.4 test: ^1.25.8 - very_good_analysis: ^10.3.0 + very_good_analysis: ^11.0.0-rc.1 executables: very_good: diff --git a/test/helpers/command_helper.dart b/test/helpers/command_helper.dart index 82eb9305a..aa4169304 100644 --- a/test/helpers/command_helper.dart +++ b/test/helpers/command_helper.dart @@ -5,11 +5,11 @@ import 'package:mocktail/mocktail.dart'; import 'package:pub_updater/pub_updater.dart'; import 'package:very_good_cli/src/command_runner.dart'; -class _MockLogger extends Mock implements Logger {} +class _MockLogger extends Mock implements Logger; -class _MockProgress extends Mock implements Progress {} +class _MockProgress extends Mock implements Progress; -class _MockPubUpdater extends Mock implements PubUpdater {} +class _MockPubUpdater extends Mock implements PubUpdater; void Function() _overridePrint(void Function(List) fn) { return () { @@ -58,9 +58,8 @@ void Function() withRunner( ), ).thenAnswer((_) => Future.value(true)); - when( - () => pubUpdater.getLatestVersion(any()), - ).thenAnswer((_) async => '1.0.0'); + when(() => pubUpdater.getLatestVersion(any())) + .thenAnswer((_) async => '1.0.0'); await runnerFn(commandRunner, logger, pubUpdater, printLogs); }); diff --git a/test/helpers/test_multi_template_commands.dart b/test/helpers/test_multi_template_commands.dart index d3100bd31..16c1ad990 100644 --- a/test/helpers/test_multi_template_commands.dart +++ b/test/helpers/test_multi_template_commands.dart @@ -7,7 +7,7 @@ import 'package:test/test.dart'; import 'package:very_good_cli/src/commands/commands.dart'; import 'package:very_good_cli/src/logger_extension.dart'; -class _MockArgResults extends Mock implements ArgResults {} +class _MockArgResults extends Mock implements ArgResults; Future testMultiTemplateCommand({ required MultiTemplates multiTemplatesCommand, @@ -33,9 +33,8 @@ Future testMultiTemplateCommand({ when(() => argResults.wasParsed(any())).thenReturn(true); when(() => argResults['template'] as String?).thenReturn(templateName); - when( - () => argResults['output-directory'] as String?, - ).thenReturn(outputDirectory.path); + when(() => argResults['output-directory'] as String?) + .thenReturn(outputDirectory.path); for (final entry in mockArgs.entries) { when(() => argResults[entry.key]).thenReturn(entry.value); @@ -55,8 +54,7 @@ Future testMultiTemplateCommand({ onVarsChanged: any(named: 'onVarsChanged'), ), ); - verify( - () => generator.generate(any(), vars: expectedVars, logger: logger), - ).called(1); + verify(() => generator.generate(any(), vars: expectedVars, logger: logger)) + .called(1); verify(() => logger.created(expectedLogSummary)).called(1); } diff --git a/test/src/cli/dart_cli_test.dart b/test/src/cli/dart_cli_test.dart index 3faa8bdcc..4db492d97 100644 --- a/test/src/cli/dart_cli_test.dart +++ b/test/src/cli/dart_cli_test.dart @@ -33,11 +33,11 @@ class _TestProcess { } } -class _MockProcess extends Mock implements _TestProcess {} +class _MockProcess extends Mock implements _TestProcess; -class _MockLogger extends Mock implements Logger {} +class _MockLogger extends Mock implements Logger; -class _MockProgress extends Mock implements Progress {} +class _MockProgress extends Mock implements Progress; void main() { group('Dart', () { @@ -160,12 +160,10 @@ void main() { p.join(tempDirectory.path, 'test_plugin'), )..createSync(); - File( - p.join(nestedDirectory.path, 'pubspec.yaml'), - ).writeAsStringSync(_pubspec); - File( - p.join(ignoredDirectory.path, 'pubspec.yaml'), - ).writeAsStringSync(_pubspec); + File(p.join(nestedDirectory.path, 'pubspec.yaml')) + .writeAsStringSync(_pubspec); + File(p.join(ignoredDirectory.path, 'pubspec.yaml')) + .writeAsStringSync(_pubspec); final relativePathPrefix = '.${p.context.separator}'; @@ -252,9 +250,8 @@ void main() { final tempDirectory = Directory.systemTemp.createTempSync(); addTearDown(() => tempDirectory.deleteSync(recursive: true)); - File( - p.join(tempDirectory.path, 'pubspec.yaml'), - ).writeAsStringSync(_unreachableGitUrlPubspec); + File(p.join(tempDirectory.path, 'pubspec.yaml')) + .writeAsStringSync(_unreachableGitUrlPubspec); when( () => process.run( diff --git a/test/src/cli/flutter_cli_test.dart b/test/src/cli/flutter_cli_test.dart index 04a530cb8..9c675e8a1 100644 --- a/test/src/cli/flutter_cli_test.dart +++ b/test/src/cli/flutter_cli_test.dart @@ -36,13 +36,13 @@ class _TestProcess { } } -class _MockProcess extends Mock implements _TestProcess {} +class _MockProcess extends Mock implements _TestProcess; -class _MockLogger extends Mock implements Logger {} +class _MockLogger extends Mock implements Logger; -class _MockProgress extends Mock implements Progress {} +class _MockProgress extends Mock implements Progress; -class _FakeGeneratorTarget extends Fake implements GeneratorTarget {} +class _FakeGeneratorTarget extends Fake implements GeneratorTarget; void main() { final successProcessResult = ProcessResult(42, ExitCode.success.code, '', ''); @@ -177,12 +177,10 @@ void main() { p.join(tempDirectory.path, 'test_plugin'), )..createSync(); - File( - p.join(nestedDirectory.path, 'pubspec.yaml'), - ).writeAsStringSync(_pubspec); - File( - p.join(ignoredDirectory.path, 'pubspec.yaml'), - ).writeAsStringSync(_pubspec); + File(p.join(nestedDirectory.path, 'pubspec.yaml')) + .writeAsStringSync(_pubspec); + File(p.join(ignoredDirectory.path, 'pubspec.yaml')) + .writeAsStringSync(_pubspec); final relativePathPrefix = '.${p.context.separator}'; @@ -269,9 +267,8 @@ void main() { final tempDirectory = Directory.systemTemp.createTempSync(); addTearDown(() => tempDirectory.deleteSync(recursive: true)); - File( - p.join(tempDirectory.path, 'pubspec.yaml'), - ).writeAsStringSync(_unreachableGitUrlPubspec); + File(p.join(tempDirectory.path, 'pubspec.yaml')) + .writeAsStringSync(_unreachableGitUrlPubspec); when( () => process.run( diff --git a/test/src/cli/git_cli_test.dart b/test/src/cli/git_cli_test.dart index 222a16b7a..cb894b9c3 100644 --- a/test/src/cli/git_cli_test.dart +++ b/test/src/cli/git_cli_test.dart @@ -15,11 +15,11 @@ class _TestProcess { } } -class _MockProcess extends Mock implements _TestProcess {} +class _MockProcess extends Mock implements _TestProcess; -class _MockLogger extends Mock implements Logger {} +class _MockLogger extends Mock implements Logger; -class _MockProgress extends Mock implements Progress {} +class _MockProgress extends Mock implements Progress; void main() { final successProcessResult = ProcessResult(42, ExitCode.success.code, '', ''); diff --git a/test/src/cli/test_cli_runner_test.dart b/test/src/cli/test_cli_runner_test.dart index 0ad1e1744..6cbd5d578 100644 --- a/test/src/cli/test_cli_runner_test.dart +++ b/test/src/cli/test_cli_runner_test.dart @@ -14,15 +14,15 @@ import 'package:very_good_test_runner/very_good_test_runner.dart'; import '../../fixtures/fixtures.dart'; -class _MockMasonGenerator extends Mock implements MasonGenerator {} +class _MockMasonGenerator extends Mock implements MasonGenerator; -class _MockGeneratorHooks extends Mock implements GeneratorHooks {} +class _MockGeneratorHooks extends Mock implements GeneratorHooks; -class _MockProgress extends Mock implements Progress {} +class _MockProgress extends Mock implements Progress; -class _MockLogger extends Mock implements Logger {} +class _MockLogger extends Mock implements Logger; -class _FakeGeneratorTarget extends Fake implements GeneratorTarget {} +class _FakeGeneratorTarget extends Fake implements GeneratorTarget; void main() { group(CoverageCollectionMode, () { @@ -329,9 +329,8 @@ void main() { stderr: stderrLogs.add, overrideTestRunner: testRunner( Stream.fromIterable([ - ...failingJsonOutput( - tempDirectory.path, - ).map(TestEvent.fromJson), + ...failingJsonOutput(tempDirectory.path) + .map(TestEvent.fromJson), const ExitTestEvent(exitCode: 1, time: 0), ]), ), @@ -392,9 +391,8 @@ void main() { stderr: stderrLogs.add, overrideTestRunner: testRunner( Stream.fromIterable([ - ...skipExceptionMessageJsonOutput( - tempDirectory.path, - ).map(TestEvent.fromJson), + ...skipExceptionMessageJsonOutput(tempDirectory.path) + .map(TestEvent.fromJson), const ExitTestEvent(exitCode: 0, time: 0), ]), ), @@ -559,9 +557,8 @@ void main() { File(p.join(tempDirectory.path, 'pubspec.yaml')).createSync(); final testEventStream = Stream.fromIterable([ - ...compilationErrorJsonOutput( - tempDirectory.path, - ).map(TestEvent.fromJson), + ...compilationErrorJsonOutput(tempDirectory.path) + .map(TestEvent.fromJson), const ExitTestEvent(exitCode: 1, time: 0), ]); @@ -947,141 +944,131 @@ void main() { }, ); - test( - 'runs tests w/coverage + min-coverage 100 + recursive (pass)', - () async { - final tempDirectory = Directory.systemTemp.createTempSync(); - addTearDown(() => tempDirectory.deleteSync(recursive: true)); + test('runs tests w/coverage + min-coverage 100 + recursive (pass)', () async { + final tempDirectory = Directory.systemTemp.createTempSync(); + addTearDown(() => tempDirectory.deleteSync(recursive: true)); - File(p.join(tempDirectory.path, 'pubspec.yaml')).createSync(); - Directory(p.join(tempDirectory.path, 'test')).createSync(); + File(p.join(tempDirectory.path, 'pubspec.yaml')).createSync(); + Directory(p.join(tempDirectory.path, 'test')).createSync(); - final tempNestedDirectory = Directory( - p.join(tempDirectory.path, 'test'), - )..createSync(); - File(p.join(tempNestedDirectory.path, 'pubspec.yaml')).createSync(); - Directory(p.join(tempNestedDirectory.path, 'test')).createSync(); + final tempNestedDirectory = Directory( + p.join(tempDirectory.path, 'test'), + )..createSync(); + File(p.join(tempNestedDirectory.path, 'pubspec.yaml')).createSync(); + Directory(p.join(tempNestedDirectory.path, 'test')).createSync(); - await expectLater( - TestCLIRunner.test( - testType: TestRunType.flutter, - cwd: tempDirectory.path, - collectCoverage: true, - minCoverage: 100, - recursive: true, - stdout: stdoutLogs.add, - stderr: stderrLogs.add, - overrideTestRunner: testRunner( - Stream.fromIterable([ - const DoneTestEvent(success: true, time: 0), - const ExitTestEvent(exitCode: 0, time: 0), - ]), - onStart: () { - File(p.join(tempDirectory.path, 'coverage', 'lcov.info')) - ..createSync(recursive: true) - ..writeAsStringSync(lcov100); - File( - p.join(tempNestedDirectory.path, 'coverage', 'lcov.info'), - ) - ..createSync(recursive: true) - ..writeAsStringSync(lcov100); - }, - ), - logger: logger, + await expectLater( + TestCLIRunner.test( + testType: TestRunType.flutter, + cwd: tempDirectory.path, + collectCoverage: true, + minCoverage: 100, + recursive: true, + stdout: stdoutLogs.add, + stderr: stderrLogs.add, + overrideTestRunner: testRunner( + Stream.fromIterable([ + const DoneTestEvent(success: true, time: 0), + const ExitTestEvent(exitCode: 0, time: 0), + ]), + onStart: () { + File(p.join(tempDirectory.path, 'coverage', 'lcov.info')) + ..createSync(recursive: true) + ..writeAsStringSync(lcov100); + File(p.join(tempNestedDirectory.path, 'coverage', 'lcov.info')) + ..createSync(recursive: true) + ..writeAsStringSync(lcov100); + }, ), - completion(equals([ExitCode.success.code, ExitCode.success.code])), - ); + logger: logger, + ), + completion(equals([ExitCode.success.code, ExitCode.success.code])), + ); - final nestedRelativePath = p.relative( - tempNestedDirectory.path, - from: tempDirectory.path, - ); - final relativePathPrefix = '.${p.context.separator}'; + final nestedRelativePath = p.relative( + tempNestedDirectory.path, + from: tempDirectory.path, + ); + final relativePathPrefix = '.${p.context.separator}'; - expect( - stdoutLogs, - unorderedEquals([ - '''Running "flutter test" in $relativePathPrefix$nestedRelativePath ...\n''', - contains('All tests passed!'), - 'Running "flutter test" in . ...\n', - contains('All tests passed!'), - ]), - ); - expect(testRunnerArgs, equals(['--coverage', '--coverage'])); - }, - ); + expect( + stdoutLogs, + unorderedEquals([ + '''Running "flutter test" in $relativePathPrefix$nestedRelativePath ...\n''', + contains('All tests passed!'), + 'Running "flutter test" in . ...\n', + contains('All tests passed!'), + ]), + ); + expect(testRunnerArgs, equals(['--coverage', '--coverage'])); + }); - test( - 'runs tests w/coverage + min-coverage 100 + recursive (fail)', - () async { - final tempDirectory = Directory.systemTemp.createTempSync(); - addTearDown(() => tempDirectory.deleteSync(recursive: true)); + test('runs tests w/coverage + min-coverage 100 + recursive (fail)', () async { + final tempDirectory = Directory.systemTemp.createTempSync(); + addTearDown(() => tempDirectory.deleteSync(recursive: true)); - File(p.join(tempDirectory.path, 'pubspec.yaml')).createSync(); - Directory(p.join(tempDirectory.path, 'test')).createSync(); + File(p.join(tempDirectory.path, 'pubspec.yaml')).createSync(); + Directory(p.join(tempDirectory.path, 'test')).createSync(); - final tempNestedDirectory = Directory( - p.join(tempDirectory.path, 'test'), - )..createSync(); - File(p.join(tempNestedDirectory.path, 'pubspec.yaml')).createSync(); - Directory(p.join(tempNestedDirectory.path, 'test')).createSync(); + final tempNestedDirectory = Directory( + p.join(tempDirectory.path, 'test'), + )..createSync(); + File(p.join(tempNestedDirectory.path, 'pubspec.yaml')).createSync(); + Directory(p.join(tempNestedDirectory.path, 'test')).createSync(); - await expectLater( - TestCLIRunner.test( - testType: TestRunType.flutter, - cwd: tempDirectory.path, - collectCoverage: true, - minCoverage: 100, - recursive: true, - stdout: stdoutLogs.add, - stderr: stderrLogs.add, - overrideTestRunner: testRunner( - Stream.fromIterable([ - const DoneTestEvent(success: true, time: 0), - const ExitTestEvent(exitCode: 0, time: 0), - ]), - onStart: () { - File(p.join(tempDirectory.path, 'coverage', 'lcov.info')) - ..createSync(recursive: true) - ..writeAsStringSync(lcov100); - File( - p.join(tempNestedDirectory.path, 'coverage', 'lcov.info'), - ) - ..createSync(recursive: true) - ..writeAsStringSync(lcov95); - }, - ), - logger: logger, + await expectLater( + TestCLIRunner.test( + testType: TestRunType.flutter, + cwd: tempDirectory.path, + collectCoverage: true, + minCoverage: 100, + recursive: true, + stdout: stdoutLogs.add, + stderr: stderrLogs.add, + overrideTestRunner: testRunner( + Stream.fromIterable([ + const DoneTestEvent(success: true, time: 0), + const ExitTestEvent(exitCode: 0, time: 0), + ]), + onStart: () { + File(p.join(tempDirectory.path, 'coverage', 'lcov.info')) + ..createSync(recursive: true) + ..writeAsStringSync(lcov100); + File(p.join(tempNestedDirectory.path, 'coverage', 'lcov.info')) + ..createSync(recursive: true) + ..writeAsStringSync(lcov95); + }, ), - throwsA( - isA().having( - (e) => e.coverage, - 'coverage', - 95.0, - ), + logger: logger, + ), + throwsA( + isA().having( + (e) => e.coverage, + 'coverage', + 95.0, ), - ); + ), + ); - final nestedRelativePath = p.relative( - tempNestedDirectory.path, - from: tempDirectory.path, - ); - final relativePathPrefix = '.${p.context.separator}'; + final nestedRelativePath = p.relative( + tempNestedDirectory.path, + from: tempDirectory.path, + ); + final relativePathPrefix = '.${p.context.separator}'; - expect( - stdoutLogs, - unorderedEquals([ - 'Running "flutter test" in ' - '. ...\n', - contains('All tests passed!'), - '''Running "flutter test" in $relativePathPrefix$nestedRelativePath ...\n''', - contains('All tests passed!'), - ]), - ); - expect(stderrLogs, isEmpty); - expect(testRunnerArgs, equals(['--coverage', '--coverage'])); - }, - ); + expect( + stdoutLogs, + unorderedEquals([ + 'Running "flutter test" in ' + '. ...\n', + contains('All tests passed!'), + '''Running "flutter test" in $relativePathPrefix$nestedRelativePath ...\n''', + contains('All tests passed!'), + ]), + ); + expect(stderrLogs, isEmpty); + expect(testRunnerArgs, equals(['--coverage', '--coverage'])); + }); test('runs tests w/optimizations (passing)', () async { final tempDirectory = Directory.systemTemp.createTempSync(); @@ -1437,9 +1424,8 @@ void main() { final lcovDir = Directory( p.join(tempDirectory.path, 'coverage'), )..createSync(recursive: true); - File( - p.join(lcovDir.path, 'lcov.info'), - ).writeAsStringSync('end_of_record\n'); + File(p.join(lcovDir.path, 'lcov.info')) + .writeAsStringSync('end_of_record\n'); }, ), ), @@ -1497,12 +1483,10 @@ void main() { final libDir = Directory(p.join(tempDirectory.path, 'lib')) ..createSync(recursive: true); - File( - p.join(libDir.path, 'tested.dart'), - ).writeAsStringSync('void tested() {}'); - File( - p.join(libDir.path, 'untested.dart'), - ).writeAsStringSync('void unused() {}'); + File(p.join(libDir.path, 'tested.dart')) + .writeAsStringSync('void tested() {}'); + File(p.join(libDir.path, 'untested.dart')) + .writeAsStringSync('void unused() {}'); File(p.join(tempDirectory.path, 'pubspec.yaml')).createSync(); Directory(p.join(tempDirectory.path, 'test')).createSync(); @@ -1568,12 +1552,10 @@ void main() { final libDir = Directory(p.join(tempDirectory.path, 'lib')) ..createSync(recursive: true); - File( - p.join(libDir.path, 'main.dart'), - ).writeAsStringSync('void main() {}'); - File( - p.join(libDir.path, 'main.g.dart'), - ).writeAsStringSync('// Generated code'); + File(p.join(libDir.path, 'main.dart')) + .writeAsStringSync('void main() {}'); + File(p.join(libDir.path, 'main.g.dart')) + .writeAsStringSync('// Generated code'); File(p.join(tempDirectory.path, 'pubspec.yaml')).createSync(); Directory(p.join(tempDirectory.path, 'test')).createSync(); diff --git a/test/src/command_runner_test.dart b/test/src/command_runner_test.dart index 2550d589c..df0124aed 100644 --- a/test/src/command_runner_test.dart +++ b/test/src/command_runner_test.dart @@ -12,17 +12,17 @@ import 'package:test/test.dart'; import 'package:very_good_cli/src/command_runner.dart'; import 'package:very_good_cli/src/version.dart'; -class _MockLogger extends Mock implements Logger {} +class _MockLogger extends Mock implements Logger; -class _MockPubUpdater extends Mock implements PubUpdater {} +class _MockPubUpdater extends Mock implements PubUpdater; -class _MockProgress extends Mock implements Progress {} +class _MockProgress extends Mock implements Progress; -class _MockDirectory extends Mock implements Directory {} +class _MockDirectory extends Mock implements Directory; -class _MockFile extends Mock implements File {} +class _MockFile extends Mock implements File; -class _MockStdout extends Mock implements Stdout {} +class _MockStdout extends Mock implements Stdout; const expectedUsage = [ '🦄 A Very Good Command-Line Interface\n', @@ -71,9 +71,8 @@ void main() { environment: {'CI': 'true'}, ); - when( - () => pubUpdater.getLatestVersion(any()), - ).thenAnswer((_) async => packageVersion); + when(() => pubUpdater.getLatestVersion(any())) + .thenAnswer((_) async => packageVersion); }); test('can be instantiated without optional parameters', () { @@ -82,9 +81,8 @@ void main() { group('run', () { test('shows update message when newer version exists', () async { - when( - () => pubUpdater.getLatestVersion(any()), - ).thenAnswer((_) async => latestVersion); + when(() => pubUpdater.getLatestVersion(any())) + .thenAnswer((_) async => latestVersion); final result = await commandRunner.run(['--version']); expect(result, equals(ExitCode.success.code)); @@ -94,9 +92,8 @@ void main() { test( 'does not show update message when using the update command', () async { - when( - () => pubUpdater.getLatestVersion(any()), - ).thenAnswer((_) async => latestVersion); + when(() => pubUpdater.getLatestVersion(any())) + .thenAnswer((_) async => latestVersion); when( () => pubUpdater.update( packageName: packageName, @@ -124,9 +121,8 @@ void main() { ); test('handles pub update errors gracefully', () async { - when( - () => pubUpdater.getLatestVersion(any()), - ).thenThrow(Exception('oops')); + when(() => pubUpdater.getLatestVersion(any())) + .thenThrow(Exception('oops')); final result = await commandRunner.run(['--version']); expect(result, equals(ExitCode.success.code)); diff --git a/test/src/commands/create/commands/app_ui_package_test.dart b/test/src/commands/create/commands/app_ui_package_test.dart index 8742b8838..1d44e09be 100644 --- a/test/src/commands/create/commands/app_ui_package_test.dart +++ b/test/src/commands/create/commands/app_ui_package_test.dart @@ -9,20 +9,20 @@ import 'package:very_good_cli/src/commands/commands.dart'; import '../../../../helpers/helpers.dart'; -class _MockLogger extends Mock implements Logger {} +class _MockLogger extends Mock implements Logger; -class _MockProgress extends Mock implements Progress {} +class _MockProgress extends Mock implements Progress; -class _MockMasonGenerator extends Mock implements MasonGenerator {} +class _MockMasonGenerator extends Mock implements MasonGenerator; -class _MockGeneratorHooks extends Mock implements GeneratorHooks {} +class _MockGeneratorHooks extends Mock implements GeneratorHooks; -class _MockArgResults extends Mock implements ArgResults {} +class _MockArgResults extends Mock implements ArgResults; -class _FakeLogger extends Fake implements Logger {} +class _FakeLogger extends Fake implements Logger; class _FakeDirectoryGeneratorTarget extends Fake - implements DirectoryGeneratorTarget {} + implements DirectoryGeneratorTarget; final expectedUsage = [ ''' @@ -170,9 +170,8 @@ void main() { logger: logger, generatorFromBundle: (_) async => generator, )..argResultOverrides = argResults; - when( - () => argResults['output-directory'] as String?, - ).thenReturn(tempDirectory.path); + when(() => argResults['output-directory'] as String?) + .thenReturn(tempDirectory.path); when(() => argResults.rest).thenReturn(['my_app_ui']); final result = await command.run(); @@ -204,9 +203,8 @@ void main() { logger: logger, ), ).called(1); - verify( - () => logger.info('Created a Very Good App UI Package! 🦄'), - ).called(1); + verify(() => logger.info('Created a Very Good App UI Package! 🦄')) + .called(1); }); }); }); diff --git a/test/src/commands/create/commands/dart_cli_test.dart b/test/src/commands/create/commands/dart_cli_test.dart index 5777defd5..96a3237d3 100644 --- a/test/src/commands/create/commands/dart_cli_test.dart +++ b/test/src/commands/create/commands/dart_cli_test.dart @@ -9,20 +9,20 @@ import 'package:very_good_cli/src/commands/commands.dart'; import '../../../../helpers/helpers.dart'; -class _MockLogger extends Mock implements Logger {} +class _MockLogger extends Mock implements Logger; -class _MockProgress extends Mock implements Progress {} +class _MockProgress extends Mock implements Progress; -class _MockMasonGenerator extends Mock implements MasonGenerator {} +class _MockMasonGenerator extends Mock implements MasonGenerator; -class _MockGeneratorHooks extends Mock implements GeneratorHooks {} +class _MockGeneratorHooks extends Mock implements GeneratorHooks; -class _MockArgResults extends Mock implements ArgResults {} +class _MockArgResults extends Mock implements ArgResults; -class _FakeLogger extends Fake implements Logger {} +class _FakeLogger extends Fake implements Logger; class _FakeDirectoryGeneratorTarget extends Fake - implements DirectoryGeneratorTarget {} + implements DirectoryGeneratorTarget; final expectedUsage = [ ''' @@ -65,10 +65,7 @@ void main() { group('can be instantiated', () { test('with default options', () { final logger = Logger(); - final command = CreateDartCLI( - logger: logger, - generatorFromBundle: null, - ); + final command = CreateDartCLI(logger: logger, generatorFromBundle: null); expect(command.name, equals('dart_cli')); expect( command.description, @@ -172,13 +169,11 @@ void main() { logger: logger, generatorFromBundle: (_) async => generator, )..argResultOverrides = argResults; - when( - () => argResults['output-directory'] as String?, - ).thenReturn(tempDirectory.path); + when(() => argResults['output-directory'] as String?) + .thenReturn(tempDirectory.path); when(() => argResults.rest).thenReturn(['my_cli']); - when( - () => argResults['executable-name'] as String?, - ).thenReturn('my_executable'); + when(() => argResults['executable-name'] as String?) + .thenReturn('my_executable'); final result = await command.run(); diff --git a/test/src/commands/create/commands/dart_package_test.dart b/test/src/commands/create/commands/dart_package_test.dart index a5b6a4c18..91c7baad3 100644 --- a/test/src/commands/create/commands/dart_package_test.dart +++ b/test/src/commands/create/commands/dart_package_test.dart @@ -9,20 +9,20 @@ import 'package:very_good_cli/src/commands/commands.dart'; import '../../../../helpers/helpers.dart'; -class _MockLogger extends Mock implements Logger {} +class _MockLogger extends Mock implements Logger; -class _MockMasonGenerator extends Mock implements MasonGenerator {} +class _MockMasonGenerator extends Mock implements MasonGenerator; -class _MockProgress extends Mock implements Progress {} +class _MockProgress extends Mock implements Progress; -class _MockGeneratorHooks extends Mock implements GeneratorHooks {} +class _MockGeneratorHooks extends Mock implements GeneratorHooks; -class _MockArgResults extends Mock implements ArgResults {} +class _MockArgResults extends Mock implements ArgResults; -class _FakeLogger extends Fake implements Logger {} +class _FakeLogger extends Fake implements Logger; class _FakeDirectoryGeneratorTarget extends Fake - implements DirectoryGeneratorTarget {} + implements DirectoryGeneratorTarget; final expectedUsage = [ ''' @@ -167,9 +167,8 @@ void main() { logger: logger, generatorFromBundle: (_) async => generator, )..argResultOverrides = argResults; - when( - () => argResults['output-directory'] as String?, - ).thenReturn(tempDirectory.path); + when(() => argResults['output-directory'] as String?) + .thenReturn(tempDirectory.path); when(() => argResults.rest).thenReturn(['my_package']); final result = await command.run(); @@ -201,9 +200,8 @@ void main() { logger: logger, ), ).called(1); - verify( - () => logger.info('Created a Very Good Dart Package! 🦄'), - ).called(1); + verify(() => logger.info('Created a Very Good Dart Package! 🦄')) + .called(1); }); }); }); diff --git a/test/src/commands/create/commands/docs_site_test.dart b/test/src/commands/create/commands/docs_site_test.dart index 6d744c4a1..c85d71f02 100644 --- a/test/src/commands/create/commands/docs_site_test.dart +++ b/test/src/commands/create/commands/docs_site_test.dart @@ -9,20 +9,20 @@ import 'package:very_good_cli/src/commands/commands.dart'; import '../../../../helpers/helpers.dart'; -class _MockLogger extends Mock implements Logger {} +class _MockLogger extends Mock implements Logger; -class _MockProgress extends Mock implements Progress {} +class _MockProgress extends Mock implements Progress; -class _MockMasonGenerator extends Mock implements MasonGenerator {} +class _MockMasonGenerator extends Mock implements MasonGenerator; -class _MockGeneratorHooks extends Mock implements GeneratorHooks {} +class _MockGeneratorHooks extends Mock implements GeneratorHooks; -class _MockArgResults extends Mock implements ArgResults {} +class _MockArgResults extends Mock implements ArgResults; -class _FakeLogger extends Fake implements Logger {} +class _FakeLogger extends Fake implements Logger; class _FakeDirectoryGeneratorTarget extends Fake - implements DirectoryGeneratorTarget {} + implements DirectoryGeneratorTarget; final expectedUsage = [ ''' @@ -167,13 +167,11 @@ void main() { logger: logger, generatorFromBundle: (_) async => generator, )..argResultOverrides = argResults; - when( - () => argResults['output-directory'] as String?, - ).thenReturn(tempDirectory.path); + when(() => argResults['output-directory'] as String?) + .thenReturn(tempDirectory.path); when(() => argResults.rest).thenReturn(['my_docs_site']); - when( - () => argResults['org-name'] as String?, - ).thenReturn('VeryGoodOpenSource'); + when(() => argResults['org-name'] as String?) + .thenReturn('VeryGoodOpenSource'); final result = await command.run(); @@ -204,9 +202,8 @@ void main() { logger: logger, ), ).called(1); - verify( - () => logger.info('Created a Very Good documentation site! 🦄'), - ).called(1); + verify(() => logger.info('Created a Very Good documentation site! 🦄')) + .called(1); }); test('uses default org name when omitted', () async { @@ -219,9 +216,8 @@ void main() { generatorFromBundle: (_) async => generator, )..argResultOverrides = argResults; when(() => argResults.wasParsed(any())).thenReturn(false); - when( - () => argResults['output-directory'] as String?, - ).thenReturn(tempDirectory.path); + when(() => argResults['output-directory'] as String?) + .thenReturn(tempDirectory.path); when(() => argResults.rest).thenReturn(['my_docs_site']); when(() => argResults['org-name'] as String?).thenReturn(null); diff --git a/test/src/commands/create/commands/flame_game_test.dart b/test/src/commands/create/commands/flame_game_test.dart index 1f54ce7e5..2c9b3c3bd 100644 --- a/test/src/commands/create/commands/flame_game_test.dart +++ b/test/src/commands/create/commands/flame_game_test.dart @@ -13,20 +13,20 @@ import 'package:very_good_cli/src/commands/create/commands/flame_game.dart'; import '../../../../helpers/helpers.dart'; -class _MockLogger extends Mock implements Logger {} +class _MockLogger extends Mock implements Logger; -class _MockProgress extends Mock implements Progress {} +class _MockProgress extends Mock implements Progress; -class _MockMasonGenerator extends Mock implements MasonGenerator {} +class _MockMasonGenerator extends Mock implements MasonGenerator; -class _MockGeneratorHooks extends Mock implements GeneratorHooks {} +class _MockGeneratorHooks extends Mock implements GeneratorHooks; -class _MockArgResults extends Mock implements ArgResults {} +class _MockArgResults extends Mock implements ArgResults; -class _FakeLogger extends Fake implements Logger {} +class _FakeLogger extends Fake implements Logger; class _FakeDirectoryGeneratorTarget extends Fake - implements DirectoryGeneratorTarget {} + implements DirectoryGeneratorTarget; final expectedUsage = [ 'Generate a Very Good Flame game.\n' @@ -180,16 +180,13 @@ void main() { logger: logger, generatorFromBundle: (_) async => generator, )..argResultOverrides = argResults; - when( - () => argResults['output-directory'] as String?, - ).thenReturn(tempDirectory.path); + when(() => argResults['output-directory'] as String?) + .thenReturn(tempDirectory.path); when(() => argResults.rest).thenReturn(['my_app']); - when( - () => argResults['application-id'] as String?, - ).thenReturn('xyz.app.my_app'); - when( - () => argResults['platforms'] as List, - ).thenReturn(['android', 'ios', 'web', 'macos', 'windows']); + when(() => argResults['application-id'] as String?) + .thenReturn('xyz.app.my_app'); + when(() => argResults['platforms'] as List) + .thenReturn(['android', 'ios', 'web', 'macos', 'windows']); final result = await command.run(); diff --git a/test/src/commands/create/commands/flutter_app_test.dart b/test/src/commands/create/commands/flutter_app_test.dart index f243c3317..3c180cb60 100644 --- a/test/src/commands/create/commands/flutter_app_test.dart +++ b/test/src/commands/create/commands/flutter_app_test.dart @@ -9,18 +9,18 @@ import 'package:very_good_cli/src/commands/create/commands/flutter_app.dart'; import '../../../../helpers/helpers.dart'; -class _MockLogger extends Mock implements Logger {} +class _MockLogger extends Mock implements Logger; -class _MockProgress extends Mock implements Progress {} +class _MockProgress extends Mock implements Progress; -class _MockMasonGenerator extends Mock implements MasonGenerator {} +class _MockMasonGenerator extends Mock implements MasonGenerator; -class _MockGeneratorHooks extends Mock implements GeneratorHooks {} +class _MockGeneratorHooks extends Mock implements GeneratorHooks; -class _FakeLogger extends Fake implements Logger {} +class _FakeLogger extends Fake implements Logger; class _FakeDirectoryGeneratorTarget extends Fake - implements DirectoryGeneratorTarget {} + implements DirectoryGeneratorTarget; final expectedUsage = [ ''' diff --git a/test/src/commands/create/commands/flutter_package_test.dart b/test/src/commands/create/commands/flutter_package_test.dart index 5d06b04e7..8278cee25 100644 --- a/test/src/commands/create/commands/flutter_package_test.dart +++ b/test/src/commands/create/commands/flutter_package_test.dart @@ -9,20 +9,20 @@ import 'package:very_good_cli/src/commands/commands.dart'; import '../../../../helpers/helpers.dart'; -class _MockLogger extends Mock implements Logger {} +class _MockLogger extends Mock implements Logger; -class _MockProgress extends Mock implements Progress {} +class _MockProgress extends Mock implements Progress; -class _MockMasonGenerator extends Mock implements MasonGenerator {} +class _MockMasonGenerator extends Mock implements MasonGenerator; -class _MockGeneratorHooks extends Mock implements GeneratorHooks {} +class _MockGeneratorHooks extends Mock implements GeneratorHooks; -class _MockArgResults extends Mock implements ArgResults {} +class _MockArgResults extends Mock implements ArgResults; -class _FakeLogger extends Fake implements Logger {} +class _FakeLogger extends Fake implements Logger; class _FakeDirectoryGeneratorTarget extends Fake - implements DirectoryGeneratorTarget {} + implements DirectoryGeneratorTarget; final expectedUsage = [ ''' @@ -170,9 +170,8 @@ void main() { logger: logger, generatorFromBundle: (_) async => generator, )..argResultOverrides = argResults; - when( - () => argResults['output-directory'] as String?, - ).thenReturn(tempDirectory.path); + when(() => argResults['output-directory'] as String?) + .thenReturn(tempDirectory.path); when(() => argResults.rest).thenReturn(['my_flutter_package']); final result = await command.run(); @@ -204,9 +203,8 @@ void main() { logger: logger, ), ).called(1); - verify( - () => logger.info('Created a Very Good Flutter Package! 🦄'), - ).called(1); + verify(() => logger.info('Created a Very Good Flutter Package! 🦄')) + .called(1); }); }); }); diff --git a/test/src/commands/create/commands/flutter_plugin_test.dart b/test/src/commands/create/commands/flutter_plugin_test.dart index b84604987..c1a6fb192 100644 --- a/test/src/commands/create/commands/flutter_plugin_test.dart +++ b/test/src/commands/create/commands/flutter_plugin_test.dart @@ -14,20 +14,20 @@ import 'package:very_good_cli/src/commands/commands.dart'; import '../../../../helpers/helpers.dart'; -class _MockLogger extends Mock implements Logger {} +class _MockLogger extends Mock implements Logger; -class _MockProgress extends Mock implements Progress {} +class _MockProgress extends Mock implements Progress; -class _MockMasonGenerator extends Mock implements MasonGenerator {} +class _MockMasonGenerator extends Mock implements MasonGenerator; -class _MockGeneratorHooks extends Mock implements GeneratorHooks {} +class _MockGeneratorHooks extends Mock implements GeneratorHooks; -class _MockArgResults extends Mock implements ArgResults {} +class _MockArgResults extends Mock implements ArgResults; -class _FakeLogger extends Fake implements Logger {} +class _FakeLogger extends Fake implements Logger; class _FakeDirectoryGeneratorTarget extends Fake - implements DirectoryGeneratorTarget {} + implements DirectoryGeneratorTarget; class _TestProcess { Future run( @@ -40,7 +40,7 @@ class _TestProcess { } } -class _MockProcess extends Mock implements _TestProcess {} +class _MockProcess extends Mock implements _TestProcess; final expectedUsage = [ 'Generate a Very Good Flutter plugin.\n' @@ -198,13 +198,11 @@ void main() { logger: logger, generatorFromBundle: (_) async => generator, )..argResultOverrides = argResults; - when( - () => argResults['output-directory'] as String?, - ).thenReturn(tempDirectory.path); + when(() => argResults['output-directory'] as String?) + .thenReturn(tempDirectory.path); when(() => argResults.rest).thenReturn(['my_plugin']); - when( - () => argResults['platforms'] as List, - ).thenReturn(['android', 'ios', 'windows']); + when(() => argResults['platforms'] as List) + .thenReturn(['android', 'ios', 'windows']); final result = await command.run(); @@ -239,9 +237,8 @@ void main() { logger: logger, ), ).called(1); - verify( - () => logger.info('Created a Very Good Flutter Plugin! 🦄'), - ).called(1); + verify(() => logger.info('Created a Very Good Flutter Plugin! 🦄')) + .called(1); }); test( @@ -271,9 +268,8 @@ void main() { final pigeonDir = Directory( path.join(target.dir.path, 'my_plugin_$platform', 'pigeons'), )..createSync(recursive: true); - File( - path.join(pigeonDir.path, 'messages.dart'), - ).writeAsStringSync(''); + File(path.join(pigeonDir.path, 'messages.dart')) + .writeAsStringSync(''); } return generatedFiles; @@ -302,13 +298,11 @@ void main() { generatorFromBundle: (_) async => generator, )..argResultOverrides = argResults; - when( - () => argResults['output-directory'] as String?, - ).thenReturn(tempDirectory.path); + when(() => argResults['output-directory'] as String?) + .thenReturn(tempDirectory.path); when(() => argResults.rest).thenReturn(['my_plugin']); - when( - () => argResults['platforms'] as List, - ).thenReturn(pluginPlatforms); + when(() => argResults['platforms'] as List) + .thenReturn(pluginPlatforms); await ProcessOverrides.runZoned( () => expectLater( diff --git a/test/src/commands/create/create_subcommand_test.dart b/test/src/commands/create/create_subcommand_test.dart index 955c07e90..20f02e47d 100644 --- a/test/src/commands/create/create_subcommand_test.dart +++ b/test/src/commands/create/create_subcommand_test.dart @@ -11,29 +11,29 @@ import 'package:very_good_cli/src/commands/create/commands/create_subcommand.dar import 'package:very_good_cli/src/commands/create/templates/template.dart'; import 'package:very_good_cli/src/very_good_config/very_good_config.dart'; -class _MockTemplate extends Mock implements Template {} +class _MockTemplate extends Mock implements Template; -class _MockArgResults extends Mock implements ArgResults {} +class _MockArgResults extends Mock implements ArgResults; -class _MockLogger extends Mock implements Logger {} +class _MockLogger extends Mock implements Logger; -class _MockProgress extends Mock implements Progress {} +class _MockProgress extends Mock implements Progress; -class _MockMasonGenerator extends Mock implements MasonGenerator {} +class _MockMasonGenerator extends Mock implements MasonGenerator; -class _MockBundle extends Mock implements MasonBundle {} +class _MockBundle extends Mock implements MasonBundle; -class _MockGeneratorHooks extends Mock implements GeneratorHooks {} +class _MockGeneratorHooks extends Mock implements GeneratorHooks; -class _FakeLogger extends Fake implements Logger {} +class _FakeLogger extends Fake implements Logger; class _FakeDirectoryGeneratorTarget extends Fake - implements DirectoryGeneratorTarget {} + implements DirectoryGeneratorTarget; -class _FakeDirectory extends Fake implements Directory {} +class _FakeDirectory extends Fake implements Directory; class _TestCreateSubCommand extends CreateSubCommand { - _TestCreateSubCommand({ + new({ required this.template, required super.logger, required super.generatorFromBundle, @@ -51,7 +51,7 @@ class _TestCreateSubCommand extends CreateSubCommand { class _TestCreateSubCommandWithOrgName extends _TestCreateSubCommand with OrgName { - _TestCreateSubCommandWithOrgName({ + new({ required super.template, required super.logger, required super.generatorFromBundle, @@ -60,7 +60,7 @@ class _TestCreateSubCommandWithOrgName extends _TestCreateSubCommand class _TestCreateSubCommandWithPublishable extends _TestCreateSubCommand with Publishable { - _TestCreateSubCommandWithPublishable({ + new({ required super.template, required super.logger, required super.generatorFromBundle, @@ -69,7 +69,7 @@ class _TestCreateSubCommandWithPublishable extends _TestCreateSubCommand class _TestCreateSubCommandWithWorkspace extends _TestCreateSubCommand with Workspace { - _TestCreateSubCommandWithWorkspace({ + new({ required super.template, required super.logger, required super.generatorFromBundle, @@ -78,7 +78,7 @@ class _TestCreateSubCommandWithWorkspace extends _TestCreateSubCommand class _TestCreateSubCommandMultiTemplate extends CreateSubCommand with MultiTemplates { - _TestCreateSubCommandMultiTemplate({ + new({ required this.templates, required super.logger, required super.generatorFromBundle, @@ -95,8 +95,7 @@ class _TestCreateSubCommandMultiTemplate extends CreateSubCommand } class _TestCommandRunner extends CommandRunner { - _TestCommandRunner({required this.command}) - : super('runner', 'Test command runner') { + new({required this.command}) : super('runner', 'Test command runner') { addCommand(command); } @@ -150,9 +149,8 @@ Run "runner help" to see global options.'''; template = _MockTemplate(); when(() => template.name).thenReturn('test'); when(() => template.bundle).thenReturn(bundle); - when( - () => template.onGenerateComplete(any(), any()), - ).thenAnswer((_) async {}); + when(() => template.onGenerateComplete(any(), any())) + .thenAnswer((_) async {}); }); group('can be instantiated', () { @@ -609,9 +607,8 @@ Run "runner help" to see global options.'''; template = _MockTemplate(); when(() => template.name).thenReturn('test'); when(() => template.bundle).thenReturn(bundle); - when( - () => template.onGenerateComplete(any(), any()), - ).thenAnswer((_) async {}); + when(() => template.onGenerateComplete(any(), any())) + .thenAnswer((_) async {}); }); group('can be instantiated', () { @@ -920,17 +917,15 @@ Run "runner help" to see global options.'''; when(() => template1.name).thenReturn('template1'); when(() => template1.help).thenReturn('template1 help'); when(() => template1.bundle).thenReturn(bundle); - when( - () => template1.onGenerateComplete(any(), any()), - ).thenAnswer((_) async {}); + when(() => template1.onGenerateComplete(any(), any())) + .thenAnswer((_) async {}); final template2 = _MockTemplate(); when(() => template2.name).thenReturn('template2'); when(() => template2.help).thenReturn('template2 help'); when(() => template2.bundle).thenReturn(bundle); - when( - () => template2.onGenerateComplete(any(), any()), - ).thenAnswer((_) async {}); + when(() => template2.onGenerateComplete(any(), any())) + .thenAnswer((_) async {}); templates = [template1, template2]; }); @@ -1080,9 +1075,8 @@ Run "runner help" to see global options.'''; tempDirectory.deleteSync(recursive: true); }); - File( - path.join(tempDirectory.path, veryGoodConfigFileName), - ).writeAsStringSync('create:\n template: unknown'); + File(path.join(tempDirectory.path, veryGoodConfigFileName)) + .writeAsStringSync('create:\n template: unknown'); Directory.current = tempDirectory.path; await expectLater( @@ -1138,18 +1132,16 @@ Run "runner help" to see global options.'''; template = _MockTemplate(); when(() => template.name).thenReturn('test'); when(() => template.bundle).thenReturn(bundle); - when( - () => template.onGenerateComplete(any(), any()), - ).thenAnswer((_) async {}); + when(() => template.onGenerateComplete(any(), any())) + .thenAnswer((_) async {}); }); group('resolve', () { test('applies config value when the arg was not parsed', () { final argResults = _MockArgResults(); when(() => argResults.wasParsed(any())).thenReturn(false); - when( - () => argResults['description'] as String?, - ).thenReturn('A Very Good Project created by Very Good CLI.'); + when(() => argResults['description'] as String?) + .thenReturn('A Very Good Project created by Very Good CLI.'); final command = _TestCreateSubCommand( @@ -1169,9 +1161,7 @@ Run "runner help" to see global options.'''; final argResults = _MockArgResults(); when(() => argResults.wasParsed(any())).thenReturn(false); when(() => argResults.wasParsed('description')).thenReturn(true); - when( - () => argResults['description'] as String?, - ).thenReturn('From CLI'); + when(() => argResults['description'] as String?).thenReturn('From CLI'); final command = _TestCreateSubCommand( @@ -1333,9 +1323,8 @@ Run "runner help" to see global options.'''; Directory.current = cwd; tempDirectory.deleteSync(recursive: true); }); - File( - path.join(tempDirectory.path, veryGoodConfigFileName), - ).writeAsStringSync('create:\n org_name: com.very.good'); + File(path.join(tempDirectory.path, veryGoodConfigFileName)) + .writeAsStringSync('create:\n org_name: com.very.good'); Directory.current = tempDirectory.path; final result = await runner.run(['create_subcommand', 'test_project']); @@ -1357,33 +1346,26 @@ Run "runner help" to see global options.'''; ).called(1); }); - test( - 'fails with exit code ${ExitCode.config.code} ' - 'when very_good.yaml is malformed', - () async { - final tempDirectory = Directory.systemTemp.createTempSync(); - addTearDown(() { - Directory.current = cwd; - tempDirectory.deleteSync(recursive: true); - }); - File( - path.join(tempDirectory.path, veryGoodConfigFileName), - ).writeAsStringSync('- not\n- a\n- map'); - Directory.current = tempDirectory.path; + test('fails with exit code ${ExitCode.config.code} ' + 'when very_good.yaml is malformed', () async { + final tempDirectory = Directory.systemTemp.createTempSync(); + addTearDown(() { + Directory.current = cwd; + tempDirectory.deleteSync(recursive: true); + }); + File(path.join(tempDirectory.path, veryGoodConfigFileName)) + .writeAsStringSync('- not\n- a\n- map'); + Directory.current = tempDirectory.path; - final result = await runner.run([ - 'create_subcommand', - 'test_project', - ]); + final result = await runner.run(['create_subcommand', 'test_project']); - expect(result, equals(ExitCode.config.code)); - verify( - () => logger.err( - any(that: contains('Could not read `very_good.yaml`')), - ), - ).called(1); - }, - ); + expect(result, equals(ExitCode.config.code)); + verify( + () => logger.err( + any(that: contains('Could not read `very_good.yaml`')), + ), + ).called(1); + }); }); }); @@ -1409,9 +1391,8 @@ Run "runner help" to see global options.'''; template = _MockTemplate(); when(() => template.name).thenReturn('test'); when(() => template.bundle).thenReturn(bundle); - when( - () => template.onGenerateComplete(any(), any()), - ).thenAnswer((_) async {}); + when(() => template.onGenerateComplete(any(), any())) + .thenAnswer((_) async {}); }); group('can be instantiated', () { @@ -1603,9 +1584,8 @@ Run "runner help" to see global options.'''; template = _MockTemplate(); when(() => template.name).thenReturn('test'); when(() => template.bundle).thenReturn(bundle); - when( - () => template.onGenerateComplete(any(), any()), - ).thenAnswer((_) async {}); + when(() => template.onGenerateComplete(any(), any())) + .thenAnswer((_) async {}); }); group('can be instantiated', () { diff --git a/test/src/commands/dart/commands/dart_test_test.dart b/test/src/commands/dart/commands/dart_test_test.dart index 589183c29..ffbcfa7a1 100644 --- a/test/src/commands/dart/commands/dart_test_test.dart +++ b/test/src/commands/dart/commands/dart_test_test.dart @@ -15,11 +15,11 @@ import 'package:very_good_cli/src/very_good_config/very_good_config.dart'; import '../../../../helpers/helpers.dart'; -class _MockLogger extends Mock implements Logger {} +class _MockLogger extends Mock implements Logger; -class _MockArgResults extends Mock implements ArgResults {} +class _MockArgResults extends Mock implements ArgResults; -class _MockDartTestCommand extends Mock implements DartTestCommandCall {} +class _MockDartTestCommand extends Mock implements DartTestCommandCall; const expectedTestUsage = [ 'Run tests in a Dart project.\n' @@ -56,7 +56,6 @@ const expectedTestUsage = [ // A concrete class should have methods with body // and we just want to mock this class for the test. -// ignore: one_member_abstracts abstract class DartTestCommandCall { Future> call({ String cwd = '.', @@ -133,9 +132,8 @@ void main() { when(() => argResults['run-skipped']).thenReturn(false); when(() => argResults['optimization']).thenReturn(true); when(() => argResults['platform']).thenReturn(null); - when( - () => argResults['collect-coverage-from'], - ).thenReturn('imports'); + when(() => argResults['collect-coverage-from']) + .thenReturn('imports'); when(() => argResults['report-on']).thenReturn([]); when(() => argResults['file-reporter']).thenReturn(null); when(() => argResults.rest).thenReturn([]); @@ -191,9 +189,8 @@ void main() { Directory.current = tempDirectory.path; Directory(path.join(Directory.current.path, 'project')).createSync(); - File( - path.join(Directory.current.path, 'project', 'pubspec.yaml'), - ).createSync(); + File(path.join(Directory.current.path, 'project', 'pubspec.yaml')) + .createSync(); final result = await commandRunner.run(['dart', 'test', '-r']); expect(result, equals(ExitCode.success.code)); @@ -340,9 +337,8 @@ void main() { }); test('completes normally --test-randomize-ordering-seed random', () async { - when( - () => argResults['test-randomize-ordering-seed'], - ).thenReturn('random'); + when(() => argResults['test-randomize-ordering-seed']) + .thenReturn('random'); final result = await testCommand.run(); expect(result, equals(ExitCode.success.code)); verify( @@ -361,9 +357,8 @@ void main() { 'completes normally --test-randomize-ordering-seed 2305182648', () async { const randomSeed = '2305182648'; - when( - () => argResults['test-randomize-ordering-seed'], - ).thenReturn(randomSeed); + when(() => argResults['test-randomize-ordering-seed']) + .thenReturn(randomSeed); final result = await testCommand.run(); expect(result, equals(ExitCode.success.code)); verify( @@ -467,9 +462,8 @@ void main() { 'reports on a different directory when --report-on is supplied', () async { when(() => argResults['min-coverage']).thenReturn('0'); - when( - () => argResults['report-on'], - ).thenReturn(['routes']); + when(() => argResults['report-on']) + .thenReturn(['routes']); final result = await testCommand.run(); expect(result, equals(ExitCode.success.code)); verify( @@ -491,9 +485,8 @@ void main() { 'splits space-separated paths when --report-on "lib test" is supplied', () async { when(() => argResults['min-coverage']).thenReturn('0'); - when( - () => argResults['report-on'], - ).thenReturn(['lib test']); + when(() => argResults['report-on']) + .thenReturn(['lib test']); final result = await testCommand.run(); expect(result, equals(ExitCode.success.code)); verify( @@ -515,9 +508,8 @@ void main() { 'splits comma-separated paths when --report-on "lib,test" is supplied', () async { when(() => argResults['min-coverage']).thenReturn('0'); - when( - () => argResults['report-on'], - ).thenReturn(['lib,test']); + when(() => argResults['report-on']) + .thenReturn(['lib,test']); final result = await testCommand.run(); expect(result, equals(ExitCode.success.code)); verify( @@ -654,9 +646,8 @@ void main() { 'exclude files from coverage when --exclude-coverage is used', () async { when(() => argResults['coverage']).thenReturn(true); - when( - () => argResults['exclude-coverage'], - ).thenReturn('*.g.dart'); + when(() => argResults['exclude-coverage']) + .thenReturn('*.g.dart'); final result = await testCommand.run(); expect(result, equals(ExitCode.success.code)); verify( @@ -812,9 +803,8 @@ void main() { }); test('completes normally --file-reporter json:test-report.json', () async { - when( - () => argResults['file-reporter'], - ).thenReturn('json:test-report.json'); + when(() => argResults['file-reporter']) + .thenReturn('json:test-report.json'); final result = await testCommand.run(); expect(result, equals(ExitCode.success.code)); verify( @@ -844,9 +834,8 @@ void main() { Directory.current = tempDirectory.path; File(path.join(tempDirectory.path, 'pubspec.yaml')).createSync(); - File( - path.join(tempDirectory.path, 'very_good.yaml'), - ).writeAsStringSync('- not\n- a\n- map'); + File(path.join(tempDirectory.path, 'very_good.yaml')) + .writeAsStringSync('- not\n- a\n- map'); final result = await commandRunner.run(['dart', 'test']); expect(result, equals(ExitCode.config.code)); @@ -937,9 +926,8 @@ void main() { test('CLI --file-reporter takes precedence over config value', () { when(() => argResults.wasParsed(any())).thenReturn(false); when(() => argResults.wasParsed('file-reporter')).thenReturn(true); - when( - () => argResults['file-reporter'], - ).thenReturn('json:cli.json'); + when(() => argResults['file-reporter']) + .thenReturn('json:cli.json'); final options = DartTestOptions.parse( argResults, @@ -955,9 +943,8 @@ void main() { test('falls back to the CLI default when the parsed arg is null ' 'and the config is unset', () { when(() => argResults.wasParsed(any())).thenReturn(true); - when( - () => argResults['collect-coverage-from'], - ).thenReturn(null); + when(() => argResults['collect-coverage-from']) + .thenReturn(null); final options = DartTestOptions.parse(argResults); diff --git a/test/src/commands/packages/commands/check/commands/licenses_test.dart b/test/src/commands/packages/commands/check/commands/licenses_test.dart index 346e541de..6e9ab6fdb 100644 --- a/test/src/commands/packages/commands/check/commands/licenses_test.dart +++ b/test/src/commands/packages/commands/check/commands/licenses_test.dart @@ -20,20 +20,19 @@ import 'package:very_good_cli/src/very_good_config/very_good_config.dart'; import '../../../../../../helpers/helpers.dart'; -class _MockArgResults extends Mock implements ArgResults {} +class _MockArgResults extends Mock implements ArgResults; -class _MockProgress extends Mock implements Progress {} +class _MockProgress extends Mock implements Progress; -class _MockResult extends Mock implements detector.Result {} +class _MockResult extends Mock implements detector.Result; -class _MockLicenseMatch extends Mock implements detector.LicenseMatch {} +class _MockLicenseMatch extends Mock implements detector.LicenseMatch; -class _MockLicenseWithNGrams extends Mock - implements detector.LicenseWithNGrams {} +class _MockLicenseWithNGrams extends Mock implements detector.LicenseWithNGrams; -class _MockPackageConfig extends Mock implements package_config.PackageConfig {} +class _MockPackageConfig extends Mock implements package_config.PackageConfig; -class _MockPackage extends Mock implements package_config.Package {} +class _MockPackage extends Mock implements package_config.Package; const _expectedPackagesCheckLicensesUsage = [ "Check packages' licenses in a Dart or Flutter project.\n" @@ -184,13 +183,11 @@ void main() { test( '''when there is a single hosted direct dependency and license''', withRunner((commandRunner, logger, pubUpdater, printLogs) async { - File( - path.join(tempDirectory.path, pubspecLockBasename), - ).writeAsStringSync(_validPubspecLockContent); + File(path.join(tempDirectory.path, pubspecLockBasename)) + .writeAsStringSync(_validPubspecLockContent); - when( - () => packageConfig.packages, - ).thenReturn([veryGoodTestRunnerConfigPackage]); + when(() => packageConfig.packages) + .thenReturn([veryGoodTestRunnerConfigPackage]); when(() => detectorResult.matches).thenReturn([mitLicenseMatch]); when(() => logger.progress(any())).thenReturn(progress); @@ -217,15 +214,13 @@ void main() { test( '''when there are multiple hosted direct dependency and licenses''', withRunner((commandRunner, logger, pubUpdater, printLogs) async { - File( - path.join(tempDirectory.path, pubspecLockBasename), - ).writeAsStringSync(_validMultiplePubspecLockContent); + File(path.join(tempDirectory.path, pubspecLockBasename)) + .writeAsStringSync(_validMultiplePubspecLockContent); when(() => logger.progress(any())).thenReturn(progress); - when( - () => detectorResult.matches, - ).thenReturn([mitLicenseMatch, bsdLicenseMatch]); + when(() => detectorResult.matches) + .thenReturn([mitLicenseMatch, bsdLicenseMatch]); when(() => packageConfig.packages).thenReturn({ veryGoodTestRunnerConfigPackage, cliCompletionConfigPackage, @@ -257,13 +252,11 @@ void main() { test( '''when both allowed and forbidden are specified but left empty''', withRunner((commandRunner, logger, pubUpdater, printLogs) async { - File( - path.join(tempDirectory.path, pubspecLockBasename), - ).writeAsStringSync(_validPubspecLockContent); + File(path.join(tempDirectory.path, pubspecLockBasename)) + .writeAsStringSync(_validPubspecLockContent); - when( - () => packageConfig.packages, - ).thenReturn([veryGoodTestRunnerConfigPackage]); + when(() => packageConfig.packages) + .thenReturn([veryGoodTestRunnerConfigPackage]); when(() => detectorResult.matches).thenReturn([mitLicenseMatch]); when(() => logger.progress(any())).thenReturn(progress); @@ -294,13 +287,11 @@ void main() { test( 'unknown when no license file is found', withRunner((commandRunner, logger, pubUpdater, printLogs) async { - File( - path.join(tempDirectory.path, pubspecLockBasename), - ).writeAsStringSync(_validPubspecLockContent); + File(path.join(tempDirectory.path, pubspecLockBasename)) + .writeAsStringSync(_validPubspecLockContent); - when( - () => packageConfig.packages, - ).thenReturn([veryGoodTestRunnerConfigPackage]); + when(() => packageConfig.packages) + .thenReturn([veryGoodTestRunnerConfigPackage]); final licenseFilePath = path.join( tempDirectory.path, veryGoodTestRunnerConfigPackage.name, @@ -332,13 +323,11 @@ void main() { test( 'unknown when non-standard license file is found', withRunner((commandRunner, logger, pubUpdater, printLogs) async { - File( - path.join(tempDirectory.path, pubspecLockBasename), - ).writeAsStringSync(_validPubspecLockContent); + File(path.join(tempDirectory.path, pubspecLockBasename)) + .writeAsStringSync(_validPubspecLockContent); - when( - () => packageConfig.packages, - ).thenReturn([veryGoodTestRunnerConfigPackage]); + when(() => packageConfig.packages) + .thenReturn([veryGoodTestRunnerConfigPackage]); final licenseFilePath = path.join( tempDirectory.path, veryGoodTestRunnerConfigPackage.name, @@ -382,21 +371,18 @@ and limitations under the License.'''); test( 'unknown when invalid license file is found', withRunner((commandRunner, logger, pubUpdater, printLogs) async { - File( - path.join(tempDirectory.path, pubspecLockBasename), - ).writeAsStringSync(_validPubspecLockContent); + File(path.join(tempDirectory.path, pubspecLockBasename)) + .writeAsStringSync(_validPubspecLockContent); - when( - () => packageConfig.packages, - ).thenReturn([veryGoodTestRunnerConfigPackage]); + when(() => packageConfig.packages) + .thenReturn([veryGoodTestRunnerConfigPackage]); final licenseFilePath = path.join( tempDirectory.path, veryGoodTestRunnerConfigPackage.name, 'LICENSE', ); - File( - licenseFilePath, - ).writeAsStringSync('This is an invalid license file.'); + File(licenseFilePath) + .writeAsStringSync('This is an invalid license file.'); when(() => logger.progress(any())).thenReturn(progress); when(() => detectorResult.matches).thenReturn([]); @@ -428,9 +414,8 @@ and limitations under the License.'''); test( 'when an unknown error is thrown', withRunner((commandRunner, logger, pubUpdater, printLogs) async { - File( - path.join(tempDirectory.path, pubspecLockBasename), - ).writeAsStringSync(_validMultiplePubspecLockContent); + File(path.join(tempDirectory.path, pubspecLockBasename)) + .writeAsStringSync(_validMultiplePubspecLockContent); when(() => logger.progress(any())).thenReturn(progress); @@ -486,9 +471,8 @@ and limitations under the License.'''); test( 'when cached package path cannot be found', withRunner((commandRunner, logger, pubUpdater, printLogs) async { - File( - path.join(tempDirectory.path, pubspecLockBasename), - ).writeAsStringSync(_validPubspecLockContent); + File(path.join(tempDirectory.path, pubspecLockBasename)) + .writeAsStringSync(_validPubspecLockContent); when(() => logger.progress(any())).thenReturn(progress); @@ -523,24 +507,21 @@ and limitations under the License.'''); test( 'when cached package directory cannot be found', withRunner((commandRunner, logger, pubUpdater, printLogs) async { - File( - path.join(tempDirectory.path, pubspecLockBasename), - ).writeAsStringSync(_validPubspecLockContent); + File(path.join(tempDirectory.path, pubspecLockBasename)) + .writeAsStringSync(_validPubspecLockContent); when(() => logger.progress(any())).thenReturn(progress); - when( - () => packageConfig.packages, - ).thenReturn({veryGoodTestRunnerConfigPackage}); + when(() => packageConfig.packages) + .thenReturn({veryGoodTestRunnerConfigPackage}); final packagePath = path.join( tempDirectory.path, 'inexistent', 'nothing', ); - when( - () => veryGoodTestRunnerConfigPackage.root, - ).thenReturn(Uri.file(packagePath)); + when(() => veryGoodTestRunnerConfigPackage.root) + .thenReturn(Uri.file(packagePath)); final targetPath = tempDirectory.path; final result = await commandRunner.run([ @@ -571,9 +552,8 @@ and limitations under the License.'''); test( 'when all licenses fail to be retrieved', withRunner((commandRunner, logger, pubUpdater, printLogs) async { - File( - path.join(tempDirectory.path, pubspecLockBasename), - ).writeAsStringSync(_validMultiplePubspecLockContent); + File(path.join(tempDirectory.path, pubspecLockBasename)) + .writeAsStringSync(_validMultiplePubspecLockContent); when(() => logger.progress(any())).thenReturn(progress); @@ -682,16 +662,13 @@ and limitations under the License.'''); test( 'by default', withRunner((commandRunner, logger, pubUpdater, printLogs) async { - File( - path.join(tempDirectory.path, pubspecLockBasename), - ).writeAsStringSync(_validPubspecLockContent); + File(path.join(tempDirectory.path, pubspecLockBasename)) + .writeAsStringSync(_validPubspecLockContent); - when( - () => packageConfig.packages, - ).thenReturn({veryGoodTestRunnerConfigPackage}); - when( - () => detectorResult.matches, - ).thenReturn([mitLicenseMatch]); + when(() => packageConfig.packages) + .thenReturn({veryGoodTestRunnerConfigPackage}); + when(() => detectorResult.matches) + .thenReturn([mitLicenseMatch]); when(() => logger.progress(any())).thenReturn(progress); @@ -727,16 +704,13 @@ and limitations under the License.'''); test( 'when specified', withRunner((commandRunner, logger, pubUpdater, printLogs) async { - File( - path.join(tempDirectory.path, pubspecLockBasename), - ).writeAsStringSync(_validPubspecLockContent); + File(path.join(tempDirectory.path, pubspecLockBasename)) + .writeAsStringSync(_validPubspecLockContent); - when( - () => packageConfig.packages, - ).thenReturn({veryGoodTestRunnerConfigPackage}); - when( - () => detectorResult.matches, - ).thenReturn([mitLicenseMatch]); + when(() => packageConfig.packages) + .thenReturn({veryGoodTestRunnerConfigPackage}); + when(() => detectorResult.matches) + .thenReturn([mitLicenseMatch]); when(() => logger.progress(any())).thenReturn(progress); @@ -775,13 +749,11 @@ and limitations under the License.'''); test( 'on developer dev dependencies only', withRunner((commandRunner, logger, pubUpdater, printLogs) async { - File( - path.join(tempDirectory.path, pubspecLockBasename), - ).writeAsStringSync(_validPubspecLockContent); + File(path.join(tempDirectory.path, pubspecLockBasename)) + .writeAsStringSync(_validPubspecLockContent); - when( - () => packageConfig.packages, - ).thenReturn({veryGoodAnalysisConfigPackage}); + when(() => packageConfig.packages) + .thenReturn({veryGoodAnalysisConfigPackage}); when(() => detectorResult.matches).thenReturn([mitLicenseMatch]); when(() => logger.progress(any())).thenReturn(progress); @@ -820,13 +792,11 @@ and limitations under the License.'''); test( 'on transitive dependencies only', withRunner((commandRunner, logger, pubUpdater, printLogs) async { - File( - path.join(tempDirectory.path, pubspecLockBasename), - ).writeAsStringSync(_validPubspecLockContent); + File(path.join(tempDirectory.path, pubspecLockBasename)) + .writeAsStringSync(_validPubspecLockContent); - when( - () => packageConfig.packages, - ).thenReturn({yamlConfigPackage}); + when(() => packageConfig.packages) + .thenReturn({yamlConfigPackage}); when(() => detectorResult.matches).thenReturn([mitLicenseMatch]); when(() => logger.progress(any())).thenReturn(progress); @@ -865,13 +835,11 @@ and limitations under the License.'''); test( 'on direct overridden dependencies only', withRunner((commandRunner, logger, pubUpdater, printLogs) async { - File( - path.join(tempDirectory.path, pubspecLockBasename), - ).writeAsStringSync(_validPubspecLockContent); + File(path.join(tempDirectory.path, pubspecLockBasename)) + .writeAsStringSync(_validPubspecLockContent); - when( - () => packageConfig.packages, - ).thenReturn({pathConfigPackage}); + when(() => packageConfig.packages) + .thenReturn({pathConfigPackage}); when(() => detectorResult.matches).thenReturn([mitLicenseMatch]); when(() => logger.progress(any())).thenReturn(progress); @@ -912,9 +880,8 @@ and limitations under the License.'''); test( 'on all dependencies', withRunner((commandRunner, logger, pubUpdater, printLogs) async { - File( - path.join(tempDirectory.path, pubspecLockBasename), - ).writeAsStringSync(_validPubspecLockContent); + File(path.join(tempDirectory.path, pubspecLockBasename)) + .writeAsStringSync(_validPubspecLockContent); when(() => packageConfig.packages).thenReturn({ veryGoodTestRunnerConfigPackage, @@ -985,13 +952,11 @@ and limitations under the License.'''); test( 'warns when a license is not recognized', withRunner((commandRunner, logger, pubUpdater, printLogs) async { - File( - path.join(tempDirectory.path, pubspecLockBasename), - ).writeAsStringSync(_validPubspecLockContent); + File(path.join(tempDirectory.path, pubspecLockBasename)) + .writeAsStringSync(_validPubspecLockContent); - when( - () => packageConfig.packages, - ).thenReturn({veryGoodTestRunnerConfigPackage}); + when(() => packageConfig.packages) + .thenReturn({veryGoodTestRunnerConfigPackage}); when(() => detectorResult.matches).thenReturn([mitLicenseMatch]); when(() => logger.progress(any())).thenReturn(progress); @@ -1017,15 +982,13 @@ and limitations under the License.'''); test( 'exits when a license is not allowed', withRunner((commandRunner, logger, pubUpdater, printLogs) async { - File( - path.join(tempDirectory.path, pubspecLockBasename), - ).writeAsStringSync(_validPubspecLockContent); + File(path.join(tempDirectory.path, pubspecLockBasename)) + .writeAsStringSync(_validPubspecLockContent); when(() => logger.progress(any())).thenReturn(progress); - when( - () => packageConfig.packages, - ).thenReturn({veryGoodTestRunnerConfigPackage}); + when(() => packageConfig.packages) + .thenReturn({veryGoodTestRunnerConfigPackage}); when(() => detectorResult.matches).thenReturn([mitLicenseMatch]); final result = await commandRunner.run([ @@ -1043,9 +1006,8 @@ and limitations under the License.'''); test( 'when a single license is not allowed', withRunner((commandRunner, logger, pubUpdater, printLogs) async { - File( - path.join(tempDirectory.path, pubspecLockBasename), - ).writeAsStringSync(_validMultiplePubspecLockContent); + File(path.join(tempDirectory.path, pubspecLockBasename)) + .writeAsStringSync(_validMultiplePubspecLockContent); when(() => logger.progress(any())).thenReturn(progress); @@ -1086,9 +1048,8 @@ and limitations under the License.'''); test( 'when a single license is not allowed and forbidden is left empty', withRunner((commandRunner, logger, pubUpdater, printLogs) async { - File( - path.join(tempDirectory.path, pubspecLockBasename), - ).writeAsStringSync(_validMultiplePubspecLockContent); + File(path.join(tempDirectory.path, pubspecLockBasename)) + .writeAsStringSync(_validMultiplePubspecLockContent); when(() => logger.progress(any())).thenReturn(progress); @@ -1131,9 +1092,8 @@ and limitations under the License.'''); test( 'when multiple licenses are not allowed', withRunner((commandRunner, logger, pubUpdater, printLogs) async { - File( - path.join(tempDirectory.path, pubspecLockBasename), - ).writeAsStringSync(_validMultiplePubspecLockContent); + File(path.join(tempDirectory.path, pubspecLockBasename)) + .writeAsStringSync(_validMultiplePubspecLockContent); when(() => logger.progress(any())).thenReturn(progress); @@ -1183,15 +1143,13 @@ and limitations under the License.'''); test( 'warns when a license is not recognized', withRunner((commandRunner, logger, pubUpdater, printLogs) async { - File( - path.join(tempDirectory.path, pubspecLockBasename), - ).writeAsStringSync(_validPubspecLockContent); + File(path.join(tempDirectory.path, pubspecLockBasename)) + .writeAsStringSync(_validPubspecLockContent); when(() => logger.progress(any())).thenReturn(progress); - when( - () => packageConfig.packages, - ).thenReturn({veryGoodTestRunnerConfigPackage}); + when(() => packageConfig.packages) + .thenReturn({veryGoodTestRunnerConfigPackage}); when(() => detectorResult.matches).thenReturn([mitLicenseMatch]); const invalidLicense = 'not_a_valid_license'; @@ -1215,15 +1173,13 @@ and limitations under the License.'''); test( 'exits when a license is forbidden', withRunner((commandRunner, logger, pubUpdater, printLogs) async { - File( - path.join(tempDirectory.path, pubspecLockBasename), - ).writeAsStringSync(_validPubspecLockContent); + File(path.join(tempDirectory.path, pubspecLockBasename)) + .writeAsStringSync(_validPubspecLockContent); when(() => logger.progress(any())).thenReturn(progress); - when( - () => packageConfig.packages, - ).thenReturn({veryGoodTestRunnerConfigPackage}); + when(() => packageConfig.packages) + .thenReturn({veryGoodTestRunnerConfigPackage}); when(() => detectorResult.matches).thenReturn([bsdLicenseMatch]); final result = await commandRunner.run([ @@ -1241,9 +1197,8 @@ and limitations under the License.'''); test( 'when a single license is forbidden', withRunner((commandRunner, logger, pubUpdater, printLogs) async { - File( - path.join(tempDirectory.path, pubspecLockBasename), - ).writeAsStringSync(_validMultiplePubspecLockContent); + File(path.join(tempDirectory.path, pubspecLockBasename)) + .writeAsStringSync(_validMultiplePubspecLockContent); when(() => logger.progress(any())).thenReturn(progress); @@ -1286,9 +1241,8 @@ and limitations under the License.'''); test( 'when a single license is forbidden and allowed is left empty', withRunner((commandRunner, logger, pubUpdater, printLogs) async { - File( - path.join(tempDirectory.path, pubspecLockBasename), - ).writeAsStringSync(_validMultiplePubspecLockContent); + File(path.join(tempDirectory.path, pubspecLockBasename)) + .writeAsStringSync(_validMultiplePubspecLockContent); when(() => logger.progress(any())).thenReturn(progress); @@ -1333,9 +1287,8 @@ and limitations under the License.'''); test( 'when multiple licenses are forbidden', withRunner((commandRunner, logger, pubUpdater, printLogs) async { - File( - path.join(tempDirectory.path, pubspecLockBasename), - ).writeAsStringSync(_validMultiplePubspecLockContent); + File(path.join(tempDirectory.path, pubspecLockBasename)) + .writeAsStringSync(_validMultiplePubspecLockContent); when(() => logger.progress(any())).thenReturn(progress); @@ -1413,13 +1366,11 @@ and limitations under the License.'''); test( 'text format prints packages with license separated by a dash', withRunner((commandRunner, logger, pubUpdater, printLogs) async { - File( - path.join(tempDirectory.path, pubspecLockBasename), - ).writeAsStringSync(_validPubspecLockContent); + File(path.join(tempDirectory.path, pubspecLockBasename)) + .writeAsStringSync(_validPubspecLockContent); - when( - () => packageConfig.packages, - ).thenReturn({veryGoodTestRunnerConfigPackage}); + when(() => packageConfig.packages) + .thenReturn({veryGoodTestRunnerConfigPackage}); when(() => detectorResult.matches).thenReturn([mitLicenseMatch]); when(() => logger.progress(any())).thenReturn(progress); @@ -1446,13 +1397,11 @@ and limitations under the License.'''); test( 'csv format prints packages with license in a CSV format.', withRunner((commandRunner, logger, pubUpdater, printLogs) async { - File( - path.join(tempDirectory.path, pubspecLockBasename), - ).writeAsStringSync(_validPubspecLockContent); + File(path.join(tempDirectory.path, pubspecLockBasename)) + .writeAsStringSync(_validPubspecLockContent); - when( - () => packageConfig.packages, - ).thenReturn({veryGoodTestRunnerConfigPackage}); + when(() => packageConfig.packages) + .thenReturn({veryGoodTestRunnerConfigPackage}); when(() => detectorResult.matches).thenReturn([mitLicenseMatch]); when(() => logger.progress(any())).thenReturn(progress); @@ -1484,9 +1433,8 @@ and limitations under the License.'''); test( 'a single package by name', withRunner((commandRunner, logger, pubUpdater, printLogs) async { - File( - path.join(tempDirectory.path, pubspecLockBasename), - ).writeAsStringSync(_validMultiplePubspecLockContent); + File(path.join(tempDirectory.path, pubspecLockBasename)) + .writeAsStringSync(_validMultiplePubspecLockContent); when(() => logger.progress(any())).thenReturn(progress); @@ -1520,9 +1468,8 @@ and limitations under the License.'''); test( 'multiple packages by name', withRunner((commandRunner, logger, pubUpdater, printLogs) async { - File( - path.join(tempDirectory.path, pubspecLockBasename), - ).writeAsStringSync(_validMultiplePubspecLockContent); + File(path.join(tempDirectory.path, pubspecLockBasename)) + .writeAsStringSync(_validMultiplePubspecLockContent); when(() => logger.progress(any())).thenReturn(progress); @@ -1588,9 +1535,8 @@ and limitations under the License.'''); test( 'when it failed to parse a pubspec.lock file at the target path', withRunner((commandRunner, logger, pubUpdater, printLogs) async { - File( - path.join(tempDirectory.path, pubspecLockBasename), - ).writeAsStringSync(''); + File(path.join(tempDirectory.path, pubspecLockBasename)) + .writeAsStringSync(''); when(() => logger.progress(any())).thenReturn(progress); @@ -1612,9 +1558,8 @@ and limitations under the License.'''); test( 'when no dependencies of type are found', withRunner((commandRunner, logger, pubUpdater, printLogs) async { - File( - path.join(tempDirectory.path, pubspecLockBasename), - ).writeAsStringSync(_emptyPubspecLockContent); + File(path.join(tempDirectory.path, pubspecLockBasename)) + .writeAsStringSync(_emptyPubspecLockContent); when(() => logger.progress(any())).thenReturn(progress); @@ -1636,13 +1581,11 @@ and limitations under the License.'''); test( 'when detectLicense throws an unknown error', withRunner((commandRunner, logger, pubUpdater, printLogs) async { - File( - path.join(tempDirectory.path, pubspecLockBasename), - ).writeAsStringSync(_validPubspecLockContent); + File(path.join(tempDirectory.path, pubspecLockBasename)) + .writeAsStringSync(_validPubspecLockContent); - when( - () => packageConfig.packages, - ).thenReturn({veryGoodTestRunnerConfigPackage}); + when(() => packageConfig.packages) + .thenReturn({veryGoodTestRunnerConfigPackage}); final error = Exception('error'); @@ -1671,9 +1614,8 @@ and limitations under the License.'''); test( 'when there is no package config file', withRunner((commandRunner, logger, pubUpdater, printLogs) async { - File( - path.join(tempDirectory.path, pubspecLockBasename), - ).writeAsStringSync(_validPubspecLockContent); + File(path.join(tempDirectory.path, pubspecLockBasename)) + .writeAsStringSync(_validPubspecLockContent); when(() => logger.progress(any())).thenReturn(progress); @@ -1699,9 +1641,8 @@ and limitations under the License.'''); test( 'when cached package path cannot be found', withRunner((commandRunner, logger, pubUpdater, printLogs) async { - File( - path.join(tempDirectory.path, pubspecLockBasename), - ).writeAsStringSync(_validPubspecLockContent); + File(path.join(tempDirectory.path, pubspecLockBasename)) + .writeAsStringSync(_validPubspecLockContent); when(() => logger.progress(any())).thenReturn(progress); @@ -1726,24 +1667,21 @@ and limitations under the License.'''); test( 'when cached package directory cannot be found', withRunner((commandRunner, logger, pubUpdater, printLogs) async { - File( - path.join(tempDirectory.path, pubspecLockBasename), - ).writeAsStringSync(_validPubspecLockContent); + File(path.join(tempDirectory.path, pubspecLockBasename)) + .writeAsStringSync(_validPubspecLockContent); when(() => logger.progress(any())).thenReturn(progress); - when( - () => packageConfig.packages, - ).thenReturn({veryGoodTestRunnerConfigPackage}); + when(() => packageConfig.packages) + .thenReturn({veryGoodTestRunnerConfigPackage}); final packagePath = path.join( tempDirectory.path, 'inexistent', 'nothing', ); - when( - () => veryGoodTestRunnerConfigPackage.root, - ).thenReturn(Uri.file(packagePath)); + when(() => veryGoodTestRunnerConfigPackage.root) + .thenReturn(Uri.file(packagePath)); final targetPath = tempDirectory.path; final result = await commandRunner.run([ @@ -1766,9 +1704,8 @@ and limitations under the License.'''); test( '''reclassifies member dependencies and reports them at the root''', withRunner((commandRunner, logger, pubUpdater, printLogs) async { - File( - path.join(tempDirectory.path, 'pubspec.yaml'), - ).writeAsStringSync(_workspaceRootPubspecContent); + File(path.join(tempDirectory.path, 'pubspec.yaml')) + .writeAsStringSync(_workspaceRootPubspecContent); File(path.join(tempDirectory.path, 'app', 'pubspec.yaml')) ..createSync(recursive: true) ..writeAsStringSync(_appMemberPubspecContent); @@ -1782,9 +1719,8 @@ and limitations under the License.'''); ) ..createSync(recursive: true) ..writeAsStringSync(_pkgAMemberPubspecContent); - File( - path.join(tempDirectory.path, pubspecLockBasename), - ).writeAsStringSync(_workspacePubspecLockContent); + File(path.join(tempDirectory.path, pubspecLockBasename)) + .writeAsStringSync(_workspacePubspecLockContent); when(() => packageConfig.packages).thenReturn({ veryGoodTestRunnerConfigPackage, @@ -1811,9 +1747,8 @@ and limitations under the License.'''); test( '''lists lock transitives not claimed by any member under --dependency-type transitive''', withRunner((commandRunner, logger, pubUpdater, printLogs) async { - File( - path.join(tempDirectory.path, 'pubspec.yaml'), - ).writeAsStringSync(_workspaceRootPubspecContent); + File(path.join(tempDirectory.path, 'pubspec.yaml')) + .writeAsStringSync(_workspaceRootPubspecContent); File(path.join(tempDirectory.path, 'app', 'pubspec.yaml')) ..createSync(recursive: true) ..writeAsStringSync(_appMemberPubspecContent); @@ -1827,9 +1762,8 @@ and limitations under the License.'''); ) ..createSync(recursive: true) ..writeAsStringSync(_pkgAMemberPubspecContent); - File( - path.join(tempDirectory.path, pubspecLockBasename), - ).writeAsStringSync(_workspacePubspecLockContent); + File(path.join(tempDirectory.path, pubspecLockBasename)) + .writeAsStringSync(_workspacePubspecLockContent); when(() => packageConfig.packages).thenReturn({yamlConfigPackage}); when(() => detectorResult.matches).thenReturn([mitLicenseMatch]); @@ -1855,19 +1789,16 @@ and limitations under the License.'''); test( '''warns and continues when a workspace entry points to a missing directory''', withRunner((commandRunner, logger, pubUpdater, printLogs) async { - File( - path.join(tempDirectory.path, 'pubspec.yaml'), - ).writeAsStringSync(_missingMemberWorkspaceRootPubspecContent); + File(path.join(tempDirectory.path, 'pubspec.yaml')) + .writeAsStringSync(_missingMemberWorkspaceRootPubspecContent); File(path.join(tempDirectory.path, 'app', 'pubspec.yaml')) ..createSync(recursive: true) ..writeAsStringSync(_appMemberPubspecContent); - File( - path.join(tempDirectory.path, pubspecLockBasename), - ).writeAsStringSync(_workspacePubspecLockContent); + File(path.join(tempDirectory.path, pubspecLockBasename)) + .writeAsStringSync(_workspacePubspecLockContent); - when( - () => packageConfig.packages, - ).thenReturn({veryGoodTestRunnerConfigPackage}); + when(() => packageConfig.packages) + .thenReturn({veryGoodTestRunnerConfigPackage}); when(() => detectorResult.matches).thenReturn([mitLicenseMatch]); when(() => logger.progress(any())).thenReturn(progress); @@ -1890,17 +1821,15 @@ and limitations under the License.'''); test( '''uses the injected resolver override to reclassify dependencies''', withRunner((commandRunner, logger, pubUpdater, printLogs) async { - File( - path.join(tempDirectory.path, pubspecLockBasename), - ).writeAsStringSync(_workspacePubspecLockContent); + File(path.join(tempDirectory.path, pubspecLockBasename)) + .writeAsStringSync(_workspacePubspecLockContent); resolveWorkspaceOverride = (_, {required logger}) => { 'very_good_test_runner': PubspecDependencyType.directMain, }; - when( - () => packageConfig.packages, - ).thenReturn({veryGoodTestRunnerConfigPackage}); + when(() => packageConfig.packages) + .thenReturn({veryGoodTestRunnerConfigPackage}); when(() => detectorResult.matches).thenReturn([mitLicenseMatch]); when(() => logger.progress(any())).thenReturn(progress); @@ -1922,9 +1851,8 @@ and limitations under the License.'''); test( '''shows workspace-root guidance when run inside a member with no lock''', withRunner((commandRunner, logger, pubUpdater, printLogs) async { - File( - path.join(tempDirectory.path, 'pubspec.yaml'), - ).writeAsStringSync(_appMemberPubspecContent); + File(path.join(tempDirectory.path, 'pubspec.yaml')) + .writeAsStringSync(_appMemberPubspecContent); when(() => logger.progress(any())).thenReturn(progress); @@ -1950,9 +1878,8 @@ and limitations under the License.'''); 'fails with exit code ${ExitCode.config.code} ' 'when very_good.yaml is malformed', withRunner((commandRunner, logger, pubUpdater, printLogs) async { - File( - path.join(tempDirectory.path, 'very_good.yaml'), - ).writeAsStringSync('- not\n- a\n- map'); + File(path.join(tempDirectory.path, 'very_good.yaml')) + .writeAsStringSync('- not\n- a\n- map'); final result = await commandRunner.run([ ...commandArguments, @@ -1971,12 +1898,10 @@ and limitations under the License.'''); test('applies config values when args were not parsed', () { final argResults = _MockArgResults(); when(() => argResults.wasParsed(any())).thenReturn(false); - when( - () => argResults['ignore-retrieval-failures'], - ).thenReturn(false); - when( - () => argResults['dependency-type'], - ).thenReturn(['direct-main']); + when(() => argResults['ignore-retrieval-failures']) + .thenReturn(false); + when(() => argResults['dependency-type']) + .thenReturn(['direct-main']); when(() => argResults['allowed']).thenReturn([]); when(() => argResults['forbidden']).thenReturn([]); when(() => argResults['skip-packages']).thenReturn([]); @@ -2009,12 +1934,10 @@ and limitations under the License.'''); test('resolves forbidden licenses from config', () { final argResults = _MockArgResults(); when(() => argResults.wasParsed(any())).thenReturn(false); - when( - () => argResults['ignore-retrieval-failures'], - ).thenReturn(false); - when( - () => argResults['dependency-type'], - ).thenReturn(['direct-main']); + when(() => argResults['ignore-retrieval-failures']) + .thenReturn(false); + when(() => argResults['dependency-type']) + .thenReturn(['direct-main']); when(() => argResults['allowed']).thenReturn([]); when(() => argResults['forbidden']).thenReturn([]); when(() => argResults['skip-packages']).thenReturn([]); @@ -2039,12 +1962,10 @@ and limitations under the License.'''); test('CLI arguments take precedence over config values', () { final argResults = _MockArgResults(); when(() => argResults.wasParsed(any())).thenReturn(true); - when( - () => argResults['ignore-retrieval-failures'], - ).thenReturn(false); - when( - () => argResults['dependency-type'], - ).thenReturn(['direct-dev']); + when(() => argResults['ignore-retrieval-failures']) + .thenReturn(false); + when(() => argResults['dependency-type']) + .thenReturn(['direct-dev']); when(() => argResults['allowed']).thenReturn(['BSD']); when(() => argResults['forbidden']).thenReturn([]); when(() => argResults['skip-packages']).thenReturn([]); @@ -2075,12 +1996,10 @@ and limitations under the License.'''); test( 'applies skip-packages value from config', withRunner((commandRunner, logger, pubUpdater, printLogs) async { - File( - path.join(tempDirectory.path, pubspecLockBasename), - ).writeAsStringSync(_validMultiplePubspecLockContent); - File( - path.join(tempDirectory.path, 'very_good.yaml'), - ).writeAsStringSync(''' + File(path.join(tempDirectory.path, pubspecLockBasename)) + .writeAsStringSync(_validMultiplePubspecLockContent); + File(path.join(tempDirectory.path, 'very_good.yaml')) + .writeAsStringSync(''' packages: check: licenses: diff --git a/test/src/commands/packages/commands/get_test.dart b/test/src/commands/packages/commands/get_test.dart index e9a4139b8..ea122b15a 100644 --- a/test/src/commands/packages/commands/get_test.dart +++ b/test/src/commands/packages/commands/get_test.dart @@ -14,7 +14,7 @@ import 'package:very_good_cli/src/very_good_config/very_good_config.dart'; import '../../../../helpers/helpers.dart'; -class _MockArgResults extends Mock implements ArgResults {} +class _MockArgResults extends Mock implements ArgResults; const _expectedPackagesGetUsage = [ 'Get packages in a Dart or Flutter project.\n' @@ -93,9 +93,8 @@ void main() { final tempDirectory = Directory.systemTemp.createTempSync(); addTearDown(() => tempDirectory.deleteSync(recursive: true)); - File( - path.join(tempDirectory.path, 'pubspec.yaml'), - ).writeAsStringSync(''); + File(path.join(tempDirectory.path, 'pubspec.yaml')) + .writeAsStringSync(''); final result = await commandRunner.run([ 'packages', 'get', @@ -111,15 +110,14 @@ void main() { final tempDirectory = Directory.systemTemp.createTempSync(); addTearDown(() => tempDirectory.deleteSync(recursive: true)); - File(path.join(tempDirectory.path, 'pubspec.yaml')).writeAsStringSync( - ''' + File(path.join(tempDirectory.path, 'pubspec.yaml')) + .writeAsStringSync(''' name: example version: 0.1.0 environment: sdk: ^3.13.0 -''', - ); +'''); // Mock flutter process to simulate flutter not being installed Future mockProcess( @@ -189,15 +187,14 @@ sdk: ^3.13.0 final tempDirectory = Directory.systemTemp.createTempSync(); addTearDown(() => tempDirectory.deleteSync(recursive: true)); - File(path.join(tempDirectory.path, 'pubspec.yaml')).writeAsStringSync( - ''' + File(path.join(tempDirectory.path, 'pubspec.yaml')) + .writeAsStringSync(''' name: example version: 0.1.0 environment: sdk: ^3.13.0 - ''', - ); + '''); final result = await commandRunner.run([ 'packages', 'get', @@ -612,12 +609,9 @@ sdk: ^3.13.0 final tempDirectory = Directory.systemTemp.createTempSync(); addTearDown(() => tempDirectory.deleteSync(recursive: true)); - File( - path.join(tempDirectory.path, 'pubspec.yaml'), - ).createSync(); - File( - path.join(tempDirectory.path, 'very_good.yaml'), - ).writeAsStringSync('- not\n- a\n- map'); + File(path.join(tempDirectory.path, 'pubspec.yaml')).createSync(); + File(path.join(tempDirectory.path, 'very_good.yaml')) + .writeAsStringSync('- not\n- a\n- map'); final result = await commandRunner.run([ 'packages', @@ -659,9 +653,7 @@ sdk: ^3.13.0 final argResults = _MockArgResults(); when(() => argResults.wasParsed(any())).thenReturn(true); when(() => argResults['recursive']).thenReturn(false); - when( - () => argResults['ignore'], - ).thenReturn(['cli']); + when(() => argResults['ignore']).thenReturn(['cli']); final options = PackagesGetOptions.parse( argResults, @@ -697,9 +689,8 @@ sdk: ^3.13.0 final tempDirectory = Directory.systemTemp.createTempSync(); addTearDown(() => tempDirectory.deleteSync(recursive: true)); - File( - path.join(tempDirectory.path, 'very_good.yaml'), - ).writeAsStringSync(''' + File(path.join(tempDirectory.path, 'very_good.yaml')) + .writeAsStringSync(''' packages: get: recursive: true @@ -750,9 +741,8 @@ environment: final tempDirectory = Directory.systemTemp.createTempSync(); addTearDown(() => tempDirectory.deleteSync(recursive: true)); - File( - path.join(tempDirectory.path, 'very_good.yaml'), - ).writeAsStringSync(''' + File(path.join(tempDirectory.path, 'very_good.yaml')) + .writeAsStringSync(''' packages: get: recursive: true diff --git a/test/src/commands/test/test_test.dart b/test/src/commands/test/test_test.dart index 4dd2070ac..da7db3040 100644 --- a/test/src/commands/test/test_test.dart +++ b/test/src/commands/test/test_test.dart @@ -15,11 +15,11 @@ import 'package:very_good_cli/src/very_good_config/very_good_config.dart'; import '../../../helpers/helpers.dart'; -class _MockLogger extends Mock implements Logger {} +class _MockLogger extends Mock implements Logger; -class _MockArgResults extends Mock implements ArgResults {} +class _MockArgResults extends Mock implements ArgResults; -class _MockFlutterTestCommand extends Mock implements FlutterTestCommand {} +class _MockFlutterTestCommand extends Mock implements FlutterTestCommand; const expectedTestUsage = [ 'Run `flutter test` in a project. (Check very_good dart test for running `dart test` instead.)\n' @@ -59,7 +59,6 @@ const expectedTestUsage = [ // A concrete class should have methods with body // and we just want to mock this class for the test. -// ignore: one_member_abstracts abstract class FlutterTestCommand { Future> call({ String cwd = '.', @@ -138,9 +137,8 @@ void main() { when(() => argResults['flavor']).thenReturn(null); when(() => argResults['timeout']).thenReturn(null); when(() => argResults['file-reporter']).thenReturn(null); - when( - () => argResults['collect-coverage-from'], - ).thenReturn('imports'); + when(() => argResults['collect-coverage-from']) + .thenReturn('imports'); when(() => argResults.rest).thenReturn([]); }); @@ -194,9 +192,8 @@ void main() { Directory.current = tempDirectory.path; Directory(path.join(Directory.current.path, 'project')).createSync(); - File( - path.join(Directory.current.path, 'project', 'pubspec.yaml'), - ).createSync(); + File(path.join(Directory.current.path, 'project', 'pubspec.yaml')) + .createSync(); final result = await commandRunner.run(['test', '-r']); expect(result, equals(ExitCode.success.code)); @@ -392,9 +389,8 @@ void main() { test( 'completes normally --test-randomize-ordering-seed random', () async { - when( - () => argResults['test-randomize-ordering-seed'], - ).thenReturn('random'); + when(() => argResults['test-randomize-ordering-seed']) + .thenReturn('random'); final result = await testCommand.run(); expect(result, equals(ExitCode.success.code)); verify( @@ -414,9 +410,8 @@ void main() { 'completes normally --test-randomize-ordering-seed 2305182648', () async { const randomSeed = '2305182648'; - when( - () => argResults['test-randomize-ordering-seed'], - ).thenReturn(randomSeed); + when(() => argResults['test-randomize-ordering-seed']) + .thenReturn(randomSeed); final result = await testCommand.run(); expect(result, equals(ExitCode.success.code)); verify( @@ -463,9 +458,8 @@ void main() { }); test('completes normally --dart-define', () async { - when( - () => argResults['dart-define'], - ).thenReturn(['FOO=bar', 'X=42']); + when(() => argResults['dart-define']) + .thenReturn(['FOO=bar', 'X=42']); final result = await testCommand.run(); expect(result, equals(ExitCode.success.code)); verify( @@ -484,9 +478,8 @@ void main() { }); test('completes normally --dart-define-from-file', () async { - when( - () => argResults['dart-define-from-file'], - ).thenReturn(['defines/foo.json', 'bar.env']); + when(() => argResults['dart-define-from-file']) + .thenReturn(['defines/foo.json', 'bar.env']); final result = await testCommand.run(); expect(result, equals(ExitCode.success.code)); verify( @@ -607,9 +600,8 @@ void main() { test( 'completes normally --file-reporter json:test-report.json', () async { - when( - () => argResults['file-reporter'], - ).thenReturn('json:test-report.json'); + when(() => argResults['file-reporter']) + .thenReturn('json:test-report.json'); final result = await testCommand.run(); expect(result, equals(ExitCode.success.code)); verify( @@ -804,9 +796,8 @@ void main() { 'exclude files from coverage when --exclude-coverage is used', () async { when(() => argResults['coverage']).thenReturn(true); - when( - () => argResults['exclude-coverage'], - ).thenReturn('*.g.dart'); + when(() => argResults['exclude-coverage']) + .thenReturn('*.g.dart'); final result = await testCommand.run(); expect(result, equals(ExitCode.success.code)); verify( @@ -826,9 +817,8 @@ void main() { test('exclude files from coverage when multiple globs are passed ' 'via --exclude-coverage', () async { when(() => argResults['coverage']).thenReturn(true); - when( - () => argResults['exclude-coverage'], - ).thenReturn('*.g.dart *.freezed.dart'); + when(() => argResults['exclude-coverage']) + .thenReturn('*.g.dart *.freezed.dart'); final result = await testCommand.run(); expect(result, equals(ExitCode.success.code)); verify( @@ -868,9 +858,8 @@ void main() { 'reports on a different directory when --report-on is supplied', () async { when(() => argResults['min-coverage']).thenReturn('0'); - when( - () => argResults['report-on'], - ).thenReturn(['routes']); + when(() => argResults['report-on']) + .thenReturn(['routes']); final result = await testCommand.run(); expect(result, equals(ExitCode.success.code)); verify( @@ -892,9 +881,8 @@ void main() { 'splits space-separated paths when --report-on "lib test" is supplied', () async { when(() => argResults['min-coverage']).thenReturn('0'); - when( - () => argResults['report-on'], - ).thenReturn(['lib test']); + when(() => argResults['report-on']) + .thenReturn(['lib test']); final result = await testCommand.run(); expect(result, equals(ExitCode.success.code)); verify( @@ -916,9 +904,8 @@ void main() { 'splits comma-separated paths when --report-on "lib,test" is supplied', () async { when(() => argResults['min-coverage']).thenReturn('0'); - when( - () => argResults['report-on'], - ).thenReturn(['lib,test']); + when(() => argResults['report-on']) + .thenReturn(['lib,test']); final result = await testCommand.run(); expect(result, equals(ExitCode.success.code)); verify( @@ -950,9 +937,8 @@ void main() { Directory.current = tempDirectory.path; File(path.join(tempDirectory.path, 'pubspec.yaml')).createSync(); - File( - path.join(tempDirectory.path, 'very_good.yaml'), - ).writeAsStringSync('- not\n- a\n- map'); + File(path.join(tempDirectory.path, 'very_good.yaml')) + .writeAsStringSync('- not\n- a\n- map'); final result = await commandRunner.run(['test']); expect(result, equals(ExitCode.config.code)); @@ -1000,9 +986,8 @@ void main() { test('CLI --file-reporter takes precedence over config value', () { when(() => argResults.wasParsed(any())).thenReturn(false); when(() => argResults.wasParsed('file-reporter')).thenReturn(true); - when( - () => argResults['file-reporter'], - ).thenReturn('json:cli.json'); + when(() => argResults['file-reporter']) + .thenReturn('json:cli.json'); final options = FlutterTestOptions.parse( argResults, @@ -1016,9 +1001,8 @@ void main() { test('falls back to the CLI default when the parsed arg is null ' 'and the config is unset', () { when(() => argResults.wasParsed(any())).thenReturn(true); - when( - () => argResults['collect-coverage-from'], - ).thenReturn(null); + when(() => argResults['collect-coverage-from']) + .thenReturn(null); final options = FlutterTestOptions.parse(argResults); diff --git a/test/src/commands/update_test.dart b/test/src/commands/update_test.dart index 26f71485b..02eb282ac 100644 --- a/test/src/commands/update_test.dart +++ b/test/src/commands/update_test.dart @@ -8,7 +8,7 @@ import 'package:very_good_cli/src/version.dart'; import '../../helpers/helpers.dart'; -class _MockProgress extends Mock implements Progress {} +class _MockProgress extends Mock implements Progress; void main() { const latestVersion = '0.0.0'; @@ -22,9 +22,8 @@ void main() { test( 'handles pub latest version query errors', withRunner((commandRunner, logger, pubUpdater, printLogs) async { - when( - () => pubUpdater.getLatestVersion(any()), - ).thenThrow(Exception('oops')); + when(() => pubUpdater.getLatestVersion(any())) + .thenThrow(Exception('oops')); final result = await commandRunner.run(['update']); expect(result, equals(ExitCode.software.code)); verify(() => logger.progress('Checking for updates')).called(1); @@ -41,9 +40,8 @@ void main() { test( 'handles pub update errors', withRunner((commandRunner, logger, pubUpdater, printLogs) async { - when( - () => pubUpdater.getLatestVersion(any()), - ).thenAnswer((_) async => latestVersion); + when(() => pubUpdater.getLatestVersion(any())) + .thenAnswer((_) async => latestVersion); when( () => pubUpdater.update( packageName: any(named: 'packageName'), @@ -73,9 +71,8 @@ void main() { 'Oh no! Installing this is not possible right now!', ); - when( - () => pubUpdater.getLatestVersion(any()), - ).thenAnswer((_) async => latestVersion); + when(() => pubUpdater.getLatestVersion(any())) + .thenAnswer((_) async => latestVersion); when( () => pubUpdater.update( @@ -105,9 +102,8 @@ void main() { test( 'updates when newer version exists', withRunner((commandRunner, logger, pubUpdater, printLogs) async { - when( - () => pubUpdater.getLatestVersion(any()), - ).thenAnswer((_) async => latestVersion); + when(() => pubUpdater.getLatestVersion(any())) + .thenAnswer((_) async => latestVersion); when( () => pubUpdater.update( packageName: any(named: 'packageName'), @@ -132,9 +128,8 @@ void main() { test( 'does not update when already on latest version', withRunner((commandRunner, logger, pubUpdater, printLogs) async { - when( - () => pubUpdater.getLatestVersion(any()), - ).thenAnswer((_) async => packageVersion); + when(() => pubUpdater.getLatestVersion(any())) + .thenAnswer((_) async => packageVersion); when(() => logger.progress(any())).thenReturn(_MockProgress()); final result = await commandRunner.run(['update']); expect(result, equals(ExitCode.success.code)); diff --git a/test/src/logger_extension_test.dart b/test/src/logger_extension_test.dart index fbafcaf33..99ffed3d0 100644 --- a/test/src/logger_extension_test.dart +++ b/test/src/logger_extension_test.dart @@ -4,9 +4,9 @@ import 'package:test/test.dart'; import 'package:universal_io/io.dart'; import 'package:very_good_cli/src/logger_extension.dart'; -class _MockLogger extends Mock implements Logger {} +class _MockLogger extends Mock implements Logger; -class _MockStdout extends Mock implements Stdout {} +class _MockStdout extends Mock implements Stdout; void main() { group('LoggerX', () { @@ -53,29 +53,26 @@ void main() { ]); }); - test( - '''defaults to `fallbackStdoutTerminalColumns` when there is no terminal''', - () async { - await IOOverrides.runZoned(stdout: () => stdout, () async { - when(() => stdout.hasTerminal).thenReturn(false); - const stdoutException = StdoutException(''); - when(() => stdout.terminalColumns).thenThrow(stdoutException); - - final longWord = Iterable.generate( - fallbackStdoutTerminalColumns, - (_) => '1', - ).join(); - const shortWord = '1'; - - logger.wrap('$longWord $shortWord', print: logger.info); - - verifyInOrder([ - () => logger.info(any(that: equals('$longWord '))), - () => logger.info(any(that: equals('$shortWord '))), - ]); - }); - }, - ); + test('''defaults to `fallbackStdoutTerminalColumns` when there is no terminal''', () async { + await IOOverrides.runZoned(stdout: () => stdout, () async { + when(() => stdout.hasTerminal).thenReturn(false); + const stdoutException = StdoutException(''); + when(() => stdout.terminalColumns).thenThrow(stdoutException); + + final longWord = Iterable.generate( + fallbackStdoutTerminalColumns, + (_) => '1', + ).join(); + const shortWord = '1'; + + logger.wrap('$longWord $shortWord', print: logger.info); + + verifyInOrder([ + () => logger.info(any(that: equals('$longWord '))), + () => logger.info(any(that: equals('$shortWord '))), + ]); + }); + }); test( '''defaults to `terminalColumns` when there is no length''', @@ -101,20 +98,17 @@ void main() { }, ); - test( - '''throws when an unknown exception occurs when reading `stdout.terminalColumns`''', - () async { - await IOOverrides.runZoned(stdout: () => stdout, () async { - final unknownException = Exception(); - when(() => stdout.terminalColumns).thenThrow(unknownException); + test('''throws when an unknown exception occurs when reading `stdout.terminalColumns`''', () async { + await IOOverrides.runZoned(stdout: () => stdout, () async { + final unknownException = Exception(); + when(() => stdout.terminalColumns).thenThrow(unknownException); - expect( - () => logger.wrap('test', print: logger.info), - throwsA(equals(unknownException)), - ); - }); - }, - ); + expect( + () => logger.wrap('test', print: logger.info), + throwsA(equals(unknownException)), + ); + }); + }); }); }); } diff --git a/test/src/mcp/mcp_command_test.dart b/test/src/mcp/mcp_command_test.dart index d31617f02..6e3889344 100644 --- a/test/src/mcp/mcp_command_test.dart +++ b/test/src/mcp/mcp_command_test.dart @@ -16,7 +16,7 @@ class _MockServerFactory extends Mock { MCPServer call({required StreamChannel channel}); } -class _FakeStreamChannel extends Fake implements StreamChannel {} +class _FakeStreamChannel extends Fake implements StreamChannel; void main() { group('MCPCommand', () { @@ -39,9 +39,8 @@ void main() { registerFallbackValue(StackTrace.current); registerFallbackValue(_FakeStreamChannel()); - when( - () => serverFactory(channel: any(named: 'channel')), - ).thenAnswer((_) => server); + when(() => serverFactory(channel: any(named: 'channel'))) + .thenAnswer((_) => server); }); test('should have correct command name', () { @@ -93,13 +92,12 @@ Start the MCP (Model Context Protocol) server. WARNING: This is an experimental test('run() uses default channel factory when not provided', () async { final defaultFactoryChannelController = StreamChannelController(); - when(() => serverFactory(channel: any(named: 'channel'))).thenAnswer(( - invocation, - ) { - return VeryGoodMCPServer( - channel: defaultFactoryChannelController.foreign, - ); - }); + when(() => serverFactory(channel: any(named: 'channel'))) + .thenAnswer((invocation) { + return VeryGoodMCPServer( + channel: defaultFactoryChannelController.foreign, + ); + }); final command = MCPCommand(serverFactory: serverFactory.call); diff --git a/test/src/mcp/mcp_server_test.dart b/test/src/mcp/mcp_server_test.dart index 6c36ce9a3..c3d1a8e14 100644 --- a/test/src/mcp/mcp_server_test.dart +++ b/test/src/mcp/mcp_server_test.dart @@ -11,8 +11,7 @@ import 'package:test/test.dart'; import 'package:very_good_cli/src/command_runner.dart'; import 'package:very_good_cli/src/mcp/mcp_server.dart'; -class _MockVeryGoodCommandRunner extends Mock - implements VeryGoodCommandRunner {} +class _MockVeryGoodCommandRunner extends Mock implements VeryGoodCommandRunner; int _idCounter = 1; @@ -101,9 +100,8 @@ void main() { CallToolRequest(name: 'dummyTool', arguments: const {}), ); - when( - () => mockCommandRunner.run(any()), - ).thenAnswer((_) async => ExitCode.success.code); + when(() => mockCommandRunner.run(any())) + .thenAnswer((_) async => ExitCode.success.code); // This is the handshake that // MUST happen before any other requests, to fix the timeout. @@ -280,16 +278,12 @@ void main() { final capturedArgs = verify(() => mockCommandRunner.run(captureAny())).captured.first as List; - expect( - capturedArgs, - equals(['create', 'docs_site', 'my_docs']), - ); + expect(capturedArgs, equals(['create', 'docs_site', 'my_docs'])); }); test('handles command runner failure', () async { - when( - () => mockCommandRunner.run(any()), - ).thenAnswer((_) async => ExitCode.software.code); + when(() => mockCommandRunner.run(any())) + .thenAnswer((_) async => ExitCode.software.code); final response = await sendRequest( CallToolRequest.methodName, @@ -467,9 +461,8 @@ void main() { }); test('handles command failure', () async { - when( - () => mockCommandRunner.run(any()), - ).thenAnswer((_) async => ExitCode.software.code); + when(() => mockCommandRunner.run(any())) + .thenAnswer((_) async => ExitCode.software.code); final response = await sendRequest( CallToolRequest.methodName, _params(CallToolRequest(name: 'test', arguments: {})), @@ -490,10 +483,7 @@ void main() { await sendRequest( CallToolRequest.methodName, _params( - CallToolRequest( - name: 'test', - arguments: {'timeout_seconds': 120}, - ), + CallToolRequest(name: 'test', arguments: {'timeout_seconds': 120}), ), ); @@ -813,9 +803,8 @@ void main() { }); test('omits the output block when nothing was captured', () async { - when( - () => mockCommandRunner.run(any()), - ).thenAnswer((_) async => ExitCode.success.code); + when(() => mockCommandRunner.run(any())) + .thenAnswer((_) async => ExitCode.success.code); final response = await sendRequest( CallToolRequest.methodName, diff --git a/test/src/pubspec_workspace/pubspec_workspace_test.dart b/test/src/pubspec_workspace/pubspec_workspace_test.dart index 1b3ec8d94..4f4c0d231 100644 --- a/test/src/pubspec_workspace/pubspec_workspace_test.dart +++ b/test/src/pubspec_workspace/pubspec_workspace_test.dart @@ -7,15 +7,14 @@ import 'package:test/test.dart'; import 'package:very_good_cli/src/pubspec/pubspec.dart'; import 'package:very_good_cli/src/pubspec_workspace/pubspec_workspace.dart'; -class _MockLogger extends Mock implements Logger {} +class _MockLogger extends Mock implements Logger; void main() { /// Writes a `pubspec.yaml` with [content] into a subdirectory [name] /// (which maybe a nested path) of [root], creating directories as needed. Directory writePubspec(Directory root, String name, String content) { - final directory = Directory( - path.join(root.path, name), - )..createSync(recursive: true); + final directory = Directory(path.join(root.path, name)) + ..createSync(recursive: true); File(path.join(directory.path, 'pubspec.yaml')).writeAsStringSync(content); return directory; } @@ -41,9 +40,8 @@ void main() { }); test('returns null and warns when the root pubspec is unparseable', () { - File( - path.join(tempDirectory.path, 'pubspec.yaml'), - ).writeAsStringSync('{{{ not valid yaml'); + File(path.join(tempDirectory.path, 'pubspec.yaml')) + .writeAsStringSync('{{{ not valid yaml'); final result = resolveWorkspaceDependencies( tempDirectory, @@ -184,10 +182,8 @@ dependencies: }); }); - test( - 'resolves a cross-member type conflict via precedence main > dev', - () { - writePubspec(tempDirectory, '.', ''' + test('resolves a cross-member type conflict via precedence main > dev', () { + writePubspec(tempDirectory, '.', ''' name: workspace_root environment: sdk: ^3.11.0 @@ -195,7 +191,7 @@ workspace: - app - packages/pkg_a '''); - writePubspec(tempDirectory, 'app', ''' + writePubspec(tempDirectory, 'app', ''' name: app resolution: workspace environment: @@ -203,7 +199,7 @@ environment: dependencies: shared: ^1.0.0 '''); - writePubspec(tempDirectory, 'packages/pkg_a', ''' + writePubspec(tempDirectory, 'packages/pkg_a', ''' name: pkg_a resolution: workspace environment: @@ -212,17 +208,13 @@ dev_dependencies: shared: ^1.0.0 '''); - final result = resolveWorkspaceDependencies( - tempDirectory, - logger: logger, - ); + final result = resolveWorkspaceDependencies( + tempDirectory, + logger: logger, + ); - expect( - result!['shared'], - PubspecDependencyType.directMain, - ); - }, - ); + expect(result!['shared'], PubspecDependencyType.directMain); + }); test( 'resolves a cross-member type conflict via precedence dev > overridden', @@ -257,10 +249,7 @@ dependency_overrides: logger: logger, ); - expect( - result!['shared'], - PubspecDependencyType.directDev, - ); + expect(result!['shared'], PubspecDependencyType.directDev); }, ); @@ -297,10 +286,7 @@ dependency_overrides: logger: logger, ); - expect( - result!['shared'], - PubspecDependencyType.directMain, - ); + expect(result!['shared'], PubspecDependencyType.directMain); }, ); @@ -423,9 +409,8 @@ dependencies: // A glob-matched directory without a pubspec.yaml is silently skipped: // globs like `packages/*` legitimately co-exist with documentation or // fixture folders and should not emit warnings for them. - Directory( - path.join(tempDirectory.path, 'packages', 'not_a_package'), - ).createSync(recursive: true); + Directory(path.join(tempDirectory.path, 'packages', 'not_a_package')) + .createSync(recursive: true); final result = resolveWorkspaceDependencies( tempDirectory, @@ -459,11 +444,7 @@ dependencies: '''); // A pubspec.yaml is present but unparseable — the review still wants // this surfaced as a warning even under a glob. - writePubspec( - tempDirectory, - 'packages/broken', - '{{{ not valid yaml', - ); + writePubspec(tempDirectory, 'packages/broken', '{{{ not valid yaml'); final result = resolveWorkspaceDependencies( tempDirectory, @@ -475,10 +456,8 @@ dependencies: }, ); - test( - 'silently skips a glob entry that cannot be listed', - () { - writePubspec(tempDirectory, '.', ''' + test('silently skips a glob entry that cannot be listed', () { + writePubspec(tempDirectory, '.', ''' name: workspace_root environment: sdk: ^3.11.0 @@ -486,7 +465,7 @@ workspace: - app - blocked/* '''); - writePubspec(tempDirectory, 'app', ''' + writePubspec(tempDirectory, 'app', ''' name: app resolution: workspace environment: @@ -494,21 +473,20 @@ environment: dependencies: path: ^1.9.0 '''); - // A file where the glob expects a directory makes listing throw a - // FileSystemException, which is treated as no match. Since the entry - // is a glob, a no-match is silent (an empty `blocked/*` is a - // legitimate configuration). - File(path.join(tempDirectory.path, 'blocked')).writeAsStringSync(''); + // A file where the glob expects a directory makes listing throw a + // FileSystemException, which is treated as no match. Since the entry + // is a glob, a no-match is silent (an empty `blocked/*` is a + // legitimate configuration). + File(path.join(tempDirectory.path, 'blocked')).writeAsStringSync(''); - final result = resolveWorkspaceDependencies( - tempDirectory, - logger: logger, - ); + final result = resolveWorkspaceDependencies( + tempDirectory, + logger: logger, + ); - expect(result, {'path': PubspecDependencyType.directMain}); - verifyNever(() => logger.warn(any())); - }, - ); + expect(result, {'path': PubspecDependencyType.directMain}); + verifyNever(() => logger.warn(any())); + }); test('warns and continues when a workspace entry matches no directory', () { writePubspec(tempDirectory, '.', ''' @@ -593,27 +571,24 @@ flutter: verifyNever(() => logger.warn(any())); }); - test( - 'discovers a workspace declared only in the root ' - 'pubspec_overrides.yaml', - () { - // The root pubspec.yaml has no workspace declaration; Pub allows the - // workspace list to live in pubspec_overrides.yaml instead. If we - // ignore the overrides file we return null and the licenses command - // falls back to the lockfile (where every member dependency is - // transitive) — that's the failure mode this test guards against. - writePubspec(tempDirectory, '.', ''' + test('discovers a workspace declared only in the root ' + 'pubspec_overrides.yaml', () { + // The root pubspec.yaml has no workspace declaration; Pub allows the + // workspace list to live in pubspec_overrides.yaml instead. If we + // ignore the overrides file we return null and the licenses command + // falls back to the lockfile (where every member dependency is + // transitive) — that's the failure mode this test guards against. + writePubspec(tempDirectory, '.', ''' name: workspace_root environment: sdk: ^3.11.0 '''); - File( - path.join(tempDirectory.path, 'pubspec_overrides.yaml'), - ).writeAsStringSync(''' + File(path.join(tempDirectory.path, 'pubspec_overrides.yaml')) + .writeAsStringSync(''' workspace: - app '''); - writePubspec(tempDirectory, 'app', ''' + writePubspec(tempDirectory, 'app', ''' name: app resolution: workspace environment: @@ -622,14 +597,13 @@ dependencies: path: ^1.9.0 '''); - final result = resolveWorkspaceDependencies( - tempDirectory, - logger: logger, - ); + final result = resolveWorkspaceDependencies( + tempDirectory, + logger: logger, + ); - expect(result, {'path': PubspecDependencyType.directMain}); - }, - ); + expect(result, {'path': PubspecDependencyType.directMain}); + }); test( "applies a member's pubspec_overrides.yaml before walking further", @@ -652,9 +626,8 @@ environment: dependencies: path: ^1.9.0 '''); - File( - path.join(tempDirectory.path, 'app', 'pubspec_overrides.yaml'), - ).writeAsStringSync(''' + File(path.join(tempDirectory.path, 'app', 'pubspec_overrides.yaml')) + .writeAsStringSync(''' workspace: - nested '''); @@ -679,13 +652,11 @@ dependencies: }, ); - test( - 'pubspec_overrides.yaml replaces dependency_overrides entirely', - () { - // The overrides file replaces, not merges — the pubspec.yaml - // dependency_overrides entry must be dropped in favor of the one in - // pubspec_overrides.yaml. - writePubspec(tempDirectory, '.', ''' + test('pubspec_overrides.yaml replaces dependency_overrides entirely', () { + // The overrides file replaces, not merges — the pubspec.yaml + // dependency_overrides entry must be dropped in favor of the one in + // pubspec_overrides.yaml. + writePubspec(tempDirectory, '.', ''' name: workspace_root environment: sdk: ^3.11.0 @@ -694,43 +665,38 @@ workspace: dependency_overrides: meta: ^1.9.0 '''); - File( - path.join(tempDirectory.path, 'pubspec_overrides.yaml'), - ).writeAsStringSync(''' + File(path.join(tempDirectory.path, 'pubspec_overrides.yaml')) + .writeAsStringSync(''' dependency_overrides: args: ^2.4.0 '''); - writePubspec(tempDirectory, 'app', ''' + writePubspec(tempDirectory, 'app', ''' name: app resolution: workspace environment: sdk: ^3.11.0 '''); - final result = resolveWorkspaceDependencies( - tempDirectory, - logger: logger, - ); + final result = resolveWorkspaceDependencies( + tempDirectory, + logger: logger, + ); - expect(result, {'args': PubspecDependencyType.directOverridden}); - }, - ); + expect(result, {'args': PubspecDependencyType.directOverridden}); + }); - test( - 'falls back to pubspec.yaml alone when pubspec_overrides.yaml is ' - 'unparseable', - () { - writePubspec(tempDirectory, '.', ''' + test('falls back to pubspec.yaml alone when pubspec_overrides.yaml is ' + 'unparseable', () { + writePubspec(tempDirectory, '.', ''' name: workspace_root environment: sdk: ^3.11.0 workspace: - app '''); - File( - path.join(tempDirectory.path, 'pubspec_overrides.yaml'), - ).writeAsStringSync('{{{ not valid yaml'); - writePubspec(tempDirectory, 'app', ''' + File(path.join(tempDirectory.path, 'pubspec_overrides.yaml')) + .writeAsStringSync('{{{ not valid yaml'); + writePubspec(tempDirectory, 'app', ''' name: app resolution: workspace environment: @@ -739,14 +705,13 @@ dependencies: path: ^1.9.0 '''); - final result = resolveWorkspaceDependencies( - tempDirectory, - logger: logger, - ); + final result = resolveWorkspaceDependencies( + tempDirectory, + logger: logger, + ); - expect(result, {'path': PubspecDependencyType.directMain}); - }, - ); + expect(result, {'path': PubspecDependencyType.directMain}); + }); test('returns an empty map when no member declares direct deps', () { writePubspec(tempDirectory, '.', ''' @@ -813,9 +778,8 @@ name: app environment: sdk: ^3.11.0 '''); - File( - path.join(tempDirectory.path, 'pubspec_overrides.yaml'), - ).writeAsStringSync(''' + File(path.join(tempDirectory.path, 'pubspec_overrides.yaml')) + .writeAsStringSync(''' resolution: workspace '''); @@ -835,9 +799,8 @@ environment: // The override clears the resolution (an empty overrides file that // does not set resolution leaves the pubspec.yaml value alone, so we // set it to something other than 'workspace' to force replacement). - File( - path.join(tempDirectory.path, 'pubspec_overrides.yaml'), - ).writeAsStringSync(''' + File(path.join(tempDirectory.path, 'pubspec_overrides.yaml')) + .writeAsStringSync(''' resolution: none '''); diff --git a/test/src/very_good_config/very_good_config_test.dart b/test/src/very_good_config/very_good_config_test.dart index b85408ece..d97f107fa 100644 --- a/test/src/very_good_config/very_good_config_test.dart +++ b/test/src/very_good_config/very_good_config_test.dart @@ -10,7 +10,7 @@ import 'package:path/path.dart' as p; import 'package:test/test.dart'; import 'package:very_good_cli/src/very_good_config/very_good_config.dart'; -class _MockLogger extends Mock implements Logger {} +class _MockLogger extends Mock implements Logger; void main() { group(VeryGoodConfig, () { @@ -457,15 +457,15 @@ packages: test('parses min-coverage at the boundaries', () { expect( - VeryGoodConfig.fromString( - 'test:\n min_coverage: 0', - ).test.minCoverage, + VeryGoodConfig.fromString('test:\n min_coverage: 0') + .test + .minCoverage, equals('0'), ); expect( - VeryGoodConfig.fromString( - 'test:\n min_coverage: 100', - ).test.minCoverage, + VeryGoodConfig.fromString('test:\n min_coverage: 100') + .test + .minCoverage, equals('100'), ); }); @@ -530,12 +530,11 @@ packages: }); test('reads config from the starting directory', () { - File(p.join(nestedDir.path, veryGoodConfigFileName)).writeAsStringSync( - ''' + File(p.join(nestedDir.path, veryGoodConfigFileName)) + .writeAsStringSync(''' test: min_coverage: 80 -''', - ); +'''); final config = VeryGoodConfig.load(nestedDir, logger: logger); @@ -558,12 +557,11 @@ test: test: min_coverage: 90 '''); - File(p.join(nestedDir.path, veryGoodConfigFileName)).writeAsStringSync( - ''' + File(p.join(nestedDir.path, veryGoodConfigFileName)) + .writeAsStringSync(''' test: min_coverage: 80 -''', - ); +'''); final config = VeryGoodConfig.load(nestedDir, logger: logger); @@ -580,9 +578,8 @@ test: test( 'logs an error and returns null when very_good.yaml is malformed', () { - File( - p.join(tempDir.path, veryGoodConfigFileName), - ).writeAsStringSync('- not\n- a\n- map'); + File(p.join(tempDir.path, veryGoodConfigFileName)) + .writeAsStringSync('- not\n- a\n- map'); final config = VeryGoodConfig.load(tempDir, logger: logger); @@ -598,9 +595,8 @@ test: test( 'logs an error and returns null when the closest file is malformed', () { - File( - p.join(nestedDir.path, veryGoodConfigFileName), - ).writeAsStringSync('- not\n- a\n- map'); + File(p.join(nestedDir.path, veryGoodConfigFileName)) + .writeAsStringSync('- not\n- a\n- map'); final config = VeryGoodConfig.load(nestedDir, logger: logger); diff --git a/tool/spdx_license/hooks/pre_gen.dart b/tool/spdx_license/hooks/pre_gen.dart index 96d0d7d5d..c94efb19d 100644 --- a/tool/spdx_license/hooks/pre_gen.dart +++ b/tool/spdx_license/hooks/pre_gen.dart @@ -31,14 +31,13 @@ const _spdxTargetPath = 'license-list-data-main/json/details'; /// {@endtemplate} class GenerateSpdxLicenseException implements Exception { /// {@macro generate_spdx_license_exception} - const GenerateSpdxLicenseException(String message) - : message = '[spdx_license] $message'; + const new(String message) : message = '[spdx_license] $message'; final String message; } /// {@macro pre_gen} -Future run(HookContext context) async => preGen(context); +Future run(HookContext context) => preGen(context); /// {@template pre_gen} /// Populates the context `licenses` variable with the SPDX license list, and diff --git a/tool/spdx_license/hooks/pubspec.yaml b/tool/spdx_license/hooks/pubspec.yaml index 338beacb7..4c5ae80d3 100644 --- a/tool/spdx_license/hooks/pubspec.yaml +++ b/tool/spdx_license/hooks/pubspec.yaml @@ -18,4 +18,4 @@ dependencies: dev_dependencies: mocktail: ^1.0.3 test: ^1.30.0 - very_good_analysis: ^10.3.0 + very_good_analysis: ^11.0.0-rc.1 diff --git a/tool/spdx_license/hooks/test/pre_gen_test.dart b/tool/spdx_license/hooks/test/pre_gen_test.dart index 1ae5b4f13..43d5574ef 100644 --- a/tool/spdx_license/hooks/test/pre_gen_test.dart +++ b/tool/spdx_license/hooks/test/pre_gen_test.dart @@ -8,20 +8,20 @@ import 'package:test/test.dart'; import '../pre_gen.dart' as pre_gen; -class _MockClient extends Mock implements http.Client {} +class _MockClient extends Mock implements http.Client; -class _MockResponse extends Mock implements http.Response {} +class _MockResponse extends Mock implements http.Response; -class _MockZipDecoder extends Mock implements ZipDecoder {} +class _MockZipDecoder extends Mock implements ZipDecoder; -class _MockArchive extends Mock implements Archive {} +class _MockArchive extends Mock implements Archive; -class _MockLogger extends Mock implements Logger {} +class _MockLogger extends Mock implements Logger; -class _MockProgress extends Mock implements Progress {} +class _MockProgress extends Mock implements Progress; class _TestHookContext implements HookContext { - _TestHookContext({required this._logger}); + new({required this._logger}); final Logger _logger; @@ -122,11 +122,7 @@ void main() { when(() => zipDecoder.decodeBytes(bodyBytes)).thenReturn(archive); when(() => archive.files).thenReturn([]); - await pre_gen.preGen( - context, - client: client, - zipDecoder: zipDecoder, - ); + await pre_gen.preGen(context, client: client, zipDecoder: zipDecoder); verify(() => progress.complete('Found 0 SPDX licenses')).called(1); }); @@ -145,11 +141,7 @@ void main() { when(() => response.bodyBytes).thenReturn(bodyBytes); when(() => zipDecoder.decodeBytes(bodyBytes)).thenThrow('error'); - await pre_gen.preGen( - context, - client: client, - zipDecoder: zipDecoder, - ); + await pre_gen.preGen(context, client: client, zipDecoder: zipDecoder); verify(() => progress.cancel()).called(1); }); @@ -174,11 +166,7 @@ void main() { const error = 'an error'; when(() => zipDecoder.decodeBytes(bodyBytes)).thenThrow(error); - await pre_gen.preGen( - context, - client: client, - zipDecoder: zipDecoder, - ); + await pre_gen.preGen(context, client: client, zipDecoder: zipDecoder); const errorMessage = '''[spdx_license] Failed to decode the SPDX license list, received error: $error'''; diff --git a/tool/spdx_license/pubspec.yaml b/tool/spdx_license/pubspec.yaml index 13538bcd3..6378b488d 100644 --- a/tool/spdx_license/pubspec.yaml +++ b/tool/spdx_license/pubspec.yaml @@ -10,4 +10,4 @@ environment: dev_dependencies: test: ^1.25.2 - very_good_analysis: ^10.3.0 + very_good_analysis: ^11.0.0-rc.1