@teamscale/javascript-instrumenter 0.1.0-beta.4 → 0.1.0-beta.6
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 +1 -1
- package/dist/package.json +11 -11
- package/dist/src/App.d.ts.map +1 -1
- package/dist/src/App.js +15 -2
- package/dist/src/instrumenter/Instrumenter.d.ts +2 -1
- package/dist/src/instrumenter/Instrumenter.d.ts.map +1 -1
- package/dist/src/instrumenter/Instrumenter.js +2 -2
- package/dist/src/instrumenter/RelativeCollectorPatternParser.d.ts +8 -0
- package/dist/src/instrumenter/RelativeCollectorPatternParser.d.ts.map +1 -0
- package/dist/src/instrumenter/RelativeCollectorPatternParser.js +53 -0
- package/dist/src/instrumenter/RelativeCollectorPatternParser.test.d.ts +2 -0
- package/dist/src/instrumenter/RelativeCollectorPatternParser.test.d.ts.map +1 -0
- package/dist/src/instrumenter/RelativeCollectorPatternParser.test.js +28 -0
- package/dist/src/instrumenter/Task.d.ts +7 -7
- package/dist/src/instrumenter/Task.d.ts.map +1 -1
- package/dist/src/instrumenter/Task.js +32 -16
- package/dist/src/instrumenter/TaskBuilder.d.ts +3 -2
- package/dist/src/instrumenter/TaskBuilder.d.ts.map +1 -1
- package/dist/src/instrumenter/TaskBuilder.js +5 -5
- package/dist/src/main.js +1 -1
- package/dist/src/vaccine/types.d.ts +36 -0
- package/dist/src/vaccine/types.d.ts.map +1 -0
- package/dist/src/vaccine/types.js +2 -0
- package/dist/vaccine.js +1 -1
- package/package.json +12 -12
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@ in the Teamscale Simple Coverage Format and sent to a Teamscale instance.
|
|
|
9
9
|
The Teamscale JavaScript Profiler consists of the [Coverage Collector](https://www.npmjs.com/package/@teamscale/coverage-collector)
|
|
10
10
|
and this JavaScript Instrumenter.
|
|
11
11
|
More details on using them (in combination) can be found
|
|
12
|
-
in the [Teamscale Documentation](https://docs.teamscale.com/howto/
|
|
12
|
+
in the [Teamscale Documentation](https://docs.teamscale.com/howto/setting-up-profiler-tga/javascript/).
|
|
13
13
|
|
|
14
14
|
The Instrumenter instruments a given (set of) JavaScript file(s) such that (1) coverage
|
|
15
15
|
information is produced and (2) forwarded to the Collector.
|
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teamscale/javascript-instrumenter",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.6",
|
|
4
4
|
"description": "JavaScript coverage instrumenter with coverage forwarding to a collector process",
|
|
5
5
|
"main": "dist/src/main.js",
|
|
6
6
|
"bin": "dist/src/main.js",
|
|
@@ -23,9 +23,9 @@
|
|
|
23
23
|
"dist/**/*"
|
|
24
24
|
],
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@babel/core": "^7.23.
|
|
26
|
+
"@babel/core": "^7.23.9",
|
|
27
27
|
"@babel/plugin-transform-modules-commonjs": "^7.23.3",
|
|
28
|
-
"@babel/preset-env": "^7.23.
|
|
28
|
+
"@babel/preset-env": "^7.23.9",
|
|
29
29
|
"@types/argparse": "^2.0.14",
|
|
30
30
|
"@types/async": "^3.2.24",
|
|
31
31
|
"@types/babel__generator": "^7.6.8",
|
|
@@ -34,26 +34,26 @@
|
|
|
34
34
|
"@types/convert-source-map": "^2.0.3",
|
|
35
35
|
"@types/glob": "^8.1.0",
|
|
36
36
|
"@types/istanbul-lib-instrument": "^1.7.7",
|
|
37
|
-
"@types/jest": "^29.5.
|
|
38
|
-
"@types/node": "^20.11.
|
|
37
|
+
"@types/jest": "^29.5.12",
|
|
38
|
+
"@types/node": "^20.11.19",
|
|
39
39
|
"@types/ws": "^8.5.10",
|
|
40
40
|
"babel-jest": "^29.7.0",
|
|
41
|
-
"esbuild": "^0.
|
|
41
|
+
"esbuild": "^0.20.1",
|
|
42
42
|
"esbuild-plugin-inline-worker": "^0.1.1",
|
|
43
43
|
"jest": "^29.7.0",
|
|
44
44
|
"rimraf": "^5.0.5",
|
|
45
|
-
"ts-jest": "^29.1.
|
|
45
|
+
"ts-jest": "^29.1.2",
|
|
46
46
|
"ts-node": "^10.9.2",
|
|
47
47
|
"tslib": "^2.6.2",
|
|
48
48
|
"typescript": "^5.3.3"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@cqse/commons": "0.1.0-beta.
|
|
51
|
+
"@cqse/commons": "0.1.0-beta.5",
|
|
52
52
|
"@teamscale/lib-instrument": "workspace:../lib-instrument",
|
|
53
53
|
"@babel/generator": "^7.23.6",
|
|
54
|
-
"@babel/parser": "^7.23.
|
|
55
|
-
"@babel/traverse": "^7.23.
|
|
56
|
-
"@babel/types": "^7.23.
|
|
54
|
+
"@babel/parser": "^7.23.9",
|
|
55
|
+
"@babel/traverse": "^7.23.9",
|
|
56
|
+
"@babel/types": "^7.23.9",
|
|
57
57
|
"@types/micromatch": "^4.0.6",
|
|
58
58
|
"argparse": "^2.0.1",
|
|
59
59
|
"async": "^3.2.5",
|
package/dist/src/App.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../../src/App.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../../src/App.ts"],"names":[],"mappings":"AACA,OAAO,EAAuB,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAGtE,OAAO,EAAE,uBAAuB,EAAe,MAAM,4BAA4B,CAAC;AAKlF,OAAO,MAAM,MAAM,QAAQ,CAAC;AAG5B;;GAEG;AACH,qBAAa,GAAG;IACf;;;OAGG;WACiB,GAAG,IAAI,OAAO,CAAC,UAAU,CAAC;IAe9C;;;OAGG;WACW,iBAAiB,CAAC,MAAM,EAAE,uBAAuB,GAAG,IAAI;IAwCtE;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,WAAW;IA0D1B;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,WAAW;IA+B1B;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,gBAAgB;IAI/B;;;;;OAKG;WACW,qBAAqB,CAAC,MAAM,EAAE,uBAAuB,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAS1G,OAAO,CAAC,MAAM,CAAC,yBAAyB;IAIxC,OAAO,CAAC,MAAM,CAAC,kBAAkB;CAajC"}
|
package/dist/src/App.js
CHANGED
|
@@ -51,8 +51,8 @@ class App {
|
|
|
51
51
|
const config = parser.parse_args();
|
|
52
52
|
// Build the logger
|
|
53
53
|
const logger = this.buildLogger(config);
|
|
54
|
-
logger.
|
|
55
|
-
logger.
|
|
54
|
+
logger.trace('Retrieved arguments', process.argv);
|
|
55
|
+
logger.trace('Translated arguments to config', config);
|
|
56
56
|
// Run the instrumenter with the given configuration.
|
|
57
57
|
return this.runForConfigArguments(config, logger);
|
|
58
58
|
}
|
|
@@ -123,6 +123,19 @@ class App {
|
|
|
123
123
|
help: 'The collector (`host:port` or `wss://host:port/` or `ws://host:port/`) to send coverage information to.',
|
|
124
124
|
default: 'ws://localhost:54678'
|
|
125
125
|
});
|
|
126
|
+
parser.add_argument('--relative-collector', {
|
|
127
|
+
help: 'Pattern used to determine the collector URL from the application hostname.'
|
|
128
|
+
+ ' Useful for Kubernetes deployments where the collector URL is not known at instrumentation time.'
|
|
129
|
+
+ ' Example: `replace-in-host:app collector,scheme:wss`.'
|
|
130
|
+
+ ' This causes the first occurrence of `app` in the application hostname to be replaced with `collector`'
|
|
131
|
+
+ ' and the URL scheme changed to wss.'
|
|
132
|
+
+ ' Available operations:'
|
|
133
|
+
+ ' `replace-in-host:SEARCH REPLACE` replaces the literal term SEARCH once in the hostname with REPLACE.'
|
|
134
|
+
+ ' `port:NUMBER` changes the port to NUMBER.'
|
|
135
|
+
+ ' `port:keep` keeps the port of the application (instead of using the chosen scheme\'s default port).'
|
|
136
|
+
+ ' `scheme:SCHEME` changes the URL scheme to one of ws, wss, http or https.'
|
|
137
|
+
+ ' `path:PATH` uses the URL path PATH (instead of no path).'
|
|
138
|
+
});
|
|
126
139
|
parser.add_argument('-x', '--exclude-origin', {
|
|
127
140
|
nargs: '*',
|
|
128
141
|
help: 'Glob pattern(s) of files in the source origin to not produce coverage for. Multiple patterns can be separated by space.'
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FileExcludePattern, InstrumentationTask, OriginSourcePattern, SourceMapReference, TaskElement, TaskResult } from './Task';
|
|
2
2
|
import { RawSourceMap, SourceMapConsumer } from 'source-map';
|
|
3
3
|
import { Optional } from 'typescript-optional';
|
|
4
4
|
import Logger from 'bunyan';
|
|
5
|
+
import { CollectorSpecifier } from '@src/vaccine/types';
|
|
5
6
|
export declare const IS_INSTRUMENTED_TOKEN = "$IS_JS_PROFILER_INSTRUMENTED=true";
|
|
6
7
|
/**
|
|
7
8
|
* An instrumenter that can conduct a {@code InstrumentationTask}.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Instrumenter.d.ts","sourceRoot":"","sources":["../../../src/instrumenter/Instrumenter.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,kBAAkB,
|
|
1
|
+
{"version":3,"file":"Instrumenter.d.ts","sourceRoot":"","sources":["../../../src/instrumenter/Instrumenter.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,kBAAkB,EAElB,mBAAmB,EACnB,mBAAmB,EAEnB,kBAAkB,EAElB,WAAW,EACX,UAAU,EACV,MAAM,QAAQ,CAAC;AAEhB,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAM7D,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,MAAM,MAAM,QAAQ,CAAC;AAO5B,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAExD,eAAO,MAAM,qBAAqB,sCAAsC,CAAC;AAEzE;;GAEG;AACH,MAAM,WAAW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AM,GAAG,YAAY,GAAG,SAAS,CAwC7G"}
|
|
@@ -204,7 +204,7 @@ class IstanbulInstrumenter {
|
|
|
204
204
|
loadVaccine(filePath, collector) {
|
|
205
205
|
// We first replace parameters in the file with the
|
|
206
206
|
// actual values, for example, the collector to send the coverage information to.
|
|
207
|
-
return fs.readFileSync(filePath, 'utf8').replace(/\$
|
|
207
|
+
return fs.readFileSync(filePath, 'utf8').replace(/\$COLLECTOR_SPECIFIER/g, JSON.stringify(collector));
|
|
208
208
|
}
|
|
209
209
|
/**
|
|
210
210
|
* @returns whether the given file is supported for instrumentation.
|
|
@@ -222,7 +222,7 @@ class IstanbulInstrumenter {
|
|
|
222
222
|
* given task element.
|
|
223
223
|
*/
|
|
224
224
|
configurationAlternativesFor(taskElement) {
|
|
225
|
-
this.logger.
|
|
225
|
+
this.logger.trace(`Determining configuration alternatives for ${taskElement.fromFile}`);
|
|
226
226
|
const baseConfig = {
|
|
227
227
|
isInstrumentedToken: exports.IS_INSTRUMENTED_TOKEN,
|
|
228
228
|
produceSourceMap: 'external',
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { CollectorSpecifierRelative } from "@src/vaccine/types";
|
|
2
|
+
/** Parses a relative collector pattern. */
|
|
3
|
+
export declare class RelativeCollectorPatternParser {
|
|
4
|
+
/** Parses the given pattern. */
|
|
5
|
+
static parse(pattern: string): CollectorSpecifierRelative;
|
|
6
|
+
private static apply;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=RelativeCollectorPatternParser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RelativeCollectorPatternParser.d.ts","sourceRoot":"","sources":["../../../src/instrumenter/RelativeCollectorPatternParser.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AAEhE,2CAA2C;AAC3C,qBAAa,8BAA8B;IAEvC,gCAAgC;IAChC,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,0BAA0B;IAkBzD,OAAO,CAAC,MAAM,CAAC,KAAK;CAgCvB"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RelativeCollectorPatternParser = void 0;
|
|
4
|
+
const commons_1 = require("@cqse/commons");
|
|
5
|
+
/** Parses a relative collector pattern. */
|
|
6
|
+
class RelativeCollectorPatternParser {
|
|
7
|
+
/** Parses the given pattern. */
|
|
8
|
+
static parse(pattern) {
|
|
9
|
+
const parts = pattern.split(",");
|
|
10
|
+
const specifier = {
|
|
11
|
+
type: "relative"
|
|
12
|
+
};
|
|
13
|
+
for (const part of parts) {
|
|
14
|
+
const colonIndex = part.indexOf(":");
|
|
15
|
+
commons_1.Contract.require(colonIndex > -1, `Invalid relative collector pattern ${pattern}: ${part} has no colon after the operation`);
|
|
16
|
+
const operation = part.substring(0, colonIndex);
|
|
17
|
+
const value = part.substring(colonIndex + 1);
|
|
18
|
+
RelativeCollectorPatternParser.apply(operation, value, specifier);
|
|
19
|
+
}
|
|
20
|
+
return specifier;
|
|
21
|
+
}
|
|
22
|
+
static apply(operation, value, specifier) {
|
|
23
|
+
switch (operation) {
|
|
24
|
+
case "port":
|
|
25
|
+
commons_1.Contract.requireStringPattern(value, /[0-9]+|keep/, `Invalid relative collector pattern: port must be a number: ${value}`);
|
|
26
|
+
if (value === "keep") {
|
|
27
|
+
specifier.port = value;
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
specifier.port = parseInt(value);
|
|
31
|
+
}
|
|
32
|
+
break;
|
|
33
|
+
case "replace-in-host":
|
|
34
|
+
commons_1.Contract.requireStringPattern(value, /[^ ]+ [^ ]*/, `Invalid relative collector pattern: replace-in-host must contain exactly one space to separate search string and replacement: ${value}`);
|
|
35
|
+
const parts = value.split(" ");
|
|
36
|
+
specifier.hostReplace = {
|
|
37
|
+
search: parts[0],
|
|
38
|
+
replace: parts[1],
|
|
39
|
+
};
|
|
40
|
+
break;
|
|
41
|
+
case "path":
|
|
42
|
+
specifier.path = value;
|
|
43
|
+
break;
|
|
44
|
+
case "scheme":
|
|
45
|
+
commons_1.Contract.requireStringPattern(value, /ws|wss|http|https/i, `Invalid relative collector pattern: scheme must be one of ws, wss, http or https: ${value}`);
|
|
46
|
+
specifier.scheme = value.toLowerCase();
|
|
47
|
+
break;
|
|
48
|
+
default:
|
|
49
|
+
throw new commons_1.IllegalArgumentException(`Invalid relative collector pattern: unknown operation ${operation}`);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
exports.RelativeCollectorPatternParser = RelativeCollectorPatternParser;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RelativeCollectorPatternParser.test.d.ts","sourceRoot":"","sources":["../../../src/instrumenter/RelativeCollectorPatternParser.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const RelativeCollectorPatternParser_1 = require("./RelativeCollectorPatternParser");
|
|
4
|
+
describe("SubstitutionPatternParser", () => {
|
|
5
|
+
test('empty pattern', () => {
|
|
6
|
+
expect(RelativeCollectorPatternParser_1.RelativeCollectorPatternParser.parse("")).toEqual({
|
|
7
|
+
type: "relative",
|
|
8
|
+
});
|
|
9
|
+
});
|
|
10
|
+
test('keep port', () => {
|
|
11
|
+
expect(RelativeCollectorPatternParser_1.RelativeCollectorPatternParser.parse("")).toEqual({
|
|
12
|
+
type: "relative",
|
|
13
|
+
port: "keep",
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
test('all features', () => {
|
|
17
|
+
expect(RelativeCollectorPatternParser_1.RelativeCollectorPatternParser.parse("scheme:wss,port:1234,replace-in-host:foo bar,path:path/path")).toEqual({
|
|
18
|
+
type: "relative",
|
|
19
|
+
hostReplace: {
|
|
20
|
+
search: "foo",
|
|
21
|
+
replace: "bar",
|
|
22
|
+
},
|
|
23
|
+
path: "path/path",
|
|
24
|
+
port: 1234,
|
|
25
|
+
scheme: "wss",
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Optional } from 'typescript-optional';
|
|
2
|
+
import { CollectorSpecifier } from '../vaccine/types';
|
|
2
3
|
/**
|
|
3
4
|
* An abstract source map type.
|
|
4
5
|
*/
|
|
@@ -46,14 +47,13 @@ export declare class TaskElement {
|
|
|
46
47
|
isInPlace(): boolean;
|
|
47
48
|
}
|
|
48
49
|
/**
|
|
49
|
-
*
|
|
50
|
-
*
|
|
50
|
+
* Given a command-line URL and an optional relative pattern, create a specifier for how the vaccine can
|
|
51
|
+
* locate the connector.
|
|
52
|
+
*
|
|
53
|
+
* If a relative pattern is given, it is preferred, since the command-line interface always provides a URL
|
|
54
|
+
* (the default URL in case the user didn't explicitly specify one).
|
|
51
55
|
*/
|
|
52
|
-
export declare
|
|
53
|
-
/** The URL specifying the address the collector is reachable at. */
|
|
54
|
-
readonly url: string;
|
|
55
|
-
constructor(specifier: string);
|
|
56
|
-
}
|
|
56
|
+
export declare function createCollectorSpecifier(commandLineUrl: string, relativePattern?: string): CollectorSpecifier;
|
|
57
57
|
/**
|
|
58
58
|
* Patterns that define which parts of a given bundle to instrument or not.
|
|
59
59
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Task.d.ts","sourceRoot":"","sources":["../../../src/instrumenter/Task.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"Task.d.ts","sourceRoot":"","sources":["../../../src/instrumenter/Task.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAG/C,OAAO,EAAE,kBAAkB,EAAqD,MAAM,kBAAkB,CAAA;AAGxG;;GAEG;A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M,CAAC;gBAE9B,iBAAiB,EAAE,MAAM;CAIrC"}
|
|
@@ -3,10 +3,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.SourceMapFileReference = exports.TaskResult = exports.InstrumentationTask = exports.FileExcludePattern = exports.OriginSourcePattern = exports.
|
|
6
|
+
exports.SourceMapFileReference = exports.TaskResult = exports.InstrumentationTask = exports.FileExcludePattern = exports.OriginSourcePattern = exports.createCollectorSpecifier = exports.TaskElement = exports.SourceMapReference = void 0;
|
|
7
7
|
const typescript_optional_1 = require("typescript-optional");
|
|
8
8
|
const commons_1 = require("@cqse/commons");
|
|
9
9
|
const micromatch_1 = __importDefault(require("micromatch"));
|
|
10
|
+
const RelativeCollectorPatternParser_1 = require("./RelativeCollectorPatternParser");
|
|
10
11
|
/**
|
|
11
12
|
* An abstract source map type.
|
|
12
13
|
*/
|
|
@@ -34,24 +35,39 @@ class TaskElement {
|
|
|
34
35
|
}
|
|
35
36
|
exports.TaskElement = TaskElement;
|
|
36
37
|
/**
|
|
37
|
-
*
|
|
38
|
-
*
|
|
38
|
+
* Given a command-line URL and an optional relative pattern, create a specifier for how the vaccine can
|
|
39
|
+
* locate the connector.
|
|
40
|
+
*
|
|
41
|
+
* If a relative pattern is given, it is preferred, since the command-line interface always provides a URL
|
|
42
|
+
* (the default URL in case the user didn't explicitly specify one).
|
|
39
43
|
*/
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
44
|
+
function createCollectorSpecifier(commandLineUrl, relativePattern) {
|
|
45
|
+
if (relativePattern !== undefined) {
|
|
46
|
+
return RelativeCollectorPatternParser_1.RelativeCollectorPatternParser.parse(relativePattern);
|
|
47
|
+
}
|
|
48
|
+
return parseCommandLineUrl(commandLineUrl);
|
|
49
|
+
}
|
|
50
|
+
exports.createCollectorSpecifier = createCollectorSpecifier;
|
|
51
|
+
/**
|
|
52
|
+
* Parses, validates and normalizes the given URL that the user provided on the command-line.
|
|
53
|
+
*/
|
|
54
|
+
function parseCommandLineUrl(commandLineUrl) {
|
|
55
|
+
let url;
|
|
56
|
+
if (commandLineUrl.indexOf('://') > 0) {
|
|
57
|
+
// A trailing slash will be removed
|
|
58
|
+
url = commandLineUrl.replace(/\/$/, '');
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
commons_1.Contract.requireStringPattern(commandLineUrl, '.+:[0-9]+', 'Invalid collector pattern used!');
|
|
62
|
+
const host = commandLineUrl.split(':')[0];
|
|
63
|
+
const port = Number.parseInt(commandLineUrl.split(':')[1]);
|
|
64
|
+
url = `ws://${host}:${port}`;
|
|
52
65
|
}
|
|
66
|
+
return {
|
|
67
|
+
type: "url",
|
|
68
|
+
url,
|
|
69
|
+
};
|
|
53
70
|
}
|
|
54
|
-
exports.CollectorSpecifier = CollectorSpecifier;
|
|
55
71
|
/**
|
|
56
72
|
* Configuration used to match paths with `micromatch`.
|
|
57
73
|
*/
|
|
@@ -7,6 +7,7 @@ export type ConfigurationParameters = {
|
|
|
7
7
|
to?: string;
|
|
8
8
|
source_map?: string;
|
|
9
9
|
collector: string;
|
|
10
|
+
collector_pattern?: string;
|
|
10
11
|
include_origin?: string[];
|
|
11
12
|
exclude_origin?: string[];
|
|
12
13
|
exclude_bundle?: string[];
|
|
@@ -37,8 +38,8 @@ export declare class TaskBuilder {
|
|
|
37
38
|
*/
|
|
38
39
|
private dumpMatchedOriginsFile;
|
|
39
40
|
constructor();
|
|
40
|
-
/** Set the collector
|
|
41
|
-
|
|
41
|
+
/** Set the collector specification based on the command-line arguments. */
|
|
42
|
+
setCollectorFromCommandLine(commandLineUrl: string, relativePattern?: string): this;
|
|
42
43
|
/** Set the origin include pattern. If multiple patterns are present, concatenates them via the OR operator. */
|
|
43
44
|
setOriginSourceIncludePatterns(patterns: string[] | undefined): this;
|
|
44
45
|
/** Set the origin exclude pattern(s). If multiple patterns are present, concatenates them via the OR operator. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TaskBuilder.d.ts","sourceRoot":"","sources":["../../../src/instrumenter/TaskBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,mBAAmB,EAGnB,kBAAkB,
|
|
1
|
+
{"version":3,"file":"TaskBuilder.d.ts","sourceRoot":"","sources":["../../../src/instrumenter/TaskBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,mBAAmB,EAGnB,kBAAkB,EAGlB,MAAM,QAAQ,CAAC;AAOhB,2DAA2D;AAC3D,MAAM,MAAM,uBAAuB,GAAG;IACrC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAElB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,EAAE,CAAC,EAAE,MAAM,CAAC;IAEZ,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAE3B,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAE1B,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAE1B,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAE1B,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB,sBAAsB,CAAC,EAAE,MAAM,CAAC;CAChC,CAAC;AAkBF;;GAEG;AACH,qBAAa,WAAW;IACvB,gDAAgD;IAChD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAgB;IAEzC,6CAA6C;IAC7C,OAAO,CAAC,SAAS,CAA4B;IAE7C,+BAA+B;IAC/B,OAAO,CAAC,2BAA2B,CAAuB;IAE1D,8BAA8B;IAC9B,OAAO,CAAC,2BAA2B,CAAuB;IAE1D,8BAA8B;IAC9B,OAAO,CAAC,yBAAyB,CAAuB;IAExD;;qDAEiD;IACjD,OAAO,CAAC,eAAe,CAAqB;IAE5C;;;OAGG;IACH,OAAO,CAAC,sBAAsB,CAAqB;;IAOnD,2EAA2E;IAC3E,2BAA2B,CAAC,cAAc,EAAE,MAAM,EAAE,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI;IAMnF,gHAAgH;IAChH,8BAA8B,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,SAAS,GAAG,IAAI;IAKpE,kHAAkH;IAClH,8BAA8B,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,SAAS,GAAG,IAAI;IAKpE,qHAAqH;IACrH,wBAAwB,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,SAAS,GAAG,IAAI;IAK9D,yBAAyB;IACzB,UAAU,CAAC,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,iBAAiB,CAAC,EAAE,kBAAkB,GAAG,IAAI;IAKlG;;;;OAIG;IACH,aAAa,CAAC,MAAM,EAAE,uBAAuB,GAAG,IAAI;IAqCpD;;;;;;;OAOG;IACH,OAAO,CAAC,4CAA4C;IAgCpD;;;;;;OAMG;IACH,OAAO,CAAC,0BAA0B;IASlC;;OAEG;IACI,KAAK,IAAI,mBAAmB;CAUnC"}
|
|
@@ -52,10 +52,10 @@ class TaskBuilder {
|
|
|
52
52
|
this.elements = [];
|
|
53
53
|
this.collector = null;
|
|
54
54
|
}
|
|
55
|
-
/** Set the collector
|
|
56
|
-
|
|
57
|
-
commons_1.Contract.requireNonEmpty(
|
|
58
|
-
this.collector =
|
|
55
|
+
/** Set the collector specification based on the command-line arguments. */
|
|
56
|
+
setCollectorFromCommandLine(commandLineUrl, relativePattern) {
|
|
57
|
+
commons_1.Contract.requireNonEmpty(commandLineUrl, "The collector URL must not be empty");
|
|
58
|
+
this.collector = (0, Task_1.createCollectorSpecifier)(commandLineUrl, relativePattern);
|
|
59
59
|
return this;
|
|
60
60
|
}
|
|
61
61
|
/** Set the origin include pattern. If multiple patterns are present, concatenates them via the OR operator. */
|
|
@@ -91,7 +91,7 @@ class TaskBuilder {
|
|
|
91
91
|
const sourceMap = config.source_map;
|
|
92
92
|
this.dumpOriginsFile = config.dump_origins_to;
|
|
93
93
|
this.dumpMatchedOriginsFile = config.dump_origin_matches_to;
|
|
94
|
-
this.
|
|
94
|
+
this.setCollectorFromCommandLine(config.collector, config.collector_pattern);
|
|
95
95
|
this.setOriginSourceIncludePatterns(config.include_origin);
|
|
96
96
|
this.setOriginSourceExcludePatterns(config.exclude_origin);
|
|
97
97
|
this.setBundleExcludePatterns(config.exclude_bundle);
|
package/dist/src/main.js
CHANGED
|
@@ -18,7 +18,7 @@ App_1.App.run()
|
|
|
18
18
|
const stats = (_b = result.task) === null || _b === void 0 ? void 0 : _b.originSourcePattern.retrieveMatchingFiles();
|
|
19
19
|
console.log(`\tSource origin matches`);
|
|
20
20
|
console.log(`\t\tInclude patterns: [${stats.includePatterns}]`);
|
|
21
|
-
console.log(`\t\tExclude patterns: [${stats.
|
|
21
|
+
console.log(`\t\tExclude patterns: [${stats.excludePatterns}]`);
|
|
22
22
|
console.log(`\t\tInclude matches: ${stats.includeMatches.length}`);
|
|
23
23
|
console.log(`\t\tExclude matches: ${stats.excludeMatches.length}`);
|
|
24
24
|
console.log(`\t\tNeither matches: ${stats.neitherExcludedNorIncluded.length}`);
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The collector URL is known at build time.
|
|
3
|
+
*/
|
|
4
|
+
export interface CollectorSpecifierUrl {
|
|
5
|
+
/** Type of collector specifier. */
|
|
6
|
+
type: "url";
|
|
7
|
+
/** The URL under which the collector can be reached at runtime. */
|
|
8
|
+
url: string;
|
|
9
|
+
}
|
|
10
|
+
/** Describes a one-time search and replace operation on a string. */
|
|
11
|
+
export interface SearchReplace {
|
|
12
|
+
/** Literal string to search for. */
|
|
13
|
+
search: string;
|
|
14
|
+
/** Literal replacement string. */
|
|
15
|
+
replace: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* The collector can be reached by replacing a term in location.host and optionally changing the port.
|
|
19
|
+
*/
|
|
20
|
+
export interface CollectorSpecifierRelative {
|
|
21
|
+
/** Type of collector specifier. */
|
|
22
|
+
type: "relative";
|
|
23
|
+
/** Literal replacement string. */
|
|
24
|
+
hostReplace?: SearchReplace;
|
|
25
|
+
/** Optional port. If no port is given, uses the protocol's default port. */
|
|
26
|
+
port?: number | "keep";
|
|
27
|
+
/** Optional URL scheme to use. If no scheme is given, uses ws. */
|
|
28
|
+
scheme?: string;
|
|
29
|
+
/** Optional path. If no path is given, uses only the hostname. */
|
|
30
|
+
path?: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Specifies how the vaccine can reach the collector.
|
|
34
|
+
*/
|
|
35
|
+
export type CollectorSpecifier = CollectorSpecifierUrl | CollectorSpecifierRelative;
|
|
36
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/vaccine/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACrC,mCAAmC;IACnC,IAAI,EAAE,KAAK,CAAC;IACZ,mEAAmE;IACnE,GAAG,EAAE,MAAM,CAAC;CACZ;AAED,qEAAqE;AACrE,MAAM,WAAW,aAAa;IAC7B,oCAAoC;IACpC,MAAM,EAAE,MAAM,CAAC;IACf,kCAAkC;IAClC,OAAO,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,0BAA0B;IAC1C,mCAAmC;IACnC,IAAI,EAAE,UAAU,CAAC;IACjB,kCAAkC;IAClC,WAAW,CAAC,EAAE,aAAa,CAAC;IAC5B,4EAA4E;IAC5E,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,kEAAkE;IAClE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,kEAAkE;IAClE,IAAI,CAAC,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,qBAAqB,GAAG,0BAA0B,CAAA"}
|
package/dist/vaccine.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(()=>{function
|
|
1
|
+
"use strict";(()=>{function u(t){let o=new Blob([t],{type:"text/javascript"}),e=URL.createObjectURL(o),r=new Worker(e);return URL.revokeObjectURL(e),r}function d(){return u('var i=class{constructor(e){this.cachedMessages=[];this.url=e,this.socket=this.createSocket()}createSocket(){let e=new WebSocket(this.url);return e.onopen=()=>this.onopen(),e.onclose=()=>this.onclose(),e}onclose(){this.socket=this.createSocket()}onopen(){console.log("Connection to Coverage Collector established."),this.cachedMessages.forEach(e=>this.socket.send(e)),this.cachedMessages=[]}send(e){this.socket.readyState===WebSocket.OPEN?this.socket.send(e):(this.cachedMessages.push(e),this.cachedMessages.length%500===0&&console.log(`More than ${this.cachedMessages.length} messages are queued to be sent.`))}};var c=class{constructor(e,o){this.milliseconds=e;this.onCountedToZero=o;this.timerHandle=null}restartCountdown(){this.stopCountdown(),this.timerHandle=self.setTimeout(()=>{this.stopCountdown(),this.onCountedToZero()},this.milliseconds)}stopCountdown(){this.timerHandle!==null&&(self.clearTimeout(this.timerHandle),this.timerHandle=null)}};var m=20,C=1e3,v="c",a=class{constructor(e){this.socket=e,this.cachedCoveredRanges=new Map,this.numberOfCachedPositions=0,this.flushCountdown=new c(C,()=>this.flush())}addLines(e,o){let t=this.cachedCoveredRanges.get(e);t||(t=new Set,this.cachedCoveredRanges.set(e,t)),o.forEach(r=>t.add(r)),this.numberOfCachedPositions+=1,this.flushCountdown.restartCountdown(),this.numberOfCachedPositions>=m&&this.flush()}arrayToLineCov(e){let o=[];for(let t of e)o.push(`${t}`);return o.join(";")}flush(){if(this.numberOfCachedPositions===0)return;this.flushCountdown.stopCountdown();let e=[];this.cachedCoveredRanges.forEach((o,t)=>{e.push(`@${t}`),e.push(this.arrayToLineCov(o))}),this.socket.send(`${v} ${e.join(";")}`),this.cachedCoveredRanges.clear(),this.numberOfCachedPositions=0}};var l=class s{static resolve(e){switch(e.type){case"url":return e.url;case"relative":return s.resolveRelative(location.host,location.port,e)}}static resolveRelative(e,o,t){var u;let r=e;t.hostReplace&&(r=e.replace(t.hostReplace.search,t.hostReplace.replace));let g=(u=t.scheme)!=null?u:"ws",n;t.port===void 0?n="":t.port==="keep"?n=`:${o}`:n=`:${t.port}`;let h="";t.path&&(h=`/${t.path}`);let d=`${g}://${r}${n}${h}`;return console.debug(`Resolved collector URL ${d} from ${e}:${o}`),d}};console.log("Starting coverage forwarding worker.");var f=new i(`${l.resolve($COLLECTOR_SPECIFIER)}/socket`),p=new a(f);onmessage=s=>{if(Array.isArray(s.data)){let[e,o]=s.data;p.addLines(e,o)}else s.data==="unload"?p.flush():console.error(`No handler for message: ${s.data}`)};\n')}function l(){return f()}function f(){return window}function g(t,o){let e=l()[t];return e||(e=o,l()[t]=e),e}function p(t,o){let e=new Map;function r(s){let n=e.get(s);return n||(n={lines:new Set},e.set(s,n),n)}function i(s,n,b=n){let h=r(s).lines;for(let c=n;c<=b;c++)h.add(c);h.size>255&&a()}function a(){o(e),e.clear()}return setInterval(()=>a(),t),{putLineCoverage:i,flush:a}}var v=g("__TS_AGENT",{});function C(){return v._$BcWorker}function m(t){return v._$BcWorker=t,t}var w=p(250,t=>{for(let o of t.entries())C().postMessage([o[0],Array.from(o[1].lines)])});l()._$l=w.putLineCoverage;if(!C()){let t=m(new d);(function(){let e=()=>{w.flush(),t.postMessage("unload")},r=function(a,s){s&&s.addEventListener(a,e,{capture:!0})},i=f();r("blur",i),r("unload",i),r("visibilitychange",i),r("beforeunload",i)})()}})();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teamscale/javascript-instrumenter",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.6",
|
|
4
4
|
"description": "JavaScript coverage instrumenter with coverage forwarding to a collector process",
|
|
5
5
|
"main": "dist/src/main.js",
|
|
6
6
|
"bin": "dist/src/main.js",
|
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
"dist/**/*"
|
|
16
16
|
],
|
|
17
17
|
"devDependencies": {
|
|
18
|
-
"@babel/core": "^7.23.
|
|
18
|
+
"@babel/core": "^7.23.9",
|
|
19
19
|
"@babel/plugin-transform-modules-commonjs": "^7.23.3",
|
|
20
|
-
"@babel/preset-env": "^7.23.
|
|
20
|
+
"@babel/preset-env": "^7.23.9",
|
|
21
21
|
"@types/argparse": "^2.0.14",
|
|
22
22
|
"@types/async": "^3.2.24",
|
|
23
23
|
"@types/babel__generator": "^7.6.8",
|
|
@@ -26,25 +26,25 @@
|
|
|
26
26
|
"@types/convert-source-map": "^2.0.3",
|
|
27
27
|
"@types/glob": "^8.1.0",
|
|
28
28
|
"@types/istanbul-lib-instrument": "^1.7.7",
|
|
29
|
-
"@types/jest": "^29.5.
|
|
30
|
-
"@types/node": "^20.11.
|
|
29
|
+
"@types/jest": "^29.5.12",
|
|
30
|
+
"@types/node": "^20.11.19",
|
|
31
31
|
"@types/ws": "^8.5.10",
|
|
32
32
|
"babel-jest": "^29.7.0",
|
|
33
|
-
"esbuild": "^0.
|
|
33
|
+
"esbuild": "^0.20.1",
|
|
34
34
|
"esbuild-plugin-inline-worker": "^0.1.1",
|
|
35
35
|
"jest": "^29.7.0",
|
|
36
36
|
"rimraf": "^5.0.5",
|
|
37
|
-
"ts-jest": "^29.1.
|
|
37
|
+
"ts-jest": "^29.1.2",
|
|
38
38
|
"ts-node": "^10.9.2",
|
|
39
39
|
"tslib": "^2.6.2",
|
|
40
40
|
"typescript": "^5.3.3"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@cqse/commons": "0.1.0-beta.
|
|
43
|
+
"@cqse/commons": "0.1.0-beta.5",
|
|
44
44
|
"@babel/generator": "^7.23.6",
|
|
45
|
-
"@babel/parser": "^7.23.
|
|
46
|
-
"@babel/traverse": "^7.23.
|
|
47
|
-
"@babel/types": "^7.23.
|
|
45
|
+
"@babel/parser": "^7.23.9",
|
|
46
|
+
"@babel/traverse": "^7.23.9",
|
|
47
|
+
"@babel/types": "^7.23.9",
|
|
48
48
|
"@types/micromatch": "^4.0.6",
|
|
49
49
|
"argparse": "^2.0.1",
|
|
50
50
|
"async": "^3.2.5",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"typescript-optional": "^2.0.1",
|
|
59
59
|
"unload": "^2.4.1",
|
|
60
60
|
"web-worker": "^1.3.0",
|
|
61
|
-
"@teamscale/lib-instrument": "0.1.0-beta.
|
|
61
|
+
"@teamscale/lib-instrument": "0.1.0-beta.6"
|
|
62
62
|
},
|
|
63
63
|
"publishConfig": {
|
|
64
64
|
"access": "public"
|