@elliemae/ds-codemods 1.53.4-rc.2 → 1.53.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/.eslintrc.js +3 -3
- package/CHANGELOG.md +49 -930
- package/package.json +13 -1
- package/src/cli/code-mods/cli.js +6 -0
- package/src/cli/code-mods/command-arguments/promptCheckEmPackagesInconsistencies.js +3 -2
- package/src/cli/code-mods/command-arguments/promptFixLegacyImports.js +3 -2
- package/src/cli/code-mods/command-arguments/promptMissingPackages.js +29 -0
- package/src/cli/code-mods/command-logics/check-missing-packages/index.js +63 -0
- package/src/cli/code-mods/command-logics/execute-commands-map.js +4 -0
- package/src/cli/code-mods/commands.js +1 -0
- package/src/cli/code-mods/inquirer-questions-prompter.js +4 -0
- /package/test-ables/fix-legacy-imports/{legacy-react-ts.tsx → legacy-react-ts.tsx.mock} +0 -0
- /package/test-ables/fix-legacy-imports/{legacy-react-ts2.tsx → legacy-react-ts2.tsx.mock} +0 -0
- /package/test-ables/fix-legacy-imports/{legacy-react.jsx → legacy-react.jsx.mock} +0 -0
- /package/test-ables/fix-legacy-imports/{legacy-react2.jsx → legacy-react2.jsx.mock} +0 -0
- /package/test-ables/fix-legacy-imports/{legacy-ts.ts → legacy-ts.ts.mock} +0 -0
- /package/test-ables/fix-legacy-imports/{legacy-ts2.ts → legacy-ts2.ts.mock} +0 -0
- /package/test-ables/fix-legacy-imports/{legacy1.js → legacy1.js.mock} +0 -0
- /package/test-ables/fix-legacy-imports/{legacy2.js → legacy2.js.mock} +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elliemae/ds-codemods",
|
|
3
|
-
"version": "1.53.4
|
|
3
|
+
"version": "1.53.4",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Ellie Mae - Dim Sum - Code Mods",
|
|
6
6
|
"module": "esm/index.js",
|
|
@@ -22,13 +22,25 @@
|
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"arg": "^5.0.0",
|
|
25
|
+
"chalk": "^4.1.2",
|
|
26
|
+
"depcheck": "^1.4.2",
|
|
25
27
|
"esm": "^3.2.25",
|
|
26
28
|
"fs": "0.0.1-security",
|
|
27
29
|
"fs-extra": "^9.1.0",
|
|
28
30
|
"glob": "^7.1.6",
|
|
29
31
|
"inquirer": "^8.0.0",
|
|
32
|
+
"pacote": "^11.3.5",
|
|
30
33
|
"path": "^0.12.7"
|
|
31
34
|
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"babel-eslint": "^10.1.0",
|
|
37
|
+
"eslint-config-airbnb": "^18.2.1",
|
|
38
|
+
"eslint-config-prettier": "^8.3.0",
|
|
39
|
+
"eslint-plugin-import": "^2.24.2",
|
|
40
|
+
"eslint-plugin-jsx-a11y": "^6.4.1",
|
|
41
|
+
"eslint-plugin-prettier": "^4.0.0",
|
|
42
|
+
"eslint-plugin-react": "^7.25.1"
|
|
43
|
+
},
|
|
32
44
|
"publishConfig": {
|
|
33
45
|
"access": "public"
|
|
34
46
|
},
|
package/src/cli/code-mods/cli.js
CHANGED
|
@@ -7,6 +7,9 @@ function parseArgumentsIntoOptions(rawArgs) {
|
|
|
7
7
|
{
|
|
8
8
|
'--globPattern': String,
|
|
9
9
|
'--globPatternIgnore': String,
|
|
10
|
+
'--projectFolderPath': String,
|
|
11
|
+
'--ignorePackagesGlobPattern': String,
|
|
12
|
+
'--ignoreFilesGlobPattern': String,
|
|
10
13
|
},
|
|
11
14
|
{
|
|
12
15
|
argv: rawArgs.slice(2),
|
|
@@ -15,6 +18,9 @@ function parseArgumentsIntoOptions(rawArgs) {
|
|
|
15
18
|
return {
|
|
16
19
|
globPattern: args['--globPattern'],
|
|
17
20
|
globPatternIgnore: args['--globPatternIgnore'],
|
|
21
|
+
projectFolderPath: args['--projectFolderPath'],
|
|
22
|
+
ignorePackagesGlobPattern: args['--ignorePackagesGlobPattern'],
|
|
23
|
+
ignoreFilesGlobPattern: args['--ignoreFilesGlobPattern'],
|
|
18
24
|
script: args._[0],
|
|
19
25
|
};
|
|
20
26
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export const getPackagesInconsistenciesQuestions = (originalOptions) => {
|
|
2
2
|
const extraOptions = [];
|
|
3
|
-
|
|
3
|
+
const { globPattern, globPatternIgnore } = originalOptions;
|
|
4
|
+
if (!globPattern && globPattern !== '') {
|
|
4
5
|
extraOptions.push({
|
|
5
6
|
type: 'input',
|
|
6
7
|
name: 'globPattern',
|
|
@@ -9,7 +10,7 @@ export const getPackagesInconsistenciesQuestions = (originalOptions) => {
|
|
|
9
10
|
default: './package.json', // './packages/ds-codemods/test-ables/check-packages-inconsistencies/package.json.test',
|
|
10
11
|
});
|
|
11
12
|
}
|
|
12
|
-
if (!
|
|
13
|
+
if (!globPatternIgnore && globPatternIgnore !== '') {
|
|
13
14
|
extraOptions.push({
|
|
14
15
|
type: 'input',
|
|
15
16
|
name: 'globPatternIgnore',
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export const getLegacyImportsQuestions = (originalOptions) => {
|
|
2
2
|
const extraOptions = [];
|
|
3
|
-
|
|
3
|
+
const { globPattern, globPatternIgnore } = originalOptions;
|
|
4
|
+
if (!globPattern && globPattern !== '') {
|
|
4
5
|
extraOptions.push({
|
|
5
6
|
type: 'input',
|
|
6
7
|
name: 'globPattern',
|
|
@@ -8,7 +9,7 @@ export const getLegacyImportsQuestions = (originalOptions) => {
|
|
|
8
9
|
default: './**/*.js,./**/*.jsx,./**/*.ts,./**/*.tsx',
|
|
9
10
|
});
|
|
10
11
|
}
|
|
11
|
-
if (!
|
|
12
|
+
if (!globPatternIgnore && globPatternIgnore !== '') {
|
|
12
13
|
extraOptions.push({
|
|
13
14
|
type: 'input',
|
|
14
15
|
name: 'globPatternIgnore',
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export const getMissingPackagesQuestions = (originalOptions) => {
|
|
2
|
+
const extraOptions = [];
|
|
3
|
+
const { projectFolderPath, ignorePackagesGlobPattern, ignoreFilesGlobPattern } = originalOptions;
|
|
4
|
+
if (!projectFolderPath && projectFolderPath !== '') {
|
|
5
|
+
extraOptions.push({
|
|
6
|
+
type: 'input',
|
|
7
|
+
name: 'projectFolderPath',
|
|
8
|
+
message: 'path to the project folder containing package.json file',
|
|
9
|
+
default: './',
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
if (!ignorePackagesGlobPattern && ignorePackagesGlobPattern !== '') {
|
|
13
|
+
extraOptions.push({
|
|
14
|
+
type: 'input',
|
|
15
|
+
name: 'ignorePackagesGlobPattern',
|
|
16
|
+
message: 'Please provide a comma separated list of globPatterns for ignored packages, if any.',
|
|
17
|
+
default: '',
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
if (!ignoreFilesGlobPattern && ignoreFilesGlobPattern !== '') {
|
|
21
|
+
extraOptions.push({
|
|
22
|
+
type: 'input',
|
|
23
|
+
name: 'ignoreFilesGlobPattern',
|
|
24
|
+
message: 'Please provide a comma separated list of globPatterns for ignored files, if any.',
|
|
25
|
+
default: '**/*.eslintrc.js',
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
return extraOptions;
|
|
29
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import depcheck from 'depcheck';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import { generatePathFromCurrentFolder } from '../../../utils';
|
|
4
|
+
export const checkMissingPackages = async (options) => {
|
|
5
|
+
const { projectFolderPath, ignorePackagesGlobPattern, ignoreFilesGlobPattern } = options;
|
|
6
|
+
const ignorePatterns = ignorePackagesGlobPattern
|
|
7
|
+
.split(',')
|
|
8
|
+
.map((pattern) => (pattern && pattern !== '' ? generatePathFromCurrentFolder(pattern) : ''));
|
|
9
|
+
const ignoreMatches = ignoreFilesGlobPattern
|
|
10
|
+
.split(',')
|
|
11
|
+
.map((pattern) => (pattern && pattern !== '' ? generatePathFromCurrentFolder(pattern) : ''));
|
|
12
|
+
const depCheckOptions = {
|
|
13
|
+
ignoreBinPackage: false, // ignore the packages with bin entry
|
|
14
|
+
skipMissing: false, // skip calculation of missing dependencies
|
|
15
|
+
parsers: {
|
|
16
|
+
// the target parsers
|
|
17
|
+
'**/*.js': depcheck.parser.jsx,
|
|
18
|
+
'**/*.jsx': depcheck.parser.jsx,
|
|
19
|
+
'**/*.ts': depcheck.parser.typescript,
|
|
20
|
+
'**/*.tsx': depcheck.parser.typescript,
|
|
21
|
+
},
|
|
22
|
+
detectors: [
|
|
23
|
+
depcheck.detector.requireCallExpression,
|
|
24
|
+
depcheck.detector.requireResolveCallExpression,
|
|
25
|
+
depcheck.detector.importDeclaration,
|
|
26
|
+
depcheck.detector.typescriptImportType,
|
|
27
|
+
depcheck.detector.exportDeclaration,
|
|
28
|
+
],
|
|
29
|
+
specials: [
|
|
30
|
+
// the target special parsers
|
|
31
|
+
depcheck.special.babel,
|
|
32
|
+
depcheck.special.bin,
|
|
33
|
+
depcheck.special.eslint,
|
|
34
|
+
depcheck.special.husky,
|
|
35
|
+
depcheck.special.jest,
|
|
36
|
+
depcheck.special.mocha,
|
|
37
|
+
depcheck.special.prettier,
|
|
38
|
+
depcheck.special.tslint,
|
|
39
|
+
depcheck.special.webpack,
|
|
40
|
+
],
|
|
41
|
+
ignorePatterns,
|
|
42
|
+
ignoreMatches,
|
|
43
|
+
};
|
|
44
|
+
const pathToRoot = generatePathFromCurrentFolder(projectFolderPath);
|
|
45
|
+
console.log(chalk.bold.cyanBright(`Dependencies results for ${pathToRoot}`));
|
|
46
|
+
depcheck(pathToRoot, depCheckOptions).then((unused) => {
|
|
47
|
+
let noError = true;
|
|
48
|
+
if (Array.isArray(unused.dependencies) && unused.dependencies.length > 0) {
|
|
49
|
+
noError = false;
|
|
50
|
+
console.log(chalk.yellowBright('Found unused dependencies :>> '), unused.dependencies);
|
|
51
|
+
}
|
|
52
|
+
if (Array.isArray(unused.devDependencies) && unused.devDependencies.length > 0) {
|
|
53
|
+
noError = false;
|
|
54
|
+
console.log(chalk.magentaBright('Found unused dev dependencies :>> '), unused.devDependencies);
|
|
55
|
+
}
|
|
56
|
+
if (Object.keys(unused.missing).length > 0) {
|
|
57
|
+
noError = false;
|
|
58
|
+
console.log(chalk.redBright('Found missing dependencies :>> '), unused.missing);
|
|
59
|
+
}
|
|
60
|
+
if (noError) console.log(chalk.bold.greenBright(`no errors found!`));
|
|
61
|
+
console.log('\n');
|
|
62
|
+
});
|
|
63
|
+
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { fixLegacyImports } from './fix-legacy-imports';
|
|
2
2
|
import { checkPackagesInconsistencies } from './check-packages-inconsistencies';
|
|
3
|
+
import { checkMissingPackages } from './check-missing-packages';
|
|
3
4
|
import { COMMANDS } from '../commands';
|
|
4
5
|
|
|
5
6
|
export async function executeCommandsMap(args, options) {
|
|
@@ -13,6 +14,9 @@ export async function executeCommandsMap(args, options) {
|
|
|
13
14
|
case COMMANDS.CHECK_PACKAGES_INCONSISTENCIES:
|
|
14
15
|
checkPackagesInconsistencies(options);
|
|
15
16
|
break;
|
|
17
|
+
case COMMANDS.CHECK_MISSING_PACKAGES:
|
|
18
|
+
checkMissingPackages(options);
|
|
19
|
+
break;
|
|
16
20
|
default:
|
|
17
21
|
break;
|
|
18
22
|
}
|
|
@@ -2,6 +2,7 @@ export const COMMANDS = {
|
|
|
2
2
|
FIX_LEGACY_IMPORTS: 'fix-legacy-imports',
|
|
3
3
|
FIX_LEGACY_IMPORTS_REVERT: 'fix-legacy-imports:revert',
|
|
4
4
|
CHECK_PACKAGES_INCONSISTENCIES: 'check-packages-inconsistencies',
|
|
5
|
+
CHECK_MISSING_PACKAGES: 'check-missing-packages',
|
|
5
6
|
EXIT: 'exit',
|
|
6
7
|
};
|
|
7
8
|
|
|
@@ -2,6 +2,7 @@ import inquirer from 'inquirer';
|
|
|
2
2
|
import { COMMANDS, COMMANDS_ARRAY } from './commands';
|
|
3
3
|
import { getLegacyImportsQuestions } from './command-arguments/promptFixLegacyImports';
|
|
4
4
|
import { getPackagesInconsistenciesQuestions } from './command-arguments/promptCheckEmPackagesInconsistencies';
|
|
5
|
+
import { getMissingPackagesQuestions } from './command-arguments/promptMissingPackages';
|
|
5
6
|
|
|
6
7
|
async function promptForMissingScriptSpecificOptions({ originalOptions, promptOptions }) {
|
|
7
8
|
const script = originalOptions.script || promptOptions.script;
|
|
@@ -14,6 +15,9 @@ async function promptForMissingScriptSpecificOptions({ originalOptions, promptOp
|
|
|
14
15
|
case COMMANDS.CHECK_PACKAGES_INCONSISTENCIES:
|
|
15
16
|
scriptQuestions.push(...getPackagesInconsistenciesQuestions(originalOptions));
|
|
16
17
|
break;
|
|
18
|
+
case COMMANDS.CHECK_MISSING_PACKAGES:
|
|
19
|
+
scriptQuestions.push(...getMissingPackagesQuestions(originalOptions));
|
|
20
|
+
break;
|
|
17
21
|
default:
|
|
18
22
|
break;
|
|
19
23
|
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|