@teamscale/javascript-instrumenter 1.0.0-beta.4 → 1.0.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/dist/package.json +1 -4
- package/dist/src/App.d.ts +4 -0
- package/dist/src/App.d.ts.map +1 -1
- package/dist/src/App.js +54 -1
- package/dist/src/instrumenter/Instrumenter.d.ts +1 -2
- package/dist/src/instrumenter/Instrumenter.d.ts.map +1 -1
- package/dist/src/instrumenter/Instrumenter.js +5 -5
- package/dist/src/instrumenter/InstrumenterConfig.d.ts +1 -0
- package/dist/src/instrumenter/InstrumenterConfig.d.ts.map +1 -1
- package/dist/src/instrumenter/InstrumenterConfig.js +24 -2
- package/dist/src/instrumenter/Task.d.ts +1 -2
- package/dist/src/instrumenter/Task.d.ts.map +1 -1
- package/dist/src/instrumenter/Task.js +1 -2
- package/dist/src/main.js +3 -69
- package/package.json +3 -30
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teamscale/javascript-instrumenter",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.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,7 +23,6 @@
|
|
|
23
23
|
"@babel/core": "^7.26.8",
|
|
24
24
|
"@babel/plugin-transform-modules-commonjs": "^7.26.3",
|
|
25
25
|
"@babel/preset-env": "^7.26.8",
|
|
26
|
-
"@types/argparse": "^2.0.17",
|
|
27
26
|
"@types/async": "^3.2.24",
|
|
28
27
|
"@types/babel__generator": "^7.6.8",
|
|
29
28
|
"@types/babel__traverse": "^7.20.6",
|
|
@@ -52,7 +51,6 @@
|
|
|
52
51
|
"@babel/traverse": "^7.26.8",
|
|
53
52
|
"@babel/types": "^7.26.8",
|
|
54
53
|
"@types/micromatch": "^4.0.9",
|
|
55
|
-
"argparse": "^2.0.1",
|
|
56
54
|
"async": "^3.2.6",
|
|
57
55
|
"bunyan": "^1.8.15",
|
|
58
56
|
"convert-source-map": "^2.0.0",
|
|
@@ -61,7 +59,6 @@
|
|
|
61
59
|
"micromatch": "4.0.8",
|
|
62
60
|
"mkdirp": "^3.0.1",
|
|
63
61
|
"source-map": "0.7.4",
|
|
64
|
-
"typescript-optional": "^2.0.1",
|
|
65
62
|
"unload": "^2.4.1",
|
|
66
63
|
"uuid": "^11.1.0",
|
|
67
64
|
"web-worker": "^1.5.0"
|
package/dist/src/App.d.ts
CHANGED
|
@@ -44,5 +44,9 @@ export declare class App {
|
|
|
44
44
|
static runForConfigArguments(config: InstrumenterOptions, logger?: Logger): Promise<TaskResult>;
|
|
45
45
|
private static createInstrumentationTask;
|
|
46
46
|
private static createInstrumenter;
|
|
47
|
+
/**
|
|
48
|
+
* Processes the task result and produces console outputs, and possibly a process exit with a corresponding code.
|
|
49
|
+
*/
|
|
50
|
+
private static finalizeAppRunWithConsoleOutputs;
|
|
47
51
|
}
|
|
48
52
|
//# sourceMappingURL=App.d.ts.map
|
package/dist/src/App.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../../src/App.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAYtE,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,OAAO,EAA4C,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AAGlH;;GAEG;AACH,qBAAa,GAAG;IACf;;;OAGG;WACiB,GAAG,IAAI,OAAO,CAAC,UAAU,CAAC;IAI9C;;OAEG;WACiB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC;IA2BnE;;;;;;OAMG;WACW,gBAAgB,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,2BAA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xC,OAAO,CAAC,MAAM,CAAC,kBAAkB;IAcjC;;OAEG;mBACkB,gCAAgC;CAmDrD"}
|
package/dist/src/App.js
CHANGED
|
@@ -207,7 +207,8 @@ class App {
|
|
|
207
207
|
}
|
|
208
208
|
const task = this.createInstrumentationTask(config);
|
|
209
209
|
commons_1.Contract.require(task.elements.length > 0, 'The instrumentation task must not be empty.');
|
|
210
|
-
|
|
210
|
+
const instrumentationResult = this.createInstrumenter(logger !== null && logger !== void 0 ? logger : this.buildDummyLogger(), task.collector, task.targetBucket).instrument(task);
|
|
211
|
+
return App.finalizeAppRunWithConsoleOutputs(instrumentationResult);
|
|
211
212
|
}
|
|
212
213
|
static createInstrumentationTask(config) {
|
|
213
214
|
return new TaskBuilder_1.TaskBuilder().addFromConfig(config).build();
|
|
@@ -226,5 +227,57 @@ class App {
|
|
|
226
227
|
return new Instrumenter_1.IstanbulInstrumenter(pathVariant2, logger, collector, targetBucket);
|
|
227
228
|
}
|
|
228
229
|
}
|
|
230
|
+
/**
|
|
231
|
+
* Processes the task result and produces console outputs, and possibly a process exit with a corresponding code.
|
|
232
|
+
*/
|
|
233
|
+
static async finalizeAppRunWithConsoleOutputs(resultPromise) {
|
|
234
|
+
var _a, _b;
|
|
235
|
+
try {
|
|
236
|
+
const result = await resultPromise;
|
|
237
|
+
console.log('Instrumentation finished.');
|
|
238
|
+
console.log(`\tInstrumented: ${result.translated}`);
|
|
239
|
+
console.log(`\tExcluded: ${result.excluded}`);
|
|
240
|
+
console.log(`\tInstrumented from cache: ${result.translatedFromCache}`);
|
|
241
|
+
console.log(`\tAlready instrumented: ${result.alreadyInstrumented}`);
|
|
242
|
+
console.log(`\tUnsupported: ${result.unsupported}`);
|
|
243
|
+
console.log(`\tWith warning: ${result.warnings}`);
|
|
244
|
+
console.log(`\tFailed: ${result.failed}`);
|
|
245
|
+
if ((_a = result.task) === null || _a === void 0 ? void 0 : _a.originSourcePattern.patternsSpecified()) {
|
|
246
|
+
const stats = (_b = result.task) === null || _b === void 0 ? void 0 : _b.originSourcePattern.retrieveMatchingFiles();
|
|
247
|
+
console.log(`\tSource origin matches`);
|
|
248
|
+
console.log(`\t\tInclude patterns: [${stats.includePatterns}]`);
|
|
249
|
+
console.log(`\t\tExclude patterns: [${stats.excludePatterns}]`);
|
|
250
|
+
console.log(`\t\tInclude matches: ${stats.includeMatches.length}`);
|
|
251
|
+
console.log(`\t\tExclude matches: ${stats.excludeMatches.length}`);
|
|
252
|
+
console.log(`\t\tNeither matches: ${stats.neitherExcludedNorIncluded.length}`);
|
|
253
|
+
if (stats.includeMatches.length === 0 && stats.excludeMatches.length === 0) {
|
|
254
|
+
console.error('\nWARNING: Specified include/exclude patterns are expected to match at least once. ' +
|
|
255
|
+
'None matched for this instrumenter invocation.\n');
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
if (result.translated === 0 && result.translatedFromCache === 0 && result.alreadyInstrumented === 0) {
|
|
259
|
+
console.error('\nWARNING: Each invocation of the JavaScript Instrumenter is supposed to match at \n' +
|
|
260
|
+
'least one file to instrument; no file was matched for instrumentation in this invocation. \n' +
|
|
261
|
+
'Please check the list of input files and the include/exclude patterns.\n');
|
|
262
|
+
}
|
|
263
|
+
if (result.failed > 0) {
|
|
264
|
+
console.error('FAILURE: The instrumentation failed for some files. Please check the log for details.\n');
|
|
265
|
+
}
|
|
266
|
+
return result;
|
|
267
|
+
}
|
|
268
|
+
catch (reason) {
|
|
269
|
+
if (reason instanceof commons_1.InvalidConfigurationException) {
|
|
270
|
+
// Do not print the stack trace for invalid configuration parameters from the user.
|
|
271
|
+
console.error(`Failed: ${reason.message}`);
|
|
272
|
+
}
|
|
273
|
+
else {
|
|
274
|
+
console.error('Failed: ', reason);
|
|
275
|
+
}
|
|
276
|
+
process.exit(1);
|
|
277
|
+
}
|
|
278
|
+
finally {
|
|
279
|
+
console.log('Bye bye.');
|
|
280
|
+
}
|
|
281
|
+
}
|
|
229
282
|
}
|
|
230
283
|
exports.App = App;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { FileExcludePattern, InstrumentationTask, OriginSourcePattern, SourceMapReference, TaskElement, TaskResult } from './Task';
|
|
2
2
|
import { RawSourceMap, SourceMapConsumer } from 'source-map';
|
|
3
|
-
import { Optional } from 'typescript-optional';
|
|
4
3
|
import Logger from 'bunyan';
|
|
5
4
|
import { CollectorSpecifier, CoverageBucketSpecifier } from '@src/vaccine/types';
|
|
6
5
|
export declare const IS_INSTRUMENTED_TOKEN = "$IS_JS_PROFILER_INSTRUMENTED=true";
|
|
@@ -82,7 +81,7 @@ export declare function loadSourceMap(instrumentedSource: string, instrumentedSo
|
|
|
82
81
|
* @param taskFile - The name of the file the `inputSource` is from.
|
|
83
82
|
* @param externalSourceMapFile - An external source map file to consider.
|
|
84
83
|
*/
|
|
85
|
-
export declare function loadInputSourceMap(inputSource: string, taskFile: string, externalSourceMapFile
|
|
84
|
+
export declare function loadInputSourceMap(inputSource: string, taskFile: string, externalSourceMapFile?: SourceMapReference): RawSourceMap | undefined;
|
|
86
85
|
/**
|
|
87
86
|
* Extract a sourcemap for a given code comment.
|
|
88
87
|
*
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,E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AUxC;AAsBD;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CACjC,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,MAAM,EAChB,qBAAqB,CAAC,EAAE,kBAAkB,GACxC,YAAY,GAAG,SAAS,CAU1B;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,UAAU,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS,CAwC7G"}
|
|
@@ -48,7 +48,6 @@ const fs = __importStar(require("fs"));
|
|
|
48
48
|
const mkdirp = __importStar(require("mkdirp"));
|
|
49
49
|
const path = __importStar(require("path"));
|
|
50
50
|
const convertSourceMap = __importStar(require("convert-source-map"));
|
|
51
|
-
const typescript_optional_1 = require("typescript-optional");
|
|
52
51
|
const async_1 = __importDefault(require("async"));
|
|
53
52
|
const WebToolkit_1 = require("./WebToolkit");
|
|
54
53
|
const FileSystem_1 = require("./FileSystem");
|
|
@@ -242,8 +241,9 @@ class IstanbulInstrumenter {
|
|
|
242
241
|
this.logger.trace(`Determining configuration alternatives for ${taskElement.fromFile}`);
|
|
243
242
|
const baseConfig = {
|
|
244
243
|
isInstrumentedToken: exports.IS_INSTRUMENTED_TOKEN,
|
|
245
|
-
produceSourceMap: '
|
|
244
|
+
produceSourceMap: 'none',
|
|
246
245
|
codeToPrepend: this.vaccineSource,
|
|
246
|
+
preserveComments: false, // Will remove commends including old source maps that are provided inline as comments
|
|
247
247
|
compact: false // Would lead to `code generator has deoptimised the styling of` errors otherwise
|
|
248
248
|
};
|
|
249
249
|
return [
|
|
@@ -283,7 +283,7 @@ exports.IstanbulInstrumenter = IstanbulInstrumenter;
|
|
|
283
283
|
* @param instrumentedSourceFileName - The file name to assume for the file name.
|
|
284
284
|
*/
|
|
285
285
|
async function loadSourceMap(instrumentedSource, instrumentedSourceFileName) {
|
|
286
|
-
const instrumentedSourceMap = loadInputSourceMap(instrumentedSource, instrumentedSourceFileName,
|
|
286
|
+
const instrumentedSourceMap = loadInputSourceMap(instrumentedSource, instrumentedSourceFileName, undefined);
|
|
287
287
|
if (instrumentedSourceMap) {
|
|
288
288
|
return await new source_map_1.SourceMapConsumer(instrumentedSourceMap);
|
|
289
289
|
}
|
|
@@ -308,8 +308,8 @@ function loadInputSourceMapsStandard(taskFile, bundleFile, externalSourceMapFile
|
|
|
308
308
|
* @param externalSourceMapFile - An external source map file to consider.
|
|
309
309
|
*/
|
|
310
310
|
function loadInputSourceMap(inputSource, taskFile, externalSourceMapFile) {
|
|
311
|
-
if (externalSourceMapFile
|
|
312
|
-
const sourceMapOrigin = externalSourceMapFile
|
|
311
|
+
if (externalSourceMapFile) {
|
|
312
|
+
const sourceMapOrigin = externalSourceMapFile;
|
|
313
313
|
if (!(sourceMapOrigin instanceof Task_1.SourceMapFileReference)) {
|
|
314
314
|
throw new commons_1.IllegalArgumentException('Type of source map not yet supported!');
|
|
315
315
|
}
|
|
@@ -27,6 +27,7 @@ export type InstrumenterOptions = {
|
|
|
27
27
|
collectorConfigFileContent?: string;
|
|
28
28
|
collectorOption?: string[];
|
|
29
29
|
collectorOptionsList?: boolean;
|
|
30
|
+
coverageTargetFromCollector?: boolean;
|
|
30
31
|
};
|
|
31
32
|
/**
|
|
32
33
|
* Builds and returns a configuration parameters object for the JavaScript instrumenter.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InstrumenterConfig.d.ts","sourceRoot":"","sources":["../../../src/instrumenter/InstrumenterConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,uBAAuB,EAGvB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAGxC;;;;GAIG;AACH,MAAM,MAAM,mBAAmB,GAAG;IACjC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,EAAE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SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,0BAA0B,CAAC,EAAE,MAAM,CAAC;IACpC,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,2BAA2B,CAAC,EAAE,OAAO,CAAC;CACtC,CAAC;AAsBF;;;GAGG;AACH,wBAAgB,wCAAwC,IAAI,uBAAuB,CA+IlF"}
|
|
@@ -53,6 +53,10 @@ function buildInstrumenterConfigurationParameters() {
|
|
|
53
53
|
help: 'The name of the application to report coverage for. Will be used to make the automatically generated application ID more readable.',
|
|
54
54
|
group: CONFIG_GROUP_TARGET_PARAMS
|
|
55
55
|
});
|
|
56
|
+
addParameter(undefined, '--coverage-target-from-collector', 'bool', {
|
|
57
|
+
help: 'All coverage target (upload) parameters, for example, the target partition, shall be specified by the collector.',
|
|
58
|
+
group: CONFIG_GROUP_TARGET_PARAMS
|
|
59
|
+
});
|
|
56
60
|
addParameter('-f', '--config-id', 'string', {
|
|
57
61
|
help: 'The ID of the profiler configuration to use; this configuration is refetched from Teamscale once a minute.',
|
|
58
62
|
group: CONFIG_GROUP_TARGET_PARAMS
|
|
@@ -127,8 +131,26 @@ function buildInstrumenterConfigurationParameters() {
|
|
|
127
131
|
}
|
|
128
132
|
});
|
|
129
133
|
parameters.addArgumentCheck(options => {
|
|
130
|
-
if (
|
|
131
|
-
|
|
134
|
+
if (options.coverageTargetFromCollector) {
|
|
135
|
+
// No other coverage target specifiers shall be set.
|
|
136
|
+
if (Array.isArray(options.collectorOption) && options.collectorOption.length > 0) {
|
|
137
|
+
const optionsSet = new Set(options.collectorOption.map((value) => value.split("=")[0]));
|
|
138
|
+
if (optionsSet.has("teamscale-partition")
|
|
139
|
+
|| optionsSet.has("teamscale-project")
|
|
140
|
+
|| optionsSet.has("teamscale-repository")
|
|
141
|
+
|| optionsSet.has("teamscale-message")) {
|
|
142
|
+
return 'The parameter `--coverage-target-from-collector` cannot be combined ' +
|
|
143
|
+
'with explicitly setting upload target options in the instrumenter.';
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
// Only if the coverage target parameters shall be set in the instrumented app only (see TS-44625).
|
|
149
|
+
if (!options.configId && !options.collectorConfigFile && !(Array.isArray(options.collectorOption) && options.collectorOption.length > 0)) {
|
|
150
|
+
return 'Either a configuration ID (--config-id), a collector configuration file (--collector-config-file) ' +
|
|
151
|
+
'or explicit collector options (--collector-option) must be specified. You can also decide to set all ' +
|
|
152
|
+
'coverage upload parameters on the collector side only by setting --coverage-target-from-collector.';
|
|
153
|
+
}
|
|
132
154
|
}
|
|
133
155
|
});
|
|
134
156
|
parameters.addArgumentCheck(options => {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Optional } from 'typescript-optional';
|
|
2
1
|
import { CollectorSpecifier, CoverageBucketSpecifier } from '../vaccine/types';
|
|
3
2
|
/**
|
|
4
3
|
* An abstract source map type.
|
|
@@ -39,7 +38,7 @@ export declare class TaskElement {
|
|
|
39
38
|
/** The destination file */
|
|
40
39
|
readonly toFile: string;
|
|
41
40
|
/** An external source map file relevant for the file at hand */
|
|
42
|
-
readonly externalSourceMapFile
|
|
41
|
+
readonly externalSourceMapFile?: SourceMapReference;
|
|
43
42
|
constructor(fromFile: string, toFile: string, externalSourceMap?: SourceMapReference);
|
|
44
43
|
/**
|
|
45
44
|
* Is it an in-place instrumentation task?
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Task.d.ts","sourceRoot":"","sources":["../../../src/instrumenter/Task.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Task.d.ts","sourceRoot":"","sources":["../../../src/instrumenter/Task.ts"],"names":[],"mappings":"AAEA,OAAO,EACN,kBAAkB,EAElB,uBAAuB,EACvB,MAAM,kBAAkB,CAAC;AAG1B;;GAEG;AACH,8BAAsB,kBAAkB;CAAI;AAE5C,KAAK,UAAU,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC;AAE/D;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG,UAAU,GAAG;IAAE,IAAI,EAAE,YAAY,CAAA;CAAE,CAAC;AAEjE;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,UAAU,GAAG;IACpC,IAAI,EAAE,KAAK,CAAC;IACZ,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,mBAAmB,EAAE,OAAO,CAAC;CAC7B,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,MAAM,GAAG,UAAU,GAAG,CAAC,cAAc,GAAG,SAAS,CAAC,CAAC;AAE/D;;;GAGG;AACH,qBAAa,WAAW;IACvB,sBAAsB;IACtB,SAAgB,QAAQ,EAAE,MAAM,CAAC;IAEjC,2BAA2B;IAC3B,SAAgB,MAAM,EAAE,MAAM,CAAC;IAE/B,gEAAgE;IAChE,SAAgB,qBAAqB,CAAC,EAAE,kBAAkB,CAAC;gBAE/C,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,iBAAiB,CAAC,EAAE,kBAAkB;IAMpF;;OAEG;IACI,SAAS,IAAI,OAAO;CAK3B;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CAAC,cAAc,EAAE,MAAM,EAAE,eAAe,CAAC,EAAE,MAAM,GAAG,kBAAkB,CAM7G;AAgCD;;;;;;GAMG;AACH,qBAA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AAG,UAAU;IAanD;;OAEG;WACW,OAAO,CAAC,IAAI,CAAC,EAAE,mBAAmB,GAAG,UAAU;IAI7D;;;;OAIG;WACW,KAAK,CAAC,CAAC,EAAE,KAAK,GAAG,UAAU;IAKzC;;;;OAIG;WACW,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU;CAI9C;AAED;;GAEG;AACH,qBAAa,sBAAuB,SAAQ,kBAAkB;IAC7D,2CAA2C;IAC3C,SAAgB,iBAAiB,EAAE,MAAM,CAAC;gBAE9B,iBAAiB,EAAE,MAAM;CAIrC"}
|
|
@@ -5,7 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.SourceMapFileReference = exports.TaskResult = exports.InstrumentationTask = exports.FileExcludePattern = exports.OriginSourcePattern = exports.TaskElement = exports.SourceMapReference = void 0;
|
|
7
7
|
exports.createCollectorSpecifier = createCollectorSpecifier;
|
|
8
|
-
const typescript_optional_1 = require("typescript-optional");
|
|
9
8
|
const commons_1 = require("@cqse/commons");
|
|
10
9
|
const micromatch_1 = __importDefault(require("micromatch"));
|
|
11
10
|
const RelativeCollectorPatternParser_1 = require("./RelativeCollectorPatternParser");
|
|
@@ -23,7 +22,7 @@ class TaskElement {
|
|
|
23
22
|
constructor(fromFile, toFile, externalSourceMap) {
|
|
24
23
|
this.fromFile = commons_1.Contract.requireDefined(fromFile);
|
|
25
24
|
this.toFile = commons_1.Contract.requireDefined(toFile);
|
|
26
|
-
this.externalSourceMapFile =
|
|
25
|
+
this.externalSourceMapFile = externalSourceMap;
|
|
27
26
|
}
|
|
28
27
|
/**
|
|
29
28
|
* Is it an in-place instrumentation task?
|
package/dist/src/main.js
CHANGED
|
@@ -1,74 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
-
if (k2 === undefined) k2 = k;
|
|
5
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
-
}
|
|
9
|
-
Object.defineProperty(o, k2, desc);
|
|
10
|
-
}) : (function(o, m, k, k2) {
|
|
11
|
-
if (k2 === undefined) k2 = k;
|
|
12
|
-
o[k2] = m[k];
|
|
13
|
-
}));
|
|
14
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
-
}) : function(o, v) {
|
|
17
|
-
o["default"] = v;
|
|
18
|
-
});
|
|
19
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
-
var ownKeys = function(o) {
|
|
21
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
-
var ar = [];
|
|
23
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
-
return ar;
|
|
25
|
-
};
|
|
26
|
-
return ownKeys(o);
|
|
27
|
-
};
|
|
28
|
-
return function (mod) {
|
|
29
|
-
if (mod && mod.__esModule) return mod;
|
|
30
|
-
var result = {};
|
|
31
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
-
__setModuleDefault(result, mod);
|
|
33
|
-
return result;
|
|
34
|
-
};
|
|
35
|
-
})();
|
|
36
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
4
|
const App_1 = require("./App");
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
App_1.App.run()
|
|
42
|
-
.then(result => {
|
|
43
|
-
var _a, _b;
|
|
44
|
-
console.log('Instrumentation finished.');
|
|
45
|
-
console.log(`\tInstrumented: ${result.translated}`);
|
|
46
|
-
console.log(`\tExcluded: ${result.excluded}`);
|
|
47
|
-
console.log(`\tInstrumented from cache: ${result.translatedFromCache}`);
|
|
48
|
-
console.log(`\tAlready instrumented: ${result.alreadyInstrumented}`);
|
|
49
|
-
console.log(`\tUnsupported: ${result.unsupported}`);
|
|
50
|
-
console.log(`\tWith warning: ${result.warnings}`);
|
|
51
|
-
console.log(`\tFailed: ${result.failed}`);
|
|
52
|
-
if ((_a = result.task) === null || _a === void 0 ? void 0 : _a.originSourcePattern.patternsSpecified()) {
|
|
53
|
-
const stats = (_b = result.task) === null || _b === void 0 ? void 0 : _b.originSourcePattern.retrieveMatchingFiles();
|
|
54
|
-
console.log(`\tSource origin matches`);
|
|
55
|
-
console.log(`\t\tInclude patterns: [${stats.includePatterns}]`);
|
|
56
|
-
console.log(`\t\tExclude patterns: [${stats.excludePatterns}]`);
|
|
57
|
-
console.log(`\t\tInclude matches: ${stats.includeMatches.length}`);
|
|
58
|
-
console.log(`\t\tExclude matches: ${stats.excludeMatches.length}`);
|
|
59
|
-
console.log(`\t\tNeither matches: ${stats.neitherExcludedNorIncluded.length}`);
|
|
60
|
-
}
|
|
61
|
-
})
|
|
62
|
-
.catch(reason => {
|
|
63
|
-
if (reason instanceof commons_1.InvalidConfigurationException) {
|
|
64
|
-
// Do not print the stack trace for invalid configuration parameters from the user.
|
|
65
|
-
console.error(`Failed: ${reason.message}`);
|
|
66
|
-
}
|
|
67
|
-
else {
|
|
68
|
-
console.error('Failed: ', reason);
|
|
69
|
-
}
|
|
70
|
-
process.exit(1);
|
|
71
|
-
})
|
|
72
|
-
.finally(() => {
|
|
73
|
-
console.log('Bye bye.');
|
|
5
|
+
// Main function of the instrumenter
|
|
6
|
+
App_1.App.run().catch(reason => {
|
|
7
|
+
console.error(reason);
|
|
74
8
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teamscale/javascript-instrumenter",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.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",
|
|
@@ -11,38 +11,12 @@
|
|
|
11
11
|
"files": [
|
|
12
12
|
"dist/**/*"
|
|
13
13
|
],
|
|
14
|
-
"devDependencies": {
|
|
15
|
-
"@babel/core": "^7.26.8",
|
|
16
|
-
"@babel/plugin-transform-modules-commonjs": "^7.26.3",
|
|
17
|
-
"@babel/preset-env": "^7.26.8",
|
|
18
|
-
"@types/argparse": "^2.0.17",
|
|
19
|
-
"@types/async": "^3.2.24",
|
|
20
|
-
"@types/babel__generator": "^7.6.8",
|
|
21
|
-
"@types/babel__traverse": "^7.20.6",
|
|
22
|
-
"@types/bunyan": "^1.8.11",
|
|
23
|
-
"@types/convert-source-map": "^2.0.3",
|
|
24
|
-
"@types/glob": "^9.0.0",
|
|
25
|
-
"@types/jest": "^29.5.14",
|
|
26
|
-
"@types/node": "^22.13.4",
|
|
27
|
-
"@types/ws": "^8.5.14",
|
|
28
|
-
"@types/uuid": "^10.0.0",
|
|
29
|
-
"babel-jest": "^29.7.0",
|
|
30
|
-
"esbuild": "^0.25.0",
|
|
31
|
-
"esbuild-plugin-inline-worker": "^0.1.1",
|
|
32
|
-
"jest": "^29.7.0",
|
|
33
|
-
"rimraf": "^6.0.1",
|
|
34
|
-
"ts-jest": "^29.2.5",
|
|
35
|
-
"ts-node": "^10.9.2",
|
|
36
|
-
"tslib": "^2.8.1",
|
|
37
|
-
"typescript": "^5.7.3"
|
|
38
|
-
},
|
|
39
14
|
"dependencies": {
|
|
40
15
|
"@babel/generator": "^7.26.8",
|
|
41
16
|
"@babel/parser": "^7.26.8",
|
|
42
17
|
"@babel/traverse": "^7.26.8",
|
|
43
18
|
"@babel/types": "^7.26.8",
|
|
44
19
|
"@types/micromatch": "^4.0.9",
|
|
45
|
-
"argparse": "^2.0.1",
|
|
46
20
|
"async": "^3.2.6",
|
|
47
21
|
"bunyan": "^1.8.15",
|
|
48
22
|
"convert-source-map": "^2.0.0",
|
|
@@ -51,12 +25,11 @@
|
|
|
51
25
|
"micromatch": "4.0.8",
|
|
52
26
|
"mkdirp": "^3.0.1",
|
|
53
27
|
"source-map": "0.7.4",
|
|
54
|
-
"typescript-optional": "^2.0.1",
|
|
55
28
|
"unload": "^2.4.1",
|
|
56
29
|
"uuid": "^11.1.0",
|
|
57
30
|
"web-worker": "^1.5.0",
|
|
58
|
-
"@cqse/commons": "1.0.0-beta.
|
|
59
|
-
"@teamscale/lib-instrument": "1.0.0-beta.
|
|
31
|
+
"@cqse/commons": "1.0.0-beta.6",
|
|
32
|
+
"@teamscale/lib-instrument": "1.0.0-beta.6"
|
|
60
33
|
},
|
|
61
34
|
"publishConfig": {
|
|
62
35
|
"access": "public"
|