Thanks for your interest in improving component-previewer.
This is a pnpm workspace. The example/ app consumes the
library source directly via Metro (bob's metro-config + the source export
condition), so editing src/ hot-reloads in the example with no rebuild or
repack.
pnpm install # links the workspaceRun these before opening a pull request; CI runs the same set:
pnpm lint # eslint (typescript-eslint)
pnpm typecheck # tsc --noEmit
pnpm test # vitest — CSF parsing, discovery, shell compose, control inference
pnpm build # react-native-builder-bob → lib/module (ESM) + lib/typescript (.d.ts)The core (src/csf.ts, src/registry.ts, src/shell.tsx, src/controls.ts)
is pure and unit-tested. Prefer adding behavior to a pure function with a test
over adding it to the UI.
cd example
EXPO_PUBLIC_PREVIEW=1 npx expo start # press i for iOS, or --web- Deep-link straight into one story:
EXPO_PUBLIC_PREVIEW_STORY=button--primary. EXPO_PUBLIC_*is inlined at bundle time — restart with--clearafter changing it, or Metro serves the stale bundle.- Without
EXPO_PUBLIC_PREVIEW=1the example boots its normal screen.
For a headless screenshot on a booted simulator:
xcrun simctl io booted screenshot /tmp/shot.png.
- The runtime imports only
reactandreact-native. No new runtime dependency without a strong reason — it is the whole pitch. - Keep discovery zero-codegen (
require.context/import.meta.glob). - The host's real shell always wraps outside a story; CSF
decoratorsrun inside it.
- One focused change per PR; keep the diff small.
- Include a test for new core behavior.
- Make sure the full quality gate passes.
Releases publish to npm with signed build provenance, authenticated
tokenless via npm Trusted Publishing (OIDC) — there is no NPM_TOKEN
secret stored anywhere.
One-time setup on npmjs.com (Package → Settings → Trusted Publisher):
- Provider: GitHub Actions
- Organization / repository:
2bTwist/component-previewer - Workflow filename:
release.yml
To cut a release:
- Bump
versioninpackage.jsonand commit. gh release create vX.Y.Z --title "vX.Y.Z" --notes "…".- The
Releaseworkflow runs the full gate, builds, and runsnpm publish --provenance --access public. No manualnpm publish.