@promptui-lib/cli 0.1.0 → 0.1.2
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/README.md +416 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -1
- package/package.json +5 -5
package/README.md
ADDED
|
@@ -0,0 +1,416 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="./logo.png" alt="PromptUI Logo" width="200" />
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<h1 align="center">PromptUI</h1>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
<a href="https://www.npmjs.com/package/@promptui-lib/cli"><img src="https://img.shields.io/npm/v/@promptui-lib/cli.svg" alt="npm version" /></a>
|
|
9
|
+
<a href="https://www.npmjs.com/package/@promptui-lib/cli"><img src="https://img.shields.io/npm/dm/@promptui-lib/cli.svg" alt="npm downloads" /></a>
|
|
10
|
+
<img src="https://img.shields.io/badge/license-proprietary-red.svg" alt="license" />
|
|
11
|
+
</p>
|
|
12
|
+
|
|
13
|
+
<p align="center">
|
|
14
|
+
<strong>Transform Figma designs into production-ready code in seconds.</strong>
|
|
15
|
+
</p>
|
|
16
|
+
|
|
17
|
+
<p align="center">
|
|
18
|
+
100% deterministic. No AI. Same input = same output, always.
|
|
19
|
+
</p>
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## What is it?
|
|
24
|
+
|
|
25
|
+
**PromptUI** is a library that automatically converts your Figma designs into clean, production-ready code.
|
|
26
|
+
|
|
27
|
+
Supports multiple frameworks:
|
|
28
|
+
- **React + SCSS** (BEM methodology)
|
|
29
|
+
- **Material UI** (MUI)
|
|
30
|
+
- **Tailwind CSS**
|
|
31
|
+
- **Bootstrap**
|
|
32
|
+
- **Flutter** (Dart StatelessWidgets)
|
|
33
|
+
- **SwiftUI** (iOS/macOS Views)
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Installation
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
npm install -g @promptui-lib/cli
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## How It Works
|
|
46
|
+
|
|
47
|
+
### 1. Mark your components in Figma
|
|
48
|
+
|
|
49
|
+
In Figma, add `#` at the beginning of frame names you want to export:
|
|
50
|
+
|
|
51
|
+
```
|
|
52
|
+
#Button → Will be exported as component
|
|
53
|
+
#CardProduct → Will be exported as component
|
|
54
|
+
#HeaderNav → Will be exported as component
|
|
55
|
+
Button → Ignored (no #)
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### 2. Configure the project
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
npx @promptui-lib/cli init
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Set your credentials:
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
export FIGMA_TOKEN=your_token_here
|
|
68
|
+
export FIGMA_FILE_ID=file_id_here
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### 3. Generate components
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
# React + SCSS
|
|
75
|
+
npx @promptui-lib/cli generate
|
|
76
|
+
|
|
77
|
+
# Bootstrap
|
|
78
|
+
npx @promptui-lib/cli generate bootstrap
|
|
79
|
+
|
|
80
|
+
# Material UI
|
|
81
|
+
npx @promptui-lib/cli generate mui
|
|
82
|
+
|
|
83
|
+
# Tailwind CSS
|
|
84
|
+
npx @promptui-lib/cli generate tailwind
|
|
85
|
+
|
|
86
|
+
# Flutter
|
|
87
|
+
npx @promptui-lib/cli generate flutter
|
|
88
|
+
|
|
89
|
+
# SwiftUI
|
|
90
|
+
npx @promptui-lib/cli generate swiftui
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
---
|
|
94
|
+
|
|
95
|
+
## Examples
|
|
96
|
+
|
|
97
|
+
### Example 1: Button with React + SCSS
|
|
98
|
+
|
|
99
|
+
**In Figma:** Frame named `#Button`
|
|
100
|
+
|
|
101
|
+
```
|
|
102
|
+
#Button (Frame)
|
|
103
|
+
├── Padding: 12px 24px
|
|
104
|
+
├── Background: #3B82F6
|
|
105
|
+
├── Border Radius: 8px
|
|
106
|
+
└── label (Text: "Click me")
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
**Command:**
|
|
110
|
+
```bash
|
|
111
|
+
npx @promptui-lib/cli generate
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
**Result:**
|
|
115
|
+
|
|
116
|
+
```tsx
|
|
117
|
+
// src/components/atoms/Button/button.tsx
|
|
118
|
+
import type { ReactNode } from 'react';
|
|
119
|
+
import './button.scss';
|
|
120
|
+
|
|
121
|
+
export interface IButtonProps {
|
|
122
|
+
children?: ReactNode;
|
|
123
|
+
className?: string;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export const Button = ({ children, className = '' }: IButtonProps) => {
|
|
127
|
+
return (
|
|
128
|
+
<button className={`button ${className}`.trim()}>
|
|
129
|
+
<span className="button__label">{children}</span>
|
|
130
|
+
</button>
|
|
131
|
+
);
|
|
132
|
+
};
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
```scss
|
|
136
|
+
// src/components/atoms/Button/button.scss
|
|
137
|
+
.button {
|
|
138
|
+
display: flex;
|
|
139
|
+
align-items: center;
|
|
140
|
+
justify-content: center;
|
|
141
|
+
padding: $spacing-sm $spacing-lg;
|
|
142
|
+
background-color: $color-primary;
|
|
143
|
+
border-radius: $radius-medium;
|
|
144
|
+
|
|
145
|
+
&__label {
|
|
146
|
+
color: $color-text-inverse;
|
|
147
|
+
font-weight: $font-weight-medium;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
---
|
|
153
|
+
|
|
154
|
+
### Example 2: Card with Bootstrap
|
|
155
|
+
|
|
156
|
+
**In Figma:** Frame named `#CardProduct`
|
|
157
|
+
|
|
158
|
+
```
|
|
159
|
+
#CardProduct (Frame)
|
|
160
|
+
├── image (Rectangle)
|
|
161
|
+
├── content (Frame)
|
|
162
|
+
│ ├── title (Text: "Product Name")
|
|
163
|
+
│ ├── description (Text: "Lorem ipsum...")
|
|
164
|
+
│ └── price (Text: "$99.00")
|
|
165
|
+
└── button (Instance of #Button)
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
**Command:**
|
|
169
|
+
```bash
|
|
170
|
+
npx @promptui-lib/cli generate bootstrap
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
**Result:**
|
|
174
|
+
|
|
175
|
+
```tsx
|
|
176
|
+
// src/components/molecules/CardProduct/card-product.tsx
|
|
177
|
+
import type { ReactNode } from 'react';
|
|
178
|
+
|
|
179
|
+
export interface ICardProductProps {
|
|
180
|
+
children?: ReactNode;
|
|
181
|
+
className?: string;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
export const CardProduct = ({ children, className = '' }: ICardProductProps) => {
|
|
185
|
+
return (
|
|
186
|
+
<div className={`card ${className}`.trim()}>
|
|
187
|
+
<img className="card-img-top" alt="Product" />
|
|
188
|
+
<div className="card-body">
|
|
189
|
+
<h5 className="card-title fw-bold">Product Name</h5>
|
|
190
|
+
<p className="card-text text-muted">Lorem ipsum...</p>
|
|
191
|
+
<p className="h4 text-primary fw-bold">$99.00</p>
|
|
192
|
+
<button className="btn btn-primary w-100">Buy Now</button>
|
|
193
|
+
</div>
|
|
194
|
+
</div>
|
|
195
|
+
);
|
|
196
|
+
};
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
---
|
|
200
|
+
|
|
201
|
+
### Example 3: Header with Tailwind CSS
|
|
202
|
+
|
|
203
|
+
**In Figma:** Frame named `#HeaderNav`
|
|
204
|
+
|
|
205
|
+
**Command:**
|
|
206
|
+
```bash
|
|
207
|
+
npx @promptui-lib/cli generate tailwind
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
**Result:**
|
|
211
|
+
|
|
212
|
+
```tsx
|
|
213
|
+
// src/components/organisms/HeaderNav/header-nav.tsx
|
|
214
|
+
export const HeaderNav = ({ className = '' }: IHeaderNavProps) => {
|
|
215
|
+
return (
|
|
216
|
+
<header className={`flex items-center justify-between px-6 py-4 bg-white shadow-sm ${className}`.trim()}>
|
|
217
|
+
<div className="flex items-center gap-2">
|
|
218
|
+
<img src="/logo.svg" className="h-8 w-8" alt="Logo" />
|
|
219
|
+
<span className="text-xl font-bold text-gray-900">Brand</span>
|
|
220
|
+
</div>
|
|
221
|
+
<nav className="flex items-center gap-8">
|
|
222
|
+
<a className="text-gray-600 hover:text-gray-900">Home</a>
|
|
223
|
+
<a className="text-gray-600 hover:text-gray-900">Products</a>
|
|
224
|
+
<a className="text-gray-600 hover:text-gray-900">About</a>
|
|
225
|
+
</nav>
|
|
226
|
+
<button className="px-4 py-2 bg-blue-500 text-white rounded-lg">
|
|
227
|
+
Sign In
|
|
228
|
+
</button>
|
|
229
|
+
</header>
|
|
230
|
+
);
|
|
231
|
+
};
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
---
|
|
235
|
+
|
|
236
|
+
### Example 4: Button with Flutter
|
|
237
|
+
|
|
238
|
+
**In Figma:** Frame named `#Button`
|
|
239
|
+
|
|
240
|
+
**Command:**
|
|
241
|
+
```bash
|
|
242
|
+
npx @promptui-lib/cli generate flutter
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
**Result:**
|
|
246
|
+
|
|
247
|
+
```dart
|
|
248
|
+
/// Button
|
|
249
|
+
/// Generated by PromptUI (Flutter)
|
|
250
|
+
|
|
251
|
+
import 'package:flutter/material.dart';
|
|
252
|
+
|
|
253
|
+
class Button extends StatelessWidget {
|
|
254
|
+
const Button({super.key});
|
|
255
|
+
|
|
256
|
+
@override
|
|
257
|
+
Widget build(BuildContext context) {
|
|
258
|
+
return Container(
|
|
259
|
+
padding: EdgeInsets.symmetric(vertical: 8, horizontal: 24),
|
|
260
|
+
decoration: BoxDecoration(
|
|
261
|
+
color: Theme.of(context).primaryColor,
|
|
262
|
+
borderRadius: BorderRadius.circular(8),
|
|
263
|
+
),
|
|
264
|
+
child: Text('Click me'),
|
|
265
|
+
);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
---
|
|
271
|
+
|
|
272
|
+
### Example 5: Button with SwiftUI
|
|
273
|
+
|
|
274
|
+
**In Figma:** Frame named `#Button`
|
|
275
|
+
|
|
276
|
+
**Command:**
|
|
277
|
+
```bash
|
|
278
|
+
npx @promptui-lib/cli generate swiftui
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
**Result:**
|
|
282
|
+
|
|
283
|
+
```swift
|
|
284
|
+
/// Button
|
|
285
|
+
/// Generated by PromptUI (SwiftUI)
|
|
286
|
+
|
|
287
|
+
import SwiftUI
|
|
288
|
+
|
|
289
|
+
struct Button: View {
|
|
290
|
+
var body: some View {
|
|
291
|
+
Text("Click me")
|
|
292
|
+
.padding(.horizontal, 24)
|
|
293
|
+
.padding(.vertical, 8)
|
|
294
|
+
.background(.blue)
|
|
295
|
+
.foregroundColor(.white)
|
|
296
|
+
.cornerRadius(8)
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
#Preview {
|
|
301
|
+
Button()
|
|
302
|
+
}
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
---
|
|
306
|
+
|
|
307
|
+
## Commands
|
|
308
|
+
|
|
309
|
+
| Command | Description |
|
|
310
|
+
|---------|-------------|
|
|
311
|
+
| `npx @promptui-lib/cli init` | Configure the project |
|
|
312
|
+
| `npx @promptui-lib/cli generate` | Generate components (React + SCSS) |
|
|
313
|
+
| `npx @promptui-lib/cli generate bootstrap` | Generate with Bootstrap |
|
|
314
|
+
| `npx @promptui-lib/cli generate mui` | Generate with Material UI |
|
|
315
|
+
| `npx @promptui-lib/cli generate tailwind` | Generate with Tailwind CSS |
|
|
316
|
+
| `npx @promptui-lib/cli generate flutter` | Generate with Flutter/Dart |
|
|
317
|
+
| `npx @promptui-lib/cli generate swiftui` | Generate with SwiftUI |
|
|
318
|
+
| `npx @promptui-lib/cli sync tokens` | Sync design tokens |
|
|
319
|
+
|
|
320
|
+
## Options
|
|
321
|
+
|
|
322
|
+
| Option | Description |
|
|
323
|
+
|--------|-------------|
|
|
324
|
+
| `-p, --preview` | Preview without saving |
|
|
325
|
+
| `-o, --output <dir>` | Output directory |
|
|
326
|
+
| `-f, --force` | Overwrite existing files |
|
|
327
|
+
|
|
328
|
+
---
|
|
329
|
+
|
|
330
|
+
## Atomic Design
|
|
331
|
+
|
|
332
|
+
Components are automatically organized:
|
|
333
|
+
|
|
334
|
+
| Layer | Description | Examples |
|
|
335
|
+
|-------|-------------|----------|
|
|
336
|
+
| **atoms** | Simple components | Button, Input, Label, Icon |
|
|
337
|
+
| **molecules** | Medium compositions | Card, SearchBar, FormField |
|
|
338
|
+
| **organisms** | Complex compositions | Header, Footer, Sidebar |
|
|
339
|
+
|
|
340
|
+
---
|
|
341
|
+
|
|
342
|
+
## Configuration
|
|
343
|
+
|
|
344
|
+
Create `promptui.config.json`:
|
|
345
|
+
|
|
346
|
+
```json
|
|
347
|
+
{
|
|
348
|
+
"figma": {
|
|
349
|
+
"fileId": "your-file-id"
|
|
350
|
+
},
|
|
351
|
+
"output": {
|
|
352
|
+
"basePath": "src/components"
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
---
|
|
358
|
+
|
|
359
|
+
## For Designers
|
|
360
|
+
|
|
361
|
+
### Figma Rules
|
|
362
|
+
|
|
363
|
+
1. **`#` prefix** - Add to frame name to export
|
|
364
|
+
2. **Auto Layout** - Always use to maintain structure
|
|
365
|
+
3. **Descriptive names** - `title`, `content`, not "Frame 1"
|
|
366
|
+
4. **PascalCase** - `#ButtonPrimary`, not `#button-primary`
|
|
367
|
+
|
|
368
|
+
### Correct structure example
|
|
369
|
+
|
|
370
|
+
```
|
|
371
|
+
#CardProduct (Frame, Auto Layout Vertical)
|
|
372
|
+
├── image (Rectangle, Aspect Ratio 16:9)
|
|
373
|
+
├── content (Frame, Auto Layout Vertical, Padding 16px)
|
|
374
|
+
│ ├── title (Text, Heading/H3)
|
|
375
|
+
│ ├── description (Text, Body/Small)
|
|
376
|
+
│ └── price (Text, Heading/H2)
|
|
377
|
+
└── actions (Frame, Auto Layout Horizontal)
|
|
378
|
+
└── button (Instance of #Button)
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
---
|
|
382
|
+
|
|
383
|
+
## Environment Variables
|
|
384
|
+
|
|
385
|
+
| Variable | Description |
|
|
386
|
+
|----------|-------------|
|
|
387
|
+
| `FIGMA_TOKEN` | Figma access token |
|
|
388
|
+
| `FIGMA_FILE_ID` | Figma file ID |
|
|
389
|
+
|
|
390
|
+
### How to get Figma Token
|
|
391
|
+
|
|
392
|
+
1. Go to [Figma Account Settings](https://www.figma.com/settings)
|
|
393
|
+
2. Navigate to "Personal Access Tokens"
|
|
394
|
+
3. Create a new token
|
|
395
|
+
|
|
396
|
+
### How to get File ID
|
|
397
|
+
|
|
398
|
+
The File ID is in your Figma file URL:
|
|
399
|
+
|
|
400
|
+
```
|
|
401
|
+
https://www.figma.com/file/ABC123xyz/MyProject
|
|
402
|
+
^^^^^^^^^^^
|
|
403
|
+
This is the File ID
|
|
404
|
+
```
|
|
405
|
+
|
|
406
|
+
---
|
|
407
|
+
|
|
408
|
+
## Author
|
|
409
|
+
|
|
410
|
+
**Desiree Menezes** - [@desireemenezes](https://github.com/desireemenezes)
|
|
411
|
+
|
|
412
|
+
---
|
|
413
|
+
|
|
414
|
+
## License
|
|
415
|
+
|
|
416
|
+
Proprietary - All rights reserved.
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAsEH,wBAAsB,GAAG,CAAC,IAAI,GAAE,MAAM,EAA0B,GAAG,OAAO,CAAC,IAAI,CAAC,CAkH/E"}
|
package/dist/index.js
CHANGED
|
@@ -21,6 +21,8 @@ Commands:
|
|
|
21
21
|
generate mui Generate all #marked components (Material UI)
|
|
22
22
|
generate tailwind Generate all #marked components (Tailwind CSS)
|
|
23
23
|
generate bootstrap Generate all #marked components (Bootstrap)
|
|
24
|
+
generate flutter Generate all #marked components (Flutter/Dart)
|
|
25
|
+
generate swiftui Generate all #marked components (SwiftUI)
|
|
24
26
|
generate <nodeId> Generate specific node by ID
|
|
25
27
|
generate <file.json> Generate from local JSON file
|
|
26
28
|
sync tokens Sync design tokens from Figma
|
|
@@ -41,6 +43,8 @@ Frameworks:
|
|
|
41
43
|
mui Material UI with sx props and MUI components
|
|
42
44
|
tailwind Tailwind CSS utility classes
|
|
43
45
|
bootstrap Bootstrap CSS classes
|
|
46
|
+
flutter Flutter/Dart StatelessWidget components
|
|
47
|
+
swiftui SwiftUI View structs for iOS/macOS
|
|
44
48
|
|
|
45
49
|
Examples:
|
|
46
50
|
promptui init # Create promptui.config.json
|
|
@@ -49,6 +53,8 @@ Examples:
|
|
|
49
53
|
promptui generate mui # Generate all (Material UI)
|
|
50
54
|
promptui generate tailwind # Generate all (Tailwind CSS)
|
|
51
55
|
promptui generate bootstrap # Generate all (Bootstrap)
|
|
56
|
+
promptui generate flutter # Generate all (Flutter)
|
|
57
|
+
promptui generate swiftui # Generate all (SwiftUI)
|
|
52
58
|
promptui generate 123:456 # Generate specific node
|
|
53
59
|
promptui generate ./button.json # Generate from local JSON
|
|
54
60
|
promptui generate ./button.json -p # Preview without writing
|
|
@@ -99,7 +105,7 @@ export async function run(args = process.argv.slice(2)) {
|
|
|
99
105
|
// promptui generate [framework|nodeId|file.json]
|
|
100
106
|
case 'generate': {
|
|
101
107
|
const input = positionals[1];
|
|
102
|
-
const FRAMEWORKS = ['react', 'mui', 'tailwind', 'bootstrap'];
|
|
108
|
+
const FRAMEWORKS = ['react', 'mui', 'tailwind', 'bootstrap', 'flutter', 'swiftui'];
|
|
103
109
|
// Detecta se o input é um framework
|
|
104
110
|
const isFramework = input && FRAMEWORKS.includes(input);
|
|
105
111
|
// Se não tem input ou é um framework, gera todos os componentes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promptui-lib/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "CLI for PromptUI - Figma to React code generator",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -45,10 +45,10 @@
|
|
|
45
45
|
"bin"
|
|
46
46
|
],
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@promptui-lib/core": "0.1.
|
|
49
|
-
"@promptui-lib/figma-parser": "0.1.
|
|
50
|
-
"@promptui-lib/codegen": "0.1.
|
|
51
|
-
"@promptui-lib/mcp-agent": "0.1.
|
|
48
|
+
"@promptui-lib/core": "0.1.2",
|
|
49
|
+
"@promptui-lib/figma-parser": "0.1.2",
|
|
50
|
+
"@promptui-lib/codegen": "0.1.2",
|
|
51
|
+
"@promptui-lib/mcp-agent": "0.1.2"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@types/node": "^20.0.0",
|