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,397 @@
1
+ """Luff project commands and structured command results."""
2
+
3
+ import json
4
+ import os
5
+ import shutil
6
+ import subprocess
7
+ import sys
8
+ from contextlib import ExitStack, redirect_stdout
9
+ from importlib.metadata import distribution, version
10
+ from pathlib import Path
11
+ from typing import Any
12
+
13
+ import click
14
+ import yaml
15
+
16
+ from .bootstrap import ProjectBootstrap
17
+ from .cli import append_command, check_command, init_config
18
+ from .config import Config
19
+ from .config_manager import ConfigManager
20
+ from .exceptions import FlutterSetupError
21
+ from .project_creator import ProjectCreator
22
+ from .standards import StandardsError, resolve_standards
23
+
24
+ PLATFORMS = ("android", "ios", "linux", "macos", "web", "windows")
25
+
26
+
27
+ @click.group()
28
+ @click.version_option(package_name="everydaydevops-luff")
29
+ def luff() -> None:
30
+ """Build better Flutter applications."""
31
+
32
+
33
+ for command in (append_command, check_command, init_config):
34
+ luff.add_command(command)
35
+
36
+
37
+ def emit(result: dict[str, Any], output_format: str) -> None:
38
+ if output_format == "json":
39
+ click.echo(json.dumps(result, sort_keys=True))
40
+ elif result["status"] == "planned":
41
+ click.echo(f"Would create {result['destination']}")
42
+ click.echo(yaml.safe_dump(result["manifest"], sort_keys=False).rstrip())
43
+ elif result["status"] == "created":
44
+ click.echo(f"Created {result['destination']}")
45
+ else:
46
+ click.echo(result.get("message", result["status"]))
47
+
48
+
49
+ def user_manifest() -> Path | None:
50
+ directory = Path(os.environ.get("XDG_CONFIG_HOME") or Path.home() / ".config")
51
+ candidate = directory / "luff" / "config.yaml"
52
+ return candidate if candidate.is_file() else None
53
+
54
+
55
+ def legacy_settings(section: str) -> dict[str, Any]:
56
+ path = ConfigManager().config_file
57
+ if not path.is_file():
58
+ return {}
59
+ try:
60
+ data = yaml.safe_load(path.read_text(encoding="utf-8"))
61
+ except yaml.YAMLError as exc:
62
+ raise ValueError(f"Invalid legacy configuration: {path}") from exc
63
+ if not isinstance(data, dict) or not isinstance(data.get(section, {}), dict):
64
+ raise ValueError(f"Expected a configuration mapping for {section!r} in {path}")
65
+ return data.get(section, {})
66
+
67
+
68
+ def sdk_executable(explicit: Path | None) -> Path:
69
+ """Locate an installed Flutter SDK without provisioning."""
70
+ if explicit is not None:
71
+ candidate = explicit / "bin" / "flutter"
72
+ elif executable := shutil.which("flutter"):
73
+ candidate = Path(executable)
74
+ else:
75
+ location = legacy_settings("flutter").get("location")
76
+ if location is not None and not isinstance(location, str):
77
+ raise ValueError("Legacy flutter.location must be a path string")
78
+ root = Path(location) if location else Path.home() / "development" / "flutter"
79
+ candidate = root / "bin" / "flutter"
80
+ if not candidate.is_file() or not os.access(candidate, os.X_OK):
81
+ raise ValueError(
82
+ "Install Flutter or use --flutter-sdk to select an installed SDK"
83
+ )
84
+ resolved = candidate.resolve()
85
+ if resolved.parent.name != "bin" or not os.access(
86
+ resolved.with_name("dart"), os.X_OK
87
+ ):
88
+ raise ValueError(
89
+ "Flutter resolves to a wrapper or incomplete SDK. Use --flutter-sdk with the installed SDK root."
90
+ )
91
+ return resolved
92
+
93
+
94
+ def run_sdk(command: list[str], directory: Path) -> subprocess.CompletedProcess[str]:
95
+ return subprocess.run(
96
+ command,
97
+ cwd=directory,
98
+ capture_output=True,
99
+ text=True,
100
+ stdin=subprocess.DEVNULL,
101
+ timeout=900,
102
+ env={**os.environ, "CI": "true", "FLUTTER_SUPPRESS_ANALYTICS": "true"},
103
+ )
104
+
105
+
106
+ def sdk_version(executable: Path, directory: Path) -> str:
107
+ result = run_sdk([str(executable), "--version", "--machine"], directory)
108
+ if result.returncode:
109
+ raise ValueError(result.stderr.strip() or "Flutter SDK version check failed")
110
+ try:
111
+ detected = json.loads(result.stdout)["frameworkVersion"]
112
+ if not isinstance(detected, str):
113
+ raise TypeError
114
+ return detected
115
+ except (ValueError, KeyError, TypeError) as exc:
116
+ raise ValueError("Flutter did not report a framework version") from exc
117
+
118
+
119
+ @luff.command()
120
+ @click.argument("name", required=False)
121
+ @click.option("--config", "manifest", type=click.Path(path_type=Path, dir_okay=False))
122
+ @click.option(
123
+ "--profile", type=click.Choice(["everydaydevops", "everyday-devops-flutter"])
124
+ )
125
+ @click.option("--platforms", multiple=True, type=click.Choice(PLATFORMS))
126
+ @click.option("--org")
127
+ @click.option("--dir", "output_dir", default=".", type=click.Path(path_type=Path))
128
+ @click.option("--flutter-sdk", type=click.Path(path_type=Path))
129
+ @click.option("--flutter-version")
130
+ @click.option("--flutter-update", type=click.Choice(["skip"]), hidden=True)
131
+ @click.option("--template", type=click.Choice(["app", "plugin"]))
132
+ @click.option("--architecture", type=click.Choice(["basic", "clean"]))
133
+ @click.option("--database", type=click.Choice(["none", "sqlite"]))
134
+ @click.option("--testing", type=click.Choice(["standard", "mocktail"]))
135
+ @click.option("--e2e-testing", type=click.Choice(["integration_test", "patrol"]))
136
+ @click.option("--auth-provider", type=click.Choice(["none", "firebase"]))
137
+ @click.option("--cloud-database", type=click.Choice(["none", "firestore"]))
138
+ @click.option("--notifications-provider", type=click.Choice(["none", "firebase"]))
139
+ @click.option("--ios-language", type=click.Choice(["swift", "objc"]))
140
+ @click.option("--android-language", type=click.Choice(["kotlin", "java"]))
141
+ @click.option("--non-interactive", is_flag=True)
142
+ @click.option("--dry-run", is_flag=True)
143
+ @click.option(
144
+ "--format", "output_format", type=click.Choice(["text", "json"]), default="text"
145
+ )
146
+ @click.option("--verbose", "-v", is_flag=True)
147
+ @click.pass_context
148
+ def create(
149
+ ctx: click.Context,
150
+ /,
151
+ manifest: Path | None,
152
+ profile: str | None,
153
+ platforms: tuple[str, ...],
154
+ output_dir: Path,
155
+ flutter_sdk: Path | None,
156
+ flutter_update: str | None,
157
+ database: str | None,
158
+ auth_provider: str | None,
159
+ non_interactive: bool,
160
+ dry_run: bool,
161
+ output_format: str,
162
+ verbose: bool,
163
+ **project_options: str | None,
164
+ ) -> None:
165
+ """Create a new Flutter app using a versioned standards profile."""
166
+ try:
167
+ local_manifest = output_dir / ".luff.yaml"
168
+ if manifest is None and local_manifest.is_file():
169
+ manifest = local_manifest
170
+ project: dict[str, Any] = {
171
+ key: value for key, value in project_options.items() if value is not None
172
+ }
173
+ if platforms:
174
+ project["platforms"] = list(platforms)
175
+ capabilities = {}
176
+ if database is not None:
177
+ capabilities["persistence"] = database == "sqlite"
178
+ if auth_provider is not None:
179
+ capabilities["authentication"] = auth_provider == "firebase"
180
+ overrides: dict[str, Any] = {"project": project, "capabilities": capabilities}
181
+ if profile:
182
+ overrides["profile"] = {"id": "everyday-devops-flutter", "version": "1.0.0"}
183
+ user = user_manifest()
184
+ resolved = resolve_standards(project=manifest, user=user, overrides=overrides)
185
+ settings = resolved["project"]
186
+ interactive = (
187
+ not (non_interactive or dry_run or output_format == "json")
188
+ and sys.stdin.isatty()
189
+ )
190
+ for key, prompt in (
191
+ ("name", "Project name"),
192
+ ("platforms", "Platforms (space-separated)"),
193
+ ):
194
+ if key in settings:
195
+ continue
196
+ if not interactive:
197
+ flag = "a project name" if key == "name" else "--platforms"
198
+ raise ValueError(f"Provide {flag} or set project.{key} in the manifest")
199
+ answer = click.prompt(
200
+ prompt, default="ios android" if key == "platforms" else None, err=True
201
+ )
202
+ project[key] = answer.split() if key == "platforms" else answer
203
+ resolved = resolve_standards(project=manifest, user=user, overrides=overrides)
204
+ settings = resolved["project"]
205
+ if "org" not in settings:
206
+ legacy_org = legacy_settings("project").get("org", "com.example")
207
+ # Route inherited values through the same manifest schema as CLI values.
208
+ project["org"] = legacy_org
209
+ resolved = resolve_standards(
210
+ project=manifest, user=user, overrides=overrides
211
+ )
212
+ settings = resolved["project"]
213
+ settings.setdefault("template", "app")
214
+ features = resolved["capabilities"]
215
+ mobile = set(settings["platforms"]) & {"ios", "android"}
216
+ if settings.get("e2e_testing") == "patrol" and not mobile:
217
+ raise ValueError("Patrol requires an iOS or Android target")
218
+ if features["persistence"] and "web" in settings["platforms"]:
219
+ raise ValueError("The SQLite scaffold requires native platforms")
220
+ if (
221
+ features["authentication"]
222
+ or settings.get("cloud_database", "none") != "none"
223
+ or settings.get("notifications_provider", "none") != "none"
224
+ ) and not mobile:
225
+ raise ValueError("Firebase scaffolding requires an iOS or Android target")
226
+ if features["sentry"] and settings["architecture"] != "clean":
227
+ raise ValueError("Sentry scaffolding requires clean architecture")
228
+ if settings["template"] == "plugin" and (
229
+ any(features.values())
230
+ or settings["architecture"] != "basic"
231
+ or settings["testing"] != "standard"
232
+ or settings["e2e_testing"] != "integration_test"
233
+ or settings.get("cloud_database", "none") != "none"
234
+ or settings.get("notifications_provider", "none") != "none"
235
+ ):
236
+ raise ValueError("Plugin projects support minimal scaffolding only")
237
+ if not output_dir.is_dir():
238
+ raise ValueError(f"Output directory does not exist: {output_dir}")
239
+ destination = output_dir.resolve() / settings["name"]
240
+ if destination.exists() or destination.is_symlink():
241
+ raise ValueError(f"Destination already exists: {destination}")
242
+ except (StandardsError, ValueError, OSError) as exc:
243
+ emit({"status": "invalid", "message": str(exc)}, output_format)
244
+ ctx.exit(2)
245
+
246
+ if dry_run:
247
+ emit(
248
+ {
249
+ "status": "planned",
250
+ "destination": str(destination),
251
+ "manifest": resolved,
252
+ },
253
+ output_format,
254
+ )
255
+ return
256
+
257
+ try:
258
+ with redirect_stdout(sys.stderr):
259
+ executable = sdk_executable(flutter_sdk)
260
+ detected = sdk_version(executable, destination.parent)
261
+ required = settings.get("flutter_version", detected)
262
+ if required != detected:
263
+ raise ValueError(
264
+ f"Flutter {required} required, found {detected}. Select it using --flutter-sdk."
265
+ )
266
+ settings["flutter_version"] = detected
267
+ cfg = Config(
268
+ project_name=settings["name"],
269
+ platforms=settings["platforms"],
270
+ org=settings["org"],
271
+ channel="stable",
272
+ output_dir=destination.parent,
273
+ template=settings["template"],
274
+ ios_language=settings.get("ios_language", "swift"),
275
+ android_language=settings.get("android_language", "kotlin"),
276
+ flutter_update_mode="skip",
277
+ dry_run=False,
278
+ verbose=verbose,
279
+ flutter_location=executable.parent.parent,
280
+ architecture=settings["architecture"],
281
+ database="sqlite" if features["persistence"] else "none",
282
+ testing=settings["testing"],
283
+ e2e_testing=settings["e2e_testing"],
284
+ auth_provider="firebase" if features["authentication"] else "none",
285
+ cloud_database=settings.get("cloud_database", "none"),
286
+ notifications_provider=settings.get("notifications_provider", "none"),
287
+ flutter_version=detected,
288
+ managed=True,
289
+ offline=features["offline"],
290
+ sentry=features["sentry"],
291
+ )
292
+ destination.mkdir(exist_ok=False)
293
+ ProjectCreator(cfg).create_project()
294
+ if cfg.template == "app":
295
+ ProjectBootstrap(cfg).bootstrap_project()
296
+ resolved["luff_version"] = version("everydaydevops-luff")
297
+ (destination / ".luff.yaml").write_text(
298
+ yaml.safe_dump(resolved, sort_keys=False), encoding="utf-8"
299
+ )
300
+ except (ValueError, OSError, FlutterSetupError, subprocess.SubprocessError) as exc:
301
+ emit(
302
+ {"status": "failed", "destination": str(destination), "message": str(exc)},
303
+ output_format,
304
+ )
305
+ ctx.exit(1)
306
+ emit(
307
+ {"status": "created", "destination": str(destination), "manifest": resolved},
308
+ output_format,
309
+ )
310
+
311
+
312
+ @luff.command()
313
+ @click.option("--dir", "directory", default=".", type=click.Path(path_type=Path))
314
+ @click.option("--flutter-sdk", type=click.Path(path_type=Path))
315
+ @click.option("--device", help="Run integration tests on this device")
316
+ @click.option("--skip-builds", is_flag=True)
317
+ @click.option(
318
+ "--format", "output_format", type=click.Choice(["text", "json"]), default="text"
319
+ )
320
+ @click.pass_context
321
+ def verify(
322
+ ctx: click.Context,
323
+ directory: Path,
324
+ flutter_sdk: Path | None,
325
+ device: str | None,
326
+ skip_builds: bool,
327
+ output_format: str,
328
+ ) -> None:
329
+ """Run Flutter quality gates without provisioning a machine."""
330
+ from .verification import verify_project
331
+
332
+ with redirect_stdout(sys.stderr):
333
+ result = verify_project(directory.resolve(), flutter_sdk, device, skip_builds)
334
+ if output_format == "text":
335
+ for check in result["checks"]:
336
+ click.echo(f"{check['name']}: {check['status']} {check['detail']}".rstrip())
337
+ else:
338
+ emit(result, output_format)
339
+ if result["status"] != "passed":
340
+ ctx.exit(1)
341
+
342
+
343
+ @luff.command()
344
+ @click.option("--dir", "directory", type=click.Path(path_type=Path))
345
+ def skills(directory: Path | None) -> None:
346
+ """List packaged skills or copy them into an agent's skill directory."""
347
+ package = distribution("everydaydevops-luff")
348
+ sources = sorted(
349
+ Path(str(package.locate_file(entry))).resolve()
350
+ for entry in package.files or ()
351
+ if entry.parts[-5:-2] == ("share", "luff", "skills")
352
+ and entry.name == "SKILL.md"
353
+ )
354
+ if not sources:
355
+ root = Path(__file__).resolve().parent.parent / "skills"
356
+ sources = sorted(root.glob("flutter-*/SKILL.md"))
357
+ if not sources:
358
+ raise click.ClickException("This installation contains no Luff skills")
359
+ if directory is None:
360
+ for source in sources:
361
+ click.echo(source)
362
+ return
363
+ try:
364
+ payloads = {
365
+ directory / source.parent.name / "SKILL.md": source.read_bytes()
366
+ for source in sources
367
+ }
368
+ for target in payloads:
369
+ if target.exists() or target.is_symlink():
370
+ raise click.ClickException(f"Skill already exists: {target}")
371
+ with ExitStack() as rollback:
372
+ for target, content in payloads.items():
373
+ target.parent.mkdir(parents=True, exist_ok=True)
374
+ with target.open("xb") as output:
375
+ rollback.callback(target.unlink, missing_ok=True)
376
+ output.write(content)
377
+ rollback.pop_all()
378
+ except OSError as exc:
379
+ raise click.ClickException(f"Could not install Luff skills: {exc}") from exc
380
+ for target in payloads:
381
+ click.echo(target)
382
+
383
+
384
+ def main() -> None:
385
+ arguments = sys.argv[1:]
386
+ structured = "--format=json" in arguments or any(
387
+ pair == ("--format", "json") for pair in zip(arguments, arguments[1:])
388
+ )
389
+ if not structured:
390
+ luff()
391
+ return
392
+ try:
393
+ result = luff.main(args=arguments, standalone_mode=False)
394
+ except click.ClickException as exc:
395
+ emit({"status": "invalid", "message": exc.format_message()}, "json")
396
+ raise SystemExit(exc.exit_code) from exc
397
+ raise SystemExit(result)
@@ -0,0 +1,91 @@
1
+ """Project creation for Flutter setup."""
2
+
3
+ import subprocess
4
+ from typing import List
5
+
6
+ from rich.console import Console
7
+
8
+ from .config import Config
9
+ from .exceptions import ProjectCreationError
10
+
11
+ console = Console()
12
+
13
+
14
+ class ProjectCreator:
15
+ """Creates Flutter projects with specified configuration."""
16
+
17
+ def __init__(self, config: Config):
18
+ """Initialize ProjectCreator."""
19
+ self.config = config
20
+ self.flutter_root = config.flutter_location
21
+
22
+ def create_project(self) -> None:
23
+ """Create the Flutter project."""
24
+ if self.config.dry_run:
25
+ console.print("[yellow]DRY RUN: Would create Flutter project[/yellow]")
26
+ return
27
+
28
+ # Skip only when a Flutter project is already present (pubspec.yaml exists).
29
+ # A pre-existing directory without pubspec.yaml (e.g. a repo cloned before
30
+ # flutter-setup was run) is a valid target: flutter create will add the
31
+ # missing scaffold files without touching files that are already there.
32
+ if (self.config.project_path / "pubspec.yaml").exists():
33
+ console.print(
34
+ f" ⚠️ Flutter project already exists at '{self.config.project_path}'—skipping create."
35
+ )
36
+ return
37
+
38
+ # Create project directory (and parents) if not already present
39
+ self.config.project_path.mkdir(parents=True, exist_ok=True)
40
+
41
+ # Build flutter create command
42
+ create_cmd = self._build_create_command()
43
+
44
+ # Execute flutter create
45
+ console.print(
46
+ f" 🏗️ Creating Flutter project at {self.config.project_path}..."
47
+ )
48
+
49
+ try:
50
+ subprocess.run(
51
+ create_cmd,
52
+ check=True,
53
+ capture_output=True,
54
+ text=True,
55
+ **self.config.sdk_subprocess_options(),
56
+ )
57
+ console.print(f" ✅ Project created at: {self.config.project_path}")
58
+
59
+ except subprocess.CalledProcessError as e:
60
+ raise ProjectCreationError(f"Failed to create project: {e}")
61
+
62
+ def _build_create_command(self) -> List[str]:
63
+ """Build the flutter create command."""
64
+ cmd = [
65
+ str(self.flutter_root / "bin" / "flutter"),
66
+ "create",
67
+ "--org",
68
+ self.config.org,
69
+ "--project-name",
70
+ self.config.package_name,
71
+ "--platforms",
72
+ self.config.platforms_csv,
73
+ "--template",
74
+ self.config.template,
75
+ ]
76
+
77
+ # Add template-specific options
78
+ if self.config.template == "plugin":
79
+ cmd.extend(
80
+ [
81
+ "--ios-language",
82
+ self.config.ios_language,
83
+ "--android-language",
84
+ self.config.android_language,
85
+ ]
86
+ )
87
+
88
+ # Add output path
89
+ cmd.append(str(self.config.project_path))
90
+
91
+ return cmd
@@ -0,0 +1,99 @@
1
+ """Load a versioned Flutter profile and validate configuration without writes."""
2
+
3
+ import json
4
+ from importlib.resources import files
5
+ from pathlib import Path
6
+ from typing import Any, cast
7
+
8
+ import yaml
9
+ from jsonschema import Draft202012Validator, FormatChecker
10
+
11
+
12
+ class StandardsError(ValueError):
13
+ """A standards configuration could not be read or validated."""
14
+
15
+
16
+ def _data(name: str) -> dict[str, Any]:
17
+ resource = files("flutter_setup").joinpath("standards_data", name)
18
+ return json.loads(resource.read_text(encoding="utf-8"))
19
+
20
+
21
+ class _ManifestLoader(yaml.SafeLoader):
22
+ # YAML dates must remain strings so they can be validated against JSON Schema.
23
+ yaml_implicit_resolvers = {
24
+ key: [
25
+ (tag, regex)
26
+ for tag, regex in resolvers
27
+ if tag != "tag:yaml.org,2002:timestamp"
28
+ ]
29
+ for key, resolvers in yaml.SafeLoader.yaml_implicit_resolvers.items()
30
+ }
31
+
32
+ def construct_mapping(
33
+ self, node: yaml.MappingNode, deep: bool = False
34
+ ) -> dict[Any, Any]:
35
+ result: dict[Any, Any] = {}
36
+ for key_node, value_node in node.value:
37
+ key = self.construct_object(key_node, deep=deep)
38
+ if not isinstance(key, str):
39
+ raise StandardsError("Configuration keys must be strings")
40
+ if key in result:
41
+ raise StandardsError(f"Duplicate configuration key {key!r}")
42
+ result[key] = self.construct_object(value_node, deep=deep)
43
+ return result
44
+
45
+
46
+ def _validate(document: object, source: str) -> dict[str, Any]:
47
+ validator = Draft202012Validator(
48
+ _data("manifest-v1.schema.json"), format_checker=FormatChecker()
49
+ )
50
+ error = next(validator.iter_errors(document), None)
51
+ if error is not None:
52
+ key_path = ".".join(map(str, error.absolute_path))
53
+ location = f"{source} ({key_path})" if key_path else source
54
+ raise StandardsError(f"{location}: {error.message}")
55
+ return cast(dict[str, Any], document)
56
+
57
+
58
+ def load_manifest(path: Path) -> dict[str, Any]:
59
+ """Load and validate YAML or JSON configuration from an explicit path."""
60
+ try:
61
+ document = yaml.load(path.read_text(encoding="utf-8"), Loader=_ManifestLoader)
62
+ except (OSError, ValueError, yaml.YAMLError) as exc:
63
+ raise StandardsError(f"{path}: {exc}") from exc
64
+ return _validate(document, str(path))
65
+
66
+
67
+ def resolve_standards(
68
+ *,
69
+ project: Path | None = None,
70
+ user: Path | None = None,
71
+ overrides: dict[str, Any] | None = None,
72
+ ) -> dict[str, Any]:
73
+ """Resolve explicit CLI values, project, user, profile, then defaults."""
74
+ layers = [load_manifest(path) for path in (user, project) if path is not None]
75
+ if overrides is not None:
76
+ layers.append(_validate({"schema_version": 1, **overrides}, "CLI overrides"))
77
+
78
+ selection = {"id": "everyday-devops-flutter", "version": "1.0.0"}
79
+ for layer in layers:
80
+ selection = layer.get("profile", selection)
81
+ profile = _data(f"{selection['id']}-{selection['version']}.json")
82
+ resolved: dict[str, Any] = {
83
+ "schema_version": 1,
84
+ "profile": selection,
85
+ "capabilities": dict(profile["capabilities"]),
86
+ "rules": {key: rule["severity"] for key, rule in profile["rules"].items()},
87
+ "exceptions": {},
88
+ "project": dict(profile.get("project", {})),
89
+ }
90
+ project_values: dict[str, Any] = {}
91
+ for layer in layers:
92
+ project_values.update(layer.get("project", {}))
93
+ for key in ("capabilities", "rules", "exceptions", "project"):
94
+ resolved[key].update(layer.get(key, {}))
95
+ if project_values.get("template") == "plugin":
96
+ for key, default in (("architecture", "basic"), ("testing", "standard")):
97
+ if key not in project_values:
98
+ resolved["project"][key] = default
99
+ return resolved
@@ -0,0 +1,97 @@
1
+ {
2
+ "id": "everyday-devops-flutter",
3
+ "version": "1.0.0",
4
+ "capabilities": {
5
+ "persistence": false,
6
+ "authentication": false,
7
+ "offline": false,
8
+ "sentry": false
9
+ },
10
+ "rules": {
11
+ "architecture.feature-first": {
12
+ "severity": "error",
13
+ "guidance": "Organize each feature into presentation, domain and data boundaries."
14
+ },
15
+ "state.riverpod": {
16
+ "severity": "error",
17
+ "guidance": "Use Riverpod providers for application state and dependency injection."
18
+ },
19
+ "navigation.go-router": {
20
+ "severity": "error",
21
+ "guidance": "Define routes and deep links using GoRouter."
22
+ },
23
+ "design.material-3": {
24
+ "severity": "warning",
25
+ "guidance": "Use Material 3 and theme tokens."
26
+ },
27
+ "design.responsive": {
28
+ "severity": "warning",
29
+ "guidance": "Adapt layouts to window size, orientation and text scaling."
30
+ },
31
+ "design.accessibility": {
32
+ "severity": "error",
33
+ "guidance": "Verify semantics, labels, contrast, focus and accessible target sizes."
34
+ },
35
+ "data.drift": {
36
+ "severity": "warning",
37
+ "guidance": "Use Drift with SQLite when local persistence is enabled.",
38
+ "capability": "persistence"
39
+ },
40
+ "auth.port": {
41
+ "severity": "warning",
42
+ "guidance": "Keep the authentication provider behind a replaceable interface.",
43
+ "capability": "authentication"
44
+ },
45
+ "data.offline": {
46
+ "severity": "warning",
47
+ "guidance": "Document offline behavior, cache and synchronization policy.",
48
+ "capability": "offline"
49
+ },
50
+ "observability.logging": {
51
+ "severity": "warning",
52
+ "guidance": "Emit structured logs and redact credentials and personal data."
53
+ },
54
+ "observability.sentry": {
55
+ "severity": "warning",
56
+ "guidance": "Use Sentry with consent and redaction settings when enabled.",
57
+ "capability": "sentry"
58
+ },
59
+ "test.unit-widget": {
60
+ "severity": "error",
61
+ "guidance": "Cover domain and widget behavior using Flutter tests."
62
+ },
63
+ "test.mocktail": {
64
+ "severity": "warning",
65
+ "guidance": "Use Mocktail when substituting test dependencies."
66
+ },
67
+ "test.patrol": {
68
+ "severity": "warning",
69
+ "guidance": "Use Patrol for end-to-end tests on supported configured platforms."
70
+ },
71
+ "ci.github-actions": {
72
+ "severity": "error",
73
+ "guidance": "Run formatting, analysis, tests and platform-appropriate builds in GitHub Actions."
74
+ },
75
+ "dependencies.management": {
76
+ "severity": "error",
77
+ "guidance": "Commit application lockfiles and review dependency upgrades."
78
+ },
79
+ "sdk.pinned": {
80
+ "severity": "error",
81
+ "guidance": "Record the Flutter SDK version and use it consistently in CI and development."
82
+ },
83
+ "docs.development": {
84
+ "severity": "warning",
85
+ "guidance": "Document setup, design decisions, checks and supported platforms."
86
+ },
87
+ "agents.instructions": {
88
+ "severity": "warning",
89
+ "guidance": "Provide repository-scoped agent instructions and validation commands."
90
+ }
91
+ },
92
+ "project": {
93
+ "architecture": "clean",
94
+ "testing": "mocktail",
95
+ "e2e_testing": "integration_test"
96
+ }
97
+ }