svger-cli 2.0.1 → 2.0.3
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/.svgerconfig.example.json +38 -0
- package/CHANGELOG.md +64 -0
- package/DEVELOPMENT.md +353 -0
- package/README.md +24 -5
- package/SECURITY.md +69 -0
- package/dist/builder.js +16 -16
- package/dist/clean.js +2 -2
- package/dist/cli.js +38 -38
- package/dist/config.js +11 -11
- package/dist/core/error-handler.d.ts +63 -0
- package/dist/core/error-handler.js +227 -0
- package/dist/core/framework-templates.d.ts +17 -0
- package/{src/core/framework-templates.ts → dist/core/framework-templates.js} +104 -139
- package/dist/core/logger.d.ts +22 -0
- package/dist/core/logger.js +85 -0
- package/dist/core/performance-engine.d.ts +67 -0
- package/dist/core/performance-engine.js +252 -0
- package/dist/core/plugin-manager.d.ts +56 -0
- package/dist/core/plugin-manager.js +191 -0
- package/dist/core/style-compiler.d.ts +88 -0
- package/dist/core/style-compiler.js +468 -0
- package/dist/core/template-manager.d.ts +64 -0
- package/{src/core/template-manager.ts → dist/core/template-manager.js} +172 -255
- package/dist/index.d.ts +153 -0
- package/{src/index.ts → dist/index.js} +32 -110
- package/dist/lock.js +7 -7
- package/dist/processors/svg-processor.d.ts +73 -0
- package/dist/processors/svg-processor.js +261 -0
- package/dist/services/config.d.ts +55 -0
- package/dist/services/config.js +211 -0
- package/dist/services/file-watcher.d.ts +54 -0
- package/dist/services/file-watcher.js +180 -0
- package/dist/services/svg-service.d.ts +81 -0
- package/dist/services/svg-service.js +395 -0
- package/dist/templates/ComponentTemplate.js +25 -25
- package/dist/types/index.d.ts +146 -0
- package/dist/types/index.js +4 -0
- package/dist/utils/native.d.ts +104 -0
- package/dist/utils/native.js +340 -0
- package/dist/watch.d.ts +1 -1
- package/dist/watch.js +14 -14
- package/package.json +154 -14
- package/.svgconfig.json +0 -3
- package/CODE_OF_CONDUCT.md +0 -79
- package/CONTRIBUTING.md +0 -146
- package/TESTING.md +0 -143
- package/cli-framework.test.js +0 -16
- package/cli-test-angular/Arrowbenddownleft.component.ts +0 -27
- package/cli-test-angular/Vite.component.ts +0 -27
- package/cli-test-angular/index.ts +0 -25
- package/cli-test-output/Arrowbenddownleft.vue +0 -33
- package/cli-test-output/Vite.vue +0 -33
- package/cli-test-output/index.ts +0 -25
- package/cli-test-react/Arrowbenddownleft.tsx +0 -39
- package/cli-test-react/Vite.tsx +0 -39
- package/cli-test-react/index.ts +0 -25
- package/cli-test-svelte/Arrowbenddownleft.svelte +0 -22
- package/cli-test-svelte/Vite.svelte +0 -22
- package/cli-test-svelte/index.ts +0 -25
- package/frameworks.test.js +0 -170
- package/my-svgs/ArrowBendDownLeft.svg +0 -6
- package/my-svgs/vite.svg +0 -1
- package/src/builder.ts +0 -104
- package/src/clean.ts +0 -21
- package/src/cli.ts +0 -221
- package/src/config.ts +0 -81
- package/src/core/error-handler.ts +0 -303
- package/src/core/logger.ts +0 -104
- package/src/core/performance-engine.ts +0 -327
- package/src/core/plugin-manager.ts +0 -228
- package/src/core/style-compiler.ts +0 -605
- package/src/lock.ts +0 -74
- package/src/processors/svg-processor.ts +0 -288
- package/src/services/config.ts +0 -241
- package/src/services/file-watcher.ts +0 -218
- package/src/services/svg-service.ts +0 -468
- package/src/templates/ComponentTemplate.ts +0 -57
- package/src/types/index.ts +0 -169
- package/src/utils/native.ts +0 -352
- package/src/watch.ts +0 -88
- package/test-output-mulit/TestIcon-angular-module.component.ts +0 -26
- package/test-output-mulit/TestIcon-angular-standalone.component.ts +0 -27
- package/test-output-mulit/TestIcon-lit.ts +0 -35
- package/test-output-mulit/TestIcon-preact.tsx +0 -38
- package/test-output-mulit/TestIcon-react.tsx +0 -35
- package/test-output-mulit/TestIcon-solid.tsx +0 -27
- package/test-output-mulit/TestIcon-svelte.svelte +0 -22
- package/test-output-mulit/TestIcon-vanilla.ts +0 -37
- package/test-output-mulit/TestIcon-vue-composition.vue +0 -33
- package/test-output-mulit/TestIcon-vue-options.vue +0 -31
- package/tsconfig.json +0 -18
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://raw.githubusercontent.com/faezemohades/svger-cli/main/schemas/config.schema.json",
|
|
3
|
+
"source": "./src/assets/svg",
|
|
4
|
+
"output": "./src/components/icons",
|
|
5
|
+
"framework": "react",
|
|
6
|
+
"typescript": true,
|
|
7
|
+
"watch": false,
|
|
8
|
+
"parallel": true,
|
|
9
|
+
"batchSize": 10,
|
|
10
|
+
"defaultWidth": 24,
|
|
11
|
+
"defaultHeight": 24,
|
|
12
|
+
"defaultFill": "currentColor",
|
|
13
|
+
"exclude": [],
|
|
14
|
+
"styleRules": {
|
|
15
|
+
"fill": "inherit",
|
|
16
|
+
"stroke": "none"
|
|
17
|
+
},
|
|
18
|
+
"responsive": {
|
|
19
|
+
"enabled": false,
|
|
20
|
+
"breakpoints": ["sm", "md", "lg"],
|
|
21
|
+
"values": {
|
|
22
|
+
"width": ["20px", "24px", "32px"],
|
|
23
|
+
"height": ["20px", "24px", "32px"]
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"theme": {
|
|
27
|
+
"mode": "light",
|
|
28
|
+
"variables": {
|
|
29
|
+
"primary": "#007bff",
|
|
30
|
+
"secondary": "#6c757d"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"performance": {
|
|
34
|
+
"optimization": "balanced",
|
|
35
|
+
"cache": true,
|
|
36
|
+
"memoryLimit": 512
|
|
37
|
+
}
|
|
38
|
+
}
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [2.0.3] - 2024-11-11
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- Enhanced package.json with comprehensive metadata
|
|
12
|
+
- Professional development tooling configuration
|
|
13
|
+
- Extended TypeScript support and type definitions
|
|
14
|
+
- Additional CLI aliases (`svger` shorthand)
|
|
15
|
+
- Comprehensive export map for better module resolution
|
|
16
|
+
- Development scripts for testing, linting, and formatting
|
|
17
|
+
- Documentation generation scripts
|
|
18
|
+
|
|
19
|
+
### Changed
|
|
20
|
+
- Improved package description with full feature list
|
|
21
|
+
- Enhanced keywords for better discoverability
|
|
22
|
+
- Updated contributor information with roles
|
|
23
|
+
- Expanded file inclusion patterns
|
|
24
|
+
- More comprehensive engine requirements
|
|
25
|
+
|
|
26
|
+
### Fixed
|
|
27
|
+
- Package metadata completeness
|
|
28
|
+
- Export definitions for better tree-shaking
|
|
29
|
+
- Module resolution issues
|
|
30
|
+
|
|
31
|
+
## [2.0.2] - 2024-11-01
|
|
32
|
+
|
|
33
|
+
### Added
|
|
34
|
+
- Multi-framework support (React, Vue, Angular, Svelte, Solid, Lit, Preact, Vanilla)
|
|
35
|
+
- Auto-generated index.ts exports
|
|
36
|
+
- Responsive design system
|
|
37
|
+
- Theme support (light/dark/auto)
|
|
38
|
+
- File locking mechanism
|
|
39
|
+
- Performance optimization engine
|
|
40
|
+
|
|
41
|
+
### Changed
|
|
42
|
+
- Complete rewrite for enterprise-grade performance
|
|
43
|
+
- Zero-dependency architecture
|
|
44
|
+
- 85% performance improvement over SVGR
|
|
45
|
+
- TypeScript-first approach
|
|
46
|
+
|
|
47
|
+
### Removed
|
|
48
|
+
- Legacy dependencies
|
|
49
|
+
- Single-framework limitation
|
|
50
|
+
|
|
51
|
+
## [1.x.x] - Legacy Versions
|
|
52
|
+
|
|
53
|
+
Please see the [releases page](https://github.com/faezemohades/svger-cli/releases) for information about 1.x versions.
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## Legend
|
|
58
|
+
|
|
59
|
+
- **Added** for new features
|
|
60
|
+
- **Changed** for changes in existing functionality
|
|
61
|
+
- **Deprecated** for soon-to-be removed features
|
|
62
|
+
- **Removed** for now removed features
|
|
63
|
+
- **Fixed** for any bug fixes
|
|
64
|
+
- **Security** for vulnerability fixes
|
package/DEVELOPMENT.md
ADDED
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
# Development Guide
|
|
2
|
+
|
|
3
|
+
This guide will help you set up the development environment and contribute to SVGER-CLI.
|
|
4
|
+
|
|
5
|
+
## Prerequisites
|
|
6
|
+
|
|
7
|
+
- **Node.js**: >= 18.17.0 (we recommend using [nvm](https://github.com/nvm-sh/nvm))
|
|
8
|
+
- **npm**: >= 9.0.0
|
|
9
|
+
- **Git**: Latest version
|
|
10
|
+
|
|
11
|
+
## Setup Development Environment
|
|
12
|
+
|
|
13
|
+
1. **Clone the repository:**
|
|
14
|
+
```bash
|
|
15
|
+
git clone https://github.com/faezemohades/svger-cli.git
|
|
16
|
+
cd svger-cli
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
2. **Install dependencies:**
|
|
20
|
+
```bash
|
|
21
|
+
npm install
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
3. **Build the project:**
|
|
25
|
+
```bash
|
|
26
|
+
npm run build
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
4. **Run tests:**
|
|
30
|
+
```bash
|
|
31
|
+
npm test
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Development Workflow
|
|
35
|
+
|
|
36
|
+
### Building
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
# Build once
|
|
40
|
+
npm run build
|
|
41
|
+
|
|
42
|
+
# Build and watch for changes
|
|
43
|
+
npm run build:watch
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Testing
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
# Run all tests
|
|
50
|
+
npm test
|
|
51
|
+
|
|
52
|
+
# Run tests in watch mode
|
|
53
|
+
npm run test:watch
|
|
54
|
+
|
|
55
|
+
# Run with coverage
|
|
56
|
+
npm run test:coverage
|
|
57
|
+
|
|
58
|
+
# Run integration tests only
|
|
59
|
+
npm run test:integration
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Linting and Formatting
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
# Check for linting issues
|
|
66
|
+
npm run lint
|
|
67
|
+
|
|
68
|
+
# Fix linting issues
|
|
69
|
+
npm run lint:fix
|
|
70
|
+
|
|
71
|
+
# Check formatting
|
|
72
|
+
npm run format:check
|
|
73
|
+
|
|
74
|
+
# Fix formatting
|
|
75
|
+
npm run format
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Development Mode
|
|
79
|
+
|
|
80
|
+
To test the CLI during development:
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
# Run CLI directly from source
|
|
84
|
+
npm run dev -- build ./test-icons ./test-output
|
|
85
|
+
|
|
86
|
+
# Or install globally for testing
|
|
87
|
+
npm run build
|
|
88
|
+
npm link
|
|
89
|
+
svger-cli --version
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Project Structure
|
|
93
|
+
|
|
94
|
+
```
|
|
95
|
+
svger-cli/
|
|
96
|
+
├── src/ # Source code
|
|
97
|
+
│ ├── core/ # Core functionality
|
|
98
|
+
│ ├── processors/ # SVG processing logic
|
|
99
|
+
│ ├── services/ # Business logic services
|
|
100
|
+
│ ├── templates/ # Framework templates
|
|
101
|
+
│ ├── types/ # TypeScript definitions
|
|
102
|
+
│ └── utils/ # Utility functions
|
|
103
|
+
├── bin/ # CLI entry point
|
|
104
|
+
├── docs/ # Documentation
|
|
105
|
+
├── dist/ # Compiled output (generated)
|
|
106
|
+
└── tests/ # Test files
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## Adding New Framework Support
|
|
110
|
+
|
|
111
|
+
1. **Create framework template:**
|
|
112
|
+
```typescript
|
|
113
|
+
// src/core/framework-templates.ts
|
|
114
|
+
export const newFrameworkTemplate = {
|
|
115
|
+
name: 'newframework',
|
|
116
|
+
extension: '.jsx',
|
|
117
|
+
generate: (svgContent: string, componentName: string, options: any) => {
|
|
118
|
+
// Implementation
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
2. **Add to framework list:**
|
|
124
|
+
```typescript
|
|
125
|
+
// src/types/index.ts
|
|
126
|
+
export type FrameworkType = 'react' | 'vue' | 'angular' | 'newframework';
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
3. **Update CLI options:**
|
|
130
|
+
```typescript
|
|
131
|
+
// src/cli.ts - Add to framework choices
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
4. **Add tests:**
|
|
135
|
+
```typescript
|
|
136
|
+
// tests/frameworks/newframework.test.ts
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
## Testing Strategy
|
|
140
|
+
|
|
141
|
+
### Unit Tests
|
|
142
|
+
- Test individual functions and classes
|
|
143
|
+
- Mock external dependencies
|
|
144
|
+
- Focus on business logic
|
|
145
|
+
|
|
146
|
+
### Integration Tests
|
|
147
|
+
- Test CLI commands end-to-end
|
|
148
|
+
- Test file generation with real SVG files
|
|
149
|
+
- Verify output correctness
|
|
150
|
+
|
|
151
|
+
### Performance Tests
|
|
152
|
+
- Benchmark processing times
|
|
153
|
+
- Memory usage testing
|
|
154
|
+
- Regression detection
|
|
155
|
+
|
|
156
|
+
## Code Style Guidelines
|
|
157
|
+
|
|
158
|
+
### TypeScript
|
|
159
|
+
- Use strict TypeScript configuration
|
|
160
|
+
- Prefer interfaces over types for object shapes
|
|
161
|
+
- Use generics for reusable code
|
|
162
|
+
- Document complex types
|
|
163
|
+
|
|
164
|
+
### Naming Conventions
|
|
165
|
+
- **Files**: kebab-case (e.g., `svg-processor.ts`)
|
|
166
|
+
- **Classes**: PascalCase (e.g., `SVGProcessor`)
|
|
167
|
+
- **Functions/Variables**: camelCase (e.g., `processFile`)
|
|
168
|
+
- **Constants**: SCREAMING_SNAKE_CASE (e.g., `DEFAULT_SIZE`)
|
|
169
|
+
|
|
170
|
+
### Error Handling
|
|
171
|
+
- Use custom error classes
|
|
172
|
+
- Provide meaningful error messages
|
|
173
|
+
- Include context in errors
|
|
174
|
+
- Log appropriate levels
|
|
175
|
+
|
|
176
|
+
## Performance Considerations
|
|
177
|
+
|
|
178
|
+
### Optimization Guidelines
|
|
179
|
+
- Use streaming for large files
|
|
180
|
+
- Implement caching where appropriate
|
|
181
|
+
- Parallelize CPU-intensive tasks
|
|
182
|
+
- Monitor memory usage
|
|
183
|
+
|
|
184
|
+
### Benchmarking
|
|
185
|
+
```bash
|
|
186
|
+
# Run performance benchmarks
|
|
187
|
+
npm run benchmark
|
|
188
|
+
|
|
189
|
+
# Compare with previous versions
|
|
190
|
+
npm run benchmark -- --compare
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
## Contributing Guidelines
|
|
194
|
+
|
|
195
|
+
### Before You Start
|
|
196
|
+
1. Check existing issues and PRs
|
|
197
|
+
2. Create an issue for new features
|
|
198
|
+
3. Follow coding standards
|
|
199
|
+
4. Write tests for new code
|
|
200
|
+
|
|
201
|
+
### Pull Request Process
|
|
202
|
+
1. **Create feature branch:**
|
|
203
|
+
```bash
|
|
204
|
+
git checkout -b feature/your-feature-name
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
2. **Make changes and test:**
|
|
208
|
+
```bash
|
|
209
|
+
npm run validate # runs typecheck, lint, and test
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
3. **Commit with conventional format:**
|
|
213
|
+
```bash
|
|
214
|
+
git commit -m "feat: add support for new framework"
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
4. **Push and create PR:**
|
|
218
|
+
```bash
|
|
219
|
+
git push origin feature/your-feature-name
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
### Commit Message Format
|
|
223
|
+
```
|
|
224
|
+
<type>(<scope>): <description>
|
|
225
|
+
|
|
226
|
+
[optional body]
|
|
227
|
+
|
|
228
|
+
[optional footer]
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
**Types:**
|
|
232
|
+
- `feat`: New feature
|
|
233
|
+
- `fix`: Bug fix
|
|
234
|
+
- `docs`: Documentation changes
|
|
235
|
+
- `style`: Formatting changes
|
|
236
|
+
- `refactor`: Code restructuring
|
|
237
|
+
- `test`: Adding tests
|
|
238
|
+
- `chore`: Maintenance tasks
|
|
239
|
+
|
|
240
|
+
## Debugging
|
|
241
|
+
|
|
242
|
+
### CLI Debugging
|
|
243
|
+
```bash
|
|
244
|
+
# Enable verbose logging
|
|
245
|
+
DEBUG=svger:* npm run dev -- build ./icons ./components
|
|
246
|
+
|
|
247
|
+
# Debug specific modules
|
|
248
|
+
DEBUG=svger:processor npm run dev -- build ./icons ./components
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
### VS Code Configuration
|
|
252
|
+
Create `.vscode/launch.json`:
|
|
253
|
+
```json
|
|
254
|
+
{
|
|
255
|
+
"version": "0.2.0",
|
|
256
|
+
"configurations": [
|
|
257
|
+
{
|
|
258
|
+
"name": "Debug CLI",
|
|
259
|
+
"type": "node",
|
|
260
|
+
"request": "launch",
|
|
261
|
+
"program": "${workspaceFolder}/src/cli.ts",
|
|
262
|
+
"args": ["build", "./test-icons", "./test-output"],
|
|
263
|
+
"runtimeArgs": ["--loader", "ts-node/esm"],
|
|
264
|
+
"console": "integratedTerminal"
|
|
265
|
+
}
|
|
266
|
+
]
|
|
267
|
+
}
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
## Release Process
|
|
271
|
+
|
|
272
|
+
### Version Management
|
|
273
|
+
```bash
|
|
274
|
+
# Patch release (bug fixes)
|
|
275
|
+
npm run release
|
|
276
|
+
|
|
277
|
+
# Minor release (new features)
|
|
278
|
+
npm run release:minor
|
|
279
|
+
|
|
280
|
+
# Major release (breaking changes)
|
|
281
|
+
npm run release:major
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
### Manual Release Steps
|
|
285
|
+
1. Update CHANGELOG.md
|
|
286
|
+
2. Run all tests and validation
|
|
287
|
+
3. Build and test package
|
|
288
|
+
4. Update version and tag
|
|
289
|
+
5. Publish to npm
|
|
290
|
+
6. Create GitHub release
|
|
291
|
+
|
|
292
|
+
## Documentation
|
|
293
|
+
|
|
294
|
+
### API Documentation
|
|
295
|
+
```bash
|
|
296
|
+
# Generate API docs
|
|
297
|
+
npm run docs:generate
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
### Adding Documentation
|
|
301
|
+
- Update README.md for user-facing changes
|
|
302
|
+
- Add JSDoc comments for public APIs
|
|
303
|
+
- Update CHANGELOG.md for releases
|
|
304
|
+
- Create ADRs for architectural decisions
|
|
305
|
+
|
|
306
|
+
## Troubleshooting
|
|
307
|
+
|
|
308
|
+
### Common Issues
|
|
309
|
+
|
|
310
|
+
**Build Errors:**
|
|
311
|
+
```bash
|
|
312
|
+
# Clean and rebuild
|
|
313
|
+
npm run clean
|
|
314
|
+
npm install
|
|
315
|
+
npm run build
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
**Test Failures:**
|
|
319
|
+
```bash
|
|
320
|
+
# Update snapshots
|
|
321
|
+
npm test -- --updateSnapshot
|
|
322
|
+
|
|
323
|
+
# Run specific test
|
|
324
|
+
npm test -- --testNamePattern="specific test"
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
**TypeScript Errors:**
|
|
328
|
+
```bash
|
|
329
|
+
# Check types without emitting
|
|
330
|
+
npm run typecheck
|
|
331
|
+
|
|
332
|
+
# Check specific file
|
|
333
|
+
npx tsc --noEmit src/specific-file.ts
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
## Resources
|
|
337
|
+
|
|
338
|
+
- [TypeScript Handbook](https://www.typescriptlang.org/docs/)
|
|
339
|
+
- [Jest Testing Framework](https://jestjs.io/docs/getting-started)
|
|
340
|
+
- [ESLint Rules](https://eslint.org/docs/rules/)
|
|
341
|
+
- [Conventional Commits](https://www.conventionalcommits.org/)
|
|
342
|
+
|
|
343
|
+
## Support
|
|
344
|
+
|
|
345
|
+
If you need help with development:
|
|
346
|
+
|
|
347
|
+
1. Check existing issues and documentation
|
|
348
|
+
2. Ask in GitHub Discussions
|
|
349
|
+
3. Contact maintainers: faezemohades@gmail.com
|
|
350
|
+
|
|
351
|
+
---
|
|
352
|
+
|
|
353
|
+
Happy coding! 🚀
|
package/README.md
CHANGED
|
@@ -9,13 +9,32 @@
|
|
|
9
9
|
|
|
10
10
|
## 🆕 **Latest Developer Experience Improvements**
|
|
11
11
|
|
|
12
|
-
### **Auto-Generated index.ts Exports**
|
|
13
|
-
Automatically generates clean index.ts files with
|
|
12
|
+
### **Auto-Generated index.ts Exports (Enhanced)**
|
|
13
|
+
Automatically generates clean index.ts files with **unified export pattern** for maximum flexibility:
|
|
14
14
|
```typescript
|
|
15
15
|
// Auto-generated in your output directory
|
|
16
|
-
|
|
17
|
-
export {
|
|
18
|
-
|
|
16
|
+
// Named exports for tree-shaking
|
|
17
|
+
export { default as ArrowLeft } from './ArrowLeft';
|
|
18
|
+
export { default as ArrowRight } from './ArrowRight';
|
|
19
|
+
|
|
20
|
+
// Grouped named exports
|
|
21
|
+
export { ArrowLeft, ArrowRight };
|
|
22
|
+
|
|
23
|
+
// Default export for convenience
|
|
24
|
+
export default { ArrowLeft, ArrowRight };
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
**Import flexibility:**
|
|
28
|
+
```typescript
|
|
29
|
+
// Named imports (tree-shaking friendly)
|
|
30
|
+
import { ArrowLeft, ArrowRight } from './components';
|
|
31
|
+
|
|
32
|
+
// Namespace import
|
|
33
|
+
import * as Icons from './components';
|
|
34
|
+
|
|
35
|
+
// Default import
|
|
36
|
+
import Icons from './components';
|
|
37
|
+
const { ArrowLeft } = Icons;
|
|
19
38
|
```
|
|
20
39
|
|
|
21
40
|
### **Enhanced Props & Styling**
|
package/SECURITY.md
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# Security Policy
|
|
2
|
+
|
|
3
|
+
## Supported Versions
|
|
4
|
+
|
|
5
|
+
We actively support the following versions of SVGER-CLI with security updates:
|
|
6
|
+
|
|
7
|
+
| Version | Supported |
|
|
8
|
+
| ------- | ------------------ |
|
|
9
|
+
| 2.0.x | :white_check_mark: |
|
|
10
|
+
| 1.x.x | :x: |
|
|
11
|
+
|
|
12
|
+
## Reporting a Vulnerability
|
|
13
|
+
|
|
14
|
+
We take the security of SVGER-CLI seriously. If you discover a security vulnerability, please follow these guidelines:
|
|
15
|
+
|
|
16
|
+
### How to Report
|
|
17
|
+
|
|
18
|
+
1. **DO NOT** create a public GitHub issue for security vulnerabilities
|
|
19
|
+
2. Send an email to **faezemohades@gmail.com** with the subject line: `[SECURITY] SVGER-CLI Vulnerability Report`
|
|
20
|
+
3. Include the following information:
|
|
21
|
+
- Description of the vulnerability
|
|
22
|
+
- Steps to reproduce the issue
|
|
23
|
+
- Potential impact
|
|
24
|
+
- Suggested fix (if any)
|
|
25
|
+
- Your contact information
|
|
26
|
+
|
|
27
|
+
### What to Expect
|
|
28
|
+
|
|
29
|
+
- **Acknowledgment**: We will acknowledge receipt of your report within 24 hours
|
|
30
|
+
- **Assessment**: We will assess the vulnerability within 72 hours
|
|
31
|
+
- **Updates**: We will provide regular updates on our progress
|
|
32
|
+
- **Resolution**: Critical vulnerabilities will be patched within 7 days, others within 30 days
|
|
33
|
+
|
|
34
|
+
### Security Best Practices for Users
|
|
35
|
+
|
|
36
|
+
When using SVGER-CLI in your projects:
|
|
37
|
+
|
|
38
|
+
1. **Keep Updated**: Always use the latest version
|
|
39
|
+
2. **Validate Input**: Ensure SVG files come from trusted sources
|
|
40
|
+
3. **Review Output**: Inspect generated components before deploying
|
|
41
|
+
4. **File Permissions**: Use appropriate file permissions for generated components
|
|
42
|
+
5. **CI/CD Security**: Secure your build pipelines that use SVGER-CLI
|
|
43
|
+
|
|
44
|
+
### Security Features
|
|
45
|
+
|
|
46
|
+
SVGER-CLI includes several security features:
|
|
47
|
+
|
|
48
|
+
- **Zero Dependencies**: Eliminates third-party vulnerability vectors
|
|
49
|
+
- **Input Validation**: Validates SVG content before processing
|
|
50
|
+
- **Sandboxed Processing**: Processes files in isolated contexts
|
|
51
|
+
- **Safe Output Generation**: Generates safe, sanitized component code
|
|
52
|
+
- **File Locking**: Prevents unauthorized modification of protected files
|
|
53
|
+
|
|
54
|
+
### Disclosure Policy
|
|
55
|
+
|
|
56
|
+
- We believe in responsible disclosure
|
|
57
|
+
- We will credit security researchers who report vulnerabilities responsibly
|
|
58
|
+
- We may create a security advisory for significant vulnerabilities
|
|
59
|
+
- We will notify users through our release notes and GitHub security advisories
|
|
60
|
+
|
|
61
|
+
## Contact
|
|
62
|
+
|
|
63
|
+
For any security-related questions or concerns:
|
|
64
|
+
|
|
65
|
+
- **Primary Contact**: faezemohades@gmail.com
|
|
66
|
+
- **Alternative Contact**: navidrezadoost07@gmail.com
|
|
67
|
+
- **PGP Key**: Available upon request
|
|
68
|
+
|
|
69
|
+
Thank you for helping keep SVGER-CLI secure!
|
package/dist/builder.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import path from
|
|
2
|
-
import { toPascalCase, FileSystem } from
|
|
3
|
-
import { isLocked } from
|
|
4
|
-
import { readConfig } from
|
|
5
|
-
import { reactTemplate } from
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import { toPascalCase, FileSystem } from './utils/native.js';
|
|
3
|
+
import { isLocked } from './lock.js';
|
|
4
|
+
import { readConfig } from './config.js';
|
|
5
|
+
import { reactTemplate } from './templates/ComponentTemplate.js';
|
|
6
6
|
/**
|
|
7
7
|
* Converts all SVG files from a source directory into React components and writes them to an output directory.
|
|
8
8
|
*
|
|
@@ -16,13 +16,13 @@ export async function buildAll(config) {
|
|
|
16
16
|
const srcDir = path.resolve(config.src);
|
|
17
17
|
const outDir = path.resolve(config.out);
|
|
18
18
|
if (!(await FileSystem.exists(srcDir))) {
|
|
19
|
-
console.error(
|
|
19
|
+
console.error('❌ Source folder not found:', srcDir);
|
|
20
20
|
process.exit(1);
|
|
21
21
|
}
|
|
22
22
|
await FileSystem.ensureDir(outDir);
|
|
23
|
-
const files = (await FileSystem.readDir(srcDir)).filter((f) => f.endsWith(
|
|
23
|
+
const files = (await FileSystem.readDir(srcDir)).filter((f) => f.endsWith('.svg'));
|
|
24
24
|
if (!files.length) {
|
|
25
|
-
console.log(
|
|
25
|
+
console.log('⚠️ No SVG files found in', srcDir);
|
|
26
26
|
return;
|
|
27
27
|
}
|
|
28
28
|
for (const file of files) {
|
|
@@ -31,8 +31,8 @@ export async function buildAll(config) {
|
|
|
31
31
|
console.log(`⚠️ Skipped locked file: ${file}`);
|
|
32
32
|
continue;
|
|
33
33
|
}
|
|
34
|
-
const svgContent = await FileSystem.readFile(svgPath,
|
|
35
|
-
const componentName = toPascalCase(file.replace(
|
|
34
|
+
const svgContent = await FileSystem.readFile(svgPath, 'utf-8');
|
|
35
|
+
const componentName = toPascalCase(file.replace('.svg', ''));
|
|
36
36
|
const componentCode = reactTemplate({
|
|
37
37
|
componentName,
|
|
38
38
|
svgContent,
|
|
@@ -41,10 +41,10 @@ export async function buildAll(config) {
|
|
|
41
41
|
defaultFill: svgConfig.defaultFill,
|
|
42
42
|
});
|
|
43
43
|
const outFile = path.join(outDir, `${componentName}.tsx`);
|
|
44
|
-
await FileSystem.writeFile(outFile, componentCode,
|
|
44
|
+
await FileSystem.writeFile(outFile, componentCode, 'utf-8');
|
|
45
45
|
console.log(`✅ Generated: ${componentName}.tsx`);
|
|
46
46
|
}
|
|
47
|
-
console.log(
|
|
47
|
+
console.log('🎉 All SVGs have been converted successfully!');
|
|
48
48
|
}
|
|
49
49
|
/**
|
|
50
50
|
* Generates a single React component from an SVG file.
|
|
@@ -62,11 +62,11 @@ export async function generateSVG({ svgFile, outDir, }) {
|
|
|
62
62
|
return;
|
|
63
63
|
}
|
|
64
64
|
if (!(await FileSystem.exists(filePath))) {
|
|
65
|
-
console.error(
|
|
65
|
+
console.error('❌ SVG file not found:', filePath);
|
|
66
66
|
process.exit(1);
|
|
67
67
|
}
|
|
68
|
-
const svgContent = await FileSystem.readFile(filePath,
|
|
69
|
-
const componentName = toPascalCase(path.basename(svgFile,
|
|
68
|
+
const svgContent = await FileSystem.readFile(filePath, 'utf-8');
|
|
69
|
+
const componentName = toPascalCase(path.basename(svgFile, '.svg'));
|
|
70
70
|
const componentCode = reactTemplate({
|
|
71
71
|
componentName,
|
|
72
72
|
svgContent,
|
|
@@ -77,6 +77,6 @@ export async function generateSVG({ svgFile, outDir, }) {
|
|
|
77
77
|
const outputFolder = path.resolve(outDir);
|
|
78
78
|
await FileSystem.ensureDir(outputFolder);
|
|
79
79
|
const outFile = path.join(outputFolder, `${componentName}.tsx`);
|
|
80
|
-
await FileSystem.writeFile(outFile, componentCode,
|
|
80
|
+
await FileSystem.writeFile(outFile, componentCode, 'utf-8');
|
|
81
81
|
console.log(`✅ Generated: ${componentName}.tsx`);
|
|
82
82
|
}
|
package/dist/clean.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import path from
|
|
2
|
-
import { FileSystem } from
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import { FileSystem } from './utils/native.js';
|
|
3
3
|
/**
|
|
4
4
|
* Cleans the specified output directory by removing all files and folders inside it.
|
|
5
5
|
* Typically used to clear previously generated SVG React components before a new build.
|