create-template-html-css 2.0.4 → 2.2.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.
Files changed (99) hide show
  1. package/CHANGELOG.md +436 -0
  2. package/CODE-SPLITTING-GUIDE.md +274 -0
  3. package/COMPONENTS-GALLERY.html +143 -8
  4. package/HTML-VS-REACT.md +289 -0
  5. package/QUICKSTART-REACT.md +293 -0
  6. package/REACT-SUPPORT-SUMMARY.md +235 -0
  7. package/README.md +261 -12
  8. package/bin/cli.js +100 -759
  9. package/bin/commands/create.js +288 -0
  10. package/bin/commands/gallery.js +42 -0
  11. package/bin/commands/insert.js +123 -0
  12. package/bin/commands/list.js +73 -0
  13. package/package.json +10 -3
  14. package/src/component-choices.js +7 -0
  15. package/src/components-registry.js +112 -0
  16. package/src/format-utils.js +49 -0
  17. package/src/generator.js +83 -594
  18. package/src/generators/color-schemes.js +78 -0
  19. package/src/generators/color-utils.js +108 -0
  20. package/src/generators/component-filters.js +151 -0
  21. package/src/generators/html-generators.js +180 -0
  22. package/src/generators/validation.js +43 -0
  23. package/src/index.js +2 -1
  24. package/src/inserter.js +55 -233
  25. package/src/inserters/backup-utils.js +20 -0
  26. package/src/inserters/component-loader.js +68 -0
  27. package/src/inserters/html-utils.js +31 -0
  28. package/src/inserters/indentation-utils.js +90 -0
  29. package/src/inserters/validation-utils.js +49 -0
  30. package/src/react-component-choices.js +97 -0
  31. package/src/react-component-templates.js +182 -0
  32. package/src/react-file-operations.js +172 -0
  33. package/src/react-generator.js +219 -0
  34. package/src/react-templates.js +418 -0
  35. package/src/templates/basic-components-templates.js +157 -0
  36. package/src/templates/form-components-templates.js +194 -0
  37. package/src/templates/interactive-components-templates.js +139 -0
  38. package/src/utils/file-utils.js +97 -0
  39. package/src/utils/path-utils.js +32 -0
  40. package/src/utils/string-utils.js +51 -0
  41. package/src/utils/template-loader.js +91 -0
  42. package/templates/_shared/PATTERNS.md +246 -0
  43. package/templates/_shared/README.md +74 -0
  44. package/templates/_shared/base.css +18 -0
  45. package/templates/blackjack/index.html +1 -1
  46. package/templates/breakout/index.html +1 -1
  47. package/templates/connect-four/index.html +1 -1
  48. package/templates/dice-game/index.html +1 -1
  49. package/templates/flappy-bird/index.html +1 -1
  50. package/templates/pong/index.html +1 -1
  51. package/templates/skeleton/index.html +4 -4
  52. package/templates/slot-machine/index.html +1 -1
  53. package/templates/tetris/index.html +1 -1
  54. package/templates-react/README.md +126 -0
  55. package/templates-react/alert/Alert.css +158 -0
  56. package/templates-react/alert/Alert.example.jsx +106 -0
  57. package/templates-react/alert/Alert.jsx +61 -0
  58. package/templates-react/badge/Badge.css +196 -0
  59. package/templates-react/badge/Badge.example.jsx +182 -0
  60. package/templates-react/badge/Badge.jsx +44 -0
  61. package/templates-react/button/Button.css +88 -0
  62. package/templates-react/button/Button.example.jsx +40 -0
  63. package/templates-react/button/Button.jsx +29 -0
  64. package/templates-react/card/Card.css +86 -0
  65. package/templates-react/card/Card.example.jsx +49 -0
  66. package/templates-react/card/Card.jsx +35 -0
  67. package/templates-react/checkbox/Checkbox.css +217 -0
  68. package/templates-react/checkbox/Checkbox.example.jsx +141 -0
  69. package/templates-react/checkbox/Checkbox.jsx +82 -0
  70. package/templates-react/counter/Counter.css +99 -0
  71. package/templates-react/counter/Counter.example.jsx +45 -0
  72. package/templates-react/counter/Counter.jsx +70 -0
  73. package/templates-react/dropdown/Dropdown.css +237 -0
  74. package/templates-react/dropdown/Dropdown.example.jsx +98 -0
  75. package/templates-react/dropdown/Dropdown.jsx +154 -0
  76. package/templates-react/form/Form.css +128 -0
  77. package/templates-react/form/Form.example.jsx +64 -0
  78. package/templates-react/form/Form.jsx +125 -0
  79. package/templates-react/input/Input.css +113 -0
  80. package/templates-react/input/Input.example.jsx +82 -0
  81. package/templates-react/input/Input.jsx +87 -0
  82. package/templates-react/modal/Modal.css +152 -0
  83. package/templates-react/modal/Modal.example.jsx +90 -0
  84. package/templates-react/modal/Modal.jsx +46 -0
  85. package/templates-react/navbar/Navbar.css +139 -0
  86. package/templates-react/navbar/Navbar.example.jsx +37 -0
  87. package/templates-react/navbar/Navbar.jsx +62 -0
  88. package/templates-react/progress/Progress.css +247 -0
  89. package/templates-react/progress/Progress.example.jsx +244 -0
  90. package/templates-react/progress/Progress.jsx +79 -0
  91. package/templates-react/switch/Switch.css +244 -0
  92. package/templates-react/switch/Switch.example.jsx +221 -0
  93. package/templates-react/switch/Switch.jsx +98 -0
  94. package/templates-react/todo-list/TodoList.css +236 -0
  95. package/templates-react/todo-list/TodoList.example.jsx +15 -0
  96. package/templates-react/todo-list/TodoList.jsx +84 -0
  97. package/templates-react/tooltip/Tooltip.css +165 -0
  98. package/templates-react/tooltip/Tooltip.example.jsx +166 -0
  99. package/templates-react/tooltip/Tooltip.jsx +176 -0
package/CHANGELOG.md CHANGED
@@ -5,6 +5,442 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [Unreleased]
9
+
10
+ ### ⚛️ React Component Expansion (Part 3)
11
+
12
+ #### Added - 3 New React Components
13
+ - **Badge** - Status badge component
14
+ - 7 variants (default, primary, secondary, success, warning, error, info)
15
+ - 3 sizes (small, medium, large)
16
+ - Pill shape option
17
+ - Count badges with maxCount support (displays "99+" when exceeded)
18
+ - Dot badges for status indicators
19
+ - 4 positioning options (top-right, top-left, bottom-right, bottom-left)
20
+ - Outline style variants
21
+ - Pulse animation for attention
22
+ - Show/hide zero counts
23
+ - Dark mode support
24
+ - Use cases: notification counts, status labels, categories, priority levels
25
+
26
+ - **Switch** - Toggle switch component for on/off states
27
+ - 6 colors (primary, secondary, success, error, warning, info)
28
+ - 3 sizes (small, medium, large)
29
+ - Label with left/right positioning
30
+ - Icon support for checked/unchecked states
31
+ - Loading state with spinner animation
32
+ - Disabled state
33
+ - Controlled component with onChange handler
34
+ - Focus, hover, and active effects
35
+ - Accessibility with role and aria attributes
36
+ - Dark mode support
37
+ - Use cases: settings toggles, dark mode, sound controls, notifications
38
+
39
+ - **Progress** - Progress bar component for visual feedback
40
+ - 7 color variants (all standard colors)
41
+ - 3 sizes (small, medium, large)
42
+ - Percentage display (showPercentage)
43
+ - Custom labels (showLabel, custom label text)
44
+ - Striped pattern option
45
+ - Animated striped pattern
46
+ - Indeterminate loading state
47
+ - Min/max/value range support
48
+ - Aria attributes for accessibility
49
+ - Circular progress bonus styles
50
+ - Pulse glow animation
51
+ - Dark mode support
52
+ - Use cases: file uploads, task completion, loading states, skill levels
53
+
54
+ #### Summary
55
+ - React components expanded from 12 to 15 components
56
+ - All new components follow the same structure (ComponentName.jsx, ComponentName.css, ComponentName.example.jsx)
57
+ - Full color customization support with ##PRIMARY_COLOR## and ##SECONDARY_COLOR## placeholders
58
+ - Components work in both full project and component-only modes
59
+ - Comprehensive examples provided for each component with real-world use cases
60
+ - Advanced CSS techniques: transforms, gradients, animations, pseudo-elements
61
+ - Total new code: ~1,511 lines across 9 files
62
+
63
+ ### ⚛️ React Component Expansion (Part 2)
64
+
65
+ #### Added - 3 New React Components
66
+ - **Dropdown** - Advanced select dropdown component
67
+ - Single and multi-select support
68
+ - Searchable options
69
+ - Keyboard navigation
70
+ - Custom option rendering
71
+ - Disabled state
72
+ - Error handling and validation
73
+ - Max height customization
74
+ - Click-outside to close
75
+ - Smooth animations
76
+
77
+ - **Checkbox** - Customizable checkbox component
78
+ - Multiple sizes (small, medium, large)
79
+ - Multiple colors (primary, secondary, success, error)
80
+ - Indeterminate state support
81
+ - Label and helper text
82
+ - Error messages
83
+ - Disabled state
84
+ - Animated check mark
85
+ - Dark mode support
86
+
87
+ - **Tooltip** - Contextual tooltip component
88
+ - Four positions (top, bottom, left, right)
89
+ - Multiple triggers (hover, click, focus, both)
90
+ - Customizable delay
91
+ - Optional arrow
92
+ - Max width control
93
+ - Auto-positioning within viewport
94
+ - Smooth animations
95
+ - Disabled state
96
+
97
+ #### Summary
98
+ - React components expanded from 9 to 12 components
99
+ - All new components follow the same structure (ComponentName.jsx, ComponentName.css, ComponentName.example.jsx)
100
+ - Full color customization support with ##PRIMARY_COLOR## and ##SECONDARY_COLOR## placeholders
101
+ - Components work in both full project and component-only modes
102
+ - Comprehensive examples provided for each component
103
+
104
+ ### ⚛️ React Component Expansion (Part 1)
105
+
106
+ #### Added - 3 New React Components (v2.1.0 extended)
107
+ - **Navbar** - Responsive navigation bar with mobile hamburger menu
108
+ - Logo customization (text or component)
109
+ - Configurable menu items
110
+ - Mobile-responsive with slide-in menu
111
+ - Sticky positioning
112
+ - Smooth animations
113
+ - Click handlers for navigation
114
+
115
+ - **Input** - Advanced text input component with validation
116
+ - Multiple input types (text, email, password, etc.)
117
+ - Label and placeholder support
118
+ - Validation with error messages
119
+ - Helper text display
120
+ - Icon support
121
+ - Disabled and required states
122
+ - Focus and touch states
123
+ - Controlled and uncontrolled modes
124
+ - Max length support
125
+
126
+ - **Alert** - Notification/alert component with variants
127
+ - Four types: success, error, warning, info
128
+ - Auto-styled with type-specific colors
129
+ - Dismissible with close button
130
+ - Title and message support
131
+ - Custom icon support
132
+ - Smooth slide-in animation
133
+ - Optional close handler
134
+
135
+ #### Summary
136
+ - React components expanded from 6 to 9 components
137
+ - All new components follow the same structure (ComponentName.jsx, ComponentName.css, ComponentName.example.jsx)
138
+ - Full color customization support with ##PRIMARY_COLOR## and ##SECONDARY_COLOR## placeholders
139
+ - Components work in both full project and component-only modes
140
+
141
+ ## [2.1.0] - 2026-02-08
142
+
143
+ ### ⚛️ React Support
144
+
145
+ #### Added - React Component Generation
146
+ - **React Component Templates** - Generate React components with JSX
147
+ - Created `templates-react/` directory with 6 React components:
148
+ - Button - Customizable button with variants and sizes
149
+ - Card - Display content in elegant cards
150
+ - Counter - Interactive counter with state management
151
+ - Form - Flexible form with validation
152
+ - Modal - Dialog modal with overlay
153
+ - Todo List - Complete CRUD operations
154
+ - All components use modern React Hooks (useState, useEffect)
155
+ - Full CSS styling with customizable colors
156
+ - Dark mode support with CSS media queries
157
+ - Example files for each component
158
+
159
+ - **React Generator** - New `src/react-generator.js` module
160
+ - Generates complete React project structure with Vite
161
+ - Creates `src/components/` directory structure
162
+ - Generates `App.jsx`, `index.jsx`, and `index.html`
163
+ - Creates `package.json` with React 18 and Vite dependencies
164
+ - Generates `vite.config.js` for Vite configuration
165
+ - Generates `.gitignore` and `README.md`
166
+ - Supports color customization (schemes and custom colors)
167
+ - **Component-Only Mode**: New `addReactComponentOnly()` function
168
+ - Adds single React component (JSX + CSS) without full project structure
169
+ - Perfect for adding components to existing projects
170
+ - Validates component doesn't already exist
171
+ - Provides usage instructions after creation
172
+ - **Security**: Full input validation and sanitization
173
+ - Component name validation against whitelist
174
+ - Project name sanitization using `sanitizeFilename()`
175
+ - Protection against path traversal attacks
176
+ - Alphanumeric validation for project names
177
+ - Export functions: `generateReactTemplate()`, `addReactComponentOnly()`, `VALID_REACT_COMPONENTS`
178
+
179
+ - **React CLI Support** - Enhanced CLI with React mode
180
+ - Added `--react` flag to `create` command
181
+ - Added `--component-only` flag for adding components without full project
182
+ - Interactive framework selection (HTML or React)
183
+ - Interactive project type selection (Full project or Component only)
184
+ - React component choices loaded dynamically
185
+ - Created `src/react-component-choices.js` with component descriptions
186
+ - Updated CLI help messages to mention React support
187
+ - Updated main CLI description to include React
188
+
189
+ - **React Documentation**
190
+ - Created `templates-react/README.md` with usage guide
191
+
192
+ #### Fixed
193
+ - **JSX File Extension**: Changed `index.js` to `index.jsx` to properly support JSX syntax
194
+ - Vite requires `.jsx` extension for files containing JSX
195
+ - Updated generator to create `index.jsx` instead of `index.js`
196
+ - Updated `index.html` reference to `/src/index.jsx`
197
+ - Prevents "Failed to parse source for import analysis" errors
198
+ - Created `QUICKSTART-REACT.md` - Quick start guide for React
199
+ - Created `HTML-VS-REACT.md` - Comprehensive comparison guide
200
+ - Updated main `README.md` with React sections:
201
+ - "React Support" in What's New
202
+ - "Mode 1b: Create a React Component Project" usage guide
203
+ - React component descriptions and examples
204
+ - Added React keywords to `package.json`
205
+ - Updated version to 2.1.0
206
+
207
+ #### Security Enhancements
208
+ - **Enhanced Input Validation** - Strengthened security across all components
209
+ - All user inputs are validated and sanitized
210
+ - Path traversal protection (blocks ../, ..\, /../, \..\ patterns)
211
+ - Project name length validation (max 100 characters)
212
+ - Alphanumeric character requirement for names
213
+ - Dangerous character removal (<>:"|?*)
214
+ ### 🔧 Code Quality & Architecture Improvements
215
+
216
+ #### Refactored - React Generator Module Split
217
+ - **Major Refactoring**: Split `react-generator.js` (659 lines) into focused modules
218
+ - Reduced main file by **73%** (176 lines)
219
+ - Better separation of concerns and maintainability
220
+
221
+ - **New Module Structure**:
222
+ - `src/react-generator.js` (176 lines) - Main export functions and validation
223
+ - `generateReactTemplate()` - Full React project generation
224
+ - `addReactComponentOnly()` - Component-only mode
225
+ - `validateComponent()` - Component name validation
226
+ - Exports `VALID_REACT_COMPONENTS` constant
227
+
228
+ - `src/react-templates.js` (303 lines) - Template generation functions
229
+ - `generateAppJsx()` - App component with examples
230
+ - `generateIndexJs()` - React entry point
231
+ - `generateIndexHtml()` - HTML template
232
+ - `generatePackageJson()` - Package configuration
233
+ - `generateGitignore()` - Git ignore file
234
+ - `generateViteConfig()` - Vite configuration
235
+ - `generateReadme()` - Project README
236
+ - Version constants: `REACT_VERSION`, `VITE_VERSION`, `VITE_REACT_PLUGIN_VERSION`
237
+
238
+ - `src/react-file-operations.js` (148 lines) - File I/O and utilities
239
+ - `readComponentFiles()` - Read and process templates
240
+ - `writeComponentFiles()` - Write JSX and CSS files
241
+ - `createReactProjectStructure()` - Create project directories
242
+ - `toPascalCase()` - Convert names to PascalCase
243
+ - `resolveColors()` - Resolve color schemes
244
+ - Color constants: `DEFAULT_PRIMARY_COLOR`, `DEFAULT_SECONDARY_COLOR`
245
+
246
+ - **Code Organization Improvements**:
247
+ - Extracted common helper functions to reduce duplication
248
+ - Simplified App.jsx template generation with `createAppTemplate()`
249
+ - Added clear section headers for better code navigation
250
+ - Extracted magic values into named constants
251
+ - Organized code into logical sections (CONSTANTS, UTILITIES, VALIDATORS, etc.)
252
+
253
+ #### Benefits
254
+ - **Maintainability**: Each module has single responsibility
255
+ - **Testability**: Easier to test focused modules independently
256
+ - **Readability**: Clear separation between templates, file operations, and main logic
257
+ - **Performance**: Better tree-shaking with modular exports
258
+ - **Developer Experience**: Easier to find and modify specific functionality
259
+
260
+ #### Testing
261
+ - ✅ All functionality preserved - no breaking changes
262
+ - ✅ Full project generation tested and working
263
+ - ✅ Component-only mode tested and working
264
+ - ✅ All React components generate correctly
265
+ - ✅ No syntax or runtime errors - Component name whitelist validation
266
+ - Empty/null input rejection
267
+
268
+ - **Secure File Operations** - Protected file system operations
269
+ - All file paths use `path.join()` to prevent traversal
270
+ - Directory creation with `recursive: true` safely
271
+ - Output directory restricted to `process.cwd()` subdirectories
272
+ - No arbitrary file system access allowed
273
+
274
+ - **Example Usage:**
275
+ ```bash
276
+ # Interactive mode
277
+ create-template create --react
278
+
279
+ # With flags
280
+ create-template create --react -c button -n my-button
281
+ create-template create --react -c counter -n my-counter --color-scheme ocean
282
+
283
+ # Run the React project
284
+ cd my-counter
285
+ npm install
286
+ npm run dev
287
+ ```
288
+
289
+ ### 🏗️ Major Refactoring
290
+
291
+ #### Changed - Code Deduplication
292
+
293
+ #### Fixed - Template Consistency
294
+ - **Standardized Template HTML Syntax** - Fixed inconsistencies across templates
295
+ - Fixed `skeleton` template to use HTML5 syntax instead of XHTML (removed `/` from void elements)
296
+ - Added missing `{{name}}` placeholder to 8 game templates:
297
+ - `blackjack`, `breakout`, `connect-four`, `dice-game`, `flappy-bird`, `pong`, `slot-machine`, `tetris`
298
+ - All 42 templates now consistently use HTML5 syntax
299
+ - All templates now support custom naming via `{{name}}` placeholder
300
+ - Improved template generation consistency
301
+
302
+ - **Enhanced Template Documentation** - Improved templates/_shared directory
303
+ - Updated `README.md` with comprehensive philosophy and statistics
304
+ - Created `PATTERNS.md` documenting 15+ recurring code patterns
305
+ - Created `CONTRIBUTING.md` with complete template development guide
306
+ - Documented intentional CSS/JS duplication strategy (42 self-contained templates)
307
+ - Added statistics: 42 templates with CSS reset, 37 with gradient backgrounds
308
+ - Clarified that templates are intentionally standalone for copy-paste usage
309
+ - Better onboarding for contributors understanding template architecture
310
+
311
+ - **Centralized String Utilities** - Eliminated duplicate string manipulation patterns
312
+ - Created `src/utils/string-utils.js` with reusable string functions
313
+ - Extracted functions:
314
+ - `textToId()` - Convert text to valid HTML/CSS ID (e.g., "My Item" → "my-item")
315
+ - `sanitizeForFilename()` - Remove invalid filename characters
316
+ - `parseCommaSeparated()` - Parse comma-separated lists with trimming
317
+ - `parseKeyValuePairs()` - Parse "key:value" comma-separated pairs
318
+ - Refactored `src/generators/html-generators.js` to use string utilities (23 lines net reduction)
319
+ - Refactored `src/generators/validation.js` to use string utilities
320
+ - Fixed `src/generator.js` to properly use `createComponentDirs()` (6 lines reduction)
321
+ - Eliminated 3 duplicate instances of `.toLowerCase().replace(/\s+/g, "-")` pattern
322
+ - More consistent string handling across codebase
323
+
324
+ - **Centralized Template Loading** - Eliminated duplicate template file reading
325
+ - Created `src/utils/template-loader.js` with reusable template reading functions
326
+ - Extracted functions:
327
+ - `getTemplatePath()` - Get template directory path
328
+ - `readTemplateFile()` - Read any template file
329
+ - `readTemplateHtml()` - Read template HTML with fallback logic
330
+ - `readTemplateCss()` - Read template CSS with css/ subfolder support
331
+ - `readTemplateJs()` - Read template JS with js/ subfolder support
332
+ - `hasTemplateJs()` - Check if template has JavaScript
333
+ - Refactored `src/generator.js` to use template loader (12 lines net reduction)
334
+ - Refactored `src/inserters/component-loader.js` to use template loader (8 lines net reduction)
335
+ - Eliminated repetitive `fs.readFile()` and `path.join()` patterns
336
+ - More consistent template file handling across codebase
337
+
338
+ - **Centralized File Operations** - Eliminated duplicate file system operations
339
+ - Created `src/utils/file-utils.js` with reusable file operation functions
340
+ - Extracted functions:
341
+ - `ensureDir()` - Create directory with parents
342
+ - `ensureDirs()` - Create multiple directories
343
+ - `writeHtmlFile()` - Write formatted HTML files
344
+ - `writeCssFile()` - Write formatted CSS files
345
+ - `writeJsFile()` - Write formatted JS files
346
+ - `createComponentDirs()` - Create component directory structure
347
+ - `writeComponentFiles()` - Write all component files atomically
348
+ - Refactored `src/generator.js` to use file utilities (reduced by 11 lines)
349
+ - Refactored `src/inserter.js` to use file utilities (reduced by 9 lines)
350
+ - Eliminated repetitive `fs.mkdir({recursive: true})` and `fs.writeFile()` patterns
351
+ - More consistent error handling and file formatting
352
+
353
+ - **Centralized Indentation Logic** - Eliminated duplicate indentation handling
354
+ - Created `src/inserters/indentation-utils.js` with reusable indentation functions
355
+ - Extracted functions:
356
+ - `normalizeIndentation()` - Normalize content with base indentation
357
+ - `createInlineStyleTag()` - Generate inline style tags
358
+ - `createInlineScriptTag()` - Generate inline script tags
359
+ - `createStyleLink()` - Generate external stylesheet links
360
+ - `createScriptTag()` - Generate external script tags
361
+ - `createComponentInsertion()` - Generate component HTML with comment
362
+ - Refactored `src/inserter.js` to use utilities
363
+ - Reduced inserter.js from 206 to 163 lines (21% reduction)
364
+ - Eliminated ~40 lines of duplicate indentation normalization logic
365
+ - More maintainable and testable code
366
+
367
+ - **Centralized Path Utilities** - Eliminated __dirname duplication in ES Modules
368
+ - Created `src/utils/path-utils.js` with `getDirname()` and `getFilename()` utilities
369
+ - Replaced repetitive `fileURLToPath` + `dirname` pattern in 3 files:
370
+ - `src/generator.js` - Now uses `getDirname(import.meta.url)`
371
+ - `src/inserters/component-loader.js` - Now uses `getDirname(import.meta.url)`
372
+ - `bin/commands/gallery.js` - Now uses `getDirname(import.meta.url)`
373
+ - Cleaner, more maintainable ES Modules __dirname handling
374
+ - Reduced boilerplate by ~15 lines
375
+
376
+ - **Centralized Components Registry** - Eliminated duplicate component lists
377
+ - Created `src/components-registry.js` as single source of truth
378
+ - Contains `VALID_COMPONENTS` array (46 components, alphabetically sorted)
379
+ - Contains `COMPONENT_CHOICES` with categorized prompts
380
+ - Removed duplicates from:
381
+ - `src/generators/validation.js` - Now imports from registry
382
+ - `src/inserters/validation-utils.js` - Now imports from registry
383
+ - `src/component-choices.js` - Now re-exports from registry (deprecated)
384
+ - Reduced code duplication by ~130 lines
385
+ - Single maintenance point for component additions
386
+
387
+ #### Changed - Inserter Module Architecture
388
+ - **Modular Inserter Structure** - Split 327-line inserter.js into organized modules
389
+ - Main inserter.js reduced from 327 to 206 lines (37% reduction)
390
+ - New `src/inserters/` directory with specialized modules:
391
+ - `validation-utils.js` (93 lines) - Component validation, HTML structure validation
392
+ - `html-utils.js` (31 lines) - HTML indentation detection and manipulation
393
+ - `backup-utils.js` (19 lines) - File backup creation utilities
394
+ - `component-loader.js` (95 lines) - Template loading for HTML, CSS, and JS files
395
+ - Better separation of concerns and maintainability
396
+ - Security validation maintained throughout refactor
397
+
398
+ #### Changed - Generator Module Architecture
399
+ - **Modular Generator Structure** - Split massive 661-line generator.js into organized modules
400
+ - Main generator.js reduced from 661 to 166 lines (75% reduction!)
401
+ - New `src/generators/` directory with specialized modules:
402
+ - `color-schemes.js` (76 lines) - All color presets and scheme management
403
+ - `color-utils.js` (93 lines) - Color manipulation utilities and dark mode
404
+ - `component-filters.js` (135 lines) - Button, card, spinner variations filtering
405
+ - `html-generators.js` (171 lines) - Navigation and form field generation
406
+ - `validation.js` (61 lines) - Component validation and security utilities
407
+ - Better separation of concerns and maintainability
408
+ - Improved code organization and testability
409
+
410
+ #### Changed - CLI Module Architecture
411
+ - **ES Modules Migration** - Converted entire codebase from CommonJS to ES Modules
412
+ - All `require()` statements replaced with `import`
413
+ - All `module.exports` replaced with `export`
414
+ - Added `"type": "module"` to package.json
415
+ - Updated dynamic imports for optional dependencies (Prettier)
416
+ - Proper `__dirname` support using `fileURLToPath` and `dirname`
417
+
418
+ - **Modular CLI Architecture** - Refactored CLI from single 618-line file to organized structure
419
+ - Main CLI file reduced from 618 to 85 lines (86% reduction!)
420
+ - Commands split into separate modules in `bin/commands/` directory
421
+ - `create.js` - 174 lines (handles template creation with prompts)
422
+ - `insert.js` - 123 lines (handles component insertion into HTML)
423
+ - `list.js` - 73 lines (displays all 46 available components)
424
+ - `gallery.js` - 42 lines (opens interactive component gallery)
425
+ - Total reduction: 618 lines → 497 lines across 5 files
426
+
427
+ #### Added
428
+ - **Enhanced Security** - Comprehensive input validation for component names
429
+ - Blocks path traversal attacks (`../`, `..\`, `/../`, `\..\`)
430
+ - Prevents path separator usage in component names (`/`, `\`)
431
+ - Validates both interactive prompts and command-line flags
432
+ - Maximum name length limit (100 characters)
433
+ - Allows legitimate names with dots (e.g., "my-component-2.0")
434
+ - Protects against directory traversal to parent/system directories
435
+
436
+ #### Technical Improvements
437
+ - Better code maintainability with modular architecture
438
+ - Improved performance with ES Modules tree-shaking
439
+ - Cleaner separation of concerns (each command in its own file)
440
+ - Enhanced error handling and validation
441
+ - All file imports include `.js` extension (ES Modules requirement)
442
+ - Cross-platform `__dirname` support in ES Modules environment
443
+
8
444
  ## [2.0.2] - 2026-02-05
9
445
 
10
446
  ### Fixed