@quaso-i18n/cli 1.0.0-rc.2 → 1.0.0-rc.2.main.g0745fee

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +77 -54
  2. package/package.json +1 -1
  3. package/quaso.mjs +1571 -136
package/README.md CHANGED
@@ -1,80 +1,103 @@
1
1
  # @quaso-i18n/cli
2
2
 
3
- The command line of Quaso, open-source localization for i18next JSON files. It uploads your source
4
- files to your team's Quaso instance, writes the translations back into your repository, shows
5
- progress, holds a release back when translations are missing, and imports the translations you
6
- already have. It never asks anything, prints JSON with `--json`, and its exit codes say what
7
- happened, so it works the same on a laptop, in CI and for AI agents.
3
+ Quaso's command-line interface (CLI) uploads i18next JSON v4 and Markdown source files, downloads translations,
4
+ starts translation jobs, checks progress, and imports existing translations. Commands do not
5
+ prompt for input. JSON output and exit codes support scripts, continuous integration (CI), and AI
6
+ agents.
8
7
 
9
- It runs on Node 22 or later and Deno 2.9 or later: one file, no dependencies.
8
+ ## Quick start
9
+
10
+ You need a Quaso instance and an API key with the `upload` scope. Create the key while signed in as an administrator,
11
+ in **Account → API keys**. The CLI runs on Node 22 or later and Deno 2.9 or later. Its published
12
+ package contains one JavaScript file with no separate runtime dependencies.
13
+
14
+ These examples follow current `main`. For a tagged release, use the matching CLI version and its
15
+ documentation. Install the CLI in your game repository:
10
16
 
11
17
  ```sh
12
- npm install --save-dev @quaso-i18n/cli # then: npx quaso …
13
- deno run -A npm:@quaso-i18n/cli status # or with Deno, from npm
18
+ npm install --save-dev @quaso-i18n/cli@main
19
+ export QUASO_HOSTNAME=translate.yourgame.com
20
+ export QUASO_API_KEY='your upload API key'
21
+ npx quaso init --languages de,fr,pl
14
22
  ```
15
23
 
16
- ## Connecting
24
+ Replace the hostname and key with your values. These environment commands use a POSIX shell.
25
+ Check the generated `quaso.config.json` before uploading: by default it reads English source files
26
+ from `src/locales/en/**/*.json` and writes translations to `src/locales/{lang}/{path}`.
17
27
 
18
28
  ```sh
19
- export QUASO_HOSTNAME=translate.yourgame.com # https is assumed; http://localhost:8000 works too
20
- export QUASO_API_KEY=qso_… # read scope: download, status; upload scope: upload, import
29
+ npx quaso upload --dry-run
30
+ npx quaso upload
31
+ npx quaso download
32
+ npx quaso status --fail-on untranslated
21
33
  ```
22
34
 
23
- The API key only ever comes from the environment. `"hostname"` in the config file is a fallback for
24
- `QUASO_HOSTNAME`.
35
+ Translate on the website between upload and download. With a Gemini key configured, use
36
+ `npx quaso translate` to start and wait for a translation job. Upload can also start a job when
37
+ automatic translation is enabled; use `npx quaso upload --wait` to wait for it.
25
38
 
26
- ## The config file
39
+ For Deno, replace `npx quaso` with `deno run -A npm:@quaso-i18n/cli@main`.
27
40
 
28
- `quaso.config.json`, in the current folder or the nearest parent (`quaso init` writes one):
41
+ ## Connecting
29
42
 
30
- ```json
31
- {
32
- "sourceLanguage": "en",
33
- "languages": ["de", "fr", "pl", "ja", "zh-Hans"],
34
- "languageMapping": { "zh-Hans": "zh-CN" },
35
- "files": [{ "source": "src/locales/en/**/*.json", "translation": "src/locales/{lang}/{path}" }],
36
- "limits": [{ "file": "store.json", "key": "title", "maxLength": 30 }]
37
- }
38
- ```
43
+ `QUASO_HOSTNAME` accepts a hostname, which uses HTTPS, or a full URL such as
44
+ `http://localhost:8000`; plain `http://` is only for `localhost`, `127.0.0.1` and `[::1]`. The API
45
+ key comes only from `QUASO_API_KEY`; never commit it. With a key set, the CLI only connects to
46
+ `QUASO_HOSTNAME` and refuses a `hostname` that only the config file names, so a cloned repository
47
+ can't send your key to its own server.
39
48
 
40
- `{lang}` is the language as your game names it (after `languageMapping`); `{path}` is the source
41
- file's path below the folder where the glob starts.
49
+ For an administrator's key, the `read` scope permits download and status; `upload` also permits
50
+ upload, import, and translation jobs. Each key follows its creator's current permissions. A
51
+ manager's upload key can translate assigned languages but cannot upload, import, download, or
52
+ read status. Deleting the creator's account disables the key. Commit the config and package lockfile so the team shares the same
53
+ paths and CLI version.
42
54
 
43
55
  ## Commands
44
56
 
45
- | Command | Does | Options |
46
- | ----------------------------- | ----------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------- |
47
- | `quaso init` | writes a starter `quaso.config.json`, and never overwrites one | `--languages` (required), `--source`, `--files`, `--translation` |
48
- | `quaso upload` | sends the source files and reports what was added, changed and removed | `--dry-run`, `--file`, `--rename old=new`, `--wait` |
49
- | `quaso download` | writes every language's files, skipping files that haven't changed | `--dry-run`, `--language`, `--file`, `--prune` |
50
- | `quaso translate` | asks the instance's LLM to translate untranslated strings, and waits for it | `--language`, `--file`, `--retranslate`, `--instruction`, `--model`, `--no-wait`, `--dry-run` |
51
- | `quaso status` | shows progress per language: untranslated, green, blue, outdated, pending, QA | `--language`, `--fail-on untranslated` (or `outdated`, `green`) |
52
- | `quaso import` | imports existing translation files | `--as green` or `--as blue`, `--language`, `--file`, `--overwrite`, `--keep-identical`, `--dry-run` |
53
- | `quaso version`, `quaso help` | print the version, or the help of a command | |
57
+ Run `npx quaso <command> --help` for every option. The main commands are:
58
+
59
+ | Command | Purpose |
60
+ | ----------------- | ----------------------------------------------------------------------------------------- |
61
+ | `init` | Create a config; use `--from-crowdin` to convert a Crowdin layout. |
62
+ | `upload` | Send source files and report changes; preview with `--dry-run`. |
63
+ | `download` | Write translations; use `--at` for a published version from a past time. |
64
+ | `translate` | Start a translation job and wait; preview its scope with `--dry-run`. |
65
+ | `status` | Show progress; use `--fail-on untranslated,outdated,green` to enforce release conditions. |
66
+ | `import` | Read existing translations as `--as green` or `--as blue`; preview with `--dry-run`. |
67
+ | `version`, `help` | Print the version or command help. |
54
68
 
55
- Every command takes `--json` (one JSON document on stdout, with a `schemaVersion`), `--cwd <dir>`,
56
- `--config <path>` and `--help`. Results go to stdout, progress and errors to stderr; colours only in
57
- a terminal, and never with `NO_COLOR`.
69
+ By default, download includes current accepted values, including outdated translations. Pending suggestions
70
+ are excluded. Missing translations use source text unless the config sets `untranslated` to
71
+ `omit`. Set `outdated` to `omit` to leave out older-source translations. Your app must supply
72
+ source-language text for omitted entries. `status --fail-on` has no condition for quality assurance (QA) errors; review those counts
73
+ separately.
74
+
75
+ Every command accepts `--json`, `--cwd <dir>`, `--config <path>`, `--help`, and `--version`.
76
+ With `--json`, the CLI writes one JSON result or handled error to stdout, with a `schemaVersion`.
77
+ Progress and errors go to stderr. Set `NO_COLOR` to disable terminal colors.
58
78
 
59
79
  ## Exit codes
60
80
 
61
- | Code | Meaning |
62
- | ---- | ---------------------------------------------------------------------- |
63
- | 0 | success |
64
- | 1 | unexpected error |
65
- | 2 | bad usage or invalid config |
66
- | 3 | authentication or permission problem (missing API key, wrong scope) |
67
- | 4 | network error or server unavailable (safe to retry) |
68
- | 5 | invalid source file (JSON syntax, duplicate key) |
69
- | 6 | finished, but some items were refused or failed; the output lists them |
70
- | 7 | the `status --fail-on` condition is met |
81
+ | Code | Meaning |
82
+ | ---- | ----------------------------------------------------------------------- |
83
+ | 0 | Success. |
84
+ | 1 | Unexpected error. |
85
+ | 2 | Invalid usage or config. |
86
+ | 3 | Authentication or permission problem. |
87
+ | 4 | Network or server failure; check the instance before repeating a write. |
88
+ | 5 | Invalid source file, such as a duplicate JSON key. |
89
+ | 6 | Some items were refused or failed; read the result for details. |
90
+ | 7 | A `status --fail-on` condition is met. |
71
91
 
72
92
  ## Safety
73
93
 
74
- The CLI computes every output path itself from the config and the languages it asked for, and
75
- refuses to write a source file, the source language, a file a `source` glob would find, or anything
76
- outside the folder of `quaso.config.json`. It only sends files from inside that folder, never
77
- through a symbolic link that leads out of it. It never starts other programs and never runs git.
94
+ Download keeps files with local edits and exits with code 6; import the changes or review them
95
+ before using `--overwrite-local`. Keep `.quaso/` ignored by Git. `--prune` does not protect local
96
+ edits in files whose source is gone, so check its dry-run list before deleting them.
97
+
98
+ The CLI checks output paths before writing and refuses writes outside the project folder or over
99
+ source files. It does not follow HTTP redirects, start other programs, or run Git. Use previews,
100
+ review downloaded changes, and run your game tests before committing translations.
78
101
 
79
- The full guide, with every option, JSON output, CI and AI agents, is `docs/cli.md` in the Quaso
80
- repository.
102
+ See the [full CLI reference](https://github.com/explodi/quaso/blob/main/docs/cli.md) for config
103
+ fields, command options, JSON results, retry behavior, and safety checks.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quaso-i18n/cli",
3
- "version": "1.0.0-rc.2",
3
+ "version": "1.0.0-rc.2.main.g0745fee",
4
4
  "description": "The command line of Quaso, localization for i18next JSON files: upload, download, status and import, from a laptop, from CI and for AI agents",
5
5
  "license": "MIT",
6
6
  "type": "module",