Comvi CLI
@comvi/cli moves translations between your repository and your Comvi project,
generates a TypeScript declaration from the project’s keys and checks local catalogs offline.
Install
Section titled “Install”npm install -D @comvi/clipnpm add -D @comvi/cliyarn add -D @comvi/clibun add -d @comvi/cliRun it as npx comvi <command> once it is a dev dependency, or as npx --package @comvi/cli comvi <command> with nothing installed.
Authenticate
Section titled “Authenticate”export COMVI_API_KEY=comvi_xxxxxxxxxxxxxxxxnpx comvi pullEvery command except comvi check reads COMVI_API_KEY. The key selects the project, so there is no project
id to configure. Create one under API keys. The CLI also loads
the nearest .env file before each command except comvi check, walking up from the working directory and
stopping at the first package.json, so COMVI_API_KEY=... in .env works with no
wrapper. Real environment variables always win over the file.
| Variable | Effect |
|---|---|
COMVI_API_KEY |
API key. Overrides apiKey in the config file |
COMVI_API_BASE_URL |
Overrides apiBaseUrl in the config file |
COMVI_NO_ENV=1 |
Skip auto-loading .env, same as --no-dotenv |
COMVI_DEBUG=1 |
Print to stderr which .env was loaded and how many entries it added or skipped |
Config file
Section titled “Config file”npx comvi init{ "apiBaseUrl": "https://api.comvi.io", "outputPath": "src/types/i18n.d.ts", "strictParams": true, "translationsPath": "./src/locales", "fileTemplate": "{namespace}/{languageTag}.json", "format": "json", "locales": ["en", "de"], "namespaces": ["common", "auth"], "push": { "forceMode": "ask" }, "pull": { "emptyDir": false }}comvi init writes .comvirc.json in the current directory without locales or
namespaces; add those by hand. It does write push and pull with their defaults,
"forceMode": "ask" and "emptyDir": false. The file is safe to commit because the
key stays in the environment. Commands find it by walking up from the working directory
and stopping at the first package.json, so in a monorepo each package needs its own file
or an explicit --config ../../.comvirc.json.
| Field | Default | Meaning |
|---|---|---|
apiKey |
$COMVI_API_KEY |
API key. Prefer the environment variable |
apiBaseUrl |
https://api.comvi.io |
Comvi API base URL |
outputPath |
src/types/i18n.d.ts |
Where comvi typegen writes the declaration |
strictParams |
true |
false makes every interpolation parameter optional |
augment |
package the app declares | Module the declaration augments, for a private wrapper package. See Type-check translation keys |
translationsPath |
./src/locales |
Directory for local translation files |
fileTemplate |
{namespace}/{languageTag}.json |
File layout for pull, push and check. With the default template the default namespace lives at the root as {languageTag}.json; a custom template is matched literally. Must contain {languageTag} and {namespace} once each and end in .json or .{extension}; comvi check also accepts a template without {namespace} |
format |
json |
Translation file format. Only json exists |
locales |
every locale | Restrict pull, push and check to these BCP-47 codes (pt-BR, zh-Hans). Without it, pull fetches every project locale and push and check read every local catalog. --locale replaces the list |
namespaces |
every namespace | Restrict pull, push and check to these namespaces. --ns replaces the list |
push.forceMode |
ask |
Conflict handling for comvi push: override, keep, ask or abort |
pull.emptyDir |
false |
Clear the pulled locales and namespaces after a successful fetch |
sourceLocale |
en |
Locale comvi check compares every other catalog with. --source overrides it |
check.identical |
false |
comvi check warns when a translation equals its source |
check.strict |
false |
comvi check fails on warnings too |
strictParams, pull.emptyDir, check.identical and check.strict must be JSON booleans: the string "false" fails
validation with exit 4 before any command that reads the file opens a connection. An empty locales or
namespaces list, a duplicate, or a non-string entry fails the same way. So does a field the
config does not have: the legacy languages and defaultNsName are rejected by name, with
locales named as the replacement for the first. Pull and push take the default namespace
from the project; comvi check, which never connects, calls it default.
comvi init options
Section titled “comvi init options”| Flag | Default | Meaning |
|---|---|---|
-k, --api-key <key> |
none | Write the key into the file. Prints a warning: arguments show up in process listings and shell history |
-u, --api-url <url> |
$COMVI_API_BASE_URL, else https://api.comvi.io |
apiBaseUrl to write. A malformed URL exits 4 and writes nothing |
-o, --output <path> |
src/types/i18n.d.ts |
outputPath to write |
--no-strict-params |
off | Write strictParams: false |
--translations-path <path> |
./src/locales |
translationsPath to write |
--file-template <template> |
{namespace}/{languageTag}.json |
fileTemplate to write |
--force |
off | Overwrite an existing .comvirc.json |
An existing file is left untouched and the command exits 4. --force rewrites the
whole file, dropping any locales and namespaces and resetting push and pull to their
defaults. When a key
is set, init validates it against the platform; a failed validation is a warning and the
file is still written.
Commands
Section titled “Commands”| Command | Purpose |
|---|---|
comvi pull |
Download translations from the project to local JSON files |
comvi push |
Upload local translation files to the project |
comvi translate |
Machine-translate the values the project is missing and write them to local files |
comvi typegen |
Generate a TypeScript declaration from the project’s keys |
comvi check |
Compare local catalogs with the source locale, offline, and exit 1 on errors unless --no-fail |
Global flags
Section titled “Global flags”| Flag | Meaning |
|---|---|
-V, --version |
Print the installed @comvi/cli version |
-h, --help |
Print usage for the program or one command |
--dotenv <path> |
Load one .env file instead of auto-discovery. A missing file exits 4. comvi check loads no .env and ignores it |
--no-dotenv |
Skip auto-loading .env |
The flag is --dotenv, not --env-file: Node claims --env-file across the whole command
line and exits 9 on a missing file before the CLI starts.
Exit codes
Section titled “Exit codes”Every command uses the same codes, so CI can act on the code alone. comvi init still writes
the config and only warns when the key cannot be validated.
| Code | Meaning | What to do |
|---|---|---|
0 |
Done, or findings under comvi check --no-fail |
Nothing |
1 |
The command ran and found a problem: a conflict under --force-mode abort, outdated types under typegen --check, errors under comvi check (warnings too with --strict) unless --no-fail, a value comvi translate could not translate; also a local failure such as a file that cannot be written |
Fix the content |
2 |
The platform was unreachable, timed out, answered a retryable status (408, 409, 425, 429 or 5xx), or sent an unexpected response; comvi translate also when its --timeout ends with values still missing |
Retry |
3 |
The API key was rejected, lacks the scope the command needs, its project no longer exists, or the account reached a plan or credit limit | Fix the key or plan |
4 |
Invalid input: configuration, flags, a catalog file push or check cannot read, a declaration typegen --check cannot read, a file pull --empty-dir cannot back up, a locale the project does not have (or the key may not read or write), nothing to push, --force-mode ask without a terminal when a conflict needs an answer, or a wrong apiBaseUrl |
Fix the input |
A missing or invalid .comvirc.json exits 4. One that exists but cannot be read, such as a
directory or a file without read permission, exits 1 in pull, push and typegen and
4 in comvi check. comvi check never contacts the platform, so it
never exits 2 or 3, and a missing .comvirc.json is not an error for it. Every case is on
comvi check.
Next steps
Section titled “Next steps”- comvi pull: download translations, filters and
--empty-dir. - comvi push: upload translations and resolve conflicts.
- comvi translate: fill the missing values with machine translation, in a terminal or a CI pull request.
- comvi typegen: generate types, watch mode and
--checkin CI. - comvi check: validate local catalogs offline, rules and exit codes.
- CI/CD integration: full pipeline examples.