diff --git a/packages/dart_frog_cli/e2e/test/daemon/dev_server_domain_test.dart b/packages/dart_frog_cli/e2e/test/daemon/dev_server_domain_test.dart index 306ce3904..55175c15d 100644 --- a/packages/dart_frog_cli/e2e/test/daemon/dev_server_domain_test.dart +++ b/packages/dart_frog_cli/e2e/test/daemon/dev_server_domain_test.dart @@ -191,8 +191,9 @@ void main() { ); }); - testServer(port: project1Server2Port, 'GET / on project 1 server 2', - (host) async { + testServer(port: project1Server2Port, 'GET / on project 1 server 2', ( + host, + ) async { final response = await http.get(Uri.parse(host)); expect(response.statusCode, equals(HttpStatus.ok)); expect(response.body, equals('Welcome to Dart Frog!')); @@ -233,8 +234,9 @@ void main() { expect(response.isSuccess, isTrue); }); - testServer(port: project2ServerPort, 'GET /new_route on project 2', - (host) async { + testServer(port: project2ServerPort, 'GET /new_route on project 2', ( + host, + ) async { final response = await http.get(Uri.parse(host)); expect(response.statusCode, equals(HttpStatus.ok)); expect(response.headers, contains('date')); @@ -245,27 +247,27 @@ void main() { }); test('try staggered-stop a dev server on project 1', () async { - final (response1, response2) = - await daemonStdio.sendStaggeredDaemonRequest( - ( - DaemonRequest( - id: '${++requestCount}', - domain: 'dev_server', - method: 'stop', - params: { - 'applicationId': project1Server1Id, - }, - ), - DaemonRequest( - id: '${++requestCount}', - domain: 'dev_server', - method: 'stop', - params: { - 'applicationId': project1Server1Id, - }, - ), - ), - ); + final (response1, response2) = await daemonStdio + .sendStaggeredDaemonRequest( + ( + DaemonRequest( + id: '${++requestCount}', + domain: 'dev_server', + method: 'stop', + params: { + 'applicationId': project1Server1Id, + }, + ), + DaemonRequest( + id: '${++requestCount}', + domain: 'dev_server', + method: 'stop', + params: { + 'applicationId': project1Server1Id, + }, + ), + ), + ); expect(response1.isSuccess, isTrue); expect(response1.result!['exitCode'], equals(0)); @@ -305,16 +307,18 @@ void main() { }); testServer( - // TODO(renancaraujo): this fails on linux: https://github.com/dart-frog-dev/dart_frog/issues/807 - skip: Platform.isLinux, - 'GET on project 1 server 1: connection refused', (host) async { - final responseFuture = http.get(Uri.parse(host)); - - await expectLater( - responseFuture, - throwsA(isA()), - ); - }); + // TODO(renancaraujo): this fails on linux: https://github.com/dart-frog-dev/dart_frog/issues/807 + skip: Platform.isLinux, + 'GET on project 1 server 1: connection refused', + (host) async { + final responseFuture = http.get(Uri.parse(host)); + + await expectLater( + responseFuture, + throwsA(isA()), + ); + }, + ); testServer( port: project2ServerPort, diff --git a/packages/dart_frog_cli/e2e/test/daemon/route_configuration_domain_test.dart b/packages/dart_frog_cli/e2e/test/daemon/route_configuration_domain_test.dart index 2e18e0ccf..a0274fe34 100644 --- a/packages/dart_frog_cli/e2e/test/daemon/route_configuration_domain_test.dart +++ b/packages/dart_frog_cli/e2e/test/daemon/route_configuration_domain_test.dart @@ -236,27 +236,27 @@ void main() { }); test('staggered-stop watcher', () async { - final (response1, response2) = - await daemonStdio.sendStaggeredDaemonRequest( - ( - DaemonRequest( - id: '${requestCount++}', - domain: 'route_configuration', - method: 'watcherStop', - params: { - 'watcherId': projectWatcherId, - }, - ), - DaemonRequest( - id: '${requestCount++}', - domain: 'route_configuration', - method: 'watcherStop', - params: { - 'watcherId': projectWatcherId, - }, - ), - ), - ); + final (response1, response2) = await daemonStdio + .sendStaggeredDaemonRequest( + ( + DaemonRequest( + id: '${requestCount++}', + domain: 'route_configuration', + method: 'watcherStop', + params: { + 'watcherId': projectWatcherId, + }, + ), + DaemonRequest( + id: '${requestCount++}', + domain: 'route_configuration', + method: 'watcherStop', + params: { + 'watcherId': projectWatcherId, + }, + ), + ), + ); expect(response1.isSuccess, isTrue); expect(response1.result?['exitCode'], equals(0)); diff --git a/packages/dart_frog_cli/e2e/test/helpers/dart_frog_daemon.dart b/packages/dart_frog_cli/e2e/test/helpers/dart_frog_daemon.dart index 9aa31fbc6..e3d3494e5 100644 --- a/packages/dart_frog_cli/e2e/test/helpers/dart_frog_daemon.dart +++ b/packages/dart_frog_cli/e2e/test/helpers/dart_frog_daemon.dart @@ -69,8 +69,11 @@ class DaemonStdioHelper { Duration timeout = _defaultTimeout, Matcher? withParamsThat, }) async { - var wrappedMatcher = isA() - .having((e) => '${e.domain}.${e.event}', 'is $methodKey', methodKey); + var wrappedMatcher = isA().having( + (e) => '${e.domain}.${e.event}', + 'is $methodKey', + methodKey, + ); if (withParamsThat != null) { wrappedMatcher = wrappedMatcher.having( @@ -237,7 +240,7 @@ class DaemonStdioHelper { /// A matcher that matches a [DaemonMessage] to a daemon stdout line. class _MatchMessageToStdoutLine extends CustomMatcher { _MatchMessageToStdoutLine(Matcher matcher) - : super('Message to stdout line', 'message', matcher); + : super('Message to stdout line', 'message', matcher); @override Object? featureValueOf(dynamic actual) { diff --git a/packages/dart_frog_cli/e2e/test/helpers/dart_frog_new.dart b/packages/dart_frog_cli/e2e/test/helpers/dart_frog_new.dart index 2659e3a64..99268c2b2 100644 --- a/packages/dart_frog_cli/e2e/test/helpers/dart_frog_new.dart +++ b/packages/dart_frog_cli/e2e/test/helpers/dart_frog_new.dart @@ -7,22 +7,20 @@ import 'run_process.dart'; Future dartFrogNewRoute( String routePath, { required Directory directory, -}) => - _dartFrogNew( - routePath: routePath, - what: 'route', - directory: directory, - ); +}) => _dartFrogNew( + routePath: routePath, + what: 'route', + directory: directory, +); Future dartFrogNewMiddleware( String routePath, { required Directory directory, -}) => - _dartFrogNew( - routePath: routePath, - what: 'middleware', - directory: directory, - ); +}) => _dartFrogNew( + routePath: routePath, + what: 'middleware', + directory: directory, +); Future _dartFrogNew({ required String routePath, diff --git a/packages/dart_frog_cli/e2e/test/helpers/files.dart b/packages/dart_frog_cli/e2e/test/helpers/files.dart index f4f942cc9..97a0f8c36 100644 --- a/packages/dart_frog_cli/e2e/test/helpers/files.dart +++ b/packages/dart_frog_cli/e2e/test/helpers/files.dart @@ -11,9 +11,9 @@ final doesNotExist = FileExistsMatcher(isFalse); class FileExistsMatcher extends CustomMatcher { FileExistsMatcher(Matcher matcher) - : super( - 'File exists', - 'file exists', - isA().having((p) => p.existsSync(), 'exists', matcher), - ); + : super( + 'File exists', + 'file exists', + isA().having((p) => p.existsSync(), 'exists', matcher), + ); } diff --git a/packages/dart_frog_cli/e2e/test/new_test.dart b/packages/dart_frog_cli/e2e/test/new_test.dart index cf68b435f..445e99adc 100644 --- a/packages/dart_frog_cli/e2e/test/new_test.dart +++ b/packages/dart_frog_cli/e2e/test/new_test.dart @@ -64,8 +64,9 @@ void main() { }); test('Creates a index route for an existing directory', () async { - Directory(path.join(routesDirectory.path, 'nested')) - .createSync(recursive: true); + Directory( + path.join(routesDirectory.path, 'nested'), + ).createSync(recursive: true); await dartFrogNewRoute('/nested', directory: projectDirectory); @@ -118,8 +119,9 @@ void main() { 'Creates route normally when there is a non-dart file with the same ' 'route path', () async { - File(path.join(routesDirectory.path, 'something.py')) - .createSync(recursive: true); + File( + path.join(routesDirectory.path, 'something.py'), + ).createSync(recursive: true); await dartFrogNewRoute('/something', directory: projectDirectory); @@ -222,14 +224,16 @@ void main() { test('Excuse existing endpoints (existing rogue route)', () async { await dartFrogNewRoute('/existing_rogue', directory: projectDirectory); - Directory(path.join(routesDirectory.path, 'existing_rogue')) - .createSync(recursive: true); + Directory( + path.join(routesDirectory.path, 'existing_rogue'), + ).createSync(recursive: true); await expectLater( () => dartFrogNewRoute('/existing_rogue', directory: projectDirectory), failsWith( - stderr: 'Failed to create route: Rogue route detected. ' + stderr: + 'Failed to create route: Rogue route detected. ' 'Rename routes${slash}existing_rogue.dart to ' 'routes${slash}existing_rogue${slash}index.dart.', ), @@ -242,8 +246,9 @@ void main() { directory: projectDirectory, ); - File(path.join(routesDirectory.path, 'conflicting_route/index.dart')) - .createSync(recursive: true); + File( + path.join(routesDirectory.path, 'conflicting_route/index.dart'), + ).createSync(recursive: true); await expectLater( () async => dartFrogNewRoute( @@ -251,7 +256,8 @@ void main() { directory: projectDirectory, ), failsWith( - stderr: 'Failed to create route: ' + stderr: + 'Failed to create route: ' 'Route conflict detected. ' 'routes${slash}conflicting_route.dart and ' 'routes${slash}conflicting_route${slash}index.dart ' @@ -384,7 +390,8 @@ void main() { directory: projectDirectory, ), failsWith( - stderr: 'There is already a middleware at ' + stderr: + 'There is already a middleware at ' 'routes${slash}existing_middleware${slash}_middleware.dart', ), ); @@ -406,7 +413,8 @@ void main() { directory: projectDirectory, ), failsWith( - stderr: 'Failed to create middleware: ' + stderr: + 'Failed to create middleware: ' 'Duplicate parameter name found: id', ), ); @@ -445,8 +453,9 @@ void main() { test('Excuse middleware creation upon existing rogue routes', () async { await dartFrogNewRoute('/existing_rogue', directory: projectDirectory); - Directory(path.join(routesDirectory.path, 'existing_rogue')) - .createSync(recursive: true); + Directory( + path.join(routesDirectory.path, 'existing_rogue'), + ).createSync(recursive: true); await expectLater( () async => dartFrogNewMiddleware( @@ -454,36 +463,41 @@ void main() { directory: projectDirectory, ), failsWith( - stderr: 'Failed to create middleware: Rogue route detected. ' + stderr: + 'Failed to create middleware: Rogue route detected. ' 'Rename routes${slash}existing_rogue.dart to ' 'routes${slash}existing_rogue${slash}index.dart.', ), ); }); - test('Excuse middleware creation upon existing route conflicts', - () async { - await dartFrogNewRoute( - '/conflicting_route', - directory: projectDirectory, - ); - - File(path.join(routesDirectory.path, 'conflicting_route/index.dart')) - .createSync(recursive: true); - - await expectLater( - () async => dartFrogNewMiddleware( + test( + 'Excuse middleware creation upon existing route conflicts', + () async { + await dartFrogNewRoute( '/conflicting_route', directory: projectDirectory, - ), - failsWith( - stderr: 'Failed to create middleware: Route conflict detected. ' - 'routes${slash}conflicting_route.dart and ' - 'routes${slash}conflicting_route${slash}index.dart both ' - 'resolve to /conflicting_route.', - ), - ); - }); + ); + + File( + path.join(routesDirectory.path, 'conflicting_route/index.dart'), + ).createSync(recursive: true); + + await expectLater( + () async => dartFrogNewMiddleware( + '/conflicting_route', + directory: projectDirectory, + ), + failsWith( + stderr: + 'Failed to create middleware: Route conflict detected. ' + 'routes${slash}conflicting_route.dart and ' + 'routes${slash}conflicting_route${slash}index.dart both ' + 'resolve to /conflicting_route.', + ), + ); + }, + ); }); }); } diff --git a/packages/dart_frog_cli/lib/src/command_runner.dart b/packages/dart_frog_cli/lib/src/command_runner.dart index 5a049a16a..174a353e5 100644 --- a/packages/dart_frog_cli/lib/src/command_runner.dart +++ b/packages/dart_frog_cli/lib/src/command_runner.dart @@ -33,12 +33,12 @@ class DartFrogCommandRunner extends CompletionCommandRunner { io.ProcessSignal? sigint, Exit? exit, io.Stdin? stdin, - }) : _logger = logger ?? Logger(), - _pubUpdater = pubUpdater ?? PubUpdater(), - _sigint = sigint ?? io.ProcessSignal.sigint, - _exit = exit ?? io.exit, - stdin = stdin ?? io.stdin, - super(executableName, executableDescription) { + }) : _logger = logger ?? Logger(), + _pubUpdater = pubUpdater ?? PubUpdater(), + _sigint = sigint ?? io.ProcessSignal.sigint, + _exit = exit ?? io.exit, + stdin = stdin ?? io.stdin, + super(executableName, executableDescription) { argParser.addFlags(); addCommand(BuildCommand(logger: _logger)); addCommand(CreateCommand(logger: _logger)); diff --git a/packages/dart_frog_cli/lib/src/commands/build/build.dart b/packages/dart_frog_cli/lib/src/commands/build/build.dart index cde13ba07..f55950e7d 100644 --- a/packages/dart_frog_cli/lib/src/commands/build/build.dart +++ b/packages/dart_frog_cli/lib/src/commands/build/build.dart @@ -15,13 +15,14 @@ class BuildCommand extends DartFrogCommand { @visibleForTesting GeneratorBuilder? generator, @visibleForTesting ProdServerBuilderConstructor? prodServerBuilderConstructor, - }) : _generator = generator ?? MasonGenerator.fromBundle, - _prodServerBuilderConstructor = - prodServerBuilderConstructor ?? ProdServerBuilder.new { + }) : _generator = generator ?? MasonGenerator.fromBundle, + _prodServerBuilderConstructor = + prodServerBuilderConstructor ?? ProdServerBuilder.new { argParser.addOption( 'dart-version', defaultsTo: 'stable', - help: 'The Dart SDK version used to build the Dockerfile, defaults to' + help: + 'The Dart SDK version used to build the Dockerfile, defaults to' ' stable.', ); } diff --git a/packages/dart_frog_cli/lib/src/commands/create/create.dart b/packages/dart_frog_cli/lib/src/commands/create/create.dart index aa2318a10..88e56b582 100644 --- a/packages/dart_frog_cli/lib/src/commands/create/create.dart +++ b/packages/dart_frog_cli/lib/src/commands/create/create.dart @@ -23,7 +23,8 @@ class CreateCommand extends DartFrogCommand { }) : _generator = generator ?? MasonGenerator.fromBundle { argParser.addOption( 'project-name', - help: 'The project name for this new project. ' + help: + 'The project name for this new project. ' 'This must be a valid dart package name.', ); } @@ -66,7 +67,8 @@ class CreateCommand extends DartFrogCommand { /// Uses the current directory path name /// if the `--project-name` option is not explicitly specified. String get _projectName { - final projectName = results['project-name'] as String? ?? + final projectName = + results['project-name'] as String? ?? path.basename(path.normalize(_outputDirectory.absolute.path)); _validateProjectName(projectName); return projectName; diff --git a/packages/dart_frog_cli/lib/src/commands/dev/dev.dart b/packages/dart_frog_cli/lib/src/commands/dev/dev.dart index ba314274f..b9e57c7b2 100644 --- a/packages/dart_frog_cli/lib/src/commands/dev/dev.dart +++ b/packages/dart_frog_cli/lib/src/commands/dev/dev.dart @@ -16,9 +16,9 @@ class DevCommand extends DartFrogCommand { super.logger, GeneratorBuilder? generator, DevServerRunnerConstructor? devServerRunnerConstructor, - }) : _generator = generator ?? MasonGenerator.fromBundle, - _devServerRunnerConstructor = - devServerRunnerConstructor ?? DevServerRunner.new { + }) : _generator = generator ?? MasonGenerator.fromBundle, + _devServerRunnerConstructor = + devServerRunnerConstructor ?? DevServerRunner.new { argParser ..addOption( 'port', @@ -103,7 +103,8 @@ class DevCommand extends DartFrogCommand { Future run() async { final port = io.Platform.environment['PORT'] ?? results['port'] as String; - final dartVmServicePort = (results['dart-vm-service-port'] as String?) ?? + final dartVmServicePort = + (results['dart-vm-service-port'] as String?) ?? _defaultDartVmServicePort; final generator = await _generator(dartFrogDevServerBundle); diff --git a/packages/dart_frog_cli/lib/src/commands/list/list.dart b/packages/dart_frog_cli/lib/src/commands/list/list.dart index c2d0a6ec1..e3b99df3d 100644 --- a/packages/dart_frog_cli/lib/src/commands/list/list.dart +++ b/packages/dart_frog_cli/lib/src/commands/list/list.dart @@ -7,9 +7,10 @@ import 'package:mason/mason.dart'; /// Definition for a function that builds a [RouteConfiguration] from a /// [Directory]. -typedef RouteConfigurationBuilder = RouteConfiguration Function( - Directory directory, -); +typedef RouteConfigurationBuilder = + RouteConfiguration Function( + Directory directory, + ); /// {@template list_command} /// `dart_frog list "path/to/project"` @@ -25,7 +26,8 @@ class ListCommand extends DartFrogCommand { argParser.addFlag( 'plain', abbr: 'p', - help: 'Return the output in a plain format, printing each route on a new ' + help: + 'Return the output in a plain format, printing each route on a new ' 'line.', negatable: false, ); diff --git a/packages/dart_frog_cli/lib/src/commands/new/new.dart b/packages/dart_frog_cli/lib/src/commands/new/new.dart index 61c0738ea..75faefa10 100644 --- a/packages/dart_frog_cli/lib/src/commands/new/new.dart +++ b/packages/dart_frog_cli/lib/src/commands/new/new.dart @@ -87,8 +87,9 @@ class _NewSubCommand extends DartFrogCommand { ); } - final segments = - routeName.split('/').skipWhile((element) => element.isEmpty); + final segments = routeName + .split('/') + .skipWhile((element) => element.isEmpty); for (final segment in segments) { if (segment.isEmpty) { diff --git a/packages/dart_frog_cli/lib/src/commands/update/update.dart b/packages/dart_frog_cli/lib/src/commands/update/update.dart index 532ceddab..c9f3f0a2d 100644 --- a/packages/dart_frog_cli/lib/src/commands/update/update.dart +++ b/packages/dart_frog_cli/lib/src/commands/update/update.dart @@ -14,8 +14,8 @@ class UpdateCommand extends DartFrogCommand { UpdateCommand({ required Logger logger, PubUpdater? pubUpdater, - }) : _logger = logger, - _pubUpdater = pubUpdater ?? PubUpdater() { + }) : _logger = logger, + _pubUpdater = pubUpdater ?? PubUpdater() { argParser.addFlag( 'verify-only', help: 'Check if an update is available, without committing to update.', diff --git a/packages/dart_frog_cli/lib/src/daemon/connection.dart b/packages/dart_frog_cli/lib/src/daemon/connection.dart index 1c4bad2ca..242cccebb 100644 --- a/packages/dart_frog_cli/lib/src/daemon/connection.dart +++ b/packages/dart_frog_cli/lib/src/daemon/connection.dart @@ -35,8 +35,8 @@ class DaemonStdioConnection implements DaemonConnection { DaemonStdioConnection({ @visibleForTesting StreamSink>? testStdout, @visibleForTesting Stream>? testStdin, - }) : _stdout = testStdout ?? stdout, - _stdin = testStdin ?? stdin { + }) : _stdout = testStdout ?? stdout, + _stdin = testStdin ?? stdin { _outputStreamController.stream.listen((message) { final json = jsonEncode(message.toJson()); _stdout.add(utf8.encode('[$json]\n')); diff --git a/packages/dart_frog_cli/lib/src/daemon/domain/dev_server_domain.dart b/packages/dart_frog_cli/lib/src/daemon/domain/dev_server_domain.dart index 892f699a6..11ba99db3 100644 --- a/packages/dart_frog_cli/lib/src/daemon/domain/dev_server_domain.dart +++ b/packages/dart_frog_cli/lib/src/daemon/domain/dev_server_domain.dart @@ -18,9 +18,9 @@ class DevServerDomain extends DomainBase { @visibleForTesting super.getId, @visibleForTesting GeneratorBuilder? generator, @visibleForTesting DevServerRunnerConstructor? devServerRunnerConstructor, - }) : _generator = generator ?? MasonGenerator.fromBundle, - _devServerRunnerConstructor = - devServerRunnerConstructor ?? DevServerRunner.new { + }) : _generator = generator ?? MasonGenerator.fromBundle, + _devServerRunnerConstructor = + devServerRunnerConstructor ?? DevServerRunner.new { addHandler('start', _start); addHandler('reload', _reload); addHandler('stop', _stop); diff --git a/packages/dart_frog_cli/lib/src/daemon/domain/domain_base.dart b/packages/dart_frog_cli/lib/src/daemon/domain/domain_base.dart index fe6e66d3b..60a1d6b19 100644 --- a/packages/dart_frog_cli/lib/src/daemon/domain/domain_base.dart +++ b/packages/dart_frog_cli/lib/src/daemon/domain/domain_base.dart @@ -5,9 +5,10 @@ import 'package:meta/meta.dart'; import 'package:uuid/uuid.dart'; /// Type definition for a daemon method which handles a [DaemonRequest]. -typedef DomainRequestHandler = Future Function( - DaemonRequest request, -); +typedef DomainRequestHandler = + Future Function( + DaemonRequest request, + ); const Uuid _uuidGenerator = Uuid(); diff --git a/packages/dart_frog_cli/lib/src/daemon/domain/route_configuration_domain.dart b/packages/dart_frog_cli/lib/src/daemon/domain/route_configuration_domain.dart index 86331038a..6f8252186 100644 --- a/packages/dart_frog_cli/lib/src/daemon/domain/route_configuration_domain.dart +++ b/packages/dart_frog_cli/lib/src/daemon/domain/route_configuration_domain.dart @@ -17,7 +17,7 @@ class RouteConfigurationDomain extends DomainBase { @visibleForTesting RouteConfigurationWatcherBuilder? routeConfigurationWatcherBuilder, }) : _routeConfigWatcherBuilder = - routeConfigurationWatcherBuilder ?? RouteConfigurationWatcher.new { + routeConfigurationWatcherBuilder ?? RouteConfigurationWatcher.new { addHandler('watcherStart', _watcherStart); addHandler( 'watcherGenerateRouteConfiguration', diff --git a/packages/dart_frog_cli/lib/src/daemon/exceptions.dart b/packages/dart_frog_cli/lib/src/daemon/exceptions.dart index 207966766..3e803feed 100644 --- a/packages/dart_frog_cli/lib/src/daemon/exceptions.dart +++ b/packages/dart_frog_cli/lib/src/daemon/exceptions.dart @@ -25,7 +25,7 @@ class DartFrogDaemonMalformedMessageException extends DartFrogDaemonMessageException { /// {@macro dart_frog_daemon_malformed_message_exception} const DartFrogDaemonMalformedMessageException(String message) - : super('Malformed message, $message'); + : super('Malformed message, $message'); } /// {@template dart_frog_daemon_missing_parameter_exception} @@ -36,5 +36,5 @@ class DartFrogDaemonMissingParameterException extends DartFrogDaemonMessageException { /// {@macro dart_frog_daemon_malformed_message_exception} const DartFrogDaemonMissingParameterException(String message) - : super('Missing parameter, $message'); + : super('Missing parameter, $message'); } diff --git a/packages/dart_frog_cli/lib/src/daemon/protocol.dart b/packages/dart_frog_cli/lib/src/daemon/protocol.dart index ab3f52896..c0be452f6 100644 --- a/packages/dart_frog_cli/lib/src/daemon/protocol.dart +++ b/packages/dart_frog_cli/lib/src/daemon/protocol.dart @@ -175,20 +175,20 @@ class DaemonResponse extends DaemonMessage { required String id, required Map result, }) : this._( - id: id, - result: result, - error: null, - ); + id: id, + result: result, + error: null, + ); /// Creates an error [DaemonResponse]. const DaemonResponse.error({ required String id, required Map error, }) : this._( - id: id, - result: null, - error: error, - ); + id: id, + result: null, + error: error, + ); /// Creates a [DaemonResponse] from a [rawMessage] json. factory DaemonResponse.fromJson(Map rawMessage) { diff --git a/packages/dart_frog_cli/lib/src/dev_server_runner/dev_server_runner.dart b/packages/dart_frog_cli/lib/src/dev_server_runner/dev_server_runner.dart index 313c9cad2..e5dfab7a5 100644 --- a/packages/dart_frog_cli/lib/src/dev_server_runner/dev_server_runner.dart +++ b/packages/dart_frog_cli/lib/src/dev_server_runner/dev_server_runner.dart @@ -11,22 +11,25 @@ import 'package:stream_transform/stream_transform.dart'; import 'package:watcher/watcher.dart'; /// Typedef for [io.Process.start]. -typedef ProcessStart = Future Function( - String executable, - List arguments, { - bool runInShell, -}); +typedef ProcessStart = + Future Function( + String executable, + List arguments, { + bool runInShell, + }); /// Typedef for [io.Process.run]. -typedef ProcessRun = Future Function( - String executable, - List arguments, -); +typedef ProcessRun = + Future Function( + String executable, + List arguments, + ); /// Typedef for [DirectoryWatcher.new]. -typedef DirectoryWatcherBuilder = DirectoryWatcher Function( - String directory, -); +typedef DirectoryWatcherBuilder = + DirectoryWatcher Function( + String directory, + ); /// Regex for detecting warnings in the output of `dart run`. final _warningRegex = RegExp(r'^.*:\d+:\d+: Warning: .*', multiLine: true); @@ -39,15 +42,16 @@ final _dartVmServiceAlreadyInUseErrorRegex = RegExp( ); /// Typedef for [DevServerRunner.new]. -typedef DevServerRunnerConstructor = DevServerRunner Function({ - required Logger logger, - required String port, - required io.InternetAddress? address, - required MasonGenerator devServerBundleGenerator, - required String dartVmServicePort, - required io.Directory workingDirectory, - void Function()? onHotReloadEnabled, -}); +typedef DevServerRunnerConstructor = + DevServerRunner Function({ + required Logger logger, + required String port, + required io.InternetAddress? address, + required MasonGenerator devServerBundleGenerator, + required String dartVmServicePort, + required io.Directory workingDirectory, + void Function()? onHotReloadEnabled, + }); /// {@template dev_server_runner} /// A class that manages a local development server process lifecycle. @@ -81,20 +85,20 @@ class DevServerRunner { @visibleForTesting ProcessRun? runProcess, @visibleForTesting RuntimeCompatibilityCallback? runtimeCompatibilityCallback, - }) : _directoryWatcher = directoryWatcher ?? DirectoryWatcher.new, - _isWindows = isWindows ?? io.Platform.isWindows, - _sigint = sigint ?? io.ProcessSignal.sigint, - _startProcess = startProcess ?? io.Process.start, - _runProcess = runProcess ?? io.Process.run, - _generatorTarget = - generatorTarget ?? RestorableDirectoryGeneratorTarget.new, - _ensureRuntimeCompatibility = - runtimeCompatibilityCallback ?? ensureRuntimeCompatibility, - assert(port.isNotEmpty, 'port cannot be empty'), - assert( - dartVmServicePort.isNotEmpty, - 'dartVmServicePort cannot be empty', - ); + }) : _directoryWatcher = directoryWatcher ?? DirectoryWatcher.new, + _isWindows = isWindows ?? io.Platform.isWindows, + _sigint = sigint ?? io.ProcessSignal.sigint, + _startProcess = startProcess ?? io.Process.start, + _runProcess = runProcess ?? io.Process.run, + _generatorTarget = + generatorTarget ?? RestorableDirectoryGeneratorTarget.new, + _ensureRuntimeCompatibility = + runtimeCompatibilityCallback ?? ensureRuntimeCompatibility, + assert(port.isNotEmpty, 'port cannot be empty'), + assert( + dartVmServicePort.isNotEmpty, + 'dartVmServicePort cannot be empty', + ); /// [Logger] instance used to wrap stdout. final Logger logger; @@ -381,13 +385,17 @@ class DevServerRunner { .debounce(Duration.zero) .listen((_) => _reload()); - _watcherSubscription!.asFuture().then((_) async { - await _cancelWatcherSubscription(); - await stop(); - }).catchError((_) async { - await _cancelWatcherSubscription(); - await stop(ExitCode.software); - }).ignore(); + _watcherSubscription! + .asFuture() + .then((_) async { + await _cancelWatcherSubscription(); + await stop(); + }) + .catchError((_) async { + await _cancelWatcherSubscription(); + await stop(ExitCode.software); + }) + .ignore(); } /// Stops the development server and the watcher then diff --git a/packages/dart_frog_cli/lib/src/dev_server_runner/restorable_directory_generator_target.dart b/packages/dart_frog_cli/lib/src/dev_server_runner/restorable_directory_generator_target.dart index 9a3fa9ce6..24044391d 100644 --- a/packages/dart_frog_cli/lib/src/dev_server_runner/restorable_directory_generator_target.dart +++ b/packages/dart_frog_cli/lib/src/dev_server_runner/restorable_directory_generator_target.dart @@ -4,20 +4,21 @@ import 'dart:io' as io; import 'package:mason/mason.dart'; /// Signature for the [DirectoryGeneratorTarget.createFile] method. -typedef CreateFile = Future Function( - String path, - List contents, { - Logger? logger, - OverwriteRule? overwriteRule, -}); +typedef CreateFile = + Future Function( + String path, + List contents, { + Logger? logger, + OverwriteRule? overwriteRule, + }); /// Typedef for [RestorableDirectoryGeneratorTarget.new] -typedef RestorableDirectoryGeneratorTargetBuilder - = RestorableDirectoryGeneratorTarget Function( - io.Directory dir, { - CreateFile? createFile, - Logger? logger, -}); +typedef RestorableDirectoryGeneratorTargetBuilder = + RestorableDirectoryGeneratorTarget Function( + io.Directory dir, { + CreateFile? createFile, + Logger? logger, + }); /// {@template cached_file} /// A cached file which consists of the file path and contents. @@ -43,9 +44,9 @@ class RestorableDirectoryGeneratorTarget extends DirectoryGeneratorTarget { super.dir, { CreateFile? createFile, Logger? logger, - }) : _cachedSnapshots = Queue(), - _createFile = createFile, - _logger = logger; + }) : _cachedSnapshots = Queue(), + _createFile = createFile, + _logger = logger; final CreateFile? _createFile; final Logger? _logger; diff --git a/packages/dart_frog_cli/lib/src/prod_server_builder/prod_server_builder.dart b/packages/dart_frog_cli/lib/src/prod_server_builder/prod_server_builder.dart index 34c5d387f..be9bdc7e6 100644 --- a/packages/dart_frog_cli/lib/src/prod_server_builder/prod_server_builder.dart +++ b/packages/dart_frog_cli/lib/src/prod_server_builder/prod_server_builder.dart @@ -5,12 +5,13 @@ import 'package:mason/mason.dart'; import 'package:meta/meta.dart'; /// Typedef for [ProdServerBuilder.new]. -typedef ProdServerBuilderConstructor = ProdServerBuilder Function({ - required Logger logger, - required String dartVersion, - required io.Directory workingDirectory, - required MasonGenerator prodServerBundleGenerator, -}); +typedef ProdServerBuilderConstructor = + ProdServerBuilder Function({ + required Logger logger, + required String dartVersion, + required io.Directory workingDirectory, + required MasonGenerator prodServerBundleGenerator, + }); /// {@template prod_server_builder} /// A class that builds the production server runtime code. @@ -31,7 +32,7 @@ class ProdServerBuilder { @visibleForTesting RuntimeCompatibilityCallback? runtimeCompatibilityCallback, }) : _ensureRuntimeCompatibility = - runtimeCompatibilityCallback ?? ensureRuntimeCompatibility; + runtimeCompatibilityCallback ?? ensureRuntimeCompatibility; /// The Dart SDK version used to build the Dockerfile. final String dartVersion; diff --git a/packages/dart_frog_cli/lib/src/route_configuration_watcher/route_configuration_watcher.dart b/packages/dart_frog_cli/lib/src/route_configuration_watcher/route_configuration_watcher.dart index c57a3f397..92c57f889 100644 --- a/packages/dart_frog_cli/lib/src/route_configuration_watcher/route_configuration_watcher.dart +++ b/packages/dart_frog_cli/lib/src/route_configuration_watcher/route_configuration_watcher.dart @@ -9,26 +9,30 @@ import 'package:stream_transform/stream_transform.dart'; import 'package:watcher/watcher.dart'; /// Typedef for [DirectoryWatcher.new]. -typedef DirectoryWatcherBuilder = DirectoryWatcher Function( - String directory, -); +typedef DirectoryWatcherBuilder = + DirectoryWatcher Function( + String directory, + ); /// Typedef for [RouteConfiguration] change callbacks. -typedef RouteConfigurationChanged = void Function( - RouteConfiguration routeConfiguration, -); +typedef RouteConfigurationChanged = + void Function( + RouteConfiguration routeConfiguration, + ); /// Typedef for [RouteConfigurationWatcher.new]. -typedef RouteConfigurationWatcherBuilder = RouteConfigurationWatcher Function({ - required Logger logger, - required io.Directory workingDirectory, - required RouteConfigurationChanged onRouteConfigurationChanged, -}); +typedef RouteConfigurationWatcherBuilder = + RouteConfigurationWatcher Function({ + required Logger logger, + required io.Directory workingDirectory, + required RouteConfigurationChanged onRouteConfigurationChanged, + }); /// Typedef for [buildRouteConfiguration] -typedef RouteConfigurationBuilder = RouteConfiguration Function( - io.Directory directory, -); +typedef RouteConfigurationBuilder = + RouteConfiguration Function( + io.Directory directory, + ); /// {@template route_configuration_watcher} /// Monitors a dart frog project for changes on its route configuration. @@ -41,9 +45,9 @@ class RouteConfigurationWatcher { required this.onRouteConfigurationChanged, @visibleForTesting DirectoryWatcherBuilder? directoryWatcher, @visibleForTesting RouteConfigurationBuilder? routeConfigurationBuilder, - }) : _directoryWatcher = directoryWatcher ?? DirectoryWatcher.new, - _routeConfigurationBuilder = - routeConfigurationBuilder ?? buildRouteConfiguration; + }) : _directoryWatcher = directoryWatcher ?? DirectoryWatcher.new, + _routeConfigurationBuilder = + routeConfigurationBuilder ?? buildRouteConfiguration; /// [Logger] instance used to wrap stdout. final Logger logger; diff --git a/packages/dart_frog_cli/pubspec.yaml b/packages/dart_frog_cli/pubspec.yaml index 8f7bfeb75..b95a7efd2 100644 --- a/packages/dart_frog_cli/pubspec.yaml +++ b/packages/dart_frog_cli/pubspec.yaml @@ -12,7 +12,7 @@ screenshots: path: assets/logo.png environment: - sdk: ^3.5.0 + sdk: ^3.9.0 dependencies: args: ^2.5.0 diff --git a/packages/dart_frog_cli/test/helpers/override_print.dart b/packages/dart_frog_cli/test/helpers/override_print.dart index c197d05eb..a673cb90d 100644 --- a/packages/dart_frog_cli/test/helpers/override_print.dart +++ b/packages/dart_frog_cli/test/helpers/override_print.dart @@ -5,7 +5,7 @@ void Function() overridePrint(void Function(List) fn) { return () { final spec = ZoneSpecification( - print: (_, __, ___, String msg) { + print: (_, _, _, String msg) { printLogs.add(msg); }, ); diff --git a/packages/dart_frog_cli/test/src/command_runner_test.dart b/packages/dart_frog_cli/test/src/command_runner_test.dart index ec3af4e89..23cd8bac5 100644 --- a/packages/dart_frog_cli/test/src/command_runner_test.dart +++ b/packages/dart_frog_cli/test/src/command_runner_test.dart @@ -53,7 +53,8 @@ final changelogLink = lightCyan.wrap( ), ), ); -final updateMessage = ''' +final updateMessage = + ''' ${lightYellow.wrap('Update available!')} ${lightCyan.wrap(packageVersion)} \u2192 ${lightCyan.wrap(latestVersion)} ${lightYellow.wrap('Changelog:')} $changelogLink Run ${lightCyan.wrap('$executableName update')} to update'''; @@ -103,7 +104,8 @@ void main() { ); // The message should contain the invalid option name but is // differet based on the platform it's running on. - final containsInvalidOption = message.contains( + final containsInvalidOption = + message.contains( '"invalid-option"', ) || message.contains( diff --git a/packages/dart_frog_cli/test/src/commands/build/build_test.dart b/packages/dart_frog_cli/test/src/commands/build/build_test.dart index 0e40efa2c..41bb76405 100644 --- a/packages/dart_frog_cli/test/src/commands/build/build_test.dart +++ b/packages/dart_frog_cli/test/src/commands/build/build_test.dart @@ -51,23 +51,25 @@ void main() { late Directory givenWorkingDirectory; late MasonGenerator givenProdServerBundleGenerator; - final command = BuildCommand( - logger: logger, - generator: (_) async => generator, - prodServerBuilderConstructor: ({ - required Logger logger, - required String dartVersion, - required Directory workingDirectory, - required MasonGenerator prodServerBundleGenerator, - }) { - givenDartVersion = dartVersion; - givenWorkingDirectory = workingDirectory; - givenProdServerBundleGenerator = prodServerBundleGenerator; - return builder; - }, - ) - ..testArgResults = argResults - ..testCwd = cwd; + final command = + BuildCommand( + logger: logger, + generator: (_) async => generator, + prodServerBuilderConstructor: + ({ + required Logger logger, + required String dartVersion, + required Directory workingDirectory, + required MasonGenerator prodServerBundleGenerator, + }) { + givenDartVersion = dartVersion; + givenWorkingDirectory = workingDirectory; + givenProdServerBundleGenerator = prodServerBundleGenerator; + return builder; + }, + ) + ..testArgResults = argResults + ..testCwd = cwd; when( () => builder.build(), ).thenAnswer((_) => Future.value(ExitCode.tempFail)); @@ -82,19 +84,20 @@ void main() { }); test('returns software error if the builder throws', () { - final command = BuildCommand( - logger: logger, - generator: (_) async => generator, - prodServerBuilderConstructor: ({ - required Logger logger, - required String dartVersion, - required Directory workingDirectory, - required MasonGenerator prodServerBundleGenerator, - }) => - builder, - ) - ..testArgResults = argResults - ..testCwd = cwd; + final command = + BuildCommand( + logger: logger, + generator: (_) async => generator, + prodServerBuilderConstructor: + ({ + required Logger logger, + required String dartVersion, + required Directory workingDirectory, + required MasonGenerator prodServerBundleGenerator, + }) => builder, + ) + ..testArgResults = argResults + ..testCwd = cwd; when(() => builder.build()).thenThrow(Exception()); expect(command.run(), completion(ExitCode.software.code)); diff --git a/packages/dart_frog_cli/test/src/commands/create/create_test.dart b/packages/dart_frog_cli/test/src/commands/create/create_test.dart index 597ecccd0..6a1882813 100644 --- a/packages/dart_frog_cli/test/src/commands/create/create_test.dart +++ b/packages/dart_frog_cli/test/src/commands/create/create_test.dart @@ -38,12 +38,13 @@ void main() { progress = _MockProgress(); when(() => logger.progress(any())).thenReturn(progress); generator = _MockMasonGenerator(); - command = CreateCommand( - logger: logger, - generator: (_) async => generator, - ) - ..testArgResults = argResults - ..testUsage = 'test usage'; + command = + CreateCommand( + logger: logger, + generator: (_) async => generator, + ) + ..testArgResults = argResults + ..testUsage = 'test usage'; }); test('throws UsageException when args is empty.', () async { diff --git a/packages/dart_frog_cli/test/src/commands/dev/dev_test.dart b/packages/dart_frog_cli/test/src/commands/dev/dev_test.dart index a7ccbc14b..bd209aa1a 100644 --- a/packages/dart_frog_cli/test/src/commands/dev/dev_test.dart +++ b/packages/dart_frog_cli/test/src/commands/dev/dev_test.dart @@ -66,30 +66,32 @@ void main() { late Directory givenWorkingDirectory; late void Function()? givenOnHotReloadEnabled; - final command = DevCommand( - generator: (_) async => generator, - devServerRunnerConstructor: ({ - required logger, - required port, - required address, - required devServerBundleGenerator, - required dartVmServicePort, - required workingDirectory, - void Function()? onHotReloadEnabled, - }) { - givenPort = port; - givenAddress = address; - givenDartVmServicePort = dartVmServicePort; - givenDevServerBundleGenerator = devServerBundleGenerator; - givenWorkingDirectory = workingDirectory; - givenOnHotReloadEnabled = onHotReloadEnabled; - return runner; - }, - logger: logger, - ) - ..testStdin = stdin - ..testArgResults = argResults - ..testCwd = cwd; + final command = + DevCommand( + generator: (_) async => generator, + devServerRunnerConstructor: + ({ + required logger, + required port, + required address, + required devServerBundleGenerator, + required dartVmServicePort, + required workingDirectory, + void Function()? onHotReloadEnabled, + }) { + givenPort = port; + givenAddress = address; + givenDartVmServicePort = dartVmServicePort; + givenDevServerBundleGenerator = devServerBundleGenerator; + givenWorkingDirectory = workingDirectory; + givenOnHotReloadEnabled = onHotReloadEnabled; + return runner; + }, + logger: logger, + ) + ..testStdin = stdin + ..testArgResults = argResults + ..testCwd = cwd; await expectLater(command.run(), completion(ExitCode.success.code)); @@ -106,23 +108,25 @@ void main() { }); test('results with dev server exit code', () async { - final command = DevCommand( - generator: (_) async => generator, - devServerRunnerConstructor: ({ - required logger, - required port, - required address, - required devServerBundleGenerator, - required dartVmServicePort, - required workingDirectory, - void Function()? onHotReloadEnabled, - }) { - return runner; - }, - logger: logger, - ) - ..testArgResults = argResults - ..testStdin = stdin; + final command = + DevCommand( + generator: (_) async => generator, + devServerRunnerConstructor: + ({ + required logger, + required port, + required address, + required devServerBundleGenerator, + required dartVmServicePort, + required workingDirectory, + void Function()? onHotReloadEnabled, + }) { + return runner; + }, + logger: logger, + ) + ..testArgResults = argResults + ..testStdin = stdin; when(() => runner.start(any())).thenAnswer((_) => Future.value()); when(() => runner.exitCode).thenAnswer((_) async => ExitCode.unavailable); @@ -131,23 +135,25 @@ void main() { }); test('fails if dev server runner fails on start', () async { - final command = DevCommand( - generator: (_) async => generator, - devServerRunnerConstructor: ({ - required logger, - required port, - required address, - required devServerBundleGenerator, - required dartVmServicePort, - required workingDirectory, - void Function()? onHotReloadEnabled, - }) { - return runner; - }, - logger: logger, - ) - ..testArgResults = argResults - ..testStdin = stdin; + final command = + DevCommand( + generator: (_) async => generator, + devServerRunnerConstructor: + ({ + required logger, + required port, + required address, + required devServerBundleGenerator, + required dartVmServicePort, + required workingDirectory, + void Function()? onHotReloadEnabled, + }) { + return runner; + }, + logger: logger, + ) + ..testArgResults = argResults + ..testStdin = stdin; when(() => runner.start(any())).thenAnswer((_) async { throw DartFrogDevServerException('oops'); @@ -169,24 +175,26 @@ void main() { final cwd = Directory.systemTemp; - final command = DevCommand( - generator: (_) async => generator, - devServerRunnerConstructor: ({ - required logger, - required port, - required address, - required devServerBundleGenerator, - required dartVmServicePort, - required workingDirectory, - void Function()? onHotReloadEnabled, - }) { - return runner; - }, - logger: logger, - ) - ..testStdin = stdin - ..testArgResults = argResults - ..testCwd = cwd; + final command = + DevCommand( + generator: (_) async => generator, + devServerRunnerConstructor: + ({ + required logger, + required port, + required address, + required devServerBundleGenerator, + required dartVmServicePort, + required workingDirectory, + void Function()? onHotReloadEnabled, + }) { + return runner; + }, + logger: logger, + ) + ..testStdin = stdin + ..testArgResults = argResults + ..testCwd = cwd; await expectLater(command.run(), completion(ExitCode.software.code)); @@ -240,24 +248,26 @@ void main() { (_) => exitCodeCompleter.future, ); - command = DevCommand( - generator: (_) async => generator, - devServerRunnerConstructor: ({ - required logger, - required port, - required address, - required devServerBundleGenerator, - required dartVmServicePort, - required workingDirectory, - void Function()? onHotReloadEnabled, - }) { - givenOnHotReloadEnabled = onHotReloadEnabled!; - return runner; - }, - logger: logger, - ) - ..testArgResults = argResults - ..testStdin = stdin; + command = + DevCommand( + generator: (_) async => generator, + devServerRunnerConstructor: + ({ + required logger, + required port, + required address, + required devServerBundleGenerator, + required dartVmServicePort, + required workingDirectory, + void Function()? onHotReloadEnabled, + }) { + givenOnHotReloadEnabled = onHotReloadEnabled!; + return runner; + }, + logger: logger, + ) + ..testArgResults = argResults + ..testStdin = stdin; }); Future hotReloadTest(int asciiValue, String character) async { diff --git a/packages/dart_frog_cli/test/src/commands/list/list_test.dart b/packages/dart_frog_cli/test/src/commands/list/list_test.dart index ce95d7525..0dbf6dea5 100644 --- a/packages/dart_frog_cli/test/src/commands/list/list_test.dart +++ b/packages/dart_frog_cli/test/src/commands/list/list_test.dart @@ -63,12 +63,13 @@ void main() { updater = _MockPubUpdater(); routeConfiguration = _MockRouteConfiguration(); when(() => logger.progress(any())).thenReturn(progress); - command = ListCommand( - logger: logger, - buildConfiguration: (_) => routeConfiguration, - ) - ..testArgResults = argResults - ..testUsage = 'test usage'; + command = + ListCommand( + logger: logger, + buildConfiguration: (_) => routeConfiguration, + ) + ..testArgResults = argResults + ..testUsage = 'test usage'; when(() => argResults['plain']).thenReturn(false); when( diff --git a/packages/dart_frog_cli/test/src/commands/new/new_test.dart b/packages/dart_frog_cli/test/src/commands/new/new_test.dart index d66bd0993..83f3e838e 100644 --- a/packages/dart_frog_cli/test/src/commands/new/new_test.dart +++ b/packages/dart_frog_cli/test/src/commands/new/new_test.dart @@ -65,14 +65,15 @@ void main() { progress = _MockProgress(); generator = _MockMasonGenerator(); updater = _MockPubUpdater(); - command = NewCommand( - logger: logger, - generator: (_) async { - return generator; - }, - ) - ..testArgResults = argResults - ..testUsage = 'test usage'; + command = + NewCommand( + logger: logger, + generator: (_) async { + return generator; + }, + ) + ..testArgResults = argResults + ..testUsage = 'test usage'; final sigint = _MockProcessSignal(); @@ -388,8 +389,9 @@ void main() { logger: any(named: 'logger'), ), ).thenAnswer((invocation) async { - final onVarsChanged = invocation.namedArguments[#onVarsChanged] - as void Function(Map); + final onVarsChanged = + invocation.namedArguments[#onVarsChanged] + as void Function(Map); onVarsChanged({'dir_path': '${directory.path}/routes/something'}); }); @@ -460,8 +462,9 @@ void main() { logger: any(named: 'logger'), ), ).thenAnswer((invocation) async { - final onVarsChanged = invocation.namedArguments[#onVarsChanged] - as void Function(Map); + final onVarsChanged = + invocation.namedArguments[#onVarsChanged] + as void Function(Map); onVarsChanged({'dir_path': '${directory.path}/routes/something'}); }); diff --git a/packages/dart_frog_cli/test/src/daemon/domain/dev_server_domain_test.dart b/packages/dart_frog_cli/test/src/daemon/domain/dev_server_domain_test.dart index 7d11d9f9f..77e534552 100644 --- a/packages/dart_frog_cli/test/src/daemon/domain/dev_server_domain_test.dart +++ b/packages/dart_frog_cli/test/src/daemon/domain/dev_server_domain_test.dart @@ -35,17 +35,18 @@ void main() { daemonServer, getId: () => 'id', generator: (_) async => generator, - devServerRunnerConstructor: ({ - required logger, - required port, - required address, - required devServerBundleGenerator, - required dartVmServicePort, - required workingDirectory, - void Function()? onHotReloadEnabled, - }) { - return runner; - }, + devServerRunnerConstructor: + ({ + required logger, + required port, + required address, + required devServerBundleGenerator, + required dartVmServicePort, + required workingDirectory, + void Function()? onHotReloadEnabled, + }) { + return runner; + }, ); completer = Completer(); when(() => runner.start()).thenAnswer((_) async {}); @@ -69,23 +70,24 @@ void main() { daemonServer, getId: () => 'id', generator: (_) async => generator, - devServerRunnerConstructor: ({ - required logger, - required port, - required address, - required devServerBundleGenerator, - required dartVmServicePort, - required workingDirectory, - void Function()? onHotReloadEnabled, - }) { - passedLogger = logger; - passedPort = port; - passedAddress = address; - passedDevServerBundleGenerator = devServerBundleGenerator; - passedDartVmServicePort = dartVmServicePort; - passedWorkingDirectory = workingDirectory; - return runner; - }, + devServerRunnerConstructor: + ({ + required logger, + required port, + required address, + required devServerBundleGenerator, + required dartVmServicePort, + required workingDirectory, + void Function()? onHotReloadEnabled, + }) { + passedLogger = logger; + passedPort = port; + passedAddress = address; + passedDevServerBundleGenerator = devServerBundleGenerator; + passedDartVmServicePort = dartVmServicePort; + passedWorkingDirectory = workingDirectory; + return runner; + }, ); expect( @@ -287,7 +289,8 @@ void main() { const DaemonResponse.error( id: '12', error: { - 'message': 'Malformed message, invalid hostname "lol": ' + 'message': + 'Malformed message, invalid hostname "lol": ' 'must be a valid IPv4 or IPv6 address.', }, ), @@ -623,19 +626,20 @@ void main() { final domain = DevServerDomain( daemonServer, generator: (_) async => generator, - devServerRunnerConstructor: ({ - required logger, - required port, - required address, - required devServerBundleGenerator, - required dartVmServicePort, - required workingDirectory, - void Function()? onHotReloadEnabled, - }) { - final runner = calls == 0 ? runner1 : runner2; - calls++; - return runner; - }, + devServerRunnerConstructor: + ({ + required logger, + required port, + required address, + required devServerBundleGenerator, + required dartVmServicePort, + required workingDirectory, + void Function()? onHotReloadEnabled, + }) { + final runner = calls == 0 ? runner1 : runner2; + calls++; + return runner; + }, ); await domain.handleRequest( diff --git a/packages/dart_frog_cli/test/src/daemon/domain/route_configuration_domain_test.dart b/packages/dart_frog_cli/test/src/daemon/domain/route_configuration_domain_test.dart index 06192d09f..68da1d310 100644 --- a/packages/dart_frog_cli/test/src/daemon/domain/route_configuration_domain_test.dart +++ b/packages/dart_frog_cli/test/src/daemon/domain/route_configuration_domain_test.dart @@ -69,13 +69,14 @@ void main() { domain = RouteConfigurationDomain( daemonServer, getId: () => 'id', - routeConfigurationWatcherBuilder: ({ - required Logger logger, - required Directory workingDirectory, - required RouteConfigurationChanged onRouteConfigurationChanged, - }) { - return watcher; - }, + routeConfigurationWatcherBuilder: + ({ + required Logger logger, + required Directory workingDirectory, + required RouteConfigurationChanged onRouteConfigurationChanged, + }) { + return watcher; + }, ); when(() => watcher.start()).thenAnswer((_) async {}); @@ -96,16 +97,17 @@ void main() { domain = RouteConfigurationDomain( daemonServer, getId: () => 'id', - routeConfigurationWatcherBuilder: ({ - required Logger logger, - required Directory workingDirectory, - required RouteConfigurationChanged onRouteConfigurationChanged, - }) { - passedLogger = logger; - passedWorkingDirectory = workingDirectory; - passedOnRouteConfigurationChanged = onRouteConfigurationChanged; - return watcher; - }, + routeConfigurationWatcherBuilder: + ({ + required Logger logger, + required Directory workingDirectory, + required RouteConfigurationChanged onRouteConfigurationChanged, + }) { + passedLogger = logger; + passedWorkingDirectory = workingDirectory; + passedOnRouteConfigurationChanged = onRouteConfigurationChanged; + return watcher; + }, ); expect( @@ -533,15 +535,16 @@ void main() { domain = RouteConfigurationDomain( daemonServer, - routeConfigurationWatcherBuilder: ({ - required Logger logger, - required Directory workingDirectory, - required RouteConfigurationChanged onRouteConfigurationChanged, - }) { - final watcher = calls == 0 ? watcher1 : watcher2; - calls++; - return watcher; - }, + routeConfigurationWatcherBuilder: + ({ + required Logger logger, + required Directory workingDirectory, + required RouteConfigurationChanged onRouteConfigurationChanged, + }) { + final watcher = calls == 0 ? watcher1 : watcher2; + calls++; + return watcher; + }, ); await domain.handleRequest( diff --git a/packages/dart_frog_cli/test/src/dev_server_runner/dev_server_runner_test.dart b/packages/dart_frog_cli/test/src/dev_server_runner/dev_server_runner_test.dart index d6a2df605..5620ceda1 100644 --- a/packages/dart_frog_cli/test/src/dev_server_runner/dev_server_runner_test.dart +++ b/packages/dart_frog_cli/test/src/dev_server_runner/dev_server_runner_test.dart @@ -81,9 +81,9 @@ void main() { directoryWatcher: (_) => directoryWatcher, generatorTarget: (_, {createFile, logger}) => generatorTarget, isWindows: isWindows, - startProcess: (_, __, {runInShell = false}) async => process, + startProcess: (_, _, {runInShell = false}) async => process, sigint: sigint, - runProcess: (_, __) async => processResult, + runProcess: (_, _) async => processResult, runtimeCompatibilityCallback: (_) {}, ); @@ -99,8 +99,8 @@ void main() { onVarsChanged: any(named: 'onVarsChanged'), ), ).thenAnswer((invocation) async { - (invocation.namedArguments[const Symbol('onVarsChanged')] as void - Function(Map vars)) + (invocation.namedArguments[const Symbol('onVarsChanged')] + as void Function(Map vars)) .call({}); }); @@ -171,9 +171,9 @@ void main() { directoryWatcher: (_) => directoryWatcher, generatorTarget: (_, {createFile, logger}) => generatorTarget, isWindows: isWindows, - startProcess: (_, __, {runInShell = false}) async => process, + startProcess: (_, _, {runInShell = false}) async => process, sigint: sigint, - runProcess: (_, __) async => processResult, + runProcess: (_, _) async => processResult, runtimeCompatibilityCallback: (_) { throw const DartFrogCompatibilityException('oops'); }, @@ -236,16 +236,17 @@ void main() { directoryWatcher: (_) => directoryWatcher, generatorTarget: (_, {createFile, logger}) => generatorTarget, isWindows: isWindows, - startProcess: ( - String executable, - List arguments, { - bool runInShell = false, - }) async { - receivedArgs = arguments; - return process; - }, + startProcess: + ( + String executable, + List arguments, { + bool runInShell = false, + }) async { + receivedArgs = arguments; + return process; + }, sigint: sigint, - runProcess: (_, __) async => processResult, + runProcess: (_, _) async => processResult, runtimeCompatibilityCallback: (_) => true, ); @@ -289,16 +290,17 @@ void main() { directoryWatcher: (_) => directoryWatcher, generatorTarget: (_, {createFile, logger}) => generatorTarget, isWindows: isWindows, - startProcess: ( - String executable, - List arguments, { - bool runInShell = false, - }) async { - receivedArgs = arguments; - return process; - }, + startProcess: + ( + String executable, + List arguments, { + bool runInShell = false, + }) async { + receivedArgs = arguments; + return process; + }, sigint: sigint, - runProcess: (_, __) async => processResult, + runProcess: (_, _) async => processResult, runtimeCompatibilityCallback: (_) => true, ); @@ -353,7 +355,7 @@ void main() { workingDirectory: Directory.current, directoryWatcher: (_) => directoryWatcher, isWindows: true, - startProcess: (_, __, {runInShell = false}) async => process, + startProcess: (_, _, {runInShell = false}) async => process, sigint: sigint, runProcess: (String executable, List arguments) async { processRunCalls.add([executable, ...arguments]); @@ -476,8 +478,8 @@ void main() { onVarsChanged: any(named: 'onVarsChanged'), ), ).thenAnswer((invocation) async { - (invocation.namedArguments[const Symbol('onVarsChanged')] as void - Function(Map vars)) + (invocation.namedArguments[const Symbol('onVarsChanged')] + as void Function(Map vars)) .call({}); }); when( @@ -505,23 +507,24 @@ void main() { dartVmServicePort: '4343', workingDirectory: Directory.current, directoryWatcher: (_) => directoryWatcher, - generatorTarget: ( - _, { - CreateFile? createFile, - Logger? logger, - }) => - generatorTarget, + generatorTarget: + ( + _, { + CreateFile? createFile, + Logger? logger, + }) => generatorTarget, isWindows: isWindows, - startProcess: ( - String executable, - List arguments, { - bool runInShell = false, - }) async { - receivedArgs = arguments; - return process; - }, + startProcess: + ( + String executable, + List arguments, { + bool runInShell = false, + }) async { + receivedArgs = arguments; + return process; + }, sigint: sigint, - runProcess: (_, __) async => processResult, + runProcess: (_, _) async => processResult, runtimeCompatibilityCallback: (_) => true, ); await expectLater(devServerRunner.start(), completes); @@ -844,7 +847,7 @@ runs codegen with debounce when changes are made to the public or routes directo workingDirectory: Directory.current, directoryWatcher: (_) => directoryWatcher, isWindows: true, - startProcess: (_, __, {runInShell = false}) async => process, + startProcess: (_, _, {runInShell = false}) async => process, sigint: sigint, runProcess: (String executable, List arguments) async { processRunCalls.add([executable, ...arguments]); @@ -948,7 +951,7 @@ runs codegen with debounce when changes are made to the public or routes directo dartVmServicePort: dartVmServicePort, workingDirectory: Directory.current, directoryWatcher: (_) => directoryWatcher, - startProcess: (_, __, {runInShell = false}) async => process, + startProcess: (_, _, {runInShell = false}) async => process, sigint: sigint, runProcess: (String executable, List arguments) async { processRunCalls.add([executable, ...arguments]); @@ -990,7 +993,7 @@ lib/my_model.g.dart:53:20: Warning: Operand of null-aware operation '!' has type dartVmServicePort: dartVmServicePort, workingDirectory: Directory.current, directoryWatcher: (_) => directoryWatcher, - startProcess: (_, __, {runInShell = false}) async => process, + startProcess: (_, _, {runInShell = false}) async => process, sigint: sigint, runtimeCompatibilityCallback: (_) => true, ); @@ -1033,7 +1036,7 @@ Could not start the VM service: localhost:8181 is already in use.'''; dartVmServicePort: dartVmServicePort, workingDirectory: Directory.current, directoryWatcher: (_) => directoryWatcher, - startProcess: (_, __, {runInShell = false}) async => process, + startProcess: (_, _, {runInShell = false}) async => process, sigint: sigint, runProcess: (String executable, List arguments) async { processRunCalls.add([executable, ...arguments]); diff --git a/packages/dart_frog_cli/test/src/prod_server_builder/prod_server_builder_test.dart b/packages/dart_frog_cli/test/src/prod_server_builder/prod_server_builder_test.dart index f90a9c215..c445c4a8b 100644 --- a/packages/dart_frog_cli/test/src/prod_server_builder/prod_server_builder_test.dart +++ b/packages/dart_frog_cli/test/src/prod_server_builder/prod_server_builder_test.dart @@ -69,8 +69,8 @@ void main() { onVarsChanged: any(named: 'onVarsChanged'), ), ).thenAnswer((invocation) async { - (invocation.namedArguments[const Symbol('onVarsChanged')] as void - Function(Map)) + (invocation.namedArguments[const Symbol('onVarsChanged')] + as void Function(Map)) .call({'dartVersion': 'stable'}); }); when( diff --git a/packages/dart_frog_cli/test/src/route_configuration_watcher/route_configuration_watcher_test.dart b/packages/dart_frog_cli/test/src/route_configuration_watcher/route_configuration_watcher_test.dart index 74fec4528..7937ee58f 100644 --- a/packages/dart_frog_cli/test/src/route_configuration_watcher/route_configuration_watcher_test.dart +++ b/packages/dart_frog_cli/test/src/route_configuration_watcher/route_configuration_watcher_test.dart @@ -181,8 +181,8 @@ void main() { await routeConfigurationWatcher.start(); - final result = - routeConfigurationWatcher.forceRouteConfigurationRegeneration(); + final result = routeConfigurationWatcher + .forceRouteConfigurationRegeneration(); expect(result, same(routeConfiguration)); }); @@ -200,8 +200,8 @@ void main() { await routeConfigurationWatcher.start(); - final result = - routeConfigurationWatcher.forceRouteConfigurationRegeneration(); + final result = routeConfigurationWatcher + .forceRouteConfigurationRegeneration(); expect(result, isNull); }); @@ -220,8 +220,8 @@ void main() { await routeConfigurationWatcher.start(); await routeConfigurationWatcher.stop(); - final result = - routeConfigurationWatcher.forceRouteConfigurationRegeneration(); + final result = routeConfigurationWatcher + .forceRouteConfigurationRegeneration(); expect(result, isNull); }); diff --git a/packages/dart_frog_cli/test/src/runtime_compatibility_test.dart b/packages/dart_frog_cli/test/src/runtime_compatibility_test.dart index d2520d39f..a735f28de 100644 --- a/packages/dart_frog_cli/test/src/runtime_compatibility_test.dart +++ b/packages/dart_frog_cli/test/src/runtime_compatibility_test.dart @@ -75,8 +75,7 @@ void main() { ); }); - test( - 'throws when the pubspec.yaml does ' + test('throws when the pubspec.yaml does ' 'not contain a dart_frog dependency', () { const expected = 'Expected to find a dependency on "dart_frog" in the pubspec.yaml';