Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ from any directory containing a `wherefore/` folder. See the
[package README](packages/wherefore-dashboard/README.md) for build options, local
preview, and deploying to Cloudflare Pages.

Running several projects at the same time? See
[Running several projects at once](packages/wherefore-dashboard/README.md#running-several-projects-at-once)
-- concurrent `dev` is fine; concurrent `build`s want per-project installs.

## Running the dashboard from source

If you have this repo cloned and want to run the dashboard from the local source
Expand Down
13 changes: 13 additions & 0 deletions packages/wherefore-dashboard/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,19 @@ npm install --save-dev @dustinvk/wherefore-dashboard

Bumping the dashboard later is a one-line change in your `package.json`.

## Running several projects at once

The dashboard caches per install, not per project. That has one consequence worth knowing:

- **Multiple `dev` servers at once is fine.** Browsing two or more projects side by side works --
each `dev` server renders its own project. You may see harmless `Duplicate id "Q-..."` warnings
in the logs; they do not affect what is served.
- **Avoid running multiple `build`s at once against the same `npx` install.** Parallel builds of
different projects (e.g. a multi-repo CI job or script) share one on-disk cache and can
cross-contaminate each other's output. Either serialize the builds, or install the dashboard as a
per-project devDependency (see above) and build via an npm script so each project uses its own
isolated copy.

## Deploy to Cloudflare Pages

- Build command: `npx @dustinvk/wherefore-dashboard build`
Expand Down
17 changes: 17 additions & 0 deletions packages/wherefore-dashboard/bin/wherefore-dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,19 @@ import { tmpdir } from 'node:os';
const __dirname = dirname(fileURLToPath(import.meta.url));
const PACKAGE_ROOT = resolve(__dirname, '..');

async function resetContentStore() {
// Astro persists its content-layer data store under the package root, not under --src:
// dev -> <root>/.astro/data-store.json
// build -> <root>/node_modules/.astro/data-store.json (cacheDir default)
// Question ids (Q-001, ...) are identical in every project, so a store left over from a
// different --src collides and Astro logs "Duplicate id". Clear it so each run is scoped to
// the current --src. The store is cheap to rebuild for a markdown viewer.
await Promise.all([
rm(resolve(PACKAGE_ROOT, '.astro', 'data-store.json'), { force: true }),
rm(resolve(PACKAGE_ROOT, 'node_modules', '.astro', 'data-store.json'), { force: true }),
]);
}

const USAGE = `wherefore-dashboard -- build or preview a static dashboard from a wherefore/ directory

Usage:
Expand Down Expand Up @@ -66,6 +79,8 @@ if (command === 'build') {
process.env.WHEREFORE_SRC = src;
if (flags.title) process.env.WHEREFORE_TITLE = flags.title;

await resetContentStore();

const workDir = resolve(tmpdir(), `wherefore-dashboard-${Date.now()}`);

process.chdir(PACKAGE_ROOT);
Expand All @@ -89,6 +104,8 @@ if (command === 'build') {
process.env.WHEREFORE_SRC = src;
if (flags.title) process.env.WHEREFORE_TITLE = flags.title;

await resetContentStore();

const server = await dev({ root: PACKAGE_ROOT });
process.on('SIGINT', async () => {
await server.stop();
Expand Down
4 changes: 2 additions & 2 deletions packages/wherefore-dashboard/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/wherefore-dashboard/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dustinvk/wherefore-dashboard",
"version": "0.1.1",
"version": "0.1.2",
"description": "Build tool that reads a wherefore/ directory and emits a static dashboard.",
"author": "Dustin VanKrimpen",
"license": "MIT",
Expand Down
Loading