@eloqnt/cli 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/eloqnt.mjs +1 -1
- package/dist/defineEloqntCommand-CsM_g_XS.mjs +2 -0
- package/dist/{lint-D7191wzi.mjs → lint-Der-f_t7.mjs} +1 -1
- package/dist/{status-BlndPEOf.mjs → status-B4lvo1TO.mjs} +1 -1
- package/dist/translate-Cz-hJ6Gv.mjs +4 -0
- package/package.json +2 -2
- package/dist/defineEloqntCommand-BrLGrJ7d.mjs +0 -1
- package/dist/translate-1gUfH1xf.mjs +0 -4
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,runMain as n}from"citty";try{e.loadEnvFile()}catch{}n(t({meta:{name:`eloqnt`,description:`AI-powered translations for developers`},subCommands:{status:r(()=>import(`../status-
|
|
2
|
+
import e from"node:process";import{defineCommand as t,runMain as n}from"citty";try{e.loadEnvFile()}catch{}n(t({meta:{name:`eloqnt`,description:`AI-powered translations for developers`},subCommands:{status:r(()=>import(`../status-B4lvo1TO.mjs`)),lint:r(()=>import(`../lint-Der-f_t7.mjs`)),translate:r(()=>import(`../translate-Cz-hJ6Gv.mjs`)),login:r(()=>import(`../login-qJXHaxC9.mjs`)),logout:r(()=>import(`../logout-Dv-YLq8P.mjs`)),whoami:r(()=>import(`../whoami-CR34U7uT.mjs`))}}));function r(e){return()=>e().then(e=>e.default)}export{};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{EloqntSdkError as e,loadConfig as t}from"@eloqnt/sdk";import n from"node:process";import{defineCommand as r}from"citty";import i from"picocolors";function a(e){let t=[`${i.red(i.bold(`✗ ${e.message}`))} ${i.dim(`(${e.code})`)}`],{details:n}=e;if(n)if(t.push(``),typeof n==`string`)t.push(` ${n}`);else{t.push(` ${n.heading}`);for(let e of n.items)t.push(` ${i.dim(`•`)} ${e}`)}return t.push(``,i.cyan(`→ ${e.hint}`)),e.docsUrl&&t.push(i.dim(` ${e.docsUrl}`)),`\n${t.join(`
|
|
2
|
+
`)}`}function o(i){return r({meta:i.meta,args:{config:{type:`string`,description:`Path to the eloqnt config file (defaults to .eloqnt/config.{ts,mts,js,mjs})`},json:{type:`boolean`,description:`Output the result as JSON`,default:!1},...i.args},async run({args:r}){try{let{config:e,rootDir:a}=await t({configPath:r.config}),o=await i.execute({config:e,rootDir:a,args:r}),s=r.json?JSON.stringify(i.json?i.json(o):o,null,2):i.render(o);n.stdout.write(`${s}\n`),i.ok&&!i.ok(o)&&(n.exitCode=1)}catch(t){if(t instanceof e){n.stderr.write(`${a(t)}\n`),n.exitCode=1;return}throw t}}})}export{o as t};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{t as e}from"./defineEloqntCommand-
|
|
1
|
+
import{t as e}from"./defineEloqntCommand-CsM_g_XS.mjs";import{lint as t}from"@eloqnt/sdk";import n from"node:process";import{relative as r,resolve as i}from"node:path";import a from"picocolors";const o=new Intl.Segmenter,s=[[4352,4447],[9001,9002],[11904,12350],[12353,13311],[13312,19903],[19968,40959],[40960,42191],[44032,55203],[63744,64255],[65040,65049],[65072,65135],[65280,65376],[65504,65510],[126976,127743],[127744,129791],[131072,262141]];function c(e){let t=[];for(let{segment:n}of o.segment(e))t.push({text:n,width:u(n)});return t}function l(e){let t=0;for(let{segment:n}of o.segment(e))t+=u(n);return t}function u(e){let t=e.codePointAt(0)??0;return d(t)?0:s.some(([e,n])=>t>=e&&t<=n)?2:1}function d(e){return e<=31||e>=127&&e<=159||e>=768&&e<=879||e>=8203&&e<=8207||e>=8232&&e<=8238||e>=8288&&e<=8292||e===65279}var f=e({meta:{name:`lint`,description:`Statically analyze your source code and messages for common problems.`},async execute({config:e,rootDir:a}){let{messages:o,srcPath:s}=e;function c(e){return(Array.isArray(e)?e:[e]).map(e=>i(a,e))}let l=await t({messagesPath:c(o.path),sourceLocale:o.sourceLocale,format:o.format,locales:o.locales,srcPath:s?c(s):void 0,cwd:a}),u=n.cwd();return{issues:l.map(e=>e.location?{...e,location:{...e.location,file:r(u,e.location.file)}}:e),sourceLocale:o.sourceLocale}},render:({issues:e,sourceLocale:t})=>p(e,t),ok:({issues:e})=>e.length===0,json:({issues:e})=>e});function p(e,t){if(e.length===0)return`\n${a.green(`No issues found`)}`;let n=Object.groupBy(e,e=>e.location?.file??e.locale),r=m(Object.entries(n),t).map(([e,n])=>h(e,n,n[0].locale===t)),i=`${e.length} ${e.length===1?`issue`:`issues`}`,o=a.bold(a.red(`${i} found`));return`\n${[...r,o].join(`
|
|
2
2
|
|
|
3
3
|
`)}`}function m(e,t){let n=e.findIndex(([,e])=>e[0].locale===t);if(n<=0)return e;let r=[...e],[i]=r.splice(n,1);return[i,...r]}function h(e,t,n){let r=[n?`${a.cyan(e)} ${a.dim(`(source locale)`)}`:a.cyan(e)];for(let e of t){r.push(a.dim(`│`));let{content:t,span:n}=g(e);r.push(y(t)),r.push(...v(n,e.message,e.rule))}return r.join(`
|
|
4
4
|
`)}function g(e){let t=`"${e.key}"`,n=e.targetMessage??e.sourceMessage,r=_(t),i=e.highlight?.type===`value`||e.highlight?.type===`argument`,o=i?a.dim(t):t,s=a.dim(`: `),c=l(t);if(n!==void 0&&e.highlight?.type===`argument`){let t=w(n),i=`{${e.highlight.name}}`,a=t.indexOf(i);if(a>=0){let{inner:e,offset:n}=b(t,a,i.length,r);return{content:`${o}${s}"${e}"`,span:{column:c+3+n,length:l(i)}}}}let u=n===void 0?`"…"`:`"${T(w(n),r)}"`,d=`${o}${s}${i?u:a.dim(u)}`;return n!==void 0&&e.highlight?.type===`value`?{content:d,span:{column:c+2,length:l(u)}}:{content:d,span:{column:0,length:c}}}function _(e){let t=3+l(e)+2+2;return Math.max(24,Math.min(48,80-t))}function v(e,t,n){let r=Math.min(1,e.length-1),i=`─`.repeat(r)+`┬`+`─`.repeat(e.length-1-r),o=`${t} ${a.dim(`(${n})`)}`;return[y(` `.repeat(e.column)+a.yellow(i)),y(`${` `.repeat(e.column+r)}${a.yellow(`╰─`)} ${o}`)]}function y(e){return a.dim(`│ `)+e}function b(e,t,n,r){let i=c(e),a=i.reduce((e,t)=>e+t.width,0),o=x(i,t),s=x(i,t+n);if(a<=r)return{inner:e,offset:S(i,0,o)};let l=Math.max(S(i,o,s),r-2),u=o,d=0;for(;u>0&&d+i[u-1].width<=16;)u--,d+=i[u].width;let f=o;for(;f<i.length&&d+i[f].width<=l;)d+=i[f].width,f++;for(;u>0&&d+i[u-1].width<=l;)u--,d+=i[u].width;let p=u>0?`…`:``,m=f<i.length?`…`:``;return{inner:p+i.slice(u,f).map(e=>e.text).join(``)+m,offset:S(i,u,o)+p.length}}function x(e,t){let n=0;for(let r=0;r<e.length;r++){if(n>=t)return r;n+=e[r].text.length}return e.length}function S(e,t,n){let r=0;for(let i=t;i<n;i++)r+=e[i].width;return r}const C=RegExp(`[\0--]`,`g`);function w(e){return e.replace(/\s+/g,` `).replace(C,``).trim()}function T(e,t){if(l(e)<=t)return e;let n=``,r=0;for(let i of c(e)){if(r+i.width>t-1)break;n+=i.text,r+=i.width}return`${n}…`}export{f as default,p as formatLint};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{t as e}from"./defineEloqntCommand-
|
|
1
|
+
import{t as e}from"./defineEloqntCommand-CsM_g_XS.mjs";import{getStatus as t}from"@eloqnt/sdk";import{resolve as n}from"node:path";import r from"picocolors";var i=e({meta:{name:`status`,description:`Report translation completeness per locale.`},async execute({config:e,rootDir:r}){let{messages:i}=e;return await t({messagesPath:(Array.isArray(i.path)?i.path:[i.path]).map(e=>n(r,e)),sourceLocale:i.sourceLocale,format:i.format,locales:i.locales,cwd:r})},render(e){let{source:t,targets:n}=e,i=Math.max(t.locale.length,...n.map(e=>e.locale.length)),a=`${t.totalMessages} ${t.totalMessages===1?`message`:`messages`}`,o=[`${r.bold(t.locale.padEnd(i))} ${r.dim(a)}`];for(let e of n){let t=r.bold(e.locale.padEnd(i)),n=e.missing.length===0?r.green(`complete`):r.yellow(`${e.missing.length} missing`);o.push(`${t} ${n}`)}return o.join(`
|
|
2
2
|
`)}});export{i as default};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{t as e}from"./defineEloqntCommand-CsM_g_XS.mjs";import{i as t,n}from"./urls-DdV5qJFG.mjs";import{loadStyleguide as r,translate as i}from"@eloqnt/sdk";import a from"node:process";import{basename as o,dirname as s,relative as c,resolve as l}from"node:path";import u from"picocolors";function d(e,t={month:`short`,day:`numeric`}){return new Date(e).toLocaleDateString(`en-US`,t)}var f=e({meta:{name:`translate`,description:`Translate strings to target locales (defaults to missing ones).`,requiresLogin:!0},args:{id:{type:`string`,description:`(Re-)translate these message ids (comma-separated)`},locale:{type:`string`,description:`Restrict to these target locales (comma-separated)`}},async execute({config:e,rootDir:o,args:s}){let{messages:d}=e,f=(Array.isArray(d.path)?d.path:[d.path]).map(e=>l(o,e)),p=await r({cwd:o}),m=e.model?`local eloqnt/engine running ${typeof e.model==`string`?e.model:e.model.modelId}`:`hosted eloqnt/engine`;a.stderr.write(u.dim(`\nTranslating via ${m} …\n`));let h=await i({messagesPath:f,sourceLocale:d.sourceLocale,format:d.format,locales:d.locales,cwd:o,engineUrl:n(),languageModel:e.model,providerOptions:e.providerOptions,authToken:await t(),styleguide:p,ids:typeof s.id==`string`?s.id.split(`,`):void 0,onlyLocales:typeof s.locale==`string`?s.locale.split(`,`):void 0}),g=a.cwd();return{result:h,rows:h.targets.map(e=>({file:c(g,e.file),count:e.translated.length})),complete:h.complete}},render({result:e,rows:t,complete:n}){let r=Object.groupBy(t,e=>s(e.file));return`\n${Object.entries(r).map(([e,t=[]])=>{let n=Math.max(0,...t.map(e=>o(e.file).length)),r=t.map(e=>` ${o(e.file).padEnd(n)} ${e.count===0?u.dim(`Nothing to translate`):u.green(`${e.count} translated`)}`);return[u.dim(`${e}/`),...r].join(`
|
|
2
|
+
`)}).join(`
|
|
3
|
+
|
|
4
|
+
`)}\n\n${n?u.green(`✔ Fully translated`):e.quota?u.yellow(`✗ Monthly included usage exhausted — translated as much as possible, resets ${d(e.quota.resetsAt)}`):u.dim(`✗ Partially translated, run eloqnt lint to see what's left`)}`},json:({result:e})=>e});export{f as default};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eloqnt/cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"description": "eloqnt CLI",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"citty": "^0.1.6",
|
|
30
30
|
"open": "^11.0.0",
|
|
31
31
|
"picocolors": "^1.1.1",
|
|
32
|
-
"@eloqnt/sdk": "0.0.
|
|
32
|
+
"@eloqnt/sdk": "0.0.2"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@types/node": "^25.9.1"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{EloqntSdkError as e,loadConfig as t}from"@eloqnt/sdk";import n from"node:process";import{defineCommand as r}from"citty";function i(i){return r({meta:i.meta,args:{config:{type:`string`,description:`Path to the eloqnt config file (defaults to .eloqnt/config.{ts,js,mjs})`},json:{type:`boolean`,description:`Output the result as JSON`,default:!1},...i.args},async run({args:r}){try{let{config:e,rootDir:a}=await t({configPath:r.config}),o=await i.execute({config:e,rootDir:a,args:r}),s=r.json?JSON.stringify(i.json?i.json(o):o,null,2):i.render(o);n.stdout.write(`${s}\n`),i.ok&&!i.ok(o)&&(n.exitCode=1)}catch(t){if(t instanceof e){n.stderr.write(`error (${t.code}): ${t.message}\n`),n.exitCode=1;return}throw t}}})}export{i as t};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./defineEloqntCommand-BrLGrJ7d.mjs";import{i as t,n}from"./urls-DdV5qJFG.mjs";import{loadStyleguide as r,translate as i}from"@eloqnt/sdk";import a from"node:process";import{basename as o,dirname as s,relative as c,resolve as l}from"node:path";import u from"picocolors";function d(e,t={month:`short`,day:`numeric`}){return new Date(e).toLocaleDateString(`en-US`,t)}var f=e({meta:{name:`translate`,description:`Translate strings to target locales (defaults to missing ones).`,requiresLogin:!0},args:{id:{type:`string`,description:`(Re-)translate these message ids (comma-separated)`},locale:{type:`string`,description:`Restrict to these target locales (comma-separated)`}},async execute({config:e,rootDir:o,args:s}){let{messages:d}=e,f=(Array.isArray(d.path)?d.path:[d.path]).map(e=>l(o,e)),p=await r({cwd:o});a.stderr.write(u.dim(`\nTranslating via ${e.model?`your model`:`eloqnt/engine`} …\n\n`));let m=await i({messagesPath:f,sourceLocale:d.sourceLocale,format:d.format,locales:d.locales,cwd:o,engineUrl:n(),languageModel:e.model,authToken:await t(),styleguide:p,ids:typeof s.id==`string`?s.id.split(`,`):void 0,onlyLocales:typeof s.locale==`string`?s.locale.split(`,`):void 0}),h=a.cwd();return{result:m,rows:m.targets.map(e=>({file:c(h,e.file),count:e.translated.length})),complete:m.complete}},render({result:e,rows:t,complete:n}){let r=Object.groupBy(t,e=>s(e.file));return`${Object.entries(r).map(([e,t=[]])=>{let n=Math.max(0,...t.map(e=>o(e.file).length)),r=t.map(e=>` ${o(e.file).padEnd(n)} ${e.count===0?u.dim(`Nothing to translate`):u.green(`${e.count} translated`)}`);return[u.dim(`${e}/`),...r].join(`
|
|
2
|
-
`)}).join(`
|
|
3
|
-
|
|
4
|
-
`)}\n\n${n?u.green(`✔ Fully translated`):e.quota?u.yellow(`✗ Monthly included usage exhausted — translated as much as possible, resets ${d(e.quota.resetsAt)}`):u.dim(`✗ Partially translated, run eloqnt lint to see what's left`)}`},json:({result:e})=>e});export{f as default};
|