create-template-html-css 2.0.4 → 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/breakout/index.html +1 -1
- package/templates/connect-four/index.html +1 -1
- package/templates/dice-game/index.html +1 -1
- package/templates/flappy-bird/index.html +1 -1
- package/templates/pong/index.html +1 -1
- package/templates/skeleton/index.html +4 -4
- package/templates/slot-machine/index.html +1 -1
- package/templates/tetris/index.html +1 -1
- 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/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
# Create Template HTML/CSS
|
|
1
|
+
# Create Template HTML/CSS 🎨⚛️
|
|
2
2
|
|
|
3
|
-
A powerful CLI library to create HTML+CSS
|
|
3
|
+
A powerful CLI library to create HTML+CSS and React component templates. Generate styled UI components in seconds!
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/create-template-html-css)
|
|
6
6
|
[](https://www.npmjs.com/package/create-template-html-css)
|
|
@@ -28,12 +28,13 @@ npm install -g create-template-html-css
|
|
|
28
28
|
## ✨ Features
|
|
29
29
|
|
|
30
30
|
- 🚀 **Fast Creation** - Create UI components in seconds
|
|
31
|
+
- ⚛️ **React Support** - Generate React components with JSX (v2.1.0+)
|
|
31
32
|
- 🎨 **Modern Design** - All templates are designed with high standards
|
|
32
33
|
- 📱 **Responsive** - All components adapt to mobile devices
|
|
33
34
|
- 🌈 **Stunning Gradients** - Colorful and attractive designs
|
|
34
35
|
- ⚡ **Animations** - Smooth and professional effects
|
|
35
36
|
- 🔧 **Customizable** - Easy to edit and modify the code
|
|
36
|
-
- 📦 **46 Templates** - Button, Card, Form, Navigation, Modal, Footer, Hero, Slider, Table, Login, Register, Skeleton, Spinner, Animated Cards, Typing Effect, Fade Gallery, Grid Layouts, Masonry Grid, Dashboard, Flexbox Layouts, Todo List, Counter, Accordion, Tabs, 16 Interactive Games
|
|
37
|
+
- 📦 **46 HTML Templates + 6 React Components** - Button, Card, Form, Navigation, Modal, Footer, Hero, Slider, Table, Login, Register, Skeleton, Spinner, Animated Cards, Typing Effect, Fade Gallery, Grid Layouts, Masonry Grid, Dashboard, Flexbox Layouts, Todo List, Counter, Accordion, Tabs, 16 Interactive Games
|
|
37
38
|
- 🎯 **Two Modes** - Create new projects or insert into existing HTML pages
|
|
38
39
|
- 🔒 **Secure** - Input validation and path protection
|
|
39
40
|
- 📚 **Well Documented** - Comprehensive guides and examples
|
|
@@ -42,6 +43,66 @@ npm install -g create-template-html-css
|
|
|
42
43
|
- 📂 **Organized Structure** - CSS and JS files automatically organized in folders (v1.6.2+)
|
|
43
44
|
- 💾 **Simple Backups** - Clean backup naming without timestamps (v1.6.2+)
|
|
44
45
|
- 🎯 **Customizable Components** - Choose navigation items and form fields during creation (v1.7.0+)
|
|
46
|
+
- 🏗️ **Modern Architecture** - ES Modules for better performance and tree-shaking (v2.1.0+)
|
|
47
|
+
- 🧩 **Modular CLI** - Refactored command structure for better maintainability (v2.1.0+)
|
|
48
|
+
- ⚡ **Vite Integration** - React projects use Vite for fast development (v2.1.0+)
|
|
49
|
+
|
|
50
|
+
## 🆕 What's New in v2.1.0
|
|
51
|
+
|
|
52
|
+
### ⚛️ **React Support**
|
|
53
|
+
- **React Components** - Generate React components with JSX
|
|
54
|
+
- **6 React Components** - Button, Card, Counter, Form, Modal, Todo List
|
|
55
|
+
- **Two Modes**:
|
|
56
|
+
- **Full Project** - Complete React + Vite project with all dependencies
|
|
57
|
+
- **Component Only** - Just JSX + CSS files for existing projects
|
|
58
|
+
- **Vite Integration** - Fast development with Vite build tool
|
|
59
|
+
- **Modern Hooks** - All components use React Hooks (useState, useEffect, etc.)
|
|
60
|
+
- **TypeScript Ready** - Easy to convert to TypeScript
|
|
61
|
+
- **Full Project Setup** - Includes package.json, vite.config.js, and project structure
|
|
62
|
+
|
|
63
|
+
**Create Full React Project:**
|
|
64
|
+
```bash
|
|
65
|
+
# Interactive mode
|
|
66
|
+
create-template create --react
|
|
67
|
+
|
|
68
|
+
# With flags
|
|
69
|
+
create-template create --react -c button -n my-button
|
|
70
|
+
create-template create --react -c counter -n my-counter
|
|
71
|
+
create-template create --react -c todo-list -n my-todos
|
|
72
|
+
|
|
73
|
+
# With custom colors
|
|
74
|
+
create-template create --react -c card -n my-card --color-scheme ocean
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
**Add Component to Existing Project (Component Only Mode):**
|
|
78
|
+
```bash
|
|
79
|
+
# Interactive mode (choose "Component only")
|
|
80
|
+
create-template create --react
|
|
81
|
+
|
|
82
|
+
# With flags - adds component to current directory
|
|
83
|
+
create-template create --react --component-only -c button --color-scheme sunset
|
|
84
|
+
create-template create --react --component-only -c card --color-scheme ocean
|
|
85
|
+
|
|
86
|
+
# Navigate to your project's components folder first
|
|
87
|
+
cd my-app/src/components
|
|
88
|
+
create-template create --react --component-only -c modal --color-scheme vibrant
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
**Component Only Mode:**
|
|
92
|
+
- Creates just `ComponentName/ComponentName.jsx` and `ComponentName/ComponentName.css`
|
|
93
|
+
- Perfect for adding to existing React projects
|
|
94
|
+
- No package.json, no Vite config, no extra files
|
|
95
|
+
- Validates that component doesn't already exist
|
|
96
|
+
- Works with all color schemes
|
|
97
|
+
- Usage instructions displayed after creation
|
|
98
|
+
|
|
99
|
+
**Available React Components:**
|
|
100
|
+
- 🔘 **Button** - Customizable button with variants (primary, secondary, success, danger) and sizes
|
|
101
|
+
- 🎴 **Card** - Display content in an elegant card with image support
|
|
102
|
+
- 🔢 **Counter** - Interactive counter with increment/decrement and limits
|
|
103
|
+
- 📝 **Form** - Flexible form with validation and multiple field types
|
|
104
|
+
- 🪟 **Modal** - Dialog modal component with overlay
|
|
105
|
+
- ✅ **Todo List** - Complete todo list with CRUD operations
|
|
45
106
|
|
|
46
107
|
## 🆕 What's New in v2.0.0
|
|
47
108
|
|
|
@@ -326,10 +387,89 @@ $ create-template create
|
|
|
326
387
|
```
|
|
327
388
|
my-awesome-button/
|
|
328
389
|
├── index.html
|
|
329
|
-
├──
|
|
330
|
-
└──
|
|
390
|
+
├── css/
|
|
391
|
+
│ └── style.css
|
|
392
|
+
└── js/
|
|
393
|
+
└── script.js
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
### Mode 1b: Create a React Component Project ⚛️
|
|
397
|
+
|
|
398
|
+
Generate a complete React project with Vite:
|
|
399
|
+
|
|
400
|
+
```bash
|
|
401
|
+
create-template create --react
|
|
402
|
+
```
|
|
403
|
+
|
|
404
|
+
Follow the interactive prompts:
|
|
405
|
+
1. **Select Framework** - Choose React
|
|
406
|
+
2. **Select Component Type** - Choose from Button, Card, Counter, Form, Modal, Todo List
|
|
407
|
+
3. **Enter Component Name** - Give your project a meaningful name
|
|
408
|
+
4. **Choose Color Scheme** (optional) - Select from preset schemes or enter custom colors
|
|
409
|
+
|
|
410
|
+
**Example (Basic):**
|
|
411
|
+
|
|
412
|
+
```bash
|
|
413
|
+
$ create-template create --react
|
|
414
|
+
? What framework would you like to use? React (JSX + CSS)
|
|
415
|
+
? Choose a component type: Counter
|
|
416
|
+
? Enter a name for your component: my-counter
|
|
417
|
+
? Choose a color scheme: (Use arrow keys)
|
|
418
|
+
❯ Ocean - Professional blue gradient
|
|
419
|
+
Sunset - Warm orange to yellow gradient
|
|
420
|
+
Forest - Natural green gradient
|
|
421
|
+
✓ React component created successfully!
|
|
422
|
+
Location: ./my-counter/
|
|
331
423
|
```
|
|
332
424
|
|
|
425
|
+
**Example (With Flags):**
|
|
426
|
+
|
|
427
|
+
```bash
|
|
428
|
+
# Create React button with custom colors
|
|
429
|
+
create-template create --react -c button -n my-button --primary-color "#FF5733"
|
|
430
|
+
|
|
431
|
+
# Create React todo list with ocean color scheme
|
|
432
|
+
create-template create --react -c todo-list -n my-todos --color-scheme ocean
|
|
433
|
+
|
|
434
|
+
# Create React modal
|
|
435
|
+
create-template create --react -c modal -n my-modal
|
|
436
|
+
```
|
|
437
|
+
|
|
438
|
+
**Result:**
|
|
439
|
+
```
|
|
440
|
+
my-counter/
|
|
441
|
+
├── src/
|
|
442
|
+
│ ├── components/
|
|
443
|
+
│ │ └── Counter/
|
|
444
|
+
│ │ ├── Counter.jsx
|
|
445
|
+
│ │ └── Counter.css
|
|
446
|
+
│ ├── App.jsx
|
|
447
|
+
│ └── index.js
|
|
448
|
+
├── index.html
|
|
449
|
+
├── package.json
|
|
450
|
+
├── vite.config.js
|
|
451
|
+
├── .gitignore
|
|
452
|
+
└── README.md
|
|
453
|
+
```
|
|
454
|
+
|
|
455
|
+
**Running the React Project:**
|
|
456
|
+
|
|
457
|
+
```bash
|
|
458
|
+
cd my-counter
|
|
459
|
+
npm install
|
|
460
|
+
npm run dev
|
|
461
|
+
```
|
|
462
|
+
|
|
463
|
+
Open [http://localhost:5173](http://localhost:5173) in your browser.
|
|
464
|
+
|
|
465
|
+
**Available React Components:**
|
|
466
|
+
- 🔘 **Button** - Variants: primary, secondary, success, danger | Sizes: small, medium, large
|
|
467
|
+
- 🎴 **Card** - Image, title, description, footer support with hover effects
|
|
468
|
+
- 🔢 **Counter** - Increment/decrement with limits, step customization, reset button
|
|
469
|
+
- 📝 **Form** - Multiple field types, built-in validation, error messages
|
|
470
|
+
- 🪟 **Modal** - Customizable sizes (small, medium, large), overlay, close handlers
|
|
471
|
+
- ✅ **Todo List** - Add, toggle complete, delete tasks with statistics
|
|
472
|
+
|
|
333
473
|
### Mode 2: Insert Component into Existing HTML Page
|
|
334
474
|
|
|
335
475
|
Add components directly to your existing HTML files without creating new projects:
|
|
@@ -1020,15 +1160,56 @@ See [SECURITY.md](SECURITY.md) for more details.
|
|
|
1020
1160
|
|
|
1021
1161
|
## 🔒 Security
|
|
1022
1162
|
|
|
1023
|
-
This project includes security features to protect your files:
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
- **
|
|
1027
|
-
-
|
|
1163
|
+
This project includes comprehensive security features to protect your files and data:
|
|
1164
|
+
|
|
1165
|
+
### Input Validation & Sanitization
|
|
1166
|
+
- **Component Whitelist** - Only validated components can be created/inserted
|
|
1167
|
+
- HTML templates: 46 components validated against `VALID_COMPONENTS`
|
|
1168
|
+
- React components: 6 components validated against `VALID_REACT_COMPONENTS`
|
|
1169
|
+
- **Project Name Sanitization** - All user-provided names are sanitized
|
|
1170
|
+
- Path traversal protection (blocks `../`, `..\`, `/../`, etc.)
|
|
1171
|
+
- Length validation (max 100 characters)
|
|
1172
|
+
- Alphanumeric character requirement
|
|
1173
|
+
- Dangerous character removal (`<>:"|?*`)
|
|
1174
|
+
- Empty/null input rejection
|
|
1175
|
+
- **Color Validation** - Hex color codes validated with regex pattern
|
|
1028
1176
|
- **HTML Structure Validation** - Ensures proper HTML structure before insertion
|
|
1029
|
-
- **Zero Dependencies for Security** - Uses only Node.js built-in modules for security checks
|
|
1030
1177
|
|
|
1031
|
-
|
|
1178
|
+
### Path Security
|
|
1179
|
+
- **Path Traversal Protection** - Prevents access outside working directory
|
|
1180
|
+
- All file operations use `path.join()` for safe path construction
|
|
1181
|
+
- Output directories restricted to `process.cwd()` subdirectories
|
|
1182
|
+
- No arbitrary file system access allowed
|
|
1183
|
+
- **Safe File Operations** - All file system operations are protected
|
|
1184
|
+
- Directory creation uses `recursive: true` safely
|
|
1185
|
+
- File writes validated before execution
|
|
1186
|
+
- Backup creation before file modifications
|
|
1187
|
+
|
|
1188
|
+
### Code Security
|
|
1189
|
+
- **Zero External Dependencies for Security** - Uses only Node.js built-in modules for security checks
|
|
1190
|
+
- **ES Modules** - Modern module system prevents prototype pollution
|
|
1191
|
+
- **Strict Mode** - All code runs in JavaScript strict mode
|
|
1192
|
+
- **No eval()** - No dynamic code execution
|
|
1193
|
+
|
|
1194
|
+
### Security Best Practices
|
|
1195
|
+
- **Input Validation**: All user inputs validated before processing
|
|
1196
|
+
- **Whitelist Approach**: Component selection validated against predefined lists
|
|
1197
|
+
- HTML: 46 validated components
|
|
1198
|
+
- React: 6 validated components (`VALID_REACT_COMPONENTS`)
|
|
1199
|
+
- **Path Sanitization**: All file paths sanitized using `sanitizeFilename()`
|
|
1200
|
+
- Prevents path traversal attacks (../, ../../, etc.)
|
|
1201
|
+
- Blocks dangerous characters and patterns
|
|
1202
|
+
- Validates alphanumeric names only
|
|
1203
|
+
- **Component-Only Mode Security**:
|
|
1204
|
+
- Validates component doesn't already exist
|
|
1205
|
+
- Checks for directory conflicts
|
|
1206
|
+
- Safe output directory handling
|
|
1207
|
+
- **File System Protection**: Safe file operations with error handling
|
|
1208
|
+
- **No Code Injection**: Template-based generation prevents code injection
|
|
1209
|
+
- **Clear Error Messages**: Informative errors without exposing system details
|
|
1210
|
+
- **Regular Security Audits**: Dependencies updated and audited regularly
|
|
1211
|
+
|
|
1212
|
+
For security concerns or to report vulnerabilities, see [SECURITY.md](SECURITY.md)
|
|
1032
1213
|
|
|
1033
1214
|
## 🤝 Contributing
|
|
1034
1215
|
|