fix(check): make browser smoke check cross-platform on windows
This commit is contained in:
@@ -16,7 +16,7 @@
|
|||||||
"dev": "concurrently --names \"ai,agent,coding-agent,mom,web-ui,tui\" --prefix-colors \"cyan,yellow,red,white,green,magenta\" \"cd packages/ai && npm run dev\" \"cd packages/agent && npm run dev\" \"cd packages/coding-agent && npm run dev\" \"cd packages/mom && npm run dev\" \"cd packages/web-ui && npm run dev\" \"cd packages/tui && npm run dev\"",
|
"dev": "concurrently --names \"ai,agent,coding-agent,mom,web-ui,tui\" --prefix-colors \"cyan,yellow,red,white,green,magenta\" \"cd packages/ai && npm run dev\" \"cd packages/agent && npm run dev\" \"cd packages/coding-agent && npm run dev\" \"cd packages/mom && npm run dev\" \"cd packages/web-ui && npm run dev\" \"cd packages/tui && npm run dev\"",
|
||||||
"dev:tsc": "concurrently --names \"ai,web-ui\" --prefix-colors \"cyan,green\" \"cd packages/ai && npm run dev:tsc\" \"cd packages/web-ui && npm run dev:tsc\"",
|
"dev:tsc": "concurrently --names \"ai,web-ui\" --prefix-colors \"cyan,green\" \"cd packages/ai && npm run dev:tsc\" \"cd packages/web-ui && npm run dev:tsc\"",
|
||||||
"check": "biome check --write --error-on-warnings . && tsgo --noEmit && npm run check:browser-smoke && cd packages/web-ui && npm run check",
|
"check": "biome check --write --error-on-warnings . && tsgo --noEmit && npm run check:browser-smoke && cd packages/web-ui && npm run check",
|
||||||
"check:browser-smoke": "sh -c 'esbuild scripts/browser-smoke-entry.ts --bundle --platform=browser --format=esm --log-limit=0 --outfile=/tmp/pi-browser-smoke.js > /tmp/pi-browser-smoke-errors.log 2>&1 || { echo \"Browser smoke check failed. See /tmp/pi-browser-smoke-errors.log\"; exit 1; }'",
|
"check:browser-smoke": "node scripts/check-browser-smoke.mjs",
|
||||||
"test": "npm run test --workspaces --if-present",
|
"test": "npm run test --workspaces --if-present",
|
||||||
"version:patch": "npm version patch -ws --no-git-tag-version && node scripts/sync-versions.js && shx rm -rf node_modules packages/*/node_modules package-lock.json && npm install",
|
"version:patch": "npm version patch -ws --no-git-tag-version && node scripts/sync-versions.js && shx rm -rf node_modules packages/*/node_modules package-lock.json && npm install",
|
||||||
"version:minor": "npm version minor -ws --no-git-tag-version && node scripts/sync-versions.js && shx rm -rf node_modules packages/*/node_modules package-lock.json && npm install",
|
"version:minor": "npm version minor -ws --no-git-tag-version && node scripts/sync-versions.js && shx rm -rf node_modules packages/*/node_modules package-lock.json && npm install",
|
||||||
|
|||||||
36
scripts/check-browser-smoke.mjs
Normal file
36
scripts/check-browser-smoke.mjs
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
import { writeFileSync } from "node:fs";
|
||||||
|
import { tmpdir } from "node:os";
|
||||||
|
import { join } from "node:path";
|
||||||
|
import { build } from "esbuild";
|
||||||
|
|
||||||
|
const outputPath = join(tmpdir(), "pi-browser-smoke.js");
|
||||||
|
const errorLogPath = join(tmpdir(), "pi-browser-smoke-errors.log");
|
||||||
|
|
||||||
|
try {
|
||||||
|
await build({
|
||||||
|
entryPoints: ["scripts/browser-smoke-entry.ts"],
|
||||||
|
bundle: true,
|
||||||
|
platform: "browser",
|
||||||
|
format: "esm",
|
||||||
|
logLevel: "silent",
|
||||||
|
outfile: outputPath,
|
||||||
|
});
|
||||||
|
process.exit(0);
|
||||||
|
} catch (error) {
|
||||||
|
let detailedErrors = "";
|
||||||
|
if (error && typeof error === "object" && "errors" in error && Array.isArray(error.errors)) {
|
||||||
|
detailedErrors = error.errors
|
||||||
|
.map((entry) => {
|
||||||
|
const location = entry.location
|
||||||
|
? `${entry.location.file}:${entry.location.line}:${entry.location.column}`
|
||||||
|
: "";
|
||||||
|
return [location, entry.text].filter(Boolean).join(" ");
|
||||||
|
})
|
||||||
|
.join("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
const baseError = error instanceof Error ? (error.stack ?? error.message) : String(error);
|
||||||
|
writeFileSync(errorLogPath, [detailedErrors, baseError].filter(Boolean).join("\n\n"), "utf-8");
|
||||||
|
console.error(`Browser smoke check failed. See ${errorLogPath}`);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user