@elliemae/ds-codemods 3.22.0-next.3 → 3.22.0-next.31
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,4 +1,7 @@
|
|
|
1
1
|
/* eslint-disable no-console */
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import fse from 'fs-extra';
|
|
4
|
+
import path from 'path';
|
|
2
5
|
import depcheck from 'depcheck';
|
|
3
6
|
import {
|
|
4
7
|
brightYellowStr,
|
|
@@ -9,6 +12,16 @@ import {
|
|
|
9
12
|
} from '../../../utils/CLI_COLORS.mjs';
|
|
10
13
|
import { generatePathFromCurrentFolder } from '../../../utils/index.mjs';
|
|
11
14
|
|
|
15
|
+
function generateFolderIfNotExistSync(finalDir) {
|
|
16
|
+
if (!fs.existsSync(finalDir)) {
|
|
17
|
+
fs.mkdirSync(finalDir, { recursive: true });
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const overWriteFile = fse.outputFileSync;
|
|
22
|
+
const getPackageName = () => process.cwd().split('/').pop();
|
|
23
|
+
const getRoot = () => process.cwd().split('/packages')[0];
|
|
24
|
+
|
|
12
25
|
const logUnusedDep = (unused) => {
|
|
13
26
|
console.log(brightYellowStr('### Found unused dependencies :>>'));
|
|
14
27
|
console.log('```');
|
|
@@ -29,6 +42,15 @@ const logMissing = (unused) => {
|
|
|
29
42
|
console.log(missingString);
|
|
30
43
|
console.log('}');
|
|
31
44
|
console.log('```');
|
|
45
|
+
const root = getRoot();
|
|
46
|
+
const pck = getPackageName();
|
|
47
|
+
const folder = `${root}/checkdeps`;
|
|
48
|
+
try {
|
|
49
|
+
generateFolderIfNotExistSync(folder);
|
|
50
|
+
overWriteFile(`${folder}/${pck}.txt`, missingString);
|
|
51
|
+
} catch {
|
|
52
|
+
console.error('error generating files');
|
|
53
|
+
}
|
|
32
54
|
};
|
|
33
55
|
|
|
34
56
|
export const checkMissingPackages = async (options) => {
|
|
@@ -78,11 +100,11 @@ export const checkMissingPackages = async (options) => {
|
|
|
78
100
|
const unusedDevDep = Array.isArray(unused.devDependencies) && unused.devDependencies.length > 0;
|
|
79
101
|
const missing = Object.keys(unused.missing).length > 0;
|
|
80
102
|
const hasErrors = unusedDep || unusedDevDep || missing;
|
|
81
|
-
console.log(boldBrightCyanStr(`# Dependencies results for ${
|
|
82
|
-
console.log(boldBrightCyanStr(`[${pathToRoot}](${pathToRoot}package.json)`));
|
|
83
|
-
if (unusedDep) logUnusedDep(unused);
|
|
84
|
-
if (unusedDevDep) logUnusedDevDep(unused);
|
|
85
|
-
if (missing) logMissing(unused);
|
|
103
|
+
console.log(boldBrightCyanStr(`# Dependencies results for ${getPackageName()}`));
|
|
104
|
+
// console.log(boldBrightCyanStr(`[${pathToRoot}](${pathToRoot}package.json)`));
|
|
105
|
+
// if (unusedDep) logUnusedDep(unused);
|
|
106
|
+
// if (unusedDevDep) logUnusedDevDep(unused);
|
|
107
|
+
if (missing) logMissing(unused, pathToRoot);
|
|
86
108
|
if (!hasErrors) console.log(greenStr(`no problems found!`));
|
|
87
109
|
});
|
|
88
110
|
};
|