mirror of
https://github.com/phranck/TUIkit.git
synced 2026-05-21 09:50:35 +00:00
982c369853
- Migrate landing page and dashboard from Next.js 16 to Astro 5 - Remove Framer Motion dependency (saves ~122KB gzipped) - Lazy-load Howler.js audio (only on power button click) - Disable expensive CSS effects on mobile (<768px): - backdrop-blur replaced with solid backgrounds - Cloud animations simplified (no blur, static) - Rain canvas and SpinnerLights skip on mobile - Avatar filters reduced to grayscale+brightness - Optimize hydration: client:idle for decorative components - Combine Google Fonts requests (2 -> 1) - Remove audio preloading (lazy-loaded instead) - Fix process.env -> import.meta.env for Astro compatibility - Update Languages icon from Swift logo to code brackets
60 lines
1.9 KiB
TypeScript
60 lines
1.9 KiB
TypeScript
/**
|
|
* Prebuild script: runs before `astro build` via the `prebuild` npm script.
|
|
*
|
|
* 1. Generates terminal-data.ts from terminal-script.md
|
|
* 2. Counts Swift @Test and @Suite annotations to produce project-stats.json
|
|
* (consumed by astro.config.mjs as environment variables)
|
|
*/
|
|
|
|
import { parseTerminalScript } from "../src/lib/terminal-parser";
|
|
import { execSync } from "child_process";
|
|
import fs from "fs";
|
|
import path from "path";
|
|
|
|
// Terminal Data
|
|
|
|
const script = parseTerminalScript();
|
|
const terminalOutputPath = path.join(process.cwd(), "src", "components", "react", "terminal-data.ts");
|
|
|
|
const tsContent = `/**
|
|
* Auto-generated from terminal-script.md
|
|
* DO NOT EDIT THIS FILE DIRECTLY - Edit terminal-script.md instead
|
|
*/
|
|
|
|
import type { TerminalScript } from "../../lib/terminal-parser";
|
|
|
|
export const TERMINAL_SCRIPT: TerminalScript = ${JSON.stringify(script, null, 2)};
|
|
`;
|
|
|
|
fs.writeFileSync(terminalOutputPath, tsContent);
|
|
console.log("✓ Generated terminal-data.ts from terminal-script.md");
|
|
|
|
// Project Stats
|
|
|
|
const projectRoot = path.resolve(process.cwd(), "..");
|
|
const testsDir = path.join(projectRoot, "Tests");
|
|
|
|
/**
|
|
* Count occurrences of a pattern in all .swift files under a directory.
|
|
* Falls back to 0 if the directory doesn't exist (e.g. CI without Swift source).
|
|
*/
|
|
function countPattern(directory: string, pattern: string): number {
|
|
if (!fs.existsSync(directory)) return 0;
|
|
try {
|
|
const output = execSync(
|
|
`grep -r '${pattern}' --include='*.swift' "${directory}" | wc -l`,
|
|
{ encoding: "utf-8" }
|
|
);
|
|
return parseInt(output.trim(), 10) || 0;
|
|
} catch {
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
const testCount = countPattern(testsDir, "@Test\\b");
|
|
const suiteCount = countPattern(testsDir, "@Suite\\b");
|
|
|
|
const statsPath = path.join(process.cwd(), "project-stats.json");
|
|
fs.writeFileSync(statsPath, JSON.stringify({ testCount, suiteCount }, null, 2));
|
|
console.log(`✓ Generated project-stats.json (${testCount} tests, ${suiteCount} suites)`);
|