Scripts
Add new badge to the database
Section titled “Add new badge to the database”pnpm exec vite-node scripts/add-badge.ts fire_green "Octofin Eliteboard"Rename display name of a badge
Section titled “Rename display name of a badge”pnpm exec vite-node scripts/rename-badge.ts 10 "New 4v4 Sundaes"Add many badge owners
Section titled “Add many badge owners”pnpm exec vite-node scripts/add-badge-winners.ts 10 "750705955909664791,79237403620945920"Converting gifs (badges) to thumbnail (.png)
Section titled “Converting gifs (badges) to thumbnail (.png)”sips -s format png ./sundae.gif --out .Convert many .png files to .avif
Section titled “Convert many .png files to .avif”While in the folder with the images:
pnpm dlx sharp-cli --input '*.png' --output '{dir}/{name}.avif' --format avifDoing monthly update
Section titled “Doing monthly update”- Drop the whole splat3 repository into
/scripts/dicts/splat3(pull before). - If the dump’s shape changed, update
/scripts/splat3-types.tsto match (the dump is gitignored, so these types are hand-maintained rather than inferred from the JSON). - Update all
CURRENT_SEASONconstants - Update
CURRENT_PATCHconstants - Update
PATCHESconstant with the latest patch + remove the oldest - Update the stage list in
stage-ids.tsandcreate-misc-json.ts. Add images from Lean’s repository and avify them. pnpm exec vite-node scripts/create-misc-json.tspnpm exec vite-node scripts/create-gear-json.tspnpm exec vite-node scripts/create-analyzer-json.ts(writesweapon-params.tsdirectly intoapp/features/build-analyzer/data)- Double check that no hard-coded special damages changed
pnpm run i18n:sync(the scripts write the regional variants’ full translations, sync removes what they share with their parent language)
pnpm exec vite-node scripts/create-object-dmg-json.ts(writesobject-dmg.jsondirectly intoapp/features/object-damage-calculator/dataanddamage-rate-history.jsonfor the params page intoapp/features/params/data)pnpm exec vite-node scripts/sync-weapon-params.ts(writes the weapon/sub/special param histories for the params page)- Fill new weapon IDs by category to
weapon-ids.ts(easy to take from the diff of English weapons.json) - Get gear IDs for each slot from /output folder and update
gear-ids.ts. - Delete all images inside
main-weapons,main-weapons-outlined,main-weapons-outlined-2,main-weapons-outlined-3andgearfolders. - Replace with images from Lean’s repository.
- Run the
pnpm exec vite-node scripts/replace-img-names.tscommand - Run the
pnpm exec vite-node scripts/replace-weapon-names.tscommand - Run the .avif generating command in each image folder.
- Update manually any languages that use English
gear.jsonandweapons.jsonfiles
Deploy to Render.com
Section titled “Deploy to Render.com”pnpm run deploy:prodPuts the service in maintenance mode, triggers a deploy and polls it every 10 seconds until it is live. Then pings /health on the new instance over SSH (public traffic only sees Render’s 503 maintenance page) every 10 seconds until it returns 200, and finally turns maintenance mode off. On success it prints the pnpm run changelog:image <sha> command with the commit of the previous release filled in.
If the build fails the previous version is still running, so maintenance mode is turned off again. Any other failure or timeout leaves maintenance mode on to be handled from the Render dashboard.
Needs RENDER_API_KEY (Render Dashboard -> Account Settings -> API Keys), RENDER_SERVICE_ID and PROD_SSH_TARGET (see the one-time setup below) in .env.
The docs site
Section titled “The docs site”The docs site (https://docs.sendou.ink) is a Render static site that deploys itself: its auto-deploy is set to “After CI checks pass”, so every commit to main whose checks pass is built, the e2e job having published its screenshots by then (see Living docs). The previous version is served until the new build is live, and a skipped commit is picked up by the next green one (or redeployed from the dashboard).
The static site’s settings: the repository root as its root directory, pnpm install --frozen-lockfile && pnpm run docs:screenshots:download && pnpm run docs:build as the build command and docs/site/dist as the publish directory.
Download the production database from Render.com
Section titled “Download the production database from Render.com”pnpm run download-prod-dbTakes a VACUUM INTO snapshot of the live database (compacted, and consistent unlike a cp of a WAL database), streams it down gzipped, and archives it as ../backups/db-<timestamp>.sqlite3.gz (PROD_DB_BACKUP_DIR to change). Once the snapshot has been verified it replaces db-snapshot.sqlite3 in this checkout and every sendou.ink checkout next to it, deletes the stale db-sandbox.sqlite3 files, and rebuilds db-sandbox.sqlite3 in the checkout you ran it from (pnpm run sandbox:reset does that rebuild on its own).
Flags: --dry-run prints what would happen, --yes skips the confirmation, --keep <n> prunes all but the newest n archives.
One-time setup
Section titled “One-time setup”- Add your public key at Render Dashboard -> Account Settings -> SSH Keys.
- Set
PROD_SSH_TARGETin.envto the address in Render Dashboard -> the service -> SSH, e.g.srv-xxxxxxxx@ssh.frankfurt.render.com. - Run
ssh $PROD_SSH_TARGET 'echo ok'once to accept the host key.
Doing it by hand
Section titled “Doing it by hand”If SSH is unavailable, the same thing through the dashboard “Shell” tab:
cd /var/datasqlite3 -readonly db.sqlite3 "VACUUM INTO '/var/data/db-snapshot.sqlite3'"gzip db-snapshot.sqlite3wormhole send db-snapshot.sqlite3.gz- On the receiving computer use the command shown.
gunzip db-snapshot.sqlite3.gzin the checkout root, thenpnpm run sandbox:resetrm db-snapshot.sqlite3.gzon the server, it is sharing the disk with production