diff --git a/.github/dependabot.yml b/.github/dependabot.yml index b276d15..75ddf2b 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,12 +1,11 @@ # Keep the supply chain current: GitHub Actions and Cargo dependencies. # -# Copied from Project-Colony-Resources templates/dependabot.yml. The one -# difference is the cargo directory: the crate lives in src-tauri/. +# Copied from Project-Colony-Resources templates/dependabot.yml. # # Dependabot opening a PR is not the rule being followed; merging it is. See # design/dependencies.md: everything is on its latest release, always. # -# The libraries in dist/vendor/ (highlight.js, KaTeX, Mermaid, the Colony +# The libraries in src/ui/vendor/ (highlight.js, KaTeX, Mermaid, the Colony # themes) are not packages Dependabot can see. Check them by hand on the # weekly pass; docs/third-party-notices.md lists their versions. version: 2 @@ -29,7 +28,7 @@ updates: patterns: ["*"] - package-ecosystem: cargo - directory: /src-tauri + directory: / schedule: interval: weekly open-pull-requests-limit: 5 diff --git a/.github/scripts/check-colony-themes.py b/.github/scripts/check-colony-themes.py index 4bd5a77..ad95511 100644 --- a/.github/scripts/check-colony-themes.py +++ b/.github/scripts/check-colony-themes.py @@ -1,10 +1,13 @@ #!/usr/bin/env python3 -"""Check that dist/ only uses Colony colours that every theme defines. +"""Check that src/ui/ only uses Colony colours that every theme defines. -dist/vendor/colony/colony-themes.css sets the --colony-* variables once per +src/ui/vendor/colony/colony-themes.css sets the --colony-* variables once per theme, and themes.json lists the themes the picker offers. A variable one theme lacks leaves that colour unset in that theme, so this fails on it, and on a picker entry with no CSS block or a CSS block with no picker entry. +colony-accents.css sets the accent colours once for every theme, so a +variable it defines counts as defined everywhere, and every accent the +picker offers must be one of them. """ import json @@ -12,29 +15,40 @@ import sys from pathlib import Path -dist = Path(__file__).resolve().parents[2] / "dist" -vendor = dist / "vendor" / "colony" +ui = Path(__file__).resolve().parents[2] / "src" / "ui" +vendor = ui / "vendor" / "colony" + + +def variables(css_file): + """{selector: set of --colony-* names}, comments out first: the file + header quotes a selector.""" + css = re.sub(r"/\*.*?\*/", "", (vendor / css_file).read_text(encoding="utf-8"), flags=re.S) + return { + selector.strip(): set(re.findall(r"(--colony-[a-z0-9-]+):", body)) + for selector, body in re.findall(r"([^{}]+)\{([^}]*)\}", css) + } + -# Comments out first: the file header quotes a selector. -css = re.sub(r"/\*.*?\*/", "", (vendor / "colony-themes.css").read_text(encoding="utf-8"), flags=re.S) themes = { - slug: set(re.findall(r"(--colony-[a-z0-9-]+):", body)) - for slug, body in re.findall(r'\[data-colony-theme="([^"]+)"\][^{]*\{([^}]*)\}', css) -} -listed = { - variant["slug"] - for family in json.loads((vendor / "themes.json").read_text(encoding="utf-8"))["families"] - for variant in family["variants"] + re.search(r'\[data-colony-theme="([^"]+)"\]', selector).group(1): defined + for selector, defined in variables("colony-themes.css").items() + if "[data-colony-theme=" in selector } +accents = variables("colony-accents.css").get(":root", set()) +theme_list = json.loads((vendor / "themes.json").read_text(encoding="utf-8")) +listed = {variant["slug"] for family in theme_list["families"] for variant in family["variants"]} errors = [] if not themes or set(themes) != listed: errors.append(f"themes.json and colony-themes.css disagree: {sorted(set(themes) ^ listed)}") -for path in sorted(dist.glob("*.*")): - for var in sorted(set(re.findall(r"--colony-[a-z0-9-]+", path.read_text(encoding="utf-8")))): +for accent in theme_list["accents"]: + if accent["cssVar"] not in accents: + errors.append(f"themes.json: accent {accent['key']} has no {accent['cssVar']} in colony-accents.css") +for path in sorted(ui.glob("*.*")): + for var in sorted(set(re.findall(r"--colony-[a-z0-9-]+", path.read_text(encoding="utf-8"))) - accents): missing = [slug for slug, defined in themes.items() if var not in defined] if missing: errors.append(f"{path.name}: {var} is missing from {', '.join(missing)}") -print("\n".join(errors) or f"OK: all {len(themes)} themes define every --colony-* variable in dist/") +print("\n".join(errors) or f"OK: all {len(themes)} themes define every --colony-* variable in src/ui/") sys.exit(1 if errors else 0) diff --git a/.github/scripts/check-document-filter.py b/.github/scripts/check-document-filter.py index f61b171..3cbba36 100644 --- a/.github/scripts/check-document-filter.py +++ b/.github/scripts/check-document-filter.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -"""Check that render() in dist/app.js still drops every element that could act +"""Check that render() in src/ui/app.js still drops every element that could act on MemoryStick's own page. comrak keeps a document's raw HTML as written, and the inert