Skip to content

Commit aef2509

Browse files
authored
feat(dart_frog_dev_server): upgrade to dart_frog_gen ^0.2.0 (#375)
1 parent df60ae9 commit aef2509

File tree

2 files changed

+142
-25
lines changed

2 files changed

+142
-25
lines changed

bricks/dart_frog_dev_server/hooks/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ environment:
55
sdk: ">=2.18.0 <3.0.0"
66

77
dependencies:
8-
dart_frog_gen: ^0.1.0
8+
dart_frog_gen: ^0.2.0
99
mason: ^0.1.0-dev.31
1010
pubspec_parse: ^1.2.0
1111

bricks/dart_frog_dev_server/hooks/test/pre_gen_test.dart

Lines changed: 141 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -147,21 +147,52 @@ void main() {
147147
route: '/',
148148
middleware: null,
149149
files: [
150-
RouteFile(name: 'index', path: 'index.dart', route: '/'),
151-
RouteFile(name: 'hello', path: 'hello.dart', route: '/hello'),
150+
RouteFile(
151+
name: 'index',
152+
path: 'index.dart',
153+
route: '/',
154+
params: [],
155+
),
156+
RouteFile(
157+
name: 'hello',
158+
path: 'hello.dart',
159+
route: '/hello',
160+
params: [],
161+
),
152162
],
163+
params: [],
153164
)
154165
],
155166
routes: [
156-
RouteFile(name: 'index', path: 'index.dart', route: '/'),
157-
RouteFile(name: 'hello', path: 'hello.dart', route: '/hello'),
167+
RouteFile(
168+
name: 'index',
169+
path: 'index.dart',
170+
route: '/',
171+
params: [],
172+
),
173+
RouteFile(
174+
name: 'hello',
175+
path: 'hello.dart',
176+
route: '/hello',
177+
params: [],
178+
),
158179
],
159180
endpoints: {
160181
'/': [
161-
RouteFile(name: 'index', path: 'index.dart', route: '/'),
182+
RouteFile(
183+
name: 'index',
184+
path: 'index.dart',
185+
route: '/',
186+
params: [],
187+
),
162188
],
163189
'/hello': [
164-
RouteFile(name: 'hello', path: 'hello.dart', route: '/hello'),
190+
RouteFile(
191+
name: 'hello',
192+
path: 'hello.dart',
193+
route: '/hello',
194+
params: [],
195+
),
165196
]
166197
},
167198
rogueRoutes: [],
@@ -185,14 +216,35 @@ void main() {
185216
'route': '/',
186217
'middleware': false,
187218
'files': [
188-
{'name': 'index', 'path': 'index.dart', 'route': '/'},
189-
{'name': 'hello', 'path': 'hello.dart', 'route': '/hello'}
190-
]
219+
{
220+
'name': 'index',
221+
'path': 'index.dart',
222+
'route': '/',
223+
'file_params': <String>[],
224+
},
225+
{
226+
'name': 'hello',
227+
'path': 'hello.dart',
228+
'route': '/hello',
229+
'file_params': <String>[],
230+
}
231+
],
232+
'directory_params': <String>[],
191233
}
192234
],
193235
'routes': [
194-
{'name': 'index', 'path': 'index.dart', 'route': '/'},
195-
{'name': 'hello', 'path': 'hello.dart', 'route': '/hello'}
236+
{
237+
'name': 'index',
238+
'path': 'index.dart',
239+
'route': '/',
240+
'file_params': const <String>[],
241+
},
242+
{
243+
'name': 'hello',
244+
'path': 'hello.dart',
245+
'route': '/hello',
246+
'file_params': const <String>[],
247+
}
196248
],
197249
'middleware': [
198250
{'name': 'hello_middleware', 'path': 'hello/middleware.dart'}
@@ -227,10 +279,20 @@ void main() {
227279
test('reports nothing when there are endpoints and no conflicts', () {
228280
when(() => configuration.endpoints).thenReturn({
229281
'/': const [
230-
RouteFile(name: 'index', path: 'index.dart', route: '/'),
282+
RouteFile(
283+
name: 'index',
284+
path: 'index.dart',
285+
route: '/',
286+
params: [],
287+
),
231288
],
232289
'/hello': const [
233-
RouteFile(name: 'hello', path: 'hello.dart', route: '/hello')
290+
RouteFile(
291+
name: 'hello',
292+
path: 'hello.dart',
293+
route: '/hello',
294+
params: [],
295+
)
234296
]
235297
});
236298
reportRouteConflicts(context, configuration);
@@ -241,11 +303,26 @@ void main() {
241303
() {
242304
when(() => configuration.endpoints).thenReturn({
243305
'/': const [
244-
RouteFile(name: 'index', path: 'index.dart', route: '/'),
306+
RouteFile(
307+
name: 'index',
308+
path: 'index.dart',
309+
route: '/',
310+
params: [],
311+
),
245312
],
246313
'/hello': const [
247-
RouteFile(name: 'hello', path: 'hello.dart', route: '/hello'),
248-
RouteFile(name: 'hello_index', path: 'hello/index.dart', route: '/')
314+
RouteFile(
315+
name: 'hello',
316+
path: 'hello.dart',
317+
route: '/hello',
318+
params: [],
319+
),
320+
RouteFile(
321+
name: 'hello_index',
322+
path: 'hello/index.dart',
323+
route: '/',
324+
params: [],
325+
)
249326
]
250327
});
251328
reportRouteConflicts(context, configuration);
@@ -261,15 +338,40 @@ void main() {
261338
'when there are multiple endpoint with conflicts', () {
262339
when(() => configuration.endpoints).thenReturn({
263340
'/': const [
264-
RouteFile(name: 'index', path: 'index.dart', route: '/'),
341+
RouteFile(
342+
name: 'index',
343+
path: 'index.dart',
344+
route: '/',
345+
params: [],
346+
),
265347
],
266348
'/hello': const [
267-
RouteFile(name: 'hello', path: 'hello.dart', route: '/hello'),
268-
RouteFile(name: 'hello_index', path: 'hello/index.dart', route: '/')
349+
RouteFile(
350+
name: 'hello',
351+
path: 'hello.dart',
352+
route: '/hello',
353+
params: [],
354+
),
355+
RouteFile(
356+
name: 'hello_index',
357+
path: 'hello/index.dart',
358+
route: '/',
359+
params: [],
360+
)
269361
],
270362
'/echo': const [
271-
RouteFile(name: 'echo', path: 'echo.dart', route: '/echo'),
272-
RouteFile(name: 'echo_index', path: 'echo/index.dart', route: '/')
363+
RouteFile(
364+
name: 'echo',
365+
path: 'echo.dart',
366+
route: '/echo',
367+
params: [],
368+
),
369+
RouteFile(
370+
name: 'echo_index',
371+
path: 'echo/index.dart',
372+
route: '/',
373+
params: [],
374+
)
273375
]
274376
});
275377
reportRouteConflicts(context, configuration);
@@ -308,7 +410,12 @@ void main() {
308410
test('reports single rogue route', () {
309411
when(() => configuration.rogueRoutes).thenReturn(
310412
const [
311-
RouteFile(name: 'hello', path: 'hello.dart', route: '/hello'),
413+
RouteFile(
414+
name: 'hello',
415+
path: 'hello.dart',
416+
route: '/hello',
417+
params: [],
418+
),
312419
],
313420
);
314421
reportRogueRoutes(context, configuration);
@@ -322,8 +429,18 @@ void main() {
322429
test('reports multiple rogue routes', () {
323430
when(() => configuration.rogueRoutes).thenReturn(
324431
const [
325-
RouteFile(name: 'hello', path: 'hello.dart', route: '/hello'),
326-
RouteFile(name: 'hi', path: 'hi.dart', route: '/hi'),
432+
RouteFile(
433+
name: 'hello',
434+
path: 'hello.dart',
435+
route: '/hello',
436+
params: [],
437+
),
438+
RouteFile(
439+
name: 'hi',
440+
path: 'hi.dart',
441+
route: '/hi',
442+
params: [],
443+
),
327444
],
328445
);
329446
reportRogueRoutes(context, configuration);

0 commit comments

Comments
 (0)