@http-forge/cli 0.1.6 → 0.2.5
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 +447 -232
- package/dist/ai/providers.d.ts +34 -0
- package/dist/ai/providers.d.ts.map +1 -0
- package/dist/ai/providers.js +98 -0
- package/dist/ai/providers.js.map +1 -0
- package/dist/commands/env.d.ts +14 -0
- package/dist/commands/env.d.ts.map +1 -0
- package/dist/commands/env.js +165 -0
- package/dist/commands/env.js.map +1 -0
- package/dist/commands/generate-collection.d.ts +11 -0
- package/dist/commands/generate-collection.d.ts.map +1 -0
- package/dist/commands/generate-collection.js +301 -0
- package/dist/commands/generate-collection.js.map +1 -0
- package/dist/commands/list.d.ts +12 -0
- package/dist/commands/list.d.ts.map +1 -0
- package/dist/commands/list.js +170 -0
- package/dist/commands/list.js.map +1 -0
- package/dist/commands/mcp.d.ts +19 -0
- package/dist/commands/mcp.d.ts.map +1 -0
- package/dist/commands/mcp.js +211 -0
- package/dist/commands/mcp.js.map +1 -0
- package/dist/commands/run.d.ts +35 -0
- package/dist/commands/run.d.ts.map +1 -0
- package/dist/commands/run.js +589 -0
- package/dist/commands/run.js.map +1 -0
- package/dist/commands/schedule.d.ts +11 -0
- package/dist/commands/schedule.d.ts.map +1 -0
- package/dist/commands/schedule.js +237 -0
- package/dist/commands/schedule.js.map +1 -0
- package/dist/commands/suggest-env.d.ts +12 -0
- package/dist/commands/suggest-env.d.ts.map +1 -0
- package/dist/commands/suggest-env.js +205 -0
- package/dist/commands/suggest-env.js.map +1 -0
- package/dist/commands.d.ts +14 -7
- package/dist/commands.d.ts.map +1 -1
- package/dist/commands.js +28 -436
- package/dist/commands.js.map +1 -1
- package/dist/curl-parser.d.ts +51 -0
- package/dist/curl-parser.d.ts.map +1 -0
- package/dist/curl-parser.js +365 -0
- package/dist/curl-parser.js.map +1 -0
- package/dist/index.d.ts +7 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +162 -87
- package/dist/index.js.map +1 -1
- package/dist/output/format.d.ts +63 -0
- package/dist/output/format.d.ts.map +1 -0
- package/dist/output/format.js +280 -0
- package/dist/output/format.js.map +1 -0
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* HTTP Forge CLI
|
|
4
4
|
*
|
|
5
|
-
* Command-line interface for HTTP Forge runtime operations
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
5
|
+
* Command-line interface for HTTP Forge runtime operations.
|
|
6
|
+
*
|
|
7
|
+
* http-forge run collection <name>
|
|
8
|
+
* http-forge run suite <name>
|
|
9
|
+
* http-forge run request <name> --collection <ref>
|
|
10
|
+
* http-forge run folder <path> --collection <ref>
|
|
11
|
+
* http-forge mcp start --port 3100
|
|
11
12
|
*/
|
|
12
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
14
|
exports.main = main;
|
|
@@ -21,22 +22,30 @@ async function main() {
|
|
|
21
22
|
const command = args[0];
|
|
22
23
|
try {
|
|
23
24
|
switch (command) {
|
|
24
|
-
case 'mcp
|
|
25
|
-
await (0, commands_1.
|
|
25
|
+
case 'mcp':
|
|
26
|
+
await (0, commands_1.handleMcpGroup)(args.slice(1));
|
|
27
|
+
break;
|
|
28
|
+
case 'run':
|
|
29
|
+
await (0, commands_1.handleRunGroup)(args.slice(1));
|
|
30
|
+
break;
|
|
31
|
+
case 'copy-as':
|
|
32
|
+
await (0, commands_1.handleCopyAs)(args.slice(1));
|
|
33
|
+
break;
|
|
34
|
+
case 'list':
|
|
35
|
+
await (0, commands_1.handleList)(args.slice(1));
|
|
26
36
|
break;
|
|
27
|
-
case '
|
|
28
|
-
await (0, commands_1.
|
|
37
|
+
case 'env':
|
|
38
|
+
await (0, commands_1.handleEnv)(args.slice(1));
|
|
29
39
|
break;
|
|
30
|
-
case '
|
|
31
|
-
await (0, commands_1.
|
|
40
|
+
case 'generate-collection':
|
|
41
|
+
await (0, commands_1.handleGenerateCollection)(args.slice(1));
|
|
32
42
|
break;
|
|
33
|
-
case '
|
|
34
|
-
await (0, commands_1.
|
|
43
|
+
case 'suggest-env':
|
|
44
|
+
await (0, commands_1.handleSuggestEnv)(args.slice(1));
|
|
35
45
|
break;
|
|
36
|
-
case '
|
|
37
|
-
await (0, commands_1.
|
|
46
|
+
case 'schedule':
|
|
47
|
+
await (0, commands_1.handleSchedule)(args.slice(1));
|
|
38
48
|
break;
|
|
39
|
-
case '--help':
|
|
40
49
|
case '-h':
|
|
41
50
|
printUsage();
|
|
42
51
|
process.exit(0);
|
|
@@ -60,96 +69,162 @@ USAGE:
|
|
|
60
69
|
http-forge <command> [options]
|
|
61
70
|
|
|
62
71
|
COMMANDS:
|
|
63
|
-
|
|
72
|
+
run <type> [name] Execute requests
|
|
73
|
+
Types:
|
|
74
|
+
collection <name> Run all requests in a collection
|
|
75
|
+
suite <name> Run a test suite (accepts name or id)
|
|
76
|
+
request <name> Run a single request (also needs --collection)
|
|
77
|
+
folder <path> Run requests under a folder (also needs --collection)
|
|
78
|
+
Options:
|
|
79
|
+
--env <name> Environment (default: $HTTP_FORGE_ENV or dev)
|
|
80
|
+
--environment <name> Same as --env (long form)
|
|
81
|
+
--workspace <path> Workspace folder (default: $HTTP_FORGE_WORKSPACE or cwd)
|
|
82
|
+
--collection <ref> Collection for 'request' and 'folder' types
|
|
83
|
+
--folder <path> Scope to a folder (for 'request'); slash-separated
|
|
84
|
+
--no-recursive Run only immediate children (for 'folder' type)
|
|
85
|
+
--var <KEY=VALUE> Override a variable (repeatable; highest priority)
|
|
86
|
+
--iterations <num> Number of iterations (default: 1)
|
|
87
|
+
--concurrency <num> Parallel virtual users (default: 1)
|
|
88
|
+
--stop-on-error Stop on first failure
|
|
89
|
+
--delay <ms> Delay between requests in milliseconds
|
|
90
|
+
--include <field> Extra output fields (repeatable):
|
|
91
|
+
collection/suite/folder: perRequest, failedOnly, consoleOutput
|
|
92
|
+
request: headers, cookies, tests, consoleOutput
|
|
93
|
+
--reporter <spec> Generate a report (repeatable): html, junit, or name:path
|
|
94
|
+
--reporter html
|
|
95
|
+
--reporter junit:results/junit.xml
|
|
96
|
+
--exit-code Exit 1 when any assertion fails (for CI)
|
|
97
|
+
--output <fmt> Output format: json or table (default: json)
|
|
98
|
+
--json Short for --output json
|
|
99
|
+
|
|
100
|
+
mcp <action> Manage MCP server lifecycle
|
|
64
101
|
Actions:
|
|
65
|
-
start Start MCP server
|
|
66
|
-
stop Stop MCP server
|
|
67
|
-
status Show MCP server status
|
|
68
|
-
Options
|
|
102
|
+
start Start MCP server
|
|
103
|
+
stop Stop MCP server
|
|
104
|
+
status Show MCP server status
|
|
105
|
+
Options:
|
|
69
106
|
--port <num> Port to listen on (default: 3100)
|
|
70
107
|
--host <addr> Host to bind to (default: 127.0.0.1)
|
|
71
|
-
--workspace <path> Workspace folder (default:
|
|
108
|
+
--workspace <path> Workspace folder (default: $HTTP_FORGE_WORKSPACE or cwd)
|
|
72
109
|
|
|
73
|
-
|
|
110
|
+
copy-as Print a request as a code snippet
|
|
74
111
|
Required:
|
|
75
112
|
--collection <ref> Collection (id, slug, or name)
|
|
76
113
|
--request <ref> Request (id, slug, or name)
|
|
114
|
+
--lang <name> Target language: curl, fetch, python
|
|
77
115
|
Optional:
|
|
78
|
-
--folder <path> Scope
|
|
79
|
-
|
|
80
|
-
--
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
116
|
+
--folder <path> Scope resolution to this folder
|
|
117
|
+
--workspace <path> Workspace folder (default: $HTTP_FORGE_WORKSPACE or cwd)
|
|
118
|
+
--environment <name> Environment to resolve variables against
|
|
119
|
+
|
|
120
|
+
list <subcommand> List workspace resources
|
|
121
|
+
Subcommands:
|
|
122
|
+
collections List all collections (id, name, request count)
|
|
123
|
+
suites List all test suites (id, name, request count)
|
|
124
|
+
environments List all environments (name, active, variable count)
|
|
125
|
+
requests List requests in a collection (requires --collection)
|
|
126
|
+
folders List folders in a collection (requires --collection)
|
|
127
|
+
Options:
|
|
128
|
+
--workspace <path> Workspace folder (default: $HTTP_FORGE_WORKSPACE or cwd)
|
|
129
|
+
--collection <ref> Collection reference (required for 'requests' and 'folders')
|
|
130
|
+
--folder <path> Scope to a sub-folder (for 'requests' and 'folders')
|
|
85
131
|
--output <fmt> Output format: json or table (default: json)
|
|
86
132
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
--
|
|
95
|
-
--
|
|
96
|
-
--
|
|
97
|
-
|
|
98
|
-
|
|
133
|
+
env <subcommand> Manage environment variables
|
|
134
|
+
Subcommands:
|
|
135
|
+
list List all environments (name, active, variable count)
|
|
136
|
+
get <name> Show all variables for an environment
|
|
137
|
+
set <env> <k> <v> Permanently write a variable to the env JSON file
|
|
138
|
+
unset <env> <key> Remove a variable from the env JSON file
|
|
139
|
+
Options:
|
|
140
|
+
--workspace <path> Workspace folder (default: $HTTP_FORGE_WORKSPACE or cwd)
|
|
141
|
+
--output <fmt> Output format for list/get: json or table (default: json)
|
|
142
|
+
--no-values Omit values in 'get' (show only key names)
|
|
143
|
+
|
|
144
|
+
generate-collection Create a collection from a curl command, Postman file, or OpenAPI spec
|
|
145
|
+
Sources (one required):
|
|
146
|
+
--curl <cmd> curl command string (quote the whole thing)
|
|
147
|
+
--postman <file> Postman Collection v2.x JSON file
|
|
148
|
+
--openapi <file> OpenAPI 3.0 spec file (.json / .yaml / .yml)
|
|
149
|
+
Options:
|
|
150
|
+
--name <name> Collection name (default: derived from source)
|
|
151
|
+
--env <name> Write detected vars (curl) or create env (openapi) with this name
|
|
152
|
+
--create-envs openapi: create environments from server URLs
|
|
153
|
+
--ai Enhance collection with AI (needs OPENAI_API_KEY or ANTHROPIC_API_KEY)
|
|
154
|
+
--workspace <path> Workspace folder (default: $HTTP_FORGE_WORKSPACE or cwd)
|
|
99
155
|
--output <fmt> Output format: json or table (default: json)
|
|
100
156
|
|
|
101
|
-
|
|
157
|
+
suggest-env Detect hardcoded values and suggest environment variables
|
|
102
158
|
Required:
|
|
103
|
-
--collection <ref> Collection
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
--
|
|
108
|
-
|
|
109
|
-
--workspace <path> Workspace folder (default:
|
|
110
|
-
--environment <name> Environment to use
|
|
111
|
-
--var <KEY=VALUE> Override a variable (repeatable; highest priority)
|
|
112
|
-
--iterations <num> Number of iterations (default: 1)
|
|
113
|
-
--stop-on-error Stop on first failure
|
|
114
|
-
--delay <ms> Delay between requests
|
|
115
|
-
--include <field> Include extra fields (repeatable):
|
|
116
|
-
perRequest, failedOnly, consoleOutput, report
|
|
159
|
+
--collection <ref> Collection name, slug, or id
|
|
160
|
+
Options:
|
|
161
|
+
--apply Replace values in collection + write to environment
|
|
162
|
+
--env <name> Target environment for --apply (default: active env)
|
|
163
|
+
--ai Use AI detection (needs OPENAI_API_KEY or ANTHROPIC_API_KEY)
|
|
164
|
+
--min-occurrences Only suggest values in at least N requests (default: 1)
|
|
165
|
+
--workspace <path> Workspace folder (default: $HTTP_FORGE_WORKSPACE or cwd)
|
|
117
166
|
--output <fmt> Output format: json or table (default: json)
|
|
118
167
|
|
|
119
|
-
|
|
168
|
+
schedule Generate a CI schedule config for running a test suite
|
|
120
169
|
Required:
|
|
121
|
-
--suite <
|
|
122
|
-
|
|
123
|
-
--
|
|
124
|
-
--
|
|
125
|
-
--
|
|
126
|
-
--
|
|
127
|
-
--
|
|
128
|
-
--
|
|
129
|
-
--
|
|
130
|
-
|
|
131
|
-
--output <fmt> Output format: json or table (default: json)
|
|
170
|
+
--suite <name> Test suite name (or id/slug)
|
|
171
|
+
Options:
|
|
172
|
+
--env <name> Environment to pass to the suite run
|
|
173
|
+
--cron <expr> Cron schedule expression (default: "0 */6 * * *")
|
|
174
|
+
--output <path> Output file path (default: .github/workflows/http-forge-<suite>.yml)
|
|
175
|
+
--reporter <spec> Reporter spec, e.g. "junit:results/junit.xml" (default: junit)
|
|
176
|
+
--no-exit-code Do not fail the job on assertion failures
|
|
177
|
+
--format <type> github-actions | cron | both (default: github-actions)
|
|
178
|
+
--print-cron Print cron entry to stdout (alias for --format cron)
|
|
179
|
+
--workspace <path> Workspace folder (default: $HTTP_FORGE_WORKSPACE or cwd)
|
|
132
180
|
|
|
133
181
|
EXAMPLES:
|
|
134
|
-
http-forge mcp
|
|
135
|
-
http-forge mcp
|
|
136
|
-
http-forge mcp
|
|
137
|
-
http-forge run
|
|
138
|
-
http-forge run
|
|
139
|
-
http-forge run
|
|
140
|
-
http-forge run
|
|
141
|
-
http-forge run
|
|
142
|
-
http-forge run
|
|
143
|
-
http-forge run
|
|
144
|
-
http-forge run
|
|
145
|
-
http-forge run
|
|
182
|
+
http-forge mcp start --port 3100
|
|
183
|
+
http-forge mcp status
|
|
184
|
+
http-forge mcp stop
|
|
185
|
+
http-forge run collection "my-api" --env dev
|
|
186
|
+
http-forge run request "Get Users" --collection "my-api" --env production
|
|
187
|
+
http-forge run request "Get Users" --collection "my-api" --folder Auth --include tests
|
|
188
|
+
http-forge run collection "my-api" --env dev --include perRequest
|
|
189
|
+
http-forge run collection "my-api" --env prod --var BASE_URL=https://api.example.com --var API_KEY=$API_KEY
|
|
190
|
+
http-forge run folder "Auth/Login" --collection "my-api" --env dev --include perRequest
|
|
191
|
+
http-forge run folder Users --collection "my-api" --no-recursive --include report
|
|
192
|
+
http-forge run suite "smoke-tests" --iterations 3 --include failedOnly --output json
|
|
193
|
+
http-forge run suite "smoke-tests" --env staging --var TOKEN=$CI_TOKEN
|
|
194
|
+
http-forge run suite "smoke-tests" --reporter junit:results/junit.xml --exit-code
|
|
195
|
+
http-forge run suite "smoke-tests" --reporter html --reporter junit:results/junit.xml --exit-code
|
|
196
|
+
http-forge run suite "load-test" --concurrency 10 --iterations 5
|
|
197
|
+
http-forge copy-as --collection my-api --request get-users --lang curl
|
|
198
|
+
http-forge copy-as --collection my-api --request "Create User" --lang python
|
|
199
|
+
http-forge list collections
|
|
200
|
+
http-forge list suites --output table
|
|
201
|
+
http-forge list environments --workspace /path/to/workspace
|
|
202
|
+
http-forge list requests --collection my-api --output table
|
|
203
|
+
http-forge list requests --collection my-api --folder Auth
|
|
204
|
+
http-forge list folders --collection my-api
|
|
205
|
+
http-forge env list
|
|
206
|
+
http-forge env get staging
|
|
207
|
+
http-forge env get staging --output table
|
|
208
|
+
http-forge env set staging BASE_URL https://staging.example.com
|
|
209
|
+
http-forge env set staging API_KEY=my-secret-key
|
|
210
|
+
http-forge env unset staging OLD_VAR
|
|
211
|
+
http-forge generate-collection --curl "curl https://api.example.com/users"
|
|
212
|
+
http-forge generate-collection --curl "curl -X POST -H 'Authorization: Bearer sk-abc' https://api.example.com/v1/users -d '{\"name\":\"Alice\"}'" --env dev
|
|
213
|
+
http-forge generate-collection --postman ./MyCollection.postman_collection.json
|
|
214
|
+
http-forge generate-collection --openapi ./openapi.yaml --name "Payments API" --create-envs --env staging
|
|
215
|
+
http-forge suggest-env --collection my-api --output table
|
|
216
|
+
http-forge suggest-env --collection my-api --apply --env staging
|
|
217
|
+
http-forge schedule --suite smoke-tests --env staging
|
|
218
|
+
http-forge schedule --suite regression --env prod --cron "0 2 * * *" --format both
|
|
146
219
|
|
|
147
220
|
NOTES:
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
221
|
+
Collection, request, and folder references accept an id, a slug, or a display
|
|
222
|
+
name. Resolution tries id, then slug, then name, and stops at the first match.
|
|
223
|
+
If a name matches multiple items, the command lists the candidates and exits
|
|
224
|
+
non-zero — pass the id or slug to disambiguate.
|
|
225
|
+
|
|
226
|
+
Set HTTP_FORGE_WORKSPACE and HTTP_FORGE_ENV in your shell profile to avoid
|
|
227
|
+
repeating --workspace and --env on every command.
|
|
153
228
|
|
|
154
229
|
OPTIONS:
|
|
155
230
|
--help, -h Show this help message
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;AAaH,oBA0DC;AArED,yCASoB;AAEb,KAAK,UAAU,IAAI;IACxB,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAEnC,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACtB,UAAU,EAAE,CAAC;QACb,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,MAAM,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;IAExB,IAAI,CAAC;QACH,QAAQ,OAAO,EAAE,CAAC;YAChB,KAAK,KAAK;gBACR,MAAM,IAAA,yBAAc,EAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;gBACpC,MAAM;YAER,KAAK,KAAK;gBACR,MAAM,IAAA,yBAAc,EAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;gBACpC,MAAM;YAER,KAAK,SAAS;gBACZ,MAAM,IAAA,uBAAY,EAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;gBAClC,MAAM;YAER,KAAK,MAAM;gBACT,MAAM,IAAA,qBAAU,EAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;gBAChC,MAAM;YAER,KAAK,KAAK;gBACR,MAAM,IAAA,oBAAS,EAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;gBAC/B,MAAM;YAER,KAAK,qBAAqB;gBACxB,MAAM,IAAA,mCAAwB,EAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;gBAC9C,MAAM;YAER,KAAK,aAAa;gBAChB,MAAM,IAAA,2BAAgB,EAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;gBACtC,MAAM;YAER,KAAK,UAAU;gBACb,MAAM,IAAA,yBAAc,EAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;gBACpC,MAAM;YAER,KAAK,IAAI;gBACP,UAAU,EAAE,CAAC;gBACb,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;gBAChB,MAAM;YAER;gBACE,OAAO,CAAC,KAAK,CAAC,oBAAoB,OAAO,EAAE,CAAC,CAAC;gBAC7C,UAAU,EAAE,CAAC;gBACb,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACpB,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAG,KAAe,CAAC,OAAO,CAAC,CAAC;QAClD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC;AAED,SAAS,UAAU;IACjB,OAAO,CAAC,GAAG,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsKb,CAAC,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Output formatting and argument parsing utilities shared across all CLI commands.
|
|
3
|
+
*/
|
|
4
|
+
import type { ResolutionInfo } from '@http-forge/core';
|
|
5
|
+
export interface ParsedArgs {
|
|
6
|
+
workspace: string;
|
|
7
|
+
collection?: string;
|
|
8
|
+
request?: string;
|
|
9
|
+
suite?: string;
|
|
10
|
+
folder?: string;
|
|
11
|
+
recursive: boolean;
|
|
12
|
+
environment?: string;
|
|
13
|
+
variables: Record<string, unknown>;
|
|
14
|
+
iterations?: number;
|
|
15
|
+
concurrency?: number;
|
|
16
|
+
stopOnError: boolean;
|
|
17
|
+
delay?: number;
|
|
18
|
+
requestFilter?: string[];
|
|
19
|
+
include: string[];
|
|
20
|
+
/** Parsed reporter entries: { name: 'junit'|'html', path?: string } */
|
|
21
|
+
reporters: Array<{
|
|
22
|
+
name: string;
|
|
23
|
+
path?: string;
|
|
24
|
+
}>;
|
|
25
|
+
exitCode: boolean;
|
|
26
|
+
output: 'json' | 'table';
|
|
27
|
+
}
|
|
28
|
+
export declare function parseArgs(args: string[]): ParsedArgs;
|
|
29
|
+
/**
|
|
30
|
+
* Merge process.env into variables at lowest priority.
|
|
31
|
+
* Explicit --var flags (already in opts.variables) take precedence.
|
|
32
|
+
*/
|
|
33
|
+
export declare function mergeProcessEnv(opts: ParsedArgs): void;
|
|
34
|
+
/**
|
|
35
|
+
* Print how a reference (collection/folder/request) was resolved to stderr.
|
|
36
|
+
* Goes to stderr to keep stdout reserved for the JSON/table result.
|
|
37
|
+
*/
|
|
38
|
+
export declare function logResolution(info: ResolutionInfo): void;
|
|
39
|
+
/**
|
|
40
|
+
* Guard stdout so it carries ONLY the machine-readable result.
|
|
41
|
+
* Routes console.log/info to stderr while a run is in progress.
|
|
42
|
+
* @returns a restore function that reinstates the original console methods.
|
|
43
|
+
*/
|
|
44
|
+
export declare function installStdoutGuard(): () => void;
|
|
45
|
+
export declare function outputResult(result: unknown, format: 'json' | 'table'): void;
|
|
46
|
+
/**
|
|
47
|
+
* Tabular output for list commands.
|
|
48
|
+
*/
|
|
49
|
+
export declare function outputListResult(items: object[], format: 'json' | 'table', tableColumns: string[]): void;
|
|
50
|
+
/**
|
|
51
|
+
* Determine whether a run result represents an all-passing run.
|
|
52
|
+
* Suite/collection/folder results expose `summary.allPassed`; a single request
|
|
53
|
+
* result exposes `allPassed` directly. Defaults to true so we never fail a CI
|
|
54
|
+
* build on an unrecognized response shape.
|
|
55
|
+
*/
|
|
56
|
+
export declare function runAllPassed(result: unknown): boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Post-run CI handling:
|
|
59
|
+
* - Copy reporters to their explicit output paths.
|
|
60
|
+
* - Exit 1 when --exit-code is set and any test failed.
|
|
61
|
+
*/
|
|
62
|
+
export declare function finalizeCiReports(result: unknown, opts: ParsedArgs): void;
|
|
63
|
+
//# sourceMappingURL=format.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../src/output/format.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAQvD,MAAM,WAAW,UAAU;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,OAAO,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,uEAAuE;IACvE,SAAS,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAClD,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;CAC1B;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,UAAU,CA8EpD;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI,CAMtD;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,cAAc,GAAG,IAAI,CAOxD;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,IAAI,MAAM,IAAI,CAS/C;AAMD,wBAAgB,YAAY,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,GAAG,IAAI,CAM5E;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,MAAM,EAAE,EACf,MAAM,EAAE,MAAM,GAAG,OAAO,EACxB,YAAY,EAAE,MAAM,EAAE,GACrB,IAAI,CA6BN;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAOrD;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,GAAG,IAAI,CAoCzE"}
|
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Output formatting and argument parsing utilities shared across all CLI commands.
|
|
4
|
+
*/
|
|
5
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
10
|
+
}
|
|
11
|
+
Object.defineProperty(o, k2, desc);
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
17
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
18
|
+
}) : function(o, v) {
|
|
19
|
+
o["default"] = v;
|
|
20
|
+
});
|
|
21
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
22
|
+
var ownKeys = function(o) {
|
|
23
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
24
|
+
var ar = [];
|
|
25
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
26
|
+
return ar;
|
|
27
|
+
};
|
|
28
|
+
return ownKeys(o);
|
|
29
|
+
};
|
|
30
|
+
return function (mod) {
|
|
31
|
+
if (mod && mod.__esModule) return mod;
|
|
32
|
+
var result = {};
|
|
33
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
34
|
+
__setModuleDefault(result, mod);
|
|
35
|
+
return result;
|
|
36
|
+
};
|
|
37
|
+
})();
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.parseArgs = parseArgs;
|
|
40
|
+
exports.mergeProcessEnv = mergeProcessEnv;
|
|
41
|
+
exports.logResolution = logResolution;
|
|
42
|
+
exports.installStdoutGuard = installStdoutGuard;
|
|
43
|
+
exports.outputResult = outputResult;
|
|
44
|
+
exports.outputListResult = outputListResult;
|
|
45
|
+
exports.runAllPassed = runAllPassed;
|
|
46
|
+
exports.finalizeCiReports = finalizeCiReports;
|
|
47
|
+
const fs = __importStar(require("fs"));
|
|
48
|
+
const path = __importStar(require("path"));
|
|
49
|
+
function parseArgs(args) {
|
|
50
|
+
const opts = {
|
|
51
|
+
workspace: process.env.HTTP_FORGE_WORKSPACE ?? process.cwd(),
|
|
52
|
+
recursive: true,
|
|
53
|
+
variables: {},
|
|
54
|
+
stopOnError: false,
|
|
55
|
+
include: [],
|
|
56
|
+
reporters: [],
|
|
57
|
+
exitCode: false,
|
|
58
|
+
output: 'json',
|
|
59
|
+
};
|
|
60
|
+
for (let i = 0; i < args.length; i++) {
|
|
61
|
+
const arg = args[i];
|
|
62
|
+
if (arg === '--workspace' && i + 1 < args.length) {
|
|
63
|
+
opts.workspace = args[++i];
|
|
64
|
+
}
|
|
65
|
+
else if (arg === '--collection' && i + 1 < args.length) {
|
|
66
|
+
opts.collection = args[++i];
|
|
67
|
+
}
|
|
68
|
+
else if (arg === '--request' && i + 1 < args.length) {
|
|
69
|
+
opts.request = args[++i];
|
|
70
|
+
}
|
|
71
|
+
else if (arg === '--suite' && i + 1 < args.length) {
|
|
72
|
+
opts.suite = args[++i];
|
|
73
|
+
}
|
|
74
|
+
else if (arg === '--folder' && i + 1 < args.length) {
|
|
75
|
+
opts.folder = args[++i];
|
|
76
|
+
}
|
|
77
|
+
else if (arg === '--recursive' && i + 1 < args.length) {
|
|
78
|
+
opts.recursive = args[++i] !== 'false';
|
|
79
|
+
}
|
|
80
|
+
else if (arg === '--no-recursive') {
|
|
81
|
+
opts.recursive = false;
|
|
82
|
+
}
|
|
83
|
+
else if ((arg === '--environment' || arg === '--env') && i + 1 < args.length) {
|
|
84
|
+
// --env is the short alias for --environment
|
|
85
|
+
opts.environment = args[++i];
|
|
86
|
+
}
|
|
87
|
+
else if (arg === '--iterations' && i + 1 < args.length) {
|
|
88
|
+
opts.iterations = parseInt(args[++i], 10);
|
|
89
|
+
}
|
|
90
|
+
else if (arg === '--concurrency' && i + 1 < args.length) {
|
|
91
|
+
opts.concurrency = parseInt(args[++i], 10);
|
|
92
|
+
}
|
|
93
|
+
else if (arg === '--stop-on-error') {
|
|
94
|
+
opts.stopOnError = true;
|
|
95
|
+
}
|
|
96
|
+
else if (arg === '--delay' && i + 1 < args.length) {
|
|
97
|
+
opts.delay = parseInt(args[++i], 10);
|
|
98
|
+
}
|
|
99
|
+
else if (arg === '--include' && i + 1 < args.length) {
|
|
100
|
+
opts.include.push(args[++i]);
|
|
101
|
+
}
|
|
102
|
+
else if (arg === '--reporter' && i + 1 < args.length) {
|
|
103
|
+
const raw = args[++i];
|
|
104
|
+
const colonIdx = raw.indexOf(':');
|
|
105
|
+
if (colonIdx > 0) {
|
|
106
|
+
opts.reporters.push({ name: raw.slice(0, colonIdx), path: raw.slice(colonIdx + 1) });
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
opts.reporters.push({ name: raw });
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
else if (arg === '--out' && i + 1 < args.length) {
|
|
113
|
+
// --out <path> sets the output path for the last reporter, or defaults to junit
|
|
114
|
+
const outPath = args[++i];
|
|
115
|
+
if (opts.reporters.length > 0) {
|
|
116
|
+
opts.reporters[opts.reporters.length - 1].path = outPath;
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
opts.reporters.push({ name: 'junit', path: outPath });
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
else if (arg === '--exit-code') {
|
|
123
|
+
opts.exitCode = true;
|
|
124
|
+
}
|
|
125
|
+
else if (arg === '--json') {
|
|
126
|
+
// --json is a shorthand for --output json
|
|
127
|
+
opts.output = 'json';
|
|
128
|
+
}
|
|
129
|
+
else if (arg === '--output' && i + 1 < args.length) {
|
|
130
|
+
const out = args[++i];
|
|
131
|
+
if (out === 'json' || out === 'table') {
|
|
132
|
+
opts.output = out;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
else if (arg === '--var' && i + 1 < args.length) {
|
|
136
|
+
const pair = args[++i];
|
|
137
|
+
const eqIdx = pair.indexOf('=');
|
|
138
|
+
if (eqIdx > 0) {
|
|
139
|
+
opts.variables[pair.slice(0, eqIdx)] = pair.slice(eqIdx + 1);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return opts;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Merge process.env into variables at lowest priority.
|
|
147
|
+
* Explicit --var flags (already in opts.variables) take precedence.
|
|
148
|
+
*/
|
|
149
|
+
function mergeProcessEnv(opts) {
|
|
150
|
+
// HTTP_FORGE_ENV sets the default environment when --env is not provided
|
|
151
|
+
if (!opts.environment && process.env.HTTP_FORGE_ENV) {
|
|
152
|
+
opts.environment = process.env.HTTP_FORGE_ENV;
|
|
153
|
+
}
|
|
154
|
+
opts.variables = { ...process.env, ...opts.variables };
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Print how a reference (collection/folder/request) was resolved to stderr.
|
|
158
|
+
* Goes to stderr to keep stdout reserved for the JSON/table result.
|
|
159
|
+
*/
|
|
160
|
+
function logResolution(info) {
|
|
161
|
+
if (info.kind === 'folder') {
|
|
162
|
+
console.error(`Resolved --folder "${info.value}" -> ${info.id}`);
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
const loc = info.path ? ` (${info.path})` : '';
|
|
166
|
+
console.error(`Resolved --${info.kind} "${info.value}" by ${info.tier} -> ${info.id}${loc}`);
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Guard stdout so it carries ONLY the machine-readable result.
|
|
170
|
+
* Routes console.log/info to stderr while a run is in progress.
|
|
171
|
+
* @returns a restore function that reinstates the original console methods.
|
|
172
|
+
*/
|
|
173
|
+
function installStdoutGuard() {
|
|
174
|
+
const originalLog = console.log;
|
|
175
|
+
const originalInfo = console.info;
|
|
176
|
+
console.log = (...args) => console.error(...args);
|
|
177
|
+
console.info = (...args) => console.error(...args);
|
|
178
|
+
return () => {
|
|
179
|
+
console.log = originalLog;
|
|
180
|
+
console.info = originalInfo;
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
// ────────────────────────────────────────────────────────
|
|
184
|
+
// Result Output
|
|
185
|
+
// ────────────────────────────────────────────────────────
|
|
186
|
+
function outputResult(result, format) {
|
|
187
|
+
if (format === 'json') {
|
|
188
|
+
process.stdout.write(`${JSON.stringify(result, null, 2)}\n`);
|
|
189
|
+
}
|
|
190
|
+
else {
|
|
191
|
+
process.stdout.write(`Result: ${typeof result === 'string' ? result : JSON.stringify(result, null, 2)}\n`);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Tabular output for list commands.
|
|
196
|
+
*/
|
|
197
|
+
function outputListResult(items, format, tableColumns) {
|
|
198
|
+
if (format === 'json') {
|
|
199
|
+
process.stdout.write(`${JSON.stringify(items, null, 2)}\n`);
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
if (items.length === 0) {
|
|
203
|
+
console.log('(no items)');
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
const rows = items;
|
|
207
|
+
const cols = tableColumns.filter((c) => rows.some((r) => r[c] !== undefined));
|
|
208
|
+
const widths = cols.map((c) => {
|
|
209
|
+
const maxVal = Math.max(c.length, ...rows.map((r) => String(r[c] ?? '').length));
|
|
210
|
+
return Math.min(maxVal, 60);
|
|
211
|
+
});
|
|
212
|
+
const header = cols.map((c, i) => c.toUpperCase().padEnd(widths[i])).join(' ');
|
|
213
|
+
const sep = cols.map((_, i) => '─'.repeat(widths[i])).join(' ');
|
|
214
|
+
console.log(header);
|
|
215
|
+
console.log(sep);
|
|
216
|
+
for (const row of rows) {
|
|
217
|
+
const line = cols
|
|
218
|
+
.map((c, i) => String(row[c] ?? '').substring(0, widths[i]).padEnd(widths[i]))
|
|
219
|
+
.join(' ');
|
|
220
|
+
console.log(line);
|
|
221
|
+
}
|
|
222
|
+
console.log(`\n${rows.length} item${rows.length !== 1 ? 's' : ''}`);
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Determine whether a run result represents an all-passing run.
|
|
226
|
+
* Suite/collection/folder results expose `summary.allPassed`; a single request
|
|
227
|
+
* result exposes `allPassed` directly. Defaults to true so we never fail a CI
|
|
228
|
+
* build on an unrecognized response shape.
|
|
229
|
+
*/
|
|
230
|
+
function runAllPassed(result) {
|
|
231
|
+
if (!result || typeof result !== 'object')
|
|
232
|
+
return true;
|
|
233
|
+
const r = result;
|
|
234
|
+
const summary = r.summary;
|
|
235
|
+
if (summary && typeof summary.allPassed === 'boolean')
|
|
236
|
+
return summary.allPassed;
|
|
237
|
+
if (typeof r.allPassed === 'boolean')
|
|
238
|
+
return r.allPassed;
|
|
239
|
+
return true;
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Post-run CI handling:
|
|
243
|
+
* - Copy reporters to their explicit output paths.
|
|
244
|
+
* - Exit 1 when --exit-code is set and any test failed.
|
|
245
|
+
*/
|
|
246
|
+
function finalizeCiReports(result, opts) {
|
|
247
|
+
const r = result;
|
|
248
|
+
for (const reporter of opts.reporters) {
|
|
249
|
+
if (reporter.name === 'junit' && reporter.path) {
|
|
250
|
+
const junit = r?.junitReport;
|
|
251
|
+
if (junit?.path && fs.existsSync(junit.path)) {
|
|
252
|
+
fs.mkdirSync(path.dirname(path.resolve(reporter.path)), { recursive: true });
|
|
253
|
+
fs.copyFileSync(junit.path, reporter.path);
|
|
254
|
+
console.error(`Wrote JUnit report to ${reporter.path}`);
|
|
255
|
+
}
|
|
256
|
+
else {
|
|
257
|
+
console.error('Warning: --reporter junit:<path> was set but no JUnit report was generated.');
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
if (reporter.name === 'html' && reporter.path) {
|
|
261
|
+
const report = r?.report;
|
|
262
|
+
if (report?.uri) {
|
|
263
|
+
const srcPath = report.uri.replace(/^file:\/\//, '');
|
|
264
|
+
if (fs.existsSync(srcPath)) {
|
|
265
|
+
fs.mkdirSync(path.dirname(path.resolve(reporter.path)), { recursive: true });
|
|
266
|
+
fs.copyFileSync(srcPath, reporter.path);
|
|
267
|
+
console.error(`Wrote HTML report to ${reporter.path}`);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
else {
|
|
271
|
+
console.error('Warning: --reporter html:<path> was set but no HTML report was generated ' +
|
|
272
|
+
'(pass --include report or set HTTP_FORGE_GENERATE_REPORTS=true).');
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
if (opts.exitCode && !runAllPassed(result)) {
|
|
277
|
+
process.exit(1);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
//# sourceMappingURL=format.js.map
|