Skip to content

Add serve-instrument-all package#1363

Open
gdevenyi wants to merge 1 commit into
v2from
serve-instruments-all
Open

Add serve-instrument-all package#1363
gdevenyi wants to merge 1 commit into
v2from
serve-instruments-all

Conversation

@gdevenyi
Copy link
Copy Markdown
Contributor

@gdevenyi gdevenyi commented Jun 1, 2026

Summary

Adds @opendatacapture/serve-instrument-all, a dev server that serves every instrument in a directory tree, extending the single-instrument serve-instrument package.

Given a target directory containing forms/ and/or interactive/ subdirectories, it:

  • enumerates each instrument (forms/<name>/, interactive/<name>/) and serves an index page linking to all of them
  • renders each instrument via ScalarInstrumentRenderer, rebuilding its bundle on file change (fs.watch)
  • serves runtime assets under /runtime/*
  • includes an en/fr language switcher wired to the libui i18n translator
  • supports --port and --verbose (the latter now also emits per-request logs)

The implementation closely mirrors serve-instrument (same build setup, esbuild config, and conventions).

Notes

  • The pnpm-lock.yaml change is a single additive importer block; transitive dependency drift from regeneration was stripped so the diff stays minimal. pnpm install --frozen-lockfile passes.
  • tsc, eslint, and build all pass for the new package.

Known limitations (follow-ups, not blockers)

  • A build failure on a listed instrument currently returns 404 rather than distinguishing a compile error.
  • The instrument list is enumerated once at startup; adding/removing instrument directories requires a restart.

🤖 Generated with Claude Code

Adds a dev server that serves every instrument in a directory tree of
forms/ and interactive/ subdirectories, with an index page and a
language switcher, extending the single-instrument serve-instrument
package.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 1, 2026 18:18
@gdevenyi gdevenyi requested a review from joshunrau as a code owner June 1, 2026 18:18
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 1, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 3d697108-4cd7-437a-80c5-d09bdbc2ce63

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch serve-instruments-all

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new workspace package, @opendatacapture/serve-instrument-all, providing a dev server that discovers and serves all instruments under forms/ and interactive/, with an index page and per-instrument rendering/bundling.

Changes:

  • Introduces the serve-instrument-all CLI + HTTP server to enumerate instruments and serve an index plus per-instrument pages.
  • Adds a small React client/root app including an en/fr language switcher and instrument rendering via ScalarInstrumentRenderer.
  • Adds build tooling (esbuild + Tailwind CSS extraction) and wires the new package into the pnpm workspace lockfile.

Reviewed changes

Copilot reviewed 7 out of 8 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
pnpm-lock.yaml Adds the new workspace importer for packages/serve-instrument-all.
packages/serve-instrument-all/package.json Defines the new package, bin entry, and dependencies for the CLI/dev server.
packages/serve-instrument-all/tsconfig.json TypeScript config matching existing dev-server conventions (DOM libs, runtime path mapping).
packages/serve-instrument-all/scripts/build.js Builds the Node CLI and browser client bundles (plus inlined Tailwind styles).
packages/serve-instrument-all/src/cli.ts CLI argument parsing/validation and server startup (--port, --verbose).
packages/serve-instrument-all/src/server.tsx HTTP server, instrument discovery, bundling/watch logic, and runtime asset serving.
packages/serve-instrument-all/src/root.tsx React UI: index page + instrument page with language switcher.
packages/serve-instrument-all/src/client.tsx Client hydration entrypoint for the server-rendered HTML.
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +161 to +163
const [, type, name] = instrumentMatch;
const decodedName = decodeURIComponent(name!);
const encodedBundle = await this.loaderMap.getEncodedBundle(type!, decodedName);
Comment on lines +197 to +200
const clientBundle = await fs.promises
.readFile(path.resolve(import.meta.dirname, 'client.js'), 'utf-8')
.then((text) => `const __ROOT_PROPS__ = ${JSON.stringify(props)}; ${text}`);

Comment on lines +44 to +47
fs.watch(target, { recursive: false }, () => {
log(chalk.yellow('↺') + chalk.dim(` [${this.label}] File changed, rebuilding...`));
void this.updateEncodedBundle();
});
Comment on lines +161 to +163
const [, type, name] = instrumentMatch;
const decodedName = decodeURIComponent(name!);
const encodedBundle = await this.loaderMap.getEncodedBundle(type!, decodedName);
Comment on lines +197 to +200
const clientBundle = await fs.promises
.readFile(path.resolve(import.meta.dirname, 'client.js'), 'utf-8')
.then((text) => `const __ROOT_PROPS__ = ${JSON.stringify(props)}; ${text}`);

Comment on lines +44 to +47
fs.watch(target, { recursive: false }, () => {
log(chalk.yellow('↺') + chalk.dim(` [${this.label}] File changed, rebuilding...`));
void this.updateEncodedBundle();
});
Comment on lines +161 to +163
const [, type, name] = instrumentMatch;
const decodedName = decodeURIComponent(name!);
const encodedBundle = await this.loaderMap.getEncodedBundle(type!, decodedName);
Comment on lines +197 to +200
const clientBundle = await fs.promises
.readFile(path.resolve(import.meta.dirname, 'client.js'), 'utf-8')
.then((text) => `const __ROOT_PROPS__ = ${JSON.stringify(props)}; ${text}`);

Comment on lines +44 to +47
fs.watch(target, { recursive: false }, () => {
log(chalk.yellow('↺') + chalk.dim(` [${this.label}] File changed, rebuilding...`));
void this.updateEncodedBundle();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants