Skip to content

Commit b90ce81

Browse files
authored
feat(dart_frog_cli): package:dart_frog runtime compatibility check (#366)
1 parent f37406e commit b90ce81

File tree

16 files changed

+274
-8
lines changed

16 files changed

+274
-8
lines changed

.github/workflows/examples_counter.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ on:
1414
- ".github/workflows/examples_counter.yaml"
1515
- "packages/dart_frog/lib/**"
1616
- "packages/dart_frog/pubspec.yaml"
17+
- "packages/dart_frog_cli/lib/**"
18+
- "packages/dart_frog_cli/pubspec.yaml"
1719
branches:
1820
- main
1921

.github/workflows/examples_echo.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ on:
1414
- ".github/workflows/examples_echo.yaml"
1515
- "packages/dart_frog/lib/**"
1616
- "packages/dart_frog/pubspec.yaml"
17+
- "packages/dart_frog_cli/lib/**"
18+
- "packages/dart_frog_cli/pubspec.yaml"
1719
branches:
1820
- main
1921

.github/workflows/examples_hello_world.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ on:
1414
- ".github/workflows/examples_hello_world.yaml"
1515
- "packages/dart_frog/lib/**"
1616
- "packages/dart_frog/pubspec.yaml"
17+
- "packages/dart_frog_cli/lib/**"
18+
- "packages/dart_frog_cli/pubspec.yaml"
1719
branches:
1820
- main
1921

.github/workflows/examples_todos.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ on:
1616
- ".github/workflows/examples_todos.yaml"
1717
- "packages/dart_frog/lib/**"
1818
- "packages/dart_frog/pubspec.yaml"
19+
- "packages/dart_frog_cli/lib/**"
20+
- "packages/dart_frog_cli/pubspec.yaml"
1921
branches:
2022
- main
2123

docs/docs/overview.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ dart_frog dev
5050
By default port `8080` is used. A custom port can be used via the `--port` option.
5151
:::
5252

53+
:::caution
54+
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.
55+
:::
56+
5357
### Create a Production Build 📦
5458

5559
Create a production build which includes a `DockerFile` so that you can deploy anywhere:

examples/counter/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ environment:
77
sdk: ">=2.17.0 <3.0.0"
88

99
dependencies:
10-
dart_frog: ^0.0.1-dev
10+
dart_frog: ^0.1.0
1111

1212
dev_dependencies:
1313
http: ^0.13.5

examples/echo/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ environment:
77
sdk: ">=2.17.0 <3.0.0"
88

99
dependencies:
10-
dart_frog: ^0.0.1-dev
10+
dart_frog: ^0.1.0
1111

1212
dev_dependencies:
1313
http: ^0.13.5

examples/hello_world/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ environment:
77
sdk: ">=2.17.0 <3.0.0"
88

99
dependencies:
10-
dart_frog: ^0.0.1-dev
10+
dart_frog: ^0.1.0
1111

1212
dev_dependencies:
1313
http: ^0.13.5

examples/todos/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ environment:
77
sdk: ">=2.17.0 <3.0.0"
88

99
dependencies:
10-
dart_frog: ^0.0.1-dev
10+
dart_frog: ^0.1.0
1111
in_memory_todos_data_source:
1212
path: packages/in_memory_todos_data_source
1313
todos_data_source:

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

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,26 @@
1+
import 'dart:io';
2+
13
import 'package:dart_frog_cli/src/command.dart';
24
import 'package:dart_frog_cli/src/commands/build/templates/dart_frog_prod_server_bundle.dart';
35
import 'package:dart_frog_cli/src/commands/commands.dart';
6+
import 'package:dart_frog_cli/src/runtime_compatibility.dart'
7+
as runtime_compatibility;
48
import 'package:mason/mason.dart';
59

610
/// {@template build_command}
711
/// `dart_frog build` command which creates a production build`.
812
/// {@endtemplate}
913
class BuildCommand extends DartFrogCommand {
1014
/// {@macro build_command}
11-
BuildCommand({super.logger, GeneratorBuilder? generator})
12-
: _generator = generator ?? MasonGenerator.fromBundle;
13-
15+
BuildCommand({
16+
super.logger,
17+
void Function(Directory)? ensureRuntimeCompatibility,
18+
GeneratorBuilder? generator,
19+
}) : _ensureRuntimeCompatibility = ensureRuntimeCompatibility ??
20+
runtime_compatibility.ensureRuntimeCompatibility,
21+
_generator = generator ?? MasonGenerator.fromBundle;
22+
23+
final void Function(Directory) _ensureRuntimeCompatibility;
1424
final GeneratorBuilder _generator;
1525

1626
@override
@@ -21,6 +31,8 @@ class BuildCommand extends DartFrogCommand {
2131

2232
@override
2333
Future<int> run() async {
34+
_ensureRuntimeCompatibility(cwd);
35+
2436
final generator = await _generator(dartFrogProdServerBundle);
2537
var vars = <String, dynamic>{};
2638

0 commit comments

Comments
 (0)