@appland/scanner 1.86.0 → 1.87.1

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,17 @@
1
+ # [@appland/scanner-v1.87.1](https://github.com/getappmap/appmap-js/compare/@appland/scanner-v1.87.0...@appland/scanner-v1.87.1) (2024-07-25)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * conditionally create sql_warnings.txt ([737f59f](https://github.com/getappmap/appmap-js/commit/737f59f323b3c9300bc6985cb179fa7264c8f7fd))
7
+
8
+ # [@appland/scanner-v1.87.0](https://github.com/getappmap/appmap-js/compare/@appland/scanner-v1.86.0...@appland/scanner-v1.87.0) (2024-04-30)
9
+
10
+
11
+ ### Features
12
+
13
+ * Build scanner binary packages with Node 18 ([37c939b](https://github.com/getappmap/appmap-js/commit/37c939b7b3e19a098bfe81d2e5a66bacb413f6e3))
14
+
1
15
  # [@appland/scanner-v1.86.0](https://github.com/getappmap/appmap-js/compare/@appland/scanner-v1.85.0...@appland/scanner-v1.86.0) (2023-12-28)
2
16
 
3
17
 
package/LICENSE.txt CHANGED
@@ -12,7 +12,7 @@ Software: @appland/scanner
12
12
 
13
13
  License: MIT License
14
14
 
15
- Copyright 2023, AppLand Inc
15
+ Copyright 2024, AppLand Inc
16
16
 
17
17
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
18
18
  to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
@@ -106,20 +106,7 @@ class RuleChecker {
106
106
  if (!checkInstance.filterEvent(event, appMapIndex)) {
107
107
  return;
108
108
  }
109
- let appmapConfigDir;
110
- {
111
- let searchDir = (0, path_1.dirname)((0, path_1.resolve)(appMapFileName));
112
- while (!appmapConfigDir) {
113
- if (yield (0, util_1.fileExists)((0, path_1.join)(searchDir, 'appmap.yml'))) {
114
- appmapConfigDir = searchDir;
115
- }
116
- else {
117
- if ((0, path_1.dirname)(searchDir) === searchDir)
118
- break;
119
- searchDir = (0, path_1.dirname)(searchDir);
120
- }
121
- }
122
- }
109
+ const appmapConfigDir = yield findConfigDir(appMapFileName);
123
110
  const resolvePath = (path) => __awaiter(this, void 0, void 0, function* () {
124
111
  const candidates = [path];
125
112
  if (appmapConfigDir)
@@ -272,3 +259,26 @@ class RuleChecker {
272
259
  }
273
260
  }
274
261
  exports.default = RuleChecker;
262
+ const configDirs = new Map();
263
+ function findConfigDir(appMapFileName) {
264
+ return __awaiter(this, void 0, void 0, function* () {
265
+ if (configDirs.has(appMapFileName))
266
+ return configDirs.get(appMapFileName);
267
+ let appmapConfigDir;
268
+ {
269
+ let searchDir = (0, path_1.dirname)((0, path_1.resolve)(appMapFileName));
270
+ while (!appmapConfigDir) {
271
+ if (yield (0, util_1.fileExists)((0, path_1.join)(searchDir, 'appmap.yml'))) {
272
+ appmapConfigDir = searchDir;
273
+ }
274
+ else {
275
+ if ((0, path_1.dirname)(searchDir) === searchDir)
276
+ break;
277
+ searchDir = (0, path_1.dirname)(searchDir);
278
+ }
279
+ }
280
+ }
281
+ configDirs.set(appMapFileName, appmapConfigDir);
282
+ return appmapConfigDir;
283
+ });
284
+ }
@@ -25,4 +25,5 @@ checks:
25
25
  - rule: too-many-updates
26
26
  # - rule: unbatched-materialized-query
27
27
  - rule: unauthenticated-encryption
28
+ - rule: unfulfilled-promise
28
29
  - rule: update-in-get-request
@@ -17,12 +17,22 @@ function writeErrorToFile(error) {
17
17
  return __awaiter(this, void 0, void 0, function* () {
18
18
  const flags = SqlParseErrorFileOpened ? 'a' : 'w';
19
19
  SqlParseErrorFileOpened = true;
20
- (0, promises_1.open)(SqlParseErrorFileName, flags).then((handle) => {
21
- handle.write([error.toString(), ''].join('\n')).finally(handle.close.bind(handle));
22
- });
20
+ const msg = [String(error), ''].join('\n');
21
+ try {
22
+ (0, promises_1.open)(SqlParseErrorFileName, flags).then((handle) => {
23
+ handle.write([error.toString(), ''].join('\n')).finally(handle.close.bind(handle));
24
+ });
25
+ }
26
+ catch (e) {
27
+ console.warn(e);
28
+ console.warn(`SQL Error: ${msg}`);
29
+ }
23
30
  });
24
31
  }
25
32
  function sqlWarning(parseError) {
33
+ if (!process.env['APPMAP_SQL_WARNING']) {
34
+ return;
35
+ }
26
36
  if (!SqlErrors.has(parseError.sql)) {
27
37
  writeErrorToFile(parseError);
28
38
  SqlErrors.add(parseError.sql);
@@ -368,12 +368,14 @@ class GitProperties {
368
368
  }
369
369
  }
370
370
  const gitCache = new Map();
371
+ const noCacheList = ['clearCache'];
371
372
  // GitProperties is available externally as Git.
372
373
  // This export provides a simple caching layer around GitProperties to avoid
373
374
  // excessive shelling out to git.
374
375
  exports.Git = new Proxy(GitProperties, {
375
376
  get(target, prop) {
376
- if (typeof target[prop] === 'function') {
377
+ if (!noCacheList.includes(prop.toString()) &&
378
+ typeof target[prop] === 'function') {
377
379
  return new Proxy(target[prop], {
378
380
  apply(target, thisArg, argArray) {
379
381
  const cacheKey = `${prop.toString()}(${JSON.stringify(argArray)})`;
@@ -382,12 +384,7 @@ exports.Git = new Proxy(GitProperties, {
382
384
  }
383
385
  /* eslint-disable-next-line @typescript-eslint/ban-types */
384
386
  const result = Reflect.apply(target, thisArg, argArray);
385
- if (result instanceof Promise) {
386
- return result.then((r) => {
387
- gitCache.set(cacheKey, r);
388
- return r;
389
- });
390
- }
387
+ gitCache.set(cacheKey, result);
391
388
  return result;
392
389
  },
393
390
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appland/scanner",
3
- "version": "1.86.0",
3
+ "version": "1.87.1",
4
4
  "description": "Analyze AppMaps for code flaws",
5
5
  "bin": "built/cli.js",
6
6
  "main": "built/index.js",
@@ -19,7 +19,7 @@
19
19
  "doc-up-to-date": "git diff --exit-code doc/",
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
- "test": "jest --filter=./test/testFilter.js --detectOpenHandles",
22
+ "test": "yarn jest",
23
23
  "jest": "jest --filter=./test/testFilter.js --detectOpenHandles",
24
24
  "semantic-release": "semantic-release",
25
25
  "watch": "node bin/preBuild.js && tsc -p tsconfig.build.json --watch"
@@ -51,7 +51,7 @@
51
51
  "jest": "^29.5.0",
52
52
  "nock": "^13.2.2",
53
53
  "openapi-types": "^9.3.0",
54
- "pkg": "^5.5.2",
54
+ "pkg": "^5.8.0",
55
55
  "prettier": "^2.7.1",
56
56
  "semantic-release": "^19.0.2",
57
57
  "sinon": "^13.0.1",
@@ -98,10 +98,10 @@
98
98
  },
99
99
  "pkg": {
100
100
  "targets": [
101
- "node16-linux-x64",
102
- "node16-win-x64",
103
- "node16-macos-x64",
104
- "node16-macos-arm64"
101
+ "node18-linux-x64",
102
+ "node18-win-x64",
103
+ "node18-macos-x64",
104
+ "node18-macos-arm64"
105
105
  ],
106
106
  "scripts": [
107
107
  "built/scanner/*.js",