slnodejs 6.1.916 → 6.1.921

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 (74) hide show
  1. package/package.json +1 -1
  2. package/tsOutputs/build-scanner/build-diff-process.js +2 -0
  3. package/tsOutputs/build-scanner/build-diff-process.js.map +1 -1
  4. package/tsOutputs/build-scanner/instrumentation/browser-instrumenter.js +11 -2
  5. package/tsOutputs/build-scanner/instrumentation/browser-instrumenter.js.map +1 -1
  6. package/tsOutputs/cli-parse/cli.js +4 -0
  7. package/tsOutputs/cli-parse/cli.js.map +1 -1
  8. package/tsOutputs/cli-parse/contracts.d.ts +4 -0
  9. package/tsOutputs/cli-parse/contracts.js.map +1 -1
  10. package/tsOutputs/cli-parse/executors/build-args-dto.js +1 -0
  11. package/tsOutputs/cli-parse/executors/build-args-dto.js.map +1 -1
  12. package/tsOutputs/cli-parse/executors/build-executor.js +19 -1
  13. package/tsOutputs/cli-parse/executors/build-executor.js.map +1 -1
  14. package/tsOutputs/cli-parse/executors/run-executor.js +2 -1
  15. package/tsOutputs/cli-parse/executors/run-executor.js.map +1 -1
  16. package/tsOutputs/common/agent-events/agent-events-controller.js.map +1 -1
  17. package/tsOutputs/common/config-process/config.d.ts +1 -0
  18. package/tsOutputs/common/config-process/config.js +1 -0
  19. package/tsOutputs/common/config-process/config.js.map +1 -1
  20. package/tsOutputs/common/constants/sl-env-vars.d.ts +4 -0
  21. package/tsOutputs/common/constants/sl-env-vars.js +4 -0
  22. package/tsOutputs/common/constants/sl-env-vars.js.map +1 -1
  23. package/tsOutputs/common/footprints-process-v6/hits-collector.js +1 -0
  24. package/tsOutputs/common/footprints-process-v6/hits-collector.js.map +1 -1
  25. package/tsOutputs/common/footprints-process-v6/index.d.ts +4 -8
  26. package/tsOutputs/common/footprints-process-v6/index.js +2 -14
  27. package/tsOutputs/common/footprints-process-v6/index.js.map +1 -1
  28. package/tsOutputs/common/http/contracts.d.ts +1 -1
  29. package/tsOutputs/common/watchdog.d.ts +9 -8
  30. package/tsOutputs/common/watchdog.js +1 -4
  31. package/tsOutputs/common/watchdog.js.map +1 -1
  32. package/tsOutputs/test-listener/agent-loader.js +8 -2
  33. package/tsOutputs/test-listener/agent-loader.js.map +1 -1
  34. package/tsOutputs/test-listener/agent.d.ts +1 -1
  35. package/tsOutputs/test-listener/bootstrap.js +4 -0
  36. package/tsOutputs/test-listener/bootstrap.js.map +1 -1
  37. package/tsOutputs/test-listener/config-process/config-loader.js +1 -1
  38. package/tsOutputs/test-listener/config-process/config-loader.js.map +1 -1
  39. package/tsOutputs/test-listener/factory.d.ts +3 -5
  40. package/tsOutputs/test-listener/factory.js +15 -23
  41. package/tsOutputs/test-listener/factory.js.map +1 -1
  42. package/tsOutputs/test-listener/logs-process/index.d.ts +2 -2
  43. package/tsOutputs/common/uuid.js +0 -21
  44. package/tsOutputs/common/uuid.js.map +0 -1
  45. package/tsOutputs/test-listener/config-process/config-system.d.ts +0 -88
  46. package/tsOutputs/test-listener/config-process/config-system.js +0 -259
  47. package/tsOutputs/test-listener/config-process/config-system.js.map +0 -1
  48. package/tsOutputs/test-listener/config-process/index.js +0 -110
  49. package/tsOutputs/test-listener/config-process/index.js.map +0 -1
  50. package/tsOutputs/test-listener/config.d.ts +0 -50
  51. package/tsOutputs/test-listener/config.js +0 -62
  52. package/tsOutputs/test-listener/config.js.map +0 -1
  53. package/tsOutputs/test-listener/environment-data-service.d.ts +0 -11
  54. package/tsOutputs/test-listener/environment-data-service.js +0 -60
  55. package/tsOutputs/test-listener/environment-data-service.js.map +0 -1
  56. package/tsOutputs/test-listener/footprints-process/footprints-service-proxy.js +0 -36
  57. package/tsOutputs/test-listener/footprints-process/footprints-service-proxy.js.map +0 -1
  58. package/tsOutputs/test-listener/footprints-process/index.js +0 -226
  59. package/tsOutputs/test-listener/footprints-process/index.js.map +0 -1
  60. package/tsOutputs/test-listener/footprints-process/istanbul-to-footprints-base.js +0 -130
  61. package/tsOutputs/test-listener/footprints-process/istanbul-to-footprints-base.js.map +0 -1
  62. package/tsOutputs/test-listener/footprints-process/istanbul-to-footprints-contract.js +0 -3
  63. package/tsOutputs/test-listener/footprints-process/istanbul-to-footprints-contract.js.map +0 -1
  64. package/tsOutputs/test-listener/footprints-process/istanbul-to-footprints-v3.js +0 -272
  65. package/tsOutputs/test-listener/footprints-process/istanbul-to-footprints-v3.js.map +0 -1
  66. package/tsOutputs/test-listener/queue.js +0 -40
  67. package/tsOutputs/test-listener/queue.js.map +0 -1
  68. package/tsOutputs/test-listener/state-tracker-process/index.js +0 -143
  69. package/tsOutputs/test-listener/state-tracker-process/index.js.map +0 -1
  70. package/tsOutputs/test-listener/utils.js +0 -68
  71. package/tsOutputs/test-listener/utils.js.map +0 -1
  72. package/tsOutputs/test-listener/watchdog.d.ts +0 -89
  73. package/tsOutputs/test-listener/watchdog.js +0 -128
  74. package/tsOutputs/test-listener/watchdog.js.map +0 -1
@@ -1,62 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AgentConfigWithRuntimeArgs = exports.AgentConfig = void 0;
4
- const config_system_1 = require("./config-process/config-system");
5
- class AgentConfig extends config_system_1.BaseConfiguration {
6
- constructor() {
7
- super(...arguments);
8
- /**
9
- * Sealights agent token (JWT)
10
- * @type {string}
11
- * @memberOf Config
12
- */
13
- this.token = new config_system_1.StringConfigKey(false);
14
- this.tokenFile = new config_system_1.StringConfigKey(false);
15
- this.server = new config_system_1.StringConfigKey(false);
16
- this.proxy = new config_system_1.StringConfigKey(false);
17
- this.interval = new config_system_1.NumberConfigKey(false, 10000);
18
- this.testStatusCheckInterval = new config_system_1.NumberConfigKey(false, 30000);
19
- this.enabled = new config_system_1.BooleanConfigKey(false, true);
20
- this.sendFootprints = new config_system_1.BooleanConfigKey(false, true);
21
- this.sendEvents = new config_system_1.BooleanConfigKey(false, true);
22
- this.sendLogs = new config_system_1.BooleanConfigKey(false, false);
23
- this.customerId = new config_system_1.StringConfigKey(false);
24
- this.appName = new config_system_1.StringConfigKey(false);
25
- this.branch = new config_system_1.StringConfigKey(false);
26
- this.build = new config_system_1.StringConfigKey(false);
27
- this.environmentName = new config_system_1.StringConfigKey(false);
28
- this.useBranchCoverage = new config_system_1.BooleanConfigKey(false, false);
29
- this.labId = new config_system_1.StringConfigKey(false);
30
- this.testStage = new config_system_1.StringConfigKey(false);
31
- this.httpServerColoring = new config_system_1.BooleanConfigKey(false, false);
32
- this.httpClientColoring = new config_system_1.BooleanConfigKey(false, false);
33
- this.useInitialColor = new config_system_1.BooleanConfigKey(false, true);
34
- this.gzip = new config_system_1.BooleanConfigKey(false, true);
35
- this.useIstanbul = new config_system_1.BooleanConfigKey(false, false);
36
- this.enableChildProcessPatcher = new config_system_1.BooleanConfigKey(false, false);
37
- /**
38
- * Comma-separated list of loggers. Available: console, file
39
- */
40
- this.loggers = new config_system_1.StringConfigKey(false, '');
41
- /**
42
- * Port number for coloring
43
- * */
44
- this.httpListeningPort = new config_system_1.NumberConfigKey(false, 0);
45
- this.useFootprintsV3 = new config_system_1.BooleanConfigKey(false, true);
46
- this.extendedFootprints = new config_system_1.BooleanConfigKey(false, false);
47
- }
48
- }
49
- exports.AgentConfig = AgentConfig;
50
- class AgentConfigWithRuntimeArgs extends AgentConfig {
51
- constructor() {
52
- super(...arguments);
53
- /**
54
- * Path to config file
55
- *
56
- * @memberOf AgentConfigWithRuntimeArgs
57
- */
58
- this.cfg = new config_system_1.StringConfigKey(false);
59
- }
60
- }
61
- exports.AgentConfigWithRuntimeArgs = AgentConfigWithRuntimeArgs;
62
- //# sourceMappingURL=config.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../../test-listener/config.ts"],"names":[],"mappings":";;;AAAA,kEAAuH;AAEvH,MAAa,WAAY,SAAQ,iCAAiB;IAAlD;;QACI;;;;WAIG;QACI,UAAK,GAAG,IAAI,+BAAe,CAAC,KAAK,CAAC,CAAC;QAEnC,cAAS,GAAG,IAA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AI,CAAC,CAAC;QAEpD,SAAI,GAAG,IAAI,gCAAgB,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QAEzC,gBAAW,GAAG,IAAI,gCAAgB,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QAEjD,8BAAyB,GAAG,IAAI,gCAAgB,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QAEtE;;WAEG;QACI,YAAO,GAAG,IAAI,+BAAe,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QAEhD;;YAEI;QACG,sBAAiB,GAAG,IAAI,+BAAe,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QAElD,oBAAe,GAAG,IAAI,gCAAgB,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QAEpD,uBAAkB,GAAG,IAAI,gCAAgB,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IAEnE,CAAC;CAAA;AApED,kCAoEC;AAED,MAAa,0BAA2B,SAAQ,WAAW;IAA3D;;QACI;;;;WAIG;QACI,QAAG,GAAG,IAAI,+BAAe,CAAC,KAAK,CAAC,CAAC;IAC5C,CAAC;CAAA;AAPD,gEAOC"}
@@ -1,11 +0,0 @@
1
- import { AgentConfig } from './config';
2
- /**
3
- * The service is used to get environmental data for submission (process id, machine data, etc.)
4
- */
5
- export declare class EnvironmentDataService {
6
- private cfg;
7
- constructor(cfg: AgentConfig);
8
- private envData;
9
- getEnvDataForSubmission(): any;
10
- setLastError(message: string): void;
11
- }
@@ -1,60 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EnvironmentDataService = void 0;
4
- const os = require("os");
5
- const version = process.env.npm_package_version;
6
- function clone(o) {
7
- //if (!o) return o; //Unreachable
8
- return JSON.parse(JSON.stringify(o));
9
- }
10
- /**
11
- * The service is used to get environmental data for submission (process id, machine data, etc.)
12
- */
13
- class EnvironmentDataService {
14
- constructor(cfg) {
15
- this.cfg = cfg;
16
- this.envData = null;
17
- if (!cfg)
18
- throw new Error('cfg is required');
19
- this.envData = {
20
- machineName: os.hostname(),
21
- platform: os.platform(),
22
- processArgv: process.argv,
23
- os: os.type(),
24
- osVersion: os.release(),
25
- arch: os.arch(),
26
- processId: process.pid,
27
- ipAddress: clone(os.networkInterfaces()),
28
- dependencies: clone(process.versions),
29
- runtime: process.version,
30
- agentType: 'nodejs',
31
- agentVersion: version,
32
- };
33
- if (cfg && cfg.environmentName.hasValue) {
34
- this.envData.environmentName = cfg.environmentName.value;
35
- }
36
- if (cfg && cfg.labId.hasValue) {
37
- this.envData.labId = cfg.labId.value;
38
- }
39
- if (cfg && cfg.testStage.hasValue) {
40
- this.envData.testStage = cfg.testStage.value;
41
- }
42
- }
43
- getEnvDataForSubmission() {
44
- const returnedEnvData = clone(this.envData);
45
- returnedEnvData.memory = {
46
- process: process.memoryUsage(),
47
- machine: {
48
- freemem: os.freemem(),
49
- totalmem: os.totalmem(),
50
- },
51
- };
52
- this.setLastError(null);
53
- return returnedEnvData;
54
- }
55
- setLastError(message) {
56
- this.envData.lastError = message;
57
- }
58
- }
59
- exports.EnvironmentDataService = EnvironmentDataService;
60
- //# sourceMappingURL=environment-data-service.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"environment-data-service.js","sourceRoot":"","sources":["../../test-listener/environment-data-service.ts"],"names":[],"mappings":";;;AACA,yBAA0B;AAC1B,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC;AAEhD,SAAS,KAAK,CAAI,CAAI;IAClB,iCAAiC;IACjC,OAAU,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;AAC5C,CAAC;AAED;;GAEG;AACH,MAAa,sBAAsB;IAC/B,YAA2B,GAAgB;QAAhB,QAAG,GAAH,GAAG,CAAa;QA2BnC,YAAO,GAAQ,IAAI,CAAC;QA1BxB,IAAI,CAAC,GAAG;YAAE,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CA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AAQ,EAAE;aAC1B;SACJ,CAAC;QACF,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;QACxB,OAAO,eAAe,CAAC;IAC3B,CAAC;IAEM,YAAY,CAAC,OAAe;QAC/B,IAAI,CAAC,OAAO,CAAC,SAAS,GAAG,OAAO,CAAC;IACrC,CAAC;CACJ;AA9CD,wDA8CC"}
@@ -1,36 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FootprintsServiceProxy = void 0;
4
- const base_proxy_1 = require("../base-proxy");
5
- const messages_formatter_1 = require("../../common/messages-formatter");
6
- class FootprintsServiceProxy extends base_proxy_1.BaseProxy {
7
- constructor(cfg, request, logger) {
8
- super(cfg, request, logger);
9
- }
10
- submitFootprints(packetToSend, callback) {
11
- if (!packetToSend) {
12
- this.logger.info('Submit footprints - got null or empty packet. Skip submitting.');
13
- return;
14
- }
15
- const bufferToSend = new Buffer(JSON.stringify(packetToSend));
16
- const hitFiles = this.getHitFiles(packetToSend);
17
- this.logger.debug(`Submitting footprints, tests: ${JSON.stringify(packetToSend.tests)}`);
18
- this.logger.debug(`Submitting footprints, files: ${hitFiles}`);
19
- const url = '/v5/agents/footprints';
20
- this.post(bufferToSend, url, callback);
21
- }
22
- getHitFiles(packetToSend) {
23
- if (!this.logger.isDebugEnabled()) {
24
- return;
25
- }
26
- const formatter = new messages_formatter_1.MessagesFormatter();
27
- if (packetToSend && packetToSend.apps && packetToSend.apps[0] && packetToSend.apps[0].files) {
28
- packetToSend.apps[0].files.forEach((file) => {
29
- formatter.addContent(file.path);
30
- });
31
- }
32
- return formatter.content;
33
- }
34
- }
35
- exports.FootprintsServiceProxy = FootprintsServiceProxy;
36
- //# sourceMappingURL=footprints-service-proxy.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"footprints-service-proxy.js","sourceRoot":"","sources":["../../../test-listener/footprints-process/footprints-service-proxy.ts"],"names":[],"mappings":";;;AAAA,8CAA0C;AAI1C,wEAAk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,CAAC;YACpC,CAAC,CAAC,CAAC;SACN;QACD,OAAO,SAAS,CAAC,OAAO,CAAC;IAC7B,CAAC;CACJ;AA5BD,wDA4BC"}
@@ -1,226 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FootprintsProcess = void 0;
4
- const queue_1 = require("../queue");
5
- const system_date_1 = require("../../common/system-date");
6
- class FootprintsProcess {
7
- constructor(
8
- /**
9
- * Initial configuration
10
- */
11
- cfg,
12
- /**
13
- * Background thread that tells the footprints service to send footprints from the queue to the server
14
- */
15
- sendToServerWatchdog,
16
- /**
17
- * Foreground thread that prevents the process from shutting down, and kept alive while there are items to submit to the server or items are currently being submitted
18
- */
19
- keepaliveWatchdog,
20
- /**
21
- * Configuration process that periodically refreshes server-sent configuration
22
- */
23
- configProcess,
24
- /**
25
- * Proxy to the server for footprints submission
26
- */
27
- footprintsServiceProxy,
28
- /**
29
- * Environments service, used to get environmental data for submission (process id, machine data, etc.)
30
- */
31
- environmentDataService, agentInstanceData, istanbulToFootprints, logger) {
32
- this.cfg = cfg;
33
- this.sendToServerWatchdog = sendToServerWatchdog;
34
- this.keepaliveWatchdog = keepaliveWatchdog;
35
- this.configProcess = configProcess;
36
- this.footprintsServiceProxy = footprintsServiceProxy;
37
- this.environmentDataService = environmentDataService;
38
- this.agentInstanceData = agentInstanceData;
39
- this.istanbulToFootprints = istanbulToFootprints;
40
- this.logger = logger;
41
- this.isSubmittingFootprints = false;
42
- this.sequence = 0;
43
- this.isRunning = false;
44
- this.stopCallbacks = [];
45
- if (!cfg)
46
- throw new Error('cfg was not specified');
47
- if (!sendToServerWatchdog)
48
- throw new Error('sendToServerWatchdog was not specified');
49
- if (!keepaliveWatchdog)
50
- throw new Error('keepaliveWatchdog was not specified');
51
- if (!configProcess)
52
- throw new Error('configProcess was not specified');
53
- if (!footprintsServiceProxy)
54
- throw new Error('footprintsServiceProxy was not specified');
55
- if (!environmentDataService)
56
- throw new Error('environmentDataService was not specified');
57
- if (!agentInstanceData)
58
- throw new Error('agentInstanceData was not specified');
59
- if (!istanbulToFootprints)
60
- throw new Error('istanbulToFootprints was not specified');
61
- if (!logger) {
62
- throw new Error('logger was not specified');
63
- }
64
- this.footprintsQueue = new queue_1.Queue();
65
- sendToServerWatchdog.on('alarm', () => {
66
- this.logger.debug('Start submitting footprints, triggered by send to server watchdog.');
67
- this.submitQueuedFootprints();
68
- });
69
- configProcess.on('configuration_changed', (cfg) => {
70
- this.updateConfig(cfg);
71
- });
72
- this.footprintsQueue.on('full', () => {
73
- this.logger.debug('Start submitting footprints, queue is full.');
74
- this.submitQueuedFootprints();
75
- });
76
- keepaliveWatchdog.on('alarm', () => {
77
- //console.log('keepaliveWatchdog. isSubmittingFootprints:' + this.isSubmittingFootprints + ', queue size: ' + this.footprintsQueue.getQueueSize());
78
- if (!this.isSubmittingFootprints && this.footprintsQueue.getQueueSize() == 0) {
79
- keepaliveWatchdog.stop();
80
- }
81
- });
82
- }
83
- enqueueCurrentFootprints(executionId, testName) {
84
- const footprints = this.istanbulToFootprints.getCurrentFootprints();
85
- const hitModules = Object.keys(footprints);
86
- if (!hitModules || hitModules.length == 0) { //If no modules were hit at all, don't enqueue anything
87
- this.logger.info('No files were hit, not enqueuing footprints.');
88
- return;
89
- }
90
- this.logger.info(`Enqueuing footprints for ${hitModules.length} files.`);
91
- this.footprintsQueue.enqueue({
92
- executionId: executionId,
93
- testName: testName,
94
- footprints: footprints,
95
- localTime: (0, system_date_1.getSystemDateValueOf)()
96
- });
97
- if (this.isRunning && this.cfg.sendFootprints.value && this.cfg.enabled.value) {
98
- this.ensureKeepaliveThreadRunning();
99
- this.sendToServerWatchdog.start();
100
- }
101
- }
102
- ensureKeepaliveThreadRunning() {
103
- this.keepaliveWatchdog.start();
104
- }
105
- updateConfig(updatedCfg) {
106
- if (updatedCfg.sendFootprints.value === false || updatedCfg.enabled.value === false) {
107
- this.footprintsQueue.clear();
108
- this.stop(() => { });
109
- }
110
- this.cfg = updatedCfg;
111
- this.sendToServerWatchdog.setInterval(this.cfg.interval.value);
112
- }
113
- createFootprintsPacket(items) {
114
- const packet = this.istanbulToFootprints.createFootprintsPackageForSending(items, {
115
- customerId: this.cfg.customerId.value,
116
- environment: this.environmentDataService.getEnvDataForSubmission(),
117
- configurationData: this.cfg.toJsonObject(),
118
- meta: {
119
- sequence: ++this.sequence,
120
- generated: (0, system_date_1.getSystemDateValueOf)(),
121
- agentId: this.agentInstanceData.agentId
122
- },
123
- tests: [],
124
- apps: []
125
- });
126
- return packet;
127
- }
128
- submitQueuedFootprints() {
129
- if (!this.isRunning) {
130
- this.logger.info('Agent is not running, not sending footprints');
131
- return;
132
- }
133
- if (this.cfg.sendFootprints.value === false) {
134
- this.logger.info('Not sending footprints since agent is configured to not send.');
135
- return; //Can't start without server or token
136
- }
137
- if (this.isSubmittingFootprints) {
138
- this.logger.info('Not sending footprints since its already submitting.');
139
- return;
140
- }
141
- if (this.footprintsQueue.getQueueSize() == 0) {
142
- this.logger.info('Not sending footprints since queue size is 0');
143
- return;
144
- }
145
- this.logger.info('About to send footprints. Queue size:' + this.footprintsQueue.getQueueSize());
146
- const items = this.footprintsQueue.dequeue(/*this.cfg.maxFootprintsChunkSize ||*/ 1000);
147
- const packet = this.createFootprintsPacket(items);
148
- this.isSubmittingFootprints = true;
149
- this.footprintsServiceProxy.submitFootprints(packet, (err) => {
150
- this.isSubmittingFootprints = false;
151
- this.logger.info('Sent footprints. Queue size:' + this.footprintsQueue.getQueueSize() + ', err:' + err);
152
- if (err) {
153
- this.environmentDataService.setLastError(err.stack);
154
- this.footprintsQueue.requeue(items); //Requeue items for later submission
155
- }
156
- else if (this.footprintsQueue.getQueueSize() > 0) { //If there was an error, don't send now. Otherwise, if the queue still has items, send those now
157
- this.submitQueuedFootprints();
158
- }
159
- else
160
- this.fireQueueEmpty();
161
- });
162
- }
163
- fireQueueEmpty() {
164
- if (this.stopCallbacks.length > 0) {
165
- this.stopCallbacks.forEach((cb) => {
166
- try {
167
- cb();
168
- }
169
- catch (err) {
170
- this.environmentDataService.setLastError(err.stack);
171
- }
172
- });
173
- }
174
- }
175
- start() {
176
- if (this.isRunning)
177
- return; //Already started
178
- if (this.cfg.enabled.value == false)
179
- return; //Don't do anything if agent is completely disabled
180
- this.isRunning = true;
181
- this.sendToServerWatchdog.start();
182
- if (this.footprintsQueue.getQueueSize() > 0) {
183
- this.ensureKeepaliveThreadRunning();
184
- }
185
- }
186
- stop(callback) {
187
- try {
188
- this.sendToServerWatchdog.stop();
189
- if (this.cfg.enabled.value === false || this.cfg.sendFootprints.value === false) { //Footprints/Agent functionality is disabled. Return immediately
190
- this.isRunning = false;
191
- return callback();
192
- }
193
- this.logger.debug('Start submitting footprints, triggered by stop event.');
194
- this.submitQueuedFootprints(); //If footprints are being submitted, this has no effect. Otherwise, it will start submitting footprints if the queue is non-empty
195
- if (this.isSubmittingFootprints) {
196
- /*
197
- Nothing to do right now, since footprints are being submitted
198
- When the submission is over (successfully or not), if the queue is empty the next batch of footprints will be sent.
199
- If after submission the queue is cleared, this callback will be called
200
- */
201
- this.stopCallbacks.push(() => {
202
- this.isRunning = false;
203
- this.keepaliveWatchdog.stop();
204
- return callback();
205
- });
206
- }
207
- else {
208
- /*
209
- Queue must be empty, and nothing is sent. submitQueuedFootprints() would have started sending footprints if the queue was non-empty
210
- */
211
- this.isRunning = false;
212
- this.keepaliveWatchdog.stop();
213
- return callback();
214
- }
215
- }
216
- catch (err) {
217
- //TODO: log
218
- return callback();
219
- }
220
- }
221
- getQueueSize() {
222
- return this.footprintsQueue.getQueueSize();
223
- }
224
- }
225
- exports.FootprintsProcess = FootprintsProcess;
226
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../test-listener/footprints-process/index.ts"],"names":[],"mappings":";;;AAGA,oCAAiC;AAMjC,0DAA8D;AAG9D,MAAa,iBAAiB;IAC1B;IACI;;OAEG;IACK,GAAgB;IACxB;;OAEG;I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require("path");
5
- const messages_formatter_1 = require("../../common/messages-formatter");
6
- const GLOBAL_ISTANBUL_CONTAINER_NAMES = ['__coverage__'];
7
- function newNumberArray(length) {
8
- const arr = [];
9
- for (let i = 0; i < length; i++)
10
- arr.push(0);
11
- return arr;
12
- }
13
- class IstanbulToFootprintsBase {
14
- constructor(logger) {
15
- this.previousIstanbulCounters = {};
16
- this.relativeModulePaths = {};
17
- this.logger = logger;
18
- }
19
- getIstanbulCounters() {
20
- if (this.globalCoverageContainer)
21
- return this.globalCoverageContainer;
22
- const re = /^\$\$cov_[0-9]+\$\$$/;
23
- const keys = Object.keys(global);
24
- if (this.logger.isDebugEnabled()) {
25
- this.logger.debug('The \'global\' object contains the following keys:\n\t' + keys.join('\n\t'));
26
- }
27
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
28
- for (let i = 0; i < keys.length; i++) {
29
- const k = keys[i];
30
- if ((re.exec(k)) !== null || GLOBAL_ISTANBUL_CONTAINER_NAMES.indexOf(k) >= 0) {
31
- this.globalCoverageContainer = global[k];
32
- return this.globalCoverageContainer;
33
- }
34
- }
35
- return null;
36
- }
37
- getRelativeModulePath(module) {
38
- if (!this.relativeModulePaths[module.path]) {
39
- this.relativeModulePaths[module.path] = path.relative(process.cwd(), module.path).replace(/\\/g, '/');
40
- }
41
- return this.relativeModulePaths[module.path];
42
- }
43
- formatLoc(loc) {
44
- return loc.line + ',' + loc.column;
45
- }
46
- getCurrentFootprints() {
47
- const diff = this.getIstanbulCountersDiff(this.getIstanbulCounters());
48
- return diff;
49
- }
50
- getIstanbulCountersDiff(currentCounters) {
51
- if (!currentCounters) {
52
- this.logger.error('Couldn\'t get istanbul counters, return empty diff.');
53
- return {};
54
- }
55
- const diff = {};
56
- let diffModule = null;
57
- function createModuleForDiff(istanbulModule) {
58
- diffModule = diff[istanbulModule] = { b: {}, f: {}, s: {} };
59
- return diffModule;
60
- }
61
- const prevCounters = this.previousIstanbulCounters;
62
- for (const istanbulModule in currentCounters) {
63
- diffModule = null;
64
- if (!prevCounters[istanbulModule]) {
65
- prevCounters[istanbulModule] = { b: {}, f: {}, s: {} };
66
- }
67
- const prevModule = prevCounters[istanbulModule];
68
- for (const funcId in currentCounters[istanbulModule].f) {
69
- if (prevModule.f[funcId] === undefined) {
70
- prevModule.f[funcId] = 0;
71
- }
72
- const currentFunctionHits = currentCounters[istanbulModule].f[funcId];
73
- const prevFunctionHits = prevModule.f[funcId] || 0;
74
- if (currentFunctionHits > prevFunctionHits) {
75
- //this is a diff
76
- diffModule = diffModule || createModuleForDiff(istanbulModule);
77
- diffModule.f[funcId] = (currentFunctionHits - prevFunctionHits);
78
- prevModule.f[funcId] = currentFunctionHits;
79
- }
80
- }
81
- for (const branchId in currentCounters[istanbulModule].b) {
82
- const currentBranchesHits = currentCounters[istanbulModule].b[branchId];
83
- const prevBranchHits = prevModule.b[branchId];
84
- if (prevBranchHits) {
85
- for (let i = 0, j = currentBranchesHits.length; i < j; i++) {
86
- const currentHits = currentBranchesHits[i], previousHits = prevBranchHits[i] || 0;
87
- if (currentHits > previousHits) {
88
- //this is a diff
89
- diffModule = diffModule || createModuleForDiff(istanbulModule);
90
- diffModule.b[branchId] = diffModule.b[branchId] || newNumberArray(currentBranchesHits.length);
91
- diffModule.b[branchId][i] = currentHits - previousHits;
92
- prevBranchHits[i] = currentHits;
93
- }
94
- }
95
- }
96
- else {
97
- prevModule.b[branchId] = currentBranchesHits.slice();
98
- let branchSetHasHits = false;
99
- for (let i = 0, j = currentBranchesHits.length; i < j && !branchSetHasHits; i++) {
100
- if (currentBranchesHits[i])
101
- branchSetHasHits = true;
102
- }
103
- if (branchSetHasHits) {
104
- diffModule = diffModule || createModuleForDiff(istanbulModule);
105
- diffModule.b[branchId] = currentBranchesHits.slice();
106
- }
107
- }
108
- }
109
- }
110
- this.logDiff(diff);
111
- return diff;
112
- }
113
- logDiff(diff) {
114
- if (!this.logger.isDebugEnabled()) {
115
- return;
116
- }
117
- const modules = Object.keys(diff);
118
- const formatter = new messages_formatter_1.MessagesFormatter();
119
- modules.forEach((module) => {
120
- const methods = diff[module].f || {};
121
- const branches = diff[module].b || {};
122
- const methodsSize = Object.keys(methods).length;
123
- const branchesSize = Object.keys(branches).length;
124
- formatter.addContent(`${module}: ${methodsSize} methods and ${branchesSize} branches`);
125
- });
126
- this.logger.debug(`Found coverage data for ${modules.length} files:\n ${formatter.content}`);
127
- }
128
- }
129
- exports.IstanbulToFootprintsBase = IstanbulToFootprintsBase;
130
- //# sourceMappingURL=istanbul-to-footprints-base.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"istanbul-to-footprints-base.js","sourceRoot":"","sources":["../../../test-listener/footprints-process/istanbul-to-footprints-base.ts"],"names":[],"mappings":";;;AAEA,6BAA8B;AAC9B,wEAAkE;AAGlE,MAAM,+BAA+B,GAAG,CAAC,cAAc,CAAC,CAAC;AAEzD,SAAS,cAAc,CAAC,MAAc;IAClC,MAAM,GAAG,GAAG,EAAE,CAAC;IACf,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC,EAAE;QAC3B,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAChB,OAAO,GAAG,CAAC;AACf,CAAC;AAED,MAAsB,wBAAwB;IAM1C,YAAY,MAAc;QAJlB,6BAAwB,GAA4B,EAAE,CAAC;QA4BvD,wBAAmB,GAA+B,EAAE,CAAC;QAvBzD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACzB,CAAC;IAIS,mBAAmB;QACzB,IAAI,IAAI,CAAC,uBAAuB;YAAE,OAAO,IAAI,CAAC,uBAAuB,CAAC;QACtE,MAAM,EAAE,GAAG,sBAAsB,CAAC;QAClC,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACjC,IAAI,IAAI,CAAC,MAAM,CAAC,cAAc,EAAE,EAAC;YAC7B,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,wDAAwD,GAAG,IAAI,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E,CAAC,CAAC;IAEjG,CAAC;CACJ;AAtID,4DAsIC"}
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=istanbul-to-footprints-contract.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"istanbul-to-footprints-contract.js","sourceRoot":"","sources":["../../../test-listener/footprints-process/istanbul-to-footprints-contract.ts"],"names":[],"mappings":""}