dependency-cruiser 12.5.0-beta-3 → 12.5.0-beta-4
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/cache.js +5 -3
- package/src/cache/content-strategy.js +80 -180
- package/src/cache/find-content-changes.js +104 -0
- package/src/cache/metadata-strategy.js +66 -75
- package/src/cache/utl.js +14 -2
- package/src/main/index.js +2 -2
- package/src/meta.js +1 -1
package/package.json
CHANGED
package/src/cache/cache.js
CHANGED
|
@@ -2,8 +2,8 @@ const { readFileSync, mkdirSync, writeFileSync } = require("fs");
|
|
|
2
2
|
const { join } = require("path");
|
|
3
3
|
const meta = require("../extract/transpile/meta");
|
|
4
4
|
const { optionsAreCompatible } = require("./options-compatible");
|
|
5
|
-
const
|
|
6
|
-
const
|
|
5
|
+
const MetadataStrategy = require("./metadata-strategy");
|
|
6
|
+
const ContentStrategy = require("./content-strategy");
|
|
7
7
|
|
|
8
8
|
const CACHE_FILE_NAME = "cache.json";
|
|
9
9
|
|
|
@@ -14,7 +14,9 @@ module.exports = class Cache {
|
|
|
14
14
|
constructor(pCacheStrategy) {
|
|
15
15
|
this.revisionData = null;
|
|
16
16
|
this.cacheStrategy =
|
|
17
|
-
pCacheStrategy === "content"
|
|
17
|
+
pCacheStrategy === "content"
|
|
18
|
+
? new ContentStrategy()
|
|
19
|
+
: new MetadataStrategy();
|
|
18
20
|
}
|
|
19
21
|
|
|
20
22
|
/**
|
|
@@ -1,174 +1,29 @@
|
|
|
1
|
+
const { join } = require("path").posix;
|
|
1
2
|
const { isDeepStrictEqual } = require("util");
|
|
2
|
-
const
|
|
3
|
-
const { DEBUG } = require("../utl/bus-log-levels");
|
|
4
|
-
const findAllFiles = require("../utl/find-all-files");
|
|
3
|
+
const findContentChanges = require("./find-content-changes");
|
|
5
4
|
const {
|
|
6
5
|
getFileHash,
|
|
7
|
-
excludeFilter,
|
|
8
|
-
includeOnlyFilter,
|
|
9
|
-
hasInterestingExtension,
|
|
10
6
|
isInterestingChangeType,
|
|
11
7
|
addCheckSumToChange,
|
|
8
|
+
moduleIsInterestingForDiff,
|
|
12
9
|
} = require("./utl");
|
|
13
10
|
|
|
14
11
|
/**
|
|
15
|
-
* @param {
|
|
16
|
-
* @
|
|
17
|
-
* @returns {import('../..').IRevisionChange}
|
|
12
|
+
* @param {string} pBaseDirectory
|
|
13
|
+
* @returns {(pModule: import("../..").IModule) => import("../..").IModule}
|
|
18
14
|
*/
|
|
19
|
-
function
|
|
20
|
-
pFileSet,
|
|
21
|
-
pFileHashFunction = getFileHash
|
|
22
|
-
) {
|
|
23
|
-
// eslint-disable-next-line complexity
|
|
15
|
+
function addCheckSumToModule(pBaseDirectory) {
|
|
24
16
|
return (pModule) => {
|
|
25
|
-
if (
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
) {
|
|
31
|
-
if (!pFileSet.has(pModule.source)) {
|
|
32
|
-
return { name: pModule.source, changeType: "deleted" };
|
|
33
|
-
}
|
|
34
|
-
const lNewCheckSum = pFileHashFunction(pModule.source);
|
|
35
|
-
if (lNewCheckSum !== pModule.checksum) {
|
|
36
|
-
return {
|
|
37
|
-
name: pModule.source,
|
|
38
|
-
changeType: "modified",
|
|
39
|
-
checksum: lNewCheckSum,
|
|
40
|
-
};
|
|
41
|
-
}
|
|
17
|
+
if (moduleIsInterestingForDiff(pModule)) {
|
|
18
|
+
return {
|
|
19
|
+
...pModule,
|
|
20
|
+
checksum: getFileHash(join(pBaseDirectory, pModule.source)),
|
|
21
|
+
};
|
|
42
22
|
}
|
|
43
|
-
return
|
|
44
|
-
name: pModule.source,
|
|
45
|
-
changeType: "unmodified",
|
|
46
|
-
checksum: pModule.checksum,
|
|
47
|
-
};
|
|
23
|
+
return pModule;
|
|
48
24
|
};
|
|
49
25
|
}
|
|
50
26
|
|
|
51
|
-
/**
|
|
52
|
-
We can run into these scenarios:
|
|
53
|
-
- there is no cache yet:
|
|
54
|
-
modules will === []; all files will be marked as 'added'
|
|
55
|
-
- there is a cache and it contains checksums:
|
|
56
|
-
- existing files that are not in the cache => added
|
|
57
|
-
- modules that are in the cache:
|
|
58
|
-
- don't exist anymore => deleted TODO:
|
|
59
|
-
we might wrongly bump into this for files that are gitignored and that don't have an interesting extension
|
|
60
|
-
- cached checksum === current checksum => not a change; left out
|
|
61
|
-
- cached checksum !== current checksum => modified
|
|
62
|
-
- there is a cache, but it doesn't contain checksums => same as before, except
|
|
63
|
-
all files will be marked as 'modified'
|
|
64
|
-
* @param {string} pDirectory
|
|
65
|
-
* @param {import("../..").ICruiseResult} pCachedCruiseResult
|
|
66
|
-
* @param {Object} pOptions
|
|
67
|
-
* @param {Set<string>} pOptions.extensions
|
|
68
|
-
* @param {string} pOptions.baseDir
|
|
69
|
-
* @returns {{source: string; changeType: import("watskeburt").changeTypeType; checksum: string}[]}
|
|
70
|
-
*/
|
|
71
|
-
function findChanges(pDirectory, pCachedCruiseResult, pOptions) {
|
|
72
|
-
bus.emit("progress", "cache: - hauling revision data", { level: DEBUG });
|
|
73
|
-
const lFileSet = new Set(
|
|
74
|
-
findAllFiles(pDirectory, {
|
|
75
|
-
baseDir: pOptions.baseDir,
|
|
76
|
-
excludeFilterFn: excludeFilter(pOptions.exclude),
|
|
77
|
-
includeOnlyFilterFn: includeOnlyFilter(pOptions.includeOnly),
|
|
78
|
-
}).filter(hasInterestingExtension(pOptions.extensions))
|
|
79
|
-
);
|
|
80
|
-
|
|
81
|
-
bus.emit("progress", "cache: - determining cached vs new", { level: DEBUG });
|
|
82
|
-
const lDiffCachedVsNew = pCachedCruiseResult.modules.map(
|
|
83
|
-
diffCachedModuleAgainstFileSet(lFileSet)
|
|
84
|
-
);
|
|
85
|
-
|
|
86
|
-
bus.emit("progress", "cache: - determining new vs cached", { level: DEBUG });
|
|
87
|
-
lDiffCachedVsNew.forEach(({ name }) => lFileSet.delete(name));
|
|
88
|
-
|
|
89
|
-
const lDiffNewVsCached = [];
|
|
90
|
-
for (let lFileName of lFileSet) {
|
|
91
|
-
lDiffNewVsCached.push({
|
|
92
|
-
name: lFileName,
|
|
93
|
-
changeType: "added",
|
|
94
|
-
checksum: getFileHash(lFileName),
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
bus.emit("progress", "cache: - returning revision data", { level: DEBUG });
|
|
99
|
-
return lDiffCachedVsNew.concat(lDiffNewVsCached);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
*
|
|
104
|
-
* @param {string} pDirectory
|
|
105
|
-
* @param {import("../..").ICruiseResult} pCachedCruiseResult
|
|
106
|
-
* @param {import("../../types/strict-options").IStrictCruiseOptions} pCruiseOptions
|
|
107
|
-
* @param {Object} pOptions
|
|
108
|
-
* @param {Set<string>} pOptions.extensions
|
|
109
|
-
* @param {Set<import("watskeburt").changeTypeType>} pOptions.interestingChangeTypes
|
|
110
|
-
* @param {string} pOptions.baseDir
|
|
111
|
-
* @param {(pString:string) => Array<import("watskeburt").IChange>} pOptions.diffListFn
|
|
112
|
-
* @param {(import("watskeburt").IChange) => import("../..").IRevisionChange} pOptions.checksumFn
|
|
113
|
-
* @returns {import("../..").IRevisionData}
|
|
114
|
-
*/
|
|
115
|
-
function getRevisionData(
|
|
116
|
-
pDirectory,
|
|
117
|
-
pCachedCruiseResult,
|
|
118
|
-
pCruiseOptions,
|
|
119
|
-
pOptions
|
|
120
|
-
) {
|
|
121
|
-
const lOptions = {
|
|
122
|
-
diffListFn: findChanges,
|
|
123
|
-
checksumFn: addCheckSumToChange,
|
|
124
|
-
baseDir: process.cwd(),
|
|
125
|
-
...pOptions,
|
|
126
|
-
};
|
|
127
|
-
return {
|
|
128
|
-
SHA1: "unknown-in-content-cache-strategy",
|
|
129
|
-
changes: lOptions
|
|
130
|
-
.diffListFn(pDirectory, pCachedCruiseResult, {
|
|
131
|
-
baseDir: lOptions.baseDir,
|
|
132
|
-
extensions: lOptions.extensions,
|
|
133
|
-
includeOnly: pCruiseOptions.includeOnly,
|
|
134
|
-
exclude: pCruiseOptions.exclude,
|
|
135
|
-
})
|
|
136
|
-
.filter(isInterestingChangeType(lOptions.interestingChangeTypes)),
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* @param {import("../..").IRevisionData} pExistingRevisionData
|
|
142
|
-
* @param {import("../..").IRevisionData} pNewRevisionData
|
|
143
|
-
* @returns {boolean}
|
|
144
|
-
*/
|
|
145
|
-
function revisionDataEqual(pExistingRevisionData, pNewRevisionData) {
|
|
146
|
-
return (
|
|
147
|
-
Boolean(pExistingRevisionData) &&
|
|
148
|
-
Boolean(pNewRevisionData) &&
|
|
149
|
-
isDeepStrictEqual(pExistingRevisionData.changes, pNewRevisionData.changes)
|
|
150
|
-
);
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
* @param {import("../..").IModule} pModule
|
|
155
|
-
* @param {import("../..").IRevisionChange}
|
|
156
|
-
*/
|
|
157
|
-
function addCheckSumToModule(pModule) {
|
|
158
|
-
if (
|
|
159
|
-
!pModule.consolidated &&
|
|
160
|
-
!pModule.coreModule &&
|
|
161
|
-
!pModule.couldNotResolve &&
|
|
162
|
-
!pModule.matchesDoNotFollow
|
|
163
|
-
) {
|
|
164
|
-
return {
|
|
165
|
-
...pModule,
|
|
166
|
-
checksum: getFileHash(pModule.source),
|
|
167
|
-
};
|
|
168
|
-
}
|
|
169
|
-
return pModule;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
27
|
/**
|
|
173
28
|
* @param {import("../..").IRevisionChange[]} pChanges
|
|
174
29
|
* @param {import("../..").IModule[]} pModules
|
|
@@ -185,29 +40,74 @@ function refreshChanges(pChanges, pModules) {
|
|
|
185
40
|
);
|
|
186
41
|
}
|
|
187
42
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
43
|
+
module.exports = class ContentStrategy {
|
|
44
|
+
/**
|
|
45
|
+
* @param {string} pDirectory
|
|
46
|
+
* @param {import("../..").ICruiseResult} pCachedCruiseResult
|
|
47
|
+
* @param {import("../../types/strict-options").IStrictCruiseOptions} pCruiseOptions
|
|
48
|
+
* @param {Object} pOptions
|
|
49
|
+
* @param {Set<string>} pOptions.extensions
|
|
50
|
+
* @param {Set<import("watskeburt").changeTypeType>} pOptions.interestingChangeTypes
|
|
51
|
+
* @param {string} pOptions.baseDir
|
|
52
|
+
* @param {(pString:string) => Array<import("watskeburt").IChange>} pOptions.diffListFn
|
|
53
|
+
* @param {(import("watskeburt").IChange) => import("../..").IRevisionChange} pOptions.checksumFn
|
|
54
|
+
* @returns {import("../..").IRevisionData}
|
|
55
|
+
*/
|
|
56
|
+
getRevisionData(pDirectory, pCachedCruiseResult, pCruiseOptions, pOptions) {
|
|
57
|
+
const lOptions = {
|
|
58
|
+
diffListFn: findContentChanges,
|
|
59
|
+
checksumFn: addCheckSumToChange,
|
|
60
|
+
baseDir: process.cwd(),
|
|
61
|
+
...pOptions,
|
|
62
|
+
};
|
|
63
|
+
return {
|
|
64
|
+
SHA1: "unknown-in-content-cache-strategy",
|
|
65
|
+
changes: lOptions
|
|
66
|
+
.diffListFn(pDirectory, pCachedCruiseResult, {
|
|
67
|
+
baseDir: lOptions.baseDir,
|
|
68
|
+
extensions: lOptions.extensions,
|
|
69
|
+
includeOnly: pCruiseOptions.includeOnly,
|
|
70
|
+
exclude: pCruiseOptions.exclude,
|
|
71
|
+
})
|
|
72
|
+
.filter(isInterestingChangeType(lOptions.interestingChangeTypes)),
|
|
73
|
+
};
|
|
74
|
+
}
|
|
199
75
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
76
|
+
/**
|
|
77
|
+
* @param {import("../..").IRevisionData} pExistingRevisionData
|
|
78
|
+
* @param {import("../..").IRevisionData} pNewRevisionData
|
|
79
|
+
* @returns {boolean}
|
|
80
|
+
*/
|
|
81
|
+
revisionDataEqual(pExistingRevisionData, pNewRevisionData) {
|
|
82
|
+
return (
|
|
83
|
+
Boolean(pExistingRevisionData) &&
|
|
84
|
+
Boolean(pNewRevisionData) &&
|
|
85
|
+
// Even though we don't really have a SHA1, it might be the previous version
|
|
86
|
+
// of the cache did, e.g. because it was rendered with the metadata cache
|
|
87
|
+
// strategy. In that case the SHA1 comparison is a reliable, fast bailout.
|
|
88
|
+
pExistingRevisionData.SHA1 === pNewRevisionData.SHA1 &&
|
|
89
|
+
isDeepStrictEqual(pExistingRevisionData.changes, pNewRevisionData.changes)
|
|
90
|
+
);
|
|
91
|
+
}
|
|
208
92
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
93
|
+
/**
|
|
94
|
+
* @param {import("../..").ICruiseResult} pCruiseResult
|
|
95
|
+
* @param {import("../..").IRevisionData} pRevisionData
|
|
96
|
+
* @returns {import("../..").ICruiseResult}
|
|
97
|
+
*/
|
|
98
|
+
prepareRevisionDataForSaving(pCruiseResult, pRevisionData) {
|
|
99
|
+
const lModulesWithCheckSum = pCruiseResult.modules.map(
|
|
100
|
+
addCheckSumToModule(pCruiseResult.summary.optionsUsed.baseDir)
|
|
101
|
+
);
|
|
102
|
+
const lRevisionData = {
|
|
103
|
+
...pRevisionData,
|
|
104
|
+
changes: refreshChanges(pRevisionData.changes, lModulesWithCheckSum),
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
return {
|
|
108
|
+
...pCruiseResult,
|
|
109
|
+
modules: lModulesWithCheckSum,
|
|
110
|
+
revisionData: lRevisionData,
|
|
111
|
+
};
|
|
112
|
+
}
|
|
213
113
|
};
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
const { join } = require("path").posix;
|
|
2
|
+
const bus = require("../utl/bus");
|
|
3
|
+
const { DEBUG } = require("../utl/bus-log-levels");
|
|
4
|
+
const findAllFiles = require("../utl/find-all-files");
|
|
5
|
+
const {
|
|
6
|
+
getFileHash,
|
|
7
|
+
excludeFilter,
|
|
8
|
+
includeOnlyFilter,
|
|
9
|
+
hasInterestingExtension,
|
|
10
|
+
moduleIsInterestingForDiff,
|
|
11
|
+
} = require("./utl");
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @param {Set<string>} pFileSet
|
|
15
|
+
* @param {typeof getFileHash} pFileHashFunction
|
|
16
|
+
* @returns {(pModule:import("../..").IModule) => import('../..').IRevisionChange}
|
|
17
|
+
*/
|
|
18
|
+
function diffCachedModuleAgainstFileSet(
|
|
19
|
+
pFileSet,
|
|
20
|
+
pBaseDirectory,
|
|
21
|
+
pFileHashFunction = getFileHash
|
|
22
|
+
) {
|
|
23
|
+
return (pModule) => {
|
|
24
|
+
if (!moduleIsInterestingForDiff(pModule)) {
|
|
25
|
+
return { name: pModule.source, changeType: "ignored" };
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (!pFileSet.has(pModule.source)) {
|
|
29
|
+
return { name: pModule.source, changeType: "deleted" };
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const lNewCheckSum = pFileHashFunction(
|
|
33
|
+
join(pBaseDirectory, pModule.source)
|
|
34
|
+
);
|
|
35
|
+
if (lNewCheckSum !== pModule.checksum) {
|
|
36
|
+
return {
|
|
37
|
+
name: pModule.source,
|
|
38
|
+
changeType: "modified",
|
|
39
|
+
checksum: lNewCheckSum,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return {
|
|
44
|
+
name: pModule.source,
|
|
45
|
+
changeType: "unmodified",
|
|
46
|
+
checksum: pModule.checksum,
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
We can run into these scenarios:
|
|
53
|
+
- there is no cache yet:
|
|
54
|
+
modules will === []; all files will be marked as 'added'
|
|
55
|
+
- there is a cache and it contains checksums:
|
|
56
|
+
- existing files that are not in the cache => added
|
|
57
|
+
- modules that are in the cache:
|
|
58
|
+
- don't exist anymore => deleted TODO:
|
|
59
|
+
we might wrongly bump into this for files that are gitignored and that don't have an interesting extension
|
|
60
|
+
- cached checksum === current checksum => not a change; left out
|
|
61
|
+
- cached checksum !== current checksum => modified
|
|
62
|
+
- there is a cache, but it doesn't contain checksums => same as before, except
|
|
63
|
+
all files will be marked as 'modified'
|
|
64
|
+
* @param {string} pDirectory
|
|
65
|
+
* @param {import("../..").ICruiseResult} pCachedCruiseResult
|
|
66
|
+
* @param {Object} pOptions
|
|
67
|
+
* @param {Set<string>} pOptions.extensions
|
|
68
|
+
* @param {string} pOptions.baseDir
|
|
69
|
+
* @returns {{source: string; changeType: import("watskeburt").changeTypeType; checksum: string}[]}
|
|
70
|
+
*/
|
|
71
|
+
module.exports = function findContentChanges(
|
|
72
|
+
pDirectory,
|
|
73
|
+
pCachedCruiseResult,
|
|
74
|
+
pOptions
|
|
75
|
+
) {
|
|
76
|
+
bus.emit("progress", "cache: - hauling revision data", { level: DEBUG });
|
|
77
|
+
const lFileSet = new Set(
|
|
78
|
+
findAllFiles(pDirectory, {
|
|
79
|
+
baseDir: pOptions.baseDir,
|
|
80
|
+
excludeFilterFn: excludeFilter(pOptions.exclude),
|
|
81
|
+
includeOnlyFilterFn: includeOnlyFilter(pOptions.includeOnly),
|
|
82
|
+
}).filter(hasInterestingExtension(pOptions.extensions))
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
bus.emit("progress", "cache: - determining cached vs new", { level: DEBUG });
|
|
86
|
+
const lDiffCachedVsNew = pCachedCruiseResult.modules.map(
|
|
87
|
+
diffCachedModuleAgainstFileSet(lFileSet, pOptions.baseDir)
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
bus.emit("progress", "cache: - determining new vs cached", { level: DEBUG });
|
|
91
|
+
lDiffCachedVsNew.forEach(({ name }) => lFileSet.delete(name));
|
|
92
|
+
|
|
93
|
+
const lDiffNewVsCached = [];
|
|
94
|
+
for (let lFileName of lFileSet) {
|
|
95
|
+
lDiffNewVsCached.push({
|
|
96
|
+
name: lFileName,
|
|
97
|
+
changeType: "added",
|
|
98
|
+
checksum: getFileHash(join(pOptions.baseDir, lFileName)),
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
bus.emit("progress", "cache: - returning revision data", { level: DEBUG });
|
|
103
|
+
return lDiffCachedVsNew.concat(lDiffNewVsCached);
|
|
104
|
+
};
|
|
@@ -8,83 +8,74 @@ const {
|
|
|
8
8
|
changeHasInterestingExtension,
|
|
9
9
|
} = require("./utl");
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
pDirectory,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
shaRetrievalFn: getSHASync,
|
|
31
|
-
diffListFn: listSync,
|
|
32
|
-
checksumFn: addCheckSumToChange,
|
|
33
|
-
...pOptions,
|
|
34
|
-
};
|
|
35
|
-
try {
|
|
36
|
-
const lSHA = lOptions.shaRetrievalFn();
|
|
37
|
-
return {
|
|
38
|
-
SHA1: lSHA,
|
|
39
|
-
changes: lOptions
|
|
40
|
-
.diffListFn(lSHA)
|
|
41
|
-
.filter(({ name }) => excludeFilter(pCruiseOptions.exclude)(name))
|
|
42
|
-
.filter(({ name }) =>
|
|
43
|
-
includeOnlyFilter(pCruiseOptions.includeOnly)(name)
|
|
44
|
-
)
|
|
45
|
-
.filter(changeHasInterestingExtension(lOptions.extensions))
|
|
46
|
-
.filter(isInterestingChangeType(lOptions.interestingChangeTypes))
|
|
47
|
-
.map(lOptions.checksumFn),
|
|
11
|
+
module.exports = class MetaDataStrategy {
|
|
12
|
+
/**
|
|
13
|
+
* @param {Set<string>} pExtensions
|
|
14
|
+
* @param {Set<import("watskeburt").changeTypeType>} pInterestingChangeTypes
|
|
15
|
+
* @param {import("../../types/strict-options").IStrictCruiseOptions} pCruiseOptions
|
|
16
|
+
* @param {Object} pOptions
|
|
17
|
+
* @param {Set<string>} pOptions.extensions
|
|
18
|
+
* @param {Set<import("watskeburt").changeTypeType>} pOptions.interestingChangeTypes
|
|
19
|
+
* @param {() => string} pOptions.shaRetrievalFn
|
|
20
|
+
* @param {(pString:string) => Array<import("watskeburt").IChange>} pOptions.diffListFn
|
|
21
|
+
* @param {(import("watskeburt").IChange) => import("../..").IRevisionChange} pOptions.checksumFn
|
|
22
|
+
* @returns {import("../..").IRevisionData}
|
|
23
|
+
*/
|
|
24
|
+
getRevisionData(pDirectory, pCachedCruiseResult, pCruiseOptions, pOptions) {
|
|
25
|
+
const lOptions = {
|
|
26
|
+
shaRetrievalFn: getSHASync,
|
|
27
|
+
diffListFn: listSync,
|
|
28
|
+
checksumFn: addCheckSumToChange,
|
|
29
|
+
...pOptions,
|
|
48
30
|
};
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
31
|
+
try {
|
|
32
|
+
const lSHA = lOptions.shaRetrievalFn();
|
|
33
|
+
return {
|
|
34
|
+
SHA1: lSHA,
|
|
35
|
+
changes: lOptions
|
|
36
|
+
.diffListFn(lSHA)
|
|
37
|
+
.filter(({ name }) => excludeFilter(pCruiseOptions.exclude)(name))
|
|
38
|
+
.filter(({ name }) =>
|
|
39
|
+
includeOnlyFilter(pCruiseOptions.includeOnly)(name)
|
|
40
|
+
)
|
|
41
|
+
.filter(changeHasInterestingExtension(lOptions.extensions))
|
|
42
|
+
.filter(isInterestingChangeType(lOptions.interestingChangeTypes))
|
|
43
|
+
.map(lOptions.checksumFn),
|
|
44
|
+
};
|
|
45
|
+
} catch (pError) {
|
|
46
|
+
throw new Error(
|
|
47
|
+
"The --cache option works in concert with git - and it seems either the " +
|
|
48
|
+
"current folder isn't version managed or git isn't installed. Error:" +
|
|
49
|
+
`\n\n ${pError}\n`
|
|
50
|
+
);
|
|
51
|
+
}
|
|
55
52
|
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* @param {import("../..").IRevisionData} pExistingRevisionData
|
|
60
|
-
* @param {import("../..").IRevisionData} pNewRevisionData
|
|
61
|
-
* @returns {boolean}
|
|
62
|
-
*/
|
|
63
|
-
function revisionDataEqual(pExistingRevisionData, pNewRevisionData) {
|
|
64
|
-
return (
|
|
65
|
-
Boolean(pExistingRevisionData) &&
|
|
66
|
-
Boolean(pNewRevisionData) &&
|
|
67
|
-
pExistingRevisionData.SHA1 === pNewRevisionData.SHA1 &&
|
|
68
|
-
isDeepStrictEqual(pExistingRevisionData.changes, pNewRevisionData.changes)
|
|
69
|
-
);
|
|
70
|
-
}
|
|
71
53
|
|
|
72
|
-
/**
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
54
|
+
/**
|
|
55
|
+
* @param {import("../..").IRevisionData} pExistingRevisionData
|
|
56
|
+
* @param {import("../..").IRevisionData} pNewRevisionData
|
|
57
|
+
* @returns {boolean}
|
|
58
|
+
*/
|
|
59
|
+
revisionDataEqual(pExistingRevisionData, pNewRevisionData) {
|
|
60
|
+
return (
|
|
61
|
+
Boolean(pExistingRevisionData) &&
|
|
62
|
+
Boolean(pNewRevisionData) &&
|
|
63
|
+
pExistingRevisionData.SHA1 === pNewRevisionData.SHA1 &&
|
|
64
|
+
isDeepStrictEqual(pExistingRevisionData.changes, pNewRevisionData.changes)
|
|
65
|
+
);
|
|
66
|
+
}
|
|
85
67
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
68
|
+
/**
|
|
69
|
+
* @param {import("../..").ICruiseResult} pCruiseResult
|
|
70
|
+
* @param {import("../..").IRevisionData} pRevisionData
|
|
71
|
+
* @returns {import("../..").ICruiseResult}
|
|
72
|
+
*/
|
|
73
|
+
prepareRevisionDataForSaving(pCruiseResult, pRevisionData) {
|
|
74
|
+
return pRevisionData
|
|
75
|
+
? {
|
|
76
|
+
...pCruiseResult,
|
|
77
|
+
revisionData: pRevisionData,
|
|
78
|
+
}
|
|
79
|
+
: pCruiseResult;
|
|
80
|
+
}
|
|
90
81
|
};
|
package/src/cache/utl.js
CHANGED
|
@@ -81,12 +81,11 @@ function changeHasInterestingExtension(pExtensions) {
|
|
|
81
81
|
(pChange.oldName && hasInterestingExtension(pExtensions)(pChange.oldName));
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
// skipping: "pairing broken", "unmodified", "
|
|
84
|
+
// skipping: "pairing broken", "unmodified", "type changed", "ignored"
|
|
85
85
|
const DEFAULT_INTERESTING_CHANGE_TYPES = new Set([
|
|
86
86
|
"added",
|
|
87
87
|
"copied",
|
|
88
88
|
"deleted",
|
|
89
|
-
"ignored",
|
|
90
89
|
"modified",
|
|
91
90
|
"renamed",
|
|
92
91
|
"unmerged",
|
|
@@ -104,6 +103,18 @@ function isInterestingChangeType(pInterestingChangeTypes) {
|
|
|
104
103
|
);
|
|
105
104
|
}
|
|
106
105
|
|
|
106
|
+
/**
|
|
107
|
+
* @param {pModule:import("../..").IModule} pModule
|
|
108
|
+
*/
|
|
109
|
+
function moduleIsInterestingForDiff(pModule) {
|
|
110
|
+
return (
|
|
111
|
+
!pModule.consolidated &&
|
|
112
|
+
!pModule.coreModule &&
|
|
113
|
+
!pModule.couldNotResolve &&
|
|
114
|
+
!pModule.matchesDoNotFollow
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
|
|
107
118
|
module.exports = {
|
|
108
119
|
getFileHash,
|
|
109
120
|
excludeFilter,
|
|
@@ -112,4 +123,5 @@ module.exports = {
|
|
|
112
123
|
changeHasInterestingExtension,
|
|
113
124
|
isInterestingChangeType,
|
|
114
125
|
addCheckSumToChange,
|
|
126
|
+
moduleIsInterestingForDiff,
|
|
115
127
|
};
|
package/src/main/index.js
CHANGED
|
@@ -65,7 +65,7 @@ function futureCruise(
|
|
|
65
65
|
if (lCruiseOptions.cache) {
|
|
66
66
|
bus.emit(
|
|
67
67
|
"progress",
|
|
68
|
-
`cache: check freshness
|
|
68
|
+
`cache: check freshness with ${lCruiseOptions.cache.strategy}`,
|
|
69
69
|
c(2)
|
|
70
70
|
);
|
|
71
71
|
|
|
@@ -112,7 +112,7 @@ function futureCruise(
|
|
|
112
112
|
);
|
|
113
113
|
|
|
114
114
|
if (lCruiseOptions.cache) {
|
|
115
|
-
bus.emit("progress", "cache:
|
|
115
|
+
bus.emit("progress", "cache: save", c(7));
|
|
116
116
|
lCache.write(lCruiseOptions.cache.folder, lCruiseResult);
|
|
117
117
|
}
|
|
118
118
|
|