@vercel/geistdocs 1.1.1 → 1.2.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/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{program as j}from"commander";import{copyFile as Y,rm as tt}from"fs/promises";import{join as R}from"path";import{cancel as et,intro as st,isCancel as nt,log as ot,outro as rt,spinner as at,text as it}from"@clack/prompts";import{exec as Z}from"child_process";import{promisify as Q}from"util";var D="https://github.com/vercel/geistdocs";var y={stdio:"ignore"};var E="geistdocs-update",m=Q(Z);var ct="https://github.com/vercel/geistdocs.git",lt=async t=>{await m(`git clone --depth 1 --filter=blob:none --sparse ${ct} ${t}`,y),await m("git sparse-checkout set apps/template",{...y,cwd:t}),await m("mv apps/template/* apps/template/.[!.]* . 2>/dev/null || true",{...y,cwd:t,shell:"/bin/bash"}),await m("rm -rf apps .git",{...y,cwd:t})},pt=async()=>{await Y(".env.example",".env.local")},gt=async()=>{await tt(R("content","docs"),{recursive:!0,force:!0})},dt=async()=>{await m("pnpm install",y)},ft=async()=>{await m("git init",y),await m("git add .",y),await m('git commit -m "\u2728 Initial commit"',y)},mt=async()=>{let t=await it({message:"What is your project named?",placeholder:"my-app",validate(e){if(e.length===0)return"Please enter a project name."}});return nt(t)&&(et("Operation cancelled."),process.exit(0)),t.toString()},I=async t=>{try{st("Let's start a Geistdocs project!");let e=process.cwd(),o=t.name||await mt(),n=at(),a=R(e,o);n.start("Cloning template..."),await lt(o),n.message("Moving into project..."),process.chdir(a),n.message("Setting up environment variables..."),await pt(),n.message("Deleting demo content..."),await gt(),n.message("Installing dependencies..."),await dt(),t.disableGit||(n.message("Initializing Git repository..."),await ft()),n.stop("Project initialized successfully!"),rt("Run `pnpm dev` to start the development server.")}catch(e){let o=e instanceof Error?e.message:`Failed to initialize project: ${e}`;ot.error(o),process.exit(1)}};import{createHash as ht}from"crypto";import{existsSync as z}from"fs";import{readFile as O,writeFile as G}from"fs/promises";import{dirname as ut,parse as _,resolve as v}from"path";import{intro as wt,isCancel as yt,log as h,outro as F,spinner as $t,text as Tt}from"@clack/prompts";import{glob as xt}from"glob";import{Project as Pt,SyntaxKind as C}from"ts-morph";var U=10,Ft="content/docs/**/*.mdx",A=".translation-cache.json",St=/\.[a-z]{2}\.mdx$/,vt=async t=>(await xt(t,{cwd:process.cwd(),absolute:!0,nodir:!0})).filter(o=>o.endsWith(".mdx")).filter(o=>!St.test(o)),bt=t=>{let e=v(process.cwd(),t),a=new Pt({skipAddingFilesFromTsConfig:!0}).addSourceFileAtPath(e).getVariableDeclaration("translations");if(!a)throw new Error("Could not find translations export in config file");let r=a.getInitializer();if(!r||r.getKind()!==C.ObjectLiteralExpression)throw new Error("translations must be an object literal");let s=r.asKind(C.ObjectLiteralExpression);if(!s)throw new Error("Could not parse translations object");let c=s.getProperties().filter(p=>p.getKind()===C.PropertyAssignment).map(p=>p.asKind(C.PropertyAssignment)?.getName()).filter(p=>p!==void 0);if(c.length===0)throw new Error("No locales found in translations object");let[d,...u]=c;return u},Et=t=>ht("sha256").update(t).digest("hex"),Ct=async()=>{let t=v(process.cwd(),A);if(!z(t))return{};try{let e=await O(t,"utf-8");return JSON.parse(e)}catch{return h.warn("Failed to load translation cache, starting fresh"),{}}},M=async t=>{let e=v(process.cwd(),A);await G(e,JSON.stringify(t,null,2),"utf-8")},jt=(t,e,o,n)=>{let a=t[e];if(!a)return!0;let r=a[o];return r?r.hash!==n:!0},Dt=async(t,e,o)=>{let n=await O(t,"utf-8"),a=await fetch(o,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:n,locale:e})}),r=await a.text();if(!a.ok){let s=`Translation failed with status ${a.status}`;try{let c=JSON.parse(r);s=c.error||c.message||s}catch{s=r||s}throw new Error(s)}try{return JSON.parse(r).translation}catch{throw new Error(`Failed to parse response: ${r.slice(0,200)}`)}},Ut=async(t,e,o,n,a)=>{let r=ut(t),{name:s,ext:c}=_(t),d=v(r,`${s}.${e}${c}`);await G(d,o,"utf-8"),n[t]||(n[t]={}),n[t][e]={hash:a,translatedAt:new Date().toISOString()},await M(n)},k=async(t,e)=>{wt("Translate MDX content");let o=t??Ft,n=[],a=e.url||process.env.GEISTDOCS_TRANSLATE_URL||"https://geistdocs.com/translate",r=e.config??"geistdocs.tsx";if(r)try{n=bt(r),h.info(`Loaded ${n.length} locale(s) from config: ${n.join(", ")}`)}catch(i){h.error(`Failed to load config: ${i instanceof Error?i.message:String(i)}`),F("Translation cancelled"),process.exit(1)}let s=await vt(o);if(s.length===0&&(h.error(`No MDX files found matching pattern: ${o}`),F("Translation cancelled"),process.exit(1)),h.info(`Found ${s.length} MDX file(s) matching pattern`),n.length===0){let i=await Tt({message:"Enter target locales (comma-separated):",placeholder:"cn,fr,es",validate:l=>{if(!l)return"At least one locale is required"}});yt(i)&&(F("Translation cancelled"),process.exit(0)),n=i.split(",").map(l=>l.trim())}let c=v(process.cwd(),A),d=await Ct();z(c)||await M(d),h.info(`Using cache: ${c}`);let u=new Map;for(let i of s){let l=await O(i,"utf-8");u.set(i,Et(l))}let p=[],$=0;for(let i of n)for(let l of s){let P=u.get(l);if(!P)throw new Error(`Hash not found for file: ${l}`);e.force||jt(d,l,i,P)?p.push({filePath:l,locale:i,hash:P}):$+=1}if(p.length===0){h.success("All translations are up to date!"),F(`Skipped ${$} file(s) (unchanged)`);return}let w=[];for(let i=0;i<p.length;i+=U)w.push(p.slice(i,i+U));h.info(`Processing ${p.length} translation(s) in ${w.length} batch(es) of up to ${U}`),$>0&&h.info(`Skipped ${$} translation(s) (unchanged)`);let x=$t();try{let i=[];x.start("Starting translation...");let l=0;for(let T=0;T<w.length;T++){let b=w[T];x.message(`Processing batch ${T+1}/${w.length} (${b.length} translations) - ${l}/${p.length} complete`),await Promise.all(b.map(async f=>{let{name:B,ext:W}=_(f.filePath),q=await Dt(f.filePath,f.locale,a);await Ut(f.filePath,f.locale,q,d,f.hash),i.push({name:B,locale:f.locale,ext:W}),l+=1})),T<w.length-1&&(x.message(`Batch ${T+1}/${w.length} complete. Pausing...`),await new Promise(f=>setTimeout(f,1e3)))}x.stop("Translation complete!");for(let{name:T,locale:b,ext:f}of i)h.success(`Saved: ${T}.${b}${f}`);let P=[`Translated ${i.length} file(s)`];$>0&&P.push(`Skipped ${$} unchanged`),F(P.join(" \u2022 "))}catch(i){let l=i instanceof Error?i.message:String(i);x.stop(`Translation failed: ${l}`),F("Exiting"),process.exit(1)}};import{copyFile as Ot,mkdir as K,rm as L}from"fs/promises";import{dirname as At,join as S}from"path";import{intro as Nt,log as g,outro as H,spinner as Lt}from"@clack/prompts";import{glob as Rt}from"glob";var X="apps/template",It=["**/*"],zt=["content/docs/**"],Gt=async t=>{let e=process.cwd(),o=S(e,t);await L(o,{recursive:!0,force:!0}),await K(o,{recursive:!0})},_t=async t=>await m(`git clone --depth 1 ${D} ${t}`),N=async t=>await L(t,{recursive:!0,force:!0}),J=async(t,e,o)=>(await Rt(t,{cwd:o,nodir:!0,dot:!0,ignore:[".git/**",...e]})).sort(),Mt=async(t,e)=>{let o=process.cwd(),n=S(e,X,t),a=S(o,t);await K(At(a),{recursive:!0}),await Ot(n,a)},kt=async t=>{let e=process.cwd(),o=S(e,t);await L(o,{force:!0})},Ht=async(t,e,o,n)=>{let a={success:[],deleted:[],failed:[]};for(let r of t)try{n.message(`Updating ${r}...`),await Mt(r,o),a.success.push(r)}catch(s){let c=s instanceof Error?s.message:`${s}`;a.failed.push({file:r,error:c})}for(let r of e)try{n.message(`Deleting ${r}...`),await kt(r),a.deleted.push(r)}catch(s){let c=s instanceof Error?s.message:`${s}`;a.failed.push({file:r,error:c})}return a},Jt=t=>{if(t.success.length>0){g.success(`Successfully updated ${t.success.length} files:`);for(let e of t.success)g.info(` \u2713 ${e}`)}if(t.deleted.length>0){g.success(`Deleted ${t.deleted.length} files:`);for(let e of t.deleted)g.info(` \u{1F5D1} ${e}`)}if(t.failed.length>0){g.warn(`Failed to update ${t.failed.length} files:`);for(let{file:e,error:o}of t.failed)g.error(` \u2717 ${e}: ${o}`)}},V=async(t,e)=>{let o=process.cwd(),n=S(o,E),a=t&&t.length>0?t:It,r=t&&t.length>0?[]:zt;try{Nt("Let's update your Geistdocs project!"),g.info(`Repository: ${D}`),t&&t.length>0&&g.info(`Updating specific files: ${t.join(", ")}`),e?.sync&&g.info("Sync mode enabled: will delete files removed from template");let s=Lt();s.start("Creating temporary directory..."),await Gt(E),s.message("Cloning repository..."),await _t(E),s.message("Scanning for files...");let c=S(n,X),d=await J(a,r,c),u=[];if(e?.sync){s.message("Comparing with local files...");let $=await J(a,r,o),w=new Set(d);u=$.filter(x=>!w.has(x))}if(s.stop(`Found ${d.length} files to update`),d.length===0&&u.length===0){g.warn("No files matched the patterns. Nothing to update."),await N(n),H("Update cancelled.");return}g.info(`Patterns: ${a.length}`),g.info(`Files to update: ${d.length}`),e?.sync&&g.info(`Files to delete: ${u.length}`),s.start("Updating files...");let p=await Ht(d,u,n,s);s.message("Cleaning up..."),await N(n),s.stop("Update complete!"),Jt(p),H("Please review and test the changes carefully.")}catch(s){let c=s instanceof Error?s.message:`${s}`;try{await N(n)}catch{}g.error(`Failed to update project: ${c}`),process.exit(1)}};j.command("init").description("Initialize a new Geistdocs project").option("--name <name>","Name of the project").option("--disable-git","Disable git initialization").action(I);j.command("update [files...]").description("Update a Geistdocs project (optionally specify files/patterns to update)").option("--sync","Delete local files that no longer exist in the template").action(V);j.command("translate [pattern]").description("Translate MDX file(s) to one or more locales (default: content/docs/**/*.mdx)").option("--config <path>","Path to config file to load locales from (defaults to geistdocs.tsx)").option("--url <url>","Custom translation API URL (defaults to GEISTDOCS_TRANSLATE_URL or https://geistdocs.com/translate)").option("--force","Force re-translation of all files, ignoring cache").action(k);j.parse(process.argv);
|
|
2
|
+
import{program as P}from"commander";import{copyFile as V,rm as q}from"fs/promises";import{join as R}from"path";import{cancel as W,intro as Y,isCancel as Z,log as Q,outro as tt,spinner as et,text as st}from"@clack/prompts";import{spawn as X}from"child_process";var v="https://github.com/vercel/geistdocs";var h={stdio:"ignore"};var x="geistdocs-update",f=(t,e)=>new Promise((s,r)=>{let[a,...i]=t.split(" "),n=X(a,i,{stdio:["ignore","pipe","pipe"],shell:e?.shell??!0,cwd:e?.cwd}),l="",c="";n.stdout?.on("data",p=>{l+=p.toString()}),n.stderr?.on("data",p=>{c+=p.toString()});let o=()=>{n.kill("SIGTERM"),setTimeout(()=>{n.killed||n.kill("SIGKILL")},1e3)};process.on("SIGINT",o),process.on("SIGTERM",o),n.on("close",p=>{process.removeListener("SIGINT",o),process.removeListener("SIGTERM",o),p===0?s({stdout:l,stderr:c}):r(new Error(`Command failed with code ${p}: ${c}`))}),n.on("error",p=>{process.removeListener("SIGINT",o),process.removeListener("SIGTERM",o),r(p)})});var nt="https://github.com/vercel/geistdocs.git",rt=async t=>{await f(`git clone --depth 1 --filter=blob:none --sparse ${nt} ${t}`,h),await f("git sparse-checkout set apps/template",{...h,cwd:t}),await f("mv apps/template/* apps/template/.[!.]* . 2>/dev/null || true",{...h,cwd:t,shell:"/bin/bash"}),await f("rm -rf apps .git",{...h,cwd:t})},ot=async()=>{await V(".env.example",".env.local")},at=async()=>{await q(R("content","docs"),{recursive:!0,force:!0})},it=async()=>{await f("pnpm install",h)},ct=async()=>{await f("git init",h),await f("git add .",h),await f('git commit -m "\u2728 Initial commit"',h)},lt=async()=>{let t=await st({message:"What is your project named?",placeholder:"my-app",validate(e){if(e.length===0)return"Please enter a project name."}});return Z(t)&&(W("Operation cancelled."),process.exit(0)),t.toString()},j=async t=>{try{Y("Let's start a Geistdocs project!");let e=process.cwd(),s=t.name||await lt(),r=et(),a=R(e,s);r.start("Cloning template..."),await rt(s),r.message("Moving into project..."),process.chdir(a),r.message("Setting up environment variables..."),await ot(),r.message("Deleting demo content..."),await at(),r.message("Installing dependencies..."),await it(),t.disableGit||(r.message("Initializing Git repository..."),await ct()),r.stop("Project initialized successfully!"),tt("Run `pnpm dev` to start the development server.")}catch(e){let s=e instanceof Error?e.message:`Failed to initialize project: ${e}`;Q.error(s),process.exit(1)}};import{createHash as pt}from"crypto";import{existsSync as L}from"fs";import{readFile as F,writeFile as U}from"fs/promises";import{dirname as gt,parse as D,resolve as $}from"path";import{intro as dt,isCancel as ft,log as m,outro as T,spinner as mt,text as ut}from"@clack/prompts";import{glob as ht}from"glob";import{Project as wt,SyntaxKind as S}from"ts-morph";var b=10,yt="content/docs/**/*.mdx",C=".translation-cache.json",Tt=/\.[a-z]{2}\.mdx$/,$t=async t=>(await ht(t,{cwd:process.cwd(),absolute:!0,nodir:!0})).filter(s=>s.endsWith(".mdx")).filter(s=>!Tt.test(s)),Pt=t=>{let e=$(process.cwd(),t),a=new wt({skipAddingFilesFromTsConfig:!0}).addSourceFileAtPath(e).getVariableDeclaration("translations");if(!a)throw new Error("Could not find translations export in config file");let i=a.getInitializer();if(!i||i.getKind()!==S.ObjectLiteralExpression)throw new Error("translations must be an object literal");let n=i.asKind(S.ObjectLiteralExpression);if(!n)throw new Error("Could not parse translations object");let l=n.getProperties().filter(p=>p.getKind()===S.PropertyAssignment).map(p=>p.asKind(S.PropertyAssignment)?.getName()).filter(p=>p!==void 0);if(l.length===0)throw new Error("No locales found in translations object");let[c,...o]=l;return o},xt=t=>pt("sha256").update(t).digest("hex"),St=async()=>{let t=$(process.cwd(),C);if(!L(t))return{};try{let e=await F(t,"utf-8");return JSON.parse(e)}catch{return m.warn("Failed to load translation cache, starting fresh"),{}}},N=async t=>{let e=$(process.cwd(),C);await U(e,JSON.stringify(t,null,2),"utf-8")},vt=(t,e,s,r)=>{let a=t[e];if(!a)return!0;let i=a[s];return i?i.hash!==r:!0},bt=async(t,e,s)=>{let r=await F(t,"utf-8"),a=await fetch(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:r,locale:e})}),i=await a.text();if(!a.ok){let n=`Translation failed with status ${a.status}`;try{let l=JSON.parse(i);n=l.error||l.message||n}catch{n=i||n}throw new Error(n)}try{return JSON.parse(i).translation}catch{throw new Error(`Failed to parse response: ${i.slice(0,200)}`)}},Ft=async(t,e,s,r,a)=>{let i=gt(t),{name:n,ext:l}=D(t),c=$(i,`${n}.${e}${l}`);await U(c,s,"utf-8"),r[t]||(r[t]={}),r[t][e]={hash:a,translatedAt:new Date().toISOString()},await N(r)},Ct=t=>{try{let e=Pt(t);return m.info(`Loaded ${e.length} locale(s) from config: ${e.join(", ")}`),e}catch(e){m.error(`Failed to load config: ${e instanceof Error?e.message:String(e)}`),T("Translation cancelled"),process.exit(1)}},Et=async()=>{let t=await ut({message:"Enter target locales (comma-separated):",placeholder:"cn,fr,es",validate:e=>{if(!e)return"At least one locale is required"}});return ft(t)&&(T("Translation cancelled"),process.exit(0)),t.split(",").map(e=>e.trim())},It=async t=>{let e=new Map;for(let s of t){let r=await F(s,"utf-8");e.set(s,xt(r))}return e},Rt=(t,e,s,r,a)=>{let i=[],n=0;for(let l of t)for(let c of e){let o=s.get(c);if(!o)throw new Error(`Hash not found for file: ${c}`);a||vt(r,c,l,o)?i.push({filePath:c,locale:l,hash:o}):n+=1}return{tasks:i,skippedCount:n}},jt=async(t,e,s,r)=>{let a=mt(),i=[];a.start("Starting translation...");let n=0;for(let l=0;l<t.length;l++){let c=t[l];a.message(`Processing batch ${l+1}/${t.length} (${c.length} translations) - ${n}/${e} complete`),await Promise.all(c.map(async o=>{let{name:p,ext:u}=D(o.filePath),g=await bt(o.filePath,o.locale,s);await Ft(o.filePath,o.locale,g,r,o.hash),i.push({name:p,locale:o.locale,ext:u}),n+=1})),l<t.length-1&&(a.message(`Batch ${l+1}/${t.length} complete. Pausing...`),await new Promise(o=>setTimeout(o,1e3)))}return a.stop("Translation complete!"),i},O=async(t,e)=>{dt("Translate MDX content");let s=t??yt,r=e.url||process.env.GEISTDOCS_TRANSLATE_URL||"https://geistdocs.com/translate",a=Ct(e.config??"geistdocs.tsx"),i=await $t(s);i.length===0&&(m.error(`No MDX files found matching pattern: ${s}`),T("Translation cancelled"),process.exit(1)),m.info(`Found ${i.length} MDX file(s) matching pattern`),a.length===0&&(a=await Et());let n=$(process.cwd(),C),l=await St();L(n)||await N(l),m.info(`Using cache: ${n}`);let c=await It(i),{tasks:o,skippedCount:p}=Rt(a,i,c,l,e.force);if(o.length===0){m.success("All translations are up to date!"),T(`Skipped ${p} file(s) (unchanged)`);return}let u=[];for(let g=0;g<o.length;g+=b)u.push(o.slice(g,g+b));m.info(`Processing ${o.length} translation(s) in ${u.length} batch(es) of up to ${b}`),p>0&&m.info(`Skipped ${p} translation(s) (unchanged)`);try{let g=await jt(u,o.length,r,l);for(let{name:B,locale:K,ext:J}of g)m.success(`Saved: ${B}.${K}${J}`);let y=[`Translated ${g.length} file(s)`];p>0&&y.push(`Skipped ${p} unchanged`),T(y.join(" \u2022 "))}catch(g){let y=g instanceof Error?g.message:String(g);m.error(`Translation failed: ${y}`),T("Exiting"),process.exit(1)}};import{access as Lt,copyFile as Ut,mkdir as z,rm as I}from"fs/promises";import{dirname as Dt,join as w}from"path";import{intro as Nt,log as d,outro as A,spinner as Ot}from"@clack/prompts";import{glob as At}from"glob";var _="apps/template",kt=["**/*"],Gt=["content/docs/**"],Mt=async(t,e)=>{let s=w(t,e);await I(s,{recursive:!0,force:!0}),await z(s,{recursive:!0})},zt=async(t,e)=>{await f(`git clone --depth 1 --filter=blob:none --sparse ${v} ${e}`,{cwd:t}),await f("git sparse-checkout set apps/template",{cwd:w(t,e)})},E=async t=>await I(t,{recursive:!0,force:!0}),k=async(t,e,s)=>(await At(t,{cwd:s,nodir:!0,dot:!0,ignore:[".git/**",...e]})).sort(),_t=async t=>{try{return await Lt(t),!0}catch{return!1}},Ht=async(t,e,s)=>{let r=w(e,_,t),a=w(s,t);return await _t(r)?(await Ut(r,a),{success:!0}):{success:!1,error:`Source file not found: ${r}`}},Bt=async(t,e)=>{let s=w(e,t);return await I(s,{force:!0}),{success:!0}},G=20,M=async(t,e,s)=>{let r=[];for(let a=0;a<t.length;a+=s){let i=t.slice(a,a+s),n=await Promise.all(i.map(e));r.push(...n)}return r},Kt=async(t,e,s,r,a)=>{let i={success:[],deleted:[],failed:[]},n=[...new Set(t.map(c=>Dt(w(r,c))))];a.message(`Creating ${n.length} directories...`),await Promise.all(n.map(c=>z(c,{recursive:!0}))),a.message(`Updating ${t.length} files...`);let l=await M(t,async c=>{let o=await Ht(c,s,r);return{file:c,...o}},G);for(let{file:c,success:o,error:p}of l)o?i.success.push(c):i.failed.push({file:c,error:p??"Unknown error"});if(e.length>0){a.message(`Deleting ${e.length} files...`);let c=await M(e,async o=>{try{return await Bt(o,r),{file:o,success:!0}}catch(p){let u=p instanceof Error?p.message:`${p}`;return{file:o,success:!1,error:u}}},G);for(let o of c)o.success?i.deleted.push(o.file):i.failed.push({file:o.file,error:o.error})}return i},Jt=t=>{if(t.success.length>0){d.success(`Successfully updated ${t.success.length} files:`);for(let e of t.success)d.info(` \u2713 ${e}`)}if(t.deleted.length>0){d.success(`Deleted ${t.deleted.length} files:`);for(let e of t.deleted)d.info(` \u{1F5D1} ${e}`)}if(t.failed.length>0){d.warn(`Failed to update ${t.failed.length} files:`);for(let{file:e,error:s}of t.failed)d.error(` \u2717 ${e}: ${s}`)}},H=async(t,e)=>{let s=process.cwd(),r=w(s,x),a=t&&t.length>0?t:kt,i=t&&t.length>0?[]:Gt;try{Nt("Let's update your Geistdocs project!"),d.info(`Repository: ${v}`),t&&t.length>0&&d.info(`Updating specific files: ${t.join(", ")}`),e?.sync&&d.info("Sync mode enabled: will delete files removed from template");let n=Ot();n.start("Creating temporary directory..."),await Mt(s,x),n.message("Cloning repository..."),await zt(s,x),n.message("Scanning for files...");let l=w(r,_),c=await k(a,i,l),o=[];if(e?.sync){n.message("Comparing with local files...");let u=await k(a,i,s),g=new Set(c);o=u.filter(y=>!g.has(y))}if(n.stop(`Found ${c.length} files to update`),c.length===0&&o.length===0){d.warn("No files matched the patterns. Nothing to update."),await E(r),A("Update cancelled.");return}d.info(`Patterns: ${a.length}`),d.info(`Files to update: ${c.length}`),e?.sync&&d.info(`Files to delete: ${o.length}`),n.start("Updating files...");let p=await Kt(c,o,r,s,n);n.message("Cleaning up..."),await E(r),n.stop("Update complete!"),Jt(p),A("Please review and test the changes carefully.")}catch(n){let l=n instanceof Error?n.message:`${n}`;try{await E(r)}catch{}d.error(`Failed to update project: ${l}`),process.exit(1)}};P.name("geistdocs").description("CLI for Geistdocs projects").version("1.1.1","-v, --version","Output the current version");P.command("init").description("Initialize a new Geistdocs project").option("--name <name>","Name of the project").option("--disable-git","Disable git initialization").action(j);P.command("update [files...]").description("Update a Geistdocs project (optionally specify files/patterns to update)").option("--sync","Delete local files that no longer exist in the template").action(H);P.command("translate [pattern]").description("Translate MDX file(s) to one or more locales (default: content/docs/**/*.mdx)").option("--config <path>","Path to config file to load locales from (defaults to geistdocs.tsx)").option("--url <url>","Custom translation API URL (defaults to GEISTDOCS_TRANSLATE_URL or https://geistdocs.com/translate)").option("--force","Force re-translation of all files, ignoring cache").action(O);P.parse(process.argv);
|