@testomatio/reporter 1.6.13 → 2.0.1-beta-esm

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (142) hide show
  1. package/lib/adapter/codecept.d.ts +2 -0
  2. package/lib/adapter/codecept.js +295 -335
  3. package/lib/adapter/cucumber/current.d.ts +14 -0
  4. package/lib/adapter/cucumber/current.js +195 -203
  5. package/lib/adapter/cucumber/legacy.d.ts +0 -0
  6. package/lib/adapter/cucumber/legacy.js +130 -155
  7. package/lib/adapter/cucumber.d.ts +2 -0
  8. package/lib/adapter/cucumber.js +5 -16
  9. package/lib/adapter/cypress-plugin/index.d.ts +2 -0
  10. package/lib/adapter/cypress-plugin/index.js +93 -105
  11. package/lib/adapter/jasmine.d.ts +11 -0
  12. package/lib/adapter/jasmine.js +54 -53
  13. package/lib/adapter/jest.d.ts +13 -0
  14. package/lib/adapter/jest.js +97 -99
  15. package/lib/adapter/mocha.d.ts +2 -0
  16. package/lib/adapter/mocha.js +112 -140
  17. package/lib/adapter/playwright.d.ts +14 -0
  18. package/lib/adapter/playwright.js +195 -231
  19. package/lib/adapter/vitest.d.ts +35 -0
  20. package/lib/adapter/vitest.js +150 -149
  21. package/lib/adapter/webdriver.d.ts +24 -0
  22. package/lib/adapter/webdriver.js +134 -119
  23. package/lib/bin/cli.d.ts +2 -0
  24. package/lib/bin/cli.js +164 -211
  25. package/lib/bin/reportXml.d.ts +2 -0
  26. package/lib/bin/reportXml.js +49 -52
  27. package/lib/bin/startTest.d.ts +2 -0
  28. package/lib/bin/startTest.js +82 -95
  29. package/lib/bin/uploadArtifacts.d.ts +2 -0
  30. package/lib/bin/uploadArtifacts.js +55 -61
  31. package/lib/client.d.ts +76 -0
  32. package/lib/client.js +411 -465
  33. package/lib/config.d.ts +1 -0
  34. package/lib/config.js +16 -21
  35. package/lib/constants.d.ts +25 -0
  36. package/lib/constants.js +50 -44
  37. package/lib/data-storage.d.ts +34 -0
  38. package/lib/data-storage.js +206 -188
  39. package/lib/junit-adapter/adapter.d.ts +9 -0
  40. package/lib/junit-adapter/adapter.js +17 -20
  41. package/lib/junit-adapter/csharp.d.ts +4 -0
  42. package/lib/junit-adapter/csharp.js +18 -14
  43. package/lib/junit-adapter/index.d.ts +3 -0
  44. package/lib/junit-adapter/index.js +27 -25
  45. package/lib/junit-adapter/java.d.ts +5 -0
  46. package/lib/junit-adapter/java.js +41 -53
  47. package/lib/junit-adapter/javascript.d.ts +4 -0
  48. package/lib/junit-adapter/javascript.js +30 -27
  49. package/lib/junit-adapter/python.d.ts +5 -0
  50. package/lib/junit-adapter/python.js +38 -37
  51. package/lib/junit-adapter/ruby.d.ts +4 -0
  52. package/lib/junit-adapter/ruby.js +11 -8
  53. package/lib/output.d.ts +11 -0
  54. package/lib/output.js +44 -52
  55. package/lib/package.json +3 -0
  56. package/lib/pipe/bitbucket.d.ts +23 -0
  57. package/lib/pipe/bitbucket.js +210 -229
  58. package/lib/pipe/csv.d.ts +47 -0
  59. package/lib/pipe/csv.js +113 -126
  60. package/lib/pipe/debug.d.ts +29 -0
  61. package/lib/pipe/debug.js +104 -99
  62. package/lib/pipe/github.d.ts +30 -0
  63. package/lib/pipe/github.js +186 -213
  64. package/lib/pipe/gitlab.d.ts +23 -0
  65. package/lib/pipe/gitlab.js +166 -207
  66. package/lib/pipe/html.d.ts +34 -0
  67. package/lib/pipe/html.js +260 -319
  68. package/lib/pipe/index.d.ts +1 -0
  69. package/lib/pipe/index.js +84 -66
  70. package/lib/pipe/testomatio.d.ts +70 -0
  71. package/lib/pipe/testomatio.js +413 -462
  72. package/lib/reporter-functions.d.ts +34 -0
  73. package/lib/reporter-functions.js +28 -26
  74. package/lib/reporter.d.ts +232 -0
  75. package/lib/reporter.js +34 -29
  76. package/lib/services/artifacts.d.ts +33 -0
  77. package/lib/services/artifacts.js +55 -51
  78. package/lib/services/index.d.ts +9 -0
  79. package/lib/services/index.js +14 -12
  80. package/lib/services/key-values.d.ts +27 -0
  81. package/lib/services/key-values.js +56 -53
  82. package/lib/services/logger.d.ts +64 -0
  83. package/lib/services/logger.js +227 -245
  84. package/lib/template/testomatio.hbs +651 -1366
  85. package/lib/uploader.d.ts +60 -0
  86. package/lib/uploader.js +291 -360
  87. package/lib/utils/pipe_utils.d.ts +41 -0
  88. package/lib/utils/pipe_utils.js +89 -85
  89. package/lib/utils/utils.d.ts +45 -0
  90. package/lib/utils/utils.js +347 -307
  91. package/lib/xmlReader.d.ts +92 -0
  92. package/lib/xmlReader.js +490 -529
  93. package/package.json +57 -15
  94. package/src/adapter/codecept.js +375 -0
  95. package/src/adapter/cucumber/current.js +228 -0
  96. package/src/adapter/cucumber/legacy.js +158 -0
  97. package/src/adapter/cucumber.js +4 -0
  98. package/src/adapter/cypress-plugin/index.js +112 -0
  99. package/src/adapter/jasmine.js +60 -0
  100. package/src/adapter/jest.js +107 -0
  101. package/src/adapter/mocha.cjs +2 -0
  102. package/src/adapter/mocha.js +157 -0
  103. package/src/adapter/playwright.js +250 -0
  104. package/src/adapter/vitest.js +183 -0
  105. package/src/adapter/webdriver.js +142 -0
  106. package/src/bin/cli.js +280 -0
  107. package/src/bin/reportXml.js +74 -0
  108. package/src/bin/startTest.js +123 -0
  109. package/src/bin/uploadArtifacts.js +90 -0
  110. package/src/client.js +504 -0
  111. package/src/config.js +30 -0
  112. package/src/constants.js +53 -0
  113. package/src/data-storage.js +204 -0
  114. package/src/junit-adapter/adapter.js +23 -0
  115. package/src/junit-adapter/csharp.js +16 -0
  116. package/src/junit-adapter/index.js +28 -0
  117. package/src/junit-adapter/java.js +58 -0
  118. package/src/junit-adapter/javascript.js +31 -0
  119. package/src/junit-adapter/python.js +42 -0
  120. package/src/junit-adapter/ruby.js +10 -0
  121. package/src/output.js +57 -0
  122. package/src/pipe/bitbucket.js +254 -0
  123. package/src/pipe/csv.js +140 -0
  124. package/src/pipe/debug.js +104 -0
  125. package/src/pipe/github.js +233 -0
  126. package/src/pipe/gitlab.js +229 -0
  127. package/src/pipe/html.js +374 -0
  128. package/src/pipe/index.js +71 -0
  129. package/src/pipe/testomatio.js +503 -0
  130. package/src/reporter-functions.js +55 -0
  131. package/src/reporter.cjs_decprecated +21 -0
  132. package/src/reporter.js +33 -0
  133. package/src/services/artifacts.js +59 -0
  134. package/src/services/index.js +13 -0
  135. package/src/services/key-values.js +59 -0
  136. package/src/services/logger.js +316 -0
  137. package/src/template/emptyData.svg +23 -0
  138. package/src/template/testomatio.hbs +706 -0
  139. package/src/uploader.js +371 -0
  140. package/src/utils/pipe_utils.js +119 -0
  141. package/src/utils/utils.js +383 -0
  142. package/src/xmlReader.js +562 -0
package/lib/bin/cli.js CHANGED
@@ -1,275 +1,228 @@
1
1
  #!/usr/bin/env node
2
- const { program } = require('commander');
3
- const spawn = require('cross-spawn');
4
- const chalk = require('chalk');
5
- const glob = require('glob');
6
- const debug = require('debug')('@testomatio/reporter:cli');
7
- const TestomatClient = require('../client');
8
- const XmlReader = require('../xmlReader');
9
- const { APP_PREFIX, STATUS } = require('../constants');
10
- const { version } = require('../../package.json');
11
- const config = require('../config');
12
- const { readLatestRunId } = require('../utils/utils');
13
- const { filesize: prettyBytes } = require('filesize');
14
-
15
- console.log(chalk.cyan.bold(` 🤩 Testomat.io Reporter v${version}`));
16
-
2
+ "use strict";
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ const commander_1 = require("commander");
8
+ const cross_spawn_1 = require("cross-spawn");
9
+ const glob_1 = __importDefault(require("glob"));
10
+ const debug_1 = __importDefault(require("debug"));
11
+ const client_js_1 = __importDefault(require("../client.js"));
12
+ const xmlReader_js_1 = __importDefault(require("../xmlReader.js"));
13
+ const constants_js_1 = require("../constants.js");
14
+ const package_json_1 = require("../../package.json");
15
+ const config_js_1 = require("../config.js");
16
+ const utils_js_1 = require("../utils/utils.js");
17
+ const picocolors_1 = __importDefault(require("picocolors"));
18
+ const filesize_1 = require("filesize");
19
+ const dotenv_1 = __importDefault(require("dotenv"));
20
+ const debug = (0, debug_1.default)('@testomatio/reporter:xml-cli');
21
+ console.log(picocolors_1.default.cyan(picocolors_1.default.bold(` 🤩 Testomat.io Reporter v${package_json_1.version}`)));
22
+ const program = new commander_1.Command();
17
23
  program
18
- .version(version)
19
- .option('--env-file <envfile>', 'Load environment variables from env file')
20
- .hook('preAction', thisCommand => {
24
+ .version(package_json_1.version)
25
+ .option('--env-file <envfile>', 'Load environment variables from env file')
26
+ .hook('preAction', thisCommand => {
21
27
  const opts = thisCommand.opts();
22
28
  if (opts.envFile) {
23
- require('dotenv').config({ path: opts.envFile });
24
- } else {
25
- require('dotenv').config();
29
+ dotenv_1.default.config({ path: opts.envFile });
26
30
  }
27
- });
28
-
31
+ else {
32
+ dotenv_1.default.config();
33
+ }
34
+ });
29
35
  program
30
- .command('start')
31
- .description('Start a new run and return its ID')
32
- .action(async () => {
36
+ .command('start')
37
+ .description('Start a new run and return its ID')
38
+ .action(async () => {
33
39
  console.log('Starting a new Run on Testomat.io...');
34
- const apiKey = process.env['INPUT_TESTOMATIO-KEY'] || config.TESTOMATIO;
35
- const client = new TestomatClient({ apiKey });
36
-
40
+ const apiKey = process.env['INPUT_TESTOMATIO-KEY'] || config_js_1.config.TESTOMATIO;
41
+ const client = new client_js_1.default({ apiKey });
37
42
  client.createRun().then(() => {
38
- console.log(process.env.runId);
39
- process.exit(0);
43
+ console.log(process.env.runId);
44
+ process.exit(0);
40
45
  });
41
- });
42
-
46
+ });
43
47
  program
44
- .command('finish')
45
- .description('Finish Run by its ID')
46
- .action(async () => {
47
- process.env.TESTOMATIO_RUN ||= readLatestRunId();
48
-
48
+ .command('finish')
49
+ .description('Finish Run by its ID')
50
+ .action(async () => {
51
+ process.env.TESTOMATIO_RUN ||= (0, utils_js_1.readLatestRunId)();
49
52
  if (!process.env.TESTOMATIO_RUN) {
50
- console.log('TESTOMATIO_RUN environment variable must be set or restored from a previous run.');
51
- return process.exit(1);
53
+ console.log('TESTOMATIO_RUN environment variable must be set or restored from a previous run.');
54
+ return process.exit(1);
52
55
  }
53
-
54
56
  console.log('Finishing Run on Testomat.io...');
55
- const apiKey = process.env['INPUT_TESTOMATIO-KEY'] || config.TESTOMATIO;
56
- const client = new TestomatClient({ apiKey });
57
-
58
- client.updateRunStatus(STATUS.FINISHED).then(() => {
59
- console.log(chalk.yellow(`Run ${process.env.TESTOMATIO_RUN} was finished`));
60
- process.exit(0);
57
+ const apiKey = process.env['INPUT_TESTOMATIO-KEY'] || config_js_1.config.TESTOMATIO;
58
+ const client = new client_js_1.default({ apiKey });
59
+ // @ts-ignore
60
+ client.updateRunStatus(constants_js_1.STATUS.FINISHED).then(() => {
61
+ console.log(picocolors_1.default.yellow(`Run ${process.env.TESTOMATIO_RUN} was finished`));
62
+ process.exit(0);
61
63
  });
62
- });
63
-
64
+ });
64
65
  program
65
- .command('run')
66
- .description('Run tests with the specified command')
67
- .argument('<command>', 'Test runner command')
68
- .option('--filter <filter>', 'Additional execution filter')
69
- .action(async (command, opts) => {
70
- const apiKey = process.env['INPUT_TESTOMATIO-KEY'] || config.TESTOMATIO;
66
+ .command('run')
67
+ .description('Run tests with the specified command')
68
+ .argument('<command>', 'Test runner command')
69
+ .option('--filter <filter>', 'Additional execution filter')
70
+ .action(async (command, opts) => {
71
+ const apiKey = process.env['INPUT_TESTOMATIO-KEY'] || config_js_1.config.TESTOMATIO;
71
72
  const title = process.env.TESTOMATIO_TITLE;
72
-
73
73
  if (!command || !command.split) {
74
- console.log(APP_PREFIX, `No command provided. Use -c option to launch a test runner.`);
75
- return process.exit(255);
74
+ console.log(constants_js_1.APP_PREFIX, `No command provided. Use -c option to launch a test runner.`);
75
+ return process.exit(255);
76
76
  }
77
-
78
- const client = new TestomatClient({ apiKey, title, parallel: true });
79
-
77
+ const client = new client_js_1.default({ apiKey, title, parallel: true });
80
78
  if (opts.filter) {
81
- const [pipe, ...optsArray] = opts.filter.split(':');
82
- const pipeOptions = optsArray.join(':');
83
-
84
- try {
85
- const tests = await client.prepareRun({ pipe, pipeOptions });
86
- if (tests && tests.length > 0) {
87
- command += ` --grep (${tests.join('|')})`;
79
+ const [pipe, ...optsArray] = opts.filter.split(':');
80
+ const pipeOptions = optsArray.join(':');
81
+ try {
82
+ const tests = await client.prepareRun({ pipe, pipeOptions });
83
+ if (tests && tests.length > 0) {
84
+ command += ` --grep (${tests.join('|')})`;
85
+ }
86
+ }
87
+ catch (err) {
88
+ console.log(constants_js_1.APP_PREFIX, err);
88
89
  }
89
- } catch (err) {
90
- console.log(APP_PREFIX, err);
91
- }
92
90
  }
93
-
94
- console.log(APP_PREFIX, `🚀 Running`, chalk.green(command));
95
-
91
+ console.log(constants_js_1.APP_PREFIX, `🚀 Running`, picocolors_1.default.green(command));
96
92
  const runTests = () => {
97
- const testCmds = command.split(' ');
98
- const cmd = spawn(testCmds[0], testCmds.slice(1), { stdio: 'inherit' });
99
-
100
- cmd.on('close', code => {
101
- const emoji = code === 0 ? '🟢' : '🔴';
102
- console.log(APP_PREFIX, emoji, `Runner exited with ${chalk.bold(code)}`);
103
- if (apiKey) {
104
- const status = code === 0 ? 'passed' : 'failed';
105
- client.updateRunStatus(status, true);
106
- }
107
- process.exit(code);
108
- });
93
+ const testCmds = command.split(' ');
94
+ const cmd = (0, cross_spawn_1.spawn)(testCmds[0], testCmds.slice(1), { stdio: 'inherit' });
95
+ cmd.on('close', code => {
96
+ const emoji = code === 0 ? '🟢' : '🔴';
97
+ console.log(constants_js_1.APP_PREFIX, emoji, `Runner exited with ${picocolors_1.default.bold(code)}`);
98
+ if (apiKey) {
99
+ const status = code === 0 ? 'passed' : 'failed';
100
+ client.updateRunStatus(status, true);
101
+ }
102
+ process.exit(code);
103
+ });
109
104
  };
110
-
111
105
  if (apiKey) {
112
- client.createRun().then(runTests);
113
- } else {
114
- runTests();
106
+ client.createRun().then(runTests);
107
+ }
108
+ else {
109
+ runTests();
115
110
  }
116
- });
117
-
111
+ });
118
112
  program
119
- .command('xml')
120
- .description('Parse XML reports and upload to Testomat.io')
121
- .argument('<pattern>', 'XML file pattern')
122
- .option('-d, --dir <dir>', 'Project directory')
123
- .option('--java-tests [java-path]', 'Load Java tests from path, by default: src/test/java')
124
- .option('--lang <lang>', 'Language used (python, ruby, java)')
125
- .option('--timelimit <time>', 'default time limit in seconds to kill a stuck process')
126
- .action(async (pattern, opts) => {
113
+ .command('xml')
114
+ .description('Parse XML reports and upload to Testomat.io')
115
+ .argument('<pattern>', 'XML file pattern')
116
+ .option('-d, --dir <dir>', 'Project directory')
117
+ .option('--java-tests [java-path]', 'Load Java tests from path, by default: src/test/java')
118
+ .option('--lang <lang>', 'Language used (python, ruby, java)')
119
+ .option('--timelimit <time>', 'default time limit in seconds to kill a stuck process')
120
+ .action(async (pattern, opts) => {
127
121
  if (!pattern.endsWith('.xml')) {
128
- pattern += '.xml';
122
+ pattern += '.xml';
129
123
  }
130
124
  let { javaTests, lang } = opts;
131
- if (javaTests === true) javaTests = 'src/test/java';
125
+ if (javaTests === true)
126
+ javaTests = 'src/test/java';
132
127
  lang = lang?.toLowerCase();
133
- const runReader = new XmlReader({ javaTests, lang });
134
- const files = glob.sync(pattern, { cwd: opts.dir || process.cwd() });
128
+ const runReader = new xmlReader_js_1.default({ javaTests, lang });
129
+ const files = glob_1.default.sync(pattern, { cwd: opts.dir || process.cwd() });
135
130
  if (!files.length) {
136
- console.log(APP_PREFIX, `Report can't be created. No XML files found 😥`);
137
- process.exit(1);
131
+ console.log(constants_js_1.APP_PREFIX, `Report can't be created. No XML files found 😥`);
132
+ process.exit(1);
138
133
  }
139
-
140
134
  for (const file of files) {
141
- console.log(APP_PREFIX, `Parsed ${file}`);
142
- runReader.parse(file);
135
+ console.log(constants_js_1.APP_PREFIX, `Parsed ${file}`);
136
+ runReader.parse(file);
143
137
  }
144
-
145
138
  let timeoutTimer;
146
139
  if (opts.timelimit) {
147
- timeoutTimer = setTimeout(
148
- () => {
149
- console.log(
150
- `⚠️ Reached timeout of ${opts.timelimit}s. Exiting... (Exit code is 0 to not fail the pipeline)`,
151
- );
152
- process.exit(0);
153
- },
154
- parseInt(opts.timelimit, 10) * 1000,
155
- );
140
+ timeoutTimer = setTimeout(() => {
141
+ console.log(`⚠️ Reached timeout of ${opts.timelimit}s. Exiting... (Exit code is 0 to not fail the pipeline)`);
142
+ process.exit(0);
143
+ }, parseInt(opts.timelimit, 10) * 1000);
156
144
  }
157
-
158
145
  try {
159
- await runReader.createRun();
160
- await runReader.uploadData();
161
- } catch (err) {
162
- console.log(APP_PREFIX, 'Error updating status, skipping...', err);
146
+ await runReader.createRun();
147
+ await runReader.uploadData();
163
148
  }
164
-
165
- if (timeoutTimer) clearTimeout(timeoutTimer);
166
- });
167
-
149
+ catch (err) {
150
+ console.log(constants_js_1.APP_PREFIX, 'Error updating status, skipping...', err);
151
+ }
152
+ if (timeoutTimer)
153
+ clearTimeout(timeoutTimer);
154
+ });
168
155
  program
169
- .command('upload-artifacts')
170
- .description('Upload artifacts to Testomat.io')
171
- .option('--force', 'Re-upload artifacts even if they were uploaded before')
172
- .action(async opts => {
173
- const apiKey = config.TESTOMATIO;
174
-
156
+ .command('upload-artifacts')
157
+ .description('Upload artifacts to Testomat.io')
158
+ .option('--force', 'Re-upload artifacts even if they were uploaded before')
159
+ .action(async (opts) => {
160
+ const apiKey = config_js_1.config.TESTOMATIO;
175
161
  process.env.TESTOMATIO_DISABLE_ARTIFACTS = '';
176
- const runId = process.env.TESTOMATIO_RUN || process.env.runId || readLatestRunId();
177
-
162
+ const runId = process.env.TESTOMATIO_RUN || process.env.runId || (0, utils_js_1.readLatestRunId)();
178
163
  if (!runId) {
179
- console.log('TESTOMATIO_RUN environment variable must be set or restored from a previous run.');
180
- return process.exit(1);
164
+ console.log('TESTOMATIO_RUN environment variable must be set or restored from a previous run.');
165
+ return process.exit(1);
181
166
  }
182
-
183
- const client = new TestomatClient({
184
- apiKey,
185
- runId,
186
- isBatchEnabled: false,
167
+ const client = new client_js_1.default({
168
+ apiKey,
169
+ runId,
170
+ isBatchEnabled: false,
187
171
  });
188
-
189
172
  let testruns = client.uploader.readUploadedFiles(runId);
190
173
  const numTotalArtifacts = testruns.length;
191
-
192
174
  debug('Found testruns:', testruns);
193
-
194
- if (!opts.force) testruns = testruns.filter(tr => !tr.uploaded);
195
-
175
+ if (!opts.force)
176
+ testruns = testruns.filter(tr => !tr.uploaded);
196
177
  if (!testruns.length) {
197
- console.log(APP_PREFIX, '🗄️ Total artifacts:', numTotalArtifacts);
198
- if (numTotalArtifacts) {
199
- console.log(APP_PREFIX, 'No new artifacts to upload');
200
- console.log(APP_PREFIX, 'To re-upload artifacts run this command with --force flag');
201
- }
202
- process.exit(0);
178
+ console.log(constants_js_1.APP_PREFIX, '🗄️ Total artifacts:', numTotalArtifacts);
179
+ if (numTotalArtifacts) {
180
+ console.log(constants_js_1.APP_PREFIX, 'No new artifacts to upload');
181
+ console.log(constants_js_1.APP_PREFIX, 'To re-upload artifacts run this command with --force flag');
182
+ }
183
+ process.exit(0);
203
184
  }
204
-
205
185
  const testrunsByRid = testruns.reduce((acc, { rid, file }) => {
206
- if (!acc[rid]) {
207
- acc[rid] = [];
208
- }
209
- if (!acc[rid].includes(file)) acc[rid].push(file);
210
- return acc;
186
+ if (!acc[rid]) {
187
+ acc[rid] = [];
188
+ }
189
+ if (!acc[rid].includes(file))
190
+ acc[rid].push(file);
191
+ return acc;
211
192
  }, {});
212
-
213
193
  await client.createRun();
214
194
  client.uploader.checkEnabled();
215
195
  client.uploader.disableLogStorage();
216
-
217
196
  for (const rid in testrunsByRid) {
218
- const files = testrunsByRid[rid];
219
- await client.addTestRun(undefined, { rid, files });
197
+ const files = testrunsByRid[rid];
198
+ await client.addTestRun(undefined, { rid, files });
220
199
  }
221
-
222
- console.log(APP_PREFIX, '🗄️', client.uploader.successfulUploads.length, 'artifacts 🟢uploaded');
223
-
200
+ console.log(constants_js_1.APP_PREFIX, '🗄️', client.uploader.successfulUploads.length, 'artifacts 🟢uploaded');
224
201
  if (client.uploader.successfulUploads.length) {
225
- debug('\n', APP_PREFIX, `🗄️ ${client.uploader.successfulUploads.length} artifacts uploaded to S3 bucket`);
226
- const uploadedArtifacts = client.uploader.successfulUploads.map(file => ({
227
- relativePath: file.path.replace(process.cwd(), ''),
228
- link: file.link,
229
- sizePretty: prettyBytes(file.size, { round: 0 }).toString(),
230
- }));
231
-
232
- uploadedArtifacts.forEach(upload => {
233
- debug(
234
- `🟢 Uploaded artifact`,
235
- `${upload.relativePath},`,
236
- 'size:',
237
- `${upload.sizePretty},`,
238
- 'link:',
239
- `${upload.link}`,
240
- );
241
- });
202
+ debug('\n', constants_js_1.APP_PREFIX, `🗄️ ${client.uploader.successfulUploads.length} artifacts uploaded to S3 bucket`);
203
+ const uploadedArtifacts = client.uploader.successfulUploads.map(file => ({
204
+ relativePath: file.path.replace(process.cwd(), ''),
205
+ link: file.link,
206
+ sizePretty: (0, filesize_1.filesize)(file.size, { round: 0 }).toString(),
207
+ }));
208
+ uploadedArtifacts.forEach(upload => {
209
+ debug(`🟢Uploaded artifact`, `${upload.relativePath},`, 'size:', `${upload.sizePretty},`, 'link:', `${upload.link}`);
210
+ });
242
211
  }
243
-
244
212
  const filesizeStrMaxLength = 7;
245
-
246
213
  if (client.uploader.failedUploads.length) {
247
- console.log(
248
- '\n',
249
- APP_PREFIX,
250
- '🗄️',
251
- client.uploader.failedUploads.length,
252
- `artifacts 🔴${chalk.bold('failed')} to upload`,
253
- );
254
-
255
- const failedUploads = client.uploader.failedUploads.map(({ path, size }) => ({
256
- relativePath: path.replace(process.cwd(), ''),
257
- sizePretty: prettyBytes(size, { round: 0 }).toString(),
258
- }));
259
-
260
- const pathPadding = Math.max(...failedUploads.map(upload => upload.relativePath.length)) + 1;
261
- failedUploads.forEach(upload => {
262
- console.log(
263
- ` ${chalk.gray('|')} 🔴 ${upload.relativePath.padEnd(pathPadding)} ${chalk.gray(
264
- `| ${upload.sizePretty.padStart(filesizeStrMaxLength)} |`,
265
- )}`,
266
- );
267
- });
214
+ console.log('\n', constants_js_1.APP_PREFIX, '🗄️', client.uploader.failedUploads.length, `artifacts 🔴${picocolors_1.default.bold('failed')} to upload`);
215
+ const failedUploads = client.uploader.failedUploads.map(({ path, size }) => ({
216
+ relativePath: path.replace(process.cwd(), ''),
217
+ sizePretty: (0, filesize_1.filesize)(size, { round: 0 }).toString(),
218
+ }));
219
+ const pathPadding = Math.max(...failedUploads.map(upload => upload.relativePath.length)) + 1;
220
+ failedUploads.forEach(upload => {
221
+ console.log(` ${picocolors_1.default.gray('|')} 🔴 ${upload.relativePath.padEnd(pathPadding)} ${picocolors_1.default.gray(`| ${upload.sizePretty.padStart(filesizeStrMaxLength)} |`)}`);
222
+ });
268
223
  }
269
- });
270
-
224
+ });
271
225
  program.parse(process.argv);
272
-
273
226
  if (!process.argv.slice(2).length) {
274
- program.outputHelp();
227
+ program.outputHelp();
275
228
  }
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -1,72 +1,69 @@
1
1
  #!/usr/bin/env node
2
- const { program } = require('commander');
3
- const chalk = require('chalk');
4
- const glob = require('glob');
5
- const debug = require('debug')('@testomatio/reporter:xml-cli');
6
- const { APP_PREFIX } = require('../constants');
7
- const XmlReader = require('../xmlReader');
8
-
9
- const { version } = require('../../package.json');
10
-
11
- console.log(chalk.cyan.bold(` 🤩 Testomat.io XML Reporter v${version}`));
12
-
2
+ "use strict";
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ const commander_1 = require("commander");
8
+ const picocolors_1 = __importDefault(require("picocolors"));
9
+ const glob_1 = require("glob");
10
+ const debug_1 = __importDefault(require("debug"));
11
+ const constants_js_1 = require("../constants.js");
12
+ const xmlReader_js_1 = __importDefault(require("../xmlReader.js"));
13
+ const package_json_1 = require("../../package.json");
14
+ const dotenv_1 = __importDefault(require("dotenv"));
15
+ const debug = (0, debug_1.default)('@testomatio/reporter:xml-cli');
16
+ console.log(picocolors_1.default.cyan(picocolors_1.default.bold(` 🤩 Testomat.io XML Reporter v${package_json_1.version}`)));
17
+ const program = new commander_1.Command();
13
18
  program
14
- .arguments('<pattern>')
15
- .option('-d, --dir <dir>', 'Project directory')
16
- .option('--java-tests [java-path]', 'Load Java tests from path, by default: src/test/java')
17
- .option('--lang <lang>', 'Language used (python, ruby, java)')
18
- .option('--timelimit <time>', 'default time limit in seconds to kill a stuck process')
19
- .option('--env-file <envfile>', 'Load environment variables from env file')
20
- .action(async (pattern, opts) => {
19
+ .arguments('<pattern>')
20
+ .option('-d, --dir <dir>', 'Project directory')
21
+ .option('--java-tests [java-path]', 'Load Java tests from path, by default: src/test/java')
22
+ .option('--lang <lang>', 'Language used (python, ruby, java)')
23
+ .option('--timelimit <time>', 'default time limit in seconds to kill a stuck process')
24
+ .option('--env-file <envfile>', 'Load environment variables from env file')
25
+ .action(async (pattern, opts) => {
21
26
  if (!pattern.endsWith('.xml')) {
22
- pattern += '.xml';
27
+ pattern += '.xml';
23
28
  }
24
29
  let { javaTests, lang } = opts;
25
30
  if (opts.envFile) {
26
- console.log(APP_PREFIX, 'Loading env file:', opts.envFile);
27
- debug('Loading env file: %s', opts.envFile);
28
- require('dotenv').config({ path: opts.envFile }); // eslint-disable-line
31
+ console.log(constants_js_1.APP_PREFIX, 'Loading env file:', opts.envFile);
32
+ debug('Loading env file: %s', opts.envFile);
33
+ dotenv_1.default.config({ path: opts.envFile });
29
34
  }
30
- if (javaTests === true) javaTests = 'src/test/java';
31
35
  lang = lang?.toLowerCase();
32
- const runReader = new XmlReader({ javaTests, lang });
33
- const files = glob.sync(pattern, { cwd: opts.dir || process.cwd() });
36
+ if (javaTests === true || (lang === 'java' && !javaTests))
37
+ javaTests = 'src/test/java';
38
+ const runReader = new xmlReader_js_1.default({ javaTests, lang });
39
+ const files = glob_1.glob.sync(pattern, { cwd: opts.dir || process.cwd() });
34
40
  if (!files.length) {
35
- console.log(APP_PREFIX, `Report can't be created. No XML files found 😥`);
36
- process.exitCode = 1;
37
- return;
41
+ console.log(constants_js_1.APP_PREFIX, `Report can't be created. No XML files found 😥`);
42
+ process.exitCode = 1;
43
+ return;
38
44
  }
39
-
40
45
  for (const file of files) {
41
- console.log(APP_PREFIX, `Parsed ${file}`);
42
- runReader.parse(file);
46
+ console.log(constants_js_1.APP_PREFIX, `Parsed ${file}`);
47
+ runReader.parse(file);
43
48
  }
44
-
45
49
  let timeoutTimer;
46
50
  if (opts.timelimit) {
47
- timeoutTimer = setTimeout(
48
- () => {
49
- console.log(
50
- `⚠️ Reached timeout of ${opts.timelimit}s. Exiting... (Exit code is 0 to not fail the pipeline)`,
51
- );
52
- process.exit(0);
53
- },
54
- parseInt(opts.timelimit, 10) * 1000,
55
- );
51
+ timeoutTimer = setTimeout(() => {
52
+ console.log(`⚠️ Reached timeout of ${opts.timelimit}s. Exiting... (Exit code is 0 to not fail the pipeline)`);
53
+ process.exit(0);
54
+ }, parseInt(opts.timelimit, 10) * 1000);
56
55
  }
57
-
58
56
  try {
59
- await runReader.createRun();
60
- await runReader.uploadData();
61
- } catch (err) {
62
- console.log(APP_PREFIX, 'Error updating status, skipping...', err);
57
+ await runReader.createRun();
58
+ await runReader.uploadData();
63
59
  }
64
-
65
- if (timeoutTimer) clearTimeout(timeoutTimer);
66
- });
67
-
60
+ catch (err) {
61
+ console.log(constants_js_1.APP_PREFIX, 'Error updating status, skipping...', err);
62
+ }
63
+ if (timeoutTimer)
64
+ clearTimeout(timeoutTimer);
65
+ });
68
66
  if (process.argv.length < 3) {
69
- program.outputHelp();
67
+ program.outputHelp();
70
68
  }
71
-
72
69
  program.parse(process.argv);
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};