@teamscale/javascript-instrumenter 1.0.0-beta.7 → 1.0.5
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/main.mjs +216 -0
- package/package.json +18 -9
- package/dist/package.json +0 -63
- package/dist/src/App.d.ts +0 -16
- package/dist/src/App.d.ts.map +0 -1
- package/dist/src/App.js +0 -233
- package/dist/src/instrumenter/FileSystem.d.ts +0 -10
- package/dist/src/instrumenter/FileSystem.d.ts.map +0 -1
- package/dist/src/instrumenter/FileSystem.js +0 -104
- package/dist/src/instrumenter/Instrumenter.d.ts +0 -25
- package/dist/src/instrumenter/Instrumenter.d.ts.map +0 -1
- package/dist/src/instrumenter/Instrumenter.js +0 -292
- package/dist/src/instrumenter/InstrumenterConfig.d.ts +0 -28
- package/dist/src/instrumenter/InstrumenterConfig.d.ts.map +0 -1
- package/dist/src/instrumenter/InstrumenterConfig.js +0 -159
- package/dist/src/instrumenter/RelativeCollectorPatternParser.d.ts +0 -6
- package/dist/src/instrumenter/RelativeCollectorPatternParser.d.ts.map +0 -1
- package/dist/src/instrumenter/RelativeCollectorPatternParser.js +0 -53
- package/dist/src/instrumenter/RelativeCollectorPatternParser.test.d.ts +0 -2
- package/dist/src/instrumenter/RelativeCollectorPatternParser.test.d.ts.map +0 -1
- package/dist/src/instrumenter/RelativeCollectorPatternParser.test.js +0 -33
- package/dist/src/instrumenter/Task.d.ts +0 -80
- package/dist/src/instrumenter/Task.d.ts.map +0 -1
- package/dist/src/instrumenter/Task.js +0 -228
- package/dist/src/instrumenter/TaskBuilder.d.ts +0 -25
- package/dist/src/instrumenter/TaskBuilder.d.ts.map +0 -1
- package/dist/src/instrumenter/TaskBuilder.js +0 -181
- package/dist/src/instrumenter/WebToolkit.d.ts +0 -13
- package/dist/src/instrumenter/WebToolkit.d.ts.map +0 -1
- package/dist/src/instrumenter/WebToolkit.js +0 -119
- package/dist/src/main.d.ts +0 -3
- package/dist/src/main.d.ts.map +0 -1
- package/dist/src/main.js +0 -10
- package/dist/src/vaccine/types.d.ts +0 -28
- package/dist/src/vaccine/types.d.ts.map +0 -1
- package/dist/src/vaccine/types.js +0 -2
package/package.json
CHANGED
|
@@ -1,13 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teamscale/javascript-instrumenter",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"description": "JavaScript coverage instrumenter with coverage forwarding to a collector process",
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/main.mjs",
|
|
7
|
+
"bin": "dist/main.mjs",
|
|
8
8
|
"author": "CQSE GmbH",
|
|
9
9
|
"license": "Apache-2.0",
|
|
10
10
|
"homepage": "https://docs.teamscale.com/howto/setting-up-profiler-tga/javascript/",
|
|
11
|
+
"keywords": [
|
|
12
|
+
"javascript",
|
|
13
|
+
"coverage",
|
|
14
|
+
"test coverage",
|
|
15
|
+
"coverage profiler",
|
|
16
|
+
"testing",
|
|
17
|
+
"instrumenter",
|
|
18
|
+
"teamscale"
|
|
19
|
+
],
|
|
11
20
|
"files": [
|
|
12
21
|
"dist/**/*"
|
|
13
22
|
],
|
|
@@ -28,17 +37,17 @@
|
|
|
28
37
|
"unload": "^2.4.1",
|
|
29
38
|
"uuid": "^13.0.0",
|
|
30
39
|
"web-worker": "^1.5.0",
|
|
31
|
-
"@
|
|
32
|
-
"@
|
|
40
|
+
"@teamscale/lib-instrument": "1.0.5",
|
|
41
|
+
"@cqse/commons": "1.0.5"
|
|
33
42
|
},
|
|
34
43
|
"publishConfig": {
|
|
35
44
|
"access": "public"
|
|
36
45
|
},
|
|
37
46
|
"scripts": {
|
|
38
|
-
"clean": "rimraf dist
|
|
39
|
-
"build": "tsc --
|
|
47
|
+
"clean": "rimraf dist",
|
|
48
|
+
"build": "pnpm tsc --noEmit && pnpm tsdown && pnpm run buildVaccine",
|
|
40
49
|
"buildVaccine": "node esbuild.mjs",
|
|
41
|
-
"instrumenter": "node dist/
|
|
50
|
+
"instrumenter": "node dist/main.mjs",
|
|
42
51
|
"test": "node --import tsx --test test/**/*.test.ts"
|
|
43
52
|
}
|
|
44
53
|
}
|
package/dist/package.json
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@teamscale/javascript-instrumenter",
|
|
3
|
-
"version": "1.0.0-beta.7",
|
|
4
|
-
"description": "JavaScript coverage instrumenter with coverage forwarding to a collector process",
|
|
5
|
-
"main": "dist/src/main.js",
|
|
6
|
-
"bin": "dist/src/main.js",
|
|
7
|
-
"types": "dist/src/main.d.ts",
|
|
8
|
-
"author": "CQSE GmbH",
|
|
9
|
-
"license": "Apache-2.0",
|
|
10
|
-
"homepage": "https://docs.teamscale.com/howto/setting-up-profiler-tga/javascript/",
|
|
11
|
-
"scripts": {
|
|
12
|
-
"prepublishOnly": "pnpm clean && pnpm build",
|
|
13
|
-
"clean": "rimraf dist tsconfig.tsbuildinfo",
|
|
14
|
-
"build": "tsc --project tsconfig.json && pnpm buildVaccine",
|
|
15
|
-
"buildVaccine": "node esbuild.mjs",
|
|
16
|
-
"instrumenter": "node dist/src/main.js",
|
|
17
|
-
"test": "node --import tsx --test test/**/*.test.ts"
|
|
18
|
-
},
|
|
19
|
-
"files": [
|
|
20
|
-
"dist/**/*"
|
|
21
|
-
],
|
|
22
|
-
"devDependencies": {
|
|
23
|
-
"@babel/core": "^7.28.5",
|
|
24
|
-
"@babel/plugin-transform-modules-commonjs": "^7.27.1",
|
|
25
|
-
"@babel/preset-env": "^7.28.5",
|
|
26
|
-
"@types/async": "^3.2.25",
|
|
27
|
-
"@types/babel__generator": "^7.27.0",
|
|
28
|
-
"@types/babel__traverse": "^7.28.0",
|
|
29
|
-
"@types/bunyan": "^1.8.11",
|
|
30
|
-
"@types/convert-source-map": "^2.0.3",
|
|
31
|
-
"@types/node": "^22.18.12",
|
|
32
|
-
"@types/ws": "^8.18.1",
|
|
33
|
-
"esbuild": "^0.25.11",
|
|
34
|
-
"esbuild-plugin-inline-worker": "^0.1.1",
|
|
35
|
-
"rimraf": "^6.0.1",
|
|
36
|
-
"tslib": "^2.8.1",
|
|
37
|
-
"tsx": "^4.19.2",
|
|
38
|
-
"typescript": "^5.8.3"
|
|
39
|
-
},
|
|
40
|
-
"dependencies": {
|
|
41
|
-
"@babel/generator": "^7.28.5",
|
|
42
|
-
"@babel/parser": "^7.28.5",
|
|
43
|
-
"@babel/traverse": "^7.28.5",
|
|
44
|
-
"@babel/types": "^7.28.5",
|
|
45
|
-
"@cqse/commons": "workspace:../cqse-commons",
|
|
46
|
-
"@teamscale/lib-instrument": "workspace:../lib-instrument",
|
|
47
|
-
"@types/micromatch": "^4.0.10",
|
|
48
|
-
"async": "^3.2.6",
|
|
49
|
-
"bunyan": "^1.8.15",
|
|
50
|
-
"convert-source-map": "^2.0.0",
|
|
51
|
-
"foreground-child": "^3.3.1",
|
|
52
|
-
"micromatch": "4.0.8",
|
|
53
|
-
"mkdirp": "^3.0.1",
|
|
54
|
-
"source-map": "0.7.6",
|
|
55
|
-
"tinyglobby": "^0.2.15",
|
|
56
|
-
"unload": "^2.4.1",
|
|
57
|
-
"uuid": "^13.0.0",
|
|
58
|
-
"web-worker": "^1.5.0"
|
|
59
|
-
},
|
|
60
|
-
"publishConfig": {
|
|
61
|
-
"access": "public"
|
|
62
|
-
}
|
|
63
|
-
}
|
package/dist/src/App.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { TaskResult } from './instrumenter/Task';
|
|
2
|
-
import Logger from 'bunyan';
|
|
3
|
-
import { InstrumenterOptions } from './instrumenter/InstrumenterConfig';
|
|
4
|
-
export declare class App {
|
|
5
|
-
static run(): Promise<TaskResult>;
|
|
6
|
-
static runForArgv(argv: string[]): Promise<TaskResult>;
|
|
7
|
-
static parseCommandLine(args?: string[], beforeArgumentCheckCallback?: (options: InstrumenterOptions) => void): InstrumenterOptions;
|
|
8
|
-
static postprocessConfig(config: InstrumenterOptions): void;
|
|
9
|
-
private static buildLogger;
|
|
10
|
-
private static buildDummyLogger;
|
|
11
|
-
static runForConfigArguments(config: InstrumenterOptions, logger?: Logger): Promise<TaskResult>;
|
|
12
|
-
private static createInstrumentationTask;
|
|
13
|
-
private static createInstrumenter;
|
|
14
|
-
private static finalizeAppRunWithConsoleOutputs;
|
|
15
|
-
}
|
|
16
|
-
//# sourceMappingURL=App.d.ts.map
|
package/dist/src/App.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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;AAMlH,qBAAa,GAAG;WAKK,GAAG,IAAI,OAAO,CAAC,UAAU,CAAC;WAO1B,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC;WAkCrD,gBAAgB,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,2BAA2B,CAAC,EAAE,CAAC,OAAO,EAAE,mBAAmB,KAAK,IAAI,GAAG,mBAAmB;WAU5H,iBAAiB,CAAC,MAAM,EAAE,mBAAmB,GAAG,IAAI;IA2ClE,OAAO,CAAC,MAAM,CAAC,WAAW;IAkC1B,OAAO,CAAC,MAAM,CAAC,gBAAgB;WAUjB,qBAAqB,CAAC,MAAM,EAAE,mBAAmB,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAqCtG,OAAO,CAAC,MAAM,CAAC,yBAAyB;IAIxC,OAAO,CAAC,MAAM,CAAC,kBAAkB;mBAiBZ,gCAAgC;CAmDrD"}
|
package/dist/src/App.js
DELETED
|
@@ -1,233 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
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);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.App = void 0;
|
|
40
|
-
const Instrumenter_1 = require("./instrumenter/Instrumenter");
|
|
41
|
-
const commons_1 = require("@cqse/commons");
|
|
42
|
-
const TaskBuilder_1 = require("./instrumenter/TaskBuilder");
|
|
43
|
-
const path = __importStar(require("path"));
|
|
44
|
-
const package_json_1 = require("../package.json");
|
|
45
|
-
const fs_1 = require("fs");
|
|
46
|
-
const mkdirp_1 = require("mkdirp");
|
|
47
|
-
const bunyan_1 = __importDefault(require("bunyan"));
|
|
48
|
-
const InstrumenterConfig_1 = require("./instrumenter/InstrumenterConfig");
|
|
49
|
-
const process = __importStar(require("node:process"));
|
|
50
|
-
class App {
|
|
51
|
-
static async run() {
|
|
52
|
-
return this.runForArgv(process.argv);
|
|
53
|
-
}
|
|
54
|
-
static async runForArgv(argv) {
|
|
55
|
-
const config = this.parseCommandLine(argv.slice(2), options => {
|
|
56
|
-
if (options.collectorOptionsList) {
|
|
57
|
-
const collectorParameters = (0, commons_1.buildReconfigurableCollectorParameters)();
|
|
58
|
-
(0, commons_1.printHelp)(collectorParameters, undefined, true);
|
|
59
|
-
console.log("");
|
|
60
|
-
console.log("ATTENTION:\n" +
|
|
61
|
-
"When specifying credentials of Teamscale or other services via --collector-config-file or --collector-option,\n" +
|
|
62
|
-
"the credentials will be included in the instrumented source code and are thus visible\n" +
|
|
63
|
-
"to anyone that can access your deployed application.\n" +
|
|
64
|
-
"We recommend you instead give these credentials to the collector directly when launching it.\n");
|
|
65
|
-
process.exit(0);
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
const logger = this.buildLogger(config);
|
|
69
|
-
logger.trace('Retrieved arguments', process.argv);
|
|
70
|
-
logger.trace('Translated arguments to config', config);
|
|
71
|
-
return this.runForConfigArguments(config, logger);
|
|
72
|
-
}
|
|
73
|
-
static parseCommandLine(args, beforeArgumentCheckCallback) {
|
|
74
|
-
const configParameters = (0, InstrumenterConfig_1.buildInstrumenterConfigurationParameters)();
|
|
75
|
-
const appInfos = { about: package_json_1.description, version: package_json_1.version, name: package_json_1.name };
|
|
76
|
-
return (0, commons_1.processCommandLine)(configParameters, appInfos, args, beforeArgumentCheckCallback);
|
|
77
|
-
}
|
|
78
|
-
static postprocessConfig(config) {
|
|
79
|
-
function unquoteString(originalString) {
|
|
80
|
-
if (originalString === undefined) {
|
|
81
|
-
return originalString;
|
|
82
|
-
}
|
|
83
|
-
const result = originalString.replace(/^["'](.+(?=["']$))["']$/, '$1');
|
|
84
|
-
if (result === originalString) {
|
|
85
|
-
return result;
|
|
86
|
-
}
|
|
87
|
-
else {
|
|
88
|
-
return unquoteString(result);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
function unquoteStringElements(originalArray) {
|
|
92
|
-
if (originalArray === undefined) {
|
|
93
|
-
return undefined;
|
|
94
|
-
}
|
|
95
|
-
return originalArray.map(s => {
|
|
96
|
-
if (typeof s === 'string') {
|
|
97
|
-
return unquoteString(s);
|
|
98
|
-
}
|
|
99
|
-
else {
|
|
100
|
-
return s;
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
for (const [property, value] of Object.entries(config)) {
|
|
105
|
-
if (value === undefined) {
|
|
106
|
-
}
|
|
107
|
-
else if (typeof value === 'string') {
|
|
108
|
-
config[property] = unquoteString(value);
|
|
109
|
-
}
|
|
110
|
-
else if (Array.isArray(value)) {
|
|
111
|
-
config[property] = unquoteStringElements(value);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
static buildLogger(config) {
|
|
116
|
-
const logfilePath = 'logs/instrumenter.log';
|
|
117
|
-
mkdirp_1.mkdirp.sync(path.dirname(logfilePath));
|
|
118
|
-
const logLevel = config.logLevel ?? 'info';
|
|
119
|
-
return bunyan_1.default.createLogger({
|
|
120
|
-
name: 'Instrumenter',
|
|
121
|
-
streams: [
|
|
122
|
-
{
|
|
123
|
-
level: logLevel,
|
|
124
|
-
stream: {
|
|
125
|
-
write: (rec) => {
|
|
126
|
-
console.log('[%s] %s: %s', rec.time.toISOString(), bunyan_1.default.nameFromLevel[rec.level], rec.msg);
|
|
127
|
-
}
|
|
128
|
-
},
|
|
129
|
-
type: 'raw'
|
|
130
|
-
},
|
|
131
|
-
{
|
|
132
|
-
level: logLevel,
|
|
133
|
-
path: logfilePath
|
|
134
|
-
}
|
|
135
|
-
]
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
static buildDummyLogger() {
|
|
139
|
-
return bunyan_1.default.createLogger({ name: 'Instrumenter' });
|
|
140
|
-
}
|
|
141
|
-
static runForConfigArguments(config, logger) {
|
|
142
|
-
this.postprocessConfig(config);
|
|
143
|
-
if (config.collectorConfigFile) {
|
|
144
|
-
if (!(0, fs_1.existsSync)(config.collectorConfigFile)) {
|
|
145
|
-
throw new commons_1.InvalidConfigurationException(`The specified collector configuration file '${config.collectorConfigFile}' does not exist.`);
|
|
146
|
-
}
|
|
147
|
-
config.collectorConfigFileContent = (0, fs_1.readFileSync)(config.collectorConfigFile, 'utf8');
|
|
148
|
-
}
|
|
149
|
-
if (Array.isArray(config.collectorOption)) {
|
|
150
|
-
if (!config.collectorConfigFileContent) {
|
|
151
|
-
config.collectorConfigFileContent = "";
|
|
152
|
-
}
|
|
153
|
-
config.collectorConfigFileContent += `\n${config.collectorOption.join("\n")}`;
|
|
154
|
-
}
|
|
155
|
-
if (config.collectorConfigFileContent) {
|
|
156
|
-
try {
|
|
157
|
-
const collectorParameters = (0, commons_1.buildReconfigurableCollectorParameters)();
|
|
158
|
-
const { options } = (0, commons_1.parseConfigFile)(config.collectorConfigFileContent, collectorParameters);
|
|
159
|
-
if (!(0, commons_1.checkArguments)(collectorParameters, options)) {
|
|
160
|
-
throw new commons_1.InvalidConfigurationException(`Not all required configuration options are specified correctly.`);
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
catch (e) {
|
|
164
|
-
throw new commons_1.InvalidConfigurationException(`The specified collector configuration is invalid: ${e.message}`);
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
const task = this.createInstrumentationTask(config);
|
|
168
|
-
commons_1.Contract.require(task.elements.length > 0, 'The instrumentation task must not be empty.');
|
|
169
|
-
const instrumentationResult = this.createInstrumenter(logger ?? this.buildDummyLogger(), task.collector, task.targetBucket).instrument(task);
|
|
170
|
-
return App.finalizeAppRunWithConsoleOutputs(instrumentationResult);
|
|
171
|
-
}
|
|
172
|
-
static createInstrumentationTask(config) {
|
|
173
|
-
return new TaskBuilder_1.TaskBuilder().addFromConfig(config).build();
|
|
174
|
-
}
|
|
175
|
-
static createInstrumenter(logger, collector, targetBucket) {
|
|
176
|
-
const pathVariant1 = path.join(__dirname, '../vaccine.js');
|
|
177
|
-
const pathVariant2 = path.join(__dirname, '../dist/vaccine.js');
|
|
178
|
-
if ((0, fs_1.existsSync)(pathVariant1)) {
|
|
179
|
-
return new Instrumenter_1.IstanbulInstrumenter(pathVariant1, logger, collector, targetBucket);
|
|
180
|
-
}
|
|
181
|
-
else {
|
|
182
|
-
return new Instrumenter_1.IstanbulInstrumenter(pathVariant2, logger, collector, targetBucket);
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
static async finalizeAppRunWithConsoleOutputs(resultPromise) {
|
|
186
|
-
try {
|
|
187
|
-
const result = await resultPromise;
|
|
188
|
-
console.log('Instrumentation finished.');
|
|
189
|
-
console.log(`\tInstrumented: ${result.translated}`);
|
|
190
|
-
console.log(`\tExcluded: ${result.excluded}`);
|
|
191
|
-
console.log(`\tInstrumented from cache: ${result.translatedFromCache}`);
|
|
192
|
-
console.log(`\tAlready instrumented: ${result.alreadyInstrumented}`);
|
|
193
|
-
console.log(`\tUnsupported: ${result.unsupported}`);
|
|
194
|
-
console.log(`\tWith warning: ${result.warnings}`);
|
|
195
|
-
console.log(`\tFailed: ${result.failed}`);
|
|
196
|
-
if (result.task?.originSourcePattern.patternsSpecified()) {
|
|
197
|
-
const stats = result.task?.originSourcePattern.retrieveMatchingFiles();
|
|
198
|
-
console.log(`\tSource origin matches`);
|
|
199
|
-
console.log(`\t\tInclude patterns: [${stats.includePatterns}]`);
|
|
200
|
-
console.log(`\t\tExclude patterns: [${stats.excludePatterns}]`);
|
|
201
|
-
console.log(`\t\tInclude matches: ${stats.includeMatches.length}`);
|
|
202
|
-
console.log(`\t\tExclude matches: ${stats.excludeMatches.length}`);
|
|
203
|
-
console.log(`\t\tNeither matches: ${stats.neitherExcludedNorIncluded.length}`);
|
|
204
|
-
if (stats.includeMatches.length === 0 && stats.excludeMatches.length === 0) {
|
|
205
|
-
console.error('\nWARNING: Specified include/exclude patterns are expected to match at least once. ' +
|
|
206
|
-
'None matched for this instrumenter invocation.\n');
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
if (result.translated === 0 && result.translatedFromCache === 0 && result.alreadyInstrumented === 0) {
|
|
210
|
-
console.error('\nWARNING: Each invocation of the JavaScript Instrumenter is supposed to match at \n' +
|
|
211
|
-
'least one file to instrument; no file was matched for instrumentation in this invocation. \n' +
|
|
212
|
-
'Please check the list of input files and the include/exclude patterns.\n');
|
|
213
|
-
}
|
|
214
|
-
if (result.failed > 0) {
|
|
215
|
-
console.error('FAILURE: The instrumentation failed for some files. Please check the log for details.\n');
|
|
216
|
-
}
|
|
217
|
-
return result;
|
|
218
|
-
}
|
|
219
|
-
catch (reason) {
|
|
220
|
-
if (reason instanceof commons_1.InvalidConfigurationException) {
|
|
221
|
-
console.error(`Failed: ${reason.message}`);
|
|
222
|
-
}
|
|
223
|
-
else {
|
|
224
|
-
console.error('Failed: ', reason);
|
|
225
|
-
}
|
|
226
|
-
process.exit(1);
|
|
227
|
-
}
|
|
228
|
-
finally {
|
|
229
|
-
console.log('Bye bye.');
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
exports.App = App;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { RawSourceMap } from 'source-map';
|
|
2
|
-
export declare function isExistingFile(path: string): boolean;
|
|
3
|
-
export declare function isExistingDirectory(path: string): boolean;
|
|
4
|
-
export declare function ensureExistingDirectory(path: string): void;
|
|
5
|
-
export declare function findSubFolders(startFromFolder: string, folderName: string): string[];
|
|
6
|
-
export declare function isDirectoryEmpty(path: string): boolean;
|
|
7
|
-
export declare function expandToFileSet(toExpand: string): string[];
|
|
8
|
-
export declare function sourceMapFromMapFile(mapFilePath: string): RawSourceMap | undefined;
|
|
9
|
-
export declare function replaceNonFilesystemCharacters(name: string): string;
|
|
10
|
-
//# sourceMappingURL=FileSystem.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FileSystem.d.ts","sourceRoot":"","sources":["../../../src/instrumenter/FileSystem.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAM1C,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEpD;AAKD,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEzD;AAKD,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAU1D;AAKD,wBAAgB,cAAc,CAAC,eAAe,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE,CAgBpF;AAKD,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEtD;AAOD,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,CAc1D;AAOD,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS,CAGlF;AAKD,wBAAgB,8BAA8B,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAKnE"}
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
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);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.isExistingFile = isExistingFile;
|
|
40
|
-
exports.isExistingDirectory = isExistingDirectory;
|
|
41
|
-
exports.ensureExistingDirectory = ensureExistingDirectory;
|
|
42
|
-
exports.findSubFolders = findSubFolders;
|
|
43
|
-
exports.isDirectoryEmpty = isDirectoryEmpty;
|
|
44
|
-
exports.expandToFileSet = expandToFileSet;
|
|
45
|
-
exports.sourceMapFromMapFile = sourceMapFromMapFile;
|
|
46
|
-
exports.replaceNonFilesystemCharacters = replaceNonFilesystemCharacters;
|
|
47
|
-
const commons_1 = require("@cqse/commons");
|
|
48
|
-
const fs = __importStar(require("fs"));
|
|
49
|
-
const mkdirp = __importStar(require("mkdirp"));
|
|
50
|
-
const path_1 = __importDefault(require("path"));
|
|
51
|
-
const tinyglobby_1 = require("tinyglobby");
|
|
52
|
-
function isExistingFile(path) {
|
|
53
|
-
return fs.existsSync(path) && fs.lstatSync(path).isFile();
|
|
54
|
-
}
|
|
55
|
-
function isExistingDirectory(path) {
|
|
56
|
-
return fs.existsSync(path) && fs.lstatSync(path).isDirectory();
|
|
57
|
-
}
|
|
58
|
-
function ensureExistingDirectory(path) {
|
|
59
|
-
if (!fs.existsSync(path)) {
|
|
60
|
-
mkdirp.sync(path);
|
|
61
|
-
}
|
|
62
|
-
if (!fs.lstatSync(path).isDirectory()) {
|
|
63
|
-
throw new commons_1.InvalidConfigurationException(`The specified path '${path}' does not point to an existing directory!`);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
function findSubFolders(startFromFolder, folderName) {
|
|
67
|
-
const matches = [];
|
|
68
|
-
const entries = fs.readdirSync(startFromFolder, { withFileTypes: true });
|
|
69
|
-
for (const entry of entries) {
|
|
70
|
-
const fullPath = path_1.default.join(startFromFolder, entry.name);
|
|
71
|
-
if (entry.name === folderName && entry.isDirectory()) {
|
|
72
|
-
matches.push(fullPath);
|
|
73
|
-
}
|
|
74
|
-
if (entry.isDirectory()) {
|
|
75
|
-
const nestedMatches = findSubFolders(fullPath, folderName);
|
|
76
|
-
matches.push(...nestedMatches);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
return matches;
|
|
80
|
-
}
|
|
81
|
-
function isDirectoryEmpty(path) {
|
|
82
|
-
return !isExistingDirectory(path) || fs.readdirSync(path).length > 0;
|
|
83
|
-
}
|
|
84
|
-
function expandToFileSet(toExpand) {
|
|
85
|
-
let globPattern = toExpand;
|
|
86
|
-
if (fs.existsSync(toExpand)) {
|
|
87
|
-
const stat = fs.lstatSync(toExpand, {});
|
|
88
|
-
if (stat.isFile()) {
|
|
89
|
-
return [toExpand];
|
|
90
|
-
}
|
|
91
|
-
if (stat.isDirectory()) {
|
|
92
|
-
globPattern = `${toExpand}${path_1.default.sep}**`;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
return (0, tinyglobby_1.globSync)(globPattern, { onlyFiles: true });
|
|
96
|
-
}
|
|
97
|
-
function sourceMapFromMapFile(mapFilePath) {
|
|
98
|
-
const content = fs.readFileSync(mapFilePath, 'utf8');
|
|
99
|
-
return JSON.parse(content);
|
|
100
|
-
}
|
|
101
|
-
function replaceNonFilesystemCharacters(name) {
|
|
102
|
-
const result = name.replace(/[^a-zA-Z0-9_\-.\\/]/g, '_');
|
|
103
|
-
return result.replace(/_+/g, '_');
|
|
104
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { FileExcludePattern, InstrumentationTask, OriginSourcePattern, SourceMapReference, TaskElement, TaskResult } from './Task';
|
|
2
|
-
import { RawSourceMap } from 'source-map';
|
|
3
|
-
import Logger from 'bunyan';
|
|
4
|
-
import { CollectorSpecifier, CoverageBucketSpecifier } from '../vaccine/types';
|
|
5
|
-
export declare const IS_INSTRUMENTED_TOKEN = "$IS_JS_PROFILER_INSTRUMENTED=true";
|
|
6
|
-
export interface IInstrumenter {
|
|
7
|
-
instrument(task: InstrumentationTask): Promise<TaskResult>;
|
|
8
|
-
}
|
|
9
|
-
export declare class IstanbulInstrumenter implements IInstrumenter {
|
|
10
|
-
private readonly vaccineSource;
|
|
11
|
-
private logger;
|
|
12
|
-
constructor(vaccineFilePath: string, logger: Logger, collector: CollectorSpecifier, targetBucket: CoverageBucketSpecifier);
|
|
13
|
-
instrument(task: InstrumentationTask): Promise<TaskResult>;
|
|
14
|
-
instrumentOne(taskElement: TaskElement, excludeBundles: FileExcludePattern, sourcePattern: OriginSourcePattern, dumpOriginsFile: string | undefined): Promise<TaskResult>;
|
|
15
|
-
private instrumentBundle;
|
|
16
|
-
private writeBundleFile;
|
|
17
|
-
private loadVaccine;
|
|
18
|
-
private isFileTypeSupported;
|
|
19
|
-
private configurationAlternativesFor;
|
|
20
|
-
private clearFile;
|
|
21
|
-
private dumpToJson;
|
|
22
|
-
}
|
|
23
|
-
export declare function loadInputSourceMap(inputSource: string, taskFile: string, externalSourceMapFile?: SourceMapReference): RawSourceMap | undefined;
|
|
24
|
-
export declare function sourceMapFromCodeComment(sourcecode: string, sourceFilePath: string): RawSourceMap | undefined;
|
|
25
|
-
//# sourceMappingURL=Instrumenter.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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,MAAM,YAAY,CAAC;AAM1C,OAAO,MAAM,MAAM,QAAQ,CAAC;AAO5B,OAAO,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAE/E,eAAO,MAAM,qBAAqB,sCAAsC,CAAC;AAKzE,MAAM,WAAW,aAAa;IAM7B,UAAU,CAAC,IAAI,EAAE,mBAAmB,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;CAC3D;AA6BD,qBAAa,oBAAqB,YAAW,aAAa;IAMzD,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAS;IAKvC,OAAO,CAAC,MAAM,CAAS;gBAEX,eAAe,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,kBAAkB,EAAE,YAAY,EAAE,uBAAuB;IAanH,UAAU,CAAC,IAAI,EAAE,mBAAmB,GAAG,OAAO,CAAC,UAAU,CAAC;IAmC1D,aAAa,CAClB,WAAW,EAAE,WAAW,EACxB,cAAc,EAAE,kBAAkB,EAClC,aAAa,EAAE,mBAAmB,EAClC,eAAe,EAAE,MAAM,GAAG,SAAS,GACjC,OAAO,CAAC,UAAU,CAAC;YAsER,gBAAgB;IA8C9B,OAAO,CAAC,eAAe;IAiCvB,OAAO,CAAC,WAAW;IAWnB,OAAO,CAAC,mBAAmB;IAa3B,OAAO,CAAC,4BAA4B;IAkBpC,OAAO,CAAC,SAAS;IAWjB,OAAO,CAAC,UAAU;CAYlB;AA6BD,wBAAgB,kBAAkB,CACjC,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,MAAM,EAChB,qBAAqB,CAAC,EAAE,kBAAkB,GACxC,YAAY,GAAG,SAAS,CAU1B;AAQD,wBAAgB,wBAAwB,CAAC,UAAU,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS,CAwC7G"}
|