Skip to content

Comvi CLI

The Comvi CLI (@comvi/cli) lets you manage translations from your terminal. Sync translation files, generate TypeScript types, and integrate Comvi into your build pipeline.

Terminal window
npm install -D @comvi/cli

Or install globally:

Terminal window
npm install -g @comvi/cli
  1. Run comvi init to create a .comvirc.json in your project root.
  2. Set COMVI_API_KEY in your environment (or .env file).
  3. Run comvi typegen to generate TypeScript types.
Terminal window
npx comvi init
export COMVI_API_KEY=your_api_key_here
npx comvi typegen

The comvi init command creates a .comvirc.json in your project root. You can also write it by hand:

.comvirc.json
{
"apiBaseUrl": "https://api.comvi.io",
"outputPath": "src/types/i18n.d.ts",
"strictParams": true,
"translationsPath": "./src/locales",
"fileTemplate": "{namespace}/{languageTag}.json",
"format": "json",
"push": {
"forceMode": "ask"
},
"pull": {
"emptyDir": false
}
}
OptionTypeRequiredDefaultDescription
apiKeystringNo$COMVI_API_KEYAPI key for authentication. Prefer the environment variable
apiBaseUrlstringNo'https://api.comvi.io'Comvi API base URL
outputPathstringNo'src/types/i18n.d.ts'Output file path for generated TypeScript types
strictParamsbooleanNotrueRequire interpolation params in generated types
translationsPathstringNo'./src/locales'Directory for local translation JSON files
fileTemplatestringNo'{namespace}/{languageTag}.json'File layout for pull/push. Default namespace stored at root as {languageTag}.json; other namespaces nested under {namespace}/. Custom templates are matched literally
format'json'No'json'Translation file format
localesstring[]NoAll project localesRestrict pull/push to these BCP 47 locale tags. --locale flag overrides entirely
namespacesstring[]NoAll namespacesRestrict pull/push to these namespaces. --ns flag overrides entirely
push.forceMode'override' | 'keep' | 'ask' | 'abort'No'ask'Conflict handling for comvi push
pull.emptyDirbooleanNofalseClear the translations directory before comvi pull

Create a .comvirc.json configuration file. Validates your API key against the platform when COMVI_API_KEY is set.

Terminal window
comvi init

Download translations from the Comvi platform to your local project.

Terminal window
comvi pull

See comvi pull for full options.

Upload local translation files to the Comvi platform.

Terminal window
comvi push

See comvi push for full options.

Generate TypeScript type definitions from your translation keys.

Terminal window
comvi typegen

See comvi typegen for full options.

These flags apply to every command:

FlagDescription
--env-file <path>Load a specific .env file instead of auto-discovery
--no-env-fileSkip auto-loading .env entirely

The CLI reads these environment variables. They override values in .comvirc.json.

VariableDescription
COMVI_API_KEYAPI key for authenticating with the Comvi API. Overrides apiKey in config
COMVI_API_BASE_URLAPI base URL. Overrides apiBaseUrl in config
COMVI_NO_ENVSet to 1 to skip auto-loading .env (same as --no-env-file)
Terminal window
# Use environment variables in CI
COMVI_API_KEY=tlk_abc123 npx comvi pull
CodeMeaning
0Success
1General error (invalid config, missing API key, auth failure, network error, unexpected failure)
4Validation error (invalid locale/namespace filter, malformed config)

Add Comvi to your build pipeline to keep translations in sync:

.github/workflows/i18n.yml
name: Sync Translations
on:
push:
branches: [main]
jobs:
sync:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
- run: npm ci
- run: npx comvi pull
- run: npx comvi typegen
env:
COMVI_API_KEY: ${{ secrets.COMVI_API_KEY }}

See CI/CD Integration for more detailed workflows.