@elliemae/ds-codemods 3.57.0-next.3 → 3.57.0-next.30
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.
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
/* eslint-disable no-console */
|
|
2
|
+
import depcheck from 'depcheck';
|
|
2
3
|
import fs from 'fs';
|
|
3
4
|
import fse from 'fs-extra';
|
|
4
|
-
import path from 'path';
|
|
5
|
-
import depcheck from 'depcheck';
|
|
6
5
|
import {
|
|
7
|
-
brightYellowStr,
|
|
8
|
-
brightRedStr,
|
|
9
|
-
brightMagentaStr,
|
|
10
6
|
boldBrightCyanStr,
|
|
7
|
+
// brightMagentaStr,
|
|
8
|
+
brightRedStr,
|
|
9
|
+
brightYellowStr,
|
|
11
10
|
greenStr,
|
|
12
11
|
} from '../../../utils/CLI_COLORS.mjs';
|
|
13
12
|
import { generatePathFromCurrentFolder } from '../../../utils/index.mjs';
|
|
@@ -30,12 +29,12 @@ const logUnusedDep = (unused) => {
|
|
|
30
29
|
console.log(unused.dependencies);
|
|
31
30
|
console.log('```');
|
|
32
31
|
};
|
|
33
|
-
const logUnusedDevDep = (
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
};
|
|
32
|
+
// const logUnusedDevDep = (unsedWithoutFalsePositives) => {
|
|
33
|
+
// console.log(brightMagentaStr('### Found unused dev dependencies :>>'));
|
|
34
|
+
// console.log('```');
|
|
35
|
+
// console.log(unsedWithoutFalsePositives);
|
|
36
|
+
// console.log('```');
|
|
37
|
+
// };
|
|
39
38
|
const logMissing = (unused) => {
|
|
40
39
|
const missingString = [...Object.keys(unused.missing)].map((pack) => `\t${pack}`).join(',\n');
|
|
41
40
|
console.log(brightRedStr('### Found missing dependencies :>>'));
|
|
@@ -56,6 +55,15 @@ const logMissing = (unused) => {
|
|
|
56
55
|
}
|
|
57
56
|
};
|
|
58
57
|
|
|
58
|
+
// const devDependenciesFalsePositives = [
|
|
59
|
+
// '@elliemae/ds-monorepo-devops',
|
|
60
|
+
// '@elliemae/ds-test-utils',
|
|
61
|
+
// '@elliemae/pui-cli',
|
|
62
|
+
// '@elliemae/pui-theme',
|
|
63
|
+
// 'jest',
|
|
64
|
+
// ];
|
|
65
|
+
// const filterFalsePositivesDevDeps = (unusedDep) => !devDependenciesFalsePositives.includes(unusedDep);
|
|
66
|
+
|
|
59
67
|
export const checkMissingPackages = async (options) => {
|
|
60
68
|
const { projectFolderPath, ignorePackagesGlobPattern, ignoreFilesGlobPattern } = options;
|
|
61
69
|
const ignorePatterns = ignorePackagesGlobPattern
|
|
@@ -93,20 +101,24 @@ export const checkMissingPackages = async (options) => {
|
|
|
93
101
|
depcheck.special.tslint,
|
|
94
102
|
depcheck.special.webpack,
|
|
95
103
|
],
|
|
96
|
-
ignorePatterns: [...ignorePatterns, '
|
|
104
|
+
ignorePatterns: [...ignorePatterns, '**/.cache/**/*', '**/dist/**/*', '**/node_modules/**/*', '**/src/tests/**/*'],
|
|
97
105
|
ignoreMatches,
|
|
98
106
|
};
|
|
99
107
|
const pathToRoot = generatePathFromCurrentFolder(projectFolderPath);
|
|
100
108
|
|
|
101
109
|
depcheck(pathToRoot, depCheckOptions).then((unused) => {
|
|
102
110
|
const unusedDep = Array.isArray(unused.dependencies) && unused.dependencies.length > 0;
|
|
103
|
-
const
|
|
111
|
+
const unusedDevDepWithoutFalsePositives = []; // we can't reliable check for unused devDependencies
|
|
112
|
+
// Array.isArray(unused?.devDependencies) && unused.devDependencies.length > 0
|
|
113
|
+
// ? unused.devDependencies.filter(filterFalsePositivesDevDeps)
|
|
114
|
+
// : [];
|
|
115
|
+
const unusedDevDep = unusedDevDepWithoutFalsePositives.length > 0;
|
|
104
116
|
const missing = Object.keys(unused.missing).length > 0;
|
|
105
117
|
const hasErrors = unusedDep || unusedDevDep || missing;
|
|
106
118
|
console.log(boldBrightCyanStr(`# Dependencies results for ${getPackageName()}`));
|
|
107
119
|
// console.log(boldBrightCyanStr(`[${pathToRoot}](${pathToRoot}package.json)`));
|
|
108
|
-
|
|
109
|
-
// if (unusedDevDep) logUnusedDevDep(
|
|
120
|
+
if (unusedDep) logUnusedDep(unused);
|
|
121
|
+
// if (unusedDevDep) logUnusedDevDep(unusedDevDepWithoutFalsePositives);
|
|
110
122
|
if (missing) logMissing(unused, pathToRoot);
|
|
111
123
|
if (!hasErrors) console.log(greenStr(`no problems found!`));
|
|
112
124
|
});
|