230927a80e
this fix the nextcloud login + drive selector (chroot)
fix also invitation / magic link
also correct the UX: once user has logged in nextcloud, show an explicita page
59 lines
2.6 KiB
JavaScript
59 lines
2.6 KiB
JavaScript
#!/usr/bin/env node
|
|
/*
|
|
* Emit `static-dist/askama-common.css` from the SvelteKit design-token
|
|
* source of truth (`src/lib/styles/base/variables.css`) plus the auth-page
|
|
* component styles (`src/lib/styles/askama-common.css`).
|
|
*
|
|
* WHY A POST-BUILD SCRIPT:
|
|
* Vite's `writeBundle` hooks fire mid-build, before
|
|
* `@sveltejs/adapter-static` copies the finalised site to
|
|
* `../static-dist/`. Anything written to that directory during
|
|
* Vite gets wiped when adapter-static runs. A `postbuild` script
|
|
* runs after everything the SvelteKit build owns, so its output
|
|
* survives — one predictable moment, no ordering trap.
|
|
*
|
|
* WHAT IT PRODUCES:
|
|
* A single stable-named CSS file at `static-dist/askama-common.css`
|
|
* containing:
|
|
* 1. Every design token declared in `base/variables.css` (:root,
|
|
* `light-dark(...)`, dark-mode blocks, etc.)
|
|
* 2. The auth-page component rules from `askama-common.css`
|
|
* Concatenated, prefixed with a "do not edit" header, written UTF-8.
|
|
*
|
|
* SINGLE SOURCE OF TRUTH:
|
|
* If a token changes in `variables.css`, one rebuild propagates it to
|
|
* both the SPA (via Svelte's normal build pipeline) AND the askama
|
|
* templates (via this file). Two consumers, one source. No manual
|
|
* sync step.
|
|
*
|
|
* SERVER SIDE:
|
|
* Server-rendered askama templates reference:
|
|
* <link rel="stylesheet" href="/askama-common.css">
|
|
* The Rust web layer serves `static-dist/askama-common.css` at that
|
|
* URL through the same ServeDir the SPA uses. No route wiring needed.
|
|
*/
|
|
|
|
import { readFileSync, writeFileSync, mkdirSync } from 'node:fs';
|
|
import { dirname, resolve } from 'node:path';
|
|
import { fileURLToPath } from 'node:url';
|
|
|
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
const stylesDir = resolve(__dirname, '../src/lib/styles');
|
|
const outputFile = resolve(__dirname, '../../static-dist/askama-common.css');
|
|
|
|
const header =
|
|
'/* Auto-generated by frontend/scripts/emit-askama-common.mjs.\n' +
|
|
' * Do NOT edit by hand — regenerated on every `npm run build`.\n' +
|
|
' * Sources: src/lib/styles/base/variables.css (design tokens)\n' +
|
|
' * src/lib/styles/askama-common.css (auth components)\n' +
|
|
' */\n\n';
|
|
|
|
const tokens = readFileSync(resolve(stylesDir, 'base/variables.css'), 'utf8');
|
|
const components = readFileSync(resolve(stylesDir, 'askama-common.css'), 'utf8');
|
|
|
|
mkdirSync(dirname(outputFile), { recursive: true });
|
|
writeFileSync(outputFile, header + tokens + '\n' + components, 'utf8');
|
|
|
|
const bytes = Buffer.byteLength(header + tokens + '\n' + components, 'utf8');
|
|
console.log(`emit-askama-common: wrote ${bytes} bytes → ${outputFile}`);
|