@appland/scanner 1.74.0 → 1.74.2
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/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
# [@appland/scanner-v1.74.2](https://github.com/getappmap/appmap-js/compare/@appland/scanner-v1.74.1...@appland/scanner-v1.74.2) (2022-12-16)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* Don't let scanner crash on EACCES error ([e542d9b](https://github.com/getappmap/appmap-js/commit/e542d9b3270011ab1788ef95d8c8bc059c2d9d3b))
|
|
7
|
+
|
|
8
|
+
# [@appland/scanner-v1.74.1](https://github.com/getappmap/appmap-js/compare/@appland/scanner-v1.74.0...@appland/scanner-v1.74.1) (2022-12-16)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* Disable file watching on "ENOSPC: System limit for number of file watchers reached" ([e51b423](https://github.com/getappmap/appmap-js/commit/e51b4236384ae0ea2cde0bd79b739f7821ca30c1))
|
|
14
|
+
* Enable scan:completed telemetry ([6e20d73](https://github.com/getappmap/appmap-js/commit/6e20d7305fd86bd077c88f674615edb31854a11a))
|
|
15
|
+
* Send telemetry for scan:watcher_error:enospc and index:watcher_error:enospc ([989db4a](https://github.com/getappmap/appmap-js/commit/989db4a40db8338613afe182be25b0315df94316))
|
|
16
|
+
|
|
1
17
|
# [@appland/scanner-v1.74.0](https://github.com/getappmap/appmap-js/compare/@appland/scanner-v1.73.1...@appland/scanner-v1.74.0) (2022-12-07)
|
|
2
18
|
|
|
3
19
|
|
|
@@ -47,6 +47,7 @@ const scanner_1 = __importDefault(require("./scanner"));
|
|
|
47
47
|
const configurationProvider_1 = require("../../configuration/configurationProvider");
|
|
48
48
|
const telemetry_1 = __importDefault(require("../../telemetry"));
|
|
49
49
|
const events_1 = __importDefault(require("events"));
|
|
50
|
+
const watchScanTelemetry_1 = require("./watchScanTelemetry");
|
|
50
51
|
function isDir(targetPath) {
|
|
51
52
|
return __awaiter(this, void 0, void 0, function* () {
|
|
52
53
|
try {
|
|
@@ -77,6 +78,7 @@ class Watcher {
|
|
|
77
78
|
// do not remove callbackify, apparently on windows
|
|
78
79
|
// passing plain async function doesn't work (?)
|
|
79
80
|
this.queue = (0, async_1.queue)((0, node_util_1.callbackify)(this.scan.bind(this)), 2);
|
|
81
|
+
watchScanTelemetry_1.WatchScanTelemetry.watch(this.scanEventEmitter);
|
|
80
82
|
}
|
|
81
83
|
watch() {
|
|
82
84
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -109,6 +111,7 @@ class Watcher {
|
|
|
109
111
|
this.appmapWatcher = chokidar.watch(watchDir, {
|
|
110
112
|
ignoreInitial: true,
|
|
111
113
|
ignored,
|
|
114
|
+
ignorePermissionErrors: true,
|
|
112
115
|
});
|
|
113
116
|
this.appmapPoller = chokidar.watch(watchDir, {
|
|
114
117
|
ignoreInitial: false,
|
|
@@ -118,8 +121,35 @@ class Watcher {
|
|
|
118
121
|
persistent: false,
|
|
119
122
|
});
|
|
120
123
|
const enqueue = (filePath) => path_1.default.basename(filePath) === 'mtime' && this.enqueue(filePath);
|
|
121
|
-
|
|
122
|
-
|
|
124
|
+
this.appmapPoller.on('add', enqueue).on('change', enqueue);
|
|
125
|
+
this.appmapWatcher
|
|
126
|
+
.on('add', enqueue)
|
|
127
|
+
.on('change', enqueue)
|
|
128
|
+
.on('error', this.watcherErrorFunction.bind(this));
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
watcherErrorFunction(error) {
|
|
132
|
+
var _a;
|
|
133
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
134
|
+
if (this.appmapWatcher &&
|
|
135
|
+
error.message.includes('ENOSPC: System limit for number of file watchers reached')) {
|
|
136
|
+
console.warn(error.stack);
|
|
137
|
+
console.warn('Will disable file watching. File polling will stay enabled.');
|
|
138
|
+
yield ((_a = this.appmapWatcher) === null || _a === void 0 ? void 0 : _a.close());
|
|
139
|
+
this.appmapWatcher = undefined;
|
|
140
|
+
console.warn('File watching disabled.');
|
|
141
|
+
telemetry_1.default.sendEvent({
|
|
142
|
+
name: `scan:watcher_error:enospc`,
|
|
143
|
+
properties: {
|
|
144
|
+
errorMessage: error.message,
|
|
145
|
+
errorStack: error.stack,
|
|
146
|
+
},
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
// let it crash if it's some other error, to learn what the error is
|
|
151
|
+
throw error;
|
|
152
|
+
}
|
|
123
153
|
});
|
|
124
154
|
}
|
|
125
155
|
close() {
|
|
@@ -8,11 +8,20 @@ const eventAggregator_1 = __importDefault(require("../../lib/eventAggregator"));
|
|
|
8
8
|
const scanResults_1 = require("../../report/scanResults");
|
|
9
9
|
class WatchScanTelemetry {
|
|
10
10
|
constructor(scanEvents) {
|
|
11
|
-
new eventAggregator_1.default((events) => {
|
|
11
|
+
this.cancelFn = new eventAggregator_1.default((events) => {
|
|
12
12
|
const scanEvents = events.map((e) => e.arg);
|
|
13
13
|
this.sendTelemetry(scanEvents);
|
|
14
14
|
}).attach(scanEvents, 'scan');
|
|
15
15
|
}
|
|
16
|
+
cancel() {
|
|
17
|
+
if (this.cancelFn)
|
|
18
|
+
this.cancelFn();
|
|
19
|
+
this.cancelFn = undefined;
|
|
20
|
+
}
|
|
21
|
+
static watch(scanEvents) {
|
|
22
|
+
const telemetry = new WatchScanTelemetry(scanEvents);
|
|
23
|
+
return () => telemetry.cancel();
|
|
24
|
+
}
|
|
16
25
|
sendTelemetry(scanEvents) {
|
|
17
26
|
const ruleIds = new Set();
|
|
18
27
|
let elapsed = 0;
|
|
@@ -30,7 +30,11 @@ class EventAggregator {
|
|
|
30
30
|
this.pending = [];
|
|
31
31
|
}
|
|
32
32
|
attach(emitter, event) {
|
|
33
|
-
|
|
33
|
+
const listenerFn = (...args) => {
|
|
34
|
+
this.push(emitter, event, args[0]);
|
|
35
|
+
};
|
|
36
|
+
emitter.addListener(event, listenerFn);
|
|
37
|
+
return () => emitter.removeListener(event, listenerFn);
|
|
34
38
|
}
|
|
35
39
|
}
|
|
36
40
|
exports.default = EventAggregator;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@appland/scanner",
|
|
3
|
-
"version": "1.74.
|
|
3
|
+
"version": "1.74.2",
|
|
4
4
|
"description": "Analyze AppMaps for code flaws",
|
|
5
5
|
"bin": "built/cli.js",
|
|
6
6
|
"files": [
|
|
@@ -20,7 +20,8 @@
|
|
|
20
20
|
"lint": "eslint src --ext .ts",
|
|
21
21
|
"ci": "yarn lint && yarn build && yarn schema-up-to-date && yarn doc-up-to-date && yarn test",
|
|
22
22
|
"test": "jest --filter=./test/testFilter.js",
|
|
23
|
-
"semantic-release": "semantic-release"
|
|
23
|
+
"semantic-release": "semantic-release",
|
|
24
|
+
"watch": "node bin/preBuild.js && tsc -p tsconfig.build.json --watch"
|
|
24
25
|
},
|
|
25
26
|
"author": "AppLand, Inc.",
|
|
26
27
|
"license": "Commons Clause + MIT",
|
|
@@ -61,7 +62,7 @@
|
|
|
61
62
|
"dependencies": {
|
|
62
63
|
"@appland/client": "^1.5.0",
|
|
63
64
|
"@appland/models": "^1.18.1",
|
|
64
|
-
"@appland/openapi": "1.
|
|
65
|
+
"@appland/openapi": "1.3.0",
|
|
65
66
|
"@appland/sql-parser": "^1.5.0",
|
|
66
67
|
"@types/cli-progress": "^3.9.2",
|
|
67
68
|
"ajv": "^8.8.2",
|