@testmonitor/testmonitor-cli 0.5.2 → 1.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/CHANGELOG.md CHANGED
@@ -4,6 +4,6 @@ All notable changes to this project will be documented in this file.
4
4
  The format is based on [Keep a Changelog](http://keepachangelog.com/)
5
5
  and this project adheres to [Semantic Versioning](http://semver.org/).
6
6
 
7
- ## [1.0.0] - 2025-08-15
7
+ ## [1.0.0] - 2025-09-17
8
8
  ### Added
9
9
  - Initial version.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # TestMonitor CLI
2
2
 
3
- The TestMonitor CLI (`testmonitor-cli`) lets you interact with the TestMonitor platform directly from your terminal or CI pipelines. You can use it to submit automated test results through a simple, scriptable interface.
3
+ The TestMonitor CLI (`testmonitor-cli`) lets you interact with the [TestMonitor](https://www.testmonitor.com/) platform directly from your terminal or CI pipelines. You can use it to submit automated test results through a simple, scriptable interface.
4
4
 
5
5
  ## Table of Contents
6
6
 
@@ -76,9 +76,9 @@ testmonitor-cli junit submit [options]
76
76
 
77
77
  ## Documentation
78
78
 
79
- Please refer to our [knowledge base](https://help.testmonitor.com/) for more information.
79
+ Please refer to our [knowledge base](https://help.testmonitor.com/testmonitor-cli) for more information.
80
80
 
81
81
  ## License
82
82
 
83
83
  Copyright (c) TestMonitor | we are Cerios B.V.
84
- All rights reserved.
84
+ All rights reserved.
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- var T=Object.defineProperty;var U=(n,e)=>()=>(n&&(e=n(n=0)),e);var L=(n,e)=>{for(var t in e)T(n,t,{get:e[t],enumerable:!0})};var v={};L(v,{default:()=>D});var D,_=U(()=>{D={name:"@testmonitor/testmonitor-cli",type:"module",version:"0.5.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",prepare:"npm run build",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 B}from"commander";async function h(){return"0.5.2"}import{Command as A}from"commander";import"dotenv/config";import q from"fs";import{Command as X}from"commander";import $ from"os";import I from"fs";import S from"axios";import x from"form-data";var E=await h(),R=`NodeJS/${process.nodeVersion}`,J=`${$.platform()} ${$.release()}`,N=`TestMonitorCLI/${E} (${R}; ${J}; +https://www.testmonitor.com/)`,f=class{constructor({domain:e,httpClient:t}){this.baseURL=`https://${e}/api/v1`,this.httpClient=t||S.create({baseURL:this.baseURL,headers:{"User-Agent":N}})}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,s){let c={...o instanceof x?o.getHeaders():{"Content-Type":"application/json"},...s.headers||{}};try{return(await this.httpClient.request({method:e,url:t,data:o,headers:c,...s})).data}catch(a){let u=a.response?.data?.message||a.message;throw new Error(u)}}async submitJUnitReport({token:e,filePath:t,name:o,automationType:s,milestoneId:i,milestoneName:c,preserveNames:a,skipRootSuite:u,testEnvironmentId:b}){let p=new x;p.append("token",e),p.append("report",I.createReadStream(t));let w={name:o,milestone:c,milestone_id:i,preserve_names:a?1:null,skip_root_suite:u?1:null,test_environment_id:b,type:s};for(let[r,d]of Object.entries(w))d!=null&&p.append(r,d);return this.post("/reporters/junit/submit",p)}};import l from"chalk";import P from"ora";import{table as V}from"table";var g=class{#e="TestMonitor";info(e){console.log(`${this.#e}: ${e}`)}success(e){console.log(`${this.#e}: ${l.green(e)}`)}warn(e){console.warn(`${this.#e}: ${l.yellow(e)}`)}error(e,t){let o=`${this.#e}: ${l.red(e)}`;console.error(o),process.env.DEBUG&&t instanceof Error&&console.error(l.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 s=P({text:`${this.#e}: ${e}`,color:"green"}).start();try{let i=await t();return s.succeed(`${this.#e}: ${l.green(o.successMessage||e)}`),i}catch(i){throw s.fail(`${this.#e}: ${l.red(o.errorMessage||e)}`),i}}table(e,t){let o=V(e,{singleLine:!0,...t});console.log(o)}};async function F(n,{client:e}={}){let{domain:t,token:o,file:s,name:i,automationType:c,milestoneId:a,milestoneName:u,preserveNames:b,skipRootSuite:p,testEnvironmentId:w}=n,r=new g;q.existsSync(s)||(r.error(`File not found at path ${s}`),process.exit(1));let d=e||new f({domain:t});try{let{data:m}=await r.spin("Submitting...",()=>d.submitJUnitReport({token:o,filePath:s,name:i,automationType:c,milestoneId:a,milestoneName:u,preserveNames:b,skipRootSuite:p,testEnvironmentId:w}),{successMessage:"Report submitted.",errorMessage:"Failed to submit."});r.line(),r.table([["JUnit file",m.name],["Test run code",m.test_run.code],["Test run URL",m.test_run.links.show]])}catch(m){let O=m.response?.data?.message||m.message;r.line(),r.error(O,m),process.exit(1)}}var j=new X("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("-t, --token <id>","Your JUnit token").requiredOption("-f, --file <path>","Path to your JUnit XML file").option("-a, --automation-type <type>","The automation test type (e.g., cucumber, jest, playwright, phpunit, ranorex, selenium).").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("-v, --verbose","Enable verbose debug output.").action(n=>F(n));var C=new A("junit").name("junit").description("Commands for JUnit XML report submission.").helpOption("-h, --help","Display help for command.");C.addCommand(j);var M=C;var y=new B;y.name("testmonitor-cli").version(await h(),"-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.");y.on("option:verbose",function(){process.env.VERBOSE=this.opts().verbose});y.addCommand(M);y.parse(process.argv);
2
+ var T=Object.defineProperty;var U=(n,e)=>()=>(n&&(e=n(n=0)),e);var L=(n,e)=>{for(var t in e)T(n,t,{get:e[t],enumerable:!0})};var v={};L(v,{default:()=>D});var D,_=U(()=>{D={name:"@testmonitor/testmonitor-cli",type:"module",version:"1.0.0",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",prepare:"npm run build",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 B}from"commander";async function h(){return"1.0.0"}import{Command as A}from"commander";import"dotenv/config";import q from"fs";import{Command as X}from"commander";import $ from"os";import I from"fs";import S from"axios";import x from"form-data";var E=await h(),R=`NodeJS/${process.nodeVersion}`,J=`${$.platform()} ${$.release()}`,N=`TestMonitorCLI/${E} (${R}; ${J}; +https://www.testmonitor.com/)`,f=class{constructor({domain:e,httpClient:t}){this.baseURL=`https://${e}/api/v1`,this.httpClient=t||S.create({baseURL:this.baseURL,headers:{"User-Agent":N}})}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,s){let c={...o instanceof x?o.getHeaders():{"Content-Type":"application/json"},...s.headers||{}};try{return(await this.httpClient.request({method:e,url:t,data:o,headers:c,...s})).data}catch(a){let u=a.response?.data?.message||a.message;throw new Error(u)}}async submitJUnitReport({token:e,filePath:t,name:o,automationType:s,milestoneId:i,milestoneName:c,preserveNames:a,skipRootSuite:u,testEnvironmentId:b}){let p=new x;p.append("token",e),p.append("report",I.createReadStream(t));let w={name:o,milestone:c,milestone_id:i,preserve_names:a?1:null,skip_root_suite:u?1:null,test_environment_id:b,type:s};for(let[r,d]of Object.entries(w))d!=null&&p.append(r,d);return this.post("/reporters/junit/submit",p)}};import l from"chalk";import P from"ora";import{table as V}from"table";var g=class{#e="TestMonitor";info(e){console.log(`${this.#e}: ${e}`)}success(e){console.log(`${this.#e}: ${l.green(e)}`)}warn(e){console.warn(`${this.#e}: ${l.yellow(e)}`)}error(e,t){let o=`${this.#e}: ${l.red(e)}`;console.error(o),process.env.DEBUG&&t instanceof Error&&console.error(l.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 s=P({text:`${this.#e}: ${e}`,color:"green"}).start();try{let i=await t();return s.succeed(`${this.#e}: ${l.green(o.successMessage||e)}`),i}catch(i){throw s.fail(`${this.#e}: ${l.red(o.errorMessage||e)}`),i}}table(e,t){let o=V(e,{singleLine:!0,...t});console.log(o)}};async function F(n,{client:e}={}){let{domain:t,token:o,file:s,name:i,automationType:c,milestoneId:a,milestoneName:u,preserveNames:b,skipRootSuite:p,testEnvironmentId:w}=n,r=new g;q.existsSync(s)||(r.error(`File not found at path ${s}`),process.exit(1));let d=e||new f({domain:t});try{let{data:m}=await r.spin("Submitting...",()=>d.submitJUnitReport({token:o,filePath:s,name:i,automationType:c,milestoneId:a,milestoneName:u,preserveNames:b,skipRootSuite:p,testEnvironmentId:w}),{successMessage:"Report submitted.",errorMessage:"Failed to submit."});r.line(),r.table([["JUnit file",m.name],["Test run code",m.test_run.code],["Test run URL",m.test_run.links.show]])}catch(m){let O=m.response?.data?.message||m.message;r.line(),r.error(O,m),process.exit(1)}}var j=new X("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("-t, --token <id>","Your JUnit token").requiredOption("-f, --file <path>","Path to your JUnit XML file").option("-a, --automation-type <type>","The automation test type (e.g., cucumber, jest, playwright, phpunit, ranorex, selenium).").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("-v, --verbose","Enable verbose debug output.").action(n=>F(n));var C=new A("junit").name("junit").description("Commands for JUnit XML report submission.").helpOption("-h, --help","Display help for command.");C.addCommand(j);var M=C;var y=new B;y.name("testmonitor-cli").version(await h(),"-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.");y.on("option:verbose",function(){process.env.VERBOSE=this.opts().verbose});y.addCommand(M);y.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.5.2",
4
+ "version": "1.0.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",
@@ -77,7 +77,7 @@ export const submitJUnitXMLCommand = new Command('submit')
77
77
  '-a, --automation-type <type>',
78
78
  'The automation test type (e.g., cucumber, jest, playwright, phpunit, ranorex, selenium).'
79
79
  )
80
- .option('-m, --milestone-id <id>', 'Milestone ID for the new test run (required if not set in configuration))')
80
+ .option('-m, --milestone-id <id>', 'Milestone ID for the new test run (required if not set in configuration)')
81
81
  .option('-o, --milestone-name <name>', 'Find or create a milestone by name for the test run.')
82
82
  .option('-n, --name <name>', 'Custom name for the test run (auto-generated if omitted).')
83
83
  .option('-p, --preserve-names', 'Preserve test case names exactly as in the XML file.')