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 +1 -1
- package/src/cache/content-strategy.js +5 -7
- package/src/cache/metadata-strategy.js +2 -2
- package/src/cache/utl.js +11 -3
- package/src/main/index.js +6 -2
- package/src/meta.js +1 -1
- package/src/utl/find-all-files.js +37 -5
package/package.json
CHANGED
|
@@ -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
|
-
|
|
78
|
-
|
|
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
|
-
|
|
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(
|
|
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
|
|
78
|
+
function changeHasInterestingExtension(pExtensions) {
|
|
72
79
|
return (pChange) =>
|
|
73
|
-
pExtensions
|
|
74
|
-
(pChange.oldName && pExtensions
|
|
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(
|
|
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
|
|
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
|
@@ -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:
|
|
26
|
+
* @param {{baseDir: string; ignoreFilterFn: FilterFunctionType; excludeFilterFn: FilterFunctionType; includeOnlyFilterFn: FilterFunctionType}} pOptions
|
|
23
27
|
* @returns {string[]}
|
|
24
28
|
*/
|
|
25
|
-
function walk(
|
|
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(
|
|
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
|
-
{
|
|
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
|
};
|