@eloqnt/cli 0.4.0 → 0.4.1
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
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:{lint:r(()=>import(`../lint-6H7VNJC2.mjs`)),review:r(()=>import(`../review-
|
|
2
|
+
import e from"node:process";import{defineCommand as t,runMain as n}from"citty";try{e.loadEnvFile()}catch{}n(t({meta:{name:`eloqnt`,description:`AI-powered translations for developers`},subCommands:{lint:r(()=>import(`../lint-6H7VNJC2.mjs`)),review:r(()=>import(`../review-BZbZJcYs.mjs`)),translate:r(()=>import(`../translate-BiFqwHuB.mjs`)),login:r(()=>import(`../login-CyIWGXXx.mjs`)),logout:r(()=>import(`../logout-BjdvLusP.mjs`)),whoami:r(()=>import(`../whoami-CTueGAHT.mjs`))}}));function r(e){return()=>e().then(e=>e.default)}export{};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{t as e}from"./withErrorFormatting-CnMLjXSn.mjs";import{a as t,i as n,n as r,t as i}from"./urls-BrJoRsYB.mjs";import{t as a}from"./createSpinner-BBkrpcrh.mjs";import o from"node:process";import{defineCommand as s}from"citty";import c from"picocolors";import{EloqntSdkError as l,getAuthHeaders as u}from"@eloqnt/sdk/_internal";import{hostname as d}from"node:os";import{setTimeout as f}from"node:timers/promises";import{outro as p}from"@clack/prompts";import m from"open";var h=`0.4.
|
|
1
|
+
import{t as e}from"./withErrorFormatting-CnMLjXSn.mjs";import{a as t,i as n,n as r,t as i}from"./urls-BrJoRsYB.mjs";import{t as a}from"./createSpinner-BBkrpcrh.mjs";import o from"node:process";import{defineCommand as s}from"citty";import c from"picocolors";import{EloqntSdkError as l,getAuthHeaders as u}from"@eloqnt/sdk/_internal";import{hostname as d}from"node:os";import{setTimeout as f}from"node:timers/promises";import{outro as p}from"@clack/prompts";import m from"open";var h=`0.4.1`;function g(e){m(e).catch(()=>{})}const _=`eloqnt-cli`,v=`eloqnt-cli/${h} (${d()}; ${o.platform} ${o.arch}; node ${o.version})`;var y=s({meta:{name:`login`,description:`Authenticates the CLI by storing an auth token locally.`},run:()=>e(async()=>{let e=i(),s=await n();s&&await fetch(`${e}/revoke-session`,{method:`POST`,headers:{authorization:`Bearer ${s}`,"content-type":`application/json`,"user-agent":v},body:JSON.stringify({token:s})}).catch(()=>{});let u=await fetch(`${e}/device/code`,{method:`POST`,headers:{"content-type":`application/json`,"user-agent":v},body:JSON.stringify({client_id:_})});if(!u.ok)throw new l(`ENGINE_UNREACHABLE`,`Couldn't start the login flow`,{details:`The auth server responded with ${u.status}.`,hint:`Check your connection and run eloqnt login again.`});let d=await u.json();o.stderr.write(`\n${c.cyan(`Log in to eloqnt studio`)}\n`),o.stderr.write(c.dim(`${d.verification_uri_complete}\n\n`)),g(d.verification_uri_complete);let f=o.stderr.isTTY?a():void 0;f?f.start(`Waiting for approval in the browser`):o.stderr.write(c.dim(`Waiting for approval in the browser …
|
|
2
2
|
`));let m=await x(e,d);if(!m.access_token)throw f?.stop(c.dim(`Login cancelled`)),new l(`NOT_AUTHENTICATED`,m.error_description??`Login failed`,{hint:`Run eloqnt login to try again.`});await t(m.access_token),f?(f.stop(c.dim(`Approved in the browser`)),p(c.green(`Logged in`))):o.stdout.write(`${c.green(`Logged in`)}\n`),await b(m.access_token)&&o.stderr.write(`\n${c.cyan(`→ Choose a plan at ${r()}/plans`)}\n`)})});async function b(e){try{let t=await fetch(new URL(`/api/engine/me`,r()),{headers:u(e)});if(!t.ok)return!1;let n=await t.json();return Array.isArray(n.plans)&&n.plans.length===0}catch{return!1}}async function x(e,t){let n=Date.now()+t.expires_in*1e3,r=t.interval;for(;Date.now()<n;){await f(r*1e3);let n=await(await fetch(`${e}/device/token`,{method:`POST`,headers:{"content-type":`application/json`,"user-agent":v},body:JSON.stringify({grant_type:`urn:ietf:params:oauth:grant-type:device_code`,device_code:t.device_code,client_id:_})})).json();if(n.access_token)return n;if(n.error!==`authorization_pending`){if(n.error===`slow_down`){r+=5;continue}return n}}return{error:`expired_token`,error_description:`The login request expired`}}export{y as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{defineCommand as e}from"citty";var t=e({meta:{name:`review`,description:"Review source strings before translation and fix issues in place (defaults to the `source` subcommand)."},setup({rawArgs:e}){e.find(e=>!e.startsWith(`-`))!==`source`&&e.unshift(`source`)},subCommands:{source:()=>import(`./source-BIRHLi05.mjs`).then(e=>e.default)}});export{t as default};
|
package/package.json
CHANGED
package/dist/review-BPDZscRV.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{defineCommand as e}from"citty";var t=e({meta:{name:`review`,description:`Review source strings before translation and fix issues in place.`},subCommands:{source:()=>import(`./source-BIRHLi05.mjs`).then(e=>e.default)}});export{t as default};
|