Campaign Kit docs
v1.1.0
Get help
● Customize · Quality

Build, tests & checks
before every release.

One command runs every check: typecheck, lint, format check and the automated test suites. Then the production builds.

01Test databases (once)

On Windows

The commands on this page are written for a bash shell: Terminal on macOS or Linux. On Windows, run them in WSL 2 (Ubuntu) with Node.js, pnpm and PostgreSQL installed inside WSL, and paste them unchanged. Some commands set a variable in front of the command (DATABASE_URL=... pnpm ...), which PowerShell does not accept; commands that only call pnpm or node also work in PowerShell or Git Bash.

The API, airdrop and E2E tests run against real PostgreSQL databases. Create and migrate them once:

createdb campaign_kit_test
DATABASE_URL=postgres://localhost:5432/campaign_kit_test pnpm db:migrate
createdb campaign_kit_e2e
DATABASE_URL=postgres://localhost:5432/campaign_kit_e2e pnpm db:migrate
Never point tests at production

The test suites truncate their tables between tests. The airdrop tests refuse a database whose name does not end in _test, the E2E test anything other than campaign_kit_e2e.

02Run the checks

Run everything with one command from the repository root:

pnpm check

pnpm check runs, in this order, and stops at the first failure:

StepCommand on its ownWhat it does
Typecheckpnpm typecheckTypeScript check of every package (pnpm -r typecheck).
Lintpnpm lintESLint (flat config, eslint.config.js).
Format checkpnpm format:checkPrettier, 120 columns. It only reports; pnpm format rewrites the files in place.
Testspnpm testEvery automated test suite (table below).

After you change code, run pnpm format first, then pnpm check. pnpm test runs the packages one at a time because the API and airdrop suites share the test database.

The test suites

337 automated tests in total:

SuiteTestsWhat it covers
API (apps/api)141Against a real PostgreSQL database: auth, game, quests, referrals, shop, ads callback, wallets, admin, seasons, squads, puzzles, fairness, analytics, links, reports, broadcasts, sponsors, revenue, clone, /paysupport, edits that keep unsent fields, start-up checks and /health; Telegram calls mocked
Admin (apps/admin)69Pages and forms
Mini App (apps/miniapp)60Screens, launch parameters, claim transaction
Airdrop (packages/airdrop)24Signals, allocation, fair multipliers, publish, distributor address check
Contract (packages/ton-claim)27The Tact distributor contract in a TON sandbox (real TVM emulation in @ton/sandbox)
Shared (packages/shared)7Economy maths
On-chain E2E (e2e)9Full airdrop chain in the sandbox: API, database, contract, claims, withdraw

The E2E test writes its result to e2e/results/airdrop-e2e.json.

The automated tests mock the Telegram Bot API and run the contract in a sandbox. Telegram itself is connected by you: create your bot in @BotFather, test Stars payments in Telegram's test environment and run the airdrop on TON testnet before mainnet (see the Go-live checklist).

03Production builds

CommandOutput
pnpm --filter @kit/api buildapps/api/dist/index.js + dist/migrate.js (the Docker image does this for you)
pnpm --filter @kit/miniapp buildapps/miniapp/dist + generated TON Connect manifest
pnpm --filter @kit/admin buildapps/admin/dist + TON Connect manifest
pnpm --filter @kit/ton-claim buildOnly when you change the contract (Tact compile + wrappers)

04Go-live checklist

  • /health answers over https with "database":"ok" and the API start-up log shows no production warnings; Workspace settings show https and the right network.
  • Webhook registered and menu button set in the Launch checklist.
  • Main Mini App set in BotFather with ?c=<slug>; one tracked link and one squad invite tested.
  • Both TON Connect manifests load over https.
  • A test Stars purchase and a refund done with your own account in Telegram's test environment.
  • Payment support reply set in Settings → Branding; the bot's menu lists /start and /paysupport, and /paysupport answers with your text (see Payment support reply).
  • Adsgram Reward URL tested, if you use ads.
  • A full airdrop run on testnet, including a claim and the withdraw.
  • Backups scheduled and one restore tested.
  • DEMO_READ_ONLY is not set (it is only for a public showcase install).