Skip to content

Contributing and Releasing

Mcdavid Obioha edited this page Dec 2, 2026 · 1 revision

Contributing and Releasing

Set up

Use Node.js 22.

git clone https://github.com/mcdavidobioha/whatsapp-chat-widget-react-typescript.git
cd whatsapp-chat-widget-react-typescript
npm ci

Commands

Command What it does
npm run dev Vite demo app (demo/) with live reload.
npm run lint Strict TypeScript check (no emit).
npm test Builds, runs the Node tests for the message helpers, then the Vitest component, hours, page-context and axe accessibility tests.
npm run size Builds and checks the gzipped bundle against the limit in package.json.
npm run build Generates the inlined CSS and props.schema.json, then compiles to dist/.

CI runs build, lint, tests and the size check on every push and pull request.

Project layout

Path Responsibility
src/WhatsAppChat.tsx The component and its props (with TSDoc).
src/hours.ts Business-hours logic (isOpenNow).
src/pageContext.ts Page and UTM footer (buildPageContext).
src/message.ts Phone validation and the wa.me URL.
src/hooks.ts, src/labels.ts Clock, visibility and path hooks; default text.
src/styles.css The only place CSS is written.
props.schema.json Generated from the props interface; commit it.
llms.txt, AGENTS.md Guides for AI coding assistants.
test/ Node tests and Vitest tests.
examples/stackblitz/ The StackBlitz demo, which installs the published package.

Generated files you should not edit by hand: src/styles.generated.ts (from styles.css, not committed) and props.schema.json.

Making a change

  1. Branch from main.
  2. Add or change code, plus a test that fails without the change.
  3. If you add or change a prop: update its TSDoc (@default, @example), the README, llms.txt, CHANGELOG.md and this wiki's Props Reference (it is generated from props.schema.json).
  4. Keep CSS scoped under .wcr-widget, class names prefixed wcr-, and prefer logical properties (margin-inline, inset-inline-end) so right-to-left keeps working.
  5. Run npm run lint && npm test && npm run size.
  6. Open a pull request describing what changed and why.

Guidelines: no new runtime dependencies, keep existing props working (deprecate rather than remove), and keep the form accessible.

Releasing (maintainers)

Publishing uses npm trusted publishing from GitHub Actions, so no token is stored.

  1. Update version in package.json and add an entry to CHANGELOG.md.
  2. Push to main and wait for CI to pass.
  3. Create the release:
    gh release create vX.Y.Z --target main --title vX.Y.Z --generate-notes
  4. The Publish to npm workflow runs tests and publishes with provenance. It may take a few minutes for npm to show the new version.
  5. Update examples/stackblitz/package.json to the new version and refresh its lockfile so the live demo uses it.

Published versions cannot be replaced; if something is wrong, publish a new patch version.

Clone this wiki locally