@eloqnt/cli 0.6.32 → 0.7.0
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 +28 -0
- package/dist/bin/eloqnt.mjs +1 -1
- package/dist/context-BKSAltkI.mjs +1 -0
- package/dist/crowdin-MDUTKr-r.mjs +1 -0
- package/dist/{defineEloqntCommand-BNNDggcZ.mjs → defineEloqntCommand-GkAsZ0sd.mjs} +1 -1
- package/dist/download-CVroYXQr.mjs +3 -0
- package/dist/{download-DfXkJo_Z.mjs → download-DBgR7tC_.mjs} +1 -1
- package/dist/extract-BW3QOv6G.mjs +3 -0
- package/dist/lint-CfQICr8Y.mjs +7 -0
- package/dist/{login-cvA1zw4B.mjs → login-wvtfpkQs.mjs} +1 -1
- package/dist/{logout-BAr7ojyZ.mjs → logout-DvSJiVwt.mjs} +1 -1
- package/dist/report-CIHPhU_6.mjs +1 -0
- package/dist/resolvePaths-CKsEPHfH.mjs +1 -0
- package/dist/{review-hRnF51uJ.mjs → review-B_PGSNrY.mjs} +1 -1
- package/dist/source-QvIhIT-3.mjs +11 -0
- package/dist/{sources-CYGybeK8.mjs → sources-B_5yAc3F.mjs} +1 -1
- package/dist/stringWidth-D0Z3LOKi.mjs +1 -0
- package/dist/{translate-D4A7TVLU.mjs → translate-CZbtc5Zk.mjs} +4 -4
- package/dist/{translations-DmsEv9OB.mjs → translations-BSNkEO3Z.mjs} +1 -1
- package/dist/{translations-BhDnGrNN.mjs → translations-DPiOLF_D.mjs} +1 -1
- package/dist/upload-DJx2EJFi.mjs +3 -0
- package/dist/upload-DpfJtQaM.mjs +1 -0
- package/dist/{whoami-CUFPZPY4.mjs → whoami-QGFYR_hV.mjs} +1 -1
- package/dist/{withErrorFormatting-CnMLjXSn.mjs → withErrorFormatting-rhiaj7Md.mjs} +1 -1
- package/package.json +2 -2
- package/dist/crowdin-DdfREp0-.mjs +0 -1
- package/dist/lint-Wu02Ge85.mjs +0 -7
- package/dist/report-CEfrIjER.mjs +0 -1
- package/dist/source-CNaJNsTq.mjs +0 -11
- package/dist/stringWidth-DvyI3S_b.mjs +0 -1
- package/dist/upload-Dsy5tcAd.mjs +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# @eloqnt/cli
|
|
2
2
|
|
|
3
|
+
## 0.7.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 0df71c3: `inconsistent-args` now flags a translation that prints an argument through a different formatter than the source or drops its select, e.g. `#` → `{count}`.
|
|
8
|
+
- 72bb518: Add a `missing-plural-count` lint rule for a translated plural case without the count that the locale selects for several numbers, e.g. Portuguese `one {uma meta}`, which also renders for 0.
|
|
9
|
+
|
|
10
|
+
### Patch Changes
|
|
11
|
+
|
|
12
|
+
- ebb6cd6: `inconsistent-exact-plurals` and `translate` now accept exact plural cases a translation adds, e.g. French `=0 {Aucun objectif}`, and only report the source's exact cases a translation drops. `translate` adds one where a number the source words without the count shares its category with other numbers.
|
|
13
|
+
- Updated dependencies [0df71c3]
|
|
14
|
+
- Updated dependencies [ebb6cd6]
|
|
15
|
+
- Updated dependencies [72bb518]
|
|
16
|
+
- @eloqnt/sdk@0.7.0
|
|
17
|
+
|
|
18
|
+
## 0.6.33
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- a925589: Add `eloqnt crowdin context extract`, `upload`, and `download` to add a source outline of where your code uses each string to its context on Crowdin. Context you write in place of an outline is kept until the string’s text changes.
|
|
23
|
+
- a925589: Fail with an error when a `srcPath` folder doesn’t exist or holds no next-intl calls, instead of running `lint`, `translate`, and `review source` without source analysis.
|
|
24
|
+
- Updated dependencies [a925589]
|
|
25
|
+
- Updated dependencies [5a2a313]
|
|
26
|
+
- Updated dependencies [ad5c626]
|
|
27
|
+
- Updated dependencies [dec6700]
|
|
28
|
+
- Updated dependencies [a925589]
|
|
29
|
+
- @eloqnt/sdk@0.6.31
|
|
30
|
+
|
|
3
31
|
## 0.6.32
|
|
4
32
|
|
|
5
33
|
### Patch Changes
|
package/dist/bin/eloqnt.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import e from"node:process";import{defineCommand as t,renderUsage as n,runMain as r}from"citty";import i from"picocolors";var a=`0.
|
|
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.7.0`;try{e.loadEnvFile()}catch{}const o=t({meta:{name:`eloqnt`,version:a,description:`AI-powered translations for developers`},subCommands:{lint:d(()=>import(`../lint-CfQICr8Y.mjs`)),review:d(()=>import(`../review-B_PGSNrY.mjs`)),translate:d(()=>import(`../translate-CZbtc5Zk.mjs`)),crowdin:d(()=>import(`../crowdin-MDUTKr-r.mjs`)),login:d(()=>import(`../login-wvtfpkQs.mjs`)),logout:d(()=>import(`../logout-DvSJiVwt.mjs`)),whoami:d(()=>import(`../whoami-QGFYR_hV.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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{defineCommand as e}from"citty";var t=e({meta:{name:`context`,description:`Extract, upload, and download context for your Crowdin strings.`},subCommands:{extract:()=>import(`./extract-BW3QOv6G.mjs`).then(e=>e.default),upload:()=>import(`./upload-DJx2EJFi.mjs`).then(e=>e.default),download:()=>import(`./download-CVroYXQr.mjs`).then(e=>e.default)}});export{t as default};
|
|
@@ -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-DpfJtQaM.mjs`).then(e=>e.default),download:()=>import(`./download-DBgR7tC_.mjs`).then(e=>e.default),context:()=>import(`./context-BKSAltkI.mjs`).then(e=>e.default)}});export{t as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./withErrorFormatting-
|
|
1
|
+
import{t as e}from"./withErrorFormatting-rhiaj7Md.mjs";import t from"node:process";import{defineCommand as n}from"citty";import{loadConfig as r}from"@eloqnt/sdk/_internal";function i(i){let a=i.requiresConfig!==!1;return n({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:n}){return e(async()=>{let e;if(a){let{config:t,rootDir:i}=await r({configPath:n.config});e={config:t,rootDir:i,args:n}}else e={config:void 0,rootDir:t.cwd(),args:n};let o=await i.execute(e),s=n.json?JSON.stringify(i.json?i.json(o):o,null,2):i.render(o);t.stdout.write(`${s}\n`),i.ok&&!i.ok(o)&&(t.exitCode=1)})}})}export{i as t};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{t as e}from"./defineEloqntCommand-GkAsZ0sd.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{basename as o,relative as s}from"node:path";import{downloadCrowdinContext as c}from"@eloqnt/sdk/_internal";var l=e({meta:{name:`download`,description:`Download the strings of your Crowdin project with their current context.`},requiresConfig:!1,args:{branch:{type:`string`,description:`Sync with this branch of the Crowdin project`}},async execute({rootDir:e,args:t}){let n=await r({label:`Downloading context from Crowdin`,json:!!t.json,task:()=>c({rootDir:e,branch:t.branch})}),a=i.cwd();return{result:{...n,contextFile:s(a,n.contextFile),files:n.files.map(e=>({...e,file:s(a,e.file)}))}}},render({result:e}){let r=e.files.map(e=>({file:e.file,detail:a.green(`${e.strings} ${e.strings===1?`string`:`strings`}`)+(e.withAiContext>0?a.dim(`, ${e.withAiContext} with AI context`):``)})),i=e.files.reduce((e,t)=>e+t.strings,0),s=a.green(`✔ Downloaded ${i} ${i===1?`string`:`strings`} from ${e.project.name} to ${o(e.contextFile)}`)+(e.branch?` ${a.dim(`(${e.branch})`)}`:``);return`\n${[t(r),...n(e.warnings),s].join(`
|
|
2
|
+
|
|
3
|
+
`)}`},json:({result:e})=>e});export{l 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-
|
|
1
|
+
import{defineCommand as e}from"citty";var t=e({meta:{name:`download`,description:`Download translations from your Crowdin project.`},subCommands:{translations:()=>import(`./translations-BSNkEO3Z.mjs`).then(e=>e.default)}});export{t as default};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{t as e}from"./defineEloqntCommand-GkAsZ0sd.mjs";import{n as t,r as n,t as r}from"./withSpinner-CeQSfolX.mjs";import{t as i}from"./resolvePaths-CKsEPHfH.mjs";import a from"node:process";import o from"picocolors";import{basename as s,relative as c}from"node:path";import{extractCrowdinContext as l}from"@eloqnt/sdk/_internal-source";var u=e({meta:{name:`extract`,description:`Extract context for your Crowdin strings from how your code uses them.`},async execute({config:e,rootDir:t,args:n}){let{messages:o,srcPath:s}=e,u=await r({label:`Extracting context from source code`,json:!!n.json,task:()=>l({messagesPath:i(o.path,t),sourceLocale:o.sourceLocale,format:o.format,locales:o.locales,codes:o.codes,srcPath:s?i(s,t):void 0,rootDir:t})}),d=a.cwd();return{result:{...u,contextFile:c(d,u.contextFile),files:u.files.map(e=>({...e,file:c(d,e.file)}))}}},render({result:e}){let r=e.files.map(e=>({file:e.file,detail:o.green(`${e.extracted} extracted`)+(e.reset>0?o.dim(`, ${e.reset} ${e.reset===1?`edit`:`edits`} reset to an outline`):``)+(e.unused>0?o.dim(`, ${e.unused} not found in source`):``)})),i=e.files.reduce((e,t)=>e+t.extracted,0),a=i===0?o.dim(`No strings found in source code`):o.green(`✔ Extracted context for ${i} ${i===1?`string`:`strings`} to ${s(e.contextFile)}`),c=[t(r),...n(e.warnings),a],l=i>0?o.dim("→ Run `eloqnt crowdin context upload` to upload it"):void 0;return`\n${c.join(`
|
|
2
|
+
|
|
3
|
+
`)}${l?`\n\n${l}`:``}`},json:({result:e})=>e});export{u as default};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import{t as e}from"./defineEloqntCommand-GkAsZ0sd.mjs";import{t}from"./resolvePaths-CKsEPHfH.mjs";import{n,t as r}from"./report-CIHPhU_6.mjs";import{a as i,i as a,r as o,t as s}from"./stringWidth-D0Z3LOKi.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:n,args:r}){let{messages:i,srcPath:a}=e,o=await c({messagesPath:t(i.path,n),sourceLocale:i.sourceLocale,format:i.format,locales:i.locales,codes:i.codes,srcPath:a?t(a,n):void 0,rules:e.lint?.rules,overrides:e.lint?.overrides,rootDir:n}),s=l.cwd();return{issues:o.map(e=>{let t=e;if(t.location&&(t={...t,location:{...t.location,file:d(s,t.location.file)}}),t.rule===`undefined-key`&&t.sourceReferences?.length){let e=t.sourceReferences.map(e=>({...e,path:d(s,e.path)})),n=e[0].line?`${e[0].path}:${e[0].line}`:e[0].path,r=e.length>1?` (+${e.length-1} more)`:``;t={...t,sourceReferences:e,message:`Used in ${n}${r} but not defined for ${i.sourceLocale}`}}return t}),sourceLocale:i.sourceLocale,noSrcPath:!a,strict:!!r.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://cli.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 t=`"${e.key}"`,r=e.targetMessage??e.sourceMessage,a=w(t),s=e.highlight?.type===`value`||e.highlight?.type===`argument`,c=s?u.dim(t):t,l=u.dim(`: `),d=o(t);if(r!==void 0&&e.highlight?.type===`argument`){let t=n(r),i=e.highlight.token,s=t.indexOf(i);if(s>=0){let{inner:e,offset:n}=E(t,s,i.length,a);return{content:`${c}${l}"${e}"`,span:{column:d+3+n,length:o(i)}}}}let f=r===void 0?`"…"`:`"${i(n(r),a)}"`,p=`${c}${l}${s?f:u.dim(f)}`;return r!==void 0&&e.highlight?.type===`value`?{content:p,span:{column:d+2,length:o(f)}}:{content:p,span:{column:0,length:d}}}function w(e){let t=3+o(e)+2+2;return Math.max(24,Math.min(48,a()-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=s(e),a=i.reduce((e,t)=>e+t.width,0),o=D(i,t),c=D(i,t+n);if(a<=r)return{inner:e,offset:O(i,0,o)};let l=Math.max(O(i,o,c),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:O(i,u,o)+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-
|
|
1
|
+
import{t as e}from"./bin/eloqnt.mjs";import{t}from"./withErrorFormatting-rhiaj7Md.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-
|
|
1
|
+
import{t as e}from"./withErrorFormatting-rhiaj7Md.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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"picocolors";function t(t){return e.dim(`│ `)+t}const n=/* @__PURE__ */ RegExp(`[\0--]`,`g`);function r(e){return e.replace(/\s+/g,` `).replace(n,``).trim()}export{r as n,t};
|
|
@@ -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-
|
|
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-QvIhIT-3.mjs`).then(e=>e.default)}});export{t as default};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import{t as e}from"./defineEloqntCommand-GkAsZ0sd.mjs";import{t}from"./createSpinner-BBkrpcrh.mjs";import{t as n}from"./resolvePaths-CKsEPHfH.mjs";import{t as r}from"./parseListArg-p5H1s5JC.mjs";import{n as i,t as a}from"./report-CIHPhU_6.mjs";import{a as o,i as s,n as c,r as l}from"./stringWidth-D0Z3LOKi.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:i,args:a}){let{messages:o,srcPath:s}=e,c=n(o.path,i),l=s?n(s,i):void 0,f=await x({rootDir:i,path:e.styleguides}),v=p(f,[o.sourceLocale]),y=e.model?`eloqnt/engine (${typeof e.model==`string`?e.model:e.model.modelId})`:`eloqnt/engine (hosted)`,S=g.stderr.isTTY&&!a.json,C;function w(e){if(!a.json){if(e.phase===`context-enrichment`){e.state===`started`?(g.stderr.write(`
|
|
2
|
+
`),S?(C=t({withGuide:!1}),C.start(`Context enrichment running`)):g.stderr.write(_.dim(`Context enrichment running …
|
|
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}if(e.phase===`post-checks`){e.state===`started`?S?(C=t({withGuide:!1}),C.start(`Post-review checks running`)):g.stderr.write(_.dim(`Post-review checks running …
|
|
5
|
+
`)):(C?.clear(),C=void 0,m(_.green(`✔`),`Post-review checks done`));return}e.state===`started`?(v?m(_.green(`✔`),v):m(_.dim(`–`),`No styleguides found`),S?(C=t({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:c,sourceLocale:o.sourceLocale,format:o.format,locales:o.locales,codes:o.codes,rootDir:i,engineUrl:d(),languageModel:e.model,authToken:await u(),styleguide:f,ids:r(a.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=s()){let{findings:n,reviewed:r,missingTranslations:i,quota:a}=e,o=[],c=/* @__PURE__ */ 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));o.push(r.join(`
|
|
6
|
+
`))}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,a!==void 0)}`});return[_.dim(`${e}/`),...r].join(`
|
|
7
|
+
`)}).join(`
|
|
8
|
+
|
|
9
|
+
`);o.push(d),a&&o.push(_.yellow(`! Monthly included usage exhausted, reviewed as much as possible. Resets ${f(a.resetsAt)}`));let p=r===0?_.dim(`→ Add new strings for the source locale to review them before translation`):i>0?_.dim("→ Run `eloqnt translate` to translate"):void 0;return`\n${o.join(`
|
|
10
|
+
|
|
11
|
+
`)}${p?`\n\n${p}`:``}\n`}function w(e,t){let n=t-3-2,r=e.newId??e.id,o=T(e.id,e.before,n),s=[a(`${_.red(`-`)} ${_.dim(o)}`)],u;if(e.status===`fixed`){let t=T(r,e.after,n),i=E(e.via,e.sourceFiles,n-l(t));u=i?T(r,e.after,n-l(i)):t,s.push(a(`${_.green(`+`)} ${u}${i?_.dim(i):``}`))}else{let t=e.sourceFiles[0],i;if(t){let e=[t,D(t),v(t)].map(e=>` (apply manually in ${e})`);i=c(n,e)||e.at(-1)}else i=` (apply manually)`;u=T(r,e.after,n-l(i)),s.push(a(`${_.yellow(`!`)} ${u}${_.dim(i)}`))}let d=Math.min(l(u)+2,t-3);return s.push(a(_.yellow(`─┬${`─`.repeat(Math.max(0,d-2))}`))),s.push(a(` ${_.yellow(`╰─`)} ${i(e.note)}`)),s}function T(e,t,n){let r=l(`"${e}": ""`);return`"${e}": "${o(i(t),Math.max(0,n-r))}"`}function E(e,t,n){if(e!==`code`||t.length===0)return``;let r=t.length>1?[`(${t.length} call sites)`]:[`(${t[0]})`,`(${D(t[0])})`,`(${v(t[0])})`],i=c(n-1,r);return i?` ${i}`:``}function D(e){let t=e.split(`/`);return t.length<=2?e:`${t[0]}/…/${t.at(-1)}`}function O(e,t){let n=/* @__PURE__ */ new Map;for(let r of e){let e=r.file??t,i=n.get(e)??{fixed:0,reported:0};i[r.status===`fixed`?`fixed`:`reported`]++,n.set(e,i)}return n}function k(e,t,n,r){if(e===0)return _.dim(`Nothing to review`);let i=[`${e} reviewed`];t===0&&n===0&&!r&&i.push(`no fixes needed`),t>0&&i.push(`${t} fixed`),n>0&&i.push(`${n} ${n===1?`needs`:`need`} a manual edit`);let a=i.join(`, `);return n>0?_.yellow(a):r?_.dim(a):_.green(a)}export{S as default};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{t as e}from"./defineEloqntCommand-
|
|
1
|
+
import{t as e}from"./defineEloqntCommand-GkAsZ0sd.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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"node:process";const t=new Intl.Segmenter,n=[[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 r(e){let n=[];for(let{segment:r}of t.segment(e))n.push({text:r,width:c(r)});return n}function i(e){let n=0;for(let{segment:r}of t.segment(e))n+=c(r);return n}function a(t=80){let{columns:n,isTTY:r}=e.stdout;return!r||!n?t:Math.max(40,n)}function o(e,t){if(i(e)<=t)return e;let n=``,a=0;for(let i of r(e)){if(a+i.width>t-1)break;n+=i.text,a+=i.width}return`${n}…`}function s(e,t){return t.find(t=>i(t)<=e)??``}function c(e){let t=e.codePointAt(0)??0;return l(t)?0:n.some(([e,n])=>t>=e&&t<=n)?2:1}function l(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}export{o as a,a as i,s as n,i as r,r as t};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import{t as e}from"./defineEloqntCommand-
|
|
2
|
-
`),O?(k=
|
|
1
|
+
import{t as e}from"./defineEloqntCommand-GkAsZ0sd.mjs";import{t}from"./createSpinner-BBkrpcrh.mjs";import{t as n}from"./resolvePaths-CKsEPHfH.mjs";import{t as r}from"./parseListArg-p5H1s5JC.mjs";import{a as i,i as a,n as o}from"./stringWidth-D0Z3LOKi.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=n(g.path,l),x=_?n(_,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=r(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 r=`(${t}/${n})`,s=a()-4,c=`Translating ${e}% done`;return o(s,[`Translating ${E} · ${e}% done ${r}`,`Translating ${E} · ${e}% done`,`Translating ${e}% done ${r}`,c])||i(c,s)}let j=0;function M(e){if(!u.json){if(e.phase===`context-enrichment`){e.state===`started`?(m.stderr.write(`
|
|
2
|
+
`),O?(k=t({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
|
-
`),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=
|
|
5
|
-
`)):(k?.clear(),k=void 0,f(h.green(`✔`),`Post-translation checks done`))}}let N;try{N=await p({messagesPath:b,sourceLocale:g.sourceLocale,format:g.format,locales:g.locales,codes:g.codes,rootDir:l,engineUrl:c(),languageModel:e.model,authToken:await s(),styleguide:S,ids:
|
|
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=t({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=t({withGuide:!1}),k.start(`Post-translation checks running`)):m.stderr.write(h.dim(`Post-translation checks running …
|
|
5
|
+
`)):(k?.clear(),k=void 0,f(h.green(`✔`),`Post-translation checks done`))}}let N;try{N=await p({messagesPath:b,sourceLocale:g.sourceLocale,format:g.format,locales:g.locales,codes:g.codes,rootDir:l,engineUrl:c(),languageModel:e.model,authToken:await s(),styleguide:S,ids:r(u.id),onlyLocales:w,srcPath:x,onProgress:M})}catch(e){throw k?.clear(),e}let P=m.cwd(),F=N.targets.flatMap(e=>e.files.map(t=>({file:v(P,t.file),locale:e.locale,count:t.translated.length})));return{result:N,rows:F,complete:N.complete,noStyleguides:!D}},render({result:e,rows:t,complete:n,noStyleguides:r}){let i=Object.groupBy(t,e=>_(e.file));return`\n${Object.entries(i).map(([e,t=[]])=>{let n=Math.max(0,...t.map(e=>g(e.file).length)),r=t.map(e=>g(e.file)),i=r.length!==new Set(r).size,a=Math.max(0,...t.map(e=>e.locale.length)),o=t.map(e=>` ${g(e.file).padEnd(n)} ${i?`${h.dim(e.locale.padEnd(a))} `:``}${e.count===0?h.dim(`Nothing to translate`):h.green(`${e.count} translated`)}`);return[h.dim(`${e}/`),...o].join(`
|
|
6
6
|
`)}).join(`
|
|
7
7
|
|
|
8
8
|
`)}\n\n${n?h.green(`✔ Project fully translated`):e.quota?h.yellow(`! Monthly included usage exhausted, translated as much as possible. Resets ${u(e.quota.resetsAt)}`):h.dim(`✗ Partially translated, run eloqnt lint to see what's left`)}${r?`\n\n${h.dim(`→ Add a styleguide to improve your translation quality`)}\n${h.dim(` ${l}/docs/styleguides`)}`:``}`},json:({result:e})=>e});export{b as default};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{t as e}from"./defineEloqntCommand-
|
|
1
|
+
import{t as e}from"./defineEloqntCommand-GkAsZ0sd.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};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{t as e}from"./defineEloqntCommand-
|
|
1
|
+
import{t as e}from"./defineEloqntCommand-GkAsZ0sd.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};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{t as e}from"./defineEloqntCommand-GkAsZ0sd.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{uploadCrowdinContext as s}from"@eloqnt/sdk/_internal";var c=e({meta:{name:`upload`,description:`Upload the context in crowdin-context.jsonl to the strings in your Crowdin project.`},requiresConfig:!1,args:{branch:{type:`string`,description:`Sync with this branch of the Crowdin project`}},async execute({rootDir:e,args:t}){let n=await r({label:`Uploading context 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=>{let t=[e.updated>0?a.green(`${e.updated} updated`):void 0,e.unchanged>0?a.dim(`${e.unchanged} unchanged`):void 0,e.skipped>0?a.dim(`${e.skipped} edited on Crowdin`):void 0,e.missing>0?a.yellow(`${e.missing} not on Crowdin`):void 0].filter(Boolean);return{file:e.file,detail:t.length>0?t.join(a.dim(`, `)):a.dim(`Nothing to upload`)}}),i=e.files.reduce((e,t)=>e+t.updated,0),o=i===0?a.dim(`Context on Crowdin is up to date`):a.green(`✔ Uploaded context for ${i} ${i===1?`string`:`strings`} to ${e.project.name}`)+(e.branch?` ${a.dim(`(${e.branch})`)}`:``);return`\n${[t(r),...n(e.warnings),o].join(`
|
|
2
|
+
|
|
3
|
+
`)}`},json:({result:e})=>e});export{c 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-B_5yAc3F.mjs`).then(e=>e.default),translations:()=>import(`./translations-DPiOLF_D.mjs`).then(e=>e.default)}});export{t as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{t as e}from"./defineEloqntCommand-
|
|
1
|
+
import{t as e}from"./defineEloqntCommand-GkAsZ0sd.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};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import e from"node:process";import t from"picocolors";import{EloqntSdkError as n}from"@eloqnt/sdk/_internal";function r(e){let n=[`${t.red(t.bold(`✗ ${e.message}`))} ${t.dim(`(${e.code})`)}`],{details:r}=e;if(r)if(n.push(``),typeof r==`string`)n.push(` ${r}`);else{n.push(` ${r.heading}`);for(let e of r.items)n.push(` ${t.dim(`•`)} ${e}`)}return n.push(``,t.cyan(`→ ${e.hint}`)),e.docsUrl&&n.push(t.dim(` ${e.docsUrl}`)),`\n${n.join(`
|
|
1
|
+
import e from"node:process";import t from"picocolors";import{EloqntSdkError as n}from"@eloqnt/sdk/_internal";function r(e){let n=[`${t.red(t.bold(`✗ ${e.message}`))} ${t.dim(`(${e.code})`)}`],{details:r}=e;if(r){if(n.push(``),typeof r==`string`)n.push(` ${r}`);else{n.push(` ${r.heading}`);for(let e of r.items)n.push(` ${t.dim(`•`)} ${e}`)}}return n.push(``,t.cyan(`→ ${e.hint}`)),e.docsUrl&&n.push(t.dim(` ${e.docsUrl}`)),`\n${n.join(`
|
|
2
2
|
`)}`}async function i(t){try{await t()}catch(t){if(t instanceof n){e.stderr.write(`${r(t)}\n`),e.exitCode=1;return}throw t}}export{i as t};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eloqnt/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "A linter for your translation files, with AI translation built in.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"i18n",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"citty": "^0.1.6",
|
|
38
38
|
"open": "^11.0.0",
|
|
39
39
|
"picocolors": "^1.1.1",
|
|
40
|
-
"@eloqnt/sdk": "0.
|
|
40
|
+
"@eloqnt/sdk": "0.7.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@types/node": "^25.9.5"
|
|
@@ -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-Dsy5tcAd.mjs`).then(e=>e.default),download:()=>import(`./download-DfXkJo_Z.mjs`).then(e=>e.default)}});export{t as default};
|
package/dist/lint-Wu02Ge85.mjs
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./defineEloqntCommand-BNNDggcZ.mjs";import{n as t,t as n}from"./report-CEfrIjER.mjs";import{a as r,i,o as a,r as o,t as s}from"./stringWidth-DvyI3S_b.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,o=await c({messagesPath:a(r.path,t),sourceLocale:r.sourceLocale,format:r.format,locales:r.locales,codes:r.codes,srcPath:i?a(i,t):void 0,rules:e.lint?.rules,overrides:e.lint?.overrides,rootDir:t}),s=l.cwd();return{issues:o.map(e=>{let t=e;if(t.location&&(t={...t,location:{...t.location,file:d(s,t.location.file)}}),t.rule===`undefined-key`&&t.sourceReferences?.length){let e=t.sourceReferences.map(e=>({...e,path:d(s,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://cli.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,r){let i=[r?`${u.cyan(e)} ${u.dim(`(source locale)`)}`:u.cyan(e)];for(let e of t){i.push(u.dim(`│`));let{content:t,span:r}=C(e);i.push(n(t)),i.push(...T(r,e))}return i.join(`
|
|
7
|
-
`)}function C(e){let n=`"${e.key}"`,i=e.targetMessage??e.sourceMessage,a=w(n),s=e.highlight?.type===`value`||e.highlight?.type===`argument`,c=s?u.dim(n):n,l=u.dim(`: `),d=o(n);if(i!==void 0&&e.highlight?.type===`argument`){let n=t(i),r=e.highlight.token,s=n.indexOf(r);if(s>=0){let{inner:e,offset:t}=E(n,s,r.length,a);return{content:`${c}${l}"${e}"`,span:{column:d+3+t,length:o(r)}}}}let f=i===void 0?`"…"`:`"${r(t(i),a)}"`,p=`${c}${l}${s?f:u.dim(f)}`;return i!==void 0&&e.highlight?.type===`value`?{content:p,span:{column:d+2,length:o(f)}}:{content:p,span:{column:0,length:d}}}function w(e){let t=3+o(e)+2+2;return Math.max(24,Math.min(48,i()-t))}function T(e,t){let r=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[n(` `.repeat(e.column)+r(a)),n(`${` `.repeat(e.column+i)}${r(`╰─`)} ${o}`)]}function E(e,t,n,r){let i=s(e),a=i.reduce((e,t)=>e+t.width,0),o=D(i,t),c=D(i,t+n);if(a<=r)return{inner:e,offset:O(i,0,o)};let l=Math.max(O(i,o,c),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:O(i,u,o)+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};
|
package/dist/report-CEfrIjER.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import e from"picocolors";function t(t){return e.dim(`│ `)+t}const n=RegExp(`[\0--]`,`g`);function r(e){return e.replace(/\s+/g,` `).replace(n,``).trim()}export{r as n,t};
|
package/dist/source-CNaJNsTq.mjs
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
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
|
-
`),S?(C=n({withGuide:!1}),C.start(`Context enrichment running`)):g.stderr.write(_.dim(`Context enrichment running …
|
|
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}if(e.phase===`post-checks`){e.state===`started`?S?(C=n({withGuide:!1}),C.start(`Post-review checks running`)):g.stderr.write(_.dim(`Post-review checks running …
|
|
5
|
-
`)):(C?.clear(),C=void 0,m(_.green(`✔`),`Post-review checks done`));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(`
|
|
6
|
-
`))}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,a!==void 0)}`});return[_.dim(`${e}/`),...r].join(`
|
|
7
|
-
`)}).join(`
|
|
8
|
-
|
|
9
|
-
`);s.push(d),a&&s.push(_.yellow(`! Monthly included usage exhausted, reviewed as much as possible. Resets ${f(a.resetsAt)}`));let p=r===0?_.dim(`→ Add new strings for the source locale to review them before translation`):i>0?_.dim("→ Run `eloqnt translate` to translate"):void 0;return`\n${s.join(`
|
|
10
|
-
|
|
11
|
-
`)}${p?`\n\n${p}`:``}\n`}function w(e,t){let n=t-3-2,a=e.newId??e.id,o=T(e.id,e.before,n),c=[i(`${_.red(`-`)} ${_.dim(o)}`)],u;if(e.status===`fixed`){let t=T(a,e.after,n),r=E(e.via,e.sourceFiles,n-l(t));u=r?T(a,e.after,n-l(r)):t,c.push(i(`${_.green(`+`)} ${u}${r?_.dim(r):``}`))}else{let t=e.sourceFiles[0],r;if(t){let e=[t,D(t),v(t)].map(e=>` (apply manually in ${e})`);r=s(n,e)||e.at(-1)}else r=` (apply manually)`;u=T(a,e.after,n-l(r)),c.push(i(`${_.yellow(`!`)} ${u}${_.dim(r)}`))}let d=Math.min(l(u)+2,t-3);return c.push(i(_.yellow(`─┬${`─`.repeat(Math.max(0,d-2))}`))),c.push(i(` ${_.yellow(`╰─`)} ${r(e.note)}`)),c}function T(e,t,n){let i=l(`"${e}": ""`);return`"${e}": "${a(r(t),Math.max(0,n-i))}"`}function E(e,t,n){if(e!==`code`||t.length===0)return``;let r=t.length>1?[`(${t.length} call sites)`]:[`(${t[0]})`,`(${D(t[0])})`,`(${v(t[0])})`],i=s(n-1,r);return i?` ${i}`:``}function D(e){let t=e.split(`/`);return t.length<=2?e:`${t[0]}/…/${t.at(-1)}`}function O(e,t){let n=new Map;for(let r of e){let e=r.file??t,i=n.get(e)??{fixed:0,reported:0};i[r.status===`fixed`?`fixed`:`reported`]++,n.set(e,i)}return n}function k(e,t,n,r){if(e===0)return _.dim(`Nothing to review`);let i=[`${e} reviewed`];t===0&&n===0&&!r&&i.push(`no fixes needed`),t>0&&i.push(`${t} fixed`),n>0&&i.push(`${n} ${n===1?`needs`:`need`} a manual edit`);let a=i.join(`, `);return n>0?_.yellow(a):r?_.dim(a):_.green(a)}export{S as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import e from"node:process";import{resolve as t}from"node:path";function n(e,n){return(Array.isArray(e)?e:[e]).map(e=>typeof e==`string`?t(n,e):{source:t(n,e.source),targets:t(n,e.targets)})}const r=new Intl.Segmenter,i=[[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 a(e){let t=[];for(let{segment:n}of r.segment(e))t.push({text:n,width:u(n)});return t}function o(e){let t=0;for(let{segment:n}of r.segment(e))t+=u(n);return t}function s(t=80){let{columns:n,isTTY:r}=e.stdout;return!r||!n?t:Math.max(40,n)}function c(e,t){if(o(e)<=t)return e;let n=``,r=0;for(let i of a(e)){if(r+i.width>t-1)break;n+=i.text,r+=i.width}return`${n}…`}function l(e,t){return t.find(t=>o(t)<=e)??``}function u(e){let t=e.codePointAt(0)??0;return d(t)?0:i.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}export{c as a,s as i,l as n,n as o,o as r,a as t};
|
package/dist/upload-Dsy5tcAd.mjs
DELETED
|
@@ -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-CYGybeK8.mjs`).then(e=>e.default),translations:()=>import(`./translations-BhDnGrNN.mjs`).then(e=>e.default)}});export{t as default};
|