mirror of
https://github.com/Xevion/xevion.dev.git
synced 2026-01-31 10:26:52 -06:00
feat: parallelize check tasks with real-time progress output
This commit is contained in:
@@ -3,12 +3,67 @@ set dotenv-load
|
|||||||
default:
|
default:
|
||||||
just --list
|
just --list
|
||||||
|
|
||||||
|
[script("bun")]
|
||||||
check:
|
check:
|
||||||
bun run --cwd web format
|
const checks = [
|
||||||
bun run --cwd web lint
|
{ name: "prettier", cmd: ["bun", "run", "--cwd", "web", "format:check"] },
|
||||||
bun run --cwd web check
|
{ name: "eslint", cmd: ["bun", "run", "--cwd", "web", "lint"] },
|
||||||
cargo clippy --all-targets
|
{ name: "svelte-check", cmd: ["bun", "run", "--cwd", "web", "check"] },
|
||||||
cargo fmt --check
|
{ name: "clippy", cmd: ["cargo", "clippy", "--all-targets"] },
|
||||||
|
{ name: "rustfmt", cmd: ["cargo", "fmt", "--check"] },
|
||||||
|
];
|
||||||
|
|
||||||
|
const start = Date.now();
|
||||||
|
const remaining = new Set(checks.map(c => c.name));
|
||||||
|
const results = [];
|
||||||
|
|
||||||
|
// Spawn all checks in parallel
|
||||||
|
const promises = checks.map(async (check) => {
|
||||||
|
const proc = Bun.spawn(check.cmd, {
|
||||||
|
env: { ...process.env, FORCE_COLOR: "1" },
|
||||||
|
stdout: "pipe",
|
||||||
|
stderr: "pipe",
|
||||||
|
});
|
||||||
|
|
||||||
|
const [stdout, stderr] = await Promise.all([
|
||||||
|
new Response(proc.stdout).text(),
|
||||||
|
new Response(proc.stderr).text(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
await proc.exited;
|
||||||
|
const elapsed = ((Date.now() - start) / 1000).toFixed(1);
|
||||||
|
|
||||||
|
return { ...check, stdout, stderr, exitCode: proc.exitCode, elapsed };
|
||||||
|
});
|
||||||
|
|
||||||
|
// Progress updater
|
||||||
|
const interval = setInterval(() => {
|
||||||
|
const elapsed = ((Date.now() - start) / 1000).toFixed(1);
|
||||||
|
const tasks = Array.from(remaining).join(", ");
|
||||||
|
process.stderr.write(`\r\x1b[K${elapsed}s [${tasks}]`);
|
||||||
|
}, 100);
|
||||||
|
|
||||||
|
// Stream outputs as they complete
|
||||||
|
let anyFailed = false;
|
||||||
|
for (const promise of promises) {
|
||||||
|
const result = await promise;
|
||||||
|
remaining.delete(result.name);
|
||||||
|
|
||||||
|
if (result.exitCode !== 0) {
|
||||||
|
anyFailed = true;
|
||||||
|
process.stderr.write(`\r\x1b[K`);
|
||||||
|
process.stdout.write(`❌ ${result.name} (${result.elapsed}s)\n`);
|
||||||
|
if (result.stdout) process.stdout.write(result.stdout);
|
||||||
|
if (result.stderr) process.stderr.write(result.stderr);
|
||||||
|
} else {
|
||||||
|
process.stderr.write(`\r\x1b[K`);
|
||||||
|
process.stdout.write(`✅ ${result.name} (${result.elapsed}s)\n`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
clearInterval(interval);
|
||||||
|
process.stderr.write(`\r\x1b[K`);
|
||||||
|
process.exit(anyFailed ? 1 : 0);
|
||||||
|
|
||||||
build:
|
build:
|
||||||
bun run --cwd web build
|
bun run --cwd web build
|
||||||
|
|||||||
+2
-1
@@ -12,7 +12,8 @@
|
|||||||
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
|
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
|
||||||
"clean": "rm -rf .svelte-kit build node_modules",
|
"clean": "rm -rf .svelte-kit build node_modules",
|
||||||
"lint": "eslint .",
|
"lint": "eslint .",
|
||||||
"format": "prettier --write ."
|
"format": "prettier --write .",
|
||||||
|
"format:check": "prettier --check ."
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@fontsource-variable/inter": "^5.2.8",
|
"@fontsource-variable/inter": "^5.2.8",
|
||||||
|
|||||||
Reference in New Issue
Block a user