clone

a personal forge on plain git: static pages, stacked-diff reviews, signed local ci, repo sites and releases

main
forge / test / scenarios / insights-private.sh
insights-private.sh 2.2K
1# Private repos are in no public insights: no insights page or export in2# www, and nothing of theirs in the forge's (JSON or Parquet). Their3# exports are in the lake's state, and in their pages in the private root4# for their readers (insights-private-pages). A5# repo that goes private leaves the forge's insights at once; one that goes6# public joins them at the next run.7. "$(dirname "$0")/../lib.sh"8user dami9repo --private dami/secret "hidden thing"10repo dami/open "open thing"11for r in secret open; do12 clone dami "dami/$r" "$T/w/$r"13 at "$T/w/$r" commit "first"14 ok push_as dami "$T/w/$r" origin main15 at "$T/w/$r" commit "idea"16 ok push_as dami "$T/w/$r" origin HEAD:dami/idea17done18build19ok forge lake20w=$FORGE_WWW21exists "$w/dami/open/insights/insights.json"22missing "$w/dami/secret"23exists "$FORGE_ROOT/.forge/lake/export/dami/secret/insights/insights.json"24has "$w/insights/insights.json" 'dami/open'25lacks "$w/insights/insights.json" 'dami/secret'26if grep -rlq 'secret' "$w/insights" "$w/dami/open"; then fail "a public export names the private repo"; fi27# The Parquet files, read: rows of dami/open only.28pq() { (cd "$T_HOME" && node --input-type=module -e "29import { DuckDBInstance } from '@duckdb/node-api';30const db = await DuckDBInstance.create(':memory:');31const c = await db.connect();32const r = await c.runAndReadAll(\"SELECT string_agg(DISTINCT repo, ' ' ORDER BY repo) FROM read_parquet('\" + process.argv[1] + \"')\");33console.log(r.getRowsJson()[0][0] ?? '');34" "$1"); }35for f in events reviews; do eq "$(pq "$w/insights/$f.parquet")" "dami/open"; done36eq "$(pq "$FORGE_ROOT/.forge/lake/export/dami/secret/insights/events.parquet")" "dami/secret"37# Going private takes it out of the forge's insights right away, and the38# next run doesn't put its pages' exports back.39ok ssh_as dami private dami/open40missing "$w/dami/open"41missing "$w/insights/insights.json"42ok forge lake43exists "$w/insights/insights.json"44lacks "$w/insights/insights.json" 'dami/open'45missing "$w/dami/open"46# Going public: in the forge's insights after the next run, and its own page.47ok ssh_as dami public dami/secret48build dami/secret49ok forge lake50has "$w/insights/insights.json" 'dami/secret'51exists "$w/dami/secret/insights/insights.json"52exists "$w/dami/secret/insights/index.html"