create-lexy 0.4.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 +151 -48
- 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,16 +20,23 @@ 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
|
+
import babel from "@rolldown/plugin-babel";
|
|
27
28
|
import tailwindcss from "@tailwindcss/vite";
|
|
28
|
-
import react from "@vitejs/plugin-react";
|
|
29
|
+
import react, { reactCompilerPreset } from "@vitejs/plugin-react";
|
|
29
30
|
import { defineConfig } from "vite";
|
|
30
31
|
|
|
31
32
|
export default defineConfig({
|
|
32
|
-
plugins: [
|
|
33
|
+
plugins: [
|
|
34
|
+
react(),
|
|
35
|
+
// React Compiler: memoizaci\xF3n autom\xE1tica. En Vite 8 (Rolldown) el plugin de
|
|
36
|
+
// React es oxc, as\xED que el compilador corre como preset de babel aparte.
|
|
37
|
+
babel({ presets: [reactCompilerPreset()] }),
|
|
38
|
+
tailwindcss(),
|
|
39
|
+
],
|
|
33
40
|
resolve: {
|
|
34
41
|
alias: {
|
|
35
42
|
"@": path.resolve(import.meta.dirname, "./src"),
|
|
@@ -45,7 +52,7 @@ export default defineConfig({
|
|
|
45
52
|
},
|
|
46
53
|
},
|
|
47
54
|
});
|
|
48
|
-
`,
|
|
55
|
+
`,st=`import js from "@eslint/js";
|
|
49
56
|
import jsxA11y from "eslint-plugin-jsx-a11y";
|
|
50
57
|
import reactHooks from "eslint-plugin-react-hooks";
|
|
51
58
|
import simpleImportSort from "eslint-plugin-simple-import-sort";
|
|
@@ -74,14 +81,14 @@ export default tseslint.config(
|
|
|
74
81
|
},
|
|
75
82
|
},
|
|
76
83
|
);
|
|
77
|
-
`,
|
|
84
|
+
`,it=`{
|
|
78
85
|
"printWidth": 100
|
|
79
86
|
}
|
|
80
|
-
`,
|
|
87
|
+
`,at=`pnpm-lock.yaml
|
|
81
88
|
src/lexy-theme.css
|
|
82
89
|
public/fonts/
|
|
83
90
|
dist/
|
|
84
|
-
`,
|
|
91
|
+
`,ct=`name: CI
|
|
85
92
|
|
|
86
93
|
on:
|
|
87
94
|
push:
|
|
@@ -103,7 +110,7 @@ jobs:
|
|
|
103
110
|
- run: pnpm exec prettier --check .
|
|
104
111
|
- run: pnpm build
|
|
105
112
|
- run: pnpm audit --audit-level high
|
|
106
|
-
`,
|
|
113
|
+
`,lt=`{
|
|
107
114
|
"files": [],
|
|
108
115
|
"references": [{ "path": "./tsconfig.app.json" }, { "path": "./tsconfig.node.json" }],
|
|
109
116
|
"compilerOptions": {
|
|
@@ -111,7 +118,7 @@ jobs:
|
|
|
111
118
|
"paths": { "@/*": ["./src/*"] }
|
|
112
119
|
}
|
|
113
120
|
}
|
|
114
|
-
`,
|
|
121
|
+
`,pt=`{
|
|
115
122
|
"compilerOptions": {
|
|
116
123
|
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
|
|
117
124
|
"target": "ES2022",
|
|
@@ -135,7 +142,7 @@ jobs:
|
|
|
135
142
|
},
|
|
136
143
|
"include": ["src"]
|
|
137
144
|
}
|
|
138
|
-
`,
|
|
145
|
+
`,dt=`{
|
|
139
146
|
"compilerOptions": {
|
|
140
147
|
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
|
|
141
148
|
"target": "ES2023",
|
|
@@ -152,7 +159,7 @@ jobs:
|
|
|
152
159
|
},
|
|
153
160
|
"include": ["vite.config.ts"]
|
|
154
161
|
}
|
|
155
|
-
`,
|
|
162
|
+
`,mt=e=>`<!doctype html>
|
|
156
163
|
<html lang="es">
|
|
157
164
|
<head>
|
|
158
165
|
<meta charset="UTF-8" />
|
|
@@ -164,43 +171,73 @@ jobs:
|
|
|
164
171
|
<script type="module" src="/src/main.tsx"></script>
|
|
165
172
|
</body>
|
|
166
173
|
</html>
|
|
167
|
-
`,
|
|
174
|
+
`,ut=`@import "tailwindcss";
|
|
168
175
|
@import "./lexy-theme.css";
|
|
169
|
-
`,
|
|
176
|
+
`,ft=e=>e.architecture==="feature"?`import "./index.css";
|
|
170
177
|
|
|
171
178
|
import { StrictMode } from "react";
|
|
172
179
|
import { createRoot } from "react-dom/client";
|
|
180
|
+
import { BrowserRouter } from "react-router";
|
|
173
181
|
|
|
174
|
-
import { App } from "
|
|
182
|
+
import { App } from "./app/App";
|
|
183
|
+
|
|
184
|
+
createRoot(document.getElementById("root")!).render(
|
|
185
|
+
<StrictMode>
|
|
186
|
+
<BrowserRouter>
|
|
187
|
+
<App />
|
|
188
|
+
</BrowserRouter>
|
|
189
|
+
</StrictMode>,
|
|
190
|
+
);
|
|
191
|
+
`:`import "./index.css";
|
|
192
|
+
|
|
193
|
+
import { StrictMode } from "react";
|
|
194
|
+
import { createRoot } from "react-dom/client";
|
|
195
|
+
|
|
196
|
+
import { App } from "./views/App";
|
|
175
197
|
|
|
176
198
|
createRoot(document.getElementById("root")!).render(
|
|
177
199
|
<StrictMode>
|
|
178
200
|
<App />
|
|
179
201
|
</StrictMode>,
|
|
180
202
|
);
|
|
181
|
-
`,
|
|
182
|
-
return (
|
|
183
|
-
<main className="flex min-h-screen items-center justify-center bg-background text-foreground">
|
|
203
|
+
`,Pe=` <main className="flex min-h-screen items-center justify-center bg-background text-foreground">
|
|
184
204
|
<div className="text-center">
|
|
185
205
|
<h1 className="text-2xl font-semibold">Proyecto Lexy listo</h1>
|
|
186
206
|
<p className="mt-2 text-sm text-muted-foreground">
|
|
187
207
|
Trae tu primer componente: <code>npx create-lexy add button</code>
|
|
188
208
|
</p>
|
|
189
209
|
</div>
|
|
190
|
-
</main
|
|
210
|
+
</main>`,gt=e=>e.architecture==="feature"?`import { Route, Routes } from "react-router";
|
|
211
|
+
|
|
212
|
+
const Home = () => {
|
|
213
|
+
return (
|
|
214
|
+
${Pe}
|
|
215
|
+
);
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
export const App = () => {
|
|
219
|
+
return (
|
|
220
|
+
<Routes>
|
|
221
|
+
<Route path="/" element={<Home />} />
|
|
222
|
+
</Routes>
|
|
223
|
+
);
|
|
224
|
+
};
|
|
225
|
+
`:`export const App = () => {
|
|
226
|
+
return (
|
|
227
|
+
${Pe}
|
|
191
228
|
);
|
|
192
229
|
};
|
|
193
|
-
`,
|
|
230
|
+
`,yt=`import { type ClassValue, clsx } from "clsx";
|
|
194
231
|
import { twMerge } from "tailwind-merge";
|
|
195
232
|
|
|
196
233
|
export function cn(...inputs: ClassValue[]) {
|
|
197
234
|
return twMerge(clsx(inputs));
|
|
198
235
|
}
|
|
199
|
-
`,
|
|
236
|
+
`,ht=`node_modules/
|
|
200
237
|
dist/
|
|
201
238
|
*.log
|
|
202
239
|
.env
|
|
203
|
-
`,
|
|
240
|
+
`,wt=e=>`# ${e.projectName}
|
|
204
241
|
|
|
205
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.
|
|
206
243
|
|
|
@@ -210,31 +247,97 @@ npx create-lexy view button # ver un componente antes de instalarlo
|
|
|
210
247
|
npx create-lexy add button # instalarlo (local y editable)
|
|
211
248
|
npx create-lexy doctor # divergencia con el registry
|
|
212
249
|
\`\`\`
|
|
213
|
-
`,
|
|
214
|
-
`},
|
|
215
|
-
`),await n("components.json",
|
|
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}
|
|
216
253
|
Arquitectura: ${o.architecture}
|
|
217
|
-
Mundo: ${o.world}`,"Configuraci\xF3n de Proyecto");let n=
|
|
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
|
|
218
255
|
|
|
219
|
-
`)+
|
|
220
|
-
`)+
|
|
221
|
-
`)+
|
|
256
|
+
`)+v.dim(`Siguientes pasos:
|
|
257
|
+
`)+v.cyan(` pnpm dev
|
|
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(`
|
|
222
259
|
`),r=t.split(`
|
|
223
|
-
`),n=o.length,s=r.length,i=Array.from({length:n+1},()=>new Array(s+1).fill(0));for(let
|
|
224
|
-
`)};var
|
|
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(`
|
|
225
262
|
${n.title??r}`)+F.dim(` \xB7 instalado con registry@${i??"?"} \xB7 vigente registry@${s}
|
|
226
|
-
`));let
|
|
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(`
|
|
227
264
|
Diagn\xF3stico del proyecto Lexy
|
|
228
|
-
`));let i;try{i=await
|
|
229
|
-
Sin componentes instalados a\xFAn (create-lexy add <nombre>).`));else{let
|
|
230
|
-
Componentes instalados (registry vigente: ${
|
|
231
|
-
`));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(`
|
|
232
269
|
Todo en orden.
|
|
233
|
-
`):
|
|
270
|
+
`):j.red(`
|
|
234
271
|
Hay problemas que atender (exit 1).
|
|
235
|
-
`)),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
|
+
|
|
274
|
+
> **Para el agente (Claude Code):** este archivo es tu guion. La persona que
|
|
275
|
+
> tienes enfrente es **dise\xF1adora, no programadora**: no le preguntes por
|
|
276
|
+
> tecnolog\xEDa (arquitectura, router, layered/feature) \u2014 preg\xFAntale por la **forma
|
|
277
|
+
> de lo que quiere construir**. Conduce t\xFA la conversaci\xF3n; al final ejecutas el
|
|
278
|
+
> CLI por ella. Cuando termines, **borra este archivo**.
|
|
279
|
+
|
|
280
|
+
## 1. Entrevista (en lenguaje de producto, no t\xE9cnico)
|
|
281
|
+
|
|
282
|
+
Conversa hasta tener claridad real. No dispares todas las preguntas de golpe:
|
|
283
|
+
hazlas de a poco, repregunta y resume lo que entendiste. Cubre:
|
|
284
|
+
|
|
285
|
+
- **Qu\xE9 es** \u2014 en una o dos frases, \xBFqu\xE9 producto es y qu\xE9 problema resuelve?
|
|
286
|
+
- **Para qui\xE9n es** \u2014 \xBFlo usan **clientes de Lexy** (personas en un tr\xE1mite
|
|
287
|
+
legal, mundo *cliente*: calma, una idea por pantalla) o el **equipo interno /
|
|
288
|
+
CRM** (abogados trabajando, mundo *CRM*: densidad, escaneabilidad)? \xBFAmbos?
|
|
289
|
+
- **Forma del producto** \u2014 \xBFes **una pantalla o flujo corto** (una landing, un
|
|
290
|
+
formulario, una demo) o **una app con varias secciones y navegaci\xF3n** (un
|
|
291
|
+
dashboard, listados, vistas de detalle)?
|
|
292
|
+
- **Pantallas y flujos clave** \u2014 \xBFqu\xE9 vistas importan y qu\xE9 hace la persona en
|
|
293
|
+
cada una? \xBFC\xF3mo se mueve entre ellas?
|
|
294
|
+
- **Datos y referencias** \u2014 \xBFqu\xE9 datos maneja? \xBFHay un Figma, capturas o un
|
|
295
|
+
producto de referencia que mande sobre composiciones gen\xE9ricas?
|
|
296
|
+
|
|
297
|
+
## 2. Traducir las respuestas a flags (no se lo muestres a la persona)
|
|
298
|
+
|
|
299
|
+
| Lo que dijo la persona | Flag |
|
|
300
|
+
|---|---|
|
|
301
|
+
| Para clientes de Lexy | \`--world cliente\` |
|
|
302
|
+
| Para el equipo interno / CRM | \`--world crm\` |
|
|
303
|
+
| Para ambos o a\xFAn no est\xE1 claro | \`--world mixto\` |
|
|
304
|
+
| Una pantalla o flujo corto | \`--type layer\` |
|
|
305
|
+
| Una app con secciones y navegaci\xF3n | \`--type feature\` |
|
|
306
|
+
|
|
307
|
+
Elige tambi\xE9n un **nombre de proyecto** en kebab-case (min\xFAsculas, sin espacios),
|
|
308
|
+
derivado de lo que construye (ej. \`intake-divorcios\`, \`crm-casos\`).
|
|
309
|
+
|
|
310
|
+
## 3. Ejecutar (t\xFA, el agente \u2014 no la persona)
|
|
311
|
+
|
|
312
|
+
En **esta misma carpeta vac\xEDa**, corre:
|
|
313
|
+
|
|
314
|
+
\`\`\`bash
|
|
315
|
+
npx create-lexy create <nombre> --type <layer|feature> --world <cliente|crm|mixto>
|
|
316
|
+
npx @lexydesign/ai install
|
|
317
|
+
\`\`\`
|
|
318
|
+
|
|
319
|
+
## 4. Volcar la entrevista en el brief vivo
|
|
320
|
+
|
|
321
|
+
Abre \`ai/PROJECT-CONTEXT.md\` (lo cre\xF3 \`@lexydesign/ai install\`) y compl\xE9talo
|
|
322
|
+
con lo que recopilaste: **qu\xE9 se construye**, **para qui\xE9n**, **pantallas y
|
|
323
|
+
flujos clave**, **referencias** y **decisiones/restricciones** ya tomadas. Ese
|
|
324
|
+
archivo es el plan inicial del proyecto y la memoria de las pr\xF3ximas sesiones.
|
|
325
|
+
|
|
326
|
+
## 5. Cerrar
|
|
327
|
+
|
|
328
|
+
Borra este archivo (\`${Y}\`): su trabajo termin\xF3. Conf\xEDrmale a la
|
|
329
|
+
persona que su proyecto est\xE1 listo y prop\xF3n el primer paso concreto
|
|
330
|
+
(p. ej. "\xBFDise\xF1amos la pantalla de inicio?").
|
|
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(`
|
|
236
339
|
\u2500\u2500 ${e} \u2500\u2500
|
|
237
|
-
`))),
|
|
238
|
-
${i.items.length} componente(s). Instala con: create-lexy add <nombre>`));return}let o=e.toLowerCase();if(t.installed){let i=process.cwd(),
|
|
239
|
-
`),console.log(
|
|
240
|
-
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);
|