bun-ui-tests 1.0.3 → 1.0.4
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/cli.ts +9 -4
- package/package.json +1 -1
- package/ui-runner.ts +11 -21
package/cli.ts
CHANGED
|
@@ -60,11 +60,16 @@ async function buildFrontend() {
|
|
|
60
60
|
|
|
61
61
|
async function checkBuildExists(): Promise<boolean> {
|
|
62
62
|
const distPath = join(__dirname, "app", "dist", "index.html");
|
|
63
|
+
console.error(`Debug: __dirname is ${__dirname}`);
|
|
64
|
+
console.error(`Debug: import.meta.url is ${import.meta.url}`);
|
|
63
65
|
try {
|
|
64
|
-
await
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
const exists = await Bun.file(distPath).exists();
|
|
67
|
+
if (!exists) {
|
|
68
|
+
console.error(`Debug: Bun.file.exists failed for: ${distPath}`);
|
|
69
|
+
}
|
|
70
|
+
return exists;
|
|
71
|
+
} catch (err) {
|
|
72
|
+
console.error(`Debug: Error checking path ${distPath}:`, err);
|
|
68
73
|
return false;
|
|
69
74
|
}
|
|
70
75
|
}
|
package/package.json
CHANGED
package/ui-runner.ts
CHANGED
|
@@ -14,7 +14,6 @@
|
|
|
14
14
|
import { spawn } from "node:child_process";
|
|
15
15
|
import { readdir, readFile, stat } from "node:fs/promises";
|
|
16
16
|
import { join, relative, dirname } from "node:path";
|
|
17
|
-
import { existsSync } from "node:fs";
|
|
18
17
|
|
|
19
18
|
// Determina o diretório do executável ou script
|
|
20
19
|
const getBaseDir = () => {
|
|
@@ -128,29 +127,20 @@ if (isDevMode) {
|
|
|
128
127
|
}
|
|
129
128
|
|
|
130
129
|
// 2. Arquivos Estáticos (Frontend)
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
// Se não encontrou o arquivo e não é um asset (SPA fallback)
|
|
142
|
-
if (!filePath.includes(".")) {
|
|
143
|
-
const indexFile = Bun.file(join(distPath, "index.html"));
|
|
144
|
-
return new Response(indexFile);
|
|
145
|
-
}
|
|
146
|
-
} catch (err) {
|
|
147
|
-
console.error("Error serving file:", err);
|
|
130
|
+
const file = Bun.file(join(distPath, url.pathname === "/" ? "/index.html" : url.pathname));
|
|
131
|
+
if (await file.exists()) {
|
|
132
|
+
return new Response(file);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// SPA fallback
|
|
136
|
+
if (!url.pathname.includes(".")) {
|
|
137
|
+
const indexFile = Bun.file(join(distPath, "index.html"));
|
|
138
|
+
if (await indexFile.exists()) {
|
|
139
|
+
return new Response(indexFile);
|
|
148
140
|
}
|
|
149
|
-
} else {
|
|
150
|
-
return new Response("Frontend build not found. Run 'buntestui build' first.", { status: 404 });
|
|
151
141
|
}
|
|
152
142
|
|
|
153
|
-
return new Response("
|
|
143
|
+
return new Response("Frontend build not found.", { status: 404 });
|
|
154
144
|
},
|
|
155
145
|
websocket: websocketHandler
|
|
156
146
|
});
|