@teamscale/javascript-instrumenter 0.1.0-beta.2 → 0.1.0-beta.4

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 CHANGED
@@ -27,10 +27,10 @@ pnpm build
27
27
 
28
28
  ## Workflow Integration
29
29
 
30
- There are several options to run the Instrumenter. For example, via `yarn` by running
30
+ There are several options to run the Instrumenter. For example, via `pnpm` by running
31
31
 
32
32
  ```
33
- yarn instrumenter
33
+ pnpm instrumenter
34
34
  ```
35
35
 
36
36
  or via `npx` by running
@@ -39,8 +39,3 @@ or via `npx` by running
39
39
  npx @teamscale/javascript-instrumenter
40
40
  ```
41
41
 
42
- ## Limitations
43
-
44
- This tool inherits most of the limitations of IstanbulJs, including
45
- a considerable performance impact.
46
-
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teamscale/javascript-instrumenter",
3
- "version": "0.1.0-beta.2",
3
+ "version": "0.1.0-beta.4",
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,40 +23,40 @@
23
23
  "dist/**/*"
24
24
  ],
25
25
  "devDependencies": {
26
- "@babel/core": "^7.23.2",
27
- "@babel/plugin-transform-modules-commonjs": "^7.23.0",
28
- "@babel/preset-env": "^7.23.2",
29
- "@types/argparse": "^2.0.12",
30
- "@types/async": "^3.2.22",
31
- "@types/babel__generator": "^7.6.6",
32
- "@types/babel__traverse": "^7.20.3",
33
- "@types/bunyan": "^1.8.10",
34
- "@types/convert-source-map": "^2.0.2",
26
+ "@babel/core": "^7.23.7",
27
+ "@babel/plugin-transform-modules-commonjs": "^7.23.3",
28
+ "@babel/preset-env": "^7.23.8",
29
+ "@types/argparse": "^2.0.14",
30
+ "@types/async": "^3.2.24",
31
+ "@types/babel__generator": "^7.6.8",
32
+ "@types/babel__traverse": "^7.20.5",
33
+ "@types/bunyan": "^1.8.11",
34
+ "@types/convert-source-map": "^2.0.3",
35
35
  "@types/glob": "^8.1.0",
36
- "@types/istanbul-lib-instrument": "^1.7.6",
37
- "@types/jest": "^29.5.6",
38
- "@types/node": "^20.8.6",
39
- "@types/ws": "^8.5.7",
36
+ "@types/istanbul-lib-instrument": "^1.7.7",
37
+ "@types/jest": "^29.5.11",
38
+ "@types/node": "^20.11.0",
39
+ "@types/ws": "^8.5.10",
40
40
  "babel-jest": "^29.7.0",
41
- "esbuild": "^0.19.5",
41
+ "esbuild": "^0.19.11",
42
42
  "esbuild-plugin-inline-worker": "^0.1.1",
43
43
  "jest": "^29.7.0",
44
44
  "rimraf": "^5.0.5",
45
45
  "ts-jest": "^29.1.1",
46
- "ts-node": "^10.9.1",
46
+ "ts-node": "^10.9.2",
47
47
  "tslib": "^2.6.2",
48
- "typescript": "^5.2.2"
48
+ "typescript": "^5.3.3"
49
49
  },
50
50
  "dependencies": {
51
- "@cqse/commons": "0.0.1-beta.59",
51
+ "@cqse/commons": "0.1.0-beta.2",
52
52
  "@teamscale/lib-instrument": "workspace:../lib-instrument",
53
- "@babel/generator": "^7.23.0",
54
- "@babel/parser": "^7.23.0",
55
- "@babel/traverse": "^7.23.2",
56
- "@babel/types": "^7.23.0",
57
- "@types/micromatch": "^4.0.3",
53
+ "@babel/generator": "^7.23.6",
54
+ "@babel/parser": "^7.23.6",
55
+ "@babel/traverse": "^7.23.7",
56
+ "@babel/types": "^7.23.6",
57
+ "@types/micromatch": "^4.0.6",
58
58
  "argparse": "^2.0.1",
59
- "async": "^3.2.4",
59
+ "async": "^3.2.5",
60
60
  "bunyan": "^1.8.15",
61
61
  "convert-source-map": "^2.0.0",
62
62
  "foreground-child": "^3.1.1",
@@ -66,7 +66,7 @@
66
66
  "source-map": "0.7.4",
67
67
  "typescript-optional": "^2.0.1",
68
68
  "unload": "^2.4.1",
69
- "web-worker": "^1.2.0"
69
+ "web-worker": "^1.3.0"
70
70
  },
71
71
  "publishConfig": {
72
72
  "access": "public"
@@ -1 +1 @@
1
- {"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../../src/App.ts"],"names":[],"mappings":"AACA,OAAO,EAA0C,UAAU,EAAC,MAAM,qBAAqB,CAAC;AAGxF,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;IAwCtE;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,WAAW;IAyC1B;;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"}
1
+ {"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../../src/App.ts"],"names":[],"mappings":"AACA,OAAO,EAA0C,UAAU,EAAC,MAAM,qBAAqB,CAAC;AAGxF,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;IAwCtE;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,WAAW;IA4C1B;;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
@@ -136,7 +136,10 @@ class App {
136
136
  help: 'Glob pattern(s) of input (bundle) files to keep unchanged (to not instrument).'
137
137
  });
138
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'
139
+ help: 'Path specifying where to dump source origins file names, based on the source maps, as a JSON file.'
140
+ });
141
+ parser.add_argument('-m', '--dump-origin-matches-to', {
142
+ help: 'Path specifying where to dump a JSON with the names of the files that have matched the origin include/exclude patterns.'
140
143
  });
141
144
  parser.add_argument('inputs', { nargs: '+', help: 'The input file(s) to instrument.' });
142
145
  return parser;
@@ -60,10 +60,10 @@ export declare class IstanbulInstrumenter implements IInstrumenter {
60
60
  * given task element.
61
61
  */
62
62
  private configurationAlternativesFor;
63
- /** Appends all origins from the source map to a given file. Creates the file if it does not exist yet. */
64
- private dumpOrigins;
65
- /** Clears the dump origins file if it exists, such that it is now ready to be appended for every instrumented file. */
66
- private clearDumpOriginsFileIfNeeded;
63
+ /** Deletes the file if it exists, such that it is now ready to be appended. */
64
+ private clearFile;
65
+ /** Write the contents of the given object into the given file, if provided. */
66
+ private dumpToJson;
67
67
  }
68
68
  /**
69
69
  * Extract the sourcemap from the given source code.
@@ -1 +1 @@
1
- {"version":3,"file":"Instrumenter.d.ts","sourceRoot":"","sources":["../../../src/instrumenter/Instrumenter.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,kBAAkB,EAClB,kBAAkB,EAElB,mBAAmB,EACnB,mBAAmB,EAEnB,kBAAkB,EAElB,WAAW,EACX,UAAU,EACV,MAAM,QAAQ,CAAC;A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AClC,eAAe,EAAE,MAAM,GAAG,SAAS,GACjC,OAAO,CAAC,UAAU,CAAC;YAsER,gBAAgB;IA8C9B,OAAO,CAAC,eAAe;IA0BvB;;;;OAIG;IACH,OAAO,CAAC,WAAW;IAMnB;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAS3B;;;OAGG;IACH,OAAO,CAAC,4BAA4B;IAgBpC,+EAA+E;IAC/E,OAAO,CAAC,SAAS;IAUjB,+EAA+E;IAC/E,OAAO,CAAC,UAAU;CAYlB;AAED;;;;;GAKG;AACH,wBAAsB,aAAa,CAClC,kBAAkB,EAAE,MAAM,EAC1B,0BAA0B,EAAE,MAAM,GAChC,OAAO,CAAC,iBAAiB,GAAG,SAAS,CAAC,CAUxC;AAsBD;;;;;;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,CAwC7G"}
@@ -75,18 +75,22 @@ class IstanbulInstrumenter {
75
75
  * {@inheritDoc #IInstrumenter.instrument}
76
76
  */
77
77
  async instrument(task) {
78
- this.clearDumpOriginsFileIfNeeded(task.dumpOriginsFile);
78
+ this.clearFile(task.dumpOriginsFile);
79
+ this.clearFile(task.dumpMatchedOriginsFile);
79
80
  // We limit the number of instrumentations in parallel to one to
80
81
  // not overuse memory (NodeJS has only limited mem to use).
81
- return async_1.default
82
+ const result = await async_1.default
82
83
  .mapLimit(task.elements, 1, async (taskElement) => {
83
84
  return await this.instrumentOne(taskElement, task.excludeFilesPattern, task.originSourcePattern, task.dumpOriginsFile);
84
85
  })
85
86
  .then(results => {
86
87
  return results.reduce((prev, curr) => {
87
88
  return prev.withIncrement(curr);
88
- }, Task_1.TaskResult.neutral());
89
+ }, Task_1.TaskResult.neutral(task));
89
90
  });
91
+ // Write the matching statistics to a JSON
92
+ this.dumpToJson(task.dumpMatchedOriginsFile, task.originSourcePattern.retrieveMatchingFiles());
93
+ return result;
90
94
  }
91
95
  /**
92
96
  * Perform the instrumentation for one given task element (file to instrument).
@@ -157,7 +161,7 @@ class IstanbulInstrumenter {
157
161
  for (const inputSourceMap of inputSourceMaps.filter(map => map)) {
158
162
  const originSourceFiles = (_a = inputSourceMap === null || inputSourceMap === void 0 ? void 0 : inputSourceMap.sources) !== null && _a !== void 0 ? _a : [];
159
163
  if (dumpOriginsFile) {
160
- this.dumpOrigins(dumpOriginsFile, originSourceFiles);
164
+ this.dumpToJson(dumpOriginsFile, originSourceFiles);
161
165
  }
162
166
  }
163
167
  // The main instrumentation (adding coverage statements) is performed now:
@@ -222,33 +226,37 @@ class IstanbulInstrumenter {
222
226
  const baseConfig = {
223
227
  isInstrumentedToken: exports.IS_INSTRUMENTED_TOKEN,
224
228
  produceSourceMap: 'external',
225
- codeToPrepend: this.vaccineSource
229
+ codeToPrepend: this.vaccineSource,
230
+ compact: false // Would lead to `code generator has deoptimised the styling of` errors otherwise
226
231
  };
227
232
  return [
228
233
  { ...baseConfig, ...{ esModules: true } },
229
234
  { ...baseConfig, ...{ esModules: false } }
230
235
  ];
231
236
  }
232
- /** Appends all origins from the source map to a given file. Creates the file if it does not exist yet. */
233
- dumpOrigins(dumpOriginsFile, originSourceFiles) {
234
- const jsonContent = JSON.stringify(originSourceFiles, null, 2);
235
- fs.writeFile(dumpOriginsFile, jsonContent + '\n', { flag: 'a' }, error => {
236
- if (error) {
237
- this.logger.warn('Could not dump origins file');
238
- }
239
- });
240
- }
241
- /** Clears the dump origins file if it exists, such that it is now ready to be appended for every instrumented file. */
242
- clearDumpOriginsFileIfNeeded(dumpOriginsFile) {
243
- if (dumpOriginsFile && fs.existsSync(dumpOriginsFile)) {
237
+ /** Deletes the file if it exists, such that it is now ready to be appended. */
238
+ clearFile(filePath) {
239
+ if (filePath && fs.existsSync(filePath)) {
244
240
  try {
245
- fs.unlinkSync(dumpOriginsFile);
241
+ fs.unlinkSync(filePath);
246
242
  }
247
243
  catch (err) {
248
- this.logger.warn('Could not clear origins file: ' + err);
244
+ this.logger.warn(`Could not clear file ${filePath}:` + err);
249
245
  }
250
246
  }
251
247
  }
248
+ /** Write the contents of the given object into the given file, if provided. */
249
+ dumpToJson(targetFilePath, toDump) {
250
+ if (!targetFilePath) {
251
+ return;
252
+ }
253
+ const jsonContent = JSON.stringify(toDump, null, 2);
254
+ fs.writeFile(targetFilePath, jsonContent + '\n', { flag: 'a' }, error => {
255
+ if (error) {
256
+ this.logger.warn(`Could not dump JSON to file ${targetFilePath}:` + error.message);
257
+ }
258
+ });
259
+ }
252
260
  }
253
261
  exports.IstanbulInstrumenter = IstanbulInstrumenter;
254
262
  /**
@@ -69,6 +69,18 @@ export declare class OriginSourcePattern {
69
69
  * An exclude is stronger than an include.
70
70
  */
71
71
  private readonly exclude;
72
+ /**
73
+ * Files that did match the `include` pattern.
74
+ */
75
+ private readonly includeMatches;
76
+ /**
77
+ * Files that did match the `exclude` pattern.
78
+ */
79
+ private readonly excludeMatches;
80
+ /**
81
+ * Files that did neither match the `exclude` nor the `include` pattern.
82
+ */
83
+ private readonly neitherExcludedNorIncluded;
72
84
  constructor(include: string[] | undefined, exclude: string[] | undefined);
73
85
  /**
74
86
  * Does the given pattern require to include the given file?
@@ -88,6 +100,20 @@ export declare class OriginSourcePattern {
88
100
  * (Primarily, used for testing.)
89
101
  */
90
102
  isAnyIncluded(originFiles: string[]): boolean;
103
+ /**
104
+ * Retrieve the file names that have been matching the different patterns.
105
+ */
106
+ retrieveMatchingFiles(): {
107
+ includePatterns: string[];
108
+ excludePatterns: string[];
109
+ excludeMatches: string[];
110
+ includeMatches: string[];
111
+ neitherExcludedNorIncluded: string[];
112
+ };
113
+ /**
114
+ * Returns if include/exclude patterns are specified.
115
+ */
116
+ patternsSpecified(): boolean;
91
117
  }
92
118
  /**
93
119
  * Pattern describing files (bundles) to not instrument.
@@ -129,7 +155,11 @@ export declare class InstrumentationTask {
129
155
  * File to write the file-origin-mapping to.
130
156
  */
131
157
  readonly dumpOriginsFile: string | undefined;
132
- constructor(collector: CollectorSpecifier, elements: TaskElement[], excludeFilesPattern: FileExcludePattern, originSourcePattern: OriginSourcePattern, dumpOriginsFile: string | undefined);
158
+ /**
159
+ * File to write the matched files to.
160
+ */
161
+ readonly dumpMatchedOriginsFile: string | undefined;
162
+ constructor(collector: CollectorSpecifier, elements: TaskElement[], excludeFilesPattern: FileExcludePattern, originSourcePattern: OriginSourcePattern, dumpOriginsFile: string | undefined, dumpMatchedOriginsFile: string | undefined);
133
163
  /**
134
164
  * @returns the elements of the task.
135
165
  */
@@ -153,7 +183,9 @@ export declare class TaskResult {
153
183
  readonly failed: number;
154
184
  /** Number of warnings that were produced during the instrumentation process */
155
185
  readonly warnings: number;
156
- constructor(translated: number, excluded: number, translatedFromCache: number, alreadyInstrumented: number, unsupported: number, failed: number, warnings: number);
186
+ /** The instrumentation task for that the results were produced. */
187
+ readonly task?: InstrumentationTask;
188
+ constructor(translated: number, excluded: number, translatedFromCache: number, alreadyInstrumented: number, unsupported: number, failed: number, warnings: number, task?: InstrumentationTask);
157
189
  /**
158
190
  * Returns the sum of the present task results and the given one.
159
191
  *
@@ -163,7 +195,7 @@ export declare class TaskResult {
163
195
  /**
164
196
  * @returns the neutral task element (adding it with {@code withIncrement} does not change the result).
165
197
  */
166
- static neutral(): TaskResult;
198
+ static neutral(task?: InstrumentationTask): TaskResult;
167
199
  /**
168
200
  * @returns a task result signaling one error.
169
201
  *
@@ -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;AAI/C;;GAEG;AACH,8BAAsB,kBAAkB;CAAG;AAE3C,KAAK,UAAU,GAAG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AM,EAAE,MAAM,CAAC;IAE/B,+EAA+E;IAC/E,SAAgB,QAAQ,EAAE,MAAM,CAAC;IAEjC,mEAAmE;IACnE,SAAgB,IAAI,CAAC,EAAE,mBAAmB,CAAC;gBAG1C,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,mBAAmB,EAAE,MAAM,EAC3B,mBAAmB,EAAE,MAAM,EAC3B,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,IAAI,CAAC,EAAE,mBAAmB;IAmB3B;;;;OAIG;IACI,aAAa,CAAC,KAAK,EAAE,UAAU,GAAG,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"}
@@ -52,6 +52,14 @@ class CollectorSpecifier {
52
52
  }
53
53
  }
54
54
  exports.CollectorSpecifier = CollectorSpecifier;
55
+ /**
56
+ * Configuration used to match paths with `micromatch`.
57
+ */
58
+ const MATCHER_OPTIONS = {
59
+ basename: false,
60
+ lookbehinds: true,
61
+ noglobstar: false
62
+ };
55
63
  /**
56
64
  * Patterns that define which parts of a given bundle to instrument or not.
57
65
  *
@@ -63,6 +71,9 @@ class OriginSourcePattern {
63
71
  constructor(include, exclude) {
64
72
  this.include = normalizePatterns(include);
65
73
  this.exclude = normalizePatterns(exclude);
74
+ this.includeMatches = new Set();
75
+ this.excludeMatches = new Set();
76
+ this.neitherExcludedNorIncluded = new Set();
66
77
  }
67
78
  /**
68
79
  * Does the given pattern require to include the given file?
@@ -82,14 +93,23 @@ class OriginSourcePattern {
82
93
  }
83
94
  const normalizedOriginFile = normalizePath(originFile);
84
95
  if (this.exclude) {
85
- const matchedToExclude = (0, micromatch_1.default)([normalizedOriginFile], this.exclude);
96
+ const matchedToExclude = (0, micromatch_1.default)([normalizedOriginFile], this.exclude, MATCHER_OPTIONS);
86
97
  if (matchedToExclude.length === 1) {
98
+ this.excludeMatches.add(normalizedOriginFile);
87
99
  return false;
88
100
  }
89
101
  }
90
102
  if (this.include) {
91
- return micromatch_1.default.some([normalizedOriginFile], this.include || ['**']);
103
+ const result = micromatch_1.default.some([normalizedOriginFile], this.include, MATCHER_OPTIONS);
104
+ if (result) {
105
+ this.includeMatches.add(normalizedOriginFile);
106
+ }
107
+ else {
108
+ this.neitherExcludedNorIncluded.add(normalizedOriginFile);
109
+ }
110
+ return result;
92
111
  }
112
+ this.neitherExcludedNorIncluded.add(normalizedOriginFile);
93
113
  return true;
94
114
  }
95
115
  /**
@@ -99,6 +119,25 @@ class OriginSourcePattern {
99
119
  isAnyIncluded(originFiles) {
100
120
  return originFiles.find(value => this.isIncluded(value)) !== undefined;
101
121
  }
122
+ /**
123
+ * Retrieve the file names that have been matching the different patterns.
124
+ */
125
+ retrieveMatchingFiles() {
126
+ var _a, _b;
127
+ return {
128
+ includePatterns: (_a = this.include) !== null && _a !== void 0 ? _a : [],
129
+ excludePatterns: (_b = this.exclude) !== null && _b !== void 0 ? _b : [],
130
+ excludeMatches: [...this.excludeMatches],
131
+ includeMatches: [...this.includeMatches],
132
+ neitherExcludedNorIncluded: [...this.neitherExcludedNorIncluded]
133
+ };
134
+ }
135
+ /**
136
+ * Returns if include/exclude patterns are specified.
137
+ */
138
+ patternsSpecified() {
139
+ return this.include !== undefined || this.exclude !== undefined;
140
+ }
102
141
  }
103
142
  exports.OriginSourcePattern = OriginSourcePattern;
104
143
  /**
@@ -138,10 +177,22 @@ function normalizeGlobPattern(pattern) {
138
177
  if (!pattern) {
139
178
  return pattern;
140
179
  }
141
- return removeTrailingCurrentWorkingDir(pattern);
180
+ // This should be in line with the logic in `normalizePath`.
181
+ return removeTrailingDirectoryTraversals(removeTrailingCurrentWorkingDir(pattern));
142
182
  }
143
183
  function normalizePath(toNormalize) {
144
- return removeTrailingCurrentWorkingDir(toNormalize.replace(/\\/g, '/'));
184
+ // This should be in line with the logic in `normalizeGlobPattern`.
185
+ return removeTrailingDirectoryTraversals(removeTrailingCurrentWorkingDir(toNormalize.replace(/\\/g, '/')));
186
+ }
187
+ /**
188
+ * `micromatch` cannot deal with leading `../`, so we remove those.
189
+ */
190
+ function removeTrailingDirectoryTraversals(toNormalize) {
191
+ let result = toNormalize;
192
+ while (result.startsWith("../")) {
193
+ result = result.substring(3);
194
+ }
195
+ return result;
145
196
  }
146
197
  function removeTrailingCurrentWorkingDir(removeFrom) {
147
198
  return removePrefix('webpack:///', removePrefix('./', removeFrom));
@@ -156,12 +207,13 @@ function removePrefix(prefix, removeFrom) {
156
207
  * The actual instrumentation task.
157
208
  */
158
209
  class InstrumentationTask {
159
- constructor(collector, elements, excludeFilesPattern, originSourcePattern, dumpOriginsFile) {
210
+ constructor(collector, elements, excludeFilesPattern, originSourcePattern, dumpOriginsFile, dumpMatchedOriginsFile) {
160
211
  this.collector = commons_1.Contract.requireDefined(collector);
161
212
  this.excludeFilesPattern = commons_1.Contract.requireDefined(excludeFilesPattern);
162
213
  this.originSourcePattern = commons_1.Contract.requireDefined(originSourcePattern);
163
214
  this._elements = commons_1.Contract.requireDefined(elements).slice();
164
215
  this.dumpOriginsFile = dumpOriginsFile;
216
+ this.dumpMatchedOriginsFile = dumpMatchedOriginsFile;
165
217
  }
166
218
  /**
167
219
  * @returns the elements of the task.
@@ -177,7 +229,7 @@ exports.InstrumentationTask = InstrumentationTask;
177
229
  * A summary of executing the instrumentation task.
178
230
  */
179
231
  class TaskResult {
180
- constructor(translated, excluded, translatedFromCache, alreadyInstrumented, unsupported, failed, warnings) {
232
+ constructor(translated, excluded, translatedFromCache, alreadyInstrumented, unsupported, failed, warnings, task) {
181
233
  commons_1.Contract.require(translated > -1);
182
234
  commons_1.Contract.require(excluded > -1);
183
235
  commons_1.Contract.require(translatedFromCache > -1);
@@ -192,6 +244,7 @@ class TaskResult {
192
244
  this.unsupported = unsupported;
193
245
  this.failed = failed;
194
246
  this.warnings = warnings;
247
+ this.task = task;
195
248
  }
196
249
  /**
197
250
  * Returns the sum of the present task results and the given one.
@@ -199,13 +252,14 @@ class TaskResult {
199
252
  * @param incBy - The task result to add (as delta).
200
253
  */
201
254
  withIncrement(incBy) {
202
- return new TaskResult(this.translated + incBy.translated, this.excluded + incBy.excluded, this.translatedFromCache + incBy.translatedFromCache, this.alreadyInstrumented + incBy.alreadyInstrumented, this.unsupported + incBy.unsupported, this.failed + incBy.failed, this.warnings + incBy.warnings);
255
+ var _a;
256
+ return new TaskResult(this.translated + incBy.translated, this.excluded + incBy.excluded, this.translatedFromCache + incBy.translatedFromCache, this.alreadyInstrumented + incBy.alreadyInstrumented, this.unsupported + incBy.unsupported, this.failed + incBy.failed, this.warnings + incBy.warnings, (_a = this.task) !== null && _a !== void 0 ? _a : incBy.task);
203
257
  }
204
258
  /**
205
259
  * @returns the neutral task element (adding it with {@code withIncrement} does not change the result).
206
260
  */
207
- static neutral() {
208
- return new TaskResult(0, 0, 0, 0, 0, 0, 0);
261
+ static neutral(task) {
262
+ return new TaskResult(0, 0, 0, 0, 0, 0, 0, task);
209
263
  }
210
264
  /**
211
265
  * @returns a task result signaling one error.
@@ -11,6 +11,7 @@ export type ConfigurationParameters = {
11
11
  exclude_origin?: string[];
12
12
  exclude_bundle?: string[];
13
13
  dump_origins_to?: string;
14
+ dump_origin_matches_to?: string;
14
15
  };
15
16
  /**
16
17
  * A builder for an instrumentation task.
@@ -26,8 +27,15 @@ export declare class TaskBuilder {
26
27
  private originSourceExcludePatterns;
27
28
  /** Bundle exclude patters. */
28
29
  private bundleFileExcludePatterns;
29
- /** File path where all origins from the source map should be dumped in json format, or undefined if no origins should be dumped */
30
+ /**
31
+ * File path where all origins from the source map should be dumped in JSON format,
32
+ * or undefined if no origins should be dumped */
30
33
  private dumpOriginsFile;
34
+ /**
35
+ * File path where the matched origin file names are stored as JSON,
36
+ * `undefined` if this information should not be dumped.
37
+ */
38
+ private dumpMatchedOriginsFile;
31
39
  constructor();
32
40
  /** Set the collector by extracting the information from a given string */
33
41
  setCollectorFromString(collectorSpecification: string): this;
@@ -1 +1 @@
1
- {"version":3,"file":"TaskBuilder.d.ts","sourceRoot":"","sources":["../../../src/instrumenter/TaskBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,mBAAmB,EAGnB,kBAAkB,EAElB,MAAM,QAAQ,CAAC;AAMhB,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;IAElB,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;CACzB,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,mIAAmI;IACnI,OAAO,CAAC,eAAe,CAAqB;;IAO5C,0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AAC;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,0EAA0E;IAC1E,sBAAsB,CAAC,sBAAsB,EAAE,MAAM,GAAG,IAAI;IAM5D,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"}
@@ -90,6 +90,7 @@ class TaskBuilder {
90
90
  const target = config.to;
91
91
  const sourceMap = config.source_map;
92
92
  this.dumpOriginsFile = config.dump_origins_to;
93
+ this.dumpMatchedOriginsFile = config.dump_origin_matches_to;
93
94
  this.setCollectorFromString(config.collector);
94
95
  this.setOriginSourceIncludePatterns(config.include_origin);
95
96
  this.setOriginSourceExcludePatterns(config.exclude_origin);
@@ -170,7 +171,7 @@ class TaskBuilder {
170
171
  * Build the instrumentation task.
171
172
  */
172
173
  build() {
173
- return new Task_1.InstrumentationTask(commons_1.Contract.requireDefined(this.collector), this.elements, new Task_1.FileExcludePattern(this.bundleFileExcludePatterns), new Task_1.OriginSourcePattern(this.originSourceIncludePatterns, this.originSourceExcludePatterns), this.dumpOriginsFile);
174
+ return new Task_1.InstrumentationTask(commons_1.Contract.requireDefined(this.collector), this.elements, new Task_1.FileExcludePattern(this.bundleFileExcludePatterns), new Task_1.OriginSourcePattern(this.originSourceIncludePatterns, this.originSourceExcludePatterns), this.dumpOriginsFile, this.dumpMatchedOriginsFile);
174
175
  }
175
176
  }
176
177
  exports.TaskBuilder = TaskBuilder;
package/dist/src/main.js CHANGED
@@ -5,6 +5,7 @@ const App_1 = require("./App");
5
5
  // Run the instrumenter and print the results to the console.
6
6
  App_1.App.run()
7
7
  .then(result => {
8
+ var _a, _b;
8
9
  console.log('Instrumentation finished.');
9
10
  console.log(`\tInstrumented: ${result.translated}`);
10
11
  console.log(`\tExcluded: ${result.excluded}`);
@@ -13,6 +14,15 @@ App_1.App.run()
13
14
  console.log(`\tUnsupported: ${result.unsupported}`);
14
15
  console.log(`\tWith warning: ${result.warnings}`);
15
16
  console.log(`\tFailed: ${result.failed}`);
17
+ if ((_a = result.task) === null || _a === void 0 ? void 0 : _a.originSourcePattern.patternsSpecified()) {
18
+ const stats = (_b = result.task) === null || _b === void 0 ? void 0 : _b.originSourcePattern.retrieveMatchingFiles();
19
+ console.log(`\tSource origin matches`);
20
+ console.log(`\t\tInclude patterns: [${stats.includePatterns}]`);
21
+ console.log(`\t\tExclude patterns: [${stats.excludeMatches}]`);
22
+ console.log(`\t\tInclude matches: ${stats.includeMatches.length}`);
23
+ console.log(`\t\tExclude matches: ${stats.excludeMatches.length}`);
24
+ console.log(`\t\tNeither matches: ${stats.neitherExcludedNorIncluded.length}`);
25
+ }
16
26
  })
17
27
  .catch(reason => {
18
28
  console.log('Failed: ', reason);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teamscale/javascript-instrumenter",
3
- "version": "0.1.0-beta.2",
3
+ "version": "0.1.0-beta.4",
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,39 +15,39 @@
15
15
  "dist/**/*"
16
16
  ],
17
17
  "devDependencies": {
18
- "@babel/core": "^7.23.2",
19
- "@babel/plugin-transform-modules-commonjs": "^7.23.0",
20
- "@babel/preset-env": "^7.23.2",
21
- "@types/argparse": "^2.0.12",
22
- "@types/async": "^3.2.22",
23
- "@types/babel__generator": "^7.6.6",
24
- "@types/babel__traverse": "^7.20.3",
25
- "@types/bunyan": "^1.8.10",
26
- "@types/convert-source-map": "^2.0.2",
18
+ "@babel/core": "^7.23.7",
19
+ "@babel/plugin-transform-modules-commonjs": "^7.23.3",
20
+ "@babel/preset-env": "^7.23.8",
21
+ "@types/argparse": "^2.0.14",
22
+ "@types/async": "^3.2.24",
23
+ "@types/babel__generator": "^7.6.8",
24
+ "@types/babel__traverse": "^7.20.5",
25
+ "@types/bunyan": "^1.8.11",
26
+ "@types/convert-source-map": "^2.0.3",
27
27
  "@types/glob": "^8.1.0",
28
- "@types/istanbul-lib-instrument": "^1.7.6",
29
- "@types/jest": "^29.5.6",
30
- "@types/node": "^20.8.6",
31
- "@types/ws": "^8.5.7",
28
+ "@types/istanbul-lib-instrument": "^1.7.7",
29
+ "@types/jest": "^29.5.11",
30
+ "@types/node": "^20.11.0",
31
+ "@types/ws": "^8.5.10",
32
32
  "babel-jest": "^29.7.0",
33
- "esbuild": "^0.19.5",
33
+ "esbuild": "^0.19.11",
34
34
  "esbuild-plugin-inline-worker": "^0.1.1",
35
35
  "jest": "^29.7.0",
36
36
  "rimraf": "^5.0.5",
37
37
  "ts-jest": "^29.1.1",
38
- "ts-node": "^10.9.1",
38
+ "ts-node": "^10.9.2",
39
39
  "tslib": "^2.6.2",
40
- "typescript": "^5.2.2"
40
+ "typescript": "^5.3.3"
41
41
  },
42
42
  "dependencies": {
43
- "@cqse/commons": "0.0.1-beta.59",
44
- "@babel/generator": "^7.23.0",
45
- "@babel/parser": "^7.23.0",
46
- "@babel/traverse": "^7.23.2",
47
- "@babel/types": "^7.23.0",
48
- "@types/micromatch": "^4.0.3",
43
+ "@cqse/commons": "0.1.0-beta.2",
44
+ "@babel/generator": "^7.23.6",
45
+ "@babel/parser": "^7.23.6",
46
+ "@babel/traverse": "^7.23.7",
47
+ "@babel/types": "^7.23.6",
48
+ "@types/micromatch": "^4.0.6",
49
49
  "argparse": "^2.0.1",
50
- "async": "^3.2.4",
50
+ "async": "^3.2.5",
51
51
  "bunyan": "^1.8.15",
52
52
  "convert-source-map": "^2.0.0",
53
53
  "foreground-child": "^3.1.1",
@@ -57,8 +57,8 @@
57
57
  "source-map": "0.7.4",
58
58
  "typescript-optional": "^2.0.1",
59
59
  "unload": "^2.4.1",
60
- "web-worker": "^1.2.0",
61
- "@teamscale/lib-instrument": "0.1.0-beta.2"
60
+ "web-worker": "^1.3.0",
61
+ "@teamscale/lib-instrument": "0.1.0-beta.4"
62
62
  },
63
63
  "publishConfig": {
64
64
  "access": "public"