Skip to content

Commit d7e178e

Browse files
committed
Merge branch 'dependabot/pub/packages/dart_frog/very_good_analysis-7.0.0' of github.com:VeryGoodOpenSource/dart_frog into dependabot/pub/packages/dart_frog/very_good_analysis-7.0.0
2 parents e936b5f + 0a74a8c commit d7e178e

File tree

9 files changed

+40
-27
lines changed

9 files changed

+40
-27
lines changed
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
include: package:very_good_analysis/analysis_options.6.0.0.yaml
1+
include: package:very_good_analysis/analysis_options.7.0.0.yaml

bricks/dart_frog_dev_server/hooks/pre_gen.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Future<void> preGen(
2323
final RouteConfiguration configuration;
2424
try {
2525
configuration = buildConfiguration(io.Directory.current);
26-
} catch (error) {
26+
} on Exception catch (error) {
2727
context.logger.err('$error');
2828
return exit(1);
2929
}

bricks/dart_frog_dev_server/hooks/pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ dev_dependencies:
1313
mocktail: ^1.0.0
1414
path: ^1.8.2
1515
test: ^1.25.0
16-
very_good_analysis: ^6.0.0
16+
very_good_analysis: ^7.0.0

docs/docs/overview.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ To customize the running dev server, you can use the following options:
5353
- `--port` - The port to run the dev server on. Defaults to `8080`.
5454
- `--dart-vm-service-port` - The port to run the Dart VM service on. Defaults to `8181`. This is required when trying to run multiple dev servers simultaneously on the same host.
5555
- `--host` - The host to run the dev server on. Defaults to `localhost`.
56-
57-
:::
56+
To customize it further, a `--` signals the **end of options** and disables further option processing from `dart_frog dev`. Any arguments after the `--` are passed into the [Dart tool](https://dart.dev/tools/dart-tool) process. For example, you could use the `--` to enable [experimental flags](https://dart.dev/tools/experiment-flags) such as macros by doing `dart_frog dev -- --enable-experiment=macros`.
57+
:::
5858

5959
:::caution
6060
Each release of the `dart_frog_cli` supports a specific version range of the `dart_frog` runtime. If the current version of the `dart_frog` runtime is incompatible with the installed `dart_frog_cli` version, an error will be reported and you will need to update your `dart_frog_cli` version or `dart_frog` version accordingly.
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
include: package:very_good_analysis/analysis_options.6.0.0.yaml
1+
include: package:very_good_analysis/analysis_options.7.0.0.yaml

packages/dart_frog_cli/e2e/pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ dev_dependencies:
1414
meta: ^1.7.0
1515
path: ^1.8.2
1616
test: ^1.19.2
17-
very_good_analysis: ^6.0.0
17+
very_good_analysis: ^7.0.0

packages/dart_frog_cli/lib/src/commands/dev/dev.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ class DevCommand extends DartFrogCommand {
131131
);
132132

133133
try {
134-
await _devServerRunner.start();
134+
await _devServerRunner.start(results.rest);
135135
return (await _devServerRunner.exitCode).code;
136136
} catch (e) {
137137
logger.err(e.toString());

packages/dart_frog_cli/lib/src/dev_server_runner/dev_server_runner.dart

+17-3
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,16 @@ class DevServerRunner {
233233
///
234234
/// This method will throw a [DartFrogDevServerException] if called after
235235
/// [stop] has been called.
236-
Future<void> start() async {
236+
///
237+
/// The [arguments] are optional and usually expected to be those from
238+
/// `ArgResults.rest`; since a `--` signals the **end of options** and
239+
/// disables further option processing from `dart_frog dev`. Any [arguments]
240+
/// after the `--` are passed into the [Dart tool](https://dart.dev/tools/dart-tool)
241+
/// process.
242+
///
243+
/// For example, you could use the `--` to enable [experimental flags](https://dart.dev/tools/experiment-flags)
244+
/// such as macros by doing `dart_frog dev -- --enable-experiment=macros`.
245+
Future<void> start([List<String> arguments = const []]) async {
237246
if (isCompleted) {
238247
throw DartFrogDevServerException(
239248
'Cannot start a dev server after it has been stopped.',
@@ -258,12 +267,17 @@ class DevServerRunner {
258267
);
259268

260269
logger.detail(
261-
'''[process] dart $enableVmServiceFlag $serverDartFilePath''',
270+
'''[process] dart $enableVmServiceFlag $serverDartFilePath ${arguments.join(' ')}''',
262271
);
263272

264273
final process = _serverProcess = await _startProcess(
265274
'dart',
266-
[enableVmServiceFlag, '--enable-asserts', serverDartFilePath],
275+
[
276+
enableVmServiceFlag,
277+
'--enable-asserts',
278+
...arguments,
279+
serverDartFilePath,
280+
],
267281
runInShell: true,
268282
);
269283

packages/dart_frog_cli/test/src/commands/dev/dev_test.dart

+15-16
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ void main() {
3636
when<dynamic>(() => argResults['port']).thenReturn('8080');
3737
when<dynamic>(() => argResults['dart-vm-service-port'])
3838
.thenReturn('8181');
39+
when(() => argResults.rest).thenReturn(['--enable-experiment=macros']);
3940
when(() => stdin.hasTerminal).thenReturn(false);
4041
});
4142

@@ -45,14 +46,15 @@ void main() {
4546
});
4647

4748
test('run the dev server with the given parameters', () async {
48-
when(() => runner.start()).thenAnswer((_) => Future.value());
49+
when(() => runner.start(any())).thenAnswer((_) => Future.value());
4950
when(() => runner.exitCode).thenAnswer(
5051
(_) => Future.value(ExitCode.success),
5152
);
5253

5354
when(() => argResults['hostname']).thenReturn('192.168.1.2');
5455
when(() => argResults['port']).thenReturn('1234');
5556
when(() => argResults['dart-vm-service-port']).thenReturn('5678');
57+
when(() => argResults.rest).thenReturn(['--enable-experiment=macros']);
5658

5759
final cwd = Directory.systemTemp;
5860

@@ -90,7 +92,9 @@ void main() {
9092

9193
await expectLater(command.run(), completion(ExitCode.success.code));
9294

93-
verify(() => runner.start()).called(1);
95+
verify(
96+
() => runner.start(any(that: equals(['--enable-experiment=macros']))),
97+
).called(1);
9498

9599
expect(givenPort, equals('1234'));
96100
expect(givenAddress, InternetAddress.tryParse('192.168.1.2'));
@@ -119,12 +123,7 @@ void main() {
119123
..testArgResults = argResults
120124
..testStdin = stdin;
121125

122-
when(() => runner.start()).thenAnswer((_) => Future.value());
123-
when(() => runner.exitCode).thenAnswer(
124-
(_) => Future.value(ExitCode.success),
125-
);
126-
127-
when(() => runner.start()).thenAnswer((_) => Future.value());
126+
when(() => runner.start(any())).thenAnswer((_) => Future.value());
128127
when(() => runner.exitCode).thenAnswer((_) async => ExitCode.unavailable);
129128

130129
await expectLater(command.run(), completion(ExitCode.unavailable.code));
@@ -149,7 +148,7 @@ void main() {
149148
..testArgResults = argResults
150149
..testStdin = stdin;
151150

152-
when(() => runner.start()).thenAnswer((_) async {
151+
when(() => runner.start(any())).thenAnswer((_) async {
153152
throw DartFrogDevServerException('oops');
154153
});
155154

@@ -158,7 +157,7 @@ void main() {
158157
});
159158

160159
test('fails if hostname is invalid', () async {
161-
when(() => runner.start()).thenAnswer((_) => Future.value());
160+
when(() => runner.start(any())).thenAnswer((_) => Future.value());
162161
when(() => runner.exitCode).thenAnswer(
163162
(_) => Future.value(ExitCode.success),
164163
);
@@ -196,7 +195,7 @@ void main() {
196195
),
197196
).called(1);
198197

199-
verifyNever(() => runner.start());
198+
verifyNever(() => runner.start(any()));
200199
});
201200

202201
group('listening to stdin', () {
@@ -233,7 +232,7 @@ void main() {
233232
),
234233
);
235234

236-
when(() => runner.start()).thenAnswer((_) => Future.value());
235+
when(() => runner.start(any())).thenAnswer((_) => Future.value());
237236

238237
when(() => runner.reload()).thenAnswer((_) => Future.value());
239238
when(() => runner.exitCode).thenAnswer(
@@ -332,9 +331,9 @@ void main() {
332331
});
333332

334333
test('cancels subscription when dev server throws', () async {
335-
final startComplter = Completer<void>();
336-
when(() => runner.start()).thenAnswer((_) async {
337-
await startComplter.future;
334+
final startCompleter = Completer<void>();
335+
when(() => runner.start(any())).thenAnswer((_) async {
336+
await startCompleter.future;
338337
});
339338

340339
command.run().ignore();
@@ -347,7 +346,7 @@ void main() {
347346
verify(() => stdin.echoMode = false).called(1);
348347
verify(() => stdin.lineMode = false).called(1);
349348

350-
startComplter.completeError(Exception('oops'));
349+
startCompleter.completeError(Exception('oops'));
351350
await Future<void>.delayed(Duration.zero);
352351

353352
expect(stdinController.hasListener, isFalse);

0 commit comments

Comments
 (0)