svger-cli 4.0.5 → 4.0.6
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 +9 -0
- package/README.md +33 -32
- package/dist/core/performance-engine.d.ts +1 -0
- package/dist/core/performance-engine.js +7 -10
- package/dist/processors/svg-processor.d.ts +2 -0
- package/dist/processors/svg-processor.js +24 -25
- package/docs/api/media/ADR-SVG-INTRGRATION-METHODS-001.adr.md +157 -0
- package/docs/api/media/CICD.md +315 -0
- package/docs/api/media/INTEGRATIONS.md +543 -0
- package/docs/api/media/LICENSE +21 -0
- package/docs/api/media/PERFORMANCE-RESULTS.md +31 -0
- package/docs/api/media/README.md +364 -0
- package/docs/api/media/REAL-WORLD-BENCHMARKS.md +159 -0
- package/docs/api/media/SAMPLE-SVGS-TESTING.md +276 -0
- package/package.json +1 -1
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
# CI/CD Documentation
|
|
2
|
+
|
|
3
|
+
This directory contains comprehensive CI/CD workflows and configurations for automated building, testing, and deployment of SVGER-CLI.
|
|
4
|
+
|
|
5
|
+
## 📁 Available Workflows
|
|
6
|
+
|
|
7
|
+
### 1. **GitHub Actions** (`.github/workflows/`)
|
|
8
|
+
|
|
9
|
+
#### `ci.yml` - Continuous Integration
|
|
10
|
+
- **Triggers**: Push to `main`/`develop`, Pull Requests
|
|
11
|
+
- **Jobs**:
|
|
12
|
+
- **Test**: Runs on Node.js 18.x, 20.x, 22.x
|
|
13
|
+
- Linting (ESLint)
|
|
14
|
+
- Type checking (TypeScript)
|
|
15
|
+
- Unit & integration tests with coverage
|
|
16
|
+
- Codecov upload
|
|
17
|
+
- **Build**: Compiles TypeScript, generates documentation
|
|
18
|
+
- **Integration Test**: Tests CLI installation and integrations
|
|
19
|
+
- **Security**: NPM audit and Snyk scanning
|
|
20
|
+
|
|
21
|
+
#### `release.yml` - Automated Release
|
|
22
|
+
- **Triggers**: Tag push (`v*.*.*`) or manual dispatch
|
|
23
|
+
- **Jobs**:
|
|
24
|
+
- **Create Release**: Generates changelog and GitHub release
|
|
25
|
+
- **Publish NPM**: Publishes to npm registry
|
|
26
|
+
- **Publish Docker**: Multi-platform Docker images (amd64/arm64)
|
|
27
|
+
- **Update Docs**: Deploys API docs to GitHub Pages
|
|
28
|
+
- **Notify**: Slack notifications
|
|
29
|
+
|
|
30
|
+
### 2. **Jenkins** (`Jenkinsfile`)
|
|
31
|
+
|
|
32
|
+
Full-featured Jenkins pipeline with:
|
|
33
|
+
- Parallel linting and type checking
|
|
34
|
+
- Comprehensive test suites
|
|
35
|
+
- Security auditing
|
|
36
|
+
- Docker image building
|
|
37
|
+
- NPM and Docker registry publishing
|
|
38
|
+
- Slack notifications
|
|
39
|
+
|
|
40
|
+
**Parameters**:
|
|
41
|
+
- `BUILD_TYPE`: CI, Release, or Docker
|
|
42
|
+
- `VERSION`: Release version number
|
|
43
|
+
|
|
44
|
+
**Triggers**:
|
|
45
|
+
- SCM polling every 15 minutes
|
|
46
|
+
- Daily builds on main branch
|
|
47
|
+
|
|
48
|
+
### 3. **Docker** (`Dockerfile`, `docker-compose.yml`)
|
|
49
|
+
|
|
50
|
+
#### Dockerfile
|
|
51
|
+
Multi-stage build optimized for:
|
|
52
|
+
- Small image size (Alpine-based)
|
|
53
|
+
- Security (non-root user)
|
|
54
|
+
- Performance (layer caching)
|
|
55
|
+
- Multi-architecture support
|
|
56
|
+
|
|
57
|
+
#### Docker Compose
|
|
58
|
+
Multiple service profiles:
|
|
59
|
+
- `svger-dev`: Development with hot reload
|
|
60
|
+
- `svger-prod`: Production-like environment
|
|
61
|
+
- `svger-test`: Automated testing
|
|
62
|
+
- `svger-watch`: Watch mode for builds
|
|
63
|
+
- `svger-ci`: CI simulation locally
|
|
64
|
+
- `docs`: Documentation server with Nginx
|
|
65
|
+
|
|
66
|
+
## 🚀 Quick Start
|
|
67
|
+
|
|
68
|
+
### GitHub Actions
|
|
69
|
+
|
|
70
|
+
Already configured! Push to your repository:
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
git push origin main
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
For releases:
|
|
77
|
+
```bash
|
|
78
|
+
git tag v1.0.0
|
|
79
|
+
git push origin v1.0.0
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Jenkins
|
|
83
|
+
|
|
84
|
+
1. **Setup Jenkins**:
|
|
85
|
+
```bash
|
|
86
|
+
# Add required plugins
|
|
87
|
+
- Pipeline
|
|
88
|
+
- Git
|
|
89
|
+
- Docker Pipeline
|
|
90
|
+
- NodeJS
|
|
91
|
+
- Slack Notification (optional)
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
2. **Configure Credentials**:
|
|
95
|
+
- `npm-token`: NPM authentication token
|
|
96
|
+
- `docker-registry-credentials`: Docker registry credentials
|
|
97
|
+
- `SLACK_WEBHOOK` (optional): Slack webhook URL
|
|
98
|
+
|
|
99
|
+
3. **Create Pipeline**:
|
|
100
|
+
- New Item → Pipeline
|
|
101
|
+
- Configure SCM to point to repository
|
|
102
|
+
- Select `Jenkinsfile` from repository
|
|
103
|
+
|
|
104
|
+
4. **Run Build**:
|
|
105
|
+
```bash
|
|
106
|
+
# CI Build
|
|
107
|
+
Build with Parameters → BUILD_TYPE: CI
|
|
108
|
+
|
|
109
|
+
# Release
|
|
110
|
+
Build with Parameters → BUILD_TYPE: Release, VERSION: 1.0.0
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### Docker Development
|
|
114
|
+
|
|
115
|
+
1. **Start development environment**:
|
|
116
|
+
```bash
|
|
117
|
+
# Create workspace directories
|
|
118
|
+
mkdir -p workspace/input workspace/output
|
|
119
|
+
|
|
120
|
+
# Start dev container
|
|
121
|
+
docker-compose up svger-dev
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
2. **Run tests**:
|
|
125
|
+
```bash
|
|
126
|
+
docker-compose --profile test up svger-test
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
3. **Build production image**:
|
|
130
|
+
```bash
|
|
131
|
+
docker build -t svger-cli:latest .
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
4. **Run production container**:
|
|
135
|
+
```bash
|
|
136
|
+
# Process SVGs
|
|
137
|
+
docker run -v $(pwd)/svgs:/workspace/input \
|
|
138
|
+
-v $(pwd)/output:/workspace/output \
|
|
139
|
+
svger-cli:latest build \
|
|
140
|
+
--src /workspace/input \
|
|
141
|
+
--out /workspace/output \
|
|
142
|
+
--framework react \
|
|
143
|
+
--typescript
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
5. **Start all services**:
|
|
147
|
+
```bash
|
|
148
|
+
# Development + docs
|
|
149
|
+
docker-compose --profile docs up
|
|
150
|
+
|
|
151
|
+
# Full CI simulation
|
|
152
|
+
docker-compose --profile ci up
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
## 🔧 Configuration
|
|
156
|
+
|
|
157
|
+
### Required Secrets (GitHub Actions)
|
|
158
|
+
|
|
159
|
+
Add these to your repository settings → Secrets and variables → Actions:
|
|
160
|
+
|
|
161
|
+
- `NPM_TOKEN`: NPM authentication token for publishing
|
|
162
|
+
- `CODECOV_TOKEN` (optional): Codecov upload token
|
|
163
|
+
- `SNYK_TOKEN` (optional): Snyk security scanning
|
|
164
|
+
- `SLACK_WEBHOOK_URL` (optional): Slack notifications
|
|
165
|
+
|
|
166
|
+
### Required Secrets (Jenkins)
|
|
167
|
+
|
|
168
|
+
Configure in Jenkins → Credentials:
|
|
169
|
+
|
|
170
|
+
- **npm-token** (Secret text): NPM authentication
|
|
171
|
+
- **docker-registry-credentials** (Username/Password): Docker registry
|
|
172
|
+
- **SLACK_WEBHOOK** (Secret text, optional): Slack notifications
|
|
173
|
+
|
|
174
|
+
## 📊 Workflow Details
|
|
175
|
+
|
|
176
|
+
### Test Coverage
|
|
177
|
+
|
|
178
|
+
All workflows include:
|
|
179
|
+
- ✅ Linting with ESLint
|
|
180
|
+
- ✅ TypeScript type checking
|
|
181
|
+
- ✅ Framework tests (React, Vue, Angular, Svelte)
|
|
182
|
+
- ✅ Configuration tests
|
|
183
|
+
- ✅ End-to-end tests
|
|
184
|
+
- ✅ Integration tests
|
|
185
|
+
- ✅ Code coverage reporting
|
|
186
|
+
|
|
187
|
+
### Security Scanning
|
|
188
|
+
|
|
189
|
+
- NPM audit for dependency vulnerabilities
|
|
190
|
+
- Snyk security scanning
|
|
191
|
+
- Docker image vulnerability scanning
|
|
192
|
+
|
|
193
|
+
### Performance Optimization
|
|
194
|
+
|
|
195
|
+
- Parallel test execution
|
|
196
|
+
- Docker layer caching
|
|
197
|
+
- NPM cache for faster installs
|
|
198
|
+
- Multi-stage builds for smaller images
|
|
199
|
+
|
|
200
|
+
## 🐳 Docker Commands Reference
|
|
201
|
+
|
|
202
|
+
```bash
|
|
203
|
+
# Development
|
|
204
|
+
docker-compose up svger-dev # Start dev environment
|
|
205
|
+
docker-compose exec svger-dev npm test # Run tests in container
|
|
206
|
+
docker-compose logs -f svger-dev # View logs
|
|
207
|
+
|
|
208
|
+
# Testing
|
|
209
|
+
docker-compose --profile test up # Run test suite
|
|
210
|
+
docker-compose --profile ci up # Simulate CI locally
|
|
211
|
+
|
|
212
|
+
# Production
|
|
213
|
+
docker-compose --profile production up # Production environment
|
|
214
|
+
|
|
215
|
+
# Watch mode
|
|
216
|
+
docker-compose --profile watch up # Build with watch mode
|
|
217
|
+
|
|
218
|
+
# Documentation
|
|
219
|
+
docker-compose --profile docs up # Serve docs on :8080
|
|
220
|
+
|
|
221
|
+
# Cleanup
|
|
222
|
+
docker-compose down -v # Stop and remove volumes
|
|
223
|
+
docker system prune -af # Clean everything
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
## 🔄 Release Process
|
|
227
|
+
|
|
228
|
+
### Automated Release (Recommended)
|
|
229
|
+
|
|
230
|
+
1. **Update version** in `package.json`
|
|
231
|
+
2. **Update** `CHANGELOG.md`
|
|
232
|
+
3. **Commit changes**:
|
|
233
|
+
```bash
|
|
234
|
+
git add .
|
|
235
|
+
git commit -m "chore: release v1.0.0"
|
|
236
|
+
```
|
|
237
|
+
4. **Create and push tag**:
|
|
238
|
+
```bash
|
|
239
|
+
git tag v1.0.0
|
|
240
|
+
git push origin main --tags
|
|
241
|
+
```
|
|
242
|
+
5. **GitHub Actions** automatically:
|
|
243
|
+
- Creates GitHub release
|
|
244
|
+
- Publishes to NPM
|
|
245
|
+
- Builds and pushes Docker image
|
|
246
|
+
- Updates documentation
|
|
247
|
+
|
|
248
|
+
### Manual Release
|
|
249
|
+
|
|
250
|
+
```bash
|
|
251
|
+
# Using npm scripts
|
|
252
|
+
npm run release # Patch version (1.0.0 → 1.0.1)
|
|
253
|
+
npm run release:minor # Minor version (1.0.0 → 1.1.0)
|
|
254
|
+
npm run release:major # Major version (1.0.0 → 2.0.0)
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
## 📈 Monitoring & Notifications
|
|
258
|
+
|
|
259
|
+
### Build Status
|
|
260
|
+
|
|
261
|
+
- **GitHub Actions**: Check Actions tab in repository
|
|
262
|
+
- **Jenkins**: Jenkins dashboard
|
|
263
|
+
- **Docker**: `docker-compose logs`
|
|
264
|
+
|
|
265
|
+
### Notifications
|
|
266
|
+
|
|
267
|
+
Configure Slack webhooks for build notifications:
|
|
268
|
+
- ✅ Successful builds
|
|
269
|
+
- ❌ Failed builds
|
|
270
|
+
- 📦 New releases
|
|
271
|
+
|
|
272
|
+
## 🛠️ Troubleshooting
|
|
273
|
+
|
|
274
|
+
### Common Issues
|
|
275
|
+
|
|
276
|
+
1. **NPM publish fails**:
|
|
277
|
+
- Verify `NPM_TOKEN` is set correctly
|
|
278
|
+
- Check npm registry authentication
|
|
279
|
+
- Ensure version doesn't exist already
|
|
280
|
+
|
|
281
|
+
2. **Docker build fails**:
|
|
282
|
+
- Check Docker daemon is running
|
|
283
|
+
- Verify Dockerfile syntax
|
|
284
|
+
- Check available disk space
|
|
285
|
+
|
|
286
|
+
3. **Tests fail in CI but pass locally**:
|
|
287
|
+
- Ensure environment variables are set
|
|
288
|
+
- Check Node.js version matches
|
|
289
|
+
- Review CI logs for specific errors
|
|
290
|
+
|
|
291
|
+
4. **Jenkins build stuck**:
|
|
292
|
+
- Check executor availability
|
|
293
|
+
- Review console output
|
|
294
|
+
- Verify credentials are configured
|
|
295
|
+
|
|
296
|
+
## 📚 Additional Resources
|
|
297
|
+
|
|
298
|
+
- [GitHub Actions Documentation](https://docs.github.com/en/actions)
|
|
299
|
+
- [Jenkins Pipeline Syntax](https://www.jenkins.io/doc/book/pipeline/)
|
|
300
|
+
- [Docker Best Practices](https://docs.docker.com/develop/dev-best-practices/)
|
|
301
|
+
- [NPM Publishing Guide](https://docs.npmjs.com/packages-and-modules/contributing-packages-to-the-registry)
|
|
302
|
+
|
|
303
|
+
## 🤝 Contributing
|
|
304
|
+
|
|
305
|
+
When adding new CI/CD features:
|
|
306
|
+
|
|
307
|
+
1. Test workflows locally using Docker Compose
|
|
308
|
+
2. Validate GitHub Actions with [act](https://github.com/nektos/act)
|
|
309
|
+
3. Update this documentation
|
|
310
|
+
4. Add tests for new functionality
|
|
311
|
+
5. Submit PR with clear description
|
|
312
|
+
|
|
313
|
+
---
|
|
314
|
+
|
|
315
|
+
For issues or questions, please open an issue on GitHub or contact the maintainers.
|