bun-ui-tests 1.0.4 → 1.0.5
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 +19 -4
- package/package.json +1 -1
- package/ui-runner.ts +10 -0
package/cli.ts
CHANGED
|
@@ -2,10 +2,25 @@
|
|
|
2
2
|
|
|
3
3
|
import { spawn } from "node:child_process";
|
|
4
4
|
import { readFile, access } from "node:fs/promises";
|
|
5
|
-
import { join, dirname } from "node:path";
|
|
5
|
+
import { join, dirname, resolve } from "node:path";
|
|
6
6
|
import { fileURLToPath } from "node:url";
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
// Robustly determine the package root directory
|
|
9
|
+
function getPackageRoot() {
|
|
10
|
+
// 1. Try to use process.argv[1] which often points to the real script path
|
|
11
|
+
// when run via bunx or direct execution.
|
|
12
|
+
try {
|
|
13
|
+
const argvPath = process.argv[1];
|
|
14
|
+
if (argvPath && argvPath.endsWith("cli.ts")) {
|
|
15
|
+
return dirname(argvPath);
|
|
16
|
+
}
|
|
17
|
+
} catch (e) {}
|
|
18
|
+
|
|
19
|
+
// 2. Fallback to import.meta.dir
|
|
20
|
+
return import.meta.dir;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const __dirname = getPackageRoot();
|
|
9
24
|
|
|
10
25
|
const COMMANDS = {
|
|
11
26
|
run: "Run the test UI (production mode)",
|
|
@@ -60,8 +75,8 @@ async function buildFrontend() {
|
|
|
60
75
|
|
|
61
76
|
async function checkBuildExists(): Promise<boolean> {
|
|
62
77
|
const distPath = join(__dirname, "app", "dist", "index.html");
|
|
63
|
-
console.error(`Debug:
|
|
64
|
-
console.error(`Debug:
|
|
78
|
+
console.error(`Debug: process.argv[1] is ${process.argv[1]}`);
|
|
79
|
+
console.error(`Debug: Resolved __dirname is ${__dirname}`);
|
|
65
80
|
try {
|
|
66
81
|
const exists = await Bun.file(distPath).exists();
|
|
67
82
|
if (!exists) {
|
package/package.json
CHANGED
package/ui-runner.ts
CHANGED
|
@@ -21,12 +21,22 @@ const getBaseDir = () => {
|
|
|
21
21
|
if (import.meta.path && !import.meta.path.endsWith('.ts')) {
|
|
22
22
|
return dirname(process.execPath);
|
|
23
23
|
}
|
|
24
|
+
|
|
25
|
+
// Try process.argv[1] to find real path
|
|
26
|
+
try {
|
|
27
|
+
const argvPath = process.argv[1];
|
|
28
|
+
if (argvPath && argvPath.endsWith("ui-runner.ts")) {
|
|
29
|
+
return dirname(argvPath);
|
|
30
|
+
}
|
|
31
|
+
} catch (e) {}
|
|
32
|
+
|
|
24
33
|
// Se rodando como script .ts, usa o dir do próprio arquivo
|
|
25
34
|
return import.meta.dir;
|
|
26
35
|
};
|
|
27
36
|
|
|
28
37
|
const baseDir = getBaseDir();
|
|
29
38
|
const distPath = join(baseDir, "app", "dist");
|
|
39
|
+
console.log(`Debug: ui-runner argv[1] is ${process.argv[1]}`);
|
|
30
40
|
console.log(`Debug: distPath is ${distPath}`);
|
|
31
41
|
const isDevMode = process.env.BUN_TEST_UI_DEV === "true";
|
|
32
42
|
|