create-template-html-css 1.5.0 → 1.6.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/bin/cli.js CHANGED
@@ -1,260 +1,416 @@
1
- #!/usr/bin/env node
2
-
3
- const { program } = require('commander');
4
- const inquirer = require('inquirer').default || require('inquirer');
5
- const path = require('path');
6
- const fs = require('fs').promises;
7
- const { generateTemplate } = require('../src/generator');
8
- const { insertComponent } = require('../src/inserter');
9
- const chalk = require('chalk');
10
-
11
- program
12
- .name('create-template')
13
- .description(chalk.cyan('šŸŽØ Create HTML/CSS UI component templates in seconds'))
14
- .version('1.5.0');
15
-
16
- // Add intro message
17
- program.on('--help', () => {
18
- console.log('\n' + chalk.cyan('Examples:'));
19
- console.log(' $ create-template create # Create a new template');
20
- console.log(' $ create-template insert # Insert into existing HTML');
21
- console.log(' $ create-template list # List all templates');
22
- console.log('');
23
- });
24
-
25
- program
26
- .command('create')
27
- .description(chalk.green('Create a new HTML/CSS template component'))
28
- .action(async () => {
29
- try {
30
- console.log(chalk.cyan('\n✨ Creating a new template component...\n'));
31
-
32
- const answers = await inquirer.prompt([
33
- {
34
- type: 'list',
35
- name: 'component',
36
- message: 'What component would you like to create?',
37
- choices: [
38
- new inquirer.Separator(chalk.gray('─ Basic Components')),
39
- { name: 'Button', value: 'button' },
40
- { name: 'Card', value: 'card' },
41
- { name: 'Form', value: 'form' },
42
- { name: 'Navigation', value: 'navigation' },
43
- { name: 'Modal', value: 'modal' },
44
- { name: 'Footer', value: 'footer' },
45
- { name: 'Hero Section', value: 'hero' },
46
- { name: 'Slider', value: 'slider' },
47
- { name: 'Table', value: 'table' },
48
- new inquirer.Separator(chalk.gray('─ Animation Templates')),
49
- { name: 'Spinner (Loading Animations)', value: 'spinner' },
50
- { name: 'Animated Card (Interactive Cards)', value: 'animated-card' },
51
- { name: 'Typing Effect (Text Animations)', value: 'typing-effect' },
52
- { name: 'Fade Gallery (Image Gallery)', value: 'fade-gallery' },
53
- new inquirer.Separator(chalk.gray('─ Grid Layouts (CSS Grid)')),
54
- { name: 'Grid Layout', value: 'grid-layout' },
55
- { name: 'Masonry Grid (Pinterest-style)', value: 'masonry-grid' },
56
- { name: 'Dashboard Grid (Admin Panel)', value: 'dashboard-grid' },
57
- new inquirer.Separator(chalk.gray('─ Flexbox Layouts')),
58
- { name: 'Flex Layout (Flexbox Patterns)', value: 'flex-layout' },
59
- { name: 'Flex Cards (Equal-height cards)', value: 'flex-cards' },
60
- { name: 'Flex Dashboard (Flexbox Admin)', value: 'flex-dashboard' },
61
- new inquirer.Separator(chalk.gray('─ DOM Manipulation Examples')),
62
- { name: 'Todo List (Add/Remove Items)', value: 'todo-list' },
63
- { name: 'Counter (Click Handlers)', value: 'counter' },
64
- { name: 'Accordion (Toggle Content)', value: 'accordion' },
65
- { name: 'Tabs (Switch Sections)', value: 'tabs' }
66
- ]
67
- },
68
- {
69
- type: 'input',
70
- name: 'name',
71
- message: 'Enter a name for your component:',
72
- default: (answers) => answers.component,
73
- validate: (input) => {
74
- if (!input || input.trim().length === 0) {
75
- return 'Please enter a valid name';
76
- }
77
- if (input.includes('..') || input.includes('/') || input.includes('\\')) {
78
- return 'Name cannot contain path separators or parent directory references';
79
- }
80
- if (input.length > 100) {
81
- return 'Name is too long (max 100 characters)';
82
- }
83
- return true;
84
- }
85
- },
86
- ]);
87
-
88
- // Always include JavaScript file
89
- answers.includeJs = true;
90
-
91
- await generateTemplate(answers);
92
-
93
- console.log('\n' + chalk.green('āœ“ Template created successfully!'));
94
- console.log(chalk.gray(` Location: ./${answers.name}/`));
95
- console.log(chalk.gray(` Files: index.html, style.css${answers.includeJs ? ', script.js' : ''}`));
96
- console.log('');
97
- } catch (error) {
98
- console.error(chalk.red('āœ— Error:'), error.message);
99
- process.exit(1);
100
- }
101
- });
102
-
103
- program
104
- .command('insert')
105
- .description(chalk.green('Insert a component into an existing HTML page'))
106
- .action(async () => {
107
- try {
108
- console.log(chalk.cyan('\nšŸš€ Inserting component into HTML file...\n'));
109
-
110
- const answers = await inquirer.prompt([
111
- {
112
- type: 'input',
113
- name: 'targetFile',
114
- message: 'Enter the path to your HTML file:',
115
- default: 'index.html',
116
- validate: async (input) => {
117
- if (!input || input.trim().length === 0) {
118
- return 'Please enter a file path';
119
- }
120
- if (!input.toLowerCase().endsWith('.html')) {
121
- return 'File must be an HTML file (.html)';
122
- }
123
-
124
- // Check if file exists
125
- try {
126
- await fs.access(path.resolve(process.cwd(), input));
127
- return true;
128
- } catch {
129
- return `File not found: ${input}`;
130
- }
131
- }
132
- },
133
- {
134
- type: 'list',
135
- name: 'component',
136
- message: 'Which component would you like to insert?',
137
- choices: [
138
- new inquirer.Separator(chalk.gray('─ Basic Components')),
139
- { name: 'Button', value: 'button' },
140
- { name: 'Card', value: 'card' },
141
- { name: 'Form', value: 'form' },
142
- { name: 'Navigation', value: 'navigation' },
143
- { name: 'Modal', value: 'modal' },
144
- { name: 'Footer', value: 'footer' },
145
- { name: 'Hero Section', value: 'hero' },
146
- { name: 'Slider', value: 'slider' },
147
- { name: 'Table', value: 'table' },
148
- new inquirer.Separator(chalk.gray('─ Animation Templates')),
149
- { name: 'Spinner', value: 'spinner' },
150
- { name: 'Animated Card', value: 'animated-card' },
151
- { name: 'Typing Effect', value: 'typing-effect' },
152
- { name: 'Fade Gallery', value: 'fade-gallery' },
153
- new inquirer.Separator(chalk.gray('─ Grid Layouts')),
154
- { name: 'Grid Layout', value: 'grid-layout' },
155
- { name: 'Masonry Grid', value: 'masonry-grid' },
156
- { name: 'Dashboard Grid', value: 'dashboard-grid' },
157
- new inquirer.Separator(chalk.gray('─ Flexbox Layouts')),
158
- { name: 'Flex Layout', value: 'flex-layout' },
159
- { name: 'Flex Cards', value: 'flex-cards' },
160
- { name: 'Flex Dashboard', value: 'flex-dashboard' },
161
- new inquirer.Separator(chalk.gray('─ DOM Manipulation')),
162
- { name: 'Todo List', value: 'todo-list' },
163
- { name: 'Counter', value: 'counter' },
164
- { name: 'Accordion', value: 'accordion' },
165
- { name: 'Tabs', value: 'tabs' }
166
- ]
167
- },
168
- {
169
- type: 'list',
170
- name: 'scriptMode',
171
- message: 'How should the JavaScript be added?',
172
- choices: [
173
- { name: 'Separate file (recommended)', value: 'separate' },
174
- { name: 'Inline (inside <script> tag)', value: 'inline' },
175
- { name: 'Skip (I\'ll add it manually)', value: 'skip' }
176
- ],
177
- default: 'separate'
178
- }
179
- ]);
180
-
181
- // CSS is always separate (external)
182
- answers.styleMode = 'separate';
183
-
184
- const result = await insertComponent(answers);
185
-
186
- console.log('\n' + chalk.green('āœ“ Component inserted successfully!'));
187
- console.log(chalk.cyan(' Summary:'));
188
- console.log(chalk.gray(` File: ${path.relative(process.cwd(), result.targetFile)}`));
189
- console.log(chalk.gray(` Component: ${chalk.bold(result.component)}`));
190
- console.log(chalk.gray(` CSS: ${chalk.yellow('external file')}`));
191
- console.log(chalk.gray(` JS: ${chalk.yellow(result.scriptMode)}`));
192
- console.log(chalk.gray(`\n Component IDs: ${result.component}-styles, ${result.component}-script`));
193
- console.log('');
194
- } catch (error) {
195
- console.error('\n' + chalk.red('āœ— Error:'), error.message);
196
- process.exit(1);
197
- }
198
- });
199
-
200
- program
201
- .command('list')
202
- .description(chalk.green('List all available templates'))
203
- .action(() => {
204
- console.log('\n' + chalk.blue('šŸ“¦ Available Components (23 total)\n'));
205
-
206
- console.log(chalk.yellow('━ Basic Components (9)'));
207
- console.log(' button Styled button component');
208
- console.log(' card Card component with image and content');
209
- console.log(' form Form with input fields and validation');
210
- console.log(' navigation Responsive navigation bar');
211
- console.log(' modal Modal dialog component');
212
- console.log(' footer Footer section');
213
- console.log(' hero Hero section with CTA button');
214
- console.log(' slider Image carousel with navigation');
215
- console.log(' table Data table with search and filtering');
216
-
217
- console.log('\n' + chalk.magenta('━ Animation Templates (4)'));
218
- console.log(' spinner 5 loading spinner variations');
219
- console.log(' animated-card 6 interactive card animations');
220
- console.log(' typing-effect Text typing animations');
221
- console.log(' fade-gallery Image gallery with fade effects');
222
-
223
- console.log('\n' + chalk.cyan('━ Grid Layouts (3)'));
224
- console.log(' grid-layout CSS Grid patterns and examples');
225
- console.log(' masonry-grid Pinterest-style masonry layout');
226
- console.log(' dashboard-grid Complete admin dashboard (Grid)');
227
-
228
- console.log('\n' + chalk.green('━ Flexbox Layouts (3)'));
229
- console.log(' flex-layout Flexbox patterns and examples');
230
- console.log(' flex-cards Equal-height card layouts');
231
- console.log(' flex-dashboard Complete admin dashboard (Flexbox)');
232
-
233
- console.log('\n' + chalk.red('━ DOM Manipulation Examples (4)'));
234
- console.log(' todo-list Interactive todo list with add/remove');
235
- console.log(' counter Click counter with history tracking');
236
- console.log(' accordion Collapsible accordion component');
237
- console.log(' tabs Tabbed content switcher');
238
-
239
- console.log('\n' + chalk.gray('Usage:'));
240
- console.log(' create-template create Create a new component');
241
- console.log(' create-template insert Insert into HTML file');
242
- console.log('');
243
- });
244
-
245
- program.parse(process.argv);
246
-
247
- if (!process.argv.slice(2).length) {
248
- console.log('\n' + chalk.cyan('šŸŽØ Create HTML/CSS UI Templates\n'));
249
- console.log(chalk.white('Usage: create-template [command]') + '\n');
250
- console.log(chalk.yellow('Commands:'));
251
- console.log(' create Create a new template component');
252
- console.log(' insert Insert component into existing HTML file');
253
- console.log(' list Show all available templates');
254
- console.log(' help Display help information\n');
255
- console.log(chalk.gray('Examples:'));
256
- console.log(' $ create-template create # Interactive template creation');
257
- console.log(' $ create-template insert # Interactive component insertion');
258
- console.log(' $ create-template list # View all 19 templates');
259
- console.log(' $ create-template --help # Show full help\n');
260
- }
1
+ #!/usr/bin/env node
2
+
3
+ const { program } = require("commander");
4
+ const inquirer = require("inquirer").default || require("inquirer");
5
+ const path = require("path");
6
+ const fs = require("fs").promises;
7
+ const { generateTemplate } = require("../src/generator");
8
+ const { insertComponent } = require("../src/inserter");
9
+ const chalk = require("chalk");
10
+
11
+ program
12
+ .name("create-template")
13
+ .description(
14
+ chalk.cyan("šŸŽØ Create HTML/CSS UI component templates in seconds"),
15
+ )
16
+ .version("1.6.2");
17
+
18
+ // Add intro message
19
+ program.on("--help", () => {
20
+ console.log("\n" + chalk.cyan("Examples:"));
21
+ console.log(
22
+ " $ create-template create # Interactive mode",
23
+ );
24
+ console.log(" $ create-template create -c button -n my-btn # With flags");
25
+ console.log(
26
+ " $ create-template insert # Interactive mode",
27
+ );
28
+ console.log(
29
+ " $ create-template insert -f index.html -c card -s separate # With flags",
30
+ );
31
+ console.log(
32
+ " $ create-template insert -f page.html -c button --backup # With backup",
33
+ );
34
+ console.log(
35
+ " $ create-template list # List all templates",
36
+ );
37
+ console.log("");
38
+ console.log(chalk.yellow("Create Command Flags:"));
39
+ console.log(
40
+ " -c, --component <type> Component type (button, card, form, etc.)",
41
+ );
42
+ console.log(" -n, --name <name> Project/component name");
43
+ console.log(
44
+ " --include-js Include JavaScript file (default: true)",
45
+ );
46
+ console.log(" --no-include-js Exclude JavaScript file");
47
+ console.log(" -v, --verbose Show detailed output");
48
+ console.log("");
49
+ console.log(chalk.yellow("Insert Command Flags:"));
50
+ console.log(" -f, --file <path> Path to HTML file");
51
+ console.log(" -c, --component <type> Component type to insert");
52
+ console.log(
53
+ " -s, --script <mode> Script mode (inline, separate, skip)",
54
+ );
55
+ console.log(
56
+ " --style <mode> Style mode (inline, separate, skip)",
57
+ );
58
+ console.log(" -b, --backup Create backup before insertion");
59
+ console.log(" -v, --verbose Show detailed output");
60
+ console.log("");
61
+ });
62
+
63
+ program
64
+ .command("create")
65
+ .description(chalk.green("Create a new HTML/CSS template component"))
66
+ .option("-c, --component <type>", "Component type (button, card, form, etc.)")
67
+ .option("-n, --name <name>", "Component name/project name")
68
+ .option("--include-js", "Include JavaScript file", true)
69
+ .option("--no-include-js", "Exclude JavaScript file")
70
+ .option("-v, --verbose", "Verbose output")
71
+ .action(async (options) => {
72
+ try {
73
+ if (options.verbose) {
74
+ console.log(chalk.gray("[DEBUG] Options:"), options);
75
+ }
76
+
77
+ // If flags are provided, use them directly
78
+ if (options.component && options.name) {
79
+ if (options.verbose) {
80
+ console.log(chalk.gray("[INFO] Using provided options..."));
81
+ }
82
+
83
+ const createOptions = {
84
+ component: options.component,
85
+ name: options.name,
86
+ includeJs: options.includeJs,
87
+ };
88
+
89
+ await generateTemplate(createOptions);
90
+
91
+ console.log("\n" + chalk.green("āœ“ Template created successfully!"));
92
+ console.log(chalk.gray(` Location: ./${options.name}/`));
93
+ console.log(chalk.gray(` Structure:`));
94
+ console.log(chalk.gray(` index.html`));
95
+ console.log(chalk.gray(` css/`));
96
+ console.log(chalk.gray(` └── style.css`));
97
+ if (options.includeJs) {
98
+ console.log(chalk.gray(` js/`));
99
+ console.log(chalk.gray(` └── script.js`));
100
+ }
101
+ console.log("");
102
+ return;
103
+ }
104
+
105
+ // Otherwise, use interactive mode
106
+ console.log(chalk.cyan("\n✨ Creating a new template component...\n"));
107
+
108
+ const answers = await inquirer.prompt([
109
+ {
110
+ type: "list",
111
+ name: "component",
112
+ message: "What component would you like to create?",
113
+ choices: [
114
+ new inquirer.Separator(chalk.gray("─ Basic Components")),
115
+ { name: "Button", value: "button" },
116
+ { name: "Card", value: "card" },
117
+ { name: "Form", value: "form" },
118
+ { name: "Navigation", value: "navigation" },
119
+ { name: "Modal", value: "modal" },
120
+ { name: "Footer", value: "footer" },
121
+ { name: "Hero Section", value: "hero" },
122
+ { name: "Slider", value: "slider" },
123
+ { name: "Table", value: "table" },
124
+ new inquirer.Separator(chalk.gray("─ Animation Templates")),
125
+ { name: "Spinner (Loading Animations)", value: "spinner" },
126
+ {
127
+ name: "Animated Card (Interactive Cards)",
128
+ value: "animated-card",
129
+ },
130
+ { name: "Typing Effect (Text Animations)", value: "typing-effect" },
131
+ { name: "Fade Gallery (Image Gallery)", value: "fade-gallery" },
132
+ new inquirer.Separator(chalk.gray("─ Grid Layouts (CSS Grid)")),
133
+ { name: "Grid Layout", value: "grid-layout" },
134
+ { name: "Masonry Grid (Pinterest-style)", value: "masonry-grid" },
135
+ { name: "Dashboard Grid (Admin Panel)", value: "dashboard-grid" },
136
+ new inquirer.Separator(chalk.gray("─ Flexbox Layouts")),
137
+ { name: "Flex Layout (Flexbox Patterns)", value: "flex-layout" },
138
+ { name: "Flex Cards (Equal-height cards)", value: "flex-cards" },
139
+ { name: "Flex Dashboard (Flexbox Admin)", value: "flex-dashboard" },
140
+ new inquirer.Separator(chalk.gray("─ DOM Manipulation Examples")),
141
+ { name: "Todo List (Add/Remove Items)", value: "todo-list" },
142
+ { name: "Counter (Click Handlers)", value: "counter" },
143
+ { name: "Accordion (Toggle Content)", value: "accordion" },
144
+ { name: "Tabs (Switch Sections)", value: "tabs" },
145
+ ],
146
+ },
147
+ {
148
+ type: "input",
149
+ name: "name",
150
+ message: "Enter a name for your component:",
151
+ default: (answers) => answers.component,
152
+ validate: (input) => {
153
+ if (!input || input.trim().length === 0) {
154
+ return "Please enter a valid name";
155
+ }
156
+ if (
157
+ input.includes("..") ||
158
+ input.includes("/") ||
159
+ input.includes("\\")
160
+ ) {
161
+ return "Name cannot contain path separators or parent directory references";
162
+ }
163
+ if (input.length > 100) {
164
+ return "Name is too long (max 100 characters)";
165
+ }
166
+ return true;
167
+ },
168
+ },
169
+ ]);
170
+
171
+ // Always include JavaScript file
172
+ answers.includeJs = true;
173
+
174
+ await generateTemplate(answers);
175
+
176
+ console.log("\n" + chalk.green("āœ“ Template created successfully!"));
177
+ console.log(chalk.gray(` Location: ./${answers.name}/`));
178
+ console.log(chalk.gray(` Structure:`));
179
+ console.log(chalk.gray(` index.html`));
180
+ console.log(chalk.gray(` css/`));
181
+ console.log(chalk.gray(` └── style.css`));
182
+ if (answers.includeJs) {
183
+ console.log(chalk.gray(` js/`));
184
+ console.log(chalk.gray(` └── script.js`));
185
+ }
186
+ console.log("");
187
+ } catch (error) {
188
+ console.error(chalk.red("āœ— Error:"), error.message);
189
+ process.exit(1);
190
+ }
191
+ });
192
+
193
+ program
194
+ .command("insert")
195
+ .description(chalk.green("Insert a component into an existing HTML page"))
196
+ .option("-f, --file <path>", "Path to the HTML file")
197
+ .option("-c, --component <type>", "Component type to insert")
198
+ .option("-s, --script <mode>", "Script mode (inline, separate, skip)")
199
+ .option("--style <mode>", "Style mode (inline, separate, skip)")
200
+ .option("-b, --backup", "Create backup of original file")
201
+ .option("-v, --verbose", "Verbose output")
202
+ .action(async (options) => {
203
+ try {
204
+ if (options.verbose) {
205
+ console.log(chalk.gray("[DEBUG] Options:"), options);
206
+ }
207
+
208
+ // If flags are provided, use them directly
209
+ if (options.file && options.component) {
210
+ if (options.verbose) {
211
+ console.log(chalk.gray("[INFO] Using provided options..."));
212
+ }
213
+
214
+ const insertOptions = {
215
+ targetFile: options.file,
216
+ component: options.component,
217
+ scriptMode: options.script || "separate",
218
+ styleMode: "separate",
219
+ createBackup: options.backup || false,
220
+ };
221
+
222
+ const result = await insertComponent(insertOptions);
223
+
224
+ console.log("\n" + chalk.green("āœ“ Component inserted successfully!"));
225
+ console.log(chalk.cyan(" Summary:"));
226
+ console.log(
227
+ chalk.gray(
228
+ ` File: ${path.relative(process.cwd(), result.targetFile)}`,
229
+ ),
230
+ );
231
+ console.log(
232
+ chalk.gray(` Component: ${chalk.bold(result.component)}`),
233
+ );
234
+ console.log(chalk.gray(` CSS: ${chalk.yellow("external file")}`));
235
+ console.log(chalk.gray(` JS: ${chalk.yellow(result.scriptMode)}`));
236
+ console.log(
237
+ chalk.gray(
238
+ `\n Component IDs: ${result.component}-styles, ${result.component}-script`,
239
+ ),
240
+ );
241
+ if (result.backupPath) {
242
+ console.log(
243
+ chalk.gray(
244
+ ` Backup: ${chalk.yellow(path.relative(process.cwd(), result.backupPath))}`,
245
+ ),
246
+ );
247
+ }
248
+ console.log("");
249
+ return;
250
+ }
251
+
252
+ // Otherwise, use interactive mode
253
+ console.log(chalk.cyan("\nšŸš€ Inserting component into HTML file...\n"));
254
+
255
+ const answers = await inquirer.prompt([
256
+ {
257
+ type: "input",
258
+ name: "targetFile",
259
+ message: "Enter the path to your HTML file:",
260
+ default: "index.html",
261
+ validate: async (input) => {
262
+ if (!input || input.trim().length === 0) {
263
+ return "Please enter a file path";
264
+ }
265
+ if (!input.toLowerCase().endsWith(".html")) {
266
+ return "File must be an HTML file (.html)";
267
+ }
268
+
269
+ // Check if file exists
270
+ try {
271
+ await fs.access(path.resolve(process.cwd(), input));
272
+ return true;
273
+ } catch {
274
+ return `File not found: ${input}`;
275
+ }
276
+ },
277
+ },
278
+ {
279
+ type: "list",
280
+ name: "component",
281
+ message: "Which component would you like to insert?",
282
+ choices: [
283
+ new inquirer.Separator(chalk.gray("─ Basic Components")),
284
+ { name: "Button", value: "button" },
285
+ { name: "Card", value: "card" },
286
+ { name: "Form", value: "form" },
287
+ { name: "Navigation", value: "navigation" },
288
+ { name: "Modal", value: "modal" },
289
+ { name: "Footer", value: "footer" },
290
+ { name: "Hero Section", value: "hero" },
291
+ { name: "Slider", value: "slider" },
292
+ { name: "Table", value: "table" },
293
+ new inquirer.Separator(chalk.gray("─ Animation Templates")),
294
+ { name: "Spinner", value: "spinner" },
295
+ { name: "Animated Card", value: "animated-card" },
296
+ { name: "Typing Effect", value: "typing-effect" },
297
+ { name: "Fade Gallery", value: "fade-gallery" },
298
+ new inquirer.Separator(chalk.gray("─ Grid Layouts")),
299
+ { name: "Grid Layout", value: "grid-layout" },
300
+ { name: "Masonry Grid", value: "masonry-grid" },
301
+ { name: "Dashboard Grid", value: "dashboard-grid" },
302
+ new inquirer.Separator(chalk.gray("─ Flexbox Layouts")),
303
+ { name: "Flex Layout", value: "flex-layout" },
304
+ { name: "Flex Cards", value: "flex-cards" },
305
+ { name: "Flex Dashboard", value: "flex-dashboard" },
306
+ new inquirer.Separator(chalk.gray("─ DOM Manipulation")),
307
+ { name: "Todo List", value: "todo-list" },
308
+ { name: "Counter", value: "counter" },
309
+ { name: "Accordion", value: "accordion" },
310
+ { name: "Tabs", value: "tabs" },
311
+ ],
312
+ },
313
+ {
314
+ type: "list",
315
+ name: "scriptMode",
316
+ message: "How should the JavaScript be added?",
317
+ choices: [
318
+ { name: "Separate file (recommended)", value: "separate" },
319
+ { name: "Inline (inside <script> tag)", value: "inline" },
320
+ { name: "Skip (I'll add it manually)", value: "skip" },
321
+ ],
322
+ default: "separate",
323
+ },
324
+ ]);
325
+
326
+ // CSS is always separate (external)
327
+ answers.styleMode = "separate";
328
+
329
+ const result = await insertComponent(answers);
330
+
331
+ console.log("\n" + chalk.green("āœ“ Component inserted successfully!"));
332
+ console.log(chalk.cyan(" Summary:"));
333
+ console.log(
334
+ chalk.gray(
335
+ ` File: ${path.relative(process.cwd(), result.targetFile)}`,
336
+ ),
337
+ );
338
+ console.log(chalk.gray(` Component: ${chalk.bold(result.component)}`));
339
+ console.log(chalk.gray(` CSS: ${chalk.yellow("external file")}`));
340
+ console.log(chalk.gray(` JS: ${chalk.yellow(result.scriptMode)}`));
341
+ console.log(
342
+ chalk.gray(
343
+ `\n Component IDs: ${result.component}-styles, ${result.component}-script`,
344
+ ),
345
+ );
346
+ console.log("");
347
+ } catch (error) {
348
+ console.error("\n" + chalk.red("āœ— Error:"), error.message);
349
+ process.exit(1);
350
+ }
351
+ });
352
+
353
+ program
354
+ .command("list")
355
+ .description(chalk.green("List all available templates"))
356
+ .action(() => {
357
+ console.log("\n" + chalk.blue("šŸ“¦ Available Components (23 total)\n"));
358
+
359
+ console.log(chalk.yellow("━ Basic Components (9)"));
360
+ console.log(" button Styled button component");
361
+ console.log(" card Card component with image and content");
362
+ console.log(" form Form with input fields and validation");
363
+ console.log(" navigation Responsive navigation bar");
364
+ console.log(" modal Modal dialog component");
365
+ console.log(" footer Footer section");
366
+ console.log(" hero Hero section with CTA button");
367
+ console.log(" slider Image carousel with navigation");
368
+ console.log(" table Data table with search and filtering");
369
+
370
+ console.log("\n" + chalk.magenta("━ Animation Templates (4)"));
371
+ console.log(" spinner 5 loading spinner variations");
372
+ console.log(" animated-card 6 interactive card animations");
373
+ console.log(" typing-effect Text typing animations");
374
+ console.log(" fade-gallery Image gallery with fade effects");
375
+
376
+ console.log("\n" + chalk.cyan("━ Grid Layouts (3)"));
377
+ console.log(" grid-layout CSS Grid patterns and examples");
378
+ console.log(" masonry-grid Pinterest-style masonry layout");
379
+ console.log(" dashboard-grid Complete admin dashboard (Grid)");
380
+
381
+ console.log("\n" + chalk.green("━ Flexbox Layouts (3)"));
382
+ console.log(" flex-layout Flexbox patterns and examples");
383
+ console.log(" flex-cards Equal-height card layouts");
384
+ console.log(" flex-dashboard Complete admin dashboard (Flexbox)");
385
+
386
+ console.log("\n" + chalk.red("━ DOM Manipulation Examples (4)"));
387
+ console.log(" todo-list Interactive todo list with add/remove");
388
+ console.log(" counter Click counter with history tracking");
389
+ console.log(" accordion Collapsible accordion component");
390
+ console.log(" tabs Tabbed content switcher");
391
+
392
+ console.log("\n" + chalk.gray("Usage:"));
393
+ console.log(" create-template create Create a new component");
394
+ console.log(" create-template insert Insert into HTML file");
395
+ console.log("");
396
+ });
397
+
398
+ program.parse(process.argv);
399
+
400
+ if (!process.argv.slice(2).length) {
401
+ console.log("\n" + chalk.cyan("šŸŽØ Create HTML/CSS UI Templates\n"));
402
+ console.log(chalk.white("Usage: create-template [command] [options]") + "\n");
403
+ console.log(chalk.yellow("Commands:"));
404
+ console.log(" create Create a new template component");
405
+ console.log(" insert Insert component into existing HTML file");
406
+ console.log(" list Show all available templates");
407
+ console.log(" help Display help information\n");
408
+ console.log(chalk.gray("Interactive Examples:"));
409
+ console.log(" $ create-template create # Create with prompts");
410
+ console.log(" $ create-template insert # Insert with prompts");
411
+ console.log(" $ create-template list # View all 23 templates\n");
412
+ console.log(chalk.gray("Flag Examples (Non-interactive):"));
413
+ console.log(" $ create-template create -c button -n my-btn");
414
+ console.log(" $ create-template insert -f index.html -c card -s separate");
415
+ console.log(" $ create-template --help # Show full help\n");
416
+ }