Validate manifest files and auto-detect artifact type.
(
content_path: Path,
)
| 506 | |
| 507 | |
| 508 | def validate_and_detect_manifest( |
| 509 | content_path: Path, |
| 510 | ) -> ManifestResult: |
| 511 | """ |
| 512 | Validate manifest files and auto-detect artifact type. |
| 513 | """ |
| 514 | # Try framework manifests first |
| 515 | framework_manifests = ["framework.json", "package.json"] |
| 516 | for manifest in framework_manifests: |
| 517 | manifest_path = content_path / manifest |
| 518 | if manifest_path.exists(): |
| 519 | try: |
| 520 | with open(manifest_path, "r") as f: |
| 521 | json.load(f) # Validate JSON syntax |
| 522 | print(f"Found valid framework manifest: {manifest_path}") |
| 523 | return ManifestResult( |
| 524 | is_valid=True, manifest_path=manifest_path, is_framework=True |
| 525 | ) |
| 526 | except json.JSONDecodeError as e: |
| 527 | logger.warning(f"Invalid JSON in {manifest_path}: {e}") |
| 528 | |
| 529 | # Try platform manifest |
| 530 | platform_manifest = content_path / "platform.json" |
| 531 | if platform_manifest.exists(): |
| 532 | try: |
| 533 | with open(platform_manifest, "r") as f: |
| 534 | json.load(f) # Validate JSON syntax |
| 535 | print(f"Found valid platform manifest: {platform_manifest}") |
| 536 | return ManifestResult( |
| 537 | is_valid=True, manifest_path=platform_manifest, is_framework=False |
| 538 | ) |
| 539 | except json.JSONDecodeError as e: |
| 540 | logger.warning(f"Invalid JSON in {platform_manifest}: {e}") |
| 541 | |
| 542 | return ManifestResult(is_valid=False, manifest_path=None, is_framework=False) |
| 543 | |
| 544 | |
| 545 | def get_platformio_command_path(path: Path) -> str: |
no test coverage detected