svger-cli 1.0.6 → 1.0.8

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 (64) hide show
  1. package/CODE_OF_CONDUCT.md +79 -0
  2. package/CONTRIBUTING.md +146 -0
  3. package/LICENSE +21 -0
  4. package/README.md +1862 -73
  5. package/TESTING.md +143 -0
  6. package/cli-framework.test.js +16 -0
  7. package/cli-test-angular/Arrowbenddownleft.component.ts +27 -0
  8. package/cli-test-angular/Vite.component.ts +27 -0
  9. package/cli-test-angular/index.ts +25 -0
  10. package/{my-icons/ArrowBendDownLeft.tsx → cli-test-output/Arrowbenddownleft.vue} +28 -12
  11. package/{my-icons/Vite.tsx → cli-test-output/Vite.vue} +28 -12
  12. package/cli-test-output/index.ts +25 -0
  13. package/cli-test-react/Arrowbenddownleft.tsx +39 -0
  14. package/cli-test-react/Vite.tsx +39 -0
  15. package/cli-test-react/index.ts +25 -0
  16. package/cli-test-svelte/Arrowbenddownleft.svelte +22 -0
  17. package/cli-test-svelte/Vite.svelte +22 -0
  18. package/cli-test-svelte/index.ts +25 -0
  19. package/dist/builder.js +12 -13
  20. package/dist/clean.js +3 -3
  21. package/dist/cli.js +139 -61
  22. package/dist/config.d.ts +1 -1
  23. package/dist/config.js +5 -7
  24. package/dist/lock.js +1 -1
  25. package/dist/templates/ComponentTemplate.d.ts +15 -0
  26. package/dist/templates/ComponentTemplate.js +15 -0
  27. package/dist/watch.d.ts +2 -1
  28. package/dist/watch.js +30 -33
  29. package/docs/ADR-SVG-INTRGRATION-METHODS-002.adr.md +550 -0
  30. package/docs/FRAMEWORK-GUIDE.md +768 -0
  31. package/docs/IMPLEMENTATION-SUMMARY.md +376 -0
  32. package/frameworks.test.js +170 -0
  33. package/package.json +8 -10
  34. package/src/builder.ts +12 -13
  35. package/src/clean.ts +3 -3
  36. package/src/cli.ts +148 -59
  37. package/src/config.ts +5 -6
  38. package/src/core/error-handler.ts +303 -0
  39. package/src/core/framework-templates.ts +428 -0
  40. package/src/core/logger.ts +104 -0
  41. package/src/core/performance-engine.ts +327 -0
  42. package/src/core/plugin-manager.ts +228 -0
  43. package/src/core/style-compiler.ts +605 -0
  44. package/src/core/template-manager.ts +619 -0
  45. package/src/index.ts +235 -0
  46. package/src/lock.ts +1 -1
  47. package/src/processors/svg-processor.ts +288 -0
  48. package/src/services/config.ts +241 -0
  49. package/src/services/file-watcher.ts +218 -0
  50. package/src/services/svg-service.ts +468 -0
  51. package/src/types/index.ts +169 -0
  52. package/src/utils/native.ts +352 -0
  53. package/src/watch.ts +36 -36
  54. package/test-output-mulit/TestIcon-angular-module.component.ts +26 -0
  55. package/test-output-mulit/TestIcon-angular-standalone.component.ts +27 -0
  56. package/test-output-mulit/TestIcon-lit.ts +35 -0
  57. package/test-output-mulit/TestIcon-preact.tsx +38 -0
  58. package/test-output-mulit/TestIcon-react.tsx +35 -0
  59. package/test-output-mulit/TestIcon-solid.tsx +27 -0
  60. package/test-output-mulit/TestIcon-svelte.svelte +22 -0
  61. package/test-output-mulit/TestIcon-vanilla.ts +37 -0
  62. package/test-output-mulit/TestIcon-vue-composition.vue +33 -0
  63. package/test-output-mulit/TestIcon-vue-options.vue +31 -0
  64. package/tsconfig.json +11 -9
@@ -0,0 +1,376 @@
1
+ # Multi-Framework Implementation Summary
2
+
3
+ ## 🎯 Project Objectives
4
+
5
+ Transform svger-cli from a React-only SVG component generator into a **universal, multi-framework SVG processing toolkit** supporting 8 modern UI frameworks with professional engineering standards.
6
+
7
+ ---
8
+
9
+ ## ✅ Completed Features
10
+
11
+ ### 1. Framework Support (8 Frameworks)
12
+
13
+ | Framework | Status | File Extension | Key Features |
14
+ |-----------|--------|----------------|--------------|
15
+ | **React** | ✅ Complete | `.tsx/.jsx` | forwardRef, memo, TypeScript props |
16
+ | **Vue 3** | ✅ Complete | `.vue` | Composition API, Options API, `<script setup>` |
17
+ | **Svelte** | ✅ Complete | `.svelte` | TypeScript props, reactive bindings |
18
+ | **Angular** | ✅ Complete | `.component.ts` | Standalone, OnPush, Input decorators |
19
+ | **Solid** | ✅ Complete | `.tsx/.jsx` | Component types, reactive primitives |
20
+ | **Preact** | ✅ Complete | `.tsx/.jsx` | Lightweight JSX, FunctionComponent |
21
+ | **Lit** | ✅ Complete | `.ts/.js` | Web Components, decorators, shadow DOM |
22
+ | **Vanilla** | ✅ Complete | `.ts/.js` | Factory functions, DOM API |
23
+
24
+ ### 2. Core Architecture
25
+
26
+ ✅ **FrameworkTemplateEngine** (`src/core/framework-templates.ts`)
27
+ - Single class managing all 8 framework generators
28
+ - Framework-specific code generation with best practices
29
+ - SVG attribute parsing and processing
30
+ - File extension determination per framework
31
+
32
+ ✅ **Type System** (`src/types/index.ts`)
33
+ - `FrameworkType`: Union type for all frameworks
34
+ - `FrameworkOptions`: Framework-specific configuration
35
+ - `ComponentGenerationOptions`: Unified generation interface
36
+
37
+ ✅ **Configuration Management** (`src/services/config.ts`)
38
+ - Default framework settings
39
+ - Framework options support
40
+ - Configuration merging and validation
41
+
42
+ ✅ **SVG Processing** (`src/processors/svg-processor.ts`)
43
+ - Framework-agnostic processing pipeline
44
+ - Dynamic file extension generation
45
+ - Framework template engine integration
46
+
47
+ ### 3. CLI Enhancement
48
+
49
+ ✅ **New Options**:
50
+ ```bash
51
+ --framework <type> # react|vue|svelte|angular|solid|preact|lit|vanilla
52
+ --typescript # Generate TypeScript (default: true)
53
+ --no-typescript # Generate JavaScript
54
+ --composition # Vue Composition API
55
+ --standalone # Angular standalone components
56
+ --signals # Angular/Solid signals
57
+ ```
58
+
59
+ ✅ **Updated Commands**:
60
+ - `build`: Multi-framework support with options
61
+ - `generate`: Single-file framework conversion
62
+ - `watch`: Framework-aware auto-rebuild
63
+
64
+ ### 4. Testing & Validation
65
+
66
+ ✅ **Automated Test Suite** (`test-frameworks.js`)
67
+ - 10 test variants covering all frameworks
68
+ - Framework-specific validation rules
69
+ - Component generation verification
70
+ - File extension checks
71
+ - **Result**: 10/10 tests passing ✅
72
+
73
+ ✅ **Manual Testing**:
74
+ - CLI tested with Vue, Angular, Svelte
75
+ - Real SVG files converted successfully
76
+ - Correct file extensions verified
77
+ - Component code quality validated
78
+
79
+ ### 5. Documentation
80
+
81
+ ✅ **FRAMEWORK-GUIDE.md**
82
+ - Complete usage guide for all 8 frameworks
83
+ - Framework-specific code examples
84
+ - Configuration documentation
85
+ - CLI reference with examples
86
+
87
+ ✅ **TESTING.md**
88
+ - Automated testing instructions
89
+ - Manual testing procedures
90
+ - Expected test results
91
+ - Framework validation criteria
92
+
93
+ ✅ **Code Documentation**
94
+ - JSDoc comments on key classes
95
+ - Inline code explanations
96
+ - Type definitions with descriptions
97
+
98
+ ---
99
+
100
+ ## 🏗️ Technical Implementation
101
+
102
+ ### Key Files Modified
103
+
104
+ 1. **src/core/framework-templates.ts** (NEW - 426 lines)
105
+ - FrameworkTemplateEngine class
106
+ - 8 private generator methods
107
+ - SVG parsing utilities
108
+ - File extension determination
109
+
110
+ 2. **src/types/index.ts** (UPDATED)
111
+ - Added FrameworkType union
112
+ - Added FrameworkOptions interface
113
+ - Updated ComponentGenerationOptions
114
+
115
+ 3. **src/cli.ts** (UPDATED)
116
+ - Added framework CLI options
117
+ - Updated build command
118
+ - Updated generate command
119
+
120
+ 4. **src/services/config.ts** (UPDATED)
121
+ - Framework defaults
122
+ - frameworkOptions support
123
+
124
+ 5. **src/processors/svg-processor.ts** (UPDATED)
125
+ - Framework template engine integration
126
+ - Dynamic file extensions
127
+ - Framework-aware processing
128
+
129
+ 6. **src/services/svg-service.ts** (UPDATED)
130
+ - Framework config passing
131
+ - CLI option support
132
+
133
+ ### Zero-Dependency Approach
134
+
135
+ ✅ **Native Node.js APIs Only**
136
+ - No new external dependencies added
137
+ - File operations via native `fs` module
138
+ - String processing with native methods
139
+ - Template string generation
140
+
141
+ ✅ **Performance Optimizations**
142
+ - Single template engine instance
143
+ - Efficient string concatenation
144
+ - Minimal regex operations
145
+ - Framework-specific code paths
146
+
147
+ ---
148
+
149
+ ## 📊 Test Results
150
+
151
+ ### Automated Tests (test-frameworks.js)
152
+
153
+ ```
154
+ Total Tests: 10
155
+ ✅ Passed: 10
156
+ ❌ Failed: 0
157
+
158
+ Frameworks Tested:
159
+ ✅ React
160
+ ✅ Vue (Composition API)
161
+ ✅ Vue (Options API)
162
+ ✅ Svelte
163
+ ✅ Angular (Standalone)
164
+ ✅ Angular (Module)
165
+ ✅ Solid
166
+ ✅ Preact
167
+ ✅ Lit
168
+ ✅ Vanilla
169
+ ```
170
+
171
+ ### Manual CLI Tests
172
+
173
+ ```bash
174
+ # Vue Composition API
175
+ ✅ svger-cli build my-svgs cli-test-output --framework vue --composition
176
+ → Generated .vue files with <script setup>
177
+
178
+ # Angular Standalone
179
+ ✅ svger-cli build my-svgs cli-test-angular --framework angular --standalone
180
+ → Generated .component.ts with standalone: true
181
+
182
+ # Svelte TypeScript
183
+ ✅ svger-cli build my-svgs cli-test-svelte --framework svelte
184
+ → Generated .svelte files with TypeScript
185
+ ```
186
+
187
+ ---
188
+
189
+ ## 🎨 Framework-Specific Features
190
+
191
+ ### React
192
+ - `React.forwardRef` for ref forwarding
193
+ - TypeScript prop interfaces
194
+ - Size prop for convenience
195
+ - className and style support
196
+
197
+ ### Vue 3
198
+ - Composition API with `<script setup>`
199
+ - Options API support
200
+ - Reactive bindings (`:class`, `:style`)
201
+ - `v-bind="$attrs"` for prop spreading
202
+
203
+ ### Svelte
204
+ - TypeScript prop types (`export let`)
205
+ - Reactive bindings (`{width}`, `{height}`)
206
+ - Rest props (`{...$$restProps}`)
207
+ - Native TypeScript support
208
+
209
+ ### Angular
210
+ - Standalone components (Angular 16+)
211
+ - `ChangeDetectionStrategy.OnPush`
212
+ - Input decorators with defaults
213
+ - Attribute binding (`[attr.class]`)
214
+
215
+ ### Solid
216
+ - Component JSX types
217
+ - Reactive props
218
+ - Class and style bindings
219
+ - Props spreading
220
+
221
+ ### Preact
222
+ - FunctionComponent type
223
+ - JSX namespace
224
+ - Lightweight API
225
+ - Compatible with React patterns
226
+
227
+ ### Lit
228
+ - Web Components standard
229
+ - Custom element decorators
230
+ - Reactive properties
231
+ - Shadow DOM support
232
+
233
+ ### Vanilla
234
+ - Factory function pattern
235
+ - DOM API usage
236
+ - SVG namespace handling
237
+ - Attribute manipulation
238
+
239
+ ---
240
+
241
+ ## 📁 Project Structure
242
+
243
+ ```
244
+ svger-cli/
245
+ ├── src/
246
+ │ ├── core/
247
+ │ │ └── framework-templates.ts # Multi-framework generator
248
+ │ ├── types/
249
+ │ │ └── index.ts # Framework types
250
+ │ ├── cli.ts # CLI with framework options
251
+ │ ├── processors/
252
+ │ │ └── svg-processor.ts # Framework-aware processing
253
+ │ └── services/
254
+ │ ├── config.ts # Framework configuration
255
+ │ └── svg-service.ts # Framework integration
256
+ ├── test-frameworks.js # Automated test suite
257
+ ├── FRAMEWORK-GUIDE.md # Complete usage guide
258
+ ├── TESTING.md # Testing documentation
259
+ └── test-output/ # Generated test components
260
+ ```
261
+
262
+ ---
263
+
264
+ ## 🚀 Usage Examples
265
+
266
+ ### Basic Usage
267
+
268
+ ```bash
269
+ # Default (React)
270
+ svger-cli build ./svgs ./components
271
+
272
+ # Vue with Composition API
273
+ svger-cli build ./svgs ./components --framework vue --composition
274
+
275
+ # Angular Standalone
276
+ svger-cli build ./svgs ./components --framework angular --standalone
277
+
278
+ # Svelte TypeScript
279
+ svger-cli build ./svgs ./components --framework svelte
280
+ ```
281
+
282
+ ### Programmatic API
283
+
284
+ ```typescript
285
+ import { frameworkTemplateEngine } from 'svger-cli';
286
+
287
+ const component = frameworkTemplateEngine.generateComponent({
288
+ framework: 'vue',
289
+ componentName: 'MyIcon',
290
+ svgContent: '<svg>...</svg>',
291
+ typescript: true,
292
+ frameworkOptions: { scriptSetup: true }
293
+ });
294
+ ```
295
+
296
+ ---
297
+
298
+ ## 🎯 Quality Metrics
299
+
300
+ ✅ **Code Quality**
301
+ - TypeScript strict mode compliant
302
+ - Zero ESLint errors
303
+ - Comprehensive type coverage
304
+ - Clean separation of concerns
305
+
306
+ ✅ **Testing Coverage**
307
+ - All 8 frameworks tested
308
+ - 10 test variants
309
+ - Framework-specific validation
310
+ - Real-world SVG processing
311
+
312
+ ✅ **Documentation**
313
+ - Complete API documentation
314
+ - Framework-specific guides
315
+ - Usage examples for all frameworks
316
+ - Testing procedures
317
+
318
+ ✅ **Performance**
319
+ - Zero new dependencies
320
+ - Efficient code generation
321
+ - Minimal memory footprint
322
+ - Fast compilation
323
+
324
+ ---
325
+
326
+ ## 🔄 Migration Path
327
+
328
+ For existing users:
329
+
330
+ ```bash
331
+ # Before (React only)
332
+ svger-cli build ./svgs ./components
333
+
334
+ # After (still works - React is default)
335
+ svger-cli build ./svgs ./components
336
+
337
+ # New capability
338
+ svger-cli build ./svgs ./components --framework vue
339
+ ```
340
+
341
+ **Backward Compatibility**: 100% maintained ✅
342
+
343
+ ---
344
+
345
+ ## 📝 Commit History
346
+
347
+ ```
348
+ feat: Complete multi-framework support for all 8 UI frameworks
349
+
350
+ - Implemented comprehensive framework support: React, Vue, Svelte, Angular, Solid, Preact, Lit, Vanilla JS
351
+ - Created FrameworkTemplateEngine with framework-specific generators
352
+ - Added CLI options: --framework, --typescript, --composition, --standalone
353
+ - Updated types system with FrameworkType and FrameworkOptions
354
+ - Enhanced config service with framework defaults
355
+ - Fixed file extension generation based on framework
356
+ - Created comprehensive testing suite (test-frameworks.js)
357
+ - Added framework documentation (FRAMEWORK-GUIDE.md, TESTING.md)
358
+ - All 10 test variants passing successfully
359
+ ```
360
+
361
+ ---
362
+
363
+ ## 🎉 Achievement Summary
364
+
365
+ **SVGER-CLI v2.0** is now a **professional, enterprise-grade, multi-framework SVG processing toolkit** that:
366
+
367
+ ✅ Supports 8 modern UI frameworks
368
+ ✅ Maintains zero external dependencies
369
+ ✅ Follows framework best practices
370
+ ✅ Provides comprehensive documentation
371
+ ✅ Includes automated testing
372
+ ✅ Maintains backward compatibility
373
+ ✅ Uses TypeScript for type safety
374
+ ✅ Generates idiomatic, production-ready code
375
+
376
+ **All requirements met. Implementation complete and tested.** 🚀
@@ -0,0 +1,170 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Framework Testing Script for SVGER-CLI
5
+ * Tests all 8 supported frameworks: React, Vue, Svelte, Angular, Solid, Preact, Lit, Vanilla
6
+ */
7
+
8
+ import { frameworkTemplateEngine } from './dist/index.js';
9
+ import fs from 'fs';
10
+ import path from 'path';
11
+
12
+ const testSVG = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" fill="currentColor">
13
+ <path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z"/>
14
+ </svg>`;
15
+
16
+ const frameworks = [
17
+ { name: 'react', typescript: true, options: {} },
18
+ { name: 'vue', typescript: true, options: { scriptSetup: true } },
19
+ { name: 'vue', typescript: true, options: { scriptSetup: false } },
20
+ { name: 'svelte', typescript: true, options: {} },
21
+ { name: 'angular', typescript: true, options: { standalone: true } },
22
+ { name: 'angular', typescript: true, options: { standalone: false } },
23
+ { name: 'solid', typescript: true, options: {} },
24
+ { name: 'preact', typescript: true, options: {} },
25
+ { name: 'lit', typescript: true, options: {} },
26
+ { name: 'vanilla', typescript: true, options: {} }
27
+ ];
28
+
29
+ console.log('🚀 SVGER-CLI Framework Testing Suite\n');
30
+ console.log('=' .repeat(80));
31
+
32
+ const testOutputDir = path.join(process.cwd(), 'test-output');
33
+ if (!fs.existsSync(testOutputDir)) {
34
+ fs.mkdirSync(testOutputDir, { recursive: true });
35
+ }
36
+
37
+ let passed = 0;
38
+ let failed = 0;
39
+
40
+ frameworks.forEach((config, index) => {
41
+ const { name, typescript, options } = config;
42
+ const variant = options.scriptSetup !== undefined
43
+ ? (options.scriptSetup ? '-composition' : '-options')
44
+ : options.standalone !== undefined
45
+ ? (options.standalone ? '-standalone' : '-module')
46
+ : '';
47
+
48
+ const testName = `${name}${variant}`;
49
+
50
+ try {
51
+ console.log(`\n[${index + 1}/${frameworks.length}] Testing: ${testName.toUpperCase()}`);
52
+ console.log('-'.repeat(80));
53
+
54
+ const componentOptions = {
55
+ framework: name,
56
+ componentName: 'TestIcon',
57
+ svgContent: testSVG,
58
+ typescript,
59
+ frameworkOptions: options
60
+ };
61
+
62
+ // Generate component
63
+ const component = frameworkTemplateEngine.generateComponent(componentOptions);
64
+
65
+ // Validate component
66
+ if (!component || component.length === 0) {
67
+ throw new Error('Generated component is empty');
68
+ }
69
+
70
+ // Get file extension
71
+ const extension = frameworkTemplateEngine.getFileExtension(name, typescript);
72
+
73
+ // Save to file
74
+ const fileName = `TestIcon-${testName}.${extension}`;
75
+ const filePath = path.join(testOutputDir, fileName);
76
+ fs.writeFileSync(filePath, component, 'utf8');
77
+
78
+ // Framework-specific validation
79
+ switch (name) {
80
+ case 'react':
81
+ case 'preact':
82
+ case 'solid':
83
+ if (!component.includes('export default')) {
84
+ throw new Error('Missing default export');
85
+ }
86
+ if (!component.includes('interface')) {
87
+ throw new Error('Missing TypeScript interface');
88
+ }
89
+ break;
90
+
91
+ case 'vue':
92
+ if (!component.includes('<template>')) {
93
+ throw new Error('Missing Vue template section');
94
+ }
95
+ if (!component.includes('<script')) {
96
+ throw new Error('Missing Vue script section');
97
+ }
98
+ if (options.scriptSetup && !component.includes('setup')) {
99
+ throw new Error('Missing composition API setup');
100
+ }
101
+ break;
102
+
103
+ case 'svelte':
104
+ if (!component.includes('<script')) {
105
+ throw new Error('Missing Svelte script section');
106
+ }
107
+ if (!component.includes('export let')) {
108
+ throw new Error('Missing Svelte props');
109
+ }
110
+ break;
111
+
112
+ case 'angular':
113
+ if (!component.includes('@Component')) {
114
+ throw new Error('Missing Angular decorator');
115
+ }
116
+ if (!component.includes('selector:')) {
117
+ throw new Error('Missing component selector');
118
+ }
119
+ if (options.standalone && !component.includes('standalone: true')) {
120
+ throw new Error('Missing standalone flag');
121
+ }
122
+ break;
123
+
124
+ case 'lit':
125
+ if (!component.includes('@customElement')) {
126
+ throw new Error('Missing Lit decorator');
127
+ }
128
+ if (!component.includes('extends LitElement')) {
129
+ throw new Error('Not extending LitElement');
130
+ }
131
+ break;
132
+
133
+ case 'vanilla':
134
+ if (!component.includes('export function')) {
135
+ throw new Error('Missing function export');
136
+ }
137
+ if (!component.includes('document.createElementNS')) {
138
+ throw new Error('Missing DOM manipulation');
139
+ }
140
+ break;
141
+ }
142
+
143
+ console.log(`✅ SUCCESS: Generated valid ${name.toUpperCase()} component`);
144
+ console.log(` 📄 File: ${fileName}`);
145
+ console.log(` 📏 Size: ${component.length} characters`);
146
+ console.log(` 📝 Extension: .${extension}`);
147
+
148
+ passed++;
149
+
150
+ } catch (error) {
151
+ console.log(`❌ FAILED: ${testName.toUpperCase()}`);
152
+ console.log(` Error: ${error.message}`);
153
+ failed++;
154
+ }
155
+ });
156
+
157
+ console.log('\n' + '='.repeat(80));
158
+ console.log('\n📊 Test Results Summary\n');
159
+ console.log(` Total Tests: ${frameworks.length}`);
160
+ console.log(` ✅ Passed: ${passed}`);
161
+ console.log(` ❌ Failed: ${failed}`);
162
+ console.log(` 📂 Output: ${testOutputDir}\n`);
163
+
164
+ if (failed === 0) {
165
+ console.log('🎉 All framework tests passed successfully!\n');
166
+ process.exit(0);
167
+ } else {
168
+ console.log('⚠️ Some tests failed. Please review the errors above.\n');
169
+ process.exit(1);
170
+ }
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "svger-cli",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "description": "CLI and runtime for converting SVGs to React components with watch support",
5
5
  "main": "dist/cli.js",
6
6
  "type": "module",
7
7
  "bin": {
8
- "svger-cli": "./dist/cli.js"
8
+ "svger-cli": "./bin/svg-tool.js"
9
9
  },
10
10
  "scripts": {
11
- "build": "tsc",
11
+ "build": "tsc -p tsconfig.json",
12
12
  "dev": "ts-node src/cli.ts"
13
13
  },
14
14
  "keywords": [
@@ -18,17 +18,15 @@
18
18
  "components"
19
19
  ],
20
20
  "author": "faeze mohades",
21
+ "repository": "https://github.com/faezemohades/svger-cli",
21
22
  "license": "MIT",
22
- "dependencies": {
23
- "change-case": "^5.4.4",
24
- "chokidar": "^4.0.3",
25
- "commander": "^14.0.2",
26
- "fs-extra": "^11.3.2"
27
- },
23
+ "dependencies": {},
28
24
  "devDependencies": {
29
- "@types/fs-extra": "^11.0.4",
30
25
  "@types/node": "^24.9.2",
31
26
  "ts-node": "^10.9.2",
32
27
  "typescript": "^5.9.3"
28
+ },
29
+ "engines": {
30
+ "node": ">=18.17"
33
31
  }
34
32
  }
package/src/builder.ts CHANGED
@@ -1,6 +1,5 @@
1
- import fs from "fs-extra";
2
1
  import path from "path";
3
- import { pascalCase } from "change-case";
2
+ import { toPascalCase, FileSystem } from "./utils/native.js";
4
3
  import { isLocked } from "./lock.js";
5
4
  import { readConfig } from "./config.js";
6
5
  import { reactTemplate } from "./templates/ComponentTemplate.js";
@@ -18,13 +17,13 @@ export async function buildAll(config: { src: string; out: string }) {
18
17
  const srcDir = path.resolve(config.src);
19
18
  const outDir = path.resolve(config.out);
20
19
 
21
- if (!fs.existsSync(srcDir)) {
20
+ if (!(await FileSystem.exists(srcDir))) {
22
21
  console.error("❌ Source folder not found:", srcDir);
23
22
  process.exit(1);
24
23
  }
25
24
 
26
- await fs.ensureDir(outDir);
27
- const files = (await fs.readdir(srcDir)).filter(f => f.endsWith(".svg"));
25
+ await FileSystem.ensureDir(outDir);
26
+ const files = (await FileSystem.readDir(srcDir)).filter((f: string) => f.endsWith(".svg"));
28
27
 
29
28
  if (!files.length) {
30
29
  console.log("⚠️ No SVG files found in", srcDir);
@@ -39,8 +38,8 @@ export async function buildAll(config: { src: string; out: string }) {
39
38
  continue;
40
39
  }
41
40
 
42
- const svgContent = await fs.readFile(svgPath, "utf-8");
43
- const componentName = pascalCase(file.replace(".svg", ""));
41
+ const svgContent = await FileSystem.readFile(svgPath, "utf-8");
42
+ const componentName = toPascalCase(file.replace(".svg", ""));
44
43
  const componentCode = reactTemplate({
45
44
  componentName,
46
45
  svgContent,
@@ -50,7 +49,7 @@ export async function buildAll(config: { src: string; out: string }) {
50
49
  });
51
50
 
52
51
  const outFile = path.join(outDir, `${componentName}.tsx`);
53
- await fs.writeFile(outFile, componentCode, "utf-8");
52
+ await FileSystem.writeFile(outFile, componentCode, "utf-8");
54
53
  console.log(`✅ Generated: ${componentName}.tsx`);
55
54
  }
56
55
 
@@ -80,13 +79,13 @@ export async function generateSVG({
80
79
  return;
81
80
  }
82
81
 
83
- if (!fs.existsSync(filePath)) {
82
+ if (!(await FileSystem.exists(filePath))) {
84
83
  console.error("❌ SVG file not found:", filePath);
85
84
  process.exit(1);
86
85
  }
87
86
 
88
- const svgContent = await fs.readFile(filePath, "utf-8");
89
- const componentName = pascalCase(path.basename(svgFile, ".svg"));
87
+ const svgContent = await FileSystem.readFile(filePath, "utf-8");
88
+ const componentName = toPascalCase(path.basename(svgFile, ".svg"));
90
89
  const componentCode = reactTemplate({
91
90
  componentName,
92
91
  svgContent,
@@ -96,10 +95,10 @@ export async function generateSVG({
96
95
  });
97
96
 
98
97
  const outputFolder = path.resolve(outDir);
99
- await fs.ensureDir(outputFolder);
98
+ await FileSystem.ensureDir(outputFolder);
100
99
 
101
100
  const outFile = path.join(outputFolder, `${componentName}.tsx`);
102
- await fs.writeFile(outFile, componentCode, "utf-8");
101
+ await FileSystem.writeFile(outFile, componentCode, "utf-8");
103
102
 
104
103
  console.log(`✅ Generated: ${componentName}.tsx`);
105
104
  }
package/src/clean.ts CHANGED
@@ -1,5 +1,5 @@
1
- import fs from "fs-extra";
2
1
  import path from "path";
2
+ import { FileSystem } from "./utils/native.js";
3
3
 
4
4
  /**
5
5
  * Cleans the specified output directory by removing all files and folders inside it.
@@ -11,11 +11,11 @@ import path from "path";
11
11
  export async function clean(outDir: string) {
12
12
  const targetDir = path.resolve(outDir);
13
13
 
14
- if (!fs.existsSync(targetDir)) {
14
+ if (!(await FileSystem.exists(targetDir))) {
15
15
  console.log(`⚠️ Directory not found: ${targetDir}`);
16
16
  return;
17
17
  }
18
18
 
19
- await fs.emptyDir(targetDir);
19
+ await FileSystem.emptyDir(targetDir);
20
20
  console.log(`🧹 Cleaned all generated SVG components in: ${targetDir}`);
21
21
  }