Skip to content

Commit 12bb42e

Browse files
authored
Merge pull request #565 from DevKor-github/feature/issue-537-generated-policy
Align generated Dart file policy
2 parents 5f414ac + 00a930c commit 12bb42e

13 files changed

Lines changed: 135 additions & 8 deletions

.github/copilot-instructions.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,10 +199,11 @@ class ScheduleRepositoryImpl implements ScheduleRepository {
199199

200200
## Code Generation Files
201201

202-
**Never manually edit** generated files (`.g.dart`, `.freezed.dart`, `di_setup.config.dart`). These are created by:
202+
**Never manually edit or commit** generated Dart files (`.g.dart`, `.freezed.dart`, `.mocks.dart`, `di_setup.config.dart`, Widgetbook `*.directories.g.dart`). These are ignored build artifacts created by:
203203

204204
- `build_runner` for JSON serialization, Freezed, Injectable, Drift
205-
- Regenerate after modifying annotated classes
205+
- Widgetbook code generation for component directories
206+
- Regenerate after modifying annotated classes, then stage only source/configuration changes
206207

207208
## Testing
208209

.github/workflows/android-play-closed.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,10 @@ jobs:
106106
- name: Run code generation
107107
run: dart run build_runner build --delete-conflicting-outputs
108108

109-
- name: Verify generated files are current
109+
- name: Check generated Dart policy
110+
run: dart run tool/check_generated_dart_policy.dart
111+
112+
- name: Verify generation left tracked files unchanged
110113
run: git diff --exit-code
111114

112115
- name: Analyze

.github/workflows/android-play-internal.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,10 @@ jobs:
102102
- name: Run code generation
103103
run: dart run build_runner build --delete-conflicting-outputs
104104

105-
- name: Verify generated files are current
105+
- name: Check generated Dart policy
106+
run: dart run tool/check_generated_dart_policy.dart
107+
108+
- name: Verify generation left tracked files unchanged
106109
run: git diff --exit-code
107110

108111
- name: Analyze

.github/workflows/firebase-hosting-merge.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ jobs:
3232
- run: flutter pub get
3333

3434
- run: dart run build_runner build -d
35+
36+
- name: Check generated Dart policy
37+
run: dart run tool/check_generated_dart_policy.dart
38+
3539
- name: Build Web
3640
env:
3741
REST_API_URL: ${{ vars.REST_API_URL }}

.github/workflows/firebase-hosting-pull-request-widgetbook.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ jobs:
3737
- run: dart run build_runner build -d
3838
working-directory: ${{ env.working-directory }}
3939

40+
- name: Check generated Dart policy
41+
run: dart run tool/check_generated_dart_policy.dart
42+
4043
- run: flutter build web --release
4144
working-directory: ${{ env.working-directory }}
4245

.github/workflows/firebase-hosting-pull-request.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ jobs:
3535

3636
- run: dart run build_runner build -d
3737

38+
- name: Check generated Dart policy
39+
run: dart run tool/check_generated_dart_policy.dart
40+
3841
- name: Build Web
3942
env:
4043
REST_API_URL: ${{ vars.REST_API_URL }}

.github/workflows/firebase_hosting-merge-widgetbook.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ jobs:
3434

3535
- run: dart run build_runner build -d
3636
working-directory: ${{ env.working-directory }}
37+
38+
- name: Check generated Dart policy
39+
run: dart run tool/check_generated_dart_policy.dart
3740

3841
- run: flutter build web --release
3942
working-directory: ${{ env.working-directory }}

.github/workflows/flutter_test.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ jobs:
2929
run: flutter --version
3030
- name: Run generator
3131
run: dart run build_runner build --delete-conflicting-outputs
32+
- name: Check generated Dart policy
33+
run: dart run tool/check_generated_dart_policy.dart
3234
- name: Analyze
3335
run: flutter analyze
3436
- name: Run test with coverage

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ app.*.map.json
4646
/android/app/profile
4747
/android/app/release
4848

49+
# Generated Dart outputs are local/CI build artifacts; regenerate them but do
50+
# not commit them.
4951
*.g.dart
5052
*.mocks.dart
5153
*.config.dart

AGENTS.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ This Flutter app uses layered code under `lib/`. Platform services, database, DI
77
## Build, Test, and Development Commands
88

99
- `flutter pub get`: install Dart and Flutter dependencies.
10-
- `dart run build_runner build --delete-conflicting-outputs`: regenerate Drift, JSON, Injectable, and other generated files.
10+
- `dart run build_runner build --delete-conflicting-outputs`: regenerate Drift, JSON, Injectable, Mockito, Freezed, and Widgetbook Dart outputs as ignored local build artifacts.
1111
- `flutter analyze`: run analyzer checks using `analysis_options.yaml`.
1212
- `flutter test`: run the full test suite.
1313
- `flutter test --coverage`: run tests and update `coverage/lcov.info`.
@@ -18,15 +18,15 @@ Do not use `npm test`; the root `package.json` placeholder script intentionally
1818

1919
## Coding Style & Naming Conventions
2020

21-
Follow `package:flutter_lints/flutter.yaml`. Use standard Dart formatting with two-space indentation; run `dart format lib test` before broad Dart edits are submitted. File names use `snake_case.dart`; classes, blocs, cubits, entities, and models use `PascalCase`; methods and fields use `camelCase`. Keep generated `*.g.dart` and `*.config.dart` files in sync. Preserve clean-architecture boundaries: UI should depend on domain use cases, not remote data sources.
21+
Follow `package:flutter_lints/flutter.yaml`. Use standard Dart formatting with two-space indentation; run `dart format lib test` before broad Dart edits are submitted. File names use `snake_case.dart`; classes, blocs, cubits, entities, and models use `PascalCase`; methods and fields use `camelCase`. Generated Dart outputs (`*.g.dart`, `*.config.dart`, `*.freezed.dart`, `*.mocks.dart`, including Widgetbook directories output) are ignored build artifacts; regenerate them before analyze/test but do not stage or commit them. Preserve clean-architecture boundaries: UI should depend on domain use cases, not remote data sources.
2222

2323
## Testing Guidelines
2424

2525
Place tests next to the matching layer path under `test/`, and name files `*_test.dart` (for example, `test/data/repositories/schedule_repository_impl_test.dart`). Prefer unit tests for domain/data changes and widget tests for presentation behavior. For blocs or cubits, cover events, emitted states, and repository failure cases.
2626

2727
## Commit & Pull Request Guidelines
2828

29-
Commits follow Conventional Commits through commitlint, such as `feat: add schedule refresh` or `chore: update widget layout`; the configured header limit is 500 characters. PRs should include a description, linked issue when applicable, test results, and screenshots or recordings for UI changes. Call out generated-file updates.
29+
Commits follow Conventional Commits through commitlint, such as `feat: add schedule refresh` or `chore: update widget layout`; the configured header limit is 500 characters. PRs should include a description, linked issue when applicable, test results, and screenshots or recordings for UI changes. Call out generator or source changes when they affect generated Dart output, but do not include ignored generated Dart files in PRs.
3030

3131
## Agent-Specific Instructions
3232

0 commit comments

Comments
 (0)