create-lexy 0.4.0 → 0.5.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 +149 -50
- 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 l=await
|
|
2
|
+
import{readFileSync as Et}from"fs";import ke from"path";import{fileURLToPath as It}from"url";import{Command as Lt}from"commander";import kt from"picocolors";import{spawn as De}from"child_process";import K from"fs/promises";import B from"path";import{confirm as Me,isCancel as qe,spinner as fe}from"@clack/prompts";import h from"picocolors";import Y from"path";var Fe=(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/'),Te=[["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 n=Te.find(([s])=>o.path.startsWith(s));return{relPath:n?Y.posix.join(n[1](t),o.path.slice(n[0].length)):Y.posix.join(t.paths.components,Y.posix.basename(o.path)),content:Fe(o.content,t)}});import ie from"fs/promises";import Se from"path";var ae=e=>Se.join(e,".lexy"),k=async e=>{let t;try{t=await ie.readFile(ae(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},ce=async(e,t)=>{await ie.writeFile(ae(e),JSON.stringify(t,null,2)+`
|
|
3
|
+
`)};import M from"fs/promises";import Re from"os";import $ from"path";import{fileURLToPath as Oe}from"url";var le="@lexydesign/registry",O=`https://cdn.jsdelivr.net/npm/${le}`,Ae=8e3,H=$.resolve($.dirname(Oe(import.meta.url)),"../assets"),Ne=$.join(Re.homedir(),".cache","create-lexy","registry"),U=async e=>{let t=await fetch(e,{signal:AbortSignal.timeout(Ae)});if(!t.ok){let o=new Error(`HTTP ${t.status} al pedir ${e}`);throw o.status=t.status,o}return await t.json()},pe=async e=>{try{return JSON.parse(await M.readFile($.join(H,"r",e),"utf-8"))}catch{return null}},X=async()=>{try{return(await M.readFile($.join(H,"registry-version"),"utf-8")).trim()}catch{return"bundle"}},R=null,J=async()=>{if(R)return R;try{R=(await U(`https://registry.npmjs.org/${le}/latest`)).version}catch{try{R=(await U(`${O}@latest/package.json`)).version}catch{R=await X()}}return R},x=async(e,t)=>{let o=e.replace(/^@lexy\//,""),n=t??await J(),r=$.join(Ne,n,`${o}.json`);try{return{item:JSON.parse(await M.readFile(r,"utf-8")),version:n,source:"cache"}}catch{}try{let s=await U(`${O}@${n}/r/${o}.json`);return await M.mkdir($.dirname(r),{recursive:!0}),await M.writeFile(r,JSON.stringify(s)),{item:s,version:n,source:"cdn"}}catch(s){if(s.status===404)throw new Error(`El componente "${o}" no existe en el registry (versi\xF3n ${n}). Mira el cat\xE1logo con \`create-lexy view --list\`.`);let i=await pe(`${o}.json`);if(i)return{item:i,version:await X(),source:"bundle"};throw new Error(`No se pudo alcanzar el registry (\xBFsin red?) y "${o}" tampoco est\xE1 en el bundle local del CLI.`)}},de=async()=>{try{let e=await J();return{index:await U(`${O}@${e}/r/registry.json`),version:e,source:"cdn"}}catch{let e=await pe("registry.json");if(e)return{index:e,version:await X(),source:"bundle"};throw new Error("No se pudo alcanzar el registry ni leer el bundle local del CLI.")}},me=$.join(H,"theme/lexy-theme.css"),ue=$.join(H,"fonts");var _e=(e,t)=>new Promise((o,n)=>{De("pnpm",["add",...e],{cwd:t,stdio:"ignore",shell:!0}).on("close",s=>s===0?o():n(new Error(`pnpm add fall\xF3 con c\xF3digo ${s}`)))}),ze=async e=>{try{return await K.readFile(e,"utf-8")}catch{return null}},ge=async(e,t)=>{let o=process.cwd(),n=await k(o),r=fe();r.start("Resolviendo componentes en el registry...");let s=new Map,i=async a=>{let l=a.toLowerCase().replace(/^@lexy\//,"");if(s.has(l))return;let f=await x(l);s.set(l,f);for(let b of f.item.registryDependencies??[])await i(b)};try{for(let a of e)await i(a)}catch(a){throw r.stop(h.red("No se pudo resolver el pedido.")),a}let p=new Map;for(let[a,{item:l}]of s){let f=[];for(let b of P(l,n)){let L=await ze(B.join(o,b.relPath));f.push({...b,status:L===null?"new":L===b.content?"same":"differs"})}p.set(a,f)}let c=Array.from(p.values()).flat().filter(a=>a.status==="differs");if(r.stop(`Resueltos: ${Array.from(s.keys()).join(", ")}`),c.length>0&&!t.overwrite){let a=c.map(l=>` ${l.relPath}`).join(`
|
|
4
|
+
`);if(process.stdout.isTTY&&process.stdin.isTTY){let l=await Me({message:`Estos archivos existen con cambios locales y ser\xE1n sobrescritos:
|
|
5
5
|
${a}
|
|
6
|
-
\xBFContinuar?`});if(
|
|
6
|
+
\xBFContinuar?`});if(qe(l)||l!==!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,l]of
|
|
8
|
+
Usa --overwrite para sobrescribirlos.`)),process.exitCode=1;return}}for(let[a,l]of p){let{item:f,version:b,source:L}=s.get(a);for(let y of l){if(y.status==="same")continue;let C=B.join(o,y.relPath);await K.mkdir(B.dirname(C),{recursive:!0}),await K.writeFile(C,y.content)}n.installed[f.name]=b;let V=e.map(y=>y.toLowerCase()).includes(a)?"":h.dim(" (dependencia)"),D=L==="bundle"?h.yellow(" [bundle local \u2014 sin red]"):"";console.log(h.green(`${h.bold(f.title??f.name)} instalado`)+V+h.cyan(` \u2192 ${n.paths.components}/`)+D);for(let y of l){let C=y.status==="same"?h.dim(" (sin cambios)"):"";console.log(h.dim(` ${y.relPath}${C}`))}}await ce(o,n);let d=new Set;for(let{item:a}of s.values())for(let l of a.dependencies??[])d.add(l);let m=JSON.parse(await K.readFile(B.join(o,"package.json"),"utf-8")),g={...m.dependencies,...m.devDependencies},z=a=>{let l=a.lastIndexOf("@");return l>0?a.slice(0,l):a},u=Array.from(d).filter(a=>!g[z(a)]);if(u.length>0)if(t.install===!1)console.log(h.yellow(`Dependencias pendientes (inst\xE1lalas t\xFA): ${u.join(", ")}`));else{let a=fe();a.start(`Instalando dependencias: ${u.join(", ")}...`),await _e(u,o),a.stop("Dependencias instaladas.")}};import{spawn as ut}from"child_process";import{note as ft,outro as gt,spinner as yt}from"@clack/prompts";import v from"picocolors";import{cancel as Ve,intro as Ue,isCancel as He,select as he,text as Je}from"@clack/prompts";import xe from"picocolors";var Q=[{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"}],ye=e=>Q.find(t=>t.value===e).architecture;var Be=`
|
|
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
|
+
`,Z=e=>{He(e)&&(Ve("Operaci\xF3n cancelada por el usuario."),process.exit(0))},we=async e=>{console.clear(),Ue(`${xe.cyan(Be)}
|
|
24
|
+
${xe.bold(" Bienvenido al generador de proyectos Lexy")}`);let t=e;if(!t){let r=await Je({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."}});Z(r),t=r}let o=await he({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"});Z(o);let n=await he({message:"\xBFC\xF3mo es lo que vas a construir?",options:Q.map(r=>({label:r.label,value:r.value,hint:r.hint})),initialValue:"app"});return Z(n),{projectName:t,architecture:ye(n),world:o}};import E from"fs/promises";import I from"path";var Ke={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"]},Ge="10.33.3",We=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@${Ge}`,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
|
+
`},Ye=`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
|
+
`,Xe=`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
|
+
`,Qe=`{
|
|
78
85
|
"printWidth": 100
|
|
79
86
|
}
|
|
80
|
-
`,
|
|
87
|
+
`,Ze=`pnpm-lock.yaml
|
|
81
88
|
src/lexy-theme.css
|
|
82
89
|
public/fonts/
|
|
83
90
|
dist/
|
|
84
|
-
`,
|
|
91
|
+
`,et=`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
|
+
`,tt=`{
|
|
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
|
+
`,ot=`{
|
|
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
|
+
`,rt=`{
|
|
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
|
+
`,nt=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
|
+
`,st=`@import "tailwindcss";
|
|
168
175
|
@import "./lexy-theme.css";
|
|
169
|
-
`,
|
|
176
|
+
`,it=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
|
+
`,be=` <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>`,at=e=>e.architecture==="feature"?`import { Route, Routes } from "react-router";
|
|
211
|
+
|
|
212
|
+
const Home = () => {
|
|
213
|
+
return (
|
|
214
|
+
${be}
|
|
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
|
+
${be}
|
|
191
228
|
);
|
|
192
229
|
};
|
|
193
|
-
`,
|
|
230
|
+
`,ct=`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
|
+
`,lt=`node_modules/
|
|
200
237
|
dist/
|
|
201
238
|
*.log
|
|
202
239
|
.env
|
|
203
|
-
`,
|
|
240
|
+
`,pt=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,93 @@ 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
|
|
250
|
+
`,dt=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":`${O}@latest/r/{name}.json`}},null,2)+`
|
|
251
|
+
`},mt=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:O},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:{}}},ve=async(e,t)=>{let o=["package.json","src","index.html",".lexy"],n=[];for(let c of o)try{await E.access(I.join(t,c)),n.push(c)}catch{}if(n.length>0)throw new Error(`El directorio actual ya contiene archivos de un proyecto (${n.join(", ")}). Ejecuta el comando dentro de una carpeta vac\xEDa.`);for(let c of Ke[e.architecture])await E.mkdir(I.join(t,c),{recursive:!0});let r=(c,d)=>E.writeFile(I.join(t,c),d);await r("package.json",We(e)),await r("vite.config.ts",Ye),await r("tsconfig.json",tt),await r("tsconfig.app.json",ot),await r("tsconfig.node.json",rt),await r("eslint.config.js",Xe),await r(".prettierrc",Qe),await r(".prettierignore",Ze),await E.mkdir(I.join(t,".github/workflows"),{recursive:!0}),await r(".github/workflows/ci.yml",et),await r("index.html",nt(e)),await r(".gitignore",lt),await r("README.md",pt(e)),await r("src/index.css",st),await r("src/main.tsx",it(e));let s=e.architecture==="feature"?"src/app":"src/views";await r(`${s}/App.tsx`,at(e));let i=mt(e);await r(".lexy",JSON.stringify(i,null,2)+`
|
|
252
|
+
`),await r("components.json",dt(e)),await E.copyFile(me,I.join(t,"src/lexy-theme.css")),await E.mkdir(I.join(t,"public/fonts"),{recursive:!0}),await E.cp(ue,I.join(t,"public/fonts"),{recursive:!0});let p=I.join(t,i.paths.lib,"utils");await E.mkdir(p,{recursive:!0}),await E.writeFile(I.join(p,"cn.ts"),ct)};var ht=["feature","layer"],xt=["cliente","crm","mixto"],wt=e=>new Promise((t,o)=>{ut("pnpm",["install"],{cwd:e,stdio:"ignore",shell:!0}).on("close",r=>r===0?t():o(new Error(`pnpm install fall\xF3 con c\xF3digo ${r}`)))}),je=async(e,t)=>{let o;!!(e&&t.type)?(ht.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&&!xt.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 we(e),ft(`Nombre: ${o.projectName}
|
|
216
253
|
Arquitectura: ${o.architecture}
|
|
217
|
-
Mundo: ${o.world}`,"Configuraci\xF3n de Proyecto");let
|
|
218
|
-
|
|
219
|
-
`)+
|
|
220
|
-
`)+
|
|
221
|
-
`)+
|
|
222
|
-
`),
|
|
223
|
-
`),
|
|
224
|
-
`)};var
|
|
225
|
-
${
|
|
226
|
-
`));let
|
|
254
|
+
Mundo: ${o.world}`,"Configuraci\xF3n de Proyecto");let r=yt();r.start("Construyendo tu proyecto...");let s=process.cwd();try{await ve(o,s)}catch(i){throw r.stop(v.red("No se pudo crear el proyecto.")),i}t.install!==!1&&(r.message("Instalando dependencias base..."),await wt(s)),r.stop("\xA1Proyecto construido con \xE9xito!"),gt(v.green(`Todo listo en el directorio actual
|
|
255
|
+
|
|
256
|
+
`)+v.dim(`Siguientes pasos:
|
|
257
|
+
`)+v.cyan(` pnpm dev
|
|
258
|
+
`)+v.cyan(" npx create-lexy add button"))};import bt from"fs/promises";import vt from"path";import F from"picocolors";import ee from"picocolors";var q=(e,t)=>{let o=e.split(`
|
|
259
|
+
`),n=t.split(`
|
|
260
|
+
`),r=o.length,s=n.length,i=Array.from({length:r+1},()=>new Array(s+1).fill(0));for(let m=r-1;m>=0;m--)for(let g=s-1;g>=0;g--)i[m][g]=o[m]===n[g]?i[m+1][g+1]+1:Math.max(i[m+1][g],i[m][g+1]);let p=[],c=0,d=0;for(;c<r&&d<s;)o[c]===n[d]?(p.push({type:"same",text:o[c]}),c++,d++):i[c+1][d]>=i[c][d+1]?p.push({type:"del",text:o[c++]}):p.push({type:"add",text:n[d++]});for(;c<r;)p.push({type:"del",text:o[c++]});for(;d<s;)p.push({type:"add",text:n[d++]});return p},G=e=>e.some(t=>t.type!=="same"),Ce=(e,t=3)=>{if(!G(e))return null;let o=new Array(e.length).fill(!1);e.forEach((s,i)=>{if(s.type!=="same")for(let p=Math.max(0,i-t);p<=Math.min(e.length-1,i+t);p++)o[p]=!0});let n=[],r=!1;for(let s=0;s<e.length;s++){if(!o[s]){r||(n.push(ee.dim(" \u22EF")),r=!0);continue}r=!1;let i=e[s];i.type==="same"?n.push(` ${i.text}`):i.type==="del"?n.push(ee.red(`- ${i.text}`)):n.push(ee.green(`+ ${i.text}`))}return n.join(`
|
|
261
|
+
`)};var Pe=async e=>{let t=process.cwd(),o=await k(t),n=e.toLowerCase(),{item:r,version:s}=await x(n),i=o.installed[n];console.log(F.bold(`
|
|
262
|
+
${r.title??n}`)+F.dim(` \xB7 instalado con registry@${i??"?"} \xB7 vigente registry@${s}
|
|
263
|
+
`));let p=!1;for(let c of P(r,o)){let d=await bt.readFile(vt.join(t,c.relPath),"utf-8").catch(()=>null);if(d===null){console.log(F.red(`\u2717 ${c.relPath} no existe localmente`)+F.dim(` \u2014 cr\xE9alo con \`create-lexy add ${n}\``)),p=!0;continue}let m=Ce(q(d,c.content));m===null?console.log(F.green(`\u2713 ${c.relPath}`)+F.dim(" sin diferencias")):(p=!0,console.log(F.yellow(`\xB1 ${c.relPath}`)+F.dim(" (\u2212 local \xB7 + registry)")),console.log(m))}p&&(process.exitCode=1)};import A from"fs/promises";import S from"path";import j from"picocolors";var $e=async e=>{let t=process.cwd(),o=0,n=u=>console.log(j.green(" \u2713 ")+u),r=u=>console.log(j.yellow(" \u2022 ")+u),s=(u,a)=>{o=1,console.log(j.red(" \u2717 ")+u),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 u=await
|
|
265
|
+
`));let i;try{i=await k(t),n(`.lexy v\xE1lido (arquitectura ${i.architecture}${i.world?`, mundo ${i.world}`:""})`)}catch(u){return s(u.message),1}await A.access(S.join(t,"src/lexy-theme.css")).then(()=>!0,()=>!1)?n("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=S.join(i.paths.lib,"utils/cn.ts");await A.access(S.join(t,c)).then(()=>!0,()=>!1)?n(`helper cn presente (${c})`):s(`falta el helper cn (${c})`);let m=S.join(t,"ai/lexy-ai-manifest.json"),g=await A.readFile(m,"utf-8").catch(()=>null);if(g===null)console.log(j.dim(" \xB7 capa de IA no instalada (npx @lexydesign/ai install) \u2014 opcional"));else try{let u=JSON.parse(g),a=u.files??[],l=[];for(let f of a)await A.access(S.join(t,f)).then(()=>!0,()=>!1)||l.push(f);l.length>0?s(`capa de IA ${u.aiVersion??"?"} incompleta \u2014 faltan ${l.length} archivo(s) (${l.slice(0,3).join(", ")}${l.length>3?", \u2026":""})`,"npx @lexydesign/ai install"):n(`capa de IA ${u.aiVersion??"?"} completa (${a.length} archivos)`)}catch{s("ai/lexy-ai-manifest.json no es JSON v\xE1lido","regenera con `npx @lexydesign/ai install`")}let z=Object.entries(i.installed);if(z.length===0)console.log(j.dim(`
|
|
266
|
+
Sin componentes instalados a\xFAn (create-lexy add <nombre>).`));else{let u=await J();console.log(j.bold(`
|
|
230
267
|
Componentes instalados (registry vigente: ${u})
|
|
231
|
-
`));for(let[a,l]of z){let f;try{f=await x(a)}catch(y){s(`${a}: ${y.message}`);continue}let b
|
|
268
|
+
`));for(let[a,l]of z){let f;try{f=await x(a)}catch(y){s(`${a}: ${y.message}`);continue}let b=P(f.item,i),L=[],V=!1;for(let y of b){let C=await A.readFile(S.join(t,y.relPath),"utf-8").catch(()=>null);C===null?L.push(y.relPath):G(q(C,y.content))&&(V=!0)}if(L.length>0){s(`${a}: archivos faltantes (${L.join(", ")})`,`create-lexy add ${a}`);continue}if(!V){n(`${a} al d\xEDa (${f.version})`);continue}let D=!0;if(l&&l!==f.version)try{let y=await x(a,l),C=P(y.item,i);D=!1;for(let ne of C){let se=await A.readFile(S.join(t,ne.relPath),"utf-8").catch(()=>null);(se===null||G(q(se,ne.content)))&&(D=!0)}}catch{}D?e.strict?s(`${a}: editado localmente (difiere del registry vigente)`,`create-lexy diff ${a}`):r(`${a}: editado localmente \u2014 divergencia deliberada (m\xEDrala con \`create-lexy diff ${a}\`)`):s(`${a}: desactualizado (instalado con ${l}, vigente ${f.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 te from"fs/promises";import Ee from"path";import{note as jt,outro as Ct}from"@clack/prompts";import oe from"picocolors";var W="LEXY-KICKOFF.md",Pt=`# 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 (\`${W}\`): 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
|
+
`,Ie=async e=>{let t=process.cwd();for(let r of["package.json",".lexy"])if(await te.access(Ee.join(t,r)).then(()=>!0,()=>!1))throw new Error(`El directorio actual ya contiene un proyecto (${r}). \`kickoff\` es para empezar de cero en una carpeta vac\xEDa.`);let o=Ee.join(t,W);if(await te.access(o).then(()=>!0,()=>!1)&&!e.force)throw new Error(`${W} ya existe. Usa --force para regenerarlo.`);await te.writeFile(o,Pt),jt(`Se cre\xF3 ${oe.cyan(W)} en esta carpeta.
|
|
332
|
+
|
|
333
|
+
Abre la carpeta con Claude Code y di: `+oe.bold("\xABay\xFAdame a arrancar mi proyecto Lexy\xBB")+`.
|
|
334
|
+
El agente te entrevistar\xE1 y montar\xE1 el proyecto por ti.`,"Kickoff listo"),Ct(oe.green("Sin flags, sin prompts t\xE9cnicos \u2014 solo conversa con el agente."))};import $t from"fs/promises";import re from"path";import w from"picocolors";var _=e=>console.log(w.bold(w.cyan(`
|
|
236
335
|
\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(w.dim("tipo: ")+
|
|
240
|
-
Error: `)+t.message),process.exit(1)}};
|
|
336
|
+
`))),Le=async(e,t)=>{if(t.list||!e){let{index:i,version:p,source:c}=await de();_(`Cat\xE1logo Lexy \xB7 @lexydesign/registry@${p}${c==="bundle"?" (bundle local)":""}`);for(let d of i.items)console.log(` ${w.bold(d.name.padEnd(20))} ${w.dim(d.description??"")}`);console.log(w.dim(`
|
|
337
|
+
${i.items.length} componente(s). Instala con: create-lexy add <nombre>`));return}let o=e.toLowerCase();if(t.installed){let i=process.cwd(),p=await k(i),c=p.installed[o];if(!c){console.error(w.red(`"${o}" no figura como instalado en .lexy. Inst\xE1lalo con \`create-lexy add ${o}\`.`)),process.exitCode=1;return}let{item:d}=await x(o,c).catch(()=>x(o));_(`${d.title??o} \xB7 copia local (instalado con registry@${c})`);for(let m of P(d,p)){let g=await $t.readFile(re.join(i,m.relPath),"utf-8").catch(()=>null);_(g===null?`${m.relPath} (FALTANTE)`:m.relPath),g!==null&&console.log(g)}return}let{item:n,version:r,source:s}=await x(o);_(`${n.title??n.name} \xB7 @lexydesign/registry@${r}${s==="bundle"?" (bundle local)":""}`),n.description&&console.log(n.description+`
|
|
338
|
+
`),console.log(w.dim("tipo: ")+n.type),console.log(w.dim("deps npm: ")+((n.dependencies??[]).join(", ")||"\u2014")),console.log(w.dim("deps registry: ")+((n.registryDependencies??[]).join(", ")||"\u2014")),console.log(w.dim("archivos: ")+n.files.map(i=>re.posix.basename(i.path)).join(", ")),console.log(w.dim("instalar: ")+`create-lexy add ${n.name}`);for(let i of n.files)typeof i.content=="string"&&(_(re.posix.basename(i.path)),console.log(i.content))};var Ft=ke.dirname(It(import.meta.url)),Tt=JSON.parse(Et(ke.join(Ft,"../package.json"),"utf-8")),T=new Lt,N=e=>async()=>{try{await e()}catch(t){console.error(kt.red(`
|
|
339
|
+
Error: `)+t.message),process.exit(1)}};T.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(Tt.version);T.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)=>N(()=>je(e,t))());T.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=>N(()=>Ie(e))());T.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)=>N(()=>ge(e,t))());T.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)=>N(()=>Le(e,t))());T.command("diff").description("Copia local vs versi\xF3n vigente del registry (exit 1 si hay diferencias)").argument("<component>","Nombre en el registry").action(e=>N(()=>Pe(e))());T.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=>N(async()=>{process.exitCode=await $e(e)})());T.parse(process.argv);
|