@curl-runner/cli 1.0.1

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/README.md ADDED
@@ -0,0 +1,518 @@
1
+ # @curl-runner/cli
2
+
3
+ [![TypeScript](https://img.shields.io/badge/typescript-%23007ACC.svg?style=flat-square&logo=typescript&logoColor=white)](https://www.typescriptlang.org/)
4
+ [![Bun](https://img.shields.io/badge/Bun-%23000000.svg?style=flat-square&logo=bun&logoColor=white)](https://bun.sh)
5
+ [![MIT License](https://img.shields.io/badge/License-MIT-yellow.svg?style=flat-square)](https://opensource.org/licenses/MIT)
6
+
7
+ A powerful CLI tool for HTTP request management using YAML configuration files. Built with [Bun](https://bun.sh) for blazing-fast performance and featuring variable interpolation, parallel execution, and response validation.
8
+
9
+ ## 🚀 Features
10
+
11
+ - **📝 YAML Configuration**: Define HTTP requests in simple, readable YAML files
12
+ - **📁 Directory Support**: Execute multiple requests from entire directories
13
+ - **🔄 Execution Modes**: Sequential and parallel execution for optimal performance
14
+ - **🔧 Variable Interpolation**: Dynamic values using environment variables and inline substitutions
15
+ - **✅ Response Validation**: Built-in assertions for status codes, headers, and response bodies
16
+ - **📊 Beautiful Output**: Clean, colorized console output with detailed metrics
17
+ - **🔄 Retry Logic**: Automatic retry mechanisms with configurable delays
18
+ - **🔐 Authentication**: Support for Basic Auth and Bearer token authentication
19
+ - **⚡ Performance Metrics**: Detailed timing statistics for each request
20
+ - **🎯 Glob Patterns**: Flexible file matching with glob support
21
+
22
+ ## 📦 Installation
23
+
24
+ ### From Source
25
+
26
+ ```bash
27
+ # Clone the monorepo
28
+ git clone https://github.com/alexvcasillas/curl-runner.git
29
+ cd curl-runner
30
+
31
+ # Install dependencies
32
+ bun install
33
+
34
+ # Build the CLI
35
+ bun run build:cli
36
+
37
+ # The binary will be available at ./curl-runner
38
+ ```
39
+
40
+ ### Development Mode
41
+
42
+ ```bash
43
+ # Run from source
44
+ bun run packages/cli/src/cli.ts [files...] [options]
45
+
46
+ # Or use the workspace script
47
+ bun run cli [files...] [options]
48
+ ```
49
+
50
+ ## 🚀 Quick Start
51
+
52
+ ### Basic Usage
53
+
54
+ ```bash
55
+ # Run a single YAML file
56
+ curl-runner api-test.yaml
57
+
58
+ # Run all YAML files in current directory
59
+ curl-runner
60
+
61
+ # Run all files in a directory
62
+ curl-runner examples/
63
+
64
+ # Run with options
65
+ curl-runner -pv examples/ # Parallel + Verbose mode
66
+ ```
67
+
68
+ ### Your First Request
69
+
70
+ Create `my-first-request.yaml`:
71
+
72
+ ```yaml
73
+ request:
74
+ name: Get User Data
75
+ url: https://jsonplaceholder.typicode.com/users/1
76
+ method: GET
77
+ expect:
78
+ status: 200
79
+ ```
80
+
81
+ Run it:
82
+
83
+ ```bash
84
+ curl-runner my-first-request.yaml
85
+ ```
86
+
87
+ ## 📝 YAML Configuration
88
+
89
+ ### Single Request Format
90
+
91
+ ```yaml
92
+ request:
93
+ name: Request Name # Optional: Human-readable name
94
+ url: https://api.example.com/users # Required: Target URL
95
+ method: GET # HTTP method (GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS)
96
+ headers: # Optional: Custom headers
97
+ Authorization: Bearer ${TOKEN}
98
+ Content-Type: application/json
99
+ params: # Optional: Query parameters
100
+ page: 1
101
+ limit: 10
102
+ body: # Optional: Request body (JSON, string, etc.)
103
+ name: John Doe
104
+ email: john@example.com
105
+ timeout: 5000 # Optional: Request timeout in ms (default: 30000)
106
+ followRedirects: true # Optional: Follow HTTP redirects (default: true)
107
+ maxRedirects: 5 # Optional: Max redirect count (default: 5)
108
+ auth: # Optional: Authentication
109
+ type: basic|bearer
110
+ username: user # For basic auth
111
+ password: pass # For basic auth
112
+ token: your-token # For bearer auth
113
+ retry: # Optional: Retry configuration
114
+ count: 3 # Number of retry attempts
115
+ delay: 1000 # Delay between retries in ms
116
+ expect: # Optional: Response validation
117
+ status: 200 # Expected status code(s)
118
+ headers: # Expected headers
119
+ Content-Type: application/json
120
+ body: # Expected body content
121
+ contains: "success"
122
+ ```
123
+
124
+ ### Multiple Requests Format
125
+
126
+ ```yaml
127
+ requests:
128
+ - name: Get Users
129
+ url: https://api.example.com/users
130
+ method: GET
131
+
132
+ - name: Create User
133
+ url: https://api.example.com/users
134
+ method: POST
135
+ headers:
136
+ Content-Type: application/json
137
+ body:
138
+ name: Jane Doe
139
+ email: jane@example.com
140
+ ```
141
+
142
+ ### Collection Format
143
+
144
+ ```yaml
145
+ global:
146
+ execution: sequential|parallel # Execution mode
147
+ continueOnError: true|false # Continue on request failures
148
+ variables: # Global variables
149
+ BASE_URL: https://api.example.com
150
+ API_KEY: ${API_KEY} # Environment variable
151
+ output: # Output configuration
152
+ verbose: true # Show detailed output
153
+ showHeaders: true # Display response headers
154
+ showBody: true # Display response body
155
+ showMetrics: true # Display performance metrics
156
+ format: pretty|json|raw # Output format
157
+ saveToFile: results.json # Save results to file
158
+ defaults: # Default request settings
159
+ headers:
160
+ User-Agent: curl-runner/1.0.0
161
+ timeout: 10000
162
+
163
+ collection:
164
+ name: API Integration Tests
165
+ description: Complete test suite for our API
166
+ variables: # Collection-specific variables
167
+ USER_ID: 123
168
+ defaults: # Collection-specific defaults
169
+ headers:
170
+ Accept: application/json
171
+ requests:
172
+ - name: Get User Profile
173
+ url: ${BASE_URL}/users/${USER_ID}
174
+ method: GET
175
+ expect:
176
+ status: 200
177
+ body:
178
+ contains: "email"
179
+
180
+ - name: Update Profile
181
+ url: ${BASE_URL}/users/${USER_ID}
182
+ method: PUT
183
+ headers:
184
+ Content-Type: application/json
185
+ body:
186
+ name: Updated Name
187
+ expect:
188
+ status: [200, 204]
189
+ ```
190
+
191
+ ## 🔧 Variable Interpolation
192
+
193
+ Variables can be defined at multiple levels and are resolved in this order:
194
+
195
+ 1. **Environment variables**: `${ENV_VAR}`
196
+ 2. **Global variables**: Defined in `global.variables`
197
+ 3. **Collection variables**: Defined in `collection.variables`
198
+ 4. **Request variables**: Defined in `request.variables`
199
+
200
+ ```yaml
201
+ global:
202
+ variables:
203
+ BASE_URL: https://api.staging.com
204
+ VERSION: v1
205
+
206
+ collection:
207
+ variables:
208
+ RESOURCE: users
209
+ USER_ID: 123
210
+
211
+ requests:
212
+ - name: Get User
213
+ url: ${BASE_URL}/${VERSION}/${RESOURCE}/${USER_ID}
214
+ method: GET
215
+ variables:
216
+ USER_ID: 456 # Overrides collection variable
217
+ ```
218
+
219
+ ## 📊 CLI Options
220
+
221
+ ```bash
222
+ Usage: curl-runner [files...] [options]
223
+
224
+ Files:
225
+ files... YAML files or directories to process
226
+ (default: current directory *.yaml, *.yml)
227
+
228
+ Options:
229
+ -h, --help Show help message
230
+ -v, --verbose Enable verbose output
231
+ -p, --execution parallel Execute requests in parallel (default: sequential)
232
+ -c, --continue-on-error Continue execution even if requests fail
233
+ --all Find all YAML files recursively in directories
234
+ --output <file> Save execution results to JSON file
235
+ --version Show version information
236
+
237
+ Examples:
238
+ curl-runner # Run all .yaml/.yml files in current directory
239
+ curl-runner api-test.yaml # Run specific file
240
+ curl-runner tests/ examples/ # Run all files in multiple directories
241
+ curl-runner --all -p # Run all files recursively in parallel
242
+ curl-runner tests/*.yaml -vc # Run with verbose output, continue on errors
243
+ ```
244
+
245
+ ## 🎯 Advanced Features
246
+
247
+ ### Authentication
248
+
249
+ ```yaml
250
+ # Basic Authentication
251
+ request:
252
+ url: https://api.example.com/protected
253
+ method: GET
254
+ auth:
255
+ type: basic
256
+ username: myuser
257
+ password: mypass
258
+
259
+ # Bearer Token Authentication
260
+ request:
261
+ url: https://api.example.com/protected
262
+ method: GET
263
+ auth:
264
+ type: bearer
265
+ token: ${ACCESS_TOKEN}
266
+ ```
267
+
268
+ ### Response Validation
269
+
270
+ ```yaml
271
+ request:
272
+ url: https://api.example.com/health
273
+ method: GET
274
+ expect:
275
+ status: 200 # Single status code
276
+ # status: [200, 201, 204] # Multiple acceptable status codes
277
+ headers:
278
+ Content-Type: application/json
279
+ X-Rate-Limit-Remaining: "*" # Use "*" for any value
280
+ body:
281
+ contains: "healthy" # Body must contain this text
282
+ # For JSON responses, you can validate structure:
283
+ # json:
284
+ # status: "ok"
285
+ # version: "1.0.0"
286
+ ```
287
+
288
+ ### Retry Configuration
289
+
290
+ ```yaml
291
+ request:
292
+ url: https://api.example.com/flaky-endpoint
293
+ method: GET
294
+ retry:
295
+ count: 3 # Retry up to 3 times
296
+ delay: 1000 # Wait 1 second between retries
297
+ timeout: 5000 # 5 second timeout per attempt
298
+ ```
299
+
300
+ ### Performance Monitoring
301
+
302
+ ```yaml
303
+ global:
304
+ output:
305
+ showMetrics: true # Enable performance metrics
306
+ format: pretty # Human-readable output
307
+
308
+ request:
309
+ url: https://api.example.com/data
310
+ method: GET
311
+ ```
312
+
313
+ Example output with metrics:
314
+ ```
315
+ ✅ Get API Data (200 OK)
316
+ 📊 Duration: 245ms
317
+ 📈 DNS Lookup: 12ms
318
+ 🔗 TCP Connection: 45ms
319
+ 🔐 TLS Handshake: 89ms
320
+ ⏱️ Time to First Byte: 156ms
321
+ 📥 Download: 34ms
322
+ 📦 Response Size: 1.2KB
323
+ ```
324
+
325
+ ## 📁 File Organization
326
+
327
+ ### Directory Structure Example
328
+
329
+ ```
330
+ api-tests/
331
+ ├── auth/
332
+ │ ├── login.yaml
333
+ │ └── refresh-token.yaml
334
+ ├── users/
335
+ │ ├── crud-operations.yaml
336
+ │ └── profile-management.yaml
337
+ ├── orders/
338
+ │ └── order-lifecycle.yaml
339
+ └── global-config.yaml
340
+ ```
341
+
342
+ ### Running Directory Tests
343
+
344
+ ```bash
345
+ # Run all tests in auth directory
346
+ curl-runner api-tests/auth/
347
+
348
+ # Run all tests recursively
349
+ curl-runner --all api-tests/
350
+
351
+ # Run specific test suites in parallel
352
+ curl-runner -p api-tests/users/ api-tests/orders/
353
+ ```
354
+
355
+ ## 🔍 Example YAML Files
356
+
357
+ The `examples/` directory contains sample configurations:
358
+
359
+ - **`simple.yaml`**: Basic GET request
360
+ - **`collection.yaml`**: Multiple requests with global configuration
361
+ - **`parallel.yaml`**: Parallel execution with various HTTP methods
362
+ - **`test-with-retry.yaml`**: Retry logic and error handling
363
+
364
+ ### Running Examples
365
+
366
+ ```bash
367
+ # Run a specific example
368
+ curl-runner examples/simple.yaml
369
+
370
+ # Run all examples
371
+ curl-runner examples/
372
+
373
+ # Run examples with verbose output
374
+ curl-runner -v examples/
375
+ ```
376
+
377
+ ## 🧪 Testing & Development
378
+
379
+ ### Running Tests
380
+
381
+ ```bash
382
+ # Run unit tests
383
+ bun test
384
+
385
+ # Run integration tests with example files
386
+ curl-runner examples/
387
+
388
+ # Test CLI functionality
389
+ bun run packages/cli/src/cli.ts --help
390
+ ```
391
+
392
+ ### Development Commands
393
+
394
+ ```bash
395
+ # Run in development mode with file watching
396
+ bun run dev:cli
397
+
398
+ # Build the CLI binary
399
+ bun run build:cli
400
+
401
+ # Check code quality
402
+ bun run check
403
+ ```
404
+
405
+ ## 🎨 Output Formats
406
+
407
+ ### Pretty Format (Default)
408
+
409
+ ```
410
+ 🚀 CURL RUNNER
411
+
412
+ ✅ Get User Data (200 OK)
413
+ 📊 Duration: 234ms
414
+ 📦 Size: 856 bytes
415
+
416
+ ❌ Create Invalid User (422 Unprocessable Entity)
417
+ 📊 Duration: 145ms
418
+ ❗ Validation failed: email is required
419
+
420
+ 📈 Summary: 1 successful, 1 failed (379ms total)
421
+ ```
422
+
423
+ ### JSON Format
424
+
425
+ ```bash
426
+ curl-runner --output results.json tests/
427
+ ```
428
+
429
+ ```json
430
+ {
431
+ "summary": {
432
+ "total": 2,
433
+ "successful": 1,
434
+ "failed": 1,
435
+ "duration": 379
436
+ },
437
+ "results": [
438
+ {
439
+ "request": {
440
+ "name": "Get User Data",
441
+ "url": "https://api.example.com/users/1",
442
+ "method": "GET"
443
+ },
444
+ "success": true,
445
+ "status": 200,
446
+ "metrics": {
447
+ "duration": 234,
448
+ "size": 856
449
+ }
450
+ }
451
+ ]
452
+ }
453
+ ```
454
+
455
+ ## 🐛 Troubleshooting
456
+
457
+ ### Common Issues
458
+
459
+ 1. **No YAML files found**
460
+ ```bash
461
+ # Make sure you're in the right directory or specify files explicitly
462
+ curl-runner path/to/your/files.yaml
463
+ ```
464
+
465
+ 2. **Request timeout**
466
+ ```yaml
467
+ request:
468
+ url: https://slow-api.example.com
469
+ timeout: 10000 # Increase timeout to 10 seconds
470
+ ```
471
+
472
+ 3. **SSL certificate issues**
473
+ ```yaml
474
+ request:
475
+ url: https://self-signed-cert.example.com
476
+ insecure: true # Skip SSL verification (not recommended for production)
477
+ ```
478
+
479
+ 4. **Variable interpolation not working**
480
+ ```bash
481
+ # Make sure environment variables are exported
482
+ export API_KEY=your-key-here
483
+ curl-runner config.yaml
484
+ ```
485
+
486
+ ### Debug Mode
487
+
488
+ ```bash
489
+ # Run with maximum verbosity to debug issues
490
+ curl-runner -v your-config.yaml
491
+ ```
492
+
493
+ ## 🤝 Contributing
494
+
495
+ We welcome contributions! Please see the main [CONTRIBUTE.md](../../CONTRIBUTE.md) for guidelines.
496
+
497
+ ### CLI-Specific Development
498
+
499
+ When contributing to the CLI:
500
+
501
+ 1. **Test with examples**: Always test your changes with the provided examples
502
+ 2. **Update TypeScript types**: Keep `src/types/config.ts` up to date
503
+ 3. **Add tests**: Include unit tests for new functionality
504
+ 4. **Update this README**: Document any new features or configuration options
505
+
506
+ ## 📄 License
507
+
508
+ MIT License - see [LICENSE.md](../../LICENSE.md) for details.
509
+
510
+ ## 🔗 Related
511
+
512
+ - **[Main Repository](../../@README.md)**: Full project documentation
513
+ - **[Documentation Website](../docs/)**: Interactive documentation and examples
514
+ - **[Contributing Guide](../../CONTRIBUTE.md)**: How to contribute to the project
515
+
516
+ ---
517
+
518
+ Built with ❤️ using [Bun](https://bun.sh) and TypeScript
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "@curl-runner/cli",
3
+ "version": "1.0.1",
4
+ "description": "A powerful CLI tool for HTTP request management using YAML configuration",
5
+ "type": "module",
6
+ "main": "./src/cli.ts",
7
+ "bin": {
8
+ "curl-runner": "./src/cli.ts"
9
+ },
10
+ "scripts": {
11
+ "start": "bun run src/cli.ts",
12
+ "dev": "bun --watch src/cli.ts",
13
+ "build": "bun build src/cli.ts --compile --outfile ./curl-runner",
14
+ "format": "biome format --write .",
15
+ "lint": "biome lint .",
16
+ "check": "biome check --write .",
17
+ "test": "bun test"
18
+ },
19
+ "keywords": [
20
+ "curl",
21
+ "http",
22
+ "api",
23
+ "testing",
24
+ "yaml",
25
+ "cli",
26
+ "bun"
27
+ ],
28
+ "author": "",
29
+ "license": "MIT",
30
+ "publishConfig": {
31
+ "access": "public"
32
+ },
33
+ "files": [
34
+ "src",
35
+ "README.md"
36
+ ],
37
+ "devDependencies": {
38
+ "@types/bun": "latest"
39
+ },
40
+ "peerDependencies": {
41
+ "typescript": "^5.0.0"
42
+ }
43
+ }