@eloqnt/cli 0.0.8 → 0.0.9
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 +8 -0
- package/dist/bin/eloqnt.mjs +1 -1
- package/dist/createSpinner-0uAr0__M.mjs +1 -0
- package/dist/{login-CDByiLM7.mjs → login-DGT76noz.mjs} +1 -1
- package/dist/translate-DfH-kzRD.mjs +8 -0
- package/package.json +2 -2
- package/dist/createSpinner-eJF8xlU7.mjs +0 -1
- package/dist/translate-MMptm6YR.mjs +0 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @eloqnt/cli
|
|
2
2
|
|
|
3
|
+
## 0.0.9
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 2571ceb: Run static post-translation checks (ICU placeholder parity) on every received translation, with up to two automatic re-translations on failure.
|
|
8
|
+
- Updated dependencies [2571ceb]
|
|
9
|
+
- @eloqnt/sdk@0.0.8
|
|
10
|
+
|
|
3
11
|
## 0.0.8
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
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,runMain as n}from"citty";try{e.loadEnvFile()}catch{}n(t({meta:{name:`eloqnt`,description:`AI-powered translations for developers`},subCommands:{lint:r(()=>import(`../lint-DJ_-UKqz.mjs`)),translate:r(()=>import(`../translate-
|
|
2
|
+
import e from"node:process";import{defineCommand as t,runMain as n}from"citty";try{e.loadEnvFile()}catch{}n(t({meta:{name:`eloqnt`,description:`AI-powered translations for developers`},subCommands:{lint:r(()=>import(`../lint-DJ_-UKqz.mjs`)),translate:r(()=>import(`../translate-DfH-kzRD.mjs`)),login:r(()=>import(`../login-DGT76noz.mjs`)),logout:r(()=>import(`../logout-BI-HnLL5.mjs`)),whoami:r(()=>import(`../whoami-VnvhpU5y.mjs`))}}));function r(e){return()=>e().then(e=>e.default)}export{};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"picocolors";import{spinner as t}from"@clack/prompts";function n({withGuide:n=!0}={}){let r=t({styleFrame:t=>e.cyan(t),withGuide:n});return{...r,start:e=>r.start(e&&`${e} `),message:e=>r.message(e&&`${e} `)}}export{n as t};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{t as e}from"./withErrorFormatting-BzsnYkDV.mjs";import{a as t,t as n}from"./urls-DdV5qJFG.mjs";import{t as r}from"./createSpinner-
|
|
1
|
+
import{t as e}from"./withErrorFormatting-BzsnYkDV.mjs";import{a as t,t as n}from"./urls-DdV5qJFG.mjs";import{t as r}from"./createSpinner-0uAr0__M.mjs";import{EloqntSdkError as i}from"@eloqnt/sdk";import a from"node:process";import{defineCommand as o}from"citty";import s from"picocolors";import{setTimeout as c}from"node:timers/promises";import{outro as l}from"@clack/prompts";import u from"open";function d(e){u(e).catch(()=>{})}const f=`eloqnt-cli`;var p=o({meta:{name:`login`,description:`Authenticates the CLI by storing an auth token locally.`},run:()=>e(async()=>{let e=n(),o=await fetch(`${e}/device/code`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({client_id:f})});if(!o.ok)throw new i(`ENGINE_UNREACHABLE`,`Couldn't start the login flow`,{details:`The auth server responded with ${o.status}.`,hint:`Check your connection and run eloqnt login again.`});let c=await o.json();a.stderr.write(`\n${s.cyan(`Log in to eloqnt studio`)}\n`),a.stderr.write(s.dim(`${c.verification_uri_complete}\n\n`)),d(c.verification_uri_complete);let u=a.stderr.isTTY?r():void 0;u?u.start(`Waiting for approval in the browser`):a.stderr.write(s.dim(`Waiting for approval in the browser …
|
|
2
2
|
`));let p=await m(e,c);if(!p.access_token)throw u?.stop(s.dim(`Login cancelled`)),new i(`NOT_AUTHENTICATED`,p.error_description??`Login failed`,{hint:`Run eloqnt login to try again.`});await t(p.access_token),u?(u.stop(s.dim(`Approved in the browser`)),l(s.green(`Logged in`))):a.stdout.write(`${s.green(`Logged in`)}\n`)})});async function m(e,t){let n=Date.now()+t.expires_in*1e3,r=t.interval;for(;Date.now()<n;){await c(r*1e3);let n=await(await fetch(`${e}/device/token`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({grant_type:`urn:ietf:params:oauth:grant-type:device_code`,device_code:t.device_code,client_id:f})})).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{p as default};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import{t as e}from"./defineEloqntCommand-BEnYhPuF.mjs";import{t}from"./resolvePaths-Bc7dGH8a.mjs";import{i as n,n as r}from"./urls-DdV5qJFG.mjs";import{t as i}from"./createSpinner-0uAr0__M.mjs";import{loadStyleguide as a,translate as o}from"@eloqnt/sdk";import s from"node:process";import{basename as c,dirname as l,relative as u}from"node:path";import d from"picocolors";function f(e,t={month:`short`,day:`numeric`}){return new Date(e).toLocaleDateString(`en-US`,t)}function p(e,t){s.stderr.write(`${e} ${d.dim(t)}\n`)}var m=e({meta:{name:`translate`,description:`Translate strings to target locales (defaults to missing ones).`,requiresLogin:!0},args:{id:{type:`string`,description:`(Re-)translate these message ids (comma-separated)`},locale:{type:`string`,description:`Restrict to these target locales (comma-separated)`}},async execute({config:e,rootDir:c,args:l}){let{messages:f,srcPath:m}=e,h=t(f.path,c),g=m?t(m,c):void 0,_=await a({cwd:c}),v=e.model?`local eloqnt/engine running ${typeof e.model==`string`?e.model:e.model.modelId}`:`hosted eloqnt/engine`,y=typeof l.locale==`string`?l.locale.split(`,`):Array.isArray(f.locales)?f.locales.filter(e=>e!==f.sourceLocale):void 0,b=`${y?.length?`${y.join(`, `)} `:``}via ${v}`,x=s.stderr.isTTY&&!l.json,S;function C(e){if(!l.json){if(e.phase===`context-enrichment`){e.state===`started`?(s.stderr.write(`
|
|
2
|
+
`),x?(S=i({withGuide:!1}),S.start(`Context enrichment running`)):s.stderr.write(d.dim(`Context enrichment running …
|
|
3
|
+
`))):e.state===`completed`?(S?.clear(),S=void 0,p(d.green(`✔`),`Context enrichment complete`)):(s.stderr.write(`
|
|
4
|
+
`),p(d.dim(`–`),"Skipped context enrichment — set `srcPath` to enable"));return}if(e.phase===`translate`){e.state===`started`?x?(S=i({withGuide:!1}),S.start(`Translating ${b}`)):s.stderr.write(d.dim(`Translating ${b} …\n`)):(S?.clear(),S=void 0,p(d.green(`✔`),`Translated ${b}`));return}e.state===`started`?x?(S=i({withGuide:!1}),S.start(`Post-translation checks running`)):s.stderr.write(d.dim(`Post-translation checks running …
|
|
5
|
+
`)):(S?.clear(),S=void 0,p(d.green(`✔`),`Post-translation checks done`))}}let w;try{w=await o({messagesPath:h,sourceLocale:f.sourceLocale,format:f.format,locales:f.locales,cwd:c,engineUrl:r(),languageModel:e.model,providerOptions:e.providerOptions,authToken:await n(),styleguide:_,ids:typeof l.id==`string`?l.id.split(`,`):void 0,onlyLocales:typeof l.locale==`string`?l.locale.split(`,`):void 0,srcPath:g,onProgress:C})}catch(e){throw S?.clear(),e}let T=s.cwd(),E=w.targets.flatMap(e=>e.files.map(e=>({file:u(T,e.file),count:e.translated.length})));return{result:w,rows:E,complete:w.complete}},render({result:e,rows:t,complete:n}){let r=Object.groupBy(t,e=>l(e.file));return`\n${Object.entries(r).map(([e,t=[]])=>{let n=Math.max(0,...t.map(e=>c(e.file).length)),r=t.map(e=>` ${c(e.file).padEnd(n)} ${e.count===0?d.dim(`Nothing to translate`):d.green(`${e.count} translated`)}`);return[d.dim(`${e}/`),...r].join(`
|
|
6
|
+
`)}).join(`
|
|
7
|
+
|
|
8
|
+
`)}\n\n${n?d.green(`✔ Project fully translated`):e.quota?d.yellow(`! Monthly included usage exhausted, translated as much as possible. Resets ${f(e.quota.resetsAt)}`):d.dim(`✗ Partially translated, run eloqnt lint to see what's left`)}`},json:({result:e})=>e});export{m as default};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eloqnt/cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.9",
|
|
4
4
|
"description": "CLI for eloqnt/studio",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"citty": "^0.1.6",
|
|
31
31
|
"open": "^11.0.0",
|
|
32
32
|
"picocolors": "^1.1.1",
|
|
33
|
-
"@eloqnt/sdk": "0.0.
|
|
33
|
+
"@eloqnt/sdk": "0.0.8"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@types/node": "^25.9.1"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import e from"picocolors";import{spinner as t}from"@clack/prompts";function n({withGuide:n=!0}={}){return t({styleFrame:t=>e.cyan(t),withGuide:n})}export{n as t};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./defineEloqntCommand-BEnYhPuF.mjs";import{t}from"./resolvePaths-Bc7dGH8a.mjs";import{i as n,n as r}from"./urls-DdV5qJFG.mjs";import{t as i}from"./createSpinner-eJF8xlU7.mjs";import{loadStyleguide as a,translate as o}from"@eloqnt/sdk";import s from"node:process";import{basename as c,dirname as l,relative as u}from"node:path";import d from"picocolors";function f(e,t={month:`short`,day:`numeric`}){return new Date(e).toLocaleDateString(`en-US`,t)}function p(e,t){s.stderr.write(`${e} ${d.dim(t)}\n`)}var m=e({meta:{name:`translate`,description:`Translate strings to target locales (defaults to missing ones).`,requiresLogin:!0},args:{id:{type:`string`,description:`(Re-)translate these message ids (comma-separated)`},locale:{type:`string`,description:`Restrict to these target locales (comma-separated)`}},async execute({config:e,rootDir:c,args:l}){let{messages:f,srcPath:m}=e,h=t(f.path,c),g=m?t(m,c):void 0,_=await a({cwd:c}),v=e.model?`local eloqnt/engine running ${typeof e.model==`string`?e.model:e.model.modelId}`:`hosted eloqnt/engine`,y=typeof l.locale==`string`?l.locale.split(`,`):Array.isArray(f.locales)?f.locales.filter(e=>e!==f.sourceLocale):void 0,b=`${y?.length?`${y.join(`, `)} `:``}via ${v}`,x=s.stderr.isTTY&&!l.json,S;function C(e){if(!l.json){if(e.phase===`source-scan`){e.state===`started`?(s.stderr.write(`
|
|
2
|
-
`),x?(S=i({withGuide:!1}),S.start(`Enriching context from source code`)):s.stderr.write(d.dim(`Enriching context from source code …
|
|
3
|
-
`))):e.state===`completed`?(S?.clear(),S=void 0,p(d.green(`✔`),`Enriched context from source code`)):(s.stderr.write(`
|
|
4
|
-
`),p(d.dim(`–`),"Skipped context enrichment — set `srcPath` to enable"));return}e.state===`started`?x?(S=i({withGuide:!1}),S.start(`Translating ${b}`)):s.stderr.write(d.dim(`Translating ${b} …\n`)):(S?.clear(),S=void 0,p(d.green(`✔`),`Translated ${b}`))}}let w;try{w=await o({messagesPath:h,sourceLocale:f.sourceLocale,format:f.format,locales:f.locales,cwd:c,engineUrl:r(),languageModel:e.model,providerOptions:e.providerOptions,authToken:await n(),styleguide:_,ids:typeof l.id==`string`?l.id.split(`,`):void 0,onlyLocales:typeof l.locale==`string`?l.locale.split(`,`):void 0,srcPath:g,onProgress:C})}catch(e){throw S?.clear(),e}let T=s.cwd(),E=w.targets.flatMap(e=>e.files.map(e=>({file:u(T,e.file),count:e.translated.length})));return{result:w,rows:E,complete:w.complete}},render({result:e,rows:t,complete:n}){let r=Object.groupBy(t,e=>l(e.file));return`\n${Object.entries(r).map(([e,t=[]])=>{let n=Math.max(0,...t.map(e=>c(e.file).length)),r=t.map(e=>` ${c(e.file).padEnd(n)} ${e.count===0?d.dim(`Nothing to translate`):d.green(`${e.count} translated`)}`);return[d.dim(`${e}/`),...r].join(`
|
|
5
|
-
`)}).join(`
|
|
6
|
-
|
|
7
|
-
`)}\n\n${n?d.green(`✔ Project fully translated`):e.quota?d.yellow(`! Monthly included usage exhausted, translated as much as possible. Resets ${f(e.quota.resetsAt)}`):d.dim(`✗ Partially translated, run eloqnt lint to see what's left`)}`},json:({result:e})=>e});export{m as default};
|