mirror of
https://github.com/kellymichels/zscripts-token-savers
synced 2026-10-07 07:18:18 +00:00
The mirror's deploy pair had drifted ~280 lines behind: it lacked the
transactional .env preserve/restore (an interrupted deploy could destroy
server-side env files), the stderr-flattening step wrapper (a successful
deploy reported failure and skipped its own verification), and the
verification rework (channel re-picked every retry, edge only with a Host
to route by, verify.timeoutSeconds, honest split of "stale build" vs "no
channel answered").
The sync is byte-faithful to the private tree except where the mirror's
own Sanitization suite demands otherwise - and it caught the first copy:
three failures for private project names, a private domain, and a
private-only script name that rode along in comments. Each war story keeps
its lesson and loses its cast, per the convention already in the file
("EvoCivilCode: deploy/" was already published as "(deploy/, infra/,
...)"). That suite going red on an unsanitized copy is exactly what it
exists for.
Also in this change:
- tests/VerifyPlan.Tests.ps1 - the channel-selection rules are pure
functions and Pester pins them (no domain => no edge attempt; the PS 5.1
one-element-unroll trap). First verification tests in the mirror.
- README: the verify block now documents viaProxy/upstream (they shipped
in the docker-network read but were never in the README),
timeoutSeconds, and the channel order with why it re-resolves per retry.
- README.txt: generated plain-text twin, via scripts/readme_txt.py
(vendored from the fleet's reference implementation; the file is
generated, never edited by hand).
- CHANGELOG.md/.txt: entries merged into the existing Unreleased sections.
CHECKSUMS.txt refreshed (42 entries). Pester: 240 passed, 0 failed.
Both synced files parse clean.
Observed, untouched: the Unreleased section carries duplicate "### Fixed"
headings from earlier appends; folding them risks reordering entries whose
prose references their neighbours, so it is left for the next release cut
(zbump #110 rolls Unreleased into the version being cut).
77 lines
2.6 KiB
Python
77 lines
2.6 KiB
Python
# Evomedia.net Token Savers — https://github.com/evomedia-net/evo.zscripts
|
|
# Created by Kelly Michels · dev@evomedia.net
|
|
# Licensed under the MIT License. See LICENSE.
|
|
|
|
"""Render README.md to README.txt with the markdown markup removed.
|
|
|
|
README.txt exists for terminals, pagers and anywhere markdown doesn't
|
|
render. It is generated - never edit it by hand:
|
|
|
|
python scripts/readme_txt.py # rewrite README.txt
|
|
python scripts/readme_txt.py --check # exit 1 if it is out of sync
|
|
|
|
The test suite runs --check, so a README.md edit that forgets to
|
|
regenerate fails CI rather than shipping a stale mirror.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import re
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parent.parent
|
|
|
|
|
|
def _inline(text: str) -> str:
|
|
text = re.sub(r"!\[([^\]]*)\]\([^)]*\)", r"\1", text) # images -> alt text
|
|
text = re.sub(r"\[([^\]]+)\]\(([^)]+)\)", r"\1 (\2)", text) # links -> text (url)
|
|
text = re.sub(r"\*\*([^*]+)\*\*", r"\1", text) # bold
|
|
text = re.sub(r"(?<!\*)\*([^*\n]+)\*(?!\*)", r"\1", text) # italic
|
|
text = re.sub(r"`([^`]+)`", r"\1", text) # inline code
|
|
return text
|
|
|
|
|
|
def render(md: str) -> str:
|
|
out: list[str] = []
|
|
in_fence = False
|
|
for line in md.splitlines():
|
|
if line.lstrip().startswith("```"):
|
|
# Drop the fence markers; the code itself stays, indented so it
|
|
# still reads as a block without the backticks.
|
|
in_fence = not in_fence
|
|
continue
|
|
if in_fence:
|
|
out.append((" " + line) if line else "")
|
|
continue
|
|
heading = re.match(r"^(#{1,6})\s+(.*)$", line)
|
|
if heading:
|
|
text = _inline(heading.group(2))
|
|
out.append(text)
|
|
out.append(("=" if len(heading.group(1)) == 1 else "-") * len(text))
|
|
continue
|
|
out.append(_inline(line))
|
|
text = "\n".join(out)
|
|
text = re.sub(r"\n{3,}", "\n\n", text)
|
|
return text.strip() + "\n"
|
|
|
|
|
|
def main() -> int:
|
|
source = (ROOT / "README.md").read_text(encoding="utf-8")
|
|
rendered = render(source)
|
|
target = ROOT / "README.txt"
|
|
if "--check" in sys.argv:
|
|
current = target.read_text(encoding="utf-8") if target.exists() else ""
|
|
if current != rendered:
|
|
print("README.txt is out of sync - run: python scripts/readme_txt.py")
|
|
return 1
|
|
print("README.txt is in sync")
|
|
return 0
|
|
target.write_text(rendered, encoding="utf-8", newline="\n")
|
|
print(f"Wrote {target} ({len(rendered.splitlines())} lines)")
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|