Skip to content

Commit 54b42e6

Browse files
committed
feat: update cli bundles
1 parent acc6829 commit 54b42e6

File tree

58 files changed

+1025
-1478
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+1025
-1478
lines changed

packages/dart_frog_cli/e2e/test/daemon/daemon_domain_test.dart

+4-16
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,7 @@ void main() {
2121
late final DaemonStdioHelper daemonStdio;
2222

2323
setUpAll(() async {
24-
await dartFrogCreate(
25-
projectName: projectName,
26-
directory: tempDirectory,
27-
);
24+
await dartFrogCreate(projectName: projectName, directory: tempDirectory);
2825
daemonProcess = await dartFrogDaemonStart();
2926

3027
daemonStdio = DaemonStdioHelper(daemonProcess);
@@ -34,10 +31,7 @@ void main() {
3431
group('daemon domain', () {
3532
test('daemon is ready', () async {
3633
final readyEvent = await daemonStdio.awaitForDaemonEvent('daemon.ready');
37-
expect(
38-
readyEvent.params?.keys,
39-
containsAll(['version', 'processId']),
40-
);
34+
expect(readyEvent.params?.keys, containsAll(['version', 'processId']));
4135
});
4236

4337
group('daemon responds to invalid messages', () {
@@ -46,10 +40,7 @@ void main() {
4640
final protocolError = await daemonStdio.awaitForDaemonEvent(
4741
'daemon.protocolError',
4842
);
49-
expect(
50-
protocolError.params?['message'],
51-
equals('Not a valid JSON'),
52-
);
43+
expect(protocolError.params?['message'], equals('Not a valid JSON'));
5344
});
5445

5546
test('daemon process responds to invalid json', () async {
@@ -127,10 +118,7 @@ void main() {
127118
),
128119
);
129120

130-
expect(
131-
response.result,
132-
equals({'version': '0.0.1'}),
133-
);
121+
expect(response.result, equals({'version': '0.0.1'}));
134122
});
135123

136124
test('daemon.kill', () async {

packages/dart_frog_cli/e2e/test/daemon/dev_server_domain_test.dart

+43-69
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,8 @@ void main() {
4949
var requestCount = 0;
5050

5151
setUpAll(() async {
52-
await dartFrogCreate(
53-
projectName: projectName1,
54-
directory: tempDirectory,
55-
);
56-
await dartFrogCreate(
57-
projectName: projectName2,
58-
directory: tempDirectory,
59-
);
52+
await dartFrogCreate(projectName: projectName1, directory: tempDirectory);
53+
await dartFrogCreate(projectName: projectName2, directory: tempDirectory);
6054

6155
daemonProcess = await dartFrogDaemonStart();
6256
daemonStdio = DaemonStdioHelper(daemonProcess);
@@ -191,8 +185,9 @@ void main() {
191185
);
192186
});
193187

194-
testServer(port: project1Server2Port, 'GET / on project 1 server 2',
195-
(host) async {
188+
testServer(port: project1Server2Port, 'GET / on project 1 server 2', (
189+
host,
190+
) async {
196191
final response = await http.get(Uri.parse(host));
197192
expect(response.statusCode, equals(HttpStatus.ok));
198193
expect(response.body, equals('Welcome to Dart Frog!'));
@@ -205,10 +200,7 @@ void main() {
205200

206201
test('modify files on project 2', () async {
207202
final routesDirectory = Directory(
208-
path.join(
209-
projectDirectory2.path,
210-
'routes',
211-
),
203+
path.join(projectDirectory2.path, 'routes'),
212204
);
213205

214206
expect(fileAt('index.dart', on: routesDirectory), exists);
@@ -224,17 +216,16 @@ void main() {
224216
id: '${++requestCount}',
225217
domain: 'dev_server',
226218
method: 'reload',
227-
params: {
228-
'applicationId': project2ServerId,
229-
},
219+
params: {'applicationId': project2ServerId},
230220
),
231221
);
232222

233223
expect(response.isSuccess, isTrue);
234224
});
235225

236-
testServer(port: project2ServerPort, 'GET /new_route on project 2',
237-
(host) async {
226+
testServer(port: project2ServerPort, 'GET /new_route on project 2', (
227+
host,
228+
) async {
238229
final response = await http.get(Uri.parse(host));
239230
expect(response.statusCode, equals(HttpStatus.ok));
240231
expect(response.headers, contains('date'));
@@ -245,27 +236,21 @@ void main() {
245236
});
246237

247238
test('try staggered-stop a dev server on project 1', () async {
248-
final (response1, response2) =
249-
await daemonStdio.sendStaggeredDaemonRequest(
250-
(
251-
DaemonRequest(
252-
id: '${++requestCount}',
253-
domain: 'dev_server',
254-
method: 'stop',
255-
params: {
256-
'applicationId': project1Server1Id,
257-
},
258-
),
259-
DaemonRequest(
260-
id: '${++requestCount}',
261-
domain: 'dev_server',
262-
method: 'stop',
263-
params: {
264-
'applicationId': project1Server1Id,
265-
},
266-
),
267-
),
268-
);
239+
final (response1, response2) = await daemonStdio
240+
.sendStaggeredDaemonRequest((
241+
DaemonRequest(
242+
id: '${++requestCount}',
243+
domain: 'dev_server',
244+
method: 'stop',
245+
params: {'applicationId': project1Server1Id},
246+
),
247+
DaemonRequest(
248+
id: '${++requestCount}',
249+
domain: 'dev_server',
250+
method: 'stop',
251+
params: {'applicationId': project1Server1Id},
252+
),
253+
));
269254

270255
expect(response1.isSuccess, isTrue);
271256
expect(response1.result!['exitCode'], equals(0));
@@ -278,9 +263,7 @@ void main() {
278263
id: '${++requestCount}',
279264
domain: 'dev_server',
280265
method: 'stop',
281-
params: {
282-
'applicationId': project1Server1Id,
283-
},
266+
params: {'applicationId': project1Server1Id},
284267
),
285268
);
286269

@@ -305,16 +288,15 @@ void main() {
305288
});
306289

307290
testServer(
308-
// TODO(renancaraujo): this fails on linux: https://github.com/VeryGoodOpenSource/dart_frog/issues/807
309-
skip: Platform.isLinux,
310-
'GET on project 1 server 1: connection refused', (host) async {
311-
final responseFuture = http.get(Uri.parse(host));
312-
313-
await expectLater(
314-
responseFuture,
315-
throwsA(isA<SocketException>()),
316-
);
317-
});
291+
// TODO(renancaraujo): this fails on linux: https://github.com/VeryGoodOpenSource/dart_frog/issues/807
292+
skip: Platform.isLinux,
293+
'GET on project 1 server 1: connection refused',
294+
(host) async {
295+
final responseFuture = http.get(Uri.parse(host));
296+
297+
await expectLater(responseFuture, throwsA(isA<SocketException>()));
298+
},
299+
);
318300

319301
testServer(
320302
port: project2ServerPort,
@@ -325,12 +307,7 @@ void main() {
325307
(host) async {
326308
final responseFuture = http.get(Uri.parse(host));
327309

328-
await expectLater(
329-
responseFuture,
330-
throwsA(
331-
isA<SocketException>(),
332-
),
333-
);
310+
await expectLater(responseFuture, throwsA(isA<SocketException>()));
334311
},
335312
);
336313

@@ -340,16 +317,13 @@ void main() {
340317
// TODO(renancaraujo): this fails on linux: https://github.com/VeryGoodOpenSource/dart_frog/issues/807
341318
skip: Platform.isLinux,
342319
(host) async {
343-
await expectLater(
344-
() async {
345-
final response = await http.get(Uri.parse(host));
346-
stderr
347-
..writeln(response.statusCode)
348-
..writeln(response.body);
349-
return response;
350-
},
351-
throwsA(isA<SocketException>()),
352-
);
320+
await expectLater(() async {
321+
final response = await http.get(Uri.parse(host));
322+
stderr
323+
..writeln(response.statusCode)
324+
..writeln(response.body);
325+
return response;
326+
}, throwsA(isA<SocketException>()));
353327
},
354328
);
355329
});

packages/dart_frog_cli/e2e/test/daemon/route_configuration_domain_test.dart

+19-35
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,7 @@ void main() {
3232
late String projectWatcherId;
3333

3434
setUpAll(() async {
35-
await dartFrogCreate(
36-
projectName: projectName,
37-
directory: tempDirectory,
38-
);
35+
await dartFrogCreate(projectName: projectName, directory: tempDirectory);
3936
daemonProcess = await dartFrogDaemonStart();
4037

4138
daemonStdio = DaemonStdioHelper(daemonProcess);
@@ -54,9 +51,7 @@ void main() {
5451
id: '${++requestCount}',
5552
domain: 'route_configuration',
5653
method: 'watcherStart',
57-
params: {
58-
'workingDirectory': projectDirectory.path,
59-
},
54+
params: {'workingDirectory': projectDirectory.path},
6055
),
6156
);
6257

@@ -164,9 +159,7 @@ void main() {
164159
id: '${requestCount++}',
165160
domain: 'route_configuration',
166161
method: 'watcherGenerateRouteConfiguration',
167-
params: {
168-
'watcherId': projectWatcherId,
169-
},
162+
params: {'watcherId': projectWatcherId},
170163
),
171164
);
172165

@@ -208,10 +201,7 @@ void main() {
208201
containsPair('requestId', '1'),
209202
containsPair(
210203
'message',
211-
allOf(
212-
startsWith('[watcher] add'),
213-
endsWith('rogue_route.dart'),
214-
),
204+
allOf(startsWith('[watcher] add'), endsWith('rogue_route.dart')),
215205
),
216206
),
217207
timeout: const Duration(seconds: 5),
@@ -236,27 +226,21 @@ void main() {
236226
});
237227

238228
test('staggered-stop watcher', () async {
239-
final (response1, response2) =
240-
await daemonStdio.sendStaggeredDaemonRequest(
241-
(
242-
DaemonRequest(
243-
id: '${requestCount++}',
244-
domain: 'route_configuration',
245-
method: 'watcherStop',
246-
params: {
247-
'watcherId': projectWatcherId,
248-
},
249-
),
250-
DaemonRequest(
251-
id: '${requestCount++}',
252-
domain: 'route_configuration',
253-
method: 'watcherStop',
254-
params: {
255-
'watcherId': projectWatcherId,
256-
},
257-
),
258-
),
259-
);
229+
final (response1, response2) = await daemonStdio
230+
.sendStaggeredDaemonRequest((
231+
DaemonRequest(
232+
id: '${requestCount++}',
233+
domain: 'route_configuration',
234+
method: 'watcherStop',
235+
params: {'watcherId': projectWatcherId},
236+
),
237+
DaemonRequest(
238+
id: '${requestCount++}',
239+
domain: 'route_configuration',
240+
method: 'watcherStop',
241+
params: {'watcherId': projectWatcherId},
242+
),
243+
));
260244

261245
expect(response1.isSuccess, isTrue);
262246
expect(response1.result?['exitCode'], equals(0));

packages/dart_frog_cli/e2e/test/dev_test.dart

+28-31
Original file line numberDiff line numberDiff line change
@@ -63,41 +63,38 @@ void main() {
6363
tempDirectory.delete(recursive: true).ignore();
6464
});
6565

66-
test(
67-
'running two different dart_frog dev command will fail '
68-
'when different dart vm port is not set',
69-
() async {
70-
final process1 = await dartFrogDev(
71-
directory: Directory(path.join(tempDirectory.path, projectName1)),
66+
test('running two different dart_frog dev command will fail '
67+
'when different dart vm port is not set', () async {
68+
final process1 = await dartFrogDev(
69+
directory: Directory(path.join(tempDirectory.path, projectName1)),
70+
);
71+
addTearDown(() async {
72+
await killDartFrogServer(process1.pid).ignoreErrors();
73+
});
74+
75+
try {
76+
final process2 = await dartFrogDev(
77+
directory: Directory(path.join(tempDirectory.path, projectName2)),
78+
exitOnError: false,
7279
);
7380
addTearDown(() async {
74-
await killDartFrogServer(process1.pid).ignoreErrors();
81+
await killDartFrogServer(process2.pid).ignoreErrors();
7582
});
7683

77-
try {
78-
final process2 = await dartFrogDev(
79-
directory: Directory(path.join(tempDirectory.path, projectName2)),
80-
exitOnError: false,
81-
);
82-
addTearDown(() async {
83-
await killDartFrogServer(process2.pid).ignoreErrors();
84-
});
85-
86-
fail('exception not thrown');
87-
} catch (e) {
88-
expect(e.toString(), contains('Could not start the VM service:'));
89-
90-
expect(
91-
e.toString(),
92-
contains(
93-
'DartDevelopmentServiceException: Failed to create server socket',
94-
),
95-
);
96-
97-
expect(e.toString(), contains('127.0.0.1:8181'));
98-
}
99-
},
100-
);
84+
fail('exception not thrown');
85+
} catch (e) {
86+
expect(e.toString(), contains('Could not start the VM service:'));
87+
88+
expect(
89+
e.toString(),
90+
contains(
91+
'DartDevelopmentServiceException: Failed to create server socket',
92+
),
93+
);
94+
95+
expect(e.toString(), contains('127.0.0.1:8181'));
96+
}
97+
});
10198

10299
test(
103100
'runs two different dart_frog dev servers without any issues',

packages/dart_frog_cli/e2e/test/helpers/dart_frog_build.dart

+1-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ import 'dart:io';
22

33
import 'helpers.dart';
44

5-
Future<void> dartFrogBuild({
6-
required Directory directory,
7-
}) async {
5+
Future<void> dartFrogBuild({required Directory directory}) async {
86
await runProcess(
97
'dart_frog',
108
['build'],

0 commit comments

Comments
 (0)