@eloqnt/cli 0.4.0 → 0.4.2

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,17 @@
1
1
  # @eloqnt/cli
2
2
 
3
+ ## 0.4.2
4
+
5
+ ### Patch Changes
6
+
7
+ - c673da8: Normalize the spacing above the `eloqnt translate` hint in `eloqnt lint` output to a single blank line, matching `eloqnt review`.
8
+
9
+ ## 0.4.1
10
+
11
+ ### Patch Changes
12
+
13
+ - 30b42f0: The source review now runs as `eloqnt review` (the explicit `eloqnt review source` form keeps working).
14
+
3
15
  ## 0.4.0
4
16
 
5
17
  ### Minor Changes
@@ -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-6H7VNJC2.mjs`)),review:r(()=>import(`../review-BPDZscRV.mjs`)),translate:r(()=>import(`../translate-BiFqwHuB.mjs`)),login:r(()=>import(`../login-nkMnzEjE.mjs`)),logout:r(()=>import(`../logout-BjdvLusP.mjs`)),whoami:r(()=>import(`../whoami-CTueGAHT.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-BwKSOVgc.mjs`)),review:r(()=>import(`../review-BZbZJcYs.mjs`)),translate:r(()=>import(`../translate-BiFqwHuB.mjs`)),login:r(()=>import(`../login-Cri7Zb15.mjs`)),logout:r(()=>import(`../logout-BjdvLusP.mjs`)),whoami:r(()=>import(`../whoami-CTueGAHT.mjs`))}}));function r(e){return()=>e().then(e=>e.default)}export{};
@@ -1,4 +1,4 @@
1
- import{t as e}from"./defineEloqntCommand-BNNDggcZ.mjs";import{i as t,n,r,t as i}from"./stringWidth-D46ajgdE.mjs";import{t as a}from"./resolvePaths-Bc7dGH8a.mjs";import{lint as o}from"@eloqnt/sdk";import s from"node:process";import{basename as c,relative as l}from"node:path";import u from"picocolors";var d=e({meta:{name:`lint`,description:`Statically analyze your source code and messages for common problems.`},async execute({config:e,rootDir:t}){let{messages:n,srcPath:r}=e,i=await o({messagesPath:a(n.path,t),sourceLocale:n.sourceLocale,format:n.format,locales:n.locales,srcPath:r?a(r,t):void 0,cwd:t}),u=s.cwd();return{issues:i.map(e=>{let t=e;if(t.location&&(t={...t,location:{...t.location,file:l(u,t.location.file)}}),t.rule===`undefined-key`&&t.sourceReferences?.length){let e=t.sourceReferences.map(e=>({path:l(u,e.path)})),n=e.length>1?` (+${e.length-1} more)`:``,r=t.location?c(t.location.file):`the source catalog`;t={...t,sourceReferences:e,message:`Used in ${e[0].path}${n} but not defined in ${r}`}}return t}),sourceLocale:n.sourceLocale,noSrcPath:!r}},render:({issues:e,sourceLocale:t,noSrcPath:n})=>{let r=f(e,t);return n?`\n${u.dim("– Skipped source code analysis due to absent `srcPath`")}\n${r}`:r},ok:({issues:e})=>e.length===0,json:({issues:e})=>e});function f(e,t){if(e.length===0)return`\n${u.green(`No issues found`)}\n`;let n=Object.groupBy(e,e=>e.location?.file??e.locale),r=p(Object.entries(n),t).map(([e,n])=>m(e,n,n[0].locale===t)),i=`${e.length} ${e.length===1?`issue`:`issues`}`,a=u.bold(u.red(`✗ ${i} found`)),o=e.filter(e=>e.rule===`missing-translation`).length,s=o?`${a}\n${u.dim(`→ Run \`eloqnt translate\` to fill in ${o} missing ${o===1?`translation`:`translations`}`)}`:a;return`\n${[...r,s].join(`
1
+ import{t as e}from"./defineEloqntCommand-BNNDggcZ.mjs";import{i as t,n,r,t as i}from"./stringWidth-D46ajgdE.mjs";import{t as a}from"./resolvePaths-Bc7dGH8a.mjs";import{lint as o}from"@eloqnt/sdk";import s from"node:process";import{basename as c,relative as l}from"node:path";import u from"picocolors";var d=e({meta:{name:`lint`,description:`Statically analyze your source code and messages for common problems.`},async execute({config:e,rootDir:t}){let{messages:n,srcPath:r}=e,i=await o({messagesPath:a(n.path,t),sourceLocale:n.sourceLocale,format:n.format,locales:n.locales,srcPath:r?a(r,t):void 0,cwd:t}),u=s.cwd();return{issues:i.map(e=>{let t=e;if(t.location&&(t={...t,location:{...t.location,file:l(u,t.location.file)}}),t.rule===`undefined-key`&&t.sourceReferences?.length){let e=t.sourceReferences.map(e=>({path:l(u,e.path)})),n=e.length>1?` (+${e.length-1} more)`:``,r=t.location?c(t.location.file):`the source catalog`;t={...t,sourceReferences:e,message:`Used in ${e[0].path}${n} but not defined in ${r}`}}return t}),sourceLocale:n.sourceLocale,noSrcPath:!r}},render:({issues:e,sourceLocale:t,noSrcPath:n})=>{let r=f(e,t);return n?`\n${u.dim("– Skipped source code analysis due to absent `srcPath`")}\n${r}`:r},ok:({issues:e})=>e.length===0,json:({issues:e})=>e});function f(e,t){if(e.length===0)return`\n${u.green(`No issues found`)}\n`;let n=Object.groupBy(e,e=>e.location?.file??e.locale),r=p(Object.entries(n),t).map(([e,n])=>m(e,n,n[0].locale===t)),i=`${e.length} ${e.length===1?`issue`:`issues`}`,a=u.bold(u.red(`✗ ${i} found`)),o=e.filter(e=>e.rule===`missing-translation`).length,s=o?u.dim(`→ Run \`eloqnt translate\` to fill in ${o} missing ${o===1?`translation`:`translations`}`):void 0;return`\n${[...r,a,s].filter(Boolean).join(`
2
2
 
3
3
  `)}\n`}function p(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 m(e,t,n){let i=[n?`${u.cyan(e)} ${u.dim(`(source locale)`)}`:u.cyan(e)];for(let e of t){i.push(u.dim(`│`));let{content:t,span:n}=h(e);i.push(r(t)),i.push(..._(n,e.message,e.rule))}return i.join(`
4
4
  `)}function h(e){let r=`"${e.key}"`,i=e.targetMessage??e.sourceMessage,a=g(r),o=e.highlight?.type===`value`||e.highlight?.type===`argument`,s=o?u.dim(r):r,c=u.dim(`: `),l=n(r);if(i!==void 0&&e.highlight?.type===`argument`){let r=t(i),o=e.highlight.token,u=r.indexOf(o);if(u>=0){let{inner:e,offset:t}=v(r,u,o.length,a);return{content:`${s}${c}"${e}"`,span:{column:l+3+t,length:n(o)}}}}let d=i===void 0?`"…"`:`"${x(t(i),a)}"`,f=`${s}${c}${o?d:u.dim(d)}`;return i!==void 0&&e.highlight?.type===`value`?{content:f,span:{column:l+2,length:n(d)}}:{content:f,span:{column:0,length:l}}}function g(e){let t=3+n(e)+2+2;return Math.max(24,Math.min(48,80-t))}function _(e,t,n){let i=Math.min(1,e.length-1),a=`─`.repeat(i)+`┬`+`─`.repeat(e.length-1-i),o=`${t} ${u.dim(`(${n})`)}`;return[r(` `.repeat(e.column)+u.yellow(a)),r(`${` `.repeat(e.column+i)}${u.yellow(`╰─`)} ${o}`)]}function v(e,t,n,r){let a=i(e),o=a.reduce((e,t)=>e+t.width,0),s=y(a,t),c=y(a,t+n);if(o<=r)return{inner:e,offset:b(a,0,s)};let l=Math.max(b(a,s,c),r-2),u=s,d=0;for(;u>0&&d+a[u-1].width<=16;)u--,d+=a[u].width;let f=s;for(;f<a.length&&d+a[f].width<=l;)d+=a[f].width,f++;for(;u>0&&d+a[u-1].width<=l;)u--,d+=a[u].width;let p=u>0?`…`:``,m=f<a.length?`…`:``;return{inner:p+a.slice(u,f).map(e=>e.text).join(``)+m,offset:b(a,u,s)+p.length}}function y(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 b(e,t,n){let r=0;for(let i=t;i<n;i++)r+=e[i].width;return r}function x(e,t){if(n(e)<=t)return e;let r=``,a=0;for(let n of i(e)){if(a+n.width>t-1)break;r+=n.text,a+=n.width}return`${r}…`}export{d as default,f as formatLint};
@@ -1,2 +1,2 @@
1
- import{t as e}from"./withErrorFormatting-CnMLjXSn.mjs";import{a as t,i as n,n as r,t as i}from"./urls-BrJoRsYB.mjs";import{t as a}from"./createSpinner-BBkrpcrh.mjs";import o from"node:process";import{defineCommand as s}from"citty";import c from"picocolors";import{EloqntSdkError as l,getAuthHeaders as u}from"@eloqnt/sdk/_internal";import{hostname as d}from"node:os";import{setTimeout as f}from"node:timers/promises";import{outro as p}from"@clack/prompts";import m from"open";var h=`0.4.0`;function g(e){m(e).catch(()=>{})}const _=`eloqnt-cli`,v=`eloqnt-cli/${h} (${d()}; ${o.platform} ${o.arch}; node ${o.version})`;var y=s({meta:{name:`login`,description:`Authenticates the CLI by storing an auth token locally.`},run:()=>e(async()=>{let e=i(),s=await n();s&&await fetch(`${e}/revoke-session`,{method:`POST`,headers:{authorization:`Bearer ${s}`,"content-type":`application/json`,"user-agent":v},body:JSON.stringify({token:s})}).catch(()=>{});let u=await fetch(`${e}/device/code`,{method:`POST`,headers:{"content-type":`application/json`,"user-agent":v},body:JSON.stringify({client_id:_})});if(!u.ok)throw new l(`ENGINE_UNREACHABLE`,`Couldn't start the login flow`,{details:`The auth server responded with ${u.status}.`,hint:`Check your connection and run eloqnt login again.`});let d=await u.json();o.stderr.write(`\n${c.cyan(`Log in to eloqnt studio`)}\n`),o.stderr.write(c.dim(`${d.verification_uri_complete}\n\n`)),g(d.verification_uri_complete);let f=o.stderr.isTTY?a():void 0;f?f.start(`Waiting for approval in the browser`):o.stderr.write(c.dim(`Waiting for approval in the browser …
1
+ import{t as e}from"./withErrorFormatting-CnMLjXSn.mjs";import{a as t,i as n,n as r,t as i}from"./urls-BrJoRsYB.mjs";import{t as a}from"./createSpinner-BBkrpcrh.mjs";import o from"node:process";import{defineCommand as s}from"citty";import c from"picocolors";import{EloqntSdkError as l,getAuthHeaders as u}from"@eloqnt/sdk/_internal";import{hostname as d}from"node:os";import{setTimeout as f}from"node:timers/promises";import{outro as p}from"@clack/prompts";import m from"open";var h=`0.4.2`;function g(e){m(e).catch(()=>{})}const _=`eloqnt-cli`,v=`eloqnt-cli/${h} (${d()}; ${o.platform} ${o.arch}; node ${o.version})`;var y=s({meta:{name:`login`,description:`Authenticates the CLI by storing an auth token locally.`},run:()=>e(async()=>{let e=i(),s=await n();s&&await fetch(`${e}/revoke-session`,{method:`POST`,headers:{authorization:`Bearer ${s}`,"content-type":`application/json`,"user-agent":v},body:JSON.stringify({token:s})}).catch(()=>{});let u=await fetch(`${e}/device/code`,{method:`POST`,headers:{"content-type":`application/json`,"user-agent":v},body:JSON.stringify({client_id:_})});if(!u.ok)throw new l(`ENGINE_UNREACHABLE`,`Couldn't start the login flow`,{details:`The auth server responded with ${u.status}.`,hint:`Check your connection and run eloqnt login again.`});let d=await u.json();o.stderr.write(`\n${c.cyan(`Log in to eloqnt studio`)}\n`),o.stderr.write(c.dim(`${d.verification_uri_complete}\n\n`)),g(d.verification_uri_complete);let f=o.stderr.isTTY?a():void 0;f?f.start(`Waiting for approval in the browser`):o.stderr.write(c.dim(`Waiting for approval in the browser …
2
2
  `));let m=await x(e,d);if(!m.access_token)throw f?.stop(c.dim(`Login cancelled`)),new l(`NOT_AUTHENTICATED`,m.error_description??`Login failed`,{hint:`Run eloqnt login to try again.`});await t(m.access_token),f?(f.stop(c.dim(`Approved in the browser`)),p(c.green(`Logged in`))):o.stdout.write(`${c.green(`Logged in`)}\n`),await b(m.access_token)&&o.stderr.write(`\n${c.cyan(`→ Choose a plan at ${r()}/plans`)}\n`)})});async function b(e){try{let t=await fetch(new URL(`/api/engine/me`,r()),{headers:u(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 f(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};
@@ -0,0 +1 @@
1
+ import{defineCommand as e}from"citty";var t=e({meta:{name:`review`,description:"Review source strings before translation and fix issues in place (defaults to the `source` subcommand)."},setup({rawArgs:e}){e.find(e=>!e.startsWith(`-`))!==`source`&&e.unshift(`source`)},subCommands:{source:()=>import(`./source-BIRHLi05.mjs`).then(e=>e.default)}});export{t as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eloqnt/cli",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
4
4
  "description": "CLI for eloqnt/studio",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1 +0,0 @@
1
- import{defineCommand as e}from"citty";var t=e({meta:{name:`review`,description:`Review source strings before translation and fix issues in place.`},subCommands:{source:()=>import(`./source-BIRHLi05.mjs`).then(e=>e.default)}});export{t as default};