diff --git a/craft/src/main.tsx b/craft/src/main.tsx index e0da316..330e3e8 100644 --- a/craft/src/main.tsx +++ b/craft/src/main.tsx @@ -10,11 +10,15 @@ import './styles/editor.css'; // captured too. installConsoleErrorBuffer(); -// Logged so the build that produced a given session is visible in the -// browser console; also the only current reference to `editorBuild()`, -// which keeps the __EDITOR_BUILD__-reading module from being tree-shaken -// out of the bundle before Task 19 wires it into the report payload. -console.log(`[site-builder] build ${editorBuild()}`); +// Exposed on window (not logged -- no need to print this on every load for +// every customer) so support can ask someone to type __WHP_EDITOR_BUILD__ +// in the console on request. This call is also load-bearing for bundling: +// it is currently the only reference to `editorBuild()`, which keeps the +// __EDITOR_BUILD__-reading module from being tree-shaken out of the bundle +// before Task 19 wires it into the report payload. Do not remove this line +// as a "stray global" cleanup -- doing so silently reverts every future +// bug report to showing 'dev' instead of a real build stamp. +(window as any).__WHP_EDITOR_BUILD__ = editorBuild(); // Read WHP_CONFIG injected by PHP wrapper (or null for standalone dev) const whpConfig: WhpConfig | null = (window as any).WHP_CONFIG || null; diff --git a/craft/src/utils/build-stamp.test.ts b/craft/src/utils/build-stamp.test.ts new file mode 100644 index 0000000..52395fe --- /dev/null +++ b/craft/src/utils/build-stamp.test.ts @@ -0,0 +1,8 @@ +import { describe, it, expect } from 'vitest'; +import { editorBuild } from './build-stamp'; + +describe('editorBuild', () => { + it("returns 'dev' when __EDITOR_BUILD__ is undefined (vitest does not apply Vite's define)", () => { + expect(editorBuild()).toBe('dev'); + }); +}); diff --git a/craft/vite.config.ts b/craft/vite.config.ts index de42c20..f5b1a34 100644 --- a/craft/vite.config.ts +++ b/craft/vite.config.ts @@ -9,7 +9,10 @@ import { execSync } from 'child_process' const editorBuild = (() => { let sha = 'nogit' try { - sha = execSync('git rev-parse --short HEAD', { cwd: __dirname }).toString().trim() + sha = execSync('git rev-parse --short HEAD', { + cwd: __dirname, + stdio: ['ignore', 'pipe', 'ignore'], + }).toString().trim() } catch { // Building outside a git checkout (release tarball) -- keep 'nogit'. }