Files
CatoandClaude Opus 5 d88da54244 refactor(blog): bip-kit typed blocks replace contentlayer — the post body is server-rendered again (#254)
contentlayer generated a typed `.contentlayer/generated` package at
install/build time and compiled each post's MDX into a JS function. That
indirection had already cost this app a working blog: contentlayer 0.3.x
calls a React internal (`getOwner`) that React 19 removed, so the compiled
body crashed during prerender AND during SSR. The workaround shipped in
MDXContentClient.tsx was to render the post body client-only
(`next/dynamic`, `ssr: false`) — every reader and every crawler got
"Lade Inhalt…" and the article appeared only after hydration.

Posts are now markdown read from disk and parsed with bip-kit 0.2.2:

- content/blog/intake-engine.mdx → .md. The `<Callout type="tip">` became
  GitHub callout syntax (`> [!TIP]`), the `<Infographic>` a captioned
  figure, and the MDX `import` line is gone. `&nbsp;` became a real U+00A0,
  since typed blocks have no HTML passthrough to render an entity through.
  Word-level parity verified: zero words lost, and the article parses to the
  28 blocks you would expect (callout, figure, ol, table, hr, …).
- src/lib/blog.ts is the collection: parseFrontmatter + parseContentBlocks +
  extractToc + readingTime. It enforces the `title`/`date` requirement that
  contentlayer's field schema used to, and guards the slug before it reaches
  the filesystem.
- /blog/[slug] renders through bip-kit's async server ArticleBody. The route
  is prerendered (SSG) again instead of being a client-only shell, and it
  gains a scroll-spy TOC, a reading-progress hairline, server-side shiki
  highlighting, figure lightbox and reading time.
- /blog is a server component again: as a client component it shipped its
  own list-and-sort to every reader for data that comes off disk.
- setHighlighterLoader(() => import('shiki')) is registered at module scope
  because this app builds `output: standalone`, where bip-kit's zero-config
  shiki import is invisible to Next's file tracer — without the literal,
  production would ship unhighlighted while dev looked right.

Deleted with it: contentlayer, next-contentlayer, rehype-pretty-code,
remark-gfm, @mdx-js/react; contentlayer.config.ts; MDXContent.tsx,
MDXContentClient.tsx, MDXComponents.tsx; `withContentlayer` in next.config;
the `contentlayer:build` script, the `postinstall` hook that ran it, and
the SKIP_CONTENTLAYER seams in both Dockerfiles and deploy.yml.disabled that
existed only to switch that build off; the `.contentlayer` entries in
.gitignore/.prettierignore/eslint ignores; and the
estree-util-value-to-estree + toml overrides, which pinned packages nothing
depends on any more (deepmerge-ts stays — it comes via @prisma/config).

Security: contentlayer was the only path to @opentelemetry/core and
@opentelemetry/sdk-trace-node. `pnpm audit` in frontend/ goes from
"2 vulnerabilities found — 1 moderate | 1 high" to "No known
vulnerabilities found".

Visible: the article carried `prose prose-indigo dark:prose-invert` with no
@tailwindcss/typography plugin installed, so those classes matched nothing
and the post rendered as unstyled browser defaults. src/app/blog/blog.css
maps datacat's palette onto bip-kit's --bp-* contract for BOTH themes —
datacat's dark mode is prefers-color-scheme, the same axis bip-kit switches
on, so the article now darkens with the page instead of ignoring it.

Only frontend/ is touched; backend/ is untouched.


Claude-Session: https://claude.ai/code/session_01WqKqMnHQHSmkGFfc5t7Rxn

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-07 14:55:47 +00:00

242 lines
6.7 KiB
Plaintext

name: 🚀 Deploy to Production
on:
push:
branches: [ main ]
paths-ignore:
- '**.md'
- 'docs/**'
workflow_dispatch:
inputs:
skip_tests:
description: 'Skip tests (use with caution)'
required: false
default: 'false'
type: boolean
env:
NODE_VERSION: '18'
DOCKER_COMPOSE_VERSION: '2.20.0'
jobs:
# Job 1: Code Quality & Security Checks
quality:
name: 🔍 Code Quality & Security
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
cache-dependency-path: |
package-lock.json
frontend/package-lock.json
backend/package-lock.json
- name: Install dependencies
run: |
npm ci
cd frontend && npm ci --legacy-peer-deps
cd ../backend && npm ci
- name: Lint frontend
run: cd frontend && npm run lint
- name: TypeScript check
run: cd frontend && npx tsc --noEmit
- name: Security audit
run: |
npm audit --audit-level moderate
cd frontend && npm audit --audit-level moderate
cd ../backend && npm audit --audit-level moderate
# Job 2: Testing
test:
name: 🧪 Testing
runs-on: ubuntu-latest
needs: quality
if: inputs.skip_tests != 'true'
services:
postgres:
image: postgres:15-alpine
env:
POSTGRES_PASSWORD: testpassword
POSTGRES_USER: testuser
POSTGRES_DB: testdb
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
redis:
image: redis:7-alpine
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 6379:6379
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
- name: Install dependencies
run: |
npm ci
cd frontend && npm ci --legacy-peer-deps
cd ../backend && npm ci
- name: Setup test database
env:
DATABASE_URL: postgresql://testuser:testpassword@localhost:5432/testdb
run: |
cd backend
npx prisma migrate dev --name test
npx prisma generate
- name: Run backend tests
env:
DATABASE_URL: postgresql://testuser:testpassword@localhost:5432/testdb
JWT_SECRET: test-secret-key
REDIS_URL: redis://localhost:6379
run: |
cd backend
node ../test-auth.js
- name: Install Playwright
run: npx playwright install --with-deps chromium
- name: Run Playwright tests
run: npm run test
env:
CI: true
- name: Upload test results
uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-report
path: playwright-report/
retention-days: 7
# Job 3: Build & Deploy
deploy:
name: 🚀 Deploy to Production
runs-on: ubuntu-latest
needs: [quality, test]
if: always() && (needs.quality.result == 'success' && (needs.test.result == 'success' || inputs.skip_tests == 'true'))
environment: production
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Create environment file
run: |
cat > .env.production << EOF
NODE_ENV=production
PORT=5001
DATABASE_URL=postgresql://formbuilder:${{ secrets.DB_PASSWORD }}@postgres:5432/formbuilder
DB_HOST=postgres
DB_PORT=5432
DB_DATABASE=formbuilder
DB_USER=formbuilder
DB_PASSWORD=${{ secrets.DB_PASSWORD }}
REDIS_URL=redis://redis:6379
JWT_SECRET=${{ secrets.JWT_SECRET }}
OPENAI_API_KEY=${{ secrets.OPENAI_API_KEY }}
NEXT_PUBLIC_API_URL=${{ secrets.NEXT_PUBLIC_API_URL }}
NEXT_PUBLIC_BRAND_PRESET=generic
NEXT_TELEMETRY_DISABLED=1
EOF
- name: Build Docker images
run: |
docker-compose -f docker-compose.prod.yml build --no-cache
- name: Deploy application
run: |
# Set environment variables
export DB_PASSWORD="${{ secrets.DB_PASSWORD }}"
export JWT_SECRET="${{ secrets.JWT_SECRET }}"
export OPENAI_API_KEY="${{ secrets.OPENAI_API_KEY }}"
export NEXT_PUBLIC_API_URL="${{ secrets.NEXT_PUBLIC_API_URL }}"
# Run deployment script
./scripts/deploy.sh
- name: Health check
run: |
timeout 300 bash -c 'while ! curl -f http://localhost:5001/health; do sleep 5; done'
curl -f http://localhost:3000 > /dev/null
- name: Notify deployment status
if: always()
run: |
if [ "${{ job.status }}" = "success" ]; then
echo "✅ Deployment successful!"
echo "🌐 Application: http://localhost:3000"
echo "⚙️ API: http://localhost:5001"
else
echo "❌ Deployment failed!"
fi
# Job 4: Post-deployment tests
smoke-tests:
name: 🚨 Smoke Tests
runs-on: ubuntu-latest
needs: deploy
if: always() && needs.deploy.result == 'success'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Run smoke tests
run: |
# Test critical endpoints
curl -f http://localhost:5001/health
curl -f http://localhost:3000
# Test authentication
response=$(curl -s -X POST http://localhost:5001/api/v1/auth/register \
-H "Content-Type: application/json" \
-d '{"email":"smoke-test@example.com","password":"testpass123","name":"Smoke Test"}')
if echo "$response" | grep -q "success"; then
echo "✅ Authentication system working"
else
echo "❌ Authentication system failed"
exit 1
fi
- name: Performance check
run: |
# Basic performance check
response_time=$(curl -o /dev/null -s -w '%{time_total}' http://localhost:3000)
if (( $(echo "$response_time < 3.0" | bc -l) )); then
echo "✅ Performance check passed: ${response_time}s"
else
echo "⚠️ Performance warning: ${response_time}s (>3s)"
fi