Fix scaffolding generations (#138820)

This commit is contained in:
Steven Hartland
2025-02-19 19:23:29 +00:00
committed by GitHub
parent bc5146db3c
commit 4ed4c2cc5c
4 changed files with 105 additions and 42 deletions

View File

@ -4,9 +4,12 @@ from __future__ import annotations
import json
from pathlib import Path
from typing import Any
import attr
from script.util import sort_manifest
from .const import COMPONENT_DIR, TESTS_DIR
@ -44,16 +47,19 @@ class Info:
"""Path to the manifest."""
return COMPONENT_DIR / self.domain / "manifest.json"
def manifest(self) -> dict:
def manifest(self) -> dict[str, Any]:
"""Return integration manifest."""
return json.loads(self.manifest_path.read_text())
def update_manifest(self, **kwargs) -> None:
"""Update the integration manifest."""
print(f"Updating {self.domain} manifest: {kwargs}")
self.manifest_path.write_text(
json.dumps({**self.manifest(), **kwargs}, indent=2) + "\n"
)
# Sort keys in manifest so we don't trigger hassfest errors.
manifest: dict[str, Any] = {**self.manifest(), **kwargs}
sort_manifest(manifest)
self.manifest_path.write_text(json.dumps(manifest, indent=2) + "\n")
@property
def strings_path(self) -> Path: