@eloqnt/cli 0.0.3 → 0.0.5

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 ADDED
@@ -0,0 +1,42 @@
1
+ # @eloqnt/cli
2
+
3
+ ## 0.0.5
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [cc5762c]
8
+ - @eloqnt/sdk@0.0.5
9
+
10
+ ## 0.0.4
11
+
12
+ ### Patch Changes
13
+
14
+ - 0ada64a: Refine CLI UX and align account commands with the shared error contract.
15
+ - 6159c7b: Handle messages split across several `messages.path` folders correctly, including a new `duplicate-id` lint rule for ids repeated across folders.
16
+ - Updated dependencies [c30db07]
17
+ - Updated dependencies [6159c7b]
18
+ - @eloqnt/sdk@0.0.4
19
+
20
+ ## 0.0.3
21
+
22
+ ### Patch Changes
23
+
24
+ - ae30b1e: The `inconsistent-args` lint rule now catches rich tags (`<b>…</b>`) a translation drops or invents, not just `{argument}` placeholders. Placeholders are compared by their literal token, so a `<name>` tag never stands in for a `{name}` argument, and the reporter underlines the stray tag in the value.
25
+ - Updated dependencies [ae30b1e]
26
+ - @eloqnt/sdk@0.0.3
27
+
28
+ ## 0.0.2
29
+
30
+ ### Patch Changes
31
+
32
+ - f50af2b: Make CLI errors friendlier.
33
+ - Updated dependencies [f50af2b]
34
+ - @eloqnt/sdk@0.0.2
35
+
36
+ ## 0.0.1
37
+
38
+ ### Patch Changes
39
+
40
+ - 4b62102: Exercise the automated release pipeline. No functional changes since the initial 0.0.0 publish.
41
+ - Updated dependencies [4b62102]
42
+ - @eloqnt/sdk@0.0.1
@@ -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:{status:r(()=>import(`../status-B4lvo1TO.mjs`)),lint:r(()=>import(`../lint-BGq3Vdt3.mjs`)),translate:r(()=>import(`../translate-Cz-hJ6Gv.mjs`)),login:r(()=>import(`../login-qJXHaxC9.mjs`)),logout:r(()=>import(`../logout-Dv-YLq8P.mjs`)),whoami:r(()=>import(`../whoami-CR34U7uT.mjs`))}}));function r(e){return()=>e().then(e=>e.default)}export{};
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-EEWge-v7.mjs`)),translate:r(()=>import(`../translate-BjGIVueO.mjs`)),login:r(()=>import(`../login-I-q8XlUT.mjs`)),logout:r(()=>import(`../logout-BI-HnLL5.mjs`)),whoami:r(()=>import(`../whoami-BO35bAgR.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(){return t({styleFrame:t=>e.cyan(t)})}export{n as t};
@@ -0,0 +1 @@
1
+ import{t as e}from"./withErrorFormatting-BzsnYkDV.mjs";import{loadConfig as t}from"@eloqnt/sdk";import n from"node:process";import{defineCommand as r}from"citty";function i(i){let a=i.requiresConfig!==!1;return r({meta:i.meta,args:{...a&&{config:{type:`string`,description:`Path to the eloqnt config file (defaults to .eloqnt/config.{ts,mts,js,mjs})`}},json:{type:`boolean`,description:`Output the result as JSON`,default:!1},...i.args},run({args:r}){return e(async()=>{let e;if(a){let{config:n,rootDir:i}=await t({configPath:r.config});e={config:n,rootDir:i,args:r}}else e={config:void 0,rootDir:n.cwd(),args:r};let o=await i.execute(e),s=r.json?JSON.stringify(i.json?i.json(o):o,null,2):i.render(o);n.stdout.write(`${s}\n`),i.ok&&!i.ok(o)&&(n.exitCode=1)})}})}export{i as t};
@@ -1,4 +1,4 @@
1
- import{t as e}from"./defineEloqntCommand-CsM_g_XS.mjs";import{lint as t}from"@eloqnt/sdk";import n from"node:process";import{relative as r,resolve as i}from"node:path";import a from"picocolors";const o=new Intl.Segmenter,s=[[4352,4447],[9001,9002],[11904,12350],[12353,13311],[13312,19903],[19968,40959],[40960,42191],[44032,55203],[63744,64255],[65040,65049],[65072,65135],[65280,65376],[65504,65510],[126976,127743],[127744,129791],[131072,262141]];function c(e){let t=[];for(let{segment:n}of o.segment(e))t.push({text:n,width:u(n)});return t}function l(e){let t=0;for(let{segment:n}of o.segment(e))t+=u(n);return t}function u(e){let t=e.codePointAt(0)??0;return d(t)?0:s.some(([e,n])=>t>=e&&t<=n)?2:1}function d(e){return e<=31||e>=127&&e<=159||e>=768&&e<=879||e>=8203&&e<=8207||e>=8232&&e<=8238||e>=8288&&e<=8292||e===65279}var f=e({meta:{name:`lint`,description:`Statically analyze your source code and messages for common problems.`},async execute({config:e,rootDir:a}){let{messages:o,srcPath:s}=e;function c(e){return(Array.isArray(e)?e:[e]).map(e=>i(a,e))}let l=await t({messagesPath:c(o.path),sourceLocale:o.sourceLocale,format:o.format,locales:o.locales,srcPath:s?c(s):void 0,cwd:a}),u=n.cwd();return{issues:l.map(e=>e.location?{...e,location:{...e.location,file:r(u,e.location.file)}}:e),sourceLocale:o.sourceLocale}},render:({issues:e,sourceLocale:t})=>p(e,t),ok:({issues:e})=>e.length===0,json:({issues:e})=>e});function p(e,t){if(e.length===0)return`\n${a.green(`No issues found`)}`;let n=Object.groupBy(e,e=>e.location?.file??e.locale),r=m(Object.entries(n),t).map(([e,n])=>h(e,n,n[0].locale===t)),i=`${e.length} ${e.length===1?`issue`:`issues`}`,o=a.bold(a.red(`${i} found`));return`\n${[...r,o].join(`
1
+ import{t as e}from"./defineEloqntCommand-BEnYhPuF.mjs";import{lint as t}from"@eloqnt/sdk";import n from"node:process";import{relative as r,resolve as i}from"node:path";import a from"picocolors";const o=new Intl.Segmenter,s=[[4352,4447],[9001,9002],[11904,12350],[12353,13311],[13312,19903],[19968,40959],[40960,42191],[44032,55203],[63744,64255],[65040,65049],[65072,65135],[65280,65376],[65504,65510],[126976,127743],[127744,129791],[131072,262141]];function c(e){let t=[];for(let{segment:n}of o.segment(e))t.push({text:n,width:u(n)});return t}function l(e){let t=0;for(let{segment:n}of o.segment(e))t+=u(n);return t}function u(e){let t=e.codePointAt(0)??0;return d(t)?0:s.some(([e,n])=>t>=e&&t<=n)?2:1}function d(e){return e<=31||e>=127&&e<=159||e>=768&&e<=879||e>=8203&&e<=8207||e>=8232&&e<=8238||e>=8288&&e<=8292||e===65279}var f=e({meta:{name:`lint`,description:`Statically analyze your source code and messages for common problems.`},async execute({config:e,rootDir:a}){let{messages:o,srcPath:s}=e;function c(e){return(Array.isArray(e)?e:[e]).map(e=>i(a,e))}let l=await t({messagesPath:c(o.path),sourceLocale:o.sourceLocale,format:o.format,locales:o.locales,srcPath:s?c(s):void 0,cwd:a}),u=n.cwd();return{issues:l.map(e=>e.location?{...e,location:{...e.location,file:r(u,e.location.file)}}:e),sourceLocale:o.sourceLocale}},render:({issues:e,sourceLocale:t})=>p(e,t),ok:({issues:e})=>e.length===0,json:({issues:e})=>e});function p(e,t){if(e.length===0)return`\n${a.green(`No issues found`)}\n`;let n=Object.groupBy(e,e=>e.location?.file??e.locale),r=m(Object.entries(n),t).map(([e,n])=>h(e,n,n[0].locale===t)),i=`${e.length} ${e.length===1?`issue`:`issues`}`,o=a.bold(a.red(`✗ ${i} found`)),s=e.filter(e=>e.rule===`missing-translation`).length,c=s?`${o}\n${a.dim(`→ Run \`eloqnt translate\` to fill in ${s} missing ${s===1?`translation`:`translations`}`)}`:o;return`\n${[...r,c].join(`
2
2
 
3
- `)}`}function m(e,t){let n=e.findIndex(([,e])=>e[0].locale===t);if(n<=0)return e;let r=[...e],[i]=r.splice(n,1);return[i,...r]}function h(e,t,n){let r=[n?`${a.cyan(e)} ${a.dim(`(source locale)`)}`:a.cyan(e)];for(let e of t){r.push(a.dim(`│`));let{content:t,span:n}=g(e);r.push(y(t)),r.push(...v(n,e.message,e.rule))}return r.join(`
3
+ `)}\n`}function m(e,t){let n=e.findIndex(([,e])=>e[0].locale===t);if(n<=0)return e;let r=[...e],[i]=r.splice(n,1);return[i,...r]}function h(e,t,n){let r=[n?`${a.cyan(e)} ${a.dim(`(source locale)`)}`:a.cyan(e)];for(let e of t){r.push(a.dim(`│`));let{content:t,span:n}=g(e);r.push(y(t)),r.push(...v(n,e.message,e.rule))}return r.join(`
4
4
  `)}function g(e){let t=`"${e.key}"`,n=e.targetMessage??e.sourceMessage,r=_(t),i=e.highlight?.type===`value`||e.highlight?.type===`argument`,o=i?a.dim(t):t,s=a.dim(`: `),c=l(t);if(n!==void 0&&e.highlight?.type===`argument`){let t=w(n),i=e.highlight.token,a=t.indexOf(i);if(a>=0){let{inner:e,offset:n}=b(t,a,i.length,r);return{content:`${o}${s}"${e}"`,span:{column:c+3+n,length:l(i)}}}}let u=n===void 0?`"…"`:`"${T(w(n),r)}"`,d=`${o}${s}${i?u:a.dim(u)}`;return n!==void 0&&e.highlight?.type===`value`?{content:d,span:{column:c+2,length:l(u)}}:{content:d,span:{column:0,length:c}}}function _(e){let t=3+l(e)+2+2;return Math.max(24,Math.min(48,80-t))}function v(e,t,n){let r=Math.min(1,e.length-1),i=`─`.repeat(r)+`┬`+`─`.repeat(e.length-1-r),o=`${t} ${a.dim(`(${n})`)}`;return[y(` `.repeat(e.column)+a.yellow(i)),y(`${` `.repeat(e.column+r)}${a.yellow(`╰─`)} ${o}`)]}function y(e){return a.dim(`│ `)+e}function b(e,t,n,r){let i=c(e),a=i.reduce((e,t)=>e+t.width,0),o=x(i,t),s=x(i,t+n);if(a<=r)return{inner:e,offset:S(i,0,o)};let l=Math.max(S(i,o,s),r-2),u=o,d=0;for(;u>0&&d+i[u-1].width<=16;)u--,d+=i[u].width;let f=o;for(;f<i.length&&d+i[f].width<=l;)d+=i[f].width,f++;for(;u>0&&d+i[u-1].width<=l;)u--,d+=i[u].width;let p=u>0?`…`:``,m=f<i.length?`…`:``;return{inner:p+i.slice(u,f).map(e=>e.text).join(``)+m,offset:S(i,u,o)+p.length}}function x(e,t){let n=0;for(let r=0;r<e.length;r++){if(n>=t)return r;n+=e[r].text.length}return e.length}function S(e,t,n){let r=0;for(let i=t;i<n;i++)r+=e[i].width;return r}const C=RegExp(`[\0--Ÿ]`,`g`);function w(e){return e.replace(/\s+/g,` `).replace(C,``).trim()}function T(e,t){if(l(e)<=t)return e;let n=``,r=0;for(let i of c(e)){if(r+i.width>t-1)break;n+=i.text,r+=i.width}return`${n}…`}export{f as default,p as formatLint};
@@ -0,0 +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-CqLPjqnr.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
+ `));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 @@
1
+ import{t as e}from"./withErrorFormatting-BzsnYkDV.mjs";import{i as t,r as n,t as r}from"./urls-DdV5qJFG.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 studio by removing a local auth token.`},run:()=>e(async()=>{let e=await t();e&&await fetch(`${r()}/sign-out`,{method:`POST`,headers:{authorization:`Bearer ${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};
@@ -0,0 +1,4 @@
1
+ import{t as e}from"./defineEloqntCommand-BEnYhPuF.mjs";import{i as t,n}from"./urls-DdV5qJFG.mjs";import{t as r}from"./createSpinner-CqLPjqnr.mjs";import{loadStyleguide as i,translate as a}from"@eloqnt/sdk";import o from"node:process";import{basename as s,dirname as c,relative as l,resolve 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)}var p=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:s,args:c}){let{messages:f}=e,p=(Array.isArray(f.path)?f.path:[f.path]).map(e=>u(s,e)),m=await i({cwd:s}),h=e.model?`local eloqnt/engine running ${typeof e.model==`string`?e.model:e.model.modelId}`:`hosted eloqnt/engine`,g=typeof c.locale==`string`?c.locale.split(`,`):Array.isArray(f.locales)?f.locales.filter(e=>e!==f.sourceLocale):void 0,_=`${g?.length?`${g.join(`, `)} `:``}via ${h}`,v=o.stderr.isTTY&&!c.json?r():void 0;v?v.start(`Translating ${_}`):c.json||o.stderr.write(d.dim(`\nTranslating ${_} …\n`));let y;try{y=await a({messagesPath:p,sourceLocale:f.sourceLocale,format:f.format,locales:f.locales,cwd:s,engineUrl:n(),languageModel:e.model,providerOptions:e.providerOptions,authToken:await t(),styleguide:m,ids:typeof c.id==`string`?c.id.split(`,`):void 0,onlyLocales:typeof c.locale==`string`?c.locale.split(`,`):void 0})}catch(e){throw v?.clear(),e}v?.stop(d.dim(`Translated ${_}`));let b=o.cwd(),x=y.targets.flatMap(e=>e.files.map(e=>({file:l(b,e.file),count:e.translated.length})));return{result:y,rows:x,complete:y.complete}},render({result:e,rows:t,complete:n}){let r=Object.groupBy(t,e=>c(e.file));return`\n${Object.entries(r).map(([e,t=[]])=>{let n=Math.max(0,...t.map(e=>s(e.file).length)),r=t.map(e=>` ${s(e.file).padEnd(n)} ${e.count===0?d.dim(`Nothing to translate`):d.green(`${e.count} translated`)}`);return[d.dim(`${e}/`),...r].join(`
2
+ `)}).join(`
3
+
4
+ `)}\n\n${n?d.green(`✔ 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{p as default};
@@ -0,0 +1 @@
1
+ import{t as e}from"./defineEloqntCommand-BEnYhPuF.mjs";import{i as t,n}from"./urls-DdV5qJFG.mjs";import{EloqntSdkError as r,getAuthHeaders as i}from"@eloqnt/sdk";import a from"picocolors";var o=e({meta:{name:`whoami`,description:`Shows the logged-in user account.`},requiresConfig:!1,async execute(){let e=await t();if(!e)throw new r(`NOT_AUTHENTICATED`,`Not logged in`,{hint:`Run eloqnt login to authenticate.`});let a=await fetch(new URL(`/api/engine/me`,n()),{headers:i(e)});if(a.status===401)throw new r(`NOT_AUTHENTICATED`,`Your session has expired`,{hint:`Run eloqnt login to sign in again.`});if(!a.ok)throw new r(`ENGINE_ERROR`,`Sorry, we couldn't load your account`,{details:`The studio API responded with ${a.status}.`,hint:`This is on our end. Try again in a few minutes.`});let o=await a.json();return{email:o.user.email,subscription:o.subscription.status}},render:({email:e,subscription:t})=>`Email: ${a.green(e)}\nSubscription: ${s(t)}`,json:e=>e});function s(e){return e===`active`?a.green(`active`):e===`trialing`?a.yellow(`trialing`):e===`none`?a.yellow(`none (subscribe at ${n()}/app)`):a.yellow(e)}export{o as default};
@@ -0,0 +1,2 @@
1
+ import{EloqntSdkError as e}from"@eloqnt/sdk";import t from"node:process";import n from"picocolors";function r(e){let t=[`${n.red(n.bold(`✗ ${e.message}`))} ${n.dim(`(${e.code})`)}`],{details:r}=e;if(r)if(t.push(``),typeof r==`string`)t.push(` ${r}`);else{t.push(` ${r.heading}`);for(let e of r.items)t.push(` ${n.dim(`•`)} ${e}`)}return t.push(``,n.cyan(`→ ${e.hint}`)),e.docsUrl&&t.push(n.dim(` ${e.docsUrl}`)),`\n${t.join(`
2
+ `)}`}async function i(n){try{await n()}catch(n){if(n instanceof e){t.stderr.write(`${r(n)}\n`),t.exitCode=1;return}throw n}}export{i as t};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eloqnt/cli",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
4
4
  "description": "CLI for eloqnt/studio",
5
5
  "repository": {
6
6
  "type": "git",
@@ -12,7 +12,8 @@
12
12
  },
13
13
  "files": [
14
14
  "dist",
15
- "!dist/**/*.map"
15
+ "!dist/**/*.map",
16
+ "CHANGELOG.md"
16
17
  ],
17
18
  "type": "module",
18
19
  "exports": {
@@ -29,7 +30,7 @@
29
30
  "citty": "^0.1.6",
30
31
  "open": "^11.0.0",
31
32
  "picocolors": "^1.1.1",
32
- "@eloqnt/sdk": "0.0.3"
33
+ "@eloqnt/sdk": "0.0.5"
33
34
  },
34
35
  "devDependencies": {
35
36
  "@types/node": "^25.9.1"
@@ -1,2 +0,0 @@
1
- import{EloqntSdkError as e,loadConfig as t}from"@eloqnt/sdk";import n from"node:process";import{defineCommand as r}from"citty";import i from"picocolors";function a(e){let t=[`${i.red(i.bold(`✗ ${e.message}`))} ${i.dim(`(${e.code})`)}`],{details:n}=e;if(n)if(t.push(``),typeof n==`string`)t.push(` ${n}`);else{t.push(` ${n.heading}`);for(let e of n.items)t.push(` ${i.dim(`•`)} ${e}`)}return t.push(``,i.cyan(`→ ${e.hint}`)),e.docsUrl&&t.push(i.dim(` ${e.docsUrl}`)),`\n${t.join(`
2
- `)}`}function o(i){return r({meta:i.meta,args:{config:{type:`string`,description:`Path to the eloqnt config file (defaults to .eloqnt/config.{ts,mts,js,mjs})`},json:{type:`boolean`,description:`Output the result as JSON`,default:!1},...i.args},async run({args:r}){try{let{config:e,rootDir:a}=await t({configPath:r.config}),o=await i.execute({config:e,rootDir:a,args:r}),s=r.json?JSON.stringify(i.json?i.json(o):o,null,2):i.render(o);n.stdout.write(`${s}\n`),i.ok&&!i.ok(o)&&(n.exitCode=1)}catch(t){if(t instanceof e){n.stderr.write(`${a(t)}\n`),n.exitCode=1;return}throw t}}})}export{o as t};
@@ -1 +0,0 @@
1
- import{a as e,t}from"./urls-DdV5qJFG.mjs";import n from"node:process";import{defineCommand as r}from"citty";import i from"picocolors";import{setTimeout as a}from"node:timers/promises";import{spinner as o}from"@clack/prompts";import s from"open";function c(e){s(e).catch(()=>{})}const l=`eloqnt-cli`;var u=r({meta:{name:`login`,description:`Authenticates the CLI by storing an auth token locally.`},async run(){let r=t(),a=await fetch(`${r}/device/code`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({client_id:l})});if(!a.ok){n.stderr.write(i.red(`Could not start the login flow (${a.status})\n`)),n.exitCode=1;return}let s=await a.json();n.stderr.write(`\n${i.cyan(`Log in to eloqnt studio`)}\n`),n.stderr.write(i.dim(`${s.verification_uri_complete}\n\n`)),c(s.verification_uri_complete);let u=o();u.start(`Waiting for approval in the browser`);let f=await d(r,s);if(!f.access_token){u.stop(i.red(f.error_description??`Login failed`)),n.exitCode=1;return}await e(f.access_token),u.stop(i.green(`Logged in`))}});async function d(e,t){let n=Date.now()+t.expires_in*1e3,r=t.interval;for(;Date.now()<n;){await a(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:l})})).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 — run eloqnt login again`}}export{u as default};
@@ -1 +0,0 @@
1
- import{i as e,r as t,t as n}from"./urls-DdV5qJFG.mjs";import r from"node:process";import{defineCommand as i}from"citty";import a from"picocolors";var o=i({meta:{name:`logout`,description:`Logs out of eloqnt studio by removing a local auth token.`},async run(){let i=await e();i&&await fetch(`${n()}/sign-out`,{method:`POST`,headers:{authorization:`Bearer ${i}`}}).catch(()=>{});let o=await t();r.stdout.write(o||i?`${a.green(`Logged out`)}\n`:`${a.dim(`Not logged in`)}\n`)}});export{o as default};
@@ -1,2 +0,0 @@
1
- import{t as e}from"./defineEloqntCommand-CsM_g_XS.mjs";import{getStatus as t}from"@eloqnt/sdk";import{resolve as n}from"node:path";import r from"picocolors";var i=e({meta:{name:`status`,description:`Report translation completeness per locale.`},async execute({config:e,rootDir:r}){let{messages:i}=e;return await t({messagesPath:(Array.isArray(i.path)?i.path:[i.path]).map(e=>n(r,e)),sourceLocale:i.sourceLocale,format:i.format,locales:i.locales,cwd:r})},render(e){let{source:t,targets:n}=e,i=Math.max(t.locale.length,...n.map(e=>e.locale.length)),a=`${t.totalMessages} ${t.totalMessages===1?`message`:`messages`}`,o=[`${r.bold(t.locale.padEnd(i))} ${r.dim(a)}`];for(let e of n){let t=r.bold(e.locale.padEnd(i)),n=e.missing.length===0?r.green(`complete`):r.yellow(`${e.missing.length} missing`);o.push(`${t} ${n}`)}return o.join(`
2
- `)}});export{i as default};
@@ -1,4 +0,0 @@
1
- import{t as e}from"./defineEloqntCommand-CsM_g_XS.mjs";import{i as t,n}from"./urls-DdV5qJFG.mjs";import{loadStyleguide as r,translate as i}from"@eloqnt/sdk";import a from"node:process";import{basename as o,dirname as s,relative as c,resolve as l}from"node:path";import u from"picocolors";function d(e,t={month:`short`,day:`numeric`}){return new Date(e).toLocaleDateString(`en-US`,t)}var f=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:o,args:s}){let{messages:d}=e,f=(Array.isArray(d.path)?d.path:[d.path]).map(e=>l(o,e)),p=await r({cwd:o}),m=e.model?`local eloqnt/engine running ${typeof e.model==`string`?e.model:e.model.modelId}`:`hosted eloqnt/engine`;a.stderr.write(u.dim(`\nTranslating via ${m} …\n`));let h=await i({messagesPath:f,sourceLocale:d.sourceLocale,format:d.format,locales:d.locales,cwd:o,engineUrl:n(),languageModel:e.model,providerOptions:e.providerOptions,authToken:await t(),styleguide:p,ids:typeof s.id==`string`?s.id.split(`,`):void 0,onlyLocales:typeof s.locale==`string`?s.locale.split(`,`):void 0}),g=a.cwd();return{result:h,rows:h.targets.map(e=>({file:c(g,e.file),count:e.translated.length})),complete:h.complete}},render({result:e,rows:t,complete:n}){let r=Object.groupBy(t,e=>s(e.file));return`\n${Object.entries(r).map(([e,t=[]])=>{let n=Math.max(0,...t.map(e=>o(e.file).length)),r=t.map(e=>` ${o(e.file).padEnd(n)} ${e.count===0?u.dim(`Nothing to translate`):u.green(`${e.count} translated`)}`);return[u.dim(`${e}/`),...r].join(`
2
- `)}).join(`
3
-
4
- `)}\n\n${n?u.green(`✔ Fully translated`):e.quota?u.yellow(`✗ Monthly included usage exhausted — translated as much as possible, resets ${d(e.quota.resetsAt)}`):u.dim(`✗ Partially translated, run eloqnt lint to see what's left`)}`},json:({result:e})=>e});export{f as default};
@@ -1 +0,0 @@
1
- import{i as e,n as t}from"./urls-DdV5qJFG.mjs";import{getAuthHeaders as n}from"@eloqnt/sdk";import r from"node:process";import{defineCommand as i}from"citty";import a from"picocolors";var o=i({meta:{name:`whoami`,description:`Shows the logged-in user account.`},async run(){let i=await e();if(!i){r.stderr.write(`${a.dim(`Not logged in — run eloqnt login`)}\n`),r.exitCode=1;return}let o=await fetch(new URL(`/api/engine/me`,t()),{headers:n(i)});if(o.status===401){r.stderr.write(`${a.dim(`Session expired — run eloqnt login`)}\n`),r.exitCode=1;return}if(!o.ok){r.stderr.write(a.red(`Could not load the account (${o.status})\n`)),r.exitCode=1;return}let c=await o.json();r.stdout.write(`Email: ${a.green(c.user.email)}\nSubscription: ${s(c.subscription.status)}\n`)}});function s(e){return e===`active`?a.green(`active`):e===`trialing`?a.yellow(`trialing`):e===`none`?a.yellow(`none — subscribe at ${t()}/app`):a.yellow(e)}export{o as default};