everydaydevops-luff 3.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. everydaydevops_luff-3.0.0.data/data/share/luff/skills/flutter-audit/SKILL.md +30 -0
  2. everydaydevops_luff-3.0.0.data/data/share/luff/skills/flutter-create/SKILL.md +27 -0
  3. everydaydevops_luff-3.0.0.data/data/share/luff/skills/flutter-feature/SKILL.md +30 -0
  4. everydaydevops_luff-3.0.0.data/data/share/luff/skills/flutter-migrate/SKILL.md +30 -0
  5. everydaydevops_luff-3.0.0.data/data/share/luff/skills/flutter-verify/SKILL.md +12 -0
  6. everydaydevops_luff-3.0.0.dist-info/METADATA +50 -0
  7. everydaydevops_luff-3.0.0.dist-info/RECORD +40 -0
  8. everydaydevops_luff-3.0.0.dist-info/WHEEL +5 -0
  9. everydaydevops_luff-3.0.0.dist-info/entry_points.txt +3 -0
  10. everydaydevops_luff-3.0.0.dist-info/licenses/LICENSE +21 -0
  11. everydaydevops_luff-3.0.0.dist-info/top_level.txt +1 -0
  12. flutter_setup/__init__.py +0 -0
  13. flutter_setup/appender.py +46 -0
  14. flutter_setup/bootstrap.py +1655 -0
  15. flutter_setup/cicd_generator.py +885 -0
  16. flutter_setup/cli.py +1193 -0
  17. flutter_setup/config.py +156 -0
  18. flutter_setup/config_manager.py +160 -0
  19. flutter_setup/core.py +204 -0
  20. flutter_setup/exceptions.py +37 -0
  21. flutter_setup/flutter_manager.py +579 -0
  22. flutter_setup/platform.py +15 -0
  23. flutter_setup/prerequisites.py +39 -0
  24. flutter_setup/prerequisites_linux.py +140 -0
  25. flutter_setup/prerequisites_macos.py +226 -0
  26. flutter_setup/project_cli.py +397 -0
  27. flutter_setup/project_creator.py +91 -0
  28. flutter_setup/standards.py +99 -0
  29. flutter_setup/standards_data/everyday-devops-flutter-1.0.0.json +97 -0
  30. flutter_setup/standards_data/manifest-v1.schema.json +209 -0
  31. flutter_setup/templates/everyday/AGENTS.md +5 -0
  32. flutter_setup/templates/everyday/app_log.dart +6 -0
  33. flutter_setup/templates/everyday/home_content.dart +9 -0
  34. flutter_setup/templates/everyday/home_repository.dart +8 -0
  35. flutter_setup/templates/everyday/home_screen.dart +60 -0
  36. flutter_setup/templates/everyday/offline_store.dart +5 -0
  37. flutter_setup/templates/everyday/sentry_startup.dart +16 -0
  38. flutter_setup/templates/everyday/theme.dart +12 -0
  39. flutter_setup/templates.py +73 -0
  40. flutter_setup/verification.py +160 -0
@@ -0,0 +1,885 @@
1
+ """CI/CD code generation for Flutter projects."""
2
+
3
+ import re
4
+ import subprocess
5
+ from pathlib import Path
6
+
7
+ from rich.console import Console
8
+
9
+ from .config import Config
10
+
11
+ console = Console()
12
+
13
+
14
+ class CicdGenerator:
15
+ """Generates CI/CD workflows and configuration for Flutter projects."""
16
+
17
+ def __init__(self, config: Config, force: bool = False) -> None:
18
+ """Initialize CicdGenerator."""
19
+ self.config = config
20
+ self.force = force
21
+ self.project_path = config.project_path
22
+ self.project_name = config.project_name
23
+ self.package_name = config.package_name
24
+ self.platforms = [p.lower() for p in config.platforms]
25
+ self.flutter_channel = config.channel
26
+ self.flutter_version = self._get_current_flutter_version()
27
+ self.needs_codegen = config.database == "sqlite"
28
+
29
+ def _get_current_flutter_version(self) -> str:
30
+ """Get the current Flutter version from the installed Flutter SDK."""
31
+ try:
32
+ flutter_bin = self.config.flutter_location / "bin" / "flutter"
33
+ if not flutter_bin.exists():
34
+ # Fallback: try to find flutter in PATH
35
+ import shutil
36
+
37
+ flutter_path = shutil.which("flutter")
38
+ if not flutter_path:
39
+ console.print(
40
+ " ⚠️ Flutter not found, using 'stable' as default version"
41
+ )
42
+ return "stable"
43
+ flutter_bin = Path(flutter_path)
44
+
45
+ # Run flutter --version to get the version
46
+ result = subprocess.run(
47
+ [str(flutter_bin), "--version"],
48
+ capture_output=True,
49
+ **self.config.sdk_subprocess_options(),
50
+ text=True,
51
+ check=False,
52
+ )
53
+
54
+ # Parse version from output
55
+ # Output format: "Flutter 3.24.0 • channel stable • ..."
56
+ output = result.stdout or result.stderr or ""
57
+ match = re.search(r"Flutter\s+([\d.]+)", output)
58
+ if match:
59
+ version = match.group(1)
60
+ console.print(f" ℹ️ Detected Flutter version: {version}")
61
+ return version
62
+ else:
63
+ console.print(
64
+ " ⚠️ Could not parse Flutter version, using '3.38.0' as default"
65
+ )
66
+ return "3.38.0"
67
+ except Exception as e:
68
+ console.print(
69
+ f" ⚠️ Error detecting Flutter version: {e}, using '3.38.0' as default"
70
+ )
71
+ return "3.38.0"
72
+
73
+ def _write_workflow_file(self, filepath: Path, content: str) -> None:
74
+ """Write a workflow file, skipping if it exists and force is False."""
75
+ if filepath.exists() and not self.force:
76
+ console.print(
77
+ f" ⚠️ {filepath.name} already exists — skipping (use --force to overwrite)"
78
+ )
79
+ return
80
+ filepath.write_text(content)
81
+
82
+ def _codegen_step(self) -> str:
83
+ """Return the build_runner code generation step for workflows that need it."""
84
+ if not self.needs_codegen:
85
+ return ""
86
+ return """
87
+ - name: Generate code
88
+ run: dart run build_runner build --delete-conflicting-outputs
89
+ """
90
+
91
+ def generate_cicd(self) -> None:
92
+ """Generate all CI/CD files."""
93
+ if self.config.dry_run:
94
+ console.print("[yellow]DRY RUN: Would generate CI/CD files[/yellow]")
95
+ return
96
+
97
+ console.print(" 🔧 Generating CI/CD workflows and configuration...")
98
+
99
+ # Create .github directory structure
100
+ github_dir = self.project_path / ".github"
101
+ workflows_dir = github_dir / "workflows"
102
+ workflows_dir.mkdir(parents=True, exist_ok=True)
103
+
104
+ # Generate workflows
105
+ self._generate_lint_workflow(workflows_dir)
106
+ self._generate_format_workflow(workflows_dir)
107
+ self._generate_test_workflow(workflows_dir)
108
+ self._generate_build_workflows(workflows_dir)
109
+
110
+ # Generate dependabot configuration
111
+ self._generate_dependabot(github_dir)
112
+
113
+ # Generate setup documentation
114
+ self._generate_setup_docs(github_dir)
115
+
116
+ # Generate git hooks for local quality gates
117
+ self._generate_git_hooks()
118
+
119
+ console.print(" ✅ CI/CD workflows and configuration generated")
120
+
121
+ def _generate_lint_workflow(self, workflows_dir: Path) -> None:
122
+ """Generate lint workflow for flutter analyze."""
123
+ workflow_content = f"""name: Lint
124
+
125
+ on:
126
+ pull_request:
127
+ types: [opened, synchronize, reopened, ready_for_review]
128
+ push:
129
+ branches: ["main"]
130
+
131
+ concurrency:
132
+ group: lint-${{{{ github.ref }}}}
133
+ cancel-in-progress: true
134
+
135
+ jobs:
136
+ lint:
137
+ if: github.event_name != 'pull_request' || github.event.pull_request.draft == false
138
+ runs-on: ubuntu-latest
139
+ permissions:
140
+ contents: read
141
+ issues: write
142
+ steps:
143
+ - name: Checkout
144
+ uses: actions/checkout@v4
145
+
146
+ - name: Setup Flutter
147
+ uses: subosito/flutter-action@v2
148
+ with:
149
+ channel: ${{{{ secrets.FLUTTER_CHANNEL || 'stable' }}}}
150
+ version: ${{{{ secrets.FLUTTER_VERSION || '{self.flutter_version}' }}}}
151
+
152
+ - name: Cache pub
153
+ uses: actions/cache@v4
154
+ with:
155
+ path: ~/.pub-cache
156
+ key: pub-${{{{ runner.os }}}}-${{{{ hashFiles('**/pubspec.yaml', '**/pubspec.lock') }}}}
157
+
158
+ - name: Install dependencies
159
+ run: flutter pub get
160
+
161
+ - name: Analyze
162
+ run: flutter analyze
163
+
164
+ - name: Comment PR with results
165
+ if: github.event_name == 'pull_request' && failure()
166
+ uses: actions/github-script@v7
167
+ with:
168
+ script: |
169
+ github.rest.issues.createComment({{
170
+ issue_number: context.issue.number,
171
+ owner: context.repo.owner,
172
+ repo: context.repo.repo,
173
+ body: '❌ Linting failed. Please run `flutter analyze` locally and fix the issues.'
174
+ }})
175
+ """
176
+
177
+ workflow_file = workflows_dir / "lint.yml"
178
+ self._write_workflow_file(workflow_file, workflow_content)
179
+
180
+ def _generate_format_workflow(self, workflows_dir: Path) -> None:
181
+ """Generate format workflow for dart format."""
182
+ workflow_content = f"""name: Format
183
+
184
+ on:
185
+ pull_request:
186
+ types: [opened, synchronize, reopened, ready_for_review]
187
+ push:
188
+ branches: ["main"]
189
+
190
+ concurrency:
191
+ group: format-${{{{ github.ref }}}}
192
+ cancel-in-progress: true
193
+
194
+ jobs:
195
+ format:
196
+ if: github.event_name != 'pull_request' || github.event.pull_request.draft == false
197
+ runs-on: ubuntu-latest
198
+ permissions:
199
+ contents: read
200
+ issues: write
201
+ steps:
202
+ - name: Checkout
203
+ uses: actions/checkout@v4
204
+
205
+ - name: Setup Flutter
206
+ uses: subosito/flutter-action@v2
207
+ with:
208
+ channel: ${{{{ secrets.FLUTTER_CHANNEL || 'stable' }}}}
209
+ version: ${{{{ secrets.FLUTTER_VERSION || '{self.flutter_version}' }}}}
210
+
211
+ - name: Cache pub
212
+ uses: actions/cache@v4
213
+ with:
214
+ path: ~/.pub-cache
215
+ key: pub-${{{{ runner.os }}}}-${{{{ hashFiles('**/pubspec.yaml', '**/pubspec.lock') }}}}
216
+
217
+ - name: Install dependencies
218
+ run: flutter pub get
219
+
220
+ - name: Check formatting
221
+ run: dart format --set-exit-if-changed .
222
+
223
+ - name: Comment PR with results
224
+ if: github.event_name == 'pull_request' && failure()
225
+ uses: actions/github-script@v7
226
+ with:
227
+ script: |
228
+ github.rest.issues.createComment({{
229
+ issue_number: context.issue.number,
230
+ owner: context.repo.owner,
231
+ repo: context.repo.repo,
232
+ body: '❌ Code formatting check failed. Please run `dart format .` locally and commit the changes.'
233
+ }})
234
+ """
235
+
236
+ workflow_file = workflows_dir / "format.yml"
237
+ self._write_workflow_file(workflow_file, workflow_content)
238
+
239
+ def _generate_test_workflow(self, workflows_dir: Path) -> None:
240
+ """Generate test workflow."""
241
+ workflow_content = f"""name: Test
242
+
243
+ on:
244
+ pull_request:
245
+ types: [opened, synchronize, reopened, ready_for_review]
246
+ push:
247
+ branches: ["main"]
248
+
249
+ concurrency:
250
+ group: test-${{{{ github.ref }}}}
251
+ cancel-in-progress: true
252
+
253
+ jobs:
254
+ test:
255
+ if: github.event_name != 'pull_request' || github.event.pull_request.draft == false
256
+ runs-on: ubuntu-latest
257
+ steps:
258
+ - name: Checkout
259
+ uses: actions/checkout@v4
260
+
261
+ - name: Setup Flutter
262
+ uses: subosito/flutter-action@v2
263
+ with:
264
+ channel: ${{{{ secrets.FLUTTER_CHANNEL || 'stable' }}}}
265
+ version: ${{{{ secrets.FLUTTER_VERSION || '{self.flutter_version}' }}}}
266
+
267
+ - name: Cache pub
268
+ uses: actions/cache@v4
269
+ with:
270
+ path: ~/.pub-cache
271
+ key: pub-${{{{ runner.os }}}}-${{{{ hashFiles('**/pubspec.yaml', '**/pubspec.lock') }}}}
272
+
273
+ - name: Install dependencies
274
+ run: flutter pub get
275
+ {self._codegen_step()}
276
+ - name: Run unit tests
277
+ run: flutter test --coverage
278
+
279
+ - name: Upload coverage
280
+ if: github.event_name == 'pull_request'
281
+ uses: codecov/codecov-action@v5
282
+ with:
283
+ token: ${{{{ secrets.CODECOV_TOKEN }}}}
284
+ files: ./coverage/lcov.info
285
+ fail_ci_if_error: false
286
+ """
287
+
288
+ workflow_file = workflows_dir / "test.yml"
289
+ self._write_workflow_file(workflow_file, workflow_content)
290
+
291
+ def _generate_build_workflows(self, workflows_dir: Path) -> None:
292
+ """Generate build workflows for enabled platforms."""
293
+ if "ios" in self.platforms:
294
+ self._generate_ios_build_workflow(workflows_dir)
295
+ if "android" in self.platforms:
296
+ self._generate_android_build_workflow(workflows_dir)
297
+ if "web" in self.platforms:
298
+ self._generate_web_build_workflow(workflows_dir)
299
+ if "macos" in self.platforms:
300
+ self._generate_macos_build_workflow(workflows_dir)
301
+ if "linux" in self.platforms:
302
+ self._generate_linux_build_workflow(workflows_dir)
303
+ if "windows" in self.platforms:
304
+ self._generate_windows_build_workflow(workflows_dir)
305
+
306
+ def _generate_ios_build_workflow(self, workflows_dir: Path) -> None:
307
+ """Generate iOS build workflow."""
308
+ workflow_content = f"""name: Build iOS
309
+
310
+ on:
311
+ workflow_dispatch:
312
+ push:
313
+ tags:
314
+ - 'v*.*.*'
315
+
316
+ jobs:
317
+ build-ios:
318
+ runs-on: macos-latest
319
+ steps:
320
+ - name: Checkout
321
+ uses: actions/checkout@v4
322
+
323
+ - name: Setup Flutter
324
+ uses: subosito/flutter-action@v2
325
+ with:
326
+ channel: ${{{{ secrets.FLUTTER_CHANNEL || 'stable' }}}}
327
+ version: ${{{{ secrets.FLUTTER_VERSION || '{self.flutter_version}' }}}}
328
+
329
+ - name: Cache pub
330
+ uses: actions/cache@v4
331
+ with:
332
+ path: ~/.pub-cache
333
+ key: pub-${{{{ runner.os }}}}-${{{{ hashFiles('**/pubspec.yaml', '**/pubspec.lock') }}}}
334
+
335
+ - name: Install dependencies
336
+ run: flutter pub get
337
+ {self._codegen_step()}
338
+ - name: Build iOS
339
+ run: flutter build ios --release --no-codesign
340
+
341
+ - name: Upload artifacts
342
+ uses: actions/upload-artifact@v4
343
+ with:
344
+ name: ios-build
345
+ path: build/ios/iphoneos/Runner.app
346
+ if-no-files-found: error
347
+ """
348
+
349
+ workflow_file = workflows_dir / "build-ios.yml"
350
+ self._write_workflow_file(workflow_file, workflow_content)
351
+
352
+ def _generate_android_build_workflow(self, workflows_dir: Path) -> None:
353
+ """Generate Android build workflow."""
354
+ workflow_content = f"""name: Build Android
355
+
356
+ on:
357
+ workflow_dispatch:
358
+ push:
359
+ tags:
360
+ - 'v*.*.*'
361
+
362
+ jobs:
363
+ build-android:
364
+ runs-on: ubuntu-latest
365
+ steps:
366
+ - name: Checkout
367
+ uses: actions/checkout@v4
368
+
369
+ - name: Setup Java
370
+ uses: actions/setup-java@v4
371
+ with:
372
+ distribution: 'temurin'
373
+ java-version: '17'
374
+
375
+ - name: Setup Flutter
376
+ uses: subosito/flutter-action@v2
377
+ with:
378
+ channel: ${{{{ secrets.FLUTTER_CHANNEL || 'stable' }}}}
379
+ version: ${{{{ secrets.FLUTTER_VERSION || '{self.flutter_version}' }}}}
380
+
381
+ - name: Cache pub
382
+ uses: actions/cache@v4
383
+ with:
384
+ path: ~/.pub-cache
385
+ key: pub-${{{{ runner.os }}}}-${{{{ hashFiles('**/pubspec.yaml', '**/pubspec.lock') }}}}
386
+
387
+ - name: Install dependencies
388
+ run: flutter pub get
389
+ {self._codegen_step()}
390
+ - name: Build APK
391
+ run: flutter build apk --release
392
+
393
+ - name: Build AAB
394
+ run: flutter build appbundle --release
395
+
396
+ - name: Upload APK
397
+ uses: actions/upload-artifact@v4
398
+ with:
399
+ name: android-apk
400
+ path: build/app/outputs/flutter-apk/app-release.apk
401
+ if-no-files-found: error
402
+
403
+ - name: Upload AAB
404
+ uses: actions/upload-artifact@v4
405
+ with:
406
+ name: android-aab
407
+ path: build/app/outputs/bundle/release/app-release.aab
408
+ if-no-files-found: error
409
+ """
410
+
411
+ workflow_file = workflows_dir / "build-android.yml"
412
+ self._write_workflow_file(workflow_file, workflow_content)
413
+
414
+ def _generate_web_build_workflow(self, workflows_dir: Path) -> None:
415
+ """Generate Web build workflow."""
416
+ workflow_content = f"""name: Build Web
417
+
418
+ on:
419
+ workflow_dispatch:
420
+ push:
421
+ tags:
422
+ - 'v*.*.*'
423
+
424
+ jobs:
425
+ build-web:
426
+ runs-on: ubuntu-latest
427
+ steps:
428
+ - name: Checkout
429
+ uses: actions/checkout@v4
430
+
431
+ - name: Setup Flutter
432
+ uses: subosito/flutter-action@v2
433
+ with:
434
+ channel: ${{{{ secrets.FLUTTER_CHANNEL || 'stable' }}}}
435
+ version: ${{{{ secrets.FLUTTER_VERSION || '{self.flutter_version}' }}}}
436
+
437
+ - name: Cache pub
438
+ uses: actions/cache@v4
439
+ with:
440
+ path: ~/.pub-cache
441
+ key: pub-${{{{ runner.os }}}}-${{{{ hashFiles('**/pubspec.yaml', '**/pubspec.lock') }}}}
442
+
443
+ - name: Install dependencies
444
+ run: flutter pub get
445
+ {self._codegen_step()}
446
+ - name: Build Web
447
+ run: flutter build web --release
448
+
449
+ - name: Upload artifacts
450
+ uses: actions/upload-artifact@v4
451
+ with:
452
+ name: web-build
453
+ path: build/web
454
+ if-no-files-found: error
455
+ """
456
+
457
+ workflow_file = workflows_dir / "build-web.yml"
458
+ self._write_workflow_file(workflow_file, workflow_content)
459
+
460
+ def _generate_macos_build_workflow(self, workflows_dir: Path) -> None:
461
+ """Generate macOS build workflow."""
462
+ workflow_content = f"""name: Build macOS
463
+
464
+ on:
465
+ workflow_dispatch:
466
+ push:
467
+ tags:
468
+ - 'v*.*.*'
469
+
470
+ jobs:
471
+ build-macos:
472
+ runs-on: macos-latest
473
+ steps:
474
+ - name: Checkout
475
+ uses: actions/checkout@v4
476
+
477
+ - name: Setup Flutter
478
+ uses: subosito/flutter-action@v2
479
+ with:
480
+ channel: ${{{{ secrets.FLUTTER_CHANNEL || 'stable' }}}}
481
+ version: ${{{{ secrets.FLUTTER_VERSION || '{self.flutter_version}' }}}}
482
+
483
+ - name: Cache pub
484
+ uses: actions/cache@v4
485
+ with:
486
+ path: ~/.pub-cache
487
+ key: pub-${{{{ runner.os }}}}-${{{{ hashFiles('**/pubspec.yaml', '**/pubspec.lock') }}}}
488
+
489
+ - name: Install dependencies
490
+ run: flutter pub get
491
+ {self._codegen_step()}
492
+ - name: Build macOS
493
+ run: flutter build macos --release
494
+
495
+ - name: Upload artifacts
496
+ uses: actions/upload-artifact@v4
497
+ with:
498
+ name: macos-build
499
+ path: build/macos/Build/Products/Release
500
+ if-no-files-found: error
501
+ """
502
+
503
+ workflow_file = workflows_dir / "build-macos.yml"
504
+ self._write_workflow_file(workflow_file, workflow_content)
505
+
506
+ def _generate_linux_build_workflow(self, workflows_dir: Path) -> None:
507
+ """Generate Linux build workflow."""
508
+ workflow_content = f"""name: Build Linux
509
+
510
+ on:
511
+ workflow_dispatch:
512
+ push:
513
+ tags:
514
+ - 'v*.*.*'
515
+
516
+ jobs:
517
+ build-linux:
518
+ runs-on: ubuntu-latest
519
+ steps:
520
+ - name: Checkout
521
+ uses: actions/checkout@v4
522
+
523
+ - name: Setup Flutter
524
+ uses: subosito/flutter-action@v2
525
+ with:
526
+ channel: ${{{{ secrets.FLUTTER_CHANNEL || 'stable' }}}}
527
+ version: ${{{{ secrets.FLUTTER_VERSION || '{self.flutter_version}' }}}}
528
+
529
+ - name: Cache pub
530
+ uses: actions/cache@v4
531
+ with:
532
+ path: ~/.pub-cache
533
+ key: pub-${{{{ runner.os }}}}-${{{{ hashFiles('**/pubspec.yaml', '**/pubspec.lock') }}}}
534
+
535
+ - name: Install Linux dependencies
536
+ run: |
537
+ sudo apt-get update
538
+ sudo apt-get install -y \\
539
+ libgtk-3-dev \\
540
+ libayatana-appindicator3-dev \\
541
+ clang \\
542
+ cmake \\
543
+ ninja-build \\
544
+ pkg-config \\
545
+ liblzma-dev
546
+
547
+ - name: Install dependencies
548
+ run: flutter pub get
549
+ {self._codegen_step()}
550
+ - name: Build Linux
551
+ run: flutter build linux --release
552
+
553
+ - name: Upload artifacts
554
+ uses: actions/upload-artifact@v4
555
+ with:
556
+ name: linux-build
557
+ path: build/linux/x64/release/bundle
558
+ if-no-files-found: error
559
+ """
560
+
561
+ workflow_file = workflows_dir / "build-linux.yml"
562
+ self._write_workflow_file(workflow_file, workflow_content)
563
+
564
+ def _generate_windows_build_workflow(self, workflows_dir: Path) -> None:
565
+ """Generate Windows build workflow."""
566
+ workflow_content = f"""name: Build Windows
567
+
568
+ on:
569
+ workflow_dispatch:
570
+ push:
571
+ tags:
572
+ - 'v*.*.*'
573
+
574
+ jobs:
575
+ build-windows:
576
+ runs-on: windows-latest
577
+ steps:
578
+ - name: Checkout
579
+ uses: actions/checkout@v4
580
+
581
+ - name: Setup Flutter
582
+ uses: subosito/flutter-action@v2
583
+ with:
584
+ channel: ${{{{ secrets.FLUTTER_CHANNEL || 'stable' }}}}
585
+ version: ${{{{ secrets.FLUTTER_VERSION || '{self.flutter_version}' }}}}
586
+
587
+ - name: Cache pub
588
+ uses: actions/cache@v4
589
+ with:
590
+ path: ~/.pub-cache
591
+ key: pub-${{{{ runner.os }}}}-${{{{ hashFiles('**/pubspec.yaml', '**/pubspec.lock') }}}}
592
+
593
+ - name: Install dependencies
594
+ run: flutter pub get
595
+ {self._codegen_step()}
596
+ - name: Build Windows
597
+ run: flutter build windows --release
598
+
599
+ - name: Upload artifacts
600
+ uses: actions/upload-artifact@v4
601
+ with:
602
+ name: windows-build
603
+ path: build/windows/x64/runner/Release
604
+ if-no-files-found: error
605
+ """
606
+
607
+ workflow_file = workflows_dir / "build-windows.yml"
608
+ self._write_workflow_file(workflow_file, workflow_content)
609
+
610
+ def _generate_dependabot(self, github_dir: Path) -> None:
611
+ """Generate dependabot.yml configuration."""
612
+ dependabot_content = """version: 2
613
+ updates:
614
+ # Enable version updates for Flutter/Dart dependencies
615
+ - package-ecosystem: "pub"
616
+ directory: "/"
617
+ schedule:
618
+ interval: "weekly"
619
+ open-pull-requests-limit: 10
620
+ groups:
621
+ flutter-dependencies:
622
+ patterns:
623
+ - "flutter*"
624
+ - "dart*"
625
+ dev-dependencies:
626
+ patterns:
627
+ - "*_test"
628
+ - "*test*"
629
+ - "mockito"
630
+ - "build_runner"
631
+
632
+ # Enable version updates for GitHub Actions
633
+ - package-ecosystem: "github-actions"
634
+ directory: "/"
635
+ schedule:
636
+ interval: "weekly"
637
+ open-pull-requests-limit: 5
638
+ """
639
+
640
+ dependabot_file = github_dir / "dependabot.yml"
641
+ self._write_workflow_file(dependabot_file, dependabot_content)
642
+
643
+ def _generate_setup_docs(self, github_dir: Path) -> None:
644
+ """Generate CI/CD setup documentation."""
645
+ docs_content = f"""# CI/CD Setup Guide
646
+
647
+ This document provides instructions for setting up and configuring the CI/CD workflows for {self.project_name}.
648
+
649
+ ## Overview
650
+
651
+ The CI/CD workflows in this repository include:
652
+
653
+ - **Lint Workflow** (`lint.yml`): Runs `flutter analyze` on pull requests and pushes
654
+ - **Format Workflow** (`format.yml`): Checks code formatting with `dart format`
655
+ - **Test Workflow** (`test.yml`): Runs unit tests
656
+ - **Build Workflows**: Platform-specific build workflows for enabled platforms
657
+
658
+ ## Prerequisites
659
+
660
+ 1. **GitHub Actions enabled**: Ensure GitHub Actions are enabled in your repository settings
661
+ 2. **Flutter Configuration**: Set Flutter channel and version secrets (optional, defaults to `stable` channel)
662
+
663
+ ## Configuration
664
+
665
+ ### GitHub Secrets
666
+
667
+ Go to **Settings → Secrets → Actions** and create the following secrets:
668
+
669
+ | Secret | Value | Description | Required |
670
+ |--------|-------|-------------|----------|
671
+ | `FLUTTER_CHANNEL` | `stable`, `beta`, or `dev` | Flutter channel to use in workflows. Defaults to `stable` if not set. | No |
672
+ | `FLUTTER_VERSION` | Specific version (e.g., `3.24.0`) or empty | Flutter SDK version to use. If not set, defaults to the Flutter version that was installed when the project was created ({self.flutter_version}). Examples: `3.24.0`, `3.24.1`, `3.25.0`. Check [Flutter releases](https://docs.flutter.dev/release/archive) for available versions. | No |
673
+ | `CODECOV_TOKEN` | Codecov upload token | Token for uploading test coverage reports to Codecov. See [Codecov Token Setup](#codecov-token-setup) below for instructions. | No |
674
+
675
+ **Note**: If `FLUTTER_VERSION` is not set, the workflow will use the Flutter version that was installed when the project was created ({self.flutter_version}) as the default. Setting a specific version ensures consistent builds across all CI runs and allows you to override the default version.
676
+
677
+ ### Codecov Token Setup
678
+
679
+ To enable test coverage reporting in pull requests, you'll need to set up a Codecov token:
680
+
681
+ 1. **Sign in to Codecov**:
682
+ - Go to [codecov.io](https://codecov.io) and sign in with your GitHub account
683
+ - Grant Codecov access to your repository when prompted
684
+
685
+ 2. **Get your upload token**:
686
+ - Navigate to your repository on Codecov (or go to **Settings → Integrations**)
687
+ - Copy your repository's upload token (it will look like: `xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx`)
688
+
689
+ 3. **Add the secret to GitHub**:
690
+ - Go to your repository on GitHub
691
+ - Navigate to **Settings → Secrets and variables → Actions**
692
+ - Click **New repository secret**
693
+ - Name: `CODECOV_TOKEN`
694
+ - Value: Paste your Codecov upload token
695
+ - Click **Add secret**
696
+
697
+ **Note**: The Codecov token is optional. The test workflow will still run tests without it, but coverage reports won't be uploaded to Codecov. If you don't plan to use Codecov, you can skip this step.
698
+
699
+ ### Additional Secrets (for App Store Deployment)
700
+
701
+ If you plan to deploy to app stores or use code signing, you'll need to configure additional secrets:
702
+
703
+ #### iOS App Store Connect (for TestFlight/App Store deployment)
704
+
705
+ 1. Go to [App Store Connect API Keys](https://appstoreconnect.apple.com/access/api)
706
+ 2. Create a new API key
707
+ 3. Download the `.p8` file (⚠️ only available once!)
708
+ 4. Convert to Base64:
709
+ ```bash
710
+ base64 -i AuthKey_ABC12345.p8 | pbcopy
711
+ ```
712
+ 5. Add the following secrets in **Settings → Secrets → Actions**:
713
+
714
+ | Secret | Description |
715
+ |--------|-------------|
716
+ | `APPLE_NOTARY_KEY_ID` | Key ID (example: ABC123DEFG) |
717
+ | `APPLE_NOTARY_ISSUER_ID` | Issuer ID (UUID on App Store Connect) |
718
+ | `APPLE_NOTARY_KEY_BASE64` | Base64 of the `.p8` key |
719
+
720
+ #### Google Play Console (for Play Store deployment)
721
+
722
+ 1. Go to [Google Play Console](https://play.google.com/console)
723
+ 2. Navigate to **Setup → API access**
724
+ 3. Create a service account
725
+ 4. Download the JSON key file
726
+ 5. Add the following secret in **Settings → Secrets → Actions**:
727
+
728
+ | Secret | Description |
729
+ |--------|-------------|
730
+ | `GOOGLE_PLAY_SERVICE_ACCOUNT_JSON` | Contents of the JSON key file |
731
+
732
+ ## Workflow Triggers
733
+
734
+ ### Automatic Triggers
735
+
736
+ - **Lint, Format, Test**: Run on pull requests and pushes to `main` branch
737
+ - **Build Workflows**: Run on version tags (`v*.*.*`) only — not on every push to `main`
738
+
739
+ ### Manual Triggers
740
+
741
+ All build workflows can be triggered manually via **Actions → [Workflow Name] → Run workflow**
742
+
743
+ ## Platform-Specific Notes
744
+
745
+ {self._generate_platform_notes()}
746
+
747
+ ## Troubleshooting
748
+
749
+ ### Common Issues
750
+
751
+ 1. **Workflow fails with "Flutter not found" or version error**
752
+ - Ensure the `FLUTTER_CHANNEL` secret is set correctly (`stable`, `beta`, or `dev`)
753
+ - If using `FLUTTER_VERSION`, verify the version exists for the specified channel
754
+ - Check [Flutter releases](https://docs.flutter.dev/release/archive) for valid version numbers
755
+ - If `FLUTTER_VERSION` is set incorrectly, remove it to use the latest version from the channel
756
+
757
+ 2. **Build fails on specific platform**
758
+ - Verify that the platform is enabled in your `pubspec.yaml`
759
+ - Check platform-specific dependencies are installed
760
+
761
+ 3. **Dependabot not creating PRs**
762
+ - Ensure Dependabot is enabled in repository settings
763
+ - Check that `dependabot.yml` is in the `.github` directory
764
+
765
+ ### Getting Help
766
+
767
+ - Check workflow logs in the **Actions** tab
768
+ - Review Flutter documentation for platform-specific requirements
769
+ - Consult GitHub Actions documentation for workflow syntax
770
+
771
+ ## Security Best Practices
772
+
773
+ 1. **Never commit secrets**: Always use GitHub Secrets for sensitive information
774
+ 2. **Review Dependabot PRs**: Regularly review and merge dependency updates
775
+ 3. **Limit workflow permissions**: Use minimal required permissions in workflows
776
+ 4. **Regular updates**: Keep GitHub Actions versions up to date
777
+
778
+ ## Next Steps
779
+
780
+ 1. Set up repository variables (if needed)
781
+ 2. Configure secrets (if deploying to app stores)
782
+ 3. Push your code to trigger workflows
783
+ 4. Monitor workflow runs in the **Actions** tab
784
+ """
785
+
786
+ docs_file = github_dir / "CI_CD_SETUP.md"
787
+ self._write_workflow_file(docs_file, docs_content)
788
+
789
+ def _generate_platform_notes(self) -> str:
790
+ """Generate platform-specific notes for the documentation."""
791
+ notes = []
792
+ if "ios" in self.platforms:
793
+ notes.append(
794
+ "### iOS\n"
795
+ "- Requires macOS runner\n"
796
+ "- Builds are unsigned by default\n"
797
+ "- For code signing, configure Apple Developer certificates"
798
+ )
799
+ if "android" in self.platforms:
800
+ notes.append(
801
+ "### Android\n"
802
+ "- Builds both APK and AAB formats\n"
803
+ "- Requires Java 17\n"
804
+ "- For Play Store deployment, configure Google Play Console API"
805
+ )
806
+ if "web" in self.platforms:
807
+ notes.append(
808
+ "### Web\n"
809
+ "- Builds optimized web assets\n"
810
+ "- Can be deployed to any static hosting service"
811
+ )
812
+ if "macos" in self.platforms:
813
+ notes.append(
814
+ "### macOS\n"
815
+ "- Requires macOS runner\n"
816
+ "- Builds unsigned .app bundles by default\n"
817
+ "- For distribution, configure code signing and notarization"
818
+ )
819
+ if "linux" in self.platforms:
820
+ notes.append(
821
+ "### Linux\n"
822
+ "- Installs required system dependencies automatically\n"
823
+ "- Builds bundle directory structure\n"
824
+ "- Can be packaged as .deb, .rpm, or AppImage"
825
+ )
826
+ if "windows" in self.platforms:
827
+ notes.append(
828
+ "### Windows\n"
829
+ "- Builds Windows executable\n"
830
+ "- Can be packaged as MSIX or installer"
831
+ )
832
+ return "\n\n".join(notes) if notes else "No platform-specific notes."
833
+
834
+ def _generate_git_hooks(self) -> None:
835
+ """Generate .git-hooks/ scripts that mirror the CI quality gates locally."""
836
+ hooks_dir = self.project_path / ".git-hooks"
837
+ hooks_dir.mkdir(parents=True, exist_ok=True)
838
+
839
+ pre_commit = hooks_dir / "pre-commit"
840
+ if not pre_commit.exists() or self.force:
841
+ pre_commit.write_text(
842
+ "#!/usr/bin/env bash\n"
843
+ "# pre-commit: run dart format to catch style issues before CI.\n"
844
+ "set -euo pipefail\n"
845
+ "\n"
846
+ 'FLUTTER_BIN="${FLUTTER_ROOT:-}/bin"\n'
847
+ 'DART="${FLUTTER_BIN}/dart"\n'
848
+ '[ -x "$DART" ] || DART="$(command -v dart 2>/dev/null)" || '
849
+ '{ echo "dart not found"; exit 1; }\n'
850
+ "\n"
851
+ 'echo "pre-commit: dart format --set-exit-if-changed ."\n'
852
+ '"$DART" format --set-exit-if-changed . || {\n'
853
+ ' echo ""\n'
854
+ ' echo "Formatting errors found. Run: dart format ."\n'
855
+ ' echo "then re-stage the changed files and commit again."\n'
856
+ " exit 1\n"
857
+ "}\n"
858
+ )
859
+ pre_commit.chmod(0o755)
860
+
861
+ pre_push = hooks_dir / "pre-push"
862
+ if not pre_push.exists() or self.force:
863
+ pre_push.write_text(
864
+ "#!/usr/bin/env bash\n"
865
+ "# pre-push: run flutter analyze before pushing to catch lint issues.\n"
866
+ "set -euo pipefail\n"
867
+ "\n"
868
+ 'FLUTTER_BIN="${FLUTTER_ROOT:-}/bin"\n'
869
+ 'FLUTTER="${FLUTTER_BIN}/flutter"\n'
870
+ '[ -x "$FLUTTER" ] || FLUTTER="$(command -v flutter 2>/dev/null)" || '
871
+ '{ echo "flutter not found"; exit 1; }\n'
872
+ "\n"
873
+ 'echo "pre-push: flutter analyze"\n'
874
+ '"$FLUTTER" analyze || {\n'
875
+ ' echo ""\n'
876
+ ' echo "flutter analyze reported issues. Fix them before pushing."\n'
877
+ " exit 1\n"
878
+ "}\n"
879
+ )
880
+ pre_push.chmod(0o755)
881
+
882
+ console.print(
883
+ " ✅ Git hooks created in .git-hooks/ — "
884
+ "run `git config core.hooksPath .git-hooks` to activate"
885
+ )