@testmonitor/testmonitor-cli 0.0.4 → 0.5.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 +8 -52
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/src/commands/junit/submit-junit-xml-command.js +7 -13
- package/src/index.js +0 -2
- package/src/lib/api-client.js +5 -14
- package/src/commands/check/check-auth-command.js +0 -45
- package/src/commands/check/index.js +0 -12
package/README.md
CHANGED
|
@@ -34,64 +34,20 @@ testmonitor-cli --version
|
|
|
34
34
|
|
|
35
35
|
To begin using the CLI, follow these steps:
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
1. Go to your project settings in TestMonitor.
|
|
38
|
+
2. Enable the **JUnit XML** integration under the **Integrations** menu.
|
|
39
|
+
3. Copy the **Token**.
|
|
40
|
+
4. Run the following command:
|
|
38
41
|
|
|
39
|
-
Set your API token using the TESTMONITOR_TOKEN environment variable.
|
|
40
|
-
|
|
41
|
-
**macOS/Linux:**
|
|
42
|
-
```sh
|
|
43
|
-
export TESTMONITOR_TOKEN=<your_api_token>
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
**Windows (PowerShell):**
|
|
47
42
|
```sh
|
|
48
|
-
|
|
43
|
+
testmonitor-cli junit submit -d domain.testmonitor.com -t <token> -f ./junit.xml
|
|
49
44
|
```
|
|
50
|
-
|
|
51
|
-
> You can find or regenerate your API token in your TestMonitor user profile settings under API Tokens.
|
|
52
|
-
|
|
53
|
-
### Check your connection
|
|
54
|
-
|
|
55
|
-
Verify that your domain and token are set up correctly:
|
|
56
|
-
|
|
57
|
-
```sh
|
|
58
|
-
testmonitor-cli check auth -d domain.testmonitor.com
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
If the connection is successful, you’ll see:
|
|
62
|
-
|
|
63
|
-
```sh
|
|
64
|
-
Connection successful.
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
If the check fails, try the following:
|
|
68
|
-
|
|
69
|
-
- **Invalid token**: Regenerate it from your user profile in TestMonitor and update the TESTMONITOR_TOKEN variable.
|
|
70
|
-
- **Wrong domain**: Double-check that the --domain flag matches the full domain assigned to your TestMonitor workspace (e.g., mycompany.testmonitor.com).
|
|
71
|
-
- **Deleted or inactive account**: Log into TestMonitor to ensure your user account is still active.
|
|
72
|
-
|
|
73
|
-
If problems persist, contact support@testmonitor.com.
|
|
45
|
+
> Replace `<token>` with your actual integration ID.
|
|
74
46
|
|
|
75
47
|
## Command Reference
|
|
76
48
|
|
|
77
49
|
This section lists all available commands grouped by functionality.
|
|
78
50
|
|
|
79
|
-
### Check
|
|
80
|
-
|
|
81
|
-
Tools for verifying your CLI setup and connection to the TestMonitor API.
|
|
82
|
-
|
|
83
|
-
#### Auth
|
|
84
|
-
|
|
85
|
-
Verify API token and domain connectivity.
|
|
86
|
-
|
|
87
|
-
```sh
|
|
88
|
-
testmonitor-cli check auth [options]
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
| Option | Description |
|
|
92
|
-
|--------------------------|----------------------------------|
|
|
93
|
-
| -d, --domain <domain> | TestMonitor domain (required) |
|
|
94
|
-
|
|
95
51
|
### JUnit
|
|
96
52
|
|
|
97
53
|
Commands for managing JUnit-style test reports.
|
|
@@ -107,13 +63,13 @@ testmonitor-cli junit submit [options]
|
|
|
107
63
|
| Option | Description |
|
|
108
64
|
|-----------------------------------|--------------------------------------------------|
|
|
109
65
|
| -d, --domain <domain> | TestMonitor domain (required) |
|
|
110
|
-
| -
|
|
66
|
+
| -t, --token <token> | JUnit token (required) |
|
|
111
67
|
| -f, --file <path> | Path to JUnit XML file (required) |
|
|
68
|
+
| -a, --automation-type <type> | Test type (e.g. playwright, selenium) |
|
|
112
69
|
| -n, --name <name> | Custom test run name |
|
|
113
70
|
| -m, --milestone-id <id> | Target milestone ID |
|
|
114
71
|
| -o, --milestone-name <name> | Milestone name to find or create |
|
|
115
72
|
| -e, --test-environment-id <id> | Target test environment ID |
|
|
116
|
-
| -t, --type <type> | Test type (e.g. cypress, playwright, phpunit) |
|
|
117
73
|
| -p, --preserve-names | Preserve original test case names |
|
|
118
74
|
| -s, --skip-root-suite | Skip root test suite nesting |
|
|
119
75
|
| -v, --verbose | Output debug information |
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var N=Object.defineProperty;var D=(n,e)=>()=>(n&&(e=n(n=0)),e);var S=(n,e)=>{for(var t in e)N(n,t,{get:e[t],enumerable:!0})};var b={};S(b,{default:()=>L});var L,T=D(()=>{L={name:"@testmonitor/testmonitor-cli",type:"module",version:"0.0.2",description:"The TestMonitor CLI lets you interact with the TestMonitor platform directly from your terminal or CI pipelines.",keywords:["testmonitor","cli"],homepage:"https://www.testmonitor.com/",bugs:{url:"https://github.com/testmonitor/testmonitor-cli/issues"},repository:{type:"git",url:"git+https://github.com/testmonitor/testmonitor-cli.git"},author:"TestMonitor | we are Cerios B.V.",main:"src/index.js",bin:{"testmonitor-cli":"dist/index.js"},scripts:{start:"node src/index.js",build:"node esbuild.config.js",lint:"eslint .","lint:fix":"eslint . --fix",test:"NODE_OPTIONS='--experimental-vm-modules' jest","test:watch":"NODE_OPTIONS='--experimental-vm-modules' jest --watch","test:coverage":"NODE_OPTIONS='--experimental-vm-modules' jest --coverage"},dependencies:{axios:"^1.7.9",chalk:"^5.4.1",commander:"^14.0.0",dotenv:"^17.2.0",ora:"^8.2.0","strip-ansi":"^7.1.0",table:"^6.9.0"},devDependencies:{chai:"^5.2.0",esbuild:"^0.25.6",eslint:"^9.31.0","eslint-config-prettier":"^10.1.5","eslint-formatter-junit":"^8.40.0","eslint-plugin-import":"^2.32.0","eslint-plugin-jest":"^28.14.0","eslint-plugin-jsdoc":"^51.4.1",jest:"^29.7.0","jest-junit":"^16.0.0",prettier:"^3.6.2"},engines:{node:">=
|
|
2
|
+
var N=Object.defineProperty;var D=(n,e)=>()=>(n&&(e=n(n=0)),e);var S=(n,e)=>{for(var t in e)N(n,t,{get:e[t],enumerable:!0})};var b={};S(b,{default:()=>L});var L,T=D(()=>{L={name:"@testmonitor/testmonitor-cli",type:"module",version:"0.0.2",description:"The TestMonitor CLI lets you interact with the TestMonitor platform directly from your terminal or CI pipelines.",keywords:["testmonitor","cli"],homepage:"https://www.testmonitor.com/",bugs:{url:"https://github.com/testmonitor/testmonitor-cli/issues"},repository:{type:"git",url:"git+https://github.com/testmonitor/testmonitor-cli.git"},author:"TestMonitor | we are Cerios B.V.",main:"src/index.js",bin:{"testmonitor-cli":"dist/index.js"},scripts:{start:"node src/index.js",build:"node esbuild.config.js",lint:"eslint .","lint:fix":"eslint . --fix",test:"NODE_OPTIONS='--experimental-vm-modules' jest","test:watch":"NODE_OPTIONS='--experimental-vm-modules' jest --watch","test:coverage":"NODE_OPTIONS='--experimental-vm-modules' jest --coverage"},dependencies:{axios:"^1.7.9",chalk:"^5.4.1",commander:"^14.0.0",dotenv:"^17.2.0",ora:"^8.2.0","strip-ansi":"^7.1.0",table:"^6.9.0"},devDependencies:{chai:"^5.2.0",esbuild:"^0.25.6",eslint:"^9.31.0","eslint-config-prettier":"^10.1.5","eslint-formatter-junit":"^8.40.0","eslint-plugin-import":"^2.32.0","eslint-plugin-jest":"^28.14.0","eslint-plugin-jsdoc":"^51.4.1",jest:"^29.7.0","jest-junit":"^16.0.0",prettier:"^3.6.2"},engines:{node:">=18.0.0"}}});import"dotenv/config";import{Command as W}from"commander";async function y(){return"0.0.2"}import{Command as B}from"commander";import{Command as X}from"commander";import C from"os";import R from"fs";import P from"axios";import O from"form-data";var V=await y(),q=`NodeJS/${process.nodeVersion}`,J=`${C.platform()} ${C.release()}`,A=`TestMonitorCLI/${V} (${q}; ${J}; +https://www.testmonitor.com/)`,u=class{constructor({domain:e,apiKey:t,httpClient:o}){this.baseURL=`https://${e}/api/v1`,this.apiKey=t,this.httpClient=o||P.create({baseURL:this.baseURL,headers:{Authorization:`Bearer ${this.apiKey}`,"User-Agent":A}})}async get(e,t={}){return this._request("get",e,null,t)}async post(e,t={},o={}){return this._request("post",e,t,o)}async put(e,t={},o={}){return this._request("put",e,t,o)}async delete(e,t={}){return this._request("delete",e,null,t)}async _request(e,t,o,i){let s={...o instanceof O?o.getHeaders():{"Content-Type":"application/json"},...i.headers||{}};try{return(await this.httpClient.request({method:e,url:t,data:o,headers:s,...i})).data}catch(a){let f=a.response?.data?.message||a.message;throw new Error(f)}}async checkConnection(){return this.get("/my-account")}async submitJUnitReport({integrationId:e,filePath:t,name:o,type:i,milestoneId:r,milestoneName:s,preserveNames:a,skipRootSuite:f,testEnvironmentId:w}){let c=new O;c.append("integration_id",e),c.append("report",R.createReadStream(t));let v={name:o,type:i,milestone:s,milestone_id:r,preserve_names:a?1:null,skip_root_suite:f?1:null,test_environment_id:w};for(let[m,l]of Object.entries(v))l!=null&&c.append(m,l);return this.post("/reporters/junit/submit",c)}};import d from"chalk";import K from"ora";import{table as F}from"table";var h=class{#e="TestMonitor";info(e){console.log(`${this.#e}: ${e}`)}success(e){console.log(`${this.#e}: ${d.green(e)}`)}warn(e){console.warn(`${this.#e}: ${d.yellow(e)}`)}error(e,t){let o=`${this.#e}: ${d.red(e)}`;console.error(o),process.env.DEBUG&&t instanceof Error&&console.error(d.gray(t.stack||t.message))}debug(e){process.env.DEBUG&&console.log(`${this.#e}: ${e}`)}line(e=""){console.log(e)}async spin(e,t,o={}){let i=K({text:`${this.#e}: ${e}`,color:"green"}).start();try{let r=await t();return i.succeed(`${this.#e}: ${d.green(o.successMessage||e)}`),r}catch(r){throw i.fail(`${this.#e}: ${d.red(o.errorMessage||e)}`),r}}table(e,t){let o=F(e,{singleLine:!0,...t});console.log(o)}};async function G(n,{client:e}={}){let{domain:t}=n,o=new h,i=process.env.TESTMONITOR_TOKEN;i||(o.error("TESTMONITOR_TOKEN environment variable is not set."),process.exit(1));let r=e||new u({domain:t,apiKey:i});try{let{data:s}=await o.spin("Connecting...",()=>r.checkConnection(),{successMessage:"Connection successful.",errorMessage:"Failed to connect."});o.line(),o.table([["User ID",s.id],["Name",s.name],["Email",s.email]])}catch(s){let a=s.response?.data?.message||s.message;o.line(),o.error(a,s),process.exit(1)}}var _=new X("auth").description("Verify connectivity with your TestMonitor instance.").requiredOption("-d, --domain <domain>","Your TestMonitor domain name (e.g., mydomain.testmonitor.com)").action(async n=>{await G(n)});var x=new B("check").name("check").description("Commands for verifying the connection state.").helpOption("-h, --help","Display help for command.");x.addCommand(_);var M=x;import{Command as Q}from"commander";import"dotenv/config";import Y from"fs";import{Command as z}from"commander";async function H(n,{client:e}={}){let{domain:t,integrationId:o,file:i,name:r,milestoneId:s,milestoneName:a,preserveNames:f,skipRootSuite:w,testEnvironmentId:c,type:v}=n,m=new h,l=process.env.TESTMONITOR_TOKEN;l||(m.error("TESTMONITOR_TOKEN environment variable is not set."),process.exit(1)),Y.existsSync(i)||(m.error(`File not found at path ${i}`),process.exit(1));let j=e||new u({domain:t,apiKey:l});try{let{data:p}=await m.spin("Submitting...",()=>j.submitJUnitReport({integrationId:o,filePath:i,name:r,type:v,milestoneId:s,milestoneName:a,preserveNames:f,skipRootSuite:w,testEnvironmentId:c}),{successMessage:"Report submitted.",errorMessage:"Failed to submit."});m.line(),m.table([["JUnit file",p.name],["Test run code",p.test_run.code],["Test run URL",p.test_run.links.show]])}catch(p){let k=p.response?.data?.message||p.message;m.line(),m.error(k,p),process.exit(1)}}var $=new z("submit").name("submit").description("Submit a JUnit XML file to your TestMonitor instance.").helpOption("-h, --help","Display help for command.").requiredOption("-d, --domain <domain>","Your TestMonitor domain name (e.g., mydomain.testmonitor.com)").requiredOption("-i, --integration-id <id>","The JUnit integration ID").requiredOption("-f, --file <path>","Path to your JUnit XML file").option("-m, --milestone-id <id>","Milestone ID for the new test run (required if not set in configuration))").option("-o, --milestone-name <name>","Find or create a milestone by name for the test run.").option("-n, --name <name>","Custom name for the test run (auto-generated if omitted).").option("-p, --preserve-names","Preserve test case names exactly as in the XML file.").option("-s, --skip-root-suite","Skip the root suite and start from nested suites.").option("-e, --test-environment-id <id>","Test environment ID for the new test run.").option("-t, --type <type>","The automation test type (cypress, playwright, phpunit, selenium).").option("-v, --verbose","Enable verbose debug output.").action(n=>H(n));var I=new Q("junit").name("junit").description("Commands for JUnit XML report submission.").helpOption("-h, --help","Display help for command.");I.addCommand($);var E=I;var g=new W;g.name("testmonitor-cli").version(await y(),"-v, --version","Display the current CLI version.").description("CLI tool for interacting with the TestMonitor API.").helpCommand(!1).helpOption("-h, --help","Display help for command.");g.on("option:verbose",function(){process.env.VERBOSE=this.opts().verbose});g.addCommand(M);g.addCommand(E);g.parse(process.argv);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@testmonitor/testmonitor-cli",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0
|
|
4
|
+
"version": "0.5.0",
|
|
5
5
|
"description": "The TestMonitor CLI lets you interact with the TestMonitor platform directly from your terminal or CI pipelines.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"testmonitor",
|
|
@@ -9,7 +9,7 @@ import { Logger } from '../../lib/logger.js';
|
|
|
9
9
|
export async function handleSubmitJUnitXML(options, { client } = {}) {
|
|
10
10
|
const {
|
|
11
11
|
domain,
|
|
12
|
-
|
|
12
|
+
token,
|
|
13
13
|
file,
|
|
14
14
|
name,
|
|
15
15
|
milestoneId,
|
|
@@ -17,33 +17,27 @@ export async function handleSubmitJUnitXML(options, { client } = {}) {
|
|
|
17
17
|
preserveNames,
|
|
18
18
|
skipRootSuite,
|
|
19
19
|
testEnvironmentId,
|
|
20
|
-
|
|
20
|
+
automationType,
|
|
21
21
|
} = options;
|
|
22
22
|
|
|
23
23
|
const log = new Logger();
|
|
24
|
-
const apiKey = process.env.TESTMONITOR_TOKEN;
|
|
25
|
-
|
|
26
|
-
if (!apiKey) {
|
|
27
|
-
log.error('TESTMONITOR_TOKEN environment variable is not set.');
|
|
28
|
-
process.exit(1);
|
|
29
|
-
}
|
|
30
24
|
|
|
31
25
|
if (!fs.existsSync(file)) {
|
|
32
26
|
log.error(`File not found at path ${file}`);
|
|
33
27
|
process.exit(1);
|
|
34
28
|
}
|
|
35
29
|
|
|
36
|
-
const apiClient = client || new APIClient({ domain
|
|
30
|
+
const apiClient = client || new APIClient({ domain });
|
|
37
31
|
|
|
38
32
|
try {
|
|
39
33
|
const { data } = await log.spin(
|
|
40
34
|
'Submitting...',
|
|
41
35
|
() =>
|
|
42
36
|
apiClient.submitJUnitReport({
|
|
43
|
-
|
|
37
|
+
token,
|
|
44
38
|
filePath: file,
|
|
45
39
|
name,
|
|
46
|
-
|
|
40
|
+
automationType,
|
|
47
41
|
milestoneId,
|
|
48
42
|
milestoneName,
|
|
49
43
|
preserveNames,
|
|
@@ -77,14 +71,14 @@ export const submitJUnitXMLCommand = new Command('submit')
|
|
|
77
71
|
.description('Submit a JUnit XML file to your TestMonitor instance.')
|
|
78
72
|
.helpOption('-h, --help', 'Display help for command.')
|
|
79
73
|
.requiredOption('-d, --domain <domain>', 'Your TestMonitor domain name (e.g., mydomain.testmonitor.com)')
|
|
80
|
-
.requiredOption('-
|
|
74
|
+
.requiredOption('-t, --token <id>', 'Your JUnit token')
|
|
81
75
|
.requiredOption('-f, --file <path>', 'Path to your JUnit XML file')
|
|
76
|
+
.option('-a, --automation-type <type>', 'The automation test type (playwright, phpunit, selenium).')
|
|
82
77
|
.option('-m, --milestone-id <id>', 'Milestone ID for the new test run (required if not set in configuration))')
|
|
83
78
|
.option('-o, --milestone-name <name>', 'Find or create a milestone by name for the test run.')
|
|
84
79
|
.option('-n, --name <name>', 'Custom name for the test run (auto-generated if omitted).')
|
|
85
80
|
.option('-p, --preserve-names', 'Preserve test case names exactly as in the XML file.')
|
|
86
81
|
.option('-s, --skip-root-suite', 'Skip the root suite and start from nested suites.')
|
|
87
82
|
.option('-e, --test-environment-id <id>', 'Test environment ID for the new test run.')
|
|
88
|
-
.option('-t, --type <type>', 'The automation test type (cypress, playwright, phpunit, selenium).')
|
|
89
83
|
.option('-v, --verbose', 'Enable verbose debug output.')
|
|
90
84
|
.action((options) => handleSubmitJUnitXML(options));
|
package/src/index.js
CHANGED
|
@@ -3,7 +3,6 @@ import 'dotenv/config';
|
|
|
3
3
|
import { Command } from 'commander';
|
|
4
4
|
|
|
5
5
|
import { appVersion } from './lib/app-version.js';
|
|
6
|
-
import checkGroup from './commands/check/index.js';
|
|
7
6
|
import junitGroup from './commands/junit/index.js';
|
|
8
7
|
|
|
9
8
|
const program = new Command();
|
|
@@ -19,7 +18,6 @@ program.on('option:verbose', function () {
|
|
|
19
18
|
process.env.VERBOSE = this.opts().verbose;
|
|
20
19
|
});
|
|
21
20
|
|
|
22
|
-
program.addCommand(checkGroup);
|
|
23
21
|
program.addCommand(junitGroup);
|
|
24
22
|
|
|
25
23
|
program.parse(process.argv);
|
package/src/lib/api-client.js
CHANGED
|
@@ -12,16 +12,14 @@ const osVersion = `${os.platform()} ${os.release()}`;
|
|
|
12
12
|
const userAgent = `TestMonitorCLI/${cliVersion} (${nodeVersion}; ${osVersion}; +https://www.testmonitor.com/)`;
|
|
13
13
|
|
|
14
14
|
export class APIClient {
|
|
15
|
-
constructor({ domain,
|
|
15
|
+
constructor({ domain, httpClient }) {
|
|
16
16
|
this.baseURL = `https://${domain}/api/v1`;
|
|
17
|
-
this.apiKey = apiKey;
|
|
18
17
|
|
|
19
18
|
this.httpClient =
|
|
20
19
|
httpClient ||
|
|
21
20
|
axios.create({
|
|
22
21
|
baseURL: this.baseURL,
|
|
23
22
|
headers: {
|
|
24
|
-
Authorization: `Bearer ${this.apiKey}`,
|
|
25
23
|
'User-Agent': userAgent,
|
|
26
24
|
},
|
|
27
25
|
});
|
|
@@ -66,21 +64,14 @@ export class APIClient {
|
|
|
66
64
|
}
|
|
67
65
|
}
|
|
68
66
|
|
|
69
|
-
/**
|
|
70
|
-
* Check connection to the API by fetching account info
|
|
71
|
-
*/
|
|
72
|
-
async checkConnection() {
|
|
73
|
-
return this.get('/my-account');
|
|
74
|
-
}
|
|
75
|
-
|
|
76
67
|
/**
|
|
77
68
|
* Submit a JUnit report using plain data and file path
|
|
78
69
|
*/
|
|
79
70
|
async submitJUnitReport({
|
|
80
|
-
|
|
71
|
+
token,
|
|
81
72
|
filePath,
|
|
82
73
|
name,
|
|
83
|
-
|
|
74
|
+
automationType,
|
|
84
75
|
milestoneId,
|
|
85
76
|
milestoneName,
|
|
86
77
|
preserveNames,
|
|
@@ -89,17 +80,17 @@ export class APIClient {
|
|
|
89
80
|
}) {
|
|
90
81
|
const form = new FormData();
|
|
91
82
|
|
|
92
|
-
form.append('
|
|
83
|
+
form.append('token', token);
|
|
93
84
|
form.append('report', fs.createReadStream(filePath));
|
|
94
85
|
|
|
95
86
|
const optional = {
|
|
96
87
|
name,
|
|
97
|
-
type,
|
|
98
88
|
milestone: milestoneName,
|
|
99
89
|
milestone_id: milestoneId,
|
|
100
90
|
preserve_names: preserveNames ? 1 : null,
|
|
101
91
|
skip_root_suite: skipRootSuite ? 1 : null,
|
|
102
92
|
test_environment_id: testEnvironmentId,
|
|
93
|
+
type: automationType,
|
|
103
94
|
};
|
|
104
95
|
|
|
105
96
|
for (const [key, value] of Object.entries(optional)) {
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { Command } from 'commander';
|
|
2
|
-
|
|
3
|
-
import { APIClient } from '../../lib/api-client.js';
|
|
4
|
-
import { Logger } from '../../lib/logger.js';
|
|
5
|
-
|
|
6
|
-
export async function handleCheckConnection(options, { client } = {}) {
|
|
7
|
-
const { domain } = options;
|
|
8
|
-
|
|
9
|
-
const log = new Logger();
|
|
10
|
-
const apiKey = process.env.TESTMONITOR_TOKEN;
|
|
11
|
-
|
|
12
|
-
if (!apiKey) {
|
|
13
|
-
log.error('TESTMONITOR_TOKEN environment variable is not set.');
|
|
14
|
-
process.exit(1);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const apiClient = client || new APIClient({ domain, apiKey });
|
|
18
|
-
|
|
19
|
-
try {
|
|
20
|
-
const { data } = await log.spin('Connecting...', () => apiClient.checkConnection(), {
|
|
21
|
-
successMessage: 'Connection successful.',
|
|
22
|
-
errorMessage: 'Failed to connect.',
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
log.line();
|
|
26
|
-
log.table([
|
|
27
|
-
['User ID', data.id],
|
|
28
|
-
['Name', data.name],
|
|
29
|
-
['Email', data.email],
|
|
30
|
-
]);
|
|
31
|
-
} catch (error) {
|
|
32
|
-
const message = error.response?.data?.message || error.message;
|
|
33
|
-
|
|
34
|
-
log.line();
|
|
35
|
-
log.error(message, error);
|
|
36
|
-
process.exit(1);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export const checkAuthCommand = new Command('auth')
|
|
41
|
-
.description('Verify connectivity with your TestMonitor instance.')
|
|
42
|
-
.requiredOption('-d, --domain <domain>', 'Your TestMonitor domain name (e.g., mydomain.testmonitor.com)')
|
|
43
|
-
.action(async (options) => {
|
|
44
|
-
await handleCheckConnection(options);
|
|
45
|
-
});
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Command } from 'commander';
|
|
2
|
-
|
|
3
|
-
import { checkAuthCommand } from './check-auth-command.js';
|
|
4
|
-
|
|
5
|
-
const checkGroup = new Command('check')
|
|
6
|
-
.name('check')
|
|
7
|
-
.description('Commands for verifying the connection state.')
|
|
8
|
-
.helpOption('-h, --help', 'Display help for command.');
|
|
9
|
-
|
|
10
|
-
checkGroup.addCommand(checkAuthCommand);
|
|
11
|
-
|
|
12
|
-
export default checkGroup;
|