@eloqnt/cli 0.6.27 → 0.6.29

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 CHANGED
@@ -1,5 +1,22 @@
1
1
  # @eloqnt/cli
2
2
 
3
+ ## 0.6.29
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [73ef929]
8
+ - @eloqnt/sdk@0.6.27
9
+
10
+ ## 0.6.28
11
+
12
+ ### Patch Changes
13
+
14
+ - 9f98b5b: `ELOQNT_ENGINE_URL` now takes the production engine origin or a localhost address, and reports an `INVALID_ENGINE_URL` error for anything else.
15
+ - 9f98b5b: Publish under the MIT license, with a `LICENSE` file in the package.
16
+ - Updated dependencies [9f98b5b]
17
+ - Updated dependencies [9f98b5b]
18
+ - @eloqnt/sdk@0.6.26
19
+
3
20
  ## 0.6.27
4
21
 
5
22
  ### Patch Changes
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Jan Amann
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # `@eloqnt/cli`
2
2
 
3
- eloqnt/cli is a linter for your translation files. It catches errors before they ship, and fills the gaps with AI translation.
3
+ eloqnt/cli is a linter for your translation files. It catches errors before they ship, and optionally fills in missing translations.
4
4
 
5
5
  [Documentation](https://cli.eloqnt.dev/docs) · [Configuration](https://cli.eloqnt.dev/docs/configuration)
6
6
 
@@ -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.27`;try{e.loadEnvFile()}catch{}const o=t({meta:{name:`eloqnt`,version:a,description:`AI-powered translations for developers`},subCommands:{lint:d(()=>import(`../lint-Wu02Ge85.mjs`)),review:d(()=>import(`../review-Jq5qfN92.mjs`)),translate:d(()=>import(`../translate-Db4Yhr8o.mjs`)),crowdin:d(()=>import(`../crowdin-DdfREp0-.mjs`)),login:d(()=>import(`../login-BpNU31ln.mjs`)),logout:d(()=>import(`../logout-DSYs8Q7s.mjs`)),whoami:d(()=>import(`../whoami-CL3FnZLb.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://cli.eloqnt.dev/docs`:`https://cli.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};
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.29`;try{e.loadEnvFile()}catch{}const o=t({meta:{name:`eloqnt`,version:a,description:`AI-powered translations for developers`},subCommands:{lint:d(()=>import(`../lint-Wu02Ge85.mjs`)),review:d(()=>import(`../review-DF1pGY0a.mjs`)),translate:d(()=>import(`../translate-D4A7TVLU.mjs`)),crowdin:d(()=>import(`../crowdin-DdfREp0-.mjs`)),login:d(()=>import(`../login-cvA1zw4B.mjs`)),logout:d(()=>import(`../logout-BAr7ojyZ.mjs`)),whoami:d(()=>import(`../whoami-CUFPZPY4.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://cli.eloqnt.dev/docs`:`https://cli.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
- 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,n as i,o as a,r as o}from"./urls-C1kSCAFx.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=i(),t=await r();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/engine`)}\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 …
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,n as i,o as a,r as o}from"./urls-qvEAJDcV.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=i(),t=await r();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/engine`)}\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
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 a(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 ${o()}/plans`)}\n`)})});async function b(e){try{let t=await fetch(new URL(`/api/engine/me`,o()),{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};
@@ -1 +1 @@
1
- import{t as e}from"./withErrorFormatting-CnMLjXSn.mjs";import{a as t,i as n,n as r}from"./urls-C1kSCAFx.mjs";import i from"node:process";import{defineCommand as a}from"citty";import o from"picocolors";var s=a({meta:{name:`logout`,description:`Logs out of eloqnt/engine by removing a local auth token.`},run:()=>e(async()=>{let e=await t();e&&await fetch(`${r()}/revoke-session`,{method:`POST`,headers:{authorization:`Bearer ${e}`,"content-type":`application/json`},body:JSON.stringify({token:e})}).catch(()=>{});let a=await n();i.stdout.write(`${a||e?o.green(`Logged out`):o.dim(`Not logged in`)}\n`)})});export{s as default};
1
+ import{t as e}from"./withErrorFormatting-CnMLjXSn.mjs";import{a as t,i as n,n as r}from"./urls-qvEAJDcV.mjs";import i from"node:process";import{defineCommand as a}from"citty";import o from"picocolors";var s=a({meta:{name:`logout`,description:`Logs out of eloqnt/engine by removing a local auth token.`},run:()=>e(async()=>{let e=await t();e&&await fetch(`${r()}/revoke-session`,{method:`POST`,headers:{authorization:`Bearer ${e}`,"content-type":`application/json`},body:JSON.stringify({token:e})}).catch(()=>{});let a=await n();i.stdout.write(`${a||e?o.green(`Logged out`):o.dim(`Not logged in`)}\n`)})});export{s as default};
@@ -1 +1 @@
1
- import{defineCommand as e}from"citty";var t=e({meta:{name:`review`,description:`Review source strings and fix issues in place.`},setup({rawArgs:e}){e.find(e=>!e.startsWith(`-`))!==`source`&&e.unshift(`source`)},subCommands:{source:()=>import(`./source-CqF_hqe4.mjs`).then(e=>e.default)}});export{t as default};
1
+ import{defineCommand as e}from"citty";var t=e({meta:{name:`review`,description:`Review source strings and fix issues in place.`},setup({rawArgs:e}){e.find(e=>!e.startsWith(`-`))!==`source`&&e.unshift(`source`)},subCommands:{source:()=>import(`./source-P4NovuaN.mjs`).then(e=>e.default)}});export{t as default};
@@ -1,4 +1,4 @@
1
- import{t as e}from"./defineEloqntCommand-BNNDggcZ.mjs";import{t}from"./parseListArg-p5H1s5JC.mjs";import{t as n}from"./createSpinner-BBkrpcrh.mjs";import{n as r,t as i}from"./report-CEfrIjER.mjs";import{a,i as o,n as s,o as c,r as l}from"./stringWidth-DvyI3S_b.mjs";import{a as u,r as d}from"./urls-C1kSCAFx.mjs";import{n as f,r as p,t as m}from"./writeStep-CerCYWGN.mjs";import{reviewSource as h}from"@eloqnt/sdk";import g from"node:process";import _ from"picocolors";import{basename as v,dirname as y,relative as b}from"node:path";import{loadStyleguide as x}from"@eloqnt/sdk/_internal";var S=e({meta:{name:`source`,description:`Review source strings for errors and fix them in place.`,requiresLogin:!0},args:{id:{type:`string`,description:`(Re-)review these message ids (comma-separated)`}},async execute({config:e,rootDir:r,args:i}){let{messages:a,srcPath:o}=e,s=c(a.path,r),l=o?c(o,r):void 0,f=await x({rootDir:r,path:e.styleguides}),v=p(f,[a.sourceLocale]),y=e.model?`eloqnt/engine (${typeof e.model==`string`?e.model:e.model.modelId})`:`eloqnt/engine (hosted)`,S=g.stderr.isTTY&&!i.json,C;function w(e){if(!i.json){if(e.phase===`context-enrichment`){e.state===`started`?(g.stderr.write(`
1
+ import{t as e}from"./defineEloqntCommand-BNNDggcZ.mjs";import{t}from"./parseListArg-p5H1s5JC.mjs";import{t as n}from"./createSpinner-BBkrpcrh.mjs";import{n as r,t as i}from"./report-CEfrIjER.mjs";import{a,i as o,n as s,o as c,r as l}from"./stringWidth-DvyI3S_b.mjs";import{a as u,r as d}from"./urls-qvEAJDcV.mjs";import{n as f,r as p,t as m}from"./writeStep-CerCYWGN.mjs";import{reviewSource as h}from"@eloqnt/sdk";import g from"node:process";import _ from"picocolors";import{basename as v,dirname as y,relative as b}from"node:path";import{loadStyleguide as x}from"@eloqnt/sdk/_internal";var S=e({meta:{name:`source`,description:`Review source strings for errors and fix them in place.`,requiresLogin:!0},args:{id:{type:`string`,description:`(Re-)review these message ids (comma-separated)`}},async execute({config:e,rootDir:r,args:i}){let{messages:a,srcPath:o}=e,s=c(a.path,r),l=o?c(o,r):void 0,f=await x({rootDir:r,path:e.styleguides}),v=p(f,[a.sourceLocale]),y=e.model?`eloqnt/engine (${typeof e.model==`string`?e.model:e.model.modelId})`:`eloqnt/engine (hosted)`,S=g.stderr.isTTY&&!i.json,C;function w(e){if(!i.json){if(e.phase===`context-enrichment`){e.state===`started`?(g.stderr.write(`
2
2
  `),S?(C=n({withGuide:!1}),C.start(`Context enrichment running`)):g.stderr.write(_.dim(`Context enrichment running …
3
3
  `))):e.state===`completed`?(C?.clear(),C=void 0,m(_.green(`✔`),`Context enrichment complete`)):(g.stderr.write(`
4
4
  `),m(_.dim(`–`),"Skipped source code analysis due to absent `srcPath`"));return}e.state===`started`?(v?m(_.green(`✔`),v):m(_.dim(`–`),`No styleguides found`),S?(C=n({withGuide:!1}),C.start(`Reviewing source strings via ${y}`)):g.stderr.write(_.dim(`Reviewing source strings via ${y} …\n`))):(C?.clear(),C=void 0,m(_.green(`✔`),`Reviewed source strings via ${y}`))}}let T;try{T=await h({messagesPath:s,sourceLocale:a.sourceLocale,format:a.format,locales:a.locales,codes:a.codes,rootDir:r,engineUrl:d(),languageModel:e.model,authToken:await u(),styleguide:f,ids:t(i.id),srcPath:l,onProgress:w})}catch(e){throw C?.clear(),e}let E=g.cwd();return{result:{...T,files:T.files.map(e=>({...e,file:b(E,e.file)})),findings:T.findings.map(e=>({...e,file:e.file?b(E,e.file):void 0,sourceFiles:e.sourceFiles.map(e=>b(E,e))}))}}},render:({result:e})=>C(e),ok:({result:e})=>e.findings.every(e=>e.status===`fixed`),json:({result:e})=>e});function C(e,t=o()){let{findings:n,reviewed:r,missingTranslations:i,quota:a}=e,s=[],c=new Map;for(let t of n){let n=t.file??e.sourceLocale,r=c.get(n)??[];r.push(t),c.set(n,r)}for(let[e,n]of c){let r=[`${_.cyan(e)} ${_.dim(`(source locale)`)}`];for(let e of n)r.push(_.dim(`│`)),r.push(...w(e,t));s.push(r.join(`
@@ -1,4 +1,4 @@
1
- import{t as e}from"./defineEloqntCommand-BNNDggcZ.mjs";import{t}from"./parseListArg-p5H1s5JC.mjs";import{t as n}from"./createSpinner-BBkrpcrh.mjs";import{a as r,i,n as a,o}from"./stringWidth-DvyI3S_b.mjs";import{a as s,r as c,t as l}from"./urls-C1kSCAFx.mjs";import{n as u,r as d,t as f}from"./writeStep-CerCYWGN.mjs";import{translate as p}from"@eloqnt/sdk";import m from"node:process";import h from"picocolors";import{basename as g,dirname as _,relative as v}from"node:path";import{loadStyleguide as y}from"@eloqnt/sdk/_internal";var b=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:l,args:u}){let{messages:g,srcPath:_}=e,b=o(g.path,l),x=_?o(_,l):void 0,S=await y({rootDir:l,path:e.styleguides}),C=e.model?`eloqnt/engine (${typeof e.model==`string`?e.model:e.model.modelId})`:`eloqnt/engine (hosted)`,w=t(u.locale),T=w??(Array.isArray(g.locales)?g.locales.filter(e=>e!==g.sourceLocale):void 0),E=`${T?.length?`${T.join(`, `)} `:``}via ${C}`,D=d(S,T??Object.keys(S.byLocale)),O=m.stderr.isTTY&&!u.json,k;function A(e,t,n){let o=`(${t}/${n})`,s=i()-4,c=`Translating ${e}% done`;return a(s,[`Translating ${E} · ${e}% done ${o}`,`Translating ${E} · ${e}% done`,`Translating ${e}% done ${o}`,c])||r(c,s)}let j=0;function M(e){if(!u.json){if(e.phase===`context-enrichment`){e.state===`started`?(m.stderr.write(`
1
+ import{t as e}from"./defineEloqntCommand-BNNDggcZ.mjs";import{t}from"./parseListArg-p5H1s5JC.mjs";import{t as n}from"./createSpinner-BBkrpcrh.mjs";import{a as r,i,n as a,o}from"./stringWidth-DvyI3S_b.mjs";import{a as s,r as c,t as l}from"./urls-qvEAJDcV.mjs";import{n as u,r as d,t as f}from"./writeStep-CerCYWGN.mjs";import{translate as p}from"@eloqnt/sdk";import m from"node:process";import h from"picocolors";import{basename as g,dirname as _,relative as v}from"node:path";import{loadStyleguide as y}from"@eloqnt/sdk/_internal";var b=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:l,args:u}){let{messages:g,srcPath:_}=e,b=o(g.path,l),x=_?o(_,l):void 0,S=await y({rootDir:l,path:e.styleguides}),C=e.model?`eloqnt/engine (${typeof e.model==`string`?e.model:e.model.modelId})`:`eloqnt/engine (hosted)`,w=t(u.locale),T=w??(Array.isArray(g.locales)?g.locales.filter(e=>e!==g.sourceLocale):void 0),E=`${T?.length?`${T.join(`, `)} `:``}via ${C}`,D=d(S,T??Object.keys(S.byLocale)),O=m.stderr.isTTY&&!u.json,k;function A(e,t,n){let o=`(${t}/${n})`,s=i()-4,c=`Translating ${e}% done`;return a(s,[`Translating ${E} · ${e}% done ${o}`,`Translating ${E} · ${e}% done`,`Translating ${e}% done ${o}`,c])||r(c,s)}let j=0;function M(e){if(!u.json){if(e.phase===`context-enrichment`){e.state===`started`?(m.stderr.write(`
2
2
  `),O?(k=n({withGuide:!1}),k.start(`Context enrichment running`)):m.stderr.write(h.dim(`Context enrichment running …
3
3
  `))):e.state===`completed`?(k?.clear(),k=void 0,f(h.green(`✔`),`Context enrichment complete`)):(m.stderr.write(`
4
4
  `),f(h.dim(`–`),"Skipped context enrichment (no `srcPath` set)"));return}if(e.phase===`translate`){if(e.state===`started`)D?f(h.green(`✔`),D):f(h.dim(`–`),`No styleguides found`),O?(k=n({withGuide:!1}),k.start(`Translating ${E}`)):m.stderr.write(h.dim(`Translating ${E} …\n`));else if(e.state===`progress`){let t=Math.floor(e.completedStrings/e.totalStrings*100);if(O)k?.message(A(t,e.completedStrings,e.totalStrings));else{let n=Math.floor(t/25);n>j&&n<4&&(j=n,m.stderr.write(h.dim(`Translating ${t}% done (${e.completedStrings}/${e.totalStrings}) …\n`)))}}else e.state===`stopped`?(k?.clear(),k=void 0):(k?.clear(),k=void 0,f(h.green(`✔`),`Translated ${E}`));return}e.state===`started`?O?(k=n({withGuide:!1}),k.start(`Post-translation checks running`)):m.stderr.write(h.dim(`Post-translation checks running …
@@ -0,0 +1 @@
1
+ import e from"node:process";import{dirname as t,join as n}from"node:path";import{EloqntSdkError as r}from"@eloqnt/sdk/_internal";import{homedir as i}from"node:os";import{mkdir as a,readFile as o,rm as s,writeFile as c}from"node:fs/promises";function l(){let t=e.env.XDG_CONFIG_HOME??n(i(),`.config`);return n(t,`eloqnt`,`credentials.json`)}async function u(){if(e.env.ELOQNT_TOKEN)return e.env.ELOQNT_TOKEN;try{let e=await o(l(),`utf8`),t=JSON.parse(e);return typeof t.token==`string`?t.token:void 0}catch{return}}async function d(e){let n=l();return await a(t(n),{recursive:!0}),await c(n,`${JSON.stringify({token:e},null,2)}\n`,{mode:384}),n}async function f(){try{return await s(l()),!0}catch{return!1}}const p=`https://engine.eloqnt.dev`;function m(e,t){let n;try{n=new URL(e)}catch{throw new r(`INVALID_ENGINE_URL`,`Can't use ${e} as the engine URL`,{details:`${t} isn't a valid URL.`,hint:`Unset ${t} to use ${p}.`})}if(n.origin!==p&&n.hostname!==`localhost`)throw new r(`INVALID_ENGINE_URL`,`Can't use ${n.origin} as the engine URL`,{details:`${t} takes ${p} or a localhost address, and nothing else.`,hint:`Unset ${t} to use ${p}.`});return n.origin}function h(){return e.env.ELOQNT_ENGINE_URL===void 0?e.env.ELOQNT_STUDIO_URL===void 0?p:m(e.env.ELOQNT_STUDIO_URL,`ELOQNT_STUDIO_URL`):m(e.env.ELOQNT_ENGINE_URL,`ELOQNT_ENGINE_URL`)}function g(){return`${h()}/api/auth`}const _=`https://cli.eloqnt.dev`;export{u as a,f as i,g as n,d as o,h as r,_ as t};
@@ -1,2 +1,2 @@
1
- import{t as e}from"./defineEloqntCommand-BNNDggcZ.mjs";import{a as t,r as n}from"./urls-C1kSCAFx.mjs";import r from"picocolors";import{EloqntSdkError as i,MeResponseSchema as a,getAuthHeaders as o}from"@eloqnt/sdk/_internal";function s(e){return r.dim(e.padEnd(12))}var c=e({meta:{name:`whoami`,description:`Shows the logged-in user account.`},requiresConfig:!1,async execute(){let e=await t();if(!e)throw new i(`NOT_AUTHENTICATED`,`Not logged in`,{hint:`Run eloqnt login to authenticate.`});let r=await fetch(new URL(`/api/engine/me`,n()),{headers:o(e)});if(r.status===401)throw new i(`NOT_AUTHENTICATED`,`Your session has expired`,{hint:`Run eloqnt login to sign in again.`});if(!r.ok)throw new i(`ENGINE_ERROR`,`Sorry, we couldn't load your account`,{details:`The studio API responded with ${r.status}.`,hint:`This is on our end. Try again in a few minutes.`});let s=a.safeParse(await r.json());if(!s.success)throw new i(`ENGINE_ERROR`,`Sorry, we couldn't load your account`,{details:`The studio API returned an unexpected shape.`,hint:`This is on our end. Try again in a few minutes.`});let{user:c,plans:l,hosted:u}=s.data;return{email:c.email,plans:l,hosted:u}},render:({email:e,plans:t,hosted:i})=>{let a=[`${s(`Email:`)}${e}`,`${s(`Plan:`)}${l(t,i)}`];return i&&a.push(`${s(`Quota used:`)}${u(i)}`),t.length===0&&a.push(``,r.cyan(`→ Choose a plan at ${n()}/plans`)),a.join(`
1
+ import{t as e}from"./defineEloqntCommand-BNNDggcZ.mjs";import{a as t,r as n}from"./urls-qvEAJDcV.mjs";import r from"picocolors";import{EloqntSdkError as i,MeResponseSchema as a,getAuthHeaders as o}from"@eloqnt/sdk/_internal";function s(e){return r.dim(e.padEnd(12))}var c=e({meta:{name:`whoami`,description:`Shows the logged-in user account.`},requiresConfig:!1,async execute(){let e=await t();if(!e)throw new i(`NOT_AUTHENTICATED`,`Not logged in`,{hint:`Run eloqnt login to authenticate.`});let r=await fetch(new URL(`/api/engine/me`,n()),{headers:o(e)});if(r.status===401)throw new i(`NOT_AUTHENTICATED`,`Your session has expired`,{hint:`Run eloqnt login to sign in again.`});if(!r.ok)throw new i(`ENGINE_ERROR`,`Sorry, we couldn't load your account`,{details:`The studio API responded with ${r.status}.`,hint:`This is on our end. Try again in a few minutes.`});let s=a.safeParse(await r.json());if(!s.success)throw new i(`ENGINE_ERROR`,`Sorry, we couldn't load your account`,{details:`The studio API returned an unexpected shape.`,hint:`This is on our end. Try again in a few minutes.`});let{user:c,plans:l,hosted:u}=s.data;return{email:c.email,plans:l,hosted:u}},render:({email:e,plans:t,hosted:i})=>{let a=[`${s(`Email:`)}${e}`,`${s(`Plan:`)}${l(t,i)}`];return i&&a.push(`${s(`Quota used:`)}${u(i)}`),t.length===0&&a.push(``,r.cyan(`→ Choose a plan at ${n()}/plans`)),a.join(`
2
2
  `)},json:e=>e});function l(e,t){if(e.length===0)return r.yellow(`none`);let n=e.map(e=>e===`hosted`?`Hosted model`:`Bring your own model`),i=t?.status===`trialing`?r.dim(` (trial, includes 1/4 of monthly usage)`):``;return r.green(n.join(` + `))+i}function u(e){let{usedPercent:t,resetsAt:n}=e,i=`${t}%`;return`${t>=100?r.red(i):t>=80?r.yellow(i):r.green(i)} (resets ${new Intl.DateTimeFormat(`en-US`,{month:`short`,day:`numeric`}).format(new Date(n))})`}export{c as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eloqnt/cli",
3
- "version": "0.6.27",
3
+ "version": "0.6.29",
4
4
  "description": "A linter for your translation files, with AI translation built in.",
5
5
  "keywords": [
6
6
  "i18n",
@@ -12,13 +12,15 @@
12
12
  "translation"
13
13
  ],
14
14
  "homepage": "https://cli.eloqnt.dev",
15
+ "license": "MIT",
15
16
  "bin": {
16
17
  "eloqnt": "./dist/bin/eloqnt.mjs"
17
18
  },
18
19
  "files": [
19
20
  "dist",
20
21
  "!dist/**/*.map",
21
- "CHANGELOG.md"
22
+ "CHANGELOG.md",
23
+ "LICENSE"
22
24
  ],
23
25
  "type": "module",
24
26
  "exports": {
@@ -35,7 +37,7 @@
35
37
  "citty": "^0.1.6",
36
38
  "open": "^11.0.0",
37
39
  "picocolors": "^1.1.1",
38
- "@eloqnt/sdk": "0.6.25"
40
+ "@eloqnt/sdk": "0.6.27"
39
41
  },
40
42
  "devDependencies": {
41
43
  "@types/node": "^25.9.5"
@@ -1 +0,0 @@
1
- import e from"node:process";import{dirname as t,join as n}from"node:path";import{homedir as r}from"node:os";import{mkdir as i,readFile as a,rm as o,writeFile as s}from"node:fs/promises";function c(){let t=e.env.XDG_CONFIG_HOME??n(r(),`.config`);return n(t,`eloqnt`,`credentials.json`)}async function l(){if(e.env.ELOQNT_TOKEN)return e.env.ELOQNT_TOKEN;try{let e=await a(c(),`utf8`),t=JSON.parse(e);return typeof t.token==`string`?t.token:void 0}catch{return}}async function u(e){let n=c();return await i(t(n),{recursive:!0}),await s(n,`${JSON.stringify({token:e},null,2)}\n`,{mode:384}),n}async function d(){try{return await o(c()),!0}catch{return!1}}function f(){return e.env.ELOQNT_ENGINE_URL??e.env.ELOQNT_STUDIO_URL??`https://engine.eloqnt.dev`}function p(){return`${f()}/api/auth`}const m=`https://cli.eloqnt.dev`;export{l as a,d as i,p as n,u as o,f as r,m as t};