create-lexy 0.5.0 → 0.5.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/dist/index.js +53 -49
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{readFileSync as
|
|
3
|
-
`)};import
|
|
4
|
-
`);if(process.stdout.isTTY&&process.stdin.isTTY){let
|
|
2
|
+
import{readFileSync as At}from"fs";import Me from"path";import{fileURLToPath as Nt}from"url";import{Command as Mt}from"commander";import Dt from"picocolors";import{spawn as Je}from"child_process";import G from"fs/promises";import B from"path";import{confirm as Ke,isCancel as Be,spinner as xe}from"@clack/prompts";import h from"picocolors";import Q from"path";var De=(e,t)=>t.architecture!=="feature"?e:e.replace(/from ["']@\/lib\/utils\/cn["']/g,'from "@/shared/lib/utils/cn"').replace(/from ["']@\/components\/base\//g,'from "@/shared/components/base/'),_e=[["components/base/",e=>e.paths.components],["views/",e=>e.paths.views],["hooks/",e=>e.paths.hooks],["lib/",e=>e.paths.lib]],P=(e,t)=>e.files.filter(o=>typeof o.content=="string").map(o=>{let r=_e.find(([s])=>o.path.startsWith(s));return{relPath:r?Q.posix.join(r[1](t),o.path.slice(r[0].length)):Q.posix.join(t.paths.components,Q.posix.basename(o.path)),content:De(o.content,t)}});import de from"fs/promises";import qe from"path";var me=e=>qe.join(e,".lexy"),S=async e=>{let t;try{t=await de.readFile(me(e),"utf-8")}catch{throw new Error("No se encontr\xF3 el archivo .lexy. \xBFEst\xE1s en la ra\xEDz de un proyecto Lexy? (cr\xE9alo con `npx create-lexy create`)")}let o=JSON.parse(t);if(!o.paths?.components)throw new Error("El .lexy no tiene paths.components \u2014 archivo corrupto o de una versi\xF3n incompatible.");return o.installed??={},o},ue=async(e,t)=>{await de.writeFile(me(e),JSON.stringify(t,null,2)+`
|
|
3
|
+
`)};import q from"fs/promises";import Ve from"os";import E from"path";import{fileURLToPath as ze}from"url";var fe="@lexydesign/registry",M=`https://cdn.jsdelivr.net/npm/${fe}`,He=8e3,J=E.resolve(E.dirname(ze(import.meta.url)),"../assets"),Ue=E.join(Ve.homedir(),".cache","create-lexy","registry"),U=async e=>{let t=await fetch(e,{signal:AbortSignal.timeout(He)});if(!t.ok){let o=new Error(`HTTP ${t.status} al pedir ${e}`);throw o.status=t.status,o}return await t.json()},ge=async e=>{try{return JSON.parse(await q.readFile(E.join(J,"r",e),"utf-8"))}catch{return null}},Z=async()=>{try{return(await q.readFile(E.join(J,"registry-version"),"utf-8")).trim()}catch{return"bundle"}},N=null,K=async()=>{if(N)return N;try{N=(await U(`https://registry.npmjs.org/${fe}/latest`)).version}catch{try{N=(await U(`${M}@latest/package.json`)).version}catch{N=await Z()}}return N},w=async(e,t)=>{let o=e.replace(/^@lexy\//,""),r=t??await K(),n=E.join(Ue,r,`${o}.json`);try{return{item:JSON.parse(await q.readFile(n,"utf-8")),version:r,source:"cache"}}catch{}try{let s=await U(`${M}@${r}/r/${o}.json`);return await q.mkdir(E.dirname(n),{recursive:!0}),await q.writeFile(n,JSON.stringify(s)),{item:s,version:r,source:"cdn"}}catch(s){if(s.status===404)throw new Error(`El componente "${o}" no existe en el registry (versi\xF3n ${r}). Mira el cat\xE1logo con \`create-lexy view --list\`.`);let i=await ge(`${o}.json`);if(i)return{item:i,version:await Z(),source:"bundle"};throw new Error(`No se pudo alcanzar el registry (\xBFsin red?) y "${o}" tampoco est\xE1 en el bundle local del CLI.`)}},ye=async()=>{try{let e=await K();return{index:await U(`${M}@${e}/r/registry.json`),version:e,source:"cdn"}}catch{let e=await ge("registry.json");if(e)return{index:e,version:await Z(),source:"bundle"};throw new Error("No se pudo alcanzar el registry ni leer el bundle local del CLI.")}},he=E.join(J,"theme/lexy-theme.css"),we=E.join(J,"fonts");var Ge=(e,t)=>new Promise((o,r)=>{Je("pnpm",["add",...e],{cwd:t,stdio:"ignore",shell:!0}).on("close",s=>s===0?o():r(new Error(`pnpm add fall\xF3 con c\xF3digo ${s}`)))}),We=async e=>{try{return await G.readFile(e,"utf-8")}catch{return null}},be=async(e,t)=>{let o=process.cwd(),r=await S(o),n=xe();n.start("Resolviendo componentes en el registry...");let s=new Map,i=async a=>{let p=a.toLowerCase().replace(/^@lexy\//,"");if(s.has(p))return;let g=await w(p);s.set(p,g);for(let b of g.item.registryDependencies??[])await i(b)};try{for(let a of e)await i(a)}catch(a){throw n.stop(h.red("No se pudo resolver el pedido.")),a}let l=new Map;for(let[a,{item:p}]of s){let g=[];for(let b of P(p,r)){let T=await We(B.join(o,b.relPath));g.push({...b,status:T===null?"new":T===b.content?"same":"differs"})}l.set(a,g)}let c=Array.from(l.values()).flat().filter(a=>a.status==="differs");if(n.stop(`Resueltos: ${Array.from(s.keys()).join(", ")}`),c.length>0&&!t.overwrite){let a=c.map(p=>` ${p.relPath}`).join(`
|
|
4
|
+
`);if(process.stdout.isTTY&&process.stdin.isTTY){let p=await Ke({message:`Estos archivos existen con cambios locales y ser\xE1n sobrescritos:
|
|
5
5
|
${a}
|
|
6
|
-
\xBFContinuar?`});if(
|
|
6
|
+
\xBFContinuar?`});if(Be(p)||p!==!0){console.log(h.yellow("Operaci\xF3n cancelada \u2014 nada fue modificado.")),process.exitCode=1;return}}else{console.error(h.red(`Estos archivos existen con cambios locales:
|
|
7
7
|
`)+a+h.dim(`
|
|
8
|
-
Usa --overwrite para sobrescribirlos.`)),process.exitCode=1;return}}for(let[a,
|
|
8
|
+
Usa --overwrite para sobrescribirlos.`)),process.exitCode=1;return}}for(let[a,p]of l){let{item:g,version:b,source:T}=s.get(a);for(let y of p){if(y.status==="same")continue;let C=B.join(o,y.relPath);await G.mkdir(B.dirname(C),{recursive:!0}),await G.writeFile(C,y.content)}r.installed[g.name]=b;let H=e.map(y=>y.toLowerCase()).includes(a)?"":h.dim(" (dependencia)"),_=T==="bundle"?h.yellow(" [bundle local \u2014 sin red]"):"";console.log(h.green(`${h.bold(g.title??g.name)} instalado`)+H+h.cyan(` \u2192 ${r.paths.components}/`)+_);for(let y of p){let C=y.status==="same"?h.dim(" (sin cambios)"):"";console.log(h.dim(` ${y.relPath}${C}`))}}await ue(o,r);let m=new Set;for(let{item:a}of s.values())for(let p of a.dependencies??[])m.add(p);let d=JSON.parse(await G.readFile(B.join(o,"package.json"),"utf-8")),u={...d.dependencies,...d.devDependencies},R=a=>{let p=a.lastIndexOf("@");return p>0?a.slice(0,p):a},f=Array.from(m).filter(a=>!u[R(a)]);if(f.length>0)if(t.install===!1)console.log(h.yellow(`Dependencias pendientes (inst\xE1lalas t\xFA): ${f.join(", ")}`));else{let a=xe();a.start(`Instalando dependencias: ${f.join(", ")}...`),await Ge(f,o),a.stop("Dependencias instaladas.")}};import{spawn as vt}from"child_process";import{note as jt,outro as $t,spinner as Ct}from"@clack/prompts";import v from"picocolors";import{cancel as Ye,intro as Xe,isCancel as Qe,select as je,text as Ze}from"@clack/prompts";import $e from"picocolors";var ee=[{value:"screen",label:"Una pantalla o flujo corto",hint:"landing, formulario, demo \u2014 sin navegaci\xF3n entre secciones",architecture:"layer"},{value:"app",label:"Una app con secciones y navegaci\xF3n",hint:"dashboard, listados, detalle \u2014 varias vistas con router",architecture:"feature"}],ve=e=>ee.find(t=>t.value===e).architecture;var et=`
|
|
9
9
|
###### ######
|
|
10
10
|
##::+#### ####+::##
|
|
11
11
|
#-..:+################+:..:#
|
|
@@ -20,9 +20,9 @@ Usa --overwrite para sobrescribirlos.`)),process.exitCode=1;return}}for(let[a,l]
|
|
|
20
20
|
...........:====:...........
|
|
21
21
|
......................
|
|
22
22
|
..............
|
|
23
|
-
`,
|
|
24
|
-
${
|
|
25
|
-
`},
|
|
23
|
+
`,te=e=>{Qe(e)&&(Ye("Operaci\xF3n cancelada por el usuario."),process.exit(0))},Ce=async e=>{console.clear(),Xe(`${$e.cyan(et)}
|
|
24
|
+
${$e.bold(" Bienvenido al generador de proyectos Lexy")}`);let t=e;if(!t){let n=await Ze({message:"\xBFCu\xE1l es el nombre de tu proyecto?",placeholder:"lexy-app",validate:s=>{if(!s||s.trim()==="")return"El nombre es obligatorio.";if(!/^(?:@[a-z0-9-*~][a-z0-9-*._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/.test(s))return"El nombre debe estar en min\xFAsculas, sin espacios ni caracteres especiales."}});te(n),t=n}let o=await je({message:"\xBFPara qui\xE9n es este proyecto?",options:[{label:"Clientes de Lexy",value:"cliente",hint:"Producto de cara al cliente final"},{label:"Equipo interno / CRM",value:"crm",hint:"Herramienta densa para el equipo Lexy"},{label:"Ambos o a\xFAn no lo s\xE9",value:"mixto",hint:"Se decide por pantalla m\xE1s adelante"}],initialValue:"mixto"});te(o);let r=await je({message:"\xBFC\xF3mo es lo que vas a construir?",options:ee.map(n=>({label:n.label,value:n.value,hint:n.hint})),initialValue:"app"});return te(r),{projectName:t,architecture:ve(r),world:o}};import k from"fs/promises";import I from"path";var tt={feature:["src/app","src/features","src/shared/assets","src/shared/components/base","src/shared/hooks","src/shared/services","src/shared/lib","src/shared/types"],layer:["src/assets","src/components/base","src/hooks","src/services","src/lib","src/types","src/views","src/stores"]},ot="10.33.3",rt=e=>{let t=e.architecture==="feature"?{"react-router":"^7.9.0"}:{};return JSON.stringify({name:e.projectName,private:!0,version:"0.0.0",type:"module",packageManager:`pnpm@${ot}`,scripts:{dev:"vite",build:"tsc -b && vite build",preview:"vite preview",lint:"eslint .",format:"prettier --write ."},dependencies:{clsx:"^2.1.1",react:"^19.2.6","react-dom":"^19.2.6",...t,"tailwind-merge":"^3.3.1"},devDependencies:{"@babel/core":"^7.29.7","@eslint/js":"^10.0.1","@rolldown/plugin-babel":"^0.2.3","@tailwindcss/vite":"^4.3.0","@types/babel__core":"^7.20.5","@types/node":"^24.12.3","@types/react":"^19.2.14","@types/react-dom":"^19.2.3","@vitejs/plugin-react":"^6.0.1","babel-plugin-react-compiler":"^1.0.0",eslint:"^10.4.1","eslint-plugin-jsx-a11y":"^6.10.2","eslint-plugin-react-hooks":"^7.1.1","eslint-plugin-simple-import-sort":"^13.0.0",globals:"^17.6.0",prettier:"^3.8.4",tailwindcss:"^4.3.0",terser:"^5.48.0",typescript:"~5.9.3","typescript-eslint":"^8.61.0",vite:"^8.0.12"}},null,2)+`
|
|
25
|
+
`},nt=`import path from "node:path";
|
|
26
26
|
|
|
27
27
|
import babel from "@rolldown/plugin-babel";
|
|
28
28
|
import tailwindcss from "@tailwindcss/vite";
|
|
@@ -52,7 +52,7 @@ export default defineConfig({
|
|
|
52
52
|
},
|
|
53
53
|
},
|
|
54
54
|
});
|
|
55
|
-
`,
|
|
55
|
+
`,st=`import js from "@eslint/js";
|
|
56
56
|
import jsxA11y from "eslint-plugin-jsx-a11y";
|
|
57
57
|
import reactHooks from "eslint-plugin-react-hooks";
|
|
58
58
|
import simpleImportSort from "eslint-plugin-simple-import-sort";
|
|
@@ -81,14 +81,14 @@ export default tseslint.config(
|
|
|
81
81
|
},
|
|
82
82
|
},
|
|
83
83
|
);
|
|
84
|
-
`,
|
|
84
|
+
`,it=`{
|
|
85
85
|
"printWidth": 100
|
|
86
86
|
}
|
|
87
|
-
`,
|
|
87
|
+
`,at=`pnpm-lock.yaml
|
|
88
88
|
src/lexy-theme.css
|
|
89
89
|
public/fonts/
|
|
90
90
|
dist/
|
|
91
|
-
`,
|
|
91
|
+
`,ct=`name: CI
|
|
92
92
|
|
|
93
93
|
on:
|
|
94
94
|
push:
|
|
@@ -110,7 +110,7 @@ jobs:
|
|
|
110
110
|
- run: pnpm exec prettier --check .
|
|
111
111
|
- run: pnpm build
|
|
112
112
|
- run: pnpm audit --audit-level high
|
|
113
|
-
`,
|
|
113
|
+
`,lt=`{
|
|
114
114
|
"files": [],
|
|
115
115
|
"references": [{ "path": "./tsconfig.app.json" }, { "path": "./tsconfig.node.json" }],
|
|
116
116
|
"compilerOptions": {
|
|
@@ -118,7 +118,7 @@ jobs:
|
|
|
118
118
|
"paths": { "@/*": ["./src/*"] }
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
|
-
`,
|
|
121
|
+
`,pt=`{
|
|
122
122
|
"compilerOptions": {
|
|
123
123
|
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
|
|
124
124
|
"target": "ES2022",
|
|
@@ -142,7 +142,7 @@ jobs:
|
|
|
142
142
|
},
|
|
143
143
|
"include": ["src"]
|
|
144
144
|
}
|
|
145
|
-
`,
|
|
145
|
+
`,dt=`{
|
|
146
146
|
"compilerOptions": {
|
|
147
147
|
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
|
|
148
148
|
"target": "ES2023",
|
|
@@ -159,7 +159,7 @@ jobs:
|
|
|
159
159
|
},
|
|
160
160
|
"include": ["vite.config.ts"]
|
|
161
161
|
}
|
|
162
|
-
`,
|
|
162
|
+
`,mt=e=>`<!doctype html>
|
|
163
163
|
<html lang="es">
|
|
164
164
|
<head>
|
|
165
165
|
<meta charset="UTF-8" />
|
|
@@ -171,9 +171,9 @@ jobs:
|
|
|
171
171
|
<script type="module" src="/src/main.tsx"></script>
|
|
172
172
|
</body>
|
|
173
173
|
</html>
|
|
174
|
-
`,
|
|
174
|
+
`,ut=`@import "tailwindcss";
|
|
175
175
|
@import "./lexy-theme.css";
|
|
176
|
-
`,
|
|
176
|
+
`,ft=e=>e.architecture==="feature"?`import "./index.css";
|
|
177
177
|
|
|
178
178
|
import { StrictMode } from "react";
|
|
179
179
|
import { createRoot } from "react-dom/client";
|
|
@@ -200,18 +200,18 @@ createRoot(document.getElementById("root")!).render(
|
|
|
200
200
|
<App />
|
|
201
201
|
</StrictMode>,
|
|
202
202
|
);
|
|
203
|
-
`,
|
|
203
|
+
`,Pe=` <main className="flex min-h-screen items-center justify-center bg-background text-foreground">
|
|
204
204
|
<div className="text-center">
|
|
205
205
|
<h1 className="text-2xl font-semibold">Proyecto Lexy listo</h1>
|
|
206
206
|
<p className="mt-2 text-sm text-muted-foreground">
|
|
207
207
|
Trae tu primer componente: <code>npx create-lexy add button</code>
|
|
208
208
|
</p>
|
|
209
209
|
</div>
|
|
210
|
-
</main>`,
|
|
210
|
+
</main>`,gt=e=>e.architecture==="feature"?`import { Route, Routes } from "react-router";
|
|
211
211
|
|
|
212
212
|
const Home = () => {
|
|
213
213
|
return (
|
|
214
|
-
${
|
|
214
|
+
${Pe}
|
|
215
215
|
);
|
|
216
216
|
};
|
|
217
217
|
|
|
@@ -224,20 +224,20 @@ export const App = () => {
|
|
|
224
224
|
};
|
|
225
225
|
`:`export const App = () => {
|
|
226
226
|
return (
|
|
227
|
-
${
|
|
227
|
+
${Pe}
|
|
228
228
|
);
|
|
229
229
|
};
|
|
230
|
-
`,
|
|
230
|
+
`,yt=`import { type ClassValue, clsx } from "clsx";
|
|
231
231
|
import { twMerge } from "tailwind-merge";
|
|
232
232
|
|
|
233
233
|
export function cn(...inputs: ClassValue[]) {
|
|
234
234
|
return twMerge(clsx(inputs));
|
|
235
235
|
}
|
|
236
|
-
`,
|
|
236
|
+
`,ht=`node_modules/
|
|
237
237
|
dist/
|
|
238
238
|
*.log
|
|
239
239
|
.env
|
|
240
|
-
`,
|
|
240
|
+
`,wt=e=>`# ${e.projectName}
|
|
241
241
|
|
|
242
242
|
Proyecto Lexy (React + Vite + TS + theme Lexy). Los componentes viven en tu proyecto: m\xEDralos con \`view\`, inst\xE1lalos con \`add\`, ed\xEDtalos con libertad.
|
|
243
243
|
|
|
@@ -247,29 +247,29 @@ npx create-lexy view button # ver un componente antes de instalarlo
|
|
|
247
247
|
npx create-lexy add button # instalarlo (local y editable)
|
|
248
248
|
npx create-lexy doctor # divergencia con el registry
|
|
249
249
|
\`\`\`
|
|
250
|
-
`,
|
|
251
|
-
`},
|
|
252
|
-
`),await
|
|
250
|
+
`,xt=e=>{let o=e.architecture==="feature"?"@/shared":"@";return JSON.stringify({$schema:"https://ui.shadcn.com/schema.json",style:"new-york",rsc:!1,tsx:!0,tailwind:{config:"",css:"src/index.css",baseColor:"neutral",cssVariables:!0},aliases:{components:`${o}/components`,ui:`${o}/components/base`,utils:`${o}/lib/utils/cn`,lib:`${o}/lib`,hooks:`${o}/hooks`},registries:{"@lexy":`${M}@latest/r/{name}.json`}},null,2)+`
|
|
251
|
+
`},bt=e=>{let t=e.architecture==="feature";return{version:"2.0.0",generatedAt:new Date().toISOString(),architecture:e.architecture,world:e.world,registry:{package:"@lexydesign/registry",cdn:M},componentImportPattern:t?"@/shared/components/base/{Component}":"@/components/base/{Component}",paths:{components:t?"src/shared/components/base":"src/components/base",hooks:t?"src/shared/hooks":"src/hooks",services:t?"src/shared/services":"src/services",lib:t?"src/shared/lib":"src/lib",views:t?"src/features":"src/views"},installed:{}}},Ee=async(e,t)=>{let o=["package.json","src","index.html",".lexy"],r=[];for(let c of o)try{await k.access(I.join(t,c)),r.push(c)}catch{}if(r.length>0)throw new Error(`El directorio actual ya contiene archivos de un proyecto (${r.join(", ")}). Ejecuta el comando dentro de una carpeta vac\xEDa.`);for(let c of tt[e.architecture])await k.mkdir(I.join(t,c),{recursive:!0});let n=(c,m)=>k.writeFile(I.join(t,c),m);await n("package.json",rt(e)),await n("vite.config.ts",nt),await n("tsconfig.json",lt),await n("tsconfig.app.json",pt),await n("tsconfig.node.json",dt),await n("eslint.config.js",st),await n(".prettierrc",it),await n(".prettierignore",at),await k.mkdir(I.join(t,".github/workflows"),{recursive:!0}),await n(".github/workflows/ci.yml",ct),await n("index.html",mt(e)),await n(".gitignore",ht),await n("README.md",wt(e)),await n("src/index.css",ut),await n("src/main.tsx",ft(e));let s=e.architecture==="feature"?"src/app":"src/views";await n(`${s}/App.tsx`,gt(e));let i=bt(e);await n(".lexy",JSON.stringify(i,null,2)+`
|
|
252
|
+
`),await n("components.json",xt(e)),await k.copyFile(he,I.join(t,"src/lexy-theme.css")),await k.mkdir(I.join(t,"public/fonts"),{recursive:!0}),await k.cp(we,I.join(t,"public/fonts"),{recursive:!0});let l=I.join(t,i.paths.lib,"utils");await k.mkdir(l,{recursive:!0}),await k.writeFile(I.join(l,"cn.ts"),yt)};var Pt=["feature","layer"],Et=["cliente","crm","mixto"],kt=e=>new Promise((t,o)=>{vt("pnpm",["install"],{cwd:e,stdio:"ignore",shell:!0}).on("close",n=>n===0?t():o(new Error(`pnpm install fall\xF3 con c\xF3digo ${n}`)))}),ke=async(e,t)=>{let o;!!(e&&t.type)?(Pt.includes(t.type)||(console.error(v.red(`Error: la arquitectura "${t.type}" no es v\xE1lida. Usa "feature" o "layer".`)),process.exit(1)),t.world&&!Et.includes(t.world)&&(console.error(v.red(`Error: el mundo "${t.world}" no es v\xE1lido. Usa "cliente", "crm" o "mixto".`)),process.exit(1)),t.world||console.warn(v.yellow('Aviso: sin --world; se asume "mixto". ')+v.dim("Pasa --world cliente|crm para fijar densidad y voz desde el inicio.")),o={projectName:e,architecture:t.type,world:t.world??"mixto"},console.log(v.blue("Modo automatizado detectado. Saltando interfaz interactiva..."))):o=await Ce(e),jt(`Nombre: ${o.projectName}
|
|
253
253
|
Arquitectura: ${o.architecture}
|
|
254
|
-
Mundo: ${o.world}`,"Configuraci\xF3n de Proyecto");let
|
|
254
|
+
Mundo: ${o.world}`,"Configuraci\xF3n de Proyecto");let n=Ct();n.start("Construyendo tu proyecto...");let s=process.cwd();try{await Ee(o,s)}catch(i){throw n.stop(v.red("No se pudo crear el proyecto.")),i}t.install!==!1&&(n.message("Instalando dependencias base..."),await kt(s)),n.stop("\xA1Proyecto construido con \xE9xito!"),$t(v.green(`Todo listo en el directorio actual
|
|
255
255
|
|
|
256
256
|
`)+v.dim(`Siguientes pasos:
|
|
257
257
|
`)+v.cyan(` pnpm dev
|
|
258
|
-
`)+v.cyan(" npx create-lexy add button"))};import
|
|
259
|
-
`),
|
|
260
|
-
`),
|
|
261
|
-
`)};var
|
|
262
|
-
${
|
|
263
|
-
`));let
|
|
258
|
+
`)+v.cyan(" npx create-lexy add button"))};import It from"fs/promises";import Lt from"path";import F from"picocolors";import oe from"picocolors";var V=(e,t)=>{let o=e.split(`
|
|
259
|
+
`),r=t.split(`
|
|
260
|
+
`),n=o.length,s=r.length,i=Array.from({length:n+1},()=>new Array(s+1).fill(0));for(let d=n-1;d>=0;d--)for(let u=s-1;u>=0;u--)i[d][u]=o[d]===r[u]?i[d+1][u+1]+1:Math.max(i[d+1][u],i[d][u+1]);let l=[],c=0,m=0;for(;c<n&&m<s;)o[c]===r[m]?(l.push({type:"same",text:o[c]}),c++,m++):i[c+1][m]>=i[c][m+1]?l.push({type:"del",text:o[c++]}):l.push({type:"add",text:r[m++]});for(;c<n;)l.push({type:"del",text:o[c++]});for(;m<s;)l.push({type:"add",text:r[m++]});return l},W=e=>e.some(t=>t.type!=="same"),Ie=(e,t=3)=>{if(!W(e))return null;let o=new Array(e.length).fill(!1);e.forEach((s,i)=>{if(s.type!=="same")for(let l=Math.max(0,i-t);l<=Math.min(e.length-1,i+t);l++)o[l]=!0});let r=[],n=!1;for(let s=0;s<e.length;s++){if(!o[s]){n||(r.push(oe.dim(" \u22EF")),n=!0);continue}n=!1;let i=e[s];i.type==="same"?r.push(` ${i.text}`):i.type==="del"?r.push(oe.red(`- ${i.text}`)):r.push(oe.green(`+ ${i.text}`))}return r.join(`
|
|
261
|
+
`)};var Le=async e=>{let t=process.cwd(),o=await S(t),r=e.toLowerCase(),{item:n,version:s}=await w(r),i=o.installed[r];console.log(F.bold(`
|
|
262
|
+
${n.title??r}`)+F.dim(` \xB7 instalado con registry@${i??"?"} \xB7 vigente registry@${s}
|
|
263
|
+
`));let l=!1;for(let c of P(n,o)){let m=await It.readFile(Lt.join(t,c.relPath),"utf-8").catch(()=>null);if(m===null){console.log(F.red(`\u2717 ${c.relPath} no existe localmente`)+F.dim(` \u2014 cr\xE9alo con \`create-lexy add ${r}\``)),l=!0;continue}let d=Ie(V(m,c.content));d===null?console.log(F.green(`\u2713 ${c.relPath}`)+F.dim(" sin diferencias")):(l=!0,console.log(F.yellow(`\xB1 ${c.relPath}`)+F.dim(" (\u2212 local \xB7 + registry)")),console.log(d))}l&&(process.exitCode=1)};import D from"fs/promises";import O from"path";import j from"picocolors";var Te=async e=>{let t=process.cwd(),o=0,r=f=>console.log(j.green(" \u2713 ")+f),n=f=>console.log(j.yellow(" \u2022 ")+f),s=(f,a)=>{o=1,console.log(j.red(" \u2717 ")+f),a&&console.log(j.dim(` \u2192 ${a}`))};console.log(j.bold(`
|
|
264
264
|
Diagn\xF3stico del proyecto Lexy
|
|
265
|
-
`));let i;try{i=await
|
|
266
|
-
Sin componentes instalados a\xFAn (create-lexy add <nombre>).`));else{let
|
|
267
|
-
Componentes instalados (registry vigente: ${
|
|
268
|
-
`));for(let[a,
|
|
265
|
+
`));let i;try{i=await S(t),r(`.lexy v\xE1lido (arquitectura ${i.architecture}${i.world?`, mundo ${i.world}`:""})`)}catch(f){return s(f.message),1}await D.access(O.join(t,"src/lexy-theme.css")).then(()=>!0,()=>!1)?r("theme presente (src/lexy-theme.css)"):s("falta src/lexy-theme.css","re-cr\xE9alo desde un proyecto nuevo o copia el theme del registry");let c=O.join(i.paths.lib,"utils/cn.ts");await D.access(O.join(t,c)).then(()=>!0,()=>!1)?r(`helper cn presente (${c})`):s(`falta el helper cn (${c})`);let d=O.join(t,"ai/lexy-ai-manifest.json"),u=await D.readFile(d,"utf-8").catch(()=>null);if(u===null)console.log(j.dim(" \xB7 capa de IA no instalada (npx @lexydesign/ai install) \u2014 opcional"));else try{let f=JSON.parse(u),a=f.files??[],p=[];for(let g of a)await D.access(O.join(t,g)).then(()=>!0,()=>!1)||p.push(g);p.length>0?s(`capa de IA ${f.aiVersion??"?"} incompleta \u2014 faltan ${p.length} archivo(s) (${p.slice(0,3).join(", ")}${p.length>3?", \u2026":""})`,"npx @lexydesign/ai install"):r(`capa de IA ${f.aiVersion??"?"} completa (${a.length} archivos)`)}catch{s("ai/lexy-ai-manifest.json no es JSON v\xE1lido","regenera con `npx @lexydesign/ai install`")}let R=Object.entries(i.installed);if(R.length===0)console.log(j.dim(`
|
|
266
|
+
Sin componentes instalados a\xFAn (create-lexy add <nombre>).`));else{let f=await K();console.log(j.bold(`
|
|
267
|
+
Componentes instalados (registry vigente: ${f})
|
|
268
|
+
`));for(let[a,p]of R){let g;try{g=await w(a)}catch(y){s(`${a}: ${y.message}`);continue}let b=P(g.item,i),T=[],H=!1;for(let y of b){let C=await D.readFile(O.join(t,y.relPath),"utf-8").catch(()=>null);C===null?T.push(y.relPath):W(V(C,y.content))&&(H=!0)}if(T.length>0){s(`${a}: archivos faltantes (${T.join(", ")})`,`create-lexy add ${a}`);continue}if(!H){r(`${a} al d\xEDa (${g.version})`);continue}let _=!0;if(p&&p!==g.version)try{let y=await w(a,p),C=P(y.item,i);_=!1;for(let le of C){let pe=await D.readFile(O.join(t,le.relPath),"utf-8").catch(()=>null);(pe===null||W(V(pe,le.content)))&&(_=!0)}}catch{}_?e.strict?s(`${a}: editado localmente (difiere del registry vigente)`,`create-lexy diff ${a}`):n(`${a}: editado localmente \u2014 divergencia deliberada (m\xEDrala con \`create-lexy diff ${a}\`)`):s(`${a}: desactualizado (instalado con ${p}, vigente ${g.version})`,`create-lexy diff ${a} \xB7 create-lexy add ${a} --overwrite`)}}return console.log(o===0?j.green(`
|
|
269
269
|
Todo en orden.
|
|
270
270
|
`):j.red(`
|
|
271
271
|
Hay problemas que atender (exit 1).
|
|
272
|
-
`)),o};import
|
|
272
|
+
`)),o};import re from"fs/promises";import Se from"path";import{note as Tt,outro as St}from"@clack/prompts";import ne from"picocolors";var Y="LEXY-KICKOFF.md",Ft=`# Kickoff de proyecto Lexy \u2014 protocolo de entrevista
|
|
273
273
|
|
|
274
274
|
> **Para el agente (Claude Code):** este archivo es tu guion. La persona que
|
|
275
275
|
> tienes enfrente es **dise\xF1adora, no programadora**: no le preguntes por
|
|
@@ -325,15 +325,19 @@ archivo es el plan inicial del proyecto y la memoria de las pr\xF3ximas sesiones
|
|
|
325
325
|
|
|
326
326
|
## 5. Cerrar
|
|
327
327
|
|
|
328
|
-
Borra este archivo (\`${
|
|
328
|
+
Borra este archivo (\`${Y}\`): su trabajo termin\xF3. Conf\xEDrmale a la
|
|
329
329
|
persona que su proyecto est\xE1 listo y prop\xF3n el primer paso concreto
|
|
330
330
|
(p. ej. "\xBFDise\xF1amos la pantalla de inicio?").
|
|
331
|
-
`,
|
|
332
|
-
|
|
333
|
-
Abre la carpeta con Claude Code y di: `+
|
|
334
|
-
El agente te entrevistar\xE1 y montar\xE1 el proyecto por ti.`,"Kickoff listo"),
|
|
331
|
+
`,Fe=async e=>{let t=process.cwd();for(let n of["package.json",".lexy"])if(await re.access(Se.join(t,n)).then(()=>!0,()=>!1))throw new Error(`El directorio actual ya contiene un proyecto (${n}). \`kickoff\` es para empezar de cero en una carpeta vac\xEDa.`);let o=Se.join(t,Y);if(await re.access(o).then(()=>!0,()=>!1)&&!e.force)throw new Error(`${Y} ya existe. Usa --force para regenerarlo.`);await re.writeFile(o,Ft),Tt(`Se cre\xF3 ${ne.cyan(Y)} en esta carpeta.
|
|
332
|
+
|
|
333
|
+
Abre la carpeta con Claude Code y di: `+ne.bold("\xABay\xFAdame a arrancar mi proyecto Lexy\xBB")+`.
|
|
334
|
+
El agente te entrevistar\xE1 y montar\xE1 el proyecto por ti.`,"Kickoff listo"),St(ne.green("Sin flags, sin prompts t\xE9cnicos \u2014 solo conversa con el agente."))};import se from"fs/promises";import X from"path";import $ from"picocolors";var ae="@lexydesign/kit",Re=`https://cdn.jsdelivr.net/npm/${ae}`,Oe=8e3,ie=async e=>{let t=await fetch(e,{signal:AbortSignal.timeout(Oe)});if(!t.ok){let o=new Error(`HTTP ${t.status} al pedir ${e}`);throw o.status=t.status,o}return Buffer.from(await t.arrayBuffer())},Rt=async()=>{try{let t=await fetch(`https://registry.npmjs.org/${ae}/latest`,{signal:AbortSignal.timeout(Oe)});if(t.ok)return(await t.json()).version}catch{}return JSON.parse((await ie(`${Re}@latest/package.json`)).toString("utf-8")).version},Ae=async e=>{let t=process.cwd(),o=X.resolve(t,e.dir??"lexy-kit"),r=X.relative(t,o)||".";if(await se.access(o).then(()=>!0).catch(()=>!1)&&!e.force)throw new Error(`Ya existe ${$.bold(r)}. Usa ${$.cyan("--force")} para sobrescribir o ${$.cyan("--dir <ruta>")} para otra carpeta.`);let s=await Rt();console.log($.dim(`
|
|
335
|
+
Trayendo ${ae}@${s} \u2192 ${r}/
|
|
336
|
+
`));let i=`${Re}@${s}/kit`,l=JSON.parse((await ie(`${i}/manifest.json`)).toString("utf-8")),c=["index.html","kit.css","kit.js","manifest.json","README.md","AGENTS.md","llms.txt","llms-full.txt","fonts/noto-sans-latin.woff2","fonts/OFL-NotoSans.txt",...l.guides?.pautas??[],...l.components.map(d=>d.file),...l.blocks.map(d=>d.file)],m=0;for(let d of c)try{let u=await ie(`${i}/${d}`),R=X.join(o,d);await se.mkdir(X.dirname(R),{recursive:!0}),await se.writeFile(R,u),m+=1}catch(u){console.warn($.yellow(`\u26A0 no se pudo traer ${d}`)+$.dim(` (${u.message})`))}console.log($.green("\u2713 Kit listo")+$.dim(` \u2014 ${m} archivo(s), ${l.components.length} componente(s) + ${l.blocks.length} block(s)
|
|
337
|
+
`)),console.log(` Abre ${$.bold(`${r}/index.html`)} en el navegador.`),console.log($.dim(` El cat\xE1logo m\xE1quina-legible est\xE1 en ${r}/manifest.json.
|
|
338
|
+
`))};import Ot from"fs/promises";import ce from"path";import x from"picocolors";var z=e=>console.log(x.bold(x.cyan(`
|
|
335
339
|
\u2500\u2500 ${e} \u2500\u2500
|
|
336
|
-
`))),
|
|
337
|
-
${i.items.length} componente(s). Instala con: create-lexy add <nombre>`));return}let o=e.toLowerCase();if(t.installed){let i=process.cwd(),
|
|
338
|
-
`),console.log(
|
|
339
|
-
Error: `)+t.message),process.exit(1)}};
|
|
340
|
+
`))),Ne=async(e,t)=>{if(t.list||!e){let{index:i,version:l,source:c}=await ye();z(`Cat\xE1logo Lexy \xB7 @lexydesign/registry@${l}${c==="bundle"?" (bundle local)":""}`);for(let m of i.items)console.log(` ${x.bold(m.name.padEnd(20))} ${x.dim(m.description??"")}`);console.log(x.dim(`
|
|
341
|
+
${i.items.length} componente(s). Instala con: create-lexy add <nombre>`));return}let o=e.toLowerCase();if(t.installed){let i=process.cwd(),l=await S(i),c=l.installed[o];if(!c){console.error(x.red(`"${o}" no figura como instalado en .lexy. Inst\xE1lalo con \`create-lexy add ${o}\`.`)),process.exitCode=1;return}let{item:m}=await w(o,c).catch(()=>w(o));z(`${m.title??o} \xB7 copia local (instalado con registry@${c})`);for(let d of P(m,l)){let u=await Ot.readFile(ce.join(i,d.relPath),"utf-8").catch(()=>null);z(u===null?`${d.relPath} (FALTANTE)`:d.relPath),u!==null&&console.log(u)}return}let{item:r,version:n,source:s}=await w(o);z(`${r.title??r.name} \xB7 @lexydesign/registry@${n}${s==="bundle"?" (bundle local)":""}`),r.description&&console.log(r.description+`
|
|
342
|
+
`),console.log(x.dim("tipo: ")+r.type),console.log(x.dim("deps npm: ")+((r.dependencies??[]).join(", ")||"\u2014")),console.log(x.dim("deps registry: ")+((r.registryDependencies??[]).join(", ")||"\u2014")),console.log(x.dim("archivos: ")+r.files.map(i=>ce.posix.basename(i.path)).join(", ")),console.log(x.dim("instalar: ")+`create-lexy add ${r.name}`);for(let i of r.files)typeof i.content=="string"&&(z(ce.posix.basename(i.path)),console.log(i.content))};var _t=Me.dirname(Nt(import.meta.url)),qt=JSON.parse(At(Me.join(_t,"../package.json"),"utf-8")),L=new Mt,A=e=>async()=>{try{await e()}catch(t){console.error(Dt.red(`
|
|
343
|
+
Error: `)+t.message),process.exit(1)}};L.name("create-lexy").description("CLI del Lexy Design System: crea proyectos y trae componentes a demanda.\nLos componentes viven en tu proyecto \u2014 m\xEDralos con `view`, inst\xE1lalos con `add`, ed\xEDtalos con libertad.").version(qt.version);L.command("create",{isDefault:!0}).alias("init").description("Crea un proyecto Lexy vac\xEDo (React + Vite + TS + theme); los componentes llegan con `add`").argument("[project-name]","Nombre del proyecto").option("-t, --type <architecture>","Arquitectura (feature o layer) \u2014 activa el modo no interactivo").option("-w, --world <world>","Mundo de dise\xF1o (cliente, crm o mixto)").option("--no-install","No correr pnpm install al final").action((e,t)=>A(()=>ke(e,t))());L.command("kickoff").description("Deja un .md de entrevista para que el agente conduzca el arranque de un dise\xF1ador (carpeta vac\xEDa)").option("--force","Regenerar el .md de kickoff si ya existe").action(e=>A(()=>Fe(e))());L.command("add").description("Instala componentes del registry en tu proyecto (local y editable), con sus dependencias").argument("<components...>","Nombres en el registry (ej: button card)").option("--overwrite","Sobrescribir copias locales con cambios sin preguntar").option("--no-install","No instalar dependencias npm").action((e,t)=>A(()=>be(e,t))());L.command("view").description("Muestra c\xF3digo + doc + metadata de un componente antes de instalarlo").argument("[component]","Nombre en el registry (sin nombre: lista el cat\xE1logo)").option("--installed","Mostrar la copia local instalada en vez de la del registry").option("--list","Listar el cat\xE1logo completo").action((e,t)=>A(()=>Ne(e,t))());L.command("kit").description("Trae el kit HTML/low-fi (mismos componentes y blocks en HTML plano) a una carpeta").option("--dir <path>","Carpeta destino (por defecto: lexy-kit)").option("--force","Sobrescribir la carpeta si ya existe").action(e=>A(()=>Ae(e))());L.command("diff").description("Copia local vs versi\xF3n vigente del registry (exit 1 si hay diferencias)").argument("<component>","Nombre en el registry").action(e=>A(()=>Le(e))());L.command("doctor").description("Drift de todo lo instalado contra el registry (solo lectura; exit 1 con problemas)").option("--strict","Las ediciones locales tambi\xE9n hacen fallar").action(e=>A(async()=>{process.exitCode=await Te(e)})());L.parse(process.argv);
|