All scripts live in the scripts/ directory. Root-level pnpm commands are defined in the root package.json.
Interactive setup script for first-time Opencom installation.
./scripts/setup.shWhat it does:
- Checks prerequisites (Node.js 18+, PNPM 9+)
- Installs dependencies (
pnpm install) - Creates a Convex project and deploys the backend
- Prompts for admin email/password (or accepts via flags)
- Creates workspace and admin account
- Generates
.env.localfiles for all apps - Optionally starts the dev server
Flags:
| Flag | Description |
|---|---|
--email <email> |
Admin email address |
--password <password> |
Admin password |
--name <name> |
Admin display name |
--workspace <name> |
Workspace name |
--skip-dev |
Skip starting dev server |
--non-interactive |
Run without prompts (requires --email and --password) |
Non-interactive example (CI):
./scripts/setup.sh --email admin@example.com --password yourpassword --non-interactive --skip-devRegenerates .env.local files after setup or configuration changes.
./scripts/update-env.sh --url https://your-project.convex.cloud --workspace your_workspace_id| Flag | Description |
|---|---|
--url <url> |
Convex deployment URL |
--workspace <id> |
Workspace ID |
Builds the widget IIFE bundle and copies it to consuming apps' public/ directories.
bash scripts/build-widget-for-tests.shWhat it does:
- Runs
pnpm buildinapps/widget/ - Copies
apps/widget/dist/opencom-widget.iife.jsto:apps/web/public/opencom-widget.iife.jsapps/landing/public/opencom-widget.iife.js
Required before: Web E2E tests, local landing page widget demos.
PNPM alias: pnpm build:widget
Deploys the widget bundle to Cloudflare R2 CDN with versioning and cache purge.
DRY_RUN=1 bash scripts/deploy-widget-cdn.sh # Dry run
bash scripts/deploy-widget-cdn.sh # Production deployWhat it does:
- Resolves widget deploy version (
WIDGET_DEPLOY_VERSIONoverride,widget-v*tag, otherwisepackageVersion-<sha>with CIrun_idsuffix) - Builds the widget IIFE bundle
- Generates a
widget.jsloader fromscripts/widget-loader.js - Creates a
manifest.jsonwith the latest deploy version - Uploads versioned bundle, loader, and manifest to R2
- Purges Cloudflare CDN cache for updated URLs
Environment variables:
| Variable | Default | Description |
|---|---|---|
WIDGET_CDN_BUCKET |
opencom-static |
R2 bucket name |
WIDGET_CDN_BASE_URL |
https://cdn.opencom.dev |
CDN base URL |
WIDGET_DEPLOY_VERSION |
(auto) | Optional explicit version key for v/<version>/widget.js |
DRY_RUN |
0 |
Set to 1 to skip upload |
CLOUDFLARE_ACCOUNT_ID |
(required) | Cloudflare account ID |
CLOUDFLARE_API_TOKEN |
(required) | Cloudflare API token (R2 Write + Cache Purge) |
CLOUDFLARE_ZONE_ID |
(required) | Zone ID for cache purge |
PNPM alias: pnpm deploy:widget:cdn (sources .env.local automatically)
CI workflow: .github/workflows/deploy-widget.yml — runs on push to master or widget-v* tags, supports manual workflow_dispatch with dry-run option.
Loader script template embedded into the CDN widget.js. Implements a fallback mechanism:
- Queues API calls (
init,identify,trackEvent, etc.) while script loads - Captures auto-init config from
data-opencom-*attributes orwindow.opencomSettings - Fetches
manifest.jsonto resolve current widget version - Falls back to a hardcoded version if manifest fetch fails (3s timeout)
- Loads the versioned IIFE bundle asynchronously
These scripts run as CI checks and can be run locally. All exit with non-zero status on failure.
Scans Convex backend files for raw query/mutation handlers that bypass the auth wrapper system.
pnpm security:convex-auth-guardValidates that exported queries and mutations use the proper authentication wrappers. Known exceptions are tracked in security/convex-raw-handler-registry.json.
Detects v.any() usage in Convex function arguments (a potential injection surface).
pnpm security:convex-any-args-gateKnown exceptions are tracked in security/convex-v-any-arg-exceptions.json with expiry dates.
Scans the codebase for accidentally committed secrets, API keys, and credentials.
pnpm security:secret-scanReviewed false-positive exceptions are tracked in
security/secret-scan-exceptions.json with owner, reason, and expiry metadata.
Validates security header configuration across HTTP endpoints.
pnpm security:headers-checkRuns pnpm audit and fails if vulnerabilities exceed the allowlist.
node scripts/ci-audit-gate.jsKnown vulnerabilities are allowlisted in security/dependency-audit-allowlist.json with expiry dates.
Summarizes recent E2E test run results from test-run-log.jsonl.
pnpm test:summary # Show summary
pnpm test:clear # Clear run historyGenerates an E2E test reliability report from Playwright results.
node scripts/e2e-reliability-report.jsCI gate that fails if E2E flakiness or failures exceed the budget.
node scripts/e2e-reliability-gate.jsBudgets are defined in security/e2e-reliability-budget.json:
| Metric | Budget |
|---|---|
| Unexpected (failures) | 0 |
| Flaky | 5 |
| Skipped | 70 |
Runs E2E tests against a production build.
pnpm test:e2e:prodSeeds demo data for the landing page widget demonstration.
pnpm seed:landing # Seed demo data
pnpm seed:landing:cleanup # Clean up demo dataFiles in security/ configure CI gate behavior:
| File | Purpose |
|---|---|
convex-raw-handler-registry.json |
Governance-reviewed raw handler audit trail |
convex-raw-handler-inventory.json |
Sensitive authorization surface inventory |
convex-v-any-arg-exceptions.json |
Allowed v.any() usage with expiry dates |
convex-v-any-arg-inventory.json |
Migration progress for v.any() elimination |
dependency-audit-allowlist.json |
Known acceptable dependency vulnerabilities |
e2e-reliability-budget.json |
Flakiness/failure thresholds for E2E gate |
e2e-reliability-allowlist.json |
Known flaky test exceptions |
| Command | Description |
|---|---|
pnpm dev |
Start all apps in parallel |
pnpm dev:web |
Start web dashboard |
pnpm dev:widget |
Start widget dev server |
pnpm dev:convex |
Start Convex backend |
pnpm dev:mobile |
Start Expo mobile app |
pnpm dev:landing |
Start landing page |
| Command | Description |
|---|---|
pnpm build |
Build all apps |
pnpm build:web |
Build web dashboard |
pnpm build:widget |
Build widget and distribute |
pnpm build:landing |
Build landing page |
pnpm build:sdk-core |
Build SDK core package |
pnpm build:rn-sdk |
Build React Native SDK |
| Command | Description |
|---|---|
pnpm lint |
Lint all packages |
pnpm format |
Format all files |
pnpm format:check |
Check formatting |
pnpm typecheck |
Typecheck all packages |
| Command | Description |
|---|---|
pnpm test |
Run unit + E2E tests |
pnpm test:unit |
Run unit tests (Vitest) |
pnpm test:e2e |
Run E2E tests (Playwright) |
pnpm test:ci |
Run tests with coverage |
pnpm test:convex |
Run Convex integration tests |
pnpm test:summary |
Show E2E run summary |
pnpm test:clear |
Clear E2E run history |
pnpm test:e2e:prod |
Run E2E against production build |
| Command | Description |
|---|---|
pnpm security:convex-auth-guard |
Scan for unguarded handlers |
pnpm security:convex-any-args-gate |
Scan for v.any() usage |
pnpm security:secret-scan |
Scan for committed secrets |
pnpm security:headers-check |
Validate security headers |
| Command | Description |
|---|---|
pnpm deploy:widget:cdn |
Deploy widget to CDN |
pnpm seed:landing |
Seed landing demo data |
pnpm seed:landing:cleanup |
Clean up landing demo data |