-
-
Notifications
You must be signed in to change notification settings - Fork 2
fix(explorer): harden mount gate, tests, and watch lifecycle #232
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,7 +13,9 @@ flatbread start --watch --open | |
| # → http://localhost:5057/graphql Apollo sandbox | ||
| ``` | ||
|
|
||
| No separate Next app is required. | ||
| No separate Next app is required. Requires a built `dist/static` (see | ||
| [Develop in the monorepo](#develop-in-the-monorepo)); `pnpm play:efforts` runs | ||
| that build automatically. | ||
|
|
||
| ## Static deploy | ||
|
|
||
|
|
@@ -31,6 +33,7 @@ Same-origin deploys (assets served by Flatbread) need no query param. | |
| | Export | Role | | ||
| | ------------------------------ | ------------------------------------------ | | ||
| | `getExplorerStaticDir()` | Absolute path to `dist/static` for Express | | ||
| | `explorerAssetsPresent()` | Whether prebuilt `index.html` exists | | ||
| | `matchExplorerPreset(content)` | Detect Effort Graph (and later presets) | | ||
| | `EXPLORER_BOOTSTRAP_PATH` | Bootstrap JSON path Flatbread injects | | ||
|
|
||
|
|
@@ -40,6 +43,14 @@ There is no public React component export in v1. | |
|
|
||
| ```bash | ||
| pnpm --filter @flatbread/explorer test | ||
| pnpm --filter @flatbread/explorer build | ||
| pnpm play:efforts # flatbread start --watch --open from repo root | ||
| pnpm play:efforts # builds explorer, then flatbread start --watch --open | ||
| ``` | ||
|
|
||
| For UI-only iteration with HMR, run Flatbread and Vite in separate terminals | ||
| (Vite proxies `/graphql` and `/events` to Flatbread on port **5057**, or | ||
| `FLATBREAD_PORT` when set): | ||
|
|
||
| ```bash | ||
| pnpm exec flatbread start --watch # terminal 1 — GraphQL on :5057 | ||
| pnpm --filter @flatbread/explorer dev # terminal 2 — SPA on :5173 | ||
|
Comment on lines
+46
to
+55
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. severity: MED (docs-and-positioning, explorer-package) HMR docs imply Minimal fix: Document exporting |
||
| ``` | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,16 +1,40 @@ | ||
| import fs from 'node:fs'; | ||
| import path from 'node:path'; | ||
| import { fileURLToPath } from 'node:url'; | ||
|
|
||
| /** HTTP path Flatbread serves for explorer bootstrap JSON. */ | ||
| export const EXPLORER_BOOTSTRAP_PATH = '/__flatbread/explorer.json'; | ||
|
|
||
| let staticDirOverride: string | undefined; | ||
|
|
||
| /** | ||
| * Test-only: force `getExplorerStaticDir()` to `dir`. | ||
| * Pass `undefined` to clear. Not for production callers. | ||
| */ | ||
| export function setExplorerStaticDirOverride(dir: string | undefined): void { | ||
| staticDirOverride = dir; | ||
| } | ||
|
|
||
|
Comment on lines
+8
to
+17
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. severity: MED (cli-and-runtime, explorer-package) Public process-global override has no isolation. Any parallel AVA worker mutating it can corrupt unrelated suites (same root cause as the openPath HIGH). Minimal fix: Move the override behind a test-only export path, or document it and require serial consumers everywhere it is set/cleared. |
||
| /** | ||
| * Absolute path to the prebuilt SPA assets shipped in this package. | ||
| * Flatbread mounts these with `express.static` when a preset matches. | ||
| * Honors `setExplorerStaticDirOverride` when set (tests only). | ||
| */ | ||
| export function getExplorerStaticDir(): string { | ||
| if (staticDirOverride !== undefined) { | ||
| return staticDirOverride; | ||
| } | ||
| const here = path.dirname(fileURLToPath(import.meta.url)); | ||
| // Works from both `src/node` (tests) and `dist/node` (published). | ||
| const packageRoot = path.resolve(here, '../..'); | ||
| return path.join(packageRoot, 'dist', 'static'); | ||
| } | ||
|
|
||
| /** | ||
| * True when prebuilt SPA `index.html` exists under `getExplorerStaticDir()`. | ||
| * Flatbread uses this with `matchExplorerPreset` before mounting or advertising | ||
| * explorer. | ||
| */ | ||
| export function explorerAssetsPresent(): boolean { | ||
| return fs.existsSync(path.join(getExplorerStaticDir(), 'index.html')); | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
severity: MED (docs-and-positioning)
Docs claim explorer is always at
http://localhost:5057/foreffortGraphContent(), but mount/--opennow require assets and HMR UI is on 5173.Minimal fix: Add the same “when mounted / assets present” qualifier as
setup.md, and point HMR UI at 5173.