@elliemae/ds-codemods 3.11.1-rc.0 → 3.12.0-next.0
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/bin/cli/code-mods/command-logics/check-deprecated-packages/logResults.js +15 -50
- package/bin/cli/code-mods/command-logics/check-missing-packages/index.js +13 -7
- package/bin/cli/code-mods/command-logics/check-packages-inconsistencies/index.js +13 -7
- package/bin/cli/code-mods/command-logics/help-migrate-to-v3/index.js +14 -8
- package/bin/cli/code-mods/command-logics/help-migrate-to-v3/logMatch.js +11 -11
- package/bin/cli/utils/CLI_COLORS.js +81 -0
- package/package.json +5 -3
|
@@ -1,61 +1,26 @@
|
|
|
1
|
-
import
|
|
1
|
+
import {
|
|
2
|
+
severityLoggingMap,
|
|
3
|
+
yellowStr,
|
|
4
|
+
boldCyanStr,
|
|
5
|
+
boldGreenStr,
|
|
6
|
+
brightCyanStr,
|
|
7
|
+
whiteStr,
|
|
8
|
+
} from '../../../utils/CLI_COLORS';
|
|
2
9
|
import { DEPRECATED_PACKAGES } from './constants';
|
|
3
|
-
// Colors
|
|
4
|
-
// black
|
|
5
|
-
// red
|
|
6
|
-
// green
|
|
7
|
-
// yellow
|
|
8
|
-
// blue
|
|
9
|
-
// magenta
|
|
10
|
-
// cyan
|
|
11
|
-
// white
|
|
12
|
-
// blackBright (alias: gray, grey)
|
|
13
|
-
// redBright
|
|
14
|
-
// greenBright
|
|
15
|
-
// yellowBright
|
|
16
|
-
// blueBright
|
|
17
|
-
// magentaBright
|
|
18
|
-
// cyanBright
|
|
19
|
-
// whiteBright
|
|
20
|
-
|
|
21
|
-
// Background colors
|
|
22
|
-
// bgBlack
|
|
23
|
-
// bgRed
|
|
24
|
-
// bgGreen
|
|
25
|
-
// bgYellow
|
|
26
|
-
// bgBlue
|
|
27
|
-
// bgMagenta
|
|
28
|
-
// bgCyan
|
|
29
|
-
// bgWhite
|
|
30
|
-
// bgBlackBright (alias: bgGray, bgGrey)
|
|
31
|
-
// bgRedBright
|
|
32
|
-
// bgGreenBright
|
|
33
|
-
// bgYellowBright
|
|
34
|
-
// bgBlueBright
|
|
35
|
-
// bgMagentaBright
|
|
36
|
-
// bgCyanBright
|
|
37
|
-
// bgWhiteBright
|
|
38
|
-
|
|
39
|
-
const chalkMap = {
|
|
40
|
-
1: chalk.bold.yellowBright.bgRed,
|
|
41
|
-
2: chalk.bold.redBright,
|
|
42
|
-
3: chalk.bold.red,
|
|
43
|
-
4: chalk.red,
|
|
44
|
-
};
|
|
45
10
|
|
|
46
11
|
const logDeprecatedComponent = ({ name, solution, severity, confluence }) => {
|
|
47
12
|
const [sevDesc, sevLevel] = severity;
|
|
48
|
-
const chalkLog =
|
|
49
|
-
console.log(
|
|
50
|
-
console.log(
|
|
13
|
+
const chalkLog = severityLoggingMap[sevLevel];
|
|
14
|
+
console.log(yellowStr('--------------------------------'));
|
|
15
|
+
console.log(boldCyanStr(`${name} deprecation!`));
|
|
51
16
|
console.log(chalkLog(sevDesc));
|
|
52
|
-
console.log(
|
|
53
|
-
console.log(
|
|
54
|
-
console.log(
|
|
17
|
+
console.log(boldGreenStr(solution));
|
|
18
|
+
console.log(whiteStr(confluence));
|
|
19
|
+
console.log(yellowStr('--------------------------------'));
|
|
55
20
|
};
|
|
56
21
|
|
|
57
22
|
export function logCyanQuestion(question) {
|
|
58
|
-
console.log(
|
|
23
|
+
console.log(brightCyanStr(question));
|
|
59
24
|
}
|
|
60
25
|
|
|
61
26
|
export function logResults(detectedPackages) {
|
|
@@ -1,23 +1,29 @@
|
|
|
1
1
|
/* eslint-disable no-console */
|
|
2
2
|
import depcheck from 'depcheck';
|
|
3
|
-
import
|
|
3
|
+
import {
|
|
4
|
+
brightYellowStr,
|
|
5
|
+
brightRedStr,
|
|
6
|
+
brightMagentaStr,
|
|
7
|
+
boldBrightCyanStr,
|
|
8
|
+
greenStr,
|
|
9
|
+
} from '../../../utils/CLI_COLORS';
|
|
4
10
|
import { generatePathFromCurrentFolder } from '../../../utils';
|
|
5
11
|
|
|
6
12
|
const logUnusedDep = (unused) => {
|
|
7
|
-
console.log(
|
|
13
|
+
console.log(brightYellowStr('### Found unused dependencies :>>'));
|
|
8
14
|
console.log('```');
|
|
9
15
|
console.log(unused.dependencies);
|
|
10
16
|
console.log('```');
|
|
11
17
|
};
|
|
12
18
|
const logUnusedDevDep = (unused) => {
|
|
13
|
-
console.log(
|
|
19
|
+
console.log(brightMagentaStr('### Found unused dev dependencies :>>'));
|
|
14
20
|
console.log('```');
|
|
15
21
|
console.log(unused.devDependencies);
|
|
16
22
|
console.log('```');
|
|
17
23
|
};
|
|
18
24
|
const logMissing = (unused) => {
|
|
19
25
|
const missingString = [...Object.keys(unused.missing)].map((pack) => `\t${pack}`).join(',\n');
|
|
20
|
-
console.log(
|
|
26
|
+
console.log(brightRedStr('### Found missing dependencies :>>'));
|
|
21
27
|
console.log('```');
|
|
22
28
|
console.log('{');
|
|
23
29
|
console.log(missingString);
|
|
@@ -72,11 +78,11 @@ export const checkMissingPackages = async (options) => {
|
|
|
72
78
|
const unusedDevDep = Array.isArray(unused.devDependencies) && unused.devDependencies.length > 0;
|
|
73
79
|
const missing = Object.keys(unused.missing).length > 0;
|
|
74
80
|
const hasErrors = unusedDep || unusedDevDep || missing;
|
|
75
|
-
console.log(
|
|
76
|
-
console.log(
|
|
81
|
+
console.log(boldBrightCyanStr(`# Dependencies results for ${pathToRoot}`));
|
|
82
|
+
console.log(boldBrightCyanStr(`[${pathToRoot}](${pathToRoot}package.json)`));
|
|
77
83
|
if (unusedDep) logUnusedDep(unused);
|
|
78
84
|
if (unusedDevDep) logUnusedDevDep(unused);
|
|
79
85
|
if (missing) logMissing(unused);
|
|
80
|
-
if (!hasErrors) console.log(
|
|
86
|
+
if (!hasErrors) console.log(greenStr(`no problems found!`));
|
|
81
87
|
});
|
|
82
88
|
};
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
|
-
import
|
|
2
|
+
import {
|
|
3
|
+
yellowStr,
|
|
4
|
+
boldBrightYellowBgRedStr,
|
|
5
|
+
brightYellowStr,
|
|
6
|
+
boldRedStr,
|
|
7
|
+
boldBrightCyanStr,
|
|
8
|
+
} from '../../../utils/CLI_COLORS';
|
|
3
9
|
import { getPackageJsonEmDsVersions } from './getPackageJsonEmDsVersions';
|
|
4
10
|
import {
|
|
5
11
|
generatePathFromCurrentFolder,
|
|
@@ -39,18 +45,18 @@ export const checkPackagesInconsistencies = async (options) => {
|
|
|
39
45
|
const highestVersion = getHighestMatchVersion(matches);
|
|
40
46
|
const { errors, hasErrors } = getErrors(highestVersion, matches);
|
|
41
47
|
if (hasErrors) {
|
|
42
|
-
console.log(
|
|
48
|
+
console.log(yellowStr('Your Package json has some Elliemae dimsum inconsistencies'));
|
|
43
49
|
console.log(errors);
|
|
44
|
-
console.log(
|
|
50
|
+
console.log(yellowStr('Please solve them as soon as possible to avoid unexpected errors'));
|
|
45
51
|
}
|
|
46
52
|
const shouldUpdateToNewest =
|
|
47
53
|
highestVersion.major < latestVersionParsed.major ||
|
|
48
54
|
(highestVersion.major === latestVersionParsed.major && highestVersion.minor < latestVersionParsed.minor - 6);
|
|
49
55
|
if (shouldUpdateToNewest) {
|
|
50
|
-
console.log(
|
|
51
|
-
console.log(
|
|
52
|
-
console.log(
|
|
53
|
-
console.log(
|
|
56
|
+
console.log(boldBrightYellowBgRedStr('We detected that you are using a version that is too outdated'));
|
|
57
|
+
console.log(brightYellowStr(`Detected (highest) version:`, boldRedStr(highestVersion.fullVersion)));
|
|
58
|
+
console.log(brightYellowStr(`Latest version:`, boldBrightCyanStr(latestVersionParsed.fullVersion)));
|
|
59
|
+
console.log(boldBrightYellowBgRedStr('Please update to the newest version release as soon as possible!'));
|
|
54
60
|
}
|
|
55
61
|
}
|
|
56
62
|
});
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
/* eslint-disable max-statements */
|
|
2
2
|
/* eslint-disable no-console */
|
|
3
|
-
import chalk from 'chalk';
|
|
4
3
|
import util from 'util';
|
|
5
4
|
import fs from 'fs';
|
|
6
5
|
import fse from 'fs-extra';
|
|
7
6
|
import { generatePathFromCurrentFolder, globArray } from '../../../utils';
|
|
7
|
+
import {
|
|
8
|
+
brightMagentaStr,
|
|
9
|
+
boldGreenStr,
|
|
10
|
+
brightYellowStr,
|
|
11
|
+
brightRedStr,
|
|
12
|
+
brightCyanStr,
|
|
13
|
+
} from '../../../utils/CLI_COLORS';
|
|
8
14
|
import { getSolutions } from './getSolutions';
|
|
9
15
|
import { replaceFromSolutions } from './replaceFromSolutions';
|
|
10
16
|
|
|
@@ -54,31 +60,31 @@ export const helpMigrateToV3 = (options) => {
|
|
|
54
60
|
});
|
|
55
61
|
if (totals.hasErrors) {
|
|
56
62
|
console.log('\n');
|
|
57
|
-
console.log(
|
|
63
|
+
console.log(brightMagentaStr('# Found outdated import statement in:'));
|
|
58
64
|
console.log('```');
|
|
59
65
|
console.log(totals.listOfAllFilesWithErrors);
|
|
60
66
|
console.log('```');
|
|
61
67
|
console.log('\n');
|
|
62
|
-
console.log(
|
|
68
|
+
console.log(boldGreenStr('## The following files were auto-fixed'));
|
|
63
69
|
console.log('```');
|
|
64
70
|
console.log(totals.listOfFixedFiles);
|
|
65
71
|
console.log('```');
|
|
66
|
-
console.log(
|
|
72
|
+
console.log(boldGreenStr(`a total of ${totals.totalAppliedFixes} fixes were applied`));
|
|
67
73
|
if (totals.hasUnfixables) {
|
|
68
74
|
console.log('\n');
|
|
69
|
-
console.log(
|
|
75
|
+
console.log(brightRedStr('## found some problems that can not be autofixed '));
|
|
70
76
|
console.log('```');
|
|
71
77
|
console.log(util.inspect(totals.listOfUnfixableFiles, { showHidden: false, depth: null, colors: true }));
|
|
72
78
|
console.log('```');
|
|
73
79
|
console.log('\n');
|
|
74
|
-
console.log(
|
|
80
|
+
console.log(brightRedStr('you must manually solve those import statements'));
|
|
75
81
|
console.log('check https://qa.dimsum.rd.elliemae.io/ documentation to find your new import statements');
|
|
76
82
|
}
|
|
77
83
|
}
|
|
78
84
|
console.log('\n');
|
|
79
|
-
console.log(
|
|
85
|
+
console.log(brightYellowStr('# You must ensure following dependencies are present in your package.json:'));
|
|
80
86
|
console.log('```');
|
|
81
87
|
console.log(util.inspect(Object.keys(totals.convertedPackagesMap), { showHidden: false, depth: null, colors: true }));
|
|
82
88
|
console.log('```');
|
|
83
|
-
console.log(
|
|
89
|
+
console.log(brightCyanStr('Done.'));
|
|
84
90
|
};
|
|
@@ -1,33 +1,33 @@
|
|
|
1
1
|
/* eslint-disable no-console */
|
|
2
|
-
import
|
|
2
|
+
import { brightCyanStr, brightMagentaStr, yellowStr, brightGreenStr } from '../../../utils/CLI_COLORS';
|
|
3
3
|
import { getSubFolderSolution, mapComponentsToImportStatement } from './getSolutions';
|
|
4
4
|
|
|
5
5
|
const logSubfolderImport = (fullMatch, components, fullFromPack) => {
|
|
6
6
|
const { solution } = getSubFolderSolution(fullMatch, components, fullFromPack);
|
|
7
|
-
console.log(
|
|
7
|
+
console.log(brightMagentaStr('detected'));
|
|
8
8
|
console.log(fullMatch);
|
|
9
|
-
console.log(
|
|
10
|
-
console.log(
|
|
9
|
+
console.log(brightCyanStr('you should move to'));
|
|
10
|
+
console.log(brightGreenStr(solution));
|
|
11
11
|
};
|
|
12
12
|
|
|
13
13
|
const logSuggestedNewImportStatements = (fullMatch, newStatements) => {
|
|
14
|
-
console.log(
|
|
14
|
+
console.log(brightMagentaStr('detected'));
|
|
15
15
|
console.log(fullMatch);
|
|
16
|
-
console.log(
|
|
17
|
-
newStatements.forEach((statement) => console.log(
|
|
16
|
+
console.log(brightCyanStr('you should move to'));
|
|
17
|
+
newStatements.forEach((statement) => console.log(brightGreenStr(statement)));
|
|
18
18
|
};
|
|
19
19
|
|
|
20
20
|
const logUnAutoFixables = (fullMatch, unautofixables) => {
|
|
21
|
-
console.log(
|
|
21
|
+
console.log(brightMagentaStr('detected'));
|
|
22
22
|
console.log(fullMatch);
|
|
23
|
-
console.log(
|
|
23
|
+
console.log(brightCyanStr("we can't automatically suggest you any fix for"));
|
|
24
24
|
console.log(unautofixables);
|
|
25
25
|
console.log('please check https://qa.dimsum.rd.elliemae.io/ documentation to update the import statements');
|
|
26
26
|
};
|
|
27
27
|
|
|
28
28
|
export const logMatch = (match) => {
|
|
29
29
|
const { fullMatch, componentVariable, fullFromPack, optionalSubfolder } = match;
|
|
30
|
-
console.log(
|
|
30
|
+
console.log(yellowStr('--------------------------------'));
|
|
31
31
|
if (optionalSubfolder !== '') logSubfolderImport(fullMatch, componentVariable, fullFromPack);
|
|
32
32
|
else {
|
|
33
33
|
const csvComponents = componentVariable.replace(/{+/g, '').replace(/}+/g, '').replace(/\s+/g, '').split(',');
|
|
@@ -35,5 +35,5 @@ export const logMatch = (match) => {
|
|
|
35
35
|
logSuggestedNewImportStatements(fullMatch, newImportStatements);
|
|
36
36
|
if (unAutoFixables) logUnAutoFixables(fullMatch, unAutoFixables);
|
|
37
37
|
}
|
|
38
|
-
console.log(
|
|
38
|
+
console.log(yellowStr('--------------------------------'));
|
|
39
39
|
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
// https://en.wikipedia.org/wiki/ANSI_escape_code#Colors
|
|
2
|
+
export const CLI_COLORS = {
|
|
3
|
+
reset: '\x1b[0m',
|
|
4
|
+
bold: '\x1b[1m',
|
|
5
|
+
dim: '\x1b[2m',
|
|
6
|
+
underline: '\x1b[4m',
|
|
7
|
+
strikethrough: '\x1b[9m',
|
|
8
|
+
black: '\x1b[30m',
|
|
9
|
+
red: '\x1b[31m',
|
|
10
|
+
green: '\x1b[32m',
|
|
11
|
+
yellow: '\x1b[33m',
|
|
12
|
+
blue: '\x1b[34m',
|
|
13
|
+
magenta: '\x1b[35m',
|
|
14
|
+
cyan: '\x1b[36m',
|
|
15
|
+
white: '\x1b[37m',
|
|
16
|
+
gray: '\x1b[90m',
|
|
17
|
+
brightRed: '\x1b[91m',
|
|
18
|
+
brightGreen: '\x1b[92m',
|
|
19
|
+
brightYellow: '\x1b[93m',
|
|
20
|
+
brightBlue: '\x1b[94m',
|
|
21
|
+
brightMagenta: '\x1b[95m',
|
|
22
|
+
brightCyan: '\x1b[96m',
|
|
23
|
+
brightWhite: '\x1b[97m',
|
|
24
|
+
bgBlack: '\x1b[40m',
|
|
25
|
+
bgRed: '\x1b[41m',
|
|
26
|
+
bgGreen: '\x1b[42m',
|
|
27
|
+
bgYellow: '\x1b[43m',
|
|
28
|
+
bgBlue: '\x1b[44m',
|
|
29
|
+
bgMagenta: '\x1b[45m',
|
|
30
|
+
bgCyan: '\x1b[46m',
|
|
31
|
+
bgWhite: '\x1b[47m',
|
|
32
|
+
bgGray: '\x1b[100m',
|
|
33
|
+
bgBrightRed: '\x1b[101m',
|
|
34
|
+
bgBrightGreen: '\x1b[102m',
|
|
35
|
+
bgBrightYellow: '\x1b[103m',
|
|
36
|
+
bgBrightBlue: '\x1b[104m',
|
|
37
|
+
bgBrightMagenta: '\x1b[105m',
|
|
38
|
+
bgBrightCyan: '\x1b[106m',
|
|
39
|
+
bgBrightWhite: '\x1b[107m',
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const {
|
|
43
|
+
bold,
|
|
44
|
+
brightYellow,
|
|
45
|
+
red,
|
|
46
|
+
cyan,
|
|
47
|
+
green,
|
|
48
|
+
white,
|
|
49
|
+
yellow,
|
|
50
|
+
bgRed,
|
|
51
|
+
reset,
|
|
52
|
+
brightRed,
|
|
53
|
+
brightCyan,
|
|
54
|
+
brightMagenta,
|
|
55
|
+
brightGreen,
|
|
56
|
+
} = CLI_COLORS;
|
|
57
|
+
export const boldBrightYellowBgRedStr = (str) => `${bold}${brightYellow}${bgRed}${str}${reset}`;
|
|
58
|
+
|
|
59
|
+
export const boldBrightRedStr = (str) => `${bold}${brightRed}${str}${reset}`;
|
|
60
|
+
export const boldRedStr = (str) => `${bold}${red}${str}${reset}`;
|
|
61
|
+
export const boldBrightCyanStr = (str) => `${bold}${brightCyan}${str}${reset}`;
|
|
62
|
+
export const boldCyanStr = (str) => `${bold}${cyan}${str}${reset}`;
|
|
63
|
+
export const boldGreenStr = (str) => `${bold}${green}${str}${reset}`;
|
|
64
|
+
|
|
65
|
+
export const brightGreenStr = (str) => `${brightGreen}${str}${reset}`;
|
|
66
|
+
export const brightRedStr = (str) => `${brightRed}${str}${reset}`;
|
|
67
|
+
export const brightMagentaStr = (str) => `${brightMagenta}${str}${reset}`;
|
|
68
|
+
export const brightCyanStr = (str) => `${brightCyan}${str}${reset}`;
|
|
69
|
+
export const brightYellowStr = (str) => `${brightYellow}${str}${reset}`;
|
|
70
|
+
|
|
71
|
+
export const greenStr = (str) => `${green}${str}${reset}`;
|
|
72
|
+
export const redStr = (str) => `${red}${str}${reset}`;
|
|
73
|
+
export const whiteStr = (str) => `${white}${str}${reset}`;
|
|
74
|
+
export const yellowStr = (str) => `${yellow}${str}${reset}`;
|
|
75
|
+
|
|
76
|
+
export const severityLoggingMap = {
|
|
77
|
+
1: boldBrightYellowBgRedStr,
|
|
78
|
+
2: boldBrightRedStr,
|
|
79
|
+
3: boldRedStr,
|
|
80
|
+
4: redStr,
|
|
81
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elliemae/ds-codemods",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.12.0-next.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "ICE MT - Dimsum - Code Mods",
|
|
6
6
|
"files": [
|
|
@@ -31,7 +31,6 @@
|
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"arg": "~5.0.1",
|
|
34
|
-
"chalk": "~4.1.2",
|
|
35
34
|
"depcheck": "~1.4.3",
|
|
36
35
|
"esm": "~3.2.25",
|
|
37
36
|
"fs": "~0.0.1-security",
|
|
@@ -47,8 +46,11 @@
|
|
|
47
46
|
},
|
|
48
47
|
"scripts": {
|
|
49
48
|
"try-codemods": "npx ./",
|
|
49
|
+
"dev:install": "pnpm --filter {.}... i --no-lockfile",
|
|
50
|
+
"eslint:fix": "eslint --ext='.js,.jsx,.test.js,.ts,.tsx' --fix --config='../../.eslintrc.js' bin/",
|
|
50
51
|
"try-check-deprecated-packages": "npx ./ check-deprecated-packages --cwd=\"test-ables/check-deprecated-packages/with-deprecated\"",
|
|
51
52
|
"try-check-deprecated-packages-no-dimsum": "npx ./ check-deprecated-packages --cwd=\"test-ables/check-deprecated-packages/without-dimsum-packages\"",
|
|
52
|
-
"try-help-migrate-to-v3": "npx ./ help-migrate-to-v3 --globPattern=\"test-ables/help-migrate-to-v3/**/*.js,./**/*.jsx,./**/*.ts,./**/*.tsx\" --globPatternIgnore=\"**/node_modules/**/*\""
|
|
53
|
+
"try-help-migrate-to-v3": "npx ./ help-migrate-to-v3 --globPattern=\"test-ables/help-migrate-to-v3/**/*.js,./**/*.jsx,./**/*.ts,./**/*.tsx\" --globPatternIgnore=\"**/node_modules/**/*\"",
|
|
54
|
+
"checkDeps": "exit 0 | echo"
|
|
53
55
|
}
|
|
54
56
|
}
|