e22d123009
- Converted readdirSync, readFileSync, and statSync to async readdir, readFile, stat across skills and agent discovery. - Made scanDirectoryForSkills async and refactored custom directory scanning to use Promise.all for concurrent processing. - Updated agent discovery to use fs/promises for async file reading and refactored helper patterns. - Added AgentParsingError exception class for better error handling during agent parsing. - Added filesystem error type guards (isEnoent, isEacces, isPerm, etc.) to pi-utils for safe error checking. - Added color manipulation utilities to pi-utils for accessibility features. - Added color-blind mode setting to settings manager. - Migrated plugins, settings, and config modules from sync to async file operations. - Updated error handling to use new pi-utils type guards for type-safe checking.
65 lines
1.8 KiB
TypeScript
65 lines
1.8 KiB
TypeScript
import * as fs from "node:fs/promises";
|
|
|
|
// Clean dist
|
|
await fs.rm("./dist/client", { recursive: true, force: true });
|
|
|
|
// Build React app
|
|
const result = await Bun.build({
|
|
entrypoints: ["./src/client/index.tsx"],
|
|
outdir: "./dist/client",
|
|
minify: true,
|
|
naming: "[dir]/[name].[ext]",
|
|
});
|
|
|
|
if (!result.success) {
|
|
console.error("Build failed");
|
|
for (const message of result.logs) {
|
|
console.error(message);
|
|
}
|
|
process.exit(1);
|
|
}
|
|
|
|
// Create index.html
|
|
const indexHtml = `<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>AI Usage Statistics</title>
|
|
<style>
|
|
:root {
|
|
--bg-primary: #1a1a2e;
|
|
--bg-secondary: #16213e;
|
|
--bg-card: #0f3460;
|
|
--text-primary: #eee;
|
|
--text-secondary: #aaa;
|
|
--accent: #e94560;
|
|
--success: #4ade80;
|
|
--error: #f87171;
|
|
--border: #1f2937;
|
|
}
|
|
body {
|
|
margin: 0;
|
|
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
|
|
background: var(--bg-primary);
|
|
color: var(--text-primary);
|
|
}
|
|
* { box-sizing: border-box; }
|
|
::-webkit-scrollbar { width: 8px; height: 8px; }
|
|
::-webkit-scrollbar-track { background: var(--bg-primary); }
|
|
::-webkit-scrollbar-thumb { background: var(--bg-card); border-radius: 4px; }
|
|
::-webkit-scrollbar-thumb:hover { background: var(--accent); }
|
|
.spin { animation: spin 1s linear infinite; }
|
|
@keyframes spin { 100% { transform: rotate(360deg); } }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div id="root"></div>
|
|
<script src="index.js" type="module"></script>
|
|
</body>
|
|
</html>`;
|
|
|
|
await Bun.write("./dist/client/index.html", indexHtml);
|
|
|
|
console.log("Build complete");
|