@eloqnt/cli 0.6.5 → 0.6.7

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,27 @@
1
1
  # @eloqnt/cli
2
2
 
3
+ ## 0.6.7
4
+
5
+ ### Patch Changes
6
+
7
+ - 9c75437: Add a `styleguides` config option that sets the directory styleguides are loaded from, e.g. to share one set across multiple projects.
8
+ - Updated dependencies [9c75437]
9
+ - Updated dependencies [9c75437]
10
+ - Updated dependencies [9c75437]
11
+ - @eloqnt/sdk@0.7.0
12
+
13
+ ## 0.6.6
14
+
15
+ ### Patch Changes
16
+
17
+ - ef191bf: `messages.format` can now reference a codec from an installed package by its name (e.g. `'@eloqnt/format-apple-xcstrings'`).
18
+ - ef191bf: `defineCodec` now accepts a shared-file variant for formats that keep every locale in one file.
19
+ - ef191bf: `messages.path` entries can now split into `{source, targets}` for when source and target files need a different path structure.
20
+ - Updated dependencies [ef191bf]
21
+ - Updated dependencies [ef191bf]
22
+ - Updated dependencies [ef191bf]
23
+ - @eloqnt/sdk@0.6.5
24
+
3
25
  ## 0.6.5
4
26
 
5
27
  ### Patch Changes
@@ -1 +1 @@
1
- export { };
1
+ export {}
@@ -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.5`;try{e.loadEnvFile()}catch{}const o=t({meta:{name:`eloqnt`,version:a,description:`AI-powered translations for developers`},subCommands:{lint:d(()=>import(`../lint-BHoQowEL.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};
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.7`;try{e.loadEnvFile()}catch{}const o=t({meta:{name:`eloqnt`,version:a,description:`AI-powered translations for developers`},subCommands:{lint:d(()=>import(`../lint-BebREqRc.mjs`)),review:d(()=>import(`../review-BzLUIgIa.mjs`)),translate:d(()=>import(`../translate-C0l-08TO.mjs`)),crowdin:d(()=>import(`../crowdin-DdfREp0-.mjs`)),login:d(()=>import(`../login-W60UmKbD.mjs`)),logout:d(()=>import(`../logout-BCLs2gQ-.mjs`)),whoami:d(()=>import(`../whoami-bo3bXioJ.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};
@@ -0,0 +1 @@
1
+ import{defineCommand as e}from"citty";var t=e({meta:{name:`crowdin`,description:`Sync messages with a Crowdin project (uses crowdin.yml).`},subCommands:{upload:()=>import(`./upload-Dsy5tcAd.mjs`).then(e=>e.default),download:()=>import(`./download-DfXkJo_Z.mjs`).then(e=>e.default)}});export{t as default};
@@ -1 +1 @@
1
- import{defineCommand as e}from"citty";var t=e({meta:{name:`download`,description:`Download translations from your Crowdin project.`},subCommands:{translations:()=>import(`./translations-fTIBanLm.mjs`).then(e=>e.default)}});export{t as default};
1
+ import{defineCommand as e}from"citty";var t=e({meta:{name:`download`,description:`Download translations from your Crowdin project.`},subCommands:{translations:()=>import(`./translations-DmsEv9OB.mjs`).then(e=>e.default)}});export{t as default};
@@ -0,0 +1,7 @@
1
+ import{t as e}from"./defineEloqntCommand-BNNDggcZ.mjs";import{a as t,i as n,o as r,r as i,s as a,t as o}from"./stringWidth-Ba8f3rhS.mjs";import{t as s}from"./resolvePaths-CKsEPHfH.mjs";import{lint as c}from"@eloqnt/sdk";import l from"node:process";import u from"picocolors";import{relative as d,resolve as f}from"node:path";var p=e({meta:{name:`lint`,description:`Statically analyze your source code and messages for common problems.`},args:{strict:{type:`boolean`,description:`Exit with a non-zero code when warnings are found`,default:!1}},async execute({config:e,rootDir:t,args:n}){let{messages:r,srcPath:i}=e,a=await c({messagesPath:s(r.path,t),sourceLocale:r.sourceLocale,format:r.format,locales:r.locales,codes:r.codes,srcPath:i?s(i,t):void 0,rootDir:t}),o=l.cwd();return{issues:a.map(e=>{let t=e;if(t.location&&(t={...t,location:{...t.location,file:d(o,t.location.file)}}),t.rule===`undefined-key`&&t.sourceReferences?.length){let e=t.sourceReferences.map(e=>({...e,path:d(o,e.path)})),n=e[0].line?`${e[0].path}:${e[0].line}`:e[0].path,i=e.length>1?` (+${e.length-1} more)`:``;t={...t,sourceReferences:e,message:`Used in ${n}${i} but not defined for ${r.sourceLocale}`}}return t}),sourceLocale:r.sourceLocale,noSrcPath:!i,strict:!!n.strict}},render:({issues:e,sourceLocale:t,noSrcPath:n})=>{let r=h(e,t),i=n?`\n${u.dim("– Skipped source code analysis due to absent `srcPath`")}\n${r}`:r;return l.env.GITHUB_ACTIONS&&e.length>0?`${i}\n${_(e)}`:i},ok:({issues:e,strict:t})=>t?e.length===0:!e.some(e=>e.severity===`error`),json:({issues:e})=>e.map(e=>({...e,docsUrl:m(e.rule)}))});function m(e){return`https://studio.eloqnt.dev/docs/lint-rules/${e}`}function h(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=x(Object.entries(n),t).map(([e,n])=>S(e,n,n[0].locale===t)),i=e.filter(e=>e.severity===`error`).length,a=e.length-i,o=[i>0&&u.bold(u.red(`✗ ${g(i,`error`)}`)),a>0&&u.bold(u.yellow(`! ${g(a,`warning`)}`))].filter(Boolean).join(`
2
+ `),s=e.filter(e=>e.rule===`missing-translation`).length,c=[e.some(e=>e.rule!==`missing-translation`)&&u.dim(`→ Rule details: ${m(`<rule>`)}`),s>0&&u.dim(`→ Run \`eloqnt translate\` to fill in ${s} missing ${s===1?`translation`:`translations`}`)].filter(Boolean).join(`
3
+ `);return`\n${[...r,o,c].filter(Boolean).join(`
4
+
5
+ `)}\n`}function g(e,t){return`${e} ${e===1?t:`${t}s`}`}function _(e){return e.map(e=>{let t=e.rule===`undefined-key`&&e.sourceReferences?.length?e.sourceReferences[0]:void 0,n=t?.path??e.location?.file,r=[n&&`file=${b(v(n))}`,t?.line&&`line=${t.line}`,`title=${b(e.rule)}`].filter(Boolean).join(`,`),i=y(`"${e.key}": ${e.message}\n${m(e.rule)}`);return`::${e.severity} ${r}::${i}`}).join(`
6
+ `)}function v(e){let t=l.env.GITHUB_WORKSPACE;return t?d(t,f(e)):e}function y(e){return e.replace(/%/g,`%25`).replace(/\r/g,`%0D`).replace(/\n/g,`%0A`)}function b(e){return y(e).replace(/:/g,`%3A`).replace(/,/g,`%2C`)}function x(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 S(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}=C(e);i.push(r(t)),i.push(...T(n,e))}return i.join(`
7
+ `)}function C(e){let n=`"${e.key}"`,r=e.targetMessage??e.sourceMessage,o=w(n),s=e.highlight?.type===`value`||e.highlight?.type===`argument`,c=s?u.dim(n):n,l=u.dim(`: `),d=i(n);if(r!==void 0&&e.highlight?.type===`argument`){let t=a(r),n=e.highlight.token,s=t.indexOf(n);if(s>=0){let{inner:e,offset:r}=E(t,s,n.length,o);return{content:`${c}${l}"${e}"`,span:{column:d+3+r,length:i(n)}}}}let f=r===void 0?`"…"`:`"${t(a(r),o)}"`,p=`${c}${l}${s?f:u.dim(f)}`;return r!==void 0&&e.highlight?.type===`value`?{content:p,span:{column:d+2,length:i(f)}}:{content:p,span:{column:0,length:d}}}function w(e){let t=3+i(e)+2+2;return Math.max(24,Math.min(48,n()-t))}function T(e,t){let n=t.severity===`error`?u.red:u.yellow,i=Math.min(1,e.length-1),a=`─`.repeat(i)+`┬`+`─`.repeat(e.length-1-i),o=`${t.message} ${u.dim(`(${t.rule})`)}`;return[r(` `.repeat(e.column)+n(a)),r(`${` `.repeat(e.column+i)}${n(`╰─`)} ${o}`)]}function E(e,t,n,r){let i=o(e),a=i.reduce((e,t)=>e+t.width,0),s=D(i,t),c=D(i,t+n);if(a<=r)return{inner:e,offset:O(i,0,s)};let l=Math.max(O(i,s,c),r-2),u=s,d=0;for(;u>0&&d+i[u-1].width<=16;)u--,d+=i[u].width;let f=s;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:O(i,u,s)+p.length}}function D(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 O(e,t,n){let r=0;for(let i=t;i<n;i++)r+=e[i].width;return r}export{p as default,_ as formatGithubAnnotations,h as formatLint};
@@ -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,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 …
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-F6fkAWuj.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
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};
@@ -1 +1 @@
1
- import{t as e}from"./withErrorFormatting-CnMLjXSn.mjs";import{i as t,r as n,t as r}from"./urls-BrJoRsYB.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()}/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{i as t,r as n,t as r}from"./urls-F6fkAWuj.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()}/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};
@@ -0,0 +1 @@
1
+ import{resolve as e}from"node:path";function t(t,n){return(Array.isArray(t)?t:[t]).map(t=>typeof t==`string`?e(n,t):{source:e(n,t.source),targets:e(n,t.targets)})}export{t};
@@ -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-DxyjecuV.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-mubcyKGd.mjs`).then(e=>e.default)}});export{t as default};
@@ -1,7 +1,7 @@
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,r as s,s as c}from"./stringWidth-Ba8f3rhS.mjs";import{t as l}from"./resolvePaths-Bc7dGH8a.mjs";import{i as u,n as d}from"./urls-BrJoRsYB.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=l(a.path,r),c=o?l(o,r):void 0,f=await x({cwd:r}),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{a as r,i,n as a,o,r as s,s as c}from"./stringWidth-Ba8f3rhS.mjs";import{t as l}from"./resolvePaths-CKsEPHfH.mjs";import{i as u,n as d}from"./urls-F6fkAWuj.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=l(a.path,r),c=o?l(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
- `),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,cwd:r,engineUrl:d(),languageModel:e.model,authToken:await u(),styleguide:f,ids:t(i.id),srcPath:c,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=i()){let{findings:n,reviewed:r,missingTranslations:a,quota:o}=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(`
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:c,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=i()){let{findings:n,reviewed:r,missingTranslations:a,quota:o}=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(`
5
5
  `))}let l=O(n,e.sourceLocale),u=Object.groupBy(e.files,e=>y(e.file)),d=Object.entries(u).map(([e,t=[]])=>{let n=Math.max(0,...t.map(e=>v(e.file).length)),r=t.map(e=>{let t=v(e.file).padEnd(n),r=l.get(e.file);return` ${t} ${k(e.reviewed,r?.fixed??0,r?.reported??0,o!==void 0)}`});return[_.dim(`${e}/`),...r].join(`
6
6
  `)}).join(`
7
7
 
@@ -1,3 +1,3 @@
1
- import{t as e}from"./defineEloqntCommand-BNNDggcZ.mjs";import{n as t,r as n,t as r}from"./withSpinner-CeQSfolX.mjs";import i from"node:process";import a from"picocolors";import{relative as o}from"node:path";import{uploadCrowdinSources as s}from"@eloqnt/sdk/_internal";var c=e({meta:{name:`sources`,description:`Upload source files to your Crowdin project.`},requiresConfig:!1,args:{branch:{type:`string`,description:`Sync with this branch of the Crowdin project (created when missing)`}},async execute({rootDir:e,args:t}){let n=await r({label:`Uploading sources to Crowdin`,json:!!t.json,task:()=>s({cwd:e,branch:t.branch})}),a=i.cwd();return{result:{...n,files:n.files.map(e=>({...e,file:o(a,e.file)}))}}},render({result:e}){let r=e.files.map(e=>({file:e.file,detail:a.green(e.action===`created`?`Created`:`Updated`)})),i=e.files.length,o=a.green(`✔ Uploaded ${i} source ${i===1?`file`:`files`} to ${e.project.name}`)+(e.branch?` ${a.dim(`(${e.branch})`)}`:``);return`\n${[...e.createdBranch?[a.green(`✔ Created the branch ${e.createdBranch}`)]:[],t(r),...n(e.warnings),o].join(`
1
+ import{t as e}from"./defineEloqntCommand-BNNDggcZ.mjs";import{n as t,r as n,t as r}from"./withSpinner-CeQSfolX.mjs";import i from"node:process";import a from"picocolors";import{relative as o}from"node:path";import{uploadCrowdinSources as s}from"@eloqnt/sdk/_internal";var c=e({meta:{name:`sources`,description:`Upload source files to your Crowdin project.`},requiresConfig:!1,args:{branch:{type:`string`,description:`Sync with this branch of the Crowdin project (created when missing)`}},async execute({rootDir:e,args:t}){let n=await r({label:`Uploading sources to Crowdin`,json:!!t.json,task:()=>s({rootDir:e,branch:t.branch})}),a=i.cwd();return{result:{...n,files:n.files.map(e=>({...e,file:o(a,e.file)}))}}},render({result:e}){let r=e.files.map(e=>({file:e.file,detail:a.green(e.action===`created`?`Created`:`Updated`)})),i=e.files.length,o=a.green(`✔ Uploaded ${i} source ${i===1?`file`:`files`} to ${e.project.name}`)+(e.branch?` ${a.dim(`(${e.branch})`)}`:``);return`\n${[...e.createdBranch?[a.green(`✔ Created the branch ${e.createdBranch}`)]:[],t(r),...n(e.warnings),o].join(`
2
2
 
3
3
  `)}`},json:({result:e})=>e});export{c as default};
@@ -1,8 +1,8 @@
1
- import{t as e}from"./defineEloqntCommand-BNNDggcZ.mjs";import{t}from"./parseListArg-p5H1s5JC.mjs";import{t as n}from"./createSpinner-BBkrpcrh.mjs";import{t as r}from"./resolvePaths-Bc7dGH8a.mjs";import{i,n as a}from"./urls-BrJoRsYB.mjs";import{n as o,r as s,t as c}from"./writeStep-CerCYWGN.mjs";import{translate as l}from"@eloqnt/sdk";import u from"node:process";import d from"picocolors";import{basename as f,dirname as p,relative as m}from"node:path";import{loadStyleguide as h}from"@eloqnt/sdk/_internal";var g=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:f}){let{messages:p,srcPath:g}=e,_=r(p.path,o),v=g?r(g,o):void 0,y=await h({cwd:o}),b=e.model?`eloqnt/engine (${typeof e.model==`string`?e.model:e.model.modelId})`:`eloqnt/engine (hosted)`,x=t(f.locale),S=x??(Array.isArray(p.locales)?p.locales.filter(e=>e!==p.sourceLocale):void 0),C=`${S?.length?`${S.join(`, `)} `:``}via ${b}`,w=s(y,S??Object.keys(y.byLocale)),T=u.stderr.isTTY&&!f.json,E;function D(e){if(!f.json){if(e.phase===`context-enrichment`){e.state===`started`?(u.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{t as r}from"./resolvePaths-CKsEPHfH.mjs";import{i,n as a}from"./urls-F6fkAWuj.mjs";import{n as o,r as s,t as c}from"./writeStep-CerCYWGN.mjs";import{translate as l}from"@eloqnt/sdk";import u from"node:process";import d from"picocolors";import{basename as f,dirname as p,relative as m}from"node:path";import{loadStyleguide as h}from"@eloqnt/sdk/_internal";var g=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:f}){let{messages:p,srcPath:g}=e,_=r(p.path,o),v=g?r(g,o):void 0,y=await h({rootDir:o,path:e.styleguides}),b=e.model?`eloqnt/engine (${typeof e.model==`string`?e.model:e.model.modelId})`:`eloqnt/engine (hosted)`,x=t(f.locale),S=x??(Array.isArray(p.locales)?p.locales.filter(e=>e!==p.sourceLocale):void 0),C=`${S?.length?`${S.join(`, `)} `:``}via ${b}`,w=s(y,S??Object.keys(y.byLocale)),T=u.stderr.isTTY&&!f.json,E;function D(e){if(!f.json){if(e.phase===`context-enrichment`){e.state===`started`?(u.stderr.write(`
2
2
  `),T?(E=n({withGuide:!1}),E.start(`Context enrichment running`)):u.stderr.write(d.dim(`Context enrichment running …
3
3
  `))):e.state===`completed`?(E?.clear(),E=void 0,c(d.green(`✔`),`Context enrichment complete`)):(u.stderr.write(`
4
4
  `),c(d.dim(`–`),"Skipped context enrichment due to absent `srcPath`"));return}if(e.phase===`translate`){e.state===`started`?(w?c(d.green(`✔`),w):c(d.dim(`–`),`No styleguides found`),T?(E=n({withGuide:!1}),E.start(`Translating ${C}`)):u.stderr.write(d.dim(`Translating ${C} …\n`))):(E?.clear(),E=void 0,c(d.green(`✔`),`Translated ${C}`));return}e.state===`started`?T?(E=n({withGuide:!1}),E.start(`Post-translation checks running`)):u.stderr.write(d.dim(`Post-translation checks running …
5
- `)):(E?.clear(),E=void 0,c(d.green(`✔`),`Post-translation checks done`))}}let O;try{O=await l({messagesPath:_,sourceLocale:p.sourceLocale,format:p.format,locales:p.locales,cwd:o,engineUrl:a(),languageModel:e.model,authToken:await i(),styleguide:y,ids:t(f.id),onlyLocales:x,srcPath:v,onProgress:D})}catch(e){throw E?.clear(),e}let k=u.cwd(),A=O.targets.flatMap(e=>e.files.map(e=>({file:m(k,e.file),count:e.translated.length})));return{result:O,rows:A,complete:O.complete,noStyleguides:!w}},render({result:e,rows:t,complete:n,noStyleguides:r}){let i=Object.groupBy(t,e=>p(e.file));return`\n${Object.entries(i).map(([e,t=[]])=>{let n=Math.max(0,...t.map(e=>f(e.file).length)),r=t.map(e=>` ${f(e.file).padEnd(n)} ${e.count===0?d.dim(`Nothing to translate`):d.green(`${e.count} translated`)}`);return[d.dim(`${e}/`),...r].join(`
5
+ `)):(E?.clear(),E=void 0,c(d.green(`✔`),`Post-translation checks done`))}}let O;try{O=await l({messagesPath:_,sourceLocale:p.sourceLocale,format:p.format,locales:p.locales,codes:p.codes,rootDir:o,engineUrl:a(),languageModel:e.model,authToken:await i(),styleguide:y,ids:t(f.id),onlyLocales:x,srcPath:v,onProgress:D})}catch(e){throw E?.clear(),e}let k=u.cwd(),A=O.targets.flatMap(e=>e.files.map(t=>({file:m(k,t.file),locale:e.locale,count:t.translated.length})));return{result:O,rows:A,complete:O.complete,noStyleguides:!w}},render({result:e,rows:t,complete:n,noStyleguides:r}){let i=Object.groupBy(t,e=>p(e.file));return`\n${Object.entries(i).map(([e,t=[]])=>{let n=Math.max(0,...t.map(e=>f(e.file).length)),r=t.map(e=>f(e.file)),i=r.length!==new Set(r).size,a=Math.max(0,...t.map(e=>e.locale.length)),o=t.map(e=>` ${f(e.file).padEnd(n)} ${i?`${d.dim(e.locale.padEnd(a))} `:``}${e.count===0?d.dim(`Nothing to translate`):d.green(`${e.count} translated`)}`);return[d.dim(`${e}/`),...o].join(`
6
6
  `)}).join(`
7
7
 
8
8
  `)}\n\n${n?d.green(`✔ Project fully translated`):e.quota?d.yellow(`! Monthly included usage exhausted, translated as much as possible. Resets ${o(e.quota.resetsAt)}`):d.dim(`✗ Partially translated, run eloqnt lint to see what's left`)}${r?`\n\n${d.dim(`→ Add a styleguide to improve your translation quality`)}\n${d.dim(` ${a()}/docs#styleguides`)}`:``}`},json:({result:e})=>e});export{g as default};
@@ -1,3 +1,3 @@
1
- import{t as e}from"./defineEloqntCommand-BNNDggcZ.mjs";import{n as t,r as n,t as r}from"./withSpinner-CeQSfolX.mjs";import{t as i}from"./parseListArg-p5H1s5JC.mjs";import a from"node:process";import o from"picocolors";import{relative as s}from"node:path";import{uploadCrowdinTranslations as c}from"@eloqnt/sdk/_internal";var l=e({meta:{name:`translations`,description:`Upload existing local translations to your Crowdin project (they arrive unapproved).`},requiresConfig:!1,args:{branch:{type:`string`,description:`Sync with this branch of the Crowdin project`},locale:{type:`string`,description:`Restrict to these target languages (comma-separated)`}},async execute({rootDir:e,args:t}){let n=await r({label:`Uploading translations to Crowdin`,json:!!t.json,task:()=>c({cwd:e,branch:t.branch,onlyLocales:i(t.locale)})}),o=a.cwd();return{result:{...n,files:n.files.map(e=>({...e,file:s(o,e.file)}))}}},render({result:e}){let r=e.files.map(e=>({file:e.file,detail:e.status===`uploaded`?o.green(`Uploaded`):o.dim(`No local file`)})),i=e.files.filter(e=>e.status===`uploaded`).length,a=i===0?o.dim(`Nothing to upload`):o.green(`✔ Uploaded ${i} translation ${i===1?`file`:`files`} to ${e.project.name}`)+(e.branch?` ${o.dim(`(${e.branch})`)}`:``);return`\n${[t(r),...n(e.warnings),a].join(`
1
+ import{t as e}from"./defineEloqntCommand-BNNDggcZ.mjs";import{n as t,r as n,t as r}from"./withSpinner-CeQSfolX.mjs";import{t as i}from"./parseListArg-p5H1s5JC.mjs";import a from"node:process";import o from"picocolors";import{relative as s}from"node:path";import{uploadCrowdinTranslations as c}from"@eloqnt/sdk/_internal";var l=e({meta:{name:`translations`,description:`Upload existing local translations to your Crowdin project (they arrive unapproved).`},requiresConfig:!1,args:{branch:{type:`string`,description:`Sync with this branch of the Crowdin project`},locale:{type:`string`,description:`Restrict to these target languages (comma-separated)`}},async execute({rootDir:e,args:t}){let n=await r({label:`Uploading translations to Crowdin`,json:!!t.json,task:()=>c({rootDir:e,branch:t.branch,onlyLocales:i(t.locale)})}),o=a.cwd();return{result:{...n,files:n.files.map(e=>({...e,file:s(o,e.file)}))}}},render({result:e}){let r=e.files.map(e=>({file:e.file,detail:e.status===`uploaded`?o.green(`Uploaded`):o.dim(`No local file`)})),i=e.files.filter(e=>e.status===`uploaded`).length,a=i===0?o.dim(`Nothing to upload`):o.green(`✔ Uploaded ${i} translation ${i===1?`file`:`files`} to ${e.project.name}`)+(e.branch?` ${o.dim(`(${e.branch})`)}`:``);return`\n${[t(r),...n(e.warnings),a].join(`
2
2
 
3
3
  `)}`},json:({result:e})=>e});export{l as default};
@@ -1,3 +1,3 @@
1
- import{t as e}from"./defineEloqntCommand-BNNDggcZ.mjs";import{n as t,r as n,t as r}from"./withSpinner-CeQSfolX.mjs";import{t as i}from"./parseListArg-p5H1s5JC.mjs";import a from"node:process";import o from"picocolors";import{relative as s}from"node:path";import{downloadCrowdinTranslations as c}from"@eloqnt/sdk/_internal";var l=e({meta:{name:`translations`,description:`Download translations from your Crowdin project into your local messages files.`},requiresConfig:!1,args:{branch:{type:`string`,description:`Sync with this branch of the Crowdin project`},locale:{type:`string`,description:`Restrict to these target languages (comma-separated)`}},async execute({rootDir:e,args:t}){let n=await r({label:`Downloading translations from Crowdin`,json:!!t.json,task:()=>c({cwd:e,branch:t.branch,onlyLocales:i(t.locale)})}),o=a.cwd();return{result:{...n,files:n.files.map(e=>({...e,file:s(o,e.file)}))}}},render({result:e}){let r=e.files.map(e=>({file:e.file,detail:e.status===`updated`?o.green(`Updated`):o.dim(`Nothing translated yet`)})),i=e.files.filter(e=>e.status===`updated`).length,a=i===0?o.dim(`Nothing to download yet`):o.green(`✔ Downloaded ${i} translation ${i===1?`file`:`files`} from ${e.project.name}`)+(e.branch?` ${o.dim(`(${e.branch})`)}`:``);return`\n${[t(r),...n(e.warnings),a].join(`
1
+ import{t as e}from"./defineEloqntCommand-BNNDggcZ.mjs";import{n as t,r as n,t as r}from"./withSpinner-CeQSfolX.mjs";import{t as i}from"./parseListArg-p5H1s5JC.mjs";import a from"node:process";import o from"picocolors";import{relative as s}from"node:path";import{downloadCrowdinTranslations as c}from"@eloqnt/sdk/_internal";var l=e({meta:{name:`translations`,description:`Download translations from your Crowdin project into your local messages files.`},requiresConfig:!1,args:{branch:{type:`string`,description:`Sync with this branch of the Crowdin project`},locale:{type:`string`,description:`Restrict to these target languages (comma-separated)`}},async execute({rootDir:e,args:t}){let n=await r({label:`Downloading translations from Crowdin`,json:!!t.json,task:()=>c({rootDir:e,branch:t.branch,onlyLocales:i(t.locale)})}),o=a.cwd();return{result:{...n,files:n.files.map(e=>({...e,file:s(o,e.file)}))}}},render({result:e}){let r=e.files.map(e=>({file:e.file,detail:e.status===`updated`?o.green(`Updated`):o.dim(`Nothing translated yet`)})),i=e.files.filter(e=>e.status===`updated`).length,a=i===0?o.dim(`Nothing to download yet`):o.green(`✔ Downloaded ${i} translation ${i===1?`file`:`files`} from ${e.project.name}`)+(e.branch?` ${o.dim(`(${e.branch})`)}`:``);return`\n${[t(r),...n(e.warnings),a].join(`
2
2
 
3
3
  `)}`},json:({result:e})=>e});export{l as default};
@@ -0,0 +1 @@
1
+ import{defineCommand as e}from"citty";var t=e({meta:{name:`upload`,description:`Upload sources or translations to your Crowdin project.`},subCommands:{sources:()=>import(`./sources-CYGybeK8.mjs`).then(e=>e.default),translations:()=>import(`./translations-BhDnGrNN.mjs`).then(e=>e.default)}});export{t as default};
@@ -0,0 +1 @@
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_STUDIO_URL??`https://studio.eloqnt.dev`}function p(){return`${f()}/api/auth`}export{u as a,l as i,f as n,d as r,p as t};
@@ -1,2 +1,2 @@
1
- import{t as e}from"./defineEloqntCommand-BNNDggcZ.mjs";import{i as t,n}from"./urls-BrJoRsYB.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{i as t,n}from"./urls-F6fkAWuj.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.5",
3
+ "version": "0.6.7",
4
4
  "description": "CLI for eloqnt/studio",
5
5
  "homepage": "https://studio.eloqnt.dev",
6
6
  "bin": {
@@ -22,14 +22,14 @@
22
22
  "access": "public"
23
23
  },
24
24
  "dependencies": {
25
- "@clack/prompts": "^1.5.1",
25
+ "@clack/prompts": "^1.7.0",
26
26
  "citty": "^0.1.6",
27
27
  "open": "^11.0.0",
28
28
  "picocolors": "^1.1.1",
29
- "@eloqnt/sdk": "0.6.4"
29
+ "@eloqnt/sdk": "0.6.6"
30
30
  },
31
31
  "devDependencies": {
32
- "@types/node": "^25.9.1"
32
+ "@types/node": "^25.9.5"
33
33
  },
34
34
  "scripts": {
35
35
  "build": "vp pack --minify src/index.ts src/bin/eloqnt.ts"
@@ -1 +0,0 @@
1
- import{defineCommand as e}from"citty";var t=e({meta:{name:`crowdin`,description:`Sync messages with a Crowdin project (uses crowdin.yml).`},subCommands:{upload:()=>import(`./upload-BDnaUB4y.mjs`).then(e=>e.default),download:()=>import(`./download-BuHS-69H.mjs`).then(e=>e.default)}});export{t as default};
@@ -1,7 +0,0 @@
1
- import{t as e}from"./defineEloqntCommand-BNNDggcZ.mjs";import{a as t,i as n,o as r,r as i,s as a,t as o}from"./stringWidth-Ba8f3rhS.mjs";import{t as s}from"./resolvePaths-Bc7dGH8a.mjs";import{lint as c}from"@eloqnt/sdk";import l from"node:process";import u from"picocolors";import{basename as d,relative as f,resolve as p}from"node:path";var m=e({meta:{name:`lint`,description:`Statically analyze your source code and messages for common problems.`},args:{strict:{type:`boolean`,description:`Exit with a non-zero code when warnings are found`,default:!1}},async execute({config:e,rootDir:t,args:n}){let{messages:r,srcPath:i}=e,a=await c({messagesPath:s(r.path,t),sourceLocale:r.sourceLocale,format:r.format,locales:r.locales,srcPath:i?s(i,t):void 0,cwd:t}),o=l.cwd();return{issues:a.map(e=>{let t=e;if(t.location&&(t={...t,location:{...t.location,file:f(o,t.location.file)}}),t.rule===`undefined-key`&&t.sourceReferences?.length){let e=t.sourceReferences.map(e=>({...e,path:f(o,e.path)})),n=e[0].line?`${e[0].path}:${e[0].line}`:e[0].path,r=e.length>1?` (+${e.length-1} more)`:``,i=t.location?d(t.location.file):`the source catalog`;t={...t,sourceReferences:e,message:`Used in ${n}${r} but not defined in ${i}`}}return t}),sourceLocale:r.sourceLocale,noSrcPath:!i,strict:!!n.strict}},render:({issues:e,sourceLocale:t,noSrcPath:n})=>{let r=g(e,t),i=n?`\n${u.dim("– Skipped source code analysis due to absent `srcPath`")}\n${r}`:r;return l.env.GITHUB_ACTIONS&&e.length>0?`${i}\n${v(e)}`:i},ok:({issues:e,strict:t})=>t?e.length===0:!e.some(e=>e.severity===`error`),json:({issues:e})=>e.map(e=>({...e,docsUrl:h(e.rule)}))});function h(e){return`https://studio.eloqnt.dev/docs/lint-rules/${e}`}function g(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=S(Object.entries(n),t).map(([e,n])=>C(e,n,n[0].locale===t)),i=e.filter(e=>e.severity===`error`).length,a=e.length-i,o=[i>0&&u.bold(u.red(`✗ ${_(i,`error`)}`)),a>0&&u.bold(u.yellow(`! ${_(a,`warning`)}`))].filter(Boolean).join(`
2
- `),s=e.filter(e=>e.rule===`missing-translation`).length,c=[e.some(e=>e.rule!==`missing-translation`)&&u.dim(`→ Rule details: ${h(`<rule>`)}`),s>0&&u.dim(`→ Run \`eloqnt translate\` to fill in ${s} missing ${s===1?`translation`:`translations`}`)].filter(Boolean).join(`
3
- `);return`\n${[...r,o,c].filter(Boolean).join(`
4
-
5
- `)}\n`}function _(e,t){return`${e} ${e===1?t:`${t}s`}`}function v(e){return e.map(e=>{let t=e.rule===`undefined-key`&&e.sourceReferences?.length?e.sourceReferences[0]:void 0,n=t?.path??e.location?.file,r=[n&&`file=${x(y(n))}`,t?.line&&`line=${t.line}`,`title=${x(e.rule)}`].filter(Boolean).join(`,`),i=b(`"${e.key}": ${e.message}\n${h(e.rule)}`);return`::${e.severity} ${r}::${i}`}).join(`
6
- `)}function y(e){let t=l.env.GITHUB_WORKSPACE;return t?f(t,p(e)):e}function b(e){return e.replace(/%/g,`%25`).replace(/\r/g,`%0D`).replace(/\n/g,`%0A`)}function x(e){return b(e).replace(/:/g,`%3A`).replace(/,/g,`%2C`)}function S(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 C(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}=w(e);i.push(r(t)),i.push(...E(n,e))}return i.join(`
7
- `)}function w(e){let n=`"${e.key}"`,r=e.targetMessage??e.sourceMessage,o=T(n),s=e.highlight?.type===`value`||e.highlight?.type===`argument`,c=s?u.dim(n):n,l=u.dim(`: `),d=i(n);if(r!==void 0&&e.highlight?.type===`argument`){let t=a(r),n=e.highlight.token,s=t.indexOf(n);if(s>=0){let{inner:e,offset:r}=D(t,s,n.length,o);return{content:`${c}${l}"${e}"`,span:{column:d+3+r,length:i(n)}}}}let f=r===void 0?`"…"`:`"${t(a(r),o)}"`,p=`${c}${l}${s?f:u.dim(f)}`;return r!==void 0&&e.highlight?.type===`value`?{content:p,span:{column:d+2,length:i(f)}}:{content:p,span:{column:0,length:d}}}function T(e){let t=3+i(e)+2+2;return Math.max(24,Math.min(48,n()-t))}function E(e,t){let n=t.severity===`error`?u.red:u.yellow,i=Math.min(1,e.length-1),a=`─`.repeat(i)+`┬`+`─`.repeat(e.length-1-i),o=`${t.message} ${u.dim(`(${t.rule})`)}`;return[r(` `.repeat(e.column)+n(a)),r(`${` `.repeat(e.column+i)}${n(`╰─`)} ${o}`)]}function D(e,t,n,r){let i=o(e),a=i.reduce((e,t)=>e+t.width,0),s=O(i,t),c=O(i,t+n);if(a<=r)return{inner:e,offset:k(i,0,s)};let l=Math.max(k(i,s,c),r-2),u=s,d=0;for(;u>0&&d+i[u-1].width<=16;)u--,d+=i[u].width;let f=s;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:k(i,u,s)+p.length}}function O(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 k(e,t,n){let r=0;for(let i=t;i<n;i++)r+=e[i].width;return r}export{m as default,v as formatGithubAnnotations,g as formatLint};
@@ -1 +0,0 @@
1
- import{resolve as e}from"node:path";function t(t,n){return(Array.isArray(t)?t:[t]).map(t=>e(n,t))}export{t};
@@ -1 +0,0 @@
1
- import{defineCommand as e}from"citty";var t=e({meta:{name:`upload`,description:`Upload sources or translations to your Crowdin project.`},subCommands:{sources:()=>import(`./sources-D2CmEsFc.mjs`).then(e=>e.default),translations:()=>import(`./translations-5dIUqhdZ.mjs`).then(e=>e.default)}});export{t as default};
@@ -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(){return n(e.env.XDG_CONFIG_HOME??n(r(),`.config`),`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_STUDIO_URL??`https://studio.eloqnt.dev`}function p(){return`${f()}/api/auth`}export{u as a,l as i,f as n,d as r,p as t};