Files
Oxicloud/scripts/gen-token-docs.mjs
T
DioCrafts 54639d466a chore(frontend): remove the legacy vanilla-JS frontend and its tooling
The SvelteKit app under /frontend has fully superseded the legacy
vanilla-JS/CSS frontend in /static, which was only ever served by a
debug `cargo run` / `PROFILE=dev` and never shipped to production.
Remove it together with the whole subsystem that existed only to
support it (~54k lines).

Frontend & assets:
- Delete /static (js/, css/, *.html, sw.js, basemaps/, locales symlink).
- Relocate the brand/PWA assets (logo/, favicon.ico, manifest.webmanifest)
  to frontend/static/ so they ship with the SPA. This also fixes the
  favicon, which app.html referenced but was missing from the prod bundle.
- Migrate the Nextcloud login-flow redirects from /nextcloud-error.html
  to the SvelteKit /nextcloud/error route.

Web layer:
- Simplify resolve_static_path: drop the PROFILE=dev branch; always prefer
  the Vite static-dist/ build, fall back to the configured path.
- Resolve i18n locales from the served SPA dir with a frontend/static
  fallback so `just dev` works without a prior build.

Build:
- Prune build.rs from 1262 to ~70 lines (git metadata only); the Rust asset
  pipeline and the OXICLOUD_RUST_ASSETS rollback flag are gone.
- Drop the now-unused build-dependencies (oxc_*, lightningcss).
- Remove the COPY static lines from the Dockerfile (cacher + builder).

Tooling & docs:
- Delete biome.json, jsconfig.json, tools/check-*.py, identifier.sh.
- Remove the legacy front-* justfile recipes; repoint the design-system
  scripts (locales, dead-tokens, brand-drift, token-docs) at the frontend,
  and drop check-contrast/check-headings (coupled to the old token
  taxonomy / multi-page HTML).
- Repoint docs/DESIGN-SYSTEM.md links; remove 5 superseded docs/plan/*.

Backend dead code:
- Remove the dead `folder_repo` field from FileBlobWriteRepository.
- Remove the deprecated GET /api/folders/{id}/listing endpoint
  (superseded by /resources).

Verified: cargo clippy (all-features/all-targets) clean, cargo test
--workspace 448 passed, cargo fmt clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-21 03:20:10 +02:00

66 lines
2.6 KiB
JavaScript

#!/usr/bin/env node
// Generates docs/TOKENS.md — a grouped reference of every design token defined
// in frontend/src/lib/styles/base/variables.css. Run after changing tokens:
// node scripts/gen-token-docs.mjs
import { readFileSync, writeFileSync } from 'node:fs';
import { join, dirname } from 'node:path';
import { fileURLToPath } from 'node:url';
const repo = join(dirname(fileURLToPath(import.meta.url)), '..');
const src = readFileSync(
join(repo, 'frontend', 'src', 'lib', 'styles', 'base', 'variables.css'),
'utf8'
);
const tokens = [];
for (const m of src.matchAll(/^\s*(--[a-z0-9-]+)\s*:\s*([^;]+);/gim)) {
if (!tokens.some((t) => t[0] === m[1])) tokens.push([m[1], m[2].trim().replace(/\s+/g, ' ')]);
}
const CATEGORIES = [
['Spacing (4px grid)', /^--space-/],
['Radius', /^--radius/],
['Typography', /^--(text-|leading-|weight-|tracking-|font-|measure-|icon-)/],
['Z-index layers', /^--z-/],
['Motion (durations + easing)', /^--(motion-|ease-|spin-)/],
['Elevation (composed shadows)', /^--shadow-/],
['Breakpoints (reference)', /^--bp-/],
['Density', /^--density-/],
['Layout shell', /^--(sidebar-width|gutter|grid-card)/],
['Color — text', /^--color-text/],
['Color — background', /^--color-bg/],
['Color — border', /^--color-border/],
['Color — accent / brand', /^--color-(accent|logo|focus|on-accent|primary)/],
['Color — semantic (success/warn/danger/info)', /^--color-(success|error|danger|warning|info)/],
['Color — shadow alphas / overlays', /^--color-(shadow|overlay|on-overlay)/],
['Color — sidebar', /^--color-sidebar/],
['Color — file types', /^--color-ft/],
['Color — calendar dots', /^--color-cal/],
['Color — badges', /^--color-badge/],
['Color — other', /^--color-/],
['Other', /.*/]
];
const buckets = new Map(CATEGORIES.map(([name]) => [name, []]));
for (const [name, value] of tokens) {
const cat = CATEGORIES.find(([, re]) => re.test(name))[0];
buckets.get(cat).push([name, value]);
}
let md = `# Design tokens
> Auto-generated from \`frontend/src/lib/styles/base/variables.css\` by \`scripts/gen-token-docs.mjs\`.
> Do not edit by hand — re-run the generator after changing tokens.
**${tokens.length} tokens** across ${[...buckets].filter(([, v]) => v.length).length} groups.
\n`;
for (const [name, rows] of buckets) {
if (!rows.length) continue;
md += `\n## ${name}\n\n| Token | Value |\n| --- | --- |\n`;
for (const [tok, val] of rows) md += `| \`${tok}\` | \`${val.replace(/\|/g, '\\|')}\` |\n`;
}
writeFileSync(join(repo, 'docs', 'TOKENS.md'), md);
console.log(`✓ Wrote docs/TOKENS.md (${tokens.length} tokens).`);