Commands
The scripts of a CAITS project, the commands of CAITS, the environment variables, and the reports. init writes the scripts in package.json: they are yours to change.
The scripts of every day
| Script | What it does |
|---|---|
npm run dev | Starts the app on http:/, and reloads it as you edit. |
npm run tdd | Runs the unit tests, then, at each save, the tests of the files you changed. In an AI agent, it runs them once and stops: run it again after a change. |
npm test | Runs every unit test, contracts and integration tests included. |
npm run check | Runs every check at once, prints the output of the failing ones only, and writes the reports. Run it before each commit. |
npm run build | Builds the app for production, in dist/. |
npm start | Starts the production build on port PORT. |
The scripts of each check
npm run check runs six of these at once, each in its own build folder. To fix one check, run its script alone. The harness shows what each one catches.
| Script | What it does |
|---|---|
npm run typecheck | Builds the app, then checks the types of the TypeScript files and the Marko templates. |
npm run lint | Runs lint:code, then lint:architecture. |
npm run lint:code | Runs ESLint. |
npm run lint:architecture | Checks the architecture rules, in under a second. |
npm run test:coverage | Runs the unit tests with their coverage, which must reach 100%, and writes the report of the tests. |
npm run test:mutation | Runs Stryker: every mutant must be killed. Then gives each file's score, and the survivors. |
npm run test:e2e | Builds the app, starts it, and runs the end-to-end tests in a browser. |
npm run test:unit | The unit tests, without the infra and integration tests: the fastest ones. |
npm run test:contracts | The infra tests: each adapter runs the contract of its port. |
npm run test:integration | The backend, with its real adapters. |
The commands of CAITS
The scripts run these commands. Run them yourself with npx caits <command>.
| Command | What it does |
|---|---|
caits init [folder] | Makes a project, or adds CAITS to the current one: see Add CAITS to a project. |
caits update | Writes the defaults of the installed CAITS to quality/. Run it after you install another version. It gives the commands that add the packages and the values that package.json lacks. |
caits dev | Starts the development server. It builds in node_modules/, so npm run check can run at the same time, and restarts when the setup changes. |
caits check <script>… | Runs the scripts it gets, all at once. npm run check gives it the six checks: remove one, or add your own. |
caits architecture | Checks the rules of quality/ on src/ and test/. |
caits e2e | Starts the server of quality/, then runs the end-to-end tests. |
caits mutation | Runs Stryker, then runs again, with more time and fewer at once, the mutants that the clock stopped: their second result counts. Then it gives each file's score and the survivors. It fails when a mutant isn't judged. Its options go to Stryker. |
caits mutation-summary | Gives each file's score from the last report. With --survivors, it lists the mutants that survived, and those not judged. |
caits --version, caits --help | The installed version, and the usage of each command. |
The options of init:
| Option | What it does |
|---|---|
--example | Writes the example app, fetched with git from IngeniozIT/ at the tag of your CAITS version. |
--no-install | Writes the files, but installs nothing. Then run npm install and npx playwright install chromium. |
--example-source <source> | To work on CAITS itself: writes the example from a git repository with # and a tag or a branch, or a folder. |
--caits <source> | To work on CAITS itself: where npm gets CAITS, such as file:/. |
The environment variables
| Variable | Read by | What it sets |
|---|---|---|
PORT | npm run dev, npm start | The port of the app. Default: 3000. |
HMR_PORT | npm run dev | The port that sends your changes to the browser. Default: 24678. Give each project its own to run two at once. |
DATA_DIR | The example app | The folder where the backend keeps its files. Default: tmp/. The end-to-end tests give each project its own, and empty it first. |
The end-to-end tests start the app on port 4310. When another program uses it, caits e2e stops and says so.
The reports
npm run check writes its reports in reports/:
| Report | What it shows |
|---|---|
reports/ | Your tests, as a spec: what the app does, test by test. See the harness. |
reports/ | The coverage, line by line. |
reports/ | The mutants, file by file. |