@teamscale/coverage-collector 0.0.1-beta.35 → 0.0.1-beta.39
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/dist/package.json +2 -2
- package/dist/src/main.js +17 -15
- package/dist/src/receiver/Session.d.ts +4 -2
- package/dist/src/receiver/Session.js +4 -2
- package/dist/src/utils/PrettyFileLogger.d.ts +13 -0
- package/dist/src/utils/PrettyFileLogger.js +24 -0
- package/dist/src/utils/StdConsoleLogger.d.ts +5 -0
- package/dist/src/utils/StdConsoleLogger.js +15 -0
- package/package.json +2 -2
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teamscale/coverage-collector",
|
|
3
|
-
"version": "0.0.1-beta.
|
|
3
|
+
"version": "0.0.1-beta.39",
|
|
4
4
|
"description": "Collector for JavaScript code coverage information",
|
|
5
5
|
"main": "dist/src/main.js",
|
|
6
6
|
"bin": "dist/src/main.js",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@cqse/commons": "^0.0.1-beta.26",
|
|
26
26
|
"argparse": "^2.0.1",
|
|
27
|
-
"async": "^3.2.
|
|
27
|
+
"async": "^3.2.4",
|
|
28
28
|
"axios": "^0.24.0",
|
|
29
29
|
"bunyan": "^1.8.15",
|
|
30
30
|
"dotenv": "^14.1.0",
|
package/dist/src/main.js
CHANGED
|
@@ -42,6 +42,8 @@ const util_1 = require("util");
|
|
|
42
42
|
const tmp_1 = __importDefault(require("tmp"));
|
|
43
43
|
const mkdirp_1 = __importDefault(require("mkdirp"));
|
|
44
44
|
const path_1 = __importDefault(require("path"));
|
|
45
|
+
const StdConsoleLogger_1 = require("./utils/StdConsoleLogger");
|
|
46
|
+
const PrettyFileLogger_1 = require("./utils/PrettyFileLogger");
|
|
45
47
|
/**
|
|
46
48
|
* The main class of the Teamscale JavaScript Collector.
|
|
47
49
|
* Used to start the collector for with a given configuration.
|
|
@@ -69,6 +71,10 @@ class Main {
|
|
|
69
71
|
help: 'Print received coverage information to the terminal?',
|
|
70
72
|
default: false
|
|
71
73
|
});
|
|
74
|
+
parser.add_argument('-j', '--json-log', {
|
|
75
|
+
help: 'Additional JSON-like log file format.',
|
|
76
|
+
action: 'store_true'
|
|
77
|
+
});
|
|
72
78
|
// Parameters for the upload to Teamscale
|
|
73
79
|
parser.add_argument('-u', '--teamscale-server-url', {
|
|
74
80
|
help: 'Upload the coverage to the given Teamscale server URL, for example, https://teamscale.dev.example.com:8080/production.',
|
|
@@ -122,24 +128,20 @@ class Main {
|
|
|
122
128
|
const logfilePath = config.log_to_file.trim();
|
|
123
129
|
mkdirp_1.default.sync(path_1.default.dirname(logfilePath));
|
|
124
130
|
const logLevel = config.log_level;
|
|
125
|
-
|
|
126
|
-
name: '
|
|
131
|
+
const logger = bunyan_1.default.createLogger({
|
|
132
|
+
name: 'Collector',
|
|
127
133
|
streams: [
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
console.log('[%s] %s: %s', rec.time.toISOString(), bunyan_1.default.nameFromLevel[rec.level], rec.msg);
|
|
133
|
-
}
|
|
134
|
-
},
|
|
135
|
-
type: 'raw'
|
|
136
|
-
},
|
|
137
|
-
{
|
|
138
|
-
level: logLevel,
|
|
139
|
-
path: logfilePath
|
|
140
|
-
}
|
|
134
|
+
// console output
|
|
135
|
+
{ level: logLevel, stream: new StdConsoleLogger_1.StdConsoleLogger(), type: 'raw' },
|
|
136
|
+
// default log file
|
|
137
|
+
{ level: logLevel, stream: new PrettyFileLogger_1.PrettyFileLogger(fs.createWriteStream(logfilePath)), type: 'raw' }
|
|
141
138
|
]
|
|
142
139
|
});
|
|
140
|
+
// If the given flag is set, we also log with a JSON-like format
|
|
141
|
+
if (config.json_log) {
|
|
142
|
+
logger.addStream({ level: logLevel, path: `${logfilePath}.json` });
|
|
143
|
+
}
|
|
144
|
+
return logger;
|
|
143
145
|
}
|
|
144
146
|
/**
|
|
145
147
|
* Entry point of the Teamscale JavaScript Profiler.
|
|
@@ -43,8 +43,10 @@ export declare class Session {
|
|
|
43
43
|
* This method also conducts the mapping based on the source map.
|
|
44
44
|
*
|
|
45
45
|
* @param fileId - The identifier of the instrumented bundle (file).
|
|
46
|
-
* @param
|
|
47
|
-
* @param
|
|
46
|
+
* @param startLine - The line number within the bundle the range starts.
|
|
47
|
+
* @param startColumn - The column in the given `startLine` on that the range starts (inclusive).
|
|
48
|
+
* @param endLine - The line number within the bundle the range ends.
|
|
49
|
+
* @param endColumn - The column in the given `startLine` on that the range ends (inclusive).
|
|
48
50
|
*/
|
|
49
51
|
putCoverage(fileId: string, startLine: number, startColumn: number, endLine: number, endColumn: number): void;
|
|
50
52
|
/**
|
|
@@ -51,8 +51,10 @@ class Session {
|
|
|
51
51
|
* This method also conducts the mapping based on the source map.
|
|
52
52
|
*
|
|
53
53
|
* @param fileId - The identifier of the instrumented bundle (file).
|
|
54
|
-
* @param
|
|
55
|
-
* @param
|
|
54
|
+
* @param startLine - The line number within the bundle the range starts.
|
|
55
|
+
* @param startColumn - The column in the given `startLine` on that the range starts (inclusive).
|
|
56
|
+
* @param endLine - The line number within the bundle the range ends.
|
|
57
|
+
* @param endColumn - The column in the given `startLine` on that the range ends (inclusive).
|
|
56
58
|
*/
|
|
57
59
|
putCoverage(fileId, startLine, startColumn, endLine, endColumn) {
|
|
58
60
|
var _a, _b;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import 'dotenv/config';
|
|
3
|
+
import { WriteStream } from 'fs';
|
|
4
|
+
/**
|
|
5
|
+
* Class for log4j-like logger. Stream output shows less information than the
|
|
6
|
+
* standard JSON format of the bunyan logger and therefore has better readability.
|
|
7
|
+
*/
|
|
8
|
+
export declare class PrettyFileLogger {
|
|
9
|
+
outputStream: WriteStream;
|
|
10
|
+
constructor(outputStream: WriteStream);
|
|
11
|
+
write(rec: Record<any, any>): void;
|
|
12
|
+
end(): void;
|
|
13
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.PrettyFileLogger = void 0;
|
|
7
|
+
const bunyan_1 = __importDefault(require("bunyan"));
|
|
8
|
+
require("dotenv/config");
|
|
9
|
+
/**
|
|
10
|
+
* Class for log4j-like logger. Stream output shows less information than the
|
|
11
|
+
* standard JSON format of the bunyan logger and therefore has better readability.
|
|
12
|
+
*/
|
|
13
|
+
class PrettyFileLogger {
|
|
14
|
+
constructor(outputStream) {
|
|
15
|
+
this.outputStream = outputStream;
|
|
16
|
+
}
|
|
17
|
+
write(rec) {
|
|
18
|
+
this.outputStream.write(`[${rec.time.toISOString()}] ${bunyan_1.default.nameFromLevel[rec.level].toUpperCase()}: ${rec.msg}\n`);
|
|
19
|
+
}
|
|
20
|
+
end() {
|
|
21
|
+
this.outputStream.close();
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.PrettyFileLogger = PrettyFileLogger;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.StdConsoleLogger = void 0;
|
|
7
|
+
const bunyan_1 = __importDefault(require("bunyan"));
|
|
8
|
+
require("dotenv/config");
|
|
9
|
+
/** Class for console logger. Doesn't print all information to ensure better readability. */
|
|
10
|
+
class StdConsoleLogger {
|
|
11
|
+
write(rec) {
|
|
12
|
+
console.log(`[${rec.time.toISOString()}] ${bunyan_1.default.nameFromLevel[rec.level].toUpperCase()}: ${rec.msg}`);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.StdConsoleLogger = StdConsoleLogger;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teamscale/coverage-collector",
|
|
3
|
-
"version": "0.0.1-beta.
|
|
3
|
+
"version": "0.0.1-beta.39",
|
|
4
4
|
"description": "Collector for JavaScript code coverage information",
|
|
5
5
|
"main": "dist/src/main.js",
|
|
6
6
|
"bin": "dist/src/main.js",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@cqse/commons": "^0.0.1-beta.26",
|
|
26
26
|
"argparse": "^2.0.1",
|
|
27
|
-
"async": "^3.2.
|
|
27
|
+
"async": "^3.2.4",
|
|
28
28
|
"axios": "^0.24.0",
|
|
29
29
|
"bunyan": "^1.8.15",
|
|
30
30
|
"dotenv": "^14.1.0",
|