testbeats 2.0.3 → 2.0.4
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/package.json +1 -1
- package/src/cli.js +1 -4
- package/src/commands/publish.command.js +11 -2
- package/src/utils/config.builder.js +11 -2
package/package.json
CHANGED
package/src/cli.js
CHANGED
|
@@ -6,10 +6,9 @@ const sade = require('sade');
|
|
|
6
6
|
const prog = sade('testbeats');
|
|
7
7
|
const { PublishCommand } = require('./commands/publish.command');
|
|
8
8
|
const logger = require('./utils/logger');
|
|
9
|
-
const { ConfigBuilder } = require('./utils/config.builder');
|
|
10
9
|
|
|
11
10
|
prog
|
|
12
|
-
.version('2.0.
|
|
11
|
+
.version('2.0.4')
|
|
13
12
|
.option('-c, --config', 'path to config file')
|
|
14
13
|
.option('-l, --logLevel', 'Log Level', "INFO")
|
|
15
14
|
.option('--slack', 'slack webhook url')
|
|
@@ -30,8 +29,6 @@ prog.command('publish')
|
|
|
30
29
|
.action(async (opts) => {
|
|
31
30
|
try {
|
|
32
31
|
logger.setLevel(opts.logLevel);
|
|
33
|
-
const config_builder = new ConfigBuilder(opts);
|
|
34
|
-
config_builder.build();
|
|
35
32
|
const publish_command = new PublishCommand(opts);
|
|
36
33
|
await publish_command.publish();
|
|
37
34
|
} catch (error) {
|
|
@@ -3,6 +3,7 @@ const trp = require('test-results-parser');
|
|
|
3
3
|
const prp = require('performance-results-parser');
|
|
4
4
|
|
|
5
5
|
const beats = require('../beats');
|
|
6
|
+
const { ConfigBuilder } = require('../utils/config.builder');
|
|
6
7
|
const target_manager = require('../targets');
|
|
7
8
|
const logger = require('../utils/logger');
|
|
8
9
|
const { processData } = require('../helpers/helper');
|
|
@@ -19,6 +20,7 @@ class PublishCommand {
|
|
|
19
20
|
|
|
20
21
|
async publish() {
|
|
21
22
|
logger.info(`🥁 TestBeats v${pkg.version}`);
|
|
23
|
+
this.#buildConfig();
|
|
22
24
|
this.#validateOptions();
|
|
23
25
|
this.#setConfigFromFile();
|
|
24
26
|
this.#processConfig();
|
|
@@ -28,6 +30,11 @@ class PublishCommand {
|
|
|
28
30
|
logger.info('✅ Results published successfully!');
|
|
29
31
|
}
|
|
30
32
|
|
|
33
|
+
#buildConfig() {
|
|
34
|
+
const config_builder = new ConfigBuilder(this.opts);
|
|
35
|
+
config_builder.build();
|
|
36
|
+
}
|
|
37
|
+
|
|
31
38
|
#validateOptions() {
|
|
32
39
|
if (!this.opts) {
|
|
33
40
|
throw new Error('Missing publish options');
|
|
@@ -42,8 +49,10 @@ class PublishCommand {
|
|
|
42
49
|
const cwd = process.cwd();
|
|
43
50
|
const file_path = path.join(cwd, this.opts.config);
|
|
44
51
|
try {
|
|
45
|
-
|
|
52
|
+
const config_json = require(path.join(cwd, this.opts.config));
|
|
53
|
+
this.opts.config = config_json;
|
|
46
54
|
} catch (error) {
|
|
55
|
+
logger.error({ error }, `Failed to read config file: '${file_path}' with error: '${error.message}'`);
|
|
47
56
|
throw new Error(`Config file not found: ${file_path}`);
|
|
48
57
|
}
|
|
49
58
|
}
|
|
@@ -63,7 +72,7 @@ class PublishCommand {
|
|
|
63
72
|
}
|
|
64
73
|
|
|
65
74
|
#validateConfig() {
|
|
66
|
-
logger.info("🛠️
|
|
75
|
+
logger.info("🛠️ Validating configuration...")
|
|
67
76
|
for (const config of this.configs) {
|
|
68
77
|
this.#validateResults(config);
|
|
69
78
|
this.#validateTargets(config);
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const logger = require('./logger');
|
|
3
|
+
|
|
1
4
|
class ConfigBuilder {
|
|
2
5
|
|
|
3
6
|
/**
|
|
@@ -11,16 +14,22 @@ class ConfigBuilder {
|
|
|
11
14
|
if (!this.opts) {
|
|
12
15
|
return;
|
|
13
16
|
}
|
|
14
|
-
if (this.opts.config) {
|
|
17
|
+
if (typeof this.opts.config === 'object') {
|
|
18
|
+
return
|
|
19
|
+
}
|
|
20
|
+
if (this.opts.config && typeof this.opts.config === 'string') {
|
|
15
21
|
return;
|
|
16
22
|
}
|
|
17
23
|
|
|
24
|
+
logger.info('🏗 Building config...')
|
|
18
25
|
this.#buildConfig();
|
|
19
26
|
this.#buildBeats();
|
|
20
27
|
this.#buildResults();
|
|
21
28
|
this.#buildTargets();
|
|
22
29
|
this.#buildExtensions();
|
|
23
30
|
|
|
31
|
+
logger.debug(`🛠️ Generated Config: \n${JSON.stringify(this.config, null, 2)}`);
|
|
32
|
+
|
|
24
33
|
this.opts.config = this.config;
|
|
25
34
|
}
|
|
26
35
|
|
|
@@ -67,7 +76,7 @@ class ConfigBuilder {
|
|
|
67
76
|
this.config.results = [
|
|
68
77
|
{
|
|
69
78
|
type,
|
|
70
|
-
files: [file]
|
|
79
|
+
files: [path.join(file)]
|
|
71
80
|
}
|
|
72
81
|
]
|
|
73
82
|
}
|