dependency-cruiser 12.5.0-beta-2 → 12.5.0-beta-3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dependency-cruiser",
3
- "version": "12.5.0-beta-2",
3
+ "version": "12.5.0-beta-3",
4
4
  "description": "Validate and visualize dependencies. With your rules. JavaScript, TypeScript, CoffeeScript. ES6, CommonJS, AMD.",
5
5
  "keywords": [
6
6
  "static analysis",
@@ -6,8 +6,8 @@ const {
6
6
  getFileHash,
7
7
  excludeFilter,
8
8
  includeOnlyFilter,
9
- isInterestingChangeType,
10
9
  hasInterestingExtension,
10
+ isInterestingChangeType,
11
11
  addCheckSumToChange,
12
12
  } = require("./utl");
13
13
 
@@ -73,9 +73,9 @@ function findChanges(pDirectory, pCachedCruiseResult, pOptions) {
73
73
  const lFileSet = new Set(
74
74
  findAllFiles(pDirectory, {
75
75
  baseDir: pOptions.baseDir,
76
- })
77
- .filter(excludeFilter(pOptions.exclude))
78
- .filter(includeOnlyFilter(pOptions.includeOnly))
76
+ excludeFilterFn: excludeFilter(pOptions.exclude),
77
+ includeOnlyFilterFn: includeOnlyFilter(pOptions.includeOnly),
78
+ }).filter(hasInterestingExtension(pOptions.extensions))
79
79
  );
80
80
 
81
81
  bus.emit("progress", "cache: - determining cached vs new", { level: DEBUG });
@@ -96,9 +96,7 @@ function findChanges(pDirectory, pCachedCruiseResult, pOptions) {
96
96
  }
97
97
 
98
98
  bus.emit("progress", "cache: - returning revision data", { level: DEBUG });
99
- return lDiffCachedVsNew
100
- .concat(lDiffNewVsCached)
101
- .filter(hasInterestingExtension(pOptions.extensions));
99
+ return lDiffCachedVsNew.concat(lDiffNewVsCached);
102
100
  }
103
101
 
104
102
  /**
@@ -5,7 +5,7 @@ const {
5
5
  addCheckSumToChange,
6
6
  excludeFilter,
7
7
  includeOnlyFilter,
8
- hasInterestingExtension,
8
+ changeHasInterestingExtension,
9
9
  } = require("./utl");
10
10
 
11
11
  /**
@@ -42,7 +42,7 @@ function getRevisionData(
42
42
  .filter(({ name }) =>
43
43
  includeOnlyFilter(pCruiseOptions.includeOnly)(name)
44
44
  )
45
- .filter(hasInterestingExtension(lOptions.extensions))
45
+ .filter(changeHasInterestingExtension(lOptions.extensions))
46
46
  .filter(isInterestingChangeType(lOptions.interestingChangeTypes))
47
47
  .map(lOptions.checksumFn),
48
48
  };
package/src/cache/utl.js CHANGED
@@ -63,15 +63,22 @@ function includeOnlyFilter(pIncludeOnlyFilter) {
63
63
  return true;
64
64
  };
65
65
  }
66
+ /**
67
+ * @param {Set<string>} pExtensions
68
+ * @returns {(pFileName: string) => boolean}
69
+ */
70
+ function hasInterestingExtension(pExtensions) {
71
+ return (pFileName) => pExtensions.has(path.extname(pFileName));
72
+ }
66
73
 
67
74
  /**
68
75
  * @param {Set<string>} pExtensions
69
76
  * @returns {(pChange: import("watskeburt").IChange) => boolean}
70
77
  */
71
- function hasInterestingExtension(pExtensions) {
78
+ function changeHasInterestingExtension(pExtensions) {
72
79
  return (pChange) =>
73
- pExtensions.has(path.extname(pChange.name)) ||
74
- (pChange.oldName && pExtensions.has(path.extname(pChange.oldName)));
80
+ hasInterestingExtension(pExtensions)(pChange.name) ||
81
+ (pChange.oldName && hasInterestingExtension(pExtensions)(pChange.oldName));
75
82
  }
76
83
 
77
84
  // skipping: "pairing broken", "unmodified", "unmerged", "type changed"
@@ -102,6 +109,7 @@ module.exports = {
102
109
  excludeFilter,
103
110
  includeOnlyFilter,
104
111
  hasInterestingExtension,
112
+ changeHasInterestingExtension,
105
113
  isInterestingChangeType,
106
114
  addCheckSumToChange,
107
115
  };
package/src/main/index.js CHANGED
@@ -63,9 +63,13 @@ function futureCruise(
63
63
  let lCache = null;
64
64
 
65
65
  if (lCruiseOptions.cache) {
66
- bus.emit("progress", "cache: checking freshness", c(2));
66
+ bus.emit(
67
+ "progress",
68
+ `cache: check freshness based on ${lCruiseOptions.cache.strategy}`,
69
+ c(2)
70
+ );
67
71
 
68
- lCache = new Cache(lCruiseOptions?.cache.strategy);
72
+ lCache = new Cache(lCruiseOptions.cache.strategy);
69
73
  const lCachedResults = lCache.read(lCruiseOptions.cache.folder);
70
74
 
71
75
  if (lCache.canServeFromCache(lCruiseOptions, lCachedResults)) {
package/src/meta.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /* generated - don't edit */
2
2
 
3
3
  module.exports = {
4
- version: "12.5.0-beta-2",
4
+ version: "12.5.0-beta-3",
5
5
  engines: {
6
6
  node: "^14||^16||>=18",
7
7
  },
@@ -3,6 +3,10 @@ const { join } = require("path");
3
3
  const ignore = require("ignore");
4
4
  const pathToPosix = require("./path-to-posix");
5
5
 
6
+ /**
7
+ * @typedef {(pString:string, pIndex: number, pArray: string[]) => boolean} FilterFunctionType
8
+ */
9
+
6
10
  /**
7
11
  * @param {string} pFullPathToFile
8
12
  * @param {string} pBaseDirectory
@@ -19,13 +23,18 @@ function fileIsDirectory(pFullPathToFile, pBaseDirectory) {
19
23
 
20
24
  /**
21
25
  * @param {string} pDirectoryName
22
- * @param {{baseDir: string; ignoreFilterFn: (pString:string, pIndex: number, pArray: string[]) => boolean)}} pOptions
26
+ * @param {{baseDir: string; ignoreFilterFn: FilterFunctionType; excludeFilterFn: FilterFunctionType; includeOnlyFilterFn: FilterFunctionType}} pOptions
23
27
  * @returns {string[]}
24
28
  */
25
- function walk(pDirectoryName, { baseDir, ignoreFilterFn }) {
29
+ function walk(
30
+ pDirectoryName,
31
+ { baseDir, ignoreFilterFn, excludeFilterFn, includeOnlyFilterFn }
32
+ ) {
26
33
  return readdirSync(join(baseDir, pDirectoryName))
27
34
  .map((pFileName) => join(pDirectoryName, pFileName))
28
35
  .filter(ignoreFilterFn)
36
+ .filter(excludeFilterFn)
37
+ .filter(includeOnlyFilterFn)
29
38
  .map((pFullPathToFile) => ({
30
39
  fullPathToFile: pFullPathToFile,
31
40
  isDirectory: fileIsDirectory(pFullPathToFile, baseDir),
@@ -38,7 +47,14 @@ function walk(pDirectoryName, { baseDir, ignoreFilterFn }) {
38
47
  */
39
48
  (pSum, { fullPathToFile, isDirectory }) => {
40
49
  if (isDirectory) {
41
- return pSum.concat(walk(fullPathToFile, { baseDir, ignoreFilterFn }));
50
+ return pSum.concat(
51
+ walk(fullPathToFile, {
52
+ baseDir,
53
+ ignoreFilterFn,
54
+ excludeFilterFn,
55
+ includeOnlyFilterFn,
56
+ })
57
+ );
42
58
  }
43
59
  return pSum.concat(fullPathToFile);
44
60
  },
@@ -55,14 +71,28 @@ function readIgnoreFile(pFileName) {
55
71
  }
56
72
  }
57
73
 
74
+ /**
75
+ * @type FilterFunctionType
76
+ */
77
+ // eslint-disable-next-line no-unused-vars
78
+ function identityFilter(_pString, _pIndex, _pArray) {
79
+ return true;
80
+ }
81
+
58
82
  /**
59
83
  * @param {string} pDirectoryName
60
- * @param {{baseDir: string; ignoreFileContents?: string; additionalIgnorePatterns?: string[]}} pOptions
84
+ * @param {{baseDir: string; ignoreFileContents?: string; additionalIgnorePatterns?: string[]; excludeFilterFn: FilterFunctionType; includeOnlyFilterFn: FilterFunctionType}} pOptions
61
85
  * @returns {string[]}
62
86
  */
63
87
  module.exports = function findAllFiles(
64
88
  pDirectoryName,
65
- { baseDir, ignoreFileContents, additionalIgnorePatterns }
89
+ {
90
+ baseDir,
91
+ ignoreFileContents,
92
+ additionalIgnorePatterns,
93
+ excludeFilterFn,
94
+ includeOnlyFilterFn,
95
+ }
66
96
  ) {
67
97
  const lIgnoreFileContents =
68
98
  ignoreFileContents ?? readIgnoreFile(join(baseDir, ".gitignore"));
@@ -75,5 +105,7 @@ module.exports = function findAllFiles(
75
105
  return walk(pDirectoryName, {
76
106
  baseDir,
77
107
  ignoreFilterFn: lIgnoreFilterFunction,
108
+ excludeFilterFn: excludeFilterFn ?? identityFilter,
109
+ includeOnlyFilterFn: includeOnlyFilterFn ?? identityFilter,
78
110
  });
79
111
  };