Skip to content

Commit dbd0c68

Browse files
authored
feat(dart_frog_prod_server): support custom entrypoint (#269)
1 parent 22ec806 commit dbd0c68

File tree

4 files changed

+37
-3
lines changed

4 files changed

+37
-3
lines changed

bricks/dart_frog_prod_server/__brick__/build/bin/server.dart

Lines changed: 4 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bricks/dart_frog_prod_server/hooks/pre_gen.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ Future<void> preGen(
4646
'globalMiddleware': configuration.globalMiddleware != null
4747
? configuration.globalMiddleware!.toJson()
4848
: false,
49+
'invokeCustomEntrypoint': configuration.invokeCustomEntrypoint,
4950
'pathDependencies': await getPathDependencies(projectDirectory),
5051
};
5152
}

bricks/dart_frog_prod_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.12.0 <3.0.0"
66

77
dependencies:
8-
dart_frog_gen: ^0.0.2-dev.7
8+
dart_frog_gen: ^0.0.2-dev.8
99
io: ^1.0.3
1010
mason: ^0.1.0-dev.31
1111
path: ^1.8.1

bricks/dart_frog_prod_server/hooks/test/pre_gen_test.dart

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,36 @@ void main() {
6868
verify(() => logger.err(exception.toString())).called(1);
6969
});
7070

71+
test('retains invokeCustomEntrypoint (true)', () async {
72+
const configuration = RouteConfiguration(
73+
middleware: [],
74+
directories: [],
75+
routes: [],
76+
rogueRoutes: [],
77+
endpoints: {},
78+
invokeCustomEntrypoint: true,
79+
);
80+
final exitCalls = <int>[];
81+
await preGen(
82+
context,
83+
buildConfiguration: (_) => configuration,
84+
exit: exitCalls.add,
85+
);
86+
expect(exitCalls, isEmpty);
87+
verifyNever(() => logger.err(any()));
88+
expect(
89+
context.vars,
90+
equals({
91+
'directories': <RouteDirectory>[],
92+
'routes': <RouteFile>[],
93+
'middleware': <MiddlewareFile>[],
94+
'globalMiddleware': false,
95+
'invokeCustomEntrypoint': true,
96+
'pathDependencies': <String>[]
97+
}),
98+
);
99+
});
100+
71101
test('updates context.vars when buildRouteConfiguration succeeds',
72102
() async {
73103
const configuration = RouteConfiguration(
@@ -137,6 +167,7 @@ void main() {
137167
{'name': 'hello_middleware', 'path': 'hello/middleware.dart'}
138168
],
139169
'globalMiddleware': {'name': 'middleware', 'path': 'middleware.dart'},
170+
'invokeCustomEntrypoint': false,
140171
'pathDependencies': <String>[],
141172
}),
142173
);

0 commit comments

Comments
 (0)