@eloqnt/cli 0.6.1 → 0.6.3
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.
- package/CHANGELOG.md +17 -0
- package/README.md +95 -1
- package/dist/bin/eloqnt.mjs +1 -1
- package/dist/{login-DkoUYP1R.mjs → login-CeogRhyV.mjs} +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @eloqnt/cli
|
|
2
2
|
|
|
3
|
+
## 0.6.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [d2a5b84]
|
|
8
|
+
- @eloqnt/sdk@0.6.3
|
|
9
|
+
|
|
10
|
+
## 0.6.2
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- c03e374: Add a `missing-other-case` lint rule for a `plural`, `selectordinal`, or `select` statement without an `other` case, which throws where the message is formatted. Messages like these were previously skipped by every rule, so their ICU arguments now get checked too.
|
|
15
|
+
- c03e374: A translation no longer has to spell out every plural category its locale can select on ([ref](https://x.com/jamannnnnn/status/2082746902219559208)). The rule is replaced by two, since its halves answer to different authorities: `unreachable-plural-case` for a case the target locale never selects, and `inconsistent-exact-plurals` for `=0`-style cases that don't match the source.
|
|
16
|
+
- Updated dependencies [c03e374]
|
|
17
|
+
- Updated dependencies [c03e374]
|
|
18
|
+
- @eloqnt/sdk@0.6.2
|
|
19
|
+
|
|
3
20
|
## 0.6.1
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -1,3 +1,97 @@
|
|
|
1
1
|
# `@eloqnt/cli`
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
An AI-based toolchain that helps you ship high-quality translations.
|
|
4
|
+
|
|
5
|
+
[Documentation](https://studio.eloqnt.dev/docs) · [Configuration](https://studio.eloqnt.dev/docs/configuration)
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
The first step to high-quality translations is to lint your project for common problems:
|
|
10
|
+
|
|
11
|
+
```console
|
|
12
|
+
$ eloqnt lint
|
|
13
|
+
|
|
14
|
+
messages/es.json
|
|
15
|
+
│
|
|
16
|
+
│ "kFvGpR": "Tienes mensajes nuevos"
|
|
17
|
+
│ ─┬──────────────────────
|
|
18
|
+
│ ╰─ Missing ICU argument: {count} (inconsistent-args)
|
|
19
|
+
│
|
|
20
|
+
│ "X0ha1a": "Save changes"
|
|
21
|
+
│ ─┬────────────
|
|
22
|
+
│ ╰─ Missing translation in es.json (missing-translation)
|
|
23
|
+
|
|
24
|
+
✗ 1 error
|
|
25
|
+
! 1 warning
|
|
26
|
+
|
|
27
|
+
→ Run `eloqnt translate` to fill in 1 missing translation
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Linting runs static analysis on your source code and matches it against your messages, catching issues like unused messages, missing translations, broken ICU arguments, and more.
|
|
31
|
+
|
|
32
|
+
## Setup
|
|
33
|
+
|
|
34
|
+
### 1. Install the CLI
|
|
35
|
+
|
|
36
|
+
Add the CLI as a local project dependency:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
npm install @eloqnt/cli --save-dev
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
If you're in a monorepo, install it within local packages as needed.
|
|
43
|
+
|
|
44
|
+
### 2. Add a config file
|
|
45
|
+
|
|
46
|
+
Create a config file at `.eloqnt/config.ts`:
|
|
47
|
+
|
|
48
|
+
```ts
|
|
49
|
+
import {defineConfig} from '@eloqnt/cli';
|
|
50
|
+
|
|
51
|
+
export default defineConfig({
|
|
52
|
+
// The folder containing your source code
|
|
53
|
+
// (optional, only if you use next-intl)
|
|
54
|
+
srcPath: './src',
|
|
55
|
+
|
|
56
|
+
// Where and how you store your messages
|
|
57
|
+
messages: {
|
|
58
|
+
path: './messages',
|
|
59
|
+
locales: 'infer',
|
|
60
|
+
sourceLocale: 'en',
|
|
61
|
+
format: 'json'
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
All paths are relative to your project root. For more sophisticated setups like monorepos or when not using `next-intl`, see the [configuration docs](https://studio.eloqnt.dev/docs/configuration).
|
|
67
|
+
|
|
68
|
+
### 3. Lint your source code and messages
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
npx eloqnt lint
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
See [`eloqnt lint`](https://studio.eloqnt.dev/docs/cli/lint) for details.
|
|
75
|
+
|
|
76
|
+
## Start translating
|
|
77
|
+
|
|
78
|
+
Once linting works, you can optionally use [`eloqnt translate`](https://studio.eloqnt.dev/docs/cli/translate) to fill in any missing translations:
|
|
79
|
+
|
|
80
|
+
```console
|
|
81
|
+
$ eloqnt translate
|
|
82
|
+
|
|
83
|
+
✔ Context enrichment complete
|
|
84
|
+
✔ Styleguides loaded (global, es)
|
|
85
|
+
✔ Translated de, es via eloqnt/engine (hosted)
|
|
86
|
+
✔ Post-translation checks done
|
|
87
|
+
|
|
88
|
+
messages/
|
|
89
|
+
de.json 2 translated
|
|
90
|
+
es.json 2 translated
|
|
91
|
+
|
|
92
|
+
✔ Project fully translated
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Source strings are enriched with context from their call sites, [styleguides](https://studio.eloqnt.dev/docs/styleguides) steer tone and terminology, and post-translation checks retry anything that comes back wrong.
|
|
96
|
+
|
|
97
|
+
To get started with translating, [log into eloqnt/studio](https://studio.eloqnt.dev/login) first.
|
package/dist/bin/eloqnt.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import e from"node:process";import{defineCommand as t,renderUsage as n,runMain as r}from"citty";import i from"picocolors";var a=`0.6.
|
|
2
|
+
import e from"node:process";import{defineCommand as t,renderUsage as n,runMain as r}from"citty";import i from"picocolors";var a=`0.6.3`;try{e.loadEnvFile()}catch{}const o=t({meta:{name:`eloqnt`,version:a,description:`AI-powered translations for developers`},subCommands:{lint:d(()=>import(`../lint-C_GvlHIh.mjs`)),review:d(()=>import(`../review-C_Op7_7I.mjs`)),translate:d(()=>import(`../translate-0d7JNq0l.mjs`)),crowdin:d(()=>import(`../crowdin-BXlNSsuT.mjs`)),login:d(()=>import(`../login-CeogRhyV.mjs`)),logout:d(()=>import(`../logout-BjdvLusP.mjs`)),whoami:d(()=>import(`../whoami-CTueGAHT.mjs`))}}),s=e.argv.slice(2);r(o,{rawArgs:s.length===1&&s[0]===`-v`?[`--version`]:s,async showUsage(e,t){console.log(await n(e,t)),console.log(i.dim(`Docs: ${await c(e,t)}`))}});async function c(e,t){let n=(await u(e.meta))?.name,r=(await u(t?.meta))?.name,i=r===void 0||r===`eloqnt`?n:r;return i===void 0||i===`eloqnt`?`https://studio.eloqnt.dev/docs`:`https://studio.eloqnt.dev/docs/cli/${await l(i)}`}async function l(e){let t=o.subCommands??{};if(e in t)return e;for(let[n,r]of Object.entries(t)){let t=(await u(r))?.subCommands;if(t&&e in t)return n}return e}function u(e){return typeof e==`function`?e():e}function d(e){return()=>e().then(e=>e.default)}export{a as t};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import{t as e}from"./bin/eloqnt.mjs";import{t}from"./withErrorFormatting-CnMLjXSn.mjs";import{t as n}from"./createSpinner-BBkrpcrh.mjs";import{a as r,i,n as a,t as o}from"./urls-BrJoRsYB.mjs";import s from"node:process";import{defineCommand as c}from"citty";import l from"picocolors";import{EloqntSdkError as u,getAuthHeaders as d}from"@eloqnt/sdk/_internal";import{outro as f}from"@clack/prompts";import{hostname as p}from"node:os";import{setTimeout as m}from"node:timers/promises";import h from"open";function g(e){h(e).catch(()=>{})}const _=`eloqnt-cli`,v=`eloqnt-cli/${e} (${p()}; ${s.platform} ${s.arch}; node ${s.version})`;var y=c({meta:{name:`login`,description:`Authenticates the CLI by storing an auth token locally.`},run:()=>t(async()=>{let e=o(),t=await i();t&&await fetch(`${e}/revoke-session`,{method:`POST`,headers:{authorization:`Bearer ${t}`,"content-type":`application/json`,"user-agent":v},body:JSON.stringify({token:t})}).catch(()=>{});let c=await fetch(`${e}/device/code`,{method:`POST`,headers:{"content-type":`application/json`,"user-agent":v},body:JSON.stringify({client_id:_})});if(!c.ok)throw new u(`ENGINE_UNREACHABLE`,`Couldn't start the login flow`,{details:`The auth server responded with ${c.status}.`,hint:`Check your connection and run eloqnt login again.`});let d=await c.json();s.stderr.write(`\n${l.cyan(`Log in to eloqnt studio`)}\n`),s.stderr.write(l.dim(`${d.verification_uri_complete}\n\n`)),g(d.verification_uri_complete);let p=s.stderr.isTTY?n():void 0;p?p.start(`Waiting for approval in the browser`):s.stderr.write(l.dim(`Waiting for approval in the browser …
|
|
2
|
-
`));let m=await x(e,d);if(!m.access_token)throw p?.stop(l.dim(`Login
|
|
2
|
+
`));let m=await x(e,d);if(!m.access_token)throw p?.stop(l.dim(`Login canceled`)),new u(`NOT_AUTHENTICATED`,m.error_description??`Login failed`,{hint:`Run eloqnt login to try again.`});await r(m.access_token),p?(p.stop(l.dim(`Approved in the browser`)),f(l.green(`Logged in`))):s.stdout.write(`${l.green(`Logged in`)}\n`),await b(m.access_token)&&s.stderr.write(`\n${l.cyan(`→ Choose a plan at ${a()}/plans`)}\n`)})});async function b(e){try{let t=await fetch(new URL(`/api/engine/me`,a()),{headers:d(e)});if(!t.ok)return!1;let n=await t.json();return Array.isArray(n.plans)&&n.plans.length===0}catch{return!1}}async function x(e,t){let n=Date.now()+t.expires_in*1e3,r=t.interval;for(;Date.now()<n;){await m(r*1e3);let n=await(await fetch(`${e}/device/token`,{method:`POST`,headers:{"content-type":`application/json`,"user-agent":v},body:JSON.stringify({grant_type:`urn:ietf:params:oauth:grant-type:device_code`,device_code:t.device_code,client_id:_})})).json();if(n.access_token)return n;if(n.error!==`authorization_pending`){if(n.error===`slow_down`){r+=5;continue}return n}}return{error:`expired_token`,error_description:`The login request expired`}}export{y as default};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eloqnt/cli",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.3",
|
|
4
4
|
"description": "CLI for eloqnt/studio",
|
|
5
5
|
"homepage": "https://studio.eloqnt.dev",
|
|
6
6
|
"bin": {
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"citty": "^0.1.6",
|
|
27
27
|
"open": "^11.0.0",
|
|
28
28
|
"picocolors": "^1.1.1",
|
|
29
|
-
"@eloqnt/sdk": "0.6.
|
|
29
|
+
"@eloqnt/sdk": "0.6.3"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@types/node": "^25.9.1"
|