Updates for hooks
This commit is contained in:
@@ -18,7 +18,15 @@
|
||||
"Bash(pip install:*)",
|
||||
"Bash(python3 -m pip install requests python-dotenv)",
|
||||
"Bash(python3 -c \"import sys; print\\(sys.executable\\)\")",
|
||||
"Bash(python -c \"import sys; print\\(sys.executable\\)\")"
|
||||
"Bash(python -c \"import sys; print\\(sys.executable\\)\")",
|
||||
"Bash(command -v python)",
|
||||
"Bash(command -v python3)",
|
||||
"Bash(/c/Python314/python -c \"import requests, dotenv\")",
|
||||
"Bash(bash -c '[[ -x \"\"/c/Python314/python\"\" ]] && echo \"\"executable\"\" || echo \"\"not executable\"\"')",
|
||||
"Bash(bash -c '/c/Python314/python -c \"\"import requests, dotenv\"\" 2>&1 && echo OK || echo FAIL')",
|
||||
"Bash(bash -c '/c/Python314/python -c \"\"import requests, dotenv\"\" && echo OK || echo FAIL')",
|
||||
"Bash(bash -c '_py_check\\(\\) { [[ -n \"\"$1\"\" ]] && \"\"$1\"\" -c \"\"import requests, dotenv\"\" &>/dev/null 2>&1; }; if _py_check \"\"/c/Python314/python\"\"; then echo \"\"FOUND\"\"; else echo \"\"NOT FOUND\"\"; fi')",
|
||||
"Bash(bash -c 'set -euo pipefail; _py_check\\(\\) { [[ -n \"\"$1\"\" ]] && \"\"$1\"\" -c \"\"import requests, dotenv\"\" &>/dev/null 2>&1; }; if _py_check \"\"/c/Python314/python\"\"; then echo FOUND; else echo NOT FOUND; fi')"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,17 +19,12 @@ POST_PUSH="$HOOKS_DIR/post-push"
|
||||
cat > "$POST_PUSH" << 'EOF'
|
||||
#!/usr/bin/env bash
|
||||
# post-push hook — sync markdown files to WikiJS after every push.
|
||||
cd "$(git rev-parse --show-toplevel)"
|
||||
PYTHON=$(command -v python3 2>/dev/null || command -v python 2>/dev/null || true)
|
||||
if [[ -z "$PYTHON" ]]; then
|
||||
echo "[wikijs] python not found — skipping doc sync"
|
||||
elif ! "$PYTHON" -c "import requests" &>/dev/null; then
|
||||
echo "[wikijs] requests not installed — skipping doc sync (run: $PYTHON -m pip install requests python-dotenv)"
|
||||
else
|
||||
"$PYTHON" tools/publish_docs.py || echo "[wikijs] publish failed — run manually: $PYTHON tools/publish_docs.py"
|
||||
fi
|
||||
REPO=$(git rev-parse --show-toplevel)
|
||||
powershell.exe -NoProfile -NonInteractive -Command "
|
||||
Set-Location '$REPO'
|
||||
python tools/publish_docs.py
|
||||
" || echo "[wikijs] publish failed — run manually: python tools/publish_docs.py"
|
||||
EOF
|
||||
|
||||
chmod +x "$POST_PUSH"
|
||||
echo " Installed post-push hook → $POST_PUSH"
|
||||
|
||||
@@ -32,16 +32,24 @@ WIKIJS_API_KEY = os.environ["WIKIJS_API_KEY"] # loud failure if missing
|
||||
GRAPHQL_ENDPOINT = f"{WIKIJS_URL.rstrip('/')}/graphql"
|
||||
LOCALE = "en"
|
||||
|
||||
# Maps repo-relative file path → WikiJS page path (no leading slash)
|
||||
MANIFEST: dict[str, str] = {
|
||||
"README.md": "en/engineering/AI-Framework/home",
|
||||
"CLAUDE.md": "en/engineering/AI-Framework/CLAUDE",
|
||||
"docker/CLAUDE.md": "en/engineering/AI-Framework/docker",
|
||||
"ignition/CLAUDE.md": "en/engineering/AI-Framework/ignition",
|
||||
"testing/CLAUDE.md": "en/engineering/AI-Framework/testing",
|
||||
"webdev/CLAUDE.md": "en/engineering/AI-Framework/webdev",
|
||||
"ignition/ignition-api.md": "en/engineering/AI-Framework/ignition/ignition-api",
|
||||
"docker/config/traefik/dynamic/README.md": "en/engineering/AI-Framework/docker/traefik",
|
||||
# Maps repo-relative file path → (WikiJS path, title)
|
||||
MANIFEST: dict[str, tuple[str, str]] = {
|
||||
"README.md": (
|
||||
"engineering/AI-Framework", "AI-Framework Project"),
|
||||
"CLAUDE.md": (
|
||||
"engineering/AI-Framework/CLAUDE", "Claude AI Instructions"),
|
||||
"docker/CLAUDE.md": (
|
||||
"engineering/AI-Framework/docker", "Docker"),
|
||||
"ignition/CLAUDE.md": (
|
||||
"engineering/AI-Framework/ignition", "Ignition"),
|
||||
"testing/CLAUDE.md": (
|
||||
"engineering/AI-Framework/testing", "Testing"),
|
||||
"webdev/CLAUDE.md": (
|
||||
"engineering/AI-Framework/webdev", "WebDev"),
|
||||
"ignition/ignition-api.md": (
|
||||
"engineering/AI-Framework/ignition/ignition-api", "Ignition Open API Endpoints"),
|
||||
"docker/config/traefik/dynamic/README.md": (
|
||||
"engineering/AI-Framework/docker/traefik", "Traefik"),
|
||||
}
|
||||
|
||||
|
||||
@@ -83,16 +91,6 @@ def page_id_for_path(wiki_path: str) -> int | None:
|
||||
return None
|
||||
|
||||
|
||||
def derive_title(local_path: str) -> str:
|
||||
stem = Path(local_path).stem # e.g. "ignition-api"
|
||||
if stem.upper() == "README":
|
||||
# Use parent directory name for README files
|
||||
parent = Path(local_path).parent.name
|
||||
if parent == ".":
|
||||
return "Home"
|
||||
return parent.replace("-", " ").replace("_", " ").title()
|
||||
return stem.replace("-", " ").replace("_", " ").title()
|
||||
|
||||
|
||||
def create_page(wiki_path: str, title: str, content: str) -> None:
|
||||
mutation = """
|
||||
@@ -165,9 +163,8 @@ def main() -> int:
|
||||
|
||||
errors = 0
|
||||
|
||||
for local_rel, wiki_path in MANIFEST.items():
|
||||
for local_rel, (wiki_path, title) in MANIFEST.items():
|
||||
local_file = REPO_ROOT / local_rel
|
||||
title = derive_title(local_rel)
|
||||
|
||||
if not local_file.exists():
|
||||
print(f"[SKIP] {local_rel} (file not found)")
|
||||
|
||||
Reference in New Issue
Block a user