generated from nhcarrigan/template
feat: reorganise bash scripts and add comprehensive documentation (#6)
CI / dependency-pin-check-typescript (push) Successful in 5s
CI / dependency-pin-check-python (push) Successful in 4s
CI / python (push) Successful in 9m28s
CI / typescript (push) Successful in 9m42s
Security Scan and Upload / Security & DefectDojo Upload (push) Successful in 1m39s
CI / dependency-pin-check-typescript (push) Successful in 5s
CI / dependency-pin-check-python (push) Successful in 4s
CI / python (push) Successful in 9m28s
CI / typescript (push) Successful in 9m42s
Security Scan and Upload / Security & DefectDojo Upload (push) Successful in 1m39s
## Summary This PR completes the bash script restructuring and adds comprehensive documentation across all script categories. ### Bash Restructuring - Moved cohort shell scripts (`remove_github_members.sh`, `update_github_teams.sh`) from `python/cohort/` into a new `bash/cohort/` directory - Moved existing bash utilities (`add-keys-to-git.sh`, `fix-yubikey-perms.sh`, `list-yubikey-ssh-keys.sh`) into a new `bash/yubikey/` subdirectory - Updated `run.sh` to support **Bash** as a third language option alongside TypeScript and Python - Bash scripts are run directly (no 1Password secret injection needed) - Category discovery and script listing works the same as for TS/Python - Removed dead "Root Scripts" logic that was no longer needed ### Documentation Added `README.md` files for all script categories that were missing them: - `bash/cohort/README.md` — cohort GitHub team management scripts - `bash/yubikey/README.md` — YubiKey SSH key and permission utilities - `typescript/src/crowdin/README.md` — Crowdin translation management scripts - `typescript/src/discord/README.md` — Discord bot utility scripts - `typescript/src/discourse/README.md` — Discourse forum management scripts - `typescript/src/gitea/README.md` — Gitea bulk repository operation scripts - `typescript/src/github/README.md` — GitHub API interaction scripts - `typescript/src/music/README.md` — Music file metadata tools - `typescript/src/s3/README.md` — S3-compatible object storage scripts - `typescript/src/security/README.md` — Security analysis and reporting scripts - `python/cohort/README.md` — Updated to remove moved shell scripts, fix usage commands Also updated project-level docs: - **`README.md`** — Corrected project structure, fixed running instructions (removed references to non-existent `make run-ts`/`make run-py` targets), added Bash prerequisites - **`CLAUDE.md`** — Updated project overview, structure, development standards, and script-adding guides to reflect the current state of the project ✨ This PR was created with help from Hikari~ 🌸 Co-authored-by: Naomi Carrigan <commits@nhcarrigan.com> Reviewed-on: #6 Co-authored-by: Hikari <hikari@nhcarrigan.com> Co-committed-by: Hikari <hikari@nhcarrigan.com>
This commit was merged in pull request #6.
This commit is contained in:
@@ -0,0 +1,86 @@
|
||||
"""Dry-run check of Discord message lengths before sending the activity report.
|
||||
|
||||
Parses the catch_up_report.md table, formats each team's data into a monospace
|
||||
Discord table, and reports whether any message would exceed Discord's 2000-char limit.
|
||||
Run this before send_activity_report.py to catch length issues early.
|
||||
|
||||
Data files (place in data/):
|
||||
- catch_up_report.md Activity report generated by catch_up_report.py
|
||||
|
||||
Env vars:
|
||||
- None
|
||||
"""
|
||||
|
||||
FIELDS = [
|
||||
("Discord Username", "Name", 18),
|
||||
("Discord Messages", "Msgs", 5),
|
||||
("PRs Opened", "PRs", 4),
|
||||
("Issues Opened", "Issues", 6),
|
||||
("Issue Comments", "Issue♟", 7),
|
||||
("PR Comments", "PR♟", 5),
|
||||
("PR Reviews", "Reviews", 7),
|
||||
("Commits", "Commits", 7),
|
||||
]
|
||||
|
||||
REPORT_PATH = "data/catch_up_report.md"
|
||||
|
||||
|
||||
def parse_report(path: str) -> dict[str, list[dict]]:
|
||||
"""Parse the markdown table from catch_up_report.md into team → rows."""
|
||||
teams: dict[str, list[dict]] = {}
|
||||
with open(path, encoding="utf-8") as f:
|
||||
lines = f.readlines()
|
||||
header_line = None
|
||||
for i, line in enumerate(lines):
|
||||
if line.startswith("| Discord ID |"):
|
||||
header_line = i
|
||||
break
|
||||
headers = [h.strip() for h in lines[header_line].strip().strip("|").split("|")]
|
||||
for line in lines[header_line + 2 :]:
|
||||
line = line.strip()
|
||||
if not line.startswith("|"):
|
||||
break
|
||||
vals = [v.strip() for v in line.strip().strip("|").split("|")]
|
||||
row = dict(zip(headers, vals))
|
||||
teams.setdefault(row["Team"], []).append(row)
|
||||
return teams
|
||||
|
||||
|
||||
def format_table(members: list[dict]) -> str:
|
||||
"""Format a team's member list as a monospace table for Discord."""
|
||||
members = sorted(members, key=lambda r: int(r["Discord Messages"]), reverse=True)
|
||||
col_widths = [w for _, _, w in FIELDS]
|
||||
col_headers = [h for _, h, _ in FIELDS]
|
||||
max_name = max(len(m["Discord Username"]) for m in members)
|
||||
col_widths[0] = max(col_widths[0], max_name)
|
||||
|
||||
def pad(val: str, width: int, right_align: bool = False) -> str:
|
||||
return val.rjust(width) if right_align else val.ljust(width)
|
||||
|
||||
header_row = " ".join(
|
||||
pad(col_headers[i], col_widths[i], right_align=(i > 0))
|
||||
for i in range(len(FIELDS))
|
||||
)
|
||||
separator = " ".join("-" * w for w in col_widths)
|
||||
rows = []
|
||||
for m in members:
|
||||
vals = [m[key] for key, _, _ in FIELDS]
|
||||
row = " ".join(
|
||||
pad(vals[i], col_widths[i], right_align=(i > 0)) for i in range(len(FIELDS))
|
||||
)
|
||||
rows.append(row)
|
||||
return "\n".join([header_row, separator] + rows)
|
||||
|
||||
|
||||
def main() -> None:
|
||||
"""Check Discord message lengths for all teams."""
|
||||
teams = parse_report(REPORT_PATH)
|
||||
for team, members in teams.items():
|
||||
table = format_table(members)
|
||||
msg = f"**{team} — Activity Report (Feb 15–23)**\n```\n{table}\n```"
|
||||
status = "OK" if len(msg) <= 2000 else f"OVER by {len(msg) - 2000}"
|
||||
print(f"{team}: {len(msg)} chars — {status}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user