Scaffold Cloudron packaging workspace
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Produce status documentation for all apps."""
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import pathlib
|
||||
import re
|
||||
from datetime import datetime
|
||||
from typing import Dict, List
|
||||
|
||||
@@ -30,7 +32,7 @@ def detect_status(app_dir: pathlib.Path) -> str:
|
||||
placeholders = 0
|
||||
if "TODO" in json.dumps(manifest):
|
||||
placeholders += 1
|
||||
if "Replace start.sh" in start_script:
|
||||
if "not implemented" in start_script:
|
||||
placeholders += 1
|
||||
|
||||
if placeholders == 0:
|
||||
@@ -50,7 +52,27 @@ def render_table(rows: List[Dict[str, str]]) -> str:
|
||||
return "\n".join(lines)
|
||||
|
||||
|
||||
def parse_args() -> argparse.Namespace:
|
||||
parser = argparse.ArgumentParser(description="Generate docs/APP_STATUS.md")
|
||||
parser.add_argument(
|
||||
"--preserve-timestamp",
|
||||
action="store_true",
|
||||
help="Reuse the existing timestamp if the status file already exists",
|
||||
)
|
||||
return parser.parse_args()
|
||||
|
||||
|
||||
def extract_existing_timestamp(path: pathlib.Path) -> str | None:
|
||||
if not path.exists():
|
||||
return None
|
||||
match = re.search(r"_Updated: ([0-9T:-]+Z)_", path.read_text(encoding="utf-8"))
|
||||
if match:
|
||||
return match.group(1)
|
||||
return None
|
||||
|
||||
|
||||
def main() -> None:
|
||||
args = parse_args()
|
||||
catalog = load_catalog()
|
||||
rows: List[Dict[str, str]] = []
|
||||
for entry in catalog:
|
||||
@@ -65,7 +87,13 @@ def main() -> None:
|
||||
"issue": entry.get("issue", "")
|
||||
})
|
||||
|
||||
output = ["# Application Status", "", f"_Updated: {datetime.utcnow().isoformat(timespec='seconds')}Z_", "", render_table(rows)]
|
||||
timestamp = datetime.utcnow().isoformat(timespec='seconds') + "Z"
|
||||
if args.preserve_timestamp:
|
||||
existing = extract_existing_timestamp(ROOT / "docs" / "APP_STATUS.md")
|
||||
if existing:
|
||||
timestamp = existing
|
||||
|
||||
output = ["# Application Status", "", f"_Updated: {timestamp}_", "", render_table(rows)]
|
||||
status_path = ROOT / "docs" / "APP_STATUS.md"
|
||||
status_path.write_text("\n".join(output) + "\n", encoding="utf-8")
|
||||
print(f"Updated {status_path.relative_to(ROOT)}")
|
||||
|
Reference in New Issue
Block a user