Skip to main content

CLI & npm Scripts

All runnable commands are defined in each app's package.json "scripts" block and invoked with npm run <name>.

Backend (be-create-lab-studio)​

Development​

CommandWhat it does
npm run devStarts the Express server with ts-node in development mode
npm run buildCompiles TypeScript → dist/, then copies .sql migration and seed files
npm run serveRuns the compiled dist/server.js (production-style local run)

Database​

CommandWhat it does
npm run db:migrateApplies all pending migration files
npm run db:seedRuns all seed files (development data)
npm run db:seed-prodRuns production-safe seed subset only
npm run db:seed-file -- <filename>Runs a single seed file by name
npm run db:deleteDrops all tables in the schema
npm run db:resetdb:delete → db:migrate → db:seed (full local rebuild)

Each database command has a CLI entry point in src/cli/:

ScriptEntry point
db:migratesrc/cli/db-migrate.ts
db:seedsrc/cli/db-seed.ts
db:seed-prodsrc/cli/db-seed-prod.ts
db:seed-filesrc/cli/db-seed-file.ts
db:deletesrc/cli/db-delete.ts

Frontend (fe-create-lab-studio)​

CommandWhat it does
npm run devStarts the Vite dev server at http://localhost:5173
npm run buildType-checks with tsc then bundles with Vite into dist/
npm run previewServes the last dist/ build locally
npm run lintRuns ESLint across the project

Adding a new script​

1. Add it to package.json​

"scripts": {
"my-script": "ts-node src/cli/my-script.ts"
}

Create the corresponding CLI entry point in src/cli/my-script.ts:

import { MyService } from '../application/services/MyService';

async function main() {
const service = new MyService();
await service.run();
}

main().catch(console.error);

2. Run it locally​

npm run my-script

3. Wire it into CI/CD (optional)​

If the script should run on every deploy, add it to the workflow YAML inside the SSH run block. See CI/CD for details.