create-template-html-css 2.0.3 → 2.1.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/CHANGELOG.md +305 -0
- package/HTML-VS-REACT.md +289 -0
- package/QUICKSTART-REACT.md +293 -0
- package/REACT-SUPPORT-SUMMARY.md +235 -0
- package/README.md +193 -12
- package/bin/cli.js +98 -759
- package/bin/commands/create.js +272 -0
- package/bin/commands/gallery.js +42 -0
- package/bin/commands/insert.js +123 -0
- package/bin/commands/list.js +73 -0
- package/package.json +10 -3
- package/src/component-choices.js +7 -0
- package/src/components-registry.js +112 -0
- package/src/format-utils.js +49 -0
- package/src/generator.js +83 -594
- package/src/generators/color-schemes.js +78 -0
- package/src/generators/color-utils.js +108 -0
- package/src/generators/component-filters.js +151 -0
- package/src/generators/html-generators.js +180 -0
- package/src/generators/validation.js +43 -0
- package/src/index.js +2 -1
- package/src/inserter.js +55 -233
- package/src/inserters/backup-utils.js +20 -0
- package/src/inserters/component-loader.js +68 -0
- package/src/inserters/html-utils.js +31 -0
- package/src/inserters/indentation-utils.js +90 -0
- package/src/inserters/validation-utils.js +49 -0
- package/src/react-component-choices.js +45 -0
- package/src/react-file-operations.js +172 -0
- package/src/react-generator.js +208 -0
- package/src/react-templates.js +350 -0
- package/src/utils/file-utils.js +97 -0
- package/src/utils/path-utils.js +32 -0
- package/src/utils/string-utils.js +51 -0
- package/src/utils/template-loader.js +91 -0
- package/templates/_shared/PATTERNS.md +246 -0
- package/templates/_shared/README.md +74 -0
- package/templates/_shared/base.css +18 -0
- package/templates/blackjack/index.html +1 -1
- package/templates/blackjack/script.js +9 -9
- package/templates/breakout/index.html +1 -1
- package/templates/breakout/script.js +6 -6
- package/templates/connect-four/index.html +1 -1
- package/templates/connect-four/script.js +5 -5
- package/templates/dice-game/index.html +1 -1
- package/templates/dice-game/script.js +20 -20
- package/templates/flappy-bird/index.html +1 -1
- package/templates/flappy-bird/script.js +10 -10
- package/templates/pong/index.html +1 -1
- package/templates/pong/script.js +8 -8
- package/templates/skeleton/index.html +4 -4
- package/templates/slot-machine/index.html +1 -1
- package/templates/slot-machine/script.js +6 -6
- package/templates/tetris/index.html +1 -1
- package/templates/tetris/script.js +5 -5
- package/templates-react/README.md +126 -0
- package/templates-react/button/Button.css +88 -0
- package/templates-react/button/Button.example.jsx +40 -0
- package/templates-react/button/Button.jsx +29 -0
- package/templates-react/card/Card.css +86 -0
- package/templates-react/card/Card.example.jsx +49 -0
- package/templates-react/card/Card.jsx +35 -0
- package/templates-react/counter/Counter.css +99 -0
- package/templates-react/counter/Counter.example.jsx +45 -0
- package/templates-react/counter/Counter.jsx +70 -0
- package/templates-react/form/Form.css +128 -0
- package/templates-react/form/Form.example.jsx +65 -0
- package/templates-react/form/Form.jsx +125 -0
- package/templates-react/modal/Modal.css +152 -0
- package/templates-react/modal/Modal.example.jsx +90 -0
- package/templates-react/modal/Modal.jsx +46 -0
- package/templates-react/todo-list/TodoList.css +236 -0
- package/templates-react/todo-list/TodoList.example.jsx +15 -0
- package/templates-react/todo-list/TodoList.jsx +84 -0
package/bin/cli.js
CHANGED
|
@@ -1,759 +1,98 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
.
|
|
14
|
-
.
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
console.log("
|
|
22
|
-
console.log(
|
|
23
|
-
|
|
24
|
-
);
|
|
25
|
-
console.log(" $ create-template
|
|
26
|
-
console.log(
|
|
27
|
-
|
|
28
|
-
);
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
);
|
|
32
|
-
console.log(
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
)
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
)
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
)
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
)
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
)
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
)
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
)
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
);
|
|
82
|
-
console.log("
|
|
83
|
-
console.log("
|
|
84
|
-
console.log("");
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
.
|
|
89
|
-
.
|
|
90
|
-
.
|
|
91
|
-
.
|
|
92
|
-
.
|
|
93
|
-
.
|
|
94
|
-
.
|
|
95
|
-
.
|
|
96
|
-
.
|
|
97
|
-
.
|
|
98
|
-
|
|
99
|
-
.action(async (options) => {
|
|
100
|
-
try {
|
|
101
|
-
if (options.verbose) {
|
|
102
|
-
console.log(chalk.gray("[DEBUG] Options:"), options);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
// If flags are provided, use them directly
|
|
106
|
-
if (options.component && options.name) {
|
|
107
|
-
if (options.verbose) {
|
|
108
|
-
console.log(chalk.gray("[INFO] Using provided options..."));
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
const createOptions = {
|
|
112
|
-
component: options.component,
|
|
113
|
-
name: options.name,
|
|
114
|
-
includeJs: options.includeJs,
|
|
115
|
-
darkMode: options.darkMode,
|
|
116
|
-
colorScheme: options.colorScheme,
|
|
117
|
-
primaryColor: options.primaryColor,
|
|
118
|
-
secondaryColor: options.secondaryColor,
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
await generateTemplate(createOptions);
|
|
122
|
-
|
|
123
|
-
console.log("\n" + chalk.green("✓ Template created successfully!"));
|
|
124
|
-
console.log(chalk.gray(` Location: ./${options.name}/`));
|
|
125
|
-
console.log(chalk.gray(` Structure:`));
|
|
126
|
-
console.log(chalk.gray(` index.html`));
|
|
127
|
-
console.log(chalk.gray(` css/`));
|
|
128
|
-
console.log(chalk.gray(` └── style.css`));
|
|
129
|
-
if (options.includeJs) {
|
|
130
|
-
console.log(chalk.gray(` js/`));
|
|
131
|
-
console.log(chalk.gray(` └── script.js`));
|
|
132
|
-
}
|
|
133
|
-
console.log("");
|
|
134
|
-
return;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
// Otherwise, use interactive mode
|
|
138
|
-
console.log(chalk.cyan("\n✨ Creating a new template component...\n"));
|
|
139
|
-
|
|
140
|
-
const answers = await inquirer.prompt([
|
|
141
|
-
{
|
|
142
|
-
type: "list",
|
|
143
|
-
name: "component",
|
|
144
|
-
message: "What component would you like to create?",
|
|
145
|
-
choices: [
|
|
146
|
-
new inquirer.Separator(chalk.gray("─ Basic Components")),
|
|
147
|
-
{ name: "Button", value: "button" },
|
|
148
|
-
{ name: "Card", value: "card" },
|
|
149
|
-
{ name: "Form", value: "form" },
|
|
150
|
-
{ name: "Navigation", value: "navigation" },
|
|
151
|
-
{ name: "Modal", value: "modal" },
|
|
152
|
-
{ name: "Footer", value: "footer" },
|
|
153
|
-
{ name: "Hero Section", value: "hero" },
|
|
154
|
-
{ name: "Slider", value: "slider" },
|
|
155
|
-
{ name: "Table", value: "table" },
|
|
156
|
-
new inquirer.Separator(chalk.gray("─ Authentication Forms")),
|
|
157
|
-
{ name: "Login Form", value: "login" },
|
|
158
|
-
{ name: "Register Form", value: "register" },
|
|
159
|
-
new inquirer.Separator(chalk.gray("─ Loading Placeholders")),
|
|
160
|
-
{ name: "Skeleton (Loading Placeholders)", value: "skeleton" },
|
|
161
|
-
new inquirer.Separator(chalk.gray("─ Animation Templates")),
|
|
162
|
-
{ name: "Spinner (Loading Animations)", value: "spinner" },
|
|
163
|
-
{
|
|
164
|
-
name: "Animated Card (Interactive Cards)",
|
|
165
|
-
value: "animated-card",
|
|
166
|
-
},
|
|
167
|
-
{ name: "Typing Effect (Text Animations)", value: "typing-effect" },
|
|
168
|
-
{ name: "Fade Gallery (Image Gallery)", value: "fade-gallery" },
|
|
169
|
-
new inquirer.Separator(chalk.gray("─ Grid Layouts (CSS Grid)")),
|
|
170
|
-
{ name: "Grid Layout", value: "grid-layout" },
|
|
171
|
-
{ name: "Masonry Grid (Pinterest-style)", value: "masonry-grid" },
|
|
172
|
-
{ name: "Dashboard Grid (Admin Panel)", value: "dashboard-grid" },
|
|
173
|
-
new inquirer.Separator(chalk.gray("─ Flexbox Layouts")),
|
|
174
|
-
{ name: "Flex Layout (Flexbox Patterns)", value: "flex-layout" },
|
|
175
|
-
{ name: "Flex Cards (Equal-height cards)", value: "flex-cards" },
|
|
176
|
-
{ name: "Flex Dashboard (Flexbox Admin)", value: "flex-dashboard" },
|
|
177
|
-
new inquirer.Separator(chalk.gray("─ DOM Manipulation Examples")),
|
|
178
|
-
{ name: "Todo List (Add/Remove Items)", value: "todo-list" },
|
|
179
|
-
{ name: "Counter (Click Handlers)", value: "counter" },
|
|
180
|
-
{ name: "Accordion (Toggle Content)", value: "accordion" },
|
|
181
|
-
{ name: "Tabs (Switch Sections)", value: "tabs" },
|
|
182
|
-
new inquirer.Separator(chalk.gray("─ Interactive Games")),
|
|
183
|
-
{ name: "🎮 Tic-Tac-Toe", value: "tic-tac-toe" },
|
|
184
|
-
{ name: "🎮 Memory Game", value: "memory-game" },
|
|
185
|
-
{ name: "🎮 Snake Game", value: "snake-game" },
|
|
186
|
-
{ name: "🎮 Guess Number", value: "guess-number" },
|
|
187
|
-
{ name: "🎮 2048", value: "game-2048" },
|
|
188
|
-
{ name: "🎮 Whack-a-Mole", value: "whack-a-mole" },
|
|
189
|
-
{ name: "🎮 Simon Says", value: "simon-says" },
|
|
190
|
-
{ name: "🎮 Rock-Paper-Scissors", value: "rock-paper-scissors" },
|
|
191
|
-
{ name: "🎮 Breakout", value: "breakout" },
|
|
192
|
-
{ name: "🎮 Tetris", value: "tetris" },
|
|
193
|
-
{ name: "🎮 Flappy Bird", value: "flappy-bird" },
|
|
194
|
-
{ name: "🎮 Connect Four", value: "connect-four" },
|
|
195
|
-
{ name: "🎮 Blackjack", value: "blackjack" },
|
|
196
|
-
{ name: "🎮 Slot Machine", value: "slot-machine" },
|
|
197
|
-
{ name: "🎮 Dice Game", value: "dice-game" },
|
|
198
|
-
{ name: "🎮 Pong", value: "pong" },
|
|
199
|
-
],
|
|
200
|
-
},
|
|
201
|
-
{
|
|
202
|
-
type: "input",
|
|
203
|
-
name: "name",
|
|
204
|
-
message: "Enter a name for your component:",
|
|
205
|
-
default: (answers) => answers.component,
|
|
206
|
-
validate: (input) => {
|
|
207
|
-
if (!input || input.trim().length === 0) {
|
|
208
|
-
return "Please enter a valid name";
|
|
209
|
-
}
|
|
210
|
-
if (
|
|
211
|
-
input.includes("..") ||
|
|
212
|
-
input.includes("/") ||
|
|
213
|
-
input.includes("\\")
|
|
214
|
-
) {
|
|
215
|
-
return "Name cannot contain path separators or parent directory references";
|
|
216
|
-
}
|
|
217
|
-
if (input.length > 100) {
|
|
218
|
-
return "Name is too long (max 100 characters)";
|
|
219
|
-
}
|
|
220
|
-
return true;
|
|
221
|
-
},
|
|
222
|
-
},
|
|
223
|
-
{
|
|
224
|
-
type: "input",
|
|
225
|
-
name: "navItems",
|
|
226
|
-
message: "Enter navigation items (comma-separated):",
|
|
227
|
-
default: "Home, About, Services, Portfolio, Contact",
|
|
228
|
-
when: (answers) => answers.component === "navigation",
|
|
229
|
-
validate: (input) => {
|
|
230
|
-
if (!input || input.trim().length === 0) {
|
|
231
|
-
return "Please enter at least one navigation item";
|
|
232
|
-
}
|
|
233
|
-
return true;
|
|
234
|
-
},
|
|
235
|
-
},
|
|
236
|
-
{
|
|
237
|
-
type: "checkbox",
|
|
238
|
-
name: "formFields",
|
|
239
|
-
message: "Select form fields to include:",
|
|
240
|
-
choices: [
|
|
241
|
-
{ name: "Name", value: "name", checked: true },
|
|
242
|
-
{ name: "Email", value: "email", checked: true },
|
|
243
|
-
{ name: "Phone", value: "phone", checked: false },
|
|
244
|
-
{ name: "Subject", value: "subject", checked: false },
|
|
245
|
-
{ name: "Message", value: "message", checked: true },
|
|
246
|
-
{ name: "Terms Checkbox", value: "terms", checked: false },
|
|
247
|
-
],
|
|
248
|
-
when: (answers) => answers.component === "form",
|
|
249
|
-
validate: (input) => {
|
|
250
|
-
if (input.length === 0) {
|
|
251
|
-
return "Please select at least one form field";
|
|
252
|
-
}
|
|
253
|
-
return true;
|
|
254
|
-
},
|
|
255
|
-
},
|
|
256
|
-
{
|
|
257
|
-
type: "list",
|
|
258
|
-
name: "buttonVariations",
|
|
259
|
-
message: "Which button variations do you want?",
|
|
260
|
-
choices: [
|
|
261
|
-
{ name: "All Buttons (6 variations)", value: "all" },
|
|
262
|
-
{ name: "Select Specific Buttons", value: "select" },
|
|
263
|
-
],
|
|
264
|
-
when: (answers) => answers.component === "button",
|
|
265
|
-
},
|
|
266
|
-
{
|
|
267
|
-
type: "checkbox",
|
|
268
|
-
name: "selectedButtons",
|
|
269
|
-
message: "Select button variations:",
|
|
270
|
-
choices: [
|
|
271
|
-
{ name: "Primary Button", value: "primary", checked: true },
|
|
272
|
-
{ name: "Secondary Button", value: "secondary", checked: true },
|
|
273
|
-
{ name: "Success Button", value: "success", checked: true },
|
|
274
|
-
{ name: "Danger Button", value: "danger", checked: true },
|
|
275
|
-
{ name: "Outlined Button", value: "outlined", checked: true },
|
|
276
|
-
{ name: "Disabled Button", value: "disabled", checked: true },
|
|
277
|
-
],
|
|
278
|
-
when: (answers) => answers.component === "button" && answers.buttonVariations === "select",
|
|
279
|
-
validate: (input) => {
|
|
280
|
-
if (input.length === 0) {
|
|
281
|
-
return "Please select at least one button variation";
|
|
282
|
-
}
|
|
283
|
-
return true;
|
|
284
|
-
},
|
|
285
|
-
},
|
|
286
|
-
{
|
|
287
|
-
type: "list",
|
|
288
|
-
name: "cardVariations",
|
|
289
|
-
message: "Which card variations do you want?",
|
|
290
|
-
choices: [
|
|
291
|
-
{ name: "All Cards (6 variations)", value: "all" },
|
|
292
|
-
{ name: "Select Specific Cards", value: "select" },
|
|
293
|
-
],
|
|
294
|
-
when: (answers) => answers.component === "card",
|
|
295
|
-
},
|
|
296
|
-
{
|
|
297
|
-
type: "checkbox",
|
|
298
|
-
name: "selectedCards",
|
|
299
|
-
message: "Select card variations:",
|
|
300
|
-
choices: [
|
|
301
|
-
{ name: "Modern Card (Featured)", value: "modern", checked: true },
|
|
302
|
-
{ name: "Premium Card (Price)", value: "premium", checked: true },
|
|
303
|
-
{ name: "Blog Card (Tags)", value: "blog", checked: true },
|
|
304
|
-
{ name: "Minimal Card", value: "minimal", checked: true },
|
|
305
|
-
{ name: "User Profile Card", value: "user", checked: true },
|
|
306
|
-
{ name: "Interactive Card", value: "interactive", checked: true },
|
|
307
|
-
],
|
|
308
|
-
when: (answers) => answers.component === "card" && answers.cardVariations === "select",
|
|
309
|
-
validate: (input) => {
|
|
310
|
-
if (input.length === 0) {
|
|
311
|
-
return "Please select at least one card variation";
|
|
312
|
-
}
|
|
313
|
-
return true;
|
|
314
|
-
},
|
|
315
|
-
},
|
|
316
|
-
{
|
|
317
|
-
type: "list",
|
|
318
|
-
name: "spinnerVariations",
|
|
319
|
-
message: "Which spinner variations do you want?",
|
|
320
|
-
choices: [
|
|
321
|
-
{ name: "All Spinners (5 types)", value: "all" },
|
|
322
|
-
{ name: "Select Specific Spinners", value: "select" },
|
|
323
|
-
],
|
|
324
|
-
when: (answers) => answers.component === "spinner",
|
|
325
|
-
},
|
|
326
|
-
{
|
|
327
|
-
type: "checkbox",
|
|
328
|
-
name: "selectedSpinners",
|
|
329
|
-
message: "Select spinner types:",
|
|
330
|
-
choices: [
|
|
331
|
-
{ name: "Circle Spinner", value: "circle", checked: true },
|
|
332
|
-
{ name: "Bouncing Dots", value: "dots", checked: true },
|
|
333
|
-
{ name: "Pulse Loader", value: "pulse", checked: true },
|
|
334
|
-
{ name: "Bar Loader", value: "bars", checked: true },
|
|
335
|
-
{ name: "Gradient Ring", value: "gradient", checked: true },
|
|
336
|
-
],
|
|
337
|
-
when: (answers) => answers.component === "spinner" && answers.spinnerVariations === "select",
|
|
338
|
-
validate: (input) => {
|
|
339
|
-
if (input.length === 0) {
|
|
340
|
-
return "Please select at least one spinner type";
|
|
341
|
-
}
|
|
342
|
-
return true;
|
|
343
|
-
},
|
|
344
|
-
},
|
|
345
|
-
{
|
|
346
|
-
type: "input",
|
|
347
|
-
name: "customFormFields",
|
|
348
|
-
message: "Add custom fields (format: type:label, e.g., 'text:Age, url:Website'):",
|
|
349
|
-
when: (answers) => answers.component === "form",
|
|
350
|
-
default: "",
|
|
351
|
-
validate: (input) => {
|
|
352
|
-
if (!input || input.trim().length === 0) {
|
|
353
|
-
return true; // Optional field
|
|
354
|
-
}
|
|
355
|
-
// Basic validation for format
|
|
356
|
-
const fields = input.split(',');
|
|
357
|
-
for (const field of fields) {
|
|
358
|
-
const trimmed = field.trim();
|
|
359
|
-
if (trimmed && !trimmed.includes(':')) {
|
|
360
|
-
return "Invalid format. Use 'type:label' (e.g., 'text:Age, url:Website')";
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
return true;
|
|
364
|
-
},
|
|
365
|
-
},
|
|
366
|
-
{
|
|
367
|
-
type: "confirm",
|
|
368
|
-
name: "darkMode",
|
|
369
|
-
message: "Add dark mode support (prefers-color-scheme)?",
|
|
370
|
-
default: false,
|
|
371
|
-
},
|
|
372
|
-
{
|
|
373
|
-
type: "list",
|
|
374
|
-
name: "colorOption",
|
|
375
|
-
message: "How would you like to choose colors?",
|
|
376
|
-
choices: [
|
|
377
|
-
{ name: "Use a preset color scheme", value: "preset" },
|
|
378
|
-
{ name: "Enter custom hex colors", value: "custom" },
|
|
379
|
-
{ name: "Skip color customization", value: "skip" },
|
|
380
|
-
],
|
|
381
|
-
},
|
|
382
|
-
{
|
|
383
|
-
type: "list",
|
|
384
|
-
name: "colorScheme",
|
|
385
|
-
message: "Choose a color scheme:",
|
|
386
|
-
choices: Object.entries(COLOR_SCHEMES).map(([key, scheme]) => ({
|
|
387
|
-
name: `${scheme.name} - ${scheme.description}`,
|
|
388
|
-
value: key,
|
|
389
|
-
})),
|
|
390
|
-
when: (answers) => answers.colorOption === "preset",
|
|
391
|
-
},
|
|
392
|
-
{
|
|
393
|
-
type: "input",
|
|
394
|
-
name: "primaryColor",
|
|
395
|
-
message: "Primary color (hex format, e.g., #667eea) [skip for default]:",
|
|
396
|
-
default: "",
|
|
397
|
-
when: (answers) => answers.colorOption === "custom",
|
|
398
|
-
validate: (input) => {
|
|
399
|
-
if (!input || input.trim().length === 0) {
|
|
400
|
-
return true; // Optional field
|
|
401
|
-
}
|
|
402
|
-
// Basic hex color validation
|
|
403
|
-
const hexRegex = /^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/;
|
|
404
|
-
if (!hexRegex.test(input.trim())) {
|
|
405
|
-
return "Please enter a valid hex color (e.g., #667eea)";
|
|
406
|
-
}
|
|
407
|
-
return true;
|
|
408
|
-
},
|
|
409
|
-
},
|
|
410
|
-
{
|
|
411
|
-
type: "input",
|
|
412
|
-
name: "secondaryColor",
|
|
413
|
-
message: "Secondary color (hex format, e.g., #764ba2) [skip for default]:",
|
|
414
|
-
default: "",
|
|
415
|
-
when: (answers) => answers.colorOption === "custom",
|
|
416
|
-
validate: (input) => {
|
|
417
|
-
if (!input || input.trim().length === 0) {
|
|
418
|
-
return true; // Optional field
|
|
419
|
-
}
|
|
420
|
-
// Basic hex color validation
|
|
421
|
-
const hexRegex = /^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/;
|
|
422
|
-
if (!hexRegex.test(input.trim())) {
|
|
423
|
-
return "Please enter a valid hex color (e.g., #764ba2)";
|
|
424
|
-
}
|
|
425
|
-
return true;
|
|
426
|
-
},
|
|
427
|
-
},
|
|
428
|
-
]);
|
|
429
|
-
|
|
430
|
-
// Always include JavaScript file
|
|
431
|
-
answers.includeJs = true;
|
|
432
|
-
|
|
433
|
-
await generateTemplate(answers);
|
|
434
|
-
|
|
435
|
-
console.log("\n" + chalk.green("✓ Template created successfully!"));
|
|
436
|
-
console.log(chalk.gray(` Location: ./${answers.name}/`));
|
|
437
|
-
console.log(chalk.gray(` Structure:`));
|
|
438
|
-
console.log(chalk.gray(` index.html`));
|
|
439
|
-
console.log(chalk.gray(` css/`));
|
|
440
|
-
console.log(chalk.gray(` └── style.css`));
|
|
441
|
-
if (answers.includeJs) {
|
|
442
|
-
console.log(chalk.gray(` js/`));
|
|
443
|
-
console.log(chalk.gray(` └── script.js`));
|
|
444
|
-
}
|
|
445
|
-
console.log("");
|
|
446
|
-
} catch (error) {
|
|
447
|
-
console.error(chalk.red("✗ Error:"), error.message);
|
|
448
|
-
process.exit(1);
|
|
449
|
-
}
|
|
450
|
-
});
|
|
451
|
-
|
|
452
|
-
program
|
|
453
|
-
.command("insert")
|
|
454
|
-
.description(chalk.green("Insert a component into an existing HTML page"))
|
|
455
|
-
.option("-f, --file <path>", "Path to the HTML file")
|
|
456
|
-
.option("-c, --component <type>", "Component type to insert")
|
|
457
|
-
.option("-s, --script <mode>", "Script mode (inline, separate, skip)")
|
|
458
|
-
.option("--style <mode>", "Style mode (inline, separate, skip)")
|
|
459
|
-
.option("-b, --backup", "Create backup of original file")
|
|
460
|
-
.option("-v, --verbose", "Verbose output")
|
|
461
|
-
.action(async (options) => {
|
|
462
|
-
try {
|
|
463
|
-
if (options.verbose) {
|
|
464
|
-
console.log(chalk.gray("[DEBUG] Options:"), options);
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
// If flags are provided, use them directly
|
|
468
|
-
if (options.file && options.component) {
|
|
469
|
-
if (options.verbose) {
|
|
470
|
-
console.log(chalk.gray("[INFO] Using provided options..."));
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
const insertOptions = {
|
|
474
|
-
targetFile: options.file,
|
|
475
|
-
component: options.component,
|
|
476
|
-
scriptMode: options.script || "separate",
|
|
477
|
-
styleMode: "separate",
|
|
478
|
-
createBackup: options.backup || false,
|
|
479
|
-
};
|
|
480
|
-
|
|
481
|
-
const result = await insertComponent(insertOptions);
|
|
482
|
-
|
|
483
|
-
console.log("\n" + chalk.green("✓ Component inserted successfully!"));
|
|
484
|
-
console.log(chalk.cyan(" Summary:"));
|
|
485
|
-
console.log(
|
|
486
|
-
chalk.gray(
|
|
487
|
-
` File: ${path.relative(process.cwd(), result.targetFile)}`,
|
|
488
|
-
),
|
|
489
|
-
);
|
|
490
|
-
console.log(
|
|
491
|
-
chalk.gray(` Component: ${chalk.bold(result.component)}`),
|
|
492
|
-
);
|
|
493
|
-
console.log(chalk.gray(` CSS: ${chalk.yellow("external file")}`));
|
|
494
|
-
console.log(chalk.gray(` JS: ${chalk.yellow(result.scriptMode)}`));
|
|
495
|
-
console.log(
|
|
496
|
-
chalk.gray(
|
|
497
|
-
`\n Component IDs: ${result.component}-styles, ${result.component}-script`,
|
|
498
|
-
),
|
|
499
|
-
);
|
|
500
|
-
if (result.backupPath) {
|
|
501
|
-
console.log(
|
|
502
|
-
chalk.gray(
|
|
503
|
-
` Backup: ${chalk.yellow(path.relative(process.cwd(), result.backupPath))}`,
|
|
504
|
-
),
|
|
505
|
-
);
|
|
506
|
-
}
|
|
507
|
-
console.log("");
|
|
508
|
-
return;
|
|
509
|
-
}
|
|
510
|
-
|
|
511
|
-
// Otherwise, use interactive mode
|
|
512
|
-
console.log(chalk.cyan("\n🚀 Inserting component into HTML file...\n"));
|
|
513
|
-
|
|
514
|
-
const answers = await inquirer.prompt([
|
|
515
|
-
{
|
|
516
|
-
type: "input",
|
|
517
|
-
name: "targetFile",
|
|
518
|
-
message: "Enter the path to your HTML file:",
|
|
519
|
-
default: "index.html",
|
|
520
|
-
validate: async (input) => {
|
|
521
|
-
if (!input || input.trim().length === 0) {
|
|
522
|
-
return "Please enter a file path";
|
|
523
|
-
}
|
|
524
|
-
if (!input.toLowerCase().endsWith(".html")) {
|
|
525
|
-
return "File must be an HTML file (.html)";
|
|
526
|
-
}
|
|
527
|
-
|
|
528
|
-
// Check if file exists
|
|
529
|
-
try {
|
|
530
|
-
await fs.access(path.resolve(process.cwd(), input));
|
|
531
|
-
return true;
|
|
532
|
-
} catch {
|
|
533
|
-
return `File not found: ${input}`;
|
|
534
|
-
}
|
|
535
|
-
},
|
|
536
|
-
},
|
|
537
|
-
{
|
|
538
|
-
type: "list",
|
|
539
|
-
name: "component",
|
|
540
|
-
message: "Which component would you like to insert?",
|
|
541
|
-
choices: [
|
|
542
|
-
new inquirer.Separator(chalk.gray("─ Basic Components")),
|
|
543
|
-
{ name: "Button", value: "button" },
|
|
544
|
-
{ name: "Card", value: "card" },
|
|
545
|
-
{ name: "Form", value: "form" },
|
|
546
|
-
{ name: "Navigation", value: "navigation" },
|
|
547
|
-
{ name: "Modal", value: "modal" },
|
|
548
|
-
{ name: "Footer", value: "footer" },
|
|
549
|
-
{ name: "Hero Section", value: "hero" },
|
|
550
|
-
{ name: "Slider", value: "slider" },
|
|
551
|
-
{ name: "Table", value: "table" },
|
|
552
|
-
new inquirer.Separator(chalk.gray("─ Authentication Forms")),
|
|
553
|
-
{ name: "Login Form", value: "login" },
|
|
554
|
-
{ name: "Register Form", value: "register" },
|
|
555
|
-
new inquirer.Separator(chalk.gray("─ Loading Placeholders")),
|
|
556
|
-
{ name: "Skeleton (Loading Placeholders)", value: "skeleton" },
|
|
557
|
-
new inquirer.Separator(chalk.gray("─ Animation Templates")),
|
|
558
|
-
{ name: "Spinner", value: "spinner" },
|
|
559
|
-
{ name: "Animated Card", value: "animated-card" },
|
|
560
|
-
{ name: "Typing Effect", value: "typing-effect" },
|
|
561
|
-
{ name: "Fade Gallery", value: "fade-gallery" },
|
|
562
|
-
new inquirer.Separator(chalk.gray("─ Grid Layouts")),
|
|
563
|
-
{ name: "Grid Layout", value: "grid-layout" },
|
|
564
|
-
{ name: "Masonry Grid", value: "masonry-grid" },
|
|
565
|
-
{ name: "Dashboard Grid", value: "dashboard-grid" },
|
|
566
|
-
new inquirer.Separator(chalk.gray("─ Flexbox Layouts")),
|
|
567
|
-
{ name: "Flex Layout", value: "flex-layout" },
|
|
568
|
-
{ name: "Flex Cards", value: "flex-cards" },
|
|
569
|
-
{ name: "Flex Dashboard", value: "flex-dashboard" },
|
|
570
|
-
new inquirer.Separator(chalk.gray("─ DOM Manipulation")),
|
|
571
|
-
{ name: "Todo List", value: "todo-list" },
|
|
572
|
-
{ name: "Counter", value: "counter" },
|
|
573
|
-
{ name: "Accordion", value: "accordion" },
|
|
574
|
-
{ name: "Tabs", value: "tabs" },
|
|
575
|
-
new inquirer.Separator(chalk.gray("─ Interactive Games")),
|
|
576
|
-
{ name: "🎮 Tic-Tac-Toe", value: "tic-tac-toe" },
|
|
577
|
-
{ name: "🎮 Memory Game", value: "memory-game" },
|
|
578
|
-
{ name: "🎮 Snake Game", value: "snake-game" },
|
|
579
|
-
{ name: "🎮 Guess Number", value: "guess-number" },
|
|
580
|
-
{ name: "🎮 2048", value: "game-2048" },
|
|
581
|
-
{ name: "🎮 Whack-a-Mole", value: "whack-a-mole" },
|
|
582
|
-
{ name: "🎮 Simon Says", value: "simon-says" },
|
|
583
|
-
{ name: "🎮 Rock-Paper-Scissors", value: "rock-paper-scissors" },
|
|
584
|
-
{ name: "🎮 Breakout", value: "breakout" },
|
|
585
|
-
{ name: "🎮 Tetris", value: "tetris" },
|
|
586
|
-
{ name: "🎮 Flappy Bird", value: "flappy-bird" },
|
|
587
|
-
{ name: "🎮 Connect Four", value: "connect-four" },
|
|
588
|
-
{ name: "🎮 Blackjack", value: "blackjack" },
|
|
589
|
-
{ name: "🎮 Slot Machine", value: "slot-machine" },
|
|
590
|
-
{ name: "🎮 Dice Game", value: "dice-game" },
|
|
591
|
-
{ name: "🎮 Pong", value: "pong" },
|
|
592
|
-
],
|
|
593
|
-
},
|
|
594
|
-
{
|
|
595
|
-
type: "list",
|
|
596
|
-
name: "scriptMode",
|
|
597
|
-
message: "How should the JavaScript be added?",
|
|
598
|
-
choices: [
|
|
599
|
-
{ name: "Separate file (recommended)", value: "separate" },
|
|
600
|
-
{ name: "Inline (inside <script> tag)", value: "inline" },
|
|
601
|
-
{ name: "Skip (I'll add it manually)", value: "skip" },
|
|
602
|
-
],
|
|
603
|
-
default: "separate",
|
|
604
|
-
},
|
|
605
|
-
]);
|
|
606
|
-
|
|
607
|
-
// CSS is always separate (external)
|
|
608
|
-
answers.styleMode = "separate";
|
|
609
|
-
|
|
610
|
-
const result = await insertComponent(answers);
|
|
611
|
-
|
|
612
|
-
console.log("\n" + chalk.green("✓ Component inserted successfully!"));
|
|
613
|
-
console.log(chalk.cyan(" Summary:"));
|
|
614
|
-
console.log(
|
|
615
|
-
chalk.gray(
|
|
616
|
-
` File: ${path.relative(process.cwd(), result.targetFile)}`,
|
|
617
|
-
),
|
|
618
|
-
);
|
|
619
|
-
console.log(chalk.gray(` Component: ${chalk.bold(result.component)}`));
|
|
620
|
-
console.log(chalk.gray(` CSS: ${chalk.yellow("external file")}`));
|
|
621
|
-
console.log(chalk.gray(` JS: ${chalk.yellow(result.scriptMode)}`));
|
|
622
|
-
console.log(
|
|
623
|
-
chalk.gray(
|
|
624
|
-
`\n Component IDs: ${result.component}-styles, ${result.component}-script`,
|
|
625
|
-
),
|
|
626
|
-
);
|
|
627
|
-
console.log("");
|
|
628
|
-
} catch (error) {
|
|
629
|
-
console.error("\n" + chalk.red("✗ Error:"), error.message);
|
|
630
|
-
process.exit(1);
|
|
631
|
-
}
|
|
632
|
-
});
|
|
633
|
-
|
|
634
|
-
program
|
|
635
|
-
.command("list")
|
|
636
|
-
.description(chalk.green("List all available templates"))
|
|
637
|
-
.action(() => {
|
|
638
|
-
console.log("\n" + chalk.blue("📦 Available Components (46 total)\n"));
|
|
639
|
-
|
|
640
|
-
console.log(chalk.yellow("━ Basic Components (9)"));
|
|
641
|
-
console.log(" button Styled button component");
|
|
642
|
-
console.log(" card Card component with image and content");
|
|
643
|
-
console.log(" form Form with input fields and validation");
|
|
644
|
-
console.log(" navigation Responsive navigation bar");
|
|
645
|
-
console.log(" modal Modal dialog component");
|
|
646
|
-
console.log(" footer Footer section");
|
|
647
|
-
console.log(" hero Hero section with CTA button");
|
|
648
|
-
console.log(" slider Image carousel with navigation");
|
|
649
|
-
console.log(" table Data table with search and filtering");
|
|
650
|
-
|
|
651
|
-
console.log("\n" + chalk.green("━ Authentication Forms (2)"));
|
|
652
|
-
console.log(" login Login form with validation");
|
|
653
|
-
console.log(" register Register form with password requirements");
|
|
654
|
-
|
|
655
|
-
console.log("\n" + chalk.cyan("━ Loading Placeholders (1)"));
|
|
656
|
-
console.log(" skeleton Skeleton loading placeholder with shimmer animation");
|
|
657
|
-
|
|
658
|
-
console.log("\n" + chalk.magenta("━ Animation Templates (4)"));
|
|
659
|
-
console.log(" spinner 5 loading spinner variations");
|
|
660
|
-
console.log(" animated-card 6 interactive card animations");
|
|
661
|
-
console.log(" typing-effect Text typing animations");
|
|
662
|
-
console.log(" fade-gallery Image gallery with fade effects");
|
|
663
|
-
|
|
664
|
-
console.log("\n" + chalk.cyan("━ Grid Layouts (3)"));
|
|
665
|
-
console.log(" grid-layout CSS Grid patterns and examples");
|
|
666
|
-
console.log(" masonry-grid Pinterest-style masonry layout");
|
|
667
|
-
console.log(" dashboard-grid Complete admin dashboard (Grid)");
|
|
668
|
-
|
|
669
|
-
console.log("\n" + chalk.blue("━ Flexbox Layouts (3)"));
|
|
670
|
-
console.log(" flex-layout Flexbox patterns and examples");
|
|
671
|
-
console.log(" flex-cards Equal-height card layouts");
|
|
672
|
-
console.log(" flex-dashboard Complete admin dashboard (Flexbox)");
|
|
673
|
-
|
|
674
|
-
console.log("\n" + chalk.red("━ DOM Manipulation Examples (4)"));
|
|
675
|
-
console.log(" todo-list Interactive todo list with add/remove");
|
|
676
|
-
console.log(" counter Click counter with history tracking");
|
|
677
|
-
console.log(" accordion Collapsible accordion component");
|
|
678
|
-
console.log(" tabs Tabbed content switcher");
|
|
679
|
-
|
|
680
|
-
console.log("\n" + chalk.green("━ Interactive Games (16)"));
|
|
681
|
-
console.log(" tic-tac-toe Classic Tic-Tac-Toe game with score tracking");
|
|
682
|
-
console.log(" memory-game Memory card matching game with difficulty levels");
|
|
683
|
-
console.log(" snake-game Classic Snake game with keyboard controls");
|
|
684
|
-
console.log(" guess-number Number guessing game with hints and scoring");
|
|
685
|
-
console.log(" game-2048 2048 puzzle game with touch & keyboard controls");
|
|
686
|
-
console.log(" whack-a-mole Whack-A-Mole arcade game with difficulty levels");
|
|
687
|
-
console.log(" simon-says Simon Says memory pattern game");
|
|
688
|
-
console.log(" rock-paper-scissors Rock Paper Scissors vs AI");
|
|
689
|
-
console.log(" breakout Brick breaker arcade game with levels");
|
|
690
|
-
console.log(" tetris Classic Tetris with piece preview");
|
|
691
|
-
console.log(" flappy-bird Flappy Bird obstacle avoidance game");
|
|
692
|
-
console.log(" connect-four Connect 4 strategy game vs AI");
|
|
693
|
-
console.log(" blackjack Blackjack card game with betting");
|
|
694
|
-
console.log(" slot-machine 3-reel slot machine with jackpots");
|
|
695
|
-
console.log(" dice-game Dice race to 100 strategy game");
|
|
696
|
-
console.log(" pong Classic Pong paddle game vs AI");
|
|
697
|
-
|
|
698
|
-
console.log("\n" + chalk.gray("Usage:"));
|
|
699
|
-
console.log(" create-template create Create a new component");
|
|
700
|
-
console.log(" create-template insert Insert into HTML file");
|
|
701
|
-
console.log("");
|
|
702
|
-
});
|
|
703
|
-
|
|
704
|
-
program
|
|
705
|
-
.command("gallery")
|
|
706
|
-
.description(chalk.magenta("🎨 Open interactive component gallery in browser"))
|
|
707
|
-
.action(async () => {
|
|
708
|
-
try {
|
|
709
|
-
const galleryPath = path.join(__dirname, "..", "COMPONENTS-GALLERY.html");
|
|
710
|
-
const fileUrl = `file:///${galleryPath.replace(/\\/g, "/")}`;
|
|
711
|
-
|
|
712
|
-
console.log(chalk.cyan("\n🎨 Opening Component Gallery...\n"));
|
|
713
|
-
|
|
714
|
-
// Cross-platform: open file in default browser
|
|
715
|
-
let command;
|
|
716
|
-
if (process.platform === "win32") {
|
|
717
|
-
command = `start "" "${galleryPath}"`;
|
|
718
|
-
} else if (process.platform === "darwin") {
|
|
719
|
-
command = `open "${galleryPath}"`;
|
|
720
|
-
} else {
|
|
721
|
-
// Linux and others
|
|
722
|
-
command = `xdg-open "${galleryPath}"`;
|
|
723
|
-
}
|
|
724
|
-
|
|
725
|
-
exec(command, (error) => {
|
|
726
|
-
if (error) {
|
|
727
|
-
console.error(chalk.red("✗ Could not open gallery:"), error.message);
|
|
728
|
-
console.log(chalk.gray(`Try opening manually: ${galleryPath}`));
|
|
729
|
-
} else {
|
|
730
|
-
console.log(chalk.green("✓ Gallery opened in your browser!"));
|
|
731
|
-
console.log(chalk.gray(`Location: ${galleryPath}\n`));
|
|
732
|
-
}
|
|
733
|
-
});
|
|
734
|
-
} catch (error) {
|
|
735
|
-
console.error(chalk.red("✗ Error:"), error.message);
|
|
736
|
-
}
|
|
737
|
-
});
|
|
738
|
-
|
|
739
|
-
program.parse(process.argv);
|
|
740
|
-
|
|
741
|
-
if (!process.argv.slice(2).length) {
|
|
742
|
-
console.log("\n" + chalk.cyan("🎨 Create HTML/CSS UI Templates\n"));
|
|
743
|
-
console.log(chalk.white("Usage: create-template [command] [options]") + "\n");
|
|
744
|
-
console.log(chalk.yellow("Commands:"));
|
|
745
|
-
console.log(" create Create a new template component");
|
|
746
|
-
console.log(" insert Insert component into existing HTML file");
|
|
747
|
-
console.log(" list Show all available templates");
|
|
748
|
-
console.log(" gallery Open interactive component gallery");
|
|
749
|
-
console.log(" help Display help information\n");
|
|
750
|
-
console.log(chalk.gray("Interactive Examples:"));
|
|
751
|
-
console.log(" $ create-template create # Create with prompts");
|
|
752
|
-
console.log(" $ create-template insert # Insert with prompts");
|
|
753
|
-
console.log(" $ create-template gallery # View all components in gallery");
|
|
754
|
-
console.log(" $ create-template list # View all 46 templates\n");
|
|
755
|
-
console.log(chalk.gray("Flag Examples (Non-interactive):"));
|
|
756
|
-
console.log(" $ create-template create -c button -n my-btn");
|
|
757
|
-
console.log(" $ create-template insert -f index.html -c card -s separate");
|
|
758
|
-
console.log(" $ create-template --help # Show full help\n");
|
|
759
|
-
}
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { program } from "commander";
|
|
4
|
+
import chalk from "chalk";
|
|
5
|
+
import { COLOR_SCHEMES } from "../src/generator.js";
|
|
6
|
+
import { createCommand } from "./commands/create.js";
|
|
7
|
+
import { insertCommand } from "./commands/insert.js";
|
|
8
|
+
import { listCommand } from "./commands/list.js";
|
|
9
|
+
import { galleryCommand } from "./commands/gallery.js";
|
|
10
|
+
|
|
11
|
+
program
|
|
12
|
+
.name("create-template")
|
|
13
|
+
.description(chalk.cyan("🎨 Create HTML/CSS/React UI component templates in seconds"))
|
|
14
|
+
.version("2.0.4");
|
|
15
|
+
|
|
16
|
+
// Help message
|
|
17
|
+
program.on("--help", () => {
|
|
18
|
+
console.log("\n" + chalk.cyan("Examples:"));
|
|
19
|
+
console.log(" $ create-template create # Interactive mode");
|
|
20
|
+
console.log(" $ create-template create -c button -n my-btn # With flags");
|
|
21
|
+
console.log(" $ create-template create --react -c button -n my-btn # React component");
|
|
22
|
+
console.log(" $ create-template create -c card --dark-mode --color-scheme vibrant");
|
|
23
|
+
console.log(" $ create-template insert # Interactive mode");
|
|
24
|
+
console.log(" $ create-template insert -f index.html -c card -s separate");
|
|
25
|
+
console.log(" $ create-template list # List all templates");
|
|
26
|
+
console.log(" $ create-template gallery # Open gallery\n");
|
|
27
|
+
|
|
28
|
+
console.log(chalk.yellow("Available Color Schemes:"));
|
|
29
|
+
Object.entries(COLOR_SCHEMES).forEach(([key, scheme]) => {
|
|
30
|
+
console.log(` ${key.padEnd(12)} - ${scheme.description}`);
|
|
31
|
+
});
|
|
32
|
+
console.log("");
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
// Create command
|
|
36
|
+
program
|
|
37
|
+
.command("create")
|
|
38
|
+
.description(chalk.green("Create a new HTML/CSS template component"))
|
|
39
|
+
.option("-c, --component <type>", "Component type (button, card, form, etc.)")
|
|
40
|
+
.option("-n, --name <name>", "Component name/project name")
|
|
41
|
+
.option("-r, --react", "Create React component instead of HTML")
|
|
42
|
+
.option("--component-only", "Create only component folder (React only, no full project)")
|
|
43
|
+
.option("--include-js", "Include JavaScript file", true)
|
|
44
|
+
.option("--no-include-js", "Exclude JavaScript file")
|
|
45
|
+
.option("--dark-mode", "Add dark mode support")
|
|
46
|
+
.option("--primary-color <color>", "Primary color (hex: #667eea)")
|
|
47
|
+
.option("--secondary-color <color>", "Secondary color (hex: #764ba2)")
|
|
48
|
+
.option("--color-scheme <scheme>", "Color scheme preset")
|
|
49
|
+
.option("-v, --verbose", "Verbose output")
|
|
50
|
+
.action(createCommand);
|
|
51
|
+
|
|
52
|
+
// Insert command
|
|
53
|
+
program
|
|
54
|
+
.command("insert")
|
|
55
|
+
.description(chalk.green("Insert a component into an existing HTML page"))
|
|
56
|
+
.option("-f, --file <path>", "Path to the HTML file")
|
|
57
|
+
.option("-c, --component <type>", "Component type to insert")
|
|
58
|
+
.option("-s, --script <mode>", "Script mode (inline, separate, skip)")
|
|
59
|
+
.option("--style <mode>", "Style mode (inline, separate, skip)")
|
|
60
|
+
.option("-b, --backup", "Create backup of original file")
|
|
61
|
+
.option("-v, --verbose", "Verbose output")
|
|
62
|
+
.action(insertCommand);
|
|
63
|
+
|
|
64
|
+
// List command
|
|
65
|
+
program
|
|
66
|
+
.command("list")
|
|
67
|
+
.description(chalk.green("List all available templates"))
|
|
68
|
+
.action(listCommand);
|
|
69
|
+
|
|
70
|
+
// Gallery command
|
|
71
|
+
program
|
|
72
|
+
.command("gallery")
|
|
73
|
+
.description(chalk.magenta("🎨 Open interactive component gallery"))
|
|
74
|
+
.action(galleryCommand);
|
|
75
|
+
|
|
76
|
+
program.parse(process.argv);
|
|
77
|
+
|
|
78
|
+
// Show help if no command provided
|
|
79
|
+
if (!process.argv.slice(2).length) {
|
|
80
|
+
console.log("\n" + chalk.cyan("🎨 Create HTML/CSS/React UI Templates\n"));
|
|
81
|
+
console.log(chalk.white("Usage: create-template [command] [options]") + "\n");
|
|
82
|
+
console.log(chalk.yellow("Commands:"));
|
|
83
|
+
console.log(" create Create a new template component (HTML or React)");
|
|
84
|
+
console.log(" insert Insert component into existing HTML file");
|
|
85
|
+
console.log(" list Show all available templates");
|
|
86
|
+
console.log(" gallery Open interactive component gallery");
|
|
87
|
+
console.log(" help Display help information\n");
|
|
88
|
+
console.log(chalk.gray("Interactive Examples:"));
|
|
89
|
+
console.log(" $ create-template create # Create with prompts");
|
|
90
|
+
console.log(" $ create-template insert # Insert with prompts");
|
|
91
|
+
console.log(" $ create-template gallery # View all components");
|
|
92
|
+
console.log(" $ create-template list # View all 46 templates\n");
|
|
93
|
+
console.log(chalk.gray("Flag Examples:"));
|
|
94
|
+
console.log(" $ create-template create -c button -n my-btn");
|
|
95
|
+
console.log(" $ create-template create --react -c counter -n my-counter");
|
|
96
|
+
console.log(" $ create-template insert -f index.html -c card -s separate");
|
|
97
|
+
console.log(" $ create-template --help # Show full help\n");
|
|
98
|
+
}
|