60e5ef6844
All-in-One docker-compose-Stack (Muster von RAPPORT-SERVER gespiegelt): db/auth/rest/kong + cms-Service (Node-API + Hugo-Binary 0.161.1 + Admin-SPA). - DB-backed: posts-Tabelle kanonisch, MD ist generiertes Artefakt - echte Hugo-Vorschau via draft:true + --buildDrafts → /_preview - Publish: DB → content/library/<section>/<slug>.md → hugo build → live - Bild-Upload nach static/images/, Supabase-Auth schützt /api/* - Proxmox-LXC-Script: legt Container an, generiert Secrets, startet Stack Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
42 lines
1.6 KiB
JavaScript
42 lines
1.6 KiB
JavaScript
import { execFile } from 'node:child_process';
|
|
import { promisify } from 'node:util';
|
|
|
|
const execFileP = promisify(execFile);
|
|
const SITE_DIR = process.env.SITE_DIR || '/site';
|
|
|
|
// Baut die Site. dest ist relativ zum Repo-Root (z.B. "public" oder "preview").
|
|
// drafts:true => --buildDrafts (für die Vorschau).
|
|
export async function hugoBuild({ dest, drafts = false } = {}) {
|
|
const args = ['--source', SITE_DIR, '--destination', dest, '--cleanDestinationDir'];
|
|
if (drafts) args.push('--buildDrafts');
|
|
const { stdout, stderr } = await execFileP('hugo', args, {
|
|
cwd: SITE_DIR,
|
|
maxBuffer: 10 * 1024 * 1024,
|
|
});
|
|
return { stdout, stderr };
|
|
}
|
|
|
|
// Optionaler Git-Backup beim Publish (GIT_PUBLISH=true). Schlägt nie hart fehl —
|
|
// das Publish soll an einem Git-Problem nicht scheitern.
|
|
export async function gitCommit(message) {
|
|
if (process.env.GIT_PUBLISH !== 'true') return { skipped: true };
|
|
|
|
const env = {
|
|
...process.env,
|
|
GIT_AUTHOR_NAME: process.env.GIT_AUTHOR_NAME || 'OPENBUREAU CMS',
|
|
GIT_AUTHOR_EMAIL: process.env.GIT_AUTHOR_EMAIL || 'cms@openbureau.ch',
|
|
GIT_COMMITTER_NAME: process.env.GIT_AUTHOR_NAME || 'OPENBUREAU CMS',
|
|
GIT_COMMITTER_EMAIL: process.env.GIT_AUTHOR_EMAIL || 'cms@openbureau.ch',
|
|
};
|
|
const git = (...args) => execFileP('git', ['-C', SITE_DIR, ...args], { env });
|
|
|
|
await git('add', 'content');
|
|
// Nichts zu committen? Dann ruhig raus.
|
|
const status = await git('status', '--porcelain', 'content');
|
|
if (!status.stdout.trim()) return { nothing: true };
|
|
|
|
await git('commit', '-m', message);
|
|
await git('push', process.env.GIT_REMOTE || 'origin', process.env.GIT_BRANCH || 'main');
|
|
return { committed: true };
|
|
}
|