usm/cli-init
The usm init command analyzes the repo and generates a starter usmconfig.json.
Usage
bash
# Analyze repo and generate usmconfig.json
usm init
# Overwrite existing usmconfig.json
usm init --forceWhy this exists
New users need a config file that tells usm scan where to look. Init detects apps, packages, Prisma schemas, and Docker Compose services from the repo structure and writes a usmconfig.json so the next scan can work immediately.
How it works
Init pipeline (repo analysis) (run-init)
System pipeline behind usm init: analyze repo structure, write starter config.
- Setup — repo root directory
- Parse — apps/* and packages/* directories for package.json
- Parse — prisma schema files
- Generate — usmconfig.json with services, shared, data, outputs sections
Set up USM in a new repo (first-run-init)
First-run experience: an adopter initializes USM in their repository and reviews the generated usmconfig.json without reading docs first.
- Run — usm init in the repo root
- Review — generated usmconfig.json — services match apps/*, shared and data paths detected correctly
- Correct — any misdetected services or missing shared packages by editing usmconfig.json before running usm scan
Guarantees
init-creates-config
usm init must create a valid usmconfig.json at the specified output path
Acceptance criteria:
- [ ] Config has version: '1'
- [ ] Config has name, services, shared, data, sources, outputs fields
- [ ] Config does not overwrite unless --force is passed
Test specifications
init-default
Given:
- repo_with_apps: true
When: first-run-init
Then:
- assertion: usmconfig.json created with services matching apps/*
- assertion: exit code 0
init-no-overwrite
Given:
- existing_config: true
Then:
- assertion: error thrown "File already exists"
- assertion: exit code 1
Implementation
- Primary: src/scan/init.ts
- Test code status: none
See Also
- usm/system