@curl-runner/cli 1.15.0 → 1.16.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.
Files changed (36) hide show
  1. package/package.json +3 -2
  2. package/src/ci-exit.test.ts +0 -215
  3. package/src/cli.ts +0 -1326
  4. package/src/diff/baseline-manager.test.ts +0 -181
  5. package/src/diff/baseline-manager.ts +0 -266
  6. package/src/diff/diff-formatter.ts +0 -316
  7. package/src/diff/index.ts +0 -3
  8. package/src/diff/response-differ.test.ts +0 -330
  9. package/src/diff/response-differ.ts +0 -489
  10. package/src/executor/max-concurrency.test.ts +0 -139
  11. package/src/executor/profile-executor.test.ts +0 -132
  12. package/src/executor/profile-executor.ts +0 -167
  13. package/src/executor/request-executor.ts +0 -663
  14. package/src/parser/yaml.test.ts +0 -480
  15. package/src/parser/yaml.ts +0 -272
  16. package/src/snapshot/index.ts +0 -3
  17. package/src/snapshot/snapshot-differ.test.ts +0 -358
  18. package/src/snapshot/snapshot-differ.ts +0 -296
  19. package/src/snapshot/snapshot-formatter.ts +0 -170
  20. package/src/snapshot/snapshot-manager.test.ts +0 -204
  21. package/src/snapshot/snapshot-manager.ts +0 -342
  22. package/src/types/config.ts +0 -638
  23. package/src/utils/colors.ts +0 -30
  24. package/src/utils/condition-evaluator.test.ts +0 -415
  25. package/src/utils/condition-evaluator.ts +0 -327
  26. package/src/utils/curl-builder.test.ts +0 -165
  27. package/src/utils/curl-builder.ts +0 -201
  28. package/src/utils/logger.ts +0 -856
  29. package/src/utils/response-store.test.ts +0 -213
  30. package/src/utils/response-store.ts +0 -108
  31. package/src/utils/stats.test.ts +0 -161
  32. package/src/utils/stats.ts +0 -151
  33. package/src/utils/version-checker.ts +0 -165
  34. package/src/version.ts +0 -43
  35. package/src/watcher/file-watcher.test.ts +0 -186
  36. package/src/watcher/file-watcher.ts +0 -140
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@curl-runner/cli",
3
- "version": "1.15.0",
3
+ "version": "1.16.1",
4
4
  "description": "A powerful CLI tool for HTTP request management using YAML configuration",
5
5
  "type": "module",
6
6
  "main": "./dist/cli.js",
@@ -14,6 +14,7 @@
14
14
  "format": "biome format --write .",
15
15
  "lint": "biome lint .",
16
16
  "check": "biome check --write .",
17
+ "typecheck": "tsc --noEmit",
17
18
  "test": "bun test"
18
19
  },
19
20
  "keywords": [
@@ -31,7 +32,7 @@
31
32
  "access": "public"
32
33
  },
33
34
  "files": [
34
- "src",
35
+ "dist",
35
36
  "README.md"
36
37
  ],
37
38
  "devDependencies": {
@@ -1,215 +0,0 @@
1
- import { describe, expect, test } from 'bun:test';
2
- import type { ExecutionSummary, GlobalConfig } from './types/config';
3
-
4
- /**
5
- * Determines the appropriate exit code based on execution results and CI configuration.
6
- * This is a standalone function for testing purposes.
7
- */
8
- function determineExitCode(summary: ExecutionSummary, config: GlobalConfig): number {
9
- const { failed, total } = summary;
10
- const ci = config.ci;
11
-
12
- // If no failures, always exit with 0
13
- if (failed === 0) {
14
- return 0;
15
- }
16
-
17
- // Check CI exit code options
18
- if (ci) {
19
- // strictExit: exit 1 if ANY failures occur
20
- if (ci.strictExit) {
21
- return 1;
22
- }
23
-
24
- // failOn: exit 1 if failures exceed the threshold
25
- if (ci.failOn !== undefined && failed > ci.failOn) {
26
- return 1;
27
- }
28
-
29
- // failOnPercentage: exit 1 if failure percentage exceeds the threshold
30
- if (ci.failOnPercentage !== undefined && total > 0) {
31
- const failurePercentage = (failed / total) * 100;
32
- if (failurePercentage > ci.failOnPercentage) {
33
- return 1;
34
- }
35
- }
36
-
37
- // If any CI option is set but thresholds not exceeded, exit 0
38
- if (ci.failOn !== undefined || ci.failOnPercentage !== undefined) {
39
- return 0;
40
- }
41
- }
42
-
43
- // Default behavior: exit 1 if failures AND continueOnError is false
44
- return !config.continueOnError ? 1 : 0;
45
- }
46
-
47
- /**
48
- * Creates a mock execution summary for testing
49
- */
50
- function createSummary(total: number, failed: number): ExecutionSummary {
51
- return {
52
- total,
53
- successful: total - failed,
54
- failed,
55
- duration: 1000,
56
- results: [],
57
- };
58
- }
59
-
60
- describe('CI Exit Code', () => {
61
- describe('default behavior (no CI options)', () => {
62
- test('should exit 0 when no failures', () => {
63
- const summary = createSummary(10, 0);
64
- const config: GlobalConfig = {};
65
- expect(determineExitCode(summary, config)).toBe(0);
66
- });
67
-
68
- test('should exit 1 when failures exist and continueOnError is false', () => {
69
- const summary = createSummary(10, 2);
70
- const config: GlobalConfig = {};
71
- expect(determineExitCode(summary, config)).toBe(1);
72
- });
73
-
74
- test('should exit 0 when failures exist and continueOnError is true', () => {
75
- const summary = createSummary(10, 2);
76
- const config: GlobalConfig = { continueOnError: true };
77
- expect(determineExitCode(summary, config)).toBe(0);
78
- });
79
- });
80
-
81
- describe('--strict-exit flag', () => {
82
- test('should exit 1 when strictExit is true and any failures exist', () => {
83
- const summary = createSummary(10, 1);
84
- const config: GlobalConfig = { ci: { strictExit: true } };
85
- expect(determineExitCode(summary, config)).toBe(1);
86
- });
87
-
88
- test('should exit 0 when strictExit is true but no failures', () => {
89
- const summary = createSummary(10, 0);
90
- const config: GlobalConfig = { ci: { strictExit: true } };
91
- expect(determineExitCode(summary, config)).toBe(0);
92
- });
93
-
94
- test('should exit 1 when strictExit is true even with continueOnError', () => {
95
- const summary = createSummary(10, 1);
96
- const config: GlobalConfig = {
97
- continueOnError: true,
98
- ci: { strictExit: true },
99
- };
100
- expect(determineExitCode(summary, config)).toBe(1);
101
- });
102
- });
103
-
104
- describe('--fail-on threshold', () => {
105
- test('should exit 0 when failures are at or below threshold', () => {
106
- const summary = createSummary(10, 2);
107
- const config: GlobalConfig = { ci: { failOn: 2 } };
108
- expect(determineExitCode(summary, config)).toBe(0);
109
- });
110
-
111
- test('should exit 1 when failures exceed threshold', () => {
112
- const summary = createSummary(10, 3);
113
- const config: GlobalConfig = { ci: { failOn: 2 } };
114
- expect(determineExitCode(summary, config)).toBe(1);
115
- });
116
-
117
- test('should exit 0 when failOn is 0 and no failures', () => {
118
- const summary = createSummary(10, 0);
119
- const config: GlobalConfig = { ci: { failOn: 0 } };
120
- expect(determineExitCode(summary, config)).toBe(0);
121
- });
122
-
123
- test('should exit 1 when failOn is 0 and any failures exist', () => {
124
- const summary = createSummary(10, 1);
125
- const config: GlobalConfig = { ci: { failOn: 0 } };
126
- expect(determineExitCode(summary, config)).toBe(1);
127
- });
128
- });
129
-
130
- describe('--fail-on-percentage threshold', () => {
131
- test('should exit 0 when failure percentage is at or below threshold', () => {
132
- const summary = createSummary(100, 10);
133
- const config: GlobalConfig = { ci: { failOnPercentage: 10 } };
134
- expect(determineExitCode(summary, config)).toBe(0);
135
- });
136
-
137
- test('should exit 1 when failure percentage exceeds threshold', () => {
138
- const summary = createSummary(100, 11);
139
- const config: GlobalConfig = { ci: { failOnPercentage: 10 } };
140
- expect(determineExitCode(summary, config)).toBe(1);
141
- });
142
-
143
- test('should exit 0 when failOnPercentage is 50 and failures are 50%', () => {
144
- const summary = createSummary(10, 5);
145
- const config: GlobalConfig = { ci: { failOnPercentage: 50 } };
146
- expect(determineExitCode(summary, config)).toBe(0);
147
- });
148
-
149
- test('should exit 1 when failOnPercentage is 50 and failures are 51%', () => {
150
- const summary = createSummary(100, 51);
151
- const config: GlobalConfig = { ci: { failOnPercentage: 50 } };
152
- expect(determineExitCode(summary, config)).toBe(1);
153
- });
154
-
155
- test('should handle edge case with 0 total requests', () => {
156
- const summary = createSummary(0, 0);
157
- const config: GlobalConfig = { ci: { failOnPercentage: 10 } };
158
- expect(determineExitCode(summary, config)).toBe(0);
159
- });
160
- });
161
-
162
- describe('combined options', () => {
163
- test('strictExit takes precedence over failOn', () => {
164
- const summary = createSummary(10, 1);
165
- const config: GlobalConfig = {
166
- ci: { strictExit: true, failOn: 5 },
167
- };
168
- expect(determineExitCode(summary, config)).toBe(1);
169
- });
170
-
171
- test('strictExit takes precedence over failOnPercentage', () => {
172
- const summary = createSummary(100, 1);
173
- const config: GlobalConfig = {
174
- ci: { strictExit: true, failOnPercentage: 50 },
175
- };
176
- expect(determineExitCode(summary, config)).toBe(1);
177
- });
178
-
179
- test('failOn checked before failOnPercentage', () => {
180
- const summary = createSummary(100, 6); // 6% failure
181
- const config: GlobalConfig = {
182
- ci: { failOn: 5, failOnPercentage: 10 }, // Would pass percentage but fail count
183
- };
184
- expect(determineExitCode(summary, config)).toBe(1);
185
- });
186
-
187
- test('should exit 0 when all thresholds pass', () => {
188
- const summary = createSummary(100, 5); // 5% failure
189
- const config: GlobalConfig = {
190
- ci: { failOn: 5, failOnPercentage: 10 },
191
- };
192
- expect(determineExitCode(summary, config)).toBe(0);
193
- });
194
- });
195
-
196
- describe('CI option with continueOnError', () => {
197
- test('should still respect CI thresholds even with continueOnError', () => {
198
- const summary = createSummary(10, 3);
199
- const config: GlobalConfig = {
200
- continueOnError: true,
201
- ci: { failOn: 2 },
202
- };
203
- expect(determineExitCode(summary, config)).toBe(1);
204
- });
205
-
206
- test('should exit 0 when threshold not exceeded with continueOnError', () => {
207
- const summary = createSummary(10, 2);
208
- const config: GlobalConfig = {
209
- continueOnError: true,
210
- ci: { failOn: 2 },
211
- };
212
- expect(determineExitCode(summary, config)).toBe(0);
213
- });
214
- });
215
- });