@teamscale/javascript-instrumenter 0.0.1-beta.5 → 0.0.1-beta.50
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 +2 -52
- package/dist/package.json +21 -15
- package/dist/src/App.d.ts +6 -1
- package/dist/src/App.d.ts.map +1 -1
- package/dist/src/App.js +90 -23
- package/dist/src/instrumenter/FileSystem.js +5 -1
- package/dist/src/instrumenter/Instrumenter.d.ts +39 -19
- package/dist/src/instrumenter/Instrumenter.d.ts.map +1 -1
- package/dist/src/instrumenter/Instrumenter.js +153 -66
- package/dist/src/instrumenter/Postprocessor.d.ts +9 -0
- package/dist/src/instrumenter/Postprocessor.d.ts.map +1 -0
- package/dist/src/instrumenter/Postprocessor.js +254 -0
- package/dist/src/instrumenter/Task.d.ts +37 -10
- package/dist/src/instrumenter/Task.d.ts.map +1 -1
- package/dist/src/instrumenter/Task.js +91 -37
- package/dist/src/instrumenter/TaskBuilder.d.ts +18 -10
- package/dist/src/instrumenter/TaskBuilder.d.ts.map +1 -1
- package/dist/src/instrumenter/TaskBuilder.js +28 -14
- package/dist/src/main.js +1 -0
- package/dist/vaccine.js +1 -221
- package/package.json +21 -15
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
|
-
|
|
12
|
+
in the [Teamscale Documentation](https://docs.teamscale.com/howto/recording-test-coverage-for-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.
|
|
@@ -25,28 +25,6 @@ yarn install
|
|
|
25
25
|
yarn build
|
|
26
26
|
```
|
|
27
27
|
|
|
28
|
-
### Preparation: Source Maps
|
|
29
|
-
|
|
30
|
-
Please make sure to enable the generation of source map files to ensure
|
|
31
|
-
that the profiled code can be mapped back to the original.
|
|
32
|
-
|
|
33
|
-
For example, when the tool Vite is used to bundle the code,
|
|
34
|
-
the generation of source map information can be enabled by setting:
|
|
35
|
-
|
|
36
|
-
```
|
|
37
|
-
build: {
|
|
38
|
-
sourcemap: true
|
|
39
|
-
}
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
or
|
|
43
|
-
|
|
44
|
-
```
|
|
45
|
-
build: {
|
|
46
|
-
sourcemap: `inline`
|
|
47
|
-
}
|
|
48
|
-
```
|
|
49
|
-
|
|
50
28
|
## Workflow Integration
|
|
51
29
|
|
|
52
30
|
There are several options to run the Instrumenter. For example, via `yarn` by running
|
|
@@ -61,36 +39,8 @@ or via `npx` by running
|
|
|
61
39
|
npx @teamscale/javascript-instrumenter
|
|
62
40
|
```
|
|
63
41
|
|
|
64
|
-
### Instrumenting a Single File
|
|
65
|
-
|
|
66
|
-
Adds information for coverage tracking to a single file, either
|
|
67
|
-
in-place (by replacing the previous content), or by producing a new file.
|
|
68
|
-
|
|
69
|
-
An in-place transformation is only allowed if the given file is already
|
|
70
|
-
the result of an automatic transformation process, that is, if a source-map is available.
|
|
71
|
-
|
|
72
|
-
If the source-map is not provided as an explicit argument, either
|
|
73
|
-
the file must contain source-map information, or the source-map file
|
|
74
|
-
must be placed along with the source file in the same directory.
|
|
75
|
-
|
|
76
|
-
```
|
|
77
|
-
yarn instrument --inplace ./the/path/to/the/file.js
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
```
|
|
81
|
-
yarn instrument --inplace ./the/path/to/the/file.js --source-map ./the/path/to/the/source.map
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
```
|
|
85
|
-
yarn instrument ./the/path/to/the/file.js --to ./the/file/path/to/write/to.js
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
### Integration with Testing Frameworks
|
|
89
|
-
|
|
90
|
-
This is planned work: Provide a Babel plugin that provides a code transformation
|
|
91
|
-
such that coverage information is collected and this information is forwarded.
|
|
92
|
-
|
|
93
42
|
## Limitations
|
|
94
43
|
|
|
95
44
|
This tool inherits most of the limitations of IstanbulJs, including
|
|
96
45
|
a considerable performance impact.
|
|
46
|
+
|
package/dist/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teamscale/javascript-instrumenter",
|
|
3
|
-
"version": "0.0.1-beta.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.0.1-beta.50",
|
|
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",
|
|
7
7
|
"types": "dist/src/main.d.ts",
|
|
@@ -12,24 +12,27 @@
|
|
|
12
12
|
"url": "https://github.com/cqse/teamscale-javascript-profiler.git"
|
|
13
13
|
},
|
|
14
14
|
"scripts": {
|
|
15
|
+
"prepublishOnly": "yarn clean && yarn build",
|
|
15
16
|
"clean": "rimraf dist tsconfig.tsbuildinfo",
|
|
16
|
-
"build": "tsc --project tsconfig.json &&
|
|
17
|
+
"build": "tsc --project tsconfig.json && yarn buildVaccine",
|
|
18
|
+
"buildVaccine": "node esbuild.mjs",
|
|
17
19
|
"instrumenter": "node dist/src/main.js",
|
|
18
|
-
"test": "yarn build && NODE_OPTIONS='--experimental-vm-modules' jest --forceExit --coverage --silent=true --detectOpenHandles"
|
|
20
|
+
"test": "yarn build && NODE_OPTIONS='--experimental-vm-modules --max-old-space-size=8192' jest --forceExit --coverage --silent=true --detectOpenHandles"
|
|
19
21
|
},
|
|
20
22
|
"files": [
|
|
21
23
|
"dist/**/*"
|
|
22
24
|
],
|
|
23
25
|
"devDependencies": {
|
|
24
|
-
"@babel/core": "^7.
|
|
25
|
-
"@babel/plugin-transform-modules-commonjs": "^7.
|
|
26
|
-
"@babel/preset-env": "^7.
|
|
26
|
+
"@babel/core": "^7.18.5",
|
|
27
|
+
"@babel/plugin-transform-modules-commonjs": "^7.18.2",
|
|
28
|
+
"@babel/preset-env": "^7.18.2",
|
|
27
29
|
"@types/async": "^3.2.6",
|
|
30
|
+
"@types/bunyan": "^1.8.8",
|
|
28
31
|
"@types/convert-source-map": "^1.5.1",
|
|
29
32
|
"@types/glob": "^7.1.3",
|
|
30
33
|
"@types/istanbul-lib-instrument": "^1.7.4",
|
|
31
34
|
"@types/jest": "^27.0.1",
|
|
32
|
-
"@types/mkdirp": "^1.0.
|
|
35
|
+
"@types/mkdirp": "^1.0.2",
|
|
33
36
|
"@types/node": "^15.0.1",
|
|
34
37
|
"@types/source-map": "^0.5.7",
|
|
35
38
|
"@types/ws": "^7.4.4",
|
|
@@ -44,22 +47,25 @@
|
|
|
44
47
|
"typescript": "^4.4.3"
|
|
45
48
|
},
|
|
46
49
|
"dependencies": {
|
|
47
|
-
"@
|
|
50
|
+
"@babel/generator": "^7.18.2",
|
|
51
|
+
"@babel/parser": "^7.18.5",
|
|
52
|
+
"@babel/traverse": "^7.18.6",
|
|
53
|
+
"@babel/types": "^7.18.4",
|
|
54
|
+
"@cqse/commons": "^0.0.1-beta.45",
|
|
48
55
|
"@types/micromatch": "^4.0.2",
|
|
49
56
|
"argparse": "^2.0.1",
|
|
50
|
-
"async": "^3.2.
|
|
57
|
+
"async": "^3.2.4",
|
|
58
|
+
"bunyan": "^1.8.15",
|
|
51
59
|
"convert-source-map": "^1.7.0",
|
|
52
60
|
"foreground-child": "^2.0.0",
|
|
53
61
|
"glob": "^7.1.7",
|
|
54
|
-
"istanbul-lib-instrument": "^
|
|
62
|
+
"istanbul-lib-instrument": "^5.2.0",
|
|
55
63
|
"micromatch": "4.0.4",
|
|
56
64
|
"mkdirp": "^1.0.4",
|
|
57
|
-
"
|
|
58
|
-
"source-map": "0.6.1",
|
|
65
|
+
"source-map": "0.7.4",
|
|
59
66
|
"typescript-optional": "^2.0.1",
|
|
60
67
|
"unload": "^2.2.0",
|
|
61
|
-
"web-worker": "^1.0.0"
|
|
62
|
-
"winston": "^3.3.3"
|
|
68
|
+
"web-worker": "^1.0.0"
|
|
63
69
|
},
|
|
64
70
|
"publishConfig": {
|
|
65
71
|
"access": "public"
|
package/dist/src/App.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TaskResult } from './instrumenter/Task';
|
|
2
2
|
import { ConfigurationParameters } from './instrumenter/TaskBuilder';
|
|
3
|
-
import
|
|
3
|
+
import Logger from 'bunyan';
|
|
4
4
|
/**
|
|
5
5
|
* Entry points of the instrumenter, including command line argument parsing.
|
|
6
6
|
*/
|
|
@@ -10,6 +10,11 @@ export declare class App {
|
|
|
10
10
|
* Parses the command line options and the instrumentation accordingly.
|
|
11
11
|
*/
|
|
12
12
|
static run(): Promise<TaskResult>;
|
|
13
|
+
/**
|
|
14
|
+
* Sometimes we get inputs from shell environments where the strings are
|
|
15
|
+
* still quoted. We remove those here.
|
|
16
|
+
*/
|
|
17
|
+
static postprocessConfig(config: ConfigurationParameters): void;
|
|
13
18
|
/**
|
|
14
19
|
* Build the command line argument parser.
|
|
15
20
|
*/
|
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,EAAuB,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAGtE,OAAO,EAAE,uBAAuB,EAAe,MAAM,4BAA4B,CAAC;
|
|
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;AAE5B;;GAEG;AACH,qBAAa,GAAG;IACf;;;OAGG;WACiB,GAAG,IAAI,OAAO,CAAC,UAAU,CAAC;IAe9C;;;OAGG;WACW,iBAAiB,CAAC,MAAM,EAAE,uBAAuB,GAAG,IAAI;IAyCtE;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,WAAW;IAyC1B;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,WAAW;IA8B1B;;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
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -29,8 +33,9 @@ const commons_1 = require("@cqse/commons");
|
|
|
29
33
|
const TaskBuilder_1 = require("./instrumenter/TaskBuilder");
|
|
30
34
|
const path = __importStar(require("path"));
|
|
31
35
|
const package_json_1 = require("../package.json");
|
|
32
|
-
const winston_1 = __importDefault(require("winston"));
|
|
33
36
|
const fs_1 = require("fs");
|
|
37
|
+
const mkdirp_1 = __importDefault(require("mkdirp"));
|
|
38
|
+
const bunyan_1 = __importDefault(require("bunyan"));
|
|
34
39
|
/**
|
|
35
40
|
* Entry points of the instrumenter, including command line argument parsing.
|
|
36
41
|
*/
|
|
@@ -46,9 +51,55 @@ class App {
|
|
|
46
51
|
const config = parser.parse_args();
|
|
47
52
|
// Build the logger
|
|
48
53
|
const logger = this.buildLogger(config);
|
|
54
|
+
logger.debug("Retrieved arguments", process.argv);
|
|
55
|
+
logger.debug("Translated arguments to config", config);
|
|
49
56
|
// Run the instrumenter with the given configuration.
|
|
50
57
|
return this.runForConfigArguments(config, logger);
|
|
51
58
|
}
|
|
59
|
+
/**
|
|
60
|
+
* Sometimes we get inputs from shell environments where the strings are
|
|
61
|
+
* still quoted. We remove those here.
|
|
62
|
+
*/
|
|
63
|
+
static postprocessConfig(config) {
|
|
64
|
+
function unquoteString(originalString) {
|
|
65
|
+
if (originalString === undefined) {
|
|
66
|
+
return originalString;
|
|
67
|
+
}
|
|
68
|
+
const result = originalString.replace(/^["'](.+(?=["']$))["']$/, '$1');
|
|
69
|
+
if (result === originalString) {
|
|
70
|
+
return result;
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
return unquoteString(result);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
function unquoteStringElements(originalArray) {
|
|
77
|
+
if (originalArray === undefined) {
|
|
78
|
+
return undefined;
|
|
79
|
+
}
|
|
80
|
+
return originalArray.map(s => {
|
|
81
|
+
if (typeof s === 'string') {
|
|
82
|
+
return unquoteString(s);
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
return s;
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
for (const [property, value] of Object.entries(config)) {
|
|
90
|
+
if (value === undefined) {
|
|
91
|
+
// In case the value is 'undefined' we can ignore this.
|
|
92
|
+
}
|
|
93
|
+
else if (typeof value === 'string') {
|
|
94
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
95
|
+
config[property] = unquoteString(value);
|
|
96
|
+
}
|
|
97
|
+
else if (Array.isArray(value)) {
|
|
98
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
99
|
+
config[property] = unquoteStringElements(value);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
52
103
|
/**
|
|
53
104
|
* Build the command line argument parser.
|
|
54
105
|
*/
|
|
@@ -59,24 +110,33 @@ class App {
|
|
|
59
110
|
parser.add_argument('-v', '--version', { action: 'version', version: package_json_1.version });
|
|
60
111
|
parser.add_argument('-i', '--in-place', {
|
|
61
112
|
action: 'store_true',
|
|
62
|
-
help: 'If set, the original files to instrument are replaced
|
|
113
|
+
help: 'If set, the original files to instrument are replaced by their instrumented counterparts.'
|
|
63
114
|
});
|
|
64
115
|
parser.add_argument('-d', '--debug', { action: 'store_true' });
|
|
65
116
|
parser.add_argument('-o', '--to', {
|
|
66
|
-
help: '
|
|
117
|
+
help: 'Path (directory or file name) to write the instrumented version to.'
|
|
67
118
|
});
|
|
68
119
|
parser.add_argument('-s', '--source-map', {
|
|
69
|
-
help: 'External location of source-map files to consider.'
|
|
120
|
+
help: 'External location of source-map files to consider.',
|
|
70
121
|
});
|
|
71
122
|
parser.add_argument('-c', '--collector', {
|
|
72
|
-
help: 'The collector (host:port) to send coverage information to.',
|
|
73
|
-
default: 'localhost:54678'
|
|
123
|
+
help: 'The collector (`host:port` or `wss://host:port/` or `ws://host:port/`) to send coverage information to.',
|
|
124
|
+
default: 'ws://localhost:54678'
|
|
74
125
|
});
|
|
75
126
|
parser.add_argument('-x', '--exclude-origin', {
|
|
76
|
-
|
|
127
|
+
nargs: '*',
|
|
128
|
+
help: 'Glob pattern(s) of files in the source origin to not produce coverage for. Multiple patterns can be separated by space.'
|
|
77
129
|
});
|
|
78
130
|
parser.add_argument('-k', '--include-origin', {
|
|
79
|
-
|
|
131
|
+
nargs: '*',
|
|
132
|
+
help: 'Glob pattern(s) of files in the source origin to produce coverage for. Multiple patterns can be separated by space.'
|
|
133
|
+
});
|
|
134
|
+
parser.add_argument('-e', '--exclude-bundle', {
|
|
135
|
+
nargs: '*',
|
|
136
|
+
help: 'Glob pattern(s) of input (bundle) files to keep unchanged (to not instrument).'
|
|
137
|
+
});
|
|
138
|
+
parser.add_argument('-p', '--dump-origins-to', {
|
|
139
|
+
help: 'Optional location specifying where to dump possible origins from the source map as a json file'
|
|
80
140
|
});
|
|
81
141
|
parser.add_argument('inputs', { nargs: '+', help: 'The input file(s) to instrument.' });
|
|
82
142
|
return parser;
|
|
@@ -85,14 +145,25 @@ class App {
|
|
|
85
145
|
* Construct the logger.
|
|
86
146
|
*/
|
|
87
147
|
static buildLogger(config) {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
148
|
+
const logfilePath = 'logs/instrumenter.log';
|
|
149
|
+
mkdirp_1.default.sync(path.dirname(logfilePath));
|
|
150
|
+
const logLevel = config.debug ? 'debug' : 'error';
|
|
151
|
+
return bunyan_1.default.createLogger({
|
|
152
|
+
name: 'Instrumenter',
|
|
153
|
+
streams: [
|
|
154
|
+
{
|
|
155
|
+
level: logLevel,
|
|
156
|
+
stream: {
|
|
157
|
+
write: (rec) => {
|
|
158
|
+
console.log('[%s] %s: %s', rec.time.toISOString(), bunyan_1.default.nameFromLevel[rec.level], rec.msg);
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
type: 'raw'
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
level: logLevel,
|
|
165
|
+
path: logfilePath
|
|
166
|
+
}
|
|
96
167
|
]
|
|
97
168
|
});
|
|
98
169
|
}
|
|
@@ -100,12 +171,7 @@ class App {
|
|
|
100
171
|
* A logger for testing.
|
|
101
172
|
*/
|
|
102
173
|
static buildDummyLogger() {
|
|
103
|
-
return
|
|
104
|
-
level: 'info',
|
|
105
|
-
format: winston_1.default.format.json(),
|
|
106
|
-
defaultMeta: {},
|
|
107
|
-
transports: [new winston_1.default.transports.Console({ format: winston_1.default.format.simple(), level: 'info' })]
|
|
108
|
-
});
|
|
174
|
+
return bunyan_1.default.createLogger({ name: 'Instrumenter' });
|
|
109
175
|
}
|
|
110
176
|
/**
|
|
111
177
|
* The instrumenter can also be started by providing the configuration dictionary explicitly.
|
|
@@ -114,6 +180,7 @@ class App {
|
|
|
114
180
|
* @param logger - The logger to use.
|
|
115
181
|
*/
|
|
116
182
|
static runForConfigArguments(config, logger) {
|
|
183
|
+
this.postprocessConfig(config);
|
|
117
184
|
const task = this.createInstrumentationTask(config);
|
|
118
185
|
commons_1.Contract.require(task.elements.length > 0, 'The instrumentation task must not be empty.');
|
|
119
186
|
return this.createInstrumenter(logger !== null && logger !== void 0 ? logger : this.buildDummyLogger()).instrument(task);
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { CollectorSpecifier, InstrumentationTask, OriginSourcePattern, TaskElement, TaskResult } from './Task';
|
|
2
|
-
import {
|
|
1
|
+
import { CollectorSpecifier, FileExcludePattern, InstrumentationTask, OriginSourcePattern, SourceMapReference, TaskElement, TaskResult } from './Task';
|
|
2
|
+
import { RawSourceMap, SourceMapConsumer } from 'source-map';
|
|
3
|
+
import { Optional } from 'typescript-optional';
|
|
4
|
+
import Logger from 'bunyan';
|
|
3
5
|
export declare const IS_INSTRUMENTED_TOKEN = "/** $IS_JS_PROFILER_INSTRUMENTED=true **/";
|
|
4
6
|
/**
|
|
5
7
|
* An instrumenter that can conduct a {@code InstrumentationTask}.
|
|
@@ -37,23 +39,16 @@ export declare class IstanbulInstrumenter implements IInstrumenter {
|
|
|
37
39
|
* @param collector - The collector to send the coverage information to.
|
|
38
40
|
* @param taskElement - The task element to perform the instrumentation for.
|
|
39
41
|
* @param sourcePattern - A pattern to restrict the instrumentation to only a fraction of the task element.
|
|
42
|
+
* @param dumpOriginsFile - A file path where all origins from the source map should be dumped in json format, or undefined if no origins should be dumped
|
|
40
43
|
*/
|
|
41
|
-
instrumentOne(collector: CollectorSpecifier, taskElement: TaskElement, sourcePattern: OriginSourcePattern): TaskResult
|
|
44
|
+
instrumentOne(collector: CollectorSpecifier, taskElement: TaskElement, excludeBundles: FileExcludePattern, sourcePattern: OriginSourcePattern, dumpOriginsFile: string | undefined): Promise<TaskResult>;
|
|
45
|
+
private removeUnwantedInstrumentation;
|
|
42
46
|
/**
|
|
43
47
|
* Loads the vaccine from the vaccine file and adjusts some template parameters.
|
|
44
48
|
*
|
|
45
49
|
* @param collector - The collector to send coverage information to.
|
|
46
50
|
*/
|
|
47
51
|
private loadVaccine;
|
|
48
|
-
/**
|
|
49
|
-
* Should the given file be excluded from the instrumentation,
|
|
50
|
-
* based on the source files that have been transpiled into it?
|
|
51
|
-
*
|
|
52
|
-
* @param pattern - The pattern to match the origin source files.
|
|
53
|
-
* @param sourceFile - The bundle file name.
|
|
54
|
-
* @param originSourceFiles - The list of files that were transpiled into the bundle.
|
|
55
|
-
*/
|
|
56
|
-
private shouldExcludeFromInstrumentation;
|
|
57
52
|
/**
|
|
58
53
|
* @returns whether the given file is supported for instrumentation.
|
|
59
54
|
*/
|
|
@@ -63,12 +58,37 @@ export declare class IstanbulInstrumenter implements IInstrumenter {
|
|
|
63
58
|
* given task element.
|
|
64
59
|
*/
|
|
65
60
|
private configurationAlternativesFor;
|
|
66
|
-
/**
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
* @param taskElement - The task element that can have a reference to an external sourcemap.
|
|
71
|
-
*/
|
|
72
|
-
private loadInputSourceMap;
|
|
61
|
+
/** Appends all origins from the source map to a given file. Creates the file if it does not exist yet. */
|
|
62
|
+
private dumpOrigins;
|
|
63
|
+
/** Clears the dump origins file if it exists, such that it is now ready to be appended for every instrumented file. */
|
|
64
|
+
private clearDumpOriginsFileIfNeeded;
|
|
73
65
|
}
|
|
66
|
+
/**
|
|
67
|
+
* Extract the sourcemap from the given source code.
|
|
68
|
+
*
|
|
69
|
+
* @param instrumentedSource - The source code.
|
|
70
|
+
* @param instrumentedSourceFileName - The file name to assume for the file name.
|
|
71
|
+
*/
|
|
72
|
+
export declare function loadSourceMap(instrumentedSource: string, instrumentedSourceFileName: string): Promise<SourceMapConsumer | undefined>;
|
|
73
|
+
/**
|
|
74
|
+
* Given a source code file, load the corresponding sourcemap.
|
|
75
|
+
*
|
|
76
|
+
* @param inputSource - The source code that might contain sourcemap comments.
|
|
77
|
+
* @param taskFile - The name of the file the `inputSource` is from.
|
|
78
|
+
* @param externalSourceMapFile - An external source map file to consider.
|
|
79
|
+
*/
|
|
80
|
+
export declare function loadInputSourceMap(inputSource: string, taskFile: string, externalSourceMapFile: Optional<SourceMapReference>): RawSourceMap | undefined;
|
|
81
|
+
/**
|
|
82
|
+
* Extract a sourcemap for a given code comment.
|
|
83
|
+
*
|
|
84
|
+
* @param sourcecode - The source code that is scanned for source map comments.
|
|
85
|
+
* @param sourceFilePath - The file name the code was loaded from.
|
|
86
|
+
*/
|
|
87
|
+
export declare function sourceMapFromCodeComment(sourcecode: string, sourceFilePath: string): RawSourceMap | undefined;
|
|
88
|
+
/**
|
|
89
|
+
* Read a source map from a source map file.
|
|
90
|
+
*
|
|
91
|
+
* @param mapFilePath
|
|
92
|
+
*/
|
|
93
|
+
export declare function sourceMapFromMapFile(mapFilePath: string): RawSourceMap | undefined;
|
|
74
94
|
//# sourceMappingURL=Instrumenter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Instrumenter.d.ts","sourceRoot":"","sources":["../../../src/instrumenter/Instrumenter.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,kBAAkB,
|
|
1
|
+
{"version":3,"file":"Instrumenter.d.ts","sourceRoot":"","sources":["../../../src/instrumenter/Instrumenter.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,kBAAkB,EAAE,kBAAkB,EACtC,mBAAmB,EACnB,mBAAmB,EAEnB,kBAAkB,EAClB,WAAW,EACX,UAAU,EACV,MAAM,QAAQ,CAAC;AAEhB,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAO7D,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,MAAM,MAAM,QAAQ,CAAC;AAG5B,eAAO,MAAM,qBAAqB,8CAA8C,CAAC;AAEjF;;GAEG;AACH,MAAM,WAAW,aAAa;IAC7B;;;;OAIG;IACH,UAAU,CAAC,IAAI,EAAE,mBAAmB,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;CAC3D;AAED;;GAEG;AACH,qBAAa,oBAAqB,YAAW,aAAa;IACzD;;;;OAIG;IACH,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAS;IAEzC;;OAEG;IACH,OAAO,CAAC,MAAM,CAAS;gBAEX,eAAe,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IASnD;;OAEG;IACG,UAAU,CAAC,IAAI,EAAE,mBAAmB,GAAG,OAAO,CAAC,UAAU,CAAC;IAsBhE;;;;;;;OAOG;IACG,aAAa,CAClB,SAAS,EAAE,kBAAkB,EAC7B,WAAW,EAAE,WAAW,EACxB,cAAc,EAAE,kBAAkB,EAClC,aAAa,EAAE,mBAAmB,EAClC,eAAe,EAAE,MAAM,GAAG,SAAS,GACjC,OAAO,CAAC,UAAU,CAAC;YAgHR,6BAA6B;IA8C3C;;;;OAIG;IACH,OAAO,CAAC,WAAW;IAMnB;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAK3B;;;OAGG;IACH,OAAO,CAAC,4BAA4B;IAcpC,0GAA0G;IAC1G,OAAO,CAAC,WAAW;IASnB,uHAAuH;IACvH,OAAO,CAAC,4BAA4B;CASpC;AAED;;;;;GAKG;AACH,wBAAsB,aAAa,CAClC,kBAAkB,EAAE,MAAM,EAC1B,0BAA0B,EAAE,MAAM,GAChC,OAAO,CAAC,iBAAiB,GAAG,SAAS,CAAC,CAUxC;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CACjC,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,MAAM,EAChB,qBAAqB,EAAE,QAAQ,CAAC,kBAAkB,CAAC,GACjD,YAAY,GAAG,SAAS,CAU1B;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,UAAU,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS,CAsC7G;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS,CAGlF"}
|