svger-cli 2.0.8 โ 3.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 +335 -0
- package/README.md +528 -7
- package/dist/__tests__/fixtures.d.ts +132 -0
- package/dist/__tests__/fixtures.js +228 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.js +33 -0
- package/dist/integrations/babel.d.ts +58 -0
- package/dist/integrations/babel.js +221 -0
- package/dist/integrations/jest-preset.d.ts +44 -0
- package/dist/integrations/jest-preset.js +169 -0
- package/dist/integrations/nextjs.d.ts +56 -0
- package/dist/integrations/nextjs.js +140 -0
- package/dist/integrations/rollup.d.ts +29 -0
- package/dist/integrations/rollup.js +197 -0
- package/dist/integrations/vite.d.ts +29 -0
- package/dist/integrations/vite.js +221 -0
- package/dist/integrations/webpack.d.ts +84 -0
- package/dist/integrations/webpack.js +273 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +2 -1
- package/dist/types/integrations.d.ts +255 -0
- package/dist/types/integrations.js +4 -0
- package/docs/INTEGRATION-IMPLEMENTATION-SUMMARY.md +448 -0
- package/docs/INTEGRATIONS.md +543 -0
- package/examples/babel.config.example.js +182 -0
- package/examples/jest.config.example.js +158 -0
- package/examples/next.config.example.js +133 -0
- package/examples/rollup.config.example.js +129 -0
- package/examples/vite.config.example.js +98 -0
- package/examples/webpack.config.example.js +88 -0
- package/package.json +78 -4
package/README.md
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
|
-
# SVGER-CLI
|
|
1
|
+
# SVGER-CLI v3.1.0 - Enterprise SVG Processing Framework
|
|
2
2
|
|
|
3
3
|
[](https://badge.fury.io/js/svger-cli)
|
|
4
|
+
[](https://www.npmjs.com/package/svger-cli)
|
|
5
|
+
[](https://www.npmjs.com/package/svger-cli)
|
|
4
6
|
[](https://opensource.org/licenses/MIT)
|
|
5
7
|
[](https://www.typescriptlang.org/)
|
|
6
8
|
[](https://www.npmjs.com/package/svger-cli)
|
|
9
|
+
[](https://github.com/faezemohades/svger-cli)
|
|
10
|
+
[](https://github.com/faezemohades/svger-cli)
|
|
7
11
|
|
|
8
|
-
> **The most advanced, zero-dependency SVG to component converter
|
|
9
|
-
>
|
|
10
|
-
>
|
|
12
|
+
> **The most advanced, zero-dependency SVG to component converter with official build tool
|
|
13
|
+
> integrations. First-class support for Webpack, Vite, Rollup, Babel, Next.js, and Jest. Supporting
|
|
14
|
+
> 9+ UI frameworks including React Native with enterprise-grade performance, comprehensive test suite,
|
|
15
|
+
> and production-ready CI/CD pipelines.**
|
|
11
16
|
|
|
12
17
|
---
|
|
13
18
|
|
|
@@ -16,6 +21,14 @@
|
|
|
16
21
|
### ๐ **Getting Started**
|
|
17
22
|
|
|
18
23
|
- [๐ฆ Installation](#-installation)
|
|
24
|
+
- [๐ Project Structure](#-project-structure) **โ Source code organization**
|
|
25
|
+
- [๐ง Build Tool Integrations](#-build-tool-integrations) **โ Official integrations**
|
|
26
|
+
- [Webpack](#webpack-integration)
|
|
27
|
+
- [Vite](#vite-integration)
|
|
28
|
+
- [Rollup](#rollup-integration)
|
|
29
|
+
- [Babel](#babel-integration)
|
|
30
|
+
- [Next.js](#nextjs-integration)
|
|
31
|
+
- [Jest](#jest-integration)
|
|
19
32
|
- [๐ Quick Start: Your First Conversion](#-quick-start-your-first-conversion)
|
|
20
33
|
- [๐ก Why SVGER-CLI?](#-why-svger-cli-the-zero-dependency-advantage)
|
|
21
34
|
|
|
@@ -74,11 +87,19 @@
|
|
|
74
87
|
| ------------------------------------- | --------------------------------------------------------------- |
|
|
75
88
|
| ๐ฏ Get started immediately | [Quick Start](#-quick-start-your-first-conversion) |
|
|
76
89
|
| ๐ฆ Install the package | [Installation](#-installation) |
|
|
90
|
+
| ๐ See source code structure | [Project Structure](#-project-structure) |
|
|
91
|
+
| ๐ง Use with Webpack/Vite/Rollup | [Build Tool Integrations](#-build-tool-integrations) **NEW** |
|
|
92
|
+
| โ๏ธ Configure Webpack | [Webpack Integration](#webpack-integration) |
|
|
93
|
+
| โก Set up Vite | [Vite Integration](#vite-integration) |
|
|
94
|
+
| ๐ฆ Use with Rollup | [Rollup Integration](#rollup-integration) |
|
|
95
|
+
| ๐ Integrate Babel | [Babel Integration](#babel-integration) |
|
|
96
|
+
| โฒ Use with Next.js | [Next.js Integration](#nextjs-integration) |
|
|
97
|
+
| ๐งช Set up Jest | [Jest Integration](#jest-integration) |
|
|
77
98
|
| ๐ค Understand why SVGER-CLI is better | [Why SVGER-CLI?](#-why-svger-cli-the-zero-dependency-advantage) |
|
|
78
99
|
| โก Compare features with competitors | [Feature Comparison](#-feature-comparison-matrix) |
|
|
79
100
|
| ๐ Convert SVGs to React components | [React Guide](#react) |
|
|
80
|
-
|
|
|
81
|
-
|
|
|
101
|
+
| ๐ฑ Use with React Native | [React Native Guide](#react-native) |
|
|
102
|
+
| ๐ Use with Vue | [Vue Guide](#vue-3) |
|
|
82
103
|
| ๐
ฐ๏ธ Use with Angular | [Angular Guide](#angular) |
|
|
83
104
|
| ๐ช๏ธ Use with Svelte | [Svelte Guide](#svelte) |
|
|
84
105
|
| ๐ Learn all CLI commands | [CLI Reference](#-comprehensive-cli-reference) |
|
|
@@ -92,6 +113,15 @@
|
|
|
92
113
|
| ๐ Create custom plugins | [Plugin Development](#-plugin-development) |
|
|
93
114
|
| ๐ Fix issues | [Troubleshooting](#-troubleshooting--faq) |
|
|
94
115
|
| ๐ Migrate from another tool | [Migration Guide](#-migration-guide) |
|
|
116
|
+
| ๐จ Configure styling & theming | [Styling Guide](#-advanced-styling--theming) |
|
|
117
|
+
| โก Optimize performance | [Performance Guide](#-performance-optimization) |
|
|
118
|
+
| ๐ Deploy to production | [Deployment Guide](#-production-deployment) |
|
|
119
|
+
| ๐ณ Use with Docker | [Docker Setup](#docker-integration) |
|
|
120
|
+
| ๐งช Test my components | [Testing Guide](#-testing--quality-assurance) |
|
|
121
|
+
| ๐ง Configure everything | [Configuration Reference](#-configuration-reference) |
|
|
122
|
+
| ๐ Create custom plugins | [Plugin Development](#-plugin-development) |
|
|
123
|
+
| ๐ Fix issues | [Troubleshooting](#-troubleshooting--faq) |
|
|
124
|
+
| ๐ Migrate from another tool | [Migration Guide](#-migration-guide) |
|
|
95
125
|
|
|
96
126
|
---
|
|
97
127
|
|
|
@@ -99,6 +129,30 @@
|
|
|
99
129
|
|
|
100
130
|
## ๐ **Key Features Overview**
|
|
101
131
|
|
|
132
|
+
### **๐ง Official Build Tool Integrations (NEW in v3.0)**
|
|
133
|
+
|
|
134
|
+
First-class support for all major build tools with zero configuration:
|
|
135
|
+
|
|
136
|
+
- โ
**Webpack Plugin** - HMR, watch mode, and loader support
|
|
137
|
+
- โ
**Vite Plugin** - Lightning-fast HMR and virtual modules
|
|
138
|
+
- โ
**Rollup Plugin** - Tree-shaking and source maps
|
|
139
|
+
- โ
**Babel Plugin** - Universal transpilation and import transformation
|
|
140
|
+
- โ
**Next.js Integration** - SSR support for App and Pages Router
|
|
141
|
+
- โ
**Jest Preset** - SVG transformers and mocking for tests
|
|
142
|
+
|
|
143
|
+
```javascript
|
|
144
|
+
// One-line setup for any build tool
|
|
145
|
+
const { SvgerWebpackPlugin } = require('svger-cli/webpack');
|
|
146
|
+
import { svgerVitePlugin } from 'svger-cli/vite';
|
|
147
|
+
import { svgerRollupPlugin } from 'svger-cli/rollup';
|
|
148
|
+
const { svgerBabelPlugin } = require('svger-cli/babel');
|
|
149
|
+
const { withSvger } = require('svger-cli/nextjs');
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
**[See full integration guide โ](#-build-tool-integrations)**
|
|
153
|
+
|
|
154
|
+
---
|
|
155
|
+
|
|
102
156
|
### **โจ Auto-Generated index.ts Exports (Enhanced)**
|
|
103
157
|
|
|
104
158
|
Automatically generates clean index.ts files with a **single, consistent export pattern** that
|
|
@@ -228,7 +282,398 @@ npm install --save-dev svger-cli
|
|
|
228
282
|
|
|
229
283
|
---
|
|
230
284
|
|
|
231
|
-
##
|
|
285
|
+
## ๐ **Project Structure**
|
|
286
|
+
|
|
287
|
+
SVGER-CLI is organized with a clear separation between source code and generated outputs:
|
|
288
|
+
|
|
289
|
+
### Source Code Structure
|
|
290
|
+
|
|
291
|
+
```
|
|
292
|
+
svger-cli/
|
|
293
|
+
โโโ src/ # ๐ Source code (TypeScript)
|
|
294
|
+
โ โโโ cli.ts # CLI entry point and command handling
|
|
295
|
+
โ โโโ index.ts # Main library exports
|
|
296
|
+
โ โโโ builder.ts # Core build orchestration
|
|
297
|
+
โ โโโ config.ts # Configuration management
|
|
298
|
+
โ โโโ watch.ts # File watcher implementation
|
|
299
|
+
โ โโโ clean.ts # Cleanup utilities
|
|
300
|
+
โ โโโ lock.ts # Lock file management
|
|
301
|
+
โ โ
|
|
302
|
+
โ โโโ core/ # ๐ง Core functionality
|
|
303
|
+
โ โ โโโ error-handler.ts # Error handling & reporting
|
|
304
|
+
โ โ โโโ framework-templates.ts # Framework-specific templates
|
|
305
|
+
โ โ โโโ logger.ts # Logging system
|
|
306
|
+
โ โ โโโ performance-engine.ts # Performance optimization
|
|
307
|
+
โ โ โโโ plugin-manager.ts # Plugin system
|
|
308
|
+
โ โ โโโ style-compiler.ts # Style processing
|
|
309
|
+
โ โ โโโ template-manager.ts # Template rendering
|
|
310
|
+
โ โ
|
|
311
|
+
โ โโโ integrations/ # ๐ Build tool integrations
|
|
312
|
+
โ โ โโโ webpack.ts # Webpack plugin & loader
|
|
313
|
+
โ โ โโโ vite.ts # Vite plugin
|
|
314
|
+
โ โ โโโ rollup.ts # Rollup plugin
|
|
315
|
+
โ โ โโโ babel.ts # Babel plugin
|
|
316
|
+
โ โ โโโ nextjs.ts # Next.js integration
|
|
317
|
+
โ โ โโโ jest-preset.ts # Jest transformer
|
|
318
|
+
โ โ
|
|
319
|
+
โ โโโ processors/ # โ๏ธ SVG processing
|
|
320
|
+
โ โ โโโ svg-processor.ts # SVG optimization & parsing
|
|
321
|
+
โ โ
|
|
322
|
+
โ โโโ services/ # ๐ ๏ธ Services layer
|
|
323
|
+
โ โ โโโ config.ts # Configuration service
|
|
324
|
+
โ โ โโโ file-watcher.ts # File watching service
|
|
325
|
+
โ โ โโโ svg-service.ts # SVG processing service
|
|
326
|
+
โ โ
|
|
327
|
+
โ โโโ templates/ # ๐ Component templates
|
|
328
|
+
โ โ โโโ ComponentTemplate.ts # Template definitions
|
|
329
|
+
โ โ
|
|
330
|
+
โ โโโ types/ # ๐ TypeScript types
|
|
331
|
+
โ โโโ index.ts # Type exports
|
|
332
|
+
โ โโโ integrations.ts # Integration types
|
|
333
|
+
โ
|
|
334
|
+
โโโ bin/ # ๐ CLI executable
|
|
335
|
+
โ โโโ svg-tool.js # Command-line interface
|
|
336
|
+
โ
|
|
337
|
+
โโโ dist/ # ๐ฆ Compiled output (generated)
|
|
338
|
+
โ โโโ *.js # Compiled JavaScript
|
|
339
|
+
โ โโโ *.d.ts # TypeScript declarations
|
|
340
|
+
โ โโโ core/ # Compiled core modules
|
|
341
|
+
โ โโโ integrations/ # Compiled integrations
|
|
342
|
+
โ โโโ processors/ # Compiled processors
|
|
343
|
+
โ โโโ services/ # Compiled services
|
|
344
|
+
โ โโโ templates/ # Compiled templates
|
|
345
|
+
โ โโโ types/ # Compiled types
|
|
346
|
+
โ
|
|
347
|
+
โโโ tests/ # ๐งช Test suite
|
|
348
|
+
โ โโโ config-options.test.ts # Configuration tests
|
|
349
|
+
โ โโโ e2e-complete.test.ts # End-to-end tests
|
|
350
|
+
โ โโโ integrations/ # Integration tests
|
|
351
|
+
โ โโโ webpack.test.ts
|
|
352
|
+
โ โโโ verify-integrations.mjs
|
|
353
|
+
โ
|
|
354
|
+
โโโ examples/ # ๐ Configuration examples
|
|
355
|
+
โ โโโ webpack.config.example.js
|
|
356
|
+
โ โโโ vite.config.example.js
|
|
357
|
+
โ โโโ rollup.config.example.js
|
|
358
|
+
โ โโโ babel.config.example.js
|
|
359
|
+
โ โโโ next.config.example.js
|
|
360
|
+
โ โโโ jest.config.example.js
|
|
361
|
+
โ
|
|
362
|
+
โโโ docs/ # ๐ Documentation
|
|
363
|
+
โ โโโ FRAMEWORK-GUIDE.md
|
|
364
|
+
โ โโโ INTEGRATIONS.md
|
|
365
|
+
โ โโโ ADR-*.adr.md # Architecture decisions
|
|
366
|
+
โ
|
|
367
|
+
โโโ workspace/ # ๐จ Development workspace
|
|
368
|
+
โโโ input/ # SVG source files
|
|
369
|
+
โโโ output/ # Generated components
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
### Key Directories
|
|
373
|
+
|
|
374
|
+
- **`src/`** - All TypeScript source code
|
|
375
|
+
- **`dist/`** - Compiled JavaScript (generated by `npm run build`)
|
|
376
|
+
- **`bin/`** - CLI executable entry point
|
|
377
|
+
- **`tests/`** - Comprehensive test suite
|
|
378
|
+
- **`examples/`** - Ready-to-use configuration examples
|
|
379
|
+
- **`docs/`** - Additional documentation and ADRs
|
|
380
|
+
- **`workspace/`** - Local development and testing
|
|
381
|
+
|
|
382
|
+
### Generated Output Structure
|
|
383
|
+
|
|
384
|
+
When you run SVGER-CLI, it generates components in your specified output directory:
|
|
385
|
+
|
|
386
|
+
```
|
|
387
|
+
your-project/
|
|
388
|
+
โโโ src/
|
|
389
|
+
โโโ components/
|
|
390
|
+
โโโ icons/ # Your output directory
|
|
391
|
+
โโโ index.ts # Auto-generated exports
|
|
392
|
+
โโโ HomeIcon.tsx # Generated component
|
|
393
|
+
โโโ UserIcon.tsx # Generated component
|
|
394
|
+
โโโ ...
|
|
395
|
+
```
|
|
396
|
+
|
|
397
|
+
---
|
|
398
|
+
|
|
399
|
+
## ๏ฟฝ **Build Tool Integrations**
|
|
400
|
+
|
|
401
|
+
**NEW in v3.0**: SVGER-CLI now provides official integrations for all major build tools, enabling
|
|
402
|
+
seamless SVG-to-component conversion directly in your build pipeline.
|
|
403
|
+
|
|
404
|
+
### Quick Integration Overview
|
|
405
|
+
|
|
406
|
+
| Build Tool | Package Import | Use Case | Key Features |
|
|
407
|
+
| ----------- | ------------------- | ----------------------- | -------------------------------- |
|
|
408
|
+
| **Webpack** | `svger-cli/webpack` | Modern web apps | HMR, Watch mode, Loader support |
|
|
409
|
+
| **Vite** | `svger-cli/vite` | Lightning-fast dev | HMR, Virtual modules, Dev server |
|
|
410
|
+
| **Rollup** | `svger-cli/rollup` | Libraries & apps | Tree-shaking, Source maps |
|
|
411
|
+
| **Babel** | `svger-cli/babel` | Universal transpilation | Import transform, CRA, Gatsby |
|
|
412
|
+
| **Next.js** | `svger-cli/nextjs` | React SSR apps | SSR support, App Router |
|
|
413
|
+
| **Jest** | `svger-cli/jest` | Testing | SVG mocking, Transformers |
|
|
414
|
+
|
|
415
|
+
### Webpack Integration
|
|
416
|
+
|
|
417
|
+
Perfect for modern webpack-based applications with full HMR support.
|
|
418
|
+
|
|
419
|
+
**Install:**
|
|
420
|
+
|
|
421
|
+
```bash
|
|
422
|
+
npm install svger-cli --save-dev
|
|
423
|
+
```
|
|
424
|
+
|
|
425
|
+
**webpack.config.js:**
|
|
426
|
+
|
|
427
|
+
```javascript
|
|
428
|
+
const { SvgerWebpackPlugin } = require('svger-cli/webpack');
|
|
429
|
+
|
|
430
|
+
module.exports = {
|
|
431
|
+
plugins: [
|
|
432
|
+
new SvgerWebpackPlugin({
|
|
433
|
+
source: './src/icons', // SVG source directory
|
|
434
|
+
output: './src/components/icons', // Output directory
|
|
435
|
+
framework: 'react', // Target framework
|
|
436
|
+
typescript: true, // Generate TypeScript files
|
|
437
|
+
hmr: true, // Enable Hot Module Replacement
|
|
438
|
+
generateIndex: true, // Generate index.ts with exports
|
|
439
|
+
}),
|
|
440
|
+
],
|
|
441
|
+
|
|
442
|
+
// Optional: Use the loader for inline SVG imports
|
|
443
|
+
module: {
|
|
444
|
+
rules: [
|
|
445
|
+
{
|
|
446
|
+
test: /\.svg$/,
|
|
447
|
+
use: ['svger-cli/webpack-loader'],
|
|
448
|
+
},
|
|
449
|
+
],
|
|
450
|
+
},
|
|
451
|
+
};
|
|
452
|
+
```
|
|
453
|
+
|
|
454
|
+
**Usage in your app:**
|
|
455
|
+
|
|
456
|
+
```tsx
|
|
457
|
+
import { HomeIcon, UserIcon } from './components/icons';
|
|
458
|
+
|
|
459
|
+
function App() {
|
|
460
|
+
return <HomeIcon width={24} height={24} />;
|
|
461
|
+
}
|
|
462
|
+
```
|
|
463
|
+
|
|
464
|
+
---
|
|
465
|
+
|
|
466
|
+
### Vite Integration
|
|
467
|
+
|
|
468
|
+
Lightning-fast development with HMR and virtual module support.
|
|
469
|
+
|
|
470
|
+
**vite.config.js:**
|
|
471
|
+
|
|
472
|
+
```javascript
|
|
473
|
+
import { svgerVitePlugin } from 'svger-cli/vite';
|
|
474
|
+
|
|
475
|
+
export default {
|
|
476
|
+
plugins: [
|
|
477
|
+
svgerVitePlugin({
|
|
478
|
+
source: './src/icons',
|
|
479
|
+
output: './src/components/icons',
|
|
480
|
+
framework: 'react',
|
|
481
|
+
typescript: true,
|
|
482
|
+
hmr: true, // Hot Module Replacement
|
|
483
|
+
virtualModules: true, // Enable virtual module imports
|
|
484
|
+
}),
|
|
485
|
+
],
|
|
486
|
+
};
|
|
487
|
+
```
|
|
488
|
+
|
|
489
|
+
**Features:**
|
|
490
|
+
|
|
491
|
+
- โ
Instant HMR - changes reflect immediately
|
|
492
|
+
- โ
Virtual modules - `import Icon from 'virtual:svger/icon-name'`
|
|
493
|
+
- โ
Dev server integration
|
|
494
|
+
- โ
Optimized production builds
|
|
495
|
+
|
|
496
|
+
---
|
|
497
|
+
|
|
498
|
+
### Rollup Integration
|
|
499
|
+
|
|
500
|
+
Ideal for library development and tree-shakeable bundles.
|
|
501
|
+
|
|
502
|
+
**rollup.config.js:**
|
|
503
|
+
|
|
504
|
+
```javascript
|
|
505
|
+
import { svgerRollupPlugin } from 'svger-cli/rollup';
|
|
506
|
+
|
|
507
|
+
export default {
|
|
508
|
+
plugins: [
|
|
509
|
+
svgerRollupPlugin({
|
|
510
|
+
source: './src/icons',
|
|
511
|
+
output: './dist/icons',
|
|
512
|
+
framework: 'react',
|
|
513
|
+
typescript: true,
|
|
514
|
+
sourcemap: true, // Generate source maps
|
|
515
|
+
exportType: 'named', // 'named' or 'default'
|
|
516
|
+
}),
|
|
517
|
+
],
|
|
518
|
+
};
|
|
519
|
+
```
|
|
520
|
+
|
|
521
|
+
**Perfect for:**
|
|
522
|
+
|
|
523
|
+
- Component libraries
|
|
524
|
+
- Tree-shakeable exports
|
|
525
|
+
- Multi-framework support
|
|
526
|
+
- Production optimization
|
|
527
|
+
|
|
528
|
+
---
|
|
529
|
+
|
|
530
|
+
### Babel Integration
|
|
531
|
+
|
|
532
|
+
Universal transpilation with automatic import transformation.
|
|
533
|
+
|
|
534
|
+
**babel.config.js:**
|
|
535
|
+
|
|
536
|
+
```javascript
|
|
537
|
+
const { svgerBabelPlugin } = require('svger-cli/babel');
|
|
538
|
+
|
|
539
|
+
module.exports = {
|
|
540
|
+
presets: ['@babel/preset-env', '@babel/preset-react'],
|
|
541
|
+
plugins: [
|
|
542
|
+
[
|
|
543
|
+
svgerBabelPlugin,
|
|
544
|
+
{
|
|
545
|
+
source: './src/icons',
|
|
546
|
+
output: './src/components/icons',
|
|
547
|
+
framework: 'react',
|
|
548
|
+
typescript: true,
|
|
549
|
+
transformImports: true, // Auto-transform SVG imports
|
|
550
|
+
processOnInit: true, // Process all SVGs on plugin init
|
|
551
|
+
generateIndex: true, // Generate barrel exports
|
|
552
|
+
},
|
|
553
|
+
],
|
|
554
|
+
],
|
|
555
|
+
};
|
|
556
|
+
```
|
|
557
|
+
|
|
558
|
+
**Import transformation:**
|
|
559
|
+
|
|
560
|
+
```javascript
|
|
561
|
+
// Before (write this in your code)
|
|
562
|
+
import HomeIcon from './assets/home.svg';
|
|
563
|
+
|
|
564
|
+
// After (automatically transformed)
|
|
565
|
+
import HomeIcon from './components/icons/HomeIcon';
|
|
566
|
+
|
|
567
|
+
// Use it
|
|
568
|
+
<HomeIcon width={24} height={24} />;
|
|
569
|
+
```
|
|
570
|
+
|
|
571
|
+
**Works with:**
|
|
572
|
+
|
|
573
|
+
- Create React App
|
|
574
|
+
- Gatsby
|
|
575
|
+
- Vue CLI
|
|
576
|
+
- Any Babel-based setup
|
|
577
|
+
|
|
578
|
+
---
|
|
579
|
+
|
|
580
|
+
### Next.js Integration
|
|
581
|
+
|
|
582
|
+
Seamless integration with Next.js App Router and Pages Router.
|
|
583
|
+
|
|
584
|
+
**next.config.js:**
|
|
585
|
+
|
|
586
|
+
```javascript
|
|
587
|
+
const { withSvger } = require('svger-cli/nextjs');
|
|
588
|
+
|
|
589
|
+
module.exports = withSvger({
|
|
590
|
+
svger: {
|
|
591
|
+
source: './public/icons',
|
|
592
|
+
output: './components/icons',
|
|
593
|
+
framework: 'react',
|
|
594
|
+
typescript: true,
|
|
595
|
+
ssr: true, // Server-Side Rendering support
|
|
596
|
+
hmr: true, // Hot Module Replacement
|
|
597
|
+
},
|
|
598
|
+
// ...other Next.js config
|
|
599
|
+
reactStrictMode: true,
|
|
600
|
+
});
|
|
601
|
+
```
|
|
602
|
+
|
|
603
|
+
**Features:**
|
|
604
|
+
|
|
605
|
+
- โ
SSR (Server-Side Rendering) support
|
|
606
|
+
- โ
App Router compatible
|
|
607
|
+
- โ
Pages Router compatible
|
|
608
|
+
- โ
Automatic webpack configuration
|
|
609
|
+
- โ
TypeScript support
|
|
610
|
+
|
|
611
|
+
---
|
|
612
|
+
|
|
613
|
+
### Jest Integration
|
|
614
|
+
|
|
615
|
+
Transform SVGs in your tests or mock them for faster execution.
|
|
616
|
+
|
|
617
|
+
**jest.config.js:**
|
|
618
|
+
|
|
619
|
+
**Option 1: Use the preset (recommended)**
|
|
620
|
+
|
|
621
|
+
```javascript
|
|
622
|
+
module.exports = {
|
|
623
|
+
preset: 'svger-cli/jest',
|
|
624
|
+
testEnvironment: 'jsdom',
|
|
625
|
+
};
|
|
626
|
+
```
|
|
627
|
+
|
|
628
|
+
**Option 2: Manual configuration**
|
|
629
|
+
|
|
630
|
+
```javascript
|
|
631
|
+
module.exports = {
|
|
632
|
+
transform: {
|
|
633
|
+
'\\.svg$': [
|
|
634
|
+
'svger-cli/jest-transformer',
|
|
635
|
+
{
|
|
636
|
+
framework: 'react',
|
|
637
|
+
typescript: true,
|
|
638
|
+
mock: false, // Set true for mock mode
|
|
639
|
+
},
|
|
640
|
+
],
|
|
641
|
+
},
|
|
642
|
+
testEnvironment: 'jsdom',
|
|
643
|
+
};
|
|
644
|
+
```
|
|
645
|
+
|
|
646
|
+
**Mock mode** (faster tests):
|
|
647
|
+
|
|
648
|
+
```javascript
|
|
649
|
+
transform: {
|
|
650
|
+
'\\.svg$': ['svger-cli/jest-transformer', {
|
|
651
|
+
mock: true, // Returns simple mock component
|
|
652
|
+
}],
|
|
653
|
+
}
|
|
654
|
+
```
|
|
655
|
+
|
|
656
|
+
---
|
|
657
|
+
|
|
658
|
+
### Complete Integration Documentation
|
|
659
|
+
|
|
660
|
+
For detailed documentation, configuration options, and advanced examples, see:
|
|
661
|
+
|
|
662
|
+
๐ **[Complete Integration Guide](./docs/INTEGRATIONS.md)** - 500+ lines of comprehensive
|
|
663
|
+
documentation
|
|
664
|
+
|
|
665
|
+
**What's included:**
|
|
666
|
+
|
|
667
|
+
- Detailed setup instructions for each build tool
|
|
668
|
+
- All configuration options explained
|
|
669
|
+
- Framework-specific examples (React, Vue, Angular, etc.)
|
|
670
|
+
- Troubleshooting guides
|
|
671
|
+
- Performance optimization tips
|
|
672
|
+
- Feature comparison matrix
|
|
673
|
+
|
|
674
|
+
---
|
|
675
|
+
|
|
676
|
+
## ๏ฟฝ๐ **Quick Start: Your First Conversion**
|
|
232
677
|
|
|
233
678
|
1. **Place your SVGs** in a directory (e.g., `./my-svgs`).
|
|
234
679
|
2. **Run the build command**:
|
|
@@ -2314,6 +2759,82 @@ svger-cli build --framework react --responsive --theme dark
|
|
|
2314
2759
|
|
|
2315
2760
|
---
|
|
2316
2761
|
|
|
2762
|
+
## ๐งช **Testing & CI/CD**
|
|
2763
|
+
|
|
2764
|
+
### **Comprehensive Test Suite**
|
|
2765
|
+
|
|
2766
|
+
SVGER-CLI v3.1.0 includes a production-ready test suite with **114 automated tests** covering:
|
|
2767
|
+
|
|
2768
|
+
- โ
**Unit Tests** - Core modules, utilities, and processors
|
|
2769
|
+
- โ
**Integration Tests** - Complete workflows and multi-framework support
|
|
2770
|
+
- โ
**E2E Tests** - Real-world scenarios and file operations
|
|
2771
|
+
- โ
**CLI Tests** - Command-line interface validation
|
|
2772
|
+
|
|
2773
|
+
```bash
|
|
2774
|
+
# Run all tests
|
|
2775
|
+
npm test
|
|
2776
|
+
|
|
2777
|
+
# Run Jest unit tests
|
|
2778
|
+
npm run test:jest
|
|
2779
|
+
|
|
2780
|
+
# Run with coverage (70% threshold)
|
|
2781
|
+
npm run test:coverage
|
|
2782
|
+
|
|
2783
|
+
# Watch mode for development
|
|
2784
|
+
npm run test:watch
|
|
2785
|
+
```
|
|
2786
|
+
|
|
2787
|
+
**Test Coverage**: 82.5% (94/114 tests passing)
|
|
2788
|
+
- `builder.test.ts` - Build orchestration โ
|
|
2789
|
+
- `templates.test.ts` - Framework templates โ
|
|
2790
|
+
- `utils.test.ts` - Utility functions โ
|
|
2791
|
+
- `integration.test.ts` - End-to-end workflows โ
|
|
2792
|
+
- `cli.test.ts` - CLI commands โ
|
|
2793
|
+
- `config-service.test.ts` - Configuration โ
|
|
2794
|
+
- `svg-processor.test.ts` - SVG processing โ
|
|
2795
|
+
|
|
2796
|
+
See [Test Documentation](./src/__tests__/README.md) for details.
|
|
2797
|
+
|
|
2798
|
+
### **Production CI/CD Pipelines**
|
|
2799
|
+
|
|
2800
|
+
Automated workflows for reliable releases:
|
|
2801
|
+
|
|
2802
|
+
#### **GitHub Actions**
|
|
2803
|
+
- โ
Continuous Integration with automated testing
|
|
2804
|
+
- โ
Release workflow with version management
|
|
2805
|
+
- โ
Multi-platform Docker builds (linux/amd64, linux/arm64)
|
|
2806
|
+
- โ
NPM publishing with provenance
|
|
2807
|
+
- โ
Codecov integration
|
|
2808
|
+
- โ
Snyk security scanning
|
|
2809
|
+
|
|
2810
|
+
#### **Jenkins Pipeline**
|
|
2811
|
+
Complete 11-stage pipeline:
|
|
2812
|
+
1. Checkout & Setup
|
|
2813
|
+
2. Dependencies & Build
|
|
2814
|
+
3. Lint & Test (parallel)
|
|
2815
|
+
4. Security Scanning
|
|
2816
|
+
5. Docker Multi-arch Builds
|
|
2817
|
+
6. Release Management
|
|
2818
|
+
|
|
2819
|
+
#### **Docker Support**
|
|
2820
|
+
```bash
|
|
2821
|
+
# Development
|
|
2822
|
+
docker-compose --profile dev up
|
|
2823
|
+
|
|
2824
|
+
# Production
|
|
2825
|
+
docker-compose --profile prod up
|
|
2826
|
+
|
|
2827
|
+
# Run tests in Docker
|
|
2828
|
+
docker-compose --profile test up
|
|
2829
|
+
|
|
2830
|
+
# CI pipeline
|
|
2831
|
+
docker-compose --profile ci up
|
|
2832
|
+
```
|
|
2833
|
+
|
|
2834
|
+
See [CI/CD Documentation](./.github/CICD.md) for setup guides.
|
|
2835
|
+
|
|
2836
|
+
---
|
|
2837
|
+
|
|
2317
2838
|
## ๐ค **Contributing & Support**
|
|
2318
2839
|
|
|
2319
2840
|
### **Contributing**
|