Skip to content

Latest commit

 

History

History
77 lines (55 loc) · 2.5 KB

File metadata and controls

77 lines (55 loc) · 2.5 KB

Contributing

Thanks for your interest in improving component-previewer.

Setup

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 workspace

Quality gate

Run 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.

Running the example

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 --clear after changing it, or Metro serves the stale bundle.
  • Without EXPO_PUBLIC_PREVIEW=1 the example boots its normal screen.

For a headless screenshot on a booted simulator: xcrun simctl io booted screenshot /tmp/shot.png.

Constraints to keep

  • The runtime imports only react and react-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 decorators run inside it.

Pull requests

  • One focused change per PR; keep the diff small.
  • Include a test for new core behavior.
  • Make sure the full quality gate passes.

Releasing

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:

  1. Bump version in package.json and commit.
  2. gh release create vX.Y.Z --title "vX.Y.Z" --notes "…".
  3. The Release workflow runs the full gate, builds, and runs npm publish --provenance --access public. No manual npm publish.