Files
stack/infra/marimo/theme/scripts/apply-overlay.sh
kert 16f3b43974
Some checks failed
CI / skinny-install (aco) (push) Successful in 1m12s
CI / skinny-install (api) (push) Successful in 30s
CI / skinny-install (bcda) (push) Successful in 36s
CI / skinny-install (bib) (push) Successful in 35s
CI / skinny-install (bls) (push) Successful in 27s
CI / skinny-install (ccw) (push) Successful in 32s
CI / skinny-install (cli) (push) Successful in 41s
CI / skinny-install (cms) (push) Successful in 37s
CI / skinny-install (conf) (push) Successful in 38s
CI / skinny-install (opps) (push) Successful in 33s
CI / skinny-install (perf) (push) Successful in 38s
CI / skinny-install (pfs) (push) Successful in 38s
CI / skinny-install (rex) (push) Successful in 34s
Deploy / build-scan-report (push) Failing after 46s
Infra CI / notebooks (push) Failing after 25s
Infra CI / zotero (push) Successful in 12s
Infra CI / docs (push) Failing after 16s
CI / lint-test (push) Failing after 11m2s
Infra CI / mc (push) Successful in 21s
Infra CI / api (push) Successful in 29s
Package Supply Chain / pkg-supply-chain (push) Failing after 41s
feat: full session — mail servers, comment pipeline, PRISMA fetch, email ingest
Mail: Maddy on DO (corwins.media+Resend, fhirworx.io+Postmark),
touchless/stateless/idempotent. Gitea SMTP via env_file. CMS inbox
at cmsupdates@mail.fhirworx.io with IMAP→bib poller.

Bib: regulations.gov v4 client, Federal Register discovery, 164K
comment backfill (running), IMAP email ingest, Zotero sync routing.

PRISMA: altcha PoW solver, CrossRef DOI resolution, 83/129 PDFs.
Zotero: schema parity, ops module, CLI, fail-fast guard.
CI: docs.Dockerfile COPY glob fix (tracks #341).
Infra: Gitea+marimo fhirworx themes, IOM/OIG modules.
2026-04-16 09:04:38 -04:00

108 lines
4.0 KiB
Bash
Executable File

#!/bin/sh
# Apply fhirworx overlay onto a vanilla marimo source tree.
# Idempotent: safe to run multiple times during iterative development.
#
# Invoked by the Dockerfile after `git clone`, before `pnpm install`.
# Run from the marimo source root (same dir as frontend/ and pyproject.toml).
set -eu
SRC="${1:?usage: apply-overlay.sh <marimo-source-root> <overlay-root>}"
OVR="${2:?}"
echo "== fhirworx overlay → $SRC"
# 1. Drop new files in place (lucide-shim, fhirworx.css, asset overrides).
cp -R "$OVR/frontend/." "$SRC/frontend/"
# 2. Add @tabler/icons-react to frontend dependencies via jq (idempotent).
# Pinned to a known-good major that matches our shim's export names.
jq '.dependencies["@tabler/icons-react"] = "^3.26.0"' \
"$SRC/frontend/package.json" > "$SRC/frontend/package.json.new"
mv "$SRC/frontend/package.json.new" "$SRC/frontend/package.json"
# 3. Rewrite pnpm-lock if it exists so pnpm install doesn't error on drift.
rm -f "$SRC/frontend/pnpm-lock.yaml" "$SRC/pnpm-lock.yaml"
# 4. Inject our CSS import into globals.css.
# `@import` must precede all other statements (postcss/CSS spec), so
# append-at-EOF would get rejected with a warning + dropped. Instead,
# insert our @import right after the last existing top-level @import.
if ! grep -q 'fhirworx.css' "$SRC/frontend/src/css/globals.css"; then
python3 - "$SRC/frontend/src/css/globals.css" <<'PY'
import sys, re
p = sys.argv[1]
s = open(p).read()
# Find the index right after the last top-level @import line.
matches = list(re.finditer(r'^@import[^;]*;\s*\n', s, flags=re.M))
if not matches:
sys.exit(f"overlay: no existing @import in {p}")
pos = matches[-1].end()
insert = '@import "./fhirworx.css";\n'
open(p, "w").write(s[:pos] + insert + s[pos:])
PY
fi
# 4b. Strip the "Resources" section from the home page.
# Touchless landing page: no upstream documentation links, just the
# user's notebooks + workspace.
HOME="$SRC/frontend/src/components/pages/home-page.tsx"
if [ -f "$HOME" ] && grep -q '<ResourceLinks />' "$HOME"; then
python3 - "$HOME" <<'PY'
import sys, re
p = sys.argv[1]
s = open(p).read()
# Remove the JSX element render.
s = re.sub(r'^\s*<ResourceLinks />\s*\n', '', s, flags=re.M)
# Remove it from the imports so TS doesn't complain about unused symbols.
s = re.sub(r'(\bResourceLinks,\s*)', '', s)
# Relabel the logo so it doesn't say "marimo".
s = s.replace('alt="marimo logo"', 'alt="fhirworx"')
open(p, 'w').write(s)
PY
fi
# 5. Inject the lucide-react → shim alias into vite.config.mts.
# Match the `resolve: {` block and insert an `alias` entry right after.
if ! grep -q 'lucide-shim' "$SRC/frontend/vite.config.mts"; then
python3 - "$SRC/frontend/vite.config.mts" <<'PY'
import sys, re
path = sys.argv[1]
s = open(path).read()
# Ensure node:path + node:url are imported for the alias resolution.
if "from \"node:path\"" not in s and "from 'node:path'" not in s:
s = 'import { dirname, resolve as pathResolve } from "node:path";\n' + \
'import { fileURLToPath } from "node:url";\n' + s
# Inject alias immediately after `resolve: {`. fileURLToPath() keeps the
# path Windows-safe and anchored to this config file, regardless of where
# the build is invoked from.
inject_alias = (
' alias: {\n'
' "lucide-react": pathResolve(\n'
' dirname(fileURLToPath(import.meta.url)),\n'
' "src/lucide-shim.tsx",\n'
' ),\n'
' },\n'
)
s2, n = re.subn(r'(resolve:\s*\{\n)', r'\1' + inject_alias, s, count=1)
if n != 1:
sys.exit(f"overlay: could not find 'resolve: {{' in {path}")
# Raise the build target to esnext. Default is es2020+old-browsers, and
# vite-plugin-top-level-await's esbuild pass can't downlevel Tabler's
# bundled destructuring patterns to that set. All currently-supported
# evergreen browsers handle esnext output fine; no need to constrain.
inject_target = (
' target: "esnext",\n'
)
s3, n2 = re.subn(r'(build:\s*\{\n)', r'\1' + inject_target, s2, count=1)
if n2 != 1:
sys.exit(f"overlay: could not find 'build: {{' in {path}")
open(path, "w").write(s3)
PY
fi
echo "== overlay applied"