forked from jamessimone/apex-rollup
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlint-staged.config.js
80 lines (74 loc) · 3.32 KB
/
lint-staged.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// we use path.resolve to combat cross-platform
// path delimiter incompatibilities ("/" versus "\\", for instance)
const path = require('path');
const resolvePath = fileName => path.resolve(__dirname + '/' + fileName);
const resolvePaths = paths => paths.map(fileName => resolvePath(fileName));
const EXTRA_CODE_COVERAGE_PATHS = resolvePaths([
'extra-tests/classes/RollupTestUtils.cls',
'extra-tests/classes/RollupTests.cls',
'extra-tests/classes/RollupEvaluatorTests.cls',
'extra-tests/classes/RollupRelationshipFieldFinderTests.cls',
'extra-tests/classes/RollupLoggerTests.cls',
'extra-tests/classes/RollupQueryBuilderTests.cls',
'extra-tests/classes/RollupRecursionItemTests.cls',
'extra-tests/classes/RollupParentResetProcessorTests.cls'
]);
const CUSTOM_LOGGER_PATHS = resolvePaths([
'plugins/CustomObjectRollupLogger/classes/RollupCustomObjectLogger.cls',
'plugins/CustomObjectRollupLogger/classes/RollupLogBatchPurger.cls',
'plugins/CustomObjectRollupLogger/classes/RollupLogControl.cls',
'plugins/CustomObjectRollupLogger/classes/RollupLogEventHandler.cls',
'plugins/CustomObjectRollupLogger/classes/RollupPurgerSchedulable.cls',
'plugins/CustomObjectRollupLogger/tests/RollupCustomObjectLoggerTests.cls',
'plugins/CustomObjectRollupLogger/tests/RollupLogBatchPurgerTests.cls'
]);
const NEBULA_LOGGER_ADAPTER_PATHS = resolvePaths([
'plugins/NebulaLogger/classes/RollupNebulaLoggerAdapter.cls',
'plugins/NebulaLogger/tests/RollupNebulaLoggerAdapterTest.cls'
]);
const CALLBACK_PATHS = resolvePaths(['plugins/RollupCallback/classes/RollupDispatch.cls', 'plugins/RollupCallback/tests/RollupDispatchTests.cls']);
let shouldRunSfdxScanner = false;
let shouldRunExtraCodeCoveragePackageCreation = false;
let shouldRunNebulaLoggerPackageCreation = false;
let shouldRunCustomLoggerPackageCreation = false;
let shouldRunCallbackPackageCreation = false;
module.exports = {
'**/lwc/*.js': filenames => `eslint ${filenames.join(' ')} --fix`,
'*.{cls,cmp,component,css,html,js,json,md,page,trigger,yaml,yml}': filenames => {
const commands = filenames.map(filename => {
if (!shouldRunSfdxScanner && (filename.endsWith('.cls') || filename.endsWith('.trigger'))) {
shouldRunSfdxScanner = true;
}
const resolvedPath = path.resolve(filename);
if (EXTRA_CODE_COVERAGE_PATHS.includes(resolvedPath)) {
shouldRunExtraCodeCoveragePackageCreation = true;
}
if (NEBULA_LOGGER_ADAPTER_PATHS.includes(resolvedPath)) {
shouldRunNebulaLoggerPackageCreation = true;
}
if (CUSTOM_LOGGER_PATHS.includes(resolvedPath)) {
shouldRunCustomLoggerPackageCreation = true;
}
if (CALLBACK_PATHS.includes(resolvedPath)) {
shouldRunCallbackPackageCreation = true;
}
return `prettier --write '${filename}'`;
});
if (shouldRunSfdxScanner) {
commands.push('npm run scan');
}
if (shouldRunExtraCodeCoveragePackageCreation) {
commands.push('npm run create:package:code-coverage');
}
if (shouldRunNebulaLoggerPackageCreation) {
commands.push('npm run create:package:nebula:adapter');
}
if (shouldRunCustomLoggerPackageCreation) {
commands.push('npm run create:package:logger');
}
if (shouldRunCallbackPackageCreation) {
commands.push('npm run create:package:callback');
}
return commands;
}
};