Development

Prerequisites

Setup

git clone https://github.com/nicopasla/better-intra.git
cd better-intra
npm install

Commands

npm run dev:firefox     # watch + web-ext auto-reload in Firefox
npm run dev:chrome      # watch + web-ext auto-reload in Chrome
npm run dev:brave       # watch + web-ext auto-reload in Brave
npm run build:firefox   # single production build for Firefox
npm run build:chrome    # single production build for Chrome

Output goes to dist-firefox/ or dist-chrome/.

Build pipeline

Always tsc (type-check only, noEmit) → vite build (content script) → vite build --config vite.popup.config.ts (popup) → vite build --config vite.background.config.ts (background service worker).

cross-env TARGET=firefox BUILD_OUT_DIR=dist-firefox tsc && cross-env TARGET=firefox BUILD_OUT_DIR=dist-firefox vite build && cross-env TARGET=firefox BUILD_OUT_DIR=dist-firefox vite build --config vite.popup.config.ts && cross-env TARGET=firefox BUILD_OUT_DIR=dist-firefox vite build --config vite.background.config.ts

Project structure

Toolchain

Worker

The Cloudflare Worker (better-intra-worker/) handles cloud settings sync, friend data, and evaluation notifications. It has its own package.json.

Commands

cd better-intra-worker
npm install
npm run dev       # wrangler dev
npm run deploy    # wrangler deploy --remote

KV namespaces

Secrets

npx wrangler secret put DISCORD_BOT_TOKEN

Evaluations architecture

Worker cron (*/5 * * * *) fetches 42 API /v2/me/scale_teams for each user, detects state changes (null → booked → revealed), sends Discord DMs, and stores pending notifications in EVAL_KV. The extension’s background service worker polls /evaluations?action=pending every 5 minutes and shows Chrome notifications from the pending list.

Testing

Tests use Vitest with jsdom environment. Test files are in tests/.

npm test           # vitest run (single pass)
npm run test:watch # vitest (watch mode)

Test files: config.test.ts, marks.test.ts, visuals.test.ts, friends.test.ts. Global setup is in tests/setup.ts.

Coding conventions

CI

Formatting

Prettier is used for formatting (editor-level; no project config file committed). No linter is configured.