@leanmcp/cli 0.2.10 → 0.2.11
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 +164 -8
- package/package.json +4 -1
package/dist/index.js
CHANGED
|
@@ -59,14 +59,33 @@ function parseUIAppDecorators(content, filePath) {
|
|
|
59
59
|
while ((match = uiAppRegex.exec(content)) !== null) {
|
|
60
60
|
const decoratorBody = match[1];
|
|
61
61
|
const methodName = match[2];
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
62
|
+
let componentPath;
|
|
63
|
+
let componentName;
|
|
64
|
+
const stringMatch = decoratorBody.match(/component\s*:\s*['"]([^'"]+)['"]/);
|
|
65
|
+
if (stringMatch) {
|
|
66
|
+
const relativePath = stringMatch[1];
|
|
67
|
+
const dir = path.dirname(filePath);
|
|
68
|
+
let resolvedPath = path.resolve(dir, relativePath);
|
|
69
|
+
if (!resolvedPath.endsWith(".tsx") && !resolvedPath.endsWith(".ts")) {
|
|
70
|
+
if (fs.existsSync(resolvedPath + ".tsx")) {
|
|
71
|
+
resolvedPath += ".tsx";
|
|
72
|
+
} else if (fs.existsSync(resolvedPath + ".ts")) {
|
|
73
|
+
resolvedPath += ".ts";
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
componentPath = resolvedPath;
|
|
77
|
+
componentName = path.basename(relativePath).replace(/\.(tsx?|jsx?)$/, "");
|
|
78
|
+
} else {
|
|
79
|
+
const identifierMatch = decoratorBody.match(/component\s*:\s*(\w+)/);
|
|
80
|
+
if (!identifierMatch) continue;
|
|
81
|
+
componentName = identifierMatch[1];
|
|
82
|
+
componentPath = importMap[componentName];
|
|
83
|
+
if (!componentPath) {
|
|
84
|
+
console.warn(`[scanUIApp] Could not resolve import for component: ${componentName}`);
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
69
87
|
}
|
|
88
|
+
if (!componentPath) continue;
|
|
70
89
|
const servicePrefix = serviceName.replace(/Service$/i, "").toLowerCase();
|
|
71
90
|
const resourceUri = `ui://${servicePrefix}/${methodName}`;
|
|
72
91
|
results.push({
|
|
@@ -134,11 +153,137 @@ async function buildUIComponent(uiApp, projectDir, isDev = false) {
|
|
|
134
153
|
<script type="module" src="./entry.tsx"></script>
|
|
135
154
|
</body>
|
|
136
155
|
</html>`);
|
|
156
|
+
const tailwindConfig = path2.join(tempDir, "tailwind.config.js");
|
|
157
|
+
await fs2.writeFile(tailwindConfig, `
|
|
158
|
+
/** @type {import('tailwindcss').Config} */
|
|
159
|
+
module.exports = {
|
|
160
|
+
content: [
|
|
161
|
+
'${path2.join(projectDir, "**/*.{ts,tsx,js,jsx}").replace(/\\/g, "/")}',
|
|
162
|
+
'${path2.join(projectDir, "mcp/**/*.{ts,tsx,js,jsx}").replace(/\\/g, "/")}',
|
|
163
|
+
'${path2.join(projectDir, "node_modules/@leanmcp/ui/**/*.{js,mjs}").replace(/\\/g, "/")}',
|
|
164
|
+
'${path2.join(projectDir, "../../packages/ui/src/**/*.{ts,tsx}").replace(/\\/g, "/")}',
|
|
165
|
+
],
|
|
166
|
+
darkMode: ['class'],
|
|
167
|
+
theme: {
|
|
168
|
+
container: {
|
|
169
|
+
center: true,
|
|
170
|
+
padding: '2rem',
|
|
171
|
+
screens: {
|
|
172
|
+
'2xl': '1400px',
|
|
173
|
+
},
|
|
174
|
+
},
|
|
175
|
+
extend: {
|
|
176
|
+
colors: {
|
|
177
|
+
border: 'hsl(var(--border))',
|
|
178
|
+
input: 'hsl(var(--input))',
|
|
179
|
+
ring: 'hsl(var(--ring))',
|
|
180
|
+
background: 'hsl(var(--background))',
|
|
181
|
+
foreground: 'hsl(var(--foreground))',
|
|
182
|
+
primary: {
|
|
183
|
+
DEFAULT: 'hsl(var(--primary))',
|
|
184
|
+
foreground: 'hsl(var(--primary-foreground))',
|
|
185
|
+
},
|
|
186
|
+
secondary: {
|
|
187
|
+
DEFAULT: 'hsl(var(--secondary))',
|
|
188
|
+
foreground: 'hsl(var(--secondary-foreground))',
|
|
189
|
+
},
|
|
190
|
+
destructive: {
|
|
191
|
+
DEFAULT: 'hsl(var(--destructive))',
|
|
192
|
+
foreground: 'hsl(var(--destructive-foreground))',
|
|
193
|
+
},
|
|
194
|
+
muted: {
|
|
195
|
+
DEFAULT: 'hsl(var(--muted))',
|
|
196
|
+
foreground: 'hsl(var(--muted-foreground))',
|
|
197
|
+
},
|
|
198
|
+
accent: {
|
|
199
|
+
DEFAULT: 'hsl(var(--accent))',
|
|
200
|
+
foreground: 'hsl(var(--accent-foreground))',
|
|
201
|
+
},
|
|
202
|
+
popover: {
|
|
203
|
+
DEFAULT: 'hsl(var(--popover))',
|
|
204
|
+
foreground: 'hsl(var(--popover-foreground))',
|
|
205
|
+
},
|
|
206
|
+
card: {
|
|
207
|
+
DEFAULT: 'hsl(var(--card))',
|
|
208
|
+
foreground: 'hsl(var(--card-foreground))',
|
|
209
|
+
},
|
|
210
|
+
},
|
|
211
|
+
borderRadius: {
|
|
212
|
+
lg: 'var(--radius)',
|
|
213
|
+
md: 'calc(var(--radius) - 2px)',
|
|
214
|
+
sm: 'calc(var(--radius) - 4px)',
|
|
215
|
+
},
|
|
216
|
+
},
|
|
217
|
+
},
|
|
218
|
+
plugins: [],
|
|
219
|
+
}
|
|
220
|
+
`);
|
|
221
|
+
const stylesCss = path2.join(tempDir, "styles.css");
|
|
222
|
+
await fs2.writeFile(stylesCss, `
|
|
223
|
+
@tailwind base;
|
|
224
|
+
@tailwind components;
|
|
225
|
+
@tailwind utilities;
|
|
226
|
+
|
|
227
|
+
@layer base {
|
|
228
|
+
:root {
|
|
229
|
+
--background: 0 0% 100%;
|
|
230
|
+
--foreground: 222.2 84% 4.9%;
|
|
231
|
+
--card: 0 0% 100%;
|
|
232
|
+
--card-foreground: 222.2 84% 4.9%;
|
|
233
|
+
--popover: 0 0% 100%;
|
|
234
|
+
--popover-foreground: 222.2 84% 4.9%;
|
|
235
|
+
--primary: 222.2 47.4% 11.2%;
|
|
236
|
+
--primary-foreground: 210 40% 98%;
|
|
237
|
+
--secondary: 210 40% 96.1%;
|
|
238
|
+
--secondary-foreground: 222.2 47.4% 11.2%;
|
|
239
|
+
--muted: 210 40% 96.1%;
|
|
240
|
+
--muted-foreground: 215.4 16.3% 46.9%;
|
|
241
|
+
--accent: 210 40% 96.1%;
|
|
242
|
+
--accent-foreground: 222.2 47.4% 11.2%;
|
|
243
|
+
--destructive: 0 84.2% 60.2%;
|
|
244
|
+
--destructive-foreground: 210 40% 98%;
|
|
245
|
+
--border: 214.3 31.8% 91.4%;
|
|
246
|
+
--input: 214.3 31.8% 91.4%;
|
|
247
|
+
--ring: 222.2 84% 4.9%;
|
|
248
|
+
--radius: 0.5rem;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
.dark {
|
|
252
|
+
--background: 222.2 84% 4.9%;
|
|
253
|
+
--foreground: 210 40% 98%;
|
|
254
|
+
--card: 222.2 84% 4.9%;
|
|
255
|
+
--card-foreground: 210 40% 98%;
|
|
256
|
+
--popover: 222.2 84% 4.9%;
|
|
257
|
+
--popover-foreground: 210 40% 98%;
|
|
258
|
+
--primary: 210 40% 98%;
|
|
259
|
+
--primary-foreground: 222.2 47.4% 11.2%;
|
|
260
|
+
--secondary: 217.2 32.6% 17.5%;
|
|
261
|
+
--secondary-foreground: 210 40% 98%;
|
|
262
|
+
--muted: 217.2 32.6% 17.5%;
|
|
263
|
+
--muted-foreground: 215 20.2% 65.1%;
|
|
264
|
+
--accent: 217.2 32.6% 17.5%;
|
|
265
|
+
--accent-foreground: 210 40% 98%;
|
|
266
|
+
--destructive: 0 62.8% 30.6%;
|
|
267
|
+
--destructive-foreground: 210 40% 98%;
|
|
268
|
+
--border: 217.2 32.6% 17.5%;
|
|
269
|
+
--input: 217.2 32.6% 17.5%;
|
|
270
|
+
--ring: 212.7 26.8% 83.9%;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
body {
|
|
274
|
+
font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
275
|
+
background-color: hsl(var(--background));
|
|
276
|
+
color: hsl(var(--foreground));
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
`);
|
|
137
280
|
const relativeComponentPath = path2.relative(tempDir, componentPath).replace(/\\/g, "/");
|
|
138
281
|
await fs2.writeFile(entryJs, `
|
|
139
282
|
import React, { StrictMode } from 'react';
|
|
140
283
|
import { createRoot } from 'react-dom/client';
|
|
141
|
-
import { AppProvider } from '@leanmcp/ui';
|
|
284
|
+
import { AppProvider, Toaster } from '@leanmcp/ui';
|
|
285
|
+
import '@leanmcp/ui/styles.css';
|
|
286
|
+
import './styles.css';
|
|
142
287
|
import { ${componentName} } from '${relativeComponentPath.replace(/\.tsx?$/, "")}';
|
|
143
288
|
|
|
144
289
|
const APP_INFO = {
|
|
@@ -150,6 +295,7 @@ function App() {
|
|
|
150
295
|
return (
|
|
151
296
|
<AppProvider appInfo={APP_INFO}>
|
|
152
297
|
<${componentName} />
|
|
298
|
+
<Toaster />
|
|
153
299
|
</AppProvider>
|
|
154
300
|
);
|
|
155
301
|
}
|
|
@@ -167,6 +313,16 @@ createRoot(document.getElementById('root')!).render(
|
|
|
167
313
|
react(),
|
|
168
314
|
viteSingleFile()
|
|
169
315
|
],
|
|
316
|
+
css: {
|
|
317
|
+
postcss: {
|
|
318
|
+
plugins: [
|
|
319
|
+
(await import("tailwindcss")).default({
|
|
320
|
+
config: tailwindConfig
|
|
321
|
+
}),
|
|
322
|
+
(await import("autoprefixer")).default
|
|
323
|
+
]
|
|
324
|
+
}
|
|
325
|
+
},
|
|
170
326
|
build: {
|
|
171
327
|
outDir,
|
|
172
328
|
emptyOutDir: false,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leanmcp/cli",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.11",
|
|
4
4
|
"description": "Command-line interface for scaffolding LeanMCP projects",
|
|
5
5
|
"bin": {
|
|
6
6
|
"leanmcp": "bin/leanmcp.js"
|
|
@@ -29,12 +29,15 @@
|
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@inquirer/prompts": "^7.0.1",
|
|
31
31
|
"@vitejs/plugin-react": "^4.3.0",
|
|
32
|
+
"autoprefixer": "^10.4.16",
|
|
32
33
|
"chalk": "^5.3.0",
|
|
33
34
|
"chokidar": "^4.0.0",
|
|
34
35
|
"commander": "^12.0.0",
|
|
35
36
|
"fs-extra": "^11.2.0",
|
|
36
37
|
"glob": "^11.0.0",
|
|
37
38
|
"ora": "^8.1.0",
|
|
39
|
+
"postcss": "^8.4.32",
|
|
40
|
+
"tailwindcss": "^3.4.0",
|
|
38
41
|
"vite": "^5.4.0",
|
|
39
42
|
"vite-plugin-singlefile": "^2.3.0"
|
|
40
43
|
},
|