@oh-my-pi/omp-stats 12.14.0 → 12.14.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build.ts +84 -0
- package/package.json +5 -3
- package/tailwind.config.js +40 -0
package/build.ts
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import * as fs from "node:fs/promises";
|
|
2
|
+
import * as path from "node:path";
|
|
3
|
+
import { compile } from "@tailwindcss/node";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Extract Tailwind class names from source files by scanning for className attributes.
|
|
7
|
+
*/
|
|
8
|
+
async function extractTailwindClasses(dir: string): Promise<Set<string>> {
|
|
9
|
+
const classes = new Set<string>();
|
|
10
|
+
const classPattern = /className\s*=\s*["'`]([^"'`]+)["'`]/g;
|
|
11
|
+
|
|
12
|
+
async function scanDir(currentDir: string): Promise<void> {
|
|
13
|
+
const entries = await fs.readdir(currentDir, { withFileTypes: true });
|
|
14
|
+
for (const entry of entries) {
|
|
15
|
+
const fullPath = path.join(currentDir, entry.name);
|
|
16
|
+
if (entry.isDirectory()) {
|
|
17
|
+
await scanDir(fullPath);
|
|
18
|
+
} else if (entry.isFile() && /\.(tsx|ts|jsx|js)$/.test(entry.name)) {
|
|
19
|
+
const content = await Bun.file(fullPath).text();
|
|
20
|
+
const matches = content.matchAll(classPattern);
|
|
21
|
+
for (const match of matches) {
|
|
22
|
+
for (const cls of match[1].split(/\s+/)) {
|
|
23
|
+
if (cls) classes.add(cls);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
await scanDir(dir);
|
|
31
|
+
return classes;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Clean dist
|
|
35
|
+
await fs.rm("./dist/client", { recursive: true, force: true });
|
|
36
|
+
|
|
37
|
+
// Build Tailwind CSS
|
|
38
|
+
console.log("Building Tailwind CSS...");
|
|
39
|
+
const sourceCss = await Bun.file("./src/client/styles.css").text();
|
|
40
|
+
const candidates = await extractTailwindClasses("./src/client");
|
|
41
|
+
const baseDir = path.resolve("./src/client");
|
|
42
|
+
|
|
43
|
+
const compiler = await compile(sourceCss, {
|
|
44
|
+
base: baseDir,
|
|
45
|
+
onDependency: () => {},
|
|
46
|
+
});
|
|
47
|
+
const tailwindOutput = compiler.build([...candidates]);
|
|
48
|
+
await Bun.write("./dist/client/styles.css", tailwindOutput);
|
|
49
|
+
|
|
50
|
+
// Build React app
|
|
51
|
+
console.log("Building React app...");
|
|
52
|
+
const result = await Bun.build({
|
|
53
|
+
entrypoints: ["./src/client/index.tsx"],
|
|
54
|
+
outdir: "./dist/client",
|
|
55
|
+
minify: true,
|
|
56
|
+
naming: "[dir]/[name].[ext]",
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
if (!result.success) {
|
|
60
|
+
console.error("Build failed");
|
|
61
|
+
for (const message of result.logs) {
|
|
62
|
+
console.error(message);
|
|
63
|
+
}
|
|
64
|
+
process.exit(1);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// Create index.html
|
|
68
|
+
const indexHtml = `<!DOCTYPE html>
|
|
69
|
+
<html lang="en">
|
|
70
|
+
<head>
|
|
71
|
+
<meta charset="UTF-8">
|
|
72
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
73
|
+
<title>AI Usage Statistics</title>
|
|
74
|
+
<link rel="stylesheet" href="styles.css">
|
|
75
|
+
</head>
|
|
76
|
+
<body>
|
|
77
|
+
<div id="root"></div>
|
|
78
|
+
<script src="index.js" type="module"></script>
|
|
79
|
+
</body>
|
|
80
|
+
</html>`;
|
|
81
|
+
|
|
82
|
+
await Bun.write("./dist/client/index.html", indexHtml);
|
|
83
|
+
|
|
84
|
+
console.log("Build complete");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oh-my-pi/omp-stats",
|
|
3
|
-
"version": "12.14.
|
|
3
|
+
"version": "12.14.2",
|
|
4
4
|
"description": "Local observability dashboard for pi AI usage statistics",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.ts",
|
|
@@ -25,6 +25,8 @@
|
|
|
25
25
|
"files": [
|
|
26
26
|
"src",
|
|
27
27
|
"public",
|
|
28
|
+
"build.ts",
|
|
29
|
+
"tailwind.config.js",
|
|
28
30
|
"README.md"
|
|
29
31
|
],
|
|
30
32
|
"keywords": [
|
|
@@ -52,8 +54,8 @@
|
|
|
52
54
|
"url": "https://github.com/can1357/oh-my-pi/issues"
|
|
53
55
|
},
|
|
54
56
|
"dependencies": {
|
|
55
|
-
"@oh-my-pi/pi-ai": "12.14.
|
|
56
|
-
"@oh-my-pi/pi-utils": "12.14.
|
|
57
|
+
"@oh-my-pi/pi-ai": "12.14.2",
|
|
58
|
+
"@oh-my-pi/pi-utils": "12.14.2",
|
|
57
59
|
"@tailwindcss/node": "4",
|
|
58
60
|
"chart.js": "4.5.1",
|
|
59
61
|
"date-fns": "^4.1.0",
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/** @type {import('tailwindcss').Config} */
|
|
2
|
+
import * as path from "node:path";
|
|
3
|
+
export default {
|
|
4
|
+
content: [path.join(import.meta.dir, "src", "client", "**/*.{js,jsx,ts,tsx}")],
|
|
5
|
+
darkMode: "class",
|
|
6
|
+
theme: {
|
|
7
|
+
extend: {
|
|
8
|
+
colors: {
|
|
9
|
+
page: "var(--bg-page)",
|
|
10
|
+
surface: "var(--bg-surface)",
|
|
11
|
+
elevated: "var(--bg-elevated)",
|
|
12
|
+
"border-subtle": "var(--border-subtle)",
|
|
13
|
+
"border-default": "var(--border-default)",
|
|
14
|
+
"text-primary": "var(--text-primary)",
|
|
15
|
+
"text-secondary": "var(--text-secondary)",
|
|
16
|
+
"text-muted": "var(--text-muted)",
|
|
17
|
+
pink: "var(--accent-pink)",
|
|
18
|
+
cyan: "var(--accent-cyan)",
|
|
19
|
+
violet: "var(--accent-violet)",
|
|
20
|
+
},
|
|
21
|
+
fontFamily: {
|
|
22
|
+
sans: [
|
|
23
|
+
"-apple-system",
|
|
24
|
+
"BlinkMacSystemFont",
|
|
25
|
+
'"Segoe UI"',
|
|
26
|
+
"Roboto",
|
|
27
|
+
"Helvetica",
|
|
28
|
+
"Arial",
|
|
29
|
+
"sans-serif",
|
|
30
|
+
],
|
|
31
|
+
},
|
|
32
|
+
borderRadius: {
|
|
33
|
+
sm: "var(--radius-sm)",
|
|
34
|
+
md: "var(--radius-md)",
|
|
35
|
+
lg: "var(--radius-lg)",
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
plugins: [],
|
|
40
|
+
};
|