@teamscale/javascript-instrumenter 1.0.0-beta.7 → 1.0.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.
Files changed (36) hide show
  1. package/dist/main.mjs +216 -0
  2. package/package.json +18 -9
  3. package/dist/package.json +0 -63
  4. package/dist/src/App.d.ts +0 -16
  5. package/dist/src/App.d.ts.map +0 -1
  6. package/dist/src/App.js +0 -233
  7. package/dist/src/instrumenter/FileSystem.d.ts +0 -10
  8. package/dist/src/instrumenter/FileSystem.d.ts.map +0 -1
  9. package/dist/src/instrumenter/FileSystem.js +0 -104
  10. package/dist/src/instrumenter/Instrumenter.d.ts +0 -25
  11. package/dist/src/instrumenter/Instrumenter.d.ts.map +0 -1
  12. package/dist/src/instrumenter/Instrumenter.js +0 -292
  13. package/dist/src/instrumenter/InstrumenterConfig.d.ts +0 -28
  14. package/dist/src/instrumenter/InstrumenterConfig.d.ts.map +0 -1
  15. package/dist/src/instrumenter/InstrumenterConfig.js +0 -159
  16. package/dist/src/instrumenter/RelativeCollectorPatternParser.d.ts +0 -6
  17. package/dist/src/instrumenter/RelativeCollectorPatternParser.d.ts.map +0 -1
  18. package/dist/src/instrumenter/RelativeCollectorPatternParser.js +0 -53
  19. package/dist/src/instrumenter/RelativeCollectorPatternParser.test.d.ts +0 -2
  20. package/dist/src/instrumenter/RelativeCollectorPatternParser.test.d.ts.map +0 -1
  21. package/dist/src/instrumenter/RelativeCollectorPatternParser.test.js +0 -33
  22. package/dist/src/instrumenter/Task.d.ts +0 -80
  23. package/dist/src/instrumenter/Task.d.ts.map +0 -1
  24. package/dist/src/instrumenter/Task.js +0 -228
  25. package/dist/src/instrumenter/TaskBuilder.d.ts +0 -25
  26. package/dist/src/instrumenter/TaskBuilder.d.ts.map +0 -1
  27. package/dist/src/instrumenter/TaskBuilder.js +0 -181
  28. package/dist/src/instrumenter/WebToolkit.d.ts +0 -13
  29. package/dist/src/instrumenter/WebToolkit.d.ts.map +0 -1
  30. package/dist/src/instrumenter/WebToolkit.js +0 -119
  31. package/dist/src/main.d.ts +0 -3
  32. package/dist/src/main.d.ts.map +0 -1
  33. package/dist/src/main.js +0 -10
  34. package/dist/src/vaccine/types.d.ts +0 -28
  35. package/dist/src/vaccine/types.d.ts.map +0 -1
  36. package/dist/src/vaccine/types.js +0 -2
@@ -1 +0,0 @@
1
- {"version":3,"file":"Task.d.ts","sourceRoot":"","sources":["../../../src/instrumenter/Task.ts"],"names":[],"mappings":"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"}
@@ -1,228 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.SourceMapFileReference = exports.TaskResult = exports.InstrumentationTask = exports.FileExcludePattern = exports.OriginSourcePattern = exports.TaskElement = exports.SourceMapReference = void 0;
7
- exports.createCollectorSpecifier = createCollectorSpecifier;
8
- const commons_1 = require("@cqse/commons");
9
- const micromatch_1 = __importDefault(require("micromatch"));
10
- const RelativeCollectorPatternParser_1 = require("./RelativeCollectorPatternParser");
11
- class SourceMapReference {
12
- }
13
- exports.SourceMapReference = SourceMapReference;
14
- class TaskElement {
15
- fromFile;
16
- toFile;
17
- externalSourceMapFile;
18
- constructor(fromFile, toFile, externalSourceMap) {
19
- this.fromFile = commons_1.Contract.requireDefined(fromFile);
20
- this.toFile = commons_1.Contract.requireDefined(toFile);
21
- this.externalSourceMapFile = externalSourceMap;
22
- }
23
- isInPlace() {
24
- return this.fromFile === this.toFile;
25
- }
26
- }
27
- exports.TaskElement = TaskElement;
28
- function createCollectorSpecifier(commandLineUrl, relativePattern) {
29
- if (relativePattern !== undefined) {
30
- return RelativeCollectorPatternParser_1.RelativeCollectorPatternParser.parse(relativePattern);
31
- }
32
- return parseCommandLineUrl(commandLineUrl);
33
- }
34
- function parseCommandLineUrl(commandLineUrl) {
35
- let url;
36
- if (commandLineUrl.indexOf('://') > 0) {
37
- url = commandLineUrl.replace(/\/$/, '');
38
- }
39
- else {
40
- commons_1.Contract.requireStringPattern(commandLineUrl, '.+:[0-9]+', 'Invalid collector pattern used!');
41
- const host = commandLineUrl.split(':')[0];
42
- const port = Number.parseInt(commandLineUrl.split(':')[1]);
43
- url = `ws://${host}:${port}`;
44
- }
45
- return {
46
- type: "url",
47
- url,
48
- };
49
- }
50
- const MATCHER_OPTIONS = {
51
- basename: false,
52
- lookbehinds: true,
53
- noglobstar: false
54
- };
55
- class OriginSourcePattern {
56
- include;
57
- exclude;
58
- includeMatches;
59
- excludeMatches;
60
- neitherExcludedNorIncluded;
61
- constructor(include, exclude) {
62
- this.include = normalizePatterns(include);
63
- this.exclude = normalizePatterns(exclude);
64
- this.includeMatches = new Set();
65
- this.excludeMatches = new Set();
66
- this.neitherExcludedNorIncluded = new Set();
67
- }
68
- isIncluded(originFile) {
69
- if (originFile.length === 0) {
70
- return true;
71
- }
72
- const normalizedOriginFile = normalizePath(originFile);
73
- if (this.exclude) {
74
- const matchedToExclude = (0, micromatch_1.default)([normalizedOriginFile], this.exclude, MATCHER_OPTIONS);
75
- if (matchedToExclude.length === 1) {
76
- this.excludeMatches.add(normalizedOriginFile);
77
- return false;
78
- }
79
- }
80
- if (this.include) {
81
- const result = micromatch_1.default.some([normalizedOriginFile], this.include, MATCHER_OPTIONS);
82
- if (result) {
83
- this.includeMatches.add(normalizedOriginFile);
84
- }
85
- else {
86
- this.neitherExcludedNorIncluded.add(normalizedOriginFile);
87
- }
88
- return result;
89
- }
90
- this.neitherExcludedNorIncluded.add(normalizedOriginFile);
91
- return true;
92
- }
93
- isAnyIncluded(originFiles) {
94
- return originFiles.find(value => this.isIncluded(value)) !== undefined;
95
- }
96
- retrieveMatchingFiles() {
97
- return {
98
- includePatterns: this.include ?? [],
99
- excludePatterns: this.exclude ?? [],
100
- excludeMatches: [...this.excludeMatches],
101
- includeMatches: [...this.includeMatches],
102
- neitherExcludedNorIncluded: [...this.neitherExcludedNorIncluded]
103
- };
104
- }
105
- patternsSpecified() {
106
- return this.include !== undefined || this.exclude !== undefined;
107
- }
108
- }
109
- exports.OriginSourcePattern = OriginSourcePattern;
110
- class FileExcludePattern {
111
- exclude;
112
- constructor(exclude) {
113
- this.exclude = normalizePatterns(exclude) ?? [];
114
- }
115
- isExcluded(filePath) {
116
- return micromatch_1.default.isMatch(normalizePath(filePath), this.exclude);
117
- }
118
- }
119
- exports.FileExcludePattern = FileExcludePattern;
120
- function normalizePatterns(patterns) {
121
- if (patterns === undefined || patterns.length === 0) {
122
- return undefined;
123
- }
124
- const normalizedPatterns = patterns
125
- .map(pattern => normalizeGlobPattern(pattern))
126
- .filter(pattern => pattern !== undefined);
127
- if (patterns.length === 0) {
128
- return undefined;
129
- }
130
- return normalizedPatterns;
131
- }
132
- function normalizeGlobPattern(pattern) {
133
- if (!pattern) {
134
- return pattern;
135
- }
136
- return removeTrailingDirectoryTraversals(removeTrailingCurrentWorkingDir(pattern));
137
- }
138
- function normalizePath(toNormalize) {
139
- return removeTrailingDirectoryTraversals(removeTrailingCurrentWorkingDir(toNormalize.replace(/\\/g, '/')));
140
- }
141
- function removeTrailingDirectoryTraversals(toNormalize) {
142
- let result = toNormalize;
143
- while (result.startsWith("../")) {
144
- result = result.substring(3);
145
- }
146
- return result;
147
- }
148
- function removeTrailingCurrentWorkingDir(removeFrom) {
149
- return removePrefix('webpack:///', removePrefix('./', removeFrom));
150
- }
151
- function removePrefix(prefix, removeFrom) {
152
- if (removeFrom.startsWith(prefix)) {
153
- return removeFrom.substring(prefix.length);
154
- }
155
- return removeFrom;
156
- }
157
- class InstrumentationTask {
158
- collector;
159
- targetBucket;
160
- _elements;
161
- originSourcePattern;
162
- excludeFilesPattern;
163
- dumpOriginsFile;
164
- dumpMatchedOriginsFile;
165
- constructor(collector, targetBucket, elements, excludeFilesPattern, originSourcePattern, dumpOriginsFile, dumpMatchedOriginsFile) {
166
- this.collector = commons_1.Contract.requireDefined(collector);
167
- this.targetBucket = commons_1.Contract.requireDefined(targetBucket);
168
- this.excludeFilesPattern = commons_1.Contract.requireDefined(excludeFilesPattern);
169
- this.originSourcePattern = commons_1.Contract.requireDefined(originSourcePattern);
170
- this._elements = commons_1.Contract.requireDefined(elements).slice();
171
- this.dumpOriginsFile = dumpOriginsFile;
172
- this.dumpMatchedOriginsFile = dumpMatchedOriginsFile;
173
- }
174
- get elements() {
175
- return this._elements.slice();
176
- }
177
- }
178
- exports.InstrumentationTask = InstrumentationTask;
179
- class TaskResult {
180
- translated;
181
- excluded;
182
- translatedFromCache;
183
- alreadyInstrumented;
184
- unsupported;
185
- failed;
186
- warnings;
187
- task;
188
- constructor(translated, excluded, translatedFromCache, alreadyInstrumented, unsupported, failed, warnings, task) {
189
- commons_1.Contract.require(translated > -1);
190
- commons_1.Contract.require(excluded > -1);
191
- commons_1.Contract.require(translatedFromCache > -1);
192
- commons_1.Contract.require(alreadyInstrumented > -1);
193
- commons_1.Contract.require(unsupported > -1);
194
- commons_1.Contract.require(failed > -1);
195
- commons_1.Contract.require(warnings > -1);
196
- this.translated = translated;
197
- this.excluded = excluded;
198
- this.translatedFromCache = translatedFromCache;
199
- this.alreadyInstrumented = alreadyInstrumented;
200
- this.unsupported = unsupported;
201
- this.failed = failed;
202
- this.warnings = warnings;
203
- this.task = task;
204
- }
205
- withIncrement(incBy) {
206
- 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, this.task ?? incBy.task);
207
- }
208
- static neutral(task) {
209
- return new TaskResult(0, 0, 0, 0, 0, 0, 0, task);
210
- }
211
- static error(e) {
212
- console.error(e);
213
- return new TaskResult(0, 0, 0, 0, 0, 1, 0);
214
- }
215
- static warning(msg) {
216
- console.warn(msg);
217
- return new TaskResult(0, 0, 0, 0, 0, 0, 1);
218
- }
219
- }
220
- exports.TaskResult = TaskResult;
221
- class SourceMapFileReference extends SourceMapReference {
222
- sourceMapFilePath;
223
- constructor(sourceMapFilePath) {
224
- super();
225
- this.sourceMapFilePath = sourceMapFilePath;
226
- }
227
- }
228
- exports.SourceMapFileReference = SourceMapFileReference;
@@ -1,25 +0,0 @@
1
- import { InstrumentationTask, SourceMapReference } from './Task';
2
- import { InstrumenterOptions } from './InstrumenterConfig';
3
- export declare class TaskBuilder {
4
- private readonly elements;
5
- private collector;
6
- private originSourceIncludePatterns;
7
- private originSourceExcludePatterns;
8
- private bundleFileExcludePatterns;
9
- private dumpOriginsFile;
10
- private dumpMatchedOriginsFile;
11
- private targetBucket;
12
- private appId;
13
- constructor();
14
- setCollectorFromCommandLine(commandLineUrl: string, relativePattern?: string): this;
15
- setCollectorTargetBucket(configId: string | undefined, commit: string, configOptions?: string, appName?: string): this;
16
- setOriginSourceIncludePatterns(patterns: string[] | undefined): this;
17
- setOriginSourceExcludePatterns(patterns: string[] | undefined): this;
18
- setBundleExcludePatterns(patterns: string[] | undefined): this;
19
- addElement(fromFilePath: string, toFilePath: string, fromFileSourceMap?: SourceMapReference): this;
20
- addFromConfig(config: InstrumenterOptions): this;
21
- private addInstrumentationTasksFromPatternWithTarget;
22
- private addInPlaceTasksFromPattern;
23
- build(): InstrumentationTask;
24
- }
25
- //# sourceMappingURL=TaskBuilder.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TaskBuilder.d.ts","sourceRoot":"","sources":["../../../src/instrumenter/TaskBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,mBAAmB,EAGnB,kBAAkB,EAGlB,MAAM,QAAQ,CAAC;AAYhB,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAuB3D,qBAAa,WAAW;IAEvB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAgB;IAGzC,OAAO,CAAC,SAAS,CAA4B;IAG7C,OAAO,CAAC,2BAA2B,CAAuB;IAG1D,OAAO,CAAC,2BAA2B,CAAuB;IAG1D,OAAO,CAAC,yBAAyB,CAAuB;IAKxD,OAAO,CAAC,eAAe,CAAqB;IAM5C,OAAO,CAAC,sBAAsB,CAAqB;IAKnD,OAAO,CAAC,YAAY,CAAiC;IAKrD,OAAO,CAAC,KAAK,CAAS;;IAUtB,2BAA2B,CAAC,cAAc,EAAE,MAAM,EAAE,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI;IAOnF,wBAAwB,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,MAAM,EACtF,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI;IAQ9B,8BAA8B,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,SAAS,GAAG,IAAI;IAMpE,8BAA8B,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,SAAS,GAAG,IAAI;IAMpE,wBAAwB,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,SAAS,GAAG,IAAI;IAM9D,UAAU,CAAC,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,iBAAiB,CAAC,EAAE,kBAAkB,GAAG,IAAI;IAUlG,aAAa,CAAC,MAAM,EAAE,mBAAmB,GAAG,IAAI;IA+ChD,OAAO,CAAC,4CAA4C;IAuCpD,OAAO,CAAC,0BAA0B;IAY3B,KAAK,IAAI,mBAAmB;CAWnC"}
@@ -1,181 +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
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.TaskBuilder = void 0;
37
- const Task_1 = require("./Task");
38
- const commons_1 = require("@cqse/commons");
39
- const fs = __importStar(require("fs"));
40
- const path = __importStar(require("path"));
41
- const FileSystem_1 = require("./FileSystem");
42
- const uuid_1 = require("uuid");
43
- function loadSourceMap(sourceMapPath) {
44
- if (sourceMapPath) {
45
- if (!fs.existsSync(sourceMapPath)) {
46
- throw new commons_1.InvalidConfigurationException(`The specified source map file '${sourceMapPath}' was not found.`);
47
- }
48
- return new Task_1.SourceMapFileReference(sourceMapPath);
49
- }
50
- return undefined;
51
- }
52
- class TaskBuilder {
53
- elements;
54
- collector;
55
- originSourceIncludePatterns;
56
- originSourceExcludePatterns;
57
- bundleFileExcludePatterns;
58
- dumpOriginsFile;
59
- dumpMatchedOriginsFile;
60
- targetBucket;
61
- appId;
62
- constructor() {
63
- this.appId = (0, uuid_1.v4)();
64
- this.elements = [];
65
- this.collector = null;
66
- this.targetBucket = null;
67
- }
68
- setCollectorFromCommandLine(commandLineUrl, relativePattern) {
69
- commons_1.Contract.requireNonEmpty(commandLineUrl, "The collector URL must not be empty");
70
- this.collector = (0, Task_1.createCollectorSpecifier)(commandLineUrl, relativePattern);
71
- return this;
72
- }
73
- setCollectorTargetBucket(configId, commit, configOptions, appName) {
74
- commons_1.Contract.requireNonEmpty(commit, "The commit must not be empty");
75
- this.appId = generateAppId(appName);
76
- this.targetBucket = { appId: this.appId, configId, commit, configOptions };
77
- return this;
78
- }
79
- setOriginSourceIncludePatterns(patterns) {
80
- this.originSourceIncludePatterns = patterns;
81
- return this;
82
- }
83
- setOriginSourceExcludePatterns(patterns) {
84
- this.originSourceExcludePatterns = patterns;
85
- return this;
86
- }
87
- setBundleExcludePatterns(patterns) {
88
- this.bundleFileExcludePatterns = patterns;
89
- return this;
90
- }
91
- addElement(fromFilePath, toFilePath, fromFileSourceMap) {
92
- this.elements.push(new Task_1.TaskElement(fromFilePath, toFilePath, fromFileSourceMap));
93
- return this;
94
- }
95
- addFromConfig(config) {
96
- const inputs = (config.input ?? []);
97
- const inPlace = config.inPlace ?? false;
98
- const target = config.to;
99
- const sourceMap = config.sourceMap;
100
- this.dumpOriginsFile = config.dumpOriginsTo;
101
- this.dumpMatchedOriginsFile = config.dumpOriginMatchesTo;
102
- this.setCollectorFromCommandLine(config.collector, config.relativeCollector);
103
- this.setOriginSourceIncludePatterns(config.includeOrigin);
104
- this.setOriginSourceExcludePatterns(config.excludeOrigin);
105
- this.setBundleExcludePatterns(config.excludeBundle);
106
- this.setCollectorTargetBucket(config.configId, config.commit ?? 'HEAD', config.collectorConfigFileContent, config.appName);
107
- const sourceMapInfo = loadSourceMap(sourceMap);
108
- if (inPlace) {
109
- if (target) {
110
- throw new commons_1.InvalidConfigurationException('No target path must be specified in case an in-place instrumentation is enabled.');
111
- }
112
- this.addInPlaceTasksFromPattern(inputs, sourceMapInfo);
113
- }
114
- else if (!inPlace) {
115
- if (!target) {
116
- throw new commons_1.InvalidConfigurationException('A target path must be specified using `--to`.');
117
- }
118
- this.addInstrumentationTasksFromPatternWithTarget(inputs, target, sourceMapInfo);
119
- }
120
- return this;
121
- }
122
- addInstrumentationTasksFromPatternWithTarget(inputs, target, sourceMapInfo) {
123
- (0, FileSystem_1.ensureExistingDirectory)(target);
124
- for (const input of inputs) {
125
- if ((0, FileSystem_1.isExistingFile)(input)) {
126
- if ((0, FileSystem_1.isExistingDirectory)(target) || target.endsWith(path.sep)) {
127
- this.addElement(input, path.join(target, path.basename(input)), sourceMapInfo);
128
- }
129
- else {
130
- this.addElement(input, target, sourceMapInfo);
131
- }
132
- }
133
- else if ((0, FileSystem_1.isExistingDirectory)(input) || isPattern(input)) {
134
- const inputFiles = inputs.flatMap(input => (0, FileSystem_1.expandToFileSet)(input));
135
- if (isPattern(input)) {
136
- inputFiles.forEach(f => this.addElement(f, path.join(target, path.basename(f)), sourceMapInfo));
137
- }
138
- else {
139
- inputFiles.forEach(f => {
140
- const pathRelativeToInputDir = path.relative(input, f);
141
- const targetFileName = path.join(target, pathRelativeToInputDir);
142
- this.addElement(f, targetFileName, sourceMapInfo);
143
- });
144
- }
145
- }
146
- else {
147
- throw new commons_1.InvalidConfigurationException(`The specified input '${input}' was not found.`);
148
- }
149
- }
150
- }
151
- addInPlaceTasksFromPattern(inputs, sourceMapInfo) {
152
- inputs
153
- .map(input => expandAndCheck(input))
154
- .reduce((prev, curr) => {
155
- return curr.concat(prev);
156
- }, [])
157
- .forEach(filePath => this.addElement(filePath, filePath, sourceMapInfo));
158
- }
159
- build() {
160
- return new Task_1.InstrumentationTask(commons_1.Contract.requireDefined(this.collector), commons_1.Contract.requireDefined(this.targetBucket), this.elements, new Task_1.FileExcludePattern(this.bundleFileExcludePatterns), new Task_1.OriginSourcePattern(this.originSourceIncludePatterns, this.originSourceExcludePatterns), this.dumpOriginsFile, this.dumpMatchedOriginsFile);
161
- }
162
- }
163
- exports.TaskBuilder = TaskBuilder;
164
- function generateAppId(appName) {
165
- const result = (0, uuid_1.v4)();
166
- if (appName) {
167
- const appPrefix = (0, FileSystem_1.replaceNonFilesystemCharacters)(appName).toLowerCase();
168
- return `${appPrefix}-${result.substring(0, 10)}`;
169
- }
170
- return result;
171
- }
172
- function isPattern(text) {
173
- return text.includes('*') || text.includes('+') || text.includes('?') || text.includes('|');
174
- }
175
- function expandAndCheck(pattern) {
176
- const result = (0, FileSystem_1.expandToFileSet)(pattern);
177
- if (result.length === 0) {
178
- throw new commons_1.InvalidConfigurationException(`No files to instrument found. \n\tWorking directory: '${process.cwd()}'\n\tPattern: '${pattern}'`);
179
- }
180
- return result;
181
- }
@@ -1,13 +0,0 @@
1
- import { Bundle, GwtBundle } from './Task';
2
- import { RawSourceMap } from 'source-map';
3
- export type GwtCallInfos = {
4
- codeArguments: string[];
5
- functionName: string;
6
- codeAsArrayArgument: boolean;
7
- };
8
- export declare function determineSymbolMapsDir(taskFile: string): string[];
9
- export declare function extractGwtCallInfos(bundleContent: string): GwtCallInfos | null;
10
- export declare function loadInputSourceMapsGwt(taskFile: string, bundleFile: GwtBundle): Array<RawSourceMap | undefined>;
11
- export declare function determineGwtFileUid(filename: string): string | undefined;
12
- export declare function isGwtBundle(bundle: Bundle): bundle is GwtBundle;
13
- //# sourceMappingURL=WebToolkit.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"WebToolkit.d.ts","sourceRoot":"","sources":["../../../src/instrumenter/WebToolkit.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAK1C,MAAM,MAAM,YAAY,GAAG;IAAE,aAAa,EAAE,MAAM,EAAE,CAAC;IAAC,YAAY,EAAE,MAAM,CAAC;IAAC,mBAAmB,EAAE,OAAO,CAAA;CAAE,CAAC;AAS3G,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,CAqBjE;AA0BD,wBAAgB,mBAAmB,CAAC,aAAa,EAAE,MAAM,GAAG,YAAY,GAAG,IAAI,CA+B9E;AAKD,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,GAAG,KAAK,CAAC,YAAY,GAAG,SAAS,CAAC,CAgC/G;AAKD,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAOxE;AAKD,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,IAAI,SAAS,CAE/D"}
@@ -1,119 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.determineSymbolMapsDir = determineSymbolMapsDir;
7
- exports.extractGwtCallInfos = extractGwtCallInfos;
8
- exports.loadInputSourceMapsGwt = loadInputSourceMapsGwt;
9
- exports.determineGwtFileUid = determineGwtFileUid;
10
- exports.isGwtBundle = isGwtBundle;
11
- const path_1 = __importDefault(require("path"));
12
- const FileSystem_1 = require("./FileSystem");
13
- const types_1 = require("@babel/types");
14
- const parser_1 = require("@babel/parser");
15
- const commons_1 = require("@cqse/commons");
16
- function determineSymbolMapsDir(taskFile) {
17
- const symbolMapDirs = [];
18
- let webInfDir = null;
19
- const pathComponents = path_1.default.resolve(taskFile).split(path_1.default.sep);
20
- for (let i = pathComponents.length - 2; i >= 0; i--) {
21
- const fullDirPath = pathComponents.slice(0, i).join(path_1.default.sep);
22
- const webInfDirCandidate = path_1.default.join(fullDirPath, 'WEB-INF');
23
- if ((0, FileSystem_1.isExistingDirectory)(webInfDirCandidate)) {
24
- webInfDir = webInfDirCandidate;
25
- }
26
- const symbolMapDirCandidate = path_1.default.join(fullDirPath, 'symbolMaps');
27
- if ((0, FileSystem_1.isExistingDirectory)(symbolMapDirCandidate)) {
28
- symbolMapDirs.push(symbolMapDirCandidate);
29
- }
30
- }
31
- if (webInfDir != null) {
32
- (0, FileSystem_1.findSubFolders)(webInfDir, 'symbolMaps').forEach(dir => symbolMapDirs.push(dir));
33
- }
34
- return symbolMapDirs;
35
- }
36
- function expressionToString(expression) {
37
- if ((0, types_1.isMemberExpression)(expression) && (0, types_1.isExpression)(expression.property)) {
38
- return `${expressionToString(expression.object)}.${expressionToString(expression.property)}`;
39
- }
40
- else if ((0, types_1.isIdentifier)(expression)) {
41
- return expression.name;
42
- }
43
- throw new commons_1.IllegalArgumentException('Type of expression not yet supported.');
44
- }
45
- function extractQualifiedFunctionName(call) {
46
- if ((0, types_1.isMemberExpression)(call.callee) || (0, types_1.isIdentifier)(call.callee)) {
47
- return expressionToString(call.callee);
48
- }
49
- throw new commons_1.IllegalArgumentException('Type of callee not yet supported.');
50
- }
51
- function extractGwtCallInfos(bundleContent) {
52
- const ast = (0, parser_1.parse)(bundleContent);
53
- if (ast.program.body.length === 0) {
54
- return null;
55
- }
56
- if (!(0, types_1.isExpressionStatement)(ast.program.body[0])) {
57
- return null;
58
- }
59
- const call = ast.program.body[0].expression;
60
- if (!(0, types_1.isCallExpression)(call)) {
61
- return null;
62
- }
63
- const qualifiedFunctionName = extractQualifiedFunctionName(call);
64
- const firstArgument = call.arguments[0];
65
- if ((0, types_1.isArrayExpression)(firstArgument)) {
66
- const codeArguments = [];
67
- for (const element of firstArgument.elements) {
68
- if ((0, types_1.isStringLiteral)(element)) {
69
- codeArguments.push(element.value);
70
- }
71
- else {
72
- throw new Error(`Did expect only string arguments in the call of "${qualifiedFunctionName}".`);
73
- }
74
- }
75
- return { codeArguments, functionName: qualifiedFunctionName, codeAsArrayArgument: true };
76
- }
77
- else if ((0, types_1.isStringLiteral)(firstArgument)) {
78
- const codeArgument = firstArgument.value;
79
- return { codeArguments: [codeArgument], functionName: qualifiedFunctionName, codeAsArrayArgument: false };
80
- }
81
- return null;
82
- }
83
- function loadInputSourceMapsGwt(taskFile, bundleFile) {
84
- const mapDirs = determineSymbolMapsDir(taskFile);
85
- const fileNumberMatcher = /sourceURL=(.*)-(\d+).js(\\n)*\s*$/;
86
- const mapModules = bundleFile.codeArguments.map(code => {
87
- const matches = fileNumberMatcher.exec(code);
88
- if (!matches) {
89
- return ['', -1];
90
- }
91
- return [matches[1], Number.parseInt(matches[2])];
92
- });
93
- const sourceMapFiles = mapModules.map(module => {
94
- for (const mapDir of mapDirs) {
95
- const mapFileCandidate = `${mapDir}/${bundleFile.fragmentId}_sourceMap${module[1]}.json`;
96
- if ((0, FileSystem_1.isExistingFile)(mapFileCandidate)) {
97
- return mapFileCandidate;
98
- }
99
- }
100
- return undefined;
101
- });
102
- return sourceMapFiles.map(file => {
103
- if (file) {
104
- return (0, FileSystem_1.sourceMapFromMapFile)(file);
105
- }
106
- return undefined;
107
- });
108
- }
109
- function determineGwtFileUid(filename) {
110
- const fileUidMatcher = /.*([0-9A-Fa-f]{32}).*/;
111
- const uidMatches = fileUidMatcher.exec(filename);
112
- if (!uidMatches || uidMatches.length < 2) {
113
- return undefined;
114
- }
115
- return uidMatches[1];
116
- }
117
- function isGwtBundle(bundle) {
118
- return bundle.type === 'gwt';
119
- }
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};
3
- //# sourceMappingURL=main.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../src/main.ts"],"names":[],"mappings":""}
package/dist/src/main.js DELETED
@@ -1,10 +0,0 @@
1
- #!/usr/bin/env node
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- const App_1 = require("./App");
5
- App_1.App.run().catch(reason => {
6
- console.error(reason);
7
- if (process.exitCode === 0 || process.exitCode === undefined) {
8
- process.exitCode = 1;
9
- }
10
- });
@@ -1,28 +0,0 @@
1
- export interface CollectorSpecifierUrl {
2
- type: 'url';
3
- url: string;
4
- }
5
- export interface SearchReplace {
6
- search: string;
7
- replace: string;
8
- }
9
- export interface CollectorSpecifierRelative {
10
- type: 'relative';
11
- hostReplace?: SearchReplace;
12
- port?: number | 'keep';
13
- scheme?: string;
14
- path?: string;
15
- }
16
- export type CollectorSpecifier = CollectorSpecifierUrl | CollectorSpecifierRelative;
17
- export interface LocationMessage {
18
- type: 'location';
19
- hostname: string;
20
- port: string;
21
- }
22
- export type CoverageBucketSpecifier = {
23
- appId: string;
24
- configId?: string;
25
- configOptions?: string;
26
- commit: string;
27
- };
28
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/vaccine/types.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,qBAAqB;IAErC,IAAI,EAAE,KAAK,CAAC;IAEZ,GAAG,EAAE,MAAM,CAAC;CACZ;AAGD,MAAM,WAAW,aAAa;IAE7B,MAAM,EAAE,MAAM,CAAC;IAEf,OAAO,EAAE,MAAM,CAAC;CAChB;AAKD,MAAM,WAAW,0BAA0B;IAE1C,IAAI,EAAE,UAAU,CAAC;IAEjB,WAAW,CAAC,EAAE,aAAa,CAAC;IAE5B,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAEvB,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,IAAI,CAAC,EAAE,MAAM,CAAC;CACd;AAKD,MAAM,MAAM,kBAAkB,GAAG,qBAAqB,GAAG,0BAA0B,CAAC;AAKpF,MAAM,WAAW,eAAe;IAE/B,IAAI,EAAE,UAAU,CAAC;IAEjB,QAAQ,EAAE,MAAM,CAAC;IAEjB,IAAI,EAAE,MAAM,CAAC;CACb;AAGD,MAAM,MAAM,uBAAuB,GAAG;IAErC,KAAK,EAAE,MAAM,CAAC;IAMd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAOlB,aAAa,CAAC,EAAE,MAAM,CAAC;IAGvB,MAAM,EAAE,MAAM,CAAC;CAEf,CAAA"}
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });