@testrigor/testrigor-cli 1.0.0 → 2.0.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/README.md +230 -3
- package/dist/commands/authenticate.d.ts +14 -0
- package/dist/commands/authenticate.js +87 -26
- package/dist/commands/test-suite/config.js +1 -1
- package/dist/commands/test-suite/run.js +253 -234
- package/dist/commands/test-suite/validate-syntax.js +2 -3
- package/dist/flags/chrome-extension.js +3 -2
- package/dist/types.d.ts +0 -12
- package/dist/util/appium.js +92 -34
- package/dist/util/certificate-uploader.js +5 -6
- package/dist/util/config.js +15 -15
- package/dist/util/parser.js +8 -8
- package/dist/util/request-builder.d.ts +2 -8
- package/dist/util/request-builder.js +12 -35
- package/dist/util/trtc.d.ts +2 -0
- package/dist/util/trtc.js +107 -38
- package/dist/util/tunnel.js +7 -6
- package/dist/util/type-guards.js +3 -4
- package/dist/util/utils.d.ts +3 -3
- package/dist/util/utils.js +23 -23
- package/dist/util/variable-file-uploader.js +7 -13
- package/dist/util/variables-path-parser.js +4 -4
- package/npm-shrinkwrap.json +11047 -0
- package/oclif.manifest.json +253 -180
- package/package.json +21 -20
package/README.md
CHANGED
|
@@ -4,12 +4,35 @@ This is a command line tool for TestRigor. It allows you to run TestRigor tests
|
|
|
4
4
|
|
|
5
5
|
### Installation
|
|
6
6
|
|
|
7
|
-
1. Install [Node.js](https://nodejs.org/en/download/) (version
|
|
8
|
-
2. Install TestRigor CLI: `npm install -g testrigor-cli`
|
|
7
|
+
1. Install [Node.js](https://nodejs.org/en/download/) (version 20.19+, 22.12+ or 24+)
|
|
8
|
+
2. Install TestRigor CLI: `npm install -g @testrigor/testrigor-cli`
|
|
9
|
+
3. Check it: `testrigor --version`
|
|
10
|
+
|
|
11
|
+
> The unscoped `testrigor-cli` package on npm is an old, unmaintained build.
|
|
12
|
+
> Install the scoped `@testrigor/testrigor-cli` package shown above; if you
|
|
13
|
+
> installed the unscoped one, run `npm uninstall -g testrigor-cli` first.
|
|
14
|
+
|
|
15
|
+
### Authentication
|
|
16
|
+
|
|
17
|
+
Store your token once, interactively:
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
testrigor authenticate
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
For CI or any non-interactive shell, pass it in instead of being prompted:
|
|
24
|
+
|
|
25
|
+
```
|
|
26
|
+
testrigor authenticate --token YOUR_TOKEN
|
|
27
|
+
echo YOUR_TOKEN | testrigor authenticate
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Or skip stored credentials entirely and set `TESTRIGOR_API_KEY`, or pass
|
|
31
|
+
`--token` to each command.
|
|
9
32
|
|
|
10
33
|
### Examples
|
|
11
34
|
|
|
12
|
-
1. Basic
|
|
35
|
+
1. Basic `testrigor test-suite run <test-suite-id> --token <token>`
|
|
13
36
|
2. With new URL `testrigor test-suite run <test-suite-id> --token <token> --url <url>`
|
|
14
37
|
3. With file upload `testrigor test-suite run <test-suite-id> --token <token> --file-path <path-to-file>`
|
|
15
38
|
4. With branch `testrigor test-suite run <test-suite-id> --token <token> --branch <branch> --commit <commit>`
|
|
@@ -47,6 +70,7 @@ testrigor test-suite run <test-suite-id> --token <token> --localhost --local-tes
|
|
|
47
70
|
```
|
|
48
71
|
|
|
49
72
|
The CLI will:
|
|
73
|
+
|
|
50
74
|
- Detect it's a mobile suite
|
|
51
75
|
- Start the mobile server (Appium) automatically
|
|
52
76
|
- Open a tunnel to TestRigor cloud
|
|
@@ -73,3 +97,206 @@ overrideTestNodes: true
|
|
|
73
97
|
```
|
|
74
98
|
|
|
75
99
|
This overrides the device config stored in the test suite and forces mobile mode (no need for `--localhost`).
|
|
100
|
+
|
|
101
|
+
### Releasing a new version
|
|
102
|
+
|
|
103
|
+
Every push to `master` runs the CircleCI `publish` workflow. It builds the tarballs, then publishes the package to npm under the `latest` tag. npm refuses to republish an existing version, so a change is only released when it bumps the version.
|
|
104
|
+
|
|
105
|
+
1. Pick the [semver](https://semver.org) bump: `patch` for fixes, `minor` for new flags or commands, `major` for breaking changes.
|
|
106
|
+
2. Bump the version with npm (don't edit `package.json` by hand):
|
|
107
|
+
|
|
108
|
+
```
|
|
109
|
+
npm run build
|
|
110
|
+
npm version patch --no-git-tag-version
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
This updates the version in `package.json` and in both root entries of `package-lock.json` (`version` and `packages[""].version`). `--no-git-tag-version` stops npm from creating its own commit and `v*` tag. npm also runs the `version` script (`oclif readme && git add README.md`). That script loads the commands from `dist`, which is why you build first. It only rewrites README sections between oclif markers such as `<!-- commands -->
|
|
114
|
+
* [`testrigor authenticate`](#testrigor-authenticate)
|
|
115
|
+
* [`testrigor help [COMMANDS]`](#testrigor-help-commands)
|
|
116
|
+
* [`testrigor test-suite config`](#testrigor-test-suite-config)
|
|
117
|
+
* [`testrigor test-suite run [TESTSUITEID]`](#testrigor-test-suite-run-testsuiteid)
|
|
118
|
+
* [`testrigor test-suite validate-syntax [TESTSUITEID]`](#testrigor-test-suite-validate-syntax-testsuiteid)
|
|
119
|
+
|
|
120
|
+
## `testrigor authenticate`
|
|
121
|
+
|
|
122
|
+
Set your testRigor authentication token
|
|
123
|
+
|
|
124
|
+
```
|
|
125
|
+
USAGE
|
|
126
|
+
$ testrigor authenticate [--token <value>]
|
|
127
|
+
|
|
128
|
+
FLAGS
|
|
129
|
+
--token=<value> API authentication token to store, instead of prompting for it
|
|
130
|
+
|
|
131
|
+
DESCRIPTION
|
|
132
|
+
Set your testRigor authentication token
|
|
133
|
+
|
|
134
|
+
EXAMPLES
|
|
135
|
+
$ testrigor authenticate
|
|
136
|
+
|
|
137
|
+
Prompts for your API authentication token
|
|
138
|
+
|
|
139
|
+
$ testrigor authenticate --token YOUR_TOKEN
|
|
140
|
+
|
|
141
|
+
Sets the token without prompting (for CI and scripts)
|
|
142
|
+
|
|
143
|
+
Use 'testrigor test-suite config' to set default test suite ID separately
|
|
144
|
+
|
|
145
|
+
Config will be stored in ~/.testrigor/testrigor.yml
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
_See code: [src/commands/authenticate.ts](https://github.com/TestRigor/testrigor-cli/blob/v2.0.0/src/commands/authenticate.ts)_
|
|
149
|
+
|
|
150
|
+
## `testrigor help [COMMANDS]`
|
|
151
|
+
|
|
152
|
+
Display help for testrigor.
|
|
153
|
+
|
|
154
|
+
```
|
|
155
|
+
USAGE
|
|
156
|
+
$ testrigor help [COMMANDS...] [-n]
|
|
157
|
+
|
|
158
|
+
ARGUMENTS
|
|
159
|
+
[COMMANDS...] Command to show help for.
|
|
160
|
+
|
|
161
|
+
FLAGS
|
|
162
|
+
-n, --nested-commands Include all nested commands in the output.
|
|
163
|
+
|
|
164
|
+
DESCRIPTION
|
|
165
|
+
Display help for testrigor.
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v5.2.20/src/commands/help.ts)_
|
|
169
|
+
|
|
170
|
+
## `testrigor test-suite config`
|
|
171
|
+
|
|
172
|
+
Configure test suite settings and default test suite ID
|
|
173
|
+
|
|
174
|
+
```
|
|
175
|
+
USAGE
|
|
176
|
+
$ testrigor test-suite config [--default <value> | --delete | --show]
|
|
177
|
+
|
|
178
|
+
FLAGS
|
|
179
|
+
--default=<value> Set the default test suite ID
|
|
180
|
+
--delete Remove the default test suite ID
|
|
181
|
+
--show Show current configuration
|
|
182
|
+
|
|
183
|
+
DESCRIPTION
|
|
184
|
+
Configure test suite settings and default test suite ID
|
|
185
|
+
|
|
186
|
+
EXAMPLES
|
|
187
|
+
$ testrigor test-suite config --default TEST-SUITE-ID
|
|
188
|
+
|
|
189
|
+
$ testrigor test-suite config --show
|
|
190
|
+
|
|
191
|
+
$ testrigor test-suite config --delete
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
_See code: [src/commands/test-suite/config.ts](https://github.com/TestRigor/testrigor-cli/blob/v2.0.0/src/commands/test-suite/config.ts)_
|
|
195
|
+
|
|
196
|
+
## `testrigor test-suite run [TESTSUITEID]`
|
|
197
|
+
|
|
198
|
+
Run all tests of a Test Suite
|
|
199
|
+
|
|
200
|
+
```
|
|
201
|
+
USAGE
|
|
202
|
+
$ testrigor test-suite run [TESTSUITEID] [--auth-token <value>] [-t <value>] [--min-port <value>] [--max-port
|
|
203
|
+
<value>] [--verbose] [-w] [--branch <value> --commit <value>] [--localhost] [--url <value>]
|
|
204
|
+
[--junit-report-save-path <value>] [--variables-path <value>] [--test-cases-path <value>] [--rules-path <value>]
|
|
205
|
+
[--settings-path <value>] [--local-test-nodes-path <value>] [--test-case-uuid <value>...] [--auto-create-ai-rules]
|
|
206
|
+
[--explicit-mutations] [--labels <value>...] [--excluded-labels <value>...] [--base-url-web <value>] [--base-url-api
|
|
207
|
+
<value>] [--chrome-extension <value>... | --file-path <value>] [--xray-execution-key <value>]
|
|
208
|
+
|
|
209
|
+
ARGUMENTS
|
|
210
|
+
[TESTSUITEID] The test suite id (optional if set in config)
|
|
211
|
+
|
|
212
|
+
FLAGS
|
|
213
|
+
-w, --async Don't wait for the test suite to finish
|
|
214
|
+
--auto-create-ai-rules Enable auto create AI based rules
|
|
215
|
+
--base-url-api=<value> Base URL for API2 (e.g., https://api2.testrigor.com)
|
|
216
|
+
--base-url-web=<value> Base URL for web interface (e.g., https://app.testrigor.com)
|
|
217
|
+
--branch=<value> [env: TR_BRANCH] The branch name
|
|
218
|
+
--chrome-extension=<value>... Chrome extension: "name=EXT_NAME file=PATH_TO_CRX"
|
|
219
|
+
--commit=<value> [env: TR_COMMIT] The commit
|
|
220
|
+
--excluded-labels=<value>... Not run tests of specific labels
|
|
221
|
+
--explicit-mutations In cases where you are always using mutations, such as storing test cases in
|
|
222
|
+
your own repository, and you always send us the set of test cases you have
|
|
223
|
+
through our API you should send "--explicit-mutations"
|
|
224
|
+
--file-path=<value> Path to the file stored locally. It will upload the new file to be used. File
|
|
225
|
+
type should be according to the file type accepted for the Test Suite type of
|
|
226
|
+
testing. If the parameter --url is used, this parameter will be ignored.
|
|
227
|
+
--junit-report-save-path=<value> JUnit report save path
|
|
228
|
+
--labels=<value>... Run tests of specific labels
|
|
229
|
+
--local-test-nodes-path=<value> Path to a YAML or JSON file with local test nodes configuration
|
|
230
|
+
--localhost Localhost run (auto-detects web vs mobile)
|
|
231
|
+
--max-port=<value> [default: 50000] Max port for tunnel
|
|
232
|
+
--min-port=<value> [default: 40000] Min port for tunnel
|
|
233
|
+
--rules-path=<value> Rules path
|
|
234
|
+
--settings-path=<value> Settings path
|
|
235
|
+
--test-case-uuid=<value>... Test case uuid (can be repeated). Requires --url (web) or --file-path (mobile
|
|
236
|
+
app upload).
|
|
237
|
+
--test-cases-path=<value> Test cases files
|
|
238
|
+
--url=<value> The url
|
|
239
|
+
--variables-path=<value> Variables path
|
|
240
|
+
--xray-execution-key=<value> Reuse an existing Xray Cloud Test Execution by key (e.g. XR-123) instead of
|
|
241
|
+
creating a new one. Optional; leave blank to create a new execution.
|
|
242
|
+
|
|
243
|
+
GLOBAL FLAGS
|
|
244
|
+
-t, --token=<value> Suite authentication token
|
|
245
|
+
--auth-token=<value> Personal authentication token
|
|
246
|
+
--verbose Verbose output
|
|
247
|
+
|
|
248
|
+
DESCRIPTION
|
|
249
|
+
Run all tests of a Test Suite
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
_See code: [src/commands/test-suite/run.ts](https://github.com/TestRigor/testrigor-cli/blob/v2.0.0/src/commands/test-suite/run.ts)_
|
|
253
|
+
|
|
254
|
+
## `testrigor test-suite validate-syntax [TESTSUITEID]`
|
|
255
|
+
|
|
256
|
+
Validate step syntax against a test suite's reusable rules, without running the steps
|
|
257
|
+
|
|
258
|
+
```
|
|
259
|
+
USAGE
|
|
260
|
+
$ testrigor test-suite validate-syntax [TESTSUITEID] [--auth-token <value>] [-t <value>] [--min-port <value>] [--max-port
|
|
261
|
+
<value>] [--verbose] [--steps <value> | --test-cases-path <value>] [--base-url-api <value>] [--rules-path <value>]
|
|
262
|
+
[--explicit-mutations]
|
|
263
|
+
|
|
264
|
+
ARGUMENTS
|
|
265
|
+
[TESTSUITEID] The test suite id (optional if set in config)
|
|
266
|
+
|
|
267
|
+
FLAGS
|
|
268
|
+
--base-url-api=<value> Base URL for API2 (e.g., https://api2.testrigor.com)
|
|
269
|
+
--explicit-mutations Validate using only the supplied rules instead of merging them with the suite's saved rules
|
|
270
|
+
--max-port=<value> [default: 50000] Max port for tunnel
|
|
271
|
+
--min-port=<value> [default: 40000] Min port for tunnel
|
|
272
|
+
--rules-path=<value> Ad hoc reusable rules to validate against, for rules not yet saved to this suite (same glob
|
|
273
|
+
format as `test-suite run --rules-path`)
|
|
274
|
+
--steps=<value> Raw step text to validate directly
|
|
275
|
+
--test-cases-path=<value> Test case files to validate (same glob format as `test-suite run --test-cases-path`)
|
|
276
|
+
|
|
277
|
+
GLOBAL FLAGS
|
|
278
|
+
-t, --token=<value> Suite authentication token
|
|
279
|
+
--auth-token=<value> Personal authentication token
|
|
280
|
+
--verbose Verbose output
|
|
281
|
+
|
|
282
|
+
DESCRIPTION
|
|
283
|
+
Validate step syntax against a test suite's reusable rules, without running the steps
|
|
284
|
+
|
|
285
|
+
EXAMPLES
|
|
286
|
+
$ testrigor test-suite validate-syntax <test-suite-id> --steps "click \"Login\""
|
|
287
|
+
|
|
288
|
+
$ testrigor test-suite validate-syntax <test-suite-id> --test-cases-path "test_cases/**/*.{yaml,txt}"
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
_See code: [src/commands/test-suite/validate-syntax.ts](https://github.com/TestRigor/testrigor-cli/blob/v2.0.0/src/commands/test-suite/validate-syntax.ts)_
|
|
292
|
+
<!-- commandsstop -->`, so this README currently stays unchanged.
|
|
293
|
+
3. Check that the diff only touches the version fields, then build and test from the lockfile:
|
|
294
|
+
|
|
295
|
+
```
|
|
296
|
+
git diff package.json package-lock.json
|
|
297
|
+
npm ci && npm run build && npm test
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
4. Commit (e.g. `Updating to version 1.0.1 #TR-XXXX`), open a PR and merge it to `master`.
|
|
301
|
+
|
|
302
|
+
If the version was edited by hand anyway, run `npm install --package-lock-only` to bring `package-lock.json` back in sync. CI installs with `npm ci`, which fails when `package.json` and `package-lock.json` don't match, so commit the lockfile along with any dependency change.
|
|
@@ -2,5 +2,19 @@ import { Command } from "@oclif/core";
|
|
|
2
2
|
export default class Authenticate extends Command {
|
|
3
3
|
static description: string;
|
|
4
4
|
static examples: string[];
|
|
5
|
+
static flags: {
|
|
6
|
+
token: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
7
|
+
};
|
|
5
8
|
run(): Promise<void>;
|
|
9
|
+
/**
|
|
10
|
+
* Where the token comes from, in order: the --token flag, an interactive
|
|
11
|
+
* hidden prompt, or piped stdin.
|
|
12
|
+
*
|
|
13
|
+
* The hidden prompt is only usable on a TTY. Without one, @oclif/core falls
|
|
14
|
+
* back to `sh -c 'read -s ...'`, which fails on any system where /bin/sh is
|
|
15
|
+
* dash (the Debian and Ubuntu default) with "read: Illegal option -s" and
|
|
16
|
+
* then silently skips the setup.
|
|
17
|
+
*/
|
|
18
|
+
private resolveToken;
|
|
19
|
+
private readStdin;
|
|
6
20
|
}
|
|
@@ -3,25 +3,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const core_1 = require("@oclif/core");
|
|
4
4
|
const core_2 = require("@oclif/core");
|
|
5
5
|
const config_1 = require("../util/config");
|
|
6
|
+
// Time to wait for a token on a piped stdin before giving up. Stdin that is
|
|
7
|
+
// neither a TTY nor a closed/redirected stream would otherwise hang forever.
|
|
8
|
+
const STDIN_TIMEOUT_MS = 5000;
|
|
6
9
|
class Authenticate extends core_2.Command {
|
|
7
10
|
async run() {
|
|
11
|
+
const { flags } = await this.parse(Authenticate);
|
|
12
|
+
// readConfig reports parse problems itself and falls back to an empty
|
|
13
|
+
// config, so it needs no wrapping here.
|
|
14
|
+
const config = await (0, config_1.readConfig)();
|
|
15
|
+
// Resolved outside the try below so that "no terminal to prompt on" is
|
|
16
|
+
// reported as itself, not as a failure to save the configuration.
|
|
17
|
+
const token = await this.resolveToken(flags.token, !!config.authToken);
|
|
8
18
|
try {
|
|
9
|
-
// Load existing config (readConfig handles parse errors gracefully)
|
|
10
|
-
const config = await (0, config_1.readConfig)();
|
|
11
|
-
// Handle authentication token
|
|
12
|
-
let tokenPromptText;
|
|
13
|
-
if (config.authToken) {
|
|
14
|
-
tokenPromptText =
|
|
15
|
-
"Enter your testRigor API token (press enter to remove)";
|
|
16
|
-
}
|
|
17
|
-
else {
|
|
18
|
-
tokenPromptText =
|
|
19
|
-
"Enter your testRigor API token (press enter to skip)";
|
|
20
|
-
}
|
|
21
|
-
const token = await core_1.ux.prompt(tokenPromptText, {
|
|
22
|
-
type: "hide",
|
|
23
|
-
required: false,
|
|
24
|
-
});
|
|
25
19
|
if (!token || token.trim() === "") {
|
|
26
20
|
if (config.authToken) {
|
|
27
21
|
delete config.authToken;
|
|
@@ -31,29 +25,96 @@ class Authenticate extends core_2.Command {
|
|
|
31
25
|
else {
|
|
32
26
|
core_1.ux.info("Authentication token setup skipped");
|
|
33
27
|
}
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
config.authToken = token.trim();
|
|
31
|
+
await (0, config_1.writeConfig)(config);
|
|
32
|
+
core_1.ux.info("Authentication token successfully saved");
|
|
33
|
+
if (config.defaultTestSuiteId) {
|
|
34
|
+
core_1.ux.info("You can now use 'testrigor run' to run your default test suite");
|
|
34
35
|
}
|
|
35
36
|
else {
|
|
36
|
-
|
|
37
|
-
await (0, config_1.writeConfig)(config);
|
|
38
|
-
core_1.ux.info("Authentication token successfully saved");
|
|
39
|
-
if (config.defaultTestSuiteId) {
|
|
40
|
-
core_1.ux.info("You can now use 'testrigor run' to run your default test suite");
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
core_1.ux.info("Use 'testrigor test-suite config --default TEST_SUITE_ID' to set your default test suite ID, then use 'testrigor run'");
|
|
44
|
-
}
|
|
37
|
+
core_1.ux.info("Use 'testrigor test-suite config --default TEST_SUITE_ID' to set your default test suite ID, then use 'testrigor run'");
|
|
45
38
|
}
|
|
46
39
|
}
|
|
47
40
|
catch (error) {
|
|
48
41
|
core_1.ux.error(`Failed to save configuration: ${error instanceof Error ? error.message : String(error)}`);
|
|
49
42
|
}
|
|
50
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* Where the token comes from, in order: the --token flag, an interactive
|
|
46
|
+
* hidden prompt, or piped stdin.
|
|
47
|
+
*
|
|
48
|
+
* The hidden prompt is only usable on a TTY. Without one, @oclif/core falls
|
|
49
|
+
* back to `sh -c 'read -s ...'`, which fails on any system where /bin/sh is
|
|
50
|
+
* dash (the Debian and Ubuntu default) with "read: Illegal option -s" and
|
|
51
|
+
* then silently skips the setup.
|
|
52
|
+
*/
|
|
53
|
+
async resolveToken(flagToken, hasExistingToken) {
|
|
54
|
+
if (flagToken !== undefined) {
|
|
55
|
+
return flagToken;
|
|
56
|
+
}
|
|
57
|
+
if (process.stdin.isTTY) {
|
|
58
|
+
return core_1.ux.prompt(hasExistingToken
|
|
59
|
+
? "Enter your testRigor API token (press enter to remove)"
|
|
60
|
+
: "Enter your testRigor API token (press enter to skip)", { type: "hide", required: false });
|
|
61
|
+
}
|
|
62
|
+
const piped = await this.readStdin();
|
|
63
|
+
if (piped) {
|
|
64
|
+
return piped;
|
|
65
|
+
}
|
|
66
|
+
this.error("No interactive terminal available to prompt for a token.\n" +
|
|
67
|
+
"Provide it another way:\n" +
|
|
68
|
+
" testrigor authenticate --token YOUR_TOKEN\n" +
|
|
69
|
+
" echo YOUR_TOKEN | testrigor authenticate\n" +
|
|
70
|
+
"Or skip this command and set the TESTRIGOR_API_KEY environment variable instead.");
|
|
71
|
+
}
|
|
72
|
+
readStdin() {
|
|
73
|
+
return new Promise((resolve) => {
|
|
74
|
+
let data = "";
|
|
75
|
+
// resolve() past the first call is a no-op, so no "settled" guard is
|
|
76
|
+
// needed for whichever of the timeout or the stream gets there first.
|
|
77
|
+
const cleanup = () => {
|
|
78
|
+
process.stdin.removeAllListeners("data");
|
|
79
|
+
process.stdin.pause();
|
|
80
|
+
};
|
|
81
|
+
const timer = setTimeout(() => {
|
|
82
|
+
cleanup();
|
|
83
|
+
resolve("");
|
|
84
|
+
}, STDIN_TIMEOUT_MS);
|
|
85
|
+
const finish = () => {
|
|
86
|
+
clearTimeout(timer);
|
|
87
|
+
cleanup();
|
|
88
|
+
resolve(data.trim());
|
|
89
|
+
};
|
|
90
|
+
process.stdin.setEncoding("utf8");
|
|
91
|
+
process.stdin.on("data", (chunk) => {
|
|
92
|
+
data += chunk;
|
|
93
|
+
// A token is a single line; stop as soon as one arrives.
|
|
94
|
+
const newlineIndex = data.indexOf("\n");
|
|
95
|
+
if (newlineIndex !== -1) {
|
|
96
|
+
data = data.slice(0, newlineIndex);
|
|
97
|
+
finish();
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
process.stdin.once("end", finish);
|
|
101
|
+
process.stdin.once("error", finish);
|
|
102
|
+
process.stdin.resume();
|
|
103
|
+
});
|
|
104
|
+
}
|
|
51
105
|
}
|
|
52
|
-
exports.default = Authenticate;
|
|
53
106
|
Authenticate.description = "Set your testRigor authentication token";
|
|
54
107
|
Authenticate.examples = [
|
|
55
108
|
"testrigor authenticate",
|
|
56
109
|
"Prompts for your API authentication token",
|
|
110
|
+
"testrigor authenticate --token YOUR_TOKEN",
|
|
111
|
+
"Sets the token without prompting (for CI and scripts)",
|
|
57
112
|
"Use 'testrigor test-suite config' to set default test suite ID separately",
|
|
58
113
|
"Config will be stored in ~/.testrigor/testrigor.yml",
|
|
59
114
|
];
|
|
115
|
+
Authenticate.flags = {
|
|
116
|
+
token: core_2.Flags.string({
|
|
117
|
+
description: "API authentication token to store, instead of prompting for it",
|
|
118
|
+
}),
|
|
119
|
+
};
|
|
120
|
+
exports.default = Authenticate;
|
|
@@ -74,7 +74,6 @@ class Config extends core_1.Command {
|
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
|
-
exports.default = Config;
|
|
78
77
|
Config.description = "Configure test suite settings and default test suite ID";
|
|
79
78
|
Config.examples = [
|
|
80
79
|
"testrigor test-suite config --default TEST-SUITE-ID",
|
|
@@ -95,3 +94,4 @@ Config.flags = {
|
|
|
95
94
|
exclusive: getExclusiveFlags("show"),
|
|
96
95
|
}),
|
|
97
96
|
};
|
|
97
|
+
exports.default = Config;
|